@relu-interactives/spatial-ecs 0.4.4 → 0.5.0
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-ln4Q7Eot.d.cts → System-V_mv07le.d.cts} +2 -2
- package/dist/{System-ln4Q7Eot.d.ts → System-V_mv07le.d.ts} +2 -2
- package/dist/{XRHandPose-CxPv-LBo.d.cts → XRHandPose-CQTLGxFC.d.cts} +218 -2
- package/dist/{XRHandPose-BImIa4ZS.d.ts → XRHandPose-CU3vNFuS.d.ts} +218 -2
- package/dist/{chunk-4AK4I3QF.js → chunk-BUEKOSR5.js} +102 -3
- package/dist/chunk-BUEKOSR5.js.map +1 -0
- package/dist/{chunk-SGADE55G.js → chunk-RXBLOO5B.js} +249 -90
- package/dist/chunk-RXBLOO5B.js.map +1 -0
- package/dist/{chunk-4DWZK4X4.js → chunk-WJD2VKEH.js} +3 -3
- package/dist/chunk-WJD2VKEH.js.map +1 -0
- package/dist/{chunk-OY2OONRR.js → chunk-Z6ZMR3CS.js} +1374 -30
- package/dist/chunk-Z6ZMR3CS.js.map +1 -0
- package/dist/components/index.cjs +99 -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/docs/guide/mixed-reality.md +137 -3
- package/dist/docs/guide/spatial-ui.md +165 -0
- package/dist/docs/guide/vr-and-hand-poses.md +29 -0
- package/dist/docs/guide/world-api.md +1 -1
- package/dist/factories/index.cjs +372 -114
- package/dist/factories/index.cjs.map +1 -1
- package/dist/factories/index.d.cts +13 -3
- package/dist/factories/index.d.ts +13 -3
- package/dist/factories/index.js +3 -3
- package/dist/{index-CuGqxuk-.d.ts → index-C3ik3sA1.d.ts} +16 -3
- package/dist/{index-B2oHfqkj.d.ts → index-CppKDxbu.d.ts} +187 -3
- package/dist/{index-CQsHUez3.d.cts → index-Dlr-7-4m.d.cts} +16 -3
- package/dist/{index-7YCk4cmQ.d.cts → index-I2IsocYW.d.cts} +187 -3
- package/dist/index.cjs +1977 -366
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -9
- package/dist/index.d.ts +42 -9
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/systems/index.cjs +1465 -25
- 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-4AK4I3QF.js.map +0 -1
- package/dist/chunk-4DWZK4X4.js.map +0 -1
- package/dist/chunk-OY2OONRR.js.map +0 -1
- package/dist/chunk-SGADE55G.js.map +0 -1
package/dist/factories/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var THREE37 = require('three');
|
|
4
4
|
var SkeletonUtils_js = require('three/examples/jsm/utils/SkeletonUtils.js');
|
|
5
5
|
var RectAreaLightHelper_js = require('three/examples/jsm/helpers/RectAreaLightHelper.js');
|
|
6
6
|
var DRACOLoader_js = require('three/examples/jsm/loaders/DRACOLoader.js');
|
|
@@ -25,7 +25,7 @@ function _interopNamespace(e) {
|
|
|
25
25
|
return Object.freeze(n);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
var
|
|
28
|
+
var THREE37__namespace = /*#__PURE__*/_interopNamespace(THREE37);
|
|
29
29
|
|
|
30
30
|
var __defProp = Object.defineProperty;
|
|
31
31
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
@@ -298,14 +298,14 @@ var _AnimationComponent = class _AnimationComponent extends Component {
|
|
|
298
298
|
return;
|
|
299
299
|
}
|
|
300
300
|
this.importedClips = clips.map((entry) => {
|
|
301
|
-
if (entry instanceof
|
|
301
|
+
if (entry instanceof THREE37__namespace.AnimationClip) {
|
|
302
302
|
return { clip: entry, sourceUrl: null };
|
|
303
303
|
}
|
|
304
304
|
if (!entry || typeof entry !== "object") {
|
|
305
305
|
return null;
|
|
306
306
|
}
|
|
307
307
|
const candidate = entry;
|
|
308
|
-
if (!(candidate.clip instanceof
|
|
308
|
+
if (!(candidate.clip instanceof THREE37__namespace.AnimationClip)) {
|
|
309
309
|
return null;
|
|
310
310
|
}
|
|
311
311
|
return {
|
|
@@ -513,11 +513,11 @@ function normalizeDistanceModel(distanceModel) {
|
|
|
513
513
|
}
|
|
514
514
|
__name(normalizeDistanceModel, "normalizeDistanceModel");
|
|
515
515
|
function createConfiguredAudio(listener, options) {
|
|
516
|
-
const sound = options.positional ? new
|
|
516
|
+
const sound = options.positional ? new THREE37__namespace.PositionalAudio(listener) : new THREE37__namespace.Audio(listener);
|
|
517
517
|
sound.setLoop(options.loop);
|
|
518
518
|
sound.setVolume(options.volume);
|
|
519
519
|
sound.setPlaybackRate(options.pitch);
|
|
520
|
-
if (sound instanceof
|
|
520
|
+
if (sound instanceof THREE37__namespace.PositionalAudio) {
|
|
521
521
|
sound.setRefDistance(options.refDistance);
|
|
522
522
|
sound.setDistanceModel(normalizeDistanceModel(options.distanceModel));
|
|
523
523
|
sound.setRolloffFactor(options.rolloffFactor);
|
|
@@ -527,16 +527,16 @@ function createConfiguredAudio(listener, options) {
|
|
|
527
527
|
__name(createConfiguredAudio, "createConfiguredAudio");
|
|
528
528
|
function createAudioEditorHelper() {
|
|
529
529
|
if (typeof document === "undefined") {
|
|
530
|
-
const geometry = new
|
|
531
|
-
new
|
|
530
|
+
const geometry = new THREE37__namespace.EdgesGeometry(
|
|
531
|
+
new THREE37__namespace.OctahedronGeometry(0.22, 0)
|
|
532
532
|
);
|
|
533
|
-
const material2 = new
|
|
533
|
+
const material2 = new THREE37__namespace.LineBasicMaterial({
|
|
534
534
|
color: "#8bc8ff",
|
|
535
535
|
transparent: true,
|
|
536
536
|
opacity: 0.95,
|
|
537
537
|
depthTest: false
|
|
538
538
|
});
|
|
539
|
-
const fallback = new
|
|
539
|
+
const fallback = new THREE37__namespace.LineSegments(geometry, material2);
|
|
540
540
|
fallback.renderOrder = 10;
|
|
541
541
|
fallback.userData.ecsHelper = true;
|
|
542
542
|
fallback.visible = false;
|
|
@@ -548,7 +548,7 @@ function createAudioEditorHelper() {
|
|
|
548
548
|
canvas.height = size;
|
|
549
549
|
const ctx = canvas.getContext("2d");
|
|
550
550
|
if (!ctx) {
|
|
551
|
-
return new
|
|
551
|
+
return new THREE37__namespace.Object3D();
|
|
552
552
|
}
|
|
553
553
|
ctx.clearRect(0, 0, size, size);
|
|
554
554
|
ctx.fillStyle = "rgba(27, 35, 52, 0.9)";
|
|
@@ -579,14 +579,14 @@ function createAudioEditorHelper() {
|
|
|
579
579
|
ctx.beginPath();
|
|
580
580
|
ctx.arc(56, 48, 16, -0.8, 0.8);
|
|
581
581
|
ctx.stroke();
|
|
582
|
-
const texture = new
|
|
582
|
+
const texture = new THREE37__namespace.CanvasTexture(canvas);
|
|
583
583
|
texture.needsUpdate = true;
|
|
584
|
-
const material = new
|
|
584
|
+
const material = new THREE37__namespace.SpriteMaterial({
|
|
585
585
|
map: texture,
|
|
586
586
|
transparent: true,
|
|
587
587
|
depthTest: false
|
|
588
588
|
});
|
|
589
|
-
const helper = new
|
|
589
|
+
const helper = new THREE37__namespace.Sprite(material);
|
|
590
590
|
helper.scale.set(0.68, 0.68, 0.68);
|
|
591
591
|
helper.renderOrder = 10;
|
|
592
592
|
helper.userData.ecsHelper = true;
|
|
@@ -620,7 +620,7 @@ var DEFAULT_ORTHO_TOP = 5;
|
|
|
620
620
|
var DEFAULT_ORTHO_BOTTOM = -5;
|
|
621
621
|
var DEFAULT_ZOOM = 1;
|
|
622
622
|
function inferProjection(camera) {
|
|
623
|
-
if (camera instanceof
|
|
623
|
+
if (camera instanceof THREE37__namespace.OrthographicCamera) {
|
|
624
624
|
return "orthographic";
|
|
625
625
|
}
|
|
626
626
|
return "perspective";
|
|
@@ -641,7 +641,7 @@ function readCameraFar(camera) {
|
|
|
641
641
|
}
|
|
642
642
|
__name(readCameraFar, "readCameraFar");
|
|
643
643
|
function inferFov(camera) {
|
|
644
|
-
if (camera instanceof
|
|
644
|
+
if (camera instanceof THREE37__namespace.PerspectiveCamera && Number.isFinite(camera.fov)) {
|
|
645
645
|
return camera.fov;
|
|
646
646
|
}
|
|
647
647
|
return DEFAULT_FOV;
|
|
@@ -664,28 +664,28 @@ function inferFar(camera) {
|
|
|
664
664
|
}
|
|
665
665
|
__name(inferFar, "inferFar");
|
|
666
666
|
function inferOrthoLeft(camera) {
|
|
667
|
-
if (camera instanceof
|
|
667
|
+
if (camera instanceof THREE37__namespace.OrthographicCamera && Number.isFinite(camera.left)) {
|
|
668
668
|
return camera.left;
|
|
669
669
|
}
|
|
670
670
|
return DEFAULT_ORTHO_LEFT;
|
|
671
671
|
}
|
|
672
672
|
__name(inferOrthoLeft, "inferOrthoLeft");
|
|
673
673
|
function inferOrthoRight(camera) {
|
|
674
|
-
if (camera instanceof
|
|
674
|
+
if (camera instanceof THREE37__namespace.OrthographicCamera && Number.isFinite(camera.right)) {
|
|
675
675
|
return camera.right;
|
|
676
676
|
}
|
|
677
677
|
return DEFAULT_ORTHO_RIGHT;
|
|
678
678
|
}
|
|
679
679
|
__name(inferOrthoRight, "inferOrthoRight");
|
|
680
680
|
function inferOrthoTop(camera) {
|
|
681
|
-
if (camera instanceof
|
|
681
|
+
if (camera instanceof THREE37__namespace.OrthographicCamera && Number.isFinite(camera.top)) {
|
|
682
682
|
return camera.top;
|
|
683
683
|
}
|
|
684
684
|
return DEFAULT_ORTHO_TOP;
|
|
685
685
|
}
|
|
686
686
|
__name(inferOrthoTop, "inferOrthoTop");
|
|
687
687
|
function inferOrthoBottom(camera) {
|
|
688
|
-
if (camera instanceof
|
|
688
|
+
if (camera instanceof THREE37__namespace.OrthographicCamera && Number.isFinite(camera.bottom)) {
|
|
689
689
|
return camera.bottom;
|
|
690
690
|
}
|
|
691
691
|
return DEFAULT_ORTHO_BOTTOM;
|
|
@@ -701,7 +701,7 @@ __name(inferZoom, "inferZoom");
|
|
|
701
701
|
var _CameraComponent = class _CameraComponent extends Component {
|
|
702
702
|
constructor(payload = {}) {
|
|
703
703
|
super();
|
|
704
|
-
this.camera = payload.camera ?? new
|
|
704
|
+
this.camera = payload.camera ?? new THREE37__namespace.PerspectiveCamera();
|
|
705
705
|
this.type = payload.type ?? "3d";
|
|
706
706
|
this.isDefault = typeof payload.isDefault === "boolean" ? payload.isDefault : false;
|
|
707
707
|
this.projection = payload.projection ?? inferProjection(payload.camera);
|
|
@@ -732,7 +732,7 @@ var Object3DRef = _Object3DRef;
|
|
|
732
732
|
// core/factories/components/CameraFactory.ts
|
|
733
733
|
function createCameraComponent(world, entityId, payload = {}) {
|
|
734
734
|
const object = world.getComponent(entityId, Object3DRef)?.object;
|
|
735
|
-
const objectCamera = object instanceof
|
|
735
|
+
const objectCamera = object instanceof THREE37__namespace.Camera ? object : void 0;
|
|
736
736
|
const component = new CameraComponent({
|
|
737
737
|
...payload,
|
|
738
738
|
camera: payload.camera ?? objectCamera
|
|
@@ -1290,15 +1290,15 @@ function createValueState(light) {
|
|
|
1290
1290
|
castShadow: light.castShadow ?? false,
|
|
1291
1291
|
frustumCulling: light.frustumCulled
|
|
1292
1292
|
};
|
|
1293
|
-
if (light instanceof
|
|
1293
|
+
if (light instanceof THREE37__namespace.PointLight) {
|
|
1294
1294
|
base.distance = light.distance;
|
|
1295
1295
|
base.decay = light.decay;
|
|
1296
|
-
} else if (light instanceof
|
|
1296
|
+
} else if (light instanceof THREE37__namespace.SpotLight) {
|
|
1297
1297
|
base.distance = light.distance;
|
|
1298
1298
|
base.decay = light.decay;
|
|
1299
1299
|
base.angle = light.angle;
|
|
1300
1300
|
base.penumbra = light.penumbra;
|
|
1301
|
-
} else if (light instanceof
|
|
1301
|
+
} else if (light instanceof THREE37__namespace.RectAreaLight) {
|
|
1302
1302
|
base.width = light.width;
|
|
1303
1303
|
base.height = light.height;
|
|
1304
1304
|
}
|
|
@@ -1341,13 +1341,13 @@ function toHexColor2(value, fallback) {
|
|
|
1341
1341
|
}
|
|
1342
1342
|
__name(toHexColor2, "toHexColor");
|
|
1343
1343
|
function getMaterialType(material) {
|
|
1344
|
-
if (material instanceof
|
|
1344
|
+
if (material instanceof THREE37__namespace.MeshPhysicalMaterial) {
|
|
1345
1345
|
return "physical";
|
|
1346
1346
|
}
|
|
1347
|
-
if (material instanceof
|
|
1347
|
+
if (material instanceof THREE37__namespace.MeshPhongMaterial) {
|
|
1348
1348
|
return "phong";
|
|
1349
1349
|
}
|
|
1350
|
-
if (material instanceof
|
|
1350
|
+
if (material instanceof THREE37__namespace.MeshBasicMaterial) {
|
|
1351
1351
|
return "basic";
|
|
1352
1352
|
}
|
|
1353
1353
|
return "standard";
|
|
@@ -1382,8 +1382,8 @@ function createMaterialValue(material) {
|
|
|
1382
1382
|
opacity: typeof materialRecord.opacity === "number" ? materialRecord.opacity : 1,
|
|
1383
1383
|
emissive: toHexColor2(materialRecord.emissive, "#000000"),
|
|
1384
1384
|
emissiveIntensity: typeof materialRecord.emissiveIntensity === "number" ? materialRecord.emissiveIntensity : 0,
|
|
1385
|
-
side: typeof materialRecord.side === "number" ? materialRecord.side :
|
|
1386
|
-
blending: typeof materialRecord.blending === "number" ? materialRecord.blending :
|
|
1385
|
+
side: typeof materialRecord.side === "number" ? materialRecord.side : THREE37__namespace.FrontSide,
|
|
1386
|
+
blending: typeof materialRecord.blending === "number" ? materialRecord.blending : THREE37__namespace.NormalBlending,
|
|
1387
1387
|
depthTest: materialRecord.depthTest !== false,
|
|
1388
1388
|
depthWrite: materialRecord.depthWrite !== false,
|
|
1389
1389
|
wireframe: Boolean(materialRecord.wireframe),
|
|
@@ -1415,7 +1415,7 @@ function createMaterialValue(material) {
|
|
|
1415
1415
|
materialRecord.lightMap
|
|
1416
1416
|
),
|
|
1417
1417
|
envMap: textureImageSrc(materialRecord.envMap),
|
|
1418
|
-
textureFiltering: map?.magFilter ===
|
|
1418
|
+
textureFiltering: map?.magFilter === THREE37__namespace.NearestFilter ? "sharp" : "smooth",
|
|
1419
1419
|
useMipmaps: map?.generateMipmaps !== false
|
|
1420
1420
|
};
|
|
1421
1421
|
}
|
|
@@ -1430,8 +1430,8 @@ function defaultMaterialValue() {
|
|
|
1430
1430
|
opacity: 1,
|
|
1431
1431
|
emissive: "#000000",
|
|
1432
1432
|
emissiveIntensity: 0,
|
|
1433
|
-
side:
|
|
1434
|
-
blending:
|
|
1433
|
+
side: THREE37__namespace.FrontSide,
|
|
1434
|
+
blending: THREE37__namespace.NormalBlending,
|
|
1435
1435
|
depthTest: true,
|
|
1436
1436
|
depthWrite: true,
|
|
1437
1437
|
wireframe: false,
|
|
@@ -2002,14 +2002,14 @@ var _TransformComponent = class _TransformComponent extends Component {
|
|
|
2002
2002
|
z: scale.z ?? 1
|
|
2003
2003
|
};
|
|
2004
2004
|
}
|
|
2005
|
-
toPositionVector3(target = new
|
|
2005
|
+
toPositionVector3(target = new THREE37.Vector3()) {
|
|
2006
2006
|
return target.set(this.position.x, this.position.y, this.position.z);
|
|
2007
2007
|
}
|
|
2008
|
-
toRotationEuler(target = new
|
|
2008
|
+
toRotationEuler(target = new THREE37.Euler(), order = "XYZ") {
|
|
2009
2009
|
return target.set(this.rotation.x, this.rotation.y, this.rotation.z, order);
|
|
2010
2010
|
}
|
|
2011
|
-
toRotationQuaternion(target = new
|
|
2012
|
-
const euler = new
|
|
2011
|
+
toRotationQuaternion(target = new THREE37.Quaternion(), order = "XYZ") {
|
|
2012
|
+
const euler = new THREE37.Euler(
|
|
2013
2013
|
this.rotation.x,
|
|
2014
2014
|
this.rotation.y,
|
|
2015
2015
|
this.rotation.z,
|
|
@@ -2017,7 +2017,7 @@ var _TransformComponent = class _TransformComponent extends Component {
|
|
|
2017
2017
|
);
|
|
2018
2018
|
return target.setFromEuler(euler);
|
|
2019
2019
|
}
|
|
2020
|
-
toScaleVector3(target = new
|
|
2020
|
+
toScaleVector3(target = new THREE37.Vector3()) {
|
|
2021
2021
|
return target.set(this.scale.x, this.scale.y, this.scale.z);
|
|
2022
2022
|
}
|
|
2023
2023
|
setPosition(input) {
|
|
@@ -2035,8 +2035,8 @@ var _TransformComponent = class _TransformComponent extends Component {
|
|
|
2035
2035
|
return this;
|
|
2036
2036
|
}
|
|
2037
2037
|
setRotation(input, order = "XYZ") {
|
|
2038
|
-
if (input instanceof
|
|
2039
|
-
const euler = new
|
|
2038
|
+
if (input instanceof THREE37.Quaternion) {
|
|
2039
|
+
const euler = new THREE37.Euler().setFromQuaternion(input, order);
|
|
2040
2040
|
this.rotation.x = euler.x;
|
|
2041
2041
|
this.rotation.y = euler.y;
|
|
2042
2042
|
this.rotation.z = euler.z;
|
|
@@ -2460,6 +2460,140 @@ function createXRInteractorSideComponent(world, entityId, ...args) {
|
|
|
2460
2460
|
}
|
|
2461
2461
|
__name(createXRInteractorSideComponent, "createXRInteractorSideComponent");
|
|
2462
2462
|
|
|
2463
|
+
// core/components/UIButton.ts
|
|
2464
|
+
var _UIButtonComponent = class _UIButtonComponent extends Component {
|
|
2465
|
+
constructor(options) {
|
|
2466
|
+
super();
|
|
2467
|
+
this.label = options?.label ?? "Button";
|
|
2468
|
+
this.actionId = options?.actionId ?? "";
|
|
2469
|
+
this.width = options?.width ?? 0.3;
|
|
2470
|
+
this.height = options?.height ?? 0.1;
|
|
2471
|
+
this.fontSize = options?.fontSize ?? 0.03;
|
|
2472
|
+
this.fontWeight = options?.fontWeight ?? 600;
|
|
2473
|
+
this.textColor = options?.textColor ?? "#ffffff";
|
|
2474
|
+
this.backgroundColor = options?.backgroundColor ?? "#2a2a2a";
|
|
2475
|
+
this.backgroundOpacity = options?.backgroundOpacity ?? 1;
|
|
2476
|
+
this.cornerRadius = options?.cornerRadius ?? 0.02;
|
|
2477
|
+
this.borderWidth = options?.borderWidth ?? 2e-3;
|
|
2478
|
+
this.borderColor = options?.borderColor ?? "#3a3a3a";
|
|
2479
|
+
}
|
|
2480
|
+
};
|
|
2481
|
+
__name(_UIButtonComponent, "UIButtonComponent");
|
|
2482
|
+
var UIButtonComponent = _UIButtonComponent;
|
|
2483
|
+
|
|
2484
|
+
// core/factories/components/UIButtonComponentFactory.ts
|
|
2485
|
+
function createUIButtonComponent(world, entityId, ...args) {
|
|
2486
|
+
const component = new UIButtonComponent(...args);
|
|
2487
|
+
world.addComponent(entityId, component);
|
|
2488
|
+
return component;
|
|
2489
|
+
}
|
|
2490
|
+
__name(createUIButtonComponent, "createUIButtonComponent");
|
|
2491
|
+
|
|
2492
|
+
// core/components/UIPanel.ts
|
|
2493
|
+
var _UIPanelComponent = class _UIPanelComponent extends Component {
|
|
2494
|
+
constructor(options) {
|
|
2495
|
+
super();
|
|
2496
|
+
this.width = options?.width ?? 0.6;
|
|
2497
|
+
this.height = options?.height ?? 0.4;
|
|
2498
|
+
this.backgroundColor = options?.backgroundColor ?? "#1c1c1c";
|
|
2499
|
+
this.backgroundOpacity = options?.backgroundOpacity ?? 0.92;
|
|
2500
|
+
this.cornerRadius = options?.cornerRadius ?? 0.02;
|
|
2501
|
+
this.borderWidth = options?.borderWidth ?? 0;
|
|
2502
|
+
this.borderColor = options?.borderColor ?? "#333333";
|
|
2503
|
+
this.pixelDensity = options?.pixelDensity ?? 1024;
|
|
2504
|
+
this.follow = options?.follow ?? "world";
|
|
2505
|
+
}
|
|
2506
|
+
};
|
|
2507
|
+
__name(_UIPanelComponent, "UIPanelComponent");
|
|
2508
|
+
var UIPanelComponent = _UIPanelComponent;
|
|
2509
|
+
|
|
2510
|
+
// core/factories/components/UIPanelComponentFactory.ts
|
|
2511
|
+
function createUIPanelComponent(world, entityId, ...args) {
|
|
2512
|
+
const component = new UIPanelComponent(...args);
|
|
2513
|
+
world.addComponent(entityId, component);
|
|
2514
|
+
return component;
|
|
2515
|
+
}
|
|
2516
|
+
__name(createUIPanelComponent, "createUIPanelComponent");
|
|
2517
|
+
|
|
2518
|
+
// core/components/UISlider.ts
|
|
2519
|
+
var _UISliderComponent = class _UISliderComponent extends Component {
|
|
2520
|
+
constructor(options) {
|
|
2521
|
+
super();
|
|
2522
|
+
this.min = options?.min ?? 0;
|
|
2523
|
+
this.max = options?.max ?? Math.max(1, this.min + 1);
|
|
2524
|
+
if (this.max <= this.min) this.max = this.min + 1;
|
|
2525
|
+
const v = options?.value ?? (this.min + this.max) / 2;
|
|
2526
|
+
this.value = Math.min(this.max, Math.max(this.min, v));
|
|
2527
|
+
this.actionId = options?.actionId ?? "";
|
|
2528
|
+
this.width = options?.width ?? 0.4;
|
|
2529
|
+
this.height = options?.height ?? 0.06;
|
|
2530
|
+
this.trackColor = options?.trackColor ?? "#2a2a2a";
|
|
2531
|
+
this.accentColor = options?.accentColor ?? "#ff6b35";
|
|
2532
|
+
this.knobColor = options?.knobColor ?? "#ffffff";
|
|
2533
|
+
}
|
|
2534
|
+
};
|
|
2535
|
+
__name(_UISliderComponent, "UISliderComponent");
|
|
2536
|
+
var UISliderComponent = _UISliderComponent;
|
|
2537
|
+
|
|
2538
|
+
// core/factories/components/UISliderComponentFactory.ts
|
|
2539
|
+
function createUISliderComponent(world, entityId, ...args) {
|
|
2540
|
+
const component = new UISliderComponent(...args);
|
|
2541
|
+
world.addComponent(entityId, component);
|
|
2542
|
+
return component;
|
|
2543
|
+
}
|
|
2544
|
+
__name(createUISliderComponent, "createUISliderComponent");
|
|
2545
|
+
|
|
2546
|
+
// core/components/UIText.ts
|
|
2547
|
+
var _UITextComponent = class _UITextComponent extends Component {
|
|
2548
|
+
constructor(options) {
|
|
2549
|
+
super();
|
|
2550
|
+
this.text = options?.text ?? "Text";
|
|
2551
|
+
this.width = options?.width ?? 0.5;
|
|
2552
|
+
this.height = options?.height ?? 0.12;
|
|
2553
|
+
this.fontSize = options?.fontSize ?? 0.035;
|
|
2554
|
+
this.fontWeight = options?.fontWeight ?? 500;
|
|
2555
|
+
this.color = options?.color ?? "#ffffff";
|
|
2556
|
+
this.align = options?.align ?? "center";
|
|
2557
|
+
this.valign = options?.valign ?? "middle";
|
|
2558
|
+
this.lineHeight = options?.lineHeight ?? 1.25;
|
|
2559
|
+
this.padding = options?.padding ?? 0.01;
|
|
2560
|
+
}
|
|
2561
|
+
};
|
|
2562
|
+
__name(_UITextComponent, "UITextComponent");
|
|
2563
|
+
var UITextComponent = _UITextComponent;
|
|
2564
|
+
|
|
2565
|
+
// core/factories/components/UITextComponentFactory.ts
|
|
2566
|
+
function createUITextComponent(world, entityId, ...args) {
|
|
2567
|
+
const component = new UITextComponent(...args);
|
|
2568
|
+
world.addComponent(entityId, component);
|
|
2569
|
+
return component;
|
|
2570
|
+
}
|
|
2571
|
+
__name(createUITextComponent, "createUITextComponent");
|
|
2572
|
+
|
|
2573
|
+
// core/components/UIToggle.ts
|
|
2574
|
+
var _UIToggleComponent = class _UIToggleComponent extends Component {
|
|
2575
|
+
constructor(options) {
|
|
2576
|
+
super();
|
|
2577
|
+
this.value = options?.value ?? false;
|
|
2578
|
+
this.actionId = options?.actionId ?? "";
|
|
2579
|
+
this.width = options?.width ?? 0.14;
|
|
2580
|
+
this.height = options?.height ?? 0.07;
|
|
2581
|
+
this.trackColor = options?.trackColor ?? "#2a2a2a";
|
|
2582
|
+
this.accentColor = options?.accentColor ?? "#ff6b35";
|
|
2583
|
+
this.knobColor = options?.knobColor ?? "#ffffff";
|
|
2584
|
+
}
|
|
2585
|
+
};
|
|
2586
|
+
__name(_UIToggleComponent, "UIToggleComponent");
|
|
2587
|
+
var UIToggleComponent = _UIToggleComponent;
|
|
2588
|
+
|
|
2589
|
+
// core/factories/components/UIToggleComponentFactory.ts
|
|
2590
|
+
function createUIToggleComponent(world, entityId, ...args) {
|
|
2591
|
+
const component = new UIToggleComponent(...args);
|
|
2592
|
+
world.addComponent(entityId, component);
|
|
2593
|
+
return component;
|
|
2594
|
+
}
|
|
2595
|
+
__name(createUIToggleComponent, "createUIToggleComponent");
|
|
2596
|
+
|
|
2463
2597
|
// core/factories/registerDefaultComponentFactories.ts
|
|
2464
2598
|
function registerDefaultComponentFactories(objectManagementSystem) {
|
|
2465
2599
|
objectManagementSystem.registerComponentFactory("animation", createAnimationComponent);
|
|
@@ -2473,6 +2607,11 @@ function registerDefaultComponentFactories(objectManagementSystem) {
|
|
|
2473
2607
|
objectManagementSystem.registerComponentFactory("vrTeleportArea", createVRTeleportAreaComponent);
|
|
2474
2608
|
objectManagementSystem.registerComponentFactory("xrHandPose", createXRHandPoseComponent);
|
|
2475
2609
|
objectManagementSystem.registerComponentFactory("xrAnchor", createXRAnchorComponent);
|
|
2610
|
+
objectManagementSystem.registerComponentFactory("uiPanel", createUIPanelComponent);
|
|
2611
|
+
objectManagementSystem.registerComponentFactory("uiText", createUITextComponent);
|
|
2612
|
+
objectManagementSystem.registerComponentFactory("uiButton", createUIButtonComponent);
|
|
2613
|
+
objectManagementSystem.registerComponentFactory("uiToggle", createUIToggleComponent);
|
|
2614
|
+
objectManagementSystem.registerComponentFactory("uiSlider", createUISliderComponent);
|
|
2476
2615
|
objectManagementSystem.registerComponentFactory("xrInteractable", createXRInteractableComponent);
|
|
2477
2616
|
objectManagementSystem.registerComponentFactory("xrInteractor", createXRInteractorComponent);
|
|
2478
2617
|
objectManagementSystem.registerComponentFactory("xrInteractorSide", createXRInteractorSideComponent);
|
|
@@ -2519,7 +2658,7 @@ var SHARED_MODEL_RESOURCE_FLAG = "spatialEcsSharedModelResource";
|
|
|
2519
2658
|
var modelCache = /* @__PURE__ */ new Map();
|
|
2520
2659
|
function markSharedResources(root) {
|
|
2521
2660
|
root.traverse((child) => {
|
|
2522
|
-
if (!(child instanceof
|
|
2661
|
+
if (!(child instanceof THREE37__namespace.Mesh)) {
|
|
2523
2662
|
return;
|
|
2524
2663
|
}
|
|
2525
2664
|
if (child.geometry) {
|
|
@@ -2593,10 +2732,10 @@ __name(createBaseEntity, "createBaseEntity");
|
|
|
2593
2732
|
// core/factories/objects/AudioFactory.ts
|
|
2594
2733
|
function getOrCreateListener(camera) {
|
|
2595
2734
|
const existing = camera.userData.ecsAudioListener;
|
|
2596
|
-
if (existing instanceof
|
|
2735
|
+
if (existing instanceof THREE37__namespace.AudioListener) {
|
|
2597
2736
|
return existing;
|
|
2598
2737
|
}
|
|
2599
|
-
const listener = new
|
|
2738
|
+
const listener = new THREE37__namespace.AudioListener();
|
|
2600
2739
|
camera.add(listener);
|
|
2601
2740
|
camera.userData.ecsAudioListener = listener;
|
|
2602
2741
|
return listener;
|
|
@@ -2609,7 +2748,7 @@ function createAudio({
|
|
|
2609
2748
|
payload,
|
|
2610
2749
|
isEditor
|
|
2611
2750
|
}) {
|
|
2612
|
-
const anchor = new
|
|
2751
|
+
const anchor = new THREE37__namespace.Object3D();
|
|
2613
2752
|
const entityId = createBaseEntity(world, anchor, {
|
|
2614
2753
|
label: payload.name ?? "Audio",
|
|
2615
2754
|
entityType: "audio",
|
|
@@ -2631,7 +2770,7 @@ function createAudio({
|
|
|
2631
2770
|
return entityId;
|
|
2632
2771
|
}
|
|
2633
2772
|
if (!isEditor) {
|
|
2634
|
-
const loader = new
|
|
2773
|
+
const loader = new THREE37__namespace.AudioLoader();
|
|
2635
2774
|
loader.load(
|
|
2636
2775
|
audio.path,
|
|
2637
2776
|
(buffer) => {
|
|
@@ -2706,7 +2845,7 @@ function applyCameraSettings(camera, options) {
|
|
|
2706
2845
|
const near = typeof options.near === "number" ? options.near : DEFAULT_NEAR2;
|
|
2707
2846
|
const far = typeof options.far === "number" ? options.far : DEFAULT_FAR2;
|
|
2708
2847
|
const projection = options.projection;
|
|
2709
|
-
if (camera instanceof
|
|
2848
|
+
if (camera instanceof THREE37__namespace.PerspectiveCamera) {
|
|
2710
2849
|
if (!projection || projection === "perspective") {
|
|
2711
2850
|
camera.fov = typeof options.fov === "number" ? options.fov : DEFAULT_FOV2;
|
|
2712
2851
|
}
|
|
@@ -2716,7 +2855,7 @@ function applyCameraSettings(camera, options) {
|
|
|
2716
2855
|
camera.updateProjectionMatrix();
|
|
2717
2856
|
return;
|
|
2718
2857
|
}
|
|
2719
|
-
if (camera instanceof
|
|
2858
|
+
if (camera instanceof THREE37__namespace.OrthographicCamera) {
|
|
2720
2859
|
camera.left = typeof options.left === "number" ? options.left : -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2721
2860
|
camera.right = typeof options.right === "number" ? options.right : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2722
2861
|
camera.top = typeof options.top === "number" ? options.top : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
@@ -2737,7 +2876,7 @@ function createCameraObject(options) {
|
|
|
2737
2876
|
const bottom = options.bottom ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2738
2877
|
const left = options.left ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2739
2878
|
const right = options.right ?? DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2740
|
-
const camera = new
|
|
2879
|
+
const camera = new THREE37__namespace.OrthographicCamera(
|
|
2741
2880
|
left,
|
|
2742
2881
|
right,
|
|
2743
2882
|
top,
|
|
@@ -2749,7 +2888,7 @@ function createCameraObject(options) {
|
|
|
2749
2888
|
camera.updateProjectionMatrix();
|
|
2750
2889
|
return camera;
|
|
2751
2890
|
}
|
|
2752
|
-
return new
|
|
2891
|
+
return new THREE37__namespace.PerspectiveCamera(
|
|
2753
2892
|
options.fov ?? DEFAULT_FOV2,
|
|
2754
2893
|
readViewportAspect(),
|
|
2755
2894
|
near,
|
|
@@ -2767,7 +2906,7 @@ function createCamera({ world, scene, camera, payload, isEditor }) {
|
|
|
2767
2906
|
transformInput: payload.transform
|
|
2768
2907
|
});
|
|
2769
2908
|
const objectRef = world.getComponent(entityId, Object3DRef);
|
|
2770
|
-
if (objectRef?.object instanceof
|
|
2909
|
+
if (objectRef?.object instanceof THREE37__namespace.Camera) {
|
|
2771
2910
|
objectRef.object.userData.entityId = entityId;
|
|
2772
2911
|
}
|
|
2773
2912
|
const componentOptions = {
|
|
@@ -2799,9 +2938,9 @@ function createCapsule({
|
|
|
2799
2938
|
scene,
|
|
2800
2939
|
payload
|
|
2801
2940
|
}) {
|
|
2802
|
-
const geometry = new
|
|
2803
|
-
const material = new
|
|
2804
|
-
const mesh = new
|
|
2941
|
+
const geometry = new THREE37__namespace.CapsuleGeometry(0.5, 1, 4, 8);
|
|
2942
|
+
const material = new THREE37__namespace.MeshStandardMaterial({ color: "#ffffff" });
|
|
2943
|
+
const mesh = new THREE37__namespace.Mesh(geometry, material);
|
|
2805
2944
|
const entityId = createBaseEntity(world, mesh, {
|
|
2806
2945
|
label: payload.name ?? "Capsule",
|
|
2807
2946
|
entityType: "capsule",
|
|
@@ -2821,9 +2960,9 @@ function createCapsule({
|
|
|
2821
2960
|
}
|
|
2822
2961
|
__name(createCapsule, "createCapsule");
|
|
2823
2962
|
function createCube({ world, scene, payload }) {
|
|
2824
|
-
const geometry = new
|
|
2825
|
-
const material = new
|
|
2826
|
-
const mesh = new
|
|
2963
|
+
const geometry = new THREE37__namespace.BoxGeometry(1, 1, 1);
|
|
2964
|
+
const material = new THREE37__namespace.MeshStandardMaterial({ color: "#ffffff" });
|
|
2965
|
+
const mesh = new THREE37__namespace.Mesh(geometry, material);
|
|
2827
2966
|
const entityId = createBaseEntity(world, mesh, {
|
|
2828
2967
|
label: payload.name ?? "Cube",
|
|
2829
2968
|
entityType: "cube",
|
|
@@ -2848,9 +2987,9 @@ function createCylinder({
|
|
|
2848
2987
|
scene,
|
|
2849
2988
|
payload
|
|
2850
2989
|
}) {
|
|
2851
|
-
const geometry = new
|
|
2852
|
-
const material = new
|
|
2853
|
-
const mesh = new
|
|
2990
|
+
const geometry = new THREE37__namespace.CylinderGeometry(0.5, 0.5, 1, 20);
|
|
2991
|
+
const material = new THREE37__namespace.MeshStandardMaterial({ color: "#ffffff" });
|
|
2992
|
+
const mesh = new THREE37__namespace.Mesh(geometry, material);
|
|
2854
2993
|
const entityId = createBaseEntity(world, mesh, {
|
|
2855
2994
|
label: payload.name ?? "Cylinder",
|
|
2856
2995
|
entityType: "cylinder",
|
|
@@ -2870,7 +3009,7 @@ function createCylinder({
|
|
|
2870
3009
|
}
|
|
2871
3010
|
__name(createCylinder, "createCylinder");
|
|
2872
3011
|
function createEmpty({ world, scene, payload, isEditor }) {
|
|
2873
|
-
const object = new
|
|
3012
|
+
const object = new THREE37__namespace.Group();
|
|
2874
3013
|
const entityId = createBaseEntity(world, object, {
|
|
2875
3014
|
label: payload.name ?? "Empty",
|
|
2876
3015
|
entityType: "empty",
|
|
@@ -2881,7 +3020,7 @@ function createEmpty({ world, scene, payload, isEditor }) {
|
|
|
2881
3020
|
}
|
|
2882
3021
|
__name(createEmpty, "createEmpty");
|
|
2883
3022
|
function createImage({ world, scene, payload }) {
|
|
2884
|
-
const anchor = new
|
|
3023
|
+
const anchor = new THREE37__namespace.Object3D();
|
|
2885
3024
|
const imagePath = payload.path ?? "";
|
|
2886
3025
|
const entityId = createBaseEntity(world, anchor, {
|
|
2887
3026
|
label: payload.name ?? "Image",
|
|
@@ -2894,7 +3033,7 @@ function createImage({ world, scene, payload }) {
|
|
|
2894
3033
|
if (!imagePath) {
|
|
2895
3034
|
return entityId;
|
|
2896
3035
|
}
|
|
2897
|
-
const loader = new
|
|
3036
|
+
const loader = new THREE37__namespace.TextureLoader();
|
|
2898
3037
|
loader.load(
|
|
2899
3038
|
imagePath,
|
|
2900
3039
|
(texture) => {
|
|
@@ -2902,13 +3041,13 @@ function createImage({ world, scene, payload }) {
|
|
|
2902
3041
|
texture.dispose();
|
|
2903
3042
|
return;
|
|
2904
3043
|
}
|
|
2905
|
-
const material = new
|
|
3044
|
+
const material = new THREE37__namespace.MeshBasicMaterial({
|
|
2906
3045
|
map: texture,
|
|
2907
3046
|
transparent: true,
|
|
2908
|
-
side:
|
|
3047
|
+
side: THREE37__namespace.DoubleSide
|
|
2909
3048
|
});
|
|
2910
|
-
const geometry = new
|
|
2911
|
-
const plane = new
|
|
3049
|
+
const geometry = new THREE37__namespace.PlaneGeometry(1, 1);
|
|
3050
|
+
const plane = new THREE37__namespace.Mesh(geometry, material);
|
|
2912
3051
|
plane.userData.entityId = entityId;
|
|
2913
3052
|
const textureImage = texture.image;
|
|
2914
3053
|
const width = textureImage?.width ?? 1;
|
|
@@ -2954,7 +3093,7 @@ function createImageTarget({
|
|
|
2954
3093
|
payload,
|
|
2955
3094
|
isEditor
|
|
2956
3095
|
}) {
|
|
2957
|
-
const anchor = new
|
|
3096
|
+
const anchor = new THREE37__namespace.Object3D();
|
|
2958
3097
|
const imagePath = payload.path ?? "";
|
|
2959
3098
|
const entityId = createBaseEntity(world, anchor, {
|
|
2960
3099
|
label: payload.name ?? "Image Target",
|
|
@@ -2971,7 +3110,7 @@ function createImageTarget({
|
|
|
2971
3110
|
if (!isEditor || !imagePath) {
|
|
2972
3111
|
return entityId;
|
|
2973
3112
|
}
|
|
2974
|
-
const loader = new
|
|
3113
|
+
const loader = new THREE37__namespace.TextureLoader();
|
|
2975
3114
|
loader.load(
|
|
2976
3115
|
imagePath,
|
|
2977
3116
|
(texture) => {
|
|
@@ -2979,13 +3118,13 @@ function createImageTarget({
|
|
|
2979
3118
|
texture.dispose();
|
|
2980
3119
|
return;
|
|
2981
3120
|
}
|
|
2982
|
-
const material = new
|
|
3121
|
+
const material = new THREE37__namespace.MeshBasicMaterial({
|
|
2983
3122
|
map: texture,
|
|
2984
3123
|
transparent: true,
|
|
2985
|
-
side:
|
|
3124
|
+
side: THREE37__namespace.DoubleSide
|
|
2986
3125
|
});
|
|
2987
|
-
const geometry = new
|
|
2988
|
-
const plane = new
|
|
3126
|
+
const geometry = new THREE37__namespace.PlaneGeometry(1, 1);
|
|
3127
|
+
const plane = new THREE37__namespace.Mesh(geometry, material);
|
|
2989
3128
|
plane.userData.entityId = entityId;
|
|
2990
3129
|
const textureImage = texture.image;
|
|
2991
3130
|
const width = textureImage?.width ?? 1;
|
|
@@ -3036,7 +3175,7 @@ function createInstancedMesh({
|
|
|
3036
3175
|
scene,
|
|
3037
3176
|
payload
|
|
3038
3177
|
}) {
|
|
3039
|
-
const anchor = new
|
|
3178
|
+
const anchor = new THREE37__namespace.Object3D();
|
|
3040
3179
|
const opts = payload.options ?? {};
|
|
3041
3180
|
const meshKind = isInstancedMeshKind(opts.meshKind) ? opts.meshKind : "cube";
|
|
3042
3181
|
const meshParameters = opts.meshParameters && typeof opts.meshParameters === "object" ? opts.meshParameters : void 0;
|
|
@@ -3107,7 +3246,7 @@ function createAmbientLight({
|
|
|
3107
3246
|
scene,
|
|
3108
3247
|
payload
|
|
3109
3248
|
}) {
|
|
3110
|
-
const light = new
|
|
3249
|
+
const light = new THREE37__namespace.AmbientLight("#ffffff", 0.6);
|
|
3111
3250
|
const entityId = createBaseEntity(world, light, {
|
|
3112
3251
|
label: payload.name ?? "Ambient Light",
|
|
3113
3252
|
entityType: "ambientLight",
|
|
@@ -3124,7 +3263,7 @@ function createAreaLight({
|
|
|
3124
3263
|
payload,
|
|
3125
3264
|
isEditor
|
|
3126
3265
|
}) {
|
|
3127
|
-
const light = new
|
|
3266
|
+
const light = new THREE37__namespace.RectAreaLight("#ffffff", 5, 4, 4);
|
|
3128
3267
|
light.lookAt(0, 0, 0);
|
|
3129
3268
|
const entityId = createBaseEntity(world, light, {
|
|
3130
3269
|
label: payload.name ?? "Area Light",
|
|
@@ -3153,7 +3292,7 @@ function createDirectionalLight({
|
|
|
3153
3292
|
payload,
|
|
3154
3293
|
isEditor
|
|
3155
3294
|
}) {
|
|
3156
|
-
const light = new
|
|
3295
|
+
const light = new THREE37__namespace.DirectionalLight("#ffffff", 1.5);
|
|
3157
3296
|
light.castShadow = true;
|
|
3158
3297
|
const entityId = createBaseEntity(world, light, {
|
|
3159
3298
|
label: payload.name ?? "Directional Light",
|
|
@@ -3164,7 +3303,7 @@ function createDirectionalLight({
|
|
|
3164
3303
|
});
|
|
3165
3304
|
createLightComponent(world, entityId, light);
|
|
3166
3305
|
if (isEditor) {
|
|
3167
|
-
const helper = new
|
|
3306
|
+
const helper = new THREE37__namespace.DirectionalLightHelper(light, 1.8, "#38bdf8");
|
|
3168
3307
|
helper.onBeforeRender = () => {
|
|
3169
3308
|
helper.update();
|
|
3170
3309
|
};
|
|
@@ -3182,7 +3321,7 @@ function createPointLight({
|
|
|
3182
3321
|
payload,
|
|
3183
3322
|
isEditor
|
|
3184
3323
|
}) {
|
|
3185
|
-
const light = new
|
|
3324
|
+
const light = new THREE37__namespace.PointLight("#ffffff", 1, 10);
|
|
3186
3325
|
const entityId = createBaseEntity(world, light, {
|
|
3187
3326
|
label: payload.name ?? "Point Light",
|
|
3188
3327
|
entityType: "pointLight",
|
|
@@ -3192,7 +3331,7 @@ function createPointLight({
|
|
|
3192
3331
|
});
|
|
3193
3332
|
createLightComponent(world, entityId, light);
|
|
3194
3333
|
if (isEditor) {
|
|
3195
|
-
const helper = new
|
|
3334
|
+
const helper = new THREE37__namespace.PointLightHelper(light, 0.35, "#fbbf24");
|
|
3196
3335
|
helper.onBeforeRender = () => {
|
|
3197
3336
|
helper.update();
|
|
3198
3337
|
};
|
|
@@ -3210,7 +3349,7 @@ function createSpotLight({
|
|
|
3210
3349
|
payload,
|
|
3211
3350
|
isEditor
|
|
3212
3351
|
}) {
|
|
3213
|
-
const light = new
|
|
3352
|
+
const light = new THREE37__namespace.SpotLight("#ffffff", 1, 20, Math.PI / 6, 0.1, 1);
|
|
3214
3353
|
const entityId = createBaseEntity(world, light, {
|
|
3215
3354
|
label: payload.name ?? "Spot Light",
|
|
3216
3355
|
entityType: "spotLight",
|
|
@@ -3220,7 +3359,7 @@ function createSpotLight({
|
|
|
3220
3359
|
});
|
|
3221
3360
|
createLightComponent(world, entityId, light);
|
|
3222
3361
|
if (isEditor) {
|
|
3223
|
-
const helper = new
|
|
3362
|
+
const helper = new THREE37__namespace.SpotLightHelper(light, "#f59e0b");
|
|
3224
3363
|
helper.onBeforeRender = () => {
|
|
3225
3364
|
helper.update();
|
|
3226
3365
|
};
|
|
@@ -3280,7 +3419,7 @@ function createModel({
|
|
|
3280
3419
|
payload,
|
|
3281
3420
|
isEditor
|
|
3282
3421
|
}) {
|
|
3283
|
-
const anchor = new
|
|
3422
|
+
const anchor = new THREE37__namespace.Object3D();
|
|
3284
3423
|
const modelPath = payload.path ?? "";
|
|
3285
3424
|
const entityId = createBaseEntity(world, anchor, {
|
|
3286
3425
|
label: payload.name ?? "Model",
|
|
@@ -3346,12 +3485,12 @@ function createModel({
|
|
|
3346
3485
|
}
|
|
3347
3486
|
__name(createModel, "createModel");
|
|
3348
3487
|
function createPlane({ world, scene, payload }) {
|
|
3349
|
-
const geometry = new
|
|
3350
|
-
const material = new
|
|
3488
|
+
const geometry = new THREE37__namespace.PlaneGeometry(100, 100);
|
|
3489
|
+
const material = new THREE37__namespace.MeshStandardMaterial({
|
|
3351
3490
|
color: "#ffffff",
|
|
3352
|
-
side:
|
|
3491
|
+
side: THREE37__namespace.DoubleSide
|
|
3353
3492
|
});
|
|
3354
|
-
const mesh = new
|
|
3493
|
+
const mesh = new THREE37__namespace.Mesh(geometry, material);
|
|
3355
3494
|
const entityId = createBaseEntity(
|
|
3356
3495
|
world,
|
|
3357
3496
|
mesh,
|
|
@@ -3387,7 +3526,7 @@ function createScriptObject({
|
|
|
3387
3526
|
scene,
|
|
3388
3527
|
payload
|
|
3389
3528
|
}) {
|
|
3390
|
-
const object = new
|
|
3529
|
+
const object = new THREE37__namespace.Group();
|
|
3391
3530
|
const entityId = createBaseEntity(world, object, {
|
|
3392
3531
|
label: payload.name ?? "Script Object",
|
|
3393
3532
|
entityType: "scriptObject",
|
|
@@ -3412,15 +3551,15 @@ function createTeleportArea({
|
|
|
3412
3551
|
const options = payload.options ?? {};
|
|
3413
3552
|
const width = typeof options.width === "number" ? options.width : 10;
|
|
3414
3553
|
const depth = typeof options.depth === "number" ? options.depth : 10;
|
|
3415
|
-
const geometry = new
|
|
3416
|
-
const material = new
|
|
3554
|
+
const geometry = new THREE37__namespace.PlaneGeometry(width, depth);
|
|
3555
|
+
const material = new THREE37__namespace.MeshBasicMaterial({
|
|
3417
3556
|
color: "#4da3ff",
|
|
3418
3557
|
transparent: true,
|
|
3419
3558
|
opacity: 0.18,
|
|
3420
|
-
side:
|
|
3559
|
+
side: THREE37__namespace.DoubleSide,
|
|
3421
3560
|
depthWrite: false
|
|
3422
3561
|
});
|
|
3423
|
-
const object = new
|
|
3562
|
+
const object = new THREE37__namespace.Mesh(geometry, material);
|
|
3424
3563
|
const entityId = createBaseEntity(world, object, {
|
|
3425
3564
|
label: payload.name ?? "Teleport Area",
|
|
3426
3565
|
entityType: "teleportArea",
|
|
@@ -3448,7 +3587,7 @@ function createXRInteractor({
|
|
|
3448
3587
|
scene,
|
|
3449
3588
|
payload
|
|
3450
3589
|
}) {
|
|
3451
|
-
const root = new
|
|
3590
|
+
const root = new THREE37__namespace.Group();
|
|
3452
3591
|
const options = payload.options ?? {};
|
|
3453
3592
|
const entityId = createBaseEntity(world, root, {
|
|
3454
3593
|
label: payload.name ?? "XR Interactor",
|
|
@@ -3461,7 +3600,7 @@ function createXRInteractor({
|
|
|
3461
3600
|
return entityId;
|
|
3462
3601
|
}
|
|
3463
3602
|
for (const side of ["left", "right"]) {
|
|
3464
|
-
const slot = new
|
|
3603
|
+
const slot = new THREE37__namespace.Group();
|
|
3465
3604
|
const label = side === "left" ? "Left Interactor" : "Right Interactor";
|
|
3466
3605
|
const slotEntityId = createBaseEntity(world, slot, {
|
|
3467
3606
|
label,
|
|
@@ -3474,12 +3613,121 @@ function createXRInteractor({
|
|
|
3474
3613
|
return entityId;
|
|
3475
3614
|
}
|
|
3476
3615
|
__name(createXRInteractor, "createXRInteractor");
|
|
3616
|
+
function createUIButton({
|
|
3617
|
+
world,
|
|
3618
|
+
scene,
|
|
3619
|
+
payload
|
|
3620
|
+
}) {
|
|
3621
|
+
const object = new THREE37__namespace.Group();
|
|
3622
|
+
const entityId = createBaseEntity(world, object, {
|
|
3623
|
+
label: payload.name ?? "UI Button",
|
|
3624
|
+
entityType: "uiButton",
|
|
3625
|
+
transformInput: payload.transform
|
|
3626
|
+
});
|
|
3627
|
+
const options = payload.options ?? {};
|
|
3628
|
+
world.addComponent(entityId, new UIButtonComponent(options));
|
|
3629
|
+
world.addComponent(
|
|
3630
|
+
entityId,
|
|
3631
|
+
new XRInteractableComponent({
|
|
3632
|
+
grabbable: false,
|
|
3633
|
+
pointable: true,
|
|
3634
|
+
hoverBehavior: "color"
|
|
3635
|
+
})
|
|
3636
|
+
);
|
|
3637
|
+
scene.add(object);
|
|
3638
|
+
return entityId;
|
|
3639
|
+
}
|
|
3640
|
+
__name(createUIButton, "createUIButton");
|
|
3641
|
+
function createUIPanel({
|
|
3642
|
+
world,
|
|
3643
|
+
scene,
|
|
3644
|
+
payload
|
|
3645
|
+
}) {
|
|
3646
|
+
const object = new THREE37__namespace.Group();
|
|
3647
|
+
const entityId = createBaseEntity(world, object, {
|
|
3648
|
+
label: payload.name ?? "UI Panel",
|
|
3649
|
+
entityType: "uiPanel",
|
|
3650
|
+
transformInput: payload.transform
|
|
3651
|
+
});
|
|
3652
|
+
const options = payload.options ?? {};
|
|
3653
|
+
world.addComponent(entityId, new UIPanelComponent(options));
|
|
3654
|
+
scene.add(object);
|
|
3655
|
+
return entityId;
|
|
3656
|
+
}
|
|
3657
|
+
__name(createUIPanel, "createUIPanel");
|
|
3658
|
+
function createUISlider({
|
|
3659
|
+
world,
|
|
3660
|
+
scene,
|
|
3661
|
+
payload
|
|
3662
|
+
}) {
|
|
3663
|
+
const object = new THREE37__namespace.Group();
|
|
3664
|
+
const entityId = createBaseEntity(world, object, {
|
|
3665
|
+
label: payload.name ?? "UI Slider",
|
|
3666
|
+
entityType: "uiSlider",
|
|
3667
|
+
transformInput: payload.transform
|
|
3668
|
+
});
|
|
3669
|
+
const options = payload.options ?? {};
|
|
3670
|
+
world.addComponent(entityId, new UISliderComponent(options));
|
|
3671
|
+
world.addComponent(
|
|
3672
|
+
entityId,
|
|
3673
|
+
new XRInteractableComponent({
|
|
3674
|
+
grabbable: false,
|
|
3675
|
+
pointable: true,
|
|
3676
|
+
hoverBehavior: "none"
|
|
3677
|
+
})
|
|
3678
|
+
);
|
|
3679
|
+
scene.add(object);
|
|
3680
|
+
return entityId;
|
|
3681
|
+
}
|
|
3682
|
+
__name(createUISlider, "createUISlider");
|
|
3683
|
+
function createUIText({
|
|
3684
|
+
world,
|
|
3685
|
+
scene,
|
|
3686
|
+
payload
|
|
3687
|
+
}) {
|
|
3688
|
+
const object = new THREE37__namespace.Group();
|
|
3689
|
+
const entityId = createBaseEntity(world, object, {
|
|
3690
|
+
label: payload.name ?? "UI Text",
|
|
3691
|
+
entityType: "uiText",
|
|
3692
|
+
transformInput: payload.transform
|
|
3693
|
+
});
|
|
3694
|
+
const options = payload.options ?? {};
|
|
3695
|
+
world.addComponent(entityId, new UITextComponent(options));
|
|
3696
|
+
scene.add(object);
|
|
3697
|
+
return entityId;
|
|
3698
|
+
}
|
|
3699
|
+
__name(createUIText, "createUIText");
|
|
3700
|
+
function createUIToggle({
|
|
3701
|
+
world,
|
|
3702
|
+
scene,
|
|
3703
|
+
payload
|
|
3704
|
+
}) {
|
|
3705
|
+
const object = new THREE37__namespace.Group();
|
|
3706
|
+
const entityId = createBaseEntity(world, object, {
|
|
3707
|
+
label: payload.name ?? "UI Toggle",
|
|
3708
|
+
entityType: "uiToggle",
|
|
3709
|
+
transformInput: payload.transform
|
|
3710
|
+
});
|
|
3711
|
+
const options = payload.options ?? {};
|
|
3712
|
+
world.addComponent(entityId, new UIToggleComponent(options));
|
|
3713
|
+
world.addComponent(
|
|
3714
|
+
entityId,
|
|
3715
|
+
new XRInteractableComponent({
|
|
3716
|
+
grabbable: false,
|
|
3717
|
+
pointable: true,
|
|
3718
|
+
hoverBehavior: "color"
|
|
3719
|
+
})
|
|
3720
|
+
);
|
|
3721
|
+
scene.add(object);
|
|
3722
|
+
return entityId;
|
|
3723
|
+
}
|
|
3724
|
+
__name(createUIToggle, "createUIToggle");
|
|
3477
3725
|
function createXRRig({
|
|
3478
3726
|
world,
|
|
3479
3727
|
scene,
|
|
3480
3728
|
payload
|
|
3481
3729
|
}) {
|
|
3482
|
-
const object = new
|
|
3730
|
+
const object = new THREE37__namespace.Group();
|
|
3483
3731
|
const entityId = createBaseEntity(world, object, {
|
|
3484
3732
|
label: payload.name ?? "XR Rig",
|
|
3485
3733
|
entityType: "xrRig",
|
|
@@ -3492,7 +3740,7 @@ function createXRRig({
|
|
|
3492
3740
|
}
|
|
3493
3741
|
__name(createXRRig, "createXRRig");
|
|
3494
3742
|
function createSprite({ world, scene, payload }) {
|
|
3495
|
-
const anchor = new
|
|
3743
|
+
const anchor = new THREE37__namespace.Object3D();
|
|
3496
3744
|
const imagePath = payload.path ?? "";
|
|
3497
3745
|
const entityId = createBaseEntity(world, anchor, {
|
|
3498
3746
|
label: payload.name ?? "Sprite",
|
|
@@ -3504,7 +3752,7 @@ function createSprite({ world, scene, payload }) {
|
|
|
3504
3752
|
if (!imagePath) {
|
|
3505
3753
|
return entityId;
|
|
3506
3754
|
}
|
|
3507
|
-
const loader = new
|
|
3755
|
+
const loader = new THREE37__namespace.TextureLoader();
|
|
3508
3756
|
loader.load(
|
|
3509
3757
|
imagePath,
|
|
3510
3758
|
(texture) => {
|
|
@@ -3512,11 +3760,11 @@ function createSprite({ world, scene, payload }) {
|
|
|
3512
3760
|
texture.dispose();
|
|
3513
3761
|
return;
|
|
3514
3762
|
}
|
|
3515
|
-
const material = new
|
|
3763
|
+
const material = new THREE37__namespace.SpriteMaterial({
|
|
3516
3764
|
map: texture,
|
|
3517
3765
|
transparent: true
|
|
3518
3766
|
});
|
|
3519
|
-
const sprite = new
|
|
3767
|
+
const sprite = new THREE37__namespace.Sprite(material);
|
|
3520
3768
|
sprite.userData.entityId = entityId;
|
|
3521
3769
|
const textureImage = texture.image;
|
|
3522
3770
|
spriteComponent.width = textureImage?.width ?? 1;
|
|
@@ -3534,9 +3782,9 @@ function createSprite({ world, scene, payload }) {
|
|
|
3534
3782
|
}
|
|
3535
3783
|
__name(createSprite, "createSprite");
|
|
3536
3784
|
function createSphere({ world, scene, payload }) {
|
|
3537
|
-
const geometry = new
|
|
3538
|
-
const material = new
|
|
3539
|
-
const mesh = new
|
|
3785
|
+
const geometry = new THREE37__namespace.SphereGeometry(0.5, 24, 24);
|
|
3786
|
+
const material = new THREE37__namespace.MeshStandardMaterial({ color: "#ffffff" });
|
|
3787
|
+
const mesh = new THREE37__namespace.Mesh(geometry, material);
|
|
3540
3788
|
const entityId = createBaseEntity(world, mesh, {
|
|
3541
3789
|
label: payload.name ?? "Sphere",
|
|
3542
3790
|
entityType: "sphere",
|
|
@@ -3556,10 +3804,10 @@ function createSphere({ world, scene, payload }) {
|
|
|
3556
3804
|
__name(createSphere, "createSphere");
|
|
3557
3805
|
function getOrCreateListener2(camera) {
|
|
3558
3806
|
const existing = camera.userData.ecsAudioListener;
|
|
3559
|
-
if (existing instanceof
|
|
3807
|
+
if (existing instanceof THREE37__namespace.AudioListener) {
|
|
3560
3808
|
return existing;
|
|
3561
3809
|
}
|
|
3562
|
-
const listener = new
|
|
3810
|
+
const listener = new THREE37__namespace.AudioListener();
|
|
3563
3811
|
camera.add(listener);
|
|
3564
3812
|
camera.userData.ecsAudioListener = listener;
|
|
3565
3813
|
return listener;
|
|
@@ -3609,10 +3857,10 @@ function normalizeOptions(input) {
|
|
|
3609
3857
|
}
|
|
3610
3858
|
__name(normalizeOptions, "normalizeOptions");
|
|
3611
3859
|
function createChromaMaterial(texture, options) {
|
|
3612
|
-
return new
|
|
3860
|
+
return new THREE37__namespace.ShaderMaterial({
|
|
3613
3861
|
uniforms: {
|
|
3614
3862
|
tex: { value: texture },
|
|
3615
|
-
keyColor: { value: new
|
|
3863
|
+
keyColor: { value: new THREE37__namespace.Color(options.backgroundColor) },
|
|
3616
3864
|
similarity: { value: options.similarity },
|
|
3617
3865
|
smoothness: { value: options.smoothness },
|
|
3618
3866
|
spill: { value: options.spill }
|
|
@@ -3644,22 +3892,22 @@ function createChromaMaterial(texture, options) {
|
|
|
3644
3892
|
}
|
|
3645
3893
|
`,
|
|
3646
3894
|
transparent: true,
|
|
3647
|
-
side:
|
|
3895
|
+
side: THREE37__namespace.DoubleSide
|
|
3648
3896
|
});
|
|
3649
3897
|
}
|
|
3650
3898
|
__name(createChromaMaterial, "createChromaMaterial");
|
|
3651
3899
|
function createStandardMaterial(texture) {
|
|
3652
|
-
return new
|
|
3900
|
+
return new THREE37__namespace.MeshBasicMaterial({
|
|
3653
3901
|
map: texture,
|
|
3654
3902
|
transparent: true,
|
|
3655
|
-
side:
|
|
3903
|
+
side: THREE37__namespace.DoubleSide
|
|
3656
3904
|
});
|
|
3657
3905
|
}
|
|
3658
3906
|
__name(createStandardMaterial, "createStandardMaterial");
|
|
3659
3907
|
function createVideoMesh(entityId, texture, options) {
|
|
3660
|
-
const geometry = new
|
|
3908
|
+
const geometry = new THREE37__namespace.PlaneGeometry(1, 1);
|
|
3661
3909
|
const material = options.isGreenScreen ? createChromaMaterial(texture, options) : createStandardMaterial(texture);
|
|
3662
|
-
const mesh = new
|
|
3910
|
+
const mesh = new THREE37__namespace.Mesh(geometry, material);
|
|
3663
3911
|
mesh.userData.entityId = entityId;
|
|
3664
3912
|
mesh.scale.set(options.width, options.height, 1);
|
|
3665
3913
|
return { mesh, material };
|
|
@@ -3694,7 +3942,7 @@ function createVideo({
|
|
|
3694
3942
|
payload,
|
|
3695
3943
|
isEditor
|
|
3696
3944
|
}) {
|
|
3697
|
-
const anchor = new
|
|
3945
|
+
const anchor = new THREE37__namespace.Object3D();
|
|
3698
3946
|
const path = payload.path ?? "";
|
|
3699
3947
|
const options = normalizeOptions(payload.options);
|
|
3700
3948
|
const entityId = createBaseEntity(world, anchor, {
|
|
@@ -3709,8 +3957,8 @@ function createVideo({
|
|
|
3709
3957
|
return entityId;
|
|
3710
3958
|
}
|
|
3711
3959
|
const video = createVideoElement(path, options);
|
|
3712
|
-
const texture = new
|
|
3713
|
-
texture.colorSpace =
|
|
3960
|
+
const texture = new THREE37__namespace.VideoTexture(video);
|
|
3961
|
+
texture.colorSpace = THREE37__namespace.SRGBColorSpace;
|
|
3714
3962
|
texture.needsUpdate = true;
|
|
3715
3963
|
const { mesh, material } = createVideoMesh(entityId, texture, options);
|
|
3716
3964
|
anchor.add(mesh);
|
|
@@ -3726,7 +3974,7 @@ function createVideo({
|
|
|
3726
3974
|
});
|
|
3727
3975
|
if (!isEditor && options.positional) {
|
|
3728
3976
|
const listener = getOrCreateListener2(camera);
|
|
3729
|
-
const audioNode = new
|
|
3977
|
+
const audioNode = new THREE37__namespace.PositionalAudio(listener);
|
|
3730
3978
|
audioNode.setVolume(options.volume);
|
|
3731
3979
|
audioNode.setRefDistance(options.refDistance);
|
|
3732
3980
|
audioNode.setDistanceModel(normalizeDistanceModel2(options.distanceModel));
|
|
@@ -3769,6 +4017,11 @@ function registerDefaultFactories(objectManagementSystem) {
|
|
|
3769
4017
|
objectManagementSystem.register("xrRig", createXRRig);
|
|
3770
4018
|
objectManagementSystem.register("xrInteractor", createXRInteractor);
|
|
3771
4019
|
objectManagementSystem.register("teleportArea", createTeleportArea);
|
|
4020
|
+
objectManagementSystem.register("uiPanel", createUIPanel);
|
|
4021
|
+
objectManagementSystem.register("uiText", createUIText);
|
|
4022
|
+
objectManagementSystem.register("uiButton", createUIButton);
|
|
4023
|
+
objectManagementSystem.register("uiToggle", createUIToggle);
|
|
4024
|
+
objectManagementSystem.register("uiSlider", createUISlider);
|
|
3772
4025
|
registerDefaultComponentFactories(objectManagementSystem);
|
|
3773
4026
|
}
|
|
3774
4027
|
__name(registerDefaultFactories, "registerDefaultFactories");
|
|
@@ -3799,6 +4052,11 @@ exports.createSelectableComponent = createSelectableComponent;
|
|
|
3799
4052
|
exports.createSelectionTransformStateComponent = createSelectionTransformStateComponent;
|
|
3800
4053
|
exports.createSpriteComponent = createSpriteComponent;
|
|
3801
4054
|
exports.createTransformComponent = createTransformComponent;
|
|
4055
|
+
exports.createUIButtonComponent = createUIButtonComponent;
|
|
4056
|
+
exports.createUIPanelComponent = createUIPanelComponent;
|
|
4057
|
+
exports.createUISliderComponent = createUISliderComponent;
|
|
4058
|
+
exports.createUITextComponent = createUITextComponent;
|
|
4059
|
+
exports.createUIToggleComponent = createUIToggleComponent;
|
|
3802
4060
|
exports.createVRTeleportAreaComponent = createVRTeleportAreaComponent;
|
|
3803
4061
|
exports.createVideoComponent = createVideoComponent;
|
|
3804
4062
|
exports.createXRAnchorComponent = createXRAnchorComponent;
|