DigitalHilsone Posted March 10, 2015 Share Posted March 10, 2015 We have the following hours: var createScene = function () { var scene = new BABYLON.Scene(engine); // setup environment var light0 = new BABYLON.PointLight("Omni", new BABYLON.Vector3(0, 10, 20), scene); var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 0, new BABYLON.Vector3(10, 10, 0), scene); camera.setPosition(new BABYLON.Vector3(-10, -10, -30)); camera.attachControl(canvas, true); // Impact impostor var impact = BABYLON.Mesh.CreatePlane("impact", 1, scene); impact.material = new BABYLON.StandardMaterial("impactMat", scene); impact.material.diffuseTexture = new BABYLON.Texture("textures/impact.png", scene); impact.material.diffuseTexture.hasAlpha = true; impact.position = new BABYLON.Vector3(0, 0, -0.1); //Wall var wall = BABYLON.Mesh.CreatePlane("wall", 20.0, scene); wall.material = new BABYLON.StandardMaterial("wallMat", scene); wall.material.emissiveColor = new BABYLON.Color3(0.5, 1, 0.5); //When pointer down event is raised scene.onPointerDown = function (evt, pickResult) { // if the click hits the ground object, we change the impact position if (pickResult.hit) { BABYLON.Animation.CreateAndStartAnimation("anim", impact, "position", 30, 120, impact.position, impact.position.add(new BABYLON.Vector3(pickResult.pickedPoint.x, pickResult.pickedPoint.y, 0))); } }; return scene; }Did not get to stop the animation at its conclusion. Animation is cyclical. I need to make it a single. Help me with this. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 10, 2015 Share Posted March 10, 2015 Hi, welcome to the forum. From the Animation class API... static ANIMATIONLOOPMODE_RELATIVE : number The animation loops but doesn't reset values and continues animation with values of the previous ending animation static ANIMATIONLOOPMODE_CYCLE : number The animation restarts with the inital values static ANIMATIONLOOPMODE_CONSTANT : number The animation keeps its final value i.e stoppedThe "0" at the end of your CreateAndStartAnimation call... is the optional loopMode parameter. So... I think you can change that last "0"... into BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT Again, delete the zero and replace with the above line. Should work. Report back, good luck. Quote Link to comment Share on other sites More sharing options...
DigitalHilsone Posted March 11, 2015 Author Share Posted March 11, 2015 Wingnut, write the function like this: if (pickResult.hit) {BABYLON.Animation.CreateAndStartAnimation("anim", impact, "position", 30, 30,impact.position, impact.position.add(new BABYLON.Vector3(pickResult.pickedPoint.x, pickResult.pickedPoint.y, 0)), 0); }Now the condition is met. Thank you for your help! Wingnut 1 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.