@relu-interactives/spatial-ecs 0.2.4 → 0.2.5

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.
Files changed (50) hide show
  1. package/dist/{System-BTyYvKVH.d.cts → System-CIiWteft.d.cts} +2 -2
  2. package/dist/{System-BTyYvKVH.d.ts → System-CIiWteft.d.ts} +2 -2
  3. package/dist/{Video-D2H5H-K3.d.cts → Video-ChVFs9Tl.d.cts} +139 -75
  4. package/dist/{Video-BWhbvVPg.d.ts → Video-DCMCLInA.d.ts} +139 -75
  5. package/dist/{chunk-XWIEEJ7Z.js → chunk-4A66FSFT.js} +128 -82
  6. package/dist/chunk-4A66FSFT.js.map +1 -0
  7. package/dist/{chunk-AYEF3X2P.js → chunk-CRP3W2GK.js} +3 -3
  8. package/dist/chunk-CRP3W2GK.js.map +1 -0
  9. package/dist/{chunk-MAWBTMCG.js → chunk-KRZLEPRI.js} +156 -88
  10. package/dist/chunk-KRZLEPRI.js.map +1 -0
  11. package/dist/{chunk-NFDTIYR4.js → chunk-NB6I5JJN.js} +17 -2
  12. package/dist/chunk-NB6I5JJN.js.map +1 -0
  13. package/dist/{chunk-P2YDX5DB.js → chunk-RXCUHGRB.js} +124 -5
  14. package/dist/chunk-RXCUHGRB.js.map +1 -0
  15. package/dist/components/index.cjs +161 -93
  16. package/dist/components/index.cjs.map +1 -1
  17. package/dist/components/index.d.cts +2 -2
  18. package/dist/components/index.d.ts +2 -2
  19. package/dist/components/index.js +1 -1
  20. package/dist/factories/index.cjs +217 -105
  21. package/dist/factories/index.cjs.map +1 -1
  22. package/dist/factories/index.d.cts +9 -3
  23. package/dist/factories/index.d.ts +9 -3
  24. package/dist/factories/index.js +3 -3
  25. package/dist/{index-KdEzEZox.d.cts → index-D1I5L7bA.d.cts} +8 -3
  26. package/dist/{index-Dm6zF1MY.d.ts → index-DGZDgt3p.d.ts} +8 -3
  27. package/dist/index.cjs +468 -179
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +7 -7
  30. package/dist/index.d.ts +7 -7
  31. package/dist/index.js +51 -12
  32. package/dist/index.js.map +1 -1
  33. package/dist/systems/index.cjs +248 -63
  34. package/dist/systems/index.cjs.map +1 -1
  35. package/dist/systems/index.d.cts +15 -3
  36. package/dist/systems/index.d.ts +15 -3
  37. package/dist/systems/index.js +3 -3
  38. package/dist/types.d.cts +1 -1
  39. package/dist/types.d.ts +1 -1
  40. package/dist/worldSnapshotUtils.cjs +15 -0
  41. package/dist/worldSnapshotUtils.cjs.map +1 -1
  42. package/dist/worldSnapshotUtils.d.cts +1 -1
  43. package/dist/worldSnapshotUtils.d.ts +1 -1
  44. package/dist/worldSnapshotUtils.js +1 -1
  45. package/package.json +1 -1
  46. package/dist/chunk-AYEF3X2P.js.map +0 -1
  47. package/dist/chunk-MAWBTMCG.js.map +0 -1
  48. package/dist/chunk-NFDTIYR4.js.map +0 -1
  49. package/dist/chunk-P2YDX5DB.js.map +0 -1
  50. package/dist/chunk-XWIEEJ7Z.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var THREE33 = require('three');
3
+ var THREE34 = require('three');
4
4
  var RectAreaLightHelper_js = require('three/examples/jsm/helpers/RectAreaLightHelper.js');
5
5
  var DRACOLoader_js = require('three/examples/jsm/loaders/DRACOLoader.js');
6
6
  var GLTFLoader_js = require('three/examples/jsm/loaders/GLTFLoader.js');
@@ -38,7 +38,7 @@ function _interopNamespace(e) {
38
38
  return Object.freeze(n);
39
39
  }
40
40
 
41
- var THREE33__namespace = /*#__PURE__*/_interopNamespace(THREE33);
41
+ var THREE34__namespace = /*#__PURE__*/_interopNamespace(THREE34);
42
42
 
43
43
  var __defProp = Object.defineProperty;
44
44
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -150,6 +150,21 @@ function normalizeDebugValue(value, ctx) {
150
150
  crossFadeDuration: typeof objectValue.crossFadeDuration === "number" && Number.isFinite(objectValue.crossFadeDuration) ? Math.max(0, objectValue.crossFadeDuration) : 0
151
151
  };
152
152
  }
