Search the Community
Showing results for tags 'autorotate'.
-
Hi, I just started learning babylonjs i have some doubts please help me I am simply making a rubix cube using MeshBox, i just simply want to rotate each block as you know what we did in Rubix Cube now my problem if i use animation for rotating 90 degree like this animationBoxY = new BABYLON.Animation("myAnimation", "rotation.y", 160, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE); animationBoxX = new BABYLON.Animation("myAnimation", "rotation.x", 160, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE); var keys = []; keys.push({ frame : 0, value : 0 }); keys.push({ frame : 100, value : Math.PI/2 }); animationBoxY.setKeys(keys); animationBoxX.setKeys(keys); window.addEventListener("keydown", handleKeyDown, false); function handleKeyDown(evt){ if (evt.keyCode==65){ Box1.animations.push(animationBoxY); scene.beginAnimation(Box1, 0, 400, true); } if (evt.keyCode==68){ Box1Copy.animations.push(animationBoxX); scene.beginAnimation(Box1Copy, 0, 110, true); } by doing this i had two problem 1. hear both the animation got combined means it's moving diagonally instead of particularly X or Y 2. if i animate in x then y so animation for y is starting with from start not the position where it was last(hope you got what I'm saying) i also tried rotation like this box1.position.x = -2; but this is not auto rotation i want that when i press a key it will rotate 90/-90 degree like in rubix cube Please help me I'm pretty new hear