@relu-interactives/spatial-ecs 0.2.4 → 0.2.6

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-BWhbvVPg.d.ts → Video-B-qMljTn.d.ts} +147 -75
  4. package/dist/{Video-D2H5H-K3.d.cts → Video-Dj4KBqQ1.d.cts} +147 -75
  5. package/dist/{chunk-XWIEEJ7Z.js → chunk-EIC5B3A7.js} +128 -82
  6. package/dist/chunk-EIC5B3A7.js.map +1 -0
  7. package/dist/{chunk-AYEF3X2P.js → chunk-FDWNCXU3.js} +3 -3
  8. package/dist/chunk-FDWNCXU3.js.map +1 -0
  9. package/dist/{chunk-NFDTIYR4.js → chunk-G2DUXNTQ.js} +18 -2
  10. package/dist/chunk-G2DUXNTQ.js.map +1 -0
  11. package/dist/{chunk-P2YDX5DB.js → chunk-NRSUYDBA.js} +275 -5
  12. package/dist/chunk-NRSUYDBA.js.map +1 -0
  13. package/dist/{chunk-MAWBTMCG.js → chunk-R5D5PWXV.js} +160 -88
  14. package/dist/chunk-R5D5PWXV.js.map +1 -0
  15. package/dist/components/index.cjs +165 -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 +221 -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-B12sx9yF.d.cts} +8 -3
  26. package/dist/{index-Dm6zF1MY.d.ts → index-Cf-PaKyN.d.ts} +8 -3
  27. package/dist/index.cjs +627 -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 +54 -12
  32. package/dist/index.js.map +1 -1
  33. package/dist/systems/index.cjs +403 -63
  34. package/dist/systems/index.cjs.map +1 -1
  35. package/dist/systems/index.d.cts +27 -3
  36. package/dist/systems/index.d.ts +27 -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 +16 -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,22 @@ 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
