rayzee 8.8.0 → 8.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/rayzee.es.js CHANGED
@@ -37370,7 +37370,7 @@ var uS = class e extends Xt {
37370
37370
  }
37371
37371
  }, pS = class extends Xt {
37372
37372
  constructor(e, t, n, r = {}) {
37373
- super(), this.scene = e, this.sceneHelpers = t, this.pathTracer = n, this._onReset = r.onReset || null;
37373
+ super(), this.scene = e, this.sceneHelpers = t, this.pathTracer = n, this._onReset = r.onReset || null, this._onLightRemoved = r.onLightRemoved || null;
37374
37374
  }
37375
37375
  addLight(e) {
37376
37376
  let t = {
@@ -37429,7 +37429,7 @@ var uS = class e extends Xt {
37429
37429
  }
37430
37430
  removeLight(e) {
37431
37431
  let t = this.scene.getObjectByProperty("uuid", e);
37432
- return !t || !t.isLight ? !1 : (this.sceneHelpers.remove(t), t.target && t.target.removeFromParent(), t.removeFromParent(), this.updateLights(), this._onReset?.(), !0);
37432
+ return !t || !t.isLight ? !1 : (this._onLightRemoved?.(t), this.sceneHelpers.remove(t), t.target && t.target.removeFromParent(), t.removeFromParent(), this.updateLights(), this._onReset?.(), !0);
37433
37433
  }
37434
37434
  clearLights() {
37435
37435
  this.sceneHelpers.clear(), this._removeAllLights(), this.updateLights(), this._onReset?.();
@@ -37479,11 +37479,11 @@ var uS = class e extends Xt {
37479
37479
  this.setShowLightHelper(e);
37480
37480
  }
37481
37481
  dispose() {
37482
- this._disposed || (this._disposed = !0, this.sceneHelpers?.clear(), this._removeAllLights(), this._onReset = null, this.pathTracer = null, this.sceneHelpers = null, this.scene = null);
37482
+ this._disposed || (this._disposed = !0, this._onLightRemoved = null, this.sceneHelpers?.clear(), this._removeAllLights(), this._onReset = null, this.pathTracer = null, this.sceneHelpers = null, this.scene = null);
37483
37483
  }
37484
37484
  _removeAllLights() {
37485
37485
  this.scene.getObjectsByProperty("isLight", !0).forEach((e) => {
37486
- e.target && this.scene.remove(e.target), this.scene.remove(e);
37486
+ this._onLightRemoved?.(e), e.target && this.scene.remove(e.target), this.scene.remove(e);
37487
37487
  });
37488
37488
  }
37489
37489
  _syncHelpers() {
@@ -40140,10 +40140,7 @@ var OC = 4096, kC = class {
40140
40140
  this._meshes = e;
40141
40141
  }
40142
40142
  attach(e) {
40143
- if (this._attached !== e && (this._controls.attach(e), this._attached = e, this._lightTargetDistance = null, this._lastLightPosition = null, e.isLight && e.target)) {
40144
- let t = e.target.position.clone().sub(e.position), n = t.length();
40145
- n > 1e-4 ? (e.quaternion.setFromUnitVectors(PC, t.normalize()), this._lightTargetDistance = n) : this._lightTargetDistance = 1, this._lastLightPosition = e.position.clone();
40146
- }
40143
+ this._attached !== e && (this._controls.attach(e), this._attached = e, this._lightTargetDistance = null, this._lastLightPosition = null, e.isLight && e.target && (this._syncLightAim(e), this._lastLightPosition = e.position.clone()));
40147
40144
  }
40148
40145
  detach() {
40149
40146
  this._attached && (this._controls.detach(), this._attached = null, this._lightTargetDistance = null, this._lastLightPosition = null);
@@ -40181,7 +40178,7 @@ var OC = 4096, kC = class {
40181
40178
  let e = this._attached;
40182
40179
  if (e.target) {
40183
40180
  let t = this._controls.mode;
40184
- if (t === "translate" && this._lastLightPosition) {
40181
+ if (t === "translate" && this._lastLightPosition && !e.isDirectionalLight) {
40185
40182
  let t = this._tempForward.copy(e.position).sub(this._lastLightPosition);
40186
40183
  e.target.position.add(t), e.target.updateMatrixWorld(!0);
40187
40184
  } else if (t === "rotate" && this._lightTargetDistance != null) {
@@ -40194,7 +40191,11 @@ var OC = 4096, kC = class {
40194
40191
  }
40195
40192
  _finalizeLightTransform() {
40196
40193
  let e = this._attached;
40197
- e.isRectAreaLight && (e.scale.x !== 1 || e.scale.y !== 1) && (e.width *= e.scale.x, e.height *= e.scale.y, e.scale.set(1, 1, 1)), this._app.lightManager?.updateLights();
40194
+ e.isDirectionalLight && e.target && this._controls.mode === "translate" && this._syncLightAim(e), e.isRectAreaLight && (e.scale.x !== 1 || e.scale.y !== 1) && (e.width *= e.scale.x, e.height *= e.scale.y, e.scale.set(1, 1, 1)), this._app.lightManager?.updateLights();
40195
+ }
40196
+ _syncLightAim(e) {
40197
+ let t = this._tempForward.copy(e.target.position).sub(e.position), n = t.length();
40198
+ n > 1e-4 ? (e.quaternion.setFromUnitVectors(PC, t.normalize()), this._lightTargetDistance = n) : this._lightTargetDistance = 1;
40198
40199
  }
40199
40200
  _recomputeAndRefit() {
40200
40201
  if (!this._meshes || this._refitInFlight || !this._attached) return;
@@ -41203,7 +41204,12 @@ var HC = class extends Xt {
41203
41204
  assetLoader: this.assetLoader,
41204
41205
  pathTracer: null,
41205
41206
  floorPlane: this.assetLoader.floorPlane
41206
- }), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new pS(this.scene, this._sceneHelpers, this.stages.pathTracer, { onReset: () => this.reset() }), this.goboManager = new mS(this.stages.pathTracer, { onReset: () => this.reset() }), this.iesManager = new TS(this.stages.pathTracer, { onReset: () => this.reset() }), this._setupDenoisingManager(), await this._setupOverlayManager(), this.transformManager = new FC({
41207
+ }), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new pS(this.scene, this._sceneHelpers, this.stages.pathTracer, {
41208
+ onReset: () => this.reset(),
41209
+ onLightRemoved: (e) => {
41210
+ this.interactionManager?.selectedObject === e && this.interactionManager.deselect();
41211
+ }
41212
+ }), this.goboManager = new mS(this.stages.pathTracer, { onReset: () => this.reset() }), this.iesManager = new TS(this.stages.pathTracer, { onReset: () => this.reset() }), this._setupDenoisingManager(), await this._setupOverlayManager(), this.transformManager = new FC({
41207
41213
  camera: this.cameraManager.camera,
41208
41214
  canvas: this.canvas,
41209
41215
  orbitControls: this.cameraManager.controls,