@tomorrowevening/hermes 0.1.40 → 0.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ThreeEditor-CB5dBR7Q.js → ThreeEditor-B4bS88iZ.js} +11 -11
- package/dist/core/remote/RemoteThree.js +68 -59
- package/dist/editor/ThreeEditor.js +13 -10
- package/dist/editor/sidePanel/utils.js +94 -87
- package/dist/hermes.cjs.js +8 -8
- package/dist/{index-DepTXu6T.js → index-XMQFdKEt.js} +616 -616
- package/dist/index.html +1 -1
- package/dist/index.js +129 -120
- package/package.json +1 -1
- package/types/core/remote/RemoteThree.d.ts +10 -1
- package/types/editor/sidePanel/utils.d.ts +7 -0
- package/types/index.d.ts +1 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Color as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class A extends b {
|
|
1
|
+
import { Color as l, ColorManagement as p, WebGPURenderer as g, RenderTarget as v, WebGLRenderTarget as f } from "three/webgpu";
|
|
2
|
+
import E from "./BaseRemote.js";
|
|
3
|
+
import { clamp as S } from "../../utils/math.js";
|
|
4
|
+
import { dispose as u, hierarchyUUID as o, ExportTexture as h, resetThreeObjects as c } from "../../utils/three.js";
|
|
5
|
+
var b = /* @__PURE__ */ ((a) => (a.CUSTOM = "ToolEvents::custom", a.SELECT_DROPDOWN = "ToolEvents::selectDropdown", a.DRAG_UPDATE = "ToolEvents::dragUpdate", a.ADD_SCENE = "ToolEvents::addScene", a.REFRESH_SCENE = "ToolEvents::refreshScene", a.REMOVE_SCENE = "ToolEvents::removeScene", a.SET_SCENE = "ToolEvents::setScene", a.SET_OBJECT = "ToolEvents::setObject", a.CLEAR_OBJECT = "ToolEvents::clearObject", a.ADD_CAMERA = "ToolEvents::addCamera", a.REMOVE_CAMERA = "ToolEvents::removeCamera", a.ADD_GROUP = "ToolEvents::addGroup", a.REMOVE_GROUP = "ToolEvents::removeGroup", a.ADD_SPLINE = "ToolEvents::addSpline", a.ADD_RENDERER = "ToolEvents::addRenderer", a.UPDATE_RENDERER = "ToolEvents::updateRenderer", a))(b || {});
|
|
6
|
+
class O extends E {
|
|
8
7
|
name;
|
|
9
8
|
canvas = null;
|
|
10
9
|
// Canvas or OffscreenCanvas
|
|
@@ -18,13 +17,17 @@ class A extends b {
|
|
|
18
17
|
renderTargetsResize = /* @__PURE__ */ new Map();
|
|
19
18
|
groups = /* @__PURE__ */ new Map();
|
|
20
19
|
_listeners = {};
|
|
20
|
+
editorUtils;
|
|
21
21
|
constructor(e, t = !1, r = !1) {
|
|
22
22
|
super("RemoteThree", t, r), this.name = e;
|
|
23
23
|
}
|
|
24
|
+
setEditorUtils(e) {
|
|
25
|
+
this.editorUtils = e;
|
|
26
|
+
}
|
|
24
27
|
dispose() {
|
|
25
28
|
this.scenes.forEach((e) => {
|
|
26
|
-
|
|
27
|
-
}), this.scenes.clear(), this.scene &&
|
|
29
|
+
u(e);
|
|
30
|
+
}), this.scenes.clear(), this.scene && u(this.scene), this.renderTargets.forEach((e) => {
|
|
28
31
|
e.dispose();
|
|
29
32
|
}), this.renderTargets.clear(), this.renderer?.dispose();
|
|
30
33
|
}
|
|
@@ -53,8 +56,8 @@ class A extends b {
|
|
|
53
56
|
const r = t[e.type];
|
|
54
57
|
if (r !== void 0) {
|
|
55
58
|
const s = { ...e, target: this }, d = r.slice(0);
|
|
56
|
-
for (let
|
|
57
|
-
d[
|
|
59
|
+
for (let i = 0, n = d.length; i < n; i++)
|
|
60
|
+
d[i].call(this, s);
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
63
|
// Objects
|
|
@@ -68,22 +71,27 @@ class A extends b {
|
|
|
68
71
|
}
|
|
69
72
|
getObject(e) {
|
|
70
73
|
if (!this.debug) return;
|
|
71
|
-
this.renderer !== void 0 && (
|
|
74
|
+
this.renderer !== void 0 && (h.renderer = this.renderer);
|
|
72
75
|
const t = this.getObjectByUUID(e);
|
|
73
76
|
t && this.setObject(t);
|
|
74
77
|
}
|
|
75
78
|
setObject(e) {
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
if (!this.editorUtils) return;
|
|
80
|
+
this.renderer !== void 0 && (h.renderer = this.renderer);
|
|
81
|
+
const t = this.editorUtils.stripObject(e);
|
|
78
82
|
this.dispatchEvent({ type: "ToolEvents::setObject", value: t });
|
|
79
83
|
}
|
|
80
84
|
requestMethod(e, t, r, s) {
|
|
81
85
|
const d = this.getObjectByUUID(e);
|
|
82
86
|
if (d)
|
|
83
87
|
try {
|
|
84
|
-
s !== void 0
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
if (s !== void 0) {
|
|
89
|
+
const i = this.editorUtils?.getSubItem(d, s);
|
|
90
|
+
i !== void 0 && i[t](r);
|
|
91
|
+
} else
|
|
92
|
+
d[t](r);
|
|
93
|
+
} catch (i) {
|
|
94
|
+
console.log("Hermes - Error requesting method:", e, t, r), console.log(i);
|
|
87
95
|
}
|
|
88
96
|
}
|
|
89
97
|
updateObject(e, t, r) {
|
|
@@ -112,34 +120,35 @@ class A extends b {
|
|
|
112
120
|
}
|
|
113
121
|
onUpdateObject(e, t, r) {
|
|
114
122
|
const s = this.getObjectByUUID(e);
|
|
115
|
-
s &&
|
|
123
|
+
s && this.editorUtils?.setItemProps(s, t, r);
|
|
116
124
|
}
|
|
117
125
|
onCreateTexture(e, t, r) {
|
|
126
|
+
if (!this.editorUtils) return;
|
|
118
127
|
const s = this.getObjectByUUID(e);
|
|
119
128
|
if (s) {
|
|
120
|
-
const d = (
|
|
129
|
+
const d = (i) => {
|
|
121
130
|
const n = t.split(".");
|
|
122
131
|
switch (n.length) {
|
|
123
132
|
case 1:
|
|
124
|
-
s[n[0]] =
|
|
133
|
+
s[n[0]] = i;
|
|
125
134
|
break;
|
|
126
135
|
case 2:
|
|
127
|
-
s[n[0]][n[1]] =
|
|
136
|
+
s[n[0]][n[1]] = i;
|
|
128
137
|
break;
|
|
129
138
|
case 3:
|
|
130
|
-
s[n[0]][n[1]][n[2]] =
|
|
139
|
+
s[n[0]][n[1]][n[2]] = i;
|
|
131
140
|
break;
|
|
132
141
|
case 4:
|
|
133
|
-
s[n[0]][n[1]][n[2]][n[3]] =
|
|
142
|
+
s[n[0]][n[1]][n[2]][n[3]] = i;
|
|
134
143
|
break;
|
|
135
144
|
case 5:
|
|
136
|
-
s[n[0]][n[1]][n[2]][n[3]][n[4]] =
|
|
145
|
+
s[n[0]][n[1]][n[2]][n[3]][n[4]] = i;
|
|
137
146
|
break;
|
|
138
147
|
}
|
|
139
148
|
s.material.needsUpdate = !0;
|
|
140
149
|
};
|
|
141
|
-
r.src.length > 0 ?
|
|
142
|
-
|
|
150
|
+
r.src.length > 0 ? this.editorUtils.textureFromSrc(r.src).then((i) => {
|
|
151
|
+
i.offset.set(r.offset[0], r.offset[1]), i.repeat.set(r.repeat[0], r.repeat[1]), d(i);
|
|
143
152
|
}) : d(null);
|
|
144
153
|
}
|
|
145
154
|
}
|
|
@@ -189,7 +198,7 @@ class A extends b {
|
|
|
189
198
|
// Renderer
|
|
190
199
|
setRenderer(e, t = null) {
|
|
191
200
|
if (this.renderer = e, this.canvas = e.domElement, this.inputElement = t !== null ? t : this.canvas, !this.debug) return;
|
|
192
|
-
const r = `#${e.getClearColor(new
|
|
201
|
+
const r = `#${e.getClearColor(new l()).getHexString()}`;
|
|
193
202
|
this.send({
|
|
194
203
|
event: "addRenderer",
|
|
195
204
|
target: "editor",
|
|
@@ -198,7 +207,7 @@ class A extends b {
|
|
|
198
207
|
outputColorSpace: e.outputColorSpace,
|
|
199
208
|
clearColor: r,
|
|
200
209
|
clearAlpha: e.getClearAlpha(),
|
|
201
|
-
colorManagement:
|
|
210
|
+
colorManagement: p.enabled,
|
|
202
211
|
toneMapping: e.toneMapping,
|
|
203
212
|
toneMappingExposure: e.toneMappingExposure,
|
|
204
213
|
type: e.isWebGLRenderer ? "WebGLRenderer" : "WebGPURenderer"
|
|
@@ -214,9 +223,9 @@ class A extends b {
|
|
|
214
223
|
}
|
|
215
224
|
// Scenes
|
|
216
225
|
addScene(e) {
|
|
217
|
-
if (e === void 0 || (this.scenes.set(e.name, e), !this.debug)) return;
|
|
218
|
-
|
|
219
|
-
const t =
|
|
226
|
+
if (e === void 0 || (this.scenes.set(e.name, e), !this.debug || !this.editorUtils)) return;
|
|
227
|
+
c(), o(e);
|
|
228
|
+
const t = this.editorUtils.stripScene(e);
|
|
220
229
|
this.send({
|
|
221
230
|
event: "addScene",
|
|
222
231
|
target: "editor",
|
|
@@ -224,10 +233,10 @@ class A extends b {
|
|
|
224
233
|
});
|
|
225
234
|
}
|
|
226
235
|
refreshScene(e) {
|
|
227
|
-
if (!this.debug) return;
|
|
236
|
+
if (!this.debug || !this.editorUtils) return;
|
|
228
237
|
const t = this.scenes.get(e);
|
|
229
238
|
if (t !== void 0) {
|
|
230
|
-
const r =
|
|
239
|
+
const r = this.editorUtils.stripScene(t);
|
|
231
240
|
this.send({
|
|
232
241
|
event: "refreshScene",
|
|
233
242
|
target: "app",
|
|
@@ -236,8 +245,8 @@ class A extends b {
|
|
|
236
245
|
}
|
|
237
246
|
}
|
|
238
247
|
removeScene(e) {
|
|
239
|
-
if (e === void 0 || (this.scenes.delete(e.name), !this.debug)) return;
|
|
240
|
-
const t =
|
|
248
|
+
if (e === void 0 || (this.scenes.delete(e.name), !this.debug || !this.editorUtils)) return;
|
|
249
|
+
const t = this.editorUtils.stripScene(e);
|
|
241
250
|
this.send({
|
|
242
251
|
event: "removeScene",
|
|
243
252
|
target: "editor",
|
|
@@ -254,9 +263,9 @@ class A extends b {
|
|
|
254
263
|
}), t);
|
|
255
264
|
}
|
|
256
265
|
setScene(e) {
|
|
257
|
-
if (e === void 0 || (this.scene = e, !this.debug)) return;
|
|
258
|
-
this.renderer !== void 0 && (
|
|
259
|
-
const t =
|
|
266
|
+
if (e === void 0 || (this.scene = e, !this.debug || !this.editorUtils)) return;
|
|
267
|
+
this.renderer !== void 0 && (h.renderer = this.renderer), c(), o(e);
|
|
268
|
+
const t = this.editorUtils.stripScene(e);
|
|
260
269
|
this.send({
|
|
261
270
|
event: "setScene",
|
|
262
271
|
target: "editor",
|
|
@@ -283,8 +292,8 @@ class A extends b {
|
|
|
283
292
|
}
|
|
284
293
|
// Cameras
|
|
285
294
|
addCamera(e) {
|
|
286
|
-
if (!this.debug) return;
|
|
287
|
-
const t =
|
|
295
|
+
if (!this.debug || !this.editorUtils) return;
|
|
296
|
+
const t = this.editorUtils.stripObject(e);
|
|
288
297
|
this.send({
|
|
289
298
|
event: "addCamera",
|
|
290
299
|
target: "editor",
|
|
@@ -292,8 +301,8 @@ class A extends b {
|
|
|
292
301
|
});
|
|
293
302
|
}
|
|
294
303
|
removeCamera(e) {
|
|
295
|
-
if (!this.debug) return;
|
|
296
|
-
const t =
|
|
304
|
+
if (!this.debug || !this.editorUtils) return;
|
|
305
|
+
const t = this.editorUtils.stripObject(e);
|
|
297
306
|
this.send({
|
|
298
307
|
event: "removeCamera",
|
|
299
308
|
target: "editor",
|
|
@@ -303,18 +312,18 @@ class A extends b {
|
|
|
303
312
|
handleApp(e) {
|
|
304
313
|
switch (e.event) {
|
|
305
314
|
case "refreshScene":
|
|
306
|
-
this.send({
|
|
315
|
+
this.editorUtils && this.send({
|
|
307
316
|
event: "refreshScene",
|
|
308
317
|
target: "editor",
|
|
309
|
-
data:
|
|
318
|
+
data: this.editorUtils.stripScene(this.scenes.get(e.data.name))
|
|
310
319
|
});
|
|
311
320
|
break;
|
|
312
321
|
case "updateRenderer":
|
|
313
|
-
this.renderer && (this.renderer.autoClearColor = e.data.autoClearColor, this.renderer.outputColorSpace = e.data.outputColorSpace, this.renderer.setClearColor(e.data.clearColor, e.data.clearAlpha), this.renderer.toneMapping = e.data.toneMapping, this.renderer.toneMappingExposure = e.data.toneMappingExposure,
|
|
322
|
+
this.renderer && (this.renderer.autoClearColor = e.data.autoClearColor, this.renderer.outputColorSpace = e.data.outputColorSpace, this.renderer.setClearColor(e.data.clearColor, e.data.clearAlpha), this.renderer.toneMapping = e.data.toneMapping, this.renderer.toneMappingExposure = e.data.toneMappingExposure, p.enabled = e.data.colorManagement);
|
|
314
323
|
break;
|
|
315
324
|
case "requestRenderer":
|
|
316
325
|
if (this.renderer !== void 0) {
|
|
317
|
-
const t = `#${this.renderer.getClearColor(new
|
|
326
|
+
const t = `#${this.renderer.getClearColor(new l()).getHexString()}`;
|
|
318
327
|
this.send({
|
|
319
328
|
event: "addRenderer",
|
|
320
329
|
target: "editor",
|
|
@@ -323,7 +332,7 @@ class A extends b {
|
|
|
323
332
|
outputColorSpace: this.renderer.outputColorSpace,
|
|
324
333
|
clearColor: t,
|
|
325
334
|
clearAlpha: this.renderer.getClearAlpha(),
|
|
326
|
-
colorManagement:
|
|
335
|
+
colorManagement: p.enabled,
|
|
327
336
|
toneMapping: this.renderer.toneMapping,
|
|
328
337
|
toneMappingExposure: this.renderer.toneMappingExposure,
|
|
329
338
|
type: this.renderer.isWebGLRenderer ? "WebGLRenderer" : "WebGPURenderer"
|
|
@@ -332,17 +341,17 @@ class A extends b {
|
|
|
332
341
|
}
|
|
333
342
|
break;
|
|
334
343
|
case "requestScene":
|
|
335
|
-
this.scenes.forEach((t) => {
|
|
336
|
-
|
|
344
|
+
this.editorUtils && (this.scenes.forEach((t) => {
|
|
345
|
+
c(), o(t), this.send({
|
|
337
346
|
event: "addScene",
|
|
338
347
|
target: "editor",
|
|
339
|
-
data:
|
|
348
|
+
data: this.editorUtils.stripScene(t)
|
|
340
349
|
});
|
|
341
|
-
}), this.scene !== void 0 && (this.renderer !== void 0 && (
|
|
350
|
+
}), this.scene !== void 0 && (this.renderer !== void 0 && (h.renderer = this.renderer), c(), o(this.scene), this.send({
|
|
342
351
|
event: "setScene",
|
|
343
352
|
target: "editor",
|
|
344
|
-
data:
|
|
345
|
-
}));
|
|
353
|
+
data: this.editorUtils.stripScene(this.scene)
|
|
354
|
+
})));
|
|
346
355
|
break;
|
|
347
356
|
}
|
|
348
357
|
if (e.event === "updateGroup") {
|
|
@@ -410,21 +419,21 @@ class A extends b {
|
|
|
410
419
|
addRT(e, t = !0, r) {
|
|
411
420
|
if (!this.renderer) return;
|
|
412
421
|
let s;
|
|
413
|
-
this.renderer instanceof
|
|
422
|
+
this.renderer instanceof g ? s = new v(32, 32, r) : s = new f(32, 32, r), s.texture.name = e, this.renderTargets.set(e, s), this.renderTargetsResize.set(e, t);
|
|
414
423
|
}
|
|
415
424
|
removeRT(e) {
|
|
416
425
|
this.renderTargets.delete(e), this.renderTargetsResize.delete(e);
|
|
417
426
|
}
|
|
418
427
|
resize(e, t) {
|
|
419
428
|
const r = this.dpr;
|
|
420
|
-
this.renderTargets.forEach((d,
|
|
421
|
-
this.renderTargetsResize.get(
|
|
429
|
+
this.renderTargets.forEach((d, i) => {
|
|
430
|
+
this.renderTargetsResize.get(i) && d.setSize(e * r, t * r);
|
|
422
431
|
});
|
|
423
432
|
const s = !(this.renderer?.domElement instanceof OffscreenCanvas);
|
|
424
433
|
this.renderer?.setSize(e, t, s);
|
|
425
434
|
}
|
|
426
435
|
set dpr(e) {
|
|
427
|
-
this.renderer?.setPixelRatio(
|
|
436
|
+
this.renderer?.setPixelRatio(S(1, 2, e));
|
|
428
437
|
}
|
|
429
438
|
get dpr() {
|
|
430
439
|
return this.renderer !== void 0 ? this.renderer?.getPixelRatio() : 1;
|
|
@@ -437,6 +446,6 @@ class A extends b {
|
|
|
437
446
|
}
|
|
438
447
|
}
|
|
439
448
|
export {
|
|
440
|
-
|
|
441
|
-
|
|
449
|
+
b as ToolEvents,
|
|
450
|
+
O as default
|
|
442
451
|
};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import o from "./
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { jsxs as r, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as i } from "react";
|
|
3
|
+
import n from "./Editor.js";
|
|
4
|
+
import o from "./multiView/MultiView.js";
|
|
5
|
+
import c from "./sidePanel/SidePanel.js";
|
|
6
|
+
import { textureFromSrc as m, setItemProps as d, getSubItem as s, stripScene as S, stripObject as f } from "./sidePanel/utils.js";
|
|
7
|
+
const h = { stripObject: f, stripScene: S, getSubItem: s, setItemProps: d, textureFromSrc: m };
|
|
8
|
+
function I(e) {
|
|
9
|
+
return i(() => (e.three.setEditorUtils(h), () => e.three.setEditorUtils(void 0)), [e.three]), /* @__PURE__ */ r(n, { children: [
|
|
10
|
+
/* @__PURE__ */ t(
|
|
11
|
+
o,
|
|
9
12
|
{
|
|
10
13
|
three: e.three,
|
|
11
14
|
scenes: e.scenes,
|
|
@@ -14,9 +17,9 @@ function f(e) {
|
|
|
14
17
|
onSceneUpdate: e.onSceneUpdate
|
|
15
18
|
}
|
|
16
19
|
),
|
|
17
|
-
/* @__PURE__ */
|
|
20
|
+
/* @__PURE__ */ t(c, { three: e.three })
|
|
18
21
|
] });
|
|
19
22
|
}
|
|
20
23
|
export {
|
|
21
|
-
|
|
24
|
+
I as default
|
|
22
25
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Texture as
|
|
1
|
+
import { Texture as m, RepeatWrapping as c } from "three";
|
|
2
2
|
import { ExportTexture as f } from "../../utils/three.js";
|
|
3
|
-
function
|
|
3
|
+
function k(e) {
|
|
4
4
|
if (e.name === "cameras")
|
|
5
5
|
return "camera";
|
|
6
6
|
if (e.name === "interactive")
|
|
@@ -14,15 +14,15 @@ function w(e) {
|
|
|
14
14
|
const s = e.type;
|
|
15
15
|
return s.search("Helper") > -1 ? "icon_utils" : s.search("Camera") > -1 ? "camera" : s.search("Light") > -1 ? "light" : "obj3D";
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function p(e) {
|
|
18
18
|
const s = {
|
|
19
19
|
name: e.name,
|
|
20
20
|
type: e.type,
|
|
21
21
|
uuid: e.uuid,
|
|
22
22
|
children: []
|
|
23
23
|
};
|
|
24
|
-
return e.children.forEach((
|
|
25
|
-
s.children.push(
|
|
24
|
+
return e.children.forEach((t) => {
|
|
25
|
+
s.children.push(p(t));
|
|
26
26
|
}), s;
|
|
27
27
|
}
|
|
28
28
|
function u(e) {
|
|
@@ -35,13 +35,13 @@ function u(e) {
|
|
|
35
35
|
const l = { src: "", offset: [0, 0], repeat: [1, 1] };
|
|
36
36
|
function d(e) {
|
|
37
37
|
const s = {};
|
|
38
|
-
for (const
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
const
|
|
42
|
-
|
|
38
|
+
for (const t in e) {
|
|
39
|
+
const r = e[t];
|
|
40
|
+
if (r !== null && typeof r == "object" && Object.prototype.hasOwnProperty.call(r, "value")) {
|
|
41
|
+
const a = r.value;
|
|
42
|
+
a == null ? s[t] = { value: l } : a.isTexture ? s[t] = { value: u(a) } : s[t] = { value: a };
|
|
43
43
|
} else
|
|
44
|
-
|
|
44
|
+
r == null ? s[t] = l : r.isTexture ? s[t] = u(r) : s[t] = r;
|
|
45
45
|
}
|
|
46
46
|
return s;
|
|
47
47
|
}
|
|
@@ -59,32 +59,32 @@ function h(e) {
|
|
|
59
59
|
}
|
|
60
60
|
function o(e) {
|
|
61
61
|
const s = {};
|
|
62
|
-
for (const
|
|
63
|
-
if (
|
|
64
|
-
const
|
|
65
|
-
switch (
|
|
62
|
+
for (const t in e) {
|
|
63
|
+
if (t.substring(0, 1) === "_" || t.substring(0, 2) === "is" || h(t)) continue;
|
|
64
|
+
const r = typeof e[t], n = e[t];
|
|
65
|
+
switch (r) {
|
|
66
66
|
case "boolean":
|
|
67
67
|
case "number":
|
|
68
68
|
case "string":
|
|
69
|
-
s[
|
|
69
|
+
s[t] = n;
|
|
70
70
|
break;
|
|
71
71
|
case "object":
|
|
72
72
|
if (n !== null)
|
|
73
73
|
if (n.isTexture)
|
|
74
|
-
s[
|
|
74
|
+
s[t] = {
|
|
75
75
|
src: f.renderToBlob(n),
|
|
76
76
|
offset: [n.offset.x, n.offset.y],
|
|
77
77
|
repeat: [n.repeat.x, n.repeat.y]
|
|
78
78
|
};
|
|
79
79
|
else if (n.isUniformNode) {
|
|
80
|
-
const
|
|
81
|
-
s[
|
|
80
|
+
const a = n.value;
|
|
81
|
+
s[t] = {
|
|
82
82
|
__isUniform: !0,
|
|
83
|
-
value:
|
|
83
|
+
value: a?.isTexture ? { src: f.renderToBlob(a), offset: [a.offset.x, a.offset.y], repeat: [a.repeat.x, a.repeat.y] } : a
|
|
84
84
|
};
|
|
85
|
-
} else
|
|
85
|
+
} else t === "uniforms" ? s[t] = d(n) : t.search("Node") > -1 || (s[t] = n);
|
|
86
86
|
else
|
|
87
|
-
|
|
87
|
+
t === "glslVersion" ? s[t] = "" : t.search("Node") > -1 || (s[t] = {
|
|
88
88
|
src: "",
|
|
89
89
|
offset: [0, 0],
|
|
90
90
|
repeat: [1, 1]
|
|
@@ -94,7 +94,11 @@ function o(e) {
|
|
|
94
94
|
}
|
|
95
95
|
return e.anisotropy !== void 0 && (s.anisotropy = e.anisotropy), e.clearcoat !== void 0 && (s.clearcoat = e.clearcoat), e.iridescence !== void 0 && (s.iridescence = e.iridescence), e.dispersion !== void 0 && (s.dispersion = e.dispersion), e.sheen !== void 0 && (s.sheen = e.sheen), e.transmission !== void 0 && (s.transmission = e.transmission), e.transmission !== void 0 && (s.transmission = e.transmission), s;
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function C(e) {
|
|
98
|
+
const s = document.createElement("canvas"), t = s.getContext("2d");
|
|
99
|
+
return s.width = e.width, s.height = e.height, t.drawImage(e, 0, 0), s.toDataURL("image/png");
|
|
100
|
+
}
|
|
101
|
+
function g(e) {
|
|
98
102
|
e.updateMatrix();
|
|
99
103
|
const s = {
|
|
100
104
|
name: e.name,
|
|
@@ -109,42 +113,42 @@ function x(e) {
|
|
|
109
113
|
lightInfo: void 0,
|
|
110
114
|
children: []
|
|
111
115
|
};
|
|
112
|
-
e.animations.forEach((
|
|
116
|
+
e.animations.forEach((r) => {
|
|
113
117
|
s.animations.push({
|
|
114
|
-
name:
|
|
115
|
-
duration:
|
|
116
|
-
blendMode:
|
|
118
|
+
name: r.name,
|
|
119
|
+
duration: r.duration,
|
|
120
|
+
blendMode: r.blendMode
|
|
117
121
|
});
|
|
118
122
|
});
|
|
119
|
-
const
|
|
120
|
-
if (
|
|
121
|
-
const
|
|
122
|
-
if (Array.isArray(
|
|
123
|
+
const t = e.type.toLowerCase();
|
|
124
|
+
if (t.search("mesh") > -1) {
|
|
125
|
+
const r = e;
|
|
126
|
+
if (Array.isArray(r.material)) {
|
|
123
127
|
const n = [];
|
|
124
|
-
|
|
125
|
-
n.push(o(
|
|
128
|
+
r.material.forEach((a) => {
|
|
129
|
+
n.push(o(a));
|
|
126
130
|
}), s.material = n;
|
|
127
131
|
} else
|
|
128
|
-
s.material = o(
|
|
129
|
-
} else if (
|
|
130
|
-
const
|
|
131
|
-
if (Array.isArray(
|
|
132
|
+
s.material = o(r.material);
|
|
133
|
+
} else if (t.search("points") > -1) {
|
|
134
|
+
const r = e;
|
|
135
|
+
if (Array.isArray(r.material)) {
|
|
132
136
|
const n = [];
|
|
133
|
-
|
|
134
|
-
n.push(o(
|
|
137
|
+
r.material.forEach((a) => {
|
|
138
|
+
n.push(o(a));
|
|
135
139
|
}), s.material = n;
|
|
136
140
|
} else
|
|
137
|
-
s.material = o(
|
|
138
|
-
} else if (
|
|
139
|
-
const
|
|
140
|
-
if (Array.isArray(
|
|
141
|
+
s.material = o(r.material);
|
|
142
|
+
} else if (t.search("line") > -1) {
|
|
143
|
+
const r = e;
|
|
144
|
+
if (Array.isArray(r.material)) {
|
|
141
145
|
const n = [];
|
|
142
|
-
|
|
143
|
-
n.push(o(
|
|
146
|
+
r.material.forEach((a) => {
|
|
147
|
+
n.push(o(a));
|
|
144
148
|
}), s.material = n;
|
|
145
149
|
} else
|
|
146
|
-
s.material = o(
|
|
147
|
-
} else
|
|
150
|
+
s.material = o(r.material);
|
|
151
|
+
} else t.search("camera") > -1 ? e.type === "PerspectiveCamera" ? s.perspectiveCameraInfo = {
|
|
148
152
|
fov: e.fov,
|
|
149
153
|
zoom: e.zoom,
|
|
150
154
|
near: e.near,
|
|
@@ -161,7 +165,7 @@ function x(e) {
|
|
|
161
165
|
right: e.right,
|
|
162
166
|
top: e.top,
|
|
163
167
|
bottom: e.bottom
|
|
164
|
-
}) :
|
|
168
|
+
}) : t.search("light") > -1 && (s.lightInfo = {
|
|
165
169
|
color: e.color,
|
|
166
170
|
intensity: e.intensity,
|
|
167
171
|
decay: e.decay,
|
|
@@ -174,86 +178,89 @@ function x(e) {
|
|
|
174
178
|
});
|
|
175
179
|
return s;
|
|
176
180
|
}
|
|
177
|
-
function
|
|
178
|
-
const
|
|
179
|
-
switch (
|
|
181
|
+
function y(e, s) {
|
|
182
|
+
const t = s.split(".");
|
|
183
|
+
switch (t.length) {
|
|
180
184
|
case 1:
|
|
181
|
-
return e[
|
|
185
|
+
return e[t[0]];
|
|
182
186
|
case 2:
|
|
183
|
-
return e[
|
|
187
|
+
return e[t[0]][t[1]];
|
|
184
188
|
case 3:
|
|
185
|
-
return e[
|
|
189
|
+
return e[t[0]][t[1]][t[2]];
|
|
186
190
|
case 4:
|
|
187
|
-
return e[
|
|
191
|
+
return e[t[0]][t[1]][t[2]][t[3]];
|
|
188
192
|
case 5:
|
|
189
|
-
return e[
|
|
193
|
+
return e[t[0]][t[1]][t[2]][t[3]][t[4]];
|
|
190
194
|
case 6:
|
|
191
|
-
return e[
|
|
195
|
+
return e[t[0]][t[1]][t[2]][t[3]][t[4]][t[5]];
|
|
192
196
|
}
|
|
193
197
|
}
|
|
194
|
-
function
|
|
195
|
-
for (const
|
|
198
|
+
function v(e, s) {
|
|
199
|
+
for (const t in s) e[t] = s[t];
|
|
196
200
|
}
|
|
197
|
-
function
|
|
201
|
+
function w(e, s, t) {
|
|
198
202
|
if (e === void 0) {
|
|
199
|
-
console.log(`Hermes - Can't set props: ${s}`,
|
|
203
|
+
console.log(`Hermes - Can't set props: ${s}`, t);
|
|
200
204
|
return;
|
|
201
205
|
}
|
|
202
|
-
const
|
|
203
|
-
if (typeof
|
|
206
|
+
const r = s.split("."), n = r.length;
|
|
207
|
+
if (typeof t != "object")
|
|
204
208
|
switch (n) {
|
|
205
209
|
case 1:
|
|
206
|
-
e[
|
|
210
|
+
e[r[0]] = t;
|
|
207
211
|
break;
|
|
208
212
|
case 2:
|
|
209
|
-
e[
|
|
213
|
+
e[r[0]][r[1]] = t;
|
|
210
214
|
break;
|
|
211
215
|
case 3:
|
|
212
|
-
e[
|
|
216
|
+
e[r[0]][r[1]][r[2]] = t;
|
|
213
217
|
break;
|
|
214
218
|
case 4:
|
|
215
|
-
e[
|
|
219
|
+
e[r[0]][r[1]][r[2]][r[3]] = t;
|
|
216
220
|
break;
|
|
217
221
|
case 5:
|
|
218
|
-
e[
|
|
222
|
+
e[r[0]][r[1]][r[2]][r[3]][r[4]] = t;
|
|
219
223
|
break;
|
|
220
224
|
}
|
|
221
225
|
else {
|
|
222
|
-
let
|
|
226
|
+
let i;
|
|
223
227
|
switch (n) {
|
|
224
228
|
case 1:
|
|
225
|
-
|
|
229
|
+
i = e[r[0]];
|
|
226
230
|
break;
|
|
227
231
|
case 2:
|
|
228
|
-
|
|
232
|
+
i = e[r[0]][r[1]];
|
|
229
233
|
break;
|
|
230
234
|
case 3:
|
|
231
|
-
|
|
235
|
+
i = e[r[0]][r[1]][r[2]];
|
|
232
236
|
break;
|
|
233
237
|
case 4:
|
|
234
|
-
|
|
238
|
+
i = e[r[0]][r[1]][r[2]][r[3]];
|
|
235
239
|
break;
|
|
236
240
|
case 5:
|
|
237
|
-
|
|
241
|
+
i = e[r[0]][r[1]][r[2]][r[3]][r[4]];
|
|
238
242
|
break;
|
|
239
243
|
}
|
|
240
|
-
|
|
244
|
+
i != null ? v(i, t) : console.log(`Hermes - Can't set props because target isn't found: ${s}`, t);
|
|
241
245
|
}
|
|
242
246
|
}
|
|
243
|
-
function
|
|
244
|
-
return new Promise((s,
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
const n = new
|
|
247
|
+
function x(e) {
|
|
248
|
+
return new Promise((s, t) => {
|
|
249
|
+
const r = new Image();
|
|
250
|
+
r.onload = () => {
|
|
251
|
+
const n = new m(r);
|
|
248
252
|
n.wrapS = c, n.wrapT = c, n.needsUpdate = !0, s(n);
|
|
249
|
-
},
|
|
253
|
+
}, r.onerror = t, r.src = e;
|
|
250
254
|
});
|
|
251
255
|
}
|
|
256
|
+
const E = { stripObject: g, stripScene: p, getSubItem: y, setItemProps: w, textureFromSrc: x };
|
|
252
257
|
export {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
k as
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
258
|
+
E as EDITOR_UTILS,
|
|
259
|
+
C as convertImageToBase64,
|
|
260
|
+
k as determineIcon,
|
|
261
|
+
y as getSubItem,
|
|
262
|
+
w as setItemProps,
|
|
263
|
+
g as stripObject,
|
|
264
|
+
p as stripScene,
|
|
265
|
+
x as textureFromSrc
|
|
259
266
|
};
|