153
+ if (constructorName === "InstancedMeshComponent") {
154
+ const imCtx = {
155
+ seen: ctx.seen,
156
+ depth: ctx.depth + 1,
157
+ maxDepth: ctx.maxDepth
158
+ };
159
+ return {
160
+ __type: "InstancedMeshComponent",
161
+ meshKind: typeof objectValue.meshKind === "string" ? objectValue.meshKind : "cube",
162
+ meshParameters: normalizeDebugValue(objectValue.meshParameters, imCtx),
163
+ castShadow: Boolean(objectValue.castShadow),
164
+ receiveShadow: Boolean(objectValue.receiveShadow),
165
+ instances: normalizeDebugValue(objectValue.instances, imCtx)
166
+ };
167
+ }
153
168
  if (constructorName === "PhysicsComponent") {
154
169
  return {
155
170
  __type: "PhysicsComponent",
@@ -558,14 +573,14 @@ var _AnimationComponent = class _AnimationComponent extends Component {
558
573
  return;
559
574
  }
560
575
  this.importedClips = clips.map((entry) => {
561
- if (entry instanceof THREE33__namespace.AnimationClip) {
576
+ if (entry instanceof THREE34__namespace.AnimationClip) {
562
577
  return { clip: entry, sourceUrl: null };
563
578
  }
564
579
  if (!entry || typeof entry !== "object") {
565
580
  return null;
566
581
  }
567
582
  const candidate = entry;
568
- if (!(candidate.clip instanceof THREE33__namespace.AnimationClip)) {
583
+ if (!(candidate.clip instanceof THREE34__namespace.AnimationClip)) {
569
584
  return null;
570
585
  }
571
586
  return {
@@ -773,11 +788,11 @@ function normalizeDistanceModel(distanceModel) {
773
788
  }
774
789
  __name(normalizeDistanceModel, "normalizeDistanceModel");
775
790
  function createConfiguredAudio(listener, options) {
776
- const sound = options.positional ? new THREE33__namespace.PositionalAudio(listener) : new THREE33__namespace.Audio(listener);
791
+ const sound = options.positional ? new THREE34__namespace.PositionalAudio(listener) : new THREE34__namespace.Audio(listener);
777
792
  sound.setLoop(options.loop);
778
793
  sound.setVolume(options.volume);
779
794
  sound.setPlaybackRate(options.pitch);
780
- if (sound instanceof THREE33__namespace.PositionalAudio) {
795
+ if (sound instanceof THREE34__namespace.PositionalAudio) {
781
796
  sound.setRefDistance(options.refDistance);
782
797
  sound.setDistanceModel(normalizeDistanceModel(options.distanceModel));
783
798
  sound.setRolloffFactor(options.rolloffFactor);
@@ -787,16 +802,16 @@ function createConfiguredAudio(listener, options) {
787
802
  __name(createConfiguredAudio, "createConfiguredAudio");
788
803
  function createAudioEditorHelper() {
789
804
  if (typeof document === "undefined") {
790
- const geometry = new THREE33__namespace.EdgesGeometry(
791
- new THREE33__namespace.OctahedronGeometry(0.22, 0)
805
+ const geometry = new THREE34__namespace.EdgesGeometry(
806
+ new THREE34__namespace.OctahedronGeometry(0.22, 0)
792
807
  );
793
- const material2 = new THREE33__namespace.LineBasicMaterial({
808
+ const material2 = new THREE34__namespace.LineBasicMaterial({
794
809
  color: "#8bc8ff",
795
810
  transparent: true,
796
811
  opacity: 0.95,
797
812
  depthTest: false
798
813
  });
799
- const fallback = new THREE33__namespace.LineSegments(geometry, material2);
814
+ const fallback = new THREE34__namespace.LineSegments(geometry, material2);
800
815
  fallback.renderOrder = 10;
801
816
  fallback.userData.ecsHelper = true;
802
817
  fallback.visible = false;
@@ -808,7 +823,7 @@ function createAudioEditorHelper() {
808
823
  canvas.height = size;
809
824
  const ctx = canvas.getContext("2d");
810
825
  if (!ctx) {
811
- return new THREE33__namespace.Object3D();
826
+ return new THREE34__namespace.Object3D();
812
827
  }
813
828
  ctx.clearRect(0, 0, size, size);
814
829
  ctx.fillStyle = "rgba(27, 35, 52, 0.9)";
@@ -839,14 +854,14 @@ function createAudioEditorHelper() {
839
854
  ctx.beginPath();
840
855
  ctx.arc(56, 48, 16, -0.8, 0.8);
841
856
  ctx.stroke();
842
- const texture = new THREE33__namespace.CanvasTexture(canvas);
857
+ const texture = new THREE34__namespace.CanvasTexture(canvas);
843
858
  texture.needsUpdate = true;
844
- const material = new THREE33__namespace.SpriteMaterial({
859
+ const material = new THREE34__namespace.SpriteMaterial({
845
860
  map: texture,
846
861
  transparent: true,
847
862
  depthTest: false
848
863
  });
849
- const helper = new THREE33__namespace.Sprite(material);
864
+ const helper = new THREE34__namespace.Sprite(material);
850
865
  helper.scale.set(0.68, 0.68, 0.68);
851
866
  helper.renderOrder = 10;
852
867
  helper.userData.ecsHelper = true;
@@ -880,7 +895,7 @@ var DEFAULT_ORTHO_TOP = 5;
880
895
  var DEFAULT_ORTHO_BOTTOM = -5;
881
896
  var DEFAULT_ZOOM = 1;
882
897
  function inferProjection(camera) {
883
- if (camera instanceof THREE33__namespace.OrthographicCamera) {
898
+ if (camera instanceof THREE34__namespace.OrthographicCamera) {
884
899
  return "orthographic";
885
900
  }
886
901
  return "perspective";
@@ -901,7 +916,7 @@ function readCameraFar(camera) {
901
916
  }
902
917
  __name(readCameraFar, "readCameraFar");
903
918
  function inferFov(camera) {
904
- if (camera instanceof THREE33__namespace.PerspectiveCamera && Number.isFinite(camera.fov)) {
919
+ if (camera instanceof THREE34__namespace.PerspectiveCamera && Number.isFinite(camera.fov)) {
905
920
  return camera.fov;
906
921
  }
907
922
  return DEFAULT_FOV;
@@ -924,28 +939,28 @@ function inferFar(camera) {
924
939
  }
925
940
  __name(inferFar, "inferFar");
926
941
  function inferOrthoLeft(camera) {
927
- if (camera instanceof THREE33__namespace.OrthographicCamera && Number.isFinite(camera.left)) {
942
+ if (camera instanceof THREE34__namespace.OrthographicCamera && Number.isFinite(camera.left)) {
928
943
  return camera.left;
929
944
  }
930
945
  return DEFAULT_ORTHO_LEFT;
931
946
  }
932
947
  __name(inferOrthoLeft, "inferOrthoLeft");
933
948
  function inferOrthoRight(camera) {
934
- if (camera instanceof THREE33__namespace.OrthographicCamera && Number.isFinite(camera.right)) {
949
+ if (camera instanceof THREE34__namespace.OrthographicCamera && Number.isFinite(camera.right)) {
935
950
  return camera.right;
936
951
  }
937
952
  return DEFAULT_ORTHO_RIGHT;
938
953
  }
939
954
  __name(inferOrthoRight, "inferOrthoRight");
940
955
  function inferOrthoTop(camera) {
941
- if (camera instanceof THREE33__namespace.OrthographicCamera && Number.isFinite(camera.top)) {
956
+ if (camera instanceof THREE34__namespace.OrthographicCamera && Number.isFinite(camera.top)) {
942
957
  return camera.top;
943
958
  }
944
959
  return DEFAULT_ORTHO_TOP;
945
960
  }
946
961
  __name(inferOrthoTop, "inferOrthoTop");
947
962
  function inferOrthoBottom(camera) {
948
- if (camera instanceof THREE33__namespace.OrthographicCamera && Number.isFinite(camera.bottom)) {
963
+ if (camera instanceof THREE34__namespace.OrthographicCamera && Number.isFinite(camera.bottom)) {
949
964
  return camera.bottom;
950
965
  }
951
966
  return DEFAULT_ORTHO_BOTTOM;
@@ -961,7 +976,7 @@ __name(inferZoom, "inferZoom");
961
976
  var _CameraComponent = class _CameraComponent extends Component {
962
977
  constructor(payload = {}) {
963
978
  super();
964
- this.camera = payload.camera ?? new THREE33__namespace.PerspectiveCamera();
979
+ this.camera = payload.camera ?? new THREE34__namespace.PerspectiveCamera();
965
980
  this.type = payload.type ?? "3d";
966
981
  this.isDefault = typeof payload.isDefault === "boolean" ? payload.isDefault : false;
967
982
  this.projection = payload.projection ?? inferProjection(payload.camera);
@@ -992,7 +1007,7 @@ var Object3DRef = _Object3DRef;
992
1007
  // core/factories/components/CameraFactory.ts
993
1008
  function createCameraComponent(world, entityId, payload = {}) {
994
1009
  const object = world.getComponent(entityId, Object3DRef)?.object;
995
- const objectCamera = object instanceof THREE33__namespace.Camera ? object : void 0;
1010
+ const objectCamera = object instanceof THREE34__namespace.Camera ? object : void 0;
996
1011
  const component = new CameraComponent({
997
1012
  ...payload,
998
1013
  camera: payload.camera ?? objectCamera
@@ -1432,15 +1447,15 @@ function createValueState(light) {
1432
1447
  castShadow: light.castShadow ?? false,
1433
1448
  frustumCulling: light.frustumCulled
1434
1449
  };
1435
- if (light instanceof THREE33__namespace.PointLight) {
1450
+ if (light instanceof THREE34__namespace.PointLight) {
1436
1451
  base.distance = light.distance;
1437
1452
  base.decay = light.decay;
1438
- } else if (light instanceof THREE33__namespace.SpotLight) {
1453
+ } else if (light instanceof THREE34__namespace.SpotLight) {
1439
1454
  base.distance = light.distance;
1440
1455
  base.decay = light.decay;
1441
1456
  base.angle = light.angle;
1442
1457
  base.penumbra = light.penumbra;
1443
- } else if (light instanceof THREE33__namespace.RectAreaLight) {
1458
+ } else if (light instanceof THREE34__namespace.RectAreaLight) {
1444
1459
  base.width = light.width;
1445
1460
  base.height = light.height;
1446
1461
  }
@@ -1483,13 +1498,13 @@ function toHexColor2(value, fallback) {
1483
1498
  }
1484
1499
  __name(toHexColor2, "toHexColor");
1485
1500
  function getMaterialType(material) {
1486
- if (material instanceof THREE33__namespace.MeshPhysicalMaterial) {
1501
+ if (material instanceof THREE34__namespace.MeshPhysicalMaterial) {
1487
1502
  return "physical";
1488
1503
  }
1489
- if (material instanceof THREE33__namespace.MeshPhongMaterial) {
1504
+ if (material instanceof THREE34__namespace.MeshPhongMaterial) {
1490
1505
  return "phong";
1491
1506
  }
1492
- if (material instanceof THREE33__namespace.MeshBasicMaterial) {
1507
+ if (material instanceof THREE34__namespace.MeshBasicMaterial) {
1493
1508
  return "basic";
1494
1509
  }
1495
1510
  return "standard";
@@ -1508,8 +1523,8 @@ function createMaterialValue(material) {
1508
1523
  opacity: typeof materialRecord.opacity === "number" ? materialRecord.opacity : 1,
1509
1524
  emissive: toHexColor2(materialRecord.emissive, "#000000"),
1510
1525
  emissiveIntensity: typeof materialRecord.emissiveIntensity === "number" ? materialRecord.emissiveIntensity : 0,
1511
- side: typeof materialRecord.side === "number" ? materialRecord.side : THREE33__namespace.FrontSide,
1512
- blending: typeof materialRecord.blending === "number" ? materialRecord.blending : THREE33__namespace.NormalBlending,
1526
+ side: typeof materialRecord.side === "number" ? materialRecord.side : THREE34__namespace.FrontSide,
1527
+ blending: typeof materialRecord.blending === "number" ? materialRecord.blending : THREE34__namespace.NormalBlending,
1513
1528
  depthTest: materialRecord.depthTest !== false,
1514
1529
  depthWrite: materialRecord.depthWrite !== false,
1515
1530
  wireframe: Boolean(materialRecord.wireframe),
@@ -1525,7 +1540,7 @@ function createMaterialValue(material) {
1525
1540
  displacementMap: materialRecord.displacementMap?.image?.src,
1526
1541
  lightMap: materialRecord.lightMap?.image?.src,
1527
1542
  envMap: materialRecord.envMap?.image?.src,
1528
- textureFiltering: map?.magFilter === THREE33__namespace.NearestFilter ? "sharp" : "smooth",
1543
+ textureFiltering: map?.magFilter === THREE34__namespace.NearestFilter ? "sharp" : "smooth",
1529
1544
  useMipmaps: map?.generateMipmaps !== false
1530
1545
  };
1531
1546
  }
@@ -1540,8 +1555,8 @@ function defaultMaterialValue() {
1540
1555
  opacity: 1,
1541
1556
  emissive: "#000000",
1542
1557
  emissiveIntensity: 0,
1543
- side: THREE33__namespace.FrontSide,
1544
- blending: THREE33__namespace.NormalBlending,
1558
+ side: THREE34__namespace.FrontSide,
1559
+ blending: THREE34__namespace.NormalBlending,
1545
1560
  depthTest: true,
1546
1561
  depthWrite: true,
1547
1562
  wireframe: false,
@@ -2139,14 +2154,14 @@ var _TransformComponent = class _TransformComponent extends Component {
2139
2154
  z: scale.z ?? 1
2140
2155
  };
2141
2156
  }
2142
- toPositionVector3(target = new THREE33.Vector3()) {
2157
+ toPositionVector3(target = new THREE34.Vector3()) {
2143
2158
  return target.set(this.position.x, this.position.y, this.position.z);
2144
2159
  }
2145
- toRotationEuler(target = new THREE33.Euler(), order = "XYZ") {
2160
+ toRotationEuler(target = new THREE34.Euler(), order = "XYZ") {
2146
2161
  return target.set(this.rotation.x, this.rotation.y, this.rotation.z, order);
2147
2162
  }
2148
- toRotationQuaternion(target = new THREE33.Quaternion(), order = "XYZ") {
2149
- const euler = new THREE33.Euler(
2163
+ toRotationQuaternion(target = new THREE34.Quaternion(), order = "XYZ") {
2164
+ const euler = new THREE34.Euler(
2150
2165
  this.rotation.x,
2151
2166
  this.rotation.y,
2152
2167
  this.rotation.z,
@@ -2154,7 +2169,7 @@ var _TransformComponent = class _TransformComponent extends Component {
2154
2169
  );
2155
2170
  return target.setFromEuler(euler);
2156
2171
  }
2157
- toScaleVector3(target = new THREE33.Vector3()) {
2172
+ toScaleVector3(target = new THREE34.Vector3()) {
2158
2173
  return target.set(this.scale.x, this.scale.y, this.scale.z);
2159
2174
  }
2160
2175
  setPosition(input) {
@@ -2172,8 +2187,8 @@ var _TransformComponent = class _TransformComponent extends Component {
2172
2187
  return this;
2173
2188
  }
2174
2189
  setRotation(input, order = "XYZ") {
2175
- if (input instanceof THREE33.Quaternion) {
2176
- const euler = new THREE33.Euler().setFromQuaternion(input, order);
2190
+ if (input instanceof THREE34.Quaternion) {
2191
+ const euler = new THREE34.Euler().setFromQuaternion(input, order);
2177
2192
  this.rotation.x = euler.x;
2178
2193
  this.rotation.y = euler.y;
2179
2194
  this.rotation.z = euler.z;
@@ -2197,6 +2212,79 @@ function createTransformComponent(world, entityId, ...args) {
2197
2212
  }
2198
2213
  __name(createTransformComponent, "createTransformComponent");
2199
2214
 
2215
+ // core/components/InstancedMesh.ts
2216
+ var DEFAULT_INSTANCE_TRANSFORM = {
2217
+ position: { x: 0, y: 0, z: 0 },
2218
+ rotation: { x: 0, y: 0, z: 0 },
2219
+ scale: { x: 1, y: 1, z: 1 }
2220
+ };
2221
+ var DEFAULT_INSTANCED_MESH_PARAMETERS = {
2222
+ capsule: DEFAULT_MESH_GEOMETRY_PARAMETERS.capsule,
2223
+ cube: DEFAULT_MESH_GEOMETRY_PARAMETERS.cube,
2224
+ cylinder: DEFAULT_MESH_GEOMETRY_PARAMETERS.cylinder,
2225
+ plane: DEFAULT_MESH_GEOMETRY_PARAMETERS.plane,
2226
+ sphere: DEFAULT_MESH_GEOMETRY_PARAMETERS.sphere
2227
+ };
2228
+ var _InstancedMeshComponent = class _InstancedMeshComponent extends Component {
2229
+ constructor(meshKind = "cube", meshParameters, options) {
2230
+ super();
2231
+ this.meshKind = meshKind;
2232
+ this.meshParameters = {
2233
+ ...DEFAULT_INSTANCED_MESH_PARAMETERS[meshKind],
2234
+ ...meshParameters ?? {}
2235
+ };
2236
+ this.castShadow = options?.castShadow ?? false;
2237
+ this.receiveShadow = options?.receiveShadow ?? false;
2238
+ this.instances = options?.instances && options.instances.length > 0 ? options.instances : [{ ...DEFAULT_INSTANCE_TRANSFORM }];
2239
+ this.instancedMesh = null;
2240
+ }
2241
+ /** Sanitize and return a copy of the current mesh parameters with valid values. */
2242
+ getSanitizedParameters() {
2243
+ const MIN_DIM = 0.01;
2244
+ const MIN_RAD = 1e-3;
2245
+ const sanitize = /* @__PURE__ */ __name((v, min) => Number.isFinite(v) ? Math.max(min, v) : min, "sanitize");
2246
+ switch (this.meshKind) {
2247
+ case "cube": {
2248
+ const p = this.meshParameters;
2249
+ return {
2250
+ width: sanitize(p.width, MIN_DIM),
2251
+ height: sanitize(p.height, MIN_DIM),
2252
+ depth: sanitize(p.depth, MIN_DIM)
2253
+ };
2254
+ }
2255
+ case "plane": {
2256
+ const p = this.meshParameters;
2257
+ return {
2258
+ width: sanitize(p.width, MIN_DIM),
2259
+ height: sanitize(p.height, MIN_DIM)
2260
+ };
2261
+ }
2262
+ case "sphere": {
2263
+ const p = this.meshParameters;
2264
+ return { radius: sanitize(p.radius, MIN_RAD) };
2265
+ }
2266
+ case "cylinder":
2267
+ case "capsule": {
2268
+ const p = this.meshParameters;
2269
+ return {
2270
+ radius: sanitize(p.radius, MIN_RAD),
2271
+ height: sanitize(p.height, MIN_DIM)
2272
+ };
2273
+ }
2274
+ }
2275
+ }
2276
+ };
2277
+ __name(_InstancedMeshComponent, "InstancedMeshComponent");
2278
+ var InstancedMeshComponent = _InstancedMeshComponent;
2279
+
2280
+ // core/factories/components/InstancedMeshComponentFactory.ts
2281
+ function createInstancedMeshComponent(world, entityId, meshKind, meshParameters, options) {
2282
+ const component = new InstancedMeshComponent(meshKind, meshParameters, options);
2283
+ world.addComponent(entityId, component);
2284
+ return component;
2285
+ }
2286
+ __name(createInstancedMeshComponent, "createInstancedMeshComponent");
2287
+
2200
2288
  // core/components/Video.ts
2201
2289
  var DEFAULT_VIDEO_OPTIONS = {
2202
2290
  autoplay: false,
@@ -2323,6 +2411,7 @@ function registerDefaultComponentFactories(objectManagementSystem) {
2323
2411
  objectManagementSystem.registerComponentFactory("sprite", createSpriteComponent);
2324
2412
  objectManagementSystem.registerComponentFactory("transform", createTransformComponent);
2325
2413
  objectManagementSystem.registerComponentFactory("video", createVideoComponent);
2414
+ objectManagementSystem.registerComponentFactory("instancedMesh", createInstancedMeshComponent);
2326
2415
  }
2327
2416
  __name(registerDefaultComponentFactories, "registerDefaultComponentFactories");
2328
2417
  function createTransform(input) {
@@ -2360,10 +2449,10 @@ var _ObjectManagementSystem = class _ObjectManagementSystem {
2360
2449
  }
2361
2450
  getOrCreateAudioListener() {
2362
2451
  const existing = this.camera.userData.ecsAudioListener;
2363
- if (existing instanceof THREE33__namespace.AudioListener) {
2452
+ if (existing instanceof THREE34__namespace.AudioListener) {
2364
2453
  return existing;
2365
2454
  }
2366
- const listener = new THREE33__namespace.AudioListener();
2455
+ const listener = new THREE34__namespace.AudioListener();
2367
2456
  this.camera.add(listener);
2368
2457
  this.camera.userData.ecsAudioListener = listener;
2369
2458
  return listener;
@@ -2537,10 +2626,10 @@ __name(createBaseEntity, "createBaseEntity");
2537
2626
  // core/factories/objects/AudioFactory.ts
2538
2627
  function getOrCreateListener(camera) {
2539
2628
  const existing = camera.userData.ecsAudioListener;
2540
- if (existing instanceof THREE33__namespace.AudioListener) {
2629
+ if (existing instanceof THREE34__namespace.AudioListener) {
2541
2630
  return existing;
2542
2631
  }
2543
- const listener = new THREE33__namespace.AudioListener();
2632
+ const listener = new THREE34__namespace.AudioListener();
2544
2633
  camera.add(listener);
2545
2634
  camera.userData.ecsAudioListener = listener;
2546
2635
  return listener;
@@ -2553,7 +2642,7 @@ function createAudio({
2553
2642
  payload,
2554
2643
  isEditor
2555
2644
  }) {
2556
- const anchor = new THREE33__namespace.Object3D();
2645
+ const anchor = new THREE34__namespace.Object3D();
2557
2646
  const entityId = createBaseEntity(world, anchor, {
2558
2647
  label: payload.name ?? "Audio",
2559
2648
  entityType: "audio",
@@ -2575,7 +2664,7 @@ function createAudio({
2575
2664
  return entityId;
2576
2665
  }
2577
2666
  if (!isEditor) {
2578
- const loader = new THREE33__namespace.AudioLoader();
2667
+ const loader = new THREE34__namespace.AudioLoader();
2579
2668
  loader.load(
2580
2669
  audio.path,
2581
2670
  (buffer) => {
@@ -2650,7 +2739,7 @@ function applyCameraSettings(camera, options) {
2650
2739
  const near = typeof options.near === "number" ? options.near : DEFAULT_NEAR2;
2651
2740
  const far = typeof options.far === "number" ? options.far : DEFAULT_FAR2;
2652
2741
  const projection = options.projection;
2653
- if (camera instanceof THREE33__namespace.PerspectiveCamera) {
2742
+ if (camera instanceof THREE34__namespace.PerspectiveCamera) {
2654
2743
  if (!projection || projection === "perspective") {
2655
2744
  camera.fov = typeof options.fov === "number" ? options.fov : DEFAULT_FOV2;
2656
2745
  }
@@ -2660,7 +2749,7 @@ function applyCameraSettings(camera, options) {
2660
2749
  camera.updateProjectionMatrix();
2661
2750
  return;
2662
2751
  }
2663
- if (camera instanceof THREE33__namespace.OrthographicCamera) {
2752
+ if (camera instanceof THREE34__namespace.OrthographicCamera) {
2664
2753
  camera.left = typeof options.left === "number" ? options.left : -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
2665
2754
  camera.right = typeof options.right === "number" ? options.right : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
2666
2755
  camera.top = typeof options.top === "number" ? options.top : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
@@ -2681,7 +2770,7 @@ function createCameraObject(options) {
2681
2770
  const bottom = options.bottom ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
2682
2771
  const left = options.left ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
2683
2772
  const right = options.right ?? DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
2684
- const camera = new THREE33__namespace.OrthographicCamera(
2773
+ const camera = new THREE34__namespace.OrthographicCamera(
2685
2774
  left,
2686
2775
  right,
2687
2776
  top,
@@ -2693,7 +2782,7 @@ function createCameraObject(options) {
2693
2782
  camera.updateProjectionMatrix();
2694
2783
  return camera;
2695
2784
  }
2696
- return new THREE33__namespace.PerspectiveCamera(
2785
+ return new THREE34__namespace.PerspectiveCamera(
2697
2786
  options.fov ?? DEFAULT_FOV2,
2698
2787
  readViewportAspect(),
2699
2788
  near,
@@ -2711,7 +2800,7 @@ function createCamera({ world, scene, camera, payload, isEditor }) {
2711
2800
  transformInput: payload.transform
2712
2801
  });
2713
2802
  const objectRef = world.getComponent(entityId, Object3DRef);
2714
- if (objectRef?.object instanceof THREE33__namespace.Camera) {
2803
+ if (objectRef?.object instanceof THREE34__namespace.Camera) {
2715
2804
  objectRef.object.userData.entityId = entityId;
2716
2805
  }
2717
2806
  const componentOptions = {
@@ -2734,7 +2823,7 @@ function createCamera({ world, scene, camera, payload, isEditor }) {
2734
2823
  } else {
2735
2824
  applyCameraSettings(object, options);
2736
2825
  if (isEditor && component.isDefault) {
2737
- const helper = new THREE33__namespace.CameraHelper(object);
2826
+ const helper = new THREE34__namespace.CameraHelper(object);
2738
2827
  helper.onBeforeRender = () => {
2739
2828
  helper.update();
2740
2829
  };
@@ -2752,9 +2841,9 @@ function createCapsule({
2752
2841
  scene,
2753
2842
  payload
2754
2843
  }) {
2755
- const geometry = new THREE33__namespace.CapsuleGeometry(0.5, 1, 4, 8);
2756
- const material = new THREE33__namespace.MeshStandardMaterial({ color: "#ffffff" });
2757
- const mesh = new THREE33__namespace.Mesh(geometry, material);
2844
+ const geometry = new THREE34__namespace.CapsuleGeometry(0.5, 1, 4, 8);
2845
+ const material = new THREE34__namespace.MeshStandardMaterial({ color: "#ffffff" });
2846
+ const mesh = new THREE34__namespace.Mesh(geometry, material);
2758
2847
  const entityId = createBaseEntity(world, mesh, {
2759
2848
  label: payload.name ?? "Capsule",
2760
2849
  entityType: "capsule",
@@ -2774,9 +2863,9 @@ function createCapsule({
2774
2863
  }
2775
2864
  __name(createCapsule, "createCapsule");
2776
2865
  function createCube({ world, scene, payload }) {
2777
- const geometry = new THREE33__namespace.BoxGeometry(1, 1, 1);
2778
- const material = new THREE33__namespace.MeshStandardMaterial({ color: "#ffffff" });
2779
- const mesh = new THREE33__namespace.Mesh(geometry, material);
2866
+ const geometry = new THREE34__namespace.BoxGeometry(1, 1, 1);
2867
+ const material = new THREE34__namespace.MeshStandardMaterial({ color: "#ffffff" });
2868
+ const mesh = new THREE34__namespace.Mesh(geometry, material);
2780
2869
  const entityId = createBaseEntity(world, mesh, {
2781
2870
  label: payload.name ?? "Cube",
2782
2871
  entityType: "cube",
@@ -2801,9 +2890,9 @@ function createCylinder({
2801
2890
  scene,
2802
2891
  payload
2803
2892
  }) {
2804
- const geometry = new THREE33__namespace.CylinderGeometry(0.5, 0.5, 1, 20);
2805
- const material = new THREE33__namespace.MeshStandardMaterial({ color: "#ffffff" });
2806
- const mesh = new THREE33__namespace.Mesh(geometry, material);
2893
+ const geometry = new THREE34__namespace.CylinderGeometry(0.5, 0.5, 1, 20);
2894
+ const material = new THREE34__namespace.MeshStandardMaterial({ color: "#ffffff" });
2895
+ const mesh = new THREE34__namespace.Mesh(geometry, material);
2807
2896
  const entityId = createBaseEntity(world, mesh, {
2808
2897
  label: payload.name ?? "Cylinder",
2809
2898
  entityType: "cylinder",
@@ -2823,7 +2912,7 @@ function createCylinder({
2823
2912
  }
2824
2913
  __name(createCylinder, "createCylinder");
2825
2914
  function createEmpty({ world, scene, payload, isEditor }) {
2826
- const object = new THREE33__namespace.Group();
2915
+ const object = new THREE34__namespace.Group();
2827
2916
  const entityId = createBaseEntity(world, object, {
2828
2917
  label: payload.name ?? "Empty",
2829
2918
  entityType: "empty",
@@ -2834,7 +2923,7 @@ function createEmpty({ world, scene, payload, isEditor }) {
2834
2923
  }
2835
2924
  __name(createEmpty, "createEmpty");
2836
2925
  function createImage({ world, scene, payload }) {
2837
- const anchor = new THREE33__namespace.Object3D();
2926
+ const anchor = new THREE34__namespace.Object3D();
2838
2927
  const imagePath = payload.path ?? "";
2839
2928
  const entityId = createBaseEntity(world, anchor, {
2840
2929
  label: payload.name ?? "Image",
@@ -2847,7 +2936,7 @@ function createImage({ world, scene, payload }) {
2847
2936
  if (!imagePath) {
2848
2937
  return entityId;
2849
2938
  }
2850
- const loader = new THREE33__namespace.TextureLoader();
2939
+ const loader = new THREE34__namespace.TextureLoader();
2851
2940
  loader.load(
2852
2941
  imagePath,
2853
2942
  (texture) => {
@@ -2855,13 +2944,13 @@ function createImage({ world, scene, payload }) {
2855
2944
  texture.dispose();
2856
2945
  return;
2857
2946
  }
2858
- const material = new THREE33__namespace.MeshBasicMaterial({
2947
+ const material = new THREE34__namespace.MeshBasicMaterial({
2859
2948
  map: texture,
2860
2949
  transparent: true,
2861
- side: THREE33__namespace.DoubleSide
2950
+ side: THREE34__namespace.DoubleSide
2862
2951
  });
2863
- const geometry = new THREE33__namespace.PlaneGeometry(1, 1);
2864
- const plane = new THREE33__namespace.Mesh(geometry, material);
2952
+ const geometry = new THREE34__namespace.PlaneGeometry(1, 1);
2953
+ const plane = new THREE34__namespace.Mesh(geometry, material);
2865
2954
  plane.userData.entityId = entityId;
2866
2955
  const textureImage = texture.image;
2867
2956
  const width = textureImage?.width ?? 1;
@@ -2907,7 +2996,7 @@ function createImageTarget({
2907
2996
  payload,
2908
2997
  isEditor
2909
2998
  }) {
2910
- const anchor = new THREE33__namespace.Object3D();
2999
+ const anchor = new THREE34__namespace.Object3D();
2911
3000
  const imagePath = payload.path ?? "";
2912
3001
  const entityId = createBaseEntity(world, anchor, {
2913
3002
  label: payload.name ?? "Image Target",
@@ -2924,7 +3013,7 @@ function createImageTarget({
2924
3013
  if (!isEditor || !imagePath) {
2925
3014
  return entityId;
2926
3015
  }
2927
- const loader = new THREE33__namespace.TextureLoader();
3016
+ const loader = new THREE34__namespace.TextureLoader();
2928
3017
  loader.load(
2929
3018
  imagePath,
2930
3019
  (texture) => {
@@ -2932,13 +3021,13 @@ function createImageTarget({
2932
3021
  texture.dispose();
2933
3022
  return;
2934
3023
  }
2935
- const material = new THREE33__namespace.MeshBasicMaterial({
3024
+ const material = new THREE34__namespace.MeshBasicMaterial({
2936
3025
  map: texture,
2937
3026
  transparent: true,
2938
- side: THREE33__namespace.DoubleSide
3027
+ side: THREE34__namespace.DoubleSide
2939
3028
  });
2940
- const geometry = new THREE33__namespace.PlaneGeometry(1, 1);
2941
- const plane = new THREE33__namespace.Mesh(geometry, material);
3029
+ const geometry = new THREE34__namespace.PlaneGeometry(1, 1);
3030
+ const plane = new THREE34__namespace.Mesh(geometry, material);
2942
3031
  plane.userData.entityId = entityId;
2943
3032
  const textureImage = texture.image;
2944
3033
  const width = textureImage?.width ?? 1;
@@ -2957,12 +3046,48 @@ function createImageTarget({
2957
3046
  return entityId;
2958
3047
  }
2959
3048
  __name(createImageTarget, "createImageTarget");
3049
+ function isInstancedMeshKind(value) {
3050
+ return value === "cube" || value === "sphere" || value === "plane" || value === "cylinder" || value === "capsule";
3051
+ }
3052
+ __name(isInstancedMeshKind, "isInstancedMeshKind");
3053
+ function isInstanceTransformArray(value) {
3054
+ return Array.isArray(value);
3055
+ }
3056
+ __name(isInstanceTransformArray, "isInstanceTransformArray");
3057
+ function createInstancedMesh({
3058
+ world,
3059
+ scene,
3060
+ payload
3061
+ }) {
3062
+ const anchor = new THREE34__namespace.Object3D();
3063
+ const opts = payload.options ?? {};
3064
+ const meshKind = isInstancedMeshKind(opts.meshKind) ? opts.meshKind : "cube";
3065
+ const meshParameters = opts.meshParameters && typeof opts.meshParameters === "object" ? opts.meshParameters : void 0;
3066
+ const instances = isInstanceTransformArray(
3067
+ opts.instances
3068
+ ) ? opts.instances : void 0;
3069
+ const castShadow = typeof opts.castShadow === "boolean" ? opts.castShadow : false;
3070
+ const receiveShadow = typeof opts.receiveShadow === "boolean" ? opts.receiveShadow : false;
3071
+ const entityId = createBaseEntity(world, anchor, {
3072
+ label: payload.name ?? "Instanced Mesh",
3073
+ entityType: "instancedMesh",
3074
+ transformInput: payload.transform
3075
+ });
3076
+ createInstancedMeshComponent(world, entityId, meshKind, meshParameters, {
3077
+ castShadow,
3078
+ receiveShadow,
3079
+ instances
3080
+ });
3081
+ scene.add(anchor);
3082
+ return entityId;
3083
+ }
3084
+ __name(createInstancedMesh, "createInstancedMesh");
2960
3085
  function createAmbientLight({
2961
3086
  world,
2962
3087
  scene,
2963
3088
  payload
2964
3089
  }) {
2965
- const light = new THREE33__namespace.AmbientLight("#ffffff", 0.6);
3090
+ const light = new THREE34__namespace.AmbientLight("#ffffff", 0.6);
2966
3091
  const entityId = createBaseEntity(world, light, {
2967
3092
  label: payload.name ?? "Ambient Light",
2968
3093
  entityType: "ambientLight",
@@ -2979,7 +3104,7 @@ function createAreaLight({
2979
3104
  payload,
2980
3105
  isEditor
2981
3106
  }) {
2982
- const light = new THREE33__namespace.RectAreaLight("#ffffff", 5, 4, 4);
3107
+ const light = new THREE34__namespace.RectAreaLight("#ffffff", 5, 4, 4);
2983
3108
  light.lookAt(0, 0, 0);
2984
3109
  const entityId = createBaseEntity(world, light, {
2985
3110
  label: payload.name ?? "Area Light",
@@ -3008,7 +3133,7 @@ function createDirectionalLight({
3008
3133
  payload,
3009
3134
  isEditor
3010
3135
  }) {
3011
- const light = new THREE33__namespace.DirectionalLight("#ffffff", 1.5);
3136
+ const light = new THREE34__namespace.DirectionalLight("#ffffff", 1.5);
3012
3137
  light.castShadow = true;
3013
3138
  const entityId = createBaseEntity(world, light, {
3014
3139
  label: payload.name ?? "Directional Light",
@@ -3019,7 +3144,7 @@ function createDirectionalLight({
3019
3144
  });
3020
3145
  createLightComponent(world, entityId, light);
3021
3146
  if (isEditor) {
3022
- const helper = new THREE33__namespace.DirectionalLightHelper(light, 1.8, "#38bdf8");
3147
+ const helper = new THREE34__namespace.DirectionalLightHelper(light, 1.8, "#38bdf8");
3023
3148
  helper.onBeforeRender = () => {
3024
3149
  helper.update();
3025
3150
  };
@@ -3037,7 +3162,7 @@ function createPointLight({
3037
3162
  payload,
3038
3163
  isEditor
3039
3164
  }) {
3040
- const light = new THREE33__namespace.PointLight("#ffffff", 1, 10);
3165
+ const light = new THREE34__namespace.PointLight("#ffffff", 1, 10);
3041
3166
  const entityId = createBaseEntity(world, light, {
3042
3167
  label: payload.name ?? "Point Light",
3043
3168
  entityType: "pointLight",
@@ -3047,7 +3172,7 @@ function createPointLight({
3047
3172
  });
3048
3173
  createLightComponent(world, entityId, light);
3049
3174
  if (isEditor) {
3050
- const helper = new THREE33__namespace.PointLightHelper(light, 0.35, "#fbbf24");
3175
+ const helper = new THREE34__namespace.PointLightHelper(light, 0.35, "#fbbf24");
3051
3176
  helper.onBeforeRender = () => {
3052
3177
  helper.update();
3053
3178
  };
@@ -3065,7 +3190,7 @@ function createSpotLight({
3065
3190
  payload,
3066
3191
  isEditor
3067
3192
  }) {
3068
- const light = new THREE33__namespace.SpotLight("#ffffff", 1, 20, Math.PI / 6, 0.1, 1);
3193
+ const light = new THREE34__namespace.SpotLight("#ffffff", 1, 20, Math.PI / 6, 0.1, 1);
3069
3194
  const entityId = createBaseEntity(world, light, {
3070
3195
  label: payload.name ?? "Spot Light",
3071
3196
  entityType: "spotLight",
@@ -3075,7 +3200,7 @@ function createSpotLight({
3075
3200
  });
3076
3201
  createLightComponent(world, entityId, light);
3077
3202
  if (isEditor) {
3078
- const helper = new THREE33__namespace.SpotLightHelper(light, "#f59e0b");
3203
+ const helper = new THREE34__namespace.SpotLightHelper(light, "#f59e0b");
3079
3204
  helper.onBeforeRender = () => {
3080
3205
  helper.update();
3081
3206
  };
@@ -3119,6 +3244,8 @@ __export(components_exports, {
3119
3244
  CameraComponent: () => CameraComponent,
3120
3245
  DEFAULT_COLLIDER_STATE: () => DEFAULT_COLLIDER_STATE,
3121
3246
  DEFAULT_ENVIRONMENT_STATE: () => DEFAULT_ENVIRONMENT_STATE,
3247
+ DEFAULT_INSTANCED_MESH_PARAMETERS: () => DEFAULT_INSTANCED_MESH_PARAMETERS,
3248
+ DEFAULT_INSTANCE_TRANSFORM: () => DEFAULT_INSTANCE_TRANSFORM,
3122
3249
  DEFAULT_MESH_GEOMETRY_PARAMETERS: () => DEFAULT_MESH_GEOMETRY_PARAMETERS,
3123
3250
  DEFAULT_PHYSICS_STATE: () => DEFAULT_PHYSICS_STATE,
3124
3251
  DEFAULT_POSTPROCESSING_STATE: () => DEFAULT_POSTPROCESSING_STATE,
@@ -3128,6 +3255,7 @@ __export(components_exports, {
3128
3255
  ImageComponent: () => ImageComponent,
3129
3256
  ImageTarget: () => ImageTarget,
3130
3257
  ImageTargetAnchor: () => ImageTargetAnchor,
3258
+ InstancedMeshComponent: () => InstancedMeshComponent,
3131
3259
  LightComponent: () => LightComponent,
3132
3260
  MaterialComponent: () => MaterialComponent,
3133
3261
  MeshComponent: () => MeshComponent,
@@ -3167,7 +3295,7 @@ function createModelLoader() {
3167
3295
  }
3168
3296
  __name(createModelLoader, "createModelLoader");
3169
3297
  function createModel({ world, scene, payload }) {
3170
- const anchor = new THREE33__namespace.Object3D();
3298
+ const anchor = new THREE34__namespace.Object3D();
3171
3299
  const modelPath = payload.path ?? "";
3172
3300
  const entityId = createBaseEntity(world, anchor, {
3173
3301
  label: payload.name ?? "Model",
@@ -3224,12 +3352,12 @@ function createModel({ world, scene, payload }) {
3224
3352
  }
3225
3353
  __name(createModel, "createModel");
3226
3354
  function createPlane({ world, scene, payload }) {
3227
- const geometry = new THREE33__namespace.PlaneGeometry(100, 100);
3228
- const material = new THREE33__namespace.MeshStandardMaterial({
3355
+ const geometry = new THREE34__namespace.PlaneGeometry(100, 100);
3356
+ const material = new THREE34__namespace.MeshStandardMaterial({
3229
3357
  color: "#ffffff",
3230
- side: THREE33__namespace.DoubleSide
3358
+ side: THREE34__namespace.DoubleSide
3231
3359
  });
3232
- const mesh = new THREE33__namespace.Mesh(geometry, material);
3360
+ const mesh = new THREE34__namespace.Mesh(geometry, material);
3233
3361
  const entityId = createBaseEntity(
3234
3362
  world,
3235
3363
  mesh,
@@ -3261,7 +3389,7 @@ function createPlane({ world, scene, payload }) {
3261
3389
  }
3262
3390
  __name(createPlane, "createPlane");
3263
3391
  function createSprite({ world, scene, payload }) {
3264
- const anchor = new THREE33__namespace.Object3D();
3392
+ const anchor = new THREE34__namespace.Object3D();
3265
3393
  const imagePath = payload.path ?? "";
3266
3394
  const entityId = createBaseEntity(world, anchor, {
3267
3395
  label: payload.name ?? "Sprite",
@@ -3273,7 +3401,7 @@ function createSprite({ world, scene, payload }) {
3273
3401
  if (!imagePath) {
3274
3402
  return entityId;
3275
3403
  }
3276
- const loader = new THREE33__namespace.TextureLoader();
3404
+ const loader = new THREE34__namespace.TextureLoader();
3277
3405
  loader.load(
3278
3406
  imagePath,
3279
3407
  (texture) => {
@@ -3281,11 +3409,11 @@ function createSprite({ world, scene, payload }) {
3281
3409
  texture.dispose();
3282
3410
  return;
3283
3411
  }
3284
- const material = new THREE33__namespace.SpriteMaterial({
3412
+ const material = new THREE34__namespace.SpriteMaterial({
3285
3413
  map: texture,
3286
3414
  transparent: true
3287
3415
  });
3288
- const sprite = new THREE33__namespace.Sprite(material);
3416
+ const sprite = new THREE34__namespace.Sprite(material);
3289
3417
  sprite.userData.entityId = entityId;
3290
3418
  const textureImage = texture.image;
3291
3419
  spriteComponent.width = textureImage?.width ?? 1;
@@ -3303,9 +3431,9 @@ function createSprite({ world, scene, payload }) {
3303
3431
  }
3304
3432
  __name(createSprite, "createSprite");
3305
3433
  function createSphere({ world, scene, payload }) {
3306
- const geometry = new THREE33__namespace.SphereGeometry(0.5, 24, 24);
3307
- const material = new THREE33__namespace.MeshStandardMaterial({ color: "#ffffff" });
3308
- const mesh = new THREE33__namespace.Mesh(geometry, material);
3434
+ const geometry = new THREE34__namespace.SphereGeometry(0.5, 24, 24);
3435
+ const material = new THREE34__namespace.MeshStandardMaterial({ color: "#ffffff" });
3436
+ const mesh = new THREE34__namespace.Mesh(geometry, material);
3309
3437
  const entityId = createBaseEntity(world, mesh, {
3310
3438
  label: payload.name ?? "Sphere",
3311
3439
  entityType: "sphere",
@@ -3325,10 +3453,10 @@ function createSphere({ world, scene, payload }) {
3325
3453
  __name(createSphere, "createSphere");
3326
3454
  function getOrCreateListener2(camera) {
3327
3455
  const existing = camera.userData.ecsAudioListener;
3328
- if (existing instanceof THREE33__namespace.AudioListener) {
3456
+ if (existing instanceof THREE34__namespace.AudioListener) {
3329
3457
  return existing;
3330
3458
  }
3331
- const listener = new THREE33__namespace.AudioListener();
3459
+ const listener = new THREE34__namespace.AudioListener();
3332
3460
  camera.add(listener);
3333
3461
  camera.userData.ecsAudioListener = listener;
3334
3462
  return listener;
@@ -3378,10 +3506,10 @@ function normalizeOptions(input) {
3378
3506
  }
3379
3507
  __name(normalizeOptions, "normalizeOptions");
3380
3508
  function createChromaMaterial(texture, options) {
3381
- return new THREE33__namespace.ShaderMaterial({
3509
+ return new THREE34__namespace.ShaderMaterial({
3382
3510
  uniforms: {
3383
3511
  tex: { value: texture },
3384
- keyColor: { value: new THREE33__namespace.Color(options.backgroundColor) },
3512
+ keyColor: { value: new THREE34__namespace.Color(options.backgroundColor) },
3385
3513
  similarity: { value: options.similarity },
3386
3514
  smoothness: { value: options.smoothness },
3387
3515
  spill: { value: options.spill }
@@ -3413,22 +3541,22 @@ function createChromaMaterial(texture, options) {
3413
3541
  }
3414
3542
  `,
3415
3543
  transparent: true,
3416
- side: THREE33__namespace.DoubleSide
3544
+ side: THREE34__namespace.DoubleSide
3417
3545
  });
3418
3546
  }
3419
3547
  __name(createChromaMaterial, "createChromaMaterial");
3420
3548
  function createStandardMaterial(texture) {
3421
- return new THREE33__namespace.MeshBasicMaterial({
3549
+ return new THREE34__namespace.MeshBasicMaterial({
3422
3550
  map: texture,
3423
3551
  transparent: true,
3424
- side: THREE33__namespace.DoubleSide
3552
+ side: THREE34__namespace.DoubleSide
3425
3553
  });
3426
3554
  }
3427
3555
  __name(createStandardMaterial, "createStandardMaterial");
3428
3556
  function createVideoMesh(entityId, texture, options) {
3429
- const geometry = new THREE33__namespace.PlaneGeometry(1, 1);
3557
+ const geometry = new THREE34__namespace.PlaneGeometry(1, 1);
3430
3558
  const material = options.isGreenScreen ? createChromaMaterial(texture, options) : createStandardMaterial(texture);
3431
- const mesh = new THREE33__namespace.Mesh(geometry, material);
3559
+ const mesh = new THREE34__namespace.Mesh(geometry, material);
3432
3560
  mesh.userData.entityId = entityId;
3433
3561
  mesh.scale.set(options.width, options.height, 1);
3434
3562
  return { mesh, material };
@@ -3463,7 +3591,7 @@ function createVideo({
3463
3591
  payload,
3464
3592
  isEditor
3465
3593
  }) {
3466
- const anchor = new THREE33__namespace.Object3D();
3594
+ const anchor = new THREE34__namespace.Object3D();
3467
3595
  const path = payload.path ?? "";
3468
3596
  const options = normalizeOptions(payload.options);
3469
3597
  const entityId = createBaseEntity(world, anchor, {
@@ -3478,8 +3606,8 @@ function createVideo({
3478
3606
  return entityId;
3479
3607
  }
3480
3608
  const video = createVideoElement(path, options);
3481
- const texture = new THREE33__namespace.VideoTexture(video);
3482
- texture.colorSpace = THREE33__namespace.SRGBColorSpace;
3609
+ const texture = new THREE34__namespace.VideoTexture(video);
3610
+ texture.colorSpace = THREE34__namespace.SRGBColorSpace;
3483
3611
  texture.needsUpdate = true;
3484
3612
  const { mesh, material } = createVideoMesh(entityId, texture, options);
3485
3613
  anchor.add(mesh);
@@ -3495,7 +3623,7 @@ function createVideo({
3495
3623
  });
3496
3624
  if (!isEditor && options.positional) {
3497
3625
  const listener = getOrCreateListener2(camera);
3498
- const audioNode = new THREE33__namespace.PositionalAudio(listener);
3626
+ const audioNode = new THREE34__namespace.PositionalAudio(listener);
3499
3627
  audioNode.setVolume(options.volume);
3500
3628
  audioNode.setRefDistance(options.refDistance);
3501
3629
  audioNode.setDistanceModel(normalizeDistanceModel2(options.distanceModel));
@@ -3523,6 +3651,7 @@ function registerDefaultFactories(objectManagementSystem) {
3523
3651
  objectManagementSystem.register("model", createModel);
3524
3652
  objectManagementSystem.register("image", createImage);
3525
3653
  objectManagementSystem.register("imageTarget", createImageTarget);
3654
+ objectManagementSystem.register("instancedMesh", createInstancedMesh);
3526
3655
  objectManagementSystem.register("sprite", createSprite);
3527
3656
  objectManagementSystem.register("audio", createAudio);
3528
3657
  objectManagementSystem.register("camera", createCamera);
@@ -3674,7 +3803,7 @@ function transitionToClip(runtime, nextClipId, crossFadeDuration) {
3674
3803
  }
3675
3804
  __name(transitionToClip, "transitionToClip");
3676
3805
  function applyActionState(action, component, paused, shouldLoop) {
3677
- const loopMode = shouldLoop ? THREE33__namespace.LoopRepeat : THREE33__namespace.LoopOnce;
3806
+ const loopMode = shouldLoop ? THREE34__namespace.LoopRepeat : THREE34__namespace.LoopOnce;
3678
3807
  const repetitions = shouldLoop ? Infinity : 1;
3679
3808
  action.setLoop(loopMode, repetitions);
3680
3809
  action.clampWhenFinished = !shouldLoop;
@@ -3847,7 +3976,7 @@ var _AnimationSystem = class _AnimationSystem {
3847
3976
  if (runtime) {
3848
3977
  stopAllActions(runtime);
3849
3978
  }
3850
- const mixer = new THREE33__namespace.AnimationMixer(root);
3979
+ const mixer = new THREE34__namespace.AnimationMixer(root);
3851
3980
  const entries2 = readRuntimeClipEntries(animation);
3852
3981
  const indexedActions = createActions(mixer, entries2);
3853
3982
  runtime = {
@@ -3973,11 +4102,11 @@ function normalizeOrthoBounds(component) {
3973
4102
  }
3974
4103
  __name(normalizeOrthoBounds, "normalizeOrthoBounds");
3975
4104
  function isPerspectiveCamera(camera) {
3976
- return camera instanceof THREE33__namespace.PerspectiveCamera;
4105
+ return camera instanceof THREE34__namespace.PerspectiveCamera;
3977
4106
  }
3978
4107
  __name(isPerspectiveCamera, "isPerspectiveCamera");
3979
4108
  function isOrthographicCamera(camera) {
3980
- return camera instanceof THREE33__namespace.OrthographicCamera;
4109
+ return camera instanceof THREE34__namespace.OrthographicCamera;
3981
4110
  }
3982
4111
  __name(isOrthographicCamera, "isOrthographicCamera");
3983
4112
  function readWindowAspect() {
@@ -4030,7 +4159,7 @@ var _CameraSyncSystem = class _CameraSyncSystem {
4030
4159
  continue;
4031
4160
  }
4032
4161
  const camera = objectRef.object;
4033
- if (!(camera instanceof THREE33__namespace.Camera)) {
4162
+ if (!(camera instanceof THREE34__namespace.Camera)) {
4034
4163
  continue;
4035
4164
  }
4036
4165
  const nextSignature = buildSignature(component, camera, windowAspect);
@@ -4094,7 +4223,7 @@ var MIN_DENSITY = 0;
4094
4223
  function createGradientTexture(effect, colors) {
4095
4224
  if (typeof document === "undefined") {
4096
4225
  const pixel = new Uint8Array([30, 30, 30, 255]);
4097
- const fallback = new THREE33__namespace.DataTexture(pixel, 1, 1, THREE33__namespace.RGBAFormat);
4226
+ const fallback = new THREE34__namespace.DataTexture(pixel, 1, 1, THREE34__namespace.RGBAFormat);
4098
4227
  fallback.needsUpdate = true;
4099
4228
  return fallback;
4100
4229
  }
@@ -4103,7 +4232,7 @@ function createGradientTexture(effect, colors) {
4103
4232
  canvas.height = 512;
4104
4233
  const context = canvas.getContext("2d");
4105
4234
  if (!context) {
4106
- const fallback = new THREE33__namespace.CanvasTexture(canvas);
4235
+ const fallback = new THREE34__namespace.CanvasTexture(canvas);
4107
4236
  fallback.needsUpdate = true;
4108
4237
  return fallback;
4109
4238
  }
@@ -4131,15 +4260,15 @@ function createGradientTexture(effect, colors) {
4131
4260
  context.fillRect(0, 0, 512, 512);
4132
4261
  context.globalCompositeOperation = "source-over";
4133
4262
  }
4134
- const texture = new THREE33__namespace.CanvasTexture(canvas);
4135
- texture.colorSpace = THREE33__namespace.SRGBColorSpace;
4263
+ const texture = new THREE34__namespace.CanvasTexture(canvas);
4264
+ texture.colorSpace = THREE34__namespace.SRGBColorSpace;
4136
4265
  texture.needsUpdate = true;
4137
4266
  return texture;
4138
4267
  }
4139
4268
  __name(createGradientTexture, "createGradientTexture");
4140
4269
  var _EnvironmentSyncSystem = class _EnvironmentSyncSystem {
4141
4270
  constructor(scene) {
4142
- this.textureLoader = new THREE33__namespace.TextureLoader();
4271
+ this.textureLoader = new THREE34__namespace.TextureLoader();
4143
4272
  this.signature = null;
4144
4273
  this.activeTexture = null;
4145
4274
  this.pendingImageUrl = null;
@@ -4162,7 +4291,7 @@ var _EnvironmentSyncSystem = class _EnvironmentSyncSystem {
4162
4291
  if (skybox.type === "color") {
4163
4292
  this.disposeActiveTexture();
4164
4293
  this.pendingImageUrl = null;
4165
- this.scene.background = new THREE33__namespace.Color(skybox.color || "#1e1e1e");
4294
+ this.scene.background = new THREE34__namespace.Color(skybox.color || "#1e1e1e");
4166
4295
  return;
4167
4296
  }
4168
4297
  if (skybox.type === "gradient") {
@@ -4196,7 +4325,7 @@ var _EnvironmentSyncSystem = class _EnvironmentSyncSystem {
4196
4325
  texture.dispose();
4197
4326
  return;
4198
4327
  }
4199
- texture.colorSpace = THREE33__namespace.SRGBColorSpace;
4328
+ texture.colorSpace = THREE34__namespace.SRGBColorSpace;
4200
4329
  this.activeTexture = texture;
4201
4330
  this.scene.background = texture;
4202
4331
  },
@@ -4215,16 +4344,16 @@ var _EnvironmentSyncSystem = class _EnvironmentSyncSystem {
4215
4344
  this.scene.fog = null;
4216
4345
  return;
4217
4346
  }
4218
- const fogColor = new THREE33__namespace.Color(fog.color || "#1e1e1e");
4347
+ const fogColor = new THREE34__namespace.Color(fog.color || "#1e1e1e");
4219
4348
  if (fog.type === "linear") {
4220
4349
  const near = Number.isFinite(fog.linear.near) ? fog.linear.near : 1;
4221
4350
  const farCandidate = Number.isFinite(fog.linear.far) ? fog.linear.far : near + 10;
4222
4351
  const far = Math.max(near + MIN_FOG_DELTA, farCandidate);
4223
- this.scene.fog = new THREE33__namespace.Fog(fogColor, near, far);
4352
+ this.scene.fog = new THREE34__namespace.Fog(fogColor, near, far);
4224
4353
  return;
4225
4354
  }
4226
4355
  const density = Number.isFinite(fog.exponential.density) ? Math.max(MIN_DENSITY, fog.exponential.density) : 2e-3;
4227
- this.scene.fog = new THREE33__namespace.FogExp2(fogColor, density);
4356
+ this.scene.fog = new THREE34__namespace.FogExp2(fogColor, density);
4228
4357
  }
4229
4358
  update(world) {
4230
4359
  const entityIds = world.query(Environment);
@@ -4306,10 +4435,10 @@ var _PostprocessingSyncSystem = class _PostprocessingSyncSystem {
4306
4435
  );
4307
4436
  }
4308
4437
  if (values.bloom.enabled) {
4309
- const size = this.renderer.getSize(new THREE33__namespace.Vector2());
4438
+ const size = this.renderer.getSize(new THREE34__namespace.Vector2());
4310
4439
  composer.addPass(
4311
4440
  new UnrealBloomPass_js.UnrealBloomPass(
4312
- new THREE33__namespace.Vector2(size.width, size.height),
4441
+ new THREE34__namespace.Vector2(size.width, size.height),
4313
4442
  values.bloom.intensity,
4314
4443
  values.bloom.radius,
4315
4444
  values.bloom.threshold
@@ -4354,7 +4483,7 @@ var _PostprocessingSyncSystem = class _PostprocessingSyncSystem {
4354
4483
  if (values.dotScreen.enabled) {
4355
4484
  composer.addPass(
4356
4485
  new DotScreenPass_js.DotScreenPass(
4357
- new THREE33__namespace.Vector2(0, 0),
4486
+ new THREE34__namespace.Vector2(0, 0),
4358
4487
  values.dotScreen.angle ?? values.dotScreen.dotScreenAngle,
4359
4488
  values.dotScreen.scale ?? values.dotScreen.dotScreenScale
4360
4489
  )
@@ -4428,7 +4557,7 @@ function computeColliderState(colliderValues, object) {
4428
4557
  if (!object) {
4429
4558
  return colliderValues;
4430
4559
  }
4431
- const scale = new THREE33__namespace.Vector3();
4560
+ const scale = new THREE34__namespace.Vector3();
4432
4561
  object.getWorldScale(scale);
4433
4562
  return {
4434
4563
  ...colliderValues,
@@ -4479,8 +4608,8 @@ function createColliderDesc(RAPIER, values, triMeshData) {
4479
4608
  values.offsetPosition.y,
4480
4609
  values.offsetPosition.z
4481
4610
  );
4482
- const offsetQuaternion = new THREE33__namespace.Quaternion().setFromEuler(
4483
- new THREE33__namespace.Euler(
4611
+ const offsetQuaternion = new THREE34__namespace.Quaternion().setFromEuler(
4612
+ new THREE34__namespace.Euler(
4484
4613
  values.offsetRotation.x,
4485
4614
  values.offsetRotation.y,
4486
4615
  values.offsetRotation.z
@@ -4491,7 +4620,7 @@ function createColliderDesc(RAPIER, values, triMeshData) {
4491
4620
  }
4492
4621
  __name(createColliderDesc, "createColliderDesc");
4493
4622
  function findFirstMeshWithGeometry(object) {
4494
- if (object instanceof THREE33__namespace.Mesh && object.geometry) {
4623
+ if (object instanceof THREE34__namespace.Mesh && object.geometry) {
4495
4624
  return object;
4496
4625
  }
4497
4626
  let found = null;
@@ -4499,7 +4628,7 @@ function findFirstMeshWithGeometry(object) {
4499
4628
  if (found) {
4500
4629
  return;
4501
4630
  }
4502
- if (child instanceof THREE33__namespace.Mesh && child.geometry) {
4631
+ if (child instanceof THREE34__namespace.Mesh && child.geometry) {
4503
4632
  found = child;
4504
4633
  }
4505
4634
  });
@@ -4525,13 +4654,13 @@ function createTriMeshData(object) {
4525
4654
  }
4526
4655
  object.updateWorldMatrix(true, true);
4527
4656
  mesh.updateWorldMatrix(true, true);
4528
- const worldToObject = new THREE33__namespace.Matrix4().copy(object.matrixWorld).invert();
4529
- const relativeMatrix = new THREE33__namespace.Matrix4().multiplyMatrices(
4657
+ const worldToObject = new THREE34__namespace.Matrix4().copy(object.matrixWorld).invert();
4658
+ const relativeMatrix = new THREE34__namespace.Matrix4().multiplyMatrices(
4530
4659
  worldToObject,
4531
4660
  mesh.matrixWorld
4532
4661
  );
4533
4662
  const vertices = new Float32Array(positionCount * 3);
4534
- const point = new THREE33__namespace.Vector3();
4663
+ const point = new THREE34__namespace.Vector3();
4535
4664
  for (let index = 0; index < positionCount; index += 1) {
4536
4665
  point.set(
4537
4666
  positionAttribute.getX(index),
@@ -4569,8 +4698,8 @@ function createTriMeshData(object) {
4569
4698
  }
4570
4699
  __name(createTriMeshData, "createTriMeshData");
4571
4700
  function syncBodyFromTransform(body, transform) {
4572
- const quaternion = new THREE33__namespace.Quaternion().setFromEuler(
4573
- new THREE33__namespace.Euler(transform.rotation.x, transform.rotation.y, transform.rotation.z)
4701
+ const quaternion = new THREE34__namespace.Quaternion().setFromEuler(
4702
+ new THREE34__namespace.Euler(transform.rotation.x, transform.rotation.y, transform.rotation.z)
4574
4703
  );
4575
4704
  body.setTranslation(
4576
4705
  {
@@ -4597,8 +4726,8 @@ function syncTransformFromBody(transform, body) {
4597
4726
  transform.position.x = position.x;
4598
4727
  transform.position.y = position.y;
4599
4728
  transform.position.z = position.z;
4600
- const euler = new THREE33__namespace.Euler().setFromQuaternion(
4601
- new THREE33__namespace.Quaternion(rotation.x, rotation.y, rotation.z, rotation.w)
4729
+ const euler = new THREE34__namespace.Euler().setFromQuaternion(
4730
+ new THREE34__namespace.Quaternion(rotation.x, rotation.y, rotation.z, rotation.w)
4602
4731
  );
4603
4732
  transform.rotation.x = euler.x;
4604
4733
  transform.rotation.y = euler.y;
@@ -4710,8 +4839,8 @@ var _PhysicsSyncSystem = class _PhysicsSyncSystem {
4710
4839
  transform.position.y,
4711
4840
  transform.position.z
4712
4841
  );
4713
- const quaternion = new THREE33__namespace.Quaternion().setFromEuler(
4714
- new THREE33__namespace.Euler(
4842
+ const quaternion = new THREE34__namespace.Quaternion().setFromEuler(
4843
+ new THREE34__namespace.Euler(
4715
4844
  transform.rotation.x,
4716
4845
  transform.rotation.y,
4717
4846
  transform.rotation.z
@@ -5286,7 +5415,7 @@ function applyLightValues(lightComponent) {
5286
5415
  values.castShadow
5287
5416
  );
5288
5417
  }
5289
- if (light instanceof THREE33__namespace.PointLight) {
5418
+ if (light instanceof THREE34__namespace.PointLight) {
5290
5419
  if (typeof values.distance === "number" && Number.isFinite(values.distance)) {
5291
5420
  light.distance = Math.max(MIN_LIGHT_DISTANCE, values.distance);
5292
5421
  }
@@ -5294,7 +5423,7 @@ function applyLightValues(lightComponent) {
5294
5423
  light.decay = Math.max(0, values.decay);
5295
5424
  }
5296
5425
  }
5297
- if (light instanceof THREE33__namespace.SpotLight) {
5426
+ if (light instanceof THREE34__namespace.SpotLight) {
5298
5427
  if (typeof values.distance === "number" && Number.isFinite(values.distance)) {
5299
5428
  light.distance = Math.max(MIN_LIGHT_DISTANCE, values.distance);
5300
5429
  }
@@ -5308,7 +5437,7 @@ function applyLightValues(lightComponent) {
5308
5437
  light.penumbra = Math.max(0, Math.min(1, values.penumbra));
5309
5438
  }
5310
5439
  }
5311
- if (light instanceof THREE33__namespace.RectAreaLight) {
5440
+ if (light instanceof THREE34__namespace.RectAreaLight) {
5312
5441
  if (typeof values.width === "number" && Number.isFinite(values.width)) {
5313
5442
  light.width = Math.max(MIN_AREA_SIZE, values.width);
5314
5443
  }
@@ -5369,15 +5498,15 @@ function resolveMaterialPropertyKey(key) {
5369
5498
  __name(resolveMaterialPropertyKey, "resolveMaterialPropertyKey");
5370
5499
  function createMaterialByType(type) {
5371
5500
  if (type === "basic") {
5372
- return new THREE33__namespace.MeshBasicMaterial();
5501
+ return new THREE34__namespace.MeshBasicMaterial();
5373
5502
  }
5374
5503
  if (type === "phong") {
5375
- return new THREE33__namespace.MeshPhongMaterial();
5504
+ return new THREE34__namespace.MeshPhongMaterial();
5376
5505
  }
5377
5506
  if (type === "physical") {
5378
- return new THREE33__namespace.MeshPhysicalMaterial();
5507
+ return new THREE34__namespace.MeshPhysicalMaterial();
5379
5508
  }
5380
- return new THREE33__namespace.MeshStandardMaterial();
5509
+ return new THREE34__namespace.MeshStandardMaterial();
5381
5510
  }
5382
5511
  __name(createMaterialByType, "createMaterialByType");
5383
5512
  function replaceMaterialAcrossObject(object, previous, next) {
@@ -5436,12 +5565,12 @@ function applyTextureFiltering(material, filtering) {
5436
5565
  const target = material;
5437
5566
  for (const slot of materialTextureSlots) {
5438
5567
  const texture = target[slot];
5439
- if (!texture || !(texture instanceof THREE33__namespace.Texture)) {
5568
+ if (!texture || !(texture instanceof THREE34__namespace.Texture)) {
5440
5569
  continue;
5441
5570
  }
5442
5571
  const useMipmaps = texture.generateMipmaps !== false;
5443
- texture.magFilter = sharp ? THREE33__namespace.NearestFilter : THREE33__namespace.LinearFilter;
5444
- texture.minFilter = useMipmaps ? sharp ? THREE33__namespace.NearestMipmapNearestFilter : THREE33__namespace.LinearMipmapLinearFilter : sharp ? THREE33__namespace.NearestFilter : THREE33__namespace.LinearFilter;
5572
+ texture.magFilter = sharp ? THREE34__namespace.NearestFilter : THREE34__namespace.LinearFilter;
5573
+ texture.minFilter = useMipmaps ? sharp ? THREE34__namespace.NearestMipmapNearestFilter : THREE34__namespace.LinearMipmapLinearFilter : sharp ? THREE34__namespace.NearestFilter : THREE34__namespace.LinearFilter;
5445
5574
  texture.needsUpdate = true;
5446
5575
  }
5447
5576
  material.needsUpdate = true;
@@ -5451,12 +5580,12 @@ function setTextureMipmaps(material, enabled) {
5451
5580
  const target = material;
5452
5581
  for (const slot of materialTextureSlots) {
5453
5582
  const texture = target[slot];
5454
- if (!texture || !(texture instanceof THREE33__namespace.Texture)) {
5583
+ if (!texture || !(texture instanceof THREE34__namespace.Texture)) {
5455
5584
  continue;
5456
5585
  }
5457
5586
  texture.generateMipmaps = enabled;
5458
- const sharp = texture.magFilter === THREE33__namespace.NearestFilter;
5459
- texture.minFilter = enabled ? sharp ? THREE33__namespace.NearestMipmapNearestFilter : THREE33__namespace.LinearMipmapLinearFilter : sharp ? THREE33__namespace.NearestFilter : THREE33__namespace.LinearFilter;
5587
+ const sharp = texture.magFilter === THREE34__namespace.NearestFilter;
5588
+ texture.minFilter = enabled ? sharp ? THREE34__namespace.NearestMipmapNearestFilter : THREE34__namespace.LinearMipmapLinearFilter : sharp ? THREE34__namespace.NearestFilter : THREE34__namespace.LinearFilter;
5460
5589
  texture.needsUpdate = true;
5461
5590
  }
5462
5591
  material.needsUpdate = true;
@@ -5467,7 +5596,7 @@ function assignMaterialTexture(material, rawKey, url, textureCache) {
5467
5596
  const key = resolveMaterialPropertyKey(rawKey);
5468
5597
  let texture = textureCache.get(url);
5469
5598
  if (!texture) {
5470
- texture = new THREE33__namespace.TextureLoader().load(url);
5599
+ texture = new THREE34__namespace.TextureLoader().load(url);
5471
5600
  textureCache.set(url, texture);
5472
5601
  }
5473
5602
  target[key] = texture;
@@ -5665,12 +5794,12 @@ function resolvePrimaryMesh(object) {
5665
5794
  if (!object) {
5666
5795
  return null;
5667
5796
  }
5668
- if (object instanceof THREE33__namespace.Mesh) {
5797
+ if (object instanceof THREE34__namespace.Mesh) {
5669
5798
  return object;
5670
5799
  }
5671
5800
  let found = null;
5672
5801
  object.traverse((child) => {
5673
- if (!found && child instanceof THREE33__namespace.Mesh) {
5802
+ if (!found && child instanceof THREE34__namespace.Mesh) {
5674
5803
  found = child;
5675
5804
  }
5676
5805
  });
@@ -5691,22 +5820,22 @@ function applyGeometry(component) {
5691
5820
  switch (component.kind) {
5692
5821
  case "cube": {
5693
5822
  const params = sanitized;
5694
- nextGeometry = new THREE33__namespace.BoxGeometry(params.width, params.height, params.depth);
5823
+ nextGeometry = new THREE34__namespace.BoxGeometry(params.width, params.height, params.depth);
5695
5824
  break;
5696
5825
  }
5697
5826
  case "plane": {
5698
5827
  const params = sanitized;
5699
- nextGeometry = new THREE33__namespace.PlaneGeometry(params.width, params.height);
5828
+ nextGeometry = new THREE34__namespace.PlaneGeometry(params.width, params.height);
5700
5829
  break;
5701
5830
  }
5702
5831
  case "sphere": {
5703
5832
  const params = sanitized;
5704
- nextGeometry = new THREE33__namespace.SphereGeometry(params.radius, 24, 24);
5833
+ nextGeometry = new THREE34__namespace.SphereGeometry(params.radius, 24, 24);
5705
5834
  break;
5706
5835
  }
5707
5836
  case "cylinder": {
5708
5837
  const params = sanitized;
5709
- nextGeometry = new THREE33__namespace.CylinderGeometry(
5838
+ nextGeometry = new THREE34__namespace.CylinderGeometry(
5710
5839
  params.radius,
5711
5840
  params.radius,
5712
5841
  params.height,
@@ -5716,7 +5845,7 @@ function applyGeometry(component) {
5716
5845
  }
5717
5846
  case "capsule": {
5718
5847
  const params = sanitized;
5719
- nextGeometry = new THREE33__namespace.CapsuleGeometry(params.radius, params.height, 4, 8);
5848
+ nextGeometry = new THREE34__namespace.CapsuleGeometry(params.radius, params.height, 4, 8);
5720
5849
  break;
5721
5850
  }
5722
5851
  default:
@@ -5732,7 +5861,7 @@ function applyShadowFlags(component) {
5732
5861
  return;
5733
5862
  }
5734
5863
  component.object.traverse((child) => {
5735
- if (child instanceof THREE33__namespace.Mesh) {
5864
+ if (child instanceof THREE34__namespace.Mesh) {
5736
5865
  child.castShadow = component.castShadow;
5737
5866
  child.receiveShadow = component.receiveShadow;
5738
5867
  }
@@ -5785,6 +5914,125 @@ var _MeshGeometrySystem = class _MeshGeometrySystem {
5785
5914
  };
5786
5915
  __name(_MeshGeometrySystem, "MeshGeometrySystem");
5787
5916
  var MeshGeometrySystem = _MeshGeometrySystem;
5917
+ function buildGeometry(component) {
5918
+ const p = component.getSanitizedParameters();
5919
+ switch (component.meshKind) {
5920
+ case "cube": {
5921
+ const params = p;
5922
+ return new THREE34__namespace.BoxGeometry(params.width, params.height, params.depth);
5923
+ }
5924
+ case "plane": {
5925
+ const params = p;
5926
+ return new THREE34__namespace.PlaneGeometry(params.width, params.height);
5927
+ }
5928
+ case "sphere": {
5929
+ const params = p;
5930
+ return new THREE34__namespace.SphereGeometry(params.radius, 24, 24);
5931
+ }
5932
+ case "cylinder": {
5933
+ const params = p;
5934
+ return new THREE34__namespace.CylinderGeometry(params.radius, params.radius, params.height, 20);
5935
+ }
5936
+ case "capsule": {
5937
+ const params = p;
5938
+ return new THREE34__namespace.CapsuleGeometry(params.radius, params.height, 4, 8);
5939
+ }
5940
+ }
5941
+ }
5942
+ __name(buildGeometry, "buildGeometry");
5943
+ var _position = new THREE34__namespace.Vector3();
5944
+ var _quaternion = new THREE34__namespace.Quaternion();
5945
+ var _euler = new THREE34__namespace.Euler();
5946
+ var _scale = new THREE34__namespace.Vector3();
5947
+ var _matrix = new THREE34__namespace.Matrix4();
5948
+ function instanceTransformToMatrix4(inst, out) {
5949
+ _position.set(inst.position.x, inst.position.y, inst.position.z);
5950
+ _euler.set(inst.rotation.x, inst.rotation.y, inst.rotation.z, "XYZ");
5951
+ _quaternion.setFromEuler(_euler);
5952
+ _scale.set(inst.scale.x, inst.scale.y, inst.scale.z);
5953
+ out.compose(_position, _quaternion, _scale);
5954
+ }
5955
+ __name(instanceTransformToMatrix4, "instanceTransformToMatrix4");
5956
+ var _InstancedMeshSystem = class _InstancedMeshSystem {
5957
+ constructor() {
5958
+ /** Signature tracking for geometry + instance count changes. */
5959
+ this.geometrySignatures = /* @__PURE__ */ new Map();
5960
+ }
5961
+ update(world) {
5962
+ const entityIds = world.query(InstancedMeshComponent);
5963
+ const alive = new Set(entityIds);
5964
+ for (const trackedId of this.geometrySignatures.keys()) {
5965
+ if (!alive.has(trackedId)) {
5966
+ this.geometrySignatures.delete(trackedId);
5967
+ }
5968
+ }
5969
+ for (const entityId of entityIds) {
5970
+ const comp = world.getComponent(
5971
+ entityId,
5972
+ InstancedMeshComponent
5973
+ );
5974
+ if (!comp) {
5975
+ continue;
5976
+ }
5977
+ let anchor = null;
5978
+ const objectRef = world.getComponent(entityId, Object3DRef);
5979
+ if (objectRef?.object) {
5980
+ anchor = objectRef.object;
5981
+ }
5982
+ if (!anchor) {
5983
+ continue;
5984
+ }
5985
+ const instanceCount = comp.instances.length;
5986
+ const geometrySignature = `${comp.meshKind}:${JSON.stringify(comp.meshParameters)}:${instanceCount}`;
5987
+ const needsRebuild = comp.instancedMesh === null || this.geometrySignatures.get(entityId) !== geometrySignature;
5988
+ if (needsRebuild) {
5989
+ if (comp.instancedMesh) {
5990
+ anchor.remove(comp.instancedMesh);
5991
+ comp.instancedMesh.geometry.dispose();
5992
+ if (Array.isArray(comp.instancedMesh.material)) {
5993
+ for (const m of comp.instancedMesh.material) {
5994
+ m.dispose();
5995
+ }
5996
+ } else {
5997
+ comp.instancedMesh.material.dispose();
5998
+ }
5999
+ comp.instancedMesh = null;
6000
+ }
6001
+ const count = Math.max(1, instanceCount);
6002
+ const geometry = buildGeometry(comp);
6003
+ const material = new THREE34__namespace.MeshStandardMaterial({ color: "#ffffff" });
6004
+ const instancedMesh = new THREE34__namespace.InstancedMesh(geometry, material, count);
6005
+ instancedMesh.castShadow = comp.castShadow;
6006
+ instancedMesh.receiveShadow = comp.receiveShadow;
6007
+ for (let i = 0; i < count; i++) {
6008
+ const inst = comp.instances[i] ?? {
6009
+ position: { x: 0, y: 0, z: 0 },
6010
+ rotation: { x: 0, y: 0, z: 0 },
6011
+ scale: { x: 1, y: 1, z: 1 }
6012
+ };
6013
+ instanceTransformToMatrix4(inst, _matrix);
6014
+ instancedMesh.setMatrixAt(i, _matrix);
6015
+ }
6016
+ instancedMesh.instanceMatrix.needsUpdate = true;
6017
+ anchor.add(instancedMesh);
6018
+ comp.instancedMesh = instancedMesh;
6019
+ this.geometrySignatures.set(entityId, geometrySignature);
6020
+ } else {
6021
+ const im = comp.instancedMesh;
6022
+ const count = comp.instances.length;
6023
+ for (let i = 0; i < count; i++) {
6024
+ instanceTransformToMatrix4(comp.instances[i], _matrix);
6025
+ im.setMatrixAt(i, _matrix);
6026
+ }
6027
+ im.instanceMatrix.needsUpdate = true;
6028
+ im.castShadow = comp.castShadow;
6029
+ im.receiveShadow = comp.receiveShadow;
6030
+ }
6031
+ }
6032
+ }
6033
+ };
6034
+ __name(_InstancedMeshSystem, "InstancedMeshSystem");
6035
+ var InstancedMeshSystem = _InstancedMeshSystem;
5788
6036
 
5789
6037
  // core/systems/RenderSystem.ts
5790
6038
  var _RenderSystem = class _RenderSystem {
@@ -5876,7 +6124,7 @@ var _Behaviour = class _Behaviour {
5876
6124
  if (!this.threeRef) {
5877
6125
  return null;
5878
6126
  }
5879
- const position = new THREE33__namespace.Vector3();
6127
+ const position = new THREE34__namespace.Vector3();
5880
6128
  this.threeRef.object.getWorldPosition(position);
5881
6129
  return position;
5882
6130
  }
@@ -5888,7 +6136,7 @@ var _Behaviour = class _Behaviour {
5888
6136
  if (!this.threeRef) {
5889
6137
  return null;
5890
6138
  }
5891
- const target = new THREE33__namespace.Vector3();
6139
+ const target = new THREE34__namespace.Vector3();
5892
6140
  this.threeRef.object.getWorldDirection(target);
5893
6141
  return target;
5894
6142
  }
@@ -5950,7 +6198,7 @@ var _Behaviour = class _Behaviour {
5950
6198
  if (!this.threeRef) {
5951
6199
  return;
5952
6200
  }
5953
- const rotation = new THREE33__namespace.Quaternion();
6201
+ const rotation = new THREE34__namespace.Quaternion();
5954
6202
  this.threeRef.object.getWorldQuaternion(rotation);
5955
6203
  rotation.slerp(targetRotation, alpha);
5956
6204
  this.transform.setRotation(rotation);
@@ -5967,7 +6215,7 @@ var _Behaviour = class _Behaviour {
5967
6215
  return;
5968
6216
  }
5969
6217
  const clone = this.threeRef.object.clone();
5970
- const rotation = new THREE33__namespace.Quaternion();
6218
+ const rotation = new THREE34__namespace.Quaternion();
5971
6219
  clone.lookAt(targetPosition);
5972
6220
  clone.getWorldQuaternion(rotation);
5973
6221
  this.transform.setRotation(rotation);
@@ -6268,8 +6516,8 @@ var _ScriptBehaviourSystem = class _ScriptBehaviourSystem {
6268
6516
  }, "onPointerUp");
6269
6517
  this.moduleLoader = moduleLoader ?? defaultModuleLoader;
6270
6518
  this.selectionCtx = selectionContext ?? null;
6271
- this.raycaster = new THREE33__namespace.Raycaster();
6272
- this.ndcPointer = new THREE33__namespace.Vector2();
6519
+ this.raycaster = new THREE34__namespace.Raycaster();
6520
+ this.ndcPointer = new THREE34__namespace.Vector2();
6273
6521
  if (this.selectionCtx) {
6274
6522
  this.selectionCtx.domElement.addEventListener("pointerdown", this.onPointerDown);
6275
6523
  this.selectionCtx.domElement.addEventListener("pointerup", this.onPointerUp);
@@ -6667,7 +6915,7 @@ var _AudioSystem = class _AudioSystem {
6667
6915
  if (!prev || prev.volume !== opts.volume) {
6668
6916
  sound.setVolume(opts.volume);
6669
6917
  }
6670
- if (opts.positional && sound instanceof THREE33__namespace.PositionalAudio) {
6918
+ if (opts.positional && sound instanceof THREE34__namespace.PositionalAudio) {
6671
6919
  if (!prev || prev.refDistance !== opts.refDistance) {
6672
6920
  sound.setRefDistance(opts.refDistance);
6673
6921
  }
@@ -6779,7 +7027,7 @@ var _VideoSystem = class _VideoSystem {
6779
7027
  component.object.scale.set(opts.width, opts.height, 1);
6780
7028
  }
6781
7029
  const material = component.material;
6782
- if (material instanceof THREE33__namespace.ShaderMaterial) {
7030
+ if (material instanceof THREE34__namespace.ShaderMaterial) {
6783
7031
  if (!prev || prev.backgroundColor !== opts.backgroundColor) {
6784
7032
  material.uniforms.keyColor.value.set(opts.backgroundColor);
6785
7033
  }
@@ -6793,7 +7041,7 @@ var _VideoSystem = class _VideoSystem {
6793
7041
  material.uniforms.spill.value = opts.spill;
6794
7042
  }
6795
7043
  }
6796
- if (opts.positional && component.audioNode instanceof THREE33__namespace.PositionalAudio) {
7044
+ if (opts.positional && component.audioNode instanceof THREE34__namespace.PositionalAudio) {
6797
7045
  const posAudio = component.audioNode;
6798
7046
  if (!prev || prev.refDistance !== opts.refDistance) {
6799
7047
  posAudio.setRefDistance(opts.refDistance);
@@ -7152,6 +7400,7 @@ var _World = class _World {
7152
7400
  isEditor ?? false
7153
7401
  );
7154
7402
  const meshGeometrySystem = new MeshGeometrySystem();
7403
+ const instancedMeshSystem = new InstancedMeshSystem();
7155
7404
  const environmentSyncSystem = this.featureFlags.supportSkybox ? new EnvironmentSyncSystem(this.scene) : null;
7156
7405
  const postprocessingSyncSystem = this.featureFlags.supportPostprocessing ? new PostprocessingSyncSystem(this.renderer, this.scene, this.camera) : null;
7157
7406
  const lightSyncSystem = new LightSyncSystem();
@@ -7174,7 +7423,8 @@ var _World = class _World {
7174
7423
  this.inputSystem = null;
7175
7424
  const coreSystems = [
7176
7425
  objectManagementSystem,
7177
- meshGeometrySystem
7426
+ meshGeometrySystem,
7427
+ instancedMeshSystem
7178
7428
  ];
7179
7429
  if (environmentSyncSystem) {
7180
7430
  coreSystems.push(environmentSyncSystem);
@@ -7387,8 +7637,8 @@ var _World = class _World {
7387
7637
  * ```
7388
7638
  */
7389
7639
  raycast(origin, direction, near = 0, far = Infinity) {
7390
- const rayOrigin = new THREE33__namespace.Vector3(origin.x, origin.y, origin.z);
7391
- const rayDirection = new THREE33__namespace.Vector3(
7640
+ const rayOrigin = new THREE34__namespace.Vector3(origin.x, origin.y, origin.z);
7641
+ const rayDirection = new THREE34__namespace.Vector3(
7392
7642
  direction.x,
7393
7643
  direction.y,
7394
7644
  direction.z
@@ -7397,7 +7647,7 @@ var _World = class _World {
7397
7647
  return [];
7398
7648
  }
7399
7649
  rayDirection.normalize();
7400
- const raycaster = new THREE33__namespace.Raycaster(rayOrigin, rayDirection, near, far);
7650
+ const raycaster = new THREE34__namespace.Raycaster(rayOrigin, rayDirection, near, far);
7401
7651
  const intersections = raycaster.intersectObjects(
7402
7652
  this.scene.children,
7403
7653
  true
@@ -7431,14 +7681,14 @@ var _World = class _World {
7431
7681
  if (!sourceObject) {
7432
7682
  return [];
7433
7683
  }
7434
- const rayOrigin = new THREE33__namespace.Vector3();
7435
- const rayDirection = new THREE33__namespace.Vector3();
7684
+ const rayOrigin = new THREE34__namespace.Vector3();
7685
+ const rayDirection = new THREE34__namespace.Vector3();
7436
7686
  sourceObject.getWorldPosition(rayOrigin);
7437
7687
  sourceObject.getWorldDirection(rayDirection);
7438
7688
  if (rayDirection.lengthSq() === 0) {
7439
7689
  return [];
7440
7690
  }
7441
- const raycaster = new THREE33__namespace.Raycaster(rayOrigin, rayDirection, near, far);
7691
+ const raycaster = new THREE34__namespace.Raycaster(rayOrigin, rayDirection, near, far);
7442
7692
  const intersections = raycaster.intersectObjects(
7443
7693
  this.scene.children,
7444
7694
  true
@@ -7731,7 +7981,8 @@ function buildComponentValueMaps(snapshot) {
7731
7981
  physicsValues: readByComponent(snapshot.components, "PhysicsComponent"),
7732
7982
  animationValues: readByComponent(snapshot.components, "AnimationComponent"),
7733
7983
  imageTargetAnchorValues: readByComponent(snapshot.components, "ImageTargetAnchor"),
7734
- scriptValues: readByComponent(snapshot.components, "ScriptComponent")
7984
+ scriptValues: readByComponent(snapshot.components, "ScriptComponent"),
7985
+ instancedMeshValues: readByComponent(snapshot.components, "InstancedMeshComponent")
7735
7986
  };
7736
7987
  }
7737
7988
  __name(buildComponentValueMaps, "buildComponentValueMaps");
@@ -8328,6 +8579,29 @@ function restoreComponentState(world, objectManagementSystem, targetEntityId, so
8328
8579
  sourceAnimation
8329
8580
  );
8330
8581
  }
8582
+ const sourceInstancedMesh = asRecord3(values.instancedMeshValues.get(sourceEntityId));
8583
+ if (sourceInstancedMesh) {
8584
+ const imComponent = world.getComponent(targetEntityId, InstancedMeshComponent);
8585
+ if (imComponent) {
8586
+ if (typeof sourceInstancedMesh.meshKind === "string") {
8587
+ imComponent.meshKind = sourceInstancedMesh.meshKind;
8588
+ }
8589
+ const parameters = asRecord3(sourceInstancedMesh.meshParameters);
8590
+ if (parameters) {
8591
+ imComponent.meshParameters = parameters;
8592
+ }
8593
+ if (typeof sourceInstancedMesh.castShadow === "boolean") {
8594
+ imComponent.castShadow = sourceInstancedMesh.castShadow;
8595
+ }
8596
+ if (typeof sourceInstancedMesh.receiveShadow === "boolean") {
8597
+ imComponent.receiveShadow = sourceInstancedMesh.receiveShadow;
8598
+ }
8599
+ if (Array.isArray(sourceInstancedMesh.instances)) {
8600
+ imComponent.instances = sourceInstancedMesh.instances;
8601
+ }
8602
+ imComponent.instancedMesh = null;
8603
+ }
8604
+ }
8331
8605
  }
8332
8606
  __name(restoreComponentState, "restoreComponentState");
8333
8607
 
@@ -8350,7 +8624,8 @@ var HYDRATABLE_ENTITY_KINDS = /* @__PURE__ */ new Set([
8350
8624
  "directionalLight",
8351
8625
  "pointLight",
8352
8626
  "spotLight",
8353
- "areaLight"
8627
+ "areaLight",
8628
+ "instancedMesh"
8354
8629
  ]);
8355
8630
 
8356
8631
  // core/hydration/hydrateWorld.ts
@@ -8427,6 +8702,18 @@ function buildEntityCreationPayload(sourceEntityId, kind, componentValues) {
8427
8702
  };
8428
8703
  }
8429
8704
  }
8705
+ if (kind === "instancedMesh") {
8706
+ const im = asRecord3(componentValues.instancedMeshValues.get(sourceEntityId));
8707
+ if (im) {
8708
+ payload.options = {
8709
+ meshKind: typeof im.meshKind === "string" ? im.meshKind : "cube",
8710
+ meshParameters: asRecord3(im.meshParameters) ?? void 0,
8711
+ castShadow: typeof im.castShadow === "boolean" ? im.castShadow : false,
8712
+ receiveShadow: typeof im.receiveShadow === "boolean" ? im.receiveShadow : false,
8713
+ instances: Array.isArray(im.instances) ? im.instances : void 0
8714
+ };
8715
+ }
8716
+ }
8430
8717
  return payload;
8431
8718
  }
8432
8719
  __name(buildEntityCreationPayload, "buildEntityCreationPayload");
@@ -8549,6 +8836,7 @@ exports.CoreComponents = components_exports;
8549
8836
  exports.EnvironmentSyncSystem = EnvironmentSyncSystem;
8550
8837
  exports.HYDRATABLE_ENTITY_KINDS = HYDRATABLE_ENTITY_KINDS;
8551
8838
  exports.InputSystem = InputSystem;
8839
+ exports.InstancedMeshSystem = InstancedMeshSystem;
8552
8840
  exports.KeyboardKeys = KeyboardKeys;
8553
8841
  exports.LightSyncSystem = LightSyncSystem;
8554
8842
  exports.MaterialSyncSystem = MaterialSyncSystem;
@@ -8570,6 +8858,7 @@ exports.createEnvironmentComponent = createEnvironmentComponent;
8570
8858
  exports.createImageComponent = createImageComponent;
8571
8859
  exports.createImageTargetAnchorComponent = createImageTargetAnchorComponent;
8572
8860
  exports.createImageTargetComponent = createImageTargetComponent;
8861
+ exports.createInstancedMeshComponent = createInstancedMeshComponent;
8573
8862
  exports.createLightComponent = createLightComponent;
8574
8863
  exports.createMaterialComponent = createMaterialComponent;
8575
8864
  exports.createMeshComponent = createMeshComponent;