Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
THREE.OrbitControls = function (object, domElement) {
this.object = object;
this.domElement = (domElement === undefined) ? document : domElement;
// Set to false to disable this control
this.enabled = true;
// "target" sets the location of focus, where the object orbits around
this.target = new THREE.Vector3();
// How far you can dolly in and out ( PerspectiveCamera only )
this.minDistance = 0;
this.maxDistance = Infinity;
// How far you can zoom in and out ( OrthographicCamera only )
this.minZoom = 0;
this.maxZoom = Infinity;
// How far you can orbit vertically, upper and lower limits.
// Range is 0 to Math.PI radians.
this.minPolarAngle = 0; // radians
this.maxPolarAngle = Math.PI; // radians
// How far you can orbit horizontally, upper and lower limits.
// If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ].
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());
}
_parseGeometry(data) {
const geometry = new THREE.Geometry();
const { vertices } = data;
for (const [ x, y, z ] of vertices) {
geometry.vertices.push(new THREE.Vector3(x, y, z));
}
const { indices, colors } = data;
for (const [ materialIndex, a, b, c ] of indices) {
const indexes = [a, b, c];
const faceColors = colors ? indexes.map(index => {
const color = colors[index];
return new THREE.Color(parseInt(color, 16) & 0xFFFFFF)
.multiplyScalar(ColorMultiplier);
}) : null;
geometry.faces.push(new THREE.Face3(a, b, c, null, faceColors, materialIndex));
}
const { textureCoords } = data;
const uvLayer = geometry.faceVertexUvs[0] = [];
// eslint-disable-next-line no-unused-vars
createArrow() {
const { type } = this.data;
this.arrow = new THREE.ArrowHelper(
new THREE.Vector3(0, 0, 1),
new THREE.Vector3(0, 0, 0),
(MarkerSizes[type] || 1) * 2,
this.getMarkerColor()
);
this.arrow.cone.material.wireframe = true;
this.el.setObject3D('arrow', this.arrow);
},
const mouseDownEvent = { type: 'mouseDown' };
const mouseUpEvent = { type: 'mouseUp', mode: _mode };
const objectChangeEvent = { type: 'objectChange' };
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 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);
domElement.addEventListener('mousemove', onPointerHover, false);
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);
domElement.addEventListener('mousemove', onPointerHover, false);
domElement.addEventListener('touchmove', onPointerHover, false);
domElement.addEventListener('mousemove', onPointerMove, false);
domElement.addEventListener('touchmove', onPointerMove, false);
domElement.addEventListener('mouseup', onPointerUp, false);
domElement.addEventListener('mouseout', onPointerUp, false);
domElement.addEventListener('touchend', onPointerUp, false);
domElement.addEventListener('touchcancel', onPointerUp, false);
domElement.addEventListener('touchleave', onPointerUp, false);
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();
update() {
const { object3D } = this.el;
const { type } = this.data;
switch (type) {
case 'UnknownLight1': {
const { _unknownVectors: [ position, rotation ] } = this.data;
object3D.position.fromArray(position);
const [ ra, rb, rc ] = rotation;
object3D.rotation.z = Math.atan2(ra, rb);
object3D.rotation.y = Math.atan2(ra, rc);
const arrow = new THREE.ArrowHelper(
new THREE.Vector3(1, 0, 0),
new THREE.Vector3(0, 0, 0),
1,
0xFFFFFF,
0.4,
0.3
);
arrow.cone.material.wireframe = true;
this.el.setObject3D('mesh', arrow);
break;
}
default:
break;
}
},
});
update() {
const { object3D } = this.el;
const { type } = this.data;
switch (type) {
case 'UnknownLight1': {
const { _unknownVectors: [ position, rotation ] } = this.data;
object3D.position.fromArray(position);
const [ ra, rb, rc ] = rotation;
object3D.rotation.z = Math.atan2(ra, rb);
object3D.rotation.y = Math.atan2(ra, rc);
const arrow = new THREE.ArrowHelper(
new THREE.Vector3(1, 0, 0),
new THREE.Vector3(0, 0, 0),
1,
0xFFFFFF,
0.4,
0.3
);
arrow.cone.material.wireframe = true;
this.el.setObject3D('mesh', arrow);
break;
}
default:
break;
}
},
});