@relu-interactives/spatial-ecs 0.4.1 → 0.4.3

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/index.cjs CHANGED
@@ -12575,6 +12575,14 @@ var _XREnvironmentSystem = class _XREnvironmentSystem {
12575
12575
  } else if (changed !== entry.lastChangedTime) {
12576
12576
  entry.lastChangedTime = changed;
12577
12577
  this.applyPlaneCollider(world, entry.entityId, plane);
12578
+ if (this.debugVisible) {
12579
+ const collider = planeColliderFromPolygon(plane.polygon);
12580
+ if (collider) {
12581
+ entry.geometry?.dispose();
12582
+ entry.geometry = null;
12583
+ this.attachPlaneDebug(world, entry, collider);
12584
+ }
12585
+ }
12578
12586
  }
12579
12587
  this.applyPose(world, entry.entityId, pose);
12580
12588
  }
@@ -12686,10 +12694,18 @@ var _XREnvironmentSystem = class _XREnvironmentSystem {
12686
12694
  wireframe: true
12687
12695
  });
12688
12696
  const root = new THREE51__namespace.Group();
12689
- root.add(new THREE51__namespace.Mesh(geometry, material));
12697
+ const child = new THREE51__namespace.Mesh(geometry, material);
12698
+ child.position.set(collider.offset.x, collider.offset.y, collider.offset.z);
12699
+ child.visible = this.debugVisible;
12700
+ root.add(child);
12690
12701
  entry.geometry = geometry;
12691
12702
  entry.material = material;
12692
- world.addComponent(entry.entityId, new Object3DRef(root));
12703
+ const existing = world.getComponent(entry.entityId, Object3DRef);
12704
+ if (existing) {
12705
+ existing.object = root;
12706
+ } else {
12707
+ world.addComponent(entry.entityId, new Object3DRef(root));
12708
+ }
12693
12709
  }
12694
12710
  applyPose(world, entityId, pose) {
12695
12711
  const transform = world.getComponent(entityId, TransformComponent);
@@ -12697,6 +12713,13 @@ var _XREnvironmentSystem = class _XREnvironmentSystem {
12697
12713
  decomposeXrPose(pose.transform.matrix, transform);
12698
12714
  }
12699
12715
  applyDebugVisibility(world) {
12716
+ if (this.debugVisible) {
12717
+ for (const [plane, entry] of this.planes) {
12718
+ if (entry.geometry) continue;
12719
+ const collider = planeColliderFromPolygon(plane.polygon);
12720
+ if (collider) this.attachPlaneDebug(world, entry, collider);
12721
+ }
12722
+ }
12700
12723
  for (const map of [this.planes, this.meshes]) {
12701
12724
  for (const entry of map.values()) {
12702
12725
  const ref = world.getComponent(entry.entityId, Object3DRef);