zmahomedy Posted April 9, 2018 Share Posted April 9, 2018 Hi guys I been working on a small project where I am rotation the mesh along its y axis. I am using the following to "animate" the mesh. scene.registerBeforeRender(function () { physicalbase.rotation.y += 0.01; }); Now I like to add in GUI functionality that can stop, speed or change the direction. In the code below I am trying to stop the rotation but it doesnt work. I even tried changing the direction but that too doesnt work. I will some advice help in this regards to better understand animation in BabylonJs properly and then learn how to interact with it (chaning values etc ) with the GUI var advancedTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI"); var button1 = BABYLON.GUI.Button.CreateSimpleButton("but1", "Stop"); button1.width = "150px" button1.height = "40px"; button1.color = "white"; button1.cornerRadius = 20; button1.background = "green"; button1.onPointerUpObservable.add(function() { physicalbase.rotation.y = 0.00; }); advancedTexture.addControl(button1); Quote Link to comment Share on other sites More sharing options...
hulahula Posted April 9, 2018 Share Posted April 9, 2018 here you go : https://www.babylonjs-playground.com/#6U2N0G Quote Link to comment Share on other sites More sharing options...
JohnK Posted April 9, 2018 Share Posted April 9, 2018 Hi @zmahomedy and welcome to the forum. A playground is always helpful and I see that @Alenvei just beat me to it. Your GUI resets the rotation to 0 but your animation loop keeps incrementing the rotation. https://www.babylonjs-playground.com/#VLQF20 hulahula 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.