@relu-interactives/spatial-ecs 0.3.0 → 0.3.1
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-PCOZLCXS.js} +160 -83
- package/dist/chunk-PCOZLCXS.js.map +1 -0
- package/dist/{chunk-7BPHZWQ6.js → chunk-U3MDYKPV.js} +47 -3
- package/dist/chunk-U3MDYKPV.js.map +1 -0
- package/dist/{chunk-7JFSEV7A.js → chunk-VXUVNC7S.js} +633 -6
- package/dist/chunk-VXUVNC7S.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 +228 -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-Gr8aCPRM.d.cts → index-CUFd71ri.d.cts} +12 -3
- package/dist/index-D84o_UA6.d.ts +488 -0
- package/dist/index-YYypJaVw.d.cts +488 -0
- package/dist/{index-BwiRJNIT.d.ts → index-w1oqWl_M.d.ts} +12 -3
- package/dist/index.cjs +971 -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 +24 -8
- package/dist/index.js.map +1 -1
- package/dist/systems/index.cjs +673 -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,56 @@ 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
|
+
object.rotation.x = -Math.PI / 2;
|
|
1292
|
+
const entityId = createBaseEntity(world, object, {
|
|
1293
|
+
label: payload.name ?? "Teleport Area",
|
|
1294
|
+
entityType: "teleportArea",
|
|
1295
|
+
transformInput: payload.transform
|
|
1296
|
+
});
|
|
1297
|
+
world.addComponent(
|
|
1298
|
+
entityId,
|
|
1299
|
+
new VRTeleportAreaComponent({ width, depth, ...options })
|
|
1300
|
+
);
|
|
1301
|
+
scene.add(object);
|
|
1302
|
+
return entityId;
|
|
1303
|
+
}
|
|
1304
|
+
__name(createTeleportArea, "createTeleportArea");
|
|
1305
|
+
function createXRRig({
|
|
1306
|
+
world,
|
|
1307
|
+
scene,
|
|
1308
|
+
payload
|
|
1309
|
+
}) {
|
|
1310
|
+
const object = new THREE24.Group();
|
|
1311
|
+
const entityId = createBaseEntity(world, object, {
|
|
1312
|
+
label: payload.name ?? "XR Rig",
|
|
1313
|
+
entityType: "xrRig",
|
|
1314
|
+
transformInput: payload.transform
|
|
1315
|
+
});
|
|
1316
|
+
const options = payload.options ?? {};
|
|
1317
|
+
world.addComponent(entityId, new XRRigComponent(options));
|
|
1318
|
+
scene.add(object);
|
|
1319
|
+
return entityId;
|
|
1320
|
+
}
|
|
1321
|
+
__name(createXRRig, "createXRRig");
|
|
1247
1322
|
function createSprite({ world, scene, payload }) {
|
|
1248
|
-
const anchor = new
|
|
1323
|
+
const anchor = new THREE24.Object3D();
|
|
1249
1324
|
const imagePath = payload.path ?? "";
|
|
1250
1325
|
const entityId = createBaseEntity(world, anchor, {
|
|
1251
1326
|
label: payload.name ?? "Sprite",
|
|
@@ -1257,7 +1332,7 @@ function createSprite({ world, scene, payload }) {
|
|
|
1257
1332
|
if (!imagePath) {
|
|
1258
1333
|
return entityId;
|
|
1259
1334
|
}
|
|
1260
|
-
const loader = new
|
|
1335
|
+
const loader = new THREE24.TextureLoader();
|
|
1261
1336
|
loader.load(
|
|
1262
1337
|
imagePath,
|
|
1263
1338
|
(texture) => {
|
|
@@ -1265,11 +1340,11 @@ function createSprite({ world, scene, payload }) {
|
|
|
1265
1340
|
texture.dispose();
|
|
1266
1341
|
return;
|
|
1267
1342
|
}
|
|
1268
|
-
const material = new
|
|
1343
|
+
const material = new THREE24.SpriteMaterial({
|
|
1269
1344
|
map: texture,
|
|
1270
1345
|
transparent: true
|
|
1271
1346
|
});
|
|
1272
|
-
const sprite = new
|
|
1347
|
+
const sprite = new THREE24.Sprite(material);
|
|
1273
1348
|
sprite.userData.entityId = entityId;
|
|
1274
1349
|
const textureImage = texture.image;
|
|
1275
1350
|
spriteComponent.width = textureImage?.width ?? 1;
|
|
@@ -1287,9 +1362,9 @@ function createSprite({ world, scene, payload }) {
|
|
|
1287
1362
|
}
|
|
1288
1363
|
__name(createSprite, "createSprite");
|
|
1289
1364
|
function createSphere({ world, scene, payload }) {
|
|
1290
|
-
const geometry = new
|
|
1291
|
-
const material = new
|
|
1292
|
-
const mesh = new
|
|
1365
|
+
const geometry = new THREE24.SphereGeometry(0.5, 24, 24);
|
|
1366
|
+
const material = new THREE24.MeshStandardMaterial({ color: "#ffffff" });
|
|
1367
|
+
const mesh = new THREE24.Mesh(geometry, material);
|
|
1293
1368
|
const entityId = createBaseEntity(world, mesh, {
|
|
1294
1369
|
label: payload.name ?? "Sphere",
|
|
1295
1370
|
entityType: "sphere",
|
|
@@ -1309,10 +1384,10 @@ function createSphere({ world, scene, payload }) {
|
|
|
1309
1384
|
__name(createSphere, "createSphere");
|
|
1310
1385
|
function getOrCreateListener2(camera) {
|
|
1311
1386
|
const existing = camera.userData.ecsAudioListener;
|
|
1312
|
-
if (existing instanceof
|
|
1387
|
+
if (existing instanceof THREE24.AudioListener) {
|
|
1313
1388
|
return existing;
|
|
1314
1389
|
}
|
|
1315
|
-
const listener = new
|
|
1390
|
+
const listener = new THREE24.AudioListener();
|
|
1316
1391
|
camera.add(listener);
|
|
1317
1392
|
camera.userData.ecsAudioListener = listener;
|
|
1318
1393
|
return listener;
|
|
@@ -1362,10 +1437,10 @@ function normalizeOptions(input) {
|
|
|
1362
1437
|
}
|
|
1363
1438
|
__name(normalizeOptions, "normalizeOptions");
|
|
1364
1439
|
function createChromaMaterial(texture, options) {
|
|
1365
|
-
return new
|
|
1440
|
+
return new THREE24.ShaderMaterial({
|
|
1366
1441
|
uniforms: {
|
|
1367
1442
|
tex: { value: texture },
|
|
1368
|
-
keyColor: { value: new
|
|
1443
|
+
keyColor: { value: new THREE24.Color(options.backgroundColor) },
|
|
1369
1444
|
similarity: { value: options.similarity },
|
|
1370
1445
|
smoothness: { value: options.smoothness },
|
|
1371
1446
|
spill: { value: options.spill }
|
|
@@ -1397,22 +1472,22 @@ function createChromaMaterial(texture, options) {
|
|
|
1397
1472
|
}
|
|
1398
1473
|
`,
|
|
1399
1474
|
transparent: true,
|
|
1400
|
-
side:
|
|
1475
|
+
side: THREE24.DoubleSide
|
|
1401
1476
|
});
|
|
1402
1477
|
}
|
|
1403
1478
|
__name(createChromaMaterial, "createChromaMaterial");
|
|
1404
1479
|
function createStandardMaterial(texture) {
|
|
1405
|
-
return new
|
|
1480
|
+
return new THREE24.MeshBasicMaterial({
|
|
1406
1481
|
map: texture,
|
|
1407
1482
|
transparent: true,
|
|
1408
|
-
side:
|
|
1483
|
+
side: THREE24.DoubleSide
|
|
1409
1484
|
});
|
|
1410
1485
|
}
|
|
1411
1486
|
__name(createStandardMaterial, "createStandardMaterial");
|
|
1412
1487
|
function createVideoMesh(entityId, texture, options) {
|
|
1413
|
-
const geometry = new
|
|
1488
|
+
const geometry = new THREE24.PlaneGeometry(1, 1);
|
|
1414
1489
|
const material = options.isGreenScreen ? createChromaMaterial(texture, options) : createStandardMaterial(texture);
|
|
1415
|
-
const mesh = new
|
|
1490
|
+
const mesh = new THREE24.Mesh(geometry, material);
|
|
1416
1491
|
mesh.userData.entityId = entityId;
|
|
1417
1492
|
mesh.scale.set(options.width, options.height, 1);
|
|
1418
1493
|
return { mesh, material };
|
|
@@ -1447,7 +1522,7 @@ function createVideo({
|
|
|
1447
1522
|
payload,
|
|
1448
1523
|
isEditor
|
|
1449
1524
|
}) {
|
|
1450
|
-
const anchor = new
|
|
1525
|
+
const anchor = new THREE24.Object3D();
|
|
1451
1526
|
const path = payload.path ?? "";
|
|
1452
1527
|
const options = normalizeOptions(payload.options);
|
|
1453
1528
|
const entityId = createBaseEntity(world, anchor, {
|
|
@@ -1462,8 +1537,8 @@ function createVideo({
|
|
|
1462
1537
|
return entityId;
|
|
1463
1538
|
}
|
|
1464
1539
|
const video = createVideoElement(path, options);
|
|
1465
|
-
const texture = new
|
|
1466
|
-
texture.colorSpace =
|
|
1540
|
+
const texture = new THREE24.VideoTexture(video);
|
|
1541
|
+
texture.colorSpace = THREE24.SRGBColorSpace;
|
|
1467
1542
|
texture.needsUpdate = true;
|
|
1468
1543
|
const { mesh, material } = createVideoMesh(entityId, texture, options);
|
|
1469
1544
|
anchor.add(mesh);
|
|
@@ -1479,7 +1554,7 @@ function createVideo({
|
|
|
1479
1554
|
});
|
|
1480
1555
|
if (!isEditor && options.positional) {
|
|
1481
1556
|
const listener = getOrCreateListener2(camera);
|
|
1482
|
-
const audioNode = new
|
|
1557
|
+
const audioNode = new THREE24.PositionalAudio(listener);
|
|
1483
1558
|
audioNode.setVolume(options.volume);
|
|
1484
1559
|
audioNode.setRefDistance(options.refDistance);
|
|
1485
1560
|
audioNode.setDistanceModel(normalizeDistanceModel2(options.distanceModel));
|
|
@@ -1519,10 +1594,12 @@ function registerDefaultFactories(objectManagementSystem) {
|
|
|
1519
1594
|
objectManagementSystem.register("spotLight", createSpotLight);
|
|
1520
1595
|
objectManagementSystem.register("areaLight", createAreaLight);
|
|
1521
1596
|
objectManagementSystem.register("scriptObject", createScriptObject);
|
|
1597
|
+
objectManagementSystem.register("xrRig", createXRRig);
|
|
1598
|
+
objectManagementSystem.register("teleportArea", createTeleportArea);
|
|
1522
1599
|
registerDefaultComponentFactories(objectManagementSystem);
|
|
1523
1600
|
}
|
|
1524
1601
|
__name(registerDefaultFactories, "registerDefaultFactories");
|
|
1525
1602
|
|
|
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-
|
|
1603
|
+
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 };
|
|
1604
|
+
//# sourceMappingURL=chunk-PCOZLCXS.js.map
|
|
1605
|
+
//# sourceMappingURL=chunk-PCOZLCXS.js.map
|