@inweb/viewer-three 27.1.2 → 27.1.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.
@@ -5078,16 +5078,14 @@ class DynamicGltfLoader {
5078
5078
  const transformedBox = node.geometryExtents.clone();
5079
5079
  const structureRoot = node.structure ? this.structureRoots.get(node.structure.id) : null;
5080
5080
  if (node.group) {
5081
- const matrices = [];
5082
- let currentGroup = node.group;
5083
- while (currentGroup && currentGroup !== structureRoot) {
5084
- if (currentGroup.matrix && currentGroup.matrixAutoUpdate === false) {
5085
- matrices.unshift(currentGroup.matrix);
5086
- }
5087
- currentGroup = currentGroup.parent;
5081
+ const relativeMatrix = new Matrix4();
5082
+ let currentObject = node.group;
5083
+ while (currentObject && currentObject !== structureRoot) {
5084
+ relativeMatrix.premultiply(currentObject.matrix);
5085
+ currentObject = currentObject.parent;
5088
5086
  }
5089
- for (const matrix of matrices) {
5090
- transformedBox.applyMatrix4(matrix);
5087
+ if (!relativeMatrix.equals(new Matrix4())) {
5088
+ transformedBox.applyMatrix4(relativeMatrix);
5091
5089
  }
5092
5090
  }
5093
5091
  if (structureRoot && structureRoot.matrix) {
@@ -5540,6 +5538,15 @@ class DynamicGltfLoader {
5540
5538
  let currentVertexOffset = 0;
5541
5539
  for (const mesh of group.objects) {
5542
5540
  const geometry = mesh.geometry.clone();
5541
+ const relativeMatrix = new Matrix4();
5542
+ let currentObject = mesh;
5543
+ while (currentObject && currentObject !== rootGroup) {
5544
+ relativeMatrix.premultiply(currentObject.matrix);
5545
+ currentObject = currentObject.parent;
5546
+ }
5547
+ if (!relativeMatrix.equals(new Matrix4())) {
5548
+ geometry.applyMatrix4(relativeMatrix);
5549
+ }
5543
5550
  const handle = mesh.userData.handle;
5544
5551
  if (!this.objectIdToIndex.has(handle)) {
5545
5552
  this.objectIdToIndex.set(handle, this.maxObjectId++);
@@ -5634,7 +5641,16 @@ class DynamicGltfLoader {
5634
5641
  let isEdge = false;
5635
5642
  group.objects.forEach((line) => {
5636
5643
  isEdge = line.userData.isEdge;
5637
- const geometry = line.geometry;
5644
+ const geometry = line.geometry.clone();
5645
+ const relativeMatrix = new Matrix4();
5646
+ let currentObject = line;
5647
+ while (currentObject && currentObject !== rootGroup) {
5648
+ relativeMatrix.premultiply(currentObject.matrix);
5649
+ currentObject = currentObject.parent;
5650
+ }
5651
+ if (!relativeMatrix.equals(new Matrix4())) {
5652
+ geometry.applyMatrix4(relativeMatrix);
5653
+ }
5638
5654
  const positionAttr = geometry.attributes.position;
5639
5655
  const vertexCount = positionAttr.count;
5640
5656
  const handle = line.userData.handle;
@@ -5657,6 +5673,7 @@ class DynamicGltfLoader {
5657
5673
  indices.push(vertexOffset + i, vertexOffset + i + 1);
5658
5674
  }
5659
5675
  vertexOffset += vertexCount;
5676
+ geometry.dispose();
5660
5677
  });
5661
5678
  const geometry = new BufferGeometry();
5662
5679
  geometry.setAttribute("position", new BufferAttribute(positions, 3));
@@ -5728,6 +5745,15 @@ class DynamicGltfLoader {
5728
5745
  for (const line of group.objects) {
5729
5746
  isEdge = line.userData.isEdge;
5730
5747
  const geometry = line.geometry.clone();
5748
+ const relativeMatrix = new Matrix4();
5749
+ let currentObject = line;
5750
+ while (currentObject && currentObject !== rootGroup) {
5751
+ relativeMatrix.premultiply(currentObject.matrix);
5752
+ currentObject = currentObject.parent;
5753
+ }
5754
+ if (!relativeMatrix.equals(new Matrix4())) {
5755
+ geometry.applyMatrix4(relativeMatrix);
5756
+ }
5731
5757
  const handle = line.userData.handle;
5732
5758
  if (!this.objectIdToIndex.has(handle)) {
5733
5759
  this.objectIdToIndex.set(handle, this.maxObjectId++);
@@ -5813,6 +5839,15 @@ class DynamicGltfLoader {
5813
5839
  const handles = new Set();
5814
5840
  for (const points of group.objects) {
5815
5841
  const geometry = points.geometry.clone();
5842
+ const relativeMatrix = new Matrix4();
5843
+ let currentObject = points;
5844
+ while (currentObject && currentObject !== rootGroup) {
5845
+ relativeMatrix.premultiply(currentObject.matrix);
5846
+ currentObject = currentObject.parent;
5847
+ }
5848
+ if (!relativeMatrix.equals(new Matrix4())) {
5849
+ geometry.applyMatrix4(relativeMatrix);
5850
+ }
5816
5851
  geometries.push(geometry);
5817
5852
  optimizedObjects.push(points);
5818
5853
  handles.add(points.userData.handle);