rayzee 11.2.1 → 11.4.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 +91 -34
- package/dist/ArchiveImporter-Cgyx5AF7.js +7860 -0
- package/dist/BidirectionalIntegrator-BKF-cwH2.js +954 -0
- package/dist/{BufferLayout-D_IBo2ci.js → BufferLayout-xPRH9jYD.js} +41 -5
- package/dist/{NeuralRetouch-Cr-otSW8.js → NeuralRetouch-C3Q2XqbF.js} +4 -3
- package/dist/{NeuralSuperRes-B7E3_M0t.js → NeuralSuperRes-DV5TtURP.js} +11 -5
- package/dist/{PathTracer-D6nbknj5.js → PathTracer-D3MvEaZK.js} +4384 -4618
- package/dist/{PhysicalSky-Dq5VSiCQ.js → PhysicalSky-CY4jiz6a.js} +2 -2
- package/dist/{RayzeeRenderer-DbjqO6v-.js → RayzeeRenderer-D23m6NqG.js} +486 -391
- package/dist/SolarLimb-bZE6y63S.js +762 -0
- package/dist/{ToneMapGPU-BOjpul7A.js → ToneMapGPU-CTDBvmmS.js} +31 -22
- 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 +1327 -838
- package/dist/rayzee.umd.js +146 -134
- package/dist/sceneCachePolicy-AKOEu2lf.js +1602 -0
- package/package.json +1 -1
- package/src/EngineDefaults.js +2 -2
- package/src/Passes/AIUpscaler.js +2 -0
- package/src/PathTracerApp.js +126 -19
- package/src/Pipeline/CompletionTracker.js +7 -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/ToneMapCPU.js +16 -4
- package/src/Processor/ToneMapGPU.js +30 -14
- 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 +221 -33
- package/src/RenderSettings.js +4 -2
- package/src/Stages/AutoExposure.js +484 -494
- package/src/Stages/Compositor.js +27 -6
- package/src/Stages/LocalExposure.js +546 -0
- package/src/Stages/NormalDepth.js +7 -12
- package/src/Stages/PathTracer.js +18 -21
- package/src/Stages/PathTracerStage.js +282 -103
- 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/index.js +1 -0
- package/src/integrators/BidirectionalIntegrator.js +20 -2
- package/src/managers/DenoisingManager.js +15 -19
- package/src/managers/InteractionManager.js +19 -6
- package/src/managers/MaterialDataManager.js +22 -5
- package/src/managers/UniformManager.js +3 -0
- package/src/managers/VideoRenderManager.js +30 -4
- package/src/neural/NeuralRetouch.js +1 -0
- package/src/neural/NeuralSuperRes.js +6 -1
- package/dist/ArchiveImporter-D_x863yu.js +0 -5198
- package/dist/BidirectionalIntegrator-DmkxxEOR.js +0 -946
- package/dist/SolarLimb-CPaeZVwz.js +0 -721
- package/dist/sceneCachePolicy-C4-4qwt6.js +0 -485
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { dt as e } from "./SolarLimb-
|
|
2
|
-
import {
|
|
3
|
-
import { n as
|
|
4
|
-
import {
|
|
5
|
-
import { i as x, r as
|
|
6
|
-
import {
|
|
7
|
-
import { i as
|
|
8
|
-
import { n as
|
|
9
|
-
import { a as
|
|
10
|
-
import { i as
|
|
11
|
-
import { n as
|
|
12
|
-
import { d as
|
|
13
|
-
import { i 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-D3MvEaZK.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 y, ot as ce, r as le, rt as ue, tt as de, u as fe, v as pe, x as b } from "./sceneCachePolicy-AKOEu2lf.js";
|
|
5
|
+
import { i as x, r as me } 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 Se, r as Ce, t as C } from "./ActiveColor-YvuQq44O.js";
|
|
11
|
+
import { n as w, r as we } from "./AssetConfig-DSEntE65.js";
|
|
12
|
+
import { d as Te, l as Ee, m as De, p as Oe, t as ke, u as T } from "./ViewTransforms-CYN7bq2w.js";
|
|
13
|
+
import { i as E, n as Ae, r as je } from "./identity-C1cLD1C0.js";
|
|
14
|
+
import { a as Me, i as Ne, t as Pe } from "./SceneMetadata-D2Sh-0e-.js";
|
|
15
|
+
import { t as Fe } from "./ToneMapGPU-CTDBvmmS.js";
|
|
16
|
+
import { LinearSRGBColorSpace as Ie, MeshBasicNodeMaterial as Le, NodeMaterial as Re, QuadMesh as D, 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, screenUV as Je, select as M, storage as Ye, texture as Xe, uint as Ze, uniform as N, uv as P, vec3 as F, vec4 as Qe } from "three/tsl";
|
|
18
|
+
import { Box3 as $e, BufferGeometry as et, CircleGeometry as tt, Color as nt, DataTexture as rt, DirectionalLight as it, DirectionalLightHelper as at, EquirectangularReflectionMapping as ot, EventDispatcher as I, FloatType as st, LinearFilter as ct, LinearSRGBColorSpace as lt, LoaderUtils as L, LoadingManager as ut, MathUtils as R, Mesh as dt, MeshPhysicalMaterial as ft, NearestFilter as pt, NoBlending as mt, NoToneMapping as ht, Object3D as gt, OrthographicCamera as _t, PerspectiveCamera as vt, PointLight as yt, PointLightHelper as bt, REVISION as xt, RGBAFormat as St, RectAreaLight as z, RenderTarget as Ct, SRGBColorSpace as B, Scene as V, SpotLight as wt, SpotLightHelper as Tt, TextureLoader as Et, UnsignedByteType as Dt, Vector2 as Ot, Vector3 as H } from "three";
|
|
19
|
+
import { RectAreaLightTexturesLib as kt } from "three/addons/lights/RectAreaLightTexturesLib.js";
|
|
20
|
+
import { RectAreaLightHelper as At } from "three/addons/helpers/RectAreaLightHelper.js";
|
|
21
|
+
import { GLTFLoader as jt } from "three/addons/loaders/GLTFLoader.js";
|
|
22
|
+
import { HDRLoader as Mt } from "three/addons/loaders/HDRLoader.js";
|
|
23
|
+
import { createMeshesFromMultiMaterialMesh as Nt } from "three/addons/utils/SceneUtils.js";
|
|
24
|
+
import { clone as Pt } from "three/addons/utils/SkeletonUtils.js";
|
|
25
25
|
//#region src/SceneHelpers.js
|
|
26
|
-
var
|
|
26
|
+
var Ft = class {
|
|
27
27
|
constructor() {
|
|
28
|
-
this.scene = new
|
|
28
|
+
this.scene = new V(), this._helpers = /* @__PURE__ */ new Map(), this.visible = !1;
|
|
29
29
|
}
|
|
30
30
|
add(e) {
|
|
31
31
|
if (this._helpers.has(e.uuid)) return this._helpers.get(e.uuid);
|
|
@@ -63,16 +63,21 @@ var jt = class {
|
|
|
63
63
|
this.clear();
|
|
64
64
|
}
|
|
65
65
|
_createHelper(e) {
|
|
66
|
-
return e.isRectAreaLight ? new
|
|
66
|
+
return e.isRectAreaLight ? new At(e) : e.isPointLight ? new bt(e, .5) : e.isSpotLight ? new Tt(e) : e.isDirectionalLight ? new at(e, .5) : null;
|
|
67
67
|
}
|
|
68
|
-
},
|
|
69
|
-
constructor(
|
|
68
|
+
}, It = class extends n {
|
|
69
|
+
constructor(e, t = {}) {
|
|
70
70
|
super("Compositor", {
|
|
71
|
-
...
|
|
72
|
-
executionMode:
|
|
73
|
-
}), this.renderer =
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
...t,
|
|
72
|
+
executionMode: s.ALWAYS
|
|
73
|
+
}), this.renderer = e, this._lightSources = [...t.displaySources ?? [], "pathtracer:color"], this.saturation = N(t.saturation ?? 1), this._transparentBackground = N(0, "int"), this._pathTracer = t.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(), this._displayGain = null, this.compositorMaterial = new Le(), this.compositorMaterial.blending = mt, this._buildColorNode(), this.compositorQuad = new D(this.compositorMaterial);
|
|
74
|
+
}
|
|
75
|
+
_buildColorNode() {
|
|
76
|
+
let t = this._sourceTexNode.sample(P()), n = this._displayGain ? t.xyz.mul(this._displayGain(t.xyz, Je)) : t.xyz, r = j(F(Ge(n, e)), n, this.saturation), i = M(this._transparentBackground, t.w, 1);
|
|
77
|
+
this.compositorMaterial.colorNode = Qe(r, i), this.compositorMaterial.needsUpdate = !0;
|
|
78
|
+
}
|
|
79
|
+
setDisplayGain(e) {
|
|
80
|
+
e !== this._displayGain && (this._displayGain = e, this._buildColorNode());
|
|
76
81
|
}
|
|
77
82
|
resolveLightTexture(e) {
|
|
78
83
|
return this.resolveLightSource(e)?.texture ?? null;
|
|
@@ -91,17 +96,17 @@ var jt = class {
|
|
|
91
96
|
let t = this._pathTracer?.getConvergenceDebugSource?.();
|
|
92
97
|
if (!t) return !1;
|
|
93
98
|
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(
|
|
99
|
+
this._debugMaterial?.dispose(), this._debugTexNode?.dispose(), this._debugM2Attr = t.m2, this._debugMaskAttr = t.frozenMask, this._debugTexNode = new Be();
|
|
100
|
+
let n = He(() => {
|
|
101
|
+
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 = Ze(A(P().y.mul(k(i))).min(i.sub(A(1))).max(A(0)).mul(r).add(a)).toVar(), s = Ye(t.m2, "float").toReadOnly().element(o).toVar(), c = Ye(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));
|
|
102
|
+
return Ue(m.greaterThanEqual(k(1)).or(_.not()), () => {
|
|
103
|
+
let e = j(F(1, .8, .1), F(1, .1, .05), m.sub(1).div(3).clamp(0, 1));
|
|
104
|
+
g.assign(j(h, e, .85));
|
|
105
|
+
}), Ue(c.equal(Ze(1)).and(u), () => {
|
|
106
|
+
g.assign(j(h, F(.1, .45, 1), .55));
|
|
102
107
|
}), g;
|
|
103
108
|
});
|
|
104
|
-
return this._debugMaterial = new
|
|
109
|
+
return this._debugMaterial = new Le(), this._debugMaterial.colorNode = Qe(n().pow(2.2).mul(this._debugExposureComp), 1), this._debugMaterial.blending = mt, this._debugQuad = new D(this._debugMaterial), !0;
|
|
105
110
|
}
|
|
106
111
|
render(e) {
|
|
107
112
|
if (!this.enabled) return;
|
|
@@ -109,7 +114,7 @@ var jt = class {
|
|
|
109
114
|
let t = e.getTexture("pathtracer:color");
|
|
110
115
|
if (t) {
|
|
111
116
|
this._debugTexNode.value = t;
|
|
112
|
-
let e = this.renderer.toneMapping !==
|
|
117
|
+
let e = this.renderer.toneMapping !== ht;
|
|
113
118
|
this._debugExposureComp.value = e ? 1 / Math.max(this.renderer.toneMappingExposure, 1e-4) : 1, this.renderer.setRenderTarget(null), this._debugQuad.render(this.renderer);
|
|
114
119
|
return;
|
|
115
120
|
}
|
|
@@ -129,7 +134,7 @@ var jt = class {
|
|
|
129
134
|
dispose() {
|
|
130
135
|
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
136
|
}
|
|
132
|
-
},
|
|
137
|
+
}, Lt = class {
|
|
133
138
|
constructor() {
|
|
134
139
|
this.textures = /* @__PURE__ */ new Map(), this.renderTargets = /* @__PURE__ */ new Map(), this.uniforms = /* @__PURE__ */ new Map(), this.state = {
|
|
135
140
|
frame: 0,
|
|
@@ -249,7 +254,7 @@ var jt = class {
|
|
|
249
254
|
dispose() {
|
|
250
255
|
this.textures.clear(), this.renderTargets.clear(), this.uniforms.clear(), this._stateChangeCallbacks.clear(), this.state = {};
|
|
251
256
|
}
|
|
252
|
-
},
|
|
257
|
+
}, Rt = class extends I {
|
|
253
258
|
constructor() {
|
|
254
259
|
super(), this._onceCallbacks = /* @__PURE__ */ new Map();
|
|
255
260
|
}
|
|
@@ -287,38 +292,38 @@ var jt = class {
|
|
|
287
292
|
eventNames() {
|
|
288
293
|
return this._listeners ? Object.keys(this._listeners) : [];
|
|
289
294
|
}
|
|
290
|
-
},
|
|
291
|
-
function
|
|
292
|
-
|
|
295
|
+
}, zt = !1, U = [], Bt = /* @__PURE__ */ new WeakMap();
|
|
296
|
+
function Vt(e) {
|
|
297
|
+
zt = !!e;
|
|
293
298
|
}
|
|
294
|
-
function
|
|
295
|
-
return
|
|
299
|
+
function Ht() {
|
|
300
|
+
return U.slice();
|
|
296
301
|
}
|
|
297
|
-
function
|
|
298
|
-
|
|
302
|
+
function Ut() {
|
|
303
|
+
U.length = 0;
|
|
299
304
|
}
|
|
300
|
-
function
|
|
305
|
+
function Wt(e) {
|
|
301
306
|
let t = [];
|
|
302
307
|
for (let n of Object.keys(e)) e[n]?.isTextureNode === !0 && t.push(n);
|
|
303
308
|
return t;
|
|
304
309
|
}
|
|
305
|
-
var
|
|
306
|
-
function
|
|
307
|
-
if (!
|
|
310
|
+
var Gt = (e) => !e || !e.image || !(e.image.width > 0);
|
|
311
|
+
function Kt(e, t, n) {
|
|
312
|
+
if (!zt) {
|
|
308
313
|
n();
|
|
309
314
|
return;
|
|
310
315
|
}
|
|
311
|
-
let r =
|
|
316
|
+
let r = Bt.get(e);
|
|
312
317
|
if (r || (r = {
|
|
313
318
|
phase: "pending",
|
|
314
319
|
unboundAtCompile: []
|
|
315
|
-
},
|
|
316
|
-
n(), r.phase === "watch" &&
|
|
320
|
+
}, Bt.set(e, r)), r.phase !== "pending") {
|
|
321
|
+
n(), r.phase === "watch" && qt(e, r);
|
|
317
322
|
return;
|
|
318
323
|
}
|
|
319
324
|
let i = Object.prototype.hasOwnProperty.call(t, "compute"), a = t.compute;
|
|
320
325
|
t.compute = function(...t) {
|
|
321
|
-
return r.phase === "pending" && (r.unboundAtCompile =
|
|
326
|
+
return r.phase === "pending" && (r.unboundAtCompile = Wt(e).filter((t) => Gt(e[t].value)), r.phase = r.unboundAtCompile.length < 2 ? "done" : "watch"), a.apply(this, t);
|
|
322
327
|
};
|
|
323
328
|
try {
|
|
324
329
|
n();
|
|
@@ -326,14 +331,14 @@ function Ht(e, t, n) {
|
|
|
326
331
|
i ? t.compute = a : delete t.compute;
|
|
327
332
|
}
|
|
328
333
|
}
|
|
329
|
-
function
|
|
334
|
+
function qt(e, t) {
|
|
330
335
|
let n = [];
|
|
331
336
|
for (let r of t.unboundAtCompile) {
|
|
332
337
|
let t = e[r]?.value;
|
|
333
|
-
if (
|
|
338
|
+
if (Gt(t)) return;
|
|
334
339
|
t.isStorageTexture !== !0 && n.push(r);
|
|
335
340
|
}
|
|
336
|
-
t.phase = "done", n.length !== 0 &&
|
|
341
|
+
t.phase = "done", n.length !== 0 && U.push({
|
|
337
342
|
stage: e.name,
|
|
338
343
|
nodes: n,
|
|
339
344
|
unboundAtCompile: t.unboundAtCompile.slice(),
|
|
@@ -342,7 +347,7 @@ function Ut(e, t) {
|
|
|
342
347
|
}
|
|
343
348
|
//#endregion
|
|
344
349
|
//#region src/Pipeline/RenderPipeline.js
|
|
345
|
-
var
|
|
350
|
+
var Jt = class {
|
|
346
351
|
_reportStageFailure(e, t, n) {
|
|
347
352
|
console.error(`[Pipeline] Error in stage '${e}' (${t}):`, n);
|
|
348
353
|
let r = `${e}:${t}`;
|
|
@@ -353,7 +358,7 @@ var Wt = class {
|
|
|
353
358
|
}));
|
|
354
359
|
}
|
|
355
360
|
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
|
|
361
|
+
this.renderer = e, this._issues = r, this._reportedStageFailures = /* @__PURE__ */ new Set(), this.width = t, this.height = n, this.stages = [], this.context = new Lt(), this.eventBus = new Rt(), this.context.setState("width", t), this.context.setState("height", n), this.stats = {
|
|
357
362
|
enabled: !1,
|
|
358
363
|
logSkipped: !1,
|
|
359
364
|
timings: /* @__PURE__ */ new Map(),
|
|
@@ -387,7 +392,7 @@ var Wt = class {
|
|
|
387
392
|
}
|
|
388
393
|
try {
|
|
389
394
|
let n = this.stats.enabled ? performance.now() : 0;
|
|
390
|
-
if (
|
|
395
|
+
if (Kt(t, this.renderer, () => t.render(this.context, e)), this.stats.enabled) {
|
|
391
396
|
let e = performance.now() - n;
|
|
392
397
|
this.stats.timings.has(t.name) || this.stats.timings.set(t.name, []);
|
|
393
398
|
let r = this.stats.timings.get(t.name);
|
|
@@ -485,7 +490,7 @@ var Wt = class {
|
|
|
485
490
|
let e = this.getInfo();
|
|
486
491
|
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
492
|
}
|
|
488
|
-
},
|
|
493
|
+
}, Yt = me("engine"), Xt = class {
|
|
489
494
|
constructor() {
|
|
490
495
|
this.timeElapsed = 0, this.lastResetTime = performance.now(), this.renderCompleteDispatched = !1, this.budgetOverrun = !1, this._budgetHeldWarned = !1;
|
|
491
496
|
}
|
|
@@ -493,7 +498,7 @@ var Wt = class {
|
|
|
493
498
|
this.timeElapsed = (performance.now() - this.lastResetTime) / 1e3;
|
|
494
499
|
}
|
|
495
500
|
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,
|
|
501
|
+
return this.budgetOverrun = !1, t !== "time" && t !== "timeOnly" || !(n > 0) || this.timeElapsed < n ? !1 : e?.frameCount > 0 ? (this.budgetOverrun = !0, !0) : (this._budgetHeldWarned || (this._budgetHeldWarned = !0, Yt.warn(`render time limit (${n}s) expired before the first sample landed — holding the deadline open to avoid capturing an empty frame`)), !1);
|
|
497
502
|
}
|
|
498
503
|
isLimitReached(e, t, n) {
|
|
499
504
|
return e ? this.isTimeLimitReached(e, t, n) ? !0 : this.stopCondition(e) !== null : !1;
|
|
@@ -510,17 +515,17 @@ var Wt = class {
|
|
|
510
515
|
resumeFromPause() {
|
|
511
516
|
this.renderCompleteDispatched = !1, this.lastResetTime = performance.now() - this.timeElapsed * 1e3;
|
|
512
517
|
}
|
|
513
|
-
},
|
|
518
|
+
}, Zt = class {
|
|
514
519
|
constructor(e) {
|
|
515
|
-
this.renderer = e, this.target = null, this.material = new
|
|
520
|
+
this.renderer = e, this.target = null, this.material = new Re(), this.material.name = "rayzee:texture-readback", this.quad = new D(this.material), this._node = null, this._source = null;
|
|
516
521
|
}
|
|
517
522
|
_ensureTarget(e, t) {
|
|
518
|
-
this.target && this.target.width === e && this.target.height === t || (this.target?.dispose(), this.target = new
|
|
519
|
-
type:
|
|
520
|
-
format:
|
|
523
|
+
this.target && this.target.width === e && this.target.height === t || (this.target?.dispose(), this.target = new Ct(e, t, {
|
|
524
|
+
type: st,
|
|
525
|
+
format: St,
|
|
521
526
|
depthBuffer: !1,
|
|
522
|
-
minFilter:
|
|
523
|
-
magFilter:
|
|
527
|
+
minFilter: pt,
|
|
528
|
+
magFilter: pt
|
|
524
529
|
}));
|
|
525
530
|
}
|
|
526
531
|
async read(e, t, n) {
|
|
@@ -531,7 +536,7 @@ var Wt = class {
|
|
|
531
536
|
}
|
|
532
537
|
}
|
|
533
538
|
draw(e, t, n) {
|
|
534
|
-
this._ensureTarget(t, n), this._source !== e && (this._node =
|
|
539
|
+
this._ensureTarget(t, n), this._source !== e && (this._node = Xe(e).load(Ke(qe.xy)), this.material.outputNode = this._node, this.material.needsUpdate = !0, this._source = e);
|
|
535
540
|
let r = this.renderer.getRenderTarget();
|
|
536
541
|
return this.renderer.setRenderTarget(this.target), this.quad.render(this.renderer), this.renderer.setRenderTarget(r), this.target;
|
|
537
542
|
}
|
|
@@ -541,15 +546,15 @@ var Wt = class {
|
|
|
541
546
|
dispose() {
|
|
542
547
|
this.target?.dispose(), this.material.dispose(), this.target = null, this._source = null, this._node = null;
|
|
543
548
|
}
|
|
544
|
-
},
|
|
549
|
+
}, Qt = 864e5, W = Object.freeze({
|
|
545
550
|
IMMUTABLE: "immutable",
|
|
546
551
|
REVALIDATE: "revalidate",
|
|
547
552
|
NETWORK: "network"
|
|
548
|
-
}),
|
|
553
|
+
}), G = (e, t) => ({
|
|
549
554
|
loaded: e,
|
|
550
555
|
total: t,
|
|
551
556
|
lengthComputable: t > 0 && e <= t
|
|
552
|
-
}), K = (e, t) => e.headers?.get?.(t) ?? null,
|
|
557
|
+
}), K = (e, t) => e.headers?.get?.(t) ?? null, $t = (e) => e.reason ?? new DOMException("aborted", "AbortError");
|
|
553
558
|
function q(e) {
|
|
554
559
|
try {
|
|
555
560
|
let t = new URL(e, globalThis.location?.href ?? "http://localhost/").pathname;
|
|
@@ -558,36 +563,36 @@ function q(e) {
|
|
|
558
563
|
return "download";
|
|
559
564
|
}
|
|
560
565
|
}
|
|
561
|
-
async function
|
|
566
|
+
async function en(e, { onProgress: t, signal: n }) {
|
|
562
567
|
let r = Number(K(e, "content-length")) || 0, i = K(e, "content-type") ?? "";
|
|
563
568
|
if (!e.body) return new Blob([await e.arrayBuffer()], { type: i });
|
|
564
569
|
let a = e.body.getReader(), o = [], s = 0;
|
|
565
570
|
for (;;) {
|
|
566
|
-
if (n?.aborted) throw a.cancel().catch(() => {}),
|
|
571
|
+
if (n?.aborted) throw a.cancel().catch(() => {}), $t(n);
|
|
567
572
|
let { done: e, value: i } = await a.read();
|
|
568
573
|
if (e) break;
|
|
569
|
-
o.push(i), s += i.length, t?.(
|
|
574
|
+
o.push(i), s += i.length, t?.(G(s, r));
|
|
570
575
|
}
|
|
571
576
|
return new Blob(o, { type: i });
|
|
572
577
|
}
|
|
573
|
-
var
|
|
578
|
+
var tn = (e, t, n) => new File([e], t, {
|
|
574
579
|
type: n || e.type,
|
|
575
580
|
lastModified: e.lastModified ?? Date.now()
|
|
576
|
-
}),
|
|
581
|
+
}), nn = () => {}, J = class {
|
|
577
582
|
constructor(e) {
|
|
578
583
|
this._storage = e, this._revalidating = /* @__PURE__ */ new Set();
|
|
579
584
|
}
|
|
580
585
|
get _area() {
|
|
581
|
-
return this._storage?.area(
|
|
586
|
+
return this._storage?.area(be.DOWNLOADS) ?? null;
|
|
582
587
|
}
|
|
583
|
-
async fetch(e, { key: t = e, name: n = q(e), policy: r =
|
|
588
|
+
async fetch(e, { key: t = e, name: n = q(e), policy: r = W.REVALIDATE, maxAgeMs: i = Qt, onProgress: a = null, signal: o = null, fetchOptions: s = {} } = {}) {
|
|
584
589
|
let c = this._area;
|
|
585
|
-
if (c && r !==
|
|
590
|
+
if (c && r !== W.NETWORK) {
|
|
586
591
|
let o = await c.open(t);
|
|
587
592
|
if (o) {
|
|
588
593
|
let c = await o.file("data");
|
|
589
|
-
if (c) return r ===
|
|
590
|
-
file:
|
|
594
|
+
if (c) return r === W.REVALIDATE && Date.now() - (o.extra.checkedAt ?? 0) >= i && this._revalidate(e, t, n, o.extra, s), a?.(G(c.size, c.size)), {
|
|
595
|
+
file: tn(c, n, o.extra.contentType),
|
|
591
596
|
release: () => o.release(),
|
|
592
597
|
fromCache: !0
|
|
593
598
|
};
|
|
@@ -605,7 +610,7 @@ var Qt = (e, t, n) => new File([e], t, {
|
|
|
605
610
|
return await this._area?.has(e) === !0;
|
|
606
611
|
}
|
|
607
612
|
async _download(e, t, n, { onProgress: r, signal: i, fetchOptions: a, cache: o }) {
|
|
608
|
-
if (i?.aborted) throw
|
|
613
|
+
if (i?.aborted) throw $t(i);
|
|
609
614
|
let s = await fetch(e, {
|
|
610
615
|
...a,
|
|
611
616
|
signal: i
|
|
@@ -622,17 +627,17 @@ var Qt = (e, t, n) => new File([e], t, {
|
|
|
622
627
|
expectedBytes: c
|
|
623
628
|
}) : null;
|
|
624
629
|
if (!u) return {
|
|
625
|
-
file:
|
|
630
|
+
file: tn(await en(s, {
|
|
626
631
|
onProgress: r,
|
|
627
632
|
signal: i
|
|
628
633
|
}), n, l.contentType),
|
|
629
|
-
release:
|
|
634
|
+
release: nn,
|
|
630
635
|
fromCache: !1
|
|
631
636
|
};
|
|
632
637
|
try {
|
|
633
638
|
await u.writeStream("data", s.body, {
|
|
634
639
|
signal: i,
|
|
635
|
-
onProgress: (e) => r?.(
|
|
640
|
+
onProgress: (e) => r?.(G(e, c))
|
|
636
641
|
}), await u.commit(l);
|
|
637
642
|
} catch (o) {
|
|
638
643
|
if (await u.abort(), o?.name !== "QuotaExceededError") throw o;
|
|
@@ -646,7 +651,7 @@ var Qt = (e, t, n) => new File([e], t, {
|
|
|
646
651
|
let d = await this._area.open(t, { wait: !0 }), f = d && await d.file("data");
|
|
647
652
|
if (!f) throw d?.release(), Error(`storage: ${n} vanished right after it was saved`);
|
|
648
653
|
return {
|
|
649
|
-
file:
|
|
654
|
+
file: tn(f, n, l.contentType),
|
|
650
655
|
release: () => d.release(),
|
|
651
656
|
fromCache: !1
|
|
652
657
|
};
|
|
@@ -683,16 +688,16 @@ var Qt = (e, t, n) => new File([e], t, {
|
|
|
683
688
|
}
|
|
684
689
|
}
|
|
685
690
|
};
|
|
686
|
-
function
|
|
691
|
+
function rn(e, t, n) {
|
|
687
692
|
return new J(t).fetch(e, n);
|
|
688
693
|
}
|
|
689
|
-
function
|
|
690
|
-
return new J(
|
|
694
|
+
function an() {
|
|
695
|
+
return new J(ye(w().cacheNamespace));
|
|
691
696
|
}
|
|
692
|
-
async function
|
|
697
|
+
async function on(e, { downloads: t = an(), ...n } = {}) {
|
|
693
698
|
if (!t._storage || !/^https?:/i.test(e)) return {
|
|
694
699
|
url: e,
|
|
695
|
-
release:
|
|
700
|
+
release: nn,
|
|
696
701
|
cached: !1
|
|
697
702
|
};
|
|
698
703
|
let { file: r, release: i } = await t.fetch(e, n), a = URL.createObjectURL(r);
|
|
@@ -706,7 +711,7 @@ async function nn(e, { downloads: t = tn(), ...n } = {}) {
|
|
|
706
711
|
}
|
|
707
712
|
//#endregion
|
|
708
713
|
//#region src/RenderSettings.js
|
|
709
|
-
var
|
|
714
|
+
var sn = {
|
|
710
715
|
maxBounces: {
|
|
711
716
|
uniform: "maxBounces",
|
|
712
717
|
reset: !0
|
|
@@ -932,9 +937,9 @@ var rn = {
|
|
|
932
937
|
HOST: "host",
|
|
933
938
|
SCENE_METADATA: "scene-metadata",
|
|
934
939
|
MODE_PRESET: "mode-preset"
|
|
935
|
-
}),
|
|
936
|
-
constructor(e =
|
|
937
|
-
super(), this._issues = t, this._defaults = e, this._routes = new Map(Object.entries(
|
|
940
|
+
}), cn = class extends I {
|
|
941
|
+
constructor(e = _, { issues: t = null } = {}) {
|
|
942
|
+
super(), this._issues = t, this._defaults = e, this._routes = new Map(Object.entries(sn)), this._values = /* @__PURE__ */ new Map(), this._sources = /* @__PURE__ */ new Map(), this._pathTracer = null, this._resetCallback = null, this._handlers = {}, this._initDefaults(e);
|
|
938
943
|
}
|
|
939
944
|
bind(e) {
|
|
940
945
|
this._pathTracer = e.stages.pathTracer, this._resetCallback = e.resetCallback, this._handlers = this._buildHandlers(e);
|
|
@@ -949,12 +954,12 @@ var rn = {
|
|
|
949
954
|
!this._values.has(e) && i !== void 0 && (this._values.set(e, i), this._sources.set(e, Y.DEFAULT));
|
|
950
955
|
}
|
|
951
956
|
_buildHandlers({ stages: e, resetCallback: t, reconcileCompletion: n, applyExposure: r, onCameraProjection: i }) {
|
|
952
|
-
let a = new
|
|
957
|
+
let a = new Ot(), o = (t, n) => {
|
|
953
958
|
a.set(n?.[0] ?? 0, n?.[1] ?? 0).multiplyScalar(R.DEG2RAD), e.pathTracer?.setUniform(t, a);
|
|
954
959
|
};
|
|
955
960
|
return {
|
|
956
961
|
handleCameraProjection: (t) => {
|
|
957
|
-
e.pathTracer?.setUniform("cameraProjection",
|
|
962
|
+
e.pathTracer?.setUniform("cameraProjection", re[t] ?? re.perspective), i?.(t);
|
|
958
963
|
},
|
|
959
964
|
handleDofMode: (t) => e.pathTracer?.setUniform("dofMode", +(t === "look")),
|
|
960
965
|
handlePanoramaLonRange: (e) => o("panoLonRange", e),
|
|
@@ -963,7 +968,7 @@ var rn = {
|
|
|
963
968
|
e.pathTracer?.setUniform("transparentBackground", t), e.compositor?.setTransparentBackground(t);
|
|
964
969
|
},
|
|
965
970
|
handleBackgroundColor: (t) => {
|
|
966
|
-
let n = t?.isColor ? t : new
|
|
971
|
+
let n = t?.isColor ? t : new nt(t);
|
|
967
972
|
e.pathTracer?.setUniform("backgroundColor", n);
|
|
968
973
|
},
|
|
969
974
|
handleExposure: (e) => {
|
|
@@ -976,13 +981,13 @@ var rn = {
|
|
|
976
981
|
e.pathTracer?.setUniform("convergenceOverlay", n), e.compositor?.setConvergenceOverlay(n), n && !this.get("useAdaptiveSampling") && t?.();
|
|
977
982
|
},
|
|
978
983
|
handleRenderLimitMode: (t) => {
|
|
979
|
-
e.pathTracer?.setRenderLimitMode?.(t), n?.();
|
|
984
|
+
e.pathTracer?.setRenderLimitMode?.(t, this.get("renderTimeLimit")), n?.();
|
|
980
985
|
},
|
|
981
986
|
handleMaxSamples: (t) => {
|
|
982
987
|
e.pathTracer?.setUniform("maxSamples", t), e.pathTracer?.updateCompletionThreshold(), n?.();
|
|
983
988
|
},
|
|
984
|
-
handleRenderTimeLimit: () => {
|
|
985
|
-
n?.();
|
|
989
|
+
handleRenderTimeLimit: (t) => {
|
|
990
|
+
e.pathTracer?.setRenderLimitMode?.(this.get("renderLimitMode"), t), n?.();
|
|
986
991
|
},
|
|
987
992
|
handleRenderMode: (t) => {
|
|
988
993
|
e.pathTracer?.setUniform("renderMode", parseInt(t));
|
|
@@ -1007,7 +1012,7 @@ var rn = {
|
|
|
1007
1012
|
set(e, t, { reset: n, silent: r, source: i = Y.HOST } = {}) {
|
|
1008
1013
|
let a = this._applyOne(e, t, i);
|
|
1009
1014
|
a?.route && ((n === void 0 ? a.route.reset ?? !0 : n) && this._resetCallback?.(), r || this.dispatchEvent({
|
|
1010
|
-
type:
|
|
1015
|
+
type: m.SETTING_CHANGED,
|
|
1011
1016
|
key: e,
|
|
1012
1017
|
value: t,
|
|
1013
1018
|
prev: a.prev
|
|
@@ -1018,7 +1023,7 @@ var rn = {
|
|
|
1018
1023
|
for (let [n, a] of Object.entries(e)) {
|
|
1019
1024
|
let e = this._applyOne(n, a, r);
|
|
1020
1025
|
e?.route && ((e.route.reset ?? !0) && (i = !0), t || this.dispatchEvent({
|
|
1021
|
-
type:
|
|
1026
|
+
type: m.SETTING_CHANGED,
|
|
1022
1027
|
key: n,
|
|
1023
1028
|
value: a,
|
|
1024
1029
|
prev: e.prev
|
|
@@ -1061,14 +1066,14 @@ var rn = {
|
|
|
1061
1066
|
let e = {};
|
|
1062
1067
|
for (let [t, n] of this._values) {
|
|
1063
1068
|
if (this._sources.get(t) !== Y.HOST || !this._routes.has(t)) continue;
|
|
1064
|
-
let r =
|
|
1069
|
+
let r = i(n);
|
|
1065
1070
|
r !== void 0 && (e[t] = r);
|
|
1066
1071
|
}
|
|
1067
1072
|
return e;
|
|
1068
1073
|
}
|
|
1069
1074
|
restore(e) {
|
|
1070
1075
|
let t = {}, n = [];
|
|
1071
|
-
for (let [r, i] of Object.entries(e ?? {})) this._routes.has(r) ? t[r] =
|
|
1076
|
+
for (let [r, i] of Object.entries(e ?? {})) this._routes.has(r) ? t[r] = o(i) : n.push(r);
|
|
1072
1077
|
return this.setMany(t), n;
|
|
1073
1078
|
}
|
|
1074
1079
|
applyAll() {
|
|
@@ -1081,19 +1086,19 @@ var rn = {
|
|
|
1081
1086
|
e.uniform ? this._pathTracer?.setUniform(e.uniform, t) : e.handler ? this._handlers[e.handler]?.(t, n) : e.apply?.(t, n);
|
|
1082
1087
|
}
|
|
1083
1088
|
_initDefaults(e) {
|
|
1084
|
-
for (let t of Object.keys(
|
|
1089
|
+
for (let t of Object.keys(sn)) t in e && (this._values.set(t, e[t]), this._sources.set(t, Y.DEFAULT));
|
|
1085
1090
|
}
|
|
1086
|
-
},
|
|
1091
|
+
}, ln = class {
|
|
1087
1092
|
constructor({ issues: e = null } = {}) {
|
|
1088
|
-
this._issues = e, this._renderer = null, this._offRegistry =
|
|
1089
|
-
this._renderer &&
|
|
1093
|
+
this._issues = e, this._renderer = null, this._offRegistry = Oe(() => {
|
|
1094
|
+
this._renderer && De(this._renderer);
|
|
1090
1095
|
});
|
|
1091
1096
|
}
|
|
1092
1097
|
get hasConfig() {
|
|
1093
1098
|
return !1;
|
|
1094
1099
|
}
|
|
1095
1100
|
get workingSpace() {
|
|
1096
|
-
return
|
|
1101
|
+
return C;
|
|
1097
1102
|
}
|
|
1098
1103
|
get workingSpaceAdopted() {
|
|
1099
1104
|
return !1;
|
|
@@ -1103,23 +1108,23 @@ var rn = {
|
|
|
1103
1108
|
}
|
|
1104
1109
|
attachRenderer(e) {
|
|
1105
1110
|
this._renderer = e;
|
|
1106
|
-
let t =
|
|
1107
|
-
return e.outputColorSpace =
|
|
1111
|
+
let t = De(e);
|
|
1112
|
+
return e.outputColorSpace = B, t;
|
|
1108
1113
|
}
|
|
1109
1114
|
listViews() {
|
|
1110
|
-
return
|
|
1115
|
+
return Te();
|
|
1111
1116
|
}
|
|
1112
1117
|
get activeView() {
|
|
1113
1118
|
return null;
|
|
1114
1119
|
}
|
|
1115
1120
|
setActiveView(e) {
|
|
1116
|
-
let t =
|
|
1121
|
+
let t = T(e);
|
|
1117
1122
|
if (!t) throw Error(`no view transform with id ${e}`);
|
|
1118
1123
|
if (t.outputEncoded) throw Error(`"${t.name}" returns display-encoded colour: it needs rayzee/addons/color`);
|
|
1119
1124
|
return this._renderer && (this._renderer.toneMapping = e), t;
|
|
1120
1125
|
}
|
|
1121
1126
|
_publishWorkingMatrix() {
|
|
1122
|
-
|
|
1127
|
+
xe(null, C);
|
|
1123
1128
|
}
|
|
1124
1129
|
loadConfig() {
|
|
1125
1130
|
let e = "colour configs need the OCIO pipeline: renderer.setColorManagement( ColorManagement ), from rayzee/addons/color";
|
|
@@ -1130,14 +1135,14 @@ var rn = {
|
|
|
1130
1135
|
exportPixels(e) {
|
|
1131
1136
|
return {
|
|
1132
1137
|
rgba: e,
|
|
1133
|
-
colorSpace:
|
|
1138
|
+
colorSpace: C
|
|
1134
1139
|
};
|
|
1135
1140
|
}
|
|
1136
1141
|
status() {
|
|
1137
|
-
let e = this._renderer ?
|
|
1142
|
+
let e = this._renderer ? T(this._renderer.toneMapping) : null;
|
|
1138
1143
|
return {
|
|
1139
1144
|
config: null,
|
|
1140
|
-
workingSpace:
|
|
1145
|
+
workingSpace: C,
|
|
1141
1146
|
workingSpaceAdopted: !1,
|
|
1142
1147
|
activeTransform: e ? {
|
|
1143
1148
|
id: e.id,
|
|
@@ -1147,23 +1152,23 @@ var rn = {
|
|
|
1147
1152
|
activeView: null,
|
|
1148
1153
|
context: null,
|
|
1149
1154
|
exportSpace: null,
|
|
1150
|
-
views:
|
|
1151
|
-
registryVersion:
|
|
1155
|
+
views: Te(),
|
|
1156
|
+
registryVersion: Ee(),
|
|
1152
1157
|
bakeError: e?.error ?? null
|
|
1153
1158
|
};
|
|
1154
1159
|
}
|
|
1155
1160
|
dispose() {
|
|
1156
|
-
this._offRegistry?.(), this._renderer = null, this._issues = null,
|
|
1161
|
+
this._offRegistry?.(), this._renderer = null, this._issues = null, Ce() === this && (xe(null), Se(null));
|
|
1157
1162
|
}
|
|
1158
|
-
},
|
|
1163
|
+
}, un = [
|
|
1159
1164
|
[/\.jpe?g(\?|#|$)/i, "image/jpeg"],
|
|
1160
1165
|
[/\.webp(\?|#|$)/i, "image/webp"],
|
|
1161
1166
|
[/\.avif(\?|#|$)/i, "image/avif"]
|
|
1162
1167
|
];
|
|
1163
|
-
function
|
|
1164
|
-
return e.mimeType ? e.mimeType : e.uri?.startsWith("data:") ? e.uri.slice(5, e.uri.indexOf(";")) :
|
|
1168
|
+
function dn(e) {
|
|
1169
|
+
return e.mimeType ? e.mimeType : e.uri?.startsWith("data:") ? e.uri.slice(5, e.uri.indexOf(";")) : un.find(([t]) => t.test(e.uri ?? ""))?.[1] ?? "image/png";
|
|
1165
1170
|
}
|
|
1166
|
-
function
|
|
1171
|
+
function fn(e) {
|
|
1167
1172
|
for (let t = 8; t + 12 <= e.length;) {
|
|
1168
1173
|
let n = (e[t] << 24 | e[t + 1] << 16 | e[t + 2] << 8 | e[t + 3]) >>> 0, r = t + 12 + n;
|
|
1169
1174
|
if (e[t + 4] === 73 && e[t + 5] === 69 && e[t + 6] === 78 && e[t + 7] === 68) return e.subarray(0, r);
|
|
@@ -1171,48 +1176,48 @@ function ln(e) {
|
|
|
1171
1176
|
}
|
|
1172
1177
|
return e;
|
|
1173
1178
|
}
|
|
1174
|
-
function
|
|
1179
|
+
function pn({ data: e, width: t, height: n }, { shared: r = !1 } = {}) {
|
|
1175
1180
|
let i = new Uint8Array(e.buffer, e.byteOffset, t * n * 4), a = i;
|
|
1176
1181
|
r && typeof SharedArrayBuffer < "u" && !(i.buffer instanceof SharedArrayBuffer) && (a = new Uint8Array(new SharedArrayBuffer(i.byteLength)), a.set(i));
|
|
1177
|
-
let o = new
|
|
1182
|
+
let o = new rt(a, t, n, St, Dt);
|
|
1178
1183
|
return o.needsUpdate = !0, o;
|
|
1179
1184
|
}
|
|
1180
|
-
function
|
|
1181
|
-
return b().decodeImage(t === "image/png" ?
|
|
1185
|
+
function mn(e, t) {
|
|
1186
|
+
return b().decodeImage(t === "image/png" ? fn(e) : e, t);
|
|
1182
1187
|
}
|
|
1183
|
-
async function
|
|
1188
|
+
async function hn(e) {
|
|
1184
1189
|
let t = await fetch(e);
|
|
1185
1190
|
if (!t.ok) throw Error(`HTTP ${t.status}`);
|
|
1186
1191
|
return new Uint8Array(await t.arrayBuffer());
|
|
1187
1192
|
}
|
|
1188
|
-
function
|
|
1189
|
-
return t.bufferView === void 0 ?
|
|
1193
|
+
function gn(e, t) {
|
|
1194
|
+
return t.bufferView === void 0 ? hn(e.options.manager.resolveURL(L.resolveURL(t.uri, e.options.path))) : e.getDependency("bufferView", t.bufferView).then((e) => new Uint8Array(e));
|
|
1190
1195
|
}
|
|
1191
|
-
var
|
|
1192
|
-
function
|
|
1196
|
+
var _n = (e, t) => !!t && t !== e.textureLoader && typeof t.parse == "function";
|
|
1197
|
+
function vn(e, t, n) {
|
|
1193
1198
|
if (e.sourceCache[t] !== void 0) return e.sourceCache[t].then((e) => e.clone());
|
|
1194
|
-
let r =
|
|
1199
|
+
let r = gn(e, e.json.images[t]).then((e) => new Promise((t, r) => {
|
|
1195
1200
|
n.parse(e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength), t, r);
|
|
1196
1201
|
}));
|
|
1197
1202
|
return e.sourceCache[t] = r, r;
|
|
1198
1203
|
}
|
|
1199
|
-
async function
|
|
1200
|
-
let n =
|
|
1204
|
+
async function yn(e, t = dn({ uri: e })) {
|
|
1205
|
+
let n = pn(await mn(await hn(e), t));
|
|
1201
1206
|
return n.flipY = !0, n;
|
|
1202
1207
|
}
|
|
1203
|
-
function
|
|
1208
|
+
function bn(e, t = null) {
|
|
1204
1209
|
return e.loadImageSource = function(e, n) {
|
|
1205
|
-
if (
|
|
1210
|
+
if (_n(this, n)) return vn(this, e, n);
|
|
1206
1211
|
let r = this.json.images[e], i = /* @__PURE__ */ Error("no image decoder in this runtime: configurePlatform( nodePlatform( { decodeImage } ) ) — see \"Running in Node\"");
|
|
1207
1212
|
return t?.(r.uri ?? `bufferView ${r.bufferView}`, i), Promise.reject(i);
|
|
1208
1213
|
}, { name: "RAYZEE_missing_image_decoder" };
|
|
1209
1214
|
}
|
|
1210
|
-
function
|
|
1215
|
+
function xn(e, t = null) {
|
|
1211
1216
|
return e.loadImageSource = function(e, n) {
|
|
1212
|
-
if (
|
|
1217
|
+
if (_n(this, n)) return vn(this, e, n);
|
|
1213
1218
|
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 =
|
|
1219
|
+
let r = this.json.images[e], i = dn(r), a = r.uri ?? `bufferView ${r.bufferView}`, o = gn(this, r).then((e) => mn(e, i)).then((e) => {
|
|
1220
|
+
let t = pn(e, { shared: !0 });
|
|
1216
1221
|
return r.extras && typeof r.extras == "object" && Object.assign(t.userData, r.extras), t.userData.mimeType = i, t;
|
|
1217
1222
|
}).catch((e) => {
|
|
1218
1223
|
throw t?.(a, e), e;
|
|
@@ -1222,8 +1227,8 @@ function vn(e, t = null) {
|
|
|
1222
1227
|
}
|
|
1223
1228
|
//#endregion
|
|
1224
1229
|
//#region src/Processor/GLTFDiffuseTransmission.js
|
|
1225
|
-
var
|
|
1226
|
-
function
|
|
1230
|
+
var Sn = "KHR_materials_diffuse_transmission";
|
|
1231
|
+
function Cn(e) {
|
|
1227
1232
|
let t = (t, n, r, i) => {
|
|
1228
1233
|
let a = {};
|
|
1229
1234
|
return e.assignTexture(a, n, r, i).then(() => {
|
|
@@ -1231,7 +1236,7 @@ function bn(e) {
|
|
|
1231
1236
|
});
|
|
1232
1237
|
};
|
|
1233
1238
|
return {
|
|
1234
|
-
name:
|
|
1239
|
+
name: Sn,
|
|
1235
1240
|
afterRoot(n) {
|
|
1236
1241
|
let r = e.json.materials ?? [], i = /* @__PURE__ */ new Set(), a = [];
|
|
1237
1242
|
for (let o of n.scenes ?? []) o.traverse((n) => {
|
|
@@ -1239,7 +1244,7 @@ function bn(e) {
|
|
|
1239
1244
|
for (let n of o) {
|
|
1240
1245
|
if (i.has(n)) continue;
|
|
1241
1246
|
i.add(n);
|
|
1242
|
-
let o = e.associations.get(n)?.materials, s = o === void 0 ? null : r[o]?.extensions?.[
|
|
1247
|
+
let o = e.associations.get(n)?.materials, s = o === void 0 ? null : r[o]?.extensions?.[Sn];
|
|
1243
1248
|
if (!s) continue;
|
|
1244
1249
|
n.diffuseTransmission = s.diffuseTransmissionFactor ?? 0;
|
|
1245
1250
|
let [c, l, u] = s.diffuseTransmissionColorFactor ?? [
|
|
@@ -1247,7 +1252,7 @@ function bn(e) {
|
|
|
1247
1252
|
1,
|
|
1248
1253
|
1
|
|
1249
1254
|
];
|
|
1250
|
-
n.diffuseTransmissionColor = new
|
|
1255
|
+
n.diffuseTransmissionColor = new nt().setRGB(c, l, u, lt), s.diffuseTransmissionTexture && a.push(t(n, "diffuseTransmissionMap", s.diffuseTransmissionTexture)), s.diffuseTransmissionColorTexture && a.push(t(n, "diffuseTransmissionColorMap", s.diffuseTransmissionColorTexture, B));
|
|
1251
1256
|
}
|
|
1252
1257
|
});
|
|
1253
1258
|
return Promise.all(a);
|
|
@@ -1256,20 +1261,20 @@ function bn(e) {
|
|
|
1256
1261
|
}
|
|
1257
1262
|
//#endregion
|
|
1258
1263
|
//#region src/Processor/GLTFDecoders.js
|
|
1259
|
-
var
|
|
1260
|
-
function
|
|
1264
|
+
var wn = "KHR_draco_mesh_compression", Tn = "KHR_texture_basisu", En = ["EXT_meshopt_compression", "KHR_meshopt_compression"], Dn = new TextDecoder();
|
|
1265
|
+
function On(e) {
|
|
1261
1266
|
if (typeof e == "string") return e;
|
|
1262
1267
|
if (!(e instanceof ArrayBuffer)) return JSON.stringify(e?.extensionsUsed ?? []);
|
|
1263
1268
|
let t = new DataView(e);
|
|
1264
|
-
if (!(e.byteLength >= 20 && t.getUint32(0, !0) === 1179937895)) return
|
|
1269
|
+
if (!(e.byteLength >= 20 && t.getUint32(0, !0) === 1179937895)) return Dn.decode(e);
|
|
1265
1270
|
let n = Math.min(t.getUint32(12, !0), e.byteLength - 20);
|
|
1266
|
-
return
|
|
1271
|
+
return Dn.decode(new Uint8Array(e, 20, n));
|
|
1267
1272
|
}
|
|
1268
|
-
async function
|
|
1269
|
-
let { dracoDecoderPath: r, ktx2TranscoderPath: i } =
|
|
1270
|
-
t.includes(
|
|
1271
|
-
t.includes(
|
|
1272
|
-
|
|
1273
|
+
async function kn(e, t, n) {
|
|
1274
|
+
let { dracoDecoderPath: r, ktx2TranscoderPath: i } = w(), [a, o, s] = await Promise.all([
|
|
1275
|
+
t.includes(wn) && !e.dracoLoader ? import("three/addons/loaders/DRACOLoader.js") : null,
|
|
1276
|
+
t.includes(Tn) && !e.ktx2Loader ? import("three/addons/loaders/KTX2Loader.js") : null,
|
|
1277
|
+
En.some((e) => t.includes(e)) && !e.meshoptDecoder ? import("three/addons/libs/meshopt_decoder.module.js") : null
|
|
1273
1278
|
]);
|
|
1274
1279
|
if (a) {
|
|
1275
1280
|
let t = new a.DRACOLoader();
|
|
@@ -1288,15 +1293,15 @@ async function En(e, t, n) {
|
|
|
1288
1293
|
}
|
|
1289
1294
|
s && e.setMeshoptDecoder(s.MeshoptDecoder);
|
|
1290
1295
|
}
|
|
1291
|
-
function
|
|
1296
|
+
function An(e, t) {
|
|
1292
1297
|
let n = e.parse.bind(e);
|
|
1293
1298
|
return e.parse = (r, i, a, o) => {
|
|
1294
|
-
|
|
1299
|
+
kn(e, On(r), t).then(() => n(r, i, a, o), (e) => o?.(e));
|
|
1295
1300
|
}, e;
|
|
1296
1301
|
}
|
|
1297
1302
|
//#endregion
|
|
1298
1303
|
//#region src/Processor/AssetLoader.js
|
|
1299
|
-
var
|
|
1304
|
+
var jn = me("assets"), Mn = {
|
|
1300
1305
|
glb: {
|
|
1301
1306
|
type: "model",
|
|
1302
1307
|
name: "GLB (GLTF Binary)"
|
|
@@ -1331,7 +1336,7 @@ var On = {
|
|
|
1331
1336
|
}, Z = {
|
|
1332
1337
|
addOn: "rayzee/addons/formats",
|
|
1333
1338
|
install: "assetLoader.registerFormat()"
|
|
1334
|
-
},
|
|
1339
|
+
}, Nn = {
|
|
1335
1340
|
zip: X,
|
|
1336
1341
|
gz: X,
|
|
1337
1342
|
tgz: X,
|
|
@@ -1348,22 +1353,22 @@ var On = {
|
|
|
1348
1353
|
usdz: Z,
|
|
1349
1354
|
exr: Z
|
|
1350
1355
|
};
|
|
1351
|
-
function
|
|
1352
|
-
let t = new
|
|
1356
|
+
function Pn(e) {
|
|
1357
|
+
let t = new et();
|
|
1353
1358
|
for (let n in e.attributes) t.setAttribute(n, e.attributes[n]);
|
|
1354
1359
|
e.index && t.setIndex(e.index);
|
|
1355
1360
|
for (let n of e.groups) t.addGroup(n.start, n.count, n.materialIndex);
|
|
1356
1361
|
return t;
|
|
1357
1362
|
}
|
|
1358
|
-
var
|
|
1359
|
-
function
|
|
1363
|
+
var Fn = 683;
|
|
1364
|
+
function In(e, t, n, r) {
|
|
1360
1365
|
if (!(r.normalize ?? !0)) return Math.PI;
|
|
1361
|
-
let i = r.shape === "ellipse" || r.shape === "disk" ? Math.PI / 4 : 1, a = e.getWorldScale(new
|
|
1366
|
+
let i = r.shape === "ellipse" || r.shape === "disk" ? Math.PI / 4 : 1, a = e.getWorldScale(new H()), o = Math.PI * i * Math.abs(t * a.x * n * a.y);
|
|
1362
1367
|
return Number.isFinite(o) ? o : Math.PI;
|
|
1363
1368
|
}
|
|
1364
|
-
var
|
|
1369
|
+
var Ln = class e extends I {
|
|
1365
1370
|
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
|
|
1371
|
+
super(), this.scene = e, this.camera = t, this.controls = n, this.targetModel = null, this.floorPlane = null, this.sceneScale = 1, this.sceneSize = new H(1, 1, 1), this.loaderCache = {}, this.uploadedFileInfo = null, this.animations = [], this.renderer = null, this.sceneMetadata = null, this._loadingManager = new ut(), 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
1372
|
this._loadCancelled || this._issues?.record(S.ASSET_UNREACHABLE, `asset "${e}" could not be fetched — anything depending on it renders without it`, { url: e });
|
|
1368
1373
|
};
|
|
1369
1374
|
}
|
|
@@ -1379,7 +1384,7 @@ var Nn = class e extends I {
|
|
|
1379
1384
|
let o = new AbortController();
|
|
1380
1385
|
this._urlAbort = o;
|
|
1381
1386
|
try {
|
|
1382
|
-
return await
|
|
1387
|
+
return await on(t, {
|
|
1383
1388
|
downloads: this.downloads,
|
|
1384
1389
|
key: i,
|
|
1385
1390
|
policy: a,
|
|
@@ -1437,7 +1442,7 @@ var Nn = class e extends I {
|
|
|
1437
1442
|
_adoptExternalObject(e) {
|
|
1438
1443
|
let t;
|
|
1439
1444
|
try {
|
|
1440
|
-
t =
|
|
1445
|
+
t = Pt(e);
|
|
1441
1446
|
} catch (t) {
|
|
1442
1447
|
throw Error(`Cannot render "${e.name || e.type}": its userData must be JSON-serializable.`, { cause: t });
|
|
1443
1448
|
}
|
|
@@ -1471,10 +1476,10 @@ var Nn = class e extends I {
|
|
|
1471
1476
|
}
|
|
1472
1477
|
getFileFormat(e) {
|
|
1473
1478
|
let t = e.split(".").pop().toLowerCase();
|
|
1474
|
-
return
|
|
1479
|
+
return Mn[t] || this._formats.get(t) || this._archiveFormats?.[t] || null;
|
|
1475
1480
|
}
|
|
1476
1481
|
formatError(e) {
|
|
1477
|
-
let t =
|
|
1482
|
+
let t = Nn[e.split(".").pop().toLowerCase()];
|
|
1478
1483
|
return /* @__PURE__ */ Error(t ? `${e}: this format is read by ${t.addOn} — install it with ${t.install}` : `Unsupported file format: ${e}`);
|
|
1479
1484
|
}
|
|
1480
1485
|
async inspectArchive(e) {
|
|
@@ -1578,8 +1583,8 @@ var Nn = class e extends I {
|
|
|
1578
1583
|
}
|
|
1579
1584
|
}
|
|
1580
1585
|
async loadModelFromFile(e, t) {
|
|
1581
|
-
let n = this.storage ? this._keyed("file",
|
|
1582
|
-
return this._sourceKey = n,
|
|
1586
|
+
let n = this.storage ? this._keyed("file", E(await Ae(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);
|
|
1587
|
+
return this._sourceKey = n, i;
|
|
1583
1588
|
}
|
|
1584
1589
|
async _loadModelFileByExtension(e, t) {
|
|
1585
1590
|
let n = t.split(".").pop().toLowerCase();
|
|
@@ -1625,7 +1630,7 @@ var Nn = class e extends I {
|
|
|
1625
1630
|
};
|
|
1626
1631
|
try {
|
|
1627
1632
|
let r = await this.loadEnvironment(n);
|
|
1628
|
-
return
|
|
1633
|
+
return pe(r, E(await Ae(e))), this.dispatchEvent({
|
|
1629
1634
|
type: "load",
|
|
1630
1635
|
texture: r,
|
|
1631
1636
|
filename: t
|
|
@@ -1647,7 +1652,7 @@ var Nn = class e extends I {
|
|
|
1647
1652
|
let e = t.split(/[?#]/)[0].split(".").pop().toLowerCase();
|
|
1648
1653
|
n = await this.loadEnvironmentByExtension(t, e);
|
|
1649
1654
|
}
|
|
1650
|
-
return n.generateMipmaps = !0, e._isNetworkUrl(t) &&
|
|
1655
|
+
return n.generateMipmaps = !0, e._isNetworkUrl(t) && pe(n, t), this.applyEnvironmentToScene(n), this.dispatchEvent({
|
|
1651
1656
|
type: "load",
|
|
1652
1657
|
texture: n,
|
|
1653
1658
|
url: t,
|
|
@@ -1684,21 +1689,21 @@ var Nn = class e extends I {
|
|
|
1684
1689
|
}
|
|
1685
1690
|
async loadEnvironmentByExtension(t, n, { loader: r = null } = {}) {
|
|
1686
1691
|
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
|
|
1692
|
+
if (!r && i?.type === "environment" && (r = this.loaderCache[n] ??= await i.createLoader(this._loadingManager)), !r && n === "hdr" && (r = this.loaderCache.hdr ??= new Mt(this._loadingManager).setDataType(st)), !r && Nn[n]) throw this.formatError(`environment.${n}`);
|
|
1688
1693
|
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
1694
|
try {
|
|
1690
|
-
r ? l = await r.loadAsync(s.url, c) : b().decodeImage ? (l = await
|
|
1695
|
+
r ? l = await r.loadAsync(s.url, c) : b().decodeImage ? (l = await yn(s.url, `image/${n === "jpg" ? "jpeg" : n}`), l.colorSpace = B) : (this.loaderCache.texture || (this.loaderCache.texture = new Et(this._loadingManager)), l = await this.loaderCache.texture.loadAsync(s.url, c), l.colorSpace = B);
|
|
1691
1696
|
} finally {
|
|
1692
1697
|
s.release();
|
|
1693
1698
|
}
|
|
1694
|
-
return this._downloadComplete("Processing Environment...", 62), l.mapping =
|
|
1699
|
+
return this._downloadComplete("Processing Environment...", 62), this.maxEnvironmentWidth && Rn(l, this.maxEnvironmentWidth), l.mapping = ot, l.minFilter = ct, l.magFilter = ct, l;
|
|
1695
1700
|
}
|
|
1696
1701
|
applyEnvironmentToScene(e) {
|
|
1697
1702
|
this.scene.background = e, this.scene.environment = e;
|
|
1698
1703
|
}
|
|
1699
1704
|
async createGLTFLoader() {
|
|
1700
|
-
let e =
|
|
1701
|
-
return b().decodeImage ? e.register((e) =>
|
|
1705
|
+
let e = An(new jt(this._loadingManager), this.renderer), t = (e, t) => this._reportImageFailure(e, t);
|
|
1706
|
+
return b().decodeImage ? e.register((e) => xn(e, t)) : g() || e.register((e) => bn(e, t)), e.register((e) => Cn(e)), e;
|
|
1702
1707
|
}
|
|
1703
1708
|
_reportImageFailure(e, t) {
|
|
1704
1709
|
try {
|
|
@@ -1734,8 +1739,8 @@ var Nn = class e extends I {
|
|
|
1734
1739
|
loadedBytes: 0,
|
|
1735
1740
|
totalBytes: 0
|
|
1736
1741
|
}), 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 =
|
|
1742
|
+
let e = await ne(() => r.loadAsync(a.url, a.cached ? void 0 : this._downloadProgress("Downloading Model...", i)));
|
|
1743
|
+
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 = Pe(e), await this.onModelLoad(this.targetModel), this.dispatchEvent({
|
|
1739
1744
|
type: "load",
|
|
1740
1745
|
model: e.scene,
|
|
1741
1746
|
filename: t.split("/").pop()
|
|
@@ -1765,7 +1770,7 @@ var Nn = class e extends I {
|
|
|
1765
1770
|
loadedBytes: 0,
|
|
1766
1771
|
totalBytes: 0
|
|
1767
1772
|
}), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(L.extractUrlBase(t));
|
|
1768
|
-
let e = await
|
|
1773
|
+
let e = await ne(() => r.loadAsync(a.url, a.cached ? void 0 : this._downloadProgress("Downloading Model...", i)));
|
|
1769
1774
|
return this._downloadComplete(), this._throwDeferred(), this._appended = !0, this._processAndParent(e.scene), {
|
|
1770
1775
|
root: e.scene,
|
|
1771
1776
|
animations: e.animations || []
|
|
@@ -1782,7 +1787,7 @@ var Nn = class e extends I {
|
|
|
1782
1787
|
return n.name = e.name || t, this._processAndParent(n), { root: n };
|
|
1783
1788
|
}
|
|
1784
1789
|
removeModelRoot(e) {
|
|
1785
|
-
e && (e.userData.__rayzeeExternal ? (
|
|
1790
|
+
e && (e.userData.__rayzeeExternal ? (te(e), e.parent?.remove(e)) : h(e));
|
|
1786
1791
|
}
|
|
1787
1792
|
async loadGLBFromArrayBuffer(e, t = "model.glb") {
|
|
1788
1793
|
let n = await this.createGLTFLoader();
|
|
@@ -1792,8 +1797,8 @@ var Nn = class e extends I {
|
|
|
1792
1797
|
status: "Processing GLB Data...",
|
|
1793
1798
|
progress: 5
|
|
1794
1799
|
}), 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 =
|
|
1800
|
+
let r = await ne(() => n.parseAsync(e, ""));
|
|
1801
|
+
return this._throwDeferred(), this.releaseTargetModel(), this.targetModel = r.scene, this.animations = r.animations || [], this.sceneMetadata = Pe(r), v({
|
|
1797
1802
|
isLoading: !0,
|
|
1798
1803
|
status: "Processing Data...",
|
|
1799
1804
|
progress: 10
|
|
@@ -1826,20 +1831,20 @@ var Nn = class e extends I {
|
|
|
1826
1831
|
}), n;
|
|
1827
1832
|
}
|
|
1828
1833
|
async onModelLoad(e) {
|
|
1829
|
-
let t = new
|
|
1834
|
+
let t = new d("onModelLoad");
|
|
1830
1835
|
t.start("Camera extraction");
|
|
1831
1836
|
let n = this.extractCamerasFromModel(e);
|
|
1832
1837
|
t.end("Camera extraction"), t.start("Camera setup");
|
|
1833
|
-
let r = new
|
|
1838
|
+
let r = new $e().setFromObject(e), i = r.getCenter(new H()), a = r.getSize(new H());
|
|
1834
1839
|
this.controls?.target.copy(i);
|
|
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
|
|
1840
|
+
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 H(Math.cos(l) * c, c / Math.sqrt(2), Math.sin(l) * c);
|
|
1836
1841
|
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) {
|
|
1837
1842
|
let e = r.min.y;
|
|
1838
1843
|
this.floorPlane.position.y = e, this.floorPlane.rotation.x = -Math.PI / 2, this.floorPlane.scale.setScalar(o * 5);
|
|
1839
1844
|
}
|
|
1840
1845
|
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,
|
|
1846
|
+
let f = o;
|
|
1847
|
+
return this.sceneSize.copy(a), t.start("setupPathTracing"), await this.setupPathTracing(e, f), t.end("setupPathTracing"), t.print(), this.dispatchEvent({
|
|
1843
1848
|
type: "modelProcessed",
|
|
1844
1849
|
model: e,
|
|
1845
1850
|
cameras: n,
|
|
@@ -1847,13 +1852,13 @@ var Nn = class e extends I {
|
|
|
1847
1852
|
center: i,
|
|
1848
1853
|
size: a,
|
|
1849
1854
|
maxDim: o,
|
|
1850
|
-
sceneScale:
|
|
1855
|
+
sceneScale: f
|
|
1851
1856
|
}
|
|
1852
1857
|
}), this.dispatchEvent({ type: "SceneRebuild" }), {
|
|
1853
1858
|
center: i,
|
|
1854
1859
|
size: a,
|
|
1855
1860
|
maxDim: o,
|
|
1856
|
-
sceneScale:
|
|
1861
|
+
sceneScale: f
|
|
1857
1862
|
};
|
|
1858
1863
|
}
|
|
1859
1864
|
extractCamerasFromModel(e) {
|
|
@@ -1869,10 +1874,10 @@ var Nn = class e extends I {
|
|
|
1869
1874
|
let t = [], n = [];
|
|
1870
1875
|
e.traverse((e) => {
|
|
1871
1876
|
let r = e.userData;
|
|
1872
|
-
e.isRectAreaLight && !r.__radianceConverted && (e.intensity *=
|
|
1877
|
+
e.isRectAreaLight && !r.__radianceConverted && (e.intensity *= In(e, e.width, e.height, r), r.__radianceConverted = !0), (e.isPointLight || e.isSpotLight) && !r.__candelaConverted && (e.intensity *= 4 * Math.PI / Fn, r.__candelaConverted = !0), e.isDirectionalLight && !r.__luxConverted && (e.intensity /= Fn, r.__luxConverted = !0);
|
|
1873
1878
|
let i = e.name.startsWith("RectAreaLightPlaceholder");
|
|
1874
1879
|
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 *
|
|
1880
|
+
let t = r.normalize ?? !0, n = r.shape ?? "rectangle", i = r.intensity * In(e, r.width, r.height, r), a = new z(new nt(...r.color), i * this._areaLightIntensityScale(), r.width, r.height);
|
|
1876
1881
|
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
1882
|
}
|
|
1878
1883
|
e.isMesh && Array.isArray(e.material) && t.push(e);
|
|
@@ -1883,8 +1888,8 @@ var Nn = class e extends I {
|
|
|
1883
1888
|
let r = e.userData.__rayzeeExternal === !0;
|
|
1884
1889
|
for (let e of t) {
|
|
1885
1890
|
if (!e.parent) continue;
|
|
1886
|
-
console.log("Found multi-material mesh:", e.name), r && (e.geometry =
|
|
1887
|
-
let t =
|
|
1891
|
+
console.log("Found multi-material mesh:", e.name), r && (e.geometry = Pn(e.geometry));
|
|
1892
|
+
let t = Nt(e);
|
|
1888
1893
|
for (let e of t.children) e.geometry.userData.__rayzeeOwned = !0;
|
|
1889
1894
|
e.parent.add(t), e.parent.remove(e);
|
|
1890
1895
|
}
|
|
@@ -1893,7 +1898,7 @@ var Nn = class e extends I {
|
|
|
1893
1898
|
this.sceneScale = t;
|
|
1894
1899
|
}
|
|
1895
1900
|
createFloorPlane() {
|
|
1896
|
-
this.floorPlane = new
|
|
1901
|
+
this.floorPlane = new dt(new tt(), new ft({
|
|
1897
1902
|
transparent: !1,
|
|
1898
1903
|
color: 3158064,
|
|
1899
1904
|
roughness: 1,
|
|
@@ -1916,7 +1921,7 @@ var Nn = class e extends I {
|
|
|
1916
1921
|
}
|
|
1917
1922
|
getSupportedFormats(e = null) {
|
|
1918
1923
|
let t = {
|
|
1919
|
-
...
|
|
1924
|
+
...Mn,
|
|
1920
1925
|
...this._archiveFormats
|
|
1921
1926
|
};
|
|
1922
1927
|
for (let [e, { type: n, name: r }] of this._formats) t[e] = {
|
|
@@ -1940,13 +1945,39 @@ var Nn = class e extends I {
|
|
|
1940
1945
|
removeAllEventListeners() {
|
|
1941
1946
|
this._listeners = void 0;
|
|
1942
1947
|
}
|
|
1943
|
-
}
|
|
1948
|
+
};
|
|
1949
|
+
function Rn(e, t) {
|
|
1950
|
+
let { data: n, width: r, height: i } = e.image ?? {};
|
|
1951
|
+
if (!(n instanceof Float32Array) || r <= t || n.length !== r * i * 4) return;
|
|
1952
|
+
let a = Math.ceil(r / t), o = Math.ceil(r / a), s = Math.ceil(i / a);
|
|
1953
|
+
for (let e = 0; e < s; e++) {
|
|
1954
|
+
let t = Math.min(i, (e + 1) * a);
|
|
1955
|
+
for (let i = 0; i < o; i++) {
|
|
1956
|
+
let s = Math.min(r, (i + 1) * a), c = 0, l = 0, u = 0, d = 0, f = 0;
|
|
1957
|
+
for (let o = e * a; o < t; o++) for (let e = i * a; e < s; e++) {
|
|
1958
|
+
let t = (o * r + e) * 4;
|
|
1959
|
+
c += n[t], l += n[t + 1], u += n[t + 2], d += n[t + 3], f++;
|
|
1960
|
+
}
|
|
1961
|
+
let p = (e * o + i) * 4;
|
|
1962
|
+
n[p] = c / f, n[p + 1] = l / f, n[p + 2] = u / f, n[p + 3] = d / f;
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
let c = o * s * 16;
|
|
1966
|
+
e.image = {
|
|
1967
|
+
data: n.byteOffset === 0 && n.byteLength === n.buffer.byteLength && n.buffer.transfer ? new Float32Array(n.buffer.transfer(c)) : n.slice(0, o * s * 4),
|
|
1968
|
+
width: o,
|
|
1969
|
+
height: s
|
|
1970
|
+
}, e.needsUpdate = !0, jn.info(`environment ${r}×${i} shrunk to ${o}×${s} (memory spill)`);
|
|
1971
|
+
}
|
|
1972
|
+
//#endregion
|
|
1973
|
+
//#region src/HeadlessCanvas.js
|
|
1974
|
+
var zn = {
|
|
1944
1975
|
addEventListener() {},
|
|
1945
1976
|
removeEventListener() {},
|
|
1946
1977
|
dispatchEvent() {
|
|
1947
1978
|
return !0;
|
|
1948
1979
|
}
|
|
1949
|
-
},
|
|
1980
|
+
}, Bn = class {
|
|
1950
1981
|
constructor(e) {
|
|
1951
1982
|
this.canvas = e, this._configuration = null, this._texture = null;
|
|
1952
1983
|
}
|
|
@@ -1974,12 +2005,12 @@ var Nn = class e extends I {
|
|
|
1974
2005
|
return this._texture;
|
|
1975
2006
|
}
|
|
1976
2007
|
};
|
|
1977
|
-
function
|
|
2008
|
+
function Vn(e = 1, t = 1) {
|
|
1978
2009
|
let n = {
|
|
1979
|
-
...
|
|
2010
|
+
...zn,
|
|
1980
2011
|
defaultView: null
|
|
1981
2012
|
}, r = {
|
|
1982
|
-
...
|
|
2013
|
+
...zn,
|
|
1983
2014
|
isHeadlessCanvas: !0,
|
|
1984
2015
|
width: e,
|
|
1985
2016
|
height: t,
|
|
@@ -2006,12 +2037,12 @@ function In(e = 1, t = 1) {
|
|
|
2006
2037
|
hasPointerCapture: () => !1,
|
|
2007
2038
|
focus() {},
|
|
2008
2039
|
getContext: (e) => e === "webgpu" ? i : null
|
|
2009
|
-
}, i = new
|
|
2040
|
+
}, i = new Bn(r);
|
|
2010
2041
|
return r;
|
|
2011
2042
|
}
|
|
2012
2043
|
//#endregion
|
|
2013
2044
|
//#region src/managers/ViewCamera.js
|
|
2014
|
-
var
|
|
2045
|
+
var Hn = class extends vt {
|
|
2015
2046
|
constructor(e, t, n, r) {
|
|
2016
2047
|
super(e, t, n, r), this.orthographic = !1, this.orthoHalfHeight = 1;
|
|
2017
2048
|
}
|
|
@@ -2035,17 +2066,17 @@ var Ln = class extends mt {
|
|
|
2035
2066
|
return -this.orthoHalfHeight * this.aspect;
|
|
2036
2067
|
}
|
|
2037
2068
|
updateProjectionMatrix() {
|
|
2038
|
-
this.orthographic ?
|
|
2069
|
+
this.orthographic ? _t.prototype.updateProjectionMatrix.call(this) : super.updateProjectionMatrix();
|
|
2039
2070
|
}
|
|
2040
2071
|
copy(e, t) {
|
|
2041
2072
|
return super.copy(e, t), this.orthographic = e.orthographic === !0, this.orthoHalfHeight = e.orthoHalfHeight ?? this.orthoHalfHeight, this;
|
|
2042
2073
|
}
|
|
2043
|
-
},
|
|
2044
|
-
DirectionalLight:
|
|
2045
|
-
PointLight:
|
|
2046
|
-
SpotLight:
|
|
2047
|
-
RectAreaLight:
|
|
2048
|
-
},
|
|
2074
|
+
}, Un = "__rayzeeUserLight", Wn = {
|
|
2075
|
+
DirectionalLight: it,
|
|
2076
|
+
PointLight: yt,
|
|
2077
|
+
SpotLight: wt,
|
|
2078
|
+
RectAreaLight: z
|
|
2079
|
+
}, Gn = class extends I {
|
|
2049
2080
|
constructor(e, t, n, r = {}) {
|
|
2050
2081
|
super(), this.scene = e, this.sceneHelpers = t, this.pathTracer = n, this._onReset = r.onReset || null, this._onLightRemoved = r.onLightRemoved || null;
|
|
2051
2082
|
}
|
|
@@ -2093,14 +2124,14 @@ var Ln = class extends mt {
|
|
|
2093
2124
|
}[e];
|
|
2094
2125
|
if (!t) return null;
|
|
2095
2126
|
let n;
|
|
2096
|
-
if (e === "DirectionalLight") n = new
|
|
2097
|
-
else if (e === "PointLight") n = new
|
|
2127
|
+
if (e === "DirectionalLight") n = new it(t.color, t.intensity), n.position.fromArray(t.position);
|
|
2128
|
+
else if (e === "PointLight") n = new yt(t.color, t.intensity), n.position.fromArray(t.position);
|
|
2098
2129
|
else if (e === "SpotLight") {
|
|
2099
|
-
n = new
|
|
2100
|
-
let e = new
|
|
2130
|
+
n = new wt(t.color, t.intensity), n.position.fromArray(t.position), n.angle = R.degToRad(t.angle);
|
|
2131
|
+
let e = new gt();
|
|
2101
2132
|
this.scene.add(e), n.target = e;
|
|
2102
|
-
} else e === "RectAreaLight" && (n = new
|
|
2103
|
-
n.userData[
|
|
2133
|
+
} else e === "RectAreaLight" && (n = new z(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");
|
|
2134
|
+
n.userData[Un] = !0, n.userData.temperature = 6500, n.userData.useTemperature = !1, n.userData.exposure = 0;
|
|
2104
2135
|
let r = this.scene.getObjectsByProperty("isLight", !0).length;
|
|
2105
2136
|
return n.name = `${e.replace("Light", "")} ${r + 1}`, this.scene.add(n), this.updateLights(), this._syncHelpers(), this._onReset?.(), this._buildDescriptor(n);
|
|
2106
2137
|
}
|
|
@@ -2126,7 +2157,7 @@ var Ln = class extends mt {
|
|
|
2126
2157
|
this.pathTracer?.updateLights(), this.sceneHelpers?.visible && this.sceneHelpers.update();
|
|
2127
2158
|
}
|
|
2128
2159
|
transferSceneLights(e, { keepUserLights: t = !1 } = {}) {
|
|
2129
|
-
this._removeAllLights(t ? (e) => !e.userData?.[
|
|
2160
|
+
this._removeAllLights(t ? (e) => !e.userData?.[Un] : void 0);
|
|
2130
2161
|
let n = e.getObjectsByProperty("isLight", !0);
|
|
2131
2162
|
if (!n || n.length === 0) {
|
|
2132
2163
|
this.updateLights();
|
|
@@ -2135,7 +2166,7 @@ var Ln = class extends mt {
|
|
|
2135
2166
|
for (let e of n) {
|
|
2136
2167
|
let t = e.clone();
|
|
2137
2168
|
if (e.updateWorldMatrix(!0, !1), e.getWorldPosition(t.position), e.getWorldQuaternion(t.quaternion), e.getWorldScale(t.scale), t.isRectAreaLight && (t.width *= t.scale.x, t.height *= t.scale.y, t.scale.set(1, 1, 1)), (e.isSpotLight || e.isDirectionalLight) && e.target) {
|
|
2138
|
-
let n = new
|
|
2169
|
+
let n = new gt();
|
|
2139
2170
|
e.target.updateWorldMatrix(!0, !1), e.target.getWorldPosition(n.position), this.scene.add(n), t.target = n;
|
|
2140
2171
|
}
|
|
2141
2172
|
this.scene.add(t);
|
|
@@ -2160,7 +2191,7 @@ var Ln = class extends mt {
|
|
|
2160
2191
|
position: e.position.toArray(),
|
|
2161
2192
|
quaternion: e.quaternion.toArray(),
|
|
2162
2193
|
scale: e.scale.toArray(),
|
|
2163
|
-
userData:
|
|
2194
|
+
userData: i(e.userData) ?? {}
|
|
2164
2195
|
};
|
|
2165
2196
|
return e.isSpotLight && Object.assign(t, {
|
|
2166
2197
|
angle: e.angle,
|
|
@@ -2180,14 +2211,14 @@ var Ln = class extends mt {
|
|
|
2180
2211
|
this.sceneHelpers?.clear(), this._removeAllLights();
|
|
2181
2212
|
let t = [];
|
|
2182
2213
|
for (let n of e ?? []) {
|
|
2183
|
-
let e =
|
|
2214
|
+
let e = Wn[n.type];
|
|
2184
2215
|
if (!e) continue;
|
|
2185
2216
|
let r = new e();
|
|
2186
2217
|
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
2218
|
1,
|
|
2188
2219
|
1,
|
|
2189
2220
|
1
|
|
2190
|
-
]), r.userData =
|
|
2221
|
+
]), r.userData = o(n.userData) ?? {};
|
|
2191
2222
|
for (let e of [
|
|
2192
2223
|
"angle",
|
|
2193
2224
|
"penumbra",
|
|
@@ -2197,7 +2228,7 @@ var Ln = class extends mt {
|
|
|
2197
2228
|
"height"
|
|
2198
2229
|
]) typeof n[e] == "number" && (r[e] = n[e]);
|
|
2199
2230
|
if (n.target) {
|
|
2200
|
-
let e = new
|
|
2231
|
+
let e = new gt();
|
|
2201
2232
|
e.position.fromArray(n.target), this.scene.add(e), r.target = e;
|
|
2202
2233
|
}
|
|
2203
2234
|
this.scene.add(r), t.push(r);
|
|
@@ -2272,11 +2303,11 @@ var Ln = class extends mt {
|
|
|
2272
2303
|
], 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
2304
|
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
2305
|
}
|
|
2275
|
-
},
|
|
2306
|
+
}, Kn = ({ element: e, pbrtEntry: t } = {}) => ({
|
|
2276
2307
|
...e === void 0 ? {} : { element: e },
|
|
2277
2308
|
...t === void 0 ? {} : { pbrtEntry: t }
|
|
2278
|
-
}), Q = /* @__PURE__ */ new WeakMap(),
|
|
2279
|
-
async function
|
|
2309
|
+
}), Q = /* @__PURE__ */ new WeakMap(), qn = 3e4, Jn = new Set([...Object.values(m), ...Object.values(p)]), Yn = /* @__PURE__ */ new Set();
|
|
2310
|
+
async function Xn(e, t) {
|
|
2280
2311
|
if (!t || typeof self < "u") return e.init();
|
|
2281
2312
|
globalThis.self = {
|
|
2282
2313
|
requestAnimationFrame: () => 0,
|
|
@@ -2288,43 +2319,43 @@ async function Wn(e, t) {
|
|
|
2288
2319
|
delete globalThis.self;
|
|
2289
2320
|
}
|
|
2290
2321
|
}
|
|
2291
|
-
var $ =
|
|
2292
|
-
function
|
|
2322
|
+
var $ = me("engine");
|
|
2323
|
+
function Zn() {
|
|
2293
2324
|
let e = new Float32Array(16);
|
|
2294
|
-
return new Uint32Array(e.buffer)[3] =
|
|
2325
|
+
return new Uint32Array(e.buffer)[3] = ge.TRIANGLE_LEAF, e;
|
|
2295
2326
|
}
|
|
2296
|
-
function
|
|
2327
|
+
function Qn(e, t) {
|
|
2297
2328
|
e.lost.then((e) => {
|
|
2298
2329
|
t.app && t.app._handleDeviceLost(e);
|
|
2299
2330
|
});
|
|
2300
2331
|
}
|
|
2301
|
-
var
|
|
2302
|
-
function
|
|
2332
|
+
var $n = /swiftshader|llvmpipe|lavapipe|basic render|microsoft basic|warp/i;
|
|
2333
|
+
function er(e) {
|
|
2303
2334
|
let t = e.info ?? {}, n = `${t.vendor ?? ""} ${t.architecture ?? ""} ${t.device ?? ""} ${t.description ?? ""}`;
|
|
2304
2335
|
return {
|
|
2305
2336
|
vendor: t.vendor ?? "",
|
|
2306
2337
|
architecture: t.architecture ?? "",
|
|
2307
2338
|
device: t.device ?? "",
|
|
2308
2339
|
description: t.description ?? "",
|
|
2309
|
-
isSoftware: t.isFallbackAdapter === !0 || e.isFallbackAdapter === !0 ||
|
|
2340
|
+
isSoftware: t.isFallbackAdapter === !0 || e.isFallbackAdapter === !0 || $n.test(n)
|
|
2310
2341
|
};
|
|
2311
2342
|
}
|
|
2312
|
-
var
|
|
2343
|
+
var tr = class extends I {
|
|
2313
2344
|
constructor(e, t = {}) {
|
|
2314
|
-
super(), this._headless = t.headless === !0 || !e, e ??=
|
|
2345
|
+
super(), this._headless = t.headless === !0 || !e, e ??= Vn();
|
|
2315
2346
|
try {
|
|
2316
2347
|
Q.get(e)?.dispose();
|
|
2317
2348
|
} catch (e) {
|
|
2318
2349
|
$.warn("prior canvas owner dispose failed", e);
|
|
2319
2350
|
}
|
|
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 `areaLightIntensityScale: 1` and `dofMode: 'physical'` through `settings`.");
|
|
2321
|
-
this._issues = new
|
|
2351
|
+
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`.");
|
|
2352
|
+
this._issues = new _e({
|
|
2322
2353
|
strict: t.strict === !0,
|
|
2323
2354
|
onIssue: (e) => this.dispatchEvent({
|
|
2324
|
-
type:
|
|
2355
|
+
type: m.ISSUE,
|
|
2325
2356
|
issue: e
|
|
2326
2357
|
})
|
|
2327
|
-
}), this.color = new
|
|
2358
|
+
}), this.color = new ln({ issues: this._issues }), Se(this.color), this.settings = new cn(_, { 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 Xt(), 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
2359
|
}
|
|
2329
2360
|
_addTrackedListener(e, t, n) {
|
|
2330
2361
|
e && (e.addEventListener(t, n), this._trackedListeners.push({
|
|
@@ -2343,21 +2374,21 @@ var Yn = class extends I {
|
|
|
2343
2374
|
}
|
|
2344
2375
|
async init() {
|
|
2345
2376
|
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(
|
|
2377
|
+
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(Zn()), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setupMaterial(), this.isInitialized = !0, $.debug("WebGPU path tracer app initialized"), this;
|
|
2347
2378
|
}
|
|
2348
2379
|
async setStorageOpener(e) {
|
|
2349
2380
|
this._storageOpener = e, !(!this.isInitialized || this.storage || this._disposed) && (await this._initStorage(), this._attachStorage());
|
|
2350
2381
|
}
|
|
2351
2382
|
async _initStorage() {
|
|
2352
|
-
let e = this._storageOption ?? (this._issues.strict && !
|
|
2383
|
+
let e = this._storageOption ?? (this._issues.strict && !we("storage") ? !1 : w().storage);
|
|
2353
2384
|
if (e !== !1) {
|
|
2354
2385
|
if (e && typeof e == "object") this.storage = e;
|
|
2355
2386
|
else {
|
|
2356
2387
|
if (!this._storageOpener) {
|
|
2357
|
-
(this._storageOption !== void 0 ||
|
|
2388
|
+
(this._storageOption !== void 0 || we("storage")) && this._issues.warn(S.CAPABILITY_MISSING, "on-disk storage needs rayzee/addons/storage: setStorageOpener( acquireSharedStorage )");
|
|
2358
2389
|
return;
|
|
2359
2390
|
}
|
|
2360
|
-
let { storage: e, reason: t, release: n } = await this._storageOpener(
|
|
2391
|
+
let { storage: e, reason: t, release: n } = await this._storageOpener(w().cacheNamespace);
|
|
2361
2392
|
if (this._disposed) {
|
|
2362
2393
|
n();
|
|
2363
2394
|
return;
|
|
@@ -2369,7 +2400,7 @@ var Yn = class extends I {
|
|
|
2369
2400
|
this.storage = e, this._storageRelease = n;
|
|
2370
2401
|
}
|
|
2371
2402
|
this._addTrackedListener(this.storage, "change", (e) => this.dispatchEvent({
|
|
2372
|
-
type:
|
|
2403
|
+
type: m.STORAGE_CHANGED,
|
|
2373
2404
|
area: e.area
|
|
2374
2405
|
})), this._addTrackedListener(this.storage, "issue", (e) => this._issues.warn(e.code, e.message, e.detail));
|
|
2375
2406
|
}
|
|
@@ -2379,20 +2410,20 @@ var Yn = class extends I {
|
|
|
2379
2410
|
}
|
|
2380
2411
|
dispatchEvent(e) {
|
|
2381
2412
|
super.dispatchEvent(e);
|
|
2382
|
-
let t =
|
|
2413
|
+
let t = p[e.type];
|
|
2383
2414
|
t && super.dispatchEvent({
|
|
2384
2415
|
...e,
|
|
2385
2416
|
type: t
|
|
2386
2417
|
});
|
|
2387
2418
|
}
|
|
2388
2419
|
addEventListener(e, t) {
|
|
2389
|
-
!
|
|
2420
|
+
!Jn.has(e) && !Yn.has(e) && (Yn.add(e), $.warn(`no engine event is named "${e}", so this listener will never fire — see EngineEvents`)), super.addEventListener(e, t);
|
|
2390
2421
|
}
|
|
2391
2422
|
animate() {
|
|
2392
2423
|
if (this._headless) throw Error("a headless app has no render loop — drive it with renderFrames() or renderUntilComplete()");
|
|
2393
2424
|
if (this._deviceLost) return;
|
|
2394
2425
|
if (this.animationManagerId = requestAnimationFrame(() => this.animate()), this._loadingInProgress || this._sdf?.isProcessing) {
|
|
2395
|
-
this.dispatchEvent({ type:
|
|
2426
|
+
this.dispatchEvent({ type: m.FRAME });
|
|
2396
2427
|
return;
|
|
2397
2428
|
}
|
|
2398
2429
|
this._beginFrame();
|
|
@@ -2404,32 +2435,42 @@ var Yn = class extends I {
|
|
|
2404
2435
|
if (!this.pauseRendering) {
|
|
2405
2436
|
if (this._beforeTrace(), this.stages.pathTracer?.isReady) {
|
|
2406
2437
|
if (this.stages.pathTracer.isComplete && this.completion.renderCompleteDispatched) {
|
|
2407
|
-
this._needsDisplayRefresh && (this._needsDisplayRefresh = !1, this.stages.compositor.render(this.pipeline.context), this._renderHelperOverlay()), this.
|
|
2438
|
+
if (this._needsDisplayRefresh && (this._needsDisplayRefresh = !1, this.stages.compositor.render(this.pipeline.context), this._renderHelperOverlay()), this._settling()) {
|
|
2439
|
+
this.dispatchEvent({ type: m.FRAME });
|
|
2440
|
+
return;
|
|
2441
|
+
}
|
|
2442
|
+
this.stopAnimation();
|
|
2408
2443
|
return;
|
|
2409
2444
|
}
|
|
2410
2445
|
if (this._holdTrace(e)) {
|
|
2411
|
-
this._renderHelperOverlay(), this.dispatchEvent({ type:
|
|
2446
|
+
this._renderHelperOverlay(), this.dispatchEvent({ type: m.FRAME });
|
|
2412
2447
|
return;
|
|
2413
2448
|
}
|
|
2414
2449
|
if (this.stages.pathTracer.readbackWait()) {
|
|
2415
|
-
this.dispatchEvent({ type:
|
|
2450
|
+
this.dispatchEvent({ type: m.FRAME });
|
|
2416
2451
|
return;
|
|
2417
2452
|
}
|
|
2418
|
-
this._traceFrame({ liveDenoise: !0 }), this.stages.pathTracer.isComplete && this.completion.markComplete() &&
|
|
2419
|
-
type: g.RENDER_COMPLETE,
|
|
2420
|
-
...this._completionInfo()
|
|
2421
|
-
}));
|
|
2453
|
+
this._traceFrame({ liveDenoise: !0 }), this.stages.pathTracer.isComplete && this.completion.markComplete() && this._announceComplete();
|
|
2422
2454
|
}
|
|
2423
|
-
this._renderHelperOverlay(), this.dispatchEvent({ type:
|
|
2455
|
+
this._renderHelperOverlay(), this.dispatchEvent({ type: m.FRAME });
|
|
2424
2456
|
}
|
|
2425
2457
|
}
|
|
2458
|
+
_announceComplete() {
|
|
2459
|
+
let e = this._completionInfo(), t = this.stages.pathTracer.resetCount, n = () => {
|
|
2460
|
+
!this.completion.renderCompleteDispatched || this.stages.pathTracer?.resetCount !== t || (this._renderCompleted(), this.dispatchEvent({
|
|
2461
|
+
type: m.RENDER_COMPLETE,
|
|
2462
|
+
...e
|
|
2463
|
+
}));
|
|
2464
|
+
}, r = this._finishImage();
|
|
2465
|
+
r ? r.then(n, n) : n();
|
|
2466
|
+
}
|
|
2426
2467
|
_traceFrame({ liveDenoise: e = !1 } = {}) {
|
|
2427
2468
|
let t = this.stages.pathTracer;
|
|
2428
2469
|
this.pipeline.render(), this._afterTrace(t, e), t.isComplete || this.completion.updateTime(), this._ensureVRAMWiring();
|
|
2429
2470
|
let n = t.vramTracker, r = t.frameCount ?? 0;
|
|
2430
|
-
n && (r <= 1 || r % 30 == 0) && n.measure(),
|
|
2471
|
+
n && (r <= 1 || r % 30 == 0) && n.measure(), ce({
|
|
2431
2472
|
timeElapsed: this.completion.timeElapsed,
|
|
2432
|
-
samples:
|
|
2473
|
+
samples: de(t),
|
|
2433
2474
|
memoryUsed: n?.current ?? 0,
|
|
2434
2475
|
memoryPeak: n?.peak ?? 0
|
|
2435
2476
|
}), this.completion.isTimeLimitReached(t, this.settings.get("renderLimitMode"), this.settings.get("renderTimeLimit")) && (t.isComplete = !0);
|
|
@@ -2447,7 +2488,7 @@ var Yn = class extends I {
|
|
|
2447
2488
|
}
|
|
2448
2489
|
_handleDeviceLost(e) {
|
|
2449
2490
|
this._deviceLost || (this._deviceLost = !0, $.error(`WebGPU device lost (${e?.reason || "unknown"}): ${e?.message || ""}`), this.stopAnimation(), this.dispatchEvent({
|
|
2450
|
-
type:
|
|
2491
|
+
type: m.DEVICE_LOST,
|
|
2451
2492
|
reason: e?.reason,
|
|
2452
2493
|
message: e?.message
|
|
2453
2494
|
}));
|
|
@@ -2462,34 +2503,34 @@ var Yn = class extends I {
|
|
|
2462
2503
|
this._paused = !1, !this.animationManagerId && !this._headless && this.animate();
|
|
2463
2504
|
}
|
|
2464
2505
|
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:
|
|
2506
|
+
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
2507
|
}
|
|
2467
2508
|
dispose() {
|
|
2468
2509
|
if (!this._disposed) {
|
|
2469
|
-
if (this._disposed = !0, this.dispatchEvent({ type:
|
|
2510
|
+
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(), ue(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
2511
|
this.meshScene.environment?.dispose(), this.meshScene.environment = null;
|
|
2471
|
-
for (let e of [...this.meshScene.children])
|
|
2512
|
+
for (let e of [...this.meshScene.children]) h(e);
|
|
2472
2513
|
this.meshScene.clear(), this.meshScene = null;
|
|
2473
2514
|
}
|
|
2474
2515
|
this._sceneHelpers?.clear(), this._sceneHelpers = null, this.scene?.clear(), this.scene = null;
|
|
2475
2516
|
try {
|
|
2476
|
-
let e =
|
|
2517
|
+
let e = Xe().value, t = We().value;
|
|
2477
2518
|
e?._listeners?.dispose && (e._listeners.dispose.length = 0), t?._listeners?.dispose && (t._listeners.dispose.length = 0);
|
|
2478
2519
|
} catch (e) {
|
|
2479
2520
|
$.warn("failed to clear TSL texture singleton listeners", e);
|
|
2480
2521
|
}
|
|
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),
|
|
2522
|
+
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
2523
|
}
|
|
2483
2524
|
}
|
|
2484
2525
|
unloadScene() {
|
|
2485
2526
|
if (this.isInitialized) {
|
|
2486
2527
|
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(
|
|
2528
|
+
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(Zn()), 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
2529
|
}
|
|
2489
2530
|
}
|
|
2490
2531
|
async loadModel(e, t = {}) {
|
|
2491
2532
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadModel(e, t), {
|
|
2492
|
-
type:
|
|
2533
|
+
type: m.MODEL_LOADED,
|
|
2493
2534
|
url: e
|
|
2494
2535
|
}, {
|
|
2495
2536
|
kind: "url",
|
|
@@ -2499,7 +2540,7 @@ var Yn = class extends I {
|
|
|
2499
2540
|
}
|
|
2500
2541
|
async loadObject3D(e, t = "object3d") {
|
|
2501
2542
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadObject3D(e, t), {
|
|
2502
|
-
type:
|
|
2543
|
+
type: m.OBJECT3D_LOADED,
|
|
2503
2544
|
name: t
|
|
2504
2545
|
}, {
|
|
2505
2546
|
kind: "object3d",
|
|
@@ -2517,7 +2558,7 @@ var Yn = class extends I {
|
|
|
2517
2558
|
await this.assetLoader.loadEnvironment(e);
|
|
2518
2559
|
let t = this.meshScene.environment;
|
|
2519
2560
|
t && this.stages.pathTracer && await this.stages.pathTracer.environment.setEnvironmentMap(t), this.pipeline?.eventBus.emit("pipeline:lightingChanged"), this.reset(), this.dispatchEvent({
|
|
2520
|
-
type:
|
|
2561
|
+
type: m.ENVIRONMENT_LOADED,
|
|
2521
2562
|
url: e
|
|
2522
2563
|
});
|
|
2523
2564
|
} finally {
|
|
@@ -2536,31 +2577,31 @@ var Yn = class extends I {
|
|
|
2536
2577
|
...t,
|
|
2537
2578
|
filename: n
|
|
2538
2579
|
}), {
|
|
2539
|
-
type:
|
|
2580
|
+
type: m.MODEL_LOADED,
|
|
2540
2581
|
filename: n
|
|
2541
2582
|
}, {
|
|
2542
2583
|
kind: "url",
|
|
2543
2584
|
url: e,
|
|
2544
2585
|
filename: n,
|
|
2545
2586
|
cacheKey: t.cacheKey ?? null,
|
|
2546
|
-
...
|
|
2587
|
+
...Kn(t)
|
|
2547
2588
|
});
|
|
2548
2589
|
return;
|
|
2549
2590
|
}
|
|
2550
|
-
if (
|
|
2551
|
-
let n =
|
|
2591
|
+
if (Ne(e)) {
|
|
2592
|
+
let n = Me(e, { isModel: (e) => this.assetLoader?.getFileFormat(e)?.type === "model" });
|
|
2552
2593
|
if (n.files.length === 0) throw Error(`${n.name} holds no files to load`);
|
|
2553
2594
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadFolder(n, t), {
|
|
2554
|
-
type:
|
|
2595
|
+
type: m.MODEL_LOADED,
|
|
2555
2596
|
filename: n.name
|
|
2556
2597
|
}, async () => {
|
|
2557
|
-
let e = await
|
|
2598
|
+
let e = await je(n);
|
|
2558
2599
|
return {
|
|
2559
2600
|
kind: "local-folder",
|
|
2560
2601
|
folder: e,
|
|
2561
|
-
key:
|
|
2602
|
+
key: E(e),
|
|
2562
2603
|
...n.flat ? { flat: !0 } : {},
|
|
2563
|
-
...
|
|
2604
|
+
...Kn(t)
|
|
2564
2605
|
};
|
|
2565
2606
|
}), this._sceneSourceInput = n;
|
|
2566
2607
|
return;
|
|
@@ -2568,22 +2609,22 @@ var Yn = class extends I {
|
|
|
2568
2609
|
let n = this.assetLoader?.getFileFormat(e?.name || "");
|
|
2569
2610
|
if (!n) throw this.assetLoader.formatError(e?.name || "");
|
|
2570
2611
|
if (n.type !== "environment" && n.type !== "image") {
|
|
2571
|
-
let n =
|
|
2612
|
+
let n = Ae(e).catch(() => ({
|
|
2572
2613
|
name: e.name,
|
|
2573
2614
|
size: e.size,
|
|
2574
2615
|
lastModified: e.lastModified ?? 0,
|
|
2575
2616
|
sample: null
|
|
2576
2617
|
}));
|
|
2577
2618
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadAssetFromFile(e, t), {
|
|
2578
|
-
type:
|
|
2619
|
+
type: m.MODEL_LOADED,
|
|
2579
2620
|
filename: e.name
|
|
2580
2621
|
}, async () => {
|
|
2581
2622
|
let e = await n;
|
|
2582
2623
|
return {
|
|
2583
2624
|
kind: "local-file",
|
|
2584
2625
|
file: e,
|
|
2585
|
-
key: e.sample ?
|
|
2586
|
-
...
|
|
2626
|
+
key: e.sample ? E(e) : null,
|
|
2627
|
+
...Kn(t)
|
|
2587
2628
|
};
|
|
2588
2629
|
}), this._sceneSourceInput = e;
|
|
2589
2630
|
return;
|
|
@@ -2594,7 +2635,7 @@ var Yn = class extends I {
|
|
|
2594
2635
|
await this.assetLoader.loadAssetFromFile(e);
|
|
2595
2636
|
let t = this.meshScene.environment;
|
|
2596
2637
|
t && this.stages.pathTracer && await this.stages.pathTracer.environment.applyHDRI(t), this.pipeline?.eventBus.emit("pipeline:lightingChanged"), this.reset(), this.dispatchEvent({
|
|
2597
|
-
type:
|
|
2638
|
+
type: m.ENVIRONMENT_LOADED,
|
|
2598
2639
|
filename: e.name
|
|
2599
2640
|
});
|
|
2600
2641
|
} finally {
|
|
@@ -2603,7 +2644,7 @@ var Yn = class extends I {
|
|
|
2603
2644
|
}
|
|
2604
2645
|
async loadExampleModels(e, t) {
|
|
2605
2646
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadExampleModels(e, t), {
|
|
2606
|
-
type:
|
|
2647
|
+
type: m.MODEL_LOADED,
|
|
2607
2648
|
index: e
|
|
2608
2649
|
}, {
|
|
2609
2650
|
kind: "url",
|
|
@@ -2620,7 +2661,7 @@ var Yn = class extends I {
|
|
|
2620
2661
|
this._loadingInProgress = !0;
|
|
2621
2662
|
try {
|
|
2622
2663
|
await this.loadSceneData(), this.reset(), this.dispatchEvent({
|
|
2623
|
-
type:
|
|
2664
|
+
type: m.TEXTURES_REPROCESSED,
|
|
2624
2665
|
maxTextureSize: r
|
|
2625
2666
|
});
|
|
2626
2667
|
} finally {
|
|
@@ -2632,16 +2673,16 @@ var Yn = class extends I {
|
|
|
2632
2673
|
return this._sceneSource ?? null;
|
|
2633
2674
|
}
|
|
2634
2675
|
get sceneSourceFile() {
|
|
2635
|
-
return this._sceneSourceInput && !
|
|
2676
|
+
return this._sceneSourceInput && !Ne(this._sceneSourceInput) ? this._sceneSourceInput : null;
|
|
2636
2677
|
}
|
|
2637
2678
|
get sceneSourceFolder() {
|
|
2638
|
-
return
|
|
2679
|
+
return Ne(this._sceneSourceInput) ? this._sceneSourceInput : null;
|
|
2639
2680
|
}
|
|
2640
2681
|
async _loadWithSceneRebuild(e, t, n = null) {
|
|
2641
2682
|
if (this._loadingInProgress) throw this._busyError("PathTracerApp");
|
|
2642
|
-
this._loadingInProgress = !0;
|
|
2683
|
+
this._loadingInProgress = !0, this.assetLoader && (this.assetLoader.maxEnvironmentWidth = this._memorySpill === !0 ? se : 0);
|
|
2643
2684
|
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();
|
|
2685
|
+
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
2686
|
} catch (e) {
|
|
2646
2687
|
throw (!e || e.code !== "LOAD_IN_PROGRESS") && this._discardFailedLoad(), e?.code === "ARCHIVE_NEEDS_ELEMENT" ? y() : e?.code !== "LOAD_IN_PROGRESS" && v({
|
|
2647
2688
|
status: `Error: ${e?.message ?? e}`,
|
|
@@ -2649,7 +2690,7 @@ var Yn = class extends I {
|
|
|
2649
2690
|
progress: 100
|
|
2650
2691
|
}), e;
|
|
2651
2692
|
} finally {
|
|
2652
|
-
this._loadingInProgress = !1;
|
|
2693
|
+
this._loadingInProgress = !1, this._spillPlan = null;
|
|
2653
2694
|
}
|
|
2654
2695
|
}
|
|
2655
2696
|
_discardFailedLoad() {
|
|
@@ -2685,7 +2726,7 @@ var Yn = class extends I {
|
|
|
2685
2726
|
reset: !1,
|
|
2686
2727
|
source: Y.SCENE_METADATA
|
|
2687
2728
|
}), this.scene && (this.scene.background = e), this.dispatchEvent({
|
|
2688
|
-
type:
|
|
2729
|
+
type: m.SCENE_METADATA_APPLIED,
|
|
2689
2730
|
metadata: t,
|
|
2690
2731
|
environment: { ...n }
|
|
2691
2732
|
});
|
|
@@ -2702,7 +2743,7 @@ var Yn = class extends I {
|
|
|
2702
2743
|
reset: !1,
|
|
2703
2744
|
source: Y.SCENE_METADATA
|
|
2704
2745
|
}), this.dispatchEvent({
|
|
2705
|
-
type:
|
|
2746
|
+
type: m.SCENE_METADATA_APPLIED,
|
|
2706
2747
|
metadata: this.sceneMetadata,
|
|
2707
2748
|
environment: { enabled: !1 }
|
|
2708
2749
|
});
|
|
@@ -2717,14 +2758,14 @@ var Yn = class extends I {
|
|
|
2717
2758
|
source: i
|
|
2718
2759
|
});
|
|
2719
2760
|
this.dispatchEvent({
|
|
2720
|
-
type:
|
|
2761
|
+
type: m.SCENE_METADATA_APPLIED,
|
|
2721
2762
|
metadata: this.sceneMetadata,
|
|
2722
2763
|
environment: { enabled: this.settings.get("enableEnvironment") }
|
|
2723
2764
|
});
|
|
2724
2765
|
}
|
|
2725
2766
|
async loadSceneData({ pendingEnvironment: e = null, keepUserLights: t = !1 } = {}) {
|
|
2726
2767
|
this._releaseSceneState({ keepSelection: !!this._preserveSelectionOnRebuild }), this._tagPrimarySceneObject();
|
|
2727
|
-
let n = new
|
|
2768
|
+
let n = new d("", {
|
|
2728
2769
|
namespace: "scene",
|
|
2729
2770
|
level: "info"
|
|
2730
2771
|
}), r = () => this.stages.pathTracer.environment.envParams.mode === "hdri" ? this.meshScene.environment : null, i = r(), a = null;
|
|
@@ -2738,7 +2779,8 @@ var Yn = class extends I {
|
|
|
2738
2779
|
}), this.assetLoader?.flushPendingGraph(this._sdf.performanceMetrics.totalProcessingTime), n.end("BVH build (SceneProcessor)"), v({
|
|
2739
2780
|
status: "Transferring data to GPU...",
|
|
2740
2781
|
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;
|
|
2782
|
+
}), 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;
|
|
2783
|
+
for (let e of [...this._sdf.srgbBucketTextures ?? [], ...this._sdf.linearBucketTextures ?? []]) e && (this.renderer.initTexture(e), await this.stages.pathTracer.drainUploads());
|
|
2742
2784
|
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
2785
|
status: "Compiling shaders...",
|
|
2744
2786
|
progress: 90
|
|
@@ -2751,7 +2793,7 @@ var Yn = class extends I {
|
|
|
2751
2793
|
let e = (this._sdf?.emissiveTriangleBuilder?.emissiveTriangles?.length ?? this._sdf?.emissiveTriangleCount ?? 0) > 0;
|
|
2752
2794
|
this.settings.set("enableEmissiveTriangleSampling", e, { reset: !1 });
|
|
2753
2795
|
}
|
|
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()), y(), this._sceneRebuilt(), this.dispatchEvent({ type:
|
|
2796
|
+
return n.start("Apply settings"), this.settings.applyAll(), this.stages.compositor.setTransparentBackground(this.settings.get("transparentBackground")), n.end("Apply settings"), n.print(this._sceneSummaryParts()), y(), this._sceneRebuilt(), this.dispatchEvent({ type: m.SCENE_REBUILD }), !0;
|
|
2755
2797
|
}
|
|
2756
2798
|
_sceneSummaryParts() {
|
|
2757
2799
|
let e = this.stages.pathTracer, t = this._sdf?.instanceTable?.setCount ?? 0, n = this._sdf?.geometryExtractor?.maps?.length ?? 0;
|
|
@@ -2782,7 +2824,7 @@ var Yn = class extends I {
|
|
|
2782
2824
|
try {
|
|
2783
2825
|
let { root: r } = await this.assetLoader.appendModel(e, { cacheKey: n });
|
|
2784
2826
|
return r.userData.__rayzeeSceneObject = !0, r.userData.__rayzeeSourceUrl = e, n && (r.userData.__rayzeeCacheKey = n), t && (r.userData.__rayzeeName = t), await this._finishRebuildNoReframe({
|
|
2785
|
-
type:
|
|
2827
|
+
type: m.MODEL_ADDED,
|
|
2786
2828
|
url: e,
|
|
2787
2829
|
id: r.uuid
|
|
2788
2830
|
}), r.uuid;
|
|
@@ -2796,7 +2838,7 @@ var Yn = class extends I {
|
|
|
2796
2838
|
try {
|
|
2797
2839
|
let { root: n } = this.assetLoader.appendObject3D(e, t || "object3d");
|
|
2798
2840
|
return n.userData.__rayzeeSceneObject = !0, t && (n.userData.__rayzeeName = t), await this._finishRebuildNoReframe({
|
|
2799
|
-
type:
|
|
2841
|
+
type: m.MODEL_ADDED,
|
|
2800
2842
|
id: n.uuid
|
|
2801
2843
|
}), n.uuid;
|
|
2802
2844
|
} finally {
|
|
@@ -2813,7 +2855,7 @@ var Yn = class extends I {
|
|
|
2813
2855
|
this._loadingInProgress = !0;
|
|
2814
2856
|
try {
|
|
2815
2857
|
return this._releaseSceneState(), n === this.sceneModel ? this.assetLoader.releaseTargetModel() : this.assetLoader.removeModelRoot(n), await this._finishRebuildNoReframe({
|
|
2816
|
-
type:
|
|
2858
|
+
type: m.SCENE_OBJECT_REMOVED,
|
|
2817
2859
|
id: e
|
|
2818
2860
|
}), !0;
|
|
2819
2861
|
} finally {
|
|
@@ -2823,29 +2865,55 @@ var Yn = class extends I {
|
|
|
2823
2865
|
setSceneObjectVisibility(e, t) {
|
|
2824
2866
|
return this.setMeshVisibilityByUuid(e, t);
|
|
2825
2867
|
}
|
|
2868
|
+
get memorySpill() {
|
|
2869
|
+
return this._memorySpill;
|
|
2870
|
+
}
|
|
2871
|
+
setMemorySpill(e) {
|
|
2872
|
+
this._memorySpill = e === !0 || e === !1 ? e : "auto";
|
|
2873
|
+
}
|
|
2874
|
+
get sceneSpilled() {
|
|
2875
|
+
return !!this._sdf?.spilling;
|
|
2876
|
+
}
|
|
2877
|
+
get geometryOnDisk() {
|
|
2878
|
+
return this._sdf?.geometryOnDisk === !0;
|
|
2879
|
+
}
|
|
2826
2880
|
_sceneBudgets(e) {
|
|
2827
|
-
return
|
|
2828
|
-
maxTriangles:
|
|
2829
|
-
maxPlacements:
|
|
2881
|
+
return this._memorySpill === !1 || !this.storage ? e : {
|
|
2882
|
+
maxTriangles: ie,
|
|
2883
|
+
maxPlacements: fe,
|
|
2830
2884
|
...e
|
|
2831
2885
|
};
|
|
2832
2886
|
}
|
|
2887
|
+
_planSpill() {
|
|
2888
|
+
let e = this._memorySpill !== !1 && !!this.storage && (this.assetLoader?.animations?.length ?? 0) === 0 && (this._memorySpill === !0 || this._sdf.needsSpill(this.meshScene));
|
|
2889
|
+
this.assetLoader && (this.assetLoader.maxEnvironmentWidth = e ? se : 0);
|
|
2890
|
+
let t = e ? this.meshScene?.environment : null, n = t?.image;
|
|
2891
|
+
return n && Rn(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;
|
|
2892
|
+
}
|
|
2833
2893
|
_progressiveSpill() {
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
return {
|
|
2894
|
+
let e = this._spillPlan ?? this._planSpill();
|
|
2895
|
+
return this._spillPlan = null, e ? {
|
|
2837
2896
|
storage: this.storage,
|
|
2838
|
-
uploader:
|
|
2839
|
-
};
|
|
2897
|
+
uploader: this._chunkUploader()
|
|
2898
|
+
} : null;
|
|
2899
|
+
}
|
|
2900
|
+
_chunkUploader() {
|
|
2901
|
+
let e = this.stages.pathTracer;
|
|
2902
|
+
return (t, n, r) => n === "triangles" ? e.createTriangleChunkUploader(t, r) : e.createChunkUploader(t);
|
|
2840
2903
|
}
|
|
2841
2904
|
_maybeSpill() {
|
|
2842
|
-
!this.
|
|
2843
|
-
type:
|
|
2905
|
+
!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({
|
|
2906
|
+
type: m.SCENE_SPILLED,
|
|
2844
2907
|
...e
|
|
2845
|
-
})).catch((e) => this._issues.warn(S.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`));
|
|
2908
|
+
})).catch((e) => this._issues.warn(S.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`)));
|
|
2909
|
+
}
|
|
2910
|
+
_scheduleRespill() {
|
|
2911
|
+
this._sdf?.spilling && (clearTimeout(this._respillTimer), this._respillTimer = setTimeout(() => {
|
|
2912
|
+
this._respillTimer = null, this._sdf?.respill().catch((e) => this._issues.warn(S.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`));
|
|
2913
|
+
}, qn), this._respillTimer.unref?.());
|
|
2846
2914
|
}
|
|
2847
2915
|
async ensureSceneResident() {
|
|
2848
|
-
this._sdf?.spilled && await this._sdf.ensureResident();
|
|
2916
|
+
this._sdf?.spilled && await this._sdf.ensureResident(), await this._sdf?.ensureGeometryResident();
|
|
2849
2917
|
}
|
|
2850
2918
|
get sceneMeshes() {
|
|
2851
2919
|
return this._sdf?.meshes ?? [];
|
|
@@ -2871,39 +2939,40 @@ var Yn = class extends I {
|
|
|
2871
2939
|
}), r;
|
|
2872
2940
|
}
|
|
2873
2941
|
updateMeshTransforms(e) {
|
|
2942
|
+
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
2943
|
this._notePlacementsMoving(e);
|
|
2875
2944
|
let t = this._sdf.updateMeshTransforms(e);
|
|
2876
|
-
return this.stages.pathTracer.updateBufferRanges([],
|
|
2945
|
+
return this.stages.pathTracer.updateBufferRanges([], this._sdf.takeMoveRanges()), this.reset(!1, { motion: !0 }), this._scheduleRespill(), t;
|
|
2877
2946
|
}
|
|
2878
2947
|
setReservedRenderResolution(e, { allowLower: n = !1 } = {}) {
|
|
2879
|
-
let
|
|
2948
|
+
let i = n ? e : Math.max(e, r);
|
|
2880
2949
|
if (!this.renderer) return this._pendingReservedRenderSize = {
|
|
2881
2950
|
requestedPx: e,
|
|
2882
2951
|
allowLower: n
|
|
2883
|
-
}, Math.max(256, Math.min(
|
|
2884
|
-
let
|
|
2885
|
-
if (
|
|
2952
|
+
}, Math.max(256, Math.min(f, Math.floor(i) || 256));
|
|
2953
|
+
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));
|
|
2954
|
+
if (c < Math.floor(e) && this._issues.warn(S.RENDER_RESERVE_CAPPED, `reserved render size ${x.n(e)}px was capped to ${x.n(c)}px by this device's limits — renders above ${x.n(c)}px will be declined` + (o.assumed && o.gb < 8 ? " (host memory unknown, 4 GB assumed: pass hostMemoryGB)" : ""), {
|
|
2886
2955
|
requested: e,
|
|
2887
|
-
applied:
|
|
2888
|
-
deviceMemoryGB:
|
|
2889
|
-
assumed:
|
|
2890
|
-
maxStorageBufferBindingSize:
|
|
2891
|
-
}), (this.stages?.pathTracer?.storageTextures?.writeColor?.image?.width ??
|
|
2956
|
+
applied: c,
|
|
2957
|
+
deviceMemoryGB: o.gb,
|
|
2958
|
+
assumed: o.assumed,
|
|
2959
|
+
maxStorageBufferBindingSize: a
|
|
2960
|
+
}), (this.stages?.pathTracer?.storageTextures?.writeColor?.image?.width ?? c) !== c) {
|
|
2892
2961
|
let e = this.pauseRendering;
|
|
2893
2962
|
this.pauseRendering = !0;
|
|
2894
2963
|
try {
|
|
2895
2964
|
let e = this.renderer.domElement;
|
|
2896
|
-
(e.width >
|
|
2965
|
+
(e.width > c || e.height > c) && this.renderer.setSize(Math.min(e.width, c), Math.min(e.height, c), !1);
|
|
2897
2966
|
for (let e of Object.values(this.stages)) e?.reallocateReservedStorage?.();
|
|
2898
2967
|
} finally {
|
|
2899
2968
|
this.pauseRendering = e;
|
|
2900
2969
|
}
|
|
2901
2970
|
this.reset(), this.dispatchEvent({
|
|
2902
|
-
type:
|
|
2903
|
-
size:
|
|
2971
|
+
type: m.RESERVED_RENDER_SIZE_CHANGED,
|
|
2972
|
+
size: c
|
|
2904
2973
|
});
|
|
2905
2974
|
}
|
|
2906
|
-
return
|
|
2975
|
+
return c;
|
|
2907
2976
|
}
|
|
2908
2977
|
_applyPendingReservedRenderSize() {
|
|
2909
2978
|
let e = this._pendingReservedRenderSize;
|
|
@@ -2911,18 +2980,18 @@ var Yn = class extends I {
|
|
|
2911
2980
|
this._pendingReservedRenderSize = null;
|
|
2912
2981
|
let t = this.setReservedRenderResolution(e.requestedPx, { allowLower: e.allowLower });
|
|
2913
2982
|
this.dispatchEvent({
|
|
2914
|
-
type:
|
|
2983
|
+
type: m.RESERVED_RENDER_SIZE_CHANGED,
|
|
2915
2984
|
size: t
|
|
2916
2985
|
});
|
|
2917
2986
|
}
|
|
2918
2987
|
getReservedRenderResolution() {
|
|
2919
|
-
return
|
|
2988
|
+
return r;
|
|
2920
2989
|
}
|
|
2921
2990
|
_isRenderSizeSupported(e, t) {
|
|
2922
|
-
return e >
|
|
2991
|
+
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
2992
|
width: e,
|
|
2924
2993
|
height: t,
|
|
2925
|
-
reserve:
|
|
2994
|
+
reserve: r
|
|
2926
2995
|
}), !1) : !0;
|
|
2927
2996
|
}
|
|
2928
2997
|
onResize() {
|
|
@@ -2933,7 +3002,7 @@ var Yn = class extends I {
|
|
|
2933
3002
|
}
|
|
2934
3003
|
_applyRenderResize(e, t) {
|
|
2935
3004
|
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:
|
|
3005
|
+
type: m.RESOLUTION_CHANGED,
|
|
2937
3006
|
width: e,
|
|
2938
3007
|
height: t
|
|
2939
3008
|
}));
|
|
@@ -3020,7 +3089,7 @@ var Yn = class extends I {
|
|
|
3020
3089
|
let e = l ? "adaptive sampling retired the frame at the convergence threshold — pass `allowEarlyRetire: true`, or disable it with setDeterministicMode()" : "something retired the render (maxSamples, a stray reset, or a canvas resize)";
|
|
3021
3090
|
throw Error(`renderFrames: stopped at ${a.frameCount}/${o} samples after ${c} passes — ${e}`);
|
|
3022
3091
|
}
|
|
3023
|
-
return a.frameCount;
|
|
3092
|
+
return await this._finishImage(), a.frameCount;
|
|
3024
3093
|
}
|
|
3025
3094
|
async renderUntilComplete({ reset: e = !0, denoise: t = !0, signal: n, drainEvery: r = 4, onProgress: i } = {}) {
|
|
3026
3095
|
let a = this.stages.pathTracer;
|
|
@@ -3052,8 +3121,8 @@ var Yn = class extends I {
|
|
|
3052
3121
|
}
|
|
3053
3122
|
}
|
|
3054
3123
|
let l = this._completionInfo();
|
|
3055
|
-
this.completion.markComplete() && this.dispatchEvent({
|
|
3056
|
-
type:
|
|
3124
|
+
await this._finishImage(), this.completion.markComplete() && this.dispatchEvent({
|
|
3125
|
+
type: m.RENDER_COMPLETE,
|
|
3057
3126
|
...l
|
|
3058
3127
|
});
|
|
3059
3128
|
let u = t ? await this._finalDenoise() : !1, { reason: d, ...f } = l;
|
|
@@ -3072,9 +3141,9 @@ var Yn = class extends I {
|
|
|
3072
3141
|
}
|
|
3073
3142
|
getProvenance() {
|
|
3074
3143
|
let e = this.stages.pathTracer, t = this.color?.status();
|
|
3075
|
-
return
|
|
3144
|
+
return i({
|
|
3076
3145
|
engine: le,
|
|
3077
|
-
three:
|
|
3146
|
+
three: xt,
|
|
3078
3147
|
adapter: this.adapterInfo ?? null,
|
|
3079
3148
|
mode: {
|
|
3080
3149
|
headless: this._headless,
|
|
@@ -3127,7 +3196,7 @@ var Yn = class extends I {
|
|
|
3127
3196
|
let t = this.stages.pathTracer;
|
|
3128
3197
|
if (!t) throw Error("restoreRenderCheckpoint: app is not initialized");
|
|
3129
3198
|
t.restoreAccumulation(e), this.needsReset = !1, this.dispatchEvent({
|
|
3130
|
-
type:
|
|
3199
|
+
type: m.RENDER_RESET,
|
|
3131
3200
|
restored: e.samples
|
|
3132
3201
|
});
|
|
3133
3202
|
}
|
|
@@ -3135,40 +3204,48 @@ var Yn = class extends I {
|
|
|
3135
3204
|
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
3205
|
let r = this.stages?.pathTracer, i = r?.storageTextures?.readTarget;
|
|
3137
3206
|
if (!i) throw Error("renderToBuffer: no render target — call init() and render at least one sample");
|
|
3138
|
-
let { width:
|
|
3207
|
+
let { width: o, height: s } = r;
|
|
3139
3208
|
if (e === "srgb") {
|
|
3140
|
-
let r = n === "display" ? this._displaySource(i) : null,
|
|
3209
|
+
let r = n === "display" ? this._displaySource(i) : null, c = {
|
|
3141
3210
|
exposure: this.renderer.toneMappingExposure,
|
|
3142
3211
|
toneMapping: this.renderer.toneMapping,
|
|
3143
3212
|
saturation: this.settings.get("saturation") ?? 1,
|
|
3144
|
-
preserveAlpha: t
|
|
3145
|
-
|
|
3213
|
+
preserveAlpha: t,
|
|
3214
|
+
gain: this._displayGain()
|
|
3215
|
+
}, l = await this._toneMapOnGPU(r?.texture ?? null, i, o, s, c), u = !l && c.gain ? await c.gain.cpu() : null;
|
|
3146
3216
|
return {
|
|
3147
|
-
data: l ??
|
|
3148
|
-
|
|
3149
|
-
|
|
3217
|
+
data: l ?? a(r ? await this._readTexture(r.texture, o, s) : await this.renderer.readRenderTargetPixelsAsync(i, 0, 0, o, s, 0), {
|
|
3218
|
+
...c,
|
|
3219
|
+
pixelGain: u && {
|
|
3220
|
+
fn: u,
|
|
3221
|
+
width: o,
|
|
3222
|
+
height: s
|
|
3223
|
+
}
|
|
3224
|
+
}),
|
|
3225
|
+
width: o,
|
|
3226
|
+
height: s,
|
|
3150
3227
|
colorSpace: e,
|
|
3151
3228
|
source: r?.source ?? "accumulation",
|
|
3152
3229
|
toneMappedOn: l ? "gpu" : "cpu"
|
|
3153
3230
|
};
|
|
3154
3231
|
}
|
|
3155
|
-
let { data:
|
|
3156
|
-
data: await this.renderer.readRenderTargetPixelsAsync(i, 0, 0,
|
|
3232
|
+
let { data: c, source: l } = n === "display" ? await this._readDisplaySource(i, o, s) : {
|
|
3233
|
+
data: await this.renderer.readRenderTargetPixelsAsync(i, 0, 0, o, s, 0),
|
|
3157
3234
|
source: "accumulation"
|
|
3158
3235
|
};
|
|
3159
3236
|
if (e === "linear") return {
|
|
3160
|
-
data:
|
|
3161
|
-
width:
|
|
3162
|
-
height:
|
|
3237
|
+
data: c,
|
|
3238
|
+
width: o,
|
|
3239
|
+
height: s,
|
|
3163
3240
|
colorSpace: e,
|
|
3164
3241
|
workingSpace: this.color?.workingSpace ?? null,
|
|
3165
3242
|
source: l
|
|
3166
3243
|
};
|
|
3167
|
-
let { rgba: u, colorSpace: d } = this.color.exportPixels(
|
|
3244
|
+
let { rgba: u, colorSpace: d } = this.color.exportPixels(c, e);
|
|
3168
3245
|
return {
|
|
3169
3246
|
data: u,
|
|
3170
|
-
width:
|
|
3171
|
-
height:
|
|
3247
|
+
width: o,
|
|
3248
|
+
height: s,
|
|
3172
3249
|
colorSpace: d,
|
|
3173
3250
|
source: l
|
|
3174
3251
|
};
|
|
@@ -3178,9 +3255,9 @@ var Yn = class extends I {
|
|
|
3178
3255
|
if (!a?.device) return this._toneMapFallback("the renderer has no WebGPU device");
|
|
3179
3256
|
try {
|
|
3180
3257
|
let o = e ? this._readbackPass().draw(e, n, r).texture : t.textures[0], s = a.get(o).texture;
|
|
3181
|
-
return s ? (this._readbackToneMapper ??= new
|
|
3258
|
+
return s ? (this._readbackToneMapper ??= new Fe(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
3259
|
} catch (e) {
|
|
3183
|
-
if (e instanceof
|
|
3260
|
+
if (e instanceof ve) throw e;
|
|
3184
3261
|
return this._toneMapFallback("the GPU pass threw", e);
|
|
3185
3262
|
} finally {
|
|
3186
3263
|
this._readbackToneMapper?.release(), e && this._textureReadback?.release();
|
|
@@ -3303,7 +3380,7 @@ var Yn = class extends I {
|
|
|
3303
3380
|
...this._canvasResources()
|
|
3304
3381
|
]);
|
|
3305
3382
|
let t = () => e.measure();
|
|
3306
|
-
this._addTrackedListener(this,
|
|
3383
|
+
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
3384
|
}
|
|
3308
3385
|
_collectStageTextures() {
|
|
3309
3386
|
let e = [], t = this.stages || {}, n = t.pathTracer;
|
|
@@ -3318,7 +3395,7 @@ var Yn = class extends I {
|
|
|
3318
3395
|
}
|
|
3319
3396
|
getSceneMinY() {
|
|
3320
3397
|
if (!this.meshScene) return 0;
|
|
3321
|
-
let e = new
|
|
3398
|
+
let e = new $e().setFromObject(this.meshScene);
|
|
3322
3399
|
return Number.isFinite(e.min.y) ? e.min.y : 0;
|
|
3323
3400
|
}
|
|
3324
3401
|
getMaterialProperty(e, t) {
|
|
@@ -3328,7 +3405,7 @@ var Yn = class extends I {
|
|
|
3328
3405
|
return this.stages.pathTracer?.materialData.getMaterialPropertySource(e, t);
|
|
3329
3406
|
}
|
|
3330
3407
|
setMaterialProperty(e, t, n) {
|
|
3331
|
-
if (this._sdf?.spilled &&
|
|
3408
|
+
if (this._sdf?.spilled && c.has(t)) {
|
|
3332
3409
|
this.ensureSceneResident().then(() => this.setMaterialProperty(e, t, n));
|
|
3333
3410
|
return;
|
|
3334
3411
|
}
|
|
@@ -3351,10 +3428,17 @@ var Yn = class extends I {
|
|
|
3351
3428
|
return (this._sdf?.emissiveTriangleBuilder?.emissiveTriangles?.length ?? this._sdf?.emissiveTriangleCount ?? 0) > 0;
|
|
3352
3429
|
}
|
|
3353
3430
|
setMeshVisibility(e, t) {
|
|
3354
|
-
this.stages.pathTracer?.updateMeshVisibility(e, t)
|
|
3431
|
+
this._whenTLASEditable(() => this.stages.pathTracer?.updateMeshVisibility(e, t));
|
|
3355
3432
|
}
|
|
3356
3433
|
updateAllMeshVisibility() {
|
|
3357
|
-
this.stages.pathTracer?.updateAllMeshVisibility()
|
|
3434
|
+
this._whenTLASEditable(() => this.stages.pathTracer?.updateAllMeshVisibility());
|
|
3435
|
+
}
|
|
3436
|
+
_whenTLASEditable(e) {
|
|
3437
|
+
let t = () => {
|
|
3438
|
+
e(), this._refreshEmissiveForVisibility(), this.reset(), this._scheduleRespill();
|
|
3439
|
+
}, n = this._sdf?.whenTLASEditable();
|
|
3440
|
+
if (!n) return t();
|
|
3441
|
+
n.then(t).catch((e) => this._issues.warn(S.STORAGE_READ_FAILED, `reading the TLAS back failed: ${e.message}`));
|
|
3358
3442
|
}
|
|
3359
3443
|
getScene() {
|
|
3360
3444
|
return this.meshScene || this.scene;
|
|
@@ -3389,7 +3473,7 @@ var Yn = class extends I {
|
|
|
3389
3473
|
};
|
|
3390
3474
|
}
|
|
3391
3475
|
_readbackPass() {
|
|
3392
|
-
return this._textureReadback ??= new
|
|
3476
|
+
return this._textureReadback ??= new Zt(this.renderer);
|
|
3393
3477
|
}
|
|
3394
3478
|
_readTexture(e, t, n) {
|
|
3395
3479
|
return this._readbackPass().read(e, t, n);
|
|
@@ -3400,20 +3484,20 @@ var Yn = class extends I {
|
|
|
3400
3484
|
n.__rayzeeOriginalColorSpace === void 0 && (n.__rayzeeOriginalColorSpace = e.colorSpace);
|
|
3401
3485
|
let r = n.__rayzeeOriginalColorSpace;
|
|
3402
3486
|
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" ?
|
|
3487
|
+
else if (t === "srgb" || t === "linear") e.colorSpace = t === "srgb" ? O : Ie, n.__rayzeeColorSpaceChoice = t;
|
|
3404
3488
|
else {
|
|
3405
3489
|
if (!this.color?.hasConfig) throw Error(`"${t}" needs a colour config loaded`);
|
|
3406
|
-
n.ocioColorSpace = t, e.colorSpace =
|
|
3490
|
+
n.ocioColorSpace = t, e.colorSpace = O;
|
|
3407
3491
|
}
|
|
3408
3492
|
e.needsUpdate = !0, this.stages.pathTracer?.sdfs && await this.rebuildMaterials();
|
|
3409
3493
|
}
|
|
3410
3494
|
setColorManagement(e) {
|
|
3411
|
-
this.color?.dispose(), this.color = new e({ issues: this._issues }),
|
|
3495
|
+
this.color?.dispose(), this.color = new e({ issues: this._issues }), Se(this.color), this.renderer && this.color.attachRenderer(this.renderer);
|
|
3412
3496
|
}
|
|
3413
3497
|
async loadColorConfig(e = {}) {
|
|
3414
3498
|
await this._leaveColorWorkingSpace();
|
|
3415
|
-
let t =
|
|
3416
|
-
return this.color.workingSpaceAdopted && await this.applyColorWorkingSpace(), (!(t?.source === "ocio" &&
|
|
3499
|
+
let t = T(this.renderer?.toneMapping), n = await this.color.loadConfig(e);
|
|
3500
|
+
return this.color.workingSpaceAdopted && await this.applyColorWorkingSpace(), (!(t?.source === "ocio" && T(this.renderer?.toneMapping) === t) || this.color.workingSpaceAdopted) && this.reset(), n;
|
|
3417
3501
|
}
|
|
3418
3502
|
async unloadColorConfig() {
|
|
3419
3503
|
await this._leaveColorWorkingSpace(), this.color.unloadConfig(), this.reset();
|
|
@@ -3431,13 +3515,15 @@ var Yn = class extends I {
|
|
|
3431
3515
|
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
3516
|
}
|
|
3433
3517
|
async rebuildMaterials(e) {
|
|
3434
|
-
await this.ensureSceneResident()
|
|
3518
|
+
await this.ensureSceneResident();
|
|
3519
|
+
let t = this.stages.pathTracer;
|
|
3520
|
+
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
3521
|
}
|
|
3436
3522
|
async _initRenderer() {
|
|
3437
|
-
if (
|
|
3523
|
+
if (ue((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
3524
|
let e = await navigator.gpu.requestAdapter({ powerPreference: "high-performance" });
|
|
3439
3525
|
if (!e) throw Error("Failed to get WebGPU adapter");
|
|
3440
|
-
this.adapterInfo =
|
|
3526
|
+
this.adapterInfo = er(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
3527
|
let t = e.limits, n = { maxColorAttachmentBytesPerSample: 128 };
|
|
3442
3528
|
for (let e of [
|
|
3443
3529
|
"maxBufferSize",
|
|
@@ -3455,23 +3541,23 @@ var Yn = class extends I {
|
|
|
3455
3541
|
let r = t[e];
|
|
3456
3542
|
r !== void 0 && (n[e] = r);
|
|
3457
3543
|
}
|
|
3458
|
-
if (n.maxStorageBuffersPerShaderStage = Math.min(t.maxStorageBuffersPerShaderStage, 10), this.renderer = new
|
|
3544
|
+
if (n.maxStorageBuffersPerShaderStage = Math.min(t.maxStorageBuffersPerShaderStage, 10), this.renderer = new Ve({
|
|
3459
3545
|
canvas: this.canvas,
|
|
3460
3546
|
alpha: !0,
|
|
3461
3547
|
powerPreference: "high-performance",
|
|
3462
3548
|
requiredLimits: n
|
|
3463
|
-
}), await
|
|
3549
|
+
}), await Xn(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
3550
|
let r = this.renderer.backend?.device;
|
|
3465
|
-
r?.lost && (this._gpuDevice = r, this._deviceLostHolder = { app: this },
|
|
3551
|
+
r?.lost && (this._gpuDevice = r, this._deviceLostHolder = { app: this }, Qn(r, this._deviceLostHolder), r.onuncapturederror = (e) => $.error("WebGPU uncaptured error:", e.error)), ze.setLTC(kt.init()), this.renderer.outputColorSpace = O, this.renderer.toneMapping = ke, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1), this.color.attachRenderer(this.renderer);
|
|
3466
3552
|
}
|
|
3467
3553
|
_initScenes() {
|
|
3468
|
-
this.scene = new
|
|
3554
|
+
this.scene = new V(), this.meshScene = new V(), this._sceneHelpers = new Ft();
|
|
3469
3555
|
}
|
|
3470
3556
|
_initAssetPipeline() {
|
|
3471
|
-
this._sdf = new
|
|
3557
|
+
this._sdf = new u({
|
|
3472
3558
|
issues: this._issues,
|
|
3473
3559
|
...this._maxSceneBytes === void 0 ? {} : { maxSceneBytes: this._maxSceneBytes }
|
|
3474
|
-
}), this.assetLoader = new
|
|
3560
|
+
}), this.assetLoader = new Ln(this.meshScene, this.camera, null, {
|
|
3475
3561
|
issues: this._issues,
|
|
3476
3562
|
areaLightIntensityScale: () => this.settings.get("areaLightIntensityScale")
|
|
3477
3563
|
}), this.assetLoader.setRenderer(this.renderer), this.assetLoader.createFloorPlane();
|
|
@@ -3479,14 +3565,14 @@ var Yn = class extends I {
|
|
|
3479
3565
|
_initPipeline() {
|
|
3480
3566
|
this._createStages();
|
|
3481
3567
|
let { clientWidth: e, clientHeight: t } = this.canvas;
|
|
3482
|
-
this.pipeline = new
|
|
3568
|
+
this.pipeline = new Jt(this.renderer, e || 1, t || 1, { issues: this._issues }), this.pipeline.addStage(this.stages.pathTracer);
|
|
3483
3569
|
for (let e of this._extraStages) this.pipeline.addStage(e);
|
|
3484
3570
|
this.pipeline.addStage(this.stages.compositor);
|
|
3485
3571
|
let n = this.canvas.clientWidth || 1, r = this.canvas.clientHeight || 1;
|
|
3486
3572
|
this._displayWidth = n, this._displayHeight = r, this._renderWidth = n, this._renderHeight = r, this.pipeline.setSize(n, r);
|
|
3487
3573
|
}
|
|
3488
3574
|
async _initManagers() {
|
|
3489
|
-
this.lightManager = new
|
|
3575
|
+
this.lightManager = new Gn(this.scene, this._sceneHelpers, this.stages.pathTracer, {
|
|
3490
3576
|
onReset: () => this.reset(),
|
|
3491
3577
|
onLightRemoved: (e) => this._lightRemoved(e)
|
|
3492
3578
|
}), 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();
|
|
@@ -3502,16 +3588,16 @@ var Yn = class extends I {
|
|
|
3502
3588
|
this.pauseRendering = !1, this.reset();
|
|
3503
3589
|
}
|
|
3504
3590
|
}, this._addTrackedListener(this.assetLoader, "load", this._onAssetLoaded), this.pipeline.eventBus.on("pathtracer:compiling", ({ compiling: e }) => this.dispatchEvent({
|
|
3505
|
-
type:
|
|
3591
|
+
type: m.SHADERS_COMPILING,
|
|
3506
3592
|
compiling: e
|
|
3507
3593
|
}));
|
|
3508
3594
|
}
|
|
3509
3595
|
_createStages() {
|
|
3510
|
-
this.stages.pathTracer = new
|
|
3596
|
+
this.stages.pathTracer = new l(this.renderer, this.scene, this.camera, {
|
|
3511
3597
|
hostMemoryGB: this._hostMemoryGB,
|
|
3512
3598
|
sortMaterials: this.settings.get("wavefrontSortMaterials")
|
|
3513
|
-
}), this._extraStages = this._createExtraStages(), this.stages.compositor = new
|
|
3514
|
-
saturation: this.settings.get("saturation") ??
|
|
3599
|
+
}), this._extraStages = this._createExtraStages(), this.stages.compositor = new It(this.renderer, {
|
|
3600
|
+
saturation: this.settings.get("saturation") ?? _.saturation,
|
|
3515
3601
|
pathTracer: this.stages.pathTracer,
|
|
3516
3602
|
displaySources: this._displaySources()
|
|
3517
3603
|
});
|
|
@@ -3520,13 +3606,13 @@ var Yn = class extends I {
|
|
|
3520
3606
|
let e = this.stages.pathTracer;
|
|
3521
3607
|
if (!e) return;
|
|
3522
3608
|
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:
|
|
3609
|
+
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
3610
|
}
|
|
3525
3611
|
_forwardEvents(e, t) {
|
|
3526
3612
|
if (e) for (let n of t) this._addTrackedListener(e, n, (e) => this.dispatchEvent(e));
|
|
3527
3613
|
}
|
|
3528
3614
|
_createCamera() {
|
|
3529
|
-
let e = new
|
|
3615
|
+
let e = new Hn(60, this.canvas.clientWidth / this.canvas.clientHeight || 1, .01, 1e3);
|
|
3530
3616
|
return e.position.set(0, 0, 5), e;
|
|
3531
3617
|
}
|
|
3532
3618
|
_createExtraStages() {
|
|
@@ -3552,6 +3638,12 @@ var Yn = class extends I {
|
|
|
3552
3638
|
}
|
|
3553
3639
|
_afterTrace() {}
|
|
3554
3640
|
_renderCompleted() {}
|
|
3641
|
+
_settling() {
|
|
3642
|
+
return !1;
|
|
3643
|
+
}
|
|
3644
|
+
_finishImage() {
|
|
3645
|
+
return null;
|
|
3646
|
+
}
|
|
3555
3647
|
_renderHelperOverlay() {
|
|
3556
3648
|
this.scene.updateMatrixWorld();
|
|
3557
3649
|
}
|
|
@@ -3570,6 +3662,9 @@ var Yn = class extends I {
|
|
|
3570
3662
|
async _finalDenoise() {
|
|
3571
3663
|
return !1;
|
|
3572
3664
|
}
|
|
3665
|
+
_displayGain() {
|
|
3666
|
+
return null;
|
|
3667
|
+
}
|
|
3573
3668
|
_denoiserInUse() {
|
|
3574
3669
|
return !1;
|
|
3575
3670
|
}
|
|
@@ -3587,4 +3682,4 @@ var Yn = class extends I {
|
|
|
3587
3682
|
_disposeExtensions() {}
|
|
3588
3683
|
};
|
|
3589
3684
|
//#endregion
|
|
3590
|
-
export {
|
|
3685
|
+
export { Lt as _, cn as a, J as c, q as d, an as f, Vt as g, Ht as h, Hn as i, on as l, Ut as m, er as n, Y as o, Jt as p, Gn as r, W as s, tr as t, rn as u };
|