@tomorrowevening/hermes 0.1.41 → 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-jkqfXLb4.js → ThreeEditor-B4bS88iZ.js} +16 -16
- package/dist/editor/sidePanel/utils.js +94 -87
- package/dist/hermes.cjs.js +8 -8
- package/dist/{index-DZmiM5y-.js → index-XMQFdKEt.js} +615 -615
- package/dist/index.html +1 -1
- package/dist/index.js +129 -120
- package/package.json +1 -1
- package/types/editor/sidePanel/utils.d.ts +7 -0
- package/types/index.d.ts +1 -0
|
@@ -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
|
};
|