rayzee 7.14.0 → 7.15.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-169.1%20KB-blue)](https://www.npmjs.com/package/rayzee)
4
+ [![minzipped size](https://img.shields.io/badge/minzipped-169.6%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
@@ -11650,10 +11650,10 @@ var Yu = class extends lc {
11650
11650
  }
11651
11651
  }, Cd = class extends st {
11652
11652
  constructor({ scene: e, camera: t, canvas: n, assetLoader: r, pathTracer: i, floorPlane: a }) {
11653
- super(), this.scene = e, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new zt(), this.focusMode = !1, this.focusPointIndicator = null, this.afPointPlacementMode = !1, this.handleAFPointClick = this.handleAFPointClick.bind(this), this.selectedObject = null, this.selectMode = !1, this.clickTimeout = null, this.mouseDownPosition = null, this.dragThreshold = 5, this.handleFocusClick = this.handleFocusClick.bind(this), this.handleSelectClick = this.handleSelectClick.bind(this), this.handleSelectDoubleClick = this.handleSelectDoubleClick.bind(this), this.handleMouseDown = this.handleMouseDown.bind(this), this.handleMouseUp = this.handleMouseUp.bind(this), this.handleContextMenu = this.handleContextMenu.bind(this), this.handleContextPointerDown = this.handleContextPointerDown.bind(this), this.handleContextPointerUp = this.handleContextPointerUp.bind(this), this.contextPointerDownPosition = null, this.canvas.addEventListener("pointerdown", this.handleContextPointerDown), this.canvas.addEventListener("pointerup", this.handleContextPointerUp), this.canvas.addEventListener("contextmenu", this.handleContextMenu), this._overlayManager = null, this._transformManager = null, this._appDispatch = null, this._orbitControls = null;
11653
+ super(), this.scene = e, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new zt(), this.focusMode = !1, this.focusPointIndicator = null, this.afPointPlacementMode = !1, this.handleAFPointClick = this.handleAFPointClick.bind(this), this.selectedObject = null, this.selectMode = !1, this.clickTimeout = null, this.mouseDownPosition = null, this.dragThreshold = 5, this.handleFocusClick = this.handleFocusClick.bind(this), this.handleSelectClick = this.handleSelectClick.bind(this), this.handleSelectDoubleClick = this.handleSelectDoubleClick.bind(this), this.handleMouseDown = this.handleMouseDown.bind(this), this.handleMouseUp = this.handleMouseUp.bind(this), this.handleContextMenu = this.handleContextMenu.bind(this), this.handleContextPointerDown = this.handleContextPointerDown.bind(this), this.handleContextPointerUp = this.handleContextPointerUp.bind(this), this.contextPointerDownPosition = null, this.canvas.addEventListener("pointerdown", this.handleContextPointerDown), this.canvas.addEventListener("pointerup", this.handleContextPointerUp), this.canvas.addEventListener("contextmenu", this.handleContextMenu), this._overlayManager = null, this._transformManager = null, this._appDispatch = null, this._orbitControls = null, this._helperScene = null;
11654
11654
  }
11655
- setDependencies({ overlayManager: e, transformManager: t, appDispatch: n, orbitControls: r }) {
11656
- this._overlayManager = e || null, this._transformManager = t || null, this._appDispatch = n || null, this._orbitControls = r || null;
11655
+ setDependencies({ overlayManager: e, transformManager: t, appDispatch: n, orbitControls: r, helperScene: i }) {
11656
+ this._overlayManager = e || null, this._transformManager = t || null, this._appDispatch = n || null, this._orbitControls = r || null, this._helperScene = i || null;
11657
11657
  }
11658
11658
  select(e) {
11659
11659
  let t = this._overlayManager?.getHelper("outline");
@@ -11753,17 +11753,17 @@ var Yu = class extends lc {
11753
11753
  this.clickTimeout = null;
11754
11754
  let t = this.getMouseCoordinates(e);
11755
11755
  this.raycaster.setFromCamera(t, this.camera);
11756
- let n = this.raycaster.intersectObjects(this.scene.children, !0), r = this.filterValidIntersects(n);
11757
- if (r.length > 0) {
11758
- let e = r[0].object, t = this.selectedObject;
11759
- t && t.uuid === e.uuid ? this.dispatchEvent({
11756
+ let n = this.raycaster.intersectObjects(this.scene.children, !0), r = this.filterValidIntersects(n), i = this._pickLightHelper(), a = null;
11757
+ if (r.length > 0 && i ? a = r[0].distance <= i.distance ? r[0].object : i.light : r.length > 0 ? a = r[0].object : i && (a = i.light), a) {
11758
+ let e = this.selectedObject;
11759
+ e && e.uuid === a.uuid ? this.dispatchEvent({
11760
11760
  type: "objectDeselected",
11761
- object: e,
11762
- uuid: e.uuid
11761
+ object: a,
11762
+ uuid: a.uuid
11763
11763
  }) : this.dispatchEvent({
11764
11764
  type: "objectSelected",
11765
- object: e,
11766
- uuid: e.uuid
11765
+ object: a,
11766
+ uuid: a.uuid
11767
11767
  });
11768
11768
  } else this.dispatchEvent({ type: "objectDeselected" });
11769
11769
  }, 250);
@@ -11827,6 +11827,21 @@ var Yu = class extends lc {
11827
11827
  return t !== this.focusPointIndicator && t !== this.floorPlane && !t.name.includes("Helper") && t.type === "Mesh";
11828
11828
  });
11829
11829
  }
11830
+ _pickLightHelper() {
11831
+ if (!this._helperScene || this._helperScene.children.length === 0) return null;
11832
+ let e = this.raycaster.intersectObjects(this._helperScene.children, !0);
11833
+ for (let t of e) {
11834
+ let e = t.object;
11835
+ for (; e;) {
11836
+ if (e.light) return {
11837
+ distance: t.distance,
11838
+ light: e.light
11839
+ };
11840
+ e = e.parent;
11841
+ }
11842
+ }
11843
+ return null;
11844
+ }
11830
11845
  updateDependencies({ scene: e, camera: t, floorPlane: n }) {
11831
11846
  e && (this.scene = e), t && (this.camera = t), n && (this.floorPlane = n);
11832
11847
  }
@@ -16024,9 +16039,9 @@ var Yf = {
16024
16039
  dispose() {
16025
16040
  this.mixer &&= (this.mixer.stopAllAction(), this.mixer.uncacheRoot(this._mixerRoot), null), this.actions = [], this.isPlaying = !1, this.timer.reset(), this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._skinnedCache = null, this._clipsCache = null;
16026
16041
  }
16027
- }, np = class {
16042
+ }, np = new rn(0, 0, -1), rp = class {
16028
16043
  constructor({ camera: e, canvas: t, orbitControls: n, app: r }) {
16029
- this._app = r, this._orbitControls = n, this._camera = e, this._controls = new vn(e, t), this._gizmoScene = new Gt(), this._gizmoScene.add(this._controls.getHelper()), this._attached = null, this._isDragging = !1, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._tempVec = new rn(), this._normalMatrix = new yt(), this._refitInFlight = !1, this._baselineComputed = !1, this._onDraggingChanged = this._onDraggingChanged.bind(this), this._onObjectChange = this._onObjectChange.bind(this), this._controls.addEventListener("dragging-changed", this._onDraggingChanged), this._controls.addEventListener("objectChange", this._onObjectChange);
16044
+ this._app = r, this._orbitControls = n, this._camera = e, this._controls = new vn(e, t), this._gizmoScene = new Gt(), this._gizmoScene.add(this._controls.getHelper()), this._attached = null, this._isDragging = !1, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._tempVec = new rn(), this._normalMatrix = new yt(), this._refitInFlight = !1, this._baselineComputed = !1, this._tempForward = new rn(), this._lightTargetDistance = null, this._lastLightPosition = null, this._onDraggingChanged = this._onDraggingChanged.bind(this), this._onObjectChange = this._onObjectChange.bind(this), this._controls.addEventListener("dragging-changed", this._onDraggingChanged), this._controls.addEventListener("objectChange", this._onObjectChange);
16030
16045
  }
16031
16046
  setMeshData(e) {
16032
16047
  this._meshes = e, this._meshTriRanges = [], this._skinnedCache = [], this._normalCache = [];
@@ -16043,19 +16058,22 @@ var Yf = {
16043
16058
  this._posBuffer = new Float32Array(t * 9), this._normalBuffer = new Float32Array(t * 9), this._baselineComputed = !1;
16044
16059
  }
16045
16060
  attach(e) {
16046
- this._attached !== e && (this._controls.attach(e), this._attached = e);
16061
+ if (this._attached !== e && (this._controls.attach(e), this._attached = e, this._lightTargetDistance = null, this._lastLightPosition = null, e.isLight && e.target)) {
16062
+ let t = e.target.position.clone().sub(e.position), n = t.length();
16063
+ n > 1e-4 ? (e.quaternion.setFromUnitVectors(np, t.normalize()), this._lightTargetDistance = n) : this._lightTargetDistance = 1, this._lastLightPosition = e.position.clone();
16064
+ }
16047
16065
  }
16048
16066
  detach() {
16049
- this._attached &&= (this._controls.detach(), null);
16067
+ this._attached && (this._controls.detach(), this._attached = null, this._lightTargetDistance = null, this._lastLightPosition = null);
16050
16068
  }
16051
16069
  setMode(e) {
16052
16070
  this._controls.setMode(e), this._app?.dispatchEvent({
16053
16071
  type: Y.TRANSFORM_MODE_CHANGED,
16054
16072
  mode: e
16055
- });
16073
+ }), this._app?.refreshFrame();
16056
16074
  }
16057
16075
  setSpace(e) {
16058
- this._controls.setSpace(e);
16076
+ this._controls.setSpace(e), this._app?.refreshFrame();
16059
16077
  }
16060
16078
  get isDragging() {
16061
16079
  return this._isDragging;
@@ -16072,10 +16090,29 @@ var Yf = {
16072
16090
  e.autoClear = !1, e.clearDepth(), e.setRenderTarget(null), e.render(this._gizmoScene, this._camera), e.autoClear = t;
16073
16091
  }
16074
16092
  _onDraggingChanged(e) {
16075
- this._isDragging = e.value, this._orbitControls && (this._orbitControls.enabled = !e.value), e.value ? this._app.dispatchEvent({ type: Y.OBJECT_TRANSFORM_START }) : (this._recomputeAndRefit(), this._app.dispatchEvent({ type: Y.OBJECT_TRANSFORM_END }));
16093
+ this._isDragging = e.value, this._orbitControls && (this._orbitControls.enabled = !e.value), e.value ? this._app.dispatchEvent({ type: Y.OBJECT_TRANSFORM_START }) : (this._attached?.isLight ? this._finalizeLightTransform() : this._recomputeAndRefit(), this._app.dispatchEvent({ type: Y.OBJECT_TRANSFORM_END }));
16076
16094
  }
16077
16095
  _onObjectChange() {
16078
- this._app.needsReset = !0, this._app.wake();
16096
+ this._app.needsReset = !0, this._app.wake(), this._attached?.isLight && this._syncLightDuringDrag();
16097
+ }
16098
+ _syncLightDuringDrag() {
16099
+ let e = this._attached;
16100
+ if (e.target) {
16101
+ let t = this._controls.mode;
16102
+ if (t === "translate" && this._lastLightPosition) {
16103
+ let t = this._tempForward.copy(e.position).sub(this._lastLightPosition);
16104
+ e.target.position.add(t), e.target.updateMatrixWorld(!0);
16105
+ } else if (t === "rotate" && this._lightTargetDistance != null) {
16106
+ let t = this._tempForward.set(0, 0, -1).applyQuaternion(e.quaternion);
16107
+ e.target.position.copy(e.position).addScaledVector(t, this._lightTargetDistance), e.target.updateMatrixWorld(!0);
16108
+ }
16109
+ this._lastLightPosition.copy(e.position);
16110
+ }
16111
+ this._app.lightManager?.updateLights();
16112
+ }
16113
+ _finalizeLightTransform() {
16114
+ let e = this._attached;
16115
+ 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();
16079
16116
  }
16080
16117
  _recomputeAndRefit() {
16081
16118
  if (!this._meshes || !this._posBuffer || this._refitInFlight || !this._attached) return;
@@ -16133,17 +16170,17 @@ var Yf = {
16133
16170
  }
16134
16171
  }
16135
16172
  dispose() {
16136
- this._controls.removeEventListener("dragging-changed", this._onDraggingChanged), this._controls.removeEventListener("objectChange", this._onObjectChange), this.detach(), this._gizmoScene.remove(this._controls.getHelper()), this._controls.dispose(), this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._baselineComputed = !1, this._app = null, this._orbitControls = null, this._camera = null, this._controls = null, this._gizmoScene = null;
16173
+ this._controls.removeEventListener("dragging-changed", this._onDraggingChanged), this._controls.removeEventListener("objectChange", this._onObjectChange), this.detach(), this._gizmoScene.remove(this._controls.getHelper()), this._controls.dispose(), this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._baselineComputed = !1, this._tempForward = null, this._lightTargetDistance = null, this._lastLightPosition = null, this._app = null, this._orbitControls = null, this._camera = null, this._controls = null, this._gizmoScene = null;
16137
16174
  }
16138
- }, rp = /* @__PURE__ */ new WeakMap(), ip = class extends st {
16175
+ }, ip = /* @__PURE__ */ new WeakMap(), ap = class extends st {
16139
16176
  constructor(e, t = {}) {
16140
16177
  super();
16141
16178
  try {
16142
- rp.get(e)?.dispose();
16179
+ ip.get(e)?.dispose();
16143
16180
  } catch (e) {
16144
16181
  console.warn("PathTracerApp: prior canvas owner dispose failed", e);
16145
16182
  }
16146
- rp.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._container = t.container || null, this.settings = new cf(X), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this._maxTextureSize = X.maxTextureSize, this.pipeline = null, this.stages = {}, this.cameraManager = null, this.lightManager = null, this.goboManager = null, this.iesManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new tp(), this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this.pathTracerEnabled = !0, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this._emissiveSamplingUserSet = !1, this.completion = new Sd(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1, this._deviceLost = !1;
16183
+ ip.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._container = t.container || null, this.settings = new cf(X), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this._maxTextureSize = X.maxTextureSize, this.pipeline = null, this.stages = {}, this.cameraManager = null, this.lightManager = null, this.goboManager = null, this.iesManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new tp(), this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this.pathTracerEnabled = !0, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this._emissiveSamplingUserSet = !1, this.completion = new Sd(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1, this._deviceLost = !1;
16147
16184
  }
16148
16185
  _addTrackedListener(e, t, n) {
16149
16186
  e && (e.addEventListener(t, n), this._trackedListeners.push({
@@ -16596,7 +16633,7 @@ var Yf = {
16596
16633
  assetLoader: this.assetLoader,
16597
16634
  pathTracer: null,
16598
16635
  floorPlane: this.assetLoader.floorPlane
16599
- }), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new uf(this.scene, this._sceneHelpers, this.stages.pathTracer, { onReset: () => this.reset() }), this.goboManager = new df(this.stages.pathTracer, { onReset: () => this.reset() }), this.iesManager = new Sf(this.stages.pathTracer, { onReset: () => this.reset() }), this._setupDenoisingManager(), this._setupOverlayManager(), this.transformManager = new np({
16636
+ }), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new uf(this.scene, this._sceneHelpers, this.stages.pathTracer, { onReset: () => this.reset() }), this.goboManager = new df(this.stages.pathTracer, { onReset: () => this.reset() }), this.iesManager = new Sf(this.stages.pathTracer, { onReset: () => this.reset() }), this._setupDenoisingManager(), this._setupOverlayManager(), this.transformManager = new rp({
16600
16637
  camera: this.cameraManager.camera,
16601
16638
  canvas: this.canvas,
16602
16639
  orbitControls: this.cameraManager.controls,
@@ -16605,7 +16642,8 @@ var Yf = {
16605
16642
  overlayManager: this.overlayManager,
16606
16643
  transformManager: this.transformManager,
16607
16644
  appDispatch: (e) => this.dispatchEvent(e),
16608
- orbitControls: this.cameraManager.controls
16645
+ orbitControls: this.cameraManager.controls,
16646
+ helperScene: this._sceneHelpers.scene
16609
16647
  }), this.denoisingManager.setOverlayManager(this.overlayManager), this.denoisingManager.setResetCallback(() => this.reset()), this.denoisingManager.setSettings(this.settings), this.environmentManager = this.stages.pathTracer.environment, this.environmentManager.callbacks.onAutoExposureReset = () => this.pipeline.eventBus.emit("autoexposure:resetHistory");
16610
16648
  }
16611
16649
  _wireEvents() {
@@ -16740,7 +16778,7 @@ var Yf = {
16740
16778
  _forwardEvents(e, t) {
16741
16779
  if (e) for (let n of t) this._addTrackedListener(e, n, (e) => this.dispatchEvent(e));
16742
16780
  }
16743
- }, ap = class {
16781
+ }, op = class {
16744
16782
  constructor(e) {
16745
16783
  this._app = e, this._cancelled = !1, this._rendering = !1;
16746
16784
  }
@@ -16838,6 +16876,6 @@ var Yf = {
16838
16876
  }
16839
16877
  };
16840
16878
  //#endregion
16841
- export { xr as AF_DEFAULTS, gr as ASVGF_QUALITY_PRESETS, br as AUTO_FOCUS_MODES, tp as AnimationManager, Sr as BVH_LEAF_MARKERS, yr as CAMERA_PRESETS, _r as CAMERA_RANGES, lf as CameraManager, Dr as DEFAULT_TEXTURE_MATRIX, Zf as DenoisingManager, X as ENGINE_DEFAULTS, Y as EngineEvents, df as GoboManager, Sf as IESManager, kr as INTERACTIVE_RENDER_CONFIG, Cd as InteractionManager, uf as LightManager, Ar as MEMORY_CONSTANTS, ep as OverlayManager, Or as PRODUCTION_RENDER_CONFIG, ip as PathTracerApp, yd as PipelineContext, xd as RenderPipeline, cf as RenderSettings, $n as RenderStage, vr as SKY_PRESETS, Qn as StageExecutionMode, Cr as TEXTURE_CONSTANTS, Z as TRIANGLE_DATA_LAYOUT, np as TransformManager, $c as VRAMTracker, ap as VideoRenderManager, Zc as bufferBytes, oc as configureAssets, sc as getAssetConfig, Qc as textureBytes };
16879
+ export { xr as AF_DEFAULTS, gr as ASVGF_QUALITY_PRESETS, br as AUTO_FOCUS_MODES, tp as AnimationManager, Sr as BVH_LEAF_MARKERS, yr as CAMERA_PRESETS, _r as CAMERA_RANGES, lf as CameraManager, Dr as DEFAULT_TEXTURE_MATRIX, Zf as DenoisingManager, X as ENGINE_DEFAULTS, Y as EngineEvents, df as GoboManager, Sf as IESManager, kr as INTERACTIVE_RENDER_CONFIG, Cd as InteractionManager, uf as LightManager, Ar as MEMORY_CONSTANTS, ep as OverlayManager, Or as PRODUCTION_RENDER_CONFIG, ap as PathTracerApp, yd as PipelineContext, xd as RenderPipeline, cf as RenderSettings, $n as RenderStage, vr as SKY_PRESETS, Qn as StageExecutionMode, Cr as TEXTURE_CONSTANTS, Z as TRIANGLE_DATA_LAYOUT, rp as TransformManager, $c as VRAMTracker, op as VideoRenderManager, Zc as bufferBytes, oc as configureAssets, sc as getAssetConfig, Qc as textureBytes };
16842
16880
 
16843
16881
  //# sourceMappingURL=rayzee.es.js.map