@loaders.gl/i3s 4.0.0-alpha.4 → 4.0.0-alpha.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.
Files changed (186) hide show
  1. package/dist/arcgis-webscene-loader.d.ts +7 -0
  2. package/dist/arcgis-webscene-loader.d.ts.map +1 -0
  3. package/dist/arcgis-webscene-loader.js +28 -0
  4. package/dist/bundle.d.ts +2 -0
  5. package/dist/bundle.d.ts.map +1 -0
  6. package/dist/bundle.js +2 -2
  7. package/dist/dist.min.js +10631 -0
  8. package/dist/es5/arcgis-webscene-loader.js +40 -0
  9. package/dist/es5/arcgis-webscene-loader.js.map +1 -0
  10. package/dist/es5/bundle.js +6 -0
  11. package/dist/es5/bundle.js.map +1 -0
  12. package/dist/es5/i3s-attribute-loader.js +195 -0
  13. package/dist/es5/i3s-attribute-loader.js.map +1 -0
  14. package/dist/es5/i3s-building-scene-layer-loader.js +46 -0
  15. package/dist/es5/i3s-building-scene-layer-loader.js.map +1 -0
  16. package/dist/es5/i3s-content-loader.js +57 -0
  17. package/dist/es5/i3s-content-loader.js.map +1 -0
  18. package/dist/es5/i3s-loader.js +193 -0
  19. package/dist/es5/i3s-loader.js.map +1 -0
  20. package/dist/es5/i3s-node-page-loader.js +39 -0
  21. package/dist/es5/i3s-node-page-loader.js.map +1 -0
  22. package/dist/es5/index.js +61 -0
  23. package/dist/es5/index.js.map +1 -0
  24. package/dist/es5/lib/helpers/i3s-nodepages-tiles.js +312 -0
  25. package/dist/es5/lib/helpers/i3s-nodepages-tiles.js.map +1 -0
  26. package/dist/es5/lib/parsers/constants.js +72 -0
  27. package/dist/es5/lib/parsers/constants.js.map +1 -0
  28. package/dist/es5/lib/parsers/parse-arcgis-webscene.js +158 -0
  29. package/dist/es5/lib/parsers/parse-arcgis-webscene.js.map +1 -0
  30. package/dist/es5/lib/parsers/parse-i3s-attribute.js +76 -0
  31. package/dist/es5/lib/parsers/parse-i3s-attribute.js.map +1 -0
  32. package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js +65 -0
  33. package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -0
  34. package/dist/es5/lib/parsers/parse-i3s-tile-content.js +510 -0
  35. package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -0
  36. package/dist/es5/lib/parsers/parse-i3s.js +116 -0
  37. package/dist/es5/lib/parsers/parse-i3s.js.map +1 -0
  38. package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js +17 -0
  39. package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -0
  40. package/dist/es5/lib/utils/customizeColors.js +159 -0
  41. package/dist/es5/lib/utils/customizeColors.js.map +1 -0
  42. package/dist/es5/lib/utils/url-utils.js +33 -0
  43. package/dist/es5/lib/utils/url-utils.js.map +1 -0
  44. package/dist/es5/types.js +26 -0
  45. package/dist/es5/types.js.map +1 -0
  46. package/dist/es5/workers/i3s-content-nodejs-worker.js +7 -0
  47. package/dist/es5/workers/i3s-content-nodejs-worker.js.map +1 -0
  48. package/dist/es5/workers/i3s-content-worker.js +6 -0
  49. package/dist/es5/workers/i3s-content-worker.js.map +1 -0
  50. package/dist/esm/arcgis-webscene-loader.js +16 -0
  51. package/dist/esm/arcgis-webscene-loader.js.map +1 -0
  52. package/dist/esm/bundle.js +4 -0
  53. package/dist/esm/bundle.js.map +1 -0
  54. package/dist/esm/i3s-attribute-loader.js +119 -0
  55. package/dist/esm/i3s-attribute-loader.js.map +1 -0
  56. package/dist/esm/i3s-building-scene-layer-loader.js +19 -0
  57. package/dist/esm/i3s-building-scene-layer-loader.js.map +1 -0
  58. package/dist/esm/i3s-content-loader.js +31 -0
  59. package/dist/esm/i3s-content-loader.js.map +1 -0
  60. package/dist/esm/i3s-loader.js +87 -0
  61. package/dist/esm/i3s-loader.js.map +1 -0
  62. package/dist/esm/i3s-node-page-loader.js +15 -0
  63. package/dist/esm/i3s-node-page-loader.js.map +1 -0
  64. package/dist/esm/index.js +8 -0
  65. package/dist/esm/index.js.map +1 -0
  66. package/dist/esm/lib/helpers/i3s-nodepages-tiles.js +198 -0
  67. package/dist/esm/lib/helpers/i3s-nodepages-tiles.js.map +1 -0
  68. package/dist/esm/lib/parsers/constants.js +57 -0
  69. package/dist/esm/lib/parsers/constants.js.map +1 -0
  70. package/dist/esm/lib/parsers/parse-arcgis-webscene.js +70 -0
  71. package/dist/esm/lib/parsers/parse-arcgis-webscene.js.map +1 -0
  72. package/dist/esm/lib/parsers/parse-i3s-attribute.js +60 -0
  73. package/dist/esm/lib/parsers/parse-i3s-attribute.js.map +1 -0
  74. package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js +39 -0
  75. package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -0
  76. package/dist/esm/lib/parsers/parse-i3s-tile-content.js +435 -0
  77. package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +1 -0
  78. package/dist/esm/lib/parsers/parse-i3s.js +83 -0
  79. package/dist/esm/lib/parsers/parse-i3s.js.map +1 -0
  80. package/dist/esm/lib/utils/convert-i3s-obb-to-mbs.js +9 -0
  81. package/dist/esm/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -0
  82. package/dist/esm/lib/utils/customizeColors.js +92 -0
  83. package/dist/esm/lib/utils/customizeColors.js.map +1 -0
  84. package/dist/esm/lib/utils/url-utils.js +28 -0
  85. package/dist/esm/lib/utils/url-utils.js.map +1 -0
  86. package/dist/esm/types.js +18 -0
  87. package/dist/esm/types.js.map +1 -0
  88. package/dist/esm/workers/i3s-content-nodejs-worker.js +5 -0
  89. package/dist/esm/workers/i3s-content-nodejs-worker.js.map +1 -0
  90. package/dist/esm/workers/i3s-content-worker.js +4 -0
  91. package/dist/esm/workers/i3s-content-worker.js.map +1 -0
  92. package/dist/i3s-attribute-loader.d.ts +21 -0
  93. package/dist/i3s-attribute-loader.d.ts.map +1 -0
  94. package/dist/i3s-attribute-loader.js +155 -132
  95. package/dist/i3s-building-scene-layer-loader.d.ts +6 -0
  96. package/dist/i3s-building-scene-layer-loader.d.ts.map +1 -0
  97. package/dist/i3s-building-scene-layer-loader.js +23 -18
  98. package/dist/i3s-content-loader.d.ts +6 -0
  99. package/dist/i3s-content-loader.d.ts.map +1 -0
  100. package/dist/i3s-content-loader.js +30 -22
  101. package/dist/i3s-content-nodejs-worker.js +198 -0
  102. package/dist/i3s-content-nodejs-worker.js.map +7 -0
  103. package/dist/i3s-content-worker.js +1523 -1383
  104. package/dist/i3s-loader.d.ts +11 -0
  105. package/dist/i3s-loader.d.ts.map +1 -0
  106. package/dist/i3s-loader.js +88 -83
  107. package/dist/i3s-node-page-loader.d.ts +7 -0
  108. package/dist/i3s-node-page-loader.d.ts.map +1 -0
  109. package/dist/i3s-node-page-loader.js +20 -20
  110. package/dist/index.d.ts +9 -0
  111. package/dist/index.d.ts.map +1 -0
  112. package/dist/index.js +19 -6
  113. package/dist/lib/helpers/i3s-nodepages-tiles.d.ts +74 -0
  114. package/dist/lib/helpers/i3s-nodepages-tiles.d.ts.map +1 -0
  115. package/dist/lib/helpers/i3s-nodepages-tiles.js +232 -219
  116. package/dist/lib/parsers/constants.d.ts +40 -0
  117. package/dist/lib/parsers/constants.d.ts.map +1 -0
  118. package/dist/lib/parsers/constants.js +87 -49
  119. package/dist/lib/parsers/parse-arcgis-webscene.d.ts +7 -0
  120. package/dist/lib/parsers/parse-arcgis-webscene.d.ts.map +1 -0
  121. package/dist/lib/parsers/parse-arcgis-webscene.js +88 -0
  122. package/dist/lib/parsers/parse-i3s-attribute.d.ts +12 -0
  123. package/dist/lib/parsers/parse-i3s-attribute.d.ts.map +1 -0
  124. package/dist/lib/parsers/parse-i3s-attribute.js +87 -62
  125. package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts +9 -0
  126. package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts.map +1 -0
  127. package/dist/lib/parsers/parse-i3s-building-scene-layer.js +41 -38
  128. package/dist/lib/parsers/parse-i3s-tile-content.d.ts +4 -0
  129. package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -0
  130. package/dist/lib/parsers/parse-i3s-tile-content.js +458 -461
  131. package/dist/lib/parsers/parse-i3s.d.ts +6 -0
  132. package/dist/lib/parsers/parse-i3s.d.ts.map +1 -0
  133. package/dist/lib/parsers/parse-i3s.js +92 -73
  134. package/dist/lib/utils/convert-i3s-obb-to-mbs.d.ts +2 -0
  135. package/dist/lib/utils/convert-i3s-obb-to-mbs.d.ts.map +1 -0
  136. package/dist/lib/utils/convert-i3s-obb-to-mbs.js +19 -8
  137. package/dist/lib/utils/customizeColors.d.ts +14 -0
  138. package/dist/lib/utils/customizeColors.d.ts.map +1 -0
  139. package/dist/lib/utils/customizeColors.js +94 -0
  140. package/dist/lib/utils/url-utils.d.ts +22 -0
  141. package/dist/lib/utils/url-utils.d.ts.map +1 -0
  142. package/dist/lib/utils/url-utils.js +41 -29
  143. package/dist/types.d.ts +1064 -0
  144. package/dist/types.d.ts.map +1 -0
  145. package/dist/types.js +20 -2
  146. package/dist/workers/i3s-content-nodejs-worker.d.ts +2 -0
  147. package/dist/workers/i3s-content-nodejs-worker.d.ts.map +1 -0
  148. package/dist/workers/i3s-content-nodejs-worker.js +6 -0
  149. package/dist/workers/i3s-content-worker.d.ts +2 -0
  150. package/dist/workers/i3s-content-worker.d.ts.map +1 -0
  151. package/dist/workers/i3s-content-worker.js +5 -4
  152. package/package.json +17 -17
  153. package/src/arcgis-webscene-loader.ts +31 -0
  154. package/src/i3s-attribute-loader.ts +9 -9
  155. package/src/i3s-content-loader.ts +19 -6
  156. package/src/i3s-loader.ts +22 -13
  157. package/src/i3s-node-page-loader.ts +6 -10
  158. package/src/index.ts +24 -7
  159. package/src/lib/helpers/i3s-nodepages-tiles.ts +84 -57
  160. package/src/lib/parsers/constants.ts +68 -55
  161. package/src/lib/parsers/parse-arcgis-webscene.ts +102 -0
  162. package/src/lib/parsers/parse-i3s-attribute.ts +21 -14
  163. package/src/lib/parsers/parse-i3s-building-scene-layer.ts +2 -1
  164. package/src/lib/parsers/parse-i3s-tile-content.ts +227 -200
  165. package/src/lib/parsers/parse-i3s.ts +55 -39
  166. package/src/lib/utils/customizeColors.ts +134 -0
  167. package/src/lib/utils/url-utils.ts +7 -7
  168. package/src/types.ts +874 -86
  169. package/src/workers/i3s-content-nodejs-worker.ts +5 -0
  170. package/dist/bundle.js.map +0 -1
  171. package/dist/i3s-attribute-loader.js.map +0 -1
  172. package/dist/i3s-building-scene-layer-loader.js.map +0 -1
  173. package/dist/i3s-content-loader.js.map +0 -1
  174. package/dist/i3s-loader.js.map +0 -1
  175. package/dist/i3s-node-page-loader.js.map +0 -1
  176. package/dist/index.js.map +0 -1
  177. package/dist/lib/helpers/i3s-nodepages-tiles.js.map +0 -1
  178. package/dist/lib/parsers/constants.js.map +0 -1
  179. package/dist/lib/parsers/parse-i3s-attribute.js.map +0 -1
  180. package/dist/lib/parsers/parse-i3s-building-scene-layer.js.map +0 -1
  181. package/dist/lib/parsers/parse-i3s-tile-content.js.map +0 -1
  182. package/dist/lib/parsers/parse-i3s.js.map +0 -1
  183. package/dist/lib/utils/convert-i3s-obb-to-mbs.js.map +0 -1
  184. package/dist/lib/utils/url-utils.js.map +0 -1
  185. package/dist/types.js.map +0 -1
  186. package/dist/workers/i3s-content-worker.js.map +0 -1
