rayzee 11.2.0 → 11.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -33
- package/dist/ArchiveImporter-D735xX-4.js +7860 -0
- package/dist/BidirectionalIntegrator-M89c0AlP.js +954 -0
- package/dist/{BufferLayout-D_IBo2ci.js → BufferLayout-xPRH9jYD.js} +41 -5
- package/dist/{NeuralRetouch-DFGbnmLb.js → NeuralRetouch-DiBH63kz.js} +1 -1
- package/dist/{NeuralSuperRes-BtXvyJQl.js → NeuralSuperRes-CZNQP13W.js} +1 -1
- package/dist/{PathTracer-BHXGJtPN.js → PathTracer-BXCCVrPK.js} +4371 -4612
- package/dist/{PhysicalSky-DN6u8UX4.js → PhysicalSky-DqmaS0lb.js} +2 -2
- package/dist/{RayzeeRenderer-Dw1x8mVL.js → RayzeeRenderer-DUSMFhmc.js} +426 -363
- package/dist/SolarLimb-bZE6y63S.js +762 -0
- package/dist/addons/archives.es.js +1 -1
- package/dist/addons/bidirectional.es.js +1 -1
- package/dist/addons/physical-sky.es.js +1 -1
- package/dist/rayzee-core.es.js +7 -7
- package/dist/rayzee.es.js +472 -468
- package/dist/rayzee.umd.js +106 -105
- package/dist/sceneCachePolicy-BAib5fCp.js +1602 -0
- package/package.json +1 -1
- package/src/EngineDefaults.js +1 -1
- package/src/PathTracerApp.js +4 -3
- package/src/Processor/ArchiveImporter.js +173 -94
- package/src/Processor/ArchiveReader.js +20 -23
- package/src/Processor/AssetLoader.js +48 -1
- package/src/Processor/BVHRefitter.js +109 -13
- package/src/Processor/BufferLayout.js +115 -0
- package/src/Processor/ChunkedRecords.js +3 -2
- package/src/Processor/EmissiveTriangleBuilder.js +6 -6
- package/src/Processor/GeometryExtractor.js +189 -79
- package/src/Processor/HostMemory.js +39 -9
- package/src/Processor/InstanceTable.js +714 -42
- package/src/Processor/PBRT/PBRTCurves.js +224 -6
- package/src/Processor/PBRT/PBRTMaterials.js +3 -0
- package/src/Processor/PBRT/PBRTSceneBuilder.js +82 -25
- package/src/Processor/PackedRayBuffer.js +5 -2
- package/src/Processor/SceneProcessor.js +747 -141
- package/src/Processor/TLASBuilder.js +32 -17
- package/src/Processor/USD/USDLayer.js +1149 -0
- package/src/Processor/USD/USDScene.js +1655 -0
- package/src/Processor/USD/USDStage.js +682 -0
- package/src/Processor/USD/USDText.js +674 -0
- package/src/Processor/USD/index.js +138 -0
- package/src/Processor/Workers/BVHRefitWorker.js +3 -3
- package/src/RayzeeRenderer.js +168 -27
- package/src/Stages/NormalDepth.js +7 -12
- package/src/Stages/PathTracer.js +12 -17
- package/src/Stages/PathTracerStage.js +273 -96
- package/src/Storage/GeometrySpill.js +46 -14
- package/src/Storage/SceneGraphCodec.js +17 -3
- package/src/Storage/SpillStore.js +9 -0
- package/src/TSL/BVHTraversal.js +183 -7
- package/src/TSL/Common.js +57 -13
- package/src/TSL/ShadeKernel.js +3 -2
- package/src/TSL/TextureSampling.js +11 -8
- package/src/TSL/patches.js +84 -0
- package/src/integrators/BidirectionalIntegrator.js +20 -2
- package/src/managers/DenoisingManager.js +4 -4
- package/src/managers/InteractionManager.js +19 -6
- package/src/managers/MaterialDataManager.js +22 -5
- package/src/managers/UniformManager.js +3 -0
- package/dist/ArchiveImporter-eNlu0_6F.js +0 -5198
- package/dist/BidirectionalIntegrator-D1-6UySB.js +0 -946
- package/dist/SolarLimb-CPaeZVwz.js +0 -721
- package/dist/sceneCachePolicy-DA7iGoL4.js +0 -485
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { dt as e } from "./SolarLimb-
|
|
2
|
-
import {
|
|
3
|
-
import { n as
|
|
4
|
-
import {
|
|
5
|
-
import { i as
|
|
6
|
-
import {
|
|
7
|
-
import { i as
|
|
8
|
-
import { n as
|
|
9
|
-
import { a as
|
|
10
|
-
import { i as C, r as
|
|
11
|
-
import { n as T, r as
|
|
12
|
-
import { d as
|
|
13
|
-
import { i as D, n as
|
|
14
|
-
import { a as
|
|
15
|
-
import { t as
|
|
16
|
-
import { LinearSRGBColorSpace as
|
|
17
|
-
import { Fn as
|
|
18
|
-
import { Box3 as
|
|
19
|
-
import { RectAreaLightTexturesLib as
|
|
20
|
-
import { RectAreaLightHelper as
|
|
21
|
-
import { GLTFLoader as
|
|
22
|
-
import { HDRLoader as
|
|
23
|
-
import { createMeshesFromMultiMaterialMesh as
|
|
24
|
-
import { clone as
|
|
1
|
+
import { dt as e } from "./SolarLimb-bZE6y63S.js";
|
|
2
|
+
import { Dt as t, Ot as n, Tt as r, _t as i, ct as a, gt as o, kt as s, mt as c, n as l, ot as u, st as d, wt as f } from "./PathTracer-BXCCVrPK.js";
|
|
3
|
+
import { n as p, t as m } from "./EngineEvents-Ci8dVWCP.js";
|
|
4
|
+
import { $ as h, C as g, G as _, M as ee, Q as te, T as ne, W as re, at as v, d as ie, et as ae, f as oe, l as se, nt as ce, ot as le, r as ue, rt as de, tt as fe, u as pe, v as me, x as y } from "./sceneCachePolicy-BAib5fCp.js";
|
|
5
|
+
import { i as b, r as x } from "./Logger-dDDGj9Av.js";
|
|
6
|
+
import { f as he, r as ge } from "./BufferLayout-xPRH9jYD.js";
|
|
7
|
+
import { i as _e, n as S, t as ve } from "./EngineIssues-CIZnXHsF.js";
|
|
8
|
+
import { n as ye, r as be } from "./shared-BGBcSxBQ.js";
|
|
9
|
+
import { a as xe } from "./WorkingMatrix-C6y233hT.js";
|
|
10
|
+
import { i as C, r as Se, t as w } from "./ActiveColor-YvuQq44O.js";
|
|
11
|
+
import { n as T, r as Ce } from "./AssetConfig-DSEntE65.js";
|
|
12
|
+
import { d as we, l as Te, m as Ee, p as De, t as Oe, u as E } from "./ViewTransforms-CYN7bq2w.js";
|
|
13
|
+
import { i as D, n as ke, r as Ae } from "./identity-C1cLD1C0.js";
|
|
14
|
+
import { a as je, i as Me, t as Ne } from "./SceneMetadata-D2Sh-0e-.js";
|
|
15
|
+
import { t as Pe } from "./ToneMapGPU-BOjpul7A.js";
|
|
16
|
+
import { LinearSRGBColorSpace as Fe, MeshBasicNodeMaterial as Ie, NodeMaterial as Le, QuadMesh as Re, RectAreaLightNode as ze, SRGBColorSpace as O, TextureNode as Be, WebGPURenderer as Ve } from "three/webgpu";
|
|
17
|
+
import { Fn as He, If as Ue, cubeTexture as We, dot as Ge, float as k, int as A, ivec2 as Ke, mix as j, screenCoordinate as qe, select as M, storage as Je, texture as Ye, uint as Xe, uniform as N, uv as P, vec3 as F, vec4 as Ze } from "three/tsl";
|
|
18
|
+
import { Box3 as Qe, BufferGeometry as $e, CircleGeometry as et, Color as tt, DataTexture as nt, DirectionalLight as rt, DirectionalLightHelper as it, EquirectangularReflectionMapping as at, EventDispatcher as I, FloatType as ot, LinearFilter as st, LinearSRGBColorSpace as ct, LoaderUtils as L, LoadingManager as lt, MathUtils as R, Mesh as ut, MeshPhysicalMaterial as dt, NearestFilter as ft, NoBlending as pt, NoToneMapping as mt, Object3D as z, OrthographicCamera as ht, PerspectiveCamera as gt, PointLight as _t, PointLightHelper as vt, REVISION as yt, RGBAFormat as bt, RectAreaLight as B, RenderTarget as xt, SRGBColorSpace as V, Scene as H, SpotLight as St, SpotLightHelper as Ct, TextureLoader as wt, UnsignedByteType as Tt, Vector2 as Et, Vector3 as U } from "three";
|
|
19
|
+
import { RectAreaLightTexturesLib as Dt } from "three/addons/lights/RectAreaLightTexturesLib.js";
|
|
20
|
+
import { RectAreaLightHelper as Ot } from "three/addons/helpers/RectAreaLightHelper.js";
|
|
21
|
+
import { GLTFLoader as kt } from "three/addons/loaders/GLTFLoader.js";
|
|
22
|
+
import { HDRLoader as At } from "three/addons/loaders/HDRLoader.js";
|
|
23
|
+
import { createMeshesFromMultiMaterialMesh as jt } from "three/addons/utils/SceneUtils.js";
|
|
24
|
+
import { clone as Mt } from "three/addons/utils/SkeletonUtils.js";
|
|
25
25
|
//#region src/SceneHelpers.js
|
|
26
|
-
var
|
|
26
|
+
var Nt = class {
|
|
27
27
|
constructor() {
|
|
28
28
|
this.scene = new H(), this._helpers = /* @__PURE__ */ new Map(), this.visible = !1;
|
|
29
29
|
}
|
|
@@ -63,16 +63,16 @@ var jt = class {
|
|
|
63
63
|
this.clear();
|
|
64
64
|
}
|
|
65
65
|
_createHelper(e) {
|
|
66
|
-
return e.isRectAreaLight ? new
|
|
66
|
+
return e.isRectAreaLight ? new Ot(e) : e.isPointLight ? new vt(e, .5) : e.isSpotLight ? new Ct(e) : e.isDirectionalLight ? new it(e, .5) : null;
|
|
67
67
|
}
|
|
68
|
-
},
|
|
68
|
+
}, Pt = class extends n {
|
|
69
69
|
constructor(t, n = {}) {
|
|
70
70
|
super("Compositor", {
|
|
71
71
|
...n,
|
|
72
|
-
executionMode:
|
|
73
|
-
}), this.renderer = t, this._lightSources = [...n.displaySources ?? [], "pathtracer:color"], this.saturation =
|
|
74
|
-
let
|
|
75
|
-
this.compositorMaterial = new
|
|
72
|
+
executionMode: s.ALWAYS
|
|
73
|
+
}), this.renderer = t, this._lightSources = [...n.displaySources ?? [], "pathtracer:color"], this.saturation = N(n.saturation ?? 1), this._transparentBackground = N(0, "int"), this._pathTracer = n.pathTracer ?? null, this._convergenceOverlay = !1, this._debugMaterial = null, this._debugQuad = null, this._debugTexNode = null, this._debugM2Attr = null, this._debugMaskAttr = null, this._debugExposureComp = N(1), this._sourceTexNode = new Be();
|
|
74
|
+
let r = this._sourceTexNode.sample(P()), i = j(F(Ge(r.xyz, e)), r.xyz, this.saturation), a = M(this._transparentBackground, r.w, 1);
|
|
75
|
+
this.compositorMaterial = new Ie(), this.compositorMaterial.colorNode = Ze(i, a), this.compositorMaterial.blending = pt, this.compositorQuad = new Re(this.compositorMaterial);
|
|
76
76
|
}
|
|
77
77
|
resolveLightTexture(e) {
|
|
78
78
|
return this.resolveLightSource(e)?.texture ?? null;
|
|
@@ -91,17 +91,17 @@ var jt = class {
|
|
|
91
91
|
let t = this._pathTracer?.getConvergenceDebugSource?.();
|
|
92
92
|
if (!t) return !1;
|
|
93
93
|
if (this._debugMaterial && this._debugM2Attr === t.m2 && this._debugMaskAttr === t.frozenMask) return !0;
|
|
94
|
-
this._debugMaterial?.dispose(), this._debugTexNode?.dispose(), this._debugM2Attr = t.m2, this._debugMaskAttr = t.frozenMask, this._debugTexNode = new
|
|
95
|
-
let n =
|
|
96
|
-
let n =
|
|
97
|
-
return
|
|
98
|
-
let e =
|
|
99
|
-
g.assign(
|
|
100
|
-
}),
|
|
101
|
-
g.assign(
|
|
94
|
+
this._debugMaterial?.dispose(), this._debugTexNode?.dispose(), this._debugM2Attr = t.m2, this._debugMaskAttr = t.frozenMask, this._debugTexNode = new Be();
|
|
95
|
+
let n = He(() => {
|
|
96
|
+
let n = Ge(this._debugTexNode.sample(P()).toVar().xyz, e).toVar(), r = t.renderWidth, i = t.renderHeight, a = A(P().x.mul(k(r))).min(r.sub(A(1))).max(A(0)), o = Xe(A(P().y.mul(k(i))).min(i.sub(A(1))).max(A(0)).mul(r).add(a)).toVar(), s = Je(t.m2, "float").toReadOnly().element(o).toVar(), c = Je(t.frozenMask, "uint").toReadOnly().element(o).toVar(), l = s.sub(n.mul(n)).max(k(0)).div(k(t.frame).add(1)).sqrt().toVar(), u = t.usePixelFreeze.greaterThan(A(0)), d = M(n.lessThan(k(1)), n.sqrt(), n).toVar(), f = M(u, l.div(n.add(k(1e-4))), l.div(d.add(k(1e-4)))).toVar(), p = M(u, t.pixelFreezeThreshold, t.noiseThreshold).toVar(), m = f.div(p.max(k(1e-6))).toVar(), h = F(n.div(n.add(k(1))).sqrt().mul(.55)).toVar(), g = h.toVar(), _ = k(t.frame).greaterThanEqual(k(t.adaptiveMinSamples));
|
|
97
|
+
return Ue(m.greaterThanEqual(k(1)).or(_.not()), () => {
|
|
98
|
+
let e = j(F(1, .8, .1), F(1, .1, .05), m.sub(1).div(3).clamp(0, 1));
|
|
99
|
+
g.assign(j(h, e, .85));
|
|
100
|
+
}), Ue(c.equal(Xe(1)).and(u), () => {
|
|
101
|
+
g.assign(j(h, F(.1, .45, 1), .55));
|
|
102
102
|
}), g;
|
|
103
103
|
});
|
|
104
|
-
return this._debugMaterial = new
|
|
104
|
+
return this._debugMaterial = new Ie(), this._debugMaterial.colorNode = Ze(n().pow(2.2).mul(this._debugExposureComp), 1), this._debugMaterial.blending = pt, this._debugQuad = new Re(this._debugMaterial), !0;
|
|
105
105
|
}
|
|
106
106
|
render(e) {
|
|
107
107
|
if (!this.enabled) return;
|
|
@@ -109,7 +109,7 @@ var jt = class {
|
|
|
109
109
|
let t = e.getTexture("pathtracer:color");
|
|
110
110
|
if (t) {
|
|
111
111
|
this._debugTexNode.value = t;
|
|
112
|
-
let e = this.renderer.toneMapping !==
|
|
112
|
+
let e = this.renderer.toneMapping !== mt;
|
|
113
113
|
this._debugExposureComp.value = e ? 1 / Math.max(this.renderer.toneMappingExposure, 1e-4) : 1, this.renderer.setRenderTarget(null), this._debugQuad.render(this.renderer);
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
@@ -129,7 +129,7 @@ var jt = class {
|
|
|
129
129
|
dispose() {
|
|
130
130
|
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;
|
|
131
131
|
}
|
|
132
|
-
},
|
|
132
|
+
}, Ft = class {
|
|
133
133
|
constructor() {
|
|
134
134
|
this.textures = /* @__PURE__ */ new Map(), this.renderTargets = /* @__PURE__ */ new Map(), this.uniforms = /* @__PURE__ */ new Map(), this.state = {
|
|
135
135
|
frame: 0,
|
|
@@ -249,7 +249,7 @@ var jt = class {
|
|
|
249
249
|
dispose() {
|
|
250
250
|
this.textures.clear(), this.renderTargets.clear(), this.uniforms.clear(), this._stateChangeCallbacks.clear(), this.state = {};
|
|
251
251
|
}
|
|
252
|
-
},
|
|
252
|
+
}, It = class extends I {
|
|
253
253
|
constructor() {
|
|
254
254
|
super(), this._onceCallbacks = /* @__PURE__ */ new Map();
|
|
255
255
|
}
|
|
@@ -287,38 +287,38 @@ var jt = class {
|
|
|
287
287
|
eventNames() {
|
|
288
288
|
return this._listeners ? Object.keys(this._listeners) : [];
|
|
289
289
|
}
|
|
290
|
-
},
|
|
291
|
-
function
|
|
292
|
-
|
|
290
|
+
}, Lt = !1, W = [], Rt = /* @__PURE__ */ new WeakMap();
|
|
291
|
+
function zt(e) {
|
|
292
|
+
Lt = !!e;
|
|
293
293
|
}
|
|
294
|
-
function
|
|
294
|
+
function Bt() {
|
|
295
295
|
return W.slice();
|
|
296
296
|
}
|
|
297
|
-
function
|
|
297
|
+
function Vt() {
|
|
298
298
|
W.length = 0;
|
|
299
299
|
}
|
|
300
|
-
function
|
|
300
|
+
function Ht(e) {
|
|
301
301
|
let t = [];
|
|
302
302
|
for (let n of Object.keys(e)) e[n]?.isTextureNode === !0 && t.push(n);
|
|
303
303
|
return t;
|
|
304
304
|
}
|
|
305
|
-
var
|
|
306
|
-
function
|
|
307
|
-
if (!
|
|
305
|
+
var Ut = (e) => !e || !e.image || !(e.image.width > 0);
|
|
306
|
+
function Wt(e, t, n) {
|
|
307
|
+
if (!Lt) {
|
|
308
308
|
n();
|
|
309
309
|
return;
|
|
310
310
|
}
|
|
311
|
-
let r =
|
|
311
|
+
let r = Rt.get(e);
|
|
312
312
|
if (r || (r = {
|
|
313
313
|
phase: "pending",
|
|
314
314
|
unboundAtCompile: []
|
|
315
|
-
},
|
|
316
|
-
n(), r.phase === "watch" &&
|
|
315
|
+
}, Rt.set(e, r)), r.phase !== "pending") {
|
|
316
|
+
n(), r.phase === "watch" && Gt(e, r);
|
|
317
317
|
return;
|
|
318
318
|
}
|
|
319
319
|
let i = Object.prototype.hasOwnProperty.call(t, "compute"), a = t.compute;
|
|
320
320
|
t.compute = function(...t) {
|
|
321
|
-
return r.phase === "pending" && (r.unboundAtCompile =
|
|
321
|
+
return r.phase === "pending" && (r.unboundAtCompile = Ht(e).filter((t) => Ut(e[t].value)), r.phase = r.unboundAtCompile.length < 2 ? "done" : "watch"), a.apply(this, t);
|
|
322
322
|
};
|
|
323
323
|
try {
|
|
324
324
|
n();
|
|
@@ -326,11 +326,11 @@ function Ht(e, t, n) {
|
|
|
326
326
|
i ? t.compute = a : delete t.compute;
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
|
-
function
|
|
329
|
+
function Gt(e, t) {
|
|
330
330
|
let n = [];
|
|
331
331
|
for (let r of t.unboundAtCompile) {
|
|
332
332
|
let t = e[r]?.value;
|
|
333
|
-
if (
|
|
333
|
+
if (Ut(t)) return;
|
|
334
334
|
t.isStorageTexture !== !0 && n.push(r);
|
|
335
335
|
}
|
|
336
336
|
t.phase = "done", n.length !== 0 && W.push({
|
|
@@ -342,7 +342,7 @@ function Ut(e, t) {
|
|
|
342
342
|
}
|
|
343
343
|
//#endregion
|
|
344
344
|
//#region src/Pipeline/RenderPipeline.js
|
|
345
|
-
var
|
|
345
|
+
var Kt = class {
|
|
346
346
|
_reportStageFailure(e, t, n) {
|
|
347
347
|
console.error(`[Pipeline] Error in stage '${e}' (${t}):`, n);
|
|
348
348
|
let r = `${e}:${t}`;
|
|
@@ -353,7 +353,7 @@ var Wt = class {
|
|
|
353
353
|
}));
|
|
354
354
|
}
|
|
355
355
|
constructor(e, t, n, { issues: r = null } = {}) {
|
|
356
|
-
this.renderer = e, this._issues = r, this._reportedStageFailures = /* @__PURE__ */ new Set(), this.width = t, this.height = n, this.stages = [], this.context = new
|
|
356
|
+
this.renderer = e, this._issues = r, this._reportedStageFailures = /* @__PURE__ */ new Set(), this.width = t, this.height = n, this.stages = [], this.context = new Ft(), this.eventBus = new It(), this.context.setState("width", t), this.context.setState("height", n), this.stats = {
|
|
357
357
|
enabled: !1,
|
|
358
358
|
logSkipped: !1,
|
|
359
359
|
timings: /* @__PURE__ */ new Map(),
|
|
@@ -387,7 +387,7 @@ var Wt = class {
|
|
|
387
387
|
}
|
|
388
388
|
try {
|
|
389
389
|
let n = this.stats.enabled ? performance.now() : 0;
|
|
390
|
-
if (
|
|
390
|
+
if (Wt(t, this.renderer, () => t.render(this.context, e)), this.stats.enabled) {
|
|
391
391
|
let e = performance.now() - n;
|
|
392
392
|
this.stats.timings.has(t.name) || this.stats.timings.set(t.name, []);
|
|
393
393
|
let r = this.stats.timings.get(t.name);
|
|
@@ -485,7 +485,7 @@ var Wt = class {
|
|
|
485
485
|
let e = this.getInfo();
|
|
486
486
|
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();
|
|
487
487
|
}
|
|
488
|
-
},
|
|
488
|
+
}, qt = x("engine"), Jt = class {
|
|
489
489
|
constructor() {
|
|
490
490
|
this.timeElapsed = 0, this.lastResetTime = performance.now(), this.renderCompleteDispatched = !1, this.budgetOverrun = !1, this._budgetHeldWarned = !1;
|
|
491
491
|
}
|
|
@@ -493,7 +493,7 @@ var Wt = class {
|
|
|
493
493
|
this.timeElapsed = (performance.now() - this.lastResetTime) / 1e3;
|
|
494
494
|
}
|
|
495
495
|
isTimeLimitReached(e, t, n) {
|
|
496
|
-
return t !== "time" || !(n > 0) || this.timeElapsed < n ? !1 : e?.frameCount > 0 ? (this.budgetOverrun = !0, !0) : (this._budgetHeldWarned || (this._budgetHeldWarned = !0,
|
|
496
|
+
return t !== "time" || !(n > 0) || this.timeElapsed < n ? !1 : e?.frameCount > 0 ? (this.budgetOverrun = !0, !0) : (this._budgetHeldWarned || (this._budgetHeldWarned = !0, qt.warn(`render time limit (${n}s) expired before the first sample landed — holding the deadline open to avoid capturing an empty frame`)), !1);
|
|
497
497
|
}
|
|
498
498
|
isLimitReached(e, t, n) {
|
|
499
499
|
return e ? this.isTimeLimitReached(e, t, n) ? !0 : this.stopCondition(e) !== null : !1;
|
|
@@ -510,17 +510,17 @@ var Wt = class {
|
|
|
510
510
|
resumeFromPause() {
|
|
511
511
|
this.renderCompleteDispatched = !1, this.lastResetTime = performance.now() - this.timeElapsed * 1e3;
|
|
512
512
|
}
|
|
513
|
-
},
|
|
513
|
+
}, Yt = class {
|
|
514
514
|
constructor(e) {
|
|
515
|
-
this.renderer = e, this.target = null, this.material = new
|
|
515
|
+
this.renderer = e, this.target = null, this.material = new Le(), this.material.name = "rayzee:texture-readback", this.quad = new Re(this.material), this._node = null, this._source = null;
|
|
516
516
|
}
|
|
517
517
|
_ensureTarget(e, t) {
|
|
518
|
-
this.target && this.target.width === e && this.target.height === t || (this.target?.dispose(), this.target = new
|
|
519
|
-
type:
|
|
520
|
-
format:
|
|
518
|
+
this.target && this.target.width === e && this.target.height === t || (this.target?.dispose(), this.target = new xt(e, t, {
|
|
519
|
+
type: ot,
|
|
520
|
+
format: bt,
|
|
521
521
|
depthBuffer: !1,
|
|
522
|
-
minFilter:
|
|
523
|
-
magFilter:
|
|
522
|
+
minFilter: ft,
|
|
523
|
+
magFilter: ft
|
|
524
524
|
}));
|
|
525
525
|
}
|
|
526
526
|
async read(e, t, n) {
|
|
@@ -531,7 +531,7 @@ var Wt = class {
|
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
533
|
draw(e, t, n) {
|
|
534
|
-
this._ensureTarget(t, n), this._source !== e && (this._node =
|
|
534
|
+
this._ensureTarget(t, n), this._source !== e && (this._node = Ye(e).load(Ke(qe.xy)), this.material.outputNode = this._node, this.material.needsUpdate = !0, this._source = e);
|
|
535
535
|
let r = this.renderer.getRenderTarget();
|
|
536
536
|
return this.renderer.setRenderTarget(this.target), this.quad.render(this.renderer), this.renderer.setRenderTarget(r), this.target;
|
|
537
537
|
}
|
|
@@ -541,15 +541,15 @@ var Wt = class {
|
|
|
541
541
|
dispose() {
|
|
542
542
|
this.target?.dispose(), this.material.dispose(), this.target = null, this._source = null, this._node = null;
|
|
543
543
|
}
|
|
544
|
-
},
|
|
544
|
+
}, Xt = 864e5, G = Object.freeze({
|
|
545
545
|
IMMUTABLE: "immutable",
|
|
546
546
|
REVALIDATE: "revalidate",
|
|
547
547
|
NETWORK: "network"
|
|
548
|
-
}),
|
|
548
|
+
}), Zt = (e, t) => ({
|
|
549
549
|
loaded: e,
|
|
550
550
|
total: t,
|
|
551
551
|
lengthComputable: t > 0 && e <= t
|
|
552
|
-
}), K = (e, t) => e.headers?.get?.(t) ?? null,
|
|
552
|
+
}), K = (e, t) => e.headers?.get?.(t) ?? null, Qt = (e) => e.reason ?? new DOMException("aborted", "AbortError");
|
|
553
553
|
function q(e) {
|
|
554
554
|
try {
|
|
555
555
|
let t = new URL(e, globalThis.location?.href ?? "http://localhost/").pathname;
|
|
@@ -558,36 +558,36 @@ function q(e) {
|
|
|
558
558
|
return "download";
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
|
-
async function
|
|
561
|
+
async function $t(e, { onProgress: t, signal: n }) {
|
|
562
562
|
let r = Number(K(e, "content-length")) || 0, i = K(e, "content-type") ?? "";
|
|
563
563
|
if (!e.body) return new Blob([await e.arrayBuffer()], { type: i });
|
|
564
564
|
let a = e.body.getReader(), o = [], s = 0;
|
|
565
565
|
for (;;) {
|
|
566
|
-
if (n?.aborted) throw a.cancel().catch(() => {}),
|
|
566
|
+
if (n?.aborted) throw a.cancel().catch(() => {}), Qt(n);
|
|
567
567
|
let { done: e, value: i } = await a.read();
|
|
568
568
|
if (e) break;
|
|
569
|
-
o.push(i), s += i.length, t?.(
|
|
569
|
+
o.push(i), s += i.length, t?.(Zt(s, r));
|
|
570
570
|
}
|
|
571
571
|
return new Blob(o, { type: i });
|
|
572
572
|
}
|
|
573
|
-
var
|
|
573
|
+
var en = (e, t, n) => new File([e], t, {
|
|
574
574
|
type: n || e.type,
|
|
575
575
|
lastModified: e.lastModified ?? Date.now()
|
|
576
|
-
}),
|
|
576
|
+
}), tn = () => {}, J = class {
|
|
577
577
|
constructor(e) {
|
|
578
578
|
this._storage = e, this._revalidating = /* @__PURE__ */ new Set();
|
|
579
579
|
}
|
|
580
580
|
get _area() {
|
|
581
|
-
return this._storage?.area(
|
|
581
|
+
return this._storage?.area(be.DOWNLOADS) ?? null;
|
|
582
582
|
}
|
|
583
|
-
async fetch(e, { key: t = e, name: n = q(e), policy: r = G.REVALIDATE, maxAgeMs: i =
|
|
583
|
+
async fetch(e, { key: t = e, name: n = q(e), policy: r = G.REVALIDATE, maxAgeMs: i = Xt, onProgress: a = null, signal: o = null, fetchOptions: s = {} } = {}) {
|
|
584
584
|
let c = this._area;
|
|
585
585
|
if (c && r !== G.NETWORK) {
|
|
586
586
|
let o = await c.open(t);
|
|
587
587
|
if (o) {
|
|
588
588
|
let c = await o.file("data");
|
|
589
|
-
if (c) return r === G.REVALIDATE && Date.now() - (o.extra.checkedAt ?? 0) >= i && this._revalidate(e, t, n, o.extra, s), a?.(
|
|
590
|
-
file:
|
|
589
|
+
if (c) return r === G.REVALIDATE && Date.now() - (o.extra.checkedAt ?? 0) >= i && this._revalidate(e, t, n, o.extra, s), a?.(Zt(c.size, c.size)), {
|
|
590
|
+
file: en(c, n, o.extra.contentType),
|
|
591
591
|
release: () => o.release(),
|
|
592
592
|
fromCache: !0
|
|
593
593
|
};
|
|
@@ -605,7 +605,7 @@ var Qt = (e, t, n) => new File([e], t, {
|
|
|
605
605
|
return await this._area?.has(e) === !0;
|
|
606
606
|
}
|
|
607
607
|
async _download(e, t, n, { onProgress: r, signal: i, fetchOptions: a, cache: o }) {
|
|
608
|
-
if (i?.aborted) throw
|
|
608
|
+
if (i?.aborted) throw Qt(i);
|
|
609
609
|
let s = await fetch(e, {
|
|
610
610
|
...a,
|
|
611
611
|
signal: i
|
|
@@ -622,17 +622,17 @@ var Qt = (e, t, n) => new File([e], t, {
|
|
|
622
622
|
expectedBytes: c
|
|
623
623
|
}) : null;
|
|
624
624
|
if (!u) return {
|
|
625
|
-
file:
|
|
625
|
+
file: en(await $t(s, {
|
|
626
626
|
onProgress: r,
|
|
627
627
|
signal: i
|
|
628
628
|
}), n, l.contentType),
|
|
629
|
-
release:
|
|
629
|
+
release: tn,
|
|
630
630
|
fromCache: !1
|
|
631
631
|
};
|
|
632
632
|
try {
|
|
633
633
|
await u.writeStream("data", s.body, {
|
|
634
634
|
signal: i,
|
|
635
|
-
onProgress: (e) => r?.(
|
|
635
|
+
onProgress: (e) => r?.(Zt(e, c))
|
|
636
636
|
}), await u.commit(l);
|
|
637
637
|
} catch (o) {
|
|
638
638
|
if (await u.abort(), o?.name !== "QuotaExceededError") throw o;
|
|
@@ -646,7 +646,7 @@ var Qt = (e, t, n) => new File([e], t, {
|
|
|
646
646
|
let d = await this._area.open(t, { wait: !0 }), f = d && await d.file("data");
|
|
647
647
|
if (!f) throw d?.release(), Error(`storage: ${n} vanished right after it was saved`);
|
|
648
648
|
return {
|
|
649
|
-
file:
|
|
649
|
+
file: en(f, n, l.contentType),
|
|
650
650
|
release: () => d.release(),
|
|
651
651
|
fromCache: !1
|
|
652
652
|
};
|
|
@@ -683,16 +683,16 @@ var Qt = (e, t, n) => new File([e], t, {
|
|
|
683
683
|
}
|
|
684
684
|
}
|
|
685
685
|
};
|
|
686
|
-
function
|
|
686
|
+
function nn(e, t, n) {
|
|
687
687
|
return new J(t).fetch(e, n);
|
|
688
688
|
}
|
|
689
|
-
function
|
|
690
|
-
return new J(
|
|
689
|
+
function rn() {
|
|
690
|
+
return new J(ye(T().cacheNamespace));
|
|
691
691
|
}
|
|
692
|
-
async function
|
|
692
|
+
async function an(e, { downloads: t = rn(), ...n } = {}) {
|
|
693
693
|
if (!t._storage || !/^https?:/i.test(e)) return {
|
|
694
694
|
url: e,
|
|
695
|
-
release:
|
|
695
|
+
release: tn,
|
|
696
696
|
cached: !1
|
|
697
697
|
};
|
|
698
698
|
let { file: r, release: i } = await t.fetch(e, n), a = URL.createObjectURL(r);
|
|
@@ -706,7 +706,7 @@ async function nn(e, { downloads: t = tn(), ...n } = {}) {
|
|
|
706
706
|
}
|
|
707
707
|
//#endregion
|
|
708
708
|
//#region src/RenderSettings.js
|
|
709
|
-
var
|
|
709
|
+
var on = {
|
|
710
710
|
maxBounces: {
|
|
711
711
|
uniform: "maxBounces",
|
|
712
712
|
reset: !0
|
|
@@ -932,9 +932,9 @@ var rn = {
|
|
|
932
932
|
HOST: "host",
|
|
933
933
|
SCENE_METADATA: "scene-metadata",
|
|
934
934
|
MODE_PRESET: "mode-preset"
|
|
935
|
-
}),
|
|
936
|
-
constructor(e =
|
|
937
|
-
super(), this._issues = t, this._defaults = e, this._routes = new Map(Object.entries(
|
|
935
|
+
}), sn = class extends I {
|
|
936
|
+
constructor(e = _, { issues: t = null } = {}) {
|
|
937
|
+
super(), this._issues = t, this._defaults = e, this._routes = new Map(Object.entries(on)), this._values = /* @__PURE__ */ new Map(), this._sources = /* @__PURE__ */ new Map(), this._pathTracer = null, this._resetCallback = null, this._handlers = {}, this._initDefaults(e);
|
|
938
938
|
}
|
|
939
939
|
bind(e) {
|
|
940
940
|
this._pathTracer = e.stages.pathTracer, this._resetCallback = e.resetCallback, this._handlers = this._buildHandlers(e);
|
|
@@ -949,12 +949,12 @@ var rn = {
|
|
|
949
949
|
!this._values.has(e) && i !== void 0 && (this._values.set(e, i), this._sources.set(e, Y.DEFAULT));
|
|
950
950
|
}
|
|
951
951
|
_buildHandlers({ stages: e, resetCallback: t, reconcileCompletion: n, applyExposure: r, onCameraProjection: i }) {
|
|
952
|
-
let a = new
|
|
952
|
+
let a = new Et(), o = (t, n) => {
|
|
953
953
|
a.set(n?.[0] ?? 0, n?.[1] ?? 0).multiplyScalar(R.DEG2RAD), e.pathTracer?.setUniform(t, a);
|
|
954
954
|
};
|
|
955
955
|
return {
|
|
956
956
|
handleCameraProjection: (t) => {
|
|
957
|
-
e.pathTracer?.setUniform("cameraProjection",
|
|
957
|
+
e.pathTracer?.setUniform("cameraProjection", re[t] ?? re.perspective), i?.(t);
|
|
958
958
|
},
|
|
959
959
|
handleDofMode: (t) => e.pathTracer?.setUniform("dofMode", +(t === "look")),
|
|
960
960
|
handlePanoramaLonRange: (e) => o("panoLonRange", e),
|
|
@@ -963,7 +963,7 @@ var rn = {
|
|
|
963
963
|
e.pathTracer?.setUniform("transparentBackground", t), e.compositor?.setTransparentBackground(t);
|
|
964
964
|
},
|
|
965
965
|
handleBackgroundColor: (t) => {
|
|
966
|
-
let n = t?.isColor ? t : new
|
|
966
|
+
let n = t?.isColor ? t : new tt(t);
|
|
967
967
|
e.pathTracer?.setUniform("backgroundColor", n);
|
|
968
968
|
},
|
|
969
969
|
handleExposure: (e) => {
|
|
@@ -1007,7 +1007,7 @@ var rn = {
|
|
|
1007
1007
|
set(e, t, { reset: n, silent: r, source: i = Y.HOST } = {}) {
|
|
1008
1008
|
let a = this._applyOne(e, t, i);
|
|
1009
1009
|
a?.route && ((n === void 0 ? a.route.reset ?? !0 : n) && this._resetCallback?.(), r || this.dispatchEvent({
|
|
1010
|
-
type:
|
|
1010
|
+
type: m.SETTING_CHANGED,
|
|
1011
1011
|
key: e,
|
|
1012
1012
|
value: t,
|
|
1013
1013
|
prev: a.prev
|
|
@@ -1018,7 +1018,7 @@ var rn = {
|
|
|
1018
1018
|
for (let [n, a] of Object.entries(e)) {
|
|
1019
1019
|
let e = this._applyOne(n, a, r);
|
|
1020
1020
|
e?.route && ((e.route.reset ?? !0) && (i = !0), t || this.dispatchEvent({
|
|
1021
|
-
type:
|
|
1021
|
+
type: m.SETTING_CHANGED,
|
|
1022
1022
|
key: n,
|
|
1023
1023
|
value: a,
|
|
1024
1024
|
prev: e.prev
|
|
@@ -1061,14 +1061,14 @@ var rn = {
|
|
|
1061
1061
|
let e = {};
|
|
1062
1062
|
for (let [t, n] of this._values) {
|
|
1063
1063
|
if (this._sources.get(t) !== Y.HOST || !this._routes.has(t)) continue;
|
|
1064
|
-
let r =
|
|
1064
|
+
let r = i(n);
|
|
1065
1065
|
r !== void 0 && (e[t] = r);
|
|
1066
1066
|
}
|
|
1067
1067
|
return e;
|
|
1068
1068
|
}
|
|
1069
1069
|
restore(e) {
|
|
1070
1070
|
let t = {}, n = [];
|
|
1071
|
-
for (let [r, i] of Object.entries(e ?? {})) this._routes.has(r) ? t[r] =
|
|
1071
|
+
for (let [r, i] of Object.entries(e ?? {})) this._routes.has(r) ? t[r] = o(i) : n.push(r);
|
|
1072
1072
|
return this.setMany(t), n;
|
|
1073
1073
|
}
|
|
1074
1074
|
applyAll() {
|
|
@@ -1081,12 +1081,12 @@ var rn = {
|
|
|
1081
1081
|
e.uniform ? this._pathTracer?.setUniform(e.uniform, t) : e.handler ? this._handlers[e.handler]?.(t, n) : e.apply?.(t, n);
|
|
1082
1082
|
}
|
|
1083
1083
|
_initDefaults(e) {
|
|
1084
|
-
for (let t of Object.keys(
|
|
1084
|
+
for (let t of Object.keys(on)) t in e && (this._values.set(t, e[t]), this._sources.set(t, Y.DEFAULT));
|
|
1085
1085
|
}
|
|
1086
|
-
},
|
|
1086
|
+
}, cn = class {
|
|
1087
1087
|
constructor({ issues: e = null } = {}) {
|
|
1088
|
-
this._issues = e, this._renderer = null, this._offRegistry =
|
|
1089
|
-
this._renderer &&
|
|
1088
|
+
this._issues = e, this._renderer = null, this._offRegistry = De(() => {
|
|
1089
|
+
this._renderer && Ee(this._renderer);
|
|
1090
1090
|
});
|
|
1091
1091
|
}
|
|
1092
1092
|
get hasConfig() {
|
|
@@ -1103,11 +1103,11 @@ var rn = {
|
|
|
1103
1103
|
}
|
|
1104
1104
|
attachRenderer(e) {
|
|
1105
1105
|
this._renderer = e;
|
|
1106
|
-
let t =
|
|
1106
|
+
let t = Ee(e);
|
|
1107
1107
|
return e.outputColorSpace = V, t;
|
|
1108
1108
|
}
|
|
1109
1109
|
listViews() {
|
|
1110
|
-
return
|
|
1110
|
+
return we();
|
|
1111
1111
|
}
|
|
1112
1112
|
get activeView() {
|
|
1113
1113
|
return null;
|
|
@@ -1119,7 +1119,7 @@ var rn = {
|
|
|
1119
1119
|
return this._renderer && (this._renderer.toneMapping = e), t;
|
|
1120
1120
|
}
|
|
1121
1121
|
_publishWorkingMatrix() {
|
|
1122
|
-
|
|
1122
|
+
xe(null, w);
|
|
1123
1123
|
}
|
|
1124
1124
|
loadConfig() {
|
|
1125
1125
|
let e = "colour configs need the OCIO pipeline: renderer.setColorManagement( ColorManagement ), from rayzee/addons/color";
|
|
@@ -1147,23 +1147,23 @@ var rn = {
|
|
|
1147
1147
|
activeView: null,
|
|
1148
1148
|
context: null,
|
|
1149
1149
|
exportSpace: null,
|
|
1150
|
-
views:
|
|
1151
|
-
registryVersion:
|
|
1150
|
+
views: we(),
|
|
1151
|
+
registryVersion: Te(),
|
|
1152
1152
|
bakeError: e?.error ?? null
|
|
1153
1153
|
};
|
|
1154
1154
|
}
|
|
1155
1155
|
dispose() {
|
|
1156
|
-
this._offRegistry?.(), this._renderer = null, this._issues = null,
|
|
1156
|
+
this._offRegistry?.(), this._renderer = null, this._issues = null, Se() === this && (xe(null), C(null));
|
|
1157
1157
|
}
|
|
1158
|
-
},
|
|
1158
|
+
}, ln = [
|
|
1159
1159
|
[/\.jpe?g(\?|#|$)/i, "image/jpeg"],
|
|
1160
1160
|
[/\.webp(\?|#|$)/i, "image/webp"],
|
|
1161
1161
|
[/\.avif(\?|#|$)/i, "image/avif"]
|
|
1162
1162
|
];
|
|
1163
|
-
function
|
|
1164
|
-
return e.mimeType ? e.mimeType : e.uri?.startsWith("data:") ? e.uri.slice(5, e.uri.indexOf(";")) :
|
|
1163
|
+
function un(e) {
|
|
1164
|
+
return e.mimeType ? e.mimeType : e.uri?.startsWith("data:") ? e.uri.slice(5, e.uri.indexOf(";")) : ln.find(([t]) => t.test(e.uri ?? ""))?.[1] ?? "image/png";
|
|
1165
1165
|
}
|
|
1166
|
-
function
|
|
1166
|
+
function dn(e) {
|
|
1167
1167
|
for (let t = 8; t + 12 <= e.length;) {
|
|
1168
1168
|
let n = (e[t] << 24 | e[t + 1] << 16 | e[t + 2] << 8 | e[t + 3]) >>> 0, r = t + 12 + n;
|
|
1169
1169
|
if (e[t + 4] === 73 && e[t + 5] === 69 && e[t + 6] === 78 && e[t + 7] === 68) return e.subarray(0, r);
|
|
@@ -1171,48 +1171,48 @@ function ln(e) {
|
|
|
1171
1171
|
}
|
|
1172
1172
|
return e;
|
|
1173
1173
|
}
|
|
1174
|
-
function
|
|
1174
|
+
function fn({ data: e, width: t, height: n }, { shared: r = !1 } = {}) {
|
|
1175
1175
|
let i = new Uint8Array(e.buffer, e.byteOffset, t * n * 4), a = i;
|
|
1176
1176
|
r && typeof SharedArrayBuffer < "u" && !(i.buffer instanceof SharedArrayBuffer) && (a = new Uint8Array(new SharedArrayBuffer(i.byteLength)), a.set(i));
|
|
1177
|
-
let o = new
|
|
1177
|
+
let o = new nt(a, t, n, bt, Tt);
|
|
1178
1178
|
return o.needsUpdate = !0, o;
|
|
1179
1179
|
}
|
|
1180
|
-
function
|
|
1181
|
-
return
|
|
1180
|
+
function pn(e, t) {
|
|
1181
|
+
return y().decodeImage(t === "image/png" ? dn(e) : e, t);
|
|
1182
1182
|
}
|
|
1183
|
-
async function
|
|
1183
|
+
async function mn(e) {
|
|
1184
1184
|
let t = await fetch(e);
|
|
1185
1185
|
if (!t.ok) throw Error(`HTTP ${t.status}`);
|
|
1186
1186
|
return new Uint8Array(await t.arrayBuffer());
|
|
1187
1187
|
}
|
|
1188
|
-
function
|
|
1189
|
-
return t.bufferView === void 0 ?
|
|
1188
|
+
function hn(e, t) {
|
|
1189
|
+
return t.bufferView === void 0 ? mn(e.options.manager.resolveURL(L.resolveURL(t.uri, e.options.path))) : e.getDependency("bufferView", t.bufferView).then((e) => new Uint8Array(e));
|
|
1190
1190
|
}
|
|
1191
|
-
var
|
|
1192
|
-
function
|
|
1191
|
+
var gn = (e, t) => !!t && t !== e.textureLoader && typeof t.parse == "function";
|
|
1192
|
+
function _n(e, t, n) {
|
|
1193
1193
|
if (e.sourceCache[t] !== void 0) return e.sourceCache[t].then((e) => e.clone());
|
|
1194
|
-
let r =
|
|
1194
|
+
let r = hn(e, e.json.images[t]).then((e) => new Promise((t, r) => {
|
|
1195
1195
|
n.parse(e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength), t, r);
|
|
1196
1196
|
}));
|
|
1197
1197
|
return e.sourceCache[t] = r, r;
|
|
1198
1198
|
}
|
|
1199
|
-
async function
|
|
1200
|
-
let n =
|
|
1199
|
+
async function vn(e, t = un({ uri: e })) {
|
|
1200
|
+
let n = fn(await pn(await mn(e), t));
|
|
1201
1201
|
return n.flipY = !0, n;
|
|
1202
1202
|
}
|
|
1203
|
-
function
|
|
1203
|
+
function yn(e, t = null) {
|
|
1204
1204
|
return e.loadImageSource = function(e, n) {
|
|
1205
|
-
if (
|
|
1205
|
+
if (gn(this, n)) return _n(this, e, n);
|
|
1206
1206
|
let r = this.json.images[e], i = /* @__PURE__ */ Error("no image decoder in this runtime: configurePlatform( nodePlatform( { decodeImage } ) ) — see \"Running in Node\"");
|
|
1207
1207
|
return t?.(r.uri ?? `bufferView ${r.bufferView}`, i), Promise.reject(i);
|
|
1208
1208
|
}, { name: "RAYZEE_missing_image_decoder" };
|
|
1209
1209
|
}
|
|
1210
|
-
function
|
|
1210
|
+
function bn(e, t = null) {
|
|
1211
1211
|
return e.loadImageSource = function(e, n) {
|
|
1212
|
-
if (
|
|
1212
|
+
if (gn(this, n)) return _n(this, e, n);
|
|
1213
1213
|
if (this.sourceCache[e] !== void 0) return this.sourceCache[e].then((e) => e.clone());
|
|
1214
|
-
let r = this.json.images[e], i =
|
|
1215
|
-
let t =
|
|
1214
|
+
let r = this.json.images[e], i = un(r), a = r.uri ?? `bufferView ${r.bufferView}`, o = hn(this, r).then((e) => pn(e, i)).then((e) => {
|
|
1215
|
+
let t = fn(e, { shared: !0 });
|
|
1216
1216
|
return r.extras && typeof r.extras == "object" && Object.assign(t.userData, r.extras), t.userData.mimeType = i, t;
|
|
1217
1217
|
}).catch((e) => {
|
|
1218
1218
|
throw t?.(a, e), e;
|
|
@@ -1222,8 +1222,8 @@ function vn(e, t = null) {
|
|
|
1222
1222
|
}
|
|
1223
1223
|
//#endregion
|
|
1224
1224
|
//#region src/Processor/GLTFDiffuseTransmission.js
|
|
1225
|
-
var
|
|
1226
|
-
function
|
|
1225
|
+
var xn = "KHR_materials_diffuse_transmission";
|
|
1226
|
+
function Sn(e) {
|
|
1227
1227
|
let t = (t, n, r, i) => {
|
|
1228
1228
|
let a = {};
|
|
1229
1229
|
return e.assignTexture(a, n, r, i).then(() => {
|
|
@@ -1231,7 +1231,7 @@ function bn(e) {
|
|
|
1231
1231
|
});
|
|
1232
1232
|
};
|
|
1233
1233
|
return {
|
|
1234
|
-
name:
|
|
1234
|
+
name: xn,
|
|
1235
1235
|
afterRoot(n) {
|
|
1236
1236
|
let r = e.json.materials ?? [], i = /* @__PURE__ */ new Set(), a = [];
|
|
1237
1237
|
for (let o of n.scenes ?? []) o.traverse((n) => {
|
|
@@ -1239,7 +1239,7 @@ function bn(e) {
|
|
|
1239
1239
|
for (let n of o) {
|
|
1240
1240
|
if (i.has(n)) continue;
|
|
1241
1241
|
i.add(n);
|
|
1242
|
-
let o = e.associations.get(n)?.materials, s = o === void 0 ? null : r[o]?.extensions?.[
|
|
1242
|
+
let o = e.associations.get(n)?.materials, s = o === void 0 ? null : r[o]?.extensions?.[xn];
|
|
1243
1243
|
if (!s) continue;
|
|
1244
1244
|
n.diffuseTransmission = s.diffuseTransmissionFactor ?? 0;
|
|
1245
1245
|
let [c, l, u] = s.diffuseTransmissionColorFactor ?? [
|
|
@@ -1247,7 +1247,7 @@ function bn(e) {
|
|
|
1247
1247
|
1,
|
|
1248
1248
|
1
|
|
1249
1249
|
];
|
|
1250
|
-
n.diffuseTransmissionColor = new
|
|
1250
|
+
n.diffuseTransmissionColor = new tt().setRGB(c, l, u, ct), s.diffuseTransmissionTexture && a.push(t(n, "diffuseTransmissionMap", s.diffuseTransmissionTexture)), s.diffuseTransmissionColorTexture && a.push(t(n, "diffuseTransmissionColorMap", s.diffuseTransmissionColorTexture, V));
|
|
1251
1251
|
}
|
|
1252
1252
|
});
|
|
1253
1253
|
return Promise.all(a);
|
|
@@ -1256,20 +1256,20 @@ function bn(e) {
|
|
|
1256
1256
|
}
|
|
1257
1257
|
//#endregion
|
|
1258
1258
|
//#region src/Processor/GLTFDecoders.js
|
|
1259
|
-
var
|
|
1260
|
-
function
|
|
1259
|
+
var Cn = "KHR_draco_mesh_compression", wn = "KHR_texture_basisu", Tn = ["EXT_meshopt_compression", "KHR_meshopt_compression"], En = new TextDecoder();
|
|
1260
|
+
function Dn(e) {
|
|
1261
1261
|
if (typeof e == "string") return e;
|
|
1262
1262
|
if (!(e instanceof ArrayBuffer)) return JSON.stringify(e?.extensionsUsed ?? []);
|
|
1263
1263
|
let t = new DataView(e);
|
|
1264
|
-
if (!(e.byteLength >= 20 && t.getUint32(0, !0) === 1179937895)) return
|
|
1264
|
+
if (!(e.byteLength >= 20 && t.getUint32(0, !0) === 1179937895)) return En.decode(e);
|
|
1265
1265
|
let n = Math.min(t.getUint32(12, !0), e.byteLength - 20);
|
|
1266
|
-
return
|
|
1266
|
+
return En.decode(new Uint8Array(e, 20, n));
|
|
1267
1267
|
}
|
|
1268
|
-
async function
|
|
1268
|
+
async function On(e, t, n) {
|
|
1269
1269
|
let { dracoDecoderPath: r, ktx2TranscoderPath: i } = T(), [a, o, s] = await Promise.all([
|
|
1270
|
-
t.includes(
|
|
1271
|
-
t.includes(
|
|
1272
|
-
|
|
1270
|
+
t.includes(Cn) && !e.dracoLoader ? import("three/addons/loaders/DRACOLoader.js") : null,
|
|
1271
|
+
t.includes(wn) && !e.ktx2Loader ? import("three/addons/loaders/KTX2Loader.js") : null,
|
|
1272
|
+
Tn.some((e) => t.includes(e)) && !e.meshoptDecoder ? import("three/addons/libs/meshopt_decoder.module.js") : null
|
|
1273
1273
|
]);
|
|
1274
1274
|
if (a) {
|
|
1275
1275
|
let t = new a.DRACOLoader();
|
|
@@ -1288,15 +1288,15 @@ async function En(e, t, n) {
|
|
|
1288
1288
|
}
|
|
1289
1289
|
s && e.setMeshoptDecoder(s.MeshoptDecoder);
|
|
1290
1290
|
}
|
|
1291
|
-
function
|
|
1291
|
+
function kn(e, t) {
|
|
1292
1292
|
let n = e.parse.bind(e);
|
|
1293
1293
|
return e.parse = (r, i, a, o) => {
|
|
1294
|
-
|
|
1294
|
+
On(e, Dn(r), t).then(() => n(r, i, a, o), (e) => o?.(e));
|
|
1295
1295
|
}, e;
|
|
1296
1296
|
}
|
|
1297
1297
|
//#endregion
|
|
1298
1298
|
//#region src/Processor/AssetLoader.js
|
|
1299
|
-
var
|
|
1299
|
+
var An = x("assets"), jn = {
|
|
1300
1300
|
glb: {
|
|
1301
1301
|
type: "model",
|
|
1302
1302
|
name: "GLB (GLTF Binary)"
|
|
@@ -1331,7 +1331,7 @@ var On = {
|
|
|
1331
1331
|
}, Z = {
|
|
1332
1332
|
addOn: "rayzee/addons/formats",
|
|
1333
1333
|
install: "assetLoader.registerFormat()"
|
|
1334
|
-
},
|
|
1334
|
+
}, Mn = {
|
|
1335
1335
|
zip: X,
|
|
1336
1336
|
gz: X,
|
|
1337
1337
|
tgz: X,
|
|
@@ -1348,22 +1348,22 @@ var On = {
|
|
|
1348
1348
|
usdz: Z,
|
|
1349
1349
|
exr: Z
|
|
1350
1350
|
};
|
|
1351
|
-
function
|
|
1352
|
-
let t = new
|
|
1351
|
+
function Nn(e) {
|
|
1352
|
+
let t = new $e();
|
|
1353
1353
|
for (let n in e.attributes) t.setAttribute(n, e.attributes[n]);
|
|
1354
1354
|
e.index && t.setIndex(e.index);
|
|
1355
1355
|
for (let n of e.groups) t.addGroup(n.start, n.count, n.materialIndex);
|
|
1356
1356
|
return t;
|
|
1357
1357
|
}
|
|
1358
|
-
var
|
|
1359
|
-
function
|
|
1358
|
+
var Pn = 683;
|
|
1359
|
+
function Fn(e, t, n, r) {
|
|
1360
1360
|
if (!(r.normalize ?? !0)) return Math.PI;
|
|
1361
1361
|
let i = r.shape === "ellipse" || r.shape === "disk" ? Math.PI / 4 : 1, a = e.getWorldScale(new U()), o = Math.PI * i * Math.abs(t * a.x * n * a.y);
|
|
1362
1362
|
return Number.isFinite(o) ? o : Math.PI;
|
|
1363
1363
|
}
|
|
1364
|
-
var
|
|
1364
|
+
var In = class e extends I {
|
|
1365
1365
|
constructor(e, t, n, { issues: r = null, areaLightIntensityScale: i = null } = {}) {
|
|
1366
|
-
super(), this.scene = e, this.camera = t, this.controls = n, this.targetModel = null, this.floorPlane = null, this.sceneScale = 1, this.sceneSize = new U(1, 1, 1), this.loaderCache = {}, this.uploadedFileInfo = null, this.animations = [], this.renderer = null, this.sceneMetadata = null, this._loadingManager = new
|
|
1366
|
+
super(), this.scene = e, this.camera = t, this.controls = n, this.targetModel = null, this.floorPlane = null, this.sceneScale = 1, this.sceneSize = new U(1, 1, 1), this.loaderCache = {}, this.uploadedFileInfo = null, this.animations = [], this.renderer = null, this.sceneMetadata = null, this._loadingManager = new lt(), this._loadCancelled = !1, this._urlAbort = null, this.storage = null, this._downloads = null, this._sourceKey = null, this._appended = !1, this.archives = null, this._archiveLoader = null, this._formats = /* @__PURE__ */ new Map(), this._issues = r, this._areaLightIntensityScale = i ?? (() => _.areaLightIntensityScale), this._loadingManager.onError = (e) => {
|
|
1367
1367
|
this._loadCancelled || this._issues?.record(S.ASSET_UNREACHABLE, `asset "${e}" could not be fetched — anything depending on it renders without it`, { url: e });
|
|
1368
1368
|
};
|
|
1369
1369
|
}
|
|
@@ -1379,7 +1379,7 @@ var Nn = class e extends I {
|
|
|
1379
1379
|
let o = new AbortController();
|
|
1380
1380
|
this._urlAbort = o;
|
|
1381
1381
|
try {
|
|
1382
|
-
return await
|
|
1382
|
+
return await an(t, {
|
|
1383
1383
|
downloads: this.downloads,
|
|
1384
1384
|
key: i,
|
|
1385
1385
|
policy: a,
|
|
@@ -1437,7 +1437,7 @@ var Nn = class e extends I {
|
|
|
1437
1437
|
_adoptExternalObject(e) {
|
|
1438
1438
|
let t;
|
|
1439
1439
|
try {
|
|
1440
|
-
t =
|
|
1440
|
+
t = Mt(e);
|
|
1441
1441
|
} catch (t) {
|
|
1442
1442
|
throw Error(`Cannot render "${e.name || e.type}": its userData must be JSON-serializable.`, { cause: t });
|
|
1443
1443
|
}
|
|
@@ -1471,10 +1471,10 @@ var Nn = class e extends I {
|
|
|
1471
1471
|
}
|
|
1472
1472
|
getFileFormat(e) {
|
|
1473
1473
|
let t = e.split(".").pop().toLowerCase();
|
|
1474
|
-
return
|
|
1474
|
+
return jn[t] || this._formats.get(t) || this._archiveFormats?.[t] || null;
|
|
1475
1475
|
}
|
|
1476
1476
|
formatError(e) {
|
|
1477
|
-
let t =
|
|
1477
|
+
let t = Mn[e.split(".").pop().toLowerCase()];
|
|
1478
1478
|
return /* @__PURE__ */ Error(t ? `${e}: this format is read by ${t.addOn} — install it with ${t.install}` : `Unsupported file format: ${e}`);
|
|
1479
1479
|
}
|
|
1480
1480
|
async inspectArchive(e) {
|
|
@@ -1578,8 +1578,8 @@ var Nn = class e extends I {
|
|
|
1578
1578
|
}
|
|
1579
1579
|
}
|
|
1580
1580
|
async loadModelFromFile(e, t) {
|
|
1581
|
-
let n = this.storage ? this._keyed("file", D(await
|
|
1582
|
-
return this._sourceKey = n,
|
|
1581
|
+
let n = this.storage ? this._keyed("file", D(await ke(e))) : null, r = /\.(usd|usda|usdc)$/i.test(t) ? await this._archiveImporter() : null, i = r ? await r.loadUSDScene({ [t]: e }, t) : await this._loadModelFileByExtension(e, t);
|
|
1582
|
+
return this._sourceKey = n, i;
|
|
1583
1583
|
}
|
|
1584
1584
|
async _loadModelFileByExtension(e, t) {
|
|
1585
1585
|
let n = t.split(".").pop().toLowerCase();
|
|
@@ -1625,7 +1625,7 @@ var Nn = class e extends I {
|
|
|
1625
1625
|
};
|
|
1626
1626
|
try {
|
|
1627
1627
|
let r = await this.loadEnvironment(n);
|
|
1628
|
-
return
|
|
1628
|
+
return me(r, D(await ke(e))), this.dispatchEvent({
|
|
1629
1629
|
type: "load",
|
|
1630
1630
|
texture: r,
|
|
1631
1631
|
filename: t
|
|
@@ -1647,7 +1647,7 @@ var Nn = class e extends I {
|
|
|
1647
1647
|
let e = t.split(/[?#]/)[0].split(".").pop().toLowerCase();
|
|
1648
1648
|
n = await this.loadEnvironmentByExtension(t, e);
|
|
1649
1649
|
}
|
|
1650
|
-
return n.generateMipmaps = !0, e._isNetworkUrl(t) &&
|
|
1650
|
+
return n.generateMipmaps = !0, e._isNetworkUrl(t) && me(n, t), this.applyEnvironmentToScene(n), this.dispatchEvent({
|
|
1651
1651
|
type: "load",
|
|
1652
1652
|
texture: n,
|
|
1653
1653
|
url: t,
|
|
@@ -1684,21 +1684,21 @@ var Nn = class e extends I {
|
|
|
1684
1684
|
}
|
|
1685
1685
|
async loadEnvironmentByExtension(t, n, { loader: r = null } = {}) {
|
|
1686
1686
|
let i = this._formats.get(n);
|
|
1687
|
-
if (!r && i?.type === "environment" && (r = this.loaderCache[n] ??= await i.createLoader(this._loadingManager)), !r && n === "hdr" && (r = this.loaderCache.hdr ??= new
|
|
1687
|
+
if (!r && i?.type === "environment" && (r = this.loaderCache[n] ??= await i.createLoader(this._loadingManager)), !r && n === "hdr" && (r = this.loaderCache.hdr ??= new At(this._loadingManager).setDataType(ot)), !r && Mn[n]) throw this.formatError(`environment.${n}`);
|
|
1688
1688
|
let a = e._isNetworkUrl(t), o = "Downloading Environment...", s = await this._viaCache(t, o, a), c = s.cached ? void 0 : this._downloadProgress(o, a), l;
|
|
1689
1689
|
try {
|
|
1690
|
-
r ? l = await r.loadAsync(s.url, c) :
|
|
1690
|
+
r ? l = await r.loadAsync(s.url, c) : y().decodeImage ? (l = await vn(s.url, `image/${n === "jpg" ? "jpeg" : n}`), l.colorSpace = V) : (this.loaderCache.texture || (this.loaderCache.texture = new wt(this._loadingManager)), l = await this.loaderCache.texture.loadAsync(s.url, c), l.colorSpace = V);
|
|
1691
1691
|
} finally {
|
|
1692
1692
|
s.release();
|
|
1693
1693
|
}
|
|
1694
|
-
return this._downloadComplete("Processing Environment...", 62), l.mapping =
|
|
1694
|
+
return this._downloadComplete("Processing Environment...", 62), this.maxEnvironmentWidth && Ln(l, this.maxEnvironmentWidth), l.mapping = at, l.minFilter = st, l.magFilter = st, l;
|
|
1695
1695
|
}
|
|
1696
1696
|
applyEnvironmentToScene(e) {
|
|
1697
1697
|
this.scene.background = e, this.scene.environment = e;
|
|
1698
1698
|
}
|
|
1699
1699
|
async createGLTFLoader() {
|
|
1700
|
-
let e =
|
|
1701
|
-
return
|
|
1700
|
+
let e = kn(new kt(this._loadingManager), this.renderer), t = (e, t) => this._reportImageFailure(e, t);
|
|
1701
|
+
return y().decodeImage ? e.register((e) => bn(e, t)) : g() || e.register((e) => yn(e, t)), e.register((e) => Sn(e)), e;
|
|
1702
1702
|
}
|
|
1703
1703
|
_reportImageFailure(e, t) {
|
|
1704
1704
|
try {
|
|
@@ -1734,8 +1734,8 @@ var Nn = class e extends I {
|
|
|
1734
1734
|
loadedBytes: 0,
|
|
1735
1735
|
totalBytes: 0
|
|
1736
1736
|
}), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(L.extractUrlBase(t));
|
|
1737
|
-
let e = await
|
|
1738
|
-
return this._downloadComplete(), this._throwDeferred(), this.releaseTargetModel(), this._sourceKey = i ? this._keyed("url", n.cacheKey ?? t) : null, this.targetModel = e.scene, this.animations = e.animations || [], this.sceneMetadata =
|
|
1737
|
+
let e = await ne(() => r.loadAsync(a.url, a.cached ? void 0 : this._downloadProgress("Downloading Model...", i)));
|
|
1738
|
+
return this._downloadComplete(), this._throwDeferred(), this.releaseTargetModel(), this._sourceKey = i ? this._keyed("url", n.cacheKey ?? t) : null, this.targetModel = e.scene, this.animations = e.animations || [], this.sceneMetadata = Ne(e), await this.onModelLoad(this.targetModel), this.dispatchEvent({
|
|
1739
1739
|
type: "load",
|
|
1740
1740
|
model: e.scene,
|
|
1741
1741
|
filename: t.split("/").pop()
|
|
@@ -1765,7 +1765,7 @@ var Nn = class e extends I {
|
|
|
1765
1765
|
loadedBytes: 0,
|
|
1766
1766
|
totalBytes: 0
|
|
1767
1767
|
}), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(L.extractUrlBase(t));
|
|
1768
|
-
let e = await
|
|
1768
|
+
let e = await ne(() => r.loadAsync(a.url, a.cached ? void 0 : this._downloadProgress("Downloading Model...", i)));
|
|
1769
1769
|
return this._downloadComplete(), this._throwDeferred(), this._appended = !0, this._processAndParent(e.scene), {
|
|
1770
1770
|
root: e.scene,
|
|
1771
1771
|
animations: e.animations || []
|
|
@@ -1782,7 +1782,7 @@ var Nn = class e extends I {
|
|
|
1782
1782
|
return n.name = e.name || t, this._processAndParent(n), { root: n };
|
|
1783
1783
|
}
|
|
1784
1784
|
removeModelRoot(e) {
|
|
1785
|
-
e && (e.userData.__rayzeeExternal ? (
|
|
1785
|
+
e && (e.userData.__rayzeeExternal ? (te(e), e.parent?.remove(e)) : h(e));
|
|
1786
1786
|
}
|
|
1787
1787
|
async loadGLBFromArrayBuffer(e, t = "model.glb") {
|
|
1788
1788
|
let n = await this.createGLTFLoader();
|
|
@@ -1792,8 +1792,8 @@ var Nn = class e extends I {
|
|
|
1792
1792
|
status: "Processing GLB Data...",
|
|
1793
1793
|
progress: 5
|
|
1794
1794
|
}), await new Promise((e) => setTimeout(e, 0));
|
|
1795
|
-
let r = await
|
|
1796
|
-
return this._throwDeferred(), this.releaseTargetModel(), this.targetModel = r.scene, this.animations = r.animations || [], this.sceneMetadata =
|
|
1795
|
+
let r = await ne(() => n.parseAsync(e, ""));
|
|
1796
|
+
return this._throwDeferred(), this.releaseTargetModel(), this.targetModel = r.scene, this.animations = r.animations || [], this.sceneMetadata = Ne(r), v({
|
|
1797
1797
|
isLoading: !0,
|
|
1798
1798
|
status: "Processing Data...",
|
|
1799
1799
|
progress: 10
|
|
@@ -1826,11 +1826,11 @@ var Nn = class e extends I {
|
|
|
1826
1826
|
}), n;
|
|
1827
1827
|
}
|
|
1828
1828
|
async onModelLoad(e) {
|
|
1829
|
-
let t = new
|
|
1829
|
+
let t = new d("onModelLoad");
|
|
1830
1830
|
t.start("Camera extraction");
|
|
1831
1831
|
let n = this.extractCamerasFromModel(e);
|
|
1832
1832
|
t.end("Camera extraction"), t.start("Camera setup");
|
|
1833
|
-
let r = new
|
|
1833
|
+
let r = new Qe().setFromObject(e), i = r.getCenter(new U()), a = r.getSize(new U());
|
|
1834
1834
|
this.controls?.target.copy(i);
|
|
1835
1835
|
let o = Math.max(a.x, a.y, a.z), s = this.camera.fov * (Math.PI / 180), c = Math.abs(o / Math.sin(s / 2) / 2), l = Math.PI / 6, u = new U(Math.cos(l) * c, c / Math.sqrt(2), Math.sin(l) * c);
|
|
1836
1836
|
if (this.camera.position.copy(u.add(i)), this.camera.lookAt(i), this.camera.near = o / 100, this.camera.far = o * 100, this.camera.updateProjectionMatrix(), this.controls && (this.controls.maxDistance = c * 10, this.controls.saveState(), this.controls.update()), t.end("Camera setup"), this.floorPlane) {
|
|
@@ -1838,8 +1838,8 @@ var Nn = class e extends I {
|
|
|
1838
1838
|
this.floorPlane.position.y = e, this.floorPlane.rotation.x = -Math.PI / 2, this.floorPlane.scale.setScalar(o * 5);
|
|
1839
1839
|
}
|
|
1840
1840
|
t.start("Process model objects"), this.processModelObjects(e), t.end("Process model objects"), t.start("Scene add"), this.scene.add(e), t.end("Scene add");
|
|
1841
|
-
let
|
|
1842
|
-
return this.sceneSize.copy(a), t.start("setupPathTracing"), await this.setupPathTracing(e,
|
|
1841
|
+
let f = o;
|
|
1842
|
+
return this.sceneSize.copy(a), t.start("setupPathTracing"), await this.setupPathTracing(e, f), t.end("setupPathTracing"), t.print(), this.dispatchEvent({
|
|
1843
1843
|
type: "modelProcessed",
|
|
1844
1844
|
model: e,
|
|
1845
1845
|
cameras: n,
|
|
@@ -1847,13 +1847,13 @@ var Nn = class e extends I {
|
|
|
1847
1847
|
center: i,
|
|
1848
1848
|
size: a,
|
|
1849
1849
|
maxDim: o,
|
|
1850
|
-
sceneScale:
|
|
1850
|
+
sceneScale: f
|
|
1851
1851
|
}
|
|
1852
1852
|
}), this.dispatchEvent({ type: "SceneRebuild" }), {
|
|
1853
1853
|
center: i,
|
|
1854
1854
|
size: a,
|
|
1855
1855
|
maxDim: o,
|
|
1856
|
-
sceneScale:
|
|
1856
|
+
sceneScale: f
|
|
1857
1857
|
};
|
|
1858
1858
|
}
|
|
1859
1859
|
extractCamerasFromModel(e) {
|
|
@@ -1869,10 +1869,10 @@ var Nn = class e extends I {
|
|
|
1869
1869
|
let t = [], n = [];
|
|
1870
1870
|
e.traverse((e) => {
|
|
1871
1871
|
let r = e.userData;
|
|
1872
|
-
e.isRectAreaLight && !r.__radianceConverted && (e.intensity *=
|
|
1872
|
+
e.isRectAreaLight && !r.__radianceConverted && (e.intensity *= Fn(e, e.width, e.height, r), r.__radianceConverted = !0), (e.isPointLight || e.isSpotLight) && !r.__candelaConverted && (e.intensity *= 4 * Math.PI / Pn, r.__candelaConverted = !0), e.isDirectionalLight && !r.__luxConverted && (e.intensity /= Pn, r.__luxConverted = !0);
|
|
1873
1873
|
let i = e.name.startsWith("RectAreaLightPlaceholder");
|
|
1874
1874
|
if (i && !(r.name && r.type === "RectAreaLight") && !e.parent?.name?.startsWith("RectAreaLightPlaceholder") && n.push(e.name), i && r.name && r.type === "RectAreaLight") {
|
|
1875
|
-
let t = r.normalize ?? !0, n = r.shape ?? "rectangle", i = r.intensity *
|
|
1875
|
+
let t = r.normalize ?? !0, n = r.shape ?? "rectangle", i = r.intensity * Fn(e, r.width, r.height, r), a = new B(new tt(...r.color), i * this._areaLightIntensityScale(), r.width, r.height);
|
|
1876
1876
|
a.userData.normalize = t, a.userData.spread = Number.isFinite(r.spread) ? r.spread : Math.PI, a.userData.shape = n, a.userData.__radianceConverted = !0, a.name = r.name, e.add(a);
|
|
1877
1877
|
}
|
|
1878
1878
|
e.isMesh && Array.isArray(e.material) && t.push(e);
|
|
@@ -1883,8 +1883,8 @@ var Nn = class e extends I {
|
|
|
1883
1883
|
let r = e.userData.__rayzeeExternal === !0;
|
|
1884
1884
|
for (let e of t) {
|
|
1885
1885
|
if (!e.parent) continue;
|
|
1886
|
-
console.log("Found multi-material mesh:", e.name), r && (e.geometry =
|
|
1887
|
-
let t =
|
|
1886
|
+
console.log("Found multi-material mesh:", e.name), r && (e.geometry = Nn(e.geometry));
|
|
1887
|
+
let t = jt(e);
|
|
1888
1888
|
for (let e of t.children) e.geometry.userData.__rayzeeOwned = !0;
|
|
1889
1889
|
e.parent.add(t), e.parent.remove(e);
|
|
1890
1890
|
}
|
|
@@ -1893,7 +1893,7 @@ var Nn = class e extends I {
|
|
|
1893
1893
|
this.sceneScale = t;
|
|
1894
1894
|
}
|
|
1895
1895
|
createFloorPlane() {
|
|
1896
|
-
this.floorPlane = new
|
|
1896
|
+
this.floorPlane = new ut(new et(), new dt({
|
|
1897
1897
|
transparent: !1,
|
|
1898
1898
|
color: 3158064,
|
|
1899
1899
|
roughness: 1,
|
|
@@ -1916,7 +1916,7 @@ var Nn = class e extends I {
|
|
|
1916
1916
|
}
|
|
1917
1917
|
getSupportedFormats(e = null) {
|
|
1918
1918
|
let t = {
|
|
1919
|
-
...
|
|
1919
|
+
...jn,
|
|
1920
1920
|
...this._archiveFormats
|
|
1921
1921
|
};
|
|
1922
1922
|
for (let [e, { type: n, name: r }] of this._formats) t[e] = {
|
|
@@ -1940,13 +1940,39 @@ var Nn = class e extends I {
|
|
|
1940
1940
|
removeAllEventListeners() {
|
|
1941
1941
|
this._listeners = void 0;
|
|
1942
1942
|
}
|
|
1943
|
-
}
|
|
1943
|
+
};
|
|
1944
|
+
function Ln(e, t) {
|
|
1945
|
+
let { data: n, width: r, height: i } = e.image ?? {};
|
|
1946
|
+
if (!(n instanceof Float32Array) || r <= t || n.length !== r * i * 4) return;
|
|
1947
|
+
let a = Math.ceil(r / t), o = Math.ceil(r / a), s = Math.ceil(i / a);
|
|
1948
|
+
for (let e = 0; e < s; e++) {
|
|
1949
|
+
let t = Math.min(i, (e + 1) * a);
|
|
1950
|
+
for (let i = 0; i < o; i++) {
|
|
1951
|
+
let s = Math.min(r, (i + 1) * a), c = 0, l = 0, u = 0, d = 0, f = 0;
|
|
1952
|
+
for (let o = e * a; o < t; o++) for (let e = i * a; e < s; e++) {
|
|
1953
|
+
let t = (o * r + e) * 4;
|
|
1954
|
+
c += n[t], l += n[t + 1], u += n[t + 2], d += n[t + 3], f++;
|
|
1955
|
+
}
|
|
1956
|
+
let p = (e * o + i) * 4;
|
|
1957
|
+
n[p] = c / f, n[p + 1] = l / f, n[p + 2] = u / f, n[p + 3] = d / f;
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
let c = o * s * 16;
|
|
1961
|
+
e.image = {
|
|
1962
|
+
data: n.byteOffset === 0 && n.byteLength === n.buffer.byteLength && n.buffer.transfer ? new Float32Array(n.buffer.transfer(c)) : n.slice(0, o * s * 4),
|
|
1963
|
+
width: o,
|
|
1964
|
+
height: s
|
|
1965
|
+
}, e.needsUpdate = !0, An.info(`environment ${r}×${i} shrunk to ${o}×${s} (memory spill)`);
|
|
1966
|
+
}
|
|
1967
|
+
//#endregion
|
|
1968
|
+
//#region src/HeadlessCanvas.js
|
|
1969
|
+
var Rn = {
|
|
1944
1970
|
addEventListener() {},
|
|
1945
1971
|
removeEventListener() {},
|
|
1946
1972
|
dispatchEvent() {
|
|
1947
1973
|
return !0;
|
|
1948
1974
|
}
|
|
1949
|
-
},
|
|
1975
|
+
}, zn = class {
|
|
1950
1976
|
constructor(e) {
|
|
1951
1977
|
this.canvas = e, this._configuration = null, this._texture = null;
|
|
1952
1978
|
}
|
|
@@ -1974,12 +2000,12 @@ var Nn = class e extends I {
|
|
|
1974
2000
|
return this._texture;
|
|
1975
2001
|
}
|
|
1976
2002
|
};
|
|
1977
|
-
function
|
|
2003
|
+
function Bn(e = 1, t = 1) {
|
|
1978
2004
|
let n = {
|
|
1979
|
-
...
|
|
2005
|
+
...Rn,
|
|
1980
2006
|
defaultView: null
|
|
1981
2007
|
}, r = {
|
|
1982
|
-
...
|
|
2008
|
+
...Rn,
|
|
1983
2009
|
isHeadlessCanvas: !0,
|
|
1984
2010
|
width: e,
|
|
1985
2011
|
height: t,
|
|
@@ -2006,12 +2032,12 @@ function In(e = 1, t = 1) {
|
|
|
2006
2032
|
hasPointerCapture: () => !1,
|
|
2007
2033
|
focus() {},
|
|
2008
2034
|
getContext: (e) => e === "webgpu" ? i : null
|
|
2009
|
-
}, i = new
|
|
2035
|
+
}, i = new zn(r);
|
|
2010
2036
|
return r;
|
|
2011
2037
|
}
|
|
2012
2038
|
//#endregion
|
|
2013
2039
|
//#region src/managers/ViewCamera.js
|
|
2014
|
-
var
|
|
2040
|
+
var Vn = class extends gt {
|
|
2015
2041
|
constructor(e, t, n, r) {
|
|
2016
2042
|
super(e, t, n, r), this.orthographic = !1, this.orthoHalfHeight = 1;
|
|
2017
2043
|
}
|
|
@@ -2035,17 +2061,17 @@ var Ln = class extends mt {
|
|
|
2035
2061
|
return -this.orthoHalfHeight * this.aspect;
|
|
2036
2062
|
}
|
|
2037
2063
|
updateProjectionMatrix() {
|
|
2038
|
-
this.orthographic ?
|
|
2064
|
+
this.orthographic ? ht.prototype.updateProjectionMatrix.call(this) : super.updateProjectionMatrix();
|
|
2039
2065
|
}
|
|
2040
2066
|
copy(e, t) {
|
|
2041
2067
|
return super.copy(e, t), this.orthographic = e.orthographic === !0, this.orthoHalfHeight = e.orthoHalfHeight ?? this.orthoHalfHeight, this;
|
|
2042
2068
|
}
|
|
2043
|
-
},
|
|
2044
|
-
DirectionalLight:
|
|
2045
|
-
PointLight:
|
|
2046
|
-
SpotLight:
|
|
2069
|
+
}, Hn = "__rayzeeUserLight", Un = {
|
|
2070
|
+
DirectionalLight: rt,
|
|
2071
|
+
PointLight: _t,
|
|
2072
|
+
SpotLight: St,
|
|
2047
2073
|
RectAreaLight: B
|
|
2048
|
-
},
|
|
2074
|
+
}, Wn = class extends I {
|
|
2049
2075
|
constructor(e, t, n, r = {}) {
|
|
2050
2076
|
super(), this.scene = e, this.sceneHelpers = t, this.pathTracer = n, this._onReset = r.onReset || null, this._onLightRemoved = r.onLightRemoved || null;
|
|
2051
2077
|
}
|
|
@@ -2093,14 +2119,14 @@ var Ln = class extends mt {
|
|
|
2093
2119
|
}[e];
|
|
2094
2120
|
if (!t) return null;
|
|
2095
2121
|
let n;
|
|
2096
|
-
if (e === "DirectionalLight") n = new
|
|
2097
|
-
else if (e === "PointLight") n = new
|
|
2122
|
+
if (e === "DirectionalLight") n = new rt(t.color, t.intensity), n.position.fromArray(t.position);
|
|
2123
|
+
else if (e === "PointLight") n = new _t(t.color, t.intensity), n.position.fromArray(t.position);
|
|
2098
2124
|
else if (e === "SpotLight") {
|
|
2099
|
-
n = new
|
|
2125
|
+
n = new St(t.color, t.intensity), n.position.fromArray(t.position), n.angle = R.degToRad(t.angle);
|
|
2100
2126
|
let e = new z();
|
|
2101
2127
|
this.scene.add(e), n.target = e;
|
|
2102
2128
|
} else e === "RectAreaLight" && (n = new B(t.color, t.intensity, t.width, t.height), n.position.fromArray(t.position), n.lookAt(0, 0, 0), n.userData.normalize = !0, n.userData.spread = Math.PI, n.userData.shape = "rectangle");
|
|
2103
|
-
n.userData[
|
|
2129
|
+
n.userData[Hn] = !0, n.userData.temperature = 6500, n.userData.useTemperature = !1, n.userData.exposure = 0;
|
|
2104
2130
|
let r = this.scene.getObjectsByProperty("isLight", !0).length;
|
|
2105
2131
|
return n.name = `${e.replace("Light", "")} ${r + 1}`, this.scene.add(n), this.updateLights(), this._syncHelpers(), this._onReset?.(), this._buildDescriptor(n);
|
|
2106
2132
|
}
|
|
@@ -2126,7 +2152,7 @@ var Ln = class extends mt {
|
|
|
2126
2152
|
this.pathTracer?.updateLights(), this.sceneHelpers?.visible && this.sceneHelpers.update();
|
|
2127
2153
|
}
|
|
2128
2154
|
transferSceneLights(e, { keepUserLights: t = !1 } = {}) {
|
|
2129
|
-
this._removeAllLights(t ? (e) => !e.userData?.[
|
|
2155
|
+
this._removeAllLights(t ? (e) => !e.userData?.[Hn] : void 0);
|
|
2130
2156
|
let n = e.getObjectsByProperty("isLight", !0);
|
|
2131
2157
|
if (!n || n.length === 0) {
|
|
2132
2158
|
this.updateLights();
|
|
@@ -2160,7 +2186,7 @@ var Ln = class extends mt {
|
|
|
2160
2186
|
position: e.position.toArray(),
|
|
2161
2187
|
quaternion: e.quaternion.toArray(),
|
|
2162
2188
|
scale: e.scale.toArray(),
|
|
2163
|
-
userData:
|
|
2189
|
+
userData: i(e.userData) ?? {}
|
|
2164
2190
|
};
|
|
2165
2191
|
return e.isSpotLight && Object.assign(t, {
|
|
2166
2192
|
angle: e.angle,
|
|
@@ -2180,14 +2206,14 @@ var Ln = class extends mt {
|
|
|
2180
2206
|
this.sceneHelpers?.clear(), this._removeAllLights();
|
|
2181
2207
|
let t = [];
|
|
2182
2208
|
for (let n of e ?? []) {
|
|
2183
|
-
let e =
|
|
2209
|
+
let e = Un[n.type];
|
|
2184
2210
|
if (!e) continue;
|
|
2185
2211
|
let r = new e();
|
|
2186
2212
|
r.name = n.name ?? "", r.visible = n.visible !== !1, r.color.setRGB(...n.color), r.intensity = n.intensity, r.position.fromArray(n.position), r.quaternion.fromArray(n.quaternion), r.scale.fromArray(n.scale ?? [
|
|
2187
2213
|
1,
|
|
2188
2214
|
1,
|
|
2189
2215
|
1
|
|
2190
|
-
]), r.userData =
|
|
2216
|
+
]), r.userData = o(n.userData) ?? {};
|
|
2191
2217
|
for (let e of [
|
|
2192
2218
|
"angle",
|
|
2193
2219
|
"penumbra",
|
|
@@ -2272,11 +2298,11 @@ var Ln = class extends mt {
|
|
|
2272
2298
|
], 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);
|
|
2273
2299
|
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;
|
|
2274
2300
|
}
|
|
2275
|
-
},
|
|
2301
|
+
}, Gn = ({ element: e, pbrtEntry: t } = {}) => ({
|
|
2276
2302
|
...e === void 0 ? {} : { element: e },
|
|
2277
2303
|
...t === void 0 ? {} : { pbrtEntry: t }
|
|
2278
|
-
}), Q = /* @__PURE__ */ new WeakMap(),
|
|
2279
|
-
async function
|
|
2304
|
+
}), Q = /* @__PURE__ */ new WeakMap(), Kn = 3e4, qn = new Set([...Object.values(m), ...Object.values(p)]), Jn = /* @__PURE__ */ new Set();
|
|
2305
|
+
async function Yn(e, t) {
|
|
2280
2306
|
if (!t || typeof self < "u") return e.init();
|
|
2281
2307
|
globalThis.self = {
|
|
2282
2308
|
requestAnimationFrame: () => 0,
|
|
@@ -2288,43 +2314,43 @@ async function Wn(e, t) {
|
|
|
2288
2314
|
delete globalThis.self;
|
|
2289
2315
|
}
|
|
2290
2316
|
}
|
|
2291
|
-
var $ =
|
|
2292
|
-
function
|
|
2317
|
+
var $ = x("engine");
|
|
2318
|
+
function Xn() {
|
|
2293
2319
|
let e = new Float32Array(16);
|
|
2294
|
-
return new Uint32Array(e.buffer)[3] =
|
|
2320
|
+
return new Uint32Array(e.buffer)[3] = ge.TRIANGLE_LEAF, e;
|
|
2295
2321
|
}
|
|
2296
|
-
function
|
|
2322
|
+
function Zn(e, t) {
|
|
2297
2323
|
e.lost.then((e) => {
|
|
2298
2324
|
t.app && t.app._handleDeviceLost(e);
|
|
2299
2325
|
});
|
|
2300
2326
|
}
|
|
2301
|
-
var
|
|
2302
|
-
function
|
|
2327
|
+
var Qn = /swiftshader|llvmpipe|lavapipe|basic render|microsoft basic|warp/i;
|
|
2328
|
+
function $n(e) {
|
|
2303
2329
|
let t = e.info ?? {}, n = `${t.vendor ?? ""} ${t.architecture ?? ""} ${t.device ?? ""} ${t.description ?? ""}`;
|
|
2304
2330
|
return {
|
|
2305
2331
|
vendor: t.vendor ?? "",
|
|
2306
2332
|
architecture: t.architecture ?? "",
|
|
2307
2333
|
device: t.device ?? "",
|
|
2308
2334
|
description: t.description ?? "",
|
|
2309
|
-
isSoftware: t.isFallbackAdapter === !0 || e.isFallbackAdapter === !0 ||
|
|
2335
|
+
isSoftware: t.isFallbackAdapter === !0 || e.isFallbackAdapter === !0 || Qn.test(n)
|
|
2310
2336
|
};
|
|
2311
2337
|
}
|
|
2312
|
-
var
|
|
2338
|
+
var er = class extends I {
|
|
2313
2339
|
constructor(e, t = {}) {
|
|
2314
|
-
super(), this._headless = t.headless === !0 || !e, e ??=
|
|
2340
|
+
super(), this._headless = t.headless === !0 || !e, e ??= Bn();
|
|
2315
2341
|
try {
|
|
2316
2342
|
Q.get(e)?.dispose();
|
|
2317
2343
|
} catch (e) {
|
|
2318
2344
|
$.warn("prior canvas owner dispose failed", e);
|
|
2319
2345
|
}
|
|
2320
|
-
if (Q.set(e, this), this.canvas = e, this._autoResize = !this._headless && t.autoResize !== !1, this._maxSceneBytes = t.maxSceneBytes, this._hostMemoryGB = t.hostMemoryGB, this._storageOption = t.storage, this._storageOpener = null, this._memorySpill = t.memorySpill === !0, this.storage = null, this._storageRelease = null, this._applySceneMetadataEnabled = t.applySceneMetadata !== !1, this._unlitRestore = null, this._applyingSceneMetadata = !1, t.profile !== void 0) throw Error("the `profile` option was removed: the engine has one set of defaults. For the old 'physical' profile set `dofMode: 'physical'` through `settings`.");
|
|
2321
|
-
this._issues = new
|
|
2346
|
+
if (Q.set(e, this), this.canvas = e, this._autoResize = !this._headless && t.autoResize !== !1, this._maxSceneBytes = t.maxSceneBytes, this._hostMemoryGB = t.hostMemoryGB, this._storageOption = t.storage, this._storageOpener = null, this._memorySpill = t.memorySpill === !0 || t.memorySpill === !1 ? t.memorySpill : "auto", this._spillPlan = null, this.storage = null, this._storageRelease = null, this._applySceneMetadataEnabled = t.applySceneMetadata !== !1, this._unlitRestore = null, this._applyingSceneMetadata = !1, t.profile !== void 0) throw Error("the `profile` option was removed: the engine has one set of defaults. For the old 'physical' profile set `areaLightIntensityScale: 1` and `dofMode: 'physical'` through `settings`.");
|
|
2347
|
+
this._issues = new _e({
|
|
2322
2348
|
strict: t.strict === !0,
|
|
2323
2349
|
onIssue: (e) => this.dispatchEvent({
|
|
2324
|
-
type:
|
|
2350
|
+
type: m.ISSUE,
|
|
2325
2351
|
issue: e
|
|
2326
2352
|
})
|
|
2327
|
-
}), this.color = new
|
|
2353
|
+
}), this.color = new cn({ issues: this._issues }), C(this.color), this.settings = new sn(_, { issues: this._issues }), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this.pipeline = null, this._pendingReservedRenderSize = null, this.stages = {}, this.camera = null, this.lightManager = null, 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 Jt(), this._resizeDebounceTimer = null, this._displayWidth = 0, this._displayHeight = 0, this._renderScale = 1, this._renderWidth = 0, this._renderHeight = 0, this._trackedListeners = [], this._disposed = !1, this._deviceLost = !1, this._gpuDevice = null, this._deviceLostHolder = null, this._deterministic = !1, this._dispatchPinned = !1, this._deterministicRestore = null, this.adapterInfo = null;
|
|
2328
2354
|
}
|
|
2329
2355
|
_addTrackedListener(e, t, n) {
|
|
2330
2356
|
e && (e.addEventListener(t, n), this._trackedListeners.push({
|
|
@@ -2343,18 +2369,18 @@ var Yn = class extends I {
|
|
|
2343
2369
|
}
|
|
2344
2370
|
async init() {
|
|
2345
2371
|
let e = this._initStorage();
|
|
2346
|
-
return await this._initRenderer(), this._applyPendingReservedRenderSize(), this.camera = this._createCamera(), this._initScenes(), this._initAssetPipeline(), this._initPipeline(), await this._initManagers(), this._wireEvents(), await e, this._attachStorage(), this.stages.pathTracer.setTriangleData(new Uint32Array(
|
|
2372
|
+
return await this._initRenderer(), this._applyPendingReservedRenderSize(), this.camera = this._createCamera(), this._initScenes(), this._initAssetPipeline(), this._initPipeline(), await this._initManagers(), this._wireEvents(), await e, this._attachStorage(), this.stages.pathTracer.setTriangleData(new Uint32Array(he.FLOATS_PER_TRIANGLE), 0), this.stages.pathTracer.setBVHData(Xn()), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setupMaterial(), this.isInitialized = !0, $.debug("WebGPU path tracer app initialized"), this;
|
|
2347
2373
|
}
|
|
2348
2374
|
async setStorageOpener(e) {
|
|
2349
2375
|
this._storageOpener = e, !(!this.isInitialized || this.storage || this._disposed) && (await this._initStorage(), this._attachStorage());
|
|
2350
2376
|
}
|
|
2351
2377
|
async _initStorage() {
|
|
2352
|
-
let e = this._storageOption ?? (this._issues.strict && !
|
|
2378
|
+
let e = this._storageOption ?? (this._issues.strict && !Ce("storage") ? !1 : T().storage);
|
|
2353
2379
|
if (e !== !1) {
|
|
2354
2380
|
if (e && typeof e == "object") this.storage = e;
|
|
2355
2381
|
else {
|
|
2356
2382
|
if (!this._storageOpener) {
|
|
2357
|
-
(this._storageOption !== void 0 ||
|
|
2383
|
+
(this._storageOption !== void 0 || Ce("storage")) && this._issues.warn(S.CAPABILITY_MISSING, "on-disk storage needs rayzee/addons/storage: setStorageOpener( acquireSharedStorage )");
|
|
2358
2384
|
return;
|
|
2359
2385
|
}
|
|
2360
2386
|
let { storage: e, reason: t, release: n } = await this._storageOpener(T().cacheNamespace);
|
|
@@ -2369,7 +2395,7 @@ var Yn = class extends I {
|
|
|
2369
2395
|
this.storage = e, this._storageRelease = n;
|
|
2370
2396
|
}
|
|
2371
2397
|
this._addTrackedListener(this.storage, "change", (e) => this.dispatchEvent({
|
|
2372
|
-
type:
|
|
2398
|
+
type: m.STORAGE_CHANGED,
|
|
2373
2399
|
area: e.area
|
|
2374
2400
|
})), this._addTrackedListener(this.storage, "issue", (e) => this._issues.warn(e.code, e.message, e.detail));
|
|
2375
2401
|
}
|
|
@@ -2379,20 +2405,20 @@ var Yn = class extends I {
|
|
|
2379
2405
|
}
|
|
2380
2406
|
dispatchEvent(e) {
|
|
2381
2407
|
super.dispatchEvent(e);
|
|
2382
|
-
let t =
|
|
2408
|
+
let t = p[e.type];
|
|
2383
2409
|
t && super.dispatchEvent({
|
|
2384
2410
|
...e,
|
|
2385
2411
|
type: t
|
|
2386
2412
|
});
|
|
2387
2413
|
}
|
|
2388
2414
|
addEventListener(e, t) {
|
|
2389
|
-
!
|
|
2415
|
+
!qn.has(e) && !Jn.has(e) && (Jn.add(e), $.warn(`no engine event is named "${e}", so this listener will never fire — see EngineEvents`)), super.addEventListener(e, t);
|
|
2390
2416
|
}
|
|
2391
2417
|
animate() {
|
|
2392
2418
|
if (this._headless) throw Error("a headless app has no render loop — drive it with renderFrames() or renderUntilComplete()");
|
|
2393
2419
|
if (this._deviceLost) return;
|
|
2394
2420
|
if (this.animationManagerId = requestAnimationFrame(() => this.animate()), this._loadingInProgress || this._sdf?.isProcessing) {
|
|
2395
|
-
this.dispatchEvent({ type:
|
|
2421
|
+
this.dispatchEvent({ type: m.FRAME });
|
|
2396
2422
|
return;
|
|
2397
2423
|
}
|
|
2398
2424
|
this._beginFrame();
|
|
@@ -2408,28 +2434,28 @@ var Yn = class extends I {
|
|
|
2408
2434
|
return;
|
|
2409
2435
|
}
|
|
2410
2436
|
if (this._holdTrace(e)) {
|
|
2411
|
-
this._renderHelperOverlay(), this.dispatchEvent({ type:
|
|
2437
|
+
this._renderHelperOverlay(), this.dispatchEvent({ type: m.FRAME });
|
|
2412
2438
|
return;
|
|
2413
2439
|
}
|
|
2414
2440
|
if (this.stages.pathTracer.readbackWait()) {
|
|
2415
|
-
this.dispatchEvent({ type:
|
|
2441
|
+
this.dispatchEvent({ type: m.FRAME });
|
|
2416
2442
|
return;
|
|
2417
2443
|
}
|
|
2418
2444
|
this._traceFrame({ liveDenoise: !0 }), this.stages.pathTracer.isComplete && this.completion.markComplete() && (this._renderCompleted(), this.dispatchEvent({
|
|
2419
|
-
type:
|
|
2445
|
+
type: m.RENDER_COMPLETE,
|
|
2420
2446
|
...this._completionInfo()
|
|
2421
2447
|
}));
|
|
2422
2448
|
}
|
|
2423
|
-
this._renderHelperOverlay(), this.dispatchEvent({ type:
|
|
2449
|
+
this._renderHelperOverlay(), this.dispatchEvent({ type: m.FRAME });
|
|
2424
2450
|
}
|
|
2425
2451
|
}
|
|
2426
2452
|
_traceFrame({ liveDenoise: e = !1 } = {}) {
|
|
2427
2453
|
let t = this.stages.pathTracer;
|
|
2428
2454
|
this.pipeline.render(), this._afterTrace(t, e), t.isComplete || this.completion.updateTime(), this._ensureVRAMWiring();
|
|
2429
2455
|
let n = t.vramTracker, r = t.frameCount ?? 0;
|
|
2430
|
-
n && (r <= 1 || r % 30 == 0) && n.measure(),
|
|
2456
|
+
n && (r <= 1 || r % 30 == 0) && n.measure(), le({
|
|
2431
2457
|
timeElapsed: this.completion.timeElapsed,
|
|
2432
|
-
samples:
|
|
2458
|
+
samples: fe(t),
|
|
2433
2459
|
memoryUsed: n?.current ?? 0,
|
|
2434
2460
|
memoryPeak: n?.peak ?? 0
|
|
2435
2461
|
}), this.completion.isTimeLimitReached(t, this.settings.get("renderLimitMode"), this.settings.get("renderTimeLimit")) && (t.isComplete = !0);
|
|
@@ -2447,7 +2473,7 @@ var Yn = class extends I {
|
|
|
2447
2473
|
}
|
|
2448
2474
|
_handleDeviceLost(e) {
|
|
2449
2475
|
this._deviceLost || (this._deviceLost = !0, $.error(`WebGPU device lost (${e?.reason || "unknown"}): ${e?.message || ""}`), this.stopAnimation(), this.dispatchEvent({
|
|
2450
|
-
type:
|
|
2476
|
+
type: m.DEVICE_LOST,
|
|
2451
2477
|
reason: e?.reason,
|
|
2452
2478
|
message: e?.message
|
|
2453
2479
|
}));
|
|
@@ -2462,34 +2488,34 @@ var Yn = class extends I {
|
|
|
2462
2488
|
this._paused = !1, !this.animationManagerId && !this._headless && this.animate();
|
|
2463
2489
|
}
|
|
2464
2490
|
reset(e = !1, { motion: t = !1 } = {}) {
|
|
2465
|
-
t && this.stages.pathTracer?.noteViewChanged(), this._beforeReset(e || t), this.pipeline && (this.pipeline.reset(), e || this.pipeline.eventBus.emit("pipeline:historyReset")), this._afterReset(), this.completion.reset(), this.wake(), this.dispatchEvent({ type:
|
|
2491
|
+
t && this.stages.pathTracer?.noteViewChanged(), this._beforeReset(e || t), this.pipeline && (this.pipeline.reset(), e || this.pipeline.eventBus.emit("pipeline:historyReset")), this._afterReset(), this.completion.reset(), this.wake(), this.dispatchEvent({ type: m.RENDER_RESET });
|
|
2466
2492
|
}
|
|
2467
2493
|
dispose() {
|
|
2468
2494
|
if (!this._disposed) {
|
|
2469
|
-
if (this._disposed = !0, this.dispatchEvent({ type:
|
|
2495
|
+
if (this._disposed = !0, this.dispatchEvent({ type: m.DISPOSE }), this.stopAnimation(), clearTimeout(this._resizeDebounceTimer), this._resizeDebounceTimer = null, clearTimeout(this._respillTimer), this._respillTimer = null, this._removeTrackedListeners(), de(null), this._storageRelease?.(), this._storageRelease = null, this.storage = null, this._sceneSource = this._sceneSourceInput = null, this._issues.detach(), this.color?.dispose(), this.color = null, this._textureReadback?.dispose(), this._textureReadback = null, this._readbackToneMapper?.dispose(), this._readbackToneMapper = null, this._disposeExtensions(), this.lightManager?.dispose(), this.pipeline?.dispose(), this._sdf?.dispose(), this._sdf = null, this.assetLoader?.dispose(), this.assetLoader = null, this.meshScene) {
|
|
2470
2496
|
this.meshScene.environment?.dispose(), this.meshScene.environment = null;
|
|
2471
|
-
for (let e of [...this.meshScene.children])
|
|
2497
|
+
for (let e of [...this.meshScene.children]) h(e);
|
|
2472
2498
|
this.meshScene.clear(), this.meshScene = null;
|
|
2473
2499
|
}
|
|
2474
2500
|
this._sceneHelpers?.clear(), this._sceneHelpers = null, this.scene?.clear(), this.scene = null;
|
|
2475
2501
|
try {
|
|
2476
|
-
let e =
|
|
2502
|
+
let e = Ye().value, t = We().value;
|
|
2477
2503
|
e?._listeners?.dispose && (e._listeners.dispose.length = 0), t?._listeners?.dispose && (t._listeners.dispose.length = 0);
|
|
2478
2504
|
} catch (e) {
|
|
2479
2505
|
$.warn("failed to clear TSL texture singleton listeners", e);
|
|
2480
2506
|
}
|
|
2481
|
-
this.canvas && Q.get(this.canvas) === this && Q.delete(this.canvas), this._gpuDevice &&= (this._gpuDevice.onuncapturederror = null, null), this._deviceLostHolder &&= (this._deviceLostHolder.app = null, null),
|
|
2507
|
+
this.canvas && Q.get(this.canvas) === this && Q.delete(this.canvas), this._gpuDevice &&= (this._gpuDevice.onuncapturederror = null, null), this._deviceLostHolder &&= (this._deviceLostHolder.app = null, null), ae(this.renderer), this.renderer = null, this.stages = {}, this.isInitialized = !1;
|
|
2482
2508
|
}
|
|
2483
2509
|
}
|
|
2484
2510
|
unloadScene() {
|
|
2485
2511
|
if (this.isInitialized) {
|
|
2486
2512
|
if (this._loadingInProgress) throw Error("PathTracerApp.unloadScene: cannot unload while a load is in progress");
|
|
2487
|
-
this._disposed || (this._releaseSceneState(), this.assetLoader?.releaseTargetModel(), this._sceneSource = this._sceneSourceInput = null, this.lightManager?.clearLights?.(), this.stages.pathTracer && (this.stages.pathTracer.setTriangleData(new Uint32Array(
|
|
2513
|
+
this._disposed || (this._releaseSceneState(), this.assetLoader?.releaseTargetModel(), this._sceneSource = this._sceneSourceInput = null, this.lightManager?.clearLights?.(), this.stages.pathTracer && (this.stages.pathTracer.setTriangleData(new Uint32Array(he.FLOATS_PER_TRIANGLE), 0), this.stages.pathTracer.setBVHData(Xn()), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setEmissiveTriangleData?.(new Float32Array(), 0, 0), this.stages.pathTracer.setupMaterial()), this._dropDisplay(), this.reset(), this.dispatchEvent({ type: m.SCENE_UNLOADED }));
|
|
2488
2514
|
}
|
|
2489
2515
|
}
|
|
2490
2516
|
async loadModel(e, t = {}) {
|
|
2491
2517
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadModel(e, t), {
|
|
2492
|
-
type:
|
|
2518
|
+
type: m.MODEL_LOADED,
|
|
2493
2519
|
url: e
|
|
2494
2520
|
}, {
|
|
2495
2521
|
kind: "url",
|
|
@@ -2499,7 +2525,7 @@ var Yn = class extends I {
|
|
|
2499
2525
|
}
|
|
2500
2526
|
async loadObject3D(e, t = "object3d") {
|
|
2501
2527
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadObject3D(e, t), {
|
|
2502
|
-
type:
|
|
2528
|
+
type: m.OBJECT3D_LOADED,
|
|
2503
2529
|
name: t
|
|
2504
2530
|
}, {
|
|
2505
2531
|
kind: "object3d",
|
|
@@ -2517,7 +2543,7 @@ var Yn = class extends I {
|
|
|
2517
2543
|
await this.assetLoader.loadEnvironment(e);
|
|
2518
2544
|
let t = this.meshScene.environment;
|
|
2519
2545
|
t && this.stages.pathTracer && await this.stages.pathTracer.environment.setEnvironmentMap(t), this.pipeline?.eventBus.emit("pipeline:lightingChanged"), this.reset(), this.dispatchEvent({
|
|
2520
|
-
type:
|
|
2546
|
+
type: m.ENVIRONMENT_LOADED,
|
|
2521
2547
|
url: e
|
|
2522
2548
|
});
|
|
2523
2549
|
} finally {
|
|
@@ -2536,31 +2562,31 @@ var Yn = class extends I {
|
|
|
2536
2562
|
...t,
|
|
2537
2563
|
filename: n
|
|
2538
2564
|
}), {
|
|
2539
|
-
type:
|
|
2565
|
+
type: m.MODEL_LOADED,
|
|
2540
2566
|
filename: n
|
|
2541
2567
|
}, {
|
|
2542
2568
|
kind: "url",
|
|
2543
2569
|
url: e,
|
|
2544
2570
|
filename: n,
|
|
2545
2571
|
cacheKey: t.cacheKey ?? null,
|
|
2546
|
-
...
|
|
2572
|
+
...Gn(t)
|
|
2547
2573
|
});
|
|
2548
2574
|
return;
|
|
2549
2575
|
}
|
|
2550
|
-
if (
|
|
2551
|
-
let n =
|
|
2576
|
+
if (Me(e)) {
|
|
2577
|
+
let n = je(e, { isModel: (e) => this.assetLoader?.getFileFormat(e)?.type === "model" });
|
|
2552
2578
|
if (n.files.length === 0) throw Error(`${n.name} holds no files to load`);
|
|
2553
2579
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadFolder(n, t), {
|
|
2554
|
-
type:
|
|
2580
|
+
type: m.MODEL_LOADED,
|
|
2555
2581
|
filename: n.name
|
|
2556
2582
|
}, async () => {
|
|
2557
|
-
let e = await
|
|
2583
|
+
let e = await Ae(n);
|
|
2558
2584
|
return {
|
|
2559
2585
|
kind: "local-folder",
|
|
2560
2586
|
folder: e,
|
|
2561
2587
|
key: D(e),
|
|
2562
2588
|
...n.flat ? { flat: !0 } : {},
|
|
2563
|
-
...
|
|
2589
|
+
...Gn(t)
|
|
2564
2590
|
};
|
|
2565
2591
|
}), this._sceneSourceInput = n;
|
|
2566
2592
|
return;
|
|
@@ -2568,14 +2594,14 @@ var Yn = class extends I {
|
|
|
2568
2594
|
let n = this.assetLoader?.getFileFormat(e?.name || "");
|
|
2569
2595
|
if (!n) throw this.assetLoader.formatError(e?.name || "");
|
|
2570
2596
|
if (n.type !== "environment" && n.type !== "image") {
|
|
2571
|
-
let n =
|
|
2597
|
+
let n = ke(e).catch(() => ({
|
|
2572
2598
|
name: e.name,
|
|
2573
2599
|
size: e.size,
|
|
2574
2600
|
lastModified: e.lastModified ?? 0,
|
|
2575
2601
|
sample: null
|
|
2576
2602
|
}));
|
|
2577
2603
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadAssetFromFile(e, t), {
|
|
2578
|
-
type:
|
|
2604
|
+
type: m.MODEL_LOADED,
|
|
2579
2605
|
filename: e.name
|
|
2580
2606
|
}, async () => {
|
|
2581
2607
|
let e = await n;
|
|
@@ -2583,7 +2609,7 @@ var Yn = class extends I {
|
|
|
2583
2609
|
kind: "local-file",
|
|
2584
2610
|
file: e,
|
|
2585
2611
|
key: e.sample ? D(e) : null,
|
|
2586
|
-
...
|
|
2612
|
+
...Gn(t)
|
|
2587
2613
|
};
|
|
2588
2614
|
}), this._sceneSourceInput = e;
|
|
2589
2615
|
return;
|
|
@@ -2594,7 +2620,7 @@ var Yn = class extends I {
|
|
|
2594
2620
|
await this.assetLoader.loadAssetFromFile(e);
|
|
2595
2621
|
let t = this.meshScene.environment;
|
|
2596
2622
|
t && this.stages.pathTracer && await this.stages.pathTracer.environment.applyHDRI(t), this.pipeline?.eventBus.emit("pipeline:lightingChanged"), this.reset(), this.dispatchEvent({
|
|
2597
|
-
type:
|
|
2623
|
+
type: m.ENVIRONMENT_LOADED,
|
|
2598
2624
|
filename: e.name
|
|
2599
2625
|
});
|
|
2600
2626
|
} finally {
|
|
@@ -2603,7 +2629,7 @@ var Yn = class extends I {
|
|
|
2603
2629
|
}
|
|
2604
2630
|
async loadExampleModels(e, t) {
|
|
2605
2631
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadExampleModels(e, t), {
|
|
2606
|
-
type:
|
|
2632
|
+
type: m.MODEL_LOADED,
|
|
2607
2633
|
index: e
|
|
2608
2634
|
}, {
|
|
2609
2635
|
kind: "url",
|
|
@@ -2620,7 +2646,7 @@ var Yn = class extends I {
|
|
|
2620
2646
|
this._loadingInProgress = !0;
|
|
2621
2647
|
try {
|
|
2622
2648
|
await this.loadSceneData(), this.reset(), this.dispatchEvent({
|
|
2623
|
-
type:
|
|
2649
|
+
type: m.TEXTURES_REPROCESSED,
|
|
2624
2650
|
maxTextureSize: r
|
|
2625
2651
|
});
|
|
2626
2652
|
} finally {
|
|
@@ -2632,24 +2658,24 @@ var Yn = class extends I {
|
|
|
2632
2658
|
return this._sceneSource ?? null;
|
|
2633
2659
|
}
|
|
2634
2660
|
get sceneSourceFile() {
|
|
2635
|
-
return this._sceneSourceInput && !
|
|
2661
|
+
return this._sceneSourceInput && !Me(this._sceneSourceInput) ? this._sceneSourceInput : null;
|
|
2636
2662
|
}
|
|
2637
2663
|
get sceneSourceFolder() {
|
|
2638
|
-
return
|
|
2664
|
+
return Me(this._sceneSourceInput) ? this._sceneSourceInput : null;
|
|
2639
2665
|
}
|
|
2640
2666
|
async _loadWithSceneRebuild(e, t, n = null) {
|
|
2641
2667
|
if (this._loadingInProgress) throw this._busyError("PathTracerApp");
|
|
2642
|
-
this._loadingInProgress = !0;
|
|
2668
|
+
this._loadingInProgress = !0, this.assetLoader && (this.assetLoader.maxEnvironmentWidth = this._memorySpill === !0 ? se : 0);
|
|
2643
2669
|
try {
|
|
2644
|
-
await e(), this._sceneSource = typeof n == "function" ? await n() : n, this._sceneSourceInput = null, this._emissiveSamplingUserSet = !1, this._clearAppendedModels(), this._modelReplaced(), await this.loadSceneData({ pendingEnvironment: this._beginSceneMetadataEnvironment() }), this._maybeSpill(), this.pipeline?.eventBus.emit("pipeline:lightingChanged"), this._dropDisplay(), this.reset(), this.dispatchEvent(t), this._modelAnnounced();
|
|
2670
|
+
await e(), this._sceneSource = typeof n == "function" ? await n() : n, this._sceneSourceInput = null, this._emissiveSamplingUserSet = !1, this._clearAppendedModels(), this._modelReplaced(), this._planSpill(), await this.loadSceneData({ pendingEnvironment: this._beginSceneMetadataEnvironment() }), this._maybeSpill(), this.pipeline?.eventBus.emit("pipeline:lightingChanged"), this._dropDisplay(), this.reset(), this.dispatchEvent(t), this._modelAnnounced();
|
|
2645
2671
|
} catch (e) {
|
|
2646
|
-
throw (!e || e.code !== "LOAD_IN_PROGRESS") && this._discardFailedLoad(), e?.code === "ARCHIVE_NEEDS_ELEMENT" ?
|
|
2672
|
+
throw (!e || e.code !== "LOAD_IN_PROGRESS") && this._discardFailedLoad(), e?.code === "ARCHIVE_NEEDS_ELEMENT" ? ce() : e?.code !== "LOAD_IN_PROGRESS" && v({
|
|
2647
2673
|
status: `Error: ${e?.message ?? e}`,
|
|
2648
2674
|
failed: !0,
|
|
2649
2675
|
progress: 100
|
|
2650
2676
|
}), e;
|
|
2651
2677
|
} finally {
|
|
2652
|
-
this._loadingInProgress = !1;
|
|
2678
|
+
this._loadingInProgress = !1, this._spillPlan = null;
|
|
2653
2679
|
}
|
|
2654
2680
|
}
|
|
2655
2681
|
_discardFailedLoad() {
|
|
@@ -2685,7 +2711,7 @@ var Yn = class extends I {
|
|
|
2685
2711
|
reset: !1,
|
|
2686
2712
|
source: Y.SCENE_METADATA
|
|
2687
2713
|
}), this.scene && (this.scene.background = e), this.dispatchEvent({
|
|
2688
|
-
type:
|
|
2714
|
+
type: m.SCENE_METADATA_APPLIED,
|
|
2689
2715
|
metadata: t,
|
|
2690
2716
|
environment: { ...n }
|
|
2691
2717
|
});
|
|
@@ -2702,7 +2728,7 @@ var Yn = class extends I {
|
|
|
2702
2728
|
reset: !1,
|
|
2703
2729
|
source: Y.SCENE_METADATA
|
|
2704
2730
|
}), this.dispatchEvent({
|
|
2705
|
-
type:
|
|
2731
|
+
type: m.SCENE_METADATA_APPLIED,
|
|
2706
2732
|
metadata: this.sceneMetadata,
|
|
2707
2733
|
environment: { enabled: !1 }
|
|
2708
2734
|
});
|
|
@@ -2717,14 +2743,14 @@ var Yn = class extends I {
|
|
|
2717
2743
|
source: i
|
|
2718
2744
|
});
|
|
2719
2745
|
this.dispatchEvent({
|
|
2720
|
-
type:
|
|
2746
|
+
type: m.SCENE_METADATA_APPLIED,
|
|
2721
2747
|
metadata: this.sceneMetadata,
|
|
2722
2748
|
environment: { enabled: this.settings.get("enableEnvironment") }
|
|
2723
2749
|
});
|
|
2724
2750
|
}
|
|
2725
2751
|
async loadSceneData({ pendingEnvironment: e = null, keepUserLights: t = !1 } = {}) {
|
|
2726
2752
|
this._releaseSceneState({ keepSelection: !!this._preserveSelectionOnRebuild }), this._tagPrimarySceneObject();
|
|
2727
|
-
let n = new
|
|
2753
|
+
let n = new d("", {
|
|
2728
2754
|
namespace: "scene",
|
|
2729
2755
|
level: "info"
|
|
2730
2756
|
}), r = () => this.stages.pathTracer.environment.envParams.mode === "hdri" ? this.meshScene.environment : null, i = r(), a = null;
|
|
@@ -2738,7 +2764,8 @@ var Yn = class extends I {
|
|
|
2738
2764
|
}), this.assetLoader?.flushPendingGraph(this._sdf.performanceMetrics.totalProcessingTime), n.end("BVH build (SceneProcessor)"), v({
|
|
2739
2765
|
status: "Transferring data to GPU...",
|
|
2740
2766
|
progress: 86
|
|
2741
|
-
}), await new Promise((e) => setTimeout(e, 0)), n.start("GPU data transfer"), !this._sdf.uploadToPathTracer(this.stages.pathTracer, this.lightManager, this.meshScene, r(), { keepUserLights: t })) return !1;
|
|
2767
|
+
}), await new Promise((e) => setTimeout(e, 0)), n.start("GPU data transfer"), await this._sdf.uploadChunks(this._chunkUploader()), !this._sdf.uploadToPathTracer(this.stages.pathTracer, this.lightManager, this.meshScene, r(), { keepUserLights: t })) return !1;
|
|
2768
|
+
for (let e of [...this._sdf.srgbBucketTextures ?? [], ...this._sdf.linearBucketTextures ?? []]) e && (this.renderer.initTexture(e), await this.stages.pathTracer.drainUploads());
|
|
2742
2769
|
this.stages.pathTracer._meshRefs = this.stages.pathTracer._collectMeshRefs(this.meshScene), this.stages.pathTracer.setMeshVisibilityData(this.stages.pathTracer._meshRefs), this._refreshEmissiveForVisibility(), n.end("GPU data transfer"), v({
|
|
2743
2770
|
status: "Compiling shaders...",
|
|
2744
2771
|
progress: 90
|
|
@@ -2751,16 +2778,16 @@ var Yn = class extends I {
|
|
|
2751
2778
|
let e = (this._sdf?.emissiveTriangleBuilder?.emissiveTriangles?.length ?? this._sdf?.emissiveTriangleCount ?? 0) > 0;
|
|
2752
2779
|
this.settings.set("enableEmissiveTriangleSampling", e, { reset: !1 });
|
|
2753
2780
|
}
|
|
2754
|
-
return n.start("Apply settings"), this.settings.applyAll(), this.stages.compositor.setTransparentBackground(this.settings.get("transparentBackground")), n.end("Apply settings"), n.print(this._sceneSummaryParts()),
|
|
2781
|
+
return n.start("Apply settings"), this.settings.applyAll(), this.stages.compositor.setTransparentBackground(this.settings.get("transparentBackground")), n.end("Apply settings"), n.print(this._sceneSummaryParts()), ce(), this._sceneRebuilt(), this.dispatchEvent({ type: m.SCENE_REBUILD }), !0;
|
|
2755
2782
|
}
|
|
2756
2783
|
_sceneSummaryParts() {
|
|
2757
2784
|
let e = this.stages.pathTracer, t = this._sdf?.instanceTable?.setCount ?? 0, n = this._sdf?.geometryExtractor?.maps?.length ?? 0;
|
|
2758
2785
|
return [
|
|
2759
|
-
|
|
2760
|
-
t ?
|
|
2761
|
-
|
|
2762
|
-
n ?
|
|
2763
|
-
|
|
2786
|
+
b.count(e.triangleCount, "tri"),
|
|
2787
|
+
t ? b.count(t, "mesh", "meshes") : null,
|
|
2788
|
+
b.count(e.materialData.materialCount, "material"),
|
|
2789
|
+
n ? b.count(n, "map") : null,
|
|
2790
|
+
b.count(e.bvhNodeCount, "BVH node")
|
|
2764
2791
|
];
|
|
2765
2792
|
}
|
|
2766
2793
|
_tagPrimarySceneObject() {
|
|
@@ -2782,7 +2809,7 @@ var Yn = class extends I {
|
|
|
2782
2809
|
try {
|
|
2783
2810
|
let { root: r } = await this.assetLoader.appendModel(e, { cacheKey: n });
|
|
2784
2811
|
return r.userData.__rayzeeSceneObject = !0, r.userData.__rayzeeSourceUrl = e, n && (r.userData.__rayzeeCacheKey = n), t && (r.userData.__rayzeeName = t), await this._finishRebuildNoReframe({
|
|
2785
|
-
type:
|
|
2812
|
+
type: m.MODEL_ADDED,
|
|
2786
2813
|
url: e,
|
|
2787
2814
|
id: r.uuid
|
|
2788
2815
|
}), r.uuid;
|
|
@@ -2796,7 +2823,7 @@ var Yn = class extends I {
|
|
|
2796
2823
|
try {
|
|
2797
2824
|
let { root: n } = this.assetLoader.appendObject3D(e, t || "object3d");
|
|
2798
2825
|
return n.userData.__rayzeeSceneObject = !0, t && (n.userData.__rayzeeName = t), await this._finishRebuildNoReframe({
|
|
2799
|
-
type:
|
|
2826
|
+
type: m.MODEL_ADDED,
|
|
2800
2827
|
id: n.uuid
|
|
2801
2828
|
}), n.uuid;
|
|
2802
2829
|
} finally {
|
|
@@ -2813,7 +2840,7 @@ var Yn = class extends I {
|
|
|
2813
2840
|
this._loadingInProgress = !0;
|
|
2814
2841
|
try {
|
|
2815
2842
|
return this._releaseSceneState(), n === this.sceneModel ? this.assetLoader.releaseTargetModel() : this.assetLoader.removeModelRoot(n), await this._finishRebuildNoReframe({
|
|
2816
|
-
type:
|
|
2843
|
+
type: m.SCENE_OBJECT_REMOVED,
|
|
2817
2844
|
id: e
|
|
2818
2845
|
}), !0;
|
|
2819
2846
|
} finally {
|
|
@@ -2823,29 +2850,55 @@ var Yn = class extends I {
|
|
|
2823
2850
|
setSceneObjectVisibility(e, t) {
|
|
2824
2851
|
return this.setMeshVisibilityByUuid(e, t);
|
|
2825
2852
|
}
|
|
2853
|
+
get memorySpill() {
|
|
2854
|
+
return this._memorySpill;
|
|
2855
|
+
}
|
|
2856
|
+
setMemorySpill(e) {
|
|
2857
|
+
this._memorySpill = e === !0 || e === !1 ? e : "auto";
|
|
2858
|
+
}
|
|
2859
|
+
get sceneSpilled() {
|
|
2860
|
+
return !!this._sdf?.spilling;
|
|
2861
|
+
}
|
|
2862
|
+
get geometryOnDisk() {
|
|
2863
|
+
return this._sdf?.geometryOnDisk === !0;
|
|
2864
|
+
}
|
|
2826
2865
|
_sceneBudgets(e) {
|
|
2827
|
-
return
|
|
2828
|
-
maxTriangles:
|
|
2829
|
-
maxPlacements:
|
|
2866
|
+
return this._memorySpill === !1 || !this.storage ? e : {
|
|
2867
|
+
maxTriangles: ie,
|
|
2868
|
+
maxPlacements: pe,
|
|
2830
2869
|
...e
|
|
2831
2870
|
};
|
|
2832
2871
|
}
|
|
2872
|
+
_planSpill() {
|
|
2873
|
+
let e = this._memorySpill !== !1 && !!this.storage && (this.assetLoader?.animations?.length ?? 0) === 0 && (this._memorySpill === !0 || this._sdf.needsSpill(this.meshScene));
|
|
2874
|
+
this.assetLoader && (this.assetLoader.maxEnvironmentWidth = e ? se : 0);
|
|
2875
|
+
let t = e ? this.meshScene?.environment : null, n = t?.image;
|
|
2876
|
+
return n && Ln(t, se), t && t.image !== n && (t.dispose(), t.needsUpdate = !0), e && this._memorySpill === "auto" && $.info("scene is past the in-memory line: building it through disk"), this._spillPlan = e, e;
|
|
2877
|
+
}
|
|
2833
2878
|
_progressiveSpill() {
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
return {
|
|
2879
|
+
let e = this._spillPlan ?? this._planSpill();
|
|
2880
|
+
return this._spillPlan = null, e ? {
|
|
2837
2881
|
storage: this.storage,
|
|
2838
|
-
uploader:
|
|
2839
|
-
};
|
|
2882
|
+
uploader: this._chunkUploader()
|
|
2883
|
+
} : null;
|
|
2884
|
+
}
|
|
2885
|
+
_chunkUploader() {
|
|
2886
|
+
let e = this.stages.pathTracer;
|
|
2887
|
+
return (t, n, r) => n === "triangles" ? e.createTriangleChunkUploader(t, r) : e.createChunkUploader(t);
|
|
2840
2888
|
}
|
|
2841
2889
|
_maybeSpill() {
|
|
2842
|
-
!this.
|
|
2843
|
-
type:
|
|
2890
|
+
!this._sdf?.spilling || !this.storage || (this._sdf.spillAfterLoad().catch((e) => this._issues.warn(S.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`)), this._sdf.spillToDisk(this.storage).then((e) => e && this.dispatchEvent({
|
|
2891
|
+
type: m.SCENE_SPILLED,
|
|
2844
2892
|
...e
|
|
2845
|
-
})).catch((e) => this._issues.warn(S.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`));
|
|
2893
|
+
})).catch((e) => this._issues.warn(S.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`)));
|
|
2894
|
+
}
|
|
2895
|
+
_scheduleRespill() {
|
|
2896
|
+
this._sdf?.spilling && (clearTimeout(this._respillTimer), this._respillTimer = setTimeout(() => {
|
|
2897
|
+
this._respillTimer = null, this._sdf?.respill().catch((e) => this._issues.warn(S.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`));
|
|
2898
|
+
}, Kn), this._respillTimer.unref?.());
|
|
2846
2899
|
}
|
|
2847
2900
|
async ensureSceneResident() {
|
|
2848
|
-
this._sdf?.spilled && await this._sdf.ensureResident();
|
|
2901
|
+
this._sdf?.spilled && await this._sdf.ensureResident(), await this._sdf?.ensureGeometryResident();
|
|
2849
2902
|
}
|
|
2850
2903
|
get sceneMeshes() {
|
|
2851
2904
|
return this._sdf?.meshes ?? [];
|
|
@@ -2871,39 +2924,40 @@ var Yn = class extends I {
|
|
|
2871
2924
|
}), r;
|
|
2872
2925
|
}
|
|
2873
2926
|
updateMeshTransforms(e) {
|
|
2927
|
+
if (this._sdf?.needsPageInForMove(e)) return this._sdf.ensureMovable(e).then(() => this.updateMeshTransforms(e)).catch((e) => this._issues.warn(S.STORAGE_READ_FAILED, `reading instance matrices back failed: ${e.message}`)), null;
|
|
2874
2928
|
this._notePlacementsMoving(e);
|
|
2875
2929
|
let t = this._sdf.updateMeshTransforms(e);
|
|
2876
|
-
return this.stages.pathTracer.updateBufferRanges([],
|
|
2930
|
+
return this.stages.pathTracer.updateBufferRanges([], this._sdf.takeMoveRanges()), this.reset(!1, { motion: !0 }), this._scheduleRespill(), t;
|
|
2877
2931
|
}
|
|
2878
2932
|
setReservedRenderResolution(e, { allowLower: n = !1 } = {}) {
|
|
2879
|
-
let
|
|
2933
|
+
let i = n ? e : Math.max(e, r);
|
|
2880
2934
|
if (!this.renderer) return this._pendingReservedRenderSize = {
|
|
2881
2935
|
requestedPx: e,
|
|
2882
2936
|
allowLower: n
|
|
2883
|
-
}, Math.max(256, Math.min(
|
|
2884
|
-
let
|
|
2885
|
-
if (
|
|
2937
|
+
}, Math.max(256, Math.min(f, Math.floor(i) || 256));
|
|
2938
|
+
let a = this.renderer.backend?.device?.limits?.maxStorageBufferBindingSize || 128 * 1024 * 1024, o = oe(this._hostMemoryGB), s = o.gb >= 8 && a >= 1024 * 1024 * 1024 ? f : 2048, c = t(Math.min(i, s));
|
|
2939
|
+
if (c < Math.floor(e) && this._issues.warn(S.RENDER_RESERVE_CAPPED, `reserved render size ${b.n(e)}px was capped to ${b.n(c)}px by this device's limits — renders above ${b.n(c)}px will be declined` + (o.assumed && o.gb < 8 ? " (host memory unknown, 4 GB assumed: pass hostMemoryGB)" : ""), {
|
|
2886
2940
|
requested: e,
|
|
2887
|
-
applied:
|
|
2888
|
-
deviceMemoryGB:
|
|
2889
|
-
assumed:
|
|
2890
|
-
maxStorageBufferBindingSize:
|
|
2891
|
-
}), (this.stages?.pathTracer?.storageTextures?.writeColor?.image?.width ??
|
|
2941
|
+
applied: c,
|
|
2942
|
+
deviceMemoryGB: o.gb,
|
|
2943
|
+
assumed: o.assumed,
|
|
2944
|
+
maxStorageBufferBindingSize: a
|
|
2945
|
+
}), (this.stages?.pathTracer?.storageTextures?.writeColor?.image?.width ?? c) !== c) {
|
|
2892
2946
|
let e = this.pauseRendering;
|
|
2893
2947
|
this.pauseRendering = !0;
|
|
2894
2948
|
try {
|
|
2895
2949
|
let e = this.renderer.domElement;
|
|
2896
|
-
(e.width >
|
|
2950
|
+
(e.width > c || e.height > c) && this.renderer.setSize(Math.min(e.width, c), Math.min(e.height, c), !1);
|
|
2897
2951
|
for (let e of Object.values(this.stages)) e?.reallocateReservedStorage?.();
|
|
2898
2952
|
} finally {
|
|
2899
2953
|
this.pauseRendering = e;
|
|
2900
2954
|
}
|
|
2901
2955
|
this.reset(), this.dispatchEvent({
|
|
2902
|
-
type:
|
|
2903
|
-
size:
|
|
2956
|
+
type: m.RESERVED_RENDER_SIZE_CHANGED,
|
|
2957
|
+
size: c
|
|
2904
2958
|
});
|
|
2905
2959
|
}
|
|
2906
|
-
return
|
|
2960
|
+
return c;
|
|
2907
2961
|
}
|
|
2908
2962
|
_applyPendingReservedRenderSize() {
|
|
2909
2963
|
let e = this._pendingReservedRenderSize;
|
|
@@ -2911,18 +2965,18 @@ var Yn = class extends I {
|
|
|
2911
2965
|
this._pendingReservedRenderSize = null;
|
|
2912
2966
|
let t = this.setReservedRenderResolution(e.requestedPx, { allowLower: e.allowLower });
|
|
2913
2967
|
this.dispatchEvent({
|
|
2914
|
-
type:
|
|
2968
|
+
type: m.RESERVED_RENDER_SIZE_CHANGED,
|
|
2915
2969
|
size: t
|
|
2916
2970
|
});
|
|
2917
2971
|
}
|
|
2918
2972
|
getReservedRenderResolution() {
|
|
2919
|
-
return
|
|
2973
|
+
return r;
|
|
2920
2974
|
}
|
|
2921
2975
|
_isRenderSizeSupported(e, t) {
|
|
2922
|
-
return e >
|
|
2976
|
+
return e > r || t > r ? (this._issues.record(S.RENDER_SIZE_DECLINED, `render resolution ${e}×${t} exceeds the ${r}px storage reserve — resize ignored, so output stays at the previous size. Raise it with setReservedRenderResolution( ${Math.max(e, t)} ) before init().`, {
|
|
2923
2977
|
width: e,
|
|
2924
2978
|
height: t,
|
|
2925
|
-
reserve:
|
|
2979
|
+
reserve: r
|
|
2926
2980
|
}), !1) : !0;
|
|
2927
2981
|
}
|
|
2928
2982
|
onResize() {
|
|
@@ -2933,7 +2987,7 @@ var Yn = class extends I {
|
|
|
2933
2987
|
}
|
|
2934
2988
|
_applyRenderResize(e, t) {
|
|
2935
2989
|
this._isRenderSizeSupported(e, t) && (this.pipeline?.setSize(this._scaled(e), this._scaled(t)), this._renderWidth = e, this._renderHeight = t, this._renderSizeChanged(e, t), this.needsReset = !0, this.dispatchEvent({
|
|
2936
|
-
type:
|
|
2990
|
+
type: m.RESOLUTION_CHANGED,
|
|
2937
2991
|
width: e,
|
|
2938
2992
|
height: t
|
|
2939
2993
|
}));
|
|
@@ -3053,7 +3107,7 @@ var Yn = class extends I {
|
|
|
3053
3107
|
}
|
|
3054
3108
|
let l = this._completionInfo();
|
|
3055
3109
|
this.completion.markComplete() && this.dispatchEvent({
|
|
3056
|
-
type:
|
|
3110
|
+
type: m.RENDER_COMPLETE,
|
|
3057
3111
|
...l
|
|
3058
3112
|
});
|
|
3059
3113
|
let u = t ? await this._finalDenoise() : !1, { reason: d, ...f } = l;
|
|
@@ -3072,9 +3126,9 @@ var Yn = class extends I {
|
|
|
3072
3126
|
}
|
|
3073
3127
|
getProvenance() {
|
|
3074
3128
|
let e = this.stages.pathTracer, t = this.color?.status();
|
|
3075
|
-
return
|
|
3076
|
-
engine:
|
|
3077
|
-
three:
|
|
3129
|
+
return i({
|
|
3130
|
+
engine: ue,
|
|
3131
|
+
three: yt,
|
|
3078
3132
|
adapter: this.adapterInfo ?? null,
|
|
3079
3133
|
mode: {
|
|
3080
3134
|
headless: this._headless,
|
|
@@ -3116,7 +3170,7 @@ var Yn = class extends I {
|
|
|
3116
3170
|
let t = await e.captureAccumulation();
|
|
3117
3171
|
return {
|
|
3118
3172
|
v: 1,
|
|
3119
|
-
engine:
|
|
3173
|
+
engine: ue,
|
|
3120
3174
|
savedAt: Date.now(),
|
|
3121
3175
|
samples: t.state.frameCount,
|
|
3122
3176
|
...t
|
|
@@ -3127,7 +3181,7 @@ var Yn = class extends I {
|
|
|
3127
3181
|
let t = this.stages.pathTracer;
|
|
3128
3182
|
if (!t) throw Error("restoreRenderCheckpoint: app is not initialized");
|
|
3129
3183
|
t.restoreAccumulation(e), this.needsReset = !1, this.dispatchEvent({
|
|
3130
|
-
type:
|
|
3184
|
+
type: m.RENDER_RESET,
|
|
3131
3185
|
restored: e.samples
|
|
3132
3186
|
});
|
|
3133
3187
|
}
|
|
@@ -3135,40 +3189,40 @@ var Yn = class extends I {
|
|
|
3135
3189
|
if (e !== "linear" && e !== "srgb" && !this.color?.hasConfig) throw Error(`renderToBuffer: colorSpace must be 'linear' or 'srgb' without a colour config loaded, got "${e}"`);
|
|
3136
3190
|
let r = this.stages?.pathTracer, i = r?.storageTextures?.readTarget;
|
|
3137
3191
|
if (!i) throw Error("renderToBuffer: no render target — call init() and render at least one sample");
|
|
3138
|
-
let { width:
|
|
3192
|
+
let { width: o, height: s } = r;
|
|
3139
3193
|
if (e === "srgb") {
|
|
3140
|
-
let r = n === "display" ? this._displaySource(i) : null,
|
|
3194
|
+
let r = n === "display" ? this._displaySource(i) : null, c = {
|
|
3141
3195
|
exposure: this.renderer.toneMappingExposure,
|
|
3142
3196
|
toneMapping: this.renderer.toneMapping,
|
|
3143
3197
|
saturation: this.settings.get("saturation") ?? 1,
|
|
3144
3198
|
preserveAlpha: t
|
|
3145
|
-
}, l = await this._toneMapOnGPU(r?.texture ?? null, i,
|
|
3199
|
+
}, l = await this._toneMapOnGPU(r?.texture ?? null, i, o, s, c);
|
|
3146
3200
|
return {
|
|
3147
|
-
data: l ??
|
|
3148
|
-
width:
|
|
3149
|
-
height:
|
|
3201
|
+
data: l ?? a(r ? await this._readTexture(r.texture, o, s) : await this.renderer.readRenderTargetPixelsAsync(i, 0, 0, o, s, 0), c),
|
|
3202
|
+
width: o,
|
|
3203
|
+
height: s,
|
|
3150
3204
|
colorSpace: e,
|
|
3151
3205
|
source: r?.source ?? "accumulation",
|
|
3152
3206
|
toneMappedOn: l ? "gpu" : "cpu"
|
|
3153
3207
|
};
|
|
3154
3208
|
}
|
|
3155
|
-
let { data:
|
|
3156
|
-
data: await this.renderer.readRenderTargetPixelsAsync(i, 0, 0,
|
|
3209
|
+
let { data: c, source: l } = n === "display" ? await this._readDisplaySource(i, o, s) : {
|
|
3210
|
+
data: await this.renderer.readRenderTargetPixelsAsync(i, 0, 0, o, s, 0),
|
|
3157
3211
|
source: "accumulation"
|
|
3158
3212
|
};
|
|
3159
3213
|
if (e === "linear") return {
|
|
3160
|
-
data:
|
|
3161
|
-
width:
|
|
3162
|
-
height:
|
|
3214
|
+
data: c,
|
|
3215
|
+
width: o,
|
|
3216
|
+
height: s,
|
|
3163
3217
|
colorSpace: e,
|
|
3164
3218
|
workingSpace: this.color?.workingSpace ?? null,
|
|
3165
3219
|
source: l
|
|
3166
3220
|
};
|
|
3167
|
-
let { rgba: u, colorSpace: d } = this.color.exportPixels(
|
|
3221
|
+
let { rgba: u, colorSpace: d } = this.color.exportPixels(c, e);
|
|
3168
3222
|
return {
|
|
3169
3223
|
data: u,
|
|
3170
|
-
width:
|
|
3171
|
-
height:
|
|
3224
|
+
width: o,
|
|
3225
|
+
height: s,
|
|
3172
3226
|
colorSpace: d,
|
|
3173
3227
|
source: l
|
|
3174
3228
|
};
|
|
@@ -3178,9 +3232,9 @@ var Yn = class extends I {
|
|
|
3178
3232
|
if (!a?.device) return this._toneMapFallback("the renderer has no WebGPU device");
|
|
3179
3233
|
try {
|
|
3180
3234
|
let o = e ? this._readbackPass().draw(e, n, r).texture : t.textures[0], s = a.get(o).texture;
|
|
3181
|
-
return s ? (this._readbackToneMapper ??= new
|
|
3235
|
+
return s ? (this._readbackToneMapper ??= new Pe(a.device, "rayzee:readback-tonemap", { input: "texture" }), this._readbackToneMapper.ensureSize(n, r), await this._readbackToneMapper.toRGBA8(s, i)) : this._toneMapFallback("the picture has no GPU texture yet");
|
|
3182
3236
|
} catch (e) {
|
|
3183
|
-
if (e instanceof
|
|
3237
|
+
if (e instanceof ve) throw e;
|
|
3184
3238
|
return this._toneMapFallback("the GPU pass threw", e);
|
|
3185
3239
|
} finally {
|
|
3186
3240
|
this._readbackToneMapper?.release(), e && this._textureReadback?.release();
|
|
@@ -3303,7 +3357,7 @@ var Yn = class extends I {
|
|
|
3303
3357
|
...this._canvasResources()
|
|
3304
3358
|
]);
|
|
3305
3359
|
let t = () => e.measure();
|
|
3306
|
-
this._addTrackedListener(this,
|
|
3360
|
+
this._addTrackedListener(this, m.SCENE_REBUILD, t), this._addTrackedListener(this, m.ENVIRONMENT_LOADED, t), this._addTrackedListener(this, m.RESOLUTION_CHANGED, t), this._vramWired = !0;
|
|
3307
3361
|
}
|
|
3308
3362
|
_collectStageTextures() {
|
|
3309
3363
|
let e = [], t = this.stages || {}, n = t.pathTracer;
|
|
@@ -3318,7 +3372,7 @@ var Yn = class extends I {
|
|
|
3318
3372
|
}
|
|
3319
3373
|
getSceneMinY() {
|
|
3320
3374
|
if (!this.meshScene) return 0;
|
|
3321
|
-
let e = new
|
|
3375
|
+
let e = new Qe().setFromObject(this.meshScene);
|
|
3322
3376
|
return Number.isFinite(e.min.y) ? e.min.y : 0;
|
|
3323
3377
|
}
|
|
3324
3378
|
getMaterialProperty(e, t) {
|
|
@@ -3328,7 +3382,7 @@ var Yn = class extends I {
|
|
|
3328
3382
|
return this.stages.pathTracer?.materialData.getMaterialPropertySource(e, t);
|
|
3329
3383
|
}
|
|
3330
3384
|
setMaterialProperty(e, t, n) {
|
|
3331
|
-
if (this._sdf?.spilled &&
|
|
3385
|
+
if (this._sdf?.spilled && c.has(t)) {
|
|
3332
3386
|
this.ensureSceneResident().then(() => this.setMaterialProperty(e, t, n));
|
|
3333
3387
|
return;
|
|
3334
3388
|
}
|
|
@@ -3351,10 +3405,17 @@ var Yn = class extends I {
|
|
|
3351
3405
|
return (this._sdf?.emissiveTriangleBuilder?.emissiveTriangles?.length ?? this._sdf?.emissiveTriangleCount ?? 0) > 0;
|
|
3352
3406
|
}
|
|
3353
3407
|
setMeshVisibility(e, t) {
|
|
3354
|
-
this.stages.pathTracer?.updateMeshVisibility(e, t)
|
|
3408
|
+
this._whenTLASEditable(() => this.stages.pathTracer?.updateMeshVisibility(e, t));
|
|
3355
3409
|
}
|
|
3356
3410
|
updateAllMeshVisibility() {
|
|
3357
|
-
this.stages.pathTracer?.updateAllMeshVisibility()
|
|
3411
|
+
this._whenTLASEditable(() => this.stages.pathTracer?.updateAllMeshVisibility());
|
|
3412
|
+
}
|
|
3413
|
+
_whenTLASEditable(e) {
|
|
3414
|
+
let t = () => {
|
|
3415
|
+
e(), this._refreshEmissiveForVisibility(), this.reset(), this._scheduleRespill();
|
|
3416
|
+
}, n = this._sdf?.whenTLASEditable();
|
|
3417
|
+
if (!n) return t();
|
|
3418
|
+
n.then(t).catch((e) => this._issues.warn(S.STORAGE_READ_FAILED, `reading the TLAS back failed: ${e.message}`));
|
|
3358
3419
|
}
|
|
3359
3420
|
getScene() {
|
|
3360
3421
|
return this.meshScene || this.scene;
|
|
@@ -3389,7 +3450,7 @@ var Yn = class extends I {
|
|
|
3389
3450
|
};
|
|
3390
3451
|
}
|
|
3391
3452
|
_readbackPass() {
|
|
3392
|
-
return this._textureReadback ??= new
|
|
3453
|
+
return this._textureReadback ??= new Yt(this.renderer);
|
|
3393
3454
|
}
|
|
3394
3455
|
_readTexture(e, t, n) {
|
|
3395
3456
|
return this._readbackPass().read(e, t, n);
|
|
@@ -3400,10 +3461,10 @@ var Yn = class extends I {
|
|
|
3400
3461
|
n.__rayzeeOriginalColorSpace === void 0 && (n.__rayzeeOriginalColorSpace = e.colorSpace);
|
|
3401
3462
|
let r = n.__rayzeeOriginalColorSpace;
|
|
3402
3463
|
if (delete n.ocioColorSpace, delete n.__rayzeeColorSpaceChoice, t == null) e.colorSpace = r, delete n.__rayzeeOriginalColorSpace;
|
|
3403
|
-
else if (t === "srgb" || t === "linear") e.colorSpace = t === "srgb" ?
|
|
3464
|
+
else if (t === "srgb" || t === "linear") e.colorSpace = t === "srgb" ? O : Fe, n.__rayzeeColorSpaceChoice = t;
|
|
3404
3465
|
else {
|
|
3405
3466
|
if (!this.color?.hasConfig) throw Error(`"${t}" needs a colour config loaded`);
|
|
3406
|
-
n.ocioColorSpace = t, e.colorSpace =
|
|
3467
|
+
n.ocioColorSpace = t, e.colorSpace = O;
|
|
3407
3468
|
}
|
|
3408
3469
|
e.needsUpdate = !0, this.stages.pathTracer?.sdfs && await this.rebuildMaterials();
|
|
3409
3470
|
}
|
|
@@ -3431,13 +3492,15 @@ var Yn = class extends I {
|
|
|
3431
3492
|
this.stages.pathTracer?.sdfs && (await this.rebuildMaterials(), this._uploadEmissivePayload(this._sdf?.rebuildEmissiveColors?.() ?? null)), t && await this.environmentManager?.buildEnvironmentCDF?.(), e?._isPhysicalSky && await this.environmentManager.generateProceduralSkyTexture(), this.environmentManager?.refreshSun?.(), this.reset();
|
|
3432
3493
|
}
|
|
3433
3494
|
async rebuildMaterials(e) {
|
|
3434
|
-
await this.ensureSceneResident()
|
|
3495
|
+
await this.ensureSceneResident();
|
|
3496
|
+
let t = this.stages.pathTracer;
|
|
3497
|
+
await t?.rebuildMaterials(e || this.meshScene), t?.triangleStorageNode?.withoutUV && this._sdf?.triangles && ee(e || this.meshScene) && (this._sdf.textureCoordinates = !0, t.setTriangleData(this._sdf.triangles, this._sdf.triangleCount, { textureCoordinates: !0 }), t.setupMaterial()), this.reset();
|
|
3435
3498
|
}
|
|
3436
3499
|
async _initRenderer() {
|
|
3437
|
-
if (
|
|
3500
|
+
if (de((e) => this.dispatchEvent(e)), typeof navigator > "u" || !navigator.gpu) throw Error("WebGPU is not available — outside a browser, install one as navigator.gpu (for Node, the `webgpu` package)");
|
|
3438
3501
|
let e = await navigator.gpu.requestAdapter({ powerPreference: "high-performance" });
|
|
3439
3502
|
if (!e) throw Error("Failed to get WebGPU adapter");
|
|
3440
|
-
this.adapterInfo =
|
|
3503
|
+
this.adapterInfo = $n(e), this.adapterInfo.isSoftware && (this._issues.warn(S.ADAPTER_SOFTWARE, `software GPU adapter "${this.adapterInfo.description || this.adapterInfo.vendor}" — renders are correct but orders of magnitude slower than hardware`, { ...this.adapterInfo }), $.warn(`software GPU adapter — check app.adapterInfo.isSoftware. ${this.adapterInfo.description}`));
|
|
3441
3504
|
let t = e.limits, n = { maxColorAttachmentBytesPerSample: 128 };
|
|
3442
3505
|
for (let e of [
|
|
3443
3506
|
"maxBufferSize",
|
|
@@ -3455,23 +3518,23 @@ var Yn = class extends I {
|
|
|
3455
3518
|
let r = t[e];
|
|
3456
3519
|
r !== void 0 && (n[e] = r);
|
|
3457
3520
|
}
|
|
3458
|
-
if (n.maxStorageBuffersPerShaderStage = Math.min(t.maxStorageBuffersPerShaderStage, 10), this.renderer = new
|
|
3521
|
+
if (n.maxStorageBuffersPerShaderStage = Math.min(t.maxStorageBuffersPerShaderStage, 10), this.renderer = new Ve({
|
|
3459
3522
|
canvas: this.canvas,
|
|
3460
3523
|
alpha: !0,
|
|
3461
3524
|
powerPreference: "high-performance",
|
|
3462
3525
|
requiredLimits: n
|
|
3463
|
-
}), await
|
|
3526
|
+
}), await Yn(this.renderer, this._headless), !this.renderer.backend?.isWebGPUBackend) throw Error("WebGPU backend unavailable — three.js fell back to WebGL2, which cannot run the path tracer's compute kernels. Check GPU process flags and driver support.");
|
|
3464
3527
|
let r = this.renderer.backend?.device;
|
|
3465
|
-
r?.lost && (this._gpuDevice = r, this._deviceLostHolder = { app: this },
|
|
3528
|
+
r?.lost && (this._gpuDevice = r, this._deviceLostHolder = { app: this }, Zn(r, this._deviceLostHolder), r.onuncapturederror = (e) => $.error("WebGPU uncaptured error:", e.error)), ze.setLTC(Dt.init()), this.renderer.outputColorSpace = O, this.renderer.toneMapping = Oe, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1), this.color.attachRenderer(this.renderer);
|
|
3466
3529
|
}
|
|
3467
3530
|
_initScenes() {
|
|
3468
|
-
this.scene = new H(), this.meshScene = new H(), this._sceneHelpers = new
|
|
3531
|
+
this.scene = new H(), this.meshScene = new H(), this._sceneHelpers = new Nt();
|
|
3469
3532
|
}
|
|
3470
3533
|
_initAssetPipeline() {
|
|
3471
|
-
this._sdf = new
|
|
3534
|
+
this._sdf = new u({
|
|
3472
3535
|
issues: this._issues,
|
|
3473
3536
|
...this._maxSceneBytes === void 0 ? {} : { maxSceneBytes: this._maxSceneBytes }
|
|
3474
|
-
}), this.assetLoader = new
|
|
3537
|
+
}), this.assetLoader = new In(this.meshScene, this.camera, null, {
|
|
3475
3538
|
issues: this._issues,
|
|
3476
3539
|
areaLightIntensityScale: () => this.settings.get("areaLightIntensityScale")
|
|
3477
3540
|
}), this.assetLoader.setRenderer(this.renderer), this.assetLoader.createFloorPlane();
|
|
@@ -3479,14 +3542,14 @@ var Yn = class extends I {
|
|
|
3479
3542
|
_initPipeline() {
|
|
3480
3543
|
this._createStages();
|
|
3481
3544
|
let { clientWidth: e, clientHeight: t } = this.canvas;
|
|
3482
|
-
this.pipeline = new
|
|
3545
|
+
this.pipeline = new Kt(this.renderer, e || 1, t || 1, { issues: this._issues }), this.pipeline.addStage(this.stages.pathTracer);
|
|
3483
3546
|
for (let e of this._extraStages) this.pipeline.addStage(e);
|
|
3484
3547
|
this.pipeline.addStage(this.stages.compositor);
|
|
3485
3548
|
let n = this.canvas.clientWidth || 1, r = this.canvas.clientHeight || 1;
|
|
3486
3549
|
this._displayWidth = n, this._displayHeight = r, this._renderWidth = n, this._renderHeight = r, this.pipeline.setSize(n, r);
|
|
3487
3550
|
}
|
|
3488
3551
|
async _initManagers() {
|
|
3489
|
-
this.lightManager = new
|
|
3552
|
+
this.lightManager = new Wn(this.scene, this._sceneHelpers, this.stages.pathTracer, {
|
|
3490
3553
|
onReset: () => this.reset(),
|
|
3491
3554
|
onLightRemoved: (e) => this._lightRemoved(e)
|
|
3492
3555
|
}), this.environmentManager = this.stages.pathTracer.environment, this.environmentManager.issues = this._issues, this.stages.pathTracer.issues = this._issues, this.environmentManager.callbacks.onLightingChanged = () => this.pipeline.eventBus.emit("pipeline:lightingChanged"), this.environmentManager.callbacks.onReset = () => this.reset();
|
|
@@ -3497,21 +3560,21 @@ var Yn = class extends I {
|
|
|
3497
3560
|
if (e.model) this._clearAppendedModels(), await this.loadSceneData({ pendingEnvironment: this._beginSceneMetadataEnvironment() });
|
|
3498
3561
|
else if (e.texture) {
|
|
3499
3562
|
let e = this.meshScene.environment;
|
|
3500
|
-
e && this.stages.pathTracer && await this.stages.pathTracer.environment.setEnvironmentMap(e),
|
|
3563
|
+
e && this.stages.pathTracer && await this.stages.pathTracer.environment.setEnvironmentMap(e), ce();
|
|
3501
3564
|
}
|
|
3502
3565
|
this.pauseRendering = !1, this.reset();
|
|
3503
3566
|
}
|
|
3504
3567
|
}, this._addTrackedListener(this.assetLoader, "load", this._onAssetLoaded), this.pipeline.eventBus.on("pathtracer:compiling", ({ compiling: e }) => this.dispatchEvent({
|
|
3505
|
-
type:
|
|
3568
|
+
type: m.SHADERS_COMPILING,
|
|
3506
3569
|
compiling: e
|
|
3507
3570
|
}));
|
|
3508
3571
|
}
|
|
3509
3572
|
_createStages() {
|
|
3510
|
-
this.stages.pathTracer = new
|
|
3573
|
+
this.stages.pathTracer = new l(this.renderer, this.scene, this.camera, {
|
|
3511
3574
|
hostMemoryGB: this._hostMemoryGB,
|
|
3512
3575
|
sortMaterials: this.settings.get("wavefrontSortMaterials")
|
|
3513
|
-
}), this._extraStages = this._createExtraStages(), this.stages.compositor = new
|
|
3514
|
-
saturation: this.settings.get("saturation") ??
|
|
3576
|
+
}), this._extraStages = this._createExtraStages(), this.stages.compositor = new Pt(this.renderer, {
|
|
3577
|
+
saturation: this.settings.get("saturation") ?? _.saturation,
|
|
3515
3578
|
pathTracer: this.stages.pathTracer,
|
|
3516
3579
|
displaySources: this._displaySources()
|
|
3517
3580
|
});
|
|
@@ -3520,13 +3583,13 @@ var Yn = class extends I {
|
|
|
3520
3583
|
let e = this.stages.pathTracer;
|
|
3521
3584
|
if (!e) return;
|
|
3522
3585
|
let t = this.completion.isLimitReached(e, this.settings.get("renderLimitMode"), this.settings.get("renderTimeLimit"));
|
|
3523
|
-
t && !e.isComplete ? e.isComplete = !0 : !t && e.isComplete && (e.isComplete = !1, this.completion.resumeFromPause(), this._completionReopened(), this.dispatchEvent({ type:
|
|
3586
|
+
t && !e.isComplete ? e.isComplete = !0 : !t && e.isComplete && (e.isComplete = !1, this.completion.resumeFromPause(), this._completionReopened(), this.dispatchEvent({ type: m.RENDER_RESET }), this.wake());
|
|
3524
3587
|
}
|
|
3525
3588
|
_forwardEvents(e, t) {
|
|
3526
3589
|
if (e) for (let n of t) this._addTrackedListener(e, n, (e) => this.dispatchEvent(e));
|
|
3527
3590
|
}
|
|
3528
3591
|
_createCamera() {
|
|
3529
|
-
let e = new
|
|
3592
|
+
let e = new Vn(60, this.canvas.clientWidth / this.canvas.clientHeight || 1, .01, 1e3);
|
|
3530
3593
|
return e.position.set(0, 0, 5), e;
|
|
3531
3594
|
}
|
|
3532
3595
|
_createExtraStages() {
|
|
@@ -3587,4 +3650,4 @@ var Yn = class extends I {
|
|
|
3587
3650
|
_disposeExtensions() {}
|
|
3588
3651
|
};
|
|
3589
3652
|
//#endregion
|
|
3590
|
-
export {
|
|
3653
|
+
export { Ft as _, sn as a, J as c, q as d, rn as f, zt as g, Bt as h, Vn as i, an as l, Vt as m, $n as n, Y as o, Kt as p, Wn as r, G as s, er as t, nn as u };
|