@relu-interactives/spatial-ecs 0.2.21 → 0.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{System-me3iAcMF.d.cts → System-CYWZ_Zx5.d.cts} +4 -3
- package/dist/{System-me3iAcMF.d.ts → System-CYWZ_Zx5.d.ts} +4 -3
- package/dist/{Video-DHnxjGhW.d.ts → Video-C1IOat7L.d.ts} +38 -9
- package/dist/{Video-U9hAnf9y.d.cts → Video-ppAXaKt0.d.cts} +38 -9
- package/dist/{chunk-K6KMKKJ6.js → chunk-52CHDPRQ.js} +118 -92
- package/dist/chunk-52CHDPRQ.js.map +1 -0
- package/dist/{chunk-5U3YS4JD.js → chunk-GZ2NKSMV.js} +421 -65
- package/dist/chunk-GZ2NKSMV.js.map +1 -0
- package/dist/{chunk-V7BNVTJW.js → chunk-JHCPRVBC.js} +25 -4
- package/dist/chunk-JHCPRVBC.js.map +1 -0
- package/dist/{chunk-AXRCGF63.js → chunk-WKGCC7YL.js} +3 -3
- package/dist/{chunk-AXRCGF63.js.map → chunk-WKGCC7YL.js.map} +1 -1
- package/dist/components/index.cjs +22 -1
- 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/authoring-a-behaviour.md +3 -40
- package/dist/docs/guide/authoring-a-script-object.md +102 -0
- package/dist/docs/guide/behaviour-lifecycle.md +4 -4
- package/dist/docs/guide/spawning/script-object.md +36 -0
- package/dist/docs/guide/systems/_sidebar.json +4 -0
- package/dist/docs/guide/systems/script-behaviour-system.md +1 -17
- package/dist/docs/guide/systems/script-object-system.md +44 -0
- package/dist/factories/index.cjs +164 -117
- package/dist/factories/index.cjs.map +1 -1
- package/dist/factories/index.d.cts +5 -3
- package/dist/factories/index.d.ts +5 -3
- package/dist/factories/index.js +3 -3
- package/dist/{index-D7FSg0Au.d.ts → index-Cu2Pt7wN.d.cts} +6 -3
- package/dist/{index-CZo5I5Gs.d.cts → index-DdiWu1b6.d.ts} +6 -3
- package/dist/index.cjs +677 -265
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +117 -28
- package/dist/index.d.ts +117 -28
- package/dist/index.js +13 -8
- package/dist/index.js.map +1 -1
- package/dist/systems/index.cjs +403 -36
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +44 -3
- package/dist/systems/index.d.ts +44 -3
- 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-5U3YS4JD.js.map +0 -1
- package/dist/chunk-K6KMKKJ6.js.map +0 -1
- package/dist/chunk-V7BNVTJW.js.map +0 -1
package/dist/factories/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var THREE29 = 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 THREE29__namespace = /*#__PURE__*/_interopNamespace(THREE29);
|
|
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 THREE29__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 THREE29__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 THREE29__namespace.PositionalAudio(listener) : new THREE29__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 THREE29__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 THREE29__namespace.EdgesGeometry(
|
|
531
|
+
new THREE29__namespace.OctahedronGeometry(0.22, 0)
|
|
532
532
|
);
|
|
533
|
-
const material2 = new
|
|
533
|
+
const material2 = new THREE29__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 THREE29__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 THREE29__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 THREE29__namespace.CanvasTexture(canvas);
|
|
583
583
|
texture.needsUpdate = true;
|
|
584
|
-
const material = new
|
|
584
|
+
const material = new THREE29__namespace.SpriteMaterial({
|
|
585
585
|
map: texture,
|
|
586
586
|
transparent: true,
|
|
587
587
|
depthTest: false
|
|
588
588
|
});
|
|
589
|
-
const helper = new
|
|
589
|
+
const helper = new THREE29__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 THREE29__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 THREE29__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 THREE29__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 THREE29__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 THREE29__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 THREE29__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 THREE29__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 THREE29__namespace.Camera ? object : void 0;
|
|
736
736
|
const component = new CameraComponent({
|
|
737
737
|
...payload,
|
|
738
738
|
camera: payload.camera ?? objectCamera
|
|
@@ -1281,15 +1281,15 @@ function createValueState(light) {
|
|
|
1281
1281
|
castShadow: light.castShadow ?? false,
|
|
1282
1282
|
frustumCulling: light.frustumCulled
|
|
1283
1283
|
};
|
|
1284
|
-
if (light instanceof
|
|
1284
|
+
if (light instanceof THREE29__namespace.PointLight) {
|
|
1285
1285
|
base.distance = light.distance;
|
|
1286
1286
|
base.decay = light.decay;
|
|
1287
|
-
} else if (light instanceof
|
|
1287
|
+
} else if (light instanceof THREE29__namespace.SpotLight) {
|
|
1288
1288
|
base.distance = light.distance;
|
|
1289
1289
|
base.decay = light.decay;
|
|
1290
1290
|
base.angle = light.angle;
|
|
1291
1291
|
base.penumbra = light.penumbra;
|
|
1292
|
-
} else if (light instanceof
|
|
1292
|
+
} else if (light instanceof THREE29__namespace.RectAreaLight) {
|
|
1293
1293
|
base.width = light.width;
|
|
1294
1294
|
base.height = light.height;
|
|
1295
1295
|
}
|
|
@@ -1332,13 +1332,13 @@ function toHexColor2(value, fallback) {
|
|
|
1332
1332
|
}
|
|
1333
1333
|
__name(toHexColor2, "toHexColor");
|
|
1334
1334
|
function getMaterialType(material) {
|
|
1335
|
-
if (material instanceof
|
|
1335
|
+
if (material instanceof THREE29__namespace.MeshPhysicalMaterial) {
|
|
1336
1336
|
return "physical";
|
|
1337
1337
|
}
|
|
1338
|
-
if (material instanceof
|
|
1338
|
+
if (material instanceof THREE29__namespace.MeshPhongMaterial) {
|
|
1339
1339
|
return "phong";
|
|
1340
1340
|
}
|
|
1341
|
-
if (material instanceof
|
|
1341
|
+
if (material instanceof THREE29__namespace.MeshBasicMaterial) {
|
|
1342
1342
|
return "basic";
|
|
1343
1343
|
}
|
|
1344
1344
|
return "standard";
|
|
@@ -1357,8 +1357,8 @@ function createMaterialValue(material) {
|
|
|
1357
1357
|
opacity: typeof materialRecord.opacity === "number" ? materialRecord.opacity : 1,
|
|
1358
1358
|
emissive: toHexColor2(materialRecord.emissive, "#000000"),
|
|
1359
1359
|
emissiveIntensity: typeof materialRecord.emissiveIntensity === "number" ? materialRecord.emissiveIntensity : 0,
|
|
1360
|
-
side: typeof materialRecord.side === "number" ? materialRecord.side :
|
|
1361
|
-
blending: typeof materialRecord.blending === "number" ? materialRecord.blending :
|
|
1360
|
+
side: typeof materialRecord.side === "number" ? materialRecord.side : THREE29__namespace.FrontSide,
|
|
1361
|
+
blending: typeof materialRecord.blending === "number" ? materialRecord.blending : THREE29__namespace.NormalBlending,
|
|
1362
1362
|
depthTest: materialRecord.depthTest !== false,
|
|
1363
1363
|
depthWrite: materialRecord.depthWrite !== false,
|
|
1364
1364
|
wireframe: Boolean(materialRecord.wireframe),
|
|
@@ -1374,7 +1374,7 @@ function createMaterialValue(material) {
|
|
|
1374
1374
|
displacementMap: materialRecord.displacementMap?.image?.src,
|
|
1375
1375
|
lightMap: materialRecord.lightMap?.image?.src,
|
|
1376
1376
|
envMap: materialRecord.envMap?.image?.src,
|
|
1377
|
-
textureFiltering: map?.magFilter ===
|
|
1377
|
+
textureFiltering: map?.magFilter === THREE29__namespace.NearestFilter ? "sharp" : "smooth",
|
|
1378
1378
|
useMipmaps: map?.generateMipmaps !== false
|
|
1379
1379
|
};
|
|
1380
1380
|
}
|
|
@@ -1389,8 +1389,8 @@ function defaultMaterialValue() {
|
|
|
1389
1389
|
opacity: 1,
|
|
1390
1390
|
emissive: "#000000",
|
|
1391
1391
|
emissiveIntensity: 0,
|
|
1392
|
-
side:
|
|
1393
|
-
blending:
|
|
1392
|
+
side: THREE29__namespace.FrontSide,
|
|
1393
|
+
blending: THREE29__namespace.NormalBlending,
|
|
1394
1394
|
depthTest: true,
|
|
1395
1395
|
depthWrite: true,
|
|
1396
1396
|
wireframe: false,
|
|
@@ -1805,7 +1805,6 @@ var _ScriptComponent = class _ScriptComponent extends Component {
|
|
|
1805
1805
|
className: typeof entry.className === "string" ? entry.className : "",
|
|
1806
1806
|
scriptUrl: typeof entry.scriptUrl === "string" ? entry.scriptUrl : "",
|
|
1807
1807
|
enabled: typeof entry.enabled === "boolean" ? entry.enabled : true,
|
|
1808
|
-
executeInEditor: typeof entry.executeInEditor === "boolean" ? entry.executeInEditor : false,
|
|
1809
1808
|
data: entry.data && typeof entry.data === "object" && !Array.isArray(entry.data) ? entry.data : {},
|
|
1810
1809
|
runtimeState: entry.runtimeState,
|
|
1811
1810
|
runtimeMessage: typeof entry.runtimeMessage === "string" ? entry.runtimeMessage : void 0
|
|
@@ -1844,6 +1843,35 @@ function createScriptComponent(world, entityId, payload = {}) {
|
|
|
1844
1843
|
}
|
|
1845
1844
|
__name(createScriptComponent, "createScriptComponent");
|
|
1846
1845
|
|
|
1846
|
+
// core/components/ScriptObjectComponent.ts
|
|
1847
|
+
var _ScriptObjectComponent = class _ScriptObjectComponent extends Component {
|
|
1848
|
+
constructor(input = {}) {
|
|
1849
|
+
super();
|
|
1850
|
+
this.scriptUrl = typeof input.scriptUrl === "string" && input.scriptUrl.length > 0 ? input.scriptUrl : null;
|
|
1851
|
+
this.className = typeof input.className === "string" && input.className.length > 0 ? input.className : null;
|
|
1852
|
+
this.enabled = typeof input.enabled === "boolean" ? input.enabled : true;
|
|
1853
|
+
this.data = input.data && typeof input.data === "object" && !Array.isArray(input.data) ? input.data : {};
|
|
1854
|
+
this.runtimeState = input.runtimeState === "idle" || input.runtimeState === "loading" || input.runtimeState === "ready" || input.runtimeState === "error" ? input.runtimeState : "idle";
|
|
1855
|
+
this.runtimeMessage = typeof input.runtimeMessage === "string" ? input.runtimeMessage : void 0;
|
|
1856
|
+
Object.defineProperty(this, "instance", {
|
|
1857
|
+
value: null,
|
|
1858
|
+
writable: true,
|
|
1859
|
+
configurable: true,
|
|
1860
|
+
enumerable: false
|
|
1861
|
+
});
|
|
1862
|
+
}
|
|
1863
|
+
};
|
|
1864
|
+
__name(_ScriptObjectComponent, "ScriptObjectComponent");
|
|
1865
|
+
var ScriptObjectComponent = _ScriptObjectComponent;
|
|
1866
|
+
|
|
1867
|
+
// core/factories/components/ScriptObjectComponentFactory.ts
|
|
1868
|
+
function createScriptObjectComponent(world, entityId, payload = {}) {
|
|
1869
|
+
const component = new ScriptObjectComponent(payload);
|
|
1870
|
+
world.addComponent(entityId, component);
|
|
1871
|
+
return component;
|
|
1872
|
+
}
|
|
1873
|
+
__name(createScriptObjectComponent, "createScriptObjectComponent");
|
|
1874
|
+
|
|
1847
1875
|
// core/components/Selectable.ts
|
|
1848
1876
|
var _Selectable = class _Selectable extends Component {
|
|
1849
1877
|
constructor(enabled = true) {
|
|
@@ -1933,14 +1961,14 @@ var _TransformComponent = class _TransformComponent extends Component {
|
|
|
1933
1961
|
z: scale.z ?? 1
|
|
1934
1962
|
};
|
|
1935
1963
|
}
|
|
1936
|
-
toPositionVector3(target = new
|
|
1964
|
+
toPositionVector3(target = new THREE29.Vector3()) {
|
|
1937
1965
|
return target.set(this.position.x, this.position.y, this.position.z);
|
|
1938
1966
|
}
|
|
1939
|
-
toRotationEuler(target = new
|
|
1967
|
+
toRotationEuler(target = new THREE29.Euler(), order = "XYZ") {
|
|
1940
1968
|
return target.set(this.rotation.x, this.rotation.y, this.rotation.z, order);
|
|
1941
1969
|
}
|
|
1942
|
-
toRotationQuaternion(target = new
|
|
1943
|
-
const euler = new
|
|
1970
|
+
toRotationQuaternion(target = new THREE29.Quaternion(), order = "XYZ") {
|
|
1971
|
+
const euler = new THREE29.Euler(
|
|
1944
1972
|
this.rotation.x,
|
|
1945
1973
|
this.rotation.y,
|
|
1946
1974
|
this.rotation.z,
|
|
@@ -1948,7 +1976,7 @@ var _TransformComponent = class _TransformComponent extends Component {
|
|
|
1948
1976
|
);
|
|
1949
1977
|
return target.setFromEuler(euler);
|
|
1950
1978
|
}
|
|
1951
|
-
toScaleVector3(target = new
|
|
1979
|
+
toScaleVector3(target = new THREE29.Vector3()) {
|
|
1952
1980
|
return target.set(this.scale.x, this.scale.y, this.scale.z);
|
|
1953
1981
|
}
|
|
1954
1982
|
setPosition(input) {
|
|
@@ -1966,8 +1994,8 @@ var _TransformComponent = class _TransformComponent extends Component {
|
|
|
1966
1994
|
return this;
|
|
1967
1995
|
}
|
|
1968
1996
|
setRotation(input, order = "XYZ") {
|
|
1969
|
-
if (input instanceof
|
|
1970
|
-
const euler = new
|
|
1997
|
+
if (input instanceof THREE29.Quaternion) {
|
|
1998
|
+
const euler = new THREE29.Euler().setFromQuaternion(input, order);
|
|
1971
1999
|
this.rotation.x = euler.x;
|
|
1972
2000
|
this.rotation.y = euler.y;
|
|
1973
2001
|
this.rotation.z = euler.z;
|
|
@@ -2205,6 +2233,10 @@ function registerDefaultComponentFactories(objectManagementSystem) {
|
|
|
2205
2233
|
createPostprocessingComponent
|
|
2206
2234
|
);
|
|
2207
2235
|
objectManagementSystem.registerComponentFactory("script", createScriptComponent);
|
|
2236
|
+
objectManagementSystem.registerComponentFactory(
|
|
2237
|
+
"scriptObject",
|
|
2238
|
+
createScriptObjectComponent
|
|
2239
|
+
);
|
|
2208
2240
|
objectManagementSystem.registerComponentFactory("selectable", createSelectableComponent);
|
|
2209
2241
|
objectManagementSystem.registerComponentFactory(
|
|
2210
2242
|
"selectionTransformState",
|
|
@@ -2220,7 +2252,7 @@ var SHARED_MODEL_RESOURCE_FLAG = "spatialEcsSharedModelResource";
|
|
|
2220
2252
|
var modelCache = /* @__PURE__ */ new Map();
|
|
2221
2253
|
function markSharedResources(root) {
|
|
2222
2254
|
root.traverse((child) => {
|
|
2223
|
-
if (!(child instanceof
|
|
2255
|
+
if (!(child instanceof THREE29__namespace.Mesh)) {
|
|
2224
2256
|
return;
|
|
2225
2257
|
}
|
|
2226
2258
|
if (child.geometry) {
|
|
@@ -2294,10 +2326,10 @@ __name(createBaseEntity, "createBaseEntity");
|
|
|
2294
2326
|
// core/factories/objects/AudioFactory.ts
|
|
2295
2327
|
function getOrCreateListener(camera) {
|
|
2296
2328
|
const existing = camera.userData.ecsAudioListener;
|
|
2297
|
-
if (existing instanceof
|
|
2329
|
+
if (existing instanceof THREE29__namespace.AudioListener) {
|
|
2298
2330
|
return existing;
|
|
2299
2331
|
}
|
|
2300
|
-
const listener = new
|
|
2332
|
+
const listener = new THREE29__namespace.AudioListener();
|
|
2301
2333
|
camera.add(listener);
|
|
2302
2334
|
camera.userData.ecsAudioListener = listener;
|
|
2303
2335
|
return listener;
|
|
@@ -2310,7 +2342,7 @@ function createAudio({
|
|
|
2310
2342
|
payload,
|
|
2311
2343
|
isEditor
|
|
2312
2344
|
}) {
|
|
2313
|
-
const anchor = new
|
|
2345
|
+
const anchor = new THREE29__namespace.Object3D();
|
|
2314
2346
|
const entityId = createBaseEntity(world, anchor, {
|
|
2315
2347
|
label: payload.name ?? "Audio",
|
|
2316
2348
|
entityType: "audio",
|
|
@@ -2332,7 +2364,7 @@ function createAudio({
|
|
|
2332
2364
|
return entityId;
|
|
2333
2365
|
}
|
|
2334
2366
|
if (!isEditor) {
|
|
2335
|
-
const loader = new
|
|
2367
|
+
const loader = new THREE29__namespace.AudioLoader();
|
|
2336
2368
|
loader.load(
|
|
2337
2369
|
audio.path,
|
|
2338
2370
|
(buffer) => {
|
|
@@ -2407,7 +2439,7 @@ function applyCameraSettings(camera, options) {
|
|
|
2407
2439
|
const near = typeof options.near === "number" ? options.near : DEFAULT_NEAR2;
|
|
2408
2440
|
const far = typeof options.far === "number" ? options.far : DEFAULT_FAR2;
|
|
2409
2441
|
const projection = options.projection;
|
|
2410
|
-
if (camera instanceof
|
|
2442
|
+
if (camera instanceof THREE29__namespace.PerspectiveCamera) {
|
|
2411
2443
|
if (!projection || projection === "perspective") {
|
|
2412
2444
|
camera.fov = typeof options.fov === "number" ? options.fov : DEFAULT_FOV2;
|
|
2413
2445
|
}
|
|
@@ -2417,7 +2449,7 @@ function applyCameraSettings(camera, options) {
|
|
|
2417
2449
|
camera.updateProjectionMatrix();
|
|
2418
2450
|
return;
|
|
2419
2451
|
}
|
|
2420
|
-
if (camera instanceof
|
|
2452
|
+
if (camera instanceof THREE29__namespace.OrthographicCamera) {
|
|
2421
2453
|
camera.left = typeof options.left === "number" ? options.left : -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2422
2454
|
camera.right = typeof options.right === "number" ? options.right : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2423
2455
|
camera.top = typeof options.top === "number" ? options.top : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
@@ -2438,7 +2470,7 @@ function createCameraObject(options) {
|
|
|
2438
2470
|
const bottom = options.bottom ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2439
2471
|
const left = options.left ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2440
2472
|
const right = options.right ?? DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2441
|
-
const camera = new
|
|
2473
|
+
const camera = new THREE29__namespace.OrthographicCamera(
|
|
2442
2474
|
left,
|
|
2443
2475
|
right,
|
|
2444
2476
|
top,
|
|
@@ -2450,7 +2482,7 @@ function createCameraObject(options) {
|
|
|
2450
2482
|
camera.updateProjectionMatrix();
|
|
2451
2483
|
return camera;
|
|
2452
2484
|
}
|
|
2453
|
-
return new
|
|
2485
|
+
return new THREE29__namespace.PerspectiveCamera(
|
|
2454
2486
|
options.fov ?? DEFAULT_FOV2,
|
|
2455
2487
|
readViewportAspect(),
|
|
2456
2488
|
near,
|
|
@@ -2468,7 +2500,7 @@ function createCamera({ world, scene, camera, payload, isEditor }) {
|
|
|
2468
2500
|
transformInput: payload.transform
|
|
2469
2501
|
});
|
|
2470
2502
|
const objectRef = world.getComponent(entityId, Object3DRef);
|
|
2471
|
-
if (objectRef?.object instanceof
|
|
2503
|
+
if (objectRef?.object instanceof THREE29__namespace.Camera) {
|
|
2472
2504
|
objectRef.object.userData.entityId = entityId;
|
|
2473
2505
|
}
|
|
2474
2506
|
const componentOptions = {
|
|
@@ -2485,20 +2517,11 @@ function createCamera({ world, scene, camera, payload, isEditor }) {
|
|
|
2485
2517
|
bottom: options.bottom,
|
|
2486
2518
|
zoom: options.zoom
|
|
2487
2519
|
};
|
|
2488
|
-
|
|
2520
|
+
createCameraComponent(world, entityId, componentOptions);
|
|
2489
2521
|
if (useWorldCamera) {
|
|
2490
2522
|
applyCameraSettings(object, options);
|
|
2491
2523
|
} else {
|
|
2492
2524
|
applyCameraSettings(object, options);
|
|
2493
|
-
if (isEditor && component.isDefault) {
|
|
2494
|
-
const helper = new THREE28__namespace.CameraHelper(object);
|
|
2495
|
-
helper.onBeforeRender = () => {
|
|
2496
|
-
helper.update();
|
|
2497
|
-
};
|
|
2498
|
-
helper.userData.ecsHelper = true;
|
|
2499
|
-
helper.visible = false;
|
|
2500
|
-
object.add(helper);
|
|
2501
|
-
}
|
|
2502
2525
|
scene.add(object);
|
|
2503
2526
|
}
|
|
2504
2527
|
return entityId;
|
|
@@ -2509,9 +2532,9 @@ function createCapsule({
|
|
|
2509
2532
|
scene,
|
|
2510
2533
|
payload
|
|
2511
2534
|
}) {
|
|
2512
|
-
const geometry = new
|
|
2513
|
-
const material = new
|
|
2514
|
-
const mesh = new
|
|
2535
|
+
const geometry = new THREE29__namespace.CapsuleGeometry(0.5, 1, 4, 8);
|
|
2536
|
+
const material = new THREE29__namespace.MeshStandardMaterial({ color: "#ffffff" });
|
|
2537
|
+
const mesh = new THREE29__namespace.Mesh(geometry, material);
|
|
2515
2538
|
const entityId = createBaseEntity(world, mesh, {
|
|
2516
2539
|
label: payload.name ?? "Capsule",
|
|
2517
2540
|
entityType: "capsule",
|
|
@@ -2531,9 +2554,9 @@ function createCapsule({
|
|
|
2531
2554
|
}
|
|
2532
2555
|
__name(createCapsule, "createCapsule");
|
|
2533
2556
|
function createCube({ world, scene, payload }) {
|
|
2534
|
-
const geometry = new
|
|
2535
|
-
const material = new
|
|
2536
|
-
const mesh = new
|
|
2557
|
+
const geometry = new THREE29__namespace.BoxGeometry(1, 1, 1);
|
|
2558
|
+
const material = new THREE29__namespace.MeshStandardMaterial({ color: "#ffffff" });
|
|
2559
|
+
const mesh = new THREE29__namespace.Mesh(geometry, material);
|
|
2537
2560
|
const entityId = createBaseEntity(world, mesh, {
|
|
2538
2561
|
label: payload.name ?? "Cube",
|
|
2539
2562
|
entityType: "cube",
|
|
@@ -2558,9 +2581,9 @@ function createCylinder({
|
|
|
2558
2581
|
scene,
|
|
2559
2582
|
payload
|
|
2560
2583
|
}) {
|
|
2561
|
-
const geometry = new
|
|
2562
|
-
const material = new
|
|
2563
|
-
const mesh = new
|
|
2584
|
+
const geometry = new THREE29__namespace.CylinderGeometry(0.5, 0.5, 1, 20);
|
|
2585
|
+
const material = new THREE29__namespace.MeshStandardMaterial({ color: "#ffffff" });
|
|
2586
|
+
const mesh = new THREE29__namespace.Mesh(geometry, material);
|
|
2564
2587
|
const entityId = createBaseEntity(world, mesh, {
|
|
2565
2588
|
label: payload.name ?? "Cylinder",
|
|
2566
2589
|
entityType: "cylinder",
|
|
@@ -2580,7 +2603,7 @@ function createCylinder({
|
|
|
2580
2603
|
}
|
|
2581
2604
|
__name(createCylinder, "createCylinder");
|
|
2582
2605
|
function createEmpty({ world, scene, payload, isEditor }) {
|
|
2583
|
-
const object = new
|
|
2606
|
+
const object = new THREE29__namespace.Group();
|
|
2584
2607
|
const entityId = createBaseEntity(world, object, {
|
|
2585
2608
|
label: payload.name ?? "Empty",
|
|
2586
2609
|
entityType: "empty",
|
|
@@ -2591,7 +2614,7 @@ function createEmpty({ world, scene, payload, isEditor }) {
|
|
|
2591
2614
|
}
|
|
2592
2615
|
__name(createEmpty, "createEmpty");
|
|
2593
2616
|
function createImage({ world, scene, payload }) {
|
|
2594
|
-
const anchor = new
|
|
2617
|
+
const anchor = new THREE29__namespace.Object3D();
|
|
2595
2618
|
const imagePath = payload.path ?? "";
|
|
2596
2619
|
const entityId = createBaseEntity(world, anchor, {
|
|
2597
2620
|
label: payload.name ?? "Image",
|
|
@@ -2604,7 +2627,7 @@ function createImage({ world, scene, payload }) {
|
|
|
2604
2627
|
if (!imagePath) {
|
|
2605
2628
|
return entityId;
|
|
2606
2629
|
}
|
|
2607
|
-
const loader = new
|
|
2630
|
+
const loader = new THREE29__namespace.TextureLoader();
|
|
2608
2631
|
loader.load(
|
|
2609
2632
|
imagePath,
|
|
2610
2633
|
(texture) => {
|
|
@@ -2612,13 +2635,13 @@ function createImage({ world, scene, payload }) {
|
|
|
2612
2635
|
texture.dispose();
|
|
2613
2636
|
return;
|
|
2614
2637
|
}
|
|
2615
|
-
const material = new
|
|
2638
|
+
const material = new THREE29__namespace.MeshBasicMaterial({
|
|
2616
2639
|
map: texture,
|
|
2617
2640
|
transparent: true,
|
|
2618
|
-
side:
|
|
2641
|
+
side: THREE29__namespace.DoubleSide
|
|
2619
2642
|
});
|
|
2620
|
-
const geometry = new
|
|
2621
|
-
const plane = new
|
|
2643
|
+
const geometry = new THREE29__namespace.PlaneGeometry(1, 1);
|
|
2644
|
+
const plane = new THREE29__namespace.Mesh(geometry, material);
|
|
2622
2645
|
plane.userData.entityId = entityId;
|
|
2623
2646
|
const textureImage = texture.image;
|
|
2624
2647
|
const width = textureImage?.width ?? 1;
|
|
@@ -2664,7 +2687,7 @@ function createImageTarget({
|
|
|
2664
2687
|
payload,
|
|
2665
2688
|
isEditor
|
|
2666
2689
|
}) {
|
|
2667
|
-
const anchor = new
|
|
2690
|
+
const anchor = new THREE29__namespace.Object3D();
|
|
2668
2691
|
const imagePath = payload.path ?? "";
|
|
2669
2692
|
const entityId = createBaseEntity(world, anchor, {
|
|
2670
2693
|
label: payload.name ?? "Image Target",
|
|
@@ -2681,7 +2704,7 @@ function createImageTarget({
|
|
|
2681
2704
|
if (!isEditor || !imagePath) {
|
|
2682
2705
|
return entityId;
|
|
2683
2706
|
}
|
|
2684
|
-
const loader = new
|
|
2707
|
+
const loader = new THREE29__namespace.TextureLoader();
|
|
2685
2708
|
loader.load(
|
|
2686
2709
|
imagePath,
|
|
2687
2710
|
(texture) => {
|
|
@@ -2689,13 +2712,13 @@ function createImageTarget({
|
|
|
2689
2712
|
texture.dispose();
|
|
2690
2713
|
return;
|
|
2691
2714
|
}
|
|
2692
|
-
const material = new
|
|
2715
|
+
const material = new THREE29__namespace.MeshBasicMaterial({
|
|
2693
2716
|
map: texture,
|
|
2694
2717
|
transparent: true,
|
|
2695
|
-
side:
|
|
2718
|
+
side: THREE29__namespace.DoubleSide
|
|
2696
2719
|
});
|
|
2697
|
-
const geometry = new
|
|
2698
|
-
const plane = new
|
|
2720
|
+
const geometry = new THREE29__namespace.PlaneGeometry(1, 1);
|
|
2721
|
+
const plane = new THREE29__namespace.Mesh(geometry, material);
|
|
2699
2722
|
plane.userData.entityId = entityId;
|
|
2700
2723
|
const textureImage = texture.image;
|
|
2701
2724
|
const width = textureImage?.width ?? 1;
|
|
@@ -2746,7 +2769,7 @@ function createInstancedMesh({
|
|
|
2746
2769
|
scene,
|
|
2747
2770
|
payload
|
|
2748
2771
|
}) {
|
|
2749
|
-
const anchor = new
|
|
2772
|
+
const anchor = new THREE29__namespace.Object3D();
|
|
2750
2773
|
const opts = payload.options ?? {};
|
|
2751
2774
|
const meshKind = isInstancedMeshKind(opts.meshKind) ? opts.meshKind : "cube";
|
|
2752
2775
|
const meshParameters = opts.meshParameters && typeof opts.meshParameters === "object" ? opts.meshParameters : void 0;
|
|
@@ -2817,7 +2840,7 @@ function createAmbientLight({
|
|
|
2817
2840
|
scene,
|
|
2818
2841
|
payload
|
|
2819
2842
|
}) {
|
|
2820
|
-
const light = new
|
|
2843
|
+
const light = new THREE29__namespace.AmbientLight("#ffffff", 0.6);
|
|
2821
2844
|
const entityId = createBaseEntity(world, light, {
|
|
2822
2845
|
label: payload.name ?? "Ambient Light",
|
|
2823
2846
|
entityType: "ambientLight",
|
|
@@ -2834,7 +2857,7 @@ function createAreaLight({
|
|
|
2834
2857
|
payload,
|
|
2835
2858
|
isEditor
|
|
2836
2859
|
}) {
|
|
2837
|
-
const light = new
|
|
2860
|
+
const light = new THREE29__namespace.RectAreaLight("#ffffff", 5, 4, 4);
|
|
2838
2861
|
light.lookAt(0, 0, 0);
|
|
2839
2862
|
const entityId = createBaseEntity(world, light, {
|
|
2840
2863
|
label: payload.name ?? "Area Light",
|
|
@@ -2863,7 +2886,7 @@ function createDirectionalLight({
|
|
|
2863
2886
|
payload,
|
|
2864
2887
|
isEditor
|
|
2865
2888
|
}) {
|
|
2866
|
-
const light = new
|
|
2889
|
+
const light = new THREE29__namespace.DirectionalLight("#ffffff", 1.5);
|
|
2867
2890
|
light.castShadow = true;
|
|
2868
2891
|
const entityId = createBaseEntity(world, light, {
|
|
2869
2892
|
label: payload.name ?? "Directional Light",
|
|
@@ -2874,7 +2897,7 @@ function createDirectionalLight({
|
|
|
2874
2897
|
});
|
|
2875
2898
|
createLightComponent(world, entityId, light);
|
|
2876
2899
|
if (isEditor) {
|
|
2877
|
-
const helper = new
|
|
2900
|
+
const helper = new THREE29__namespace.DirectionalLightHelper(light, 1.8, "#38bdf8");
|
|
2878
2901
|
helper.onBeforeRender = () => {
|
|
2879
2902
|
helper.update();
|
|
2880
2903
|
};
|
|
@@ -2892,7 +2915,7 @@ function createPointLight({
|
|
|
2892
2915
|
payload,
|
|
2893
2916
|
isEditor
|
|
2894
2917
|
}) {
|
|
2895
|
-
const light = new
|
|
2918
|
+
const light = new THREE29__namespace.PointLight("#ffffff", 1, 10);
|
|
2896
2919
|
const entityId = createBaseEntity(world, light, {
|
|
2897
2920
|
label: payload.name ?? "Point Light",
|
|
2898
2921
|
entityType: "pointLight",
|
|
@@ -2902,7 +2925,7 @@ function createPointLight({
|
|
|
2902
2925
|
});
|
|
2903
2926
|
createLightComponent(world, entityId, light);
|
|
2904
2927
|
if (isEditor) {
|
|
2905
|
-
const helper = new
|
|
2928
|
+
const helper = new THREE29__namespace.PointLightHelper(light, 0.35, "#fbbf24");
|
|
2906
2929
|
helper.onBeforeRender = () => {
|
|
2907
2930
|
helper.update();
|
|
2908
2931
|
};
|
|
@@ -2920,7 +2943,7 @@ function createSpotLight({
|
|
|
2920
2943
|
payload,
|
|
2921
2944
|
isEditor
|
|
2922
2945
|
}) {
|
|
2923
|
-
const light = new
|
|
2946
|
+
const light = new THREE29__namespace.SpotLight("#ffffff", 1, 20, Math.PI / 6, 0.1, 1);
|
|
2924
2947
|
const entityId = createBaseEntity(world, light, {
|
|
2925
2948
|
label: payload.name ?? "Spot Light",
|
|
2926
2949
|
entityType: "spotLight",
|
|
@@ -2930,7 +2953,7 @@ function createSpotLight({
|
|
|
2930
2953
|
});
|
|
2931
2954
|
createLightComponent(world, entityId, light);
|
|
2932
2955
|
if (isEditor) {
|
|
2933
|
-
const helper = new
|
|
2956
|
+
const helper = new THREE29__namespace.SpotLightHelper(light, "#f59e0b");
|
|
2934
2957
|
helper.onBeforeRender = () => {
|
|
2935
2958
|
helper.update();
|
|
2936
2959
|
};
|
|
@@ -2990,7 +3013,7 @@ function createModel({
|
|
|
2990
3013
|
payload,
|
|
2991
3014
|
isEditor
|
|
2992
3015
|
}) {
|
|
2993
|
-
const anchor = new
|
|
3016
|
+
const anchor = new THREE29__namespace.Object3D();
|
|
2994
3017
|
const modelPath = payload.path ?? "";
|
|
2995
3018
|
const entityId = createBaseEntity(world, anchor, {
|
|
2996
3019
|
label: payload.name ?? "Model",
|
|
@@ -3056,12 +3079,12 @@ function createModel({
|
|
|
3056
3079
|
}
|
|
3057
3080
|
__name(createModel, "createModel");
|
|
3058
3081
|
function createPlane({ world, scene, payload }) {
|
|
3059
|
-
const geometry = new
|
|
3060
|
-
const material = new
|
|
3082
|
+
const geometry = new THREE29__namespace.PlaneGeometry(100, 100);
|
|
3083
|
+
const material = new THREE29__namespace.MeshStandardMaterial({
|
|
3061
3084
|
color: "#ffffff",
|
|
3062
|
-
side:
|
|
3085
|
+
side: THREE29__namespace.DoubleSide
|
|
3063
3086
|
});
|
|
3064
|
-
const mesh = new
|
|
3087
|
+
const mesh = new THREE29__namespace.Mesh(geometry, material);
|
|
3065
3088
|
const entityId = createBaseEntity(
|
|
3066
3089
|
world,
|
|
3067
3090
|
mesh,
|
|
@@ -3092,8 +3115,30 @@ function createPlane({ world, scene, payload }) {
|
|
|
3092
3115
|
return entityId;
|
|
3093
3116
|
}
|
|
3094
3117
|
__name(createPlane, "createPlane");
|
|
3118
|
+
function createScriptObject({
|
|
3119
|
+
world,
|
|
3120
|
+
scene,
|
|
3121
|
+
payload
|
|
3122
|
+
}) {
|
|
3123
|
+
const object = new THREE29__namespace.Group();
|
|
3124
|
+
const entityId = createBaseEntity(world, object, {
|
|
3125
|
+
label: payload.name ?? "Script Object",
|
|
3126
|
+
entityType: "scriptObject",
|
|
3127
|
+
transformInput: payload.transform
|
|
3128
|
+
});
|
|
3129
|
+
const options = payload.options ?? {};
|
|
3130
|
+
createScriptObjectComponent(world, entityId, {
|
|
3131
|
+
scriptUrl: typeof options.scriptUrl === "string" ? options.scriptUrl : null,
|
|
3132
|
+
className: typeof options.className === "string" ? options.className : null,
|
|
3133
|
+
enabled: typeof options.enabled === "boolean" ? options.enabled : true,
|
|
3134
|
+
data: options.data && typeof options.data === "object" && !Array.isArray(options.data) ? options.data : {}
|
|
3135
|
+
});
|
|
3136
|
+
scene.add(object);
|
|
3137
|
+
return entityId;
|
|
3138
|
+
}
|
|
3139
|
+
__name(createScriptObject, "createScriptObject");
|
|
3095
3140
|
function createSprite({ world, scene, payload }) {
|
|
3096
|
-
const anchor = new
|
|
3141
|
+
const anchor = new THREE29__namespace.Object3D();
|
|
3097
3142
|
const imagePath = payload.path ?? "";
|
|
3098
3143
|
const entityId = createBaseEntity(world, anchor, {
|
|
3099
3144
|
label: payload.name ?? "Sprite",
|
|
@@ -3105,7 +3150,7 @@ function createSprite({ world, scene, payload }) {
|
|
|
3105
3150
|
if (!imagePath) {
|
|
3106
3151
|
return entityId;
|
|
3107
3152
|
}
|
|
3108
|
-
const loader = new
|
|
3153
|
+
const loader = new THREE29__namespace.TextureLoader();
|
|
3109
3154
|
loader.load(
|
|
3110
3155
|
imagePath,
|
|
3111
3156
|
(texture) => {
|
|
@@ -3113,11 +3158,11 @@ function createSprite({ world, scene, payload }) {
|
|
|
3113
3158
|
texture.dispose();
|
|
3114
3159
|
return;
|
|
3115
3160
|
}
|
|
3116
|
-
const material = new
|
|
3161
|
+
const material = new THREE29__namespace.SpriteMaterial({
|
|
3117
3162
|
map: texture,
|
|
3118
3163
|
transparent: true
|
|
3119
3164
|
});
|
|
3120
|
-
const sprite = new
|
|
3165
|
+
const sprite = new THREE29__namespace.Sprite(material);
|
|
3121
3166
|
sprite.userData.entityId = entityId;
|
|
3122
3167
|
const textureImage = texture.image;
|
|
3123
3168
|
spriteComponent.width = textureImage?.width ?? 1;
|
|
@@ -3135,9 +3180,9 @@ function createSprite({ world, scene, payload }) {
|
|
|
3135
3180
|
}
|
|
3136
3181
|
__name(createSprite, "createSprite");
|
|
3137
3182
|
function createSphere({ world, scene, payload }) {
|
|
3138
|
-
const geometry = new
|
|
3139
|
-
const material = new
|
|
3140
|
-
const mesh = new
|
|
3183
|
+
const geometry = new THREE29__namespace.SphereGeometry(0.5, 24, 24);
|
|
3184
|
+
const material = new THREE29__namespace.MeshStandardMaterial({ color: "#ffffff" });
|
|
3185
|
+
const mesh = new THREE29__namespace.Mesh(geometry, material);
|
|
3141
3186
|
const entityId = createBaseEntity(world, mesh, {
|
|
3142
3187
|
label: payload.name ?? "Sphere",
|
|
3143
3188
|
entityType: "sphere",
|
|
@@ -3157,10 +3202,10 @@ function createSphere({ world, scene, payload }) {
|
|
|
3157
3202
|
__name(createSphere, "createSphere");
|
|
3158
3203
|
function getOrCreateListener2(camera) {
|
|
3159
3204
|
const existing = camera.userData.ecsAudioListener;
|
|
3160
|
-
if (existing instanceof
|
|
3205
|
+
if (existing instanceof THREE29__namespace.AudioListener) {
|
|
3161
3206
|
return existing;
|
|
3162
3207
|
}
|
|
3163
|
-
const listener = new
|
|
3208
|
+
const listener = new THREE29__namespace.AudioListener();
|
|
3164
3209
|
camera.add(listener);
|
|
3165
3210
|
camera.userData.ecsAudioListener = listener;
|
|
3166
3211
|
return listener;
|
|
@@ -3210,10 +3255,10 @@ function normalizeOptions(input) {
|
|
|
3210
3255
|
}
|
|
3211
3256
|
__name(normalizeOptions, "normalizeOptions");
|
|
3212
3257
|
function createChromaMaterial(texture, options) {
|
|
3213
|
-
return new
|
|
3258
|
+
return new THREE29__namespace.ShaderMaterial({
|
|
3214
3259
|
uniforms: {
|
|
3215
3260
|
tex: { value: texture },
|
|
3216
|
-
keyColor: { value: new
|
|
3261
|
+
keyColor: { value: new THREE29__namespace.Color(options.backgroundColor) },
|
|
3217
3262
|
similarity: { value: options.similarity },
|
|
3218
3263
|
smoothness: { value: options.smoothness },
|
|
3219
3264
|
spill: { value: options.spill }
|
|
@@ -3245,22 +3290,22 @@ function createChromaMaterial(texture, options) {
|
|
|
3245
3290
|
}
|
|
3246
3291
|
`,
|
|
3247
3292
|
transparent: true,
|
|
3248
|
-
side:
|
|
3293
|
+
side: THREE29__namespace.DoubleSide
|
|
3249
3294
|
});
|
|
3250
3295
|
}
|
|
3251
3296
|
__name(createChromaMaterial, "createChromaMaterial");
|
|
3252
3297
|
function createStandardMaterial(texture) {
|
|
3253
|
-
return new
|
|
3298
|
+
return new THREE29__namespace.MeshBasicMaterial({
|
|
3254
3299
|
map: texture,
|
|
3255
3300
|
transparent: true,
|
|
3256
|
-
side:
|
|
3301
|
+
side: THREE29__namespace.DoubleSide
|
|
3257
3302
|
});
|
|
3258
3303
|
}
|
|
3259
3304
|
__name(createStandardMaterial, "createStandardMaterial");
|
|
3260
3305
|
function createVideoMesh(entityId, texture, options) {
|
|
3261
|
-
const geometry = new
|
|
3306
|
+
const geometry = new THREE29__namespace.PlaneGeometry(1, 1);
|
|
3262
3307
|
const material = options.isGreenScreen ? createChromaMaterial(texture, options) : createStandardMaterial(texture);
|
|
3263
|
-
const mesh = new
|
|
3308
|
+
const mesh = new THREE29__namespace.Mesh(geometry, material);
|
|
3264
3309
|
mesh.userData.entityId = entityId;
|
|
3265
3310
|
mesh.scale.set(options.width, options.height, 1);
|
|
3266
3311
|
return { mesh, material };
|
|
@@ -3295,7 +3340,7 @@ function createVideo({
|
|
|
3295
3340
|
payload,
|
|
3296
3341
|
isEditor
|
|
3297
3342
|
}) {
|
|
3298
|
-
const anchor = new
|
|
3343
|
+
const anchor = new THREE29__namespace.Object3D();
|
|
3299
3344
|
const path = payload.path ?? "";
|
|
3300
3345
|
const options = normalizeOptions(payload.options);
|
|
3301
3346
|
const entityId = createBaseEntity(world, anchor, {
|
|
@@ -3310,8 +3355,8 @@ function createVideo({
|
|
|
3310
3355
|
return entityId;
|
|
3311
3356
|
}
|
|
3312
3357
|
const video = createVideoElement(path, options);
|
|
3313
|
-
const texture = new
|
|
3314
|
-
texture.colorSpace =
|
|
3358
|
+
const texture = new THREE29__namespace.VideoTexture(video);
|
|
3359
|
+
texture.colorSpace = THREE29__namespace.SRGBColorSpace;
|
|
3315
3360
|
texture.needsUpdate = true;
|
|
3316
3361
|
const { mesh, material } = createVideoMesh(entityId, texture, options);
|
|
3317
3362
|
anchor.add(mesh);
|
|
@@ -3327,7 +3372,7 @@ function createVideo({
|
|
|
3327
3372
|
});
|
|
3328
3373
|
if (!isEditor && options.positional) {
|
|
3329
3374
|
const listener = getOrCreateListener2(camera);
|
|
3330
|
-
const audioNode = new
|
|
3375
|
+
const audioNode = new THREE29__namespace.PositionalAudio(listener);
|
|
3331
3376
|
audioNode.setVolume(options.volume);
|
|
3332
3377
|
audioNode.setRefDistance(options.refDistance);
|
|
3333
3378
|
audioNode.setDistanceModel(normalizeDistanceModel2(options.distanceModel));
|
|
@@ -3366,6 +3411,7 @@ function registerDefaultFactories(objectManagementSystem) {
|
|
|
3366
3411
|
objectManagementSystem.register("pointLight", createPointLight);
|
|
3367
3412
|
objectManagementSystem.register("spotLight", createSpotLight);
|
|
3368
3413
|
objectManagementSystem.register("areaLight", createAreaLight);
|
|
3414
|
+
objectManagementSystem.register("scriptObject", createScriptObject);
|
|
3369
3415
|
registerDefaultComponentFactories(objectManagementSystem);
|
|
3370
3416
|
}
|
|
3371
3417
|
__name(registerDefaultFactories, "registerDefaultFactories");
|
|
@@ -3391,6 +3437,7 @@ exports.createParentIdComponent = createParentIdComponent;
|
|
|
3391
3437
|
exports.createPhysicsComponent = createPhysicsComponent;
|
|
3392
3438
|
exports.createPostprocessingComponent = createPostprocessingComponent;
|
|
3393
3439
|
exports.createScriptComponent = createScriptComponent;
|
|
3440
|
+
exports.createScriptObjectComponent = createScriptObjectComponent;
|
|
3394
3441
|
exports.createSelectableComponent = createSelectableComponent;
|
|
3395
3442
|
exports.createSelectionTransformStateComponent = createSelectionTransformStateComponent;
|
|
3396
3443
|
exports.createSpriteComponent = createSpriteComponent;
|