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