@relu-interactives/spatial-ecs 0.2.5 → 0.2.7
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/{Video-DCMCLInA.d.ts → Video-B-qMljTn.d.ts} +15 -7
- package/dist/{Video-ChVFs9Tl.d.cts → Video-Dj4KBqQ1.d.cts} +15 -7
- package/dist/{chunk-RXCUHGRB.js → chunk-2F6T3BVO.js} +193 -33
- package/dist/chunk-2F6T3BVO.js.map +1 -0
- package/dist/{chunk-4A66FSFT.js → chunk-EIC5B3A7.js} +4 -4
- package/dist/{chunk-4A66FSFT.js.map → chunk-EIC5B3A7.js.map} +1 -1
- package/dist/{chunk-CRP3W2GK.js → chunk-FDWNCXU3.js} +3 -3
- package/dist/{chunk-CRP3W2GK.js.map → chunk-FDWNCXU3.js.map} +1 -1
- package/dist/{chunk-NB6I5JJN.js → chunk-G2DUXNTQ.js} +3 -2
- package/dist/chunk-G2DUXNTQ.js.map +1 -0
- package/dist/{chunk-KRZLEPRI.js → chunk-R5D5PWXV.js} +6 -2
- package/dist/chunk-R5D5PWXV.js.map +1 -0
- package/dist/components/index.cjs +4 -0
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/factories/index.cjs +4 -0
- package/dist/factories/index.cjs.map +1 -1
- package/dist/factories/index.d.cts +1 -1
- package/dist/factories/index.d.ts +1 -1
- package/dist/factories/index.js +3 -3
- package/dist/{index-D1I5L7bA.d.cts → index-B12sx9yF.d.cts} +1 -1
- package/dist/{index-DGZDgt3p.d.ts → index-Cf-PaKyN.d.ts} +1 -1
- package/dist/index.cjs +197 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +12 -9
- package/dist/index.js.map +1 -1
- package/dist/systems/index.cjs +193 -29
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +17 -4
- package/dist/systems/index.d.ts +17 -4
- package/dist/systems/index.js +3 -3
- package/dist/worldSnapshotUtils.cjs +1 -0
- package/dist/worldSnapshotUtils.cjs.map +1 -1
- package/dist/worldSnapshotUtils.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-KRZLEPRI.js.map +0 -1
- package/dist/chunk-NB6I5JJN.js.map +0 -1
- package/dist/chunk-RXCUHGRB.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AnimationComponent, b as AudioComponent, c as CameraComponentOptions, C as CameraComponent, a0 as RigidbodyState, g as ColliderState, V as PhysicsComponent, w as EnvironmentState, q as Environment, p as EntityType, I as ImageComponent, y as ImageTargetAnchor, x as ImageTarget, L as LightComponent, M as MaterialComponent, O as MeshComponent, P as MeshGeometryComponent, S as ModelComponent, T as Name, U as Object3DRef, Z as PostprocessingState, Y as Postprocessing, a3 as ScriptEntry, a2 as ScriptComponent, a4 as Selectable, a5 as SelectionTransformState, a6 as SpriteComponent, H as InstancedMeshKind, Q as MeshGeometryParameters, F as InstanceTransform, G as InstancedMeshComponent, aa as VideoComponent } from '../Video-
|
|
1
|
+
import { A as AnimationComponent, b as AudioComponent, c as CameraComponentOptions, C as CameraComponent, a0 as RigidbodyState, g as ColliderState, V as PhysicsComponent, w as EnvironmentState, q as Environment, p as EntityType, I as ImageComponent, y as ImageTargetAnchor, x as ImageTarget, L as LightComponent, M as MaterialComponent, O as MeshComponent, P as MeshGeometryComponent, S as ModelComponent, T as Name, U as Object3DRef, Z as PostprocessingState, Y as Postprocessing, a3 as ScriptEntry, a2 as ScriptComponent, a4 as Selectable, a5 as SelectionTransformState, a6 as SpriteComponent, H as InstancedMeshKind, Q as MeshGeometryParameters, F as InstanceTransform, G as InstancedMeshComponent, aa as VideoComponent } from '../Video-Dj4KBqQ1.cjs';
|
|
2
2
|
import { b as World, P as ParentId, T as TransformComponent, O as ObjectManagementSystem } from '../System-CIiWteft.cjs';
|
|
3
3
|
import * as THREE from 'three';
|
|
4
4
|
import '@dimforge/rapier3d-compat';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AnimationComponent, b as AudioComponent, c as CameraComponentOptions, C as CameraComponent, a0 as RigidbodyState, g as ColliderState, V as PhysicsComponent, w as EnvironmentState, q as Environment, p as EntityType, I as ImageComponent, y as ImageTargetAnchor, x as ImageTarget, L as LightComponent, M as MaterialComponent, O as MeshComponent, P as MeshGeometryComponent, S as ModelComponent, T as Name, U as Object3DRef, Z as PostprocessingState, Y as Postprocessing, a3 as ScriptEntry, a2 as ScriptComponent, a4 as Selectable, a5 as SelectionTransformState, a6 as SpriteComponent, H as InstancedMeshKind, Q as MeshGeometryParameters, F as InstanceTransform, G as InstancedMeshComponent, aa as VideoComponent } from '../Video-
|
|
1
|
+
import { A as AnimationComponent, b as AudioComponent, c as CameraComponentOptions, C as CameraComponent, a0 as RigidbodyState, g as ColliderState, V as PhysicsComponent, w as EnvironmentState, q as Environment, p as EntityType, I as ImageComponent, y as ImageTargetAnchor, x as ImageTarget, L as LightComponent, M as MaterialComponent, O as MeshComponent, P as MeshGeometryComponent, S as ModelComponent, T as Name, U as Object3DRef, Z as PostprocessingState, Y as Postprocessing, a3 as ScriptEntry, a2 as ScriptComponent, a4 as Selectable, a5 as SelectionTransformState, a6 as SpriteComponent, H as InstancedMeshKind, Q as MeshGeometryParameters, F as InstanceTransform, G as InstancedMeshComponent, aa as VideoComponent } from '../Video-B-qMljTn.js';
|
|
2
2
|
import { b as World, P as ParentId, T as TransformComponent, O as ObjectManagementSystem } from '../System-CIiWteft.js';
|
|
3
3
|
import * as THREE from 'three';
|
|
4
4
|
import '@dimforge/rapier3d-compat';
|
package/dist/factories/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createInstancedMeshComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVideoComponent, registerDefaultComponentFactories, registerDefaultFactories } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createInstancedMeshComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVideoComponent, registerDefaultComponentFactories, registerDefaultFactories } from '../chunk-EIC5B3A7.js';
|
|
2
|
+
import '../chunk-FDWNCXU3.js';
|
|
3
|
+
import '../chunk-R5D5PWXV.js';
|
|
4
4
|
import '../chunk-OY7ZODZP.js';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AnimationComponent, a as AnimationComponentOptions, b as AudioComponent, C as CameraComponent, c as CameraComponentOptions, d as CameraProjection, e as CameraRuntimeType, f as ColliderShape, g as ColliderState, h as CubeMeshParameters, D as DEFAULT_COLLIDER_STATE, i as DEFAULT_ENVIRONMENT_STATE, j as DEFAULT_INSTANCED_MESH_PARAMETERS, k as DEFAULT_INSTANCE_TRANSFORM, l as DEFAULT_MESH_GEOMETRY_PARAMETERS, m as DEFAULT_PHYSICS_STATE, n as DEFAULT_POSTPROCESSING_STATE, o as DEFAULT_RIGIDBODY_STATE, E as EditableMeshObjectKind, p as EntityType, q as Environment, r as EnvironmentFogState, s as EnvironmentFogType, t as EnvironmentGradientEffect, u as EnvironmentSkyboxState, v as EnvironmentSkyboxType, w as EnvironmentState, I as ImageComponent, x as ImageTarget, y as ImageTargetAnchor, z as ImageTargetAnchorOptions, B as ImageTargetReference, F as InstanceTransform, G as InstancedMeshComponent, H as InstancedMeshKind, L as LightComponent, J as LightValueState, M as MaterialComponent, K as MaterialTypeValue, N as MaterialValueState, O as MeshComponent, P as MeshGeometryComponent, Q as MeshGeometryParameters, R as MeshGeometryParametersByKind, S as ModelComponent, T as Name, U as Object3DRef, V as PhysicsComponent, W as PhysicsState, X as PlaneMeshParameters, Y as Postprocessing, Z as PostprocessingState, _ as RadiusHeightMeshParameters, $ as RadiusMeshParameters, a0 as RigidbodyState, a1 as RigidbodyType, a2 as ScriptComponent, a3 as ScriptEntry, a4 as Selectable, a5 as SelectionTransformState, a6 as SpriteComponent, a7 as TextureFilteringValue, a8 as TransformModeValue, a9 as TransformSpaceValue, aa as VideoComponent, ab as normalizePhysicsState } from './Video-
|
|
1
|
+
import { A as AnimationComponent, a as AnimationComponentOptions, b as AudioComponent, C as CameraComponent, c as CameraComponentOptions, d as CameraProjection, e as CameraRuntimeType, f as ColliderShape, g as ColliderState, h as CubeMeshParameters, D as DEFAULT_COLLIDER_STATE, i as DEFAULT_ENVIRONMENT_STATE, j as DEFAULT_INSTANCED_MESH_PARAMETERS, k as DEFAULT_INSTANCE_TRANSFORM, l as DEFAULT_MESH_GEOMETRY_PARAMETERS, m as DEFAULT_PHYSICS_STATE, n as DEFAULT_POSTPROCESSING_STATE, o as DEFAULT_RIGIDBODY_STATE, E as EditableMeshObjectKind, p as EntityType, q as Environment, r as EnvironmentFogState, s as EnvironmentFogType, t as EnvironmentGradientEffect, u as EnvironmentSkyboxState, v as EnvironmentSkyboxType, w as EnvironmentState, I as ImageComponent, x as ImageTarget, y as ImageTargetAnchor, z as ImageTargetAnchorOptions, B as ImageTargetReference, F as InstanceTransform, G as InstancedMeshComponent, H as InstancedMeshKind, L as LightComponent, J as LightValueState, M as MaterialComponent, K as MaterialTypeValue, N as MaterialValueState, O as MeshComponent, P as MeshGeometryComponent, Q as MeshGeometryParameters, R as MeshGeometryParametersByKind, S as ModelComponent, T as Name, U as Object3DRef, V as PhysicsComponent, W as PhysicsState, X as PlaneMeshParameters, Y as Postprocessing, Z as PostprocessingState, _ as RadiusHeightMeshParameters, $ as RadiusMeshParameters, a0 as RigidbodyState, a1 as RigidbodyType, a2 as ScriptComponent, a3 as ScriptEntry, a4 as Selectable, a5 as SelectionTransformState, a6 as SpriteComponent, a7 as TextureFilteringValue, a8 as TransformModeValue, a9 as TransformSpaceValue, aa as VideoComponent, ab as normalizePhysicsState } from './Video-Dj4KBqQ1.cjs';
|
|
2
2
|
import { P as ParentId, T as TransformComponent, a as TransformData, V as Vec3 } from './System-CIiWteft.cjs';
|
|
3
3
|
|
|
4
4
|
declare const index_AnimationComponent: typeof AnimationComponent;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AnimationComponent, a as AnimationComponentOptions, b as AudioComponent, C as CameraComponent, c as CameraComponentOptions, d as CameraProjection, e as CameraRuntimeType, f as ColliderShape, g as ColliderState, h as CubeMeshParameters, D as DEFAULT_COLLIDER_STATE, i as DEFAULT_ENVIRONMENT_STATE, j as DEFAULT_INSTANCED_MESH_PARAMETERS, k as DEFAULT_INSTANCE_TRANSFORM, l as DEFAULT_MESH_GEOMETRY_PARAMETERS, m as DEFAULT_PHYSICS_STATE, n as DEFAULT_POSTPROCESSING_STATE, o as DEFAULT_RIGIDBODY_STATE, E as EditableMeshObjectKind, p as EntityType, q as Environment, r as EnvironmentFogState, s as EnvironmentFogType, t as EnvironmentGradientEffect, u as EnvironmentSkyboxState, v as EnvironmentSkyboxType, w as EnvironmentState, I as ImageComponent, x as ImageTarget, y as ImageTargetAnchor, z as ImageTargetAnchorOptions, B as ImageTargetReference, F as InstanceTransform, G as InstancedMeshComponent, H as InstancedMeshKind, L as LightComponent, J as LightValueState, M as MaterialComponent, K as MaterialTypeValue, N as MaterialValueState, O as MeshComponent, P as MeshGeometryComponent, Q as MeshGeometryParameters, R as MeshGeometryParametersByKind, S as ModelComponent, T as Name, U as Object3DRef, V as PhysicsComponent, W as PhysicsState, X as PlaneMeshParameters, Y as Postprocessing, Z as PostprocessingState, _ as RadiusHeightMeshParameters, $ as RadiusMeshParameters, a0 as RigidbodyState, a1 as RigidbodyType, a2 as ScriptComponent, a3 as ScriptEntry, a4 as Selectable, a5 as SelectionTransformState, a6 as SpriteComponent, a7 as TextureFilteringValue, a8 as TransformModeValue, a9 as TransformSpaceValue, aa as VideoComponent, ab as normalizePhysicsState } from './Video-
|
|
1
|
+
import { A as AnimationComponent, a as AnimationComponentOptions, b as AudioComponent, C as CameraComponent, c as CameraComponentOptions, d as CameraProjection, e as CameraRuntimeType, f as ColliderShape, g as ColliderState, h as CubeMeshParameters, D as DEFAULT_COLLIDER_STATE, i as DEFAULT_ENVIRONMENT_STATE, j as DEFAULT_INSTANCED_MESH_PARAMETERS, k as DEFAULT_INSTANCE_TRANSFORM, l as DEFAULT_MESH_GEOMETRY_PARAMETERS, m as DEFAULT_PHYSICS_STATE, n as DEFAULT_POSTPROCESSING_STATE, o as DEFAULT_RIGIDBODY_STATE, E as EditableMeshObjectKind, p as EntityType, q as Environment, r as EnvironmentFogState, s as EnvironmentFogType, t as EnvironmentGradientEffect, u as EnvironmentSkyboxState, v as EnvironmentSkyboxType, w as EnvironmentState, I as ImageComponent, x as ImageTarget, y as ImageTargetAnchor, z as ImageTargetAnchorOptions, B as ImageTargetReference, F as InstanceTransform, G as InstancedMeshComponent, H as InstancedMeshKind, L as LightComponent, J as LightValueState, M as MaterialComponent, K as MaterialTypeValue, N as MaterialValueState, O as MeshComponent, P as MeshGeometryComponent, Q as MeshGeometryParameters, R as MeshGeometryParametersByKind, S as ModelComponent, T as Name, U as Object3DRef, V as PhysicsComponent, W as PhysicsState, X as PlaneMeshParameters, Y as Postprocessing, Z as PostprocessingState, _ as RadiusHeightMeshParameters, $ as RadiusMeshParameters, a0 as RigidbodyState, a1 as RigidbodyType, a2 as ScriptComponent, a3 as ScriptEntry, a4 as Selectable, a5 as SelectionTransformState, a6 as SpriteComponent, a7 as TextureFilteringValue, a8 as TransformModeValue, a9 as TransformSpaceValue, aa as VideoComponent, ab as normalizePhysicsState } from './Video-B-qMljTn.js';
|
|
2
2
|
import { P as ParentId, T as TransformComponent, a as TransformData, V as Vec3 } from './System-CIiWteft.js';
|
|
3
3
|
|
|
4
4
|
declare const index_AnimationComponent: typeof AnimationComponent;
|
package/dist/index.cjs
CHANGED
|
@@ -159,6 +159,7 @@ function normalizeDebugValue(value, ctx) {
|
|
|
159
159
|
return {
|
|
160
160
|
__type: "InstancedMeshComponent",
|
|
161
161
|
meshKind: typeof objectValue.meshKind === "string" ? objectValue.meshKind : "cube",
|
|
162
|
+
modelPath: typeof objectValue.modelPath === "string" ? objectValue.modelPath : "",
|
|
162
163
|
meshParameters: normalizeDebugValue(objectValue.meshParameters, imCtx),
|
|
163
164
|
castShadow: Boolean(objectValue.castShadow),
|
|
164
165
|
receiveShadow: Boolean(objectValue.receiveShadow),
|
|
@@ -2222,6 +2223,7 @@ var DEFAULT_INSTANCED_MESH_PARAMETERS = {
|
|
|
2222
2223
|
capsule: DEFAULT_MESH_GEOMETRY_PARAMETERS.capsule,
|
|
2223
2224
|
cube: DEFAULT_MESH_GEOMETRY_PARAMETERS.cube,
|
|
2224
2225
|
cylinder: DEFAULT_MESH_GEOMETRY_PARAMETERS.cylinder,
|
|
2226
|
+
model: DEFAULT_MESH_GEOMETRY_PARAMETERS.cube,
|
|
2225
2227
|
plane: DEFAULT_MESH_GEOMETRY_PARAMETERS.plane,
|
|
2226
2228
|
sphere: DEFAULT_MESH_GEOMETRY_PARAMETERS.sphere
|
|
2227
2229
|
};
|
|
@@ -2229,6 +2231,7 @@ var _InstancedMeshComponent = class _InstancedMeshComponent extends Component {
|
|
|
2229
2231
|
constructor(meshKind = "cube", meshParameters, options) {
|
|
2230
2232
|
super();
|
|
2231
2233
|
this.meshKind = meshKind;
|
|
2234
|
+
this.modelPath = options?.modelPath ?? "";
|
|
2232
2235
|
this.meshParameters = {
|
|
2233
2236
|
...DEFAULT_INSTANCED_MESH_PARAMETERS[meshKind],
|
|
2234
2237
|
...meshParameters ?? {}
|
|
@@ -2271,6 +2274,8 @@ var _InstancedMeshComponent = class _InstancedMeshComponent extends Component {
|
|
|
2271
2274
|
height: sanitize(p.height, MIN_DIM)
|
|
2272
2275
|
};
|
|
2273
2276
|
}
|
|
2277
|
+
case "model":
|
|
2278
|
+
return DEFAULT_MESH_GEOMETRY_PARAMETERS.cube;
|
|
2274
2279
|
}
|
|
2275
2280
|
}
|
|
2276
2281
|
};
|
|
@@ -5914,6 +5919,32 @@ var _MeshGeometrySystem = class _MeshGeometrySystem {
|
|
|
5914
5919
|
};
|
|
5915
5920
|
__name(_MeshGeometrySystem, "MeshGeometrySystem");
|
|
5916
5921
|
var MeshGeometrySystem = _MeshGeometrySystem;
|
|
5922
|
+
var DRACO_DECODER_PATH = resolveDracoDecoderPath();
|
|
5923
|
+
var loadGLTF = /* @__PURE__ */ __name((path) => {
|
|
5924
|
+
return new Promise((resolve, reject) => {
|
|
5925
|
+
const loader = new GLTFLoader_js.GLTFLoader();
|
|
5926
|
+
try {
|
|
5927
|
+
const dracoLoader = new DRACOLoader_js.DRACOLoader();
|
|
5928
|
+
dracoLoader.setDecoderPath(DRACO_DECODER_PATH);
|
|
5929
|
+
loader.setDRACOLoader(dracoLoader);
|
|
5930
|
+
} catch (error) {
|
|
5931
|
+
console.debug("DRACOLoader setup failed or unavailable", error);
|
|
5932
|
+
}
|
|
5933
|
+
loader.load(
|
|
5934
|
+
path,
|
|
5935
|
+
(gltf) => {
|
|
5936
|
+
resolve(gltf);
|
|
5937
|
+
},
|
|
5938
|
+
void 0,
|
|
5939
|
+
(error) => {
|
|
5940
|
+
console.debug("GLTFLoader failed to load", error);
|
|
5941
|
+
reject(error);
|
|
5942
|
+
}
|
|
5943
|
+
);
|
|
5944
|
+
});
|
|
5945
|
+
}, "loadGLTF");
|
|
5946
|
+
|
|
5947
|
+
// core/systems/InstancedMeshSystem.ts
|
|
5917
5948
|
function buildGeometry(component) {
|
|
5918
5949
|
const p = component.getSanitizedParameters();
|
|
5919
5950
|
switch (component.meshKind) {
|
|
@@ -5937,6 +5968,8 @@ function buildGeometry(component) {
|
|
|
5937
5968
|
const params = p;
|
|
5938
5969
|
return new THREE34__namespace.CapsuleGeometry(params.radius, params.height, 4, 8);
|
|
5939
5970
|
}
|
|
5971
|
+
default:
|
|
5972
|
+
return new THREE34__namespace.BoxGeometry(1, 1, 1);
|
|
5940
5973
|
}
|
|
5941
5974
|
}
|
|
5942
5975
|
__name(buildGeometry, "buildGeometry");
|
|
@@ -5945,6 +5978,7 @@ var _quaternion = new THREE34__namespace.Quaternion();
|
|
|
5945
5978
|
var _euler = new THREE34__namespace.Euler();
|
|
5946
5979
|
var _scale = new THREE34__namespace.Vector3();
|
|
5947
5980
|
var _matrix = new THREE34__namespace.Matrix4();
|
|
5981
|
+
var _modelMatrix = new THREE34__namespace.Matrix4();
|
|
5948
5982
|
function instanceTransformToMatrix4(inst, out) {
|
|
5949
5983
|
_position.set(inst.position.x, inst.position.y, inst.position.z);
|
|
5950
5984
|
_euler.set(inst.rotation.x, inst.rotation.y, inst.rotation.z, "XYZ");
|
|
@@ -5953,51 +5987,165 @@ function instanceTransformToMatrix4(inst, out) {
|
|
|
5953
5987
|
out.compose(_position, _quaternion, _scale);
|
|
5954
5988
|
}
|
|
5955
5989
|
__name(instanceTransformToMatrix4, "instanceTransformToMatrix4");
|
|
5990
|
+
function disposePrimitiveInstancedMesh(mesh) {
|
|
5991
|
+
mesh.geometry.dispose();
|
|
5992
|
+
if (Array.isArray(mesh.material)) {
|
|
5993
|
+
for (const m of mesh.material) {
|
|
5994
|
+
m.dispose();
|
|
5995
|
+
}
|
|
5996
|
+
} else {
|
|
5997
|
+
mesh.material.dispose();
|
|
5998
|
+
}
|
|
5999
|
+
}
|
|
6000
|
+
__name(disposePrimitiveInstancedMesh, "disposePrimitiveInstancedMesh");
|
|
6001
|
+
function disposeModelGroup(group) {
|
|
6002
|
+
group.traverse((child) => {
|
|
6003
|
+
const im = child;
|
|
6004
|
+
if (im.isInstancedMesh) {
|
|
6005
|
+
im.geometry.dispose();
|
|
6006
|
+
if (Array.isArray(im.material)) {
|
|
6007
|
+
for (const m of im.material) {
|
|
6008
|
+
m.dispose();
|
|
6009
|
+
}
|
|
6010
|
+
} else {
|
|
6011
|
+
im.material.dispose();
|
|
6012
|
+
}
|
|
6013
|
+
}
|
|
6014
|
+
});
|
|
6015
|
+
}
|
|
6016
|
+
__name(disposeModelGroup, "disposeModelGroup");
|
|
5956
6017
|
var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
5957
6018
|
constructor() {
|
|
5958
6019
|
/** Signature tracking for geometry + instance count changes. */
|
|
5959
6020
|
this.geometrySignatures = /* @__PURE__ */ new Map();
|
|
6021
|
+
/** Signature being loaded per entity. Maps entityId → geometrySignature in-flight.
|
|
6022
|
+
* Prevents re-dispatching a load every frame while comp.instancedMesh is still null. */
|
|
6023
|
+
this.loadingSignatures = /* @__PURE__ */ new Map();
|
|
6024
|
+
/** Per-mesh data for model kind, populated after GLTF load. */
|
|
6025
|
+
this.modelMeshEntries = /* @__PURE__ */ new Map();
|
|
5960
6026
|
}
|
|
5961
6027
|
update(world) {
|
|
5962
6028
|
const entityIds = world.query(InstancedMeshComponent);
|
|
5963
6029
|
const alive = new Set(entityIds);
|
|
5964
6030
|
for (const trackedId of this.geometrySignatures.keys()) {
|
|
5965
|
-
if (!alive.has(trackedId))
|
|
5966
|
-
|
|
5967
|
-
|
|
6031
|
+
if (!alive.has(trackedId)) this.geometrySignatures.delete(trackedId);
|
|
6032
|
+
}
|
|
6033
|
+
for (const trackedId of this.loadingSignatures.keys()) {
|
|
6034
|
+
if (!alive.has(trackedId)) this.loadingSignatures.delete(trackedId);
|
|
6035
|
+
}
|
|
6036
|
+
for (const trackedId of this.modelMeshEntries.keys()) {
|
|
6037
|
+
if (!alive.has(trackedId)) this.modelMeshEntries.delete(trackedId);
|
|
5968
6038
|
}
|
|
5969
6039
|
for (const entityId of entityIds) {
|
|
5970
6040
|
const comp = world.getComponent(
|
|
5971
6041
|
entityId,
|
|
5972
6042
|
InstancedMeshComponent
|
|
5973
6043
|
);
|
|
5974
|
-
if (!comp)
|
|
5975
|
-
continue;
|
|
5976
|
-
}
|
|
5977
|
-
let anchor = null;
|
|
6044
|
+
if (!comp) continue;
|
|
5978
6045
|
const objectRef = world.getComponent(entityId, Object3DRef);
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
}
|
|
5982
|
-
if (!anchor) {
|
|
5983
|
-
continue;
|
|
5984
|
-
}
|
|
6046
|
+
const anchor = objectRef?.object ?? null;
|
|
6047
|
+
if (!anchor) continue;
|
|
5985
6048
|
const instanceCount = comp.instances.length;
|
|
5986
|
-
const geometrySignature = `${comp.meshKind}:${JSON.stringify(comp.meshParameters)}:${instanceCount}`;
|
|
5987
|
-
const
|
|
6049
|
+
const geometrySignature = comp.meshKind === "model" ? `model:${comp.modelPath}:${instanceCount}` : `${comp.meshKind}:${JSON.stringify(comp.meshParameters)}:${instanceCount}`;
|
|
6050
|
+
const pendingLoadSignature = this.loadingSignatures.get(entityId);
|
|
6051
|
+
const needsRebuild = (comp.instancedMesh === null || this.geometrySignatures.get(entityId) !== geometrySignature) && pendingLoadSignature !== geometrySignature;
|
|
5988
6052
|
if (needsRebuild) {
|
|
5989
6053
|
if (comp.instancedMesh) {
|
|
5990
6054
|
anchor.remove(comp.instancedMesh);
|
|
5991
|
-
comp.instancedMesh.
|
|
5992
|
-
|
|
5993
|
-
for (const m of comp.instancedMesh.material) {
|
|
5994
|
-
m.dispose();
|
|
5995
|
-
}
|
|
6055
|
+
if (comp.instancedMesh.isInstancedMesh) {
|
|
6056
|
+
disposePrimitiveInstancedMesh(comp.instancedMesh);
|
|
5996
6057
|
} else {
|
|
5997
|
-
comp.instancedMesh
|
|
6058
|
+
disposeModelGroup(comp.instancedMesh);
|
|
5998
6059
|
}
|
|
5999
6060
|
comp.instancedMesh = null;
|
|
6000
6061
|
}
|
|
6062
|
+
if (pendingLoadSignature !== void 0 && pendingLoadSignature !== geometrySignature) {
|
|
6063
|
+
this.loadingSignatures.delete(entityId);
|
|
6064
|
+
this.modelMeshEntries.delete(entityId);
|
|
6065
|
+
}
|
|
6066
|
+
if (comp.meshKind === "model") {
|
|
6067
|
+
if (comp.modelPath && !this.loadingSignatures.has(entityId)) {
|
|
6068
|
+
this.loadingSignatures.set(entityId, geometrySignature);
|
|
6069
|
+
const targetSignature = geometrySignature;
|
|
6070
|
+
const targetEntityId = entityId;
|
|
6071
|
+
loadGLTF(comp.modelPath).then((gltf) => {
|
|
6072
|
+
if (!world.hasEntity(targetEntityId)) {
|
|
6073
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
6074
|
+
return;
|
|
6075
|
+
}
|
|
6076
|
+
const currentComp = world.getComponent(
|
|
6077
|
+
targetEntityId,
|
|
6078
|
+
InstancedMeshComponent
|
|
6079
|
+
);
|
|
6080
|
+
if (!currentComp) {
|
|
6081
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
6082
|
+
return;
|
|
6083
|
+
}
|
|
6084
|
+
const currentSig = `model:${currentComp.modelPath}:${currentComp.instances.length}`;
|
|
6085
|
+
if (currentSig !== targetSignature) {
|
|
6086
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
6087
|
+
return;
|
|
6088
|
+
}
|
|
6089
|
+
const currentRef = world.getComponent(targetEntityId, Object3DRef);
|
|
6090
|
+
const currentAnchor = currentRef?.object ?? null;
|
|
6091
|
+
if (!currentAnchor) {
|
|
6092
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
6093
|
+
return;
|
|
6094
|
+
}
|
|
6095
|
+
if (currentComp.instancedMesh) {
|
|
6096
|
+
currentAnchor.remove(currentComp.instancedMesh);
|
|
6097
|
+
disposeModelGroup(currentComp.instancedMesh);
|
|
6098
|
+
currentComp.instancedMesh = null;
|
|
6099
|
+
}
|
|
6100
|
+
const count2 = Math.max(1, currentComp.instances.length);
|
|
6101
|
+
const entries = [];
|
|
6102
|
+
gltf.scene.updateWorldMatrix(true, true);
|
|
6103
|
+
gltf.scene.traverse((child) => {
|
|
6104
|
+
const meshChild = child;
|
|
6105
|
+
if (!meshChild.isMesh) return;
|
|
6106
|
+
const geometry2 = meshChild.geometry.clone();
|
|
6107
|
+
const sourceMaterial = Array.isArray(meshChild.material) ? meshChild.material.map((m) => m.clone()) : meshChild.material.clone();
|
|
6108
|
+
meshChild.updateWorldMatrix(true, false);
|
|
6109
|
+
const localMatrix = meshChild.matrixWorld.clone();
|
|
6110
|
+
const instancedMesh2 = new THREE34__namespace.InstancedMesh(
|
|
6111
|
+
geometry2,
|
|
6112
|
+
Array.isArray(sourceMaterial) ? sourceMaterial : sourceMaterial,
|
|
6113
|
+
count2
|
|
6114
|
+
);
|
|
6115
|
+
instancedMesh2.castShadow = currentComp.castShadow;
|
|
6116
|
+
instancedMesh2.receiveShadow = currentComp.receiveShadow;
|
|
6117
|
+
for (let i = 0; i < count2; i++) {
|
|
6118
|
+
const inst = currentComp.instances[i] ?? {
|
|
6119
|
+
position: { x: 0, y: 0, z: 0 },
|
|
6120
|
+
rotation: { x: 0, y: 0, z: 0 },
|
|
6121
|
+
scale: { x: 1, y: 1, z: 1 }
|
|
6122
|
+
};
|
|
6123
|
+
instanceTransformToMatrix4(inst, _matrix);
|
|
6124
|
+
_modelMatrix.multiplyMatrices(_matrix, localMatrix);
|
|
6125
|
+
instancedMesh2.setMatrixAt(i, _modelMatrix);
|
|
6126
|
+
}
|
|
6127
|
+
instancedMesh2.instanceMatrix.needsUpdate = true;
|
|
6128
|
+
entries.push({ localMatrix, instancedMesh: instancedMesh2 });
|
|
6129
|
+
});
|
|
6130
|
+
if (entries.length === 0) {
|
|
6131
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
6132
|
+
return;
|
|
6133
|
+
}
|
|
6134
|
+
const group = new THREE34__namespace.Group();
|
|
6135
|
+
for (const entry of entries) {
|
|
6136
|
+
group.add(entry.instancedMesh);
|
|
6137
|
+
}
|
|
6138
|
+
currentAnchor.add(group);
|
|
6139
|
+
currentComp.instancedMesh = group;
|
|
6140
|
+
this.modelMeshEntries.set(targetEntityId, entries);
|
|
6141
|
+
this.geometrySignatures.set(targetEntityId, targetSignature);
|
|
6142
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
6143
|
+
}).catch(() => {
|
|
6144
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
6145
|
+
});
|
|
6146
|
+
}
|
|
6147
|
+
continue;
|
|
6148
|
+
}
|
|
6001
6149
|
const count = Math.max(1, instanceCount);
|
|
6002
6150
|
const geometry = buildGeometry(comp);
|
|
6003
6151
|
const material = new THREE34__namespace.MeshStandardMaterial({ color: "#ffffff" });
|
|
@@ -6018,15 +6166,32 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
6018
6166
|
comp.instancedMesh = instancedMesh;
|
|
6019
6167
|
this.geometrySignatures.set(entityId, geometrySignature);
|
|
6020
6168
|
} else {
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6169
|
+
if (comp.meshKind === "model") {
|
|
6170
|
+
const entries = this.modelMeshEntries.get(entityId);
|
|
6171
|
+
if (entries) {
|
|
6172
|
+
const count = comp.instances.length;
|
|
6173
|
+
for (const entry of entries) {
|
|
6174
|
+
for (let i = 0; i < count; i++) {
|
|
6175
|
+
instanceTransformToMatrix4(comp.instances[i], _matrix);
|
|
6176
|
+
_modelMatrix.multiplyMatrices(_matrix, entry.localMatrix);
|
|
6177
|
+
entry.instancedMesh.setMatrixAt(i, _modelMatrix);
|
|
6178
|
+
}
|
|
6179
|
+
entry.instancedMesh.instanceMatrix.needsUpdate = true;
|
|
6180
|
+
entry.instancedMesh.castShadow = comp.castShadow;
|
|
6181
|
+
entry.instancedMesh.receiveShadow = comp.receiveShadow;
|
|
6182
|
+
}
|
|
6183
|
+
}
|
|
6184
|
+
} else {
|
|
6185
|
+
const im = comp.instancedMesh;
|
|
6186
|
+
const count = comp.instances.length;
|
|
6187
|
+
for (let i = 0; i < count; i++) {
|
|
6188
|
+
instanceTransformToMatrix4(comp.instances[i], _matrix);
|
|
6189
|
+
im.setMatrixAt(i, _matrix);
|
|
6190
|
+
}
|
|
6191
|
+
im.instanceMatrix.needsUpdate = true;
|
|
6192
|
+
im.castShadow = comp.castShadow;
|
|
6193
|
+
im.receiveShadow = comp.receiveShadow;
|
|
6026
6194
|
}
|
|
6027
|
-
im.instanceMatrix.needsUpdate = true;
|
|
6028
|
-
im.castShadow = comp.castShadow;
|
|
6029
|
-
im.receiveShadow = comp.receiveShadow;
|
|
6030
6195
|
}
|
|
6031
6196
|
}
|
|
6032
6197
|
}
|
|
@@ -8586,6 +8751,9 @@ function restoreComponentState(world, objectManagementSystem, targetEntityId, so
|
|
|
8586
8751
|
if (typeof sourceInstancedMesh.meshKind === "string") {
|
|
8587
8752
|
imComponent.meshKind = sourceInstancedMesh.meshKind;
|
|
8588
8753
|
}
|
|
8754
|
+
if (typeof sourceInstancedMesh.modelPath === "string") {
|
|
8755
|
+
imComponent.modelPath = sourceInstancedMesh.modelPath;
|
|
8756
|
+
}
|
|
8589
8757
|
const parameters = asRecord3(sourceInstancedMesh.meshParameters);
|
|
8590
8758
|
if (parameters) {
|
|
8591
8759
|
imComponent.meshParameters = parameters;
|