[英]Rotate Cube around center on button click
将其放置在垂直平面上的面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);
}
编辑:
提供了到目前为止的旋转问题的解决方案(thx @Eponyme Web)。 这里的问题是,我现在不绕中心旋转。 (多维数据集的原点(0,0,0)在其他位置(因为它取决于用户上传的模型))
有没有一种简单的方法可以使旋转居中( 仅用于旋转! )?
我认为计数0和3的转换是相同的
if (this._sideCounter === 0 || 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 === 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 === 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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.