@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.
@@ -1,6 +1,6 @@
1
- import { Texture as p, RepeatWrapping as c } from "three";
1
+ import { Texture as m, RepeatWrapping as c } from "three";
2
2
  import { ExportTexture as f } from "../../utils/three.js";
3
- function w(e) {
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 m(e) {
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((r) => {
25
- s.children.push(m(r));
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 r in e) {
39
- const t = e[r];
40
- if (t !== null && typeof t == "object" && Object.prototype.hasOwnProperty.call(t, "value")) {
41
- const i = t.value;
42
- i == null ? s[r] = { value: l } : i.isTexture ? s[r] = { value: u(i) } : s[r] = { value: i };
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
- t == null ? s[r] = l : t.isTexture ? s[r] = u(t) : s[r] = t;
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 r in e) {
63
- if (r.substring(0, 1) === "_" || r.substring(0, 2) === "is" || h(r)) continue;
64
- const t = typeof e[r], n = e[r];
65
- switch (t) {
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[r] = n;
69
+ s[t] = n;
70
70
  break;
71
71
  case "object":
72
72
  if (n !== null)
73
73
  if (n.isTexture)
74
- s[r] = {
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 i = n.value;
81
- s[r] = {
80
+ const a = n.value;
81
+ s[t] = {
82
82
  __isUniform: !0,
83
- value: i?.isTexture ? { src: f.renderToBlob(i), offset: [i.offset.x, i.offset.y], repeat: [i.repeat.x, i.repeat.y] } : i
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 r === "uniforms" ? s[r] = d(n) : r.search("Node") > -1 || (s[r] = n);
85
+ } else t === "uniforms" ? s[t] = d(n) : t.search("Node") > -1 || (s[t] = n);
86
86
  else
87
- r === "glslVersion" ? s[r] = "" : r.search("Node") > -1 || (s[r] = {
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 x(e) {
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((t) => {
116
+ e.animations.forEach((r) => {
113
117
  s.animations.push({
114
- name: t.name,
115
- duration: t.duration,
116
- blendMode: t.blendMode
118
+ name: r.name,
119
+ duration: r.duration,
120
+ blendMode: r.blendMode
117
121
  });
118
122
  });
119
- const r = e.type.toLowerCase();
120
- if (r.search("mesh") > -1) {
121
- const t = e;
122
- if (Array.isArray(t.material)) {
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
- t.material.forEach((i) => {
125
- n.push(o(i));
128
+ r.material.forEach((a) => {
129
+ n.push(o(a));
126
130
  }), s.material = n;
127
131
  } else
128
- s.material = o(t.material);
129
- } else if (r.search("points") > -1) {
130
- const t = e;
131
- if (Array.isArray(t.material)) {
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
- t.material.forEach((i) => {
134
- n.push(o(i));
137
+ r.material.forEach((a) => {
138
+ n.push(o(a));
135
139
  }), s.material = n;
136
140
  } else
137
- s.material = o(t.material);
138
- } else if (r.search("line") > -1) {
139
- const t = e;
140
- if (Array.isArray(t.material)) {
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
- t.material.forEach((i) => {
143
- n.push(o(i));
146
+ r.material.forEach((a) => {
147
+ n.push(o(a));
144
148
  }), s.material = n;
145
149
  } else
146
- s.material = o(t.material);
147
- } else r.search("camera") > -1 ? e.type === "PerspectiveCamera" ? s.perspectiveCameraInfo = {
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
- }) : r.search("light") > -1 && (s.lightInfo = {
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 T(e, s) {
178
- const r = s.split(".");
179
- switch (r.length) {
181
+ function y(e, s) {
182
+ const t = s.split(".");
183
+ switch (t.length) {
180
184
  case 1:
181
- return e[r[0]];
185
+ return e[t[0]];
182
186
  case 2:
183
- return e[r[0]][r[1]];
187
+ return e[t[0]][t[1]];
184
188
  case 3:
185
- return e[r[0]][r[1]][r[2]];
189
+ return e[t[0]][t[1]][t[2]];
186
190
  case 4:
187
- return e[r[0]][r[1]][r[2]][r[3]];
191
+ return e[t[0]][t[1]][t[2]][t[3]];
188
192
  case 5:
189
- return e[r[0]][r[1]][r[2]][r[3]][r[4]];
193
+ return e[t[0]][t[1]][t[2]][t[3]][t[4]];
190
194
  case 6:
191
- return e[r[0]][r[1]][r[2]][r[3]][r[4]][r[5]];
195
+ return e[t[0]][t[1]][t[2]][t[3]][t[4]][t[5]];
192
196
  }
193
197
  }
194
- function y(e, s) {
195
- for (const r in s) e[r] = s[r];
198
+ function v(e, s) {
199
+ for (const t in s) e[t] = s[t];
196
200
  }
197
- function k(e, s, r) {
201
+ function w(e, s, t) {
198
202
  if (e === void 0) {
199
- console.log(`Hermes - Can't set props: ${s}`, r);
203
+ console.log(`Hermes - Can't set props: ${s}`, t);
200
204
  return;
201
205
  }
202
- const t = s.split("."), n = t.length;
203
- if (typeof r != "object")
206
+ const r = s.split("."), n = r.length;
207
+ if (typeof t != "object")
204
208
  switch (n) {
205
209
  case 1:
206
- e[t[0]] = r;
210
+ e[r[0]] = t;
207
211
  break;
208
212
  case 2:
209
- e[t[0]][t[1]] = r;
213
+ e[r[0]][r[1]] = t;
210
214
  break;
211
215
  case 3:
212
- e[t[0]][t[1]][t[2]] = r;
216
+ e[r[0]][r[1]][r[2]] = t;
213
217
  break;
214
218
  case 4:
215
- e[t[0]][t[1]][t[2]][t[3]] = r;
219
+ e[r[0]][r[1]][r[2]][r[3]] = t;
216
220
  break;
217
221
  case 5:
218
- e[t[0]][t[1]][t[2]][t[3]][t[4]] = r;
222
+ e[r[0]][r[1]][r[2]][r[3]][r[4]] = t;
219
223
  break;
220
224
  }
221
225
  else {
222
- let a;
226
+ let i;
223
227
  switch (n) {
224
228
  case 1:
225
- a = e[t[0]];
229
+ i = e[r[0]];
226
230
  break;
227
231
  case 2:
228
- a = e[t[0]][t[1]];
232
+ i = e[r[0]][r[1]];
229
233
  break;
230
234
  case 3:
231
- a = e[t[0]][t[1]][t[2]];
235
+ i = e[r[0]][r[1]][r[2]];
232
236
  break;
233
237
  case 4:
234
- a = e[t[0]][t[1]][t[2]][t[3]];
238
+ i = e[r[0]][r[1]][r[2]][r[3]];
235
239
  break;
236
240
  case 5:
237
- a = e[t[0]][t[1]][t[2]][t[3]][t[4]];
241
+ i = e[r[0]][r[1]][r[2]][r[3]][r[4]];
238
242
  break;
239
243
  }
240
- a != null ? y(a, r) : console.log(`Hermes - Can't set props because target isn't found: ${s}`, r);
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 C(e) {
244
- return new Promise((s, r) => {
245
- const t = new Image();
246
- t.onload = () => {
247
- const n = new p(t);
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
- }, t.onerror = r, t.src = e;
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
- w as determineIcon,
254
- T as getSubItem,
255
- k as setItemProps,
256
- x as stripObject,
257
- m as stripScene,
258
- C as textureFromSrc
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
  };