@itwin/core-frontend 5.8.0-dev.1 → 5.8.0-dev.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/lib/cjs/internal/tile/RealityTileLoader.d.ts.map +1 -1
  3. package/lib/cjs/internal/tile/RealityTileLoader.js +26 -5
  4. package/lib/cjs/internal/tile/RealityTileLoader.js.map +1 -1
  5. package/lib/cjs/internal/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.d.ts.map +1 -1
  6. package/lib/cjs/internal/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js +7 -1
  7. package/lib/cjs/internal/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js.map +1 -1
  8. package/lib/cjs/internal/tile/map/WmtsCapabilities.js +1 -1
  9. package/lib/cjs/internal/tile/map/WmtsCapabilities.js.map +1 -1
  10. package/lib/cjs/tile/GltfReader.d.ts +4 -2
  11. package/lib/cjs/tile/GltfReader.d.ts.map +1 -1
  12. package/lib/cjs/tile/GltfReader.js +54 -4
  13. package/lib/cjs/tile/GltfReader.js.map +1 -1
  14. package/lib/cjs/tile/map/ImageryTileTree.js +7 -7
  15. package/lib/cjs/tile/map/ImageryTileTree.js.map +1 -1
  16. package/lib/cjs/tools/MeasureTool.d.ts.map +1 -1
  17. package/lib/cjs/tools/MeasureTool.js +18 -1
  18. package/lib/cjs/tools/MeasureTool.js.map +1 -1
  19. package/lib/cjs/tools/PrimitiveTool.d.ts.map +1 -1
  20. package/lib/cjs/tools/PrimitiveTool.js +7 -1
  21. package/lib/cjs/tools/PrimitiveTool.js.map +1 -1
  22. package/lib/cjs/tools/ToolAdmin.d.ts +1 -0
  23. package/lib/cjs/tools/ToolAdmin.d.ts.map +1 -1
  24. package/lib/cjs/tools/ToolAdmin.js +32 -18
  25. package/lib/cjs/tools/ToolAdmin.js.map +1 -1
  26. package/lib/esm/internal/tile/RealityTileLoader.d.ts.map +1 -1
  27. package/lib/esm/internal/tile/RealityTileLoader.js +26 -5
  28. package/lib/esm/internal/tile/RealityTileLoader.js.map +1 -1
  29. package/lib/esm/internal/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.d.ts.map +1 -1
  30. package/lib/esm/internal/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js +7 -1
  31. package/lib/esm/internal/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js.map +1 -1
  32. package/lib/esm/internal/tile/map/WmtsCapabilities.js +1 -1
  33. package/lib/esm/internal/tile/map/WmtsCapabilities.js.map +1 -1
  34. package/lib/esm/tile/GltfReader.d.ts +4 -2
  35. package/lib/esm/tile/GltfReader.d.ts.map +1 -1
  36. package/lib/esm/tile/GltfReader.js +54 -4
  37. package/lib/esm/tile/GltfReader.js.map +1 -1
  38. package/lib/esm/tile/map/ImageryTileTree.js +8 -8
  39. package/lib/esm/tile/map/ImageryTileTree.js.map +1 -1
  40. package/lib/esm/tools/MeasureTool.d.ts.map +1 -1
  41. package/lib/esm/tools/MeasureTool.js +18 -1
  42. package/lib/esm/tools/MeasureTool.js.map +1 -1
  43. package/lib/esm/tools/PrimitiveTool.d.ts.map +1 -1
  44. package/lib/esm/tools/PrimitiveTool.js +7 -1
  45. package/lib/esm/tools/PrimitiveTool.js.map +1 -1
  46. package/lib/esm/tools/ToolAdmin.d.ts +1 -0
  47. package/lib/esm/tools/ToolAdmin.d.ts.map +1 -1
  48. package/lib/esm/tools/ToolAdmin.js +32 -18
  49. package/lib/esm/tools/ToolAdmin.js.map +1 -1
  50. package/package.json +20 -20
@@ -200,7 +200,7 @@ export class GltfReaderProps {
200
200
  }
201
201
  /** The GltfMeshData contains the raw GLTF mesh data. If the data is suitable to create a [[RealityMesh]] directly, basically in the quantized format produced by
202
202
  * ContextCapture, then a RealityMesh is created directly from this data. Otherwise, the mesh primitive is populated from the raw data and a MeshPrimitive
203
- * is generated. The MeshPrimitve path is much less efficient but should be rarely used.
203
+ * is generated. The MeshPrimitive path is much less efficient but should be rarely used.
204
204
  *
205
205
  * @internal
206
206
  */
