@algorisys/tinyfly 0.86.2 → 0.87.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/README.md +6 -4
- package/bin/tinyfly.mjs +44 -6
- package/lib/addons/adapters.js +168 -120
- package/lib/addons/characters.js +2 -2
- package/lib/addons/maps.js +1 -1
- package/lib/addons/scene-3d-webgl.js +52 -49
- package/lib/addons/scene-3d.js +2 -2
- package/lib/addons/shading-o5T_v9DT.js +89 -0
- package/lib/addons/{sketch-CA8ZXhxI.js → sketch-CYPUbk3Q.js} +2 -2
- package/lib/browser/tinyfly-scene-3d-webgl.iife.js +4 -2
- package/lib/browser/tinyfly-scene-3d.iife.js +2 -2
- package/lib/browser/tinyfly.iife.js +4 -4
- package/lib/browser/tinyfly.js +3161 -3102
- package/lib/browser/tinyfly.umd.js +4 -4
- package/lib/headless/headless.js +162 -17
- package/lib/types/adapters/canvas/bloom.d.ts +33 -0
- package/lib/types/adapters/canvas/index.d.ts +2 -0
- package/lib/types/adapters/canvas/offscreen.d.ts +13 -0
- package/lib/types/browser/index.d.ts +2 -0
- package/lib/types/headless/index.d.ts +1 -0
- package/lib/types/headless/loop-check.d.ts +41 -0
- package/lib/types/headless/node-video.d.ts +8 -0
- package/lib/types/headless/video-scene.d.ts +7 -1
- package/lib/types/scene-3d/scene-types.d.ts +2 -1
- package/lib/types/scene-3d/webgl/gl-data.d.ts +1 -0
- package/lib/types/scene-3d/webgl/shaders.d.ts +1 -1
- package/package.json +1 -1
- package/lib/addons/shading-ByG9UXd0.js +0 -85
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { p as _ } from "./shading-
|
|
1
|
+
import { p as _ } from "./shading-o5T_v9DT.js";
|
|
2
2
|
import { mat4 as h, vec3 as v } from "@algorisys/tinyfly";
|
|
3
|
-
const
|
|
3
|
+
const c = 8, p = { unlit: 0, flat: 1, lambert: 2, toon: 3 }, w = { ambient: 0, directional: 1, point: 2, spot: 3 }, A = `#version 300 es
|
|
4
4
|
in vec3 a_position;
|
|
5
5
|
in vec3 a_normal;
|
|
6
6
|
uniform mat4 u_model;
|
|
@@ -17,7 +17,7 @@ void main() {
|
|
|
17
17
|
}
|
|
18
18
|
`, b = `#version 300 es
|
|
19
19
|
precision highp float;
|
|
20
|
-
#define MAX_LIGHTS ${
|
|
20
|
+
#define MAX_LIGHTS ${c}
|
|
21
21
|
uniform int u_lightCount;
|
|
22
22
|
uniform int u_lightKind[MAX_LIGHTS];
|
|
23
23
|
uniform vec3 u_lightColor[MAX_LIGHTS];
|
|
@@ -27,6 +27,7 @@ uniform vec3 u_lightDirection[MAX_LIGHTS];
|
|
|
27
27
|
uniform float u_lightRange[MAX_LIGHTS];
|
|
28
28
|
uniform vec2 u_lightCone[MAX_LIGHTS];
|
|
29
29
|
uniform vec3 u_color;
|
|
30
|
+
uniform vec3 u_emissive;
|
|
30
31
|
uniform float u_opacity;
|
|
31
32
|
uniform int u_shading;
|
|
32
33
|
uniform float u_bands;
|
|
@@ -80,6 +81,7 @@ void main() {
|
|
|
80
81
|
}
|
|
81
82
|
rgb *= light;
|
|
82
83
|
}
|
|
84
|
+
rgb += u_emissive;
|
|
83
85
|
if (u_fog) {
|
|
84
86
|
float amount = clamp((distance(v_world, u_eye) - u_fogRange.x) / (u_fogRange.y - u_fogRange.x), 0.0, 1.0);
|
|
85
87
|
rgb = mix(rgb, u_fogColor, amount);
|
|
@@ -117,31 +119,32 @@ void main() {
|
|
|
117
119
|
{ id: "default-ambient", light: "ambient", color: "#ffffff", intensity: 0.35, position: [0, 0, 0], direction: [0, -1, 0], angle: 30 },
|
|
118
120
|
{ id: "default-key", light: "directional", color: "#ffffff", intensity: 0.8, position: [3, 5, 4], direction: v.normalize([-3, -5, -4]), angle: 30 }
|
|
119
121
|
];
|
|
120
|
-
function F(
|
|
121
|
-
const t = (
|
|
122
|
+
function F(a) {
|
|
123
|
+
const t = (a.length > 0 ? a : R).slice(0, c), i = {
|
|
122
124
|
count: t.length,
|
|
123
|
-
kind: new Int32Array(
|
|
124
|
-
color: new Float32Array(
|
|
125
|
-
intensity: new Float32Array(
|
|
126
|
-
position: new Float32Array(
|
|
127
|
-
direction: new Float32Array(
|
|
128
|
-
range: new Float32Array(
|
|
129
|
-
cone: new Float32Array(
|
|
125
|
+
kind: new Int32Array(c),
|
|
126
|
+
color: new Float32Array(c * 3),
|
|
127
|
+
intensity: new Float32Array(c),
|
|
128
|
+
position: new Float32Array(c * 3),
|
|
129
|
+
direction: new Float32Array(c * 3),
|
|
130
|
+
range: new Float32Array(c),
|
|
131
|
+
cone: new Float32Array(c * 2)
|
|
130
132
|
};
|
|
131
133
|
return t.forEach((o, n) => {
|
|
132
134
|
i.kind[n] = w[o.light], i.color.set(_(o.color), n * 3), i.intensity[n] = o.intensity, i.position.set(o.position, n * 3), i.direction.set(o.direction, n * 3), i.range[n] = o.range ?? 0, i.cone[n * 2] = Math.cos(o.angle * Math.PI / 180), i.cone[n * 2 + 1] = Math.cos(o.angle * 0.8 * Math.PI / 180);
|
|
133
135
|
}), i;
|
|
134
136
|
}
|
|
135
|
-
function L(
|
|
137
|
+
function L(a, t, i) {
|
|
136
138
|
return {
|
|
137
|
-
color: _(t ??
|
|
139
|
+
color: _(t ?? a.color),
|
|
140
|
+
emissive: a.emissive ? _(a.emissive) : [0, 0, 0],
|
|
138
141
|
opacity: i,
|
|
139
|
-
shading: p[
|
|
140
|
-
bands:
|
|
142
|
+
shading: p[a.shading ?? "lambert"],
|
|
143
|
+
bands: a.bands ?? 3
|
|
141
144
|
};
|
|
142
145
|
}
|
|
143
|
-
function
|
|
144
|
-
const t = h.transpose(h.invert(
|
|
146
|
+
function m(a) {
|
|
147
|
+
const t = h.transpose(h.invert(a) ?? h.identity());
|
|
145
148
|
return new Float32Array([t[0], t[1], t[2], t[4], t[5], t[6], t[8], t[9], t[10]]);
|
|
146
149
|
}
|
|
147
150
|
class C {
|
|
@@ -151,17 +154,17 @@ class C {
|
|
|
151
154
|
buffers = /* @__PURE__ */ new WeakMap();
|
|
152
155
|
overlay;
|
|
153
156
|
constructor(t, i = {}) {
|
|
154
|
-
this.gl = t, this.overlay = i.overlay, this.surface =
|
|
157
|
+
this.gl = t, this.overlay = i.overlay, this.surface = g(t, A, b), this.outline = g(t, E, y);
|
|
155
158
|
}
|
|
156
159
|
render(t) {
|
|
157
160
|
const i = this.gl, o = i.drawingBufferWidth, n = i.drawingBufferHeight;
|
|
158
161
|
i.viewport(0, 0, o, n);
|
|
159
162
|
const e = t.background && t.background !== "transparent" ? _(t.background) : null;
|
|
160
163
|
i.clearColor(e?.[0] ?? 0, e?.[1] ?? 0, e?.[2] ?? 0, e ? 1 : 0), i.clearDepth(1), i.clear(i.COLOR_BUFFER_BIT | i.DEPTH_BUFFER_BIT), i.enable(i.DEPTH_TEST), i.depthFunc(i.LEQUAL), i.enable(i.CULL_FACE), i.frontFace(i.CCW);
|
|
161
|
-
const
|
|
164
|
+
const l = t.meshes.filter((r) => r.opacity >= 1), s = t.camera.position, u = (r) => Math.hypot(r.world[12] - s[0], r.world[13] - s[1], r.world[14] - s[2]), d = t.meshes.filter((r) => r.opacity < 1).sort((r, f) => u(f) - u(r) || r.objectIndex - f.objectIndex);
|
|
162
165
|
i.disable(i.BLEND), i.depthMask(!0);
|
|
163
|
-
for (const r of
|
|
164
|
-
for (const r of
|
|
166
|
+
for (const r of l) r.material.outline && this.drawOutline(t, r, o, n);
|
|
167
|
+
for (const r of l) this.drawSurface(t, r);
|
|
165
168
|
i.enable(i.BLEND), i.blendFunc(i.SRC_ALPHA, i.ONE_MINUS_SRC_ALPHA), i.depthMask(!1);
|
|
166
169
|
for (const r of d) this.drawSurface(t, r);
|
|
167
170
|
if (i.depthMask(!0), i.disable(i.BLEND), this.overlay && t.drawables.length > 0) {
|
|
@@ -176,18 +179,18 @@ class C {
|
|
|
176
179
|
const o = this.gl, n = this.surface;
|
|
177
180
|
o.useProgram(n.program), i.material.doubleSided ? o.disable(o.CULL_FACE) : (o.enable(o.CULL_FACE), o.cullFace(o.BACK)), this.bindMesh(n, i.mesh);
|
|
178
181
|
const e = n.uniform;
|
|
179
|
-
o.uniformMatrix4fv(e("u_model"), !1, i.world), o.uniformMatrix4fv(e("u_view"), !1, t.camera.view), o.uniformMatrix4fv(e("u_projection"), !1, t.camera.projection), o.uniformMatrix3fv(e("u_normalMatrix"), !1,
|
|
180
|
-
const
|
|
181
|
-
o.uniform1i(e("u_lightCount"),
|
|
182
|
-
const
|
|
183
|
-
o.uniform3fv(e("u_color"),
|
|
182
|
+
o.uniformMatrix4fv(e("u_model"), !1, i.world), o.uniformMatrix4fv(e("u_view"), !1, t.camera.view), o.uniformMatrix4fv(e("u_projection"), !1, t.camera.projection), o.uniformMatrix3fv(e("u_normalMatrix"), !1, m(i.world));
|
|
183
|
+
const l = F(t.lights);
|
|
184
|
+
o.uniform1i(e("u_lightCount"), l.count), o.uniform1iv(e("u_lightKind"), l.kind), o.uniform3fv(e("u_lightColor"), l.color), o.uniform1fv(e("u_lightIntensity"), l.intensity), o.uniform3fv(e("u_lightPosition"), l.position), o.uniform3fv(e("u_lightDirection"), l.direction), o.uniform1fv(e("u_lightRange"), l.range), o.uniform2fv(e("u_lightCone"), l.cone);
|
|
185
|
+
const s = L(i.material, i.color, i.opacity);
|
|
186
|
+
o.uniform3fv(e("u_color"), s.color), o.uniform3fv(e("u_emissive"), s.emissive), o.uniform1f(e("u_opacity"), s.opacity), o.uniform1i(e("u_shading"), s.shading), o.uniform1f(e("u_bands"), s.bands), o.uniform3fv(e("u_eye"), t.camera.position), o.uniform3fv(e("u_forward"), t.camera.forward), o.uniform1i(e("u_orthographic"), t.camera.orthographic ? 1 : 0), o.uniform1i(e("u_fog"), t.fog ? 1 : 0), t.fog && (o.uniform3fv(e("u_fogColor"), _(t.fog.color)), o.uniform2f(e("u_fogRange"), t.fog.near, t.fog.far)), o.drawElements(o.TRIANGLES, i.mesh.indices.length, o.UNSIGNED_INT, 0);
|
|
184
187
|
}
|
|
185
188
|
drawOutline(t, i, o, n) {
|
|
186
|
-
const e = this.gl,
|
|
187
|
-
e.useProgram(
|
|
188
|
-
const u =
|
|
189
|
-
e.uniformMatrix4fv(u("u_model"), !1, i.world), e.uniformMatrix4fv(u("u_view"), !1, t.camera.view), e.uniformMatrix4fv(u("u_projection"), !1, t.camera.projection), e.uniformMatrix3fv(u("u_normalMatrix"), !1,
|
|
190
|
-
const [d, r, f] = _(
|
|
189
|
+
const e = this.gl, l = this.outline, s = i.material.outline;
|
|
190
|
+
e.useProgram(l.program), e.enable(e.CULL_FACE), e.cullFace(e.FRONT), this.bindMesh(l, i.mesh);
|
|
191
|
+
const u = l.uniform;
|
|
192
|
+
e.uniformMatrix4fv(u("u_model"), !1, i.world), e.uniformMatrix4fv(u("u_view"), !1, t.camera.view), e.uniformMatrix4fv(u("u_projection"), !1, t.camera.projection), e.uniformMatrix3fv(u("u_normalMatrix"), !1, m(i.world)), e.uniform2f(u("u_viewport"), o, n), e.uniform1f(u("u_width"), s.width * (o / t.width));
|
|
193
|
+
const [d, r, f] = _(s.color);
|
|
191
194
|
e.uniform4f(u("u_ink"), d, r, f, 1), e.drawElements(e.TRIANGLES, i.mesh.indices.length, e.UNSIGNED_INT, 0), e.cullFace(e.BACK);
|
|
192
195
|
}
|
|
193
196
|
/** Upload a mesh once; bind its buffers to the program's attributes. */
|
|
@@ -195,16 +198,16 @@ class C {
|
|
|
195
198
|
const o = this.gl;
|
|
196
199
|
let n = this.buffers.get(i);
|
|
197
200
|
if (!n) {
|
|
198
|
-
const
|
|
199
|
-
o.bindBuffer(o.ARRAY_BUFFER,
|
|
200
|
-
const
|
|
201
|
-
o.bindBuffer(o.ARRAY_BUFFER,
|
|
201
|
+
const l = o.createBuffer();
|
|
202
|
+
o.bindBuffer(o.ARRAY_BUFFER, l), o.bufferData(o.ARRAY_BUFFER, new Float32Array(i.positions), o.STATIC_DRAW);
|
|
203
|
+
const s = o.createBuffer();
|
|
204
|
+
o.bindBuffer(o.ARRAY_BUFFER, s), o.bufferData(o.ARRAY_BUFFER, new Float32Array(i.normals), o.STATIC_DRAW);
|
|
202
205
|
const u = o.createBuffer();
|
|
203
|
-
o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, u), o.bufferData(o.ELEMENT_ARRAY_BUFFER, new Uint32Array(i.indices), o.STATIC_DRAW), n = { position:
|
|
206
|
+
o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, u), o.bufferData(o.ELEMENT_ARRAY_BUFFER, new Uint32Array(i.indices), o.STATIC_DRAW), n = { position: l, normal: s, index: u }, this.buffers.set(i, n);
|
|
204
207
|
}
|
|
205
|
-
const e = (
|
|
206
|
-
const u = o.getAttribLocation(t.program,
|
|
207
|
-
u < 0 || (o.bindBuffer(o.ARRAY_BUFFER,
|
|
208
|
+
const e = (l, s) => {
|
|
209
|
+
const u = o.getAttribLocation(t.program, l);
|
|
210
|
+
u < 0 || (o.bindBuffer(o.ARRAY_BUFFER, s), o.enableVertexAttribArray(u), o.vertexAttribPointer(u, 3, o.FLOAT, !1, 0, 0));
|
|
208
211
|
};
|
|
209
212
|
e("a_position", n.position), e("a_normal", n.normal), o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, n.index);
|
|
210
213
|
}
|
|
@@ -213,25 +216,25 @@ class C {
|
|
|
213
216
|
this.gl.deleteProgram(this.surface.program), this.gl.deleteProgram(this.outline.program);
|
|
214
217
|
}
|
|
215
218
|
}
|
|
216
|
-
function
|
|
217
|
-
const o = (
|
|
218
|
-
const u =
|
|
219
|
-
if (
|
|
219
|
+
function g(a, t, i) {
|
|
220
|
+
const o = (l, s) => {
|
|
221
|
+
const u = a.createShader(l);
|
|
222
|
+
if (a.shaderSource(u, s), a.compileShader(u), !a.getShaderParameter(u, a.COMPILE_STATUS)) throw new Error(`scene-3d webgl: shader failed to compile — ${a.getShaderInfoLog(u)}`);
|
|
220
223
|
return u;
|
|
221
|
-
}, n =
|
|
222
|
-
if (
|
|
224
|
+
}, n = a.createProgram();
|
|
225
|
+
if (a.attachShader(n, o(a.VERTEX_SHADER, t)), a.attachShader(n, o(a.FRAGMENT_SHADER, i)), a.linkProgram(n), !a.getProgramParameter(n, a.LINK_STATUS)) throw new Error(`scene-3d webgl: program failed to link — ${a.getProgramInfoLog(n)}`);
|
|
223
226
|
const e = /* @__PURE__ */ new Map();
|
|
224
227
|
return {
|
|
225
228
|
program: n,
|
|
226
|
-
uniform: (
|
|
229
|
+
uniform: (l) => (e.has(l) || e.set(l, a.getUniformLocation(n, l)), e.get(l))
|
|
227
230
|
};
|
|
228
231
|
}
|
|
229
232
|
export {
|
|
230
233
|
w as LIGHT_CODE,
|
|
231
|
-
|
|
234
|
+
c as MAX_LIGHTS,
|
|
232
235
|
p as SHADING_CODE,
|
|
233
236
|
C as WebGL2Renderer,
|
|
234
|
-
|
|
237
|
+
m as normalMatrix3,
|
|
235
238
|
F as packLights,
|
|
236
239
|
L as surfaceUniforms
|
|
237
240
|
};
|
package/lib/addons/scene-3d.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { M as at, b as ct, c as lt, a as dt, e as ht, g as gt, l as pt, m as ft, p as ut, d as yt, f as wt, s as mt, h as vt, t as Mt, i as bt, v as kt } from "./load-scene-vp14_Jj-.js";
|
|
2
2
|
import { vec3 as h, mat4 as b, quat as T } from "@algorisys/tinyfly";
|
|
3
|
-
import { s as B } from "./shading-
|
|
4
|
-
import { f as Pt, l as St, p as At } from "./shading-
|
|
3
|
+
import { s as B } from "./shading-o5T_v9DT.js";
|
|
4
|
+
import { f as Pt, l as St, p as At } from "./shading-o5T_v9DT.js";
|
|
5
5
|
function F(t, e) {
|
|
6
6
|
const i = h.normalize(h.subtract(e, t)), n = Math.abs(i[1]) > 0.9999 ? [0, 0, -1] : [0, 1, 0];
|
|
7
7
|
return b.lookAt(t, e, n);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { vec3 as f } from "@algorisys/tinyfly";
|
|
2
|
+
const b = /* @__PURE__ */ new Map();
|
|
3
|
+
function M(n) {
|
|
4
|
+
const i = b.get(n);
|
|
5
|
+
if (i) return i;
|
|
6
|
+
let r = [1, 1, 1];
|
|
7
|
+
const o = n.trim().replace("#", "");
|
|
8
|
+
if (n.trim().startsWith("#") && (o.length === 3 || o.length === 6)) {
|
|
9
|
+
const t = o.length === 3 ? o.split("").map((s) => s + s).join("") : o;
|
|
10
|
+
r = [0, 2, 4].map((s) => Number.parseInt(t.slice(s, s + 2), 16) / 255);
|
|
11
|
+
} else {
|
|
12
|
+
const t = n.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/);
|
|
13
|
+
t && (r = [Number(t[1]) / 255, Number(t[2]) / 255, Number(t[3]) / 255]);
|
|
14
|
+
}
|
|
15
|
+
return b.size < 512 && b.set(n, r), r;
|
|
16
|
+
}
|
|
17
|
+
const x = [
|
|
18
|
+
{ id: "default-ambient", light: "ambient", color: "#ffffff", intensity: 0.35, position: [0, 0, 0], direction: [0, -1, 0], angle: 30 },
|
|
19
|
+
{ id: "default-key", light: "directional", color: "#ffffff", intensity: 0.8, position: [3, 5, 4], direction: f.normalize([-3, -5, -4]), angle: 30 }
|
|
20
|
+
], y = (n, i, r) => {
|
|
21
|
+
const o = Math.min(1, Math.max(0, (r - n) / (i - n)));
|
|
22
|
+
return o * o * (3 - 2 * o);
|
|
23
|
+
};
|
|
24
|
+
function g(n, i, r) {
|
|
25
|
+
const o = [0, 0, 0];
|
|
26
|
+
for (const t of r) {
|
|
27
|
+
const s = M(t.color);
|
|
28
|
+
let l;
|
|
29
|
+
if (t.light === "ambient")
|
|
30
|
+
l = t.intensity;
|
|
31
|
+
else if (t.light === "directional")
|
|
32
|
+
l = t.intensity * Math.max(0, -f.dot(i, t.direction));
|
|
33
|
+
else {
|
|
34
|
+
const e = f.subtract(t.position, n), m = f.length(e), d = m > 0 ? f.scale(e, 1 / m) : i, a = t.range ? Math.max(0, 1 - m / t.range) ** 2 : 1;
|
|
35
|
+
if (l = t.intensity * Math.max(0, f.dot(i, d)) * a, t.light === "spot") {
|
|
36
|
+
const c = Math.cos(t.angle * Math.PI / 180), h = Math.cos(t.angle * 0.8 * Math.PI / 180);
|
|
37
|
+
l *= y(c, h, -f.dot(d, t.direction));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
o[0] += s[0] * l, o[1] += s[1] * l, o[2] += s[2] * l;
|
|
41
|
+
}
|
|
42
|
+
return o;
|
|
43
|
+
}
|
|
44
|
+
function v(n, i) {
|
|
45
|
+
const r = Math.max(2, Math.round(i));
|
|
46
|
+
return Math.min(1.2, Math.ceil(Math.min(1, n) * r - 1e-9) / r);
|
|
47
|
+
}
|
|
48
|
+
function N(n, i) {
|
|
49
|
+
return n ? Math.min(1, Math.max(0, (i - n.near) / (n.far - n.near))) : 0;
|
|
50
|
+
}
|
|
51
|
+
function C(n, i, r, o) {
|
|
52
|
+
const t = n.material, s = M(n.color ?? t.color), l = t.shading ?? "lambert";
|
|
53
|
+
let e;
|
|
54
|
+
if (l === "unlit")
|
|
55
|
+
e = [...s];
|
|
56
|
+
else {
|
|
57
|
+
const a = i.length > 0 ? i : x;
|
|
58
|
+
let c;
|
|
59
|
+
if (l === "lambert") {
|
|
60
|
+
const h = [0, 0, 0];
|
|
61
|
+
for (const u of n.vertexNormals) {
|
|
62
|
+
const p = g(n.centroid, u, a);
|
|
63
|
+
h[0] += p[0] / 3, h[1] += p[1] / 3, h[2] += p[2] / 3;
|
|
64
|
+
}
|
|
65
|
+
c = h;
|
|
66
|
+
} else if (c = g(n.centroid, n.normal, a), l === "toon") {
|
|
67
|
+
const h = Math.max(c[0], c[1], c[2]), u = h > 0 ? v(h, t.bands ?? 3) / h : 0;
|
|
68
|
+
c = [c[0] * u, c[1] * u, c[2] * u];
|
|
69
|
+
}
|
|
70
|
+
e = [s[0] * c[0], s[1] * c[1], s[2] * c[2]];
|
|
71
|
+
}
|
|
72
|
+
if (t.emissive) {
|
|
73
|
+
const a = M(t.emissive);
|
|
74
|
+
e = [e[0] + a[0], e[1] + a[1], e[2] + a[2]];
|
|
75
|
+
}
|
|
76
|
+
const m = N(o, f.distance(n.centroid, r.position));
|
|
77
|
+
if (o && m > 0) {
|
|
78
|
+
const a = M(o.color);
|
|
79
|
+
e = [e[0] + (a[0] - e[0]) * m, e[1] + (a[1] - e[1]) * m, e[2] + (a[2] - e[2]) * m];
|
|
80
|
+
}
|
|
81
|
+
const d = (a) => Math.round(Math.min(1, Math.max(0, a)) * 255);
|
|
82
|
+
return { color: `rgb(${d(e[0])}, ${d(e[1])}, ${d(e[2])})`, alpha: n.opacity };
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
N as f,
|
|
86
|
+
g as l,
|
|
87
|
+
M as p,
|
|
88
|
+
C as s
|
|
89
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(h){"use strict";function j(e,i){return[e[0]*i,e[1]*i,e[2]*i]}function X(e){return Math.hypot(e[0],e[1],e[2])}function B(e){const i=X(e);return i===0?[0,0,0]:j(e,1/i)}function W(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Y(e){const i=new Array(16);for(let t=0;t<4;t++)for(let o=0;o<4;o++)i[o*4+t]=e[t*4+o];return i}function z(e){const[i,t,o,r,n,l,u,
|
|
1
|
+
(function(h){"use strict";function j(e,i){return[e[0]*i,e[1]*i,e[2]*i]}function X(e){return Math.hypot(e[0],e[1],e[2])}function B(e){const i=X(e);return i===0?[0,0,0]:j(e,1/i)}function W(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Y(e){const i=new Array(16);for(let t=0;t<4;t++)for(let o=0;o<4;o++)i[o*4+t]=e[t*4+o];return i}function z(e){const[i,t,o,r,n,l,s,u,_,a,f,m,v,p,b,w]=e,A=i*l-t*n,y=i*s-o*n,E=i*u-r*n,R=t*s-o*l,L=t*u-r*l,M=o*u-r*s,F=_*p-a*v,T=_*b-f*v,C=_*w-m*v,S=a*b-f*p,I=a*w-m*p,x=f*w-m*b,O=A*x-y*I+E*S+R*C-L*T+M*F;if(Math.abs(O)<1e-12)return null;const c=1/O;return[(l*x-s*I+u*S)*c,(o*I-t*x-r*S)*c,(p*M-b*L+w*R)*c,(f*L-a*M-m*R)*c,(s*C-n*x-u*T)*c,(i*x-o*C+r*T)*c,(b*E-v*M-w*y)*c,(_*M-f*E+m*y)*c,(n*I-l*C+u*F)*c,(t*C-i*I-r*F)*c,(v*L-p*E+w*A)*c,(a*E-_*L-m*A)*c,(l*T-n*S-s*F)*c,(i*S-t*T+o*F)*c,(p*y-v*R-b*A)*c,(_*R-a*y+f*A)*c]}const N=new Map;function g(e){const i=N.get(e);if(i)return i;let t=[1,1,1];const o=e.trim().replace("#","");if(e.trim().startsWith("#")&&(o.length===3||o.length===6)){const r=o.length===3?o.split("").map(n=>n+n).join(""):o;t=[0,2,4].map(n=>Number.parseInt(r.slice(n,n+2),16)/255)}else{const r=e.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/);r&&(t=[Number(r[1])/255,Number(r[2])/255,Number(r[3])/255])}return N.size<512&&N.set(e,t),t}B([-3,-5,-4]);const d=8,P={unlit:0,flat:1,lambert:2,toon:3},k={ambient:0,directional:1,point:2,spot:3},K=`#version 300 es
|
|
2
2
|
in vec3 a_position;
|
|
3
3
|
in vec3 a_normal;
|
|
4
4
|
uniform mat4 u_model;
|
|
@@ -25,6 +25,7 @@ uniform vec3 u_lightDirection[MAX_LIGHTS];
|
|
|
25
25
|
uniform float u_lightRange[MAX_LIGHTS];
|
|
26
26
|
uniform vec2 u_lightCone[MAX_LIGHTS];
|
|
27
27
|
uniform vec3 u_color;
|
|
28
|
+
uniform vec3 u_emissive;
|
|
28
29
|
uniform float u_opacity;
|
|
29
30
|
uniform int u_shading;
|
|
30
31
|
uniform float u_bands;
|
|
@@ -78,6 +79,7 @@ void main() {
|
|
|
78
79
|
}
|
|
79
80
|
rgb *= light;
|
|
80
81
|
}
|
|
82
|
+
rgb += u_emissive;
|
|
81
83
|
if (u_fog) {
|
|
82
84
|
float amount = clamp((distance(v_world, u_eye) - u_fogRange.x) / (u_fogRange.y - u_fogRange.x), 0.0, 1.0);
|
|
83
85
|
rgb = mix(rgb, u_fogColor, amount);
|
|
@@ -111,4 +113,4 @@ out vec4 outColor;
|
|
|
111
113
|
void main() {
|
|
112
114
|
outColor = u_ink;
|
|
113
115
|
}
|
|
114
|
-
`,Q=[{id:"default-ambient",light:"ambient",color:"#ffffff",intensity:.35,position:[0,0,0],direction:[0,-1,0],angle:30},{id:"default-key",light:"directional",color:"#ffffff",intensity:.8,position:[3,5,4],direction:B([-3,-5,-4]),angle:30}];function D(e){const i=(e.length>0?e:Q).slice(0,d),t={count:i.length,kind:new Int32Array(d),color:new Float32Array(d*3),intensity:new Float32Array(d),position:new Float32Array(d*3),direction:new Float32Array(d*3),range:new Float32Array(d),cone:new Float32Array(d*2)};return i.forEach((o,r)=>{t.kind[r]=k[o.light],t.color.set(
|
|
116
|
+
`,Q=[{id:"default-ambient",light:"ambient",color:"#ffffff",intensity:.35,position:[0,0,0],direction:[0,-1,0],angle:30},{id:"default-key",light:"directional",color:"#ffffff",intensity:.8,position:[3,5,4],direction:B([-3,-5,-4]),angle:30}];function D(e){const i=(e.length>0?e:Q).slice(0,d),t={count:i.length,kind:new Int32Array(d),color:new Float32Array(d*3),intensity:new Float32Array(d),position:new Float32Array(d*3),direction:new Float32Array(d*3),range:new Float32Array(d),cone:new Float32Array(d*2)};return i.forEach((o,r)=>{t.kind[r]=k[o.light],t.color.set(g(o.color),r*3),t.intensity[r]=o.intensity,t.position.set(o.position,r*3),t.direction.set(o.direction,r*3),t.range[r]=o.range??0,t.cone[r*2]=Math.cos(o.angle*Math.PI/180),t.cone[r*2+1]=Math.cos(o.angle*.8*Math.PI/180)}),t}function G(e,i,t){return{color:g(i??e.color),emissive:e.emissive?g(e.emissive):[0,0,0],opacity:t,shading:P[e.shading??"lambert"],bands:e.bands??3}}function U(e){const i=Y(z(e)??W());return new Float32Array([i[0],i[1],i[2],i[4],i[5],i[6],i[8],i[9],i[10]])}class J{gl;surface;outline;buffers=new WeakMap;overlay;constructor(i,t={}){this.gl=i,this.overlay=t.overlay,this.surface=H(i,K,V),this.outline=H(i,$,q)}render(i){const t=this.gl,o=t.drawingBufferWidth,r=t.drawingBufferHeight;t.viewport(0,0,o,r);const n=i.background&&i.background!=="transparent"?g(i.background):null;t.clearColor(n?.[0]??0,n?.[1]??0,n?.[2]??0,n?1:0),t.clearDepth(1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT),t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL),t.enable(t.CULL_FACE),t.frontFace(t.CCW);const l=i.meshes.filter(a=>a.opacity>=1),s=i.camera.position,u=a=>Math.hypot(a.world[12]-s[0],a.world[13]-s[1],a.world[14]-s[2]),_=i.meshes.filter(a=>a.opacity<1).sort((a,f)=>u(f)-u(a)||a.objectIndex-f.objectIndex);t.disable(t.BLEND),t.depthMask(!0);for(const a of l)a.material.outline&&this.drawOutline(i,a,o,r);for(const a of l)this.drawSurface(i,a);t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),t.depthMask(!1);for(const a of _)this.drawSurface(i,a);if(t.depthMask(!0),t.disable(t.BLEND),this.overlay&&i.drawables.length>0){const a=this.overlay;a.save(),a.setTransform(a.canvas.width/i.width,0,0,a.canvas.height/i.height,0,0),a.clearRect(0,0,i.width,i.height);for(const f of i.drawables)a.save(),f.draw(a,i),a.restore();a.restore()}else this.overlay&&this.overlay.clearRect(0,0,this.overlay.canvas.width,this.overlay.canvas.height)}drawSurface(i,t){const o=this.gl,r=this.surface;o.useProgram(r.program),t.material.doubleSided?o.disable(o.CULL_FACE):(o.enable(o.CULL_FACE),o.cullFace(o.BACK)),this.bindMesh(r,t.mesh);const n=r.uniform;o.uniformMatrix4fv(n("u_model"),!1,t.world),o.uniformMatrix4fv(n("u_view"),!1,i.camera.view),o.uniformMatrix4fv(n("u_projection"),!1,i.camera.projection),o.uniformMatrix3fv(n("u_normalMatrix"),!1,U(t.world));const l=D(i.lights);o.uniform1i(n("u_lightCount"),l.count),o.uniform1iv(n("u_lightKind"),l.kind),o.uniform3fv(n("u_lightColor"),l.color),o.uniform1fv(n("u_lightIntensity"),l.intensity),o.uniform3fv(n("u_lightPosition"),l.position),o.uniform3fv(n("u_lightDirection"),l.direction),o.uniform1fv(n("u_lightRange"),l.range),o.uniform2fv(n("u_lightCone"),l.cone);const s=G(t.material,t.color,t.opacity);o.uniform3fv(n("u_color"),s.color),o.uniform3fv(n("u_emissive"),s.emissive),o.uniform1f(n("u_opacity"),s.opacity),o.uniform1i(n("u_shading"),s.shading),o.uniform1f(n("u_bands"),s.bands),o.uniform3fv(n("u_eye"),i.camera.position),o.uniform3fv(n("u_forward"),i.camera.forward),o.uniform1i(n("u_orthographic"),i.camera.orthographic?1:0),o.uniform1i(n("u_fog"),i.fog?1:0),i.fog&&(o.uniform3fv(n("u_fogColor"),g(i.fog.color)),o.uniform2f(n("u_fogRange"),i.fog.near,i.fog.far)),o.drawElements(o.TRIANGLES,t.mesh.indices.length,o.UNSIGNED_INT,0)}drawOutline(i,t,o,r){const n=this.gl,l=this.outline,s=t.material.outline;n.useProgram(l.program),n.enable(n.CULL_FACE),n.cullFace(n.FRONT),this.bindMesh(l,t.mesh);const u=l.uniform;n.uniformMatrix4fv(u("u_model"),!1,t.world),n.uniformMatrix4fv(u("u_view"),!1,i.camera.view),n.uniformMatrix4fv(u("u_projection"),!1,i.camera.projection),n.uniformMatrix3fv(u("u_normalMatrix"),!1,U(t.world)),n.uniform2f(u("u_viewport"),o,r),n.uniform1f(u("u_width"),s.width*(o/i.width));const[_,a,f]=g(s.color);n.uniform4f(u("u_ink"),_,a,f,1),n.drawElements(n.TRIANGLES,t.mesh.indices.length,n.UNSIGNED_INT,0),n.cullFace(n.BACK)}bindMesh(i,t){const o=this.gl;let r=this.buffers.get(t);if(!r){const l=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,l),o.bufferData(o.ARRAY_BUFFER,new Float32Array(t.positions),o.STATIC_DRAW);const s=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,s),o.bufferData(o.ARRAY_BUFFER,new Float32Array(t.normals),o.STATIC_DRAW);const u=o.createBuffer();o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,u),o.bufferData(o.ELEMENT_ARRAY_BUFFER,new Uint32Array(t.indices),o.STATIC_DRAW),r={position:l,normal:s,index:u},this.buffers.set(t,r)}const n=(l,s)=>{const u=o.getAttribLocation(i.program,l);u<0||(o.bindBuffer(o.ARRAY_BUFFER,s),o.enableVertexAttribArray(u),o.vertexAttribPointer(u,3,o.FLOAT,!1,0,0))};n("a_position",r.position),n("a_normal",r.normal),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,r.index)}destroy(){this.gl.deleteProgram(this.surface.program),this.gl.deleteProgram(this.outline.program)}}function H(e,i,t){const o=(l,s)=>{const u=e.createShader(l);if(e.shaderSource(u,s),e.compileShader(u),!e.getShaderParameter(u,e.COMPILE_STATUS))throw new Error(`scene-3d webgl: shader failed to compile — ${e.getShaderInfoLog(u)}`);return u},r=e.createProgram();if(e.attachShader(r,o(e.VERTEX_SHADER,i)),e.attachShader(r,o(e.FRAGMENT_SHADER,t)),e.linkProgram(r),!e.getProgramParameter(r,e.LINK_STATUS))throw new Error(`scene-3d webgl: program failed to link — ${e.getProgramInfoLog(r)}`);const n=new Map;return{program:r,uniform:l=>(n.has(l)||n.set(l,e.getUniformLocation(r,l)),n.get(l))}}h.LIGHT_CODE=k,h.MAX_LIGHTS=d,h.SHADING_CODE=P,h.WebGL2Renderer=J,h.normalMatrix3=U,h.packLights=D,h.surfaceUniforms=G,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})})(this.tinyfly=this.tinyfly||{});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(P){"use strict";const Rt=[{name:"position",vector:"position",components:["x","y","z"]},{name:"rotation",vector:"quaternion",components:["rotateX","rotateY","rotateZ"]}];function Mt(t,s=[]){const o=[],n=new Map;for(const i of t.objects){if(i.id?n.has(i.id)&&o.push(`two objects share the id "${i.id}"`):o.push("an object has no id"),i.parent!==void 0&&!n.has(i.parent)&&o.push(`"${i.id}" has parent "${i.parent}", which must be an earlier object`),i.quaternion&&i.quaternion.length!==4&&o.push(`"${i.id}": a quaternion has four numbers`),i.kind==="mesh"){t.materials?.[i.material]||o.push(`"${i.id}" uses material "${i.material}", which is not in materials`);const r=i.geometry,a=r.type==="box"||r.type==="plane"?r.size:r.type==="torus"?[r.radius,r.tube]:r.type==="sphere"?[r.radius]:r.type==="extrude"?[r.depth,r.width??1]:[r.radius,r.height];r.type==="extrude"&&!(typeof r.path=="string"&&/^\s*[Mm]/.test(r.path))&&o.push(`"${i.id}": an extrude needs a path that starts with M`),a.every(l=>Number.isFinite(l)&&l>0)||o.push(`"${i.id}": a ${r.type}'s sizes must be positive`)}i.kind==="camera"&&(i.near>0&&i.far>i.near||o.push(`camera "${i.id}": near must be above 0 and far beyond it`),i.projection==="perspective"&&!(i.fov>0&&i.fov<180)&&o.push(`camera "${i.id}": fov is between 0 and 180 degrees`),i.projection==="orthographic"&&!(i.height>0)&&o.push(`camera "${i.id}": height must be positive`)),i.id&&n.set(i.id,i)}const e=n.get(t.camera);e?e.kind!=="camera"&&o.push(`the scene's camera "${t.camera}" is a ${e.kind}, not a camera`):o.push(`the scene's camera "${t.camera}" is not one of its objects`),t.fog&&!(t.fog.far>t.fog.near)&&o.push("fog: far must be beyond near");const c=new Map;for(const i of s){if(!i.target.startsWith(`${t.id}/`))continue;const r=i.target.slice(t.id.length+1);c.has(r)||c.set(r,new Set),c.get(r).add(i.property)}for(const[i,r]of c){n.has(i)||o.push(`a track animates "${t.id}/${i}", which is not in the scene`);for(const a of Rt)r.has(a.vector)&&a.components.some(l=>r.has(l))&&o.push(`"${i}": its ${a.name} is animated both by ${a.vector} and by ${a.components.join(" / ")}; use one`)}return o}class L{positions=[];normals=[];indices=[];vertex(s,o,n,e,c,i){const r=Math.hypot(e,c,i)||1;return this.positions.push(s,o,n),this.normals.push(e/r,c/r,i/r),this.positions.length/3-1}triangle(s,o,n){this.indices.push(s,o,n)}quad(s,o,n,e){this.indices.push(s,o,n,s,n,e)}build(){return{positions:this.positions,normals:this.normals,indices:this.indices}}}function yt(t){const s=new Map,o=[];for(let e=0;e<t.positions.length/3;e++){const c=[0,1,2].map(i=>Math.round(t.positions[e*3+i]*1e6)).join(",");s.has(c)||s.set(c,e),o.push(s.get(c))}const n=new Map;for(let e=0;e<t.indices.length/3;e++)for(let c=0;c<3;c++){const i=o[t.indices[e*3+c]],r=o[t.indices[e*3+(c+1)%3]];if(i===r)continue;const a=i<r?`${i}-${r}`:`${r}-${i}`,l=n.get(a);l?l.faces.push(e):n.set(a,{a:Math.min(i,r),b:Math.max(i,r),faces:[e]})}return[...n.values()]}const mt=32,Ut=256,U=new Map,Zt=/[MmLlHhVvCcSsQqTtAaZz]/,Gt=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,Vt={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function Bt(t){const s=[];let o=0,n=null;const e=()=>{for(;o<t.length&&/[\s,]/.test(t[o]);)o++};for(;o<t.length&&(e(),!(o>=t.length));){const c=t[o];if(Zt.test(c)){n={type:c,args:[]},s.push(n),o++;continue}if(!n)break;const i=n.type==="A"||n.type==="a",r=n.args.length%7;if(i&&(r===3||r===4)){if(c!=="0"&&c!=="1")break;n.args.push(c==="1"?1:0),o++;continue}const a=Gt.exec(t.slice(o));if(!a)break;n.args.push(parseFloat(a[0])),o+=a[0].length}return s}function Ft(t,s,o,n,e,c,i,r,a){if(t===r&&s===a)return[];let l=Math.abs(o),f=Math.abs(n);if(l===0||f===0)return[[t,s,r,a,r,a]];const d=e*Math.PI/180,u=Math.cos(d),p=Math.sin(d),b=(t-r)/2,y=(s-a)/2,h=u*b+p*y,g=-p*b+u*y,w=h*h/(l*l)+g*g/(f*f);if(w>1){const E=Math.sqrt(w);l*=E,f*=E}const k=c===i?-1:1,x=l*l*f*f-l*l*g*g-f*f*h*h,M=l*l*g*g+f*f*h*h,A=k*Math.sqrt(Math.max(0,x/M)),m=A*l*g/f,$=-A*f*h/l,j=u*m-p*$+(t+r)/2,I=p*m+u*$+(s+a)/2,v=(E,Y,z,R)=>{const gt=E*z+Y*R,tt=Math.sqrt((E*E+Y*Y)*(z*z+R*R)),V=Math.acos(Math.max(-1,Math.min(1,gt/tt)));return E*R-Y*z<0?-V:V},S=v(1,0,(h-m)/l,(g-$)/f);let T=v((h-m)/l,(g-$)/f,(-h-m)/l,(-g-$)/f);!i&&T>0&&(T-=2*Math.PI),i&&T<0&&(T+=2*Math.PI);const C=Math.max(1,Math.ceil(Math.abs(T)/(Math.PI/2))),G=T/C,Q=4/3*Math.tan(G/4),Dt=E=>{const Y=l*Math.cos(E),z=f*Math.sin(E);return[u*Y-p*z+j,p*Y+u*z+I]},Ht=E=>{const Y=-l*Math.sin(E),z=f*Math.cos(E);return[u*Y-p*z,p*Y+u*z]},Qt=[];for(let E=0;E<C;E++){const Y=S+E*G,z=Y+G,[R,gt]=Dt(Y),[tt,V]=E===C-1?[r,a]:Dt(z),[jn,En]=Ht(Y),[Xn,Yn]=Ht(z);Qt.push([R+Q*jn,gt+Q*En,tt-Q*Xn,V-Q*Yn,tt,V])}return Qt}function bt(t,s,o,n,e){const c=1-e;return c*c*c*t+3*c*c*e*s+3*c*e*e*o+e*e*e*n}function Z(t,s,o,n){return{subpath:0,type:"L",points:[o,n],startX:t,startY:s,endX:o,endY:n,length:Math.hypot(o-t,n-s)}}function B(t,s,o){const[n,e,c,i,r,a]=o,l=[0];let f=t,d=s,u=0;for(let p=1;p<=mt;p++){const b=p/mt,y=bt(t,n,c,r,b),h=bt(s,e,i,a,b);u+=Math.hypot(y-f,h-d),l.push(u),f=y,d=h}return{subpath:0,type:"C",points:[n,e,c,i,r,a],startX:t,startY:s,endX:r,endY:a,length:u,lengths:l}}function Wt(t){const s=U.get(t);if(s)return s;const o=[];let n=0,e=0,c=0,i=0,r=null,a=null,l=-1;const f=new Set,d=y=>{l<0&&(l=0),y.subpath=l,o.push(y)};for(const{type:y,args:h}of Bt(t)){const g=y.toUpperCase(),w=y!==g,k=Vt[g];if(g==="Z"){(n!==c||e!==i)&&d(Z(n,e,c,i)),l>=0&&f.add(l),n=c,e=i,r=a=null;continue}for(let x=0;x+k<=h.length;x+=k){const M=h.slice(x,x+k),A=w?n:0,m=w?e:0;let $=null,j=null;switch(g){case"M":x===0?(n=M[0]+A,e=M[1]+m,c=n,i=e,(l<0||o[o.length-1]?.subpath===l)&&l++):(d(Z(n,e,M[0]+A,M[1]+m)),n=M[0]+A,e=M[1]+m);break;case"L":d(Z(n,e,M[0]+A,M[1]+m)),n=M[0]+A,e=M[1]+m;break;case"H":d(Z(n,e,M[0]+A,e)),n=M[0]+A;break;case"V":d(Z(n,e,n,M[0]+m)),e=M[0]+m;break;case"C":{const I=[M[0]+A,M[1]+m,M[2]+A,M[3]+m,M[4]+A,M[5]+m];d(B(n,e,I)),$=[I[2],I[3]],n=I[4],e=I[5];break}case"S":{const[I,v]=r?[2*n-r[0],2*e-r[1]]:[n,e],S=[I,v,M[0]+A,M[1]+m,M[2]+A,M[3]+m];d(B(n,e,S)),$=[S[2],S[3]],n=S[4],e=S[5];break}case"Q":case"T":{let I=n,v=e;g==="Q"?(I=M[0]+A,v=M[1]+m):a&&(I=2*n-a[0],v=2*e-a[1]);const S=g==="Q"?M[2]+A:M[0]+A,T=g==="Q"?M[3]+m:M[1]+m;d(B(n,e,[n+2/3*(I-n),e+2/3*(v-e),S+2/3*(I-S),T+2/3*(v-T),S,T])),j=[I,v],n=S,e=T;break}case"A":{const I=M[5]+A,v=M[6]+m;let S=n,T=e;for(const C of Ft(n,e,M[0],M[1],M[2],M[3],M[4],I,v))d(B(S,T,C)),S=C[4],T=C[5];n=I,e=v;break}}r=$,a=j}}const u=o.reduce((y,h)=>y+h.length,0),p=[];for(let y=0;y<o.length;){const h=o[y].subpath;let g=y,w=0;for(;g<o.length&&o[g].subpath===h;)w+=o[g++].length;const k=o[y],x=o[g-1],M=f.has(h)||Math.abs(x.endX-k.startX)<1e-9&&Math.abs(x.endY-k.startY)<1e-9;p.push({start:y,end:g,length:w,closed:M}),y=g}const b={segments:o,totalLength:u,subpaths:p};return U.size>=Ut&&U.delete(U.keys().next().value),U.set(t,b),b}function H(t){let s=0;for(let o=0;o<t.length;o++){const n=t[o],e=t[(o+1)%t.length];s+=n.x*e.y-e.x*n.y}return s}function nt(t,s){let o=!1;for(let n=0,e=s.length-1;n<s.length;e=n++){const c=s[n],i=s[e];c.y>t.y!=i.y>t.y&&t.x<(i.x-c.x)*(t.y-c.y)/(i.y-c.y)+c.x&&(o=!o)}return o}const F=(t,s,o)=>(s.x-t.x)*(o.y-t.y)-(s.y-t.y)*(o.x-t.x),et=(t,s)=>t.x===s.x&&t.y===s.y;function st(t,s,o,n){return F(s,o,t)>=0&&F(o,n,t)>=0&&F(n,s,t)>=0}function Jt(t,s){let o=0;for(let u=1;u<s.length;u++)s[u].x>s[o].x&&(o=u);const n=s[o];let e=-1,c=1/0;for(let u=0;u<t.length;u++){const p=t[u],b=t[(u+1)%t.length];if(p.y>n.y==b.y>n.y)continue;const y=p.x+(n.y-p.y)*(b.x-p.x)/(b.y-p.y);y>=n.x&&y<c&&(c=y,e=u)}if(e<0)return t;const i=t[e],r=t[(e+1)%t.length];let a=i.x>r.x?e:(e+1)%t.length;const l={x:c,y:n.y};let f=1/0;for(let u=0;u<t.length;u++){const p=t[u];if(u===a||p.x<n.x)continue;const b=t[a];if(!(st(p,n,l,b)||st(p,n,b,l)))continue;const h=Math.abs(Math.atan2(p.y-n.y,p.x-n.x));h<f&&(f=h,a=u)}const d=s.slice(o).concat(s.slice(0,o));return[...t.slice(0,a+1),...d,n,t[a],...t.slice(a+1)]}function wt(t,s=[]){const o=H(t)>=0?t:[...t].reverse(),n=s.map(d=>H(d)<=0?d:[...d].reverse()),e=[...o,...n.flat()],c=new Map;e.forEach((d,u)=>c.set(d,u));const i=[...n].sort((d,u)=>Math.max(...u.map(p=>p.x))-Math.max(...d.map(p=>p.x)));let r=o;for(const d of i)r=Jt(r,d);const a=r.map(d=>c.get(d)),l=[];let f=a.length*a.length;for(;a.length>3&&f-- >0;){let d=!1;for(let u=0;u<a.length;u++){const p=a[(u+a.length-1)%a.length],b=a[u],y=a[(u+1)%a.length],[h,g,w]=[e[p],e[b],e[y]];if(F(h,g,w)<=0)continue;let k=!1;for(const x of a){const M=e[x];if(!(x===p||x===b||x===y||et(M,h)||et(M,g)||et(M,w))&&st(M,h,g,w)){k=!0;break}}if(!k){l.push(p,b,y),a.splice(u,1),d=!0;break}}d||(l.push(a[a.length-1],a[0],a[1]),a.splice(0,1))}return a.length===3&&l.push(a[0],a[1],a[2]),{points:e,triangles:l}}function Kt(t,s){const o=new Map;for(const n of Wt(t).segments){o.has(n.subpath)||o.set(n.subpath,[{x:n.startX,y:-n.startY}]);const e=o.get(n.subpath);if(n.type==="L")e.push({x:n.endX,y:-n.endY});else{const[c,i,r,a,l,f]=n.points;for(let d=1;d<=s;d++){const u=d/s,p=1-u,b=p*p*p*n.startX+3*p*p*u*c+3*p*u*u*r+u*u*u*l,y=p*p*p*n.startY+3*p*p*u*i+3*p*u*u*a+u*u*u*f;e.push({x:b,y:-y})}}}return[...o.values()].map(n=>n.filter((e,c)=>c===0||e.x!==n[c-1].x||e.y!==n[c-1].y)).map(n=>n.length>1&&n[0].x===n[n.length-1].x&&n[0].y===n[n.length-1].y?n.slice(0,-1):n).filter(n=>n.length>=3&&Math.abs(H(n))>1e-12)}function xt(t,s){const o=Kt(t,Math.max(1,Math.round(s.curveSegments??12))),n=new L;if(o.length===0)return n.build();const e=o.flat(),c=Math.min(...e.map(h=>h.x)),i=Math.max(...e.map(h=>h.x)),r=Math.min(...e.map(h=>h.y)),a=Math.max(...e.map(h=>h.y)),l=(s.width??1)/Math.max(i-c,1e-9),f=(c+i)/2,d=(r+a)/2,u=o.map(h=>h.map(g=>({x:(g.x-f)*l,y:(g.y-d)*l}))),p=u.map((h,g)=>u.filter((w,k)=>k!==g&&nt(h[0],w)).length),b=s.depth/2,y=-s.depth/2;return u.forEach((h,g)=>{if(p[g]%2===1)return;const w=u.filter((m,$)=>p[$]===p[g]+1&&nt(m[0],h)),{points:k,triangles:x}=wt(h,w),M=k.map(m=>n.vertex(m.x,m.y,b,0,0,1)),A=k.map(m=>n.vertex(m.x,m.y,y,0,0,-1));for(let m=0;m<x.length;m+=3)n.triangle(M[x[m]],M[x[m+1]],M[x[m+2]]),n.triangle(A[x[m]],A[x[m+2]],A[x[m+1]]);for(const m of[H(h)>=0?h:[...h].reverse(),...w.map($=>H($)<=0?$:[...$].reverse())])for(let $=0;$<m.length;$++){const j=m[$],I=m[($+1)%m.length],v=I.y-j.y,S=-(I.x-j.x),T=n.vertex(j.x,j.y,y,v,S,0),C=n.vertex(I.x,I.y,y,v,S,0),G=n.vertex(I.x,I.y,b,v,S,0),Q=n.vertex(j.x,j.y,b,v,S,0);n.quad(T,C,G,Q)}}),n.build()}const _=Math.PI*2;function vt([t,s,o]){const n=new L,e=t/2,c=s/2,i=o/2,r=[[[0,0,1],[[-e,-c,i],[e,-c,i],[e,c,i],[-e,c,i]]],[[0,0,-1],[[e,-c,-i],[-e,-c,-i],[-e,c,-i],[e,c,-i]]],[[1,0,0],[[e,-c,i],[e,-c,-i],[e,c,-i],[e,c,i]]],[[-1,0,0],[[-e,-c,-i],[-e,-c,i],[-e,c,i],[-e,c,-i]]],[[0,1,0],[[-e,c,i],[e,c,i],[e,c,-i],[-e,c,-i]]],[[0,-1,0],[[-e,-c,-i],[e,-c,-i],[e,-c,i],[-e,-c,i]]]];for(const[[a,l,f],d]of r){const[u,p,b,y]=d.map(([h,g,w])=>n.vertex(h,g,w,a,l,f));n.quad(u,p,b,y)}return n.build()}function kt([t,s],o=1){const n=new L,e=Math.max(1,Math.round(o)),c=[];for(let i=0;i<=e;i++){const r=s/2-s*i/e;c.push(Array.from({length:e+1},(a,l)=>n.vertex(-t/2+t*l/e,0,r,0,1,0)))}for(let i=0;i<e;i++)for(let r=0;r<e;r++)n.quad(c[i][r],c[i][r+1],c[i+1][r+1],c[i+1][r]);return n.build()}function It(t,s=16){const o=new L,n=Math.max(6,Math.round(s)),e=Math.max(3,Math.round(n/2)),c=[];for(let i=0;i<=e;i++){const r=i/e*Math.PI,a=[];for(let l=0;l<=n;l++){const f=l/n*_,d=Math.sin(r)*Math.sin(f),u=Math.cos(r),p=Math.sin(r)*Math.cos(f);a.push(o.vertex(d*t,u*t,p*t,d,u,p))}c.push(a)}for(let i=0;i<e;i++)for(let r=0;r<n;r++){const a=c[i][r],l=c[i+1][r],f=c[i+1][r+1],d=c[i][r+1];i>0&&o.triangle(a,l,d),i<e-1&&o.triangle(l,f,d)}return o.build()}function ot(t,s,o,n,e){const c=t.vertex(0,o,0,0,n,0),i=Array.from({length:e},(r,a)=>{const l=a/e*_;return t.vertex(Math.sin(l)*s,o,Math.cos(l)*s,0,n,0)});for(let r=0;r<e;r++){const a=i[r],l=i[(r+1)%e];n===1?t.triangle(c,a,l):t.triangle(c,l,a)}}function At(t,s,o=24){const n=new L,e=Math.max(6,Math.round(o)),c=s/2,i=-s/2,r=f=>Array.from({length:e+1},(d,u)=>{const p=u/e*_;return n.vertex(Math.sin(p)*t,f,Math.cos(p)*t,Math.sin(p),0,Math.cos(p))}),a=r(i),l=r(c);for(let f=0;f<e;f++)n.quad(a[f],a[f+1],l[f+1],l[f]);return ot(n,t,c,1,e),ot(n,t,i,-1,e),n.build()}function $t(t,s,o=24){const n=new L,e=Math.max(6,Math.round(o)),c=s/2,i=-s/2,r=t/s;for(let a=0;a<e;a++){const l=a/e*_,f=(a+1)/e*_,d=(l+f)/2,u=n.vertex(Math.sin(l)*t,i,Math.cos(l)*t,Math.sin(l),r,Math.cos(l)),p=n.vertex(Math.sin(f)*t,i,Math.cos(f)*t,Math.sin(f),r,Math.cos(f)),b=n.vertex(0,c,0,Math.sin(d),r,Math.cos(d));n.triangle(u,p,b)}return ot(n,t,i,-1,e),n.build()}function St(t,s,o=24){const n=new L,e=Math.max(6,Math.round(o)),c=Math.max(4,Math.round(e/2)),i=[];for(let r=0;r<=e;r++){const a=r/e*_,l=[];for(let f=0;f<=c;f++){const d=f/c*_,u=Math.cos(d)*Math.sin(a),p=Math.sin(d),b=Math.cos(d)*Math.cos(a),y=t+s*Math.cos(d);l.push(n.vertex(y*Math.sin(a),s*Math.sin(d),y*Math.cos(a),u,p,b))}i.push(l)}for(let r=0;r<e;r++)for(let a=0;a<c;a++)n.quad(i[r][a],i[r+1][a],i[r+1][a+1],i[r][a+1]);return n.build()}function Pt(t){switch(t.type){case"box":return vt(t.size);case"plane":return kt(t.size,t.segments);case"sphere":return It(t.radius,t.segments);case"cylinder":return At(t.radius,t.height,t.segments);case"cone":return $t(t.radius,t.height,t.segments);case"torus":return St(t.radius,t.tube,t.segments);case"extrude":return xt(t.path,{depth:t.depth,width:t.width,curveSegments:t.curveSegments})}}function Ct(t){const s=Array.from({length:t.indices.length/3},()=>[]);for(const o of yt(t))for(const n of o.faces){const e=o.faces.find(c=>c!==n)??-1;s[n].push({a:o.a,b:o.b,across:e})}return{...t,faceEdges:s}}function tn(t,s={}){const o=new Map((s.kinds??[]).map(i=>[i.kind,i])),n=Mt(t);for(const i of t.objects){if(nn.has(i.kind))continue;const r=o.get(i.kind);r?n.push(...(r.validate?.(i)??[]).map(a=>`"${i.id}": ${a}`)):n.push(`"${i.id}" is a ${i.kind}: load the scene with that kind (for characters: loadScene3D(scene, { kinds: [characterObjects] }), from @algorisys/tinyfly/characters)`)}if(n.length>0)throw new Error(`scene-3d: "${t.id}" is not valid:
|
|
1
|
+
(function(P){"use strict";const Rt=[{name:"position",vector:"position",components:["x","y","z"]},{name:"rotation",vector:"quaternion",components:["rotateX","rotateY","rotateZ"]}];function Mt(t,s=[]){const o=[],n=new Map;for(const i of t.objects){if(i.id?n.has(i.id)&&o.push(`two objects share the id "${i.id}"`):o.push("an object has no id"),i.parent!==void 0&&!n.has(i.parent)&&o.push(`"${i.id}" has parent "${i.parent}", which must be an earlier object`),i.quaternion&&i.quaternion.length!==4&&o.push(`"${i.id}": a quaternion has four numbers`),i.kind==="mesh"){t.materials?.[i.material]||o.push(`"${i.id}" uses material "${i.material}", which is not in materials`);const r=i.geometry,a=r.type==="box"||r.type==="plane"?r.size:r.type==="torus"?[r.radius,r.tube]:r.type==="sphere"?[r.radius]:r.type==="extrude"?[r.depth,r.width??1]:[r.radius,r.height];r.type==="extrude"&&!(typeof r.path=="string"&&/^\s*[Mm]/.test(r.path))&&o.push(`"${i.id}": an extrude needs a path that starts with M`),a.every(l=>Number.isFinite(l)&&l>0)||o.push(`"${i.id}": a ${r.type}'s sizes must be positive`)}i.kind==="camera"&&(i.near>0&&i.far>i.near||o.push(`camera "${i.id}": near must be above 0 and far beyond it`),i.projection==="perspective"&&!(i.fov>0&&i.fov<180)&&o.push(`camera "${i.id}": fov is between 0 and 180 degrees`),i.projection==="orthographic"&&!(i.height>0)&&o.push(`camera "${i.id}": height must be positive`)),i.id&&n.set(i.id,i)}const e=n.get(t.camera);e?e.kind!=="camera"&&o.push(`the scene's camera "${t.camera}" is a ${e.kind}, not a camera`):o.push(`the scene's camera "${t.camera}" is not one of its objects`),t.fog&&!(t.fog.far>t.fog.near)&&o.push("fog: far must be beyond near");const c=new Map;for(const i of s){if(!i.target.startsWith(`${t.id}/`))continue;const r=i.target.slice(t.id.length+1);c.has(r)||c.set(r,new Set),c.get(r).add(i.property)}for(const[i,r]of c){n.has(i)||o.push(`a track animates "${t.id}/${i}", which is not in the scene`);for(const a of Rt)r.has(a.vector)&&a.components.some(l=>r.has(l))&&o.push(`"${i}": its ${a.name} is animated both by ${a.vector} and by ${a.components.join(" / ")}; use one`)}return o}class L{positions=[];normals=[];indices=[];vertex(s,o,n,e,c,i){const r=Math.hypot(e,c,i)||1;return this.positions.push(s,o,n),this.normals.push(e/r,c/r,i/r),this.positions.length/3-1}triangle(s,o,n){this.indices.push(s,o,n)}quad(s,o,n,e){this.indices.push(s,o,n,s,n,e)}build(){return{positions:this.positions,normals:this.normals,indices:this.indices}}}function mt(t){const s=new Map,o=[];for(let e=0;e<t.positions.length/3;e++){const c=[0,1,2].map(i=>Math.round(t.positions[e*3+i]*1e6)).join(",");s.has(c)||s.set(c,e),o.push(s.get(c))}const n=new Map;for(let e=0;e<t.indices.length/3;e++)for(let c=0;c<3;c++){const i=o[t.indices[e*3+c]],r=o[t.indices[e*3+(c+1)%3]];if(i===r)continue;const a=i<r?`${i}-${r}`:`${r}-${i}`,l=n.get(a);l?l.faces.push(e):n.set(a,{a:Math.min(i,r),b:Math.max(i,r),faces:[e]})}return[...n.values()]}const yt=32,Ut=256,U=new Map,Zt=/[MmLlHhVvCcSsQqTtAaZz]/,Gt=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,Vt={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function Bt(t){const s=[];let o=0,n=null;const e=()=>{for(;o<t.length&&/[\s,]/.test(t[o]);)o++};for(;o<t.length&&(e(),!(o>=t.length));){const c=t[o];if(Zt.test(c)){n={type:c,args:[]},s.push(n),o++;continue}if(!n)break;const i=n.type==="A"||n.type==="a",r=n.args.length%7;if(i&&(r===3||r===4)){if(c!=="0"&&c!=="1")break;n.args.push(c==="1"?1:0),o++;continue}const a=Gt.exec(t.slice(o));if(!a)break;n.args.push(parseFloat(a[0])),o+=a[0].length}return s}function Ft(t,s,o,n,e,c,i,r,a){if(t===r&&s===a)return[];let l=Math.abs(o),u=Math.abs(n);if(l===0||u===0)return[[t,s,r,a,r,a]];const d=e*Math.PI/180,f=Math.cos(d),p=Math.sin(d),b=(t-r)/2,m=(s-a)/2,h=f*b+p*m,g=-p*b+f*m,w=h*h/(l*l)+g*g/(u*u);if(w>1){const E=Math.sqrt(w);l*=E,u*=E}const k=c===i?-1:1,x=l*l*u*u-l*l*g*g-u*u*h*h,M=l*l*g*g+u*u*h*h,A=k*Math.sqrt(Math.max(0,x/M)),y=A*l*g/u,$=-A*u*h/l,j=f*y-p*$+(t+r)/2,I=p*y+f*$+(s+a)/2,v=(E,Y,z,R)=>{const gt=E*z+Y*R,tt=Math.sqrt((E*E+Y*Y)*(z*z+R*R)),B=Math.acos(Math.max(-1,Math.min(1,gt/tt)));return E*R-Y*z<0?-B:B},S=v(1,0,(h-y)/l,(g-$)/u);let T=v((h-y)/l,(g-$)/u,(-h-y)/l,(-g-$)/u);!i&&T>0&&(T-=2*Math.PI),i&&T<0&&(T+=2*Math.PI);const C=Math.max(1,Math.ceil(Math.abs(T)/(Math.PI/2))),V=T/C,Q=4/3*Math.tan(V/4),Dt=E=>{const Y=l*Math.cos(E),z=u*Math.sin(E);return[f*Y-p*z+j,p*Y+f*z+I]},Ht=E=>{const Y=-l*Math.sin(E),z=u*Math.cos(E);return[f*Y-p*z,p*Y+f*z]},Qt=[];for(let E=0;E<C;E++){const Y=S+E*V,z=Y+V,[R,gt]=Dt(Y),[tt,B]=E===C-1?[r,a]:Dt(z),[jn,En]=Ht(Y),[Xn,Yn]=Ht(z);Qt.push([R+Q*jn,gt+Q*En,tt-Q*Xn,B-Q*Yn,tt,B])}return Qt}function bt(t,s,o,n,e){const c=1-e;return c*c*c*t+3*c*c*e*s+3*c*e*e*o+e*e*e*n}function Z(t,s,o,n){return{subpath:0,type:"L",points:[o,n],startX:t,startY:s,endX:o,endY:n,length:Math.hypot(o-t,n-s)}}function F(t,s,o){const[n,e,c,i,r,a]=o,l=[0];let u=t,d=s,f=0;for(let p=1;p<=yt;p++){const b=p/yt,m=bt(t,n,c,r,b),h=bt(s,e,i,a,b);f+=Math.hypot(m-u,h-d),l.push(f),u=m,d=h}return{subpath:0,type:"C",points:[n,e,c,i,r,a],startX:t,startY:s,endX:r,endY:a,length:f,lengths:l}}function Wt(t){const s=U.get(t);if(s)return s;const o=[];let n=0,e=0,c=0,i=0,r=null,a=null,l=-1;const u=new Set,d=m=>{l<0&&(l=0),m.subpath=l,o.push(m)};for(const{type:m,args:h}of Bt(t)){const g=m.toUpperCase(),w=m!==g,k=Vt[g];if(g==="Z"){(n!==c||e!==i)&&d(Z(n,e,c,i)),l>=0&&u.add(l),n=c,e=i,r=a=null;continue}for(let x=0;x+k<=h.length;x+=k){const M=h.slice(x,x+k),A=w?n:0,y=w?e:0;let $=null,j=null;switch(g){case"M":x===0?(n=M[0]+A,e=M[1]+y,c=n,i=e,(l<0||o[o.length-1]?.subpath===l)&&l++):(d(Z(n,e,M[0]+A,M[1]+y)),n=M[0]+A,e=M[1]+y);break;case"L":d(Z(n,e,M[0]+A,M[1]+y)),n=M[0]+A,e=M[1]+y;break;case"H":d(Z(n,e,M[0]+A,e)),n=M[0]+A;break;case"V":d(Z(n,e,n,M[0]+y)),e=M[0]+y;break;case"C":{const I=[M[0]+A,M[1]+y,M[2]+A,M[3]+y,M[4]+A,M[5]+y];d(F(n,e,I)),$=[I[2],I[3]],n=I[4],e=I[5];break}case"S":{const[I,v]=r?[2*n-r[0],2*e-r[1]]:[n,e],S=[I,v,M[0]+A,M[1]+y,M[2]+A,M[3]+y];d(F(n,e,S)),$=[S[2],S[3]],n=S[4],e=S[5];break}case"Q":case"T":{let I=n,v=e;g==="Q"?(I=M[0]+A,v=M[1]+y):a&&(I=2*n-a[0],v=2*e-a[1]);const S=g==="Q"?M[2]+A:M[0]+A,T=g==="Q"?M[3]+y:M[1]+y;d(F(n,e,[n+2/3*(I-n),e+2/3*(v-e),S+2/3*(I-S),T+2/3*(v-T),S,T])),j=[I,v],n=S,e=T;break}case"A":{const I=M[5]+A,v=M[6]+y;let S=n,T=e;for(const C of Ft(n,e,M[0],M[1],M[2],M[3],M[4],I,v))d(F(S,T,C)),S=C[4],T=C[5];n=I,e=v;break}}r=$,a=j}}const f=o.reduce((m,h)=>m+h.length,0),p=[];for(let m=0;m<o.length;){const h=o[m].subpath;let g=m,w=0;for(;g<o.length&&o[g].subpath===h;)w+=o[g++].length;const k=o[m],x=o[g-1],M=u.has(h)||Math.abs(x.endX-k.startX)<1e-9&&Math.abs(x.endY-k.startY)<1e-9;p.push({start:m,end:g,length:w,closed:M}),m=g}const b={segments:o,totalLength:f,subpaths:p};return U.size>=Ut&&U.delete(U.keys().next().value),U.set(t,b),b}function H(t){let s=0;for(let o=0;o<t.length;o++){const n=t[o],e=t[(o+1)%t.length];s+=n.x*e.y-e.x*n.y}return s}function nt(t,s){let o=!1;for(let n=0,e=s.length-1;n<s.length;e=n++){const c=s[n],i=s[e];c.y>t.y!=i.y>t.y&&t.x<(i.x-c.x)*(t.y-c.y)/(i.y-c.y)+c.x&&(o=!o)}return o}const W=(t,s,o)=>(s.x-t.x)*(o.y-t.y)-(s.y-t.y)*(o.x-t.x),et=(t,s)=>t.x===s.x&&t.y===s.y;function st(t,s,o,n){return W(s,o,t)>=0&&W(o,n,t)>=0&&W(n,s,t)>=0}function Jt(t,s){let o=0;for(let f=1;f<s.length;f++)s[f].x>s[o].x&&(o=f);const n=s[o];let e=-1,c=1/0;for(let f=0;f<t.length;f++){const p=t[f],b=t[(f+1)%t.length];if(p.y>n.y==b.y>n.y)continue;const m=p.x+(n.y-p.y)*(b.x-p.x)/(b.y-p.y);m>=n.x&&m<c&&(c=m,e=f)}if(e<0)return t;const i=t[e],r=t[(e+1)%t.length];let a=i.x>r.x?e:(e+1)%t.length;const l={x:c,y:n.y};let u=1/0;for(let f=0;f<t.length;f++){const p=t[f];if(f===a||p.x<n.x)continue;const b=t[a];if(!(st(p,n,l,b)||st(p,n,b,l)))continue;const h=Math.abs(Math.atan2(p.y-n.y,p.x-n.x));h<u&&(u=h,a=f)}const d=s.slice(o).concat(s.slice(0,o));return[...t.slice(0,a+1),...d,n,t[a],...t.slice(a+1)]}function wt(t,s=[]){const o=H(t)>=0?t:[...t].reverse(),n=s.map(d=>H(d)<=0?d:[...d].reverse()),e=[...o,...n.flat()],c=new Map;e.forEach((d,f)=>c.set(d,f));const i=[...n].sort((d,f)=>Math.max(...f.map(p=>p.x))-Math.max(...d.map(p=>p.x)));let r=o;for(const d of i)r=Jt(r,d);const a=r.map(d=>c.get(d)),l=[];let u=a.length*a.length;for(;a.length>3&&u-- >0;){let d=!1;for(let f=0;f<a.length;f++){const p=a[(f+a.length-1)%a.length],b=a[f],m=a[(f+1)%a.length],[h,g,w]=[e[p],e[b],e[m]];if(W(h,g,w)<=0)continue;let k=!1;for(const x of a){const M=e[x];if(!(x===p||x===b||x===m||et(M,h)||et(M,g)||et(M,w))&&st(M,h,g,w)){k=!0;break}}if(!k){l.push(p,b,m),a.splice(f,1),d=!0;break}}d||(l.push(a[a.length-1],a[0],a[1]),a.splice(0,1))}return a.length===3&&l.push(a[0],a[1],a[2]),{points:e,triangles:l}}function Kt(t,s){const o=new Map;for(const n of Wt(t).segments){o.has(n.subpath)||o.set(n.subpath,[{x:n.startX,y:-n.startY}]);const e=o.get(n.subpath);if(n.type==="L")e.push({x:n.endX,y:-n.endY});else{const[c,i,r,a,l,u]=n.points;for(let d=1;d<=s;d++){const f=d/s,p=1-f,b=p*p*p*n.startX+3*p*p*f*c+3*p*f*f*r+f*f*f*l,m=p*p*p*n.startY+3*p*p*f*i+3*p*f*f*a+f*f*f*u;e.push({x:b,y:-m})}}}return[...o.values()].map(n=>n.filter((e,c)=>c===0||e.x!==n[c-1].x||e.y!==n[c-1].y)).map(n=>n.length>1&&n[0].x===n[n.length-1].x&&n[0].y===n[n.length-1].y?n.slice(0,-1):n).filter(n=>n.length>=3&&Math.abs(H(n))>1e-12)}function xt(t,s){const o=Kt(t,Math.max(1,Math.round(s.curveSegments??12))),n=new L;if(o.length===0)return n.build();const e=o.flat(),c=Math.min(...e.map(h=>h.x)),i=Math.max(...e.map(h=>h.x)),r=Math.min(...e.map(h=>h.y)),a=Math.max(...e.map(h=>h.y)),l=(s.width??1)/Math.max(i-c,1e-9),u=(c+i)/2,d=(r+a)/2,f=o.map(h=>h.map(g=>({x:(g.x-u)*l,y:(g.y-d)*l}))),p=f.map((h,g)=>f.filter((w,k)=>k!==g&&nt(h[0],w)).length),b=s.depth/2,m=-s.depth/2;return f.forEach((h,g)=>{if(p[g]%2===1)return;const w=f.filter((y,$)=>p[$]===p[g]+1&&nt(y[0],h)),{points:k,triangles:x}=wt(h,w),M=k.map(y=>n.vertex(y.x,y.y,b,0,0,1)),A=k.map(y=>n.vertex(y.x,y.y,m,0,0,-1));for(let y=0;y<x.length;y+=3)n.triangle(M[x[y]],M[x[y+1]],M[x[y+2]]),n.triangle(A[x[y]],A[x[y+2]],A[x[y+1]]);for(const y of[H(h)>=0?h:[...h].reverse(),...w.map($=>H($)<=0?$:[...$].reverse())])for(let $=0;$<y.length;$++){const j=y[$],I=y[($+1)%y.length],v=I.y-j.y,S=-(I.x-j.x),T=n.vertex(j.x,j.y,m,v,S,0),C=n.vertex(I.x,I.y,m,v,S,0),V=n.vertex(I.x,I.y,b,v,S,0),Q=n.vertex(j.x,j.y,b,v,S,0);n.quad(T,C,V,Q)}}),n.build()}const _=Math.PI*2;function vt([t,s,o]){const n=new L,e=t/2,c=s/2,i=o/2,r=[[[0,0,1],[[-e,-c,i],[e,-c,i],[e,c,i],[-e,c,i]]],[[0,0,-1],[[e,-c,-i],[-e,-c,-i],[-e,c,-i],[e,c,-i]]],[[1,0,0],[[e,-c,i],[e,-c,-i],[e,c,-i],[e,c,i]]],[[-1,0,0],[[-e,-c,-i],[-e,-c,i],[-e,c,i],[-e,c,-i]]],[[0,1,0],[[-e,c,i],[e,c,i],[e,c,-i],[-e,c,-i]]],[[0,-1,0],[[-e,-c,-i],[e,-c,-i],[e,-c,i],[-e,-c,i]]]];for(const[[a,l,u],d]of r){const[f,p,b,m]=d.map(([h,g,w])=>n.vertex(h,g,w,a,l,u));n.quad(f,p,b,m)}return n.build()}function kt([t,s],o=1){const n=new L,e=Math.max(1,Math.round(o)),c=[];for(let i=0;i<=e;i++){const r=s/2-s*i/e;c.push(Array.from({length:e+1},(a,l)=>n.vertex(-t/2+t*l/e,0,r,0,1,0)))}for(let i=0;i<e;i++)for(let r=0;r<e;r++)n.quad(c[i][r],c[i][r+1],c[i+1][r+1],c[i+1][r]);return n.build()}function It(t,s=16){const o=new L,n=Math.max(6,Math.round(s)),e=Math.max(3,Math.round(n/2)),c=[];for(let i=0;i<=e;i++){const r=i/e*Math.PI,a=[];for(let l=0;l<=n;l++){const u=l/n*_,d=Math.sin(r)*Math.sin(u),f=Math.cos(r),p=Math.sin(r)*Math.cos(u);a.push(o.vertex(d*t,f*t,p*t,d,f,p))}c.push(a)}for(let i=0;i<e;i++)for(let r=0;r<n;r++){const a=c[i][r],l=c[i+1][r],u=c[i+1][r+1],d=c[i][r+1];i>0&&o.triangle(a,l,d),i<e-1&&o.triangle(l,u,d)}return o.build()}function ot(t,s,o,n,e){const c=t.vertex(0,o,0,0,n,0),i=Array.from({length:e},(r,a)=>{const l=a/e*_;return t.vertex(Math.sin(l)*s,o,Math.cos(l)*s,0,n,0)});for(let r=0;r<e;r++){const a=i[r],l=i[(r+1)%e];n===1?t.triangle(c,a,l):t.triangle(c,l,a)}}function At(t,s,o=24){const n=new L,e=Math.max(6,Math.round(o)),c=s/2,i=-s/2,r=u=>Array.from({length:e+1},(d,f)=>{const p=f/e*_;return n.vertex(Math.sin(p)*t,u,Math.cos(p)*t,Math.sin(p),0,Math.cos(p))}),a=r(i),l=r(c);for(let u=0;u<e;u++)n.quad(a[u],a[u+1],l[u+1],l[u]);return ot(n,t,c,1,e),ot(n,t,i,-1,e),n.build()}function $t(t,s,o=24){const n=new L,e=Math.max(6,Math.round(o)),c=s/2,i=-s/2,r=t/s;for(let a=0;a<e;a++){const l=a/e*_,u=(a+1)/e*_,d=(l+u)/2,f=n.vertex(Math.sin(l)*t,i,Math.cos(l)*t,Math.sin(l),r,Math.cos(l)),p=n.vertex(Math.sin(u)*t,i,Math.cos(u)*t,Math.sin(u),r,Math.cos(u)),b=n.vertex(0,c,0,Math.sin(d),r,Math.cos(d));n.triangle(f,p,b)}return ot(n,t,i,-1,e),n.build()}function St(t,s,o=24){const n=new L,e=Math.max(6,Math.round(o)),c=Math.max(4,Math.round(e/2)),i=[];for(let r=0;r<=e;r++){const a=r/e*_,l=[];for(let u=0;u<=c;u++){const d=u/c*_,f=Math.cos(d)*Math.sin(a),p=Math.sin(d),b=Math.cos(d)*Math.cos(a),m=t+s*Math.cos(d);l.push(n.vertex(m*Math.sin(a),s*Math.sin(d),m*Math.cos(a),f,p,b))}i.push(l)}for(let r=0;r<e;r++)for(let a=0;a<c;a++)n.quad(i[r][a],i[r+1][a],i[r+1][a+1],i[r][a+1]);return n.build()}function Pt(t){switch(t.type){case"box":return vt(t.size);case"plane":return kt(t.size,t.segments);case"sphere":return It(t.radius,t.segments);case"cylinder":return At(t.radius,t.height,t.segments);case"cone":return $t(t.radius,t.height,t.segments);case"torus":return St(t.radius,t.tube,t.segments);case"extrude":return xt(t.path,{depth:t.depth,width:t.width,curveSegments:t.curveSegments})}}function Ct(t){const s=Array.from({length:t.indices.length/3},()=>[]);for(const o of mt(t))for(const n of o.faces){const e=o.faces.find(c=>c!==n)??-1;s[n].push({a:o.a,b:o.b,across:e})}return{...t,faceEdges:s}}function tn(t,s={}){const o=new Map((s.kinds??[]).map(i=>[i.kind,i])),n=Mt(t);for(const i of t.objects){if(nn.has(i.kind))continue;const r=o.get(i.kind);r?n.push(...(r.validate?.(i)??[]).map(a=>`"${i.id}": ${a}`)):n.push(`"${i.id}" is a ${i.kind}: load the scene with that kind (for characters: loadScene3D(scene, { kinds: [characterObjects] }), from @algorisys/tinyfly/characters)`)}if(n.length>0)throw new Error(`scene-3d: "${t.id}" is not valid:
|
|
2
2
|
- ${n.join(`
|
|
3
|
-
- `)}`);const e=new Map,c=new Map;for(const i of t.objects){i.kind==="mesh"&&e.set(i.id,Ct(Pt(i.geometry)));const r=o.get(i.kind);r?.prepare&&c.set(i.id,r.prepare(i))}return{scene:t,meshes:e,kinds:o,prepared:c}}const nn=new Set(["group","mesh","camera","light"]);function it(t,s){return[t[0]+s[0],t[1]+s[1],t[2]+s[2]]}function N(t,s){return[t[0]-s[0],t[1]-s[1],t[2]-s[2]]}function D(t,s){return[t[0]*s,t[1]*s,t[2]*s]}function O(t,s){return t[0]*s[0]+t[1]*s[1]+t[2]*s[2]}function ct(t,s){return[t[1]*s[2]-t[2]*s[1],t[2]*s[0]-t[0]*s[2],t[0]*s[1]-t[1]*s[0]]}function W(t){return Math.hypot(t[0],t[1],t[2])}function en(t,s){return W(N(t,s))}function q(t){const s=W(t);return s===0?[0,0,0]:D(t,1/s)}function sn(t,s,o){return[t[0]+(s[0]-t[0])*o,t[1]+(s[1]-t[1])*o,t[2]+(s[2]-t[2])*o]}const on=Math.PI/180;function rt(){return[0,0,0,1]}function at(t,s){const o=Math.hypot(t[0],t[1],t[2]);if(o===0)return rt();const n=s*on/2,e=Math.sin(n)/o;return[t[0]*e,t[1]*e,t[2]*e,Math.cos(n)]}function Tt(t,s,o){return jt(jt(at([0,1,0],s),at([1,0,0],t)),at([0,0,1],o))}function jt(t,s){const[o,n,e,c]=t,[i,r,a,l]=s;return[c*i+o*l+n*a-e*r,c*r-o*a+n*l+e*i,c*a+o*r-n*i+e*l,c*l-o*i-n*r-e*a]}function cn(t){return Math.hypot(t[0],t[1],t[2],t[3])}function Et(t){const s=cn(t);return s===0?rt():[t[0]/s,t[1]/s,t[2]/s,t[3]/s]}const rn=Math.PI/180;function Xt(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function an(t,s){const o=new Array(16);for(let n=0;n<4;n++)for(let e=0;e<4;e++){let c=0;for(let i=0;i<4;i++)c+=t[i*4+e]*s[n*4+i];o[n*4+e]=c}return o}function hn(t){const[s,o,n,e]=t;return[1-2*(o*o+n*n),2*(s*o+n*e),2*(s*n-o*e),0,2*(s*o-n*e),1-2*(s*s+n*n),2*(o*n+s*e),0,2*(s*n+o*e),2*(o*n-s*e),1-2*(s*s+o*o),0,0,0,0,1]}function ln(t,s,o){const n=hn(s);for(let e=0;e<3;e++)n[e]*=o[0],n[4+e]*=o[1],n[8+e]*=o[2];return n[12]=t[0],n[13]=t[1],n[14]=t[2],n}function un(t){const s=new Array(16);for(let o=0;o<4;o++)for(let n=0;n<4;n++)s[n*4+o]=t[o*4+n];return s}function Yt(t){const[s,o,n,e,c,i,r,a,l,f,d,u,p,b,y,h]=t,g=s*i-o*c,w=s*r-n*c,k=s*a-e*c,x=o*r-n*i,M=o*a-e*i,A=n*a-e*r,m=l*b-f*p,$=l*y-d*p,j=l*h-u*p,I=f*y-d*b,v=f*h-u*b,S=d*h-u*y,T=g*S-w*v+k*I+x*j-M*$+A*m;if(Math.abs(T)<1e-12)return null;const C=1/T;return[(i*S-r*v+a*I)*C,(n*v-o*S-e*I)*C,(b*A-y*M+h*x)*C,(d*M-f*A-u*x)*C,(r*j-c*S-a*$)*C,(s*S-n*j+e*$)*C,(y*k-p*A-h*w)*C,(l*A-d*k+u*w)*C,(c*v-i*j+a*m)*C,(o*j-s*v-e*m)*C,(p*M-b*k+h*g)*C,(f*k-l*M-u*g)*C,(i*$-c*I-r*m)*C,(s*I-o*$+n*m)*C,(b*w-p*x-y*g)*C,(l*x-f*w+d*g)*C]}function fn(t,s,o,n){const e=1/Math.tan(t*rn/2),c=1/(o-n);return[e/s,0,0,0,0,e,0,0,0,0,(n+o)*c,-1,0,0,2*n*o*c,0]}function dn(t,s,o,n,e,c){const i=1/(s-t),r=1/(n-o),a=1/(c-e);return[2*i,0,0,0,0,2*r,0,0,0,0,-2*a,0,-(s+t)*i,-(n+o)*r,-(c+e)*a,1]}function pn(t,s,o=[0,1,0]){const n=q(N(t,s)),e=q(ct(o,n)),c=ct(n,e);return[e[0],c[0],n[0],0,e[1],c[1],n[1],0,e[2],c[2],n[2],0,-O(e,t),-O(c,t),-O(n,t),1]}function ht(t,s){const o=t[0]*s[0]+t[4]*s[1]+t[8]*s[2]+t[12],n=t[1]*s[0]+t[5]*s[1]+t[9]*s[2]+t[13],e=t[2]*s[0]+t[6]*s[1]+t[10]*s[2]+t[14],c=t[3]*s[0]+t[7]*s[1]+t[11]*s[2]+t[15];return c===1||c===0?[o,n,e]:[o/c,n/c,e/c]}function zt(t,s){const o=q(N(s,t)),n=Math.abs(o[1])>.9999?[0,0,-1]:[0,1,0];return pn(t,s,n)}function gn(t,s,o,n){const e=s*Math.PI/180,c=o*Math.PI/180;return[t[0]+n*Math.cos(c)*Math.sin(e),t[1]+n*Math.sin(c),t[2]+n*Math.cos(c)*Math.cos(e)]}function Mn(t,s,o){const n=N(t,s),e=W(n);if(e===0)return t;const c=Math.max(.001,e-o);return it(s,D(n,c/e))}function lt(t,s){if(t.projection==="perspective")return fn(t.fov,s,t.near,t.far);const o=t.height/2;return dn(-o*s,o*s,-o,o,t.near,t.far)}const yn=Math.cos(30*Math.PI/180),mn=new Map,X=t=>typeof t=="number"?t:void 0,J=(t,s)=>Array.isArray(t)&&t.length===s?t:void 0;function bn(t,s){const o=t.position??[0,0,0],n=J(s.get("position"),3)??[X(s.get("x"))??o[0],X(s.get("y"))??o[1],X(s.get("z"))??o[2]];let e;const c=J(s.get("quaternion"),4),i=["rotateX","rotateY","rotateZ"].map(f=>X(s.get(f)));if(c)e=Et(c);else if(i.some(f=>f!==void 0)){const f=t.rotation??[0,0,0];e=Tt(i[0]??f[0],i[1]??f[1],i[2]??f[2])}else t.quaternion?e=Et(t.quaternion):e=t.rotation?Tt(...t.rotation):rt();const r=typeof t.scale=="number"?[t.scale,t.scale,t.scale]:t.scale??[1,1,1],a=X(s.get("scale")),l=[X(s.get("scaleX"))??a??r[0],X(s.get("scaleY"))??a??r[1],X(s.get("scaleZ"))??a??r[2]];return ln(n,e,l)}const Nt=t=>[t[12],t[13],t[14]];function wn(t,s,o,n){const e=Nt(s),c=J(o.get("lookAt"),3)??t.lookAt,i=c?zt(e,c):Yt(s)??Xt(),r=t.projection==="perspective"?lt({...t,fov:X(o.get("fov"))??t.fov},n):lt({...t,height:X(o.get("height"))??t.height},n);return{id:t.id,view:i,projection:r,position:e,forward:q([-i[2],-i[6],-i[10]]),orthographic:t.projection==="orthographic",near:t.near,far:t.far}}function Lt(t){return un(Yt(t)??Xt())}function xn(t,s,o,n){return q([t[0]*s+t[4]*o+t[8]*n,t[1]*s+t[5]*o+t[9]*n,t[2]*s+t[6]*o+t[10]*n])}function vn(t,s){const o=e=>-e[2]>=s,n=[];for(let e=0;e<t.length;e++){const c=t[e],i=t[(e+1)%t.length];if(o(c)&&n.push(c),o(c)!==o(i)){const r=(-s-c[2])/(i[2]-c[2]);n.push(sn(c,i,r))}}return n}function ut(t,s=new Map,o){const{scene:n}=t,e=h=>s.get(`${n.id}/${h}`)??mn,c=new Map,i=new Map;for(const h of n.objects){const g=e(h.id),w=bn(h,g),k=h.parent?c.get(h.parent):void 0;c.set(h.id,k?an(k,w):w);const x=X(g.get("visible"))!==void 0?X(g.get("visible"))>.5:h.visible!==!1;i.set(h.id,x&&(h.parent?i.get(h.parent)!==!1:!0))}const r=s.get(n.id)?.get("activeCamera"),a=typeof r=="string"&&n.objects.some(h=>h.id===r&&h.kind==="camera")?r:n.camera,l=n.objects.find(h=>h.id===a),f=wn(l,c.get(a),e(a),o.width/o.height),d=h=>{const g=ht(f.projection,h);return{x:(g[0]+1)/2*o.width,y:(1-g[1])/2*o.height}},u=[];for(const h of n.objects){if(h.kind!=="light"||!i.get(h.id))continue;const g=e(h.id),w=Nt(c.get(h.id)),k=J(g.get("target"),3)??h.target??[0,0,0],x=g.get("color");u.push({id:h.id,light:h.light,color:typeof x=="string"?x:h.color,intensity:X(g.get("intensity"))??h.intensity,position:w,direction:q(N(k,w)),range:h.range,angle:h.angle??30})}const p=[],b=[];n.objects.forEach((h,g)=>{if(h.kind!=="mesh"||!i.get(h.id))return;const w=t.meshes.get(h.id),k=n.materials?.[h.material];if(!w||!k)return;const x=e(h.id),M=c.get(h.id),A=Lt(M),m=x.get("color"),$=(X(x.get("opacity"))??1)*(k.opacity??1);$<=0||(b.push({objectId:h.id,objectIndex:g,mesh:w,world:M,material:k,color:typeof m=="string"?m:void 0,opacity:$}),p.push(...Ot(w,M,A,f,d,k,{objectId:h.id,objectIndex:g,layer:h.layer??0,color:typeof m=="string"?m:void 0,opacity:$})))});const y=[];return n.objects.forEach((h,g)=>{const w=t.kinds.get(h.kind);if(!w||!i.get(h.id))return;const k=w.resolve({object:h,prepared:t.prepared.get(h.id),values:e(h.id),world:c.get(h.id),camera:f,width:o.width,height:o.height,toScreen:d});if(!k)return;const x=h.layer??0;for(const M of k.drawables??[])y.push({...M,objectId:h.id,objectIndex:g,layer:x});for(const M of k.meshes??[])b.push({objectId:h.id,objectIndex:g,mesh:M.mesh,world:M.world,material:M.material,opacity:M.material.opacity??1}),p.push(...Ot(M.mesh,M.world,Lt(M.world),f,d,M.material,{objectId:h.id,objectIndex:g,layer:x,opacity:M.material.opacity??1}))}),y.sort((h,g)=>h.layer-g.layer||g.depth-h.depth||h.objectIndex-g.objectIndex),p.sort((h,g)=>h.layer-g.layer||g.depth-h.depth||h.objectIndex-g.objectIndex||h.face-g.face||h.part-g.part),{id:n.id,width:o.width,height:o.height,background:n.background,fog:n.fog,camera:f,lights:u,worlds:c,triangles:p,drawables:y,meshes:b,time:o.time??0}}function Ot(t,s,o,n,e,c,i){const r=t.positions.length/3,a=[],l=[];for(let y=0;y<r;y++){const h=ht(s,[t.positions[y*3],t.positions[y*3+1],t.positions[y*3+2]]);a.push(h),l.push(ht(n.view,h))}const f=t.indices.length/3,d=[],u=[];for(let y=0;y<f;y++){const[h,g,w]=[0,1,2].map(M=>a[t.indices[y*3+M]]),k=q(ct(N(g,h),N(w,h)));d.push(k);const x=n.orthographic?D(n.forward,-1):N(n.position,h);u.push(O(k,x)>0)}const p=y=>-l[y][2]>=n.near,b=[];for(let y=0;y<f;y++){const h=u[y];if(!h&&!c.doubleSided)continue;const g=[t.indices[y*3],t.indices[y*3+1],t.indices[y*3+2]],w=g.map(v=>l[v]);if(w.every(v=>-v[2]>n.far))continue;const k=vn(w,n.near);if(k.length<3)continue;const x=h?1:-1,M=D(d[y],x),A=g.map(v=>D(xn(o,t.normals[v*3],t.normals[v*3+1],t.normals[v*3+2]),x)),m=D(it(it(a[g[0]],a[g[1]]),a[g[2]]),1/3),$=-(w[0][2]+w[1][2]+w[2][2])/3,j=[];if(c.outline&&h)for(const v of t.faceEdges[y]){const S=v.across,T=S===-1||!u[S],C=!T&&y<S&&O(d[y],d[S])<yn;(T||C)&&p(v.a)&&p(v.b)&&j.push([e(l[v.a]),e(l[v.b])])}const I=k.map(e);for(let v=1;v+1<I.length;v++)b.push({objectId:i.objectId,objectIndex:i.objectIndex,layer:i.layer,face:y,part:v-1,screen:[I[0],I[v],I[v+1]],depth:$,centroid:m,normal:M,vertexNormals:A,material:c,color:i.color,opacity:i.opacity,outline:v===1?j:[]})}return b}const ft=new Map;function K(t){const s=ft.get(t);if(s)return s;let o=[1,1,1];const n=t.trim().replace("#","");if(t.trim().startsWith("#")&&(n.length===3||n.length===6)){const e=n.length===3?n.split("").map(c=>c+c).join(""):n;o=[0,2,4].map(c=>Number.parseInt(e.slice(c,c+2),16)/255)}else{const e=t.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/);e&&(o=[Number(e[1])/255,Number(e[2])/255,Number(e[3])/255])}return ft.size<512&&ft.set(t,o),o}const kn=[{id:"default-ambient",light:"ambient",color:"#ffffff",intensity:.35,position:[0,0,0],direction:[0,-1,0],angle:30},{id:"default-key",light:"directional",color:"#ffffff",intensity:.8,position:[3,5,4],direction:q([-3,-5,-4]),angle:30}],In=(t,s,o)=>{const n=Math.min(1,Math.max(0,(o-t)/(s-t)));return n*n*(3-2*n)};function dt(t,s,o){const n=[0,0,0];for(const e of o){const c=K(e.color);let i;if(e.light==="ambient")i=e.intensity;else if(e.light==="directional")i=e.intensity*Math.max(0,-O(s,e.direction));else{const r=N(e.position,t),a=W(r),l=a>0?D(r,1/a):s,f=e.range?Math.max(0,1-a/e.range)**2:1;if(i=e.intensity*Math.max(0,O(s,l))*f,e.light==="spot"){const d=Math.cos(e.angle*Math.PI/180),u=Math.cos(e.angle*.8*Math.PI/180);i*=In(d,u,-O(l,e.direction))}}n[0]+=c[0]*i,n[1]+=c[1]*i,n[2]+=c[2]*i}return n}function An(t,s){const o=Math.max(2,Math.round(s));return Math.min(1.2,Math.ceil(Math.min(1,t)*o-1e-9)/o)}function qt(t,s){return t?Math.min(1,Math.max(0,(s-t.near)/(t.far-t.near))):0}function _t(t,s,o,n){const e=t.material,c=K(t.color??e.color),i=e.shading??"lambert";let r;if(i==="unlit")r=[...c];else{const f=s.length>0?s:kn;let d;if(i==="lambert"){const u=[0,0,0];for(const p of t.vertexNormals){const b=dt(t.centroid,p,f);u[0]+=b[0]/3,u[1]+=b[1]/3,u[2]+=b[2]/3}d=u}else if(d=dt(t.centroid,t.normal,f),i==="toon"){const u=Math.max(d[0],d[1],d[2]),p=u>0?An(u,e.bands??3)/u:0;d=[d[0]*p,d[1]*p,d[2]*p]}r=[c[0]*d[0],c[1]*d[1],c[2]*d[2]]}const a=qt(n,en(t.centroid,o.position));if(n&&a>0){const f=K(n.color);r=[r[0]+(f[0]-r[0])*a,r[1]+(f[1]-r[1])*a,r[2]+(f[2]-r[2])*a]}const l=f=>Math.round(Math.min(1,Math.max(0,f))*255);return{color:`rgb(${l(r[0])}, ${l(r[1])}, ${l(r[2])})`,alpha:t.opacity}}class $n{ctx;constructor(s){this.ctx=s}render(s){pt(this.ctx,s)}}function pt(t,s){t.save(),s.background&&s.background!=="transparent"&&(t.fillStyle=s.background,t.fillRect(0,0,s.width,s.height)),t.lineJoin="round",t.lineCap="round";let o=0;const n=(i,r)=>{for(;o<s.drawables.length;){const a=s.drawables[o];if(a.layer>i||a.layer===i&&a.depth<=r)break;t.save(),a.draw(t,s),t.restore(),o++}};let e=[];const c=i=>{if(e.length===0)return;const r=[];for(const a of e)i&&i.objectId===a.objectId&&i.layer===a.layer&&a.depth-i.depth<=Sn*a.depth?r.push(a):Pn(t,a.triangle);e=r};for(const i of s.triangles){c(i),n(i.layer,i.depth);const{color:r,alpha:a}=_t(i,s.lights,s.camera,s.fog),[l,f,d]=i.screen;t.globalAlpha=a,t.beginPath(),t.moveTo(l.x,l.y),t.lineTo(f.x,f.y),t.lineTo(d.x,d.y),t.closePath(),t.fillStyle=r,t.fill(),a>=1&&(t.strokeStyle=r,t.lineWidth=.75,t.stroke()),i.material.outline&&i.outline.length>0&&e.push({objectId:i.objectId,layer:i.layer,depth:i.depth,triangle:i})}c(),n(1/0,-1/0),t.restore()}const Sn=.04;function Pn(t,s){const o=s.material.outline;t.globalAlpha=s.opacity,t.strokeStyle=o.color,t.lineWidth=o.width,t.beginPath();for(const[n,e]of s.outline)t.moveTo(n.x,n.y),t.lineTo(e.x,e.y);t.stroke()}class Cn{renderer;width;height;scenes=new Map;values=new Map;constructor(s,o){this.renderer=s,this.width=o.width,this.height=o.height}registerScene(s){this.scenes.set(s.scene.id,s)}unregisterScene(s){this.scenes.delete(s)}resize(s,o){this.width=s,this.height=o}applyState(s){this.values=s.values,this.time=s.currentTime??this.time}time=0;render(){for(const s of this.scenes.values())this.renderer.render(ut(s,this.values,{width:this.width,height:this.height,time:this.time}))}}function Tn(t,s,o,n){pt(t,ut(s,o??new Map,{width:n.width,height:n.height,time:n.time}))}P.Canvas2DRenderer=$n,P.MeshBuilder=L,P.Scene3DAdapter=Cn,P.boxMesh=vt,P.coneMesh=$t,P.cylinderMesh=At,P.dollyPosition=Mn,P.drawResolvedScene=pt,P.drawScene3D=Tn,P.extrudeMesh=xt,P.fogAmount=qt,P.geometryMesh=Pt,P.lightAt=dt,P.loadScene3D=tn,P.lookAtView=zt,P.meshEdges=yt,P.orbitPosition=gn,P.parseColor=K,P.planeMesh=kt,P.pointInPolygon=nt,P.prepareMesh=Ct,P.projectionMatrix=lt,P.resolveScene3D=ut,P.shadeTriangle=_t,P.signedArea=H,P.sphereMesh=It,P.torusMesh=St,P.triangulate=wt,P.validateScene3D=Mt,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})})(this.tinyfly=this.tinyfly||{});
|
|
3
|
+
- `)}`);const e=new Map,c=new Map;for(const i of t.objects){i.kind==="mesh"&&e.set(i.id,Ct(Pt(i.geometry)));const r=o.get(i.kind);r?.prepare&&c.set(i.id,r.prepare(i))}return{scene:t,meshes:e,kinds:o,prepared:c}}const nn=new Set(["group","mesh","camera","light"]);function it(t,s){return[t[0]+s[0],t[1]+s[1],t[2]+s[2]]}function N(t,s){return[t[0]-s[0],t[1]-s[1],t[2]-s[2]]}function D(t,s){return[t[0]*s,t[1]*s,t[2]*s]}function O(t,s){return t[0]*s[0]+t[1]*s[1]+t[2]*s[2]}function ct(t,s){return[t[1]*s[2]-t[2]*s[1],t[2]*s[0]-t[0]*s[2],t[0]*s[1]-t[1]*s[0]]}function J(t){return Math.hypot(t[0],t[1],t[2])}function en(t,s){return J(N(t,s))}function q(t){const s=J(t);return s===0?[0,0,0]:D(t,1/s)}function sn(t,s,o){return[t[0]+(s[0]-t[0])*o,t[1]+(s[1]-t[1])*o,t[2]+(s[2]-t[2])*o]}const on=Math.PI/180;function rt(){return[0,0,0,1]}function at(t,s){const o=Math.hypot(t[0],t[1],t[2]);if(o===0)return rt();const n=s*on/2,e=Math.sin(n)/o;return[t[0]*e,t[1]*e,t[2]*e,Math.cos(n)]}function Tt(t,s,o){return jt(jt(at([0,1,0],s),at([1,0,0],t)),at([0,0,1],o))}function jt(t,s){const[o,n,e,c]=t,[i,r,a,l]=s;return[c*i+o*l+n*a-e*r,c*r-o*a+n*l+e*i,c*a+o*r-n*i+e*l,c*l-o*i-n*r-e*a]}function cn(t){return Math.hypot(t[0],t[1],t[2],t[3])}function Et(t){const s=cn(t);return s===0?rt():[t[0]/s,t[1]/s,t[2]/s,t[3]/s]}const rn=Math.PI/180;function Xt(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function an(t,s){const o=new Array(16);for(let n=0;n<4;n++)for(let e=0;e<4;e++){let c=0;for(let i=0;i<4;i++)c+=t[i*4+e]*s[n*4+i];o[n*4+e]=c}return o}function hn(t){const[s,o,n,e]=t;return[1-2*(o*o+n*n),2*(s*o+n*e),2*(s*n-o*e),0,2*(s*o-n*e),1-2*(s*s+n*n),2*(o*n+s*e),0,2*(s*n+o*e),2*(o*n-s*e),1-2*(s*s+o*o),0,0,0,0,1]}function ln(t,s,o){const n=hn(s);for(let e=0;e<3;e++)n[e]*=o[0],n[4+e]*=o[1],n[8+e]*=o[2];return n[12]=t[0],n[13]=t[1],n[14]=t[2],n}function un(t){const s=new Array(16);for(let o=0;o<4;o++)for(let n=0;n<4;n++)s[n*4+o]=t[o*4+n];return s}function Yt(t){const[s,o,n,e,c,i,r,a,l,u,d,f,p,b,m,h]=t,g=s*i-o*c,w=s*r-n*c,k=s*a-e*c,x=o*r-n*i,M=o*a-e*i,A=n*a-e*r,y=l*b-u*p,$=l*m-d*p,j=l*h-f*p,I=u*m-d*b,v=u*h-f*b,S=d*h-f*m,T=g*S-w*v+k*I+x*j-M*$+A*y;if(Math.abs(T)<1e-12)return null;const C=1/T;return[(i*S-r*v+a*I)*C,(n*v-o*S-e*I)*C,(b*A-m*M+h*x)*C,(d*M-u*A-f*x)*C,(r*j-c*S-a*$)*C,(s*S-n*j+e*$)*C,(m*k-p*A-h*w)*C,(l*A-d*k+f*w)*C,(c*v-i*j+a*y)*C,(o*j-s*v-e*y)*C,(p*M-b*k+h*g)*C,(u*k-l*M-f*g)*C,(i*$-c*I-r*y)*C,(s*I-o*$+n*y)*C,(b*w-p*x-m*g)*C,(l*x-u*w+d*g)*C]}function fn(t,s,o,n){const e=1/Math.tan(t*rn/2),c=1/(o-n);return[e/s,0,0,0,0,e,0,0,0,0,(n+o)*c,-1,0,0,2*n*o*c,0]}function dn(t,s,o,n,e,c){const i=1/(s-t),r=1/(n-o),a=1/(c-e);return[2*i,0,0,0,0,2*r,0,0,0,0,-2*a,0,-(s+t)*i,-(n+o)*r,-(c+e)*a,1]}function pn(t,s,o=[0,1,0]){const n=q(N(t,s)),e=q(ct(o,n)),c=ct(n,e);return[e[0],c[0],n[0],0,e[1],c[1],n[1],0,e[2],c[2],n[2],0,-O(e,t),-O(c,t),-O(n,t),1]}function ht(t,s){const o=t[0]*s[0]+t[4]*s[1]+t[8]*s[2]+t[12],n=t[1]*s[0]+t[5]*s[1]+t[9]*s[2]+t[13],e=t[2]*s[0]+t[6]*s[1]+t[10]*s[2]+t[14],c=t[3]*s[0]+t[7]*s[1]+t[11]*s[2]+t[15];return c===1||c===0?[o,n,e]:[o/c,n/c,e/c]}function zt(t,s){const o=q(N(s,t)),n=Math.abs(o[1])>.9999?[0,0,-1]:[0,1,0];return pn(t,s,n)}function gn(t,s,o,n){const e=s*Math.PI/180,c=o*Math.PI/180;return[t[0]+n*Math.cos(c)*Math.sin(e),t[1]+n*Math.sin(c),t[2]+n*Math.cos(c)*Math.cos(e)]}function Mn(t,s,o){const n=N(t,s),e=J(n);if(e===0)return t;const c=Math.max(.001,e-o);return it(s,D(n,c/e))}function lt(t,s){if(t.projection==="perspective")return fn(t.fov,s,t.near,t.far);const o=t.height/2;return dn(-o*s,o*s,-o,o,t.near,t.far)}const mn=Math.cos(30*Math.PI/180),yn=new Map,X=t=>typeof t=="number"?t:void 0,K=(t,s)=>Array.isArray(t)&&t.length===s?t:void 0;function bn(t,s){const o=t.position??[0,0,0],n=K(s.get("position"),3)??[X(s.get("x"))??o[0],X(s.get("y"))??o[1],X(s.get("z"))??o[2]];let e;const c=K(s.get("quaternion"),4),i=["rotateX","rotateY","rotateZ"].map(u=>X(s.get(u)));if(c)e=Et(c);else if(i.some(u=>u!==void 0)){const u=t.rotation??[0,0,0];e=Tt(i[0]??u[0],i[1]??u[1],i[2]??u[2])}else t.quaternion?e=Et(t.quaternion):e=t.rotation?Tt(...t.rotation):rt();const r=typeof t.scale=="number"?[t.scale,t.scale,t.scale]:t.scale??[1,1,1],a=X(s.get("scale")),l=[X(s.get("scaleX"))??a??r[0],X(s.get("scaleY"))??a??r[1],X(s.get("scaleZ"))??a??r[2]];return ln(n,e,l)}const Nt=t=>[t[12],t[13],t[14]];function wn(t,s,o,n){const e=Nt(s),c=K(o.get("lookAt"),3)??t.lookAt,i=c?zt(e,c):Yt(s)??Xt(),r=t.projection==="perspective"?lt({...t,fov:X(o.get("fov"))??t.fov},n):lt({...t,height:X(o.get("height"))??t.height},n);return{id:t.id,view:i,projection:r,position:e,forward:q([-i[2],-i[6],-i[10]]),orthographic:t.projection==="orthographic",near:t.near,far:t.far}}function Lt(t){return un(Yt(t)??Xt())}function xn(t,s,o,n){return q([t[0]*s+t[4]*o+t[8]*n,t[1]*s+t[5]*o+t[9]*n,t[2]*s+t[6]*o+t[10]*n])}function vn(t,s){const o=e=>-e[2]>=s,n=[];for(let e=0;e<t.length;e++){const c=t[e],i=t[(e+1)%t.length];if(o(c)&&n.push(c),o(c)!==o(i)){const r=(-s-c[2])/(i[2]-c[2]);n.push(sn(c,i,r))}}return n}function ut(t,s=new Map,o){const{scene:n}=t,e=h=>s.get(`${n.id}/${h}`)??yn,c=new Map,i=new Map;for(const h of n.objects){const g=e(h.id),w=bn(h,g),k=h.parent?c.get(h.parent):void 0;c.set(h.id,k?an(k,w):w);const x=X(g.get("visible"))!==void 0?X(g.get("visible"))>.5:h.visible!==!1;i.set(h.id,x&&(h.parent?i.get(h.parent)!==!1:!0))}const r=s.get(n.id)?.get("activeCamera"),a=typeof r=="string"&&n.objects.some(h=>h.id===r&&h.kind==="camera")?r:n.camera,l=n.objects.find(h=>h.id===a),u=wn(l,c.get(a),e(a),o.width/o.height),d=h=>{const g=ht(u.projection,h);return{x:(g[0]+1)/2*o.width,y:(1-g[1])/2*o.height}},f=[];for(const h of n.objects){if(h.kind!=="light"||!i.get(h.id))continue;const g=e(h.id),w=Nt(c.get(h.id)),k=K(g.get("target"),3)??h.target??[0,0,0],x=g.get("color");f.push({id:h.id,light:h.light,color:typeof x=="string"?x:h.color,intensity:X(g.get("intensity"))??h.intensity,position:w,direction:q(N(k,w)),range:h.range,angle:h.angle??30})}const p=[],b=[];n.objects.forEach((h,g)=>{if(h.kind!=="mesh"||!i.get(h.id))return;const w=t.meshes.get(h.id),k=n.materials?.[h.material];if(!w||!k)return;const x=e(h.id),M=c.get(h.id),A=Lt(M),y=x.get("color"),$=(X(x.get("opacity"))??1)*(k.opacity??1);$<=0||(b.push({objectId:h.id,objectIndex:g,mesh:w,world:M,material:k,color:typeof y=="string"?y:void 0,opacity:$}),p.push(...Ot(w,M,A,u,d,k,{objectId:h.id,objectIndex:g,layer:h.layer??0,color:typeof y=="string"?y:void 0,opacity:$})))});const m=[];return n.objects.forEach((h,g)=>{const w=t.kinds.get(h.kind);if(!w||!i.get(h.id))return;const k=w.resolve({object:h,prepared:t.prepared.get(h.id),values:e(h.id),world:c.get(h.id),camera:u,width:o.width,height:o.height,toScreen:d});if(!k)return;const x=h.layer??0;for(const M of k.drawables??[])m.push({...M,objectId:h.id,objectIndex:g,layer:x});for(const M of k.meshes??[])b.push({objectId:h.id,objectIndex:g,mesh:M.mesh,world:M.world,material:M.material,opacity:M.material.opacity??1}),p.push(...Ot(M.mesh,M.world,Lt(M.world),u,d,M.material,{objectId:h.id,objectIndex:g,layer:x,opacity:M.material.opacity??1}))}),m.sort((h,g)=>h.layer-g.layer||g.depth-h.depth||h.objectIndex-g.objectIndex),p.sort((h,g)=>h.layer-g.layer||g.depth-h.depth||h.objectIndex-g.objectIndex||h.face-g.face||h.part-g.part),{id:n.id,width:o.width,height:o.height,background:n.background,fog:n.fog,camera:u,lights:f,worlds:c,triangles:p,drawables:m,meshes:b,time:o.time??0}}function Ot(t,s,o,n,e,c,i){const r=t.positions.length/3,a=[],l=[];for(let m=0;m<r;m++){const h=ht(s,[t.positions[m*3],t.positions[m*3+1],t.positions[m*3+2]]);a.push(h),l.push(ht(n.view,h))}const u=t.indices.length/3,d=[],f=[];for(let m=0;m<u;m++){const[h,g,w]=[0,1,2].map(M=>a[t.indices[m*3+M]]),k=q(ct(N(g,h),N(w,h)));d.push(k);const x=n.orthographic?D(n.forward,-1):N(n.position,h);f.push(O(k,x)>0)}const p=m=>-l[m][2]>=n.near,b=[];for(let m=0;m<u;m++){const h=f[m];if(!h&&!c.doubleSided)continue;const g=[t.indices[m*3],t.indices[m*3+1],t.indices[m*3+2]],w=g.map(v=>l[v]);if(w.every(v=>-v[2]>n.far))continue;const k=vn(w,n.near);if(k.length<3)continue;const x=h?1:-1,M=D(d[m],x),A=g.map(v=>D(xn(o,t.normals[v*3],t.normals[v*3+1],t.normals[v*3+2]),x)),y=D(it(it(a[g[0]],a[g[1]]),a[g[2]]),1/3),$=-(w[0][2]+w[1][2]+w[2][2])/3,j=[];if(c.outline&&h)for(const v of t.faceEdges[m]){const S=v.across,T=S===-1||!f[S],C=!T&&m<S&&O(d[m],d[S])<mn;(T||C)&&p(v.a)&&p(v.b)&&j.push([e(l[v.a]),e(l[v.b])])}const I=k.map(e);for(let v=1;v+1<I.length;v++)b.push({objectId:i.objectId,objectIndex:i.objectIndex,layer:i.layer,face:m,part:v-1,screen:[I[0],I[v],I[v+1]],depth:$,centroid:y,normal:M,vertexNormals:A,material:c,color:i.color,opacity:i.opacity,outline:v===1?j:[]})}return b}const ft=new Map;function G(t){const s=ft.get(t);if(s)return s;let o=[1,1,1];const n=t.trim().replace("#","");if(t.trim().startsWith("#")&&(n.length===3||n.length===6)){const e=n.length===3?n.split("").map(c=>c+c).join(""):n;o=[0,2,4].map(c=>Number.parseInt(e.slice(c,c+2),16)/255)}else{const e=t.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/);e&&(o=[Number(e[1])/255,Number(e[2])/255,Number(e[3])/255])}return ft.size<512&&ft.set(t,o),o}const kn=[{id:"default-ambient",light:"ambient",color:"#ffffff",intensity:.35,position:[0,0,0],direction:[0,-1,0],angle:30},{id:"default-key",light:"directional",color:"#ffffff",intensity:.8,position:[3,5,4],direction:q([-3,-5,-4]),angle:30}],In=(t,s,o)=>{const n=Math.min(1,Math.max(0,(o-t)/(s-t)));return n*n*(3-2*n)};function dt(t,s,o){const n=[0,0,0];for(const e of o){const c=G(e.color);let i;if(e.light==="ambient")i=e.intensity;else if(e.light==="directional")i=e.intensity*Math.max(0,-O(s,e.direction));else{const r=N(e.position,t),a=J(r),l=a>0?D(r,1/a):s,u=e.range?Math.max(0,1-a/e.range)**2:1;if(i=e.intensity*Math.max(0,O(s,l))*u,e.light==="spot"){const d=Math.cos(e.angle*Math.PI/180),f=Math.cos(e.angle*.8*Math.PI/180);i*=In(d,f,-O(l,e.direction))}}n[0]+=c[0]*i,n[1]+=c[1]*i,n[2]+=c[2]*i}return n}function An(t,s){const o=Math.max(2,Math.round(s));return Math.min(1.2,Math.ceil(Math.min(1,t)*o-1e-9)/o)}function qt(t,s){return t?Math.min(1,Math.max(0,(s-t.near)/(t.far-t.near))):0}function _t(t,s,o,n){const e=t.material,c=G(t.color??e.color),i=e.shading??"lambert";let r;if(i==="unlit")r=[...c];else{const u=s.length>0?s:kn;let d;if(i==="lambert"){const f=[0,0,0];for(const p of t.vertexNormals){const b=dt(t.centroid,p,u);f[0]+=b[0]/3,f[1]+=b[1]/3,f[2]+=b[2]/3}d=f}else if(d=dt(t.centroid,t.normal,u),i==="toon"){const f=Math.max(d[0],d[1],d[2]),p=f>0?An(f,e.bands??3)/f:0;d=[d[0]*p,d[1]*p,d[2]*p]}r=[c[0]*d[0],c[1]*d[1],c[2]*d[2]]}if(e.emissive){const u=G(e.emissive);r=[r[0]+u[0],r[1]+u[1],r[2]+u[2]]}const a=qt(n,en(t.centroid,o.position));if(n&&a>0){const u=G(n.color);r=[r[0]+(u[0]-r[0])*a,r[1]+(u[1]-r[1])*a,r[2]+(u[2]-r[2])*a]}const l=u=>Math.round(Math.min(1,Math.max(0,u))*255);return{color:`rgb(${l(r[0])}, ${l(r[1])}, ${l(r[2])})`,alpha:t.opacity}}class $n{ctx;constructor(s){this.ctx=s}render(s){pt(this.ctx,s)}}function pt(t,s){t.save(),s.background&&s.background!=="transparent"&&(t.fillStyle=s.background,t.fillRect(0,0,s.width,s.height)),t.lineJoin="round",t.lineCap="round";let o=0;const n=(i,r)=>{for(;o<s.drawables.length;){const a=s.drawables[o];if(a.layer>i||a.layer===i&&a.depth<=r)break;t.save(),a.draw(t,s),t.restore(),o++}};let e=[];const c=i=>{if(e.length===0)return;const r=[];for(const a of e)i&&i.objectId===a.objectId&&i.layer===a.layer&&a.depth-i.depth<=Sn*a.depth?r.push(a):Pn(t,a.triangle);e=r};for(const i of s.triangles){c(i),n(i.layer,i.depth);const{color:r,alpha:a}=_t(i,s.lights,s.camera,s.fog),[l,u,d]=i.screen;t.globalAlpha=a,t.beginPath(),t.moveTo(l.x,l.y),t.lineTo(u.x,u.y),t.lineTo(d.x,d.y),t.closePath(),t.fillStyle=r,t.fill(),a>=1&&(t.strokeStyle=r,t.lineWidth=.75,t.stroke()),i.material.outline&&i.outline.length>0&&e.push({objectId:i.objectId,layer:i.layer,depth:i.depth,triangle:i})}c(),n(1/0,-1/0),t.restore()}const Sn=.04;function Pn(t,s){const o=s.material.outline;t.globalAlpha=s.opacity,t.strokeStyle=o.color,t.lineWidth=o.width,t.beginPath();for(const[n,e]of s.outline)t.moveTo(n.x,n.y),t.lineTo(e.x,e.y);t.stroke()}class Cn{renderer;width;height;scenes=new Map;values=new Map;constructor(s,o){this.renderer=s,this.width=o.width,this.height=o.height}registerScene(s){this.scenes.set(s.scene.id,s)}unregisterScene(s){this.scenes.delete(s)}resize(s,o){this.width=s,this.height=o}applyState(s){this.values=s.values,this.time=s.currentTime??this.time}time=0;render(){for(const s of this.scenes.values())this.renderer.render(ut(s,this.values,{width:this.width,height:this.height,time:this.time}))}}function Tn(t,s,o,n){pt(t,ut(s,o??new Map,{width:n.width,height:n.height,time:n.time}))}P.Canvas2DRenderer=$n,P.MeshBuilder=L,P.Scene3DAdapter=Cn,P.boxMesh=vt,P.coneMesh=$t,P.cylinderMesh=At,P.dollyPosition=Mn,P.drawResolvedScene=pt,P.drawScene3D=Tn,P.extrudeMesh=xt,P.fogAmount=qt,P.geometryMesh=Pt,P.lightAt=dt,P.loadScene3D=tn,P.lookAtView=zt,P.meshEdges=mt,P.orbitPosition=gn,P.parseColor=G,P.planeMesh=kt,P.pointInPolygon=nt,P.prepareMesh=Ct,P.projectionMatrix=lt,P.resolveScene3D=ut,P.shadeTriangle=_t,P.signedArea=H,P.sphereMesh=It,P.torusMesh=St,P.triangulate=wt,P.validateScene3D=Mt,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})})(this.tinyfly=this.tinyfly||{});
|