aframe-inspector
Version:
A visual inspector tool for A-Frame.
1,220 lines (1,219 loc) • 991 kB
JavaScript
/*! For license information please see aframe-inspector.min.js.LICENSE.txt */
(() => {
var e,
t,
n = {
759: (e, t, n) => {
'use strict';
n.d(t, { Z: () => i });
var r = n(187),
o = new (n.n(r)())();
o.setMaxListeners(0);
const i = o;
},
719: () => {
function e(t) {
return (
(e =
'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator
? function (e) {
return typeof e;
}
: function (e) {
return e &&
'function' == typeof Symbol &&
e.constructor === Symbol &&
e !== Symbol.prototype
? 'symbol'
: typeof e;
}),
e(t)
);
}
function t() {
return (
(t =
'undefined' != typeof Reflect && Reflect.get
? Reflect.get.bind()
: function (e, t, r) {
var o = n(e, t);
if (o) {
var i = Object.getOwnPropertyDescriptor(o, t);
return i.get
? i.get.call(arguments.length < 3 ? e : r)
: i.value;
}
}),
t.apply(this, arguments)
);
}
function n(e, t) {
for (
;
!Object.prototype.hasOwnProperty.call(e, t) && null !== (e = p(e));
);
return e;
}
function r(t, n) {
for (var r = 0; r < n.length; r++) {
var o = n[r];
(o.enumerable = o.enumerable || !1),
(o.configurable = !0),
'value' in o && (o.writable = !0),
Object.defineProperty(
t,
(void 0,
(i = (function (t, n) {
if ('object' !== e(t) || null === t) return t;
var r = t[Symbol.toPrimitive];
if (void 0 !== r) {
var o = r.call(t, 'string');
if ('object' !== e(o)) return o;
throw new TypeError(
'@@toPrimitive must return a primitive value.'
);
}
return String(t);
})(o.key)),
'symbol' === e(i) ? i : String(i)),
o
);
}
var i;
}
function o(e, t, n) {
return (
t && r(e.prototype, t),
n && r(e, n),
Object.defineProperty(e, 'prototype', { writable: !1 }),
e
);
}
function i(e, t) {
if (!(e instanceof t))
throw new TypeError('Cannot call a class as a function');
}
function a(e, t) {
if ('function' != typeof t && null !== t)
throw new TypeError(
'Super expression must either be null or a function'
);
(e.prototype = Object.create(t && t.prototype, {
constructor: { value: e, writable: !0, configurable: !0 }
})),
Object.defineProperty(e, 'prototype', { writable: !1 }),
t && s(e, t);
}
function s(e, t) {
return (
(s = Object.setPrototypeOf
? Object.setPrototypeOf.bind()
: function (e, t) {
return (e.__proto__ = t), e;
}),
s(e, t)
);
}
function l(e) {
var t = (function () {
if ('undefined' == typeof Reflect || !Reflect.construct) return !1;
if (Reflect.construct.sham) return !1;
if ('function' == typeof Proxy) return !0;
try {
return (
Boolean.prototype.valueOf.call(
Reflect.construct(Boolean, [], function () {})
),
!0
);
} catch (e) {
return !1;
}
})();
return function () {
var n,
r = p(e);
if (t) {
var o = p(this).constructor;
n = Reflect.construct(r, arguments, o);
} else n = r.apply(this, arguments);
return c(this, n);
};
}
function c(t, n) {
if (n && ('object' === e(n) || 'function' == typeof n)) return n;
if (void 0 !== n)
throw new TypeError(
'Derived constructors may only return object or undefined'
);
return u(t);
}
function u(e) {
if (void 0 === e)
throw new ReferenceError(
"this hasn't been initialised - super() hasn't been called"
);
return e;
}
function p(e) {
return (
(p = Object.setPrototypeOf
? Object.getPrototypeOf.bind()
: function (e) {
return e.__proto__ || Object.getPrototypeOf(e);
}),
p(e)
);
}
!(function () {
'use strict';
var e = (function (e) {
a(n, THREE.MeshBasicMaterial);
var t = l(n);
function n(e) {
var r;
return (
i(this, n),
((r = t.call(this)).depthTest = !1),
(r.depthWrite = !1),
(r.fog = !1),
(r.side = THREE.FrontSide),
(r.transparent = !0),
r.setValues(e),
(r.oldColor = r.color.clone()),
(r.oldOpacity = r.opacity),
(r.highlight = function (e) {
e
? (this.color.setRGB(1, 1, 0), (this.opacity = 1))
: (this.color.copy(this.oldColor),
(this.opacity = this.oldOpacity));
}),
r
);
}
return o(n);
})(),
n = (function (e) {
a(n, THREE.LineBasicMaterial);
var t = l(n);
function n(e) {
var r;
return (
i(this, n),
((r = t.call(this)).depthTest = !1),
(r.depthWrite = !1),
(r.fog = !1),
(r.transparent = !0),
(r.linewidth = 1),
r.setValues(e),
(r.oldColor = r.color.clone()),
(r.oldOpacity = r.opacity),
(r.highlight = function (e) {
e
? (this.color.setRGB(1, 1, 0), (this.opacity = 1))
: (this.color.copy(this.oldColor),
(this.opacity = this.oldOpacity));
}),
r
);
}
return o(n);
})(),
r = new e({ visible: !1, transparent: !1 });
(THREE.TransformGizmo = (function (e) {
a(n, THREE.Object3D);
var t = l(n);
function n() {
return i(this, n), t.apply(this, arguments);
}
return (
o(n, [
{
key: 'init',
value: function () {
(this.handles = new THREE.Object3D()),
(this.pickers = new THREE.Object3D()),
(this.planes = new THREE.Object3D()),
this.add(this.handles),
this.add(this.pickers),
this.add(this.planes);
var e = new THREE.PlaneGeometry(50, 50, 2, 2),
t = new THREE.MeshBasicMaterial({
visible: !1,
side: THREE.DoubleSide
}),
n = {
XY: new THREE.Mesh(e, t),
YZ: new THREE.Mesh(e, t),
XZ: new THREE.Mesh(e, t),
XYZE: new THREE.Mesh(e, t)
};
for (var r in ((this.activePlane = n.XYZE),
n.YZ.rotation.set(0, Math.PI / 2, 0),
n.XZ.rotation.set(-Math.PI / 2, 0, 0),
n))
(n[r].name = r),
this.planes.add(n[r]),
(this.planes[r] = n[r]);
var o = function (e, t) {
for (var n in e)
for (r = e[n].length; r--; ) {
var o = e[n][r][0],
i = e[n][r][1],
a = e[n][r][2];
(o.name = n),
(o.renderOrder = 1 / 0),
i && o.position.set(i[0], i[1], i[2]),
a && o.rotation.set(a[0], a[1], a[2]),
t.add(o);
}
};
o(this.handleGizmos, this.handles),
o(this.pickerGizmos, this.pickers),
this.traverse(function (e) {
if (e instanceof THREE.Mesh) {
e.updateMatrix();
var t = e.geometry.clone();
t.applyMatrix4(e.matrix),
(e.geometry = t),
e.position.set(0, 0, 0),
e.rotation.set(0, 0, 0),
e.scale.set(1, 1, 1);
}
});
}
},
{
key: 'highlight',
value: function (e) {
this.traverse(function (t) {
t.material &&
t.material.highlight &&
(t.name === e
? t.material.highlight(!0)
: t.material.highlight(!1));
});
}
},
{
key: 'update',
value: function (e, t) {
var n = new THREE.Vector3(0, 0, 0),
r = new THREE.Vector3(0, 1, 0),
o = new THREE.Matrix4();
this.traverse(function (i) {
-1 !== i.name.search('E')
? i.quaternion.setFromRotationMatrix(o.lookAt(t, n, r))
: (-1 === i.name.search('X') &&
-1 === i.name.search('Y') &&
-1 === i.name.search('Z')) ||
i.quaternion.setFromEuler(e);
});
}
}
]),
n
);
})()),
(THREE.TransformGizmoTranslate = (function (t) {
a(c, THREE.TransformGizmo);
var s = l(c);
function c() {
var t;
i(this, c), (t = s.call(this));
var o = new THREE.ConeGeometry(0.05, 0.2, 12, 1, !1);
o.translate(0, 0.5, 0);
var a = new THREE.BufferGeometry();
a.setAttribute(
'position',
new THREE.Float32BufferAttribute([0, 0, 0, 1, 0, 0], 3)
);
var l = new THREE.BufferGeometry();
l.setAttribute(
'position',
new THREE.Float32BufferAttribute([0, 0, 0, 0, 1, 0], 3)
);
var u = new THREE.BufferGeometry();
return (
u.setAttribute(
'position',
new THREE.Float32BufferAttribute([0, 0, 0, 0, 0, 1], 3)
),
(t.handleGizmos = {
X: [
[
new THREE.Mesh(o, new e({ color: 16711680 })),
[0.5, 0, 0],
[0, 0, -Math.PI / 2]
],
[new THREE.Line(a, new n({ color: 16711680 }))]
],
Y: [
[new THREE.Mesh(o, new e({ color: 65280 })), [0, 0.5, 0]],
[new THREE.Line(l, new n({ color: 65280 }))]
],
Z: [
[
new THREE.Mesh(o, new e({ color: 255 })),
[0, 0, 0.5],
[Math.PI / 2, 0, 0]
],
[new THREE.Line(u, new n({ color: 255 }))]
],
XYZ: [
[
new THREE.Mesh(
new THREE.OctahedronGeometry(0.1, 0),
new e({ color: 16777215, opacity: 0.25 })
),
[0, 0, 0],
[0, 0, 0]
]
],
XY: [
[
new THREE.Mesh(
new THREE.PlaneGeometry(0.29, 0.29),
new e({ color: 16776960, opacity: 0.25 })
),
[0.15, 0.15, 0]
]
],
YZ: [
[
new THREE.Mesh(
new THREE.PlaneGeometry(0.29, 0.29),
new e({ color: 65535, opacity: 0.25 })
),
[0, 0.15, 0.15],
[0, Math.PI / 2, 0]
]
],
XZ: [
[
new THREE.Mesh(
new THREE.PlaneGeometry(0.29, 0.29),
new e({ color: 16711935, opacity: 0.25 })
),
[0.15, 0, 0.15],
[-Math.PI / 2, 0, 0]
]
]
}),
(t.pickerGizmos = {
X: [
[
new THREE.Mesh(
new THREE.CylinderGeometry(0.2, 0, 1, 4, 1, !1),
r
),
[0.6, 0, 0],
[0, 0, -Math.PI / 2]
]
],
Y: [
[
new THREE.Mesh(
new THREE.CylinderGeometry(0.2, 0, 1, 4, 1, !1),
r
),
[0, 0.6, 0]
]
],
Z: [
[
new THREE.Mesh(
new THREE.CylinderGeometry(0.2, 0, 1, 4, 1, !1),
r
),
[0, 0, 0.6],
[Math.PI / 2, 0, 0]
]
],
XYZ: [
[new THREE.Mesh(new THREE.OctahedronGeometry(0.2, 0), r)]
],
XY: [
[
new THREE.Mesh(new THREE.PlaneGeometry(0.4, 0.4), r),
[0.2, 0.2, 0]
]
],
YZ: [
[
new THREE.Mesh(new THREE.PlaneGeometry(0.4, 0.4), r),
[0, 0.2, 0.2],
[0, Math.PI / 2, 0]
]
],
XZ: [
[
new THREE.Mesh(new THREE.PlaneGeometry(0.4, 0.4), r),
[0.2, 0, 0.2],
[-Math.PI / 2, 0, 0]
]
]
}),
t.init(),
t
);
}
return (
o(c, [
{
key: 'setActivePlane',
value: function (e, t) {
var n = new THREE.Matrix4();
t.applyMatrix4(
n
.copy(n.extractRotation(this.planes.XY.matrixWorld))
.invert()
),
'X' === e &&
((this.activePlane = this.planes.XY),
Math.abs(t.y) > Math.abs(t.z) &&
(this.activePlane = this.planes.XZ)),
'Y' === e &&
((this.activePlane = this.planes.XY),
Math.abs(t.x) > Math.abs(t.z) &&
(this.activePlane = this.planes.YZ)),
'Z' === e &&
((this.activePlane = this.planes.XZ),
Math.abs(t.x) > Math.abs(t.y) &&
(this.activePlane = this.planes.YZ)),
'XYZ' === e && (this.activePlane = this.planes.XYZE),
'XY' === e && (this.activePlane = this.planes.XY),
'YZ' === e && (this.activePlane = this.planes.YZ),
'XZ' === e && (this.activePlane = this.planes.XZ);
}
}
]),
c
);
})()),
(THREE.TransformGizmoRotate = (function (e) {
a(c, THREE.TransformGizmo);
var s = l(c);
function c() {
var e;
i(this, c);
var t = function (e, t, n) {
var r = new THREE.BufferGeometry(),
o = [];
n = n || 1;
for (var i = 0; i <= 64 * n; ++i)
'x' === t &&
o.push(
0,
Math.cos((i / 32) * Math.PI) * e,
Math.sin((i / 32) * Math.PI) * e
),
'y' === t &&
o.push(
Math.cos((i / 32) * Math.PI) * e,
0,
Math.sin((i / 32) * Math.PI) * e
),
'z' === t &&
o.push(
Math.sin((i / 32) * Math.PI) * e,
Math.cos((i / 32) * Math.PI) * e,
0
);
return (
r.setAttribute(
'position',
new THREE.Float32BufferAttribute(o, 3)
),
r
);
};
return (
((e = s.call(this)).handleGizmos = {
X: [
[
new THREE.Line(
new t(1, 'x', 0.5),
new n({ color: 16711680 })
)
]
],
Y: [
[
new THREE.Line(
new t(1, 'y', 0.5),
new n({ color: 65280 })
)
]
],
Z: [
[
new THREE.Line(
new t(1, 'z', 0.5),
new n({ color: 255 })
)
]
],
E: [
[
new THREE.Line(
new t(1.25, 'z', 1),
new n({ color: 13421568 })
)
]
],
XYZE: [
[
new THREE.Line(
new t(1, 'z', 1),
new n({ color: 7895160 })
)
]
]
}),
(e.pickerGizmos = {
X: [
[
new THREE.Mesh(
new THREE.TorusGeometry(1, 0.12, 4, 12, Math.PI),
r
),
[0, 0, 0],
[0, -Math.PI / 2, -Math.PI / 2]
]
],
Y: [
[
new THREE.Mesh(
new THREE.TorusGeometry(1, 0.12, 4, 12, Math.PI),
r
),
[0, 0, 0],
[Math.PI / 2, 0, 0]
]
],
Z: [
[
new THREE.Mesh(
new THREE.TorusGeometry(1, 0.12, 4, 12, Math.PI),
r
),
[0, 0, 0],
[0, 0, -Math.PI / 2]
]
],
E: [
[
new THREE.Mesh(
new THREE.TorusGeometry(1.25, 0.12, 2, 24),
r
)
]
],
XYZE: [
[
new THREE.Mesh(
new THREE.TorusGeometry(1, 0.12, 2, 24),
r
)
]
]
}),
(e.pickerGizmos.XYZE[0][0].visible = !1),
e.init(),
e
);
}
return (
o(c, [
{
key: 'setActivePlane',
value: function (e) {
'E' === e && (this.activePlane = this.planes.XYZE),
'X' === e && (this.activePlane = this.planes.YZ),
'Y' === e && (this.activePlane = this.planes.XZ),
'Z' === e && (this.activePlane = this.planes.XY);
}
},
{
key: 'update',
value: function (e, n) {
t(p(c.prototype), 'update', this).call(this, e, n);
var r = new THREE.Matrix4(),
o = new THREE.Euler(0, 0, 1),
i = new THREE.Quaternion(),
a = new THREE.Vector3(1, 0, 0),
s = new THREE.Vector3(0, 1, 0),
l = new THREE.Vector3(0, 0, 1),
u = new THREE.Quaternion(),
f = new THREE.Quaternion(),
d = new THREE.Quaternion(),
m = n.clone();
o.copy(this.planes.XY.rotation),
i.setFromEuler(o),
r.makeRotationFromQuaternion(i).copy(r).invert(),
m.applyMatrix4(r),
this.traverse(function (e) {
i.setFromEuler(o),
'X' === e.name &&
(u.setFromAxisAngle(a, Math.atan2(-m.y, m.z)),
i.multiplyQuaternions(i, u),
e.quaternion.copy(i)),
'Y' === e.name &&
(f.setFromAxisAngle(s, Math.atan2(m.x, m.z)),
i.multiplyQuaternions(i, f),
e.quaternion.copy(i)),
'Z' === e.name &&
(d.setFromAxisAngle(l, Math.atan2(m.y, m.x)),
i.multiplyQuaternions(i, d),
e.quaternion.copy(i));
});
}
}
]),
c
);
})()),
(THREE.TransformGizmoScale = (function (t) {
a(c, THREE.TransformGizmo);
var s = l(c);
function c() {
var t;
i(this, c), (t = s.call(this));
var o = new THREE.BoxGeometry(0.125, 0.125, 0.125);
o.translate(0, 0.5, 0);
var a = new THREE.BufferGeometry();
a.setAttribute(
'position',
new THREE.Float32BufferAttribute([0, 0, 0, 1, 0, 0], 3)
);
var l = new THREE.BufferGeometry();
l.setAttribute(
'position',
new THREE.Float32BufferAttribute([0, 0, 0, 0, 1, 0], 3)
);
var u = new THREE.BufferGeometry();
return (
u.setAttribute(
'position',
new THREE.Float32BufferAttribute([0, 0, 0, 0, 0, 1], 3)
),
(t.handleGizmos = {
X: [
[
new THREE.Mesh(o, new e({ color: 16711680 })),
[0.5, 0, 0],
[0, 0, -Math.PI / 2]
],
[new THREE.Line(a, new n({ color: 16711680 }))]
],
Y: [
[new THREE.Mesh(o, new e({ color: 65280 })), [0, 0.5, 0]],
[new THREE.Line(l, new n({ color: 65280 }))]
],
Z: [
[
new THREE.Mesh(o, new e({ color: 255 })),
[0, 0, 0.5],
[Math.PI / 2, 0, 0]
],
[new THREE.Line(u, new n({ color: 255 }))]
],
XYZ: [
[
new THREE.Mesh(
new THREE.BoxGeometry(0.125, 0.125, 0.125),
new e({ color: 16777215, opacity: 0.25 })
)
]
]
}),
(t.pickerGizmos = {
X: [
[
new THREE.Mesh(
new THREE.CylinderGeometry(0.2, 0, 1, 4, 1, !1),
r
),
[0.6, 0, 0],
[0, 0, -Math.PI / 2]
]
],
Y: [
[
new THREE.Mesh(
new THREE.CylinderGeometry(0.2, 0, 1, 4, 1, !1),
r
),
[0, 0.6, 0]
]
],
Z: [
[
new THREE.Mesh(
new THREE.CylinderGeometry(0.2, 0, 1, 4, 1, !1),
r
),
[0, 0, 0.6],
[Math.PI / 2, 0, 0]
]
],
XYZ: [
[new THREE.Mesh(new THREE.BoxGeometry(0.4, 0.4, 0.4), r)]
]
}),
t.init(),
t
);
}
return (
o(c, [
{
key: 'setActivePlane',
value: function (e, t) {
var n = new THREE.Matrix4();
t.applyMatrix4(
n
.copy(n.extractRotation(this.planes.XY.matrixWorld))
.invert()
),
'X' === e &&
((this.activePlane = this.planes.XY),
Math.abs(t.y) > Math.abs(t.z) &&
(this.activePlane = this.planes.XZ)),
'Y' === e &&
((this.activePlane = this.planes.XY),
Math.abs(t.x) > Math.abs(t.z) &&
(this.activePlane = this.planes.YZ)),
'Z' === e &&
((this.activePlane = this.planes.XZ),
Math.abs(t.x) > Math.abs(t.y) &&
(this.activePlane = this.planes.YZ)),
'XYZ' === e && (this.activePlane = this.planes.XYZE);
}
}
]),
c
);
})()),
(THREE.TransformControls = (function (e) {
a(n, THREE.Object3D);
var t = l(n);
function n(e, r) {
var o;
i(this, n),
(o = t.call(this)),
(r = void 0 !== r ? r : document),
(o.object = void 0),
(o.visible = !1),
(o.translationSnap = null),
(o.rotationSnap = null),
(o.space = 'world'),
(o.size = 1),
(o.axis = null);
var a = e,
s = u(o),
l = 'translate',
c = !1,
p = {
translate: new THREE.TransformGizmoTranslate(),
rotate: new THREE.TransformGizmoRotate(),
scale: new THREE.TransformGizmoScale()
};
for (var f in p) {
var d = p[f];
(d.visible = f === l), o.add(d);
}
var m = { type: 'change' },
h = { type: 'mouseDown' },
y = { type: 'mouseUp', mode: l },
b = { type: 'objectChange' },
g = new THREE.Raycaster(),
v = new THREE.Vector2(),
A = new THREE.Vector3(),
C = new THREE.Vector3(),
w = new THREE.Vector3(),
E = new THREE.Vector3(),
x = 1,
S = new THREE.Matrix4(),
O = new THREE.Vector3(),
k = new THREE.Matrix4(),
j = new THREE.Vector3(),
T = new THREE.Quaternion(),
M = new THREE.Euler(),
I = new THREE.Vector3(1, 0, 0),
R = new THREE.Vector3(0, 1, 0),
P = new THREE.Vector3(0, 0, 1),
N = new THREE.Quaternion(),
L = new THREE.Quaternion(),
_ = new THREE.Quaternion(),
D = new THREE.Quaternion(),
B = new THREE.Quaternion(),
z = new THREE.Vector3(),
F = new THREE.Vector3(),
H = new THREE.Matrix4(),
V = new THREE.Matrix4(),
U = new THREE.Vector3(),
Y = new THREE.Vector3(),
W = new THREE.Euler(),
Z = new THREE.Matrix4(),
Q = new THREE.Vector3(),
G = new THREE.Euler();
function $(e) {
if (
void 0 !== s.object &&
!0 !== c &&
(void 0 === e.button || 0 === e.button)
) {
var t = J(
e.changedTouches ? e.changedTouches[0] : e,
p[l].pickers.children
),
n = null;
t && ((n = t.object.name), e.preventDefault()),
s.axis !== n &&
((s.axis = n), s.update(), s.dispatchEvent(m));
}
}
function X(e) {
if (
void 0 !== s.object &&
!0 !== c &&
(void 0 === e.button || 0 === e.button)
) {
var t = e.changedTouches ? e.changedTouches[0] : e;
if (0 === t.button || void 0 === t.button) {
var n = J(t, p[l].pickers.children);
if (n) {
e.preventDefault(),
e.stopPropagation(),
(s.axis = n.object.name),
s.dispatchEvent(h),
s.update(),
O.copy(Q).sub(Y).normalize(),
p[l].setActivePlane(s.axis, O);
var r = J(t, [p[l].activePlane]);
r &&
(z.copy(s.object.position),
F.copy(s.object.scale),
H.extractRotation(s.object.matrix),
Z.extractRotation(s.object.matrixWorld),
V.extractRotation(s.object.parent.matrixWorld),
U.setFromMatrixScale(
k.copy(s.object.parent.matrixWorld).invert()
),
C.copy(r.point));
}
}
c = !0;
}
}
function q(e) {
if (
void 0 !== s.object &&
null !== s.axis &&
!1 !== c &&
(void 0 === e.button || 0 === e.button)
) {
var t = J(e.changedTouches ? e.changedTouches[0] : e, [
p[l].activePlane
]);
if (!1 !== t) {
if (
(e.preventDefault(),
e.stopPropagation(),
A.copy(t.point),
'translate' === l)
)
A.sub(C),
A.multiply(U),
'local' === s.space &&
(A.applyMatrix4(k.copy(Z).invert()),
-1 === s.axis.search('X') && (A.x = 0),
-1 === s.axis.search('Y') && (A.y = 0),
-1 === s.axis.search('Z') && (A.z = 0),
A.applyMatrix4(H),
s.object.position.copy(z),
s.object.position.add(A)),
('world' !== s.space &&
-1 === s.axis.search('XYZ')) ||
(-1 === s.axis.search('X') && (A.x = 0),
-1 === s.axis.search('Y') && (A.y = 0),
-1 === s.axis.search('Z') && (A.z = 0),
A.applyMatrix4(k.copy(V).invert()),
s.object.position.copy(z),
s.object.position.add(A)),
null !== s.translationSnap &&
('local' === s.space &&
s.object.position.applyMatrix4(
k.copy(Z).invert()
),
-1 !== s.axis.search('X') &&
(s.object.position.x =
Math.round(
s.object.position.x / s.translationSnap
) * s.translationSnap),
-1 !== s.axis.search('Y') &&
(s.object.position.y =
Math.round(
s.object.position.y / s.translationSnap
) * s.translationSnap),
-1 !== s.axis.search('Z') &&
(s.object.position.z =
Math.round(
s.object.position.z / s.translationSnap
) * s.translationSnap),
'local' === s.space &&
s.object.position.applyMatrix4(Z));
else if ('scale' === l)
A.sub(C),
A.multiply(U),
'local' === s.space &&
('XYZ' === s.axis
? ((x = 1 + A.y / Math.max(F.x, F.y, F.z)),
(s.object.scale.x = F.x * x),
(s.object.scale.y = F.y * x),
(s.object.scale.z = F.z * x))
: (A.applyMatrix4(k.copy(Z).invert()),
'X' === s.axis &&
(s.object.scale.x = F.x * (1 + A.x / F.x)),
'Y' === s.axis &&
(s.object.scale.y = F.y * (1 + A.y / F.y)),
'Z' === s.axis &&
(s.object.scale.z = F.z * (1 + A.z / F.z))));
else if ('rotate' === l)
if (
(A.sub(Y),
A.multiply(U),
j.copy(C).sub(Y),
j.multiply(U),
'E' === s.axis)
)
A.applyMatrix4(k.copy(S).invert()),
j.applyMatrix4(k.copy(S).invert()),
w.set(
Math.atan2(A.z, A.y),
Math.atan2(A.x, A.z),
Math.atan2(A.y, A.x)
),
E.set(
Math.atan2(j.z, j.y),
Math.atan2(j.x, j.z),
Math.atan2(j.y, j.x)
),
T.setFromRotationMatrix(k.copy(V).invert()),
B.setFromAxisAngle(O, w.z - E.z),
N.setFromRotationMatrix(Z),
T.multiplyQuaternions(T, B),
T.multiplyQuaternions(T, N),
s.object.quaternion.copy(T);
else if ('XYZE' === s.axis) {
var n = A.clone().cross(j).normalize();
B.setFromEuler(M.set(n.x, n.y, n.z)),
T.setFromRotationMatrix(k.copy(V).invert()),
L.setFromAxisAngle(B, -A.clone().angleTo(j)),
N.setFromRotationMatrix(Z),
T.multiplyQuaternions(T, L),
T.multiplyQuaternions(T, N),
s.object.quaternion.copy(T);
} else
'local' === s.space
? (A.applyMatrix4(k.copy(Z).invert()),
j.applyMatrix4(k.copy(Z).invert()),
w.set(
Math.atan2(A.z, A.y),
Math.atan2(A.x, A.z),
Math.atan2(A.y, A.x)
),
E.set(
Math.atan2(j.z, j.y),
Math.atan2(j.x, j.z),
Math.atan2(j.y, j.x)
),
N.setFromRotationMatrix(H),
null !== s.rotationSnap
? (L.setFromAxisAngle(
I,
Math.round((w.x - E.x) / s.rotationSnap) *
s.rotationSnap
),
_.setFromAxisAngle(
R,
Math.round((w.y - E.y) / s.rotationSnap) *
s.rotationSnap
),
D.setFromAxisAngle(
P,
Math.round((w.z - E.z) / s.rotationSnap) *
s.rotationSnap
))
: (L.setFromAxisAngle(I, w.x - E.x),
_.setFromAxisAngle(R, w.y - E.y),
D.setFromAxisAngle(P, w.z - E.z)),
'X' === s.axis && N.multiplyQuaternions(N, L),
'Y' === s.axis && N.multiplyQuaternions(N, _),
'Z' === s.axis && N.multiplyQuaternions(N, D),
s.object.quaternion.copy(N))
: 'world' === s.space &&
(w.set(
Math.atan2(A.z, A.y),
Math.atan2(A.x, A.z),
Math.atan2(A.y, A.x)
),
E.set(
Math.atan2(j.z, j.y),
Math.atan2(j.x, j.z),
Math.atan2(j.y, j.x)
),
T.setFromRotationMatrix(k.copy(V).invert()),
null !== s.rotationSnap
? (L.setFromAxisAngle(
I,
Math.round((w.x - E.x) / s.rotationSnap) *
s.rotationSnap
),
_.setFromAxisAngle(
R,
Math.round((w.y - E.y) / s.rotationSnap) *
s.rotationSnap
),
D.setFromAxisAngle(
P,
Math.round((w.z - E.z) / s.rotationSnap) *
s.rotationSnap
))
: (L.setFromAxisAngle(I, w.x - E.x),
_.setFromAxisAngle(R, w.y - E.y),
D.setFromAxisAngle(P, w.z - E.z)),
N.setFromRotationMatrix(Z),
'X' === s.axis && T.multiplyQuaternions(T, L),
'Y' === s.axis && T.multiplyQuaternions(T, _),
'Z' === s.axis && T.multiplyQuaternions(T, D),
T.multiplyQuaternions(T, N),
s.object.quaternion.copy(T));
'translate' === l
? ((s.object.position.x = parseFloat(
s.object.position.x.toFixed(5)
)),
(s.object.position.y = parseFloat(
s.object.position.y.toFixed(5)
)),
(s.object.position.z = parseFloat(
s.object.position.z.toFixed(5)
)))
: 'rotate' === l
? ((s.object.rotation.x = parseFloat(
s.object.rotation.x.toFixed(5)
)),
(s.object.rotation.y = parseFloat(
s.object.rotation.y.toFixed(5)
)),
(s.object.rotation.z = parseFloat(
s.object.rotation.z.toFixed(5)
)))
: ((s.object.scale.x = parseFloat(
s.object.scale.x.toFixed(5)
)),
(s.object.scale.y = parseFloat(
s.object.scale.y.toFixed(5)
)),
(s.object.scale.z = parseFloat(
s.object.scale.z.toFixed(5)
))),
s.update(),
s.dispatchEvent(m),
(b.mode = l),
s.dispatchEvent(b);
}
}
}
function K(e) {
e.preventDefault(),
(void 0 !== e.button && 0 !== e.button) ||
(c &&
null !== s.axis &&
((y.mode = l), s.dispatchEvent(y)),
(c = !1),
'TouchEvent' in window && e instanceof TouchEvent
? ((s.axis = null), s.update(), s.dispatchEvent(m))
: $(e));
}
function J(e, t) {
var n = r.getBoundingClientRect(),
o = (e.clientX - n.left) / n.width,
i = (e.clientY - n.top) / n.height;
v.set(2 * o - 1, -2 * i + 1), g.setFromCamera(v, a);
var s = g.intersectObjects(t, !0);
return !!s[0] && s[0];
}
return (
(o.setCamera = function (e) {
a = e;
}),
(o.activate = function () {
r.addEventListener('mousedown', X, !1),
r.addEventListener('touchstart', X, !1),
r.addEventListener('mousemove', $, !1),
r.addEventListener('touchmove', $, !1),
r.addEventListener('mousemove', q, !1),
r.addEventListener('touchmove', q, !1),
r.addEventListener('mouseup', K, !1),
r.addEventListener('mouseout', K, !1),
r.addEventListener('touchend', K, !1),
r.addEventListener('touchcancel', K, !1),
r.addEventListener('touchleave', K, !1);
}),
o.activate(),
(o.dispose = function () {
r.removeEventListener('mousedown', X),
r.removeEventListener('touchstart', X),
r.removeEventListener('mousemove', $),
r.removeEventListener('touchmove', $),
r.removeEventListener('mousemove', q),
r.removeEventListener('touchmove', q),
r.removeEventListener('mouseup', K),
r.removeEventListener('mouseout', K),
r.removeEventListener('touchend', K),
r.removeEventListener('touchcancel', K),
r.removeEventListener('touchleave', K);
}),
(o.attach = function (e) {
(this.object = e), (this.visible = !0), this.update(!0);
}),
(o.detach = function () {
(this.object = void 0),
(this.visible = !1),
(this.axis = null);
}),
(o.getMode = function () {
return l;
}),
(o.setMode = function (e) {
for (var t in ('scale' === (l = e || l) &&
(s.space = 'local'),
p))
p[t].visible = t === l;
this.update(), s.dispatchEvent(m);
}),
(o.setTranslationSnap = function (e) {
s.translationSnap = e;
}),
(o.setRotationSnap = function (e) {
s.rotationSnap = e;
}),
(o.setSize = function (e) {
(s.size = e), this.update(!0), s.dispatchEvent(m);
}),
(o.setSpace = function (e) {
(s.space = e), this.update(), s.dispatchEvent(m);
}),
(o.update = function (e) {
void 0 !== s.object &&
(s.object.updateMatrixWorld(),
Y.setFromMatrixPosition(s.object.matrixWorld),
W.setFromRotationMatrix(
k.extractRotation(s.object.matrixWorld)
),
a.updateMatrixWorld(),
Q.setFromMatrixPosition(a.matrixWorld),
G.