view3d-core 1.0.0

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/index.js ADDED
@@ -0,0 +1,644 @@
1
+ import * as e from "three";
2
+ import t from "gsap";
3
+ import { I as i, J as n, a as r, O as a, T as c, L as h, C as l, f as p, E as d, t as g, w as f, K as y } from "./SerializationPlugin-CBr1GY5q.js";
4
+ import { A, k, u, m, G, M, o, q, P, v, S, s, Z, a1, V, X, a0, W, U, N, Q, _, Y, R, $ } from "./SerializationPlugin-CBr1GY5q.js";
5
+ class b {
6
+ constructor() {
7
+ this.listeners = /* @__PURE__ */ new Map();
8
+ }
9
+ on(e2, t2) {
10
+ this.listeners.has(e2) || this.listeners.set(e2, /* @__PURE__ */ new Set());
11
+ const s2 = { callback: t2, once: false };
12
+ return this.listeners.get(e2).add(s2), () => {
13
+ var _a;
14
+ (_a = this.listeners.get(e2)) == null ? void 0 : _a.delete(s2);
15
+ };
16
+ }
17
+ once(e2, t2) {
18
+ this.listeners.has(e2) || this.listeners.set(e2, /* @__PURE__ */ new Set());
19
+ const s2 = { callback: t2, once: true };
20
+ return this.listeners.get(e2).add(s2), () => {
21
+ var _a;
22
+ (_a = this.listeners.get(e2)) == null ? void 0 : _a.delete(s2);
23
+ };
24
+ }
25
+ off(e2, t2) {
26
+ if (!t2) return void this.listeners.delete(e2);
27
+ const s2 = this.listeners.get(e2);
28
+ if (s2) {
29
+ for (const e3 of s2) if (e3.callback === t2) {
30
+ s2.delete(e3);
31
+ break;
32
+ }
33
+ }
34
+ }
35
+ emit(e2, t2) {
36
+ const s2 = this.listeners.get(e2);
37
+ if (!s2) return;
38
+ const i2 = [];
39
+ for (const e3 of s2) {
40
+ try {
41
+ e3.callback(t2);
42
+ } catch (e4) {
43
+ }
44
+ e3.once && i2.push(e3);
45
+ }
46
+ for (const e3 of i2) s2.delete(e3);
47
+ }
48
+ hasListeners(e2) {
49
+ const t2 = this.listeners.get(e2);
50
+ return void 0 !== t2 && t2.size > 0;
51
+ }
52
+ listenerCount(e2) {
53
+ var _a;
54
+ return ((_a = this.listeners.get(e2)) == null ? void 0 : _a.size) ?? 0;
55
+ }
56
+ removeAllListeners() {
57
+ this.listeners.clear();
58
+ }
59
+ dispose() {
60
+ this.removeAllListeners();
61
+ }
62
+ }
63
+ class w {
64
+ constructor(t2) {
65
+ this.events = t2, this._envBackground = null, this._environmentEnabled = false, this.envMapChangeCallbacks = [], this.ssrMeshList = [], this.scene = new e.Scene(), this.scene.name = "MainScene";
66
+ }
67
+ get envBackground() {
68
+ return this._envBackground;
69
+ }
70
+ set envBackground(e2) {
71
+ this._envBackground = e2, this.updateEnvironment(), this.envMapChangeCallbacks.forEach((e3) => e3());
72
+ }
73
+ get environmentEnabled() {
74
+ return this._environmentEnabled;
75
+ }
76
+ set environmentEnabled(e2) {
77
+ this._environmentEnabled = e2, this.updateEnvironment();
78
+ }
79
+ updateEnvironment() {
80
+ this.scene.environment = this._environmentEnabled ? this._envBackground : null;
81
+ }
82
+ onEnvMapChange(e2) {
83
+ return this.envMapChangeCallbacks.push(e2), () => {
84
+ const t2 = this.envMapChangeCallbacks.indexOf(e2);
85
+ t2 > -1 && this.envMapChangeCallbacks.splice(t2, 1);
86
+ };
87
+ }
88
+ setBackground(e2) {
89
+ this.scene.background = e2, this.events.emit("scene:background:change", { background: e2 });
90
+ }
91
+ setSkybox(t2) {
92
+ return new Promise((s2, i2) => {
93
+ new e.CubeTextureLoader().load(t2, (e2) => {
94
+ this.scene.background = e2, this.events.emit("scene:background:change", { background: e2 }), s2(e2);
95
+ }, void 0, i2);
96
+ });
97
+ }
98
+ setEnvironmentMap(t2) {
99
+ return new Promise((s2, i2) => {
100
+ new e.CubeTextureLoader().load(t2, (e2) => {
101
+ this.envBackground = e2, s2(e2);
102
+ }, void 0, i2);
103
+ });
104
+ }
105
+ add(...e2) {
106
+ for (const t2 of e2) this.scene.add(t2), this.events.emit("object:added", { object: t2, parent: this.scene });
107
+ }
108
+ remove(...e2) {
109
+ for (const t2 of e2) this.scene.remove(t2), this.events.emit("object:removed", { object: t2, parent: this.scene });
110
+ }
111
+ getObjectByName(e2) {
112
+ return this.scene.getObjectByName(e2);
113
+ }
114
+ getObjectById(e2) {
115
+ return this.scene.getObjectById(e2);
116
+ }
117
+ traverse(e2) {
118
+ this.scene.traverse(e2);
119
+ }
120
+ getMeshes() {
121
+ const t2 = [];
122
+ return this.scene.traverse((s2) => {
123
+ s2 instanceof e.Mesh && t2.push(s2);
124
+ }), t2;
125
+ }
126
+ getLights() {
127
+ const t2 = [];
128
+ return this.scene.traverse((s2) => {
129
+ s2 instanceof e.Light && t2.push(s2);
130
+ }), t2;
131
+ }
132
+ clear() {
133
+ for (; this.scene.children.length > 0; ) {
134
+ const e2 = this.scene.children[0];
135
+ this.scene.remove(e2), this.events.emit("object:removed", { object: e2, parent: this.scene });
136
+ }
137
+ }
138
+ dispose() {
139
+ this.scene.traverse((t2) => {
140
+ var _a;
141
+ t2 instanceof e.Mesh && ((_a = t2.geometry) == null ? void 0 : _a.dispose(), Array.isArray(t2.material) ? t2.material.forEach((e2) => {
142
+ e2.dispose(), "map" in e2 && e2.map && e2.map.dispose();
143
+ }) : t2.material && (t2.material.dispose(), "map" in t2.material && t2.material.map && t2.material.map.dispose()));
144
+ }), this.clear(), this.envMapChangeCallbacks = [], this.ssrMeshList.length = 0;
145
+ }
146
+ }
147
+ const x = { fov: 50, near: 0.1, far: 1e5, position: { x: 10, y: 10, z: 10 } };
148
+ class E {
149
+ constructor(t2, s2, i2) {
150
+ this.container = t2, this.events = s2, this.config = { ...x, ...i2 };
151
+ const n2 = t2.clientWidth / t2.clientHeight;
152
+ 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
+ get position() {
155
+ return this.camera.position;
156
+ }
157
+ get fov() {
158
+ return this.camera.fov;
159
+ }
160
+ set fov(e2) {
161
+ this.camera.fov = e2, this.camera.updateProjectionMatrix(), this.events.emit("camera:change", { camera: this.camera });
162
+ }
163
+ get near() {
164
+ return this.camera.near;
165
+ }
166
+ set near(e2) {
167
+ this.camera.near = e2, this.camera.updateProjectionMatrix(), this.events.emit("camera:change", { camera: this.camera });
168
+ }
169
+ get far() {
170
+ return this.camera.far;
171
+ }
172
+ set far(e2) {
173
+ this.camera.far = e2, this.camera.updateProjectionMatrix(), this.events.emit("camera:change", { camera: this.camera });
174
+ }
175
+ setPosition(e2, t2, s2) {
176
+ this.camera.position.set(e2, t2, s2), this.events.emit("camera:change", { camera: this.camera });
177
+ }
178
+ lookAt(t2) {
179
+ t2 instanceof e.Vector3 ? this.camera.lookAt(t2) : this.camera.lookAt(t2.x, t2.y, t2.z), this.events.emit("camera:change", { camera: this.camera });
180
+ }
181
+ updateAspect() {
182
+ this.camera.aspect = this.container.clientWidth / this.container.clientHeight, this.camera.updateProjectionMatrix();
183
+ }
184
+ getWorldDirection() {
185
+ const t2 = new e.Vector3();
186
+ return this.camera.getWorldDirection(t2), t2;
187
+ }
188
+ getTargetPoint(e2) {
189
+ const t2 = this.getWorldDirection();
190
+ return this.camera.position.clone().add(t2.multiplyScalar(e2));
191
+ }
192
+ getConfig() {
193
+ return { fov: this.camera.fov, near: this.camera.near, far: this.camera.far, position: { x: this.camera.position.x, y: this.camera.position.y, z: this.camera.position.z } };
194
+ }
195
+ applyConfig(e2) {
196
+ void 0 !== e2.fov && (this.camera.fov = e2.fov), void 0 !== e2.near && (this.camera.near = e2.near), void 0 !== e2.far && (this.camera.far = e2.far), e2.position && this.camera.position.set(e2.position.x, e2.position.y, e2.position.z), this.camera.updateProjectionMatrix(), this.events.emit("camera:change", { camera: this.camera });
197
+ }
198
+ dispose() {
199
+ }
200
+ }
201
+ const C = { pixelRatio: "undefined" != typeof window ? window.devicePixelRatio : 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 };
202
+ class z {
203
+ constructor(t2, s2, i2) {
204
+ this.container = t2, this.events = s2, this.config = { ...C, ...i2 }, 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
+ get domElement() {
207
+ return this.renderer.domElement;
208
+ }
209
+ get pixelRatio() {
210
+ return this.renderer.getPixelRatio();
211
+ }
212
+ set pixelRatio(e2) {
213
+ this.renderer.setPixelRatio(e2), this.config.pixelRatio = e2;
214
+ }
215
+ getSize() {
216
+ const t2 = new e.Vector2();
217
+ return this.renderer.getSize(t2), { width: t2.x, height: t2.y };
218
+ }
219
+ setSize(e2, t2) {
220
+ this.renderer.setSize(e2, t2), this.events.emit("resize", { width: e2, height: t2 });
221
+ }
222
+ updateSize() {
223
+ const e2 = this.container.clientWidth, t2 = this.container.clientHeight;
224
+ this.setSize(e2, t2);
225
+ }
226
+ render(e2, t2) {
227
+ this.renderer.render(e2, t2);
228
+ }
229
+ getScreenshot(e2 = "image/png", t2 = 0.9) {
230
+ return this.renderer.domElement.toDataURL(e2, t2);
231
+ }
232
+ setShadowMapEnabled(e2) {
233
+ this.renderer.shadowMap.enabled = e2, this.config.shadowMapEnabled = e2;
234
+ }
235
+ setShadowMapType(e2) {
236
+ this.renderer.shadowMap.type = e2, this.config.shadowMapType = e2;
237
+ }
238
+ setToneMapping(e2, t2) {
239
+ this.renderer.toneMapping = e2, this.config.toneMapping = e2, void 0 !== t2 && (this.renderer.toneMappingExposure = t2, this.config.toneMappingExposure = t2);
240
+ }
241
+ getConfig() {
242
+ return { ...this.config };
243
+ }
244
+ applyConfig(e2) {
245
+ void 0 !== e2.pixelRatio && (this.pixelRatio = e2.pixelRatio), void 0 !== e2.toneMapping && (this.renderer.toneMapping = e2.toneMapping, this.config.toneMapping = e2.toneMapping), void 0 !== e2.toneMappingExposure && (this.renderer.toneMappingExposure = e2.toneMappingExposure, this.config.toneMappingExposure = e2.toneMappingExposure), void 0 !== e2.shadowMapEnabled && this.setShadowMapEnabled(e2.shadowMapEnabled), void 0 !== e2.shadowMapType && this.setShadowMapType(e2.shadowMapType);
246
+ }
247
+ getInfo() {
248
+ return this.renderer.info;
249
+ }
250
+ resetInfo() {
251
+ this.renderer.info.reset();
252
+ }
253
+ dispose() {
254
+ this.renderer.dispose(), this.renderer.forceContextLoss(), this.renderer.domElement.parentNode && this.renderer.domElement.parentNode.removeChild(this.renderer.domElement);
255
+ }
256
+ }
257
+ const L = { autoResize: true, fps: null, autoStart: true };
258
+ class I {
259
+ constructor(t2) {
260
+ this.animationId = null, this._isRunning = false, this.frameCallbacks = /* @__PURE__ */ new Set(), this.fpsInterval = 0, this.lastFrameTime = 0, this.resizeHandler = null, this.animate = () => {
261
+ if (!this._isRunning) return;
262
+ this.animationId = requestAnimationFrame(this.animate);
263
+ const e2 = performance.now();
264
+ if (this.fpsInterval > 0) {
265
+ const t4 = e2 - this.lastFrameTime;
266
+ if (t4 < this.fpsInterval) return;
267
+ this.lastFrameTime = e2 - t4 % this.fpsInterval;
268
+ }
269
+ const t3 = this.clock.getDelta(), s2 = this.clock.getElapsedTime();
270
+ this.events.emit("render:before", { delta: t3, elapsed: s2 });
271
+ for (const e3 of this.frameCallbacks) try {
272
+ e3(t3, s2);
273
+ } catch (e4) {
274
+ }
275
+ this.render(), this.events.emit("render:after", { delta: t3, elapsed: s2 });
276
+ }, this.config = { ...L, ...t2 }, this.container = t2.container, this.events = new b(), this.clock = new e.Clock(false), this.sceneManager = new w(this.events), this.cameraManager = new E(this.container, this.events, t2.camera), this.sceneManager.scene.add(this.cameraManager.camera), this.rendererManager = new z(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();
277
+ }
278
+ get scene() {
279
+ return this.sceneManager.scene;
280
+ }
281
+ get camera() {
282
+ return this.cameraManager.camera;
283
+ }
284
+ get renderer() {
285
+ return this.rendererManager.renderer;
286
+ }
287
+ get domElement() {
288
+ return this.rendererManager.domElement;
289
+ }
290
+ get isRunning() {
291
+ return this._isRunning;
292
+ }
293
+ setupAutoResize() {
294
+ this.resizeHandler = () => this.resize(), window.addEventListener("resize", this.resizeHandler);
295
+ }
296
+ start() {
297
+ this._isRunning || (this._isRunning = true, this.clock.start(), this.lastFrameTime = performance.now(), this.events.emit("engine:start", void 0), this.animate());
298
+ }
299
+ stop() {
300
+ this._isRunning && (this._isRunning = false, this.clock.stop(), null !== this.animationId && (cancelAnimationFrame(this.animationId), this.animationId = null), this.events.emit("engine:stop", void 0));
301
+ }
302
+ render() {
303
+ this.rendererManager.render(this.scene, this.camera);
304
+ }
305
+ resize() {
306
+ const e2 = this.container.clientWidth, t2 = this.container.clientHeight;
307
+ this.cameraManager.updateAspect(), this.rendererManager.setSize(e2, t2), this.events.emit("resize", { width: e2, height: t2 });
308
+ }
309
+ onUpdate(e2) {
310
+ return this.frameCallbacks.add(e2), () => {
311
+ this.frameCallbacks.delete(e2);
312
+ };
313
+ }
314
+ screenshot(e2, t2) {
315
+ return this.render(), this.rendererManager.getScreenshot(e2, t2);
316
+ }
317
+ setFPS(e2) {
318
+ this.config.fps = e2, this.fpsInterval = null !== e2 && e2 > 0 ? 1e3 / e2 : 0;
319
+ }
320
+ getFPS() {
321
+ return this.fpsInterval > 0 ? 1e3 / this.fpsInterval : 0;
322
+ }
323
+ dispose() {
324
+ 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();
325
+ }
326
+ }
327
+ let T = "/draco/";
328
+ const _D = class _D {
329
+ constructor(e2) {
330
+ this.progressList = [], this.commonFrameList = [], this.mixerList = [], this.shaderList = [], this.getDistanceScalePoint = i, this.getBestViewTarget = n, this.config = e2, this.engine = new I({ container: e2.container, ...e2.engine, autoStart: false }), this.events = this.engine.events, this.plugins = new r({ engine: this.engine, events: this.events }), this.installCorePlugins(), this.engine.onUpdate((e3, t2) => {
331
+ this.onUpdate(e3, t2);
332
+ }), e2.sceneParams && this.restoreScene(e2.sceneParams), e2.meshListParams && e2.meshListParams.forEach((e3) => {
333
+ this.setModelFromInfo(e3.rootInfo, e3.group);
334
+ }), e2.skyParams && (this.setSky(e2.skyParams), this.setGlobalEnvBackground(e2.skyParams)), false !== e2.autoStart && this.engine.start();
335
+ }
336
+ static get dracoPath() {
337
+ return T;
338
+ }
339
+ static set dracoPath(e2) {
340
+ T = e2;
341
+ }
342
+ get THREE() {
343
+ return e;
344
+ }
345
+ get gsap() {
346
+ return t;
347
+ }
348
+ get scene() {
349
+ return this.engine.scene;
350
+ }
351
+ get camera() {
352
+ return this.engine.camera;
353
+ }
354
+ get renderer() {
355
+ return this.engine.renderer;
356
+ }
357
+ get viewer() {
358
+ 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"), a2 = this.plugins.get("gui");
359
+ 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: a2 == null ? void 0 : a2.gui, renderSceneResize: () => this.engine.resize(), destroySceneRender: () => this.dispose(), saveSceneEditor: () => this.saveSceneEditor() };
360
+ }
361
+ installCorePlugins() {
362
+ this.plugins.use(new a()), this.plugins.use(new c());
363
+ const e2 = new h({ dracoPath: _D.dracoPath });
364
+ this.plugins.use(e2), this.plugins.use(new l()), this.plugins.use(new p()), this.plugins.use(new d()), this.plugins.use(new g({ 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 } }));
365
+ const t2 = this.config.gui;
366
+ true !== (t2 == null ? void 0 : t2.useProxy) && this.plugins.use(new f({ autoPlace: (t2 == null ? void 0 : t2.autoPlace) ?? true, width: (t2 == null ? void 0 : t2.width) ?? 300, useProxy: (t2 == null ? void 0 : t2.useProxy) ?? false }));
367
+ }
368
+ onUpdate(e2, t2) {
369
+ this.mixerList.forEach((e3) => {
370
+ var _a;
371
+ (_a = e3.mixerRender) == null ? void 0 : _a.call(e3);
372
+ }), this.shaderList.forEach((e3) => {
373
+ var _a;
374
+ (_a = e3.ShaderAnimateRender) == null ? void 0 : _a.call(e3);
375
+ }), this.commonFrameList.forEach((e3) => {
376
+ var _a;
377
+ (_a = e3.frameAnimationRender) == null ? void 0 : _a.call(e3);
378
+ });
379
+ const s2 = this.plugins.get("composer");
380
+ s2 && s2.render();
381
+ }
382
+ use(e2) {
383
+ return this.plugins.use(e2), this;
384
+ }
385
+ setModelFromInfo(e2, t2 = null) {
386
+ const s2 = this.plugins.get("loader");
387
+ if (!s2) throw new Error("Loader plugin not installed");
388
+ const i2 = s2.loadModel(e2), n2 = i2.complete;
389
+ i2.complete = (t3) => {
390
+ t3.rootInfo = e2, this.scene.add(t3), n2(t3);
391
+ };
392
+ const r2 = { loaderService: i2, rootInfo: e2, params: t2 };
393
+ return this.progressList.push(r2), r2;
394
+ }
395
+ setSky(e2) {
396
+ this.engine.sceneManager.setSkybox(e2);
397
+ }
398
+ setGlobalEnvBackground(e2) {
399
+ this.engine.sceneManager.setEnvironmentMap(e2).then(() => {
400
+ this.engine.sceneManager.environmentEnabled = true;
401
+ });
402
+ }
403
+ setCss2dDOM(e2, t2) {
404
+ const s2 = this.plugins.get("css-renderer");
405
+ if (!s2) throw new Error("CSS Renderer plugin not installed");
406
+ e2.style.pointerEvents = "auto";
407
+ return s2.addCSS2D(e2, t2);
408
+ }
409
+ setCss3dDOM(e2, t2) {
410
+ const s2 = this.plugins.get("css-renderer");
411
+ if (!s2) throw new Error("CSS Renderer plugin not installed");
412
+ return s2.addCSS3D(e2, t2);
413
+ }
414
+ getSceneEvent(e2, t2) {
415
+ const s2 = this.plugins.get("editor");
416
+ if (!s2) return;
417
+ const i2 = s2.handleClick(e2);
418
+ i2 && t2(i2);
419
+ }
420
+ getRawSceneEvent() {
421
+ const t2 = new e.Raycaster(), s2 = new e.Vector2();
422
+ return { raycaster: t2, getIntersects: (e2, i2) => {
423
+ const n2 = this.renderer.domElement.getBoundingClientRect();
424
+ 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);
425
+ } };
426
+ }
427
+ setGsapAnimation(e2, s2, i2 = {}) {
428
+ return t.to(e2, { ...s2, duration: 2, ease: "none", repeat: 0, yoyo: false, yoyoEase: true, ...i2 });
429
+ }
430
+ setModelAnimationPlay(t2) {
431
+ if (!t2.animationPlayParams || !t2.animations) return null;
432
+ const { speed: s2, actionIndexs: i2, startTime: n2, loop: r2 } = t2.animationPlayParams, a2 = new e.Clock(), o2 = new e.AnimationMixer(t2), c2 = t2.animations.filter((e2, t3) => i2[t3]).map((t3) => {
433
+ const i3 = o2.clipAction(t3);
434
+ return i3.loop = r2 ? e.LoopRepeat : e.LoopOnce, i3.time = n2, i3.timeScale = s2, i3.clampWhenFinished = true, i3.play(), i3;
435
+ });
436
+ return t2.mixerRender = () => {
437
+ o2.update(a2.getDelta());
438
+ }, this.mixerList.push(o2), { mixer: o2, actions: c2 };
439
+ }
440
+ removeModelAnimation(e2) {
441
+ const t2 = this.mixerList.findIndex((t3) => t3 === e2 || t3.mixerRender === e2.mixerRender);
442
+ t2 > -1 && this.mixerList.splice(t2, 1);
443
+ }
444
+ setCurveAnimation(e2, t2 = 1) {
445
+ const s2 = this.commonFrameList, i2 = { id: Date.now(), curve: e2, time: 0, pause: false, speed: t2, frameCallback: null, frameEndCallback: null, start: function() {
446
+ s2.includes(this) || s2.push(this), this.pause = false;
447
+ }, destroy: function() {
448
+ const e3 = s2.indexOf(this);
449
+ e3 > -1 && s2.splice(e3, 1);
450
+ }, frameAnimationRender: () => {
451
+ var _a, _b;
452
+ if (i2.pause) return;
453
+ if (i2.time += i2.speed / 1e3, i2.time > 1 || i2.time < 0) return i2.time = i2.time > 1 ? 1 : 0, i2.pause = true, void ((_a = i2.frameEndCallback) == null ? void 0 : _a.call(i2));
454
+ const t3 = e2.getPointAt(i2.time);
455
+ (_b = i2.frameCallback) == null ? void 0 : _b.call(i2, t3);
456
+ } };
457
+ return i2;
458
+ }
459
+ setOutlinePass(e2 = []) {
460
+ const t2 = this.plugins.get("composer");
461
+ t2 && t2.setOutlineObjects(e2);
462
+ }
463
+ setSceneControlMode(e2) {
464
+ const t2 = this.plugins.get("editor");
465
+ t2 && t2.setMode(e2);
466
+ }
467
+ setTransformControlsProperty(e2, t2) {
468
+ const s2 = this.plugins.get("transform-controller");
469
+ s2 && s2.controls.hasOwnProperty(e2) && (s2.controls[e2] = t2);
470
+ }
471
+ getObjectViews(e2, t2) {
472
+ return y(e2, t2 ?? this.camera.fov);
473
+ }
474
+ getSceneCurveList() {
475
+ return this.scene.children.filter((e2) => e2.isCurveMesh).map((e2) => {
476
+ var _a, _b;
477
+ return { path: e2.curvePath || ((_b = (_a = e2.geometry) == null ? void 0 : _a.parameters) == null ? void 0 : _b.path), mesh: e2 };
478
+ });
479
+ }
480
+ saveSceneEditor() {
481
+ if (this.config.saveCallback) {
482
+ const e2 = {}, t2 = [];
483
+ this.config.saveCallback(e2, t2);
484
+ }
485
+ }
486
+ restoreScene(e2) {
487
+ }
488
+ getSceneEditorImage(e2) {
489
+ return Array.isArray(e2) ? this.engine.screenshot(e2[0], e2[1]) : this.engine.screenshot(e2 == null ? void 0 : e2.type, e2 == null ? void 0 : e2.quality);
490
+ }
491
+ refreshGUI() {
492
+ const e2 = this.plugins.get("gui");
493
+ e2 && e2.updateDisplay();
494
+ }
495
+ setGUIDomPosition(e2) {
496
+ const t2 = this.plugins.get("gui");
497
+ if (!t2 || !t2.domElement) return null;
498
+ const s2 = t2.domElement;
499
+ return e2.appendChild(s2), { GUIDom: s2, remove: () => {
500
+ s2.parentElement === e2 && e2.removeChild(s2);
501
+ } };
502
+ }
503
+ setOperateOption(e2, t2) {
504
+ const s2 = this.plugins.get("editor"), i2 = this.plugins.get("gizmo");
505
+ switch (e2) {
506
+ case "stats":
507
+ i2 && i2.setStatsVisible(t2);
508
+ break;
509
+ case "axes":
510
+ i2 && i2.setAxesVisible(t2);
511
+ break;
512
+ case "grid":
513
+ i2 && i2.setGridVisible(t2);
514
+ break;
515
+ case "openKey":
516
+ s2 && (s2.config.enableKeyboard = t2);
517
+ }
518
+ }
519
+ setSceneFromClassify(e2) {
520
+ this.scene.children.forEach((e3) => {
521
+ e3.rootInfo;
522
+ });
523
+ }
524
+ pointSyncTransform(e2, t2) {
525
+ const s2 = e2.clone();
526
+ return s2.applyMatrix4(t2.matrixWorld), s2;
527
+ }
528
+ meshGroupCloneMaterial(e2) {
529
+ e2.traverse((e3) => {
530
+ if (e3.isMesh) {
531
+ const t2 = e3, s2 = t2;
532
+ s2.isCloneMaterial || (s2.originMaterial = t2.material, t2.material = Array.isArray(t2.material) ? t2.material.map((e4) => e4.clone()) : t2.material.clone(), s2.isCloneMaterial = true);
533
+ }
534
+ });
535
+ }
536
+ changeMeshMaterial(e2, t2) {
537
+ e2.traverse((e3) => {
538
+ if (e3.isMesh) {
539
+ const s2 = e3;
540
+ (Array.isArray(s2.material) ? s2.material : [s2.material]).forEach((e4) => {
541
+ Object.entries(t2).forEach(([t3, s3]) => {
542
+ t3 in e4 && ("color" === t3 || "emissive" === t3 ? e4[t3].set(s3) : e4[t3] = s3);
543
+ }), e4.needsUpdate = true;
544
+ });
545
+ }
546
+ });
547
+ }
548
+ changeMeshTransform(e2, t2) {
549
+ const s2 = e2;
550
+ if (!s2.meshRevertTransform) {
551
+ const t3 = e2.position.clone(), i2 = e2.rotation.clone(), n2 = e2.scale.clone();
552
+ s2.meshRevertTransform = () => {
553
+ e2.position.copy(t3), e2.rotation.copy(i2), e2.scale.copy(n2);
554
+ };
555
+ }
556
+ 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);
557
+ }
558
+ setGsapMeshAction(e2, s2, i2, n2) {
559
+ const { query: r2 } = n2;
560
+ s2.position && i2.position && (e2.position.set(s2.position.x, s2.position.y, s2.position.z), t.to(e2.position, { x: i2.position.x, y: i2.position.y, z: i2.position.z, ...r2 })), s2.rotation && i2.rotation && (e2.rotation.set(s2.rotation.x, s2.rotation.y, s2.rotation.z), t.to(e2.rotation, { x: i2.rotation.x, y: i2.rotation.y, z: i2.rotation.z, ...r2 })), s2.scale && i2.scale && (e2.scale.set(s2.scale.x, s2.scale.y, s2.scale.z), t.to(e2.scale, { x: i2.scale.x, y: i2.scale.y, z: i2.scale.z, ...r2 }));
561
+ }
562
+ start() {
563
+ this.engine.start();
564
+ }
565
+ stop() {
566
+ this.engine.stop();
567
+ }
568
+ dispose() {
569
+ this.plugins.dispose(), this.engine.dispose(), this.progressList = [], this.mixerList = [], this.shaderList = [], this.commonFrameList = [];
570
+ }
571
+ };
572
+ _D.THREE = e;
573
+ _D.gsap = t;
574
+ let D = _D;
575
+ function j(e2) {
576
+ var _a;
577
+ (_a = e2.geometry) == null ? void 0 : _a.dispose(), Array.isArray(e2.material) ? e2.material.forEach(B) : e2.material && B(e2.material);
578
+ }
579
+ function B(e2) {
580
+ e2.dispose();
581
+ const t2 = e2;
582
+ 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();
583
+ }
584
+ function O(e2) {
585
+ e2.traverse((e3) => {
586
+ e3.isMesh && j(e3);
587
+ });
588
+ }
589
+ function F(t2) {
590
+ for (t2.traverse((e2) => {
591
+ e2.isMesh && j(e2);
592
+ }); t2.children.length > 0; ) t2.remove(t2.children[0]);
593
+ t2.background instanceof e.Texture && t2.background.dispose(), t2.environment && t2.environment.dispose();
594
+ }
595
+ export {
596
+ A as AnimationPlugin,
597
+ p as CSSRendererPlugin,
598
+ E as CameraManager,
599
+ l as ComposerPlugin,
600
+ k as DrawingPlugin,
601
+ d as EditorPlugin,
602
+ I as Engine,
603
+ u as EnvironmentPlugin,
604
+ b as EventEmitter,
605
+ f as GUIPlugin,
606
+ m as GeoMapPlugin,
607
+ G as GeometryPlugin,
608
+ g as GizmoPlugin,
609
+ h as LoaderPlugin,
610
+ M as MaterialPlugin,
611
+ a as OrbitControllerPlugin,
612
+ o as ParticlePlugin,
613
+ q as PhysicsPlugin,
614
+ P as Plugin,
615
+ r as PluginManager,
616
+ z as RendererManager,
617
+ w as SceneManager,
618
+ v as SerializationPlugin,
619
+ S as ShaderPlugin,
620
+ s as TextPlugin,
621
+ D as ThreeEditor,
622
+ c as TransformControllerPlugin,
623
+ Z as clamp,
624
+ a1 as createBox3Helper,
625
+ V as createRaycaster,
626
+ X as degToRad,
627
+ B as disposeMaterial,
628
+ j as disposeMesh,
629
+ O as disposeObject,
630
+ F as disposeScene,
631
+ n as getBestViewTarget,
632
+ i as getDistanceScalePoint,
633
+ a0 as getObjectBox3,
634
+ y as getObjectViews,
635
+ W as getPointAtDistance,
636
+ U as getRootModel,
637
+ N as getWebGLMouse,
638
+ Q as getWebGLMouseFromContainer,
639
+ _ as lerp,
640
+ Y as radToDeg,
641
+ R as raycastObjects,
642
+ $ as smoothstep
643
+ };
644
+ //# sourceMappingURL=index.js.map