rayzee 7.22.7 → 7.22.8
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 +131 -78
- package/dist/rayzee.umd.js +14 -2
- package/package.json +1 -1
- package/src/EngineDefaults.js +2 -1
- package/src/Passes/OIDNDenoiser.js +163 -26
package/dist/rayzee.es.js
CHANGED
|
@@ -1026,7 +1026,7 @@ var Br = [
|
|
|
1026
1026
|
renderMode: 1,
|
|
1027
1027
|
enableAlphaShadows: !0,
|
|
1028
1028
|
enableOIDN: !0,
|
|
1029
|
-
oidnQuality: "
|
|
1029
|
+
oidnQuality: "high",
|
|
1030
1030
|
interactionModeEnabled: !1,
|
|
1031
1031
|
useAdaptiveSampling: !0,
|
|
1032
1032
|
noiseThreshold: .02,
|
|
@@ -16228,16 +16228,26 @@ function cm() {
|
|
|
16228
16228
|
var lm = new Float32Array(3), um = {
|
|
16229
16229
|
QUALITY_MODELS: {
|
|
16230
16230
|
fast: "rt_hdr_alb_nrm_small",
|
|
16231
|
-
balance: "
|
|
16231
|
+
balance: "rt_hdr_calb_cnrm",
|
|
16232
16232
|
high: "rt_hdr_calb_cnrm_large"
|
|
16233
16233
|
},
|
|
16234
16234
|
DEFAULT_OPTIONS: {
|
|
16235
16235
|
enableOIDN: !0,
|
|
16236
16236
|
oidnQuality: "fast",
|
|
16237
16237
|
debugGbufferMaps: !0,
|
|
16238
|
-
tileSize:
|
|
16238
|
+
tileSize: 512
|
|
16239
16239
|
}
|
|
16240
|
-
}, dm =
|
|
16240
|
+
}, dm = "\n@group(0) @binding(0) var<storage, read_write> col: array<vec4<f32>>;\n@group(0) @binding(1) var<uniform> scale: f32;\n\n@compute @workgroup_size(64)\nfn main( @builtin(global_invocation_id) gid: vec3<u32>,\n @builtin(num_workgroups) nwg: vec3<u32> ) {\n let i = gid.y * nwg.x * 64u + gid.x;\n if ( i >= arrayLength( &col ) ) { return; }\n let c = col[ i ];\n col[ i ] = vec4<f32>( c.xyz * scale, c.w );\n}\n", fm = 64, pm = 32768, mm = .18;
|
|
16241
|
+
function hm(e, t) {
|
|
16242
|
+
let n = 0;
|
|
16243
|
+
for (let r = 0; r < t; r++) {
|
|
16244
|
+
let t = r * 4, i = .212671 * e[t] + .71516 * e[t + 1] + .072169 * e[t + 2];
|
|
16245
|
+
n += Math.log2(Math.max(i, 0) + 1e-4);
|
|
16246
|
+
}
|
|
16247
|
+
let r = mm / 2 ** (n / t);
|
|
16248
|
+
return Number.isFinite(r) && r > 0 ? r : 1;
|
|
16249
|
+
}
|
|
16250
|
+
var gm = class extends lt {
|
|
16241
16251
|
constructor(e, t, n, r, i = {}) {
|
|
16242
16252
|
if (super(), !e || !t || !n || !r) throw Error("OIDNDenoiser requires output canvas, renderer, scene, and camera");
|
|
16243
16253
|
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 = {
|
|
@@ -16247,10 +16257,10 @@ var lm = new Float32Array(3), um = {
|
|
|
16247
16257
|
}, this._gpuInputBufferSize = {
|
|
16248
16258
|
width: 0,
|
|
16249
16259
|
height: 0
|
|
16250
|
-
}, this._gpuInputPadBuffer = null, this._gpuInputPaddedRowBytes = 0, this._alphaReadbackBuffer = null, this._alphaReadbackMapped = !1, this._cachedAlpha = null, this._cachedAlphaWidth = 0, this.config = {
|
|
16260
|
+
}, this._gpuInputPadBuffer = null, this._gpuInputPaddedRowBytes = 0, this._colorScalePipeline = null, this._colorScaleBindGroup = null, this._colorScaleUniform = null, this._oidnInputScale = 1, this._alphaReadbackBuffer = null, this._alphaReadbackMapped = !1, this._cachedAlpha = null, this._cachedAlphaWidth = 0, this.config = {
|
|
16251
16261
|
...um.DEFAULT_OPTIONS,
|
|
16252
16262
|
...i
|
|
16253
|
-
}, this.enabled = this.config.enableOIDN, this.quality = this.config.oidnQuality, this.debugGbufferMaps = this.config.debugGbufferMaps, this.tileSize = this.config.tileSize, this.state = {
|
|
16263
|
+
}, this.enabled = this.config.enableOIDN, this.quality = this.config.oidnQuality, this.debugGbufferMaps = this.config.debugGbufferMaps, this.tileSize = this.config.tileSize, this._activeTileSize = 0, this.state = {
|
|
16254
16264
|
isDenoising: !1,
|
|
16255
16265
|
isLoading: !1,
|
|
16256
16266
|
abortController: null
|
|
@@ -16287,7 +16297,7 @@ var lm = new Float32Array(3), um = {
|
|
|
16287
16297
|
if (this.state.isLoading) return;
|
|
16288
16298
|
this.state.isLoading = !0;
|
|
16289
16299
|
let e = this._generateTzaUrl();
|
|
16290
|
-
if (this.currentTZAUrl === e && this.unet) {
|
|
16300
|
+
if (this.currentTZAUrl === e && this._activeTileSize === this.tileSize && this.unet) {
|
|
16291
16301
|
this.state.isLoading = !1;
|
|
16292
16302
|
return;
|
|
16293
16303
|
}
|
|
@@ -16305,7 +16315,7 @@ var lm = new Float32Array(3), um = {
|
|
|
16305
16315
|
aux: !0,
|
|
16306
16316
|
hdr: !0,
|
|
16307
16317
|
maxTileSize: this.tileSize
|
|
16308
|
-
}), this.currentTZAUrl = e, this.dispatchEvent({ type: "loaded" }), im.debug("UNet weights loaded:", e);
|
|
16318
|
+
}), this.currentTZAUrl = e, this._activeTileSize = this.tileSize, this.dispatchEvent({ type: "loaded" }), im.debug("UNet weights loaded:", e);
|
|
16309
16319
|
} catch (e) {
|
|
16310
16320
|
im.error("UNet weights failed to load:", e), this.dispatchEvent({
|
|
16311
16321
|
type: "error",
|
|
@@ -16391,7 +16401,7 @@ var lm = new Float32Array(3), um = {
|
|
|
16391
16401
|
for (let e = 0; e < t; e++) i.copyBufferToBuffer(c, e * o, r, e * a, a);
|
|
16392
16402
|
}
|
|
16393
16403
|
};
|
|
16394
|
-
l(n.color, this._gpuInputBuffers.color), l(n.albedo, this._gpuInputBuffers.albedo), l(n.normal, this._gpuInputBuffers.normal), r.queue.submit([i.finish()]),
|
|
16404
|
+
l(n.color, this._gpuInputBuffers.color), l(n.albedo, this._gpuInputBuffers.albedo), l(n.normal, this._gpuInputBuffers.normal), r.queue.submit([i.finish()]), await this._readbackColor(r, e, t), globalThis.__OIDN_NO_INPUT_SCALE && (this._oidnInputScale = 1), this._applyColorScale(r, e * t), this.ctx.drawImage(this.input, 0, 0, e, t);
|
|
16395
16405
|
let u = {
|
|
16396
16406
|
color: {
|
|
16397
16407
|
data: this._gpuInputBuffers.color,
|
|
@@ -16443,7 +16453,7 @@ var lm = new Float32Array(3), um = {
|
|
|
16443
16453
|
if (this._gpuInputBuffers.color?.destroy(), this._gpuInputBuffers.albedo?.destroy(), this._gpuInputBuffers.normal?.destroy(), this._gpuInputPadBuffer?.destroy(), this._alphaReadbackMapped && this._alphaReadbackBuffer) try {
|
|
16444
16454
|
this._alphaReadbackBuffer.unmap();
|
|
16445
16455
|
} catch {}
|
|
16446
|
-
this._alphaReadbackBuffer?.destroy(), this._alphaReadbackMapped = !1, this._gpuInputBuffers = {
|
|
16456
|
+
this._alphaReadbackBuffer?.destroy(), this._alphaReadbackMapped = !1, this._colorScaleBindGroup = null, this._colorScaleUniform?.destroy(), this._colorScaleUniform = null, this._gpuInputBuffers = {
|
|
16447
16457
|
color: null,
|
|
16448
16458
|
albedo: null,
|
|
16449
16459
|
normal: null
|
|
@@ -16452,7 +16462,7 @@ var lm = new Float32Array(3), um = {
|
|
|
16452
16462
|
height: 0
|
|
16453
16463
|
};
|
|
16454
16464
|
}
|
|
16455
|
-
async
|
|
16465
|
+
async _readbackColor(e, t, n) {
|
|
16456
16466
|
let r = t * n * 16;
|
|
16457
16467
|
this._alphaReadbackBuffer === null && (this._alphaReadbackBuffer = e.createBuffer({
|
|
16458
16468
|
label: "oidn-alpha-readback",
|
|
@@ -16467,10 +16477,53 @@ var lm = new Float32Array(3), um = {
|
|
|
16467
16477
|
this._alphaReadbackMapped = !1;
|
|
16468
16478
|
return;
|
|
16469
16479
|
}
|
|
16470
|
-
let o = new Float32Array(i.getMappedRange()), s = t * n
|
|
16471
|
-
|
|
16480
|
+
let o = new Float32Array(i.getMappedRange()), s = t * n;
|
|
16481
|
+
this._oidnInputScale = hm(o, s);
|
|
16482
|
+
let c = null;
|
|
16483
|
+
if (this.getTransparentBackground()) {
|
|
16484
|
+
c = new Uint8Array(s);
|
|
16485
|
+
for (let e = 0; e < s; e++) c[e] = Math.min(Math.max(o[e * 4 + 3] * 255, 0), 255) | 0;
|
|
16486
|
+
}
|
|
16472
16487
|
i.unmap(), this._alphaReadbackMapped = !1, this._cachedAlpha = c, this._cachedAlphaWidth = t;
|
|
16473
16488
|
}
|
|
16489
|
+
_outputExposure() {
|
|
16490
|
+
return this.getExposure() / this._oidnInputScale;
|
|
16491
|
+
}
|
|
16492
|
+
_applyColorScale(e, t) {
|
|
16493
|
+
let n = this._oidnInputScale;
|
|
16494
|
+
if (!this._ensureColorScalePipeline(e)) return;
|
|
16495
|
+
e.queue.writeBuffer(this._colorScaleUniform, 0, new Float32Array([n]));
|
|
16496
|
+
let r = Math.ceil(t / fm), i = Math.min(r, pm), a = Math.ceil(r / i), o = e.createCommandEncoder({ label: "oidn-color-scale" }), s = o.beginComputePass({ label: "oidn-color-scale" });
|
|
16497
|
+
s.setPipeline(this._colorScalePipeline), s.setBindGroup(0, this._colorScaleBindGroup), s.dispatchWorkgroups(i, a, 1), s.end(), e.queue.submit([o.finish()]);
|
|
16498
|
+
}
|
|
16499
|
+
_ensureColorScalePipeline(e) {
|
|
16500
|
+
let t = this._gpuInputBuffers.color;
|
|
16501
|
+
return !e || !t ? null : (this._colorScalePipeline ||= e.createComputePipeline({
|
|
16502
|
+
label: "oidn-color-scale",
|
|
16503
|
+
layout: "auto",
|
|
16504
|
+
compute: {
|
|
16505
|
+
module: e.createShaderModule({
|
|
16506
|
+
label: "oidn-color-scale",
|
|
16507
|
+
code: dm
|
|
16508
|
+
}),
|
|
16509
|
+
entryPoint: "main"
|
|
16510
|
+
}
|
|
16511
|
+
}), this._colorScaleUniform ||= e.createBuffer({
|
|
16512
|
+
label: "oidn-color-scale-uniform",
|
|
16513
|
+
size: 16,
|
|
16514
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
16515
|
+
}), this._colorScaleBindGroup ||= e.createBindGroup({
|
|
16516
|
+
label: "oidn-color-scale",
|
|
16517
|
+
layout: this._colorScalePipeline.getBindGroupLayout(0),
|
|
16518
|
+
entries: [{
|
|
16519
|
+
binding: 0,
|
|
16520
|
+
resource: { buffer: t }
|
|
16521
|
+
}, {
|
|
16522
|
+
binding: 1,
|
|
16523
|
+
resource: { buffer: this._colorScaleUniform }
|
|
16524
|
+
}]
|
|
16525
|
+
}), this._colorScalePipeline);
|
|
16526
|
+
}
|
|
16474
16527
|
_executeWithAbortGPU(e) {
|
|
16475
16528
|
return new Promise((t, n) => {
|
|
16476
16529
|
if (this.state.abortController?.signal.aborted) {
|
|
@@ -16508,7 +16561,7 @@ var lm = new Float32Array(3), um = {
|
|
|
16508
16561
|
}
|
|
16509
16562
|
r.queue.submit([d.finish()]);
|
|
16510
16563
|
let f = u.mapAsync(GPUMapMode.READ).then(() => {
|
|
16511
|
-
let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this.
|
|
16564
|
+
let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this._outputExposure(), c = this.getSaturation(), l = Zp.get(this.getToneMapping()) || Zp.get(He), d = this._cachedAlpha, f = this._cachedAlphaWidth;
|
|
16512
16565
|
for (let i = 0, a = e.length; i < a; i += 4) {
|
|
16513
16566
|
let a = e[i] * r, s = e[i + 1] * r, u = e[i + 2] * r;
|
|
16514
16567
|
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) {
|
|
@@ -16549,7 +16602,7 @@ var lm = new Float32Array(3), um = {
|
|
|
16549
16602
|
try {
|
|
16550
16603
|
let o = r.createCommandEncoder({ label: "oidn-readback" });
|
|
16551
16604
|
o.copyBufferToBuffer(e, 0, a, 0, i), r.queue.submit([o.finish()]), await a.mapAsync(GPUMapMode.READ);
|
|
16552
|
-
let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this.
|
|
16605
|
+
let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this._outputExposure(), u = this.getSaturation(), d = Zp.get(this.getToneMapping()) || Zp.get(He), f = this._cachedAlpha;
|
|
16553
16606
|
for (let e = 0, t = s.length; e < t; e += 4) {
|
|
16554
16607
|
let t = s[e] * l, n = s[e + 1] * l, r = s[e + 2] * l;
|
|
16555
16608
|
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;
|
|
@@ -16573,13 +16626,13 @@ var lm = new Float32Array(3), um = {
|
|
|
16573
16626
|
this._pendingStagingBuffers.clear();
|
|
16574
16627
|
}
|
|
16575
16628
|
dispose() {
|
|
16576
|
-
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");
|
|
16629
|
+
this.abort(), this._destroyPendingStagingBuffers(), this.unet?.dispose(), cm(), this._destroyGPUInputBuffers(), this._colorScalePipeline = null, this.output?.parentNode && this.output.remove(), this.unet = null, this.ctx = null, this.state.abortController = null, this.removeAllListeners?.(), im.debug("disposed");
|
|
16577
16630
|
}
|
|
16578
|
-
},
|
|
16579
|
-
function
|
|
16631
|
+
}, _m = "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})}};", vm = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", _m], { type: "text/javascript;charset=utf-8" });
|
|
16632
|
+
function ym(e) {
|
|
16580
16633
|
let t;
|
|
16581
16634
|
try {
|
|
16582
|
-
if (t =
|
|
16635
|
+
if (t = vm && (self.URL || self.webkitURL).createObjectURL(vm), !t) throw "";
|
|
16583
16636
|
let n = new Worker(t, {
|
|
16584
16637
|
type: "module",
|
|
16585
16638
|
name: e?.name
|
|
@@ -16588,7 +16641,7 @@ function mm(e) {
|
|
|
16588
16641
|
(self.URL || self.webkitURL).revokeObjectURL(t);
|
|
16589
16642
|
}), n;
|
|
16590
16643
|
} catch {
|
|
16591
|
-
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
16644
|
+
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(_m), {
|
|
16592
16645
|
type: "module",
|
|
16593
16646
|
name: e?.name
|
|
16594
16647
|
});
|
|
@@ -16596,7 +16649,7 @@ function mm(e) {
|
|
|
16596
16649
|
}
|
|
16597
16650
|
//#endregion
|
|
16598
16651
|
//#region src/Passes/AIUpscaler.js
|
|
16599
|
-
var
|
|
16652
|
+
var bm = {
|
|
16600
16653
|
fast: {
|
|
16601
16654
|
2: "2x-spanx2-ch48.onnx",
|
|
16602
16655
|
4: "4xNomos8k_span_otf_strong_fp32_opset17.onnx"
|
|
@@ -16610,17 +16663,17 @@ var hm = {
|
|
|
16610
16663
|
4: "4xNomos2_hq_mosr_fp32.onnx"
|
|
16611
16664
|
}
|
|
16612
16665
|
};
|
|
16613
|
-
function
|
|
16666
|
+
function xm() {
|
|
16614
16667
|
let { upscalerModelBaseUrl: e } = cl(), t = {};
|
|
16615
|
-
for (let n in
|
|
16668
|
+
for (let n in bm) {
|
|
16616
16669
|
t[n] = {};
|
|
16617
|
-
for (let r in
|
|
16670
|
+
for (let r in bm[n]) t[n][r] = e + bm[n][r];
|
|
16618
16671
|
}
|
|
16619
16672
|
return t;
|
|
16620
16673
|
}
|
|
16621
|
-
var
|
|
16674
|
+
var Sm = {
|
|
16622
16675
|
get QUALITY_PRESETS() {
|
|
16623
|
-
return
|
|
16676
|
+
return xm();
|
|
16624
16677
|
},
|
|
16625
16678
|
TILE_SIZE: 512,
|
|
16626
16679
|
TILE_OVERLAP: 16,
|
|
@@ -16631,17 +16684,17 @@ var _m = {
|
|
|
16631
16684
|
}],
|
|
16632
16685
|
graphOptimizationLevel: "all"
|
|
16633
16686
|
}
|
|
16634
|
-
},
|
|
16687
|
+
}, Cm = class extends lt {
|
|
16635
16688
|
constructor(e, t, n = {}) {
|
|
16636
16689
|
if (super(), !e || !t) throw Error("AIUpscaler requires output canvas and renderer");
|
|
16637
|
-
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 ||
|
|
16690
|
+
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 || Sm.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
|
|
16638
16691
|
isUpscaling: !1,
|
|
16639
16692
|
isLoading: !1,
|
|
16640
16693
|
abortController: null
|
|
16641
16694
|
}, 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;
|
|
16642
16695
|
}
|
|
16643
16696
|
async _ensureSession() {
|
|
16644
|
-
let e =
|
|
16697
|
+
let e = Sm.QUALITY_PRESETS[this.quality];
|
|
16645
16698
|
if (!e) throw Error(`Unknown quality preset: ${this.quality}`);
|
|
16646
16699
|
let t = e[this.scaleFactor];
|
|
16647
16700
|
if (!t) throw Error(`No model for ${this.quality}/${this.scaleFactor}x`);
|
|
@@ -16651,14 +16704,14 @@ var _m = {
|
|
|
16651
16704
|
message: `Loading ${this.scaleFactor}x upscale model...`
|
|
16652
16705
|
});
|
|
16653
16706
|
try {
|
|
16654
|
-
this._worker ||= new
|
|
16707
|
+
this._worker ||= new ym(), await new Promise((e, n) => {
|
|
16655
16708
|
let r = (t) => {
|
|
16656
16709
|
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)));
|
|
16657
16710
|
}, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o } = cl();
|
|
16658
16711
|
this._worker.addEventListener("message", r), this._worker.postMessage({
|
|
16659
16712
|
type: "load",
|
|
16660
16713
|
url: t,
|
|
16661
|
-
sessionOptions:
|
|
16714
|
+
sessionOptions: Sm.SESSION_OPTIONS,
|
|
16662
16715
|
ortRuntimeUrl: i,
|
|
16663
16716
|
ortWasmPaths: a,
|
|
16664
16717
|
cacheNamespace: o
|
|
@@ -16729,7 +16782,7 @@ var _m = {
|
|
|
16729
16782
|
alpha: !0
|
|
16730
16783
|
});
|
|
16731
16784
|
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));
|
|
16732
|
-
let o =
|
|
16785
|
+
let o = Sm.TILE_OVERLAP, s = this.tileSize, c = s - o * 2, l = Math.ceil(n / c), u = Math.ceil(r / c), d = l * u, f = 0;
|
|
16733
16786
|
for (let o = 0; o < u; o++) for (let u = 0; u < l; u++) {
|
|
16734
16787
|
if (e.aborted) throw new DOMException("Aborted", "AbortError");
|
|
16735
16788
|
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);
|
|
@@ -16875,7 +16928,7 @@ var _m = {
|
|
|
16875
16928
|
this.hdr = !!e;
|
|
16876
16929
|
}
|
|
16877
16930
|
setQuality(e) {
|
|
16878
|
-
if (!
|
|
16931
|
+
if (!Sm.QUALITY_PRESETS[e]) {
|
|
16879
16932
|
console.warn(`AIUpscaler: Invalid quality "${e}", must be fast/balanced/quality`);
|
|
16880
16933
|
return;
|
|
16881
16934
|
}
|
|
@@ -16898,7 +16951,7 @@ var _m = {
|
|
|
16898
16951
|
async dispose() {
|
|
16899
16952
|
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");
|
|
16900
16953
|
}
|
|
16901
|
-
},
|
|
16954
|
+
}, wm = class extends lt {
|
|
16902
16955
|
constructor({ renderer: e, mainCanvas: t, scene: n, camera: r, stages: i, pipeline: a, getExposure: o, getSaturation: s, getTransparentBg: c }) {
|
|
16903
16956
|
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._onReset = null, this._onPostProcessRefresh = 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;
|
|
16904
16957
|
}
|
|
@@ -16919,7 +16972,7 @@ var _m = {
|
|
|
16919
16972
|
setupDenoiser() {
|
|
16920
16973
|
if (!this.denoiserCanvas) return;
|
|
16921
16974
|
let e = this._stages.pathTracer;
|
|
16922
|
-
this.denoiser = new
|
|
16975
|
+
this.denoiser = new gm(this.denoiserCanvas, this.renderer, this.scene, this.camera, {
|
|
16923
16976
|
...Y,
|
|
16924
16977
|
backendParams: () => ({
|
|
16925
16978
|
device: this.renderer.backend.device,
|
|
@@ -16944,7 +16997,7 @@ var _m = {
|
|
|
16944
16997
|
setupUpscaler() {
|
|
16945
16998
|
if (!this.denoiserCanvas) return;
|
|
16946
16999
|
let e = this._stages.pathTracer;
|
|
16947
|
-
this.upscaler = new
|
|
17000
|
+
this.upscaler = new Cm(this.denoiserCanvas, this.renderer, {
|
|
16948
17001
|
scaleFactor: Y.upscalerScale || 2,
|
|
16949
17002
|
quality: Y.upscalerQuality || "fast",
|
|
16950
17003
|
getSourceCanvas: () => this.denoiser?.enabled ? null : this.renderer.domElement,
|
|
@@ -17095,7 +17148,7 @@ var _m = {
|
|
|
17095
17148
|
let t = kr[e];
|
|
17096
17149
|
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));
|
|
17097
17150
|
}
|
|
17098
|
-
},
|
|
17151
|
+
}, Tm = class {
|
|
17099
17152
|
constructor() {
|
|
17100
17153
|
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;
|
|
17101
17154
|
}
|
|
@@ -17119,7 +17172,7 @@ var _m = {
|
|
|
17119
17172
|
dispose() {
|
|
17120
17173
|
this.visible = !1;
|
|
17121
17174
|
}
|
|
17122
|
-
},
|
|
17175
|
+
}, Em = class {
|
|
17123
17176
|
constructor(n, r) {
|
|
17124
17177
|
this.layer = "scene", this._enabled = !0, this._outlineNode = bn(n, r, {
|
|
17125
17178
|
selectedObjects: [],
|
|
@@ -17150,11 +17203,11 @@ var _m = {
|
|
|
17150
17203
|
this._enabled = !1, this._outlineNode?.dispose(), this._material?.dispose(), this._quad = null;
|
|
17151
17204
|
}
|
|
17152
17205
|
};
|
|
17153
|
-
function
|
|
17206
|
+
function Dm(e = !1) {
|
|
17154
17207
|
let t = document.createElement("canvas");
|
|
17155
17208
|
return t.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;" + (e ? "display:none;" : ""), t;
|
|
17156
17209
|
}
|
|
17157
|
-
function
|
|
17210
|
+
function Om(e, t = Infinity) {
|
|
17158
17211
|
let n = e?.getBoundingClientRect();
|
|
17159
17212
|
if (!n || n.width === 0 || n.height === 0) return null;
|
|
17160
17213
|
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);
|
|
@@ -17165,9 +17218,9 @@ function Cm(e, t = Infinity) {
|
|
|
17165
17218
|
}
|
|
17166
17219
|
//#endregion
|
|
17167
17220
|
//#region src/managers/helpers/ViewOverlayRenderer.js
|
|
17168
|
-
var
|
|
17221
|
+
var km = 4096, Am = class {
|
|
17169
17222
|
constructor() {
|
|
17170
|
-
this.canvas =
|
|
17223
|
+
this.canvas = Dm(!0), this._visible = !1, this.renderer = null, this._sizeSource = null;
|
|
17171
17224
|
}
|
|
17172
17225
|
async init({ device: e, sizeSource: t }) {
|
|
17173
17226
|
this._sizeSource = t;
|
|
@@ -17184,7 +17237,7 @@ var wm = 4096, Tm = class {
|
|
|
17184
17237
|
}
|
|
17185
17238
|
syncSize() {
|
|
17186
17239
|
if (!this.renderer) return;
|
|
17187
|
-
let e =
|
|
17240
|
+
let e = Om(this._sizeSource, km);
|
|
17188
17241
|
!e || e.width === this.canvas.width && e.height === this.canvas.height || this.renderer.setSize(e.width, e.height, !1);
|
|
17189
17242
|
}
|
|
17190
17243
|
begin() {
|
|
@@ -17196,18 +17249,18 @@ var wm = 4096, Tm = class {
|
|
|
17196
17249
|
dispose() {
|
|
17197
17250
|
br(this.renderer), this.renderer = null, this.canvas.parentElement?.removeChild(this.canvas);
|
|
17198
17251
|
}
|
|
17199
|
-
},
|
|
17252
|
+
}, jm = ai("overlay"), Mm = (e, t) => e.visible && e.layer === t && e.render, Nm = class {
|
|
17200
17253
|
constructor(e) {
|
|
17201
|
-
this.camera = e, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas =
|
|
17254
|
+
this.camera = e, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas = Dm(), this._hudCtx = this._hudCanvas.getContext("2d"), this._helperScene = null, this._viewOverlay = null;
|
|
17202
17255
|
}
|
|
17203
17256
|
async initViewRenderer({ device: e, sizeSource: t }) {
|
|
17204
17257
|
if (!(!e || !t)) try {
|
|
17205
|
-
this._viewOverlay = await new
|
|
17258
|
+
this._viewOverlay = await new Am().init({
|
|
17206
17259
|
device: e,
|
|
17207
17260
|
sizeSource: t
|
|
17208
17261
|
});
|
|
17209
17262
|
} catch (e) {
|
|
17210
|
-
|
|
17263
|
+
jm.error("overlay surface unavailable — light gizmos, transform gizmo and outlines are disabled", e), this._viewOverlay = null;
|
|
17211
17264
|
}
|
|
17212
17265
|
}
|
|
17213
17266
|
setHelperScene(e) {
|
|
@@ -17223,11 +17276,11 @@ var wm = 4096, Tm = class {
|
|
|
17223
17276
|
}
|
|
17224
17277
|
setupDefaultHelpers({ helperScene: e, meshScene: t, pipeline: n, denoisingManager: r, app: i, renderWidth: a, renderHeight: o }) {
|
|
17225
17278
|
this.setHelperScene(e);
|
|
17226
|
-
let s = new
|
|
17279
|
+
let s = new Tm();
|
|
17227
17280
|
this.register("tiles", s), s.setRenderSize(a || 1, o || 1), i.addEventListener("resolution_changed", (e) => {
|
|
17228
17281
|
s.setRenderSize(e.width, e.height);
|
|
17229
17282
|
}), n.eventBus.on("pipeline:reset", () => s.hide()), this._wireDenoiserTileEvents(s, r);
|
|
17230
|
-
let c = new
|
|
17283
|
+
let c = new Em(t, this.camera);
|
|
17231
17284
|
this.register("outline", c);
|
|
17232
17285
|
}
|
|
17233
17286
|
_wireDenoiserTileEvents(e, t) {
|
|
@@ -17239,7 +17292,7 @@ var wm = 4096, Tm = class {
|
|
|
17239
17292
|
}));
|
|
17240
17293
|
}
|
|
17241
17294
|
register(e, t) {
|
|
17242
|
-
this._helpers.has(e) && (
|
|
17295
|
+
this._helpers.has(e) && (jm.warn(`helper "${e}" already registered — replacing.`), this._helpers.get(e).dispose?.()), this._helpers.set(e, t);
|
|
17243
17296
|
}
|
|
17244
17297
|
unregister(e) {
|
|
17245
17298
|
let t = this._helpers.get(e);
|
|
@@ -17277,16 +17330,16 @@ var wm = 4096, Tm = class {
|
|
|
17277
17330
|
}
|
|
17278
17331
|
_renderSceneLayer(e) {
|
|
17279
17332
|
this._helperScene?.render(e, this.camera);
|
|
17280
|
-
for (let t of this._helpers.values())
|
|
17333
|
+
for (let t of this._helpers.values()) Mm(t, "scene") && t.render(e, this.camera);
|
|
17281
17334
|
}
|
|
17282
17335
|
_hasVisibleSceneOverlay() {
|
|
17283
17336
|
if (this._helperScene?.isDrawing) return !0;
|
|
17284
|
-
for (let e of this._helpers.values()) if (
|
|
17337
|
+
for (let e of this._helpers.values()) if (Mm(e, "scene")) return !0;
|
|
17285
17338
|
return !1;
|
|
17286
17339
|
}
|
|
17287
17340
|
refreshHUD() {
|
|
17288
17341
|
let e = this._hudCanvas, t = this._hudCtx, n = !1;
|
|
17289
|
-
for (let e of this._helpers.values()) if (
|
|
17342
|
+
for (let e of this._helpers.values()) if (Mm(e, "hud")) {
|
|
17290
17343
|
n = !0;
|
|
17291
17344
|
break;
|
|
17292
17345
|
}
|
|
@@ -17295,10 +17348,10 @@ var wm = 4096, Tm = class {
|
|
|
17295
17348
|
return;
|
|
17296
17349
|
}
|
|
17297
17350
|
e.style.display !== "" && (e.style.display = "");
|
|
17298
|
-
let r = e.clientWidth, i = e.clientHeight, a = r > 0 && i > 0 ?
|
|
17351
|
+
let r = e.clientWidth, i = e.clientHeight, a = r > 0 && i > 0 ? Om(e) : null;
|
|
17299
17352
|
if (a) {
|
|
17300
17353
|
(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);
|
|
17301
|
-
for (let e of this._helpers.values())
|
|
17354
|
+
for (let e of this._helpers.values()) Mm(e, "hud") && e.render(t, r, i);
|
|
17302
17355
|
t.restore(), e.style.display !== "" && (e.style.display = "");
|
|
17303
17356
|
}
|
|
17304
17357
|
}
|
|
@@ -17306,7 +17359,7 @@ var wm = 4096, Tm = class {
|
|
|
17306
17359
|
for (let e of this._helpers.values()) e.dispose?.();
|
|
17307
17360
|
this._helpers.clear(), this._viewOverlay?.dispose(), this._viewOverlay = null, this._hudCanvas.parentElement && this._hudCanvas.parentElement.removeChild(this._hudCanvas);
|
|
17308
17361
|
}
|
|
17309
|
-
},
|
|
17362
|
+
}, Pm = class extends lt {
|
|
17310
17363
|
constructor() {
|
|
17311
17364
|
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;
|
|
17312
17365
|
}
|
|
@@ -17406,7 +17459,7 @@ var wm = 4096, Tm = class {
|
|
|
17406
17459
|
dispose() {
|
|
17407
17460
|
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;
|
|
17408
17461
|
}
|
|
17409
|
-
},
|
|
17462
|
+
}, Fm = new sn(0, 0, -1), Im = class {
|
|
17410
17463
|
constructor({ camera: e, canvas: t, orbitControls: n, app: r }) {
|
|
17411
17464
|
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);
|
|
17412
17465
|
}
|
|
@@ -17427,7 +17480,7 @@ var wm = 4096, Tm = class {
|
|
|
17427
17480
|
attach(e) {
|
|
17428
17481
|
if (this._attached !== e && (this._controls.attach(e), this._attached = e, this._lightTargetDistance = null, this._lastLightPosition = null, e.isLight && e.target)) {
|
|
17429
17482
|
let t = e.target.position.clone().sub(e.position), n = t.length();
|
|
17430
|
-
n > 1e-4 ? (e.quaternion.setFromUnitVectors(
|
|
17483
|
+
n > 1e-4 ? (e.quaternion.setFromUnitVectors(Fm, t.normalize()), this._lightTargetDistance = n) : this._lightTargetDistance = 1, this._lastLightPosition = e.position.clone();
|
|
17431
17484
|
}
|
|
17432
17485
|
}
|
|
17433
17486
|
detach() {
|
|
@@ -17539,7 +17592,7 @@ var wm = 4096, Tm = class {
|
|
|
17539
17592
|
dispose() {
|
|
17540
17593
|
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;
|
|
17541
17594
|
}
|
|
17542
|
-
},
|
|
17595
|
+
}, Lm = class {
|
|
17543
17596
|
constructor(e) {
|
|
17544
17597
|
this.layer = "scene", this._transformManager = e, this._enabled = !0;
|
|
17545
17598
|
}
|
|
@@ -17558,15 +17611,15 @@ var wm = 4096, Tm = class {
|
|
|
17558
17611
|
dispose() {
|
|
17559
17612
|
this._enabled = !1;
|
|
17560
17613
|
}
|
|
17561
|
-
},
|
|
17614
|
+
}, Rm = /* @__PURE__ */ new WeakMap(), zm = ai("engine"), Bm = class extends lt {
|
|
17562
17615
|
constructor(e, t = {}) {
|
|
17563
17616
|
super();
|
|
17564
17617
|
try {
|
|
17565
|
-
|
|
17618
|
+
Rm.get(e)?.dispose();
|
|
17566
17619
|
} catch (e) {
|
|
17567
|
-
|
|
17620
|
+
zm.warn("prior canvas owner dispose failed", e);
|
|
17568
17621
|
}
|
|
17569
|
-
|
|
17622
|
+
Rm.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 Pm(), 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;
|
|
17570
17623
|
}
|
|
17571
17624
|
_addTrackedListener(e, t, n) {
|
|
17572
17625
|
e && (e.addEventListener(t, n), this._trackedListeners.push({
|
|
@@ -17579,12 +17632,12 @@ var wm = 4096, Tm = class {
|
|
|
17579
17632
|
for (let { target: e, type: t, handler: n } of this._trackedListeners) try {
|
|
17580
17633
|
e.removeEventListener(t, n);
|
|
17581
17634
|
} catch (e) {
|
|
17582
|
-
|
|
17635
|
+
zm.warn("failed to remove listener", t, e);
|
|
17583
17636
|
}
|
|
17584
17637
|
this._trackedListeners.length = 0;
|
|
17585
17638
|
}
|
|
17586
17639
|
async init() {
|
|
17587
|
-
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,
|
|
17640
|
+
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, zm.debug("WebGPU path tracer app initialized"), this;
|
|
17588
17641
|
}
|
|
17589
17642
|
animate() {
|
|
17590
17643
|
if (!this._deviceLost) {
|
|
@@ -17594,7 +17647,7 @@ var wm = 4096, Tm = class {
|
|
|
17594
17647
|
}
|
|
17595
17648
|
if (this.cameraManager.controls && this.cameraManager.controls.update(), this.animationManager?.isPlaying && !this._animRefitInFlight) {
|
|
17596
17649
|
let e = this.animationManager.update();
|
|
17597
|
-
e && (this._animRefitInFlight = !0, this.refitBVH(e).catch((e) =>
|
|
17650
|
+
e && (this._animRefitInFlight = !0, this.refitBVH(e).catch((e) => zm.error("animation refit error:", e)).finally(() => {
|
|
17598
17651
|
this._animRefitInFlight = !1;
|
|
17599
17652
|
}));
|
|
17600
17653
|
}
|
|
@@ -17628,7 +17681,7 @@ var wm = 4096, Tm = class {
|
|
|
17628
17681
|
this.animationManagerId &&= (cancelAnimationFrame(this.animationManagerId), null);
|
|
17629
17682
|
}
|
|
17630
17683
|
_handleDeviceLost(e) {
|
|
17631
|
-
this._deviceLost || (this._deviceLost = !0,
|
|
17684
|
+
this._deviceLost || (this._deviceLost = !0, zm.error(`WebGPU device lost (${e?.reason || "unknown"}): ${e?.message || ""}`), this.stopAnimation(), this.dispatchEvent({
|
|
17632
17685
|
type: ur.DEVICE_LOST,
|
|
17633
17686
|
reason: e?.reason,
|
|
17634
17687
|
message: e?.message
|
|
@@ -17658,7 +17711,7 @@ var wm = 4096, Tm = class {
|
|
|
17658
17711
|
let e = Ae().value, t = k().value;
|
|
17659
17712
|
e?._listeners?.dispose && (e._listeners.dispose.length = 0), t?._listeners?.dispose && (t._listeners.dispose.length = 0);
|
|
17660
17713
|
} catch (e) {
|
|
17661
|
-
|
|
17714
|
+
zm.warn("failed to clear TSL texture singleton listeners", e);
|
|
17662
17715
|
}
|
|
17663
17716
|
br(this.renderer), this.renderer = null, this.stages = {}, this.isInitialized = !1;
|
|
17664
17717
|
}
|
|
@@ -17882,7 +17935,7 @@ var wm = 4096, Tm = class {
|
|
|
17882
17935
|
if (!e) return;
|
|
17883
17936
|
this._pendingReservedRenderSize = null;
|
|
17884
17937
|
let t = this.setReservedRenderResolution(e.requestedPx, { allowLower: e.allowLower });
|
|
17885
|
-
t < e.requestedPx &&
|
|
17938
|
+
t < e.requestedPx && zm.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({
|
|
17886
17939
|
type: "reserved_render_size_changed",
|
|
17887
17940
|
size: t
|
|
17888
17941
|
});
|
|
@@ -17891,7 +17944,7 @@ var wm = 4096, Tm = class {
|
|
|
17891
17944
|
return Dr;
|
|
17892
17945
|
}
|
|
17893
17946
|
_isRenderSizeSupported(e, t) {
|
|
17894
|
-
return e > Dr || t > Dr ? (
|
|
17947
|
+
return e > Dr || t > Dr ? (zm.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;
|
|
17895
17948
|
}
|
|
17896
17949
|
onResize() {
|
|
17897
17950
|
let e = this.canvas.clientWidth, t = this.canvas.clientHeight;
|
|
@@ -18075,7 +18128,7 @@ var wm = 4096, Tm = class {
|
|
|
18075
18128
|
this._pathTracerEnabled = e, e || this.precompileRaster();
|
|
18076
18129
|
}
|
|
18077
18130
|
precompileRaster() {
|
|
18078
|
-
return !this.renderer || !this.meshScene ? Promise.resolve() : (this._rasterPrecompile ??= this.renderer.compileAsync(this.meshScene, this.cameraManager.camera).catch((e) =>
|
|
18131
|
+
return !this.renderer || !this.meshScene ? Promise.resolve() : (this._rasterPrecompile ??= this.renderer.compileAsync(this.meshScene, this.cameraManager.camera).catch((e) => zm.warn("raster fallback precompile failed", e)), this._rasterPrecompile);
|
|
18079
18132
|
}
|
|
18080
18133
|
get isLoading() {
|
|
18081
18134
|
return this._loadingInProgress;
|
|
@@ -18182,7 +18235,7 @@ var wm = 4096, Tm = class {
|
|
|
18182
18235
|
let n = this.renderer.backend?.device;
|
|
18183
18236
|
n?.lost && (n.lost.then((e) => {
|
|
18184
18237
|
this._disposed || this._handleDeviceLost(e);
|
|
18185
|
-
}), n.onuncapturederror = (e) =>
|
|
18238
|
+
}), n.onuncapturederror = (e) => zm.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);
|
|
18186
18239
|
}
|
|
18187
18240
|
_initCameraManager() {
|
|
18188
18241
|
this.cameraManager = new Op(this.canvas);
|
|
@@ -18210,12 +18263,12 @@ var wm = 4096, Tm = class {
|
|
|
18210
18263
|
assetLoader: this.assetLoader,
|
|
18211
18264
|
pathTracer: null,
|
|
18212
18265
|
floorPlane: this.assetLoader.floorPlane
|
|
18213
|
-
}), 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
|
|
18266
|
+
}), 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 Im({
|
|
18214
18267
|
camera: this.cameraManager.camera,
|
|
18215
18268
|
canvas: this.canvas,
|
|
18216
18269
|
orbitControls: this.cameraManager.controls,
|
|
18217
18270
|
app: this
|
|
18218
|
-
}), this.overlayManager.register("transform", new
|
|
18271
|
+
}), this.overlayManager.register("transform", new Lm(this.transformManager)), this.interactionManager.setDependencies({
|
|
18219
18272
|
overlayManager: this.overlayManager,
|
|
18220
18273
|
transformManager: this.transformManager,
|
|
18221
18274
|
appDispatch: (e) => this.dispatchEvent(e),
|
|
@@ -18293,7 +18346,7 @@ var wm = 4096, Tm = class {
|
|
|
18293
18346
|
});
|
|
18294
18347
|
}
|
|
18295
18348
|
_setupDenoisingManager() {
|
|
18296
|
-
this.denoisingManager = new
|
|
18349
|
+
this.denoisingManager = new wm({
|
|
18297
18350
|
renderer: this.renderer,
|
|
18298
18351
|
mainCanvas: this.canvas,
|
|
18299
18352
|
scene: this.scene,
|
|
@@ -18336,7 +18389,7 @@ var wm = 4096, Tm = class {
|
|
|
18336
18389
|
this.scene.updateMatrixWorld(), this.overlayManager?.render();
|
|
18337
18390
|
}
|
|
18338
18391
|
async _setupOverlayManager() {
|
|
18339
|
-
this.overlayManager = new
|
|
18392
|
+
this.overlayManager = new Nm(this.cameraManager.camera), this.overlayManager.setupDefaultHelpers({
|
|
18340
18393
|
helperScene: this._sceneHelpers,
|
|
18341
18394
|
meshScene: this.meshScene,
|
|
18342
18395
|
pipeline: this.pipeline,
|
|
@@ -18367,7 +18420,7 @@ var wm = 4096, Tm = class {
|
|
|
18367
18420
|
_forwardEvents(e, t) {
|
|
18368
18421
|
if (e) for (let n of t) this._addTrackedListener(e, n, (e) => this.dispatchEvent(e));
|
|
18369
18422
|
}
|
|
18370
|
-
},
|
|
18423
|
+
}, Vm = class {
|
|
18371
18424
|
constructor(e) {
|
|
18372
18425
|
this._app = e, this._cancelled = !1, this._rendering = !1;
|
|
18373
18426
|
}
|
|
@@ -18465,4 +18518,4 @@ var wm = 4096, Tm = class {
|
|
|
18465
18518
|
}
|
|
18466
18519
|
};
|
|
18467
18520
|
//#endregion
|
|
18468
|
-
export { Pr as AF_DEFAULTS, kr as ASVGF_QUALITY_PRESETS, Nr as AUTO_FOCUS_MODES,
|
|
18521
|
+
export { Pr as AF_DEFAULTS, kr as ASVGF_QUALITY_PRESETS, Nr as AUTO_FOCUS_MODES, Pm as AnimationManager, Fr as BVH_LEAF_MARKERS, Mr as CAMERA_PRESETS, Ar as CAMERA_RANGES, Op as CameraManager, Br as DEFAULT_TEXTURE_MATRIX, wm 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, Nm as OverlayManager, Vr as PRODUCTION_RENDER_CONFIG, Bm 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, Im as TransformManager, uu as VRAMTracker, Vm 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 };
|