@relu-interactives/spatial-ecs 0.2.21 → 0.2.22

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-me3iAcMF.d.cts → System-CYWZ_Zx5.d.cts} +4 -3
  2. package/dist/{System-me3iAcMF.d.ts → System-CYWZ_Zx5.d.ts} +4 -3
  3. package/dist/{Video-DHnxjGhW.d.ts → Video-C1IOat7L.d.ts} +38 -9
  4. package/dist/{Video-U9hAnf9y.d.cts → Video-ppAXaKt0.d.cts} +38 -9
  5. package/dist/{chunk-K6KMKKJ6.js → chunk-52CHDPRQ.js} +118 -92
  6. package/dist/chunk-52CHDPRQ.js.map +1 -0
  7. package/dist/{chunk-5U3YS4JD.js → chunk-GZ2NKSMV.js} +421 -65
  8. package/dist/chunk-GZ2NKSMV.js.map +1 -0
  9. package/dist/{chunk-V7BNVTJW.js → chunk-JHCPRVBC.js} +25 -4
  10. package/dist/chunk-JHCPRVBC.js.map +1 -0
  11. package/dist/{chunk-AXRCGF63.js → chunk-WKGCC7YL.js} +3 -3
  12. package/dist/{chunk-AXRCGF63.js.map → chunk-WKGCC7YL.js.map} +1 -1
  13. package/dist/components/index.cjs +22 -1
  14. package/dist/components/index.cjs.map +1 -1
  15. package/dist/components/index.d.cts +3 -3
  16. package/dist/components/index.d.ts +3 -3
  17. package/dist/components/index.js +1 -1
  18. package/dist/docs/guide/authoring-a-behaviour.md +3 -40
  19. package/dist/docs/guide/authoring-a-script-object.md +102 -0
  20. package/dist/docs/guide/behaviour-lifecycle.md +4 -4
  21. package/dist/docs/guide/spawning/script-object.md +36 -0
  22. package/dist/docs/guide/systems/_sidebar.json +4 -0
  23. package/dist/docs/guide/systems/script-behaviour-system.md +1 -17
  24. package/dist/docs/guide/systems/script-object-system.md +44 -0
  25. package/dist/factories/index.cjs +164 -117
  26. package/dist/factories/index.cjs.map +1 -1
  27. package/dist/factories/index.d.cts +5 -3
  28. package/dist/factories/index.d.ts +5 -3
  29. package/dist/factories/index.js +3 -3
  30. package/dist/{index-D7FSg0Au.d.ts → index-Cu2Pt7wN.d.cts} +6 -3
  31. package/dist/{index-CZo5I5Gs.d.cts → index-DdiWu1b6.d.ts} +6 -3
  32. package/dist/index.cjs +677 -265
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +117 -28
  35. package/dist/index.d.ts +117 -28
  36. package/dist/index.js +13 -8
  37. package/dist/index.js.map +1 -1
  38. package/dist/systems/index.cjs +403 -36
  39. package/dist/systems/index.cjs.map +1 -1
  40. package/dist/systems/index.d.cts +44 -3
  41. package/dist/systems/index.d.ts +44 -3
  42. package/dist/systems/index.js +3 -3
  43. package/dist/types.d.cts +1 -1
  44. package/dist/types.d.ts +1 -1
  45. package/dist/worldSnapshotUtils.d.cts +1 -1
  46. package/dist/worldSnapshotUtils.d.ts +1 -1
  47. package/package.json +1 -1
  48. package/dist/chunk-5U3YS4JD.js.map +0 -1
  49. package/dist/chunk-K6KMKKJ6.js.map +0 -1
  50. package/dist/chunk-V7BNVTJW.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import { createTransform, applyTransform, resolveDracoDecoderPath, loadSharedGltf, cloneModelScene } from './chunk-AXRCGF63.js';
2
- import { AnimationComponent, AudioComponent, Object3DRef, CameraComponent, MeshGeometryComponent, PhysicsComponent, Environment, EntityType, ImageComponent, ImageTargetAnchor, ImageTarget, LightComponent, MaterialComponent, MeshComponent, ModelComponent, Name, ParentId, Postprocessing, ScriptComponent, Selectable, SelectionTransformState, SpriteComponent, TransformComponent, InstancedMeshComponent, InstanceSlotComponent, VideoComponent, DEFAULT_INSTANCE_TRANSFORM } from './chunk-V7BNVTJW.js';
1
+ import { createTransform, applyTransform, resolveDracoDecoderPath, loadSharedGltf, cloneModelScene } from './chunk-WKGCC7YL.js';
2
+ import { AnimationComponent, AudioComponent, Object3DRef, CameraComponent, MeshGeometryComponent, PhysicsComponent, Environment, EntityType, ImageComponent, ImageTargetAnchor, ImageTarget, LightComponent, MaterialComponent, MeshComponent, ModelComponent, Name, ParentId, Postprocessing, ScriptComponent, ScriptObjectComponent, Selectable, SelectionTransformState, SpriteComponent, TransformComponent, InstancedMeshComponent, InstanceSlotComponent, VideoComponent, DEFAULT_INSTANCE_TRANSFORM } from './chunk-JHCPRVBC.js';
3
3
  import { __name } from './chunk-OY7ZODZP.js';
