@relu-interactives/spatial-ecs 0.3.4 → 0.3.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.
- package/dist/{System-vrU46Vuw.d.cts → System-TmC2EijF.d.cts} +2 -2
- package/dist/{System-vrU46Vuw.d.ts → System-TmC2EijF.d.ts} +2 -2
- package/dist/{XRRig-2686IqLQ.d.cts → XRInteractor-CCUzSqg9.d.ts} +96 -2
- package/dist/{XRRig-D2QURXl1.d.ts → XRInteractor-I2q6TKtF.d.cts} +96 -2
- package/dist/{chunk-4BZYK3JP.js → chunk-FQTOC7HK.js} +135 -88
- package/dist/chunk-FQTOC7HK.js.map +1 -0
- package/dist/{chunk-2LVFGVWI.js → chunk-JRJ3CL5H.js} +3 -3
- package/dist/{chunk-2LVFGVWI.js.map → chunk-JRJ3CL5H.js.map} +1 -1
- package/dist/{chunk-6QC2PJLD.js → chunk-N4GKZ7IV.js} +29 -3
- package/dist/chunk-N4GKZ7IV.js.map +1 -0
- package/dist/{chunk-ID266ZUA.js → chunk-WRJ2K3LZ.js} +525 -41
- package/dist/chunk-WRJ2K3LZ.js.map +1 -0
- package/dist/components/index.cjs +26 -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 +185 -112
- package/dist/factories/index.cjs.map +1 -1
- package/dist/factories/index.d.cts +7 -3
- package/dist/factories/index.d.ts +7 -3
- package/dist/factories/index.js +3 -3
- package/dist/{index-BtKOaHfY.d.ts → index-BltjPEhg.d.cts} +10 -3
- package/dist/{index-CRmfSYdj.d.ts → index-BpbmZuOz.d.ts} +92 -16
- package/dist/{index-Bc0YCz1A.d.cts → index-C5FrDt3z.d.cts} +92 -16
- package/dist/{index-Xu238jLn.d.cts → index-W8pUajCW.d.ts} +10 -3
- package/dist/index.cjs +829 -261
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -9
- package/dist/index.d.ts +76 -9
- package/dist/index.js +8 -8
- package/dist/systems/index.cjs +532 -36
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +2 -2
- package/dist/systems/index.d.ts +2 -2
- 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-4BZYK3JP.js.map +0 -1
- package/dist/chunk-6QC2PJLD.js.map +0 -1
- package/dist/chunk-ID266ZUA.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, XRRigComponent, VRTeleportAreaComponent, XRInteractableComponent, DEFAULT_INSTANCE_TRANSFORM } from './chunk-
|
|
1
|
+
import { createTransform, applyTransform, resolveDracoDecoderPath, loadSharedGltf, cloneModelScene } from './chunk-JRJ3CL5H.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, XRInteractorComponent, XRInteractorSideComponent, DEFAULT_INSTANCE_TRANSFORM } from './chunk-N4GKZ7IV.js';
|
|
3
3
|
import { __name } from './chunk-OY7ZODZP.js';
|
|
4
|
-
import * as
|
|
4
|
+
import * as THREE25 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 THREE25.PositionalAudio(listener) : new THREE25.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 THREE25.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 THREE25.EdgesGeometry(
|
|
40
|
+
new THREE25.OctahedronGeometry(0.22, 0)
|
|
41
41
|
);
|
|
42
|
-
const material2 = new
|
|
42
|
+
const material2 = new THREE25.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 THREE25.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 THREE25.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 THREE25.CanvasTexture(canvas);
|
|
92
92
|
texture.needsUpdate = true;
|
|
93
|
-
const material = new
|
|
93
|
+
const material = new THREE25.SpriteMaterial({
|
|
94
94
|
map: texture,
|
|
95
95
|
transparent: true,
|
|
96
96
|
depthTest: false
|
|
97
97
|
});
|
|
98
|
-
const helper = new
|
|
98
|
+
const helper = new THREE25.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 THREE25.Camera ? object : void 0;
|
|
126
126
|
const component = new CameraComponent({
|
|
127
127
|
...payload,
|
|
128
128
|
camera: payload.camera ?? objectCamera
|
|
@@ -414,6 +414,22 @@ function createXRInteractableComponent(world, entityId, ...args) {
|
|
|
414
414
|
}
|
|
415
415
|
__name(createXRInteractableComponent, "createXRInteractableComponent");
|
|
416
416
|
|
|
417
|
+
// core/factories/components/XRInteractorFactory.ts
|
|
418
|
+
function createXRInteractorComponent(world, entityId, ...args) {
|
|
419
|
+
const component = new XRInteractorComponent(...args);
|
|
420
|
+
world.addComponent(entityId, component);
|
|
421
|
+
return component;
|
|
422
|
+
}
|
|
423
|
+
__name(createXRInteractorComponent, "createXRInteractorComponent");
|
|
424
|
+
|
|
425
|
+
// core/factories/components/XRInteractorSideFactory.ts
|
|
426
|
+
function createXRInteractorSideComponent(world, entityId, ...args) {
|
|
427
|
+
const component = new XRInteractorSideComponent(...args);
|
|
428
|
+
world.addComponent(entityId, component);
|
|
429
|
+
return component;
|
|
430
|
+
}
|
|
431
|
+
__name(createXRInteractorSideComponent, "createXRInteractorSideComponent");
|
|
432
|
+
|
|
417
433
|
// core/factories/registerDefaultComponentFactories.ts
|
|
418
434
|
function registerDefaultComponentFactories(objectManagementSystem) {
|
|
419
435
|
objectManagementSystem.registerComponentFactory("animation", createAnimationComponent);
|
|
@@ -426,6 +442,8 @@ function registerDefaultComponentFactories(objectManagementSystem) {
|
|
|
426
442
|
objectManagementSystem.registerComponentFactory("xrRig", createXRRigComponent);
|
|
427
443
|
objectManagementSystem.registerComponentFactory("vrTeleportArea", createVRTeleportAreaComponent);
|
|
428
444
|
objectManagementSystem.registerComponentFactory("xrInteractable", createXRInteractableComponent);
|
|
445
|
+
objectManagementSystem.registerComponentFactory("xrInteractor", createXRInteractorComponent);
|
|
446
|
+
objectManagementSystem.registerComponentFactory("xrInteractorSide", createXRInteractorSideComponent);
|
|
429
447
|
objectManagementSystem.registerComponentFactory(
|
|
430
448
|
"imageTargetAnchor",
|
|
431
449
|
createImageTargetAnchorComponent
|
|
@@ -485,10 +503,10 @@ __name(createBaseEntity, "createBaseEntity");
|
|
|
485
503
|
// core/factories/objects/AudioFactory.ts
|
|
486
504
|
function getOrCreateListener(camera) {
|
|
487
505
|
const existing = camera.userData.ecsAudioListener;
|
|
488
|
-
if (existing instanceof
|
|
506
|
+
if (existing instanceof THREE25.AudioListener) {
|
|
489
507
|
return existing;
|
|
490
508
|
}
|
|
491
|
-
const listener = new
|
|
509
|
+
const listener = new THREE25.AudioListener();
|
|
492
510
|
camera.add(listener);
|
|
493
511
|
camera.userData.ecsAudioListener = listener;
|
|
494
512
|
return listener;
|
|
@@ -501,7 +519,7 @@ function createAudio({
|
|
|
501
519
|
payload,
|
|
502
520
|
isEditor
|
|
503
521
|
}) {
|
|
504
|
-
const anchor = new
|
|
522
|
+
const anchor = new THREE25.Object3D();
|
|
505
523
|
const entityId = createBaseEntity(world, anchor, {
|
|
506
524
|
label: payload.name ?? "Audio",
|
|
507
525
|
entityType: "audio",
|
|
@@ -523,7 +541,7 @@ function createAudio({
|
|
|
523
541
|
return entityId;
|
|
524
542
|
}
|
|
525
543
|
if (!isEditor) {
|
|
526
|
-
const loader = new
|
|
544
|
+
const loader = new THREE25.AudioLoader();
|
|
527
545
|
loader.load(
|
|
528
546
|
audio.path,
|
|
529
547
|
(buffer) => {
|
|
@@ -598,7 +616,7 @@ function applyCameraSettings(camera, options) {
|
|
|
598
616
|
const near = typeof options.near === "number" ? options.near : DEFAULT_NEAR;
|
|
599
617
|
const far = typeof options.far === "number" ? options.far : DEFAULT_FAR;
|
|
600
618
|
const projection = options.projection;
|
|
601
|
-
if (camera instanceof
|
|
619
|
+
if (camera instanceof THREE25.PerspectiveCamera) {
|
|
602
620
|
if (!projection || projection === "perspective") {
|
|
603
621
|
camera.fov = typeof options.fov === "number" ? options.fov : DEFAULT_FOV;
|
|
604
622
|
}
|
|
@@ -608,7 +626,7 @@ function applyCameraSettings(camera, options) {
|
|
|
608
626
|
camera.updateProjectionMatrix();
|
|
609
627
|
return;
|
|
610
628
|
}
|
|
611
|
-
if (camera instanceof
|
|
629
|
+
if (camera instanceof THREE25.OrthographicCamera) {
|
|
612
630
|
camera.left = typeof options.left === "number" ? options.left : -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
613
631
|
camera.right = typeof options.right === "number" ? options.right : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
614
632
|
camera.top = typeof options.top === "number" ? options.top : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
@@ -629,7 +647,7 @@ function createCameraObject(options) {
|
|
|
629
647
|
const bottom = options.bottom ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
630
648
|
const left = options.left ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
631
649
|
const right = options.right ?? DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
632
|
-
const camera = new
|
|
650
|
+
const camera = new THREE25.OrthographicCamera(
|
|
633
651
|
left,
|
|
634
652
|
right,
|
|
635
653
|
top,
|
|
@@ -641,7 +659,7 @@ function createCameraObject(options) {
|
|
|
641
659
|
camera.updateProjectionMatrix();
|
|
642
660
|
return camera;
|
|
643
661
|
}
|
|
644
|
-
return new
|
|
662
|
+
return new THREE25.PerspectiveCamera(
|
|
645
663
|
options.fov ?? DEFAULT_FOV,
|
|
646
664
|
readViewportAspect(),
|
|
647
665
|
near,
|
|
@@ -659,7 +677,7 @@ function createCamera({ world, scene, camera, payload, isEditor }) {
|
|
|
659
677
|
transformInput: payload.transform
|
|
660
678
|
});
|
|
661
679
|
const objectRef = world.getComponent(entityId, Object3DRef);
|
|
662
|
-
if (objectRef?.object instanceof
|
|
680
|
+
if (objectRef?.object instanceof THREE25.Camera) {
|
|
663
681
|
objectRef.object.userData.entityId = entityId;
|
|
664
682
|
}
|
|
665
683
|
const componentOptions = {
|
|
@@ -691,9 +709,9 @@ function createCapsule({
|
|
|
691
709
|
scene,
|
|
692
710
|
payload
|
|
693
711
|
}) {
|
|
694
|
-
const geometry = new
|
|
695
|
-
const material = new
|
|
696
|
-
const mesh = new
|
|
712
|
+
const geometry = new THREE25.CapsuleGeometry(0.5, 1, 4, 8);
|
|
713
|
+
const material = new THREE25.MeshStandardMaterial({ color: "#ffffff" });
|
|
714
|
+
const mesh = new THREE25.Mesh(geometry, material);
|
|
697
715
|
const entityId = createBaseEntity(world, mesh, {
|
|
698
716
|
label: payload.name ?? "Capsule",
|
|
699
717
|
entityType: "capsule",
|
|
@@ -713,9 +731,9 @@ function createCapsule({
|
|
|
713
731
|
}
|
|
714
732
|
__name(createCapsule, "createCapsule");
|
|
715
733
|
function createCube({ world, scene, payload }) {
|
|
716
|
-
const geometry = new
|
|
717
|
-
const material = new
|
|
718
|
-
const mesh = new
|
|
734
|
+
const geometry = new THREE25.BoxGeometry(1, 1, 1);
|
|
735
|
+
const material = new THREE25.MeshStandardMaterial({ color: "#ffffff" });
|
|
736
|
+
const mesh = new THREE25.Mesh(geometry, material);
|
|
719
737
|
const entityId = createBaseEntity(world, mesh, {
|
|
720
738
|
label: payload.name ?? "Cube",
|
|
721
739
|
entityType: "cube",
|
|
@@ -740,9 +758,9 @@ function createCylinder({
|
|
|
740
758
|
scene,
|
|
741
759
|
payload
|
|
742
760
|
}) {
|
|
743
|
-
const geometry = new
|
|
744
|
-
const material = new
|
|
745
|
-
const mesh = new
|
|
761
|
+
const geometry = new THREE25.CylinderGeometry(0.5, 0.5, 1, 20);
|
|
762
|
+
const material = new THREE25.MeshStandardMaterial({ color: "#ffffff" });
|
|
763
|
+
const mesh = new THREE25.Mesh(geometry, material);
|
|
746
764
|
const entityId = createBaseEntity(world, mesh, {
|
|
747
765
|
label: payload.name ?? "Cylinder",
|
|
748
766
|
entityType: "cylinder",
|
|
@@ -762,7 +780,7 @@ function createCylinder({
|
|
|
762
780
|
}
|
|
763
781
|
__name(createCylinder, "createCylinder");
|
|
764
782
|
function createEmpty({ world, scene, payload, isEditor }) {
|
|
765
|
-
const object = new
|
|
783
|
+
const object = new THREE25.Group();
|
|
766
784
|
const entityId = createBaseEntity(world, object, {
|
|
767
785
|
label: payload.name ?? "Empty",
|
|
768
786
|
entityType: "empty",
|
|
@@ -773,7 +791,7 @@ function createEmpty({ world, scene, payload, isEditor }) {
|
|
|
773
791
|
}
|
|
774
792
|
__name(createEmpty, "createEmpty");
|
|
775
793
|
function createImage({ world, scene, payload }) {
|
|
776
|
-
const anchor = new
|
|
794
|
+
const anchor = new THREE25.Object3D();
|
|
777
795
|
const imagePath = payload.path ?? "";
|
|
778
796
|
const entityId = createBaseEntity(world, anchor, {
|
|
779
797
|
label: payload.name ?? "Image",
|
|
@@ -786,7 +804,7 @@ function createImage({ world, scene, payload }) {
|
|
|
786
804
|
if (!imagePath) {
|
|
787
805
|
return entityId;
|
|
788
806
|
}
|
|
789
|
-
const loader = new
|
|
807
|
+
const loader = new THREE25.TextureLoader();
|
|
790
808
|
loader.load(
|
|
791
809
|
imagePath,
|
|
792
810
|
(texture) => {
|
|
@@ -794,13 +812,13 @@ function createImage({ world, scene, payload }) {
|
|
|
794
812
|
texture.dispose();
|
|
795
813
|
return;
|
|
796
814
|
}
|
|
797
|
-
const material = new
|
|
815
|
+
const material = new THREE25.MeshBasicMaterial({
|
|
798
816
|
map: texture,
|
|
799
817
|
transparent: true,
|
|
800
|
-
side:
|
|
818
|
+
side: THREE25.DoubleSide
|
|
801
819
|
});
|
|
802
|
-
const geometry = new
|
|
803
|
-
const plane = new
|
|
820
|
+
const geometry = new THREE25.PlaneGeometry(1, 1);
|
|
821
|
+
const plane = new THREE25.Mesh(geometry, material);
|
|
804
822
|
plane.userData.entityId = entityId;
|
|
805
823
|
const textureImage = texture.image;
|
|
806
824
|
const width = textureImage?.width ?? 1;
|
|
@@ -846,7 +864,7 @@ function createImageTarget({
|
|
|
846
864
|
payload,
|
|
847
865
|
isEditor
|
|
848
866
|
}) {
|
|
849
|
-
const anchor = new
|
|
867
|
+
const anchor = new THREE25.Object3D();
|
|
850
868
|
const imagePath = payload.path ?? "";
|
|
851
869
|
const entityId = createBaseEntity(world, anchor, {
|
|
852
870
|
label: payload.name ?? "Image Target",
|
|
@@ -863,7 +881,7 @@ function createImageTarget({
|
|
|
863
881
|
if (!isEditor || !imagePath) {
|
|
864
882
|
return entityId;
|
|
865
883
|
}
|
|
866
|
-
const loader = new
|
|
884
|
+
const loader = new THREE25.TextureLoader();
|
|
867
885
|
loader.load(
|
|
868
886
|
imagePath,
|
|
869
887
|
(texture) => {
|
|
@@ -871,13 +889,13 @@ function createImageTarget({
|
|
|
871
889
|
texture.dispose();
|
|
872
890
|
return;
|
|
873
891
|
}
|
|
874
|
-
const material = new
|
|
892
|
+
const material = new THREE25.MeshBasicMaterial({
|
|
875
893
|
map: texture,
|
|
876
894
|
transparent: true,
|
|
877
|
-
side:
|
|
895
|
+
side: THREE25.DoubleSide
|
|
878
896
|
});
|
|
879
|
-
const geometry = new
|
|
880
|
-
const plane = new
|
|
897
|
+
const geometry = new THREE25.PlaneGeometry(1, 1);
|
|
898
|
+
const plane = new THREE25.Mesh(geometry, material);
|
|
881
899
|
plane.userData.entityId = entityId;
|
|
882
900
|
const textureImage = texture.image;
|
|
883
901
|
const width = textureImage?.width ?? 1;
|
|
@@ -928,7 +946,7 @@ function createInstancedMesh({
|
|
|
928
946
|
scene,
|
|
929
947
|
payload
|
|
930
948
|
}) {
|
|
931
|
-
const anchor = new
|
|
949
|
+
const anchor = new THREE25.Object3D();
|
|
932
950
|
const opts = payload.options ?? {};
|
|
933
951
|
const meshKind = isInstancedMeshKind(opts.meshKind) ? opts.meshKind : "cube";
|
|
934
952
|
const meshParameters = opts.meshParameters && typeof opts.meshParameters === "object" ? opts.meshParameters : void 0;
|
|
@@ -999,7 +1017,7 @@ function createAmbientLight({
|
|
|
999
1017
|
scene,
|
|
1000
1018
|
payload
|
|
1001
1019
|
}) {
|
|
1002
|
-
const light = new
|
|
1020
|
+
const light = new THREE25.AmbientLight("#ffffff", 0.6);
|
|
1003
1021
|
const entityId = createBaseEntity(world, light, {
|
|
1004
1022
|
label: payload.name ?? "Ambient Light",
|
|
1005
1023
|
entityType: "ambientLight",
|
|
@@ -1016,7 +1034,7 @@ function createAreaLight({
|
|
|
1016
1034
|
payload,
|
|
1017
1035
|
isEditor
|
|
1018
1036
|
}) {
|
|
1019
|
-
const light = new
|
|
1037
|
+
const light = new THREE25.RectAreaLight("#ffffff", 5, 4, 4);
|
|
1020
1038
|
light.lookAt(0, 0, 0);
|
|
1021
1039
|
const entityId = createBaseEntity(world, light, {
|
|
1022
1040
|
label: payload.name ?? "Area Light",
|
|
@@ -1045,7 +1063,7 @@ function createDirectionalLight({
|
|
|
1045
1063
|
payload,
|
|
1046
1064
|
isEditor
|
|
1047
1065
|
}) {
|
|
1048
|
-
const light = new
|
|
1066
|
+
const light = new THREE25.DirectionalLight("#ffffff", 1.5);
|
|
1049
1067
|
light.castShadow = true;
|
|
1050
1068
|
const entityId = createBaseEntity(world, light, {
|
|
1051
1069
|
label: payload.name ?? "Directional Light",
|
|
@@ -1056,7 +1074,7 @@ function createDirectionalLight({
|
|
|
1056
1074
|
});
|
|
1057
1075
|
createLightComponent(world, entityId, light);
|
|
1058
1076
|
if (isEditor) {
|
|
1059
|
-
const helper = new
|
|
1077
|
+
const helper = new THREE25.DirectionalLightHelper(light, 1.8, "#38bdf8");
|
|
1060
1078
|
helper.onBeforeRender = () => {
|
|
1061
1079
|
helper.update();
|
|
1062
1080
|
};
|
|
@@ -1074,7 +1092,7 @@ function createPointLight({
|
|
|
1074
1092
|
payload,
|
|
1075
1093
|
isEditor
|
|
1076
1094
|
}) {
|
|
1077
|
-
const light = new
|
|
1095
|
+
const light = new THREE25.PointLight("#ffffff", 1, 10);
|
|
1078
1096
|
const entityId = createBaseEntity(world, light, {
|
|
1079
1097
|
label: payload.name ?? "Point Light",
|
|
1080
1098
|
entityType: "pointLight",
|
|
@@ -1084,7 +1102,7 @@ function createPointLight({
|
|
|
1084
1102
|
});
|
|
1085
1103
|
createLightComponent(world, entityId, light);
|
|
1086
1104
|
if (isEditor) {
|
|
1087
|
-
const helper = new
|
|
1105
|
+
const helper = new THREE25.PointLightHelper(light, 0.35, "#fbbf24");
|
|
1088
1106
|
helper.onBeforeRender = () => {
|
|
1089
1107
|
helper.update();
|
|
1090
1108
|
};
|
|
@@ -1102,7 +1120,7 @@ function createSpotLight({
|
|
|
1102
1120
|
payload,
|
|
1103
1121
|
isEditor
|
|
1104
1122
|
}) {
|
|
1105
|
-
const light = new
|
|
1123
|
+
const light = new THREE25.SpotLight("#ffffff", 1, 20, Math.PI / 6, 0.1, 1);
|
|
1106
1124
|
const entityId = createBaseEntity(world, light, {
|
|
1107
1125
|
label: payload.name ?? "Spot Light",
|
|
1108
1126
|
entityType: "spotLight",
|
|
@@ -1112,7 +1130,7 @@ function createSpotLight({
|
|
|
1112
1130
|
});
|
|
1113
1131
|
createLightComponent(world, entityId, light);
|
|
1114
1132
|
if (isEditor) {
|
|
1115
|
-
const helper = new
|
|
1133
|
+
const helper = new THREE25.SpotLightHelper(light, "#f59e0b");
|
|
1116
1134
|
helper.onBeforeRender = () => {
|
|
1117
1135
|
helper.update();
|
|
1118
1136
|
};
|
|
@@ -1147,7 +1165,7 @@ function createModel({
|
|
|
1147
1165
|
payload,
|
|
1148
1166
|
isEditor
|
|
1149
1167
|
}) {
|
|
1150
|
-
const anchor = new
|
|
1168
|
+
const anchor = new THREE25.Object3D();
|
|
1151
1169
|
const modelPath = payload.path ?? "";
|
|
1152
1170
|
const entityId = createBaseEntity(world, anchor, {
|
|
1153
1171
|
label: payload.name ?? "Model",
|
|
@@ -1213,12 +1231,12 @@ function createModel({
|
|
|
1213
1231
|
}
|
|
1214
1232
|
__name(createModel, "createModel");
|
|
1215
1233
|
function createPlane({ world, scene, payload }) {
|
|
1216
|
-
const geometry = new
|
|
1217
|
-
const material = new
|
|
1234
|
+
const geometry = new THREE25.PlaneGeometry(100, 100);
|
|
1235
|
+
const material = new THREE25.MeshStandardMaterial({
|
|
1218
1236
|
color: "#ffffff",
|
|
1219
|
-
side:
|
|
1237
|
+
side: THREE25.DoubleSide
|
|
1220
1238
|
});
|
|
1221
|
-
const mesh = new
|
|
1239
|
+
const mesh = new THREE25.Mesh(geometry, material);
|
|
1222
1240
|
const entityId = createBaseEntity(
|
|
1223
1241
|
world,
|
|
1224
1242
|
mesh,
|
|
@@ -1254,7 +1272,7 @@ function createScriptObject({
|
|
|
1254
1272
|
scene,
|
|
1255
1273
|
payload
|
|
1256
1274
|
}) {
|
|
1257
|
-
const object = new
|
|
1275
|
+
const object = new THREE25.Group();
|
|
1258
1276
|
const entityId = createBaseEntity(world, object, {
|
|
1259
1277
|
label: payload.name ?? "Script Object",
|
|
1260
1278
|
entityType: "scriptObject",
|
|
@@ -1279,15 +1297,15 @@ function createTeleportArea({
|
|
|
1279
1297
|
const options = payload.options ?? {};
|
|
1280
1298
|
const width = typeof options.width === "number" ? options.width : 10;
|
|
1281
1299
|
const depth = typeof options.depth === "number" ? options.depth : 10;
|
|
1282
|
-
const geometry = new
|
|
1283
|
-
const material = new
|
|
1300
|
+
const geometry = new THREE25.PlaneGeometry(width, depth);
|
|
1301
|
+
const material = new THREE25.MeshBasicMaterial({
|
|
1284
1302
|
color: "#4da3ff",
|
|
1285
1303
|
transparent: true,
|
|
1286
1304
|
opacity: 0.18,
|
|
1287
|
-
side:
|
|
1305
|
+
side: THREE25.DoubleSide,
|
|
1288
1306
|
depthWrite: false
|
|
1289
1307
|
});
|
|
1290
|
-
const object = new
|
|
1308
|
+
const object = new THREE25.Mesh(geometry, material);
|
|
1291
1309
|
const entityId = createBaseEntity(world, object, {
|
|
1292
1310
|
label: payload.name ?? "Teleport Area",
|
|
1293
1311
|
entityType: "teleportArea",
|
|
@@ -1310,12 +1328,40 @@ function createTeleportArea({
|
|
|
1310
1328
|
return entityId;
|
|
1311
1329
|
}
|
|
1312
1330
|
__name(createTeleportArea, "createTeleportArea");
|
|
1331
|
+
function createXRInteractor({
|
|
1332
|
+
world,
|
|
1333
|
+
scene,
|
|
1334
|
+
payload
|
|
1335
|
+
}) {
|
|
1336
|
+
const root = new THREE25.Group();
|
|
1337
|
+
const options = payload.options ?? {};
|
|
1338
|
+
const entityId = createBaseEntity(world, root, {
|
|
1339
|
+
label: payload.name ?? "XR Interactor",
|
|
1340
|
+
entityType: "xrInteractor",
|
|
1341
|
+
transformInput: payload.transform
|
|
1342
|
+
});
|
|
1343
|
+
world.addComponent(entityId, new XRInteractorComponent(options));
|
|
1344
|
+
scene.add(root);
|
|
1345
|
+
for (const side of ["left", "right"]) {
|
|
1346
|
+
const slot = new THREE25.Group();
|
|
1347
|
+
const label = side === "left" ? "Left Interactor" : "Right Interactor";
|
|
1348
|
+
const slotEntityId = createBaseEntity(world, slot, {
|
|
1349
|
+
label,
|
|
1350
|
+
entityType: "empty",
|
|
1351
|
+
parentId: entityId
|
|
1352
|
+
});
|
|
1353
|
+
world.addComponent(slotEntityId, new XRInteractorSideComponent({ side }));
|
|
1354
|
+
scene.add(slot);
|
|
1355
|
+
}
|
|
1356
|
+
return entityId;
|
|
1357
|
+
}
|
|
1358
|
+
__name(createXRInteractor, "createXRInteractor");
|
|
1313
1359
|
function createXRRig({
|
|
1314
1360
|
world,
|
|
1315
1361
|
scene,
|
|
1316
1362
|
payload
|
|
1317
1363
|
}) {
|
|
1318
|
-
const object = new
|
|
1364
|
+
const object = new THREE25.Group();
|
|
1319
1365
|
const entityId = createBaseEntity(world, object, {
|
|
1320
1366
|
label: payload.name ?? "XR Rig",
|
|
1321
1367
|
entityType: "xrRig",
|
|
@@ -1328,7 +1374,7 @@ function createXRRig({
|
|
|
1328
1374
|
}
|
|
1329
1375
|
__name(createXRRig, "createXRRig");
|
|
1330
1376
|
function createSprite({ world, scene, payload }) {
|
|
1331
|
-
const anchor = new
|
|
1377
|
+
const anchor = new THREE25.Object3D();
|
|
1332
1378
|
const imagePath = payload.path ?? "";
|
|
1333
1379
|
const entityId = createBaseEntity(world, anchor, {
|
|
1334
1380
|
label: payload.name ?? "Sprite",
|
|
@@ -1340,7 +1386,7 @@ function createSprite({ world, scene, payload }) {
|
|
|
1340
1386
|
if (!imagePath) {
|
|
1341
1387
|
return entityId;
|
|
1342
1388
|
}
|
|
1343
|
-
const loader = new
|
|
1389
|
+
const loader = new THREE25.TextureLoader();
|
|
1344
1390
|
loader.load(
|
|
1345
1391
|
imagePath,
|
|
1346
1392
|
(texture) => {
|
|
@@ -1348,11 +1394,11 @@ function createSprite({ world, scene, payload }) {
|
|
|
1348
1394
|
texture.dispose();
|
|
1349
1395
|
return;
|
|
1350
1396
|
}
|
|
1351
|
-
const material = new
|
|
1397
|
+
const material = new THREE25.SpriteMaterial({
|
|
1352
1398
|
map: texture,
|
|
1353
1399
|
transparent: true
|
|
1354
1400
|
});
|
|
1355
|
-
const sprite = new
|
|
1401
|
+
const sprite = new THREE25.Sprite(material);
|
|
1356
1402
|
sprite.userData.entityId = entityId;
|
|
1357
1403
|
const textureImage = texture.image;
|
|
1358
1404
|
spriteComponent.width = textureImage?.width ?? 1;
|
|
@@ -1370,9 +1416,9 @@ function createSprite({ world, scene, payload }) {
|
|
|
1370
1416
|
}
|
|
1371
1417
|
__name(createSprite, "createSprite");
|
|
1372
1418
|
function createSphere({ world, scene, payload }) {
|
|
1373
|
-
const geometry = new
|
|
1374
|
-
const material = new
|
|
1375
|
-
const mesh = new
|
|
1419
|
+
const geometry = new THREE25.SphereGeometry(0.5, 24, 24);
|
|
1420
|
+
const material = new THREE25.MeshStandardMaterial({ color: "#ffffff" });
|
|
1421
|
+
const mesh = new THREE25.Mesh(geometry, material);
|
|
1376
1422
|
const entityId = createBaseEntity(world, mesh, {
|
|
1377
1423
|
label: payload.name ?? "Sphere",
|
|
1378
1424
|
entityType: "sphere",
|
|
@@ -1392,10 +1438,10 @@ function createSphere({ world, scene, payload }) {
|
|
|
1392
1438
|
__name(createSphere, "createSphere");
|
|
1393
1439
|
function getOrCreateListener2(camera) {
|
|
1394
1440
|
const existing = camera.userData.ecsAudioListener;
|
|
1395
|
-
if (existing instanceof
|
|
1441
|
+
if (existing instanceof THREE25.AudioListener) {
|
|
1396
1442
|
return existing;
|
|
1397
1443
|
}
|
|
1398
|
-
const listener = new
|
|
1444
|
+
const listener = new THREE25.AudioListener();
|
|
1399
1445
|
camera.add(listener);
|
|
1400
1446
|
camera.userData.ecsAudioListener = listener;
|
|
1401
1447
|
return listener;
|
|
@@ -1445,10 +1491,10 @@ function normalizeOptions(input) {
|
|
|
1445
1491
|
}
|
|
1446
1492
|
__name(normalizeOptions, "normalizeOptions");
|
|
1447
1493
|
function createChromaMaterial(texture, options) {
|
|
1448
|
-
return new
|
|
1494
|
+
return new THREE25.ShaderMaterial({
|
|
1449
1495
|
uniforms: {
|
|
1450
1496
|
tex: { value: texture },
|
|
1451
|
-
keyColor: { value: new
|
|
1497
|
+
keyColor: { value: new THREE25.Color(options.backgroundColor) },
|
|
1452
1498
|
similarity: { value: options.similarity },
|
|
1453
1499
|
smoothness: { value: options.smoothness },
|
|
1454
1500
|
spill: { value: options.spill }
|
|
@@ -1480,22 +1526,22 @@ function createChromaMaterial(texture, options) {
|
|
|
1480
1526
|
}
|
|
1481
1527
|
`,
|
|
1482
1528
|
transparent: true,
|
|
1483
|
-
side:
|
|
1529
|
+
side: THREE25.DoubleSide
|
|
1484
1530
|
});
|
|
1485
1531
|
}
|
|
1486
1532
|
__name(createChromaMaterial, "createChromaMaterial");
|
|
1487
1533
|
function createStandardMaterial(texture) {
|
|
1488
|
-
return new
|
|
1534
|
+
return new THREE25.MeshBasicMaterial({
|
|
1489
1535
|
map: texture,
|
|
1490
1536
|
transparent: true,
|
|
1491
|
-
side:
|
|
1537
|
+
side: THREE25.DoubleSide
|
|
1492
1538
|
});
|
|
1493
1539
|
}
|
|
1494
1540
|
__name(createStandardMaterial, "createStandardMaterial");
|
|
1495
1541
|
function createVideoMesh(entityId, texture, options) {
|
|
1496
|
-
const geometry = new
|
|
1542
|
+
const geometry = new THREE25.PlaneGeometry(1, 1);
|
|
1497
1543
|
const material = options.isGreenScreen ? createChromaMaterial(texture, options) : createStandardMaterial(texture);
|
|
1498
|
-
const mesh = new
|
|
1544
|
+
const mesh = new THREE25.Mesh(geometry, material);
|
|
1499
1545
|
mesh.userData.entityId = entityId;
|
|
1500
1546
|
mesh.scale.set(options.width, options.height, 1);
|
|
1501
1547
|
return { mesh, material };
|
|
@@ -1530,7 +1576,7 @@ function createVideo({
|
|
|
1530
1576
|
payload,
|
|
1531
1577
|
isEditor
|
|
1532
1578
|
}) {
|
|
1533
|
-
const anchor = new
|
|
1579
|
+
const anchor = new THREE25.Object3D();
|
|
1534
1580
|
const path = payload.path ?? "";
|
|
1535
1581
|
const options = normalizeOptions(payload.options);
|
|
1536
1582
|
const entityId = createBaseEntity(world, anchor, {
|
|
@@ -1545,8 +1591,8 @@ function createVideo({
|
|
|
1545
1591
|
return entityId;
|
|
1546
1592
|
}
|
|
1547
1593
|
const video = createVideoElement(path, options);
|
|
1548
|
-
const texture = new
|
|
1549
|
-
texture.colorSpace =
|
|
1594
|
+
const texture = new THREE25.VideoTexture(video);
|
|
1595
|
+
texture.colorSpace = THREE25.SRGBColorSpace;
|
|
1550
1596
|
texture.needsUpdate = true;
|
|
1551
1597
|
const { mesh, material } = createVideoMesh(entityId, texture, options);
|
|
1552
1598
|
anchor.add(mesh);
|
|
@@ -1562,7 +1608,7 @@ function createVideo({
|
|
|
1562
1608
|
});
|
|
1563
1609
|
if (!isEditor && options.positional) {
|
|
1564
1610
|
const listener = getOrCreateListener2(camera);
|
|
1565
|
-
const audioNode = new
|
|
1611
|
+
const audioNode = new THREE25.PositionalAudio(listener);
|
|
1566
1612
|
audioNode.setVolume(options.volume);
|
|
1567
1613
|
audioNode.setRefDistance(options.refDistance);
|
|
1568
1614
|
audioNode.setDistanceModel(normalizeDistanceModel2(options.distanceModel));
|
|
@@ -1603,11 +1649,12 @@ function registerDefaultFactories(objectManagementSystem) {
|
|
|
1603
1649
|
objectManagementSystem.register("areaLight", createAreaLight);
|
|
1604
1650
|
objectManagementSystem.register("scriptObject", createScriptObject);
|
|
1605
1651
|
objectManagementSystem.register("xrRig", createXRRig);
|
|
1652
|
+
objectManagementSystem.register("xrInteractor", createXRInteractor);
|
|
1606
1653
|
objectManagementSystem.register("teleportArea", createTeleportArea);
|
|
1607
1654
|
registerDefaultComponentFactories(objectManagementSystem);
|
|
1608
1655
|
}
|
|
1609
1656
|
__name(registerDefaultFactories, "registerDefaultFactories");
|
|
1610
1657
|
|
|
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-
|
|
1613
|
-
//# sourceMappingURL=chunk-
|
|
1658
|
+
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, createXRInteractorComponent, createXRInteractorSideComponent, createXRRigComponent, registerDefaultComponentFactories, registerDefaultFactories };
|
|
1659
|
+
//# sourceMappingURL=chunk-FQTOC7HK.js.map
|
|
1660
|
+
//# sourceMappingURL=chunk-FQTOC7HK.js.map
|