将其放置在垂直平面上的面6上。 我希望此多维数据集通过单击按钮来更改其位置。 所以我单击按钮->现在面5在飞机上。再次按下-> 3在飞机上。 由此产生的顺序应该是:6 5 3 2 1 4-> 6 5。 。
我尝试了s.th。像这样:(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 :(得分:1)
我认为计数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);
}