@relu-interactives/spatial-ecs 0.2.4 → 0.2.5
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-D2H5H-K3.d.cts → Video-ChVFs9Tl.d.cts} +139 -75
- package/dist/{Video-BWhbvVPg.d.ts → Video-DCMCLInA.d.ts} +139 -75
- package/dist/{chunk-XWIEEJ7Z.js → chunk-4A66FSFT.js} +128 -82
- package/dist/chunk-4A66FSFT.js.map +1 -0
- package/dist/{chunk-AYEF3X2P.js → chunk-CRP3W2GK.js} +3 -3
- package/dist/chunk-CRP3W2GK.js.map +1 -0
- package/dist/{chunk-MAWBTMCG.js → chunk-KRZLEPRI.js} +156 -88
- package/dist/chunk-KRZLEPRI.js.map +1 -0
- package/dist/{chunk-NFDTIYR4.js → chunk-NB6I5JJN.js} +17 -2
- package/dist/chunk-NB6I5JJN.js.map +1 -0
- package/dist/{chunk-P2YDX5DB.js → chunk-RXCUHGRB.js} +124 -5
- package/dist/chunk-RXCUHGRB.js.map +1 -0
- package/dist/components/index.cjs +161 -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 +217 -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-D1I5L7bA.d.cts} +8 -3
- package/dist/{index-Dm6zF1MY.d.ts → index-DGZDgt3p.d.ts} +8 -3
- package/dist/index.cjs +468 -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 +51 -12
- package/dist/index.js.map +1 -1
- package/dist/systems/index.cjs +248 -63
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +15 -3
- package/dist/systems/index.d.ts +15 -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 +15 -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,79 @@ 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
|
+
plane: DEFAULT_MESH_GEOMETRY_PARAMETERS.plane,
|
|
1932
|
+
sphere: DEFAULT_MESH_GEOMETRY_PARAMETERS.sphere
|
|
1933
|
+
};
|
|
1934
|
+
var _InstancedMeshComponent = class _InstancedMeshComponent extends Component {
|
|
1935
|
+
constructor(meshKind = "cube", meshParameters, options) {
|
|
1936
|
+
super();
|
|
1937
|
+
this.meshKind = meshKind;
|
|
1938
|
+
this.meshParameters = {
|
|
1939
|
+
...DEFAULT_INSTANCED_MESH_PARAMETERS[meshKind],
|
|
1940
|
+
...meshParameters ?? {}
|
|
1941
|
+
};
|
|
1942
|
+
this.castShadow = options?.castShadow ?? false;
|
|
1943
|
+
this.receiveShadow = options?.receiveShadow ?? false;
|
|
1944
|
+
this.instances = options?.instances && options.instances.length > 0 ? options.instances : [{ ...DEFAULT_INSTANCE_TRANSFORM }];
|
|
1945
|
+
this.instancedMesh = null;
|
|
1946
|
+
}
|
|
1947
|
+
/** Sanitize and return a copy of the current mesh parameters with valid values. */
|
|
1948
|
+
getSanitizedParameters() {
|
|
1949
|
+
const MIN_DIM = 0.01;
|
|
1950
|
+
const MIN_RAD = 1e-3;
|
|
1951
|
+
const sanitize = /* @__PURE__ */ __name((v, min) => Number.isFinite(v) ? Math.max(min, v) : min, "sanitize");
|
|
1952
|
+
switch (this.meshKind) {
|
|
1953
|
+
case "cube": {
|
|
1954
|
+
const p = this.meshParameters;
|
|
1955
|
+
return {
|
|
1956
|
+
width: sanitize(p.width, MIN_DIM),
|
|
1957
|
+
height: sanitize(p.height, MIN_DIM),
|
|
1958
|
+
depth: sanitize(p.depth, MIN_DIM)
|
|
1959
|
+
};
|
|
1960
|
+
}
|
|
1961
|
+
case "plane": {
|
|
1962
|
+
const p = this.meshParameters;
|
|
1963
|
+
return {
|
|
1964
|
+
width: sanitize(p.width, MIN_DIM),
|
|
1965
|
+
height: sanitize(p.height, MIN_DIM)
|
|
1966
|
+
};
|
|
1967
|
+
}
|
|
1968
|
+
case "sphere": {
|
|
1969
|
+
const p = this.meshParameters;
|
|
1970
|
+
return { radius: sanitize(p.radius, MIN_RAD) };
|
|
1971
|
+
}
|
|
1972
|
+
case "cylinder":
|
|
1973
|
+
case "capsule": {
|
|
1974
|
+
const p = this.meshParameters;
|
|
1975
|
+
return {
|
|
1976
|
+
radius: sanitize(p.radius, MIN_RAD),
|
|
1977
|
+
height: sanitize(p.height, MIN_DIM)
|
|
1978
|
+
};
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
};
|
|
1983
|
+
__name(_InstancedMeshComponent, "InstancedMeshComponent");
|
|
1984
|
+
var InstancedMeshComponent = _InstancedMeshComponent;
|
|
1985
|
+
|
|
1986
|
+
// core/factories/components/InstancedMeshComponentFactory.ts
|
|
1987
|
+
function createInstancedMeshComponent(world, entityId, meshKind, meshParameters, options) {
|
|
1988
|
+
const component = new InstancedMeshComponent(meshKind, meshParameters, options);
|
|
1989
|
+
world.addComponent(entityId, component);
|
|
1990
|
+
return component;
|
|
1991
|
+
}
|
|
1992
|
+
__name(createInstancedMeshComponent, "createInstancedMeshComponent");
|
|
1993
|
+
|
|
1921
1994
|
// core/components/Video.ts
|
|
1922
1995
|
var DEFAULT_VIDEO_OPTIONS = {
|
|
1923
1996
|
autoplay: false,
|
|
@@ -2044,6 +2117,7 @@ function registerDefaultComponentFactories(objectManagementSystem) {
|
|
|
2044
2117
|
objectManagementSystem.registerComponentFactory("sprite", createSpriteComponent);
|
|
2045
2118
|
objectManagementSystem.registerComponentFactory("transform", createTransformComponent);
|
|
2046
2119
|
objectManagementSystem.registerComponentFactory("video", createVideoComponent);
|
|
2120
|
+
objectManagementSystem.registerComponentFactory("instancedMesh", createInstancedMeshComponent);
|
|
2047
2121
|
}
|
|
2048
2122
|
__name(registerDefaultComponentFactories, "registerDefaultComponentFactories");
|
|
2049
2123
|
function createTransform(input) {
|
|
@@ -2084,10 +2158,10 @@ __name(createBaseEntity, "createBaseEntity");
|
|
|
2084
2158
|
// core/factories/objects/AudioFactory.ts
|
|
2085
2159
|
function getOrCreateListener(camera) {
|
|
2086
2160
|
const existing = camera.userData.ecsAudioListener;
|
|
2087
|
-
if (existing instanceof
|
|
2161
|
+
if (existing instanceof THREE27__namespace.AudioListener) {
|
|
2088
2162
|
return existing;
|
|
2089
2163
|
}
|
|
2090
|
-
const listener = new
|
|
2164
|
+
const listener = new THREE27__namespace.AudioListener();
|
|
2091
2165
|
camera.add(listener);
|
|
2092
2166
|
camera.userData.ecsAudioListener = listener;
|
|
2093
2167
|
return listener;
|
|
@@ -2100,7 +2174,7 @@ function createAudio({
|
|
|
2100
2174
|
payload,
|
|
2101
2175
|
isEditor
|
|
2102
2176
|
}) {
|
|
2103
|
-
const anchor = new
|
|
2177
|
+
const anchor = new THREE27__namespace.Object3D();
|
|
2104
2178
|
const entityId = createBaseEntity(world, anchor, {
|
|
2105
2179
|
label: payload.name ?? "Audio",
|
|
2106
2180
|
entityType: "audio",
|
|
@@ -2122,7 +2196,7 @@ function createAudio({
|
|
|
2122
2196
|
return entityId;
|
|
2123
2197
|
}
|
|
2124
2198
|
if (!isEditor) {
|
|
2125
|
-
const loader = new
|
|
2199
|
+
const loader = new THREE27__namespace.AudioLoader();
|
|
2126
2200
|
loader.load(
|
|
2127
2201
|
audio.path,
|
|
2128
2202
|
(buffer) => {
|
|
@@ -2197,7 +2271,7 @@ function applyCameraSettings(camera, options) {
|
|
|
2197
2271
|
const near = typeof options.near === "number" ? options.near : DEFAULT_NEAR2;
|
|
2198
2272
|
const far = typeof options.far === "number" ? options.far : DEFAULT_FAR2;
|
|
2199
2273
|
const projection = options.projection;
|
|
2200
|
-
if (camera instanceof
|
|
2274
|
+
if (camera instanceof THREE27__namespace.PerspectiveCamera) {
|
|
2201
2275
|
if (!projection || projection === "perspective") {
|
|
2202
2276
|
camera.fov = typeof options.fov === "number" ? options.fov : DEFAULT_FOV2;
|
|
2203
2277
|
}
|
|
@@ -2207,7 +2281,7 @@ function applyCameraSettings(camera, options) {
|
|
|
2207
2281
|
camera.updateProjectionMatrix();
|
|
2208
2282
|
return;
|
|
2209
2283
|
}
|
|
2210
|
-
if (camera instanceof
|
|
2284
|
+
if (camera instanceof THREE27__namespace.OrthographicCamera) {
|
|
2211
2285
|
camera.left = typeof options.left === "number" ? options.left : -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2212
2286
|
camera.right = typeof options.right === "number" ? options.right : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2213
2287
|
camera.top = typeof options.top === "number" ? options.top : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
@@ -2228,7 +2302,7 @@ function createCameraObject(options) {
|
|
|
2228
2302
|
const bottom = options.bottom ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2229
2303
|
const left = options.left ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2230
2304
|
const right = options.right ?? DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
|
|
2231
|
-
const camera = new
|
|
2305
|
+
const camera = new THREE27__namespace.OrthographicCamera(
|
|
2232
2306
|
left,
|
|
2233
2307
|
right,
|
|
2234
2308
|
top,
|
|
@@ -2240,7 +2314,7 @@ function createCameraObject(options) {
|
|
|
2240
2314
|
camera.updateProjectionMatrix();
|
|
2241
2315
|
return camera;
|
|
2242
2316
|
}
|
|
2243
|
-
return new
|
|
2317
|
+
return new THREE27__namespace.PerspectiveCamera(
|
|
2244
2318
|
options.fov ?? DEFAULT_FOV2,
|
|
2245
2319
|
readViewportAspect(),
|
|
2246
2320
|
near,
|
|
@@ -2258,7 +2332,7 @@ function createCamera({ world, scene, camera, payload, isEditor }) {
|
|
|
2258
2332
|
transformInput: payload.transform
|
|
2259
2333
|
});
|
|
2260
2334
|
const objectRef = world.getComponent(entityId, Object3DRef);
|
|
2261
|
-
if (objectRef?.object instanceof
|
|
2335
|
+
if (objectRef?.object instanceof THREE27__namespace.Camera) {
|
|
2262
2336
|
objectRef.object.userData.entityId = entityId;
|
|
2263
2337
|
}
|
|
2264
2338
|
const componentOptions = {
|
|
@@ -2281,7 +2355,7 @@ function createCamera({ world, scene, camera, payload, isEditor }) {
|
|
|
2281
2355
|
} else {
|
|
2282
2356
|
applyCameraSettings(object, options);
|
|
2283
2357
|
if (isEditor && component.isDefault) {
|
|
2284
|
-
const helper = new
|
|
2358
|
+
const helper = new THREE27__namespace.CameraHelper(object);
|
|
2285
2359
|
helper.onBeforeRender = () => {
|
|
2286
2360
|
helper.update();
|
|
2287
2361
|
};
|
|
@@ -2299,9 +2373,9 @@ function createCapsule({
|
|
|
2299
2373
|
scene,
|
|
2300
2374
|
payload
|
|
2301
2375
|
}) {
|
|
2302
|
-
const geometry = new
|
|
2303
|
-
const material = new
|
|
2304
|
-
const mesh = new
|
|
2376
|
+
const geometry = new THREE27__namespace.CapsuleGeometry(0.5, 1, 4, 8);
|
|
2377
|
+
const material = new THREE27__namespace.MeshStandardMaterial({ color: "#ffffff" });
|
|
2378
|
+
const mesh = new THREE27__namespace.Mesh(geometry, material);
|
|
2305
2379
|
const entityId = createBaseEntity(world, mesh, {
|
|
2306
2380
|
label: payload.name ?? "Capsule",
|
|
2307
2381
|
entityType: "capsule",
|
|
@@ -2321,9 +2395,9 @@ function createCapsule({
|
|
|
2321
2395
|
}
|
|
2322
2396
|
__name(createCapsule, "createCapsule");
|
|
2323
2397
|
function createCube({ world, scene, payload }) {
|
|
2324
|
-
const geometry = new
|
|
2325
|
-
const material = new
|
|
2326
|
-
const mesh = new
|
|
2398
|
+
const geometry = new THREE27__namespace.BoxGeometry(1, 1, 1);
|
|
2399
|
+
const material = new THREE27__namespace.MeshStandardMaterial({ color: "#ffffff" });
|
|
2400
|
+
const mesh = new THREE27__namespace.Mesh(geometry, material);
|
|
2327
2401
|
const entityId = createBaseEntity(world, mesh, {
|
|
2328
2402
|
label: payload.name ?? "Cube",
|
|
2329
2403
|
entityType: "cube",
|
|
@@ -2348,9 +2422,9 @@ function createCylinder({
|
|
|
2348
2422
|
scene,
|
|
2349
2423
|
payload
|
|
2350
2424
|
}) {
|
|
2351
|
-
const geometry = new
|
|
2352
|
-
const material = new
|
|
2353
|
-
const mesh = new
|
|
2425
|
+
const geometry = new THREE27__namespace.CylinderGeometry(0.5, 0.5, 1, 20);
|
|
2426
|
+
const material = new THREE27__namespace.MeshStandardMaterial({ color: "#ffffff" });
|
|
2427
|
+
const mesh = new THREE27__namespace.Mesh(geometry, material);
|
|
2354
2428
|
const entityId = createBaseEntity(world, mesh, {
|
|
2355
2429
|
label: payload.name ?? "Cylinder",
|
|
2356
2430
|
entityType: "cylinder",
|
|
@@ -2370,7 +2444,7 @@ function createCylinder({
|
|
|
2370
2444
|
}
|
|
2371
2445
|
__name(createCylinder, "createCylinder");
|
|
2372
2446
|
function createEmpty({ world, scene, payload, isEditor }) {
|
|
2373
|
-
const object = new
|
|
2447
|
+
const object = new THREE27__namespace.Group();
|
|
2374
2448
|
const entityId = createBaseEntity(world, object, {
|
|
2375
2449
|
label: payload.name ?? "Empty",
|
|
2376
2450
|
entityType: "empty",
|
|
@@ -2381,7 +2455,7 @@ function createEmpty({ world, scene, payload, isEditor }) {
|
|
|
2381
2455
|
}
|
|
2382
2456
|
__name(createEmpty, "createEmpty");
|
|
2383
2457
|
function createImage({ world, scene, payload }) {
|
|
2384
|
-
const anchor = new
|
|
2458
|
+
const anchor = new THREE27__namespace.Object3D();
|
|
2385
2459
|
const imagePath = payload.path ?? "";
|
|
2386
2460
|
const entityId = createBaseEntity(world, anchor, {
|
|
2387
2461
|
label: payload.name ?? "Image",
|
|
@@ -2394,7 +2468,7 @@ function createImage({ world, scene, payload }) {
|
|
|
2394
2468
|
if (!imagePath) {
|
|
2395
2469
|
return entityId;
|
|
2396
2470
|
}
|
|
2397
|
-
const loader = new
|
|
2471
|
+
const loader = new THREE27__namespace.TextureLoader();
|
|
2398
2472
|
loader.load(
|
|
2399
2473
|
imagePath,
|
|
2400
2474
|
(texture) => {
|
|
@@ -2402,13 +2476,13 @@ function createImage({ world, scene, payload }) {
|
|
|
2402
2476
|
texture.dispose();
|
|
2403
2477
|
return;
|
|
2404
2478
|
}
|
|
2405
|
-
const material = new
|
|
2479
|
+
const material = new THREE27__namespace.MeshBasicMaterial({
|
|
2406
2480
|
map: texture,
|
|
2407
2481
|
transparent: true,
|
|
2408
|
-
side:
|
|
2482
|
+
side: THREE27__namespace.DoubleSide
|
|
2409
2483
|
});
|
|
2410
|
-
const geometry = new
|
|
2411
|
-
const plane = new
|
|
2484
|
+
const geometry = new THREE27__namespace.PlaneGeometry(1, 1);
|
|
2485
|
+
const plane = new THREE27__namespace.Mesh(geometry, material);
|
|
2412
2486
|
plane.userData.entityId = entityId;
|
|
2413
2487
|
const textureImage = texture.image;
|
|
2414
2488
|
const width = textureImage?.width ?? 1;
|
|
@@ -2454,7 +2528,7 @@ function createImageTarget({
|
|
|
2454
2528
|
payload,
|
|
2455
2529
|
isEditor
|
|
2456
2530
|
}) {
|
|
2457
|
-
const anchor = new
|
|
2531
|
+
const anchor = new THREE27__namespace.Object3D();
|
|
2458
2532
|
const imagePath = payload.path ?? "";
|
|
2459
2533
|
const entityId = createBaseEntity(world, anchor, {
|
|
2460
2534
|
label: payload.name ?? "Image Target",
|
|
@@ -2471,7 +2545,7 @@ function createImageTarget({
|
|
|
2471
2545
|
if (!isEditor || !imagePath) {
|
|
2472
2546
|
return entityId;
|
|
2473
2547
|
}
|
|
2474
|
-
const loader = new
|
|
2548
|
+
const loader = new THREE27__namespace.TextureLoader();
|
|
2475
2549
|
loader.load(
|
|
2476
2550
|
imagePath,
|
|
2477
2551
|
(texture) => {
|
|
@@ -2479,13 +2553,13 @@ function createImageTarget({
|
|
|
2479
2553
|
texture.dispose();
|
|
2480
2554
|
return;
|
|
2481
2555
|
}
|
|
2482
|
-
const material = new
|
|
2556
|
+
const material = new THREE27__namespace.MeshBasicMaterial({
|
|
2483
2557
|
map: texture,
|
|
2484
2558
|
transparent: true,
|
|
2485
|
-
side:
|
|
2559
|
+
side: THREE27__namespace.DoubleSide
|
|
2486
2560
|
});
|
|
2487
|
-
const geometry = new
|
|
2488
|
-
const plane = new
|
|
2561
|
+
const geometry = new THREE27__namespace.PlaneGeometry(1, 1);
|
|
2562
|
+
const plane = new THREE27__namespace.Mesh(geometry, material);
|
|
2489
2563
|
plane.userData.entityId = entityId;
|
|
2490
2564
|
const textureImage = texture.image;
|
|
2491
2565
|
const width = textureImage?.width ?? 1;
|
|
@@ -2504,12 +2578,48 @@ function createImageTarget({
|
|
|
2504
2578
|
return entityId;
|
|
2505
2579
|
}
|
|
2506
2580
|
__name(createImageTarget, "createImageTarget");
|
|
2581
|
+
function isInstancedMeshKind(value) {
|
|
2582
|
+
return value === "cube" || value === "sphere" || value === "plane" || value === "cylinder" || value === "capsule";
|
|
2583
|
+
}
|
|
2584
|
+
__name(isInstancedMeshKind, "isInstancedMeshKind");
|
|
2585
|
+
function isInstanceTransformArray(value) {
|
|
2586
|
+
return Array.isArray(value);
|
|
2587
|
+
}
|
|
2588
|
+
__name(isInstanceTransformArray, "isInstanceTransformArray");
|
|
2589
|
+
function createInstancedMesh({
|
|
2590
|
+
world,
|
|
2591
|
+
scene,
|
|
2592
|
+
payload
|
|
2593
|
+
}) {
|
|
2594
|
+
const anchor = new THREE27__namespace.Object3D();
|
|
2595
|
+
const opts = payload.options ?? {};
|
|
2596
|
+
const meshKind = isInstancedMeshKind(opts.meshKind) ? opts.meshKind : "cube";
|
|
2597
|
+
const meshParameters = opts.meshParameters && typeof opts.meshParameters === "object" ? opts.meshParameters : void 0;
|
|
2598
|
+
const instances = isInstanceTransformArray(
|
|
2599
|
+
opts.instances
|
|
2600
|
+
) ? opts.instances : void 0;
|
|
2601
|
+
const castShadow = typeof opts.castShadow === "boolean" ? opts.castShadow : false;
|
|
2602
|
+
const receiveShadow = typeof opts.receiveShadow === "boolean" ? opts.receiveShadow : false;
|
|
2603
|
+
const entityId = createBaseEntity(world, anchor, {
|
|
2604
|
+
label: payload.name ?? "Instanced Mesh",
|
|
2605
|
+
entityType: "instancedMesh",
|
|
2606
|
+
transformInput: payload.transform
|
|
2607
|
+
});
|
|
2608
|
+
createInstancedMeshComponent(world, entityId, meshKind, meshParameters, {
|
|
2609
|
+
castShadow,
|
|
2610
|
+
receiveShadow,
|
|
2611
|
+
instances
|
|
2612
|
+
});
|
|
2613
|
+
scene.add(anchor);
|
|
2614
|
+
return entityId;
|
|
2615
|
+
}
|
|
2616
|
+
__name(createInstancedMesh, "createInstancedMesh");
|
|
2507
2617
|
function createAmbientLight({
|
|
2508
2618
|
world,
|
|
2509
2619
|
scene,
|
|
2510
2620
|
payload
|
|
2511
2621
|
}) {
|
|
2512
|
-
const light = new
|
|
2622
|
+
const light = new THREE27__namespace.AmbientLight("#ffffff", 0.6);
|
|
2513
2623
|
const entityId = createBaseEntity(world, light, {
|
|
2514
2624
|
label: payload.name ?? "Ambient Light",
|
|
2515
2625
|
entityType: "ambientLight",
|
|
@@ -2526,7 +2636,7 @@ function createAreaLight({
|
|
|
2526
2636
|
payload,
|
|
2527
2637
|
isEditor
|
|
2528
2638
|
}) {
|
|
2529
|
-
const light = new
|
|
2639
|
+
const light = new THREE27__namespace.RectAreaLight("#ffffff", 5, 4, 4);
|
|
2530
2640
|
light.lookAt(0, 0, 0);
|
|
2531
2641
|
const entityId = createBaseEntity(world, light, {
|
|
2532
2642
|
label: payload.name ?? "Area Light",
|
|
@@ -2555,7 +2665,7 @@ function createDirectionalLight({
|
|
|
2555
2665
|
payload,
|
|
2556
2666
|
isEditor
|
|
2557
2667
|
}) {
|
|
2558
|
-
const light = new
|
|
2668
|
+
const light = new THREE27__namespace.DirectionalLight("#ffffff", 1.5);
|
|
2559
2669
|
light.castShadow = true;
|
|
2560
2670
|
const entityId = createBaseEntity(world, light, {
|
|
2561
2671
|
label: payload.name ?? "Directional Light",
|
|
@@ -2566,7 +2676,7 @@ function createDirectionalLight({
|
|
|
2566
2676
|
});
|
|
2567
2677
|
createLightComponent(world, entityId, light);
|
|
2568
2678
|
if (isEditor) {
|
|
2569
|
-
const helper = new
|
|
2679
|
+
const helper = new THREE27__namespace.DirectionalLightHelper(light, 1.8, "#38bdf8");
|
|
2570
2680
|
helper.onBeforeRender = () => {
|
|
2571
2681
|
helper.update();
|
|
2572
2682
|
};
|
|
@@ -2584,7 +2694,7 @@ function createPointLight({
|
|
|
2584
2694
|
payload,
|
|
2585
2695
|
isEditor
|
|
2586
2696
|
}) {
|
|
2587
|
-
const light = new
|
|
2697
|
+
const light = new THREE27__namespace.PointLight("#ffffff", 1, 10);
|
|
2588
2698
|
const entityId = createBaseEntity(world, light, {
|
|
2589
2699
|
label: payload.name ?? "Point Light",
|
|
2590
2700
|
entityType: "pointLight",
|
|
@@ -2594,7 +2704,7 @@ function createPointLight({
|
|
|
2594
2704
|
});
|
|
2595
2705
|
createLightComponent(world, entityId, light);
|
|
2596
2706
|
if (isEditor) {
|
|
2597
|
-
const helper = new
|
|
2707
|
+
const helper = new THREE27__namespace.PointLightHelper(light, 0.35, "#fbbf24");
|
|
2598
2708
|
helper.onBeforeRender = () => {
|
|
2599
2709
|
helper.update();
|
|
2600
2710
|
};
|
|
@@ -2612,7 +2722,7 @@ function createSpotLight({
|
|
|
2612
2722
|
payload,
|
|
2613
2723
|
isEditor
|
|
2614
2724
|
}) {
|
|
2615
|
-
const light = new
|
|
2725
|
+
const light = new THREE27__namespace.SpotLight("#ffffff", 1, 20, Math.PI / 6, 0.1, 1);
|
|
2616
2726
|
const entityId = createBaseEntity(world, light, {
|
|
2617
2727
|
label: payload.name ?? "Spot Light",
|
|
2618
2728
|
entityType: "spotLight",
|
|
@@ -2622,7 +2732,7 @@ function createSpotLight({
|
|
|
2622
2732
|
});
|
|
2623
2733
|
createLightComponent(world, entityId, light);
|
|
2624
2734
|
if (isEditor) {
|
|
2625
|
-
const helper = new
|
|
2735
|
+
const helper = new THREE27__namespace.SpotLightHelper(light, "#f59e0b");
|
|
2626
2736
|
helper.onBeforeRender = () => {
|
|
2627
2737
|
helper.update();
|
|
2628
2738
|
};
|
|
@@ -2678,7 +2788,7 @@ function createModelLoader() {
|
|
|
2678
2788
|
}
|
|
2679
2789
|
__name(createModelLoader, "createModelLoader");
|
|
2680
2790
|
function createModel({ world, scene, payload }) {
|
|
2681
|
-
const anchor = new
|
|
2791
|
+
const anchor = new THREE27__namespace.Object3D();
|
|
2682
2792
|
const modelPath = payload.path ?? "";
|
|
2683
2793
|
const entityId = createBaseEntity(world, anchor, {
|
|
2684
2794
|
label: payload.name ?? "Model",
|
|
@@ -2735,12 +2845,12 @@ function createModel({ world, scene, payload }) {
|
|
|
2735
2845
|
}
|
|
2736
2846
|
__name(createModel, "createModel");
|
|
2737
2847
|
function createPlane({ world, scene, payload }) {
|
|
2738
|
-
const geometry = new
|
|
2739
|
-
const material = new
|
|
2848
|
+
const geometry = new THREE27__namespace.PlaneGeometry(100, 100);
|
|
2849
|
+
const material = new THREE27__namespace.MeshStandardMaterial({
|
|
2740
2850
|
color: "#ffffff",
|
|
2741
|
-
side:
|
|
2851
|
+
side: THREE27__namespace.DoubleSide
|
|
2742
2852
|
});
|
|
2743
|
-
const mesh = new
|
|
2853
|
+
const mesh = new THREE27__namespace.Mesh(geometry, material);
|
|
2744
2854
|
const entityId = createBaseEntity(
|
|
2745
2855
|
world,
|
|
2746
2856
|
mesh,
|
|
@@ -2772,7 +2882,7 @@ function createPlane({ world, scene, payload }) {
|
|
|
2772
2882
|
}
|
|
2773
2883
|
__name(createPlane, "createPlane");
|
|
2774
2884
|
function createSprite({ world, scene, payload }) {
|
|
2775
|
-
const anchor = new
|
|
2885
|
+
const anchor = new THREE27__namespace.Object3D();
|
|
2776
2886
|
const imagePath = payload.path ?? "";
|
|
2777
2887
|
const entityId = createBaseEntity(world, anchor, {
|
|
2778
2888
|
label: payload.name ?? "Sprite",
|
|
@@ -2784,7 +2894,7 @@ function createSprite({ world, scene, payload }) {
|
|
|
2784
2894
|
if (!imagePath) {
|
|
2785
2895
|
return entityId;
|
|
2786
2896
|
}
|
|
2787
|
-
const loader = new
|
|
2897
|
+
const loader = new THREE27__namespace.TextureLoader();
|
|
2788
2898
|
loader.load(
|
|
2789
2899
|
imagePath,
|
|
2790
2900
|
(texture) => {
|
|
@@ -2792,11 +2902,11 @@ function createSprite({ world, scene, payload }) {
|
|
|
2792
2902
|
texture.dispose();
|
|
2793
2903
|
return;
|
|
2794
2904
|
}
|
|
2795
|
-
const material = new
|
|
2905
|
+
const material = new THREE27__namespace.SpriteMaterial({
|
|
2796
2906
|
map: texture,
|
|
2797
2907
|
transparent: true
|
|
2798
2908
|
});
|
|
2799
|
-
const sprite = new
|
|
2909
|
+
const sprite = new THREE27__namespace.Sprite(material);
|
|
2800
2910
|
sprite.userData.entityId = entityId;
|
|
2801
2911
|
const textureImage = texture.image;
|
|
2802
2912
|
spriteComponent.width = textureImage?.width ?? 1;
|
|
@@ -2814,9 +2924,9 @@ function createSprite({ world, scene, payload }) {
|
|
|
2814
2924
|
}
|
|
2815
2925
|
__name(createSprite, "createSprite");
|
|
2816
2926
|
function createSphere({ world, scene, payload }) {
|
|
2817
|
-
const geometry = new
|
|
2818
|
-
const material = new
|
|
2819
|
-
const mesh = new
|
|
2927
|
+
const geometry = new THREE27__namespace.SphereGeometry(0.5, 24, 24);
|
|
2928
|
+
const material = new THREE27__namespace.MeshStandardMaterial({ color: "#ffffff" });
|
|
2929
|
+
const mesh = new THREE27__namespace.Mesh(geometry, material);
|
|
2820
2930
|
const entityId = createBaseEntity(world, mesh, {
|
|
2821
2931
|
label: payload.name ?? "Sphere",
|
|
2822
2932
|
entityType: "sphere",
|
|
@@ -2836,10 +2946,10 @@ function createSphere({ world, scene, payload }) {
|
|
|
2836
2946
|
__name(createSphere, "createSphere");
|
|
2837
2947
|
function getOrCreateListener2(camera) {
|
|
2838
2948
|
const existing = camera.userData.ecsAudioListener;
|
|
2839
|
-
if (existing instanceof
|
|
2949
|
+
if (existing instanceof THREE27__namespace.AudioListener) {
|
|
2840
2950
|
return existing;
|
|
2841
2951
|
}
|
|
2842
|
-
const listener = new
|
|
2952
|
+
const listener = new THREE27__namespace.AudioListener();
|
|
2843
2953
|
camera.add(listener);
|
|
2844
2954
|
camera.userData.ecsAudioListener = listener;
|
|
2845
2955
|
return listener;
|
|
@@ -2889,10 +2999,10 @@ function normalizeOptions(input) {
|
|
|
2889
2999
|
}
|
|
2890
3000
|
__name(normalizeOptions, "normalizeOptions");
|
|
2891
3001
|
function createChromaMaterial(texture, options) {
|
|
2892
|
-
return new
|
|
3002
|
+
return new THREE27__namespace.ShaderMaterial({
|
|
2893
3003
|
uniforms: {
|
|
2894
3004
|
tex: { value: texture },
|
|
2895
|
-
keyColor: { value: new
|
|
3005
|
+
keyColor: { value: new THREE27__namespace.Color(options.backgroundColor) },
|
|
2896
3006
|
similarity: { value: options.similarity },
|
|
2897
3007
|
smoothness: { value: options.smoothness },
|
|
2898
3008
|
spill: { value: options.spill }
|
|
@@ -2924,22 +3034,22 @@ function createChromaMaterial(texture, options) {
|
|
|
2924
3034
|
}
|
|
2925
3035
|
`,
|
|
2926
3036
|
transparent: true,
|
|
2927
|
-
side:
|
|
3037
|
+
side: THREE27__namespace.DoubleSide
|
|
2928
3038
|
});
|
|
2929
3039
|
}
|
|
2930
3040
|
__name(createChromaMaterial, "createChromaMaterial");
|
|
2931
3041
|
function createStandardMaterial(texture) {
|
|
2932
|
-
return new
|
|
3042
|
+
return new THREE27__namespace.MeshBasicMaterial({
|
|
2933
3043
|
map: texture,
|
|
2934
3044
|
transparent: true,
|
|
2935
|
-
side:
|
|
3045
|
+
side: THREE27__namespace.DoubleSide
|
|
2936
3046
|
});
|
|
2937
3047
|
}
|
|
2938
3048
|
__name(createStandardMaterial, "createStandardMaterial");
|
|
2939
3049
|
function createVideoMesh(entityId, texture, options) {
|
|
2940
|
-
const geometry = new
|
|
3050
|
+
const geometry = new THREE27__namespace.PlaneGeometry(1, 1);
|
|
2941
3051
|
const material = options.isGreenScreen ? createChromaMaterial(texture, options) : createStandardMaterial(texture);
|
|
2942
|
-
const mesh = new
|
|
3052
|
+
const mesh = new THREE27__namespace.Mesh(geometry, material);
|
|
2943
3053
|
mesh.userData.entityId = entityId;
|
|
2944
3054
|
mesh.scale.set(options.width, options.height, 1);
|
|
2945
3055
|
return { mesh, material };
|
|
@@ -2974,7 +3084,7 @@ function createVideo({
|
|
|
2974
3084
|
payload,
|
|
2975
3085
|
isEditor
|
|
2976
3086
|
}) {
|
|
2977
|
-
const anchor = new
|
|
3087
|
+
const anchor = new THREE27__namespace.Object3D();
|
|
2978
3088
|
const path = payload.path ?? "";
|
|
2979
3089
|
const options = normalizeOptions(payload.options);
|
|
2980
3090
|
const entityId = createBaseEntity(world, anchor, {
|
|
@@ -2989,8 +3099,8 @@ function createVideo({
|
|
|
2989
3099
|
return entityId;
|
|
2990
3100
|
}
|
|
2991
3101
|
const video = createVideoElement(path, options);
|
|
2992
|
-
const texture = new
|
|
2993
|
-
texture.colorSpace =
|
|
3102
|
+
const texture = new THREE27__namespace.VideoTexture(video);
|
|
3103
|
+
texture.colorSpace = THREE27__namespace.SRGBColorSpace;
|
|
2994
3104
|
texture.needsUpdate = true;
|
|
2995
3105
|
const { mesh, material } = createVideoMesh(entityId, texture, options);
|
|
2996
3106
|
anchor.add(mesh);
|
|
@@ -3006,7 +3116,7 @@ function createVideo({
|
|
|
3006
3116
|
});
|
|
3007
3117
|
if (!isEditor && options.positional) {
|
|
3008
3118
|
const listener = getOrCreateListener2(camera);
|
|
3009
|
-
const audioNode = new
|
|
3119
|
+
const audioNode = new THREE27__namespace.PositionalAudio(listener);
|
|
3010
3120
|
audioNode.setVolume(options.volume);
|
|
3011
3121
|
audioNode.setRefDistance(options.refDistance);
|
|
3012
3122
|
audioNode.setDistanceModel(normalizeDistanceModel2(options.distanceModel));
|
|
@@ -3034,6 +3144,7 @@ function registerDefaultFactories(objectManagementSystem) {
|
|
|
3034
3144
|
objectManagementSystem.register("model", createModel);
|
|
3035
3145
|
objectManagementSystem.register("image", createImage);
|
|
3036
3146
|
objectManagementSystem.register("imageTarget", createImageTarget);
|
|
3147
|
+
objectManagementSystem.register("instancedMesh", createInstancedMesh);
|
|
3037
3148
|
objectManagementSystem.register("sprite", createSprite);
|
|
3038
3149
|
objectManagementSystem.register("audio", createAudio);
|
|
3039
3150
|
objectManagementSystem.register("camera", createCamera);
|
|
@@ -3055,6 +3166,7 @@ exports.createEnvironmentComponent = createEnvironmentComponent;
|
|
|
3055
3166
|
exports.createImageComponent = createImageComponent;
|
|
3056
3167
|
exports.createImageTargetAnchorComponent = createImageTargetAnchorComponent;
|
|
3057
3168
|
exports.createImageTargetComponent = createImageTargetComponent;
|
|
3169
|
+
exports.createInstancedMeshComponent = createInstancedMeshComponent;
|
|
3058
3170
|
exports.createLightComponent = createLightComponent;
|
|
3059
3171
|
exports.createMaterialComponent = createMaterialComponent;
|
|
3060
3172
|
exports.createMeshComponent = createMeshComponent;
|