@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.cjs CHANGED
@@ -6,7 +6,7 @@ var fiber = require('@react-three/fiber');
6
6
  var threeMeshBvh = require('three-mesh-bvh');
7
7
 
8
8
  // src/version.ts
9
- var version = "0.4.0";
9
+ var version = "0.5.0";
10
10
 
11
11
  // src/debug.ts
12
12
  var _enabled = false;
@@ -1525,6 +1525,7 @@ function findTrackingPair(obj) {
1525
1525
  function registerSubtree(obj, store, mirror, instanceKey) {
1526
1526
  obj.traverse((child) => {
1527
1527
  if (!store.has(child) && shouldRegister(instanceKey, child)) {
1528
+ ensureAncestorChain(child, store, mirror);
1528
1529
  store.register(child);
1529
1530
  mirror.onObjectAdded(child);
1530
1531
  }
@@ -3359,6 +3360,21 @@ function shouldRegister(instanceKey, obj) {
3359
3360
  if (filter) return filter(obj);
3360
3361
  return true;
3361
3362
  }
3363
+ function ensureAncestorChain(obj, store, mirror) {
3364
+ const chain = [];
3365
+ let cursor = obj.parent;
3366
+ while (cursor) {
3367
+ if (store.has(cursor)) break;
3368
+ chain.push(cursor);
3369
+ cursor = cursor.parent;
3370
+ }
3371
+ for (let i = chain.length - 1; i >= 0; i--) {
3372
+ const ancestor = chain[i];
3373
+ store.register(ancestor);
3374
+ mirror.onObjectAdded(ancestor);
3375
+ mirror.materialize(ancestor.uuid);
3376
+ }
3377
+ }
3362
3378
  function getStore2(canvasId = "") {
3363
3379
  return _stores.get(canvasId) ?? null;
3364
3380
  }
@@ -3518,10 +3534,17 @@ function exposeGlobalAPI(store, gl, cameraRef, selMgr, inspCtrl, mirror, canvasI
3518
3534
  return;
3519
3535
  }
3520
3536
  obj.userData.__r3fdom_manual = true;
3521
- store.register(obj);
3522
- mirror?.onObjectAdded(obj);
3523
- mirror?.materialize(obj.uuid);
3524
- r3fLog("bridge", `r3fRegister: "${obj.userData?.testId || obj.name || obj.uuid.slice(0, 8)}" (${obj.type})`);
3537
+ ensureAncestorChain(obj, store, mirror);
3538
+ let count = 0;
3539
+ obj.traverse((child) => {
3540
+ if (!store.has(child)) {
3541
+ store.register(child);
3542
+ mirror?.onObjectAdded(child);
3543
+ mirror?.materialize(child.uuid);
3544
+ count++;
3545
+ }
3546
+ });
3547
+ r3fLog("bridge", `r3fRegister: "${obj.userData?.testId || obj.name || obj.uuid.slice(0, 8)}" (${obj.type}) \u2014 ${count} objects`);
3525
3548
  },
3526
3549
  r3fUnregister: (obj) => {
3527
3550
  if (!store.has(obj)) return;
@@ -3778,8 +3801,12 @@ function ThreeDom({
3778
3801
  if (mode === "auto") {
3779
3802
  if (filter) {
3780
3803
  store.addTrackedRoot(scene);
3804
+ store.register(scene);
3805
+ mirror.onObjectAdded(scene);
3781
3806
  scene.traverse((obj) => {
3807
+ if (obj === scene) return;
3782
3808
  if (filter(obj)) {
3809
+ ensureAncestorChain(obj, store, mirror);
3783
3810
  store.register(obj);
3784
3811
  mirror.onObjectAdded(obj);
3785
3812
  }