@relu-interactives/spatial-ecs 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{System-CYWZ_Zx5.d.cts → System-vrU46Vuw.d.cts} +16 -2
- package/dist/{System-CYWZ_Zx5.d.ts → System-vrU46Vuw.d.ts} +16 -2
- package/dist/{Video-AIQYTAAr.d.cts → XRRig-CAmf04NX.d.ts} +131 -4
- package/dist/{Video-DlZ4G9ig.d.ts → XRRig-Cu-EyliG.d.cts} +131 -4
- package/dist/{chunk-PZ4CAALA.js → chunk-67WGASUJ.js} +3 -3
- package/dist/{chunk-PZ4CAALA.js.map → chunk-67WGASUJ.js.map} +1 -1
- package/dist/{chunk-AT5SPSPM.js → chunk-JWTRFJBL.js} +168 -83
- package/dist/chunk-JWTRFJBL.js.map +1 -0
- package/dist/{chunk-7JFSEV7A.js → chunk-SALBG747.js} +757 -6
- package/dist/chunk-SALBG747.js.map +1 -0
- package/dist/{chunk-7BPHZWQ6.js → chunk-U3MDYKPV.js} +47 -3
- package/dist/chunk-U3MDYKPV.js.map +1 -0
- package/dist/components/index.cjs +44 -0
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +3 -3
- package/dist/components/index.d.ts +3 -3
- package/dist/components/index.js +1 -1
- package/dist/factories/index.cjs +236 -107
- package/dist/factories/index.cjs.map +1 -1
- package/dist/factories/index.d.cts +9 -3
- package/dist/factories/index.d.ts +9 -3
- package/dist/factories/index.js +3 -3
- package/dist/index-Bc0YCz1A.d.cts +514 -0
- package/dist/index-CRmfSYdj.d.ts +514 -0
- package/dist/{index-Gr8aCPRM.d.cts → index-CUFd71ri.d.cts} +12 -3
- package/dist/{index-BwiRJNIT.d.ts → index-w1oqWl_M.d.ts} +12 -3
- package/dist/index.cjs +1107 -198
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -8
- package/dist/index.d.ts +42 -8
- package/dist/index.js +26 -8
- package/dist/index.js.map +1 -1
- package/dist/systems/index.cjs +799 -1
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +3 -278
- package/dist/systems/index.d.ts +3 -278
- package/dist/systems/index.js +3 -3
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/worldSnapshotUtils.d.cts +1 -1
- package/dist/worldSnapshotUtils.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-7BPHZWQ6.js.map +0 -1
- package/dist/chunk-7JFSEV7A.js.map +0 -1
- package/dist/chunk-AT5SPSPM.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createTransform, applyTransform, resolveDracoDecoderPath, loadSharedGltf, cloneModelScene } from './chunk-
|
|
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-
|
|
1
|
+
import { createTransform, applyTransform, resolveDracoDecoderPath, loadSharedGltf, cloneModelScene } from './chunk-67WGASUJ.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, XRRigComponent, VRTeleportAreaComponent, XRInteractableComponent, DEFAULT_INSTANCE_TRANSFORM } from './chunk-U3MDYKPV.js';
|
|
3
3
|
import { __name } from './chunk-OY7ZODZP.js';
|
|
4
|
-
import * as
|
|
4
|
+
import * as THREE24 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
|
|
25
|
+
const sound = options.positional ? new THREE24.PositionalAudio(listener) : new THREE24.Audio(listener);
|
|
26
26
|
sound.setLoop(options.loop);
|
|
27
27
|
sound.setVolume(options.volume);
|
|
28
28
|
sound.setPlaybackRate(options.pitch);
|
|
29
|
-
if (sound instanceof
|
|
29
|
+
if (sound instanceof THREE24.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
|
|
40
|
-
new
|
|
39
|
+
const geometry = new THREE24.EdgesGeometry(
|
|
40
|
+
new THREE24.OctahedronGeometry(0.22, 0)
|
|
41
41
|
);
|
|
42
|
-
const material2 = new
|
|
42
|
+
const material2 = new THREE24.LineBasicMaterial({
|
|
43
43
|
color: "#8bc8ff",
|
|
44
44
|
transparent: true,
|
|
45
45
|
opacity: 0.95,
|
|
46
46
|
depthTest: false
|
|
47
47
|
});
|
|
48
|
-
const fallback = new
|
|
48
|
+
const fallback = new THREE24.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
|
|
60
|
+
return new THREE24.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
|
|
91
|
+
const texture = new THREE24.CanvasTexture(canvas);
|
|
92
92
|
texture.needsUpdate = true;
|
|
93
|
-
const material = new
|
|
93
|
+
const material = new THREE24.SpriteMaterial({
|
|
94
94
|
map: texture,
|
|
95
95
|
transparent: true,
|
|
96
96
|
depthTest: false
|
|
97
97
|
});
|
|
98
|
-
const helper = new
|
|
98
|
+
const helper = new THREE24.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
|
|
125
|
+
const objectCamera = object instanceof THREE24.Camera ? object : void 0;
|
|
126
126
|
const component = new CameraComponent({
|
|
127
127
|
...payload,
|
|
128
128
|
camera: payload.camera ?? objectCamera
|
|
@@ -390,6 +390,30 @@ function createVideoComponent(world, entityId, ...args) {
|
|
|
390
390
|
}
|
|
391
391
|
__name(createVideoComponent, "createVideoComponent");
|
|
392
392
|
|
|
393
|
+
// core/factories/components/XRRigFactory.ts
|
|
394
|
+
function createXRRigComponent(world, entityId, ...args) {
|
|
395
|
+
const component = new XRRigComponent(...args);
|
|
396
|
+
world.addComponent(entityId, component);
|
|
397
|
+
return component;
|
|
398
|
+
}
|
|
399
|
+
__name(createXRRigComponent, "createXRRigComponent");
|
|
400
|
+
|
|
401
|
+
// core/factories/components/VRTeleportAreaFactory.ts
|
|
402
|
+
function createVRTeleportAreaComponent(world, entityId, ...args) {
|
|
403
|
+
const component = new VRTeleportAreaComponent(...args);
|
|
404
|
+
world.addComponent(entityId, component);
|
|
405
|
+
return component;
|
|
406
|
+
}
|
|
407
|
+
__name(createVRTeleportAreaComponent, "createVRTeleportAreaComponent");
|
|
408
|
+
|
|
409
|
+
// core/factories/components/XRInteractableFactory.ts
|
|
410
|
+
function createXRInteractableComponent(world, entityId, ...args) {
|
|
411
|
+
const component = new XRInteractableComponent(...args);
|
|
412
|
+
world.addComponent(entityId, component);
|
|
413
|
+
return component;
|
|
414
|
+
}
|
|
415
|
+
__name(createXRInteractableComponent, "createXRInteractableComponent");
|
|
416
|
+
|
|
393
417
|
// core/factories/registerDefaultComponentFactories.ts
|
|
394
418
|
function registerDefaultComponentFactories(objectManagementSystem) {
|
|
395
419
|
objectManagementSystem.registerComponentFactory("animation", createAnimationComponent);
|
|
@@ -399,6 +423,9 @@ function registerDefaultComponentFactories(objectManagementSystem) {
|
|
|
399
423
|
objectManagementSystem.registerComponentFactory("environment", createEnvironmentComponent);
|
|
400
424
|
objectManagementSystem.registerComponentFactory("entityType", createEntityTypeComponent);
|
|
401
425
|
objectManagementSystem.registerComponentFactory("image", createImageComponent);
|
|
426
|
+
objectManagementSystem.registerComponentFactory("xrRig", createXRRigComponent);
|
|
427
|
+
objectManagementSystem.registerComponentFactory("vrTeleportArea", createVRTeleportAreaComponent);
|
|
428
|
+
objectManagementSystem.registerComponentFactory("xrInteractable", createXRInteractableComponent);
|
|
402
429
|
objectManagementSystem.registerComponentFactory(
|
|
403
430
|
"imageTargetAnchor",
|
|
404
431
|
createImageTargetAnchorComponent
|
|
@@ -458,10 +485,10 @@ __name(createBaseEntity, "createBaseEntity");
|
|
|
458
485
|
// core/factories/objects/AudioFactory.ts
|
|
459
486
|
function getOrCreateListener(camera) {
|
|
460
487
|
const existing = camera.userData.ecsAudioListener;
|
|
461
|
-
if (existing instanceof
|
|
488
|
+
if (existing instanceof THREE24.AudioListener) {
|
|
462
489
|
return existing;
|
|
463
490
|
}
|
|
464
|
-
const listener = new
|
|
491
|
+
const listener = new THREE24.AudioListener();
|
|
465
492
|
camera.add(listener);
|
|
466
493
|
camera.userData.ecsAudioListener = listener;
|
|
467
494
|
return listener;
|
|
@@ -474,7 +501,7 @@ function createAudio({
|
|
|
474
501
|
payload,
|
|
475
502
|
isEditor
|
|
476
503
|
}) {
|
|
477
|
-
const anchor = new
|
|
504
|
+
const anchor = new THREE24.Object3D();
|
|
478
505
|
const entityId = createBaseEntity(world, anchor, {
|
|
479
506
|
label: payload.name ?? "Audio",
|
|
480
507
|
entityType: "audio",
|
|
@@ -496,7 +523,7 @@ function createAudio({
|
|
|
496
523
|
return entityId;
|
|
497
524
|
}
|
|
498
525
|
if (!isEditor) {
|
|
499
|
-
const loader = new
|
|
526
|
+
const loader = new THREE24.AudioLoader();
|
|
500
527
|
loader.load(
|
|
501
528
|
audio.path,
|
|
502
529
|
(buffer) => {
|
|
@@ -571,7 +598,7 @@ function applyCameraSettings(camera, options) {
|
|
|
571
598
|
const near = typeof options.near === "number" ? options.near : DEFAULT_NEAR;
|
|
572
599
|
const far = typeof options.far === "number" ? options.far : DEFAULT_FAR;
|
|
573
600
|
const projection = options.projection;
|
|
574
|
-
if (camera instanceof
|
|
601
|
+
if (camera instanceof THREE24.PerspectiveCamera) {
|
|
575
602
|
if (!projection || projection === "perspective") {
|
|
576
603
|
camera.fov = typeof options.fov === "number" ? options.fov : DEFAULT_FOV;
|
|
577
604
|
}
|
|
@@ -581,7 +608,7 @@ function applyCameraSettings(camera, options) {
|
|
|
581
608
|
camera.updateProjectionMatrix();
|
|
582
609
|
return;
|
|
583
610
|
}
|
|
584
|
-
if (camera instanceof
|
|
611
|
+
if (camera instanceof THREE24.OrthographicCamera) {
|
|
585
612
|
camera.left = typeof options.left === "number" ? options.left : -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
586
613
|
camera.right = typeof options.right === "number" ? options.right : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
587
614
|
camera.top = typeof options.top === "number" ? options.top : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
@@ -602,7 +629,7 @@ function createCameraObject(options) {
|
|
|
602
629
|
const bottom = options.bottom ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
603
630
|
const left = options.left ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
604
631
|
const right = options.right ?? DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
605
|
-
const camera = new
|
|
632
|
+
const camera = new THREE24.OrthographicCamera(
|
|
606
633
|
left,
|
|
607
634
|
right,
|
|
608
635
|
top,
|
|
@@ -614,7 +641,7 @@ function createCameraObject(options) {
|
|
|
614
641
|
camera.updateProjectionMatrix();
|
|
615
642
|
return camera;
|
|
616
643
|
}
|
|
617
|
-
return new
|
|
644
|
+
return new THREE24.PerspectiveCamera(
|
|
618
645
|
options.fov ?? DEFAULT_FOV,
|
|
619
646
|
readViewportAspect(),
|
|
620
647
|
near,
|
|
@@ -632,7 +659,7 @@ function createCamera({ world, scene, camera, payload, isEditor }) {
|
|
|
632
659
|
transformInput: payload.transform
|
|
633
660
|
});
|
|
634
661
|
const objectRef = world.getComponent(entityId, Object3DRef);
|
|
635
|
-
if (objectRef?.object instanceof
|
|
662
|
+
if (objectRef?.object instanceof THREE24.Camera) {
|
|
636
663
|
objectRef.object.userData.entityId = entityId;
|
|
637
664
|
}
|
|
638
665
|
const componentOptions = {
|
|
@@ -664,9 +691,9 @@ function createCapsule({
|
|
|
664
691
|
scene,
|
|
665
692
|
payload
|
|
666
693
|
}) {
|
|
667
|
-
const geometry = new
|
|
668
|
-
const material = new
|
|
669
|
-
const mesh = new
|
|
694
|
+
const geometry = new THREE24.CapsuleGeometry(0.5, 1, 4, 8);
|
|
695
|
+
const material = new THREE24.MeshStandardMaterial({ color: "#ffffff" });
|
|
696
|
+
const mesh = new THREE24.Mesh(geometry, material);
|
|
670
697
|
const entityId = createBaseEntity(world, mesh, {
|
|
671
698
|
label: payload.name ?? "Capsule",
|
|
672
699
|
entityType: "capsule",
|
|
@@ -686,9 +713,9 @@ function createCapsule({
|
|
|
686
713
|
}
|
|
687
714
|
__name(createCapsule, "createCapsule");
|
|
688
715
|
function createCube({ world, scene, payload }) {
|
|
689
|
-
const geometry = new
|
|
690
|
-
const material = new
|
|
691
|
-
const mesh = new
|
|
716
|
+
const geometry = new THREE24.BoxGeometry(1, 1, 1);
|
|
717
|
+
const material = new THREE24.MeshStandardMaterial({ color: "#ffffff" });
|
|
718
|
+
const mesh = new THREE24.Mesh(geometry, material);
|
|
692
719
|
const entityId = createBaseEntity(world, mesh, {
|
|
693
720
|
label: payload.name ?? "Cube",
|
|
694
721
|
entityType: "cube",
|
|
@@ -713,9 +740,9 @@ function createCylinder({
|
|
|
713
740
|
scene,
|
|
714
741
|
payload
|
|
715
742
|
}) {
|
|
716
|
-
const geometry = new
|
|
717
|
-
const material = new
|
|
718
|
-
const mesh = new
|
|
743
|
+
const geometry = new THREE24.CylinderGeometry(0.5, 0.5, 1, 20);
|
|
744
|
+
const material = new THREE24.MeshStandardMaterial({ color: "#ffffff" });
|
|
745
|
+
const mesh = new THREE24.Mesh(geometry, material);
|
|
719
746
|
const entityId = createBaseEntity(world, mesh, {
|
|
720
747
|
label: payload.name ?? "Cylinder",
|
|
721
748
|
entityType: "cylinder",
|
|
@@ -735,7 +762,7 @@ function createCylinder({
|
|
|
735
762
|
}
|
|
736
763
|
__name(createCylinder, "createCylinder");
|
|
737
764
|
function createEmpty({ world, scene, payload, isEditor }) {
|
|
738
|
-
const object = new
|
|
765
|
+
const object = new THREE24.Group();
|
|
739
766
|
const entityId = createBaseEntity(world, object, {
|
|
740
767
|
label: payload.name ?? "Empty",
|
|
741
768
|
entityType: "empty",
|
|
@@ -746,7 +773,7 @@ function createEmpty({ world, scene, payload, isEditor }) {
|
|
|
746
773
|
}
|
|
747
774
|
__name(createEmpty, "createEmpty");
|
|
748
775
|
function createImage({ world, scene, payload }) {
|
|
749
|
-
const anchor = new
|
|
776
|
+
const anchor = new THREE24.Object3D();
|
|
750
777
|
const imagePath = payload.path ?? "";
|
|
751
778
|
const entityId = createBaseEntity(world, anchor, {
|
|
752
779
|
label: payload.name ?? "Image",
|
|
@@ -759,7 +786,7 @@ function createImage({ world, scene, payload }) {
|
|
|
759
786
|
if (!imagePath) {
|
|
760
787
|
return entityId;
|
|
761
788
|
}
|
|
762
|
-
const loader = new
|
|
789
|
+
const loader = new THREE24.TextureLoader();
|
|
763
790
|
loader.load(
|
|
764
791
|
imagePath,
|
|
765
792
|
(texture) => {
|
|
@@ -767,13 +794,13 @@ function createImage({ world, scene, payload }) {
|
|
|
767
794
|
texture.dispose();
|
|
768
795
|
return;
|
|
769
796
|
}
|
|
770
|
-
const material = new
|
|
797
|
+
const material = new THREE24.MeshBasicMaterial({
|
|
771
798
|
map: texture,
|
|
772
799
|
transparent: true,
|
|
773
|
-
side:
|
|
800
|
+
side: THREE24.DoubleSide
|
|
774
801
|
});
|
|
775
|
-
const geometry = new
|
|
776
|
-
const plane = new
|
|
802
|
+
const geometry = new THREE24.PlaneGeometry(1, 1);
|
|
803
|
+
const plane = new THREE24.Mesh(geometry, material);
|
|
777
804
|
plane.userData.entityId = entityId;
|
|
778
805
|
const textureImage = texture.image;
|
|
779
806
|
const width = textureImage?.width ?? 1;
|
|
@@ -819,7 +846,7 @@ function createImageTarget({
|
|
|
819
846
|
payload,
|
|
820
847
|
isEditor
|
|
821
848
|
}) {
|
|
822
|
-
const anchor = new
|
|
849
|
+
const anchor = new THREE24.Object3D();
|
|
823
850
|
const imagePath = payload.path ?? "";
|
|
824
851
|
const entityId = createBaseEntity(world, anchor, {
|
|
825
852
|
label: payload.name ?? "Image Target",
|
|
@@ -836,7 +863,7 @@ function createImageTarget({
|
|
|
836
863
|
if (!isEditor || !imagePath) {
|
|
837
864
|
return entityId;
|
|
838
865
|
}
|
|
839
|
-
const loader = new
|
|
866
|
+
const loader = new THREE24.TextureLoader();
|
|
840
867
|
loader.load(
|
|
841
868
|
imagePath,
|
|
842
869
|
(texture) => {
|
|
@@ -844,13 +871,13 @@ function createImageTarget({
|
|
|
844
871
|
texture.dispose();
|
|
845
872
|
return;
|
|
846
873
|
}
|
|
847
|
-
const material = new
|
|
874
|
+
const material = new THREE24.MeshBasicMaterial({
|
|
848
875
|
map: texture,
|
|
849
876
|
transparent: true,
|
|
850
|
-
side:
|
|
877
|
+
side: THREE24.DoubleSide
|
|
851
878
|
});
|
|
852
|
-
const geometry = new
|
|
853
|
-
const plane = new
|
|
879
|
+
const geometry = new THREE24.PlaneGeometry(1, 1);
|
|
880
|
+
const plane = new THREE24.Mesh(geometry, material);
|
|
854
881
|
plane.userData.entityId = entityId;
|
|
855
882
|
const textureImage = texture.image;
|
|
856
883
|
const width = textureImage?.width ?? 1;
|
|
@@ -901,7 +928,7 @@ function createInstancedMesh({
|
|
|
901
928
|
scene,
|
|
902
929
|
payload
|
|
903
930
|
}) {
|
|
904
|
-
const anchor = new
|
|
931
|
+
const anchor = new THREE24.Object3D();
|
|
905
932
|
const opts = payload.options ?? {};
|
|
906
933
|
const meshKind = isInstancedMeshKind(opts.meshKind) ? opts.meshKind : "cube";
|
|
907
934
|
const meshParameters = opts.meshParameters && typeof opts.meshParameters === "object" ? opts.meshParameters : void 0;
|
|
@@ -972,7 +999,7 @@ function createAmbientLight({
|
|
|
972
999
|
scene,
|
|
973
1000
|
payload
|
|
974
1001
|
}) {
|
|
975
|
-
const light = new
|
|
1002
|
+
const light = new THREE24.AmbientLight("#ffffff", 0.6);
|
|
976
1003
|
const entityId = createBaseEntity(world, light, {
|
|
977
1004
|
label: payload.name ?? "Ambient Light",
|
|
978
1005
|
entityType: "ambientLight",
|
|
@@ -989,7 +1016,7 @@ function createAreaLight({
|
|
|
989
1016
|
payload,
|
|
990
1017
|
isEditor
|
|
991
1018
|
}) {
|
|
992
|
-
const light = new
|
|
1019
|
+
const light = new THREE24.RectAreaLight("#ffffff", 5, 4, 4);
|
|
993
1020
|
light.lookAt(0, 0, 0);
|
|
994
1021
|
const entityId = createBaseEntity(world, light, {
|
|
995
1022
|
label: payload.name ?? "Area Light",
|
|
@@ -1018,7 +1045,7 @@ function createDirectionalLight({
|
|
|
1018
1045
|
payload,
|
|
1019
1046
|
isEditor
|
|
1020
1047
|
}) {
|
|
1021
|
-
const light = new
|
|
1048
|
+
const light = new THREE24.DirectionalLight("#ffffff", 1.5);
|
|
1022
1049
|
light.castShadow = true;
|
|
1023
1050
|
const entityId = createBaseEntity(world, light, {
|
|
1024
1051
|
label: payload.name ?? "Directional Light",
|
|
@@ -1029,7 +1056,7 @@ function createDirectionalLight({
|
|
|
1029
1056
|
});
|
|
1030
1057
|
createLightComponent(world, entityId, light);
|
|
1031
1058
|
if (isEditor) {
|
|
1032
|
-
const helper = new
|
|
1059
|
+
const helper = new THREE24.DirectionalLightHelper(light, 1.8, "#38bdf8");
|
|
1033
1060
|
helper.onBeforeRender = () => {
|
|
1034
1061
|
helper.update();
|
|
1035
1062
|
};
|
|
@@ -1047,7 +1074,7 @@ function createPointLight({
|
|
|
1047
1074
|
payload,
|
|
1048
1075
|
isEditor
|
|
1049
1076
|
}) {
|
|
1050
|
-
const light = new
|
|
1077
|
+
const light = new THREE24.PointLight("#ffffff", 1, 10);
|
|
1051
1078
|
const entityId = createBaseEntity(world, light, {
|
|
1052
1079
|
label: payload.name ?? "Point Light",
|
|
1053
1080
|
entityType: "pointLight",
|
|
@@ -1057,7 +1084,7 @@ function createPointLight({
|
|
|
1057
1084
|
});
|
|
1058
1085
|
createLightComponent(world, entityId, light);
|
|
1059
1086
|
if (isEditor) {
|
|
1060
|
-
const helper = new
|
|
1087
|
+
const helper = new THREE24.PointLightHelper(light, 0.35, "#fbbf24");
|
|
1061
1088
|
helper.onBeforeRender = () => {
|
|
1062
1089
|
helper.update();
|
|
1063
1090
|
};
|
|
@@ -1075,7 +1102,7 @@ function createSpotLight({
|
|
|
1075
1102
|
payload,
|
|
1076
1103
|
isEditor
|
|
1077
1104
|
}) {
|
|
1078
|
-
const light = new
|
|
1105
|
+
const light = new THREE24.SpotLight("#ffffff", 1, 20, Math.PI / 6, 0.1, 1);
|
|
1079
1106
|
const entityId = createBaseEntity(world, light, {
|
|
1080
1107
|
label: payload.name ?? "Spot Light",
|
|
1081
1108
|
entityType: "spotLight",
|
|
@@ -1085,7 +1112,7 @@ function createSpotLight({
|
|
|
1085
1112
|
});
|
|
1086
1113
|
createLightComponent(world, entityId, light);
|
|
1087
1114
|
if (isEditor) {
|
|
1088
|
-
const helper = new
|
|
1115
|
+
const helper = new THREE24.SpotLightHelper(light, "#f59e0b");
|
|
1089
1116
|
helper.onBeforeRender = () => {
|
|
1090
1117
|
helper.update();
|
|
1091
1118
|
};
|
|
@@ -1120,7 +1147,7 @@ function createModel({
|
|
|
1120
1147
|
payload,
|
|
1121
1148
|
isEditor
|
|
1122
1149
|
}) {
|
|
1123
|
-
const anchor = new
|
|
1150
|
+
const anchor = new THREE24.Object3D();
|
|
1124
1151
|
const modelPath = payload.path ?? "";
|
|
1125
1152
|
const entityId = createBaseEntity(world, anchor, {
|
|
1126
1153
|
label: payload.name ?? "Model",
|
|
@@ -1186,12 +1213,12 @@ function createModel({
|
|
|
1186
1213
|
}
|
|
1187
1214
|
__name(createModel, "createModel");
|
|
1188
1215
|
function createPlane({ world, scene, payload }) {
|
|
1189
|
-
const geometry = new
|
|
1190
|
-
const material = new
|
|
1216
|
+
const geometry = new THREE24.PlaneGeometry(100, 100);
|
|
1217
|
+
const material = new THREE24.MeshStandardMaterial({
|
|
1191
1218
|
color: "#ffffff",
|
|
1192
|
-
side:
|
|
1219
|
+
side: THREE24.DoubleSide
|
|
1193
1220
|
});
|
|
1194
|
-
const mesh = new
|
|
1221
|
+
const mesh = new THREE24.Mesh(geometry, material);
|
|
1195
1222
|
const entityId = createBaseEntity(
|
|
1196
1223
|
world,
|
|
1197
1224
|
mesh,
|
|
@@ -1227,7 +1254,7 @@ function createScriptObject({
|
|
|
1227
1254
|
scene,
|
|
1228
1255
|
payload
|
|
1229
1256
|
}) {
|
|
1230
|
-
const object = new
|
|
1257
|
+
const object = new THREE24.Group();
|
|
1231
1258
|
const entityId = createBaseEntity(world, object, {
|
|
1232
1259
|
label: payload.name ?? "Script Object",
|
|
1233
1260
|
entityType: "scriptObject",
|
|
@@ -1244,8 +1271,64 @@ function createScriptObject({
|
|
|
1244
1271
|
return entityId;
|
|
1245
1272
|
}
|
|
1246
1273
|
__name(createScriptObject, "createScriptObject");
|
|
1274
|
+
function createTeleportArea({
|
|
1275
|
+
world,
|
|
1276
|
+
scene,
|
|
1277
|
+
payload
|
|
1278
|
+
}) {
|
|
1279
|
+
const options = payload.options ?? {};
|
|
1280
|
+
const width = typeof options.width === "number" ? options.width : 10;
|
|
1281
|
+
const depth = typeof options.depth === "number" ? options.depth : 10;
|
|
1282
|
+
const geometry = new THREE24.PlaneGeometry(width, depth);
|
|
1283
|
+
const material = new THREE24.MeshBasicMaterial({
|
|
1284
|
+
color: "#4da3ff",
|
|
1285
|
+
transparent: true,
|
|
1286
|
+
opacity: 0.18,
|
|
1287
|
+
side: THREE24.DoubleSide,
|
|
1288
|
+
depthWrite: false
|
|
1289
|
+
});
|
|
1290
|
+
const object = new THREE24.Mesh(geometry, material);
|
|
1291
|
+
const entityId = createBaseEntity(world, object, {
|
|
1292
|
+
label: payload.name ?? "Teleport Area",
|
|
1293
|
+
entityType: "teleportArea",
|
|
1294
|
+
// The flat-on-the-ground rotation must live in the ECS TRANSFORM, not on
|
|
1295
|
+
// the Object3D: createBaseEntity applies the transform over the object, and
|
|
1296
|
+
// TransformSyncSystem re-applies it every frame — so a rotation set
|
|
1297
|
+
// directly on the mesh is overwritten immediately and the area stands up
|
|
1298
|
+
// like a wall. Same convention as the `plane` primitive.
|
|
1299
|
+
transformInput: {
|
|
1300
|
+
position: payload.transform?.position,
|
|
1301
|
+
rotation: payload.transform?.rotation ?? { x: -Math.PI / 2, y: 0, z: 0 },
|
|
1302
|
+
scale: payload.transform?.scale
|
|
1303
|
+
}
|
|
1304
|
+
});
|
|
1305
|
+
world.addComponent(
|
|
1306
|
+
entityId,
|
|
1307
|
+
new VRTeleportAreaComponent({ width, depth, ...options })
|
|
1308
|
+
);
|
|
1309
|
+
scene.add(object);
|
|
1310
|
+
return entityId;
|
|
1311
|
+
}
|
|
1312
|
+
__name(createTeleportArea, "createTeleportArea");
|
|
1313
|
+
function createXRRig({
|
|
1314
|
+
world,
|
|
1315
|
+
scene,
|
|
1316
|
+
payload
|
|
1317
|
+
}) {
|
|
1318
|
+
const object = new THREE24.Group();
|
|
1319
|
+
const entityId = createBaseEntity(world, object, {
|
|
1320
|
+
label: payload.name ?? "XR Rig",
|
|
1321
|
+
entityType: "xrRig",
|
|
1322
|
+
transformInput: payload.transform
|
|
1323
|
+
});
|
|
1324
|
+
const options = payload.options ?? {};
|
|
1325
|
+
world.addComponent(entityId, new XRRigComponent(options));
|
|
1326
|
+
scene.add(object);
|
|
1327
|
+
return entityId;
|
|
1328
|
+
}
|
|
1329
|
+
__name(createXRRig, "createXRRig");
|
|
1247
1330
|
function createSprite({ world, scene, payload }) {
|
|
1248
|
-
const anchor = new
|
|
1331
|
+
const anchor = new THREE24.Object3D();
|
|
1249
1332
|
const imagePath = payload.path ?? "";
|
|
1250
1333
|
const entityId = createBaseEntity(world, anchor, {
|
|
1251
1334
|
label: payload.name ?? "Sprite",
|
|
@@ -1257,7 +1340,7 @@ function createSprite({ world, scene, payload }) {
|
|
|
1257
1340
|
if (!imagePath) {
|
|
1258
1341
|
return entityId;
|
|
1259
1342
|
}
|
|
1260
|
-
const loader = new
|
|
1343
|
+
const loader = new THREE24.TextureLoader();
|
|
1261
1344
|
loader.load(
|
|
1262
1345
|
imagePath,
|
|
1263
1346
|
(texture) => {
|
|
@@ -1265,11 +1348,11 @@ function createSprite({ world, scene, payload }) {
|
|
|
1265
1348
|
texture.dispose();
|
|
1266
1349
|
return;
|
|
1267
1350
|
}
|
|
1268
|
-
const material = new
|
|
1351
|
+
const material = new THREE24.SpriteMaterial({
|
|
1269
1352
|
map: texture,
|
|
1270
1353
|
transparent: true
|
|
1271
1354
|
});
|
|
1272
|
-
const sprite = new
|
|
1355
|
+
const sprite = new THREE24.Sprite(material);
|
|
1273
1356
|
sprite.userData.entityId = entityId;
|
|
1274
1357
|
const textureImage = texture.image;
|
|
1275
1358
|
spriteComponent.width = textureImage?.width ?? 1;
|
|
@@ -1287,9 +1370,9 @@ function createSprite({ world, scene, payload }) {
|
|
|
1287
1370
|
}
|
|
1288
1371
|
__name(createSprite, "createSprite");
|
|
1289
1372
|
function createSphere({ world, scene, payload }) {
|
|
1290
|
-
const geometry = new
|
|
1291
|
-
const material = new
|
|
1292
|
-
const mesh = new
|
|
1373
|
+
const geometry = new THREE24.SphereGeometry(0.5, 24, 24);
|
|
1374
|
+
const material = new THREE24.MeshStandardMaterial({ color: "#ffffff" });
|
|
1375
|
+
const mesh = new THREE24.Mesh(geometry, material);
|
|
1293
1376
|
const entityId = createBaseEntity(world, mesh, {
|
|
1294
1377
|
label: payload.name ?? "Sphere",
|
|
1295
1378
|
entityType: "sphere",
|
|
@@ -1309,10 +1392,10 @@ function createSphere({ world, scene, payload }) {
|
|
|
1309
1392
|
__name(createSphere, "createSphere");
|
|
1310
1393
|
function getOrCreateListener2(camera) {
|
|
1311
1394
|
const existing = camera.userData.ecsAudioListener;
|
|
1312
|
-
if (existing instanceof
|
|
1395
|
+
if (existing instanceof THREE24.AudioListener) {
|
|
1313
1396
|
return existing;
|
|
1314
1397
|
}
|
|
1315
|
-
const listener = new
|
|
1398
|
+
const listener = new THREE24.AudioListener();
|
|
1316
1399
|
camera.add(listener);
|
|
1317
1400
|
camera.userData.ecsAudioListener = listener;
|
|
1318
1401
|
return listener;
|
|
@@ -1362,10 +1445,10 @@ function normalizeOptions(input) {
|
|
|
1362
1445
|
}
|
|
1363
1446
|
__name(normalizeOptions, "normalizeOptions");
|
|
1364
1447
|
function createChromaMaterial(texture, options) {
|
|
1365
|
-
return new
|
|
1448
|
+
return new THREE24.ShaderMaterial({
|
|
1366
1449
|
uniforms: {
|
|
1367
1450
|
tex: { value: texture },
|
|
1368
|
-
keyColor: { value: new
|
|
1451
|
+
keyColor: { value: new THREE24.Color(options.backgroundColor) },
|
|
1369
1452
|
similarity: { value: options.similarity },
|
|
1370
1453
|
smoothness: { value: options.smoothness },
|
|
1371
1454
|
spill: { value: options.spill }
|
|
@@ -1397,22 +1480,22 @@ function createChromaMaterial(texture, options) {
|
|
|
1397
1480
|
}
|
|
1398
1481
|
`,
|
|
1399
1482
|
transparent: true,
|
|
1400
|
-
side:
|
|
1483
|
+
side: THREE24.DoubleSide
|
|
1401
1484
|
});
|
|
1402
1485
|
}
|
|
1403
1486
|
__name(createChromaMaterial, "createChromaMaterial");
|
|
1404
1487
|
function createStandardMaterial(texture) {
|
|
1405
|
-
return new
|
|
1488
|
+
return new THREE24.MeshBasicMaterial({
|
|
1406
1489
|
map: texture,
|
|
1407
1490
|
transparent: true,
|
|
1408
|
-
side:
|
|
1491
|
+
side: THREE24.DoubleSide
|
|
1409
1492
|
});
|
|
1410
1493
|
}
|
|
1411
1494
|
__name(createStandardMaterial, "createStandardMaterial");
|
|
1412
1495
|
function createVideoMesh(entityId, texture, options) {
|
|
1413
|
-
const geometry = new
|
|
1496
|
+
const geometry = new THREE24.PlaneGeometry(1, 1);
|
|
1414
1497
|
const material = options.isGreenScreen ? createChromaMaterial(texture, options) : createStandardMaterial(texture);
|
|
1415
|
-
const mesh = new
|
|
1498
|
+
const mesh = new THREE24.Mesh(geometry, material);
|
|
1416
1499
|
mesh.userData.entityId = entityId;
|
|
1417
1500
|
mesh.scale.set(options.width, options.height, 1);
|
|
1418
1501
|
return { mesh, material };
|
|
@@ -1447,7 +1530,7 @@ function createVideo({
|
|
|
1447
1530
|
payload,
|
|
1448
1531
|
isEditor
|
|
1449
1532
|
}) {
|
|
1450
|
-
const anchor = new
|
|
1533
|
+
const anchor = new THREE24.Object3D();
|
|
1451
1534
|
const path = payload.path ?? "";
|
|
1452
1535
|
const options = normalizeOptions(payload.options);
|
|
1453
1536
|
const entityId = createBaseEntity(world, anchor, {
|
|
@@ -1462,8 +1545,8 @@ function createVideo({
|
|
|
1462
1545
|
return entityId;
|
|
1463
1546
|
}
|
|
1464
1547
|
const video = createVideoElement(path, options);
|
|
1465
|
-
const texture = new
|
|
1466
|
-
texture.colorSpace =
|
|
1548
|
+
const texture = new THREE24.VideoTexture(video);
|
|
1549
|
+
texture.colorSpace = THREE24.SRGBColorSpace;
|
|
1467
1550
|
texture.needsUpdate = true;
|
|
1468
1551
|
const { mesh, material } = createVideoMesh(entityId, texture, options);
|
|
1469
1552
|
anchor.add(mesh);
|
|
@@ -1479,7 +1562,7 @@ function createVideo({
|
|
|
1479
1562
|
});
|
|
1480
1563
|
if (!isEditor && options.positional) {
|
|
1481
1564
|
const listener = getOrCreateListener2(camera);
|
|
1482
|
-
const audioNode = new
|
|
1565
|
+
const audioNode = new THREE24.PositionalAudio(listener);
|
|
1483
1566
|
audioNode.setVolume(options.volume);
|
|
1484
1567
|
audioNode.setRefDistance(options.refDistance);
|
|
1485
1568
|
audioNode.setDistanceModel(normalizeDistanceModel2(options.distanceModel));
|
|
@@ -1519,10 +1602,12 @@ function registerDefaultFactories(objectManagementSystem) {
|
|
|
1519
1602
|
objectManagementSystem.register("spotLight", createSpotLight);
|
|
1520
1603
|
objectManagementSystem.register("areaLight", createAreaLight);
|
|
1521
1604
|
objectManagementSystem.register("scriptObject", createScriptObject);
|
|
1605
|
+
objectManagementSystem.register("xrRig", createXRRig);
|
|
1606
|
+
objectManagementSystem.register("teleportArea", createTeleportArea);
|
|
1522
1607
|
registerDefaultComponentFactories(objectManagementSystem);
|
|
1523
1608
|
}
|
|
1524
1609
|
__name(registerDefaultFactories, "registerDefaultFactories");
|
|
1525
1610
|
|
|
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-
|
|
1528
|
-
//# sourceMappingURL=chunk-
|
|
1611
|
+
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, createVRTeleportAreaComponent, createVideoComponent, createXRInteractableComponent, createXRRigComponent, registerDefaultComponentFactories, registerDefaultFactories };
|
|
1612
|
+
//# sourceMappingURL=chunk-JWTRFJBL.js.map
|
|
1613
|
+
//# sourceMappingURL=chunk-JWTRFJBL.js.map
|