@tomorrowevening/hermes 0.1.39 → 0.1.41
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-CTkjs-SY.js → ThreeEditor-jkqfXLb4.js} +16 -16
- package/dist/core/Application.js +77 -0
- package/dist/core/remote/BaseRemote.js +33 -0
- package/dist/core/remote/RemoteTheatre.js +253 -0
- package/dist/core/remote/RemoteThree.js +451 -0
- package/dist/core/types.js +7 -0
- package/dist/editor/Editor.js +12 -0
- package/dist/editor/HermesApp.js +24 -0
- package/dist/editor/ThreeEditor.js +25 -0
- package/dist/editor/components/Draggable.js +40 -0
- package/dist/editor/components/DraggableItem.js +25 -0
- package/dist/editor/components/Dropdown.js +32 -0
- package/dist/editor/components/DropdownItem.js +50 -0
- package/dist/editor/components/NavButton.js +7 -0
- package/dist/editor/components/content.js +4 -0
- package/dist/editor/components/icons/CloseIcon.js +9 -0
- package/dist/editor/components/icons/DragIcon.js +12 -0
- package/dist/editor/multiView/CameraWindow.js +64 -0
- package/dist/editor/multiView/DepthNodeMaterial.js +12 -0
- package/dist/editor/multiView/InfiniteGridHelper.js +31 -0
- package/dist/editor/multiView/InfiniteGridHelperGPU.js +31 -0
- package/dist/editor/multiView/InfiniteGridMaterial.js +137 -0
- package/dist/editor/multiView/InfiniteGridNodeMaterial.js +63 -0
- package/dist/editor/multiView/MultiView.js +890 -0
- package/dist/editor/multiView/Toggle.js +25 -0
- package/dist/editor/multiView/UVMaterial.js +60 -0
- package/dist/editor/multiView/UVNodeMaterial.js +10 -0
- package/dist/editor/sidePanel/Accordion.js +56 -0
- package/dist/editor/sidePanel/ChildObject.js +78 -0
- package/dist/editor/sidePanel/ContainerObject.js +11 -0
- package/dist/editor/sidePanel/DebugData.js +133 -0
- package/dist/editor/sidePanel/SidePanel.js +91 -0
- package/dist/editor/sidePanel/inspector/InspectGrid3.js +82 -0
- package/dist/editor/sidePanel/inspector/InspectGrid4.js +58 -0
- package/dist/editor/sidePanel/inspector/InspectImage.js +100 -0
- package/dist/editor/sidePanel/inspector/InspectNumber.js +76 -0
- package/dist/editor/sidePanel/inspector/InspectVector2.js +154 -0
- package/dist/editor/sidePanel/inspector/Inspector.js +95 -0
- package/dist/editor/sidePanel/inspector/InspectorField.js +128 -0
- package/dist/editor/sidePanel/inspector/InspectorGroup.js +110 -0
- package/dist/editor/sidePanel/inspector/utils/DragNumber.js +27 -0
- package/dist/editor/sidePanel/inspector/utils/InspectAnimation.js +99 -0
- package/dist/editor/sidePanel/inspector/utils/InspectCamera.js +91 -0
- package/dist/editor/sidePanel/inspector/utils/InspectLight.js +85 -0
- package/dist/editor/sidePanel/inspector/utils/InspectMaterial.js +861 -0
- package/dist/editor/sidePanel/inspector/utils/InspectTransform.js +93 -0
- package/dist/editor/sidePanel/utils.js +259 -0
- package/dist/editor/tools/Transform.js +77 -0
- package/dist/editor/tools/splineEditor/Spline.js +348 -0
- package/dist/editor/tools/splineEditor/index.js +193 -0
- package/dist/editor/utils.js +27 -0
- package/dist/hermes.cjs.js +8 -30
- package/dist/{index-BpKOzCuX.js → index-DZmiM5y-.js} +617 -617
- package/dist/index.html +1 -1
- package/dist/index.js +125 -0
- package/dist/utils/ImageSequenceCapturer.js +148 -0
- package/dist/utils/detectSettings.js +46 -0
- package/dist/utils/math.js +68 -0
- package/dist/utils/post.js +206 -0
- package/dist/utils/theatre.js +316 -0
- package/dist/utils/three.js +199 -0
- package/dist/webworkers/EventHandling.js +115 -0
- package/dist/webworkers/ProxyManager.js +76 -0
- package/package.json +13 -7
- package/types/core/remote/RemoteThree.d.ts +10 -1
- package/dist/.vite/manifest.json +0 -12
- package/dist/hermes.es.js +0 -8077
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { types as n } from "@tomorrowevening/theatre-core";
|
|
2
|
+
import { useState as d, useEffect as p } from "react";
|
|
3
|
+
let m;
|
|
4
|
+
function v() {
|
|
5
|
+
const [i, s] = d(m);
|
|
6
|
+
return p(() => {
|
|
7
|
+
m || import("@tomorrowevening/theatre-studio").then((e) => {
|
|
8
|
+
m = e.default, m.initialize(), m.ui.hide(), s(m);
|
|
9
|
+
});
|
|
10
|
+
}, []), i;
|
|
11
|
+
}
|
|
12
|
+
async function E() {
|
|
13
|
+
for (; !document.getElementById("theatrejs-studio-root"); )
|
|
14
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
15
|
+
const i = document.getElementById("theatrejs-studio-root");
|
|
16
|
+
if (i === null || i.shadowRoot === null) return;
|
|
17
|
+
const s = i.shadowRoot.getElementById("pointer-root");
|
|
18
|
+
if (s === null) return;
|
|
19
|
+
const e = s.children[0];
|
|
20
|
+
if (e !== null) {
|
|
21
|
+
try {
|
|
22
|
+
const t = e.children[1].children[1];
|
|
23
|
+
t.parentElement?.removeChild(t);
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const r = e.children[3];
|
|
28
|
+
r.style.top = "0", r.style.right = "300px";
|
|
29
|
+
} catch {
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function O(i, s, e, r) {
|
|
34
|
+
r.sheetObject(i, s, {
|
|
35
|
+
transform: {
|
|
36
|
+
position: {
|
|
37
|
+
x: e.position.x,
|
|
38
|
+
y: e.position.y,
|
|
39
|
+
z: e.position.z
|
|
40
|
+
},
|
|
41
|
+
rotation: {
|
|
42
|
+
x: e.rotation.x,
|
|
43
|
+
y: e.rotation.y,
|
|
44
|
+
z: e.rotation.z
|
|
45
|
+
},
|
|
46
|
+
scale: {
|
|
47
|
+
x: e.scale.x,
|
|
48
|
+
y: e.scale.y,
|
|
49
|
+
z: e.scale.z
|
|
50
|
+
},
|
|
51
|
+
visible: e.visible
|
|
52
|
+
}
|
|
53
|
+
}, (t) => {
|
|
54
|
+
const o = t.transform;
|
|
55
|
+
e.position.copy(o.position), e.rotation.copy(o.rotation), e.scale.copy(o.scale), e.visible = o.visible;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const h = [
|
|
59
|
+
"allowOverride",
|
|
60
|
+
"alphaHash",
|
|
61
|
+
"alphaTest",
|
|
62
|
+
"alphaToCoverage",
|
|
63
|
+
"blendAlpha",
|
|
64
|
+
"blendColor",
|
|
65
|
+
"blendDst",
|
|
66
|
+
"blendDstAlpha",
|
|
67
|
+
"blendEquation",
|
|
68
|
+
"blendEquationAlpha",
|
|
69
|
+
"blendSrc",
|
|
70
|
+
"blendSrcAlpha",
|
|
71
|
+
"blending",
|
|
72
|
+
"clipIntersection",
|
|
73
|
+
"clipShadows",
|
|
74
|
+
"clipping",
|
|
75
|
+
"clippingPlanes",
|
|
76
|
+
"colorWrite",
|
|
77
|
+
"combine",
|
|
78
|
+
"defaultAttributeValues",
|
|
79
|
+
"defines",
|
|
80
|
+
"depthFunc",
|
|
81
|
+
"depthTest",
|
|
82
|
+
"depthWrite",
|
|
83
|
+
"dithering",
|
|
84
|
+
"extensions",
|
|
85
|
+
"fog",
|
|
86
|
+
"forceSinglePass",
|
|
87
|
+
"fragmentShader",
|
|
88
|
+
"glslVersion",
|
|
89
|
+
"id",
|
|
90
|
+
"index0AttributeName",
|
|
91
|
+
"index1AttributeName",
|
|
92
|
+
"index2AttributeName",
|
|
93
|
+
"index3AttributeName",
|
|
94
|
+
"index4AttributeName",
|
|
95
|
+
"isMaterial",
|
|
96
|
+
"lights",
|
|
97
|
+
"linewidth",
|
|
98
|
+
"name",
|
|
99
|
+
"needsUpdate",
|
|
100
|
+
"polygonOffset",
|
|
101
|
+
"polygonOffsetFactor",
|
|
102
|
+
"polygonOffsetUnits",
|
|
103
|
+
"precision",
|
|
104
|
+
"premultipliedAlpha",
|
|
105
|
+
"shadowSide",
|
|
106
|
+
"side",
|
|
107
|
+
"stencilFail",
|
|
108
|
+
"stencilFunc",
|
|
109
|
+
"stencilFuncMask",
|
|
110
|
+
"stencilRef",
|
|
111
|
+
"stencilWrite",
|
|
112
|
+
"stencilWriteMask",
|
|
113
|
+
"stencilZFail",
|
|
114
|
+
"stencilZPass",
|
|
115
|
+
"toneMapped",
|
|
116
|
+
"transparent",
|
|
117
|
+
"type",
|
|
118
|
+
"uniformsGroups",
|
|
119
|
+
"uniformsNeedUpdate",
|
|
120
|
+
"userData",
|
|
121
|
+
"uuid",
|
|
122
|
+
"version",
|
|
123
|
+
"vertexColors",
|
|
124
|
+
"vertexShader",
|
|
125
|
+
"visible",
|
|
126
|
+
"wireframe",
|
|
127
|
+
"wireframeLinewidth",
|
|
128
|
+
"wireframeLinecap",
|
|
129
|
+
"wireframeLinejoin"
|
|
130
|
+
];
|
|
131
|
+
function f(i) {
|
|
132
|
+
const s = typeof i;
|
|
133
|
+
if (i === null || i.isTexture)
|
|
134
|
+
return "texture";
|
|
135
|
+
if (s === "boolean")
|
|
136
|
+
return "boolean";
|
|
137
|
+
if (s === "number")
|
|
138
|
+
return "number";
|
|
139
|
+
if (s === "string")
|
|
140
|
+
return "string";
|
|
141
|
+
if (s === "object") {
|
|
142
|
+
if (i.isColor)
|
|
143
|
+
return "color";
|
|
144
|
+
if (i.isVector2)
|
|
145
|
+
return "vector2";
|
|
146
|
+
if (i.isVector3)
|
|
147
|
+
return "vector3";
|
|
148
|
+
if (i.isVector4)
|
|
149
|
+
return "vector4";
|
|
150
|
+
if (i.isMatrix2)
|
|
151
|
+
return "matrix2";
|
|
152
|
+
if (i.isMatrix3)
|
|
153
|
+
return "matrix3";
|
|
154
|
+
if (i.isMatrix4)
|
|
155
|
+
return "matrix4";
|
|
156
|
+
if (i.isEuler)
|
|
157
|
+
return "euler";
|
|
158
|
+
if (Array.isArray(i))
|
|
159
|
+
return "array";
|
|
160
|
+
}
|
|
161
|
+
return "object";
|
|
162
|
+
}
|
|
163
|
+
function y(i) {
|
|
164
|
+
const s = [];
|
|
165
|
+
for (const r in i) {
|
|
166
|
+
const t = h.find((a) => a === r), o = r.indexOf("_") === 0 || r.indexOf("is") === 0;
|
|
167
|
+
if (!(t || o))
|
|
168
|
+
if (r === "uniforms") {
|
|
169
|
+
const a = i.uniforms;
|
|
170
|
+
for (const c in a) {
|
|
171
|
+
const b = a[c].value, u = f(b);
|
|
172
|
+
u === "array" || u === "object" || s.push({
|
|
173
|
+
name: `uniforms.${c}.value`,
|
|
174
|
+
type: u,
|
|
175
|
+
value: b
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
} else {
|
|
179
|
+
const a = f(i[r]);
|
|
180
|
+
s.push({
|
|
181
|
+
name: r,
|
|
182
|
+
type: a,
|
|
183
|
+
value: i[r]
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return s.filter(
|
|
188
|
+
(r) => r.type !== "array" && r.type !== "object" && r.type !== "texture"
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
function x(i) {
|
|
192
|
+
const s = {}, e = { nudgeMultiplier: 0.01 };
|
|
193
|
+
return i.forEach((r) => {
|
|
194
|
+
let t = r.value;
|
|
195
|
+
switch (r.type) {
|
|
196
|
+
case "color":
|
|
197
|
+
t = n.rgba({ r: t.r, g: t.g, b: t.b, a: 1 });
|
|
198
|
+
break;
|
|
199
|
+
case "number":
|
|
200
|
+
t = n.number(t, e);
|
|
201
|
+
break;
|
|
202
|
+
case "euler":
|
|
203
|
+
case "vector3":
|
|
204
|
+
t = {
|
|
205
|
+
x: n.number(t.x, e),
|
|
206
|
+
y: n.number(t.y, e),
|
|
207
|
+
z: n.number(t.z, e)
|
|
208
|
+
};
|
|
209
|
+
break;
|
|
210
|
+
case "vector2":
|
|
211
|
+
t = {
|
|
212
|
+
x: n.number(t.x, e),
|
|
213
|
+
y: n.number(t.y, e)
|
|
214
|
+
};
|
|
215
|
+
break;
|
|
216
|
+
case "vector4":
|
|
217
|
+
t = {
|
|
218
|
+
x: n.number(t.x, e),
|
|
219
|
+
y: n.number(t.y, e),
|
|
220
|
+
z: n.number(t.z, e),
|
|
221
|
+
w: n.number(t.w, e)
|
|
222
|
+
};
|
|
223
|
+
break;
|
|
224
|
+
case "matrix2":
|
|
225
|
+
t = {
|
|
226
|
+
0: n.number(t.elements[0], e),
|
|
227
|
+
1: n.number(t.elements[1], e),
|
|
228
|
+
2: n.number(t.elements[2], e),
|
|
229
|
+
3: n.number(t.elements[3], e)
|
|
230
|
+
};
|
|
231
|
+
break;
|
|
232
|
+
case "matrix3":
|
|
233
|
+
t = {
|
|
234
|
+
0: n.number(t.elements[0], e),
|
|
235
|
+
1: n.number(t.elements[1], e),
|
|
236
|
+
2: n.number(t.elements[2], e),
|
|
237
|
+
3: n.number(t.elements[3], e),
|
|
238
|
+
4: n.number(t.elements[4], e),
|
|
239
|
+
5: n.number(t.elements[5], e),
|
|
240
|
+
6: n.number(t.elements[6], e),
|
|
241
|
+
7: n.number(t.elements[7], e),
|
|
242
|
+
8: n.number(t.elements[8], e)
|
|
243
|
+
};
|
|
244
|
+
break;
|
|
245
|
+
case "matrix4":
|
|
246
|
+
t = {
|
|
247
|
+
0: n.number(t.elements[0], e),
|
|
248
|
+
1: n.number(t.elements[1], e),
|
|
249
|
+
2: n.number(t.elements[2], e),
|
|
250
|
+
3: n.number(t.elements[3], e),
|
|
251
|
+
4: n.number(t.elements[4], e),
|
|
252
|
+
5: n.number(t.elements[5], e),
|
|
253
|
+
6: n.number(t.elements[6], e),
|
|
254
|
+
7: n.number(t.elements[7], e),
|
|
255
|
+
8: n.number(t.elements[8], e),
|
|
256
|
+
9: n.number(t.elements[9], e),
|
|
257
|
+
10: n.number(t.elements[10], e),
|
|
258
|
+
11: n.number(t.elements[11], e),
|
|
259
|
+
12: n.number(t.elements[12], e),
|
|
260
|
+
13: n.number(t.elements[13], e),
|
|
261
|
+
14: n.number(t.elements[14], e),
|
|
262
|
+
15: n.number(t.elements[15], e)
|
|
263
|
+
};
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
if (r.name.includes(".")) {
|
|
267
|
+
const o = r.name.split(".");
|
|
268
|
+
let l = s;
|
|
269
|
+
for (let a = 0; a < o.length - 1; a++) {
|
|
270
|
+
const c = o[a];
|
|
271
|
+
l[c] || (l[c] = {}), l = l[c];
|
|
272
|
+
}
|
|
273
|
+
l[o[o.length - 1]] = t;
|
|
274
|
+
} else
|
|
275
|
+
s[r.name] = t;
|
|
276
|
+
}), s;
|
|
277
|
+
}
|
|
278
|
+
function g(i, s, e) {
|
|
279
|
+
s.forEach((r) => {
|
|
280
|
+
if (i[r.name] !== void 0)
|
|
281
|
+
switch (r.type) {
|
|
282
|
+
case "boolean":
|
|
283
|
+
case "number":
|
|
284
|
+
i[r.name] = e.material[r.name];
|
|
285
|
+
break;
|
|
286
|
+
case "color":
|
|
287
|
+
case "euler":
|
|
288
|
+
case "matrix2":
|
|
289
|
+
case "matrix3":
|
|
290
|
+
case "matrix4":
|
|
291
|
+
case "vector2":
|
|
292
|
+
case "vector3":
|
|
293
|
+
case "vector4":
|
|
294
|
+
i[r.name].copy(e.material[r.name]);
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
function M(i, s, e, r) {
|
|
300
|
+
if (!e.isMaterial) return;
|
|
301
|
+
const t = y(e), o = x(t);
|
|
302
|
+
r.sheetObject(i, s, {
|
|
303
|
+
material: o
|
|
304
|
+
}, (l) => {
|
|
305
|
+
g(e, t, l);
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
export {
|
|
309
|
+
M as animateObjectMaterial,
|
|
310
|
+
O as animateObjectTransform,
|
|
311
|
+
g as applyObjectMaterial,
|
|
312
|
+
E as customizeTheatreElements,
|
|
313
|
+
x as getObjectMaterialObject,
|
|
314
|
+
y as getObjectMaterialProps,
|
|
315
|
+
v as useStudio
|
|
316
|
+
};
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { BufferGeometry as M, OrthographicCamera as y, Texture as g, Scene as T, MeshBasicMaterial as O, Float32BufferAttribute as l, Mesh as B, LinearSRGBColorSpace as m, ObjectLoader as R, AnimationMixer as D, AnimationClip as W, Matrix4 as Z, AlwaysStencilFunc as v, ReplaceStencilOp as o, NotEqualStencilFunc as A, EqualStencilFunc as w, KeepStencilOp as c, NormalBlending as q, AddEquation as u, SrcAlphaFactor as F, OneMinusSrcAlphaFactor as b, CustomBlending as f, OneFactor as x, DstColorFactor as P, OneMinusDstColorFactor as U } from "three";
|
|
2
|
+
const h = new M();
|
|
3
|
+
h.setAttribute("position", new l([-0.5, -0.5, 0, 1.5, -0.5, 0, -0.5, 1.5, 0], 3));
|
|
4
|
+
h.setAttribute("normal", new l([0, 0, 1, 0, 0, 1], 3));
|
|
5
|
+
h.setAttribute("uv", new l([0, 0, 2, 0, 0, 2], 2));
|
|
6
|
+
const I = new y(-0.5, 0.5, 0.5, -0.5, 0, 100), S = (e) => {
|
|
7
|
+
e?.dispose();
|
|
8
|
+
}, C = (e) => {
|
|
9
|
+
if (e)
|
|
10
|
+
if (Array.isArray(e))
|
|
11
|
+
e.forEach((t) => C(t));
|
|
12
|
+
else {
|
|
13
|
+
for (const t in e) {
|
|
14
|
+
const n = e[t];
|
|
15
|
+
n !== null && n instanceof g && S(n);
|
|
16
|
+
}
|
|
17
|
+
if (e.isShaderMaterial === !0) {
|
|
18
|
+
const t = e;
|
|
19
|
+
for (const n in t.uniforms) {
|
|
20
|
+
const i = t.uniforms[n];
|
|
21
|
+
i.value !== null && i.value instanceof g && S(i.value);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
e.dispose();
|
|
25
|
+
}
|
|
26
|
+
}, L = (e) => {
|
|
27
|
+
if (e) {
|
|
28
|
+
for (; e.children.length > 0; ) {
|
|
29
|
+
const t = e.children[0];
|
|
30
|
+
t.type === "Audio" ? (t.pause(), t.parent && t.parent.remove(t)) : L(t);
|
|
31
|
+
}
|
|
32
|
+
if (e.parent && e.parent.remove(e), e.isMesh) {
|
|
33
|
+
const t = e;
|
|
34
|
+
t.geometry?.dispose(), C(t.material);
|
|
35
|
+
}
|
|
36
|
+
e.dispose !== void 0 && e.dispose();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
let d = 0;
|
|
40
|
+
const N = () => {
|
|
41
|
+
d = 0;
|
|
42
|
+
}, $ = (e) => {
|
|
43
|
+
if (!e) return;
|
|
44
|
+
let t = e.name.replaceAll(" ", "").replaceAll("/", ".");
|
|
45
|
+
if (t.length === 0 && (t = `obj_${d}`, d++), e.parent !== null && e.parent.uuid.length > 0 && (t = `${e.parent.uuid}.${t}`), e.uuid = t, e.isMesh !== void 0) {
|
|
46
|
+
const n = e;
|
|
47
|
+
if (Array.isArray(n.material))
|
|
48
|
+
n.material.forEach((i, s) => {
|
|
49
|
+
i.uuid = `${t}.material.${s}`;
|
|
50
|
+
});
|
|
51
|
+
else {
|
|
52
|
+
const i = n.material;
|
|
53
|
+
i.uuid = `${t}.material`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
e.children.forEach((n) => $(n));
|
|
57
|
+
};
|
|
58
|
+
class V {
|
|
59
|
+
static renderer;
|
|
60
|
+
static canvas;
|
|
61
|
+
static context = null;
|
|
62
|
+
static scene = null;
|
|
63
|
+
static camera = null;
|
|
64
|
+
static material = null;
|
|
65
|
+
static inited = !1;
|
|
66
|
+
static width = 100;
|
|
67
|
+
static height = 100;
|
|
68
|
+
static init() {
|
|
69
|
+
this.inited || (this.canvas = document.createElement("canvas"), this.canvas.width = this.width, this.canvas.height = this.height, this.context = this.canvas.getContext("2d"), this.inited = !0);
|
|
70
|
+
}
|
|
71
|
+
static renderToBlob(t) {
|
|
72
|
+
this.init();
|
|
73
|
+
const n = t.repeat.clone(), i = t.offset.clone();
|
|
74
|
+
if (t.repeat.set(1, 1), t.offset.set(0, 0), this.context !== null) {
|
|
75
|
+
this.context.clearRect(0, 0, this.width, this.height);
|
|
76
|
+
const s = t.image;
|
|
77
|
+
if (s != null && s.width > 0) {
|
|
78
|
+
this.canvas.title = t.sourceFile;
|
|
79
|
+
const r = this.canvas.width / s.width, a = this.renderToCanvas(t);
|
|
80
|
+
this.context.drawImage(a, 0, 0, s.width * r, s.height * r);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return t.repeat.copy(n), t.offset.copy(i), this.canvas.toDataURL("image/png");
|
|
84
|
+
}
|
|
85
|
+
static renderToCanvas(t) {
|
|
86
|
+
if (this.material === null) {
|
|
87
|
+
this.camera = new y(-0.5, 0.5, 0.5, -0.5, 0, 100), this.scene = new T(), this.material = new O();
|
|
88
|
+
const n = new M();
|
|
89
|
+
n.setAttribute("position", new l([-0.5, -0.5, 0, 1.5, -0.5, 0, -0.5, 1.5, 0], 3)), n.setAttribute("normal", new l([0, 0, 1, 0, 0, 1], 3)), n.setAttribute("uv", new l([0, 0, 2, 0, 0, 2], 2));
|
|
90
|
+
const i = new B(n, this.material);
|
|
91
|
+
this.scene.add(i);
|
|
92
|
+
}
|
|
93
|
+
if (t.isRenderTargetTexture)
|
|
94
|
+
this.material.map = t, this.renderer.render(this.scene, this.camera);
|
|
95
|
+
else {
|
|
96
|
+
const n = this.renderer.outputColorSpace, i = t.colorSpace;
|
|
97
|
+
this.renderer.outputColorSpace = m, t.colorSpace = m, this.material.map = t, this.renderer.render(this.scene, this.camera), this.renderer.outputColorSpace = n, t.colorSpace = i;
|
|
98
|
+
}
|
|
99
|
+
return this.renderer.domElement;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function H(e) {
|
|
103
|
+
return new Promise((t) => {
|
|
104
|
+
const n = new R();
|
|
105
|
+
n.parseAsync(e.scene).then((i) => {
|
|
106
|
+
const s = new D(i);
|
|
107
|
+
if (e.animations.length > 0) {
|
|
108
|
+
const a = e.animations.map((E) => W.parse(E));
|
|
109
|
+
s.clipAction(a[0]).play(), s.getRoot().animations = e.animations, s.getRoot().mixer = s;
|
|
110
|
+
}
|
|
111
|
+
const r = [];
|
|
112
|
+
e.cameras && e.cameras.length > 0 && e.cameras.forEach((a) => {
|
|
113
|
+
const p = n.parse(a);
|
|
114
|
+
r.push(p);
|
|
115
|
+
}), t({
|
|
116
|
+
animations: e.animations,
|
|
117
|
+
model: i,
|
|
118
|
+
mixer: s,
|
|
119
|
+
cameras: r
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
const K = (e, t, n, i) => {
|
|
125
|
+
e.setRenderTarget(i), e.clear(), e.render(t, n);
|
|
126
|
+
};
|
|
127
|
+
function G(e, t, n, i) {
|
|
128
|
+
e.applyMatrix4(new Z().makeTranslation(t, -n, -i));
|
|
129
|
+
}
|
|
130
|
+
function _(e) {
|
|
131
|
+
e.computeBoundingBox();
|
|
132
|
+
const t = e.boundingBox, n = (t.max.x - t.min.x) / 2, i = (t.max.y - t.min.y) / 2;
|
|
133
|
+
G(e, n, i, 0);
|
|
134
|
+
}
|
|
135
|
+
function z(e, t, n) {
|
|
136
|
+
e.left = t / -2, e.right = t / 2, e.top = n / 2, e.bottom = n / -2, e.position.x = t / 2, e.position.y = n / -2, e.updateProjectionMatrix();
|
|
137
|
+
}
|
|
138
|
+
function J(e, t, n) {
|
|
139
|
+
const i = 1.7777777777777777, s = t / n;
|
|
140
|
+
let r = t, a = n;
|
|
141
|
+
s > i ? r = n * i : a = t / i, e.left = r / -2, e.right = r / 2, e.top = a / 2, e.bottom = a / -2, e.updateProjectionMatrix();
|
|
142
|
+
}
|
|
143
|
+
function Q() {
|
|
144
|
+
let t = "transferControlToOffscreen" in document.createElement("canvas");
|
|
145
|
+
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
|
|
146
|
+
const i = navigator.userAgent.match(/version\/(\d+)/i);
|
|
147
|
+
t = (i ? parseInt(i[1]) : 0) >= 17;
|
|
148
|
+
}
|
|
149
|
+
return t;
|
|
150
|
+
}
|
|
151
|
+
function X(e, t, n = !0, i = !1) {
|
|
152
|
+
e.renderOrder = -t;
|
|
153
|
+
const s = e.material;
|
|
154
|
+
Array.isArray(s) ? s.forEach((r) => {
|
|
155
|
+
r.colorWrite = n, r.depthWrite = i, r.stencilWrite = !0, r.stencilRef = t, r.stencilFunc = v, r.stencilFail = o, r.stencilZFail = o, r.stencilZPass = o;
|
|
156
|
+
}) : (s.colorWrite = n, s.depthWrite = i, s.stencilWrite = !0, s.stencilRef = t, s.stencilFunc = v, s.stencilFail = o, s.stencilZFail = o, s.stencilZPass = o);
|
|
157
|
+
}
|
|
158
|
+
function Y(e, t, n = !1) {
|
|
159
|
+
const i = e.material;
|
|
160
|
+
Array.isArray(i) ? i.forEach((s) => {
|
|
161
|
+
s.stencilWrite = !0, s.stencilRef = t, s.stencilFunc = n ? A : w, s.stencilFail = c, s.stencilZFail = c, s.stencilZPass = c;
|
|
162
|
+
}) : (i.stencilWrite = !0, i.stencilRef = t, i.stencilFunc = n ? A : w, i.stencilFail = c, i.stencilZFail = c, i.stencilZPass = c);
|
|
163
|
+
}
|
|
164
|
+
function j(e) {
|
|
165
|
+
e.blending = q, e.blendEquation = u, e.blendSrc = F, e.blendDst = b, e.needsUpdate = !0;
|
|
166
|
+
}
|
|
167
|
+
function ee(e) {
|
|
168
|
+
e.blending = f, e.blendEquation = u, e.blendSrc = F, e.blendDst = x, e.needsUpdate = !0;
|
|
169
|
+
}
|
|
170
|
+
function te(e) {
|
|
171
|
+
e.blending = f, e.blendEquation = u, e.blendSrc = P, e.blendDst = b, e.needsUpdate = !0;
|
|
172
|
+
}
|
|
173
|
+
function ne(e) {
|
|
174
|
+
e.blending = f, e.blendEquation = u, e.blendSrc = U, e.blendDst = x, e.needsUpdate = !0;
|
|
175
|
+
}
|
|
176
|
+
export {
|
|
177
|
+
V as ExportTexture,
|
|
178
|
+
G as anchorGeometry,
|
|
179
|
+
_ as anchorGeometryTL,
|
|
180
|
+
X as createMask,
|
|
181
|
+
L as dispose,
|
|
182
|
+
C as disposeMaterial,
|
|
183
|
+
S as disposeTexture,
|
|
184
|
+
$ as hierarchyUUID,
|
|
185
|
+
I as orthoCamera,
|
|
186
|
+
H as parseModelLite,
|
|
187
|
+
K as renderToTexture,
|
|
188
|
+
N as resetThreeObjects,
|
|
189
|
+
ee as setMaterialBlendAdd,
|
|
190
|
+
te as setMaterialBlendMultiply,
|
|
191
|
+
j as setMaterialBlendNormal,
|
|
192
|
+
ne as setMaterialBlendScreen,
|
|
193
|
+
Q as supportsOffscreenCanvas,
|
|
194
|
+
d as totalThreeObjects,
|
|
195
|
+
h as triangle,
|
|
196
|
+
z as updateCameraOrtho,
|
|
197
|
+
J as updateCameraOrtho16x9,
|
|
198
|
+
Y as useMask
|
|
199
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
const s = a([
|
|
2
|
+
"ctrlKey",
|
|
3
|
+
"metaKey",
|
|
4
|
+
"shiftKey",
|
|
5
|
+
"button",
|
|
6
|
+
"pointerId",
|
|
7
|
+
"pointerType",
|
|
8
|
+
"clientX",
|
|
9
|
+
"clientY",
|
|
10
|
+
"pageX",
|
|
11
|
+
"pageY"
|
|
12
|
+
]), l = a([
|
|
13
|
+
"clientX",
|
|
14
|
+
"clientY",
|
|
15
|
+
"deltaX",
|
|
16
|
+
"deltaY",
|
|
17
|
+
"deltaMode"
|
|
18
|
+
]), h = a([
|
|
19
|
+
"ctrlKey",
|
|
20
|
+
"metaKey",
|
|
21
|
+
"shiftKey",
|
|
22
|
+
"keyCode"
|
|
23
|
+
]);
|
|
24
|
+
function y(e, n) {
|
|
25
|
+
e.preventDefault(), l(e, n);
|
|
26
|
+
}
|
|
27
|
+
function f(e) {
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
}
|
|
30
|
+
function m(e, n, t) {
|
|
31
|
+
for (const r of n)
|
|
32
|
+
t[r] = e[r];
|
|
33
|
+
}
|
|
34
|
+
function a(e) {
|
|
35
|
+
return function(t, r) {
|
|
36
|
+
const o = { type: t.type };
|
|
37
|
+
m(t, e, o), r(o);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function c(e, n) {
|
|
41
|
+
const t = [], r = { type: e.type, touches: t };
|
|
42
|
+
for (let o = 0; o < e.touches.length; ++o) {
|
|
43
|
+
const i = e.touches[o];
|
|
44
|
+
t.push({
|
|
45
|
+
pageX: i.pageX,
|
|
46
|
+
pageY: i.pageY
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
n(r);
|
|
50
|
+
}
|
|
51
|
+
const w = {
|
|
52
|
+
37: !0,
|
|
53
|
+
// left
|
|
54
|
+
38: !0,
|
|
55
|
+
// up
|
|
56
|
+
39: !0,
|
|
57
|
+
// right
|
|
58
|
+
40: !0
|
|
59
|
+
// down
|
|
60
|
+
};
|
|
61
|
+
function v(e, n) {
|
|
62
|
+
const { keyCode: t } = e;
|
|
63
|
+
w[t] && (e.preventDefault(), h(e, n));
|
|
64
|
+
}
|
|
65
|
+
const E = {
|
|
66
|
+
contextmenu: f,
|
|
67
|
+
mousedown: s,
|
|
68
|
+
mousemove: s,
|
|
69
|
+
mouseup: s,
|
|
70
|
+
pointerdown: s,
|
|
71
|
+
pointermove: s,
|
|
72
|
+
pointerup: s,
|
|
73
|
+
touchstart: c,
|
|
74
|
+
touchmove: c,
|
|
75
|
+
touchend: c,
|
|
76
|
+
wheel: y,
|
|
77
|
+
keydown: v
|
|
78
|
+
};
|
|
79
|
+
let g = 0;
|
|
80
|
+
class H {
|
|
81
|
+
id;
|
|
82
|
+
worker;
|
|
83
|
+
constructor(n, t, r) {
|
|
84
|
+
this.id = g++, this.worker = t;
|
|
85
|
+
const o = (d) => {
|
|
86
|
+
this.worker.postMessage({
|
|
87
|
+
type: "event",
|
|
88
|
+
id: this.id,
|
|
89
|
+
data: d
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
t.postMessage({
|
|
93
|
+
type: "makeProxy",
|
|
94
|
+
id: this.id
|
|
95
|
+
});
|
|
96
|
+
for (const [d, p] of Object.entries(r))
|
|
97
|
+
n.addEventListener(d, (u) => {
|
|
98
|
+
p(u, o);
|
|
99
|
+
});
|
|
100
|
+
function i() {
|
|
101
|
+
o({
|
|
102
|
+
type: "resize",
|
|
103
|
+
left: 0,
|
|
104
|
+
top: 0,
|
|
105
|
+
width: innerWidth,
|
|
106
|
+
height: innerHeight
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
window.addEventListener("resize", i), i();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
export {
|
|
113
|
+
H as ElementProxy,
|
|
114
|
+
E as WebworkerEventHandlers
|
|
115
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { EventDispatcher as r } from "three";
|
|
2
|
+
import { noop as e } from "../core/types.js";
|
|
3
|
+
class n extends r {
|
|
4
|
+
style = {};
|
|
5
|
+
left = 0;
|
|
6
|
+
top = 0;
|
|
7
|
+
width = 0;
|
|
8
|
+
height = 0;
|
|
9
|
+
ownerDocument = void 0;
|
|
10
|
+
constructor() {
|
|
11
|
+
super(), this.ownerDocument = this;
|
|
12
|
+
}
|
|
13
|
+
get clientWidth() {
|
|
14
|
+
return this.width;
|
|
15
|
+
}
|
|
16
|
+
set clientWidth(t) {
|
|
17
|
+
this.width = t;
|
|
18
|
+
}
|
|
19
|
+
get clientHeight() {
|
|
20
|
+
return this.height;
|
|
21
|
+
}
|
|
22
|
+
set clientHeight(t) {
|
|
23
|
+
this.height = t;
|
|
24
|
+
}
|
|
25
|
+
// OrbitControls call these as of r132. Implementing as no-ops
|
|
26
|
+
setPointerCapture() {
|
|
27
|
+
}
|
|
28
|
+
releasePointerCapture() {
|
|
29
|
+
}
|
|
30
|
+
getBoundingClientRect() {
|
|
31
|
+
return {
|
|
32
|
+
x: this.left,
|
|
33
|
+
y: this.top,
|
|
34
|
+
left: this.left,
|
|
35
|
+
top: this.top,
|
|
36
|
+
width: this.width,
|
|
37
|
+
height: this.height,
|
|
38
|
+
right: this.left + this.width,
|
|
39
|
+
bottom: this.top + this.height,
|
|
40
|
+
toJSON: () => ({})
|
|
41
|
+
// Satisfies the DOMRect interface
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
handleEvent(t) {
|
|
45
|
+
if (t.type === "size") {
|
|
46
|
+
this.left = t.left, this.top = t.top, this.width = t.width, this.height = t.height;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
t.preventDefault = e, t.stopPropagation = e, this.dispatchEvent(t);
|
|
50
|
+
}
|
|
51
|
+
focus() {
|
|
52
|
+
}
|
|
53
|
+
getRootNode() {
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
class l {
|
|
58
|
+
targets = {};
|
|
59
|
+
constructor() {
|
|
60
|
+
this.handleEvent = this.handleEvent.bind(this);
|
|
61
|
+
}
|
|
62
|
+
makeProxy(t) {
|
|
63
|
+
const { id: h } = t, s = new n();
|
|
64
|
+
this.targets[h] = s;
|
|
65
|
+
}
|
|
66
|
+
getProxy(t) {
|
|
67
|
+
return this.targets[t];
|
|
68
|
+
}
|
|
69
|
+
handleEvent(t) {
|
|
70
|
+
this.targets[t.id]?.handleEvent(t.data);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
n as ElementProxyReceiver,
|
|
75
|
+
l as ProxyManager
|
|
76
|
+
};
|