rayzee 7.22.5 → 7.22.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rayzee.es.js +327 -327
- package/dist/rayzee.umd.js +24 -24
- package/package.json +1 -1
- package/src/Stages/EdgeFilter.js +22 -9
package/dist/rayzee.es.js
CHANGED
|
@@ -12120,7 +12120,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
|
|
|
12120
12120
|
dispose() {
|
|
12121
12121
|
this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this._outputTarget?.dispose(), this._readTexNode?.dispose(), this._normalDepthTexNode?.dispose(), this._shadingNormalTexNode?.dispose(), this._albedoTexNode?.dispose(), this._varianceTexNode?.dispose(), this._srcAlphaTexNode?.dispose();
|
|
12122
12122
|
}
|
|
12123
|
-
}, hf = 6e4, gf = (e) => R(e.equal(e), e, j(0)).clamp(0, 1e7), _f = (e) => W(gf(e.x), gf(e.y), gf(e.z)), vf = [
|
|
12123
|
+
}, hf = 6e4, gf = (e) => R(e.equal(e), e, j(0)).clamp(0, 1e7), _f = (e) => W(gf(e.x), gf(e.y), gf(e.z)), vf = 4, yf = [
|
|
12124
12124
|
1 / 256,
|
|
12125
12125
|
4 / 256,
|
|
12126
12126
|
6 / 256,
|
|
@@ -12146,12 +12146,12 @@ var ef = ai("wavefront"), tf = 256, nf = [
|
|
|
12146
12146
|
6 / 256,
|
|
12147
12147
|
4 / 256,
|
|
12148
12148
|
1 / 256
|
|
12149
|
-
],
|
|
12149
|
+
], bf = class extends cr {
|
|
12150
12150
|
constructor(e, t = {}) {
|
|
12151
12151
|
super("EdgeAwareFiltering", {
|
|
12152
12152
|
...t,
|
|
12153
12153
|
executionMode: sr.PER_CYCLE
|
|
12154
|
-
}), this.renderer = e, this.filterStrength = V(t.filterStrength ?? 1), this.phiLuminance = V(t.phiLuminance ??
|
|
12154
|
+
}), this.renderer = e, this.filterStrength = V(t.filterStrength ?? 1), this.phiLuminance = V(t.phiLuminance ?? 1), this.phiNormal = V(t.phiNormal ?? 64), this.phiDepth = V(t.phiDepth ?? .1), this.iterations = t.atrousIterations ?? t.edgeAtrousIterations ?? 5, this.stepSizeU = V(1, "int"), this.isLastIterationU = V(0, "int"), this.isFirstIterationU = V(1, "int"), this.varianceHistoryU = V(0, "int"), this.resW = V(t.width || 1), this.resH = V(t.height || 1), this._colorTexNode = new c(), this._ndTexNode = new c(), this._snTexNode = new c(), this._albedoTexNode = new c(), this._varTexNode = new c(), this._readTexNode = new c();
|
|
12155
12155
|
let n = t.width || 1, r = t.height || 1;
|
|
12156
12156
|
this._demodTex = this._makeStorageTex(), this._storageTexA = this._makeStorageTex(), this._storageTexB = this._makeStorageTex(), this._srcRegion = new qe(new on(0, 0), new on(0, 0)), this.outputTarget = new i(n, r, {
|
|
12157
12157
|
type: dt,
|
|
@@ -12188,20 +12188,20 @@ var ef = ai("wavefront"), tf = 256, nf = [
|
|
|
12188
12188
|
]);
|
|
12189
12189
|
}
|
|
12190
12190
|
_buildAtrous(e) {
|
|
12191
|
-
let t = this._readTexNode, n = this._colorTexNode, r = this._ndTexNode, i = this._snTexNode, a = this._albedoTexNode, o = this._varTexNode, s = this.filterStrength, c = this.phiLuminance, l = this.phiNormal, u = this.phiDepth, d = this.stepSizeU, m = this.isLastIterationU, h = this.isFirstIterationU, g = this.
|
|
12191
|
+
let t = this._readTexNode, n = this._colorTexNode, r = this._ndTexNode, i = this._snTexNode, a = this._albedoTexNode, o = this._varTexNode, s = this.filterStrength, c = this.phiLuminance, l = this.phiNormal, u = this.phiDepth, d = this.stepSizeU, m = this.isLastIterationU, h = this.isFirstIterationU, g = this.varianceHistoryU, _ = this.resW, v = this.resH;
|
|
12192
12192
|
return f(() => {
|
|
12193
|
-
let f = N(Ve.x).mul(16).add(N(se.x)),
|
|
12194
|
-
p(f.lessThan(N(
|
|
12195
|
-
let p = P(f,
|
|
12193
|
+
let f = N(Ve.x).mul(16).add(N(se.x)), y = N(Ve.y).mul(16).add(N(se.y));
|
|
12194
|
+
p(f.lessThan(N(_)).and(y.lessThan(N(v))), () => {
|
|
12195
|
+
let p = P(f, y), b = z(t, p), x = b.xyz, S = Oa(x), C = z(r, p).w, w = z(i, p).xyz.mul(2).sub(1), T = C.lessThan(j(hf)), E = R(T, j(1), j(0)), D = z(a, p).xyz, O = R(T, F(D, W(Tr)), W(1)), k = F(Oa(O), j(Tr)), ee = h.equal(N(1)), te = g.lessThan(N(vf)), ne = (e) => {
|
|
12196
12196
|
let t = z(o, e);
|
|
12197
|
-
return F(t.z, t.w);
|
|
12198
|
-
},
|
|
12197
|
+
return R(te, F(t.z, t.w), t.z);
|
|
12198
|
+
}, re = ee.select(ne(p), b.w.mul(b.w)).toVar(), ie = c.mul(Ce(F(re, j(0)))).div(k).add(j(1e-4)), M = W(0).toVar(), ae = j(0).toVar(), oe = j(0).toVar();
|
|
12199
12199
|
for (let e = 0; e < 5; e++) for (let n = 0; n < 5; n++) {
|
|
12200
|
-
let a = n - 2, o = e - 2, s =
|
|
12201
|
-
|
|
12200
|
+
let a = n - 2, o = e - 2, s = yf[e * 5 + n], c = P(f.add(d.mul(a)).clamp(N(0), N(_).sub(1)), y.add(d.mul(o)).clamp(N(0), N(v).sub(1))), p = z(t, c), m = p.xyz, h = Oa(m), g = z(r, c).w, b = z(i, c).xyz.mul(2).sub(1), x = R(g.lessThan(j(hf)), j(1), j(0)), T = S.sub(h).abs().div(ie).negate().exp(), D = ge(A(w, b).clamp(0, 1), l), O = C.sub(g).abs().div(F(C.mul(u), j(.001))).negate().exp(), k = E.mul(x), te = E.oneMinus().mul(x.oneMinus()), re = k.add(te), se = I(j(1), D.mul(O), k), ce = j(s).mul(T).mul(se).mul(re), le = ee.select(ne(c), p.w.mul(p.w));
|
|
12201
|
+
M.addAssign(m.mul(ce)), ae.addAssign(ce), oe.addAssign(ce.mul(ce).mul(F(le, j(0))));
|
|
12202
12202
|
}
|
|
12203
|
-
let
|
|
12204
|
-
Me(e, Le(B(f), B(
|
|
12203
|
+
let se = M.div(F(ae, j(1e-4))), ce = oe.div(F(ae.mul(ae), j(1e-8))), le = m.equal(N(1)), ue = z(n, p).xyz, de = I(ue, se.mul(O), s), fe = le.select(de, se), L = le.select(z(n, p).w, Ce(F(ce, j(0))));
|
|
12204
|
+
Me(e, Le(B(f), B(y)), G(fe, L)).toWriteOnly();
|
|
12205
12205
|
});
|
|
12206
12206
|
})().compute([
|
|
12207
12207
|
this._dispatchX,
|
|
@@ -12225,7 +12225,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
|
|
|
12225
12225
|
return;
|
|
12226
12226
|
}
|
|
12227
12227
|
let o = t.image;
|
|
12228
|
-
o && o.width > 0 && o.height > 0 && (o.width !== this.outputTarget.width || o.height !== this.outputTarget.height) && this.setSize(o.width, o.height), this._colorTexNode.value = t, this._ndTexNode.value = n, this._snTexNode.value = r, this._albedoTexNode.value = i, this._varTexNode.value = a, this._compiled ||= (this.renderer.compute(this._computeDemod), this.renderer.compute(this._computeAtrousA), this.renderer.compute(this._computeAtrousB), !0), this.renderer.compute(this._computeDemod);
|
|
12228
|
+
o && o.width > 0 && o.height > 0 && (o.width !== this.outputTarget.width || o.height !== this.outputTarget.height) && this.setSize(o.width, o.height), this.varianceHistoryU.value = e.getState("accumulatedFrames") ?? 0, this._colorTexNode.value = t, this._ndTexNode.value = n, this._snTexNode.value = r, this._albedoTexNode.value = i, this._varTexNode.value = a, this._compiled ||= (this.renderer.compute(this._computeDemod), this.renderer.compute(this._computeAtrousA), this.renderer.compute(this._computeAtrousB), !0), this.renderer.compute(this._computeDemod);
|
|
12229
12229
|
let s = this._demodTex, c = this._computeAtrousA, l = this._computeAtrousB;
|
|
12230
12230
|
for (let e = 0; e < this.iterations; e++) {
|
|
12231
12231
|
this.stepSizeU.value = 1 << e, this.isLastIterationU.value = +(e === this.iterations - 1), this.isFirstIterationU.value = +(e === 0), this._readTexNode.value = s, this.renderer.compute(c), s = c === this._computeAtrousA ? this._storageTexA : this._storageTexB;
|
|
@@ -12259,7 +12259,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
|
|
|
12259
12259
|
dispose() {
|
|
12260
12260
|
this._computeDemod?.dispose(), this._computeAtrousA?.dispose(), this._computeAtrousB?.dispose(), this._demodTex?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this.outputTarget?.dispose(), this._colorTexNode?.dispose(), this._ndTexNode?.dispose(), this._snTexNode?.dispose(), this._albedoTexNode?.dispose(), this._varTexNode?.dispose(), this._readTexNode?.dispose();
|
|
12261
12261
|
}
|
|
12262
|
-
},
|
|
12262
|
+
}, xf = 256, Sf = -8, Cf = 6 - Sf, wf = Cf / xf, Tf = 1e4, Ef = /* @__PURE__ */ K("\n fn adaptExposure(\n geoMean: f32,\n prevExposure: f32,\n keyValue: f32,\n minExp: f32,\n maxExp: f32,\n speedBright: f32,\n speedDark: f32,\n dt: f32,\n isFirstFrame: f32\n ) -> vec4f {\n\n let targetExp = clamp( keyValue / max( geoMean, 0.001 ), minExp, maxExp );\n var newExposure = targetExp;\n\n // Temporal smoothing (skip on first frame)\n if ( isFirstFrame < 0.5 ) {\n\n // Asymmetric speed: brighter scenes adapt faster\n let speed = select( speedDark, speedBright, targetExp < prevExposure );\n let alpha = 1.0 - exp( -dt * speed );\n newExposure = mix( prevExposure, targetExp, alpha );\n\n }\n\n return vec4f( newExposure, geoMean, targetExp, 1.0 );\n\n }\n"), Df = class extends cr {
|
|
12263
12263
|
constructor(e, t = {}) {
|
|
12264
12264
|
super("AutoExposure", {
|
|
12265
12265
|
...t,
|
|
@@ -12275,7 +12275,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
|
|
|
12275
12275
|
depthBuffer: !1,
|
|
12276
12276
|
stencilBuffer: !1
|
|
12277
12277
|
};
|
|
12278
|
-
this._downsampleTarget = new i(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new s(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = dt, this._downsampleStorageTex.format = zt, this._downsampleStorageTex.minFilter = Dt, this._downsampleStorageTex.magFilter = Dt, this._reductionStorageTex = new s(1, 1), this._reductionStorageTex.type = dt, this._reductionStorageTex.format = zt, this._reductionStorageTex.minFilter = Dt, this._reductionStorageTex.magFilter = Dt, this._reductionReadTarget = new i(1, 1, e), this._adaptationResult = w(1, "vec4"), this._readbackBuffer = new n(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = w(
|
|
12278
|
+
this._downsampleTarget = new i(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new s(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = dt, this._downsampleStorageTex.format = zt, this._downsampleStorageTex.minFilter = Dt, this._downsampleStorageTex.magFilter = Dt, this._reductionStorageTex = new s(1, 1), this._reductionStorageTex.type = dt, this._reductionStorageTex.format = zt, this._reductionStorageTex.minFilter = Dt, this._reductionStorageTex.magFilter = Dt, this._reductionReadTarget = new i(1, 1, e), this._adaptationResult = w(1, "vec4"), this._readbackBuffer = new n(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = w(xf, "uint").toAtomic();
|
|
12279
12279
|
}
|
|
12280
12280
|
_buildCompute() {
|
|
12281
12281
|
this._buildDownsampleCompute(), this._buildHistogramCompute(), this._buildHistogramAnalyzeCompute(), this._buildAdaptationCompute();
|
|
@@ -12309,7 +12309,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
|
|
|
12309
12309
|
for (let i = 0; i < 16; i++) {
|
|
12310
12310
|
let a = r.mul(16).add(i), o = a.mod(64), s = a.div(64), c = z(e, P(N(o), N(s))), l = c.x, u = c.y;
|
|
12311
12311
|
p(u.greaterThan(0), () => {
|
|
12312
|
-
let e = B(l.div(u).sub(j(
|
|
12312
|
+
let e = B(l.div(u).sub(j(Sf)).div(j(Cf)).mul(j(xf)).floor().clamp(0, j(xf - 1))), r = j(o).add(.5).div(j(64)), i = j(s).add(.5).div(j(64)), a = r.sub(.5), c = i.sub(.5), d = B(a.mul(a).add(c.mul(c)).mul(n).negate().exp().mul(j(Tf)));
|
|
12313
12313
|
x(t.element(e), d);
|
|
12314
12314
|
});
|
|
12315
12315
|
}
|
|
@@ -12327,14 +12327,14 @@ var ef = ai("wavefront"), tf = 256, nf = [
|
|
|
12327
12327
|
let e = this._histogramBuffer, t = this._reductionStorageTex, n = this.lowPercentileU, r = this.highPercentileU;
|
|
12328
12328
|
this._histogramAnalyzeNode = f(() => {
|
|
12329
12329
|
let i = j(0).toVar();
|
|
12330
|
-
m(
|
|
12330
|
+
m(xf, ({ i: t }) => {
|
|
12331
12331
|
i.addAssign(j(S(e.element(t))));
|
|
12332
12332
|
});
|
|
12333
12333
|
let a = i.mul(n), o = i.mul(r), s = j(0).toVar(), c = j(0).toVar(), l = j(0).toVar(), u = j(0).toVar();
|
|
12334
|
-
m(
|
|
12334
|
+
m(xf, ({ i: t }) => {
|
|
12335
12335
|
let n = j(S(e.element(t)));
|
|
12336
12336
|
u.assign(s), s.addAssign(n), p(u.lessThan(o).and(s.greaterThan(a)), () => {
|
|
12337
|
-
let e = j(
|
|
12337
|
+
let e = j(Sf).add(j(t).add(.5).mul(j(wf)));
|
|
12338
12338
|
c.addAssign(e.mul(n)), l.addAssign(n);
|
|
12339
12339
|
});
|
|
12340
12340
|
});
|
|
@@ -12349,7 +12349,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
|
|
|
12349
12349
|
_buildAdaptationCompute() {
|
|
12350
12350
|
let e = this._reductionReadTexNode, t = this._adaptationResult, n = this.keyValueU, r = this.minExposureU, i = this.maxExposureU, a = this.adaptSpeedBrightU, o = this.adaptSpeedDarkU, s = this.deltaTimeU, c = this.isFirstFrameU, l = this.previousExposureU;
|
|
12351
12351
|
this._adaptationComputeNode = f(() => {
|
|
12352
|
-
let u = z(e, P(N(0), N(0))).x, d =
|
|
12352
|
+
let u = z(e, P(N(0), N(0))).x, d = Ef(u, l, n, r, i, a, o, s, c);
|
|
12353
12353
|
t.element(B(0)).assign(d);
|
|
12354
12354
|
})().compute(1, [
|
|
12355
12355
|
1,
|
|
@@ -12413,7 +12413,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
|
|
|
12413
12413
|
dispose() {
|
|
12414
12414
|
this._downsampleComputeNode?.dispose(), this._histogramComputeNode?.dispose(), this._histogramAnalyzeNode?.dispose(), this._adaptationComputeNode?.dispose(), this._downsampleTarget?.dispose(), this._downsampleStorageTex?.dispose(), this._reductionStorageTex?.dispose(), this._reductionReadTarget?.dispose(), this._readbackBuffer?.dispose(), this._inputTexNode?.dispose(), this._reductionReadTexNode?.dispose();
|
|
12415
12415
|
}
|
|
12416
|
-
},
|
|
12416
|
+
}, Of = class extends cr {
|
|
12417
12417
|
constructor(n, r = {}) {
|
|
12418
12418
|
super("Compositor", {
|
|
12419
12419
|
...r,
|
|
@@ -12467,7 +12467,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
|
|
|
12467
12467
|
dispose() {
|
|
12468
12468
|
this._sourceTexNode?.dispose(), this.compositorMaterial?.dispose(), this._debugTexNode?.dispose(), this._debugMaterial?.dispose(), this.compositorQuad = null, this._debugQuad = null, this._debugMaterial = null, this._debugTexNode = null, this._pathTracer = null;
|
|
12469
12469
|
}
|
|
12470
|
-
},
|
|
12470
|
+
}, kf = class {
|
|
12471
12471
|
constructor() {
|
|
12472
12472
|
this.textures = /* @__PURE__ */ new Map(), this.renderTargets = /* @__PURE__ */ new Map(), this.uniforms = /* @__PURE__ */ new Map(), this.state = {
|
|
12473
12473
|
frame: 0,
|
|
@@ -12589,7 +12589,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
|
|
|
12589
12589
|
dispose() {
|
|
12590
12590
|
this.textures.clear(), this.renderTargets.clear(), this.uniforms.clear(), this._stateChangeCallbacks.clear(), this.state = {};
|
|
12591
12591
|
}
|
|
12592
|
-
},
|
|
12592
|
+
}, Af = class extends lt {
|
|
12593
12593
|
constructor() {
|
|
12594
12594
|
super(), this._onceCallbacks = /* @__PURE__ */ new Map();
|
|
12595
12595
|
}
|
|
@@ -12627,38 +12627,38 @@ var ef = ai("wavefront"), tf = 256, nf = [
|
|
|
12627
12627
|
eventNames() {
|
|
12628
12628
|
return this._listeners ? Object.keys(this._listeners) : [];
|
|
12629
12629
|
}
|
|
12630
|
-
},
|
|
12631
|
-
function
|
|
12632
|
-
|
|
12633
|
-
}
|
|
12634
|
-
function Pf() {
|
|
12635
|
-
return jf.slice();
|
|
12630
|
+
}, jf = !1, Mf = [], Nf = /* @__PURE__ */ new WeakMap();
|
|
12631
|
+
function Pf(e) {
|
|
12632
|
+
jf = !!e;
|
|
12636
12633
|
}
|
|
12637
12634
|
function Ff() {
|
|
12638
|
-
|
|
12635
|
+
return Mf.slice();
|
|
12636
|
+
}
|
|
12637
|
+
function If() {
|
|
12638
|
+
Mf.length = 0;
|
|
12639
12639
|
}
|
|
12640
|
-
function
|
|
12640
|
+
function Lf(e) {
|
|
12641
12641
|
let t = [];
|
|
12642
12642
|
for (let n of Object.keys(e)) e[n]?.isTextureNode === !0 && t.push(n);
|
|
12643
12643
|
return t;
|
|
12644
12644
|
}
|
|
12645
|
-
var
|
|
12646
|
-
function
|
|
12647
|
-
if (!
|
|
12645
|
+
var Rf = (e) => !e || !e.image || !(e.image.width > 0);
|
|
12646
|
+
function zf(e, t, n) {
|
|
12647
|
+
if (!jf) {
|
|
12648
12648
|
n();
|
|
12649
12649
|
return;
|
|
12650
12650
|
}
|
|
12651
|
-
let r =
|
|
12651
|
+
let r = Nf.get(e);
|
|
12652
12652
|
if (r || (r = {
|
|
12653
12653
|
phase: "pending",
|
|
12654
12654
|
unboundAtCompile: []
|
|
12655
|
-
},
|
|
12656
|
-
n(), r.phase === "watch" &&
|
|
12655
|
+
}, Nf.set(e, r)), r.phase !== "pending") {
|
|
12656
|
+
n(), r.phase === "watch" && Bf(e, r);
|
|
12657
12657
|
return;
|
|
12658
12658
|
}
|
|
12659
12659
|
let i = Object.prototype.hasOwnProperty.call(t, "compute"), a = t.compute;
|
|
12660
12660
|
t.compute = function(...t) {
|
|
12661
|
-
return r.phase === "pending" && (r.unboundAtCompile =
|
|
12661
|
+
return r.phase === "pending" && (r.unboundAtCompile = Lf(e).filter((t) => Rf(e[t].value)), r.phase = r.unboundAtCompile.length < 2 ? "done" : "watch"), a.apply(this, t);
|
|
12662
12662
|
};
|
|
12663
12663
|
try {
|
|
12664
12664
|
n();
|
|
@@ -12666,14 +12666,14 @@ function Rf(e, t, n) {
|
|
|
12666
12666
|
i ? t.compute = a : delete t.compute;
|
|
12667
12667
|
}
|
|
12668
12668
|
}
|
|
12669
|
-
function
|
|
12669
|
+
function Bf(e, t) {
|
|
12670
12670
|
let n = [];
|
|
12671
12671
|
for (let r of t.unboundAtCompile) {
|
|
12672
12672
|
let t = e[r]?.value;
|
|
12673
|
-
if (
|
|
12673
|
+
if (Rf(t)) return;
|
|
12674
12674
|
t.isStorageTexture !== !0 && n.push(r);
|
|
12675
12675
|
}
|
|
12676
|
-
t.phase = "done", n.length !== 0 &&
|
|
12676
|
+
t.phase = "done", n.length !== 0 && Mf.push({
|
|
12677
12677
|
stage: e.name,
|
|
12678
12678
|
nodes: n,
|
|
12679
12679
|
unboundAtCompile: t.unboundAtCompile.slice(),
|
|
@@ -12682,9 +12682,9 @@ function zf(e, t) {
|
|
|
12682
12682
|
}
|
|
12683
12683
|
//#endregion
|
|
12684
12684
|
//#region src/Pipeline/RenderPipeline.js
|
|
12685
|
-
var
|
|
12685
|
+
var Vf = class {
|
|
12686
12686
|
constructor(e, t, n) {
|
|
12687
|
-
this.renderer = e, this.width = t, this.height = n, this.stages = [], this.context = new
|
|
12687
|
+
this.renderer = e, this.width = t, this.height = n, this.stages = [], this.context = new kf(), this.eventBus = new Af(), this.context.setState("width", t), this.context.setState("height", n), this.stats = {
|
|
12688
12688
|
enabled: !1,
|
|
12689
12689
|
logSkipped: !1,
|
|
12690
12690
|
timings: /* @__PURE__ */ new Map(),
|
|
@@ -12718,7 +12718,7 @@ var Bf = class {
|
|
|
12718
12718
|
}
|
|
12719
12719
|
try {
|
|
12720
12720
|
let n = this.stats.enabled ? performance.now() : 0;
|
|
12721
|
-
if (
|
|
12721
|
+
if (zf(t, this.renderer, () => t.render(this.context, e)), this.stats.enabled) {
|
|
12722
12722
|
let e = performance.now() - n;
|
|
12723
12723
|
this.stats.timings.has(t.name) || this.stats.timings.set(t.name, []);
|
|
12724
12724
|
let r = this.stats.timings.get(t.name);
|
|
@@ -12816,7 +12816,7 @@ var Bf = class {
|
|
|
12816
12816
|
let e = this.getInfo();
|
|
12817
12817
|
console.group("[Pipeline] Info"), console.log("Stages:", e.stages), console.log("Context Textures:", e.textures), console.log("Context Render Targets:", e.renderTargets), console.log("Context Uniforms:", e.uniforms), console.log("Event Types:", e.events), console.log("State:", e.contextState), console.groupEnd();
|
|
12818
12818
|
}
|
|
12819
|
-
},
|
|
12819
|
+
}, Hf = class {
|
|
12820
12820
|
constructor() {
|
|
12821
12821
|
this.timeElapsed = 0, this.lastResetTime = performance.now(), this.renderCompleteDispatched = !1;
|
|
12822
12822
|
}
|
|
@@ -12838,7 +12838,7 @@ var Bf = class {
|
|
|
12838
12838
|
resumeFromPause() {
|
|
12839
12839
|
this.renderCompleteDispatched = !1, this.lastResetTime = performance.now() - this.timeElapsed * 1e3;
|
|
12840
12840
|
}
|
|
12841
|
-
},
|
|
12841
|
+
}, Uf = class extends lt {
|
|
12842
12842
|
constructor({ scene: e, camera: t, canvas: n, assetLoader: r, pathTracer: i, floorPlane: a }) {
|
|
12843
12843
|
super(), this.scene = e, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new Ht(), this.focusMode = !1, this.focusPointIndicator = null, this.afPointPlacementMode = !1, this.handleAFPointClick = this.handleAFPointClick.bind(this), this.selectedObject = null, this.selectMode = !1, this.clickTimeout = null, this.mouseDownPosition = null, this.dragThreshold = 5, this.handleFocusClick = this.handleFocusClick.bind(this), this.handleSelectClick = this.handleSelectClick.bind(this), this.handleSelectDoubleClick = this.handleSelectDoubleClick.bind(this), this.handleMouseDown = this.handleMouseDown.bind(this), this.handleMouseUp = this.handleMouseUp.bind(this), this.handleContextMenu = this.handleContextMenu.bind(this), this.handleContextPointerDown = this.handleContextPointerDown.bind(this), this.handleContextPointerUp = this.handleContextPointerUp.bind(this), this.contextPointerDownPosition = null, this.canvas.addEventListener("pointerdown", this.handleContextPointerDown), this.canvas.addEventListener("pointerup", this.handleContextPointerUp), this.canvas.addEventListener("contextmenu", this.handleContextMenu), this._overlayManager = null, this._transformManager = null, this._appDispatch = null, this._orbitControls = null, this._helperScene = null;
|
|
12844
12844
|
}
|
|
@@ -13074,18 +13074,18 @@ var Bf = class {
|
|
|
13074
13074
|
dispose() {
|
|
13075
13075
|
this.canvas.removeEventListener("click", this.handleAFPointClick), this.canvas.removeEventListener("click", this.handleFocusClick), this.canvas.removeEventListener("mousedown", this.handleMouseDown), this.canvas.removeEventListener("mouseup", this.handleMouseUp), this.canvas.removeEventListener("click", this.handleSelectClick), this.canvas.removeEventListener("dblclick", this.handleSelectDoubleClick), this.canvas.removeEventListener("contextmenu", this.handleContextMenu), this.canvas.removeEventListener("pointerdown", this.handleContextPointerDown), this.canvas.removeEventListener("pointerup", this.handleContextPointerUp), this.clickTimeout &&= (clearTimeout(this.clickTimeout), null), this.mouseDownPosition = null, this.contextPointerDownPosition = null, this.focusPointIndicator &&= (this.scene.remove(this.focusPointIndicator), null), this.canvas.style.cursor = "auto", this.scene = null, this.camera = null, this.canvas = null, this.assetLoader = null, this.pathTracer = null, this.floorPlane = null, this.raycaster = null;
|
|
13076
13076
|
}
|
|
13077
|
-
},
|
|
13077
|
+
}, Wf = {
|
|
13078
13078
|
STRING: "string",
|
|
13079
13079
|
NUMBER: "number",
|
|
13080
13080
|
WORD: "word",
|
|
13081
13081
|
LBRACKET: "[",
|
|
13082
13082
|
RBRACKET: "]"
|
|
13083
|
-
},
|
|
13084
|
-
function
|
|
13083
|
+
}, Gf = (e) => e === " " || e === " " || e === "\n" || e === "\r" || e === "\f", Kf = (e) => e >= "0" && e <= "9", qf = (e, t, n) => !!(Kf(e) || e === "." && Kf(t) || (e === "-" || e === "+") && (Kf(t) || t === "." && Kf(n)));
|
|
13084
|
+
function Jf(e) {
|
|
13085
13085
|
let t = [], n = e.length, r = 0;
|
|
13086
13086
|
for (; r < n;) {
|
|
13087
13087
|
let i = e[r];
|
|
13088
|
-
if (
|
|
13088
|
+
if (Gf(i)) {
|
|
13089
13089
|
r++;
|
|
13090
13090
|
continue;
|
|
13091
13091
|
}
|
|
@@ -13094,11 +13094,11 @@ function qf(e) {
|
|
|
13094
13094
|
continue;
|
|
13095
13095
|
}
|
|
13096
13096
|
if (i === "[") {
|
|
13097
|
-
t.push({ type:
|
|
13097
|
+
t.push({ type: Wf.LBRACKET }), r++;
|
|
13098
13098
|
continue;
|
|
13099
13099
|
}
|
|
13100
13100
|
if (i === "]") {
|
|
13101
|
-
t.push({ type:
|
|
13101
|
+
t.push({ type: Wf.RBRACKET }), r++;
|
|
13102
13102
|
continue;
|
|
13103
13103
|
}
|
|
13104
13104
|
if (i === "\"") {
|
|
@@ -13107,12 +13107,12 @@ function qf(e) {
|
|
|
13107
13107
|
for (; r < n && e[r] !== "\"";) r++;
|
|
13108
13108
|
if (r >= n) throw Error("PBRT tokenizer: unterminated string literal");
|
|
13109
13109
|
t.push({
|
|
13110
|
-
type:
|
|
13110
|
+
type: Wf.STRING,
|
|
13111
13111
|
value: e.slice(i, r)
|
|
13112
13112
|
}), r++;
|
|
13113
13113
|
continue;
|
|
13114
13114
|
}
|
|
13115
|
-
if (
|
|
13115
|
+
if (qf(i, e[r + 1], e[r + 2])) {
|
|
13116
13116
|
let i = r;
|
|
13117
13117
|
for (r++; r < n;) {
|
|
13118
13118
|
let t = e[r];
|
|
@@ -13122,16 +13122,16 @@ function qf(e) {
|
|
|
13122
13122
|
let a = e.slice(i, r), o = Number(a);
|
|
13123
13123
|
if (Number.isNaN(o)) throw Error(`PBRT tokenizer: invalid number "${a}"`);
|
|
13124
13124
|
t.push({
|
|
13125
|
-
type:
|
|
13125
|
+
type: Wf.NUMBER,
|
|
13126
13126
|
value: o
|
|
13127
13127
|
});
|
|
13128
13128
|
continue;
|
|
13129
13129
|
}
|
|
13130
13130
|
{
|
|
13131
13131
|
let i = r;
|
|
13132
|
-
for (; r < n && !
|
|
13132
|
+
for (; r < n && !Gf(e[r]) && e[r] !== "\"" && e[r] !== "[" && e[r] !== "]" && e[r] !== "#";) r++;
|
|
13133
13133
|
t.push({
|
|
13134
|
-
type:
|
|
13134
|
+
type: Wf.WORD,
|
|
13135
13135
|
value: e.slice(i, r)
|
|
13136
13136
|
});
|
|
13137
13137
|
}
|
|
@@ -13140,7 +13140,7 @@ function qf(e) {
|
|
|
13140
13140
|
}
|
|
13141
13141
|
//#endregion
|
|
13142
13142
|
//#region src/Processor/PBRT/PBRTMath.js
|
|
13143
|
-
function
|
|
13143
|
+
function Yf() {
|
|
13144
13144
|
return [
|
|
13145
13145
|
1,
|
|
13146
13146
|
0,
|
|
@@ -13160,7 +13160,7 @@ function Jf() {
|
|
|
13160
13160
|
1
|
|
13161
13161
|
];
|
|
13162
13162
|
}
|
|
13163
|
-
function
|
|
13163
|
+
function Xf(e, t) {
|
|
13164
13164
|
let n = e[0], r = e[1], i = e[2], a = e[3], o = e[4], s = e[5], c = e[6], l = e[7], u = e[8], d = e[9], f = e[10], p = e[11], m = e[12], h = e[13], g = e[14], _ = e[15], v = t[0], y = t[1], b = t[2], x = t[3], S = t[4], C = t[5], w = t[6], T = t[7], E = t[8], D = t[9], O = t[10], k = t[11], A = t[12], ee = t[13], te = t[14], j = t[15];
|
|
13165
13165
|
return [
|
|
13166
13166
|
n * v + o * y + u * b + m * x,
|
|
@@ -13181,7 +13181,7 @@ function Yf(e, t) {
|
|
|
13181
13181
|
a * A + l * ee + p * te + _ * j
|
|
13182
13182
|
];
|
|
13183
13183
|
}
|
|
13184
|
-
function
|
|
13184
|
+
function Zf(e, t, n) {
|
|
13185
13185
|
return [
|
|
13186
13186
|
1,
|
|
13187
13187
|
0,
|
|
@@ -13201,7 +13201,7 @@ function Xf(e, t, n) {
|
|
|
13201
13201
|
1
|
|
13202
13202
|
];
|
|
13203
13203
|
}
|
|
13204
|
-
function
|
|
13204
|
+
function Qf(e, t, n) {
|
|
13205
13205
|
return [
|
|
13206
13206
|
e,
|
|
13207
13207
|
0,
|
|
@@ -13221,7 +13221,7 @@ function Zf(e, t, n) {
|
|
|
13221
13221
|
1
|
|
13222
13222
|
];
|
|
13223
13223
|
}
|
|
13224
|
-
function
|
|
13224
|
+
function $f(e, t, n, r) {
|
|
13225
13225
|
let i = Math.hypot(t, n, r) || 1;
|
|
13226
13226
|
t /= i, n /= i, r /= i;
|
|
13227
13227
|
let a = e * Math.PI / 180, o = Math.cos(a), s = Math.sin(a), c = 1 - o, l = c * t * t + o, u = c * t * n - s * r, d = c * t * r + s * n, f = c * t * n + s * r, p = c * n * n + o, m = c * n * r - s * t;
|
|
@@ -13244,21 +13244,21 @@ function Qf(e, t, n, r) {
|
|
|
13244
13244
|
1
|
|
13245
13245
|
];
|
|
13246
13246
|
}
|
|
13247
|
-
function
|
|
13247
|
+
function ep(e, t) {
|
|
13248
13248
|
return [
|
|
13249
13249
|
e[0] - t[0],
|
|
13250
13250
|
e[1] - t[1],
|
|
13251
13251
|
e[2] - t[2]
|
|
13252
13252
|
];
|
|
13253
13253
|
}
|
|
13254
|
-
function
|
|
13254
|
+
function tp(e, t) {
|
|
13255
13255
|
return [
|
|
13256
13256
|
e[1] * t[2] - e[2] * t[1],
|
|
13257
13257
|
e[2] * t[0] - e[0] * t[2],
|
|
13258
13258
|
e[0] * t[1] - e[1] * t[0]
|
|
13259
13259
|
];
|
|
13260
13260
|
}
|
|
13261
|
-
function
|
|
13261
|
+
function np(e) {
|
|
13262
13262
|
let t = Math.hypot(e[0], e[1], e[2]) || 1;
|
|
13263
13263
|
return [
|
|
13264
13264
|
e[0] / t,
|
|
@@ -13266,8 +13266,8 @@ function tp(e) {
|
|
|
13266
13266
|
e[2] / t
|
|
13267
13267
|
];
|
|
13268
13268
|
}
|
|
13269
|
-
function
|
|
13270
|
-
let r =
|
|
13269
|
+
function rp(e, t, n) {
|
|
13270
|
+
let r = np(ep(t, e)), i = np(tp(np(n), r)), a = tp(r, i);
|
|
13271
13271
|
return [
|
|
13272
13272
|
i[0],
|
|
13273
13273
|
i[1],
|
|
@@ -13287,9 +13287,9 @@ function np(e, t, n) {
|
|
|
13287
13287
|
1
|
|
13288
13288
|
];
|
|
13289
13289
|
}
|
|
13290
|
-
function
|
|
13290
|
+
function ip(e) {
|
|
13291
13291
|
let t = e[0], n = e[1], r = e[2], i = e[3], a = e[4], o = e[5], s = e[6], c = e[7], l = e[8], u = e[9], d = e[10], f = e[11], p = e[12], m = e[13], h = e[14], g = e[15], _ = u * h * c - m * d * c + m * s * f - o * h * f - u * s * g + o * d * g, v = p * d * c - l * h * c - p * s * f + a * h * f + l * s * g - a * d * g, y = l * m * c - p * u * c + p * o * f - a * m * f - l * o * g + a * u * g, b = p * u * s - l * m * s - p * o * d + a * m * d + l * o * h - a * u * h, x = t * _ + n * v + r * y + i * b;
|
|
13292
|
-
if (x === 0) return
|
|
13292
|
+
if (x === 0) return Yf();
|
|
13293
13293
|
let S = 1 / x;
|
|
13294
13294
|
return [
|
|
13295
13295
|
_ * S,
|
|
@@ -13312,7 +13312,7 @@ function rp(e) {
|
|
|
13312
13312
|
}
|
|
13313
13313
|
//#endregion
|
|
13314
13314
|
//#region src/Processor/PBRT/PBRTParser.js
|
|
13315
|
-
var
|
|
13315
|
+
var ap = class {
|
|
13316
13316
|
constructor(e = {}) {
|
|
13317
13317
|
this.resolveInclude = e.resolveInclude || (() => {
|
|
13318
13318
|
throw Error("PBRTParser: Include used but no resolveInclude provided");
|
|
@@ -13326,14 +13326,14 @@ var ip = class {
|
|
|
13326
13326
|
instances: [],
|
|
13327
13327
|
objects: /* @__PURE__ */ new Map(),
|
|
13328
13328
|
warnings: []
|
|
13329
|
-
}, this.ctm =
|
|
13329
|
+
}, this.ctm = Yf(), this.state = {
|
|
13330
13330
|
material: null,
|
|
13331
13331
|
areaLight: null,
|
|
13332
13332
|
reverseOrientation: !1
|
|
13333
13333
|
}, this.attributeStack = [], this.transformStack = [], this.coordSystems = /* @__PURE__ */ new Map(), this.currentObject = null, this.objectBeginCTM = null, this.dirStack = [""], this.tokens = [], this.pos = 0, this._warnedUnknown = /* @__PURE__ */ new Set();
|
|
13334
13334
|
}
|
|
13335
13335
|
parse(e, t = "") {
|
|
13336
|
-
return this.dirStack = [t], this._run(
|
|
13336
|
+
return this.dirStack = [t], this._run(Jf(e)), this.ir;
|
|
13337
13337
|
}
|
|
13338
13338
|
_peek() {
|
|
13339
13339
|
return this.tokens[this.pos];
|
|
@@ -13343,12 +13343,12 @@ var ip = class {
|
|
|
13343
13343
|
}
|
|
13344
13344
|
_expectNumber(e) {
|
|
13345
13345
|
let t = this._next();
|
|
13346
|
-
if (!t || t.type !==
|
|
13346
|
+
if (!t || t.type !== Wf.NUMBER) throw Error(`PBRT parser: expected number for ${e}, got ${t ? t.value : "EOF"}`);
|
|
13347
13347
|
return t.value;
|
|
13348
13348
|
}
|
|
13349
13349
|
_expectString(e) {
|
|
13350
13350
|
let t = this._next();
|
|
13351
|
-
if (!t || t.type !==
|
|
13351
|
+
if (!t || t.type !== Wf.STRING) throw Error(`PBRT parser: expected string for ${e}, got ${t ? t.value : "EOF"}`);
|
|
13352
13352
|
return t.value;
|
|
13353
13353
|
}
|
|
13354
13354
|
_readNumbers(e) {
|
|
@@ -13357,17 +13357,17 @@ var ip = class {
|
|
|
13357
13357
|
return t;
|
|
13358
13358
|
}
|
|
13359
13359
|
_readBracketedOrBareNumbers(e) {
|
|
13360
|
-
if (this._peek() && this._peek().type ===
|
|
13360
|
+
if (this._peek() && this._peek().type === Wf.LBRACKET) {
|
|
13361
13361
|
this._next();
|
|
13362
13362
|
let e = [];
|
|
13363
|
-
for (; this._peek() && this._peek().type !==
|
|
13363
|
+
for (; this._peek() && this._peek().type !== Wf.RBRACKET;) e.push(this._expectNumber("transform element"));
|
|
13364
13364
|
return this._next(), e;
|
|
13365
13365
|
}
|
|
13366
13366
|
return this._readNumbers(e);
|
|
13367
13367
|
}
|
|
13368
13368
|
_parseParams() {
|
|
13369
13369
|
let e = {};
|
|
13370
|
-
for (; this._peek() && this._peek().type ===
|
|
13370
|
+
for (; this._peek() && this._peek().type === Wf.STRING;) {
|
|
13371
13371
|
let t = this._next().value.trim().split(/\s+/), n = t[0], r = t[1] === void 0 ? t[0] : t[1];
|
|
13372
13372
|
e[r] = {
|
|
13373
13373
|
type: n,
|
|
@@ -13378,23 +13378,23 @@ var ip = class {
|
|
|
13378
13378
|
}
|
|
13379
13379
|
_parseParamValue() {
|
|
13380
13380
|
let e = [];
|
|
13381
|
-
if (this._peek() && this._peek().type ===
|
|
13382
|
-
for (this._next(); this._peek() && this._peek().type !==
|
|
13381
|
+
if (this._peek() && this._peek().type === Wf.LBRACKET) {
|
|
13382
|
+
for (this._next(); this._peek() && this._peek().type !== Wf.RBRACKET;) e.push(this._coerceValueToken(this._next()));
|
|
13383
13383
|
this._next();
|
|
13384
13384
|
} else e.push(this._coerceValueToken(this._next()));
|
|
13385
13385
|
return e;
|
|
13386
13386
|
}
|
|
13387
13387
|
_coerceValueToken(e) {
|
|
13388
13388
|
if (!e) throw Error("PBRT parser: unexpected EOF in parameter value");
|
|
13389
|
-
if (e.type ===
|
|
13390
|
-
if (e.type ===
|
|
13389
|
+
if (e.type === Wf.NUMBER || e.type === Wf.STRING) return e.value;
|
|
13390
|
+
if (e.type === Wf.WORD) return e.value === "true" ? !0 : e.value === "false" ? !1 : e.value;
|
|
13391
13391
|
throw Error(`PBRT parser: unexpected token in parameter value: ${e.type}`);
|
|
13392
13392
|
}
|
|
13393
13393
|
_run(e) {
|
|
13394
13394
|
let t = this.tokens, n = this.pos;
|
|
13395
13395
|
for (this.tokens = e, this.pos = 0; this.pos < this.tokens.length;) {
|
|
13396
13396
|
let e = this._next();
|
|
13397
|
-
if (e.type !==
|
|
13397
|
+
if (e.type !== Wf.WORD) throw Error(`PBRT parser: expected directive, got ${e.type} ${e.value ?? ""}`);
|
|
13398
13398
|
this._directive(e.value);
|
|
13399
13399
|
}
|
|
13400
13400
|
this.tokens = t, this.pos = n;
|
|
@@ -13402,25 +13402,25 @@ var ip = class {
|
|
|
13402
13402
|
_directive(e) {
|
|
13403
13403
|
switch (e) {
|
|
13404
13404
|
case "Identity":
|
|
13405
|
-
this.ctm =
|
|
13405
|
+
this.ctm = Yf();
|
|
13406
13406
|
break;
|
|
13407
13407
|
case "Translate": {
|
|
13408
13408
|
let [e, t, n] = this._readNumbers(3);
|
|
13409
|
-
this.ctm =
|
|
13409
|
+
this.ctm = Xf(this.ctm, Zf(e, t, n));
|
|
13410
13410
|
break;
|
|
13411
13411
|
}
|
|
13412
13412
|
case "Scale": {
|
|
13413
13413
|
let [e, t, n] = this._readNumbers(3);
|
|
13414
|
-
this.ctm =
|
|
13414
|
+
this.ctm = Xf(this.ctm, Qf(e, t, n));
|
|
13415
13415
|
break;
|
|
13416
13416
|
}
|
|
13417
13417
|
case "Rotate": {
|
|
13418
13418
|
let [e, t, n, r] = this._readNumbers(4);
|
|
13419
|
-
this.ctm =
|
|
13419
|
+
this.ctm = Xf(this.ctm, $f(e, t, n, r));
|
|
13420
13420
|
break;
|
|
13421
13421
|
}
|
|
13422
13422
|
case "LookAt": {
|
|
13423
|
-
let e = this._readNumbers(9), t =
|
|
13423
|
+
let e = this._readNumbers(9), t = rp([
|
|
13424
13424
|
e[0],
|
|
13425
13425
|
e[1],
|
|
13426
13426
|
e[2]
|
|
@@ -13433,7 +13433,7 @@ var ip = class {
|
|
|
13433
13433
|
e[7],
|
|
13434
13434
|
e[8]
|
|
13435
13435
|
]);
|
|
13436
|
-
this.ctm =
|
|
13436
|
+
this.ctm = Xf(this.ctm, ip(t));
|
|
13437
13437
|
break;
|
|
13438
13438
|
}
|
|
13439
13439
|
case "Transform":
|
|
@@ -13441,7 +13441,7 @@ var ip = class {
|
|
|
13441
13441
|
break;
|
|
13442
13442
|
case "ConcatTransform": {
|
|
13443
13443
|
let e = this._readBracketedOrBareNumbers(16);
|
|
13444
|
-
this.ctm =
|
|
13444
|
+
this.ctm = Xf(this.ctm, e);
|
|
13445
13445
|
break;
|
|
13446
13446
|
}
|
|
13447
13447
|
case "CoordinateSystem":
|
|
@@ -13457,7 +13457,7 @@ var ip = class {
|
|
|
13457
13457
|
this.ir.camera = {
|
|
13458
13458
|
type: e,
|
|
13459
13459
|
params: t,
|
|
13460
|
-
cameraToWorld:
|
|
13460
|
+
cameraToWorld: ip(this.ctm)
|
|
13461
13461
|
};
|
|
13462
13462
|
break;
|
|
13463
13463
|
}
|
|
@@ -13481,7 +13481,7 @@ var ip = class {
|
|
|
13481
13481
|
this._skipTypeAndParams();
|
|
13482
13482
|
break;
|
|
13483
13483
|
case "WorldBegin":
|
|
13484
|
-
this.ctm =
|
|
13484
|
+
this.ctm = Yf(), this.state = {
|
|
13485
13485
|
material: null,
|
|
13486
13486
|
areaLight: null,
|
|
13487
13487
|
reverseOrientation: !1
|
|
@@ -13526,7 +13526,7 @@ var ip = class {
|
|
|
13526
13526
|
this._readNumbers(2);
|
|
13527
13527
|
break;
|
|
13528
13528
|
case "MediumInterface":
|
|
13529
|
-
this._peek() && this._peek().type ===
|
|
13529
|
+
this._peek() && this._peek().type === Wf.STRING && this._next(), this._peek() && this._peek().type === Wf.STRING && this._next();
|
|
13530
13530
|
break;
|
|
13531
13531
|
case "MakeNamedMedium":
|
|
13532
13532
|
this._skipNamedAndParams();
|
|
@@ -13634,7 +13634,7 @@ var ip = class {
|
|
|
13634
13634
|
}
|
|
13635
13635
|
}
|
|
13636
13636
|
_emitShape(e) {
|
|
13637
|
-
this.currentObject === null ? this.ir.shapes.push(e) : (e.relativeCTM =
|
|
13637
|
+
this.currentObject === null ? this.ir.shapes.push(e) : (e.relativeCTM = Xf(ip(this.objectBeginCTM), e.ctm), this.ir.objects.get(this.currentObject).push(e));
|
|
13638
13638
|
}
|
|
13639
13639
|
_include(e) {
|
|
13640
13640
|
let t = this.resolveInclude(e, this.dirStack[this.dirStack.length - 1]);
|
|
@@ -13643,13 +13643,13 @@ var ip = class {
|
|
|
13643
13643
|
return;
|
|
13644
13644
|
}
|
|
13645
13645
|
let n = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "";
|
|
13646
|
-
this.dirStack.push(n), this._run(
|
|
13646
|
+
this.dirStack.push(n), this._run(Jf(t)), this.dirStack.pop();
|
|
13647
13647
|
}
|
|
13648
13648
|
_skipTypeAndParams() {
|
|
13649
|
-
this._peek() && this._peek().type ===
|
|
13649
|
+
this._peek() && this._peek().type === Wf.STRING && this._next(), this._parseParams();
|
|
13650
13650
|
}
|
|
13651
13651
|
_skipNamedAndParams() {
|
|
13652
|
-
this._peek() && this._peek().type ===
|
|
13652
|
+
this._peek() && this._peek().type === Wf.STRING && this._next(), this._parseParams();
|
|
13653
13653
|
}
|
|
13654
13654
|
_num(e, t) {
|
|
13655
13655
|
return e && e.value.length ? e.value[0] : t;
|
|
@@ -13663,7 +13663,7 @@ var ip = class {
|
|
|
13663
13663
|
_warnUnknown(e) {
|
|
13664
13664
|
this._warnedUnknown.has(e) || (this._warnedUnknown.add(e), this._warn(`Unsupported directive ignored: ${e}`));
|
|
13665
13665
|
}
|
|
13666
|
-
},
|
|
13666
|
+
}, op = {
|
|
13667
13667
|
au: [
|
|
13668
13668
|
1,
|
|
13669
13669
|
.78,
|
|
@@ -13719,12 +13719,12 @@ var ip = class {
|
|
|
13719
13719
|
.9,
|
|
13720
13720
|
.9
|
|
13721
13721
|
]
|
|
13722
|
-
},
|
|
13722
|
+
}, sp = [
|
|
13723
13723
|
.92,
|
|
13724
13724
|
.92,
|
|
13725
13725
|
.92
|
|
13726
13726
|
];
|
|
13727
|
-
function
|
|
13727
|
+
function cp(e) {
|
|
13728
13728
|
let t = Math.max(1e3, Math.min(4e4, e)) / 100, n, r, i;
|
|
13729
13729
|
t <= 66 ? (n = 255, r = 99.47 * Math.log(t) - 161.12) : (n = 329.7 * (t - 60) ** -.1332, r = 288.12 * (t - 60) ** -.0755), i = t >= 66 ? 255 : t <= 19 ? 0 : 138.52 * Math.log(t - 10) - 305.04;
|
|
13730
13730
|
let a = (e) => Math.max(0, Math.min(255, e)) / 255;
|
|
@@ -13734,15 +13734,15 @@ function sp(e) {
|
|
|
13734
13734
|
a(i) ** 2.2
|
|
13735
13735
|
];
|
|
13736
13736
|
}
|
|
13737
|
-
function
|
|
13737
|
+
function lp(e, t, n) {
|
|
13738
13738
|
let r = e[t];
|
|
13739
13739
|
return r && typeof r.value[0] == "number" ? r.value[0] : n;
|
|
13740
13740
|
}
|
|
13741
|
-
function
|
|
13741
|
+
function up(e, t, n) {
|
|
13742
13742
|
let r = e[t];
|
|
13743
13743
|
return r && typeof r.value[0] == "string" ? r.value[0] : n;
|
|
13744
13744
|
}
|
|
13745
|
-
async function
|
|
13745
|
+
async function dp(e, t, n, r = null) {
|
|
13746
13746
|
let i = e[t];
|
|
13747
13747
|
if (!i) return {
|
|
13748
13748
|
rgb: r,
|
|
@@ -13781,14 +13781,14 @@ async function up(e, t, n, r = null) {
|
|
|
13781
13781
|
};
|
|
13782
13782
|
}
|
|
13783
13783
|
if (i.type === "blackbody") return {
|
|
13784
|
-
rgb:
|
|
13784
|
+
rgb: cp(i.value[0]),
|
|
13785
13785
|
texture: null
|
|
13786
13786
|
};
|
|
13787
13787
|
if (i.type === "spectrum") {
|
|
13788
13788
|
if (typeof i.value[0] == "string") {
|
|
13789
|
-
let e =
|
|
13790
|
-
return e &&
|
|
13791
|
-
rgb:
|
|
13789
|
+
let e = fp(i.value[0]);
|
|
13790
|
+
return e && op[e] ? {
|
|
13791
|
+
rgb: op[e].slice(),
|
|
13792
13792
|
texture: null
|
|
13793
13793
|
} : (n.warn(`named spectrum "${i.value[0]}" approximated to gray`), {
|
|
13794
13794
|
rgb: [
|
|
@@ -13816,18 +13816,18 @@ async function up(e, t, n, r = null) {
|
|
|
13816
13816
|
texture: null
|
|
13817
13817
|
};
|
|
13818
13818
|
}
|
|
13819
|
-
function
|
|
13819
|
+
function fp(e) {
|
|
13820
13820
|
let t = e.toLowerCase().match(/metal-([a-z]+)/);
|
|
13821
13821
|
if (t) return t[1];
|
|
13822
|
-
for (let t of Object.keys(
|
|
13822
|
+
for (let t of Object.keys(op)) if (e.toLowerCase().includes(t)) return t;
|
|
13823
13823
|
return null;
|
|
13824
13824
|
}
|
|
13825
|
-
function
|
|
13825
|
+
function pp(e, t) {
|
|
13826
13826
|
if (e.roughness && typeof e.roughness.value[0] == "number") return e.roughness.value[0];
|
|
13827
|
-
let n =
|
|
13827
|
+
let n = lp(e, "uroughness", null), r = lp(e, "vroughness", null);
|
|
13828
13828
|
return n !== null && r !== null ? (n + r) / 2 : n === null ? t : n;
|
|
13829
13829
|
}
|
|
13830
|
-
async function
|
|
13830
|
+
async function mp(e, t) {
|
|
13831
13831
|
let n = e?.type || "diffuse", r = e?.params || {}, i = new Tt({
|
|
13832
13832
|
side: st,
|
|
13833
13833
|
roughness: 1,
|
|
@@ -13839,7 +13839,7 @@ async function pp(e, t) {
|
|
|
13839
13839
|
};
|
|
13840
13840
|
switch (n) {
|
|
13841
13841
|
case "diffuse":
|
|
13842
|
-
o(await
|
|
13842
|
+
o(await dp(r, "reflectance", t, [
|
|
13843
13843
|
.5,
|
|
13844
13844
|
.5,
|
|
13845
13845
|
.5
|
|
@@ -13847,14 +13847,14 @@ async function pp(e, t) {
|
|
|
13847
13847
|
break;
|
|
13848
13848
|
case "conductor":
|
|
13849
13849
|
case "metal": {
|
|
13850
|
-
let e = await
|
|
13850
|
+
let e = await dp(r, "reflectance", t, null), n = r.eta, s = r.k, c = n && n.type === "spectrum" && typeof n.value[0] == "string";
|
|
13851
13851
|
if (e.rgb || e.texture) o(e);
|
|
13852
13852
|
else if (n && s && !c) {
|
|
13853
|
-
let e = (await
|
|
13853
|
+
let e = (await dp(r, "eta", t, [
|
|
13854
13854
|
.2,
|
|
13855
13855
|
.92,
|
|
13856
13856
|
1.1
|
|
13857
|
-
])).rgb, n = (await
|
|
13857
|
+
])).rgb, n = (await dp(r, "k", t, [
|
|
13858
13858
|
3.9,
|
|
13859
13859
|
2.45,
|
|
13860
13860
|
2.14
|
|
@@ -13864,28 +13864,28 @@ async function pp(e, t) {
|
|
|
13864
13864
|
i(e[1], n[1]),
|
|
13865
13865
|
i(e[2], n[2])
|
|
13866
13866
|
]);
|
|
13867
|
-
} else a(n ? (await
|
|
13868
|
-
i.metalness = 1, i.roughness =
|
|
13867
|
+
} else a(n ? (await dp(r, "eta", t, sp)).rgb || sp : op.cu);
|
|
13868
|
+
i.metalness = 1, i.roughness = pp(r, .1);
|
|
13869
13869
|
break;
|
|
13870
13870
|
}
|
|
13871
13871
|
case "dielectric":
|
|
13872
13872
|
case "thindielectric":
|
|
13873
|
-
i.transmission = 1, i.metalness = 0, i.color.setRGB(1, 1, 1), i.ior =
|
|
13873
|
+
i.transmission = 1, i.metalness = 0, i.color.setRGB(1, 1, 1), i.ior = lp(r, "eta", 1.5), i.roughness = pp(r, 0), i.thickness = n === "thindielectric" ? 0 : lp(r, "thickness", 0);
|
|
13874
13874
|
break;
|
|
13875
13875
|
case "coateddiffuse":
|
|
13876
|
-
o(await
|
|
13876
|
+
o(await dp(r, "reflectance", t, [
|
|
13877
13877
|
.5,
|
|
13878
13878
|
.5,
|
|
13879
13879
|
.5
|
|
13880
|
-
])), i.roughness = .6, i.metalness = 0, i.clearcoat = 1, i.clearcoatRoughness =
|
|
13880
|
+
])), i.roughness = .6, i.metalness = 0, i.clearcoat = 1, i.clearcoatRoughness = pp(r, 0);
|
|
13881
13881
|
break;
|
|
13882
13882
|
case "diffusetransmission": {
|
|
13883
|
-
let e = await
|
|
13883
|
+
let e = await dp(r, "transmittance", t, [
|
|
13884
13884
|
.25,
|
|
13885
13885
|
.25,
|
|
13886
13886
|
.25
|
|
13887
13887
|
]);
|
|
13888
|
-
o(await
|
|
13888
|
+
o(await dp(r, "reflectance", t, [
|
|
13889
13889
|
.25,
|
|
13890
13890
|
.25,
|
|
13891
13891
|
.25
|
|
@@ -13898,9 +13898,9 @@ async function pp(e, t) {
|
|
|
13898
13898
|
i.transmission = 1, i.ior = 1, i.roughness = 0, i.color.setRGB(1, 1, 1);
|
|
13899
13899
|
break;
|
|
13900
13900
|
case "mix": {
|
|
13901
|
-
let e = r.materials?.value || [], n = Math.max(0, Math.min(1,
|
|
13901
|
+
let e = r.materials?.value || [], n = Math.max(0, Math.min(1, lp(r, "amount", .5))), a = e[0] ? t.namedMaterials?.get(e[0]) : null, o = e[1] ? t.namedMaterials?.get(e[1]) : null;
|
|
13902
13902
|
if (a && o) {
|
|
13903
|
-
let [e, r] = await Promise.all([
|
|
13903
|
+
let [e, r] = await Promise.all([mp(a, t), mp(o, t)]), s = (e, t) => e * (1 - n) + t * n;
|
|
13904
13904
|
i.color.lerpColors(e.color, r.color, n), i.roughness = s(e.roughness, r.roughness), i.metalness = s(e.metalness, r.metalness), i.ior = s(e.ior ?? 1.5, r.ior ?? 1.5), i.transmission = s(e.transmission ?? 0, r.transmission ?? 0), i.thickness = s(e.thickness ?? 0, r.thickness ?? 0), i.clearcoat = s(e.clearcoat ?? 0, r.clearcoat ?? 0), i.clearcoatRoughness = s(e.clearcoatRoughness ?? 0, r.clearcoatRoughness ?? 0), i.emissive.lerpColors(e.emissive, r.emissive, n), i.emissiveIntensity = s(e.emissiveIntensity ?? 0, r.emissiveIntensity ?? 0), i.map = (n < .5 ? e.map : r.map) || null;
|
|
13905
13905
|
break;
|
|
13906
13906
|
}
|
|
@@ -13910,7 +13910,7 @@ async function pp(e, t) {
|
|
|
13910
13910
|
case "subsurface":
|
|
13911
13911
|
case "hair":
|
|
13912
13912
|
case "measured":
|
|
13913
|
-
t.warn(`material "${n}" not supported — using diffuse approximation`), a((await
|
|
13913
|
+
t.warn(`material "${n}" not supported — using diffuse approximation`), a((await dp(r, "reflectance", t, [
|
|
13914
13914
|
.5,
|
|
13915
13915
|
.5,
|
|
13916
13916
|
.5
|
|
@@ -13924,7 +13924,7 @@ async function pp(e, t) {
|
|
|
13924
13924
|
}
|
|
13925
13925
|
//#endregion
|
|
13926
13926
|
//#region src/Processor/PBRT/PBRTSceneBuilder.js
|
|
13927
|
-
var
|
|
13927
|
+
var hp = [
|
|
13928
13928
|
1,
|
|
13929
13929
|
0,
|
|
13930
13930
|
0,
|
|
@@ -13941,7 +13941,7 @@ var mp = [
|
|
|
13941
13941
|
0,
|
|
13942
13942
|
0,
|
|
13943
13943
|
1
|
|
13944
|
-
],
|
|
13944
|
+
], gp = class {
|
|
13945
13945
|
constructor(e = {}) {
|
|
13946
13946
|
this.resolvePLY = e.resolvePLY || (async () => null), this.resolveImage = e.resolveImage || (async () => null), this.resolveEnvironment = e.resolveEnvironment || e.resolveImage || (async () => null), this.convertHandedness = e.convertHandedness === !0, this.warnings = [], this.report = [], this._materialCache = /* @__PURE__ */ new Map(), this._textureCache = /* @__PURE__ */ new Map();
|
|
13947
13947
|
}
|
|
@@ -13977,7 +13977,7 @@ var mp = [
|
|
|
13977
13977
|
continue;
|
|
13978
13978
|
}
|
|
13979
13979
|
for (let e of i) {
|
|
13980
|
-
let i =
|
|
13980
|
+
let i = Xf(r.ctm, e.relativeCTM || e.ctm), a = await this._buildShapeMesh(e, i, `instance_${n++}`);
|
|
13981
13981
|
a && t.add(a);
|
|
13982
13982
|
}
|
|
13983
13983
|
}
|
|
@@ -13989,7 +13989,7 @@ var mp = [
|
|
|
13989
13989
|
i.map && !a && (this.warn(`${n} (${e.type}, "${e.material?.type || "diffuse"}") has a texture map but no UVs — dropping map, using base color`), o = i.clone(), o.map = null);
|
|
13990
13990
|
let s = new Ct(r, o);
|
|
13991
13991
|
s.name = n;
|
|
13992
|
-
let c = this.convertHandedness ?
|
|
13992
|
+
let c = this.convertHandedness ? Xf(hp, t) : t;
|
|
13993
13993
|
new St().fromArray(c).decompose(s.position, s.quaternion, s.scale), s.updateMatrix(), r.computeBoundingBox();
|
|
13994
13994
|
let l = r.boundingBox ? r.boundingBox.clone().applyMatrix4(s.matrix).getSize(new sn()) : new sn();
|
|
13995
13995
|
return this.report.push({
|
|
@@ -14044,7 +14044,7 @@ var mp = [
|
|
|
14044
14044
|
return i.setAttribute("position", new ut(Float32Array.from(t), 3)), i.setIndex(r), i.computeVertexNormals(), i;
|
|
14045
14045
|
}
|
|
14046
14046
|
async _plyMesh(e) {
|
|
14047
|
-
let t =
|
|
14047
|
+
let t = up(e, "filename", null);
|
|
14048
14048
|
if (!t) return this.warn("plymesh missing filename"), null;
|
|
14049
14049
|
try {
|
|
14050
14050
|
let e = await this.resolvePLY(t);
|
|
@@ -14054,10 +14054,10 @@ var mp = [
|
|
|
14054
14054
|
}
|
|
14055
14055
|
}
|
|
14056
14056
|
_sphere(e) {
|
|
14057
|
-
return new Xt(
|
|
14057
|
+
return new Xt(lp(e, "radius", 1), 48, 32);
|
|
14058
14058
|
}
|
|
14059
14059
|
_disk(e) {
|
|
14060
|
-
let t =
|
|
14060
|
+
let t = lp(e, "radius", 1), n = lp(e, "innerradius", 0), r = lp(e, "height", 0), i = [], a = [];
|
|
14061
14061
|
for (let e = 0; e < 48; e++) {
|
|
14062
14062
|
let o = e / 48 * Math.PI * 2, s = (e + 1) / 48 * Math.PI * 2, c = i.length / 3;
|
|
14063
14063
|
i.push(Math.cos(o) * n, Math.sin(o) * n, r), i.push(Math.cos(o) * t, Math.sin(o) * t, r), i.push(Math.cos(s) * t, Math.sin(s) * t, r), i.push(Math.cos(s) * n, Math.sin(s) * n, r), a.push(c, c + 1, c + 2, c, c + 2, c + 3);
|
|
@@ -14072,15 +14072,15 @@ var mp = [
|
|
|
14072
14072
|
resolveNamedTexture: (e) => this._resolveNamedTexture(e),
|
|
14073
14073
|
namedMaterials: this.ir.namedMaterials,
|
|
14074
14074
|
warn: (e) => this.warn(e)
|
|
14075
|
-
}, r = await
|
|
14075
|
+
}, r = await mp(e.material, n);
|
|
14076
14076
|
return e.areaLight && await this._applyAreaLight(r, e.areaLight, n), t.set(e.areaLight, r), r;
|
|
14077
14077
|
}
|
|
14078
14078
|
async _applyAreaLight(e, t, n) {
|
|
14079
|
-
let r = await
|
|
14079
|
+
let r = await dp(t.params, "L", n, [
|
|
14080
14080
|
1,
|
|
14081
14081
|
1,
|
|
14082
14082
|
1
|
|
14083
|
-
]), i =
|
|
14083
|
+
]), i = lp(t.params, "scale", 1), a = r.rgb || [
|
|
14084
14084
|
1,
|
|
14085
14085
|
1,
|
|
14086
14086
|
1
|
|
@@ -14092,7 +14092,7 @@ var mp = [
|
|
|
14092
14092
|
let t = this.ir.namedTextures.get(e), n = null;
|
|
14093
14093
|
if (!t) this.warn(`named texture "${e}" not defined`);
|
|
14094
14094
|
else if (t.class === "imagemap") {
|
|
14095
|
-
let r =
|
|
14095
|
+
let r = up(t.params, "filename", null);
|
|
14096
14096
|
if (r) try {
|
|
14097
14097
|
let t = await this.resolveImage(r);
|
|
14098
14098
|
t ? n = { texture: t } : this.warn(`image not found for texture "${e}": ${r}`);
|
|
@@ -14180,7 +14180,7 @@ var mp = [
|
|
|
14180
14180
|
return c.name = "PBRT Camera", c.up.copy(a.normalize()), c.position.copy(r), c.lookAt(o), c.updateMatrixWorld(!0), c;
|
|
14181
14181
|
}
|
|
14182
14182
|
_verticalFov(e, t) {
|
|
14183
|
-
let n =
|
|
14183
|
+
let n = lp(e, "fov", 90);
|
|
14184
14184
|
if (t >= 1) return n;
|
|
14185
14185
|
let r = n * Math.PI / 180;
|
|
14186
14186
|
return 2 * Math.atan(Math.tan(r / 2) / t) * 180 / Math.PI;
|
|
@@ -14188,7 +14188,7 @@ var mp = [
|
|
|
14188
14188
|
async _buildEnvironment(e) {
|
|
14189
14189
|
let t = e.find((e) => e.type === "infinite");
|
|
14190
14190
|
if (!t) return null;
|
|
14191
|
-
let n =
|
|
14191
|
+
let n = lp(t.params, "scale", 1), r = up(t.params, "filename", null);
|
|
14192
14192
|
if (r) try {
|
|
14193
14193
|
let e = await this.resolveEnvironment(r);
|
|
14194
14194
|
if (e) return e.mapping = ct, { texture: e };
|
|
@@ -14196,7 +14196,7 @@ var mp = [
|
|
|
14196
14196
|
} catch (e) {
|
|
14197
14197
|
this.warn(`failed to load infinite-light image ${r}: ${e.message}`);
|
|
14198
14198
|
}
|
|
14199
|
-
let i = ((await
|
|
14199
|
+
let i = ((await dp(t.params, "L", {
|
|
14200
14200
|
resolveNamedTexture: async () => null,
|
|
14201
14201
|
warn: (e) => this.warn(e)
|
|
14202
14202
|
}, [
|
|
@@ -14215,20 +14215,20 @@ var mp = [
|
|
|
14215
14215
|
_reportUnsupportedLights(e) {
|
|
14216
14216
|
for (let t of e) t.type !== "infinite" && this.warn(`light "${t.type}" not supported (only infinite lights and emissive area lights are mapped)`);
|
|
14217
14217
|
}
|
|
14218
|
-
},
|
|
14219
|
-
function
|
|
14218
|
+
}, _p = new TextDecoder();
|
|
14219
|
+
function vp(e) {
|
|
14220
14220
|
let t = e.replace(/\\/g, "/").split("/"), n = [];
|
|
14221
14221
|
for (let e of t) e === "" || e === "." || (e === ".." ? n.pop() : n.push(e));
|
|
14222
14222
|
return n.join("/");
|
|
14223
14223
|
}
|
|
14224
|
-
function
|
|
14225
|
-
return !e || t.startsWith("/") ?
|
|
14224
|
+
function yp(e, t) {
|
|
14225
|
+
return !e || t.startsWith("/") ? vp(t) : vp(`${e}/${t}`);
|
|
14226
14226
|
}
|
|
14227
|
-
var
|
|
14227
|
+
var bp = class {
|
|
14228
14228
|
constructor(e) {
|
|
14229
14229
|
this.byPath = /* @__PURE__ */ new Map(), this.byBase = /* @__PURE__ */ new Map();
|
|
14230
14230
|
for (let t in e) {
|
|
14231
|
-
let n =
|
|
14231
|
+
let n = vp(t).toLowerCase(), r = {
|
|
14232
14232
|
norm: n,
|
|
14233
14233
|
bytes: e[t]
|
|
14234
14234
|
};
|
|
@@ -14238,13 +14238,13 @@ var yp = class {
|
|
|
14238
14238
|
}
|
|
14239
14239
|
}
|
|
14240
14240
|
find(e) {
|
|
14241
|
-
let t =
|
|
14241
|
+
let t = vp(e).toLowerCase();
|
|
14242
14242
|
if (this.byPath.has(t)) return this.byPath.get(t).bytes;
|
|
14243
14243
|
let n = this.byBase.get(t.split("/").pop());
|
|
14244
14244
|
return n ? (n.find((e) => e.norm.endsWith("/" + t)) || n[0]).bytes : null;
|
|
14245
14245
|
}
|
|
14246
14246
|
};
|
|
14247
|
-
function
|
|
14247
|
+
function xp(e) {
|
|
14248
14248
|
let t = Object.keys(e).filter((e) => e.toLowerCase().endsWith(".pbrt"));
|
|
14249
14249
|
if (t.length === 0) return null;
|
|
14250
14250
|
let n = t.filter((e) => /(^|\/)(scene|main)\.pbrt$/i.test(e)), r = n.length ? n : t;
|
|
@@ -14253,17 +14253,17 @@ function bp(e) {
|
|
|
14253
14253
|
return n === r ? e.length - t.length : n - r;
|
|
14254
14254
|
}), r[0];
|
|
14255
14255
|
}
|
|
14256
|
-
async function
|
|
14257
|
-
let { vfs: t, plyParser: n, imageFromBytes: r, envFromBytes: i, convertHandedness: a } = e, o = new
|
|
14256
|
+
async function Sp(e) {
|
|
14257
|
+
let { vfs: t, plyParser: n, imageFromBytes: r, envFromBytes: i, convertHandedness: a } = e, o = new bp(t), s = e.entryPath || xp(t);
|
|
14258
14258
|
if (!s) throw Error("PBRT loader: no .pbrt file found in archive");
|
|
14259
14259
|
let c = o.find(s);
|
|
14260
14260
|
if (!c) throw Error(`PBRT loader: entry "${s}" not readable`);
|
|
14261
|
-
let l = s.includes("/") ? s.slice(0, s.lastIndexOf("/")) : "", u = new
|
|
14262
|
-
let n = o.find(
|
|
14263
|
-
return n ?
|
|
14264
|
-
} }).parse(
|
|
14261
|
+
let l = s.includes("/") ? s.slice(0, s.lastIndexOf("/")) : "", u = new ap({ resolveInclude: (e, t) => {
|
|
14262
|
+
let n = o.find(yp(t, e)) || o.find(e);
|
|
14263
|
+
return n ? _p.decode(n) : null;
|
|
14264
|
+
} }).parse(_p.decode(c), l), d = (e) => e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength);
|
|
14265
14265
|
return {
|
|
14266
|
-
...await new
|
|
14266
|
+
...await new gp({
|
|
14267
14267
|
convertHandedness: a,
|
|
14268
14268
|
resolvePLY: async (e) => {
|
|
14269
14269
|
let t = o.find(e);
|
|
@@ -14283,7 +14283,7 @@ async function xp(e) {
|
|
|
14283
14283
|
}
|
|
14284
14284
|
//#endregion
|
|
14285
14285
|
//#region src/Processor/AssetLoader.js
|
|
14286
|
-
var
|
|
14286
|
+
var Cp = {
|
|
14287
14287
|
glb: {
|
|
14288
14288
|
type: "model",
|
|
14289
14289
|
name: "GLB (GLTF Binary)"
|
|
@@ -14348,7 +14348,7 @@ var Sp = {
|
|
|
14348
14348
|
type: "archive",
|
|
14349
14349
|
name: "ZIP Archive"
|
|
14350
14350
|
}
|
|
14351
|
-
},
|
|
14351
|
+
}, wp = class e extends lt {
|
|
14352
14352
|
constructor(e, t, n) {
|
|
14353
14353
|
super(), this.scene = e, this.camera = t, this.controls = n, this.targetModel = null, this._externalModel = null, this.floorPlane = null, this.sceneScale = 1, this.loaderCache = {}, this.uploadedFileInfo = null, this.animations = [], this.renderer = null, this._loadingManager = new _t(), this._loadCancelled = !1;
|
|
14354
14354
|
}
|
|
@@ -14394,7 +14394,7 @@ var Sp = {
|
|
|
14394
14394
|
this.renderer = e;
|
|
14395
14395
|
}
|
|
14396
14396
|
getFileFormat(e) {
|
|
14397
|
-
return
|
|
14397
|
+
return Cp[e.split(".").pop().toLowerCase()] || null;
|
|
14398
14398
|
}
|
|
14399
14399
|
readFileAsArrayBuffer(e) {
|
|
14400
14400
|
return new Promise((t, n) => {
|
|
@@ -14529,7 +14529,7 @@ var Sp = {
|
|
|
14529
14529
|
async loadArchiveFromFile(e, t) {
|
|
14530
14530
|
try {
|
|
14531
14531
|
let n = await this.readFileAsArrayBuffer(e), r = vn(new Uint8Array(n));
|
|
14532
|
-
return
|
|
14532
|
+
return xp(r) ? await this.loadPBRTFromZip(r, t) : await this.processObjMtlPairsInZip(r, t) || await this.findAndLoadModelFromZip(r, t);
|
|
14533
14533
|
} catch (e) {
|
|
14534
14534
|
throw console.error("Error loading ZIP archive:", e), e;
|
|
14535
14535
|
}
|
|
@@ -14543,7 +14543,7 @@ var Sp = {
|
|
|
14543
14543
|
let { PLYLoader: e } = await import("three/examples/jsm/loaders/PLYLoader.js");
|
|
14544
14544
|
this.loaderCache.ply = new e();
|
|
14545
14545
|
}
|
|
14546
|
-
let { group: n, environment: r, report: i, warnings: a, entryPath: o } = await
|
|
14546
|
+
let { group: n, environment: r, report: i, warnings: a, entryPath: o } = await Sp({
|
|
14547
14547
|
vfs: e,
|
|
14548
14548
|
plyParser: (e) => this.loaderCache.ply.parse(e),
|
|
14549
14549
|
imageFromBytes: (e, t) => this._pbrtTextureFromBytes(e, t),
|
|
@@ -14642,7 +14642,7 @@ var Sp = {
|
|
|
14642
14642
|
}
|
|
14643
14643
|
for (let t in e) {
|
|
14644
14644
|
let n = t.split(".").pop().toLowerCase();
|
|
14645
|
-
if (
|
|
14645
|
+
if (Cp[n] && Cp[n].type === "model") return console.log(`Loading model file from ZIP: ${t}`), await this.loadModelFromZipEntry(e[t], t, n, e);
|
|
14646
14646
|
}
|
|
14647
14647
|
throw Error("No supported model files found in the ZIP archive");
|
|
14648
14648
|
}
|
|
@@ -15202,10 +15202,10 @@ var Sp = {
|
|
|
15202
15202
|
getSupportedFormats(e = null) {
|
|
15203
15203
|
if (e) {
|
|
15204
15204
|
let t = {};
|
|
15205
|
-
for (let [n, r] of Object.entries(
|
|
15205
|
+
for (let [n, r] of Object.entries(Cp)) r.type === e && (t[n] = r);
|
|
15206
15206
|
return t;
|
|
15207
15207
|
}
|
|
15208
|
-
return
|
|
15208
|
+
return Cp;
|
|
15209
15209
|
}
|
|
15210
15210
|
dispose() {
|
|
15211
15211
|
for (let e in this.loaderCache) {
|
|
@@ -15217,7 +15217,7 @@ var Sp = {
|
|
|
15217
15217
|
removeAllEventListeners() {
|
|
15218
15218
|
this._listeners = void 0;
|
|
15219
15219
|
}
|
|
15220
|
-
},
|
|
15220
|
+
}, Tp = {
|
|
15221
15221
|
maxBounces: {
|
|
15222
15222
|
uniform: "maxBounces",
|
|
15223
15223
|
reset: !0
|
|
@@ -15408,10 +15408,10 @@ var Sp = {
|
|
|
15408
15408
|
},
|
|
15409
15409
|
renderMode: { handler: "handleRenderMode" },
|
|
15410
15410
|
environmentRotation: { handler: "handleEnvironmentRotation" }
|
|
15411
|
-
},
|
|
15411
|
+
}, Ep = {
|
|
15412
15412
|
bounces: "maxBounces",
|
|
15413
15413
|
debugMode: "visMode"
|
|
15414
|
-
},
|
|
15414
|
+
}, Dp = class extends lt {
|
|
15415
15415
|
constructor(e = Y) {
|
|
15416
15416
|
super(), this._values = /* @__PURE__ */ new Map(), this._pathTracer = null, this._resetCallback = null, this._handlers = {}, this._delegates = {}, this._initDefaults(e);
|
|
15417
15417
|
}
|
|
@@ -15469,7 +15469,7 @@ var Sp = {
|
|
|
15469
15469
|
let i = this._values.get(e);
|
|
15470
15470
|
if (i === t) return;
|
|
15471
15471
|
this._values.set(e, t);
|
|
15472
|
-
let a =
|
|
15472
|
+
let a = Tp[e];
|
|
15473
15473
|
a && (this._applyRoute(a, t, i), (n === void 0 ? a.reset ?? !0 : n) && this._resetCallback?.(), r || this.dispatchEvent({
|
|
15474
15474
|
type: ur.SETTING_CHANGED,
|
|
15475
15475
|
key: e,
|
|
@@ -15483,7 +15483,7 @@ var Sp = {
|
|
|
15483
15483
|
let e = this._values.get(n);
|
|
15484
15484
|
if (e === i) continue;
|
|
15485
15485
|
this._values.set(n, i);
|
|
15486
|
-
let a =
|
|
15486
|
+
let a = Tp[n];
|
|
15487
15487
|
a && (this._applyRoute(a, i, e), (a.reset ?? !0) && (r = !0), t || this.dispatchEvent({
|
|
15488
15488
|
type: ur.SETTING_CHANGED,
|
|
15489
15489
|
key: n,
|
|
@@ -15501,7 +15501,7 @@ var Sp = {
|
|
|
15501
15501
|
}
|
|
15502
15502
|
applyAll() {
|
|
15503
15503
|
for (let [e, t] of this._values) {
|
|
15504
|
-
let n =
|
|
15504
|
+
let n = Tp[e];
|
|
15505
15505
|
n && this._applyRoute(n, t, void 0);
|
|
15506
15506
|
}
|
|
15507
15507
|
}
|
|
@@ -15509,10 +15509,10 @@ var Sp = {
|
|
|
15509
15509
|
e.uniform ? (this._pathTracer?.setUniform(e.uniform, t), e.after && this._pathTracer?.[e.after]?.()) : e.handler ? this._handlers[e.handler]?.(t, n) : e.delegate && this._delegates[e.delegate]?.updateParam?.(e.param, t);
|
|
15510
15510
|
}
|
|
15511
15511
|
_initDefaults(e) {
|
|
15512
|
-
for (let t of Object.keys(
|
|
15513
|
-
for (let [t, n] of Object.entries(
|
|
15512
|
+
for (let t of Object.keys(Tp)) t in e && this._values.set(t, e[t]);
|
|
15513
|
+
for (let [t, n] of Object.entries(Ep)) t in e && this._values.set(n, e[t]);
|
|
15514
15514
|
}
|
|
15515
|
-
},
|
|
15515
|
+
}, Op = class extends lt {
|
|
15516
15516
|
constructor(e) {
|
|
15517
15517
|
super();
|
|
15518
15518
|
let t = e.clientWidth, n = e.clientHeight;
|
|
@@ -15678,7 +15678,7 @@ var Sp = {
|
|
|
15678
15678
|
dispose() {
|
|
15679
15679
|
this.controls?.dispose();
|
|
15680
15680
|
}
|
|
15681
|
-
},
|
|
15681
|
+
}, kp = class extends lt {
|
|
15682
15682
|
constructor(e, t, n, r = {}) {
|
|
15683
15683
|
super(), this.scene = e, this.sceneHelpers = t, this.pathTracer = n, this._onReset = r.onReset || null;
|
|
15684
15684
|
}
|
|
@@ -15838,14 +15838,14 @@ var Sp = {
|
|
|
15838
15838
|
], n.distance = e.distance ?? 0, n.penumbra = e.penumbra ?? 0, n.decay = e.decay ?? 2) : e.type === "PointLight" && (n.distance = e.distance ?? 0, n.decay = e.decay ?? 2);
|
|
15839
15839
|
return (e.type === "SpotLight" || e.type === "DirectionalLight") && e.userData?.gobo && (n.gobo = e.userData.gobo.name, n.goboIntensity = e.userData.gobo.intensity, n.goboInverted = !!e.userData.gobo.inverted, e.type === "DirectionalLight" && (n.goboScale = e.userData.gobo.scale ?? 5)), e.type === "SpotLight" && e.userData?.ies && (n.ies = e.userData.ies.name, n.iesIntensity = e.userData.ies.intensity ?? 1, n.fixtureLumens = e.userData.ies.fixtureLumens ?? null), n;
|
|
15840
15840
|
}
|
|
15841
|
-
},
|
|
15841
|
+
}, Ap = class {
|
|
15842
15842
|
constructor(e, t = {}) {
|
|
15843
15843
|
this.pathTracer = e, this._onReset = t.onReset || null, this.texture = null, this.entries = [], this._size = 256;
|
|
15844
15844
|
}
|
|
15845
15845
|
async loadLibrary(e, { size: t = 256 } = {}) {
|
|
15846
15846
|
if (!Array.isArray(e) || e.length === 0) return [];
|
|
15847
15847
|
this._size = t;
|
|
15848
|
-
let n = await Promise.all(e.map((e) =>
|
|
15848
|
+
let n = await Promise.all(e.map((e) => jp(e.url))), r = t, i = t, a = n.length, o = new Uint8Array(r * i * a * 4), s = document.createElement("canvas");
|
|
15849
15849
|
s.width = r, s.height = i;
|
|
15850
15850
|
let c = s.getContext("2d", { willReadFrequently: !0 });
|
|
15851
15851
|
for (let e = 0; e < a; e++) {
|
|
@@ -15874,7 +15874,7 @@ var Sp = {
|
|
|
15874
15874
|
o.userData.gobo = {
|
|
15875
15875
|
name: e.name,
|
|
15876
15876
|
index: e.index,
|
|
15877
|
-
intensity:
|
|
15877
|
+
intensity: Mp(r),
|
|
15878
15878
|
inverted: !!i,
|
|
15879
15879
|
scale: Math.max(1e-4, a)
|
|
15880
15880
|
};
|
|
@@ -15916,28 +15916,28 @@ var Sp = {
|
|
|
15916
15916
|
return t && t.isSpotLight ? t : null;
|
|
15917
15917
|
}
|
|
15918
15918
|
};
|
|
15919
|
-
function
|
|
15919
|
+
function jp(e) {
|
|
15920
15920
|
return new Promise((t, n) => {
|
|
15921
15921
|
let r = new Image();
|
|
15922
15922
|
r.crossOrigin = "anonymous", r.onload = () => t(r), r.onerror = () => n(/* @__PURE__ */ Error(`Failed to load gobo image: ${e}`)), r.src = e;
|
|
15923
15923
|
});
|
|
15924
15924
|
}
|
|
15925
|
-
function
|
|
15925
|
+
function Mp(e) {
|
|
15926
15926
|
return Math.max(0, Math.min(1, e));
|
|
15927
15927
|
}
|
|
15928
15928
|
//#endregion
|
|
15929
15929
|
//#region src/Processor/IESParser.js
|
|
15930
|
-
function
|
|
15930
|
+
function Np(e, t = "ies") {
|
|
15931
15931
|
let n = e.search(/TILT\s*=/i);
|
|
15932
15932
|
if (n < 0) throw Error(`IES (${t}): missing TILT line`);
|
|
15933
15933
|
let r = e.indexOf("\n", n);
|
|
15934
15934
|
if (r < 0) throw Error(`IES (${t}): truncated TILT line`);
|
|
15935
15935
|
let i = e.slice(n, r).match(/TILT\s*=\s*(\w+)/i), a = i ? i[1].toUpperCase() : "NONE", o = e.slice(r);
|
|
15936
15936
|
if (a === "INCLUDE") {
|
|
15937
|
-
let e =
|
|
15938
|
-
o =
|
|
15937
|
+
let e = Lp(o), t = 2 + 2 * Number(e[1]);
|
|
15938
|
+
o = Rp(o, t);
|
|
15939
15939
|
}
|
|
15940
|
-
let s =
|
|
15940
|
+
let s = Lp(o), c = 0, l = () => Number(s[c++]), u = l(), d = l(), f = l(), p = l(), m = l(), h = l();
|
|
15941
15941
|
l(), l(), l(), l();
|
|
15942
15942
|
let g = l();
|
|
15943
15943
|
if (l(), l(), !Number.isFinite(p) || p <= 0) throw Error(`IES (${t}): invalid vertical angle count ${p}`);
|
|
@@ -15963,18 +15963,18 @@ function Mp(e, t = "ies") {
|
|
|
15963
15963
|
name: t
|
|
15964
15964
|
};
|
|
15965
15965
|
}
|
|
15966
|
-
function
|
|
15966
|
+
function Pp(e, t, n) {
|
|
15967
15967
|
let r = new Uint8Array(t * n), { verticalAngles: i, horizontalAngles: a, candela: o, maxCandela: s } = e;
|
|
15968
15968
|
if (s <= 0) return r;
|
|
15969
15969
|
let c = i[i.length - 1], l = a[a.length - 1], u = a[0], d = a.length === 1 || l === u;
|
|
15970
15970
|
for (let e = 0; e < n; e++) {
|
|
15971
|
-
let f = (e + .5) / n * c, p =
|
|
15971
|
+
let f = (e + .5) / n * c, p = zp(i, f), m = Math.min(p + 1, i.length - 1), h = i[m] - i[p], g = h > 0 ? (f - i[p]) / h : 0;
|
|
15972
15972
|
for (let n = 0; n < t; n++) {
|
|
15973
15973
|
let i;
|
|
15974
|
-
if (d) i =
|
|
15974
|
+
if (d) i = Bp(o[p][0], o[m][0], g);
|
|
15975
15975
|
else {
|
|
15976
|
-
let e = u + (n + .5) / t * (l - u), r =
|
|
15977
|
-
i =
|
|
15976
|
+
let e = u + (n + .5) / t * (l - u), r = zp(a, e), s = Math.min(r + 1, a.length - 1), c = a[s] - a[r], d = c > 0 ? (e - a[r]) / c : 0, f = o[p][r], h = o[p][s], _ = o[m][r], v = o[m][s];
|
|
15977
|
+
i = Bp(Bp(f, h, d), Bp(_, v, d), g);
|
|
15978
15978
|
}
|
|
15979
15979
|
let c = Math.min(1, Math.max(0, i / s));
|
|
15980
15980
|
r[e * t + n] = Math.round(c * 255);
|
|
@@ -15982,7 +15982,7 @@ function Np(e, t, n) {
|
|
|
15982
15982
|
}
|
|
15983
15983
|
return r;
|
|
15984
15984
|
}
|
|
15985
|
-
function
|
|
15985
|
+
function Fp(e, t = .1) {
|
|
15986
15986
|
let { verticalAngles: n, horizontalAngles: r, candela: i, maxCandela: a } = e, o = Math.PI / 4;
|
|
15987
15987
|
if (a <= 0 || !n?.length) return o;
|
|
15988
15988
|
let s = a * t, c = r.length, l = n[n.length - 1], u = !1;
|
|
@@ -15997,7 +15997,7 @@ function Pp(e, t = .1) {
|
|
|
15997
15997
|
let d = l * Math.PI / 180;
|
|
15998
15998
|
return Math.min(Math.max(d, 5 * Math.PI / 180), 89 * Math.PI / 180);
|
|
15999
15999
|
}
|
|
16000
|
-
function
|
|
16000
|
+
function Ip(e, t, n = .7) {
|
|
16001
16001
|
let { verticalAngles: r, horizontalAngles: i, candela: a, maxCandela: o } = e;
|
|
16002
16002
|
if (o <= 0 || !r?.length || t <= 0) return 0;
|
|
16003
16003
|
let s = o * n, c = i.length, l = 0;
|
|
@@ -16010,15 +16010,15 @@ function Fp(e, t, n = .7) {
|
|
|
16010
16010
|
let u = t * 180 / Math.PI, d = u > 0 ? 1 - l / u : 0;
|
|
16011
16011
|
return Math.min(Math.max(d, 0), 1);
|
|
16012
16012
|
}
|
|
16013
|
-
function
|
|
16013
|
+
function Lp(e) {
|
|
16014
16014
|
return e.split(/\s+/).filter((e) => e.length > 0);
|
|
16015
16015
|
}
|
|
16016
|
-
function
|
|
16016
|
+
function Rp(e, t) {
|
|
16017
16017
|
let n = /\S+/g, r = 0;
|
|
16018
16018
|
for (; n.exec(e) !== null;) if (r++, r === t) return e.slice(n.lastIndex);
|
|
16019
16019
|
return "";
|
|
16020
16020
|
}
|
|
16021
|
-
function
|
|
16021
|
+
function zp(e, t) {
|
|
16022
16022
|
if (t <= e[0]) return 0;
|
|
16023
16023
|
if (t >= e[e.length - 1]) return e.length - 1;
|
|
16024
16024
|
let n = 0, r = e.length - 1;
|
|
@@ -16028,12 +16028,12 @@ function Rp(e, t) {
|
|
|
16028
16028
|
}
|
|
16029
16029
|
return n;
|
|
16030
16030
|
}
|
|
16031
|
-
function
|
|
16031
|
+
function Bp(e, t, n) {
|
|
16032
16032
|
return e + (t - e) * n;
|
|
16033
16033
|
}
|
|
16034
16034
|
//#endregion
|
|
16035
16035
|
//#region src/managers/IESManager.js
|
|
16036
|
-
var
|
|
16036
|
+
var Vp = class {
|
|
16037
16037
|
constructor(e, t = {}) {
|
|
16038
16038
|
this.pathTracer = e, this._onReset = t.onReset || null, this.texture = null, this.entries = [], this._gridWidth = 128, this._gridHeight = 128;
|
|
16039
16039
|
}
|
|
@@ -16044,11 +16044,11 @@ var Bp = class {
|
|
|
16044
16044
|
try {
|
|
16045
16045
|
let r = await fetch(e.url);
|
|
16046
16046
|
if (!r.ok) throw Error(`HTTP ${r.status}`);
|
|
16047
|
-
let i =
|
|
16047
|
+
let i = Np(await r.text(), e.name);
|
|
16048
16048
|
return {
|
|
16049
16049
|
it: e,
|
|
16050
16050
|
profile: i,
|
|
16051
|
-
grid:
|
|
16051
|
+
grid: Pp(i, t, n)
|
|
16052
16052
|
};
|
|
16053
16053
|
} catch (t) {
|
|
16054
16054
|
return console.warn(`IESManager: failed to load "${e.name}": ${t.message}`), null;
|
|
@@ -16062,14 +16062,14 @@ var Bp = class {
|
|
|
16062
16062
|
let r = t[e];
|
|
16063
16063
|
o[n + e * 4 + 0] = r, o[n + e * 4 + 1] = r, o[n + e * 4 + 2] = r, o[n + e * 4 + 3] = 255;
|
|
16064
16064
|
}
|
|
16065
|
-
let i = r[e].profile, c =
|
|
16065
|
+
let i = r[e].profile, c = Fp(i);
|
|
16066
16066
|
s.push({
|
|
16067
16067
|
name: r[e].it.name,
|
|
16068
16068
|
index: e,
|
|
16069
16069
|
maxCandela: i.maxCandela,
|
|
16070
16070
|
photometricType: i.photometricType,
|
|
16071
16071
|
suggestedAngle: c,
|
|
16072
|
-
suggestedPenumbra:
|
|
16072
|
+
suggestedPenumbra: Ip(i, c),
|
|
16073
16073
|
lumens: i.lumens
|
|
16074
16074
|
});
|
|
16075
16075
|
}
|
|
@@ -16102,7 +16102,7 @@ var Bp = class {
|
|
|
16102
16102
|
l = Number.isFinite(e.lumens) ? e.lumens : null, i.userData.ies = {
|
|
16103
16103
|
name: e.name,
|
|
16104
16104
|
index: e.index,
|
|
16105
|
-
intensity:
|
|
16105
|
+
intensity: Hp(n),
|
|
16106
16106
|
fixtureLumens: l
|
|
16107
16107
|
}, r && (Number.isFinite(e.suggestedAngle) && (i.angle = e.suggestedAngle, o = e.suggestedAngle), Number.isFinite(e.suggestedPenumbra) && (i.penumbra = e.suggestedPenumbra, s = e.suggestedPenumbra), i.decay = 2, c = 2);
|
|
16108
16108
|
}
|
|
@@ -16125,44 +16125,44 @@ var Bp = class {
|
|
|
16125
16125
|
return t && t.isSpotLight ? t : null;
|
|
16126
16126
|
}
|
|
16127
16127
|
};
|
|
16128
|
-
function
|
|
16128
|
+
function Hp(e) {
|
|
16129
16129
|
return Math.max(0, Math.min(1, e));
|
|
16130
16130
|
}
|
|
16131
16131
|
//#endregion
|
|
16132
16132
|
//#region src/Processor/ToneMapCPU.js
|
|
16133
|
-
var
|
|
16134
|
-
function Up(e, t, n, r, i) {
|
|
16135
|
-
i[0] = Hp(e), i[1] = Hp(t), i[2] = Hp(n);
|
|
16136
|
-
}
|
|
16133
|
+
var Up = (e) => Math.min(Math.max(e, 0), 1);
|
|
16137
16134
|
function Wp(e, t, n, r, i) {
|
|
16138
|
-
i[0] =
|
|
16135
|
+
i[0] = Up(e), i[1] = Up(t), i[2] = Up(n);
|
|
16139
16136
|
}
|
|
16140
16137
|
function Gp(e, t, n, r, i) {
|
|
16141
|
-
|
|
16138
|
+
i[0] = Up(e * r), i[1] = Up(t * r), i[2] = Up(n * r);
|
|
16142
16139
|
}
|
|
16143
16140
|
function Kp(e, t, n, r, i) {
|
|
16141
|
+
e *= r, t *= r, n *= r, i[0] = Up(e / (e + 1)), i[1] = Up(t / (t + 1)), i[2] = Up(n / (n + 1));
|
|
16142
|
+
}
|
|
16143
|
+
function qp(e, t, n, r, i) {
|
|
16144
16144
|
e = Math.max(e * r - .004, 0), t = Math.max(t * r - .004, 0), n = Math.max(n * r - .004, 0);
|
|
16145
16145
|
let a = (e) => (e * (6.2 * e + .5) / (e * (6.2 * e + 1.7) + .06)) ** 2.2;
|
|
16146
16146
|
i[0] = a(e), i[1] = a(t), i[2] = a(n);
|
|
16147
16147
|
}
|
|
16148
|
-
function
|
|
16148
|
+
function Jp(e, t, n, r, i) {
|
|
16149
16149
|
e = e * r / .6, t = t * r / .6, n = n * r / .6;
|
|
16150
16150
|
let a = .59719 * e + .35458 * t + .04823 * n, o = .076 * e + .90834 * t + .01566 * n, s = .0284 * e + .13383 * t + .83777 * n, c = (e) => (e * (e + .0245786) - 90537e-9) / (e * (.983729 * e + .432951) + .238081);
|
|
16151
|
-
a = c(a), o = c(o), s = c(s), i[0] =
|
|
16151
|
+
a = c(a), o = c(o), s = c(s), i[0] = Up(1.60475 * a - .53108 * o - .07367 * s), i[1] = Up(-.10208 * a + 1.10813 * o - .00605 * s), i[2] = Up(-.00327 * a - .07276 * o + 1.07602 * s);
|
|
16152
16152
|
}
|
|
16153
|
-
function
|
|
16153
|
+
function Yp(e, t, n, r, i) {
|
|
16154
16154
|
e *= r, t *= r, n *= r;
|
|
16155
16155
|
let a = .6274 * e + .3293 * t + .0433 * n, o = .0691 * e + .9195 * t + .0113 * n, s = .0164 * e + .088 * t + .8956 * n, c = .856627153315983 * a + .0951212405381588 * o + .0482516061458583 * s, l = .137318972929847 * a + .761241990602591 * o + .101439036467562 * s, u = .11189821299995 * a + .0767994186031903 * o + .811302368396859 * s, d = -12.47393, f = 4.026069 - d;
|
|
16156
|
-
c =
|
|
16156
|
+
c = Up((Math.log2(Math.max(c, 1e-10)) - d) / f), l = Up((Math.log2(Math.max(l, 1e-10)) - d) / f), u = Up((Math.log2(Math.max(u, 1e-10)) - d) / f);
|
|
16157
16157
|
let p = (e) => {
|
|
16158
16158
|
let t = e * e, n = t * t;
|
|
16159
16159
|
return 15.5 * n * t - 40.14 * n * e + 31.96 * n - 6.868 * t * e + .4298 * t + .1191 * e - .00232;
|
|
16160
16160
|
};
|
|
16161
16161
|
c = p(c), l = p(l), u = p(u);
|
|
16162
16162
|
let m = 1.1271005818144368 * c - .11060664309660323 * l - .016493938717834573 * u, h = -.1413297634984383 * c + 1.157823702216272 * l - .016493938717834257 * u, g = -.14132976349843826 * c - .11060664309660294 * l + 1.2519364065950405 * u;
|
|
16163
|
-
m = Math.max(0, m) ** 2.2, h = Math.max(0, h) ** 2.2, g = Math.max(0, g) ** 2.2, i[0] =
|
|
16163
|
+
m = Math.max(0, m) ** 2.2, h = Math.max(0, h) ** 2.2, g = Math.max(0, g) ** 2.2, i[0] = Up(1.6605 * m - .5876 * h - .0728 * g), i[1] = Up(-.1246 * m + 1.1329 * h - .0083 * g), i[2] = Up(-.0182 * m - .1006 * h + 1.1187 * g);
|
|
16164
16164
|
}
|
|
16165
|
-
function
|
|
16165
|
+
function Xp(e, t, n, r, i) {
|
|
16166
16166
|
let a = .76;
|
|
16167
16167
|
e *= r, t *= r, n *= r;
|
|
16168
16168
|
let o = Math.min(e, Math.min(t, n)), s = o < .08 ? o - 6.25 * o * o : .04;
|
|
@@ -16177,43 +16177,43 @@ function Yp(e, t, n, r, i) {
|
|
|
16177
16177
|
let f = 1 - 1 / (.15 * (c - u) + 1);
|
|
16178
16178
|
i[0] = e + (u - e) * f, i[1] = t + (u - t) * f, i[2] = n + (u - n) * f;
|
|
16179
16179
|
}
|
|
16180
|
-
var
|
|
16181
|
-
[At,
|
|
16182
|
-
[J,
|
|
16183
|
-
[Gt,
|
|
16184
|
-
[Ze,
|
|
16185
|
-
[He,
|
|
16186
|
-
[We,
|
|
16187
|
-
[Ot,
|
|
16188
|
-
]),
|
|
16189
|
-
function
|
|
16180
|
+
var Zp = new Map([
|
|
16181
|
+
[At, Wp],
|
|
16182
|
+
[J, Gp],
|
|
16183
|
+
[Gt, Kp],
|
|
16184
|
+
[Ze, qp],
|
|
16185
|
+
[He, Jp],
|
|
16186
|
+
[We, Yp],
|
|
16187
|
+
[Ot, Xp]
|
|
16188
|
+
]), Qp = 1 / 2.2;
|
|
16189
|
+
function $p(e) {
|
|
16190
16190
|
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
16191
16191
|
}
|
|
16192
|
-
var
|
|
16193
|
-
function
|
|
16192
|
+
var em = .2126, tm = .7152, nm = .0722;
|
|
16193
|
+
function rm(e, t) {
|
|
16194
16194
|
if (t === 1) return;
|
|
16195
|
-
let n = e[0] *
|
|
16195
|
+
let n = e[0] * em + e[1] * tm + e[2] * nm;
|
|
16196
16196
|
e[0] = n + (e[0] - n) * t, e[1] = n + (e[1] - n) * t, e[2] = n + (e[2] - n) * t;
|
|
16197
16197
|
}
|
|
16198
16198
|
//#endregion
|
|
16199
16199
|
//#region src/Passes/OIDNDenoiser.js
|
|
16200
|
-
var
|
|
16201
|
-
async function
|
|
16202
|
-
if (!
|
|
16200
|
+
var im = ai("oidn"), am = null, om = null;
|
|
16201
|
+
async function sm() {
|
|
16202
|
+
if (!am) {
|
|
16203
16203
|
let [e, t] = await Promise.all([import("oidn-web"), import("@tensorflow/tfjs-core")]);
|
|
16204
|
-
|
|
16204
|
+
am = e.initUNetFromURL, om = t.engine;
|
|
16205
16205
|
}
|
|
16206
|
-
return
|
|
16206
|
+
return am;
|
|
16207
16207
|
}
|
|
16208
|
-
function
|
|
16209
|
-
if (
|
|
16210
|
-
let e =
|
|
16208
|
+
function cm() {
|
|
16209
|
+
if (om) try {
|
|
16210
|
+
let e = om();
|
|
16211
16211
|
e?.registryFactory && "webgpu-oidn" in e.registryFactory && e.removeBackend("webgpu-oidn");
|
|
16212
16212
|
} catch (e) {
|
|
16213
|
-
|
|
16213
|
+
im.warn("failed to clear cached TFJS backend", e);
|
|
16214
16214
|
}
|
|
16215
16215
|
}
|
|
16216
|
-
var
|
|
16216
|
+
var lm = new Float32Array(3), um = {
|
|
16217
16217
|
QUALITY_MODELS: {
|
|
16218
16218
|
fast: "rt_hdr_alb_nrm_small",
|
|
16219
16219
|
balance: "rt_hdr_alb_nrm",
|
|
@@ -16225,7 +16225,7 @@ var cm = new Float32Array(3), lm = {
|
|
|
16225
16225
|
debugGbufferMaps: !0,
|
|
16226
16226
|
tileSize: 256
|
|
16227
16227
|
}
|
|
16228
|
-
},
|
|
16228
|
+
}, dm = class extends lt {
|
|
16229
16229
|
constructor(e, t, n, r, i = {}) {
|
|
16230
16230
|
if (super(), !e || !t || !n || !r) throw Error("OIDNDenoiser requires output canvas, renderer, scene, and camera");
|
|
16231
16231
|
this.renderer = t, this.scene = n, this.camera = r, this.input = t.domElement, this.output = e, this.extractGBufferData = i.extractGBufferData || null, this.getMRTRenderTarget = i.getMRTRenderTarget || null, this.backendParamsGetter = i.backendParams || null, this.getGPUTextures = i.getGPUTextures || null, this.getExposure = i.getExposure || (() => 1), this.getToneMapping = i.getToneMapping || (() => He), this.getSaturation = i.getSaturation || (() => 1), this.getTransparentBackground = i.getTransparentBackground || (() => !1), this.isGPUMode = !!this.backendParamsGetter, this.gpuDevice = null, this._gpuInputBuffers = {
|
|
@@ -16236,14 +16236,14 @@ var cm = new Float32Array(3), lm = {
|
|
|
16236
16236
|
width: 0,
|
|
16237
16237
|
height: 0
|
|
16238
16238
|
}, this._gpuInputPadBuffer = null, this._gpuInputPaddedRowBytes = 0, this._alphaReadbackBuffer = null, this._alphaReadbackMapped = !1, this._cachedAlpha = null, this._cachedAlphaWidth = 0, this.config = {
|
|
16239
|
-
...
|
|
16239
|
+
...um.DEFAULT_OPTIONS,
|
|
16240
16240
|
...i
|
|
16241
16241
|
}, this.enabled = this.config.enableOIDN, this.quality = this.config.oidnQuality, this.debugGbufferMaps = this.config.debugGbufferMaps, this.tileSize = this.config.tileSize, this.state = {
|
|
16242
16242
|
isDenoising: !1,
|
|
16243
16243
|
isLoading: !1,
|
|
16244
16244
|
abortController: null
|
|
16245
16245
|
}, this._pendingStagingBuffers = /* @__PURE__ */ new Set(), this._pendingTileBlits = [], this.currentTZAUrl = null, this.unet = null, this._pendingStart = !1, this._initialize().catch((e) => {
|
|
16246
|
-
|
|
16246
|
+
im.error("init failed:", e), this.dispatchEvent({
|
|
16247
16247
|
type: "error",
|
|
16248
16248
|
error: e
|
|
16249
16249
|
});
|
|
@@ -16289,13 +16289,13 @@ var cm = new Float32Array(3), lm = {
|
|
|
16289
16289
|
let e = this.backendParamsGetter();
|
|
16290
16290
|
this.gpuDevice = e?.device ?? null, t = e?.device ? e : void 0;
|
|
16291
16291
|
}
|
|
16292
|
-
this.unet = await (await
|
|
16292
|
+
this.unet = await (await sm())(e, t, {
|
|
16293
16293
|
aux: !0,
|
|
16294
16294
|
hdr: !0,
|
|
16295
16295
|
maxTileSize: this.tileSize
|
|
16296
|
-
}), this.currentTZAUrl = e, this.dispatchEvent({ type: "loaded" }),
|
|
16296
|
+
}), this.currentTZAUrl = e, this.dispatchEvent({ type: "loaded" }), im.debug("UNet weights loaded:", e);
|
|
16297
16297
|
} catch (e) {
|
|
16298
|
-
|
|
16298
|
+
im.error("UNet weights failed to load:", e), this.dispatchEvent({
|
|
16299
16299
|
type: "error",
|
|
16300
16300
|
error: /* @__PURE__ */ Error(`Denoiser loading failed: ${e.message}`)
|
|
16301
16301
|
});
|
|
@@ -16304,14 +16304,14 @@ var cm = new Float32Array(3), lm = {
|
|
|
16304
16304
|
}
|
|
16305
16305
|
}
|
|
16306
16306
|
_generateTzaUrl() {
|
|
16307
|
-
let { oidnWeightsBaseUrl: e } = cl(), { QUALITY_MODELS: t } =
|
|
16307
|
+
let { oidnWeightsBaseUrl: e } = cl(), { QUALITY_MODELS: t } = um;
|
|
16308
16308
|
return `${e}${t[this.quality] || t.balance}.tza`;
|
|
16309
16309
|
}
|
|
16310
16310
|
async updateConfiguration(e) {
|
|
16311
16311
|
Object.keys(e).some((t) => this.config[t] !== e[t]) && (Object.assign(this.config, e), this.quality = this.config.oidnQuality, this.debugGbufferMaps = this.config.debugGbufferMaps, this.tileSize = this.config.tileSize, await this._setupUNetDenoiser());
|
|
16312
16312
|
}
|
|
16313
16313
|
async updateQuality(e) {
|
|
16314
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
16314
|
+
if (!Object.prototype.hasOwnProperty.call(um.QUALITY_MODELS, e)) throw Error(`Invalid quality setting: ${e}. Must be one of: ${Object.keys(um.QUALITY_MODELS).join(", ")}`);
|
|
16315
16315
|
await this.updateConfiguration({ oidnQuality: e });
|
|
16316
16316
|
}
|
|
16317
16317
|
async start() {
|
|
@@ -16322,7 +16322,7 @@ var cm = new Float32Array(3), lm = {
|
|
|
16322
16322
|
if (t) {
|
|
16323
16323
|
this.renderer?.resetState?.(), this.input.style.opacity = "0";
|
|
16324
16324
|
let t = performance.now() - e;
|
|
16325
|
-
|
|
16325
|
+
im.debug(`denoise complete in ${Q.ms(t)} · quality ${this.quality}`);
|
|
16326
16326
|
}
|
|
16327
16327
|
return t;
|
|
16328
16328
|
}
|
|
@@ -16332,7 +16332,7 @@ var cm = new Float32Array(3), lm = {
|
|
|
16332
16332
|
try {
|
|
16333
16333
|
return await this._executeUNet(), !0;
|
|
16334
16334
|
} catch (e) {
|
|
16335
|
-
return e.name === "AbortError" ?
|
|
16335
|
+
return e.name === "AbortError" ? im.debug("denoise aborted") : im.error("denoise error:", e), this.input.style.opacity = "1", !1;
|
|
16336
16336
|
} finally {
|
|
16337
16337
|
this.state.isDenoising = !1, this.state.abortController = null, this.dispatchEvent({ type: "end" });
|
|
16338
16338
|
}
|
|
@@ -16342,11 +16342,11 @@ var cm = new Float32Array(3), lm = {
|
|
|
16342
16342
|
}
|
|
16343
16343
|
async _executeUNetGPU() {
|
|
16344
16344
|
let { width: e, height: t } = this.output;
|
|
16345
|
-
if (!this.getGPUTextures) return
|
|
16345
|
+
if (!this.getGPUTextures) return im.warn("GPU mode enabled but getGPUTextures not provided"), !1;
|
|
16346
16346
|
let n = this.getGPUTextures();
|
|
16347
|
-
if (!n?.color) return
|
|
16347
|
+
if (!n?.color) return im.warn("GPU textures not ready yet"), !1;
|
|
16348
16348
|
let r = this.gpuDevice;
|
|
16349
|
-
if (!r) return
|
|
16349
|
+
if (!r) return im.warn("gpuDevice not available"), !1;
|
|
16350
16350
|
this._ensureGPUInputBuffers(e, t);
|
|
16351
16351
|
let i = r.createCommandEncoder({ label: "oidn-tex-to-buf" }), a = e * 16, o = this._gpuInputPaddedRowBytes, s = o > a, c = this._gpuInputPadBuffer, l = (n, r) => {
|
|
16352
16352
|
if (!s) i.copyTextureToBuffer({
|
|
@@ -16496,10 +16496,10 @@ var cm = new Float32Array(3), lm = {
|
|
|
16496
16496
|
}
|
|
16497
16497
|
r.queue.submit([d.finish()]);
|
|
16498
16498
|
let f = u.mapAsync(GPUMapMode.READ).then(() => {
|
|
16499
|
-
let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this.getExposure(), c = this.getSaturation(), l =
|
|
16499
|
+
let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this.getExposure(), c = this.getSaturation(), l = Zp.get(this.getToneMapping()) || Zp.get(He), d = this._cachedAlpha, f = this._cachedAlphaWidth;
|
|
16500
16500
|
for (let i = 0, a = e.length; i < a; i += 4) {
|
|
16501
16501
|
let a = e[i] * r, s = e[i + 1] * r, u = e[i + 2] * r;
|
|
16502
|
-
if (c !== 1 && (
|
|
16502
|
+
if (c !== 1 && (lm[0] = a, lm[1] = s, lm[2] = u, rm(lm, c), a = lm[0], s = lm[1], u = lm[2]), l(a, s, u, 1, lm), t.data[i] = $p(lm[0]) * 255 + .5 | 0, t.data[i + 1] = $p(lm[1]) * 255 + .5 | 0, t.data[i + 2] = $p(lm[2]) * 255 + .5 | 0, d) {
|
|
16503
16503
|
let e = (i >> 2) % o, r = (i >> 2) / o | 0;
|
|
16504
16504
|
t.data[i + 3] = d[(n.y + r) * f + n.x + e];
|
|
16505
16505
|
} else t.data[i + 3] = 255;
|
|
@@ -16526,7 +16526,7 @@ var cm = new Float32Array(3), lm = {
|
|
|
16526
16526
|
async _displayGPUOutput({ data: e, width: t, height: n }) {
|
|
16527
16527
|
let r = this.gpuDevice;
|
|
16528
16528
|
if (!r) {
|
|
16529
|
-
|
|
16529
|
+
im.error("gpuDevice not available for output readback");
|
|
16530
16530
|
return;
|
|
16531
16531
|
}
|
|
16532
16532
|
let i = t * n * 4 * 4, a = r.createBuffer({
|
|
@@ -16537,10 +16537,10 @@ var cm = new Float32Array(3), lm = {
|
|
|
16537
16537
|
try {
|
|
16538
16538
|
let o = r.createCommandEncoder({ label: "oidn-readback" });
|
|
16539
16539
|
o.copyBufferToBuffer(e, 0, a, 0, i), r.queue.submit([o.finish()]), await a.mapAsync(GPUMapMode.READ);
|
|
16540
|
-
let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this.getExposure(), u = this.getSaturation(), d =
|
|
16540
|
+
let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this.getExposure(), u = this.getSaturation(), d = Zp.get(this.getToneMapping()) || Zp.get(He), f = this._cachedAlpha;
|
|
16541
16541
|
for (let e = 0, t = s.length; e < t; e += 4) {
|
|
16542
16542
|
let t = s[e] * l, n = s[e + 1] * l, r = s[e + 2] * l;
|
|
16543
|
-
u !== 1 && (
|
|
16543
|
+
u !== 1 && (lm[0] = t, lm[1] = n, lm[2] = r, rm(lm, u), t = lm[0], n = lm[1], r = lm[2]), d(t, n, r, 1, lm), c.data[e] = $p(lm[0]) * 255 + .5 | 0, c.data[e + 1] = $p(lm[1]) * 255 + .5 | 0, c.data[e + 2] = $p(lm[2]) * 255 + .5 | 0, c.data[e + 3] = f ? f[e >> 2] : 255;
|
|
16544
16544
|
}
|
|
16545
16545
|
a.unmap(), this.ctx.putImageData(c, 0, 0);
|
|
16546
16546
|
} finally {
|
|
@@ -16548,12 +16548,12 @@ var cm = new Float32Array(3), lm = {
|
|
|
16548
16548
|
}
|
|
16549
16549
|
}
|
|
16550
16550
|
abort() {
|
|
16551
|
-
this._pendingStart = !1, !(!this.enabled || !this.state.isDenoising) && (this.state.abortController?.abort(), this._destroyPendingStagingBuffers(), this.input.style.opacity = "1", this.state.isDenoising = !1, this.dispatchEvent({ type: "end" }),
|
|
16551
|
+
this._pendingStart = !1, !(!this.enabled || !this.state.isDenoising) && (this.state.abortController?.abort(), this._destroyPendingStagingBuffers(), this.input.style.opacity = "1", this.state.isDenoising = !1, this.dispatchEvent({ type: "end" }), im.debug("denoise aborted"));
|
|
16552
16552
|
}
|
|
16553
16553
|
setSize(e, t) {
|
|
16554
16554
|
if (e <= 0 || t <= 0) throw Error(`Invalid dimensions: ${e}x${t}`);
|
|
16555
16555
|
this.output.width = e, this.output.height = t, this._setupUNetDenoiser().catch((e) => {
|
|
16556
|
-
|
|
16556
|
+
im.error("reinitialize after size change failed:", e);
|
|
16557
16557
|
});
|
|
16558
16558
|
}
|
|
16559
16559
|
_destroyPendingStagingBuffers() {
|
|
@@ -16561,13 +16561,13 @@ var cm = new Float32Array(3), lm = {
|
|
|
16561
16561
|
this._pendingStagingBuffers.clear();
|
|
16562
16562
|
}
|
|
16563
16563
|
dispose() {
|
|
16564
|
-
this.abort(), this._destroyPendingStagingBuffers(), this.unet?.dispose(),
|
|
16564
|
+
this.abort(), this._destroyPendingStagingBuffers(), this.unet?.dispose(), cm(), this._destroyGPUInputBuffers(), this.output?.parentNode && this.output.remove(), this.unet = null, this.ctx = null, this.state.abortController = null, this.removeAllListeners?.(), im.debug("disposed");
|
|
16565
16565
|
}
|
|
16566
|
-
},
|
|
16567
|
-
function
|
|
16566
|
+
}, fm = "let e={ortRuntimeUrl:`https://cdn.jsdelivr.net/npm/onnxruntime-web@1.24.3/dist/ort.webgpu.bundle.min.mjs`,ortWasmPaths:`https://cdn.jsdelivr.net/npm/onnxruntime-web@1.24.3/dist/`,cacheNamespace:`rayzee`},t=null;async function n(){return t||(t=await import(e.ortRuntimeUrl),t.env.wasm.wasmPaths=e.ortWasmPaths,t.env.logLevel=`error`,t)}function r(){return`${e.cacheNamespace}:ai-upscaler-models`}const i=`models`;let a=null,o=null;function s(){return new Promise((e,t)=>{let n=indexedDB.open(r(),1);n.onupgradeneeded=()=>n.result.createObjectStore(i),n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function c(e){try{let t=await s();return await new Promise((n,r)=>{let a=t.transaction(i,`readonly`).objectStore(i).get(e);a.onsuccess=()=>n(a.result||null),a.onerror=()=>r(a.error)})}catch{return null}}async function l(e,t){try{let n=await s();await new Promise((r,a)=>{let o=n.transaction(i,`readwrite`);o.objectStore(i).put(t,e),o.oncomplete=()=>r(),o.onerror=()=>a(o.error)})}catch{}}async function u(e){let t=await c(e);if(t)return console.log(`AI Upscaler Worker: model loaded from cache (${(t.byteLength/1024/1024).toFixed(1)}MB)`),t;let n=await fetch(e);if(!n.ok)throw Error(`Failed to fetch model: ${n.status}`);let r=await n.arrayBuffer();return l(e,r.slice(0)),r}async function d(e,t){if(a&&o===e){self.postMessage({type:`loaded`,backend:`webgpu`});return}a&&=(await a.release(),null);let[r,i]=await Promise.all([u(e),n()]);a=await i.InferenceSession.create(r,t),o=e;let s=512;try{let e=await navigator.gpu?.requestAdapter(),t=await e?.requestAdapterInfo?.()||e?.info,n=/apple|swiftshader|llvmpipe/i.test(t?.vendor||``)||/apple|swiftshader/i.test(t?.architecture||``),r=t?.device?.toLowerCase?.()?.includes(`integrated`)||/intel.*iris|intel.*uhd|intel.*hd|amd.*vega|radeon.*graphics/i.test(t?.description||``);s=n?128:r?256:512,console.log(`AI Upscaler Worker: GPU=\"${t?.description||t?.device||`unknown`}\", tileSize=${s}`)}catch{}let c=(r.byteLength/1024/1024).toFixed(1);console.log(`AI Upscaler Worker: model loaded (${c}MB), backend: webgpu`),self.postMessage({type:`loaded`,backend:`webgpu`,tileSize:s})}async function f(e,t,r,i){let o=await n(),s=a.inputNames[0],c=a.outputNames[0],l=new o.Tensor(`float32`,e,[1,3,r,t]),u=(await a.run({[s]:l}))[c].data;self.postMessage({type:`inferred`,outputData:u,id:i},[u.buffer])}self.onmessage=async t=>{let{type:n}=t.data;try{n===`load`?(t.data.ortRuntimeUrl&&(e.ortRuntimeUrl=t.data.ortRuntimeUrl),t.data.ortWasmPaths&&(e.ortWasmPaths=t.data.ortWasmPaths),t.data.cacheNamespace&&(e.cacheNamespace=t.data.cacheNamespace),await d(t.data.url,t.data.sessionOptions)):n===`infer`?await f(t.data.tileData,t.data.width,t.data.height,t.data.id):n===`dispose`&&a&&(await a.release(),a=null,o=null)}catch(e){self.postMessage({type:`error`,message:e.message,id:t.data?.id})}};", pm = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", fm], { type: "text/javascript;charset=utf-8" });
|
|
16567
|
+
function mm(e) {
|
|
16568
16568
|
let t;
|
|
16569
16569
|
try {
|
|
16570
|
-
if (t =
|
|
16570
|
+
if (t = pm && (self.URL || self.webkitURL).createObjectURL(pm), !t) throw "";
|
|
16571
16571
|
let n = new Worker(t, {
|
|
16572
16572
|
type: "module",
|
|
16573
16573
|
name: e?.name
|
|
@@ -16576,7 +16576,7 @@ function pm(e) {
|
|
|
16576
16576
|
(self.URL || self.webkitURL).revokeObjectURL(t);
|
|
16577
16577
|
}), n;
|
|
16578
16578
|
} catch {
|
|
16579
|
-
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
16579
|
+
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(fm), {
|
|
16580
16580
|
type: "module",
|
|
16581
16581
|
name: e?.name
|
|
16582
16582
|
});
|
|
@@ -16584,7 +16584,7 @@ function pm(e) {
|
|
|
16584
16584
|
}
|
|
16585
16585
|
//#endregion
|
|
16586
16586
|
//#region src/Passes/AIUpscaler.js
|
|
16587
|
-
var
|
|
16587
|
+
var hm = {
|
|
16588
16588
|
fast: {
|
|
16589
16589
|
2: "2x-spanx2-ch48.onnx",
|
|
16590
16590
|
4: "4xNomos8k_span_otf_strong_fp32_opset17.onnx"
|
|
@@ -16598,17 +16598,17 @@ var mm = {
|
|
|
16598
16598
|
4: "4xNomos2_hq_mosr_fp32.onnx"
|
|
16599
16599
|
}
|
|
16600
16600
|
};
|
|
16601
|
-
function
|
|
16601
|
+
function gm() {
|
|
16602
16602
|
let { upscalerModelBaseUrl: e } = cl(), t = {};
|
|
16603
|
-
for (let n in
|
|
16603
|
+
for (let n in hm) {
|
|
16604
16604
|
t[n] = {};
|
|
16605
|
-
for (let r in
|
|
16605
|
+
for (let r in hm[n]) t[n][r] = e + hm[n][r];
|
|
16606
16606
|
}
|
|
16607
16607
|
return t;
|
|
16608
16608
|
}
|
|
16609
|
-
var
|
|
16609
|
+
var _m = {
|
|
16610
16610
|
get QUALITY_PRESETS() {
|
|
16611
|
-
return
|
|
16611
|
+
return gm();
|
|
16612
16612
|
},
|
|
16613
16613
|
TILE_SIZE: 512,
|
|
16614
16614
|
TILE_OVERLAP: 16,
|
|
@@ -16619,17 +16619,17 @@ var gm = {
|
|
|
16619
16619
|
}],
|
|
16620
16620
|
graphOptimizationLevel: "all"
|
|
16621
16621
|
}
|
|
16622
|
-
},
|
|
16622
|
+
}, vm = class extends lt {
|
|
16623
16623
|
constructor(e, t, n = {}) {
|
|
16624
16624
|
if (super(), !e || !t) throw Error("AIUpscaler requires output canvas and renderer");
|
|
16625
|
-
this.renderer = t, this.input = t.domElement, this.output = e, this.getSourceCanvas = n.getSourceCanvas || null, this.getGPUTextures = n.getGPUTextures || null, this.getExposure = n.getExposure || (() => 1), this.getToneMapping = n.getToneMapping || (() => He), this.getSaturation = n.getSaturation || (() => 1), this.enabled = !1, this.hdr = !1, this.scaleFactor = n.scaleFactor || 2, this.quality = n.quality || "fast", this.tileSize = n.tileSize ||
|
|
16625
|
+
this.renderer = t, this.input = t.domElement, this.output = e, this.getSourceCanvas = n.getSourceCanvas || null, this.getGPUTextures = n.getGPUTextures || null, this.getExposure = n.getExposure || (() => 1), this.getToneMapping = n.getToneMapping || (() => He), this.getSaturation = n.getSaturation || (() => 1), this.enabled = !1, this.hdr = !1, this.scaleFactor = n.scaleFactor || 2, this.quality = n.quality || "fast", this.tileSize = n.tileSize || _m.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
|
|
16626
16626
|
isUpscaling: !1,
|
|
16627
16627
|
isLoading: !1,
|
|
16628
16628
|
abortController: null
|
|
16629
16629
|
}, this._worker = null, this._currentModelUrl = null, this._tileId = 0, this._pendingWorkerHandlers = /* @__PURE__ */ new Set(), this._upscaledAlpha = null, this._upscaledAlphaWidth = 0, this._backupCanvas = null, this._baseWidth = e.width, this._baseHeight = e.height, this._hdrStagingBuffer = null, this._hdrStagingWidth = 0, this._hdrStagingHeight = 0;
|
|
16630
16630
|
}
|
|
16631
16631
|
async _ensureSession() {
|
|
16632
|
-
let e =
|
|
16632
|
+
let e = _m.QUALITY_PRESETS[this.quality];
|
|
16633
16633
|
if (!e) throw Error(`Unknown quality preset: ${this.quality}`);
|
|
16634
16634
|
let t = e[this.scaleFactor];
|
|
16635
16635
|
if (!t) throw Error(`No model for ${this.quality}/${this.scaleFactor}x`);
|
|
@@ -16639,14 +16639,14 @@ var gm = {
|
|
|
16639
16639
|
message: `Loading ${this.scaleFactor}x upscale model...`
|
|
16640
16640
|
});
|
|
16641
16641
|
try {
|
|
16642
|
-
this._worker ||= new
|
|
16642
|
+
this._worker ||= new mm(), await new Promise((e, n) => {
|
|
16643
16643
|
let r = (t) => {
|
|
16644
16644
|
t.data.type === "loaded" ? (this._worker.removeEventListener("message", r), t.data.tileSize && !this._tileSizeOverride && (this.tileSize = t.data.tileSize), console.log(`AI Upscaler: ${this.scaleFactor}x model loaded, backend: ${t.data.backend}, tileSize: ${this.tileSize}`), e()) : t.data.type === "error" && (this._worker.removeEventListener("message", r), n(Error(t.data.message)));
|
|
16645
16645
|
}, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o } = cl();
|
|
16646
16646
|
this._worker.addEventListener("message", r), this._worker.postMessage({
|
|
16647
16647
|
type: "load",
|
|
16648
16648
|
url: t,
|
|
16649
|
-
sessionOptions:
|
|
16649
|
+
sessionOptions: _m.SESSION_OPTIONS,
|
|
16650
16650
|
ortRuntimeUrl: i,
|
|
16651
16651
|
ortWasmPaths: a,
|
|
16652
16652
|
cacheNamespace: o
|
|
@@ -16716,8 +16716,8 @@ var gm = {
|
|
|
16716
16716
|
willReadFrequently: !0,
|
|
16717
16717
|
alpha: !0
|
|
16718
16718
|
});
|
|
16719
|
-
this._cacheUpscaledAlpha(t, n * i, r * i), t.isHDR && (this._hdrToneMapFn =
|
|
16720
|
-
let o =
|
|
16719
|
+
this._cacheUpscaledAlpha(t, n * i, r * i), t.isHDR && (this._hdrToneMapFn = Zp.get(this.getToneMapping()) || Zp.get(He), this._hdrExposure = this.getExposure(), this._hdrSaturation = this.getSaturation(), this._tmOut = new Float32Array(3));
|
|
16720
|
+
let o = _m.TILE_OVERLAP, s = this.tileSize, c = s - o * 2, l = Math.ceil(n / c), u = Math.ceil(r / c), d = l * u, f = 0;
|
|
16721
16721
|
for (let o = 0; o < u; o++) for (let u = 0; u < l; u++) {
|
|
16722
16722
|
if (e.aborted) throw new DOMException("Aborted", "AbortError");
|
|
16723
16723
|
let l = Math.min(u * c, Math.max(0, n - s)), p = Math.min(o * c, Math.max(0, r - s)), m = Math.min(s, n - l), h = Math.min(s, r - p), g = this._extractTile(t, l, p, m, h), _ = await this._inferTile(g, m, h), v = l * i, y = p * i, b = m * i, x = h * i, S = this._tensorToImageData(_, b, x, v, y);
|
|
@@ -16790,7 +16790,7 @@ var gm = {
|
|
|
16790
16790
|
let u = ((n + e) * o + (t + i)) * 4, d = e * r + i;
|
|
16791
16791
|
if (s) {
|
|
16792
16792
|
let e = this._hdrToneMapFn, t = this._hdrExposure, n = this._hdrSaturation, r = a[u] * t, i = a[u + 1] * t, o = a[u + 2] * t;
|
|
16793
|
-
n !== 1 && (this._tmOut[0] = r, this._tmOut[1] = i, this._tmOut[2] = o,
|
|
16793
|
+
n !== 1 && (this._tmOut[0] = r, this._tmOut[1] = i, this._tmOut[2] = o, rm(this._tmOut, n), r = this._tmOut[0], i = this._tmOut[1], o = this._tmOut[2]), e(r, i, o, 1, this._tmOut), l[d] = this._tmOut[0] ** +Qp, l[c + d] = this._tmOut[1] ** +Qp, l[2 * c + d] = this._tmOut[2] ** +Qp;
|
|
16794
16794
|
} else l[d] = a[u] / 255, l[c + d] = a[u + 1] / 255, l[2 * c + d] = a[u + 2] / 255;
|
|
16795
16795
|
}
|
|
16796
16796
|
return l;
|
|
@@ -16848,10 +16848,10 @@ var gm = {
|
|
|
16848
16848
|
this._backupCanvas = document.createElement("canvas"), this._backupCanvas.width = e.width, this._backupCanvas.height = e.height;
|
|
16849
16849
|
let t = this._backupCanvas.getContext("2d");
|
|
16850
16850
|
if (e.isHDR) {
|
|
16851
|
-
let { data: n, width: r, height: i } = e, a = t.createImageData(r, i), o = a.data, s =
|
|
16851
|
+
let { data: n, width: r, height: i } = e, a = t.createImageData(r, i), o = a.data, s = Zp.get(this.getToneMapping()) || Zp.get(He), c = this.getExposure(), l = this.getSaturation(), u = new Float32Array(3);
|
|
16852
16852
|
for (let e = 0, t = r * i; e < t; e++) {
|
|
16853
16853
|
let t = e * 4, r = n[t] * c, i = n[t + 1] * c, a = n[t + 2] * c;
|
|
16854
|
-
l !== 1 && (u[0] = r, u[1] = i, u[2] = a,
|
|
16854
|
+
l !== 1 && (u[0] = r, u[1] = i, u[2] = a, rm(u, l), r = u[0], i = u[1], a = u[2]), s(r, i, a, 1, u), o[t] = u[0] ** +Qp * 255 + .5 | 0, o[t + 1] = u[1] ** +Qp * 255 + .5 | 0, o[t + 2] = u[2] ** +Qp * 255 + .5 | 0, o[t + 3] = 255;
|
|
16855
16855
|
}
|
|
16856
16856
|
t.putImageData(a, 0, 0);
|
|
16857
16857
|
} else t.putImageData(e, 0, 0);
|
|
@@ -16863,7 +16863,7 @@ var gm = {
|
|
|
16863
16863
|
this.hdr = !!e;
|
|
16864
16864
|
}
|
|
16865
16865
|
setQuality(e) {
|
|
16866
|
-
if (!
|
|
16866
|
+
if (!_m.QUALITY_PRESETS[e]) {
|
|
16867
16867
|
console.warn(`AIUpscaler: Invalid quality "${e}", must be fast/balanced/quality`);
|
|
16868
16868
|
return;
|
|
16869
16869
|
}
|
|
@@ -16886,7 +16886,7 @@ var gm = {
|
|
|
16886
16886
|
async dispose() {
|
|
16887
16887
|
this.abort(), this._cleanupPendingWorkerHandlers(), this._worker &&= (this._worker.postMessage({ type: "dispose" }), this._worker.terminate(), null), this._currentModelUrl = null, this._backupCanvas = null, this._upscaledAlpha = null, this.state.abortController = null, this._hdrStagingBuffer?.destroy(), this._hdrStagingBuffer = null, this._hdrStagingWidth = 0, this._hdrStagingHeight = 0, console.log("AIUpscaler disposed");
|
|
16888
16888
|
}
|
|
16889
|
-
},
|
|
16889
|
+
}, ym = class extends lt {
|
|
16890
16890
|
constructor({ renderer: e, mainCanvas: t, scene: n, camera: r, stages: i, pipeline: a, getExposure: o, getSaturation: s, getTransparentBg: c }) {
|
|
16891
16891
|
super(), this.renderer = e, this.mainCanvas = t, this.denoiserCanvas = this._createDenoiserCanvas(t), this.scene = n, this.camera = r, this.pipeline = a, this._stages = i, this._getExposure = o, this._getSaturation = s, this._getTransparentBg = c, this.denoiser = null, this.upscaler = null, this._lastRenderWidth = 0, this._lastRenderHeight = 0, this._pendingStartUpscaler = null, this._denoiserStartHandler = null, this._denoiserEndHandler = null, this._upscalerResChangedHandler = null, this._upscalerStartHandler = null, this._upscalerProgressHandler = null, this._upscalerEndHandler = null;
|
|
16892
16892
|
}
|
|
@@ -16907,7 +16907,7 @@ var gm = {
|
|
|
16907
16907
|
setupDenoiser() {
|
|
16908
16908
|
if (!this.denoiserCanvas) return;
|
|
16909
16909
|
let e = this._stages.pathTracer;
|
|
16910
|
-
this.denoiser = new
|
|
16910
|
+
this.denoiser = new dm(this.denoiserCanvas, this.renderer, this.scene, this.camera, {
|
|
16911
16911
|
...Y,
|
|
16912
16912
|
backendParams: () => ({
|
|
16913
16913
|
device: this.renderer.backend.device,
|
|
@@ -16932,7 +16932,7 @@ var gm = {
|
|
|
16932
16932
|
setupUpscaler() {
|
|
16933
16933
|
if (!this.denoiserCanvas) return;
|
|
16934
16934
|
let e = this._stages.pathTracer;
|
|
16935
|
-
this.upscaler = new
|
|
16935
|
+
this.upscaler = new vm(this.denoiserCanvas, this.renderer, {
|
|
16936
16936
|
scaleFactor: Y.upscalerScale || 2,
|
|
16937
16937
|
quality: Y.upscalerQuality || "fast",
|
|
16938
16938
|
getSourceCanvas: () => this.denoiser?.enabled ? null : this.renderer.domElement,
|
|
@@ -17080,7 +17080,7 @@ var gm = {
|
|
|
17080
17080
|
let t = kr[e];
|
|
17081
17081
|
t && (this._stages.asvgf?.updateParameters(t), this._stages.bilateralFilter?.updateParameters(t), this._stages.variance && t.varianceBoost !== void 0 && (this._stages.variance.varianceBoost.value = t.varianceBoost));
|
|
17082
17082
|
}
|
|
17083
|
-
},
|
|
17083
|
+
}, bm = class {
|
|
17084
17084
|
constructor() {
|
|
17085
17085
|
this.layer = "hud", this.visible = !1, this._tileBounds = null, this._imageWidth = 1, this._imageHeight = 1, this.enabled = !0, this._borderColor = "rgba(255, 0, 0, 0.6)", this._borderWidthRatio = 1 / 540, this._borderWidthMin = 1.5, this._borderWidthMax = 4;
|
|
17086
17086
|
}
|
|
@@ -17104,7 +17104,7 @@ var gm = {
|
|
|
17104
17104
|
dispose() {
|
|
17105
17105
|
this.visible = !1;
|
|
17106
17106
|
}
|
|
17107
|
-
},
|
|
17107
|
+
}, xm = class {
|
|
17108
17108
|
constructor(n, r) {
|
|
17109
17109
|
this.layer = "scene", this._enabled = !0, this._outlineNode = bn(n, r, {
|
|
17110
17110
|
selectedObjects: [],
|
|
@@ -17135,11 +17135,11 @@ var gm = {
|
|
|
17135
17135
|
this._enabled = !1, this._outlineNode?.dispose(), this._material?.dispose(), this._quad = null;
|
|
17136
17136
|
}
|
|
17137
17137
|
};
|
|
17138
|
-
function
|
|
17138
|
+
function Sm(e = !1) {
|
|
17139
17139
|
let t = document.createElement("canvas");
|
|
17140
17140
|
return t.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;" + (e ? "display:none;" : ""), t;
|
|
17141
17141
|
}
|
|
17142
|
-
function
|
|
17142
|
+
function Cm(e, t = Infinity) {
|
|
17143
17143
|
let n = e?.getBoundingClientRect();
|
|
17144
17144
|
if (!n || n.width === 0 || n.height === 0) return null;
|
|
17145
17145
|
let r = Math.min(window.devicePixelRatio || 1, 2), i = Math.round(n.width * r), a = Math.round(n.height * r), o = t / Math.max(i, a);
|
|
@@ -17150,9 +17150,9 @@ function Sm(e, t = Infinity) {
|
|
|
17150
17150
|
}
|
|
17151
17151
|
//#endregion
|
|
17152
17152
|
//#region src/managers/helpers/ViewOverlayRenderer.js
|
|
17153
|
-
var
|
|
17153
|
+
var wm = 4096, Tm = class {
|
|
17154
17154
|
constructor() {
|
|
17155
|
-
this.canvas =
|
|
17155
|
+
this.canvas = Sm(!0), this._visible = !1, this.renderer = null, this._sizeSource = null;
|
|
17156
17156
|
}
|
|
17157
17157
|
async init({ device: e, sizeSource: t }) {
|
|
17158
17158
|
this._sizeSource = t;
|
|
@@ -17169,7 +17169,7 @@ var Cm = 4096, wm = class {
|
|
|
17169
17169
|
}
|
|
17170
17170
|
syncSize() {
|
|
17171
17171
|
if (!this.renderer) return;
|
|
17172
|
-
let e =
|
|
17172
|
+
let e = Cm(this._sizeSource, wm);
|
|
17173
17173
|
!e || e.width === this.canvas.width && e.height === this.canvas.height || this.renderer.setSize(e.width, e.height, !1);
|
|
17174
17174
|
}
|
|
17175
17175
|
begin() {
|
|
@@ -17181,18 +17181,18 @@ var Cm = 4096, wm = class {
|
|
|
17181
17181
|
dispose() {
|
|
17182
17182
|
br(this.renderer), this.renderer = null, this.canvas.parentElement?.removeChild(this.canvas);
|
|
17183
17183
|
}
|
|
17184
|
-
},
|
|
17184
|
+
}, Em = ai("overlay"), Dm = (e, t) => e.visible && e.layer === t && e.render, Om = class {
|
|
17185
17185
|
constructor(e) {
|
|
17186
|
-
this.camera = e, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas =
|
|
17186
|
+
this.camera = e, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas = Sm(), this._hudCtx = this._hudCanvas.getContext("2d"), this._helperScene = null, this._viewOverlay = null;
|
|
17187
17187
|
}
|
|
17188
17188
|
async initViewRenderer({ device: e, sizeSource: t }) {
|
|
17189
17189
|
if (!(!e || !t)) try {
|
|
17190
|
-
this._viewOverlay = await new
|
|
17190
|
+
this._viewOverlay = await new Tm().init({
|
|
17191
17191
|
device: e,
|
|
17192
17192
|
sizeSource: t
|
|
17193
17193
|
});
|
|
17194
17194
|
} catch (e) {
|
|
17195
|
-
|
|
17195
|
+
Em.error("overlay surface unavailable — light gizmos, transform gizmo and outlines are disabled", e), this._viewOverlay = null;
|
|
17196
17196
|
}
|
|
17197
17197
|
}
|
|
17198
17198
|
setHelperScene(e) {
|
|
@@ -17208,11 +17208,11 @@ var Cm = 4096, wm = class {
|
|
|
17208
17208
|
}
|
|
17209
17209
|
setupDefaultHelpers({ helperScene: e, meshScene: t, pipeline: n, denoisingManager: r, app: i, renderWidth: a, renderHeight: o }) {
|
|
17210
17210
|
this.setHelperScene(e);
|
|
17211
|
-
let s = new
|
|
17211
|
+
let s = new bm();
|
|
17212
17212
|
this.register("tiles", s), s.setRenderSize(a || 1, o || 1), i.addEventListener("resolution_changed", (e) => {
|
|
17213
17213
|
s.setRenderSize(e.width, e.height);
|
|
17214
17214
|
}), n.eventBus.on("pipeline:reset", () => s.hide()), this._wireDenoiserTileEvents(s, r);
|
|
17215
|
-
let c = new
|
|
17215
|
+
let c = new xm(t, this.camera);
|
|
17216
17216
|
this.register("outline", c);
|
|
17217
17217
|
}
|
|
17218
17218
|
_wireDenoiserTileEvents(e, t) {
|
|
@@ -17224,7 +17224,7 @@ var Cm = 4096, wm = class {
|
|
|
17224
17224
|
}));
|
|
17225
17225
|
}
|
|
17226
17226
|
register(e, t) {
|
|
17227
|
-
this._helpers.has(e) && (
|
|
17227
|
+
this._helpers.has(e) && (Em.warn(`helper "${e}" already registered — replacing.`), this._helpers.get(e).dispose?.()), this._helpers.set(e, t);
|
|
17228
17228
|
}
|
|
17229
17229
|
unregister(e) {
|
|
17230
17230
|
let t = this._helpers.get(e);
|
|
@@ -17262,16 +17262,16 @@ var Cm = 4096, wm = class {
|
|
|
17262
17262
|
}
|
|
17263
17263
|
_renderSceneLayer(e) {
|
|
17264
17264
|
this._helperScene?.render(e, this.camera);
|
|
17265
|
-
for (let t of this._helpers.values())
|
|
17265
|
+
for (let t of this._helpers.values()) Dm(t, "scene") && t.render(e, this.camera);
|
|
17266
17266
|
}
|
|
17267
17267
|
_hasVisibleSceneOverlay() {
|
|
17268
17268
|
if (this._helperScene?.isDrawing) return !0;
|
|
17269
|
-
for (let e of this._helpers.values()) if (
|
|
17269
|
+
for (let e of this._helpers.values()) if (Dm(e, "scene")) return !0;
|
|
17270
17270
|
return !1;
|
|
17271
17271
|
}
|
|
17272
17272
|
refreshHUD() {
|
|
17273
17273
|
let e = this._hudCanvas, t = this._hudCtx, n = !1;
|
|
17274
|
-
for (let e of this._helpers.values()) if (
|
|
17274
|
+
for (let e of this._helpers.values()) if (Dm(e, "hud")) {
|
|
17275
17275
|
n = !0;
|
|
17276
17276
|
break;
|
|
17277
17277
|
}
|
|
@@ -17280,10 +17280,10 @@ var Cm = 4096, wm = class {
|
|
|
17280
17280
|
return;
|
|
17281
17281
|
}
|
|
17282
17282
|
e.style.display !== "" && (e.style.display = "");
|
|
17283
|
-
let r = e.clientWidth, i = e.clientHeight, a = r > 0 && i > 0 ?
|
|
17283
|
+
let r = e.clientWidth, i = e.clientHeight, a = r > 0 && i > 0 ? Cm(e) : null;
|
|
17284
17284
|
if (a) {
|
|
17285
17285
|
(e.width !== a.width || e.height !== a.height) && (e.width = a.width, e.height = a.height), t.clearRect(0, 0, a.width, a.height), t.save(), t.scale(a.width / r, a.height / i);
|
|
17286
|
-
for (let e of this._helpers.values())
|
|
17286
|
+
for (let e of this._helpers.values()) Dm(e, "hud") && e.render(t, r, i);
|
|
17287
17287
|
t.restore(), e.style.display !== "" && (e.style.display = "");
|
|
17288
17288
|
}
|
|
17289
17289
|
}
|
|
@@ -17291,7 +17291,7 @@ var Cm = 4096, wm = class {
|
|
|
17291
17291
|
for (let e of this._helpers.values()) e.dispose?.();
|
|
17292
17292
|
this._helpers.clear(), this._viewOverlay?.dispose(), this._viewOverlay = null, this._hudCanvas.parentElement && this._hudCanvas.parentElement.removeChild(this._hudCanvas);
|
|
17293
17293
|
}
|
|
17294
|
-
},
|
|
17294
|
+
}, km = class extends lt {
|
|
17295
17295
|
constructor() {
|
|
17296
17296
|
super(), this.mixer = null, this.timer = new tn(), this.actions = [], this.isPlaying = !1, this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._tempVec = new sn(), this._skinnedCache = null, this._clipsCache = null, this._savedTimeScale = 1, this.onFinished = null, this.wakeCallback = null;
|
|
17297
17297
|
}
|
|
@@ -17391,7 +17391,7 @@ var Cm = 4096, wm = class {
|
|
|
17391
17391
|
dispose() {
|
|
17392
17392
|
this.mixer &&= (this.mixer.stopAllAction(), this.mixer.uncacheRoot(this._mixerRoot), null), this.actions = [], this.isPlaying = !1, this.timer.reset(), this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._skinnedCache = null, this._clipsCache = null;
|
|
17393
17393
|
}
|
|
17394
|
-
},
|
|
17394
|
+
}, Am = new sn(0, 0, -1), jm = class {
|
|
17395
17395
|
constructor({ camera: e, canvas: t, orbitControls: n, app: r }) {
|
|
17396
17396
|
this._app = r, this._orbitControls = n, this._camera = e, this._controls = new xn(e, t), this._gizmoScene = new Jt(), this._gizmoScene.add(this._controls.getHelper()), this._attached = null, this._isDragging = !1, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._tempVec = new sn(), this._normalMatrix = new xt(), this._refitInFlight = !1, this._baselineComputed = !1, this._tempForward = new sn(), this._lightTargetDistance = null, this._lastLightPosition = null, this._onDraggingChanged = this._onDraggingChanged.bind(this), this._onObjectChange = this._onObjectChange.bind(this), this._controls.addEventListener("dragging-changed", this._onDraggingChanged), this._controls.addEventListener("objectChange", this._onObjectChange);
|
|
17397
17397
|
}
|
|
@@ -17412,7 +17412,7 @@ var Cm = 4096, wm = class {
|
|
|
17412
17412
|
attach(e) {
|
|
17413
17413
|
if (this._attached !== e && (this._controls.attach(e), this._attached = e, this._lightTargetDistance = null, this._lastLightPosition = null, e.isLight && e.target)) {
|
|
17414
17414
|
let t = e.target.position.clone().sub(e.position), n = t.length();
|
|
17415
|
-
n > 1e-4 ? (e.quaternion.setFromUnitVectors(
|
|
17415
|
+
n > 1e-4 ? (e.quaternion.setFromUnitVectors(Am, t.normalize()), this._lightTargetDistance = n) : this._lightTargetDistance = 1, this._lastLightPosition = e.position.clone();
|
|
17416
17416
|
}
|
|
17417
17417
|
}
|
|
17418
17418
|
detach() {
|
|
@@ -17524,7 +17524,7 @@ var Cm = 4096, wm = class {
|
|
|
17524
17524
|
dispose() {
|
|
17525
17525
|
this._controls.removeEventListener("dragging-changed", this._onDraggingChanged), this._controls.removeEventListener("objectChange", this._onObjectChange), this.detach(), this._gizmoScene.remove(this._controls.getHelper()), this._controls.dispose(), this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._baselineComputed = !1, this._tempForward = null, this._lightTargetDistance = null, this._lastLightPosition = null, this._app = null, this._orbitControls = null, this._camera = null, this._controls = null, this._gizmoScene = null;
|
|
17526
17526
|
}
|
|
17527
|
-
},
|
|
17527
|
+
}, Mm = class {
|
|
17528
17528
|
constructor(e) {
|
|
17529
17529
|
this.layer = "scene", this._transformManager = e, this._enabled = !0;
|
|
17530
17530
|
}
|
|
@@ -17543,15 +17543,15 @@ var Cm = 4096, wm = class {
|
|
|
17543
17543
|
dispose() {
|
|
17544
17544
|
this._enabled = !1;
|
|
17545
17545
|
}
|
|
17546
|
-
},
|
|
17546
|
+
}, Nm = /* @__PURE__ */ new WeakMap(), Pm = ai("engine"), Fm = class extends lt {
|
|
17547
17547
|
constructor(e, t = {}) {
|
|
17548
17548
|
super();
|
|
17549
17549
|
try {
|
|
17550
|
-
|
|
17550
|
+
Nm.get(e)?.dispose();
|
|
17551
17551
|
} catch (e) {
|
|
17552
|
-
|
|
17552
|
+
Pm.warn("prior canvas owner dispose failed", e);
|
|
17553
17553
|
}
|
|
17554
|
-
|
|
17554
|
+
Nm.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._container = t.container || null, this.settings = new Dp(Y), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this._maxTextureSize = Y.maxTextureSize, this.pipeline = null, this._pendingReservedRenderSize = null, this.stages = {}, this.cameraManager = null, this.lightManager = null, this.goboManager = null, this.iesManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new km(), this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this._pathTracerEnabled = !0, this._rasterPrecompile = null, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this._emissiveSamplingUserSet = !1, this.completion = new Hf(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1, this._deviceLost = !1, this._deterministic = !1, this._dispatchPinned = !1, this._deterministicRestore = null;
|
|
17555
17555
|
}
|
|
17556
17556
|
_addTrackedListener(e, t, n) {
|
|
17557
17557
|
e && (e.addEventListener(t, n), this._trackedListeners.push({
|
|
@@ -17564,12 +17564,12 @@ var Cm = 4096, wm = class {
|
|
|
17564
17564
|
for (let { target: e, type: t, handler: n } of this._trackedListeners) try {
|
|
17565
17565
|
e.removeEventListener(t, n);
|
|
17566
17566
|
} catch (e) {
|
|
17567
|
-
|
|
17567
|
+
Pm.warn("failed to remove listener", t, e);
|
|
17568
17568
|
}
|
|
17569
17569
|
this._trackedListeners.length = 0;
|
|
17570
17570
|
}
|
|
17571
17571
|
async init() {
|
|
17572
|
-
return await this._initRenderer(), this._applyPendingReservedRenderSize(), this._initCameraManager(), this._initScenes(), this._initAssetPipeline(), this._initPipeline(), await this._initManagers(), this._wireEvents(), this.stages.pathTracer.setTriangleData(new Float32Array(32), 0), this.stages.pathTracer.setBVHData(new Float32Array(16)), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setupMaterial(), this.isInitialized = !0,
|
|
17572
|
+
return await this._initRenderer(), this._applyPendingReservedRenderSize(), this._initCameraManager(), this._initScenes(), this._initAssetPipeline(), this._initPipeline(), await this._initManagers(), this._wireEvents(), this.stages.pathTracer.setTriangleData(new Float32Array(32), 0), this.stages.pathTracer.setBVHData(new Float32Array(16)), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setupMaterial(), this.isInitialized = !0, Pm.debug("WebGPU path tracer app initialized"), this;
|
|
17573
17573
|
}
|
|
17574
17574
|
animate() {
|
|
17575
17575
|
if (!this._deviceLost) {
|
|
@@ -17579,7 +17579,7 @@ var Cm = 4096, wm = class {
|
|
|
17579
17579
|
}
|
|
17580
17580
|
if (this.cameraManager.controls && this.cameraManager.controls.update(), this.animationManager?.isPlaying && !this._animRefitInFlight) {
|
|
17581
17581
|
let e = this.animationManager.update();
|
|
17582
|
-
e && (this._animRefitInFlight = !0, this.refitBVH(e).catch((e) =>
|
|
17582
|
+
e && (this._animRefitInFlight = !0, this.refitBVH(e).catch((e) => Pm.error("animation refit error:", e)).finally(() => {
|
|
17583
17583
|
this._animRefitInFlight = !1;
|
|
17584
17584
|
}));
|
|
17585
17585
|
}
|
|
@@ -17613,7 +17613,7 @@ var Cm = 4096, wm = class {
|
|
|
17613
17613
|
this.animationManagerId &&= (cancelAnimationFrame(this.animationManagerId), null);
|
|
17614
17614
|
}
|
|
17615
17615
|
_handleDeviceLost(e) {
|
|
17616
|
-
this._deviceLost || (this._deviceLost = !0,
|
|
17616
|
+
this._deviceLost || (this._deviceLost = !0, Pm.error(`WebGPU device lost (${e?.reason || "unknown"}): ${e?.message || ""}`), this.stopAnimation(), this.dispatchEvent({
|
|
17617
17617
|
type: ur.DEVICE_LOST,
|
|
17618
17618
|
reason: e?.reason,
|
|
17619
17619
|
message: e?.message
|
|
@@ -17651,7 +17651,7 @@ var Cm = 4096, wm = class {
|
|
|
17651
17651
|
let e = Ae().value, t = k().value;
|
|
17652
17652
|
e?._listeners?.dispose && (e._listeners.dispose.length = 0), t?._listeners?.dispose && (t._listeners.dispose.length = 0);
|
|
17653
17653
|
} catch (e) {
|
|
17654
|
-
|
|
17654
|
+
Pm.warn("failed to clear TSL texture singleton listeners", e);
|
|
17655
17655
|
}
|
|
17656
17656
|
br(this.renderer), this.renderer = null, this.stages = {}, this.isInitialized = !1;
|
|
17657
17657
|
}
|
|
@@ -17875,7 +17875,7 @@ var Cm = 4096, wm = class {
|
|
|
17875
17875
|
if (!e) return;
|
|
17876
17876
|
this._pendingReservedRenderSize = null;
|
|
17877
17877
|
let t = this.setReservedRenderResolution(e.requestedPx, { allowLower: e.allowLower });
|
|
17878
|
-
t < e.requestedPx &&
|
|
17878
|
+
t < e.requestedPx && Pm.warn(`reserved render size ${Q.n(e.requestedPx)}px was capped to ${Q.n(t)}px by this device's limits — renders above ${Q.n(t)}px will be declined.`), this.dispatchEvent({
|
|
17879
17879
|
type: "reserved_render_size_changed",
|
|
17880
17880
|
size: t
|
|
17881
17881
|
});
|
|
@@ -17884,7 +17884,7 @@ var Cm = 4096, wm = class {
|
|
|
17884
17884
|
return Dr;
|
|
17885
17885
|
}
|
|
17886
17886
|
_isRenderSizeSupported(e, t) {
|
|
17887
|
-
return e > Dr || t > Dr ? (
|
|
17887
|
+
return e > Dr || t > Dr ? (Pm.warn(`render resolution ${e}×${t} exceeds the ${Dr}px reserve (compute storage textures are pre-allocated at ${Dr}px). Ignoring resize — raise the reserve with setReservedRenderResolution( ${Math.max(e, t)} ) first, or use a resolution ≤ ${Dr}.`), !1) : !0;
|
|
17888
17888
|
}
|
|
17889
17889
|
onResize() {
|
|
17890
17890
|
let e = this.canvas.clientWidth, t = this.canvas.clientHeight;
|
|
@@ -18055,7 +18055,7 @@ var Cm = 4096, wm = class {
|
|
|
18055
18055
|
this._pathTracerEnabled = e, e || this.precompileRaster();
|
|
18056
18056
|
}
|
|
18057
18057
|
precompileRaster() {
|
|
18058
|
-
return !this.renderer || !this.meshScene ? Promise.resolve() : (this._rasterPrecompile ??= this.renderer.compileAsync(this.meshScene, this.cameraManager.camera).catch((e) =>
|
|
18058
|
+
return !this.renderer || !this.meshScene ? Promise.resolve() : (this._rasterPrecompile ??= this.renderer.compileAsync(this.meshScene, this.cameraManager.camera).catch((e) => Pm.warn("raster fallback precompile failed", e)), this._rasterPrecompile);
|
|
18059
18059
|
}
|
|
18060
18060
|
get isLoading() {
|
|
18061
18061
|
return this._loadingInProgress;
|
|
@@ -18162,40 +18162,40 @@ var Cm = 4096, wm = class {
|
|
|
18162
18162
|
let n = this.renderer.backend?.device;
|
|
18163
18163
|
n?.lost && (n.lost.then((e) => {
|
|
18164
18164
|
this._disposed || this._handleDeviceLost(e);
|
|
18165
|
-
}), n.onuncapturederror = (e) =>
|
|
18165
|
+
}), n.onuncapturederror = (e) => Pm.error("WebGPU uncaptured error:", e.error)), r.setLTC(cn.init()), this.renderer.outputColorSpace = a, this.renderer.toneMapping = He, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1);
|
|
18166
18166
|
}
|
|
18167
18167
|
_initCameraManager() {
|
|
18168
|
-
this.cameraManager = new
|
|
18168
|
+
this.cameraManager = new Op(this.canvas);
|
|
18169
18169
|
}
|
|
18170
18170
|
_initScenes() {
|
|
18171
18171
|
this.scene = new Jt(), this.meshScene = new Jt(), this._sceneHelpers = new Nn();
|
|
18172
18172
|
}
|
|
18173
18173
|
_initAssetPipeline() {
|
|
18174
|
-
this._sdf = new Qc(), this.assetLoader = new
|
|
18174
|
+
this._sdf = new Qc(), this.assetLoader = new wp(this.meshScene, this.cameraManager.camera, this.cameraManager.controls), this.assetLoader.setRenderer(this.renderer), this.assetLoader.createFloorPlane(), this._addTrackedListener(this.cameraManager.controls, "change", () => {
|
|
18175
18175
|
this.needsReset = !0, this.wake();
|
|
18176
18176
|
});
|
|
18177
18177
|
}
|
|
18178
18178
|
_initPipeline() {
|
|
18179
18179
|
this._createStages();
|
|
18180
18180
|
let { clientWidth: e, clientHeight: t } = this.canvas;
|
|
18181
|
-
this.pipeline = new
|
|
18181
|
+
this.pipeline = new Vf(this.renderer, e || 1, t || 1), this.pipeline.addStage(this.stages.pathTracer), this.pipeline.addStage(this.stages.normalDepth), this.pipeline.addStage(this.stages.motionVector), this.pipeline.addStage(this.stages.asvgf), this.pipeline.addStage(this.stages.variance), this.pipeline.addStage(this.stages.bilateralFilter), this.pipeline.addStage(this.stages.edgeFilter), this.pipeline.addStage(this.stages.autoExposure), this.pipeline.addStage(this.stages.compositor);
|
|
18182
18182
|
let n = this.canvas.clientWidth || 1, r = this.canvas.clientHeight || 1;
|
|
18183
18183
|
this.pipeline.setSize(n, r);
|
|
18184
18184
|
}
|
|
18185
18185
|
async _initManagers() {
|
|
18186
|
-
this.interactionManager = new
|
|
18186
|
+
this.interactionManager = new Uf({
|
|
18187
18187
|
scene: this.meshScene,
|
|
18188
18188
|
camera: this.cameraManager.camera,
|
|
18189
18189
|
canvas: this.canvas,
|
|
18190
18190
|
assetLoader: this.assetLoader,
|
|
18191
18191
|
pathTracer: null,
|
|
18192
18192
|
floorPlane: this.assetLoader.floorPlane
|
|
18193
|
-
}), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new
|
|
18193
|
+
}), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new kp(this.scene, this._sceneHelpers, this.stages.pathTracer, { onReset: () => this.reset() }), this.goboManager = new Ap(this.stages.pathTracer, { onReset: () => this.reset() }), this.iesManager = new Vp(this.stages.pathTracer, { onReset: () => this.reset() }), this._setupDenoisingManager(), await this._setupOverlayManager(), this.transformManager = new jm({
|
|
18194
18194
|
camera: this.cameraManager.camera,
|
|
18195
18195
|
canvas: this.canvas,
|
|
18196
18196
|
orbitControls: this.cameraManager.controls,
|
|
18197
18197
|
app: this
|
|
18198
|
-
}), this.overlayManager.register("transform", new
|
|
18198
|
+
}), this.overlayManager.register("transform", new Mm(this.transformManager)), this.interactionManager.setDependencies({
|
|
18199
18199
|
overlayManager: this.overlayManager,
|
|
18200
18200
|
transformManager: this.transformManager,
|
|
18201
18201
|
appDispatch: (e) => this.dispatchEvent(e),
|
|
@@ -18267,13 +18267,13 @@ var Cm = 4096, wm = class {
|
|
|
18267
18267
|
this.transformManager?.setMeshData(this._sdf.meshes);
|
|
18268
18268
|
}
|
|
18269
18269
|
_createStages() {
|
|
18270
|
-
this.stages.pathTracer = new rf(this.renderer, this.scene, this.cameraManager.camera), this.stages.normalDepth = new af(this.renderer, { pathTracer: this.stages.pathTracer }), this.stages.motionVector = new of(this.renderer, this.cameraManager.camera, { pathTracer: this.stages.pathTracer }), this.stages.asvgf = new lf(this.renderer, { enabled: !1 }), this.stages.variance = new ff(this.renderer, { enabled: !1 }), this.stages.bilateralFilter = new mf(this.renderer, { enabled: !1 }), this.stages.edgeFilter = new
|
|
18270
|
+
this.stages.pathTracer = new rf(this.renderer, this.scene, this.cameraManager.camera), this.stages.normalDepth = new af(this.renderer, { pathTracer: this.stages.pathTracer }), this.stages.motionVector = new of(this.renderer, this.cameraManager.camera, { pathTracer: this.stages.pathTracer }), this.stages.asvgf = new lf(this.renderer, { enabled: !1 }), this.stages.variance = new ff(this.renderer, { enabled: !1 }), this.stages.bilateralFilter = new mf(this.renderer, { enabled: !1 }), this.stages.edgeFilter = new bf(this.renderer, { enabled: !1 }), this.stages.autoExposure = new Df(this.renderer, { enabled: Y.autoExposure ?? !1 }), this.stages.compositor = new Of(this.renderer, {
|
|
18271
18271
|
saturation: this.settings.get("saturation") ?? Y.saturation,
|
|
18272
18272
|
pathTracer: this.stages.pathTracer
|
|
18273
18273
|
});
|
|
18274
18274
|
}
|
|
18275
18275
|
_setupDenoisingManager() {
|
|
18276
|
-
this.denoisingManager = new
|
|
18276
|
+
this.denoisingManager = new ym({
|
|
18277
18277
|
renderer: this.renderer,
|
|
18278
18278
|
mainCanvas: this.canvas,
|
|
18279
18279
|
scene: this.scene,
|
|
@@ -18316,7 +18316,7 @@ var Cm = 4096, wm = class {
|
|
|
18316
18316
|
this.scene.updateMatrixWorld(), this.overlayManager?.render();
|
|
18317
18317
|
}
|
|
18318
18318
|
async _setupOverlayManager() {
|
|
18319
|
-
this.overlayManager = new
|
|
18319
|
+
this.overlayManager = new Om(this.cameraManager.camera), this.overlayManager.setupDefaultHelpers({
|
|
18320
18320
|
helperScene: this._sceneHelpers,
|
|
18321
18321
|
meshScene: this.meshScene,
|
|
18322
18322
|
pipeline: this.pipeline,
|
|
@@ -18347,7 +18347,7 @@ var Cm = 4096, wm = class {
|
|
|
18347
18347
|
_forwardEvents(e, t) {
|
|
18348
18348
|
if (e) for (let n of t) this._addTrackedListener(e, n, (e) => this.dispatchEvent(e));
|
|
18349
18349
|
}
|
|
18350
|
-
},
|
|
18350
|
+
}, Im = class {
|
|
18351
18351
|
constructor(e) {
|
|
18352
18352
|
this._app = e, this._cancelled = !1, this._rendering = !1;
|
|
18353
18353
|
}
|
|
@@ -18445,4 +18445,4 @@ var Cm = 4096, wm = class {
|
|
|
18445
18445
|
}
|
|
18446
18446
|
};
|
|
18447
18447
|
//#endregion
|
|
18448
|
-
export { Pr as AF_DEFAULTS, kr as ASVGF_QUALITY_PRESETS, Nr as AUTO_FOCUS_MODES,
|
|
18448
|
+
export { Pr as AF_DEFAULTS, kr as ASVGF_QUALITY_PRESETS, Nr as AUTO_FOCUS_MODES, km as AnimationManager, Fr as BVH_LEAF_MARKERS, Mr as CAMERA_PRESETS, Ar as CAMERA_RANGES, Op as CameraManager, Br as DEFAULT_TEXTURE_MATRIX, ym as DenoisingManager, Y as ENGINE_DEFAULTS, ur as EngineEvents, Ap as GoboManager, Vp as IESManager, Hr as INTERACTIVE_RENDER_CONFIG, Uf as InteractionManager, Wr as LOG_LEVELS, kp as LightManager, ii as Logger, Er as MAX_RESERVABLE_RENDER_SIZE, Ur as MEMORY_CONSTANTS, Om as OverlayManager, Vr as PRODUCTION_RENDER_CONFIG, Fm as PathTracerApp, kf as PipelineContext, Vf as RenderPipeline, Dp as RenderSettings, cr as RenderStage, jr as SKY_PRESETS, sr as StageExecutionMode, Ir as TEXTURE_CONSTANTS, X as TRIANGLE_DATA_LAYOUT, jm as TransformManager, uu as VRAMTracker, Im as VideoRenderManager, cu as bufferBytes, If as clearBindingAuditFindings, sl as configureAssets, ai as createLogger, Q as fmt, cl as getAssetConfig, Ff as getBindingAuditFindings, Pf as setBindingAudit, lu as textureBytes };
|