Closed tidus2020 closed 3 years ago
And the "ready" will run after many "update", and i can't rotate the cube with code "this.transform.rotation.y += 0.01;", but i can move it by "this.transform.position.x += 0.01;"
First you got it... Unity Version 2020.1 or greater.
Second, there is no mesh component, light component or camera component in the new version. There is only a BABYLON.ScriptComponent
Third, rotation in gltf uses Quaternions ... In BabylonJS, if mesh.rotationQuaternion is NOT NULL then mesh.rotation is ignored. The toolkit by default uses rotationQuaternion ... So either use the To and From Eulers adding to Y... or use mesh.addRotation(0,0.01,0)
If you absolutely want to use node.rotation instead of node.rotationQuaternion then you must NULL rotationQuaternion after you update the rotation values. There is a Scene Manager helper function to make this easy.
BABYLON.SceneManager.ValidateTransformRotation(mesh)
or (for short)
SM.ValidateTransformRotation(mesh)
Then you can use node.rotation.y += 0.01
Check this out https://forum.babylonjs.com/t/require-extension-cvtools-babylon-mesh-is-not-available/17592/9
That should help get you started
Thanks for that ! and only one question , the "ready" function will run after "update" function , i have to handle it by myself?
The execute when ready function fires after ALL nodes have been parsed and when the scene loader goes away. This is after the awake and after the start and probably several updates
Like setting with Unity2020 or Unity2021, there is no meshComponent anymore...