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.
@@ -0,0 +1,3411 @@
1
+ import { OrbitControls as e } from "three/examples/jsm/controls/OrbitControls.js";
2
+ import * as t from "three";
3
+ import { TransformControls as n } from "three/examples/jsm/controls/TransformControls.js";
4
+ import { GLTFLoader as s } from "three/examples/jsm/loaders/GLTFLoader.js";
5
+ import { DRACOLoader as i } from "three/examples/jsm/loaders/DRACOLoader.js";
6
+ import { FBXLoader as o } from "three/examples/jsm/loaders/FBXLoader.js";
7
+ import { OBJLoader as r } from "three/examples/jsm/loaders/OBJLoader.js";
8
+ import { MTLLoader as a } from "three/examples/jsm/loaders/MTLLoader.js";
9
+ import { FontLoader as l } from "three/examples/jsm/loaders/FontLoader.js";
10
+ import { EffectComposer as d } from "three/examples/jsm/postprocessing/EffectComposer.js";
11
+ import { RenderPass as c } from "three/examples/jsm/postprocessing/RenderPass.js";
12
+ import { OutlinePass as h } from "three/examples/jsm/postprocessing/OutlinePass.js";
13
+ import { UnrealBloomPass as u } from "three/examples/jsm/postprocessing/UnrealBloomPass.js";
14
+ import { SAOPass as m } from "three/examples/jsm/postprocessing/SAOPass.js";
15
+ import { SSRPass as p } from "three/examples/jsm/postprocessing/SSRPass.js";
16
+ import { ShaderPass as f } from "three/examples/jsm/postprocessing/ShaderPass.js";
17
+ import { FXAAShader as g } from "three/examples/jsm/shaders/FXAAShader.js";
18
+ import { OutputPass as _ } from "three/examples/jsm/postprocessing/OutputPass.js";
19
+ import { CSS2DObject as v, CSS2DRenderer as b } from "three/examples/jsm/renderers/CSS2DRenderer.js";
20
+ import { CSS3DObject as y, CSS3DRenderer as w } from "three/examples/jsm/renderers/CSS3DRenderer.js";
21
+ import x from "three/examples/jsm/libs/stats.module.js";
22
+ import { ViewHelper as C } from "three/examples/jsm/helpers/ViewHelper.js";
23
+ import M from "gsap";
24
+ import P from "proj4";
25
+ import * as S from "cannon-es";
26
+ import { TextGeometry as F } from "three/examples/jsm/geometries/TextGeometry.js";
27
+ import { RGBELoader as E } from "three/examples/jsm/loaders/RGBELoader.js";
28
+ class A {
29
+ constructor(e4) {
30
+ this.plugins = /* @__PURE__ */ new Map(), this.context = { ...e4, pluginManager: this };
31
+ }
32
+ use(e4) {
33
+ const { name: t2 } = e4;
34
+ if (this.plugins.has(t2)) return this;
35
+ if (e4.dependencies) {
36
+ for (const n3 of e4.dependencies) if (!this.plugins.has(n3)) throw new Error(`Plugin "${t2}" depends on "${n3}", but it's not installed`);
37
+ }
38
+ const n2 = e4.install(this.context);
39
+ return n2 instanceof Promise ? n2.then(() => {
40
+ this.plugins.set(t2, e4), this.context.events.emit("plugin:installed", { name: t2 });
41
+ }).catch((e5) => {
42
+ }) : (this.plugins.set(t2, e4), this.context.events.emit("plugin:installed", { name: t2 })), this;
43
+ }
44
+ useAll(e4) {
45
+ for (const t2 of e4) this.use(t2);
46
+ return this;
47
+ }
48
+ get(e4) {
49
+ return this.plugins.get(e4);
50
+ }
51
+ remove(e4) {
52
+ var _a;
53
+ const t2 = this.plugins.get(e4);
54
+ if (!t2) return false;
55
+ for (const [t3, n3] of this.plugins) if ((_a = n3.dependencies) == null ? void 0 : _a.includes(e4)) return false;
56
+ const n2 = t2.uninstall();
57
+ return n2 instanceof Promise ? n2.then(() => {
58
+ this.plugins.delete(e4), this.context.events.emit("plugin:uninstalled", { name: e4 });
59
+ }).catch((e5) => {
60
+ }) : (this.plugins.delete(e4), this.context.events.emit("plugin:uninstalled", { name: e4 })), true;
61
+ }
62
+ has(e4) {
63
+ return this.plugins.has(e4);
64
+ }
65
+ getAll() {
66
+ return Array.from(this.plugins.values());
67
+ }
68
+ getNames() {
69
+ return Array.from(this.plugins.keys());
70
+ }
71
+ dispose() {
72
+ const e4 = Array.from(this.plugins.keys()).reverse();
73
+ for (const t2 of e4) this.remove(t2);
74
+ }
75
+ }
76
+ class k {
77
+ constructor(e4) {
78
+ this._installed = false, this.unsubscribers = [], this.config = e4 ?? {};
79
+ }
80
+ install(e4) {
81
+ var _a;
82
+ this._installed || (this.context = e4, this._installed = true, this.registerLifecycleHooks(), (_a = this.onInstall) == null ? void 0 : _a.call(this));
83
+ }
84
+ uninstall() {
85
+ var _a;
86
+ if (this._installed) {
87
+ (_a = this.onUninstall) == null ? void 0 : _a.call(this);
88
+ for (const e4 of this.unsubscribers) e4();
89
+ this.unsubscribers = [], this._installed = false;
90
+ }
91
+ }
92
+ isInstalled() {
93
+ return this._installed;
94
+ }
95
+ registerLifecycleHooks() {
96
+ const { events: e4 } = this.context;
97
+ if ("function" == typeof this.onSceneReady) {
98
+ const t2 = e4.on("scene:ready", ({ scene: e5 }) => {
99
+ this.onSceneReady(e5);
100
+ });
101
+ this.unsubscribers.push(t2);
102
+ }
103
+ if ("function" == typeof this.onUpdate && this.onUpdate !== k.prototype.onUpdate) {
104
+ const t2 = e4.on("render:before", ({ delta: e5, elapsed: t3 }) => {
105
+ this.onUpdate(e5, t3);
106
+ });
107
+ this.unsubscribers.push(t2);
108
+ }
109
+ if ("function" == typeof this.onResize) {
110
+ const t2 = e4.on("resize", ({ width: e5, height: t3 }) => {
111
+ this.onResize(e5, t3);
112
+ });
113
+ this.unsubscribers.push(t2);
114
+ }
115
+ if ("function" == typeof this.onBeforeDispose) {
116
+ const t2 = e4.on("engine:dispose", () => {
117
+ this.onBeforeDispose();
118
+ });
119
+ this.unsubscribers.push(t2);
120
+ }
121
+ }
122
+ get engine() {
123
+ return this.context.engine;
124
+ }
125
+ get scene() {
126
+ return this.context.engine.scene;
127
+ }
128
+ get camera() {
129
+ return this.context.engine.camera;
130
+ }
131
+ get renderer() {
132
+ return this.context.engine.renderer;
133
+ }
134
+ get events() {
135
+ return this.context.events;
136
+ }
137
+ get pluginManager() {
138
+ return this.context.pluginManager;
139
+ }
140
+ subscribe(e4, t2) {
141
+ const n2 = this.events.on(e4, t2);
142
+ this.unsubscribers.push(n2);
143
+ }
144
+ }
145
+ const T = { enableDamping: true, dampingFactor: 0.05, minDistance: 1, maxDistance: 5e3, minZoom: 1e3, maxPolarAngle: Math.PI, enablePan: true, enableZoom: true, enableRotate: true };
146
+ class L extends k {
147
+ constructor(e4) {
148
+ super({ ...T, ...e4 }), this.name = "orbit-controller", this.viewAngleList = [];
149
+ }
150
+ get controls() {
151
+ return this._controls;
152
+ }
153
+ get target() {
154
+ return this._controls.target;
155
+ }
156
+ onInstall() {
157
+ const { camera: t2, renderer: n2 } = this.engine;
158
+ this._controls = new e(t2, n2.domElement), this.applyConfig(this.config), this.subscribe("render:before", () => {
159
+ this._controls.update();
160
+ }), this._controls.addEventListener("start", () => {
161
+ this.events.emit("controls:start", void 0);
162
+ }), this._controls.addEventListener("end", () => {
163
+ this.events.emit("controls:end", void 0);
164
+ }), this._controls.addEventListener("change", () => {
165
+ this.events.emit("controls:change", void 0);
166
+ });
167
+ }
168
+ onUninstall() {
169
+ this._controls.dispose();
170
+ }
171
+ applyConfig(e4) {
172
+ void 0 !== e4.enableDamping && (this._controls.enableDamping = e4.enableDamping), void 0 !== e4.dampingFactor && (this._controls.dampingFactor = e4.dampingFactor), void 0 !== e4.minDistance && (this._controls.minDistance = e4.minDistance), void 0 !== e4.maxDistance && (this._controls.maxDistance = e4.maxDistance), void 0 !== e4.maxPolarAngle && (this._controls.maxPolarAngle = e4.maxPolarAngle), void 0 !== e4.enablePan && (this._controls.enablePan = e4.enablePan), void 0 !== e4.enableZoom && (this._controls.enableZoom = e4.enableZoom), void 0 !== e4.enableRotate && (this._controls.enableRotate = e4.enableRotate);
173
+ }
174
+ getConfig() {
175
+ return { enableDamping: this._controls.enableDamping, dampingFactor: this._controls.dampingFactor, minDistance: this._controls.minDistance, maxDistance: this._controls.maxDistance, minZoom: this._controls.minZoom, maxPolarAngle: this._controls.maxPolarAngle, enablePan: this._controls.enablePan, enableZoom: this._controls.enableZoom, enableRotate: this._controls.enableRotate };
176
+ }
177
+ setTarget(e4, t2, n2) {
178
+ this._controls.target.set(e4, t2, n2), this._controls.update();
179
+ }
180
+ setEnabled(e4) {
181
+ this._controls.enabled = e4;
182
+ }
183
+ saveViewAngle(e4) {
184
+ const t2 = { position: this.camera.position.clone(), target: this._controls.target.clone() };
185
+ return this.viewAngleList.push(t2), t2;
186
+ }
187
+ getViewAngleList() {
188
+ return this.viewAngleList;
189
+ }
190
+ clearViewAngleList() {
191
+ this.viewAngleList = [];
192
+ }
193
+ reset() {
194
+ this._controls.reset();
195
+ }
196
+ }
197
+ const O = { mode: "translate", space: "world", showX: true, showY: true, showZ: true, translationSnap: null, rotationSnap: null, scaleSnap: null };
198
+ class H extends k {
199
+ constructor(e4) {
200
+ super({ ...O, ...e4 }), this.name = "transform-controller", this.dependencies = ["orbit-controller"], this.box3Helper = null;
201
+ }
202
+ get controls() {
203
+ return this._controls;
204
+ }
205
+ get object() {
206
+ return this._controls.object;
207
+ }
208
+ onInstall() {
209
+ const { camera: e4, renderer: s2, scene: i2 } = this.engine;
210
+ this._controls = new n(e4, s2.domElement), this._controls.name = "TransformControls", this._controls.traverse((e5) => {
211
+ e5.isTransformControls = true;
212
+ }), i2.add(this._controls), this.box3Helper = new t.Box3Helper(new t.Box3(), 16776960), this.box3Helper.name = "Box3Helper", this.box3Helper.visible = false, i2.add(this.box3Helper), this.applyConfig(this.config), this._controls.addEventListener("dragging-changed", (e5) => {
213
+ var _a, _b;
214
+ const t2 = (_a = this.pluginManager) == null ? void 0 : _a.get("orbit-controller");
215
+ t2 && (t2.controls.enabled = !e5.value), (_b = this.dragChangeCallback) == null ? void 0 : _b.call(this, e5.value), e5.value ? this.events.emit("object:transform:start", { object: this._controls.object }) : this.events.emit("object:transform:end", { object: this._controls.object });
216
+ }), this._controls.addEventListener("change", () => {
217
+ if (this._controls.object && (this.events.emit("object:transform:change", { object: this._controls.object }), this.box3Helper && this._controls.object)) {
218
+ const e5 = new t.Box3().setFromObject(this._controls.object);
219
+ this.box3Helper.box = e5, this.box3Helper.visible = true;
220
+ }
221
+ });
222
+ }
223
+ onUninstall() {
224
+ this.detach(), this.scene.remove(this._controls), this._controls.dispose(), this.box3Helper && (this.scene.remove(this.box3Helper), this.box3Helper = null);
225
+ }
226
+ applyConfig(e4) {
227
+ void 0 !== e4.mode && this._controls.setMode(e4.mode), void 0 !== e4.space && this._controls.setSpace(e4.space), void 0 !== e4.showX && (this._controls.showX = e4.showX), void 0 !== e4.showY && (this._controls.showY = e4.showY), void 0 !== e4.showZ && (this._controls.showZ = e4.showZ), void 0 !== e4.translationSnap && this._controls.setTranslationSnap(e4.translationSnap), void 0 !== e4.rotationSnap && this._controls.setRotationSnap(e4.rotationSnap), void 0 !== e4.scaleSnap && this._controls.setScaleSnap(e4.scaleSnap);
228
+ }
229
+ getConfig() {
230
+ return { mode: this._controls.mode, space: this._controls.space, showX: this._controls.showX, showY: this._controls.showY, showZ: this._controls.showZ, translationSnap: this._controls.translationSnap, rotationSnap: this._controls.rotationSnap, scaleSnap: this._controls.scaleSnap ?? null };
231
+ }
232
+ attach(e4) {
233
+ this._controls.attach(e4);
234
+ }
235
+ detach() {
236
+ this._controls.detach(), this.box3Helper && (this.box3Helper.visible = false);
237
+ }
238
+ setMode(e4) {
239
+ this._controls.setMode(e4);
240
+ }
241
+ setSpace(e4) {
242
+ this._controls.setSpace(e4);
243
+ }
244
+ setSize(e4) {
245
+ this._controls.setSize(e4);
246
+ }
247
+ setEnabled(e4) {
248
+ this._controls.enabled = e4;
249
+ }
250
+ showBox3Helper(e4) {
251
+ this.box3Helper && (this.box3Helper.visible = e4);
252
+ }
253
+ }
254
+ const B = { dracoPath: "/draco/", useDraco: true };
255
+ class j extends k {
256
+ constructor(e4) {
257
+ super({ ...B, ...e4 }), this.name = "loader", this.fontCache = /* @__PURE__ */ new Map();
258
+ }
259
+ onInstall() {
260
+ this.dracoLoader = new i(), this.dracoLoader.setDecoderPath(this.config.dracoPath), this.gltfLoader = new s(), this.config.useDraco && this.gltfLoader.setDRACOLoader(this.dracoLoader), this.fbxLoader = new o(), this.objLoader = new r(), this.mtlLoader = new a(), this.textureLoader = new t.TextureLoader(), this.cubeTextureLoader = new t.CubeTextureLoader(), this.fontLoader = new l();
261
+ }
262
+ onUninstall() {
263
+ this.dracoLoader.dispose(), this.fontCache.clear();
264
+ }
265
+ setDracoPath(e4) {
266
+ this.config.dracoPath = e4, this.dracoLoader.setDecoderPath(e4);
267
+ }
268
+ loadModel(e4) {
269
+ const { type: t2, url: n2 } = e4;
270
+ switch (t2) {
271
+ case "GLTF":
272
+ return this.loadGLTF(n2);
273
+ case "FBX":
274
+ return this.loadFBX(n2);
275
+ case "OBJ":
276
+ return this.loadOBJ(n2);
277
+ default:
278
+ throw new Error(`Unsupported model type: ${t2}`);
279
+ }
280
+ }
281
+ loadGLTF(e4) {
282
+ const t2 = { progress: () => {
283
+ }, complete: () => {
284
+ } };
285
+ return this.events.emit("load:start", { url: e4, type: "GLTF" }), this.gltfLoader.load(e4, (n2) => {
286
+ const s2 = n2.scene;
287
+ s2.animations = n2.animations, t2.complete(s2), this.events.emit("load:complete", { url: e4, object: s2 });
288
+ }, (n2) => {
289
+ const s2 = n2.loaded / n2.total;
290
+ t2.progress(s2, n2), this.events.emit("load:progress", { url: e4, loaded: n2.loaded, total: n2.total, percent: s2 });
291
+ }, (t3) => {
292
+ this.events.emit("load:error", { url: e4, error: t3 });
293
+ }), t2;
294
+ }
295
+ loadFBX(e4) {
296
+ const n2 = { progress: () => {
297
+ }, complete: () => {
298
+ } };
299
+ return this.events.emit("load:start", { url: e4, type: "FBX" }), this.fbxLoader.load(e4, (s2) => {
300
+ s2.traverse((e5) => {
301
+ if (e5.isMesh) {
302
+ const n3 = e5;
303
+ Array.isArray(n3.material) ? n3.material.forEach((e6) => {
304
+ e6.side = t.DoubleSide;
305
+ }) : n3.material && (n3.material.side = t.DoubleSide);
306
+ }
307
+ }), n2.complete(s2), this.events.emit("load:complete", { url: e4, object: s2 });
308
+ }, (t2) => {
309
+ const s2 = t2.loaded / t2.total;
310
+ n2.progress(s2, t2), this.events.emit("load:progress", { url: e4, loaded: t2.loaded, total: t2.total, percent: s2 });
311
+ }, (t2) => {
312
+ this.events.emit("load:error", { url: e4, error: t2 });
313
+ }), n2;
314
+ }
315
+ loadOBJ(e4) {
316
+ const t2 = { progress: () => {
317
+ }, complete: () => {
318
+ } };
319
+ this.events.emit("load:start", { url: e4, type: "OBJ" });
320
+ const n2 = e4.replace(".obj", ".mtl");
321
+ return this.mtlLoader.load(n2, (n3) => {
322
+ n3.preload(), this.objLoader.setMaterials(n3), this.objLoader.load(e4, (n4) => {
323
+ t2.complete(n4), this.events.emit("load:complete", { url: e4, object: n4 });
324
+ }, (n4) => {
325
+ const s2 = n4.loaded / n4.total;
326
+ t2.progress(s2, n4), this.events.emit("load:progress", { url: e4, loaded: n4.loaded, total: n4.total, percent: s2 });
327
+ }, (t3) => {
328
+ this.events.emit("load:error", { url: e4, error: t3 });
329
+ });
330
+ }, void 0, () => {
331
+ this.objLoader.load(e4, (n3) => {
332
+ t2.complete(n3), this.events.emit("load:complete", { url: e4, object: n3 });
333
+ }, (e5) => {
334
+ const n3 = e5.loaded / e5.total;
335
+ t2.progress(n3, e5);
336
+ }, (t3) => {
337
+ this.events.emit("load:error", { url: e4, error: t3 });
338
+ });
339
+ }), t2;
340
+ }
341
+ loadTexture(e4) {
342
+ return new Promise((t2, n2) => {
343
+ this.textureLoader.load(e4, t2, void 0, n2);
344
+ });
345
+ }
346
+ loadCubeTexture(e4) {
347
+ return new Promise((t2, n2) => {
348
+ this.cubeTextureLoader.load(e4, t2, void 0, n2);
349
+ });
350
+ }
351
+ loadFont(e4) {
352
+ const t2 = this.fontCache.get(e4);
353
+ return t2 ? Promise.resolve(t2) : new Promise((t3, n2) => {
354
+ this.fontLoader.load(e4, (n3) => {
355
+ this.fontCache.set(e4, n3), t3(n3);
356
+ }, void 0, n2);
357
+ });
358
+ }
359
+ createVideoTexture(e4) {
360
+ const n2 = document.createElement("video");
361
+ return n2.crossOrigin = "anonymous", n2.src = e4, n2.muted = true, n2.loop = true, n2.play(), new t.VideoTexture(n2);
362
+ }
363
+ getMaterials(e4) {
364
+ const t2 = [];
365
+ return e4.traverse((e5) => {
366
+ if (e5.isMesh) {
367
+ const n2 = e5;
368
+ Array.isArray(n2.material) ? t2.push(...n2.material) : n2.material && t2.push(n2.material);
369
+ }
370
+ }), [...new Set(t2)];
371
+ }
372
+ }
373
+ const R = { enabled: true, outline: { enabled: true, edgeStrength: 4, edgeGlow: 0, edgeThickness: 2, pulsePeriod: 0, visibleEdgeColor: 16449071, hiddenEdgeColor: 16449071 }, bloom: { enabled: false, strength: 1.5, radius: 0.4, threshold: 0.85 }, ssao: { enabled: false, intensity: 0.01, scale: 100 }, ssr: { enabled: false, thickness: 0.018, infiniteThick: false, maxDistance: 0.01, opacity: 0.5 }, screenMask: { enabled: false } };
374
+ class z extends k {
375
+ constructor(e4) {
376
+ super({ ...R, ...e4 }), this.name = "composer", this._renderWay = "效果渲染", this.ssrMeshList = [];
377
+ }
378
+ get composer() {
379
+ return this._composer;
380
+ }
381
+ get outlinePass() {
382
+ return this._outlinePass;
383
+ }
384
+ get bloomPass() {
385
+ return this._bloomPass;
386
+ }
387
+ get saoPass() {
388
+ return this._saoPass;
389
+ }
390
+ get ssrPass() {
391
+ return this._ssrPass;
392
+ }
393
+ get renderWay() {
394
+ return this._renderWay;
395
+ }
396
+ onInstall() {
397
+ var _a, _b, _c, _d, _e2, _f;
398
+ const { scene: e4, camera: n2, renderer: s2 } = this.engine, i2 = s2.domElement.parentElement, o2 = i2.clientWidth, r2 = i2.clientHeight, a2 = s2.getPixelRatio();
399
+ this._composer = new d(s2), this._composer.setSize(o2, r2), this._composer.setPixelRatio(a2), this.renderPass = new c(e4, n2), this._composer.addPass(this.renderPass), this._saoPass = new m(e4, n2), this._saoPass.enabled = ((_a = this.config.ssao) == null ? void 0 : _a.enabled) ?? false, this.config.ssao && (this._saoPass.params.saoIntensity = this.config.ssao.intensity, this._saoPass.params.saoScale = this.config.ssao.scale), this._composer.addPass(this._saoPass), this._bloomPass = new u(new t.Vector2(o2, r2), ((_b = this.config.bloom) == null ? void 0 : _b.strength) ?? 1.5, ((_c = this.config.bloom) == null ? void 0 : _c.radius) ?? 0.4, ((_d = this.config.bloom) == null ? void 0 : _d.threshold) ?? 0.85), this._bloomPass.enabled = ((_e2 = this.config.bloom) == null ? void 0 : _e2.enabled) ?? false, this._composer.addPass(this._bloomPass), this._ssrPass = new p({ renderer: s2, scene: e4, camera: n2, width: o2, height: r2, selects: this.ssrMeshList, groundReflector: null }), this._ssrPass.enabled = ((_f = this.config.ssr) == null ? void 0 : _f.enabled) ?? false, this.config.ssr && (this._ssrPass.thickness = this.config.ssr.thickness, this._ssrPass.infiniteThick = this.config.ssr.infiniteThick, this._ssrPass.maxDistance = this.config.ssr.maxDistance, this._ssrPass.opacity = this.config.ssr.opacity), this._composer.addPass(this._ssrPass), this._outlinePass = new h(new t.Vector2(o2, r2), e4, n2), this._outlinePass.renderToScreen = true, this.config.outline && (this._outlinePass.edgeStrength = this.config.outline.edgeStrength, this._outlinePass.edgeGlow = this.config.outline.edgeGlow, this._outlinePass.edgeThickness = this.config.outline.edgeThickness, this._outlinePass.pulsePeriod = this.config.outline.pulsePeriod, this._outlinePass.visibleEdgeColor.set(this.config.outline.visibleEdgeColor), this._outlinePass.hiddenEdgeColor.set(this.config.outline.hiddenEdgeColor)), this._outlinePass.overlayMaterial.blending = t.CustomBlending, this._outlinePass.overlayMaterial.blendSrc = t.OneFactor, this._composer.addPass(this._outlinePass), this.outputPass = new _(), this._composer.addPass(this.outputPass), this._fxaaPass = new f(g), this._fxaaPass.material.uniforms.resolution.value.x = 1 / (o2 * a2), this._fxaaPass.material.uniforms.resolution.value.y = 1 / (r2 * a2), this._composer.addPass(this._fxaaPass);
400
+ }
401
+ onUninstall() {
402
+ this._composer.dispose();
403
+ }
404
+ onResize(e4, t2) {
405
+ const n2 = this.renderer.getPixelRatio();
406
+ this._composer.setSize(e4, t2), this._bloomPass.setSize(e4, t2), this._fxaaPass.material.uniforms.resolution.value.x = 1 / (e4 * n2), this._fxaaPass.material.uniforms.resolution.value.y = 1 / (t2 * n2);
407
+ }
408
+ render() {
409
+ "效果渲染" === this._renderWay ? this._composer.render() : this.renderer.render(this.scene, this.camera);
410
+ }
411
+ setRenderWay(e4) {
412
+ this._renderWay = e4;
413
+ }
414
+ setOutlineObjects(e4) {
415
+ this._outlinePass.selectedObjects = e4;
416
+ }
417
+ clearOutlineObjects() {
418
+ this._outlinePass.selectedObjects = [];
419
+ }
420
+ configureOutline(e4) {
421
+ void 0 !== e4.enabled && (this._outlinePass.enabled = e4.enabled), void 0 !== e4.edgeStrength && (this._outlinePass.edgeStrength = e4.edgeStrength), void 0 !== e4.edgeGlow && (this._outlinePass.edgeGlow = e4.edgeGlow), void 0 !== e4.edgeThickness && (this._outlinePass.edgeThickness = e4.edgeThickness), void 0 !== e4.pulsePeriod && (this._outlinePass.pulsePeriod = e4.pulsePeriod), void 0 !== e4.visibleEdgeColor && this._outlinePass.visibleEdgeColor.set(e4.visibleEdgeColor), void 0 !== e4.hiddenEdgeColor && this._outlinePass.hiddenEdgeColor.set(e4.hiddenEdgeColor);
422
+ }
423
+ configureBloom(e4) {
424
+ void 0 !== e4.enabled && (this._bloomPass.enabled = e4.enabled), void 0 !== e4.strength && (this._bloomPass.strength = e4.strength), void 0 !== e4.radius && (this._bloomPass.radius = e4.radius), void 0 !== e4.threshold && (this._bloomPass.threshold = e4.threshold);
425
+ }
426
+ configureSSAO(e4) {
427
+ void 0 !== e4.enabled && (this._saoPass.enabled = e4.enabled), void 0 !== e4.intensity && (this._saoPass.params.saoIntensity = e4.intensity), void 0 !== e4.scale && (this._saoPass.params.saoScale = e4.scale);
428
+ }
429
+ configureSSR(e4) {
430
+ void 0 !== e4.enabled && (this._ssrPass.enabled = e4.enabled), void 0 !== e4.thickness && (this._ssrPass.thickness = e4.thickness), void 0 !== e4.infiniteThick && (this._ssrPass.infiniteThick = e4.infiniteThick), void 0 !== e4.maxDistance && (this._ssrPass.maxDistance = e4.maxDistance), void 0 !== e4.opacity && (this._ssrPass.opacity = e4.opacity);
431
+ }
432
+ addSSRMesh(e4) {
433
+ this.ssrMeshList.includes(e4) || this.ssrMeshList.push(e4);
434
+ }
435
+ removeSSRMesh(e4) {
436
+ const t2 = this.ssrMeshList.indexOf(e4);
437
+ t2 > -1 && this.ssrMeshList.splice(t2, 1);
438
+ }
439
+ }
440
+ class D extends k {
441
+ constructor() {
442
+ super(...arguments), this.name = "css-renderer", this.CSS2DObject = v, this.CSS3DObject = y;
443
+ }
444
+ get css2dRenderer() {
445
+ return this._css2dRenderer;
446
+ }
447
+ get css3dRenderer() {
448
+ return this._css3dRenderer;
449
+ }
450
+ onInstall() {
451
+ const e4 = this.renderer.domElement.parentElement, t2 = e4.clientWidth, n2 = e4.clientHeight;
452
+ this._css3dRenderer = new w(), this.setupCSSRenderer(this._css3dRenderer, e4, t2, n2), this._css2dRenderer = new b(), this.setupCSSRenderer(this._css2dRenderer, e4, t2, n2);
453
+ }
454
+ setupCSSRenderer(e4, t2, n2, s2) {
455
+ e4.setSize(n2, s2), e4.domElement.style.position = "absolute", e4.domElement.style.top = "0", e4.domElement.style.left = "0", e4.domElement.style.pointerEvents = "none", e4.domElement.style.zIndex = "1", t2.appendChild(e4.domElement);
456
+ }
457
+ onUninstall() {
458
+ var _a, _b;
459
+ (_a = this._css2dRenderer.domElement.parentElement) == null ? void 0 : _a.removeChild(this._css2dRenderer.domElement), (_b = this._css3dRenderer.domElement.parentElement) == null ? void 0 : _b.removeChild(this._css3dRenderer.domElement);
460
+ }
461
+ onUpdate() {
462
+ this._css2dRenderer.render(this.scene, this.camera), this._css3dRenderer.render(this.scene, this.camera);
463
+ }
464
+ onResize(e4, t2) {
465
+ this._css2dRenderer.setSize(e4, t2), this._css3dRenderer.setSize(e4, t2);
466
+ }
467
+ createCSS2DObject(e4, t2, n2 = true) {
468
+ n2 && (e4.style.pointerEvents = "auto");
469
+ const s2 = new v(e4);
470
+ return t2 && s2.position.copy(t2), s2.destroy = () => {
471
+ this.scene.remove(s2);
472
+ }, s2;
473
+ }
474
+ createCSS3DObject(e4, t2, n2 = false) {
475
+ n2 && (e4.style.pointerEvents = "auto");
476
+ const s2 = new y(e4);
477
+ return t2 && s2.position.copy(t2), s2.destroy = () => {
478
+ this.scene.remove(s2);
479
+ }, s2;
480
+ }
481
+ addCSS2D(e4, t2) {
482
+ const n2 = this.createCSS2DObject(e4, t2);
483
+ return this.scene.add(n2), n2;
484
+ }
485
+ addCSS3D(e4, t2) {
486
+ const n2 = this.createCSS3DObject(e4, t2);
487
+ return this.scene.add(n2), n2;
488
+ }
489
+ }
490
+ function G(e4) {
491
+ const n2 = e4.target;
492
+ return new t.Vector2(e4.offsetX / n2.clientWidth * 2 - 1, -e4.offsetY / n2.clientHeight * 2 + 1);
493
+ }
494
+ function U(e4, n2) {
495
+ const s2 = n2.getBoundingClientRect();
496
+ return new t.Vector2((e4.clientX - s2.left) / s2.width * 2 - 1, -(e4.clientY - s2.top) / s2.height * 2 + 1);
497
+ }
498
+ function I(e4, n2, s2) {
499
+ const i2 = new t.Raycaster();
500
+ i2.setFromCamera(e4, n2);
501
+ return i2.intersectObjects(s2, true).filter((e5) => {
502
+ const t2 = e5.object;
503
+ return !(t2.isTransformControls || "TransformControls" === t2.text) && t2.isMesh && t2.visible;
504
+ });
505
+ }
506
+ function V(e4) {
507
+ let t2 = e4;
508
+ for (; t2.parent && "Scene" !== t2.parent.type; ) t2 = t2.parent;
509
+ return t2;
510
+ }
511
+ function N(e4) {
512
+ const n2 = new t.Raycaster();
513
+ return { raycaster: n2, getIntersects(t2, s2) {
514
+ const i2 = G(t2);
515
+ return n2.setFromCamera(i2, e4), n2.intersectObjects(s2, true);
516
+ }, setRange(e5, t2) {
517
+ n2.near = e5, n2.far = t2;
518
+ } };
519
+ }
520
+ const X = { modes: ["选择", "根选择", "变换", "场景绘制", "点击信息"], defaultMode: "变换", isTransformChildren: false, enableKeyboard: false };
521
+ class W extends k {
522
+ constructor(e4) {
523
+ super({ ...X, ...e4 }), this.name = "editor", this.dependencies = ["transform-controller", "composer"], this._currentInfo = null, this.keydownHandler = null, this._mode = this.config.defaultMode || "变换";
524
+ }
525
+ get mode() {
526
+ return this._mode;
527
+ }
528
+ get currentInfo() {
529
+ return this._currentInfo;
530
+ }
531
+ get isTransformChildren() {
532
+ return this.config.isTransformChildren;
533
+ }
534
+ set isTransformChildren(e4) {
535
+ this.config.isTransformChildren = e4;
536
+ }
537
+ onInstall() {
538
+ this.config.enableKeyboard && this.enableKeyboard();
539
+ }
540
+ onUninstall() {
541
+ this.disableKeyboard();
542
+ }
543
+ setMode(e4) {
544
+ const t2 = this._mode;
545
+ this._mode = e4, this.events.emit("mode:change", { mode: e4, previous: t2 });
546
+ }
547
+ handleClick(e4) {
548
+ var _a;
549
+ const n2 = this.getPlugin("transform-controller"), s2 = this.getPlugin("composer");
550
+ if (!n2 || !s2) return null;
551
+ n2.detach();
552
+ const i2 = this.renderer.domElement.getBoundingClientRect(), o2 = I(new t.Vector2((e4.clientX - i2.left) / i2.width * 2 - 1, -(e4.clientY - i2.top) / i2.height * 2 + 1), this.camera, this.scene.children).find((e5) => {
553
+ e5.object;
554
+ const t2 = V(e5.object);
555
+ return e5.object.visible && t2.visible;
556
+ });
557
+ if (!o2) return this._currentInfo = null, this.events.emit("click", { event: e4, info: null }), null;
558
+ const { object: r2, point: a2 } = o2, l2 = V(r2);
559
+ switch (this._mode) {
560
+ case "变换":
561
+ s2.clearOutlineObjects(), this.config.isTransformChildren ? n2.attach(r2) : n2.attach(l2);
562
+ break;
563
+ case "选择":
564
+ s2.setOutlineObjects([r2]);
565
+ break;
566
+ case "根选择":
567
+ s2.setOutlineObjects([l2]);
568
+ break;
569
+ case "场景绘制":
570
+ (_a = this.drawEventCallback) == null ? void 0 : _a.call(this, a2, r2);
571
+ }
572
+ return this._currentInfo = { currentModel: r2, currentRootModel: l2, point: a2.clone(), mode: this._mode }, this.events.emit("click", { event: e4, info: this._currentInfo }), this.events.emit("object:selected", { object: "选择" === this._mode ? r2 : l2, previous: null }), this._currentInfo;
573
+ }
574
+ getRawRaycast(e4, n2) {
575
+ const s2 = G(e4), i2 = new t.Raycaster();
576
+ i2.setFromCamera(s2, this.camera);
577
+ const o2 = n2 || this.scene.children, r2 = i2.intersectObjects(o2, true);
578
+ return { raycaster: i2, intersects: r2 };
579
+ }
580
+ select(e4) {
581
+ var _a, _b;
582
+ const t2 = this.getPlugin("transform-controller"), n2 = this.getPlugin("composer");
583
+ t2 && n2 && (e4 ? ("变换" === this._mode && t2.attach(e4), n2.setOutlineObjects([e4]), this.events.emit("object:selected", { object: e4, previous: ((_a = this._currentInfo) == null ? void 0 : _a.currentModel) || null })) : (t2.detach(), n2.clearOutlineObjects(), this.events.emit("object:deselected", { object: (_b = this._currentInfo) == null ? void 0 : _b.currentModel })));
584
+ }
585
+ deselect() {
586
+ this.select(null), this._currentInfo = null;
587
+ }
588
+ enableKeyboard() {
589
+ if (this.keydownHandler) return;
590
+ const e4 = this.getPlugin("transform-controller");
591
+ this.keydownHandler = (t2) => {
592
+ var _a;
593
+ if (e4) switch (t2.key.toLowerCase()) {
594
+ case "w":
595
+ e4.setMode("translate");
596
+ break;
597
+ case "e":
598
+ e4.setMode("rotate");
599
+ break;
600
+ case "r":
601
+ e4.setMode("scale");
602
+ break;
603
+ case "escape":
604
+ this.deselect();
605
+ break;
606
+ case "delete":
607
+ case "backspace":
608
+ ((_a = this._currentInfo) == null ? void 0 : _a.currentRootModel) && (this.scene.remove(this._currentInfo.currentRootModel), this.deselect());
609
+ }
610
+ }, document.addEventListener("keydown", this.keydownHandler), this.config.enableKeyboard = true;
611
+ }
612
+ disableKeyboard() {
613
+ this.keydownHandler && (document.removeEventListener("keydown", this.keydownHandler), this.keydownHandler = null), this.config.enableKeyboard = false;
614
+ }
615
+ getPlugin(e4) {
616
+ var _a;
617
+ return (_a = this.pluginManager) == null ? void 0 : _a.get(e4);
618
+ }
619
+ }
620
+ function J(e4, t2) {
621
+ var n2 = e4.__state.conversionName.toString(), s2 = Math.round(e4.r), i2 = Math.round(e4.g), o2 = Math.round(e4.b), r2 = e4.a, a2 = Math.round(e4.h), l2 = e4.s.toFixed(1), d2 = e4.v.toFixed(1);
622
+ if (t2 || "THREE_CHAR_HEX" === n2 || "SIX_CHAR_HEX" === n2) {
623
+ for (var c2 = e4.hex.toString(16); c2.length < 6; ) c2 = "0" + c2;
624
+ return "#" + c2;
625
+ }
626
+ return "CSS_RGB" === n2 ? "rgb(" + s2 + "," + i2 + "," + o2 + ")" : "CSS_RGBA" === n2 ? "rgba(" + s2 + "," + i2 + "," + o2 + "," + r2 + ")" : "HEX" === n2 ? "0x" + e4.hex.toString(16) : "RGB_ARRAY" === n2 ? "[" + s2 + "," + i2 + "," + o2 + "]" : "RGBA_ARRAY" === n2 ? "[" + s2 + "," + i2 + "," + o2 + "," + r2 + "]" : "RGB_OBJ" === n2 ? "{r:" + s2 + ",g:" + i2 + ",b:" + o2 + "}" : "RGBA_OBJ" === n2 ? "{r:" + s2 + ",g:" + i2 + ",b:" + o2 + ",a:" + r2 + "}" : "HSV_OBJ" === n2 ? "{h:" + a2 + ",s:" + l2 + ",v:" + d2 + "}" : "HSVA_OBJ" === n2 ? "{h:" + a2 + ",s:" + l2 + ",v:" + d2 + ",a:" + r2 + "}" : "unknown format";
627
+ }
628
+ var Y = Array.prototype.forEach, K = Array.prototype.slice, Z = { BREAK: {}, extend: function(e4) {
629
+ return this.each(K.call(arguments, 1), function(t2) {
630
+ (this.isObject(t2) ? Object.keys(t2) : []).forEach((function(n2) {
631
+ this.isUndefined(t2[n2]) || (e4[n2] = t2[n2]);
632
+ }).bind(this));
633
+ }, this), e4;
634
+ }, defaults: function(e4) {
635
+ return this.each(K.call(arguments, 1), function(t2) {
636
+ (this.isObject(t2) ? Object.keys(t2) : []).forEach((function(n2) {
637
+ this.isUndefined(e4[n2]) && (e4[n2] = t2[n2]);
638
+ }).bind(this));
639
+ }, this), e4;
640
+ }, compose: function() {
641
+ var e4 = K.call(arguments);
642
+ return function() {
643
+ for (var t2 = K.call(arguments), n2 = e4.length - 1; n2 >= 0; n2--) t2 = [e4[n2].apply(this, t2)];
644
+ return t2[0];
645
+ };
646
+ }, each: function(e4, t2, n2) {
647
+ if (e4) {
648
+ if (Y && e4.forEach && e4.forEach === Y) e4.forEach(t2, n2);
649
+ else if (e4.length === e4.length + 0) {
650
+ var s2, i2 = void 0;
651
+ for (i2 = 0, s2 = e4.length; i2 < s2; i2++) if (i2 in e4 && t2.call(n2, e4[i2], i2) === this.BREAK) return;
652
+ } else for (var o2 in e4) if (t2.call(n2, e4[o2], o2) === this.BREAK) return;
653
+ }
654
+ }, defer: function(e4) {
655
+ setTimeout(e4, 0);
656
+ }, debounce: function(e4, t2, n2) {
657
+ var s2 = void 0;
658
+ return function() {
659
+ var i2 = this, o2 = arguments;
660
+ var r2 = n2 || !s2;
661
+ clearTimeout(s2), s2 = setTimeout(function() {
662
+ s2 = null, n2 || e4.apply(i2, o2);
663
+ }, t2), r2 && e4.apply(i2, o2);
664
+ };
665
+ }, toArray: function(e4) {
666
+ return e4.toArray ? e4.toArray() : K.call(e4);
667
+ }, isUndefined: function(e4) {
668
+ return void 0 === e4;
669
+ }, isNull: function(e4) {
670
+ return null === e4;
671
+ }, isNaN: function(e4) {
672
+ function t2(t3) {
673
+ return e4.apply(this, arguments);
674
+ }
675
+ return t2.toString = function() {
676
+ return e4.toString();
677
+ }, t2;
678
+ }(function(e4) {
679
+ return isNaN(e4);
680
+ }), isArray: Array.isArray || function(e4) {
681
+ return e4.constructor === Array;
682
+ }, isObject: function(e4) {
683
+ return e4 === Object(e4);
684
+ }, isNumber: function(e4) {
685
+ return e4 === e4 + 0;
686
+ }, isString: function(e4) {
687
+ return e4 === e4 + "";
688
+ }, isBoolean: function(e4) {
689
+ return false === e4 || true === e4;
690
+ }, isFunction: function(e4) {
691
+ return e4 instanceof Function;
692
+ } }, q = [{ litmus: Z.isString, conversions: { THREE_CHAR_HEX: { read: function(e4) {
693
+ var t2 = e4.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);
694
+ return null !== t2 && { space: "HEX", hex: parseInt("0x" + t2[1].toString() + t2[1].toString() + t2[2].toString() + t2[2].toString() + t2[3].toString() + t2[3].toString(), 0) };
695
+ }, write: J }, SIX_CHAR_HEX: { read: function(e4) {
696
+ var t2 = e4.match(/^#([A-F0-9]{6})$/i);
697
+ return null !== t2 && { space: "HEX", hex: parseInt("0x" + t2[1].toString(), 0) };
698
+ }, write: J }, CSS_RGB: { read: function(e4) {
699
+ var t2 = e4.match(/^rgb\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);
700
+ return null !== t2 && { space: "RGB", r: parseFloat(t2[1]), g: parseFloat(t2[2]), b: parseFloat(t2[3]) };
701
+ }, write: J }, CSS_RGBA: { read: function(e4) {
702
+ var t2 = e4.match(/^rgba\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);
703
+ return null !== t2 && { space: "RGB", r: parseFloat(t2[1]), g: parseFloat(t2[2]), b: parseFloat(t2[3]), a: parseFloat(t2[4]) };
704
+ }, write: J } } }, { litmus: Z.isNumber, conversions: { HEX: { read: function(e4) {
705
+ return { space: "HEX", hex: e4, conversionName: "HEX" };
706
+ }, write: function(e4) {
707
+ return e4.hex;
708
+ } } } }, { litmus: Z.isArray, conversions: { RGB_ARRAY: { read: function(e4) {
709
+ return 3 === e4.length && { space: "RGB", r: e4[0], g: e4[1], b: e4[2] };
710
+ }, write: function(e4) {
711
+ return [e4.r, e4.g, e4.b];
712
+ } }, RGBA_ARRAY: { read: function(e4) {
713
+ return 4 === e4.length && { space: "RGB", r: e4[0], g: e4[1], b: e4[2], a: e4[3] };
714
+ }, write: function(e4) {
715
+ return [e4.r, e4.g, e4.b, e4.a];
716
+ } } } }, { litmus: Z.isObject, conversions: { RGBA_OBJ: { read: function(e4) {
717
+ return !!(Z.isNumber(e4.r) && Z.isNumber(e4.g) && Z.isNumber(e4.b) && Z.isNumber(e4.a)) && { space: "RGB", r: e4.r, g: e4.g, b: e4.b, a: e4.a };
718
+ }, write: function(e4) {
719
+ return { r: e4.r, g: e4.g, b: e4.b, a: e4.a };
720
+ } }, RGB_OBJ: { read: function(e4) {
721
+ return !!(Z.isNumber(e4.r) && Z.isNumber(e4.g) && Z.isNumber(e4.b)) && { space: "RGB", r: e4.r, g: e4.g, b: e4.b };
722
+ }, write: function(e4) {
723
+ return { r: e4.r, g: e4.g, b: e4.b };
724
+ } }, HSVA_OBJ: { read: function(e4) {
725
+ return !!(Z.isNumber(e4.h) && Z.isNumber(e4.s) && Z.isNumber(e4.v) && Z.isNumber(e4.a)) && { space: "HSV", h: e4.h, s: e4.s, v: e4.v, a: e4.a };
726
+ }, write: function(e4) {
727
+ return { h: e4.h, s: e4.s, v: e4.v, a: e4.a };
728
+ } }, HSV_OBJ: { read: function(e4) {
729
+ return !!(Z.isNumber(e4.h) && Z.isNumber(e4.s) && Z.isNumber(e4.v)) && { space: "HSV", h: e4.h, s: e4.s, v: e4.v };
730
+ }, write: function(e4) {
731
+ return { h: e4.h, s: e4.s, v: e4.v };
732
+ } } } }], Q = void 0, $ = void 0, ee = function() {
733
+ $ = false;
734
+ var e4 = arguments.length > 1 ? Z.toArray(arguments) : arguments[0];
735
+ return Z.each(q, function(t2) {
736
+ if (t2.litmus(e4)) return Z.each(t2.conversions, function(t3, n2) {
737
+ if (Q = t3.read(e4), false === $ && false !== Q) return $ = Q, Q.conversionName = n2, Q.conversion = t3, Z.BREAK;
738
+ }), Z.BREAK;
739
+ }), $;
740
+ }, te = void 0, ne = { hsv_to_rgb: function(e4, t2, n2) {
741
+ var s2 = Math.floor(e4 / 60) % 6, i2 = e4 / 60 - Math.floor(e4 / 60), o2 = n2 * (1 - t2), r2 = n2 * (1 - i2 * t2), a2 = n2 * (1 - (1 - i2) * t2), l2 = [[n2, a2, o2], [r2, n2, o2], [o2, n2, a2], [o2, r2, n2], [a2, o2, n2], [n2, o2, r2]][s2];
742
+ return { r: 255 * l2[0], g: 255 * l2[1], b: 255 * l2[2] };
743
+ }, rgb_to_hsv: function(e4, t2, n2) {
744
+ var s2 = Math.min(e4, t2, n2), i2 = Math.max(e4, t2, n2), o2 = i2 - s2, r2 = void 0;
745
+ return 0 === i2 ? { h: NaN, s: 0, v: 0 } : (r2 = e4 === i2 ? (t2 - n2) / o2 : t2 === i2 ? 2 + (n2 - e4) / o2 : 4 + (e4 - t2) / o2, (r2 /= 6) < 0 && (r2 += 1), { h: 360 * r2, s: o2 / i2, v: i2 / 255 });
746
+ }, rgb_to_hex: function(e4, t2, n2) {
747
+ var s2 = this.hex_with_component(0, 2, e4);
748
+ return s2 = this.hex_with_component(s2, 1, t2), s2 = this.hex_with_component(s2, 0, n2);
749
+ }, component_from_hex: function(e4, t2) {
750
+ return e4 >> 8 * t2 & 255;
751
+ }, hex_with_component: function(e4, t2, n2) {
752
+ return n2 << (te = 8 * t2) | e4 & ~(255 << te);
753
+ } }, se = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e4) {
754
+ return typeof e4;
755
+ } : function(e4) {
756
+ return e4 && "function" == typeof Symbol && e4.constructor === Symbol && e4 !== Symbol.prototype ? "symbol" : typeof e4;
757
+ }, ie = function(e4, t2) {
758
+ if (!(e4 instanceof t2)) throw new TypeError("Cannot call a class as a function");
759
+ }, oe = /* @__PURE__ */ function() {
760
+ function e4(e5, t2) {
761
+ for (var n2 = 0; n2 < t2.length; n2++) {
762
+ var s2 = t2[n2];
763
+ s2.enumerable = s2.enumerable || false, s2.configurable = true, "value" in s2 && (s2.writable = true), Object.defineProperty(e5, s2.key, s2);
764
+ }
765
+ }
766
+ return function(t2, n2, s2) {
767
+ return n2 && e4(t2.prototype, n2), s2 && e4(t2, s2), t2;
768
+ };
769
+ }(), re = function e2(t2, n2, s2) {
770
+ null === t2 && (t2 = Function.prototype);
771
+ var i2 = Object.getOwnPropertyDescriptor(t2, n2);
772
+ if (void 0 === i2) {
773
+ var o2 = Object.getPrototypeOf(t2);
774
+ return null === o2 ? void 0 : e2(o2, n2, s2);
775
+ }
776
+ if ("value" in i2) return i2.value;
777
+ var r2 = i2.get;
778
+ return void 0 !== r2 ? r2.call(s2) : void 0;
779
+ }, ae = function(e4, t2) {
780
+ if ("function" != typeof t2 && null !== t2) throw new TypeError("Super expression must either be null or a function, not " + typeof t2);
781
+ e4.prototype = Object.create(t2 && t2.prototype, { constructor: { value: e4, enumerable: false, writable: true, configurable: true } }), t2 && (Object.setPrototypeOf ? Object.setPrototypeOf(e4, t2) : e4.__proto__ = t2);
782
+ }, le = function(e4, t2) {
783
+ if (!e4) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
784
+ return !t2 || "object" != typeof t2 && "function" != typeof t2 ? e4 : t2;
785
+ }, de = function() {
786
+ function e4() {
787
+ if (ie(this, e4), this.__state = ee.apply(this, arguments), false === this.__state) throw new Error("Failed to interpret color arguments");
788
+ this.__state.a = this.__state.a || 1;
789
+ }
790
+ return oe(e4, [{ key: "toString", value: function() {
791
+ return J(this);
792
+ } }, { key: "toHexString", value: function() {
793
+ return J(this, true);
794
+ } }, { key: "toOriginal", value: function() {
795
+ return this.__state.conversion.write(this);
796
+ } }]), e4;
797
+ }();
798
+ function ce(e4, t2, n2) {
799
+ Object.defineProperty(e4, t2, { get: function() {
800
+ return "RGB" === this.__state.space || de.recalculateRGB(this, t2, n2), this.__state[t2];
801
+ }, set: function(e5) {
802
+ "RGB" !== this.__state.space && (de.recalculateRGB(this, t2, n2), this.__state.space = "RGB"), this.__state[t2] = e5;
803
+ } });
804
+ }
805
+ function he(e4, t2) {
806
+ Object.defineProperty(e4, t2, { get: function() {
807
+ return "HSV" === this.__state.space || de.recalculateHSV(this), this.__state[t2];
808
+ }, set: function(e5) {
809
+ "HSV" !== this.__state.space && (de.recalculateHSV(this), this.__state.space = "HSV"), this.__state[t2] = e5;
810
+ } });
811
+ }
812
+ de.recalculateRGB = function(e4, t2, n2) {
813
+ if ("HEX" === e4.__state.space) e4.__state[t2] = ne.component_from_hex(e4.__state.hex, n2);
814
+ else {
815
+ if ("HSV" !== e4.__state.space) throw new Error("Corrupted color state");
816
+ Z.extend(e4.__state, ne.hsv_to_rgb(e4.__state.h, e4.__state.s, e4.__state.v));
817
+ }
818
+ }, de.recalculateHSV = function(e4) {
819
+ var t2 = ne.rgb_to_hsv(e4.r, e4.g, e4.b);
820
+ Z.extend(e4.__state, { s: t2.s, v: t2.v }), Z.isNaN(t2.h) ? Z.isUndefined(e4.__state.h) && (e4.__state.h = 0) : e4.__state.h = t2.h;
821
+ }, de.COMPONENTS = ["r", "g", "b", "h", "s", "v", "hex", "a"], ce(de.prototype, "r", 2), ce(de.prototype, "g", 1), ce(de.prototype, "b", 0), he(de.prototype, "h"), he(de.prototype, "s"), he(de.prototype, "v"), Object.defineProperty(de.prototype, "a", { get: function() {
822
+ return this.__state.a;
823
+ }, set: function(e4) {
824
+ this.__state.a = e4;
825
+ } }), Object.defineProperty(de.prototype, "hex", { get: function() {
826
+ return "HEX" !== this.__state.space && (this.__state.hex = ne.rgb_to_hex(this.r, this.g, this.b), this.__state.space = "HEX"), this.__state.hex;
827
+ }, set: function(e4) {
828
+ this.__state.space = "HEX", this.__state.hex = e4;
829
+ } });
830
+ var ue = function() {
831
+ function e4(t2, n2) {
832
+ ie(this, e4), this.initialValue = t2[n2], this.domElement = document.createElement("div"), this.object = t2, this.property = n2, this.__onChange = void 0, this.__onFinishChange = void 0;
833
+ }
834
+ return oe(e4, [{ key: "onChange", value: function(e5) {
835
+ return this.__onChange = e5, this;
836
+ } }, { key: "onFinishChange", value: function(e5) {
837
+ return this.__onFinishChange = e5, this;
838
+ } }, { key: "setValue", value: function(e5) {
839
+ return this.object[this.property] = e5, this.__onChange && this.__onChange.call(this, e5), this.updateDisplay(), this;
840
+ } }, { key: "getValue", value: function() {
841
+ return this.object[this.property];
842
+ } }, { key: "updateDisplay", value: function() {
843
+ return this;
844
+ } }, { key: "isModified", value: function() {
845
+ return this.initialValue !== this.getValue();
846
+ } }]), e4;
847
+ }(), me = {};
848
+ Z.each({ HTMLEvents: ["change"], MouseEvents: ["click", "mousemove", "mousedown", "mouseup", "mouseover"], KeyboardEvents: ["keydown"] }, function(e4, t2) {
849
+ Z.each(e4, function(e5) {
850
+ me[e5] = t2;
851
+ });
852
+ });
853
+ var pe = /(\d+(\.\d+)?)px/;
854
+ function fe(e4) {
855
+ if ("0" === e4 || Z.isUndefined(e4)) return 0;
856
+ var t2 = e4.match(pe);
857
+ return Z.isNull(t2) ? 0 : parseFloat(t2[1]);
858
+ }
859
+ var ge = { makeSelectable: function(e4, t2) {
860
+ void 0 !== e4 && void 0 !== e4.style && (e4.onselectstart = t2 ? function() {
861
+ return false;
862
+ } : function() {
863
+ }, e4.style.MozUserSelect = t2 ? "auto" : "none", e4.style.KhtmlUserSelect = t2 ? "auto" : "none", e4.unselectable = t2 ? "on" : "off");
864
+ }, makeFullscreen: function(e4, t2, n2) {
865
+ var s2 = n2, i2 = t2;
866
+ Z.isUndefined(i2) && (i2 = true), Z.isUndefined(s2) && (s2 = true), e4.style.position = "absolute", i2 && (e4.style.left = 0, e4.style.right = 0), s2 && (e4.style.top = 0, e4.style.bottom = 0);
867
+ }, fakeEvent: function(e4, t2, n2, s2) {
868
+ var i2 = n2 || {}, o2 = me[t2];
869
+ if (!o2) throw new Error("Event type " + t2 + " not supported.");
870
+ var r2 = document.createEvent(o2);
871
+ switch (o2) {
872
+ case "MouseEvents":
873
+ var a2 = i2.x || i2.clientX || 0, l2 = i2.y || i2.clientY || 0;
874
+ r2.initMouseEvent(t2, i2.bubbles || false, i2.cancelable || true, window, i2.clickCount || 1, 0, 0, a2, l2, false, false, false, false, 0, null);
875
+ break;
876
+ case "KeyboardEvents":
877
+ var d2 = r2.initKeyboardEvent || r2.initKeyEvent;
878
+ Z.defaults(i2, { cancelable: true, ctrlKey: false, altKey: false, shiftKey: false, metaKey: false, keyCode: void 0, charCode: void 0 }), d2(t2, i2.bubbles || false, i2.cancelable, window, i2.ctrlKey, i2.altKey, i2.shiftKey, i2.metaKey, i2.keyCode, i2.charCode);
879
+ break;
880
+ default:
881
+ r2.initEvent(t2, i2.bubbles || false, i2.cancelable || true);
882
+ }
883
+ Z.defaults(r2, s2), e4.dispatchEvent(r2);
884
+ }, bind: function(e4, t2, n2, s2) {
885
+ var i2 = s2 || false;
886
+ return e4.addEventListener ? e4.addEventListener(t2, n2, i2) : e4.attachEvent && e4.attachEvent("on" + t2, n2), ge;
887
+ }, unbind: function(e4, t2, n2, s2) {
888
+ var i2 = s2 || false;
889
+ return e4.removeEventListener ? e4.removeEventListener(t2, n2, i2) : e4.detachEvent && e4.detachEvent("on" + t2, n2), ge;
890
+ }, addClass: function(e4, t2) {
891
+ if (void 0 === e4.className) e4.className = t2;
892
+ else if (e4.className !== t2) {
893
+ var n2 = e4.className.split(/ +/);
894
+ -1 === n2.indexOf(t2) && (n2.push(t2), e4.className = n2.join(" ").replace(/^\s+/, "").replace(/\s+$/, ""));
895
+ }
896
+ return ge;
897
+ }, removeClass: function(e4, t2) {
898
+ if (t2) if (e4.className === t2) e4.removeAttribute("class");
899
+ else {
900
+ var n2 = e4.className.split(/ +/), s2 = n2.indexOf(t2);
901
+ -1 !== s2 && (n2.splice(s2, 1), e4.className = n2.join(" "));
902
+ }
903
+ else e4.className = void 0;
904
+ return ge;
905
+ }, hasClass: function(e4, t2) {
906
+ return new RegExp("(?:^|\\s+)" + t2 + "(?:\\s+|$)").test(e4.className) || false;
907
+ }, getWidth: function(e4) {
908
+ var t2 = getComputedStyle(e4);
909
+ return fe(t2["border-left-width"]) + fe(t2["border-right-width"]) + fe(t2["padding-left"]) + fe(t2["padding-right"]) + fe(t2.width);
910
+ }, getHeight: function(e4) {
911
+ var t2 = getComputedStyle(e4);
912
+ return fe(t2["border-top-width"]) + fe(t2["border-bottom-width"]) + fe(t2["padding-top"]) + fe(t2["padding-bottom"]) + fe(t2.height);
913
+ }, getOffset: function(e4) {
914
+ var t2 = e4, n2 = { left: 0, top: 0 };
915
+ if (t2.offsetParent) do {
916
+ n2.left += t2.offsetLeft, n2.top += t2.offsetTop, t2 = t2.offsetParent;
917
+ } while (t2);
918
+ return n2;
919
+ }, isActive: function(e4) {
920
+ return e4 === document.activeElement && (e4.type || e4.href);
921
+ } }, _e = function() {
922
+ function e4(t2, n2) {
923
+ ie(this, e4);
924
+ var s2 = le(this, (e4.__proto__ || Object.getPrototypeOf(e4)).call(this, t2, n2)), i2 = s2;
925
+ return s2.__prev = s2.getValue(), s2.__checkbox = document.createElement("input"), s2.__checkbox.setAttribute("type", "checkbox"), ge.bind(s2.__checkbox, "change", function() {
926
+ i2.setValue(!i2.__prev);
927
+ }, false), s2.domElement.appendChild(s2.__checkbox), s2.updateDisplay(), s2;
928
+ }
929
+ return ae(e4, ue), oe(e4, [{ key: "setValue", value: function(t2) {
930
+ var n2 = re(e4.prototype.__proto__ || Object.getPrototypeOf(e4.prototype), "setValue", this).call(this, t2);
931
+ return this.__onFinishChange && this.__onFinishChange.call(this, this.getValue()), this.__prev = this.getValue(), n2;
932
+ } }, { key: "updateDisplay", value: function() {
933
+ return true === this.getValue() ? (this.__checkbox.setAttribute("checked", "checked"), this.__checkbox.checked = true, this.__prev = true) : (this.__checkbox.checked = false, this.__prev = false), re(e4.prototype.__proto__ || Object.getPrototypeOf(e4.prototype), "updateDisplay", this).call(this);
934
+ } }]), e4;
935
+ }(), ve = function() {
936
+ function e4(t2, n2, s2) {
937
+ ie(this, e4);
938
+ var i2 = le(this, (e4.__proto__ || Object.getPrototypeOf(e4)).call(this, t2, n2)), o2 = s2, r2 = i2;
939
+ if (i2.__select = document.createElement("select"), Z.isArray(o2)) {
940
+ var a2 = {};
941
+ Z.each(o2, function(e5) {
942
+ a2[e5] = e5;
943
+ }), o2 = a2;
944
+ }
945
+ return Z.each(o2, function(e5, t3) {
946
+ var n3 = document.createElement("option");
947
+ n3.innerHTML = t3, n3.setAttribute("value", e5), r2.__select.appendChild(n3);
948
+ }), i2.updateDisplay(), ge.bind(i2.__select, "change", function() {
949
+ var e5 = this.options[this.selectedIndex].value;
950
+ r2.setValue(e5);
951
+ }), i2.domElement.appendChild(i2.__select), i2;
952
+ }
953
+ return ae(e4, ue), oe(e4, [{ key: "setValue", value: function(t2) {
954
+ var n2 = re(e4.prototype.__proto__ || Object.getPrototypeOf(e4.prototype), "setValue", this).call(this, t2);
955
+ return this.__onFinishChange && this.__onFinishChange.call(this, this.getValue()), n2;
956
+ } }, { key: "updateDisplay", value: function() {
957
+ return ge.isActive(this.__select) ? this : (this.__select.value = this.getValue(), re(e4.prototype.__proto__ || Object.getPrototypeOf(e4.prototype), "updateDisplay", this).call(this));
958
+ } }]), e4;
959
+ }(), be = function() {
960
+ function e4(t2, n2) {
961
+ ie(this, e4);
962
+ var s2 = le(this, (e4.__proto__ || Object.getPrototypeOf(e4)).call(this, t2, n2)), i2 = s2;
963
+ function o2() {
964
+ i2.setValue(i2.__input.value);
965
+ }
966
+ return s2.__input = document.createElement("input"), s2.__input.setAttribute("type", "text"), ge.bind(s2.__input, "keyup", o2), ge.bind(s2.__input, "change", o2), ge.bind(s2.__input, "blur", function() {
967
+ i2.__onFinishChange && i2.__onFinishChange.call(i2, i2.getValue());
968
+ }), ge.bind(s2.__input, "keydown", function(e5) {
969
+ 13 === e5.keyCode && this.blur();
970
+ }), s2.updateDisplay(), s2.domElement.appendChild(s2.__input), s2;
971
+ }
972
+ return ae(e4, ue), oe(e4, [{ key: "updateDisplay", value: function() {
973
+ return ge.isActive(this.__input) || (this.__input.value = this.getValue()), re(e4.prototype.__proto__ || Object.getPrototypeOf(e4.prototype), "updateDisplay", this).call(this);
974
+ } }]), e4;
975
+ }();
976
+ function ye(e4) {
977
+ var t2 = e4.toString();
978
+ return t2.indexOf(".") > -1 ? t2.length - t2.indexOf(".") - 1 : 0;
979
+ }
980
+ var we = function() {
981
+ function e4(t2, n2, s2) {
982
+ ie(this, e4);
983
+ var i2 = le(this, (e4.__proto__ || Object.getPrototypeOf(e4)).call(this, t2, n2)), o2 = s2 || {};
984
+ return i2.__min = o2.min, i2.__max = o2.max, i2.__step = o2.step, Z.isUndefined(i2.__step) ? 0 === i2.initialValue ? i2.__impliedStep = 1 : i2.__impliedStep = Math.pow(10, Math.floor(Math.log(Math.abs(i2.initialValue)) / Math.LN10)) / 10 : i2.__impliedStep = i2.__step, i2.__precision = ye(i2.__impliedStep), i2;
985
+ }
986
+ return ae(e4, ue), oe(e4, [{ key: "setValue", value: function(t2) {
987
+ var n2 = t2;
988
+ return void 0 !== this.__min && n2 < this.__min ? n2 = this.__min : void 0 !== this.__max && n2 > this.__max && (n2 = this.__max), void 0 !== this.__step && n2 % this.__step !== 0 && (n2 = Math.round(n2 / this.__step) * this.__step), re(e4.prototype.__proto__ || Object.getPrototypeOf(e4.prototype), "setValue", this).call(this, n2);
989
+ } }, { key: "min", value: function(e5) {
990
+ return this.__min = e5, this;
991
+ } }, { key: "max", value: function(e5) {
992
+ return this.__max = e5, this;
993
+ } }, { key: "step", value: function(e5) {
994
+ return this.__step = e5, this.__impliedStep = e5, this.__precision = ye(e5), this;
995
+ } }]), e4;
996
+ }();
997
+ var xe = function() {
998
+ function e4(t2, n2, s2) {
999
+ ie(this, e4);
1000
+ var i2 = le(this, (e4.__proto__ || Object.getPrototypeOf(e4)).call(this, t2, n2, s2));
1001
+ i2.__truncationSuspended = false;
1002
+ var o2 = i2, r2 = void 0;
1003
+ function a2() {
1004
+ o2.__onFinishChange && o2.__onFinishChange.call(o2, o2.getValue());
1005
+ }
1006
+ function l2(e5) {
1007
+ var t3 = r2 - e5.clientY;
1008
+ o2.setValue(o2.getValue() + t3 * o2.__impliedStep), r2 = e5.clientY;
1009
+ }
1010
+ function d2() {
1011
+ ge.unbind(window, "mousemove", l2), ge.unbind(window, "mouseup", d2), a2();
1012
+ }
1013
+ return i2.__input = document.createElement("input"), i2.__input.setAttribute("type", "text"), ge.bind(i2.__input, "change", function() {
1014
+ var e5 = parseFloat(o2.__input.value);
1015
+ Z.isNaN(e5) || o2.setValue(e5);
1016
+ }), ge.bind(i2.__input, "blur", function() {
1017
+ a2();
1018
+ }), ge.bind(i2.__input, "mousedown", function(e5) {
1019
+ ge.bind(window, "mousemove", l2), ge.bind(window, "mouseup", d2), r2 = e5.clientY;
1020
+ }), ge.bind(i2.__input, "keydown", function(e5) {
1021
+ 13 === e5.keyCode && (o2.__truncationSuspended = true, this.blur(), o2.__truncationSuspended = false, a2());
1022
+ }), i2.updateDisplay(), i2.domElement.appendChild(i2.__input), i2;
1023
+ }
1024
+ return ae(e4, we), oe(e4, [{ key: "updateDisplay", value: function() {
1025
+ var t2, n2, s2;
1026
+ return this.__input.value = this.__truncationSuspended ? this.getValue() : (t2 = this.getValue(), n2 = this.__precision, s2 = Math.pow(10, n2), Math.round(t2 * s2) / s2), re(e4.prototype.__proto__ || Object.getPrototypeOf(e4.prototype), "updateDisplay", this).call(this);
1027
+ } }]), e4;
1028
+ }();
1029
+ function Ce(e4, t2, n2, s2, i2) {
1030
+ return s2 + (e4 - t2) / (n2 - t2) * (i2 - s2);
1031
+ }
1032
+ var Me = function() {
1033
+ function e4(t2, n2, s2, i2, o2) {
1034
+ ie(this, e4);
1035
+ var r2 = le(this, (e4.__proto__ || Object.getPrototypeOf(e4)).call(this, t2, n2, { min: s2, max: i2, step: o2 })), a2 = r2;
1036
+ function l2(e5) {
1037
+ e5.preventDefault();
1038
+ var t3 = a2.__background.getBoundingClientRect();
1039
+ return a2.setValue(Ce(e5.clientX, t3.left, t3.right, a2.__min, a2.__max)), false;
1040
+ }
1041
+ function d2() {
1042
+ ge.unbind(window, "mousemove", l2), ge.unbind(window, "mouseup", d2), a2.__onFinishChange && a2.__onFinishChange.call(a2, a2.getValue());
1043
+ }
1044
+ function c2(e5) {
1045
+ var t3 = e5.touches[0].clientX, n3 = a2.__background.getBoundingClientRect();
1046
+ a2.setValue(Ce(t3, n3.left, n3.right, a2.__min, a2.__max));
1047
+ }
1048
+ function h2() {
1049
+ ge.unbind(window, "touchmove", c2), ge.unbind(window, "touchend", h2), a2.__onFinishChange && a2.__onFinishChange.call(a2, a2.getValue());
1050
+ }
1051
+ return r2.__background = document.createElement("div"), r2.__foreground = document.createElement("div"), ge.bind(r2.__background, "mousedown", function(e5) {
1052
+ document.activeElement.blur(), ge.bind(window, "mousemove", l2), ge.bind(window, "mouseup", d2), l2(e5);
1053
+ }), ge.bind(r2.__background, "touchstart", function(e5) {
1054
+ if (1 !== e5.touches.length) return;
1055
+ ge.bind(window, "touchmove", c2), ge.bind(window, "touchend", h2), c2(e5);
1056
+ }), ge.addClass(r2.__background, "slider"), ge.addClass(r2.__foreground, "slider-fg"), r2.updateDisplay(), r2.__background.appendChild(r2.__foreground), r2.domElement.appendChild(r2.__background), r2;
1057
+ }
1058
+ return ae(e4, we), oe(e4, [{ key: "updateDisplay", value: function() {
1059
+ var t2 = (this.getValue() - this.__min) / (this.__max - this.__min);
1060
+ return this.__foreground.style.width = 100 * t2 + "%", re(e4.prototype.__proto__ || Object.getPrototypeOf(e4.prototype), "updateDisplay", this).call(this);
1061
+ } }]), e4;
1062
+ }(), Pe = function() {
1063
+ function e4(t2, n2, s2) {
1064
+ ie(this, e4);
1065
+ var i2 = le(this, (e4.__proto__ || Object.getPrototypeOf(e4)).call(this, t2, n2)), o2 = i2;
1066
+ return i2.__button = document.createElement("div"), i2.__button.innerHTML = void 0 === s2 ? "Fire" : s2, ge.bind(i2.__button, "click", function(e5) {
1067
+ return e5.preventDefault(), o2.fire(), false;
1068
+ }), ge.addClass(i2.__button, "button"), i2.domElement.appendChild(i2.__button), i2;
1069
+ }
1070
+ return ae(e4, ue), oe(e4, [{ key: "fire", value: function() {
1071
+ this.__onChange && this.__onChange.call(this), this.getValue().call(this.object), this.__onFinishChange && this.__onFinishChange.call(this, this.getValue());
1072
+ } }]), e4;
1073
+ }(), Se = function() {
1074
+ function e4(t2, n2) {
1075
+ ie(this, e4);
1076
+ var s2 = le(this, (e4.__proto__ || Object.getPrototypeOf(e4)).call(this, t2, n2));
1077
+ s2.__color = new de(s2.getValue()), s2.__temp = new de(0);
1078
+ var i2 = s2;
1079
+ s2.domElement = document.createElement("div"), ge.makeSelectable(s2.domElement, false), s2.__selector = document.createElement("div"), s2.__selector.className = "selector", s2.__saturation_field = document.createElement("div"), s2.__saturation_field.className = "saturation-field", s2.__field_knob = document.createElement("div"), s2.__field_knob.className = "field-knob", s2.__field_knob_border = "2px solid ", s2.__hue_knob = document.createElement("div"), s2.__hue_knob.className = "hue-knob", s2.__hue_field = document.createElement("div"), s2.__hue_field.className = "hue-field", s2.__input = document.createElement("input"), s2.__input.type = "text", s2.__input_textShadow = "0 1px 1px ", ge.bind(s2.__input, "keydown", function(e5) {
1080
+ 13 === e5.keyCode && h2.call(this);
1081
+ }), ge.bind(s2.__input, "blur", h2), ge.bind(s2.__selector, "mousedown", function() {
1082
+ ge.addClass(this, "drag").bind(window, "mouseup", function() {
1083
+ ge.removeClass(i2.__selector, "drag");
1084
+ });
1085
+ }), ge.bind(s2.__selector, "touchstart", function() {
1086
+ ge.addClass(this, "drag").bind(window, "touchend", function() {
1087
+ ge.removeClass(i2.__selector, "drag");
1088
+ });
1089
+ });
1090
+ var o2, r2 = document.createElement("div");
1091
+ function a2(e5) {
1092
+ m2(e5), ge.bind(window, "mousemove", m2), ge.bind(window, "touchmove", m2), ge.bind(window, "mouseup", d2), ge.bind(window, "touchend", d2);
1093
+ }
1094
+ function l2(e5) {
1095
+ p2(e5), ge.bind(window, "mousemove", p2), ge.bind(window, "touchmove", p2), ge.bind(window, "mouseup", c2), ge.bind(window, "touchend", c2);
1096
+ }
1097
+ function d2() {
1098
+ ge.unbind(window, "mousemove", m2), ge.unbind(window, "touchmove", m2), ge.unbind(window, "mouseup", d2), ge.unbind(window, "touchend", d2), u2();
1099
+ }
1100
+ function c2() {
1101
+ ge.unbind(window, "mousemove", p2), ge.unbind(window, "touchmove", p2), ge.unbind(window, "mouseup", c2), ge.unbind(window, "touchend", c2), u2();
1102
+ }
1103
+ function h2() {
1104
+ var e5 = ee(this.value);
1105
+ false !== e5 ? (i2.__color.__state = e5, i2.setValue(i2.__color.toOriginal())) : this.value = i2.__color.toString();
1106
+ }
1107
+ function u2() {
1108
+ i2.__onFinishChange && i2.__onFinishChange.call(i2, i2.__color.toOriginal());
1109
+ }
1110
+ function m2(e5) {
1111
+ -1 === e5.type.indexOf("touch") && e5.preventDefault();
1112
+ var t3 = i2.__saturation_field.getBoundingClientRect(), n3 = e5.touches && e5.touches[0] || e5, s3 = n3.clientX, o3 = n3.clientY, r3 = (s3 - t3.left) / (t3.right - t3.left), a3 = 1 - (o3 - t3.top) / (t3.bottom - t3.top);
1113
+ return a3 > 1 ? a3 = 1 : a3 < 0 && (a3 = 0), r3 > 1 ? r3 = 1 : r3 < 0 && (r3 = 0), i2.__color.v = a3, i2.__color.s = r3, i2.setValue(i2.__color.toOriginal()), false;
1114
+ }
1115
+ function p2(e5) {
1116
+ -1 === e5.type.indexOf("touch") && e5.preventDefault();
1117
+ var t3 = i2.__hue_field.getBoundingClientRect(), n3 = 1 - ((e5.touches && e5.touches[0] || e5).clientY - t3.top) / (t3.bottom - t3.top);
1118
+ return n3 > 1 ? n3 = 1 : n3 < 0 && (n3 = 0), i2.__color.h = 360 * n3, i2.setValue(i2.__color.toOriginal()), false;
1119
+ }
1120
+ return Z.extend(s2.__selector.style, { width: "122px", height: "102px", padding: "3px", backgroundColor: "#222", boxShadow: "0px 1px 3px rgba(0,0,0,0.3)" }), Z.extend(s2.__field_knob.style, { position: "absolute", width: "12px", height: "12px", border: s2.__field_knob_border + (s2.__color.v < 0.5 ? "#fff" : "#000"), boxShadow: "0px 1px 3px rgba(0,0,0,0.5)", borderRadius: "12px", zIndex: 1 }), Z.extend(s2.__hue_knob.style, { position: "absolute", width: "15px", height: "2px", borderRight: "4px solid #fff", zIndex: 1 }), Z.extend(s2.__saturation_field.style, { width: "100px", height: "100px", border: "1px solid #555", marginRight: "3px", display: "inline-block", cursor: "pointer" }), Z.extend(r2.style, { width: "100%", height: "100%", background: "none" }), Ee(r2, "top", "rgba(0,0,0,0)", "#000"), Z.extend(s2.__hue_field.style, { width: "15px", height: "100px", border: "1px solid #555", cursor: "ns-resize", position: "absolute", top: "3px", right: "3px" }), (o2 = s2.__hue_field).style.background = "", o2.style.cssText += "background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);", o2.style.cssText += "background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);", o2.style.cssText += "background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);", o2.style.cssText += "background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);", o2.style.cssText += "background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);", Z.extend(s2.__input.style, { outline: "none", textAlign: "center", color: "#fff", border: 0, fontWeight: "bold", textShadow: s2.__input_textShadow + "rgba(0,0,0,0.7)" }), ge.bind(s2.__saturation_field, "mousedown", a2), ge.bind(s2.__saturation_field, "touchstart", a2), ge.bind(s2.__field_knob, "mousedown", a2), ge.bind(s2.__field_knob, "touchstart", a2), ge.bind(s2.__hue_field, "mousedown", l2), ge.bind(s2.__hue_field, "touchstart", l2), s2.__saturation_field.appendChild(r2), s2.__selector.appendChild(s2.__field_knob), s2.__selector.appendChild(s2.__saturation_field), s2.__selector.appendChild(s2.__hue_field), s2.__hue_field.appendChild(s2.__hue_knob), s2.domElement.appendChild(s2.__input), s2.domElement.appendChild(s2.__selector), s2.updateDisplay(), s2;
1121
+ }
1122
+ return ae(e4, ue), oe(e4, [{ key: "updateDisplay", value: function() {
1123
+ var e5 = ee(this.getValue());
1124
+ if (false !== e5) {
1125
+ var t2 = false;
1126
+ Z.each(de.COMPONENTS, function(n3) {
1127
+ if (!Z.isUndefined(e5[n3]) && !Z.isUndefined(this.__color.__state[n3]) && e5[n3] !== this.__color.__state[n3]) return t2 = true, {};
1128
+ }, this), t2 && Z.extend(this.__color.__state, e5);
1129
+ }
1130
+ Z.extend(this.__temp.__state, this.__color.__state), this.__temp.a = 1;
1131
+ var n2 = this.__color.v < 0.5 || this.__color.s > 0.5 ? 255 : 0, s2 = 255 - n2;
1132
+ Z.extend(this.__field_knob.style, { marginLeft: 100 * this.__color.s - 7 + "px", marginTop: 100 * (1 - this.__color.v) - 7 + "px", backgroundColor: this.__temp.toHexString(), border: this.__field_knob_border + "rgb(" + n2 + "," + n2 + "," + n2 + ")" }), this.__hue_knob.style.marginTop = 100 * (1 - this.__color.h / 360) + "px", this.__temp.s = 1, this.__temp.v = 1, Ee(this.__saturation_field, "left", "#fff", this.__temp.toHexString()), this.__input.value = this.__color.toString(), Z.extend(this.__input.style, { backgroundColor: this.__color.toHexString(), color: "rgb(" + n2 + "," + n2 + "," + n2 + ")", textShadow: this.__input_textShadow + "rgba(" + s2 + "," + s2 + "," + s2 + ",.7)" });
1133
+ } }]), e4;
1134
+ }(), Fe = ["-moz-", "-o-", "-webkit-", "-ms-", ""];
1135
+ function Ee(e4, t2, n2, s2) {
1136
+ e4.style.background = "", Z.each(Fe, function(i2) {
1137
+ e4.style.cssText += "background: " + i2 + "linear-gradient(" + t2 + ", " + n2 + " 0%, " + s2 + " 100%); ";
1138
+ });
1139
+ }
1140
+ var Ae = function(e4, t2) {
1141
+ var n2 = t2 || document, s2 = document.createElement("style");
1142
+ s2.type = "text/css", s2.innerHTML = e4;
1143
+ var i2 = n2.getElementsByTagName("head")[0];
1144
+ try {
1145
+ i2.appendChild(s2);
1146
+ } catch (e5) {
1147
+ }
1148
+ }, ke = function(e4, t2) {
1149
+ var n2 = e4[t2];
1150
+ return Z.isArray(arguments[2]) || Z.isObject(arguments[2]) ? new ve(e4, t2, arguments[2]) : Z.isNumber(n2) ? Z.isNumber(arguments[2]) && Z.isNumber(arguments[3]) ? Z.isNumber(arguments[4]) ? new Me(e4, t2, arguments[2], arguments[3], arguments[4]) : new Me(e4, t2, arguments[2], arguments[3]) : Z.isNumber(arguments[4]) ? new xe(e4, t2, { min: arguments[2], max: arguments[3], step: arguments[4] }) : new xe(e4, t2, { min: arguments[2], max: arguments[3] }) : Z.isString(n2) ? new be(e4, t2) : Z.isFunction(n2) ? new Pe(e4, t2, "") : Z.isBoolean(n2) ? new _e(e4, t2) : null;
1151
+ };
1152
+ var Te = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(e4) {
1153
+ setTimeout(e4, 1e3 / 60);
1154
+ }, Le = function() {
1155
+ function e4() {
1156
+ ie(this, e4), this.backgroundElement = document.createElement("div"), Z.extend(this.backgroundElement.style, { backgroundColor: "rgba(0,0,0,0.8)", top: 0, left: 0, display: "none", zIndex: "1000", opacity: 0, WebkitTransition: "opacity 0.2s linear", transition: "opacity 0.2s linear" }), ge.makeFullscreen(this.backgroundElement), this.backgroundElement.style.position = "fixed", this.domElement = document.createElement("div"), Z.extend(this.domElement.style, { position: "fixed", display: "none", zIndex: "1001", opacity: 0, WebkitTransition: "-webkit-transform 0.2s ease-out, opacity 0.2s linear", transition: "transform 0.2s ease-out, opacity 0.2s linear" }), document.body.appendChild(this.backgroundElement), document.body.appendChild(this.domElement);
1157
+ var t2 = this;
1158
+ ge.bind(this.backgroundElement, "click", function() {
1159
+ t2.hide();
1160
+ });
1161
+ }
1162
+ return oe(e4, [{ key: "show", value: function() {
1163
+ var e5 = this;
1164
+ this.backgroundElement.style.display = "block", this.domElement.style.display = "block", this.domElement.style.opacity = 0, this.domElement.style.webkitTransform = "scale(1.1)", this.layout(), Z.defer(function() {
1165
+ e5.backgroundElement.style.opacity = 1, e5.domElement.style.opacity = 1, e5.domElement.style.webkitTransform = "scale(1)";
1166
+ });
1167
+ } }, { key: "hide", value: function() {
1168
+ var e5 = this, t2 = function t3() {
1169
+ e5.domElement.style.display = "none", e5.backgroundElement.style.display = "none", ge.unbind(e5.domElement, "webkitTransitionEnd", t3), ge.unbind(e5.domElement, "transitionend", t3), ge.unbind(e5.domElement, "oTransitionEnd", t3);
1170
+ };
1171
+ ge.bind(this.domElement, "webkitTransitionEnd", t2), ge.bind(this.domElement, "transitionend", t2), ge.bind(this.domElement, "oTransitionEnd", t2), this.backgroundElement.style.opacity = 0, this.domElement.style.opacity = 0, this.domElement.style.webkitTransform = "scale(1.1)";
1172
+ } }, { key: "layout", value: function() {
1173
+ this.domElement.style.left = window.innerWidth / 2 - ge.getWidth(this.domElement) / 2 + "px", this.domElement.style.top = window.innerHeight / 2 - ge.getHeight(this.domElement) / 2 + "px";
1174
+ } }]), e4;
1175
+ }(), Oe = function(e4) {
1176
+ if ("undefined" != typeof window) {
1177
+ var t2 = document.createElement("style");
1178
+ return t2.setAttribute("type", "text/css"), t2.innerHTML = e4, document.head.appendChild(t2), e4;
1179
+ }
1180
+ }(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n");
1181
+ Ae(Oe);
1182
+ var He = "Default", Be = function() {
1183
+ try {
1184
+ return !!window.localStorage;
1185
+ } catch (e4) {
1186
+ return false;
1187
+ }
1188
+ }(), je = void 0, Re = true, ze = void 0, De = false, Ge = [], Ue = function e3(t2) {
1189
+ var n2 = this, s2 = t2 || {};
1190
+ this.domElement = document.createElement("div"), this.__ul = document.createElement("ul"), this.domElement.appendChild(this.__ul), ge.addClass(this.domElement, "dg"), this.__folders = {}, this.__controllers = [], this.__rememberedObjects = [], this.__rememberedObjectIndecesToControllers = [], this.__listening = [], s2 = Z.defaults(s2, { closeOnTop: false, autoPlace: true, width: e3.DEFAULT_WIDTH }), s2 = Z.defaults(s2, { resizable: s2.autoPlace, hideable: s2.autoPlace }), Z.isUndefined(s2.load) ? s2.load = { preset: He } : s2.preset && (s2.load.preset = s2.preset), Z.isUndefined(s2.parent) && s2.hideable && Ge.push(this), s2.resizable = Z.isUndefined(s2.parent) && s2.resizable, s2.autoPlace && Z.isUndefined(s2.scrollable) && (s2.scrollable = true);
1191
+ var i2, o2 = Be && "true" === localStorage.getItem(Je(this, "isLocal")), r2 = void 0, a2 = void 0;
1192
+ if (Object.defineProperties(this, { parent: { get: function() {
1193
+ return s2.parent;
1194
+ } }, scrollable: { get: function() {
1195
+ return s2.scrollable;
1196
+ } }, autoPlace: { get: function() {
1197
+ return s2.autoPlace;
1198
+ } }, closeOnTop: { get: function() {
1199
+ return s2.closeOnTop;
1200
+ } }, preset: { get: function() {
1201
+ return n2.parent ? n2.getRoot().preset : s2.load.preset;
1202
+ }, set: function(e4) {
1203
+ n2.parent ? n2.getRoot().preset = e4 : s2.load.preset = e4, function(e5) {
1204
+ for (var t3 = 0; t3 < e5.__preset_select.length; t3++) e5.__preset_select[t3].value === e5.preset && (e5.__preset_select.selectedIndex = t3);
1205
+ }(this), n2.revert();
1206
+ } }, width: { get: function() {
1207
+ return s2.width;
1208
+ }, set: function(e4) {
1209
+ s2.width = e4, qe(n2, e4);
1210
+ } }, name: { get: function() {
1211
+ return s2.name;
1212
+ }, set: function(e4) {
1213
+ s2.name = e4, a2 && (a2.innerHTML = s2.name);
1214
+ } }, closed: { get: function() {
1215
+ return s2.closed;
1216
+ }, set: function(t3) {
1217
+ s2.closed = t3, s2.closed ? ge.addClass(n2.__ul, e3.CLASS_CLOSED) : ge.removeClass(n2.__ul, e3.CLASS_CLOSED), this.onResize(), n2.__closeButton && (n2.__closeButton.innerHTML = t3 ? e3.TEXT_OPEN : e3.TEXT_CLOSED);
1218
+ } }, load: { get: function() {
1219
+ return s2.load;
1220
+ } }, useLocalStorage: { get: function() {
1221
+ return o2;
1222
+ }, set: function(e4) {
1223
+ Be && (o2 = e4, e4 ? ge.bind(window, "unload", r2) : ge.unbind(window, "unload", r2), localStorage.setItem(Je(n2, "isLocal"), e4));
1224
+ } } }), Z.isUndefined(s2.parent)) {
1225
+ if (this.closed = s2.closed || false, ge.addClass(this.domElement, e3.CLASS_MAIN), ge.makeSelectable(this.domElement, false), Be && o2) {
1226
+ n2.useLocalStorage = true;
1227
+ var l2 = localStorage.getItem(Je(this, "gui"));
1228
+ l2 && (s2.load = JSON.parse(l2));
1229
+ }
1230
+ this.__closeButton = document.createElement("div"), this.__closeButton.innerHTML = e3.TEXT_CLOSED, ge.addClass(this.__closeButton, e3.CLASS_CLOSE_BUTTON), s2.closeOnTop ? (ge.addClass(this.__closeButton, e3.CLASS_CLOSE_TOP), this.domElement.insertBefore(this.__closeButton, this.domElement.childNodes[0])) : (ge.addClass(this.__closeButton, e3.CLASS_CLOSE_BOTTOM), this.domElement.appendChild(this.__closeButton)), ge.bind(this.__closeButton, "click", function() {
1231
+ n2.closed = !n2.closed;
1232
+ });
1233
+ } else {
1234
+ void 0 === s2.closed && (s2.closed = true);
1235
+ var d2 = document.createTextNode(s2.name);
1236
+ ge.addClass(d2, "controller-name"), a2 = Ie(n2, d2);
1237
+ ge.addClass(this.__ul, e3.CLASS_CLOSED), ge.addClass(a2, "title"), ge.bind(a2, "click", function(e4) {
1238
+ return e4.preventDefault(), n2.closed = !n2.closed, false;
1239
+ }), s2.closed || (this.closed = false);
1240
+ }
1241
+ s2.autoPlace && (Z.isUndefined(s2.parent) && (Re && (ze = document.createElement("div"), ge.addClass(ze, "dg"), ge.addClass(ze, e3.CLASS_AUTO_PLACE_CONTAINER), document.body.appendChild(ze), Re = false), ze.appendChild(this.domElement), ge.addClass(this.domElement, e3.CLASS_AUTO_PLACE)), this.parent || qe(n2, s2.width)), this.__resizeHandler = function() {
1242
+ n2.onResizeDebounced();
1243
+ }, ge.bind(window, "resize", this.__resizeHandler), ge.bind(this.__ul, "webkitTransitionEnd", this.__resizeHandler), ge.bind(this.__ul, "transitionend", this.__resizeHandler), ge.bind(this.__ul, "oTransitionEnd", this.__resizeHandler), this.onResize(), s2.resizable && Ze(this), r2 = function() {
1244
+ Be && "true" === localStorage.getItem(Je(n2, "isLocal")) && localStorage.setItem(Je(n2, "gui"), JSON.stringify(n2.getSaveObject()));
1245
+ }, this.saveToLocalStorageIfPossible = r2, s2.parent || ((i2 = n2.getRoot()).width += 1, Z.defer(function() {
1246
+ i2.width -= 1;
1247
+ }));
1248
+ };
1249
+ function Ie(e4, t2, n2) {
1250
+ var s2 = document.createElement("li");
1251
+ return t2 && s2.appendChild(t2), n2 ? e4.__ul.insertBefore(s2, n2) : e4.__ul.appendChild(s2), e4.onResize(), s2;
1252
+ }
1253
+ function Ve(e4) {
1254
+ ge.unbind(window, "resize", e4.__resizeHandler), e4.saveToLocalStorageIfPossible && ge.unbind(window, "unload", e4.saveToLocalStorageIfPossible);
1255
+ }
1256
+ function Ne(e4, t2) {
1257
+ var n2 = e4.__preset_select[e4.__preset_select.selectedIndex];
1258
+ n2.innerHTML = t2 ? n2.value + "*" : n2.value;
1259
+ }
1260
+ function Xe(e4, t2) {
1261
+ var n2 = e4.getRoot(), s2 = n2.__rememberedObjects.indexOf(t2.object);
1262
+ if (-1 !== s2) {
1263
+ var i2 = n2.__rememberedObjectIndecesToControllers[s2];
1264
+ if (void 0 === i2 && (i2 = {}, n2.__rememberedObjectIndecesToControllers[s2] = i2), i2[t2.property] = t2, n2.load && n2.load.remembered) {
1265
+ var o2 = n2.load.remembered, r2 = void 0;
1266
+ if (o2[e4.preset]) r2 = o2[e4.preset];
1267
+ else {
1268
+ if (!o2[He]) return;
1269
+ r2 = o2[He];
1270
+ }
1271
+ if (r2[s2] && void 0 !== r2[s2][t2.property]) {
1272
+ var a2 = r2[s2][t2.property];
1273
+ t2.initialValue = a2, t2.setValue(a2);
1274
+ }
1275
+ }
1276
+ }
1277
+ }
1278
+ function We(e4, t2, n2, s2) {
1279
+ if (void 0 === t2[n2]) throw new Error('Object "' + t2 + '" has no property "' + n2 + '"');
1280
+ var i2 = void 0;
1281
+ if (s2.color) i2 = new Se(t2, n2);
1282
+ else {
1283
+ var o2 = [t2, n2].concat(s2.factoryArgs);
1284
+ i2 = ke.apply(e4, o2);
1285
+ }
1286
+ s2.before instanceof ue && (s2.before = s2.before.__li), Xe(e4, i2), ge.addClass(i2.domElement, "c");
1287
+ var r2 = document.createElement("span");
1288
+ ge.addClass(r2, "property-name"), r2.innerHTML = i2.property;
1289
+ var a2 = document.createElement("div");
1290
+ a2.appendChild(r2), a2.appendChild(i2.domElement);
1291
+ var l2 = Ie(e4, a2, s2.before);
1292
+ return ge.addClass(l2, Ue.CLASS_CONTROLLER_ROW), i2 instanceof Se ? ge.addClass(l2, "color") : ge.addClass(l2, se(i2.getValue())), function(e5, t3, n3) {
1293
+ if (n3.__li = t3, n3.__gui = e5, Z.extend(n3, { options: function(t4) {
1294
+ if (arguments.length > 1) {
1295
+ var s4 = n3.__li.nextElementSibling;
1296
+ return n3.remove(), We(e5, n3.object, n3.property, { before: s4, factoryArgs: [Z.toArray(arguments)] });
1297
+ }
1298
+ if (Z.isArray(t4) || Z.isObject(t4)) {
1299
+ var i4 = n3.__li.nextElementSibling;
1300
+ return n3.remove(), We(e5, n3.object, n3.property, { before: i4, factoryArgs: [t4] });
1301
+ }
1302
+ }, name: function(e6) {
1303
+ return n3.__li.firstElementChild.firstElementChild.innerHTML = e6, n3;
1304
+ }, listen: function() {
1305
+ return n3.__gui.listen(n3), n3;
1306
+ }, remove: function() {
1307
+ return n3.__gui.remove(n3), n3;
1308
+ } }), n3 instanceof Me) {
1309
+ var s3 = new xe(n3.object, n3.property, { min: n3.__min, max: n3.__max, step: n3.__step });
1310
+ Z.each(["updateDisplay", "onChange", "onFinishChange", "step", "min", "max"], function(e6) {
1311
+ var t4 = n3[e6], i4 = s3[e6];
1312
+ n3[e6] = s3[e6] = function() {
1313
+ var e7 = Array.prototype.slice.call(arguments);
1314
+ return i4.apply(s3, e7), t4.apply(n3, e7);
1315
+ };
1316
+ }), ge.addClass(t3, "has-slider"), n3.domElement.insertBefore(s3.domElement, n3.domElement.firstElementChild);
1317
+ } else if (n3 instanceof xe) {
1318
+ var i3 = function(t4) {
1319
+ if (Z.isNumber(n3.__min) && Z.isNumber(n3.__max)) {
1320
+ var s4 = n3.__li.firstElementChild.firstElementChild.innerHTML, i4 = n3.__gui.__listening.indexOf(n3) > -1;
1321
+ n3.remove();
1322
+ var o3 = We(e5, n3.object, n3.property, { before: n3.__li.nextElementSibling, factoryArgs: [n3.__min, n3.__max, n3.__step] });
1323
+ return o3.name(s4), i4 && o3.listen(), o3;
1324
+ }
1325
+ return t4;
1326
+ };
1327
+ n3.min = Z.compose(i3, n3.min), n3.max = Z.compose(i3, n3.max);
1328
+ } else n3 instanceof _e ? (ge.bind(t3, "click", function() {
1329
+ ge.fakeEvent(n3.__checkbox, "click");
1330
+ }), ge.bind(n3.__checkbox, "click", function(e6) {
1331
+ e6.stopPropagation();
1332
+ })) : n3 instanceof Pe ? (ge.bind(t3, "click", function() {
1333
+ ge.fakeEvent(n3.__button, "click");
1334
+ }), ge.bind(t3, "mouseover", function() {
1335
+ ge.addClass(n3.__button, "hover");
1336
+ }), ge.bind(t3, "mouseout", function() {
1337
+ ge.removeClass(n3.__button, "hover");
1338
+ })) : n3 instanceof Se && (ge.addClass(t3, "color"), n3.updateDisplay = Z.compose(function(e6) {
1339
+ return t3.style.borderLeftColor = n3.__color.toString(), e6;
1340
+ }, n3.updateDisplay), n3.updateDisplay());
1341
+ n3.setValue = Z.compose(function(t4) {
1342
+ return e5.getRoot().__preset_select && n3.isModified() && Ne(e5.getRoot(), true), t4;
1343
+ }, n3.setValue);
1344
+ }(e4, l2, i2), e4.__controllers.push(i2), i2;
1345
+ }
1346
+ function Je(e4, t2) {
1347
+ return document.location.href + "." + t2;
1348
+ }
1349
+ function Ye(e4, t2, n2) {
1350
+ var s2 = document.createElement("option");
1351
+ s2.innerHTML = t2, s2.value = t2, e4.__preset_select.appendChild(s2), n2 && (e4.__preset_select.selectedIndex = e4.__preset_select.length - 1);
1352
+ }
1353
+ function Ke(e4, t2) {
1354
+ t2.style.display = e4.useLocalStorage ? "block" : "none";
1355
+ }
1356
+ function Ze(e4) {
1357
+ var t2 = void 0;
1358
+ function n2(n3) {
1359
+ return n3.preventDefault(), e4.width += t2 - n3.clientX, e4.onResize(), t2 = n3.clientX, false;
1360
+ }
1361
+ function s2() {
1362
+ ge.removeClass(e4.__closeButton, Ue.CLASS_DRAG), ge.unbind(window, "mousemove", n2), ge.unbind(window, "mouseup", s2);
1363
+ }
1364
+ function i2(i3) {
1365
+ return i3.preventDefault(), t2 = i3.clientX, ge.addClass(e4.__closeButton, Ue.CLASS_DRAG), ge.bind(window, "mousemove", n2), ge.bind(window, "mouseup", s2), false;
1366
+ }
1367
+ e4.__resize_handle = document.createElement("div"), Z.extend(e4.__resize_handle.style, { width: "6px", marginLeft: "-3px", height: "200px", cursor: "ew-resize", position: "absolute" }), ge.bind(e4.__resize_handle, "mousedown", i2), ge.bind(e4.__closeButton, "mousedown", i2), e4.domElement.insertBefore(e4.__resize_handle, e4.domElement.firstElementChild);
1368
+ }
1369
+ function qe(e4, t2) {
1370
+ e4.domElement.style.width = t2 + "px", e4.__save_row && e4.autoPlace && (e4.__save_row.style.width = t2 + "px"), e4.__closeButton && (e4.__closeButton.style.width = t2 + "px");
1371
+ }
1372
+ function Qe(e4, t2) {
1373
+ var n2 = {};
1374
+ return Z.each(e4.__rememberedObjects, function(s2, i2) {
1375
+ var o2 = {}, r2 = e4.__rememberedObjectIndecesToControllers[i2];
1376
+ Z.each(r2, function(e5, n3) {
1377
+ o2[n3] = t2 ? e5.initialValue : e5.getValue();
1378
+ }), n2[i2] = o2;
1379
+ }), n2;
1380
+ }
1381
+ function $e(e4) {
1382
+ 0 !== e4.length && Te.call(window, function() {
1383
+ $e(e4);
1384
+ }), Z.each(e4, function(e5) {
1385
+ e5.updateDisplay();
1386
+ });
1387
+ }
1388
+ Ue.toggleHide = function() {
1389
+ De = !De, Z.each(Ge, function(e4) {
1390
+ e4.domElement.style.display = De ? "none" : "";
1391
+ });
1392
+ }, Ue.CLASS_AUTO_PLACE = "a", Ue.CLASS_AUTO_PLACE_CONTAINER = "ac", Ue.CLASS_MAIN = "main", Ue.CLASS_CONTROLLER_ROW = "cr", Ue.CLASS_TOO_TALL = "taller-than-window", Ue.CLASS_CLOSED = "closed", Ue.CLASS_CLOSE_BUTTON = "close-button", Ue.CLASS_CLOSE_TOP = "close-top", Ue.CLASS_CLOSE_BOTTOM = "close-bottom", Ue.CLASS_DRAG = "drag", Ue.DEFAULT_WIDTH = 245, Ue.TEXT_CLOSED = "Close Controls", Ue.TEXT_OPEN = "Open Controls", Ue._keydownHandler = function(e4) {
1393
+ "text" === document.activeElement.type || 72 !== e4.which && 72 !== e4.keyCode || Ue.toggleHide();
1394
+ }, ge.bind(window, "keydown", Ue._keydownHandler, false), Z.extend(Ue.prototype, { add: function(e4, t2) {
1395
+ return We(this, e4, t2, { factoryArgs: Array.prototype.slice.call(arguments, 2) });
1396
+ }, addColor: function(e4, t2) {
1397
+ return We(this, e4, t2, { color: true });
1398
+ }, remove: function(e4) {
1399
+ this.__ul.removeChild(e4.__li), this.__controllers.splice(this.__controllers.indexOf(e4), 1);
1400
+ var t2 = this;
1401
+ Z.defer(function() {
1402
+ t2.onResize();
1403
+ });
1404
+ }, destroy: function() {
1405
+ if (this.parent) throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");
1406
+ this.autoPlace && ze.removeChild(this.domElement);
1407
+ var e4 = this;
1408
+ Z.each(this.__folders, function(t2) {
1409
+ e4.removeFolder(t2);
1410
+ }), ge.unbind(window, "keydown", Ue._keydownHandler, false), Ve(this);
1411
+ }, addFolder: function(e4) {
1412
+ if (void 0 !== this.__folders[e4]) throw new Error('You already have a folder in this GUI by the name "' + e4 + '"');
1413
+ var t2 = { name: e4, parent: this };
1414
+ t2.autoPlace = this.autoPlace, this.load && this.load.folders && this.load.folders[e4] && (t2.closed = this.load.folders[e4].closed, t2.load = this.load.folders[e4]);
1415
+ var n2 = new Ue(t2);
1416
+ this.__folders[e4] = n2;
1417
+ var s2 = Ie(this, n2.domElement);
1418
+ return ge.addClass(s2, "folder"), n2;
1419
+ }, removeFolder: function(e4) {
1420
+ this.__ul.removeChild(e4.domElement.parentElement), delete this.__folders[e4.name], this.load && this.load.folders && this.load.folders[e4.name] && delete this.load.folders[e4.name], Ve(e4);
1421
+ var t2 = this;
1422
+ Z.each(e4.__folders, function(t3) {
1423
+ e4.removeFolder(t3);
1424
+ }), Z.defer(function() {
1425
+ t2.onResize();
1426
+ });
1427
+ }, open: function() {
1428
+ this.closed = false;
1429
+ }, close: function() {
1430
+ this.closed = true;
1431
+ }, hide: function() {
1432
+ this.domElement.style.display = "none";
1433
+ }, show: function() {
1434
+ this.domElement.style.display = "";
1435
+ }, onResize: function() {
1436
+ var e4 = this.getRoot();
1437
+ if (e4.scrollable) {
1438
+ var t2 = ge.getOffset(e4.__ul).top, n2 = 0;
1439
+ Z.each(e4.__ul.childNodes, function(t3) {
1440
+ e4.autoPlace && t3 === e4.__save_row || (n2 += ge.getHeight(t3));
1441
+ }), window.innerHeight - t2 - 20 < n2 ? (ge.addClass(e4.domElement, Ue.CLASS_TOO_TALL), e4.__ul.style.height = window.innerHeight - t2 - 20 + "px") : (ge.removeClass(e4.domElement, Ue.CLASS_TOO_TALL), e4.__ul.style.height = "auto");
1442
+ }
1443
+ e4.__resize_handle && Z.defer(function() {
1444
+ e4.__resize_handle.style.height = e4.__ul.offsetHeight + "px";
1445
+ }), e4.__closeButton && (e4.__closeButton.style.width = e4.width + "px");
1446
+ }, onResizeDebounced: Z.debounce(function() {
1447
+ this.onResize();
1448
+ }, 50), remember: function() {
1449
+ if (Z.isUndefined(je) && ((je = new Le()).domElement.innerHTML = `<div id="dg-save" class="dg dialogue">
1450
+
1451
+ Here's the new load parameter for your <code>GUI</code>'s constructor:
1452
+
1453
+ <textarea id="dg-new-constructor"></textarea>
1454
+
1455
+ <div id="dg-save-locally">
1456
+
1457
+ <input id="dg-local-storage" type="checkbox"/> Automatically save
1458
+ values to <code>localStorage</code> on exit.
1459
+
1460
+ <div id="dg-local-explain">The values saved to <code>localStorage</code> will
1461
+ override those passed to <code>dat.GUI</code>'s constructor. This makes it
1462
+ easier to work incrementally, but <code>localStorage</code> is fragile,
1463
+ and your friends may not see the same values you do.
1464
+
1465
+ </div>
1466
+
1467
+ </div>
1468
+
1469
+ </div>`), this.parent) throw new Error("You can only call remember on a top level GUI.");
1470
+ var e4 = this;
1471
+ Z.each(Array.prototype.slice.call(arguments), function(t2) {
1472
+ 0 === e4.__rememberedObjects.length && function(e5) {
1473
+ var t3 = e5.__save_row = document.createElement("li");
1474
+ ge.addClass(e5.domElement, "has-save"), e5.__ul.insertBefore(t3, e5.__ul.firstChild), ge.addClass(t3, "save-row");
1475
+ var n2 = document.createElement("span");
1476
+ n2.innerHTML = "&nbsp;", ge.addClass(n2, "button gears");
1477
+ var s2 = document.createElement("span");
1478
+ s2.innerHTML = "Save", ge.addClass(s2, "button"), ge.addClass(s2, "save");
1479
+ var i2 = document.createElement("span");
1480
+ i2.innerHTML = "New", ge.addClass(i2, "button"), ge.addClass(i2, "save-as");
1481
+ var o2 = document.createElement("span");
1482
+ o2.innerHTML = "Revert", ge.addClass(o2, "button"), ge.addClass(o2, "revert");
1483
+ var r2 = e5.__preset_select = document.createElement("select");
1484
+ e5.load && e5.load.remembered ? Z.each(e5.load.remembered, function(t4, n3) {
1485
+ Ye(e5, n3, n3 === e5.preset);
1486
+ }) : Ye(e5, He, false);
1487
+ if (ge.bind(r2, "change", function() {
1488
+ for (var t4 = 0; t4 < e5.__preset_select.length; t4++) e5.__preset_select[t4].innerHTML = e5.__preset_select[t4].value;
1489
+ e5.preset = this.value;
1490
+ }), t3.appendChild(r2), t3.appendChild(n2), t3.appendChild(s2), t3.appendChild(i2), t3.appendChild(o2), Be) {
1491
+ var a2 = document.getElementById("dg-local-explain"), l2 = document.getElementById("dg-local-storage");
1492
+ document.getElementById("dg-save-locally").style.display = "block", "true" === localStorage.getItem(Je(e5, "isLocal")) && l2.setAttribute("checked", "checked"), Ke(e5, a2), ge.bind(l2, "change", function() {
1493
+ e5.useLocalStorage = !e5.useLocalStorage, Ke(e5, a2);
1494
+ });
1495
+ }
1496
+ var d2 = document.getElementById("dg-new-constructor");
1497
+ ge.bind(d2, "keydown", function(e6) {
1498
+ !e6.metaKey || 67 !== e6.which && 67 !== e6.keyCode || je.hide();
1499
+ }), ge.bind(n2, "click", function() {
1500
+ d2.innerHTML = JSON.stringify(e5.getSaveObject(), void 0, 2), je.show(), d2.focus(), d2.select();
1501
+ }), ge.bind(s2, "click", function() {
1502
+ e5.save();
1503
+ }), ge.bind(i2, "click", function() {
1504
+ var t4 = prompt("Enter a new preset name.");
1505
+ t4 && e5.saveAs(t4);
1506
+ }), ge.bind(o2, "click", function() {
1507
+ e5.revert();
1508
+ });
1509
+ }(e4), -1 === e4.__rememberedObjects.indexOf(t2) && e4.__rememberedObjects.push(t2);
1510
+ }), this.autoPlace && qe(this, this.width);
1511
+ }, getRoot: function() {
1512
+ for (var e4 = this; e4.parent; ) e4 = e4.parent;
1513
+ return e4;
1514
+ }, getSaveObject: function() {
1515
+ var e4 = this.load;
1516
+ return e4.closed = this.closed, this.__rememberedObjects.length > 0 && (e4.preset = this.preset, e4.remembered || (e4.remembered = {}), e4.remembered[this.preset] = Qe(this)), e4.folders = {}, Z.each(this.__folders, function(t2, n2) {
1517
+ e4.folders[n2] = t2.getSaveObject();
1518
+ }), e4;
1519
+ }, save: function() {
1520
+ this.load.remembered || (this.load.remembered = {}), this.load.remembered[this.preset] = Qe(this), Ne(this, false), this.saveToLocalStorageIfPossible();
1521
+ }, saveAs: function(e4) {
1522
+ this.load.remembered || (this.load.remembered = {}, this.load.remembered[He] = Qe(this, true)), this.load.remembered[e4] = Qe(this), this.preset = e4, Ye(this, e4, true), this.saveToLocalStorageIfPossible();
1523
+ }, revert: function(e4) {
1524
+ Z.each(this.__controllers, function(t2) {
1525
+ this.getRoot().load.remembered ? Xe(e4 || this.getRoot(), t2) : t2.setValue(t2.initialValue), t2.__onFinishChange && t2.__onFinishChange.call(t2, t2.getValue());
1526
+ }, this), Z.each(this.__folders, function(e5) {
1527
+ e5.revert(e5);
1528
+ }), e4 || Ne(this.getRoot(), false);
1529
+ }, listen: function(e4) {
1530
+ var t2 = 0 === this.__listening.length;
1531
+ this.__listening.push(e4), t2 && $e(this.__listening);
1532
+ }, updateDisplay: function() {
1533
+ Z.each(this.__controllers, function(e4) {
1534
+ e4.updateDisplay();
1535
+ }), Z.each(this.__folders, function(e4) {
1536
+ e4.updateDisplay();
1537
+ });
1538
+ } });
1539
+ var et = Ue;
1540
+ const tt = { autoPlace: true, width: 300, useProxy: false, closed: false }, nt = ["立方体", "球体", "圆柱体", "圆锥体", "圆环", "平面", "圆环结", "十二面体", "二十面体", "八面体", "四面体"], st = ["基础材质", "标准材质", "Lambert材质", "Phong材质", "物理材质", "Toon材质"], it = ["AmbientLight", "DirectionalLight", "PointLight", "SpotLight", "HemisphereLight", "RectAreaLight"], ot = ["围栏物体", "平面绘制", "曲线路径", "直线路径"], rt = ["场景交点", "地图区域中心", "地图行政中心"];
1541
+ class at extends k {
1542
+ constructor(e4) {
1543
+ super({ ...tt, ...e4 }), this.name = "gui", this._gui = null, this.sceneFolder = null, this.controlFolder = null, this.meshFolder = null, this.animationFolder = null, this.selectPanel = null, this.modelListFolder = null, this.innerMeshListFolder = null, this.drawMeshListFolder = null, this.geoMapListFolder = null, this.particleListFolder = null, this.borderGroupListFolder = null, this.textMeshListFolder = null, this.designMeshListFolder = null, this.lightListFolder = null, this.handlerParams = { mode: "变换", isTransformChildren: false, openKey: false }, this.innerMeshParams = { geometryType: "立方体", materialType: "标准材质" }, this.drawParams = { mode: "围栏物体", pointMode: "场景交点", materialType: "标准材质" }, this.geoMapParams = { url: "", materialType: "标准材质" }, this.particleParams = { particlesSum: 1e5, inner: 0, outer: 2e3, maxVelocity: 50, mapUrl: "https://z2586300277.github.io/three-editor/dist/files/channels/snow.png", sportType: "全随机", shaderCodeName: "水波纹" }, this.borderGroupParams = { url: "https://geo.datav.aliyun.com/areas_v3/bound/100000.json", materialType: "基础材质", dlength: 0 }, this.textMeshParams = { fontLink: "https://z2586300277.github.io/three-editor/dist/files/font/cn1.json", text: "", materialType: "标准材质" }, this.designMeshParams = { type: "镜面" }, this.lightParams = { lightType: "AmbientLight" };
1544
+ }
1545
+ onInstall() {
1546
+ this.createGUI();
1547
+ }
1548
+ onUninstall() {
1549
+ this.destroy();
1550
+ }
1551
+ get gui() {
1552
+ return this._gui;
1553
+ }
1554
+ get domElement() {
1555
+ var _a;
1556
+ return ((_a = this._gui) == null ? void 0 : _a.domElement) ?? null;
1557
+ }
1558
+ createGUI() {
1559
+ this.config.useProxy || (this._gui = new et({ autoPlace: this.config.autoPlace, width: this.config.width }), this.createSceneFolder(), this.createControlFolder(), this.createMeshFolder(), this.createAnimationFolder());
1560
+ }
1561
+ createSceneFolder() {
1562
+ this._gui && (this.sceneFolder = this._gui.addFolder("场景配置"), this.createRendererFolder(), this.createCameraFolder(), this.createOrbitControlsFolder(), this.createEnvironmentFolder(), this.createLightGroupFolder(), this.createComposerFolder(), this.config.closed || this.sceneFolder.open());
1563
+ }
1564
+ createRendererFolder() {
1565
+ if (!this.sceneFolder) return;
1566
+ const e4 = this.sceneFolder.addFolder("渲染器配置"), n2 = this.renderer, s2 = { toneMapping: n2.toneMapping, toneMappingExposure: n2.toneMappingExposure, shadowMapEnabled: n2.shadowMap.enabled, shadowMapType: n2.shadowMap.type, pixelRatio: n2.getPixelRatio(), outputColorSpace: n2.outputColorSpace };
1567
+ e4.add(s2, "toneMapping", { "无": t.NoToneMapping, "线性": t.LinearToneMapping, Reinhard: t.ReinhardToneMapping, Cineon: t.CineonToneMapping, ACESFilmic: t.ACESFilmicToneMapping }).name("色调映射").onChange((e5) => {
1568
+ n2.toneMapping = e5;
1569
+ }), e4.add(s2, "toneMappingExposure", 0, 3, 0.1).name("曝光度").onChange((e5) => {
1570
+ n2.toneMappingExposure = e5;
1571
+ }), e4.add(s2, "shadowMapEnabled").name("阴影").onChange((e5) => {
1572
+ n2.shadowMap.enabled = e5;
1573
+ }), e4.add(s2, "pixelRatio", 0.5, 3, 0.1).name("像素比").onChange((e5) => {
1574
+ n2.setPixelRatio(e5);
1575
+ });
1576
+ }
1577
+ createCameraFolder() {
1578
+ if (!this.sceneFolder) return;
1579
+ const e4 = this.sceneFolder.addFolder("相机配置"), t2 = this.camera;
1580
+ e4.add(t2, "fov", 10, 120, 1).name("视角").onChange(() => {
1581
+ t2.updateProjectionMatrix();
1582
+ }), e4.add(t2, "near", 0.01, 100, 0.01).name("近裁剪面").onChange(() => {
1583
+ t2.updateProjectionMatrix();
1584
+ }), e4.add(t2, "far", 100, 1e5, 100).name("远裁剪面").onChange(() => {
1585
+ t2.updateProjectionMatrix();
1586
+ });
1587
+ const n2 = e4.addFolder("位置");
1588
+ n2.add(t2.position, "x", -1e3, 1e3, 1).listen(), n2.add(t2.position, "y", -1e3, 1e3, 1).listen(), n2.add(t2.position, "z", -1e3, 1e3, 1).listen();
1589
+ }
1590
+ createOrbitControlsFolder() {
1591
+ var _a;
1592
+ if (!this.sceneFolder) return;
1593
+ const e4 = (_a = this.pluginManager) == null ? void 0 : _a.get("orbit-controller");
1594
+ if (!(e4 == null ? void 0 : e4.controls)) return;
1595
+ const t2 = this.sceneFolder.addFolder("轨道控制"), n2 = e4.controls;
1596
+ t2.add(n2, "enableDamping").name("阻尼"), t2.add(n2, "dampingFactor", 0, 1, 0.01).name("阻尼系数"), t2.add(n2, "enableZoom").name("缩放"), t2.add(n2, "enableRotate").name("旋转"), t2.add(n2, "enablePan").name("平移"), t2.add(n2, "autoRotate").name("自动旋转"), t2.add(n2, "autoRotateSpeed", 0, 10, 0.1).name("旋转速度"), t2.add(n2, "minDistance", 0, 1e3, 1).name("最小距离"), t2.add(n2, "maxDistance", 0, 1e4, 10).name("最大距离"), t2.add(n2, "maxPolarAngle", 0, Math.PI, 0.01).name("最大极角");
1597
+ }
1598
+ createEnvironmentFolder() {
1599
+ var _a, _b;
1600
+ if (!this.sceneFolder) return;
1601
+ const e4 = this.sceneFolder.addFolder("环境配置"), n2 = this.scene, s2 = e4.addFolder("雾配置"), i2 = { enabled: !!n2.fog, color: n2.fog ? "#" + n2.fog.color.getHexString() : "#cccccc", near: ((_a = n2.fog) == null ? void 0 : _a.near) ?? 1, far: ((_b = n2.fog) == null ? void 0 : _b.far) ?? 1e3 };
1602
+ s2.add(i2, "enabled").name("启用").onChange((e5) => {
1603
+ n2.fog = e5 ? new t.Fog(i2.color, i2.near, i2.far) : null;
1604
+ }), s2.addColor(i2, "color").name("颜色").onChange((e5) => {
1605
+ n2.fog && n2.fog.color.set(e5);
1606
+ }), s2.add(i2, "near", 0, 1e3, 1).name("近距离").onChange((e5) => {
1607
+ n2.fog && (n2.fog.near = e5);
1608
+ }), s2.add(i2, "far", 0, 1e4, 10).name("远距离").onChange((e5) => {
1609
+ n2.fog && (n2.fog.far = e5);
1610
+ });
1611
+ e4.addColor({ color: "#000000" }, "color").name("背景颜色").onChange((e5) => {
1612
+ n2.background = new t.Color(e5);
1613
+ });
1614
+ }
1615
+ createLightGroupFolder() {
1616
+ if (!this.sceneFolder) return;
1617
+ const e4 = this.sceneFolder.addFolder("灯光配置");
1618
+ this.lightListFolder = e4.addFolder("灯光列表"), e4.add(this.lightParams, "lightType", it).name("光源类型"), e4.add({ fn: () => {
1619
+ const e5 = this.createLight(this.lightParams.lightType);
1620
+ this.scene.add(e5), this.addLightPanel(e5), this.events.emit("light:add", { light: e5 });
1621
+ } }, "fn").name("添加光源"), this.scene.children.forEach((e5) => {
1622
+ e5 instanceof t.Light && this.addLightPanel(e5);
1623
+ });
1624
+ }
1625
+ createLight(e4) {
1626
+ switch (e4) {
1627
+ case "AmbientLight":
1628
+ default:
1629
+ return new t.AmbientLight(16777215, 0.5);
1630
+ case "DirectionalLight":
1631
+ const e5 = new t.DirectionalLight(16777215, 1);
1632
+ return e5.position.set(5, 10, 5), e5.castShadow = true, e5;
1633
+ case "PointLight":
1634
+ const n2 = new t.PointLight(16777215, 1, 100);
1635
+ return n2.position.set(0, 5, 0), n2;
1636
+ case "SpotLight":
1637
+ const s2 = new t.SpotLight(16777215, 1);
1638
+ return s2.position.set(0, 10, 0), s2.castShadow = true, s2;
1639
+ case "HemisphereLight":
1640
+ return new t.HemisphereLight(16777215, 4473924, 1);
1641
+ case "RectAreaLight":
1642
+ const i2 = new t.RectAreaLight(16777215, 1, 10, 10);
1643
+ return i2.position.set(0, 5, 0), i2;
1644
+ }
1645
+ }
1646
+ addLightPanel(e4) {
1647
+ var _a;
1648
+ if (!this.lightListFolder) return;
1649
+ const n2 = this.lightListFolder.addFolder(e4.type + e4.id), s2 = (_a = this.pluginManager) == null ? void 0 : _a.get("transform-controller"), i2 = { color: "#" + e4.color.getHexString() };
1650
+ if (n2.addColor(i2, "color").name("颜色").onChange((t2) => {
1651
+ e4.color.set(t2);
1652
+ }), n2.add(e4, "intensity", 0, 10, 0.1).name("强度"), !(e4 instanceof t.AmbientLight || e4 instanceof t.HemisphereLight)) {
1653
+ const t2 = n2.addFolder("位置");
1654
+ t2.add(e4.position, "x", -100, 100, 0.1).listen(), t2.add(e4.position, "y", -100, 100, 0.1).listen(), t2.add(e4.position, "z", -100, 100, 0.1).listen();
1655
+ }
1656
+ void 0 !== e4.castShadow && n2.add(e4, "castShadow").name("投射阴影"), n2.add({ fn: () => {
1657
+ (s2 == null ? void 0 : s2.controls) && s2.controls.attach(e4);
1658
+ } }, "fn").name("选中"), n2.add({ fn: () => {
1659
+ var _a2, _b;
1660
+ (_a2 = e4.parent) == null ? void 0 : _a2.remove(e4), (_b = this.lightListFolder) == null ? void 0 : _b.removeFolder(n2);
1661
+ } }, "fn").name("删除");
1662
+ }
1663
+ createComposerFolder() {
1664
+ var _a;
1665
+ if (!this.sceneFolder) return;
1666
+ const e4 = (_a = this.pluginManager) == null ? void 0 : _a.get("composer");
1667
+ if (!e4) return;
1668
+ const t2 = this.sceneFolder.addFolder("后期处理"), n2 = t2.addFolder("轮廓光"), s2 = e4.outlinePass;
1669
+ if (s2) {
1670
+ n2.add(s2, "enabled").name("启用"), n2.add(s2, "edgeStrength", 0, 10, 0.1).name("边缘强度"), n2.add(s2, "edgeGlow", 0, 5, 0.1).name("边缘发光"), n2.add(s2, "edgeThickness", 0, 5, 0.1).name("边缘厚度"), n2.add(s2, "pulsePeriod", 0, 5, 0.1).name("脉冲周期");
1671
+ const e5 = { visibleEdgeColor: "#" + s2.visibleEdgeColor.getHexString(), hiddenEdgeColor: "#" + s2.hiddenEdgeColor.getHexString() };
1672
+ n2.addColor(e5, "visibleEdgeColor").name("可见边缘颜色").onChange((e6) => {
1673
+ s2.visibleEdgeColor.set(e6);
1674
+ }), n2.addColor(e5, "hiddenEdgeColor").name("隐藏边缘颜色").onChange((e6) => {
1675
+ s2.hiddenEdgeColor.set(e6);
1676
+ });
1677
+ }
1678
+ const i2 = t2.addFolder("泛光"), o2 = e4.bloomPass;
1679
+ o2 && (i2.add(o2, "enabled").name("启用"), i2.add(o2, "strength", 0, 3, 0.1).name("强度"), i2.add(o2, "radius", 0, 1, 0.01).name("半径"), i2.add(o2, "threshold", 0, 1, 0.01).name("阈值"));
1680
+ }
1681
+ createControlFolder() {
1682
+ this._gui && (this.controlFolder = this._gui.addFolder("控制配置"), this.controlFolder.add(this.handlerParams, "mode", ["选择", "根选择", "变换", "场景绘制", "点击信息"]).name("模式").listen().onChange((e4) => {
1683
+ this.events.emit("mode:change", { mode: e4 });
1684
+ }), this.controlFolder.add(this.handlerParams, "isTransformChildren").name("子变换").listen(), this.controlFolder.add(this.handlerParams, "openKey").name("开启按键").listen().onChange((e4) => {
1685
+ this.events.emit("keyboard:toggle", { enabled: e4 });
1686
+ }), this.createSyncTransformFolder(), this.createStatsFolder(), this.createHelpersFolder(), this.createTransformControlsFolder(), this.config.closed || this.controlFolder.open());
1687
+ }
1688
+ createSyncTransformFolder() {
1689
+ if (!this.controlFolder) return;
1690
+ const e4 = this.controlFolder.addFolder("同步控制"), t2 = { syncPosition: false, syncRotation: false, syncScale: false };
1691
+ e4.add(t2, "syncPosition").name("同步位置"), e4.add(t2, "syncRotation").name("同步旋转"), e4.add(t2, "syncScale").name("同步缩放");
1692
+ }
1693
+ createStatsFolder() {
1694
+ if (!this.controlFolder) return;
1695
+ const e4 = this.controlFolder.addFolder("性能监控"), t2 = { showStats: false, statsMode: 0 };
1696
+ e4.add(t2, "showStats").name("显示性能").onChange((e5) => {
1697
+ this.events.emit("stats:toggle", { enabled: e5 });
1698
+ }), e4.add(t2, "statsMode", { FPS: 0, MS: 1, MB: 2 }).name("模式").onChange((e5) => {
1699
+ this.events.emit("stats:mode", { mode: e5 });
1700
+ });
1701
+ }
1702
+ createHelpersFolder() {
1703
+ if (!this.controlFolder) return;
1704
+ const e4 = this.controlFolder.addFolder("辅助工具"), t2 = { showGrid: true, showAxes: true, gridSize: 100, gridDivisions: 100, axesSize: 5 };
1705
+ e4.add(t2, "showGrid").name("显示网格").onChange((e5) => {
1706
+ this.events.emit("helper:grid", { enabled: e5, size: t2.gridSize, divisions: t2.gridDivisions });
1707
+ }), e4.add(t2, "gridSize", 10, 500, 10).name("网格大小").onChange((e5) => {
1708
+ this.events.emit("helper:grid", { enabled: t2.showGrid, size: e5, divisions: t2.gridDivisions });
1709
+ }), e4.add(t2, "gridDivisions", 10, 200, 10).name("网格分割").onChange((e5) => {
1710
+ this.events.emit("helper:grid", { enabled: t2.showGrid, size: t2.gridSize, divisions: e5 });
1711
+ }), e4.add(t2, "showAxes").name("显示坐标轴").onChange((e5) => {
1712
+ this.events.emit("helper:axes", { enabled: e5, size: t2.axesSize });
1713
+ }), e4.add(t2, "axesSize", 1, 50, 1).name("坐标轴大小").onChange((e5) => {
1714
+ this.events.emit("helper:axes", { enabled: t2.showAxes, size: e5 });
1715
+ });
1716
+ }
1717
+ createTransformControlsFolder() {
1718
+ var _a;
1719
+ if (!this.controlFolder) return;
1720
+ const e4 = (_a = this.pluginManager) == null ? void 0 : _a.get("transform-controller");
1721
+ if (!(e4 == null ? void 0 : e4.controls)) return;
1722
+ const t2 = this.controlFolder.addFolder("变换控制器配置"), n2 = e4.controls;
1723
+ t2.add(n2, "mode", ["translate", "rotate", "scale"]).name("模式"), t2.add(n2, "space", ["world", "local"]).name("空间"), t2.add(n2, "size", 0.1, 5, 0.1).name("大小"), t2.add(n2, "showX").name("显示X轴"), t2.add(n2, "showY").name("显示Y轴"), t2.add(n2, "showZ").name("显示Z轴");
1724
+ const s2 = { translationSnap: n2.translationSnap ?? 0, rotationSnap: n2.rotationSnap ?? 0 };
1725
+ t2.add(s2, "translationSnap", 0, 10, 0.1).name("平移吸附").onChange((e5) => {
1726
+ n2.setTranslationSnap(0 === e5 ? null : e5);
1727
+ }), t2.add(s2, "rotationSnap", 0, Math.PI / 4, 0.01).name("旋转吸附").onChange((e5) => {
1728
+ n2.setRotationSnap(0 === e5 ? null : e5);
1729
+ });
1730
+ }
1731
+ createMeshFolder() {
1732
+ this._gui && (this.meshFolder = this._gui.addFolder("3D物体"), this.createModelFolder(), this.createDrawFolder(), this.createInnerMeshFolder(), this.createGeoMapFolder(), this.createParticleFolder(), this.createBorderGroupFolder(), this.createTextMeshFolder(), this.createDesignMeshFolder(), this.config.closed || this.meshFolder.open());
1733
+ }
1734
+ createModelFolder() {
1735
+ if (!this.meshFolder) return;
1736
+ const e4 = this.meshFolder.addFolder("模型配置");
1737
+ this.modelListFolder = e4.addFolder("已有列表");
1738
+ const t2 = { dracoPath: "/draco/", loadGLTF: () => {
1739
+ this.openFileDialog(".glb,.gltf", (e5) => {
1740
+ this.events.emit("model:load", { file: e5, type: "GLTF" });
1741
+ });
1742
+ }, loadFBX: () => {
1743
+ this.openFileDialog(".fbx", (e5) => {
1744
+ this.events.emit("model:load", { file: e5, type: "FBX" });
1745
+ });
1746
+ }, loadOBJ: () => {
1747
+ this.openFileDialog(".obj", (e5) => {
1748
+ this.events.emit("model:load", { file: e5, type: "OBJ" });
1749
+ });
1750
+ } };
1751
+ e4.add(t2, "dracoPath").name("Draco路径"), e4.add(t2, "loadGLTF").name("加载GLTF"), e4.add(t2, "loadFBX").name("加载FBX"), e4.add(t2, "loadOBJ").name("加载OBJ");
1752
+ }
1753
+ addModelPanel(e4) {
1754
+ var _a, _b, _c, _d;
1755
+ if (!this.modelListFolder) return;
1756
+ const n2 = this.modelListFolder.addFolder(e4.name + e4.id), s2 = (_a = this.pluginManager) == null ? void 0 : _a.get("transform-controller"), i2 = (_b = this.pluginManager) == null ? void 0 : _b.get("orbit-controller"), o2 = (_c = this.pluginManager) == null ? void 0 : _c.get("composer");
1757
+ this.addMeshControlPanel(e4, n2.addFolder("物体控制")), this.addGroupGlobalPanel(e4, n2.addFolder("全局和子项控制")), ((_d = e4.animations) == null ? void 0 : _d.length) > 0 && this.addGroupAnimationPanel(e4, n2.addFolder("动画配置")), n2.add({ fn: () => {
1758
+ (s2 == null ? void 0 : s2.controls) && s2.controls.attach(e4);
1759
+ } }, "fn").name("选中"), n2.add({ fn: () => {
1760
+ if (i2 == null ? void 0 : i2.controls) {
1761
+ const n3 = new t.Box3().setFromObject(e4), s3 = n3.getCenter(new t.Vector3()), o3 = n3.getSize(new t.Vector3()), r2 = 2 * Math.max(o3.x, o3.y, o3.z);
1762
+ i2.controls.target.copy(s3), this.camera.position.copy(s3).add(new t.Vector3(r2, r2, r2));
1763
+ }
1764
+ (s2 == null ? void 0 : s2.controls) && s2.controls.attach(e4), o2 && o2.setOutlineObjects([e4]);
1765
+ } }, "fn").name("定位物体"), n2.add({ fn: () => {
1766
+ var _a2, _b2;
1767
+ (s2 == null ? void 0 : s2.controls) && s2.controls.detach(), (_a2 = e4.parent) == null ? void 0 : _a2.remove(e4), (_b2 = this.modelListFolder) == null ? void 0 : _b2.removeFolder(n2);
1768
+ } }, "fn").name("删除");
1769
+ }
1770
+ addMeshControlPanel(e4, t2) {
1771
+ t2.add(e4, "visible").name("可见");
1772
+ const n2 = t2.addFolder("位置");
1773
+ n2.add(e4.position, "x", -1e3, 1e3, 0.1).listen(), n2.add(e4.position, "y", -1e3, 1e3, 0.1).listen(), n2.add(e4.position, "z", -1e3, 1e3, 0.1).listen();
1774
+ const s2 = t2.addFolder("旋转");
1775
+ s2.add(e4.rotation, "x", -Math.PI, Math.PI, 0.01).listen(), s2.add(e4.rotation, "y", -Math.PI, Math.PI, 0.01).listen(), s2.add(e4.rotation, "z", -Math.PI, Math.PI, 0.01).listen();
1776
+ const i2 = t2.addFolder("缩放");
1777
+ i2.add(e4.scale, "x", 0.01, 10, 0.01).listen(), i2.add(e4.scale, "y", 0.01, 10, 0.01).listen(), i2.add(e4.scale, "z", 0.01, 10, 0.01).listen();
1778
+ i2.add({ scale: 1 }, "scale", 0.01, 10, 0.01).name("统一缩放").onChange((t3) => {
1779
+ e4.scale.set(t3, t3, t3);
1780
+ }), e4.isMesh && (t2.add(e4, "castShadow").name("投射阴影"), t2.add(e4, "receiveShadow").name("接收阴影"));
1781
+ }
1782
+ addGroupGlobalPanel(e4, t2) {
1783
+ const n2 = e4.globalConfig || { useGlobalConfig: false, isSaveChildren: true, isSaveMaterials: true, mesh: { castShadow: false, receiveShadow: false }, material: { envMap: false, envMapIntensity: 1, reflectivity: 0.98 } };
1784
+ e4.globalConfig = n2, t2.add(n2, "useGlobalConfig").name("使用全局配置"), t2.add(n2, "isSaveChildren").name("保存子项"), t2.add(n2, "isSaveMaterials").name("保存材质");
1785
+ const s2 = t2.addFolder("网格配置");
1786
+ s2.add(n2.mesh, "castShadow").name("投射阴影").onChange((t3) => {
1787
+ n2.useGlobalConfig && e4.traverse((e5) => {
1788
+ e5.isMesh && (e5.castShadow = t3);
1789
+ });
1790
+ }), s2.add(n2.mesh, "receiveShadow").name("接收阴影").onChange((t3) => {
1791
+ n2.useGlobalConfig && e4.traverse((e5) => {
1792
+ e5.isMesh && (e5.receiveShadow = t3);
1793
+ });
1794
+ });
1795
+ t2.addFolder("材质配置").add(n2.material, "envMapIntensity", 0, 5, 0.1).name("环境贴图强度").onChange((t3) => {
1796
+ n2.useGlobalConfig && e4.traverse((e5) => {
1797
+ if (e5.isMesh) {
1798
+ (Array.isArray(e5.material) ? e5.material : [e5.material]).forEach((e6) => {
1799
+ void 0 !== e6.envMapIntensity && (e6.envMapIntensity = t3);
1800
+ });
1801
+ }
1802
+ });
1803
+ });
1804
+ }
1805
+ addGroupAnimationPanel(e4, t2) {
1806
+ const n2 = e4.animations;
1807
+ if (!n2 || 0 === n2.length) return;
1808
+ const s2 = e4.animationPlayParams || { initPlay: false, speed: 0.5, actionIndexs: new Array(n2.length).fill(false), startTime: 0, loop: false };
1809
+ e4.animationPlayParams = s2, t2.add(s2, "initPlay").name("初始播放"), t2.add(s2, "speed", 0, 2, 0.1).name("速度"), t2.add(s2, "startTime", 0, 10, 0.1).name("开始时间"), t2.add(s2, "loop").name("循环");
1810
+ const i2 = t2.addFolder("动画列表");
1811
+ n2.forEach((e5, t3) => {
1812
+ i2.add(s2.actionIndexs, t3.toString()).name(e5.name || `动画${t3}`);
1813
+ }), t2.add({ play: () => {
1814
+ this.events.emit("animation:play", { group: e4, params: s2 });
1815
+ } }, "play").name("播放"), t2.add({ stop: () => {
1816
+ this.events.emit("animation:stop", { group: e4 });
1817
+ } }, "stop").name("停止");
1818
+ }
1819
+ createDrawFolder() {
1820
+ if (!this.meshFolder) return;
1821
+ const e4 = this.meshFolder.addFolder("绘制配置");
1822
+ this.drawMeshListFolder = e4.addFolder("已有列表"), e4.add(this.drawParams, "mode", ot).name("绘制模式"), e4.add(this.drawParams, "pointMode", rt).name("点模式"), e4.add(this.drawParams, "materialType", st).name("材质"), e4.add({ fn: () => {
1823
+ this.events.emit("draw:start", { mode: this.drawParams.mode, pointMode: this.drawParams.pointMode, materialType: this.drawParams.materialType });
1824
+ } }, "fn").name("添加绘制组");
1825
+ }
1826
+ addDrawMeshPanel(e4) {
1827
+ var _a;
1828
+ if (!this.drawMeshListFolder) return;
1829
+ const t2 = this.drawMeshListFolder.addFolder(e4.name + e4.id), n2 = (_a = this.pluginManager) == null ? void 0 : _a.get("transform-controller");
1830
+ this.addMeshControlPanel(e4, t2.addFolder("物体控制")), t2.add({ fn: () => {
1831
+ (n2 == null ? void 0 : n2.controls) && n2.controls.attach(e4);
1832
+ } }, "fn").name("选中"), t2.add({ fn: () => {
1833
+ var _a2, _b;
1834
+ (n2 == null ? void 0 : n2.controls) && n2.controls.detach(), (_a2 = e4.parent) == null ? void 0 : _a2.remove(e4), (_b = this.drawMeshListFolder) == null ? void 0 : _b.removeFolder(t2);
1835
+ } }, "fn").name("删除");
1836
+ }
1837
+ createInnerMeshFolder() {
1838
+ if (!this.meshFolder) return;
1839
+ const e4 = this.meshFolder.addFolder("内置物体");
1840
+ this.innerMeshListFolder = e4.addFolder("已有列表"), e4.add(this.innerMeshParams, "geometryType", nt).name("几何体"), e4.add(this.innerMeshParams, "materialType", st).name("材质"), e4.add({ fn: () => {
1841
+ var _a;
1842
+ const e5 = this.createGeometry(this.innerMeshParams.geometryType), n2 = this.createMaterial(this.innerMeshParams.materialType), s2 = new t.Mesh(e5, n2);
1843
+ s2.isInnerMesh = true, s2.geometryType = this.innerMeshParams.geometryType, s2.materialType = this.innerMeshParams.materialType, this.scene.add(s2), this.addInnerMeshPanel(s2);
1844
+ const i2 = (_a = this.pluginManager) == null ? void 0 : _a.get("transform-controller");
1845
+ (i2 == null ? void 0 : i2.controls) && i2.controls.attach(s2), this.events.emit("innermesh:add", { mesh: s2 });
1846
+ } }, "fn").name("添加");
1847
+ }
1848
+ addInnerMeshPanel(e4) {
1849
+ var _a;
1850
+ if (!this.innerMeshListFolder) return;
1851
+ const t2 = e4.geometryType || "立方体", n2 = this.innerMeshListFolder.addFolder(t2 + ":" + e4.name + e4.id), s2 = (_a = this.pluginManager) == null ? void 0 : _a.get("transform-controller");
1852
+ this.addMeshControlPanel(e4, n2.addFolder("物体控制")), this.addMaterialPanel(e4.material, n2.addFolder("材质配置")), n2.add({ fn: () => {
1853
+ (s2 == null ? void 0 : s2.controls) && s2.controls.attach(e4);
1854
+ } }, "fn").name("选中"), n2.add({ fn: () => {
1855
+ var _a2, _b;
1856
+ (s2 == null ? void 0 : s2.controls) && s2.controls.detach(), (_a2 = e4.parent) == null ? void 0 : _a2.remove(e4), (_b = this.innerMeshListFolder) == null ? void 0 : _b.removeFolder(n2);
1857
+ } }, "fn").name("删除");
1858
+ }
1859
+ addMaterialPanel(e4, n2) {
1860
+ if (e4) {
1861
+ if (e4.color) {
1862
+ const t2 = { color: "#" + e4.color.getHexString() };
1863
+ n2.addColor(t2, "color").name("颜色").onChange((t3) => {
1864
+ e4.color.set(t3);
1865
+ });
1866
+ }
1867
+ if (e4.emissive) {
1868
+ const t2 = { emissive: "#" + e4.emissive.getHexString() };
1869
+ n2.addColor(t2, "emissive").name("发光颜色").onChange((t3) => {
1870
+ e4.emissive.set(t3);
1871
+ }), n2.add(e4, "emissiveIntensity", 0, 5, 0.1).name("发光强度");
1872
+ }
1873
+ n2.add(e4, "transparent").name("透明"), n2.add(e4, "opacity", 0, 1, 0.01).name("透明度"), n2.add(e4, "side", { "正面": t.FrontSide, "背面": t.BackSide, "双面": t.DoubleSide }).name("渲染面"), void 0 !== e4.wireframe && n2.add(e4, "wireframe").name("线框"), void 0 !== e4.metalness && n2.add(e4, "metalness", 0, 1, 0.01).name("金属度"), void 0 !== e4.roughness && n2.add(e4, "roughness", 0, 1, 0.01).name("粗糙度"), void 0 !== e4.envMapIntensity && n2.add(e4, "envMapIntensity", 0, 5, 0.1).name("环境贴图强度");
1874
+ }
1875
+ }
1876
+ createGeoMapFolder() {
1877
+ if (!this.meshFolder) return;
1878
+ const e4 = this.meshFolder.addFolder("三维地图");
1879
+ this.geoMapListFolder = e4.addFolder("地图列表"), e4.add(this.geoMapParams, "url").name("地图数据地址"), e4.add(this.geoMapParams, "materialType", st).name("地图材质类型"), e4.add({ fn: () => {
1880
+ const e5 = this.geoMapParams.url || "https://z2586300277.github.io/3d-file-server/files/json/guangdong.json";
1881
+ this.events.emit("geomap:load", { url: e5, materialType: this.geoMapParams.materialType });
1882
+ } }, "fn").name("添加地图");
1883
+ }
1884
+ addGeoMapPanel(e4) {
1885
+ var _a;
1886
+ if (!this.geoMapListFolder) return;
1887
+ const t2 = this.geoMapListFolder.addFolder(e4.name + e4.id), n2 = (_a = this.pluginManager) == null ? void 0 : _a.get("transform-controller");
1888
+ this.addMeshControlPanel(e4, t2.addFolder("物体控制")), t2.add({ fn: () => {
1889
+ (n2 == null ? void 0 : n2.controls) && n2.controls.attach(e4);
1890
+ } }, "fn").name("选中"), t2.add({ fn: () => {
1891
+ var _a2, _b;
1892
+ (n2 == null ? void 0 : n2.controls) && n2.controls.detach(), (_a2 = e4.parent) == null ? void 0 : _a2.remove(e4), (_b = this.geoMapListFolder) == null ? void 0 : _b.removeFolder(t2);
1893
+ } }, "fn").name("删除");
1894
+ }
1895
+ createParticleFolder() {
1896
+ if (!this.meshFolder) return;
1897
+ const e4 = this.meshFolder.addFolder("粒子物体");
1898
+ this.particleListFolder = e4.addFolder("粒子列表");
1899
+ const t2 = e4.addFolder("初始化参数");
1900
+ t2.add(this.particleParams, "particlesSum").name("数量"), t2.add(this.particleParams, "inner").name("内半径"), t2.add(this.particleParams, "outer").name("外半径"), t2.add(this.particleParams, "maxVelocity").name("最大速度"), t2.add(this.particleParams, "mapUrl").name("贴图路径"), t2.add(this.particleParams, "shaderCodeName", ["水波纹", "火焰", "烟雾", "雪花", "星空"]).name("着色器"), t2.add(this.particleParams, "sportType", ["全随机", "随机向下", "随机向上", "直线匀速向上", "直线匀速向下"]).name("运动方式"), e4.add({ fn: () => {
1901
+ this.events.emit("particle:create", { ...this.particleParams });
1902
+ } }, "fn").name("增加一个粒子物体");
1903
+ }
1904
+ addParticlePanel(e4) {
1905
+ var _a;
1906
+ if (!this.particleListFolder) return;
1907
+ const t2 = this.particleListFolder.addFolder(e4.name + e4.id), n2 = (_a = this.pluginManager) == null ? void 0 : _a.get("transform-controller");
1908
+ this.addMeshControlPanel(e4, t2.addFolder("物体控制")), t2.add({ fn: () => {
1909
+ (n2 == null ? void 0 : n2.controls) && n2.controls.attach(e4);
1910
+ } }, "fn").name("选中"), t2.add({ fn: () => {
1911
+ var _a2, _b;
1912
+ (n2 == null ? void 0 : n2.controls) && n2.controls.detach(), (_a2 = e4.parent) == null ? void 0 : _a2.remove(e4), (_b = this.particleListFolder) == null ? void 0 : _b.removeFolder(t2);
1913
+ } }, "fn").name("删除");
1914
+ }
1915
+ createBorderGroupFolder() {
1916
+ if (!this.meshFolder) return;
1917
+ const e4 = this.meshFolder.addFolder("边界物体");
1918
+ this.borderGroupListFolder = e4.addFolder("列表"), e4.add(this.borderGroupParams, "url").name("边界物体数据源"), e4.add(this.borderGroupParams, "materialType", st).name("材质类型"), e4.add(this.borderGroupParams, "dlength", 0).name("低于点数舍弃"), e4.add({ fn: () => {
1919
+ this.events.emit("bordergroup:create", { ...this.borderGroupParams });
1920
+ } }, "fn").name("添加边界物体");
1921
+ }
1922
+ addBorderGroupPanel(e4) {
1923
+ var _a;
1924
+ if (!this.borderGroupListFolder) return;
1925
+ const t2 = this.borderGroupListFolder.addFolder(e4.name + e4.id), n2 = (_a = this.pluginManager) == null ? void 0 : _a.get("transform-controller");
1926
+ this.addMeshControlPanel(e4, t2.addFolder("物体控制")), t2.add({ fn: () => {
1927
+ (n2 == null ? void 0 : n2.controls) && n2.controls.attach(e4);
1928
+ } }, "fn").name("选中"), t2.add({ fn: () => {
1929
+ var _a2, _b;
1930
+ (n2 == null ? void 0 : n2.controls) && n2.controls.detach(), (_a2 = e4.parent) == null ? void 0 : _a2.remove(e4), (_b = this.borderGroupListFolder) == null ? void 0 : _b.removeFolder(t2);
1931
+ } }, "fn").name("删除");
1932
+ }
1933
+ createTextMeshFolder() {
1934
+ if (!this.meshFolder) return;
1935
+ const e4 = this.meshFolder.addFolder("文本物体");
1936
+ this.textMeshListFolder = e4.addFolder("列表"), e4.add(this.textMeshParams, "fontLink").name("字体链接"), e4.add(this.textMeshParams, "materialType", st).name("材质类型"), e4.add(this.textMeshParams, "text").name("文本内容"), e4.add({ fn: () => {
1937
+ this.textMeshParams.text && this.events.emit("textmesh:create", { ...this.textMeshParams });
1938
+ } }, "fn").name("添加文本物体");
1939
+ }
1940
+ addTextMeshPanel(e4) {
1941
+ var _a;
1942
+ if (!this.textMeshListFolder) return;
1943
+ const t2 = e4.text || e4.name, n2 = this.textMeshListFolder.addFolder(t2 + e4.id), s2 = (_a = this.pluginManager) == null ? void 0 : _a.get("transform-controller");
1944
+ this.addMeshControlPanel(e4, n2.addFolder("物体控制")), this.addMaterialPanel(e4.material, n2.addFolder("材质配置")), n2.add({ fn: () => {
1945
+ (s2 == null ? void 0 : s2.controls) && s2.controls.attach(e4);
1946
+ } }, "fn").name("选中"), n2.add({ fn: () => {
1947
+ var _a2, _b;
1948
+ (s2 == null ? void 0 : s2.controls) && s2.controls.detach(), (_a2 = e4.parent) == null ? void 0 : _a2.remove(e4), (_b = this.textMeshListFolder) == null ? void 0 : _b.removeFolder(n2);
1949
+ } }, "fn").name("删除");
1950
+ }
1951
+ createDesignMeshFolder() {
1952
+ if (!this.meshFolder) return;
1953
+ const e4 = this.meshFolder.addFolder("设计物体");
1954
+ this.designMeshListFolder = e4.addFolder("列表"), e4.add(this.designMeshParams, "type", ["镜面", "水面", "玻璃", "发光体"]).name("类型"), e4.add({ fn: () => {
1955
+ this.events.emit("designmesh:create", { type: this.designMeshParams.type });
1956
+ } }, "fn").name("添加");
1957
+ }
1958
+ addDesignMeshPanel(e4) {
1959
+ var _a;
1960
+ if (!this.designMeshListFolder) return;
1961
+ const t2 = this.designMeshListFolder.addFolder(e4.id + (e4.name || "")), n2 = (_a = this.pluginManager) == null ? void 0 : _a.get("transform-controller");
1962
+ this.addMeshControlPanel(e4, t2.addFolder("物体控制")), t2.add({ fn: () => {
1963
+ (n2 == null ? void 0 : n2.controls) && n2.controls.attach(e4);
1964
+ } }, "fn").name("选中"), t2.add({ fn: () => {
1965
+ var _a2, _b;
1966
+ (n2 == null ? void 0 : n2.controls) && n2.controls.detach(), (_a2 = e4.parent) == null ? void 0 : _a2.remove(e4), (_b = this.designMeshListFolder) == null ? void 0 : _b.removeFolder(t2);
1967
+ } }, "fn").name("删除");
1968
+ }
1969
+ createAnimationFolder() {
1970
+ this._gui && (this.animationFolder = this._gui.addFolder("动画配置"), this.createOrbitAnimationFolder(), this.createMeshAnimationFolder(), this.createMoveAnimationFolder());
1971
+ }
1972
+ createOrbitAnimationFolder() {
1973
+ var _a;
1974
+ if (!this.animationFolder) return;
1975
+ const e4 = this.animationFolder.addFolder("视角控制"), t2 = (_a = this.pluginManager) == null ? void 0 : _a.get("orbit-controller");
1976
+ if (!(t2 == null ? void 0 : t2.controls)) return;
1977
+ const n2 = t2.controls, s2 = { autoRotate: n2.autoRotate, autoRotateSpeed: n2.autoRotateSpeed, enableDamping: n2.enableDamping, dampingFactor: n2.dampingFactor };
1978
+ e4.add(s2, "autoRotate").name("自动旋转").onChange((e5) => {
1979
+ n2.autoRotate = e5;
1980
+ }), e4.add(s2, "autoRotateSpeed", 0, 10, 0.1).name("旋转速度").onChange((e5) => {
1981
+ n2.autoRotateSpeed = e5;
1982
+ }), e4.add({ fn: () => {
1983
+ this.events.emit("camera:preset", { preset: "front" });
1984
+ } }, "fn").name("正视图"), e4.add({ fn: () => {
1985
+ this.events.emit("camera:preset", { preset: "top" });
1986
+ } }, "fn").name("俯视图"), e4.add({ fn: () => {
1987
+ this.events.emit("camera:preset", { preset: "side" });
1988
+ } }, "fn").name("侧视图");
1989
+ }
1990
+ createMeshAnimationFolder() {
1991
+ if (!this.animationFolder) return;
1992
+ const e4 = this.animationFolder.addFolder("物体动画"), t2 = { duration: 2, ease: "power2.inOut", repeat: 0, yoyo: false };
1993
+ e4.add(t2, "duration", 0.1, 10, 0.1).name("持续时间"), e4.add(t2, "ease", ["none", "power1.in", "power1.out", "power1.inOut", "power2.in", "power2.out", "power2.inOut", "elastic.out", "bounce.out"]).name("缓动函数"), e4.add(t2, "repeat", -1, 10, 1).name("重复次数"), e4.add(t2, "yoyo").name("往返"), e4.add({ fn: () => {
1994
+ this.events.emit("animation:record", { type: "start", params: t2 });
1995
+ } }, "fn").name("记录起始"), e4.add({ fn: () => {
1996
+ this.events.emit("animation:record", { type: "end", params: t2 });
1997
+ } }, "fn").name("记录结束"), e4.add({ fn: () => {
1998
+ this.events.emit("animation:play", { params: t2 });
1999
+ } }, "fn").name("播放动画");
2000
+ }
2001
+ createMoveAnimationFolder() {
2002
+ if (!this.animationFolder) return;
2003
+ const e4 = this.animationFolder.addFolder("运动动画"), t2 = { speed: 1, loop: false };
2004
+ e4.add(t2, "speed", 0.1, 10, 0.1).name("速度"), e4.add(t2, "loop").name("循环"), e4.add({ fn: () => {
2005
+ this.events.emit("curve:animate", { action: "start", params: t2 });
2006
+ } }, "fn").name("开始运动"), e4.add({ fn: () => {
2007
+ this.events.emit("curve:animate", { action: "pause", params: t2 });
2008
+ } }, "fn").name("暂停运动"), e4.add({ fn: () => {
2009
+ this.events.emit("curve:animate", { action: "stop", params: t2 });
2010
+ } }, "fn").name("停止运动");
2011
+ }
2012
+ createSelectMeshPanel(e4) {
2013
+ if (this.destroySelectPanel(), this._gui) {
2014
+ if (this.selectPanel = this._gui.addFolder("#:" + e4.name + "配置"), this.addMeshControlPanel(e4, this.selectPanel.addFolder("基础配置")), e4.isMesh) {
2015
+ const t2 = e4;
2016
+ Array.isArray(t2.material) ? t2.material.forEach((e5, t3) => {
2017
+ this.addMaterialPanel(e5, this.selectPanel.addFolder("材质配置" + t3));
2018
+ }) : this.addMaterialPanel(t2.material, this.selectPanel.addFolder("材质配置"));
2019
+ }
2020
+ this.addShaderPanel(e4, this.selectPanel.addFolder("着色器配置")), this.addDesignPanel(e4, this.selectPanel.addFolder("设计配置")), this.selectPanel.open();
2021
+ }
2022
+ }
2023
+ createSelectRootGroupPanel(e4) {
2024
+ if (!e4.RootMaterials) return void this.createSelectMeshPanel(e4);
2025
+ if (this.destroySelectPanel(), !this._gui) return;
2026
+ this.selectPanel = this._gui.addFolder("$:" + e4.name + "配置"), this.addMeshControlPanel(e4, this.selectPanel.addFolder("基础配置"));
2027
+ const t2 = e4.RootMaterials;
2028
+ if (t2 && t2.length > 0) {
2029
+ const e5 = this.selectPanel.addFolder("遍历材质配置");
2030
+ t2.forEach((t3, n2) => {
2031
+ this.addMaterialPanel(t3, e5.addFolder("材质" + n2));
2032
+ });
2033
+ }
2034
+ this.addShaderPanel(e4, this.selectPanel.addFolder("着色器配置")), this.selectPanel.open();
2035
+ }
2036
+ destroySelectPanel() {
2037
+ this.selectPanel && this._gui && (this._gui.removeFolder(this.selectPanel), this.selectPanel = null);
2038
+ }
2039
+ addShaderPanel(e4, t2) {
2040
+ const n2 = { shaderType: "无", intensity: 1 };
2041
+ t2.add(n2, "shaderType", ["无", "发光", "扫描", "流动", "渐变"]).name("着色器类型").onChange((t3) => {
2042
+ this.events.emit("shader:apply", { model: e4, type: t3, intensity: n2.intensity });
2043
+ }), t2.add(n2, "intensity", 0, 5, 0.1).name("强度").onChange((t3) => {
2044
+ this.events.emit("shader:update", { model: e4, intensity: t3 });
2045
+ });
2046
+ }
2047
+ addDesignPanel(e4, t2) {
2048
+ const n2 = { reflector: false, refractor: false };
2049
+ t2.add(n2, "reflector").name("镜面反射").onChange((t3) => {
2050
+ this.events.emit("design:reflector", { model: e4, enabled: t3 });
2051
+ }), t2.add(n2, "refractor").name("折射").onChange((t3) => {
2052
+ this.events.emit("design:refractor", { model: e4, enabled: t3 });
2053
+ });
2054
+ }
2055
+ createGeometry(e4) {
2056
+ switch (e4) {
2057
+ case "立方体":
2058
+ default:
2059
+ return new t.BoxGeometry(1, 1, 1);
2060
+ case "球体":
2061
+ return new t.SphereGeometry(0.5, 32, 32);
2062
+ case "圆柱体":
2063
+ return new t.CylinderGeometry(0.5, 0.5, 1, 32);
2064
+ case "圆锥体":
2065
+ return new t.ConeGeometry(0.5, 1, 32);
2066
+ case "圆环":
2067
+ return new t.TorusGeometry(0.5, 0.2, 16, 100);
2068
+ case "平面":
2069
+ return new t.PlaneGeometry(1, 1);
2070
+ case "圆环结":
2071
+ return new t.TorusKnotGeometry(0.5, 0.15, 100, 16);
2072
+ case "十二面体":
2073
+ return new t.DodecahedronGeometry(0.5);
2074
+ case "二十面体":
2075
+ return new t.IcosahedronGeometry(0.5);
2076
+ case "八面体":
2077
+ return new t.OctahedronGeometry(0.5);
2078
+ case "四面体":
2079
+ return new t.TetrahedronGeometry(0.5);
2080
+ }
2081
+ }
2082
+ createMaterial(e4) {
2083
+ switch (e4) {
2084
+ case "基础材质":
2085
+ return new t.MeshBasicMaterial({ color: 16777215 });
2086
+ case "标准材质":
2087
+ return new t.MeshStandardMaterial({ color: 16777215, metalness: 0.5, roughness: 0.5 });
2088
+ case "Lambert材质":
2089
+ return new t.MeshLambertMaterial({ color: 16777215 });
2090
+ case "Phong材质":
2091
+ return new t.MeshPhongMaterial({ color: 16777215 });
2092
+ case "物理材质":
2093
+ return new t.MeshPhysicalMaterial({ color: 16777215, metalness: 0.5, roughness: 0.5 });
2094
+ case "Toon材质":
2095
+ return new t.MeshToonMaterial({ color: 16777215 });
2096
+ default:
2097
+ return new t.MeshStandardMaterial({ color: 16777215 });
2098
+ }
2099
+ }
2100
+ openFileDialog(e4, t2) {
2101
+ const n2 = document.createElement("input");
2102
+ n2.type = "file", n2.accept = e4, n2.onchange = (e5) => {
2103
+ var _a;
2104
+ const n3 = (_a = e5.target.files) == null ? void 0 : _a[0];
2105
+ n3 && t2(n3);
2106
+ }, n2.click();
2107
+ }
2108
+ addFolder(e4) {
2109
+ var _a;
2110
+ return ((_a = this._gui) == null ? void 0 : _a.addFolder(e4)) ?? null;
2111
+ }
2112
+ setPosition(e4) {
2113
+ this._gui && this._gui.domElement && e4.appendChild(this._gui.domElement);
2114
+ }
2115
+ updateDisplay() {
2116
+ }
2117
+ show() {
2118
+ this._gui && this._gui.show();
2119
+ }
2120
+ hide() {
2121
+ this._gui && this._gui.hide();
2122
+ }
2123
+ destroy() {
2124
+ this._gui && (this._gui.destroy(), this._gui = null), this.sceneFolder = null, this.controlFolder = null, this.meshFolder = null, this.animationFolder = null, this.selectPanel = null, this.modelListFolder = null, this.innerMeshListFolder = null, this.drawMeshListFolder = null, this.geoMapListFolder = null, this.particleListFolder = null, this.borderGroupListFolder = null, this.textMeshListFolder = null, this.designMeshListFolder = null, this.lightListFolder = null;
2125
+ }
2126
+ getConfig() {
2127
+ return { ...this.config };
2128
+ }
2129
+ setMode(e4) {
2130
+ this.handlerParams.mode = e4;
2131
+ }
2132
+ getMode() {
2133
+ return this.handlerParams.mode;
2134
+ }
2135
+ }
2136
+ const lt = { 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 } };
2137
+ class dt extends k {
2138
+ constructor(e4) {
2139
+ super({ ...lt, ...e4 }), this.name = "gizmo", this.gridHelper = null, this.axesHelper = null, this.stats = null, this.viewHelper = null, this.box3Helper = null, this.currentBox3 = null;
2140
+ }
2141
+ onInstall() {
2142
+ this.config.grid.enabled && this.createGridHelper(), this.config.axes.enabled && this.createAxesHelper(), this.config.stats.enabled && this.createStats(), this.config.viewHelper.enabled && this.createViewHelper(), this.subscribe("object:selected", (e4) => {
2143
+ e4.object && this.onObjectSelected(e4.object);
2144
+ }), this.subscribe("object:deselected", () => this.onObjectDeselected());
2145
+ }
2146
+ onUninstall() {
2147
+ this.removeGridHelper(), this.removeAxesHelper(), this.removeStats(), this.removeViewHelper(), this.removeBox3Helper();
2148
+ }
2149
+ createGridHelper() {
2150
+ this.removeGridHelper();
2151
+ const { size: e4, divisions: n2, colorCenterLine: s2, colorGrid: i2 } = this.config.grid;
2152
+ return this.gridHelper = new t.GridHelper(e4, n2, s2, i2), this.gridHelper.name = "__gridHelper__", this.scene.add(this.gridHelper), this.gridHelper;
2153
+ }
2154
+ removeGridHelper() {
2155
+ this.gridHelper && (this.scene.remove(this.gridHelper), this.gridHelper.dispose(), this.gridHelper = null);
2156
+ }
2157
+ setGridVisible(e4) {
2158
+ e4 && !this.gridHelper ? this.createGridHelper() : !e4 && this.gridHelper && this.removeGridHelper(), this.config.grid.enabled = e4;
2159
+ }
2160
+ updateGrid(e4) {
2161
+ Object.assign(this.config.grid, e4), this.config.grid.enabled && this.createGridHelper();
2162
+ }
2163
+ createAxesHelper() {
2164
+ return this.removeAxesHelper(), this.axesHelper = new t.AxesHelper(this.config.axes.size), this.axesHelper.name = "__axesHelper__", this.scene.add(this.axesHelper), this.axesHelper;
2165
+ }
2166
+ removeAxesHelper() {
2167
+ this.axesHelper && (this.scene.remove(this.axesHelper), this.axesHelper.dispose(), this.axesHelper = null);
2168
+ }
2169
+ setAxesVisible(e4) {
2170
+ e4 && !this.axesHelper ? this.createAxesHelper() : !e4 && this.axesHelper && this.removeAxesHelper(), this.config.axes.enabled = e4;
2171
+ }
2172
+ updateAxes(e4) {
2173
+ Object.assign(this.config.axes, e4), this.config.axes.enabled && this.createAxesHelper();
2174
+ }
2175
+ createStats() {
2176
+ var _a;
2177
+ return this.removeStats(), this.stats = new x(), this.stats.showPanel(this.config.stats.mode), this.stats.dom.style.position = "absolute", this.stats.dom.style.top = "0", this.stats.dom.style.left = "0", (_a = this.renderer.domElement.parentElement) == null ? void 0 : _a.appendChild(this.stats.dom), this.stats;
2178
+ }
2179
+ removeStats() {
2180
+ var _a;
2181
+ this.stats && ((_a = this.stats.dom.parentElement) == null ? void 0 : _a.removeChild(this.stats.dom), this.stats = null);
2182
+ }
2183
+ setStatsVisible(e4) {
2184
+ e4 && !this.stats ? this.createStats() : !e4 && this.stats && this.removeStats(), this.config.stats.enabled = e4;
2185
+ }
2186
+ setStatsMode(e4) {
2187
+ this.config.stats.mode = e4, this.stats && this.stats.showPanel(e4);
2188
+ }
2189
+ updateStats() {
2190
+ this.stats && this.stats.update();
2191
+ }
2192
+ createViewHelper() {
2193
+ this.removeViewHelper();
2194
+ try {
2195
+ const e4 = this.renderer.domElement.parentElement;
2196
+ return e4 ? (this.viewHelper = new C(this.camera, e4), this.viewHelper) : null;
2197
+ } catch (e4) {
2198
+ return null;
2199
+ }
2200
+ }
2201
+ removeViewHelper() {
2202
+ this.viewHelper && (this.viewHelper.dispose(), this.viewHelper = null);
2203
+ }
2204
+ setViewHelperVisible(e4) {
2205
+ e4 && !this.viewHelper ? this.createViewHelper() : !e4 && this.viewHelper && this.removeViewHelper(), this.config.viewHelper.enabled = e4;
2206
+ }
2207
+ renderViewHelper(e4) {
2208
+ this.viewHelper && (this.viewHelper.render(this.renderer), this.viewHelper.animating && this.viewHelper.update(e4));
2209
+ }
2210
+ createBox3Helper(e4) {
2211
+ return this.removeBox3Helper(), this.currentBox3 = new t.Box3().setFromObject(e4), this.box3Helper = new t.Box3Helper(this.currentBox3, new t.Color(this.config.box3Helper.color)), this.box3Helper.name = "__box3Helper__", this.scene.add(this.box3Helper), this.box3Helper;
2212
+ }
2213
+ updateBox3Helper(e4) {
2214
+ this.currentBox3 && this.box3Helper && this.currentBox3.setFromObject(e4);
2215
+ }
2216
+ removeBox3Helper() {
2217
+ this.box3Helper && (this.scene.remove(this.box3Helper), this.box3Helper.dispose(), this.box3Helper = null, this.currentBox3 = null);
2218
+ }
2219
+ setBox3HelperVisible(e4) {
2220
+ this.config.box3Helper.enabled = e4, e4 || this.removeBox3Helper();
2221
+ }
2222
+ onObjectSelected(e4) {
2223
+ this.config.box3Helper.enabled && this.createBox3Helper(e4);
2224
+ }
2225
+ onObjectDeselected() {
2226
+ this.removeBox3Helper();
2227
+ }
2228
+ getGridHelper() {
2229
+ return this.gridHelper;
2230
+ }
2231
+ getAxesHelper() {
2232
+ return this.axesHelper;
2233
+ }
2234
+ getStats() {
2235
+ return this.stats;
2236
+ }
2237
+ getViewHelper() {
2238
+ return this.viewHelper;
2239
+ }
2240
+ getBox3Helper() {
2241
+ return this.box3Helper;
2242
+ }
2243
+ getConfig() {
2244
+ return { ...this.config };
2245
+ }
2246
+ }
2247
+ function ct(e4, n2, s2 = 0.9) {
2248
+ const i2 = e4.distanceTo(n2);
2249
+ return new t.Vector3().subVectors(n2, e4).normalize().multiplyScalar(i2 * s2).add(e4);
2250
+ }
2251
+ function ht(e4, n2, s2) {
2252
+ return new t.Vector3().subVectors(n2, e4).normalize().multiplyScalar(s2).add(e4);
2253
+ }
2254
+ function ut(e4) {
2255
+ return e4 * (Math.PI / 180);
2256
+ }
2257
+ function mt(e4) {
2258
+ return e4 * (180 / Math.PI);
2259
+ }
2260
+ function pt(e4, t2, n2) {
2261
+ return Math.max(t2, Math.min(n2, e4));
2262
+ }
2263
+ function ft(e4, t2, n2) {
2264
+ return e4 + (t2 - e4) * n2;
2265
+ }
2266
+ function gt(e4, t2, n2) {
2267
+ const s2 = pt((n2 - e4) / (t2 - e4), 0, 1);
2268
+ return s2 * s2 * (3 - 2 * s2);
2269
+ }
2270
+ function _t(e4) {
2271
+ const n2 = new t.Box3().setFromObject(e4), { max: s2, min: i2 } = n2, o2 = new t.Vector3();
2272
+ n2.getCenter(o2);
2273
+ return { max: s2, min: i2, center: o2, radius: new t.Vector3().subVectors(s2, i2).length() / 2 };
2274
+ }
2275
+ function vt(e4, n2 = 2.5) {
2276
+ const { center: s2, max: i2 } = _t(e4);
2277
+ return { position: ht(s2, i2, new t.Vector3().subVectors(i2, s2).length() * n2), target: s2 };
2278
+ }
2279
+ function bt(e4, n2 = 50) {
2280
+ const { center: s2, max: i2, min: o2, radius: r2 } = _t(e4), a2 = r2 / Math.tan(n2 * Math.PI / 360);
2281
+ return { frontView: new t.Vector3(s2.x, s2.y, i2.z + a2), backView: new t.Vector3(s2.x, s2.y, o2.z - a2), leftView: new t.Vector3(o2.x - a2, s2.y, s2.z), rightView: new t.Vector3(i2.x + a2, s2.y, s2.z), topView: new t.Vector3(s2.x, i2.y + a2, s2.z), bottomView: new t.Vector3(s2.x, o2.y - a2, s2.z), target: s2 };
2282
+ }
2283
+ function yt(e4 = 16776960) {
2284
+ const n2 = new t.Box3(), s2 = new t.Box3Helper(n2, e4);
2285
+ return s2.name = "Box3Helper", s2.visible = false, s2;
2286
+ }
2287
+ const wt = { speed: 0.01, mixRatio: 0.5 };
2288
+ class xt extends k {
2289
+ constructor(e4) {
2290
+ super({ ...wt, ...e4 }), this.name = "shader", this.presets = /* @__PURE__ */ new Map(), this.appliedObjects = /* @__PURE__ */ new Map(), this.shaderAnimations = [];
2291
+ }
2292
+ onInstall() {
2293
+ this.registerBuiltinPresets();
2294
+ }
2295
+ onUninstall() {
2296
+ for (const [e4] of this.appliedObjects) this.remove(e4);
2297
+ this.presets.clear();
2298
+ }
2299
+ onUpdate(e4) {
2300
+ for (const { controller: e5 } of this.shaderAnimations) e5.update();
2301
+ }
2302
+ registerBuiltinPresets() {
2303
+ this.registerPreset("彩虹光", { name: "彩虹光", uniforms: this.getCommonUniforms(), fragHeader: this.getUniformDeclarations(this.getCommonUniforms()), fragBody: "\n vec3 rainbow = vec3(\n sin(vUv.x * 10.0 + iTime) * 0.5 + 0.5,\n sin(vUv.y * 10.0 + iTime + 2.094) * 0.5 + 0.5,\n sin((vUv.x + vUv.y) * 5.0 + iTime + 4.188) * 0.5 + 0.5\n );\n vec4 diffuseColor = vec4(mix(diffuse, rainbow, mixRatio), opacity);\n ", animate: (e4, t2) => {
2304
+ e4.iTime.value += 0.5 * t2;
2305
+ } }), this.registerPreset("水波纹", { name: "水波纹", uniforms: this.getCommonUniforms(), fragHeader: this.getUniformDeclarations(this.getCommonUniforms()), fragBody: "\n float wave = sin(length(vUv - 0.5) * 20.0 - iTime * 3.0) * 0.5 + 0.5;\n vec3 waterColor = mix(diffuse, vec3(0.0, 0.5, 1.0), wave * mixRatio);\n vec4 diffuseColor = vec4(waterColor, opacity);\n ", animate: (e4, t2) => {
2306
+ e4.iTime.value += t2;
2307
+ } }), this.registerPreset("光圈扫射", { name: "光圈扫射", uniforms: { ...this.getCommonUniforms(), circleWidth: { type: "number", value: 0.1, unit: "float" }, isDisCard: { type: "bool", value: false, unit: "bool" } }, fragHeader: this.getUniformDeclarations({ ...this.getCommonUniforms(), circleWidth: { type: "number", value: 0.1, unit: "float" }, isDisCard: { type: "bool", value: false, unit: "bool" } }), fragBody: "\n float dist = length(vUv - 0.5);\n float circle = smoothstep(iTime - circleWidth, iTime, dist) - smoothstep(iTime, iTime + circleWidth, dist);\n vec3 scanColor = mix(diffuse, mixColor, circle * intensity);\n vec4 diffuseColor = vec4(scanColor, opacity);\n if (isDisCard && circle < 0.01) discard;\n ", animate: (e4, t2) => {
2308
+ e4.iTime.value += 0.3 * t2, e4.iTime.value > 1 && (e4.iTime.value = 0);
2309
+ } }), this.registerPreset("流光围栏", { name: "流光围栏", uniforms: this.getCommonUniforms(), fragHeader: this.getUniformDeclarations(this.getCommonUniforms()), fragBody: "\n float flow = fract(vUv.y - iTime * speed * 10.0);\n vec3 fenceColor = mix(diffuse, mixColor, flow * intensity);\n vec4 diffuseColor = vec4(fenceColor, opacity * (1.0 - flow * 0.5));\n ", animate: (e4, t2) => {
2310
+ e4.iTime.value += t2;
2311
+ } }), this.registerPreset("流光围栏2", { name: "流光围栏2", uniforms: this.getCommonUniforms(), fragHeader: this.getUniformDeclarations(this.getCommonUniforms()), fragBody: "\n float gradient = 1.0 - vUv.y;\n float flow = fract(vUv.y * 2.0 - iTime * speed * 5.0);\n vec3 fenceColor = mix(diffuse, mixColor, flow * gradient * intensity);\n vec4 diffuseColor = vec4(fenceColor, opacity * gradient);\n ", animate: (e4, t2) => {
2312
+ e4.iTime.value += t2;
2313
+ } }), this.registerPreset("雪片着色", { name: "雪片着色", uniforms: this.getCommonUniforms(), fragHeader: this.getUniformDeclarations(this.getCommonUniforms()), fragBody: "\n float snow = fract(sin(dot(vUv, vec2(12.9898, 78.233)) + iTime) * 43758.5453);\n vec3 snowColor = mix(diffuse, vec3(1.0), snow * mixRatio * 0.3);\n vec4 diffuseColor = vec4(snowColor, opacity);\n ", animate: (e4, t2) => {
2314
+ e4.iTime.value += 0.1 * t2;
2315
+ } }), this.registerPreset("光线叠加", { name: "光线叠加", uniforms: this.getCommonUniforms(), fragHeader: this.getUniformDeclarations(this.getCommonUniforms()), fragBody: "\n float glow = pow(1.0 - length(vUv - 0.5) * 2.0, 2.0);\n vec3 glowColor = diffuse + mixColor * glow * intensity;\n vec4 diffuseColor = vec4(glowColor, opacity);\n " }), this.registerPreset("绚烂线条", { name: "绚烂线条", uniforms: this.getCommonUniforms(), fragHeader: this.getUniformDeclarations(this.getCommonUniforms()), fragBody: "\n float line = abs(sin(vUv.x * 50.0 + iTime * 2.0)) * abs(sin(vUv.y * 50.0 + iTime * 2.0));\n vec3 lineColor = mix(diffuse, mixColor, line * intensity);\n vec4 diffuseColor = vec4(lineColor, opacity);\n ", animate: (e4, t2) => {
2316
+ e4.iTime.value += t2;
2317
+ } }), this.registerPreset("流光闪电", { name: "流光闪电", uniforms: this.getCommonUniforms(), fragHeader: this.getUniformDeclarations(this.getCommonUniforms()), fragBody: "\n float lightning = pow(fract(sin(vUv.x * 100.0 + iTime * 10.0) * 43758.5453), 10.0);\n vec3 lightningColor = mix(diffuse, vec3(0.8, 0.9, 1.0), lightning * intensity);\n vec4 diffuseColor = vec4(lightningColor, opacity);\n ", animate: (e4, t2) => {
2318
+ e4.iTime.value += t2;
2319
+ } }), this.registerPreset("火焰燃烧", { name: "火焰燃烧", uniforms: this.getCommonUniforms(), fragHeader: this.getUniformDeclarations(this.getCommonUniforms()), fragBody: "\n float noise = fract(sin(dot(vUv + iTime * 0.1, vec2(12.9898, 78.233))) * 43758.5453);\n float fire = pow(1.0 - vUv.y, 2.0) * noise;\n vec3 fireColor = mix(vec3(1.0, 0.3, 0.0), vec3(1.0, 0.8, 0.0), fire);\n vec3 finalColor = mix(diffuse, fireColor, fire * intensity);\n vec4 diffuseColor = vec4(finalColor, opacity);\n ", animate: (e4, t2) => {
2320
+ e4.iTime.value += t2;
2321
+ } }), this.registerPreset("流光栅格", { name: "流光栅格", uniforms: this.getCommonUniforms(), fragHeader: this.getUniformDeclarations(this.getCommonUniforms()), fragBody: "\n float gridX = step(0.9, fract(vUv.x * 10.0));\n float gridY = step(0.9, fract(vUv.y * 10.0));\n float grid = max(gridX, gridY);\n float flow = fract(vUv.x + vUv.y - iTime * speed * 2.0);\n vec3 gridColor = mix(diffuse, mixColor, grid * flow * intensity);\n vec4 diffuseColor = vec4(gridColor, opacity);\n ", animate: (e4, t2) => {
2322
+ e4.iTime.value += t2;
2323
+ } }), this.registerPreset("着色天空", { name: "着色天空", uniforms: { ...this.getCommonUniforms(), topColor: { type: "color", value: new t.Color(30719), unit: "vec3" }, bottomColor: { type: "color", value: new t.Color(16777215), unit: "vec3" }, offset: { type: "number", value: 0, unit: "float" }, exponent: { type: "number", value: 0.6, unit: "float" } }, fragHeader: "\n uniform vec3 topColor;\n uniform vec3 bottomColor;\n uniform float offset;\n uniform float exponent;\n varying vec3 vWorldPosition;\n ", vertexHeader: "\n varying vec3 vWorldPosition;\n void main() {\n vec4 worldPosition = modelMatrix * vec4(position, 1.0);\n vWorldPosition = worldPosition.xyz;\n ", fragBody: "\n float h = normalize(vWorldPosition + offset).y;\n vec3 skyColor = mix(bottomColor, topColor, max(pow(max(h, 0.0), exponent), 0.0));\n vec4 diffuseColor = vec4(skyColor, opacity);\n " }), this.registerPreset("水面着色", { name: "水面着色", uniforms: { ...this.getCommonUniforms(), waterColor: { type: "color", value: new t.Color(7695), unit: "vec3" }, waveHeight: { type: "number", value: 0.1, unit: "float" }, waveSpeed: { type: "number", value: 1, unit: "float" } }, fragHeader: `
2324
+ uniform vec3 waterColor;
2325
+ uniform float waveHeight;
2326
+ uniform float waveSpeed;
2327
+ ${this.getUniformDeclarations(this.getCommonUniforms())}
2328
+ `, fragBody: "\n float wave1 = sin(vUv.x * 10.0 + iTime * waveSpeed) * waveHeight;\n float wave2 = sin(vUv.y * 8.0 + iTime * waveSpeed * 0.8) * waveHeight;\n float wave = (wave1 + wave2) * 0.5 + 0.5;\n vec3 finalColor = mix(waterColor, mixColor, wave * intensity);\n vec4 diffuseColor = vec4(finalColor, opacity * 0.8);\n ", animate: (e4, t2) => {
2329
+ e4.iTime.value += t2;
2330
+ } }), this.registerPreset("热力图", { name: "热力图", uniforms: { ...this.getCommonUniforms(), Points: { type: "array", value: [], unit: "vec3" }, PointsCount: { type: "number", value: 0, unit: "int" }, radius: { type: "number", value: 0.3, unit: "float" } }, fragHeader: `
2331
+ uniform vec3 Points[100];
2332
+ uniform int PointsCount;
2333
+ uniform float radius;
2334
+ ${this.getUniformDeclarations(this.getCommonUniforms())}
2335
+ `, fragBody: "\n float heat = 0.0;\n for (int i = 0; i < 100; i++) {\n if (i >= PointsCount) break;\n float dist = distance(vec2(vUv.x, vUv.y), Points[i].xy);\n heat += Points[i].z * smoothstep(radius, 0.0, dist);\n }\n heat = clamp(heat, 0.0, 1.0);\n vec3 heatColor = mix(vec3(0.0, 0.0, 1.0), vec3(1.0, 0.0, 0.0), heat);\n heatColor = mix(heatColor, vec3(1.0, 1.0, 0.0), smoothstep(0.5, 1.0, heat));\n vec4 diffuseColor = vec4(mix(diffuse, heatColor, heat * intensity), opacity);\n " }), this.registerPreset("晶片着色", { name: "晶片着色", uniforms: this.getCommonUniforms(), fragHeader: this.getUniformDeclarations(this.getCommonUniforms()), fragBody: "\n vec2 cell = floor(vUv * 20.0);\n float noise = fract(sin(dot(cell, vec2(12.9898, 78.233))) * 43758.5453);\n vec3 crystalColor = mix(diffuse, mixColor, noise * intensity);\n vec4 diffuseColor = vec4(crystalColor, opacity);\n " });
2336
+ }
2337
+ getCommonUniforms() {
2338
+ return { iTime: { type: "number", value: 0, unit: "float" }, speed: { type: "number", value: this.config.speed, unit: "float" }, intensity: { type: "number", value: 1, unit: "float" }, mixRatio: { type: "number", value: this.config.mixRatio, unit: "float" }, mixColor: { type: "color", value: new t.Color(16777215), unit: "vec3" }, hasUv: { type: "bool", value: true, unit: "bool" } };
2339
+ }
2340
+ getUniformDeclarations(e4) {
2341
+ return Object.entries(e4).map(([e5, t2]) => `uniform ${t2.unit} ${e5};`).join("\n");
2342
+ }
2343
+ registerPreset(e4, t2) {
2344
+ this.presets.set(e4, t2);
2345
+ }
2346
+ getPreset(e4) {
2347
+ return this.presets.get(e4);
2348
+ }
2349
+ getPresetNames() {
2350
+ return Array.from(this.presets.keys());
2351
+ }
2352
+ apply(e4, n2) {
2353
+ const s2 = this.presets.get(n2);
2354
+ if (!s2) return null;
2355
+ const i2 = {};
2356
+ for (const [e5, n3] of Object.entries(s2.uniforms)) i2[e5] = { ...n3, value: n3.value instanceof t.Color ? n3.value.clone() : n3.value };
2357
+ const o2 = this.getMaterials(e4);
2358
+ if (0 === o2.length) return null;
2359
+ o2.forEach((e5) => {
2360
+ this.applyShaderToMaterial(e5, i2, s2);
2361
+ });
2362
+ const r2 = { uniforms: i2, update: () => {
2363
+ s2.animate && s2.animate(i2, 0.016);
2364
+ }, destroy: () => {
2365
+ this.remove(e4);
2366
+ } };
2367
+ return this.appliedObjects.set(e4, r2), s2.animate && this.shaderAnimations.push({ object: e4, controller: r2 }), this.events.emit("shader:applied", { object: e4, shaderName: n2 }), r2;
2368
+ }
2369
+ applyShaderToMaterial(e4, t2, n2) {
2370
+ e4.dispose(), e4.onBeforeCompile = (e5) => {
2371
+ for (const [n3, s2] of Object.entries(t2)) e5.uniforms[n3] = { value: s2.value };
2372
+ n2.vertexHeader && (e5.vertexShader = e5.vertexShader.replace("void main() {", n2.vertexHeader)), e5.vertexShader.includes("varying vec2 vUv") || (e5.vertexShader = "varying vec2 vUv;\n" + e5.vertexShader, e5.vertexShader = e5.vertexShader.replace("void main() {", "void main() {\nvUv = uv;")), e5.fragmentShader = e5.fragmentShader.replace("#include <common>", `varying vec2 vUv;
2373
+ ${n2.fragHeader}
2374
+ #include <common>
2375
+ ${n2.fragFunc || ""}`), e5.fragmentShader = e5.fragmentShader.replace("vec4 diffuseColor = vec4( diffuse, opacity );", n2.fragBody);
2376
+ }, e4.needsUpdate = true;
2377
+ }
2378
+ remove(e4) {
2379
+ if (!this.appliedObjects.get(e4)) return;
2380
+ this.getMaterials(e4).forEach((e5) => {
2381
+ e5.onBeforeCompile = () => {
2382
+ }, e5.dispose(), e5.needsUpdate = true;
2383
+ });
2384
+ const t2 = this.shaderAnimations.findIndex((t3) => t3.object === e4);
2385
+ t2 > -1 && this.shaderAnimations.splice(t2, 1), this.appliedObjects.delete(e4), this.events.emit("shader:removed", { object: e4 });
2386
+ }
2387
+ getMaterials(e4) {
2388
+ const t2 = [];
2389
+ return e4.traverse((e5) => {
2390
+ if (e5.isMesh) {
2391
+ const n2 = e5;
2392
+ Array.isArray(n2.material) ? t2.push(...n2.material) : n2.material && t2.push(n2.material);
2393
+ }
2394
+ }), [...new Set(t2)];
2395
+ }
2396
+ }
2397
+ const Ct = { defaultDuration: 2, defaultEase: "power2.inOut" };
2398
+ class Mt extends k {
2399
+ constructor(e4) {
2400
+ super({ ...Ct, ...e4 }), this.name = "animation", this.mixers = [], this.curveAnimations = [], this.tweens = [];
2401
+ }
2402
+ onUninstall() {
2403
+ this.stopAll();
2404
+ }
2405
+ onUpdate(e4) {
2406
+ var _a, _b;
2407
+ for (const e5 of this.mixers) e5.mixer.update(e5.clock.getDelta());
2408
+ for (const e5 of this.curveAnimations) {
2409
+ if (e5.pause) continue;
2410
+ if (e5.time += e5.speed / 1e3, e5.time > 1 || e5.time < 0) {
2411
+ e5.time = e5.time > 1 ? 1 : 0, e5.pause = true, (_a = e5.frameEndCallback) == null ? void 0 : _a.call(e5);
2412
+ continue;
2413
+ }
2414
+ const t2 = e5.curve.getPointAt(e5.time);
2415
+ (_b = e5.frameCallback) == null ? void 0 : _b.call(e5, t2);
2416
+ }
2417
+ }
2418
+ playModelAnimation(e4, n2) {
2419
+ const s2 = e4, i2 = e4.animations;
2420
+ if (!i2 || 0 === i2.length) return null;
2421
+ const o2 = { ...{ initPlay: true, speed: 1, actionIndexs: i2.map(() => true), startTime: 0, loop: true }, ...n2, ...e4.animationPlayParams }, r2 = new t.Clock(), a2 = new t.AnimationMixer(s2), l2 = i2.filter((e5, t2) => o2.actionIndexs[t2]).map((e5) => {
2422
+ const n3 = a2.clipAction(e5);
2423
+ return n3.loop = o2.loop ? t.LoopRepeat : t.LoopOnce, n3.time = o2.startTime, n3.timeScale = o2.speed, n3.clampWhenFinished = true, o2.initPlay && n3.play(), n3;
2424
+ }), d2 = { mixer: a2, object: s2, actions: l2, clock: r2 };
2425
+ return this.mixers.push(d2), e4.animationPlayParams = o2, this.events.emit("animation:start", { object: s2 }), d2;
2426
+ }
2427
+ stopModelAnimation(e4) {
2428
+ const t2 = this.mixers.findIndex((t3) => t3.object === e4);
2429
+ if (t2 > -1) {
2430
+ this.mixers[t2].actions.forEach((e5) => e5.stop()), this.mixers.splice(t2, 1), this.events.emit("animation:stop", { object: e4 });
2431
+ }
2432
+ }
2433
+ toggleModelAnimation(e4, t2) {
2434
+ const n2 = this.mixers.find((t3) => t3.object === e4);
2435
+ n2 && n2.actions.forEach((e5) => {
2436
+ e5.paused = t2;
2437
+ });
2438
+ }
2439
+ getMixerInfo(e4) {
2440
+ return this.mixers.find((t2) => t2.object === e4);
2441
+ }
2442
+ tween(e4, t2, n2) {
2443
+ const s2 = M.to(e4, { ...t2, duration: (n2 == null ? void 0 : n2.duration) ?? this.config.defaultDuration, ease: (n2 == null ? void 0 : n2.ease) ?? this.config.defaultEase, repeat: (n2 == null ? void 0 : n2.repeat) ?? 0, yoyo: (n2 == null ? void 0 : n2.yoyo) ?? false, yoyoEase: (n2 == null ? void 0 : n2.yoyoEase) ?? true, onUpdate: n2 == null ? void 0 : n2.onUpdate, onComplete: () => {
2444
+ var _a;
2445
+ (_a = n2 == null ? void 0 : n2.onComplete) == null ? void 0 : _a.call(n2);
2446
+ const e5 = this.tweens.indexOf(s2);
2447
+ e5 > -1 && this.tweens.splice(e5, 1);
2448
+ } });
2449
+ return this.tweens.push(s2), { play: () => s2.play(), pause: () => s2.pause(), resume: () => s2.resume(), kill: () => {
2450
+ s2.kill();
2451
+ const e5 = this.tweens.indexOf(s2);
2452
+ e5 > -1 && this.tweens.splice(e5, 1);
2453
+ }, progress: (e5) => (void 0 !== e5 && s2.progress(e5), s2.progress()) };
2454
+ }
2455
+ animateCamera(e4, t2, n2, s2) {
2456
+ return Promise.all([new Promise((t3) => {
2457
+ this.tween(e4.position, n2.position, { ...s2, onComplete: t3 });
2458
+ }), new Promise((e5) => {
2459
+ this.tween(t2.target, n2.target, { ...s2, onComplete: e5 });
2460
+ })]).then(() => {
2461
+ });
2462
+ }
2463
+ animateTransform(e4, t2, n2) {
2464
+ const s2 = [];
2465
+ return t2.position && s2.push(new Promise((s3) => {
2466
+ this.tween(e4.position, t2.position, { ...n2, onComplete: s3 });
2467
+ })), t2.rotation && s2.push(new Promise((s3) => {
2468
+ this.tween(e4.rotation, t2.rotation, { ...n2, onComplete: s3 });
2469
+ })), t2.scale && s2.push(new Promise((s3) => {
2470
+ this.tween(e4.scale, t2.scale, { ...n2, onComplete: s3 });
2471
+ })), Promise.all(s2).then(() => {
2472
+ });
2473
+ }
2474
+ createCurveAnimation(e4, t2 = 1) {
2475
+ const n2 = { id: Date.now(), curve: e4, time: 0, pause: true, speed: t2, frameCallback: null, frameEndCallback: null, start: () => {
2476
+ this.curveAnimations.includes(n2) || this.curveAnimations.push(n2), n2.pause = false;
2477
+ }, destroy: () => {
2478
+ const e5 = this.curveAnimations.indexOf(n2);
2479
+ e5 > -1 && this.curveAnimations.splice(e5, 1);
2480
+ } };
2481
+ return n2;
2482
+ }
2483
+ animateAlongCurve(e4, t2, n2) {
2484
+ const s2 = this.createCurveAnimation(t2, (n2 == null ? void 0 : n2.speed) ?? 1);
2485
+ return s2.frameCallback = (i2) => {
2486
+ if (e4.position.copy(i2), n2 == null ? void 0 : n2.lookAhead) {
2487
+ const n3 = Math.min(s2.time + 0.01, 1), i3 = t2.getPointAt(n3);
2488
+ e4.lookAt(i3);
2489
+ }
2490
+ }, s2.frameEndCallback = (n2 == null ? void 0 : n2.onComplete) ?? null, s2;
2491
+ }
2492
+ stopAll() {
2493
+ for (const e4 of this.mixers) e4.actions.forEach((e5) => e5.stop());
2494
+ this.mixers = [], this.curveAnimations = [];
2495
+ for (const e4 of this.tweens) e4.kill();
2496
+ this.tweens = [];
2497
+ }
2498
+ pauseAll() {
2499
+ for (const e4 of this.mixers) e4.actions.forEach((e5) => {
2500
+ e5.paused = true;
2501
+ });
2502
+ for (const e4 of this.curveAnimations) e4.pause = true;
2503
+ for (const e4 of this.tweens) e4.pause();
2504
+ }
2505
+ resumeAll() {
2506
+ for (const e4 of this.mixers) e4.actions.forEach((e5) => {
2507
+ e5.paused = false;
2508
+ });
2509
+ for (const e4 of this.curveAnimations) e4.pause = false;
2510
+ for (const e4 of this.tweens) e4.resume();
2511
+ }
2512
+ }
2513
+ const Pt = { defaultMode: "围栏物体", defaultPointMode: "场景交点", defaultMaterialType: "标准材质", fenceHeight: 5, lineWidth: 0.01 };
2514
+ class St extends k {
2515
+ constructor(e4) {
2516
+ super({ ...Pt, ...e4 }), this.name = "drawing", this.currentPoints = [], this.previewMesh = null, this._isDrawing = false, this.drawnObjects = [], this._mode = this.config.defaultMode, this._pointMode = this.config.defaultPointMode;
2517
+ }
2518
+ get mode() {
2519
+ return this._mode;
2520
+ }
2521
+ get pointMode() {
2522
+ return this._pointMode;
2523
+ }
2524
+ get isDrawing() {
2525
+ return this._isDrawing;
2526
+ }
2527
+ onUninstall() {
2528
+ this.cancel(), this.previewMesh && (this.scene.remove(this.previewMesh), this.previewMesh = null);
2529
+ }
2530
+ setMode(e4) {
2531
+ this._mode = e4;
2532
+ }
2533
+ setPointMode(e4) {
2534
+ this._pointMode = e4;
2535
+ }
2536
+ start() {
2537
+ this._isDrawing = true, this.currentPoints = [], this.events.emit("draw:start", { mode: this._mode });
2538
+ }
2539
+ addPoint(e4) {
2540
+ this._isDrawing || this.start(), this.currentPoints.push(e4.clone()), this.events.emit("draw:point", { point: e4 }), this.updatePreview();
2541
+ }
2542
+ handleSceneClick(e4, t2) {
2543
+ var _a, _b, _c, _d;
2544
+ let n2 = e4;
2545
+ if ("地图区域中心" === this._pointMode && ((_b = (_a = t2 == null ? void 0 : t2.geoInfo) == null ? void 0 : _a.properties) == null ? void 0 : _b.centroidCoord3)) {
2546
+ const e5 = t2.parent;
2547
+ if (e5 == null ? void 0 : e5.getTransformedVector) {
2548
+ const s2 = t2.geoInfo.properties.centroidCoord3.clone();
2549
+ s2.add(t2.position), t2.initTranslate && s2.sub(t2.initTranslate), n2 = e5.getTransformedVector(s2);
2550
+ }
2551
+ } else if ("地图行政中心" === this._pointMode && ((_d = (_c = t2 == null ? void 0 : t2.geoInfo) == null ? void 0 : _c.properties) == null ? void 0 : _d.centerCoord3)) {
2552
+ const e5 = t2.parent;
2553
+ if (e5 == null ? void 0 : e5.getTransformedVector) {
2554
+ const s2 = t2.geoInfo.properties.centerCoord3.clone();
2555
+ s2.add(t2.position), t2.initTranslate && s2.sub(t2.initTranslate), n2 = e5.getTransformedVector(s2);
2556
+ }
2557
+ }
2558
+ this.addPoint(n2);
2559
+ }
2560
+ complete() {
2561
+ if (this.currentPoints.length < 2) return null;
2562
+ let e4;
2563
+ switch (this._mode) {
2564
+ case "围栏物体":
2565
+ e4 = this.createFence(this.currentPoints);
2566
+ break;
2567
+ case "平面绘制":
2568
+ e4 = this.createPlane(this.currentPoints);
2569
+ break;
2570
+ case "曲线路径":
2571
+ e4 = this.createCurve(this.currentPoints);
2572
+ break;
2573
+ case "直线路径":
2574
+ e4 = this.createLine(this.currentPoints);
2575
+ break;
2576
+ default:
2577
+ return null;
2578
+ }
2579
+ e4.isDrawMesh = true, this.scene.add(e4), this.previewMesh && (this.scene.remove(this.previewMesh), this.previewMesh = null);
2580
+ const t2 = { mesh: e4, points: [...this.currentPoints], mode: this._mode };
2581
+ return this.drawnObjects.push(t2), this._isDrawing = false, this.currentPoints = [], this.events.emit("draw:complete", { mesh: e4 }), t2;
2582
+ }
2583
+ cancel() {
2584
+ this._isDrawing = false, this.currentPoints = [], this.previewMesh && (this.scene.remove(this.previewMesh), this.previewMesh = null), this.events.emit("draw:cancel", void 0);
2585
+ }
2586
+ undoPoint() {
2587
+ this.currentPoints.length > 0 && (this.currentPoints.pop(), this.updatePreview());
2588
+ }
2589
+ updatePreview() {
2590
+ if (!(this.currentPoints.length < 2)) {
2591
+ switch (this.previewMesh && this.scene.remove(this.previewMesh), this._mode) {
2592
+ case "围栏物体":
2593
+ this.previewMesh = this.createFence(this.currentPoints, true);
2594
+ break;
2595
+ case "平面绘制":
2596
+ this.previewMesh = this.createPlane(this.currentPoints, true);
2597
+ break;
2598
+ case "曲线路径":
2599
+ this.previewMesh = this.createCurve(this.currentPoints, true);
2600
+ break;
2601
+ case "直线路径":
2602
+ this.previewMesh = this.createLine(this.currentPoints, true);
2603
+ }
2604
+ this.previewMesh && this.scene.add(this.previewMesh);
2605
+ }
2606
+ }
2607
+ createFence(e4, n2 = false) {
2608
+ const s2 = this.config.fenceHeight, i2 = [], o2 = [], r2 = [];
2609
+ for (let t2 = 0; t2 < e4.length; t2++) {
2610
+ const n3 = e4[t2];
2611
+ i2.push(n3.x, n3.y, n3.z), i2.push(n3.x, n3.y + s2, n3.z);
2612
+ const o3 = t2 / (e4.length - 1);
2613
+ r2.push(o3, 0), r2.push(o3, 1);
2614
+ }
2615
+ for (let t2 = 0; t2 < e4.length - 1; t2++) {
2616
+ const e5 = 2 * t2;
2617
+ o2.push(e5, e5 + 1, e5 + 2), o2.push(e5 + 1, e5 + 3, e5 + 2);
2618
+ }
2619
+ const a2 = new t.BufferGeometry();
2620
+ a2.setAttribute("position", new t.Float32BufferAttribute(i2, 3)), a2.setAttribute("uv", new t.Float32BufferAttribute(r2, 2)), a2.setIndex(o2), a2.computeVertexNormals();
2621
+ const l2 = new t.MeshStandardMaterial({ color: n2 ? 65280 : 4491519, side: t.DoubleSide, transparent: true, opacity: n2 ? 0.5 : 0.8 }), d2 = new t.Mesh(a2, l2);
2622
+ return d2.name = "Fence", d2;
2623
+ }
2624
+ createPlane(e4, n2 = false) {
2625
+ if (e4.length < 3) return this.createLine(e4, n2);
2626
+ const s2 = new t.Shape();
2627
+ s2.moveTo(e4[0].x, e4[0].z);
2628
+ for (let t2 = 1; t2 < e4.length; t2++) s2.lineTo(e4[t2].x, e4[t2].z);
2629
+ s2.closePath();
2630
+ const i2 = new t.ShapeGeometry(s2);
2631
+ i2.rotateX(-Math.PI / 2);
2632
+ const o2 = e4.reduce((e5, t2) => e5 + t2.y, 0) / e4.length;
2633
+ i2.translate(0, o2, 0);
2634
+ const r2 = new t.MeshStandardMaterial({ color: n2 ? 65280 : 4491519, side: t.DoubleSide, transparent: true, opacity: n2 ? 0.5 : 0.8 }), a2 = new t.Mesh(i2, r2);
2635
+ return a2.name = "Plane", a2;
2636
+ }
2637
+ createCurve(e4, n2 = false) {
2638
+ const s2 = new t.CatmullRomCurve3(e4), i2 = s2.getPoints(50), o2 = new t.BufferGeometry().setFromPoints(i2), r2 = new t.LineBasicMaterial({ color: n2 ? 65280 : 16729224, linewidth: 2 }), a2 = new t.Line(o2, r2);
2639
+ return a2.name = "Curve", a2.isCurveMesh = true, a2.curvePath = s2, a2;
2640
+ }
2641
+ createLine(e4, n2 = false) {
2642
+ const s2 = new t.BufferGeometry().setFromPoints(e4), i2 = new t.LineBasicMaterial({ color: n2 ? 65280 : 16776960, linewidth: 2 }), o2 = new t.Line(s2, i2);
2643
+ return o2.name = "Line", o2;
2644
+ }
2645
+ getDrawnObjects() {
2646
+ return this.drawnObjects;
2647
+ }
2648
+ removeDrawnObject(e4) {
2649
+ const t2 = this.drawnObjects.findIndex((t3) => t3.mesh === e4);
2650
+ t2 > -1 && (this.scene.remove(e4), this.drawnObjects.splice(t2, 1));
2651
+ }
2652
+ clearAll() {
2653
+ for (const e4 of this.drawnObjects) this.scene.remove(e4.mesh);
2654
+ this.drawnObjects = [];
2655
+ }
2656
+ getCurveList() {
2657
+ return this.scene.children.filter((e4) => e4.isCurveMesh).map((e4) => ({ path: e4.curvePath, mesh: e4 }));
2658
+ }
2659
+ }
2660
+ const Ft = { materialType: "标准材质", coordinateScale: 1e4 };
2661
+ class Et extends k {
2662
+ constructor(e4) {
2663
+ super({ ...Ft, ...e4 }), this.name = "geomap", this.geoGroups = [];
2664
+ }
2665
+ onUninstall() {
2666
+ this.clearAll();
2667
+ }
2668
+ async load(e4, t2) {
2669
+ var _a;
2670
+ const n2 = await fetch(e4), s2 = await n2.json(), i2 = this.createGeoGroup(s2, { materialType: (t2 == null ? void 0 : t2.materialType) ?? this.config.materialType, depth: (t2 == null ? void 0 : t2.depth) ?? 1, color: (t2 == null ? void 0 : t2.color) ?? 4491519, opacity: (t2 == null ? void 0 : t2.opacity) ?? 0.8 });
2671
+ return i2.isGeoGroup = true, this.centerGroup(i2), this.scene.add(i2), this.geoGroups.push({ group: i2, url: e4, materialType: (t2 == null ? void 0 : t2.materialType) ?? this.config.materialType, features: s2.features }), (_a = this.onGroupLoaded) == null ? void 0 : _a.call(this, i2), this.events.emit("geomap:load:complete", { group: i2 }), i2;
2672
+ }
2673
+ createGeoGroup(e4, n2) {
2674
+ const s2 = new t.Group();
2675
+ s2.name = "GeoGroup";
2676
+ for (const t2 of e4.features) {
2677
+ const e5 = this.createFeatureMeshes(t2, n2);
2678
+ for (const t3 of e5) s2.add(t3);
2679
+ }
2680
+ return s2;
2681
+ }
2682
+ createFeatureMeshes(e4, t2) {
2683
+ const n2 = [], { geometry: s2, properties: i2 } = e4;
2684
+ let o2 = [];
2685
+ "Polygon" === s2.type ? o2 = [s2.coordinates] : "MultiPolygon" === s2.type && (o2 = s2.coordinates);
2686
+ for (const e5 of o2) {
2687
+ const s3 = this.createPolygonMesh(e5, t2);
2688
+ s3.name = i2.name || "Region";
2689
+ const o3 = { properties: { ...i2 } };
2690
+ i2.center && (o3.properties.centerCoord3 = this.coordToVector3(i2.center)), i2.centroid && (o3.properties.centroidCoord3 = this.coordToVector3(i2.centroid)), s3.geoInfo = o3, n2.push(s3);
2691
+ }
2692
+ return n2;
2693
+ }
2694
+ createPolygonMesh(e4, n2) {
2695
+ const s2 = e4[0], i2 = new t.Shape(), o2 = this.coordToVector2(s2[0]);
2696
+ i2.moveTo(o2.x, o2.y);
2697
+ for (let e5 = 1; e5 < s2.length; e5++) {
2698
+ const t2 = this.coordToVector2(s2[e5]);
2699
+ i2.lineTo(t2.x, t2.y);
2700
+ }
2701
+ i2.closePath();
2702
+ for (let n3 = 1; n3 < e4.length; n3++) {
2703
+ const s3 = new t.Path(), o3 = e4[n3], r3 = this.coordToVector2(o3[0]);
2704
+ s3.moveTo(r3.x, r3.y);
2705
+ for (let e5 = 1; e5 < o3.length; e5++) {
2706
+ const t2 = this.coordToVector2(o3[e5]);
2707
+ s3.lineTo(t2.x, t2.y);
2708
+ }
2709
+ i2.holes.push(s3);
2710
+ }
2711
+ const r2 = new t.ExtrudeGeometry(i2, { depth: n2.depth, bevelEnabled: false });
2712
+ r2.rotateX(-Math.PI / 2);
2713
+ const a2 = new t.MeshStandardMaterial({ color: n2.color, transparent: true, opacity: n2.opacity, side: t.DoubleSide });
2714
+ return new t.Mesh(r2, a2);
2715
+ }
2716
+ coordToVector2(e4) {
2717
+ const [n2, s2] = e4, [i2, o2] = P("EPSG:4326", "EPSG:3857", [n2, s2]);
2718
+ return new t.Vector2(i2 / this.config.coordinateScale, o2 / this.config.coordinateScale);
2719
+ }
2720
+ coordToVector3(e4) {
2721
+ const [n2, s2] = e4, [i2, o2] = P("EPSG:4326", "EPSG:3857", [n2, s2]);
2722
+ return new t.Vector3(i2 / this.config.coordinateScale, 0, o2 / this.config.coordinateScale);
2723
+ }
2724
+ centerGroup(e4) {
2725
+ const n2 = new t.Box3().setFromObject(e4), s2 = new t.Vector3();
2726
+ n2.getCenter(s2), e4.translationOriginDiff = s2.clone(), e4.getTransformedVector = (t2) => {
2727
+ const n3 = t2.clone();
2728
+ return n3.sub(s2), n3.multiply(e4.scale), n3.applyEuler(e4.rotation), n3.add(e4.position), n3;
2729
+ }, e4.traverse((e5) => {
2730
+ e5.isMesh && (e5.position.sub(s2), e5.initTranslate = e5.position.clone());
2731
+ });
2732
+ }
2733
+ getGeoGroups() {
2734
+ return this.geoGroups;
2735
+ }
2736
+ removeGeoGroup(e4) {
2737
+ const t2 = this.geoGroups.findIndex((t3) => t3.group === e4);
2738
+ t2 > -1 && (this.scene.remove(e4), this.geoGroups.splice(t2, 1));
2739
+ }
2740
+ clearAll() {
2741
+ for (const e4 of this.geoGroups) this.scene.remove(e4.group);
2742
+ this.geoGroups = [];
2743
+ }
2744
+ findRegionByName(e4) {
2745
+ for (const t2 of this.geoGroups) {
2746
+ const n2 = t2.group.children.find((t3) => t3.name === e4);
2747
+ if (n2) return n2;
2748
+ }
2749
+ return null;
2750
+ }
2751
+ highlightRegion(e4, n2 = 16711680) {
2752
+ e4.material instanceof t.MeshStandardMaterial && (e4.material.emissive.setHex(n2), e4.material.emissiveIntensity = 0.3);
2753
+ }
2754
+ unhighlightRegion(e4) {
2755
+ e4.material instanceof t.MeshStandardMaterial && (e4.material.emissiveIntensity = 0);
2756
+ }
2757
+ }
2758
+ const At = { defaultSize: 1 };
2759
+ class kt extends k {
2760
+ constructor(e4) {
2761
+ super({ ...At, ...e4 }), this.name = "geometry", this.geometryTypes = ["立方体", "球体", "圆柱体", "圆锥体", "平面", "圆环", "圆环结", "十二面体", "二十面体", "八面体", "四面体", "胶囊体"], this.innerMeshes = [];
2762
+ }
2763
+ onUninstall() {
2764
+ this.clearAll();
2765
+ }
2766
+ createGeometry(e4, n2) {
2767
+ const s2 = this.config.defaultSize, i2 = n2 || {};
2768
+ switch (e4) {
2769
+ case "立方体":
2770
+ return new t.BoxGeometry(i2.width ?? s2, i2.height ?? s2, i2.depth ?? s2, i2.widthSegments ?? 1, i2.heightSegments ?? 1, i2.depthSegments ?? 1);
2771
+ case "球体":
2772
+ return new t.SphereGeometry(i2.radius ?? s2 / 2, i2.widthSegments ?? 32, i2.heightSegments ?? 16, i2.phiStart ?? 0, i2.phiLength ?? 2 * Math.PI, i2.thetaStart ?? 0, i2.thetaLength ?? Math.PI);
2773
+ case "圆柱体":
2774
+ return new t.CylinderGeometry(i2.radiusTop ?? s2 / 2, i2.radiusBottom ?? s2 / 2, i2.height ?? s2, i2.radialSegments ?? 32, i2.heightSegments ?? 1, i2.openEnded ?? false);
2775
+ case "圆锥体":
2776
+ return new t.ConeGeometry(i2.radius ?? s2 / 2, i2.height ?? s2, i2.radialSegments ?? 32, i2.heightSegments ?? 1, i2.openEnded ?? false);
2777
+ case "平面":
2778
+ return new t.PlaneGeometry(i2.width ?? s2, i2.height ?? s2, i2.widthSegments ?? 1, i2.heightSegments ?? 1);
2779
+ case "圆环":
2780
+ return new t.TorusGeometry(i2.radius ?? s2 / 2, i2.tube ?? s2 / 6, i2.radialSegments ?? 16, i2.tubularSegments ?? 100, i2.arc ?? 2 * Math.PI);
2781
+ case "圆环结":
2782
+ return new t.TorusKnotGeometry(i2.radius ?? s2 / 2, i2.tube ?? s2 / 6, i2.tubularSegments ?? 64, i2.radialSegments ?? 8, i2.p ?? 2, i2.q ?? 3);
2783
+ case "十二面体":
2784
+ return new t.DodecahedronGeometry(i2.radius ?? s2 / 2);
2785
+ case "二十面体":
2786
+ return new t.IcosahedronGeometry(i2.radius ?? s2 / 2);
2787
+ case "八面体":
2788
+ return new t.OctahedronGeometry(i2.radius ?? s2 / 2);
2789
+ case "四面体":
2790
+ return new t.TetrahedronGeometry(i2.radius ?? s2 / 2);
2791
+ case "胶囊体":
2792
+ return new t.CapsuleGeometry(i2.radius ?? s2 / 4, i2.height ?? s2 / 2, i2.capSegments ?? 4, i2.radialSegments ?? 8);
2793
+ default:
2794
+ return new t.BoxGeometry(s2, s2, s2);
2795
+ }
2796
+ }
2797
+ createMesh(e4, n2, s2) {
2798
+ const i2 = this.createGeometry(e4, s2);
2799
+ i2.geometryType = e4;
2800
+ const o2 = new t.Mesh(i2, n2 ?? new t.MeshStandardMaterial({ color: 8421504 }));
2801
+ return o2.name = e4, o2.isInnerMesh = true, o2;
2802
+ }
2803
+ addToScene(e4, t2, n2) {
2804
+ const s2 = this.createMesh(e4, t2, n2);
2805
+ return this.scene.add(s2), this.innerMeshes.push(s2), s2;
2806
+ }
2807
+ createBox(e4 = 1, n2 = 16777215) {
2808
+ const s2 = new t.BoxGeometry(e4, e4, e4), i2 = new t.MeshBasicMaterial({ color: n2 });
2809
+ return new t.Mesh(s2, i2);
2810
+ }
2811
+ getInnerMeshes() {
2812
+ return this.innerMeshes;
2813
+ }
2814
+ removeMesh(e4) {
2815
+ const t2 = this.innerMeshes.indexOf(e4);
2816
+ t2 > -1 && (this.scene.remove(e4), e4.geometry.dispose(), Array.isArray(e4.material) ? e4.material.forEach((e5) => e5.dispose()) : e4.material.dispose(), this.innerMeshes.splice(t2, 1));
2817
+ }
2818
+ clearAll() {
2819
+ for (const e4 of this.innerMeshes) this.scene.remove(e4), e4.geometry.dispose(), Array.isArray(e4.material) ? e4.material.forEach((e5) => e5.dispose()) : e4.material.dispose();
2820
+ this.innerMeshes = [];
2821
+ }
2822
+ updateGeometry(e4, t2, n2) {
2823
+ const s2 = e4.geometry;
2824
+ e4.geometry = this.createGeometry(t2, n2), e4.geometry.geometryType = t2, s2.dispose();
2825
+ }
2826
+ }
2827
+ const Tt = { defaultType: "标准材质", defaultColor: 8421504 };
2828
+ class Lt extends k {
2829
+ constructor(e4) {
2830
+ super({ ...Tt, ...e4 }), this.name = "material", this.materialTypes = ["基础材质", "标准材质", "物理材质", "Lambert材质", "Phong材质", "Toon材质", "法线材质", "深度材质"];
2831
+ }
2832
+ createMaterial(e4, n2) {
2833
+ const s2 = n2 || {}, i2 = { color: s2.color ?? this.config.defaultColor, opacity: s2.opacity ?? 1, transparent: s2.transparent ?? false, side: s2.side ?? t.FrontSide, wireframe: s2.wireframe ?? false };
2834
+ switch (e4) {
2835
+ case "基础材质":
2836
+ return new t.MeshBasicMaterial({ ...i2, map: s2.map });
2837
+ case "标准材质":
2838
+ return new t.MeshStandardMaterial({ ...i2, flatShading: s2.flatShading ?? false, map: s2.map, emissive: s2.emissive ?? 0, emissiveIntensity: s2.emissiveIntensity ?? 1, roughness: s2.roughness ?? 0.5, metalness: s2.metalness ?? 0.5, envMapIntensity: s2.envMapIntensity ?? 1 });
2839
+ case "物理材质":
2840
+ return new t.MeshPhysicalMaterial({ ...i2, flatShading: s2.flatShading ?? false, map: s2.map, emissive: s2.emissive ?? 0, emissiveIntensity: s2.emissiveIntensity ?? 1, roughness: s2.roughness ?? 0.5, metalness: s2.metalness ?? 0.5, envMapIntensity: s2.envMapIntensity ?? 1 });
2841
+ case "Lambert材质":
2842
+ return new t.MeshLambertMaterial({ ...i2, flatShading: s2.flatShading ?? false, map: s2.map, emissive: s2.emissive ?? 0, emissiveIntensity: s2.emissiveIntensity ?? 1 });
2843
+ case "Phong材质":
2844
+ return new t.MeshPhongMaterial({ ...i2, flatShading: s2.flatShading ?? false, map: s2.map, emissive: s2.emissive ?? 0, emissiveIntensity: s2.emissiveIntensity ?? 1 });
2845
+ case "Toon材质":
2846
+ return new t.MeshToonMaterial({ ...i2, map: s2.map });
2847
+ case "法线材质":
2848
+ return new t.MeshNormalMaterial({ opacity: s2.opacity ?? 1, transparent: s2.transparent ?? false, side: s2.side ?? t.FrontSide, wireframe: s2.wireframe ?? false, flatShading: s2.flatShading ?? false });
2849
+ case "深度材质":
2850
+ return new t.MeshDepthMaterial({ opacity: s2.opacity ?? 1, wireframe: s2.wireframe ?? false });
2851
+ default:
2852
+ return new t.MeshStandardMaterial(i2);
2853
+ }
2854
+ }
2855
+ changeMaterial(e4, t2) {
2856
+ const n2 = Array.isArray(e4.material) ? e4.material : [e4.material];
2857
+ e4._originalMaterials || (e4._originalMaterials = n2.map((e5) => e5.clone()));
2858
+ for (const e5 of n2) this.applyParams(e5, t2);
2859
+ }
2860
+ changeGroupMaterial(e4, t2) {
2861
+ e4.traverse((e5) => {
2862
+ e5.isMesh && this.changeMaterial(e5, t2);
2863
+ });
2864
+ }
2865
+ applyParams(e4, t2) {
2866
+ const n2 = e4;
2867
+ void 0 !== t2.color && n2.color && n2.color.set(t2.color), void 0 !== t2.opacity && (n2.opacity = t2.opacity), void 0 !== t2.transparent && (n2.transparent = t2.transparent), void 0 !== t2.side && (n2.side = t2.side), void 0 !== t2.wireframe && (n2.wireframe = t2.wireframe), void 0 !== t2.emissive && n2.emissive && n2.emissive.set(t2.emissive), void 0 !== t2.emissiveIntensity && (n2.emissiveIntensity = t2.emissiveIntensity), void 0 !== t2.roughness && (n2.roughness = t2.roughness), void 0 !== t2.metalness && (n2.metalness = t2.metalness), e4.needsUpdate = true;
2868
+ }
2869
+ revertMaterial(e4) {
2870
+ const t2 = e4._originalMaterials;
2871
+ t2 && (Array.isArray(e4.material) ? e4.material.forEach((e5, n2) => {
2872
+ t2[n2] && this.copyMaterialProperties(t2[n2], e5);
2873
+ }) : t2[0] && this.copyMaterialProperties(t2[0], e4.material));
2874
+ }
2875
+ revertGroupMaterial(e4) {
2876
+ e4.traverse((e5) => {
2877
+ e5.isMesh && this.revertMaterial(e5);
2878
+ });
2879
+ }
2880
+ copyMaterialProperties(e4, t2) {
2881
+ const n2 = e4, s2 = t2;
2882
+ n2.color && s2.color && s2.color.copy(n2.color), n2.emissive && s2.emissive && s2.emissive.copy(n2.emissive), s2.opacity = n2.opacity, s2.transparent = n2.transparent, s2.side = n2.side, void 0 !== n2.wireframe && (s2.wireframe = n2.wireframe), void 0 !== n2.emissiveIntensity && (s2.emissiveIntensity = n2.emissiveIntensity), void 0 !== n2.roughness && (s2.roughness = n2.roughness), void 0 !== n2.metalness && (s2.metalness = n2.metalness), t2.needsUpdate = true;
2883
+ }
2884
+ cloneMaterial(e4) {
2885
+ e4.traverse((e5) => {
2886
+ if (e5.isMesh) {
2887
+ const t2 = e5;
2888
+ t2.isCloneMaterial = true, t2.originMaterial = t2.material, Array.isArray(t2.material) ? t2.material = t2.material.map((e6) => e6.clone()) : t2.material = t2.material.clone();
2889
+ }
2890
+ });
2891
+ }
2892
+ getMaterials(e4) {
2893
+ const t2 = [];
2894
+ return e4.traverse((e5) => {
2895
+ if (e5.isMesh) {
2896
+ const n2 = e5;
2897
+ Array.isArray(n2.material) ? t2.push(...n2.material) : n2.material && t2.push(n2.material);
2898
+ }
2899
+ }), [...new Set(t2)];
2900
+ }
2901
+ }
2902
+ const Ot = { particlesSum: 1e4, inner: 0, outer: 100, maxVelocity: 10, mapUrl: "", shaderCodeName: "雪片着色", sportType: "全随机" };
2903
+ class Ht extends k {
2904
+ constructor(e4) {
2905
+ super({ ...Ot, ...e4 }), this.name = "particle", this.sportTypes = ["全随机", "随机向下", "随机向上", "直线匀速向上", "直线匀速向下"], this.particleSystems = [], this.textureLoader = new t.TextureLoader();
2906
+ }
2907
+ onUninstall() {
2908
+ this.clearAll();
2909
+ }
2910
+ onUpdate(e4) {
2911
+ for (const t2 of this.particleSystems) this.updateParticleSystem(t2, e4);
2912
+ }
2913
+ createParticleSystem(e4) {
2914
+ const n2 = { particlesSum: (e4 == null ? void 0 : e4.particlesSum) ?? this.config.particlesSum, inner: (e4 == null ? void 0 : e4.inner) ?? this.config.inner, outer: (e4 == null ? void 0 : e4.outer) ?? this.config.outer, maxVelocity: (e4 == null ? void 0 : e4.maxVelocity) ?? this.config.maxVelocity, mapUrl: (e4 == null ? void 0 : e4.mapUrl) ?? this.config.mapUrl, sportType: (e4 == null ? void 0 : e4.sportType) ?? this.config.sportType, size: (e4 == null ? void 0 : e4.size) ?? 1, color: (e4 == null ? void 0 : e4.color) ?? 16777215, opacity: (e4 == null ? void 0 : e4.opacity) ?? 1 }, { particlesSum: s2, inner: i2, outer: o2, maxVelocity: r2, sportType: a2 } = n2, l2 = new t.BufferGeometry(), d2 = new Float32Array(3 * s2), c2 = new Float32Array(3 * s2);
2915
+ for (let e5 = 0; e5 < s2; e5++) {
2916
+ const t2 = 3 * e5, n3 = i2 + Math.random() * (o2 - i2), s3 = Math.random() * Math.PI * 2, l3 = Math.acos(2 * Math.random() - 1);
2917
+ switch (d2[t2] = n3 * Math.sin(l3) * Math.cos(s3), d2[t2 + 1] = n3 * Math.sin(l3) * Math.sin(s3), d2[t2 + 2] = n3 * Math.cos(l3), a2) {
2918
+ case "全随机":
2919
+ c2[t2] = (Math.random() - 0.5) * r2, c2[t2 + 1] = (Math.random() - 0.5) * r2, c2[t2 + 2] = (Math.random() - 0.5) * r2;
2920
+ break;
2921
+ case "随机向下":
2922
+ c2[t2] = (Math.random() - 0.5) * r2 * 0.2, c2[t2 + 1] = -Math.random() * r2, c2[t2 + 2] = (Math.random() - 0.5) * r2 * 0.2;
2923
+ break;
2924
+ case "随机向上":
2925
+ c2[t2] = (Math.random() - 0.5) * r2 * 0.2, c2[t2 + 1] = Math.random() * r2, c2[t2 + 2] = (Math.random() - 0.5) * r2 * 0.2;
2926
+ break;
2927
+ case "直线匀速向上":
2928
+ c2[t2] = 0, c2[t2 + 1] = r2, c2[t2 + 2] = 0;
2929
+ break;
2930
+ case "直线匀速向下":
2931
+ c2[t2] = 0, c2[t2 + 1] = -r2, c2[t2 + 2] = 0;
2932
+ }
2933
+ }
2934
+ l2.setAttribute("position", new t.BufferAttribute(d2, 3));
2935
+ const h2 = new t.PointsMaterial({ size: n2.size, color: n2.color, transparent: true, opacity: n2.opacity, depthWrite: false, blending: t.AdditiveBlending });
2936
+ n2.mapUrl && this.textureLoader.load(n2.mapUrl, (e5) => {
2937
+ h2.map = e5, h2.needsUpdate = true;
2938
+ });
2939
+ const u2 = new t.Points(l2, h2);
2940
+ u2.name = "ParticleSystem", u2.isParticleMesh = true;
2941
+ const m2 = { mesh: u2, velocities: c2, config: n2 };
2942
+ return this.particleSystems.push(m2), u2;
2943
+ }
2944
+ addToScene(e4) {
2945
+ const t2 = this.createParticleSystem(e4);
2946
+ return this.scene.add(t2), t2;
2947
+ }
2948
+ updateParticleSystem(e4, t2) {
2949
+ const { mesh: n2, velocities: s2, config: i2 } = e4, o2 = n2.geometry.attributes.position.array, { inner: r2, outer: a2, sportType: l2 } = i2;
2950
+ for (let e5 = 0; e5 < o2.length; e5 += 3) {
2951
+ o2[e5] += s2[e5] * t2, o2[e5 + 1] += s2[e5 + 1] * t2, o2[e5 + 2] += s2[e5 + 2] * t2;
2952
+ const n3 = Math.sqrt(o2[e5] ** 2 + o2[e5 + 1] ** 2 + o2[e5 + 2] ** 2);
2953
+ if (n3 > a2 || n3 < r2) {
2954
+ const t3 = r2 + Math.random() * (a2 - r2), n4 = Math.random() * Math.PI * 2, s3 = Math.acos(2 * Math.random() - 1);
2955
+ o2[e5] = t3 * Math.sin(s3) * Math.cos(n4), o2[e5 + 1] = t3 * Math.sin(s3) * Math.sin(n4), o2[e5 + 2] = t3 * Math.cos(s3);
2956
+ }
2957
+ }
2958
+ n2.geometry.attributes.position.needsUpdate = true;
2959
+ }
2960
+ getParticleSystems() {
2961
+ return this.particleSystems;
2962
+ }
2963
+ removeParticleSystem(e4) {
2964
+ const t2 = this.particleSystems.findIndex((t3) => t3.mesh === e4);
2965
+ t2 > -1 && (this.scene.remove(e4), e4.geometry.dispose(), e4.material.dispose(), this.particleSystems.splice(t2, 1));
2966
+ }
2967
+ clearAll() {
2968
+ for (const e4 of this.particleSystems) this.scene.remove(e4.mesh), e4.mesh.geometry.dispose(), e4.mesh.material.dispose();
2969
+ this.particleSystems = [];
2970
+ }
2971
+ setEnabled(e4, t2) {
2972
+ e4.visible = t2;
2973
+ }
2974
+ }
2975
+ const Bt = { gravity: { x: 0, y: -9.82, z: 0 }, defaultMass: 1 };
2976
+ class jt extends k {
2977
+ constructor(e4) {
2978
+ super({ ...Bt, ...e4 }), this.name = "physics", this.bodies = [], this._enabled = true;
2979
+ }
2980
+ get physicsWorld() {
2981
+ return this.world;
2982
+ }
2983
+ get enabled() {
2984
+ return this._enabled;
2985
+ }
2986
+ set enabled(e4) {
2987
+ this._enabled = e4;
2988
+ }
2989
+ onInstall() {
2990
+ this.world = new S.World(), this.world.gravity.set(this.config.gravity.x, this.config.gravity.y, this.config.gravity.z), this.world.broadphase = new S.NaiveBroadphase(), void 0 !== this.world.solver.iterations && (this.world.solver.iterations = 10);
2991
+ }
2992
+ onUninstall() {
2993
+ this.clearAll();
2994
+ }
2995
+ onUpdate(e4) {
2996
+ if (this._enabled) {
2997
+ this.world.step(1 / 60, e4, 3);
2998
+ for (const e5 of this.bodies) e5.isUpdate && (e5.mesh.position.copy(e5.body.position), e5.mesh.quaternion.copy(e5.body.quaternion));
2999
+ }
3000
+ }
3001
+ setGravity(e4, t2, n2) {
3002
+ this.world.gravity.set(e4, t2, n2), this.config.gravity = { x: e4, y: t2, z: n2 };
3003
+ }
3004
+ addBody(e4, t2) {
3005
+ const { center: n2, max: s2, min: i2, radius: o2 } = _t(e4), r2 = (t2 == null ? void 0 : t2.isStatic) ? 0 : (t2 == null ? void 0 : t2.mass) ?? this.config.defaultMass;
3006
+ let a2;
3007
+ switch (t2 == null ? void 0 : t2.shape) {
3008
+ case "sphere":
3009
+ a2 = new S.Sphere(o2);
3010
+ break;
3011
+ case "cylinder":
3012
+ const e5 = Math.max(s2.x - i2.x, s2.z - i2.z) / 2, t3 = s2.y - i2.y;
3013
+ a2 = new S.Cylinder(e5, e5, t3, 16);
3014
+ break;
3015
+ default:
3016
+ a2 = new S.Box(new S.Vec3((s2.x - i2.x) / 2, (s2.y - i2.y) / 2, (s2.z - i2.z) / 2));
3017
+ }
3018
+ const l2 = new S.Body({ mass: r2, shape: a2, position: new S.Vec3(n2.x, n2.y, n2.z) });
3019
+ void 0 === (t2 == null ? void 0 : t2.friction) && void 0 === (t2 == null ? void 0 : t2.restitution) || (l2.material = new S.Material(), void 0 !== t2.friction && (l2.material.friction = t2.friction), void 0 !== t2.restitution && (l2.material.restitution = t2.restitution)), this.world.addBody(l2);
3020
+ const d2 = { body: l2, mesh: e4, isUpdate: !(t2 == null ? void 0 : t2.isStatic) };
3021
+ return this.bodies.push(d2), e4.physicsBody = l2, l2;
3022
+ }
3023
+ addGround(e4 = 0) {
3024
+ const t2 = new S.Body({ mass: 0, shape: new S.Plane(), position: new S.Vec3(0, e4, 0) });
3025
+ return t2.quaternion.setFromEuler(-Math.PI / 2, 0, 0), this.world.addBody(t2), t2;
3026
+ }
3027
+ removeBody(e4) {
3028
+ const t2 = this.bodies.findIndex((t3) => t3.mesh === e4);
3029
+ if (t2 > -1) {
3030
+ const n2 = this.bodies[t2];
3031
+ this.world.removeBody(n2.body), this.bodies.splice(t2, 1), delete e4.physicsBody;
3032
+ }
3033
+ }
3034
+ getBody(e4) {
3035
+ const t2 = this.bodies.find((t3) => t3.mesh === e4);
3036
+ return t2 == null ? void 0 : t2.body;
3037
+ }
3038
+ setBodyUpdate(e4, t2) {
3039
+ const n2 = this.bodies.find((t3) => t3.mesh === e4);
3040
+ n2 && (n2.isUpdate = t2, t2 && (n2.body.position.copy(e4.position), n2.body.quaternion.copy(e4.quaternion)));
3041
+ }
3042
+ applyForce(e4, t2, n2) {
3043
+ const s2 = this.getBody(e4);
3044
+ if (s2) {
3045
+ const e5 = new S.Vec3(t2.x, t2.y, t2.z);
3046
+ if (n2) {
3047
+ const t3 = new S.Vec3(n2.x, n2.y, n2.z);
3048
+ s2.applyForce(e5, t3);
3049
+ } else s2.applyForce(e5);
3050
+ }
3051
+ }
3052
+ applyImpulse(e4, t2, n2) {
3053
+ const s2 = this.getBody(e4);
3054
+ if (s2) {
3055
+ const e5 = new S.Vec3(t2.x, t2.y, t2.z);
3056
+ if (n2) {
3057
+ const t3 = new S.Vec3(n2.x, n2.y, n2.z);
3058
+ s2.applyImpulse(e5, t3);
3059
+ } else s2.applyImpulse(e5);
3060
+ }
3061
+ }
3062
+ setVelocity(e4, t2) {
3063
+ const n2 = this.getBody(e4);
3064
+ n2 && n2.velocity.set(t2.x, t2.y, t2.z);
3065
+ }
3066
+ resetBody(e4) {
3067
+ const t2 = this.getBody(e4);
3068
+ t2 && (t2.velocity.setZero(), t2.angularVelocity.setZero(), t2.position.copy(e4.position), t2.quaternion.copy(e4.quaternion));
3069
+ }
3070
+ clearAll() {
3071
+ for (const e4 of this.bodies) this.world.removeBody(e4.body), delete e4.mesh.physicsBody;
3072
+ this.bodies = [];
3073
+ }
3074
+ getBodies() {
3075
+ return this.bodies;
3076
+ }
3077
+ }
3078
+ const Rt = { defaultFontUrl: "https://z2586300277.github.io/three-editor/dist/files/font/cn1.json", defaultSize: 1, defaultHeight: 0.2 };
3079
+ class zt extends k {
3080
+ constructor(e4) {
3081
+ super({ ...Rt, ...e4 }), this.name = "text", this.fontLoader = new l(), this.fontCache = /* @__PURE__ */ new Map(), this.textMeshes = [];
3082
+ }
3083
+ onUninstall() {
3084
+ this.clearAll(), this.fontCache.clear();
3085
+ }
3086
+ async loadFont(e4) {
3087
+ const t2 = this.fontCache.get(e4);
3088
+ return t2 || new Promise((t3, n2) => {
3089
+ this.fontLoader.load(e4, (n3) => {
3090
+ this.fontCache.set(e4, n3), t3(n3);
3091
+ }, void 0, n2);
3092
+ });
3093
+ }
3094
+ async createTextGeometry(e4) {
3095
+ const t2 = await this.loadFont(e4.fontUrl || this.config.defaultFontUrl), n2 = new F(e4.text, { font: t2, size: e4.size ?? this.config.defaultSize, height: e4.height ?? this.config.defaultHeight, curveSegments: e4.curveSegments ?? 12, bevelEnabled: e4.bevelEnabled ?? false, bevelThickness: e4.bevelThickness ?? 0.1, bevelSize: e4.bevelSize ?? 0.05, bevelOffset: e4.bevelOffset ?? 0, bevelSegments: e4.bevelSegments ?? 3 });
3096
+ return n2.computeBoundingBox(), n2.center(), n2;
3097
+ }
3098
+ async createTextMesh(e4) {
3099
+ const n2 = await this.createTextGeometry(e4);
3100
+ let s2;
3101
+ switch (e4.materialType) {
3102
+ case "basic":
3103
+ s2 = new t.MeshBasicMaterial({ color: e4.color ?? 16777215 });
3104
+ break;
3105
+ case "phong":
3106
+ s2 = new t.MeshPhongMaterial({ color: e4.color ?? 16777215 });
3107
+ break;
3108
+ default:
3109
+ s2 = new t.MeshStandardMaterial({ color: e4.color ?? 16777215 });
3110
+ }
3111
+ const i2 = new t.Mesh(n2, s2);
3112
+ return i2.name = e4.text, i2.isTextMesh = true, i2.fontLink = e4.fontUrl || this.config.defaultFontUrl, i2.text = e4.text, i2;
3113
+ }
3114
+ async addToScene(e4) {
3115
+ const t2 = await this.createTextMesh(e4);
3116
+ return this.scene.add(t2), this.textMeshes.push(t2), t2;
3117
+ }
3118
+ async updateText(e4, t2) {
3119
+ const n2 = e4.fontLink || this.config.defaultFontUrl, s2 = e4.geometry, i2 = await this.createTextGeometry({ text: t2, fontUrl: n2 });
3120
+ e4.geometry = i2, e4.name = t2, e4.text = t2, s2.dispose();
3121
+ }
3122
+ getTextMeshes() {
3123
+ return this.textMeshes;
3124
+ }
3125
+ removeTextMesh(e4) {
3126
+ const t2 = this.textMeshes.indexOf(e4);
3127
+ t2 > -1 && (this.scene.remove(e4), e4.geometry.dispose(), Array.isArray(e4.material) ? e4.material.forEach((e5) => e5.dispose()) : e4.material.dispose(), this.textMeshes.splice(t2, 1));
3128
+ }
3129
+ clearAll() {
3130
+ for (const e4 of this.textMeshes) this.scene.remove(e4), e4.geometry.dispose(), Array.isArray(e4.material) ? e4.material.forEach((e5) => e5.dispose()) : e4.material.dispose();
3131
+ this.textMeshes = [];
3132
+ }
3133
+ }
3134
+ const Dt = { fog: { enabled: false, type: "linear", color: 13421772, near: 1, far: 1e3, density: 25e-5 }, skybox: null, environmentMap: null, environmentIntensity: 1, backgroundBlurriness: 0, backgroundIntensity: 1 };
3135
+ class Gt extends k {
3136
+ constructor(e4) {
3137
+ super({ ...Dt, ...e4 }), this.name = "environment", this.rgbeLoader = new E(), this.cubeTextureLoader = new t.CubeTextureLoader(), this.textureLoader = new t.TextureLoader(), this.currentEnvMap = null, this.currentBackground = null;
3138
+ }
3139
+ onInstall() {
3140
+ this.config.fog.enabled && this.setFog(this.config.fog), this.config.skybox && this.setSkybox(this.config.skybox), this.config.environmentMap && this.setEnvironmentMap(this.config.environmentMap);
3141
+ }
3142
+ onUninstall() {
3143
+ this.clearFog(), this.clearBackground(), this.clearEnvironmentMap();
3144
+ }
3145
+ setFog(e4) {
3146
+ if (Object.assign(this.config.fog, e4), !this.config.fog.enabled) return void this.clearFog();
3147
+ const n2 = new t.Color(this.config.fog.color);
3148
+ "linear" === this.config.fog.type ? this.scene.fog = new t.Fog(n2, this.config.fog.near ?? 1, this.config.fog.far ?? 1e3) : this.scene.fog = new t.FogExp2(n2, this.config.fog.density ?? 25e-5);
3149
+ }
3150
+ clearFog() {
3151
+ this.scene.fog = null, this.config.fog.enabled = false;
3152
+ }
3153
+ setFogColor(e4) {
3154
+ this.config.fog.color = e4, this.scene.fog && this.scene.fog.color.setHex(e4);
3155
+ }
3156
+ async setSkybox(e4) {
3157
+ switch (this.config.skybox = e4, e4.type) {
3158
+ case "color":
3159
+ this.setBackgroundColor(e4.color ?? 0);
3160
+ break;
3161
+ case "texture":
3162
+ e4.url && await this.setBackgroundTexture(e4.url);
3163
+ break;
3164
+ case "cubeTexture":
3165
+ e4.urls && 6 === e4.urls.length && await this.setBackgroundCubeTexture(e4.urls);
3166
+ break;
3167
+ case "hdr":
3168
+ e4.url && await this.setBackgroundHDR(e4.url);
3169
+ break;
3170
+ case "equirectangular":
3171
+ e4.url && await this.setBackgroundEquirectangular(e4.url);
3172
+ }
3173
+ }
3174
+ setBackgroundColor(e4) {
3175
+ this.currentBackground = new t.Color(e4), this.scene.background = this.currentBackground;
3176
+ }
3177
+ async setBackgroundTexture(e4) {
3178
+ return new Promise((t2, n2) => {
3179
+ this.textureLoader.load(e4, (e5) => {
3180
+ this.currentBackground = e5, this.scene.background = e5, t2(e5);
3181
+ }, void 0, n2);
3182
+ });
3183
+ }
3184
+ async setBackgroundCubeTexture(e4) {
3185
+ return new Promise((t2, n2) => {
3186
+ this.cubeTextureLoader.load(e4, (e5) => {
3187
+ this.currentBackground = e5, this.scene.background = e5, t2(e5);
3188
+ }, void 0, n2);
3189
+ });
3190
+ }
3191
+ async setBackgroundHDR(e4) {
3192
+ return new Promise((n2, s2) => {
3193
+ this.rgbeLoader.load(e4, (e5) => {
3194
+ e5.mapping = t.EquirectangularReflectionMapping, this.currentBackground = e5, this.scene.background = e5, n2(e5);
3195
+ }, void 0, s2);
3196
+ });
3197
+ }
3198
+ async setBackgroundEquirectangular(e4) {
3199
+ return new Promise((n2, s2) => {
3200
+ this.textureLoader.load(e4, (e5) => {
3201
+ e5.mapping = t.EquirectangularReflectionMapping, this.currentBackground = e5, this.scene.background = e5, n2(e5);
3202
+ }, void 0, s2);
3203
+ });
3204
+ }
3205
+ clearBackground() {
3206
+ this.currentBackground instanceof t.Texture && this.currentBackground.dispose(), this.scene.background = null, this.currentBackground = null, this.config.skybox = null;
3207
+ }
3208
+ async setEnvironmentMap(e4) {
3209
+ return this.config.environmentMap = e4, new Promise((n2, s2) => {
3210
+ this.rgbeLoader.load(e4, (e5) => {
3211
+ e5.mapping = t.EquirectangularReflectionMapping, this.currentEnvMap = e5, this.scene.environment = e5, "environmentIntensity" in this.scene && (this.scene.environmentIntensity = this.config.environmentIntensity), n2(e5);
3212
+ }, void 0, s2);
3213
+ });
3214
+ }
3215
+ async setCubeEnvironmentMap(e4) {
3216
+ return new Promise((t2, n2) => {
3217
+ this.cubeTextureLoader.load(e4, (e5) => {
3218
+ this.currentEnvMap = e5, this.scene.environment = e5, t2(e5);
3219
+ }, void 0, n2);
3220
+ });
3221
+ }
3222
+ clearEnvironmentMap() {
3223
+ this.currentEnvMap && this.currentEnvMap.dispose(), this.scene.environment = null, this.currentEnvMap = null, this.config.environmentMap = null;
3224
+ }
3225
+ setEnvironmentIntensity(e4) {
3226
+ this.config.environmentIntensity = e4, "environmentIntensity" in this.scene && (this.scene.environmentIntensity = e4);
3227
+ }
3228
+ setBackgroundBlurriness(e4) {
3229
+ this.config.backgroundBlurriness = e4, "backgroundBlurriness" in this.scene && (this.scene.backgroundBlurriness = e4);
3230
+ }
3231
+ setBackgroundIntensity(e4) {
3232
+ this.config.backgroundIntensity = e4, "backgroundIntensity" in this.scene && (this.scene.backgroundIntensity = e4);
3233
+ }
3234
+ getEnvironmentMap() {
3235
+ return this.currentEnvMap;
3236
+ }
3237
+ getBackground() {
3238
+ return this.currentBackground;
3239
+ }
3240
+ getFogConfig() {
3241
+ return { ...this.config.fog };
3242
+ }
3243
+ getConfig() {
3244
+ return { ...this.config };
3245
+ }
3246
+ }
3247
+ const Ut = { version: "1.0.0", includeGeometry: false, includeMaterial: true, includeUserData: true, excludeHelpers: true };
3248
+ class It extends k {
3249
+ constructor(e4) {
3250
+ super({ ...Ut, ...e4 }), this.name = "serialization";
3251
+ }
3252
+ serialize() {
3253
+ const e4 = this.scene, t2 = this.camera;
3254
+ return { version: this.config.version, metadata: { generator: "ThreeEditor", timestamp: Date.now() }, scene: this.serializeSceneProperties(), camera: this.serializeCamera(t2), objects: this.serializeObjects(e4.children), plugins: this.serializePlugins() };
3255
+ }
3256
+ serializeSceneProperties() {
3257
+ const e4 = this.scene;
3258
+ return { background: this.serializeBackground(e4.background), fog: this.serializeFog(e4.fog), environment: e4.environment ? "has_environment" : null };
3259
+ }
3260
+ serializeBackground(e4) {
3261
+ return e4 ? e4 instanceof t.Color ? { type: "color", value: e4.getHex() } : e4 instanceof t.Texture ? { type: "texture", url: e4.sourceFile || null } : null : null;
3262
+ }
3263
+ serializeFog(e4) {
3264
+ return e4 ? e4 instanceof t.Fog ? { type: "linear", color: e4.color.getHex(), near: e4.near, far: e4.far } : e4 instanceof t.FogExp2 ? { type: "exponential", color: e4.color.getHex(), density: e4.density } : null : null;
3265
+ }
3266
+ serializeCamera(e4) {
3267
+ const n2 = { type: e4.type, position: { x: e4.position.x, y: e4.position.y, z: e4.position.z }, rotation: { x: e4.rotation.x, y: e4.rotation.y, z: e4.rotation.z }, near: e4.near, far: e4.far, zoom: e4.zoom };
3268
+ return e4 instanceof t.PerspectiveCamera && (n2.fov = e4.fov), n2;
3269
+ }
3270
+ serializeObjects(e4) {
3271
+ const t2 = [];
3272
+ for (const n2 of e4) {
3273
+ if (this.config.excludeHelpers && this.isHelper(n2)) continue;
3274
+ const e5 = this.serializeObject(n2);
3275
+ e5 && t2.push(e5);
3276
+ }
3277
+ return t2;
3278
+ }
3279
+ serializeObject(e4) {
3280
+ const t2 = { uuid: e4.uuid, name: e4.name, type: e4.type, position: { x: e4.position.x, y: e4.position.y, z: e4.position.z }, rotation: { x: e4.rotation.x, y: e4.rotation.y, z: e4.rotation.z }, scale: { x: e4.scale.x, y: e4.scale.y, z: e4.scale.z }, visible: e4.visible, userData: this.config.includeUserData ? e4.userData : {} };
3281
+ return this.config.includeGeometry && e4.geometry && (t2.geometry = this.serializeGeometry(e4.geometry)), this.config.includeMaterial && e4.material && (t2.material = this.serializeMaterial(e4.material)), e4.children.length > 0 && (t2.children = this.serializeObjects(e4.children)), t2;
3282
+ }
3283
+ serializeGeometry(e4) {
3284
+ return { type: e4.type, uuid: e4.uuid, parameters: e4.parameters || {} };
3285
+ }
3286
+ serializeMaterial(e4) {
3287
+ return Array.isArray(e4) ? e4.map((e5) => this.serializeSingleMaterial(e5)) : this.serializeSingleMaterial(e4);
3288
+ }
3289
+ serializeSingleMaterial(e4) {
3290
+ const t2 = { type: e4.type, uuid: e4.uuid, name: e4.name, opacity: e4.opacity, transparent: e4.transparent, visible: e4.visible, side: e4.side };
3291
+ return e4.color && (t2.color = e4.color.getHex()), void 0 !== e4.metalness && (t2.metalness = e4.metalness), void 0 !== e4.roughness && (t2.roughness = e4.roughness), e4.emissive && (t2.emissive = e4.emissive.getHex()), void 0 !== e4.emissiveIntensity && (t2.emissiveIntensity = e4.emissiveIntensity), t2;
3292
+ }
3293
+ serializePlugins() {
3294
+ const e4 = {}, t2 = this.context.pluginManager;
3295
+ if (t2 && "function" == typeof t2.getAll) {
3296
+ const n2 = t2.getAll();
3297
+ for (const t3 of n2) t3.name !== this.name && "function" == typeof t3.getConfig && (e4[t3.name] = t3.getConfig());
3298
+ }
3299
+ return e4;
3300
+ }
3301
+ isHelper(e4) {
3302
+ return e4.name.startsWith("__") || e4.type.includes("Helper") || "TransformControls" === e4.type || "TransformControlsPlane" === e4.type;
3303
+ }
3304
+ async deserialize(e4) {
3305
+ this.deserializeCamera(e4.camera), this.deserializeSceneProperties(e4.scene), this.deserializePlugins(e4.plugins), this.events.emit("scene:deserialized", e4);
3306
+ }
3307
+ deserializeCamera(e4) {
3308
+ const n2 = this.camera;
3309
+ n2.position.set(e4.position.x, e4.position.y, e4.position.z), n2.rotation.set(e4.rotation.x, e4.rotation.y, e4.rotation.z), n2 instanceof t.PerspectiveCamera && e4.fov && (n2.fov = e4.fov, n2.near = e4.near, n2.far = e4.far, n2.zoom = e4.zoom, n2.updateProjectionMatrix());
3310
+ }
3311
+ deserializeSceneProperties(e4) {
3312
+ e4.background && "color" === e4.background.type && (this.scene.background = new t.Color(e4.background.value)), e4.fog && ("linear" === e4.fog.type ? this.scene.fog = new t.Fog(e4.fog.color, e4.fog.near, e4.fog.far) : "exponential" === e4.fog.type && (this.scene.fog = new t.FogExp2(e4.fog.color, e4.fog.density)));
3313
+ }
3314
+ deserializePlugins(e4) {
3315
+ const t2 = this.context.pluginManager;
3316
+ if (t2 && "function" == typeof t2.get) for (const [n2, s2] of Object.entries(e4)) {
3317
+ const e5 = t2.get(n2);
3318
+ e5 && "function" == typeof e5.setConfig && e5.setConfig(s2);
3319
+ }
3320
+ }
3321
+ toJSON() {
3322
+ return JSON.stringify(this.serialize(), null, 2);
3323
+ }
3324
+ async fromJSON(e4) {
3325
+ const t2 = JSON.parse(e4);
3326
+ await this.deserialize(t2);
3327
+ }
3328
+ download(e4 = "scene.json") {
3329
+ const t2 = this.toJSON(), n2 = new Blob([t2], { type: "application/json" }), s2 = URL.createObjectURL(n2), i2 = document.createElement("a");
3330
+ i2.href = s2, i2.download = e4, i2.click(), URL.revokeObjectURL(s2);
3331
+ }
3332
+ async loadFromFile(e4) {
3333
+ return new Promise((t2, n2) => {
3334
+ const s2 = new FileReader();
3335
+ s2.onload = async (e5) => {
3336
+ var _a;
3337
+ try {
3338
+ const n3 = (_a = e5.target) == null ? void 0 : _a.result;
3339
+ await this.fromJSON(n3), t2();
3340
+ } catch (e6) {
3341
+ n2(e6);
3342
+ }
3343
+ }, s2.onerror = n2, s2.readAsText(e4);
3344
+ });
3345
+ }
3346
+ getConfig() {
3347
+ return { ...this.config };
3348
+ }
3349
+ setConfig(e4) {
3350
+ Object.assign(this.config, e4);
3351
+ }
3352
+ }
3353
+ export {
3354
+ gt as $,
3355
+ Mt as A,
3356
+ it as B,
3357
+ z as C,
3358
+ X as D,
3359
+ W as E,
3360
+ ot as F,
3361
+ kt as G,
3362
+ rt as H,
3363
+ ct as I,
3364
+ vt as J,
3365
+ bt as K,
3366
+ j as L,
3367
+ Lt as M,
3368
+ G as N,
3369
+ L as O,
3370
+ k as P,
3371
+ U as Q,
3372
+ I as R,
3373
+ xt as S,
3374
+ H as T,
3375
+ V as U,
3376
+ N as V,
3377
+ ht as W,
3378
+ ut as X,
3379
+ mt as Y,
3380
+ pt as Z,
3381
+ ft as _,
3382
+ A as a,
3383
+ _t as a0,
3384
+ yt as a1,
3385
+ T as b,
3386
+ O as c,
3387
+ B as d,
3388
+ R as e,
3389
+ D as f,
3390
+ At as g,
3391
+ Tt as h,
3392
+ wt as i,
3393
+ Ct as j,
3394
+ St as k,
3395
+ Pt as l,
3396
+ Et as m,
3397
+ Ft as n,
3398
+ Ht as o,
3399
+ Ot as p,
3400
+ jt as q,
3401
+ Bt as r,
3402
+ zt as s,
3403
+ dt as t,
3404
+ Gt as u,
3405
+ It as v,
3406
+ at as w,
3407
+ tt as x,
3408
+ nt as y,
3409
+ st as z
3410
+ };
3411
+ //# sourceMappingURL=SerializationPlugin-CBr1GY5q.js.map