rayzee 11.11.0 → 11.13.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/dist/{ArchiveImporter-D5XOC3tN.js → ArchiveImporter-DQU55mit.js} +1322 -1290
- package/dist/{BidirectionalIntegrator-DqG0BEIz.js → BidirectionalIntegrator-CLmFjSN3.js} +2 -2
- package/dist/{ColorManagement-B_HjAiy2.js → ColorManagement-3xw0xXRg.js} +859 -374
- package/dist/{NeuralRetouch-BkxZPOYq.js → NeuralRetouch-CEkBhI1M.js} +1 -1
- package/dist/{NeuralSuperRes-a8xDtvXM.js → NeuralSuperRes-Drjws9nE.js} +6 -6
- package/dist/{PathTracer-C_gliSWI.js → PathTracer-7a7L3cGF.js} +3448 -3404
- package/dist/{PhysicalSky-DWK8pS0U.js → PhysicalSky-DUIbTE93.js} +1 -1
- package/dist/{RayzeeRenderer-B4ZehMg_.js → RayzeeRenderer-CjjGT2e0.js} +390 -330
- package/dist/{SceneMetadata-Bb3iwWhh.js → SceneMetadata-CoAHTAmo.js} +1 -1
- package/dist/addons/archives.es.js +1 -1
- package/dist/addons/bidirectional.es.js +1 -1
- package/dist/addons/color.es.js +2 -2
- package/dist/addons/physical-sky.es.js +1 -1
- package/dist/rayzee-core.es.js +4 -4
- package/dist/rayzee.es.js +639 -629
- package/dist/rayzee.umd.js +110 -110
- package/dist/{sceneCachePolicy-BHNKvrHR.js → sceneCachePolicy-DavHt6Ii.js} +217 -185
- package/package.json +1 -1
- package/src/Color/BakedViews.js +5 -2
- package/src/Color/BasicColor.js +27 -0
- package/src/Color/ColorManagement.js +255 -11
- package/src/Color/Displays.js +149 -7
- package/src/Color/OcioRuntime.js +19 -4
- package/src/Color/OcioViews.js +251 -37
- package/src/Passes/AIUpscaler.js +6 -2
- package/src/PathTracerApp.js +2 -0
- package/src/Processor/ArchiveImporter.js +25 -3
- package/src/Processor/AssetLoader.js +6 -4
- package/src/Processor/InstanceTable.js +36 -11
- package/src/Processor/PBRT/PBRTCurves.js +6 -3
- package/src/Processor/PBRT/PBRTSceneBuilder.js +26 -3
- package/src/Processor/PBRT/index.js +1 -0
- package/src/Processor/SceneProcessor.js +43 -5
- package/src/Processor/TLASBuilder.js +5 -4
- package/src/Processor/USD/USDScene.js +6 -1
- package/src/Processor/USD/index.js +2 -2
- package/src/Processor/utils.js +80 -1
- package/src/RayzeeRenderer.js +54 -9
- package/src/Stages/Compositor.js +86 -3
- package/src/Stages/PathTracerStage.js +17 -6
- package/src/TSL/BVHTraversal.js +1 -1
- package/src/addons/color.js +2 -2
- package/src/index.js +2 -2
- package/src/managers/DenoisingManager.js +18 -4
- package/src/managers/VideoRenderManager.js +10 -1
- package/src/neural/NeuralSuperRes.js +5 -5
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { dt as e } from "./SolarLimb-ZYl-Pwl0.js";
|
|
2
|
-
import { At as t, Dt as n, Mt as r, Ot as i, bt as a, dt as o, ft as s, i as c, jt as l, lt as u, n as d, r as f, ut as p, vt as
|
|
3
|
-
import { n as
|
|
4
|
-
import { $ as
|
|
2
|
+
import { At as t, Dt as n, Mt as r, Ot as i, bt as a, dt as o, ft as s, i as c, jt as l, lt as u, n as d, r as f, ut as p, vt as m, yt as h } from "./PathTracer-7a7L3cGF.js";
|
|
3
|
+
import { n as g, t as _ } from "./EngineEvents-CLckhYbL.js";
|
|
4
|
+
import { $ as ee, C as te, G as v, M as ne, T as y, W as re, Z as ie, ct as ae, d as oe, et as se, f as ce, it as le, l as ue, nt as de, r as fe, rt as pe, st as b, tt as me, u as he, v as ge, x as _e } from "./sceneCachePolicy-DavHt6Ii.js";
|
|
5
5
|
import { i as x, r as S } from "./Logger-dDDGj9Av.js";
|
|
6
|
-
import { f as
|
|
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 { c as
|
|
6
|
+
import { f as ve, r as ye } from "./BufferLayout-BROyMqO1.js";
|
|
7
|
+
import { i as be, n as C, t as xe } from "./EngineIssues-CfJiBaNj.js";
|
|
8
|
+
import { n as Se, r as Ce } from "./shared-BGBcSxBQ.js";
|
|
9
|
+
import { a as we } from "./WorkingMatrix-C6y233hT.js";
|
|
10
|
+
import { i as Te, r as Ee, t as w } from "./ActiveColor-YvuQq44O.js";
|
|
11
|
+
import { n as T, r as De } from "./AssetConfig-DSEntE65.js";
|
|
12
|
+
import { d as Oe, l as ke, m as Ae, p as je, t as Me, u as E } from "./ViewTransforms-CYN7bq2w.js";
|
|
13
|
+
import { i as D, n as O, r as Ne } from "./identity-C1cLD1C0.js";
|
|
14
|
+
import { c as k, i as Pe, l as Fe, o as Ie, r as Le, t as Re } from "./SceneMetadata-CoAHTAmo.js";
|
|
15
15
|
import { t as ze } from "./ToneMapGPU-4GPwoG_c.js";
|
|
16
|
-
import { LinearSRGBColorSpace as Be, MeshBasicNodeMaterial 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
|
|
16
|
+
import { LinearSRGBColorSpace as Be, MeshBasicNodeMaterial as A, QuadMesh as j, RectAreaLightNode as Ve, SRGBColorSpace as M, TextureNode as He, WebGPURenderer as Ue } from "three/webgpu";
|
|
17
|
+
import { Fn as We, If as Ge, cubeTexture as Ke, dot as qe, float as N, int as P, mix as F, screenUV as Je, select as I, storage as Ye, texture as Xe, toneMappingExposure as Ze, uint as Qe, uniform as L, uv as R, vec3 as z, vec4 as B } from "three/tsl";
|
|
18
|
+
import { Box3 as $e, BufferGeometry as et, CircleGeometry as tt, Color as nt, ColorManagement as rt, DirectionalLight as it, DirectionalLightHelper as at, EquirectangularReflectionMapping as ot, EventDispatcher as V, FloatType as st, HalfFloatType as ct, LinearFilter as lt, LinearSRGBColorSpace as ut, LoaderUtils as dt, LoadingManager as ft, MathUtils as H, Mesh as pt, MeshPhysicalMaterial as mt, NoBlending as ht, NoToneMapping as gt, Object3D as _t, OrthographicCamera as vt, PerspectiveCamera as yt, PointLight as bt, PointLightHelper as xt, REVISION as St, RectAreaLight as Ct, SRGBColorSpace as U, Scene as wt, SpotLight as Tt, SpotLightHelper as Et, TextureLoader as Dt, Vector2 as Ot, Vector3 as W } 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 wt(), 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,23 +63,32 @@ var Mt = 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 xt(e, .5) : e.isSpotLight ? new Et(e) : e.isDirectionalLight ? new at(e, .5) : null;
|
|
67
67
|
}
|
|
68
|
-
},
|
|
68
|
+
}, It = class extends l {
|
|
69
69
|
constructor(e, t = {}) {
|
|
70
70
|
super("Compositor", {
|
|
71
71
|
...t,
|
|
72
72
|
executionMode: r.ALWAYS
|
|
73
|
-
}), this.renderer = e, this._lightSources = [...t.displaySources ?? [], "pathtracer:color"], this.saturation =
|
|
73
|
+
}), this.renderer = e, this._lightSources = [...t.displaySources ?? [], "pathtracer:color"], this.saturation = L(t.saturation ?? 1), this._transparentBackground = L(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 = L(1), this._sourceTexNode = new He(), this._displayGain = null, this._backdropExposure = null, this._holdBackdrop = L(0, "int"), this._backdropGain = L(1), this._canvasTransform = null, this._canvasMaterial = null, this._canvasQuad = null, this.compositorMaterial = new A(), this.compositorMaterial.blending = ht, this._buildColorNode(), this.compositorQuad = new j(this.compositorMaterial), this.setCanvasTransform(t.canvasTransform ?? null);
|
|
74
74
|
}
|
|
75
75
|
_buildColorNode() {
|
|
76
|
-
let t = this._sourceTexNode.sample(
|
|
76
|
+
let t = this._sourceTexNode.sample(R()), n = this._displayGain ? this._displayGain(t.xyz, Je) : null;
|
|
77
77
|
if (this._backdropExposure !== null) {
|
|
78
|
-
let e = n ??
|
|
79
|
-
n =
|
|
78
|
+
let e = n ?? N(1), r = e.add(this._backdropGain.sub(e).mul(t.w.clamp(0, 1).oneMinus()));
|
|
79
|
+
n = I(this._holdBackdrop.greaterThan(P(0)), r, e);
|
|
80
80
|
}
|
|
81
|
-
let r = n ? t.xyz.mul(n) : t.xyz, i =
|
|
82
|
-
this.compositorMaterial.colorNode =
|
|
81
|
+
let r = n ? t.xyz.mul(n) : t.xyz, i = F(z(qe(r, e)), r, this.saturation), a = I(this._transparentBackground, t.w, 1);
|
|
82
|
+
this._graded = i, this._alpha = a, this.compositorMaterial.colorNode = B(i, a), this.compositorMaterial.needsUpdate = !0, this._buildCanvasNode();
|
|
83
|
+
}
|
|
84
|
+
_buildCanvasNode() {
|
|
85
|
+
this._canvasMaterial && (this._canvasMaterial.colorNode = B(this._canvasTransform(this._graded, Ze), this._alpha), this._canvasMaterial.needsUpdate = !0);
|
|
86
|
+
}
|
|
87
|
+
setCanvasTransform(e) {
|
|
88
|
+
e !== this._canvasTransform && (this._canvasTransform = e, this._canvasMaterial?.dispose(), this._canvasMaterial = null, this._canvasQuad = null, e && (this._canvasMaterial = new A(), this._canvasMaterial.blending = ht, this._canvasQuad = new j(this._canvasMaterial), this._buildCanvasNode()));
|
|
89
|
+
}
|
|
90
|
+
get showsCanvasTransform() {
|
|
91
|
+
return this._canvasQuad !== null;
|
|
83
92
|
}
|
|
84
93
|
setDisplayGain(e) {
|
|
85
94
|
e !== this._displayGain && (this._displayGain = e, this._buildColorNode());
|
|
@@ -105,19 +114,25 @@ var Mt = class {
|
|
|
105
114
|
let t = this._pathTracer?.getConvergenceDebugSource?.();
|
|
106
115
|
if (!t) return !1;
|
|
107
116
|
if (this._debugMaterial && this._debugM2Attr === t.m2 && this._debugMaskAttr === t.frozenMask) return !0;
|
|
108
|
-
this._debugMaterial?.dispose(), this._debugTexNode?.dispose(), this._debugM2Attr = t.m2, this._debugMaskAttr = t.frozenMask, this._debugTexNode = new
|
|
109
|
-
let n =
|
|
110
|
-
let n =
|
|
111
|
-
return
|
|
112
|
-
let e =
|
|
113
|
-
|
|
114
|
-
}),
|
|
115
|
-
|
|
116
|
-
}),
|
|
117
|
+
this._debugMaterial?.dispose(), this._debugTexNode?.dispose(), this._debugM2Attr = t.m2, this._debugMaskAttr = t.frozenMask, this._debugTexNode = new He();
|
|
118
|
+
let n = We(() => {
|
|
119
|
+
let n = qe(this._debugTexNode.sample(R()).toVar().xyz, e).toVar(), r = t.renderWidth, i = t.renderHeight, a = P(R().x.mul(N(r))).min(r.sub(P(1))).max(P(0)), o = Qe(P(R().y.mul(N(i))).min(i.sub(P(1))).max(P(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(N(0)).div(N(t.frame).add(1)).sqrt().toVar(), u = t.usePixelFreeze.greaterThan(P(0)), d = I(n.lessThan(N(1)), n.sqrt(), n).toVar(), f = I(u, l.div(n.add(N(1e-4))), l.div(d.add(N(1e-4)))).toVar(), p = I(u, t.pixelFreezeThreshold, t.noiseThreshold).toVar(), m = f.div(p.max(N(1e-6))).toVar(), h = z(n.div(n.add(N(1))).sqrt().mul(.55)).toVar(), g = h.toVar(), _ = N(t.frame).greaterThanEqual(N(t.adaptiveMinSamples));
|
|
120
|
+
return Ge(m.greaterThanEqual(N(1)).or(_.not()), () => {
|
|
121
|
+
let e = F(z(1, .8, .1), z(1, .1, .05), m.sub(1).div(3).clamp(0, 1));
|
|
122
|
+
g.assign(F(h, e, .85));
|
|
123
|
+
}), Ge(c.equal(Qe(1)).and(u), () => {
|
|
124
|
+
g.assign(F(h, z(.1, .45, 1), .55));
|
|
125
|
+
}), g;
|
|
117
126
|
});
|
|
118
|
-
return this._debugMaterial = new
|
|
127
|
+
return this._debugMaterial = new A(), this._debugMaterial.colorNode = B(n().pow(2.2).mul(this._debugExposureComp), 1), this._debugMaterial.blending = ht, this._debugQuad = new j(this._debugMaterial), !0;
|
|
119
128
|
}
|
|
120
129
|
render(e) {
|
|
130
|
+
this._draw(e, !1);
|
|
131
|
+
}
|
|
132
|
+
renderPicture(e) {
|
|
133
|
+
this._draw(e, !0);
|
|
134
|
+
}
|
|
135
|
+
_draw(e, t) {
|
|
121
136
|
if (!this.enabled) return;
|
|
122
137
|
if (this._convergenceOverlay && this._ensureDebugMaterial()) {
|
|
123
138
|
let t = e.getTexture("pathtracer:color");
|
|
@@ -128,13 +143,22 @@ var Mt = class {
|
|
|
128
143
|
return;
|
|
129
144
|
}
|
|
130
145
|
}
|
|
131
|
-
let
|
|
132
|
-
if (
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
146
|
+
let n = this.resolveLightTexture(e);
|
|
147
|
+
if (!n) return;
|
|
148
|
+
if (this._backdropExposure !== null) {
|
|
149
|
+
let t = e.getState("pathtracer:backdrop") === "color";
|
|
150
|
+
this._holdBackdrop.value = +!!t, t && (this._backdropGain.value = o(this._backdropExposure, this.renderer.toneMappingExposure, this.renderer.toneMapping));
|
|
151
|
+
}
|
|
152
|
+
if (this._sourceTexNode.value = n, this.renderer.setRenderTarget(null), t || !this._canvasQuad) {
|
|
153
|
+
this.compositorQuad.render(this.renderer);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
let { toneMapping: r, outputColorSpace: i } = this.renderer;
|
|
157
|
+
this.renderer.toneMapping = gt, this.renderer.outputColorSpace = rt.workingColorSpace;
|
|
158
|
+
try {
|
|
159
|
+
this._canvasQuad.render(this.renderer);
|
|
160
|
+
} finally {
|
|
161
|
+
this.renderer.toneMapping = r, this.renderer.outputColorSpace = i;
|
|
138
162
|
}
|
|
139
163
|
}
|
|
140
164
|
setConvergenceOverlay(e) {
|
|
@@ -147,9 +171,9 @@ var Mt = class {
|
|
|
147
171
|
this._transparentBackground.value = +!!e;
|
|
148
172
|
}
|
|
149
173
|
dispose() {
|
|
150
|
-
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;
|
|
174
|
+
this._sourceTexNode?.dispose(), this.compositorMaterial?.dispose(), this._canvasMaterial?.dispose(), this._canvasMaterial = null, this._canvasQuad = null, this._canvasTransform = null, this._debugTexNode?.dispose(), this._debugMaterial?.dispose(), this.compositorQuad = null, this._debugQuad = null, this._debugMaterial = null, this._debugTexNode = null, this._pathTracer = null;
|
|
151
175
|
}
|
|
152
|
-
},
|
|
176
|
+
}, Lt = class {
|
|
153
177
|
constructor() {
|
|
154
178
|
this.textures = /* @__PURE__ */ new Map(), this.renderTargets = /* @__PURE__ */ new Map(), this.uniforms = /* @__PURE__ */ new Map(), this.state = {
|
|
155
179
|
frame: 0,
|
|
@@ -268,7 +292,7 @@ var Mt = class {
|
|
|
268
292
|
dispose() {
|
|
269
293
|
this.textures.clear(), this.renderTargets.clear(), this.uniforms.clear(), this._stateChangeCallbacks.clear(), this.state = {};
|
|
270
294
|
}
|
|
271
|
-
},
|
|
295
|
+
}, Rt = class extends V {
|
|
272
296
|
constructor() {
|
|
273
297
|
super(), this._onceCallbacks = /* @__PURE__ */ new Map();
|
|
274
298
|
}
|
|
@@ -306,38 +330,38 @@ var Mt = class {
|
|
|
306
330
|
eventNames() {
|
|
307
331
|
return this._listeners ? Object.keys(this._listeners) : [];
|
|
308
332
|
}
|
|
309
|
-
},
|
|
310
|
-
function
|
|
311
|
-
|
|
333
|
+
}, zt = !1, Bt = [], Vt = /* @__PURE__ */ new WeakMap();
|
|
334
|
+
function Ht(e) {
|
|
335
|
+
zt = !!e;
|
|
312
336
|
}
|
|
313
|
-
function
|
|
314
|
-
return
|
|
337
|
+
function Ut() {
|
|
338
|
+
return Bt.slice();
|
|
315
339
|
}
|
|
316
|
-
function
|
|
317
|
-
|
|
340
|
+
function Wt() {
|
|
341
|
+
Bt.length = 0;
|
|
318
342
|
}
|
|
319
|
-
function
|
|
343
|
+
function Gt(e) {
|
|
320
344
|
let t = [];
|
|
321
345
|
for (let n of Object.keys(e)) e[n]?.isTextureNode === !0 && t.push(n);
|
|
322
346
|
return t;
|
|
323
347
|
}
|
|
324
|
-
var
|
|
325
|
-
function
|
|
326
|
-
if (!
|
|
348
|
+
var Kt = (e) => !e || !e.image || !(e.image.width > 0);
|
|
349
|
+
function qt(e, t, n) {
|
|
350
|
+
if (!zt) {
|
|
327
351
|
n();
|
|
328
352
|
return;
|
|
329
353
|
}
|
|
330
|
-
let r =
|
|
354
|
+
let r = Vt.get(e);
|
|
331
355
|
if (r || (r = {
|
|
332
356
|
phase: "pending",
|
|
333
357
|
unboundAtCompile: []
|
|
334
|
-
},
|
|
335
|
-
n(), r.phase === "watch" &&
|
|
358
|
+
}, Vt.set(e, r)), r.phase !== "pending") {
|
|
359
|
+
n(), r.phase === "watch" && Jt(e, r);
|
|
336
360
|
return;
|
|
337
361
|
}
|
|
338
362
|
let i = Object.prototype.hasOwnProperty.call(t, "compute"), a = t.compute;
|
|
339
363
|
t.compute = function(...t) {
|
|
340
|
-
return r.phase === "pending" && (r.unboundAtCompile =
|
|
364
|
+
return r.phase === "pending" && (r.unboundAtCompile = Gt(e).filter((t) => Kt(e[t].value)), r.phase = r.unboundAtCompile.length < 2 ? "done" : "watch"), a.apply(this, t);
|
|
341
365
|
};
|
|
342
366
|
try {
|
|
343
367
|
n();
|
|
@@ -345,14 +369,14 @@ function Ut(e, t, n) {
|
|
|
345
369
|
i ? t.compute = a : delete t.compute;
|
|
346
370
|
}
|
|
347
371
|
}
|
|
348
|
-
function
|
|
372
|
+
function Jt(e, t) {
|
|
349
373
|
let n = [];
|
|
350
374
|
for (let r of t.unboundAtCompile) {
|
|
351
375
|
let t = e[r]?.value;
|
|
352
|
-
if (
|
|
376
|
+
if (Kt(t)) return;
|
|
353
377
|
t.isStorageTexture !== !0 && n.push(r);
|
|
354
378
|
}
|
|
355
|
-
t.phase = "done", n.length !== 0 &&
|
|
379
|
+
t.phase = "done", n.length !== 0 && Bt.push({
|
|
356
380
|
stage: e.name,
|
|
357
381
|
nodes: n,
|
|
358
382
|
unboundAtCompile: t.unboundAtCompile.slice(),
|
|
@@ -361,7 +385,7 @@ function Wt(e, t) {
|
|
|
361
385
|
}
|
|
362
386
|
//#endregion
|
|
363
387
|
//#region src/Pipeline/RenderPipeline.js
|
|
364
|
-
var
|
|
388
|
+
var Yt = class {
|
|
365
389
|
_reportStageFailure(e, t, n) {
|
|
366
390
|
console.error(`[Pipeline] Error in stage '${e}' (${t}):`, n);
|
|
367
391
|
let r = `${e}:${t}`;
|
|
@@ -372,7 +396,7 @@ var Gt = class {
|
|
|
372
396
|
}));
|
|
373
397
|
}
|
|
374
398
|
constructor(e, t, n, { issues: r = null } = {}) {
|
|
375
|
-
this.renderer = e, this._issues = r, this._reportedStageFailures = /* @__PURE__ */ new Set(), this.width = t, this.height = n, this.stages = [], this.context = new
|
|
399
|
+
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 = {
|
|
376
400
|
enabled: !1,
|
|
377
401
|
logSkipped: !1,
|
|
378
402
|
timings: /* @__PURE__ */ new Map(),
|
|
@@ -406,7 +430,7 @@ var Gt = class {
|
|
|
406
430
|
}
|
|
407
431
|
try {
|
|
408
432
|
let n = this.stats.enabled ? performance.now() : 0;
|
|
409
|
-
if (
|
|
433
|
+
if (qt(t, this.renderer, () => t.render(this.context, e)), this.stats.enabled) {
|
|
410
434
|
let e = performance.now() - n;
|
|
411
435
|
this.stats.timings.has(t.name) || this.stats.timings.set(t.name, []);
|
|
412
436
|
let r = this.stats.timings.get(t.name);
|
|
@@ -504,7 +528,7 @@ var Gt = class {
|
|
|
504
528
|
let e = this.getInfo();
|
|
505
529
|
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();
|
|
506
530
|
}
|
|
507
|
-
},
|
|
531
|
+
}, Xt = S("engine"), Zt = class {
|
|
508
532
|
constructor() {
|
|
509
533
|
this.timeElapsed = 0, this.lastResetTime = performance.now(), this.renderCompleteDispatched = !1, this.budgetOverrun = !1, this._budgetHeldWarned = !1;
|
|
510
534
|
}
|
|
@@ -512,7 +536,7 @@ var Gt = class {
|
|
|
512
536
|
this.timeElapsed = (performance.now() - this.lastResetTime) / 1e3;
|
|
513
537
|
}
|
|
514
538
|
isTimeLimitReached(e, t, n) {
|
|
515
|
-
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,
|
|
539
|
+
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, Xt.warn(`render time limit (${n}s) expired before the first sample landed — holding the deadline open to avoid capturing an empty frame`)), !1);
|
|
516
540
|
}
|
|
517
541
|
isLimitReached(e, t, n) {
|
|
518
542
|
return e ? this.isTimeLimitReached(e, t, n) ? !0 : this.stopCondition(e) !== null : !1;
|
|
@@ -529,15 +553,15 @@ var Gt = class {
|
|
|
529
553
|
resumeFromPause() {
|
|
530
554
|
this.renderCompleteDispatched = !1, this.lastResetTime = performance.now() - this.timeElapsed * 1e3;
|
|
531
555
|
}
|
|
532
|
-
},
|
|
556
|
+
}, Qt = 864e5, G = Object.freeze({
|
|
533
557
|
IMMUTABLE: "immutable",
|
|
534
558
|
REVALIDATE: "revalidate",
|
|
535
559
|
NETWORK: "network"
|
|
536
|
-
}),
|
|
560
|
+
}), $t = (e, t) => ({
|
|
537
561
|
loaded: e,
|
|
538
562
|
total: t,
|
|
539
563
|
lengthComputable: t > 0 && e <= t
|
|
540
|
-
}), K = (e, t) => e.headers?.get?.(t) ?? null,
|
|
564
|
+
}), K = (e, t) => e.headers?.get?.(t) ?? null, en = (e) => e.reason ?? new DOMException("aborted", "AbortError");
|
|
541
565
|
function q(e) {
|
|
542
566
|
try {
|
|
543
567
|
let t = new URL(e, globalThis.location?.href ?? "http://localhost/").pathname;
|
|
@@ -546,36 +570,36 @@ function q(e) {
|
|
|
546
570
|
return "download";
|
|
547
571
|
}
|
|
548
572
|
}
|
|
549
|
-
async function
|
|
573
|
+
async function tn(e, { onProgress: t, signal: n }) {
|
|
550
574
|
let r = Number(K(e, "content-length")) || 0, i = K(e, "content-type") ?? "";
|
|
551
575
|
if (!e.body) return new Blob([await e.arrayBuffer()], { type: i });
|
|
552
576
|
let a = e.body.getReader(), o = [], s = 0;
|
|
553
577
|
for (;;) {
|
|
554
|
-
if (n?.aborted) throw a.cancel().catch(() => {}),
|
|
578
|
+
if (n?.aborted) throw a.cancel().catch(() => {}), en(n);
|
|
555
579
|
let { done: e, value: i } = await a.read();
|
|
556
580
|
if (e) break;
|
|
557
|
-
o.push(i), s += i.length, t?.(
|
|
581
|
+
o.push(i), s += i.length, t?.($t(s, r));
|
|
558
582
|
}
|
|
559
583
|
return new Blob(o, { type: i });
|
|
560
584
|
}
|
|
561
|
-
var
|
|
585
|
+
var nn = (e, t, n) => new File([e], t, {
|
|
562
586
|
type: n || e.type,
|
|
563
587
|
lastModified: e.lastModified ?? Date.now()
|
|
564
|
-
}),
|
|
588
|
+
}), rn = () => {}, J = class {
|
|
565
589
|
constructor(e) {
|
|
566
590
|
this._storage = e, this._revalidating = /* @__PURE__ */ new Set();
|
|
567
591
|
}
|
|
568
592
|
get _area() {
|
|
569
|
-
return this._storage?.area(
|
|
593
|
+
return this._storage?.area(Ce.DOWNLOADS) ?? null;
|
|
570
594
|
}
|
|
571
|
-
async fetch(e, { key: t = e, name: n = q(e), policy: r = G.REVALIDATE, maxAgeMs: i =
|
|
595
|
+
async fetch(e, { key: t = e, name: n = q(e), policy: r = G.REVALIDATE, maxAgeMs: i = Qt, onProgress: a = null, signal: o = null, fetchOptions: s = {} } = {}) {
|
|
572
596
|
let c = this._area;
|
|
573
597
|
if (c && r !== G.NETWORK) {
|
|
574
598
|
let o = await c.open(t);
|
|
575
599
|
if (o) {
|
|
576
600
|
let c = await o.file("data");
|
|
577
|
-
if (c) return r === G.REVALIDATE && Date.now() - (o.extra.checkedAt ?? 0) >= i && this._revalidate(e, t, n, o.extra, s), a?.(
|
|
578
|
-
file:
|
|
601
|
+
if (c) return r === G.REVALIDATE && Date.now() - (o.extra.checkedAt ?? 0) >= i && this._revalidate(e, t, n, o.extra, s), a?.($t(c.size, c.size)), {
|
|
602
|
+
file: nn(c, n, o.extra.contentType),
|
|
579
603
|
release: () => o.release(),
|
|
580
604
|
fromCache: !0
|
|
581
605
|
};
|
|
@@ -593,7 +617,7 @@ var Qt = (e, t, n) => new File([e], t, {
|
|
|
593
617
|
return await this._area?.has(e) === !0;
|
|
594
618
|
}
|
|
595
619
|
async _download(e, t, n, { onProgress: r, signal: i, fetchOptions: a, cache: o }) {
|
|
596
|
-
if (i?.aborted) throw
|
|
620
|
+
if (i?.aborted) throw en(i);
|
|
597
621
|
let s = await fetch(e, {
|
|
598
622
|
...a,
|
|
599
623
|
signal: i
|
|
@@ -610,17 +634,17 @@ var Qt = (e, t, n) => new File([e], t, {
|
|
|
610
634
|
expectedBytes: c
|
|
611
635
|
}) : null;
|
|
612
636
|
if (!u) return {
|
|
613
|
-
file:
|
|
637
|
+
file: nn(await tn(s, {
|
|
614
638
|
onProgress: r,
|
|
615
639
|
signal: i
|
|
616
640
|
}), n, l.contentType),
|
|
617
|
-
release:
|
|
641
|
+
release: rn,
|
|
618
642
|
fromCache: !1
|
|
619
643
|
};
|
|
620
644
|
try {
|
|
621
645
|
await u.writeStream("data", s.body, {
|
|
622
646
|
signal: i,
|
|
623
|
-
onProgress: (e) => r?.(
|
|
647
|
+
onProgress: (e) => r?.($t(e, c))
|
|
624
648
|
}), await u.commit(l);
|
|
625
649
|
} catch (o) {
|
|
626
650
|
if (await u.abort(), o?.name !== "QuotaExceededError") throw o;
|
|
@@ -634,7 +658,7 @@ var Qt = (e, t, n) => new File([e], t, {
|
|
|
634
658
|
let d = await this._area.open(t, { wait: !0 }), f = d && await d.file("data");
|
|
635
659
|
if (!f) throw d?.release(), Error(`storage: ${n} vanished right after it was saved`);
|
|
636
660
|
return {
|
|
637
|
-
file:
|
|
661
|
+
file: nn(f, n, l.contentType),
|
|
638
662
|
release: () => d.release(),
|
|
639
663
|
fromCache: !1
|
|
640
664
|
};
|
|
@@ -671,16 +695,16 @@ var Qt = (e, t, n) => new File([e], t, {
|
|
|
671
695
|
}
|
|
672
696
|
}
|
|
673
697
|
};
|
|
674
|
-
function
|
|
698
|
+
function an(e, t, n) {
|
|
675
699
|
return new J(t).fetch(e, n);
|
|
676
700
|
}
|
|
677
|
-
function
|
|
678
|
-
return new J(
|
|
701
|
+
function on() {
|
|
702
|
+
return new J(Se(T().cacheNamespace));
|
|
679
703
|
}
|
|
680
|
-
async function
|
|
704
|
+
async function sn(e, { downloads: t = on(), ...n } = {}) {
|
|
681
705
|
if (!t._storage || !/^https?:/i.test(e)) return {
|
|
682
706
|
url: e,
|
|
683
|
-
release:
|
|
707
|
+
release: rn,
|
|
684
708
|
cached: !1
|
|
685
709
|
};
|
|
686
710
|
let { file: r, release: i } = await t.fetch(e, n), a = URL.createObjectURL(r);
|
|
@@ -694,7 +718,7 @@ async function nn(e, { downloads: t = tn(), ...n } = {}) {
|
|
|
694
718
|
}
|
|
695
719
|
//#endregion
|
|
696
720
|
//#region src/RenderSettings.js
|
|
697
|
-
var
|
|
721
|
+
var cn = {
|
|
698
722
|
maxBounces: {
|
|
699
723
|
uniform: "maxBounces",
|
|
700
724
|
reset: !0
|
|
@@ -920,9 +944,9 @@ var rn = {
|
|
|
920
944
|
HOST: "host",
|
|
921
945
|
SCENE_METADATA: "scene-metadata",
|
|
922
946
|
MODE_PRESET: "mode-preset"
|
|
923
|
-
}),
|
|
924
|
-
constructor(e =
|
|
925
|
-
super(), this._issues = t, this._defaults = e, this._routes = new Map(Object.entries(
|
|
947
|
+
}), ln = class extends V {
|
|
948
|
+
constructor(e = v, { issues: t = null } = {}) {
|
|
949
|
+
super(), this._issues = t, this._defaults = e, this._routes = new Map(Object.entries(cn)), this._values = /* @__PURE__ */ new Map(), this._sources = /* @__PURE__ */ new Map(), this._pathTracer = null, this._resetCallback = null, this._handlers = {}, this._initDefaults(e);
|
|
926
950
|
}
|
|
927
951
|
bind(e) {
|
|
928
952
|
this._pathTracer = e.stages.pathTracer, this._resetCallback = e.resetCallback, this._handlers = this._buildHandlers(e);
|
|
@@ -937,12 +961,12 @@ var rn = {
|
|
|
937
961
|
!this._values.has(e) && i !== void 0 && (this._values.set(e, i), this._sources.set(e, Y.DEFAULT));
|
|
938
962
|
}
|
|
939
963
|
_buildHandlers({ stages: e, resetCallback: t, reconcileCompletion: n, applyExposure: r, onCameraProjection: i }) {
|
|
940
|
-
let a = new
|
|
941
|
-
a.set(n?.[0] ?? 0, n?.[1] ?? 0).multiplyScalar(
|
|
964
|
+
let a = new Ot(), o = (t, n) => {
|
|
965
|
+
a.set(n?.[0] ?? 0, n?.[1] ?? 0).multiplyScalar(H.DEG2RAD), e.pathTracer?.setUniform(t, a);
|
|
942
966
|
};
|
|
943
967
|
return {
|
|
944
968
|
handleCameraProjection: (t) => {
|
|
945
|
-
e.pathTracer?.setUniform("cameraProjection",
|
|
969
|
+
e.pathTracer?.setUniform("cameraProjection", re[t] ?? re.perspective), i?.(t);
|
|
946
970
|
},
|
|
947
971
|
handleDofMode: (t) => e.pathTracer?.setUniform("dofMode", +(t === "look")),
|
|
948
972
|
handlePanoramaLonRange: (e) => o("panoLonRange", e),
|
|
@@ -951,7 +975,7 @@ var rn = {
|
|
|
951
975
|
e.pathTracer?.setUniform("transparentBackground", t), e.compositor?.setTransparentBackground(t);
|
|
952
976
|
},
|
|
953
977
|
handleBackgroundColor: (t) => {
|
|
954
|
-
let n = t?.isColor ? t : new
|
|
978
|
+
let n = t?.isColor ? t : new nt(t);
|
|
955
979
|
e.pathTracer?.setUniform("backgroundColor", n);
|
|
956
980
|
},
|
|
957
981
|
handleExposure: (e) => {
|
|
@@ -995,7 +1019,7 @@ var rn = {
|
|
|
995
1019
|
set(e, t, { reset: n, silent: r, source: i = Y.HOST } = {}) {
|
|
996
1020
|
let a = this._applyOne(e, t, i);
|
|
997
1021
|
a?.route && ((n === void 0 ? a.route.reset ?? !0 : n) && this._resetCallback?.(), r || this.dispatchEvent({
|
|
998
|
-
type:
|
|
1022
|
+
type: _.SETTING_CHANGED,
|
|
999
1023
|
key: e,
|
|
1000
1024
|
value: t,
|
|
1001
1025
|
prev: a.prev
|
|
@@ -1006,7 +1030,7 @@ var rn = {
|
|
|
1006
1030
|
for (let [n, a] of Object.entries(e)) {
|
|
1007
1031
|
let e = this._applyOne(n, a, r);
|
|
1008
1032
|
e?.route && ((e.route.reset ?? !0) && (i = !0), t || this.dispatchEvent({
|
|
1009
|
-
type:
|
|
1033
|
+
type: _.SETTING_CHANGED,
|
|
1010
1034
|
key: n,
|
|
1011
1035
|
value: a,
|
|
1012
1036
|
prev: e.prev
|
|
@@ -1056,7 +1080,7 @@ var rn = {
|
|
|
1056
1080
|
}
|
|
1057
1081
|
restore(e) {
|
|
1058
1082
|
let t = {}, n = [];
|
|
1059
|
-
for (let [r, i] of Object.entries(e ?? {})) this._routes.has(r) ? t[r] =
|
|
1083
|
+
for (let [r, i] of Object.entries(e ?? {})) this._routes.has(r) ? t[r] = h(i) : n.push(r);
|
|
1060
1084
|
return this.setMany(t), n;
|
|
1061
1085
|
}
|
|
1062
1086
|
applyAll() {
|
|
@@ -1069,19 +1093,19 @@ var rn = {
|
|
|
1069
1093
|
e.uniform ? this._pathTracer?.setUniform(e.uniform, t) : e.handler ? this._handlers[e.handler]?.(t, n) : e.apply?.(t, n);
|
|
1070
1094
|
}
|
|
1071
1095
|
_initDefaults(e) {
|
|
1072
|
-
for (let t of Object.keys(
|
|
1096
|
+
for (let t of Object.keys(cn)) t in e && (this._values.set(t, e[t]), this._sources.set(t, Y.DEFAULT));
|
|
1073
1097
|
}
|
|
1074
|
-
},
|
|
1098
|
+
}, un = class {
|
|
1075
1099
|
constructor({ issues: e = null } = {}) {
|
|
1076
|
-
this._issues = e, this._renderer = null, this._offRegistry =
|
|
1077
|
-
this._renderer &&
|
|
1100
|
+
this._issues = e, this._renderer = null, this._offRegistry = je(() => {
|
|
1101
|
+
this._renderer && Ae(this._renderer);
|
|
1078
1102
|
});
|
|
1079
1103
|
}
|
|
1080
1104
|
get hasConfig() {
|
|
1081
1105
|
return !1;
|
|
1082
1106
|
}
|
|
1083
1107
|
get workingSpace() {
|
|
1084
|
-
return
|
|
1108
|
+
return w;
|
|
1085
1109
|
}
|
|
1086
1110
|
get workingSpaceAdopted() {
|
|
1087
1111
|
return !1;
|
|
@@ -1091,23 +1115,23 @@ var rn = {
|
|
|
1091
1115
|
}
|
|
1092
1116
|
attachRenderer(e) {
|
|
1093
1117
|
this._renderer = e;
|
|
1094
|
-
let t =
|
|
1095
|
-
return e.outputColorSpace =
|
|
1118
|
+
let t = Ae(e);
|
|
1119
|
+
return e.outputColorSpace = U, t;
|
|
1096
1120
|
}
|
|
1097
1121
|
listViews() {
|
|
1098
|
-
return
|
|
1122
|
+
return Oe();
|
|
1099
1123
|
}
|
|
1100
1124
|
get activeView() {
|
|
1101
1125
|
return null;
|
|
1102
1126
|
}
|
|
1103
1127
|
setActiveView(e) {
|
|
1104
|
-
let t =
|
|
1128
|
+
let t = E(e);
|
|
1105
1129
|
if (!t) throw Error(`no view transform with id ${e}`);
|
|
1106
1130
|
if (t.outputEncoded) throw Error(`"${t.name}" returns display-encoded colour: it needs rayzee/addons/color`);
|
|
1107
1131
|
return this._renderer && (this._renderer.toneMapping = e), t;
|
|
1108
1132
|
}
|
|
1109
1133
|
_publishWorkingMatrix() {
|
|
1110
|
-
|
|
1134
|
+
we(null, w);
|
|
1111
1135
|
}
|
|
1112
1136
|
loadConfig() {
|
|
1113
1137
|
let e = "colour configs need the OCIO pipeline: renderer.setColorManagement( ColorManagement ), from rayzee/addons/color";
|
|
@@ -1115,17 +1139,29 @@ var rn = {
|
|
|
1115
1139
|
}
|
|
1116
1140
|
unloadConfig() {}
|
|
1117
1141
|
setWorkingSpace() {}
|
|
1142
|
+
setHdrOutput(e) {
|
|
1143
|
+
e && this._issues?.warn(C.CAPABILITY_MISSING, "HDR on screen needs rayzee/addons/color", { capability: "color" });
|
|
1144
|
+
}
|
|
1145
|
+
get hdrOutput() {
|
|
1146
|
+
return !1;
|
|
1147
|
+
}
|
|
1148
|
+
get canvasTransform() {
|
|
1149
|
+
return null;
|
|
1150
|
+
}
|
|
1151
|
+
get canvasColorSpace() {
|
|
1152
|
+
return "srgb";
|
|
1153
|
+
}
|
|
1118
1154
|
exportPixels(e) {
|
|
1119
1155
|
return {
|
|
1120
1156
|
rgba: e,
|
|
1121
|
-
colorSpace:
|
|
1157
|
+
colorSpace: w
|
|
1122
1158
|
};
|
|
1123
1159
|
}
|
|
1124
1160
|
status() {
|
|
1125
|
-
let e = this._renderer ?
|
|
1161
|
+
let e = this._renderer ? E(this._renderer.toneMapping) : null;
|
|
1126
1162
|
return {
|
|
1127
1163
|
config: null,
|
|
1128
|
-
workingSpace:
|
|
1164
|
+
workingSpace: w,
|
|
1129
1165
|
workingSpaceAdopted: !1,
|
|
1130
1166
|
activeTransform: e ? {
|
|
1131
1167
|
id: e.id,
|
|
@@ -1135,16 +1171,23 @@ var rn = {
|
|
|
1135
1171
|
activeView: null,
|
|
1136
1172
|
context: null,
|
|
1137
1173
|
exportSpace: null,
|
|
1138
|
-
views:
|
|
1139
|
-
registryVersion:
|
|
1140
|
-
bakeError: e?.error ?? null
|
|
1174
|
+
views: Oe(),
|
|
1175
|
+
registryVersion: ke(),
|
|
1176
|
+
bakeError: e?.error ?? null,
|
|
1177
|
+
canvasColorSpace: "srgb",
|
|
1178
|
+
hdr: {
|
|
1179
|
+
on: !1,
|
|
1180
|
+
showing: !1,
|
|
1181
|
+
view: null,
|
|
1182
|
+
reason: null
|
|
1183
|
+
}
|
|
1141
1184
|
};
|
|
1142
1185
|
}
|
|
1143
1186
|
dispose() {
|
|
1144
|
-
this._offRegistry?.(), this._renderer = null, this._issues = null,
|
|
1187
|
+
this._offRegistry?.(), this._renderer = null, this._issues = null, Ee() === this && (we(null), Te(null));
|
|
1145
1188
|
}
|
|
1146
|
-
},
|
|
1147
|
-
function
|
|
1189
|
+
}, dn = "KHR_materials_diffuse_transmission";
|
|
1190
|
+
function fn(e) {
|
|
1148
1191
|
let t = (t, n, r, i) => {
|
|
1149
1192
|
let a = {};
|
|
1150
1193
|
return e.assignTexture(a, n, r, i).then(() => {
|
|
@@ -1152,7 +1195,7 @@ function cn(e) {
|
|
|
1152
1195
|
});
|
|
1153
1196
|
};
|
|
1154
1197
|
return {
|
|
1155
|
-
name:
|
|
1198
|
+
name: dn,
|
|
1156
1199
|
afterRoot(n) {
|
|
1157
1200
|
let r = e.json.materials ?? [], i = /* @__PURE__ */ new Set(), a = [];
|
|
1158
1201
|
for (let o of n.scenes ?? []) o.traverse((n) => {
|
|
@@ -1160,7 +1203,7 @@ function cn(e) {
|
|
|
1160
1203
|
for (let n of o) {
|
|
1161
1204
|
if (i.has(n)) continue;
|
|
1162
1205
|
i.add(n);
|
|
1163
|
-
let o = e.associations.get(n)?.materials, s = o === void 0 ? null : r[o]?.extensions?.[
|
|
1206
|
+
let o = e.associations.get(n)?.materials, s = o === void 0 ? null : r[o]?.extensions?.[dn];
|
|
1164
1207
|
if (!s) continue;
|
|
1165
1208
|
n.diffuseTransmission = s.diffuseTransmissionFactor ?? 0;
|
|
1166
1209
|
let [c, l, u] = s.diffuseTransmissionColorFactor ?? [
|
|
@@ -1168,7 +1211,7 @@ function cn(e) {
|
|
|
1168
1211
|
1,
|
|
1169
1212
|
1
|
|
1170
1213
|
];
|
|
1171
|
-
n.diffuseTransmissionColor = new
|
|
1214
|
+
n.diffuseTransmissionColor = new nt().setRGB(c, l, u, ut), s.diffuseTransmissionTexture && a.push(t(n, "diffuseTransmissionMap", s.diffuseTransmissionTexture)), s.diffuseTransmissionColorTexture && a.push(t(n, "diffuseTransmissionColorMap", s.diffuseTransmissionColorTexture, U));
|
|
1172
1215
|
}
|
|
1173
1216
|
});
|
|
1174
1217
|
return Promise.all(a);
|
|
@@ -1177,20 +1220,20 @@ function cn(e) {
|
|
|
1177
1220
|
}
|
|
1178
1221
|
//#endregion
|
|
1179
1222
|
//#region src/Processor/GLTFDecoders.js
|
|
1180
|
-
var
|
|
1181
|
-
function
|
|
1223
|
+
var pn = "KHR_draco_mesh_compression", mn = "KHR_texture_basisu", hn = ["EXT_meshopt_compression", "KHR_meshopt_compression"], gn = new TextDecoder();
|
|
1224
|
+
function _n(e) {
|
|
1182
1225
|
if (typeof e == "string") return e;
|
|
1183
1226
|
if (!(e instanceof ArrayBuffer)) return JSON.stringify(e?.extensionsUsed ?? []);
|
|
1184
1227
|
let t = new DataView(e);
|
|
1185
|
-
if (!(e.byteLength >= 20 && t.getUint32(0, !0) === 1179937895)) return
|
|
1228
|
+
if (!(e.byteLength >= 20 && t.getUint32(0, !0) === 1179937895)) return gn.decode(e);
|
|
1186
1229
|
let n = Math.min(t.getUint32(12, !0), e.byteLength - 20);
|
|
1187
|
-
return
|
|
1230
|
+
return gn.decode(new Uint8Array(e, 20, n));
|
|
1188
1231
|
}
|
|
1189
|
-
async function
|
|
1190
|
-
let { dracoDecoderPath: r, ktx2TranscoderPath: i } =
|
|
1191
|
-
t.includes(
|
|
1192
|
-
t.includes(
|
|
1193
|
-
|
|
1232
|
+
async function vn(e, t, n) {
|
|
1233
|
+
let { dracoDecoderPath: r, ktx2TranscoderPath: i } = T(), [a, o, s] = await Promise.all([
|
|
1234
|
+
t.includes(pn) && !e.dracoLoader ? import("three/addons/loaders/DRACOLoader.js") : null,
|
|
1235
|
+
t.includes(mn) && !e.ktx2Loader ? import("three/addons/loaders/KTX2Loader.js") : null,
|
|
1236
|
+
hn.some((e) => t.includes(e)) && !e.meshoptDecoder ? import("three/addons/libs/meshopt_decoder.module.js") : null
|
|
1194
1237
|
]);
|
|
1195
1238
|
if (a) {
|
|
1196
1239
|
let t = new a.DRACOLoader();
|
|
@@ -1209,15 +1252,15 @@ async function mn(e, t, n) {
|
|
|
1209
1252
|
}
|
|
1210
1253
|
s && e.setMeshoptDecoder(s.MeshoptDecoder);
|
|
1211
1254
|
}
|
|
1212
|
-
function
|
|
1255
|
+
function yn(e, t) {
|
|
1213
1256
|
let n = e.parse.bind(e);
|
|
1214
1257
|
return e.parse = (r, i, a, o) => {
|
|
1215
|
-
|
|
1258
|
+
vn(e, _n(r), t).then(() => n(r, i, a, o), (e) => o?.(e));
|
|
1216
1259
|
}, e;
|
|
1217
1260
|
}
|
|
1218
1261
|
//#endregion
|
|
1219
1262
|
//#region src/Processor/AssetLoader.js
|
|
1220
|
-
var
|
|
1263
|
+
var bn = S("assets"), xn = {
|
|
1221
1264
|
glb: {
|
|
1222
1265
|
type: "model",
|
|
1223
1266
|
name: "GLB (GLTF Binary)"
|
|
@@ -1252,7 +1295,7 @@ var gn = S("assets"), _n = {
|
|
|
1252
1295
|
}, Z = {
|
|
1253
1296
|
addOn: "rayzee/addons/formats",
|
|
1254
1297
|
install: "assetLoader.registerFormat()"
|
|
1255
|
-
},
|
|
1298
|
+
}, Sn = {
|
|
1256
1299
|
zip: X,
|
|
1257
1300
|
gz: X,
|
|
1258
1301
|
tgz: X,
|
|
@@ -1269,29 +1312,29 @@ var gn = S("assets"), _n = {
|
|
|
1269
1312
|
usdz: Z,
|
|
1270
1313
|
exr: Z
|
|
1271
1314
|
};
|
|
1272
|
-
function
|
|
1273
|
-
let t = new
|
|
1315
|
+
function Cn(e) {
|
|
1316
|
+
let t = new et();
|
|
1274
1317
|
for (let n in e.attributes) t.setAttribute(n, e.attributes[n]);
|
|
1275
1318
|
e.index && t.setIndex(e.index);
|
|
1276
1319
|
for (let n of e.groups) t.addGroup(n.start, n.count, n.materialIndex);
|
|
1277
1320
|
return t;
|
|
1278
1321
|
}
|
|
1279
|
-
var
|
|
1322
|
+
var wn = {
|
|
1280
1323
|
name: "RAYZEE_camera_clip",
|
|
1281
1324
|
afterRoot(e) {
|
|
1282
1325
|
for (let t of e.scenes) t.traverse((e) => {
|
|
1283
1326
|
e.isCamera && e.near > 0 && (e.userData.clipStart = e.near);
|
|
1284
1327
|
});
|
|
1285
1328
|
}
|
|
1286
|
-
},
|
|
1287
|
-
function
|
|
1329
|
+
}, Tn = 683;
|
|
1330
|
+
function En(e, t, n, r) {
|
|
1288
1331
|
if (!(r.normalize ?? !0)) return Math.PI;
|
|
1289
|
-
let i = r.shape === "ellipse" || r.shape === "disk" ? Math.PI / 4 : 1, a = e.getWorldScale(new
|
|
1332
|
+
let i = r.shape === "ellipse" || r.shape === "disk" ? Math.PI / 4 : 1, a = e.getWorldScale(new W()), o = Math.PI * i * Math.abs(t * a.x * n * a.y);
|
|
1290
1333
|
return Number.isFinite(o) ? o : Math.PI;
|
|
1291
1334
|
}
|
|
1292
|
-
var
|
|
1335
|
+
var Dn = class e extends V {
|
|
1293
1336
|
constructor(e, t, n, { issues: r = null, areaLightIntensityScale: i = null } = {}) {
|
|
1294
|
-
super(), this.scene = e, this.camera = t, this.controls = n, this.targetModel = null, this.floorPlane = null, this.sceneScale = 1, this.sceneSize = new
|
|
1337
|
+
super(), this.scene = e, this.camera = t, this.controls = n, this.targetModel = null, this.floorPlane = null, this.sceneScale = 1, this.sceneSize = new W(1, 1, 1), this.loaderCache = {}, this.uploadedFileInfo = null, this.animations = [], this.renderer = null, this.sceneMetadata = null, this._loadingManager = new ft(), 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 ?? (() => v.areaLightIntensityScale), this._loadingManager.onError = (e) => {
|
|
1295
1338
|
this._loadCancelled || this._issues?.record(C.ASSET_UNREACHABLE, `asset "${e}" could not be fetched — anything depending on it renders without it`, { url: e });
|
|
1296
1339
|
};
|
|
1297
1340
|
}
|
|
@@ -1307,7 +1350,7 @@ var Cn = class e extends L {
|
|
|
1307
1350
|
let o = new AbortController();
|
|
1308
1351
|
this._urlAbort = o;
|
|
1309
1352
|
try {
|
|
1310
|
-
return await
|
|
1353
|
+
return await sn(t, {
|
|
1311
1354
|
downloads: this.downloads,
|
|
1312
1355
|
key: i,
|
|
1313
1356
|
policy: a,
|
|
@@ -1340,7 +1383,7 @@ var Cn = class e extends L {
|
|
|
1340
1383
|
_downloadProgress(e, t) {
|
|
1341
1384
|
return (n) => {
|
|
1342
1385
|
let r = n?.loaded || 0, i = n?.lengthComputable && n.total || 0;
|
|
1343
|
-
|
|
1386
|
+
b({
|
|
1344
1387
|
isLoading: !0,
|
|
1345
1388
|
status: e,
|
|
1346
1389
|
loadedBytes: r,
|
|
@@ -1351,7 +1394,7 @@ var Cn = class e extends L {
|
|
|
1351
1394
|
};
|
|
1352
1395
|
}
|
|
1353
1396
|
_downloadComplete(e = "Processing Data...", t = 62) {
|
|
1354
|
-
|
|
1397
|
+
b({
|
|
1355
1398
|
status: e,
|
|
1356
1399
|
progress: t,
|
|
1357
1400
|
canCancel: !1,
|
|
@@ -1365,7 +1408,7 @@ var Cn = class e extends L {
|
|
|
1365
1408
|
_adoptExternalObject(e) {
|
|
1366
1409
|
let t;
|
|
1367
1410
|
try {
|
|
1368
|
-
t =
|
|
1411
|
+
t = Pt(e);
|
|
1369
1412
|
} catch (t) {
|
|
1370
1413
|
throw Error(`Cannot render "${e.name || e.type}": its userData must be JSON-serializable.`, { cause: t });
|
|
1371
1414
|
}
|
|
@@ -1399,10 +1442,10 @@ var Cn = class e extends L {
|
|
|
1399
1442
|
}
|
|
1400
1443
|
getFileFormat(e) {
|
|
1401
1444
|
let t = e.split(".").pop().toLowerCase();
|
|
1402
|
-
return
|
|
1445
|
+
return xn[t] || this._formats.get(t) || this._archiveFormats?.[t] || null;
|
|
1403
1446
|
}
|
|
1404
1447
|
formatError(e) {
|
|
1405
|
-
let t =
|
|
1448
|
+
let t = Sn[e.split(".").pop().toLowerCase()];
|
|
1406
1449
|
return /* @__PURE__ */ Error(t ? `${e}: this format is read by ${t.addOn} — install it with ${t.install}` : `Unsupported file format: ${e}`);
|
|
1407
1450
|
}
|
|
1408
1451
|
async inspectArchive(e) {
|
|
@@ -1425,7 +1468,7 @@ var Cn = class e extends L {
|
|
|
1425
1468
|
async loadAssetFromFile(e, t = {}) {
|
|
1426
1469
|
let n = e.name, r = this.getFileFormat(n);
|
|
1427
1470
|
if (!r) throw this.formatError(n);
|
|
1428
|
-
|
|
1471
|
+
b({
|
|
1429
1472
|
isLoading: !0,
|
|
1430
1473
|
status: `Loading ${r.name}...`,
|
|
1431
1474
|
progress: 2
|
|
@@ -1457,7 +1500,7 @@ var Cn = class e extends L {
|
|
|
1457
1500
|
async loadFolder(e, t = {}) {
|
|
1458
1501
|
let n = await this._archiveImporter();
|
|
1459
1502
|
if (!n) throw Error(`${e.name}: folders are read by ${X.addOn} — install it with ${X.install}`);
|
|
1460
|
-
|
|
1503
|
+
b({
|
|
1461
1504
|
isLoading: !0,
|
|
1462
1505
|
status: `Loading ${e.name}...`,
|
|
1463
1506
|
progress: 2
|
|
@@ -1477,7 +1520,7 @@ var Cn = class e extends L {
|
|
|
1477
1520
|
if (!this.getFileFormat(r)) throw this.formatError(r);
|
|
1478
1521
|
this._loadCancelled = !1;
|
|
1479
1522
|
let s = e._isNetworkUrl(t), c = `Downloading ${r}...`, l = new AbortController();
|
|
1480
|
-
this._urlAbort = l,
|
|
1523
|
+
this._urlAbort = l, b({
|
|
1481
1524
|
isLoading: !0,
|
|
1482
1525
|
status: c,
|
|
1483
1526
|
progress: 2,
|
|
@@ -1509,7 +1552,7 @@ var Cn = class e extends L {
|
|
|
1509
1552
|
}
|
|
1510
1553
|
}
|
|
1511
1554
|
async loadModelFromFile(e, t) {
|
|
1512
|
-
let n = this.storage ? this._keyed("file",
|
|
1555
|
+
let n = this.storage ? this._keyed("file", D(await O(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);
|
|
1513
1556
|
return this._sourceKey = n, i;
|
|
1514
1557
|
}
|
|
1515
1558
|
async _loadModelFileByExtension(e, t) {
|
|
@@ -1521,7 +1564,7 @@ var Cn = class e extends L {
|
|
|
1521
1564
|
}
|
|
1522
1565
|
async _loadModelWithFormat(e, t, n) {
|
|
1523
1566
|
try {
|
|
1524
|
-
|
|
1567
|
+
b({
|
|
1525
1568
|
isLoading: !0,
|
|
1526
1569
|
status: `Processing ${e.label} Data...`,
|
|
1527
1570
|
progress: 5
|
|
@@ -1530,7 +1573,7 @@ var Cn = class e extends L {
|
|
|
1530
1573
|
filename: n,
|
|
1531
1574
|
cache: this.loaderCache
|
|
1532
1575
|
});
|
|
1533
|
-
return this.releaseTargetModel(), this.targetModel = r,
|
|
1576
|
+
return this.releaseTargetModel(), this.targetModel = r, b({
|
|
1534
1577
|
isLoading: !0,
|
|
1535
1578
|
status: "Processing Data...",
|
|
1536
1579
|
progress: 10
|
|
@@ -1556,7 +1599,7 @@ var Cn = class e extends L {
|
|
|
1556
1599
|
};
|
|
1557
1600
|
try {
|
|
1558
1601
|
let r = await this.loadEnvironment(n);
|
|
1559
|
-
return
|
|
1602
|
+
return ge(r, D(await O(e))), this.dispatchEvent({
|
|
1560
1603
|
type: "load",
|
|
1561
1604
|
texture: r,
|
|
1562
1605
|
filename: t
|
|
@@ -1578,7 +1621,7 @@ var Cn = class e extends L {
|
|
|
1578
1621
|
let e = t.split(/[?#]/)[0].split(".").pop().toLowerCase();
|
|
1579
1622
|
n = await this.loadEnvironmentByExtension(t, e);
|
|
1580
1623
|
}
|
|
1581
|
-
return n.generateMipmaps = !0, e._isNetworkUrl(t) &&
|
|
1624
|
+
return n.generateMipmaps = !0, e._isNetworkUrl(t) && ge(n, t), this.applyEnvironmentToScene(n), this.dispatchEvent({
|
|
1582
1625
|
type: "load",
|
|
1583
1626
|
texture: n,
|
|
1584
1627
|
url: t,
|
|
@@ -1613,23 +1656,23 @@ var Cn = class e extends L {
|
|
|
1613
1656
|
}
|
|
1614
1657
|
return !n && this.uploadedFileInfo && (n = this.uploadedFileInfo.name.split(".").pop().toLowerCase()), n;
|
|
1615
1658
|
}
|
|
1616
|
-
async loadEnvironmentByExtension(t, n, { loader: r = null } = {}) {
|
|
1617
|
-
let
|
|
1618
|
-
if (!r &&
|
|
1619
|
-
let
|
|
1659
|
+
async loadEnvironmentByExtension(t, n, { loader: r = null, quiet: i = !1 } = {}) {
|
|
1660
|
+
let a = this._formats.get(n);
|
|
1661
|
+
if (!r && a?.type === "environment" && (r = this.loaderCache[n] ??= await a.createLoader(this._loadingManager)), !r && n === "hdr" && (r = this.loaderCache.hdr ??= new Mt(this._loadingManager).setDataType(st)), !r && Sn[n]) throw this.formatError(`environment.${n}`);
|
|
1662
|
+
let o = e._isNetworkUrl(t), s = "Downloading Environment...", c = await this._viaCache(t, s, o), l = c.cached || i ? void 0 : this._downloadProgress(s, o), u;
|
|
1620
1663
|
try {
|
|
1621
|
-
r ?
|
|
1664
|
+
r ? u = await r.loadAsync(c.url, l) : _e().decodeImage ? (u = await Le(c.url, `image/${n === "jpg" ? "jpeg" : n}`), u.colorSpace = U) : (this.loaderCache.texture || (this.loaderCache.texture = new Dt(this._loadingManager)), u = await this.loaderCache.texture.loadAsync(c.url, l), u.colorSpace = U);
|
|
1622
1665
|
} finally {
|
|
1623
|
-
|
|
1666
|
+
c.release();
|
|
1624
1667
|
}
|
|
1625
|
-
return this._downloadComplete("Processing Environment...", 62), this.maxEnvironmentWidth &&
|
|
1668
|
+
return i || this._downloadComplete("Processing Environment...", 62), this.maxEnvironmentWidth && On(u, this.maxEnvironmentWidth), u.mapping = ot, u.minFilter = lt, u.magFilter = lt, u;
|
|
1626
1669
|
}
|
|
1627
1670
|
applyEnvironmentToScene(e) {
|
|
1628
1671
|
this.scene.background = e, this.scene.environment = e;
|
|
1629
1672
|
}
|
|
1630
1673
|
async createGLTFLoader() {
|
|
1631
|
-
let e =
|
|
1632
|
-
return
|
|
1674
|
+
let e = yn(new jt(this._loadingManager), this.renderer), t = (e, t) => this._reportImageFailure(e, t);
|
|
1675
|
+
return _e().decodeImage ? e.register((e) => Ie(e, t)) : te() || e.register((e) => Pe(e, t)), e.register((e) => fn(e)), e.register(() => wn), e;
|
|
1633
1676
|
}
|
|
1634
1677
|
_reportImageFailure(e, t) {
|
|
1635
1678
|
try {
|
|
@@ -1657,7 +1700,7 @@ var Cn = class e extends L {
|
|
|
1657
1700
|
this._loadCancelled = !1;
|
|
1658
1701
|
let r = await this.createGLTFLoader(), i = e._isNetworkUrl(t), a = null;
|
|
1659
1702
|
try {
|
|
1660
|
-
|
|
1703
|
+
b({
|
|
1661
1704
|
isLoading: !0,
|
|
1662
1705
|
status: "Downloading Model...",
|
|
1663
1706
|
progress: 2,
|
|
@@ -1665,7 +1708,7 @@ var Cn = class e extends L {
|
|
|
1665
1708
|
loadedBytes: 0,
|
|
1666
1709
|
totalBytes: 0
|
|
1667
1710
|
}), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(dt.extractUrlBase(t));
|
|
1668
|
-
let e = await
|
|
1711
|
+
let e = await y(() => r.loadAsync(a.url, a.cached ? void 0 : this._downloadProgress("Downloading Model...", i)));
|
|
1669
1712
|
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 = Re(e), await this.onModelLoad(this.targetModel), this.dispatchEvent({
|
|
1670
1713
|
type: "load",
|
|
1671
1714
|
model: e.scene,
|
|
@@ -1688,7 +1731,7 @@ var Cn = class e extends L {
|
|
|
1688
1731
|
this._loadCancelled = !1;
|
|
1689
1732
|
let r = await this.createGLTFLoader(), i = e._isNetworkUrl(t), a = null;
|
|
1690
1733
|
try {
|
|
1691
|
-
|
|
1734
|
+
b({
|
|
1692
1735
|
isLoading: !0,
|
|
1693
1736
|
status: "Downloading Model...",
|
|
1694
1737
|
progress: 2,
|
|
@@ -1696,7 +1739,7 @@ var Cn = class e extends L {
|
|
|
1696
1739
|
loadedBytes: 0,
|
|
1697
1740
|
totalBytes: 0
|
|
1698
1741
|
}), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(dt.extractUrlBase(t));
|
|
1699
|
-
let e = await
|
|
1742
|
+
let e = await y(() => r.loadAsync(a.url, a.cached ? void 0 : this._downloadProgress("Downloading Model...", i)));
|
|
1700
1743
|
return this._downloadComplete(), this._throwDeferred(), this._appended = !0, this._processAndParent(e.scene), {
|
|
1701
1744
|
root: e.scene,
|
|
1702
1745
|
animations: e.animations || []
|
|
@@ -1713,18 +1756,18 @@ var Cn = class e extends L {
|
|
|
1713
1756
|
return n.name = e.name || t, this._processAndParent(n), { root: n };
|
|
1714
1757
|
}
|
|
1715
1758
|
removeModelRoot(e) {
|
|
1716
|
-
e && (e.userData.__rayzeeExternal ? (
|
|
1759
|
+
e && (e.userData.__rayzeeExternal ? (ee(e), e.parent?.remove(e)) : se(e));
|
|
1717
1760
|
}
|
|
1718
1761
|
async loadGLBFromArrayBuffer(e, t = "model.glb") {
|
|
1719
1762
|
let n = await this.createGLTFLoader();
|
|
1720
1763
|
try {
|
|
1721
|
-
|
|
1764
|
+
b({
|
|
1722
1765
|
isLoading: !0,
|
|
1723
1766
|
status: "Processing GLB Data...",
|
|
1724
1767
|
progress: 5
|
|
1725
1768
|
}), await new Promise((e) => setTimeout(e, 0));
|
|
1726
|
-
let r = await
|
|
1727
|
-
return this._throwDeferred(), this.releaseTargetModel(), this.targetModel = r.scene, this.animations = r.animations || [], this.sceneMetadata = Re(r),
|
|
1769
|
+
let r = await y(() => n.parseAsync(e, ""));
|
|
1770
|
+
return this._throwDeferred(), this.releaseTargetModel(), this.targetModel = r.scene, this.animations = r.animations || [], this.sceneMetadata = Re(r), b({
|
|
1728
1771
|
isLoading: !0,
|
|
1729
1772
|
status: "Processing Data...",
|
|
1730
1773
|
progress: 10
|
|
@@ -1746,7 +1789,7 @@ var Cn = class e extends L {
|
|
|
1746
1789
|
async loadObject3D(e, t = "object3d") {
|
|
1747
1790
|
this.releaseTargetModel();
|
|
1748
1791
|
let n = this._adoptExternalObject(e);
|
|
1749
|
-
return n.name = e.name || t, this.targetModel = n,
|
|
1792
|
+
return n.name = e.name || t, this.targetModel = n, b({
|
|
1750
1793
|
isLoading: !0,
|
|
1751
1794
|
status: "Processing Data...",
|
|
1752
1795
|
progress: 10
|
|
@@ -1760,10 +1803,10 @@ var Cn = class e extends L {
|
|
|
1760
1803
|
let t = new p("onModelLoad");
|
|
1761
1804
|
t.start("Camera extraction");
|
|
1762
1805
|
let n = this.extractCamerasFromModel(e);
|
|
1763
|
-
t.end("Camera extraction"), t.start("Camera setup");
|
|
1764
|
-
let r = new
|
|
1806
|
+
t.end("Camera extraction"), t.start("Camera setup"), ie(e);
|
|
1807
|
+
let r = new $e().setFromObject(e), i = r.getCenter(new W()), a = r.getSize(new W());
|
|
1765
1808
|
this.controls?.target.copy(i);
|
|
1766
|
-
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
|
|
1809
|
+
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 W(Math.cos(l) * c, c / Math.sqrt(2), Math.sin(l) * c);
|
|
1767
1810
|
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) {
|
|
1768
1811
|
let e = r.min.y;
|
|
1769
1812
|
this.floorPlane.position.y = e, this.floorPlane.rotation.x = -Math.PI / 2, this.floorPlane.scale.setScalar(o * 5);
|
|
@@ -1800,10 +1843,10 @@ var Cn = class e extends L {
|
|
|
1800
1843
|
let t = [], n = [];
|
|
1801
1844
|
e.traverse((e) => {
|
|
1802
1845
|
let r = e.userData;
|
|
1803
|
-
e.isRectAreaLight && !r.__radianceConverted && (e.intensity *=
|
|
1846
|
+
e.isRectAreaLight && !r.__radianceConverted && (e.intensity *= En(e, e.width, e.height, r), r.__radianceConverted = !0), (e.isPointLight || e.isSpotLight) && !r.__candelaConverted && (e.intensity *= 4 * Math.PI / Tn, r.__candelaConverted = !0), e.isDirectionalLight && !r.__luxConverted && (e.intensity /= Tn, r.__luxConverted = !0);
|
|
1804
1847
|
let i = e.name.startsWith("RectAreaLightPlaceholder");
|
|
1805
1848
|
if (i && !(r.name && r.type === "RectAreaLight") && !e.parent?.name?.startsWith("RectAreaLightPlaceholder") && n.push(e.name), i && r.name && r.type === "RectAreaLight") {
|
|
1806
|
-
let t = r.normalize ?? !0, n = r.shape ?? "rectangle", i = r.intensity *
|
|
1849
|
+
let t = r.normalize ?? !0, n = r.shape ?? "rectangle", i = r.intensity * En(e, r.width, r.height, r), a = new Ct(new nt(...r.color), i * this._areaLightIntensityScale(), r.width, r.height);
|
|
1807
1850
|
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);
|
|
1808
1851
|
}
|
|
1809
1852
|
e.isMesh && Array.isArray(e.material) && t.push(e);
|
|
@@ -1814,8 +1857,8 @@ var Cn = class e extends L {
|
|
|
1814
1857
|
let r = e.userData.__rayzeeExternal === !0;
|
|
1815
1858
|
for (let e of t) {
|
|
1816
1859
|
if (!e.parent) continue;
|
|
1817
|
-
console.log("Found multi-material mesh:", e.name), r && (e.geometry =
|
|
1818
|
-
let t =
|
|
1860
|
+
console.log("Found multi-material mesh:", e.name), r && (e.geometry = Cn(e.geometry));
|
|
1861
|
+
let t = Nt(e);
|
|
1819
1862
|
for (let e of t.children) e.geometry.userData.__rayzeeOwned = !0;
|
|
1820
1863
|
e.parent.add(t), e.parent.remove(e);
|
|
1821
1864
|
}
|
|
@@ -1824,7 +1867,7 @@ var Cn = class e extends L {
|
|
|
1824
1867
|
this.sceneScale = t;
|
|
1825
1868
|
}
|
|
1826
1869
|
createFloorPlane() {
|
|
1827
|
-
this.floorPlane = new pt(new
|
|
1870
|
+
this.floorPlane = new pt(new tt(), new mt({
|
|
1828
1871
|
transparent: !1,
|
|
1829
1872
|
color: 3158064,
|
|
1830
1873
|
roughness: 1,
|
|
@@ -1847,7 +1890,7 @@ var Cn = class e extends L {
|
|
|
1847
1890
|
}
|
|
1848
1891
|
getSupportedFormats(e = null) {
|
|
1849
1892
|
let t = {
|
|
1850
|
-
...
|
|
1893
|
+
...xn,
|
|
1851
1894
|
...this._archiveFormats
|
|
1852
1895
|
};
|
|
1853
1896
|
for (let [e, { type: n, name: r }] of this._formats) t[e] = {
|
|
@@ -1872,7 +1915,7 @@ var Cn = class e extends L {
|
|
|
1872
1915
|
this._listeners = void 0;
|
|
1873
1916
|
}
|
|
1874
1917
|
};
|
|
1875
|
-
function
|
|
1918
|
+
function On(e, t) {
|
|
1876
1919
|
let { data: n, width: r, height: i } = e.image ?? {};
|
|
1877
1920
|
if (!(n instanceof Float32Array) || r <= t || n.length !== r * i * 4) return;
|
|
1878
1921
|
let a = Math.ceil(r / t), o = Math.ceil(r / a), s = Math.ceil(i / a);
|
|
@@ -1893,17 +1936,17 @@ function wn(e, t) {
|
|
|
1893
1936
|
data: n.byteOffset === 0 && n.byteLength === n.buffer.byteLength && n.buffer.transfer ? new Float32Array(n.buffer.transfer(c)) : n.slice(0, o * s * 4),
|
|
1894
1937
|
width: o,
|
|
1895
1938
|
height: s
|
|
1896
|
-
}, e.needsUpdate = !0,
|
|
1939
|
+
}, e.needsUpdate = !0, bn.info(`environment ${r}×${i} shrunk to ${o}×${s} (memory spill)`);
|
|
1897
1940
|
}
|
|
1898
1941
|
//#endregion
|
|
1899
1942
|
//#region src/HeadlessCanvas.js
|
|
1900
|
-
var
|
|
1943
|
+
var kn = {
|
|
1901
1944
|
addEventListener() {},
|
|
1902
1945
|
removeEventListener() {},
|
|
1903
1946
|
dispatchEvent() {
|
|
1904
1947
|
return !0;
|
|
1905
1948
|
}
|
|
1906
|
-
},
|
|
1949
|
+
}, An = class {
|
|
1907
1950
|
constructor(e) {
|
|
1908
1951
|
this.canvas = e, this._configuration = null, this._texture = null;
|
|
1909
1952
|
}
|
|
@@ -1931,12 +1974,12 @@ var Tn = {
|
|
|
1931
1974
|
return this._texture;
|
|
1932
1975
|
}
|
|
1933
1976
|
};
|
|
1934
|
-
function
|
|
1977
|
+
function jn(e = 1, t = 1) {
|
|
1935
1978
|
let n = {
|
|
1936
|
-
...
|
|
1979
|
+
...kn,
|
|
1937
1980
|
defaultView: null
|
|
1938
1981
|
}, r = {
|
|
1939
|
-
...
|
|
1982
|
+
...kn,
|
|
1940
1983
|
isHeadlessCanvas: !0,
|
|
1941
1984
|
width: e,
|
|
1942
1985
|
height: t,
|
|
@@ -1963,12 +2006,12 @@ function Dn(e = 1, t = 1) {
|
|
|
1963
2006
|
hasPointerCapture: () => !1,
|
|
1964
2007
|
focus() {},
|
|
1965
2008
|
getContext: (e) => e === "webgpu" ? i : null
|
|
1966
|
-
}, i = new
|
|
2009
|
+
}, i = new An(r);
|
|
1967
2010
|
return r;
|
|
1968
2011
|
}
|
|
1969
2012
|
//#endregion
|
|
1970
2013
|
//#region src/managers/ViewCamera.js
|
|
1971
|
-
var
|
|
2014
|
+
var Mn = class extends yt {
|
|
1972
2015
|
constructor(e, t, n, r) {
|
|
1973
2016
|
super(e, t, n, r), this.orthographic = !1, this.orthoHalfHeight = 1;
|
|
1974
2017
|
}
|
|
@@ -1992,17 +2035,17 @@ var On = class extends vt {
|
|
|
1992
2035
|
return -this.orthoHalfHeight * this.aspect;
|
|
1993
2036
|
}
|
|
1994
2037
|
updateProjectionMatrix() {
|
|
1995
|
-
this.orthographic ?
|
|
2038
|
+
this.orthographic ? vt.prototype.updateProjectionMatrix.call(this) : super.updateProjectionMatrix();
|
|
1996
2039
|
}
|
|
1997
2040
|
copy(e, t) {
|
|
1998
2041
|
return super.copy(e, t), this.orthographic = e.orthographic === !0, this.orthoHalfHeight = e.orthoHalfHeight ?? this.orthoHalfHeight, this;
|
|
1999
2042
|
}
|
|
2000
|
-
},
|
|
2001
|
-
DirectionalLight:
|
|
2002
|
-
PointLight:
|
|
2003
|
-
SpotLight:
|
|
2004
|
-
RectAreaLight:
|
|
2005
|
-
},
|
|
2043
|
+
}, Nn = "__rayzeeUserLight", Pn = {
|
|
2044
|
+
DirectionalLight: it,
|
|
2045
|
+
PointLight: bt,
|
|
2046
|
+
SpotLight: Tt,
|
|
2047
|
+
RectAreaLight: Ct
|
|
2048
|
+
}, Fn = class extends V {
|
|
2006
2049
|
constructor(e, t, n, r = {}) {
|
|
2007
2050
|
super(), this.scene = e, this.sceneHelpers = t, this.pathTracer = n, this._onReset = r.onReset || null, this._onLightRemoved = r.onLightRemoved || null;
|
|
2008
2051
|
}
|
|
@@ -2050,14 +2093,14 @@ var On = class extends vt {
|
|
|
2050
2093
|
}[e];
|
|
2051
2094
|
if (!t) return null;
|
|
2052
2095
|
let n;
|
|
2053
|
-
if (e === "DirectionalLight") n = new
|
|
2054
|
-
else if (e === "PointLight") n = new
|
|
2096
|
+
if (e === "DirectionalLight") n = new it(t.color, t.intensity), n.position.fromArray(t.position);
|
|
2097
|
+
else if (e === "PointLight") n = new bt(t.color, t.intensity), n.position.fromArray(t.position);
|
|
2055
2098
|
else if (e === "SpotLight") {
|
|
2056
|
-
n = new
|
|
2057
|
-
let e = new
|
|
2099
|
+
n = new Tt(t.color, t.intensity), n.position.fromArray(t.position), n.angle = H.degToRad(t.angle);
|
|
2100
|
+
let e = new _t();
|
|
2058
2101
|
this.scene.add(e), n.target = e;
|
|
2059
|
-
} else e === "RectAreaLight" && (n = new
|
|
2060
|
-
n.userData[
|
|
2102
|
+
} else e === "RectAreaLight" && (n = new Ct(t.color, t.intensity, t.width, t.height), n.position.fromArray(t.position), n.lookAt(0, 0, 0), n.userData.normalize = !0, n.userData.spread = Math.PI, n.userData.shape = "rectangle");
|
|
2103
|
+
n.userData[Nn] = !0, n.userData.temperature = 6500, n.userData.useTemperature = !1, n.userData.exposure = 0;
|
|
2061
2104
|
let r = this.scene.getObjectsByProperty("isLight", !0).length;
|
|
2062
2105
|
return n.name = `${e.replace("Light", "")} ${r + 1}`, this.scene.add(n), this.updateLights(), this._syncHelpers(), this._onReset?.(), this._buildDescriptor(n);
|
|
2063
2106
|
}
|
|
@@ -2083,7 +2126,7 @@ var On = class extends vt {
|
|
|
2083
2126
|
this.pathTracer?.updateLights(), this.sceneHelpers?.visible && this.sceneHelpers.update();
|
|
2084
2127
|
}
|
|
2085
2128
|
transferSceneLights(e, { keepUserLights: t = !1 } = {}) {
|
|
2086
|
-
this._removeAllLights(t ? (e) => !e.userData?.[
|
|
2129
|
+
this._removeAllLights(t ? (e) => !e.userData?.[Nn] : void 0);
|
|
2087
2130
|
let n = e.getObjectsByProperty("isLight", !0);
|
|
2088
2131
|
if (!n || n.length === 0) {
|
|
2089
2132
|
this.updateLights();
|
|
@@ -2092,7 +2135,7 @@ var On = class extends vt {
|
|
|
2092
2135
|
for (let e of n) {
|
|
2093
2136
|
let t = e.clone();
|
|
2094
2137
|
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) {
|
|
2095
|
-
let n = new
|
|
2138
|
+
let n = new _t();
|
|
2096
2139
|
e.target.updateWorldMatrix(!0, !1), e.target.getWorldPosition(n.position), this.scene.add(n), t.target = n;
|
|
2097
2140
|
}
|
|
2098
2141
|
this.scene.add(t);
|
|
@@ -2137,14 +2180,14 @@ var On = class extends vt {
|
|
|
2137
2180
|
this.sceneHelpers?.clear(), this._removeAllLights();
|
|
2138
2181
|
let t = [];
|
|
2139
2182
|
for (let n of e ?? []) {
|
|
2140
|
-
let e =
|
|
2183
|
+
let e = Pn[n.type];
|
|
2141
2184
|
if (!e) continue;
|
|
2142
2185
|
let r = new e();
|
|
2143
2186
|
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 ?? [
|
|
2144
2187
|
1,
|
|
2145
2188
|
1,
|
|
2146
2189
|
1
|
|
2147
|
-
]), r.userData =
|
|
2190
|
+
]), r.userData = h(n.userData) ?? {};
|
|
2148
2191
|
for (let e of [
|
|
2149
2192
|
"angle",
|
|
2150
2193
|
"penumbra",
|
|
@@ -2154,7 +2197,7 @@ var On = class extends vt {
|
|
|
2154
2197
|
"height"
|
|
2155
2198
|
]) typeof n[e] == "number" && (r[e] = n[e]);
|
|
2156
2199
|
if (n.target) {
|
|
2157
|
-
let e = new
|
|
2200
|
+
let e = new _t();
|
|
2158
2201
|
e.position.fromArray(n.target), this.scene.add(e), r.target = e;
|
|
2159
2202
|
}
|
|
2160
2203
|
this.scene.add(r), t.push(r);
|
|
@@ -2194,7 +2237,7 @@ var On = class extends vt {
|
|
|
2194
2237
|
}
|
|
2195
2238
|
_buildDescriptor(e) {
|
|
2196
2239
|
let t = 0;
|
|
2197
|
-
e.type === "SpotLight" && e.angle !== void 0 ? t =
|
|
2240
|
+
e.type === "SpotLight" && e.angle !== void 0 ? t = H.radToDeg(e.angle) : e.type === "DirectionalLight" && (t = H.radToDeg(e.userData?.angle ?? 0));
|
|
2198
2241
|
let n = {
|
|
2199
2242
|
uuid: e.uuid,
|
|
2200
2243
|
name: e.name,
|
|
@@ -2213,7 +2256,7 @@ var On = class extends vt {
|
|
|
2213
2256
|
exposure: e.userData?.exposure ?? 0
|
|
2214
2257
|
};
|
|
2215
2258
|
if (e.type === "RectAreaLight") {
|
|
2216
|
-
n.width = e.width, n.height = e.height, n.normalize = e.userData?.normalize ?? !0, n.spread =
|
|
2259
|
+
n.width = e.width, n.height = e.height, n.normalize = e.userData?.normalize ?? !0, n.spread = H.radToDeg(e.userData?.spread ?? Math.PI);
|
|
2217
2260
|
let t = e.userData?.shape;
|
|
2218
2261
|
n.shape = t === "square" || t === "rectangle" || t === "disk" || t === "ellipse" ? t : t === 1 ? "ellipse" : "rectangle";
|
|
2219
2262
|
let r = e.getWorldDirection(e.position.clone());
|
|
@@ -2229,11 +2272,11 @@ var On = class extends vt {
|
|
|
2229
2272
|
], 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);
|
|
2230
2273
|
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;
|
|
2231
2274
|
}
|
|
2232
|
-
},
|
|
2275
|
+
}, In = ({ element: e, pbrtEntry: t } = {}) => ({
|
|
2233
2276
|
...e === void 0 ? {} : { element: e },
|
|
2234
2277
|
...t === void 0 ? {} : { pbrtEntry: t }
|
|
2235
|
-
}), Q = /* @__PURE__ */ new WeakMap(),
|
|
2236
|
-
async function
|
|
2278
|
+
}), Q = /* @__PURE__ */ new WeakMap(), Ln = 3e4, Rn = new Set([...Object.values(_), ...Object.values(g)]), zn = /* @__PURE__ */ new Set();
|
|
2279
|
+
async function Bn(e, t) {
|
|
2237
2280
|
if (!t || typeof self < "u") return e.init();
|
|
2238
2281
|
globalThis.self = {
|
|
2239
2282
|
requestAnimationFrame: () => 0,
|
|
@@ -2246,16 +2289,16 @@ async function In(e, t) {
|
|
|
2246
2289
|
}
|
|
2247
2290
|
}
|
|
2248
2291
|
var $ = S("engine");
|
|
2249
|
-
function
|
|
2292
|
+
function Vn() {
|
|
2250
2293
|
let e = new Float32Array(16);
|
|
2251
|
-
return new Uint32Array(e.buffer)[3] =
|
|
2294
|
+
return new Uint32Array(e.buffer)[3] = ye.TRIANGLE_LEAF, e;
|
|
2252
2295
|
}
|
|
2253
|
-
function
|
|
2296
|
+
function Hn(e, t) {
|
|
2254
2297
|
e.lost.then((e) => {
|
|
2255
2298
|
t.app && t.app._handleDeviceLost(e);
|
|
2256
2299
|
});
|
|
2257
2300
|
}
|
|
2258
|
-
var
|
|
2301
|
+
var Un = [
|
|
2259
2302
|
"core-features-and-limits",
|
|
2260
2303
|
"depth-clip-control",
|
|
2261
2304
|
"depth32float-stencil8",
|
|
@@ -2276,33 +2319,33 @@ var zn = [
|
|
|
2276
2319
|
"subgroups",
|
|
2277
2320
|
"texture-formats-tier1",
|
|
2278
2321
|
"texture-formats-tier2"
|
|
2279
|
-
],
|
|
2280
|
-
function
|
|
2322
|
+
], Wn = /swiftshader|llvmpipe|lavapipe|basic render|microsoft basic|warp/i;
|
|
2323
|
+
function Gn(e) {
|
|
2281
2324
|
let t = e.info ?? {}, n = `${t.vendor ?? ""} ${t.architecture ?? ""} ${t.device ?? ""} ${t.description ?? ""}`;
|
|
2282
2325
|
return {
|
|
2283
2326
|
vendor: t.vendor ?? "",
|
|
2284
2327
|
architecture: t.architecture ?? "",
|
|
2285
2328
|
device: t.device ?? "",
|
|
2286
2329
|
description: t.description ?? "",
|
|
2287
|
-
isSoftware: t.isFallbackAdapter === !0 || e.isFallbackAdapter === !0 ||
|
|
2330
|
+
isSoftware: t.isFallbackAdapter === !0 || e.isFallbackAdapter === !0 || Wn.test(n)
|
|
2288
2331
|
};
|
|
2289
2332
|
}
|
|
2290
|
-
var
|
|
2333
|
+
var Kn = class extends V {
|
|
2291
2334
|
constructor(e, t = {}) {
|
|
2292
|
-
super(), this._headless = t.headless === !0 || !e, e ??=
|
|
2335
|
+
super(), this._headless = t.headless === !0 || !e, e ??= jn();
|
|
2293
2336
|
try {
|
|
2294
2337
|
Q.get(e)?.dispose();
|
|
2295
2338
|
} catch (e) {
|
|
2296
2339
|
$.warn("prior canvas owner dispose failed", e);
|
|
2297
2340
|
}
|
|
2298
2341
|
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`.");
|
|
2299
|
-
this._issues = new
|
|
2342
|
+
this._issues = new be({
|
|
2300
2343
|
strict: t.strict === !0,
|
|
2301
2344
|
onIssue: (e) => this.dispatchEvent({
|
|
2302
|
-
type:
|
|
2345
|
+
type: _.ISSUE,
|
|
2303
2346
|
issue: e
|
|
2304
2347
|
})
|
|
2305
|
-
}), this.color = new
|
|
2348
|
+
}), this.color = new un({ issues: this._issues }), Te(this.color), this.settings = new ln(v, { 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 Zt(), 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;
|
|
2306
2349
|
}
|
|
2307
2350
|
_addTrackedListener(e, t, n) {
|
|
2308
2351
|
e && (e.addEventListener(t, n), this._trackedListeners.push({
|
|
@@ -2321,21 +2364,21 @@ var Hn = class extends L {
|
|
|
2321
2364
|
}
|
|
2322
2365
|
async init() {
|
|
2323
2366
|
let e = this._initStorage();
|
|
2324
|
-
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(
|
|
2367
|
+
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(ve.FLOATS_PER_TRIANGLE), 0), this.stages.pathTracer.setBVHData(Vn()), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setupMaterial(), this.isInitialized = !0, $.debug("WebGPU path tracer app initialized"), this;
|
|
2325
2368
|
}
|
|
2326
2369
|
async setStorageOpener(e) {
|
|
2327
2370
|
this._storageOpener = e, !(!this.isInitialized || this.storage || this._disposed) && (await this._initStorage(), this._attachStorage());
|
|
2328
2371
|
}
|
|
2329
2372
|
async _initStorage() {
|
|
2330
|
-
let e = this._storageOption ?? (this._issues.strict && !
|
|
2373
|
+
let e = this._storageOption ?? (this._issues.strict && !De("storage") ? !1 : T().storage);
|
|
2331
2374
|
if (e !== !1) {
|
|
2332
2375
|
if (e && typeof e == "object") this.storage = e;
|
|
2333
2376
|
else {
|
|
2334
2377
|
if (!this._storageOpener) {
|
|
2335
|
-
(this._storageOption !== void 0 ||
|
|
2378
|
+
(this._storageOption !== void 0 || De("storage")) && this._issues.warn(C.CAPABILITY_MISSING, "on-disk storage needs rayzee/addons/storage: setStorageOpener( acquireSharedStorage )");
|
|
2336
2379
|
return;
|
|
2337
2380
|
}
|
|
2338
|
-
let { storage: e, reason: t, release: n } = await this._storageOpener(
|
|
2381
|
+
let { storage: e, reason: t, release: n } = await this._storageOpener(T().cacheNamespace);
|
|
2339
2382
|
if (this._disposed) {
|
|
2340
2383
|
n();
|
|
2341
2384
|
return;
|
|
@@ -2347,7 +2390,7 @@ var Hn = class extends L {
|
|
|
2347
2390
|
this.storage = e, this._storageRelease = n;
|
|
2348
2391
|
}
|
|
2349
2392
|
this._addTrackedListener(this.storage, "change", (e) => this.dispatchEvent({
|
|
2350
|
-
type:
|
|
2393
|
+
type: _.STORAGE_CHANGED,
|
|
2351
2394
|
area: e.area
|
|
2352
2395
|
})), this._addTrackedListener(this.storage, "issue", (e) => this._issues.warn(e.code, e.message, e.detail));
|
|
2353
2396
|
}
|
|
@@ -2357,20 +2400,20 @@ var Hn = class extends L {
|
|
|
2357
2400
|
}
|
|
2358
2401
|
dispatchEvent(e) {
|
|
2359
2402
|
super.dispatchEvent(e);
|
|
2360
|
-
let t =
|
|
2403
|
+
let t = g[e.type];
|
|
2361
2404
|
t && super.dispatchEvent({
|
|
2362
2405
|
...e,
|
|
2363
2406
|
type: t
|
|
2364
2407
|
});
|
|
2365
2408
|
}
|
|
2366
2409
|
addEventListener(e, t) {
|
|
2367
|
-
!
|
|
2410
|
+
!Rn.has(e) && !zn.has(e) && (zn.add(e), $.warn(`no engine event is named "${e}", so this listener will never fire — see EngineEvents`)), super.addEventListener(e, t);
|
|
2368
2411
|
}
|
|
2369
2412
|
animate() {
|
|
2370
2413
|
if (this._headless) throw Error("a headless app has no render loop — drive it with renderFrames() or renderUntilComplete()");
|
|
2371
2414
|
if (this._deviceLost) return;
|
|
2372
2415
|
if (this.animationManagerId = requestAnimationFrame(() => this.animate()), this._loadingInProgress || this._sdf?.isProcessing) {
|
|
2373
|
-
this.dispatchEvent({ type:
|
|
2416
|
+
this.dispatchEvent({ type: _.FRAME });
|
|
2374
2417
|
return;
|
|
2375
2418
|
}
|
|
2376
2419
|
this._beginFrame();
|
|
@@ -2383,29 +2426,29 @@ var Hn = class extends L {
|
|
|
2383
2426
|
if (this._beforeTrace(), this.stages.pathTracer?.isReady) {
|
|
2384
2427
|
if (this.stages.pathTracer.isComplete && this.completion.renderCompleteDispatched) {
|
|
2385
2428
|
if (this._needsDisplayRefresh && (this._needsDisplayRefresh = !1, this.stages.compositor.render(this.pipeline.context), this._renderHelperOverlay()), this._settling()) {
|
|
2386
|
-
this.dispatchEvent({ type:
|
|
2429
|
+
this.dispatchEvent({ type: _.FRAME });
|
|
2387
2430
|
return;
|
|
2388
2431
|
}
|
|
2389
2432
|
this.stopAnimation();
|
|
2390
2433
|
return;
|
|
2391
2434
|
}
|
|
2392
2435
|
if (this._holdTrace(e)) {
|
|
2393
|
-
this._renderHelperOverlay(), this.dispatchEvent({ type:
|
|
2436
|
+
this._renderHelperOverlay(), this.dispatchEvent({ type: _.FRAME });
|
|
2394
2437
|
return;
|
|
2395
2438
|
}
|
|
2396
2439
|
if (this.stages.pathTracer.readbackWait()) {
|
|
2397
|
-
this.dispatchEvent({ type:
|
|
2440
|
+
this.dispatchEvent({ type: _.FRAME });
|
|
2398
2441
|
return;
|
|
2399
2442
|
}
|
|
2400
2443
|
this._traceFrame({ liveDenoise: !0 }), this.stages.pathTracer.isComplete && this.completion.markComplete() && this._announceComplete();
|
|
2401
2444
|
}
|
|
2402
|
-
this._renderHelperOverlay(), this.dispatchEvent({ type:
|
|
2445
|
+
this._renderHelperOverlay(), this.dispatchEvent({ type: _.FRAME });
|
|
2403
2446
|
}
|
|
2404
2447
|
}
|
|
2405
2448
|
_announceComplete() {
|
|
2406
2449
|
let e = this._completionInfo(), t = this.stages.pathTracer.resetCount, n = () => {
|
|
2407
2450
|
!this.completion.renderCompleteDispatched || this.stages.pathTracer?.resetCount !== t || (this._renderCompleted(), this.dispatchEvent({
|
|
2408
|
-
type:
|
|
2451
|
+
type: _.RENDER_COMPLETE,
|
|
2409
2452
|
...e
|
|
2410
2453
|
}));
|
|
2411
2454
|
}, r = this._finishImage();
|
|
@@ -2415,9 +2458,9 @@ var Hn = class extends L {
|
|
|
2415
2458
|
let t = this.stages.pathTracer;
|
|
2416
2459
|
this.pipeline.render(), this._afterTrace(t, e), t.isComplete || this.completion.updateTime(), this._ensureVRAMWiring();
|
|
2417
2460
|
let n = t.vramTracker, r = t.frameCount ?? 0;
|
|
2418
|
-
n && (r <= 1 || r % 30 == 0) && n.measure(),
|
|
2461
|
+
n && (r <= 1 || r % 30 == 0) && n.measure(), ae({
|
|
2419
2462
|
timeElapsed: this.completion.timeElapsed,
|
|
2420
|
-
samples:
|
|
2463
|
+
samples: de(t),
|
|
2421
2464
|
memoryUsed: n?.current ?? 0,
|
|
2422
2465
|
memoryPeak: n?.peak ?? 0
|
|
2423
2466
|
}), this.completion.isTimeLimitReached(t, this.settings.get("renderLimitMode"), this.settings.get("renderTimeLimit")) && (t.isComplete = !0);
|
|
@@ -2435,7 +2478,7 @@ var Hn = class extends L {
|
|
|
2435
2478
|
}
|
|
2436
2479
|
_handleDeviceLost(e) {
|
|
2437
2480
|
this._deviceLost || (this._deviceLost = !0, $.error(`WebGPU device lost (${e?.reason || "unknown"}): ${e?.message || ""}`), this.stopAnimation(), this.dispatchEvent({
|
|
2438
|
-
type:
|
|
2481
|
+
type: _.DEVICE_LOST,
|
|
2439
2482
|
reason: e?.reason,
|
|
2440
2483
|
message: e?.message
|
|
2441
2484
|
}));
|
|
@@ -2450,35 +2493,35 @@ var Hn = class extends L {
|
|
|
2450
2493
|
this._paused = !1, !this.animationManagerId && !this._headless && this.animate();
|
|
2451
2494
|
}
|
|
2452
2495
|
reset(e = !1, { motion: t = !1 } = {}) {
|
|
2453
|
-
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:
|
|
2496
|
+
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: _.RENDER_RESET });
|
|
2454
2497
|
}
|
|
2455
2498
|
dispose() {
|
|
2456
2499
|
if (this._disposed) return;
|
|
2457
|
-
if (this._disposed = !0, this.dispatchEvent({ type:
|
|
2500
|
+
if (this._disposed = !0, this.dispatchEvent({ type: _.DISPOSE }), this.stopAnimation(), clearTimeout(this._resizeDebounceTimer), this._resizeDebounceTimer = null, clearTimeout(this._respillTimer), this._respillTimer = null, this._removeTrackedListeners(), le(null), this._storageRelease?.(), this._storageRelease = null, this.storage = null, this._sceneSource = this._sceneSourceInput = null, this._issues.detach(), this.color?.dispose(), this.color = null, this._pictureCopy = 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) {
|
|
2458
2501
|
this.meshScene.environment?.dispose(), this.meshScene.environment = null;
|
|
2459
|
-
for (let e of [...this.meshScene.children])
|
|
2502
|
+
for (let e of [...this.meshScene.children]) se(e);
|
|
2460
2503
|
this.meshScene.clear(), this.meshScene = null;
|
|
2461
2504
|
}
|
|
2462
2505
|
this._sceneHelpers?.clear(), this._sceneHelpers = null, this.scene?.clear(), this.scene = null;
|
|
2463
2506
|
try {
|
|
2464
|
-
let e =
|
|
2507
|
+
let e = Xe().value, t = Ke().value;
|
|
2465
2508
|
e?._listeners?.dispose && (e._listeners.dispose.length = 0), t?._listeners?.dispose && (t._listeners.dispose.length = 0);
|
|
2466
2509
|
} catch (e) {
|
|
2467
2510
|
$.warn("failed to clear TSL texture singleton listeners", e);
|
|
2468
2511
|
}
|
|
2469
2512
|
this.canvas && Q.get(this.canvas) === this && Q.delete(this.canvas);
|
|
2470
2513
|
let e = this._gpuDevice;
|
|
2471
|
-
e && (e.onuncapturederror = null, this._gpuDevice = null), this._deviceLostHolder &&= (this._deviceLostHolder.app = null, null), Promise.resolve(
|
|
2514
|
+
e && (e.onuncapturederror = null, this._gpuDevice = null), this._deviceLostHolder &&= (this._deviceLostHolder.app = null, null), Promise.resolve(me(this.renderer)).finally(() => e?.destroy()), this.renderer = null, this.stages = {}, this.isInitialized = !1;
|
|
2472
2515
|
}
|
|
2473
2516
|
unloadScene() {
|
|
2474
2517
|
if (this.isInitialized) {
|
|
2475
2518
|
if (this._loadingInProgress) throw Error("PathTracerApp.unloadScene: cannot unload while a load is in progress");
|
|
2476
|
-
this._disposed || (this._releaseSceneState(), this.assetLoader?.releaseTargetModel(), this._sceneSource = this._sceneSourceInput = null, this.lightManager?.clearLights?.(), this.stages.pathTracer && (this.stages.pathTracer.setTriangleData(new Uint32Array(
|
|
2519
|
+
this._disposed || (this._releaseSceneState(), this.assetLoader?.releaseTargetModel(), this._sceneSource = this._sceneSourceInput = null, this.lightManager?.clearLights?.(), this.stages.pathTracer && (this.stages.pathTracer.setTriangleData(new Uint32Array(ve.FLOATS_PER_TRIANGLE), 0), this.stages.pathTracer.setBVHData(Vn()), 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: _.SCENE_UNLOADED }));
|
|
2477
2520
|
}
|
|
2478
2521
|
}
|
|
2479
2522
|
async loadModel(e, t = {}) {
|
|
2480
2523
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadModel(e, t), {
|
|
2481
|
-
type:
|
|
2524
|
+
type: _.MODEL_LOADED,
|
|
2482
2525
|
url: e
|
|
2483
2526
|
}, {
|
|
2484
2527
|
kind: "url",
|
|
@@ -2488,7 +2531,7 @@ var Hn = class extends L {
|
|
|
2488
2531
|
}
|
|
2489
2532
|
async loadObject3D(e, t = "object3d") {
|
|
2490
2533
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadObject3D(e, t), {
|
|
2491
|
-
type:
|
|
2534
|
+
type: _.OBJECT3D_LOADED,
|
|
2492
2535
|
name: t
|
|
2493
2536
|
}, {
|
|
2494
2537
|
kind: "object3d",
|
|
@@ -2506,7 +2549,7 @@ var Hn = class extends L {
|
|
|
2506
2549
|
await this.assetLoader.loadEnvironment(e);
|
|
2507
2550
|
let t = this.meshScene.environment;
|
|
2508
2551
|
t && this.stages.pathTracer && await this.stages.pathTracer.environment.setEnvironmentMap(t), this.pipeline?.eventBus.emit("pipeline:lightingChanged"), this.reset(), this.dispatchEvent({
|
|
2509
|
-
type:
|
|
2552
|
+
type: _.ENVIRONMENT_LOADED,
|
|
2510
2553
|
url: e
|
|
2511
2554
|
});
|
|
2512
2555
|
} finally {
|
|
@@ -2525,31 +2568,31 @@ var Hn = class extends L {
|
|
|
2525
2568
|
...t,
|
|
2526
2569
|
filename: n
|
|
2527
2570
|
}), {
|
|
2528
|
-
type:
|
|
2571
|
+
type: _.MODEL_LOADED,
|
|
2529
2572
|
filename: n
|
|
2530
2573
|
}, {
|
|
2531
2574
|
kind: "url",
|
|
2532
2575
|
url: e,
|
|
2533
2576
|
filename: n,
|
|
2534
2577
|
cacheKey: t.cacheKey ?? null,
|
|
2535
|
-
...
|
|
2578
|
+
...In(t)
|
|
2536
2579
|
});
|
|
2537
2580
|
return;
|
|
2538
2581
|
}
|
|
2539
|
-
if (
|
|
2582
|
+
if (k(e)) {
|
|
2540
2583
|
let n = Fe(e, { isModel: (e) => this.assetLoader?.getFileFormat(e)?.type === "model" });
|
|
2541
2584
|
if (n.files.length === 0) throw Error(`${n.name} holds no files to load`);
|
|
2542
2585
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadFolder(n, t), {
|
|
2543
|
-
type:
|
|
2586
|
+
type: _.MODEL_LOADED,
|
|
2544
2587
|
filename: n.name
|
|
2545
2588
|
}, async () => {
|
|
2546
|
-
let e = await
|
|
2589
|
+
let e = await Ne(n);
|
|
2547
2590
|
return {
|
|
2548
2591
|
kind: "local-folder",
|
|
2549
2592
|
folder: e,
|
|
2550
|
-
key:
|
|
2593
|
+
key: D(e),
|
|
2551
2594
|
...n.flat ? { flat: !0 } : {},
|
|
2552
|
-
...
|
|
2595
|
+
...In(t)
|
|
2553
2596
|
};
|
|
2554
2597
|
}), this._sceneSourceInput = n;
|
|
2555
2598
|
return;
|
|
@@ -2557,22 +2600,22 @@ var Hn = class extends L {
|
|
|
2557
2600
|
let n = this.assetLoader?.getFileFormat(e?.name || "");
|
|
2558
2601
|
if (!n) throw this.assetLoader.formatError(e?.name || "");
|
|
2559
2602
|
if (n.type !== "environment" && n.type !== "image") {
|
|
2560
|
-
let n =
|
|
2603
|
+
let n = O(e).catch(() => ({
|
|
2561
2604
|
name: e.name,
|
|
2562
2605
|
size: e.size,
|
|
2563
2606
|
lastModified: e.lastModified ?? 0,
|
|
2564
2607
|
sample: null
|
|
2565
2608
|
}));
|
|
2566
2609
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadAssetFromFile(e, t), {
|
|
2567
|
-
type:
|
|
2610
|
+
type: _.MODEL_LOADED,
|
|
2568
2611
|
filename: e.name
|
|
2569
2612
|
}, async () => {
|
|
2570
2613
|
let e = await n;
|
|
2571
2614
|
return {
|
|
2572
2615
|
kind: "local-file",
|
|
2573
2616
|
file: e,
|
|
2574
|
-
key: e.sample ?
|
|
2575
|
-
...
|
|
2617
|
+
key: e.sample ? D(e) : null,
|
|
2618
|
+
...In(t)
|
|
2576
2619
|
};
|
|
2577
2620
|
}), this._sceneSourceInput = e;
|
|
2578
2621
|
return;
|
|
@@ -2583,7 +2626,7 @@ var Hn = class extends L {
|
|
|
2583
2626
|
await this.assetLoader.loadAssetFromFile(e);
|
|
2584
2627
|
let t = this.meshScene.environment;
|
|
2585
2628
|
t && this.stages.pathTracer && await this.stages.pathTracer.environment.applyHDRI(t), this.pipeline?.eventBus.emit("pipeline:lightingChanged"), this.reset(), this.dispatchEvent({
|
|
2586
|
-
type:
|
|
2629
|
+
type: _.ENVIRONMENT_LOADED,
|
|
2587
2630
|
filename: e.name
|
|
2588
2631
|
});
|
|
2589
2632
|
} finally {
|
|
@@ -2592,7 +2635,7 @@ var Hn = class extends L {
|
|
|
2592
2635
|
}
|
|
2593
2636
|
async loadExampleModels(e, t) {
|
|
2594
2637
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadExampleModels(e, t), {
|
|
2595
|
-
type:
|
|
2638
|
+
type: _.MODEL_LOADED,
|
|
2596
2639
|
index: e
|
|
2597
2640
|
}, {
|
|
2598
2641
|
kind: "url",
|
|
@@ -2609,7 +2652,7 @@ var Hn = class extends L {
|
|
|
2609
2652
|
this._loadingInProgress = !0;
|
|
2610
2653
|
try {
|
|
2611
2654
|
await this.loadSceneData(), this.reset(), this.dispatchEvent({
|
|
2612
|
-
type:
|
|
2655
|
+
type: _.TEXTURES_REPROCESSED,
|
|
2613
2656
|
maxTextureSize: r
|
|
2614
2657
|
});
|
|
2615
2658
|
} finally {
|
|
@@ -2621,20 +2664,20 @@ var Hn = class extends L {
|
|
|
2621
2664
|
return this._sceneSource ?? null;
|
|
2622
2665
|
}
|
|
2623
2666
|
get sceneSourceFile() {
|
|
2624
|
-
return this._sceneSourceInput && !
|
|
2667
|
+
return this._sceneSourceInput && !k(this._sceneSourceInput) ? this._sceneSourceInput : null;
|
|
2625
2668
|
}
|
|
2626
2669
|
get sceneSourceFolder() {
|
|
2627
|
-
return
|
|
2670
|
+
return k(this._sceneSourceInput) ? this._sceneSourceInput : null;
|
|
2628
2671
|
}
|
|
2629
2672
|
async _loadWithSceneRebuild(e, t, n = null) {
|
|
2630
2673
|
if (this._loadingInProgress) throw this._busyError("PathTracerApp");
|
|
2631
|
-
this._loadingInProgress = !0, this.assetLoader && (this.assetLoader.maxEnvironmentWidth = this._memorySpill === !0 ?
|
|
2674
|
+
this._loadingInProgress = !0, this.assetLoader && (this.assetLoader.maxEnvironmentWidth = this._memorySpill === !0 ? ue : 0);
|
|
2632
2675
|
try {
|
|
2633
2676
|
await e(), this._sceneSource = typeof n == "function" ? await n() : n, this._sceneSourceInput = null, this._emissiveSamplingUserSet = !1, this._clearAppendedModels(), this._modelReplaced(), this._planSpill();
|
|
2634
2677
|
let r = await this.loadSceneData({ pendingEnvironment: this._beginSceneMetadataEnvironment() });
|
|
2635
2678
|
this._maybeSpill(), this.pipeline?.eventBus.emit("pipeline:lightingChanged"), this._dropDisplay(), this.reset(), this.dispatchEvent(t), this._modelAnnounced(), r && this.assetLoader?.commitPendingGraph(this.sceneModel);
|
|
2636
2679
|
} catch (e) {
|
|
2637
|
-
throw (!e || e.code !== "LOAD_IN_PROGRESS") && this._discardFailedLoad(), e?.code === "ARCHIVE_NEEDS_ELEMENT" ?
|
|
2680
|
+
throw (!e || e.code !== "LOAD_IN_PROGRESS") && this._discardFailedLoad(), e?.code === "ARCHIVE_NEEDS_ELEMENT" ? pe() : e?.code !== "LOAD_IN_PROGRESS" && b({
|
|
2638
2681
|
status: `Error: ${e?.message ?? e}`,
|
|
2639
2682
|
failed: !0,
|
|
2640
2683
|
progress: 100
|
|
@@ -2676,7 +2719,7 @@ var Hn = class extends L {
|
|
|
2676
2719
|
reset: !1,
|
|
2677
2720
|
source: Y.SCENE_METADATA
|
|
2678
2721
|
}), this.scene && (this.scene.background = e), this.dispatchEvent({
|
|
2679
|
-
type:
|
|
2722
|
+
type: _.SCENE_METADATA_APPLIED,
|
|
2680
2723
|
metadata: t,
|
|
2681
2724
|
environment: { ...n }
|
|
2682
2725
|
});
|
|
@@ -2693,7 +2736,7 @@ var Hn = class extends L {
|
|
|
2693
2736
|
reset: !1,
|
|
2694
2737
|
source: Y.SCENE_METADATA
|
|
2695
2738
|
}), this.dispatchEvent({
|
|
2696
|
-
type:
|
|
2739
|
+
type: _.SCENE_METADATA_APPLIED,
|
|
2697
2740
|
metadata: this.sceneMetadata,
|
|
2698
2741
|
environment: { enabled: !1 }
|
|
2699
2742
|
});
|
|
@@ -2708,7 +2751,7 @@ var Hn = class extends L {
|
|
|
2708
2751
|
source: i
|
|
2709
2752
|
});
|
|
2710
2753
|
this.dispatchEvent({
|
|
2711
|
-
type:
|
|
2754
|
+
type: _.SCENE_METADATA_APPLIED,
|
|
2712
2755
|
metadata: this.sceneMetadata,
|
|
2713
2756
|
environment: { enabled: this.settings.get("enableEnvironment") }
|
|
2714
2757
|
});
|
|
@@ -2726,15 +2769,15 @@ var Hn = class extends L {
|
|
|
2726
2769
|
})), n.start("BVH build (SceneProcessor)"), this._sdf.setMaxTextureSize(this.settings.get("maxTextureSize")), await this._sdf.buildBVH(this.meshScene, {
|
|
2727
2770
|
sceneKey: this.assetLoader?.sceneSourceKey ?? null,
|
|
2728
2771
|
progressive: this._progressiveSpill()
|
|
2729
|
-
}), this.assetLoader?.flushPendingGraph(this._sdf.performanceMetrics.totalProcessingTime), n.end("BVH build (SceneProcessor)"),
|
|
2772
|
+
}), this.assetLoader?.flushPendingGraph(this._sdf.performanceMetrics.totalProcessingTime), n.end("BVH build (SceneProcessor)"), b({
|
|
2730
2773
|
status: "Transferring data to GPU...",
|
|
2731
2774
|
progress: 86
|
|
2732
2775
|
}), 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;
|
|
2733
2776
|
for (let e of [...this._sdf.srgbBucketTextures ?? [], ...this._sdf.linearBucketTextures ?? []]) e && (this.renderer.initTexture(e), await this.stages.pathTracer.drainUploads());
|
|
2734
|
-
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"),
|
|
2777
|
+
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"), b({
|
|
2735
2778
|
status: "Compiling shaders...",
|
|
2736
2779
|
progress: 90
|
|
2737
|
-
}), await new Promise((e) => setTimeout(e, 0)), n.start("Material setup (TSL compile)"), this.stages.pathTracer.setupMaterial(), n.end("Material setup (TSL compile)"), this._rasterPrecompile = null, this._pathTracerEnabled || (n.start("Pipeline precompile"), await this.precompileRaster(), n.end("Pipeline precompile")), a && (
|
|
2780
|
+
}), await new Promise((e) => setTimeout(e, 0)), n.start("Material setup (TSL compile)"), this.stages.pathTracer.setupMaterial(), n.end("Material setup (TSL compile)"), this._rasterPrecompile = null, this._pathTracerEnabled || (n.start("Pipeline precompile"), await this.precompileRaster(), n.end("Pipeline precompile")), a && (b({
|
|
2738
2781
|
status: "Finalizing environment map...",
|
|
2739
2782
|
progress: 95
|
|
2740
2783
|
}), await a, this.stages.pathTracer.environment.applyCDFResults());
|
|
@@ -2743,7 +2786,7 @@ var Hn = class extends L {
|
|
|
2743
2786
|
let e = (this._sdf?.emissiveTriangleBuilder?.emissiveTriangles?.length ?? this._sdf?.emissiveTriangleCount ?? 0) > 0;
|
|
2744
2787
|
this.settings.set("enableEmissiveTriangleSampling", e, { reset: !1 });
|
|
2745
2788
|
}
|
|
2746
|
-
return n.start("Apply settings"), this.settings.applyAll(), this.stages.compositor.setTransparentBackground(this.settings.get("transparentBackground")), n.end("Apply settings"), n.print(this._sceneSummaryParts()),
|
|
2789
|
+
return n.start("Apply settings"), this.settings.applyAll(), this.stages.compositor.setTransparentBackground(this.settings.get("transparentBackground")), n.end("Apply settings"), n.print(this._sceneSummaryParts()), pe(), this._sceneRebuilt(), this.dispatchEvent({ type: _.SCENE_REBUILD }), !0;
|
|
2747
2790
|
}
|
|
2748
2791
|
_sceneSummaryParts() {
|
|
2749
2792
|
let e = this.stages.pathTracer, t = this._sdf?.instanceTable?.setCount ?? 0, n = this._sdf?.geometryExtractor?.maps?.length ?? 0;
|
|
@@ -2774,7 +2817,7 @@ var Hn = class extends L {
|
|
|
2774
2817
|
try {
|
|
2775
2818
|
let { root: r } = await this.assetLoader.appendModel(e, { cacheKey: n });
|
|
2776
2819
|
return r.userData.__rayzeeSceneObject = !0, r.userData.__rayzeeSourceUrl = e, n && (r.userData.__rayzeeCacheKey = n), t && (r.userData.__rayzeeName = t), await this._finishRebuildNoReframe({
|
|
2777
|
-
type:
|
|
2820
|
+
type: _.MODEL_ADDED,
|
|
2778
2821
|
url: e,
|
|
2779
2822
|
id: r.uuid
|
|
2780
2823
|
}), r.uuid;
|
|
@@ -2788,7 +2831,7 @@ var Hn = class extends L {
|
|
|
2788
2831
|
try {
|
|
2789
2832
|
let { root: n } = this.assetLoader.appendObject3D(e, t || "object3d");
|
|
2790
2833
|
return n.userData.__rayzeeSceneObject = !0, t && (n.userData.__rayzeeName = t), await this._finishRebuildNoReframe({
|
|
2791
|
-
type:
|
|
2834
|
+
type: _.MODEL_ADDED,
|
|
2792
2835
|
id: n.uuid
|
|
2793
2836
|
}), n.uuid;
|
|
2794
2837
|
} finally {
|
|
@@ -2805,7 +2848,7 @@ var Hn = class extends L {
|
|
|
2805
2848
|
this._loadingInProgress = !0;
|
|
2806
2849
|
try {
|
|
2807
2850
|
return this._releaseSceneState(), n === this.sceneModel ? this.assetLoader.releaseTargetModel() : this.assetLoader.removeModelRoot(n), await this._finishRebuildNoReframe({
|
|
2808
|
-
type:
|
|
2851
|
+
type: _.SCENE_OBJECT_REMOVED,
|
|
2809
2852
|
id: e
|
|
2810
2853
|
}), !0;
|
|
2811
2854
|
} finally {
|
|
@@ -2830,15 +2873,15 @@ var Hn = class extends L {
|
|
|
2830
2873
|
_sceneBudgets(e) {
|
|
2831
2874
|
return this._memorySpill === !1 || !this.storage ? e : {
|
|
2832
2875
|
maxTriangles: oe,
|
|
2833
|
-
maxPlacements:
|
|
2876
|
+
maxPlacements: he,
|
|
2834
2877
|
...e
|
|
2835
2878
|
};
|
|
2836
2879
|
}
|
|
2837
2880
|
_planSpill() {
|
|
2838
2881
|
let e = this._memorySpill !== !1 && !!this.storage && (this.assetLoader?.animations?.length ?? 0) === 0 && (this._memorySpill === !0 || this._sdf.needsSpill(this.meshScene));
|
|
2839
|
-
this.assetLoader && (this.assetLoader.maxEnvironmentWidth = e ?
|
|
2882
|
+
this.assetLoader && (this.assetLoader.maxEnvironmentWidth = e ? ue : 0);
|
|
2840
2883
|
let t = e ? this.meshScene?.environment : null, n = t?.image;
|
|
2841
|
-
return n &&
|
|
2884
|
+
return n && On(t, ue), 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;
|
|
2842
2885
|
}
|
|
2843
2886
|
_progressiveSpill() {
|
|
2844
2887
|
let e = this._spillPlan ?? this._planSpill();
|
|
@@ -2853,14 +2896,14 @@ var Hn = class extends L {
|
|
|
2853
2896
|
}
|
|
2854
2897
|
_maybeSpill() {
|
|
2855
2898
|
!this._sdf?.spilling || !this.storage || (this._sdf.spillAfterLoad().catch((e) => this._issues.warn(C.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`)), this._sdf.spillToDisk(this.storage).then((e) => e && this.dispatchEvent({
|
|
2856
|
-
type:
|
|
2899
|
+
type: _.SCENE_SPILLED,
|
|
2857
2900
|
...e
|
|
2858
2901
|
})).catch((e) => this._issues.warn(C.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`)));
|
|
2859
2902
|
}
|
|
2860
2903
|
_scheduleRespill() {
|
|
2861
2904
|
this._sdf?.spilling && (clearTimeout(this._respillTimer), this._respillTimer = setTimeout(() => {
|
|
2862
2905
|
this._respillTimer = null, this._sdf?.respill().catch((e) => this._issues.warn(C.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`));
|
|
2863
|
-
},
|
|
2906
|
+
}, Ln), this._respillTimer.unref?.());
|
|
2864
2907
|
}
|
|
2865
2908
|
async ensureSceneResident() {
|
|
2866
2909
|
this._sdf?.spilled && await this._sdf.ensureResident(), await this._sdf?.ensureGeometryResident();
|
|
@@ -2918,7 +2961,7 @@ var Hn = class extends L {
|
|
|
2918
2961
|
this.pauseRendering = e;
|
|
2919
2962
|
}
|
|
2920
2963
|
this.reset(), this.dispatchEvent({
|
|
2921
|
-
type:
|
|
2964
|
+
type: _.RESERVED_RENDER_SIZE_CHANGED,
|
|
2922
2965
|
size: l
|
|
2923
2966
|
});
|
|
2924
2967
|
}
|
|
@@ -2930,7 +2973,7 @@ var Hn = class extends L {
|
|
|
2930
2973
|
this._pendingReservedRenderSize = null;
|
|
2931
2974
|
let t = this.setReservedRenderResolution(e.requestedPx, { allowLower: e.allowLower });
|
|
2932
2975
|
this.dispatchEvent({
|
|
2933
|
-
type:
|
|
2976
|
+
type: _.RESERVED_RENDER_SIZE_CHANGED,
|
|
2934
2977
|
size: t
|
|
2935
2978
|
});
|
|
2936
2979
|
}
|
|
@@ -2952,7 +2995,7 @@ var Hn = class extends L {
|
|
|
2952
2995
|
}
|
|
2953
2996
|
_applyRenderResize(e, t) {
|
|
2954
2997
|
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({
|
|
2955
|
-
type:
|
|
2998
|
+
type: _.RESOLUTION_CHANGED,
|
|
2956
2999
|
width: e,
|
|
2957
3000
|
height: t
|
|
2958
3001
|
}));
|
|
@@ -3072,7 +3115,7 @@ var Hn = class extends L {
|
|
|
3072
3115
|
}
|
|
3073
3116
|
let l = this._completionInfo();
|
|
3074
3117
|
await this._finishImage(), this.completion.markComplete() && this.dispatchEvent({
|
|
3075
|
-
type:
|
|
3118
|
+
type: _.RENDER_COMPLETE,
|
|
3076
3119
|
...l
|
|
3077
3120
|
});
|
|
3078
3121
|
let u = t ? await this._finalDenoise() : !1, { reason: d, ...f } = l;
|
|
@@ -3092,8 +3135,8 @@ var Hn = class extends L {
|
|
|
3092
3135
|
getProvenance() {
|
|
3093
3136
|
let e = this.stages.pathTracer, t = this.color?.status();
|
|
3094
3137
|
return a({
|
|
3095
|
-
engine:
|
|
3096
|
-
three:
|
|
3138
|
+
engine: fe,
|
|
3139
|
+
three: St,
|
|
3097
3140
|
adapter: this.adapterInfo ?? null,
|
|
3098
3141
|
mode: {
|
|
3099
3142
|
headless: this._headless,
|
|
@@ -3135,7 +3178,7 @@ var Hn = class extends L {
|
|
|
3135
3178
|
let t = await e.captureAccumulation();
|
|
3136
3179
|
return {
|
|
3137
3180
|
v: 1,
|
|
3138
|
-
engine:
|
|
3181
|
+
engine: fe,
|
|
3139
3182
|
savedAt: Date.now(),
|
|
3140
3183
|
samples: t.state.frameCount,
|
|
3141
3184
|
...t
|
|
@@ -3146,7 +3189,7 @@ var Hn = class extends L {
|
|
|
3146
3189
|
let t = this.stages.pathTracer;
|
|
3147
3190
|
if (!t) throw Error("restoreRenderCheckpoint: app is not initialized");
|
|
3148
3191
|
t.restoreAccumulation(e), this.needsReset = !1, this.dispatchEvent({
|
|
3149
|
-
type:
|
|
3192
|
+
type: _.RENDER_RESET,
|
|
3150
3193
|
restored: e.samples
|
|
3151
3194
|
});
|
|
3152
3195
|
}
|
|
@@ -3176,6 +3219,7 @@ var Hn = class extends L {
|
|
|
3176
3219
|
width: a,
|
|
3177
3220
|
height: o,
|
|
3178
3221
|
colorSpace: e,
|
|
3222
|
+
displayColorSpace: this.color?.canvasColorSpace ?? "srgb",
|
|
3179
3223
|
source: r?.source ?? "accumulation",
|
|
3180
3224
|
toneMappedOn: d ? "gpu" : "cpu"
|
|
3181
3225
|
};
|
|
@@ -3212,7 +3256,7 @@ var Hn = class extends L {
|
|
|
3212
3256
|
let o = e ? this._readbackPass().draw(e, n, r).texture : t.textures[0], s = a.get(o).texture;
|
|
3213
3257
|
return s ? (this._readbackToneMapper ??= new ze(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");
|
|
3214
3258
|
} catch (e) {
|
|
3215
|
-
if (e instanceof
|
|
3259
|
+
if (e instanceof xe) throw e;
|
|
3216
3260
|
return this._toneMapFallback("the GPU pass threw", e);
|
|
3217
3261
|
} finally {
|
|
3218
3262
|
this._readbackToneMapper?.release(), e && this._textureReadback?.release();
|
|
@@ -3274,7 +3318,18 @@ var Hn = class extends L {
|
|
|
3274
3318
|
};
|
|
3275
3319
|
}
|
|
3276
3320
|
getCanvas() {
|
|
3277
|
-
return this.renderer?.domElement ? this._displayCanvas()
|
|
3321
|
+
return this.renderer?.domElement ? this._displayCanvas() ?? this._pictureCanvas() : null;
|
|
3322
|
+
}
|
|
3323
|
+
_pictureCanvas() {
|
|
3324
|
+
let e = this.renderer.domElement, t = this.stages.compositor, n = this.pipeline?.context;
|
|
3325
|
+
if (!t || !n || (t.renderPicture(n), !(this.renderer.backend?.parameters?.outputType === ct || t.showsCanvasTransform) || this._headless || typeof document > "u")) return e;
|
|
3326
|
+
let r = e.getContext("webgpu")?.getConfiguration?.()?.colorSpace ?? "srgb", i = this._pictureCopy;
|
|
3327
|
+
(!i || i.colorSpace !== r) && (i = this._pictureCopy = {
|
|
3328
|
+
canvas: document.createElement("canvas"),
|
|
3329
|
+
colorSpace: r
|
|
3330
|
+
}), (i.canvas.width !== e.width || i.canvas.height !== e.height) && (i.canvas.width = e.width, i.canvas.height = e.height);
|
|
3331
|
+
let a = i.canvas.getContext("2d", { colorSpace: r });
|
|
3332
|
+
return a.clearRect(0, 0, e.width, e.height), a.drawImage(e, 0, 0), t.render(n), i.canvas;
|
|
3278
3333
|
}
|
|
3279
3334
|
screenshot({ type: e = "image/png", quality: t } = {}) {
|
|
3280
3335
|
let n = this.getCanvas();
|
|
@@ -3335,7 +3390,7 @@ var Hn = class extends L {
|
|
|
3335
3390
|
...this._canvasResources()
|
|
3336
3391
|
]);
|
|
3337
3392
|
let t = () => e.measure();
|
|
3338
|
-
this._addTrackedListener(this,
|
|
3393
|
+
this._addTrackedListener(this, _.SCENE_REBUILD, t), this._addTrackedListener(this, _.ENVIRONMENT_LOADED, t), this._addTrackedListener(this, _.RESOLUTION_CHANGED, t), this._vramWired = !0;
|
|
3339
3394
|
}
|
|
3340
3395
|
_collectStageTextures() {
|
|
3341
3396
|
let e = [], t = this.stages || {}, n = t.pathTracer;
|
|
@@ -3350,7 +3405,7 @@ var Hn = class extends L {
|
|
|
3350
3405
|
}
|
|
3351
3406
|
getSceneMinY() {
|
|
3352
3407
|
if (!this.meshScene) return 0;
|
|
3353
|
-
let e = new
|
|
3408
|
+
let e = new $e().setFromObject(this.meshScene);
|
|
3354
3409
|
return Number.isFinite(e.min.y) ? e.min.y : 0;
|
|
3355
3410
|
}
|
|
3356
3411
|
getMaterialProperty(e, t) {
|
|
@@ -3360,7 +3415,7 @@ var Hn = class extends L {
|
|
|
3360
3415
|
return this.stages.pathTracer?.materialData.getMaterialPropertySource(e, t);
|
|
3361
3416
|
}
|
|
3362
3417
|
setMaterialProperty(e, t, n) {
|
|
3363
|
-
if (this._sdf?.spilled &&
|
|
3418
|
+
if (this._sdf?.spilled && m.has(t)) {
|
|
3364
3419
|
this.ensureSceneResident().then(() => this.setMaterialProperty(e, t, n));
|
|
3365
3420
|
return;
|
|
3366
3421
|
}
|
|
@@ -3439,20 +3494,24 @@ var Hn = class extends L {
|
|
|
3439
3494
|
n.__rayzeeOriginalColorSpace === void 0 && (n.__rayzeeOriginalColorSpace = e.colorSpace);
|
|
3440
3495
|
let r = n.__rayzeeOriginalColorSpace;
|
|
3441
3496
|
if (delete n.ocioColorSpace, delete n.__rayzeeColorSpaceChoice, t == null) e.colorSpace = r, delete n.__rayzeeOriginalColorSpace;
|
|
3442
|
-
else if (t === "srgb" || t === "linear") e.colorSpace = t === "srgb" ?
|
|
3497
|
+
else if (t === "srgb" || t === "linear") e.colorSpace = t === "srgb" ? M : Be, n.__rayzeeColorSpaceChoice = t;
|
|
3443
3498
|
else {
|
|
3444
3499
|
if (!this.color?.hasConfig) throw Error(`"${t}" needs a colour config loaded`);
|
|
3445
|
-
n.ocioColorSpace = t, e.colorSpace =
|
|
3500
|
+
n.ocioColorSpace = t, e.colorSpace = M;
|
|
3446
3501
|
}
|
|
3447
3502
|
e.needsUpdate = !0, this.stages.pathTracer?.sdfs && await this.rebuildMaterials();
|
|
3448
3503
|
}
|
|
3449
3504
|
setColorManagement(e) {
|
|
3450
|
-
this.color?.dispose(), this.color = new e({ issues: this._issues }),
|
|
3505
|
+
this.color?.dispose(), this.color = new e({ issues: this._issues }), Te(this.color), this.color.on?.("canvas", () => this._applyCanvasTransform()), this.renderer && this.color.attachRenderer(this.renderer);
|
|
3506
|
+
}
|
|
3507
|
+
_applyCanvasTransform() {
|
|
3508
|
+
let e = this.stages?.compositor;
|
|
3509
|
+
e && (e.setCanvasTransform(this.color?.canvasTransform ?? null), e.showsCanvasTransform || (this._pictureCopy = null), this.animationManagerId ? this._needsDisplayRefresh = !0 : this.pipeline?.context && !this._deviceLost && e.render(this.pipeline.context));
|
|
3451
3510
|
}
|
|
3452
3511
|
async loadColorConfig(e = {}) {
|
|
3453
3512
|
await this._leaveColorWorkingSpace();
|
|
3454
|
-
let t =
|
|
3455
|
-
return this.color.workingSpaceAdopted && await this.applyColorWorkingSpace(), (!(t?.source === "ocio" &&
|
|
3513
|
+
let t = E(this.renderer?.toneMapping), n = await this.color.loadConfig(e);
|
|
3514
|
+
return this.color.workingSpaceAdopted && await this.applyColorWorkingSpace(), (!(t?.source === "ocio" && E(this.renderer?.toneMapping) === t) || this.color.workingSpaceAdopted) && this.reset(), n;
|
|
3456
3515
|
}
|
|
3457
3516
|
async unloadColorConfig() {
|
|
3458
3517
|
await this._leaveColorWorkingSpace(), this.color.unloadConfig(), this.reset();
|
|
@@ -3472,17 +3531,17 @@ var Hn = class extends L {
|
|
|
3472
3531
|
async rebuildMaterials(e) {
|
|
3473
3532
|
await this.ensureSceneResident();
|
|
3474
3533
|
let t = this.stages.pathTracer;
|
|
3475
|
-
await t?.rebuildMaterials(e || this.meshScene), t?.triangleStorageNode?.withoutUV && this._sdf?.triangles &&
|
|
3534
|
+
await t?.rebuildMaterials(e || this.meshScene), t?.triangleStorageNode?.withoutUV && this._sdf?.triangles && ne(e || this.meshScene) && (this._sdf.textureCoordinates = !0, t.setTriangleData(this._sdf.triangles, this._sdf.triangleCount, { textureCoordinates: !0 }), t.setupMaterial()), this.reset();
|
|
3476
3535
|
}
|
|
3477
3536
|
async _initRenderer() {
|
|
3478
|
-
|
|
3537
|
+
le((e) => this.dispatchEvent(e)), (typeof navigator > "u" || !navigator.gpu) && this._issues.fail(C.WEBGPU_UNAVAILABLE, "WebGPU is not available — outside a browser, install one as navigator.gpu (for Node, the `webgpu` package)");
|
|
3479
3538
|
let e = null, t;
|
|
3480
3539
|
try {
|
|
3481
3540
|
e = await navigator.gpu.requestAdapter({ powerPreference: "high-performance" });
|
|
3482
3541
|
} catch (e) {
|
|
3483
3542
|
t = e;
|
|
3484
3543
|
}
|
|
3485
|
-
e || this._issues.fail(C.ADAPTER_UNAVAILABLE, `no WebGPU adapter${t ? ": " + t.message : ""}`, {}, t), this.adapterInfo =
|
|
3544
|
+
e || this._issues.fail(C.ADAPTER_UNAVAILABLE, `no WebGPU adapter${t ? ": " + t.message : ""}`, {}, t), this.adapterInfo = Gn(e), this.adapterInfo.isSoftware && (this._issues.warn(C.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}`));
|
|
3486
3545
|
let n = e.limits, r = { maxColorAttachmentBytesPerSample: 128 };
|
|
3487
3546
|
for (let e of [
|
|
3488
3547
|
"maxBufferSize",
|
|
@@ -3504,32 +3563,32 @@ var Hn = class extends L {
|
|
|
3504
3563
|
let i;
|
|
3505
3564
|
try {
|
|
3506
3565
|
i = await e.requestDevice({
|
|
3507
|
-
requiredFeatures:
|
|
3566
|
+
requiredFeatures: Un.filter((t) => e.features.has(t)),
|
|
3508
3567
|
requiredLimits: r
|
|
3509
3568
|
});
|
|
3510
3569
|
} catch (e) {
|
|
3511
3570
|
this._issues.fail(C.DEVICE_UNAVAILABLE, `WebGPU device request failed: ${e.message}`, { adapter: { ...this.adapterInfo } }, e);
|
|
3512
3571
|
}
|
|
3513
|
-
this.renderer = new
|
|
3572
|
+
this.renderer = new Ue({
|
|
3514
3573
|
canvas: this.canvas,
|
|
3515
3574
|
alpha: !0,
|
|
3516
3575
|
device: i
|
|
3517
3576
|
});
|
|
3518
3577
|
try {
|
|
3519
|
-
await
|
|
3578
|
+
await Bn(this.renderer, this._headless);
|
|
3520
3579
|
} catch (e) {
|
|
3521
3580
|
throw i.destroy(), e;
|
|
3522
3581
|
}
|
|
3523
|
-
this.renderer.backend?.isWebGPUBackend || (i.destroy(), this._issues.fail(C.WEBGPU_UNAVAILABLE, "three.js fell back to WebGL2, which cannot run the path tracer's compute kernels. Check GPU process flags and driver support.")), this._gpuDevice = i, i.lost && (this._deviceLostHolder = { app: this },
|
|
3582
|
+
this.renderer.backend?.isWebGPUBackend || (i.destroy(), this._issues.fail(C.WEBGPU_UNAVAILABLE, "three.js fell back to WebGL2, which cannot run the path tracer's compute kernels. Check GPU process flags and driver support.")), this._gpuDevice = i, i.lost && (this._deviceLostHolder = { app: this }, Hn(i, this._deviceLostHolder), i.onuncapturederror = (e) => $.error("WebGPU uncaptured error:", e.error)), Ve.setLTC(kt.init()), this.renderer.outputColorSpace = M, this.renderer.toneMapping = Me, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1), this.color.attachRenderer(this.renderer);
|
|
3524
3583
|
}
|
|
3525
3584
|
_initScenes() {
|
|
3526
|
-
this.scene = new
|
|
3585
|
+
this.scene = new wt(), this.meshScene = new wt(), this._sceneHelpers = new Ft();
|
|
3527
3586
|
}
|
|
3528
3587
|
_initAssetPipeline() {
|
|
3529
3588
|
this._sdf = new u({
|
|
3530
3589
|
issues: this._issues,
|
|
3531
3590
|
...this._maxSceneBytes === void 0 ? {} : { maxSceneBytes: this._maxSceneBytes }
|
|
3532
|
-
}), this.assetLoader = new
|
|
3591
|
+
}), this.assetLoader = new Dn(this.meshScene, this.camera, null, {
|
|
3533
3592
|
issues: this._issues,
|
|
3534
3593
|
areaLightIntensityScale: () => this.settings.get("areaLightIntensityScale")
|
|
3535
3594
|
}), this.assetLoader.setRenderer(this.renderer), this.assetLoader.createFloorPlane();
|
|
@@ -3537,14 +3596,14 @@ var Hn = class extends L {
|
|
|
3537
3596
|
_initPipeline() {
|
|
3538
3597
|
this._createStages();
|
|
3539
3598
|
let { clientWidth: e, clientHeight: t } = this.canvas;
|
|
3540
|
-
this.pipeline = new
|
|
3599
|
+
this.pipeline = new Yt(this.renderer, e || 1, t || 1, { issues: this._issues }), this.pipeline.addStage(this.stages.pathTracer);
|
|
3541
3600
|
for (let e of this._extraStages) this.pipeline.addStage(e);
|
|
3542
3601
|
this.pipeline.addStage(this.stages.compositor);
|
|
3543
3602
|
let n = this.canvas.clientWidth || 1, r = this.canvas.clientHeight || 1;
|
|
3544
3603
|
this._displayWidth = n, this._displayHeight = r, this._renderWidth = n, this._renderHeight = r, this.pipeline.setSize(n, r);
|
|
3545
3604
|
}
|
|
3546
3605
|
async _initManagers() {
|
|
3547
|
-
this.lightManager = new
|
|
3606
|
+
this.lightManager = new Fn(this.scene, this._sceneHelpers, this.stages.pathTracer, {
|
|
3548
3607
|
onReset: () => this.reset(),
|
|
3549
3608
|
onLightRemoved: (e) => this._lightRemoved(e)
|
|
3550
3609
|
}), 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();
|
|
@@ -3555,12 +3614,12 @@ var Hn = class extends L {
|
|
|
3555
3614
|
if (e.model) this._clearAppendedModels(), await this.loadSceneData({ pendingEnvironment: this._beginSceneMetadataEnvironment() }) && this.assetLoader?.commitPendingGraph(e.model);
|
|
3556
3615
|
else if (e.texture) {
|
|
3557
3616
|
let e = this.meshScene.environment;
|
|
3558
|
-
e && this.stages.pathTracer && await this.stages.pathTracer.environment.setEnvironmentMap(e),
|
|
3617
|
+
e && this.stages.pathTracer && await this.stages.pathTracer.environment.setEnvironmentMap(e), pe();
|
|
3559
3618
|
}
|
|
3560
3619
|
this.pauseRendering = !1, this.reset();
|
|
3561
3620
|
}
|
|
3562
3621
|
}, this._addTrackedListener(this.assetLoader, "load", this._onAssetLoaded), this.pipeline.eventBus.on("pathtracer:compiling", ({ compiling: e }) => this.dispatchEvent({
|
|
3563
|
-
type:
|
|
3622
|
+
type: _.SHADERS_COMPILING,
|
|
3564
3623
|
compiling: e
|
|
3565
3624
|
}));
|
|
3566
3625
|
}
|
|
@@ -3568,23 +3627,24 @@ var Hn = class extends L {
|
|
|
3568
3627
|
this.stages.pathTracer = new d(this.renderer, this.scene, this.camera, {
|
|
3569
3628
|
hostMemoryGB: this._hostMemoryGB,
|
|
3570
3629
|
sortMaterials: this.settings.get("wavefrontSortMaterials")
|
|
3571
|
-
}), this._extraStages = this._createExtraStages(), this.stages.compositor = new
|
|
3572
|
-
saturation: this.settings.get("saturation") ??
|
|
3630
|
+
}), this._extraStages = this._createExtraStages(), this.stages.compositor = new It(this.renderer, {
|
|
3631
|
+
saturation: this.settings.get("saturation") ?? v.saturation,
|
|
3573
3632
|
pathTracer: this.stages.pathTracer,
|
|
3574
|
-
displaySources: this._displaySources()
|
|
3633
|
+
displaySources: this._displaySources(),
|
|
3634
|
+
canvasTransform: this.color?.canvasTransform ?? null
|
|
3575
3635
|
});
|
|
3576
3636
|
}
|
|
3577
3637
|
_reconcileCompletion() {
|
|
3578
3638
|
let e = this.stages.pathTracer;
|
|
3579
3639
|
if (!e) return;
|
|
3580
3640
|
let t = this.completion.isLimitReached(e, this.settings.get("renderLimitMode"), this.settings.get("renderTimeLimit"));
|
|
3581
|
-
t && !e.isComplete ? e.isComplete = !0 : !t && e.isComplete && (e.isComplete = !1, this.completion.resumeFromPause(), this._completionReopened(), this.dispatchEvent({ type:
|
|
3641
|
+
t && !e.isComplete ? e.isComplete = !0 : !t && e.isComplete && (e.isComplete = !1, this.completion.resumeFromPause(), this._completionReopened(), this.dispatchEvent({ type: _.RENDER_RESET }), this.wake());
|
|
3582
3642
|
}
|
|
3583
3643
|
_forwardEvents(e, t) {
|
|
3584
3644
|
if (e) for (let n of t) this._addTrackedListener(e, n, (e) => this.dispatchEvent(e));
|
|
3585
3645
|
}
|
|
3586
3646
|
_createCamera() {
|
|
3587
|
-
let e = new
|
|
3647
|
+
let e = new Mn(60, this.canvas.clientWidth / this.canvas.clientHeight || 1, .01, 1e3);
|
|
3588
3648
|
return e.position.set(0, 0, 5), e;
|
|
3589
3649
|
}
|
|
3590
3650
|
_createExtraStages() {
|
|
@@ -3654,4 +3714,4 @@ var Hn = class extends L {
|
|
|
3654
3714
|
_disposeExtensions() {}
|
|
3655
3715
|
};
|
|
3656
3716
|
//#endregion
|
|
3657
|
-
export {
|
|
3717
|
+
export { Lt as _, ln as a, J as c, q as d, on as f, Ht as g, Ut as h, Mn as i, sn as l, Wt as m, Gn as n, Y as o, Yt as p, Fn as r, G as s, Kn as t, an as u };
|