4
- import * as THREE21 from 'three';
4
+ import * as THREE22 from 'three';
5
5
  import { RectAreaLightHelper } from 'three/examples/jsm/helpers/RectAreaLightHelper.js';
6
6
  import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
7
7
  import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
@@ -22,11 +22,11 @@ function normalizeDistanceModel(distanceModel) {
22
22
  }
23
23
  __name(normalizeDistanceModel, "normalizeDistanceModel");
24
24
  function createConfiguredAudio(listener, options) {
25
- const sound = options.positional ? new THREE21.PositionalAudio(listener) : new THREE21.Audio(listener);
25
+ const sound = options.positional ? new THREE22.PositionalAudio(listener) : new THREE22.Audio(listener);
26
26
  sound.setLoop(options.loop);
27
27
  sound.setVolume(options.volume);
28
28
  sound.setPlaybackRate(options.pitch);
29
- if (sound instanceof THREE21.PositionalAudio) {
29
+ if (sound instanceof THREE22.PositionalAudio) {
30
30
  sound.setRefDistance(options.refDistance);
31
31
  sound.setDistanceModel(normalizeDistanceModel(options.distanceModel));
32
32
  sound.setRolloffFactor(options.rolloffFactor);
@@ -36,16 +36,16 @@ function createConfiguredAudio(listener, options) {
36
36
  __name(createConfiguredAudio, "createConfiguredAudio");
37
37
  function createAudioEditorHelper() {
38
38
  if (typeof document === "undefined") {
39
- const geometry = new THREE21.EdgesGeometry(
40
- new THREE21.OctahedronGeometry(0.22, 0)
39
+ const geometry = new THREE22.EdgesGeometry(
40
+ new THREE22.OctahedronGeometry(0.22, 0)
41
41
  );
42
- const material2 = new THREE21.LineBasicMaterial({
42
+ const material2 = new THREE22.LineBasicMaterial({
43
43
  color: "#8bc8ff",
44
44
  transparent: true,
45
45
  opacity: 0.95,
46
46
  depthTest: false
47
47
  });
48
- const fallback = new THREE21.LineSegments(geometry, material2);
48
+ const fallback = new THREE22.LineSegments(geometry, material2);
49
49
  fallback.renderOrder = 10;
50
50
  fallback.userData.ecsHelper = true;
51
51
  fallback.visible = false;
@@ -57,7 +57,7 @@ function createAudioEditorHelper() {
57
57
  canvas.height = size;
58
58
  const ctx = canvas.getContext("2d");
59
59
  if (!ctx) {
60
- return new THREE21.Object3D();
60
+ return new THREE22.Object3D();
61
61
  }
62
62
  ctx.clearRect(0, 0, size, size);
63
63
  ctx.fillStyle = "rgba(27, 35, 52, 0.9)";
@@ -88,14 +88,14 @@ function createAudioEditorHelper() {
88
88
  ctx.beginPath();
89
89
  ctx.arc(56, 48, 16, -0.8, 0.8);
90
90
  ctx.stroke();
91
- const texture = new THREE21.CanvasTexture(canvas);
91
+ const texture = new THREE22.CanvasTexture(canvas);
92
92
  texture.needsUpdate = true;
93
- const material = new THREE21.SpriteMaterial({
93
+ const material = new THREE22.SpriteMaterial({
94
94
  map: texture,
95
95
  transparent: true,
96
96
  depthTest: false
97
97
  });
98
- const helper = new THREE21.Sprite(material);
98
+ const helper = new THREE22.Sprite(material);
99
99
  helper.scale.set(0.68, 0.68, 0.68);
100
100
  helper.renderOrder = 10;
101
101
  helper.userData.ecsHelper = true;
@@ -122,7 +122,7 @@ function createAudioComponent(world, entityId, path = "", options = {}, context)
122
122
  __name(createAudioComponent, "createAudioComponent");
123
123
  function createCameraComponent(world, entityId, payload = {}) {
124
124
  const object = world.getComponent(entityId, Object3DRef)?.object;
125
- const objectCamera = object instanceof THREE21.Camera ? object : void 0;
125
+ const objectCamera = object instanceof THREE22.Camera ? object : void 0;
126
126
  const component = new CameraComponent({
127
127
  ...payload,
128
128
  camera: payload.camera ?? objectCamera
@@ -326,6 +326,14 @@ function createScriptComponent(world, entityId, payload = {}) {
326
326
  }
327
327
  __name(createScriptComponent, "createScriptComponent");
328
328
 
329
+ // core/factories/components/ScriptObjectComponentFactory.ts
330
+ function createScriptObjectComponent(world, entityId, payload = {}) {
331
+ const component = new ScriptObjectComponent(payload);
332
+ world.addComponent(entityId, component);
333
+ return component;
334
+ }
335
+ __name(createScriptObjectComponent, "createScriptObjectComponent");
336
+
329
337
  // core/factories/components/SelectableFactory.ts
330
338
  function createSelectableComponent(world, entityId, ...args) {
331
339
  const component = new Selectable(...args);
@@ -415,6 +423,10 @@ function registerDefaultComponentFactories(objectManagementSystem) {
415
423
  createPostprocessingComponent
416
424
  );
417
425
  objectManagementSystem.registerComponentFactory("script", createScriptComponent);
426
+ objectManagementSystem.registerComponentFactory(
427
+ "scriptObject",
428
+ createScriptObjectComponent
429
+ );
418
430
  objectManagementSystem.registerComponentFactory("selectable", createSelectableComponent);
419
431
  objectManagementSystem.registerComponentFactory(
420
432
  "selectionTransformState",
@@ -446,10 +458,10 @@ __name(createBaseEntity, "createBaseEntity");
446
458
  // core/factories/objects/AudioFactory.ts
447
459
  function getOrCreateListener(camera) {
448
460
  const existing = camera.userData.ecsAudioListener;
449
- if (existing instanceof THREE21.AudioListener) {
461
+ if (existing instanceof THREE22.AudioListener) {
450
462
  return existing;
451
463
  }
452
- const listener = new THREE21.AudioListener();
464
+ const listener = new THREE22.AudioListener();
453
465
  camera.add(listener);
454
466
  camera.userData.ecsAudioListener = listener;
455
467
  return listener;
@@ -462,7 +474,7 @@ function createAudio({
462
474
  payload,
463
475
  isEditor
464
476
  }) {
465
- const anchor = new THREE21.Object3D();
477
+ const anchor = new THREE22.Object3D();
466
478
  const entityId = createBaseEntity(world, anchor, {
467
479
  label: payload.name ?? "Audio",
468
480
  entityType: "audio",
@@ -484,7 +496,7 @@ function createAudio({
484
496
  return entityId;
485
497
  }
486
498
  if (!isEditor) {
487
- const loader = new THREE21.AudioLoader();
499
+ const loader = new THREE22.AudioLoader();
488
500
  loader.load(
489
501
  audio.path,
490
502
  (buffer) => {
@@ -559,7 +571,7 @@ function applyCameraSettings(camera, options) {
559
571
  const near = typeof options.near === "number" ? options.near : DEFAULT_NEAR;
560
572
  const far = typeof options.far === "number" ? options.far : DEFAULT_FAR;
561
573
  const projection = options.projection;
562
- if (camera instanceof THREE21.PerspectiveCamera) {
574
+ if (camera instanceof THREE22.PerspectiveCamera) {
563
575
  if (!projection || projection === "perspective") {
564
576
  camera.fov = typeof options.fov === "number" ? options.fov : DEFAULT_FOV;
565
577
  }
@@ -569,7 +581,7 @@ function applyCameraSettings(camera, options) {
569
581
  camera.updateProjectionMatrix();
570
582
  return;
571
583
  }
572
- if (camera instanceof THREE21.OrthographicCamera) {
584
+ if (camera instanceof THREE22.OrthographicCamera) {
573
585
  camera.left = typeof options.left === "number" ? options.left : -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
574
586
  camera.right = typeof options.right === "number" ? options.right : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
575
587
  camera.top = typeof options.top === "number" ? options.top : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
@@ -590,7 +602,7 @@ function createCameraObject(options) {
590
602
  const bottom = options.bottom ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
591
603
  const left = options.left ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
592
604
  const right = options.right ?? DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
593
- const camera = new THREE21.OrthographicCamera(
605
+ const camera = new THREE22.OrthographicCamera(
594
606
  left,
595
607
  right,
596
608
  top,
@@ -602,7 +614,7 @@ function createCameraObject(options) {
602
614
  camera.updateProjectionMatrix();
603
615
  return camera;
604
616
  }
605
- return new THREE21.PerspectiveCamera(
617
+ return new THREE22.PerspectiveCamera(
606
618
  options.fov ?? DEFAULT_FOV,
607
619
  readViewportAspect(),
608
620
  near,
@@ -620,7 +632,7 @@ function createCamera({ world, scene, camera, payload, isEditor }) {
620
632
  transformInput: payload.transform
621
633
  });
622
634
  const objectRef = world.getComponent(entityId, Object3DRef);
623
- if (objectRef?.object instanceof THREE21.Camera) {
635
+ if (objectRef?.object instanceof THREE22.Camera) {
624
636
  objectRef.object.userData.entityId = entityId;
625
637
  }
626
638
  const componentOptions = {
@@ -637,20 +649,11 @@ function createCamera({ world, scene, camera, payload, isEditor }) {
637
649
  bottom: options.bottom,
638
650
  zoom: options.zoom
639
651
  };
640
- const component = createCameraComponent(world, entityId, componentOptions);
652
+ createCameraComponent(world, entityId, componentOptions);
641
653
  if (useWorldCamera) {
642
654
  applyCameraSettings(object, options);
643
655
  } else {
644
656
  applyCameraSettings(object, options);
645
- if (isEditor && component.isDefault) {
646
- const helper = new THREE21.CameraHelper(object);
647
- helper.onBeforeRender = () => {
648
- helper.update();
649
- };
650
- helper.userData.ecsHelper = true;
651
- helper.visible = false;
652
- object.add(helper);
653
- }
654
657
  scene.add(object);
655
658
  }
656
659
  return entityId;
@@ -661,9 +664,9 @@ function createCapsule({
661
664
  scene,
662
665
  payload
663
666
  }) {
664
- const geometry = new THREE21.CapsuleGeometry(0.5, 1, 4, 8);
665
- const material = new THREE21.MeshStandardMaterial({ color: "#ffffff" });
666
- const mesh = new THREE21.Mesh(geometry, material);
667
+ const geometry = new THREE22.CapsuleGeometry(0.5, 1, 4, 8);
668
+ const material = new THREE22.MeshStandardMaterial({ color: "#ffffff" });
669
+ const mesh = new THREE22.Mesh(geometry, material);
667
670
  const entityId = createBaseEntity(world, mesh, {
668
671
  label: payload.name ?? "Capsule",
669
672
  entityType: "capsule",
@@ -683,9 +686,9 @@ function createCapsule({
683
686
  }
684
687
  __name(createCapsule, "createCapsule");
685
688
  function createCube({ world, scene, payload }) {
686
- const geometry = new THREE21.BoxGeometry(1, 1, 1);
687
- const material = new THREE21.MeshStandardMaterial({ color: "#ffffff" });
688
- const mesh = new THREE21.Mesh(geometry, material);
689
+ const geometry = new THREE22.BoxGeometry(1, 1, 1);
690
+ const material = new THREE22.MeshStandardMaterial({ color: "#ffffff" });
691
+ const mesh = new THREE22.Mesh(geometry, material);
689
692
  const entityId = createBaseEntity(world, mesh, {
690
693
  label: payload.name ?? "Cube",
691
694
  entityType: "cube",
@@ -710,9 +713,9 @@ function createCylinder({
710
713
  scene,
711
714
  payload
712
715
  }) {
713
- const geometry = new THREE21.CylinderGeometry(0.5, 0.5, 1, 20);
714
- const material = new THREE21.MeshStandardMaterial({ color: "#ffffff" });
715
- const mesh = new THREE21.Mesh(geometry, material);
716
+ const geometry = new THREE22.CylinderGeometry(0.5, 0.5, 1, 20);
717
+ const material = new THREE22.MeshStandardMaterial({ color: "#ffffff" });
718
+ const mesh = new THREE22.Mesh(geometry, material);
716
719
  const entityId = createBaseEntity(world, mesh, {
717
720
  label: payload.name ?? "Cylinder",
718
721
  entityType: "cylinder",
@@ -732,7 +735,7 @@ function createCylinder({
732
735
  }
733
736
  __name(createCylinder, "createCylinder");
734
737
  function createEmpty({ world, scene, payload, isEditor }) {
735
- const object = new THREE21.Group();
738
+ const object = new THREE22.Group();
736
739
  const entityId = createBaseEntity(world, object, {
737
740
  label: payload.name ?? "Empty",
738
741
  entityType: "empty",
@@ -743,7 +746,7 @@ function createEmpty({ world, scene, payload, isEditor }) {
743
746
  }
744
747
  __name(createEmpty, "createEmpty");
745
748
  function createImage({ world, scene, payload }) {
746
- const anchor = new THREE21.Object3D();
749
+ const anchor = new THREE22.Object3D();
747
750
  const imagePath = payload.path ?? "";
748
751
  const entityId = createBaseEntity(world, anchor, {
749
752
  label: payload.name ?? "Image",
@@ -756,7 +759,7 @@ function createImage({ world, scene, payload }) {
756
759
  if (!imagePath) {
757
760
  return entityId;
758
761
  }
759
- const loader = new THREE21.TextureLoader();
762
+ const loader = new THREE22.TextureLoader();
760
763
  loader.load(
761
764
  imagePath,
762
765
  (texture) => {
@@ -764,13 +767,13 @@ function createImage({ world, scene, payload }) {
764
767
  texture.dispose();
765
768
  return;
766
769
  }
767
- const material = new THREE21.MeshBasicMaterial({
770
+ const material = new THREE22.MeshBasicMaterial({
768
771
  map: texture,
769
772
  transparent: true,
770
- side: THREE21.DoubleSide
773
+ side: THREE22.DoubleSide
771
774
  });
772
- const geometry = new THREE21.PlaneGeometry(1, 1);
773
- const plane = new THREE21.Mesh(geometry, material);
775
+ const geometry = new THREE22.PlaneGeometry(1, 1);
776
+ const plane = new THREE22.Mesh(geometry, material);
774
777
  plane.userData.entityId = entityId;
775
778
  const textureImage = texture.image;
776
779
  const width = textureImage?.width ?? 1;
@@ -816,7 +819,7 @@ function createImageTarget({
816
819
  payload,
817
820
  isEditor
818
821
  }) {
819
- const anchor = new THREE21.Object3D();
822
+ const anchor = new THREE22.Object3D();
820
823
  const imagePath = payload.path ?? "";
821
824
  const entityId = createBaseEntity(world, anchor, {
822
825
  label: payload.name ?? "Image Target",
@@ -833,7 +836,7 @@ function createImageTarget({
833
836
  if (!isEditor || !imagePath) {
834
837
  return entityId;
835
838
  }
836
- const loader = new THREE21.TextureLoader();
839
+ const loader = new THREE22.TextureLoader();
837
840
  loader.load(
838
841
  imagePath,
839
842
  (texture) => {
@@ -841,13 +844,13 @@ function createImageTarget({
841
844
  texture.dispose();
842
845
  return;
843
846
  }
844
- const material = new THREE21.MeshBasicMaterial({
847
+ const material = new THREE22.MeshBasicMaterial({
845
848
  map: texture,
846
849
  transparent: true,
847
- side: THREE21.DoubleSide
850
+ side: THREE22.DoubleSide
848
851
  });
849
- const geometry = new THREE21.PlaneGeometry(1, 1);
850
- const plane = new THREE21.Mesh(geometry, material);
852
+ const geometry = new THREE22.PlaneGeometry(1, 1);
853
+ const plane = new THREE22.Mesh(geometry, material);
851
854
  plane.userData.entityId = entityId;
852
855
  const textureImage = texture.image;
853
856
  const width = textureImage?.width ?? 1;
@@ -898,7 +901,7 @@ function createInstancedMesh({
898
901
  scene,
899
902
  payload
900
903
  }) {
901
- const anchor = new THREE21.Object3D();
904
+ const anchor = new THREE22.Object3D();
902
905
  const opts = payload.options ?? {};
903
906
  const meshKind = isInstancedMeshKind(opts.meshKind) ? opts.meshKind : "cube";
904
907
  const meshParameters = opts.meshParameters && typeof opts.meshParameters === "object" ? opts.meshParameters : void 0;
@@ -969,7 +972,7 @@ function createAmbientLight({
969
972
  scene,
970
973
  payload
971
974
  }) {
972
- const light = new THREE21.AmbientLight("#ffffff", 0.6);
975
+ const light = new THREE22.AmbientLight("#ffffff", 0.6);
973
976
  const entityId = createBaseEntity(world, light, {
974
977
  label: payload.name ?? "Ambient Light",
975
978
  entityType: "ambientLight",
@@ -986,7 +989,7 @@ function createAreaLight({
986
989
  payload,
987
990
  isEditor
988
991
  }) {
989
- const light = new THREE21.RectAreaLight("#ffffff", 5, 4, 4);
992
+ const light = new THREE22.RectAreaLight("#ffffff", 5, 4, 4);
990
993
  light.lookAt(0, 0, 0);
991
994
  const entityId = createBaseEntity(world, light, {
992
995
  label: payload.name ?? "Area Light",
@@ -1015,7 +1018,7 @@ function createDirectionalLight({
1015
1018
  payload,
1016
1019
  isEditor
1017
1020
  }) {
1018
- const light = new THREE21.DirectionalLight("#ffffff", 1.5);
1021
+ const light = new THREE22.DirectionalLight("#ffffff", 1.5);
1019
1022
  light.castShadow = true;
1020
1023
  const entityId = createBaseEntity(world, light, {
1021
1024
  label: payload.name ?? "Directional Light",
@@ -1026,7 +1029,7 @@ function createDirectionalLight({
1026
1029
  });
1027
1030
  createLightComponent(world, entityId, light);
1028
1031
  if (isEditor) {
1029
- const helper = new THREE21.DirectionalLightHelper(light, 1.8, "#38bdf8");
1032
+ const helper = new THREE22.DirectionalLightHelper(light, 1.8, "#38bdf8");
1030
1033
  helper.onBeforeRender = () => {
1031
1034
  helper.update();
1032
1035
  };
@@ -1044,7 +1047,7 @@ function createPointLight({
1044
1047
  payload,
1045
1048
  isEditor
1046
1049
  }) {
1047
- const light = new THREE21.PointLight("#ffffff", 1, 10);
1050
+ const light = new THREE22.PointLight("#ffffff", 1, 10);
1048
1051
  const entityId = createBaseEntity(world, light, {
1049
1052
  label: payload.name ?? "Point Light",
1050
1053
  entityType: "pointLight",
@@ -1054,7 +1057,7 @@ function createPointLight({
1054
1057
  });
1055
1058
  createLightComponent(world, entityId, light);
1056
1059
  if (isEditor) {
1057
- const helper = new THREE21.PointLightHelper(light, 0.35, "#fbbf24");
1060
+ const helper = new THREE22.PointLightHelper(light, 0.35, "#fbbf24");
1058
1061
  helper.onBeforeRender = () => {
1059
1062
  helper.update();
1060
1063
  };
@@ -1072,7 +1075,7 @@ function createSpotLight({
1072
1075
  payload,
1073
1076
  isEditor
1074
1077
  }) {
1075
- const light = new THREE21.SpotLight("#ffffff", 1, 20, Math.PI / 6, 0.1, 1);
1078
+ const light = new THREE22.SpotLight("#ffffff", 1, 20, Math.PI / 6, 0.1, 1);
1076
1079
  const entityId = createBaseEntity(world, light, {
1077
1080
  label: payload.name ?? "Spot Light",
1078
1081
  entityType: "spotLight",
@@ -1082,7 +1085,7 @@ function createSpotLight({
1082
1085
  });
1083
1086
  createLightComponent(world, entityId, light);
1084
1087
  if (isEditor) {
1085
- const helper = new THREE21.SpotLightHelper(light, "#f59e0b");
1088
+ const helper = new THREE22.SpotLightHelper(light, "#f59e0b");
1086
1089
  helper.onBeforeRender = () => {
1087
1090
  helper.update();
1088
1091
  };
@@ -1117,7 +1120,7 @@ function createModel({
1117
1120
  payload,
1118
1121
  isEditor
1119
1122
  }) {
1120
- const anchor = new THREE21.Object3D();
1123
+ const anchor = new THREE22.Object3D();
1121
1124
  const modelPath = payload.path ?? "";
1122
1125
  const entityId = createBaseEntity(world, anchor, {
1123
1126
  label: payload.name ?? "Model",
@@ -1183,12 +1186,12 @@ function createModel({
1183
1186
  }
1184
1187
  __name(createModel, "createModel");
1185
1188
  function createPlane({ world, scene, payload }) {
1186
- const geometry = new THREE21.PlaneGeometry(100, 100);
1187
- const material = new THREE21.MeshStandardMaterial({
1189
+ const geometry = new THREE22.PlaneGeometry(100, 100);
1190
+ const material = new THREE22.MeshStandardMaterial({
1188
1191
  color: "#ffffff",
1189
- side: THREE21.DoubleSide
1192
+ side: THREE22.DoubleSide
1190
1193
  });
1191
- const mesh = new THREE21.Mesh(geometry, material);
1194
+ const mesh = new THREE22.Mesh(geometry, material);
1192
1195
  const entityId = createBaseEntity(
1193
1196
  world,
1194
1197
  mesh,
@@ -1219,8 +1222,30 @@ function createPlane({ world, scene, payload }) {
1219
1222
  return entityId;
1220
1223
  }
1221
1224
  __name(createPlane, "createPlane");
1225
+ function createScriptObject({
1226
+ world,
1227
+ scene,
1228
+ payload
1229
+ }) {
1230
+ const object = new THREE22.Group();
1231
+ const entityId = createBaseEntity(world, object, {
1232
+ label: payload.name ?? "Script Object",
1233
+ entityType: "scriptObject",
1234
+ transformInput: payload.transform
1235
+ });
1236
+ const options = payload.options ?? {};
1237
+ createScriptObjectComponent(world, entityId, {
1238
+ scriptUrl: typeof options.scriptUrl === "string" ? options.scriptUrl : null,
1239
+ className: typeof options.className === "string" ? options.className : null,
1240
+ enabled: typeof options.enabled === "boolean" ? options.enabled : true,
1241
+ data: options.data && typeof options.data === "object" && !Array.isArray(options.data) ? options.data : {}
1242
+ });
1243
+ scene.add(object);
1244
+ return entityId;
1245
+ }
1246
+ __name(createScriptObject, "createScriptObject");
1222
1247
  function createSprite({ world, scene, payload }) {
1223
- const anchor = new THREE21.Object3D();
1248
+ const anchor = new THREE22.Object3D();
1224
1249
  const imagePath = payload.path ?? "";
1225
1250
  const entityId = createBaseEntity(world, anchor, {
1226
1251
  label: payload.name ?? "Sprite",
@@ -1232,7 +1257,7 @@ function createSprite({ world, scene, payload }) {
1232
1257
  if (!imagePath) {
1233
1258
  return entityId;
1234
1259
  }
1235
- const loader = new THREE21.TextureLoader();
1260
+ const loader = new THREE22.TextureLoader();
1236
1261
  loader.load(
1237
1262
  imagePath,
1238
1263
  (texture) => {
@@ -1240,11 +1265,11 @@ function createSprite({ world, scene, payload }) {
1240
1265
  texture.dispose();
1241
1266
  return;
1242
1267
  }
1243
- const material = new THREE21.SpriteMaterial({
1268
+ const material = new THREE22.SpriteMaterial({
1244
1269
  map: texture,
1245
1270
  transparent: true
1246
1271
  });
1247
- const sprite = new THREE21.Sprite(material);
1272
+ const sprite = new THREE22.Sprite(material);
1248
1273
  sprite.userData.entityId = entityId;
1249
1274
  const textureImage = texture.image;
1250
1275
  spriteComponent.width = textureImage?.width ?? 1;
@@ -1262,9 +1287,9 @@ function createSprite({ world, scene, payload }) {
1262
1287
  }
1263
1288
  __name(createSprite, "createSprite");
1264
1289
  function createSphere({ world, scene, payload }) {
1265
- const geometry = new THREE21.SphereGeometry(0.5, 24, 24);
1266
- const material = new THREE21.MeshStandardMaterial({ color: "#ffffff" });
1267
- const mesh = new THREE21.Mesh(geometry, material);
1290
+ const geometry = new THREE22.SphereGeometry(0.5, 24, 24);
1291
+ const material = new THREE22.MeshStandardMaterial({ color: "#ffffff" });
1292
+ const mesh = new THREE22.Mesh(geometry, material);
1268
1293
  const entityId = createBaseEntity(world, mesh, {
1269
1294
  label: payload.name ?? "Sphere",
1270
1295
  entityType: "sphere",
@@ -1284,10 +1309,10 @@ function createSphere({ world, scene, payload }) {
1284
1309
  __name(createSphere, "createSphere");
1285
1310
  function getOrCreateListener2(camera) {
1286
1311
  const existing = camera.userData.ecsAudioListener;
1287
- if (existing instanceof THREE21.AudioListener) {
1312
+ if (existing instanceof THREE22.AudioListener) {
1288
1313
  return existing;
1289
1314
  }
1290
- const listener = new THREE21.AudioListener();
1315
+ const listener = new THREE22.AudioListener();
1291
1316
  camera.add(listener);
1292
1317
  camera.userData.ecsAudioListener = listener;
1293
1318
  return listener;
@@ -1337,10 +1362,10 @@ function normalizeOptions(input) {
1337
1362
  }
1338
1363
  __name(normalizeOptions, "normalizeOptions");
1339
1364
  function createChromaMaterial(texture, options) {
1340
- return new THREE21.ShaderMaterial({
1365
+ return new THREE22.ShaderMaterial({
1341
1366
  uniforms: {
1342
1367
  tex: { value: texture },
1343
- keyColor: { value: new THREE21.Color(options.backgroundColor) },
1368
+ keyColor: { value: new THREE22.Color(options.backgroundColor) },
1344
1369
  similarity: { value: options.similarity },
1345
1370
  smoothness: { value: options.smoothness },
1346
1371
  spill: { value: options.spill }
@@ -1372,22 +1397,22 @@ function createChromaMaterial(texture, options) {
1372
1397
  }
1373
1398
  `,
1374
1399
  transparent: true,
1375
- side: THREE21.DoubleSide
1400
+ side: THREE22.DoubleSide
1376
1401
  });
1377
1402
  }
1378
1403
  __name(createChromaMaterial, "createChromaMaterial");
1379
1404
  function createStandardMaterial(texture) {
1380
- return new THREE21.MeshBasicMaterial({
1405
+ return new THREE22.MeshBasicMaterial({
1381
1406
  map: texture,
1382
1407
  transparent: true,
1383
- side: THREE21.DoubleSide
1408
+ side: THREE22.DoubleSide
1384
1409
  });
1385
1410
  }
1386
1411
  __name(createStandardMaterial, "createStandardMaterial");
1387
1412
  function createVideoMesh(entityId, texture, options) {
1388
- const geometry = new THREE21.PlaneGeometry(1, 1);
1413
+ const geometry = new THREE22.PlaneGeometry(1, 1);
1389
1414
  const material = options.isGreenScreen ? createChromaMaterial(texture, options) : createStandardMaterial(texture);
1390
- const mesh = new THREE21.Mesh(geometry, material);
1415
+ const mesh = new THREE22.Mesh(geometry, material);
1391
1416
  mesh.userData.entityId = entityId;
1392
1417
  mesh.scale.set(options.width, options.height, 1);
1393
1418
  return { mesh, material };
@@ -1422,7 +1447,7 @@ function createVideo({
1422
1447
  payload,
1423
1448
  isEditor
1424
1449
  }) {
1425
- const anchor = new THREE21.Object3D();
1450
+ const anchor = new THREE22.Object3D();
1426
1451
  const path = payload.path ?? "";
1427
1452
  const options = normalizeOptions(payload.options);
1428
1453
  const entityId = createBaseEntity(world, anchor, {
@@ -1437,8 +1462,8 @@ function createVideo({
1437
1462
  return entityId;
1438
1463
  }
1439
1464
  const video = createVideoElement(path, options);
1440
- const texture = new THREE21.VideoTexture(video);
1441
- texture.colorSpace = THREE21.SRGBColorSpace;
1465
+ const texture = new THREE22.VideoTexture(video);
1466
+ texture.colorSpace = THREE22.SRGBColorSpace;
1442
1467
  texture.needsUpdate = true;
1443
1468
  const { mesh, material } = createVideoMesh(entityId, texture, options);
1444
1469
  anchor.add(mesh);
@@ -1454,7 +1479,7 @@ function createVideo({
1454
1479
  });
1455
1480
  if (!isEditor && options.positional) {
1456
1481
  const listener = getOrCreateListener2(camera);
1457
- const audioNode = new THREE21.PositionalAudio(listener);
1482
+ const audioNode = new THREE22.PositionalAudio(listener);
1458
1483
  audioNode.setVolume(options.volume);
1459
1484
  audioNode.setRefDistance(options.refDistance);
1460
1485
  audioNode.setDistanceModel(normalizeDistanceModel2(options.distanceModel));
@@ -1493,10 +1518,11 @@ function registerDefaultFactories(objectManagementSystem) {
1493
1518
  objectManagementSystem.register("pointLight", createPointLight);
1494
1519
  objectManagementSystem.register("spotLight", createSpotLight);
1495
1520
  objectManagementSystem.register("areaLight", createAreaLight);
1521
+ objectManagementSystem.register("scriptObject", createScriptObject);
1496
1522
  registerDefaultComponentFactories(objectManagementSystem);
1497
1523
  }
1498
1524
  __name(registerDefaultFactories, "registerDefaultFactories");
1499
1525
 
1500
- export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createInstanceSlotComponent, createInstancedMeshComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVideoComponent, registerDefaultComponentFactories, registerDefaultFactories };
1501
- //# sourceMappingURL=chunk-K6KMKKJ6.js.map
1502
- //# sourceMappingURL=chunk-K6KMKKJ6.js.map
1526
+ export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createInstanceSlotComponent, createInstancedMeshComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createScriptObjectComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVideoComponent, registerDefaultComponentFactories, registerDefaultFactories };
1527
+ //# sourceMappingURL=chunk-52CHDPRQ.js.map
1528
+ //# sourceMappingURL=chunk-52CHDPRQ.js.map