view3d-core 1.0.2 → 1.0.3
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/SerializationPlugin-06oXfKib.js +4964 -0
- package/dist/SerializationPlugin-06oXfKib.js.map +1 -0
- package/dist/SerializationPlugin-C54a1wAp.cjs +4859 -0
- package/dist/SerializationPlugin-C54a1wAp.cjs.map +1 -0
- package/dist/index.cjs +211 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +261 -77
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.cjs +1 -1
- package/dist/plugins/index.js +1 -1
- package/package.json +6 -4
- package/dist/SerializationPlugin-D418fw5V.js +0 -3418
- package/dist/SerializationPlugin-D418fw5V.js.map +0 -1
- package/dist/SerializationPlugin-DJVOx3pd.cjs +0 -3317
- package/dist/SerializationPlugin-DJVOx3pd.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as e from "three";
|
|
2
|
-
import t from "
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { BufferGeometry as t, BufferAttribute as i, Matrix3 as n, Vector3 as r, Vector4 as a, Matrix4 as c } from "three";
|
|
3
|
+
import h from "gsap";
|
|
4
|
+
import { I as l, J as p, a as d, O as g, T as f, L as b, C as y, f as x, E as w, t as E, w as C, K as z } from "./SerializationPlugin-06oXfKib.js";
|
|
5
|
+
import { A, k, u, m, G, M, X, o, q, P, v, S, s, R, $, a3, W, Z, a2, Y, V, N, Q, a0, _, U, a1 } from "./SerializationPlugin-06oXfKib.js";
|
|
6
|
+
class L {
|
|
6
7
|
constructor() {
|
|
7
8
|
this.listeners = /* @__PURE__ */ new Map();
|
|
8
9
|
}
|
|
@@ -60,7 +61,7 @@ class b {
|
|
|
60
61
|
this.removeAllListeners();
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
|
-
class
|
|
64
|
+
class I {
|
|
64
65
|
constructor(t2) {
|
|
65
66
|
this.events = t2, this._envBackground = null, this._environmentEnabled = false, this.envMapChangeCallbacks = [], this.ssrMeshList = [], this.scene = new e.Scene(), this.scene.name = "MainScene";
|
|
66
67
|
}
|
|
@@ -144,10 +145,10 @@ class x {
|
|
|
144
145
|
}), this.clear(), this.envMapChangeCallbacks = [], this.ssrMeshList.length = 0;
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
|
-
const
|
|
148
|
-
class
|
|
148
|
+
const T = { fov: 50, near: 0.1, far: 1e5, position: { x: 10, y: 10, z: 10 } };
|
|
149
|
+
class B {
|
|
149
150
|
constructor(t2, s2, i2) {
|
|
150
|
-
this.container = t2, this.events = s2, this.config = { ...
|
|
151
|
+
this.container = t2, this.events = s2, this.config = { ...T, ...i2 };
|
|
151
152
|
const n2 = t2.clientWidth / t2.clientHeight;
|
|
152
153
|
this.camera = new e.PerspectiveCamera(this.config.fov, n2, this.config.near, this.config.far), this.camera.name = "MainCamera", this.camera.position.set(this.config.position.x, this.config.position.y, this.config.position.z);
|
|
153
154
|
}
|
|
@@ -198,10 +199,10 @@ class E {
|
|
|
198
199
|
dispose() {
|
|
199
200
|
}
|
|
200
201
|
}
|
|
201
|
-
const
|
|
202
|
-
class
|
|
202
|
+
const D = { pixelRatio: "undefined" != typeof window ? Math.min(window.devicePixelRatio, 2) : 1, antialias: true, alpha: true, logarithmicDepthBuffer: true, preserveDrawingBuffer: false, powerPreference: "high-performance", toneMapping: e.NoToneMapping, toneMappingExposure: 1, outputColorSpace: e.SRGBColorSpace, shadowMapEnabled: false, shadowMapType: e.PCFSoftShadowMap };
|
|
203
|
+
class j {
|
|
203
204
|
constructor(t2, s2, i2) {
|
|
204
|
-
this.container = t2, this.events = s2, this.config = { ...
|
|
205
|
+
this.container = t2, this.events = s2, this.config = { ...D, ...i2 }, this.config.pixelRatio = Math.min(this.config.pixelRatio, 2), this.renderer = new e.WebGLRenderer({ antialias: this.config.antialias, alpha: this.config.alpha, logarithmicDepthBuffer: this.config.logarithmicDepthBuffer, preserveDrawingBuffer: this.config.preserveDrawingBuffer, powerPreference: this.config.powerPreference }), this.renderer.setSize(t2.clientWidth, t2.clientHeight), this.renderer.setPixelRatio(this.config.pixelRatio), this.renderer.toneMapping = this.config.toneMapping, this.renderer.toneMappingExposure = this.config.toneMappingExposure, this.renderer.outputColorSpace = this.config.outputColorSpace, this.renderer.shadowMap.enabled = this.config.shadowMapEnabled, this.renderer.shadowMap.type = this.config.shadowMapType, t2.appendChild(this.renderer.domElement);
|
|
205
206
|
}
|
|
206
207
|
get domElement() {
|
|
207
208
|
return this.renderer.domElement;
|
|
@@ -255,8 +256,8 @@ class z {
|
|
|
255
256
|
this.renderer.dispose(), this.renderer.forceContextLoss(), this.renderer.domElement.parentNode && this.renderer.domElement.parentNode.removeChild(this.renderer.domElement);
|
|
256
257
|
}
|
|
257
258
|
}
|
|
258
|
-
const
|
|
259
|
-
class
|
|
259
|
+
const O = { autoResize: true, fps: null, autoStart: true };
|
|
260
|
+
class F {
|
|
260
261
|
constructor(t2) {
|
|
261
262
|
this.animationId = null, this._isRunning = false, this.frameCallbacks = /* @__PURE__ */ new Set(), this.fpsInterval = 0, this.lastFrameTime = 0, this.resizeHandler = null, this.animate = () => {
|
|
262
263
|
if (!this._isRunning) return;
|
|
@@ -274,7 +275,7 @@ class I {
|
|
|
274
275
|
} catch (e4) {
|
|
275
276
|
}
|
|
276
277
|
this.render(), this.events.emit("render:after", { delta: t3, elapsed: s2 });
|
|
277
|
-
}, this.config = { ...
|
|
278
|
+
}, this.config = { ...O, ...t2 }, this.container = t2.container, this.events = new L(), this.clock = new e.Clock(false), this.sceneManager = new I(this.events), this.cameraManager = new B(this.container, this.events, t2.camera), this.sceneManager.scene.add(this.cameraManager.camera), this.rendererManager = new j(this.container, this.events, t2.renderer), void 0 !== this.config.fps && null !== this.config.fps && this.config.fps > 0 && (this.fpsInterval = 1e3 / this.config.fps), this.config.autoResize && this.setupAutoResize(), this.events.emit("engine:ready", void 0), this.config.autoStart && this.start();
|
|
278
279
|
}
|
|
279
280
|
get scene() {
|
|
280
281
|
return this.sceneManager.scene;
|
|
@@ -325,26 +326,206 @@ class I {
|
|
|
325
326
|
this.events.emit("engine:dispose", void 0), this.stop(), this.resizeHandler && (window.removeEventListener("resize", this.resizeHandler), this.resizeHandler = null), this.frameCallbacks.clear(), this.sceneManager.dispose(), this.cameraManager.dispose(), this.rendererManager.dispose(), this.events.dispose();
|
|
326
327
|
}
|
|
327
328
|
}
|
|
328
|
-
|
|
329
|
-
|
|
329
|
+
const H = new r(), K = new r(), J = new r(), ee = new a(), te = new r(), se = new r(), ie = new a(), ne = new a(), re = new c(), ae = new c();
|
|
330
|
+
function oe(e2, t2) {
|
|
331
|
+
if (!e2 && !t2) return;
|
|
332
|
+
const s2 = e2.count === t2.count, i2 = e2.normalized === t2.normalized, n2 = e2.array.constructor === t2.array.constructor, r2 = e2.itemSize === t2.itemSize;
|
|
333
|
+
if (!(s2 && i2 && n2 && r2)) throw new Error();
|
|
334
|
+
}
|
|
335
|
+
function ce(e2, t2 = null) {
|
|
336
|
+
const s2 = e2.array.constructor, n2 = e2.normalized, r2 = e2.itemSize, a4 = null === t2 ? e2.count : t2;
|
|
337
|
+
return new i(new s2(r2 * a4), r2, n2);
|
|
338
|
+
}
|
|
339
|
+
function he(e2, t2, s2 = 0) {
|
|
340
|
+
if (e2.isInterleavedBufferAttribute) {
|
|
341
|
+
const i2 = e2.itemSize;
|
|
342
|
+
for (let n2 = 0, r2 = e2.count; n2 < r2; n2++) {
|
|
343
|
+
const r3 = n2 + s2;
|
|
344
|
+
t2.setX(r3, e2.getX(n2)), i2 >= 2 && t2.setY(r3, e2.getY(n2)), i2 >= 3 && t2.setZ(r3, e2.getZ(n2)), i2 >= 4 && t2.setW(r3, e2.getW(n2));
|
|
345
|
+
}
|
|
346
|
+
} else {
|
|
347
|
+
const i2 = t2.array, n2 = i2.constructor, r2 = i2.BYTES_PER_ELEMENT * e2.itemSize * s2;
|
|
348
|
+
new n2(i2.buffer, r2, e2.array.length).set(e2.array);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
function le(e2, t2, s2) {
|
|
352
|
+
const i2 = e2.elements, n2 = t2.elements;
|
|
353
|
+
for (let e3 = 0, t3 = n2.length; e3 < t3; e3++) i2[e3] += n2[e3] * s2;
|
|
354
|
+
}
|
|
355
|
+
function pe(e2, t2, s2) {
|
|
356
|
+
const i2 = e2.skeleton, n2 = e2.geometry, r2 = i2.bones, a4 = i2.boneInverses;
|
|
357
|
+
ie.fromBufferAttribute(n2.attributes.skinIndex, t2), ne.fromBufferAttribute(n2.attributes.skinWeight, t2), re.elements.fill(0);
|
|
358
|
+
for (let e3 = 0; e3 < 4; e3++) {
|
|
359
|
+
const t3 = ne.getComponent(e3);
|
|
360
|
+
if (0 !== t3) {
|
|
361
|
+
const s3 = ie.getComponent(e3);
|
|
362
|
+
ae.multiplyMatrices(r2[s3].matrixWorld, a4[s3]), le(re, ae, t3);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return re.multiply(e2.bindMatrix).premultiply(e2.bindMatrixInverse), s2.transformDirection(re), s2;
|
|
366
|
+
}
|
|
367
|
+
function me(e2, t2, s2, i2, n2) {
|
|
368
|
+
te.set(0, 0, 0);
|
|
369
|
+
for (let r2 = 0, a4 = e2.length; r2 < a4; r2++) {
|
|
370
|
+
const a5 = t2[r2], o2 = e2[r2];
|
|
371
|
+
0 !== a5 && (se.fromBufferAttribute(o2, i2), s2 ? te.addScaledVector(se, a5) : te.addScaledVector(se.sub(n2), a5));
|
|
372
|
+
}
|
|
373
|
+
n2.add(te);
|
|
374
|
+
}
|
|
375
|
+
class de {
|
|
376
|
+
constructor(e2) {
|
|
377
|
+
this.matrixWorld = new c(), this.geometryHash = null, this.boneMatrices = null, this.primitiveCount = -1, this.mesh = e2, this.update();
|
|
378
|
+
}
|
|
379
|
+
update() {
|
|
380
|
+
const e2 = this.mesh, t2 = e2.geometry, s2 = e2.skeleton, i2 = (t2.index ? t2.index.count : t2.attributes.position.count) / 3;
|
|
381
|
+
if (this.matrixWorld.copy(e2.matrixWorld), this.geometryHash = t2.attributes.position.version, this.primitiveCount = i2, s2) {
|
|
382
|
+
s2.boneTexture || s2.computeBoneTexture(), s2.update();
|
|
383
|
+
const e3 = s2.boneMatrices;
|
|
384
|
+
this.boneMatrices && this.boneMatrices.length === e3.length ? this.boneMatrices.set(e3) : this.boneMatrices = e3.slice();
|
|
385
|
+
} else this.boneMatrices = null;
|
|
386
|
+
}
|
|
387
|
+
didChange() {
|
|
388
|
+
const e2 = this.mesh, t2 = e2.geometry, s2 = (t2.index ? t2.index.count : t2.attributes.position.count) / 3;
|
|
389
|
+
return !(this.matrixWorld.equals(e2.matrixWorld) && this.geometryHash === t2.attributes.position.version && function(e3, t3) {
|
|
390
|
+
if (null === e3 || null === t3) return e3 === t3;
|
|
391
|
+
if (e3.length !== t3.length) return false;
|
|
392
|
+
for (let s3 = 0, i2 = e3.length; s3 < i2; s3++) if (e3[s3] !== t3[s3]) return false;
|
|
393
|
+
return true;
|
|
394
|
+
}(e2.skeleton && e2.skeleton.boneMatrices || null, this.boneMatrices) && this.primitiveCount === s2);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
class ue {
|
|
398
|
+
constructor(e2) {
|
|
399
|
+
Array.isArray(e2) || (e2 = [e2]);
|
|
400
|
+
const s2 = [];
|
|
401
|
+
e2.forEach((e3) => {
|
|
402
|
+
e3.traverseVisible((e4) => {
|
|
403
|
+
e4.isMesh && s2.push(e4);
|
|
404
|
+
});
|
|
405
|
+
}), this.meshes = s2, this.useGroups = true, this.applyWorldTransforms = true, this.attributes = ["position", "normal", "color", "tangent", "uv", "uv2"], this._intermediateGeometry = new Array(s2.length).fill().map(() => new t()), this._diffMap = /* @__PURE__ */ new WeakMap();
|
|
406
|
+
}
|
|
407
|
+
getMaterials() {
|
|
408
|
+
const e2 = [];
|
|
409
|
+
return this.meshes.forEach((t2) => {
|
|
410
|
+
Array.isArray(t2.material) ? e2.push(...t2.material) : e2.push(t2.material);
|
|
411
|
+
}), e2;
|
|
412
|
+
}
|
|
413
|
+
generate(e2 = new t()) {
|
|
414
|
+
let s2 = [];
|
|
415
|
+
const { meshes: n2, useGroups: r2, _intermediateGeometry: a4, _diffMap: o2 } = this;
|
|
416
|
+
for (let e3 = 0, t2 = n2.length; e3 < t2; e3++) {
|
|
417
|
+
const t3 = n2[e3], i2 = a4[e3], r3 = o2.get(t3);
|
|
418
|
+
!r3 || r3.didChange(t3) ? (this._convertToStaticGeometry(t3, i2), s2.push(false), r3 ? r3.update() : o2.set(t3, new de(t3))) : s2.push(true);
|
|
419
|
+
}
|
|
420
|
+
if (0 === a4.length) {
|
|
421
|
+
e2.setIndex(null);
|
|
422
|
+
const t2 = e2.attributes;
|
|
423
|
+
for (const s3 in t2) e2.deleteAttribute(s3);
|
|
424
|
+
for (const t3 in this.attributes) e2.setAttribute(this.attributes[t3], new i(new Float32Array(0), 4, false));
|
|
425
|
+
} else !function(e3, s3 = { useGroups: false, updateIndex: false, skipAttributes: [] }, n3 = new t()) {
|
|
426
|
+
const r3 = null !== e3[0].index, { useGroups: a5 = false, updateIndex: o3 = false, skipAttributes: c2 = [] } = s3, h2 = new Set(Object.keys(e3[0].attributes)), l2 = {};
|
|
427
|
+
let p2 = 0;
|
|
428
|
+
n3.clearGroups();
|
|
429
|
+
for (let t2 = 0; t2 < e3.length; ++t2) {
|
|
430
|
+
const s4 = e3[t2];
|
|
431
|
+
let i2 = 0;
|
|
432
|
+
if (r3 !== (null !== s4.index)) throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");
|
|
433
|
+
for (const e4 in s4.attributes) {
|
|
434
|
+
if (!h2.has(e4)) throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "' + e4 + '" attribute exists among all geometries, or in none of them.');
|
|
435
|
+
void 0 === l2[e4] && (l2[e4] = []), l2[e4].push(s4.attributes[e4]), i2++;
|
|
436
|
+
}
|
|
437
|
+
if (i2 !== h2.size) throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");
|
|
438
|
+
if (a5) {
|
|
439
|
+
let e4;
|
|
440
|
+
if (r3) e4 = s4.index.count;
|
|
441
|
+
else {
|
|
442
|
+
if (void 0 === s4.attributes.position) throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");
|
|
443
|
+
e4 = s4.attributes.position.count;
|
|
444
|
+
}
|
|
445
|
+
n3.addGroup(p2, e4, t2), p2 += e4;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
if (r3) {
|
|
449
|
+
let t2 = false;
|
|
450
|
+
if (!n3.index) {
|
|
451
|
+
let s4 = 0;
|
|
452
|
+
for (let t3 = 0; t3 < e3.length; ++t3) s4 += e3[t3].index.count;
|
|
453
|
+
n3.setIndex(new i(new Uint32Array(s4), 1, false)), t2 = true;
|
|
454
|
+
}
|
|
455
|
+
if (o3 || t2) {
|
|
456
|
+
const t3 = n3.index;
|
|
457
|
+
let s4 = 0, i2 = 0;
|
|
458
|
+
for (let n4 = 0; n4 < e3.length; ++n4) {
|
|
459
|
+
const r4 = e3[n4], a6 = r4.index;
|
|
460
|
+
if (true !== c2[n4]) for (let e4 = 0; e4 < a6.count; ++e4) t3.setX(s4, a6.getX(e4) + i2), s4++;
|
|
461
|
+
i2 += r4.attributes.position.count;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
for (const e4 in l2) {
|
|
466
|
+
const t2 = l2[e4];
|
|
467
|
+
if (!(e4 in n3.attributes)) {
|
|
468
|
+
let s5 = 0;
|
|
469
|
+
for (const e5 in t2) s5 += t2[e5].count;
|
|
470
|
+
n3.setAttribute(e4, ce(l2[e4][0], s5));
|
|
471
|
+
}
|
|
472
|
+
const s4 = n3.attributes[e4];
|
|
473
|
+
let i2 = 0;
|
|
474
|
+
for (let e5 = 0, n4 = t2.length; e5 < n4; e5++) {
|
|
475
|
+
const n5 = t2[e5];
|
|
476
|
+
true !== c2[e5] && he(n5, s4, i2), i2 += n5.count;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}(a4, { useGroups: r2, skipAttributes: s2 }, e2);
|
|
480
|
+
for (const t2 in e2.attributes) e2.attributes[t2].needsUpdate = true;
|
|
481
|
+
return e2;
|
|
482
|
+
}
|
|
483
|
+
_convertToStaticGeometry(e2, s2 = new t()) {
|
|
484
|
+
const i2 = e2.geometry, r2 = this.applyWorldTransforms, a4 = this.attributes.includes("normal"), o2 = this.attributes.includes("tangent"), c2 = i2.attributes, h2 = s2.attributes;
|
|
485
|
+
!s2.index && i2.index && (s2.index = i2.index.clone()), h2.position || s2.setAttribute("position", ce(c2.position)), a4 && !h2.normal && c2.normal && s2.setAttribute("normal", ce(c2.normal)), o2 && !h2.tangent && c2.tangent && s2.setAttribute("tangent", ce(c2.tangent)), oe(i2.index, s2.index), oe(c2.position, h2.position), a4 && oe(c2.normal, h2.normal), o2 && oe(c2.tangent, h2.tangent);
|
|
486
|
+
const l2 = c2.position, p2 = a4 ? c2.normal : null, m2 = o2 ? c2.tangent : null, d2 = i2.morphAttributes.position, u2 = i2.morphAttributes.normal, g2 = i2.morphAttributes.tangent, f2 = i2.morphTargetsRelative, v2 = e2.morphTargetInfluences, b2 = new n();
|
|
487
|
+
b2.getNormalMatrix(e2.matrixWorld), i2.index && s2.index.array.set(i2.index.array);
|
|
488
|
+
for (let t2 = 0, s3 = c2.position.count; t2 < s3; t2++) H.fromBufferAttribute(l2, t2), p2 && K.fromBufferAttribute(p2, t2), m2 && (ee.fromBufferAttribute(m2, t2), J.fromBufferAttribute(m2, t2)), v2 && (d2 && me(d2, v2, f2, t2, H), u2 && me(u2, v2, f2, t2, K), g2 && me(g2, v2, f2, t2, J)), e2.isSkinnedMesh && (e2.applyBoneTransform(t2, H), p2 && pe(e2, t2, K), m2 && pe(e2, t2, J)), r2 && H.applyMatrix4(e2.matrixWorld), h2.position.setXYZ(t2, H.x, H.y, H.z), p2 && (r2 && K.applyNormalMatrix(b2), h2.normal.setXYZ(t2, K.x, K.y, K.z)), m2 && (r2 && J.transformDirection(e2.matrixWorld), h2.tangent.setXYZW(t2, J.x, J.y, J.z, ee.w));
|
|
489
|
+
for (const e3 in this.attributes) {
|
|
490
|
+
const t2 = this.attributes[e3];
|
|
491
|
+
"position" !== t2 && "tangent" !== t2 && "normal" !== t2 && t2 in c2 && (h2[t2] || s2.setAttribute(t2, ce(c2[t2])), oe(c2[t2], h2[t2]), he(c2[t2], h2[t2]));
|
|
492
|
+
}
|
|
493
|
+
return e2.matrixWorld.determinant() < 0 && function(e3) {
|
|
494
|
+
const { index: t2, attributes: s3 } = e3;
|
|
495
|
+
if (t2) for (let e4 = 0, s4 = t2.count; e4 < s4; e4 += 3) {
|
|
496
|
+
const s5 = t2.getX(e4), i3 = t2.getX(e4 + 2);
|
|
497
|
+
t2.setX(e4, i3), t2.setX(e4 + 2, s5);
|
|
498
|
+
}
|
|
499
|
+
else for (const e4 in s3) {
|
|
500
|
+
const t3 = s3[e4], i3 = t3.itemSize;
|
|
501
|
+
for (let e5 = 0, s4 = t3.count; e5 < s4; e5 += 3) for (let s5 = 0; s5 < i3; s5++) {
|
|
502
|
+
const i4 = t3.getComponent(e5, s5), n2 = t3.getComponent(e5 + 2, s5);
|
|
503
|
+
t3.setComponent(e5, s5, n2), t3.setComponent(e5 + 2, s5, i4);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}(s2), s2;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
let ge = "/draco/";
|
|
510
|
+
const _fe = class _fe {
|
|
330
511
|
constructor(e2) {
|
|
331
|
-
this.progressList = [], this.commonFrameList = [], this.mixerList = [], this.shaderList = [], this.getDistanceScalePoint =
|
|
512
|
+
this.progressList = [], this.commonFrameList = [], this.mixerList = [], this.shaderList = [], this.getDistanceScalePoint = l, this.getBestViewTarget = p, this.config = e2, this.engine = new F({ container: e2.container, ...e2.engine, autoStart: false }), this.events = this.engine.events, this.plugins = new d({ engine: this.engine, events: this.events }), this.installCorePlugins(), this.engine.onUpdate((e3, t2) => {
|
|
332
513
|
this.onUpdate(e3, t2);
|
|
333
514
|
}), e2.sceneParams && this.restoreScene(e2.sceneParams), e2.meshListParams && e2.meshListParams.forEach((e3) => {
|
|
334
515
|
this.setModelFromInfo(e3.rootInfo, e3.group);
|
|
335
516
|
}), e2.skyParams && (this.setSky(e2.skyParams), this.setGlobalEnvBackground(e2.skyParams)), false !== e2.autoStart && this.engine.start();
|
|
336
517
|
}
|
|
337
518
|
static get dracoPath() {
|
|
338
|
-
return
|
|
519
|
+
return ge;
|
|
339
520
|
}
|
|
340
521
|
static set dracoPath(e2) {
|
|
341
|
-
|
|
522
|
+
ge = e2;
|
|
342
523
|
}
|
|
343
524
|
get THREE() {
|
|
344
525
|
return e;
|
|
345
526
|
}
|
|
346
527
|
get gsap() {
|
|
347
|
-
return
|
|
528
|
+
return h;
|
|
348
529
|
}
|
|
349
530
|
get scene() {
|
|
350
531
|
return this.engine.scene;
|
|
@@ -356,15 +537,15 @@ const _D = class _D {
|
|
|
356
537
|
return this.engine.renderer;
|
|
357
538
|
}
|
|
358
539
|
get viewer() {
|
|
359
|
-
const e2 = this.plugins.get("orbit-controller"), t2 = this.plugins.get("transform-controller"), s2 = this.plugins.get("composer"), i2 = this.plugins.get("css-renderer"), n2 = this.plugins.get("editor"), r2 = this.plugins.get("loader"),
|
|
360
|
-
return { scene: this.scene, camera: this.camera, renderer: this.renderer, controls: e2 == null ? void 0 : e2.controls, transformControls: t2 == null ? void 0 : t2.controls, Composer: s2, CSS2DObject: i2 == null ? void 0 : i2.CSS2DObject, CSS3DObject: i2 == null ? void 0 : i2.CSS3DObject, MixerList: this.mixerList, ShaderList: this.shaderList, CommonFrameList: this.commonFrameList, handler: n2, modelControls: r2, currentInfo: n2 == null ? void 0 : n2.currentInfo, GUI:
|
|
540
|
+
const e2 = this.plugins.get("orbit-controller"), t2 = this.plugins.get("transform-controller"), s2 = this.plugins.get("composer"), i2 = this.plugins.get("css-renderer"), n2 = this.plugins.get("editor"), r2 = this.plugins.get("loader"), a4 = this.plugins.get("gui");
|
|
541
|
+
return { scene: this.scene, camera: this.camera, renderer: this.renderer, controls: e2 == null ? void 0 : e2.controls, transformControls: t2 == null ? void 0 : t2.controls, Composer: s2, CSS2DObject: i2 == null ? void 0 : i2.CSS2DObject, CSS3DObject: i2 == null ? void 0 : i2.CSS3DObject, MixerList: this.mixerList, ShaderList: this.shaderList, CommonFrameList: this.commonFrameList, handler: n2, modelControls: r2, currentInfo: n2 == null ? void 0 : n2.currentInfo, GUI: a4 == null ? void 0 : a4.gui, renderSceneResize: () => this.engine.resize(), destroySceneRender: () => this.dispose(), saveSceneEditor: () => this.saveSceneEditor() };
|
|
361
542
|
}
|
|
362
543
|
installCorePlugins() {
|
|
363
|
-
this.plugins.use(new
|
|
364
|
-
const e2 = new
|
|
365
|
-
this.plugins.use(e2), this.plugins.use(new
|
|
544
|
+
this.plugins.use(new g()), this.plugins.use(new f());
|
|
545
|
+
const e2 = new b({ dracoPath: _fe.dracoPath });
|
|
546
|
+
this.plugins.use(e2), this.plugins.use(new y()), this.plugins.use(new x()), this.plugins.use(new w()), this.plugins.use(new E({ grid: { enabled: true, size: 100, divisions: 100, colorCenterLine: 4473924, colorGrid: 8947848 }, axes: { enabled: true, size: 5 }, stats: { enabled: false, mode: 0 }, viewHelper: { enabled: false, size: 128, position: "bottom-right" }, box3Helper: { enabled: false, color: 16776960 } }));
|
|
366
547
|
const t2 = this.config.gui;
|
|
367
|
-
true !== (t2 == null ? void 0 : t2.useProxy) && this.plugins.use(new
|
|
548
|
+
true !== (t2 == null ? void 0 : t2.useProxy) && this.plugins.use(new C({ autoPlace: (t2 == null ? void 0 : t2.autoPlace) ?? true, width: (t2 == null ? void 0 : t2.width) ?? 300, useProxy: (t2 == null ? void 0 : t2.useProxy) ?? false }));
|
|
368
549
|
}
|
|
369
550
|
onUpdate(e2, t2) {
|
|
370
551
|
this.mixerList.forEach((e3) => {
|
|
@@ -425,17 +606,17 @@ const _D = class _D {
|
|
|
425
606
|
return s2.x = (e2.clientX - n2.left) / n2.width * 2 - 1, s2.y = -(e2.clientY - n2.top) / n2.height * 2 + 1, t2.setFromCamera(s2, this.camera), t2.intersectObjects(i2, true);
|
|
426
607
|
} };
|
|
427
608
|
}
|
|
428
|
-
setGsapAnimation(e2,
|
|
429
|
-
return
|
|
609
|
+
setGsapAnimation(e2, t2, s2 = {}) {
|
|
610
|
+
return h.to(e2, { ...t2, duration: 2, ease: "none", repeat: 0, yoyo: false, yoyoEase: true, ...s2 });
|
|
430
611
|
}
|
|
431
612
|
setModelAnimationPlay(t2) {
|
|
432
613
|
if (!t2.animationPlayParams || !t2.animations) return null;
|
|
433
|
-
const { speed: s2, actionIndexs: i2, startTime: n2, loop: r2 } = t2.animationPlayParams,
|
|
614
|
+
const { speed: s2, actionIndexs: i2, startTime: n2, loop: r2 } = t2.animationPlayParams, a4 = new e.Clock(), o2 = new e.AnimationMixer(t2), c2 = t2.animations.filter((e2, t3) => i2[t3]).map((t3) => {
|
|
434
615
|
const i3 = o2.clipAction(t3);
|
|
435
616
|
return i3.loop = r2 ? e.LoopRepeat : e.LoopOnce, i3.time = n2, i3.timeScale = s2, i3.clampWhenFinished = true, i3.play(), i3;
|
|
436
617
|
});
|
|
437
618
|
return t2.mixerRender = () => {
|
|
438
|
-
o2.update(
|
|
619
|
+
o2.update(a4.getDelta());
|
|
439
620
|
}, this.mixerList.push(o2), { mixer: o2, actions: c2 };
|
|
440
621
|
}
|
|
441
622
|
removeModelAnimation(e2) {
|
|
@@ -470,7 +651,7 @@ const _D = class _D {
|
|
|
470
651
|
s2 && s2.controls.hasOwnProperty(e2) && (s2.controls[e2] = t2);
|
|
471
652
|
}
|
|
472
653
|
getObjectViews(e2, t2) {
|
|
473
|
-
return
|
|
654
|
+
return z(e2, t2 ?? this.camera.fov);
|
|
474
655
|
}
|
|
475
656
|
getSceneCurveList() {
|
|
476
657
|
return this.scene.children.filter((e2) => e2.isCurveMesh).map((e2) => {
|
|
@@ -556,9 +737,9 @@ const _D = class _D {
|
|
|
556
737
|
}
|
|
557
738
|
t2.position && e2.position.set(t2.position.x ?? e2.position.x, t2.position.y ?? e2.position.y, t2.position.z ?? e2.position.z), t2.rotation && e2.rotation.set(t2.rotation.x ?? e2.rotation.x, t2.rotation.y ?? e2.rotation.y, t2.rotation.z ?? e2.rotation.z), t2.scale && e2.scale.set(t2.scale.x ?? e2.scale.x, t2.scale.y ?? e2.scale.y, t2.scale.z ?? e2.scale.z);
|
|
558
739
|
}
|
|
559
|
-
setGsapMeshAction(e2, s2, i2
|
|
560
|
-
const { query:
|
|
561
|
-
|
|
740
|
+
setGsapMeshAction(e2, t2, s2, i2) {
|
|
741
|
+
const { query: n2 } = i2;
|
|
742
|
+
t2.position && s2.position && (e2.position.set(t2.position.x, t2.position.y, t2.position.z), h.to(e2.position, { x: s2.position.x, y: s2.position.y, z: s2.position.z, ...n2 })), t2.rotation && s2.rotation && (e2.rotation.set(t2.rotation.x, t2.rotation.y, t2.rotation.z), h.to(e2.rotation, { x: s2.rotation.x, y: s2.rotation.y, z: s2.rotation.z, ...n2 })), t2.scale && s2.scale && (e2.scale.set(t2.scale.x, t2.scale.y, t2.scale.z), h.to(e2.scale, { x: s2.scale.x, y: s2.scale.y, z: s2.scale.z, ...n2 }));
|
|
562
743
|
}
|
|
563
744
|
start() {
|
|
564
745
|
this.engine.start();
|
|
@@ -570,76 +751,79 @@ const _D = class _D {
|
|
|
570
751
|
this.plugins.dispose(), this.engine.dispose(), this.progressList = [], this.mixerList = [], this.shaderList = [], this.commonFrameList = [];
|
|
571
752
|
}
|
|
572
753
|
};
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
let
|
|
576
|
-
function
|
|
754
|
+
_fe.THREE = e;
|
|
755
|
+
_fe.gsap = h;
|
|
756
|
+
let fe = _fe;
|
|
757
|
+
function ve(e2) {
|
|
577
758
|
var _a;
|
|
578
|
-
(_a = e2.geometry) == null ? void 0 : _a.dispose(), Array.isArray(e2.material) ? e2.material.forEach(
|
|
759
|
+
(_a = e2.geometry) == null ? void 0 : _a.dispose(), Array.isArray(e2.material) ? e2.material.forEach(be) : e2.material && be(e2.material);
|
|
579
760
|
}
|
|
580
|
-
function
|
|
761
|
+
function be(e2) {
|
|
581
762
|
e2.dispose();
|
|
582
763
|
const t2 = e2;
|
|
583
764
|
t2.map && t2.map.dispose(), t2.lightMap && t2.lightMap.dispose(), t2.bumpMap && t2.bumpMap.dispose(), t2.normalMap && t2.normalMap.dispose(), t2.specularMap && t2.specularMap.dispose(), t2.envMap && t2.envMap.dispose(), t2.alphaMap && t2.alphaMap.dispose(), t2.aoMap && t2.aoMap.dispose(), t2.displacementMap && t2.displacementMap.dispose(), t2.emissiveMap && t2.emissiveMap.dispose(), t2.gradientMap && t2.gradientMap.dispose(), t2.metalnessMap && t2.metalnessMap.dispose(), t2.roughnessMap && t2.roughnessMap.dispose();
|
|
584
765
|
}
|
|
585
|
-
function
|
|
766
|
+
function Me(e2) {
|
|
586
767
|
e2.traverse((e3) => {
|
|
587
|
-
e3.isMesh &&
|
|
768
|
+
e3.isMesh && ve(e3);
|
|
588
769
|
});
|
|
589
770
|
}
|
|
590
|
-
function
|
|
771
|
+
function ye(t2) {
|
|
591
772
|
for (t2.traverse((e2) => {
|
|
592
|
-
e2.isMesh &&
|
|
773
|
+
e2.isMesh && ve(e2);
|
|
593
774
|
}); t2.children.length > 0; ) t2.remove(t2.children[0]);
|
|
594
775
|
t2.background instanceof e.Texture && t2.background.dispose(), t2.environment && t2.environment.dispose();
|
|
595
776
|
}
|
|
596
777
|
export {
|
|
597
778
|
A as AnimationPlugin,
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
779
|
+
x as CSSRendererPlugin,
|
|
780
|
+
B as CameraManager,
|
|
781
|
+
y as ComposerPlugin,
|
|
601
782
|
k as DrawingPlugin,
|
|
602
|
-
|
|
603
|
-
|
|
783
|
+
w as EditorPlugin,
|
|
784
|
+
F as Engine,
|
|
604
785
|
u as EnvironmentPlugin,
|
|
605
|
-
|
|
606
|
-
|
|
786
|
+
L as EventEmitter,
|
|
787
|
+
C as GUIPlugin,
|
|
607
788
|
m as GeoMapPlugin,
|
|
608
789
|
G as GeometryPlugin,
|
|
609
|
-
|
|
610
|
-
|
|
790
|
+
E as GizmoPlugin,
|
|
791
|
+
b as LoaderPlugin,
|
|
611
792
|
M as MaterialPlugin,
|
|
612
|
-
|
|
793
|
+
X as MeshBVH,
|
|
794
|
+
g as OrbitControllerPlugin,
|
|
613
795
|
o as ParticlePlugin,
|
|
614
796
|
q as PhysicsPlugin,
|
|
615
797
|
P as Plugin,
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
798
|
+
d as PluginManager,
|
|
799
|
+
j as RendererManager,
|
|
800
|
+
I as SceneManager,
|
|
619
801
|
v as SerializationPlugin,
|
|
620
802
|
S as ShaderPlugin,
|
|
803
|
+
ue as StaticGeometryGenerator,
|
|
621
804
|
s as TextPlugin,
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
805
|
+
fe as ThreeEditor,
|
|
806
|
+
f as TransformControllerPlugin,
|
|
807
|
+
R as buildSceneBVH,
|
|
808
|
+
$ as clamp,
|
|
809
|
+
a3 as createBox3Helper,
|
|
810
|
+
W as createRaycaster,
|
|
811
|
+
Z as degToRad,
|
|
812
|
+
be as disposeMaterial,
|
|
813
|
+
ve as disposeMesh,
|
|
814
|
+
Me as disposeObject,
|
|
815
|
+
ye as disposeScene,
|
|
816
|
+
p as getBestViewTarget,
|
|
817
|
+
l as getDistanceScalePoint,
|
|
818
|
+
a2 as getObjectBox3,
|
|
819
|
+
z as getObjectViews,
|
|
820
|
+
Y as getPointAtDistance,
|
|
821
|
+
V as getRootModel,
|
|
638
822
|
N as getWebGLMouse,
|
|
639
823
|
Q as getWebGLMouseFromContainer,
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
824
|
+
a0 as lerp,
|
|
825
|
+
_ as radToDeg,
|
|
826
|
+
U as raycastObjects,
|
|
827
|
+
a1 as smoothstep
|
|
644
828
|
};
|
|
645
829
|
//# sourceMappingURL=index.js.map
|