+ modelPath: typeof objectValue.modelPath === "string" ? objectValue.modelPath : "",
163
+ meshParameters: normalizeDebugValue(objectValue.meshParameters, imCtx),
164
+ castShadow: Boolean(objectValue.castShadow),
165
+ receiveShadow: Boolean(objectValue.receiveShadow),
166
+ instances: normalizeDebugValue(objectValue.instances, imCtx)
167
+ };
168
+ }
153
169
  if (constructorName === "PhysicsComponent") {
154
170
  return {
155
171
  __type: "PhysicsComponent",
@@ -558,14 +574,14 @@ var _AnimationComponent = class _AnimationComponent extends Component {
558
574
  return;
559
575
  }
560
576
  this.importedClips = clips.map((entry) => {
561
- if (entry instanceof THREE33__namespace.AnimationClip) {
577
+ if (entry instanceof THREE34__namespace.AnimationClip) {
562
578
  return { clip: entry, sourceUrl: null };
563
579
  }
564
580
  if (!entry || typeof entry !== "object") {
565
581
  return null;
566
582
  }
567
583
  const candidate = entry;
568
- if (!(candidate.clip instanceof THREE33__namespace.AnimationClip)) {
584
+ if (!(candidate.clip instanceof THREE34__namespace.AnimationClip)) {
569
585
  return null;
570
586
  }
571
587
  return {
@@ -773,11 +789,11 @@ function normalizeDistanceModel(distanceModel) {
773
789
  }
774
790
  __name(normalizeDistanceModel, "normalizeDistanceModel");
775
791
  function createConfiguredAudio(listener, options) {
776
- const sound = options.positional ? new THREE33__namespace.PositionalAudio(listener) : new THREE33__namespace.Audio(listener);
792
+ const sound = options.positional ? new THREE34__namespace.PositionalAudio(listener) : new THREE34__namespace.Audio(listener);
777
793
  sound.setLoop(options.loop);
778
794
  sound.setVolume(options.volume);
779
795
  sound.setPlaybackRate(options.pitch);
780
- if (sound instanceof THREE33__namespace.PositionalAudio) {
796
+ if (sound instanceof THREE34__namespace.PositionalAudio) {
781
797
  sound.setRefDistance(options.refDistance);
782
798
  sound.setDistanceModel(normalizeDistanceModel(options.distanceModel));
783
799
  sound.setRolloffFactor(options.rolloffFactor);
@@ -787,16 +803,16 @@ function createConfiguredAudio(listener, options) {
787
803
  __name(createConfiguredAudio, "createConfiguredAudio");
788
804
  function createAudioEditorHelper() {
789
805
  if (typeof document === "undefined") {
790
- const geometry = new THREE33__namespace.EdgesGeometry(
791
- new THREE33__namespace.OctahedronGeometry(0.22, 0)
806
+ const geometry = new THREE34__namespace.EdgesGeometry(
807
+ new THREE34__namespace.OctahedronGeometry(0.22, 0)
792
808
  );
793
- const material2 = new THREE33__namespace.LineBasicMaterial({
809
+ const material2 = new THREE34__namespace.LineBasicMaterial({
794
810
  color: "#8bc8ff",
795
811
  transparent: true,
796
812
  opacity: 0.95,
797
813
  depthTest: false
798
814
  });
799
- const fallback = new THREE33__namespace.LineSegments(geometry, material2);
815
+ const fallback = new THREE34__namespace.LineSegments(geometry, material2);
800
816
  fallback.renderOrder = 10;
801
817
  fallback.userData.ecsHelper = true;
802
818
  fallback.visible = false;
@@ -808,7 +824,7 @@ function createAudioEditorHelper() {
808
824
  canvas.height = size;
809
825
  const ctx = canvas.getContext("2d");
810
826
  if (!ctx) {
811
- return new THREE33__namespace.Object3D();
827
+ return new THREE34__namespace.Object3D();
812
828
  }
813
829
  ctx.clearRect(0, 0, size, size);
814
830
  ctx.fillStyle = "rgba(27, 35, 52, 0.9)";
@@ -839,14 +855,14 @@ function createAudioEditorHelper() {
839
855
  ctx.beginPath();
840
856
  ctx.arc(56, 48, 16, -0.8, 0.8);
841
857
  ctx.stroke();
842
- const texture = new THREE33__namespace.CanvasTexture(canvas);
858
+ const texture = new THREE34__namespace.CanvasTexture(canvas);
843
859
  texture.needsUpdate = true;
844
- const material = new THREE33__namespace.SpriteMaterial({
860
+ const material = new THREE34__namespace.SpriteMaterial({
845
861
  map: texture,
846
862
  transparent: true,
847
863
  depthTest: false
848
864
  });
849
- const helper = new THREE33__namespace.Sprite(material);
865
+ const helper = new THREE34__namespace.Sprite(material);
850
866
  helper.scale.set(0.68, 0.68, 0.68);
851
867
  helper.renderOrder = 10;
852
868
  helper.userData.ecsHelper = true;
@@ -880,7 +896,7 @@ var DEFAULT_ORTHO_TOP = 5;
880
896
  var DEFAULT_ORTHO_BOTTOM = -5;
881
897
  var DEFAULT_ZOOM = 1;
882
898
  function inferProjection(camera) {
883
- if (camera instanceof THREE33__namespace.OrthographicCamera) {
899
+ if (camera instanceof THREE34__namespace.OrthographicCamera) {
884
900
  return "orthographic";
885
901
  }
886
902
  return "perspective";
@@ -901,7 +917,7 @@ function readCameraFar(camera) {
901
917
  }
902
918
  __name(readCameraFar, "readCameraFar");
903
919
  function inferFov(camera) {
904
- if (camera instanceof THREE33__namespace.PerspectiveCamera && Number.isFinite(camera.fov)) {
920
+ if (camera instanceof THREE34__namespace.PerspectiveCamera && Number.isFinite(camera.fov)) {
905
921
  return camera.fov;
906
922
  }
907
923
  return DEFAULT_FOV;
@@ -924,28 +940,28 @@ function inferFar(camera) {
924
940
  }
925
941
  __name(inferFar, "inferFar");
926
942
  function inferOrthoLeft(camera) {
927
- if (camera instanceof THREE33__namespace.OrthographicCamera && Number.isFinite(camera.left)) {
943
+ if (camera instanceof THREE34__namespace.OrthographicCamera && Number.isFinite(camera.left)) {
928
944
  return camera.left;
929
945
  }
930
946
  return DEFAULT_ORTHO_LEFT;
931
947
  }
932
948
  __name(inferOrthoLeft, "inferOrthoLeft");
933
949
  function inferOrthoRight(camera) {
934
- if (camera instanceof THREE33__namespace.OrthographicCamera && Number.isFinite(camera.right)) {
950
+ if (camera instanceof THREE34__namespace.OrthographicCamera && Number.isFinite(camera.right)) {
935
951
  return camera.right;
936
952
  }
937
953
  return DEFAULT_ORTHO_RIGHT;
938
954
  }
939
955
  __name(inferOrthoRight, "inferOrthoRight");
940
956
  function inferOrthoTop(camera) {
941
- if (camera instanceof THREE33__namespace.OrthographicCamera && Number.isFinite(camera.top)) {
957
+ if (camera instanceof THREE34__namespace.OrthographicCamera && Number.isFinite(camera.top)) {
942
958
  return camera.top;
943
959
  }
944
960
  return DEFAULT_ORTHO_TOP;
945
961
  }
946
962
  __name(inferOrthoTop, "inferOrthoTop");
947
963
  function inferOrthoBottom(camera) {
948
- if (camera instanceof THREE33__namespace.OrthographicCamera && Number.isFinite(camera.bottom)) {
964
+ if (camera instanceof THREE34__namespace.OrthographicCamera && Number.isFinite(camera.bottom)) {
949
965
  return camera.bottom;
950
966
  }
951
967
  return DEFAULT_ORTHO_BOTTOM;
@@ -961,7 +977,7 @@ __name(inferZoom, "inferZoom");
961
977
  var _CameraComponent = class _CameraComponent extends Component {
962
978
  constructor(payload = {}) {
963
979
  super();
964
- this.camera = payload.camera ?? new THREE33__namespace.PerspectiveCamera();
980
+ this.camera = payload.camera ?? new THREE34__namespace.PerspectiveCamera();
965
981
  this.type = payload.type ?? "3d";
966
982
  this.isDefault = typeof payload.isDefault === "boolean" ? payload.isDefault : false;
967
983
  this.projection = payload.projection ?? inferProjection(payload.camera);
@@ -992,7 +1008,7 @@ var Object3DRef = _Object3DRef;
992
1008
  // core/factories/components/CameraFactory.ts
993
1009
  function createCameraComponent(world, entityId, payload = {}) {
994
1010
  const object = world.getComponent(entityId, Object3DRef)?.object;
995
- const objectCamera = object instanceof THREE33__namespace.Camera ? object : void 0;
1011
+ const objectCamera = object instanceof THREE34__namespace.Camera ? object : void 0;
996
1012
  const component = new CameraComponent({
997
1013
  ...payload,
998
1014
  camera: payload.camera ?? objectCamera
@@ -1432,15 +1448,15 @@ function createValueState(light) {
1432
1448
  castShadow: light.castShadow ?? false,
1433
1449
  frustumCulling: light.frustumCulled
1434
1450
  };
1435
- if (light instanceof THREE33__namespace.PointLight) {
1451
+ if (light instanceof THREE34__namespace.PointLight) {
1436
1452
  base.distance = light.distance;
1437
1453
  base.decay = light.decay;
1438
- } else if (light instanceof THREE33__namespace.SpotLight) {
1454
+ } else if (light instanceof THREE34__namespace.SpotLight) {
1439
1455
  base.distance = light.distance;
1440
1456
  base.decay = light.decay;
1441
1457
  base.angle = light.angle;
1442
1458
  base.penumbra = light.penumbra;
1443
- } else if (light instanceof THREE33__namespace.RectAreaLight) {
1459
+ } else if (light instanceof THREE34__namespace.RectAreaLight) {
1444
1460
  base.width = light.width;
1445
1461
  base.height = light.height;
1446
1462
  }
@@ -1483,13 +1499,13 @@ function toHexColor2(value, fallback) {
1483
1499
  }
1484
1500
  __name(toHexColor2, "toHexColor");
1485
1501
  function getMaterialType(material) {
1486
- if (material instanceof THREE33__namespace.MeshPhysicalMaterial) {
1502
+ if (material instanceof THREE34__namespace.MeshPhysicalMaterial) {
1487
1503
  return "physical";
1488
1504
  }
1489
- if (material instanceof THREE33__namespace.MeshPhongMaterial) {
1505
+ if (material instanceof THREE34__namespace.MeshPhongMaterial) {
1490
1506
  return "phong";
1491
1507
  }
1492
- if (material instanceof THREE33__namespace.MeshBasicMaterial) {
1508
+ if (material instanceof THREE34__namespace.MeshBasicMaterial) {
1493
1509
  return "basic";
1494
1510
  }
1495
1511
  return "standard";
@@ -1508,8 +1524,8 @@ function createMaterialValue(material) {
1508
1524
  opacity: typeof materialRecord.opacity === "number" ? materialRecord.opacity : 1,
1509
1525
  emissive: toHexColor2(materialRecord.emissive, "#000000"),
1510
1526
  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,
1527
+ side: typeof materialRecord.side === "number" ? materialRecord.side : THREE34__namespace.FrontSide,
1528
+ blending: typeof materialRecord.blending === "number" ? materialRecord.blending : THREE34__namespace.NormalBlending,
1513
1529
  depthTest: materialRecord.depthTest !== false,
1514
1530
  depthWrite: materialRecord.depthWrite !== false,
1515
1531
  wireframe: Boolean(materialRecord.wireframe),
@@ -1525,7 +1541,7 @@ function createMaterialValue(material) {
1525
1541
  displacementMap: materialRecord.displacementMap?.image?.src,
1526
1542
  lightMap: materialRecord.lightMap?.image?.src,
1527
1543
  envMap: materialRecord.envMap?.image?.src,
1528
- textureFiltering: map?.magFilter === THREE33__namespace.NearestFilter ? "sharp" : "smooth",
1544
+ textureFiltering: map?.magFilter === THREE34__namespace.NearestFilter ? "sharp" : "smooth",
1529
1545
  useMipmaps: map?.generateMipmaps !== false
1530
1546
  };
1531
1547
  }
@@ -1540,8 +1556,8 @@ function defaultMaterialValue() {
1540
1556
  opacity: 1,
1541
1557
  emissive: "#000000",
1542
1558
  emissiveIntensity: 0,
1543
- side: THREE33__namespace.FrontSide,
1544
- blending: THREE33__namespace.NormalBlending,
1559
+ side: THREE34__namespace.FrontSide,
1560
+ blending: THREE34__namespace.NormalBlending,
1545
1561
  depthTest: true,
1546
1562
  depthWrite: true,
1547
1563
  wireframe: false,
@@ -2139,14 +2155,14 @@ var _TransformComponent = class _TransformComponent extends Component {
2139
2155
  z: scale.z ?? 1
2140
2156
  };
2141
2157
  }
2142
- toPositionVector3(target = new THREE33.Vector3()) {
2158
+ toPositionVector3(target = new THREE34.Vector3()) {
2143
2159
  return target.set(this.position.x, this.position.y, this.position.z);
2144
2160
  }
2145
- toRotationEuler(target = new THREE33.Euler(), order = "XYZ") {
2161
+ toRotationEuler(target = new THREE34.Euler(), order = "XYZ") {
2146
2162
  return target.set(this.rotation.x, this.rotation.y, this.rotation.z, order);
2147
2163
  }
2148
- toRotationQuaternion(target = new THREE33.Quaternion(), order = "XYZ") {
2149
- const euler = new THREE33.Euler(
2164
+ toRotationQuaternion(target = new THREE34.Quaternion(), order = "XYZ") {
2165
+ const euler = new THREE34.Euler(
2150
2166
  this.rotation.x,
2151
2167
  this.rotation.y,
2152
2168
  this.rotation.z,
@@ -2154,7 +2170,7 @@ var _TransformComponent = class _TransformComponent extends Component {
2154
2170
  );
2155
2171
  return target.setFromEuler(euler);
2156
2172
  }
2157
- toScaleVector3(target = new THREE33.Vector3()) {
2173
+ toScaleVector3(target = new THREE34.Vector3()) {
2158
2174
  return target.set(this.scale.x, this.scale.y, this.scale.z);
2159
2175
  }
2160
2176
  setPosition(input) {
@@ -2172,8 +2188,8 @@ var _TransformComponent = class _TransformComponent extends Component {
2172
2188
  return this;
2173
2189
  }
2174
2190
  setRotation(input, order = "XYZ") {
2175
- if (input instanceof THREE33.Quaternion) {
2176
- const euler = new THREE33.Euler().setFromQuaternion(input, order);
2191
+ if (input instanceof THREE34.Quaternion) {
2192
+ const euler = new THREE34.Euler().setFromQuaternion(input, order);
2177
2193
  this.rotation.x = euler.x;
2178
2194
  this.rotation.y = euler.y;
2179
2195
  this.rotation.z = euler.z;
@@ -2197,6 +2213,83 @@ function createTransformComponent(world, entityId, ...args) {
2197
2213
  }
2198
2214
  __name(createTransformComponent, "createTransformComponent");
2199
2215
 
2216
+ // core/components/InstancedMesh.ts
2217
+ var DEFAULT_INSTANCE_TRANSFORM = {
2218
+ position: { x: 0, y: 0, z: 0 },
2219
+ rotation: { x: 0, y: 0, z: 0 },
2220
+ scale: { x: 1, y: 1, z: 1 }
2221
+ };
2222
+ var DEFAULT_INSTANCED_MESH_PARAMETERS = {
2223
+ capsule: DEFAULT_MESH_GEOMETRY_PARAMETERS.capsule,
2224
+ cube: DEFAULT_MESH_GEOMETRY_PARAMETERS.cube,
2225
+ cylinder: DEFAULT_MESH_GEOMETRY_PARAMETERS.cylinder,
2226
+ model: DEFAULT_MESH_GEOMETRY_PARAMETERS.cube,
2227
+ plane: DEFAULT_MESH_GEOMETRY_PARAMETERS.plane,
2228
+ sphere: DEFAULT_MESH_GEOMETRY_PARAMETERS.sphere
2229
+ };
2230
+ var _InstancedMeshComponent = class _InstancedMeshComponent extends Component {
2231
+ constructor(meshKind = "cube", meshParameters, options) {
2232
+ super();
2233
+ this.meshKind = meshKind;
2234
+ this.modelPath = options?.modelPath ?? "";
2235
+ this.meshParameters = {
2236
+ ...DEFAULT_INSTANCED_MESH_PARAMETERS[meshKind],
2237
+ ...meshParameters ?? {}
2238
+ };
2239
+ this.castShadow = options?.castShadow ?? false;
2240
+ this.receiveShadow = options?.receiveShadow ?? false;
2241
+ this.instances = options?.instances && options.instances.length > 0 ? options.instances : [{ ...DEFAULT_INSTANCE_TRANSFORM }];
2242
+ this.instancedMesh = null;
2243
+ }
2244
+ /** Sanitize and return a copy of the current mesh parameters with valid values. */
2245
+ getSanitizedParameters() {
2246
+ const MIN_DIM = 0.01;
2247
+ const MIN_RAD = 1e-3;
2248
+ const sanitize = /* @__PURE__ */ __name((v, min) => Number.isFinite(v) ? Math.max(min, v) : min, "sanitize");
2249
+ switch (this.meshKind) {
2250
+ case "cube": {
2251
+ const p = this.meshParameters;
2252
+ return {
2253
+ width: sanitize(p.width, MIN_DIM),
2254
+ height: sanitize(p.height, MIN_DIM),
2255
+ depth: sanitize(p.depth, MIN_DIM)
2256
+ };
2257
+ }
2258
+ case "plane": {
2259
+ const p = this.meshParameters;
2260
+ return {
2261
+ width: sanitize(p.width, MIN_DIM),
2262
+ height: sanitize(p.height, MIN_DIM)
2263
+ };
2264
+ }
2265
+ case "sphere": {
2266
+ const p = this.meshParameters;
2267
+ return { radius: sanitize(p.radius, MIN_RAD) };
2268
+ }
2269
+ case "cylinder":
2270
+ case "capsule": {
2271
+ const p = this.meshParameters;
2272
+ return {
2273
+ radius: sanitize(p.radius, MIN_RAD),
2274
+ height: sanitize(p.height, MIN_DIM)
2275
+ };
2276
+ }
2277
+ case "model":
2278
+ return DEFAULT_MESH_GEOMETRY_PARAMETERS.cube;
2279
+ }
2280
+ }
2281
+ };
2282
+ __name(_InstancedMeshComponent, "InstancedMeshComponent");
2283
+ var InstancedMeshComponent = _InstancedMeshComponent;
2284
+
2285
+ // core/factories/components/InstancedMeshComponentFactory.ts
2286
+ function createInstancedMeshComponent(world, entityId, meshKind, meshParameters, options) {
2287
+ const component = new InstancedMeshComponent(meshKind, meshParameters, options);
2288
+ world.addComponent(entityId, component);
2289
+ return component;
2290
+ }
2291
+ __name(createInstancedMeshComponent, "createInstancedMeshComponent");
2292
+
2200
2293
  // core/components/Video.ts
2201
2294
  var DEFAULT_VIDEO_OPTIONS = {
2202
2295
  autoplay: false,
@@ -2323,6 +2416,7 @@ function registerDefaultComponentFactories(objectManagementSystem) {
2323
2416
  objectManagementSystem.registerComponentFactory("sprite", createSpriteComponent);
2324
2417
  objectManagementSystem.registerComponentFactory("transform", createTransformComponent);
2325
2418
  objectManagementSystem.registerComponentFactory("video", createVideoComponent);
2419
+ objectManagementSystem.registerComponentFactory("instancedMesh", createInstancedMeshComponent);
2326
2420
  }
2327
2421
  __name(registerDefaultComponentFactories, "registerDefaultComponentFactories");
2328
2422
  function createTransform(input) {
@@ -2360,10 +2454,10 @@ var _ObjectManagementSystem = class _ObjectManagementSystem {
2360
2454
  }
2361
2455
  getOrCreateAudioListener() {
2362
2456
  const existing = this.camera.userData.ecsAudioListener;
2363
- if (existing instanceof THREE33__namespace.AudioListener) {
2457
+ if (existing instanceof THREE34__namespace.AudioListener) {
2364
2458
  return existing;
2365
2459
  }
2366
- const listener = new THREE33__namespace.AudioListener();
2460
+ const listener = new THREE34__namespace.AudioListener();
2367
2461
  this.camera.add(listener);
2368
2462
  this.camera.userData.ecsAudioListener = listener;
2369
2463
  return listener;
@@ -2537,10 +2631,10 @@ __name(createBaseEntity, "createBaseEntity");
2537
2631
  // core/factories/objects/AudioFactory.ts
2538
2632
  function getOrCreateListener(camera) {
2539
2633
  const existing = camera.userData.ecsAudioListener;
2540
- if (existing instanceof THREE33__namespace.AudioListener) {
2634
+ if (existing instanceof THREE34__namespace.AudioListener) {
2541
2635
  return existing;
2542
2636
  }
2543
- const listener = new THREE33__namespace.AudioListener();
2637
+ const listener = new THREE34__namespace.AudioListener();
2544
2638
  camera.add(listener);
2545
2639
  camera.userData.ecsAudioListener = listener;
2546
2640
  return listener;
@@ -2553,7 +2647,7 @@ function createAudio({
2553
2647
  payload,
2554
2648
  isEditor
2555
2649
  }) {
2556
- const anchor = new THREE33__namespace.Object3D();
2650
+ const anchor = new THREE34__namespace.Object3D();
2557
2651
  const entityId = createBaseEntity(world, anchor, {
2558
2652
  label: payload.name ?? "Audio",
2559
2653
  entityType: "audio",
@@ -2575,7 +2669,7 @@ function createAudio({
2575
2669
  return entityId;
2576
2670
  }
2577
2671
  if (!isEditor) {
2578
- const loader = new THREE33__namespace.AudioLoader();
2672
+ const loader = new THREE34__namespace.AudioLoader();
2579
2673
  loader.load(
2580
2674
  audio.path,
2581
2675
  (buffer) => {
@@ -2650,7 +2744,7 @@ function applyCameraSettings(camera, options) {
2650
2744
  const near = typeof options.near === "number" ? options.near : DEFAULT_NEAR2;
2651
2745
  const far = typeof options.far === "number" ? options.far : DEFAULT_FAR2;
2652
2746
  const projection = options.projection;
2653
- if (camera instanceof THREE33__namespace.PerspectiveCamera) {
2747
+ if (camera instanceof THREE34__namespace.PerspectiveCamera) {
2654
2748
  if (!projection || projection === "perspective") {
2655
2749
  camera.fov = typeof options.fov === "number" ? options.fov : DEFAULT_FOV2;
2656
2750
  }
@@ -2660,7 +2754,7 @@ function applyCameraSettings(camera, options) {
2660
2754
  camera.updateProjectionMatrix();
2661
2755
  return;
2662
2756
  }
2663
- if (camera instanceof THREE33__namespace.OrthographicCamera) {
2757
+ if (camera instanceof THREE34__namespace.OrthographicCamera) {
2664
2758
  camera.left = typeof options.left === "number" ? options.left : -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
2665
2759
  camera.right = typeof options.right === "number" ? options.right : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
2666
2760
  camera.top = typeof options.top === "number" ? options.top : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
@@ -2681,7 +2775,7 @@ function createCameraObject(options) {
2681
2775
  const bottom = options.bottom ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
2682
2776
  const left = options.left ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
2683
2777
  const right = options.right ?? DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
2684
- const camera = new THREE33__namespace.OrthographicCamera(
2778
+ const camera = new THREE34__namespace.OrthographicCamera(
2685
2779
  left,
2686
2780
  right,
2687
2781
  top,
@@ -2693,7 +2787,7 @@ function createCameraObject(options) {
2693
2787
  camera.updateProjectionMatrix();
2694
2788
  return camera;
2695
2789
  }
2696
- return new THREE33__namespace.PerspectiveCamera(
2790
+ return new THREE34__namespace.PerspectiveCamera(
2697
2791
  options.fov ?? DEFAULT_FOV2,
2698
2792
  readViewportAspect(),
2699
2793
  near,
@@ -2711,7 +2805,7 @@ function createCamera({ world, scene, camera, payload, isEditor }) {
2711
2805
  transformInput: payload.transform
2712
2806
  });
2713
2807
  const objectRef = world.getComponent(entityId, Object3DRef);
2714
- if (objectRef?.object instanceof THREE33__namespace.Camera) {
2808
+ if (objectRef?.object instanceof THREE34__namespace.Camera) {
2715
2809
  objectRef.object.userData.entityId = entityId;
2716
2810
  }
2717
2811
  const componentOptions = {
@@ -2734,7 +2828,7 @@ function createCamera({ world, scene, camera, payload, isEditor }) {
2734
2828
  } else {
2735
2829
  applyCameraSettings(object, options);
2736
2830
  if (isEditor && component.isDefault) {
2737
- const helper = new THREE33__namespace.CameraHelper(object);
2831
+ const helper = new THREE34__namespace.CameraHelper(object);
2738
2832
  helper.onBeforeRender = () => {
2739
2833
  helper.update();
2740
2834
  };
@@ -2752,9 +2846,9 @@ function createCapsule({
2752
2846
  scene,
2753
2847
  payload
2754
2848
  }) {
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);
2849
+ const geometry = new THREE34__namespace.CapsuleGeometry(0.5, 1, 4, 8);
2850
+ const material = new THREE34__namespace.MeshStandardMaterial({ color: "#ffffff" });
2851
+ const mesh = new THREE34__namespace.Mesh(geometry, material);
2758
2852
  const entityId = createBaseEntity(world, mesh, {
2759
2853
  label: payload.name ?? "Capsule",
2760
2854
  entityType: "capsule",
@@ -2774,9 +2868,9 @@ function createCapsule({
2774
2868
  }
2775
2869
  __name(createCapsule, "createCapsule");
2776
2870
  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);
2871
+ const geometry = new THREE34__namespace.BoxGeometry(1, 1, 1);
2872
+ const material = new THREE34__namespace.MeshStandardMaterial({ color: "#ffffff" });
2873
+ const mesh = new THREE34__namespace.Mesh(geometry, material);
2780
2874
  const entityId = createBaseEntity(world, mesh, {
2781
2875
  label: payload.name ?? "Cube",
2782
2876
  entityType: "cube",
@@ -2801,9 +2895,9 @@ function createCylinder({
2801
2895
  scene,
2802
2896
  payload
2803
2897
  }) {
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);
2898
+ const geometry = new THREE34__namespace.CylinderGeometry(0.5, 0.5, 1, 20);
2899
+ const material = new THREE34__namespace.MeshStandardMaterial({ color: "#ffffff" });
2900
+ const mesh = new THREE34__namespace.Mesh(geometry, material);
2807
2901
  const entityId = createBaseEntity(world, mesh, {
2808
2902
  label: payload.name ?? "Cylinder",
2809
2903
  entityType: "cylinder",
@@ -2823,7 +2917,7 @@ function createCylinder({
2823
2917
  }
2824
2918
  __name(createCylinder, "createCylinder");
2825
2919
  function createEmpty({ world, scene, payload, isEditor }) {
2826
- const object = new THREE33__namespace.Group();
2920
+ const object = new THREE34__namespace.Group();
2827
2921
  const entityId = createBaseEntity(world, object, {
2828
2922
  label: payload.name ?? "Empty",
2829
2923
  entityType: "empty",
@@ -2834,7 +2928,7 @@ function createEmpty({ world, scene, payload, isEditor }) {
2834
2928
  }
2835
2929
  __name(createEmpty, "createEmpty");
2836
2930
  function createImage({ world, scene, payload }) {
2837
- const anchor = new THREE33__namespace.Object3D();
2931
+ const anchor = new THREE34__namespace.Object3D();
2838
2932
  const imagePath = payload.path ?? "";
2839
2933
  const entityId = createBaseEntity(world, anchor, {
2840
2934
  label: payload.name ?? "Image",
@@ -2847,7 +2941,7 @@ function createImage({ world, scene, payload }) {
2847
2941
  if (!imagePath) {
2848
2942
  return entityId;
2849
2943
  }
2850
- const loader = new THREE33__namespace.TextureLoader();
2944
+ const loader = new THREE34__namespace.TextureLoader();
2851
2945
  loader.load(
2852
2946
  imagePath,
2853
2947
  (texture) => {
@@ -2855,13 +2949,13 @@ function createImage({ world, scene, payload }) {
2855
2949
  texture.dispose();
2856
2950
  return;
2857
2951
  }
2858
- const material = new THREE33__namespace.MeshBasicMaterial({
2952
+ const material = new THREE34__namespace.MeshBasicMaterial({
2859
2953
  map: texture,
2860
2954
  transparent: true,
2861
- side: THREE33__namespace.DoubleSide
2955
+ side: THREE34__namespace.DoubleSide
2862
2956
  });
2863
- const geometry = new THREE33__namespace.PlaneGeometry(1, 1);
2864
- const plane = new THREE33__namespace.Mesh(geometry, material);
2957
+ const geometry = new THREE34__namespace.PlaneGeometry(1, 1);
2958
+ const plane = new THREE34__namespace.Mesh(geometry, material);
2865
2959
  plane.userData.entityId = entityId;
2866
2960
  const textureImage = texture.image;
2867
2961
  const width = textureImage?.width ?? 1;
@@ -2907,7 +3001,7 @@ function createImageTarget({
2907
3001
  payload,
2908
3002
  isEditor
2909
3003
  }) {
2910
- const anchor = new THREE33__namespace.Object3D();
3004
+ const anchor = new THREE34__namespace.Object3D();
2911
3005
  const imagePath = payload.path ?? "";
2912
3006
  const entityId = createBaseEntity(world, anchor, {
2913
3007
  label: payload.name ?? "Image Target",
@@ -2924,7 +3018,7 @@ function createImageTarget({
2924
3018
  if (!isEditor || !imagePath) {
2925
3019
  return entityId;
2926
3020
  }
2927
- const loader = new THREE33__namespace.TextureLoader();
3021
+ const loader = new THREE34__namespace.TextureLoader();
2928
3022
  loader.load(
2929
3023
  imagePath,
2930
3024
  (texture) => {
@@ -2932,13 +3026,13 @@ function createImageTarget({
2932
3026
  texture.dispose();
2933
3027
  return;
2934
3028
  }
2935
- const material = new THREE33__namespace.MeshBasicMaterial({
3029
+ const material = new THREE34__namespace.MeshBasicMaterial({
2936
3030
  map: texture,
2937
3031
  transparent: true,
2938
- side: THREE33__namespace.DoubleSide
3032
+ side: THREE34__namespace.DoubleSide
2939
3033
  });
2940
- const geometry = new THREE33__namespace.PlaneGeometry(1, 1);
2941
- const plane = new THREE33__namespace.Mesh(geometry, material);
3034
+ const geometry = new THREE34__namespace.PlaneGeometry(1, 1);
3035
+ const plane = new THREE34__namespace.Mesh(geometry, material);
2942
3036
  plane.userData.entityId = entityId;
2943
3037
  const textureImage = texture.image;
2944
3038
  const width = textureImage?.width ?? 1;
@@ -2957,12 +3051,48 @@ function createImageTarget({
2957
3051
  return entityId;
2958
3052
  }
2959
3053
  __name(createImageTarget, "createImageTarget");
3054
+ function isInstancedMeshKind(value) {
3055
+ return value === "cube" || value === "sphere" || value === "plane" || value === "cylinder" || value === "capsule";
3056
+ }
3057
+ __name(isInstancedMeshKind, "isInstancedMeshKind");
3058
+ function isInstanceTransformArray(value) {
3059
+ return Array.isArray(value);
3060
+ }
3061
+ __name(isInstanceTransformArray, "isInstanceTransformArray");
3062
+ function createInstancedMesh({
3063
+ world,
3064
+ scene,
3065
+ payload
3066
+ }) {
3067
+ const anchor = new THREE34__namespace.Object3D();
3068
+ const opts = payload.options ?? {};
3069
+ const meshKind = isInstancedMeshKind(opts.meshKind) ? opts.meshKind : "cube";
3070
+ const meshParameters = opts.meshParameters && typeof opts.meshParameters === "object" ? opts.meshParameters : void 0;
3071
+ const instances = isInstanceTransformArray(
3072
+ opts.instances
3073
+ ) ? opts.instances : void 0;
3074
+ const castShadow = typeof opts.castShadow === "boolean" ? opts.castShadow : false;
3075
+ const receiveShadow = typeof opts.receiveShadow === "boolean" ? opts.receiveShadow : false;
3076
+ const entityId = createBaseEntity(world, anchor, {
3077
+ label: payload.name ?? "Instanced Mesh",
3078
+ entityType: "instancedMesh",
3079
+ transformInput: payload.transform
3080
+ });
3081
+ createInstancedMeshComponent(world, entityId, meshKind, meshParameters, {
3082
+ castShadow,
3083
+ receiveShadow,
3084
+ instances
3085
+ });
3086
+ scene.add(anchor);
3087
+ return entityId;
3088
+ }
3089
+ __name(createInstancedMesh, "createInstancedMesh");
2960
3090
  function createAmbientLight({
2961
3091
  world,
2962
3092
  scene,
2963
3093
  payload
2964
3094
  }) {
2965
- const light = new THREE33__namespace.AmbientLight("#ffffff", 0.6);
3095
+ const light = new THREE34__namespace.AmbientLight("#ffffff", 0.6);
2966
3096
  const entityId = createBaseEntity(world, light, {
2967
3097
  label: payload.name ?? "Ambient Light",
2968
3098
  entityType: "ambientLight",
@@ -2979,7 +3109,7 @@ function createAreaLight({
2979
3109
  payload,
2980
3110
  isEditor
2981
3111
  }) {
2982
- const light = new THREE33__namespace.RectAreaLight("#ffffff", 5, 4, 4);
3112
+ const light = new THREE34__namespace.RectAreaLight("#ffffff", 5, 4, 4);
2983
3113
  light.lookAt(0, 0, 0);
2984
3114
  const entityId = createBaseEntity(world, light, {
2985
3115
  label: payload.name ?? "Area Light",
@@ -3008,7 +3138,7 @@ function createDirectionalLight({
3008
3138
  payload,
3009
3139
  isEditor
3010
3140
  }) {
3011
- const light = new THREE33__namespace.DirectionalLight("#ffffff", 1.5);
3141
+ const light = new THREE34__namespace.DirectionalLight("#ffffff", 1.5);
3012
3142
  light.castShadow = true;
3013
3143
  const entityId = createBaseEntity(world, light, {
3014
3144
  label: payload.name ?? "Directional Light",
@@ -3019,7 +3149,7 @@ function createDirectionalLight({
3019
3149
  });
3020
3150
  createLightComponent(world, entityId, light);
3021
3151
  if (isEditor) {
3022
- const helper = new THREE33__namespace.DirectionalLightHelper(light, 1.8, "#38bdf8");
3152
+ const helper = new THREE34__namespace.DirectionalLightHelper(light, 1.8, "#38bdf8");
3023
3153
  helper.onBeforeRender = () => {
3024
3154
  helper.update();
3025
3155
  };
@@ -3037,7 +3167,7 @@ function createPointLight({
3037
3167
  payload,
3038
3168
  isEditor
3039
3169
  }) {
3040
- const light = new THREE33__namespace.PointLight("#ffffff", 1, 10);
3170
+ const light = new THREE34__namespace.PointLight("#ffffff", 1, 10);
3041
3171
  const entityId = createBaseEntity(world, light, {
3042
3172
  label: payload.name ?? "Point Light",
3043
3173
  entityType: "pointLight",
@@ -3047,7 +3177,7 @@ function createPointLight({
3047
3177
  });
3048
3178
  createLightComponent(world, entityId, light);
3049
3179
  if (isEditor) {
3050
- const helper = new THREE33__namespace.PointLightHelper(light, 0.35, "#fbbf24");
3180
+ const helper = new THREE34__namespace.PointLightHelper(light, 0.35, "#fbbf24");
3051
3181
  helper.onBeforeRender = () => {
3052
3182
  helper.update();
3053
3183
  };
@@ -3065,7 +3195,7 @@ function createSpotLight({
3065
3195
  payload,
3066
3196
  isEditor
3067
3197
  }) {
3068
- const light = new THREE33__namespace.SpotLight("#ffffff", 1, 20, Math.PI / 6, 0.1, 1);
3198
+ const light = new THREE34__namespace.SpotLight("#ffffff", 1, 20, Math.PI / 6, 0.1, 1);
3069
3199
  const entityId = createBaseEntity(world, light, {
3070
3200
  label: payload.name ?? "Spot Light",
3071
3201
  entityType: "spotLight",
@@ -3075,7 +3205,7 @@ function createSpotLight({
3075
3205
  });
3076
3206
  createLightComponent(world, entityId, light);
3077
3207
  if (isEditor) {
3078
- const helper = new THREE33__namespace.SpotLightHelper(light, "#f59e0b");
3208
+ const helper = new THREE34__namespace.SpotLightHelper(light, "#f59e0b");
3079
3209
  helper.onBeforeRender = () => {
3080
3210
  helper.update();
3081
3211
  };
@@ -3119,6 +3249,8 @@ __export(components_exports, {
3119
3249
  CameraComponent: () => CameraComponent,
3120
3250
  DEFAULT_COLLIDER_STATE: () => DEFAULT_COLLIDER_STATE,
3121
3251
  DEFAULT_ENVIRONMENT_STATE: () => DEFAULT_ENVIRONMENT_STATE,
3252
+ DEFAULT_INSTANCED_MESH_PARAMETERS: () => DEFAULT_INSTANCED_MESH_PARAMETERS,
3253
+ DEFAULT_INSTANCE_TRANSFORM: () => DEFAULT_INSTANCE_TRANSFORM,
3122
3254
  DEFAULT_MESH_GEOMETRY_PARAMETERS: () => DEFAULT_MESH_GEOMETRY_PARAMETERS,
3123
3255
  DEFAULT_PHYSICS_STATE: () => DEFAULT_PHYSICS_STATE,
3124
3256
  DEFAULT_POSTPROCESSING_STATE: () => DEFAULT_POSTPROCESSING_STATE,
@@ -3128,6 +3260,7 @@ __export(components_exports, {
3128
3260
  ImageComponent: () => ImageComponent,
3129
3261
  ImageTarget: () => ImageTarget,
3130
3262
  ImageTargetAnchor: () => ImageTargetAnchor,
3263
+ InstancedMeshComponent: () => InstancedMeshComponent,
3131
3264
  LightComponent: () => LightComponent,
3132
3265
  MaterialComponent: () => MaterialComponent,
3133
3266
  MeshComponent: () => MeshComponent,
@@ -3167,7 +3300,7 @@ function createModelLoader() {
3167
3300
  }
3168
3301
  __name(createModelLoader, "createModelLoader");
3169
3302
  function createModel({ world, scene, payload }) {
3170
- const anchor = new THREE33__namespace.Object3D();
3303
+ const anchor = new THREE34__namespace.Object3D();
3171
3304
  const modelPath = payload.path ?? "";
3172
3305
  const entityId = createBaseEntity(world, anchor, {
3173
3306
  label: payload.name ?? "Model",
@@ -3224,12 +3357,12 @@ function createModel({ world, scene, payload }) {
3224
3357
  }
3225
3358
  __name(createModel, "createModel");
3226
3359
  function createPlane({ world, scene, payload }) {
3227
- const geometry = new THREE33__namespace.PlaneGeometry(100, 100);
3228
- const material = new THREE33__namespace.MeshStandardMaterial({
3360
+ const geometry = new THREE34__namespace.PlaneGeometry(100, 100);
3361
+ const material = new THREE34__namespace.MeshStandardMaterial({
3229
3362
  color: "#ffffff",
3230
- side: THREE33__namespace.DoubleSide
3363
+ side: THREE34__namespace.DoubleSide
3231
3364
  });
3232
- const mesh = new THREE33__namespace.Mesh(geometry, material);
3365
+ const mesh = new THREE34__namespace.Mesh(geometry, material);
3233
3366
  const entityId = createBaseEntity(
3234
3367
  world,
3235
3368
  mesh,
@@ -3261,7 +3394,7 @@ function createPlane({ world, scene, payload }) {
3261
3394
  }
3262
3395
  __name(createPlane, "createPlane");
3263
3396
  function createSprite({ world, scene, payload }) {
3264
- const anchor = new THREE33__namespace.Object3D();
3397
+ const anchor = new THREE34__namespace.Object3D();
3265
3398
  const imagePath = payload.path ?? "";
3266
3399
  const entityId = createBaseEntity(world, anchor, {
3267
3400
  label: payload.name ?? "Sprite",
@@ -3273,7 +3406,7 @@ function createSprite({ world, scene, payload }) {
3273
3406
  if (!imagePath) {
3274
3407
  return entityId;
3275
3408
  }
3276
- const loader = new THREE33__namespace.TextureLoader();
3409
+ const loader = new THREE34__namespace.TextureLoader();
3277
3410
  loader.load(
3278
3411
  imagePath,
3279
3412
  (texture) => {
@@ -3281,11 +3414,11 @@ function createSprite({ world, scene, payload }) {
3281
3414
  texture.dispose();
3282
3415
  return;
3283
3416
  }
3284
- const material = new THREE33__namespace.SpriteMaterial({
3417
+ const material = new THREE34__namespace.SpriteMaterial({
3285
3418
  map: texture,
3286
3419
  transparent: true
3287
3420
  });
3288
- const sprite = new THREE33__namespace.Sprite(material);
3421
+ const sprite = new THREE34__namespace.Sprite(material);
3289
3422
  sprite.userData.entityId = entityId;
3290
3423
  const textureImage = texture.image;
3291
3424
  spriteComponent.width = textureImage?.width ?? 1;
@@ -3303,9 +3436,9 @@ function createSprite({ world, scene, payload }) {
3303
3436
  }
3304
3437
  __name(createSprite, "createSprite");
3305
3438
  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);
3439
+ const geometry = new THREE34__namespace.SphereGeometry(0.5, 24, 24);
3440
+ const material = new THREE34__namespace.MeshStandardMaterial({ color: "#ffffff" });
3441
+ const mesh = new THREE34__namespace.Mesh(geometry, material);
3309
3442
  const entityId = createBaseEntity(world, mesh, {
3310
3443
  label: payload.name ?? "Sphere",
3311
3444
  entityType: "sphere",
@@ -3325,10 +3458,10 @@ function createSphere({ world, scene, payload }) {
3325
3458
  __name(createSphere, "createSphere");
3326
3459
  function getOrCreateListener2(camera) {
3327
3460
  const existing = camera.userData.ecsAudioListener;
3328
- if (existing instanceof THREE33__namespace.AudioListener) {
3461
+ if (existing instanceof THREE34__namespace.AudioListener) {
3329
3462
  return existing;
3330
3463
  }
3331
- const listener = new THREE33__namespace.AudioListener();
3464
+ const listener = new THREE34__namespace.AudioListener();
3332
3465
  camera.add(listener);
3333
3466
  camera.userData.ecsAudioListener = listener;
3334
3467
  return listener;
@@ -3378,10 +3511,10 @@ function normalizeOptions(input) {
3378
3511
  }
3379
3512
  __name(normalizeOptions, "normalizeOptions");
3380
3513
  function createChromaMaterial(texture, options) {
3381
- return new THREE33__namespace.ShaderMaterial({
3514
+ return new THREE34__namespace.ShaderMaterial({
3382
3515
  uniforms: {
3383
3516
  tex: { value: texture },
3384
- keyColor: { value: new THREE33__namespace.Color(options.backgroundColor) },
3517
+ keyColor: { value: new THREE34__namespace.Color(options.backgroundColor) },
3385
3518
  similarity: { value: options.similarity },
3386
3519
  smoothness: { value: options.smoothness },
3387
3520
  spill: { value: options.spill }
@@ -3413,22 +3546,22 @@ function createChromaMaterial(texture, options) {
3413
3546
  }
3414
3547
  `,
3415
3548
  transparent: true,
3416
- side: THREE33__namespace.DoubleSide
3549
+ side: THREE34__namespace.DoubleSide
3417
3550
  });
3418
3551
  }
3419
3552
  __name(createChromaMaterial, "createChromaMaterial");
3420
3553
  function createStandardMaterial(texture) {
3421
- return new THREE33__namespace.MeshBasicMaterial({
3554
+ return new THREE34__namespace.MeshBasicMaterial({
3422
3555
  map: texture,
3423
3556
  transparent: true,
3424
- side: THREE33__namespace.DoubleSide
3557
+ side: THREE34__namespace.DoubleSide
3425
3558
  });
3426
3559
  }
3427
3560
  __name(createStandardMaterial, "createStandardMaterial");
3428
3561
  function createVideoMesh(entityId, texture, options) {
3429
- const geometry = new THREE33__namespace.PlaneGeometry(1, 1);
3562
+ const geometry = new THREE34__namespace.PlaneGeometry(1, 1);
3430
3563
  const material = options.isGreenScreen ? createChromaMaterial(texture, options) : createStandardMaterial(texture);
3431
- const mesh = new THREE33__namespace.Mesh(geometry, material);
3564
+ const mesh = new THREE34__namespace.Mesh(geometry, material);
3432
3565
  mesh.userData.entityId = entityId;
3433
3566
  mesh.scale.set(options.width, options.height, 1);
3434
3567
  return { mesh, material };
@@ -3463,7 +3596,7 @@ function createVideo({
3463
3596
  payload,
3464
3597
  isEditor
3465
3598
  }) {
3466
- const anchor = new THREE33__namespace.Object3D();
3599
+ const anchor = new THREE34__namespace.Object3D();
3467
3600
  const path = payload.path ?? "";
3468
3601
  const options = normalizeOptions(payload.options);
3469
3602
  const entityId = createBaseEntity(world, anchor, {
@@ -3478,8 +3611,8 @@ function createVideo({
3478
3611
  return entityId;
3479
3612
  }
3480
3613
  const video = createVideoElement(path, options);
3481
- const texture = new THREE33__namespace.VideoTexture(video);
3482
- texture.colorSpace = THREE33__namespace.SRGBColorSpace;
3614
+ const texture = new THREE34__namespace.VideoTexture(video);
3615
+ texture.colorSpace = THREE34__namespace.SRGBColorSpace;
3483
3616
  texture.needsUpdate = true;
3484
3617
  const { mesh, material } = createVideoMesh(entityId, texture, options);
3485
3618
  anchor.add(mesh);
@@ -3495,7 +3628,7 @@ function createVideo({
3495
3628
  });
3496
3629
  if (!isEditor && options.positional) {
3497
3630
  const listener = getOrCreateListener2(camera);
3498
- const audioNode = new THREE33__namespace.PositionalAudio(listener);
3631
+ const audioNode = new THREE34__namespace.PositionalAudio(listener);
3499
3632
  audioNode.setVolume(options.volume);
3500
3633
  audioNode.setRefDistance(options.refDistance);
3501
3634
  audioNode.setDistanceModel(normalizeDistanceModel2(options.distanceModel));
@@ -3523,6 +3656,7 @@ function registerDefaultFactories(objectManagementSystem) {
3523
3656
  objectManagementSystem.register("model", createModel);
3524
3657
  objectManagementSystem.register("image", createImage);
3525
3658
  objectManagementSystem.register("imageTarget", createImageTarget);
3659
+ objectManagementSystem.register("instancedMesh", createInstancedMesh);
3526
3660
  objectManagementSystem.register("sprite", createSprite);
3527
3661
  objectManagementSystem.register("audio", createAudio);
3528
3662
  objectManagementSystem.register("camera", createCamera);
@@ -3674,7 +3808,7 @@ function transitionToClip(runtime, nextClipId, crossFadeDuration) {
3674
3808
  }
3675
3809
  __name(transitionToClip, "transitionToClip");
3676
3810
  function applyActionState(action, component, paused, shouldLoop) {
3677
- const loopMode = shouldLoop ? THREE33__namespace.LoopRepeat : THREE33__namespace.LoopOnce;
3811
+ const loopMode = shouldLoop ? THREE34__namespace.LoopRepeat : THREE34__namespace.LoopOnce;
3678
3812
  const repetitions = shouldLoop ? Infinity : 1;
3679
3813
  action.setLoop(loopMode, repetitions);
3680
3814
  action.clampWhenFinished = !shouldLoop;
@@ -3847,7 +3981,7 @@ var _AnimationSystem = class _AnimationSystem {
3847
3981
  if (runtime) {
3848
3982
  stopAllActions(runtime);
3849
3983
  }
3850
- const mixer = new THREE33__namespace.AnimationMixer(root);
3984
+ const mixer = new THREE34__namespace.AnimationMixer(root);
3851
3985
  const entries2 = readRuntimeClipEntries(animation);
3852
3986
  const indexedActions = createActions(mixer, entries2);
3853
3987
  runtime = {
@@ -3973,11 +4107,11 @@ function normalizeOrthoBounds(component) {
3973
4107
  }
3974
4108
  __name(normalizeOrthoBounds, "normalizeOrthoBounds");
3975
4109
  function isPerspectiveCamera(camera) {
3976
- return camera instanceof THREE33__namespace.PerspectiveCamera;
4110
+ return camera instanceof THREE34__namespace.PerspectiveCamera;
3977
4111
  }
3978
4112
  __name(isPerspectiveCamera, "isPerspectiveCamera");
3979
4113
  function isOrthographicCamera(camera) {
3980
- return camera instanceof THREE33__namespace.OrthographicCamera;
4114
+ return camera instanceof THREE34__namespace.OrthographicCamera;
3981
4115
  }
3982
4116
  __name(isOrthographicCamera, "isOrthographicCamera");
3983
4117
  function readWindowAspect() {
@@ -4030,7 +4164,7 @@ var _CameraSyncSystem = class _CameraSyncSystem {
4030
4164
  continue;
4031
4165
  }
4032
4166
  const camera = objectRef.object;
4033
- if (!(camera instanceof THREE33__namespace.Camera)) {
4167
+ if (!(camera instanceof THREE34__namespace.Camera)) {
4034
4168
  continue;
4035
4169
  }
4036
4170
  const nextSignature = buildSignature(component, camera, windowAspect);
@@ -4094,7 +4228,7 @@ var MIN_DENSITY = 0;
4094
4228
  function createGradientTexture(effect, colors) {
4095
4229
  if (typeof document === "undefined") {
4096
4230
  const pixel = new Uint8Array([30, 30, 30, 255]);
4097
- const fallback = new THREE33__namespace.DataTexture(pixel, 1, 1, THREE33__namespace.RGBAFormat);
4231
+ const fallback = new THREE34__namespace.DataTexture(pixel, 1, 1, THREE34__namespace.RGBAFormat);
4098
4232
  fallback.needsUpdate = true;
4099
4233
  return fallback;
4100
4234
  }
@@ -4103,7 +4237,7 @@ function createGradientTexture(effect, colors) {
4103
4237
  canvas.height = 512;
4104
4238
  const context = canvas.getContext("2d");
4105
4239
  if (!context) {
4106
- const fallback = new THREE33__namespace.CanvasTexture(canvas);
4240
+ const fallback = new THREE34__namespace.CanvasTexture(canvas);
4107
4241
  fallback.needsUpdate = true;
4108
4242
  return fallback;
4109
4243
  }
@@ -4131,15 +4265,15 @@ function createGradientTexture(effect, colors) {
4131
4265
  context.fillRect(0, 0, 512, 512);
4132
4266
  context.globalCompositeOperation = "source-over";
4133
4267
  }
4134
- const texture = new THREE33__namespace.CanvasTexture(canvas);
4135
- texture.colorSpace = THREE33__namespace.SRGBColorSpace;
4268
+ const texture = new THREE34__namespace.CanvasTexture(canvas);
4269
+ texture.colorSpace = THREE34__namespace.SRGBColorSpace;
4136
4270
  texture.needsUpdate = true;
4137
4271
  return texture;
4138
4272
  }
4139
4273
  __name(createGradientTexture, "createGradientTexture");
4140
4274
  var _EnvironmentSyncSystem = class _EnvironmentSyncSystem {
4141
4275
  constructor(scene) {
4142
- this.textureLoader = new THREE33__namespace.TextureLoader();
4276
+ this.textureLoader = new THREE34__namespace.TextureLoader();
4143
4277
  this.signature = null;
4144
4278
  this.activeTexture = null;
4145
4279
  this.pendingImageUrl = null;
@@ -4162,7 +4296,7 @@ var _EnvironmentSyncSystem = class _EnvironmentSyncSystem {
4162
4296
  if (skybox.type === "color") {
4163
4297
  this.disposeActiveTexture();
4164
4298
  this.pendingImageUrl = null;
4165
- this.scene.background = new THREE33__namespace.Color(skybox.color || "#1e1e1e");
4299
+ this.scene.background = new THREE34__namespace.Color(skybox.color || "#1e1e1e");
4166
4300
  return;
4167
4301
  }
4168
4302
  if (skybox.type === "gradient") {
@@ -4196,7 +4330,7 @@ var _EnvironmentSyncSystem = class _EnvironmentSyncSystem {
4196
4330
  texture.dispose();
4197
4331
  return;
4198
4332
  }
4199
- texture.colorSpace = THREE33__namespace.SRGBColorSpace;
4333
+ texture.colorSpace = THREE34__namespace.SRGBColorSpace;
4200
4334
  this.activeTexture = texture;
4201
4335
  this.scene.background = texture;
4202
4336
  },
@@ -4215,16 +4349,16 @@ var _EnvironmentSyncSystem = class _EnvironmentSyncSystem {
4215
4349
  this.scene.fog = null;
4216
4350
  return;
4217
4351
  }
4218
- const fogColor = new THREE33__namespace.Color(fog.color || "#1e1e1e");
4352
+ const fogColor = new THREE34__namespace.Color(fog.color || "#1e1e1e");
4219
4353
  if (fog.type === "linear") {
4220
4354
  const near = Number.isFinite(fog.linear.near) ? fog.linear.near : 1;
4221
4355
  const farCandidate = Number.isFinite(fog.linear.far) ? fog.linear.far : near + 10;
4222
4356
  const far = Math.max(near + MIN_FOG_DELTA, farCandidate);
4223
- this.scene.fog = new THREE33__namespace.Fog(fogColor, near, far);
4357
+ this.scene.fog = new THREE34__namespace.Fog(fogColor, near, far);
4224
4358
  return;
4225
4359
  }
4226
4360
  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);
4361
+ this.scene.fog = new THREE34__namespace.FogExp2(fogColor, density);
4228
4362
  }
4229
4363
  update(world) {
4230
4364
  const entityIds = world.query(Environment);
@@ -4306,10 +4440,10 @@ var _PostprocessingSyncSystem = class _PostprocessingSyncSystem {
4306
4440
  );
4307
4441
  }
4308
4442
  if (values.bloom.enabled) {
4309
- const size = this.renderer.getSize(new THREE33__namespace.Vector2());
4443
+ const size = this.renderer.getSize(new THREE34__namespace.Vector2());
4310
4444
  composer.addPass(
4311
4445
  new UnrealBloomPass_js.UnrealBloomPass(
4312
- new THREE33__namespace.Vector2(size.width, size.height),
4446
+ new THREE34__namespace.Vector2(size.width, size.height),
4313
4447
  values.bloom.intensity,
4314
4448
  values.bloom.radius,
4315
4449
  values.bloom.threshold
@@ -4354,7 +4488,7 @@ var _PostprocessingSyncSystem = class _PostprocessingSyncSystem {
4354
4488
  if (values.dotScreen.enabled) {
4355
4489
  composer.addPass(
4356
4490
  new DotScreenPass_js.DotScreenPass(
4357
- new THREE33__namespace.Vector2(0, 0),
4491
+ new THREE34__namespace.Vector2(0, 0),
4358
4492
  values.dotScreen.angle ?? values.dotScreen.dotScreenAngle,
4359
4493
  values.dotScreen.scale ?? values.dotScreen.dotScreenScale
4360
4494
  )
@@ -4428,7 +4562,7 @@ function computeColliderState(colliderValues, object) {
4428
4562
  if (!object) {
4429
4563
  return colliderValues;
4430
4564
  }
4431
- const scale = new THREE33__namespace.Vector3();
4565
+ const scale = new THREE34__namespace.Vector3();
4432
4566
  object.getWorldScale(scale);
4433
4567
  return {
4434
4568
  ...colliderValues,
@@ -4479,8 +4613,8 @@ function createColliderDesc(RAPIER, values, triMeshData) {
4479
4613
  values.offsetPosition.y,
4480
4614
  values.offsetPosition.z
4481
4615
  );
4482
- const offsetQuaternion = new THREE33__namespace.Quaternion().setFromEuler(
4483
- new THREE33__namespace.Euler(
4616
+ const offsetQuaternion = new THREE34__namespace.Quaternion().setFromEuler(
4617
+ new THREE34__namespace.Euler(
4484
4618
  values.offsetRotation.x,
4485
4619
  values.offsetRotation.y,
4486
4620
  values.offsetRotation.z
@@ -4491,7 +4625,7 @@ function createColliderDesc(RAPIER, values, triMeshData) {
4491
4625
  }
4492
4626
  __name(createColliderDesc, "createColliderDesc");
4493
4627
  function findFirstMeshWithGeometry(object) {
4494
- if (object instanceof THREE33__namespace.Mesh && object.geometry) {
4628
+ if (object instanceof THREE34__namespace.Mesh && object.geometry) {
4495
4629
  return object;
4496
4630
  }
4497
4631
  let found = null;
@@ -4499,7 +4633,7 @@ function findFirstMeshWithGeometry(object) {
4499
4633
  if (found) {
4500
4634
  return;
4501
4635
  }
4502
- if (child instanceof THREE33__namespace.Mesh && child.geometry) {
4636
+ if (child instanceof THREE34__namespace.Mesh && child.geometry) {
4503
4637
  found = child;
4504
4638
  }
4505
4639
  });
@@ -4525,13 +4659,13 @@ function createTriMeshData(object) {
4525
4659
  }
4526
4660
  object.updateWorldMatrix(true, true);
4527
4661
  mesh.updateWorldMatrix(true, true);
4528
- const worldToObject = new THREE33__namespace.Matrix4().copy(object.matrixWorld).invert();
4529
- const relativeMatrix = new THREE33__namespace.Matrix4().multiplyMatrices(
4662
+ const worldToObject = new THREE34__namespace.Matrix4().copy(object.matrixWorld).invert();
4663
+ const relativeMatrix = new THREE34__namespace.Matrix4().multiplyMatrices(
4530
4664
  worldToObject,
4531
4665
  mesh.matrixWorld
4532
4666
  );
4533
4667
  const vertices = new Float32Array(positionCount * 3);
4534
- const point = new THREE33__namespace.Vector3();
4668
+ const point = new THREE34__namespace.Vector3();
4535
4669
  for (let index = 0; index < positionCount; index += 1) {
4536
4670
  point.set(
4537
4671
  positionAttribute.getX(index),
@@ -4569,8 +4703,8 @@ function createTriMeshData(object) {
4569
4703
  }
4570
4704
  __name(createTriMeshData, "createTriMeshData");
4571
4705
  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)
4706
+ const quaternion = new THREE34__namespace.Quaternion().setFromEuler(
4707
+ new THREE34__namespace.Euler(transform.rotation.x, transform.rotation.y, transform.rotation.z)
4574
4708
  );
4575
4709
  body.setTranslation(
4576
4710
  {
@@ -4597,8 +4731,8 @@ function syncTransformFromBody(transform, body) {
4597
4731
  transform.position.x = position.x;
4598
4732
  transform.position.y = position.y;
4599
4733
  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)
4734
+ const euler = new THREE34__namespace.Euler().setFromQuaternion(
4735
+ new THREE34__namespace.Quaternion(rotation.x, rotation.y, rotation.z, rotation.w)
4602
4736
  );
4603
4737
  transform.rotation.x = euler.x;
4604
4738
  transform.rotation.y = euler.y;
@@ -4710,8 +4844,8 @@ var _PhysicsSyncSystem = class _PhysicsSyncSystem {
4710
4844
  transform.position.y,
4711
4845
  transform.position.z
4712
4846
  );
4713
- const quaternion = new THREE33__namespace.Quaternion().setFromEuler(
4714
- new THREE33__namespace.Euler(
4847
+ const quaternion = new THREE34__namespace.Quaternion().setFromEuler(
4848
+ new THREE34__namespace.Euler(
4715
4849
  transform.rotation.x,
4716
4850
  transform.rotation.y,
4717
4851
  transform.rotation.z
@@ -5286,7 +5420,7 @@ function applyLightValues(lightComponent) {
5286
5420
  values.castShadow
5287
5421
  );
5288
5422
  }
5289
- if (light instanceof THREE33__namespace.PointLight) {
5423
+ if (light instanceof THREE34__namespace.PointLight) {
5290
5424
  if (typeof values.distance === "number" && Number.isFinite(values.distance)) {
5291
5425
  light.distance = Math.max(MIN_LIGHT_DISTANCE, values.distance);
5292
5426
  }
@@ -5294,7 +5428,7 @@ function applyLightValues(lightComponent) {
5294
5428
  light.decay = Math.max(0, values.decay);
5295
5429
  }
5296
5430
  }
5297
- if (light instanceof THREE33__namespace.SpotLight) {
5431
+ if (light instanceof THREE34__namespace.SpotLight) {
5298
5432
  if (typeof values.distance === "number" && Number.isFinite(values.distance)) {
5299
5433
  light.distance = Math.max(MIN_LIGHT_DISTANCE, values.distance);
5300
5434
  }
@@ -5308,7 +5442,7 @@ function applyLightValues(lightComponent) {
5308
5442
  light.penumbra = Math.max(0, Math.min(1, values.penumbra));
5309
5443
  }
5310
5444
  }
5311
- if (light instanceof THREE33__namespace.RectAreaLight) {
5445
+ if (light instanceof THREE34__namespace.RectAreaLight) {
5312
5446
  if (typeof values.width === "number" && Number.isFinite(values.width)) {
5313
5447
  light.width = Math.max(MIN_AREA_SIZE, values.width);
5314
5448
  }
@@ -5369,15 +5503,15 @@ function resolveMaterialPropertyKey(key) {
5369
5503
  __name(resolveMaterialPropertyKey, "resolveMaterialPropertyKey");
5370
5504
  function createMaterialByType(type) {
5371
5505
  if (type === "basic") {
5372
- return new THREE33__namespace.MeshBasicMaterial();
5506
+ return new THREE34__namespace.MeshBasicMaterial();
5373
5507
  }
5374
5508
  if (type === "phong") {
5375
- return new THREE33__namespace.MeshPhongMaterial();
5509
+ return new THREE34__namespace.MeshPhongMaterial();
5376
5510
  }
5377
5511
  if (type === "physical") {
5378
- return new THREE33__namespace.MeshPhysicalMaterial();
5512
+ return new THREE34__namespace.MeshPhysicalMaterial();
5379
5513
  }
5380
- return new THREE33__namespace.MeshStandardMaterial();
5514
+ return new THREE34__namespace.MeshStandardMaterial();
5381
5515
  }
5382
5516
  __name(createMaterialByType, "createMaterialByType");
5383
5517
  function replaceMaterialAcrossObject(object, previous, next) {
@@ -5436,12 +5570,12 @@ function applyTextureFiltering(material, filtering) {
5436
5570
  const target = material;
5437
5571
  for (const slot of materialTextureSlots) {
5438
5572
  const texture = target[slot];
5439
- if (!texture || !(texture instanceof THREE33__namespace.Texture)) {
5573
+ if (!texture || !(texture instanceof THREE34__namespace.Texture)) {
5440
5574
  continue;
5441
5575
  }
5442
5576
  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;
5577
+ texture.magFilter = sharp ? THREE34__namespace.NearestFilter : THREE34__namespace.LinearFilter;
5578
+ texture.minFilter = useMipmaps ? sharp ? THREE34__namespace.NearestMipmapNearestFilter : THREE34__namespace.LinearMipmapLinearFilter : sharp ? THREE34__namespace.NearestFilter : THREE34__namespace.LinearFilter;
5445
5579
  texture.needsUpdate = true;
5446
5580
  }
5447
5581
  material.needsUpdate = true;
@@ -5451,12 +5585,12 @@ function setTextureMipmaps(material, enabled) {
5451
5585
  const target = material;
5452
5586
  for (const slot of materialTextureSlots) {
5453
5587
  const texture = target[slot];
5454
- if (!texture || !(texture instanceof THREE33__namespace.Texture)) {
5588
+ if (!texture || !(texture instanceof THREE34__namespace.Texture)) {
5455
5589
  continue;
5456
5590
  }
5457
5591
  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;
5592
+ const sharp = texture.magFilter === THREE34__namespace.NearestFilter;
5593
+ texture.minFilter = enabled ? sharp ? THREE34__namespace.NearestMipmapNearestFilter : THREE34__namespace.LinearMipmapLinearFilter : sharp ? THREE34__namespace.NearestFilter : THREE34__namespace.LinearFilter;
5460
5594
  texture.needsUpdate = true;
5461
5595
  }
5462
5596
  material.needsUpdate = true;
@@ -5467,7 +5601,7 @@ function assignMaterialTexture(material, rawKey, url, textureCache) {
5467
5601
  const key = resolveMaterialPropertyKey(rawKey);
5468
5602
  let texture = textureCache.get(url);
5469
5603
  if (!texture) {
5470
- texture = new THREE33__namespace.TextureLoader().load(url);
5604
+ texture = new THREE34__namespace.TextureLoader().load(url);
5471
5605
  textureCache.set(url, texture);
5472
5606
  }
5473
5607
  target[key] = texture;
@@ -5665,12 +5799,12 @@ function resolvePrimaryMesh(object) {
5665
5799
  if (!object) {
5666
5800
  return null;
5667
5801
  }
5668
- if (object instanceof THREE33__namespace.Mesh) {
5802
+ if (object instanceof THREE34__namespace.Mesh) {
5669
5803
  return object;
5670
5804
  }
5671
5805
  let found = null;
5672
5806
  object.traverse((child) => {
5673
- if (!found && child instanceof THREE33__namespace.Mesh) {
5807
+ if (!found && child instanceof THREE34__namespace.Mesh) {
5674
5808
  found = child;
5675
5809
  }
5676
5810
  });
@@ -5691,22 +5825,22 @@ function applyGeometry(component) {
5691
5825
  switch (component.kind) {
5692
5826
  case "cube": {
5693
5827
  const params = sanitized;
5694
- nextGeometry = new THREE33__namespace.BoxGeometry(params.width, params.height, params.depth);
5828
+ nextGeometry = new THREE34__namespace.BoxGeometry(params.width, params.height, params.depth);
5695
5829
  break;
5696
5830
  }
5697
5831
  case "plane": {
5698
5832
  const params = sanitized;
5699
- nextGeometry = new THREE33__namespace.PlaneGeometry(params.width, params.height);
5833
+ nextGeometry = new THREE34__namespace.PlaneGeometry(params.width, params.height);
5700
5834
  break;
5701
5835
  }
5702
5836
  case "sphere": {
5703
5837
  const params = sanitized;
5704
- nextGeometry = new THREE33__namespace.SphereGeometry(params.radius, 24, 24);
5838
+ nextGeometry = new THREE34__namespace.SphereGeometry(params.radius, 24, 24);
5705
5839
  break;
5706
5840
  }
5707
5841
  case "cylinder": {
5708
5842
  const params = sanitized;
5709
- nextGeometry = new THREE33__namespace.CylinderGeometry(
5843
+ nextGeometry = new THREE34__namespace.CylinderGeometry(
5710
5844
  params.radius,
5711
5845
  params.radius,
5712
5846
  params.height,
@@ -5716,7 +5850,7 @@ function applyGeometry(component) {
5716
5850
  }
5717
5851
  case "capsule": {
5718
5852
  const params = sanitized;
5719
- nextGeometry = new THREE33__namespace.CapsuleGeometry(params.radius, params.height, 4, 8);
5853
+ nextGeometry = new THREE34__namespace.CapsuleGeometry(params.radius, params.height, 4, 8);
5720
5854
  break;
5721
5855
  }
5722
5856
  default:
@@ -5732,7 +5866,7 @@ function applyShadowFlags(component) {
5732
5866
  return;
5733
5867
  }
5734
5868
  component.object.traverse((child) => {
5735
- if (child instanceof THREE33__namespace.Mesh) {
5869
+ if (child instanceof THREE34__namespace.Mesh) {
5736
5870
  child.castShadow = component.castShadow;
5737
5871
  child.receiveShadow = component.receiveShadow;
5738
5872
  }
@@ -5785,6 +5919,276 @@ var _MeshGeometrySystem = class _MeshGeometrySystem {
5785
5919
  };
5786
5920
  __name(_MeshGeometrySystem, "MeshGeometrySystem");
5787
5921
  var MeshGeometrySystem = _MeshGeometrySystem;
5922
+ var DRACO_DECODER_PATH = resolveDracoDecoderPath();
5923
+ var loadGLTF = /* @__PURE__ */ __name((path) => {
5924
+ return new Promise((resolve, reject) => {
5925
+ const loader = new GLTFLoader_js.GLTFLoader();
5926
+ try {
5927
+ const dracoLoader = new DRACOLoader_js.DRACOLoader();
5928
+ dracoLoader.setDecoderPath(DRACO_DECODER_PATH);
5929
+ loader.setDRACOLoader(dracoLoader);
5930
+ } catch (error) {
5931
+ console.debug("DRACOLoader setup failed or unavailable", error);
5932
+ }
5933
+ loader.load(
5934
+ path,
5935
+ (gltf) => {
5936
+ resolve(gltf);
5937
+ },
5938
+ void 0,
5939
+ (error) => {
5940
+ console.debug("GLTFLoader failed to load", error);
5941
+ reject(error);
5942
+ }
5943
+ );
5944
+ });
5945
+ }, "loadGLTF");
5946
+
5947
+ // core/systems/InstancedMeshSystem.ts
5948
+ function buildGeometry(component) {
5949
+ const p = component.getSanitizedParameters();
5950
+ switch (component.meshKind) {
5951
+ case "cube": {
5952
+ const params = p;
5953
+ return new THREE34__namespace.BoxGeometry(params.width, params.height, params.depth);
5954
+ }
5955
+ case "plane": {
5956
+ const params = p;
5957
+ return new THREE34__namespace.PlaneGeometry(params.width, params.height);
5958
+ }
5959
+ case "sphere": {
5960
+ const params = p;
5961
+ return new THREE34__namespace.SphereGeometry(params.radius, 24, 24);
5962
+ }
5963
+ case "cylinder": {
5964
+ const params = p;
5965
+ return new THREE34__namespace.CylinderGeometry(params.radius, params.radius, params.height, 20);
5966
+ }
5967
+ case "capsule": {
5968
+ const params = p;
5969
+ return new THREE34__namespace.CapsuleGeometry(params.radius, params.height, 4, 8);
5970
+ }
5971
+ default:
5972
+ return new THREE34__namespace.BoxGeometry(1, 1, 1);
5973
+ }
5974
+ }
5975
+ __name(buildGeometry, "buildGeometry");
5976
+ var _position = new THREE34__namespace.Vector3();
5977
+ var _quaternion = new THREE34__namespace.Quaternion();
5978
+ var _euler = new THREE34__namespace.Euler();
5979
+ var _scale = new THREE34__namespace.Vector3();
5980
+ var _matrix = new THREE34__namespace.Matrix4();
5981
+ var _modelMatrix = new THREE34__namespace.Matrix4();
5982
+ function instanceTransformToMatrix4(inst, out) {
5983
+ _position.set(inst.position.x, inst.position.y, inst.position.z);
5984
+ _euler.set(inst.rotation.x, inst.rotation.y, inst.rotation.z, "XYZ");
5985
+ _quaternion.setFromEuler(_euler);
5986
+ _scale.set(inst.scale.x, inst.scale.y, inst.scale.z);
5987
+ out.compose(_position, _quaternion, _scale);
5988
+ }
5989
+ __name(instanceTransformToMatrix4, "instanceTransformToMatrix4");
5990
+ function disposePrimitiveInstancedMesh(mesh) {
5991
+ mesh.geometry.dispose();
5992
+ if (Array.isArray(mesh.material)) {
5993
+ for (const m of mesh.material) {
5994
+ m.dispose();
5995
+ }
5996
+ } else {
5997
+ mesh.material.dispose();
5998
+ }
5999
+ }
6000
+ __name(disposePrimitiveInstancedMesh, "disposePrimitiveInstancedMesh");
6001
+ function disposeModelGroup(group) {
6002
+ group.traverse((child) => {
6003
+ const im = child;
6004
+ if (im.isInstancedMesh) {
6005
+ im.geometry.dispose();
6006
+ if (Array.isArray(im.material)) {
6007
+ for (const m of im.material) {
6008
+ m.dispose();
6009
+ }
6010
+ } else {
6011
+ im.material.dispose();
6012
+ }
6013
+ }
6014
+ });
6015
+ }
6016
+ __name(disposeModelGroup, "disposeModelGroup");
6017
+ var _InstancedMeshSystem = class _InstancedMeshSystem {
6018
+ constructor() {
6019
+ /** Signature tracking for geometry + instance count changes. */
6020
+ this.geometrySignatures = /* @__PURE__ */ new Map();
6021
+ /** Entities whose GLTF model is currently loading. Prevents duplicate load triggers. */
6022
+ this.loadingEntities = /* @__PURE__ */ new Set();
6023
+ /** Per-mesh data for model kind, populated after GLTF load. */
6024
+ this.modelMeshEntries = /* @__PURE__ */ new Map();
6025
+ }
6026
+ update(world) {
6027
+ const entityIds = world.query(InstancedMeshComponent);
6028
+ const alive = new Set(entityIds);
6029
+ for (const trackedId of this.geometrySignatures.keys()) {
6030
+ if (!alive.has(trackedId)) this.geometrySignatures.delete(trackedId);
6031
+ }
6032
+ for (const trackedId of this.loadingEntities) {
6033
+ if (!alive.has(trackedId)) this.loadingEntities.delete(trackedId);
6034
+ }
6035
+ for (const trackedId of this.modelMeshEntries.keys()) {
6036
+ if (!alive.has(trackedId)) this.modelMeshEntries.delete(trackedId);
6037
+ }
6038
+ for (const entityId of entityIds) {
6039
+ const comp = world.getComponent(
6040
+ entityId,
6041
+ InstancedMeshComponent
6042
+ );
6043
+ if (!comp) continue;
6044
+ const objectRef = world.getComponent(entityId, Object3DRef);
6045
+ const anchor = objectRef?.object ?? null;
6046
+ if (!anchor) continue;
6047
+ const instanceCount = comp.instances.length;
6048
+ const geometrySignature = comp.meshKind === "model" ? `model:${comp.modelPath}:${instanceCount}` : `${comp.meshKind}:${JSON.stringify(comp.meshParameters)}:${instanceCount}`;
6049
+ const needsRebuild = comp.instancedMesh === null || this.geometrySignatures.get(entityId) !== geometrySignature;
6050
+ if (needsRebuild) {
6051
+ if (comp.instancedMesh) {
6052
+ anchor.remove(comp.instancedMesh);
6053
+ if (comp.instancedMesh.isInstancedMesh) {
6054
+ disposePrimitiveInstancedMesh(comp.instancedMesh);
6055
+ } else {
6056
+ disposeModelGroup(comp.instancedMesh);
6057
+ }
6058
+ comp.instancedMesh = null;
6059
+ }
6060
+ this.loadingEntities.delete(entityId);
6061
+ this.modelMeshEntries.delete(entityId);
6062
+ if (comp.meshKind === "model") {
6063
+ if (comp.modelPath && !this.loadingEntities.has(entityId)) {
6064
+ this.loadingEntities.add(entityId);
6065
+ const targetSignature = geometrySignature;
6066
+ const targetEntityId = entityId;
6067
+ loadGLTF(comp.modelPath).then((gltf) => {
6068
+ if (!world.hasEntity(targetEntityId)) {
6069
+ this.loadingEntities.delete(targetEntityId);
6070
+ return;
6071
+ }
6072
+ const currentComp = world.getComponent(
6073
+ targetEntityId,
6074
+ InstancedMeshComponent
6075
+ );
6076
+ if (!currentComp) {
6077
+ this.loadingEntities.delete(targetEntityId);
6078
+ return;
6079
+ }
6080
+ const currentSig = `model:${currentComp.modelPath}:${currentComp.instances.length}`;
6081
+ if (currentSig !== targetSignature) {
6082
+ this.loadingEntities.delete(targetEntityId);
6083
+ return;
6084
+ }
6085
+ const currentRef = world.getComponent(targetEntityId, Object3DRef);
6086
+ const currentAnchor = currentRef?.object ?? null;
6087
+ if (!currentAnchor) {
6088
+ this.loadingEntities.delete(targetEntityId);
6089
+ return;
6090
+ }
6091
+ const count2 = Math.max(1, currentComp.instances.length);
6092
+ const entries = [];
6093
+ gltf.scene.updateWorldMatrix(true, true);
6094
+ gltf.scene.traverse((child) => {
6095
+ const meshChild = child;
6096
+ if (!meshChild.isMesh) return;
6097
+ const geometry2 = meshChild.geometry.clone();
6098
+ const sourceMaterial = Array.isArray(meshChild.material) ? meshChild.material.map((m) => m.clone()) : meshChild.material.clone();
6099
+ meshChild.updateWorldMatrix(true, false);
6100
+ const localMatrix = meshChild.matrixWorld.clone();
6101
+ const instancedMesh2 = new THREE34__namespace.InstancedMesh(
6102
+ geometry2,
6103
+ Array.isArray(sourceMaterial) ? sourceMaterial : sourceMaterial,
6104
+ count2
6105
+ );
6106
+ instancedMesh2.castShadow = currentComp.castShadow;
6107
+ instancedMesh2.receiveShadow = currentComp.receiveShadow;
6108
+ for (let i = 0; i < count2; i++) {
6109
+ const inst = currentComp.instances[i] ?? {
6110
+ position: { x: 0, y: 0, z: 0 },
6111
+ rotation: { x: 0, y: 0, z: 0 },
6112
+ scale: { x: 1, y: 1, z: 1 }
6113
+ };
6114
+ instanceTransformToMatrix4(inst, _matrix);
6115
+ _modelMatrix.multiplyMatrices(_matrix, localMatrix);
6116
+ instancedMesh2.setMatrixAt(i, _modelMatrix);
6117
+ }
6118
+ instancedMesh2.instanceMatrix.needsUpdate = true;
6119
+ entries.push({ localMatrix, instancedMesh: instancedMesh2 });
6120
+ });
6121
+ if (entries.length === 0) {
6122
+ this.loadingEntities.delete(targetEntityId);
6123
+ return;
6124
+ }
6125
+ const group = new THREE34__namespace.Group();
6126
+ for (const entry of entries) {
6127
+ group.add(entry.instancedMesh);
6128
+ }
6129
+ currentAnchor.add(group);
6130
+ currentComp.instancedMesh = group;
6131
+ this.modelMeshEntries.set(targetEntityId, entries);
6132
+ this.geometrySignatures.set(targetEntityId, targetSignature);
6133
+ this.loadingEntities.delete(targetEntityId);
6134
+ }).catch(() => {
6135
+ this.loadingEntities.delete(targetEntityId);
6136
+ });
6137
+ }
6138
+ continue;
6139
+ }
6140
+ const count = Math.max(1, instanceCount);
6141
+ const geometry = buildGeometry(comp);
6142
+ const material = new THREE34__namespace.MeshStandardMaterial({ color: "#ffffff" });
6143
+ const instancedMesh = new THREE34__namespace.InstancedMesh(geometry, material, count);
6144
+ instancedMesh.castShadow = comp.castShadow;
6145
+ instancedMesh.receiveShadow = comp.receiveShadow;
6146
+ for (let i = 0; i < count; i++) {
6147
+ const inst = comp.instances[i] ?? {
6148
+ position: { x: 0, y: 0, z: 0 },
6149
+ rotation: { x: 0, y: 0, z: 0 },
6150
+ scale: { x: 1, y: 1, z: 1 }
6151
+ };
6152
+ instanceTransformToMatrix4(inst, _matrix);
6153
+ instancedMesh.setMatrixAt(i, _matrix);
6154
+ }
6155
+ instancedMesh.instanceMatrix.needsUpdate = true;
6156
+ anchor.add(instancedMesh);
6157
+ comp.instancedMesh = instancedMesh;
6158
+ this.geometrySignatures.set(entityId, geometrySignature);
6159
+ } else {
6160
+ if (comp.meshKind === "model") {
6161
+ const entries = this.modelMeshEntries.get(entityId);
6162
+ if (entries) {
6163
+ const count = comp.instances.length;
6164
+ for (const entry of entries) {
6165
+ for (let i = 0; i < count; i++) {
6166
+ instanceTransformToMatrix4(comp.instances[i], _matrix);
6167
+ _modelMatrix.multiplyMatrices(_matrix, entry.localMatrix);
6168
+ entry.instancedMesh.setMatrixAt(i, _modelMatrix);
6169
+ }
6170
+ entry.instancedMesh.instanceMatrix.needsUpdate = true;
6171
+ entry.instancedMesh.castShadow = comp.castShadow;
6172
+ entry.instancedMesh.receiveShadow = comp.receiveShadow;
6173
+ }
6174
+ }
6175
+ } else {
6176
+ const im = comp.instancedMesh;
6177
+ const count = comp.instances.length;
6178
+ for (let i = 0; i < count; i++) {
6179
+ instanceTransformToMatrix4(comp.instances[i], _matrix);
6180
+ im.setMatrixAt(i, _matrix);
6181
+ }
6182
+ im.instanceMatrix.needsUpdate = true;
6183
+ im.castShadow = comp.castShadow;
6184
+ im.receiveShadow = comp.receiveShadow;
6185
+ }
6186
+ }
6187
+ }
6188
+ }
6189
+ };
6190
+ __name(_InstancedMeshSystem, "InstancedMeshSystem");
6191
+ var InstancedMeshSystem = _InstancedMeshSystem;
5788
6192
 
5789
6193
  // core/systems/RenderSystem.ts
5790
6194
  var _RenderSystem = class _RenderSystem {
@@ -5876,7 +6280,7 @@ var _Behaviour = class _Behaviour {
5876
6280
  if (!this.threeRef) {
5877
6281
  return null;
5878
6282
  }
5879
- const position = new THREE33__namespace.Vector3();
6283
+ const position = new THREE34__namespace.Vector3();
5880
6284
  this.threeRef.object.getWorldPosition(position);
5881
6285
  return position;
5882
6286
  }
@@ -5888,7 +6292,7 @@ var _Behaviour = class _Behaviour {
5888
6292
  if (!this.threeRef) {
5889
6293
  return null;
5890
6294
  }
5891
- const target = new THREE33__namespace.Vector3();
6295
+ const target = new THREE34__namespace.Vector3();
5892
6296
  this.threeRef.object.getWorldDirection(target);
5893
6297
  return target;
5894
6298
  }
@@ -5950,7 +6354,7 @@ var _Behaviour = class _Behaviour {
5950
6354
  if (!this.threeRef) {
5951
6355
  return;
5952
6356
  }
5953
- const rotation = new THREE33__namespace.Quaternion();
6357
+ const rotation = new THREE34__namespace.Quaternion();
5954
6358
  this.threeRef.object.getWorldQuaternion(rotation);
5955
6359
  rotation.slerp(targetRotation, alpha);
5956
6360
  this.transform.setRotation(rotation);
@@ -5967,7 +6371,7 @@ var _Behaviour = class _Behaviour {
5967
6371
  return;
5968
6372
  }
5969
6373
  const clone = this.threeRef.object.clone();
5970
- const rotation = new THREE33__namespace.Quaternion();
6374
+ const rotation = new THREE34__namespace.Quaternion();
5971
6375
  clone.lookAt(targetPosition);
5972
6376
  clone.getWorldQuaternion(rotation);
5973
6377
  this.transform.setRotation(rotation);
@@ -6268,8 +6672,8 @@ var _ScriptBehaviourSystem = class _ScriptBehaviourSystem {
6268
6672
  }, "onPointerUp");
6269
6673
  this.moduleLoader = moduleLoader ?? defaultModuleLoader;
6270
6674
  this.selectionCtx = selectionContext ?? null;
6271
- this.raycaster = new THREE33__namespace.Raycaster();
6272
- this.ndcPointer = new THREE33__namespace.Vector2();
6675
+ this.raycaster = new THREE34__namespace.Raycaster();
6676
+ this.ndcPointer = new THREE34__namespace.Vector2();
6273
6677
  if (this.selectionCtx) {
6274
6678
  this.selectionCtx.domElement.addEventListener("pointerdown", this.onPointerDown);
6275
6679
  this.selectionCtx.domElement.addEventListener("pointerup", this.onPointerUp);
@@ -6667,7 +7071,7 @@ var _AudioSystem = class _AudioSystem {
6667
7071
  if (!prev || prev.volume !== opts.volume) {
6668
7072
  sound.setVolume(opts.volume);
6669
7073
  }
6670
- if (opts.positional && sound instanceof THREE33__namespace.PositionalAudio) {
7074
+ if (opts.positional && sound instanceof THREE34__namespace.PositionalAudio) {
6671
7075
  if (!prev || prev.refDistance !== opts.refDistance) {
6672
7076
  sound.setRefDistance(opts.refDistance);
6673
7077
  }
@@ -6779,7 +7183,7 @@ var _VideoSystem = class _VideoSystem {
6779
7183
  component.object.scale.set(opts.width, opts.height, 1);
6780
7184
  }
6781
7185
  const material = component.material;
6782
- if (material instanceof THREE33__namespace.ShaderMaterial) {
7186
+ if (material instanceof THREE34__namespace.ShaderMaterial) {
6783
7187
  if (!prev || prev.backgroundColor !== opts.backgroundColor) {
6784
7188
  material.uniforms.keyColor.value.set(opts.backgroundColor);
6785
7189
  }
@@ -6793,7 +7197,7 @@ var _VideoSystem = class _VideoSystem {
6793
7197
  material.uniforms.spill.value = opts.spill;
6794
7198
  }
6795
7199
  }
6796
- if (opts.positional && component.audioNode instanceof THREE33__namespace.PositionalAudio) {
7200
+ if (opts.positional && component.audioNode instanceof THREE34__namespace.PositionalAudio) {
6797
7201
  const posAudio = component.audioNode;
6798
7202
  if (!prev || prev.refDistance !== opts.refDistance) {
6799
7203
  posAudio.setRefDistance(opts.refDistance);
@@ -7152,6 +7556,7 @@ var _World = class _World {
7152
7556
  isEditor ?? false
7153
7557
  );
7154
7558
  const meshGeometrySystem = new MeshGeometrySystem();
7559
+ const instancedMeshSystem = new InstancedMeshSystem();
7155
7560
  const environmentSyncSystem = this.featureFlags.supportSkybox ? new EnvironmentSyncSystem(this.scene) : null;
7156
7561
  const postprocessingSyncSystem = this.featureFlags.supportPostprocessing ? new PostprocessingSyncSystem(this.renderer, this.scene, this.camera) : null;
7157
7562
  const lightSyncSystem = new LightSyncSystem();
@@ -7174,7 +7579,8 @@ var _World = class _World {
7174
7579
  this.inputSystem = null;
7175
7580
  const coreSystems = [
7176
7581
  objectManagementSystem,
7177
- meshGeometrySystem
7582
+ meshGeometrySystem,
7583
+ instancedMeshSystem
7178
7584
  ];
7179
7585
  if (environmentSyncSystem) {
7180
7586
  coreSystems.push(environmentSyncSystem);
@@ -7387,8 +7793,8 @@ var _World = class _World {
7387
7793
  * ```
7388
7794
  */
7389
7795
  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(
7796
+ const rayOrigin = new THREE34__namespace.Vector3(origin.x, origin.y, origin.z);
7797
+ const rayDirection = new THREE34__namespace.Vector3(
7392
7798
  direction.x,
7393
7799
  direction.y,
7394
7800
  direction.z
@@ -7397,7 +7803,7 @@ var _World = class _World {
7397
7803
  return [];
7398
7804
  }
7399
7805
  rayDirection.normalize();
7400
- const raycaster = new THREE33__namespace.Raycaster(rayOrigin, rayDirection, near, far);
7806
+ const raycaster = new THREE34__namespace.Raycaster(rayOrigin, rayDirection, near, far);
7401
7807
  const intersections = raycaster.intersectObjects(
7402
7808
  this.scene.children,
7403
7809
  true
@@ -7431,14 +7837,14 @@ var _World = class _World {
7431
7837
  if (!sourceObject) {
7432
7838
  return [];
7433
7839
  }
7434
- const rayOrigin = new THREE33__namespace.Vector3();
7435
- const rayDirection = new THREE33__namespace.Vector3();
7840
+ const rayOrigin = new THREE34__namespace.Vector3();
7841
+ const rayDirection = new THREE34__namespace.Vector3();
7436
7842
  sourceObject.getWorldPosition(rayOrigin);
7437
7843
  sourceObject.getWorldDirection(rayDirection);
7438
7844
  if (rayDirection.lengthSq() === 0) {
7439
7845
  return [];
7440
7846
  }
7441
- const raycaster = new THREE33__namespace.Raycaster(rayOrigin, rayDirection, near, far);
7847
+ const raycaster = new THREE34__namespace.Raycaster(rayOrigin, rayDirection, near, far);
7442
7848
  const intersections = raycaster.intersectObjects(
7443
7849
  this.scene.children,
7444
7850
  true
@@ -7731,7 +8137,8 @@ function buildComponentValueMaps(snapshot) {
7731
8137
  physicsValues: readByComponent(snapshot.components, "PhysicsComponent"),
7732
8138
  animationValues: readByComponent(snapshot.components, "AnimationComponent"),
7733
8139
  imageTargetAnchorValues: readByComponent(snapshot.components, "ImageTargetAnchor"),
7734
- scriptValues: readByComponent(snapshot.components, "ScriptComponent")
8140
+ scriptValues: readByComponent(snapshot.components, "ScriptComponent"),
8141
+ instancedMeshValues: readByComponent(snapshot.components, "InstancedMeshComponent")
7735
8142
  };
7736
8143
  }
7737
8144
  __name(buildComponentValueMaps, "buildComponentValueMaps");
@@ -8328,6 +8735,32 @@ function restoreComponentState(world, objectManagementSystem, targetEntityId, so
8328
8735
  sourceAnimation
8329
8736
  );
8330
8737
  }
8738
+ const sourceInstancedMesh = asRecord3(values.instancedMeshValues.get(sourceEntityId));
8739
+ if (sourceInstancedMesh) {
8740
+ const imComponent = world.getComponent(targetEntityId, InstancedMeshComponent);
8741
+ if (imComponent) {
8742
+ if (typeof sourceInstancedMesh.meshKind === "string") {
8743
+ imComponent.meshKind = sourceInstancedMesh.meshKind;
8744
+ }
8745
+ if (typeof sourceInstancedMesh.modelPath === "string") {
8746
+ imComponent.modelPath = sourceInstancedMesh.modelPath;
8747
+ }
8748
+ const parameters = asRecord3(sourceInstancedMesh.meshParameters);
8749
+ if (parameters) {
8750
+ imComponent.meshParameters = parameters;
8751
+ }
8752
+ if (typeof sourceInstancedMesh.castShadow === "boolean") {
8753
+ imComponent.castShadow = sourceInstancedMesh.castShadow;
8754
+ }
8755
+ if (typeof sourceInstancedMesh.receiveShadow === "boolean") {
8756
+ imComponent.receiveShadow = sourceInstancedMesh.receiveShadow;
8757
+ }
8758
+ if (Array.isArray(sourceInstancedMesh.instances)) {
8759
+ imComponent.instances = sourceInstancedMesh.instances;
8760
+ }
8761
+ imComponent.instancedMesh = null;
8762
+ }
8763
+ }
8331
8764
  }
8332
8765
  __name(restoreComponentState, "restoreComponentState");
8333
8766
 
@@ -8350,7 +8783,8 @@ var HYDRATABLE_ENTITY_KINDS = /* @__PURE__ */ new Set([
8350
8783
  "directionalLight",
8351
8784
  "pointLight",
8352
8785
  "spotLight",
8353
- "areaLight"
8786
+ "areaLight",
8787
+ "instancedMesh"
8354
8788
  ]);
8355
8789
 
8356
8790
  // core/hydration/hydrateWorld.ts
@@ -8427,6 +8861,18 @@ function buildEntityCreationPayload(sourceEntityId, kind, componentValues) {
8427
8861
  };
8428
8862
  }
8429
8863
  }
8864
+ if (kind === "instancedMesh") {
8865
+ const im = asRecord3(componentValues.instancedMeshValues.get(sourceEntityId));
8866
+ if (im) {
8867
+ payload.options = {
8868
+ meshKind: typeof im.meshKind === "string" ? im.meshKind : "cube",
8869
+ meshParameters: asRecord3(im.meshParameters) ?? void 0,
8870
+ castShadow: typeof im.castShadow === "boolean" ? im.castShadow : false,
8871
+ receiveShadow: typeof im.receiveShadow === "boolean" ? im.receiveShadow : false,
8872
+ instances: Array.isArray(im.instances) ? im.instances : void 0
8873
+ };
8874
+ }
8875
+ }
8430
8876
  return payload;
8431
8877
  }
8432
8878
  __name(buildEntityCreationPayload, "buildEntityCreationPayload");
@@ -8549,6 +8995,7 @@ exports.CoreComponents = components_exports;
8549
8995
  exports.EnvironmentSyncSystem = EnvironmentSyncSystem;
8550
8996
  exports.HYDRATABLE_ENTITY_KINDS = HYDRATABLE_ENTITY_KINDS;
8551
8997
  exports.InputSystem = InputSystem;
8998
+ exports.InstancedMeshSystem = InstancedMeshSystem;
8552
8999
  exports.KeyboardKeys = KeyboardKeys;
8553
9000
  exports.LightSyncSystem = LightSyncSystem;
8554
9001
  exports.MaterialSyncSystem = MaterialSyncSystem;
@@ -8570,6 +9017,7 @@ exports.createEnvironmentComponent = createEnvironmentComponent;
8570
9017
  exports.createImageComponent = createImageComponent;
8571
9018
  exports.createImageTargetAnchorComponent = createImageTargetAnchorComponent;
8572
9019
  exports.createImageTargetComponent = createImageTargetComponent;
9020
+ exports.createInstancedMeshComponent = createInstancedMeshComponent;
8573
9021
  exports.createLightComponent = createLightComponent;
8574
9022
  exports.createMaterialComponent = createMaterialComponent;
8575
9023
  exports.createMeshComponent = createMeshComponent;