three-cad-viewer 1.7.5 → 1.7.6

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.
@@ -54420,7 +54420,7 @@ class NestedGroup {
54420
54420
  return group;
54421
54421
  }
54422
54422
 
54423
- renderShape(shape, color, alpha, renderback, name, states) {
54423
+ renderShape(shape, color, alpha, renderback, path, name, states) {
54424
54424
  const positions =
54425
54425
  shape.vertices instanceof Float32Array
54426
54426
  ? shape.vertices
@@ -54441,6 +54441,10 @@ class NestedGroup {
54441
54441
  renderback,
54442
54442
  );
54443
54443
 
54444
+ path = path + this.delim + name;
54445
+ this.groups[path.replaceAll(this.delim, "/")] = group;
54446
+ group.name = path;
54447
+
54444
54448
  if (alpha == null) {
54445
54449
  alpha = 1.0;
54446
54450
  } else if (alpha < 1.0) {
@@ -54554,6 +54558,7 @@ class NestedGroup {
54554
54558
  shape.color,
54555
54559
  shape.alpha,
54556
54560
  shape.renderback == null ? false : shape.renderback,
54561
+ path,
54557
54562
  shape.name,
54558
54563
  states[shape.id],
54559
54564
  );
@@ -57891,7 +57896,7 @@ class Camera {
57891
57896
  }
57892
57897
  }
57893
57898
 
57894
- const version="1.7.5";
57899
+ const version="1.7.6";
57895
57900
 
57896
57901
  class Viewer {
57897
57902
  /**
@@ -59708,7 +59713,7 @@ class Viewer {
59708
59713
  * @param {number} [speed=1] - speed of animation.
59709
59714
  * @param {number} [multiplier=2.5] - multiplier for length of trajectories.
59710
59715
  */
59711
- explode(duration = 2, speed = 1, multiplier = 2.5) {
59716
+ explode(duration = 2, speed = 1, multiplier = 2.0) {
59712
59717
  this.clearAnimation();
59713
59718
 
59714
59719
  const use_origin = this.getAxes0();
@@ -59727,42 +59732,41 @@ class Viewer {
59727
59732
 
59728
59733
  for (var id in this.nestedGroup.groups) {
59729
59734
  // Loop over all Group elements
59730
- if (!(this.nestedGroup.groups[id] instanceof ObjectGroup)) {
59731
- var group = this.nestedGroup.groups[id];
59735
+ var group = this.nestedGroup.groups[id];
59732
59736
 
59733
- // Get and combine all bounding boxes of ObjectGroups
59734
- // Do not use the Group, since it returns the bounding box of the underlying
59735
- // group hierarchy instead of the object(s)
59736
- var b = new Box3();
59737
+ var b = new Box3();
59738
+ if (group instanceof ObjectGroup) {
59739
+ b.expandByObject(group);
59740
+ } else {
59737
59741
  group.children.forEach((child) => {
59738
59742
  if (child instanceof ObjectGroup) {
59739
59743
  b.expandByObject(child);
59740
59744
  }
59741
59745
  });
59742
- if (b.isEmpty()) {
59743
- continue;
59744
- }
59745
- b.getCenter(worldObjectCenter);
59746
+ }
59747
+ if (b.isEmpty()) {
59748
+ continue;
59749
+ }
59750
+ b.getCenter(worldObjectCenter);
59746
59751
 
59747
- // Explode around global center or origin
59748
- worldDirection = worldObjectCenter.sub(worldCenterOrOrigin);
59749
- localDirection = group.parent.worldToLocal(worldDirection.clone());
59752
+ // Explode around global center or origin
59753
+ worldDirection = worldObjectCenter.sub(worldCenterOrOrigin);
59754
+ localDirection = group.parent.worldToLocal(worldDirection.clone());
59750
59755
 
59751
- // Use the parent to calculate the local directions
59752
- scaledLocalDirection = group.parent.worldToLocal(
59753
- worldDirection.clone().multiplyScalar(multiplier),
59754
- );
59755
- // and ensure to shift objects at its center and not at its position
59756
- scaledLocalDirection.sub(localDirection);
59757
-
59758
- // build an animation track for the group with this direction
59759
- this.addAnimationTrack(
59760
- id,
59761
- "t",
59762
- [0, duration],
59763
- [[0, 0, 0], scaledLocalDirection.toArray()],
59764
- );
59765
- }
59756
+ // Use the parent to calculate the local directions
59757
+ scaledLocalDirection = group.parent.worldToLocal(
59758
+ worldDirection.clone().multiplyScalar(multiplier),
59759
+ );
59760
+ // and ensure to shift objects at its center and not at its position
59761
+ scaledLocalDirection.sub(localDirection);
59762
+
59763
+ // build an animation track for the group with this direction
59764
+ this.addAnimationTrack(
59765
+ id,
59766
+ "t",
59767
+ [0, duration],
59768
+ [[0, 0, 0], scaledLocalDirection.toArray()],
59769
+ );
59766
59770
  }
59767
59771
  this.initAnimation(duration, speed, "E", false);
59768
59772
  }