@relu-interactives/spatial-ecs 0.2.8 → 0.2.10
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/{chunk-PHIEXEKJ.js → chunk-R2WMVXZZ.js} +11 -2
- package/dist/chunk-R2WMVXZZ.js.map +1 -0
- package/dist/{chunk-TVBWYIGY.js → chunk-Y7KXYSPD.js} +36 -10
- package/dist/chunk-Y7KXYSPD.js.map +1 -0
- package/dist/index.cjs +43 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/systems/index.cjs +34 -8
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +9 -0
- package/dist/systems/index.d.ts +9 -0
- package/dist/systems/index.js +1 -1
- package/dist/worldSnapshotUtils.cjs +9 -0
- package/dist/worldSnapshotUtils.cjs.map +1 -1
- package/dist/worldSnapshotUtils.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-PHIEXEKJ.js.map +0 -1
- package/dist/chunk-TVBWYIGY.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MeshGeometrySystem, InstancedMeshSystem, EnvironmentSyncSystem, PostprocessingSyncSystem, LightSyncSystem, MaterialSyncSystem, PhysicsSyncSystem, AnimationSystem, AudioSystem, VideoSystem, CameraSyncSystem, TransformSyncSystem, ObjectVisibilitySystem, RenderSystem } from './chunk-
|
|
2
|
-
export { AnimationSystem, AudioSystem, Behaviour, CameraSyncSystem, EnvironmentSyncSystem, InputSystem, InstancedMeshSystem, KeyboardKeys, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, ObjectVisibilitySystem, PhysicsSyncSystem, PostprocessingSyncSystem, RenderSystem, ScriptBehaviourSystem, TransformSyncSystem, VideoSystem } from './chunk-
|
|
1
|
+
import { MeshGeometrySystem, InstancedMeshSystem, EnvironmentSyncSystem, PostprocessingSyncSystem, LightSyncSystem, MaterialSyncSystem, PhysicsSyncSystem, AnimationSystem, AudioSystem, VideoSystem, CameraSyncSystem, TransformSyncSystem, ObjectVisibilitySystem, RenderSystem } from './chunk-Y7KXYSPD.js';
|
|
2
|
+
export { AnimationSystem, AudioSystem, Behaviour, CameraSyncSystem, EnvironmentSyncSystem, InputSystem, InstancedMeshSystem, KeyboardKeys, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, ObjectVisibilitySystem, PhysicsSyncSystem, PostprocessingSyncSystem, RenderSystem, ScriptBehaviourSystem, TransformSyncSystem, VideoSystem } from './chunk-Y7KXYSPD.js';
|
|
3
3
|
import { registerDefaultFactories } from './chunk-LE6ARNYQ.js';
|
|
4
4
|
export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createInstanceSlotComponent, createInstancedMeshComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVideoComponent, registerDefaultComponentFactories, registerDefaultFactories } from './chunk-LE6ARNYQ.js';
|
|
5
5
|
import { ObjectManagementSystem, applyTransform } from './chunk-ODCWJHPS.js';
|
|
@@ -7,7 +7,7 @@ export { ObjectManagementSystem } from './chunk-ODCWJHPS.js';
|
|
|
7
7
|
import { SelectionTransformState, Object3DRef, Name, EntityType, ScriptComponent, InstancedMeshComponent, InstanceSlotComponent, AnimationComponent, TransformComponent, ModelComponent, ImageComponent, SpriteComponent, VideoComponent, AudioComponent, CameraComponent, Environment, Postprocessing, ImageTarget, LightComponent, MaterialComponent, MeshGeometryComponent, Selectable, PhysicsComponent } from './chunk-AZR6SLQN.js';
|
|
8
8
|
export { AnimationStateMachine, AnimationStateManager, components_exports as CoreComponents } from './chunk-AZR6SLQN.js';
|
|
9
9
|
import './chunk-QHILSPT4.js';
|
|
10
|
-
import { normalizeDebugValue, DEBUG_CHANGE_IGNORED_SYSTEMS, cloneHistoryValue } from './chunk-
|
|
10
|
+
import { normalizeDebugValue, DEBUG_CHANGE_IGNORED_SYSTEMS, cloneHistoryValue } from './chunk-R2WMVXZZ.js';
|
|
11
11
|
import { __name } from './chunk-OY7ZODZP.js';
|
|
12
12
|
export { Component } from './chunk-OY7ZODZP.js';
|
|
13
13
|
import * as THREE from 'three';
|
package/dist/systems/index.cjs
CHANGED
|
@@ -4236,6 +4236,15 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
4236
4236
|
this.loadingSignatures = /* @__PURE__ */ new Map();
|
|
4237
4237
|
/** Per-mesh data for model kind, populated after GLTF load. */
|
|
4238
4238
|
this.modelMeshEntries = /* @__PURE__ */ new Map();
|
|
4239
|
+
/**
|
|
4240
|
+
* System-internal ref to the Three.js mesh/group most recently placed on
|
|
4241
|
+
* the anchor by this system. Used for cleanup on rebuild instead of
|
|
4242
|
+
* `comp.instancedMesh`, which can be stale (pointing to a disposed mesh)
|
|
4243
|
+
* after an undo/redo restores a history snapshot captured at an earlier
|
|
4244
|
+
* geometry configuration. Relying on the stale comp ref would skip removal
|
|
4245
|
+
* of the current live mesh → ghost mesh in the scene.
|
|
4246
|
+
*/
|
|
4247
|
+
this.trackedMeshes = /* @__PURE__ */ new Map();
|
|
4239
4248
|
}
|
|
4240
4249
|
update(world) {
|
|
4241
4250
|
const entityIds = world.query(InstancedMeshComponent);
|
|
@@ -4249,6 +4258,9 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
4249
4258
|
for (const trackedId of this.modelMeshEntries.keys()) {
|
|
4250
4259
|
if (!alive.has(trackedId)) this.modelMeshEntries.delete(trackedId);
|
|
4251
4260
|
}
|
|
4261
|
+
for (const trackedId of this.trackedMeshes.keys()) {
|
|
4262
|
+
if (!alive.has(trackedId)) this.trackedMeshes.delete(trackedId);
|
|
4263
|
+
}
|
|
4252
4264
|
for (const entityId of entityIds) {
|
|
4253
4265
|
const comp = world.getComponent(
|
|
4254
4266
|
entityId,
|
|
@@ -4260,22 +4272,34 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
4260
4272
|
if (!anchor) continue;
|
|
4261
4273
|
const instanceCount = comp.instanceEntityIds.length;
|
|
4262
4274
|
const geometrySignature = comp.meshKind === "model" ? `model:${comp.modelPath}:${instanceCount}` : `${comp.meshKind}:${JSON.stringify(comp.meshParameters)}:${instanceCount}`;
|
|
4275
|
+
if (comp.instancedMesh === null) {
|
|
4276
|
+
const tracked = this.trackedMeshes.get(entityId);
|
|
4277
|
+
if (tracked) {
|
|
4278
|
+
comp.instancedMesh = tracked;
|
|
4279
|
+
}
|
|
4280
|
+
}
|
|
4263
4281
|
const pendingLoadSignature = this.loadingSignatures.get(entityId);
|
|
4264
|
-
const needsRebuild = (
|
|
4282
|
+
const needsRebuild = (!this.trackedMeshes.has(entityId) || this.geometrySignatures.get(entityId) !== geometrySignature) && pendingLoadSignature !== geometrySignature;
|
|
4265
4283
|
if (needsRebuild) {
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4284
|
+
const trackedMesh = this.trackedMeshes.get(entityId);
|
|
4285
|
+
if (trackedMesh) {
|
|
4286
|
+
anchor.remove(trackedMesh);
|
|
4287
|
+
if (trackedMesh.isInstancedMesh) {
|
|
4288
|
+
disposePrimitiveInstancedMesh(trackedMesh);
|
|
4270
4289
|
} else {
|
|
4271
|
-
disposeModelGroup(
|
|
4290
|
+
disposeModelGroup(trackedMesh);
|
|
4272
4291
|
}
|
|
4273
|
-
|
|
4292
|
+
this.trackedMeshes.delete(entityId);
|
|
4274
4293
|
}
|
|
4294
|
+
comp.instancedMesh = null;
|
|
4275
4295
|
if (pendingLoadSignature !== void 0 && pendingLoadSignature !== geometrySignature) {
|
|
4276
4296
|
this.loadingSignatures.delete(entityId);
|
|
4277
4297
|
this.modelMeshEntries.delete(entityId);
|
|
4278
4298
|
}
|
|
4299
|
+
if (instanceCount === 0) {
|
|
4300
|
+
this.geometrySignatures.set(entityId, geometrySignature);
|
|
4301
|
+
continue;
|
|
4302
|
+
}
|
|
4279
4303
|
if (comp.meshKind === "model") {
|
|
4280
4304
|
if (comp.modelPath && !this.loadingSignatures.has(entityId)) {
|
|
4281
4305
|
this.loadingSignatures.set(entityId, geometrySignature);
|
|
@@ -4353,6 +4377,7 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
4353
4377
|
currentComp.instancedMesh = group;
|
|
4354
4378
|
this.modelMeshEntries.set(targetEntityId, entries);
|
|
4355
4379
|
this.geometrySignatures.set(targetEntityId, targetSignature);
|
|
4380
|
+
this.trackedMeshes.set(targetEntityId, group);
|
|
4356
4381
|
this.loadingSignatures.delete(targetEntityId);
|
|
4357
4382
|
}).catch(() => {
|
|
4358
4383
|
this.loadingSignatures.delete(targetEntityId);
|
|
@@ -4360,7 +4385,7 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
4360
4385
|
}
|
|
4361
4386
|
continue;
|
|
4362
4387
|
}
|
|
4363
|
-
const count =
|
|
4388
|
+
const count = instanceCount;
|
|
4364
4389
|
const geometry = buildGeometry(comp);
|
|
4365
4390
|
const material = new THREE13__namespace.MeshStandardMaterial({ color: "#ffffff" });
|
|
4366
4391
|
const instancedMesh = new THREE13__namespace.InstancedMesh(geometry, material, count);
|
|
@@ -4379,6 +4404,7 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
4379
4404
|
instancedMesh.instanceMatrix.needsUpdate = true;
|
|
4380
4405
|
anchor.add(instancedMesh);
|
|
4381
4406
|
comp.instancedMesh = instancedMesh;
|
|
4407
|
+
this.trackedMeshes.set(entityId, instancedMesh);
|
|
4382
4408
|
this.geometrySignatures.set(entityId, geometrySignature);
|
|
4383
4409
|
} else {
|
|
4384
4410
|
if (comp.meshKind === "model") {
|