@lovelace_lol/embody 0.0.10 → 0.0.11

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.
@@ -72,6 +72,7 @@ export declare class DPthree3DMarkers {
72
72
  private zoomThreshold;
73
73
  private autoCollapseThreshold;
74
74
  private lastCameraDistance;
75
+ private markerLayoutDirty;
75
76
  private visibilityAnimationActive;
76
77
  private readonly visibilityAnimationScheduler;
77
78
  private visibilityAnimationStates;
@@ -247,7 +248,7 @@ export declare class DPthree3DMarkers {
247
248
  private refreshLaterality;
248
249
  /**
249
250
  * Apply zoom-based scaling to all markers, lines, and labels.
250
- * Only called when crossing the zoom threshold (not every frame).
251
+ * Runs on zoom threshold crossings and when marker geometry changes.
251
252
  */
252
253
  private applyZoomScale;
253
254
  setVisible(visible: boolean): void;
package/dist/three.js CHANGED
@@ -1206,6 +1206,7 @@ var DPthree3DMarkers = class {
1206
1206
  // Calculated from model size - collapse expanded regions when zoomed out
1207
1207
  __publicField(this, "lastCameraDistance", -1);
1208
1208
  // Cache to avoid unnecessary checks
1209
+ __publicField(this, "markerLayoutDirty", false);
1209
1210
  __publicField(this, "visibilityAnimationActive", false);
1210
1211
  __publicField(this, "visibilityAnimationScheduler", new AnimationFrameTaskScheduler());
1211
1212
  __publicField(this, "visibilityAnimationStates", []);
@@ -1369,6 +1370,8 @@ var DPthree3DMarkers = class {
1369
1370
  return;
1370
1371
  }
1371
1372
  this.separateOverlappingMarkers(annotationCameraCore);
1373
+ this.markerLayoutDirty = true;
1374
+ this.update();
1372
1375
  console.log(`[3DMarkers] loadRegions complete. Created markers for:`, Array.from(this.markerMeshes.keys()));
1373
1376
  console.log(`[3DMarkers] lineEndpoints:`, Array.from(this.lineEndpoints.keys()));
1374
1377
  console.log(`[3DMarkers] resolvedStyles:`, Array.from(this.resolvedStyles.keys()));
@@ -1840,6 +1843,12 @@ var DPthree3DMarkers = class {
1840
1843
  this.markerTargetVisibility.set(region.name, !startHidden && !region.isFallback);
1841
1844
  this.markerAngleGateVisibility.delete(region.name);
1842
1845
  this.markerViewportVisibility.set(region.name, true);
1846
+ this.markerLayoutDirty = true;
1847
+ if (this.visibilityAnimationActive) {
1848
+ this.setMarkerObjectsVisible(region.name, false, false);
1849
+ } else {
1850
+ this.update();
1851
+ }
1843
1852
  }
1844
1853
  /**
1845
1854
  * Embody Rust owns endpoint layout; the Three adapter applies the returned positions
@@ -2455,7 +2464,7 @@ var DPthree3DMarkers = class {
2455
2464
  const dy = this.camera.position.y - this.modelCenter.y;
2456
2465
  const dz = this.camera.position.z - this.modelCenter.z;
2457
2466
  const cameraDistance = Math.sqrt(dx * dx + dy * dy + dz * dz);
2458
- const distanceChanged = this.lastCameraDistance < 0 || Math.abs(cameraDistance - this.lastCameraDistance) > this.lastCameraDistance * 0.02;
2467
+ const distanceChanged = this.markerLayoutDirty || this.lastCameraDistance < 0 || Math.abs(cameraDistance - this.lastCameraDistance) > this.lastCameraDistance * 0.02;
2459
2468
  if (distanceChanged) {
2460
2469
  const previousDistance = this.lastCameraDistance;
2461
2470
  this.lastCameraDistance = cameraDistance;
@@ -2466,22 +2475,27 @@ var DPthree3DMarkers = class {
2466
2475
  sphere.scale.setScalar(clampedScale);
2467
2476
  }
2468
2477
  const shouldBeZoomedIn = cameraDistance < this.zoomThreshold;
2469
- if (shouldBeZoomedIn !== this.isZoomedIn) {
2478
+ const zoomChanged = shouldBeZoomedIn !== this.isZoomedIn;
2479
+ if (this.markerLayoutDirty || zoomChanged) {
2470
2480
  this.isZoomedIn = shouldBeZoomedIn;
2471
- this.applyZoomScale(shouldBeZoomedIn ? ZOOMED_IN_LINE_SCALE : 1);
2481
+ this.applyZoomScale(
2482
+ shouldBeZoomedIn ? ZOOMED_IN_LINE_SCALE : 1,
2483
+ zoomChanged || shouldBeZoomedIn
2484
+ );
2472
2485
  }
2473
2486
  const crossedAutoCollapseThreshold = previousDistance >= 0 && previousDistance <= this.autoCollapseThreshold && cameraDistance > this.autoCollapseThreshold;
2474
2487
  if (crossedAutoCollapseThreshold) {
2475
2488
  this.collapseAllRegions();
2476
2489
  }
2477
2490
  }
2478
- const cameraMoved = !this.hasCameraAngleUpdateSnapshot || this.lastCameraAngleUpdatePosition.distanceToSquared(this.camera.position) > 1e-4 || 1 - Math.abs(this.lastCameraAngleUpdateQuaternion.dot(this.camera.quaternion)) > 1e-5;
2491
+ const cameraMoved = this.markerLayoutDirty || !this.hasCameraAngleUpdateSnapshot || this.lastCameraAngleUpdatePosition.distanceToSquared(this.camera.position) > 1e-4 || 1 - Math.abs(this.lastCameraAngleUpdateQuaternion.dot(this.camera.quaternion)) > 1e-5;
2479
2492
  if (!cameraMoved) {
2480
2493
  return;
2481
2494
  }
2482
2495
  this.lastCameraAngleUpdatePosition.copy(this.camera.position);
2483
2496
  this.lastCameraAngleUpdateQuaternion.copy(this.camera.quaternion);
2484
2497
  this.hasCameraAngleUpdateSnapshot = true;
2498
+ this.markerLayoutDirty = false;
2485
2499
  const cameraAngle = getModelLocalOrbitAngle(this.model, this.modelCenter, this.camera.position);
2486
2500
  for (const [name, sphere] of this.markerMeshes) {
2487
2501
  const markerAngle = sphere.userData.cameraAngle;
@@ -2519,14 +2533,16 @@ var DPthree3DMarkers = class {
2519
2533
  }
2520
2534
  /**
2521
2535
  * Apply zoom-based scaling to all markers, lines, and labels.
2522
- * Only called when crossing the zoom threshold (not every frame).
2536
+ * Runs on zoom threshold crossings and when marker geometry changes.
2523
2537
  */
2524
- applyZoomScale(scaleFactor) {
2538
+ applyZoomScale(scaleFactor, scaleSpheres = true) {
2525
2539
  const isZoomed = scaleFactor < 1;
2526
2540
  const sphereScaleFactor = isZoomed ? ZOOMED_IN_SPHERE_SCALE : 1;
2527
2541
  const labelScaleFactor = isZoomed ? ZOOMED_IN_LABEL_SCALE : 1;
2528
- for (const sphere of this.markerMeshes.values()) {
2529
- sphere.scale.setScalar(sphereScaleFactor);
2542
+ if (scaleSpheres) {
2543
+ for (const sphere of this.markerMeshes.values()) {
2544
+ sphere.scale.setScalar(sphereScaleFactor);
2545
+ }
2530
2546
  }
2531
2547
  for (const line of this.lineMeshes.values()) {
2532
2548
  const material = line.material;
@@ -2630,6 +2646,10 @@ var DPthree3DMarkers = class {
2630
2646
  object.visible = true;
2631
2647
  this.setObjectOpacity(object, opacity * itemOpacityFactor);
2632
2648
  }
2649
+ const name = state.label?.object.userData.annotation;
2650
+ if (typeof name === "string" && !this.updateMarkerLineLayout(name)) {
2651
+ this.setMarkerObjectsVisible(name, false, false);
2652
+ }
2633
2653
  }
2634
2654
  }
2635
2655
  restoreVisibilityAnimationStates(states) {
@@ -2815,6 +2835,8 @@ var DPthree3DMarkers = class {
2815
2835
  this.stopVisibilityAnimation(true);
2816
2836
  if (visible) {
2817
2837
  this.markerGroup.visible = true;
2838
+ this.markerLayoutDirty = true;
2839
+ this.update();
2818
2840
  }
2819
2841
  this.visibilityAnimationStates = this.captureVisibilityAnimationStates();
2820
2842
  if (this.visibilityAnimationStates.length === 0) {
@@ -2877,6 +2899,7 @@ var DPthree3DMarkers = class {
2877
2899
  this.markerAngleGateVisibility.clear();
2878
2900
  this.markerViewportVisibility.clear();
2879
2901
  this.soloedMarker = null;
2902
+ this.markerLayoutDirty = false;
2880
2903
  this.hasCameraAngleUpdateSnapshot = false;
2881
2904
  }
2882
2905
  // ============ SOLO MODE ============