它被放置在垂直平面的第6个面上。我想让这个立方体在点击按钮时改变位置。所以我点击按钮-->现在第5个面在平面上。再次点击按钮-->第3个面在平面上。结果应该是:6 5 3 2 1 4 --> 6 5 . . .
我尝试了类似于这样的代码:(sideCounter是点击次数的数字)
if (this._sideCounter === 0) {
this._arModelObject.matrix = matrix.compose(translation, rotation.clone().multiply(new THREE.Quaternion().setFromEuler(new THREE.Euler().setFromVector3(new THREE.Vector3(-(Math.PI / 2), 0, 0)))), scale);
}
if (this._sideCounter === 1 || this._sideCounter === 2) {
this._arModelObject.matrix = matrix.compose(translation, rotation.clone().multiply(new THREE.Quaternion().setFromEuler(new THREE.Euler().setFromVector3(new THREE.Vector3(0, -(Math.PI / 2), 0)))), scale);
}
if (this._sideCounter === 3) {
this._arModelObject.matrix = matrix.compose(translation, rotation.clone().multiply(new THREE.Quaternion().setFromEuler(new THREE.Euler().setFromVector3(new THREE.Vector3(Math.PI / 2, 0, 0)))), scale);
}
if (this._sideCounter === 4 || this._sideCounter === 5) {
this._arModelObject.matrix = matrix.compose(translation, rotation.clone().multiply(new THREE.Quaternion().setFromEuler(new THREE.Euler().setFromVector3(new THREE.Vector3(0, 0, -(Math.PI / 2))))), scale);
}
编辑:
目前已提供了一个旋转问题的解决方案(感谢 @Eponyme Web)。问题在于,我现在没有围绕中心旋转。(立方体原点(0,0,0)在其他地方(因为它取决于用户上传的模型))
有没有一种简单的方法可以将旋转居中(仅限于旋转!!)?