Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.update = (function () {
const offset = new THREE.Vector3();
// so camera.up is the orbit axis
const quat = new THREE.Quaternion().setFromUnitVectors(object.up, new THREE.Vector3(0, 1, 0));
const quatInverse = quat.clone().inverse();
const lastPosition = new THREE.Vector3();
const lastQuaternion = new THREE.Quaternion();
return function update() {
const position = scope.object.position;
offset.copy(position).sub(scope.target);
// rotate offset to "y-axis-is-up" space
offset.applyQuaternion(quat);
// angle from z-axis around y-axis
spherical.setFromVector3(offset);
if (scope.autoRotate && state === STATE.NONE) {
rotateLeft(getAutoRotationAngle());
}
this.update = (function () {
const offset = new THREE.Vector3();
// so camera.up is the orbit axis
const quat = new THREE.Quaternion().setFromUnitVectors(object.up, new THREE.Vector3(0, 1, 0));
const quatInverse = quat.clone().inverse();
const lastPosition = new THREE.Vector3();
const lastQuaternion = new THREE.Quaternion();
return function update() {
const position = scope.object.position;
offset.copy(position).sub(scope.target);
// rotate offset to "y-axis-is-up" space
offset.applyQuaternion(quat);
// angle from z-axis around y-axis
spherical.setFromVector3(offset);
this.update = function (rotation, eye2) {
THREE.TransformGizmo.prototype.update.apply(this, arguments);
const tempMatrix = new THREE.Matrix4();
const worldRotation = new THREE.Euler(0, 0, 1);
const tempQuaternion = new THREE.Quaternion();
const unitX = new THREE.Vector3(1, 0, 0);
const unitY = new THREE.Vector3(0, 1, 0);
const unitZ = new THREE.Vector3(0, 0, 1);
const quaternionX = new THREE.Quaternion();
const quaternionY = new THREE.Quaternion();
const quaternionZ = new THREE.Quaternion();
const eye = eye2.clone();
worldRotation.copy(this.planes.XY.rotation);
tempQuaternion.setFromEuler(worldRotation);
tempMatrix.makeRotationFromQuaternion(tempQuaternion).getInverse(tempMatrix);
eye.applyMatrix4(tempMatrix);
this.traverse(child => {
tempQuaternion.setFromEuler(worldRotation);
if (child.name === 'X') {
quaternionX.setFromAxisAngle(unitX, Math.atan2(-eye.y, eye.z));
tempQuaternion.multiplyQuaternions(tempQuaternion, quaternionX);
child.quaternion.copy(tempQuaternion);
const ray = new THREE.Raycaster();
const pointerVector = new THREE.Vector2();
const point = new THREE.Vector3();
const offset = new THREE.Vector3();
const rotation = new THREE.Vector3();
const offsetRotation = new THREE.Vector3();
let scale = 1;
const lookAtMatrix = new THREE.Matrix4();
const eye = new THREE.Vector3();
const tempMatrix = new THREE.Matrix4();
const tempVector = new THREE.Vector3();
const tempQuaternion = new THREE.Quaternion();
const unitX = new THREE.Vector3(1, 0, 0);
const unitY = new THREE.Vector3(0, 1, 0);
const unitZ = new THREE.Vector3(0, 0, 1);
const quaternionXYZ = new THREE.Quaternion();
const quaternionX = new THREE.Quaternion();
const quaternionY = new THREE.Quaternion();
const quaternionZ = new THREE.Quaternion();
const quaternionE = new THREE.Quaternion();
const oldPosition = new THREE.Vector3();
const oldScale = new THREE.Vector3();
const oldRotationMatrix = new THREE.Matrix4();
const parentRotationMatrix = new THREE.Matrix4();
const parentScale = new THREE.Vector3();
this.update = function (rotation, eye2) {
THREE.TransformGizmo.prototype.update.apply(this, arguments);
const tempMatrix = new THREE.Matrix4();
const worldRotation = new THREE.Euler(0, 0, 1);
const tempQuaternion = new THREE.Quaternion();
const unitX = new THREE.Vector3(1, 0, 0);
const unitY = new THREE.Vector3(0, 1, 0);
const unitZ = new THREE.Vector3(0, 0, 1);
const quaternionX = new THREE.Quaternion();
const quaternionY = new THREE.Quaternion();
const quaternionZ = new THREE.Quaternion();
const eye = eye2.clone();
worldRotation.copy(this.planes.XY.rotation);
tempQuaternion.setFromEuler(worldRotation);
tempMatrix.makeRotationFromQuaternion(tempQuaternion).getInverse(tempMatrix);
eye.applyMatrix4(tempMatrix);
this.traverse(child => {
tempQuaternion.setFromEuler(worldRotation);
this.update = function (rotation, eye2) {
THREE.TransformGizmo.prototype.update.apply(this, arguments);
const tempMatrix = new THREE.Matrix4();
const worldRotation = new THREE.Euler(0, 0, 1);
const tempQuaternion = new THREE.Quaternion();
const unitX = new THREE.Vector3(1, 0, 0);
const unitY = new THREE.Vector3(0, 1, 0);
const unitZ = new THREE.Vector3(0, 0, 1);
const quaternionX = new THREE.Quaternion();
const quaternionY = new THREE.Quaternion();
const quaternionZ = new THREE.Quaternion();
const eye = eye2.clone();
worldRotation.copy(this.planes.XY.rotation);
tempQuaternion.setFromEuler(worldRotation);
tempMatrix.makeRotationFromQuaternion(tempQuaternion).getInverse(tempMatrix);
eye.applyMatrix4(tempMatrix);
this.traverse(child => {
tempQuaternion.setFromEuler(worldRotation);
if (child.name === 'X') {
quaternionX.setFromAxisAngle(unitX, Math.atan2(-eye.y, eye.z));
tempQuaternion.multiplyQuaternions(tempQuaternion, quaternionX);
boneIndexByKeyFrameIndex[keyFrameIndex] = boneIndex;
keyFramesByBoneIndex[boneIndex].push(keyFrame);
}
}
const tracks = [];
const boneCount = size(keyFramesByBoneIndex);
for (let boneIndex = 0; boneIndex < boneCount; boneIndex++) {
const boneKeyFrames = keyFramesByBoneIndex[boneIndex];
const timeStops = [];
const positionValues = [];
const quaternionValues = [];
for (const { time, position, rotation } of boneKeyFrames) {
timeStops.push(time);
positionValues.push(...position);
const quaternion = new THREE.Quaternion(...rotation);
quaternion.inverse();
quaternion.toArray(quaternionValues, quaternionValues.length);
}
const path = `.bones[${boneIndex}]`;
tracks.push(new THREE.VectorKeyframeTrack(`${path}.position`, timeStops, positionValues));
tracks.push(new THREE.QuaternionKeyframeTrack(`${path}.quaternion`, timeStops, quaternionValues));
}
return new THREE.AnimationClip(this.name, duration, tracks);
}
};
const lookAtMatrix = new THREE.Matrix4();
const eye = new THREE.Vector3();
const tempMatrix = new THREE.Matrix4();
const tempVector = new THREE.Vector3();
const tempQuaternion = new THREE.Quaternion();
const unitX = new THREE.Vector3(1, 0, 0);
const unitY = new THREE.Vector3(0, 1, 0);
const unitZ = new THREE.Vector3(0, 0, 1);
const quaternionXYZ = new THREE.Quaternion();
const quaternionX = new THREE.Quaternion();
const quaternionY = new THREE.Quaternion();
const quaternionZ = new THREE.Quaternion();
const quaternionE = new THREE.Quaternion();
const oldPosition = new THREE.Vector3();
const oldScale = new THREE.Vector3();
const oldRotationMatrix = new THREE.Matrix4();
const parentRotationMatrix = new THREE.Matrix4();
const parentScale = new THREE.Vector3();
const worldPosition = new THREE.Vector3();
const worldRotation = new THREE.Euler();
const worldRotationMatrix = new THREE.Matrix4();
const camPosition = new THREE.Vector3();
const camRotation = new THREE.Euler();
domElement.addEventListener('mousedown', onPointerDown, false);
domElement.addEventListener('touchstart', onPointerDown, false);
const rotation = new THREE.Vector3();
const offsetRotation = new THREE.Vector3();
let scale = 1;
const lookAtMatrix = new THREE.Matrix4();
const eye = new THREE.Vector3();
const tempMatrix = new THREE.Matrix4();
const tempVector = new THREE.Vector3();
const tempQuaternion = new THREE.Quaternion();
const unitX = new THREE.Vector3(1, 0, 0);
const unitY = new THREE.Vector3(0, 1, 0);
const unitZ = new THREE.Vector3(0, 0, 1);
const quaternionXYZ = new THREE.Quaternion();
const quaternionX = new THREE.Quaternion();
const quaternionY = new THREE.Quaternion();
const quaternionZ = new THREE.Quaternion();
const quaternionE = new THREE.Quaternion();
const oldPosition = new THREE.Vector3();
const oldScale = new THREE.Vector3();
const oldRotationMatrix = new THREE.Matrix4();
const parentRotationMatrix = new THREE.Matrix4();
const parentScale = new THREE.Vector3();
const worldPosition = new THREE.Vector3();
const worldRotation = new THREE.Euler();
const worldRotationMatrix = new THREE.Matrix4();
const camPosition = new THREE.Vector3();
this.update = function (rotation, eye2) {
THREE.TransformGizmo.prototype.update.apply(this, arguments);
const tempMatrix = new THREE.Matrix4();
const worldRotation = new THREE.Euler(0, 0, 1);
const tempQuaternion = new THREE.Quaternion();
const unitX = new THREE.Vector3(1, 0, 0);
const unitY = new THREE.Vector3(0, 1, 0);
const unitZ = new THREE.Vector3(0, 0, 1);
const quaternionX = new THREE.Quaternion();
const quaternionY = new THREE.Quaternion();
const quaternionZ = new THREE.Quaternion();
const eye = eye2.clone();
worldRotation.copy(this.planes.XY.rotation);
tempQuaternion.setFromEuler(worldRotation);
tempMatrix.makeRotationFromQuaternion(tempQuaternion).getInverse(tempMatrix);
eye.applyMatrix4(tempMatrix);
this.traverse(child => {
tempQuaternion.setFromEuler(worldRotation);
if (child.name === 'X') {
quaternionX.setFromAxisAngle(unitX, Math.atan2(-eye.y, eye.z));
tempQuaternion.multiplyQuaternions(tempQuaternion, quaternionX);
child.quaternion.copy(tempQuaternion);
}