rayzee 9.5.0 → 11.0.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 +22 -20
- package/dist/{ArchiveImporter-xuUJiklP.js → ArchiveImporter-BRQvLggb.js} +12 -13
- package/dist/{BidirectionalIntegrator-C5PKjJoT.js → BidirectionalIntegrator-9lZQxFVH.js} +87 -87
- package/dist/BufferLayout-D_IBo2ci.js +150 -0
- package/dist/{ColorManagement-CheBCPaW.js → ColorManagement-oeEk7oSu.js} +171 -171
- package/dist/{NeuralRetouch-CW11yLZ_.js → NeuralRetouch-BCXylThH.js} +3 -3
- package/dist/{NeuralSuperRes-BekaecYg.js → NeuralSuperRes-sZAeS142.js} +3 -3
- package/dist/{PathTracer-Ccl9KOuF.js → PathTracer-CQPW06Mm.js} +2911 -2669
- package/dist/{PhysicalSky-Dv2PMFGW.js → PhysicalSky-BvqCw_dy.js} +2 -2
- package/dist/{RayzeeRenderer-BQxnzCTD.js → RayzeeRenderer-COpwotpU.js} +338 -329
- package/dist/{SolarLimb-ken-JbDK.js → SolarLimb-CPaeZVwz.js} +10 -10
- package/dist/{ToneMapGPU-BHi5JzIq.js → ToneMapGPU-CjU3osDd.js} +1 -1
- package/dist/{ViewTransforms-D0rTLBsX.js → ViewTransforms-CYN7bq2w.js} +2 -2
- 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/rayzee-core.es.js +11 -11
- package/dist/rayzee.es.js +734 -599
- package/dist/rayzee.umd.js +102 -102
- package/dist/sceneCachePolicy-BSSsKY98.js +443 -0
- package/package.json +1 -1
- package/src/Color/ViewTransforms.js +5 -1
- package/src/EngineDefaults.js +59 -1032
- package/src/Headless.js +6 -5
- package/src/Passes/OIDNTemporalHistory.js +1 -1
- package/src/PathTracerApp.js +5 -3
- package/src/Processor/AssetLoader.js +6 -5
- package/src/Processor/BVHBuilder.js +10 -31
- package/src/Processor/BVHLeafFold.js +4 -6
- package/src/Processor/BVHRefitter.js +3 -46
- package/src/Processor/BufferLayout.js +291 -0
- package/src/Processor/EmissiveTriangleBuilder.js +1 -1
- package/src/Processor/GeometryExtractor.js +3 -3
- package/src/Processor/HostMemory.js +7 -1
- package/src/Processor/InstanceTable.js +1 -1
- package/src/Processor/MaterialPacking.js +2 -1
- package/src/Processor/PBRT/PBRTSceneBuilder.js +1 -1
- package/src/Processor/QueueManager.js +28 -3
- package/src/Processor/SceneProcessor.js +4 -2
- package/src/Processor/SplitBLAS.js +1 -1
- package/src/Processor/StorageTexturePool.js +22 -1
- package/src/Processor/TLASBuilder.js +1 -3
- package/src/Processor/TextureBuckets.js +237 -0
- package/src/Processor/TextureCreator.js +10 -1
- package/src/Processor/Workers/TexturesWorker.js +5 -6
- package/src/RayzeeRenderer.js +29 -32
- package/src/RenderSettings.js +26 -28
- package/src/Stages/ASVGF.js +8 -7
- package/src/Stages/AutoExposure.js +14 -5
- package/src/Stages/BilateralFilter.js +2 -1
- package/src/Stages/DenoiserSettings.js +182 -0
- package/src/Stages/EdgeFilter.js +2 -1
- package/src/Stages/MotionVector.js +1 -1
- package/src/Stages/NRD.js +2 -3
- package/src/Stages/NormalDepth.js +3 -2
- package/src/Stages/PathTracer.js +72 -4
- package/src/Stages/PathTracerStage.js +2 -1
- package/src/Stages/Variance.js +1 -1
- package/src/TSL/BVHTraversal.js +4 -1
- package/src/TSL/Common.js +1 -1
- package/src/TSL/EmissiveSampling.js +1 -1
- package/src/TSL/LightVisibility.js +111 -0
- package/src/TSL/LightsSampling.js +151 -15
- package/src/TSL/Random.js +1 -1
- package/src/TSL/ShadeKernel.js +88 -3
- package/src/TSL/TextureSampling.js +1 -1
- package/src/core.js +5 -9
- package/src/index.js +10 -21
- package/src/integrators/BidirectionalIntegrator.js +2 -1
- package/src/managers/CameraManager.js +17 -7
- package/src/managers/DenoisingManager.js +14 -10
- package/src/managers/EnvironmentManager.js +32 -13
- package/src/managers/MaterialDataManager.js +3 -3
- package/src/managers/UniformManager.js +2 -2
- package/dist/EngineDefaults-DH3bI5t-.js +0 -844
- package/dist/sceneCachePolicy-BmwYOYDu.js +0 -183
- /package/dist/{Logger-BnHghprG.js → Logger-dDDGj9Av.js} +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { dt as e } from "./SolarLimb-
|
|
2
|
-
import {
|
|
3
|
-
import { n as
|
|
4
|
-
import { _ as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { i as _e, n as
|
|
1
|
+
import { dt as e } from "./SolarLimb-CPaeZVwz.js";
|
|
2
|
+
import { Bt as t, Et as n, It as r, Lt as i, Tt as a, Vt as o, _t as s, bt as c, ct as l, gt as u, ht as d, n as f, ot as ee, st as p, vt as m, xt as h, zt as te } from "./PathTracer-CQPW06Mm.js";
|
|
3
|
+
import { n as ne, t as g } from "./EngineEvents-Ci8dVWCP.js";
|
|
4
|
+
import { A as _, C as re, D as v, E as ie, O as ae, T as oe, d as se, g as ce, j as le, l as ue, r as de, u as fe, w as pe } from "./sceneCachePolicy-BSSsKY98.js";
|
|
5
|
+
import { i as y, r as me } from "./Logger-dDDGj9Av.js";
|
|
6
|
+
import { n as he, s as ge } from "./BufferLayout-D_IBo2ci.js";
|
|
7
|
+
import { i as _e, n as b, t as ve } from "./EngineIssues-CIZnXHsF.js";
|
|
8
8
|
import { n as ye, r as be } from "./shared-BGBcSxBQ.js";
|
|
9
9
|
import { a as xe } from "./WorkingMatrix-C6y233hT.js";
|
|
10
|
-
import { i as
|
|
11
|
-
import { n as
|
|
12
|
-
import {
|
|
13
|
-
import { n as
|
|
14
|
-
import { t as
|
|
15
|
-
import { n as
|
|
16
|
-
import { LinearSRGBColorSpace as
|
|
17
|
-
import { Fn as
|
|
18
|
-
import { Box3 as
|
|
10
|
+
import { i as x, r as Se, t as S } from "./ActiveColor-YvuQq44O.js";
|
|
11
|
+
import { n as C, r as Ce } from "./AssetConfig-DSEntE65.js";
|
|
12
|
+
import { d as we, l as Te, m as Ee, p as De, t as Oe, u as w } from "./ViewTransforms-CYN7bq2w.js";
|
|
13
|
+
import { n as ke, r as T } from "./identity-DrQsGT2o.js";
|
|
14
|
+
import { t as Ae } from "./ToneMapGPU-CjU3osDd.js";
|
|
15
|
+
import { n as je } from "./archiveFormats-BZw7TiDp.js";
|
|
16
|
+
import { LinearSRGBColorSpace as Me, MeshBasicNodeMaterial as Ne, NodeMaterial as Pe, QuadMesh as E, RectAreaLightNode as Fe, SRGBColorSpace as Ie, TextureNode as Le, WebGPURenderer as Re } from "three/webgpu";
|
|
17
|
+
import { Fn as ze, If as Be, cubeTexture as Ve, dot as He, float as D, int as O, ivec2 as Ue, mix as k, screenCoordinate as We, select as A, storage as Ge, texture as Ke, uint as qe, uniform as j, uv as M, vec3 as N, vec4 as Je } from "three/tsl";
|
|
18
|
+
import { Box3 as Ye, BufferGeometry as Xe, CircleGeometry as Ze, Color as P, DataTexture as Qe, DirectionalLight as $e, DirectionalLightHelper as et, EquirectangularReflectionMapping as tt, EventDispatcher as F, FloatType as nt, LinearFilter as rt, LinearSRGBColorSpace as it, LoaderUtils as I, LoadingManager as at, MathUtils as L, Mesh as ot, MeshPhysicalMaterial as st, NearestFilter as ct, NoBlending as lt, NoToneMapping as ut, Object3D as R, OrthographicCamera as dt, PerspectiveCamera as ft, PointLight as pt, PointLightHelper as mt, REVISION as ht, RGBAFormat as gt, RectAreaLight as z, RenderTarget as _t, SRGBColorSpace as B, Scene as vt, SpotLight as yt, SpotLightHelper as bt, TextureLoader as xt, UnsignedByteType as St, Vector2 as Ct, Vector3 as V } from "three";
|
|
19
19
|
import { RectAreaLightTexturesLib as wt } from "three/addons/lights/RectAreaLightTexturesLib.js";
|
|
20
20
|
import { RectAreaLightHelper as Tt } from "three/addons/helpers/RectAreaLightHelper.js";
|
|
21
21
|
import { GLTFLoader as Et } from "three/addons/loaders/GLTFLoader.js";
|
|
@@ -66,13 +66,13 @@ var At = class {
|
|
|
66
66
|
return e.isRectAreaLight ? new Tt(e) : e.isPointLight ? new mt(e, .5) : e.isSpotLight ? new bt(e) : e.isDirectionalLight ? new et(e, .5) : null;
|
|
67
67
|
}
|
|
68
68
|
}, jt = class extends t {
|
|
69
|
-
constructor(t,
|
|
69
|
+
constructor(t, n = {}) {
|
|
70
70
|
super("Compositor", {
|
|
71
|
-
...
|
|
72
|
-
executionMode:
|
|
73
|
-
}), this.renderer = t, this._lightSources = [...
|
|
74
|
-
let
|
|
75
|
-
this.compositorMaterial = new
|
|
71
|
+
...n,
|
|
72
|
+
executionMode: o.ALWAYS
|
|
73
|
+
}), this.renderer = t, this._lightSources = [...n.displaySources ?? [], "pathtracer:color"], this.saturation = j(n.saturation ?? 1), this._transparentBackground = j(0, "int"), this._pathTracer = n.pathTracer ?? null, this._convergenceOverlay = !1, this._debugMaterial = null, this._debugQuad = null, this._debugTexNode = null, this._debugM2Attr = null, this._debugMaskAttr = null, this._debugExposureComp = j(1), this._sourceTexNode = new Le();
|
|
74
|
+
let r = this._sourceTexNode.sample(M()), i = k(N(He(r.xyz, e)), r.xyz, this.saturation), a = A(this._transparentBackground, r.w, 1);
|
|
75
|
+
this.compositorMaterial = new Ne(), this.compositorMaterial.colorNode = Je(i, a), this.compositorMaterial.blending = lt, this.compositorQuad = new E(this.compositorMaterial);
|
|
76
76
|
}
|
|
77
77
|
resolveLightTexture(e) {
|
|
78
78
|
return this.resolveLightSource(e)?.texture ?? null;
|
|
@@ -91,17 +91,17 @@ var At = class {
|
|
|
91
91
|
let t = this._pathTracer?.getConvergenceDebugSource?.();
|
|
92
92
|
if (!t) return !1;
|
|
93
93
|
if (this._debugMaterial && this._debugM2Attr === t.m2 && this._debugMaskAttr === t.frozenMask) return !0;
|
|
94
|
-
this._debugMaterial?.dispose(), this._debugTexNode?.dispose(), this._debugM2Attr = t.m2, this._debugMaskAttr = t.frozenMask, this._debugTexNode = new
|
|
95
|
-
let n =
|
|
96
|
-
let n =
|
|
97
|
-
return
|
|
98
|
-
let e =
|
|
99
|
-
h.assign(
|
|
100
|
-
}),
|
|
101
|
-
h.assign(
|
|
94
|
+
this._debugMaterial?.dispose(), this._debugTexNode?.dispose(), this._debugM2Attr = t.m2, this._debugMaskAttr = t.frozenMask, this._debugTexNode = new Le();
|
|
95
|
+
let n = ze(() => {
|
|
96
|
+
let n = He(this._debugTexNode.sample(M()).toVar().xyz, e).toVar(), r = t.renderWidth, i = t.renderHeight, a = O(M().x.mul(D(r))).min(r.sub(O(1))).max(O(0)), o = qe(O(M().y.mul(D(i))).min(i.sub(O(1))).max(O(0)).mul(r).add(a)).toVar(), s = Ge(t.m2, "float").toReadOnly().element(o).toVar(), c = Ge(t.frozenMask, "uint").toReadOnly().element(o).toVar(), l = s.sub(n.mul(n)).max(D(0)).div(D(t.frame).add(1)).sqrt().toVar(), u = t.usePixelFreeze.greaterThan(O(0)), d = A(n.lessThan(D(1)), n.sqrt(), n).toVar(), f = A(u, l.div(n.add(D(1e-4))), l.div(d.add(D(1e-4)))).toVar(), ee = A(u, t.pixelFreezeThreshold, t.noiseThreshold).toVar(), p = f.div(ee.max(D(1e-6))).toVar(), m = N(n.div(n.add(D(1))).sqrt().mul(.55)).toVar(), h = m.toVar(), te = D(t.frame).greaterThanEqual(D(t.adaptiveMinSamples));
|
|
97
|
+
return Be(p.greaterThanEqual(D(1)).or(te.not()), () => {
|
|
98
|
+
let e = k(N(1, .8, .1), N(1, .1, .05), p.sub(1).div(3).clamp(0, 1));
|
|
99
|
+
h.assign(k(m, e, .85));
|
|
100
|
+
}), Be(c.equal(qe(1)).and(u), () => {
|
|
101
|
+
h.assign(k(m, N(.1, .45, 1), .55));
|
|
102
102
|
}), h;
|
|
103
103
|
});
|
|
104
|
-
return this._debugMaterial = new
|
|
104
|
+
return this._debugMaterial = new Ne(), this._debugMaterial.colorNode = Je(n().pow(2.2).mul(this._debugExposureComp), 1), this._debugMaterial.blending = lt, this._debugQuad = new E(this._debugMaterial), !0;
|
|
105
105
|
}
|
|
106
106
|
render(e) {
|
|
107
107
|
if (!this.enabled) return;
|
|
@@ -346,7 +346,7 @@ var Ut = class {
|
|
|
346
346
|
_reportStageFailure(e, t, n) {
|
|
347
347
|
console.error(`[Pipeline] Error in stage '${e}' (${t}):`, n);
|
|
348
348
|
let r = `${e}:${t}`;
|
|
349
|
-
this._reportedStageFailures.has(r) || (this._reportedStageFailures.add(r), this._issues?.record(
|
|
349
|
+
this._reportedStageFailures.has(r) || (this._reportedStageFailures.add(r), this._issues?.record(b.STAGE_RENDER_FAILED, `stage "${e}" threw during ${t} — the frame is incomplete`, {
|
|
350
350
|
stage: e,
|
|
351
351
|
phase: t,
|
|
352
352
|
cause: String(n?.message ?? n)
|
|
@@ -485,7 +485,7 @@ var Ut = class {
|
|
|
485
485
|
let e = this.getInfo();
|
|
486
486
|
console.group("[Pipeline] Info"), console.log("Stages:", e.stages), console.log("Context Textures:", e.textures), console.log("Context Render Targets:", e.renderTargets), console.log("Context Uniforms:", e.uniforms), console.log("Event Types:", e.events), console.log("State:", e.contextState), console.groupEnd();
|
|
487
487
|
}
|
|
488
|
-
}, Wt =
|
|
488
|
+
}, Wt = me("engine"), Gt = class {
|
|
489
489
|
constructor() {
|
|
490
490
|
this.timeElapsed = 0, this.lastResetTime = performance.now(), this.renderCompleteDispatched = !1, this.budgetOverrun = !1, this._budgetHeldWarned = !1;
|
|
491
491
|
}
|
|
@@ -512,7 +512,7 @@ var Ut = class {
|
|
|
512
512
|
}
|
|
513
513
|
}, Kt = class {
|
|
514
514
|
constructor(e) {
|
|
515
|
-
this.renderer = e, this.target = null, this.material = new
|
|
515
|
+
this.renderer = e, this.target = null, this.material = new Pe(), this.material.name = "rayzee:texture-readback", this.quad = new E(this.material), this._node = null, this._source = null;
|
|
516
516
|
}
|
|
517
517
|
_ensureTarget(e, t) {
|
|
518
518
|
this.target && this.target.width === e && this.target.height === t || (this.target?.dispose(), this.target = new _t(e, t, {
|
|
@@ -531,7 +531,7 @@ var Ut = class {
|
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
533
|
draw(e, t, n) {
|
|
534
|
-
this._ensureTarget(t, n), this._source !== e && (this._node =
|
|
534
|
+
this._ensureTarget(t, n), this._source !== e && (this._node = Ke(e).load(Ue(We.xy)), this.material.outputNode = this._node, this.material.needsUpdate = !0, this._source = e);
|
|
535
535
|
let r = this.renderer.getRenderTarget();
|
|
536
536
|
return this.renderer.setRenderTarget(this.target), this.quad.render(this.renderer), this.renderer.setRenderTarget(r), this.target;
|
|
537
537
|
}
|
|
@@ -687,7 +687,7 @@ function Zt(e, t, n) {
|
|
|
687
687
|
return new J(t).fetch(e, n);
|
|
688
688
|
}
|
|
689
689
|
function Qt() {
|
|
690
|
-
return new J(ye(
|
|
690
|
+
return new J(ye(C().cacheNamespace));
|
|
691
691
|
}
|
|
692
692
|
async function $t(e, { downloads: t = Qt(), ...n } = {}) {
|
|
693
693
|
if (!t._storage || !/^https?:/i.test(e)) return {
|
|
@@ -916,45 +916,54 @@ var en = {
|
|
|
916
916
|
handler: "handleIntegrator",
|
|
917
917
|
reset: !0
|
|
918
918
|
},
|
|
919
|
-
|
|
919
|
+
shadowRays: {
|
|
920
|
+
handler: "handleShadowRays",
|
|
921
|
+
reset: !0
|
|
922
|
+
},
|
|
923
|
+
environmentRotation: { handler: "handleEnvironmentRotation" },
|
|
924
|
+
wavefrontSortMaterials: {
|
|
925
|
+
handler: "handleWavefrontSortMaterials",
|
|
926
|
+
reset: !1
|
|
927
|
+
},
|
|
928
|
+
maxTextureSize: { reset: !1 },
|
|
929
|
+
areaLightIntensityScale: { reset: !1 }
|
|
920
930
|
}, Y = Object.freeze({
|
|
921
931
|
DEFAULT: "default",
|
|
922
932
|
HOST: "host",
|
|
923
933
|
SCENE_METADATA: "scene-metadata",
|
|
924
934
|
MODE_PRESET: "mode-preset"
|
|
925
|
-
}), tn = {
|
|
926
|
-
|
|
927
|
-
debugMode: "visMode"
|
|
928
|
-
}, nn = class extends F {
|
|
929
|
-
constructor(e = v, { issues: t = null } = {}) {
|
|
935
|
+
}), tn = class extends F {
|
|
936
|
+
constructor(e = n, { issues: t = null } = {}) {
|
|
930
937
|
super(), this._issues = t, this._defaults = e, this._routes = new Map(Object.entries(en)), this._values = /* @__PURE__ */ new Map(), this._sources = /* @__PURE__ */ new Map(), this._pathTracer = null, this._resetCallback = null, this._handlers = {}, this._initDefaults(e);
|
|
931
938
|
}
|
|
932
939
|
bind(e) {
|
|
933
940
|
this._pathTracer = e.stages.pathTracer, this._resetCallback = e.resetCallback, this._handlers = this._buildHandlers(e);
|
|
934
941
|
}
|
|
935
|
-
define(e, {
|
|
942
|
+
define(e, { default: t, apply: n, reset: r = !0 }) {
|
|
936
943
|
if (this._routes.has(e)) throw Error(`setting "${e}" is already defined`);
|
|
937
944
|
this._routes.set(e, {
|
|
938
|
-
apply:
|
|
939
|
-
reset:
|
|
940
|
-
})
|
|
945
|
+
apply: n,
|
|
946
|
+
reset: r
|
|
947
|
+
});
|
|
948
|
+
let i = t === void 0 ? this._defaults[e] : t;
|
|
949
|
+
!this._values.has(e) && i !== void 0 && (this._values.set(e, i), this._sources.set(e, Y.DEFAULT));
|
|
941
950
|
}
|
|
942
951
|
_buildHandlers({ stages: e, resetCallback: t, reconcileCompletion: n, applyExposure: r, onCameraProjection: i }) {
|
|
943
|
-
let
|
|
944
|
-
|
|
952
|
+
let o = new Ct(), s = (t, n) => {
|
|
953
|
+
o.set(n?.[0] ?? 0, n?.[1] ?? 0).multiplyScalar(L.DEG2RAD), e.pathTracer?.setUniform(t, o);
|
|
945
954
|
};
|
|
946
955
|
return {
|
|
947
956
|
handleCameraProjection: (t) => {
|
|
948
|
-
e.pathTracer?.setUniform("cameraProjection",
|
|
957
|
+
e.pathTracer?.setUniform("cameraProjection", a[t] ?? a.perspective), i?.(t);
|
|
949
958
|
},
|
|
950
959
|
handleDofMode: (t) => e.pathTracer?.setUniform("dofMode", +(t === "look")),
|
|
951
|
-
handlePanoramaLonRange: (e) =>
|
|
952
|
-
handlePanoramaLatRange: (e) =>
|
|
960
|
+
handlePanoramaLonRange: (e) => s("panoLonRange", e),
|
|
961
|
+
handlePanoramaLatRange: (e) => s("panoLatRange", e),
|
|
953
962
|
handleTransparentBackground: (t) => {
|
|
954
963
|
e.pathTracer?.setUniform("transparentBackground", t), e.compositor?.setTransparentBackground(t);
|
|
955
964
|
},
|
|
956
965
|
handleBackgroundColor: (t) => {
|
|
957
|
-
let n = t?.isColor ? t : new
|
|
966
|
+
let n = t?.isColor ? t : new P(t);
|
|
958
967
|
e.pathTracer?.setUniform("backgroundColor", n);
|
|
959
968
|
},
|
|
960
969
|
handleExposure: (e) => {
|
|
@@ -981,9 +990,15 @@ var en = {
|
|
|
981
990
|
handleIntegrator: (t) => {
|
|
982
991
|
e.pathTracer?.setIntegrator?.(t);
|
|
983
992
|
},
|
|
993
|
+
handleShadowRays: (t) => {
|
|
994
|
+
e.pathTracer?.setShadowRays?.(t);
|
|
995
|
+
},
|
|
984
996
|
handleEnvironmentRotation: (t) => {
|
|
985
997
|
e.pathTracer?.environment.setEnvironmentRotation(t);
|
|
986
998
|
},
|
|
999
|
+
handleWavefrontSortMaterials: (t) => {
|
|
1000
|
+
e.pathTracer && (e.pathTracer.sortMaterials = t);
|
|
1001
|
+
},
|
|
987
1002
|
handleInteractionModeEnabled: (t) => {
|
|
988
1003
|
e.pathTracer?.setInteractionModeEnabled(t);
|
|
989
1004
|
}
|
|
@@ -992,7 +1007,7 @@ var en = {
|
|
|
992
1007
|
set(e, t, { reset: n, silent: r, source: i = Y.HOST } = {}) {
|
|
993
1008
|
let a = this._applyOne(e, t, i);
|
|
994
1009
|
a?.route && ((n === void 0 ? a.route.reset ?? !0 : n) && this._resetCallback?.(), r || this.dispatchEvent({
|
|
995
|
-
type:
|
|
1010
|
+
type: g.SETTING_CHANGED,
|
|
996
1011
|
key: e,
|
|
997
1012
|
value: t,
|
|
998
1013
|
prev: a.prev
|
|
@@ -1003,7 +1018,7 @@ var en = {
|
|
|
1003
1018
|
for (let [n, a] of Object.entries(e)) {
|
|
1004
1019
|
let e = this._applyOne(n, a, r);
|
|
1005
1020
|
e?.route && ((e.route.reset ?? !0) && (i = !0), t || this.dispatchEvent({
|
|
1006
|
-
type:
|
|
1021
|
+
type: g.SETTING_CHANGED,
|
|
1007
1022
|
key: n,
|
|
1008
1023
|
value: a,
|
|
1009
1024
|
prev: e.prev
|
|
@@ -1025,7 +1040,7 @@ var en = {
|
|
|
1025
1040
|
});
|
|
1026
1041
|
}
|
|
1027
1042
|
_reportUnknownKey(e) {
|
|
1028
|
-
this._issues?.record(
|
|
1043
|
+
this._issues?.record(b.SETTING_UNKNOWN_KEY, `unknown setting "${e}" — stored but never applied to any stage`, { key: e });
|
|
1029
1044
|
}
|
|
1030
1045
|
get(e) {
|
|
1031
1046
|
return this._values.get(e);
|
|
@@ -1046,14 +1061,14 @@ var en = {
|
|
|
1046
1061
|
let e = {};
|
|
1047
1062
|
for (let [t, n] of this._values) {
|
|
1048
1063
|
if (this._sources.get(t) !== Y.HOST || !this._routes.has(t)) continue;
|
|
1049
|
-
let
|
|
1050
|
-
|
|
1064
|
+
let r = h(n);
|
|
1065
|
+
r !== void 0 && (e[t] = r);
|
|
1051
1066
|
}
|
|
1052
1067
|
return e;
|
|
1053
1068
|
}
|
|
1054
1069
|
restore(e) {
|
|
1055
1070
|
let t = {}, n = [];
|
|
1056
|
-
for (let [r, i] of Object.entries(e ?? {})) this._routes.has(r) ? t[r] =
|
|
1071
|
+
for (let [r, i] of Object.entries(e ?? {})) this._routes.has(r) ? t[r] = c(i) : n.push(r);
|
|
1057
1072
|
return this.setMany(t), n;
|
|
1058
1073
|
}
|
|
1059
1074
|
applyAll() {
|
|
@@ -1063,15 +1078,14 @@ var en = {
|
|
|
1063
1078
|
}
|
|
1064
1079
|
}
|
|
1065
1080
|
_applyRoute(e, t, n) {
|
|
1066
|
-
e.uniform ? this._pathTracer?.setUniform(e.uniform, t) : e.handler ? this._handlers[e.handler]?.(t, n) : e.apply(t, n);
|
|
1081
|
+
e.uniform ? this._pathTracer?.setUniform(e.uniform, t) : e.handler ? this._handlers[e.handler]?.(t, n) : e.apply?.(t, n);
|
|
1067
1082
|
}
|
|
1068
1083
|
_initDefaults(e) {
|
|
1069
1084
|
for (let t of Object.keys(en)) t in e && (this._values.set(t, e[t]), this._sources.set(t, Y.DEFAULT));
|
|
1070
|
-
for (let [t, n] of Object.entries(tn)) t in e && (this._values.set(n, e[t]), this._sources.set(n, Y.DEFAULT));
|
|
1071
1085
|
}
|
|
1072
|
-
},
|
|
1086
|
+
}, nn = class {
|
|
1073
1087
|
constructor({ issues: e = null } = {}) {
|
|
1074
|
-
this._issues = e, this._renderer = null, this._offRegistry =
|
|
1088
|
+
this._issues = e, this._renderer = null, this._offRegistry = De(() => {
|
|
1075
1089
|
this._renderer && Ee(this._renderer);
|
|
1076
1090
|
});
|
|
1077
1091
|
}
|
|
@@ -1079,7 +1093,7 @@ var en = {
|
|
|
1079
1093
|
return !1;
|
|
1080
1094
|
}
|
|
1081
1095
|
get workingSpace() {
|
|
1082
|
-
return
|
|
1096
|
+
return S;
|
|
1083
1097
|
}
|
|
1084
1098
|
get workingSpaceAdopted() {
|
|
1085
1099
|
return !1;
|
|
@@ -1093,37 +1107,37 @@ var en = {
|
|
|
1093
1107
|
return e.outputColorSpace = B, t;
|
|
1094
1108
|
}
|
|
1095
1109
|
listViews() {
|
|
1096
|
-
return
|
|
1110
|
+
return we();
|
|
1097
1111
|
}
|
|
1098
1112
|
get activeView() {
|
|
1099
1113
|
return null;
|
|
1100
1114
|
}
|
|
1101
1115
|
setActiveView(e) {
|
|
1102
|
-
let t =
|
|
1116
|
+
let t = w(e);
|
|
1103
1117
|
if (!t) throw Error(`no view transform with id ${e}`);
|
|
1104
1118
|
if (t.outputEncoded) throw Error(`"${t.name}" returns display-encoded colour: it needs rayzee/addons/color`);
|
|
1105
1119
|
return this._renderer && (this._renderer.toneMapping = e), t;
|
|
1106
1120
|
}
|
|
1107
1121
|
_publishWorkingMatrix() {
|
|
1108
|
-
xe(null,
|
|
1122
|
+
xe(null, S);
|
|
1109
1123
|
}
|
|
1110
1124
|
loadConfig() {
|
|
1111
1125
|
let e = "colour configs need the OCIO pipeline: renderer.setColorManagement( ColorManagement ), from rayzee/addons/color";
|
|
1112
|
-
return this._issues?.record(
|
|
1126
|
+
return this._issues?.record(b.CAPABILITY_MISSING, e, { capability: "color" }), Promise.reject(Error(e));
|
|
1113
1127
|
}
|
|
1114
1128
|
unloadConfig() {}
|
|
1115
1129
|
setWorkingSpace() {}
|
|
1116
1130
|
exportPixels(e) {
|
|
1117
1131
|
return {
|
|
1118
1132
|
rgba: e,
|
|
1119
|
-
colorSpace:
|
|
1133
|
+
colorSpace: S
|
|
1120
1134
|
};
|
|
1121
1135
|
}
|
|
1122
1136
|
status() {
|
|
1123
|
-
let e = this._renderer ?
|
|
1137
|
+
let e = this._renderer ? w(this._renderer.toneMapping) : null;
|
|
1124
1138
|
return {
|
|
1125
1139
|
config: null,
|
|
1126
|
-
workingSpace:
|
|
1140
|
+
workingSpace: S,
|
|
1127
1141
|
workingSpaceAdopted: !1,
|
|
1128
1142
|
activeTransform: e ? {
|
|
1129
1143
|
id: e.id,
|
|
@@ -1133,23 +1147,23 @@ var en = {
|
|
|
1133
1147
|
activeView: null,
|
|
1134
1148
|
context: null,
|
|
1135
1149
|
exportSpace: null,
|
|
1136
|
-
views:
|
|
1137
|
-
registryVersion:
|
|
1150
|
+
views: we(),
|
|
1151
|
+
registryVersion: Te(),
|
|
1138
1152
|
bakeError: e?.error ?? null
|
|
1139
1153
|
};
|
|
1140
1154
|
}
|
|
1141
1155
|
dispose() {
|
|
1142
|
-
this._offRegistry?.(), this._renderer = null, this._issues = null, Se() === this && (xe(null),
|
|
1156
|
+
this._offRegistry?.(), this._renderer = null, this._issues = null, Se() === this && (xe(null), x(null));
|
|
1143
1157
|
}
|
|
1144
|
-
},
|
|
1158
|
+
}, rn = [
|
|
1145
1159
|
[/\.jpe?g(\?|#|$)/i, "image/jpeg"],
|
|
1146
1160
|
[/\.webp(\?|#|$)/i, "image/webp"],
|
|
1147
1161
|
[/\.avif(\?|#|$)/i, "image/avif"]
|
|
1148
1162
|
];
|
|
1149
|
-
function
|
|
1150
|
-
return e.mimeType ? e.mimeType : e.uri?.startsWith("data:") ? e.uri.slice(5, e.uri.indexOf(";")) :
|
|
1163
|
+
function an(e) {
|
|
1164
|
+
return e.mimeType ? e.mimeType : e.uri?.startsWith("data:") ? e.uri.slice(5, e.uri.indexOf(";")) : rn.find(([t]) => t.test(e.uri ?? ""))?.[1] ?? "image/png";
|
|
1151
1165
|
}
|
|
1152
|
-
function
|
|
1166
|
+
function on(e) {
|
|
1153
1167
|
for (let t = 8; t + 12 <= e.length;) {
|
|
1154
1168
|
let n = (e[t] << 24 | e[t + 1] << 16 | e[t + 2] << 8 | e[t + 3]) >>> 0, r = t + 12 + n;
|
|
1155
1169
|
if (e[t + 4] === 73 && e[t + 5] === 69 && e[t + 6] === 78 && e[t + 7] === 68) return e.subarray(0, r);
|
|
@@ -1157,48 +1171,48 @@ function sn(e) {
|
|
|
1157
1171
|
}
|
|
1158
1172
|
return e;
|
|
1159
1173
|
}
|
|
1160
|
-
function
|
|
1174
|
+
function sn({ data: e, width: t, height: n }, { shared: r = !1 } = {}) {
|
|
1161
1175
|
let i = new Uint8Array(e.buffer, e.byteOffset, t * n * 4), a = i;
|
|
1162
1176
|
r && typeof SharedArrayBuffer < "u" && !(i.buffer instanceof SharedArrayBuffer) && (a = new Uint8Array(new SharedArrayBuffer(i.byteLength)), a.set(i));
|
|
1163
1177
|
let o = new Qe(a, t, n, gt, St);
|
|
1164
1178
|
return o.needsUpdate = !0, o;
|
|
1165
1179
|
}
|
|
1166
|
-
function
|
|
1167
|
-
return
|
|
1180
|
+
function cn(e, t) {
|
|
1181
|
+
return d().decodeImage(t === "image/png" ? on(e) : e, t);
|
|
1168
1182
|
}
|
|
1169
|
-
async function
|
|
1183
|
+
async function ln(e) {
|
|
1170
1184
|
let t = await fetch(e);
|
|
1171
1185
|
if (!t.ok) throw Error(`HTTP ${t.status}`);
|
|
1172
1186
|
return new Uint8Array(await t.arrayBuffer());
|
|
1173
1187
|
}
|
|
1174
|
-
function
|
|
1175
|
-
return t.bufferView === void 0 ?
|
|
1188
|
+
function un(e, t) {
|
|
1189
|
+
return t.bufferView === void 0 ? ln(e.options.manager.resolveURL(I.resolveURL(t.uri, e.options.path))) : e.getDependency("bufferView", t.bufferView).then((e) => new Uint8Array(e));
|
|
1176
1190
|
}
|
|
1177
|
-
var
|
|
1178
|
-
function
|
|
1191
|
+
var dn = (e, t) => !!t && t !== e.textureLoader && typeof t.parse == "function";
|
|
1192
|
+
function fn(e, t, n) {
|
|
1179
1193
|
if (e.sourceCache[t] !== void 0) return e.sourceCache[t].then((e) => e.clone());
|
|
1180
|
-
let r =
|
|
1194
|
+
let r = un(e, e.json.images[t]).then((e) => new Promise((t, r) => {
|
|
1181
1195
|
n.parse(e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength), t, r);
|
|
1182
1196
|
}));
|
|
1183
1197
|
return e.sourceCache[t] = r, r;
|
|
1184
1198
|
}
|
|
1185
|
-
async function
|
|
1186
|
-
let n =
|
|
1199
|
+
async function pn(e, t = an({ uri: e })) {
|
|
1200
|
+
let n = sn(await cn(await ln(e), t));
|
|
1187
1201
|
return n.flipY = !0, n;
|
|
1188
1202
|
}
|
|
1189
|
-
function
|
|
1203
|
+
function mn(e, t = null) {
|
|
1190
1204
|
return e.loadImageSource = function(e, n) {
|
|
1191
|
-
if (
|
|
1205
|
+
if (dn(this, n)) return fn(this, e, n);
|
|
1192
1206
|
let r = this.json.images[e], i = /* @__PURE__ */ Error("no image decoder in this runtime: configurePlatform( nodePlatform( { decodeImage } ) ) — see \"Running in Node\"");
|
|
1193
1207
|
return t?.(r.uri ?? `bufferView ${r.bufferView}`, i), Promise.reject(i);
|
|
1194
1208
|
}, { name: "RAYZEE_missing_image_decoder" };
|
|
1195
1209
|
}
|
|
1196
|
-
function
|
|
1210
|
+
function hn(e, t = null) {
|
|
1197
1211
|
return e.loadImageSource = function(e, n) {
|
|
1198
|
-
if (
|
|
1212
|
+
if (dn(this, n)) return fn(this, e, n);
|
|
1199
1213
|
if (this.sourceCache[e] !== void 0) return this.sourceCache[e].then((e) => e.clone());
|
|
1200
|
-
let r = this.json.images[e], i =
|
|
1201
|
-
let t =
|
|
1214
|
+
let r = this.json.images[e], i = an(r), a = r.uri ?? `bufferView ${r.bufferView}`, o = un(this, r).then((e) => cn(e, i)).then((e) => {
|
|
1215
|
+
let t = sn(e, { shared: !0 });
|
|
1202
1216
|
return r.extras && typeof r.extras == "object" && Object.assign(t.userData, r.extras), t.userData.mimeType = i, t;
|
|
1203
1217
|
}).catch((e) => {
|
|
1204
1218
|
throw t?.(a, e), e;
|
|
@@ -1208,8 +1222,8 @@ function gn(e, t = null) {
|
|
|
1208
1222
|
}
|
|
1209
1223
|
//#endregion
|
|
1210
1224
|
//#region src/Processor/GLTFDiffuseTransmission.js
|
|
1211
|
-
var
|
|
1212
|
-
function
|
|
1225
|
+
var gn = "KHR_materials_diffuse_transmission";
|
|
1226
|
+
function _n(e) {
|
|
1213
1227
|
let t = (t, n, r, i) => {
|
|
1214
1228
|
let a = {};
|
|
1215
1229
|
return e.assignTexture(a, n, r, i).then(() => {
|
|
@@ -1217,7 +1231,7 @@ function vn(e) {
|
|
|
1217
1231
|
});
|
|
1218
1232
|
};
|
|
1219
1233
|
return {
|
|
1220
|
-
name:
|
|
1234
|
+
name: gn,
|
|
1221
1235
|
afterRoot(n) {
|
|
1222
1236
|
let r = e.json.materials ?? [], i = /* @__PURE__ */ new Set(), a = [];
|
|
1223
1237
|
for (let o of n.scenes ?? []) o.traverse((n) => {
|
|
@@ -1225,7 +1239,7 @@ function vn(e) {
|
|
|
1225
1239
|
for (let n of o) {
|
|
1226
1240
|
if (i.has(n)) continue;
|
|
1227
1241
|
i.add(n);
|
|
1228
|
-
let o = e.associations.get(n)?.materials, s = o === void 0 ? null : r[o]?.extensions?.[
|
|
1242
|
+
let o = e.associations.get(n)?.materials, s = o === void 0 ? null : r[o]?.extensions?.[gn];
|
|
1229
1243
|
if (!s) continue;
|
|
1230
1244
|
n.diffuseTransmission = s.diffuseTransmissionFactor ?? 0;
|
|
1231
1245
|
let [c, l, u] = s.diffuseTransmissionColorFactor ?? [
|
|
@@ -1233,7 +1247,7 @@ function vn(e) {
|
|
|
1233
1247
|
1,
|
|
1234
1248
|
1
|
|
1235
1249
|
];
|
|
1236
|
-
n.diffuseTransmissionColor = new
|
|
1250
|
+
n.diffuseTransmissionColor = new P().setRGB(c, l, u, it), s.diffuseTransmissionTexture && a.push(t(n, "diffuseTransmissionMap", s.diffuseTransmissionTexture)), s.diffuseTransmissionColorTexture && a.push(t(n, "diffuseTransmissionColorMap", s.diffuseTransmissionColorTexture, B));
|
|
1237
1251
|
}
|
|
1238
1252
|
});
|
|
1239
1253
|
return Promise.all(a);
|
|
@@ -1242,20 +1256,20 @@ function vn(e) {
|
|
|
1242
1256
|
}
|
|
1243
1257
|
//#endregion
|
|
1244
1258
|
//#region src/Processor/GLTFDecoders.js
|
|
1245
|
-
var
|
|
1246
|
-
function
|
|
1259
|
+
var vn = "KHR_draco_mesh_compression", yn = "KHR_texture_basisu", bn = ["EXT_meshopt_compression", "KHR_meshopt_compression"], xn = new TextDecoder();
|
|
1260
|
+
function Sn(e) {
|
|
1247
1261
|
if (typeof e == "string") return e;
|
|
1248
1262
|
if (!(e instanceof ArrayBuffer)) return JSON.stringify(e?.extensionsUsed ?? []);
|
|
1249
1263
|
let t = new DataView(e);
|
|
1250
|
-
if (!(e.byteLength >= 20 && t.getUint32(0, !0) === 1179937895)) return
|
|
1264
|
+
if (!(e.byteLength >= 20 && t.getUint32(0, !0) === 1179937895)) return xn.decode(e);
|
|
1251
1265
|
let n = Math.min(t.getUint32(12, !0), e.byteLength - 20);
|
|
1252
|
-
return
|
|
1266
|
+
return xn.decode(new Uint8Array(e, 20, n));
|
|
1253
1267
|
}
|
|
1254
|
-
async function
|
|
1255
|
-
let { dracoDecoderPath: r, ktx2TranscoderPath: i } =
|
|
1256
|
-
t.includes(
|
|
1257
|
-
t.includes(
|
|
1258
|
-
|
|
1268
|
+
async function Cn(e, t, n) {
|
|
1269
|
+
let { dracoDecoderPath: r, ktx2TranscoderPath: i } = C(), [a, o, s] = await Promise.all([
|
|
1270
|
+
t.includes(vn) && !e.dracoLoader ? import("three/addons/loaders/DRACOLoader.js") : null,
|
|
1271
|
+
t.includes(yn) && !e.ktx2Loader ? import("three/addons/loaders/KTX2Loader.js") : null,
|
|
1272
|
+
bn.some((e) => t.includes(e)) && !e.meshoptDecoder ? import("three/addons/libs/meshopt_decoder.module.js") : null
|
|
1259
1273
|
]);
|
|
1260
1274
|
if (a) {
|
|
1261
1275
|
let t = new a.DRACOLoader();
|
|
@@ -1274,15 +1288,15 @@ async function wn(e, t, n) {
|
|
|
1274
1288
|
}
|
|
1275
1289
|
s && e.setMeshoptDecoder(s.MeshoptDecoder);
|
|
1276
1290
|
}
|
|
1277
|
-
function
|
|
1291
|
+
function wn(e, t) {
|
|
1278
1292
|
let n = e.parse.bind(e);
|
|
1279
1293
|
return e.parse = (r, i, a, o) => {
|
|
1280
|
-
|
|
1294
|
+
Cn(e, Sn(r), t).then(() => n(r, i, a, o), (e) => o?.(e));
|
|
1281
1295
|
}, e;
|
|
1282
1296
|
}
|
|
1283
1297
|
//#endregion
|
|
1284
1298
|
//#region src/Processor/AssetLoader.js
|
|
1285
|
-
var
|
|
1299
|
+
var Tn = {
|
|
1286
1300
|
glb: {
|
|
1287
1301
|
type: "model",
|
|
1288
1302
|
name: "GLB (GLTF Binary)"
|
|
@@ -1317,7 +1331,7 @@ var En = {
|
|
|
1317
1331
|
}, Z = {
|
|
1318
1332
|
addOn: "rayzee/addons/formats",
|
|
1319
1333
|
install: "assetLoader.registerFormat()"
|
|
1320
|
-
},
|
|
1334
|
+
}, En = {
|
|
1321
1335
|
zip: X,
|
|
1322
1336
|
gz: X,
|
|
1323
1337
|
tgz: X,
|
|
@@ -1334,23 +1348,23 @@ var En = {
|
|
|
1334
1348
|
usdz: Z,
|
|
1335
1349
|
exr: Z
|
|
1336
1350
|
};
|
|
1337
|
-
function
|
|
1338
|
-
let t = new
|
|
1351
|
+
function Dn(e) {
|
|
1352
|
+
let t = new Xe();
|
|
1339
1353
|
for (let n in e.attributes) t.setAttribute(n, e.attributes[n]);
|
|
1340
1354
|
e.index && t.setIndex(e.index);
|
|
1341
1355
|
for (let n of e.groups) t.addGroup(n.start, n.count, n.materialIndex);
|
|
1342
1356
|
return t;
|
|
1343
1357
|
}
|
|
1344
|
-
var
|
|
1345
|
-
function
|
|
1358
|
+
var On = 683;
|
|
1359
|
+
function kn(e, t, n, r) {
|
|
1346
1360
|
if (!(r.normalize ?? !0)) return Math.PI;
|
|
1347
1361
|
let i = r.shape === "ellipse" || r.shape === "disk" ? Math.PI / 4 : 1, a = e.getWorldScale(new V()), o = Math.PI * i * Math.abs(t * a.x * n * a.y);
|
|
1348
1362
|
return Number.isFinite(o) ? o : Math.PI;
|
|
1349
1363
|
}
|
|
1350
|
-
var
|
|
1351
|
-
constructor(e, t,
|
|
1352
|
-
super(), this.scene = e, this.camera = t, this.controls =
|
|
1353
|
-
this._loadCancelled || this._issues?.record(
|
|
1364
|
+
var An = class e extends F {
|
|
1365
|
+
constructor(e, t, r, { issues: i = null, areaLightIntensityScale: a = null } = {}) {
|
|
1366
|
+
super(), this.scene = e, this.camera = t, this.controls = r, this.targetModel = null, this.floorPlane = null, this.sceneScale = 1, this.sceneSize = new V(1, 1, 1), this.loaderCache = {}, this.uploadedFileInfo = null, this.animations = [], this.renderer = null, this.sceneMetadata = null, this._loadingManager = new at(), 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 = i, this._areaLightIntensityScale = a ?? (() => n.areaLightIntensityScale), this._loadingManager.onError = (e) => {
|
|
1367
|
+
this._loadCancelled || this._issues?.record(b.ASSET_UNREACHABLE, `asset "${e}" could not be fetched — anything depending on it renders without it`, { url: e });
|
|
1354
1368
|
};
|
|
1355
1369
|
}
|
|
1356
1370
|
cancelActiveLoad() {
|
|
@@ -1383,7 +1397,7 @@ var jn = class e extends F {
|
|
|
1383
1397
|
return this._appended ? null : this._sourceKey;
|
|
1384
1398
|
}
|
|
1385
1399
|
_keyed(e, t) {
|
|
1386
|
-
return t ? `${e}
|
|
1400
|
+
return t ? `${e}::${t}` : null;
|
|
1387
1401
|
}
|
|
1388
1402
|
get downloads() {
|
|
1389
1403
|
return this._downloads?._storage !== this.storage && (this._downloads = new J(this.storage)), this._downloads;
|
|
@@ -1398,7 +1412,7 @@ var jn = class e extends F {
|
|
|
1398
1412
|
_downloadProgress(e, t) {
|
|
1399
1413
|
return (n) => {
|
|
1400
1414
|
let r = n?.loaded || 0, i = n?.lengthComputable && n.total || 0;
|
|
1401
|
-
|
|
1415
|
+
_({
|
|
1402
1416
|
isLoading: !0,
|
|
1403
1417
|
status: e,
|
|
1404
1418
|
loadedBytes: r,
|
|
@@ -1409,7 +1423,7 @@ var jn = class e extends F {
|
|
|
1409
1423
|
};
|
|
1410
1424
|
}
|
|
1411
1425
|
_downloadComplete(e = "Processing Data...", t = 62) {
|
|
1412
|
-
|
|
1426
|
+
_({
|
|
1413
1427
|
status: e,
|
|
1414
1428
|
progress: t,
|
|
1415
1429
|
canCancel: !1,
|
|
@@ -1457,10 +1471,10 @@ var jn = class e extends F {
|
|
|
1457
1471
|
}
|
|
1458
1472
|
getFileFormat(e) {
|
|
1459
1473
|
let t = e.split(".").pop().toLowerCase();
|
|
1460
|
-
return
|
|
1474
|
+
return Tn[t] || this._formats.get(t) || this._archiveFormats?.[t] || null;
|
|
1461
1475
|
}
|
|
1462
1476
|
formatError(e) {
|
|
1463
|
-
let t =
|
|
1477
|
+
let t = En[e.split(".").pop().toLowerCase()];
|
|
1464
1478
|
return /* @__PURE__ */ Error(t ? `${e}: this format is read by ${t.addOn} — install it with ${t.install}` : `Unsupported file format: ${e}`);
|
|
1465
1479
|
}
|
|
1466
1480
|
async inspectArchive(e) {
|
|
@@ -1480,7 +1494,7 @@ var jn = class e extends F {
|
|
|
1480
1494
|
async loadAssetFromFile(e, t = {}) {
|
|
1481
1495
|
let n = e.name, r = this.getFileFormat(n);
|
|
1482
1496
|
if (!r) throw this.formatError(n);
|
|
1483
|
-
|
|
1497
|
+
_({
|
|
1484
1498
|
isLoading: !0,
|
|
1485
1499
|
status: `Loading ${r.name}...`,
|
|
1486
1500
|
progress: 2
|
|
@@ -1514,7 +1528,7 @@ var jn = class e extends F {
|
|
|
1514
1528
|
if (!this.getFileFormat(r)) throw this.formatError(r);
|
|
1515
1529
|
this._loadCancelled = !1;
|
|
1516
1530
|
let s = e._isNetworkUrl(t), c = `Downloading ${r}...`, l = new AbortController();
|
|
1517
|
-
this._urlAbort = l,
|
|
1531
|
+
this._urlAbort = l, _({
|
|
1518
1532
|
isLoading: !0,
|
|
1519
1533
|
status: c,
|
|
1520
1534
|
progress: 2,
|
|
@@ -1546,7 +1560,7 @@ var jn = class e extends F {
|
|
|
1546
1560
|
}
|
|
1547
1561
|
}
|
|
1548
1562
|
async loadModelFromFile(e, t) {
|
|
1549
|
-
let n = this.storage ? this._keyed("file",
|
|
1563
|
+
let n = this.storage ? this._keyed("file", T(await ke(e))) : null, r = await this._loadModelFileByExtension(e, t);
|
|
1550
1564
|
return this._sourceKey = n, r;
|
|
1551
1565
|
}
|
|
1552
1566
|
async _loadModelFileByExtension(e, t) {
|
|
@@ -1558,7 +1572,7 @@ var jn = class e extends F {
|
|
|
1558
1572
|
}
|
|
1559
1573
|
async _loadModelWithFormat(e, t, n) {
|
|
1560
1574
|
try {
|
|
1561
|
-
|
|
1575
|
+
_({
|
|
1562
1576
|
isLoading: !0,
|
|
1563
1577
|
status: `Processing ${e.label} Data...`,
|
|
1564
1578
|
progress: 5
|
|
@@ -1567,7 +1581,7 @@ var jn = class e extends F {
|
|
|
1567
1581
|
filename: n,
|
|
1568
1582
|
cache: this.loaderCache
|
|
1569
1583
|
});
|
|
1570
|
-
return this.releaseTargetModel(), this.targetModel = r,
|
|
1584
|
+
return this.releaseTargetModel(), this.targetModel = r, _({
|
|
1571
1585
|
isLoading: !0,
|
|
1572
1586
|
status: "Processing Data...",
|
|
1573
1587
|
progress: 10
|
|
@@ -1593,7 +1607,7 @@ var jn = class e extends F {
|
|
|
1593
1607
|
};
|
|
1594
1608
|
try {
|
|
1595
1609
|
let r = await this.loadEnvironment(n);
|
|
1596
|
-
return
|
|
1610
|
+
return ce(r, T(await ke(e))), this.dispatchEvent({
|
|
1597
1611
|
type: "load",
|
|
1598
1612
|
texture: r,
|
|
1599
1613
|
filename: t
|
|
@@ -1615,7 +1629,7 @@ var jn = class e extends F {
|
|
|
1615
1629
|
let e = t.split(/[?#]/)[0].split(".").pop().toLowerCase();
|
|
1616
1630
|
n = await this.loadEnvironmentByExtension(t, e);
|
|
1617
1631
|
}
|
|
1618
|
-
return n.generateMipmaps = !0, e._isNetworkUrl(t) &&
|
|
1632
|
+
return n.generateMipmaps = !0, e._isNetworkUrl(t) && ce(n, t), this.applyEnvironmentToScene(n), this.dispatchEvent({
|
|
1619
1633
|
type: "load",
|
|
1620
1634
|
texture: n,
|
|
1621
1635
|
url: t,
|
|
@@ -1652,25 +1666,25 @@ var jn = class e extends F {
|
|
|
1652
1666
|
}
|
|
1653
1667
|
async loadEnvironmentByExtension(t, n, { loader: r = null } = {}) {
|
|
1654
1668
|
let i = this._formats.get(n);
|
|
1655
|
-
if (!r && i?.type === "environment" && (r = this.loaderCache[n] ??= await i.createLoader(this._loadingManager)), !r && n === "hdr" && (r = this.loaderCache.hdr ??= new Dt(this._loadingManager).setDataType(nt)), !r &&
|
|
1656
|
-
let a = e._isNetworkUrl(t), o = "Downloading Environment...",
|
|
1669
|
+
if (!r && i?.type === "environment" && (r = this.loaderCache[n] ??= await i.createLoader(this._loadingManager)), !r && n === "hdr" && (r = this.loaderCache.hdr ??= new Dt(this._loadingManager).setDataType(nt)), !r && En[n]) throw this.formatError(`environment.${n}`);
|
|
1670
|
+
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;
|
|
1657
1671
|
try {
|
|
1658
|
-
r ?
|
|
1672
|
+
r ? l = await r.loadAsync(s.url, c) : d().decodeImage ? (l = await pn(s.url, `image/${n === "jpg" ? "jpeg" : n}`), l.colorSpace = B) : (this.loaderCache.texture || (this.loaderCache.texture = new xt(this._loadingManager)), l = await this.loaderCache.texture.loadAsync(s.url, c), l.colorSpace = B);
|
|
1659
1673
|
} finally {
|
|
1660
|
-
|
|
1674
|
+
s.release();
|
|
1661
1675
|
}
|
|
1662
|
-
return this._downloadComplete("Processing Environment...", 62),
|
|
1676
|
+
return this._downloadComplete("Processing Environment...", 62), l.mapping = tt, l.minFilter = rt, l.magFilter = rt, l;
|
|
1663
1677
|
}
|
|
1664
1678
|
applyEnvironmentToScene(e) {
|
|
1665
1679
|
this.scene.background = e, this.scene.environment = e;
|
|
1666
1680
|
}
|
|
1667
1681
|
async createGLTFLoader() {
|
|
1668
|
-
let e =
|
|
1669
|
-
return
|
|
1682
|
+
let e = wn(new Et(this._loadingManager), this.renderer), t = (e, t) => this._reportImageFailure(e, t);
|
|
1683
|
+
return d().decodeImage ? e.register((e) => hn(e, t)) : u() || e.register((e) => mn(e, t)), e.register((e) => _n(e)), e;
|
|
1670
1684
|
}
|
|
1671
1685
|
_reportImageFailure(e, t) {
|
|
1672
1686
|
try {
|
|
1673
|
-
this._issues?.record(
|
|
1687
|
+
this._issues?.record(b.TEXTURE_BUILD_FAILED, `image ${e} could not be decoded (${t?.message ?? t}) — the surfaces using it render untextured`, {
|
|
1674
1688
|
image: e,
|
|
1675
1689
|
cause: String(t?.message ?? t)
|
|
1676
1690
|
});
|
|
@@ -1694,7 +1708,7 @@ var jn = class e extends F {
|
|
|
1694
1708
|
this._loadCancelled = !1;
|
|
1695
1709
|
let r = await this.createGLTFLoader(), i = e._isNetworkUrl(t), a = null;
|
|
1696
1710
|
try {
|
|
1697
|
-
|
|
1711
|
+
_({
|
|
1698
1712
|
isLoading: !0,
|
|
1699
1713
|
status: "Downloading Model...",
|
|
1700
1714
|
progress: 2,
|
|
@@ -1702,8 +1716,8 @@ var jn = class e extends F {
|
|
|
1702
1716
|
loadedBytes: 0,
|
|
1703
1717
|
totalBytes: 0
|
|
1704
1718
|
}), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(I.extractUrlBase(t));
|
|
1705
|
-
let e = await
|
|
1706
|
-
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 =
|
|
1719
|
+
let e = await s(() => r.loadAsync(a.url, a.cached ? void 0 : this._downloadProgress("Downloading Model...", i)));
|
|
1720
|
+
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 = je(e), await this.onModelLoad(this.targetModel), this.dispatchEvent({
|
|
1707
1721
|
type: "load",
|
|
1708
1722
|
model: e.scene,
|
|
1709
1723
|
filename: t.split("/").pop()
|
|
@@ -1725,7 +1739,7 @@ var jn = class e extends F {
|
|
|
1725
1739
|
this._loadCancelled = !1;
|
|
1726
1740
|
let r = await this.createGLTFLoader(), i = e._isNetworkUrl(t), a = null;
|
|
1727
1741
|
try {
|
|
1728
|
-
|
|
1742
|
+
_({
|
|
1729
1743
|
isLoading: !0,
|
|
1730
1744
|
status: "Downloading Model...",
|
|
1731
1745
|
progress: 2,
|
|
@@ -1733,7 +1747,7 @@ var jn = class e extends F {
|
|
|
1733
1747
|
loadedBytes: 0,
|
|
1734
1748
|
totalBytes: 0
|
|
1735
1749
|
}), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(I.extractUrlBase(t));
|
|
1736
|
-
let e = await
|
|
1750
|
+
let e = await s(() => r.loadAsync(a.url, a.cached ? void 0 : this._downloadProgress("Downloading Model...", i)));
|
|
1737
1751
|
return this._downloadComplete(), this._throwDeferred(), this._appended = !0, this._processAndParent(e.scene), {
|
|
1738
1752
|
root: e.scene,
|
|
1739
1753
|
animations: e.animations || []
|
|
@@ -1750,18 +1764,18 @@ var jn = class e extends F {
|
|
|
1750
1764
|
return n.name = e.name || t, this._processAndParent(n), { root: n };
|
|
1751
1765
|
}
|
|
1752
1766
|
removeModelRoot(e) {
|
|
1753
|
-
e && (e.userData.__rayzeeExternal ? (re(e), e.parent?.remove(e)) :
|
|
1767
|
+
e && (e.userData.__rayzeeExternal ? (re(e), e.parent?.remove(e)) : pe(e));
|
|
1754
1768
|
}
|
|
1755
1769
|
async loadGLBFromArrayBuffer(e, t = "model.glb") {
|
|
1756
1770
|
let n = await this.createGLTFLoader();
|
|
1757
1771
|
try {
|
|
1758
|
-
|
|
1772
|
+
_({
|
|
1759
1773
|
isLoading: !0,
|
|
1760
1774
|
status: "Processing GLB Data...",
|
|
1761
1775
|
progress: 5
|
|
1762
1776
|
}), await new Promise((e) => setTimeout(e, 0));
|
|
1763
|
-
let r = await
|
|
1764
|
-
return this._throwDeferred(), this.releaseTargetModel(), this.targetModel = r.scene, this.animations = r.animations || [], this.sceneMetadata =
|
|
1777
|
+
let r = await s(() => n.parseAsync(e, ""));
|
|
1778
|
+
return this._throwDeferred(), this.releaseTargetModel(), this.targetModel = r.scene, this.animations = r.animations || [], this.sceneMetadata = je(r), _({
|
|
1765
1779
|
isLoading: !0,
|
|
1766
1780
|
status: "Processing Data...",
|
|
1767
1781
|
progress: 10
|
|
@@ -1783,7 +1797,7 @@ var jn = class e extends F {
|
|
|
1783
1797
|
async loadObject3D(e, t = "object3d") {
|
|
1784
1798
|
this.releaseTargetModel();
|
|
1785
1799
|
let n = this._adoptExternalObject(e);
|
|
1786
|
-
return n.name = e.name || t, this.targetModel = n,
|
|
1800
|
+
return n.name = e.name || t, this.targetModel = n, _({
|
|
1787
1801
|
isLoading: !0,
|
|
1788
1802
|
status: "Processing Data...",
|
|
1789
1803
|
progress: 10
|
|
@@ -1794,20 +1808,20 @@ var jn = class e extends F {
|
|
|
1794
1808
|
}), n;
|
|
1795
1809
|
}
|
|
1796
1810
|
async onModelLoad(e) {
|
|
1797
|
-
let t = new
|
|
1811
|
+
let t = new p("onModelLoad");
|
|
1798
1812
|
t.start("Camera extraction");
|
|
1799
1813
|
let n = this.extractCamerasFromModel(e);
|
|
1800
1814
|
t.end("Camera extraction"), t.start("Camera setup");
|
|
1801
|
-
let r = new
|
|
1815
|
+
let r = new Ye().setFromObject(e), i = r.getCenter(new V()), a = r.getSize(new V());
|
|
1802
1816
|
this.controls?.target.copy(i);
|
|
1803
|
-
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,
|
|
1804
|
-
if (this.camera.position.copy(
|
|
1817
|
+
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 V(Math.cos(l) * c, c / Math.sqrt(2), Math.sin(l) * c);
|
|
1818
|
+
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) {
|
|
1805
1819
|
let e = r.min.y;
|
|
1806
1820
|
this.floorPlane.position.y = e, this.floorPlane.rotation.x = -Math.PI / 2, this.floorPlane.scale.setScalar(o * 5);
|
|
1807
1821
|
}
|
|
1808
1822
|
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");
|
|
1809
|
-
let
|
|
1810
|
-
return this.sceneSize.copy(a), t.start("setupPathTracing"), await this.setupPathTracing(e,
|
|
1823
|
+
let d = o;
|
|
1824
|
+
return this.sceneSize.copy(a), t.start("setupPathTracing"), await this.setupPathTracing(e, d), t.end("setupPathTracing"), t.print(), this.dispatchEvent({
|
|
1811
1825
|
type: "modelProcessed",
|
|
1812
1826
|
model: e,
|
|
1813
1827
|
cameras: n,
|
|
@@ -1815,13 +1829,13 @@ var jn = class e extends F {
|
|
|
1815
1829
|
center: i,
|
|
1816
1830
|
size: a,
|
|
1817
1831
|
maxDim: o,
|
|
1818
|
-
sceneScale:
|
|
1832
|
+
sceneScale: d
|
|
1819
1833
|
}
|
|
1820
1834
|
}), this.dispatchEvent({ type: "SceneRebuild" }), {
|
|
1821
1835
|
center: i,
|
|
1822
1836
|
size: a,
|
|
1823
1837
|
maxDim: o,
|
|
1824
|
-
sceneScale:
|
|
1838
|
+
sceneScale: d
|
|
1825
1839
|
};
|
|
1826
1840
|
}
|
|
1827
1841
|
extractCamerasFromModel(e) {
|
|
@@ -1837,21 +1851,21 @@ var jn = class e extends F {
|
|
|
1837
1851
|
let t = [], n = [];
|
|
1838
1852
|
e.traverse((e) => {
|
|
1839
1853
|
let r = e.userData;
|
|
1840
|
-
e.isRectAreaLight && !r.__radianceConverted && (e.intensity *=
|
|
1854
|
+
e.isRectAreaLight && !r.__radianceConverted && (e.intensity *= kn(e, e.width, e.height, r), r.__radianceConverted = !0), (e.isPointLight || e.isSpotLight) && !r.__candelaConverted && (e.intensity *= 4 * Math.PI / On, r.__candelaConverted = !0), e.isDirectionalLight && !r.__luxConverted && (e.intensity /= On, r.__luxConverted = !0);
|
|
1841
1855
|
let i = e.name.startsWith("RectAreaLightPlaceholder");
|
|
1842
1856
|
if (i && !(r.name && r.type === "RectAreaLight") && !e.parent?.name?.startsWith("RectAreaLightPlaceholder") && n.push(e.name), i && r.name && r.type === "RectAreaLight") {
|
|
1843
|
-
let t = r.normalize ?? !0, n = r.shape ?? "rectangle", i = r.intensity *
|
|
1857
|
+
let t = r.normalize ?? !0, n = r.shape ?? "rectangle", i = r.intensity * kn(e, r.width, r.height, r), a = new z(new P(...r.color), i * this._areaLightIntensityScale(), r.width, r.height);
|
|
1844
1858
|
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);
|
|
1845
1859
|
}
|
|
1846
1860
|
e.isMesh && Array.isArray(e.material) && t.push(e);
|
|
1847
|
-
}), n.length && this._issues?.record(
|
|
1861
|
+
}), n.length && this._issues?.record(b.LIGHT_PLACEHOLDER_SKIPPED, `${n.length} area-light placeholder(s) lack userData.name or userData.type 'RectAreaLight' — no light was made for them`, {
|
|
1848
1862
|
count: n.length,
|
|
1849
1863
|
names: n.slice(0, 10)
|
|
1850
1864
|
});
|
|
1851
1865
|
let r = e.userData.__rayzeeExternal === !0;
|
|
1852
1866
|
for (let e of t) {
|
|
1853
1867
|
if (!e.parent) continue;
|
|
1854
|
-
console.log("Found multi-material mesh:", e.name), r && (e.geometry =
|
|
1868
|
+
console.log("Found multi-material mesh:", e.name), r && (e.geometry = Dn(e.geometry));
|
|
1855
1869
|
let t = Ot(e);
|
|
1856
1870
|
for (let e of t.children) e.geometry.userData.__rayzeeOwned = !0;
|
|
1857
1871
|
e.parent.add(t), e.parent.remove(e);
|
|
@@ -1861,7 +1875,7 @@ var jn = class e extends F {
|
|
|
1861
1875
|
this.sceneScale = t;
|
|
1862
1876
|
}
|
|
1863
1877
|
createFloorPlane() {
|
|
1864
|
-
this.floorPlane = new ot(new
|
|
1878
|
+
this.floorPlane = new ot(new Ze(), new st({
|
|
1865
1879
|
transparent: !1,
|
|
1866
1880
|
color: 3158064,
|
|
1867
1881
|
roughness: 1,
|
|
@@ -1884,7 +1898,7 @@ var jn = class e extends F {
|
|
|
1884
1898
|
}
|
|
1885
1899
|
getSupportedFormats(e = null) {
|
|
1886
1900
|
let t = {
|
|
1887
|
-
...
|
|
1901
|
+
...Tn,
|
|
1888
1902
|
...this._archiveFormats
|
|
1889
1903
|
};
|
|
1890
1904
|
for (let [e, { type: n, name: r }] of this._formats) t[e] = {
|
|
@@ -1908,13 +1922,13 @@ var jn = class e extends F {
|
|
|
1908
1922
|
removeAllEventListeners() {
|
|
1909
1923
|
this._listeners = void 0;
|
|
1910
1924
|
}
|
|
1911
|
-
},
|
|
1925
|
+
}, jn = {
|
|
1912
1926
|
addEventListener() {},
|
|
1913
1927
|
removeEventListener() {},
|
|
1914
1928
|
dispatchEvent() {
|
|
1915
1929
|
return !0;
|
|
1916
1930
|
}
|
|
1917
|
-
},
|
|
1931
|
+
}, Mn = class {
|
|
1918
1932
|
constructor(e) {
|
|
1919
1933
|
this.canvas = e, this._configuration = null, this._texture = null;
|
|
1920
1934
|
}
|
|
@@ -1942,12 +1956,12 @@ var jn = class e extends F {
|
|
|
1942
1956
|
return this._texture;
|
|
1943
1957
|
}
|
|
1944
1958
|
};
|
|
1945
|
-
function
|
|
1959
|
+
function Nn(e = 1, t = 1) {
|
|
1946
1960
|
let n = {
|
|
1947
|
-
...
|
|
1961
|
+
...jn,
|
|
1948
1962
|
defaultView: null
|
|
1949
1963
|
}, r = {
|
|
1950
|
-
...
|
|
1964
|
+
...jn,
|
|
1951
1965
|
isHeadlessCanvas: !0,
|
|
1952
1966
|
width: e,
|
|
1953
1967
|
height: t,
|
|
@@ -1974,12 +1988,12 @@ function Pn(e = 1, t = 1) {
|
|
|
1974
1988
|
hasPointerCapture: () => !1,
|
|
1975
1989
|
focus() {},
|
|
1976
1990
|
getContext: (e) => e === "webgpu" ? i : null
|
|
1977
|
-
}, i = new
|
|
1991
|
+
}, i = new Mn(r);
|
|
1978
1992
|
return r;
|
|
1979
1993
|
}
|
|
1980
1994
|
//#endregion
|
|
1981
1995
|
//#region src/managers/ViewCamera.js
|
|
1982
|
-
var
|
|
1996
|
+
var Pn = class extends ft {
|
|
1983
1997
|
constructor(e, t, n, r) {
|
|
1984
1998
|
super(e, t, n, r), this.orthographic = !1, this.orthoHalfHeight = 1;
|
|
1985
1999
|
}
|
|
@@ -2008,12 +2022,12 @@ var Fn = class extends ft {
|
|
|
2008
2022
|
copy(e, t) {
|
|
2009
2023
|
return super.copy(e, t), this.orthographic = e.orthographic === !0, this.orthoHalfHeight = e.orthoHalfHeight ?? this.orthoHalfHeight, this;
|
|
2010
2024
|
}
|
|
2011
|
-
},
|
|
2025
|
+
}, Fn = "__rayzeeUserLight", In = {
|
|
2012
2026
|
DirectionalLight: $e,
|
|
2013
2027
|
PointLight: pt,
|
|
2014
2028
|
SpotLight: yt,
|
|
2015
2029
|
RectAreaLight: z
|
|
2016
|
-
},
|
|
2030
|
+
}, Ln = class extends F {
|
|
2017
2031
|
constructor(e, t, n, r = {}) {
|
|
2018
2032
|
super(), this.scene = e, this.sceneHelpers = t, this.pathTracer = n, this._onReset = r.onReset || null, this._onLightRemoved = r.onLightRemoved || null;
|
|
2019
2033
|
}
|
|
@@ -2068,7 +2082,7 @@ var Fn = class extends ft {
|
|
|
2068
2082
|
let e = new R();
|
|
2069
2083
|
this.scene.add(e), n.target = e;
|
|
2070
2084
|
} else e === "RectAreaLight" && (n = new z(t.color, t.intensity, t.width, t.height), n.position.fromArray(t.position), n.lookAt(0, 0, 0), n.userData.normalize = !0, n.userData.spread = Math.PI, n.userData.shape = "rectangle");
|
|
2071
|
-
n.userData[
|
|
2085
|
+
n.userData[Fn] = !0, n.userData.temperature = 6500, n.userData.useTemperature = !1, n.userData.exposure = 0;
|
|
2072
2086
|
let r = this.scene.getObjectsByProperty("isLight", !0).length;
|
|
2073
2087
|
return n.name = `${e.replace("Light", "")} ${r + 1}`, this.scene.add(n), this.updateLights(), this._syncHelpers(), this._onReset?.(), this._buildDescriptor(n);
|
|
2074
2088
|
}
|
|
@@ -2094,7 +2108,7 @@ var Fn = class extends ft {
|
|
|
2094
2108
|
this.pathTracer?.updateLights(), this.sceneHelpers?.visible && this.sceneHelpers.update();
|
|
2095
2109
|
}
|
|
2096
2110
|
transferSceneLights(e, { keepUserLights: t = !1 } = {}) {
|
|
2097
|
-
this._removeAllLights(t ? (e) => !e.userData?.[
|
|
2111
|
+
this._removeAllLights(t ? (e) => !e.userData?.[Fn] : void 0);
|
|
2098
2112
|
let n = e.getObjectsByProperty("isLight", !0);
|
|
2099
2113
|
if (!n || n.length === 0) {
|
|
2100
2114
|
this.updateLights();
|
|
@@ -2128,7 +2142,7 @@ var Fn = class extends ft {
|
|
|
2128
2142
|
position: e.position.toArray(),
|
|
2129
2143
|
quaternion: e.quaternion.toArray(),
|
|
2130
2144
|
scale: e.scale.toArray(),
|
|
2131
|
-
userData:
|
|
2145
|
+
userData: h(e.userData) ?? {}
|
|
2132
2146
|
};
|
|
2133
2147
|
return e.isSpotLight && Object.assign(t, {
|
|
2134
2148
|
angle: e.angle,
|
|
@@ -2148,14 +2162,14 @@ var Fn = class extends ft {
|
|
|
2148
2162
|
this.sceneHelpers?.clear(), this._removeAllLights();
|
|
2149
2163
|
let t = [];
|
|
2150
2164
|
for (let n of e ?? []) {
|
|
2151
|
-
let e =
|
|
2165
|
+
let e = In[n.type];
|
|
2152
2166
|
if (!e) continue;
|
|
2153
2167
|
let r = new e();
|
|
2154
2168
|
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 ?? [
|
|
2155
2169
|
1,
|
|
2156
2170
|
1,
|
|
2157
2171
|
1
|
|
2158
|
-
]), r.userData =
|
|
2172
|
+
]), r.userData = c(n.userData) ?? {};
|
|
2159
2173
|
for (let e of [
|
|
2160
2174
|
"angle",
|
|
2161
2175
|
"penumbra",
|
|
@@ -2240,11 +2254,11 @@ var Fn = class extends ft {
|
|
|
2240
2254
|
], 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);
|
|
2241
2255
|
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;
|
|
2242
2256
|
}
|
|
2243
|
-
},
|
|
2257
|
+
}, Rn = ({ element: e, pbrtEntry: t } = {}) => ({
|
|
2244
2258
|
...e === void 0 ? {} : { element: e },
|
|
2245
2259
|
...t === void 0 ? {} : { pbrtEntry: t }
|
|
2246
|
-
}), Q = /* @__PURE__ */ new WeakMap(),
|
|
2247
|
-
async function
|
|
2260
|
+
}), Q = /* @__PURE__ */ new WeakMap(), zn = new Set([...Object.values(g), ...Object.values(ne)]), Bn = /* @__PURE__ */ new Set();
|
|
2261
|
+
async function Vn(e, t) {
|
|
2248
2262
|
if (!t || typeof self < "u") return e.init();
|
|
2249
2263
|
globalThis.self = {
|
|
2250
2264
|
requestAnimationFrame: () => 0,
|
|
@@ -2256,47 +2270,43 @@ async function Hn(e, t) {
|
|
|
2256
2270
|
delete globalThis.self;
|
|
2257
2271
|
}
|
|
2258
2272
|
}
|
|
2259
|
-
var $ =
|
|
2260
|
-
function
|
|
2273
|
+
var $ = me("engine");
|
|
2274
|
+
function Hn() {
|
|
2261
2275
|
let e = new Float32Array(16);
|
|
2262
|
-
return new Uint32Array(e.buffer)[3] =
|
|
2276
|
+
return new Uint32Array(e.buffer)[3] = he.TRIANGLE_LEAF, e;
|
|
2263
2277
|
}
|
|
2264
|
-
function
|
|
2278
|
+
function Un(e, t) {
|
|
2265
2279
|
e.lost.then((e) => {
|
|
2266
2280
|
t.app && t.app._handleDeviceLost(e);
|
|
2267
2281
|
});
|
|
2268
2282
|
}
|
|
2269
|
-
var
|
|
2270
|
-
function
|
|
2283
|
+
var Wn = /swiftshader|llvmpipe|lavapipe|basic render|microsoft basic|warp/i;
|
|
2284
|
+
function Gn(e) {
|
|
2271
2285
|
let t = e.info ?? {}, n = `${t.vendor ?? ""} ${t.architecture ?? ""} ${t.device ?? ""} ${t.description ?? ""}`;
|
|
2272
2286
|
return {
|
|
2273
2287
|
vendor: t.vendor ?? "",
|
|
2274
2288
|
architecture: t.architecture ?? "",
|
|
2275
2289
|
device: t.device ?? "",
|
|
2276
2290
|
description: t.description ?? "",
|
|
2277
|
-
isSoftware: t.isFallbackAdapter === !0 || e.isFallbackAdapter === !0 ||
|
|
2291
|
+
isSoftware: t.isFallbackAdapter === !0 || e.isFallbackAdapter === !0 || Wn.test(n)
|
|
2278
2292
|
};
|
|
2279
2293
|
}
|
|
2280
|
-
var
|
|
2294
|
+
var Kn = class extends F {
|
|
2281
2295
|
constructor(e, t = {}) {
|
|
2282
|
-
super(), this._headless = t.headless === !0 || !e, e ??=
|
|
2296
|
+
super(), this._headless = t.headless === !0 || !e, e ??= Nn();
|
|
2283
2297
|
try {
|
|
2284
2298
|
Q.get(e)?.dispose();
|
|
2285
2299
|
} catch (e) {
|
|
2286
2300
|
$.warn("prior canvas owner dispose failed", e);
|
|
2287
2301
|
}
|
|
2288
|
-
Q.set(e, this), this.canvas = e, this._autoResize = !this._headless && t.autoResize !== !1, this._maxSceneBytes = t.maxSceneBytes, this._hostMemoryGB = t.hostMemoryGB, this._storageOption = t.storage, this._storageOpener = null, this._memorySpill = t.memorySpill === !0, this.storage = null, this._storageRelease = null, this._applySceneMetadataEnabled = t.applySceneMetadata !== !1, this._unlitRestore = null, this._applyingSceneMetadata = !1,
|
|
2302
|
+
if (Q.set(e, this), this.canvas = e, this._autoResize = !this._headless && t.autoResize !== !1, this._maxSceneBytes = t.maxSceneBytes, this._hostMemoryGB = t.hostMemoryGB, this._storageOption = t.storage, this._storageOpener = null, this._memorySpill = t.memorySpill === !0, this.storage = null, this._storageRelease = null, this._applySceneMetadataEnabled = t.applySceneMetadata !== !1, this._unlitRestore = null, this._applyingSceneMetadata = !1, t.profile !== void 0) throw Error("the `profile` option was removed: the engine has one set of defaults. For the old 'physical' profile set `areaLightIntensityScale: 1` and `dofMode: 'physical'` through `settings`.");
|
|
2303
|
+
this._issues = new _e({
|
|
2289
2304
|
strict: t.strict === !0,
|
|
2290
2305
|
onIssue: (e) => this.dispatchEvent({
|
|
2291
|
-
type:
|
|
2306
|
+
type: g.ISSUE,
|
|
2292
2307
|
issue: e
|
|
2293
2308
|
})
|
|
2294
|
-
}), this.color = new
|
|
2295
|
-
...v,
|
|
2296
|
-
environmentRotation: this._profile.environmentRotation,
|
|
2297
|
-
saturation: this._profile.saturation,
|
|
2298
|
-
dofMode: this._profile.dofMode
|
|
2299
|
-
}, { issues: this._issues }), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._maxTextureSize = v.maxTextureSize, this.pipeline = null, this._pendingReservedRenderSize = null, this.stages = {}, this.camera = null, this.lightManager = null, this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this._pathTracerEnabled = !0, this._rasterPrecompile = null, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this._emissiveSamplingUserSet = !1, this.completion = new Gt(), this._resizeDebounceTimer = null, this._displayWidth = 0, this._displayHeight = 0, this._renderScale = 1, this._renderWidth = 0, this._renderHeight = 0, this._trackedListeners = [], this._disposed = !1, this._deviceLost = !1, this._gpuDevice = null, this._deviceLostHolder = null, this._deterministic = !1, this._dispatchPinned = !1, this._deterministicRestore = null, this.adapterInfo = null;
|
|
2309
|
+
}), this.color = new nn({ issues: this._issues }), x(this.color), this.settings = new tn(n, { issues: this._issues }), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this.pipeline = null, this._pendingReservedRenderSize = null, this.stages = {}, this.camera = null, this.lightManager = null, this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this._pathTracerEnabled = !0, this._rasterPrecompile = null, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this._emissiveSamplingUserSet = !1, this.completion = new Gt(), this._resizeDebounceTimer = null, this._displayWidth = 0, this._displayHeight = 0, this._renderScale = 1, this._renderWidth = 0, this._renderHeight = 0, this._trackedListeners = [], this._disposed = !1, this._deviceLost = !1, this._gpuDevice = null, this._deviceLostHolder = null, this._deterministic = !1, this._dispatchPinned = !1, this._deterministicRestore = null, this.adapterInfo = null;
|
|
2300
2310
|
}
|
|
2301
2311
|
_addTrackedListener(e, t, n) {
|
|
2302
2312
|
e && (e.addEventListener(t, n), this._trackedListeners.push({
|
|
@@ -2315,33 +2325,33 @@ var qn = class extends F {
|
|
|
2315
2325
|
}
|
|
2316
2326
|
async init() {
|
|
2317
2327
|
let e = this._initStorage();
|
|
2318
|
-
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(
|
|
2328
|
+
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(ge.FLOATS_PER_TRIANGLE), 0), this.stages.pathTracer.setBVHData(Hn()), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setupMaterial(), this.isInitialized = !0, $.debug("WebGPU path tracer app initialized"), this;
|
|
2319
2329
|
}
|
|
2320
2330
|
async setStorageOpener(e) {
|
|
2321
2331
|
this._storageOpener = e, !(!this.isInitialized || this.storage || this._disposed) && (await this._initStorage(), this._attachStorage());
|
|
2322
2332
|
}
|
|
2323
2333
|
async _initStorage() {
|
|
2324
|
-
let e = this._storageOption ?? (this._issues.strict && !Ce("storage") ? !1 :
|
|
2334
|
+
let e = this._storageOption ?? (this._issues.strict && !Ce("storage") ? !1 : C().storage);
|
|
2325
2335
|
if (e !== !1) {
|
|
2326
2336
|
if (e && typeof e == "object") this.storage = e;
|
|
2327
2337
|
else {
|
|
2328
2338
|
if (!this._storageOpener) {
|
|
2329
|
-
(this._storageOption !== void 0 || Ce("storage")) && this._issues.warn(
|
|
2339
|
+
(this._storageOption !== void 0 || Ce("storage")) && this._issues.warn(b.CAPABILITY_MISSING, "on-disk storage needs rayzee/addons/storage: setStorageOpener( acquireSharedStorage )");
|
|
2330
2340
|
return;
|
|
2331
2341
|
}
|
|
2332
|
-
let { storage: e, reason: t, release: n } = await this._storageOpener(
|
|
2342
|
+
let { storage: e, reason: t, release: n } = await this._storageOpener(C().cacheNamespace);
|
|
2333
2343
|
if (this._disposed) {
|
|
2334
2344
|
n();
|
|
2335
2345
|
return;
|
|
2336
2346
|
}
|
|
2337
2347
|
if (!e) {
|
|
2338
|
-
this._issues.warn(
|
|
2348
|
+
this._issues.warn(b.STORAGE_UNAVAILABLE, `on-disk storage is off: ${t}`, { reason: t });
|
|
2339
2349
|
return;
|
|
2340
2350
|
}
|
|
2341
2351
|
this.storage = e, this._storageRelease = n;
|
|
2342
2352
|
}
|
|
2343
2353
|
this._addTrackedListener(this.storage, "change", (e) => this.dispatchEvent({
|
|
2344
|
-
type:
|
|
2354
|
+
type: g.STORAGE_CHANGED,
|
|
2345
2355
|
area: e.area
|
|
2346
2356
|
})), this._addTrackedListener(this.storage, "issue", (e) => this._issues.warn(e.code, e.message, e.detail));
|
|
2347
2357
|
}
|
|
@@ -2351,20 +2361,20 @@ var qn = class extends F {
|
|
|
2351
2361
|
}
|
|
2352
2362
|
dispatchEvent(e) {
|
|
2353
2363
|
super.dispatchEvent(e);
|
|
2354
|
-
let t =
|
|
2364
|
+
let t = ne[e.type];
|
|
2355
2365
|
t && super.dispatchEvent({
|
|
2356
2366
|
...e,
|
|
2357
2367
|
type: t
|
|
2358
2368
|
});
|
|
2359
2369
|
}
|
|
2360
2370
|
addEventListener(e, t) {
|
|
2361
|
-
!
|
|
2371
|
+
!zn.has(e) && !Bn.has(e) && (Bn.add(e), $.warn(`no engine event is named "${e}", so this listener will never fire — see EngineEvents`)), super.addEventListener(e, t);
|
|
2362
2372
|
}
|
|
2363
2373
|
animate() {
|
|
2364
2374
|
if (this._headless) throw Error("a headless app has no render loop — drive it with renderFrames() or renderUntilComplete()");
|
|
2365
2375
|
if (this._deviceLost) return;
|
|
2366
2376
|
if (this.animationManagerId = requestAnimationFrame(() => this.animate()), this._loadingInProgress || this._sdf?.isProcessing) {
|
|
2367
|
-
this.dispatchEvent({ type:
|
|
2377
|
+
this.dispatchEvent({ type: g.FRAME });
|
|
2368
2378
|
return;
|
|
2369
2379
|
}
|
|
2370
2380
|
this._beginFrame();
|
|
@@ -2380,28 +2390,28 @@ var qn = class extends F {
|
|
|
2380
2390
|
return;
|
|
2381
2391
|
}
|
|
2382
2392
|
if (this._holdTrace(e)) {
|
|
2383
|
-
this._renderHelperOverlay(), this.dispatchEvent({ type:
|
|
2393
|
+
this._renderHelperOverlay(), this.dispatchEvent({ type: g.FRAME });
|
|
2384
2394
|
return;
|
|
2385
2395
|
}
|
|
2386
2396
|
if (this.stages.pathTracer.readbackWait()) {
|
|
2387
|
-
this.dispatchEvent({ type:
|
|
2397
|
+
this.dispatchEvent({ type: g.FRAME });
|
|
2388
2398
|
return;
|
|
2389
2399
|
}
|
|
2390
2400
|
this._traceFrame({ liveDenoise: !0 }), this.stages.pathTracer.isComplete && this.completion.markComplete() && (this._renderCompleted(), this.dispatchEvent({
|
|
2391
|
-
type:
|
|
2401
|
+
type: g.RENDER_COMPLETE,
|
|
2392
2402
|
...this._completionInfo()
|
|
2393
2403
|
}));
|
|
2394
2404
|
}
|
|
2395
|
-
this._renderHelperOverlay(), this.dispatchEvent({ type:
|
|
2405
|
+
this._renderHelperOverlay(), this.dispatchEvent({ type: g.FRAME });
|
|
2396
2406
|
}
|
|
2397
2407
|
}
|
|
2398
2408
|
_traceFrame({ liveDenoise: e = !1 } = {}) {
|
|
2399
2409
|
let t = this.stages.pathTracer;
|
|
2400
2410
|
this.pipeline.render(), this._afterTrace(t, e), t.isComplete || this.completion.updateTime(), this._ensureVRAMWiring();
|
|
2401
2411
|
let n = t.vramTracker, r = t.frameCount ?? 0;
|
|
2402
|
-
n && (r <= 1 || r % 30 == 0) && n.measure(),
|
|
2412
|
+
n && (r <= 1 || r % 30 == 0) && n.measure(), le({
|
|
2403
2413
|
timeElapsed: this.completion.timeElapsed,
|
|
2404
|
-
samples:
|
|
2414
|
+
samples: ie(t),
|
|
2405
2415
|
memoryUsed: n?.current ?? 0,
|
|
2406
2416
|
memoryPeak: n?.peak ?? 0
|
|
2407
2417
|
}), this.completion.isTimeLimitReached(t, this.settings.get("renderLimitMode"), this.settings.get("renderTimeLimit")) && (t.isComplete = !0);
|
|
@@ -2419,7 +2429,7 @@ var qn = class extends F {
|
|
|
2419
2429
|
}
|
|
2420
2430
|
_handleDeviceLost(e) {
|
|
2421
2431
|
this._deviceLost || (this._deviceLost = !0, $.error(`WebGPU device lost (${e?.reason || "unknown"}): ${e?.message || ""}`), this.stopAnimation(), this.dispatchEvent({
|
|
2422
|
-
type:
|
|
2432
|
+
type: g.DEVICE_LOST,
|
|
2423
2433
|
reason: e?.reason,
|
|
2424
2434
|
message: e?.message
|
|
2425
2435
|
}));
|
|
@@ -2434,34 +2444,34 @@ var qn = class extends F {
|
|
|
2434
2444
|
this._paused = !1, !this.animationManagerId && !this._headless && this.animate();
|
|
2435
2445
|
}
|
|
2436
2446
|
reset(e = !1, { motion: t = !1 } = {}) {
|
|
2437
|
-
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:
|
|
2447
|
+
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 });
|
|
2438
2448
|
}
|
|
2439
2449
|
dispose() {
|
|
2440
2450
|
if (!this._disposed) {
|
|
2441
|
-
if (this._disposed = !0, this.dispatchEvent({ type:
|
|
2451
|
+
if (this._disposed = !0, this.dispatchEvent({ type: g.DISPOSE }), this.stopAnimation(), clearTimeout(this._resizeDebounceTimer), this._resizeDebounceTimer = null, this._removeTrackedListeners(), ae(null), this._storageRelease?.(), this._storageRelease = null, this.storage = null, this._sceneSource = this._sceneSourceFile = 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) {
|
|
2442
2452
|
this.meshScene.environment?.dispose(), this.meshScene.environment = null;
|
|
2443
|
-
for (let e of [...this.meshScene.children])
|
|
2453
|
+
for (let e of [...this.meshScene.children]) pe(e);
|
|
2444
2454
|
this.meshScene.clear(), this.meshScene = null;
|
|
2445
2455
|
}
|
|
2446
2456
|
this._sceneHelpers?.clear(), this._sceneHelpers = null, this.scene?.clear(), this.scene = null;
|
|
2447
2457
|
try {
|
|
2448
|
-
let e =
|
|
2458
|
+
let e = Ke().value, t = Ve().value;
|
|
2449
2459
|
e?._listeners?.dispose && (e._listeners.dispose.length = 0), t?._listeners?.dispose && (t._listeners.dispose.length = 0);
|
|
2450
2460
|
} catch (e) {
|
|
2451
2461
|
$.warn("failed to clear TSL texture singleton listeners", e);
|
|
2452
2462
|
}
|
|
2453
|
-
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),
|
|
2463
|
+
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;
|
|
2454
2464
|
}
|
|
2455
2465
|
}
|
|
2456
2466
|
unloadScene() {
|
|
2457
2467
|
if (this.isInitialized) {
|
|
2458
2468
|
if (this._loadingInProgress) throw Error("PathTracerApp.unloadScene: cannot unload while a load is in progress");
|
|
2459
|
-
this._disposed || (this._releaseSceneState(), this.assetLoader?.releaseTargetModel(), this._sceneSource = this._sceneSourceFile = null, this.lightManager?.clearLights?.(), this.stages.pathTracer && (this.stages.pathTracer.setTriangleData(new Uint32Array(
|
|
2469
|
+
this._disposed || (this._releaseSceneState(), this.assetLoader?.releaseTargetModel(), this._sceneSource = this._sceneSourceFile = null, this.lightManager?.clearLights?.(), this.stages.pathTracer && (this.stages.pathTracer.setTriangleData(new Uint32Array(ge.FLOATS_PER_TRIANGLE), 0), this.stages.pathTracer.setBVHData(Hn()), 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 }));
|
|
2460
2470
|
}
|
|
2461
2471
|
}
|
|
2462
2472
|
async loadModel(e, t = {}) {
|
|
2463
2473
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadModel(e, t), {
|
|
2464
|
-
type:
|
|
2474
|
+
type: g.MODEL_LOADED,
|
|
2465
2475
|
url: e
|
|
2466
2476
|
}, {
|
|
2467
2477
|
kind: "url",
|
|
@@ -2471,7 +2481,7 @@ var qn = class extends F {
|
|
|
2471
2481
|
}
|
|
2472
2482
|
async loadObject3D(e, t = "object3d") {
|
|
2473
2483
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadObject3D(e, t), {
|
|
2474
|
-
type:
|
|
2484
|
+
type: g.OBJECT3D_LOADED,
|
|
2475
2485
|
name: t
|
|
2476
2486
|
}, {
|
|
2477
2487
|
kind: "object3d",
|
|
@@ -2489,7 +2499,7 @@ var qn = class extends F {
|
|
|
2489
2499
|
await this.assetLoader.loadEnvironment(e);
|
|
2490
2500
|
let t = this.meshScene.environment;
|
|
2491
2501
|
t && this.stages.pathTracer && await this.stages.pathTracer.environment.setEnvironmentMap(t), this.pipeline?.eventBus.emit("pipeline:lightingChanged"), this.reset(), this.dispatchEvent({
|
|
2492
|
-
type:
|
|
2502
|
+
type: g.ENVIRONMENT_LOADED,
|
|
2493
2503
|
url: e
|
|
2494
2504
|
});
|
|
2495
2505
|
} finally {
|
|
@@ -2508,36 +2518,36 @@ var qn = class extends F {
|
|
|
2508
2518
|
...t,
|
|
2509
2519
|
filename: n
|
|
2510
2520
|
}), {
|
|
2511
|
-
type:
|
|
2521
|
+
type: g.MODEL_LOADED,
|
|
2512
2522
|
filename: n
|
|
2513
2523
|
}, {
|
|
2514
2524
|
kind: "url",
|
|
2515
2525
|
url: e,
|
|
2516
2526
|
filename: n,
|
|
2517
2527
|
cacheKey: t.cacheKey ?? null,
|
|
2518
|
-
...
|
|
2528
|
+
...Rn(t)
|
|
2519
2529
|
});
|
|
2520
2530
|
return;
|
|
2521
2531
|
}
|
|
2522
2532
|
let n = this.assetLoader?.getFileFormat(e?.name || "");
|
|
2523
2533
|
if (!n) throw this.assetLoader.formatError(e?.name || "");
|
|
2524
2534
|
if (n.type !== "environment" && n.type !== "image") {
|
|
2525
|
-
let n =
|
|
2535
|
+
let n = ke(e).catch(() => ({
|
|
2526
2536
|
name: e.name,
|
|
2527
2537
|
size: e.size,
|
|
2528
2538
|
lastModified: e.lastModified ?? 0,
|
|
2529
2539
|
sample: null
|
|
2530
2540
|
}));
|
|
2531
2541
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadAssetFromFile(e, t), {
|
|
2532
|
-
type:
|
|
2542
|
+
type: g.MODEL_LOADED,
|
|
2533
2543
|
filename: e.name
|
|
2534
2544
|
}, async () => {
|
|
2535
2545
|
let e = await n;
|
|
2536
2546
|
return {
|
|
2537
2547
|
kind: "local-file",
|
|
2538
2548
|
file: e,
|
|
2539
|
-
key: e.sample ?
|
|
2540
|
-
...
|
|
2549
|
+
key: e.sample ? T(e) : null,
|
|
2550
|
+
...Rn(t)
|
|
2541
2551
|
};
|
|
2542
2552
|
}), this._sceneSourceFile = e;
|
|
2543
2553
|
return;
|
|
@@ -2548,7 +2558,7 @@ var qn = class extends F {
|
|
|
2548
2558
|
await this.assetLoader.loadAssetFromFile(e);
|
|
2549
2559
|
let t = this.meshScene.environment;
|
|
2550
2560
|
t && this.stages.pathTracer && await this.stages.pathTracer.environment.applyHDRI(t), this.pipeline?.eventBus.emit("pipeline:lightingChanged"), this.reset(), this.dispatchEvent({
|
|
2551
|
-
type:
|
|
2561
|
+
type: g.ENVIRONMENT_LOADED,
|
|
2552
2562
|
filename: e.name
|
|
2553
2563
|
});
|
|
2554
2564
|
} finally {
|
|
@@ -2557,7 +2567,7 @@ var qn = class extends F {
|
|
|
2557
2567
|
}
|
|
2558
2568
|
async loadExampleModels(e, t) {
|
|
2559
2569
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadExampleModels(e, t), {
|
|
2560
|
-
type:
|
|
2570
|
+
type: g.MODEL_LOADED,
|
|
2561
2571
|
index: e
|
|
2562
2572
|
}, {
|
|
2563
2573
|
kind: "url",
|
|
@@ -2569,13 +2579,13 @@ var qn = class extends F {
|
|
|
2569
2579
|
this._loadingInProgress && this.assetLoader?.cancelActiveLoad();
|
|
2570
2580
|
}
|
|
2571
2581
|
async setMaxTextureSize(e, { reprocess: t = !0 } = {}) {
|
|
2572
|
-
let n = this.
|
|
2573
|
-
if (this.
|
|
2582
|
+
let n = this.settings.get("maxTextureSize"), r = this._sdf?.setMaxTextureSize(e) ?? e;
|
|
2583
|
+
if (this.settings.set("maxTextureSize", r, { reset: !1 }), typeof this.stages?.pathTracer?.sdfs?.setMaxTextureSize == "function" && this.stages.pathTracer.sdfs.setMaxTextureSize(r), t && r !== n && this._sdf?.triangles && !this._loadingInProgress) {
|
|
2574
2584
|
this._loadingInProgress = !0;
|
|
2575
2585
|
try {
|
|
2576
2586
|
await this.loadSceneData(), this.reset(), this.dispatchEvent({
|
|
2577
|
-
type:
|
|
2578
|
-
maxTextureSize:
|
|
2587
|
+
type: g.TEXTURES_REPROCESSED,
|
|
2588
|
+
maxTextureSize: r
|
|
2579
2589
|
});
|
|
2580
2590
|
} finally {
|
|
2581
2591
|
this._loadingInProgress = !1;
|
|
@@ -2594,7 +2604,7 @@ var qn = class extends F {
|
|
|
2594
2604
|
try {
|
|
2595
2605
|
await e(), this._sceneSource = typeof n == "function" ? await n() : n, this._sceneSourceFile = null, this._emissiveSamplingUserSet = !1, this._clearAppendedModels(), this._modelReplaced(), await this.loadSceneData({ pendingEnvironment: this._beginSceneMetadataEnvironment() }), this._maybeSpill(), this.pipeline?.eventBus.emit("pipeline:lightingChanged"), this._dropDisplay(), this.reset(), this.dispatchEvent(t), this._modelAnnounced();
|
|
2596
2606
|
} catch (e) {
|
|
2597
|
-
throw (!e || e.code !== "LOAD_IN_PROGRESS") && this._discardFailedLoad(), e?.code === "ARCHIVE_NEEDS_ELEMENT" ?
|
|
2607
|
+
throw (!e || e.code !== "LOAD_IN_PROGRESS") && this._discardFailedLoad(), e?.code === "ARCHIVE_NEEDS_ELEMENT" ? v() : e?.code !== "LOAD_IN_PROGRESS" && _({
|
|
2598
2608
|
status: `Error: ${e?.message ?? e}`,
|
|
2599
2609
|
failed: !0,
|
|
2600
2610
|
progress: 100
|
|
@@ -2617,7 +2627,7 @@ var qn = class extends F {
|
|
|
2617
2627
|
_beginSceneMetadataEnvironment() {
|
|
2618
2628
|
this._restoreUnlitSettings();
|
|
2619
2629
|
let e = this.sceneMetadata?.environment;
|
|
2620
|
-
return this._applySceneMetadataEnabled && e?.enabled === !1 ? (this._applyUnlitSettings(), null) : !this._applySceneMetadataEnabled || !e?.sourceFile || !this.stages.pathTracer ? null : (this.stages.pathTracer.environment.beginHDRI(), this._applyingSceneMetadata = !0, this.assetLoader.loadEnvironment(e.sourceFile).catch((t) => (this._issues.record(
|
|
2630
|
+
return this._applySceneMetadataEnabled && e?.enabled === !1 ? (this._applyUnlitSettings(), null) : !this._applySceneMetadataEnabled || !e?.sourceFile || !this.stages.pathTracer ? null : (this.stages.pathTracer.environment.beginHDRI(), this._applyingSceneMetadata = !0, this.assetLoader.loadEnvironment(e.sourceFile).catch((t) => (this._issues.record(b.ENVIRONMENT_LOAD_FAILED, `authored environment "${e.sourceFile}" failed to load — lighting falls back to the previous environment`, {
|
|
2621
2631
|
sourceFile: e.sourceFile,
|
|
2622
2632
|
cause: String(t?.message ?? t)
|
|
2623
2633
|
}), null)).finally(() => {
|
|
@@ -2636,7 +2646,7 @@ var qn = class extends F {
|
|
|
2636
2646
|
reset: !1,
|
|
2637
2647
|
source: Y.SCENE_METADATA
|
|
2638
2648
|
}), this.scene && (this.scene.background = e), this.dispatchEvent({
|
|
2639
|
-
type:
|
|
2649
|
+
type: g.SCENE_METADATA_APPLIED,
|
|
2640
2650
|
metadata: t,
|
|
2641
2651
|
environment: { ...n }
|
|
2642
2652
|
});
|
|
@@ -2653,7 +2663,7 @@ var qn = class extends F {
|
|
|
2653
2663
|
reset: !1,
|
|
2654
2664
|
source: Y.SCENE_METADATA
|
|
2655
2665
|
}), this.dispatchEvent({
|
|
2656
|
-
type:
|
|
2666
|
+
type: g.SCENE_METADATA_APPLIED,
|
|
2657
2667
|
metadata: this.sceneMetadata,
|
|
2658
2668
|
environment: { enabled: !1 }
|
|
2659
2669
|
});
|
|
@@ -2668,32 +2678,32 @@ var qn = class extends F {
|
|
|
2668
2678
|
source: i
|
|
2669
2679
|
});
|
|
2670
2680
|
this.dispatchEvent({
|
|
2671
|
-
type:
|
|
2681
|
+
type: g.SCENE_METADATA_APPLIED,
|
|
2672
2682
|
metadata: this.sceneMetadata,
|
|
2673
2683
|
environment: { enabled: this.settings.get("enableEnvironment") }
|
|
2674
2684
|
});
|
|
2675
2685
|
}
|
|
2676
2686
|
async loadSceneData({ pendingEnvironment: e = null, keepUserLights: t = !1 } = {}) {
|
|
2677
2687
|
this._releaseSceneState({ keepSelection: !!this._preserveSelectionOnRebuild }), this._tagPrimarySceneObject();
|
|
2678
|
-
let n = new
|
|
2688
|
+
let n = new p("", {
|
|
2679
2689
|
namespace: "scene",
|
|
2680
2690
|
level: "info"
|
|
2681
2691
|
}), r = () => this.stages.pathTracer.environment.envParams.mode === "hdri" ? this.meshScene.environment : null, i = r(), a = null;
|
|
2682
2692
|
if (e ? (n.start("Environment fetch + CDF (concurrent)"), a = e.then(async (e) => {
|
|
2683
2693
|
e && (await this.stages.pathTracer.environment.applyHDRI(e), this._applySceneMetadataSettings(e));
|
|
2684
|
-
}).catch((e) => this._issues.record(
|
|
2694
|
+
}).catch((e) => this._issues.record(b.ENVIRONMENT_LOAD_FAILED, "authored environment failed to install — the scene is lit by whatever was already loaded", { cause: String(e?.message ?? e) })).finally(() => n.end("Environment fetch + CDF (concurrent)"))) : i?.image?.data && (n.start("Environment CDF build (worker)"), this.stages.pathTracer.scene.environment = i, a = this.stages.pathTracer.environment.buildEnvironmentCDF().then(() => {
|
|
2685
2695
|
n.end("Environment CDF build (worker)"), this._applySceneMetadataEnabled && this._applySceneMetadataSettings(i);
|
|
2686
|
-
})), n.start("BVH build (SceneProcessor)"), this._sdf.setMaxTextureSize(this.
|
|
2696
|
+
})), n.start("BVH build (SceneProcessor)"), this._sdf.setMaxTextureSize(this.settings.get("maxTextureSize")), await this._sdf.buildBVH(this.meshScene, {
|
|
2687
2697
|
sceneKey: this.assetLoader?.sceneSourceKey ?? null,
|
|
2688
2698
|
progressive: this._progressiveSpill()
|
|
2689
|
-
}), this.assetLoader?.flushPendingGraph(this._sdf.performanceMetrics.totalProcessingTime), n.end("BVH build (SceneProcessor)"),
|
|
2699
|
+
}), this.assetLoader?.flushPendingGraph(this._sdf.performanceMetrics.totalProcessingTime), n.end("BVH build (SceneProcessor)"), _({
|
|
2690
2700
|
status: "Transferring data to GPU...",
|
|
2691
2701
|
progress: 86
|
|
2692
2702
|
}), await new Promise((e) => setTimeout(e, 0)), n.start("GPU data transfer"), !this._sdf.uploadToPathTracer(this.stages.pathTracer, this.lightManager, this.meshScene, r(), { keepUserLights: t })) return !1;
|
|
2693
|
-
this.stages.pathTracer._meshRefs = this.stages.pathTracer._collectMeshRefs(this.meshScene), this.stages.pathTracer.setMeshVisibilityData(this.stages.pathTracer._meshRefs), this._refreshEmissiveForVisibility(), n.end("GPU data transfer"),
|
|
2703
|
+
this.stages.pathTracer._meshRefs = this.stages.pathTracer._collectMeshRefs(this.meshScene), this.stages.pathTracer.setMeshVisibilityData(this.stages.pathTracer._meshRefs), this._refreshEmissiveForVisibility(), n.end("GPU data transfer"), _({
|
|
2694
2704
|
status: "Compiling shaders...",
|
|
2695
2705
|
progress: 90
|
|
2696
|
-
}), await new Promise((e) => setTimeout(e, 0)), n.start("Material setup (TSL compile)"), this.stages.pathTracer.setupMaterial(), n.end("Material setup (TSL compile)"), this._rasterPrecompile = null, this._pathTracerEnabled || (n.start("Pipeline precompile"), await this.precompileRaster(), n.end("Pipeline precompile")), a && (
|
|
2706
|
+
}), await new Promise((e) => setTimeout(e, 0)), n.start("Material setup (TSL compile)"), this.stages.pathTracer.setupMaterial(), n.end("Material setup (TSL compile)"), this._rasterPrecompile = null, this._pathTracerEnabled || (n.start("Pipeline precompile"), await this.precompileRaster(), n.end("Pipeline precompile")), a && (_({
|
|
2697
2707
|
status: "Finalizing environment map...",
|
|
2698
2708
|
progress: 95
|
|
2699
2709
|
}), await a, this.stages.pathTracer.environment.applyCDFResults());
|
|
@@ -2702,16 +2712,16 @@ var qn = class extends F {
|
|
|
2702
2712
|
let e = (this._sdf?.emissiveTriangleBuilder?.emissiveTriangles?.length ?? this._sdf?.emissiveTriangleCount ?? 0) > 0;
|
|
2703
2713
|
this.settings.set("enableEmissiveTriangleSampling", e, { reset: !1 });
|
|
2704
2714
|
}
|
|
2705
|
-
return n.start("Apply settings"), this.settings.applyAll(), this.stages.compositor.setTransparentBackground(this.settings.get("transparentBackground")), n.end("Apply settings"), n.print(this._sceneSummaryParts()),
|
|
2715
|
+
return n.start("Apply settings"), this.settings.applyAll(), this.stages.compositor.setTransparentBackground(this.settings.get("transparentBackground")), n.end("Apply settings"), n.print(this._sceneSummaryParts()), v(), this._sceneRebuilt(), this.dispatchEvent({ type: g.SCENE_REBUILD }), !0;
|
|
2706
2716
|
}
|
|
2707
2717
|
_sceneSummaryParts() {
|
|
2708
2718
|
let e = this.stages.pathTracer, t = this._sdf?.instanceTable?.setCount ?? 0, n = this._sdf?.geometryExtractor?.maps?.length ?? 0;
|
|
2709
2719
|
return [
|
|
2710
|
-
|
|
2711
|
-
t ?
|
|
2712
|
-
|
|
2713
|
-
n ?
|
|
2714
|
-
|
|
2720
|
+
y.count(e.triangleCount, "tri"),
|
|
2721
|
+
t ? y.count(t, "mesh", "meshes") : null,
|
|
2722
|
+
y.count(e.materialData.materialCount, "material"),
|
|
2723
|
+
n ? y.count(n, "map") : null,
|
|
2724
|
+
y.count(e.bvhNodeCount, "BVH node")
|
|
2715
2725
|
];
|
|
2716
2726
|
}
|
|
2717
2727
|
_tagPrimarySceneObject() {
|
|
@@ -2733,7 +2743,7 @@ var qn = class extends F {
|
|
|
2733
2743
|
try {
|
|
2734
2744
|
let { root: r } = await this.assetLoader.appendModel(e, { cacheKey: n });
|
|
2735
2745
|
return r.userData.__rayzeeSceneObject = !0, r.userData.__rayzeeSourceUrl = e, n && (r.userData.__rayzeeCacheKey = n), t && (r.userData.__rayzeeName = t), await this._finishRebuildNoReframe({
|
|
2736
|
-
type:
|
|
2746
|
+
type: g.MODEL_ADDED,
|
|
2737
2747
|
url: e,
|
|
2738
2748
|
id: r.uuid
|
|
2739
2749
|
}), r.uuid;
|
|
@@ -2747,7 +2757,7 @@ var qn = class extends F {
|
|
|
2747
2757
|
try {
|
|
2748
2758
|
let { root: n } = this.assetLoader.appendObject3D(e, t || "object3d");
|
|
2749
2759
|
return n.userData.__rayzeeSceneObject = !0, t && (n.userData.__rayzeeName = t), await this._finishRebuildNoReframe({
|
|
2750
|
-
type:
|
|
2760
|
+
type: g.MODEL_ADDED,
|
|
2751
2761
|
id: n.uuid
|
|
2752
2762
|
}), n.uuid;
|
|
2753
2763
|
} finally {
|
|
@@ -2764,7 +2774,7 @@ var qn = class extends F {
|
|
|
2764
2774
|
this._loadingInProgress = !0;
|
|
2765
2775
|
try {
|
|
2766
2776
|
return this._releaseSceneState(), n === this.sceneModel ? this.assetLoader.releaseTargetModel() : this.assetLoader.removeModelRoot(n), await this._finishRebuildNoReframe({
|
|
2767
|
-
type:
|
|
2777
|
+
type: g.SCENE_OBJECT_REMOVED,
|
|
2768
2778
|
id: e
|
|
2769
2779
|
}), !0;
|
|
2770
2780
|
} finally {
|
|
@@ -2776,7 +2786,7 @@ var qn = class extends F {
|
|
|
2776
2786
|
}
|
|
2777
2787
|
_sceneBudgets(e) {
|
|
2778
2788
|
return !this._memorySpill || !this.storage ? e : {
|
|
2779
|
-
maxTriangles:
|
|
2789
|
+
maxTriangles: fe,
|
|
2780
2790
|
maxPlacements: ue,
|
|
2781
2791
|
...e
|
|
2782
2792
|
};
|
|
@@ -2791,9 +2801,9 @@ var qn = class extends F {
|
|
|
2791
2801
|
}
|
|
2792
2802
|
_maybeSpill() {
|
|
2793
2803
|
!this._memorySpill || !this.storage || (this.assetLoader?.animations?.length ?? 0) > 0 || this._sdf?.spillToDisk(this.storage).then((e) => e && this.dispatchEvent({
|
|
2794
|
-
type:
|
|
2804
|
+
type: g.SCENE_SPILLED,
|
|
2795
2805
|
...e
|
|
2796
|
-
})).catch((e) => this._issues.warn(
|
|
2806
|
+
})).catch((e) => this._issues.warn(b.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`));
|
|
2797
2807
|
}
|
|
2798
2808
|
async ensureSceneResident() {
|
|
2799
2809
|
this._sdf?.spilled && await this._sdf.ensureResident();
|
|
@@ -2827,34 +2837,34 @@ var qn = class extends F {
|
|
|
2827
2837
|
return this.stages.pathTracer.updateBufferRanges([], [this._sdf.computeTLASDirtyRange()]), this.reset(!1, { motion: !0 }), t;
|
|
2828
2838
|
}
|
|
2829
2839
|
setReservedRenderResolution(e, { allowLower: t = !1 } = {}) {
|
|
2830
|
-
let n = t ? e : Math.max(e,
|
|
2840
|
+
let n = t ? e : Math.max(e, i);
|
|
2831
2841
|
if (!this.renderer) return this._pendingReservedRenderSize = {
|
|
2832
2842
|
requestedPx: e,
|
|
2833
2843
|
allowLower: t
|
|
2834
|
-
}, Math.max(256, Math.min(
|
|
2835
|
-
let
|
|
2836
|
-
if (
|
|
2844
|
+
}, Math.max(256, Math.min(r, Math.floor(n) || 256));
|
|
2845
|
+
let a = this.renderer.backend?.device?.limits?.maxStorageBufferBindingSize || 128 * 1024 * 1024, o = se(this._hostMemoryGB), s = o.gb >= 8 && a >= 1024 * 1024 * 1024 ? r : 2048, c = te(Math.min(n, s));
|
|
2846
|
+
if (c < Math.floor(e) && this._issues.warn(b.RENDER_RESERVE_CAPPED, `reserved render size ${y.n(e)}px was capped to ${y.n(c)}px by this device's limits — renders above ${y.n(c)}px will be declined` + (o.assumed && o.gb < 8 ? " (host memory unknown, 4 GB assumed: pass hostMemoryGB)" : ""), {
|
|
2837
2847
|
requested: e,
|
|
2838
|
-
applied:
|
|
2839
|
-
deviceMemoryGB:
|
|
2840
|
-
assumed:
|
|
2841
|
-
maxStorageBufferBindingSize:
|
|
2842
|
-
}), (this.stages?.pathTracer?.storageTextures?.writeColor?.image?.width ??
|
|
2848
|
+
applied: c,
|
|
2849
|
+
deviceMemoryGB: o.gb,
|
|
2850
|
+
assumed: o.assumed,
|
|
2851
|
+
maxStorageBufferBindingSize: a
|
|
2852
|
+
}), (this.stages?.pathTracer?.storageTextures?.writeColor?.image?.width ?? c) !== c) {
|
|
2843
2853
|
let e = this.pauseRendering;
|
|
2844
2854
|
this.pauseRendering = !0;
|
|
2845
2855
|
try {
|
|
2846
2856
|
let e = this.renderer.domElement;
|
|
2847
|
-
(e.width >
|
|
2857
|
+
(e.width > c || e.height > c) && this.renderer.setSize(Math.min(e.width, c), Math.min(e.height, c), !1);
|
|
2848
2858
|
for (let e of Object.values(this.stages)) e?.reallocateReservedStorage?.();
|
|
2849
2859
|
} finally {
|
|
2850
2860
|
this.pauseRendering = e;
|
|
2851
2861
|
}
|
|
2852
2862
|
this.reset(), this.dispatchEvent({
|
|
2853
|
-
type:
|
|
2854
|
-
size:
|
|
2863
|
+
type: g.RESERVED_RENDER_SIZE_CHANGED,
|
|
2864
|
+
size: c
|
|
2855
2865
|
});
|
|
2856
2866
|
}
|
|
2857
|
-
return
|
|
2867
|
+
return c;
|
|
2858
2868
|
}
|
|
2859
2869
|
_applyPendingReservedRenderSize() {
|
|
2860
2870
|
let e = this._pendingReservedRenderSize;
|
|
@@ -2862,18 +2872,18 @@ var qn = class extends F {
|
|
|
2862
2872
|
this._pendingReservedRenderSize = null;
|
|
2863
2873
|
let t = this.setReservedRenderResolution(e.requestedPx, { allowLower: e.allowLower });
|
|
2864
2874
|
this.dispatchEvent({
|
|
2865
|
-
type:
|
|
2875
|
+
type: g.RESERVED_RENDER_SIZE_CHANGED,
|
|
2866
2876
|
size: t
|
|
2867
2877
|
});
|
|
2868
2878
|
}
|
|
2869
2879
|
getReservedRenderResolution() {
|
|
2870
|
-
return
|
|
2880
|
+
return i;
|
|
2871
2881
|
}
|
|
2872
2882
|
_isRenderSizeSupported(e, t) {
|
|
2873
|
-
return e >
|
|
2883
|
+
return e > i || t > i ? (this._issues.record(b.RENDER_SIZE_DECLINED, `render resolution ${e}×${t} exceeds the ${i}px storage reserve — resize ignored, so output stays at the previous size. Raise it with setReservedRenderResolution( ${Math.max(e, t)} ) before init().`, {
|
|
2874
2884
|
width: e,
|
|
2875
2885
|
height: t,
|
|
2876
|
-
reserve:
|
|
2886
|
+
reserve: i
|
|
2877
2887
|
}), !1) : !0;
|
|
2878
2888
|
}
|
|
2879
2889
|
onResize() {
|
|
@@ -2884,7 +2894,7 @@ var qn = class extends F {
|
|
|
2884
2894
|
}
|
|
2885
2895
|
_applyRenderResize(e, t) {
|
|
2886
2896
|
this._isRenderSizeSupported(e, t) && (this.pipeline?.setSize(this._scaled(e), this._scaled(t)), this._renderWidth = e, this._renderHeight = t, this._renderSizeChanged(e, t), this.needsReset = !0, this.dispatchEvent({
|
|
2887
|
-
type:
|
|
2897
|
+
type: g.RESOLUTION_CHANGED,
|
|
2888
2898
|
width: e,
|
|
2889
2899
|
height: t
|
|
2890
2900
|
}));
|
|
@@ -3004,7 +3014,7 @@ var qn = class extends F {
|
|
|
3004
3014
|
}
|
|
3005
3015
|
let l = this._completionInfo();
|
|
3006
3016
|
this.completion.markComplete() && this.dispatchEvent({
|
|
3007
|
-
type:
|
|
3017
|
+
type: g.RENDER_COMPLETE,
|
|
3008
3018
|
...l
|
|
3009
3019
|
});
|
|
3010
3020
|
let u = t ? await this._finalDenoise() : !1, { reason: d, ...f } = l;
|
|
@@ -3023,13 +3033,9 @@ var qn = class extends F {
|
|
|
3023
3033
|
}
|
|
3024
3034
|
getProvenance() {
|
|
3025
3035
|
let e = this.stages.pathTracer, t = this.color?.status();
|
|
3026
|
-
return
|
|
3027
|
-
engine:
|
|
3036
|
+
return h({
|
|
3037
|
+
engine: de,
|
|
3028
3038
|
three: ht,
|
|
3029
|
-
profile: {
|
|
3030
|
-
name: this._profileName,
|
|
3031
|
-
values: { ...this._profile }
|
|
3032
|
-
},
|
|
3033
3039
|
adapter: this.adapterInfo ?? null,
|
|
3034
3040
|
mode: {
|
|
3035
3041
|
headless: this._headless,
|
|
@@ -3071,7 +3077,7 @@ var qn = class extends F {
|
|
|
3071
3077
|
let t = await e.captureAccumulation();
|
|
3072
3078
|
return {
|
|
3073
3079
|
v: 1,
|
|
3074
|
-
engine:
|
|
3080
|
+
engine: de,
|
|
3075
3081
|
savedAt: Date.now(),
|
|
3076
3082
|
samples: t.state.frameCount,
|
|
3077
3083
|
...t
|
|
@@ -3082,7 +3088,7 @@ var qn = class extends F {
|
|
|
3082
3088
|
let t = this.stages.pathTracer;
|
|
3083
3089
|
if (!t) throw Error("restoreRenderCheckpoint: app is not initialized");
|
|
3084
3090
|
t.restoreAccumulation(e), this.needsReset = !1, this.dispatchEvent({
|
|
3085
|
-
type:
|
|
3091
|
+
type: g.RENDER_RESET,
|
|
3086
3092
|
restored: e.samples
|
|
3087
3093
|
});
|
|
3088
3094
|
}
|
|
@@ -3090,42 +3096,42 @@ var qn = class extends F {
|
|
|
3090
3096
|
if (e !== "linear" && e !== "srgb" && !this.color?.hasConfig) throw Error(`renderToBuffer: colorSpace must be 'linear' or 'srgb' without a colour config loaded, got "${e}"`);
|
|
3091
3097
|
let r = this.stages?.pathTracer, i = r?.storageTextures?.readTarget;
|
|
3092
3098
|
if (!i) throw Error("renderToBuffer: no render target — call init() and render at least one sample");
|
|
3093
|
-
let { width:
|
|
3099
|
+
let { width: a, height: o } = r;
|
|
3094
3100
|
if (e === "srgb") {
|
|
3095
|
-
let r = n === "display" ? this._displaySource(i) : null,
|
|
3101
|
+
let r = n === "display" ? this._displaySource(i) : null, s = {
|
|
3096
3102
|
exposure: this.renderer.toneMappingExposure,
|
|
3097
3103
|
toneMapping: this.renderer.toneMapping,
|
|
3098
3104
|
saturation: this.settings.get("saturation") ?? 1,
|
|
3099
3105
|
preserveAlpha: t
|
|
3100
|
-
},
|
|
3106
|
+
}, c = await this._toneMapOnGPU(r?.texture ?? null, i, a, o, s);
|
|
3101
3107
|
return {
|
|
3102
|
-
data:
|
|
3103
|
-
width:
|
|
3104
|
-
height:
|
|
3108
|
+
data: c ?? l(r ? await this._readTexture(r.texture, a, o) : await this.renderer.readRenderTargetPixelsAsync(i, 0, 0, a, o, 0), s),
|
|
3109
|
+
width: a,
|
|
3110
|
+
height: o,
|
|
3105
3111
|
colorSpace: e,
|
|
3106
3112
|
source: r?.source ?? "accumulation",
|
|
3107
|
-
toneMappedOn:
|
|
3113
|
+
toneMappedOn: c ? "gpu" : "cpu"
|
|
3108
3114
|
};
|
|
3109
3115
|
}
|
|
3110
|
-
let { data:
|
|
3111
|
-
data: await this.renderer.readRenderTargetPixelsAsync(i, 0, 0,
|
|
3116
|
+
let { data: s, source: c } = n === "display" ? await this._readDisplaySource(i, a, o) : {
|
|
3117
|
+
data: await this.renderer.readRenderTargetPixelsAsync(i, 0, 0, a, o, 0),
|
|
3112
3118
|
source: "accumulation"
|
|
3113
3119
|
};
|
|
3114
3120
|
if (e === "linear") return {
|
|
3115
|
-
data:
|
|
3116
|
-
width:
|
|
3117
|
-
height:
|
|
3121
|
+
data: s,
|
|
3122
|
+
width: a,
|
|
3123
|
+
height: o,
|
|
3118
3124
|
colorSpace: e,
|
|
3119
3125
|
workingSpace: this.color?.workingSpace ?? null,
|
|
3120
|
-
source:
|
|
3126
|
+
source: c
|
|
3121
3127
|
};
|
|
3122
|
-
let { rgba: u, colorSpace: d } = this.color.exportPixels(
|
|
3128
|
+
let { rgba: u, colorSpace: d } = this.color.exportPixels(s, e);
|
|
3123
3129
|
return {
|
|
3124
3130
|
data: u,
|
|
3125
|
-
width:
|
|
3126
|
-
height:
|
|
3131
|
+
width: a,
|
|
3132
|
+
height: o,
|
|
3127
3133
|
colorSpace: d,
|
|
3128
|
-
source:
|
|
3134
|
+
source: c
|
|
3129
3135
|
};
|
|
3130
3136
|
}
|
|
3131
3137
|
async _toneMapOnGPU(e, t, n, r, i) {
|
|
@@ -3133,7 +3139,7 @@ var qn = class extends F {
|
|
|
3133
3139
|
if (!a?.device) return this._toneMapFallback("the renderer has no WebGPU device");
|
|
3134
3140
|
try {
|
|
3135
3141
|
let o = e ? this._readbackPass().draw(e, n, r).texture : t.textures[0], s = a.get(o).texture;
|
|
3136
|
-
return s ? (this._readbackToneMapper ??= new
|
|
3142
|
+
return s ? (this._readbackToneMapper ??= new Ae(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");
|
|
3137
3143
|
} catch (e) {
|
|
3138
3144
|
if (e instanceof ve) throw e;
|
|
3139
3145
|
return this._toneMapFallback("the GPU pass threw", e);
|
|
@@ -3143,7 +3149,7 @@ var qn = class extends F {
|
|
|
3143
3149
|
}
|
|
3144
3150
|
_toneMapFallback(e, t = null) {
|
|
3145
3151
|
let n = t ? String(t?.message ?? t) : null, r = `renderToBuffer: tone mapped on the CPU — ${e}${n ? `: ${n}` : ""}`;
|
|
3146
|
-
return $.warn(r), this._issues.warn(
|
|
3152
|
+
return $.warn(r), this._issues.warn(b.OUTPUT_TONEMAP_FALLBACK, r, {
|
|
3147
3153
|
reason: e,
|
|
3148
3154
|
cause: n
|
|
3149
3155
|
}), null;
|
|
@@ -3258,7 +3264,7 @@ var qn = class extends F {
|
|
|
3258
3264
|
...this._canvasResources()
|
|
3259
3265
|
]);
|
|
3260
3266
|
let t = () => e.measure();
|
|
3261
|
-
this._addTrackedListener(this,
|
|
3267
|
+
this._addTrackedListener(this, g.SCENE_REBUILD, t), this._addTrackedListener(this, g.ENVIRONMENT_LOADED, t), this._addTrackedListener(this, g.RESOLUTION_CHANGED, t), this._vramWired = !0;
|
|
3262
3268
|
}
|
|
3263
3269
|
_collectStageTextures() {
|
|
3264
3270
|
let e = [], t = this.stages || {}, n = t.pathTracer;
|
|
@@ -3273,7 +3279,7 @@ var qn = class extends F {
|
|
|
3273
3279
|
}
|
|
3274
3280
|
getSceneMinY() {
|
|
3275
3281
|
if (!this.meshScene) return 0;
|
|
3276
|
-
let e = new
|
|
3282
|
+
let e = new Ye().setFromObject(this.meshScene);
|
|
3277
3283
|
return Number.isFinite(e.min.y) ? e.min.y : 0;
|
|
3278
3284
|
}
|
|
3279
3285
|
getMaterialProperty(e, t) {
|
|
@@ -3283,7 +3289,7 @@ var qn = class extends F {
|
|
|
3283
3289
|
return this.stages.pathTracer?.materialData.getMaterialPropertySource(e, t);
|
|
3284
3290
|
}
|
|
3285
3291
|
setMaterialProperty(e, t, n) {
|
|
3286
|
-
if (this._sdf?.spilled &&
|
|
3292
|
+
if (this._sdf?.spilled && m.has(t)) {
|
|
3287
3293
|
this.ensureSceneResident().then(() => this.setMaterialProperty(e, t, n));
|
|
3288
3294
|
return;
|
|
3289
3295
|
}
|
|
@@ -3328,7 +3334,7 @@ var qn = class extends F {
|
|
|
3328
3334
|
return n && n.key !== "pathtracer:color" && n.texture !== e.texture ? {
|
|
3329
3335
|
texture: n.texture,
|
|
3330
3336
|
source: n.key.split(":")[0]
|
|
3331
|
-
} : (this._denoiserInUse() && this._issues.record(
|
|
3337
|
+
} : (this._denoiserInUse() && this._issues.record(b.OUTPUT_SOURCE_FALLBACK, "renderToBuffer: 'display' was asked for, but no denoiser has published a picture — returned the raw accumulation", {
|
|
3332
3338
|
requested: "display",
|
|
3333
3339
|
read: "accumulation"
|
|
3334
3340
|
}), null);
|
|
@@ -3355,20 +3361,20 @@ var qn = class extends F {
|
|
|
3355
3361
|
n.__rayzeeOriginalColorSpace === void 0 && (n.__rayzeeOriginalColorSpace = e.colorSpace);
|
|
3356
3362
|
let r = n.__rayzeeOriginalColorSpace;
|
|
3357
3363
|
if (delete n.ocioColorSpace, delete n.__rayzeeColorSpaceChoice, t == null) e.colorSpace = r, delete n.__rayzeeOriginalColorSpace;
|
|
3358
|
-
else if (t === "srgb" || t === "linear") e.colorSpace = t === "srgb" ?
|
|
3364
|
+
else if (t === "srgb" || t === "linear") e.colorSpace = t === "srgb" ? Ie : Me, n.__rayzeeColorSpaceChoice = t;
|
|
3359
3365
|
else {
|
|
3360
3366
|
if (!this.color?.hasConfig) throw Error(`"${t}" needs a colour config loaded`);
|
|
3361
|
-
n.ocioColorSpace = t, e.colorSpace =
|
|
3367
|
+
n.ocioColorSpace = t, e.colorSpace = Ie;
|
|
3362
3368
|
}
|
|
3363
3369
|
e.needsUpdate = !0, this.stages.pathTracer?.sdfs && await this.rebuildMaterials();
|
|
3364
3370
|
}
|
|
3365
3371
|
setColorManagement(e) {
|
|
3366
|
-
this.color?.dispose(), this.color = new e({ issues: this._issues }),
|
|
3372
|
+
this.color?.dispose(), this.color = new e({ issues: this._issues }), x(this.color), this.renderer && this.color.attachRenderer(this.renderer);
|
|
3367
3373
|
}
|
|
3368
3374
|
async loadColorConfig(e = {}) {
|
|
3369
3375
|
await this._leaveColorWorkingSpace();
|
|
3370
|
-
let t =
|
|
3371
|
-
return this.color.workingSpaceAdopted && await this.applyColorWorkingSpace(), (!(t?.source === "ocio" &&
|
|
3376
|
+
let t = w(this.renderer?.toneMapping), n = await this.color.loadConfig(e);
|
|
3377
|
+
return this.color.workingSpaceAdopted && await this.applyColorWorkingSpace(), (!(t?.source === "ocio" && w(this.renderer?.toneMapping) === t) || this.color.workingSpaceAdopted) && this.reset(), n;
|
|
3372
3378
|
}
|
|
3373
3379
|
async unloadColorConfig() {
|
|
3374
3380
|
await this._leaveColorWorkingSpace(), this.color.unloadConfig(), this.reset();
|
|
@@ -3389,10 +3395,10 @@ var qn = class extends F {
|
|
|
3389
3395
|
await this.ensureSceneResident(), await this.stages.pathTracer?.rebuildMaterials(e || this.meshScene), this.reset();
|
|
3390
3396
|
}
|
|
3391
3397
|
async _initRenderer() {
|
|
3392
|
-
if (
|
|
3398
|
+
if (ae((e) => this.dispatchEvent(e)), typeof navigator > "u" || !navigator.gpu) throw Error("WebGPU is not available — outside a browser, install one as navigator.gpu (for Node, the `webgpu` package)");
|
|
3393
3399
|
let e = await navigator.gpu.requestAdapter({ powerPreference: "high-performance" });
|
|
3394
3400
|
if (!e) throw Error("Failed to get WebGPU adapter");
|
|
3395
|
-
this.adapterInfo =
|
|
3401
|
+
this.adapterInfo = Gn(e), this.adapterInfo.isSoftware && (this._issues.warn(b.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}`));
|
|
3396
3402
|
let t = e.limits, n = { maxColorAttachmentBytesPerSample: 128 };
|
|
3397
3403
|
for (let e of [
|
|
3398
3404
|
"maxBufferSize",
|
|
@@ -3410,25 +3416,25 @@ var qn = class extends F {
|
|
|
3410
3416
|
let r = t[e];
|
|
3411
3417
|
r !== void 0 && (n[e] = r);
|
|
3412
3418
|
}
|
|
3413
|
-
if (n.maxStorageBuffersPerShaderStage = Math.min(t.maxStorageBuffersPerShaderStage, 10), this.renderer = new
|
|
3419
|
+
if (n.maxStorageBuffersPerShaderStage = Math.min(t.maxStorageBuffersPerShaderStage, 10), this.renderer = new Re({
|
|
3414
3420
|
canvas: this.canvas,
|
|
3415
3421
|
alpha: !0,
|
|
3416
3422
|
powerPreference: "high-performance",
|
|
3417
3423
|
requiredLimits: n
|
|
3418
|
-
}), await
|
|
3424
|
+
}), await Vn(this.renderer, this._headless), !this.renderer.backend?.isWebGPUBackend) throw Error("WebGPU backend unavailable — three.js fell back to WebGL2, which cannot run the path tracer's compute kernels. Check GPU process flags and driver support.");
|
|
3419
3425
|
let r = this.renderer.backend?.device;
|
|
3420
|
-
r?.lost && (this._gpuDevice = r, this._deviceLostHolder = { app: this },
|
|
3426
|
+
r?.lost && (this._gpuDevice = r, this._deviceLostHolder = { app: this }, Un(r, this._deviceLostHolder), r.onuncapturederror = (e) => $.error("WebGPU uncaptured error:", e.error)), Fe.setLTC(wt.init()), this.renderer.outputColorSpace = Ie, this.renderer.toneMapping = Oe, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1), this.color.attachRenderer(this.renderer);
|
|
3421
3427
|
}
|
|
3422
3428
|
_initScenes() {
|
|
3423
3429
|
this.scene = new vt(), this.meshScene = new vt(), this._sceneHelpers = new At();
|
|
3424
3430
|
}
|
|
3425
3431
|
_initAssetPipeline() {
|
|
3426
|
-
this._sdf = new
|
|
3432
|
+
this._sdf = new ee({
|
|
3427
3433
|
issues: this._issues,
|
|
3428
3434
|
...this._maxSceneBytes === void 0 ? {} : { maxSceneBytes: this._maxSceneBytes }
|
|
3429
|
-
}), this.assetLoader = new
|
|
3435
|
+
}), this.assetLoader = new An(this.meshScene, this.camera, null, {
|
|
3430
3436
|
issues: this._issues,
|
|
3431
|
-
|
|
3437
|
+
areaLightIntensityScale: () => this.settings.get("areaLightIntensityScale")
|
|
3432
3438
|
}), this.assetLoader.setRenderer(this.renderer), this.assetLoader.createFloorPlane();
|
|
3433
3439
|
}
|
|
3434
3440
|
_initPipeline() {
|
|
@@ -3441,7 +3447,7 @@ var qn = class extends F {
|
|
|
3441
3447
|
this._displayWidth = n, this._displayHeight = r, this._renderWidth = n, this._renderHeight = r, this.pipeline.setSize(n, r);
|
|
3442
3448
|
}
|
|
3443
3449
|
async _initManagers() {
|
|
3444
|
-
this.lightManager = new
|
|
3450
|
+
this.lightManager = new Ln(this.scene, this._sceneHelpers, this.stages.pathTracer, {
|
|
3445
3451
|
onReset: () => this.reset(),
|
|
3446
3452
|
onLightRemoved: (e) => this._lightRemoved(e)
|
|
3447
3453
|
}), 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();
|
|
@@ -3452,18 +3458,21 @@ var qn = class extends F {
|
|
|
3452
3458
|
if (e.model) this._clearAppendedModels(), await this.loadSceneData({ pendingEnvironment: this._beginSceneMetadataEnvironment() });
|
|
3453
3459
|
else if (e.texture) {
|
|
3454
3460
|
let e = this.meshScene.environment;
|
|
3455
|
-
e && this.stages.pathTracer && await this.stages.pathTracer.environment.setEnvironmentMap(e),
|
|
3461
|
+
e && this.stages.pathTracer && await this.stages.pathTracer.environment.setEnvironmentMap(e), v();
|
|
3456
3462
|
}
|
|
3457
3463
|
this.pauseRendering = !1, this.reset();
|
|
3458
3464
|
}
|
|
3459
3465
|
}, this._addTrackedListener(this.assetLoader, "load", this._onAssetLoaded), this.pipeline.eventBus.on("pathtracer:compiling", ({ compiling: e }) => this.dispatchEvent({
|
|
3460
|
-
type:
|
|
3466
|
+
type: g.SHADERS_COMPILING,
|
|
3461
3467
|
compiling: e
|
|
3462
3468
|
}));
|
|
3463
3469
|
}
|
|
3464
3470
|
_createStages() {
|
|
3465
|
-
this.stages.pathTracer = new
|
|
3466
|
-
|
|
3471
|
+
this.stages.pathTracer = new f(this.renderer, this.scene, this.camera, {
|
|
3472
|
+
hostMemoryGB: this._hostMemoryGB,
|
|
3473
|
+
sortMaterials: this.settings.get("wavefrontSortMaterials")
|
|
3474
|
+
}), this._extraStages = this._createExtraStages(), this.stages.compositor = new jt(this.renderer, {
|
|
3475
|
+
saturation: this.settings.get("saturation") ?? n.saturation,
|
|
3467
3476
|
pathTracer: this.stages.pathTracer,
|
|
3468
3477
|
displaySources: this._displaySources()
|
|
3469
3478
|
});
|
|
@@ -3472,13 +3481,13 @@ var qn = class extends F {
|
|
|
3472
3481
|
let e = this.stages.pathTracer;
|
|
3473
3482
|
if (!e) return;
|
|
3474
3483
|
let t = this.completion.isLimitReached(e, this.settings.get("renderLimitMode"), this.settings.get("renderTimeLimit"));
|
|
3475
|
-
t && !e.isComplete ? e.isComplete = !0 : !t && e.isComplete && (e.isComplete = !1, this.completion.resumeFromPause(), this._completionReopened(), this.dispatchEvent({ type:
|
|
3484
|
+
t && !e.isComplete ? e.isComplete = !0 : !t && e.isComplete && (e.isComplete = !1, this.completion.resumeFromPause(), this._completionReopened(), this.dispatchEvent({ type: g.RENDER_RESET }), this.wake());
|
|
3476
3485
|
}
|
|
3477
3486
|
_forwardEvents(e, t) {
|
|
3478
3487
|
if (e) for (let n of t) this._addTrackedListener(e, n, (e) => this.dispatchEvent(e));
|
|
3479
3488
|
}
|
|
3480
3489
|
_createCamera() {
|
|
3481
|
-
let e = new
|
|
3490
|
+
let e = new Pn(60, this.canvas.clientWidth / this.canvas.clientHeight || 1, .01, 1e3);
|
|
3482
3491
|
return e.position.set(0, 0, 5), e;
|
|
3483
3492
|
}
|
|
3484
3493
|
_createExtraStages() {
|
|
@@ -3539,4 +3548,4 @@ var qn = class extends F {
|
|
|
3539
3548
|
_disposeExtensions() {}
|
|
3540
3549
|
};
|
|
3541
3550
|
//#endregion
|
|
3542
|
-
export { Mt as _,
|
|
3551
|
+
export { Mt as _, tn as a, J as c, K as d, Qt as f, It as g, Lt as h, Pn as i, $t as l, Rt as m, Gn as n, Y as o, Ut as p, Ln as r, U as s, Kn as t, Zt as u };
|