【发布时间】:2020-05-28 01:26:09
【问题描述】:
我已经使用 Three.js 构建了一个魔方,并且一切正常,但我想为魔方的转动制作动画。现在,当我转向一侧时,它就会卡入新位置。怎么让它慢慢转呢?
我现在使用的代码:
function turnOrangeSide(inverse) {
let x = 0;
let y = 1;
let z = 1;
orangeGroup = new THREE.Object3D();
scene.add(orangeGroup);
//This puts all the parts of the Cube that have to be turned in the group.
orangeGroup.attach(getIntersecting(rotationPointO, x, y, z + 1));
orangeGroup.attach(getIntersecting(rotationPointO, x, y, z - 1));
orangeGroup.attach(getIntersecting(rotationPointO, x, y + 1, z));
orangeGroup.attach(getIntersecting(rotationPointO, x, y - 1, z));
orangeGroup.attach(getIntersecting(rotationPointO, x, y + 1, z + 1));
orangeGroup.attach(getIntersecting(rotationPointO, x, y - 1, z + 1));
orangeGroup.attach(getIntersecting(rotationPointO, x, y + 1, z - 1));
orangeGroup.attach(getIntersecting(rotationPointO, x, y - 1, z - 1));
let rotation = Math.PI / 2
if (inverse) rotation = -Math.PI / 2
orangeGroup.rotation.x += rotation;
}
https://rekhyt2901.github.io/AlexGames/RubiksCube/RubiksCube.html 上的实时示例。
【问题讨论】:
标签: javascript animation three.js rotation