@relu-interactives/spatial-ecs 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{System-BTyYvKVH.d.cts → System-CIiWteft.d.cts} +2 -2
- package/dist/{System-BTyYvKVH.d.ts → System-CIiWteft.d.ts} +2 -2
- package/dist/{Video-BWhbvVPg.d.ts → Video-B-qMljTn.d.ts} +147 -75
- package/dist/{Video-D2H5H-K3.d.cts → Video-Dj4KBqQ1.d.cts} +147 -75
- package/dist/{chunk-XWIEEJ7Z.js → chunk-EIC5B3A7.js} +128 -82
- package/dist/chunk-EIC5B3A7.js.map +1 -0
- package/dist/{chunk-AYEF3X2P.js → chunk-FDWNCXU3.js} +3 -3
- package/dist/chunk-FDWNCXU3.js.map +1 -0
- package/dist/{chunk-NFDTIYR4.js → chunk-G2DUXNTQ.js} +18 -2
- package/dist/chunk-G2DUXNTQ.js.map +1 -0
- package/dist/{chunk-P2YDX5DB.js → chunk-NRSUYDBA.js} +275 -5
- package/dist/chunk-NRSUYDBA.js.map +1 -0
- package/dist/{chunk-MAWBTMCG.js → chunk-R5D5PWXV.js} +160 -88
- package/dist/chunk-R5D5PWXV.js.map +1 -0
- package/dist/components/index.cjs +165 -93
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +1 -1
- package/dist/factories/index.cjs +221 -105
- package/dist/factories/index.cjs.map +1 -1
- package/dist/factories/index.d.cts +9 -3
- package/dist/factories/index.d.ts +9 -3
- package/dist/factories/index.js +3 -3
- package/dist/{index-KdEzEZox.d.cts → index-B12sx9yF.d.cts} +8 -3
- package/dist/{index-Dm6zF1MY.d.ts → index-Cf-PaKyN.d.ts} +8 -3
- package/dist/index.cjs +627 -179
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +54 -12
- package/dist/index.js.map +1 -1
- package/dist/systems/index.cjs +403 -63
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +27 -3
- package/dist/systems/index.d.ts +27 -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.cjs +16 -0
- package/dist/worldSnapshotUtils.cjs.map +1 -1
- package/dist/worldSnapshotUtils.d.cts +1 -1
- package/dist/worldSnapshotUtils.d.ts +1 -1
- package/dist/worldSnapshotUtils.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-AYEF3X2P.js.map +0 -1
- package/dist/chunk-MAWBTMCG.js.map +0 -1
- package/dist/chunk-NFDTIYR4.js.map +0 -1
- package/dist/chunk-P2YDX5DB.js.map +0 -1
- package/dist/chunk-XWIEEJ7Z.js.map +0 -1
package/dist/factories/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var THREE27 = require('three');
|
|
4
4
|
var RectAreaLightHelper_js = require('three/examples/jsm/helpers/RectAreaLightHelper.js');
|
|
5
5
|
var DRACOLoader_js = require('three/examples/jsm/loaders/DRACOLoader.js');
|
|
6
6
|
var GLTFLoader_js = require('three/examples/jsm/loaders/GLTFLoader.js');
|
|
@@ -24,7 +24,7 @@ function _interopNamespace(e) {
|
|
|
24
24
|
return Object.freeze(n);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var THREE27__namespace = /*#__PURE__*/_interopNamespace(THREE27);
|
|
28
28
|
|
|
29
29
|
var __defProp = Object.defineProperty;
|
|
30
30
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
@@ -297,14 +297,14 @@ var _AnimationComponent = class _AnimationComponent extends Component {
|
|
|
297
297
|
return;
|
|
298
298
|
}
|
|
299
299
|
this.importedClips = clips.map((entry) => {
|
|
300
|
-
if (entry instanceof
|
|
300
|
+
if (entry instanceof THREE27__namespace.AnimationClip) {
|
|
301
301
|
return { clip: entry, sourceUrl: null };
|
|
302
302
|
}
|
|
303
303
|
if (!entry || typeof entry !== "object") {
|
|
304
304
|
return null;
|
|
305
305
|
}
|
|
306
306
|
const candidate = entry;
|
|
307
|
-
if (!(candidate.clip instanceof
|
|
307
|
+
if (!(candidate.clip instanceof THREE27__namespace.AnimationClip)) {
|
|
308
308
|
return null;
|
|
309
309
|
}
|
|
310
310
|
return {
|
|
@@ -512,11 +512,11 @@ function normalizeDistanceModel(distanceModel) {
|
|
|
512
512
|
}
|
|
513
513
|
__name(normalizeDistanceModel, "normalizeDistanceModel");
|
|
514
514
|
function createConfiguredAudio(listener, options) {
|
|
515
|
-
const sound = options.positional ? new
|
|
515
|
+
const sound = options.positional ? new THREE27__namespace.PositionalAudio(listener) : new THREE27__namespace.Audio(listener);
|
|
516
516
|
sound.setLoop(options.loop);
|
|
517
517
|
sound.setVolume(options.volume);
|
|
518
518
|
sound.setPlaybackRate(options.pitch);
|
|
519
|
-
if (sound instanceof
|
|
519
|
+
if (sound instanceof THREE27__namespace.PositionalAudio) {
|
|
520
520
|
sound.setRefDistance(options.refDistance);
|
|
521
521
|
sound.setDistanceModel(normalizeDistanceModel(options.distanceModel));
|
|
522
522
|
sound.setRolloffFactor(options.rolloffFactor);
|
|
@@ -526,16 +526,16 @@ function createConfiguredAudio(listener, options) {
|
|
|
526
526
|
__name(createConfiguredAudio, "createConfiguredAudio");
|
|
527
527
|
function createAudioEditorHelper() {
|
|
528
528
|
if (typeof document === "undefined") {
|
|
529
|
-
const geometry = new
|
|
530
|
-
new
|
|
529
|
+
const geometry = new THREE27__namespace.EdgesGeometry(
|
|
530
|
+
new THREE27__namespace.OctahedronGeometry(0.22, 0)
|
|
531
531
|
);
|
|
532
|
-
const material2 = new
|
|
532
|
+
const material2 = new THREE27__namespace.LineBasicMaterial({
|
|
533
533
|
color: "#8bc8ff",
|
|
534
534
|
transparent: true,
|
|
535
535
|
opacity: 0.95,
|
|
536
536
|
depthTest: false
|
|
537
537
|
});
|
|
538
|
-
const fallback = new
|
|
538
|
+
const fallback = new THREE27__namespace.LineSegments(geometry, material2);
|
|
539
539
|
fallback.renderOrder = 10;
|
|
540
540
|
fallback.userData.ecsHelper = true;
|
|
541
541
|
fallback.visible = false;
|
|
@@ -547,7 +547,7 @@ function createAudioEditorHelper() {
|
|
|
547
547
|
canvas.height = size;
|
|
548
548
|
const ctx = canvas.getContext("2d");
|
|
549
549
|
if (!ctx) {
|
|
550
|
-
return new
|
|
550
|
+
return new THREE27__namespace.Object3D();
|
|
551
551
|
}
|
|
552
552
|
ctx.clearRect(0, 0, size, size);
|
|
553
553
|
ctx.fillStyle = "rgba(27, 35, 52, 0.9)";
|
|
@@ -578,14 +578,14 @@ function createAudioEditorHelper() {
|
|
|
578
578
|
ctx.beginPath();
|
|
579
579
|
ctx.arc(56, 48, 16, -0.8, 0.8);
|
|
580
580
|
ctx.stroke();
|
|
581
|
-
const texture = new
|
|
581
|
+
const texture = new THREE27__namespace.CanvasTexture(canvas);
|
|
582
582
|
texture.needsUpdate = true;
|
|
583
|
-
const material = new
|
|
583
|
+
const material = new THREE27__namespace.SpriteMaterial({
|
|
584
584
|
map: texture,
|
|
585
585
|
transparent: true,
|
|
586
586
|
depthTest: false
|
|
587
587
|
});
|
|
588
|
-
const helper = new
|
|
588
|
+
const helper = new THREE27__namespace.Sprite(material);
|
|
589
589
|
helper.scale.set(0.68, 0.68, 0.68);
|
|
590
590
|
helper.renderOrder = 10;
|
|
591
591
|
helper.userData.ecsHelper = true;
|
|
@@ -619,7 +619,7 @@ var DEFAULT_ORTHO_TOP = 5;
|
|
|
619
619
|
var DEFAULT_ORTHO_BOTTOM = -5;
|
|
620
620
|
var DEFAULT_ZOOM = 1;
|
|
621
621
|
function inferProjection(camera) {
|
|
622
|
-
if (camera instanceof
|
|
622
|
+
if (camera instanceof THREE27__namespace.OrthographicCamera) {
|
|
623
623
|
return "orthographic";
|
|
624
624
|
}
|
|
625
625
|
return "perspective";
|
|
@@ -640,7 +640,7 @@ function readCameraFar(camera) {
|
|
|
640
640
|
}
|
|
641
641
|
__name(readCameraFar, "readCameraFar");
|
|
642
642
|
function inferFov(camera) {
|
|
643
|
-
if (camera instanceof
|
|
643
|
+
if (camera instanceof THREE27__namespace.PerspectiveCamera && Number.isFinite(camera.fov)) {
|
|
644
644
|
return camera.fov;
|
|
645
645
|
}
|
|
646
646
|
return DEFAULT_FOV;
|
|
@@ -663,28 +663,28 @@ function inferFar(camera) {
|
|
|
663
663
|
}
|
|
664
664
|
__name(inferFar, "inferFar");
|
|
665
665
|
function inferOrthoLeft(camera) {
|
|
666
|
-
if (camera instanceof
|
|
666
|
+
if (camera instanceof THREE27__namespace.OrthographicCamera && Number.isFinite(camera.left)) {
|
|
667
667
|
return camera.left;
|
|
668
668
|
}
|
|
669
669
|
return DEFAULT_ORTHO_LEFT;
|
|
670
670
|
}
|
|
671
671
|
__name(inferOrthoLeft, "inferOrthoLeft");
|
|
672
672
|
function inferOrthoRight(camera) {
|
|
673
|
-
if (camera instanceof
|
|
673
|
+
if (camera instanceof THREE27__namespace.OrthographicCamera && Number.isFinite(camera.right)) {
|
|
674
674
|
return camera.right;
|
|
675
675
|
}
|
|
676
676
|
return DEFAULT_ORTHO_RIGHT;
|
|
677
677
|
}
|
|
678
678
|
__name(inferOrthoRight, "inferOrthoRight");
|
|
679
679
|
function inferOrthoTop(camera) {
|
|
680
|
-
if (camera instanceof
|
|
680
|
+
if (camera instanceof THREE27__namespace.OrthographicCamera && Number.isFinite(camera.top)) {
|
|
681
681
|
return camera.top;
|
|
682
682
|
}
|
|
683
683
|
return DEFAULT_ORTHO_TOP;
|
|
684
684
|
}
|
|
685
685
|
__name(inferOrthoTop, "inferOrthoTop");
|
|
686
686
|
function inferOrthoBottom(camera) {
|
|
687
|
-
if (camera instanceof
|
|
687
|
+
if (camera instanceof THREE27__namespace.OrthographicCamera && Number.isFinite(camera.bottom)) {
|
|
688
688
|
return camera.bottom;
|
|
689
689
|
}
|
|
690
690
|
return DEFAULT_ORTHO_BOTTOM;
|
|
@@ -700,7 +700,7 @@ __name(inferZoom, "inferZoom");
|
|
|
700
700
|
var _CameraComponent = class _CameraComponent extends Component {
|
|
701
701
|
constructor(payload = {}) {
|
|
702
702
|
super();
|
|
703
|
-
this.camera = payload.camera ?? new
|
|
703
|
+
this.camera = payload.camera ?? new THREE27__namespace.PerspectiveCamera();
|
|
704
704
|
this.type = payload.type ?? "3d";
|
|
705
705
|
this.isDefault = typeof payload.isDefault === "boolean" ? payload.isDefault : false;
|
|
706
706
|
this.projection = payload.projection ?? inferProjection(payload.camera);
|
|
@@ -731,7 +731,7 @@ var Object3DRef = _Object3DRef;
|
|
|
731
731
|
// core/factories/components/CameraFactory.ts
|
|
732
732
|
function createCameraComponent(world, entityId, payload = {}) {
|
|
733
733
|
const object = world.getComponent(entityId, Object3DRef)?.object;
|
|
734
|
-
const objectCamera = object instanceof
|
|
734
|
+
const objectCamera = object instanceof THREE27__namespace.Camera ? object : void 0;
|
|
735
735
|
const component = new CameraComponent({
|
|
736
736
|
...payload,
|
|
737
737
|
camera: payload.camera ?? objectCamera
|
|
@@ -1160,15 +1160,15 @@ function createValueState(light) {
|
|
|
1160
1160
|
castShadow: light.castShadow ?? false,
|
|
1161
1161
|
frustumCulling: light.frustumCulled
|
|
1162
1162
|
};
|
|
1163
|
-
if (light instanceof
|
|
1163
|
+
if (light instanceof THREE27__namespace.PointLight) {
|
|
1164
1164
|
base.distance = light.distance;
|
|
1165
1165
|
base.decay = light.decay;
|
|
1166
|
-
} else if (light instanceof
|
|
1166
|
+
} else if (light instanceof THREE27__namespace.SpotLight) {
|
|
1167
1167
|
base.distance = light.distance;
|
|
1168
1168
|
base.decay = light.decay;
|
|
1169
1169
|
base.angle = light.angle;
|
|
1170
1170
|
base.penumbra = light.penumbra;
|
|
1171
|
-
} else if (light instanceof
|
|
1171
|
+
} else if (light instanceof THREE27__namespace.RectAreaLight) {
|
|
1172
1172
|
base.width = light.width;
|
|
1173
1173
|
base.height = light.height;
|
|
1174
1174
|
}
|
|
@@ -1211,13 +1211,13 @@ function toHexColor2(value, fallback) {
|
|
|
1211
1211
|
}
|
|
1212
1212
|
__name(toHexColor2, "toHexColor");
|
|
1213
1213
|
function getMaterialType(material) {
|
|
1214
|
-
if (material instanceof
|
|
1214
|
+
if (material instanceof THREE27__namespace.MeshPhysicalMaterial) {
|
|
1215
1215
|
return "physical";
|
|
1216
1216
|
}
|
|
1217
|
-
if (material instanceof
|
|
1217
|
+
if (material instanceof THREE27__namespace.MeshPhongMaterial) {
|
|
1218
1218
|
return "phong";
|
|
1219
1219
|
}
|
|
1220
|
-
if (material instanceof
|
|
1220
|
+
if (material instanceof THREE27__namespace.MeshBasicMaterial) {
|
|
1221
1221
|
return "basic";
|
|
1222
1222
|
}
|
|
1223
1223
|
return "standard";
|
|
@@ -1236,8 +1236,8 @@ function createMaterialValue(material) {
|
|
|
1236
1236
|
opacity: typeof materialRecord.opacity === "number" ? materialRecord.opacity : 1,
|
|
1237
1237
|
emissive: toHexColor2(materialRecord.emissive, "#000000"),
|
|
1238
1238
|
emissiveIntensity: typeof materialRecord.emissiveIntensity === "number" ? materialRecord.emissiveIntensity : 0,
|
|
1239
|
-
side: typeof materialRecord.side === "number" ? materialRecord.side :
|
|
1240
|
-
blending: typeof materialRecord.blending === "number" ? materialRecord.blending :
|
|
1239
|
+
side: typeof materialRecord.side === "number" ? materialRecord.side : THREE27__namespace.FrontSide,
|
|
1240
|
+
blending: typeof materialRecord.blending === "number" ? materialRecord.blending : THREE27__namespace.NormalBlending,
|
|
1241
1241
|
depthTest: materialRecord.depthTest !== false,
|
|
1242
1242
|
depthWrite: materialRecord.depthWrite !== false,
|
|
1243
1243
|
wireframe: Boolean(materialRecord.wireframe),
|
|
@@ -1253,7 +1253,7 @@ function createMaterialValue(material) {
|
|
|
1253
1253
|
displacementMap: materialRecord.displacementMap?.image?.src,
|
|
1254
1254
|
lightMap: materialRecord.lightMap?.image?.src,
|
|
1255
1255
|
envMap: materialRecord.envMap?.image?.src,
|
|
1256
|
-
textureFiltering: map?.magFilter ===
|
|
1256
|
+
textureFiltering: map?.magFilter === THREE27__namespace.NearestFilter ? "sharp" : "smooth",
|
|
1257
1257
|
useMipmaps: map?.generateMipmaps !== false
|
|
1258
1258
|
};
|
|
1259
1259
|
}
|
|
@@ -1268,8 +1268,8 @@ function defaultMaterialValue() {
|
|
|
1268
1268
|
opacity: 1,
|
|
1269
1269
|
emissive: "#000000",
|
|
1270
1270
|
emissiveIntensity: 0,
|
|
1271
|
-
side:
|
|
1272
|
-
blending:
|
|
1271
|
+
side: THREE27__namespace.FrontSide,
|
|
1272
|
+
blending: THREE27__namespace.NormalBlending,
|
|
1273
1273
|
depthTest: true,
|
|
1274
1274
|
depthWrite: true,
|
|
1275
1275
|
wireframe: false,
|
|
@@ -1860,14 +1860,14 @@ var _TransformComponent = class _TransformComponent extends Component {
|
|
|
1860
1860
|
z: scale.z ?? 1
|
|
1861
1861
|
};
|
|
1862
1862
|
}
|
|
1863
|
-
toPositionVector3(target = new
|
|
1863
|
+
toPositionVector3(target = new THREE27.Vector3()) {
|
|
1864
1864
|
return target.set(this.position.x, this.position.y, this.position.z);
|
|
1865
1865
|
}
|
|
1866
|
-
toRotationEuler(target = new
|
|
1866
|
+
toRotationEuler(target = new THREE27.Euler(), order = "XYZ") {
|
|
1867
1867
|
return target.set(this.rotation.x, this.rotation.y, this.rotation.z, order);
|
|
1868
1868
|
}
|
|
1869
|
-
toRotationQuaternion(target = new
|
|
1870
|
-
const euler = new
|
|
1869
|
+
toRotationQuaternion(target = new THREE27.Quaternion(), order = "XYZ") {
|
|
1870
|
+
const euler = new THREE27.Euler(
|
|
1871
1871
|
this.rotation.x,
|
|
1872
1872
|
this.rotation.y,
|
|
1873
1873
|
this.rotation.z,
|
|
@@ -1875,7 +1875,7 @@ var _TransformComponent = class _TransformComponent extends Component {
|
|
|
1875
1875
|
);
|
|
1876
1876
|
return target.setFromEuler(euler);
|
|
1877
1877
|
}
|
|
1878
|
-
toScaleVector3(target = new
|
|
1878
|
+
toScaleVector3(target = new THREE27.Vector3()) {
|
|
1879
1879
|
return target.set(this.scale.x, this.scale.y, this.scale.z);
|
|
1880
1880
|
}
|
|
1881
1881
|
setPosition(input) {
|
|
@@ -1893,8 +1893,8 @@ var _TransformComponent = class _TransformComponent extends Component {
|
|
|
1893
1893
|
return this;
|
|
1894
1894
|
}
|
|
1895
1895
|
setRotation(input, order = "XYZ") {
|
|
1896
|
-
if (input instanceof
|
|
1897
|
-
const euler = new
|
|
1896
|
+
if (input instanceof THREE27.Quaternion) {
|
|
1897
|
+
const euler = new THREE27.Euler().setFromQuaternion(input, order);
|
|
1898
1898
|
this.rotation.x = euler.x;
|
|
1899
1899
|
this.rotation.y = euler.y;
|
|
1900
1900
|
this.rotation.z = euler.z;
|
|
@@ -1918,6 +1918,83 @@ function createTransformComponent(world, entityId, ...args) {
|
|
|
1918
1918
|
}
|
|
1919
1919
|
__name(createTransformComponent, "createTransformComponent");
|
|
1920
1920
|
|
|
1921
|
+
// core/components/InstancedMesh.ts
|
|
1922
|
+
var DEFAULT_INSTANCE_TRANSFORM = {
|
|
1923
|
+
position: { x: 0, y: 0, z: 0 },
|
|
1924
|
+
rotation: { x: 0, y: 0, z: 0 },
|
|
1925
|
+
scale: { x: 1, y: 1, z: 1 }
|
|
1926
|
+
};
|
|
1927
|
+
var DEFAULT_INSTANCED_MESH_PARAMETERS = {
|
|
1928
|
+
capsule: DEFAULT_MESH_GEOMETRY_PARAMETERS.capsule,
|
|
1929
|
+
cube: DEFAULT_MESH_GEOMETRY_PARAMETERS.cube,
|
|
1930
|
+
cylinder: DEFAULT_MESH_GEOMETRY_PARAMETERS.cylinder,
|
|
1931
|
+
model: DEFAULT_MESH_GEOMETRY_PARAMETERS.cube,
|
|
1932
|
+
plane: DEFAULT_MESH_GEOMETRY_PARAMETERS.plane,
|
|
1933
|
+
sphere: DEFAULT_MESH_GEOMETRY_PARAMETERS.sphere
|
|
1934
|
+
};
|
|
1935
|
+
var _InstancedMeshComponent = class _InstancedMeshComponent extends Component {
|
|
1936
|
+
constructor(meshKind = "cube", meshParameters, options) {
|
|
1937
|
+
super();
|
|
1938
|
+
this.meshKind = meshKind;
|
|
1939
|
+
this.modelPath = options?.modelPath ?? "";
|
|
1940
|
+
this.meshParameters = {
|
|
1941
|
+
...DEFAULT_INSTANCED_MESH_PARAMETERS[meshKind],
|
|
1942
|
+
...meshParameters ?? {}
|
|
1943
|
+
};
|
|
1944
|
+
this.castShadow = options?.castShadow ?? false;
|
|
1945
|
+
this.receiveShadow = options?.receiveShadow ?? false;
|
|
1946
|
+
this.instances = options?.instances && options.instances.length > 0 ? options.instances : [{ ...DEFAULT_INSTANCE_TRANSFORM }];
|
|
1947
|
+
this.instancedMesh = null;
|
|
1948
|
+
}
|
|
1949
|
+
/** Sanitize and return a copy of the current mesh parameters with valid values. */
|
|
1950
|
+
getSanitizedParameters() {
|
|
1951
|
+
const MIN_DIM = 0.01;
|
|
1952
|
+
const MIN_RAD = 1e-3;
|
|
1953
|
+
const sanitize = /* @__PURE__ */ __name((v, min) => Number.isFinite(v) ? Math.max(min, v) : min, "sanitize");
|
|
1954
|
+
switch (this.meshKind) {
|
|
1955
|
+
case "cube": {
|
|
1956
|
+
const p = this.meshParameters;
|
|
1957
|
+
return {
|
|
1958
|
+
width: sanitize(p.width, MIN_DIM),
|
|
1959
|
+
height: sanitize(p.height, MIN_DIM),
|
|
1960
|
+
depth: sanitize(p.depth, MIN_DIM)
|
|
1961
|
+
};
|
|
1962
|
+
}
|
|
1963
|
+
case "plane": {
|
|
1964
|
+
const p = this.meshParameters;
|
|
1965
|
+
return {
|
|
1966
|
+
width: sanitize(p.width, MIN_DIM),
|
|
1967
|
+
height: sanitize(p.height, MIN_DIM)
|
|
1968
|
+
};
|
|
1969
|
+
}
|
|
1970
|
+
case "sphere": {
|
|
1971
|
+
const p = this.meshParameters;
|
|
1972
|
+
return { radius: sanitize(p.radius, MIN_RAD) };
|
|
1973
|
+
}
|
|
1974
|
+
case "cylinder":
|
|
1975
|
+
case "capsule": {
|
|
1976
|
+
const p = this.meshParameters;
|
|
1977
|
+
return {
|
|
1978
|
+
radius: sanitize(p.radius, MIN_RAD),
|
|
1979
|
+
height: sanitize(p.height, MIN_DIM)
|
|
1980
|
+
};
|
|
1981
|
+
}
|
|
1982
|
+
case "model":
|
|
1983
|
+
return DEFAULT_MESH_GEOMETRY_PARAMETERS.cube;
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
};
|
|
1987
|
+
__name(_InstancedMeshComponent, "InstancedMeshComponent");
|
|
1988
|
+
var InstancedMeshComponent = _InstancedMeshComponent;
|
|
1989
|
+
|
|
1990
|
+
// core/factories/components/InstancedMeshComponentFactory.ts
|
|
1991
|
+
function createInstancedMeshComponent(world, entityId, meshKind, meshParameters, options) {
|
|
1992
|
+
const component = new InstancedMeshComponent(meshKind, meshParameters, options);
|
|
1993
|
+
world.addComponent(entityId, component);
|
|
1994
|
+
return component;
|
|
1995
|
+
}
|
|
1996
|
+
__name(createInstancedMeshComponent, "createInstancedMeshComponent");
|
|
1997
|
+
|
|
1921
1998
|
// core/components/Video.ts
|
|
1922
1999
|
var DEFAULT_VIDEO_OPTIONS = {
|
|
1923
2000
|
autoplay: false,
|
|
@@ -2044,6 +2121,7 @@ function registerDefaultComponentFactories(objectManagementSystem) {
|
|
|
2044
2121
|
objectManagementSystem.registerComponentFactory("sprite", createSpriteComponent);
|
|
2045
2122
|
objectManagementSystem.registerComponentFactory("transform", createTransformComponent);
|
|
2046
2123
|
objectManagementSystem.registerComponentFactory("video", createVideoComponent);
|
|
2124
|
+
objectManagementSystem.registerComponentFactory("instancedMesh", createInstancedMeshComponent);
|
|
2047
2125
|
}
|
|
2048
2126
|
__name(registerDefaultComponentFactories, "registerDefaultComponentFactories");
|
|
2049
2127
|
function createTransform(input) {
|
|
@@ -2084,10 +2162,10 @@ __name(createBaseEntity, "createBaseEntity");
|
|
|
2084
2162
|
// core/factories/objects/AudioFactory.ts
|
|
2085
2163
|
function getOrCreateListener(camera) {
|
|
2086
2164
|
const existing = camera.userData.ecsAudioListener;
|
|
2087
|
-
if (existing instanceof
|
|
2165
|
+
if (existing instanceof THREE27__namespace.AudioListener) {
|
|
2088
2166
|
return existing;
|
|
2089
2167
|
}
|
|
2090
|
-
const listener = new
|
|
2168
|
+
const listener = new THREE27__namespace.AudioListener();
|
|
2091
2169
|
camera.add(listener);
|
|
2092
2170
|
camera.userData.ecsAudioListener = listener;
|
|
2093
2171
|
return listener;
|
|
@@ -2100,7 +2178,7 @@ function createAudio({
|
|
|
2100
2178
|
payload,
|
|
2101
2179
|
isEditor
|
|
2102
2180
|
}) {
|
|
2103
|
-
const anchor = new
|
|
2181
|
+
const anchor = new THREE27__namespace.Object3D();
|
|
2104
2182
|
const entityId = createBaseEntity(world, anchor, {
|
|
2105
2183
|
label: payload.name ?? "Audio",
|
|
2106
2184
|
entityType: "audio",
|
|
@@ -2122,7 +2200,7 @@ function createAudio({
|
|
|
2122
2200
|
return entityId;
|
|
2123
2201
|
}
|
|
2124
2202
|
if (!isEditor) {
|
|
2125
|
-
const loader = new
|
|
2203
|
+
const loader = new THREE27__namespace.AudioLoader();
|
|
2126
2204
|
loader.load(
|
|
2127
2205
|
audio.path,
|
|
2128
2206
|
(buffer) => {
|
|
@@ -2197,7 +2275,7 @@ function applyCameraSettings(camera, options) {
|
|
|
2197
2275
|
const near = typeof options.near === "number" ? options.near : DEFAULT_NEAR2;
|
|
2198
2276
|
const far = typeof options.far === "number" ? options.far : DEFAULT_FAR2;
|
|
2199
2277
|
const projection = options.projection;
|
|
2200
|
-
if (camera instanceof
|
|
2278
|
+
if (camera instanceof THREE27__namespace.PerspectiveCamera) {
|
|
2201
2279
|
if (!projection || projection === "perspective") {
|
|
2202
2280
|
camera.fov = typeof options.fov === "number" ? options.fov : DEFAULT_FOV2;
|
|
2203
2281
|
}
|
|
@@ -2207,7 +2285,7 @@ function applyCameraSettings(camera, options) {
|
|
|
2207
2285
|
camera.updateProjectionMatrix();
|
|
2208
2286
|
return;
|
|
2209
2287
|
}
|
|
2210
|
-
if (camera instanceof
|
|
2288
|
+
if (camera instanceof THREE27__namespace.OrthographicCamera) {
|
|
2211
2289
|
camera.left = typeof options.left === "number" ? options.left : -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2212
2290
|
camera.right = typeof options.right === "number" ? options.right : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2213
2291
|
camera.top = typeof options.top === "number" ? options.top : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
@@ -2228,7 +2306,7 @@ function createCameraObject(options) {
|
|
|
2228
2306
|
const bottom = options.bottom ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2229
2307
|
const left = options.left ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2230
2308
|
const right = options.right ?? DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2231
|
-
const camera = new
|
|
2309
|
+
const camera = new THREE27__namespace.OrthographicCamera(
|
|
2232
2310
|
left,
|
|
2233
2311
|
right,
|
|
2234
2312
|
top,
|
|
@@ -2240,7 +2318,7 @@ function createCameraObject(options) {
|
|
|
2240
2318
|
camera.updateProjectionMatrix();
|
|
2241
2319
|
return camera;
|
|
2242
2320
|
}
|
|
2243
|
-
return new
|
|
2321
|
+
return new THREE27__namespace.PerspectiveCamera(
|
|
2244
2322
|
options.fov ?? DEFAULT_FOV2,
|
|
2245
2323
|
readViewportAspect(),
|
|
2246
2324
|
near,
|
|
@@ -2258,7 +2336,7 @@ function createCamera({ world, scene, camera, payload, isEditor }) {
|
|
|
2258
2336
|
transformInput: payload.transform
|
|
2259
2337
|
});
|
|
2260
2338
|
const objectRef = world.getComponent(entityId, Object3DRef);
|
|
2261
|
-
if (objectRef?.object instanceof
|
|
2339
|
+
if (objectRef?.object instanceof THREE27__namespace.Camera) {
|
|
2262
2340
|
objectRef.object.userData.entityId = entityId;
|
|
2263
2341
|
}
|
|
2264
2342
|
const componentOptions = {
|
|
@@ -2281,7 +2359,7 @@ function createCamera({ world, scene, camera, payload, isEditor }) {
|
|
|
2281
2359
|
} else {
|
|
2282
2360
|
applyCameraSettings(object, options);
|
|
2283
2361
|
if (isEditor && component.isDefault) {
|
|
2284
|
-
const helper = new
|
|
2362
|
+
const helper = new THREE27__namespace.CameraHelper(object);
|
|
2285
2363
|
helper.onBeforeRender = () => {
|
|
2286
2364
|
helper.update();
|
|
2287
2365
|
};
|
|
@@ -2299,9 +2377,9 @@ function createCapsule({
|
|
|
2299
2377
|
scene,
|
|
2300
2378
|
payload
|
|
2301
2379
|
}) {
|
|
2302
|
-
const geometry = new
|
|
2303
|
-
const material = new
|
|
2304
|
-
const mesh = new
|
|
2380
|
+
const geometry = new THREE27__namespace.CapsuleGeometry(0.5, 1, 4, 8);
|
|
2381
|
+
const material = new THREE27__namespace.MeshStandardMaterial({ color: "#ffffff" });
|
|
2382
|
+
const mesh = new THREE27__namespace.Mesh(geometry, material);
|
|
2305
2383
|
const entityId = createBaseEntity(world, mesh, {
|
|
2306
2384
|
label: payload.name ?? "Capsule",
|
|
2307
2385
|
entityType: "capsule",
|
|
@@ -2321,9 +2399,9 @@ function createCapsule({
|
|
|
2321
2399
|
}
|
|
2322
2400
|
__name(createCapsule, "createCapsule");
|
|
2323
2401
|
function createCube({ world, scene, payload }) {
|
|
2324
|
-
const geometry = new
|
|
2325
|
-
const material = new
|
|
2326
|
-
const mesh = new
|
|
2402
|
+
const geometry = new THREE27__namespace.BoxGeometry(1, 1, 1);
|
|
2403
|
+
const material = new THREE27__namespace.MeshStandardMaterial({ color: "#ffffff" });
|
|
2404
|
+
const mesh = new THREE27__namespace.Mesh(geometry, material);
|
|
2327
2405
|
const entityId = createBaseEntity(world, mesh, {
|
|
2328
2406
|
label: payload.name ?? "Cube",
|
|
2329
2407
|
entityType: "cube",
|
|
@@ -2348,9 +2426,9 @@ function createCylinder({
|
|
|
2348
2426
|
scene,
|
|
2349
2427
|
payload
|
|
2350
2428
|
}) {
|
|
2351
|
-
const geometry = new
|
|
2352
|
-
const material = new
|
|
2353
|
-
const mesh = new
|
|
2429
|
+
const geometry = new THREE27__namespace.CylinderGeometry(0.5, 0.5, 1, 20);
|
|
2430
|
+
const material = new THREE27__namespace.MeshStandardMaterial({ color: "#ffffff" });
|
|
2431
|
+
const mesh = new THREE27__namespace.Mesh(geometry, material);
|
|
2354
2432
|
const entityId = createBaseEntity(world, mesh, {
|
|
2355
2433
|
label: payload.name ?? "Cylinder",
|
|
2356
2434
|
entityType: "cylinder",
|
|
@@ -2370,7 +2448,7 @@ function createCylinder({
|
|
|
2370
2448
|
}
|
|
2371
2449
|
__name(createCylinder, "createCylinder");
|
|
2372
2450
|
function createEmpty({ world, scene, payload, isEditor }) {
|
|
2373
|
-
const object = new
|
|
2451
|
+
const object = new THREE27__namespace.Group();
|
|
2374
2452
|
const entityId = createBaseEntity(world, object, {
|
|
2375
2453
|
label: payload.name ?? "Empty",
|
|
2376
2454
|
entityType: "empty",
|
|
@@ -2381,7 +2459,7 @@ function createEmpty({ world, scene, payload, isEditor }) {
|
|
|
2381
2459
|
}
|
|
2382
2460
|
__name(createEmpty, "createEmpty");
|
|
2383
2461
|
function createImage({ world, scene, payload }) {
|
|
2384
|
-
const anchor = new
|
|
2462
|
+
const anchor = new THREE27__namespace.Object3D();
|
|
2385
2463
|
const imagePath = payload.path ?? "";
|
|
2386
2464
|
const entityId = createBaseEntity(world, anchor, {
|
|
2387
2465
|
label: payload.name ?? "Image",
|
|
@@ -2394,7 +2472,7 @@ function createImage({ world, scene, payload }) {
|
|
|
2394
2472
|
if (!imagePath) {
|
|
2395
2473
|
return entityId;
|
|
2396
2474
|
}
|
|
2397
|
-
const loader = new
|
|
2475
|
+
const loader = new THREE27__namespace.TextureLoader();
|
|
2398
2476
|
loader.load(
|
|
2399
2477
|
imagePath,
|
|
2400
2478
|
(texture) => {
|
|
@@ -2402,13 +2480,13 @@ function createImage({ world, scene, payload }) {
|
|
|
2402
2480
|
texture.dispose();
|
|
2403
2481
|
return;
|
|
2404
2482
|
}
|
|
2405
|
-
const material = new
|
|
2483
|
+
const material = new THREE27__namespace.MeshBasicMaterial({
|
|
2406
2484
|
map: texture,
|
|
2407
2485
|
transparent: true,
|
|
2408
|
-
side:
|
|
2486
|
+
side: THREE27__namespace.DoubleSide
|
|
2409
2487
|
});
|
|
2410
|
-
const geometry = new
|
|
2411
|
-
const plane = new
|
|
2488
|
+
const geometry = new THREE27__namespace.PlaneGeometry(1, 1);
|
|
2489
|
+
const plane = new THREE27__namespace.Mesh(geometry, material);
|
|
2412
2490
|
plane.userData.entityId = entityId;
|
|
2413
2491
|
const textureImage = texture.image;
|
|
2414
2492
|
const width = textureImage?.width ?? 1;
|
|
@@ -2454,7 +2532,7 @@ function createImageTarget({
|
|
|
2454
2532
|
payload,
|
|
2455
2533
|
isEditor
|
|
2456
2534
|
}) {
|
|
2457
|
-
const anchor = new
|
|
2535
|
+
const anchor = new THREE27__namespace.Object3D();
|
|
2458
2536
|
const imagePath = payload.path ?? "";
|
|
2459
2537
|
const entityId = createBaseEntity(world, anchor, {
|
|
2460
2538
|
label: payload.name ?? "Image Target",
|
|
@@ -2471,7 +2549,7 @@ function createImageTarget({
|
|
|
2471
2549
|
if (!isEditor || !imagePath) {
|
|
2472
2550
|
return entityId;
|
|
2473
2551
|
}
|
|
2474
|
-
const loader = new
|
|
2552
|
+
const loader = new THREE27__namespace.TextureLoader();
|
|
2475
2553
|
loader.load(
|
|
2476
2554
|
imagePath,
|
|
2477
2555
|
(texture) => {
|
|
@@ -2479,13 +2557,13 @@ function createImageTarget({
|
|
|
2479
2557
|
texture.dispose();
|
|
2480
2558
|
return;
|
|
2481
2559
|
}
|
|
2482
|
-
const material = new
|
|
2560
|
+
const material = new THREE27__namespace.MeshBasicMaterial({
|
|
2483
2561
|
map: texture,
|
|
2484
2562
|
transparent: true,
|
|
2485
|
-
side:
|
|
2563
|
+
side: THREE27__namespace.DoubleSide
|
|
2486
2564
|
});
|
|
2487
|
-
const geometry = new
|
|
2488
|
-
const plane = new
|
|
2565
|
+
const geometry = new THREE27__namespace.PlaneGeometry(1, 1);
|
|
2566
|
+
const plane = new THREE27__namespace.Mesh(geometry, material);
|
|
2489
2567
|
plane.userData.entityId = entityId;
|
|
2490
2568
|
const textureImage = texture.image;
|
|
2491
2569
|
const width = textureImage?.width ?? 1;
|
|
@@ -2504,12 +2582,48 @@ function createImageTarget({
|
|
|
2504
2582
|
return entityId;
|
|
2505
2583
|
}
|
|
2506
2584
|
__name(createImageTarget, "createImageTarget");
|
|
2585
|
+
function isInstancedMeshKind(value) {
|
|
2586
|
+
return value === "cube" || value === "sphere" || value === "plane" || value === "cylinder" || value === "capsule";
|
|
2587
|
+
}
|
|
2588
|
+
__name(isInstancedMeshKind, "isInstancedMeshKind");
|
|
2589
|
+
function isInstanceTransformArray(value) {
|
|
2590
|
+
return Array.isArray(value);
|
|
2591
|
+
}
|
|
2592
|
+
__name(isInstanceTransformArray, "isInstanceTransformArray");
|
|
2593
|
+
function createInstancedMesh({
|
|
2594
|
+
world,
|
|
2595
|
+
scene,
|
|
2596
|
+
payload
|
|
2597
|
+
}) {
|
|
2598
|
+
const anchor = new THREE27__namespace.Object3D();
|
|
2599
|
+
const opts = payload.options ?? {};
|
|
2600
|
+
const meshKind = isInstancedMeshKind(opts.meshKind) ? opts.meshKind : "cube";
|
|
2601
|
+
const meshParameters = opts.meshParameters && typeof opts.meshParameters === "object" ? opts.meshParameters : void 0;
|
|
2602
|
+
const instances = isInstanceTransformArray(
|
|
2603
|
+
opts.instances
|
|
2604
|
+
) ? opts.instances : void 0;
|
|
2605
|
+
const castShadow = typeof opts.castShadow === "boolean" ? opts.castShadow : false;
|
|
2606
|
+
const receiveShadow = typeof opts.receiveShadow === "boolean" ? opts.receiveShadow : false;
|
|
2607
|
+
const entityId = createBaseEntity(world, anchor, {
|
|
2608
|
+
label: payload.name ?? "Instanced Mesh",
|
|
2609
|
+
entityType: "instancedMesh",
|
|
2610
|
+
transformInput: payload.transform
|
|
2611
|
+
});
|
|
2612
|
+
createInstancedMeshComponent(world, entityId, meshKind, meshParameters, {
|
|
2613
|
+
castShadow,
|
|
2614
|
+
receiveShadow,
|
|
2615
|
+
instances
|
|
2616
|
+
});
|
|
2617
|
+
scene.add(anchor);
|
|
2618
|
+
return entityId;
|
|
2619
|
+
}
|
|
2620
|
+
__name(createInstancedMesh, "createInstancedMesh");
|
|
2507
2621
|
function createAmbientLight({
|
|
2508
2622
|
world,
|
|
2509
2623
|
scene,
|
|
2510
2624
|
payload
|
|
2511
2625
|
}) {
|
|
2512
|
-
const light = new
|
|
2626
|
+
const light = new THREE27__namespace.AmbientLight("#ffffff", 0.6);
|
|
2513
2627
|
const entityId = createBaseEntity(world, light, {
|
|
2514
2628
|
label: payload.name ?? "Ambient Light",
|
|
2515
2629
|
entityType: "ambientLight",
|
|
@@ -2526,7 +2640,7 @@ function createAreaLight({
|
|
|
2526
2640
|
payload,
|
|
2527
2641
|
isEditor
|
|
2528
2642
|
}) {
|
|
2529
|
-
const light = new
|
|
2643
|
+
const light = new THREE27__namespace.RectAreaLight("#ffffff", 5, 4, 4);
|
|
2530
2644
|
light.lookAt(0, 0, 0);
|
|
2531
2645
|
const entityId = createBaseEntity(world, light, {
|
|
2532
2646
|
label: payload.name ?? "Area Light",
|
|
@@ -2555,7 +2669,7 @@ function createDirectionalLight({
|
|
|
2555
2669
|
payload,
|
|
2556
2670
|
isEditor
|
|
2557
2671
|
}) {
|
|
2558
|
-
const light = new
|
|
2672
|
+
const light = new THREE27__namespace.DirectionalLight("#ffffff", 1.5);
|
|
2559
2673
|
light.castShadow = true;
|
|
2560
2674
|
const entityId = createBaseEntity(world, light, {
|
|
2561
2675
|
label: payload.name ?? "Directional Light",
|
|
@@ -2566,7 +2680,7 @@ function createDirectionalLight({
|
|
|
2566
2680
|
});
|
|
2567
2681
|
createLightComponent(world, entityId, light);
|
|
2568
2682
|
if (isEditor) {
|
|
2569
|
-
const helper = new
|
|
2683
|
+
const helper = new THREE27__namespace.DirectionalLightHelper(light, 1.8, "#38bdf8");
|
|
2570
2684
|
helper.onBeforeRender = () => {
|
|
2571
2685
|
helper.update();
|
|
2572
2686
|
};
|
|
@@ -2584,7 +2698,7 @@ function createPointLight({
|
|
|
2584
2698
|
payload,
|
|
2585
2699
|
isEditor
|
|
2586
2700
|
}) {
|
|
2587
|
-
const light = new
|
|
2701
|
+
const light = new THREE27__namespace.PointLight("#ffffff", 1, 10);
|
|
2588
2702
|
const entityId = createBaseEntity(world, light, {
|
|
2589
2703
|
label: payload.name ?? "Point Light",
|
|
2590
2704
|
entityType: "pointLight",
|
|
@@ -2594,7 +2708,7 @@ function createPointLight({
|
|
|
2594
2708
|
});
|
|
2595
2709
|
createLightComponent(world, entityId, light);
|
|
2596
2710
|
if (isEditor) {
|
|
2597
|
-
const helper = new
|
|
2711
|
+
const helper = new THREE27__namespace.PointLightHelper(light, 0.35, "#fbbf24");
|
|
2598
2712
|
helper.onBeforeRender = () => {
|
|
2599
2713
|
helper.update();
|
|
2600
2714
|
};
|
|
@@ -2612,7 +2726,7 @@ function createSpotLight({
|
|
|
2612
2726
|
payload,
|
|
2613
2727
|
isEditor
|
|
2614
2728
|
}) {
|
|
2615
|
-
const light = new
|
|
2729
|
+
const light = new THREE27__namespace.SpotLight("#ffffff", 1, 20, Math.PI / 6, 0.1, 1);
|
|
2616
2730
|
const entityId = createBaseEntity(world, light, {
|
|
2617
2731
|
label: payload.name ?? "Spot Light",
|
|
2618
2732
|
entityType: "spotLight",
|
|
@@ -2622,7 +2736,7 @@ function createSpotLight({
|
|
|
2622
2736
|
});
|
|
2623
2737
|
createLightComponent(world, entityId, light);
|
|
2624
2738
|
if (isEditor) {
|
|
2625
|
-
const helper = new
|
|
2739
|
+
const helper = new THREE27__namespace.SpotLightHelper(light, "#f59e0b");
|
|
2626
2740
|
helper.onBeforeRender = () => {
|
|
2627
2741
|
helper.update();
|
|
2628
2742
|
};
|
|
@@ -2678,7 +2792,7 @@ function createModelLoader() {
|
|
|
2678
2792
|
}
|
|
2679
2793
|
__name(createModelLoader, "createModelLoader");
|
|
2680
2794
|
function createModel({ world, scene, payload }) {
|
|
2681
|
-
const anchor = new
|
|
2795
|
+
const anchor = new THREE27__namespace.Object3D();
|
|
2682
2796
|
const modelPath = payload.path ?? "";
|
|
2683
2797
|
const entityId = createBaseEntity(world, anchor, {
|
|
2684
2798
|
label: payload.name ?? "Model",
|
|
@@ -2735,12 +2849,12 @@ function createModel({ world, scene, payload }) {
|
|
|
2735
2849
|
}
|
|
2736
2850
|
__name(createModel, "createModel");
|
|
2737
2851
|
function createPlane({ world, scene, payload }) {
|
|
2738
|
-
const geometry = new
|
|
2739
|
-
const material = new
|
|
2852
|
+
const geometry = new THREE27__namespace.PlaneGeometry(100, 100);
|
|
2853
|
+
const material = new THREE27__namespace.MeshStandardMaterial({
|
|
2740
2854
|
color: "#ffffff",
|
|
2741
|
-
side:
|
|
2855
|
+
side: THREE27__namespace.DoubleSide
|
|
2742
2856
|
});
|
|
2743
|
-
const mesh = new
|
|
2857
|
+
const mesh = new THREE27__namespace.Mesh(geometry, material);
|
|
2744
2858
|
const entityId = createBaseEntity(
|
|
2745
2859
|
world,
|
|
2746
2860
|
mesh,
|
|
@@ -2772,7 +2886,7 @@ function createPlane({ world, scene, payload }) {
|
|
|
2772
2886
|
}
|
|
2773
2887
|
__name(createPlane, "createPlane");
|
|
2774
2888
|
function createSprite({ world, scene, payload }) {
|
|
2775
|
-
const anchor = new
|
|
2889
|
+
const anchor = new THREE27__namespace.Object3D();
|
|
2776
2890
|
const imagePath = payload.path ?? "";
|
|
2777
2891
|
const entityId = createBaseEntity(world, anchor, {
|
|
2778
2892
|
label: payload.name ?? "Sprite",
|
|
@@ -2784,7 +2898,7 @@ function createSprite({ world, scene, payload }) {
|
|
|
2784
2898
|
if (!imagePath) {
|
|
2785
2899
|
return entityId;
|
|
2786
2900
|
}
|
|
2787
|
-
const loader = new
|
|
2901
|
+
const loader = new THREE27__namespace.TextureLoader();
|
|
2788
2902
|
loader.load(
|
|
2789
2903
|
imagePath,
|
|
2790
2904
|
(texture) => {
|
|
@@ -2792,11 +2906,11 @@ function createSprite({ world, scene, payload }) {
|
|
|
2792
2906
|
texture.dispose();
|
|
2793
2907
|
return;
|
|
2794
2908
|
}
|
|
2795
|
-
const material = new
|
|
2909
|
+
const material = new THREE27__namespace.SpriteMaterial({
|
|
2796
2910
|
map: texture,
|
|
2797
2911
|
transparent: true
|
|
2798
2912
|
});
|
|
2799
|
-
const sprite = new
|
|
2913
|
+
const sprite = new THREE27__namespace.Sprite(material);
|
|
2800
2914
|
sprite.userData.entityId = entityId;
|
|
2801
2915
|
const textureImage = texture.image;
|
|
2802
2916
|
spriteComponent.width = textureImage?.width ?? 1;
|
|
@@ -2814,9 +2928,9 @@ function createSprite({ world, scene, payload }) {
|
|
|
2814
2928
|
}
|
|
2815
2929
|
__name(createSprite, "createSprite");
|
|
2816
2930
|
function createSphere({ world, scene, payload }) {
|
|
2817
|
-
const geometry = new
|
|
2818
|
-
const material = new
|
|
2819
|
-
const mesh = new
|
|
2931
|
+
const geometry = new THREE27__namespace.SphereGeometry(0.5, 24, 24);
|
|
2932
|
+
const material = new THREE27__namespace.MeshStandardMaterial({ color: "#ffffff" });
|
|
2933
|
+
const mesh = new THREE27__namespace.Mesh(geometry, material);
|
|
2820
2934
|
const entityId = createBaseEntity(world, mesh, {
|
|
2821
2935
|
label: payload.name ?? "Sphere",
|
|
2822
2936
|
entityType: "sphere",
|
|
@@ -2836,10 +2950,10 @@ function createSphere({ world, scene, payload }) {
|
|
|
2836
2950
|
__name(createSphere, "createSphere");
|
|
2837
2951
|
function getOrCreateListener2(camera) {
|
|
2838
2952
|
const existing = camera.userData.ecsAudioListener;
|
|
2839
|
-
if (existing instanceof
|
|
2953
|
+
if (existing instanceof THREE27__namespace.AudioListener) {
|
|
2840
2954
|
return existing;
|
|
2841
2955
|
}
|
|
2842
|
-
const listener = new
|
|
2956
|
+
const listener = new THREE27__namespace.AudioListener();
|
|
2843
2957
|
camera.add(listener);
|
|
2844
2958
|
camera.userData.ecsAudioListener = listener;
|
|
2845
2959
|
return listener;
|
|
@@ -2889,10 +3003,10 @@ function normalizeOptions(input) {
|
|
|
2889
3003
|
}
|
|
2890
3004
|
__name(normalizeOptions, "normalizeOptions");
|
|
2891
3005
|
function createChromaMaterial(texture, options) {
|
|
2892
|
-
return new
|
|
3006
|
+
return new THREE27__namespace.ShaderMaterial({
|
|
2893
3007
|
uniforms: {
|
|
2894
3008
|
tex: { value: texture },
|
|
2895
|
-
keyColor: { value: new
|
|
3009
|
+
keyColor: { value: new THREE27__namespace.Color(options.backgroundColor) },
|
|
2896
3010
|
similarity: { value: options.similarity },
|
|
2897
3011
|
smoothness: { value: options.smoothness },
|
|
2898
3012
|
spill: { value: options.spill }
|
|
@@ -2924,22 +3038,22 @@ function createChromaMaterial(texture, options) {
|
|
|
2924
3038
|
}
|
|
2925
3039
|
`,
|
|
2926
3040
|
transparent: true,
|
|
2927
|
-
side:
|
|
3041
|
+
side: THREE27__namespace.DoubleSide
|
|
2928
3042
|
});
|
|
2929
3043
|
}
|
|
2930
3044
|
__name(createChromaMaterial, "createChromaMaterial");
|
|
2931
3045
|
function createStandardMaterial(texture) {
|
|
2932
|
-
return new
|
|
3046
|
+
return new THREE27__namespace.MeshBasicMaterial({
|
|
2933
3047
|
map: texture,
|
|
2934
3048
|
transparent: true,
|
|
2935
|
-
side:
|
|
3049
|
+
side: THREE27__namespace.DoubleSide
|
|
2936
3050
|
});
|
|
2937
3051
|
}
|
|
2938
3052
|
__name(createStandardMaterial, "createStandardMaterial");
|
|
2939
3053
|
function createVideoMesh(entityId, texture, options) {
|
|
2940
|
-
const geometry = new
|
|
3054
|
+
const geometry = new THREE27__namespace.PlaneGeometry(1, 1);
|
|
2941
3055
|
const material = options.isGreenScreen ? createChromaMaterial(texture, options) : createStandardMaterial(texture);
|
|
2942
|
-
const mesh = new
|
|
3056
|
+
const mesh = new THREE27__namespace.Mesh(geometry, material);
|
|
2943
3057
|
mesh.userData.entityId = entityId;
|
|
2944
3058
|
mesh.scale.set(options.width, options.height, 1);
|
|
2945
3059
|
return { mesh, material };
|
|
@@ -2974,7 +3088,7 @@ function createVideo({
|
|
|
2974
3088
|
payload,
|
|
2975
3089
|
isEditor
|
|
2976
3090
|
}) {
|
|
2977
|
-
const anchor = new
|
|
3091
|
+
const anchor = new THREE27__namespace.Object3D();
|
|
2978
3092
|
const path = payload.path ?? "";
|
|
2979
3093
|
const options = normalizeOptions(payload.options);
|
|
2980
3094
|
const entityId = createBaseEntity(world, anchor, {
|
|
@@ -2989,8 +3103,8 @@ function createVideo({
|
|
|
2989
3103
|
return entityId;
|
|
2990
3104
|
}
|
|
2991
3105
|
const video = createVideoElement(path, options);
|
|
2992
|
-
const texture = new
|
|
2993
|
-
texture.colorSpace =
|
|
3106
|
+
const texture = new THREE27__namespace.VideoTexture(video);
|
|
3107
|
+
texture.colorSpace = THREE27__namespace.SRGBColorSpace;
|
|
2994
3108
|
texture.needsUpdate = true;
|
|
2995
3109
|
const { mesh, material } = createVideoMesh(entityId, texture, options);
|
|
2996
3110
|
anchor.add(mesh);
|
|
@@ -3006,7 +3120,7 @@ function createVideo({
|
|
|
3006
3120
|
});
|
|
3007
3121
|
if (!isEditor && options.positional) {
|
|
3008
3122
|
const listener = getOrCreateListener2(camera);
|
|
3009
|
-
const audioNode = new
|
|
3123
|
+
const audioNode = new THREE27__namespace.PositionalAudio(listener);
|
|
3010
3124
|
audioNode.setVolume(options.volume);
|
|
3011
3125
|
audioNode.setRefDistance(options.refDistance);
|
|
3012
3126
|
audioNode.setDistanceModel(normalizeDistanceModel2(options.distanceModel));
|
|
@@ -3034,6 +3148,7 @@ function registerDefaultFactories(objectManagementSystem) {
|
|
|
3034
3148
|
objectManagementSystem.register("model", createModel);
|
|
3035
3149
|
objectManagementSystem.register("image", createImage);
|
|
3036
3150
|
objectManagementSystem.register("imageTarget", createImageTarget);
|
|
3151
|
+
objectManagementSystem.register("instancedMesh", createInstancedMesh);
|
|
3037
3152
|
objectManagementSystem.register("sprite", createSprite);
|
|
3038
3153
|
objectManagementSystem.register("audio", createAudio);
|
|
3039
3154
|
objectManagementSystem.register("camera", createCamera);
|
|
@@ -3055,6 +3170,7 @@ exports.createEnvironmentComponent = createEnvironmentComponent;
|
|
|
3055
3170
|
exports.createImageComponent = createImageComponent;
|
|
3056
3171
|
exports.createImageTargetAnchorComponent = createImageTargetAnchorComponent;
|
|
3057
3172
|
exports.createImageTargetComponent = createImageTargetComponent;
|
|
3173
|
+
exports.createInstancedMeshComponent = createInstancedMeshComponent;
|
|
3058
3174
|
exports.createLightComponent = createLightComponent;
|
|
3059
3175
|
exports.createMaterialComponent = createMaterialComponent;
|
|
3060
3176
|
exports.createMeshComponent = createMeshComponent;
|