rayzee 11.7.0 → 11.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -6
- package/dist/{ArchiveImporter-DYcRXeKE.js → ArchiveImporter-BJxszU_k.js} +2353 -1356
- package/dist/{BidirectionalIntegrator-BvjRpbTP.js → BidirectionalIntegrator-DWg66vAd.js} +302 -301
- package/dist/{BufferLayout-xPRH9jYD.js → BufferLayout-Bzgccg1o.js} +1 -0
- package/dist/{ColorManagement-oeEk7oSu.js → ColorManagement-B_HjAiy2.js} +1 -1
- package/dist/{EngineIssues-CIZnXHsF.js → EngineIssues-CfJiBaNj.js} +19 -8
- package/dist/{NeuralRetouch-ClaMiKYg.js → NeuralRetouch-BD9E-Yht.js} +2 -2
- package/dist/{NeuralSuperRes-WNEXun9s.js → NeuralSuperRes-C8Mf3tJX.js} +2 -2
- package/dist/{PathTracer-B9wZPPVL.js → PathTracer-DeE9UJ1n.js} +3530 -3402
- package/dist/{PhysicalSky-DcjItqKi.js → PhysicalSky-cKy75-oR.js} +45 -45
- package/dist/{RayzeeRenderer-p-NeE6E2.js → RayzeeRenderer-CzLyBA3G.js} +378 -374
- package/dist/SceneMetadata-C17UfOEp.js +183 -0
- package/dist/{SolarLimb-bZE6y63S.js → SolarLimb-DRYy8tln.js} +184 -172
- package/dist/{ToneMapGPU-sAs8wdgI.js → ToneMapGPU-4GPwoG_c.js} +13 -6
- package/dist/addons/archives.es.js +1 -1
- package/dist/addons/bidirectional.es.js +1 -1
- package/dist/addons/color.es.js +1 -1
- package/dist/addons/physical-sky.es.js +1 -1
- package/dist/addons/storage.es.js +1 -1
- package/dist/{openStorage-Fe9BoS1_.js → openStorage-CdyVjmps.js} +1 -1
- package/dist/rayzee-core.es.js +7 -7
- package/dist/rayzee.es.js +821 -794
- package/dist/rayzee.umd.js +112 -103
- package/dist/{sceneCachePolicy-B9w3BnaP.js → sceneCachePolicy-ywbGKHD3.js} +9 -6
- package/package.json +1 -1
- package/src/EngineDefaults.js +1 -0
- package/src/EngineIssues.js +21 -6
- package/src/Passes/AIUpscaler.js +4 -0
- package/src/Passes/OIDNDenoiser.js +8 -6
- package/src/Passes/OIDNTemporalHistory.js +1 -1
- package/src/PathTracerApp.js +10 -1
- package/src/Processor/ArchiveImporter.js +106 -27
- package/src/Processor/AssetLoader.js +22 -0
- package/src/Processor/BufferLayout.js +3 -3
- package/src/Processor/GeometryExtractor.js +12 -4
- package/src/Processor/LightSerializer.js +6 -2
- package/src/Processor/MaterialPacking.js +2 -2
- package/src/Processor/PBRT/PBRTMaterials.js +49 -13
- package/src/Processor/PBRT/PBRTParser.js +144 -22
- package/src/Processor/PBRT/PBRTSceneBuilder.js +287 -67
- package/src/Processor/PBRT/PBRTTextureBake.js +191 -9
- package/src/Processor/PBRT/index.js +19 -4
- package/src/Processor/PlatformImageLoader.js +9 -0
- package/src/Processor/SceneProcessor.js +42 -26
- package/src/Processor/TextureCreator.js +44 -4
- package/src/Processor/ToneMapCPU.js +34 -5
- package/src/Processor/ToneMapGPU.js +15 -9
- package/src/Processor/USD/USDScene.js +981 -17
- package/src/RayzeeRenderer.js +85 -28
- package/src/Stages/AutoExposure.js +21 -8
- package/src/Stages/Compositor.js +39 -1
- package/src/Stages/DenoiserSettings.js +0 -4
- package/src/Stages/LocalExposure.js +44 -18
- package/src/Stages/NRD.js +53 -24
- package/src/Stages/NormalDepth.js +12 -6
- package/src/Stages/PathTracer.js +27 -1
- package/src/Stages/PathTracerStage.js +14 -2
- package/src/Storage/SceneGraphCodec.js +6 -3
- package/src/TSL/BVHTraversal.js +33 -20
- package/src/TSL/CameraRay.js +12 -1
- package/src/TSL/Common.js +25 -8
- package/src/TSL/DebugKernel.js +3 -2
- package/src/TSL/Displacement.js +66 -113
- package/src/TSL/FinalWriteKernel.js +4 -7
- package/src/TSL/GenerateKernel.js +6 -2
- package/src/TSL/LightSplatKernel.js +7 -4
- package/src/TSL/LightsCore.js +6 -2
- package/src/TSL/LightsDirect.js +33 -11
- package/src/TSL/LightsSampling.js +45 -12
- package/src/TSL/SceneResources.js +19 -0
- package/src/TSL/ShadeKernel.js +3 -4
- package/src/TSL/Struct.js +1 -0
- package/src/integrators/BidirectionalIntegrator.js +1 -0
- package/src/managers/CameraManager.js +9 -0
- package/src/managers/DenoisingManager.js +1 -0
- package/src/managers/InteractionManager.js +6 -0
- package/src/managers/MaterialDataManager.js +11 -0
- package/src/managers/UniformManager.js +3 -1
- package/dist/SceneMetadata-D2Sh-0e-.js +0 -110
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { dt as e } from "./SolarLimb-
|
|
2
|
-
import {
|
|
1
|
+
import { dt as e } from "./SolarLimb-DRYy8tln.js";
|
|
2
|
+
import { Mt as t, Nt as n, Ot as r, bt as i, dt as a, ft as o, i as s, jt as c, kt as l, lt as u, n as d, r as f, ut as p, vt as ee, xt as m } from "./PathTracer-DeE9UJ1n.js";
|
|
3
3
|
import { n as h, t as g } from "./EngineEvents-CLckhYbL.js";
|
|
4
|
-
import { $ as
|
|
4
|
+
import { $ as te, C as ne, G as _, M as re, Q as ie, T as v, W as ae, at as y, d as oe, et as se, f as ce, l as le, nt as b, ot as ue, r as de, rt as fe, tt as pe, u as me, v as he, x as ge } from "./sceneCachePolicy-ywbGKHD3.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 w, r as
|
|
11
|
-
import { n as E, r as
|
|
12
|
-
import { d as
|
|
13
|
-
import { i as O, n as
|
|
14
|
-
import {
|
|
15
|
-
import { t as
|
|
16
|
-
import { LinearSRGBColorSpace as
|
|
17
|
-
import { Fn as
|
|
18
|
-
import { Box3 as
|
|
19
|
-
import { RectAreaLightTexturesLib as
|
|
20
|
-
import { RectAreaLightHelper as
|
|
21
|
-
import { GLTFLoader as
|
|
22
|
-
import { HDRLoader as
|
|
23
|
-
import { createMeshesFromMultiMaterialMesh as
|
|
24
|
-
import { clone as
|
|
6
|
+
import { f as _e, r as ve } from "./BufferLayout-Bzgccg1o.js";
|
|
7
|
+
import { i as ye, n as C, t as be } from "./EngineIssues-CfJiBaNj.js";
|
|
8
|
+
import { n as xe, r as Se } from "./shared-BGBcSxBQ.js";
|
|
9
|
+
import { a as Ce } from "./WorkingMatrix-C6y233hT.js";
|
|
10
|
+
import { i as w, r as we, t as T } from "./ActiveColor-YvuQq44O.js";
|
|
11
|
+
import { n as E, r as Te } from "./AssetConfig-DSEntE65.js";
|
|
12
|
+
import { d as Ee, l as De, m as Oe, p as ke, t as Ae, u as D } from "./ViewTransforms-CYN7bq2w.js";
|
|
13
|
+
import { i as O, n as je, r as Me } from "./identity-C1cLD1C0.js";
|
|
14
|
+
import { c as Ne, i as Pe, l as Fe, o as Ie, r as Le, t as Re } from "./SceneMetadata-C17UfOEp.js";
|
|
15
|
+
import { t as ze } from "./ToneMapGPU-4GPwoG_c.js";
|
|
16
|
+
import { LinearSRGBColorSpace as Be, MeshBasicNodeMaterial as Ve, QuadMesh as He, RectAreaLightNode as Ue, SRGBColorSpace as We, TextureNode as Ge, WebGPURenderer as Ke } from "three/webgpu";
|
|
17
|
+
import { Fn as qe, If as Je, cubeTexture as Ye, dot as Xe, float as k, int as A, mix as j, screenUV as Ze, select as M, storage as Qe, texture as $e, uint as et, uniform as N, uv as P, vec3 as F, vec4 as tt } from "three/tsl";
|
|
18
|
+
import { Box3 as nt, BufferGeometry as rt, CircleGeometry as it, Color as I, DirectionalLight as at, DirectionalLightHelper as ot, EquirectangularReflectionMapping as st, EventDispatcher as L, FloatType as ct, LinearFilter as lt, LinearSRGBColorSpace as ut, LoaderUtils as dt, LoadingManager as ft, MathUtils as R, Mesh as pt, MeshPhysicalMaterial as mt, NoBlending as ht, NoToneMapping as gt, Object3D as z, OrthographicCamera as _t, PerspectiveCamera as vt, PointLight as yt, PointLightHelper as bt, REVISION as xt, RectAreaLight as B, SRGBColorSpace as V, Scene as H, SpotLight as St, SpotLightHelper as Ct, TextureLoader as wt, Vector2 as Tt, Vector3 as U } from "three";
|
|
19
|
+
import { RectAreaLightTexturesLib as Et } from "three/addons/lights/RectAreaLightTexturesLib.js";
|
|
20
|
+
import { RectAreaLightHelper as Dt } from "three/addons/helpers/RectAreaLightHelper.js";
|
|
21
|
+
import { GLTFLoader as Ot } from "three/addons/loaders/GLTFLoader.js";
|
|
22
|
+
import { HDRLoader as kt } from "three/addons/loaders/HDRLoader.js";
|
|
23
|
+
import { createMeshesFromMultiMaterialMesh as At } from "three/addons/utils/SceneUtils.js";
|
|
24
|
+
import { clone as jt } from "three/addons/utils/SkeletonUtils.js";
|
|
25
25
|
//#region src/SceneHelpers.js
|
|
26
|
-
var
|
|
26
|
+
var Mt = class {
|
|
27
27
|
constructor() {
|
|
28
|
-
this.scene = new
|
|
28
|
+
this.scene = new H(), 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,22 +63,31 @@ var jt = class {
|
|
|
63
63
|
this.clear();
|
|
64
64
|
}
|
|
65
65
|
_createHelper(e) {
|
|
66
|
-
return e.isRectAreaLight ? new
|
|
66
|
+
return e.isRectAreaLight ? new Dt(e) : e.isPointLight ? new bt(e, .5) : e.isSpotLight ? new Ct(e) : e.isDirectionalLight ? new ot(e, .5) : null;
|
|
67
67
|
}
|
|
68
|
-
},
|
|
68
|
+
}, Nt = class extends t {
|
|
69
69
|
constructor(e, t = {}) {
|
|
70
70
|
super("Compositor", {
|
|
71
71
|
...t,
|
|
72
|
-
executionMode:
|
|
73
|
-
}), this.renderer = e, this._lightSources = [...t.displaySources ?? [], "pathtracer:color"], this.saturation = N(t.saturation ?? 1), this._transparentBackground = N(0, "int"), this._pathTracer = t.pathTracer ?? null, this._convergenceOverlay = !1, this._debugMaterial = null, this._debugQuad = null, this._debugTexNode = null, this._debugM2Attr = null, this._debugMaskAttr = null, this._debugExposureComp = N(1), this._sourceTexNode = new
|
|
72
|
+
executionMode: n.ALWAYS
|
|
73
|
+
}), this.renderer = e, this._lightSources = [...t.displaySources ?? [], "pathtracer:color"], this.saturation = N(t.saturation ?? 1), this._transparentBackground = N(0, "int"), this._pathTracer = t.pathTracer ?? null, this._convergenceOverlay = !1, this._debugMaterial = null, this._debugQuad = null, this._debugTexNode = null, this._debugM2Attr = null, this._debugMaskAttr = null, this._debugExposureComp = N(1), this._sourceTexNode = new Ge(), this._displayGain = null, this._backdropExposure = null, this._holdBackdrop = N(0, "int"), this._backdropGain = N(1), this.compositorMaterial = new Ve(), this.compositorMaterial.blending = ht, this._buildColorNode(), this.compositorQuad = new He(this.compositorMaterial);
|
|
74
74
|
}
|
|
75
75
|
_buildColorNode() {
|
|
76
|
-
let t = this._sourceTexNode.sample(P()), n = this._displayGain ?
|
|
77
|
-
this.
|
|
76
|
+
let t = this._sourceTexNode.sample(P()), n = this._displayGain ? this._displayGain(t.xyz, Ze) : null;
|
|
77
|
+
if (this._backdropExposure !== null) {
|
|
78
|
+
let e = n ?? k(1), r = e.add(this._backdropGain.sub(e).mul(t.w.clamp(0, 1).oneMinus()));
|
|
79
|
+
n = M(this._holdBackdrop.greaterThan(A(0)), r, e);
|
|
80
|
+
}
|
|
81
|
+
let r = n ? t.xyz.mul(n) : t.xyz, i = j(F(Xe(r, e)), r, this.saturation), a = M(this._transparentBackground, t.w, 1);
|
|
82
|
+
this.compositorMaterial.colorNode = tt(i, a), this.compositorMaterial.needsUpdate = !0;
|
|
78
83
|
}
|
|
79
84
|
setDisplayGain(e) {
|
|
80
85
|
e !== this._displayGain && (this._displayGain = e, this._buildColorNode());
|
|
81
86
|
}
|
|
87
|
+
setBackdropExposure(e) {
|
|
88
|
+
let t = e === null != (this._backdropExposure === null);
|
|
89
|
+
this._backdropExposure = e, t && this._buildColorNode();
|
|
90
|
+
}
|
|
82
91
|
resolveLightTexture(e) {
|
|
83
92
|
return this.resolveLightSource(e)?.texture ?? null;
|
|
84
93
|
}
|
|
@@ -96,17 +105,17 @@ var jt = class {
|
|
|
96
105
|
let t = this._pathTracer?.getConvergenceDebugSource?.();
|
|
97
106
|
if (!t) return !1;
|
|
98
107
|
if (this._debugMaterial && this._debugM2Attr === t.m2 && this._debugMaskAttr === t.frozenMask) return !0;
|
|
99
|
-
this._debugMaterial?.dispose(), this._debugTexNode?.dispose(), this._debugM2Attr = t.m2, this._debugMaskAttr = t.frozenMask, this._debugTexNode = new
|
|
100
|
-
let n =
|
|
101
|
-
let n =
|
|
102
|
-
return
|
|
103
|
-
let e = j(F(1, .8, .1), F(1, .1, .05),
|
|
104
|
-
|
|
105
|
-
}),
|
|
106
|
-
|
|
107
|
-
}),
|
|
108
|
+
this._debugMaterial?.dispose(), this._debugTexNode?.dispose(), this._debugM2Attr = t.m2, this._debugMaskAttr = t.frozenMask, this._debugTexNode = new Ge();
|
|
109
|
+
let n = qe(() => {
|
|
110
|
+
let n = Xe(this._debugTexNode.sample(P()).toVar().xyz, e).toVar(), r = t.renderWidth, i = t.renderHeight, a = A(P().x.mul(k(r))).min(r.sub(A(1))).max(A(0)), o = et(A(P().y.mul(k(i))).min(i.sub(A(1))).max(A(0)).mul(r).add(a)).toVar(), s = Qe(t.m2, "float").toReadOnly().element(o).toVar(), c = Qe(t.frozenMask, "uint").toReadOnly().element(o).toVar(), l = s.sub(n.mul(n)).max(k(0)).div(k(t.frame).add(1)).sqrt().toVar(), u = t.usePixelFreeze.greaterThan(A(0)), d = M(n.lessThan(k(1)), n.sqrt(), n).toVar(), f = M(u, l.div(n.add(k(1e-4))), l.div(d.add(k(1e-4)))).toVar(), p = M(u, t.pixelFreezeThreshold, t.noiseThreshold).toVar(), ee = f.div(p.max(k(1e-6))).toVar(), m = F(n.div(n.add(k(1))).sqrt().mul(.55)).toVar(), h = m.toVar(), g = k(t.frame).greaterThanEqual(k(t.adaptiveMinSamples));
|
|
111
|
+
return Je(ee.greaterThanEqual(k(1)).or(g.not()), () => {
|
|
112
|
+
let e = j(F(1, .8, .1), F(1, .1, .05), ee.sub(1).div(3).clamp(0, 1));
|
|
113
|
+
h.assign(j(m, e, .85));
|
|
114
|
+
}), Je(c.equal(et(1)).and(u), () => {
|
|
115
|
+
h.assign(j(m, F(.1, .45, 1), .55));
|
|
116
|
+
}), h;
|
|
108
117
|
});
|
|
109
|
-
return this._debugMaterial = new
|
|
118
|
+
return this._debugMaterial = new Ve(), this._debugMaterial.colorNode = tt(n().pow(2.2).mul(this._debugExposureComp), 1), this._debugMaterial.blending = ht, this._debugQuad = new He(this._debugMaterial), !0;
|
|
110
119
|
}
|
|
111
120
|
render(e) {
|
|
112
121
|
if (!this.enabled) return;
|
|
@@ -114,13 +123,19 @@ var jt = class {
|
|
|
114
123
|
let t = e.getTexture("pathtracer:color");
|
|
115
124
|
if (t) {
|
|
116
125
|
this._debugTexNode.value = t;
|
|
117
|
-
let e = this.renderer.toneMapping !==
|
|
126
|
+
let e = this.renderer.toneMapping !== gt;
|
|
118
127
|
this._debugExposureComp.value = e ? 1 / Math.max(this.renderer.toneMappingExposure, 1e-4) : 1, this.renderer.setRenderTarget(null), this._debugQuad.render(this.renderer);
|
|
119
128
|
return;
|
|
120
129
|
}
|
|
121
130
|
}
|
|
122
131
|
let t = this.resolveLightTexture(e);
|
|
123
|
-
|
|
132
|
+
if (t) {
|
|
133
|
+
if (this._backdropExposure !== null) {
|
|
134
|
+
let t = e.getState("pathtracer:backdrop") === "color";
|
|
135
|
+
this._holdBackdrop.value = +!!t, t && (this._backdropGain.value = a(this._backdropExposure, this.renderer.toneMappingExposure, this.renderer.toneMapping));
|
|
136
|
+
}
|
|
137
|
+
this._sourceTexNode.value = t, this.renderer.setRenderTarget(null), this.compositorQuad.render(this.renderer);
|
|
138
|
+
}
|
|
124
139
|
}
|
|
125
140
|
setConvergenceOverlay(e) {
|
|
126
141
|
this._convergenceOverlay = !!e;
|
|
@@ -134,7 +149,7 @@ var jt = class {
|
|
|
134
149
|
dispose() {
|
|
135
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;
|
|
136
151
|
}
|
|
137
|
-
},
|
|
152
|
+
}, Pt = class {
|
|
138
153
|
constructor() {
|
|
139
154
|
this.textures = /* @__PURE__ */ new Map(), this.renderTargets = /* @__PURE__ */ new Map(), this.uniforms = /* @__PURE__ */ new Map(), this.state = {
|
|
140
155
|
frame: 0,
|
|
@@ -253,7 +268,7 @@ var jt = class {
|
|
|
253
268
|
dispose() {
|
|
254
269
|
this.textures.clear(), this.renderTargets.clear(), this.uniforms.clear(), this._stateChangeCallbacks.clear(), this.state = {};
|
|
255
270
|
}
|
|
256
|
-
},
|
|
271
|
+
}, Ft = class extends L {
|
|
257
272
|
constructor() {
|
|
258
273
|
super(), this._onceCallbacks = /* @__PURE__ */ new Map();
|
|
259
274
|
}
|
|
@@ -291,15 +306,15 @@ var jt = class {
|
|
|
291
306
|
eventNames() {
|
|
292
307
|
return this._listeners ? Object.keys(this._listeners) : [];
|
|
293
308
|
}
|
|
294
|
-
},
|
|
309
|
+
}, It = !1, W = [], Lt = /* @__PURE__ */ new WeakMap();
|
|
295
310
|
function Rt(e) {
|
|
296
|
-
|
|
311
|
+
It = !!e;
|
|
297
312
|
}
|
|
298
313
|
function zt() {
|
|
299
|
-
return
|
|
314
|
+
return W.slice();
|
|
300
315
|
}
|
|
301
316
|
function Bt() {
|
|
302
|
-
|
|
317
|
+
W.length = 0;
|
|
303
318
|
}
|
|
304
319
|
function Vt(e) {
|
|
305
320
|
let t = [];
|
|
@@ -308,7 +323,7 @@ function Vt(e) {
|
|
|
308
323
|
}
|
|
309
324
|
var Ht = (e) => !e || !e.image || !(e.image.width > 0);
|
|
310
325
|
function Ut(e, t, n) {
|
|
311
|
-
if (!
|
|
326
|
+
if (!It) {
|
|
312
327
|
n();
|
|
313
328
|
return;
|
|
314
329
|
}
|
|
@@ -337,7 +352,7 @@ function Wt(e, t) {
|
|
|
337
352
|
if (Ht(t)) return;
|
|
338
353
|
t.isStorageTexture !== !0 && n.push(r);
|
|
339
354
|
}
|
|
340
|
-
t.phase = "done", n.length !== 0 &&
|
|
355
|
+
t.phase = "done", n.length !== 0 && W.push({
|
|
341
356
|
stage: e.name,
|
|
342
357
|
nodes: n,
|
|
343
358
|
unboundAtCompile: t.unboundAtCompile.slice(),
|
|
@@ -357,7 +372,7 @@ var Gt = class {
|
|
|
357
372
|
}));
|
|
358
373
|
}
|
|
359
374
|
constructor(e, t, n, { issues: r = null } = {}) {
|
|
360
|
-
this.renderer = e, this._issues = r, this._reportedStageFailures = /* @__PURE__ */ new Set(), this.width = t, this.height = n, this.stages = [], this.context = new
|
|
375
|
+
this.renderer = e, this._issues = r, this._reportedStageFailures = /* @__PURE__ */ new Set(), this.width = t, this.height = n, this.stages = [], this.context = new Pt(), this.eventBus = new Ft(), this.context.setState("width", t), this.context.setState("height", n), this.stats = {
|
|
361
376
|
enabled: !1,
|
|
362
377
|
logSkipped: !1,
|
|
363
378
|
timings: /* @__PURE__ */ new Map(),
|
|
@@ -514,7 +529,7 @@ var Gt = class {
|
|
|
514
529
|
resumeFromPause() {
|
|
515
530
|
this.renderCompleteDispatched = !1, this.lastResetTime = performance.now() - this.timeElapsed * 1e3;
|
|
516
531
|
}
|
|
517
|
-
}, Jt = 864e5,
|
|
532
|
+
}, Jt = 864e5, G = Object.freeze({
|
|
518
533
|
IMMUTABLE: "immutable",
|
|
519
534
|
REVALIDATE: "revalidate",
|
|
520
535
|
NETWORK: "network"
|
|
@@ -522,8 +537,8 @@ var Gt = class {
|
|
|
522
537
|
loaded: e,
|
|
523
538
|
total: t,
|
|
524
539
|
lengthComputable: t > 0 && e <= t
|
|
525
|
-
}),
|
|
526
|
-
function
|
|
540
|
+
}), K = (e, t) => e.headers?.get?.(t) ?? null, Xt = (e) => e.reason ?? new DOMException("aborted", "AbortError");
|
|
541
|
+
function q(e) {
|
|
527
542
|
try {
|
|
528
543
|
let t = new URL(e, globalThis.location?.href ?? "http://localhost/").pathname;
|
|
529
544
|
return decodeURIComponent(t.split("/").pop()) || "download";
|
|
@@ -532,7 +547,7 @@ function K(e) {
|
|
|
532
547
|
}
|
|
533
548
|
}
|
|
534
549
|
async function Zt(e, { onProgress: t, signal: n }) {
|
|
535
|
-
let r = Number(
|
|
550
|
+
let r = Number(K(e, "content-length")) || 0, i = K(e, "content-type") ?? "";
|
|
536
551
|
if (!e.body) return new Blob([await e.arrayBuffer()], { type: i });
|
|
537
552
|
let a = e.body.getReader(), o = [], s = 0;
|
|
538
553
|
for (;;) {
|
|
@@ -546,20 +561,20 @@ async function Zt(e, { onProgress: t, signal: n }) {
|
|
|
546
561
|
var Qt = (e, t, n) => new File([e], t, {
|
|
547
562
|
type: n || e.type,
|
|
548
563
|
lastModified: e.lastModified ?? Date.now()
|
|
549
|
-
}), $t = () => {},
|
|
564
|
+
}), $t = () => {}, J = class {
|
|
550
565
|
constructor(e) {
|
|
551
566
|
this._storage = e, this._revalidating = /* @__PURE__ */ new Set();
|
|
552
567
|
}
|
|
553
568
|
get _area() {
|
|
554
|
-
return this._storage?.area(
|
|
569
|
+
return this._storage?.area(Se.DOWNLOADS) ?? null;
|
|
555
570
|
}
|
|
556
|
-
async fetch(e, { key: t = e, name: n =
|
|
571
|
+
async fetch(e, { key: t = e, name: n = q(e), policy: r = G.REVALIDATE, maxAgeMs: i = Jt, onProgress: a = null, signal: o = null, fetchOptions: s = {} } = {}) {
|
|
557
572
|
let c = this._area;
|
|
558
|
-
if (c && r !==
|
|
573
|
+
if (c && r !== G.NETWORK) {
|
|
559
574
|
let o = await c.open(t);
|
|
560
575
|
if (o) {
|
|
561
576
|
let c = await o.file("data");
|
|
562
|
-
if (c) return r ===
|
|
577
|
+
if (c) return r === G.REVALIDATE && Date.now() - (o.extra.checkedAt ?? 0) >= i && this._revalidate(e, t, n, o.extra, s), a?.(Yt(c.size, c.size)), {
|
|
563
578
|
file: Qt(c, n, o.extra.contentType),
|
|
564
579
|
release: () => o.release(),
|
|
565
580
|
fromCache: !0
|
|
@@ -584,10 +599,10 @@ var Qt = (e, t, n) => new File([e], t, {
|
|
|
584
599
|
signal: i
|
|
585
600
|
});
|
|
586
601
|
if (!s.ok) throw Error(`HTTP ${s.status} fetching ${e}`);
|
|
587
|
-
let c = Number(
|
|
602
|
+
let c = Number(K(s, "content-length")) || 0, l = {
|
|
588
603
|
url: e,
|
|
589
|
-
contentType:
|
|
590
|
-
lastModified:
|
|
604
|
+
contentType: K(s, "content-type") ?? "",
|
|
605
|
+
lastModified: K(s, "last-modified"),
|
|
591
606
|
contentLength: c || null,
|
|
592
607
|
checkedAt: Date.now()
|
|
593
608
|
}, u = o && s.body ? await this._area.create(t, {
|
|
@@ -636,7 +651,7 @@ var Qt = (e, t, n) => new File([e], t, {
|
|
|
636
651
|
headers: t
|
|
637
652
|
});
|
|
638
653
|
if (n.body?.cancel().catch(() => {}), n.ok) {
|
|
639
|
-
let e =
|
|
654
|
+
let e = K(n, "last-modified"), t = n.status === 206 ? Number(K(n, "content-range")?.match(/\/(\d+)$/)?.[1]) || null : Number(K(n, "content-length")) || null;
|
|
640
655
|
a = !!(e && r.lastModified && e !== r.lastModified || t && r.contentLength && t !== r.contentLength);
|
|
641
656
|
}
|
|
642
657
|
} catch {}
|
|
@@ -657,10 +672,10 @@ var Qt = (e, t, n) => new File([e], t, {
|
|
|
657
672
|
}
|
|
658
673
|
};
|
|
659
674
|
function en(e, t, n) {
|
|
660
|
-
return new
|
|
675
|
+
return new J(t).fetch(e, n);
|
|
661
676
|
}
|
|
662
677
|
function tn() {
|
|
663
|
-
return new
|
|
678
|
+
return new J(xe(E().cacheNamespace));
|
|
664
679
|
}
|
|
665
680
|
async function nn(e, { downloads: t = tn(), ...n } = {}) {
|
|
666
681
|
if (!t._storage || !/^https?:/i.test(e)) return {
|
|
@@ -900,7 +915,7 @@ var rn = {
|
|
|
900
915
|
},
|
|
901
916
|
maxTextureSize: { reset: !1 },
|
|
902
917
|
areaLightIntensityScale: { reset: !1 }
|
|
903
|
-
},
|
|
918
|
+
}, Y = Object.freeze({
|
|
904
919
|
DEFAULT: "default",
|
|
905
920
|
HOST: "host",
|
|
906
921
|
SCENE_METADATA: "scene-metadata",
|
|
@@ -919,15 +934,15 @@ var rn = {
|
|
|
919
934
|
reset: r
|
|
920
935
|
});
|
|
921
936
|
let i = t === void 0 ? this._defaults[e] : t;
|
|
922
|
-
!this._values.has(e) && i !== void 0 && (this._values.set(e, i), this._sources.set(e,
|
|
937
|
+
!this._values.has(e) && i !== void 0 && (this._values.set(e, i), this._sources.set(e, Y.DEFAULT));
|
|
923
938
|
}
|
|
924
939
|
_buildHandlers({ stages: e, resetCallback: t, reconcileCompletion: n, applyExposure: r, onCameraProjection: i }) {
|
|
925
|
-
let a = new
|
|
926
|
-
a.set(n?.[0] ?? 0, n?.[1] ?? 0).multiplyScalar(
|
|
940
|
+
let a = new Tt(), o = (t, n) => {
|
|
941
|
+
a.set(n?.[0] ?? 0, n?.[1] ?? 0).multiplyScalar(R.DEG2RAD), e.pathTracer?.setUniform(t, a);
|
|
927
942
|
};
|
|
928
943
|
return {
|
|
929
944
|
handleCameraProjection: (t) => {
|
|
930
|
-
e.pathTracer?.setUniform("cameraProjection",
|
|
945
|
+
e.pathTracer?.setUniform("cameraProjection", ae[t] ?? ae.perspective), i?.(t);
|
|
931
946
|
},
|
|
932
947
|
handleDofMode: (t) => e.pathTracer?.setUniform("dofMode", +(t === "look")),
|
|
933
948
|
handlePanoramaLonRange: (e) => o("panoLonRange", e),
|
|
@@ -977,7 +992,7 @@ var rn = {
|
|
|
977
992
|
}
|
|
978
993
|
};
|
|
979
994
|
}
|
|
980
|
-
set(e, t, { reset: n, silent: r, source: i =
|
|
995
|
+
set(e, t, { reset: n, silent: r, source: i = Y.HOST } = {}) {
|
|
981
996
|
let a = this._applyOne(e, t, i);
|
|
982
997
|
a?.route && ((n === void 0 ? a.route.reset ?? !0 : n) && this._resetCallback?.(), r || this.dispatchEvent({
|
|
983
998
|
type: g.SETTING_CHANGED,
|
|
@@ -986,7 +1001,7 @@ var rn = {
|
|
|
986
1001
|
prev: a.prev
|
|
987
1002
|
}));
|
|
988
1003
|
}
|
|
989
|
-
setMany(e, { silent: t, reset: n, source: r =
|
|
1004
|
+
setMany(e, { silent: t, reset: n, source: r = Y.HOST } = {}) {
|
|
990
1005
|
let i = !1;
|
|
991
1006
|
for (let [n, a] of Object.entries(e)) {
|
|
992
1007
|
let e = this._applyOne(n, a, r);
|
|
@@ -1022,7 +1037,7 @@ var rn = {
|
|
|
1022
1037
|
let e = {};
|
|
1023
1038
|
for (let [t, n] of this._values) e[t] = {
|
|
1024
1039
|
value: n,
|
|
1025
|
-
source: this._sources.get(t) ??
|
|
1040
|
+
source: this._sources.get(t) ?? Y.DEFAULT,
|
|
1026
1041
|
routed: this._routes.has(t)
|
|
1027
1042
|
};
|
|
1028
1043
|
return e;
|
|
@@ -1033,7 +1048,7 @@ var rn = {
|
|
|
1033
1048
|
serialize() {
|
|
1034
1049
|
let e = {};
|
|
1035
1050
|
for (let [t, n] of this._values) {
|
|
1036
|
-
if (this._sources.get(t) !==
|
|
1051
|
+
if (this._sources.get(t) !== Y.HOST || !this._routes.has(t)) continue;
|
|
1037
1052
|
let r = m(n);
|
|
1038
1053
|
r !== void 0 && (e[t] = r);
|
|
1039
1054
|
}
|
|
@@ -1041,7 +1056,7 @@ var rn = {
|
|
|
1041
1056
|
}
|
|
1042
1057
|
restore(e) {
|
|
1043
1058
|
let t = {}, n = [];
|
|
1044
|
-
for (let [r,
|
|
1059
|
+
for (let [r, a] of Object.entries(e ?? {})) this._routes.has(r) ? t[r] = i(a) : n.push(r);
|
|
1045
1060
|
return this.setMany(t), n;
|
|
1046
1061
|
}
|
|
1047
1062
|
applyAll() {
|
|
@@ -1054,12 +1069,12 @@ var rn = {
|
|
|
1054
1069
|
e.uniform ? this._pathTracer?.setUniform(e.uniform, t) : e.handler ? this._handlers[e.handler]?.(t, n) : e.apply?.(t, n);
|
|
1055
1070
|
}
|
|
1056
1071
|
_initDefaults(e) {
|
|
1057
|
-
for (let t of Object.keys(rn)) t in e && (this._values.set(t, e[t]), this._sources.set(t,
|
|
1072
|
+
for (let t of Object.keys(rn)) t in e && (this._values.set(t, e[t]), this._sources.set(t, Y.DEFAULT));
|
|
1058
1073
|
}
|
|
1059
1074
|
}, on = class {
|
|
1060
1075
|
constructor({ issues: e = null } = {}) {
|
|
1061
|
-
this._issues = e, this._renderer = null, this._offRegistry =
|
|
1062
|
-
this._renderer &&
|
|
1076
|
+
this._issues = e, this._renderer = null, this._offRegistry = ke(() => {
|
|
1077
|
+
this._renderer && Oe(this._renderer);
|
|
1063
1078
|
});
|
|
1064
1079
|
}
|
|
1065
1080
|
get hasConfig() {
|
|
@@ -1076,11 +1091,11 @@ var rn = {
|
|
|
1076
1091
|
}
|
|
1077
1092
|
attachRenderer(e) {
|
|
1078
1093
|
this._renderer = e;
|
|
1079
|
-
let t =
|
|
1080
|
-
return e.outputColorSpace =
|
|
1094
|
+
let t = Oe(e);
|
|
1095
|
+
return e.outputColorSpace = V, t;
|
|
1081
1096
|
}
|
|
1082
1097
|
listViews() {
|
|
1083
|
-
return
|
|
1098
|
+
return Ee();
|
|
1084
1099
|
}
|
|
1085
1100
|
get activeView() {
|
|
1086
1101
|
return null;
|
|
@@ -1092,7 +1107,7 @@ var rn = {
|
|
|
1092
1107
|
return this._renderer && (this._renderer.toneMapping = e), t;
|
|
1093
1108
|
}
|
|
1094
1109
|
_publishWorkingMatrix() {
|
|
1095
|
-
|
|
1110
|
+
Ce(null, T);
|
|
1096
1111
|
}
|
|
1097
1112
|
loadConfig() {
|
|
1098
1113
|
let e = "colour configs need the OCIO pipeline: renderer.setColorManagement( ColorManagement ), from rayzee/addons/color";
|
|
@@ -1120,83 +1135,16 @@ var rn = {
|
|
|
1120
1135
|
activeView: null,
|
|
1121
1136
|
context: null,
|
|
1122
1137
|
exportSpace: null,
|
|
1123
|
-
views:
|
|
1124
|
-
registryVersion:
|
|
1138
|
+
views: Ee(),
|
|
1139
|
+
registryVersion: De(),
|
|
1125
1140
|
bakeError: e?.error ?? null
|
|
1126
1141
|
};
|
|
1127
1142
|
}
|
|
1128
1143
|
dispose() {
|
|
1129
|
-
this._offRegistry?.(), this._renderer = null, this._issues = null,
|
|
1144
|
+
this._offRegistry?.(), this._renderer = null, this._issues = null, we() === this && (Ce(null), w(null));
|
|
1130
1145
|
}
|
|
1131
|
-
}, sn =
|
|
1132
|
-
[/\.jpe?g(\?|#|$)/i, "image/jpeg"],
|
|
1133
|
-
[/\.webp(\?|#|$)/i, "image/webp"],
|
|
1134
|
-
[/\.avif(\?|#|$)/i, "image/avif"]
|
|
1135
|
-
];
|
|
1146
|
+
}, sn = "KHR_materials_diffuse_transmission";
|
|
1136
1147
|
function cn(e) {
|
|
1137
|
-
return e.mimeType ? e.mimeType : e.uri?.startsWith("data:") ? e.uri.slice(5, e.uri.indexOf(";")) : sn.find(([t]) => t.test(e.uri ?? ""))?.[1] ?? "image/png";
|
|
1138
|
-
}
|
|
1139
|
-
function ln(e) {
|
|
1140
|
-
for (let t = 8; t + 12 <= e.length;) {
|
|
1141
|
-
let n = (e[t] << 24 | e[t + 1] << 16 | e[t + 2] << 8 | e[t + 3]) >>> 0, r = t + 12 + n;
|
|
1142
|
-
if (e[t + 4] === 73 && e[t + 5] === 69 && e[t + 6] === 78 && e[t + 7] === 68) return e.subarray(0, r);
|
|
1143
|
-
t = r;
|
|
1144
|
-
}
|
|
1145
|
-
return e;
|
|
1146
|
-
}
|
|
1147
|
-
function un({ data: e, width: t, height: n }, { shared: r = !1 } = {}) {
|
|
1148
|
-
let i = new Uint8Array(e.buffer, e.byteOffset, t * n * 4), a = i;
|
|
1149
|
-
r && typeof SharedArrayBuffer < "u" && !(i.buffer instanceof SharedArrayBuffer) && (a = new Uint8Array(new SharedArrayBuffer(i.byteLength)), a.set(i));
|
|
1150
|
-
let o = new tt(a, t, n, vt, Ct);
|
|
1151
|
-
return o.needsUpdate = !0, o;
|
|
1152
|
-
}
|
|
1153
|
-
function dn(e, t) {
|
|
1154
|
-
return b().decodeImage(t === "image/png" ? ln(e) : e, t);
|
|
1155
|
-
}
|
|
1156
|
-
async function fn(e) {
|
|
1157
|
-
let t = await fetch(e);
|
|
1158
|
-
if (!t.ok) throw Error(`HTTP ${t.status}`);
|
|
1159
|
-
return new Uint8Array(await t.arrayBuffer());
|
|
1160
|
-
}
|
|
1161
|
-
function pn(e, t) {
|
|
1162
|
-
return t.bufferView === void 0 ? fn(e.options.manager.resolveURL(R.resolveURL(t.uri, e.options.path))) : e.getDependency("bufferView", t.bufferView).then((e) => new Uint8Array(e));
|
|
1163
|
-
}
|
|
1164
|
-
var mn = (e, t) => !!t && t !== e.textureLoader && typeof t.parse == "function";
|
|
1165
|
-
function hn(e, t, n) {
|
|
1166
|
-
if (e.sourceCache[t] !== void 0) return e.sourceCache[t].then((e) => e.clone());
|
|
1167
|
-
let r = pn(e, e.json.images[t]).then((e) => new Promise((t, r) => {
|
|
1168
|
-
n.parse(e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength), t, r);
|
|
1169
|
-
}));
|
|
1170
|
-
return e.sourceCache[t] = r, r;
|
|
1171
|
-
}
|
|
1172
|
-
async function gn(e, t = cn({ uri: e })) {
|
|
1173
|
-
let n = un(await dn(await fn(e), t));
|
|
1174
|
-
return n.flipY = !0, n;
|
|
1175
|
-
}
|
|
1176
|
-
function _n(e, t = null) {
|
|
1177
|
-
return e.loadImageSource = function(e, n) {
|
|
1178
|
-
if (mn(this, n)) return hn(this, e, n);
|
|
1179
|
-
let r = this.json.images[e], i = /* @__PURE__ */ Error("no image decoder in this runtime: configurePlatform( nodePlatform( { decodeImage } ) ) — see \"Running in Node\"");
|
|
1180
|
-
return t?.(r.uri ?? `bufferView ${r.bufferView}`, i), Promise.reject(i);
|
|
1181
|
-
}, { name: "RAYZEE_missing_image_decoder" };
|
|
1182
|
-
}
|
|
1183
|
-
function vn(e, t = null) {
|
|
1184
|
-
return e.loadImageSource = function(e, n) {
|
|
1185
|
-
if (mn(this, n)) return hn(this, e, n);
|
|
1186
|
-
if (this.sourceCache[e] !== void 0) return this.sourceCache[e].then((e) => e.clone());
|
|
1187
|
-
let r = this.json.images[e], i = cn(r), a = r.uri ?? `bufferView ${r.bufferView}`, o = pn(this, r).then((e) => dn(e, i)).then((e) => {
|
|
1188
|
-
let t = un(e, { shared: !0 });
|
|
1189
|
-
return r.extras && typeof r.extras == "object" && Object.assign(t.userData, r.extras), t.userData.mimeType = i, t;
|
|
1190
|
-
}).catch((e) => {
|
|
1191
|
-
throw t?.(a, e), e;
|
|
1192
|
-
});
|
|
1193
|
-
return this.sourceCache[e] = o, o;
|
|
1194
|
-
}, { name: "RAYZEE_platform_images" };
|
|
1195
|
-
}
|
|
1196
|
-
//#endregion
|
|
1197
|
-
//#region src/Processor/GLTFDiffuseTransmission.js
|
|
1198
|
-
var yn = "KHR_materials_diffuse_transmission";
|
|
1199
|
-
function bn(e) {
|
|
1200
1148
|
let t = (t, n, r, i) => {
|
|
1201
1149
|
let a = {};
|
|
1202
1150
|
return e.assignTexture(a, n, r, i).then(() => {
|
|
@@ -1204,7 +1152,7 @@ function bn(e) {
|
|
|
1204
1152
|
});
|
|
1205
1153
|
};
|
|
1206
1154
|
return {
|
|
1207
|
-
name:
|
|
1155
|
+
name: sn,
|
|
1208
1156
|
afterRoot(n) {
|
|
1209
1157
|
let r = e.json.materials ?? [], i = /* @__PURE__ */ new Set(), a = [];
|
|
1210
1158
|
for (let o of n.scenes ?? []) o.traverse((n) => {
|
|
@@ -1212,7 +1160,7 @@ function bn(e) {
|
|
|
1212
1160
|
for (let n of o) {
|
|
1213
1161
|
if (i.has(n)) continue;
|
|
1214
1162
|
i.add(n);
|
|
1215
|
-
let o = e.associations.get(n)?.materials, s = o === void 0 ? null : r[o]?.extensions?.[
|
|
1163
|
+
let o = e.associations.get(n)?.materials, s = o === void 0 ? null : r[o]?.extensions?.[sn];
|
|
1216
1164
|
if (!s) continue;
|
|
1217
1165
|
n.diffuseTransmission = s.diffuseTransmissionFactor ?? 0;
|
|
1218
1166
|
let [c, l, u] = s.diffuseTransmissionColorFactor ?? [
|
|
@@ -1220,7 +1168,7 @@ function bn(e) {
|
|
|
1220
1168
|
1,
|
|
1221
1169
|
1
|
|
1222
1170
|
];
|
|
1223
|
-
n.diffuseTransmissionColor = new I().setRGB(c, l, u,
|
|
1171
|
+
n.diffuseTransmissionColor = new I().setRGB(c, l, u, ut), s.diffuseTransmissionTexture && a.push(t(n, "diffuseTransmissionMap", s.diffuseTransmissionTexture)), s.diffuseTransmissionColorTexture && a.push(t(n, "diffuseTransmissionColorMap", s.diffuseTransmissionColorTexture, V));
|
|
1224
1172
|
}
|
|
1225
1173
|
});
|
|
1226
1174
|
return Promise.all(a);
|
|
@@ -1229,20 +1177,20 @@ function bn(e) {
|
|
|
1229
1177
|
}
|
|
1230
1178
|
//#endregion
|
|
1231
1179
|
//#region src/Processor/GLTFDecoders.js
|
|
1232
|
-
var
|
|
1233
|
-
function
|
|
1180
|
+
var ln = "KHR_draco_mesh_compression", un = "KHR_texture_basisu", dn = ["EXT_meshopt_compression", "KHR_meshopt_compression"], fn = new TextDecoder();
|
|
1181
|
+
function pn(e) {
|
|
1234
1182
|
if (typeof e == "string") return e;
|
|
1235
1183
|
if (!(e instanceof ArrayBuffer)) return JSON.stringify(e?.extensionsUsed ?? []);
|
|
1236
1184
|
let t = new DataView(e);
|
|
1237
|
-
if (!(e.byteLength >= 20 && t.getUint32(0, !0) === 1179937895)) return
|
|
1185
|
+
if (!(e.byteLength >= 20 && t.getUint32(0, !0) === 1179937895)) return fn.decode(e);
|
|
1238
1186
|
let n = Math.min(t.getUint32(12, !0), e.byteLength - 20);
|
|
1239
|
-
return
|
|
1187
|
+
return fn.decode(new Uint8Array(e, 20, n));
|
|
1240
1188
|
}
|
|
1241
|
-
async function
|
|
1189
|
+
async function mn(e, t, n) {
|
|
1242
1190
|
let { dracoDecoderPath: r, ktx2TranscoderPath: i } = E(), [a, o, s] = await Promise.all([
|
|
1243
|
-
t.includes(
|
|
1244
|
-
t.includes(
|
|
1245
|
-
|
|
1191
|
+
t.includes(ln) && !e.dracoLoader ? import("three/addons/loaders/DRACOLoader.js") : null,
|
|
1192
|
+
t.includes(un) && !e.ktx2Loader ? import("three/addons/loaders/KTX2Loader.js") : null,
|
|
1193
|
+
dn.some((e) => t.includes(e)) && !e.meshoptDecoder ? import("three/addons/libs/meshopt_decoder.module.js") : null
|
|
1246
1194
|
]);
|
|
1247
1195
|
if (a) {
|
|
1248
1196
|
let t = new a.DRACOLoader();
|
|
@@ -1261,15 +1209,15 @@ async function En(e, t, n) {
|
|
|
1261
1209
|
}
|
|
1262
1210
|
s && e.setMeshoptDecoder(s.MeshoptDecoder);
|
|
1263
1211
|
}
|
|
1264
|
-
function
|
|
1212
|
+
function hn(e, t) {
|
|
1265
1213
|
let n = e.parse.bind(e);
|
|
1266
1214
|
return e.parse = (r, i, a, o) => {
|
|
1267
|
-
|
|
1215
|
+
mn(e, pn(r), t).then(() => n(r, i, a, o), (e) => o?.(e));
|
|
1268
1216
|
}, e;
|
|
1269
1217
|
}
|
|
1270
1218
|
//#endregion
|
|
1271
1219
|
//#region src/Processor/AssetLoader.js
|
|
1272
|
-
var
|
|
1220
|
+
var gn = S("assets"), _n = {
|
|
1273
1221
|
glb: {
|
|
1274
1222
|
type: "model",
|
|
1275
1223
|
name: "GLB (GLTF Binary)"
|
|
@@ -1298,45 +1246,52 @@ var On = S("assets"), kn = {
|
|
|
1298
1246
|
type: "image",
|
|
1299
1247
|
name: "WebP"
|
|
1300
1248
|
}
|
|
1301
|
-
},
|
|
1249
|
+
}, X = {
|
|
1302
1250
|
addOn: "rayzee/addons/archives",
|
|
1303
1251
|
install: "assetLoader.setArchiveImporter()"
|
|
1304
|
-
},
|
|
1252
|
+
}, Z = {
|
|
1305
1253
|
addOn: "rayzee/addons/formats",
|
|
1306
1254
|
install: "assetLoader.registerFormat()"
|
|
1307
|
-
},
|
|
1308
|
-
zip:
|
|
1309
|
-
gz:
|
|
1310
|
-
tgz:
|
|
1311
|
-
tar:
|
|
1312
|
-
fbx:
|
|
1313
|
-
obj:
|
|
1314
|
-
stl:
|
|
1315
|
-
ply:
|
|
1316
|
-
dae:
|
|
1317
|
-
"3mf":
|
|
1318
|
-
usd:
|
|
1319
|
-
usda:
|
|
1320
|
-
usdc:
|
|
1321
|
-
usdz:
|
|
1322
|
-
exr:
|
|
1255
|
+
}, vn = {
|
|
1256
|
+
zip: X,
|
|
1257
|
+
gz: X,
|
|
1258
|
+
tgz: X,
|
|
1259
|
+
tar: X,
|
|
1260
|
+
fbx: Z,
|
|
1261
|
+
obj: Z,
|
|
1262
|
+
stl: Z,
|
|
1263
|
+
ply: Z,
|
|
1264
|
+
dae: Z,
|
|
1265
|
+
"3mf": Z,
|
|
1266
|
+
usd: Z,
|
|
1267
|
+
usda: Z,
|
|
1268
|
+
usdc: Z,
|
|
1269
|
+
usdz: Z,
|
|
1270
|
+
exr: Z
|
|
1323
1271
|
};
|
|
1324
|
-
function
|
|
1325
|
-
let t = new
|
|
1272
|
+
function yn(e) {
|
|
1273
|
+
let t = new rt();
|
|
1326
1274
|
for (let n in e.attributes) t.setAttribute(n, e.attributes[n]);
|
|
1327
1275
|
e.index && t.setIndex(e.index);
|
|
1328
1276
|
for (let n of e.groups) t.addGroup(n.start, n.count, n.materialIndex);
|
|
1329
1277
|
return t;
|
|
1330
1278
|
}
|
|
1331
|
-
var
|
|
1332
|
-
|
|
1279
|
+
var bn = {
|
|
1280
|
+
name: "RAYZEE_camera_clip",
|
|
1281
|
+
afterRoot(e) {
|
|
1282
|
+
for (let t of e.scenes) t.traverse((e) => {
|
|
1283
|
+
e.isCamera && e.near > 0 && (e.userData.clipStart = e.near);
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
}, xn = 683;
|
|
1287
|
+
function Sn(e, t, n, r) {
|
|
1333
1288
|
if (!(r.normalize ?? !0)) return Math.PI;
|
|
1334
1289
|
let i = r.shape === "ellipse" || r.shape === "disk" ? Math.PI / 4 : 1, a = e.getWorldScale(new U()), o = Math.PI * i * Math.abs(t * a.x * n * a.y);
|
|
1335
1290
|
return Number.isFinite(o) ? o : Math.PI;
|
|
1336
1291
|
}
|
|
1337
|
-
var
|
|
1292
|
+
var Cn = class e extends L {
|
|
1338
1293
|
constructor(e, t, n, { issues: r = null, areaLightIntensityScale: i = null } = {}) {
|
|
1339
|
-
super(), this.scene = e, this.camera = t, this.controls = n, this.targetModel = null, this.floorPlane = null, this.sceneScale = 1, this.sceneSize = new U(1, 1, 1), this.loaderCache = {}, this.uploadedFileInfo = null, this.animations = [], this.renderer = null, this.sceneMetadata = null, this._loadingManager = new
|
|
1294
|
+
super(), this.scene = e, this.camera = t, this.controls = n, this.targetModel = null, this.floorPlane = null, this.sceneScale = 1, this.sceneSize = new U(1, 1, 1), this.loaderCache = {}, this.uploadedFileInfo = null, this.animations = [], this.renderer = null, this.sceneMetadata = null, this._loadingManager = new 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 ?? (() => _.areaLightIntensityScale), this._loadingManager.onError = (e) => {
|
|
1340
1295
|
this._loadCancelled || this._issues?.record(C.ASSET_UNREACHABLE, `asset "${e}" could not be fetched — anything depending on it renders without it`, { url: e });
|
|
1341
1296
|
};
|
|
1342
1297
|
}
|
|
@@ -1356,7 +1311,7 @@ var Pn = class e extends L {
|
|
|
1356
1311
|
downloads: this.downloads,
|
|
1357
1312
|
key: i,
|
|
1358
1313
|
policy: a,
|
|
1359
|
-
name:
|
|
1314
|
+
name: q(t),
|
|
1360
1315
|
signal: o.signal,
|
|
1361
1316
|
onProgress: this._downloadProgress(n, r)
|
|
1362
1317
|
});
|
|
@@ -1373,7 +1328,7 @@ var Pn = class e extends L {
|
|
|
1373
1328
|
return t ? `${e}::${t}` : null;
|
|
1374
1329
|
}
|
|
1375
1330
|
get downloads() {
|
|
1376
|
-
return this._downloads?._storage !== this.storage && (this._downloads = new
|
|
1331
|
+
return this._downloads?._storage !== this.storage && (this._downloads = new J(this.storage)), this._downloads;
|
|
1377
1332
|
}
|
|
1378
1333
|
_isCancellation(e) {
|
|
1379
1334
|
return this._loadCancelled || e?.name === "AbortError" || e?.code === "LOAD_CANCELLED";
|
|
@@ -1410,7 +1365,7 @@ var Pn = class e extends L {
|
|
|
1410
1365
|
_adoptExternalObject(e) {
|
|
1411
1366
|
let t;
|
|
1412
1367
|
try {
|
|
1413
|
-
t =
|
|
1368
|
+
t = jt(e);
|
|
1414
1369
|
} catch (t) {
|
|
1415
1370
|
throw Error(`Cannot render "${e.name || e.type}": its userData must be JSON-serializable.`, { cause: t });
|
|
1416
1371
|
}
|
|
@@ -1444,10 +1399,10 @@ var Pn = class e extends L {
|
|
|
1444
1399
|
}
|
|
1445
1400
|
getFileFormat(e) {
|
|
1446
1401
|
let t = e.split(".").pop().toLowerCase();
|
|
1447
|
-
return
|
|
1402
|
+
return _n[t] || this._formats.get(t) || this._archiveFormats?.[t] || null;
|
|
1448
1403
|
}
|
|
1449
1404
|
formatError(e) {
|
|
1450
|
-
let t =
|
|
1405
|
+
let t = vn[e.split(".").pop().toLowerCase()];
|
|
1451
1406
|
return /* @__PURE__ */ Error(t ? `${e}: this format is read by ${t.addOn} — install it with ${t.install}` : `Unsupported file format: ${e}`);
|
|
1452
1407
|
}
|
|
1453
1408
|
async inspectArchive(e) {
|
|
@@ -1458,6 +1413,9 @@ var Pn = class e extends L {
|
|
|
1458
1413
|
flushPendingGraph(e) {
|
|
1459
1414
|
this.archives?.flushPendingGraph(e);
|
|
1460
1415
|
}
|
|
1416
|
+
commitPendingGraph(e) {
|
|
1417
|
+
this.archives?.commitPendingGraph(e);
|
|
1418
|
+
}
|
|
1461
1419
|
readFileAsArrayBuffer(e) {
|
|
1462
1420
|
return e.arrayBuffer();
|
|
1463
1421
|
}
|
|
@@ -1498,7 +1456,7 @@ var Pn = class e extends L {
|
|
|
1498
1456
|
}
|
|
1499
1457
|
async loadFolder(e, t = {}) {
|
|
1500
1458
|
let n = await this._archiveImporter();
|
|
1501
|
-
if (!n) throw Error(`${e.name}: folders are read by ${
|
|
1459
|
+
if (!n) throw Error(`${e.name}: folders are read by ${X.addOn} — install it with ${X.install}`);
|
|
1502
1460
|
y({
|
|
1503
1461
|
isLoading: !0,
|
|
1504
1462
|
status: `Loading ${e.name}...`,
|
|
@@ -1515,7 +1473,7 @@ var Pn = class e extends L {
|
|
|
1515
1473
|
}
|
|
1516
1474
|
}
|
|
1517
1475
|
async loadAssetFromUrl(t, n = {}) {
|
|
1518
|
-
let { filename: r =
|
|
1476
|
+
let { filename: r = q(t), cacheKey: i = t, cachePolicy: a, ...o } = n;
|
|
1519
1477
|
if (!this.getFileFormat(r)) throw this.formatError(r);
|
|
1520
1478
|
this._loadCancelled = !1;
|
|
1521
1479
|
let s = e._isNetworkUrl(t), c = `Downloading ${r}...`, l = new AbortController();
|
|
@@ -1551,7 +1509,7 @@ var Pn = class e extends L {
|
|
|
1551
1509
|
}
|
|
1552
1510
|
}
|
|
1553
1511
|
async loadModelFromFile(e, t) {
|
|
1554
|
-
let n = this.storage ? this._keyed("file", O(await
|
|
1512
|
+
let n = this.storage ? this._keyed("file", O(await je(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);
|
|
1555
1513
|
return this._sourceKey = n, i;
|
|
1556
1514
|
}
|
|
1557
1515
|
async _loadModelFileByExtension(e, t) {
|
|
@@ -1598,7 +1556,7 @@ var Pn = class e extends L {
|
|
|
1598
1556
|
};
|
|
1599
1557
|
try {
|
|
1600
1558
|
let r = await this.loadEnvironment(n);
|
|
1601
|
-
return he(r, O(await
|
|
1559
|
+
return he(r, O(await je(e))), this.dispatchEvent({
|
|
1602
1560
|
type: "load",
|
|
1603
1561
|
texture: r,
|
|
1604
1562
|
filename: t
|
|
@@ -1657,21 +1615,21 @@ var Pn = class e extends L {
|
|
|
1657
1615
|
}
|
|
1658
1616
|
async loadEnvironmentByExtension(t, n, { loader: r = null } = {}) {
|
|
1659
1617
|
let i = this._formats.get(n);
|
|
1660
|
-
if (!r && i?.type === "environment" && (r = this.loaderCache[n] ??= await i.createLoader(this._loadingManager)), !r && n === "hdr" && (r = this.loaderCache.hdr ??= new
|
|
1618
|
+
if (!r && i?.type === "environment" && (r = this.loaderCache[n] ??= await i.createLoader(this._loadingManager)), !r && n === "hdr" && (r = this.loaderCache.hdr ??= new kt(this._loadingManager).setDataType(ct)), !r && vn[n]) throw this.formatError(`environment.${n}`);
|
|
1661
1619
|
let a = e._isNetworkUrl(t), o = "Downloading Environment...", s = await this._viaCache(t, o, a), c = s.cached ? void 0 : this._downloadProgress(o, a), l;
|
|
1662
1620
|
try {
|
|
1663
|
-
r ? l = await r.loadAsync(s.url, c) :
|
|
1621
|
+
r ? l = await r.loadAsync(s.url, c) : ge().decodeImage ? (l = await Le(s.url, `image/${n === "jpg" ? "jpeg" : n}`), l.colorSpace = V) : (this.loaderCache.texture || (this.loaderCache.texture = new wt(this._loadingManager)), l = await this.loaderCache.texture.loadAsync(s.url, c), l.colorSpace = V);
|
|
1664
1622
|
} finally {
|
|
1665
1623
|
s.release();
|
|
1666
1624
|
}
|
|
1667
|
-
return this._downloadComplete("Processing Environment...", 62), this.maxEnvironmentWidth &&
|
|
1625
|
+
return this._downloadComplete("Processing Environment...", 62), this.maxEnvironmentWidth && wn(l, this.maxEnvironmentWidth), l.mapping = st, l.minFilter = lt, l.magFilter = lt, l;
|
|
1668
1626
|
}
|
|
1669
1627
|
applyEnvironmentToScene(e) {
|
|
1670
1628
|
this.scene.background = e, this.scene.environment = e;
|
|
1671
1629
|
}
|
|
1672
1630
|
async createGLTFLoader() {
|
|
1673
|
-
let e =
|
|
1674
|
-
return
|
|
1631
|
+
let e = hn(new Ot(this._loadingManager), this.renderer), t = (e, t) => this._reportImageFailure(e, t);
|
|
1632
|
+
return ge().decodeImage ? e.register((e) => Ie(e, t)) : ne() || e.register((e) => Pe(e, t)), e.register((e) => cn(e)), e.register(() => bn), e;
|
|
1675
1633
|
}
|
|
1676
1634
|
_reportImageFailure(e, t) {
|
|
1677
1635
|
try {
|
|
@@ -1706,9 +1664,9 @@ var Pn = class e extends L {
|
|
|
1706
1664
|
canCancel: i,
|
|
1707
1665
|
loadedBytes: 0,
|
|
1708
1666
|
totalBytes: 0
|
|
1709
|
-
}), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(
|
|
1667
|
+
}), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(dt.extractUrlBase(t));
|
|
1710
1668
|
let e = await v(() => r.loadAsync(a.url, a.cached ? void 0 : this._downloadProgress("Downloading Model...", i)));
|
|
1711
|
-
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 =
|
|
1669
|
+
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({
|
|
1712
1670
|
type: "load",
|
|
1713
1671
|
model: e.scene,
|
|
1714
1672
|
filename: t.split("/").pop()
|
|
@@ -1737,7 +1695,7 @@ var Pn = class e extends L {
|
|
|
1737
1695
|
canCancel: i,
|
|
1738
1696
|
loadedBytes: 0,
|
|
1739
1697
|
totalBytes: 0
|
|
1740
|
-
}), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(
|
|
1698
|
+
}), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(dt.extractUrlBase(t));
|
|
1741
1699
|
let e = await v(() => r.loadAsync(a.url, a.cached ? void 0 : this._downloadProgress("Downloading Model...", i)));
|
|
1742
1700
|
return this._downloadComplete(), this._throwDeferred(), this._appended = !0, this._processAndParent(e.scene), {
|
|
1743
1701
|
root: e.scene,
|
|
@@ -1755,7 +1713,7 @@ var Pn = class e extends L {
|
|
|
1755
1713
|
return n.name = e.name || t, this._processAndParent(n), { root: n };
|
|
1756
1714
|
}
|
|
1757
1715
|
removeModelRoot(e) {
|
|
1758
|
-
e && (e.userData.__rayzeeExternal ? (
|
|
1716
|
+
e && (e.userData.__rayzeeExternal ? (ie(e), e.parent?.remove(e)) : te(e));
|
|
1759
1717
|
}
|
|
1760
1718
|
async loadGLBFromArrayBuffer(e, t = "model.glb") {
|
|
1761
1719
|
let n = await this.createGLTFLoader();
|
|
@@ -1766,7 +1724,7 @@ var Pn = class e extends L {
|
|
|
1766
1724
|
progress: 5
|
|
1767
1725
|
}), await new Promise((e) => setTimeout(e, 0));
|
|
1768
1726
|
let r = await v(() => n.parseAsync(e, ""));
|
|
1769
|
-
return this._throwDeferred(), this.releaseTargetModel(), this.targetModel = r.scene, this.animations = r.animations || [], this.sceneMetadata =
|
|
1727
|
+
return this._throwDeferred(), this.releaseTargetModel(), this.targetModel = r.scene, this.animations = r.animations || [], this.sceneMetadata = Re(r), y({
|
|
1770
1728
|
isLoading: !0,
|
|
1771
1729
|
status: "Processing Data...",
|
|
1772
1730
|
progress: 10
|
|
@@ -1799,20 +1757,20 @@ var Pn = class e extends L {
|
|
|
1799
1757
|
}), n;
|
|
1800
1758
|
}
|
|
1801
1759
|
async onModelLoad(e) {
|
|
1802
|
-
let t = new
|
|
1760
|
+
let t = new p("onModelLoad");
|
|
1803
1761
|
t.start("Camera extraction");
|
|
1804
1762
|
let n = this.extractCamerasFromModel(e);
|
|
1805
1763
|
t.end("Camera extraction"), t.start("Camera setup");
|
|
1806
|
-
let r = new
|
|
1764
|
+
let r = new nt().setFromObject(e), i = r.getCenter(new U()), a = r.getSize(new U());
|
|
1807
1765
|
this.controls?.target.copy(i);
|
|
1808
|
-
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),
|
|
1809
|
-
if (this.camera.position.copy(
|
|
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 U(Math.cos(l) * c, c / Math.sqrt(2), Math.sin(l) * c);
|
|
1767
|
+
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) {
|
|
1810
1768
|
let e = r.min.y;
|
|
1811
1769
|
this.floorPlane.position.y = e, this.floorPlane.rotation.x = -Math.PI / 2, this.floorPlane.scale.setScalar(o * 5);
|
|
1812
1770
|
}
|
|
1813
1771
|
t.start("Process model objects"), this.processModelObjects(e), t.end("Process model objects"), t.start("Scene add"), this.scene.add(e), t.end("Scene add");
|
|
1814
|
-
let
|
|
1815
|
-
return this.sceneSize.copy(a), t.start("setupPathTracing"), await this.setupPathTracing(e,
|
|
1772
|
+
let d = o;
|
|
1773
|
+
return this.sceneSize.copy(a), t.start("setupPathTracing"), await this.setupPathTracing(e, d), t.end("setupPathTracing"), t.print(), this.dispatchEvent({
|
|
1816
1774
|
type: "modelProcessed",
|
|
1817
1775
|
model: e,
|
|
1818
1776
|
cameras: n,
|
|
@@ -1820,13 +1778,13 @@ var Pn = class e extends L {
|
|
|
1820
1778
|
center: i,
|
|
1821
1779
|
size: a,
|
|
1822
1780
|
maxDim: o,
|
|
1823
|
-
sceneScale:
|
|
1781
|
+
sceneScale: d
|
|
1824
1782
|
}
|
|
1825
1783
|
}), this.dispatchEvent({ type: "SceneRebuild" }), {
|
|
1826
1784
|
center: i,
|
|
1827
1785
|
size: a,
|
|
1828
1786
|
maxDim: o,
|
|
1829
|
-
sceneScale:
|
|
1787
|
+
sceneScale: d
|
|
1830
1788
|
};
|
|
1831
1789
|
}
|
|
1832
1790
|
extractCamerasFromModel(e) {
|
|
@@ -1842,10 +1800,10 @@ var Pn = class e extends L {
|
|
|
1842
1800
|
let t = [], n = [];
|
|
1843
1801
|
e.traverse((e) => {
|
|
1844
1802
|
let r = e.userData;
|
|
1845
|
-
e.isRectAreaLight && !r.__radianceConverted && (e.intensity *=
|
|
1803
|
+
e.isRectAreaLight && !r.__radianceConverted && (e.intensity *= Sn(e, e.width, e.height, r), r.__radianceConverted = !0), (e.isPointLight || e.isSpotLight) && !r.__candelaConverted && (e.intensity *= 4 * Math.PI / xn, r.__candelaConverted = !0), e.isDirectionalLight && !r.__luxConverted && (e.intensity /= xn, r.__luxConverted = !0);
|
|
1846
1804
|
let i = e.name.startsWith("RectAreaLightPlaceholder");
|
|
1847
1805
|
if (i && !(r.name && r.type === "RectAreaLight") && !e.parent?.name?.startsWith("RectAreaLightPlaceholder") && n.push(e.name), i && r.name && r.type === "RectAreaLight") {
|
|
1848
|
-
let t = r.normalize ?? !0, n = r.shape ?? "rectangle", i = r.intensity *
|
|
1806
|
+
let t = r.normalize ?? !0, n = r.shape ?? "rectangle", i = r.intensity * Sn(e, r.width, r.height, r), a = new B(new I(...r.color), i * this._areaLightIntensityScale(), r.width, r.height);
|
|
1849
1807
|
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);
|
|
1850
1808
|
}
|
|
1851
1809
|
e.isMesh && Array.isArray(e.material) && t.push(e);
|
|
@@ -1856,8 +1814,8 @@ var Pn = class e extends L {
|
|
|
1856
1814
|
let r = e.userData.__rayzeeExternal === !0;
|
|
1857
1815
|
for (let e of t) {
|
|
1858
1816
|
if (!e.parent) continue;
|
|
1859
|
-
console.log("Found multi-material mesh:", e.name), r && (e.geometry =
|
|
1860
|
-
let t =
|
|
1817
|
+
console.log("Found multi-material mesh:", e.name), r && (e.geometry = yn(e.geometry));
|
|
1818
|
+
let t = At(e);
|
|
1861
1819
|
for (let e of t.children) e.geometry.userData.__rayzeeOwned = !0;
|
|
1862
1820
|
e.parent.add(t), e.parent.remove(e);
|
|
1863
1821
|
}
|
|
@@ -1866,7 +1824,7 @@ var Pn = class e extends L {
|
|
|
1866
1824
|
this.sceneScale = t;
|
|
1867
1825
|
}
|
|
1868
1826
|
createFloorPlane() {
|
|
1869
|
-
this.floorPlane = new
|
|
1827
|
+
this.floorPlane = new pt(new it(), new mt({
|
|
1870
1828
|
transparent: !1,
|
|
1871
1829
|
color: 3158064,
|
|
1872
1830
|
roughness: 1,
|
|
@@ -1889,7 +1847,7 @@ var Pn = class e extends L {
|
|
|
1889
1847
|
}
|
|
1890
1848
|
getSupportedFormats(e = null) {
|
|
1891
1849
|
let t = {
|
|
1892
|
-
...
|
|
1850
|
+
..._n,
|
|
1893
1851
|
...this._archiveFormats
|
|
1894
1852
|
};
|
|
1895
1853
|
for (let [e, { type: n, name: r }] of this._formats) t[e] = {
|
|
@@ -1914,7 +1872,7 @@ var Pn = class e extends L {
|
|
|
1914
1872
|
this._listeners = void 0;
|
|
1915
1873
|
}
|
|
1916
1874
|
};
|
|
1917
|
-
function
|
|
1875
|
+
function wn(e, t) {
|
|
1918
1876
|
let { data: n, width: r, height: i } = e.image ?? {};
|
|
1919
1877
|
if (!(n instanceof Float32Array) || r <= t || n.length !== r * i * 4) return;
|
|
1920
1878
|
let a = Math.ceil(r / t), o = Math.ceil(r / a), s = Math.ceil(i / a);
|
|
@@ -1935,17 +1893,17 @@ function Fn(e, t) {
|
|
|
1935
1893
|
data: n.byteOffset === 0 && n.byteLength === n.buffer.byteLength && n.buffer.transfer ? new Float32Array(n.buffer.transfer(c)) : n.slice(0, o * s * 4),
|
|
1936
1894
|
width: o,
|
|
1937
1895
|
height: s
|
|
1938
|
-
}, e.needsUpdate = !0,
|
|
1896
|
+
}, e.needsUpdate = !0, gn.info(`environment ${r}×${i} shrunk to ${o}×${s} (memory spill)`);
|
|
1939
1897
|
}
|
|
1940
1898
|
//#endregion
|
|
1941
1899
|
//#region src/HeadlessCanvas.js
|
|
1942
|
-
var
|
|
1900
|
+
var Tn = {
|
|
1943
1901
|
addEventListener() {},
|
|
1944
1902
|
removeEventListener() {},
|
|
1945
1903
|
dispatchEvent() {
|
|
1946
1904
|
return !0;
|
|
1947
1905
|
}
|
|
1948
|
-
},
|
|
1906
|
+
}, En = class {
|
|
1949
1907
|
constructor(e) {
|
|
1950
1908
|
this.canvas = e, this._configuration = null, this._texture = null;
|
|
1951
1909
|
}
|
|
@@ -1973,12 +1931,12 @@ var In = {
|
|
|
1973
1931
|
return this._texture;
|
|
1974
1932
|
}
|
|
1975
1933
|
};
|
|
1976
|
-
function
|
|
1934
|
+
function Dn(e = 1, t = 1) {
|
|
1977
1935
|
let n = {
|
|
1978
|
-
...
|
|
1936
|
+
...Tn,
|
|
1979
1937
|
defaultView: null
|
|
1980
1938
|
}, r = {
|
|
1981
|
-
...
|
|
1939
|
+
...Tn,
|
|
1982
1940
|
isHeadlessCanvas: !0,
|
|
1983
1941
|
width: e,
|
|
1984
1942
|
height: t,
|
|
@@ -2005,12 +1963,12 @@ function Rn(e = 1, t = 1) {
|
|
|
2005
1963
|
hasPointerCapture: () => !1,
|
|
2006
1964
|
focus() {},
|
|
2007
1965
|
getContext: (e) => e === "webgpu" ? i : null
|
|
2008
|
-
}, i = new
|
|
1966
|
+
}, i = new En(r);
|
|
2009
1967
|
return r;
|
|
2010
1968
|
}
|
|
2011
1969
|
//#endregion
|
|
2012
1970
|
//#region src/managers/ViewCamera.js
|
|
2013
|
-
var
|
|
1971
|
+
var On = class extends vt {
|
|
2014
1972
|
constructor(e, t, n, r) {
|
|
2015
1973
|
super(e, t, n, r), this.orthographic = !1, this.orthoHalfHeight = 1;
|
|
2016
1974
|
}
|
|
@@ -2034,17 +1992,17 @@ var zn = class extends mt {
|
|
|
2034
1992
|
return -this.orthoHalfHeight * this.aspect;
|
|
2035
1993
|
}
|
|
2036
1994
|
updateProjectionMatrix() {
|
|
2037
|
-
this.orthographic ?
|
|
1995
|
+
this.orthographic ? _t.prototype.updateProjectionMatrix.call(this) : super.updateProjectionMatrix();
|
|
2038
1996
|
}
|
|
2039
1997
|
copy(e, t) {
|
|
2040
1998
|
return super.copy(e, t), this.orthographic = e.orthographic === !0, this.orthoHalfHeight = e.orthoHalfHeight ?? this.orthoHalfHeight, this;
|
|
2041
1999
|
}
|
|
2042
|
-
},
|
|
2043
|
-
DirectionalLight:
|
|
2044
|
-
PointLight:
|
|
2045
|
-
SpotLight:
|
|
2046
|
-
RectAreaLight:
|
|
2047
|
-
},
|
|
2000
|
+
}, kn = "__rayzeeUserLight", An = {
|
|
2001
|
+
DirectionalLight: at,
|
|
2002
|
+
PointLight: yt,
|
|
2003
|
+
SpotLight: St,
|
|
2004
|
+
RectAreaLight: B
|
|
2005
|
+
}, jn = class extends L {
|
|
2048
2006
|
constructor(e, t, n, r = {}) {
|
|
2049
2007
|
super(), this.scene = e, this.sceneHelpers = t, this.pathTracer = n, this._onReset = r.onReset || null, this._onLightRemoved = r.onLightRemoved || null;
|
|
2050
2008
|
}
|
|
@@ -2092,14 +2050,14 @@ var zn = class extends mt {
|
|
|
2092
2050
|
}[e];
|
|
2093
2051
|
if (!t) return null;
|
|
2094
2052
|
let n;
|
|
2095
|
-
if (e === "DirectionalLight") n = new
|
|
2096
|
-
else if (e === "PointLight") n = new
|
|
2053
|
+
if (e === "DirectionalLight") n = new at(t.color, t.intensity), n.position.fromArray(t.position);
|
|
2054
|
+
else if (e === "PointLight") n = new yt(t.color, t.intensity), n.position.fromArray(t.position);
|
|
2097
2055
|
else if (e === "SpotLight") {
|
|
2098
|
-
n = new
|
|
2099
|
-
let e = new
|
|
2056
|
+
n = new St(t.color, t.intensity), n.position.fromArray(t.position), n.angle = R.degToRad(t.angle);
|
|
2057
|
+
let e = new z();
|
|
2100
2058
|
this.scene.add(e), n.target = e;
|
|
2101
|
-
} else e === "RectAreaLight" && (n = new
|
|
2102
|
-
n.userData[
|
|
2059
|
+
} else e === "RectAreaLight" && (n = new B(t.color, t.intensity, t.width, t.height), n.position.fromArray(t.position), n.lookAt(0, 0, 0), n.userData.normalize = !0, n.userData.spread = Math.PI, n.userData.shape = "rectangle");
|
|
2060
|
+
n.userData[kn] = !0, n.userData.temperature = 6500, n.userData.useTemperature = !1, n.userData.exposure = 0;
|
|
2103
2061
|
let r = this.scene.getObjectsByProperty("isLight", !0).length;
|
|
2104
2062
|
return n.name = `${e.replace("Light", "")} ${r + 1}`, this.scene.add(n), this.updateLights(), this._syncHelpers(), this._onReset?.(), this._buildDescriptor(n);
|
|
2105
2063
|
}
|
|
@@ -2125,7 +2083,7 @@ var zn = class extends mt {
|
|
|
2125
2083
|
this.pathTracer?.updateLights(), this.sceneHelpers?.visible && this.sceneHelpers.update();
|
|
2126
2084
|
}
|
|
2127
2085
|
transferSceneLights(e, { keepUserLights: t = !1 } = {}) {
|
|
2128
|
-
this._removeAllLights(t ? (e) => !e.userData?.[
|
|
2086
|
+
this._removeAllLights(t ? (e) => !e.userData?.[kn] : void 0);
|
|
2129
2087
|
let n = e.getObjectsByProperty("isLight", !0);
|
|
2130
2088
|
if (!n || n.length === 0) {
|
|
2131
2089
|
this.updateLights();
|
|
@@ -2134,7 +2092,7 @@ var zn = class extends mt {
|
|
|
2134
2092
|
for (let e of n) {
|
|
2135
2093
|
let t = e.clone();
|
|
2136
2094
|
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) {
|
|
2137
|
-
let n = new
|
|
2095
|
+
let n = new z();
|
|
2138
2096
|
e.target.updateWorldMatrix(!0, !1), e.target.getWorldPosition(n.position), this.scene.add(n), t.target = n;
|
|
2139
2097
|
}
|
|
2140
2098
|
this.scene.add(t);
|
|
@@ -2179,14 +2137,14 @@ var zn = class extends mt {
|
|
|
2179
2137
|
this.sceneHelpers?.clear(), this._removeAllLights();
|
|
2180
2138
|
let t = [];
|
|
2181
2139
|
for (let n of e ?? []) {
|
|
2182
|
-
let e =
|
|
2140
|
+
let e = An[n.type];
|
|
2183
2141
|
if (!e) continue;
|
|
2184
2142
|
let r = new e();
|
|
2185
2143
|
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 ?? [
|
|
2186
2144
|
1,
|
|
2187
2145
|
1,
|
|
2188
2146
|
1
|
|
2189
|
-
]), r.userData =
|
|
2147
|
+
]), r.userData = i(n.userData) ?? {};
|
|
2190
2148
|
for (let e of [
|
|
2191
2149
|
"angle",
|
|
2192
2150
|
"penumbra",
|
|
@@ -2196,7 +2154,7 @@ var zn = class extends mt {
|
|
|
2196
2154
|
"height"
|
|
2197
2155
|
]) typeof n[e] == "number" && (r[e] = n[e]);
|
|
2198
2156
|
if (n.target) {
|
|
2199
|
-
let e = new
|
|
2157
|
+
let e = new z();
|
|
2200
2158
|
e.position.fromArray(n.target), this.scene.add(e), r.target = e;
|
|
2201
2159
|
}
|
|
2202
2160
|
this.scene.add(r), t.push(r);
|
|
@@ -2236,7 +2194,7 @@ var zn = class extends mt {
|
|
|
2236
2194
|
}
|
|
2237
2195
|
_buildDescriptor(e) {
|
|
2238
2196
|
let t = 0;
|
|
2239
|
-
e.type === "SpotLight" && e.angle !== void 0 ? t =
|
|
2197
|
+
e.type === "SpotLight" && e.angle !== void 0 ? t = R.radToDeg(e.angle) : e.type === "DirectionalLight" && (t = R.radToDeg(e.userData?.angle ?? 0));
|
|
2240
2198
|
let n = {
|
|
2241
2199
|
uuid: e.uuid,
|
|
2242
2200
|
name: e.name,
|
|
@@ -2255,7 +2213,7 @@ var zn = class extends mt {
|
|
|
2255
2213
|
exposure: e.userData?.exposure ?? 0
|
|
2256
2214
|
};
|
|
2257
2215
|
if (e.type === "RectAreaLight") {
|
|
2258
|
-
n.width = e.width, n.height = e.height, n.normalize = e.userData?.normalize ?? !0, n.spread =
|
|
2216
|
+
n.width = e.width, n.height = e.height, n.normalize = e.userData?.normalize ?? !0, n.spread = R.radToDeg(e.userData?.spread ?? Math.PI);
|
|
2259
2217
|
let t = e.userData?.shape;
|
|
2260
2218
|
n.shape = t === "square" || t === "rectangle" || t === "disk" || t === "ellipse" ? t : t === 1 ? "ellipse" : "rectangle";
|
|
2261
2219
|
let r = e.getWorldDirection(e.position.clone());
|
|
@@ -2271,11 +2229,11 @@ var zn = class extends mt {
|
|
|
2271
2229
|
], 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);
|
|
2272
2230
|
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;
|
|
2273
2231
|
}
|
|
2274
|
-
},
|
|
2232
|
+
}, Mn = ({ element: e, pbrtEntry: t } = {}) => ({
|
|
2275
2233
|
...e === void 0 ? {} : { element: e },
|
|
2276
2234
|
...t === void 0 ? {} : { pbrtEntry: t }
|
|
2277
|
-
}), Q = /* @__PURE__ */ new WeakMap(),
|
|
2278
|
-
async function
|
|
2235
|
+
}), Q = /* @__PURE__ */ new WeakMap(), Nn = 3e4, Pn = new Set([...Object.values(g), ...Object.values(h)]), Fn = /* @__PURE__ */ new Set();
|
|
2236
|
+
async function In(e, t) {
|
|
2279
2237
|
if (!t || typeof self < "u") return e.init();
|
|
2280
2238
|
globalThis.self = {
|
|
2281
2239
|
requestAnimationFrame: () => 0,
|
|
@@ -2288,36 +2246,57 @@ async function Kn(e, t) {
|
|
|
2288
2246
|
}
|
|
2289
2247
|
}
|
|
2290
2248
|
var $ = S("engine");
|
|
2291
|
-
function
|
|
2249
|
+
function Ln() {
|
|
2292
2250
|
let e = new Float32Array(16);
|
|
2293
|
-
return new Uint32Array(e.buffer)[3] =
|
|
2251
|
+
return new Uint32Array(e.buffer)[3] = ve.TRIANGLE_LEAF, e;
|
|
2294
2252
|
}
|
|
2295
|
-
function
|
|
2253
|
+
function Rn(e, t) {
|
|
2296
2254
|
e.lost.then((e) => {
|
|
2297
2255
|
t.app && t.app._handleDeviceLost(e);
|
|
2298
2256
|
});
|
|
2299
2257
|
}
|
|
2300
|
-
var
|
|
2301
|
-
|
|
2258
|
+
var zn = [
|
|
2259
|
+
"core-features-and-limits",
|
|
2260
|
+
"depth-clip-control",
|
|
2261
|
+
"depth32float-stencil8",
|
|
2262
|
+
"texture-compression-bc",
|
|
2263
|
+
"texture-compression-bc-sliced-3d",
|
|
2264
|
+
"texture-compression-etc2",
|
|
2265
|
+
"texture-compression-astc",
|
|
2266
|
+
"texture-compression-astc-sliced-3d",
|
|
2267
|
+
"timestamp-query",
|
|
2268
|
+
"indirect-first-instance",
|
|
2269
|
+
"shader-f16",
|
|
2270
|
+
"rg11b10ufloat-renderable",
|
|
2271
|
+
"bgra8unorm-storage",
|
|
2272
|
+
"float32-filterable",
|
|
2273
|
+
"float32-blendable",
|
|
2274
|
+
"clip-distances",
|
|
2275
|
+
"dual-source-blending",
|
|
2276
|
+
"subgroups",
|
|
2277
|
+
"texture-formats-tier1",
|
|
2278
|
+
"texture-formats-tier2"
|
|
2279
|
+
], Bn = /swiftshader|llvmpipe|lavapipe|basic render|microsoft basic|warp/i;
|
|
2280
|
+
function Vn(e) {
|
|
2302
2281
|
let t = e.info ?? {}, n = `${t.vendor ?? ""} ${t.architecture ?? ""} ${t.device ?? ""} ${t.description ?? ""}`;
|
|
2303
2282
|
return {
|
|
2304
2283
|
vendor: t.vendor ?? "",
|
|
2305
2284
|
architecture: t.architecture ?? "",
|
|
2306
2285
|
device: t.device ?? "",
|
|
2307
2286
|
description: t.description ?? "",
|
|
2308
|
-
isSoftware: t.isFallbackAdapter === !0 || e.isFallbackAdapter === !0 ||
|
|
2287
|
+
isSoftware: t.isFallbackAdapter === !0 || e.isFallbackAdapter === !0 || Bn.test(n)
|
|
2309
2288
|
};
|
|
2310
2289
|
}
|
|
2311
|
-
var
|
|
2290
|
+
var Hn = class extends L {
|
|
2312
2291
|
constructor(e, t = {}) {
|
|
2313
|
-
super(), this._headless = t.headless === !0 || !e, e ??=
|
|
2292
|
+
super(), this._headless = t.headless === !0 || !e, e ??= Dn();
|
|
2314
2293
|
try {
|
|
2315
2294
|
Q.get(e)?.dispose();
|
|
2316
2295
|
} catch (e) {
|
|
2317
2296
|
$.warn("prior canvas owner dispose failed", e);
|
|
2318
2297
|
}
|
|
2319
2298
|
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`.");
|
|
2320
|
-
this._issues = new
|
|
2299
|
+
this._issues = new ye({
|
|
2321
2300
|
strict: t.strict === !0,
|
|
2322
2301
|
onIssue: (e) => this.dispatchEvent({
|
|
2323
2302
|
type: g.ISSUE,
|
|
@@ -2342,18 +2321,18 @@ var Zn = class extends L {
|
|
|
2342
2321
|
}
|
|
2343
2322
|
async init() {
|
|
2344
2323
|
let e = this._initStorage();
|
|
2345
|
-
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(
|
|
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(_e.FLOATS_PER_TRIANGLE), 0), this.stages.pathTracer.setBVHData(Ln()), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setupMaterial(), this.isInitialized = !0, $.debug("WebGPU path tracer app initialized"), this;
|
|
2346
2325
|
}
|
|
2347
2326
|
async setStorageOpener(e) {
|
|
2348
2327
|
this._storageOpener = e, !(!this.isInitialized || this.storage || this._disposed) && (await this._initStorage(), this._attachStorage());
|
|
2349
2328
|
}
|
|
2350
2329
|
async _initStorage() {
|
|
2351
|
-
let e = this._storageOption ?? (this._issues.strict && !
|
|
2330
|
+
let e = this._storageOption ?? (this._issues.strict && !Te("storage") ? !1 : E().storage);
|
|
2352
2331
|
if (e !== !1) {
|
|
2353
2332
|
if (e && typeof e == "object") this.storage = e;
|
|
2354
2333
|
else {
|
|
2355
2334
|
if (!this._storageOpener) {
|
|
2356
|
-
(this._storageOption !== void 0 ||
|
|
2335
|
+
(this._storageOption !== void 0 || Te("storage")) && this._issues.warn(C.CAPABILITY_MISSING, "on-disk storage needs rayzee/addons/storage: setStorageOpener( acquireSharedStorage )");
|
|
2357
2336
|
return;
|
|
2358
2337
|
}
|
|
2359
2338
|
let { storage: e, reason: t, release: n } = await this._storageOpener(E().cacheNamespace);
|
|
@@ -2385,7 +2364,7 @@ var Zn = class extends L {
|
|
|
2385
2364
|
});
|
|
2386
2365
|
}
|
|
2387
2366
|
addEventListener(e, t) {
|
|
2388
|
-
!
|
|
2367
|
+
!Pn.has(e) && !Fn.has(e) && (Fn.add(e), $.warn(`no engine event is named "${e}", so this listener will never fire — see EngineEvents`)), super.addEventListener(e, t);
|
|
2389
2368
|
}
|
|
2390
2369
|
animate() {
|
|
2391
2370
|
if (this._headless) throw Error("a headless app has no render loop — drive it with renderFrames() or renderUntilComplete()");
|
|
@@ -2474,26 +2453,27 @@ var Zn = class extends L {
|
|
|
2474
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: g.RENDER_RESET });
|
|
2475
2454
|
}
|
|
2476
2455
|
dispose() {
|
|
2477
|
-
if (
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
}
|
|
2490
|
-
this.canvas && Q.get(this.canvas) === this && Q.delete(this.canvas), this._gpuDevice &&= (this._gpuDevice.onuncapturederror = null, null), this._deviceLostHolder &&= (this._deviceLostHolder.app = null, null), oe(this.renderer), this.renderer = null, this.stages = {}, this.isInitialized = !1;
|
|
2456
|
+
if (this._disposed) return;
|
|
2457
|
+
if (this._disposed = !0, this.dispatchEvent({ type: g.DISPOSE }), this.stopAnimation(), clearTimeout(this._resizeDebounceTimer), this._resizeDebounceTimer = null, clearTimeout(this._respillTimer), this._respillTimer = null, this._removeTrackedListeners(), fe(null), this._storageRelease?.(), this._storageRelease = null, this.storage = null, this._sceneSource = this._sceneSourceInput = null, this._issues.detach(), this.color?.dispose(), this.color = null, this._textureReadback?.dispose(), this._textureReadback = null, this._readbackToneMapper?.dispose(), this._readbackToneMapper = null, this._disposeExtensions(), this.lightManager?.dispose(), this.pipeline?.dispose(), this._sdf?.dispose(), this._sdf = null, this.assetLoader?.dispose(), this.assetLoader = null, this.meshScene) {
|
|
2458
|
+
this.meshScene.environment?.dispose(), this.meshScene.environment = null;
|
|
2459
|
+
for (let e of [...this.meshScene.children]) te(e);
|
|
2460
|
+
this.meshScene.clear(), this.meshScene = null;
|
|
2461
|
+
}
|
|
2462
|
+
this._sceneHelpers?.clear(), this._sceneHelpers = null, this.scene?.clear(), this.scene = null;
|
|
2463
|
+
try {
|
|
2464
|
+
let e = $e().value, t = Ye().value;
|
|
2465
|
+
e?._listeners?.dispose && (e._listeners.dispose.length = 0), t?._listeners?.dispose && (t._listeners.dispose.length = 0);
|
|
2466
|
+
} catch (e) {
|
|
2467
|
+
$.warn("failed to clear TSL texture singleton listeners", e);
|
|
2491
2468
|
}
|
|
2469
|
+
this.canvas && Q.get(this.canvas) === this && Q.delete(this.canvas);
|
|
2470
|
+
let e = this._gpuDevice;
|
|
2471
|
+
e && (e.onuncapturederror = null, this._gpuDevice = null), this._deviceLostHolder &&= (this._deviceLostHolder.app = null, null), Promise.resolve(se(this.renderer)).finally(() => e?.destroy()), this.renderer = null, this.stages = {}, this.isInitialized = !1;
|
|
2492
2472
|
}
|
|
2493
2473
|
unloadScene() {
|
|
2494
2474
|
if (this.isInitialized) {
|
|
2495
2475
|
if (this._loadingInProgress) throw Error("PathTracerApp.unloadScene: cannot unload while a load is in progress");
|
|
2496
|
-
this._disposed || (this._releaseSceneState(), this.assetLoader?.releaseTargetModel(), this._sceneSource = this._sceneSourceInput = null, this.lightManager?.clearLights?.(), this.stages.pathTracer && (this.stages.pathTracer.setTriangleData(new Uint32Array(
|
|
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(_e.FLOATS_PER_TRIANGLE), 0), this.stages.pathTracer.setBVHData(Ln()), 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: g.SCENE_UNLOADED }));
|
|
2497
2477
|
}
|
|
2498
2478
|
}
|
|
2499
2479
|
async loadModel(e, t = {}) {
|
|
@@ -2538,7 +2518,7 @@ var Zn = class extends L {
|
|
|
2538
2518
|
}
|
|
2539
2519
|
async loadFile(e, t = {}) {
|
|
2540
2520
|
if (t = this._sceneBudgets(t), typeof e == "string") {
|
|
2541
|
-
let n = t.filename ??
|
|
2521
|
+
let n = t.filename ?? q(e), r = this.assetLoader?.getFileFormat(n);
|
|
2542
2522
|
if (!r) throw this.assetLoader.formatError(n);
|
|
2543
2523
|
if (r.type === "environment" || r.type === "image") return this.loadEnvironment(e);
|
|
2544
2524
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadAssetFromUrl(e, {
|
|
@@ -2552,24 +2532,24 @@ var Zn = class extends L {
|
|
|
2552
2532
|
url: e,
|
|
2553
2533
|
filename: n,
|
|
2554
2534
|
cacheKey: t.cacheKey ?? null,
|
|
2555
|
-
...
|
|
2535
|
+
...Mn(t)
|
|
2556
2536
|
});
|
|
2557
2537
|
return;
|
|
2558
2538
|
}
|
|
2559
2539
|
if (Ne(e)) {
|
|
2560
|
-
let n =
|
|
2540
|
+
let n = Fe(e, { isModel: (e) => this.assetLoader?.getFileFormat(e)?.type === "model" });
|
|
2561
2541
|
if (n.files.length === 0) throw Error(`${n.name} holds no files to load`);
|
|
2562
2542
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadFolder(n, t), {
|
|
2563
2543
|
type: g.MODEL_LOADED,
|
|
2564
2544
|
filename: n.name
|
|
2565
2545
|
}, async () => {
|
|
2566
|
-
let e = await
|
|
2546
|
+
let e = await Me(n);
|
|
2567
2547
|
return {
|
|
2568
2548
|
kind: "local-folder",
|
|
2569
2549
|
folder: e,
|
|
2570
2550
|
key: O(e),
|
|
2571
2551
|
...n.flat ? { flat: !0 } : {},
|
|
2572
|
-
...
|
|
2552
|
+
...Mn(t)
|
|
2573
2553
|
};
|
|
2574
2554
|
}), this._sceneSourceInput = n;
|
|
2575
2555
|
return;
|
|
@@ -2577,7 +2557,7 @@ var Zn = class extends L {
|
|
|
2577
2557
|
let n = this.assetLoader?.getFileFormat(e?.name || "");
|
|
2578
2558
|
if (!n) throw this.assetLoader.formatError(e?.name || "");
|
|
2579
2559
|
if (n.type !== "environment" && n.type !== "image") {
|
|
2580
|
-
let n =
|
|
2560
|
+
let n = je(e).catch(() => ({
|
|
2581
2561
|
name: e.name,
|
|
2582
2562
|
size: e.size,
|
|
2583
2563
|
lastModified: e.lastModified ?? 0,
|
|
@@ -2592,7 +2572,7 @@ var Zn = class extends L {
|
|
|
2592
2572
|
kind: "local-file",
|
|
2593
2573
|
file: e,
|
|
2594
2574
|
key: e.sample ? O(e) : null,
|
|
2595
|
-
...
|
|
2575
|
+
...Mn(t)
|
|
2596
2576
|
};
|
|
2597
2577
|
}), this._sceneSourceInput = e;
|
|
2598
2578
|
return;
|
|
@@ -2648,11 +2628,13 @@ var Zn = class extends L {
|
|
|
2648
2628
|
}
|
|
2649
2629
|
async _loadWithSceneRebuild(e, t, n = null) {
|
|
2650
2630
|
if (this._loadingInProgress) throw this._busyError("PathTracerApp");
|
|
2651
|
-
this._loadingInProgress = !0, this.assetLoader && (this.assetLoader.maxEnvironmentWidth = this._memorySpill === !0 ?
|
|
2631
|
+
this._loadingInProgress = !0, this.assetLoader && (this.assetLoader.maxEnvironmentWidth = this._memorySpill === !0 ? le : 0);
|
|
2652
2632
|
try {
|
|
2653
|
-
await e(), this._sceneSource = typeof n == "function" ? await n() : n, this._sceneSourceInput = null, this._emissiveSamplingUserSet = !1, this._clearAppendedModels(), this._modelReplaced(), this._planSpill()
|
|
2633
|
+
await e(), this._sceneSource = typeof n == "function" ? await n() : n, this._sceneSourceInput = null, this._emissiveSamplingUserSet = !1, this._clearAppendedModels(), this._modelReplaced(), this._planSpill();
|
|
2634
|
+
let r = await this.loadSceneData({ pendingEnvironment: this._beginSceneMetadataEnvironment() });
|
|
2635
|
+
this._maybeSpill(), this.pipeline?.eventBus.emit("pipeline:lightingChanged"), this._dropDisplay(), this.reset(), this.dispatchEvent(t), this._modelAnnounced(), r && this.assetLoader?.commitPendingGraph(this.sceneModel);
|
|
2654
2636
|
} catch (e) {
|
|
2655
|
-
throw (!e || e.code !== "LOAD_IN_PROGRESS") && this._discardFailedLoad(), e?.code === "ARCHIVE_NEEDS_ELEMENT" ?
|
|
2637
|
+
throw (!e || e.code !== "LOAD_IN_PROGRESS") && this._discardFailedLoad(), e?.code === "ARCHIVE_NEEDS_ELEMENT" ? b() : e?.code !== "LOAD_IN_PROGRESS" && y({
|
|
2656
2638
|
status: `Error: ${e?.message ?? e}`,
|
|
2657
2639
|
failed: !0,
|
|
2658
2640
|
progress: 100
|
|
@@ -2692,7 +2674,7 @@ var Zn = class extends L {
|
|
|
2692
2674
|
};
|
|
2693
2675
|
n.intensity !== void 0 && (r.environmentIntensity = n.intensity, r.backgroundIntensity = n.intensity), n.rotation !== void 0 && (r.environmentRotation = n.rotation), this.settings.setMany(r, {
|
|
2694
2676
|
reset: !1,
|
|
2695
|
-
source:
|
|
2677
|
+
source: Y.SCENE_METADATA
|
|
2696
2678
|
}), this.scene && (this.scene.background = e), this.dispatchEvent({
|
|
2697
2679
|
type: g.SCENE_METADATA_APPLIED,
|
|
2698
2680
|
metadata: t,
|
|
@@ -2709,7 +2691,7 @@ var Zn = class extends L {
|
|
|
2709
2691
|
source: e[t].source
|
|
2710
2692
|
}])), this.settings.setMany(t, {
|
|
2711
2693
|
reset: !1,
|
|
2712
|
-
source:
|
|
2694
|
+
source: Y.SCENE_METADATA
|
|
2713
2695
|
}), this.dispatchEvent({
|
|
2714
2696
|
type: g.SCENE_METADATA_APPLIED,
|
|
2715
2697
|
metadata: this.sceneMetadata,
|
|
@@ -2721,7 +2703,7 @@ var Zn = class extends L {
|
|
|
2721
2703
|
if (!e) return;
|
|
2722
2704
|
this._unlitRestore = null;
|
|
2723
2705
|
let t = this.settings.getEffective();
|
|
2724
|
-
for (let [n, { value: r, source: i }] of Object.entries(e)) t[n]?.source ===
|
|
2706
|
+
for (let [n, { value: r, source: i }] of Object.entries(e)) t[n]?.source === Y.SCENE_METADATA && this.settings.set(n, r, {
|
|
2725
2707
|
reset: !1,
|
|
2726
2708
|
source: i
|
|
2727
2709
|
});
|
|
@@ -2733,7 +2715,7 @@ var Zn = class extends L {
|
|
|
2733
2715
|
}
|
|
2734
2716
|
async loadSceneData({ pendingEnvironment: e = null, keepUserLights: t = !1 } = {}) {
|
|
2735
2717
|
this._releaseSceneState({ keepSelection: !!this._preserveSelectionOnRebuild }), this._tagPrimarySceneObject();
|
|
2736
|
-
let n = new
|
|
2718
|
+
let n = new p("", {
|
|
2737
2719
|
namespace: "scene",
|
|
2738
2720
|
level: "info"
|
|
2739
2721
|
}), r = () => this.stages.pathTracer.environment.envParams.mode === "hdri" ? this.meshScene.environment : null, i = r(), a = null;
|
|
@@ -2761,7 +2743,7 @@ var Zn = class extends L {
|
|
|
2761
2743
|
let e = (this._sdf?.emissiveTriangleBuilder?.emissiveTriangles?.length ?? this._sdf?.emissiveTriangleCount ?? 0) > 0;
|
|
2762
2744
|
this.settings.set("enableEmissiveTriangleSampling", e, { reset: !1 });
|
|
2763
2745
|
}
|
|
2764
|
-
return n.start("Apply settings"), this.settings.applyAll(), this.stages.compositor.setTransparentBackground(this.settings.get("transparentBackground")), n.end("Apply settings"), n.print(this._sceneSummaryParts()),
|
|
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()), b(), this._sceneRebuilt(), this.dispatchEvent({ type: g.SCENE_REBUILD }), !0;
|
|
2765
2747
|
}
|
|
2766
2748
|
_sceneSummaryParts() {
|
|
2767
2749
|
let e = this.stages.pathTracer, t = this._sdf?.instanceTable?.setCount ?? 0, n = this._sdf?.geometryExtractor?.maps?.length ?? 0;
|
|
@@ -2847,16 +2829,16 @@ var Zn = class extends L {
|
|
|
2847
2829
|
}
|
|
2848
2830
|
_sceneBudgets(e) {
|
|
2849
2831
|
return this._memorySpill === !1 || !this.storage ? e : {
|
|
2850
|
-
maxTriangles:
|
|
2832
|
+
maxTriangles: oe,
|
|
2851
2833
|
maxPlacements: me,
|
|
2852
2834
|
...e
|
|
2853
2835
|
};
|
|
2854
2836
|
}
|
|
2855
2837
|
_planSpill() {
|
|
2856
2838
|
let e = this._memorySpill !== !1 && !!this.storage && (this.assetLoader?.animations?.length ?? 0) === 0 && (this._memorySpill === !0 || this._sdf.needsSpill(this.meshScene));
|
|
2857
|
-
this.assetLoader && (this.assetLoader.maxEnvironmentWidth = e ?
|
|
2839
|
+
this.assetLoader && (this.assetLoader.maxEnvironmentWidth = e ? le : 0);
|
|
2858
2840
|
let t = e ? this.meshScene?.environment : null, n = t?.image;
|
|
2859
|
-
return n &&
|
|
2841
|
+
return n && wn(t, le), 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;
|
|
2860
2842
|
}
|
|
2861
2843
|
_progressiveSpill() {
|
|
2862
2844
|
let e = this._spillPlan ?? this._planSpill();
|
|
@@ -2878,7 +2860,7 @@ var Zn = class extends L {
|
|
|
2878
2860
|
_scheduleRespill() {
|
|
2879
2861
|
this._sdf?.spilling && (clearTimeout(this._respillTimer), this._respillTimer = setTimeout(() => {
|
|
2880
2862
|
this._respillTimer = null, this._sdf?.respill().catch((e) => this._issues.warn(C.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`));
|
|
2881
|
-
},
|
|
2863
|
+
}, Nn), this._respillTimer.unref?.());
|
|
2882
2864
|
}
|
|
2883
2865
|
async ensureSceneResident() {
|
|
2884
2866
|
this._sdf?.spilled && await this._sdf.ensureResident(), await this._sdf?.ensureGeometryResident();
|
|
@@ -2913,34 +2895,34 @@ var Zn = class extends L {
|
|
|
2913
2895
|
return this.stages.pathTracer.updateBufferRanges([], this._sdf.takeMoveRanges()), this.reset(!1, { motion: !0 }), this._scheduleRespill(), t;
|
|
2914
2896
|
}
|
|
2915
2897
|
setReservedRenderResolution(e, { allowLower: t = !1 } = {}) {
|
|
2916
|
-
let
|
|
2898
|
+
let n = t ? e : Math.max(e, l);
|
|
2917
2899
|
if (!this.renderer) return this._pendingReservedRenderSize = {
|
|
2918
2900
|
requestedPx: e,
|
|
2919
2901
|
allowLower: t
|
|
2920
|
-
}, Math.max(256, Math.min(r, Math.floor(
|
|
2921
|
-
let
|
|
2922
|
-
if (
|
|
2902
|
+
}, Math.max(256, Math.min(r, Math.floor(n) || 256));
|
|
2903
|
+
let i = this.renderer.backend?.device?.limits?.maxStorageBufferBindingSize || 128 * 1024 * 1024, a = ce(this._hostMemoryGB), o = a.gb >= 8 && i >= 1024 * 1024 * 1024 ? r : 2048, s = c(Math.min(n, o));
|
|
2904
|
+
if (s < Math.floor(e) && this._issues.warn(C.RENDER_RESERVE_CAPPED, `reserved render size ${x.n(e)}px was capped to ${x.n(s)}px by this device's limits — renders above ${x.n(s)}px will be declined` + (a.assumed && a.gb < 8 ? " (host memory unknown, 4 GB assumed: pass hostMemoryGB)" : ""), {
|
|
2923
2905
|
requested: e,
|
|
2924
|
-
applied:
|
|
2925
|
-
deviceMemoryGB:
|
|
2926
|
-
assumed:
|
|
2927
|
-
maxStorageBufferBindingSize:
|
|
2928
|
-
}), (this.stages?.pathTracer?.storageTextures?.writeColor?.image?.width ??
|
|
2906
|
+
applied: s,
|
|
2907
|
+
deviceMemoryGB: a.gb,
|
|
2908
|
+
assumed: a.assumed,
|
|
2909
|
+
maxStorageBufferBindingSize: i
|
|
2910
|
+
}), (this.stages?.pathTracer?.storageTextures?.writeColor?.image?.width ?? s) !== s) {
|
|
2929
2911
|
let e = this.pauseRendering;
|
|
2930
2912
|
this.pauseRendering = !0;
|
|
2931
2913
|
try {
|
|
2932
2914
|
let e = this.renderer.domElement;
|
|
2933
|
-
(e.width >
|
|
2915
|
+
(e.width > s || e.height > s) && this.renderer.setSize(Math.min(e.width, s), Math.min(e.height, s), !1);
|
|
2934
2916
|
for (let e of Object.values(this.stages)) e?.reallocateReservedStorage?.();
|
|
2935
2917
|
} finally {
|
|
2936
2918
|
this.pauseRendering = e;
|
|
2937
2919
|
}
|
|
2938
2920
|
this.reset(), this.dispatchEvent({
|
|
2939
2921
|
type: g.RESERVED_RENDER_SIZE_CHANGED,
|
|
2940
|
-
size:
|
|
2922
|
+
size: s
|
|
2941
2923
|
});
|
|
2942
2924
|
}
|
|
2943
|
-
return
|
|
2925
|
+
return s;
|
|
2944
2926
|
}
|
|
2945
2927
|
_applyPendingReservedRenderSize() {
|
|
2946
2928
|
let e = this._pendingReservedRenderSize;
|
|
@@ -2953,13 +2935,13 @@ var Zn = class extends L {
|
|
|
2953
2935
|
});
|
|
2954
2936
|
}
|
|
2955
2937
|
getReservedRenderResolution() {
|
|
2956
|
-
return
|
|
2938
|
+
return l;
|
|
2957
2939
|
}
|
|
2958
2940
|
_isRenderSizeSupported(e, t) {
|
|
2959
|
-
return e >
|
|
2941
|
+
return e > l || t > l ? (this._issues.record(C.RENDER_SIZE_DECLINED, `render resolution ${e}×${t} exceeds the ${l}px storage reserve — resize ignored, so output stays at the previous size. Raise it with setReservedRenderResolution( ${Math.max(e, t)} ) before init().`, {
|
|
2960
2942
|
width: e,
|
|
2961
2943
|
height: t,
|
|
2962
|
-
reserve:
|
|
2944
|
+
reserve: l
|
|
2963
2945
|
}), !1) : !0;
|
|
2964
2946
|
}
|
|
2965
2947
|
onResize() {
|
|
@@ -3111,7 +3093,7 @@ var Zn = class extends L {
|
|
|
3111
3093
|
let e = this.stages.pathTracer, t = this.color?.status();
|
|
3112
3094
|
return m({
|
|
3113
3095
|
engine: de,
|
|
3114
|
-
three:
|
|
3096
|
+
three: xt,
|
|
3115
3097
|
adapter: this.adapterInfo ?? null,
|
|
3116
3098
|
mode: {
|
|
3117
3099
|
headless: this._headless,
|
|
@@ -3172,50 +3154,55 @@ var Zn = class extends L {
|
|
|
3172
3154
|
if (e !== "linear" && e !== "srgb" && !this.color?.hasConfig) throw Error(`renderToBuffer: colorSpace must be 'linear' or 'srgb' without a colour config loaded, got "${e}"`);
|
|
3173
3155
|
let r = this.stages?.pathTracer, i = r?.storageTextures?.readTarget;
|
|
3174
3156
|
if (!i) throw Error("renderToBuffer: no render target — call init() and render at least one sample");
|
|
3175
|
-
let { width: a, height:
|
|
3157
|
+
let { width: a, height: c } = r, l = !!this.settings.get("transparentBackground");
|
|
3176
3158
|
if (e === "srgb") {
|
|
3177
|
-
let r = n === "display" ? this._displaySource(i) : null,
|
|
3159
|
+
let r = n === "display" ? this._displaySource(i) : null, u = {
|
|
3178
3160
|
exposure: this.renderer.toneMappingExposure,
|
|
3179
3161
|
toneMapping: this.renderer.toneMapping,
|
|
3180
3162
|
saturation: this.settings.get("saturation") ?? 1,
|
|
3181
|
-
preserveAlpha: t,
|
|
3163
|
+
preserveAlpha: t && l,
|
|
3182
3164
|
gain: this._displayGain()
|
|
3183
|
-
},
|
|
3165
|
+
}, d = await this._toneMapOnGPU(r?.texture ?? null, i, a, c, u), f = !d && u.gain?.cpu ? await u.gain.cpu() : null, p = u.gain?.backdrop ?? 0;
|
|
3184
3166
|
return {
|
|
3185
|
-
data:
|
|
3186
|
-
...
|
|
3187
|
-
pixelGain:
|
|
3188
|
-
fn:
|
|
3167
|
+
data: d ?? o(r ? await this._readTexture(r.texture, a, c) : await s(this.renderer, i, a, c), {
|
|
3168
|
+
...u,
|
|
3169
|
+
pixelGain: f || p ? {
|
|
3170
|
+
fn: f,
|
|
3189
3171
|
width: a,
|
|
3190
|
-
height:
|
|
3191
|
-
|
|
3172
|
+
height: c,
|
|
3173
|
+
backdrop: p
|
|
3174
|
+
} : null
|
|
3192
3175
|
}),
|
|
3193
3176
|
width: a,
|
|
3194
|
-
height:
|
|
3177
|
+
height: c,
|
|
3195
3178
|
colorSpace: e,
|
|
3196
3179
|
source: r?.source ?? "accumulation",
|
|
3197
|
-
toneMappedOn:
|
|
3180
|
+
toneMappedOn: d ? "gpu" : "cpu"
|
|
3198
3181
|
};
|
|
3199
3182
|
}
|
|
3200
|
-
let { data:
|
|
3201
|
-
data: await
|
|
3183
|
+
let { data: u, source: d } = n === "display" ? await this._readDisplaySource(i, a, c) : {
|
|
3184
|
+
data: await s(this.renderer, i, a, c),
|
|
3202
3185
|
source: "accumulation"
|
|
3203
3186
|
};
|
|
3187
|
+
if (!l) {
|
|
3188
|
+
let e = u instanceof Uint16Array ? 15360 : 1;
|
|
3189
|
+
for (let t = 3; t < u.length; t += 4) u[t] = e;
|
|
3190
|
+
}
|
|
3204
3191
|
if (e === "linear") return {
|
|
3205
|
-
data:
|
|
3192
|
+
data: u,
|
|
3206
3193
|
width: a,
|
|
3207
|
-
height:
|
|
3194
|
+
height: c,
|
|
3208
3195
|
colorSpace: e,
|
|
3209
3196
|
workingSpace: this.color?.workingSpace ?? null,
|
|
3210
|
-
source:
|
|
3197
|
+
source: d
|
|
3211
3198
|
};
|
|
3212
|
-
let { rgba:
|
|
3199
|
+
let { rgba: f, colorSpace: p } = this.color.exportPixels(u, e);
|
|
3213
3200
|
return {
|
|
3214
|
-
data:
|
|
3201
|
+
data: f,
|
|
3215
3202
|
width: a,
|
|
3216
|
-
height:
|
|
3217
|
-
colorSpace:
|
|
3218
|
-
source:
|
|
3203
|
+
height: c,
|
|
3204
|
+
colorSpace: p,
|
|
3205
|
+
source: d
|
|
3219
3206
|
};
|
|
3220
3207
|
}
|
|
3221
3208
|
async _toneMapOnGPU(e, t, n, r, i) {
|
|
@@ -3223,9 +3210,9 @@ var Zn = class extends L {
|
|
|
3223
3210
|
if (!a?.device) return this._toneMapFallback("the renderer has no WebGPU device");
|
|
3224
3211
|
try {
|
|
3225
3212
|
let o = e ? this._readbackPass().draw(e, n, r).texture : t.textures[0], s = a.get(o).texture;
|
|
3226
|
-
return s ? (this._readbackToneMapper ??= new
|
|
3213
|
+
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");
|
|
3227
3214
|
} catch (e) {
|
|
3228
|
-
if (e instanceof
|
|
3215
|
+
if (e instanceof be) throw e;
|
|
3229
3216
|
return this._toneMapFallback("the GPU pass threw", e);
|
|
3230
3217
|
} finally {
|
|
3231
3218
|
this._readbackToneMapper?.release(), e && this._textureReadback?.release();
|
|
@@ -3363,7 +3350,7 @@ var Zn = class extends L {
|
|
|
3363
3350
|
}
|
|
3364
3351
|
getSceneMinY() {
|
|
3365
3352
|
if (!this.meshScene) return 0;
|
|
3366
|
-
let e = new
|
|
3353
|
+
let e = new nt().setFromObject(this.meshScene);
|
|
3367
3354
|
return Number.isFinite(e.min.y) ? e.min.y : 0;
|
|
3368
3355
|
}
|
|
3369
3356
|
getMaterialProperty(e, t) {
|
|
@@ -3373,7 +3360,7 @@ var Zn = class extends L {
|
|
|
3373
3360
|
return this.stages.pathTracer?.materialData.getMaterialPropertySource(e, t);
|
|
3374
3361
|
}
|
|
3375
3362
|
setMaterialProperty(e, t, n) {
|
|
3376
|
-
if (this._sdf?.spilled &&
|
|
3363
|
+
if (this._sdf?.spilled && ee.has(t)) {
|
|
3377
3364
|
this.ensureSceneResident().then(() => this.setMaterialProperty(e, t, n));
|
|
3378
3365
|
return;
|
|
3379
3366
|
}
|
|
@@ -3436,12 +3423,12 @@ var Zn = class extends L {
|
|
|
3436
3423
|
data: await this._readTexture(r.texture, t, n),
|
|
3437
3424
|
source: r.source
|
|
3438
3425
|
} : {
|
|
3439
|
-
data: await
|
|
3426
|
+
data: await s(this.renderer, e, t, n),
|
|
3440
3427
|
source: "accumulation"
|
|
3441
3428
|
};
|
|
3442
3429
|
}
|
|
3443
3430
|
_readbackPass() {
|
|
3444
|
-
return this._textureReadback ??= new
|
|
3431
|
+
return this._textureReadback ??= new f(this.renderer);
|
|
3445
3432
|
}
|
|
3446
3433
|
_readTexture(e, t, n) {
|
|
3447
3434
|
return this._readbackPass().read(e, t, n);
|
|
@@ -3452,10 +3439,10 @@ var Zn = class extends L {
|
|
|
3452
3439
|
n.__rayzeeOriginalColorSpace === void 0 && (n.__rayzeeOriginalColorSpace = e.colorSpace);
|
|
3453
3440
|
let r = n.__rayzeeOriginalColorSpace;
|
|
3454
3441
|
if (delete n.ocioColorSpace, delete n.__rayzeeColorSpaceChoice, t == null) e.colorSpace = r, delete n.__rayzeeOriginalColorSpace;
|
|
3455
|
-
else if (t === "srgb" || t === "linear") e.colorSpace = t === "srgb" ?
|
|
3442
|
+
else if (t === "srgb" || t === "linear") e.colorSpace = t === "srgb" ? We : Be, n.__rayzeeColorSpaceChoice = t;
|
|
3456
3443
|
else {
|
|
3457
3444
|
if (!this.color?.hasConfig) throw Error(`"${t}" needs a colour config loaded`);
|
|
3458
|
-
n.ocioColorSpace = t, e.colorSpace =
|
|
3445
|
+
n.ocioColorSpace = t, e.colorSpace = We;
|
|
3459
3446
|
}
|
|
3460
3447
|
e.needsUpdate = !0, this.stages.pathTracer?.sdfs && await this.rebuildMaterials();
|
|
3461
3448
|
}
|
|
@@ -3485,14 +3472,18 @@ var Zn = class extends L {
|
|
|
3485
3472
|
async rebuildMaterials(e) {
|
|
3486
3473
|
await this.ensureSceneResident();
|
|
3487
3474
|
let t = this.stages.pathTracer;
|
|
3488
|
-
await t?.rebuildMaterials(e || this.meshScene), t?.triangleStorageNode?.withoutUV && this._sdf?.triangles &&
|
|
3475
|
+
await t?.rebuildMaterials(e || this.meshScene), t?.triangleStorageNode?.withoutUV && this._sdf?.triangles && re(e || this.meshScene) && (this._sdf.textureCoordinates = !0, t.setTriangleData(this._sdf.triangles, this._sdf.triangleCount, { textureCoordinates: !0 }), t.setupMaterial()), this.reset();
|
|
3489
3476
|
}
|
|
3490
3477
|
async _initRenderer() {
|
|
3491
|
-
|
|
3492
|
-
let e =
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3478
|
+
fe((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
|
+
let e = null, t;
|
|
3480
|
+
try {
|
|
3481
|
+
e = await navigator.gpu.requestAdapter({ powerPreference: "high-performance" });
|
|
3482
|
+
} catch (e) {
|
|
3483
|
+
t = e;
|
|
3484
|
+
}
|
|
3485
|
+
e || this._issues.fail(C.ADAPTER_UNAVAILABLE, `no WebGPU adapter${t ? ": " + t.message : ""}`, {}, t), this.adapterInfo = Vn(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
|
+
let n = e.limits, r = { maxColorAttachmentBytesPerSample: 128 };
|
|
3496
3487
|
for (let e of [
|
|
3497
3488
|
"maxBufferSize",
|
|
3498
3489
|
"maxStorageBufferBindingSize",
|
|
@@ -3506,26 +3497,39 @@ var Zn = class extends L {
|
|
|
3506
3497
|
"maxComputeWorkgroupSizeY",
|
|
3507
3498
|
"maxComputeWorkgroupSizeZ"
|
|
3508
3499
|
]) {
|
|
3509
|
-
let
|
|
3510
|
-
|
|
3500
|
+
let t = n[e];
|
|
3501
|
+
t !== void 0 && (r[e] = t);
|
|
3511
3502
|
}
|
|
3512
|
-
|
|
3503
|
+
r.maxStorageBuffersPerShaderStage = Math.min(n.maxStorageBuffersPerShaderStage, 10);
|
|
3504
|
+
let i;
|
|
3505
|
+
try {
|
|
3506
|
+
i = await e.requestDevice({
|
|
3507
|
+
requiredFeatures: zn.filter((t) => e.features.has(t)),
|
|
3508
|
+
requiredLimits: r
|
|
3509
|
+
});
|
|
3510
|
+
} catch (e) {
|
|
3511
|
+
this._issues.fail(C.DEVICE_UNAVAILABLE, `WebGPU device request failed: ${e.message}`, { adapter: { ...this.adapterInfo } }, e);
|
|
3512
|
+
}
|
|
3513
|
+
this.renderer = new Ke({
|
|
3513
3514
|
canvas: this.canvas,
|
|
3514
3515
|
alpha: !0,
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3516
|
+
device: i
|
|
3517
|
+
});
|
|
3518
|
+
try {
|
|
3519
|
+
await In(this.renderer, this._headless);
|
|
3520
|
+
} catch (e) {
|
|
3521
|
+
throw i.destroy(), e;
|
|
3522
|
+
}
|
|
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 }, Rn(i, this._deviceLostHolder), i.onuncapturederror = (e) => $.error("WebGPU uncaptured error:", e.error)), Ue.setLTC(Et.init()), this.renderer.outputColorSpace = We, this.renderer.toneMapping = Ae, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1), this.color.attachRenderer(this.renderer);
|
|
3520
3524
|
}
|
|
3521
3525
|
_initScenes() {
|
|
3522
|
-
this.scene = new
|
|
3526
|
+
this.scene = new H(), this.meshScene = new H(), this._sceneHelpers = new Mt();
|
|
3523
3527
|
}
|
|
3524
3528
|
_initAssetPipeline() {
|
|
3525
|
-
this._sdf = new
|
|
3529
|
+
this._sdf = new u({
|
|
3526
3530
|
issues: this._issues,
|
|
3527
3531
|
...this._maxSceneBytes === void 0 ? {} : { maxSceneBytes: this._maxSceneBytes }
|
|
3528
|
-
}), this.assetLoader = new
|
|
3532
|
+
}), this.assetLoader = new Cn(this.meshScene, this.camera, null, {
|
|
3529
3533
|
issues: this._issues,
|
|
3530
3534
|
areaLightIntensityScale: () => this.settings.get("areaLightIntensityScale")
|
|
3531
3535
|
}), this.assetLoader.setRenderer(this.renderer), this.assetLoader.createFloorPlane();
|
|
@@ -3540,7 +3544,7 @@ var Zn = class extends L {
|
|
|
3540
3544
|
this._displayWidth = n, this._displayHeight = r, this._renderWidth = n, this._renderHeight = r, this.pipeline.setSize(n, r);
|
|
3541
3545
|
}
|
|
3542
3546
|
async _initManagers() {
|
|
3543
|
-
this.lightManager = new
|
|
3547
|
+
this.lightManager = new jn(this.scene, this._sceneHelpers, this.stages.pathTracer, {
|
|
3544
3548
|
onReset: () => this.reset(),
|
|
3545
3549
|
onLightRemoved: (e) => this._lightRemoved(e)
|
|
3546
3550
|
}), 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();
|
|
@@ -3548,10 +3552,10 @@ var Zn = class extends L {
|
|
|
3548
3552
|
_wireEvents() {
|
|
3549
3553
|
this.settings.bind(this._settingsBindings()), this.renderer.toneMappingExposure = this.settings.get("exposure") ?? 1, this.onResize(), this.resizeHandler = () => this.onResize(), this._autoResize && this._addTrackedListener(window, "resize", this.resizeHandler), this._onAssetLoaded = async (e) => {
|
|
3550
3554
|
if (!this._loadingInProgress && !(this._applyingSceneMetadata && e.texture)) {
|
|
3551
|
-
if (e.model) this._clearAppendedModels(), await this.loadSceneData({ pendingEnvironment: this._beginSceneMetadataEnvironment() });
|
|
3555
|
+
if (e.model) this._clearAppendedModels(), await this.loadSceneData({ pendingEnvironment: this._beginSceneMetadataEnvironment() }) && this.assetLoader?.commitPendingGraph(e.model);
|
|
3552
3556
|
else if (e.texture) {
|
|
3553
3557
|
let e = this.meshScene.environment;
|
|
3554
|
-
e && this.stages.pathTracer && await this.stages.pathTracer.environment.setEnvironmentMap(e),
|
|
3558
|
+
e && this.stages.pathTracer && await this.stages.pathTracer.environment.setEnvironmentMap(e), b();
|
|
3555
3559
|
}
|
|
3556
3560
|
this.pauseRendering = !1, this.reset();
|
|
3557
3561
|
}
|
|
@@ -3561,10 +3565,10 @@ var Zn = class extends L {
|
|
|
3561
3565
|
}));
|
|
3562
3566
|
}
|
|
3563
3567
|
_createStages() {
|
|
3564
|
-
this.stages.pathTracer = new
|
|
3568
|
+
this.stages.pathTracer = new d(this.renderer, this.scene, this.camera, {
|
|
3565
3569
|
hostMemoryGB: this._hostMemoryGB,
|
|
3566
3570
|
sortMaterials: this.settings.get("wavefrontSortMaterials")
|
|
3567
|
-
}), this._extraStages = this._createExtraStages(), this.stages.compositor = new
|
|
3571
|
+
}), this._extraStages = this._createExtraStages(), this.stages.compositor = new Nt(this.renderer, {
|
|
3568
3572
|
saturation: this.settings.get("saturation") ?? _.saturation,
|
|
3569
3573
|
pathTracer: this.stages.pathTracer,
|
|
3570
3574
|
displaySources: this._displaySources()
|
|
@@ -3580,7 +3584,7 @@ var Zn = class extends L {
|
|
|
3580
3584
|
if (e) for (let n of t) this._addTrackedListener(e, n, (e) => this.dispatchEvent(e));
|
|
3581
3585
|
}
|
|
3582
3586
|
_createCamera() {
|
|
3583
|
-
let e = new
|
|
3587
|
+
let e = new On(60, this.canvas.clientWidth / this.canvas.clientHeight || 1, .01, 1e3);
|
|
3584
3588
|
return e.position.set(0, 0, 5), e;
|
|
3585
3589
|
}
|
|
3586
3590
|
_createExtraStages() {
|
|
@@ -3650,4 +3654,4 @@ var Zn = class extends L {
|
|
|
3650
3654
|
_disposeExtensions() {}
|
|
3651
3655
|
};
|
|
3652
3656
|
//#endregion
|
|
3653
|
-
export {
|
|
3657
|
+
export { Pt as _, an as a, J as c, q as d, tn as f, Rt as g, zt as h, On as i, nn as l, Bt as m, Vn as n, Y as o, Gt as p, jn as r, G as s, Hn as t, en as u };
|