function scaleOneAxisOnMove() { point.applyMatrix4(tempMatrix.getInverse(worldRotationMatrix)); if (scope.axis === 'X') { scope.object.scale.x = oldScale.x * (1 + point.x / oldScale.x); } if (scope.axis === 'Y') { scope.object.scale.y = oldScale.y * (1 + point.y / oldScale.y); } if (scope.axis === 'Z') { scope.object.scale.z = oldScale.z * (1 + point.z / oldScale.z); } }
// HELPERS _getCameraPosition() { if (!this.viewProjectionMatrix) { return new THREE.Vector3(); } const cam = new THREE.Camera(); const rootInverse = new THREE.Matrix4().getInverse(this.rootTransform); cam.projectionMatrix.elements = this.viewProjectionMatrix; cam.projectionMatrixInverse = new THREE.Matrix4().getInverse(cam.projectionMatrix); // add since three@0.103.0 const campos = new THREE.Vector3(0, 0, 0).unproject(cam).applyMatrix4(rootInverse); return campos; }
function rotateXYZEAxis() { let euler = new THREE.Euler(); euler.setFromVector3( point .clone() .cross(tempVector) .normalize() ); quaternionE.setFromEuler(euler); // rotation axis tempQuaternion.setFromRotationMatrix( tempMatrix.getInverse(parentRotationMatrix) ); quaternionX.setFromAxisAngle( quaternionE, -point.clone().angleTo(tempVector) ); quaternionXYZ.setFromRotationMatrix(worldRotationMatrix); tempQuaternion.multiplyQuaternions(tempQuaternion, quaternionX); tempQuaternion.multiplyQuaternions(tempQuaternion, quaternionXYZ); scope.object.quaternion.copy(tempQuaternion); }
function rotateEAxis() { point.applyMatrix4(tempMatrix.getInverse(lookAtMatrix)); tempVector.applyMatrix4(tempMatrix.getInverse(lookAtMatrix)); rotation.set( Math.atan2(point.z, point.y), Math.atan2(point.x, point.z), Math.atan2(point.y, point.x) ); offsetRotation.set( Math.atan2(tempVector.z, tempVector.y), Math.atan2(tempVector.x, tempVector.z), Math.atan2(tempVector.y, tempVector.x) ); tempQuaternion.setFromRotationMatrix( tempMatrix.getInverse(parentRotationMatrix) ); quaternionE.setFromAxisAngle(eye, offsetRotation.z - rotation.z); quaternionXYZ.setFromRotationMatrix(worldRotationMatrix); tempQuaternion.multiplyQuaternions(tempQuaternion, quaternionE); tempQuaternion.multiplyQuaternions(tempQuaternion, quaternionXYZ); scope.object.quaternion.copy(tempQuaternion); }
point.applyMatrix4(tempMatrix.getInverse(worldRotationMatrix)); point.applyMatrix4(tempMatrix.getInverse(parentRotationMatrix)); if (scope.space === 'local') { scope.object.position.applyMatrix4( tempMatrix.getInverse(worldRotationMatrix) );
tempMatrix.getInverse(parentRotationMatrix) );
function rotateLocalSpace() { point.applyMatrix4(tempMatrix.getInverse(worldRotationMatrix)); tempVector.applyMatrix4(tempMatrix.getInverse(worldRotationMatrix));