let city: any;
const A = () => {
let box: BABYLON.Mesh
const onSceneReady: OnSceneReadyHandler = (scene) => {
// Set background transparent
scene.clearColor = new BABYLON.Color4(0, 0, 0, 0);
// This creates and positions a free camera (non-mesh)
var camera = new BABYLON.FreeCamera('camera1', new BABYLON.Vector3(0, 5, -10), scene)
// This targets the camera to scene origin
camera.setTarget(BABYLON.Vector3.Zero())
const canvas = scene.getEngine().getRenderingCanvas()
// This attaches the camera to the canvas
camera.attachControl(canvas, true)
// This creates a light, aiming 0,1,0 - to the sky (non-mesh)
const light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(0, 1, 0), scene);
light.intensity = 5;
let city: any;
//load city background
const result = SceneLoader.ImportMeshAsync(null, "/glb/", "city.glb", scene).then((result) => {
city = result.meshes[0];
//city.position.z = -1;
city.position.y = 2;
city.position.z = -3;
});
}
/**
* Will run on every frame render. We are spinning the box on y-axis.
*/
const onRender: OnRenderHandler = (scene) => {
console.log("renderitnginignign");
if (city != undefined) {
var deltaTimeInMillis = scene.getEngine().getDeltaTime()
const rpm = 10
city.rotation.y += (rpm / 60) * Math.PI * 2 * (deltaTimeInMillis / 1000)
}
}
return {
onSceneReady,
onRender
}
}
export default A;
I loaded glb file sucefully but rotation in the onRender function
(which use in OnRender) not work
after try something I found change from
city = result.meshes[0];
to
city = result.meshes[2];
//or 3, 4 blah blah
can work sucefully rotate part of my glb file
(eg : if I load forest , only trees rotated not groud)
is there a way to select all the mesh from glb file
I loaded?
I don’t know how to access and control whole glb file not the part