endset_three_editor 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/endset_three_editor.css +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/three-editor.cjs.js +6 -0
- package/dist/three-editor.cjs.js.map +1 -0
- package/dist/three-editor.es.js +3879 -0
- package/dist/three-editor.es.js.map +1 -0
- package/dist/three-editor.umd.js +6 -0
- package/dist/three-editor.umd.js.map +1 -0
- package/dist/vite.svg +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,3879 @@
|
|
|
1
|
+
import { defineComponent as Fe, ref as K, inject as bn, computed as Be, watchEffect as wn, resolveComponent as Tn, openBlock as Y, createElementBlock as q, createElementVNode as g, normalizeClass as xn, withModifiers as vt, unref as En, toDisplayString as st, Fragment as $t, renderList as Jt, createBlock as en, createCommentVNode as tn, watch as Mn, toRef as Sn, provide as vn, withDirectives as H, vModelText as oe, vShow as pe, reactive as Rn, shallowRef as An, onMounted as Pn, createVNode as it } from "vue";
|
|
2
|
+
import * as N from "three";
|
|
3
|
+
import { Controls as nn, Vector3 as E, MOUSE as xe, TOUCH as Te, Quaternion as X, Spherical as Rt, Vector2 as B, Ray as Ln, Plane as In, MathUtils as sn, Raycaster as On, Object3D as je, MeshBasicMaterial as ye, LineBasicMaterial as De, CylinderGeometry as z, BoxGeometry as F, BufferGeometry as He, Float32BufferAttribute as he, Mesh as b, OctahedronGeometry as Ke, Line as re, TorusGeometry as Re, SphereGeometry as Cn, Euler as Dn, Matrix4 as Me, PlaneGeometry as Nn, DoubleSide as on, Loader as rn, FileLoader as Tt, Color as ue, SRGBColorSpace as Se, Group as $e, Material as Ne, PointsMaterial as Ie, MeshPhongMaterial as kn, LineSegments as ft, Points as Je, TrianglesDrawMode as jn, TriangleFanDrawMode as mt, TriangleStripDrawMode as an, LoaderUtils as ke, MeshPhysicalMaterial as ne, LinearSRGBColorSpace as ae, SpotLight as Hn, PointLight as Fn, DirectionalLight as Un, InstancedMesh as zn, InstancedBufferAttribute as Gn, TextureLoader as Xn, ImageBitmapLoader as Yn, BufferAttribute as ot, InterleavedBuffer as Bn, InterleavedBufferAttribute as Kn, LinearMipmapLinearFilter as ln, NearestMipmapLinearFilter as Vn, LinearMipmapNearestFilter as Zn, NearestMipmapNearestFilter as Qn, LinearFilter as gt, NearestFilter as cn, RepeatWrapping as yt, MirroredRepeatWrapping as qn, ClampToEdgeWrapping as Wn, MeshStandardMaterial as hn, PropertyBinding as $n, SkinnedMesh as Jn, LineLoop as es, PerspectiveCamera as ts, OrthographicCamera as ns, Skeleton as ss, AnimationClip as is, Bone as os, InterpolateDiscrete as rs, InterpolateLinear as un, Texture as At, VectorKeyframeTrack as Pt, NumberKeyframeTrack as Lt, QuaternionKeyframeTrack as It, ColorManagement as Ot, FrontSide as as, Interpolant as ls, Box3 as cs, Sphere as hs } from "three";
|
|
4
|
+
import us from "@tweenjs/tween.js";
|
|
5
|
+
const Ct = { type: "change" }, xt = { type: "start" }, dn = { type: "end" }, Ve = new Ln(), Dt = new In(), ds = Math.cos(70 * sn.DEG2RAD), D = new E(), G = 2 * Math.PI, A = {
|
|
6
|
+
NONE: -1,
|
|
7
|
+
ROTATE: 0,
|
|
8
|
+
DOLLY: 1,
|
|
9
|
+
PAN: 2,
|
|
10
|
+
TOUCH_ROTATE: 3,
|
|
11
|
+
TOUCH_PAN: 4,
|
|
12
|
+
TOUCH_DOLLY_PAN: 5,
|
|
13
|
+
TOUCH_DOLLY_ROTATE: 6
|
|
14
|
+
}, rt = 1e-6;
|
|
15
|
+
class ps extends nn {
|
|
16
|
+
/**
|
|
17
|
+
* Constructs a new controls instance.
|
|
18
|
+
*
|
|
19
|
+
* @param {Object3D} object - The object that is managed by the controls.
|
|
20
|
+
* @param {?HTMLElement} domElement - The HTML element used for event listeners.
|
|
21
|
+
*/
|
|
22
|
+
constructor(e, t = null) {
|
|
23
|
+
super(e, t), this.state = A.NONE, this.target = new E(), this.cursor = new E(), this.minDistance = 0, this.maxDistance = 1 / 0, this.minZoom = 0, this.maxZoom = 1 / 0, this.minTargetRadius = 0, this.maxTargetRadius = 1 / 0, this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -1 / 0, this.maxAzimuthAngle = 1 / 0, this.enableDamping = !1, this.dampingFactor = 0.05, this.enableZoom = !0, this.zoomSpeed = 1, this.enableRotate = !0, this.rotateSpeed = 1, this.keyRotateSpeed = 1, this.enablePan = !0, this.panSpeed = 1, this.screenSpacePanning = !0, this.keyPanSpeed = 7, this.zoomToCursor = !1, this.autoRotate = !1, this.autoRotateSpeed = 2, this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" }, this.mouseButtons = { LEFT: xe.ROTATE, MIDDLE: xe.DOLLY, RIGHT: xe.PAN }, this.touches = { ONE: Te.ROTATE, TWO: Te.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._cursorStyle = "auto", this._domElementKeyEvents = null, this._lastPosition = new E(), this._lastQuaternion = new X(), this._lastTargetPosition = new E(), this._quat = new X().setFromUnitVectors(e.up, new E(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new Rt(), this._sphericalDelta = new Rt(), this._scale = 1, this._panOffset = new E(), this._rotateStart = new B(), this._rotateEnd = new B(), this._rotateDelta = new B(), this._panStart = new B(), this._panEnd = new B(), this._panDelta = new B(), this._dollyStart = new B(), this._dollyEnd = new B(), this._dollyDelta = new B(), this._dollyDirection = new E(), this._mouse = new B(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = ms.bind(this), this._onPointerDown = fs.bind(this), this._onPointerUp = gs.bind(this), this._onContextMenu = Es.bind(this), this._onMouseWheel = bs.bind(this), this._onKeyDown = ws.bind(this), this._onTouchStart = Ts.bind(this), this._onTouchMove = xs.bind(this), this._onMouseDown = ys.bind(this), this._onMouseMove = _s.bind(this), this._interceptControlDown = Ms.bind(this), this._interceptControlUp = Ss.bind(this), this.domElement !== null && this.connect(this.domElement), this.update();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Defines the visual representation of the cursor.
|
|
27
|
+
*
|
|
28
|
+
* @type {('auto'|'grab')}
|
|
29
|
+
* @default 'auto'
|
|
30
|
+
*/
|
|
31
|
+
set cursorStyle(e) {
|
|
32
|
+
this._cursorStyle = e, e === "grab" ? this.domElement.style.cursor = "grab" : this.domElement.style.cursor = "auto";
|
|
33
|
+
}
|
|
34
|
+
get cursorStyle() {
|
|
35
|
+
return this._cursorStyle;
|
|
36
|
+
}
|
|
37
|
+
connect(e) {
|
|
38
|
+
super.connect(e), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointercancel", this._onPointerUp), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.addEventListener("wheel", this._onMouseWheel, { passive: !1 }), this.domElement.getRootNode().addEventListener("keydown", this._interceptControlDown, { passive: !0, capture: !0 }), this.domElement.style.touchAction = "none";
|
|
39
|
+
}
|
|
40
|
+
disconnect() {
|
|
41
|
+
this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.ownerDocument.removeEventListener("pointermove", this._onPointerMove), this.domElement.ownerDocument.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointercancel", this._onPointerUp), this.domElement.removeEventListener("wheel", this._onMouseWheel), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.stopListenToKeyEvents(), this.domElement.getRootNode().removeEventListener("keydown", this._interceptControlDown, { capture: !0 }), this.domElement.style.touchAction = "";
|
|
42
|
+
}
|
|
43
|
+
dispose() {
|
|
44
|
+
this.disconnect();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get the current vertical rotation, in radians.
|
|
48
|
+
*
|
|
49
|
+
* @return {number} The current vertical rotation, in radians.
|
|
50
|
+
*/
|
|
51
|
+
getPolarAngle() {
|
|
52
|
+
return this._spherical.phi;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get the current horizontal rotation, in radians.
|
|
56
|
+
*
|
|
57
|
+
* @return {number} The current horizontal rotation, in radians.
|
|
58
|
+
*/
|
|
59
|
+
getAzimuthalAngle() {
|
|
60
|
+
return this._spherical.theta;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Returns the distance from the camera to the target.
|
|
64
|
+
*
|
|
65
|
+
* @return {number} The distance from the camera to the target.
|
|
66
|
+
*/
|
|
67
|
+
getDistance() {
|
|
68
|
+
return this.object.position.distanceTo(this.target);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Adds key event listeners to the given DOM element.
|
|
72
|
+
* `window` is a recommended argument for using this method.
|
|
73
|
+
*
|
|
74
|
+
* @param {HTMLElement} domElement - The DOM element
|
|
75
|
+
*/
|
|
76
|
+
listenToKeyEvents(e) {
|
|
77
|
+
e.addEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = e;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Removes the key event listener previously defined with `listenToKeyEvents()`.
|
|
81
|
+
*/
|
|
82
|
+
stopListenToKeyEvents() {
|
|
83
|
+
this._domElementKeyEvents !== null && (this._domElementKeyEvents.removeEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = null);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Save the current state of the controls. This can later be recovered with `reset()`.
|
|
87
|
+
*/
|
|
88
|
+
saveState() {
|
|
89
|
+
this.target0.copy(this.target), this.position0.copy(this.object.position), this.zoom0 = this.object.zoom;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Reset the controls to their state from either the last time the `saveState()`
|
|
93
|
+
* was called, or the initial state.
|
|
94
|
+
*/
|
|
95
|
+
reset() {
|
|
96
|
+
this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent(Ct), this.update(), this.state = A.NONE;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Programmatically pan the camera.
|
|
100
|
+
*
|
|
101
|
+
* @param {number} deltaX - The horizontal pan amount in pixels.
|
|
102
|
+
* @param {number} deltaY - The vertical pan amount in pixels.
|
|
103
|
+
*/
|
|
104
|
+
pan(e, t) {
|
|
105
|
+
this._pan(e, t), this.update();
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Programmatically dolly in (zoom in for perspective camera).
|
|
109
|
+
*
|
|
110
|
+
* @param {number} dollyScale - The dolly scale factor.
|
|
111
|
+
*/
|
|
112
|
+
dollyIn(e) {
|
|
113
|
+
this._dollyIn(e), this.update();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Programmatically dolly out (zoom out for perspective camera).
|
|
117
|
+
*
|
|
118
|
+
* @param {number} dollyScale - The dolly scale factor.
|
|
119
|
+
*/
|
|
120
|
+
dollyOut(e) {
|
|
121
|
+
this._dollyOut(e), this.update();
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Programmatically rotate the camera left (around the vertical axis).
|
|
125
|
+
*
|
|
126
|
+
* @param {number} angle - The rotation angle in radians.
|
|
127
|
+
*/
|
|
128
|
+
rotateLeft(e) {
|
|
129
|
+
this._rotateLeft(e), this.update();
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Programmatically rotate the camera up (around the horizontal axis).
|
|
133
|
+
*
|
|
134
|
+
* @param {number} angle - The rotation angle in radians.
|
|
135
|
+
*/
|
|
136
|
+
rotateUp(e) {
|
|
137
|
+
this._rotateUp(e), this.update();
|
|
138
|
+
}
|
|
139
|
+
update(e = null) {
|
|
140
|
+
const t = this.object.position;
|
|
141
|
+
D.copy(t).sub(this.target), D.applyQuaternion(this._quat), this._spherical.setFromVector3(D), this.autoRotate && this.state === A.NONE && this._rotateLeft(this._getAutoRotationAngle(e)), this.enableDamping ? (this._spherical.theta += this._sphericalDelta.theta * this.dampingFactor, this._spherical.phi += this._sphericalDelta.phi * this.dampingFactor) : (this._spherical.theta += this._sphericalDelta.theta, this._spherical.phi += this._sphericalDelta.phi);
|
|
142
|
+
let s = this.minAzimuthAngle, n = this.maxAzimuthAngle;
|
|
143
|
+
isFinite(s) && isFinite(n) && (s < -Math.PI ? s += G : s > Math.PI && (s -= G), n < -Math.PI ? n += G : n > Math.PI && (n -= G), s <= n ? this._spherical.theta = Math.max(s, Math.min(n, this._spherical.theta)) : this._spherical.theta = this._spherical.theta > (s + n) / 2 ? Math.max(s, this._spherical.theta) : Math.min(n, this._spherical.theta)), this._spherical.phi = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, this._spherical.phi)), this._spherical.makeSafe(), this.enableDamping === !0 ? this.target.addScaledVector(this._panOffset, this.dampingFactor) : this.target.add(this._panOffset), this.target.sub(this.cursor), this.target.clampLength(this.minTargetRadius, this.maxTargetRadius), this.target.add(this.cursor);
|
|
144
|
+
let i = !1;
|
|
145
|
+
if (this.zoomToCursor && this._performCursorZoom || this.object.isOrthographicCamera)
|
|
146
|
+
this._spherical.radius = this._clampDistance(this._spherical.radius);
|
|
147
|
+
else {
|
|
148
|
+
const o = this._spherical.radius;
|
|
149
|
+
this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale), i = o != this._spherical.radius;
|
|
150
|
+
}
|
|
151
|
+
if (D.setFromSpherical(this._spherical), D.applyQuaternion(this._quatInverse), t.copy(this.target).add(D), this.object.lookAt(this.target), this.enableDamping === !0 ? (this._sphericalDelta.theta *= 1 - this.dampingFactor, this._sphericalDelta.phi *= 1 - this.dampingFactor, this._panOffset.multiplyScalar(1 - this.dampingFactor)) : (this._sphericalDelta.set(0, 0, 0), this._panOffset.set(0, 0, 0)), this.zoomToCursor && this._performCursorZoom) {
|
|
152
|
+
let o = null;
|
|
153
|
+
if (this.object.isPerspectiveCamera) {
|
|
154
|
+
const a = D.length();
|
|
155
|
+
o = this._clampDistance(a * this._scale);
|
|
156
|
+
const l = a - o;
|
|
157
|
+
this.object.position.addScaledVector(this._dollyDirection, l), this.object.updateMatrixWorld(), i = !!l;
|
|
158
|
+
} else if (this.object.isOrthographicCamera) {
|
|
159
|
+
const a = new E(this._mouse.x, this._mouse.y, 0);
|
|
160
|
+
a.unproject(this.object);
|
|
161
|
+
const l = this.object.zoom;
|
|
162
|
+
this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(), i = l !== this.object.zoom;
|
|
163
|
+
const h = new E(this._mouse.x, this._mouse.y, 0);
|
|
164
|
+
h.unproject(this.object), this.object.position.sub(h).add(a), this.object.updateMatrixWorld(), o = D.length();
|
|
165
|
+
} else
|
|
166
|
+
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), this.zoomToCursor = !1;
|
|
167
|
+
o !== null && (this.screenSpacePanning ? this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position) : (Ve.origin.copy(this.object.position), Ve.direction.set(0, 0, -1).transformDirection(this.object.matrix), Math.abs(this.object.up.dot(Ve.direction)) < ds ? this.object.lookAt(this.target) : (Dt.setFromNormalAndCoplanarPoint(this.object.up, this.target), Ve.intersectPlane(Dt, this.target))));
|
|
168
|
+
} else if (this.object.isOrthographicCamera) {
|
|
169
|
+
const o = this.object.zoom;
|
|
170
|
+
this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), o !== this.object.zoom && (this.object.updateProjectionMatrix(), i = !0);
|
|
171
|
+
}
|
|
172
|
+
return this._scale = 1, this._performCursorZoom = !1, i || this._lastPosition.distanceToSquared(this.object.position) > rt || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > rt || this._lastTargetPosition.distanceToSquared(this.target) > rt ? (this.dispatchEvent(Ct), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0) : !1;
|
|
173
|
+
}
|
|
174
|
+
_getAutoRotationAngle(e) {
|
|
175
|
+
return e !== null ? G / 60 * this.autoRotateSpeed * e : G / 60 / 60 * this.autoRotateSpeed;
|
|
176
|
+
}
|
|
177
|
+
_getZoomScale(e) {
|
|
178
|
+
const t = Math.abs(e * 0.01);
|
|
179
|
+
return Math.pow(0.95, this.zoomSpeed * t);
|
|
180
|
+
}
|
|
181
|
+
_rotateLeft(e) {
|
|
182
|
+
this._sphericalDelta.theta -= e;
|
|
183
|
+
}
|
|
184
|
+
_rotateUp(e) {
|
|
185
|
+
this._sphericalDelta.phi -= e;
|
|
186
|
+
}
|
|
187
|
+
_panLeft(e, t) {
|
|
188
|
+
D.setFromMatrixColumn(t, 0), D.multiplyScalar(-e), this._panOffset.add(D);
|
|
189
|
+
}
|
|
190
|
+
_panUp(e, t) {
|
|
191
|
+
this.screenSpacePanning === !0 ? D.setFromMatrixColumn(t, 1) : (D.setFromMatrixColumn(t, 0), D.crossVectors(this.object.up, D)), D.multiplyScalar(e), this._panOffset.add(D);
|
|
192
|
+
}
|
|
193
|
+
// deltaX and deltaY are in pixels; right and down are positive
|
|
194
|
+
_pan(e, t) {
|
|
195
|
+
const s = this.domElement;
|
|
196
|
+
if (this.object.isPerspectiveCamera) {
|
|
197
|
+
const n = this.object.position;
|
|
198
|
+
D.copy(n).sub(this.target);
|
|
199
|
+
let i = D.length();
|
|
200
|
+
i *= Math.tan(this.object.fov / 2 * Math.PI / 180), this._panLeft(2 * e * i / s.clientHeight, this.object.matrix), this._panUp(2 * t * i / s.clientHeight, this.object.matrix);
|
|
201
|
+
} else this.object.isOrthographicCamera ? (this._panLeft(e * (this.object.right - this.object.left) / this.object.zoom / s.clientWidth, this.object.matrix), this._panUp(t * (this.object.top - this.object.bottom) / this.object.zoom / s.clientHeight, this.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), this.enablePan = !1);
|
|
202
|
+
}
|
|
203
|
+
_dollyOut(e) {
|
|
204
|
+
this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale /= e : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1);
|
|
205
|
+
}
|
|
206
|
+
_dollyIn(e) {
|
|
207
|
+
this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale *= e : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1);
|
|
208
|
+
}
|
|
209
|
+
_updateZoomParameters(e, t) {
|
|
210
|
+
if (!this.zoomToCursor)
|
|
211
|
+
return;
|
|
212
|
+
this._performCursorZoom = !0;
|
|
213
|
+
const s = this.domElement.getBoundingClientRect(), n = e - s.left, i = t - s.top, o = s.width, a = s.height;
|
|
214
|
+
this._mouse.x = n / o * 2 - 1, this._mouse.y = -(i / a) * 2 + 1, this._dollyDirection.set(this._mouse.x, this._mouse.y, 1).unproject(this.object).sub(this.object.position).normalize();
|
|
215
|
+
}
|
|
216
|
+
_clampDistance(e) {
|
|
217
|
+
return Math.max(this.minDistance, Math.min(this.maxDistance, e));
|
|
218
|
+
}
|
|
219
|
+
//
|
|
220
|
+
// event callbacks - update the object state
|
|
221
|
+
//
|
|
222
|
+
_handleMouseDownRotate(e) {
|
|
223
|
+
this._rotateStart.set(e.clientX, e.clientY);
|
|
224
|
+
}
|
|
225
|
+
_handleMouseDownDolly(e) {
|
|
226
|
+
this._updateZoomParameters(e.clientX, e.clientX), this._dollyStart.set(e.clientX, e.clientY);
|
|
227
|
+
}
|
|
228
|
+
_handleMouseDownPan(e) {
|
|
229
|
+
this._panStart.set(e.clientX, e.clientY);
|
|
230
|
+
}
|
|
231
|
+
_handleMouseMoveRotate(e) {
|
|
232
|
+
this._rotateEnd.set(e.clientX, e.clientY), this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
|
|
233
|
+
const t = this.domElement;
|
|
234
|
+
this._rotateLeft(G * this._rotateDelta.x / t.clientHeight), this._rotateUp(G * this._rotateDelta.y / t.clientHeight), this._rotateStart.copy(this._rotateEnd), this.update();
|
|
235
|
+
}
|
|
236
|
+
_handleMouseMoveDolly(e) {
|
|
237
|
+
this._dollyEnd.set(e.clientX, e.clientY), this._dollyDelta.subVectors(this._dollyEnd, this._dollyStart), this._dollyDelta.y > 0 ? this._dollyOut(this._getZoomScale(this._dollyDelta.y)) : this._dollyDelta.y < 0 && this._dollyIn(this._getZoomScale(this._dollyDelta.y)), this._dollyStart.copy(this._dollyEnd), this.update();
|
|
238
|
+
}
|
|
239
|
+
_handleMouseMovePan(e) {
|
|
240
|
+
this._panEnd.set(e.clientX, e.clientY), this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd), this.update();
|
|
241
|
+
}
|
|
242
|
+
_handleMouseWheel(e) {
|
|
243
|
+
this._updateZoomParameters(e.clientX, e.clientY), e.deltaY < 0 ? this._dollyIn(this._getZoomScale(e.deltaY)) : e.deltaY > 0 && this._dollyOut(this._getZoomScale(e.deltaY)), this.update();
|
|
244
|
+
}
|
|
245
|
+
_handleKeyDown(e) {
|
|
246
|
+
let t = !1;
|
|
247
|
+
switch (e.code) {
|
|
248
|
+
case this.keys.UP:
|
|
249
|
+
e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateUp(G * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, this.keyPanSpeed), t = !0;
|
|
250
|
+
break;
|
|
251
|
+
case this.keys.BOTTOM:
|
|
252
|
+
e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateUp(-G * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, -this.keyPanSpeed), t = !0;
|
|
253
|
+
break;
|
|
254
|
+
case this.keys.LEFT:
|
|
255
|
+
e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateLeft(G * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(this.keyPanSpeed, 0), t = !0;
|
|
256
|
+
break;
|
|
257
|
+
case this.keys.RIGHT:
|
|
258
|
+
e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateLeft(-G * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(-this.keyPanSpeed, 0), t = !0;
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
t && (e.preventDefault(), this.update());
|
|
262
|
+
}
|
|
263
|
+
_handleTouchStartRotate(e) {
|
|
264
|
+
if (this._pointers.length === 1)
|
|
265
|
+
this._rotateStart.set(e.pageX, e.pageY);
|
|
266
|
+
else {
|
|
267
|
+
const t = this._getSecondPointerPosition(e), s = 0.5 * (e.pageX + t.x), n = 0.5 * (e.pageY + t.y);
|
|
268
|
+
this._rotateStart.set(s, n);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
_handleTouchStartPan(e) {
|
|
272
|
+
if (this._pointers.length === 1)
|
|
273
|
+
this._panStart.set(e.pageX, e.pageY);
|
|
274
|
+
else {
|
|
275
|
+
const t = this._getSecondPointerPosition(e), s = 0.5 * (e.pageX + t.x), n = 0.5 * (e.pageY + t.y);
|
|
276
|
+
this._panStart.set(s, n);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
_handleTouchStartDolly(e) {
|
|
280
|
+
const t = this._getSecondPointerPosition(e), s = e.pageX - t.x, n = e.pageY - t.y, i = Math.sqrt(s * s + n * n);
|
|
281
|
+
this._dollyStart.set(0, i);
|
|
282
|
+
}
|
|
283
|
+
_handleTouchStartDollyPan(e) {
|
|
284
|
+
this.enableZoom && this._handleTouchStartDolly(e), this.enablePan && this._handleTouchStartPan(e);
|
|
285
|
+
}
|
|
286
|
+
_handleTouchStartDollyRotate(e) {
|
|
287
|
+
this.enableZoom && this._handleTouchStartDolly(e), this.enableRotate && this._handleTouchStartRotate(e);
|
|
288
|
+
}
|
|
289
|
+
_handleTouchMoveRotate(e) {
|
|
290
|
+
if (this._pointers.length == 1)
|
|
291
|
+
this._rotateEnd.set(e.pageX, e.pageY);
|
|
292
|
+
else {
|
|
293
|
+
const s = this._getSecondPointerPosition(e), n = 0.5 * (e.pageX + s.x), i = 0.5 * (e.pageY + s.y);
|
|
294
|
+
this._rotateEnd.set(n, i);
|
|
295
|
+
}
|
|
296
|
+
this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
|
|
297
|
+
const t = this.domElement;
|
|
298
|
+
this._rotateLeft(G * this._rotateDelta.x / t.clientHeight), this._rotateUp(G * this._rotateDelta.y / t.clientHeight), this._rotateStart.copy(this._rotateEnd);
|
|
299
|
+
}
|
|
300
|
+
_handleTouchMovePan(e) {
|
|
301
|
+
if (this._pointers.length === 1)
|
|
302
|
+
this._panEnd.set(e.pageX, e.pageY);
|
|
303
|
+
else {
|
|
304
|
+
const t = this._getSecondPointerPosition(e), s = 0.5 * (e.pageX + t.x), n = 0.5 * (e.pageY + t.y);
|
|
305
|
+
this._panEnd.set(s, n);
|
|
306
|
+
}
|
|
307
|
+
this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd);
|
|
308
|
+
}
|
|
309
|
+
_handleTouchMoveDolly(e) {
|
|
310
|
+
const t = this._getSecondPointerPosition(e), s = e.pageX - t.x, n = e.pageY - t.y, i = Math.sqrt(s * s + n * n);
|
|
311
|
+
this._dollyEnd.set(0, i), this._dollyDelta.set(0, Math.pow(this._dollyEnd.y / this._dollyStart.y, this.zoomSpeed)), this._dollyOut(this._dollyDelta.y), this._dollyStart.copy(this._dollyEnd);
|
|
312
|
+
const o = (e.pageX + t.x) * 0.5, a = (e.pageY + t.y) * 0.5;
|
|
313
|
+
this._updateZoomParameters(o, a);
|
|
314
|
+
}
|
|
315
|
+
_handleTouchMoveDollyPan(e) {
|
|
316
|
+
this.enableZoom && this._handleTouchMoveDolly(e), this.enablePan && this._handleTouchMovePan(e);
|
|
317
|
+
}
|
|
318
|
+
_handleTouchMoveDollyRotate(e) {
|
|
319
|
+
this.enableZoom && this._handleTouchMoveDolly(e), this.enableRotate && this._handleTouchMoveRotate(e);
|
|
320
|
+
}
|
|
321
|
+
// pointers
|
|
322
|
+
_addPointer(e) {
|
|
323
|
+
this._pointers.push(e.pointerId);
|
|
324
|
+
}
|
|
325
|
+
_removePointer(e) {
|
|
326
|
+
delete this._pointerPositions[e.pointerId];
|
|
327
|
+
for (let t = 0; t < this._pointers.length; t++)
|
|
328
|
+
if (this._pointers[t] == e.pointerId) {
|
|
329
|
+
this._pointers.splice(t, 1);
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
_isTrackingPointer(e) {
|
|
334
|
+
for (let t = 0; t < this._pointers.length; t++)
|
|
335
|
+
if (this._pointers[t] == e.pointerId) return !0;
|
|
336
|
+
return !1;
|
|
337
|
+
}
|
|
338
|
+
_trackPointer(e) {
|
|
339
|
+
let t = this._pointerPositions[e.pointerId];
|
|
340
|
+
t === void 0 && (t = new B(), this._pointerPositions[e.pointerId] = t), t.set(e.pageX, e.pageY);
|
|
341
|
+
}
|
|
342
|
+
_getSecondPointerPosition(e) {
|
|
343
|
+
const t = e.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0];
|
|
344
|
+
return this._pointerPositions[t];
|
|
345
|
+
}
|
|
346
|
+
//
|
|
347
|
+
_customWheelEvent(e) {
|
|
348
|
+
const t = e.deltaMode, s = {
|
|
349
|
+
clientX: e.clientX,
|
|
350
|
+
clientY: e.clientY,
|
|
351
|
+
deltaY: e.deltaY
|
|
352
|
+
};
|
|
353
|
+
switch (t) {
|
|
354
|
+
case 1:
|
|
355
|
+
s.deltaY *= 16;
|
|
356
|
+
break;
|
|
357
|
+
case 2:
|
|
358
|
+
s.deltaY *= 100;
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
return e.ctrlKey && !this._controlActive && (s.deltaY *= 10), s;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
function fs(r) {
|
|
365
|
+
this.enabled !== !1 && (this._pointers.length === 0 && (this.domElement.setPointerCapture(r.pointerId), this.domElement.ownerDocument.addEventListener("pointermove", this._onPointerMove), this.domElement.ownerDocument.addEventListener("pointerup", this._onPointerUp)), !this._isTrackingPointer(r) && (this._addPointer(r), r.pointerType === "touch" ? this._onTouchStart(r) : this._onMouseDown(r), this._cursorStyle === "grab" && (this.domElement.style.cursor = "grabbing")));
|
|
366
|
+
}
|
|
367
|
+
function ms(r) {
|
|
368
|
+
this.enabled !== !1 && (r.pointerType === "touch" ? this._onTouchMove(r) : this._onMouseMove(r));
|
|
369
|
+
}
|
|
370
|
+
function gs(r) {
|
|
371
|
+
switch (this._removePointer(r), this._pointers.length) {
|
|
372
|
+
case 0:
|
|
373
|
+
this.domElement.releasePointerCapture(r.pointerId), this.domElement.ownerDocument.removeEventListener("pointermove", this._onPointerMove), this.domElement.ownerDocument.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(dn), this.state = A.NONE, this._cursorStyle === "grab" && (this.domElement.style.cursor = "grab");
|
|
374
|
+
break;
|
|
375
|
+
case 1:
|
|
376
|
+
const e = this._pointers[0], t = this._pointerPositions[e];
|
|
377
|
+
this._onTouchStart({ pointerId: e, pageX: t.x, pageY: t.y });
|
|
378
|
+
break;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function ys(r) {
|
|
382
|
+
let e;
|
|
383
|
+
switch (r.button) {
|
|
384
|
+
case 0:
|
|
385
|
+
e = this.mouseButtons.LEFT;
|
|
386
|
+
break;
|
|
387
|
+
case 1:
|
|
388
|
+
e = this.mouseButtons.MIDDLE;
|
|
389
|
+
break;
|
|
390
|
+
case 2:
|
|
391
|
+
e = this.mouseButtons.RIGHT;
|
|
392
|
+
break;
|
|
393
|
+
default:
|
|
394
|
+
e = -1;
|
|
395
|
+
}
|
|
396
|
+
switch (e) {
|
|
397
|
+
case xe.DOLLY:
|
|
398
|
+
if (this.enableZoom === !1) return;
|
|
399
|
+
this._handleMouseDownDolly(r), this.state = A.DOLLY;
|
|
400
|
+
break;
|
|
401
|
+
case xe.ROTATE:
|
|
402
|
+
if (r.ctrlKey || r.metaKey || r.shiftKey) {
|
|
403
|
+
if (this.enablePan === !1) return;
|
|
404
|
+
this._handleMouseDownPan(r), this.state = A.PAN;
|
|
405
|
+
} else {
|
|
406
|
+
if (this.enableRotate === !1) return;
|
|
407
|
+
this._handleMouseDownRotate(r), this.state = A.ROTATE;
|
|
408
|
+
}
|
|
409
|
+
break;
|
|
410
|
+
case xe.PAN:
|
|
411
|
+
if (r.ctrlKey || r.metaKey || r.shiftKey) {
|
|
412
|
+
if (this.enableRotate === !1) return;
|
|
413
|
+
this._handleMouseDownRotate(r), this.state = A.ROTATE;
|
|
414
|
+
} else {
|
|
415
|
+
if (this.enablePan === !1) return;
|
|
416
|
+
this._handleMouseDownPan(r), this.state = A.PAN;
|
|
417
|
+
}
|
|
418
|
+
break;
|
|
419
|
+
default:
|
|
420
|
+
this.state = A.NONE;
|
|
421
|
+
}
|
|
422
|
+
this.state !== A.NONE && this.dispatchEvent(xt);
|
|
423
|
+
}
|
|
424
|
+
function _s(r) {
|
|
425
|
+
switch (this.state) {
|
|
426
|
+
case A.ROTATE:
|
|
427
|
+
if (this.enableRotate === !1) return;
|
|
428
|
+
this._handleMouseMoveRotate(r);
|
|
429
|
+
break;
|
|
430
|
+
case A.DOLLY:
|
|
431
|
+
if (this.enableZoom === !1) return;
|
|
432
|
+
this._handleMouseMoveDolly(r);
|
|
433
|
+
break;
|
|
434
|
+
case A.PAN:
|
|
435
|
+
if (this.enablePan === !1) return;
|
|
436
|
+
this._handleMouseMovePan(r);
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
function bs(r) {
|
|
441
|
+
this.enabled === !1 || this.enableZoom === !1 || this.state !== A.NONE || (r.preventDefault(), this.dispatchEvent(xt), this._handleMouseWheel(this._customWheelEvent(r)), this.dispatchEvent(dn));
|
|
442
|
+
}
|
|
443
|
+
function ws(r) {
|
|
444
|
+
this.enabled !== !1 && this._handleKeyDown(r);
|
|
445
|
+
}
|
|
446
|
+
function Ts(r) {
|
|
447
|
+
switch (this._trackPointer(r), this._pointers.length) {
|
|
448
|
+
case 1:
|
|
449
|
+
switch (this.touches.ONE) {
|
|
450
|
+
case Te.ROTATE:
|
|
451
|
+
if (this.enableRotate === !1) return;
|
|
452
|
+
this._handleTouchStartRotate(r), this.state = A.TOUCH_ROTATE;
|
|
453
|
+
break;
|
|
454
|
+
case Te.PAN:
|
|
455
|
+
if (this.enablePan === !1) return;
|
|
456
|
+
this._handleTouchStartPan(r), this.state = A.TOUCH_PAN;
|
|
457
|
+
break;
|
|
458
|
+
default:
|
|
459
|
+
this.state = A.NONE;
|
|
460
|
+
}
|
|
461
|
+
break;
|
|
462
|
+
case 2:
|
|
463
|
+
switch (this.touches.TWO) {
|
|
464
|
+
case Te.DOLLY_PAN:
|
|
465
|
+
if (this.enableZoom === !1 && this.enablePan === !1) return;
|
|
466
|
+
this._handleTouchStartDollyPan(r), this.state = A.TOUCH_DOLLY_PAN;
|
|
467
|
+
break;
|
|
468
|
+
case Te.DOLLY_ROTATE:
|
|
469
|
+
if (this.enableZoom === !1 && this.enableRotate === !1) return;
|
|
470
|
+
this._handleTouchStartDollyRotate(r), this.state = A.TOUCH_DOLLY_ROTATE;
|
|
471
|
+
break;
|
|
472
|
+
default:
|
|
473
|
+
this.state = A.NONE;
|
|
474
|
+
}
|
|
475
|
+
break;
|
|
476
|
+
default:
|
|
477
|
+
this.state = A.NONE;
|
|
478
|
+
}
|
|
479
|
+
this.state !== A.NONE && this.dispatchEvent(xt);
|
|
480
|
+
}
|
|
481
|
+
function xs(r) {
|
|
482
|
+
switch (this._trackPointer(r), this.state) {
|
|
483
|
+
case A.TOUCH_ROTATE:
|
|
484
|
+
if (this.enableRotate === !1) return;
|
|
485
|
+
this._handleTouchMoveRotate(r), this.update();
|
|
486
|
+
break;
|
|
487
|
+
case A.TOUCH_PAN:
|
|
488
|
+
if (this.enablePan === !1) return;
|
|
489
|
+
this._handleTouchMovePan(r), this.update();
|
|
490
|
+
break;
|
|
491
|
+
case A.TOUCH_DOLLY_PAN:
|
|
492
|
+
if (this.enableZoom === !1 && this.enablePan === !1) return;
|
|
493
|
+
this._handleTouchMoveDollyPan(r), this.update();
|
|
494
|
+
break;
|
|
495
|
+
case A.TOUCH_DOLLY_ROTATE:
|
|
496
|
+
if (this.enableZoom === !1 && this.enableRotate === !1) return;
|
|
497
|
+
this._handleTouchMoveDollyRotate(r), this.update();
|
|
498
|
+
break;
|
|
499
|
+
default:
|
|
500
|
+
this.state = A.NONE;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
function Es(r) {
|
|
504
|
+
this.enabled !== !1 && r.preventDefault();
|
|
505
|
+
}
|
|
506
|
+
function Ms(r) {
|
|
507
|
+
r.key === "Control" && (this._controlActive = !0, this.domElement.getRootNode().addEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
|
|
508
|
+
}
|
|
509
|
+
function Ss(r) {
|
|
510
|
+
r.key === "Control" && (this._controlActive = !1, this.domElement.getRootNode().removeEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
|
|
511
|
+
}
|
|
512
|
+
const fe = new On(), j = new E(), le = new E(), O = new X(), Nt = {
|
|
513
|
+
X: new E(1, 0, 0),
|
|
514
|
+
Y: new E(0, 1, 0),
|
|
515
|
+
Z: new E(0, 0, 1)
|
|
516
|
+
}, at = { type: "change" }, kt = { type: "mouseDown", mode: null }, jt = { type: "mouseUp", mode: null }, Ht = { type: "objectChange" };
|
|
517
|
+
class vs extends nn {
|
|
518
|
+
/**
|
|
519
|
+
* Constructs a new controls instance.
|
|
520
|
+
*
|
|
521
|
+
* @param {Camera} camera - The camera of the rendered scene.
|
|
522
|
+
* @param {?HTMLElement} domElement - The HTML element used for event listeners.
|
|
523
|
+
*/
|
|
524
|
+
constructor(e, t = null) {
|
|
525
|
+
super(void 0, t);
|
|
526
|
+
const s = new Os(this);
|
|
527
|
+
this._root = s;
|
|
528
|
+
const n = new Cs();
|
|
529
|
+
this._gizmo = n, s.add(n);
|
|
530
|
+
const i = new Ds();
|
|
531
|
+
this._plane = i, s.add(i);
|
|
532
|
+
const o = this;
|
|
533
|
+
function a(M, S) {
|
|
534
|
+
let L = S;
|
|
535
|
+
Object.defineProperty(o, M, {
|
|
536
|
+
get: function() {
|
|
537
|
+
return L !== void 0 ? L : S;
|
|
538
|
+
},
|
|
539
|
+
set: function(v) {
|
|
540
|
+
L !== v && (L = v, i[M] = v, n[M] = v, o.dispatchEvent({ type: M + "-changed", value: v }), o.dispatchEvent(at));
|
|
541
|
+
}
|
|
542
|
+
}), o[M] = S, i[M] = S, n[M] = S;
|
|
543
|
+
}
|
|
544
|
+
a("camera", e), a("object", void 0), a("enabled", !0), a("axis", null), a("mode", "translate"), a("translationSnap", null), a("rotationSnap", null), a("scaleSnap", null), a("space", "world"), a("size", 1), a("dragging", !1), a("showX", !0), a("showY", !0), a("showZ", !0), a("showXY", !0), a("showYZ", !0), a("showXZ", !0), a("minX", -1 / 0), a("maxX", 1 / 0), a("minY", -1 / 0), a("maxY", 1 / 0), a("minZ", -1 / 0), a("maxZ", 1 / 0);
|
|
545
|
+
const l = new E(), h = new E(), u = new X(), c = new X(), d = new E(), p = new X(), f = new E(), m = new E(), y = new E(), _ = 0, x = new E();
|
|
546
|
+
a("worldPosition", l), a("worldPositionStart", h), a("worldQuaternion", u), a("worldQuaternionStart", c), a("cameraPosition", d), a("cameraQuaternion", p), a("pointStart", f), a("pointEnd", m), a("rotationAxis", y), a("rotationAngle", _), a("eye", x), this._offset = new E(), this._startNorm = new E(), this._endNorm = new E(), this._cameraScale = new E(), this._parentPosition = new E(), this._parentQuaternion = new X(), this._parentQuaternionInv = new X(), this._parentScale = new E(), this._worldScaleStart = new E(), this._worldQuaternionInv = new X(), this._worldScale = new E(), this._positionStart = new E(), this._quaternionStart = new X(), this._scaleStart = new E(), this._getPointer = Rs.bind(this), this._onPointerDown = Ps.bind(this), this._onPointerHover = As.bind(this), this._onPointerMove = Ls.bind(this), this._onPointerUp = Is.bind(this), t !== null && this.connect(t);
|
|
547
|
+
}
|
|
548
|
+
connect(e) {
|
|
549
|
+
super.connect(e), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointermove", this._onPointerHover), this.domElement.addEventListener("pointerup", this._onPointerUp), this.domElement.style.touchAction = "none";
|
|
550
|
+
}
|
|
551
|
+
disconnect() {
|
|
552
|
+
this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.removeEventListener("pointermove", this._onPointerHover), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.domElement.style.touchAction = "";
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Returns the visual representation of the controls. Add the helper to your scene to
|
|
556
|
+
* visually transform the attached 3D object.
|
|
557
|
+
*
|
|
558
|
+
* @return {TransformControlsRoot} The helper.
|
|
559
|
+
*/
|
|
560
|
+
getHelper() {
|
|
561
|
+
return this._root;
|
|
562
|
+
}
|
|
563
|
+
pointerHover(e) {
|
|
564
|
+
if (this.object === void 0 || this.dragging === !0) return;
|
|
565
|
+
e !== null && fe.setFromCamera(e, this.camera);
|
|
566
|
+
const t = lt(this._gizmo.picker[this.mode], fe);
|
|
567
|
+
t ? this.axis = t.object.name : this.axis = null;
|
|
568
|
+
}
|
|
569
|
+
pointerDown(e) {
|
|
570
|
+
if (!(this.object === void 0 || this.dragging === !0 || e != null && e.button !== 0) && this.axis !== null) {
|
|
571
|
+
e !== null && fe.setFromCamera(e, this.camera);
|
|
572
|
+
const t = lt(this._plane, fe, !0);
|
|
573
|
+
t && (this.object.updateMatrixWorld(), this.object.parent.updateMatrixWorld(), this._positionStart.copy(this.object.position), this._quaternionStart.copy(this.object.quaternion), this._scaleStart.copy(this.object.scale), this.object.matrixWorld.decompose(this.worldPositionStart, this.worldQuaternionStart, this._worldScaleStart), this.pointStart.copy(t.point).sub(this.worldPositionStart)), this.dragging = !0, kt.mode = this.mode, this.dispatchEvent(kt);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
pointerMove(e) {
|
|
577
|
+
const t = this.axis, s = this.mode, n = this.object;
|
|
578
|
+
let i = this.space;
|
|
579
|
+
if (s === "scale" ? i = "local" : (t === "E" || t === "XYZE" || t === "XYZ") && (i = "world"), n === void 0 || t === null || this.dragging === !1 || e !== null && e.button !== -1) return;
|
|
580
|
+
e !== null && fe.setFromCamera(e, this.camera);
|
|
581
|
+
const o = lt(this._plane, fe, !0);
|
|
582
|
+
if (o) {
|
|
583
|
+
if (this.pointEnd.copy(o.point).sub(this.worldPositionStart), s === "translate")
|
|
584
|
+
this._offset.copy(this.pointEnd).sub(this.pointStart), i === "local" && t !== "XYZ" && this._offset.applyQuaternion(this._worldQuaternionInv), t.indexOf("X") === -1 && (this._offset.x = 0), t.indexOf("Y") === -1 && (this._offset.y = 0), t.indexOf("Z") === -1 && (this._offset.z = 0), i === "local" && t !== "XYZ" ? this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale) : this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale), n.position.copy(this._offset).add(this._positionStart), this.translationSnap && (i === "local" && (n.position.applyQuaternion(O.copy(this._quaternionStart).invert()), t.search("X") !== -1 && (n.position.x = Math.round(n.position.x / this.translationSnap) * this.translationSnap), t.search("Y") !== -1 && (n.position.y = Math.round(n.position.y / this.translationSnap) * this.translationSnap), t.search("Z") !== -1 && (n.position.z = Math.round(n.position.z / this.translationSnap) * this.translationSnap), n.position.applyQuaternion(this._quaternionStart)), i === "world" && (n.parent && n.position.add(j.setFromMatrixPosition(n.parent.matrixWorld)), t.search("X") !== -1 && (n.position.x = Math.round(n.position.x / this.translationSnap) * this.translationSnap), t.search("Y") !== -1 && (n.position.y = Math.round(n.position.y / this.translationSnap) * this.translationSnap), t.search("Z") !== -1 && (n.position.z = Math.round(n.position.z / this.translationSnap) * this.translationSnap), n.parent && n.position.sub(j.setFromMatrixPosition(n.parent.matrixWorld)))), n.position.x = Math.max(this.minX, Math.min(this.maxX, n.position.x)), n.position.y = Math.max(this.minY, Math.min(this.maxY, n.position.y)), n.position.z = Math.max(this.minZ, Math.min(this.maxZ, n.position.z));
|
|
585
|
+
else if (s === "scale") {
|
|
586
|
+
if (t.search("XYZ") !== -1) {
|
|
587
|
+
let a = this.pointEnd.length() / this.pointStart.length();
|
|
588
|
+
this.pointEnd.dot(this.pointStart) < 0 && (a *= -1), le.set(a, a, a);
|
|
589
|
+
} else
|
|
590
|
+
j.copy(this.pointStart), le.copy(this.pointEnd), j.applyQuaternion(this._worldQuaternionInv), le.applyQuaternion(this._worldQuaternionInv), le.divide(j), t.search("X") === -1 && (le.x = 1), t.search("Y") === -1 && (le.y = 1), t.search("Z") === -1 && (le.z = 1);
|
|
591
|
+
n.scale.copy(this._scaleStart).multiply(le), this.scaleSnap && (t.search("X") !== -1 && (n.scale.x = Math.round(n.scale.x / this.scaleSnap) * this.scaleSnap || this.scaleSnap), t.search("Y") !== -1 && (n.scale.y = Math.round(n.scale.y / this.scaleSnap) * this.scaleSnap || this.scaleSnap), t.search("Z") !== -1 && (n.scale.z = Math.round(n.scale.z / this.scaleSnap) * this.scaleSnap || this.scaleSnap));
|
|
592
|
+
} else if (s === "rotate") {
|
|
593
|
+
this._offset.copy(this.pointEnd).sub(this.pointStart);
|
|
594
|
+
const a = 20 / this.worldPosition.distanceTo(j.setFromMatrixPosition(this.camera.matrixWorld));
|
|
595
|
+
let l = !1;
|
|
596
|
+
t === "XYZE" ? (this.rotationAxis.copy(this._offset).cross(this.eye).normalize(), this.rotationAngle = this._offset.dot(j.copy(this.rotationAxis).cross(this.eye)) * a) : (t === "X" || t === "Y" || t === "Z") && (this.rotationAxis.copy(Nt[t]), j.copy(Nt[t]), i === "local" && j.applyQuaternion(this.worldQuaternion), j.cross(this.eye), j.length() === 0 ? l = !0 : this.rotationAngle = this._offset.dot(j.normalize()) * a), (t === "E" || l) && (this.rotationAxis.copy(this.eye), this.rotationAngle = this.pointEnd.angleTo(this.pointStart), this._startNorm.copy(this.pointStart).normalize(), this._endNorm.copy(this.pointEnd).normalize(), this.rotationAngle *= this._endNorm.cross(this._startNorm).dot(this.eye) < 0 ? 1 : -1), this.rotationSnap && (this.rotationAngle = Math.round(this.rotationAngle / this.rotationSnap) * this.rotationSnap), i === "local" && t !== "E" && t !== "XYZE" ? (n.quaternion.copy(this._quaternionStart), n.quaternion.multiply(O.setFromAxisAngle(this.rotationAxis, this.rotationAngle)).normalize()) : (this.rotationAxis.applyQuaternion(this._parentQuaternionInv), n.quaternion.copy(O.setFromAxisAngle(this.rotationAxis, this.rotationAngle)), n.quaternion.multiply(this._quaternionStart).normalize());
|
|
597
|
+
}
|
|
598
|
+
this.dispatchEvent(at), this.dispatchEvent(Ht);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
pointerUp(e) {
|
|
602
|
+
e !== null && e.button !== 0 || (this.dragging && this.axis !== null && (jt.mode = this.mode, this.dispatchEvent(jt)), this.dragging = !1, this.axis = null);
|
|
603
|
+
}
|
|
604
|
+
dispose() {
|
|
605
|
+
this.disconnect(), this._root.dispose();
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Sets the 3D object that should be transformed and ensures the controls UI is visible.
|
|
609
|
+
*
|
|
610
|
+
* @param {Object3D} object - The 3D object that should be transformed.
|
|
611
|
+
* @return {TransformControls} A reference to this controls.
|
|
612
|
+
*/
|
|
613
|
+
attach(e) {
|
|
614
|
+
return this.object = e, this._root.visible = !0, this;
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Removes the current 3D object from the controls and makes the helper UI invisible.
|
|
618
|
+
*
|
|
619
|
+
* @return {TransformControls} A reference to this controls.
|
|
620
|
+
*/
|
|
621
|
+
detach() {
|
|
622
|
+
return this.object = void 0, this.axis = null, this._root.visible = !1, this;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Resets the object's position, rotation and scale to when the current transform began.
|
|
626
|
+
*/
|
|
627
|
+
reset() {
|
|
628
|
+
this.enabled && this.dragging && (this.object.position.copy(this._positionStart), this.object.quaternion.copy(this._quaternionStart), this.object.scale.copy(this._scaleStart), this.dispatchEvent(at), this.dispatchEvent(Ht), this.pointStart.copy(this.pointEnd));
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Returns the raycaster that is used for user interaction. This object is shared between all
|
|
632
|
+
* instances of `TransformControls`.
|
|
633
|
+
*
|
|
634
|
+
* @returns {Raycaster} The internal raycaster.
|
|
635
|
+
*/
|
|
636
|
+
getRaycaster() {
|
|
637
|
+
return fe;
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Returns the transformation mode.
|
|
641
|
+
*
|
|
642
|
+
* @returns {'translate'|'rotate'|'scale'} The transformation mode.
|
|
643
|
+
*/
|
|
644
|
+
getMode() {
|
|
645
|
+
return this.mode;
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* Sets the given transformation mode.
|
|
649
|
+
*
|
|
650
|
+
* @param {'translate'|'rotate'|'scale'} mode - The transformation mode to set.
|
|
651
|
+
*/
|
|
652
|
+
setMode(e) {
|
|
653
|
+
this.mode = e;
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Sets the translation snap.
|
|
657
|
+
*
|
|
658
|
+
* @param {?number} translationSnap - The translation snap to set.
|
|
659
|
+
*/
|
|
660
|
+
setTranslationSnap(e) {
|
|
661
|
+
this.translationSnap = e;
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Sets the rotation snap.
|
|
665
|
+
*
|
|
666
|
+
* @param {?number} rotationSnap - The rotation snap to set.
|
|
667
|
+
*/
|
|
668
|
+
setRotationSnap(e) {
|
|
669
|
+
this.rotationSnap = e;
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Sets the scale snap.
|
|
673
|
+
*
|
|
674
|
+
* @param {?number} scaleSnap - The scale snap to set.
|
|
675
|
+
*/
|
|
676
|
+
setScaleSnap(e) {
|
|
677
|
+
this.scaleSnap = e;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* Sets the size of the helper UI.
|
|
681
|
+
*
|
|
682
|
+
* @param {number} size - The size to set.
|
|
683
|
+
*/
|
|
684
|
+
setSize(e) {
|
|
685
|
+
this.size = e;
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Sets the coordinate space in which transformations are applied.
|
|
689
|
+
*
|
|
690
|
+
* @param {'world'|'local'} space - The space to set.
|
|
691
|
+
*/
|
|
692
|
+
setSpace(e) {
|
|
693
|
+
this.space = e;
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Sets the colors of the control's gizmo.
|
|
697
|
+
*
|
|
698
|
+
* @param {number|Color|string} xAxis - The x-axis color.
|
|
699
|
+
* @param {number|Color|string} yAxis - The y-axis color.
|
|
700
|
+
* @param {number|Color|string} zAxis - The z-axis color.
|
|
701
|
+
* @param {number|Color|string} active - The color for active elements.
|
|
702
|
+
*/
|
|
703
|
+
setColors(e, t, s, n) {
|
|
704
|
+
const i = this._gizmo.materialLib;
|
|
705
|
+
i.xAxis.color.set(e), i.yAxis.color.set(t), i.zAxis.color.set(s), i.active.color.set(n), i.xAxisTransparent.color.set(e), i.yAxisTransparent.color.set(t), i.zAxisTransparent.color.set(s), i.activeTransparent.color.set(n), i.xAxis._color && i.xAxis._color.set(e), i.yAxis._color && i.yAxis._color.set(t), i.zAxis._color && i.zAxis._color.set(s), i.active._color && i.active._color.set(n), i.xAxisTransparent._color && i.xAxisTransparent._color.set(e), i.yAxisTransparent._color && i.yAxisTransparent._color.set(t), i.zAxisTransparent._color && i.zAxisTransparent._color.set(s), i.activeTransparent._color && i.activeTransparent._color.set(n);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
function Rs(r) {
|
|
709
|
+
if (this.domElement.ownerDocument.pointerLockElement)
|
|
710
|
+
return {
|
|
711
|
+
x: 0,
|
|
712
|
+
y: 0,
|
|
713
|
+
button: r.button
|
|
714
|
+
};
|
|
715
|
+
{
|
|
716
|
+
const e = this.domElement.getBoundingClientRect();
|
|
717
|
+
return {
|
|
718
|
+
x: (r.clientX - e.left) / e.width * 2 - 1,
|
|
719
|
+
y: -(r.clientY - e.top) / e.height * 2 + 1,
|
|
720
|
+
button: r.button
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
function As(r) {
|
|
725
|
+
if (this.enabled)
|
|
726
|
+
switch (r.pointerType) {
|
|
727
|
+
case "mouse":
|
|
728
|
+
case "pen":
|
|
729
|
+
this.pointerHover(this._getPointer(r));
|
|
730
|
+
break;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
function Ps(r) {
|
|
734
|
+
this.enabled && (document.pointerLockElement || this.domElement.setPointerCapture(r.pointerId), this.domElement.addEventListener("pointermove", this._onPointerMove), this.pointerHover(this._getPointer(r)), this.pointerDown(this._getPointer(r)));
|
|
735
|
+
}
|
|
736
|
+
function Ls(r) {
|
|
737
|
+
this.enabled && this.pointerMove(this._getPointer(r));
|
|
738
|
+
}
|
|
739
|
+
function Is(r) {
|
|
740
|
+
this.enabled && (this.domElement.releasePointerCapture(r.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.pointerUp(this._getPointer(r)));
|
|
741
|
+
}
|
|
742
|
+
function lt(r, e, t) {
|
|
743
|
+
const s = e.intersectObject(r, !0);
|
|
744
|
+
for (let n = 0; n < s.length; n++)
|
|
745
|
+
if (s[n].object.visible || t)
|
|
746
|
+
return s[n];
|
|
747
|
+
return !1;
|
|
748
|
+
}
|
|
749
|
+
const Ze = new Dn(), P = new E(0, 1, 0), Ft = new E(0, 0, 0), Ut = new Me(), Qe = new X(), et = new X(), ee = new E(), zt = new Me(), Oe = new E(1, 0, 0), ge = new E(0, 1, 0), Ce = new E(0, 0, 1), qe = new E(), Ae = new E(), Pe = new E();
|
|
750
|
+
class Os extends je {
|
|
751
|
+
constructor(e) {
|
|
752
|
+
super(), this.isTransformControlsRoot = !0, this.controls = e, this.visible = !1;
|
|
753
|
+
}
|
|
754
|
+
// updateMatrixWorld updates key transformation variables
|
|
755
|
+
updateMatrixWorld(e) {
|
|
756
|
+
const t = this.controls;
|
|
757
|
+
t.object !== void 0 && (t.object.updateMatrixWorld(), t.object.parent === null ? console.error("TransformControls: The attached 3D object must be a part of the scene graph.") : t.object.parent.matrixWorld.decompose(t._parentPosition, t._parentQuaternion, t._parentScale), t.object.matrixWorld.decompose(t.worldPosition, t.worldQuaternion, t._worldScale), t._parentQuaternionInv.copy(t._parentQuaternion).invert(), t._worldQuaternionInv.copy(t.worldQuaternion).invert()), t.camera.updateMatrixWorld(), t.camera.matrixWorld.decompose(t.cameraPosition, t.cameraQuaternion, t._cameraScale), t.camera.isOrthographicCamera ? t.camera.getWorldDirection(t.eye).negate() : t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(), super.updateMatrixWorld(e);
|
|
758
|
+
}
|
|
759
|
+
dispose() {
|
|
760
|
+
this.traverse(function(e) {
|
|
761
|
+
e.geometry && e.geometry.dispose(), e.material && e.material.dispose();
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
class Cs extends je {
|
|
766
|
+
constructor() {
|
|
767
|
+
super(), this.isTransformControlsGizmo = !0, this.type = "TransformControlsGizmo";
|
|
768
|
+
const e = new ye({
|
|
769
|
+
depthTest: !1,
|
|
770
|
+
depthWrite: !1,
|
|
771
|
+
fog: !1,
|
|
772
|
+
toneMapped: !1,
|
|
773
|
+
transparent: !0
|
|
774
|
+
}), t = new De({
|
|
775
|
+
depthTest: !1,
|
|
776
|
+
depthWrite: !1,
|
|
777
|
+
fog: !1,
|
|
778
|
+
toneMapped: !1,
|
|
779
|
+
transparent: !0
|
|
780
|
+
}), s = e.clone();
|
|
781
|
+
s.opacity = 0.15;
|
|
782
|
+
const n = t.clone();
|
|
783
|
+
n.opacity = 0.5;
|
|
784
|
+
const i = e.clone();
|
|
785
|
+
i.color.setHex(16711680);
|
|
786
|
+
const o = e.clone();
|
|
787
|
+
o.color.setHex(65280);
|
|
788
|
+
const a = e.clone();
|
|
789
|
+
a.color.setHex(255);
|
|
790
|
+
const l = e.clone();
|
|
791
|
+
l.color.setHex(16711680), l.opacity = 0.5;
|
|
792
|
+
const h = e.clone();
|
|
793
|
+
h.color.setHex(65280), h.opacity = 0.5;
|
|
794
|
+
const u = e.clone();
|
|
795
|
+
u.color.setHex(255), u.opacity = 0.5;
|
|
796
|
+
const c = e.clone();
|
|
797
|
+
c.opacity = 0.25;
|
|
798
|
+
const d = e.clone();
|
|
799
|
+
d.color.setHex(16776960), d.opacity = 0.25;
|
|
800
|
+
const p = e.clone();
|
|
801
|
+
p.color.setHex(16776960);
|
|
802
|
+
const f = e.clone();
|
|
803
|
+
f.color.setHex(7895160), this.materialLib = {
|
|
804
|
+
xAxis: i,
|
|
805
|
+
yAxis: o,
|
|
806
|
+
zAxis: a,
|
|
807
|
+
active: p,
|
|
808
|
+
xAxisTransparent: l,
|
|
809
|
+
yAxisTransparent: h,
|
|
810
|
+
zAxisTransparent: u,
|
|
811
|
+
activeTransparent: d
|
|
812
|
+
};
|
|
813
|
+
const m = new z(0, 0.04, 0.1, 12);
|
|
814
|
+
m.translate(0, 0.05, 0);
|
|
815
|
+
const y = new F(0.08, 0.08, 0.08);
|
|
816
|
+
y.translate(0, 0.04, 0);
|
|
817
|
+
const _ = new He();
|
|
818
|
+
_.setAttribute("position", new he([0, 0, 0, 1, 0, 0], 3));
|
|
819
|
+
const x = new z(75e-4, 75e-4, 0.5, 3);
|
|
820
|
+
x.translate(0, 0.25, 0);
|
|
821
|
+
function M(V, ze) {
|
|
822
|
+
const $ = new Re(V, 75e-4, 3, 64, ze * Math.PI * 2);
|
|
823
|
+
return $.rotateY(Math.PI / 2), $.rotateX(Math.PI / 2), $;
|
|
824
|
+
}
|
|
825
|
+
function S() {
|
|
826
|
+
const V = new He();
|
|
827
|
+
return V.setAttribute("position", new he([0, 0, 0, 1, 1, 1], 3)), V;
|
|
828
|
+
}
|
|
829
|
+
const L = {
|
|
830
|
+
X: [
|
|
831
|
+
[new b(m, i), [0.5, 0, 0], [0, 0, -Math.PI / 2]],
|
|
832
|
+
[new b(m, i), [-0.5, 0, 0], [0, 0, Math.PI / 2]],
|
|
833
|
+
[new b(x, i), [0, 0, 0], [0, 0, -Math.PI / 2]]
|
|
834
|
+
],
|
|
835
|
+
Y: [
|
|
836
|
+
[new b(m, o), [0, 0.5, 0]],
|
|
837
|
+
[new b(m, o), [0, -0.5, 0], [Math.PI, 0, 0]],
|
|
838
|
+
[new b(x, o)]
|
|
839
|
+
],
|
|
840
|
+
Z: [
|
|
841
|
+
[new b(m, a), [0, 0, 0.5], [Math.PI / 2, 0, 0]],
|
|
842
|
+
[new b(m, a), [0, 0, -0.5], [-Math.PI / 2, 0, 0]],
|
|
843
|
+
[new b(x, a), null, [Math.PI / 2, 0, 0]]
|
|
844
|
+
],
|
|
845
|
+
XYZ: [
|
|
846
|
+
[new b(new Ke(0.1, 0), c), [0, 0, 0]]
|
|
847
|
+
],
|
|
848
|
+
XY: [
|
|
849
|
+
[new b(new F(0.15, 0.15, 0.01), u), [0.15, 0.15, 0]]
|
|
850
|
+
],
|
|
851
|
+
YZ: [
|
|
852
|
+
[new b(new F(0.15, 0.15, 0.01), l), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
853
|
+
],
|
|
854
|
+
XZ: [
|
|
855
|
+
[new b(new F(0.15, 0.15, 0.01), h), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
856
|
+
]
|
|
857
|
+
}, v = {
|
|
858
|
+
X: [
|
|
859
|
+
[new b(new z(0.2, 0, 0.6, 4), s), [0.3, 0, 0], [0, 0, -Math.PI / 2]],
|
|
860
|
+
[new b(new z(0.2, 0, 0.6, 4), s), [-0.3, 0, 0], [0, 0, Math.PI / 2]]
|
|
861
|
+
],
|
|
862
|
+
Y: [
|
|
863
|
+
[new b(new z(0.2, 0, 0.6, 4), s), [0, 0.3, 0]],
|
|
864
|
+
[new b(new z(0.2, 0, 0.6, 4), s), [0, -0.3, 0], [0, 0, Math.PI]]
|
|
865
|
+
],
|
|
866
|
+
Z: [
|
|
867
|
+
[new b(new z(0.2, 0, 0.6, 4), s), [0, 0, 0.3], [Math.PI / 2, 0, 0]],
|
|
868
|
+
[new b(new z(0.2, 0, 0.6, 4), s), [0, 0, -0.3], [-Math.PI / 2, 0, 0]]
|
|
869
|
+
],
|
|
870
|
+
XYZ: [
|
|
871
|
+
[new b(new Ke(0.2, 0), s)]
|
|
872
|
+
],
|
|
873
|
+
XY: [
|
|
874
|
+
[new b(new F(0.2, 0.2, 0.01), s), [0.15, 0.15, 0]]
|
|
875
|
+
],
|
|
876
|
+
YZ: [
|
|
877
|
+
[new b(new F(0.2, 0.2, 0.01), s), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
878
|
+
],
|
|
879
|
+
XZ: [
|
|
880
|
+
[new b(new F(0.2, 0.2, 0.01), s), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
881
|
+
]
|
|
882
|
+
}, I = {
|
|
883
|
+
START: [
|
|
884
|
+
[new b(new Ke(0.01, 2), n), null, null, null, "helper"]
|
|
885
|
+
],
|
|
886
|
+
END: [
|
|
887
|
+
[new b(new Ke(0.01, 2), n), null, null, null, "helper"]
|
|
888
|
+
],
|
|
889
|
+
DELTA: [
|
|
890
|
+
[new re(S(), n), null, null, null, "helper"]
|
|
891
|
+
],
|
|
892
|
+
X: [
|
|
893
|
+
[new re(_, n), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
|
|
894
|
+
],
|
|
895
|
+
Y: [
|
|
896
|
+
[new re(_, n), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], "helper"]
|
|
897
|
+
],
|
|
898
|
+
Z: [
|
|
899
|
+
[new re(_, n), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], "helper"]
|
|
900
|
+
]
|
|
901
|
+
}, se = {
|
|
902
|
+
XYZE: [
|
|
903
|
+
[new b(M(0.5, 1), f), null, [0, Math.PI / 2, 0]]
|
|
904
|
+
],
|
|
905
|
+
X: [
|
|
906
|
+
[new b(M(0.5, 0.5), i)]
|
|
907
|
+
],
|
|
908
|
+
Y: [
|
|
909
|
+
[new b(M(0.5, 0.5), o), null, [0, 0, -Math.PI / 2]]
|
|
910
|
+
],
|
|
911
|
+
Z: [
|
|
912
|
+
[new b(M(0.5, 0.5), a), null, [0, Math.PI / 2, 0]]
|
|
913
|
+
],
|
|
914
|
+
E: [
|
|
915
|
+
[new b(M(0.75, 1), d), null, [0, Math.PI / 2, 0]]
|
|
916
|
+
]
|
|
917
|
+
}, J = {
|
|
918
|
+
AXIS: [
|
|
919
|
+
[new re(_, n), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
|
|
920
|
+
]
|
|
921
|
+
}, de = {
|
|
922
|
+
XYZE: [
|
|
923
|
+
[new b(new Cn(0.25, 10, 8), s)]
|
|
924
|
+
],
|
|
925
|
+
X: [
|
|
926
|
+
[new b(new Re(0.5, 0.1, 4, 24), s), [0, 0, 0], [0, -Math.PI / 2, -Math.PI / 2]]
|
|
927
|
+
],
|
|
928
|
+
Y: [
|
|
929
|
+
[new b(new Re(0.5, 0.1, 4, 24), s), [0, 0, 0], [Math.PI / 2, 0, 0]]
|
|
930
|
+
],
|
|
931
|
+
Z: [
|
|
932
|
+
[new b(new Re(0.5, 0.1, 4, 24), s), [0, 0, 0], [0, 0, -Math.PI / 2]]
|
|
933
|
+
],
|
|
934
|
+
E: [
|
|
935
|
+
[new b(new Re(0.75, 0.1, 2, 24), s)]
|
|
936
|
+
]
|
|
937
|
+
}, W = {
|
|
938
|
+
X: [
|
|
939
|
+
[new b(y, i), [0.5, 0, 0], [0, 0, -Math.PI / 2]],
|
|
940
|
+
[new b(x, i), [0, 0, 0], [0, 0, -Math.PI / 2]],
|
|
941
|
+
[new b(y, i), [-0.5, 0, 0], [0, 0, Math.PI / 2]]
|
|
942
|
+
],
|
|
943
|
+
Y: [
|
|
944
|
+
[new b(y, o), [0, 0.5, 0]],
|
|
945
|
+
[new b(x, o)],
|
|
946
|
+
[new b(y, o), [0, -0.5, 0], [0, 0, Math.PI]]
|
|
947
|
+
],
|
|
948
|
+
Z: [
|
|
949
|
+
[new b(y, a), [0, 0, 0.5], [Math.PI / 2, 0, 0]],
|
|
950
|
+
[new b(x, a), [0, 0, 0], [Math.PI / 2, 0, 0]],
|
|
951
|
+
[new b(y, a), [0, 0, -0.5], [-Math.PI / 2, 0, 0]]
|
|
952
|
+
],
|
|
953
|
+
XY: [
|
|
954
|
+
[new b(new F(0.15, 0.15, 0.01), u), [0.15, 0.15, 0]]
|
|
955
|
+
],
|
|
956
|
+
YZ: [
|
|
957
|
+
[new b(new F(0.15, 0.15, 0.01), l), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
958
|
+
],
|
|
959
|
+
XZ: [
|
|
960
|
+
[new b(new F(0.15, 0.15, 0.01), h), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
961
|
+
],
|
|
962
|
+
XYZ: [
|
|
963
|
+
[new b(new F(0.1, 0.1, 0.1), c)]
|
|
964
|
+
]
|
|
965
|
+
}, T = {
|
|
966
|
+
X: [
|
|
967
|
+
[new b(new z(0.2, 0, 0.6, 4), s), [0.3, 0, 0], [0, 0, -Math.PI / 2]],
|
|
968
|
+
[new b(new z(0.2, 0, 0.6, 4), s), [-0.3, 0, 0], [0, 0, Math.PI / 2]]
|
|
969
|
+
],
|
|
970
|
+
Y: [
|
|
971
|
+
[new b(new z(0.2, 0, 0.6, 4), s), [0, 0.3, 0]],
|
|
972
|
+
[new b(new z(0.2, 0, 0.6, 4), s), [0, -0.3, 0], [0, 0, Math.PI]]
|
|
973
|
+
],
|
|
974
|
+
Z: [
|
|
975
|
+
[new b(new z(0.2, 0, 0.6, 4), s), [0, 0, 0.3], [Math.PI / 2, 0, 0]],
|
|
976
|
+
[new b(new z(0.2, 0, 0.6, 4), s), [0, 0, -0.3], [-Math.PI / 2, 0, 0]]
|
|
977
|
+
],
|
|
978
|
+
XY: [
|
|
979
|
+
[new b(new F(0.2, 0.2, 0.01), s), [0.15, 0.15, 0]]
|
|
980
|
+
],
|
|
981
|
+
YZ: [
|
|
982
|
+
[new b(new F(0.2, 0.2, 0.01), s), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
983
|
+
],
|
|
984
|
+
XZ: [
|
|
985
|
+
[new b(new F(0.2, 0.2, 0.01), s), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
986
|
+
],
|
|
987
|
+
XYZ: [
|
|
988
|
+
[new b(new F(0.2, 0.2, 0.2), s), [0, 0, 0]]
|
|
989
|
+
]
|
|
990
|
+
}, k = {
|
|
991
|
+
X: [
|
|
992
|
+
[new re(_, n), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
|
|
993
|
+
],
|
|
994
|
+
Y: [
|
|
995
|
+
[new re(_, n), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], "helper"]
|
|
996
|
+
],
|
|
997
|
+
Z: [
|
|
998
|
+
[new re(_, n), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], "helper"]
|
|
999
|
+
]
|
|
1000
|
+
};
|
|
1001
|
+
function ie(V) {
|
|
1002
|
+
const ze = new je();
|
|
1003
|
+
for (const $ in V)
|
|
1004
|
+
for (let we = V[$].length; we--; ) {
|
|
1005
|
+
const U = V[$][we][0].clone(), Ge = V[$][we][1], Xe = V[$][we][2], Ye = V[$][we][3], _n = V[$][we][4];
|
|
1006
|
+
U.name = $, U.tag = _n, Ge && U.position.set(Ge[0], Ge[1], Ge[2]), Xe && U.rotation.set(Xe[0], Xe[1], Xe[2]), Ye && U.scale.set(Ye[0], Ye[1], Ye[2]), U.updateMatrix();
|
|
1007
|
+
const St = U.geometry.clone();
|
|
1008
|
+
St.applyMatrix4(U.matrix), U.geometry = St, U.renderOrder = 1 / 0, U.position.set(0, 0, 0), U.rotation.set(0, 0, 0), U.scale.set(1, 1, 1), ze.add(U);
|
|
1009
|
+
}
|
|
1010
|
+
return ze;
|
|
1011
|
+
}
|
|
1012
|
+
this.gizmo = {}, this.picker = {}, this.helper = {}, this.add(this.gizmo.translate = ie(L)), this.add(this.gizmo.rotate = ie(se)), this.add(this.gizmo.scale = ie(W)), this.add(this.picker.translate = ie(v)), this.add(this.picker.rotate = ie(de)), this.add(this.picker.scale = ie(T)), this.add(this.helper.translate = ie(I)), this.add(this.helper.rotate = ie(J)), this.add(this.helper.scale = ie(k)), this.picker.translate.visible = !1, this.picker.rotate.visible = !1, this.picker.scale.visible = !1;
|
|
1013
|
+
}
|
|
1014
|
+
// updateMatrixWorld will update transformations and appearance of individual handles
|
|
1015
|
+
updateMatrixWorld(e) {
|
|
1016
|
+
const s = (this.mode === "scale" ? "local" : this.space) === "local" ? this.worldQuaternion : et;
|
|
1017
|
+
this.gizmo.translate.visible = this.mode === "translate", this.gizmo.rotate.visible = this.mode === "rotate", this.gizmo.scale.visible = this.mode === "scale", this.helper.translate.visible = this.mode === "translate", this.helper.rotate.visible = this.mode === "rotate", this.helper.scale.visible = this.mode === "scale";
|
|
1018
|
+
let n = [];
|
|
1019
|
+
n = n.concat(this.picker[this.mode].children), n = n.concat(this.gizmo[this.mode].children), n = n.concat(this.helper[this.mode].children);
|
|
1020
|
+
for (let i = 0; i < n.length; i++) {
|
|
1021
|
+
const o = n[i];
|
|
1022
|
+
o.visible = !0, o.rotation.set(0, 0, 0), o.position.copy(this.worldPosition);
|
|
1023
|
+
let a;
|
|
1024
|
+
if (this.camera.isOrthographicCamera ? a = (this.camera.top - this.camera.bottom) / this.camera.zoom : a = this.worldPosition.distanceTo(this.cameraPosition) * Math.min(1.9 * Math.tan(Math.PI * this.camera.fov / 360) / this.camera.zoom, 7), o.scale.set(1, 1, 1).multiplyScalar(a * this.size / 4), o.tag === "helper") {
|
|
1025
|
+
o.visible = !1, o.name === "AXIS" ? (o.visible = !!this.axis, this.axis === "X" && (O.setFromEuler(Ze.set(0, 0, 0)), o.quaternion.copy(s).multiply(O), Math.abs(P.copy(Oe).applyQuaternion(s).dot(this.eye)) > 0.9 && (o.visible = !1)), this.axis === "Y" && (O.setFromEuler(Ze.set(0, 0, Math.PI / 2)), o.quaternion.copy(s).multiply(O), Math.abs(P.copy(ge).applyQuaternion(s).dot(this.eye)) > 0.9 && (o.visible = !1)), this.axis === "Z" && (O.setFromEuler(Ze.set(0, Math.PI / 2, 0)), o.quaternion.copy(s).multiply(O), Math.abs(P.copy(Ce).applyQuaternion(s).dot(this.eye)) > 0.9 && (o.visible = !1)), this.axis === "XYZE" && (O.setFromEuler(Ze.set(0, Math.PI / 2, 0)), P.copy(this.rotationAxis), o.quaternion.setFromRotationMatrix(Ut.lookAt(Ft, P, ge)), o.quaternion.multiply(O), o.visible = this.dragging), this.axis === "E" && (o.visible = !1)) : o.name === "START" ? (o.position.copy(this.worldPositionStart), o.visible = this.dragging) : o.name === "END" ? (o.position.copy(this.worldPosition), o.visible = this.dragging) : o.name === "DELTA" ? (o.position.copy(this.worldPositionStart), o.quaternion.copy(this.worldQuaternionStart), j.set(1e-10, 1e-10, 1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1), j.applyQuaternion(this.worldQuaternionStart.clone().invert()), o.scale.copy(j), o.visible = this.dragging) : (o.quaternion.copy(s), this.dragging ? o.position.copy(this.worldPositionStart) : o.position.copy(this.worldPosition), this.axis && (o.visible = this.axis.search(o.name) !== -1));
|
|
1026
|
+
continue;
|
|
1027
|
+
}
|
|
1028
|
+
o.quaternion.copy(s), this.mode === "translate" || this.mode === "scale" ? (o.name === "X" && Math.abs(P.copy(Oe).applyQuaternion(s).dot(this.eye)) > 0.99 && (o.scale.set(1e-10, 1e-10, 1e-10), o.visible = !1), o.name === "Y" && Math.abs(P.copy(ge).applyQuaternion(s).dot(this.eye)) > 0.99 && (o.scale.set(1e-10, 1e-10, 1e-10), o.visible = !1), o.name === "Z" && Math.abs(P.copy(Ce).applyQuaternion(s).dot(this.eye)) > 0.99 && (o.scale.set(1e-10, 1e-10, 1e-10), o.visible = !1), o.name === "XY" && Math.abs(P.copy(Ce).applyQuaternion(s).dot(this.eye)) < 0.2 && (o.scale.set(1e-10, 1e-10, 1e-10), o.visible = !1), o.name === "YZ" && Math.abs(P.copy(Oe).applyQuaternion(s).dot(this.eye)) < 0.2 && (o.scale.set(1e-10, 1e-10, 1e-10), o.visible = !1), o.name === "XZ" && Math.abs(P.copy(ge).applyQuaternion(s).dot(this.eye)) < 0.2 && (o.scale.set(1e-10, 1e-10, 1e-10), o.visible = !1)) : this.mode === "rotate" && (Qe.copy(s), P.copy(this.eye).applyQuaternion(O.copy(s).invert()), o.name.search("E") !== -1 && o.quaternion.setFromRotationMatrix(Ut.lookAt(this.eye, Ft, ge)), o.name === "X" && (O.setFromAxisAngle(Oe, Math.atan2(-P.y, P.z)), O.multiplyQuaternions(Qe, O), o.quaternion.copy(O)), o.name === "Y" && (O.setFromAxisAngle(ge, Math.atan2(P.x, P.z)), O.multiplyQuaternions(Qe, O), o.quaternion.copy(O)), o.name === "Z" && (O.setFromAxisAngle(Ce, Math.atan2(P.y, P.x)), O.multiplyQuaternions(Qe, O), o.quaternion.copy(O))), o.visible = o.visible && (o.name.indexOf("X") === -1 || this.showX), o.visible = o.visible && (o.name.indexOf("Y") === -1 || this.showY), o.visible = o.visible && (o.name.indexOf("Z") === -1 || this.showZ), o.visible = o.visible && (o.name.indexOf("E") === -1 || this.showX && this.showY && this.showZ), o.visible = o.visible && (o.name.indexOf("XY") === -1 || this.showXY), o.visible = o.visible && (o.name.indexOf("YZ") === -1 || this.showYZ), o.visible = o.visible && (o.name.indexOf("XZ") === -1 || this.showXZ), o.material._color = o.material._color || o.material.color.clone(), o.material._opacity = o.material._opacity || o.material.opacity, o.material.color.copy(o.material._color), o.material.opacity = o.material._opacity, this.enabled && this.axis && (o.name === this.axis ? (o.material.color.copy(this.materialLib.active.color), o.material.opacity = 1) : this.axis.split("").some(function(l) {
|
|
1029
|
+
return o.name === l;
|
|
1030
|
+
}) && (o.material.color.copy(this.materialLib.active.color), o.material.opacity = 1));
|
|
1031
|
+
}
|
|
1032
|
+
super.updateMatrixWorld(e);
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
class Ds extends b {
|
|
1036
|
+
constructor() {
|
|
1037
|
+
super(
|
|
1038
|
+
new Nn(1e5, 1e5, 2, 2),
|
|
1039
|
+
new ye({ visible: !1, wireframe: !0, side: on, transparent: !0, opacity: 0.1, toneMapped: !1 })
|
|
1040
|
+
), this.isTransformControlsPlane = !0, this.type = "TransformControlsPlane";
|
|
1041
|
+
}
|
|
1042
|
+
updateMatrixWorld(e) {
|
|
1043
|
+
let t = this.space;
|
|
1044
|
+
switch (this.position.copy(this.worldPosition), this.mode === "scale" && (t = "local"), qe.copy(Oe).applyQuaternion(t === "local" ? this.worldQuaternion : et), Ae.copy(ge).applyQuaternion(t === "local" ? this.worldQuaternion : et), Pe.copy(Ce).applyQuaternion(t === "local" ? this.worldQuaternion : et), P.copy(Ae), this.mode) {
|
|
1045
|
+
case "translate":
|
|
1046
|
+
case "scale":
|
|
1047
|
+
switch (this.axis) {
|
|
1048
|
+
case "X":
|
|
1049
|
+
P.copy(this.eye).cross(qe), ee.copy(qe).cross(P);
|
|
1050
|
+
break;
|
|
1051
|
+
case "Y":
|
|
1052
|
+
P.copy(this.eye).cross(Ae), ee.copy(Ae).cross(P);
|
|
1053
|
+
break;
|
|
1054
|
+
case "Z":
|
|
1055
|
+
P.copy(this.eye).cross(Pe), ee.copy(Pe).cross(P);
|
|
1056
|
+
break;
|
|
1057
|
+
case "XY":
|
|
1058
|
+
ee.copy(Pe);
|
|
1059
|
+
break;
|
|
1060
|
+
case "YZ":
|
|
1061
|
+
ee.copy(qe);
|
|
1062
|
+
break;
|
|
1063
|
+
case "XZ":
|
|
1064
|
+
P.copy(Pe), ee.copy(Ae);
|
|
1065
|
+
break;
|
|
1066
|
+
case "XYZ":
|
|
1067
|
+
case "E":
|
|
1068
|
+
ee.set(0, 0, 0);
|
|
1069
|
+
break;
|
|
1070
|
+
}
|
|
1071
|
+
break;
|
|
1072
|
+
case "rotate":
|
|
1073
|
+
default:
|
|
1074
|
+
ee.set(0, 0, 0);
|
|
1075
|
+
}
|
|
1076
|
+
ee.length() === 0 ? this.quaternion.copy(this.cameraQuaternion) : (zt.lookAt(j.set(0, 0, 0), ee, P), this.quaternion.setFromRotationMatrix(zt)), super.updateMatrixWorld(e);
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
const w = {
|
|
1080
|
+
/** Three.js 场景 */
|
|
1081
|
+
scene: null,
|
|
1082
|
+
/** 透视相机 */
|
|
1083
|
+
camera: null,
|
|
1084
|
+
/** WebGL 渲染器 */
|
|
1085
|
+
renderer: null,
|
|
1086
|
+
/** 轨道控制器(用于场景浏览) */
|
|
1087
|
+
orbitControls: null,
|
|
1088
|
+
/** 变换控制器(用于平移/旋转/缩放物体) */
|
|
1089
|
+
transformControls: null,
|
|
1090
|
+
/** 编辑器挂载的 DOM 容器 */
|
|
1091
|
+
container: null,
|
|
1092
|
+
/** 网格辅助对象(地板) */
|
|
1093
|
+
gridHelper: null,
|
|
1094
|
+
/** 当前选中的物体 */
|
|
1095
|
+
selectedObject: null
|
|
1096
|
+
};
|
|
1097
|
+
let ct = !1, ve = !1, _e = null, _t = null, tt = null, be = [];
|
|
1098
|
+
function Ns(r) {
|
|
1099
|
+
w.container = r, ks(), js(), Hs(), Fs(), zs(), Us(), Qs(), Gs(), pn(), r.addEventListener("click", Ys), window.addEventListener("resize", Xs);
|
|
1100
|
+
}
|
|
1101
|
+
function ks() {
|
|
1102
|
+
const r = new N.WebGLRenderer({ antialias: !0, alpha: !0 });
|
|
1103
|
+
r.setSize(w.container.clientWidth, w.container.clientHeight), r.setPixelRatio(Math.min(window.devicePixelRatio, 2)), w.container.appendChild(r.domElement), w.renderer = r;
|
|
1104
|
+
}
|
|
1105
|
+
function js() {
|
|
1106
|
+
w.scene = new N.Scene(), w.scene.name = "sl_scene";
|
|
1107
|
+
}
|
|
1108
|
+
function Hs() {
|
|
1109
|
+
const r = new N.GridHelper(30, 30, 8956671, 3364232);
|
|
1110
|
+
r.name = "地板", w.scene.add(r), w.gridHelper = r;
|
|
1111
|
+
}
|
|
1112
|
+
function Fs() {
|
|
1113
|
+
const r = w.container, e = r.clientWidth / r.clientHeight, t = new N.PerspectiveCamera(45, e, 0.1, 1e3);
|
|
1114
|
+
t.position.set(0, 6, 15), t.lookAt(0, 0, 0), w.camera = t;
|
|
1115
|
+
}
|
|
1116
|
+
function Us() {
|
|
1117
|
+
const r = new ps(w.camera, w.renderer.domElement);
|
|
1118
|
+
r.minDistance = 0, r.maxDistance = 1 / 0, r.addEventListener("start", () => {
|
|
1119
|
+
ct = !1;
|
|
1120
|
+
}), r.addEventListener("change", () => {
|
|
1121
|
+
ct = !0;
|
|
1122
|
+
}), r.addEventListener("end", () => {
|
|
1123
|
+
ct && (ve = !0, setTimeout(() => {
|
|
1124
|
+
ve = !1;
|
|
1125
|
+
}, 200));
|
|
1126
|
+
}), w.orbitControls = r;
|
|
1127
|
+
}
|
|
1128
|
+
function zs() {
|
|
1129
|
+
const r = new vs(
|
|
1130
|
+
w.camera,
|
|
1131
|
+
w.renderer.domElement
|
|
1132
|
+
);
|
|
1133
|
+
r.addEventListener("dragging-changed", (e) => {
|
|
1134
|
+
w.orbitControls.enabled = !e.value, e.value || (ve = !0, setTimeout(() => {
|
|
1135
|
+
ve = !1;
|
|
1136
|
+
}, 200));
|
|
1137
|
+
}), r.addEventListener("objectChange", () => {
|
|
1138
|
+
_t && w.selectedObject && _t(w.selectedObject);
|
|
1139
|
+
}), w.scene.add(r.getHelper()), w.transformControls = r;
|
|
1140
|
+
}
|
|
1141
|
+
function Gs() {
|
|
1142
|
+
const r = new N.AmbientLight(16777215, 2);
|
|
1143
|
+
w.scene.add(r);
|
|
1144
|
+
const e = new N.DirectionalLight(16777215, 3);
|
|
1145
|
+
e.position.set(48, 104, 138), w.scene.add(e);
|
|
1146
|
+
const t = new N.BoxGeometry(1, 1, 1), s = new N.MeshStandardMaterial({ color: 16777215 }), n = new N.Mesh(t, s);
|
|
1147
|
+
n.position.y = 1, n.userData.isMovable = !0, n.name = "默认立方体", nt(n, !0);
|
|
1148
|
+
}
|
|
1149
|
+
function pn() {
|
|
1150
|
+
var r, e;
|
|
1151
|
+
requestAnimationFrame(pn), us.update(), (r = w.orbitControls) == null || r.update(), (e = w.renderer) == null || e.render(w.scene, w.camera);
|
|
1152
|
+
}
|
|
1153
|
+
function Xs() {
|
|
1154
|
+
if (!w.container || !w.camera || !w.renderer) return;
|
|
1155
|
+
const r = w.container.clientWidth, e = w.container.clientHeight;
|
|
1156
|
+
r === 0 || e === 0 || (w.camera.aspect = r / e, w.camera.updateProjectionMatrix(), w.renderer.setSize(r, e));
|
|
1157
|
+
}
|
|
1158
|
+
function Et(r) {
|
|
1159
|
+
w.selectedObject !== r && (w.selectedObject && w.transformControls.detach(), w.selectedObject = r, w.transformControls.attach(r), w.transformControls.setMode("translate"), w.transformControls.showX = !0, w.transformControls.showY = !0, w.transformControls.showZ = !0, _e == null || _e(r));
|
|
1160
|
+
}
|
|
1161
|
+
function fn() {
|
|
1162
|
+
w.selectedObject && (w.transformControls.detach(), w.selectedObject = null, _e == null || _e(null));
|
|
1163
|
+
}
|
|
1164
|
+
function Ys(r) {
|
|
1165
|
+
if (ve) {
|
|
1166
|
+
ve = !1;
|
|
1167
|
+
return;
|
|
1168
|
+
}
|
|
1169
|
+
const e = w.renderer.domElement.getBoundingClientRect(), t = new N.Vector2(
|
|
1170
|
+
(r.clientX - e.left) / e.width * 2 - 1,
|
|
1171
|
+
-((r.clientY - e.top) / e.height) * 2 + 1
|
|
1172
|
+
), s = new N.Raycaster();
|
|
1173
|
+
s.setFromCamera(t, w.camera);
|
|
1174
|
+
const n = [];
|
|
1175
|
+
w.scene.traverse((o) => {
|
|
1176
|
+
o.type === "Mesh" && o.userData.isMovable && n.push(o);
|
|
1177
|
+
});
|
|
1178
|
+
const i = s.intersectObjects(n);
|
|
1179
|
+
i.length > 0 ? Et(i[0].object) : fn();
|
|
1180
|
+
}
|
|
1181
|
+
function nt(r, e = !1) {
|
|
1182
|
+
w.scene.add(r), r.userData.isMovable && (Vs(r), Mt()), e && Et(r);
|
|
1183
|
+
}
|
|
1184
|
+
function Bs(r) {
|
|
1185
|
+
w.selectedObject === r && fn(), r.parent ? r.parent.remove(r) : w.scene.remove(r), Zs(r), Mt();
|
|
1186
|
+
}
|
|
1187
|
+
function Ks(r) {
|
|
1188
|
+
const e = w.scene.getObjectByProperty("uuid", r);
|
|
1189
|
+
e && Bs(e);
|
|
1190
|
+
}
|
|
1191
|
+
function Vs(r) {
|
|
1192
|
+
r.userData.isMovable && r.parent === w.scene && (be.includes(r) || be.push(r));
|
|
1193
|
+
}
|
|
1194
|
+
function Zs(r) {
|
|
1195
|
+
const e = be.indexOf(r);
|
|
1196
|
+
e !== -1 && be.splice(e, 1);
|
|
1197
|
+
}
|
|
1198
|
+
function Qs() {
|
|
1199
|
+
const r = [];
|
|
1200
|
+
w.scene.children.forEach((e) => {
|
|
1201
|
+
e.userData.isMovable && r.push(e);
|
|
1202
|
+
}), be = r, Mt();
|
|
1203
|
+
}
|
|
1204
|
+
function Mt() {
|
|
1205
|
+
tt == null || tt([...be]);
|
|
1206
|
+
}
|
|
1207
|
+
function qs(r) {
|
|
1208
|
+
_e = r;
|
|
1209
|
+
}
|
|
1210
|
+
function Ws(r) {
|
|
1211
|
+
_t = r;
|
|
1212
|
+
}
|
|
1213
|
+
function $s(r) {
|
|
1214
|
+
tt = r;
|
|
1215
|
+
}
|
|
1216
|
+
function Js() {
|
|
1217
|
+
return be;
|
|
1218
|
+
}
|
|
1219
|
+
const ei = /^[og]\s*(.+)?/, ti = /^mtllib /, ni = /^usemtl /, si = /^usemap /, Gt = /\s+/, Xt = new E(), ht = new E(), Yt = new E(), Bt = new E(), Z = new E(), We = new ue();
|
|
1220
|
+
function ii() {
|
|
1221
|
+
const r = {
|
|
1222
|
+
objects: [],
|
|
1223
|
+
object: {},
|
|
1224
|
+
vertices: [],
|
|
1225
|
+
normals: [],
|
|
1226
|
+
colors: [],
|
|
1227
|
+
uvs: [],
|
|
1228
|
+
materials: {},
|
|
1229
|
+
materialLibraries: [],
|
|
1230
|
+
startObject: function(e, t) {
|
|
1231
|
+
if (this.object && this.object.fromDeclaration === !1) {
|
|
1232
|
+
this.object.name = e, this.object.fromDeclaration = t !== !1;
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
const s = this.object && typeof this.object.currentMaterial == "function" ? this.object.currentMaterial() : void 0;
|
|
1236
|
+
if (this.object && typeof this.object._finalize == "function" && this.object._finalize(!0), this.object = {
|
|
1237
|
+
name: e || "",
|
|
1238
|
+
fromDeclaration: t !== !1,
|
|
1239
|
+
geometry: {
|
|
1240
|
+
vertices: [],
|
|
1241
|
+
normals: [],
|
|
1242
|
+
colors: [],
|
|
1243
|
+
uvs: [],
|
|
1244
|
+
hasUVIndices: !1
|
|
1245
|
+
},
|
|
1246
|
+
materials: [],
|
|
1247
|
+
smooth: !0,
|
|
1248
|
+
startMaterial: function(n, i) {
|
|
1249
|
+
const o = this._finalize(!1);
|
|
1250
|
+
o && (o.inherited || o.groupCount <= 0) && this.materials.splice(o.index, 1);
|
|
1251
|
+
const a = {
|
|
1252
|
+
index: this.materials.length,
|
|
1253
|
+
name: n || "",
|
|
1254
|
+
mtllib: Array.isArray(i) && i.length > 0 ? i[i.length - 1] : "",
|
|
1255
|
+
smooth: o !== void 0 ? o.smooth : this.smooth,
|
|
1256
|
+
groupStart: o !== void 0 ? o.groupEnd : 0,
|
|
1257
|
+
groupEnd: -1,
|
|
1258
|
+
groupCount: -1,
|
|
1259
|
+
inherited: !1,
|
|
1260
|
+
clone: function(l) {
|
|
1261
|
+
const h = {
|
|
1262
|
+
index: typeof l == "number" ? l : this.index,
|
|
1263
|
+
name: this.name,
|
|
1264
|
+
mtllib: this.mtllib,
|
|
1265
|
+
smooth: this.smooth,
|
|
1266
|
+
groupStart: 0,
|
|
1267
|
+
groupEnd: -1,
|
|
1268
|
+
groupCount: -1,
|
|
1269
|
+
inherited: !1
|
|
1270
|
+
};
|
|
1271
|
+
return h.clone = this.clone.bind(h), h;
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1274
|
+
return this.materials.push(a), a;
|
|
1275
|
+
},
|
|
1276
|
+
currentMaterial: function() {
|
|
1277
|
+
if (this.materials.length > 0)
|
|
1278
|
+
return this.materials[this.materials.length - 1];
|
|
1279
|
+
},
|
|
1280
|
+
_finalize: function(n) {
|
|
1281
|
+
const i = this.currentMaterial();
|
|
1282
|
+
if (i && i.groupEnd === -1 && (i.groupEnd = this.geometry.vertices.length / 3, i.groupCount = i.groupEnd - i.groupStart, i.inherited = !1), n && this.materials.length > 1)
|
|
1283
|
+
for (let o = this.materials.length - 1; o >= 0; o--)
|
|
1284
|
+
this.materials[o].groupCount <= 0 && this.materials.splice(o, 1);
|
|
1285
|
+
return n && this.materials.length === 0 && this.materials.push({
|
|
1286
|
+
name: "",
|
|
1287
|
+
smooth: this.smooth
|
|
1288
|
+
}), i;
|
|
1289
|
+
}
|
|
1290
|
+
}, s && s.name && typeof s.clone == "function") {
|
|
1291
|
+
const n = s.clone(0);
|
|
1292
|
+
n.inherited = !0, this.object.materials.push(n);
|
|
1293
|
+
}
|
|
1294
|
+
this.objects.push(this.object);
|
|
1295
|
+
},
|
|
1296
|
+
finalize: function() {
|
|
1297
|
+
this.object && typeof this.object._finalize == "function" && this.object._finalize(!0);
|
|
1298
|
+
},
|
|
1299
|
+
parseVertexIndex: function(e, t) {
|
|
1300
|
+
const s = parseInt(e, 10);
|
|
1301
|
+
return (s >= 0 ? s - 1 : s + t / 3) * 3;
|
|
1302
|
+
},
|
|
1303
|
+
parseNormalIndex: function(e, t) {
|
|
1304
|
+
const s = parseInt(e, 10);
|
|
1305
|
+
return (s >= 0 ? s - 1 : s + t / 3) * 3;
|
|
1306
|
+
},
|
|
1307
|
+
parseUVIndex: function(e, t) {
|
|
1308
|
+
const s = parseInt(e, 10);
|
|
1309
|
+
return (s >= 0 ? s - 1 : s + t / 2) * 2;
|
|
1310
|
+
},
|
|
1311
|
+
addVertex: function(e, t, s) {
|
|
1312
|
+
const n = this.vertices, i = this.object.geometry.vertices;
|
|
1313
|
+
i.push(n[e + 0], n[e + 1], n[e + 2]), i.push(n[t + 0], n[t + 1], n[t + 2]), i.push(n[s + 0], n[s + 1], n[s + 2]);
|
|
1314
|
+
},
|
|
1315
|
+
addVertexPoint: function(e) {
|
|
1316
|
+
const t = this.vertices;
|
|
1317
|
+
this.object.geometry.vertices.push(t[e + 0], t[e + 1], t[e + 2]);
|
|
1318
|
+
},
|
|
1319
|
+
addVertexLine: function(e) {
|
|
1320
|
+
const t = this.vertices;
|
|
1321
|
+
this.object.geometry.vertices.push(t[e + 0], t[e + 1], t[e + 2]);
|
|
1322
|
+
},
|
|
1323
|
+
addNormal: function(e, t, s) {
|
|
1324
|
+
const n = this.normals, i = this.object.geometry.normals;
|
|
1325
|
+
i.push(n[e + 0], n[e + 1], n[e + 2]), i.push(n[t + 0], n[t + 1], n[t + 2]), i.push(n[s + 0], n[s + 1], n[s + 2]);
|
|
1326
|
+
},
|
|
1327
|
+
addFaceNormal: function(e, t, s) {
|
|
1328
|
+
const n = this.vertices, i = this.object.geometry.normals;
|
|
1329
|
+
Xt.fromArray(n, e), ht.fromArray(n, t), Yt.fromArray(n, s), Z.subVectors(Yt, ht), Bt.subVectors(Xt, ht), Z.cross(Bt), Z.normalize(), i.push(Z.x, Z.y, Z.z), i.push(Z.x, Z.y, Z.z), i.push(Z.x, Z.y, Z.z);
|
|
1330
|
+
},
|
|
1331
|
+
addColor: function(e, t, s) {
|
|
1332
|
+
const n = this.colors, i = this.object.geometry.colors;
|
|
1333
|
+
n[e] !== void 0 && i.push(n[e + 0], n[e + 1], n[e + 2]), n[t] !== void 0 && i.push(n[t + 0], n[t + 1], n[t + 2]), n[s] !== void 0 && i.push(n[s + 0], n[s + 1], n[s + 2]);
|
|
1334
|
+
},
|
|
1335
|
+
addUV: function(e, t, s) {
|
|
1336
|
+
const n = this.uvs, i = this.object.geometry.uvs;
|
|
1337
|
+
i.push(n[e + 0], n[e + 1]), i.push(n[t + 0], n[t + 1]), i.push(n[s + 0], n[s + 1]);
|
|
1338
|
+
},
|
|
1339
|
+
addDefaultUV: function() {
|
|
1340
|
+
const e = this.object.geometry.uvs;
|
|
1341
|
+
e.push(0, 0), e.push(0, 0), e.push(0, 0);
|
|
1342
|
+
},
|
|
1343
|
+
addUVLine: function(e) {
|
|
1344
|
+
const t = this.uvs;
|
|
1345
|
+
this.object.geometry.uvs.push(t[e + 0], t[e + 1]);
|
|
1346
|
+
},
|
|
1347
|
+
addFace: function(e, t, s, n, i, o, a, l, h) {
|
|
1348
|
+
const u = this.vertices.length;
|
|
1349
|
+
let c = this.parseVertexIndex(e, u), d = this.parseVertexIndex(t, u), p = this.parseVertexIndex(s, u);
|
|
1350
|
+
if (this.addVertex(c, d, p), this.addColor(c, d, p), a !== void 0 && a !== "") {
|
|
1351
|
+
const f = this.normals.length;
|
|
1352
|
+
c = this.parseNormalIndex(a, f), d = this.parseNormalIndex(l, f), p = this.parseNormalIndex(h, f), this.addNormal(c, d, p);
|
|
1353
|
+
} else
|
|
1354
|
+
this.addFaceNormal(c, d, p);
|
|
1355
|
+
if (n !== void 0 && n !== "") {
|
|
1356
|
+
const f = this.uvs.length;
|
|
1357
|
+
c = this.parseUVIndex(n, f), d = this.parseUVIndex(i, f), p = this.parseUVIndex(o, f), this.addUV(c, d, p), this.object.geometry.hasUVIndices = !0;
|
|
1358
|
+
} else
|
|
1359
|
+
this.addDefaultUV();
|
|
1360
|
+
},
|
|
1361
|
+
addPointGeometry: function(e) {
|
|
1362
|
+
this.object.geometry.type = "Points";
|
|
1363
|
+
const t = this.vertices.length;
|
|
1364
|
+
for (let s = 0, n = e.length; s < n; s++) {
|
|
1365
|
+
const i = this.parseVertexIndex(e[s], t);
|
|
1366
|
+
this.addVertexPoint(i), this.addColor(i);
|
|
1367
|
+
}
|
|
1368
|
+
},
|
|
1369
|
+
addLineGeometry: function(e, t) {
|
|
1370
|
+
this.object.geometry.type = "Line";
|
|
1371
|
+
const s = this.vertices.length, n = this.uvs.length;
|
|
1372
|
+
for (let i = 0, o = e.length; i < o; i++)
|
|
1373
|
+
this.addVertexLine(this.parseVertexIndex(e[i], s));
|
|
1374
|
+
for (let i = 0, o = t.length; i < o; i++)
|
|
1375
|
+
this.addUVLine(this.parseUVIndex(t[i], n));
|
|
1376
|
+
}
|
|
1377
|
+
};
|
|
1378
|
+
return r.startObject("", !1), r;
|
|
1379
|
+
}
|
|
1380
|
+
class oi extends rn {
|
|
1381
|
+
/**
|
|
1382
|
+
* Constructs a new OBJ loader.
|
|
1383
|
+
*
|
|
1384
|
+
* @param {LoadingManager} [manager] - The loading manager.
|
|
1385
|
+
*/
|
|
1386
|
+
constructor(e) {
|
|
1387
|
+
super(e), this.materials = null;
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* Starts loading from the given URL and passes the loaded OBJ asset
|
|
1391
|
+
* to the `onLoad()` callback.
|
|
1392
|
+
*
|
|
1393
|
+
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
|
|
1394
|
+
* @param {function(Group)} onLoad - Executed when the loading process has been finished.
|
|
1395
|
+
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
|
|
1396
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
1397
|
+
*/
|
|
1398
|
+
load(e, t, s, n) {
|
|
1399
|
+
const i = this, o = new Tt(this.manager);
|
|
1400
|
+
o.setPath(this.path), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(e, function(a) {
|
|
1401
|
+
try {
|
|
1402
|
+
t(i.parse(a));
|
|
1403
|
+
} catch (l) {
|
|
1404
|
+
n ? n(l) : console.error(l), i.manager.itemError(e);
|
|
1405
|
+
}
|
|
1406
|
+
}, s, n);
|
|
1407
|
+
}
|
|
1408
|
+
/**
|
|
1409
|
+
* Sets the material creator for this OBJ. This object is loaded via {@link MTLLoader}.
|
|
1410
|
+
*
|
|
1411
|
+
* @param {MaterialCreator} materials - An object that creates the materials for this OBJ.
|
|
1412
|
+
* @return {OBJLoader} A reference to this loader.
|
|
1413
|
+
*/
|
|
1414
|
+
setMaterials(e) {
|
|
1415
|
+
return this.materials = e, this;
|
|
1416
|
+
}
|
|
1417
|
+
/**
|
|
1418
|
+
* Parses the given OBJ data and returns the resulting group.
|
|
1419
|
+
*
|
|
1420
|
+
* @param {string} text - The raw OBJ data as a string.
|
|
1421
|
+
* @return {Group} The parsed OBJ.
|
|
1422
|
+
*/
|
|
1423
|
+
parse(e) {
|
|
1424
|
+
const t = new ii();
|
|
1425
|
+
e.indexOf(`\r
|
|
1426
|
+
`) !== -1 && (e = e.replace(/\r\n/g, `
|
|
1427
|
+
`)), e.indexOf(`\\
|
|
1428
|
+
`) !== -1 && (e = e.replace(/\\\n/g, ""));
|
|
1429
|
+
const s = e.split(`
|
|
1430
|
+
`);
|
|
1431
|
+
let n = [];
|
|
1432
|
+
for (let a = 0, l = s.length; a < l; a++) {
|
|
1433
|
+
const h = s[a].trimStart();
|
|
1434
|
+
if (h.length === 0) continue;
|
|
1435
|
+
const u = h.charAt(0);
|
|
1436
|
+
if (u !== "#")
|
|
1437
|
+
if (u === "v") {
|
|
1438
|
+
const c = h.split(Gt);
|
|
1439
|
+
switch (c[0]) {
|
|
1440
|
+
case "v":
|
|
1441
|
+
t.vertices.push(
|
|
1442
|
+
parseFloat(c[1]),
|
|
1443
|
+
parseFloat(c[2]),
|
|
1444
|
+
parseFloat(c[3])
|
|
1445
|
+
), c.length >= 7 ? (We.setRGB(
|
|
1446
|
+
parseFloat(c[4]),
|
|
1447
|
+
parseFloat(c[5]),
|
|
1448
|
+
parseFloat(c[6]),
|
|
1449
|
+
Se
|
|
1450
|
+
), t.colors.push(We.r, We.g, We.b)) : t.colors.push(void 0, void 0, void 0);
|
|
1451
|
+
break;
|
|
1452
|
+
case "vn":
|
|
1453
|
+
t.normals.push(
|
|
1454
|
+
parseFloat(c[1]),
|
|
1455
|
+
parseFloat(c[2]),
|
|
1456
|
+
parseFloat(c[3])
|
|
1457
|
+
);
|
|
1458
|
+
break;
|
|
1459
|
+
case "vt":
|
|
1460
|
+
t.uvs.push(
|
|
1461
|
+
parseFloat(c[1]),
|
|
1462
|
+
parseFloat(c[2])
|
|
1463
|
+
);
|
|
1464
|
+
break;
|
|
1465
|
+
}
|
|
1466
|
+
} else if (u === "f") {
|
|
1467
|
+
const d = h.slice(1).trim().split(Gt), p = [];
|
|
1468
|
+
for (let m = 0, y = d.length; m < y; m++) {
|
|
1469
|
+
const _ = d[m];
|
|
1470
|
+
if (_.length > 0) {
|
|
1471
|
+
const x = _.split("/");
|
|
1472
|
+
p.push(x);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
const f = p[0];
|
|
1476
|
+
for (let m = 1, y = p.length - 1; m < y; m++) {
|
|
1477
|
+
const _ = p[m], x = p[m + 1];
|
|
1478
|
+
t.addFace(
|
|
1479
|
+
f[0],
|
|
1480
|
+
_[0],
|
|
1481
|
+
x[0],
|
|
1482
|
+
f[1],
|
|
1483
|
+
_[1],
|
|
1484
|
+
x[1],
|
|
1485
|
+
f[2],
|
|
1486
|
+
_[2],
|
|
1487
|
+
x[2]
|
|
1488
|
+
);
|
|
1489
|
+
}
|
|
1490
|
+
} else if (u === "l") {
|
|
1491
|
+
const c = h.substring(1).trim().split(" ");
|
|
1492
|
+
let d = [];
|
|
1493
|
+
const p = [];
|
|
1494
|
+
if (h.indexOf("/") === -1)
|
|
1495
|
+
d = c;
|
|
1496
|
+
else
|
|
1497
|
+
for (let f = 0, m = c.length; f < m; f++) {
|
|
1498
|
+
const y = c[f].split("/");
|
|
1499
|
+
y[0] !== "" && d.push(y[0]), y[1] !== "" && p.push(y[1]);
|
|
1500
|
+
}
|
|
1501
|
+
t.addLineGeometry(d, p);
|
|
1502
|
+
} else if (u === "p") {
|
|
1503
|
+
const d = h.slice(1).trim().split(" ");
|
|
1504
|
+
t.addPointGeometry(d);
|
|
1505
|
+
} else if ((n = ei.exec(h)) !== null) {
|
|
1506
|
+
const c = (" " + n[0].slice(1).trim()).slice(1);
|
|
1507
|
+
t.startObject(c);
|
|
1508
|
+
} else if (ni.test(h))
|
|
1509
|
+
t.object.startMaterial(h.substring(7).trim(), t.materialLibraries);
|
|
1510
|
+
else if (ti.test(h))
|
|
1511
|
+
t.materialLibraries.push(h.substring(7).trim());
|
|
1512
|
+
else if (si.test(h))
|
|
1513
|
+
console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');
|
|
1514
|
+
else if (u === "s") {
|
|
1515
|
+
if (n = h.split(" "), n.length > 1) {
|
|
1516
|
+
const d = n[1].trim().toLowerCase();
|
|
1517
|
+
t.object.smooth = d !== "0" && d !== "off";
|
|
1518
|
+
} else
|
|
1519
|
+
t.object.smooth = !0;
|
|
1520
|
+
const c = t.object.currentMaterial();
|
|
1521
|
+
c && (c.smooth = t.object.smooth);
|
|
1522
|
+
} else {
|
|
1523
|
+
if (h === "\0") continue;
|
|
1524
|
+
console.warn('THREE.OBJLoader: Unexpected line: "' + h + '"');
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
t.finalize();
|
|
1528
|
+
const i = new $e();
|
|
1529
|
+
if (i.materialLibraries = [].concat(t.materialLibraries), !(t.objects.length === 1 && t.objects[0].geometry.vertices.length === 0) === !0)
|
|
1530
|
+
for (let a = 0, l = t.objects.length; a < l; a++) {
|
|
1531
|
+
const h = t.objects[a], u = h.geometry, c = h.materials, d = u.type === "Line", p = u.type === "Points";
|
|
1532
|
+
let f = !1;
|
|
1533
|
+
if (u.vertices.length === 0) continue;
|
|
1534
|
+
const m = new He();
|
|
1535
|
+
m.setAttribute("position", new he(u.vertices, 3)), u.normals.length > 0 && m.setAttribute("normal", new he(u.normals, 3)), u.colors.length > 0 && (f = !0, m.setAttribute("color", new he(u.colors, 3))), u.hasUVIndices === !0 && m.setAttribute("uv", new he(u.uvs, 2));
|
|
1536
|
+
const y = [];
|
|
1537
|
+
for (let x = 0, M = c.length; x < M; x++) {
|
|
1538
|
+
const S = c[x], L = S.name + "_" + S.smooth + "_" + f;
|
|
1539
|
+
let v = t.materials[L];
|
|
1540
|
+
if (this.materials !== null) {
|
|
1541
|
+
if (v = this.materials.create(S.name), d && v && !(v instanceof De)) {
|
|
1542
|
+
const I = new De();
|
|
1543
|
+
Ne.prototype.copy.call(I, v), I.color.copy(v.color), v = I;
|
|
1544
|
+
} else if (p && v && !(v instanceof Ie)) {
|
|
1545
|
+
const I = new Ie({ size: 10, sizeAttenuation: !1 });
|
|
1546
|
+
Ne.prototype.copy.call(I, v), I.color.copy(v.color), I.map = v.map, v = I;
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
v === void 0 && (d ? v = new De() : p ? v = new Ie({ size: 1, sizeAttenuation: !1 }) : v = new kn(), v.name = S.name, v.flatShading = !S.smooth, v.vertexColors = f, t.materials[L] = v), y.push(v);
|
|
1550
|
+
}
|
|
1551
|
+
let _;
|
|
1552
|
+
if (y.length > 1) {
|
|
1553
|
+
for (let x = 0, M = c.length; x < M; x++) {
|
|
1554
|
+
const S = c[x];
|
|
1555
|
+
m.addGroup(S.groupStart, S.groupCount, x);
|
|
1556
|
+
}
|
|
1557
|
+
d ? _ = new ft(m, y) : p ? _ = new Je(m, y) : _ = new b(m, y);
|
|
1558
|
+
} else
|
|
1559
|
+
d ? _ = new ft(m, y[0]) : p ? _ = new Je(m, y[0]) : _ = new b(m, y[0]);
|
|
1560
|
+
_.name = h.name, i.add(_);
|
|
1561
|
+
}
|
|
1562
|
+
else if (t.vertices.length > 0) {
|
|
1563
|
+
const a = new Ie({ size: 1, sizeAttenuation: !1 }), l = new He();
|
|
1564
|
+
l.setAttribute("position", new he(t.vertices, 3)), t.colors.length > 0 && t.colors[0] !== void 0 && (l.setAttribute("color", new he(t.colors, 3)), a.vertexColors = !0);
|
|
1565
|
+
const h = new Je(l, a);
|
|
1566
|
+
i.add(h);
|
|
1567
|
+
}
|
|
1568
|
+
return i;
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
function Kt(r, e) {
|
|
1572
|
+
if (e === jn)
|
|
1573
|
+
return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), r;
|
|
1574
|
+
if (e === mt || e === an) {
|
|
1575
|
+
let t = r.getIndex();
|
|
1576
|
+
if (t === null) {
|
|
1577
|
+
const o = [], a = r.getAttribute("position");
|
|
1578
|
+
if (a !== void 0) {
|
|
1579
|
+
for (let l = 0; l < a.count; l++)
|
|
1580
|
+
o.push(l);
|
|
1581
|
+
r.setIndex(o), t = r.getIndex();
|
|
1582
|
+
} else
|
|
1583
|
+
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), r;
|
|
1584
|
+
}
|
|
1585
|
+
const s = t.count - 2, n = [];
|
|
1586
|
+
if (e === mt)
|
|
1587
|
+
for (let o = 1; o <= s; o++)
|
|
1588
|
+
n.push(t.getX(0)), n.push(t.getX(o)), n.push(t.getX(o + 1));
|
|
1589
|
+
else
|
|
1590
|
+
for (let o = 0; o < s; o++)
|
|
1591
|
+
o % 2 === 0 ? (n.push(t.getX(o)), n.push(t.getX(o + 1)), n.push(t.getX(o + 2))) : (n.push(t.getX(o + 2)), n.push(t.getX(o + 1)), n.push(t.getX(o)));
|
|
1592
|
+
n.length / 3 !== s && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
|
|
1593
|
+
const i = r.clone();
|
|
1594
|
+
return i.setIndex(n), i.clearGroups(), i;
|
|
1595
|
+
} else
|
|
1596
|
+
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", e), r;
|
|
1597
|
+
}
|
|
1598
|
+
function ri(r) {
|
|
1599
|
+
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), s = r.clone();
|
|
1600
|
+
return mn(r, s, function(n, i) {
|
|
1601
|
+
e.set(i, n), t.set(n, i);
|
|
1602
|
+
}), s.traverse(function(n) {
|
|
1603
|
+
if (!n.isSkinnedMesh) return;
|
|
1604
|
+
const i = n, o = e.get(n), a = o.skeleton.bones;
|
|
1605
|
+
i.skeleton = o.skeleton.clone(), i.bindMatrix.copy(o.bindMatrix), i.skeleton.bones = a.map(function(l) {
|
|
1606
|
+
return t.get(l);
|
|
1607
|
+
}), i.bind(i.skeleton, i.bindMatrix);
|
|
1608
|
+
}), s;
|
|
1609
|
+
}
|
|
1610
|
+
function mn(r, e, t) {
|
|
1611
|
+
t(r, e);
|
|
1612
|
+
for (let s = 0; s < r.children.length; s++)
|
|
1613
|
+
mn(r.children[s], e.children[s], t);
|
|
1614
|
+
}
|
|
1615
|
+
class ai extends rn {
|
|
1616
|
+
/**
|
|
1617
|
+
* Constructs a new glTF loader.
|
|
1618
|
+
*
|
|
1619
|
+
* @param {LoadingManager} [manager] - The loading manager.
|
|
1620
|
+
*/
|
|
1621
|
+
constructor(e) {
|
|
1622
|
+
super(e), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(t) {
|
|
1623
|
+
return new di(t);
|
|
1624
|
+
}), this.register(function(t) {
|
|
1625
|
+
return new pi(t);
|
|
1626
|
+
}), this.register(function(t) {
|
|
1627
|
+
return new xi(t);
|
|
1628
|
+
}), this.register(function(t) {
|
|
1629
|
+
return new Ei(t);
|
|
1630
|
+
}), this.register(function(t) {
|
|
1631
|
+
return new Mi(t);
|
|
1632
|
+
}), this.register(function(t) {
|
|
1633
|
+
return new mi(t);
|
|
1634
|
+
}), this.register(function(t) {
|
|
1635
|
+
return new gi(t);
|
|
1636
|
+
}), this.register(function(t) {
|
|
1637
|
+
return new yi(t);
|
|
1638
|
+
}), this.register(function(t) {
|
|
1639
|
+
return new _i(t);
|
|
1640
|
+
}), this.register(function(t) {
|
|
1641
|
+
return new ui(t);
|
|
1642
|
+
}), this.register(function(t) {
|
|
1643
|
+
return new bi(t);
|
|
1644
|
+
}), this.register(function(t) {
|
|
1645
|
+
return new fi(t);
|
|
1646
|
+
}), this.register(function(t) {
|
|
1647
|
+
return new Ti(t);
|
|
1648
|
+
}), this.register(function(t) {
|
|
1649
|
+
return new wi(t);
|
|
1650
|
+
}), this.register(function(t) {
|
|
1651
|
+
return new ci(t);
|
|
1652
|
+
}), this.register(function(t) {
|
|
1653
|
+
return new Vt(t, R.EXT_MESHOPT_COMPRESSION);
|
|
1654
|
+
}), this.register(function(t) {
|
|
1655
|
+
return new Vt(t, R.KHR_MESHOPT_COMPRESSION);
|
|
1656
|
+
}), this.register(function(t) {
|
|
1657
|
+
return new Si(t);
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1660
|
+
/**
|
|
1661
|
+
* Starts loading from the given URL and passes the loaded glTF asset
|
|
1662
|
+
* to the `onLoad()` callback.
|
|
1663
|
+
*
|
|
1664
|
+
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
|
|
1665
|
+
* @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
|
|
1666
|
+
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
|
|
1667
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
1668
|
+
*/
|
|
1669
|
+
load(e, t, s, n) {
|
|
1670
|
+
const i = this;
|
|
1671
|
+
let o;
|
|
1672
|
+
if (this.resourcePath !== "")
|
|
1673
|
+
o = this.resourcePath;
|
|
1674
|
+
else if (this.path !== "") {
|
|
1675
|
+
const h = ke.extractUrlBase(e);
|
|
1676
|
+
o = ke.resolveURL(h, this.path);
|
|
1677
|
+
} else
|
|
1678
|
+
o = ke.extractUrlBase(e);
|
|
1679
|
+
this.manager.itemStart(e);
|
|
1680
|
+
const a = function(h) {
|
|
1681
|
+
n ? n(h) : console.error(h), i.manager.itemError(e), i.manager.itemEnd(e);
|
|
1682
|
+
}, l = new Tt(this.manager);
|
|
1683
|
+
l.setPath(this.path), l.setResponseType("arraybuffer"), l.setRequestHeader(this.requestHeader), l.setWithCredentials(this.withCredentials), l.load(e, function(h) {
|
|
1684
|
+
try {
|
|
1685
|
+
i.parse(h, o, function(u) {
|
|
1686
|
+
t(u), i.manager.itemEnd(e);
|
|
1687
|
+
}, a);
|
|
1688
|
+
} catch (u) {
|
|
1689
|
+
a(u);
|
|
1690
|
+
}
|
|
1691
|
+
}, s, a);
|
|
1692
|
+
}
|
|
1693
|
+
/**
|
|
1694
|
+
* Sets the given Draco loader to this loader. Required for decoding assets
|
|
1695
|
+
* compressed with the `KHR_draco_mesh_compression` extension.
|
|
1696
|
+
*
|
|
1697
|
+
* @param {DRACOLoader} dracoLoader - The Draco loader to set.
|
|
1698
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
1699
|
+
*/
|
|
1700
|
+
setDRACOLoader(e) {
|
|
1701
|
+
return this.dracoLoader = e, this;
|
|
1702
|
+
}
|
|
1703
|
+
/**
|
|
1704
|
+
* Sets the given KTX2 loader to this loader. Required for loading KTX2
|
|
1705
|
+
* compressed textures.
|
|
1706
|
+
*
|
|
1707
|
+
* @param {KTX2Loader} ktx2Loader - The KTX2 loader to set.
|
|
1708
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
1709
|
+
*/
|
|
1710
|
+
setKTX2Loader(e) {
|
|
1711
|
+
return this.ktx2Loader = e, this;
|
|
1712
|
+
}
|
|
1713
|
+
/**
|
|
1714
|
+
* Sets the given meshopt decoder. Required for decoding assets
|
|
1715
|
+
* compressed with the `EXT_meshopt_compression` extension.
|
|
1716
|
+
*
|
|
1717
|
+
* @param {Object} meshoptDecoder - The meshopt decoder to set.
|
|
1718
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
1719
|
+
*/
|
|
1720
|
+
setMeshoptDecoder(e) {
|
|
1721
|
+
return this.meshoptDecoder = e, this;
|
|
1722
|
+
}
|
|
1723
|
+
/**
|
|
1724
|
+
* Registers a plugin callback. This API is internally used to implement the various
|
|
1725
|
+
* glTF extensions but can also used by third-party code to add additional logic
|
|
1726
|
+
* to the loader.
|
|
1727
|
+
*
|
|
1728
|
+
* @param {function(parser:GLTFParser)} callback - The callback function to register.
|
|
1729
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
1730
|
+
*/
|
|
1731
|
+
register(e) {
|
|
1732
|
+
return this.pluginCallbacks.indexOf(e) === -1 && this.pluginCallbacks.push(e), this;
|
|
1733
|
+
}
|
|
1734
|
+
/**
|
|
1735
|
+
* Unregisters a plugin callback.
|
|
1736
|
+
*
|
|
1737
|
+
* @param {Function} callback - The callback function to unregister.
|
|
1738
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
1739
|
+
*/
|
|
1740
|
+
unregister(e) {
|
|
1741
|
+
return this.pluginCallbacks.indexOf(e) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e), 1), this;
|
|
1742
|
+
}
|
|
1743
|
+
/**
|
|
1744
|
+
* Parses the given glTF data and returns the resulting group.
|
|
1745
|
+
*
|
|
1746
|
+
* @param {string|ArrayBuffer} data - The raw glTF data.
|
|
1747
|
+
* @param {string} path - The URL base path.
|
|
1748
|
+
* @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
|
|
1749
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
1750
|
+
*/
|
|
1751
|
+
parse(e, t, s, n) {
|
|
1752
|
+
let i;
|
|
1753
|
+
const o = {}, a = {}, l = new TextDecoder();
|
|
1754
|
+
if (typeof e == "string")
|
|
1755
|
+
i = JSON.parse(e);
|
|
1756
|
+
else if (e instanceof ArrayBuffer)
|
|
1757
|
+
if (l.decode(new Uint8Array(e, 0, 4)) === gn) {
|
|
1758
|
+
try {
|
|
1759
|
+
o[R.KHR_BINARY_GLTF] = new vi(e);
|
|
1760
|
+
} catch (c) {
|
|
1761
|
+
n && n(c);
|
|
1762
|
+
return;
|
|
1763
|
+
}
|
|
1764
|
+
i = JSON.parse(o[R.KHR_BINARY_GLTF].content);
|
|
1765
|
+
} else
|
|
1766
|
+
i = JSON.parse(l.decode(e));
|
|
1767
|
+
else
|
|
1768
|
+
i = e;
|
|
1769
|
+
if (i.asset === void 0 || i.asset.version[0] < 2) {
|
|
1770
|
+
n && n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
|
|
1771
|
+
return;
|
|
1772
|
+
}
|
|
1773
|
+
const h = new Fi(i, {
|
|
1774
|
+
path: t || this.resourcePath || "",
|
|
1775
|
+
crossOrigin: this.crossOrigin,
|
|
1776
|
+
requestHeader: this.requestHeader,
|
|
1777
|
+
manager: this.manager,
|
|
1778
|
+
ktx2Loader: this.ktx2Loader,
|
|
1779
|
+
meshoptDecoder: this.meshoptDecoder
|
|
1780
|
+
});
|
|
1781
|
+
h.fileLoader.setRequestHeader(this.requestHeader);
|
|
1782
|
+
for (let u = 0; u < this.pluginCallbacks.length; u++) {
|
|
1783
|
+
const c = this.pluginCallbacks[u](h);
|
|
1784
|
+
c.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), a[c.name] = c, o[c.name] = !0;
|
|
1785
|
+
}
|
|
1786
|
+
if (i.extensionsUsed)
|
|
1787
|
+
for (let u = 0; u < i.extensionsUsed.length; ++u) {
|
|
1788
|
+
const c = i.extensionsUsed[u], d = i.extensionsRequired || [];
|
|
1789
|
+
switch (c) {
|
|
1790
|
+
case R.KHR_MATERIALS_UNLIT:
|
|
1791
|
+
o[c] = new hi();
|
|
1792
|
+
break;
|
|
1793
|
+
case R.KHR_DRACO_MESH_COMPRESSION:
|
|
1794
|
+
o[c] = new Ri(i, this.dracoLoader);
|
|
1795
|
+
break;
|
|
1796
|
+
case R.KHR_TEXTURE_TRANSFORM:
|
|
1797
|
+
o[c] = new Ai();
|
|
1798
|
+
break;
|
|
1799
|
+
case R.KHR_MESH_QUANTIZATION:
|
|
1800
|
+
o[c] = new Pi();
|
|
1801
|
+
break;
|
|
1802
|
+
default:
|
|
1803
|
+
d.indexOf(c) >= 0 && a[c] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + c + '".');
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
h.setExtensions(o), h.setPlugins(a), h.parse(s, n);
|
|
1807
|
+
}
|
|
1808
|
+
/**
|
|
1809
|
+
* Async version of {@link GLTFLoader#parse}.
|
|
1810
|
+
*
|
|
1811
|
+
* @async
|
|
1812
|
+
* @param {string|ArrayBuffer} data - The raw glTF data.
|
|
1813
|
+
* @param {string} path - The URL base path.
|
|
1814
|
+
* @return {Promise<GLTFLoader~LoadObject>} A Promise that resolves with the loaded glTF when the parsing has been finished.
|
|
1815
|
+
*/
|
|
1816
|
+
parseAsync(e, t) {
|
|
1817
|
+
const s = this;
|
|
1818
|
+
return new Promise(function(n, i) {
|
|
1819
|
+
s.parse(e, t, n, i);
|
|
1820
|
+
});
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
function li() {
|
|
1824
|
+
let r = {};
|
|
1825
|
+
return {
|
|
1826
|
+
get: function(e) {
|
|
1827
|
+
return r[e];
|
|
1828
|
+
},
|
|
1829
|
+
add: function(e, t) {
|
|
1830
|
+
r[e] = t;
|
|
1831
|
+
},
|
|
1832
|
+
remove: function(e) {
|
|
1833
|
+
delete r[e];
|
|
1834
|
+
},
|
|
1835
|
+
removeAll: function() {
|
|
1836
|
+
r = {};
|
|
1837
|
+
}
|
|
1838
|
+
};
|
|
1839
|
+
}
|
|
1840
|
+
function C(r, e, t) {
|
|
1841
|
+
const s = r.json.materials[e];
|
|
1842
|
+
return s.extensions && s.extensions[t] ? s.extensions[t] : null;
|
|
1843
|
+
}
|
|
1844
|
+
const R = {
|
|
1845
|
+
KHR_BINARY_GLTF: "KHR_binary_glTF",
|
|
1846
|
+
KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
|
|
1847
|
+
KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
|
|
1848
|
+
KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
|
|
1849
|
+
KHR_MATERIALS_DISPERSION: "KHR_materials_dispersion",
|
|
1850
|
+
KHR_MATERIALS_IOR: "KHR_materials_ior",
|
|
1851
|
+
KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
|
|
1852
|
+
KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
|
|
1853
|
+
KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
|
|
1854
|
+
KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",
|
|
1855
|
+
KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy",
|
|
1856
|
+
KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
|
|
1857
|
+
KHR_MATERIALS_VOLUME: "KHR_materials_volume",
|
|
1858
|
+
KHR_TEXTURE_BASISU: "KHR_texture_basisu",
|
|
1859
|
+
KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
|
|
1860
|
+
KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
|
|
1861
|
+
KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
|
|
1862
|
+
EXT_MATERIALS_BUMP: "EXT_materials_bump",
|
|
1863
|
+
EXT_TEXTURE_WEBP: "EXT_texture_webp",
|
|
1864
|
+
EXT_TEXTURE_AVIF: "EXT_texture_avif",
|
|
1865
|
+
EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
|
|
1866
|
+
KHR_MESHOPT_COMPRESSION: "KHR_meshopt_compression",
|
|
1867
|
+
EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"
|
|
1868
|
+
};
|
|
1869
|
+
class ci {
|
|
1870
|
+
constructor(e) {
|
|
1871
|
+
this.parser = e, this.name = R.KHR_LIGHTS_PUNCTUAL, this.cache = { refs: {}, uses: {} };
|
|
1872
|
+
}
|
|
1873
|
+
_markDefs() {
|
|
1874
|
+
const e = this.parser, t = this.parser.json.nodes || [];
|
|
1875
|
+
for (let s = 0, n = t.length; s < n; s++) {
|
|
1876
|
+
const i = t[s];
|
|
1877
|
+
i.extensions && i.extensions[this.name] && i.extensions[this.name].light !== void 0 && e._addNodeRef(this.cache, i.extensions[this.name].light);
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
_loadLight(e) {
|
|
1881
|
+
const t = this.parser, s = "light:" + e;
|
|
1882
|
+
let n = t.cache.get(s);
|
|
1883
|
+
if (n) return n;
|
|
1884
|
+
const i = t.json, l = ((i.extensions && i.extensions[this.name] || {}).lights || [])[e];
|
|
1885
|
+
let h;
|
|
1886
|
+
const u = new ue(16777215);
|
|
1887
|
+
l.color !== void 0 && u.setRGB(l.color[0], l.color[1], l.color[2], ae);
|
|
1888
|
+
const c = l.range !== void 0 ? l.range : 0;
|
|
1889
|
+
switch (l.type) {
|
|
1890
|
+
case "directional":
|
|
1891
|
+
h = new Un(u), h.target.position.set(0, 0, -1), h.add(h.target);
|
|
1892
|
+
break;
|
|
1893
|
+
case "point":
|
|
1894
|
+
h = new Fn(u), h.distance = c;
|
|
1895
|
+
break;
|
|
1896
|
+
case "spot":
|
|
1897
|
+
h = new Hn(u), h.distance = c, l.spot = l.spot || {}, l.spot.innerConeAngle = l.spot.innerConeAngle !== void 0 ? l.spot.innerConeAngle : 0, l.spot.outerConeAngle = l.spot.outerConeAngle !== void 0 ? l.spot.outerConeAngle : Math.PI / 4, h.angle = l.spot.outerConeAngle, h.penumbra = 1 - l.spot.innerConeAngle / l.spot.outerConeAngle, h.target.position.set(0, 0, -1), h.add(h.target);
|
|
1898
|
+
break;
|
|
1899
|
+
default:
|
|
1900
|
+
throw new Error("THREE.GLTFLoader: Unexpected light type: " + l.type);
|
|
1901
|
+
}
|
|
1902
|
+
return h.position.set(0, 0, 0), te(h, l), l.intensity !== void 0 && (h.intensity = l.intensity), h.name = t.createUniqueName(l.name || "light_" + e), n = Promise.resolve(h), t.cache.add(s, n), n;
|
|
1903
|
+
}
|
|
1904
|
+
getDependency(e, t) {
|
|
1905
|
+
if (e === "light")
|
|
1906
|
+
return this._loadLight(t);
|
|
1907
|
+
}
|
|
1908
|
+
createNodeAttachment(e) {
|
|
1909
|
+
const t = this, s = this.parser, i = s.json.nodes[e], a = (i.extensions && i.extensions[this.name] || {}).light;
|
|
1910
|
+
return a === void 0 ? null : this._loadLight(a).then(function(l) {
|
|
1911
|
+
return s._getNodeRef(t.cache, a, l);
|
|
1912
|
+
});
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
class hi {
|
|
1916
|
+
constructor() {
|
|
1917
|
+
this.name = R.KHR_MATERIALS_UNLIT;
|
|
1918
|
+
}
|
|
1919
|
+
getMaterialType() {
|
|
1920
|
+
return ye;
|
|
1921
|
+
}
|
|
1922
|
+
extendParams(e, t, s) {
|
|
1923
|
+
const n = [];
|
|
1924
|
+
e.color = new ue(1, 1, 1), e.opacity = 1;
|
|
1925
|
+
const i = t.pbrMetallicRoughness;
|
|
1926
|
+
if (i) {
|
|
1927
|
+
if (Array.isArray(i.baseColorFactor)) {
|
|
1928
|
+
const o = i.baseColorFactor;
|
|
1929
|
+
e.color.setRGB(o[0], o[1], o[2], ae), e.opacity = o[3];
|
|
1930
|
+
}
|
|
1931
|
+
i.baseColorTexture !== void 0 && n.push(s.assignTexture(e, "map", i.baseColorTexture, Se));
|
|
1932
|
+
}
|
|
1933
|
+
return Promise.all(n);
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
class ui {
|
|
1937
|
+
constructor(e) {
|
|
1938
|
+
this.parser = e, this.name = R.KHR_MATERIALS_EMISSIVE_STRENGTH;
|
|
1939
|
+
}
|
|
1940
|
+
extendMaterialParams(e, t) {
|
|
1941
|
+
const s = C(this.parser, e, this.name);
|
|
1942
|
+
return s === null || s.emissiveStrength !== void 0 && (t.emissiveIntensity = s.emissiveStrength), Promise.resolve();
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
class di {
|
|
1946
|
+
constructor(e) {
|
|
1947
|
+
this.parser = e, this.name = R.KHR_MATERIALS_CLEARCOAT;
|
|
1948
|
+
}
|
|
1949
|
+
getMaterialType(e) {
|
|
1950
|
+
return C(this.parser, e, this.name) !== null ? ne : null;
|
|
1951
|
+
}
|
|
1952
|
+
extendMaterialParams(e, t) {
|
|
1953
|
+
const s = C(this.parser, e, this.name);
|
|
1954
|
+
if (s === null) return Promise.resolve();
|
|
1955
|
+
const n = [];
|
|
1956
|
+
if (s.clearcoatFactor !== void 0 && (t.clearcoat = s.clearcoatFactor), s.clearcoatTexture !== void 0 && n.push(this.parser.assignTexture(t, "clearcoatMap", s.clearcoatTexture)), s.clearcoatRoughnessFactor !== void 0 && (t.clearcoatRoughness = s.clearcoatRoughnessFactor), s.clearcoatRoughnessTexture !== void 0 && n.push(this.parser.assignTexture(t, "clearcoatRoughnessMap", s.clearcoatRoughnessTexture)), s.clearcoatNormalTexture !== void 0 && (n.push(this.parser.assignTexture(t, "clearcoatNormalMap", s.clearcoatNormalTexture)), s.clearcoatNormalTexture.scale !== void 0)) {
|
|
1957
|
+
const i = s.clearcoatNormalTexture.scale;
|
|
1958
|
+
t.clearcoatNormalScale = new B(i, i);
|
|
1959
|
+
}
|
|
1960
|
+
return Promise.all(n);
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
class pi {
|
|
1964
|
+
constructor(e) {
|
|
1965
|
+
this.parser = e, this.name = R.KHR_MATERIALS_DISPERSION;
|
|
1966
|
+
}
|
|
1967
|
+
getMaterialType(e) {
|
|
1968
|
+
return C(this.parser, e, this.name) !== null ? ne : null;
|
|
1969
|
+
}
|
|
1970
|
+
extendMaterialParams(e, t) {
|
|
1971
|
+
const s = C(this.parser, e, this.name);
|
|
1972
|
+
return s === null || (t.dispersion = s.dispersion !== void 0 ? s.dispersion : 0), Promise.resolve();
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
class fi {
|
|
1976
|
+
constructor(e) {
|
|
1977
|
+
this.parser = e, this.name = R.KHR_MATERIALS_IRIDESCENCE;
|
|
1978
|
+
}
|
|
1979
|
+
getMaterialType(e) {
|
|
1980
|
+
return C(this.parser, e, this.name) !== null ? ne : null;
|
|
1981
|
+
}
|
|
1982
|
+
extendMaterialParams(e, t) {
|
|
1983
|
+
const s = C(this.parser, e, this.name);
|
|
1984
|
+
if (s === null) return Promise.resolve();
|
|
1985
|
+
const n = [];
|
|
1986
|
+
return s.iridescenceFactor !== void 0 && (t.iridescence = s.iridescenceFactor), s.iridescenceTexture !== void 0 && n.push(this.parser.assignTexture(t, "iridescenceMap", s.iridescenceTexture)), s.iridescenceIor !== void 0 && (t.iridescenceIOR = s.iridescenceIor), t.iridescenceThicknessRange === void 0 && (t.iridescenceThicknessRange = [100, 400]), s.iridescenceThicknessMinimum !== void 0 && (t.iridescenceThicknessRange[0] = s.iridescenceThicknessMinimum), s.iridescenceThicknessMaximum !== void 0 && (t.iridescenceThicknessRange[1] = s.iridescenceThicknessMaximum), s.iridescenceThicknessTexture !== void 0 && n.push(this.parser.assignTexture(t, "iridescenceThicknessMap", s.iridescenceThicknessTexture)), Promise.all(n);
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
class mi {
|
|
1990
|
+
constructor(e) {
|
|
1991
|
+
this.parser = e, this.name = R.KHR_MATERIALS_SHEEN;
|
|
1992
|
+
}
|
|
1993
|
+
getMaterialType(e) {
|
|
1994
|
+
return C(this.parser, e, this.name) !== null ? ne : null;
|
|
1995
|
+
}
|
|
1996
|
+
extendMaterialParams(e, t) {
|
|
1997
|
+
const s = C(this.parser, e, this.name);
|
|
1998
|
+
if (s === null) return Promise.resolve();
|
|
1999
|
+
const n = [];
|
|
2000
|
+
if (t.sheenColor = new ue(0, 0, 0), t.sheenRoughness = 0, t.sheen = 1, s.sheenColorFactor !== void 0) {
|
|
2001
|
+
const i = s.sheenColorFactor;
|
|
2002
|
+
t.sheenColor.setRGB(i[0], i[1], i[2], ae);
|
|
2003
|
+
}
|
|
2004
|
+
return s.sheenRoughnessFactor !== void 0 && (t.sheenRoughness = s.sheenRoughnessFactor), s.sheenColorTexture !== void 0 && n.push(this.parser.assignTexture(t, "sheenColorMap", s.sheenColorTexture, Se)), s.sheenRoughnessTexture !== void 0 && n.push(this.parser.assignTexture(t, "sheenRoughnessMap", s.sheenRoughnessTexture)), Promise.all(n);
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
class gi {
|
|
2008
|
+
constructor(e) {
|
|
2009
|
+
this.parser = e, this.name = R.KHR_MATERIALS_TRANSMISSION;
|
|
2010
|
+
}
|
|
2011
|
+
getMaterialType(e) {
|
|
2012
|
+
return C(this.parser, e, this.name) !== null ? ne : null;
|
|
2013
|
+
}
|
|
2014
|
+
extendMaterialParams(e, t) {
|
|
2015
|
+
const s = C(this.parser, e, this.name);
|
|
2016
|
+
if (s === null) return Promise.resolve();
|
|
2017
|
+
const n = [];
|
|
2018
|
+
return s.transmissionFactor !== void 0 && (t.transmission = s.transmissionFactor), s.transmissionTexture !== void 0 && n.push(this.parser.assignTexture(t, "transmissionMap", s.transmissionTexture)), Promise.all(n);
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
class yi {
|
|
2022
|
+
constructor(e) {
|
|
2023
|
+
this.parser = e, this.name = R.KHR_MATERIALS_VOLUME;
|
|
2024
|
+
}
|
|
2025
|
+
getMaterialType(e) {
|
|
2026
|
+
return C(this.parser, e, this.name) !== null ? ne : null;
|
|
2027
|
+
}
|
|
2028
|
+
extendMaterialParams(e, t) {
|
|
2029
|
+
const s = C(this.parser, e, this.name);
|
|
2030
|
+
if (s === null) return Promise.resolve();
|
|
2031
|
+
const n = [];
|
|
2032
|
+
t.thickness = s.thicknessFactor !== void 0 ? s.thicknessFactor : 0, s.thicknessTexture !== void 0 && n.push(this.parser.assignTexture(t, "thicknessMap", s.thicknessTexture)), t.attenuationDistance = s.attenuationDistance || 1 / 0;
|
|
2033
|
+
const i = s.attenuationColor || [1, 1, 1];
|
|
2034
|
+
return t.attenuationColor = new ue().setRGB(i[0], i[1], i[2], ae), Promise.all(n);
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
class _i {
|
|
2038
|
+
constructor(e) {
|
|
2039
|
+
this.parser = e, this.name = R.KHR_MATERIALS_IOR;
|
|
2040
|
+
}
|
|
2041
|
+
getMaterialType(e) {
|
|
2042
|
+
return C(this.parser, e, this.name) !== null ? ne : null;
|
|
2043
|
+
}
|
|
2044
|
+
extendMaterialParams(e, t) {
|
|
2045
|
+
const s = C(this.parser, e, this.name);
|
|
2046
|
+
return s === null || (t.ior = s.ior !== void 0 ? s.ior : 1.5, t.ior === 0 && (t.ior = 1e3)), Promise.resolve();
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
class bi {
|
|
2050
|
+
constructor(e) {
|
|
2051
|
+
this.parser = e, this.name = R.KHR_MATERIALS_SPECULAR;
|
|
2052
|
+
}
|
|
2053
|
+
getMaterialType(e) {
|
|
2054
|
+
return C(this.parser, e, this.name) !== null ? ne : null;
|
|
2055
|
+
}
|
|
2056
|
+
extendMaterialParams(e, t) {
|
|
2057
|
+
const s = C(this.parser, e, this.name);
|
|
2058
|
+
if (s === null) return Promise.resolve();
|
|
2059
|
+
const n = [];
|
|
2060
|
+
t.specularIntensity = s.specularFactor !== void 0 ? s.specularFactor : 1, s.specularTexture !== void 0 && n.push(this.parser.assignTexture(t, "specularIntensityMap", s.specularTexture));
|
|
2061
|
+
const i = s.specularColorFactor || [1, 1, 1];
|
|
2062
|
+
return t.specularColor = new ue().setRGB(i[0], i[1], i[2], ae), s.specularColorTexture !== void 0 && n.push(this.parser.assignTexture(t, "specularColorMap", s.specularColorTexture, Se)), Promise.all(n);
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
class wi {
|
|
2066
|
+
constructor(e) {
|
|
2067
|
+
this.parser = e, this.name = R.EXT_MATERIALS_BUMP;
|
|
2068
|
+
}
|
|
2069
|
+
getMaterialType(e) {
|
|
2070
|
+
return C(this.parser, e, this.name) !== null ? ne : null;
|
|
2071
|
+
}
|
|
2072
|
+
extendMaterialParams(e, t) {
|
|
2073
|
+
const s = C(this.parser, e, this.name);
|
|
2074
|
+
if (s === null) return Promise.resolve();
|
|
2075
|
+
const n = [];
|
|
2076
|
+
return t.bumpScale = s.bumpFactor !== void 0 ? s.bumpFactor : 1, s.bumpTexture !== void 0 && n.push(this.parser.assignTexture(t, "bumpMap", s.bumpTexture)), Promise.all(n);
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
class Ti {
|
|
2080
|
+
constructor(e) {
|
|
2081
|
+
this.parser = e, this.name = R.KHR_MATERIALS_ANISOTROPY;
|
|
2082
|
+
}
|
|
2083
|
+
getMaterialType(e) {
|
|
2084
|
+
return C(this.parser, e, this.name) !== null ? ne : null;
|
|
2085
|
+
}
|
|
2086
|
+
extendMaterialParams(e, t) {
|
|
2087
|
+
const s = C(this.parser, e, this.name);
|
|
2088
|
+
if (s === null) return Promise.resolve();
|
|
2089
|
+
const n = [];
|
|
2090
|
+
return s.anisotropyStrength !== void 0 && (t.anisotropy = s.anisotropyStrength), s.anisotropyRotation !== void 0 && (t.anisotropyRotation = s.anisotropyRotation), s.anisotropyTexture !== void 0 && n.push(this.parser.assignTexture(t, "anisotropyMap", s.anisotropyTexture)), Promise.all(n);
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
class xi {
|
|
2094
|
+
constructor(e) {
|
|
2095
|
+
this.parser = e, this.name = R.KHR_TEXTURE_BASISU;
|
|
2096
|
+
}
|
|
2097
|
+
loadTexture(e) {
|
|
2098
|
+
const t = this.parser, s = t.json, n = s.textures[e];
|
|
2099
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
2100
|
+
return null;
|
|
2101
|
+
const i = n.extensions[this.name], o = t.options.ktx2Loader;
|
|
2102
|
+
if (!o) {
|
|
2103
|
+
if (s.extensionsRequired && s.extensionsRequired.indexOf(this.name) >= 0)
|
|
2104
|
+
throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
|
|
2105
|
+
return null;
|
|
2106
|
+
}
|
|
2107
|
+
return t.loadTextureImage(e, i.source, o);
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
class Ei {
|
|
2111
|
+
constructor(e) {
|
|
2112
|
+
this.parser = e, this.name = R.EXT_TEXTURE_WEBP;
|
|
2113
|
+
}
|
|
2114
|
+
loadTexture(e) {
|
|
2115
|
+
const t = this.name, s = this.parser, n = s.json, i = n.textures[e];
|
|
2116
|
+
if (!i.extensions || !i.extensions[t])
|
|
2117
|
+
return null;
|
|
2118
|
+
const o = i.extensions[t], a = n.images[o.source];
|
|
2119
|
+
let l = s.textureLoader;
|
|
2120
|
+
if (a.uri) {
|
|
2121
|
+
const h = s.options.manager.getHandler(a.uri);
|
|
2122
|
+
h !== null && (l = h);
|
|
2123
|
+
}
|
|
2124
|
+
return s.loadTextureImage(e, o.source, l);
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
class Mi {
|
|
2128
|
+
constructor(e) {
|
|
2129
|
+
this.parser = e, this.name = R.EXT_TEXTURE_AVIF;
|
|
2130
|
+
}
|
|
2131
|
+
loadTexture(e) {
|
|
2132
|
+
const t = this.name, s = this.parser, n = s.json, i = n.textures[e];
|
|
2133
|
+
if (!i.extensions || !i.extensions[t])
|
|
2134
|
+
return null;
|
|
2135
|
+
const o = i.extensions[t], a = n.images[o.source];
|
|
2136
|
+
let l = s.textureLoader;
|
|
2137
|
+
if (a.uri) {
|
|
2138
|
+
const h = s.options.manager.getHandler(a.uri);
|
|
2139
|
+
h !== null && (l = h);
|
|
2140
|
+
}
|
|
2141
|
+
return s.loadTextureImage(e, o.source, l);
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
class Vt {
|
|
2145
|
+
constructor(e, t) {
|
|
2146
|
+
this.name = t, this.parser = e;
|
|
2147
|
+
}
|
|
2148
|
+
loadBufferView(e) {
|
|
2149
|
+
const t = this.parser.json, s = t.bufferViews[e];
|
|
2150
|
+
if (s.extensions && s.extensions[this.name]) {
|
|
2151
|
+
const n = s.extensions[this.name], i = this.parser.getDependency("buffer", n.buffer), o = this.parser.options.meshoptDecoder;
|
|
2152
|
+
if (!o || !o.supported) {
|
|
2153
|
+
if (t.extensionsRequired && t.extensionsRequired.indexOf(this.name) >= 0)
|
|
2154
|
+
throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
|
|
2155
|
+
return null;
|
|
2156
|
+
}
|
|
2157
|
+
return i.then(function(a) {
|
|
2158
|
+
const l = n.byteOffset || 0, h = n.byteLength || 0, u = n.count, c = n.byteStride, d = new Uint8Array(a, l, h);
|
|
2159
|
+
return o.decodeGltfBufferAsync ? o.decodeGltfBufferAsync(u, c, d, n.mode, n.filter).then(function(p) {
|
|
2160
|
+
return p.buffer;
|
|
2161
|
+
}) : o.ready.then(function() {
|
|
2162
|
+
const p = new ArrayBuffer(u * c);
|
|
2163
|
+
return o.decodeGltfBuffer(new Uint8Array(p), u, c, d, n.mode, n.filter), p;
|
|
2164
|
+
});
|
|
2165
|
+
});
|
|
2166
|
+
} else
|
|
2167
|
+
return null;
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
class Si {
|
|
2171
|
+
constructor(e) {
|
|
2172
|
+
this.name = R.EXT_MESH_GPU_INSTANCING, this.parser = e;
|
|
2173
|
+
}
|
|
2174
|
+
createNodeMesh(e) {
|
|
2175
|
+
const t = this.parser.json, s = t.nodes[e];
|
|
2176
|
+
if (!s.extensions || !s.extensions[this.name] || s.mesh === void 0)
|
|
2177
|
+
return null;
|
|
2178
|
+
const n = t.meshes[s.mesh];
|
|
2179
|
+
for (const h of n.primitives)
|
|
2180
|
+
if (h.mode !== Q.TRIANGLES && h.mode !== Q.TRIANGLE_STRIP && h.mode !== Q.TRIANGLE_FAN && h.mode !== void 0)
|
|
2181
|
+
return null;
|
|
2182
|
+
const o = s.extensions[this.name].attributes, a = [], l = {};
|
|
2183
|
+
for (const h in o)
|
|
2184
|
+
a.push(this.parser.getDependency("accessor", o[h]).then((u) => (l[h] = u, l[h])));
|
|
2185
|
+
return a.length < 1 ? null : (a.push(this.parser.createNodeMesh(e)), Promise.all(a).then((h) => {
|
|
2186
|
+
const u = h.pop(), c = u.isGroup ? u.children : [u], d = h[0].count, p = [];
|
|
2187
|
+
for (const f of c) {
|
|
2188
|
+
const m = new Me(), y = new E(), _ = new X(), x = new E(1, 1, 1), M = new zn(f.geometry, f.material, d);
|
|
2189
|
+
for (let S = 0; S < d; S++)
|
|
2190
|
+
l.TRANSLATION && y.fromBufferAttribute(l.TRANSLATION, S), l.ROTATION && _.fromBufferAttribute(l.ROTATION, S), l.SCALE && x.fromBufferAttribute(l.SCALE, S), M.setMatrixAt(S, m.compose(y, _, x));
|
|
2191
|
+
for (const S in l)
|
|
2192
|
+
if (S === "_COLOR_0") {
|
|
2193
|
+
const L = l[S];
|
|
2194
|
+
M.instanceColor = new Gn(L.array, L.itemSize, L.normalized);
|
|
2195
|
+
} else S !== "TRANSLATION" && S !== "ROTATION" && S !== "SCALE" && f.geometry.setAttribute(S, l[S]);
|
|
2196
|
+
je.prototype.copy.call(M, f), this.parser.assignFinalMaterial(M), p.push(M);
|
|
2197
|
+
}
|
|
2198
|
+
return u.isGroup ? (u.clear(), u.add(...p), u) : p[0];
|
|
2199
|
+
}));
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
const gn = "glTF", Le = 12, Zt = { JSON: 1313821514, BIN: 5130562 };
|
|
2203
|
+
class vi {
|
|
2204
|
+
constructor(e) {
|
|
2205
|
+
this.name = R.KHR_BINARY_GLTF, this.content = null, this.body = null;
|
|
2206
|
+
const t = new DataView(e, 0, Le), s = new TextDecoder();
|
|
2207
|
+
if (this.header = {
|
|
2208
|
+
magic: s.decode(new Uint8Array(e.slice(0, 4))),
|
|
2209
|
+
version: t.getUint32(4, !0),
|
|
2210
|
+
length: t.getUint32(8, !0)
|
|
2211
|
+
}, this.header.magic !== gn)
|
|
2212
|
+
throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
|
|
2213
|
+
if (this.header.version < 2)
|
|
2214
|
+
throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
|
|
2215
|
+
const n = this.header.length - Le, i = new DataView(e, Le);
|
|
2216
|
+
let o = 0;
|
|
2217
|
+
for (; o < n; ) {
|
|
2218
|
+
const a = i.getUint32(o, !0);
|
|
2219
|
+
o += 4;
|
|
2220
|
+
const l = i.getUint32(o, !0);
|
|
2221
|
+
if (o += 4, l === Zt.JSON) {
|
|
2222
|
+
const h = new Uint8Array(e, Le + o, a);
|
|
2223
|
+
this.content = s.decode(h);
|
|
2224
|
+
} else if (l === Zt.BIN) {
|
|
2225
|
+
const h = Le + o;
|
|
2226
|
+
this.body = e.slice(h, h + a);
|
|
2227
|
+
}
|
|
2228
|
+
o += a;
|
|
2229
|
+
}
|
|
2230
|
+
if (this.content === null)
|
|
2231
|
+
throw new Error("THREE.GLTFLoader: JSON content not found.");
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
class Ri {
|
|
2235
|
+
constructor(e, t) {
|
|
2236
|
+
if (!t)
|
|
2237
|
+
throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
|
|
2238
|
+
this.name = R.KHR_DRACO_MESH_COMPRESSION, this.json = e, this.dracoLoader = t, this.dracoLoader.preload();
|
|
2239
|
+
}
|
|
2240
|
+
decodePrimitive(e, t) {
|
|
2241
|
+
const s = this.json, n = this.dracoLoader, i = e.extensions[this.name].bufferView, o = e.extensions[this.name].attributes, a = {}, l = {}, h = {};
|
|
2242
|
+
for (const u in o) {
|
|
2243
|
+
const c = bt[u] || u.toLowerCase();
|
|
2244
|
+
a[c] = o[u];
|
|
2245
|
+
}
|
|
2246
|
+
for (const u in e.attributes) {
|
|
2247
|
+
const c = bt[u] || u.toLowerCase();
|
|
2248
|
+
if (o[u] !== void 0) {
|
|
2249
|
+
const d = s.accessors[e.attributes[u]], p = Ee[d.componentType];
|
|
2250
|
+
h[c] = p.name, l[c] = d.normalized === !0;
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
return t.getDependency("bufferView", i).then(function(u) {
|
|
2254
|
+
return new Promise(function(c, d) {
|
|
2255
|
+
n.decodeDracoFile(u, function(p) {
|
|
2256
|
+
for (const f in p.attributes) {
|
|
2257
|
+
const m = p.attributes[f], y = l[f];
|
|
2258
|
+
y !== void 0 && (m.normalized = y);
|
|
2259
|
+
}
|
|
2260
|
+
c(p);
|
|
2261
|
+
}, a, h, ae, d);
|
|
2262
|
+
});
|
|
2263
|
+
});
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
class Ai {
|
|
2267
|
+
constructor() {
|
|
2268
|
+
this.name = R.KHR_TEXTURE_TRANSFORM;
|
|
2269
|
+
}
|
|
2270
|
+
extendTexture(e, t) {
|
|
2271
|
+
return (t.texCoord === void 0 || t.texCoord === e.channel) && t.offset === void 0 && t.rotation === void 0 && t.scale === void 0 || (e = e.clone(), t.texCoord !== void 0 && (e.channel = t.texCoord), t.offset !== void 0 && e.offset.fromArray(t.offset), t.rotation !== void 0 && (e.rotation = t.rotation), t.scale !== void 0 && e.repeat.fromArray(t.scale), e.needsUpdate = !0), e;
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
class Pi {
|
|
2275
|
+
constructor() {
|
|
2276
|
+
this.name = R.KHR_MESH_QUANTIZATION;
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
class yn extends ls {
|
|
2280
|
+
constructor(e, t, s, n) {
|
|
2281
|
+
super(e, t, s, n);
|
|
2282
|
+
}
|
|
2283
|
+
copySampleValue_(e) {
|
|
2284
|
+
const t = this.resultBuffer, s = this.sampleValues, n = this.valueSize, i = e * n * 3 + n;
|
|
2285
|
+
for (let o = 0; o !== n; o++)
|
|
2286
|
+
t[o] = s[i + o];
|
|
2287
|
+
return t;
|
|
2288
|
+
}
|
|
2289
|
+
interpolate_(e, t, s, n) {
|
|
2290
|
+
const i = this.resultBuffer, o = this.sampleValues, a = this.valueSize, l = a * 2, h = a * 3, u = n - t, c = (s - t) / u, d = c * c, p = d * c, f = e * h, m = f - h, y = -2 * p + 3 * d, _ = p - d, x = 1 - y, M = _ - d + c;
|
|
2291
|
+
for (let S = 0; S !== a; S++) {
|
|
2292
|
+
const L = o[m + S + a], v = o[m + S + l] * u, I = o[f + S + a], se = o[f + S] * u;
|
|
2293
|
+
i[S] = x * L + M * v + y * I + _ * se;
|
|
2294
|
+
}
|
|
2295
|
+
return i;
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
const Li = new X();
|
|
2299
|
+
class Ii extends yn {
|
|
2300
|
+
interpolate_(e, t, s, n) {
|
|
2301
|
+
const i = super.interpolate_(e, t, s, n);
|
|
2302
|
+
return Li.fromArray(i).normalize().toArray(i), i;
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
const Q = {
|
|
2306
|
+
POINTS: 0,
|
|
2307
|
+
LINES: 1,
|
|
2308
|
+
LINE_LOOP: 2,
|
|
2309
|
+
LINE_STRIP: 3,
|
|
2310
|
+
TRIANGLES: 4,
|
|
2311
|
+
TRIANGLE_STRIP: 5,
|
|
2312
|
+
TRIANGLE_FAN: 6
|
|
2313
|
+
}, Ee = {
|
|
2314
|
+
5120: Int8Array,
|
|
2315
|
+
5121: Uint8Array,
|
|
2316
|
+
5122: Int16Array,
|
|
2317
|
+
5123: Uint16Array,
|
|
2318
|
+
5125: Uint32Array,
|
|
2319
|
+
5126: Float32Array
|
|
2320
|
+
}, Qt = {
|
|
2321
|
+
9728: cn,
|
|
2322
|
+
9729: gt,
|
|
2323
|
+
9984: Qn,
|
|
2324
|
+
9985: Zn,
|
|
2325
|
+
9986: Vn,
|
|
2326
|
+
9987: ln
|
|
2327
|
+
}, qt = {
|
|
2328
|
+
33071: Wn,
|
|
2329
|
+
33648: qn,
|
|
2330
|
+
10497: yt
|
|
2331
|
+
}, ut = {
|
|
2332
|
+
SCALAR: 1,
|
|
2333
|
+
VEC2: 2,
|
|
2334
|
+
VEC3: 3,
|
|
2335
|
+
VEC4: 4,
|
|
2336
|
+
MAT2: 4,
|
|
2337
|
+
MAT3: 9,
|
|
2338
|
+
MAT4: 16
|
|
2339
|
+
}, bt = {
|
|
2340
|
+
POSITION: "position",
|
|
2341
|
+
NORMAL: "normal",
|
|
2342
|
+
TANGENT: "tangent",
|
|
2343
|
+
TEXCOORD_0: "uv",
|
|
2344
|
+
TEXCOORD_1: "uv1",
|
|
2345
|
+
TEXCOORD_2: "uv2",
|
|
2346
|
+
TEXCOORD_3: "uv3",
|
|
2347
|
+
COLOR_0: "color",
|
|
2348
|
+
WEIGHTS_0: "skinWeight",
|
|
2349
|
+
JOINTS_0: "skinIndex"
|
|
2350
|
+
}, ce = {
|
|
2351
|
+
scale: "scale",
|
|
2352
|
+
translation: "position",
|
|
2353
|
+
rotation: "quaternion",
|
|
2354
|
+
weights: "morphTargetInfluences"
|
|
2355
|
+
}, Oi = {
|
|
2356
|
+
CUBICSPLINE: void 0,
|
|
2357
|
+
// We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
|
|
2358
|
+
// keyframe track will be initialized with a default interpolation type, then modified.
|
|
2359
|
+
LINEAR: un,
|
|
2360
|
+
STEP: rs
|
|
2361
|
+
}, dt = {
|
|
2362
|
+
OPAQUE: "OPAQUE",
|
|
2363
|
+
MASK: "MASK",
|
|
2364
|
+
BLEND: "BLEND"
|
|
2365
|
+
};
|
|
2366
|
+
function Ci(r) {
|
|
2367
|
+
return r.DefaultMaterial === void 0 && (r.DefaultMaterial = new hn({
|
|
2368
|
+
color: 16777215,
|
|
2369
|
+
emissive: 0,
|
|
2370
|
+
metalness: 1,
|
|
2371
|
+
roughness: 1,
|
|
2372
|
+
transparent: !1,
|
|
2373
|
+
depthTest: !0,
|
|
2374
|
+
side: as
|
|
2375
|
+
})), r.DefaultMaterial;
|
|
2376
|
+
}
|
|
2377
|
+
function me(r, e, t) {
|
|
2378
|
+
for (const s in t.extensions)
|
|
2379
|
+
r[s] === void 0 && (e.userData.gltfExtensions = e.userData.gltfExtensions || {}, e.userData.gltfExtensions[s] = t.extensions[s]);
|
|
2380
|
+
}
|
|
2381
|
+
function te(r, e) {
|
|
2382
|
+
e.extras !== void 0 && (typeof e.extras == "object" ? Object.assign(r.userData, e.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + e.extras));
|
|
2383
|
+
}
|
|
2384
|
+
function Di(r, e, t) {
|
|
2385
|
+
let s = !1, n = !1, i = !1;
|
|
2386
|
+
for (let h = 0, u = e.length; h < u; h++) {
|
|
2387
|
+
const c = e[h];
|
|
2388
|
+
if (c.POSITION !== void 0 && (s = !0), c.NORMAL !== void 0 && (n = !0), c.COLOR_0 !== void 0 && (i = !0), s && n && i) break;
|
|
2389
|
+
}
|
|
2390
|
+
if (!s && !n && !i) return Promise.resolve(r);
|
|
2391
|
+
const o = [], a = [], l = [];
|
|
2392
|
+
for (let h = 0, u = e.length; h < u; h++) {
|
|
2393
|
+
const c = e[h];
|
|
2394
|
+
if (s) {
|
|
2395
|
+
const d = c.POSITION !== void 0 ? t.getDependency("accessor", c.POSITION) : r.attributes.position;
|
|
2396
|
+
o.push(d);
|
|
2397
|
+
}
|
|
2398
|
+
if (n) {
|
|
2399
|
+
const d = c.NORMAL !== void 0 ? t.getDependency("accessor", c.NORMAL) : r.attributes.normal;
|
|
2400
|
+
a.push(d);
|
|
2401
|
+
}
|
|
2402
|
+
if (i) {
|
|
2403
|
+
const d = c.COLOR_0 !== void 0 ? t.getDependency("accessor", c.COLOR_0) : r.attributes.color;
|
|
2404
|
+
l.push(d);
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
return Promise.all([
|
|
2408
|
+
Promise.all(o),
|
|
2409
|
+
Promise.all(a),
|
|
2410
|
+
Promise.all(l)
|
|
2411
|
+
]).then(function(h) {
|
|
2412
|
+
const u = h[0], c = h[1], d = h[2];
|
|
2413
|
+
return s && (r.morphAttributes.position = u), n && (r.morphAttributes.normal = c), i && (r.morphAttributes.color = d), r.morphTargetsRelative = !0, r;
|
|
2414
|
+
});
|
|
2415
|
+
}
|
|
2416
|
+
function Ni(r, e) {
|
|
2417
|
+
if (r.updateMorphTargets(), e.weights !== void 0)
|
|
2418
|
+
for (let t = 0, s = e.weights.length; t < s; t++)
|
|
2419
|
+
r.morphTargetInfluences[t] = e.weights[t];
|
|
2420
|
+
if (e.extras && Array.isArray(e.extras.targetNames)) {
|
|
2421
|
+
const t = e.extras.targetNames;
|
|
2422
|
+
if (r.morphTargetInfluences.length === t.length) {
|
|
2423
|
+
r.morphTargetDictionary = {};
|
|
2424
|
+
for (let s = 0, n = t.length; s < n; s++)
|
|
2425
|
+
r.morphTargetDictionary[t[s]] = s;
|
|
2426
|
+
} else
|
|
2427
|
+
console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
function ki(r) {
|
|
2431
|
+
let e;
|
|
2432
|
+
const t = r.extensions && r.extensions[R.KHR_DRACO_MESH_COMPRESSION];
|
|
2433
|
+
if (t ? e = "draco:" + t.bufferView + ":" + t.indices + ":" + pt(t.attributes) : e = r.indices + ":" + pt(r.attributes) + ":" + r.mode, r.targets !== void 0)
|
|
2434
|
+
for (let s = 0, n = r.targets.length; s < n; s++)
|
|
2435
|
+
e += ":" + pt(r.targets[s]);
|
|
2436
|
+
return e;
|
|
2437
|
+
}
|
|
2438
|
+
function pt(r) {
|
|
2439
|
+
let e = "";
|
|
2440
|
+
const t = Object.keys(r).sort();
|
|
2441
|
+
for (let s = 0, n = t.length; s < n; s++)
|
|
2442
|
+
e += t[s] + ":" + r[t[s]] + ";";
|
|
2443
|
+
return e;
|
|
2444
|
+
}
|
|
2445
|
+
function wt(r) {
|
|
2446
|
+
switch (r) {
|
|
2447
|
+
case Int8Array:
|
|
2448
|
+
return 1 / 127;
|
|
2449
|
+
case Uint8Array:
|
|
2450
|
+
return 1 / 255;
|
|
2451
|
+
case Int16Array:
|
|
2452
|
+
return 1 / 32767;
|
|
2453
|
+
case Uint16Array:
|
|
2454
|
+
return 1 / 65535;
|
|
2455
|
+
default:
|
|
2456
|
+
throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2459
|
+
function ji(r) {
|
|
2460
|
+
return r.search(/\.jpe?g($|\?)/i) > 0 || r.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : r.search(/\.webp($|\?)/i) > 0 || r.search(/^data\:image\/webp/) === 0 ? "image/webp" : r.search(/\.ktx2($|\?)/i) > 0 || r.search(/^data\:image\/ktx2/) === 0 ? "image/ktx2" : "image/png";
|
|
2461
|
+
}
|
|
2462
|
+
const Hi = new Me();
|
|
2463
|
+
class Fi {
|
|
2464
|
+
constructor(e = {}, t = {}) {
|
|
2465
|
+
this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new li(), this.associations = /* @__PURE__ */ new Map(), this.primitiveCache = {}, this.nodeCache = {}, this.meshCache = { refs: {}, uses: {} }, this.cameraCache = { refs: {}, uses: {} }, this.lightCache = { refs: {}, uses: {} }, this.sourceCache = {}, this.textureCache = {}, this.nodeNamesUsed = {};
|
|
2466
|
+
let s = !1, n = -1, i = !1, o = -1;
|
|
2467
|
+
if (typeof navigator < "u" && typeof navigator.userAgent < "u") {
|
|
2468
|
+
const a = navigator.userAgent;
|
|
2469
|
+
s = /^((?!chrome|android).)*safari/i.test(a) === !0;
|
|
2470
|
+
const l = a.match(/Version\/(\d+)/);
|
|
2471
|
+
n = s && l ? parseInt(l[1], 10) : -1, i = a.indexOf("Firefox") > -1, o = i ? a.match(/Firefox\/([0-9]+)\./)[1] : -1;
|
|
2472
|
+
}
|
|
2473
|
+
typeof createImageBitmap > "u" || s && n < 17 || i && o < 98 ? this.textureLoader = new Xn(this.options.manager) : this.textureLoader = new Yn(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new Tt(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(!0);
|
|
2474
|
+
}
|
|
2475
|
+
setExtensions(e) {
|
|
2476
|
+
this.extensions = e;
|
|
2477
|
+
}
|
|
2478
|
+
setPlugins(e) {
|
|
2479
|
+
this.plugins = e;
|
|
2480
|
+
}
|
|
2481
|
+
parse(e, t) {
|
|
2482
|
+
const s = this, n = this.json, i = this.extensions;
|
|
2483
|
+
this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(o) {
|
|
2484
|
+
return o._markDefs && o._markDefs();
|
|
2485
|
+
}), Promise.all(this._invokeAll(function(o) {
|
|
2486
|
+
return o.beforeRoot && o.beforeRoot();
|
|
2487
|
+
})).then(function() {
|
|
2488
|
+
return Promise.all([
|
|
2489
|
+
s.getDependencies("scene"),
|
|
2490
|
+
s.getDependencies("animation"),
|
|
2491
|
+
s.getDependencies("camera")
|
|
2492
|
+
]);
|
|
2493
|
+
}).then(function(o) {
|
|
2494
|
+
const a = {
|
|
2495
|
+
scene: o[0][n.scene || 0],
|
|
2496
|
+
scenes: o[0],
|
|
2497
|
+
animations: o[1],
|
|
2498
|
+
cameras: o[2],
|
|
2499
|
+
asset: n.asset,
|
|
2500
|
+
parser: s,
|
|
2501
|
+
userData: {}
|
|
2502
|
+
};
|
|
2503
|
+
return me(i, a, n), te(a, n), Promise.all(s._invokeAll(function(l) {
|
|
2504
|
+
return l.afterRoot && l.afterRoot(a);
|
|
2505
|
+
})).then(function() {
|
|
2506
|
+
for (const l of a.scenes)
|
|
2507
|
+
l.updateMatrixWorld();
|
|
2508
|
+
e(a);
|
|
2509
|
+
});
|
|
2510
|
+
}).catch(t);
|
|
2511
|
+
}
|
|
2512
|
+
/**
|
|
2513
|
+
* Marks the special nodes/meshes in json for efficient parse.
|
|
2514
|
+
*
|
|
2515
|
+
* @private
|
|
2516
|
+
*/
|
|
2517
|
+
_markDefs() {
|
|
2518
|
+
const e = this.json.nodes || [], t = this.json.skins || [], s = this.json.meshes || [];
|
|
2519
|
+
for (let n = 0, i = t.length; n < i; n++) {
|
|
2520
|
+
const o = t[n].joints;
|
|
2521
|
+
for (let a = 0, l = o.length; a < l; a++)
|
|
2522
|
+
e[o[a]].isBone = !0;
|
|
2523
|
+
}
|
|
2524
|
+
for (let n = 0, i = e.length; n < i; n++) {
|
|
2525
|
+
const o = e[n];
|
|
2526
|
+
o.mesh !== void 0 && (this._addNodeRef(this.meshCache, o.mesh), o.skin !== void 0 && (s[o.mesh].isSkinnedMesh = !0)), o.camera !== void 0 && this._addNodeRef(this.cameraCache, o.camera);
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
/**
|
|
2530
|
+
* Counts references to shared node / Object3D resources. These resources
|
|
2531
|
+
* can be reused, or "instantiated", at multiple nodes in the scene
|
|
2532
|
+
* hierarchy. Mesh, Camera, and Light instances are instantiated and must
|
|
2533
|
+
* be marked. Non-scenegraph resources (like Materials, Geometries, and
|
|
2534
|
+
* Textures) can be reused directly and are not marked here.
|
|
2535
|
+
*
|
|
2536
|
+
* Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
|
|
2537
|
+
*
|
|
2538
|
+
* @private
|
|
2539
|
+
* @param {Object} cache
|
|
2540
|
+
* @param {Object3D} index
|
|
2541
|
+
*/
|
|
2542
|
+
_addNodeRef(e, t) {
|
|
2543
|
+
t !== void 0 && (e.refs[t] === void 0 && (e.refs[t] = e.uses[t] = 0), e.refs[t]++);
|
|
2544
|
+
}
|
|
2545
|
+
/**
|
|
2546
|
+
* Returns a reference to a shared resource, cloning it if necessary.
|
|
2547
|
+
*
|
|
2548
|
+
* @private
|
|
2549
|
+
* @param {Object} cache
|
|
2550
|
+
* @param {number} index
|
|
2551
|
+
* @param {Object} object
|
|
2552
|
+
* @return {Object}
|
|
2553
|
+
*/
|
|
2554
|
+
_getNodeRef(e, t, s) {
|
|
2555
|
+
if (e.refs[t] <= 1) return s;
|
|
2556
|
+
const n = s.clone(), i = (o, a) => {
|
|
2557
|
+
const l = this.associations.get(o);
|
|
2558
|
+
l != null && this.associations.set(a, l);
|
|
2559
|
+
for (const [h, u] of o.children.entries())
|
|
2560
|
+
i(u, a.children[h]);
|
|
2561
|
+
};
|
|
2562
|
+
return i(s, n), n.name += "_instance_" + e.uses[t]++, n;
|
|
2563
|
+
}
|
|
2564
|
+
_invokeOne(e) {
|
|
2565
|
+
const t = Object.values(this.plugins);
|
|
2566
|
+
t.push(this);
|
|
2567
|
+
for (let s = 0; s < t.length; s++) {
|
|
2568
|
+
const n = e(t[s]);
|
|
2569
|
+
if (n) return n;
|
|
2570
|
+
}
|
|
2571
|
+
return null;
|
|
2572
|
+
}
|
|
2573
|
+
_invokeAll(e) {
|
|
2574
|
+
const t = Object.values(this.plugins);
|
|
2575
|
+
t.unshift(this);
|
|
2576
|
+
const s = [];
|
|
2577
|
+
for (let n = 0; n < t.length; n++) {
|
|
2578
|
+
const i = e(t[n]);
|
|
2579
|
+
i && s.push(i);
|
|
2580
|
+
}
|
|
2581
|
+
return s;
|
|
2582
|
+
}
|
|
2583
|
+
/**
|
|
2584
|
+
* Requests the specified dependency asynchronously, with caching.
|
|
2585
|
+
*
|
|
2586
|
+
* @private
|
|
2587
|
+
* @param {string} type
|
|
2588
|
+
* @param {number} index
|
|
2589
|
+
* @return {Promise<Object3D|Material|Texture|AnimationClip|ArrayBuffer|Object>}
|
|
2590
|
+
*/
|
|
2591
|
+
getDependency(e, t) {
|
|
2592
|
+
const s = e + ":" + t;
|
|
2593
|
+
let n = this.cache.get(s);
|
|
2594
|
+
if (!n) {
|
|
2595
|
+
switch (e) {
|
|
2596
|
+
case "scene":
|
|
2597
|
+
n = this.loadScene(t);
|
|
2598
|
+
break;
|
|
2599
|
+
case "node":
|
|
2600
|
+
n = this._invokeOne(function(i) {
|
|
2601
|
+
return i.loadNode && i.loadNode(t);
|
|
2602
|
+
});
|
|
2603
|
+
break;
|
|
2604
|
+
case "mesh":
|
|
2605
|
+
n = this._invokeOne(function(i) {
|
|
2606
|
+
return i.loadMesh && i.loadMesh(t);
|
|
2607
|
+
});
|
|
2608
|
+
break;
|
|
2609
|
+
case "accessor":
|
|
2610
|
+
n = this.loadAccessor(t);
|
|
2611
|
+
break;
|
|
2612
|
+
case "bufferView":
|
|
2613
|
+
n = this._invokeOne(function(i) {
|
|
2614
|
+
return i.loadBufferView && i.loadBufferView(t);
|
|
2615
|
+
});
|
|
2616
|
+
break;
|
|
2617
|
+
case "buffer":
|
|
2618
|
+
n = this.loadBuffer(t);
|
|
2619
|
+
break;
|
|
2620
|
+
case "material":
|
|
2621
|
+
n = this._invokeOne(function(i) {
|
|
2622
|
+
return i.loadMaterial && i.loadMaterial(t);
|
|
2623
|
+
});
|
|
2624
|
+
break;
|
|
2625
|
+
case "texture":
|
|
2626
|
+
n = this._invokeOne(function(i) {
|
|
2627
|
+
return i.loadTexture && i.loadTexture(t);
|
|
2628
|
+
});
|
|
2629
|
+
break;
|
|
2630
|
+
case "skin":
|
|
2631
|
+
n = this.loadSkin(t);
|
|
2632
|
+
break;
|
|
2633
|
+
case "animation":
|
|
2634
|
+
n = this._invokeOne(function(i) {
|
|
2635
|
+
return i.loadAnimation && i.loadAnimation(t);
|
|
2636
|
+
});
|
|
2637
|
+
break;
|
|
2638
|
+
case "camera":
|
|
2639
|
+
n = this.loadCamera(t);
|
|
2640
|
+
break;
|
|
2641
|
+
default:
|
|
2642
|
+
if (n = this._invokeOne(function(i) {
|
|
2643
|
+
return i != this && i.getDependency && i.getDependency(e, t);
|
|
2644
|
+
}), !n)
|
|
2645
|
+
throw new Error("Unknown type: " + e);
|
|
2646
|
+
break;
|
|
2647
|
+
}
|
|
2648
|
+
this.cache.add(s, n);
|
|
2649
|
+
}
|
|
2650
|
+
return n;
|
|
2651
|
+
}
|
|
2652
|
+
/**
|
|
2653
|
+
* Requests all dependencies of the specified type asynchronously, with caching.
|
|
2654
|
+
*
|
|
2655
|
+
* @private
|
|
2656
|
+
* @param {string} type
|
|
2657
|
+
* @return {Promise<Array<Object>>}
|
|
2658
|
+
*/
|
|
2659
|
+
getDependencies(e) {
|
|
2660
|
+
let t = this.cache.get(e);
|
|
2661
|
+
if (!t) {
|
|
2662
|
+
const s = this, n = this.json[e + (e === "mesh" ? "es" : "s")] || [];
|
|
2663
|
+
t = Promise.all(n.map(function(i, o) {
|
|
2664
|
+
return s.getDependency(e, o);
|
|
2665
|
+
})), this.cache.add(e, t);
|
|
2666
|
+
}
|
|
2667
|
+
return t;
|
|
2668
|
+
}
|
|
2669
|
+
/**
|
|
2670
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
2671
|
+
*
|
|
2672
|
+
* @private
|
|
2673
|
+
* @param {number} bufferIndex
|
|
2674
|
+
* @return {Promise<ArrayBuffer>}
|
|
2675
|
+
*/
|
|
2676
|
+
loadBuffer(e) {
|
|
2677
|
+
const t = this.json.buffers[e], s = this.fileLoader;
|
|
2678
|
+
if (t.type && t.type !== "arraybuffer")
|
|
2679
|
+
throw new Error("THREE.GLTFLoader: " + t.type + " buffer type is not supported.");
|
|
2680
|
+
if (t.uri === void 0 && e === 0)
|
|
2681
|
+
return Promise.resolve(this.extensions[R.KHR_BINARY_GLTF].body);
|
|
2682
|
+
const n = this.options;
|
|
2683
|
+
return new Promise(function(i, o) {
|
|
2684
|
+
s.load(ke.resolveURL(t.uri, n.path), i, void 0, function() {
|
|
2685
|
+
o(new Error('THREE.GLTFLoader: Failed to load buffer "' + t.uri + '".'));
|
|
2686
|
+
});
|
|
2687
|
+
});
|
|
2688
|
+
}
|
|
2689
|
+
/**
|
|
2690
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
2691
|
+
*
|
|
2692
|
+
* @private
|
|
2693
|
+
* @param {number} bufferViewIndex
|
|
2694
|
+
* @return {Promise<ArrayBuffer>}
|
|
2695
|
+
*/
|
|
2696
|
+
loadBufferView(e) {
|
|
2697
|
+
const t = this.json.bufferViews[e];
|
|
2698
|
+
return this.getDependency("buffer", t.buffer).then(function(s) {
|
|
2699
|
+
const n = t.byteLength || 0, i = t.byteOffset || 0;
|
|
2700
|
+
return s.slice(i, i + n);
|
|
2701
|
+
});
|
|
2702
|
+
}
|
|
2703
|
+
/**
|
|
2704
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
|
|
2705
|
+
*
|
|
2706
|
+
* @private
|
|
2707
|
+
* @param {number} accessorIndex
|
|
2708
|
+
* @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
|
|
2709
|
+
*/
|
|
2710
|
+
loadAccessor(e) {
|
|
2711
|
+
const t = this, s = this.json, n = this.json.accessors[e];
|
|
2712
|
+
if (n.bufferView === void 0 && n.sparse === void 0) {
|
|
2713
|
+
const o = ut[n.type], a = Ee[n.componentType], l = n.normalized === !0, h = new a(n.count * o);
|
|
2714
|
+
return Promise.resolve(new ot(h, o, l));
|
|
2715
|
+
}
|
|
2716
|
+
const i = [];
|
|
2717
|
+
return n.bufferView !== void 0 ? i.push(this.getDependency("bufferView", n.bufferView)) : i.push(null), n.sparse !== void 0 && (i.push(this.getDependency("bufferView", n.sparse.indices.bufferView)), i.push(this.getDependency("bufferView", n.sparse.values.bufferView))), Promise.all(i).then(function(o) {
|
|
2718
|
+
const a = o[0], l = ut[n.type], h = Ee[n.componentType], u = h.BYTES_PER_ELEMENT, c = u * l, d = n.byteOffset || 0, p = n.bufferView !== void 0 ? s.bufferViews[n.bufferView].byteStride : void 0, f = n.normalized === !0;
|
|
2719
|
+
let m, y;
|
|
2720
|
+
if (p && p !== c) {
|
|
2721
|
+
const _ = Math.floor(d / p), x = "InterleavedBuffer:" + n.bufferView + ":" + n.componentType + ":" + _ + ":" + n.count;
|
|
2722
|
+
let M = t.cache.get(x);
|
|
2723
|
+
M || (m = new h(a, _ * p, n.count * p / u), M = new Bn(m, p / u), t.cache.add(x, M)), y = new Kn(M, l, d % p / u, f);
|
|
2724
|
+
} else
|
|
2725
|
+
a === null ? m = new h(n.count * l) : m = new h(a, d, n.count * l), y = new ot(m, l, f);
|
|
2726
|
+
if (n.sparse !== void 0) {
|
|
2727
|
+
const _ = ut.SCALAR, x = Ee[n.sparse.indices.componentType], M = n.sparse.indices.byteOffset || 0, S = n.sparse.values.byteOffset || 0, L = new x(o[1], M, n.sparse.count * _), v = new h(o[2], S, n.sparse.count * l);
|
|
2728
|
+
a !== null && (y = new ot(y.array.slice(), y.itemSize, y.normalized)), y.normalized = !1;
|
|
2729
|
+
for (let I = 0, se = L.length; I < se; I++) {
|
|
2730
|
+
const J = L[I];
|
|
2731
|
+
if (y.setX(J, v[I * l]), l >= 2 && y.setY(J, v[I * l + 1]), l >= 3 && y.setZ(J, v[I * l + 2]), l >= 4 && y.setW(J, v[I * l + 3]), l >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
|
|
2732
|
+
}
|
|
2733
|
+
y.normalized = f;
|
|
2734
|
+
}
|
|
2735
|
+
return y;
|
|
2736
|
+
});
|
|
2737
|
+
}
|
|
2738
|
+
/**
|
|
2739
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
|
|
2740
|
+
*
|
|
2741
|
+
* @private
|
|
2742
|
+
* @param {number} textureIndex
|
|
2743
|
+
* @return {Promise<?Texture>}
|
|
2744
|
+
*/
|
|
2745
|
+
loadTexture(e) {
|
|
2746
|
+
const t = this.json, s = this.options, i = t.textures[e].source, o = t.images[i];
|
|
2747
|
+
let a = this.textureLoader;
|
|
2748
|
+
if (o.uri) {
|
|
2749
|
+
const l = s.manager.getHandler(o.uri);
|
|
2750
|
+
l !== null && (a = l);
|
|
2751
|
+
}
|
|
2752
|
+
return this.loadTextureImage(e, i, a);
|
|
2753
|
+
}
|
|
2754
|
+
loadTextureImage(e, t, s) {
|
|
2755
|
+
const n = this, i = this.json, o = i.textures[e], a = i.images[t], l = (a.uri || a.bufferView) + ":" + o.sampler;
|
|
2756
|
+
if (this.textureCache[l])
|
|
2757
|
+
return this.textureCache[l];
|
|
2758
|
+
const h = this.loadImageSource(t, s).then(function(u) {
|
|
2759
|
+
u.flipY = !1, u.name = o.name || a.name || "", u.name === "" && typeof a.uri == "string" && a.uri.startsWith("data:image/") === !1 && (u.name = a.uri);
|
|
2760
|
+
const d = (i.samplers || {})[o.sampler] || {};
|
|
2761
|
+
return u.magFilter = Qt[d.magFilter] || gt, u.minFilter = Qt[d.minFilter] || ln, u.wrapS = qt[d.wrapS] || yt, u.wrapT = qt[d.wrapT] || yt, u.generateMipmaps = !u.isCompressedTexture && u.minFilter !== cn && u.minFilter !== gt, n.associations.set(u, { textures: e }), u;
|
|
2762
|
+
}).catch(function() {
|
|
2763
|
+
return null;
|
|
2764
|
+
});
|
|
2765
|
+
return this.textureCache[l] = h, h;
|
|
2766
|
+
}
|
|
2767
|
+
loadImageSource(e, t) {
|
|
2768
|
+
const s = this, n = this.json, i = this.options;
|
|
2769
|
+
if (this.sourceCache[e] !== void 0)
|
|
2770
|
+
return this.sourceCache[e].then((c) => c.clone());
|
|
2771
|
+
const o = n.images[e], a = self.URL || self.webkitURL;
|
|
2772
|
+
let l = o.uri || "", h = !1;
|
|
2773
|
+
if (o.bufferView !== void 0)
|
|
2774
|
+
l = s.getDependency("bufferView", o.bufferView).then(function(c) {
|
|
2775
|
+
h = !0;
|
|
2776
|
+
const d = new Blob([c], { type: o.mimeType });
|
|
2777
|
+
return l = a.createObjectURL(d), l;
|
|
2778
|
+
});
|
|
2779
|
+
else if (o.uri === void 0)
|
|
2780
|
+
throw new Error("THREE.GLTFLoader: Image " + e + " is missing URI and bufferView");
|
|
2781
|
+
const u = Promise.resolve(l).then(function(c) {
|
|
2782
|
+
return new Promise(function(d, p) {
|
|
2783
|
+
let f = d;
|
|
2784
|
+
t.isImageBitmapLoader === !0 && (f = function(m) {
|
|
2785
|
+
const y = new At(m);
|
|
2786
|
+
y.needsUpdate = !0, d(y);
|
|
2787
|
+
}), t.load(ke.resolveURL(c, i.path), f, void 0, p);
|
|
2788
|
+
});
|
|
2789
|
+
}).then(function(c) {
|
|
2790
|
+
return h === !0 && a.revokeObjectURL(l), te(c, o), c.userData.mimeType = o.mimeType || ji(o.uri), c;
|
|
2791
|
+
}).catch(function(c) {
|
|
2792
|
+
throw console.error("THREE.GLTFLoader: Couldn't load texture", l), c;
|
|
2793
|
+
});
|
|
2794
|
+
return this.sourceCache[e] = u, u;
|
|
2795
|
+
}
|
|
2796
|
+
/**
|
|
2797
|
+
* Asynchronously assigns a texture to the given material parameters.
|
|
2798
|
+
*
|
|
2799
|
+
* @private
|
|
2800
|
+
* @param {Object} materialParams
|
|
2801
|
+
* @param {string} mapName
|
|
2802
|
+
* @param {Object} mapDef
|
|
2803
|
+
* @param {string} [colorSpace]
|
|
2804
|
+
* @return {Promise<Texture>}
|
|
2805
|
+
*/
|
|
2806
|
+
assignTexture(e, t, s, n) {
|
|
2807
|
+
const i = this;
|
|
2808
|
+
return this.getDependency("texture", s.index).then(function(o) {
|
|
2809
|
+
if (!o) return null;
|
|
2810
|
+
if (s.texCoord !== void 0 && s.texCoord > 0 && (o = o.clone(), o.channel = s.texCoord), i.extensions[R.KHR_TEXTURE_TRANSFORM]) {
|
|
2811
|
+
const a = s.extensions !== void 0 ? s.extensions[R.KHR_TEXTURE_TRANSFORM] : void 0;
|
|
2812
|
+
if (a) {
|
|
2813
|
+
const l = i.associations.get(o);
|
|
2814
|
+
o = i.extensions[R.KHR_TEXTURE_TRANSFORM].extendTexture(o, a), i.associations.set(o, l);
|
|
2815
|
+
}
|
|
2816
|
+
}
|
|
2817
|
+
return n !== void 0 && (o.colorSpace = n), e[t] = o, o;
|
|
2818
|
+
});
|
|
2819
|
+
}
|
|
2820
|
+
/**
|
|
2821
|
+
* Assigns final material to a Mesh, Line, or Points instance. The instance
|
|
2822
|
+
* already has a material (generated from the glTF material options alone)
|
|
2823
|
+
* but reuse of the same glTF material may require multiple threejs materials
|
|
2824
|
+
* to accommodate different primitive types, defines, etc. New materials will
|
|
2825
|
+
* be created if necessary, and reused from a cache.
|
|
2826
|
+
*
|
|
2827
|
+
* @private
|
|
2828
|
+
* @param {Object3D} mesh Mesh, Line, or Points instance.
|
|
2829
|
+
*/
|
|
2830
|
+
assignFinalMaterial(e) {
|
|
2831
|
+
const t = e.geometry;
|
|
2832
|
+
let s = e.material;
|
|
2833
|
+
const n = t.attributes.tangent === void 0, i = t.attributes.color !== void 0, o = t.attributes.normal === void 0;
|
|
2834
|
+
if (e.isPoints) {
|
|
2835
|
+
const a = "PointsMaterial:" + s.uuid;
|
|
2836
|
+
let l = this.cache.get(a);
|
|
2837
|
+
l || (l = new Ie(), Ne.prototype.copy.call(l, s), l.color.copy(s.color), l.map = s.map, l.sizeAttenuation = !1, this.cache.add(a, l)), s = l;
|
|
2838
|
+
} else if (e.isLine) {
|
|
2839
|
+
const a = "LineBasicMaterial:" + s.uuid;
|
|
2840
|
+
let l = this.cache.get(a);
|
|
2841
|
+
l || (l = new De(), Ne.prototype.copy.call(l, s), l.color.copy(s.color), l.map = s.map, this.cache.add(a, l)), s = l;
|
|
2842
|
+
}
|
|
2843
|
+
if (n || i || o) {
|
|
2844
|
+
let a = "ClonedMaterial:" + s.uuid + ":";
|
|
2845
|
+
n && (a += "derivative-tangents:"), i && (a += "vertex-colors:"), o && (a += "flat-shading:");
|
|
2846
|
+
let l = this.cache.get(a);
|
|
2847
|
+
l || (l = s.clone(), i && (l.vertexColors = !0), o && (l.flatShading = !0), n && (l.normalScale && (l.normalScale.y *= -1), l.clearcoatNormalScale && (l.clearcoatNormalScale.y *= -1)), this.cache.add(a, l), this.associations.set(l, this.associations.get(s))), s = l;
|
|
2848
|
+
}
|
|
2849
|
+
e.material = s;
|
|
2850
|
+
}
|
|
2851
|
+
getMaterialType() {
|
|
2852
|
+
return hn;
|
|
2853
|
+
}
|
|
2854
|
+
/**
|
|
2855
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
|
|
2856
|
+
*
|
|
2857
|
+
* @private
|
|
2858
|
+
* @param {number} materialIndex
|
|
2859
|
+
* @return {Promise<Material>}
|
|
2860
|
+
*/
|
|
2861
|
+
loadMaterial(e) {
|
|
2862
|
+
const t = this, s = this.json, n = this.extensions, i = s.materials[e];
|
|
2863
|
+
let o;
|
|
2864
|
+
const a = {}, l = i.extensions || {}, h = [];
|
|
2865
|
+
if (l[R.KHR_MATERIALS_UNLIT]) {
|
|
2866
|
+
const c = n[R.KHR_MATERIALS_UNLIT];
|
|
2867
|
+
o = c.getMaterialType(), h.push(c.extendParams(a, i, t));
|
|
2868
|
+
} else {
|
|
2869
|
+
const c = i.pbrMetallicRoughness || {};
|
|
2870
|
+
if (a.color = new ue(1, 1, 1), a.opacity = 1, Array.isArray(c.baseColorFactor)) {
|
|
2871
|
+
const d = c.baseColorFactor;
|
|
2872
|
+
a.color.setRGB(d[0], d[1], d[2], ae), a.opacity = d[3];
|
|
2873
|
+
}
|
|
2874
|
+
c.baseColorTexture !== void 0 && h.push(t.assignTexture(a, "map", c.baseColorTexture, Se)), a.metalness = c.metallicFactor !== void 0 ? c.metallicFactor : 1, a.roughness = c.roughnessFactor !== void 0 ? c.roughnessFactor : 1, c.metallicRoughnessTexture !== void 0 && (h.push(t.assignTexture(a, "metalnessMap", c.metallicRoughnessTexture)), h.push(t.assignTexture(a, "roughnessMap", c.metallicRoughnessTexture))), o = this._invokeOne(function(d) {
|
|
2875
|
+
return d.getMaterialType && d.getMaterialType(e);
|
|
2876
|
+
}), h.push(Promise.all(this._invokeAll(function(d) {
|
|
2877
|
+
return d.extendMaterialParams && d.extendMaterialParams(e, a);
|
|
2878
|
+
})));
|
|
2879
|
+
}
|
|
2880
|
+
i.doubleSided === !0 && (a.side = on);
|
|
2881
|
+
const u = i.alphaMode || dt.OPAQUE;
|
|
2882
|
+
if (u === dt.BLEND ? (a.transparent = !0, a.depthWrite = !1) : (a.transparent = !1, u === dt.MASK && (a.alphaTest = i.alphaCutoff !== void 0 ? i.alphaCutoff : 0.5)), i.normalTexture !== void 0 && o !== ye && (h.push(t.assignTexture(a, "normalMap", i.normalTexture)), a.normalScale = new B(1, 1), i.normalTexture.scale !== void 0)) {
|
|
2883
|
+
const c = i.normalTexture.scale;
|
|
2884
|
+
a.normalScale.set(c, c);
|
|
2885
|
+
}
|
|
2886
|
+
if (i.occlusionTexture !== void 0 && o !== ye && (h.push(t.assignTexture(a, "aoMap", i.occlusionTexture)), i.occlusionTexture.strength !== void 0 && (a.aoMapIntensity = i.occlusionTexture.strength)), i.emissiveFactor !== void 0 && o !== ye) {
|
|
2887
|
+
const c = i.emissiveFactor;
|
|
2888
|
+
a.emissive = new ue().setRGB(c[0], c[1], c[2], ae);
|
|
2889
|
+
}
|
|
2890
|
+
return i.emissiveTexture !== void 0 && o !== ye && h.push(t.assignTexture(a, "emissiveMap", i.emissiveTexture, Se)), Promise.all(h).then(function() {
|
|
2891
|
+
const c = new o(a);
|
|
2892
|
+
return i.name && (c.name = i.name), te(c, i), t.associations.set(c, { materials: e }), i.extensions && me(n, c, i), c;
|
|
2893
|
+
});
|
|
2894
|
+
}
|
|
2895
|
+
/**
|
|
2896
|
+
* When Object3D instances are targeted by animation, they need unique names.
|
|
2897
|
+
*
|
|
2898
|
+
* @private
|
|
2899
|
+
* @param {string} originalName
|
|
2900
|
+
* @return {string}
|
|
2901
|
+
*/
|
|
2902
|
+
createUniqueName(e) {
|
|
2903
|
+
const t = $n.sanitizeNodeName(e || "");
|
|
2904
|
+
return t in this.nodeNamesUsed ? t + "_" + ++this.nodeNamesUsed[t] : (this.nodeNamesUsed[t] = 0, t);
|
|
2905
|
+
}
|
|
2906
|
+
/**
|
|
2907
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
|
|
2908
|
+
*
|
|
2909
|
+
* Creates BufferGeometries from primitives.
|
|
2910
|
+
*
|
|
2911
|
+
* @private
|
|
2912
|
+
* @param {Array<GLTF.Primitive>} primitives
|
|
2913
|
+
* @return {Promise<Array<BufferGeometry>>}
|
|
2914
|
+
*/
|
|
2915
|
+
loadGeometries(e) {
|
|
2916
|
+
const t = this, s = this.extensions, n = this.primitiveCache;
|
|
2917
|
+
function i(a) {
|
|
2918
|
+
return s[R.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a, t).then(function(l) {
|
|
2919
|
+
return Wt(l, a, t);
|
|
2920
|
+
});
|
|
2921
|
+
}
|
|
2922
|
+
const o = [];
|
|
2923
|
+
for (let a = 0, l = e.length; a < l; a++) {
|
|
2924
|
+
const h = e[a], u = ki(h), c = n[u];
|
|
2925
|
+
if (c)
|
|
2926
|
+
o.push(c.promise);
|
|
2927
|
+
else {
|
|
2928
|
+
let d;
|
|
2929
|
+
h.extensions && h.extensions[R.KHR_DRACO_MESH_COMPRESSION] ? d = i(h) : d = Wt(new He(), h, t), n[u] = { primitive: h, promise: d }, o.push(d);
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
2932
|
+
return Promise.all(o);
|
|
2933
|
+
}
|
|
2934
|
+
/**
|
|
2935
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
|
|
2936
|
+
*
|
|
2937
|
+
* @private
|
|
2938
|
+
* @param {number} meshIndex
|
|
2939
|
+
* @return {Promise<Group|Mesh|SkinnedMesh|Line|Points>}
|
|
2940
|
+
*/
|
|
2941
|
+
loadMesh(e) {
|
|
2942
|
+
const t = this, s = this.json, n = this.extensions, i = s.meshes[e], o = i.primitives, a = [];
|
|
2943
|
+
for (let l = 0, h = o.length; l < h; l++) {
|
|
2944
|
+
const u = o[l].material === void 0 ? Ci(this.cache) : this.getDependency("material", o[l].material);
|
|
2945
|
+
a.push(u);
|
|
2946
|
+
}
|
|
2947
|
+
return a.push(t.loadGeometries(o)), Promise.all(a).then(function(l) {
|
|
2948
|
+
const h = l.slice(0, l.length - 1), u = l[l.length - 1], c = [];
|
|
2949
|
+
for (let p = 0, f = u.length; p < f; p++) {
|
|
2950
|
+
const m = u[p], y = o[p];
|
|
2951
|
+
let _;
|
|
2952
|
+
const x = h[p];
|
|
2953
|
+
if (y.mode === Q.TRIANGLES || y.mode === Q.TRIANGLE_STRIP || y.mode === Q.TRIANGLE_FAN || y.mode === void 0)
|
|
2954
|
+
_ = i.isSkinnedMesh === !0 ? new Jn(m, x) : new b(m, x), _.isSkinnedMesh === !0 && _.normalizeSkinWeights(), y.mode === Q.TRIANGLE_STRIP ? _.geometry = Kt(_.geometry, an) : y.mode === Q.TRIANGLE_FAN && (_.geometry = Kt(_.geometry, mt));
|
|
2955
|
+
else if (y.mode === Q.LINES)
|
|
2956
|
+
_ = new ft(m, x);
|
|
2957
|
+
else if (y.mode === Q.LINE_STRIP)
|
|
2958
|
+
_ = new re(m, x);
|
|
2959
|
+
else if (y.mode === Q.LINE_LOOP)
|
|
2960
|
+
_ = new es(m, x);
|
|
2961
|
+
else if (y.mode === Q.POINTS)
|
|
2962
|
+
_ = new Je(m, x);
|
|
2963
|
+
else
|
|
2964
|
+
throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + y.mode);
|
|
2965
|
+
Object.keys(_.geometry.morphAttributes).length > 0 && Ni(_, i), _.name = t.createUniqueName(i.name || "mesh_" + e), te(_, i), y.extensions && me(n, _, y), t.assignFinalMaterial(_), c.push(_);
|
|
2966
|
+
}
|
|
2967
|
+
for (let p = 0, f = c.length; p < f; p++)
|
|
2968
|
+
t.associations.set(c[p], {
|
|
2969
|
+
meshes: e,
|
|
2970
|
+
primitives: p
|
|
2971
|
+
});
|
|
2972
|
+
if (c.length === 1)
|
|
2973
|
+
return i.extensions && me(n, c[0], i), c[0];
|
|
2974
|
+
const d = new $e();
|
|
2975
|
+
i.extensions && me(n, d, i), t.associations.set(d, { meshes: e });
|
|
2976
|
+
for (let p = 0, f = c.length; p < f; p++)
|
|
2977
|
+
d.add(c[p]);
|
|
2978
|
+
return d;
|
|
2979
|
+
});
|
|
2980
|
+
}
|
|
2981
|
+
/**
|
|
2982
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
|
|
2983
|
+
*
|
|
2984
|
+
* @private
|
|
2985
|
+
* @param {number} cameraIndex
|
|
2986
|
+
* @return {Promise<Camera>|undefined}
|
|
2987
|
+
*/
|
|
2988
|
+
loadCamera(e) {
|
|
2989
|
+
let t;
|
|
2990
|
+
const s = this.json.cameras[e], n = s[s.type];
|
|
2991
|
+
if (!n) {
|
|
2992
|
+
console.warn("THREE.GLTFLoader: Missing camera parameters.");
|
|
2993
|
+
return;
|
|
2994
|
+
}
|
|
2995
|
+
return s.type === "perspective" ? t = new ts(sn.radToDeg(n.yfov), n.aspectRatio || 1, n.znear || 1, n.zfar || 2e6) : s.type === "orthographic" && (t = new ns(-n.xmag, n.xmag, n.ymag, -n.ymag, n.znear, n.zfar)), s.name && (t.name = this.createUniqueName(s.name)), te(t, s), Promise.resolve(t);
|
|
2996
|
+
}
|
|
2997
|
+
/**
|
|
2998
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
|
|
2999
|
+
*
|
|
3000
|
+
* @private
|
|
3001
|
+
* @param {number} skinIndex
|
|
3002
|
+
* @return {Promise<Skeleton>}
|
|
3003
|
+
*/
|
|
3004
|
+
loadSkin(e) {
|
|
3005
|
+
const t = this.json.skins[e], s = [];
|
|
3006
|
+
for (let n = 0, i = t.joints.length; n < i; n++)
|
|
3007
|
+
s.push(this._loadNodeShallow(t.joints[n]));
|
|
3008
|
+
return t.inverseBindMatrices !== void 0 ? s.push(this.getDependency("accessor", t.inverseBindMatrices)) : s.push(null), Promise.all(s).then(function(n) {
|
|
3009
|
+
const i = n.pop(), o = n, a = [], l = [];
|
|
3010
|
+
for (let h = 0, u = o.length; h < u; h++) {
|
|
3011
|
+
const c = o[h];
|
|
3012
|
+
if (c) {
|
|
3013
|
+
a.push(c);
|
|
3014
|
+
const d = new Me();
|
|
3015
|
+
i !== null && d.fromArray(i.array, h * 16), l.push(d);
|
|
3016
|
+
} else
|
|
3017
|
+
console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', t.joints[h]);
|
|
3018
|
+
}
|
|
3019
|
+
return new ss(a, l);
|
|
3020
|
+
});
|
|
3021
|
+
}
|
|
3022
|
+
/**
|
|
3023
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
|
|
3024
|
+
*
|
|
3025
|
+
* @private
|
|
3026
|
+
* @param {number} animationIndex
|
|
3027
|
+
* @return {Promise<AnimationClip>}
|
|
3028
|
+
*/
|
|
3029
|
+
loadAnimation(e) {
|
|
3030
|
+
const t = this.json, s = this, n = t.animations[e], i = n.name ? n.name : "animation_" + e, o = [], a = [], l = [], h = [], u = [];
|
|
3031
|
+
for (let c = 0, d = n.channels.length; c < d; c++) {
|
|
3032
|
+
const p = n.channels[c], f = n.samplers[p.sampler], m = p.target, y = m.node, _ = n.parameters !== void 0 ? n.parameters[f.input] : f.input, x = n.parameters !== void 0 ? n.parameters[f.output] : f.output;
|
|
3033
|
+
m.node !== void 0 && (o.push(this.getDependency("node", y)), a.push(this.getDependency("accessor", _)), l.push(this.getDependency("accessor", x)), h.push(f), u.push(m));
|
|
3034
|
+
}
|
|
3035
|
+
return Promise.all([
|
|
3036
|
+
Promise.all(o),
|
|
3037
|
+
Promise.all(a),
|
|
3038
|
+
Promise.all(l),
|
|
3039
|
+
Promise.all(h),
|
|
3040
|
+
Promise.all(u)
|
|
3041
|
+
]).then(function(c) {
|
|
3042
|
+
const d = c[0], p = c[1], f = c[2], m = c[3], y = c[4], _ = [];
|
|
3043
|
+
for (let M = 0, S = d.length; M < S; M++) {
|
|
3044
|
+
const L = d[M], v = p[M], I = f[M], se = m[M], J = y[M];
|
|
3045
|
+
if (L === void 0) continue;
|
|
3046
|
+
L.updateMatrix && L.updateMatrix();
|
|
3047
|
+
const de = s._createAnimationTracks(L, v, I, se, J);
|
|
3048
|
+
if (de)
|
|
3049
|
+
for (let W = 0; W < de.length; W++)
|
|
3050
|
+
_.push(de[W]);
|
|
3051
|
+
}
|
|
3052
|
+
const x = new is(i, void 0, _);
|
|
3053
|
+
return te(x, n), x;
|
|
3054
|
+
});
|
|
3055
|
+
}
|
|
3056
|
+
createNodeMesh(e) {
|
|
3057
|
+
const t = this.json, s = this, n = t.nodes[e];
|
|
3058
|
+
return n.mesh === void 0 ? null : s.getDependency("mesh", n.mesh).then(function(i) {
|
|
3059
|
+
const o = s._getNodeRef(s.meshCache, n.mesh, i);
|
|
3060
|
+
return n.weights !== void 0 && o.traverse(function(a) {
|
|
3061
|
+
if (a.isMesh)
|
|
3062
|
+
for (let l = 0, h = n.weights.length; l < h; l++)
|
|
3063
|
+
a.morphTargetInfluences[l] = n.weights[l];
|
|
3064
|
+
}), o;
|
|
3065
|
+
});
|
|
3066
|
+
}
|
|
3067
|
+
/**
|
|
3068
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
|
|
3069
|
+
*
|
|
3070
|
+
* @private
|
|
3071
|
+
* @param {number} nodeIndex
|
|
3072
|
+
* @return {Promise<Object3D>}
|
|
3073
|
+
*/
|
|
3074
|
+
loadNode(e) {
|
|
3075
|
+
const t = this.json, s = this, n = t.nodes[e], i = s._loadNodeShallow(e), o = [], a = n.children || [];
|
|
3076
|
+
for (let h = 0, u = a.length; h < u; h++)
|
|
3077
|
+
o.push(s.getDependency("node", a[h]));
|
|
3078
|
+
const l = n.skin === void 0 ? Promise.resolve(null) : s.getDependency("skin", n.skin);
|
|
3079
|
+
return Promise.all([
|
|
3080
|
+
i,
|
|
3081
|
+
Promise.all(o),
|
|
3082
|
+
l
|
|
3083
|
+
]).then(function(h) {
|
|
3084
|
+
const u = h[0], c = h[1], d = h[2];
|
|
3085
|
+
d !== null && u.traverse(function(p) {
|
|
3086
|
+
p.isSkinnedMesh && p.bind(d, Hi);
|
|
3087
|
+
});
|
|
3088
|
+
for (let p = 0, f = c.length; p < f; p++)
|
|
3089
|
+
u.add(c[p]);
|
|
3090
|
+
if (u.userData.pivot !== void 0 && c.length > 0) {
|
|
3091
|
+
const p = u.userData.pivot, f = c[0];
|
|
3092
|
+
u.pivot = new E().fromArray(p), u.position.x -= p[0], u.position.y -= p[1], u.position.z -= p[2], f.position.set(0, 0, 0), delete u.userData.pivot;
|
|
3093
|
+
}
|
|
3094
|
+
return u;
|
|
3095
|
+
});
|
|
3096
|
+
}
|
|
3097
|
+
// ._loadNodeShallow() parses a single node.
|
|
3098
|
+
// skin and child nodes are created and added in .loadNode() (no '_' prefix).
|
|
3099
|
+
_loadNodeShallow(e) {
|
|
3100
|
+
const t = this.json, s = this.extensions, n = this;
|
|
3101
|
+
if (this.nodeCache[e] !== void 0)
|
|
3102
|
+
return this.nodeCache[e];
|
|
3103
|
+
const i = t.nodes[e], o = i.name ? n.createUniqueName(i.name) : "", a = [], l = n._invokeOne(function(h) {
|
|
3104
|
+
return h.createNodeMesh && h.createNodeMesh(e);
|
|
3105
|
+
});
|
|
3106
|
+
return l && a.push(l), i.camera !== void 0 && a.push(n.getDependency("camera", i.camera).then(function(h) {
|
|
3107
|
+
return n._getNodeRef(n.cameraCache, i.camera, h);
|
|
3108
|
+
})), n._invokeAll(function(h) {
|
|
3109
|
+
return h.createNodeAttachment && h.createNodeAttachment(e);
|
|
3110
|
+
}).forEach(function(h) {
|
|
3111
|
+
a.push(h);
|
|
3112
|
+
}), this.nodeCache[e] = Promise.all(a).then(function(h) {
|
|
3113
|
+
let u;
|
|
3114
|
+
if (i.isBone === !0 ? u = new os() : h.length > 1 ? u = new $e() : h.length === 1 ? u = h[0] : u = new je(), u !== h[0])
|
|
3115
|
+
for (let c = 0, d = h.length; c < d; c++)
|
|
3116
|
+
u.add(h[c]);
|
|
3117
|
+
if (i.name && (u.userData.name = i.name, u.name = o), te(u, i), i.extensions && me(s, u, i), i.matrix !== void 0) {
|
|
3118
|
+
const c = new Me();
|
|
3119
|
+
c.fromArray(i.matrix), u.applyMatrix4(c);
|
|
3120
|
+
} else
|
|
3121
|
+
i.translation !== void 0 && u.position.fromArray(i.translation), i.rotation !== void 0 && u.quaternion.fromArray(i.rotation), i.scale !== void 0 && u.scale.fromArray(i.scale);
|
|
3122
|
+
if (!n.associations.has(u))
|
|
3123
|
+
n.associations.set(u, {});
|
|
3124
|
+
else if (i.mesh !== void 0 && n.meshCache.refs[i.mesh] > 1) {
|
|
3125
|
+
const c = n.associations.get(u);
|
|
3126
|
+
n.associations.set(u, { ...c });
|
|
3127
|
+
}
|
|
3128
|
+
return n.associations.get(u).nodes = e, u;
|
|
3129
|
+
}), this.nodeCache[e];
|
|
3130
|
+
}
|
|
3131
|
+
/**
|
|
3132
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
|
|
3133
|
+
*
|
|
3134
|
+
* @private
|
|
3135
|
+
* @param {number} sceneIndex
|
|
3136
|
+
* @return {Promise<Group>}
|
|
3137
|
+
*/
|
|
3138
|
+
loadScene(e) {
|
|
3139
|
+
const t = this.extensions, s = this.json.scenes[e], n = this, i = new $e();
|
|
3140
|
+
s.name && (i.name = n.createUniqueName(s.name)), te(i, s), s.extensions && me(t, i, s);
|
|
3141
|
+
const o = s.nodes || [], a = [];
|
|
3142
|
+
for (let l = 0, h = o.length; l < h; l++)
|
|
3143
|
+
a.push(n.getDependency("node", o[l]));
|
|
3144
|
+
return Promise.all(a).then(function(l) {
|
|
3145
|
+
for (let u = 0, c = l.length; u < c; u++) {
|
|
3146
|
+
const d = l[u];
|
|
3147
|
+
d.parent !== null ? i.add(ri(d)) : i.add(d);
|
|
3148
|
+
}
|
|
3149
|
+
const h = (u) => {
|
|
3150
|
+
const c = /* @__PURE__ */ new Map();
|
|
3151
|
+
for (const [d, p] of n.associations)
|
|
3152
|
+
(d instanceof Ne || d instanceof At) && c.set(d, p);
|
|
3153
|
+
return u.traverse((d) => {
|
|
3154
|
+
const p = n.associations.get(d);
|
|
3155
|
+
p != null && c.set(d, p);
|
|
3156
|
+
}), c;
|
|
3157
|
+
};
|
|
3158
|
+
return n.associations = h(i), i;
|
|
3159
|
+
});
|
|
3160
|
+
}
|
|
3161
|
+
_createAnimationTracks(e, t, s, n, i) {
|
|
3162
|
+
const o = [], a = e.name ? e.name : e.uuid, l = [];
|
|
3163
|
+
function h(p) {
|
|
3164
|
+
p.morphTargetInfluences && l.push(p.name ? p.name : p.uuid);
|
|
3165
|
+
}
|
|
3166
|
+
ce[i.path] === ce.weights ? (h(e), e.isGroup && e.children.forEach(h)) : l.push(a);
|
|
3167
|
+
let u;
|
|
3168
|
+
switch (ce[i.path]) {
|
|
3169
|
+
case ce.weights:
|
|
3170
|
+
u = Lt;
|
|
3171
|
+
break;
|
|
3172
|
+
case ce.rotation:
|
|
3173
|
+
u = It;
|
|
3174
|
+
break;
|
|
3175
|
+
case ce.translation:
|
|
3176
|
+
case ce.scale:
|
|
3177
|
+
u = Pt;
|
|
3178
|
+
break;
|
|
3179
|
+
default:
|
|
3180
|
+
switch (s.itemSize) {
|
|
3181
|
+
case 1:
|
|
3182
|
+
u = Lt;
|
|
3183
|
+
break;
|
|
3184
|
+
case 2:
|
|
3185
|
+
case 3:
|
|
3186
|
+
default:
|
|
3187
|
+
u = Pt;
|
|
3188
|
+
break;
|
|
3189
|
+
}
|
|
3190
|
+
break;
|
|
3191
|
+
}
|
|
3192
|
+
const c = n.interpolation !== void 0 ? Oi[n.interpolation] : un, d = this._getArrayFromAccessor(s);
|
|
3193
|
+
for (let p = 0, f = l.length; p < f; p++) {
|
|
3194
|
+
const m = new u(
|
|
3195
|
+
l[p] + "." + ce[i.path],
|
|
3196
|
+
t.array,
|
|
3197
|
+
d,
|
|
3198
|
+
c
|
|
3199
|
+
);
|
|
3200
|
+
n.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(m), o.push(m);
|
|
3201
|
+
}
|
|
3202
|
+
return o;
|
|
3203
|
+
}
|
|
3204
|
+
_getArrayFromAccessor(e) {
|
|
3205
|
+
let t = e.array;
|
|
3206
|
+
if (e.normalized) {
|
|
3207
|
+
const s = wt(t.constructor), n = new Float32Array(t.length);
|
|
3208
|
+
for (let i = 0, o = t.length; i < o; i++)
|
|
3209
|
+
n[i] = t[i] * s;
|
|
3210
|
+
t = n;
|
|
3211
|
+
}
|
|
3212
|
+
return t;
|
|
3213
|
+
}
|
|
3214
|
+
_createCubicSplineTrackInterpolant(e) {
|
|
3215
|
+
e.createInterpolant = function(s) {
|
|
3216
|
+
const n = this instanceof It ? Ii : yn;
|
|
3217
|
+
return new n(this.times, this.values, this.getValueSize() / 3, s);
|
|
3218
|
+
}, e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0;
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
function Ui(r, e, t) {
|
|
3222
|
+
const s = e.attributes, n = new cs();
|
|
3223
|
+
if (s.POSITION !== void 0) {
|
|
3224
|
+
const a = t.json.accessors[s.POSITION], l = a.min, h = a.max;
|
|
3225
|
+
if (l !== void 0 && h !== void 0) {
|
|
3226
|
+
if (n.set(
|
|
3227
|
+
new E(l[0], l[1], l[2]),
|
|
3228
|
+
new E(h[0], h[1], h[2])
|
|
3229
|
+
), a.normalized) {
|
|
3230
|
+
const u = wt(Ee[a.componentType]);
|
|
3231
|
+
n.min.multiplyScalar(u), n.max.multiplyScalar(u);
|
|
3232
|
+
}
|
|
3233
|
+
} else {
|
|
3234
|
+
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
|
|
3235
|
+
return;
|
|
3236
|
+
}
|
|
3237
|
+
} else
|
|
3238
|
+
return;
|
|
3239
|
+
const i = e.targets;
|
|
3240
|
+
if (i !== void 0) {
|
|
3241
|
+
const a = new E(), l = new E();
|
|
3242
|
+
for (let h = 0, u = i.length; h < u; h++) {
|
|
3243
|
+
const c = i[h];
|
|
3244
|
+
if (c.POSITION !== void 0) {
|
|
3245
|
+
const d = t.json.accessors[c.POSITION], p = d.min, f = d.max;
|
|
3246
|
+
if (p !== void 0 && f !== void 0) {
|
|
3247
|
+
if (l.setX(Math.max(Math.abs(p[0]), Math.abs(f[0]))), l.setY(Math.max(Math.abs(p[1]), Math.abs(f[1]))), l.setZ(Math.max(Math.abs(p[2]), Math.abs(f[2]))), d.normalized) {
|
|
3248
|
+
const m = wt(Ee[d.componentType]);
|
|
3249
|
+
l.multiplyScalar(m);
|
|
3250
|
+
}
|
|
3251
|
+
a.max(l);
|
|
3252
|
+
} else
|
|
3253
|
+
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
n.expandByVector(a);
|
|
3257
|
+
}
|
|
3258
|
+
r.boundingBox = n;
|
|
3259
|
+
const o = new hs();
|
|
3260
|
+
n.getCenter(o.center), o.radius = n.min.distanceTo(n.max) / 2, r.boundingSphere = o;
|
|
3261
|
+
}
|
|
3262
|
+
function Wt(r, e, t) {
|
|
3263
|
+
const s = e.attributes, n = [];
|
|
3264
|
+
function i(o, a) {
|
|
3265
|
+
return t.getDependency("accessor", o).then(function(l) {
|
|
3266
|
+
r.setAttribute(a, l);
|
|
3267
|
+
});
|
|
3268
|
+
}
|
|
3269
|
+
for (const o in s) {
|
|
3270
|
+
const a = bt[o] || o.toLowerCase();
|
|
3271
|
+
a in r.attributes || n.push(i(s[o], a));
|
|
3272
|
+
}
|
|
3273
|
+
if (e.indices !== void 0 && !r.index) {
|
|
3274
|
+
const o = t.getDependency("accessor", e.indices).then(function(a) {
|
|
3275
|
+
r.setIndex(a);
|
|
3276
|
+
});
|
|
3277
|
+
n.push(o);
|
|
3278
|
+
}
|
|
3279
|
+
return Ot.workingColorSpace !== ae && "COLOR_0" in s && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Ot.workingColorSpace}" not supported.`), te(r, e), Ui(r, e, t), Promise.all(n).then(function() {
|
|
3280
|
+
return e.targets !== void 0 ? Di(r, e.targets, t) : r;
|
|
3281
|
+
});
|
|
3282
|
+
}
|
|
3283
|
+
function zi() {
|
|
3284
|
+
const r = new N.BoxGeometry(1, 1, 1), e = new N.MeshStandardMaterial({ color: 43775 }), t = new N.Mesh(r, e);
|
|
3285
|
+
return t.position.y = 0.5, t.userData.isMovable = !0, t.name = "正方体", nt(t, !0), t;
|
|
3286
|
+
}
|
|
3287
|
+
function Gi() {
|
|
3288
|
+
const r = new N.SphereGeometry(0.6, 32, 32), e = new N.MeshStandardMaterial({ color: 16746496 }), t = new N.Mesh(r, e);
|
|
3289
|
+
return t.position.y = 0.6, t.userData.isMovable = !0, t.name = "球体", nt(t, !0), t;
|
|
3290
|
+
}
|
|
3291
|
+
function Xi(r) {
|
|
3292
|
+
return new Promise((e, t) => {
|
|
3293
|
+
var o;
|
|
3294
|
+
const s = (o = r.name.split(".").pop()) == null ? void 0 : o.toLowerCase(), n = URL.createObjectURL(r);
|
|
3295
|
+
let i;
|
|
3296
|
+
if (s === "obj") i = new oi();
|
|
3297
|
+
else if (s === "gltf" || s === "glb") i = new ai();
|
|
3298
|
+
else {
|
|
3299
|
+
t(new Error("不支持的文件格式,请使用 .obj, .gltf, .glb"));
|
|
3300
|
+
return;
|
|
3301
|
+
}
|
|
3302
|
+
i.load(
|
|
3303
|
+
n,
|
|
3304
|
+
(a) => {
|
|
3305
|
+
const l = s === "gltf" || s === "glb" ? a.scene : a;
|
|
3306
|
+
l.traverse((c) => {
|
|
3307
|
+
var d;
|
|
3308
|
+
c.userData.isMovable = !0, c.name || (c.name = c.type), c.type === "Mesh" && (c.frustumCulled = !0, (d = c.geometry) == null || d.computeVertexNormals());
|
|
3309
|
+
});
|
|
3310
|
+
const u = new N.Box3().setFromObject(l).getCenter(new N.Vector3());
|
|
3311
|
+
l.position.sub(u), nt(l, !0), e(l);
|
|
3312
|
+
},
|
|
3313
|
+
void 0,
|
|
3314
|
+
(a) => t(a)
|
|
3315
|
+
);
|
|
3316
|
+
});
|
|
3317
|
+
}
|
|
3318
|
+
function Yi(r) {
|
|
3319
|
+
switch (r) {
|
|
3320
|
+
case "box":
|
|
3321
|
+
zi();
|
|
3322
|
+
break;
|
|
3323
|
+
case "sphere":
|
|
3324
|
+
Gi();
|
|
3325
|
+
break;
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
const Bi = {
|
|
3329
|
+
key: 1,
|
|
3330
|
+
class: "toggle-placeholder"
|
|
3331
|
+
}, Ki = { class: "tree-icon" }, Vi = { class: "tree-name" }, Zi = {
|
|
3332
|
+
key: 0,
|
|
3333
|
+
class: "tree-children"
|
|
3334
|
+
}, Qi = /* @__PURE__ */ Fe({
|
|
3335
|
+
__name: "TreeItem",
|
|
3336
|
+
props: {
|
|
3337
|
+
node: {},
|
|
3338
|
+
selectedObject: {},
|
|
3339
|
+
version: {}
|
|
3340
|
+
},
|
|
3341
|
+
emits: ["select", "delete"],
|
|
3342
|
+
setup(r, { emit: e }) {
|
|
3343
|
+
const t = r, s = e, n = K(null), { expandedSet: i, toggleExpand: o } = bn("treeExpand"), a = Be(() => i.value.has(t.node.uuid)), l = Be(() => (t.version, t.node.children.some((m) => m.userData.isMovable === !0))), h = Be(() => (t.version, t.node.children.filter(
|
|
3344
|
+
(m) => m.userData.isMovable === !0
|
|
3345
|
+
))), u = Be(
|
|
3346
|
+
() => {
|
|
3347
|
+
var m;
|
|
3348
|
+
return ((m = t.selectedObject) == null ? void 0 : m.uuid) === t.node.uuid;
|
|
3349
|
+
}
|
|
3350
|
+
);
|
|
3351
|
+
wn(
|
|
3352
|
+
() => {
|
|
3353
|
+
u.value && n.value && n.value.scrollIntoView({
|
|
3354
|
+
block: "nearest",
|
|
3355
|
+
// 仅当元素不在可视区域时才滚动
|
|
3356
|
+
behavior: "smooth"
|
|
3357
|
+
// 平滑滚动
|
|
3358
|
+
});
|
|
3359
|
+
},
|
|
3360
|
+
{ flush: "post" }
|
|
3361
|
+
);
|
|
3362
|
+
const c = (m) => {
|
|
3363
|
+
m.stopPropagation(), s("select", t.node);
|
|
3364
|
+
}, d = (m) => {
|
|
3365
|
+
m.stopPropagation(), s("delete", t.node);
|
|
3366
|
+
}, p = (m) => m.type === "Mesh" || m.type === "Sprite" ? "🟦" : m.type === "Light" ? "💡" : "📦", f = (m) => m.name || `${m.type} (${m.id})`;
|
|
3367
|
+
return (m, y) => {
|
|
3368
|
+
const _ = Tn("TreeItem", !0);
|
|
3369
|
+
return Y(), q("div", {
|
|
3370
|
+
class: "tree-node",
|
|
3371
|
+
ref_key: "nodeRef",
|
|
3372
|
+
ref: n
|
|
3373
|
+
}, [
|
|
3374
|
+
g("div", {
|
|
3375
|
+
class: xn(["tree-item", { selected: u.value }]),
|
|
3376
|
+
onClick: c
|
|
3377
|
+
}, [
|
|
3378
|
+
l.value ? (Y(), q("span", {
|
|
3379
|
+
key: 0,
|
|
3380
|
+
class: "toggle-icon",
|
|
3381
|
+
onClick: y[0] || (y[0] = vt((x) => En(o)(r.node.uuid), ["stop"]))
|
|
3382
|
+
}, st(a.value ? "▼" : "▶"), 1)) : (Y(), q("span", Bi)),
|
|
3383
|
+
g("span", Ki, st(p(r.node)), 1),
|
|
3384
|
+
g("span", Vi, st(f(r.node)), 1),
|
|
3385
|
+
g("button", {
|
|
3386
|
+
class: "tree-delete",
|
|
3387
|
+
onClick: vt(d, ["stop"])
|
|
3388
|
+
}, "×")
|
|
3389
|
+
], 2),
|
|
3390
|
+
a.value && l.value ? (Y(), q("div", Zi, [
|
|
3391
|
+
(Y(!0), q($t, null, Jt(h.value, (x) => (Y(), en(_, {
|
|
3392
|
+
key: x.uuid,
|
|
3393
|
+
node: x,
|
|
3394
|
+
"selected-object": r.selectedObject,
|
|
3395
|
+
version: r.version,
|
|
3396
|
+
onSelect: y[1] || (y[1] = (M) => s("select", M)),
|
|
3397
|
+
onDelete: y[2] || (y[2] = (M) => s("delete", M))
|
|
3398
|
+
}, null, 8, ["node", "selected-object", "version"]))), 128))
|
|
3399
|
+
])) : tn("", !0)
|
|
3400
|
+
], 512);
|
|
3401
|
+
};
|
|
3402
|
+
}
|
|
3403
|
+
}), Ue = (r, e) => {
|
|
3404
|
+
const t = r.__vccOpts || r;
|
|
3405
|
+
for (const [s, n] of e)
|
|
3406
|
+
t[s] = n;
|
|
3407
|
+
return t;
|
|
3408
|
+
}, qi = /* @__PURE__ */ Ue(Qi, [["__scopeId", "data-v-5ad9c842"]]);
|
|
3409
|
+
function Wi(r) {
|
|
3410
|
+
const e = K(/* @__PURE__ */ new Set()), t = (n) => {
|
|
3411
|
+
const i = new Set(e.value);
|
|
3412
|
+
i.has(n) ? i.delete(n) : i.add(n), e.value = i;
|
|
3413
|
+
}, s = (n) => {
|
|
3414
|
+
if (!n) return;
|
|
3415
|
+
const i = new Set(e.value);
|
|
3416
|
+
let o = n.parent;
|
|
3417
|
+
for (; o && o.type !== "Scene"; )
|
|
3418
|
+
i.add(o.uuid), o = o.parent;
|
|
3419
|
+
e.value = i;
|
|
3420
|
+
};
|
|
3421
|
+
return Mn(
|
|
3422
|
+
r,
|
|
3423
|
+
(n) => {
|
|
3424
|
+
n && s(n);
|
|
3425
|
+
},
|
|
3426
|
+
{ immediate: !0 }
|
|
3427
|
+
), { expandedSet: e, toggleExpand: t };
|
|
3428
|
+
}
|
|
3429
|
+
const $i = {
|
|
3430
|
+
key: 0,
|
|
3431
|
+
class: "property-panel"
|
|
3432
|
+
}, Ji = { class: "property-group tree-group" }, eo = { class: "tree-container" }, to = {
|
|
3433
|
+
key: 0,
|
|
3434
|
+
class: "tree-empty"
|
|
3435
|
+
}, no = { class: "property-group" }, so = { class: "row" }, io = { class: "property-group" }, oo = { class: "row" }, ro = { class: "property-group" }, ao = { class: "row" }, lo = {
|
|
3436
|
+
key: 1,
|
|
3437
|
+
class: "property-panel empty"
|
|
3438
|
+
}, co = /* @__PURE__ */ Fe({
|
|
3439
|
+
__name: "PropertyPanel",
|
|
3440
|
+
props: {
|
|
3441
|
+
transform: {},
|
|
3442
|
+
treeData: {},
|
|
3443
|
+
selectedObject: {}
|
|
3444
|
+
},
|
|
3445
|
+
emits: ["propertyChange", "treeSelect", "treeDelete"],
|
|
3446
|
+
setup(r, { emit: e }) {
|
|
3447
|
+
const t = r, s = e, n = () => s("propertyChange"), i = K(0), o = Sn(t, "selectedObject"), { expandedSet: a, toggleExpand: l } = Wi(o);
|
|
3448
|
+
vn("treeExpand", { expandedSet: a, toggleExpand: l });
|
|
3449
|
+
const h = (u) => {
|
|
3450
|
+
i.value++, s("treeDelete", u);
|
|
3451
|
+
};
|
|
3452
|
+
return (u, c) => r.transform ? (Y(), q("div", $i, [
|
|
3453
|
+
c[23] || (c[23] = g("h3", null, "属性面板", -1)),
|
|
3454
|
+
g("div", Ji, [
|
|
3455
|
+
c[10] || (c[10] = g("label", null, "场景物体", -1)),
|
|
3456
|
+
g("div", eo, [
|
|
3457
|
+
(Y(!0), q($t, null, Jt(r.treeData, (d) => (Y(), en(qi, {
|
|
3458
|
+
key: d.uuid,
|
|
3459
|
+
node: d,
|
|
3460
|
+
"selected-object": r.selectedObject,
|
|
3461
|
+
version: i.value,
|
|
3462
|
+
onSelect: c[0] || (c[0] = (p) => s("treeSelect", p)),
|
|
3463
|
+
onDelete: h
|
|
3464
|
+
}, null, 8, ["node", "selected-object", "version"]))), 128)),
|
|
3465
|
+
r.treeData.length === 0 ? (Y(), q("div", to, "暂无物体")) : tn("", !0)
|
|
3466
|
+
])
|
|
3467
|
+
]),
|
|
3468
|
+
g("div", no, [
|
|
3469
|
+
c[14] || (c[14] = g("label", null, "位置", -1)),
|
|
3470
|
+
g("div", so, [
|
|
3471
|
+
c[11] || (c[11] = g("span", null, "X:", -1)),
|
|
3472
|
+
H(g("input", {
|
|
3473
|
+
type: "number",
|
|
3474
|
+
"onUpdate:modelValue": c[1] || (c[1] = (d) => r.transform.position.x = d),
|
|
3475
|
+
step: "0.01",
|
|
3476
|
+
onInput: n
|
|
3477
|
+
}, null, 544), [
|
|
3478
|
+
[
|
|
3479
|
+
oe,
|
|
3480
|
+
r.transform.position.x,
|
|
3481
|
+
void 0,
|
|
3482
|
+
{ number: !0 }
|
|
3483
|
+
]
|
|
3484
|
+
]),
|
|
3485
|
+
c[12] || (c[12] = g("span", null, "Y:", -1)),
|
|
3486
|
+
H(g("input", {
|
|
3487
|
+
type: "number",
|
|
3488
|
+
"onUpdate:modelValue": c[2] || (c[2] = (d) => r.transform.position.y = d),
|
|
3489
|
+
step: "0.01",
|
|
3490
|
+
onInput: n
|
|
3491
|
+
}, null, 544), [
|
|
3492
|
+
[
|
|
3493
|
+
oe,
|
|
3494
|
+
r.transform.position.y,
|
|
3495
|
+
void 0,
|
|
3496
|
+
{ number: !0 }
|
|
3497
|
+
]
|
|
3498
|
+
]),
|
|
3499
|
+
c[13] || (c[13] = g("span", null, "Z:", -1)),
|
|
3500
|
+
H(g("input", {
|
|
3501
|
+
type: "number",
|
|
3502
|
+
"onUpdate:modelValue": c[3] || (c[3] = (d) => r.transform.position.z = d),
|
|
3503
|
+
step: "0.01",
|
|
3504
|
+
onInput: n
|
|
3505
|
+
}, null, 544), [
|
|
3506
|
+
[
|
|
3507
|
+
oe,
|
|
3508
|
+
r.transform.position.z,
|
|
3509
|
+
void 0,
|
|
3510
|
+
{ number: !0 }
|
|
3511
|
+
]
|
|
3512
|
+
])
|
|
3513
|
+
])
|
|
3514
|
+
]),
|
|
3515
|
+
g("div", io, [
|
|
3516
|
+
c[18] || (c[18] = g("label", null, "旋转 (弧度)", -1)),
|
|
3517
|
+
g("div", oo, [
|
|
3518
|
+
c[15] || (c[15] = g("span", null, "X:", -1)),
|
|
3519
|
+
H(g("input", {
|
|
3520
|
+
type: "number",
|
|
3521
|
+
"onUpdate:modelValue": c[4] || (c[4] = (d) => r.transform.rotation.x = d),
|
|
3522
|
+
step: "0.01",
|
|
3523
|
+
onInput: n
|
|
3524
|
+
}, null, 544), [
|
|
3525
|
+
[
|
|
3526
|
+
oe,
|
|
3527
|
+
r.transform.rotation.x,
|
|
3528
|
+
void 0,
|
|
3529
|
+
{ number: !0 }
|
|
3530
|
+
]
|
|
3531
|
+
]),
|
|
3532
|
+
c[16] || (c[16] = g("span", null, "Y:", -1)),
|
|
3533
|
+
H(g("input", {
|
|
3534
|
+
type: "number",
|
|
3535
|
+
"onUpdate:modelValue": c[5] || (c[5] = (d) => r.transform.rotation.y = d),
|
|
3536
|
+
step: "0.01",
|
|
3537
|
+
onInput: n
|
|
3538
|
+
}, null, 544), [
|
|
3539
|
+
[
|
|
3540
|
+
oe,
|
|
3541
|
+
r.transform.rotation.y,
|
|
3542
|
+
void 0,
|
|
3543
|
+
{ number: !0 }
|
|
3544
|
+
]
|
|
3545
|
+
]),
|
|
3546
|
+
c[17] || (c[17] = g("span", null, "Z:", -1)),
|
|
3547
|
+
H(g("input", {
|
|
3548
|
+
type: "number",
|
|
3549
|
+
"onUpdate:modelValue": c[6] || (c[6] = (d) => r.transform.rotation.z = d),
|
|
3550
|
+
step: "0.01",
|
|
3551
|
+
onInput: n
|
|
3552
|
+
}, null, 544), [
|
|
3553
|
+
[
|
|
3554
|
+
oe,
|
|
3555
|
+
r.transform.rotation.z,
|
|
3556
|
+
void 0,
|
|
3557
|
+
{ number: !0 }
|
|
3558
|
+
]
|
|
3559
|
+
])
|
|
3560
|
+
])
|
|
3561
|
+
]),
|
|
3562
|
+
g("div", ro, [
|
|
3563
|
+
c[22] || (c[22] = g("label", null, "缩放", -1)),
|
|
3564
|
+
g("div", ao, [
|
|
3565
|
+
c[19] || (c[19] = g("span", null, "X:", -1)),
|
|
3566
|
+
H(g("input", {
|
|
3567
|
+
type: "number",
|
|
3568
|
+
"onUpdate:modelValue": c[7] || (c[7] = (d) => r.transform.scale.x = d),
|
|
3569
|
+
step: "0.01",
|
|
3570
|
+
onInput: n
|
|
3571
|
+
}, null, 544), [
|
|
3572
|
+
[
|
|
3573
|
+
oe,
|
|
3574
|
+
r.transform.scale.x,
|
|
3575
|
+
void 0,
|
|
3576
|
+
{ number: !0 }
|
|
3577
|
+
]
|
|
3578
|
+
]),
|
|
3579
|
+
c[20] || (c[20] = g("span", null, "Y:", -1)),
|
|
3580
|
+
H(g("input", {
|
|
3581
|
+
type: "number",
|
|
3582
|
+
"onUpdate:modelValue": c[8] || (c[8] = (d) => r.transform.scale.y = d),
|
|
3583
|
+
step: "0.01",
|
|
3584
|
+
onInput: n
|
|
3585
|
+
}, null, 544), [
|
|
3586
|
+
[
|
|
3587
|
+
oe,
|
|
3588
|
+
r.transform.scale.y,
|
|
3589
|
+
void 0,
|
|
3590
|
+
{ number: !0 }
|
|
3591
|
+
]
|
|
3592
|
+
]),
|
|
3593
|
+
c[21] || (c[21] = g("span", null, "Z:", -1)),
|
|
3594
|
+
H(g("input", {
|
|
3595
|
+
type: "number",
|
|
3596
|
+
"onUpdate:modelValue": c[9] || (c[9] = (d) => r.transform.scale.z = d),
|
|
3597
|
+
step: "0.01",
|
|
3598
|
+
onInput: n
|
|
3599
|
+
}, null, 544), [
|
|
3600
|
+
[
|
|
3601
|
+
oe,
|
|
3602
|
+
r.transform.scale.z,
|
|
3603
|
+
void 0,
|
|
3604
|
+
{ number: !0 }
|
|
3605
|
+
]
|
|
3606
|
+
])
|
|
3607
|
+
])
|
|
3608
|
+
])
|
|
3609
|
+
])) : (Y(), q("div", lo, [...c[24] || (c[24] = [
|
|
3610
|
+
g("p", null, "未选中任何模型", -1)
|
|
3611
|
+
])]));
|
|
3612
|
+
}
|
|
3613
|
+
}), ho = /* @__PURE__ */ Ue(co, [["__scopeId", "data-v-94ef5fd1"]]), uo = { class: "top-bar" }, po = { class: "left-section" }, fo = { class: "dropdown-menu" }, mo = { class: "dropdown-menu sub-menu" }, go = { class: "dropdown-menu" }, yo = { class: "dropdown-menu sub-menu" }, _o = { class: "dropdown-menu" }, bo = { class: "dropdown-menu" }, wo = { class: "dropdown-menu" }, To = /* @__PURE__ */ Fe({
|
|
3614
|
+
__name: "TopBar",
|
|
3615
|
+
emits: ["addModel", "importModel"],
|
|
3616
|
+
setup(r, { emit: e }) {
|
|
3617
|
+
const t = K(!1), s = K(!1), n = K(!1), i = K(!1), o = K(!1), a = K(!1), l = K(!1), h = e, u = K(null), c = () => {
|
|
3618
|
+
var W;
|
|
3619
|
+
return (W = u.value) == null ? void 0 : W.click();
|
|
3620
|
+
}, d = (W) => {
|
|
3621
|
+
const T = W.target;
|
|
3622
|
+
T.files && T.files.length > 0 && (h("importModel", T.files[0]), T.value = "");
|
|
3623
|
+
}, p = () => console.log("新建项目"), f = () => console.log("保存场景"), m = () => console.log("导出模型"), y = () => console.log("撤销"), _ = () => console.log("重做"), x = () => console.log("复制物体"), M = () => console.log("删除物体"), S = () => console.log("重置相机"), L = () => console.log("切换网格"), v = () => console.log("打开帮助"), I = () => console.log("关于编辑器"), se = () => console.log("打开项目"), J = () => console.log("打开模型"), de = () => console.log("打开场景");
|
|
3624
|
+
return (W, T) => (Y(), q("div", uo, [
|
|
3625
|
+
g("div", po, [
|
|
3626
|
+
g("div", {
|
|
3627
|
+
class: "dropdown-wrapper",
|
|
3628
|
+
onMouseenter: T[2] || (T[2] = (k) => t.value = !0),
|
|
3629
|
+
onMouseleave: T[3] || (T[3] = (k) => t.value = !1)
|
|
3630
|
+
}, [
|
|
3631
|
+
T[17] || (T[17] = g("button", { class: "menu-btn" }, "文件", -1)),
|
|
3632
|
+
H(g("div", fo, [
|
|
3633
|
+
g("div", {
|
|
3634
|
+
class: "menu-item",
|
|
3635
|
+
onClick: p
|
|
3636
|
+
}, "新建"),
|
|
3637
|
+
g("div", {
|
|
3638
|
+
class: "menu-item dropdown-wrapper sub-trigger",
|
|
3639
|
+
onMouseenter: T[0] || (T[0] = (k) => a.value = !0),
|
|
3640
|
+
onMouseleave: T[1] || (T[1] = (k) => a.value = !1)
|
|
3641
|
+
}, [
|
|
3642
|
+
T[16] || (T[16] = g("span", null, "打开", -1)),
|
|
3643
|
+
H(g("div", mo, [
|
|
3644
|
+
g("div", {
|
|
3645
|
+
class: "menu-item",
|
|
3646
|
+
onClick: se
|
|
3647
|
+
}, "打开项目"),
|
|
3648
|
+
g("div", {
|
|
3649
|
+
class: "menu-item",
|
|
3650
|
+
onClick: J
|
|
3651
|
+
}, "打开模型"),
|
|
3652
|
+
g("div", {
|
|
3653
|
+
class: "menu-item",
|
|
3654
|
+
onClick: de
|
|
3655
|
+
}, "打开场景")
|
|
3656
|
+
], 512), [
|
|
3657
|
+
[pe, a.value]
|
|
3658
|
+
])
|
|
3659
|
+
], 32),
|
|
3660
|
+
g("div", {
|
|
3661
|
+
class: "menu-item",
|
|
3662
|
+
onClick: f
|
|
3663
|
+
}, "保存"),
|
|
3664
|
+
g("div", {
|
|
3665
|
+
class: "menu-item",
|
|
3666
|
+
onClick: m
|
|
3667
|
+
}, "导出")
|
|
3668
|
+
], 512), [
|
|
3669
|
+
[pe, t.value]
|
|
3670
|
+
])
|
|
3671
|
+
], 32),
|
|
3672
|
+
g("div", {
|
|
3673
|
+
class: "dropdown-wrapper",
|
|
3674
|
+
onMouseenter: T[8] || (T[8] = (k) => o.value = !0),
|
|
3675
|
+
onMouseleave: T[9] || (T[9] = (k) => o.value = !1)
|
|
3676
|
+
}, [
|
|
3677
|
+
T[19] || (T[19] = g("button", { class: "menu-btn" }, "添加", -1)),
|
|
3678
|
+
H(g("div", go, [
|
|
3679
|
+
g("div", {
|
|
3680
|
+
class: "menu-item",
|
|
3681
|
+
onClick: y
|
|
3682
|
+
}, "组"),
|
|
3683
|
+
g("div", {
|
|
3684
|
+
class: "menu-item dropdown-wrapper sub-trigger",
|
|
3685
|
+
onMouseenter: T[6] || (T[6] = (k) => l.value = !0),
|
|
3686
|
+
onMouseleave: T[7] || (T[7] = (k) => l.value = !1)
|
|
3687
|
+
}, [
|
|
3688
|
+
T[18] || (T[18] = g("span", null, "网格", -1)),
|
|
3689
|
+
H(g("div", yo, [
|
|
3690
|
+
g("div", {
|
|
3691
|
+
class: "menu-item",
|
|
3692
|
+
onClick: T[4] || (T[4] = (k) => h("addModel", "box"))
|
|
3693
|
+
}, " 正方体 "),
|
|
3694
|
+
g("div", {
|
|
3695
|
+
class: "menu-item",
|
|
3696
|
+
onClick: T[5] || (T[5] = (k) => h("addModel", "sphere"))
|
|
3697
|
+
}, " 球体 "),
|
|
3698
|
+
g("div", {
|
|
3699
|
+
class: "menu-item",
|
|
3700
|
+
onClick: c
|
|
3701
|
+
}, "导入")
|
|
3702
|
+
], 512), [
|
|
3703
|
+
[pe, l.value]
|
|
3704
|
+
])
|
|
3705
|
+
], 32),
|
|
3706
|
+
g("div", {
|
|
3707
|
+
class: "menu-item",
|
|
3708
|
+
onClick: x
|
|
3709
|
+
}, "光源"),
|
|
3710
|
+
g("div", {
|
|
3711
|
+
class: "menu-item",
|
|
3712
|
+
onClick: M
|
|
3713
|
+
}, "摄像机")
|
|
3714
|
+
], 512), [
|
|
3715
|
+
[pe, o.value]
|
|
3716
|
+
])
|
|
3717
|
+
], 32),
|
|
3718
|
+
g("div", {
|
|
3719
|
+
class: "dropdown-wrapper",
|
|
3720
|
+
onMouseenter: T[10] || (T[10] = (k) => s.value = !0),
|
|
3721
|
+
onMouseleave: T[11] || (T[11] = (k) => s.value = !1)
|
|
3722
|
+
}, [
|
|
3723
|
+
T[20] || (T[20] = g("button", { class: "menu-btn" }, "编辑", -1)),
|
|
3724
|
+
H(g("div", _o, [
|
|
3725
|
+
g("div", {
|
|
3726
|
+
class: "menu-item",
|
|
3727
|
+
onClick: y
|
|
3728
|
+
}, "撤销"),
|
|
3729
|
+
g("div", {
|
|
3730
|
+
class: "menu-item",
|
|
3731
|
+
onClick: _
|
|
3732
|
+
}, "重做"),
|
|
3733
|
+
g("div", {
|
|
3734
|
+
class: "menu-item",
|
|
3735
|
+
onClick: x
|
|
3736
|
+
}, "复制"),
|
|
3737
|
+
g("div", {
|
|
3738
|
+
class: "menu-item",
|
|
3739
|
+
onClick: M
|
|
3740
|
+
}, "删除")
|
|
3741
|
+
], 512), [
|
|
3742
|
+
[pe, s.value]
|
|
3743
|
+
])
|
|
3744
|
+
], 32),
|
|
3745
|
+
g("div", {
|
|
3746
|
+
class: "dropdown-wrapper",
|
|
3747
|
+
onMouseenter: T[12] || (T[12] = (k) => n.value = !0),
|
|
3748
|
+
onMouseleave: T[13] || (T[13] = (k) => n.value = !1)
|
|
3749
|
+
}, [
|
|
3750
|
+
T[21] || (T[21] = g("button", { class: "menu-btn" }, "视图", -1)),
|
|
3751
|
+
H(g("div", bo, [
|
|
3752
|
+
g("div", {
|
|
3753
|
+
class: "menu-item",
|
|
3754
|
+
onClick: S
|
|
3755
|
+
}, "重置相机"),
|
|
3756
|
+
g("div", {
|
|
3757
|
+
class: "menu-item",
|
|
3758
|
+
onClick: L
|
|
3759
|
+
}, "显示网格")
|
|
3760
|
+
], 512), [
|
|
3761
|
+
[pe, n.value]
|
|
3762
|
+
])
|
|
3763
|
+
], 32),
|
|
3764
|
+
g("div", {
|
|
3765
|
+
class: "dropdown-wrapper",
|
|
3766
|
+
onMouseenter: T[14] || (T[14] = (k) => i.value = !0),
|
|
3767
|
+
onMouseleave: T[15] || (T[15] = (k) => i.value = !1)
|
|
3768
|
+
}, [
|
|
3769
|
+
T[22] || (T[22] = g("button", { class: "menu-btn" }, "帮助", -1)),
|
|
3770
|
+
H(g("div", wo, [
|
|
3771
|
+
g("div", {
|
|
3772
|
+
class: "menu-item",
|
|
3773
|
+
onClick: v
|
|
3774
|
+
}, "使用帮助"),
|
|
3775
|
+
g("div", {
|
|
3776
|
+
class: "menu-item",
|
|
3777
|
+
onClick: I
|
|
3778
|
+
}, "关于")
|
|
3779
|
+
], 512), [
|
|
3780
|
+
[pe, i.value]
|
|
3781
|
+
])
|
|
3782
|
+
], 32)
|
|
3783
|
+
]),
|
|
3784
|
+
T[23] || (T[23] = g("div", { class: "right-section" }, [
|
|
3785
|
+
g("span", { class: "app-title" }, "3D 模型编辑器")
|
|
3786
|
+
], -1)),
|
|
3787
|
+
g("input", {
|
|
3788
|
+
type: "file",
|
|
3789
|
+
ref_key: "fileInput",
|
|
3790
|
+
ref: u,
|
|
3791
|
+
accept: ".obj,.gltf,.glb",
|
|
3792
|
+
style: { display: "none" },
|
|
3793
|
+
onChange: d
|
|
3794
|
+
}, null, 544)
|
|
3795
|
+
]));
|
|
3796
|
+
}
|
|
3797
|
+
}), xo = /* @__PURE__ */ Ue(To, [["__scopeId", "data-v-6bb4762f"]]), Eo = { class: "bottom-bar" }, Mo = /* @__PURE__ */ Fe({
|
|
3798
|
+
__name: "BottomBar",
|
|
3799
|
+
setup(r) {
|
|
3800
|
+
return (e, t) => (Y(), q("div", Eo, [...t[0] || (t[0] = [
|
|
3801
|
+
g("div", { class: "status-left" }, [
|
|
3802
|
+
g("span", null, "就绪")
|
|
3803
|
+
], -1),
|
|
3804
|
+
g("div", { class: "status-right" }, [
|
|
3805
|
+
g("span", null, "顶点: 0 | 面: 0")
|
|
3806
|
+
], -1)
|
|
3807
|
+
])]));
|
|
3808
|
+
}
|
|
3809
|
+
}), So = /* @__PURE__ */ Ue(Mo, [["__scopeId", "data-v-3427bb27"]]), vo = { class: "app-layout" }, Ro = { class: "editor-container" }, Ao = /* @__PURE__ */ Fe({
|
|
3810
|
+
__name: "DrawingBoard",
|
|
3811
|
+
setup(r) {
|
|
3812
|
+
const e = K(null), t = Rn({
|
|
3813
|
+
position: { x: 0, y: 0, z: 0 },
|
|
3814
|
+
rotation: { x: 0, y: 0, z: 0 },
|
|
3815
|
+
scale: { x: 1, y: 1, z: 1 }
|
|
3816
|
+
}), s = (f) => {
|
|
3817
|
+
t.position.x = Number(f.position.x.toFixed(3)), t.position.y = Number(f.position.y.toFixed(3)), t.position.z = Number(f.position.z.toFixed(3)), t.rotation.x = Number(f.rotation.x.toFixed(3)), t.rotation.y = Number(f.rotation.y.toFixed(3)), t.rotation.z = Number(f.rotation.z.toFixed(3)), t.scale.x = Number(f.scale.x.toFixed(3)), t.scale.y = Number(f.scale.y.toFixed(3)), t.scale.z = Number(f.scale.z.toFixed(3));
|
|
3818
|
+
}, n = (f) => {
|
|
3819
|
+
f.position.set(
|
|
3820
|
+
t.position.x,
|
|
3821
|
+
t.position.y,
|
|
3822
|
+
t.position.z
|
|
3823
|
+
), f.rotation.set(
|
|
3824
|
+
t.rotation.x,
|
|
3825
|
+
t.rotation.y,
|
|
3826
|
+
t.rotation.z
|
|
3827
|
+
), f.scale.set(t.scale.x, t.scale.y, t.scale.z);
|
|
3828
|
+
};
|
|
3829
|
+
qs((f) => {
|
|
3830
|
+
e.value = f, f && s(f);
|
|
3831
|
+
}), Ws((f) => {
|
|
3832
|
+
s(f);
|
|
3833
|
+
});
|
|
3834
|
+
const i = () => {
|
|
3835
|
+
e.value && n(e.value);
|
|
3836
|
+
}, o = (f) => Yi(f), a = async (f) => {
|
|
3837
|
+
try {
|
|
3838
|
+
await Xi(f);
|
|
3839
|
+
} catch (m) {
|
|
3840
|
+
console.error("导入失败:", m), alert("导入失败:" + m.message);
|
|
3841
|
+
}
|
|
3842
|
+
}, l = An([]);
|
|
3843
|
+
$s((f) => {
|
|
3844
|
+
l.value = f;
|
|
3845
|
+
});
|
|
3846
|
+
const h = () => {
|
|
3847
|
+
const f = Js();
|
|
3848
|
+
f && (l.value = f);
|
|
3849
|
+
}, u = (f) => Et(f), c = (f) => Ks(f.uuid), d = K(null);
|
|
3850
|
+
return Pn(() => {
|
|
3851
|
+
d.value && Ns(d.value), h();
|
|
3852
|
+
}), (f, m) => (Y(), q("div", vo, [
|
|
3853
|
+
it(xo, {
|
|
3854
|
+
onAddModel: o,
|
|
3855
|
+
onImportModel: a
|
|
3856
|
+
}),
|
|
3857
|
+
g("div", Ro, [
|
|
3858
|
+
g("div", {
|
|
3859
|
+
class: "canvas",
|
|
3860
|
+
ref_key: "containerRef",
|
|
3861
|
+
ref: d
|
|
3862
|
+
}, null, 512),
|
|
3863
|
+
it(ho, {
|
|
3864
|
+
transform: t,
|
|
3865
|
+
"tree-data": l.value,
|
|
3866
|
+
"selected-object": e.value,
|
|
3867
|
+
onPropertyChange: i,
|
|
3868
|
+
onTreeSelect: u,
|
|
3869
|
+
onTreeDelete: c
|
|
3870
|
+
}, null, 8, ["transform", "tree-data", "selected-object"])
|
|
3871
|
+
]),
|
|
3872
|
+
it(So)
|
|
3873
|
+
]));
|
|
3874
|
+
}
|
|
3875
|
+
}), Oo = /* @__PURE__ */ Ue(Ao, [["__scopeId", "data-v-a7595f5b"]]);
|
|
3876
|
+
export {
|
|
3877
|
+
Oo as DrawingBoard
|
|
3878
|
+
};
|
|
3879
|
+
//# sourceMappingURL=three-editor.es.js.map
|