@react-three-dom/core 0.4.0 → 0.5.0

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.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Object3D, Scene, Camera, WebGLRenderer, Intersection, Vector3 } from 'three';
2
2
 
3
- declare const version = "0.4.0";
3
+ declare const version = "0.5.0";
4
4
 
5
5
  /**
6
6
  * Enable or disable debug logging globally.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Object3D, Scene, Camera, WebGLRenderer, Intersection, Vector3 } from 'three';
2
2
 
3
- declare const version = "0.4.0";
3
+ declare const version = "0.5.0";
4
4
 
5
5
  /**
6
6
  * Enable or disable debug logging globally.
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { useThree, useFrame } from '@react-three/fiber';
4
4
  import { computeBoundsTree, disposeBoundsTree, acceleratedRaycast } from 'three-mesh-bvh';
5
5
 
6
6
  // src/version.ts
7
- var version = "0.4.0";
7
+ var version = "0.5.0";
8
8
 
9
9
  // src/debug.ts
10
10
  var _enabled = false;
@@ -1523,6 +1523,7 @@ function findTrackingPair(obj) {
1523
1523
  function registerSubtree(obj, store, mirror, instanceKey) {
1524
1524
  obj.traverse((child) => {
1525
1525
  if (!store.has(child) && shouldRegister(instanceKey, child)) {
1526
+ ensureAncestorChain(child, store, mirror);
1526
1527
  store.register(child);
1527
1528
  mirror.onObjectAdded(child);
1528
1529
  }
@@ -3357,6 +3358,21 @@ function shouldRegister(instanceKey, obj) {
3357
3358
  if (filter) return filter(obj);
3358
3359
  return true;
3359
3360
  }
3361
+ function ensureAncestorChain(obj, store, mirror) {
3362
+ const chain = [];
3363
+ let cursor = obj.parent;
3364
+ while (cursor) {
3365
+ if (store.has(cursor)) break;
3366
+ chain.push(cursor);
3367
+ cursor = cursor.parent;
3368
+ }
3369
+ for (let i = chain.length - 1; i >= 0; i--) {
3370
+ const ancestor = chain[i];
3371
+ store.register(ancestor);
3372
+ mirror.onObjectAdded(ancestor);
3373
+ mirror.materialize(ancestor.uuid);
3374
+ }
3375
+ }
3360
3376
  function getStore2(canvasId = "") {
3361
3377
  return _stores.get(canvasId) ?? null;
3362
3378
  }
@@ -3516,10 +3532,17 @@ function exposeGlobalAPI(store, gl, cameraRef, selMgr, inspCtrl, mirror, canvasI
3516
3532
  return;
3517
3533
  }
3518
3534
  obj.userData.__r3fdom_manual = true;
3519
- store.register(obj);
3520
- mirror?.onObjectAdded(obj);
3521
- mirror?.materialize(obj.uuid);
3522
- r3fLog("bridge", `r3fRegister: "${obj.userData?.testId || obj.name || obj.uuid.slice(0, 8)}" (${obj.type})`);
3535
+ ensureAncestorChain(obj, store, mirror);
3536
+ let count = 0;
3537
+ obj.traverse((child) => {
3538
+ if (!store.has(child)) {
3539
+ store.register(child);
3540
+ mirror?.onObjectAdded(child);
3541
+ mirror?.materialize(child.uuid);
3542
+ count++;
3543
+ }
3544
+ });
3545
+ r3fLog("bridge", `r3fRegister: "${obj.userData?.testId || obj.name || obj.uuid.slice(0, 8)}" (${obj.type}) \u2014 ${count} objects`);
3523
3546
  },
3524
3547
  r3fUnregister: (obj) => {
3525
3548
  if (!store.has(obj)) return;
@@ -3776,8 +3799,12 @@ function ThreeDom({
3776
3799
  if (mode === "auto") {
3777
3800
  if (filter) {
3778
3801
  store.addTrackedRoot(scene);
3802
+ store.register(scene);
3803
+ mirror.onObjectAdded(scene);
3779
3804
  scene.traverse((obj) => {
3805
+ if (obj === scene) return;
3780
3806
  if (filter(obj)) {
3807
+ ensureAncestorChain(obj, store, mirror);
3781
3808
  store.register(obj);
3782
3809
  mirror.onObjectAdded(obj);
3783
3810
  }