@@ -0,0 +1,6 @@
1
+ import { I3STilesetHeader, I3STileHeader, I3SMinimalNodeData, Node3DIndexDocument } from '../../types';
2
+ import type { LoaderOptions, LoaderContext } from '@loaders.gl/loader-utils';
3
+ export declare function normalizeTileData(tile: Node3DIndexDocument, context: LoaderContext): I3STileHeader;
4
+ export declare function normalizeTileNonUrlData(tile: I3SMinimalNodeData): I3STileHeader;
5
+ export declare function normalizeTilesetData(tileset: I3STilesetHeader, options: LoaderOptions, context: LoaderContext): Promise<void>;
6
+ //# sourceMappingURL=parse-i3s.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-i3s.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-i3s.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,gBAAgB,EAChB,aAAa,EAEb,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAE3E,wBAAgB,iBAAiB,CAAC,IAAI,EAAG,mBAAmB,EAAE,OAAO,EAAE,aAAa,GAAG,aAAa,CAyBnG;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAG,kBAAkB,GAAG,aAAa,CAmChF;AAED,wBAAsB,oBAAoB,CAAC,OAAO,EAAG,gBAAgB,EAAE,OAAO,EAAG,aAAa,EAAE,OAAO,EAAE,aAAa,iBA0BrH"}
@@ -1,76 +1,95 @@
1
- import { OrientedBoundingBox } from '@math.gl/culling';
2
- import { Ellipsoid } from '@math.gl/geospatial';
3
- import { load } from '@loaders.gl/core';
4
- import { TILE_TYPE, TILE_REFINEMENT, TILESET_TYPE } from '@loaders.gl/tiles';
5
- import I3SNodePagesTiles from '../helpers/i3s-nodepages-tiles';
6
- import { generateTileAttributeUrls, getUrlWithToken } from '../utils/url-utils';
7
- export function normalizeTileData(tile, options, context) {
8
- tile.url = context.url;
9
-
10
- if (tile.featureData) {
11
- tile.featureUrl = "".concat(tile.url, "/").concat(tile.featureData[0].href);
12
- }
13
-
14
- if (tile.geometryData) {
15
- tile.contentUrl = "".concat(tile.url, "/").concat(tile.geometryData[0].href);
16
- }
17
-
18
- if (tile.textureData) {
19
- tile.textureUrl = "".concat(tile.url, "/").concat(tile.textureData[0].href);
20
- }
21
-
22
- if (tile.attributeData) {
23
- tile.attributeUrls = generateTileAttributeUrls(tile);
24
- }
25
-
26
- return normalizeTileNonUrlData(tile);
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.normalizeTilesetData = exports.normalizeTileNonUrlData = exports.normalizeTileData = void 0;
7
+ const culling_1 = require("@math.gl/culling");
8
+ const geospatial_1 = require("@math.gl/geospatial");
9
+ const core_1 = require("@loaders.gl/core");
10
+ const tiles_1 = require("@loaders.gl/tiles");
11
+ const i3s_nodepages_tiles_1 = __importDefault(require("../helpers/i3s-nodepages-tiles"));
12
+ const url_utils_1 = require("../utils/url-utils");
13
+ function normalizeTileData(tile, context) {
14
+ const url = context.url || '';
15
+ let contentUrl;
16
+ if (tile.geometryData) {
17
+ contentUrl = `${url}/${tile.geometryData[0].href}`;
18
+ }
19
+ let textureUrl;
20
+ if (tile.textureData) {
21
+ textureUrl = `${url}/${tile.textureData[0].href}`;
22
+ }
23
+ let attributeUrls;
24
+ if (tile.attributeData) {
25
+ attributeUrls = (0, url_utils_1.generateTileAttributeUrls)(url, tile);
26
+ }
27
+ return normalizeTileNonUrlData({
28
+ ...tile,
29
+ url,
30
+ contentUrl,
31
+ textureUrl,
32
+ attributeUrls,
33
+ isDracoGeometry: false
34
+ });
27
35
  }
28
- export function normalizeTileNonUrlData(tile) {
29
- const box = tile.obb ? [...Ellipsoid.WGS84.cartographicToCartesian(tile.obb.center), ...tile.obb.halfSize, ...tile.obb.quaternion] : undefined;
30
- let sphere;
31
-
32
- if (tile.mbs) {
33
- sphere = [...Ellipsoid.WGS84.cartographicToCartesian(tile.mbs.slice(0, 3)), tile.mbs[3]];
34
- } else if (box) {
35
- const obb = new OrientedBoundingBox().fromCenterHalfSizeQuaternion(box.slice(0, 3), tile.obb.halfSize, tile.obb.quaternion);
36
- const boundingSphere = obb.getBoundingSphere();
37
- sphere = [...boundingSphere.center, boundingSphere.radius];
38
- tile.mbs = [...tile.obb.center, boundingSphere.radius];
39
- }
40
-
41
- tile.boundingVolume = {
42
- sphere,
43
- box
44
- };
45
- tile.lodMetricType = tile.lodSelection[0].metricType;
46
- tile.lodMetricValue = tile.lodSelection[0].maxError;
47
- tile.transformMatrix = tile.transform;
48
- tile.type = TILE_TYPE.MESH;
49
- tile.refine = TILE_REFINEMENT.REPLACE;
50
- return tile;
36
+ exports.normalizeTileData = normalizeTileData;
37
+ function normalizeTileNonUrlData(tile) {
38
+ const boundingVolume = {};
39
+ let mbs = [0, 0, 0, 1];
40
+ if (tile.mbs) {
41
+ mbs = tile.mbs;
42
+ boundingVolume.sphere = [
43
+ ...geospatial_1.Ellipsoid.WGS84.cartographicToCartesian(tile.mbs.slice(0, 3)),
44
+ tile.mbs[3] // radius of sphere
45
+ ];
46
+ }
47
+ else if (tile.obb) {
48
+ boundingVolume.box = [
49
+ ...geospatial_1.Ellipsoid.WGS84.cartographicToCartesian(tile.obb.center),
50
+ ...tile.obb.halfSize,
51
+ ...tile.obb.quaternion // quaternion
52
+ ];
53
+ const obb = new culling_1.OrientedBoundingBox().fromCenterHalfSizeQuaternion(boundingVolume.box.slice(0, 3), tile.obb.halfSize, tile.obb.quaternion);
54
+ const boundingSphere = obb.getBoundingSphere();
55
+ boundingVolume.sphere = [...boundingSphere.center, boundingSphere.radius];
56
+ mbs = [...tile.obb.center, boundingSphere.radius];
57
+ }
58
+ const lodMetricType = tile.lodSelection?.[0].metricType;
59
+ const lodMetricValue = tile.lodSelection?.[0].maxError;
60
+ const transformMatrix = tile.transform;
61
+ const type = tiles_1.TILE_TYPE.MESH;
62
+ /**
63
+ * I3S specification supports only REPLACE
64
+ */
65
+ const refine = tiles_1.TILE_REFINEMENT.REPLACE;
66
+ return { ...tile, mbs, boundingVolume, lodMetricType, lodMetricValue, transformMatrix, type, refine };
51
67
  }
52
- export async function normalizeTilesetData(tileset, options, context) {
53
- tileset.url = context.url;
54
-
55
- if (tileset.nodePages) {
56
- tileset.nodePagesTile = new I3SNodePagesTiles(tileset, options);
57
- tileset.root = await tileset.nodePagesTile.formTileFromNodePages(0);
58
- } else {
59
- var _options$i3s;
60
-
61
- const rootNodeUrl = getUrlWithToken("".concat(tileset.url, "/nodes/root"), (_options$i3s = options.i3s) === null || _options$i3s === void 0 ? void 0 : _options$i3s.token);
62
- tileset.root = await load(rootNodeUrl, tileset.loader, {
63
- i3s: {
64
- loadContent: false,
65
- isTileHeader: true,
66
- isTileset: false
67
- }
68
- });
69
- }
70
-
71
- tileset.basePath = tileset.url;
72
- tileset.type = TILESET_TYPE.I3S;
73
- tileset.lodMetricType = tileset.root.lodMetricType;
74
- tileset.lodMetricValue = tileset.root.lodMetricValue;
68
+ exports.normalizeTileNonUrlData = normalizeTileNonUrlData;
69
+ async function normalizeTilesetData(tileset, options, context) {
70
+ tileset.url = context.url;
71
+ if (tileset.nodePages) {
72
+ tileset.nodePagesTile = new i3s_nodepages_tiles_1.default(tileset, options);
73
+ tileset.root = tileset.nodePagesTile.formTileFromNodePages(0);
74
+ }
75
+ else {
76
+ // @ts-expect-error options is not properly typed
77
+ const rootNodeUrl = (0, url_utils_1.getUrlWithToken)(`${tileset.url}/nodes/root`, options.i3s?.token);
78
+ // eslint-disable-next-line no-use-before-define
79
+ tileset.root = await (0, core_1.load)(rootNodeUrl, tileset.loader, {
80
+ ...options,
81
+ i3s: {
82
+ // @ts-expect-error options is not properly typed
83
+ ...options.i3s,
84
+ loadContent: false, isTileHeader: true, isTileset: false
85
+ }
86
+ });
87
+ }
88
+ // base path that non-absolute paths in tileset are relative to.
89
+ tileset.basePath = tileset.url;
90
+ tileset.type = tiles_1.TILESET_TYPE.I3S;
91
+ // populate from root node
92
+ tileset.lodMetricType = tileset.root.lodMetricType;
93
+ tileset.lodMetricValue = tileset.root.lodMetricValue;
75
94
  }
76
- //# sourceMappingURL=parse-i3s.js.map
95
+ exports.normalizeTilesetData = normalizeTilesetData;
@@ -0,0 +1,2 @@
1
+ export declare function convertI3SObbToMbs(obb: any): any[];
2
+ //# sourceMappingURL=convert-i3s-obb-to-mbs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-i3s-obb-to-mbs.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/convert-i3s-obb-to-mbs.ts"],"names":[],"mappings":"AAGA,wBAAgB,kBAAkB,CAAC,GAAG,KAAA,SAgBrC"}
@@ -1,9 +1,20 @@
1
- import { BoundingSphere } from '@math.gl/culling';
2
- import { Ellipsoid } from '@math.gl/geospatial';
3
- export function convertI3SObbToMbs(obb) {
4
- const halfSize = obb.halfSize;
5
- const centerCartesian = Ellipsoid.WGS84.cartographicToCartesian(obb.center);
6
- const sphere = new BoundingSphere().fromCornerPoints([centerCartesian[0] - halfSize[0], centerCartesian[1] - halfSize[1], centerCartesian[2] - halfSize[2]], [centerCartesian[0] + halfSize[0], centerCartesian[1] + halfSize[1], centerCartesian[2] + halfSize[2]]);
7
- return [...obb.center, sphere.radius];
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertI3SObbToMbs = void 0;
4
+ const culling_1 = require("@math.gl/culling");
5
+ const geospatial_1 = require("@math.gl/geospatial");
6
+ function convertI3SObbToMbs(obb) {
7
+ const halfSize = obb.halfSize;
8
+ const centerCartesian = geospatial_1.Ellipsoid.WGS84.cartographicToCartesian(obb.center);
9
+ const sphere = new culling_1.BoundingSphere().fromCornerPoints([
10
+ centerCartesian[0] - halfSize[0],
11
+ centerCartesian[1] - halfSize[1],
12
+ centerCartesian[2] - halfSize[2]
13
+ ], [
14
+ centerCartesian[0] + halfSize[0],
15
+ centerCartesian[1] + halfSize[1],
16
+ centerCartesian[2] + halfSize[2]
17
+ ]);
18
+ return [...obb.center, sphere.radius];
8
19
  }
9
- //# sourceMappingURL=convert-i3s-obb-to-mbs.js.map
20
+ exports.convertI3SObbToMbs = convertI3SObbToMbs;
@@ -0,0 +1,14 @@
1
+ import type { MeshAttribute } from '@loaders.gl/schema';
2
+ import type { I3STileOptions, I3STilesetOptions } from '../../types';
3
+ import { I3SLoaderOptions } from '../../i3s-loader';
4
+ /**
5
+ * Modify vertex colors array to visualize 3D objects in a attribute driven way
6
+ * @param colors - vertex colors attribute
7
+ * @param featureIds - feature Ids attribute
8
+ * @param tileOptions - tile - related options
9
+ * @param tilesetOptions - tileset-related options
10
+ * @param options - loader options
11
+ * @returns midified colors attribute
12
+ */
13
+ export declare function customizeColors(colors: MeshAttribute, featureIds: MeshAttribute, tileOptions: I3STileOptions, tilesetOptions: I3STilesetOptions, options?: I3SLoaderOptions): Promise<MeshAttribute>;
14
+ //# sourceMappingURL=customizeColors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customizeColors.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/customizeColors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAQ,cAAc,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAC;AAI1E,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAGlD;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,aAAa,EACzB,WAAW,EAAE,cAAc,EAC3B,cAAc,EAAE,iBAAiB,EACjC,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,aAAa,CAAC,CA8DxB"}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.customizeColors = void 0;
4
+ const core_1 = require("@loaders.gl/core");
5
+ const i3s_attribute_loader_1 = require("../../i3s-attribute-loader");
6
+ const url_utils_1 = require("../utils/url-utils");
7
+ /**
8
+ * Modify vertex colors array to visualize 3D objects in a attribute driven way
9
+ * @param colors - vertex colors attribute
10
+ * @param featureIds - feature Ids attribute
11
+ * @param tileOptions - tile - related options
12
+ * @param tilesetOptions - tileset-related options
13
+ * @param options - loader options
14
+ * @returns midified colors attribute
15
+ */
16
+ async function customizeColors(colors, featureIds, tileOptions, tilesetOptions, options) {
17
+ if (!options?.i3s?.colorsByAttribute) {
18
+ return colors;
19
+ }
20
+ const colorizeAttributeField = tilesetOptions.fields.find(({ name }) => name === options?.i3s?.colorsByAttribute?.attributeName);
21
+ if (!colorizeAttributeField ||
22
+ !['esriFieldTypeDouble', 'esriFieldTypeInteger', 'esriFieldTypeSmallInteger'].includes(colorizeAttributeField.type)) {
23
+ return colors;
24
+ }
25
+ const colorizeAttributeData = await loadFeatureAttributeData(colorizeAttributeField.name, tileOptions, tilesetOptions, options);
26
+ if (!colorizeAttributeData) {
27
+ return colors;
28
+ }
29
+ const objectIdField = tilesetOptions.fields.find(({ type }) => type === 'esriFieldTypeOID');
30
+ if (!objectIdField) {
31
+ return colors;
32
+ }
33
+ const objectIdAttributeData = await loadFeatureAttributeData(objectIdField.name, tileOptions, tilesetOptions, options);
34
+ if (!objectIdAttributeData) {
35
+ return colors;
36
+ }
37
+ const attributeValuesMap = {};
38
+ // @ts-expect-error
39
+ for (let i = 0; i < objectIdAttributeData[objectIdField.name].length; i++) {
40
+ // @ts-expect-error
41
+ attributeValuesMap[objectIdAttributeData[objectIdField.name][i]] = calculateColorForAttribute(
42
+ // @ts-expect-error
43
+ colorizeAttributeData[colorizeAttributeField.name][i], options);
44
+ }
45
+ for (let i = 0; i < featureIds.value.length; i++) {
46
+ const color = attributeValuesMap[featureIds.value[i]];
47
+ if (!color) {
48
+ continue; // eslint-disable-line no-continue
49
+ }
50
+ colors.value.set(color, i * 4);
51
+ }
52
+ return colors;
53
+ }
54
+ exports.customizeColors = customizeColors;
55
+ /**
56
+ * Calculate rgba color from the attribute value
57
+ * @param attributeValue - value of the attribute
58
+ * @param options - loader options
59
+ * @returns - color array for a specific attribute value
60
+ */
61
+ function calculateColorForAttribute(attributeValue, options) {
62
+ if (!options?.i3s?.colorsByAttribute) {
63
+ return [255, 255, 255, 255];
64
+ }
65
+ const { minValue, maxValue, minColor, maxColor } = options.i3s.colorsByAttribute;
66
+ const rate = (attributeValue - minValue) / (maxValue - minValue);
67
+ const color = [255, 255, 255, 255];
68
+ for (let i = 0; i < minColor.length; i++) {
69
+ color[i] = Math.round((maxColor[i] - minColor[i]) * rate + minColor[i]);
70
+ }
71
+ return color;
72
+ }
73
+ /**
74
+ * Load feature attribute data from the ArcGIS rest service
75
+ * @param attributeName - attribute name
76
+ * @param tileOptions - tile-related options
77
+ * @param tilesetOptions - tileset-related options
78
+ * @param options - loader options
79
+ * @returns - Array-like list of the attribute values
80
+ */
81
+ async function loadFeatureAttributeData(attributeName, { attributeUrls }, { attributeStorageInfo }, options) {
82
+ const attributeIndex = attributeStorageInfo.findIndex(({ name }) => attributeName === name);
83
+ if (attributeIndex === -1) {
84
+ return null;
85
+ }
86
+ const objectIdAttributeUrl = (0, url_utils_1.getUrlWithToken)(attributeUrls[attributeIndex], options?.i3s?.token);
87
+ const attributeType = (0, i3s_attribute_loader_1.getAttributeValueType)(attributeStorageInfo[attributeIndex]);
88
+ const objectIdAttributeData = await (0, core_1.load)(objectIdAttributeUrl, i3s_attribute_loader_1.I3SAttributeLoader, {
89
+ attributeName,
90
+ attributeType
91
+ });
92
+ // @ts-expect-error TODO action engine
93
+ return objectIdAttributeData;
94
+ }
@@ -0,0 +1,22 @@
1
+ import { Node3DIndexDocument } from '../../types';
2
+ /**
3
+ * Generates url with token if it is exists.
4
+ * @param url
5
+ * @param token
6
+ * @returns
7
+ */
8
+ export declare function getUrlWithToken(url: string, token?: string | null): string;
9
+ /**
10
+ * Generates attribute urls for tile.
11
+ * @param tile
12
+ * @returns list of attribute urls
13
+ */
14
+ export declare function generateTileAttributeUrls(url: string, tile: Node3DIndexDocument): string[];
15
+ /**
16
+ * Generates attribute urls for tileset based on tileset and resource
17
+ * @param {Object} tileset
18
+ * @param {number} resource
19
+ * @returns {Array}
20
+ */
21
+ export declare function generateTilesetAttributeUrls(tileset: any, resource: any): string[];
22
+ //# sourceMappingURL=url-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/url-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,aAAa,CAAC;AAEhD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,MAAM,GAAG,IAAW,GAAG,MAAM,CAEhF;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,GAAG,MAAM,EAAE,CAU1F;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,KAAA,EAAE,QAAQ,KAAA,YAU7D"}
@@ -1,32 +1,44 @@
1
- export function getUrlWithToken(url, token = null) {
2
- return token ? "".concat(url, "?token=").concat(token) : url;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateTilesetAttributeUrls = exports.generateTileAttributeUrls = exports.getUrlWithToken = void 0;
4
+ /**
5
+ * Generates url with token if it is exists.
6
+ * @param url
7
+ * @param token
8
+ * @returns
9
+ */
10
+ function getUrlWithToken(url, token = null) {
11
+ return token ? `${url}?token=${token}` : url;
3
12
  }
4
- export function generateTileAttributeUrls(tile) {
5
- const {
6
- url,
7
- attributeData
8
- } = tile;
9
- const attributeUrls = [];
10
-
11
- for (let index = 0; index < attributeData.length; index++) {
12
- const attributeUrl = attributeData[index].href.replace('./', '');
13
- attributeUrls.push("".concat(url, "/").concat(attributeUrl));
14
- }
15
-
16
- return attributeUrls;
13
+ exports.getUrlWithToken = getUrlWithToken;
14
+ /**
15
+ * Generates attribute urls for tile.
16
+ * @param tile
17
+ * @returns list of attribute urls
18
+ */
19
+ function generateTileAttributeUrls(url, tile) {
20
+ const { attributeData = [] } = tile;
21
+ const attributeUrls = [];
22
+ for (let index = 0; index < attributeData.length; index++) {
23
+ const attributeUrl = attributeData[index].href.replace('./', '');
24
+ attributeUrls.push(`${url}/${attributeUrl}`);
25
+ }
26
+ return attributeUrls;
17
27
  }
18
- export function generateTilesetAttributeUrls(tileset, resource) {
19
- const attributeUrls = [];
20
- const {
21
- attributeStorageInfo,
22
- url
23
- } = tileset;
24
-
25
- for (let index = 0; index < attributeStorageInfo.length; index++) {
26
- const fileName = attributeStorageInfo[index].key;
27
- attributeUrls.push("".concat(url, "/nodes/").concat(resource, "/attributes/").concat(fileName, "/0"));
28
- }
29
-
30
- return attributeUrls;
28
+ exports.generateTileAttributeUrls = generateTileAttributeUrls;
29
+ /**
30
+ * Generates attribute urls for tileset based on tileset and resource
31
+ * @param {Object} tileset
32
+ * @param {number} resource
33
+ * @returns {Array}
34
+ */
35
+ function generateTilesetAttributeUrls(tileset, resource) {
36
+ const attributeUrls = [];
37
+ const { attributeStorageInfo, url } = tileset;
38
+ for (let index = 0; index < attributeStorageInfo.length; index++) {
39
+ const fileName = attributeStorageInfo[index].key;
40
+ attributeUrls.push(`${url}/nodes/${resource}/attributes/${fileName}/0`);
41
+ }
42
+ return attributeUrls;
31
43
  }
32
- //# sourceMappingURL=url-utils.js.map
44
+ exports.generateTilesetAttributeUrls = generateTilesetAttributeUrls;