@relu-interactives/spatial-ecs 0.2.5 → 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/{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-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-RXCUHGRB.js → chunk-NRSUYDBA.js} +183 -32
- package/dist/chunk-NRSUYDBA.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 +187 -28
- 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 +183 -28
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +16 -4
- package/dist/systems/index.d.ts +16 -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,156 @@ 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
|
+
/** Entities whose GLTF model is currently loading. Prevents duplicate load triggers. */
|
|
6022
|
+
this.loadingEntities = /* @__PURE__ */ new Set();
|
|
6023
|
+
/** Per-mesh data for model kind, populated after GLTF load. */
|
|
6024
|
+
this.modelMeshEntries = /* @__PURE__ */ new Map();
|
|
5960
6025
|
}
|
|
5961
6026
|
update(world) {
|
|
5962
6027
|
const entityIds = world.query(InstancedMeshComponent);
|
|
5963
6028
|
const alive = new Set(entityIds);
|
|
5964
6029
|
for (const trackedId of this.geometrySignatures.keys()) {
|
|
5965
|
-
if (!alive.has(trackedId))
|
|
5966
|
-
|
|
5967
|
-
|
|
6030
|
+
if (!alive.has(trackedId)) this.geometrySignatures.delete(trackedId);
|
|
6031
|
+
}
|
|
6032
|
+
for (const trackedId of this.loadingEntities) {
|
|
6033
|
+
if (!alive.has(trackedId)) this.loadingEntities.delete(trackedId);
|
|
6034
|
+
}
|
|
6035
|
+
for (const trackedId of this.modelMeshEntries.keys()) {
|
|
6036
|
+
if (!alive.has(trackedId)) this.modelMeshEntries.delete(trackedId);
|
|
5968
6037
|
}
|
|
5969
6038
|
for (const entityId of entityIds) {
|
|
5970
6039
|
const comp = world.getComponent(
|
|
5971
6040
|
entityId,
|
|
5972
6041
|
InstancedMeshComponent
|
|
5973
6042
|
);
|
|
5974
|
-
if (!comp)
|
|
5975
|
-
continue;
|
|
5976
|
-
}
|
|
5977
|
-
let anchor = null;
|
|
6043
|
+
if (!comp) continue;
|
|
5978
6044
|
const objectRef = world.getComponent(entityId, Object3DRef);
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
}
|
|
5982
|
-
if (!anchor) {
|
|
5983
|
-
continue;
|
|
5984
|
-
}
|
|
6045
|
+
const anchor = objectRef?.object ?? null;
|
|
6046
|
+
if (!anchor) continue;
|
|
5985
6047
|
const instanceCount = comp.instances.length;
|
|
5986
|
-
const geometrySignature = `${comp.meshKind}:${JSON.stringify(comp.meshParameters)}:${instanceCount}`;
|
|
6048
|
+
const geometrySignature = comp.meshKind === "model" ? `model:${comp.modelPath}:${instanceCount}` : `${comp.meshKind}:${JSON.stringify(comp.meshParameters)}:${instanceCount}`;
|
|
5987
6049
|
const needsRebuild = comp.instancedMesh === null || this.geometrySignatures.get(entityId) !== geometrySignature;
|
|
5988
6050
|
if (needsRebuild) {
|
|
5989
6051
|
if (comp.instancedMesh) {
|
|
5990
6052
|
anchor.remove(comp.instancedMesh);
|
|
5991
|
-
comp.instancedMesh.
|
|
5992
|
-
|
|
5993
|
-
for (const m of comp.instancedMesh.material) {
|
|
5994
|
-
m.dispose();
|
|
5995
|
-
}
|
|
6053
|
+
if (comp.instancedMesh.isInstancedMesh) {
|
|
6054
|
+
disposePrimitiveInstancedMesh(comp.instancedMesh);
|
|
5996
6055
|
} else {
|
|
5997
|
-
comp.instancedMesh
|
|
6056
|
+
disposeModelGroup(comp.instancedMesh);
|
|
5998
6057
|
}
|
|
5999
6058
|
comp.instancedMesh = null;
|
|
6000
6059
|
}
|
|
6060
|
+
this.loadingEntities.delete(entityId);
|
|
6061
|
+
this.modelMeshEntries.delete(entityId);
|
|
6062
|
+
if (comp.meshKind === "model") {
|
|
6063
|
+
if (comp.modelPath && !this.loadingEntities.has(entityId)) {
|
|
6064
|
+
this.loadingEntities.add(entityId);
|
|
6065
|
+
const targetSignature = geometrySignature;
|
|
6066
|
+
const targetEntityId = entityId;
|
|
6067
|
+
loadGLTF(comp.modelPath).then((gltf) => {
|
|
6068
|
+
if (!world.hasEntity(targetEntityId)) {
|
|
6069
|
+
this.loadingEntities.delete(targetEntityId);
|
|
6070
|
+
return;
|
|
6071
|
+
}
|
|
6072
|
+
const currentComp = world.getComponent(
|
|
6073
|
+
targetEntityId,
|
|
6074
|
+
InstancedMeshComponent
|
|
6075
|
+
);
|
|
6076
|
+
if (!currentComp) {
|
|
6077
|
+
this.loadingEntities.delete(targetEntityId);
|
|
6078
|
+
return;
|
|
6079
|
+
}
|
|
6080
|
+
const currentSig = `model:${currentComp.modelPath}:${currentComp.instances.length}`;
|
|
6081
|
+
if (currentSig !== targetSignature) {
|
|
6082
|
+
this.loadingEntities.delete(targetEntityId);
|
|
6083
|
+
return;
|
|
6084
|
+
}
|
|
6085
|
+
const currentRef = world.getComponent(targetEntityId, Object3DRef);
|
|
6086
|
+
const currentAnchor = currentRef?.object ?? null;
|
|
6087
|
+
if (!currentAnchor) {
|
|
6088
|
+
this.loadingEntities.delete(targetEntityId);
|
|
6089
|
+
return;
|
|
6090
|
+
}
|
|
6091
|
+
const count2 = Math.max(1, currentComp.instances.length);
|
|
6092
|
+
const entries = [];
|
|
6093
|
+
gltf.scene.updateWorldMatrix(true, true);
|
|
6094
|
+
gltf.scene.traverse((child) => {
|
|
6095
|
+
const meshChild = child;
|
|
6096
|
+
if (!meshChild.isMesh) return;
|
|
6097
|
+
const geometry2 = meshChild.geometry.clone();
|
|
6098
|
+
const sourceMaterial = Array.isArray(meshChild.material) ? meshChild.material.map((m) => m.clone()) : meshChild.material.clone();
|
|
6099
|
+
meshChild.updateWorldMatrix(true, false);
|
|
6100
|
+
const localMatrix = meshChild.matrixWorld.clone();
|
|
6101
|
+
const instancedMesh2 = new THREE34__namespace.InstancedMesh(
|
|
6102
|
+
geometry2,
|
|
6103
|
+
Array.isArray(sourceMaterial) ? sourceMaterial : sourceMaterial,
|
|
6104
|
+
count2
|
|
6105
|
+
);
|
|
6106
|
+
instancedMesh2.castShadow = currentComp.castShadow;
|
|
6107
|
+
instancedMesh2.receiveShadow = currentComp.receiveShadow;
|
|
6108
|
+
for (let i = 0; i < count2; i++) {
|
|
6109
|
+
const inst = currentComp.instances[i] ?? {
|
|
6110
|
+
position: { x: 0, y: 0, z: 0 },
|
|
6111
|
+
rotation: { x: 0, y: 0, z: 0 },
|
|
6112
|
+
scale: { x: 1, y: 1, z: 1 }
|
|
6113
|
+
};
|
|
6114
|
+
instanceTransformToMatrix4(inst, _matrix);
|
|
6115
|
+
_modelMatrix.multiplyMatrices(_matrix, localMatrix);
|
|
6116
|
+
instancedMesh2.setMatrixAt(i, _modelMatrix);
|
|
6117
|
+
}
|
|
6118
|
+
instancedMesh2.instanceMatrix.needsUpdate = true;
|
|
6119
|
+
entries.push({ localMatrix, instancedMesh: instancedMesh2 });
|
|
6120
|
+
});
|
|
6121
|
+
if (entries.length === 0) {
|
|
6122
|
+
this.loadingEntities.delete(targetEntityId);
|
|
6123
|
+
return;
|
|
6124
|
+
}
|
|
6125
|
+
const group = new THREE34__namespace.Group();
|
|
6126
|
+
for (const entry of entries) {
|
|
6127
|
+
group.add(entry.instancedMesh);
|
|
6128
|
+
}
|
|
6129
|
+
currentAnchor.add(group);
|
|
6130
|
+
currentComp.instancedMesh = group;
|
|
6131
|
+
this.modelMeshEntries.set(targetEntityId, entries);
|
|
6132
|
+
this.geometrySignatures.set(targetEntityId, targetSignature);
|
|
6133
|
+
this.loadingEntities.delete(targetEntityId);
|
|
6134
|
+
}).catch(() => {
|
|
6135
|
+
this.loadingEntities.delete(targetEntityId);
|
|
6136
|
+
});
|
|
6137
|
+
}
|
|
6138
|
+
continue;
|
|
6139
|
+
}
|
|
6001
6140
|
const count = Math.max(1, instanceCount);
|
|
6002
6141
|
const geometry = buildGeometry(comp);
|
|
6003
6142
|
const material = new THREE34__namespace.MeshStandardMaterial({ color: "#ffffff" });
|
|
@@ -6018,15 +6157,32 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
6018
6157
|
comp.instancedMesh = instancedMesh;
|
|
6019
6158
|
this.geometrySignatures.set(entityId, geometrySignature);
|
|
6020
6159
|
} else {
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6160
|
+
if (comp.meshKind === "model") {
|
|
6161
|
+
const entries = this.modelMeshEntries.get(entityId);
|
|
6162
|
+
if (entries) {
|
|
6163
|
+
const count = comp.instances.length;
|
|
6164
|
+
for (const entry of entries) {
|
|
6165
|
+
for (let i = 0; i < count; i++) {
|
|
6166
|
+
instanceTransformToMatrix4(comp.instances[i], _matrix);
|
|
6167
|
+
_modelMatrix.multiplyMatrices(_matrix, entry.localMatrix);
|
|
6168
|
+
entry.instancedMesh.setMatrixAt(i, _modelMatrix);
|
|
6169
|
+
}
|
|
6170
|
+
entry.instancedMesh.instanceMatrix.needsUpdate = true;
|
|
6171
|
+
entry.instancedMesh.castShadow = comp.castShadow;
|
|
6172
|
+
entry.instancedMesh.receiveShadow = comp.receiveShadow;
|
|
6173
|
+
}
|
|
6174
|
+
}
|
|
6175
|
+
} else {
|
|
6176
|
+
const im = comp.instancedMesh;
|
|
6177
|
+
const count = comp.instances.length;
|
|
6178
|
+
for (let i = 0; i < count; i++) {
|
|
6179
|
+
instanceTransformToMatrix4(comp.instances[i], _matrix);
|
|
6180
|
+
im.setMatrixAt(i, _matrix);
|
|
6181
|
+
}
|
|
6182
|
+
im.instanceMatrix.needsUpdate = true;
|
|
6183
|
+
im.castShadow = comp.castShadow;
|
|
6184
|
+
im.receiveShadow = comp.receiveShadow;
|
|
6026
6185
|
}
|
|
6027
|
-
im.instanceMatrix.needsUpdate = true;
|
|
6028
|
-
im.castShadow = comp.castShadow;
|
|
6029
|
-
im.receiveShadow = comp.receiveShadow;
|
|
6030
6186
|
}
|
|
6031
6187
|
}
|
|
6032
6188
|
}
|
|
@@ -8586,6 +8742,9 @@ function restoreComponentState(world, objectManagementSystem, targetEntityId, so
|
|
|
8586
8742
|
if (typeof sourceInstancedMesh.meshKind === "string") {
|
|
8587
8743
|
imComponent.meshKind = sourceInstancedMesh.meshKind;
|
|
8588
8744
|
}
|
|
8745
|
+
if (typeof sourceInstancedMesh.modelPath === "string") {
|
|
8746
|
+
imComponent.modelPath = sourceInstancedMesh.modelPath;
|
|
8747
|
+
}
|
|
8589
8748
|
const parameters = asRecord3(sourceInstancedMesh.meshParameters);
|
|
8590
8749
|
if (parameters) {
|
|
8591
8750
|
imComponent.meshParameters = parameters;
|