Hi,
I am making android app with babylonjs react native.
I import gltf model and change texture: dynamically add new images.
I change the page and load new images, go back and try to update the texture again.
I don’t want to load gltf every time.
const Screen: FunctionComponent<ViewProps> = (props: ViewProps) => {
const defaultScale = 1;
const dataContext = useContext(DataContext);
const [imagesData, setImagesData] = useState([]);
useEffect(() => {
setImagesData(dataContext.imagesData);
if (engine) {
const scene = new Scene(engine);
setScene(scene);
SceneLoader.ImportMeshAsync(null, baseUrl, "Gallery.glb", scene).then(result => {
let pic13 = scene.getMeshByName("pic13");
let picTexture = new Texture(imagesData[1], scene);
pic13.material.albedoTexture = picTexture;
}
});
}
}, [engine]);