diff --git a/package/example/Shared/src/App.tsx b/package/example/Shared/src/App.tsx
index 65f489c0..e87cce10 100644
--- a/package/example/Shared/src/App.tsx
+++ b/package/example/Shared/src/App.tsx
@@ -9,6 +9,7 @@ import { CameraPan } from './CameraPan'
import { AnimationTransitionsRecording } from './AnimationTransitionsRecording'
import { ImageExample } from './ImageExample'
import { LoadFromFile } from './LoadFromFile'
+import { ChangeMaterials } from './ChangeMaterials'
// import { PhysicsCoin } from './PhysicsCoin'
// import { FadeOut } from './FadeOut'
// import { CastShadow } from './CastShadow'
@@ -52,6 +53,7 @@ function HomeScreen() {
+
{/*
@@ -91,6 +93,7 @@ function App() {
+
{/* TODO: Migrate */}
{/*
diff --git a/package/example/Shared/src/ChangeMaterials.tsx b/package/example/Shared/src/ChangeMaterials.tsx
index bc8c89b8..83032df8 100644
--- a/package/example/Shared/src/ChangeMaterials.tsx
+++ b/package/example/Shared/src/ChangeMaterials.tsx
@@ -1,40 +1,19 @@
import * as React from 'react'
-import { useCallback, useRef } from 'react'
import { Button, StyleSheet, View } from 'react-native'
-import {
- FilamentView,
- Float3,
- useRenderCallback,
- useBuffer,
- useModel,
- FilamentProvider,
- useFilamentContext,
- useWorkletCallback,
-} from 'react-native-filament'
-import { getAssetPath } from './utils/getAssetPasth'
-import { useDefaultLight } from './hooks/useDefaultLight'
+import { FilamentView, useBuffer, useModel, useFilamentContext, useWorkletCallback, Camera, FilamentContext } from 'react-native-filament'
-const penguModelPath = getAssetPath('pengu.glb')
-const leftEyeTexturePath = getAssetPath('eye_full_texture_left_blue.jpg')
-const rightEyeTexturePath = getAssetPath('eye_full_texture_right_blue.jpg')
-
-// Camera config:
-const cameraPosition: Float3 = [0, 0, 8]
-const cameraTarget: Float3 = [0, 0, 0]
-const cameraUp: Float3 = [0, 1, 0]
-const focalLengthInMillimeters = 28
-const near = 0.1
-const far = 1000
+import PenguModel from '~/assets/pengu.glb'
+import LeftEyeTexture from '~/assets/eye_full_texture_left_blue.jpg'
+import RightEyeTexture from '~/assets/eye_full_texture_right_blue.jpg'
+import { DefaultLight } from './components/DefaultLight'
function Renderer() {
- const { camera, view, renderableManager } = useFilamentContext()
-
- useDefaultLight()
+ const { renderableManager } = useFilamentContext()
- const pengu = useModel({ source: penguModelPath })
- const blueLeftEyeBuffer = useBuffer({ source: leftEyeTexturePath })
- const blueRightEyeBuffer = useBuffer({ source: rightEyeTexturePath })
+ const pengu = useModel(PenguModel)
+ const blueLeftEyeBuffer = useBuffer({ source: LeftEyeTexture })
+ const blueRightEyeBuffer = useBuffer({ source: RightEyeTexture })
const penguAsset = pengu.state === 'loaded' ? pengu.asset : undefined
const changeEyes = useWorkletCallback(() => {
@@ -59,24 +38,12 @@ function Renderer() {
renderableManager.changeMaterialTextureMap(rightEye, 'Eye_Right.002', blueRightEyeBuffer, 'sRGB')
})
- const prevAspectRatio = useRef(0)
- useRenderCallback(
- useCallback(() => {
- 'worklet'
- const aspectRatio = view.getAspectRatio()
- if (prevAspectRatio.current !== aspectRatio) {
- prevAspectRatio.current = aspectRatio
- // Setup camera lens:
- camera.setLensProjection(focalLengthInMillimeters, aspectRatio, near, far)
- }
-
- camera.lookAt(cameraPosition, cameraTarget, cameraUp)
- }, [view, camera, prevAspectRatio])
- )
-
return (
-
+
+
+
+