svatopluk Posted July 29, 2016 Share Posted July 29, 2016 Hello. I have the following code: var m = new BABYLON.Mesh.CreateBox('m', 1, scene); m.position = new BABYLON.Vector3.Zero(); camera.lockedTarget = m.position; var myAnimation = new BABYLON.Animation("anim", "position", 20, BABYLON.Animation.ANIMATIONTYPE_VECTOR3, BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT); var keys = []; keys.push({ frame: 0, value: m.position, }); keys.push({ frame: 20, value: new BABYLON.Vector3(m.position.x + 10, 0, m.position.z + 10), }); myAnimation.setKeys(keys); m.animations.push(myAnimation); scene.beginAnimation(m, 0, 20); The problem is that the position of mesh is changed but the camera lockedTarget is still at 0,0,0. I suspect that during the animation the m.position vector is overriden by animation inserting a new Vector3() at the place of m.position. So the camera.lockedTarget is pointing to that old(first) reference of m.position. I'm I right about this? Is there a way to sidestep this problem? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted July 30, 2016 Share Posted July 30, 2016 Hi again @svatopluk, sorry for the slow replies. http://playground.babylonjs.com/#1NE7YH#1 Line 32 updates the target every frame. Maybe not the most elegant fix, but it works. Quote Link to comment Share on other sites More sharing options...
svatopluk Posted July 30, 2016 Author Share Posted July 30, 2016 Hello again. Thanks for the reply. I just wanted to confirm my assumption. While waiting for an answer I made a solution by making 3 animations for x, y and z. Your suggestion is cleaner, so thanks again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.