@relu-interactives/spatial-ecs 0.2.15 → 0.2.16

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.
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var THREE13 = require('three');
3
+ var THREE14 = require('three');
4
+ require('three/examples/jsm/utils/SkeletonUtils.js');
4
5
  var DRACOLoader_js = require('three/examples/jsm/loaders/DRACOLoader.js');
5
6
  var FBXLoader_js = require('three/examples/jsm/loaders/FBXLoader.js');
6
7
  var GLTFLoader_js = require('three/examples/jsm/loaders/GLTFLoader.js');
@@ -37,7 +38,7 @@ function _interopNamespace(e) {
37
38
  return Object.freeze(n);
38
39
  }
39
40
 
40
- var THREE13__namespace = /*#__PURE__*/_interopNamespace(THREE13);
41
+ var THREE14__namespace = /*#__PURE__*/_interopNamespace(THREE14);
41
42
 
42
43
  var __defProp = Object.defineProperty;
43
44
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -98,14 +99,14 @@ var _TransformComponent = class _TransformComponent extends Component {
98
99
  z: scale.z ?? 1
99
100
  };
100
101
  }
101
- toPositionVector3(target = new THREE13.Vector3()) {
102
+ toPositionVector3(target = new THREE14.Vector3()) {
102
103
  return target.set(this.position.x, this.position.y, this.position.z);
103
104
  }
104
- toRotationEuler(target = new THREE13.Euler(), order = "XYZ") {
105
+ toRotationEuler(target = new THREE14.Euler(), order = "XYZ") {
105
106
  return target.set(this.rotation.x, this.rotation.y, this.rotation.z, order);
106
107
  }
107
- toRotationQuaternion(target = new THREE13.Quaternion(), order = "XYZ") {
108
- const euler = new THREE13.Euler(
108
+ toRotationQuaternion(target = new THREE14.Quaternion(), order = "XYZ") {
109
+ const euler = new THREE14.Euler(
109
110
  this.rotation.x,
110
111
  this.rotation.y,
111
112
  this.rotation.z,
@@ -113,7 +114,7 @@ var _TransformComponent = class _TransformComponent extends Component {
113
114
  );
114
115
  return target.setFromEuler(euler);
115
116
  }
116
- toScaleVector3(target = new THREE13.Vector3()) {
117
+ toScaleVector3(target = new THREE14.Vector3()) {
117
118
  return target.set(this.scale.x, this.scale.y, this.scale.z);
118
119
  }
119
120
  setPosition(input) {
@@ -131,8 +132,8 @@ var _TransformComponent = class _TransformComponent extends Component {
131
132
  return this;
132
133
  }
133
134
  setRotation(input, order = "XYZ") {
134
- if (input instanceof THREE13.Quaternion) {
135
- const euler = new THREE13.Euler().setFromQuaternion(input, order);
135
+ if (input instanceof THREE14.Quaternion) {
136
+ const euler = new THREE14.Euler().setFromQuaternion(input, order);
136
137
  this.rotation.x = euler.x;
137
138
  this.rotation.y = euler.y;
138
139
  this.rotation.z = euler.z;
@@ -147,6 +148,7 @@ var _TransformComponent = class _TransformComponent extends Component {
147
148
  };
148
149
  __name(_TransformComponent, "TransformComponent");
149
150
  var TransformComponent = _TransformComponent;
151
+ var SHARED_MODEL_RESOURCE_FLAG = "spatialEcsSharedModelResource";
150
152
 
151
153
  // core/systems/ObjectManagementSystem.ts
152
154
  function applyTransform(object, transform) {
@@ -180,10 +182,10 @@ var _ObjectManagementSystem = class _ObjectManagementSystem {
180
182
  }
181
183
  getOrCreateAudioListener() {
182
184
  const existing = this.camera.userData.ecsAudioListener;
183
- if (existing instanceof THREE13__namespace.AudioListener) {
185
+ if (existing instanceof THREE14__namespace.AudioListener) {
184
186
  return existing;
185
187
  }
186
- const listener = new THREE13__namespace.AudioListener();
188
+ const listener = new THREE14__namespace.AudioListener();
187
189
  this.camera.add(listener);
188
190
  this.camera.userData.ecsAudioListener = listener;
189
191
  return listener;
@@ -257,14 +259,15 @@ var _ObjectManagementSystem = class _ObjectManagementSystem {
257
259
  }
258
260
  if (dispose && object3d) {
259
261
  object3d.traverse((child) => {
260
- if (child instanceof THREE13__namespace.Mesh) {
261
- child.geometry?.dispose();
262
- if (Array.isArray(child.material)) {
263
- for (const mat of child.material) {
262
+ if (child instanceof THREE14__namespace.Mesh) {
263
+ if (!child.geometry?.userData?.[SHARED_MODEL_RESOURCE_FLAG]) {
264
+ child.geometry?.dispose();
265
+ }
266
+ const materials = Array.isArray(child.material) ? child.material : [child.material];
267
+ for (const mat of materials) {
268
+ if (mat && !mat.userData?.[SHARED_MODEL_RESOURCE_FLAG]) {
264
269
  mat.dispose();
265
270
  }
266
- } else {
267
- child.material?.dispose();
268
271
  }
269
272
  }
270
273
  });
@@ -636,14 +639,14 @@ var _AnimationComponent = class _AnimationComponent extends Component {
636
639
  return;
637
640
  }
638
641
  this.importedClips = clips.map((entry) => {
639
- if (entry instanceof THREE13__namespace.AnimationClip) {
642
+ if (entry instanceof THREE14__namespace.AnimationClip) {
640
643
  return { clip: entry, sourceUrl: null };
641
644
  }
642
645
  if (!entry || typeof entry !== "object") {
643
646
  return null;
644
647
  }
645
648
  const candidate = entry;
646
- if (!(candidate.clip instanceof THREE13__namespace.AnimationClip)) {
649
+ if (!(candidate.clip instanceof THREE14__namespace.AnimationClip)) {
647
650
  return null;
648
651
  }
649
652
  return {
@@ -777,7 +780,7 @@ var DEFAULT_ORTHO_TOP = 5;
777
780
  var DEFAULT_ORTHO_BOTTOM = -5;
778
781
  var DEFAULT_ZOOM = 1;
779
782
  function inferProjection(camera) {
780
- if (camera instanceof THREE13__namespace.OrthographicCamera) {
783
+ if (camera instanceof THREE14__namespace.OrthographicCamera) {
781
784
  return "orthographic";
782
785
  }
783
786
  return "perspective";
@@ -798,7 +801,7 @@ function readCameraFar(camera) {
798
801
  }
799
802
  __name(readCameraFar, "readCameraFar");
800
803
  function inferFov(camera) {
801
- if (camera instanceof THREE13__namespace.PerspectiveCamera && Number.isFinite(camera.fov)) {
804
+ if (camera instanceof THREE14__namespace.PerspectiveCamera && Number.isFinite(camera.fov)) {
802
805
  return camera.fov;
803
806
  }
804
807
  return DEFAULT_FOV;
@@ -821,28 +824,28 @@ function inferFar(camera) {
821
824
  }
822
825
  __name(inferFar, "inferFar");
823
826
  function inferOrthoLeft(camera) {
824
- if (camera instanceof THREE13__namespace.OrthographicCamera && Number.isFinite(camera.left)) {
827
+ if (camera instanceof THREE14__namespace.OrthographicCamera && Number.isFinite(camera.left)) {
825
828
  return camera.left;
826
829
  }
827
830
  return DEFAULT_ORTHO_LEFT;
828
831
  }
829
832
  __name(inferOrthoLeft, "inferOrthoLeft");
830
833
  function inferOrthoRight(camera) {
831
- if (camera instanceof THREE13__namespace.OrthographicCamera && Number.isFinite(camera.right)) {
834
+ if (camera instanceof THREE14__namespace.OrthographicCamera && Number.isFinite(camera.right)) {
832
835
  return camera.right;
833
836
  }
834
837
  return DEFAULT_ORTHO_RIGHT;
835
838
  }
836
839
  __name(inferOrthoRight, "inferOrthoRight");
837
840
  function inferOrthoTop(camera) {
838
- if (camera instanceof THREE13__namespace.OrthographicCamera && Number.isFinite(camera.top)) {
841
+ if (camera instanceof THREE14__namespace.OrthographicCamera && Number.isFinite(camera.top)) {
839
842
  return camera.top;
840
843
  }
841
844
  return DEFAULT_ORTHO_TOP;
842
845
  }
843
846
  __name(inferOrthoTop, "inferOrthoTop");
844
847
  function inferOrthoBottom(camera) {
845
- if (camera instanceof THREE13__namespace.OrthographicCamera && Number.isFinite(camera.bottom)) {
848
+ if (camera instanceof THREE14__namespace.OrthographicCamera && Number.isFinite(camera.bottom)) {
846
849
  return camera.bottom;
847
850
  }
848
851
  return DEFAULT_ORTHO_BOTTOM;
@@ -858,7 +861,7 @@ __name(inferZoom, "inferZoom");
858
861
  var _CameraComponent = class _CameraComponent extends Component {
859
862
  constructor(payload = {}) {
860
863
  super();
861
- this.camera = payload.camera ?? new THREE13__namespace.PerspectiveCamera();
864
+ this.camera = payload.camera ?? new THREE14__namespace.PerspectiveCamera();
862
865
  this.type = payload.type ?? "3d";
863
866
  this.isDefault = typeof payload.isDefault === "boolean" ? payload.isDefault : false;
864
867
  this.projection = payload.projection ?? inferProjection(payload.camera);
@@ -1613,15 +1616,15 @@ function createValueState(light) {
1613
1616
  castShadow: light.castShadow ?? false,
1614
1617
  frustumCulling: light.frustumCulled
1615
1618
  };
1616
- if (light instanceof THREE13__namespace.PointLight) {
1619
+ if (light instanceof THREE14__namespace.PointLight) {
1617
1620
  base.distance = light.distance;
1618
1621
  base.decay = light.decay;
1619
- } else if (light instanceof THREE13__namespace.SpotLight) {
1622
+ } else if (light instanceof THREE14__namespace.SpotLight) {
1620
1623
  base.distance = light.distance;
1621
1624
  base.decay = light.decay;
1622
1625
  base.angle = light.angle;
1623
1626
  base.penumbra = light.penumbra;
1624
- } else if (light instanceof THREE13__namespace.RectAreaLight) {
1627
+ } else if (light instanceof THREE14__namespace.RectAreaLight) {
1625
1628
  base.width = light.width;
1626
1629
  base.height = light.height;
1627
1630
  }
@@ -1656,13 +1659,13 @@ function toHexColor2(value, fallback) {
1656
1659
  }
1657
1660
  __name(toHexColor2, "toHexColor");
1658
1661
  function getMaterialType(material) {
1659
- if (material instanceof THREE13__namespace.MeshPhysicalMaterial) {
1662
+ if (material instanceof THREE14__namespace.MeshPhysicalMaterial) {
1660
1663
  return "physical";
1661
1664
  }
1662
- if (material instanceof THREE13__namespace.MeshPhongMaterial) {
1665
+ if (material instanceof THREE14__namespace.MeshPhongMaterial) {
1663
1666
  return "phong";
1664
1667
  }
1665
- if (material instanceof THREE13__namespace.MeshBasicMaterial) {
1668
+ if (material instanceof THREE14__namespace.MeshBasicMaterial) {
1666
1669
  return "basic";
1667
1670
  }
1668
1671
  return "standard";
@@ -1681,8 +1684,8 @@ function createMaterialValue(material) {
1681
1684
  opacity: typeof materialRecord.opacity === "number" ? materialRecord.opacity : 1,
1682
1685
  emissive: toHexColor2(materialRecord.emissive, "#000000"),
1683
1686
  emissiveIntensity: typeof materialRecord.emissiveIntensity === "number" ? materialRecord.emissiveIntensity : 0,
1684
- side: typeof materialRecord.side === "number" ? materialRecord.side : THREE13__namespace.FrontSide,
1685
- blending: typeof materialRecord.blending === "number" ? materialRecord.blending : THREE13__namespace.NormalBlending,
1687
+ side: typeof materialRecord.side === "number" ? materialRecord.side : THREE14__namespace.FrontSide,
1688
+ blending: typeof materialRecord.blending === "number" ? materialRecord.blending : THREE14__namespace.NormalBlending,
1686
1689
  depthTest: materialRecord.depthTest !== false,
1687
1690
  depthWrite: materialRecord.depthWrite !== false,
1688
1691
  wireframe: Boolean(materialRecord.wireframe),
@@ -1698,7 +1701,7 @@ function createMaterialValue(material) {
1698
1701
  displacementMap: materialRecord.displacementMap?.image?.src,
1699
1702
  lightMap: materialRecord.lightMap?.image?.src,
1700
1703
  envMap: materialRecord.envMap?.image?.src,
1701
- textureFiltering: map?.magFilter === THREE13__namespace.NearestFilter ? "sharp" : "smooth",
1704
+ textureFiltering: map?.magFilter === THREE14__namespace.NearestFilter ? "sharp" : "smooth",
1702
1705
  useMipmaps: map?.generateMipmaps !== false
1703
1706
  };
1704
1707
  }
@@ -1713,8 +1716,8 @@ function defaultMaterialValue() {
1713
1716
  opacity: 1,
1714
1717
  emissive: "#000000",
1715
1718
  emissiveIntensity: 0,
1716
- side: THREE13__namespace.FrontSide,
1717
- blending: THREE13__namespace.NormalBlending,
1719
+ side: THREE14__namespace.FrontSide,
1720
+ blending: THREE14__namespace.NormalBlending,
1718
1721
  depthTest: true,
1719
1722
  depthWrite: true,
1720
1723
  wireframe: false,
@@ -2057,7 +2060,7 @@ function transitionToClip(runtime, nextClipId, crossFadeDuration) {
2057
2060
  }
2058
2061
  __name(transitionToClip, "transitionToClip");
2059
2062
  function applyActionState(action, component, paused, shouldLoop) {
2060
- const loopMode = shouldLoop ? THREE13__namespace.LoopRepeat : THREE13__namespace.LoopOnce;
2063
+ const loopMode = shouldLoop ? THREE14__namespace.LoopRepeat : THREE14__namespace.LoopOnce;
2061
2064
  const repetitions = shouldLoop ? Infinity : 1;
2062
2065
  action.setLoop(loopMode, repetitions);
2063
2066
  action.clampWhenFinished = !shouldLoop;
@@ -2230,7 +2233,7 @@ var _AnimationSystem = class _AnimationSystem {
2230
2233
  if (runtime) {
2231
2234
  stopAllActions(runtime);
2232
2235
  }
2233
- const mixer = new THREE13__namespace.AnimationMixer(root);
2236
+ const mixer = new THREE14__namespace.AnimationMixer(root);
2234
2237
  const entries2 = readRuntimeClipEntries(animation);
2235
2238
  const indexedActions = createActions(mixer, entries2);
2236
2239
  runtime = {
@@ -2356,11 +2359,11 @@ function normalizeOrthoBounds(component) {
2356
2359
  }
2357
2360
  __name(normalizeOrthoBounds, "normalizeOrthoBounds");
2358
2361
  function isPerspectiveCamera(camera) {
2359
- return camera instanceof THREE13__namespace.PerspectiveCamera;
2362
+ return camera instanceof THREE14__namespace.PerspectiveCamera;
2360
2363
  }
2361
2364
  __name(isPerspectiveCamera, "isPerspectiveCamera");
2362
2365
  function isOrthographicCamera(camera) {
2363
- return camera instanceof THREE13__namespace.OrthographicCamera;
2366
+ return camera instanceof THREE14__namespace.OrthographicCamera;
2364
2367
  }
2365
2368
  __name(isOrthographicCamera, "isOrthographicCamera");
2366
2369
  function readWindowAspect() {
@@ -2413,7 +2416,7 @@ var _CameraSyncSystem = class _CameraSyncSystem {
2413
2416
  continue;
2414
2417
  }
2415
2418
  const camera = objectRef.object;
2416
- if (!(camera instanceof THREE13__namespace.Camera)) {
2419
+ if (!(camera instanceof THREE14__namespace.Camera)) {
2417
2420
  continue;
2418
2421
  }
2419
2422
  const nextSignature = buildSignature(component, camera, windowAspect);
@@ -2477,7 +2480,7 @@ var MIN_DENSITY = 0;
2477
2480
  function createGradientTexture(effect, colors) {
2478
2481
  if (typeof document === "undefined") {
2479
2482
  const pixel = new Uint8Array([30, 30, 30, 255]);
2480
- const fallback = new THREE13__namespace.DataTexture(pixel, 1, 1, THREE13__namespace.RGBAFormat);
2483
+ const fallback = new THREE14__namespace.DataTexture(pixel, 1, 1, THREE14__namespace.RGBAFormat);
2481
2484
  fallback.needsUpdate = true;
2482
2485
  return fallback;
2483
2486
  }
@@ -2486,7 +2489,7 @@ function createGradientTexture(effect, colors) {
2486
2489
  canvas.height = 512;
2487
2490
  const context = canvas.getContext("2d");
2488
2491
  if (!context) {
2489
- const fallback = new THREE13__namespace.CanvasTexture(canvas);
2492
+ const fallback = new THREE14__namespace.CanvasTexture(canvas);
2490
2493
  fallback.needsUpdate = true;
2491
2494
  return fallback;
2492
2495
  }
@@ -2514,15 +2517,15 @@ function createGradientTexture(effect, colors) {
2514
2517
  context.fillRect(0, 0, 512, 512);
2515
2518
  context.globalCompositeOperation = "source-over";
2516
2519
  }
2517
- const texture = new THREE13__namespace.CanvasTexture(canvas);
2518
- texture.colorSpace = THREE13__namespace.SRGBColorSpace;
2520
+ const texture = new THREE14__namespace.CanvasTexture(canvas);
2521
+ texture.colorSpace = THREE14__namespace.SRGBColorSpace;
2519
2522
  texture.needsUpdate = true;
2520
2523
  return texture;
2521
2524
  }
2522
2525
  __name(createGradientTexture, "createGradientTexture");
2523
2526
  var _EnvironmentSyncSystem = class _EnvironmentSyncSystem {
2524
2527
  constructor(scene) {
2525
- this.textureLoader = new THREE13__namespace.TextureLoader();
2528
+ this.textureLoader = new THREE14__namespace.TextureLoader();
2526
2529
  this.signature = null;
2527
2530
  this.activeTexture = null;
2528
2531
  this.pendingImageUrl = null;
@@ -2545,7 +2548,7 @@ var _EnvironmentSyncSystem = class _EnvironmentSyncSystem {
2545
2548
  if (skybox.type === "color") {
2546
2549
  this.disposeActiveTexture();
2547
2550
  this.pendingImageUrl = null;
2548
- this.scene.background = new THREE13__namespace.Color(skybox.color || "#1e1e1e");
2551
+ this.scene.background = new THREE14__namespace.Color(skybox.color || "#1e1e1e");
2549
2552
  return;
2550
2553
  }
2551
2554
  if (skybox.type === "gradient") {
@@ -2579,7 +2582,7 @@ var _EnvironmentSyncSystem = class _EnvironmentSyncSystem {
2579
2582
  texture.dispose();
2580
2583
  return;
2581
2584
  }
2582
- texture.colorSpace = THREE13__namespace.SRGBColorSpace;
2585
+ texture.colorSpace = THREE14__namespace.SRGBColorSpace;
2583
2586
  this.activeTexture = texture;
2584
2587
  this.scene.background = texture;
2585
2588
  },
@@ -2598,16 +2601,16 @@ var _EnvironmentSyncSystem = class _EnvironmentSyncSystem {
2598
2601
  this.scene.fog = null;
2599
2602
  return;
2600
2603
  }
2601
- const fogColor = new THREE13__namespace.Color(fog.color || "#1e1e1e");
2604
+ const fogColor = new THREE14__namespace.Color(fog.color || "#1e1e1e");
2602
2605
  if (fog.type === "linear") {
2603
2606
  const near = Number.isFinite(fog.linear.near) ? fog.linear.near : 1;
2604
2607
  const farCandidate = Number.isFinite(fog.linear.far) ? fog.linear.far : near + 10;
2605
2608
  const far = Math.max(near + MIN_FOG_DELTA, farCandidate);
2606
- this.scene.fog = new THREE13__namespace.Fog(fogColor, near, far);
2609
+ this.scene.fog = new THREE14__namespace.Fog(fogColor, near, far);
2607
2610
  return;
2608
2611
  }
2609
2612
  const density = Number.isFinite(fog.exponential.density) ? Math.max(MIN_DENSITY, fog.exponential.density) : 2e-3;
2610
- this.scene.fog = new THREE13__namespace.FogExp2(fogColor, density);
2613
+ this.scene.fog = new THREE14__namespace.FogExp2(fogColor, density);
2611
2614
  }
2612
2615
  update(world) {
2613
2616
  const entityIds = world.query(Environment);
@@ -2689,10 +2692,10 @@ var _PostprocessingSyncSystem = class _PostprocessingSyncSystem {
2689
2692
  );
2690
2693
  }
2691
2694
  if (values.bloom.enabled) {
2692
- const size = this.renderer.getSize(new THREE13__namespace.Vector2());
2695
+ const size = this.renderer.getSize(new THREE14__namespace.Vector2());
2693
2696
  composer.addPass(
2694
2697
  new UnrealBloomPass_js.UnrealBloomPass(
2695
- new THREE13__namespace.Vector2(size.width, size.height),
2698
+ new THREE14__namespace.Vector2(size.width, size.height),
2696
2699
  values.bloom.intensity,
2697
2700
  values.bloom.radius,
2698
2701
  values.bloom.threshold
@@ -2737,7 +2740,7 @@ var _PostprocessingSyncSystem = class _PostprocessingSyncSystem {
2737
2740
  if (values.dotScreen.enabled) {
2738
2741
  composer.addPass(
2739
2742
  new DotScreenPass_js.DotScreenPass(
2740
- new THREE13__namespace.Vector2(0, 0),
2743
+ new THREE14__namespace.Vector2(0, 0),
2741
2744
  values.dotScreen.angle ?? values.dotScreen.dotScreenAngle,
2742
2745
  values.dotScreen.scale ?? values.dotScreen.dotScreenScale
2743
2746
  )
@@ -2811,7 +2814,7 @@ function computeColliderState(colliderValues, object) {
2811
2814
  if (!object) {
2812
2815
  return colliderValues;
2813
2816
  }
2814
- const scale = new THREE13__namespace.Vector3();
2817
+ const scale = new THREE14__namespace.Vector3();
2815
2818
  object.getWorldScale(scale);
2816
2819
  return {
2817
2820
  ...colliderValues,
@@ -2862,8 +2865,8 @@ function createColliderDesc(RAPIER, values, triMeshData) {
2862
2865
  values.offsetPosition.y,
2863
2866
  values.offsetPosition.z
2864
2867
  );
2865
- const offsetQuaternion = new THREE13__namespace.Quaternion().setFromEuler(
2866
- new THREE13__namespace.Euler(
2868
+ const offsetQuaternion = new THREE14__namespace.Quaternion().setFromEuler(
2869
+ new THREE14__namespace.Euler(
2867
2870
  values.offsetRotation.x,
2868
2871
  values.offsetRotation.y,
2869
2872
  values.offsetRotation.z
@@ -2874,7 +2877,7 @@ function createColliderDesc(RAPIER, values, triMeshData) {
2874
2877
  }
2875
2878
  __name(createColliderDesc, "createColliderDesc");
2876
2879
  function findFirstMeshWithGeometry(object) {
2877
- if (object instanceof THREE13__namespace.Mesh && object.geometry) {
2880
+ if (object instanceof THREE14__namespace.Mesh && object.geometry) {
2878
2881
  return object;
2879
2882
  }
2880
2883
  let found = null;
@@ -2882,7 +2885,7 @@ function findFirstMeshWithGeometry(object) {
2882
2885
  if (found) {
2883
2886
  return;
2884
2887
  }
2885
- if (child instanceof THREE13__namespace.Mesh && child.geometry) {
2888
+ if (child instanceof THREE14__namespace.Mesh && child.geometry) {
2886
2889
  found = child;
2887
2890
  }
2888
2891
  });
@@ -2908,13 +2911,13 @@ function createTriMeshData(object) {
2908
2911
  }
2909
2912
  object.updateWorldMatrix(true, true);
2910
2913
  mesh.updateWorldMatrix(true, true);
2911
- const worldToObject = new THREE13__namespace.Matrix4().copy(object.matrixWorld).invert();
2912
- const relativeMatrix = new THREE13__namespace.Matrix4().multiplyMatrices(
2914
+ const worldToObject = new THREE14__namespace.Matrix4().copy(object.matrixWorld).invert();
2915
+ const relativeMatrix = new THREE14__namespace.Matrix4().multiplyMatrices(
2913
2916
  worldToObject,
2914
2917
  mesh.matrixWorld
2915
2918
  );
2916
2919
  const vertices = new Float32Array(positionCount * 3);
2917
- const point = new THREE13__namespace.Vector3();
2920
+ const point = new THREE14__namespace.Vector3();
2918
2921
  for (let index = 0; index < positionCount; index += 1) {
2919
2922
  point.set(
2920
2923
  positionAttribute.getX(index),
@@ -2952,8 +2955,8 @@ function createTriMeshData(object) {
2952
2955
  }
2953
2956
  __name(createTriMeshData, "createTriMeshData");
2954
2957
  function syncBodyFromTransform(body, transform) {
2955
- const quaternion = new THREE13__namespace.Quaternion().setFromEuler(
2956
- new THREE13__namespace.Euler(transform.rotation.x, transform.rotation.y, transform.rotation.z)
2958
+ const quaternion = new THREE14__namespace.Quaternion().setFromEuler(
2959
+ new THREE14__namespace.Euler(transform.rotation.x, transform.rotation.y, transform.rotation.z)
2957
2960
  );
2958
2961
  body.setTranslation(
2959
2962
  {
@@ -2980,8 +2983,8 @@ function syncTransformFromBody(transform, body) {
2980
2983
  transform.position.x = position.x;
2981
2984
  transform.position.y = position.y;
2982
2985
  transform.position.z = position.z;
2983
- const euler = new THREE13__namespace.Euler().setFromQuaternion(
2984
- new THREE13__namespace.Quaternion(rotation.x, rotation.y, rotation.z, rotation.w)
2986
+ const euler = new THREE14__namespace.Euler().setFromQuaternion(
2987
+ new THREE14__namespace.Quaternion(rotation.x, rotation.y, rotation.z, rotation.w)
2985
2988
  );
2986
2989
  transform.rotation.x = euler.x;
2987
2990
  transform.rotation.y = euler.y;
@@ -3093,8 +3096,8 @@ var _PhysicsSyncSystem = class _PhysicsSyncSystem {
3093
3096
  transform.position.y,
3094
3097
  transform.position.z
3095
3098
  );
3096
- const quaternion = new THREE13__namespace.Quaternion().setFromEuler(
3097
- new THREE13__namespace.Euler(
3099
+ const quaternion = new THREE14__namespace.Quaternion().setFromEuler(
3100
+ new THREE14__namespace.Euler(
3098
3101
  transform.rotation.x,
3099
3102
  transform.rotation.y,
3100
3103
  transform.rotation.z
@@ -3669,7 +3672,7 @@ function applyLightValues(lightComponent) {
3669
3672
  values.castShadow
3670
3673
  );
3671
3674
  }
3672
- if (light instanceof THREE13__namespace.PointLight) {
3675
+ if (light instanceof THREE14__namespace.PointLight) {
3673
3676
  if (typeof values.distance === "number" && Number.isFinite(values.distance)) {
3674
3677
  light.distance = Math.max(MIN_LIGHT_DISTANCE, values.distance);
3675
3678
  }
@@ -3677,7 +3680,7 @@ function applyLightValues(lightComponent) {
3677
3680
  light.decay = Math.max(0, values.decay);
3678
3681
  }
3679
3682
  }
3680
- if (light instanceof THREE13__namespace.SpotLight) {
3683
+ if (light instanceof THREE14__namespace.SpotLight) {
3681
3684
  if (typeof values.distance === "number" && Number.isFinite(values.distance)) {
3682
3685
  light.distance = Math.max(MIN_LIGHT_DISTANCE, values.distance);
3683
3686
  }
@@ -3691,7 +3694,7 @@ function applyLightValues(lightComponent) {
3691
3694
  light.penumbra = Math.max(0, Math.min(1, values.penumbra));
3692
3695
  }
3693
3696
  }
3694
- if (light instanceof THREE13__namespace.RectAreaLight) {
3697
+ if (light instanceof THREE14__namespace.RectAreaLight) {
3695
3698
  if (typeof values.width === "number" && Number.isFinite(values.width)) {
3696
3699
  light.width = Math.max(MIN_AREA_SIZE, values.width);
3697
3700
  }
@@ -3752,15 +3755,15 @@ function resolveMaterialPropertyKey(key) {
3752
3755
  __name(resolveMaterialPropertyKey, "resolveMaterialPropertyKey");
3753
3756
  function createMaterialByType(type) {
3754
3757
  if (type === "basic") {
3755
- return new THREE13__namespace.MeshBasicMaterial();
3758
+ return new THREE14__namespace.MeshBasicMaterial();
3756
3759
  }
3757
3760
  if (type === "phong") {
3758
- return new THREE13__namespace.MeshPhongMaterial();
3761
+ return new THREE14__namespace.MeshPhongMaterial();
3759
3762
  }
3760
3763
  if (type === "physical") {
3761
- return new THREE13__namespace.MeshPhysicalMaterial();
3764
+ return new THREE14__namespace.MeshPhysicalMaterial();
3762
3765
  }
3763
- return new THREE13__namespace.MeshStandardMaterial();
3766
+ return new THREE14__namespace.MeshStandardMaterial();
3764
3767
  }
3765
3768
  __name(createMaterialByType, "createMaterialByType");
3766
3769
  function replaceMaterialAcrossObject(object, previous, next) {
@@ -3819,12 +3822,12 @@ function applyTextureFiltering(material, filtering) {
3819
3822
  const target = material;
3820
3823
  for (const slot of materialTextureSlots) {
3821
3824
  const texture = target[slot];
3822
- if (!texture || !(texture instanceof THREE13__namespace.Texture)) {
3825
+ if (!texture || !(texture instanceof THREE14__namespace.Texture)) {
3823
3826
  continue;
3824
3827
  }
3825
3828
  const useMipmaps = texture.generateMipmaps !== false;
3826
- texture.magFilter = sharp ? THREE13__namespace.NearestFilter : THREE13__namespace.LinearFilter;
3827
- texture.minFilter = useMipmaps ? sharp ? THREE13__namespace.NearestMipmapNearestFilter : THREE13__namespace.LinearMipmapLinearFilter : sharp ? THREE13__namespace.NearestFilter : THREE13__namespace.LinearFilter;
3829
+ texture.magFilter = sharp ? THREE14__namespace.NearestFilter : THREE14__namespace.LinearFilter;
3830
+ texture.minFilter = useMipmaps ? sharp ? THREE14__namespace.NearestMipmapNearestFilter : THREE14__namespace.LinearMipmapLinearFilter : sharp ? THREE14__namespace.NearestFilter : THREE14__namespace.LinearFilter;
3828
3831
  texture.needsUpdate = true;
3829
3832
  }
3830
3833
  material.needsUpdate = true;
@@ -3834,12 +3837,12 @@ function setTextureMipmaps(material, enabled) {
3834
3837
  const target = material;
3835
3838
  for (const slot of materialTextureSlots) {
3836
3839
  const texture = target[slot];
3837
- if (!texture || !(texture instanceof THREE13__namespace.Texture)) {
3840
+ if (!texture || !(texture instanceof THREE14__namespace.Texture)) {
3838
3841
  continue;
3839
3842
  }
3840
3843
  texture.generateMipmaps = enabled;
3841
- const sharp = texture.magFilter === THREE13__namespace.NearestFilter;
3842
- texture.minFilter = enabled ? sharp ? THREE13__namespace.NearestMipmapNearestFilter : THREE13__namespace.LinearMipmapLinearFilter : sharp ? THREE13__namespace.NearestFilter : THREE13__namespace.LinearFilter;
3844
+ const sharp = texture.magFilter === THREE14__namespace.NearestFilter;
3845
+ texture.minFilter = enabled ? sharp ? THREE14__namespace.NearestMipmapNearestFilter : THREE14__namespace.LinearMipmapLinearFilter : sharp ? THREE14__namespace.NearestFilter : THREE14__namespace.LinearFilter;
3843
3846
  texture.needsUpdate = true;
3844
3847
  }
3845
3848
  material.needsUpdate = true;
@@ -3850,7 +3853,7 @@ function assignMaterialTexture(material, rawKey, url, textureCache) {
3850
3853
  const key = resolveMaterialPropertyKey(rawKey);
3851
3854
  let texture = textureCache.get(url);
3852
3855
  if (!texture) {
3853
- texture = new THREE13__namespace.TextureLoader().load(url);
3856
+ texture = new THREE14__namespace.TextureLoader().load(url);
3854
3857
  textureCache.set(url, texture);
3855
3858
  }
3856
3859
  target[key] = texture;
@@ -4048,12 +4051,12 @@ function resolvePrimaryMesh(object) {
4048
4051
  if (!object) {
4049
4052
  return null;
4050
4053
  }
4051
- if (object instanceof THREE13__namespace.Mesh) {
4054
+ if (object instanceof THREE14__namespace.Mesh) {
4052
4055
  return object;
4053
4056
  }
4054
4057
  let found = null;
4055
4058
  object.traverse((child) => {
4056
- if (!found && child instanceof THREE13__namespace.Mesh) {
4059
+ if (!found && child instanceof THREE14__namespace.Mesh) {
4057
4060
  found = child;
4058
4061
  }
4059
4062
  });
@@ -4074,22 +4077,22 @@ function applyGeometry(component) {
4074
4077
  switch (component.kind) {
4075
4078
  case "cube": {
4076
4079
  const params = sanitized;
4077
- nextGeometry = new THREE13__namespace.BoxGeometry(params.width, params.height, params.depth);
4080
+ nextGeometry = new THREE14__namespace.BoxGeometry(params.width, params.height, params.depth);
4078
4081
  break;
4079
4082
  }
4080
4083
  case "plane": {
4081
4084
  const params = sanitized;
4082
- nextGeometry = new THREE13__namespace.PlaneGeometry(params.width, params.height);
4085
+ nextGeometry = new THREE14__namespace.PlaneGeometry(params.width, params.height);
4083
4086
  break;
4084
4087
  }
4085
4088
  case "sphere": {
4086
4089
  const params = sanitized;
4087
- nextGeometry = new THREE13__namespace.SphereGeometry(params.radius, 24, 24);
4090
+ nextGeometry = new THREE14__namespace.SphereGeometry(params.radius, 24, 24);
4088
4091
  break;
4089
4092
  }
4090
4093
  case "cylinder": {
4091
4094
  const params = sanitized;
4092
- nextGeometry = new THREE13__namespace.CylinderGeometry(
4095
+ nextGeometry = new THREE14__namespace.CylinderGeometry(
4093
4096
  params.radius,
4094
4097
  params.radius,
4095
4098
  params.height,
@@ -4099,7 +4102,7 @@ function applyGeometry(component) {
4099
4102
  }
4100
4103
  case "capsule": {
4101
4104
  const params = sanitized;
4102
- nextGeometry = new THREE13__namespace.CapsuleGeometry(params.radius, params.height, 4, 8);
4105
+ nextGeometry = new THREE14__namespace.CapsuleGeometry(params.radius, params.height, 4, 8);
4103
4106
  break;
4104
4107
  }
4105
4108
  default:
@@ -4115,7 +4118,7 @@ function applyShadowFlags(component) {
4115
4118
  return;
4116
4119
  }
4117
4120
  component.object.traverse((child) => {
4118
- if (child instanceof THREE13__namespace.Mesh) {
4121
+ if (child instanceof THREE14__namespace.Mesh) {
4119
4122
  child.castShadow = component.castShadow;
4120
4123
  child.receiveShadow = component.receiveShadow;
4121
4124
  }
@@ -4168,13 +4171,12 @@ var _MeshGeometrySystem = class _MeshGeometrySystem {
4168
4171
  };
4169
4172
  __name(_MeshGeometrySystem, "MeshGeometrySystem");
4170
4173
  var MeshGeometrySystem = _MeshGeometrySystem;
4171
- var DRACO_DECODER_PATH = resolveDracoDecoderPath();
4172
4174
  var loadGLTF = /* @__PURE__ */ __name((path) => {
4173
4175
  return new Promise((resolve, reject) => {
4174
4176
  const loader = new GLTFLoader_js.GLTFLoader();
4175
4177
  try {
4176
4178
  const dracoLoader = new DRACOLoader_js.DRACOLoader();
4177
- dracoLoader.setDecoderPath(DRACO_DECODER_PATH);
4179
+ dracoLoader.setDecoderPath(resolveDracoDecoderPath());
4178
4180
  loader.setDRACOLoader(dracoLoader);
4179
4181
  } catch (error) {
4180
4182
  console.debug("DRACOLoader setup failed or unavailable", error);
@@ -4199,35 +4201,35 @@ function buildGeometry(component) {
4199
4201
  switch (component.meshKind) {
4200
4202
  case "cube": {
4201
4203
  const params = p;
4202
- return new THREE13__namespace.BoxGeometry(params.width, params.height, params.depth);
4204
+ return new THREE14__namespace.BoxGeometry(params.width, params.height, params.depth);
4203
4205
  }
4204
4206
  case "plane": {
4205
4207
  const params = p;
4206
- return new THREE13__namespace.PlaneGeometry(params.width, params.height);
4208
+ return new THREE14__namespace.PlaneGeometry(params.width, params.height);
4207
4209
  }
4208
4210
  case "sphere": {
4209
4211
  const params = p;
4210
- return new THREE13__namespace.SphereGeometry(params.radius, 24, 24);
4212
+ return new THREE14__namespace.SphereGeometry(params.radius, 24, 24);
4211
4213
  }
4212
4214
  case "cylinder": {
4213
4215
  const params = p;
4214
- return new THREE13__namespace.CylinderGeometry(params.radius, params.radius, params.height, 20);
4216
+ return new THREE14__namespace.CylinderGeometry(params.radius, params.radius, params.height, 20);
4215
4217
  }
4216
4218
  case "capsule": {
4217
4219
  const params = p;
4218
- return new THREE13__namespace.CapsuleGeometry(params.radius, params.height, 4, 8);
4220
+ return new THREE14__namespace.CapsuleGeometry(params.radius, params.height, 4, 8);
4219
4221
  }
4220
4222
  default:
4221
- return new THREE13__namespace.BoxGeometry(1, 1, 1);
4223
+ return new THREE14__namespace.BoxGeometry(1, 1, 1);
4222
4224
  }
4223
4225
  }
4224
4226
  __name(buildGeometry, "buildGeometry");
4225
- var _position = new THREE13__namespace.Vector3();
4226
- var _quaternion = new THREE13__namespace.Quaternion();
4227
- var _euler = new THREE13__namespace.Euler();
4228
- var _scale = new THREE13__namespace.Vector3();
4229
- var _matrix = new THREE13__namespace.Matrix4();
4230
- var _modelMatrix = new THREE13__namespace.Matrix4();
4227
+ var _position = new THREE14__namespace.Vector3();
4228
+ var _quaternion = new THREE14__namespace.Quaternion();
4229
+ var _euler = new THREE14__namespace.Euler();
4230
+ var _scale = new THREE14__namespace.Vector3();
4231
+ var _matrix = new THREE14__namespace.Matrix4();
4232
+ var _modelMatrix = new THREE14__namespace.Matrix4();
4231
4233
  function instanceTransformFromComponent(transform, out) {
4232
4234
  _position.set(transform.position.x, transform.position.y, transform.position.z);
4233
4235
  _euler.set(transform.rotation.x, transform.rotation.y, transform.rotation.z, "XYZ");
@@ -4380,7 +4382,7 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
4380
4382
  const sourceMaterial = Array.isArray(meshChild.material) ? meshChild.material.map((m) => m.clone()) : meshChild.material.clone();
4381
4383
  meshChild.updateWorldMatrix(true, false);
4382
4384
  const localMatrix = meshChild.matrixWorld.clone();
4383
- const instancedMesh2 = new THREE13__namespace.InstancedMesh(
4385
+ const instancedMesh2 = new THREE14__namespace.InstancedMesh(
4384
4386
  geometry2,
4385
4387
  Array.isArray(sourceMaterial) ? sourceMaterial : sourceMaterial,
4386
4388
  count2
@@ -4405,7 +4407,7 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
4405
4407
  this.loadingSignatures.delete(targetEntityId);
4406
4408
  return;
4407
4409
  }
4408
- const group = new THREE13__namespace.Group();
4410
+ const group = new THREE14__namespace.Group();
4409
4411
  for (const entry of entries) {
4410
4412
  group.add(entry.instancedMesh);
4411
4413
  }
@@ -4423,8 +4425,8 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
4423
4425
  }
4424
4426
  const count = instanceCount;
4425
4427
  const geometry = buildGeometry(comp);
4426
- const material = new THREE13__namespace.MeshStandardMaterial({ color: "#ffffff" });
4427
- const instancedMesh = new THREE13__namespace.InstancedMesh(geometry, material, count);
4428
+ const material = new THREE14__namespace.MeshStandardMaterial({ color: "#ffffff" });
4429
+ const instancedMesh = new THREE14__namespace.InstancedMesh(geometry, material, count);
4428
4430
  instancedMesh.castShadow = comp.castShadow;
4429
4431
  instancedMesh.receiveShadow = comp.receiveShadow;
4430
4432
  for (let i = 0; i < count; i++) {
@@ -4578,7 +4580,7 @@ var _Behaviour = class _Behaviour {
4578
4580
  if (!this.threeRef) {
4579
4581
  return null;
4580
4582
  }
4581
- const position = new THREE13__namespace.Vector3();
4583
+ const position = new THREE14__namespace.Vector3();
4582
4584
  this.threeRef.object.getWorldPosition(position);
4583
4585
  return position;
4584
4586
  }
@@ -4590,7 +4592,7 @@ var _Behaviour = class _Behaviour {
4590
4592
  if (!this.threeRef) {
4591
4593
  return null;
4592
4594
  }
4593
- const target = new THREE13__namespace.Vector3();
4595
+ const target = new THREE14__namespace.Vector3();
4594
4596
  this.threeRef.object.getWorldDirection(target);
4595
4597
  return target;
4596
4598
  }
@@ -4652,7 +4654,7 @@ var _Behaviour = class _Behaviour {
4652
4654
  if (!this.threeRef) {
4653
4655
  return;
4654
4656
  }
4655
- const rotation = new THREE13__namespace.Quaternion();
4657
+ const rotation = new THREE14__namespace.Quaternion();
4656
4658
  this.threeRef.object.getWorldQuaternion(rotation);
4657
4659
  rotation.slerp(targetRotation, alpha);
4658
4660
  this.transform.setRotation(rotation);
@@ -4669,7 +4671,7 @@ var _Behaviour = class _Behaviour {
4669
4671
  return;
4670
4672
  }
4671
4673
  const clone = this.threeRef.object.clone();
4672
- const rotation = new THREE13__namespace.Quaternion();
4674
+ const rotation = new THREE14__namespace.Quaternion();
4673
4675
  clone.lookAt(targetPosition);
4674
4676
  clone.getWorldQuaternion(rotation);
4675
4677
  this.transform.setRotation(rotation);
@@ -4970,8 +4972,8 @@ var _ScriptBehaviourSystem = class _ScriptBehaviourSystem {
4970
4972
  }, "onPointerUp");
4971
4973
  this.moduleLoader = moduleLoader ?? defaultModuleLoader;
4972
4974
  this.selectionCtx = selectionContext ?? null;
4973
- this.raycaster = new THREE13__namespace.Raycaster();
4974
- this.ndcPointer = new THREE13__namespace.Vector2();
4975
+ this.raycaster = new THREE14__namespace.Raycaster();
4976
+ this.ndcPointer = new THREE14__namespace.Vector2();
4975
4977
  if (this.selectionCtx) {
4976
4978
  this.selectionCtx.domElement.addEventListener("pointerdown", this.onPointerDown);
4977
4979
  this.selectionCtx.domElement.addEventListener("pointerup", this.onPointerUp);
@@ -5381,7 +5383,7 @@ var _AudioSystem = class _AudioSystem {
5381
5383
  if (!prev || prev.volume !== opts.volume) {
5382
5384
  sound.setVolume(opts.volume);
5383
5385
  }
5384
- if (opts.positional && sound instanceof THREE13__namespace.PositionalAudio) {
5386
+ if (opts.positional && sound instanceof THREE14__namespace.PositionalAudio) {
5385
5387
  if (!prev || prev.refDistance !== opts.refDistance) {
5386
5388
  sound.setRefDistance(opts.refDistance);
5387
5389
  }
@@ -5507,7 +5509,7 @@ var _VideoSystem = class _VideoSystem {
5507
5509
  component.object.scale.set(opts.width, opts.height, 1);
5508
5510
  }
5509
5511
  const material = component.material;
5510
- if (material instanceof THREE13__namespace.ShaderMaterial) {
5512
+ if (material instanceof THREE14__namespace.ShaderMaterial) {
5511
5513
  if (!prev || prev.backgroundColor !== opts.backgroundColor) {
5512
5514
  material.uniforms.keyColor.value.set(opts.backgroundColor);
5513
5515
  }
@@ -5521,7 +5523,7 @@ var _VideoSystem = class _VideoSystem {
5521
5523
  material.uniforms.spill.value = opts.spill;
5522
5524
  }
5523
5525
  }
5524
- if (opts.positional && component.audioNode instanceof THREE13__namespace.PositionalAudio) {
5526
+ if (opts.positional && component.audioNode instanceof THREE14__namespace.PositionalAudio) {
5525
5527
  const posAudio = component.audioNode;
5526
5528
  if (!prev || prev.refDistance !== opts.refDistance) {
5527
5529
  posAudio.setRefDistance(opts.refDistance);