@@ -487,7 +487,8 @@ export class GltfReader {
487
487
  }),
488
488
  };
489
489
  }
490
- readGltfAndCreateGeometry(transformToRoot, needNormals = false, needParams = false) {
490
+ async readGltfAndCreateGeometry(transformToRoot, needNormals = false, needParams = false) {
491
+ await this.resolveResources();
491
492
  const transformStack = new TransformStack(this.getTileTransform(transformToRoot));
492
493
  const polyfaces = [];
493
494
  for (const nodeKey of this._sceneNodes) {
@@ -722,9 +723,18 @@ export class GltfReader {
722
723
  }
723
724
  }
724
725
  polyfaceFromGltfMesh(mesh, transform, needNormals, needParams) {
725
- if (!mesh.pointQParams || !mesh.points || !mesh.indices)
726
+ if (mesh.pointQParams && mesh.points && mesh.indices)
727
+ return this.polyfaceFromQuantizedData(mesh.pointQParams, mesh.points, mesh.indices, mesh.normals, mesh.uvQParams, mesh.uvs, transform, needNormals, needParams);
728
+ const meshPrim = mesh.primitive;
729
+ const triangles = meshPrim.triangles;
730
+ const points = meshPrim.points;
731
+ if (!triangles || triangles.isEmpty || points.length === 0)
726
732
  return undefined;
727
- const { points, pointQParams, normals, uvs, uvQParams, indices } = mesh;
733
+ // This will likely only be the case for Draco-compressed meshes-- see where readDracoMeshPrimitive is called within readMeshPrimitive
734
+ // That is the only case where mesh.primitive is populated but mesh.pointQParams, mesh.points, & mesh.indices are not
735
+ return this.polyfaceFromMeshPrimitive(triangles, points, meshPrim.normals, meshPrim.uvParams, transform, needNormals, needParams);
736
+ }
737
+ polyfaceFromQuantizedData(pointQParams, points, indices, normals, uvQParams, uvs, transform, needNormals, needParams) {
728
738
  const includeNormals = needNormals && undefined !== normals;
729
739
  const includeParams = needParams && undefined !== uvQParams && undefined !== uvs;
730
740
  const polyface = IndexedPolyface.create(includeNormals, includeParams);
@@ -752,6 +762,46 @@ export class GltfReader {
752
762
  }
753
763
  return polyface;
754
764
  }
765
+ polyfaceFromMeshPrimitive(triangles, points, normals, uvParams, transform, needNormals, needParams) {
766
+ const includeNormals = needNormals && normals.length > 0;
767
+ const includeParams = needParams && uvParams.length > 0;
768
+ const polyface = IndexedPolyface.create(includeNormals, includeParams);
769
+ if (points instanceof QPoint3dList) {
770
+ for (let i = 0; i < points.length; i++) {
771
+ const point = points.unquantize(i);
772
+ if (transform)
773
+ transform.multiplyPoint3d(point, point);
774
+ polyface.addPoint(point);
775
+ }
776
+ }
777
+ else {
778
+ const center = points.range.center;
779
+ for (const pt of points) {
780
+ const point = pt.plus(center);
781
+ if (transform)
782
+ transform.multiplyPoint3d(point, point);
783
+ polyface.addPoint(point);
784
+ }
785
+ }
786
+ if (includeNormals)
787
+ for (const normal of normals)
788
+ polyface.addNormal(OctEncodedNormal.decodeValue(normal.value));
789
+ if (includeParams)
790
+ for (const uv of uvParams)
791
+ polyface.addParam(uv);
792
+ const indices = triangles.indices;
793
+ let j = 0;
794
+ for (const index of indices) {
795
+ polyface.addPointIndex(index);
796
+ if (includeNormals)
797
+ polyface.addNormalIndex(index);
798
+ if (includeParams)
799
+ polyface.addParamIndex(index);
800
+ if (0 === (++j % 3))
801
+ polyface.terminateFacet();
802
+ }
803
+ return polyface;
804
+ }
755
805
  // ###TODO what is the actual type of `json`?
756
806
  getBufferView(json, accessorName) {
757
807
  try {