rayzee 7.9.1 → 7.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  # Rayzee Engine
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/rayzee?label=npm)](https://www.npmjs.com/package/rayzee)
4
- [![minzipped size](https://img.shields.io/badge/minzipped-163.7%20KB-blue)](https://www.npmjs.com/package/rayzee)
4
+ [![minzipped size](https://img.shields.io/badge/minzipped-164.9%20KB-blue)](https://www.npmjs.com/package/rayzee)
5
5
  [![downloads](https://img.shields.io/npm/dw/rayzee?label=downloads)](https://www.npmjs.com/package/rayzee)
6
6
  [![jsDelivr](https://img.shields.io/jsdelivr/npm/hm/rayzee?label=jsDelivr)](https://www.jsdelivr.com/package/npm/rayzee)
7
7
 
package/dist/rayzee.es.js CHANGED
@@ -9432,7 +9432,7 @@ function Iu({ hitBufferRO: e, activeIndicesReadRO: t, sortedIndicesRW: n, sortGl
9432
9432
  //#region src/Stages/PathTracer.js
9433
9433
  var Lu = class extends $s {
9434
9434
  constructor(e, t, n, r = {}) {
9435
- super(e, t, n, r), this.name = "PathTracer", this._packedBuffers = null, this._queueManager = null, this._kernelManager = null, this._gBufferAttr = null, this._wavefrontReady = !1, this._auxGBufferEnabled = !1, this._auxGBufferUniform = V(0, "uint"), this._useDynamicDispatch = !0, this._sortMaterials = !1, this._useSubgroupCompact = !1, this._lastBounceCounts = null, this._lastBounceCountsBudget = -1, this._readbackPending = !1, this._readbackEveryNFrames = 4, this._readbackFrameCounter = 0, this._readbackGeneration = 0, this._bounceEarlyExitThreshold = 100, this._wfRenderWidth = V(1920, "int"), this._wfRenderHeight = V(1080, "int"), this._wfMaxRayCount = V(0, "uint"), this._wfCurrentBounce = V(0, "int"), this.vramTracker = new Uc(this.renderer), this._registerVRAMProviders(), console.log("PathTracer: initialized (wavefront)");
9435
+ super(e, t, n, r), this.name = "PathTracer", this._packedBuffers = null, this._queueManager = null, this._kernelManager = null, this._gBufferAttr = null, this._wavefrontReady = !1, this._auxGBufferEnabled = !1, this._auxGBufferUniform = V(0, "uint"), this._useDynamicDispatch = !0, this._sortMaterials = !1, this._useSubgroupCompact = !1, this._lastBounceCounts = null, this._lastBounceCountsBudget = -1, this._readbackPending = !1, this._readbackEveryNFrames = 4, this._readbackFrameCounter = 0, this._readbackGeneration = 0, this._curveSizingValid = !1, this._bounceEarlyExitThreshold = 100, this._wfRenderWidth = V(1920, "int"), this._wfRenderHeight = V(1080, "int"), this._wfMaxRayCount = V(0, "uint"), this._wfCurrentBounce = V(0, "int"), this.vramTracker = new Uc(this.renderer), this._registerVRAMProviders(), console.log("PathTracer: initialized (wavefront)");
9436
9436
  }
9437
9437
  _registerVRAMProviders() {
9438
9438
  let e = this.vramTracker;
@@ -9487,7 +9487,7 @@ var Lu = class extends $s {
9487
9487
  }
9488
9488
  this.performanceMonitor?.start();
9489
9489
  let t = this.frameCount, n = this.renderMode.value, r = null;
9490
- n === 1 && t === 0 && (r = this.maxBounces.value, this.maxBounces.value = 1), this._handleResize(), this.manageASVGFForRenderMode(n), e && e.setState("tileRenderingComplete", !0), this.cameraChanged = this._updateCameraUniforms(), this.cameraOptimizer?.updateInteractionMode(this.cameraChanged), this._updateAccumulationUniforms(t, n), this.frame.value = t, this._setWfDispatch();
9490
+ n === 1 && t === 0 && (r = this.maxBounces.value, this.maxBounces.value = 1), this._handleResize(), this.manageASVGFForRenderMode(n), e && e.setState("tileRenderingComplete", !0), this.cameraChanged = this._updateCameraUniforms(), this.cameraOptimizer?.updateInteractionMode(this.cameraChanged), this.cameraChanged && (this._curveSizingValid = !1, this._readbackGeneration++), this._updateAccumulationUniforms(t, n), this.frame.value = t, this._setWfDispatch();
9491
9491
  let i = this.storageTextures.getReadTextures();
9492
9492
  this.shaderBuilder.prevColorTexNode && (this.shaderBuilder.prevColorTexNode.value = i.color, this.shaderBuilder.prevAlbedoTexNode.value = i.albedo), this._refreshWfTextureNodes();
9493
9493
  let a = this._kernelManager;
@@ -9504,7 +9504,7 @@ var Lu = class extends $s {
9504
9504
  let t = this._useDynamicDispatch;
9505
9505
  if (t) {
9506
9506
  let t = c;
9507
- if (e > 0) {
9507
+ if (e > 0 && this._curveSizingValid) {
9508
9508
  let n = e - 1, r;
9509
9509
  n < u && l[n] !== void 0 ? r = l[n] : u > 0 && (r = l[u - 1]), t = r > 0 ? r : c;
9510
9510
  }
@@ -9541,6 +9541,10 @@ var Lu = class extends $s {
9541
9541
  super.setSize(e, t), this._rebuildKernelsIfResized(n, r);
9542
9542
  }
9543
9543
  _maybeReadbackCounters() {
9544
+ if (this.cameraChanged || this.cameraOptimizer?.isInInteractionMode()) {
9545
+ this._readbackFrameCounter = this._readbackEveryNFrames;
9546
+ return;
9547
+ }
9544
9548
  if (this._readbackPending || (this._readbackFrameCounter++, this._readbackFrameCounter < this._readbackEveryNFrames)) return;
9545
9549
  this._readbackFrameCounter = 0;
9546
9550
  let e = this._queueManager?.getBounceCountsAttribute();
@@ -9548,7 +9552,7 @@ var Lu = class extends $s {
9548
9552
  this._readbackPending = !0;
9549
9553
  let t = this._readbackGeneration, n = this.maxBounces.value;
9550
9554
  this.renderer.getArrayBufferAsync(e).then((e) => {
9551
- t === this._readbackGeneration && (this._lastBounceCounts = new Uint32Array(e.slice(0)), this._lastBounceCountsBudget = n), this._readbackPending = !1;
9555
+ t === this._readbackGeneration && (this._lastBounceCounts = new Uint32Array(e.slice(0)), this._lastBounceCountsBudget = n, this._curveSizingValid = !0), this._readbackPending = !1;
9552
9556
  }).catch((e) => {
9553
9557
  console.warn("Wavefront bounceCounts readback failed:", e), this._readbackPending = !1;
9554
9558
  });
@@ -9564,7 +9568,7 @@ var Lu = class extends $s {
9564
9568
  _rebuildKernelsIfResized(e, t) {
9565
9569
  let n = this.storageTextures.renderWidth, r = this.storageTextures.renderHeight;
9566
9570
  if (n === e && r === t || !(this.materialData?.materialCount > 0)) return;
9567
- this._lastBounceCounts = null, this._lastBounceCountsBudget = -1, this._readbackFrameCounter = 0, this._readbackGeneration++;
9571
+ this._lastBounceCounts = null, this._lastBounceCountsBudget = -1, this._curveSizingValid = !1, this._readbackFrameCounter = 0, this._readbackGeneration++;
9568
9572
  let i = ac.requiredCapacity(n * r);
9569
9573
  !this._packedBuffers || i > this._packedBuffers.capacity ? (this._kernelManager && this._kernelManager.dispose(), this._wavefrontReady = !1, this._buildWavefrontKernels()) : this._resizeWavefrontInPlace(n, r);
9570
9574
  }
@@ -12808,12 +12812,47 @@ var Wd = {
12808
12812
  type: "archive",
12809
12813
  name: "ZIP Archive"
12810
12814
  }
12811
- }, Gd = class extends q {
12815
+ }, Gd = class e extends q {
12812
12816
  constructor(e, t, n) {
12813
- super(), this.scene = e, this.camera = t, this.controls = n, this.targetModel = null, this._externalModel = null, this.floorPlane = null, this.sceneScale = 1, this.loaderCache = {}, this.uploadedFileInfo = null, this.animations = [], this.renderer = null;
12817
+ super(), this.scene = e, this.camera = t, this.controls = n, this.targetModel = null, this._externalModel = null, this.floorPlane = null, this.sceneScale = 1, this.loaderCache = {}, this.uploadedFileInfo = null, this.animations = [], this.renderer = null, this._loadingManager = new ht(), this._loadCancelled = !1;
12818
+ }
12819
+ cancelActiveLoad() {
12820
+ this._loadCancelled = !0, this._loadingManager.abort();
12821
+ }
12822
+ _isCancellation(e) {
12823
+ return this._loadCancelled || e?.name === "AbortError" || e?.code === "LOAD_CANCELLED";
12824
+ }
12825
+ _cancellationError() {
12826
+ let e = /* @__PURE__ */ Error("Load cancelled");
12827
+ return e.code = "LOAD_CANCELLED", e;
12828
+ }
12829
+ _downloadProgress(e, t) {
12830
+ return (n) => {
12831
+ let r = n?.loaded || 0, i = n?.lengthComputable && n.total || 0;
12832
+ ar({
12833
+ isLoading: !0,
12834
+ status: e,
12835
+ loadedBytes: r,
12836
+ totalBytes: i,
12837
+ canCancel: !!t,
12838
+ progress: i ? Math.min(60, 2 + Math.round(r / i * 58)) : 2
12839
+ });
12840
+ };
12841
+ }
12842
+ _downloadComplete(e = "Processing Data...", t = 62) {
12843
+ ar({
12844
+ status: e,
12845
+ progress: t,
12846
+ canCancel: !1,
12847
+ loadedBytes: null,
12848
+ totalBytes: null
12849
+ });
12850
+ }
12851
+ static _isNetworkUrl(e) {
12852
+ return typeof e == "string" && /^https?:/i.test(e);
12814
12853
  }
12815
12854
  releaseTargetModel() {
12816
- this.targetModel && (this.targetModel === this._externalModel ? this.targetModel.parent?.remove(this.targetModel) : dr(this.targetModel), this.targetModel = null, this._externalModel = null);
12855
+ this.targetModel && (this.targetModel === this._externalModel ? this.targetModel.parent?.remove(this.targetModel) : dr(this.targetModel), this.targetModel = null, this._externalModel = null, this.animations = []);
12817
12856
  }
12818
12857
  setRenderer(e) {
12819
12858
  this.renderer = e;
@@ -12899,6 +12938,7 @@ var Wd = {
12899
12938
  }
12900
12939
  }
12901
12940
  async loadEnvironment(e) {
12941
+ this._loadCancelled = !1;
12902
12942
  try {
12903
12943
  this.dispatchEvent({
12904
12944
  type: "beforeEnvironmentLoad",
@@ -12915,11 +12955,11 @@ var Wd = {
12915
12955
  texture: t
12916
12956
  }), t;
12917
12957
  } catch (t) {
12918
- throw console.error("Error loading environment:", t), this.dispatchEvent({
12958
+ throw this._isCancellation(t) ? this._cancellationError() : (console.error("Error loading environment:", t), this.dispatchEvent({
12919
12959
  type: "error",
12920
12960
  message: t.message,
12921
12961
  filename: e
12922
- }), t;
12962
+ }), t);
12923
12963
  }
12924
12964
  }
12925
12965
  async loadEnvironmentFromBlob(e) {
@@ -12943,9 +12983,9 @@ var Wd = {
12943
12983
  }
12944
12984
  return !n && this.uploadedFileInfo && (n = this.uploadedFileInfo.name.split(".").pop().toLowerCase()), n;
12945
12985
  }
12946
- async loadEnvironmentByExtension(e, t) {
12947
- let n;
12948
- return t === "hdr" || t === "exr" ? n = await (t === "hdr" ? this.loaderCache.hdr || (this.loaderCache.hdr = new cn().setDataType(ct)) : this.loaderCache.exr || (this.loaderCache.exr = new dn().setDataType(ct))).loadAsync(e) : (this.loaderCache.texture || (this.loaderCache.texture = new Zt()), n = await this.loaderCache.texture.loadAsync(e), n.colorSpace = Wt), n.mapping = ot, n.minFilter = J, n.magFilter = J, n;
12986
+ async loadEnvironmentByExtension(t, n) {
12987
+ let r = e._isNetworkUrl(t), i = this._downloadProgress("Downloading Environment...", r), a;
12988
+ return n === "hdr" || n === "exr" ? a = await (n === "hdr" ? this.loaderCache.hdr || (this.loaderCache.hdr = new cn(this._loadingManager).setDataType(ct)) : this.loaderCache.exr || (this.loaderCache.exr = new dn(this._loadingManager).setDataType(ct))).loadAsync(t, i) : (this.loaderCache.texture || (this.loaderCache.texture = new Zt(this._loadingManager)), a = await this.loaderCache.texture.loadAsync(t, i), a.colorSpace = Wt), this._downloadComplete("Processing Environment...", 62), a.mapping = ot, a.minFilter = J, a.magFilter = J, a;
12949
12989
  }
12950
12990
  applyEnvironmentToScene(e) {
12951
12991
  this.scene.background = e, this.scene.environment = e;
@@ -13235,7 +13275,7 @@ var Wd = {
13235
13275
  bptcSupported: !1,
13236
13276
  pvrtcSupported: !1
13237
13277
  });
13238
- let i = new sn();
13278
+ let i = new sn(this._loadingManager);
13239
13279
  return i.setDRACOLoader(n), i.setKTX2Loader(r), i.setMeshoptDecoder(pn), i;
13240
13280
  }
13241
13281
  _disposeGLTFLoader(e) {
@@ -13246,32 +13286,66 @@ var Wd = {
13246
13286
  let n = `${t[e].url}`;
13247
13287
  return await this.loadModel(n);
13248
13288
  }
13249
- async loadModel(e) {
13250
- let t = await this.createGLTFLoader();
13289
+ async loadModel(t) {
13290
+ this._loadCancelled = !1;
13291
+ let n = await this.createGLTFLoader(), r = e._isNetworkUrl(t);
13251
13292
  try {
13252
13293
  ar({
13253
- status: "Loading Model...",
13254
- progress: 2
13294
+ isLoading: !0,
13295
+ status: "Downloading Model...",
13296
+ progress: 2,
13297
+ canCancel: r,
13298
+ loadedBytes: 0,
13299
+ totalBytes: 0
13255
13300
  });
13256
- let n = await t.loadAsync(e);
13257
- return ar({
13258
- status: "Processing Data...",
13259
- progress: 10
13260
- }), this.releaseTargetModel(), this.targetModel = n.scene, this.animations = n.animations || [], await this.onModelLoad(this.targetModel), this.dispatchEvent({
13301
+ let e = await n.loadAsync(t, this._downloadProgress("Downloading Model...", r));
13302
+ return this._downloadComplete(), this.releaseTargetModel(), this.targetModel = e.scene, this.animations = e.animations || [], await this.onModelLoad(this.targetModel), this.dispatchEvent({
13261
13303
  type: "load",
13262
- model: n.scene,
13263
- filename: e.split("/").pop()
13264
- }), n;
13265
- } catch (t) {
13266
- throw console.error("Error loading model:", t), this.dispatchEvent({
13304
+ model: e.scene,
13305
+ filename: t.split("/").pop()
13306
+ }), e;
13307
+ } catch (e) {
13308
+ throw this._isCancellation(e) ? this._cancellationError() : (console.error("Error loading model:", e), this.dispatchEvent({
13267
13309
  type: "error",
13268
- message: t.message,
13269
- filename: e
13270
- }), t;
13310
+ message: e.message,
13311
+ filename: t
13312
+ }), e);
13313
+ } finally {
13314
+ this._disposeGLTFLoader(n);
13315
+ }
13316
+ }
13317
+ _processAndParent(e) {
13318
+ this.processModelObjects(e), this.scene.add(e), e.updateMatrixWorld(!0);
13319
+ }
13320
+ async appendModel(t) {
13321
+ this._loadCancelled = !1;
13322
+ let n = await this.createGLTFLoader(), r = e._isNetworkUrl(t);
13323
+ try {
13324
+ ar({
13325
+ isLoading: !0,
13326
+ status: "Downloading Model...",
13327
+ progress: 2,
13328
+ canCancel: r,
13329
+ loadedBytes: 0,
13330
+ totalBytes: 0
13331
+ });
13332
+ let e = await n.loadAsync(t, this._downloadProgress("Downloading Model...", r));
13333
+ return this._downloadComplete(), this._processAndParent(e.scene), {
13334
+ root: e.scene,
13335
+ animations: e.animations || []
13336
+ };
13337
+ } catch (e) {
13338
+ throw this._isCancellation(e) ? this._cancellationError() : e;
13271
13339
  } finally {
13272
- this._disposeGLTFLoader(t);
13340
+ this._disposeGLTFLoader(n);
13273
13341
  }
13274
13342
  }
13343
+ appendObject3D(e, t = "object3d") {
13344
+ return e.name = e.name || t, this._processAndParent(e), { root: e };
13345
+ }
13346
+ removeModelRoot(e, { external: t = !1 } = {}) {
13347
+ e && (t ? e.parent?.remove(e) : dr(e));
13348
+ }
13275
13349
  async loadGLBFromArrayBuffer(e, t = "model.glb") {
13276
13350
  let n = await this.createGLTFLoader();
13277
13351
  try {
@@ -15610,7 +15684,7 @@ var If = {
15610
15684
  indices: i
15611
15685
  }), this._skinnedCache.push(new Float32Array(o * 3)), this._normalCache.push(new Float32Array(o * 3)), t += a;
15612
15686
  }
15613
- this._posBuffer = new Float32Array(t * 9), this._normalBuffer = new Float32Array(t * 9);
15687
+ this._posBuffer = new Float32Array(t * 9), this._normalBuffer = new Float32Array(t * 9), this._baselineComputed = !1;
15614
15688
  }
15615
15689
  attach(e) {
15616
15690
  this._attached !== e && (this._controls.attach(e), this._attached = e);
@@ -15856,6 +15930,9 @@ var If = {
15856
15930
  index: e
15857
15931
  });
15858
15932
  }
15933
+ cancelLoad() {
15934
+ this._loadingInProgress && this.assetLoader?.cancelActiveLoad();
15935
+ }
15859
15936
  async setMaxTextureSize(e, { reprocess: t = !0 } = {}) {
15860
15937
  let n = this._maxTextureSize;
15861
15938
  if (this._maxTextureSize = this._sdf?.setMaxTextureSize(e) ?? e, typeof this.stages?.pathTracer?.sdfs?.setMaxTextureSize == "function" && this.stages.pathTracer.sdfs.setMaxTextureSize(this._maxTextureSize), t && this._maxTextureSize !== n && this._sdf?.triangleData && !this._loadingInProgress) {
@@ -15874,7 +15951,7 @@ var If = {
15874
15951
  if (this._loadingInProgress) throw Error("PathTracerApp: another load is already in progress");
15875
15952
  this._loadingInProgress = !0;
15876
15953
  try {
15877
- await e(), this._syncControlsAfterLoad(), await this.loadSceneData(), this.pipeline?.eventBus.emit("autoexposure:resetHistory"), this.reset(), this.cameraManager.currentCameraIndex = 0, this.dispatchEvent(t), this.dispatchEvent({
15954
+ await e(), this._clearAppendedModels(), this._syncControlsAfterLoad(), await this.loadSceneData(), this.pipeline?.eventBus.emit("autoexposure:resetHistory"), this.reset(), this.cameraManager.currentCameraIndex = 0, this.dispatchEvent(t), this.dispatchEvent({
15878
15955
  type: "CamerasUpdated",
15879
15956
  cameras: this.cameraManager.cameras,
15880
15957
  cameraNames: this.cameraManager.getCameraNames()
@@ -15884,7 +15961,7 @@ var If = {
15884
15961
  }
15885
15962
  }
15886
15963
  async loadSceneData() {
15887
- this.interactionManager?.deselect(), this.animationManager.dispose(), this._animRefitInFlight = !1;
15964
+ this._preserveSelectionOnRebuild || this.interactionManager?.deselect(), this.animationManager.dispose(), this._animRefitInFlight = !1, this._tagPrimarySceneObject();
15888
15965
  let e = new zs("loadSceneData"), t = this.meshScene.environment, n = null;
15889
15966
  if (t?.image?.data && (e.start("Environment CDF build (worker)"), this.stages.pathTracer.scene.environment = t, n = this.stages.pathTracer.environment.buildEnvironmentCDF().then(() => e.end("Environment CDF build (worker)"))), e.start("BVH build (SceneProcessor)"), this._sdf.setMaxTextureSize(this._maxTextureSize), await this._sdf.buildBVH(this.meshScene), e.end("BVH build (SceneProcessor)"), ar({
15890
15967
  status: "Transferring data to GPU...",
@@ -15906,6 +15983,67 @@ var If = {
15906
15983
  let r = this.getSceneMinY();
15907
15984
  return this.settings.set("groundProjectionLevel", r, { reset: !1 }), this.settings.set("groundCatcherHeight", r, { reset: !1 }), e.start("Apply settings"), this.settings.applyAll(), this.stages.compositor.setTransparentBackground(this.settings.get("transparentBackground")), e.end("Apply settings"), e.print(), ir(), this._initAnimationAndTransforms(), this.dispatchEvent({ type: "SceneRebuild" }), !0;
15908
15985
  }
15986
+ _tagPrimarySceneObject() {
15987
+ let e = this.assetLoader?.targetModel;
15988
+ e && (e.userData.__rayzeeSceneObject = !0, e.userData.__rayzeeExternal = e === this.assetLoader._externalModel);
15989
+ }
15990
+ _clearAppendedModels() {
15991
+ let e = this.meshScene;
15992
+ if (!e) return;
15993
+ let t = this.assetLoader?.floorPlane, n = this.assetLoader?.targetModel;
15994
+ for (let r of [...e.children]) r === t || r === n || r.userData?.__rayzeeSceneObject && this.assetLoader.removeModelRoot(r, { external: !!r.userData.__rayzeeExternal });
15995
+ }
15996
+ async _finishRebuildNoReframe(e) {
15997
+ await this.loadSceneData(), this.pipeline?.eventBus.emit("autoexposure:resetHistory"), this.reset(), e && this.dispatchEvent(e);
15998
+ }
15999
+ async addModel(e, { name: t } = {}) {
16000
+ if (this._loadingInProgress) throw Error("PathTracerApp.addModel: another load is already in progress");
16001
+ this._loadingInProgress = !0, this._preserveSelectionOnRebuild = !0;
16002
+ try {
16003
+ let { root: n } = await this.assetLoader.appendModel(e);
16004
+ return n.userData.__rayzeeSceneObject = !0, n.userData.__rayzeeExternal = !1, t && (n.userData.__rayzeeName = t), await this._finishRebuildNoReframe({
16005
+ type: "ModelAdded",
16006
+ url: e,
16007
+ id: n.uuid
16008
+ }), n.uuid;
16009
+ } finally {
16010
+ this._preserveSelectionOnRebuild = !1, this._loadingInProgress = !1;
16011
+ }
16012
+ }
16013
+ async addModelFromObject3D(e, { name: t } = {}) {
16014
+ if (this._loadingInProgress) throw Error("PathTracerApp.addModelFromObject3D: another load is already in progress");
16015
+ this._loadingInProgress = !0, this._preserveSelectionOnRebuild = !0;
16016
+ try {
16017
+ let { root: n } = this.assetLoader.appendObject3D(e, t || "object3d");
16018
+ return n.userData.__rayzeeSceneObject = !0, n.userData.__rayzeeExternal = !0, t && (n.userData.__rayzeeName = t), await this._finishRebuildNoReframe({
16019
+ type: "ModelAdded",
16020
+ id: n.uuid
16021
+ }), n.uuid;
16022
+ } finally {
16023
+ this._preserveSelectionOnRebuild = !1, this._loadingInProgress = !1;
16024
+ }
16025
+ }
16026
+ async removeSceneObject(e) {
16027
+ let t = this.meshScene;
16028
+ if (!t) return !1;
16029
+ let n = this.assetLoader?.floorPlane;
16030
+ if (n && n.uuid === e) return !1;
16031
+ let r = t.children.find((t) => t.uuid === e && t.userData?.__rayzeeSceneObject);
16032
+ if (!r) return !1;
16033
+ if (this._loadingInProgress) throw Error("PathTracerApp.removeSceneObject: another load is already in progress");
16034
+ this._loadingInProgress = !0;
16035
+ try {
16036
+ return this.interactionManager?.deselect(), this.transformManager?.detach?.(), r === this.assetLoader.targetModel ? this.assetLoader.releaseTargetModel() : this.assetLoader.removeModelRoot(r, { external: !!r.userData.__rayzeeExternal }), await this._finishRebuildNoReframe({
16037
+ type: "SceneObjectRemoved",
16038
+ id: e
16039
+ }), !0;
16040
+ } finally {
16041
+ this._loadingInProgress = !1;
16042
+ }
16043
+ }
16044
+ setSceneObjectVisibility(e, t) {
16045
+ return this.setMeshVisibilityByUuid(e, t);
16046
+ }
15909
16047
  async refitBVH(e, t) {
15910
16048
  let n = await this._sdf.refitBVH(e, t);
15911
16049
  return this.stages.pathTracer.updateTriangleData(this._sdf.triangleData), this.stages.pathTracer.updateBVHData(this._sdf.bvhData), this.reset(), n;
@@ -16139,7 +16277,7 @@ var If = {
16139
16277
  reconcileCompletion: () => this._reconcileCompletion()
16140
16278
  }), this.renderer.toneMappingExposure = this.settings.get("exposure") ?? 1, this.onResize(), this.resizeHandler = () => this.onResize(), this._autoResize && this._addTrackedListener(window, "resize", this.resizeHandler), this._onAssetLoaded = async (e) => {
16141
16279
  if (!this._loadingInProgress) {
16142
- if (e.model) await this.loadSceneData();
16280
+ if (e.model) this._clearAppendedModels(), await this.loadSceneData();
16143
16281
  else if (e.texture) {
16144
16282
  let e = this.meshScene.environment;
16145
16283
  e && this.stages.pathTracer && await this.stages.pathTracer.environment.setEnvironmentMap(e), ir();