@margoengine/rigging 0.0.0-stage → 1.0.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/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +1443 -2
- package/dist/anatomy-data-ansur2.d.ts +63 -0
- package/dist/anatomy-data-cdc.d.ts +16 -0
- package/dist/anatomy-data-deleva.d.ts +86 -0
- package/dist/anatomy-human.d.ts +67 -0
- package/dist/anatomy-human.js +2229 -0
- package/dist/anatomy.d.ts +638 -0
- package/dist/anatomy.js +1112 -0
- package/dist/autorig.d.ts +50 -0
- package/dist/autorig.js +663 -0
- package/dist/bar-grip.d.ts +7 -0
- package/dist/body-volumes-DTym0RVY.js +56 -0
- package/dist/body-volumes.d.ts +19 -0
- package/dist/checks.d.ts +50 -0
- package/dist/contact.d.ts +186 -0
- package/dist/contact.js +746 -0
- package/dist/correctives.d.ts +92 -0
- package/dist/correctives.js +162 -0
- package/dist/coupling.d.ts +57 -0
- package/dist/coupling.js +330 -0
- package/dist/errors-D8rc8kzg.js +7 -0
- package/dist/face.d.ts +93 -0
- package/dist/face.js +144 -0
- package/dist/hands.d.ts +209 -0
- package/dist/hands.js +510 -0
- package/dist/heat.d.ts +38 -0
- package/dist/hinged-contact.d.ts +7 -0
- package/dist/hulls.d.ts +54 -0
- package/dist/hulls.js +134 -0
- package/dist/ik.d.ts +162 -0
- package/dist/ik.js +561 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +390 -0
- package/dist/joint-limits.d.ts +44 -0
- package/dist/joint-limits.js +74 -0
- package/dist/limb-collision.d.ts +99 -0
- package/dist/loading-CZaYr1N7.js +67 -0
- package/dist/mesh-CyvLHNp0.js +142 -0
- package/dist/mesh.d.ts +47 -0
- package/dist/mtoon-data.d.ts +118 -0
- package/dist/mtoon-legacy.d.ts +17 -0
- package/dist/mtoon-shader.d.ts +4 -0
- package/dist/mtoon.d.ts +84 -0
- package/dist/mtoon.js +990 -0
- package/dist/paint.d.ts +82 -0
- package/dist/pose-tracking.d.ts +117 -0
- package/dist/pose-tracking.js +488 -0
- package/dist/retarget.d.ts +78 -0
- package/dist/retarget.js +375 -0
- package/dist/rig-BawZ5OLb.js +127 -0
- package/dist/rig.d.ts +65 -0
- package/dist/shared/gltf.d.ts +257 -0
- package/dist/shared/layers.d.ts +16 -0
- package/dist/springs.d.ts +180 -0
- package/dist/springs.js +458 -0
- package/dist/strand-springs.d.ts +46 -0
- package/dist/strand-springs.js +168 -0
- package/dist/swim.d.ts +55 -0
- package/dist/swim.js +167 -0
- package/dist/transfer.d.ts +41 -0
- package/dist/transfer.js +136 -0
- package/dist/validate.d.ts +188 -0
- package/dist/validate.js +440 -0
- package/dist/voxel-weights-48ok-Dax.js +255 -0
- package/dist/voxel-weights.d.ts +42 -0
- package/dist/voxel-weights.js +1 -0
- package/dist/voxels.d.ts +36 -0
- package/dist/vrm-constraints.d.ts +60 -0
- package/dist/vrm-constraints.js +261 -0
- package/dist/vrm-first-person.d.ts +115 -0
- package/dist/vrm-first-person.js +618 -0
- package/dist/vrm-presets-CU4V4yq6.js +47 -0
- package/dist/vrm-presets.d.ts +1 -0
- package/dist/vrm.d.ts +303 -0
- package/dist/vrm.js +574 -0
- package/dist/vrm0.d.ts +134 -0
- package/dist/vrm0.js +377 -0
- package/dist/vrma.d.ts +90 -0
- package/dist/vrma.js +315 -0
- package/dist/weight-map-D8cAONQQ.js +92 -0
- package/dist/weight-map.d.ts +58 -0
- package/package.json +189 -4
package/dist/mtoon.js
ADDED
|
@@ -0,0 +1,990 @@
|
|
|
1
|
+
// @margo/core-built 1.0.0
|
|
2
|
+
import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
|
|
3
|
+
const i=(engine,version="1.0.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
|
|
4
|
+
import { r as e, t } from "./errors-D8rc8kzg.js";
|
|
5
|
+
import { setMaterialDraw as n } from "@margoengine/gltf/material-draw";
|
|
6
|
+
import { PBRDrawRun as r } from "@margoengine/gltf/pbr-model";
|
|
7
|
+
import { engineRuntime as __margoRuntime } from "@margoengine/core/extension";
|
|
8
|
+
//#region src/mtoon-legacy.ts
|
|
9
|
+
var a = (e) => /* @__PURE__ */ RangeError(`Invalid legacy MToon ${e}; repair the material. See https://margoengine.com/errors#material`);
|
|
10
|
+
function o(e) {
|
|
11
|
+
if (e.shader !== "VRM/MToon") return;
|
|
12
|
+
let t = e.floatProperties ?? {}, n = e.vectorProperties ?? {}, r = e.textureProperties ?? {}, i = (e, n, r = -Infinity, i = Infinity) => {
|
|
13
|
+
let o = t[e] ?? n;
|
|
14
|
+
if (!Number.isFinite(Math.fround(o)) || o < r || o > i) throw a(e);
|
|
15
|
+
return o;
|
|
16
|
+
}, o = (e, t) => {
|
|
17
|
+
let r = n[e] ?? t;
|
|
18
|
+
if (r.length < 3 || r.slice(0, 3).some((e) => !Number.isFinite(e) || e < 0 || e > 1)) throw a(e);
|
|
19
|
+
return [
|
|
20
|
+
r[0] ** 2.2,
|
|
21
|
+
r[1] ** 2.2,
|
|
22
|
+
r[2] ** 2.2
|
|
23
|
+
];
|
|
24
|
+
}, s = (e) => {
|
|
25
|
+
let t = r[e];
|
|
26
|
+
if (t === void 0 || t === -1) return;
|
|
27
|
+
if (!Number.isSafeInteger(t) || t < 0) throw a(e);
|
|
28
|
+
let i = n[e] ?? [
|
|
29
|
+
0,
|
|
30
|
+
0,
|
|
31
|
+
1,
|
|
32
|
+
1
|
|
33
|
+
];
|
|
34
|
+
if (i.length !== 4 || i.some((e) => !Number.isFinite(Math.fround(e)))) throw a(e);
|
|
35
|
+
return {
|
|
36
|
+
index: t,
|
|
37
|
+
extensions: { KHR_texture_transform: {
|
|
38
|
+
scale: [i[2], i[3]],
|
|
39
|
+
offset: [i[0], 1 - i[3] - i[1]]
|
|
40
|
+
} }
|
|
41
|
+
};
|
|
42
|
+
}, c = i("_ShadeShift", 0, -1, 1), l = i("_ShadeToony", .9, 0, 1), u = 1 - l + l * c, d = i("_BlendMode", 0, 0, 3), f = i("_OutlineWidthMode", 0, 0, 2), p = i("_CullMode", 2, 0, 2);
|
|
43
|
+
if (!Number.isInteger(d) || !Number.isInteger(f) || !Number.isInteger(p)) throw a("enum");
|
|
44
|
+
let m = {
|
|
45
|
+
specVersion: "1.0",
|
|
46
|
+
transparentWithZWrite: d === 3,
|
|
47
|
+
shadeColorFactor: o("_ShadeColor", [
|
|
48
|
+
1,
|
|
49
|
+
1,
|
|
50
|
+
1
|
|
51
|
+
]),
|
|
52
|
+
shadeMultiplyTexture: s("_ShadeTexture") ?? s("_MainTex"),
|
|
53
|
+
shadingShiftFactor: -(c + u) / 2,
|
|
54
|
+
shadingToonyFactor: 1 - (u - c) / 2,
|
|
55
|
+
giEqualizationFactor: 1 - i("_IndirectLightIntensity", .1, 0, 1),
|
|
56
|
+
matcapFactor: [
|
|
57
|
+
1,
|
|
58
|
+
1,
|
|
59
|
+
1
|
|
60
|
+
],
|
|
61
|
+
matcapTexture: s("_SphereAdd"),
|
|
62
|
+
parametricRimColorFactor: o("_RimColor", [
|
|
63
|
+
0,
|
|
64
|
+
0,
|
|
65
|
+
0
|
|
66
|
+
]),
|
|
67
|
+
rimMultiplyTexture: s("_RimTexture"),
|
|
68
|
+
parametricRimFresnelPowerFactor: i("_RimFresnelPower", 1, 0),
|
|
69
|
+
parametricRimLiftFactor: i("_RimLift", 0),
|
|
70
|
+
rimLightingMixFactor: i("_RimLightingMix", 0, 0, 1),
|
|
71
|
+
outlineWidthMode: [
|
|
72
|
+
"none",
|
|
73
|
+
"worldCoordinates",
|
|
74
|
+
"screenCoordinates"
|
|
75
|
+
][f],
|
|
76
|
+
outlineWidthFactor: i("_OutlineWidth", 0, 0) * .01,
|
|
77
|
+
outlineWidthMultiplyTexture: s("_OutlineWidthTexture"),
|
|
78
|
+
outlineColorFactor: o("_OutlineColor", [
|
|
79
|
+
0,
|
|
80
|
+
0,
|
|
81
|
+
0
|
|
82
|
+
]),
|
|
83
|
+
outlineLightingMixFactor: i("_OutlineColorMode", 0) === 0 ? 0 : i("_OutlineLightingMix", 1, 0, 1),
|
|
84
|
+
uvAnimationMaskTexture: s("_UvAnimMaskTexture"),
|
|
85
|
+
uvAnimationScrollXSpeedFactor: i("_UvAnimScrollX", 0),
|
|
86
|
+
uvAnimationScrollYSpeedFactor: -i("_UvAnimScrollY", 0),
|
|
87
|
+
uvAnimationRotationSpeedFactor: i("_UvAnimRotation", 0)
|
|
88
|
+
}, h = e.renderQueue === void 0 || e.renderQueue === -1 ? d === 0 ? 2e3 : d === 1 ? 2450 : d === 3 ? 2500 : 3e3 : e.renderQueue;
|
|
89
|
+
if (!Number.isInteger(h) || h < 0 || h > 5e3) throw a("renderQueue");
|
|
90
|
+
let g = n._Color ?? [
|
|
91
|
+
1,
|
|
92
|
+
1,
|
|
93
|
+
1,
|
|
94
|
+
1
|
|
95
|
+
], _ = n._EmissionColor ?? [
|
|
96
|
+
0,
|
|
97
|
+
0,
|
|
98
|
+
0,
|
|
99
|
+
1
|
|
100
|
+
];
|
|
101
|
+
if (g.length !== 4 || g.some((e) => !Number.isFinite(e) || e < 0 || e > 1) || _.length < 3 || _.slice(0, 3).some((e) => !Number.isFinite(Math.fround(e)) || e < 0)) throw a("base/emission");
|
|
102
|
+
let v = _.slice(0, 3).map((e) => e ** 2.2);
|
|
103
|
+
if (v.some((e) => !Number.isFinite(Math.fround(e)))) throw a("linear emission");
|
|
104
|
+
return {
|
|
105
|
+
definition: m,
|
|
106
|
+
queue: h,
|
|
107
|
+
base: [...o("_Color", [
|
|
108
|
+
1,
|
|
109
|
+
1,
|
|
110
|
+
1
|
|
111
|
+
]), g[3]],
|
|
112
|
+
emission: v,
|
|
113
|
+
baseTexture: s("_MainTex"),
|
|
114
|
+
normalTexture: s("_BumpMap"),
|
|
115
|
+
emissionTexture: s("_EmissionMap"),
|
|
116
|
+
normalScale: i("_BumpScale", 1),
|
|
117
|
+
cutoff: i("_Cutoff", .5, 0, 1),
|
|
118
|
+
mode: d === 3 ? 2 : d,
|
|
119
|
+
side: p === 0 ? "double" : p === 1 ? "back" : "front"
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region ../shared/mipmaps.js
|
|
124
|
+
var s = (e) => `
|
|
125
|
+
@vertex fn vertex(@builtin(vertex_index) i:u32)->@builtin(position) vec4f {
|
|
126
|
+
return vec4f(array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3))[i],0,1);
|
|
127
|
+
}
|
|
128
|
+
@group(0) @binding(0) var image:texture_2d<f32>;
|
|
129
|
+
@fragment fn fragment(@builtin(position) clip:vec4f)->@location(0) vec4f {
|
|
130
|
+
let src=textureDimensions(image);
|
|
131
|
+
let dst=max(src/2u,vec2u(1u));let g=vec2u(clip.xy);
|
|
132
|
+
let a=vec2f(g*src)/vec2f(dst);let b=vec2f((g+1u)*src)/vec2f(dst);let end=min(src,((g+1u)*src+dst-1u)/dst);
|
|
133
|
+
var sum=vec4f(0.0);var sc=vec3f(0.0);
|
|
134
|
+
for(var y=g.y*src.y/dst.y;y<end.y;y++){
|
|
135
|
+
let wy=min(b.y,f32(y+1u))-max(a.y,f32(y));
|
|
136
|
+
for(var x=g.x*src.x/dst.x;x<end.x;x++){
|
|
137
|
+
let w=(min(b.x,f32(x+1u))-max(a.x,f32(x)))*wy;let t=textureLoad(image,vec2u(x,y),0);
|
|
138
|
+
sum+=w*t;sc+=(w*t.a)*t.rgb;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
let area=(b.x-a.x)*(b.y-a.y);
|
|
142
|
+
${e ? "return vec4f(select(sum.rgb/area,sc/sum.a,sum.a>0.0),sum.a/area);" : "return sum/area;"}
|
|
143
|
+
}
|
|
144
|
+
`;
|
|
145
|
+
function c(e, t, n, r, i = 1, a = "plain") {
|
|
146
|
+
if (n < 2) return;
|
|
147
|
+
let o = t.format, c = a === "weighted", l = c ? o + ":weighted" : o, u = r.get(l);
|
|
148
|
+
if (!u) {
|
|
149
|
+
let t = e.createShaderModule({ code: s(c) });
|
|
150
|
+
r.set(l, u = e.createRenderPipeline({
|
|
151
|
+
layout: "auto",
|
|
152
|
+
vertex: {
|
|
153
|
+
module: t,
|
|
154
|
+
entryPoint: "vertex"
|
|
155
|
+
},
|
|
156
|
+
fragment: {
|
|
157
|
+
module: t,
|
|
158
|
+
entryPoint: "fragment",
|
|
159
|
+
targets: [{ format: o }]
|
|
160
|
+
}
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
let d = e.createCommandEncoder();
|
|
164
|
+
for (let r = 0; r < i; r++) for (let a = 1; a < n; a++) {
|
|
165
|
+
let n = (e) => t.createView(i > 1 ? {
|
|
166
|
+
format: o,
|
|
167
|
+
dimension: "2d",
|
|
168
|
+
baseMipLevel: e,
|
|
169
|
+
mipLevelCount: 1,
|
|
170
|
+
baseArrayLayer: r,
|
|
171
|
+
arrayLayerCount: 1
|
|
172
|
+
} : {
|
|
173
|
+
baseMipLevel: e,
|
|
174
|
+
mipLevelCount: 1
|
|
175
|
+
}), s = e.createBindGroup({
|
|
176
|
+
layout: u.getBindGroupLayout(0),
|
|
177
|
+
entries: [{
|
|
178
|
+
binding: 0,
|
|
179
|
+
resource: n(a - 1)
|
|
180
|
+
}]
|
|
181
|
+
}), c = d.beginRenderPass({ colorAttachments: [{
|
|
182
|
+
view: n(a),
|
|
183
|
+
loadOp: "clear",
|
|
184
|
+
storeOp: "store",
|
|
185
|
+
clearValue: {
|
|
186
|
+
r: 0,
|
|
187
|
+
g: 0,
|
|
188
|
+
b: 0,
|
|
189
|
+
a: 0
|
|
190
|
+
}
|
|
191
|
+
}] });
|
|
192
|
+
c.setPipeline(u), c.setBindGroup(0, s), c.draw(3), c.end();
|
|
193
|
+
}
|
|
194
|
+
e.queue.submit([d.finish()]);
|
|
195
|
+
}
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region ../shared/frame-resources.js
|
|
198
|
+
var l = (globalThis[Symbol.for("margoengine.frame-resources")] ??= { devices: /* @__PURE__ */ new WeakMap() }).devices;
|
|
199
|
+
function u(e) {
|
|
200
|
+
let t = l.get(e);
|
|
201
|
+
return t || (l.set(e, t = {
|
|
202
|
+
frame: 0,
|
|
203
|
+
open: !1,
|
|
204
|
+
lost: !1,
|
|
205
|
+
views: /* @__PURE__ */ new Set(),
|
|
206
|
+
drawing: 0,
|
|
207
|
+
retired: [],
|
|
208
|
+
written: /* @__PURE__ */ new WeakMap()
|
|
209
|
+
}), e.lost?.then?.(() => {
|
|
210
|
+
t.lost = !0;
|
|
211
|
+
let e = t.retired;
|
|
212
|
+
t.retired = [];
|
|
213
|
+
for (let t of e) t.destroy();
|
|
214
|
+
})), t;
|
|
215
|
+
}
|
|
216
|
+
function d(e, t) {
|
|
217
|
+
let n = u(e);
|
|
218
|
+
return n.open || (n.open = !0, n.frame++, queueMicrotask(n.close ??= () => {
|
|
219
|
+
if (n.open = !1, n.views.clear(), !n.retired.length) return;
|
|
220
|
+
let e = n.retired;
|
|
221
|
+
n.retired = [];
|
|
222
|
+
for (let t of e) t.destroy();
|
|
223
|
+
})), t && n.views.add(t), n.frame;
|
|
224
|
+
}
|
|
225
|
+
function f(e, t) {
|
|
226
|
+
if (!t) return;
|
|
227
|
+
let n = u(e), r = [t, ...n.written.get(t)?.extras ?? []];
|
|
228
|
+
if (n.written.delete(t), !n.lost && n.open && (n.views.size > 1 || n.drawing > 0)) n.retired.push(...r);
|
|
229
|
+
else for (let e of r) e.destroy();
|
|
230
|
+
}
|
|
231
|
+
function p(e, t, n, r) {
|
|
232
|
+
let i = d(e, r), a = u(e), o = a.written.get(t);
|
|
233
|
+
o?.values.length !== n.length && (o && a.retired.push(...o.extras), a.written.set(t, o = {
|
|
234
|
+
frame: 0,
|
|
235
|
+
view: void 0,
|
|
236
|
+
uses: 0,
|
|
237
|
+
values: new Float32Array(n.length),
|
|
238
|
+
extras: []
|
|
239
|
+
}));
|
|
240
|
+
let s = o.frame === i && o.view !== r;
|
|
241
|
+
for (let e = 0; s && e < n.length; e++) s = o.values[e] === n[e];
|
|
242
|
+
if (o.frame !== i || o.view === r || s) {
|
|
243
|
+
o.frame !== i && Object.assign(o, {
|
|
244
|
+
frame: i,
|
|
245
|
+
view: r,
|
|
246
|
+
uses: 0
|
|
247
|
+
}), o.values.set(n), e.queue.writeBuffer(t, 0, n);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
let c = o.extras[o.uses++] ??= e.createBuffer({
|
|
251
|
+
label: "frame uniform copy",
|
|
252
|
+
size: t.size,
|
|
253
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
254
|
+
});
|
|
255
|
+
return e.queue.writeBuffer(c, 0, n), { buffer: c };
|
|
256
|
+
}
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region src/mtoon-data.ts
|
|
259
|
+
var m = {
|
|
260
|
+
shadingShiftFactor: 0,
|
|
261
|
+
shadingToonyFactor: .9,
|
|
262
|
+
giEqualizationFactor: .9,
|
|
263
|
+
parametricRimFresnelPowerFactor: 5,
|
|
264
|
+
parametricRimLiftFactor: 0,
|
|
265
|
+
rimLightingMixFactor: 1,
|
|
266
|
+
outlineWidthFactor: 0,
|
|
267
|
+
outlineLightingMixFactor: 1,
|
|
268
|
+
uvAnimationScrollXSpeedFactor: 0,
|
|
269
|
+
uvAnimationScrollYSpeedFactor: 0,
|
|
270
|
+
uvAnimationRotationSpeedFactor: 0,
|
|
271
|
+
renderQueueOffsetNumber: 0
|
|
272
|
+
}, h = [
|
|
273
|
+
"shadeMultiplyTexture",
|
|
274
|
+
"shadingShiftTexture",
|
|
275
|
+
"matcapTexture",
|
|
276
|
+
"rimMultiplyTexture",
|
|
277
|
+
"outlineWidthMultiplyTexture",
|
|
278
|
+
"uvAnimationMaskTexture"
|
|
279
|
+
], g = {
|
|
280
|
+
shadeColorFactor: [
|
|
281
|
+
0,
|
|
282
|
+
0,
|
|
283
|
+
0
|
|
284
|
+
],
|
|
285
|
+
matcapFactor: [
|
|
286
|
+
1,
|
|
287
|
+
1,
|
|
288
|
+
1
|
|
289
|
+
],
|
|
290
|
+
parametricRimColorFactor: [
|
|
291
|
+
0,
|
|
292
|
+
0,
|
|
293
|
+
0
|
|
294
|
+
],
|
|
295
|
+
outlineColorFactor: [
|
|
296
|
+
0,
|
|
297
|
+
0,
|
|
298
|
+
0
|
|
299
|
+
]
|
|
300
|
+
}, _ = (e, t, n = -Infinity, r = Infinity) => {
|
|
301
|
+
if (typeof e != "number" || !Number.isFinite(Math.fround(e)) || e < n || e > r) throw RangeError(`Invalid MToon ${t}; use a finite float32 number in the documented range. See https://margoengine.com/errors#material`);
|
|
302
|
+
return e;
|
|
303
|
+
};
|
|
304
|
+
function v(e) {
|
|
305
|
+
if (!e || typeof e != "object" || e.specVersion !== "1.0") throw TypeError("MToon requires specVersion 1.0; migrate legacy VRM materials before installation. See https://margoengine.com/errors#material");
|
|
306
|
+
let t = { ...e };
|
|
307
|
+
for (let [n, r] of Object.entries(m)) {
|
|
308
|
+
let i = [
|
|
309
|
+
"shadingToonyFactor",
|
|
310
|
+
"giEqualizationFactor",
|
|
311
|
+
"rimLightingMixFactor",
|
|
312
|
+
"outlineLightingMixFactor"
|
|
313
|
+
].includes(n), a = n === "outlineWidthFactor" || n === "parametricRimFresnelPowerFactor";
|
|
314
|
+
t[n] = _(e[n] ?? r, n, i || a ? 0 : -Infinity, i ? 1 : Infinity);
|
|
315
|
+
}
|
|
316
|
+
if (!Number.isInteger(t.renderQueueOffsetNumber) || Math.abs(t.renderQueueOffsetNumber) > 9) throw RangeError("MToon renderQueueOffsetNumber must be an integer from -9 through 9. See https://margoengine.com/errors#material");
|
|
317
|
+
for (let [n, r] of Object.entries(g)) {
|
|
318
|
+
let i = e[n] ?? r;
|
|
319
|
+
if (!Array.isArray(i) || i.length !== 3) throw TypeError(`MToon ${n} needs three linear colour channels. See https://margoengine.com/errors#material`);
|
|
320
|
+
t[n] = i.map((e) => _(e, n, 0, 1));
|
|
321
|
+
}
|
|
322
|
+
let n = e.outlineWidthMode ?? "none";
|
|
323
|
+
if (![
|
|
324
|
+
"none",
|
|
325
|
+
"worldCoordinates",
|
|
326
|
+
"screenCoordinates"
|
|
327
|
+
].includes(n)) throw TypeError("MToon outlineWidthMode must be none, worldCoordinates or screenCoordinates. See https://margoengine.com/errors#material");
|
|
328
|
+
if (t.outlineWidthMode = n, e.transparentWithZWrite !== void 0 && typeof e.transparentWithZWrite != "boolean") throw TypeError("MToon transparentWithZWrite must be a boolean. See https://margoengine.com/errors#material");
|
|
329
|
+
t.transparentWithZWrite = e.transparentWithZWrite ?? !1;
|
|
330
|
+
for (let n of h) {
|
|
331
|
+
let r = e[n];
|
|
332
|
+
if (r === void 0) continue;
|
|
333
|
+
if (!r || typeof r != "object" || !Number.isSafeInteger(r.index) || r.index < 0 || r.texCoord !== void 0 && (!Number.isSafeInteger(r.texCoord) || r.texCoord < 0 || r.texCoord > 3)) throw TypeError(`MToon ${n} requires a valid texture index and TEXCOORD_0 through TEXCOORD_3. See https://margoengine.com/errors#material`);
|
|
334
|
+
r.scale !== void 0 && _(r.scale, n + ".scale");
|
|
335
|
+
let i = r.extensions?.KHR_texture_transform;
|
|
336
|
+
if (i !== void 0) {
|
|
337
|
+
if (!i || typeof i != "object" || Array.isArray(i)) throw TypeError(`MToon ${n} texture transform must be an object. See https://margoengine.com/errors#material`);
|
|
338
|
+
for (let e of ["offset", "scale"]) {
|
|
339
|
+
let t = i[e];
|
|
340
|
+
if (t !== void 0) {
|
|
341
|
+
if (!Array.isArray(t) || t.length !== 2) throw TypeError(`MToon ${n} ${e} needs two finite numbers. See https://margoengine.com/errors#material`);
|
|
342
|
+
for (let r of t) _(r, `${n}.${e}`);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
if (i.rotation !== void 0 && _(i.rotation, `${n}.rotation`), i.texCoord !== void 0 && (!Number.isSafeInteger(i.texCoord) || i.texCoord < 0 || i.texCoord > 3)) throw RangeError(`MToon ${n} texture transform requires TEXCOORD_0 through TEXCOORD_3. See https://margoengine.com/errors#material`);
|
|
346
|
+
}
|
|
347
|
+
t[n] = structuredClone(r);
|
|
348
|
+
}
|
|
349
|
+
return t;
|
|
350
|
+
}
|
|
351
|
+
var y = [
|
|
352
|
+
"shadeMultiplyTexture",
|
|
353
|
+
"shadingShiftTexture",
|
|
354
|
+
"matcapTexture",
|
|
355
|
+
"rimMultiplyTexture",
|
|
356
|
+
"outlineWidthMultiplyTexture",
|
|
357
|
+
"uvAnimationMaskTexture"
|
|
358
|
+
];
|
|
359
|
+
function b(e) {
|
|
360
|
+
return new Uint8Array(e === "matcapTexture" || e === "shadingShiftTexture" ? [
|
|
361
|
+
0,
|
|
362
|
+
0,
|
|
363
|
+
0,
|
|
364
|
+
255
|
|
365
|
+
] : [
|
|
366
|
+
255,
|
|
367
|
+
255,
|
|
368
|
+
255,
|
|
369
|
+
255
|
|
370
|
+
]);
|
|
371
|
+
}
|
|
372
|
+
function x(e, t, n, r) {
|
|
373
|
+
let i = n?.extensions?.KHR_texture_transform, a = [...i?.offset ?? [0, 0]], o = [...i?.scale ?? [1, 1]], s = i?.rotation ?? 0, c = Math.cos(s), l = Math.sin(s);
|
|
374
|
+
for (let e = 0; e < 2; e++) {
|
|
375
|
+
let t = a[e], n = o[e];
|
|
376
|
+
for (let i of r) a[e] += (i.offset[e] - t) * i.value, o[e] += (i.scale[e] - n) * i.value;
|
|
377
|
+
}
|
|
378
|
+
e.set([
|
|
379
|
+
c * o[0],
|
|
380
|
+
l * o[1],
|
|
381
|
+
a[0],
|
|
382
|
+
i?.texCoord ?? n?.texCoord ?? 0,
|
|
383
|
+
-l * o[0],
|
|
384
|
+
c * o[1],
|
|
385
|
+
a[1],
|
|
386
|
+
0,
|
|
387
|
+
n?.scale ?? 1,
|
|
388
|
+
+!!n,
|
|
389
|
+
0,
|
|
390
|
+
0
|
|
391
|
+
], t * 4);
|
|
392
|
+
}
|
|
393
|
+
function S(e, t, n) {
|
|
394
|
+
y.forEach((r, i) => x(e, 8 + i * 3, t[r], r === "matcapTexture" ? [] : n));
|
|
395
|
+
}
|
|
396
|
+
var C = 33071, w = /* @__PURE__ */ new Float32Array(12);
|
|
397
|
+
function T(e, t, n, r = []) {
|
|
398
|
+
if (!e) return !0;
|
|
399
|
+
x(w, 0, e, r);
|
|
400
|
+
for (let e = 0; e < 2; e++) {
|
|
401
|
+
let r = w[e * 4 + n];
|
|
402
|
+
if (r !== 0 && (!Number.isInteger(r) || t[e] === C)) return !1;
|
|
403
|
+
}
|
|
404
|
+
return !0;
|
|
405
|
+
}
|
|
406
|
+
function E(e, t, n, r, i) {
|
|
407
|
+
let a = (t, r, i) => {
|
|
408
|
+
let a = t * n, o = r ? Math.floor(a / 2) : 0;
|
|
409
|
+
e[i] = a - 2 * o, e[i + 3] = o;
|
|
410
|
+
};
|
|
411
|
+
a(t[0], r, 0), a(t[1], i, 1);
|
|
412
|
+
let o = t[2] * n / (2 * Math.PI), s = Math.floor(o);
|
|
413
|
+
e[2] = o - s, e[5] = s;
|
|
414
|
+
}
|
|
415
|
+
//#endregion
|
|
416
|
+
//#region ../shared/light-terms.js
|
|
417
|
+
var D = "((1-mix(max(dielectricF0.r,max(dielectricF0.g,dielectricF0.b)),dielectricF90,pow(1-vh,5.0)))*(1-metal)*base/3.14159265+d*g*fresnel/max(4*nl*nv,0.0001))", O = (e) => `
|
|
418
|
+
struct MToonFrame { rows:array<vec4f,26> }
|
|
419
|
+
@group(${e}) @binding(180) var<uniform> mt:MToonFrame;
|
|
420
|
+
${Array.from({ length: 6 }, (t, n) => `@group(${e}) @binding(${181 + n * 2}) var mtMap${n}:texture_2d<f32>;\n@group(${e}) @binding(${182 + n * 2}) var mtSampler${n}:sampler;`).join("\n")}
|
|
421
|
+
fn mtRaw(i:Out,k:u32)->vec2f {return select(i.uv.xy,i.uv.zw,mt.rows[8u+k*3u].w>0.5);}
|
|
422
|
+
fn mtTransform(p:vec2f,k:u32)->vec2f {let a=mt.rows[8u+k*3u];let b=mt.rows[9u+k*3u];return vec2f(dot(a.xyz,vec3f(p,1)),dot(b.xyz,vec3f(p,1)));}
|
|
423
|
+
fn mtAnimate(i:Out,p:vec2f)->vec2f {
|
|
424
|
+
let mask=textureSampleLevel(mtMap5,mtSampler5,mtTransform(mtRaw(i,5u),5u),0.0).b;
|
|
425
|
+
let t=mt.rows[6].xyz*mask+fract(vec3f(mt.rows[5].w,mt.rows[7].zw)*mask)*vec3f(2,2,1);let a=6.2831853*t.z;let c=cos(a);let s=sin(a);let q=p-0.5;
|
|
426
|
+
return vec2f(c*q.x+s*q.y,-s*q.x+c*q.y)+0.5+t.xy;
|
|
427
|
+
}
|
|
428
|
+
fn mtUV(i:Out,k:u32)->vec2f {return mtTransform(mtAnimate(i,mtRaw(i,k)),k);}
|
|
429
|
+
fn mtStep(nl:f32,shift:f32)->f32 {let width=1.0-mt.rows[4].y;let x=nl+shift;if(width==0.0){return select(0.0,1.0,x>=0.0);}return clamp(0.5+x/(2.0*width),0.0,1.0);}
|
|
430
|
+
fn mtDirect(base:vec3f,shade:vec3f,shift:f32,nl:f32)->vec3f {return mix(shade,base,mtStep(nl,shift));}
|
|
431
|
+
fn mtRim(i:Out,s:Surface,v:vec3f,lighting:vec3f)->vec3f {
|
|
432
|
+
var x=vec3f(v.z,0,-v.x);if(dot(x,x)<1e-10){x=vec3f(f.view[0].x,f.view[1].x,f.view[2].x);}x=normalize(x);let y=cross(v,x);
|
|
433
|
+
let uv=vec2f(dot(x,s.n),dot(y,s.n))*0.495+0.5;
|
|
434
|
+
let matcap=textureSample(mtMap2,mtSampler2,mtTransform(uv,2u)).rgb*mt.rows[2].rgb*mt.rows[10u+2u*3u].y;
|
|
435
|
+
let rim=pow(clamp(1.0-dot(s.n,v)+mt.rows[5].x,0.0,1.0),max(mt.rows[4].w,0.00001))*mt.rows[1].rgb;
|
|
436
|
+
return (matcap+rim)*textureSample(mtMap3,mtSampler3,mtUV(i,3u)).rgb*mix(vec3f(1),lighting,mt.rows[5].y);
|
|
437
|
+
}
|
|
438
|
+
`, k = (e, n, r) => {
|
|
439
|
+
let i = e.replace(n, () => r);
|
|
440
|
+
if (i === e) throw t("unsupported", "MToon shader contract changed; use matching rigging and gltf/pbr versions");
|
|
441
|
+
return i;
|
|
442
|
+
};
|
|
443
|
+
function A(e, t, n = !1) {
|
|
444
|
+
let r = e;
|
|
445
|
+
return r = k(r, "emissive:vec3f}", "emissive:vec3f, mtShade:vec3f, mtShift:f32, f0:vec3f, sw:f32}"), r = k(r, "*f.base*i.color;", "*f.base;"), r = k(r, "return s;\n}", "s.mtShade=textureSample(mtMap0,mtSampler0,mtUV(i,0u)).rgb*mt.rows[0].rgb;\n s.mtShift=mt.rows[4].x+textureSample(mtMap1,mtSampler1,mtUV(i,1u)).r*mt.rows[13].x;\n s.metal=0; s.roughness=1;s.occlusion=1;s.f0=vec3f(0);s.sw=0; return s;\n}"), r = k(r, "select(i.uv.xy,i.uv.zw,m.w>0.5),1)", "mtAnimate(i,select(i.uv.xy,i.uv.zw,m.w>0.5)),1)"), r = k(r, /fn direct_light\(s:Surface,v:vec3f,l:vec3f\)->vec3f \{[^}]*\}/, "fn direct_light(s:Surface,v:vec3f,l:vec3f)->vec3f {return mtDirect(s.base.rgb,s.mtShade,s.mtShift,dot(s.n,l))*f.radiance.rgb*f.light.w;}"), r = k(r, /fn hemisphere_ambient\(s:Surface\)->vec3f \{[^}]*\}/, "fn hemisphere_ambient(s:Surface)->vec3f {return s.base.rgb*mix(vec3f(0.35,0.3,0.25),vec3f(1),clamp(s.n.y*0.5+0.5,0.0,1.0))*f.radiance.w;}"), r = k(r, "@fragment fn fragment(", "fn margoFront(s:Surface)->Surface {return s;}\nfn margoAmbientTerm(i:Out,s:Surface,v:vec3f)->vec3f {return vec3f(0);}\nfn margoAmbientLayers(i:Out,s:Surface,v:vec3f)->vec3f {return margoAmbientTerm(i,s,v);}\n@fragment fn fragment("), n && (r = k(r, "let n=normalize(i.normal)*select(-1.0,1.0,facing);", "let n=-normalize(i.normal)*select(-1.0,1.0,facing);"), r = k(r, "o.clip=f.camera*p; o.position=p.xyz;", "o.clip=f.camera*p; o.position=p.xyz;\n let n=normalize((f.normalMatrix*vec4f(i.normal.xyz,0)).xyz);\n o.uv=i.uv;\n let mask=textureSampleLevel(mtMap4,mtSampler4,mtUV(o,4u),0.0).g;\n var world=vec4f(o.position,1.0);var clip=o.clip;\n if(mt.rows[7].x<1.5){world+=vec4f(n*mt.rows[6].w*mask,0);clip=f.camera*world;}\n else {let projected=(f.camera*vec4f(n,0));let dir=projected.xy-clip.xy*projected.w/clip.w;\n let aspect=mt.rows[7].y;let screen=vec2f(dir.x*aspect,dir.y);let len=length(screen);\n if(len>0){clip=vec4f(clip.xy+vec2f(screen.x/aspect,screen.y)/len*2.0*mt.rows[6].w*mask*clip.w,clip.zw);}}\n o.clip=clip; o.position=world.xyz;")), r = r.replace("if(abs(i.tangent.w)<0.5)", "if(true)"), O(t) + r;
|
|
446
|
+
}
|
|
447
|
+
function j(e, n = !1) {
|
|
448
|
+
let r = e;
|
|
449
|
+
r = k(r, "@fragment fn fragment(", "fn mtGI(i:Out,s:Surface,v:vec3f)->vec3f {\n var up=s;var down=s;up.n=vec3f(0,1,0);down.n=vec3f(0,-1,0);\n return mix(ambient(s)+margoAmbientTerm(i,s,v),\n (ambient(up)+ambient(down)+margoAmbientTerm(i,up,v)+margoAmbientTerm(i,down,v))*0.5,mt.rows[4].z);\n }\n @fragment fn fragment("), r = r.replace(/let margoAmbient=[^;]*;/g, ""), r = r.replace(/\+margoAmbient(?=[;+])/g, ""), r = k(r, "+ambient(s)", "+mtGI(i,s,v)");
|
|
450
|
+
let i = r.includes(D), a = r.slice(r.indexOf("@fragment fn fragment(")), o = /var color=([^;]*);/.exec(a)?.[1];
|
|
451
|
+
if (!o) throw t("unsupported", "MToon lighting sum contract changed; use matching rigging and gltf/pbr versions");
|
|
452
|
+
return r = k(r, "@fragment fn fragment(", `fn mtIncident(i:Out,s:Surface,v:vec3f)->vec3f {
|
|
453
|
+
var white=s;white.base=vec4f(1);white.mtShade=vec3f(1);white.emissive=vec3f(0);
|
|
454
|
+
${i ? "let savedShade=mtLocalShade;let savedShift=mtLocalShift;mtLocalShade=vec3f(1);mtLocalShift=white.mtShift;" : ""}
|
|
455
|
+
let l=f.light.xyz;let direct=direct_light(white,v,l);
|
|
456
|
+
let result=${o.replace(/\bs\b/g, "white")};
|
|
457
|
+
${i ? "mtLocalShade=savedShade;mtLocalShift=savedShift;" : ""}
|
|
458
|
+
return result;
|
|
459
|
+
}
|
|
460
|
+
@fragment fn fragment(`), r = k(r, "if(f.ext.x>0.5){color=s.base.rgb;}", `if(mt.rows[16].y>0.5||any(mt.rows[1].rgb!=vec3f(0))) {
|
|
461
|
+
var incident=vec3f(1);if(mt.rows[5].y>0){incident=mtIncident(i,s,v);}
|
|
462
|
+
color+=mtRim(i,s,v,incident);
|
|
463
|
+
}
|
|
464
|
+
${n ? "if(mt.rows[7].x<0.5||mt.rows[6].w==0.0){discard;}color=mt.rows[3].rgb*mix(vec3f(1),color,mt.rows[5].z);" : ""}`), r.includes("((1-mix(max(dielectricF0.r,max(dielectricF0.g,dielectricF0.b)),dielectricF90,pow(1-vh,5.0)))*(1-metal)*base/3.14159265+d*g*fresnel/max(4*nl*nv,0.0001))") && (r = r.replace("let s=surface(i,front); let v=", "let s=surface(i,front); mtLocalShade=s.mtShade;mtLocalShift=s.mtShift; let v="), r = r.split("result+=" + D + "*nl*").join("result+=mtDirect(base,mtLocalShade,mtLocalShift,dot(n,l))*"), r = "var<private> mtLocalShade:vec3f;var<private> mtLocalShift:f32;\n" + r), r;
|
|
465
|
+
}
|
|
466
|
+
//#endregion
|
|
467
|
+
//#region src/mtoon.ts
|
|
468
|
+
var M = 0, N = /* @__PURE__ */ new Float32Array(12), P = 2500, F = /* @__PURE__ */ new WeakMap(), I = {
|
|
469
|
+
shader: (e) => e.replace(/(@fragment fn fragment\([^]*?\{)/, "$1 discard;"),
|
|
470
|
+
bindings: () => [],
|
|
471
|
+
shaderRevision: 0
|
|
472
|
+
}, L = /* @__PURE__ */ new WeakMap();
|
|
473
|
+
function R(e) {
|
|
474
|
+
let t = L.get(e);
|
|
475
|
+
if (!t) {
|
|
476
|
+
let n = e.shading, r = n ? {
|
|
477
|
+
...n,
|
|
478
|
+
shader: (e, t) => (n.shader?.(e, t) ?? e).replace(/(@fragment fn fragment\([^]*?\{)/, "$1 discard;"),
|
|
479
|
+
lit: n.lit?.bind(n),
|
|
480
|
+
bindings: n.bindings.bind(n)
|
|
481
|
+
} : I;
|
|
482
|
+
t = {
|
|
483
|
+
...e,
|
|
484
|
+
shading: r
|
|
485
|
+
}, L.set(e, t);
|
|
486
|
+
}
|
|
487
|
+
return t;
|
|
488
|
+
}
|
|
489
|
+
var z = class a {coreRequirement=__margoCoreRequirement("1.0.0",import.meta.url);
|
|
490
|
+
get materials() {
|
|
491
|
+
return this.definitions;
|
|
492
|
+
}
|
|
493
|
+
get disposed() {
|
|
494
|
+
return this.dead;
|
|
495
|
+
}
|
|
496
|
+
constructor(r, a = {}) {
|
|
497
|
+
if (this.model = r, this.options = a, this.name = "mtoon:" + M++, this.definitions = /* @__PURE__ */ new Map(), this.dead = !1, this.clock = 0, this.mode = "beauty", this.mipPipelines = /* @__PURE__ */ new Map(), this.states = [], this.parts = [], !r || r.disposed) throw t("disposed", "MToon needs a live loaded PBRModel; load the avatar again");
|
|
498
|
+
let s = i(r.root.engine), c = s.sceneOf(r);
|
|
499
|
+
if (!c) throw t("state", "MToon needs a registered model; load it into a scene first");
|
|
500
|
+
this.engine = s, this.scene = c;
|
|
501
|
+
let l = r.asset.doc.materials ?? [], u = r.asset.doc.extensions, d = (u?.VRM ?? (u?.VRMC_vrm)?.extras?.vrm0)?.materialProperties;
|
|
502
|
+
for (let t = 0; t < l.length; t++) {
|
|
503
|
+
let n = d?.[t] ? o(d[t]) : void 0, i = l[t].extensions?.VRMC_materials_mtoon ?? n?.definition;
|
|
504
|
+
if (!i) continue;
|
|
505
|
+
let a = v(i), s = {}, c = l[t].alphaMode ?? "OPAQUE", u = a.renderQueueOffsetNumber;
|
|
506
|
+
if (!n && c === "BLEND" && (a.transparentWithZWrite ? u < 0 : u > 0)) throw e("MToon renderQueueOffsetNumber must be nonnegative for depth-writing blend and nonpositive for ordinary blend", "material");
|
|
507
|
+
Object.assign(s, {
|
|
508
|
+
index: t,
|
|
509
|
+
definition: a,
|
|
510
|
+
legacy: n,
|
|
511
|
+
values: /* @__PURE__ */ new Float32Array(104)
|
|
512
|
+
});
|
|
513
|
+
let f = [
|
|
514
|
+
...y.map((e) => a[e]),
|
|
515
|
+
n?.baseTexture,
|
|
516
|
+
n?.normalTexture,
|
|
517
|
+
n?.emissionTexture
|
|
518
|
+
];
|
|
519
|
+
for (let t of f) {
|
|
520
|
+
if (!t) continue;
|
|
521
|
+
let n = r.asset.doc.textures?.[t.index];
|
|
522
|
+
if (!n) throw e("MToon map names a missing texture; correct the material index", "material");
|
|
523
|
+
let i = n.sampler === void 0 ? {} : r.asset.doc.samplers?.[n.sampler];
|
|
524
|
+
if (!i || i.magFilter !== void 0 && ![9728, 9729].includes(i.magFilter) || i.minFilter !== void 0 && ![
|
|
525
|
+
9728,
|
|
526
|
+
9729,
|
|
527
|
+
9984,
|
|
528
|
+
9985,
|
|
529
|
+
9986,
|
|
530
|
+
9987
|
|
531
|
+
].includes(i.minFilter) || [i.wrapS, i.wrapT].some((e) => e !== void 0 && ![
|
|
532
|
+
10497,
|
|
533
|
+
33071,
|
|
534
|
+
33648
|
|
535
|
+
].includes(e))) throw e("MToon texture sampler needs valid glTF filter and wrapping constants", "material");
|
|
536
|
+
}
|
|
537
|
+
let p = (e) => ({
|
|
538
|
+
shader: (t, n) => A(t, n, e),
|
|
539
|
+
lit: (t) => j(t, e),
|
|
540
|
+
bindings: () => this.bindings(s, e),
|
|
541
|
+
shaderRevision: +e
|
|
542
|
+
});
|
|
543
|
+
s.body = p(!1), s.outline = p(!0), this.states.push(s), this.definitions.set(t, a);
|
|
544
|
+
}
|
|
545
|
+
for (let e of r.primitives) {
|
|
546
|
+
let n = this.states.find((t) => t.index === e.definition.material);
|
|
547
|
+
if (!n) continue;
|
|
548
|
+
let r = e.material;
|
|
549
|
+
if (r.shading) throw t("attached", "MToon material already has a shader; dispose the prior material adapter first", "state");
|
|
550
|
+
let { physical: i, extended: a, extension: o, tint: s, volume: c, attenuation: l, dispersion: u, ...d } = r, f = {
|
|
551
|
+
...d,
|
|
552
|
+
maps: d.maps.slice(0, 5),
|
|
553
|
+
extendedFrame: !0,
|
|
554
|
+
ext: [
|
|
555
|
+
0,
|
|
556
|
+
0,
|
|
557
|
+
0,
|
|
558
|
+
0
|
|
559
|
+
],
|
|
560
|
+
vertexAlpha: !1,
|
|
561
|
+
shading: n.body,
|
|
562
|
+
renderState: {
|
|
563
|
+
...r.renderState,
|
|
564
|
+
depthWrite: r.settings[0] !== 2 || n.definition.transparentWithZWrite
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
n.legacy && (f.settings = f.settings.slice(), f.settings[0] = n.legacy.mode, f.settings[1] = n.legacy.cutoff, f.base = n.legacy.base.slice(), f.emission = n.legacy.emission.slice(), f.maps = f.maps.slice(), f.maps[0] = n.legacy.baseTexture, f.maps[2] = n.legacy.normalTexture, f.maps[3] = n.legacy.emissionTexture, f.side = n.legacy.side, f.renderState.depthWrite = n.legacy.mode !== 2 || n.definition.transparentWithZWrite), f.uvt = this.coreUV(f.maps), f.factors = f.factors.slice(), n.legacy && (f.factors[2] = n.legacy.normalScale), f.maps[2] || (f.factors[2] = 0);
|
|
568
|
+
let p = {
|
|
569
|
+
...f,
|
|
570
|
+
settings: f.settings.slice(),
|
|
571
|
+
side: "back",
|
|
572
|
+
shading: n.outline,
|
|
573
|
+
renderState: {
|
|
574
|
+
...f.renderState,
|
|
575
|
+
depthWrite: !1
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
p.settings[2] = 0, this.parts.push({
|
|
579
|
+
primitive: e,
|
|
580
|
+
original: r,
|
|
581
|
+
state: n,
|
|
582
|
+
body: f,
|
|
583
|
+
outline: p,
|
|
584
|
+
authored: {
|
|
585
|
+
base: f.base.slice(),
|
|
586
|
+
emission: f.emission.slice(),
|
|
587
|
+
maps: structuredClone(f.maps)
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
if (this.device = s.gpu ?? void 0, !this.device) throw t("unsupported", "MToon needs a WebGPU or compatibility device");
|
|
592
|
+
this.removeDraw = n(r, (e) => this.draw(e));
|
|
593
|
+
for (let e of this.parts) e.primitive.material = e.body;
|
|
594
|
+
this.unsubscribe = r.onDispose(() => this.dispose());
|
|
595
|
+
}
|
|
596
|
+
static attach(e, t = {}) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
|
|
597
|
+
let n = new a(e, t);
|
|
598
|
+
try {
|
|
599
|
+
n.scene.use(n);
|
|
600
|
+
} catch (e) {
|
|
601
|
+
throw n.dispose(), e;
|
|
602
|
+
}
|
|
603
|
+
return n;
|
|
604
|
+
}
|
|
605
|
+
setup(e) {
|
|
606
|
+
if (e !== this.engine || this.disposed) throw t("attached", "MToon belongs to another scene; attach a new instance to its model", "state");
|
|
607
|
+
if (!e.gpu) throw t("unsupported", "MToon needs WebGPU or the WebGL2 compatibility device; select a GPU backend");
|
|
608
|
+
this.device = e.gpu ?? void 0;
|
|
609
|
+
}
|
|
610
|
+
registerPasses(e) {
|
|
611
|
+
(this.parts.some((e) => this.queue(e.state) >= P) || this.model.primitives.some((e) => e.material.settings[0] === 2)) && (e.add({
|
|
612
|
+
name: this.name + ":arm",
|
|
613
|
+
order: .99,
|
|
614
|
+
joins: !0,
|
|
615
|
+
execute: (e) => {
|
|
616
|
+
if (e.backend !== "webgpu") return;
|
|
617
|
+
let t = F.get(e);
|
|
618
|
+
(!t || t.arms.has(this.name)) && F.set(e, t = {
|
|
619
|
+
drawn: [],
|
|
620
|
+
arms: /* @__PURE__ */ new Set()
|
|
621
|
+
}), t.arms.add(this.name);
|
|
622
|
+
}
|
|
623
|
+
}), e.add({
|
|
624
|
+
name: this.name + ":queues",
|
|
625
|
+
order: 1.2,
|
|
626
|
+
joins: !0,
|
|
627
|
+
execute: (e) => {
|
|
628
|
+
e.backend === "webgpu" && a.drawQueues(e);
|
|
629
|
+
}
|
|
630
|
+
}));
|
|
631
|
+
}
|
|
632
|
+
static drawQueues(e) {
|
|
633
|
+
let t = F.get(e);
|
|
634
|
+
if (!t) return;
|
|
635
|
+
F.delete(e);
|
|
636
|
+
let n = t.drawn;
|
|
637
|
+
if (!n.length) return;
|
|
638
|
+
let i = [...new Set(n.flatMap((e) => e.queues))].sort((e, t) => e - t), a = new r();
|
|
639
|
+
try {
|
|
640
|
+
for (let t of i) for (let r of n) r.queues.includes(t) && r.effect.drawQueue(e, t, a);
|
|
641
|
+
} finally {
|
|
642
|
+
a.end();
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
drawQueue(e, t, n) {
|
|
646
|
+
if (!this.disposed) {
|
|
647
|
+
this.only = t;
|
|
648
|
+
try {
|
|
649
|
+
this.model.draw(e, "beauty", e.color, e.depth, "blend", void 0, n);
|
|
650
|
+
} finally {
|
|
651
|
+
this.only = void 0;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
get time() {
|
|
656
|
+
return this.clock;
|
|
657
|
+
}
|
|
658
|
+
advanceTime(e) {
|
|
659
|
+
e > 0 && (this.clock += e);
|
|
660
|
+
}
|
|
661
|
+
onPreUpdate(e) {
|
|
662
|
+
this.advanceTime(e), this.applyExpressions(), this.moveCastCutouts();
|
|
663
|
+
}
|
|
664
|
+
moveCastCutouts() {
|
|
665
|
+
let e = this.device;
|
|
666
|
+
if (!e || this.disposed) return;
|
|
667
|
+
let t, n = !1;
|
|
668
|
+
for (let r of this.states) {
|
|
669
|
+
let i = r.definition, a = this.parts.find((e) => e.state === r);
|
|
670
|
+
if (!a || a.body.settings[0] !== 1 || i.uvAnimationScrollXSpeedFactor === 0 && i.uvAnimationScrollYSpeedFactor === 0 && i.uvAnimationRotationSpeedFactor === 0) continue;
|
|
671
|
+
let o = r.resource ??= this.resources(r, e);
|
|
672
|
+
n ||= (t = this.options.expressions?.evaluate(), !0);
|
|
673
|
+
let s = t?.transforms.find((e) => e.material === r.index)?.parts ?? [], c = r.castValues ??= /* @__PURE__ */ new Float32Array(32), l = N, u = this.animationPhases(r, s);
|
|
674
|
+
c.set(u.subarray(0, 3), 0), c[3] = u[3], x(l, 0, a.body.maps[0], []), c.set(l.subarray(0, 8), 4), x(l, 0, i.uvAnimationMaskTexture, s), c.set(l.subarray(0, 8), 12), c[11] = u[4], c[19] = u[5];
|
|
675
|
+
let d = r.castBuffer ??= e.createBuffer({
|
|
676
|
+
size: 80,
|
|
677
|
+
usage: 72
|
|
678
|
+
});
|
|
679
|
+
e.queue.writeBuffer(d, 0, c, 0, 20);
|
|
680
|
+
let f = o.maps[5];
|
|
681
|
+
f.readView && (f.view = f.readView() ?? f.fallback), (r.castAnimation?.view !== f.view || r.castAnimation.buffer !== d) && (r.castAnimation = {
|
|
682
|
+
buffer: d,
|
|
683
|
+
view: f.view,
|
|
684
|
+
sampler: f.sampler
|
|
685
|
+
});
|
|
686
|
+
for (let e of this.parts) e.state === r && (e.body.castAnimation = r.castAnimation);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
animationPhases(e, t) {
|
|
690
|
+
let n = e.definition, r = e.phases ??= /* @__PURE__ */ new Float64Array(6), i = this.model.asset.doc, a = this.parts.find((t) => t.state === e)?.body.maps ?? [], o = (e) => y.every((r) => r === "matcapTexture" || r === "uvAnimationMaskTexture" || T(n[r], this.wrapOf(i, n[r]), e, t)) && a.every((t) => T(t, this.wrapOf(i, t), e));
|
|
691
|
+
return E(r, [
|
|
692
|
+
n.uvAnimationScrollXSpeedFactor,
|
|
693
|
+
n.uvAnimationScrollYSpeedFactor,
|
|
694
|
+
n.uvAnimationRotationSpeedFactor
|
|
695
|
+
], this.clock, n.uvAnimationScrollXSpeedFactor !== 0 && o(0), n.uvAnimationScrollYSpeedFactor !== 0 && o(1)), r;
|
|
696
|
+
}
|
|
697
|
+
wrapOf(e, t) {
|
|
698
|
+
let n = t ? e.textures?.[t.index] : void 0, r = n?.sampler === void 0 ? void 0 : e.samplers?.[n.sampler];
|
|
699
|
+
return [r?.wrapS, r?.wrapT];
|
|
700
|
+
}
|
|
701
|
+
draw(e) {
|
|
702
|
+
let t = this.context, n = this.mode;
|
|
703
|
+
this.context = e.context, this.mode = e.mode;
|
|
704
|
+
try {
|
|
705
|
+
this.drawLayers(e);
|
|
706
|
+
} finally {
|
|
707
|
+
this.context = t, this.mode = n;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
drawLayers(e) {
|
|
711
|
+
let { model: t } = e;
|
|
712
|
+
if (this.disposed || (this.applyExpressions(), e.mode !== "beauty")) {
|
|
713
|
+
e.draw();
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
let n = t.primitives.flatMap((e) => {
|
|
717
|
+
let t = this.parts.find((t) => e.material === t.body);
|
|
718
|
+
return t ? [{
|
|
719
|
+
...t,
|
|
720
|
+
primitive: e
|
|
721
|
+
}] : [];
|
|
722
|
+
});
|
|
723
|
+
if (!n.length) {
|
|
724
|
+
e.draw();
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
let r = t.primitives.filter((e) => !n.some((t) => t.primitive === e)), i = (e) => e.material.settings[0] === 2 ? 3e3 : e.material.settings[0] === 1 ? 2450 : 2e3, a = [.../* @__PURE__ */ new Set([...n.map((e) => this.queue(e.state)), ...r.map(i)])].sort((e, t) => e - t), o = e.phase === "all" ? F.get(e.context) : void 0;
|
|
728
|
+
if (e.phase === "blend" && this.only !== void 0) a = a.includes(this.only) ? [this.only] : [];
|
|
729
|
+
else if (o) {
|
|
730
|
+
let e = a.filter((e) => e >= P);
|
|
731
|
+
e.length && o.drawn.push({
|
|
732
|
+
effect: this,
|
|
733
|
+
queues: e
|
|
734
|
+
}), a = a.filter((e) => e < P);
|
|
735
|
+
}
|
|
736
|
+
for (let o of a) {
|
|
737
|
+
let a = n.filter((e) => this.queue(e.state) === o), s = r.filter((e) => i(e) === o), c = t.primitives.map((e) => e.material);
|
|
738
|
+
try {
|
|
739
|
+
for (let e of t.primitives) e.material = R(e.material);
|
|
740
|
+
for (let e of a) e.primitive.material = e.body;
|
|
741
|
+
for (let e of s) e.material = c[t.primitives.indexOf(e)];
|
|
742
|
+
if (e.draw(), a.some((e) => e.state.definition.outlineWidthMode !== "none" && e.state.definition.outlineWidthFactor > 0)) {
|
|
743
|
+
for (let e of s) e.material = R(e.material);
|
|
744
|
+
for (let e of a) {
|
|
745
|
+
for (let t of [
|
|
746
|
+
"base",
|
|
747
|
+
"emission",
|
|
748
|
+
"maps",
|
|
749
|
+
"uvt",
|
|
750
|
+
"factors"
|
|
751
|
+
]) Object.assign(e.outline, { [t]: e.body[t] });
|
|
752
|
+
e.primitive.material = e.outline;
|
|
753
|
+
}
|
|
754
|
+
e.draw();
|
|
755
|
+
}
|
|
756
|
+
} finally {
|
|
757
|
+
t.primitives.forEach((e, t) => {
|
|
758
|
+
e.material = c[t];
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
applyExpressions() {
|
|
764
|
+
let e = this.options.expressions?.evaluate();
|
|
765
|
+
if (e) for (let t of this.parts) {
|
|
766
|
+
let { body: n, authored: r, state: i } = t;
|
|
767
|
+
for (let [t, a] of [["color", "base"], ["emissionColor", "emission"]]) {
|
|
768
|
+
let o = r[a], s = o.slice();
|
|
769
|
+
for (let n of e.colors) if (n.material === i.index && n.type === t) for (let e of n.parts) for (let t = 0; t < s.length; t++) s[t] += (e.target[t] - o[t]) * e.value;
|
|
770
|
+
n[a] = s;
|
|
771
|
+
}
|
|
772
|
+
n.maps = r.maps.map((t) => {
|
|
773
|
+
if (!t) return t;
|
|
774
|
+
let n = structuredClone(t), r = n.extensions?.KHR_texture_transform ?? {}, a = [...r.scale ?? [1, 1]], o = [...r.offset ?? [0, 0]];
|
|
775
|
+
for (let t of e.transforms) if (t.material === i.index) for (let e of t.parts) for (let t = 0; t < 2; t++) a[t] += (e.scale[t] - (r.scale?.[t] ?? 1)) * e.value, o[t] += (e.offset[t] - (r.offset?.[t] ?? 0)) * e.value;
|
|
776
|
+
return n.extensions = {
|
|
777
|
+
...n.extensions,
|
|
778
|
+
KHR_texture_transform: {
|
|
779
|
+
...r,
|
|
780
|
+
scale: [a[0], a[1]],
|
|
781
|
+
offset: [o[0], o[1]]
|
|
782
|
+
}
|
|
783
|
+
}, n;
|
|
784
|
+
}), n.uvt = this.coreUV(n.maps);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
coreUV(e) {
|
|
788
|
+
return e.flatMap((e) => {
|
|
789
|
+
let t = e?.extensions?.KHR_texture_transform ?? {}, n = t.rotation ?? 0, r = Math.cos(n), i = Math.sin(n), a = t.scale ?? [1, 1], o = t.offset ?? [0, 0];
|
|
790
|
+
return [
|
|
791
|
+
r * a[0],
|
|
792
|
+
i * a[1],
|
|
793
|
+
o[0],
|
|
794
|
+
t.texCoord ?? e?.texCoord ?? 0,
|
|
795
|
+
-i * a[0],
|
|
796
|
+
r * a[1],
|
|
797
|
+
o[1],
|
|
798
|
+
0
|
|
799
|
+
];
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
queue(e) {
|
|
803
|
+
if (e.legacy) return e.legacy.queue;
|
|
804
|
+
let t = this.parts.find((t) => t.state === e).original.settings[0];
|
|
805
|
+
return t === 2 ? (e.definition.transparentWithZWrite ? 2500 : 3e3) + e.definition.renderQueueOffsetNumber : t === 1 ? 2450 : 2e3;
|
|
806
|
+
}
|
|
807
|
+
bindings(e, n = !1) {
|
|
808
|
+
if (this.disposed) throw t("disposed", "MToon is disposed; attach a new instance");
|
|
809
|
+
let r = this.device, i = e.resource ??= this.resources(e, r), a = e.values, o = e.definition;
|
|
810
|
+
a.set([
|
|
811
|
+
...o.shadeColorFactor,
|
|
812
|
+
0,
|
|
813
|
+
...o.parametricRimColorFactor,
|
|
814
|
+
0,
|
|
815
|
+
...o.matcapFactor,
|
|
816
|
+
0,
|
|
817
|
+
...o.outlineColorFactor,
|
|
818
|
+
0
|
|
819
|
+
]), a.set([
|
|
820
|
+
o.shadingShiftFactor,
|
|
821
|
+
o.shadingToonyFactor,
|
|
822
|
+
o.giEqualizationFactor,
|
|
823
|
+
o.parametricRimFresnelPowerFactor,
|
|
824
|
+
o.parametricRimLiftFactor,
|
|
825
|
+
o.rimLightingMixFactor,
|
|
826
|
+
o.outlineLightingMixFactor,
|
|
827
|
+
0,
|
|
828
|
+
0,
|
|
829
|
+
0,
|
|
830
|
+
0,
|
|
831
|
+
o.outlineWidthFactor
|
|
832
|
+
], 16);
|
|
833
|
+
let s = this.context.view?.viewport;
|
|
834
|
+
a[29] = s ? s[2] / s[3] : this.context.width / this.context.height, a[28] = [
|
|
835
|
+
"none",
|
|
836
|
+
"worldCoordinates",
|
|
837
|
+
"screenCoordinates"
|
|
838
|
+
].indexOf(o.outlineWidthMode);
|
|
839
|
+
let c = this.options.expressions?.evaluate(), l = {
|
|
840
|
+
shadeColor: 0,
|
|
841
|
+
rimColor: 1,
|
|
842
|
+
matcapColor: 2,
|
|
843
|
+
outlineColor: 3
|
|
844
|
+
};
|
|
845
|
+
for (let t of c?.colors ?? []) {
|
|
846
|
+
if (t.material !== e.index || !(t.type in l)) continue;
|
|
847
|
+
let n = l[t.type] * 4;
|
|
848
|
+
for (let e = 0; e < 3; e++) {
|
|
849
|
+
let r = a[n + e];
|
|
850
|
+
for (let i of t.parts) a[n + e] += (i.target[e] - r) * i.value;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
let u = c?.transforms.find((t) => t.material === e.index)?.parts ?? [];
|
|
854
|
+
S(a, o, u);
|
|
855
|
+
let d = this.animationPhases(e, u);
|
|
856
|
+
a[23] = d[3], a.set(d.subarray(0, 3), 24), a[30] = d[4], a[31] = d[5];
|
|
857
|
+
for (let e of i.maps) e.readView && (e.view = e.readView() ?? e.fallback);
|
|
858
|
+
return [{
|
|
859
|
+
binding: 180,
|
|
860
|
+
resource: p(r, i.buffer, a, this.context.view ?? this.context) ?? { buffer: i.buffer }
|
|
861
|
+
}, ...i.maps.flatMap((e, t) => t === 4 && !n || [
|
|
862
|
+
"gbuffer",
|
|
863
|
+
"capture",
|
|
864
|
+
"occlusion"
|
|
865
|
+
].includes(this.mode) && [2, 3].includes(t) ? [] : [{
|
|
866
|
+
binding: 181 + t * 2,
|
|
867
|
+
resource: e.view
|
|
868
|
+
}, {
|
|
869
|
+
binding: 182 + t * 2,
|
|
870
|
+
resource: e.sampler
|
|
871
|
+
}])];
|
|
872
|
+
}
|
|
873
|
+
resources(e, n) {
|
|
874
|
+
let r = [], i = [];
|
|
875
|
+
try {
|
|
876
|
+
for (let a = 0; a < y.length; a++) {
|
|
877
|
+
let o = e.definition[y[a]], s, l;
|
|
878
|
+
if (o) {
|
|
879
|
+
let e = this.model.asset.doc.textures[o.index], r = [...[
|
|
880
|
+
"KHR_texture_basisu",
|
|
881
|
+
"EXT_texture_webp",
|
|
882
|
+
"EXT_texture_avif"
|
|
883
|
+
].map((t) => e.extensions?.[t]?.source), e.source].find((e) => typeof e == "number" && this.model.image(e, !0));
|
|
884
|
+
if (r === void 0) throw t("unsupported", "MToon texture needs a decoded source image; load the avatar with its texture decoder");
|
|
885
|
+
let u = this.model.image(r), d = [
|
|
886
|
+
0,
|
|
887
|
+
2,
|
|
888
|
+
3
|
|
889
|
+
].includes(a);
|
|
890
|
+
if ("streamed" in u) {
|
|
891
|
+
let e = n.createTexture({
|
|
892
|
+
size: [1, 1],
|
|
893
|
+
format: "rgba8unorm",
|
|
894
|
+
usage: 6
|
|
895
|
+
});
|
|
896
|
+
n.queue.writeTexture({ texture: e }, b(y[a]), { bytesPerRow: 4 }, [1, 1]), s = e;
|
|
897
|
+
} else if ("ktx2" in u || "mipmaps" in u) s = this.model.uploadImage(r, n, d);
|
|
898
|
+
else {
|
|
899
|
+
let e = Math.floor(Math.log2(Math.max(u.width, u.height))) + 1;
|
|
900
|
+
s = n.createTexture({
|
|
901
|
+
size: [u.width, u.height],
|
|
902
|
+
mipLevelCount: e,
|
|
903
|
+
format: d ? "rgba8unorm-srgb" : "rgba8unorm",
|
|
904
|
+
usage: 22
|
|
905
|
+
});
|
|
906
|
+
try {
|
|
907
|
+
"data" in u ? n.queue.writeTexture({ texture: s }, u.data, { bytesPerRow: u.width * 4 }, [u.width, u.height]) : n.queue.copyExternalImageToTexture({ source: u }, { texture: s }, [u.width, u.height]), c(n, s, e, this.mipPipelines);
|
|
908
|
+
} catch (e) {
|
|
909
|
+
throw s.destroy(), e;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
i.push(s);
|
|
913
|
+
let f = e.sampler === void 0 ? {} : this.model.asset.doc.samplers[e.sampler], p = (e) => e === 33071 ? "clamp-to-edge" : e === 33648 ? "mirror-repeat" : "repeat";
|
|
914
|
+
l = n.createSampler({
|
|
915
|
+
addressModeU: p(f.wrapS),
|
|
916
|
+
addressModeV: p(f.wrapT),
|
|
917
|
+
magFilter: f.magFilter === 9728 ? "nearest" : "linear",
|
|
918
|
+
minFilter: [
|
|
919
|
+
9728,
|
|
920
|
+
9984,
|
|
921
|
+
9986
|
|
922
|
+
].includes(f.minFilter ?? 9729) ? "nearest" : "linear",
|
|
923
|
+
mipmapFilter: [9984, 9985].includes(f.minFilter ?? 9987) ? "nearest" : "linear",
|
|
924
|
+
lodMaxClamp: [9728, 9729].includes(f.minFilter ?? 9987) ? 0 : 32
|
|
925
|
+
});
|
|
926
|
+
} else s = n.createTexture({
|
|
927
|
+
size: [1, 1],
|
|
928
|
+
format: "rgba8unorm",
|
|
929
|
+
usage: 6
|
|
930
|
+
}), n.queue.writeTexture({ texture: s }, b(y[a]), { bytesPerRow: 4 }, [1, 1]), i.push(s), l = n.createSampler();
|
|
931
|
+
let u = o ? (() => {
|
|
932
|
+
let e = this.model.asset.doc.textures[o.index], t = [...[
|
|
933
|
+
"KHR_texture_basisu",
|
|
934
|
+
"EXT_texture_webp",
|
|
935
|
+
"EXT_texture_avif"
|
|
936
|
+
].map((t) => e.extensions?.[t]?.source), e.source].find((e) => typeof e == "number" && this.model.image(e, !0));
|
|
937
|
+
return t === void 0 ? void 0 : this.model.image(t);
|
|
938
|
+
})() : void 0, d = s.createView();
|
|
939
|
+
r.push({
|
|
940
|
+
texture: s,
|
|
941
|
+
sampler: l,
|
|
942
|
+
view: d,
|
|
943
|
+
...u && "streamed" in u ? {
|
|
944
|
+
fallback: d,
|
|
945
|
+
readView: () => u.view(n, [
|
|
946
|
+
0,
|
|
947
|
+
2,
|
|
948
|
+
3
|
|
949
|
+
].includes(a))
|
|
950
|
+
} : {}
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
return {
|
|
954
|
+
buffer: n.createBuffer({
|
|
955
|
+
size: 416,
|
|
956
|
+
usage: 72
|
|
957
|
+
}),
|
|
958
|
+
maps: r
|
|
959
|
+
};
|
|
960
|
+
} catch (e) {
|
|
961
|
+
for (let e of i) e.destroy();
|
|
962
|
+
throw e;
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
onDeviceRestored(e) {
|
|
966
|
+
this.release(), this.mipPipelines.clear(), this.device = e.gpu ?? void 0;
|
|
967
|
+
}
|
|
968
|
+
release() {
|
|
969
|
+
for (let e of this.parts) delete e.body.castAnimation;
|
|
970
|
+
for (let e of this.states) {
|
|
971
|
+
if (e.castBuffer && f(this.device, e.castBuffer), e.castBuffer = e.castAnimation = void 0, e.resource) {
|
|
972
|
+
f(this.device, e.resource.buffer);
|
|
973
|
+
for (let t of e.resource.maps) f(this.device, t.texture);
|
|
974
|
+
}
|
|
975
|
+
e.resource = void 0;
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
dispose() {
|
|
979
|
+
if (!this.disposed) {
|
|
980
|
+
this.dead = !0, this.removeDraw?.(), this.removeDraw = void 0, this.unsubscribe?.(), this.unsubscribe = void 0, this.engine.sceneOf(this)?.removePlugin(this.name);
|
|
981
|
+
for (let e of this.parts) e.primitive.material === e.body && (e.primitive.material = e.original);
|
|
982
|
+
this.release();
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
[Symbol.dispose]() {
|
|
986
|
+
this.dispose();
|
|
987
|
+
}
|
|
988
|
+
};
|
|
989
|
+
//#endregion
|
|
990
|
+
export { z as MToon };
|