@loaders.gl/gltf 4.0.0-beta.2 → 4.0.0-beta.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 (247) hide show
  1. package/dist/{dist.min.js → dist.dev.js} +3448 -3448
  2. package/dist/{esm/glb-loader.js → glb-loader.js} +2 -2
  3. package/dist/glb-loader.js.map +1 -0
  4. package/dist/{esm/glb-writer.js → glb-writer.js} +2 -2
  5. package/dist/glb-writer.js.map +1 -0
  6. package/dist/{esm/gltf-loader.js → gltf-loader.js} +2 -2
  7. package/dist/gltf-loader.js.map +1 -0
  8. package/dist/{esm/gltf-writer.js → gltf-writer.js} +2 -2
  9. package/dist/gltf-writer.js.map +1 -0
  10. package/dist/index.cjs +3558 -0
  11. package/dist/index.js +13 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/{esm/lib → lib}/api/gltf-extensions.js +11 -11
  14. package/dist/lib/api/gltf-extensions.js.map +1 -0
  15. package/dist/lib/api/gltf-scenegraph.d.ts.map +1 -1
  16. package/dist/{esm/lib → lib}/api/gltf-scenegraph.js +9 -17
  17. package/dist/lib/api/gltf-scenegraph.js.map +1 -0
  18. package/dist/{esm/lib → lib}/api/normalize-gltf-v1.js +7 -8
  19. package/dist/lib/api/normalize-gltf-v1.js.map +1 -0
  20. package/dist/{esm/lib → lib}/api/post-process-gltf.js +19 -20
  21. package/dist/lib/api/post-process-gltf.js.map +1 -0
  22. package/dist/lib/encoders/encode-glb.js.map +1 -0
  23. package/dist/{esm/lib → lib}/encoders/encode-gltf.js +1 -1
  24. package/dist/lib/encoders/encode-gltf.js.map +1 -0
  25. package/dist/lib/extensions/EXT_mesh_features.d.ts.map +1 -1
  26. package/dist/{esm/lib → lib}/extensions/EXT_mesh_features.js +7 -5
  27. package/dist/lib/extensions/EXT_mesh_features.js.map +1 -0
  28. package/dist/{esm/lib → lib}/extensions/EXT_meshopt_compression.js +2 -2
  29. package/dist/lib/extensions/EXT_meshopt_compression.js.map +1 -0
  30. package/dist/{esm/lib → lib}/extensions/EXT_structural_metadata.js +7 -7
  31. package/dist/lib/extensions/EXT_structural_metadata.js.map +1 -0
  32. package/dist/{esm/lib → lib}/extensions/EXT_texture_webp.js +2 -2
  33. package/dist/lib/extensions/EXT_texture_webp.js.map +1 -0
  34. package/dist/{esm/lib → lib}/extensions/KHR_binary_gltf.js +1 -1
  35. package/dist/lib/extensions/KHR_binary_gltf.js.map +1 -0
  36. package/dist/{esm/lib → lib}/extensions/KHR_draco_mesh_compression.js +2 -2
  37. package/dist/lib/extensions/KHR_draco_mesh_compression.js.map +1 -0
  38. package/dist/{esm/lib → lib}/extensions/KHR_texture_basisu.js +1 -1
  39. package/dist/lib/extensions/KHR_texture_basisu.js.map +1 -0
  40. package/dist/{esm/lib → lib}/extensions/KHR_texture_transform.js +6 -6
  41. package/dist/lib/extensions/KHR_texture_transform.js.map +1 -0
  42. package/dist/{esm/lib → lib}/extensions/deprecated/EXT_feature_metadata.js +3 -3
  43. package/dist/lib/extensions/deprecated/EXT_feature_metadata.js.map +1 -0
  44. package/dist/{esm/lib → lib}/extensions/deprecated/KHR_lights_punctual.js +2 -2
  45. package/dist/lib/extensions/deprecated/KHR_lights_punctual.js.map +1 -0
  46. package/dist/{esm/lib → lib}/extensions/deprecated/KHR_materials_unlit.js +1 -1
  47. package/dist/lib/extensions/deprecated/KHR_materials_unlit.js.map +1 -0
  48. package/dist/{esm/lib → lib}/extensions/deprecated/KHR_techniques_webgl.js +1 -1
  49. package/dist/lib/extensions/deprecated/KHR_techniques_webgl.js.map +1 -0
  50. package/dist/lib/extensions/utils/3d-tiles-utils.d.ts +1 -1
  51. package/dist/lib/extensions/utils/3d-tiles-utils.d.ts.map +1 -1
  52. package/dist/{esm/lib → lib}/extensions/utils/3d-tiles-utils.js +6 -9
  53. package/dist/lib/extensions/utils/3d-tiles-utils.js.map +1 -0
  54. package/dist/lib/gltf-utils/get-typed-array.d.ts +10 -0
  55. package/dist/lib/gltf-utils/get-typed-array.d.ts.map +1 -1
  56. package/dist/lib/gltf-utils/get-typed-array.js +51 -0
  57. package/dist/lib/gltf-utils/get-typed-array.js.map +1 -0
  58. package/dist/{esm/lib → lib}/gltf-utils/gltf-attribute-utils.js +1 -1
  59. package/dist/lib/gltf-utils/gltf-attribute-utils.js.map +1 -0
  60. package/dist/lib/gltf-utils/gltf-constants.js.map +1 -0
  61. package/dist/lib/gltf-utils/gltf-utils.d.ts +2 -2
  62. package/dist/lib/gltf-utils/gltf-utils.d.ts.map +1 -1
  63. package/dist/{esm/lib → lib}/gltf-utils/gltf-utils.js +7 -32
  64. package/dist/lib/gltf-utils/gltf-utils.js.map +1 -0
  65. package/dist/{esm/lib → lib}/gltf-utils/resolve-url.js +1 -1
  66. package/dist/lib/gltf-utils/resolve-url.js.map +1 -0
  67. package/dist/{esm/lib → lib}/parsers/parse-glb.js +6 -2
  68. package/dist/lib/parsers/parse-glb.js.map +1 -0
  69. package/dist/{esm/lib → lib}/parsers/parse-gltf.js +7 -7
  70. package/dist/lib/parsers/parse-gltf.js.map +1 -0
  71. package/dist/lib/types/glb-types.js.map +1 -0
  72. package/dist/lib/types/gltf-ext-feature-metadata-schema.js.map +1 -0
  73. package/dist/lib/types/gltf-ext-mesh-features-schema.d.ts +3 -1
  74. package/dist/lib/types/gltf-ext-mesh-features-schema.d.ts.map +1 -1
  75. package/dist/lib/types/gltf-ext-mesh-features-schema.js.map +1 -0
  76. package/dist/lib/types/gltf-ext-structural-metadata-schema.js.map +1 -0
  77. package/dist/lib/types/gltf-json-schema.d.ts +7 -0
  78. package/dist/lib/types/gltf-json-schema.d.ts.map +1 -1
  79. package/dist/lib/types/gltf-json-schema.js.map +1 -0
  80. package/dist/lib/types/gltf-postprocessed-schema.js.map +1 -0
  81. package/dist/lib/types/gltf-types.d.ts +1 -1
  82. package/dist/lib/types/gltf-types.d.ts.map +1 -1
  83. package/dist/lib/types/gltf-types.js.map +1 -0
  84. package/dist/lib/utils/assert.js.map +1 -0
  85. package/dist/lib/utils/version.js +2 -0
  86. package/dist/lib/utils/version.js.map +1 -0
  87. package/dist/{esm/meshopt → meshopt}/meshopt-decoder.js +1 -1
  88. package/dist/meshopt/meshopt-decoder.js.map +1 -0
  89. package/dist/{esm/webp → webp}/webp.js +1 -1
  90. package/dist/webp/webp.js.map +1 -0
  91. package/package.json +19 -11
  92. package/src/lib/api/gltf-scenegraph.ts +5 -17
  93. package/src/lib/extensions/EXT_mesh_features.ts +4 -2
  94. package/src/lib/extensions/utils/3d-tiles-utils.ts +17 -17
  95. package/src/lib/gltf-utils/get-typed-array.ts +53 -14
  96. package/src/lib/gltf-utils/gltf-utils.ts +3 -39
  97. package/src/lib/types/gltf-ext-mesh-features-schema.ts +3 -1
  98. package/src/lib/types/gltf-json-schema.ts +7 -0
  99. package/src/lib/types/gltf-types.ts +1 -1
  100. package/dist/bundle.d.ts +0 -2
  101. package/dist/bundle.d.ts.map +0 -1
  102. package/dist/es5/bundle.js +0 -6
  103. package/dist/es5/bundle.js.map +0 -1
  104. package/dist/es5/glb-loader.js +0 -54
  105. package/dist/es5/glb-loader.js.map +0 -1
  106. package/dist/es5/glb-writer.js +0 -34
  107. package/dist/es5/glb-writer.js.map +0 -1
  108. package/dist/es5/gltf-loader.js +0 -81
  109. package/dist/es5/gltf-loader.js.map +0 -1
  110. package/dist/es5/gltf-writer.js +0 -35
  111. package/dist/es5/gltf-writer.js.map +0 -1
  112. package/dist/es5/index.js +0 -88
  113. package/dist/es5/index.js.map +0 -1
  114. package/dist/es5/lib/api/gltf-extensions.js +0 -111
  115. package/dist/es5/lib/api/gltf-extensions.js.map +0 -1
  116. package/dist/es5/lib/api/gltf-scenegraph.js +0 -598
  117. package/dist/es5/lib/api/gltf-scenegraph.js.map +0 -1
  118. package/dist/es5/lib/api/normalize-gltf-v1.js +0 -331
  119. package/dist/es5/lib/api/normalize-gltf-v1.js.map +0 -1
  120. package/dist/es5/lib/api/post-process-gltf.js +0 -470
  121. package/dist/es5/lib/api/post-process-gltf.js.map +0 -1
  122. package/dist/es5/lib/encoders/encode-glb.js +0 -61
  123. package/dist/es5/lib/encoders/encode-glb.js.map +0 -1
  124. package/dist/es5/lib/encoders/encode-gltf.js +0 -20
  125. package/dist/es5/lib/encoders/encode-gltf.js.map +0 -1
  126. package/dist/es5/lib/extensions/EXT_mesh_features.js +0 -99
  127. package/dist/es5/lib/extensions/EXT_mesh_features.js.map +0 -1
  128. package/dist/es5/lib/extensions/EXT_meshopt_compression.js +0 -94
  129. package/dist/es5/lib/extensions/EXT_meshopt_compression.js.map +0 -1
  130. package/dist/es5/lib/extensions/EXT_structural_metadata.js +0 -375
  131. package/dist/es5/lib/extensions/EXT_structural_metadata.js.map +0 -1
  132. package/dist/es5/lib/extensions/EXT_texture_webp.js +0 -43
  133. package/dist/es5/lib/extensions/EXT_texture_webp.js.map +0 -1
  134. package/dist/es5/lib/extensions/KHR_binary_gltf.js +0 -39
  135. package/dist/es5/lib/extensions/KHR_binary_gltf.js.map +0 -1
  136. package/dist/es5/lib/extensions/KHR_draco_mesh_compression.js +0 -246
  137. package/dist/es5/lib/extensions/KHR_draco_mesh_compression.js.map +0 -1
  138. package/dist/es5/lib/extensions/KHR_texture_basisu.js +0 -36
  139. package/dist/es5/lib/extensions/KHR_texture_basisu.js.map +0 -1
  140. package/dist/es5/lib/extensions/KHR_texture_transform.js +0 -231
  141. package/dist/es5/lib/extensions/KHR_texture_transform.js.map +0 -1
  142. package/dist/es5/lib/extensions/deprecated/EXT_feature_metadata.js +0 -260
  143. package/dist/es5/lib/extensions/deprecated/EXT_feature_metadata.js.map +0 -1
  144. package/dist/es5/lib/extensions/deprecated/KHR_lights_punctual.js +0 -99
  145. package/dist/es5/lib/extensions/deprecated/KHR_lights_punctual.js.map +0 -1
  146. package/dist/es5/lib/extensions/deprecated/KHR_materials_unlit.js +0 -76
  147. package/dist/es5/lib/extensions/deprecated/KHR_materials_unlit.js.map +0 -1
  148. package/dist/es5/lib/extensions/deprecated/KHR_techniques_webgl.js +0 -113
  149. package/dist/es5/lib/extensions/deprecated/KHR_techniques_webgl.js.map +0 -1
  150. package/dist/es5/lib/extensions/utils/3d-tiles-utils.js +0 -254
  151. package/dist/es5/lib/extensions/utils/3d-tiles-utils.js.map +0 -1
  152. package/dist/es5/lib/gltf-utils/get-typed-array.js +0 -23
  153. package/dist/es5/lib/gltf-utils/get-typed-array.js.map +0 -1
  154. package/dist/es5/lib/gltf-utils/gltf-attribute-utils.js +0 -68
  155. package/dist/es5/lib/gltf-utils/gltf-attribute-utils.js.map +0 -1
  156. package/dist/es5/lib/gltf-utils/gltf-constants.js +0 -48
  157. package/dist/es5/lib/gltf-utils/gltf-constants.js.map +0 -1
  158. package/dist/es5/lib/gltf-utils/gltf-utils.js +0 -115
  159. package/dist/es5/lib/gltf-utils/gltf-utils.js.map +0 -1
  160. package/dist/es5/lib/gltf-utils/resolve-url.js +0 -18
  161. package/dist/es5/lib/gltf-utils/resolve-url.js.map +0 -1
  162. package/dist/es5/lib/parsers/parse-glb.js +0 -120
  163. package/dist/es5/lib/parsers/parse-glb.js.map +0 -1
  164. package/dist/es5/lib/parsers/parse-gltf.js +0 -283
  165. package/dist/es5/lib/parsers/parse-gltf.js.map +0 -1
  166. package/dist/es5/lib/types/glb-types.js +0 -2
  167. package/dist/es5/lib/types/glb-types.js.map +0 -1
  168. package/dist/es5/lib/types/gltf-ext-feature-metadata-schema.js +0 -2
  169. package/dist/es5/lib/types/gltf-ext-feature-metadata-schema.js.map +0 -1
  170. package/dist/es5/lib/types/gltf-ext-mesh-features-schema.js +0 -2
  171. package/dist/es5/lib/types/gltf-ext-mesh-features-schema.js.map +0 -1
  172. package/dist/es5/lib/types/gltf-ext-structural-metadata-schema.js +0 -2
  173. package/dist/es5/lib/types/gltf-ext-structural-metadata-schema.js.map +0 -1
  174. package/dist/es5/lib/types/gltf-json-schema.js +0 -2
  175. package/dist/es5/lib/types/gltf-json-schema.js.map +0 -1
  176. package/dist/es5/lib/types/gltf-postprocessed-schema.js +0 -2
  177. package/dist/es5/lib/types/gltf-postprocessed-schema.js.map +0 -1
  178. package/dist/es5/lib/types/gltf-types.js +0 -2
  179. package/dist/es5/lib/types/gltf-types.js.map +0 -1
  180. package/dist/es5/lib/utils/assert.js +0 -12
  181. package/dist/es5/lib/utils/assert.js.map +0 -1
  182. package/dist/es5/lib/utils/version.js +0 -9
  183. package/dist/es5/lib/utils/version.js.map +0 -1
  184. package/dist/es5/meshopt/meshopt-decoder.js +0 -215
  185. package/dist/es5/meshopt/meshopt-decoder.js.map +0 -1
  186. package/dist/es5/webp/webp.js +0 -83
  187. package/dist/es5/webp/webp.js.map +0 -1
  188. package/dist/esm/bundle.js +0 -4
  189. package/dist/esm/bundle.js.map +0 -1
  190. package/dist/esm/glb-loader.js.map +0 -1
  191. package/dist/esm/glb-writer.js.map +0 -1
  192. package/dist/esm/gltf-loader.js.map +0 -1
  193. package/dist/esm/gltf-writer.js.map +0 -1
  194. package/dist/esm/index.js +0 -13
  195. package/dist/esm/index.js.map +0 -1
  196. package/dist/esm/lib/api/gltf-extensions.js.map +0 -1
  197. package/dist/esm/lib/api/gltf-scenegraph.js.map +0 -1
  198. package/dist/esm/lib/api/normalize-gltf-v1.js.map +0 -1
  199. package/dist/esm/lib/api/post-process-gltf.js.map +0 -1
  200. package/dist/esm/lib/encoders/encode-glb.js.map +0 -1
  201. package/dist/esm/lib/encoders/encode-gltf.js.map +0 -1
  202. package/dist/esm/lib/extensions/EXT_mesh_features.js.map +0 -1
  203. package/dist/esm/lib/extensions/EXT_meshopt_compression.js.map +0 -1
  204. package/dist/esm/lib/extensions/EXT_structural_metadata.js.map +0 -1
  205. package/dist/esm/lib/extensions/EXT_texture_webp.js.map +0 -1
  206. package/dist/esm/lib/extensions/KHR_binary_gltf.js.map +0 -1
  207. package/dist/esm/lib/extensions/KHR_draco_mesh_compression.js.map +0 -1
  208. package/dist/esm/lib/extensions/KHR_texture_basisu.js.map +0 -1
  209. package/dist/esm/lib/extensions/KHR_texture_transform.js.map +0 -1
  210. package/dist/esm/lib/extensions/deprecated/EXT_feature_metadata.js.map +0 -1
  211. package/dist/esm/lib/extensions/deprecated/KHR_lights_punctual.js.map +0 -1
  212. package/dist/esm/lib/extensions/deprecated/KHR_materials_unlit.js.map +0 -1
  213. package/dist/esm/lib/extensions/deprecated/KHR_techniques_webgl.js.map +0 -1
  214. package/dist/esm/lib/extensions/utils/3d-tiles-utils.js.map +0 -1
  215. package/dist/esm/lib/gltf-utils/get-typed-array.js +0 -16
  216. package/dist/esm/lib/gltf-utils/get-typed-array.js.map +0 -1
  217. package/dist/esm/lib/gltf-utils/gltf-attribute-utils.js.map +0 -1
  218. package/dist/esm/lib/gltf-utils/gltf-constants.js.map +0 -1
  219. package/dist/esm/lib/gltf-utils/gltf-utils.js.map +0 -1
  220. package/dist/esm/lib/gltf-utils/resolve-url.js.map +0 -1
  221. package/dist/esm/lib/parsers/parse-glb.js.map +0 -1
  222. package/dist/esm/lib/parsers/parse-gltf.js.map +0 -1
  223. package/dist/esm/lib/types/glb-types.js.map +0 -1
  224. package/dist/esm/lib/types/gltf-ext-feature-metadata-schema.js.map +0 -1
  225. package/dist/esm/lib/types/gltf-ext-mesh-features-schema.js.map +0 -1
  226. package/dist/esm/lib/types/gltf-ext-structural-metadata-schema.js.map +0 -1
  227. package/dist/esm/lib/types/gltf-json-schema.js.map +0 -1
  228. package/dist/esm/lib/types/gltf-postprocessed-schema.js.map +0 -1
  229. package/dist/esm/lib/types/gltf-types.js.map +0 -1
  230. package/dist/esm/lib/utils/assert.js.map +0 -1
  231. package/dist/esm/lib/utils/version.js +0 -2
  232. package/dist/esm/lib/utils/version.js.map +0 -1
  233. package/dist/esm/meshopt/meshopt-decoder.js.map +0 -1
  234. package/dist/esm/meshopt/meshopt-encoder.ts.disabled +0 -409
  235. package/dist/esm/webp/webp.js.map +0 -1
  236. package/src/bundle.ts +0 -4
  237. /package/dist/{esm/lib → lib}/encoders/encode-glb.js +0 -0
  238. /package/dist/{esm/lib → lib}/gltf-utils/gltf-constants.js +0 -0
  239. /package/dist/{esm/lib → lib}/types/glb-types.js +0 -0
  240. /package/dist/{esm/lib → lib}/types/gltf-ext-feature-metadata-schema.js +0 -0
  241. /package/dist/{esm/lib → lib}/types/gltf-ext-mesh-features-schema.js +0 -0
  242. /package/dist/{esm/lib → lib}/types/gltf-ext-structural-metadata-schema.js +0 -0
  243. /package/dist/{esm/lib → lib}/types/gltf-json-schema.js +0 -0
  244. /package/dist/{esm/lib → lib}/types/gltf-postprocessed-schema.js +0 -0
  245. /package/dist/{esm/lib → lib}/types/gltf-types.js +0 -0
  246. /package/dist/{esm/lib → lib}/utils/assert.js +0 -0
  247. /package/dist/{es5/meshopt → meshopt}/meshopt-encoder.ts.disabled +0 -0
@@ -1,5 +1,5 @@
1
- import { GLTFScenegraph } from '../api/gltf-scenegraph';
2
- import { getPrimitiveTextureData } from './utils/3d-tiles-utils';
1
+ import { GLTFScenegraph } from "../api/gltf-scenegraph.js";
2
+ import { getPrimitiveTextureData } from "./utils/3d-tiles-utils.js";
3
3
  const EXT_MESH_FEATURES_NAME = 'EXT_mesh_features';
4
4
  export const name = EXT_MESH_FEATURES_NAME;
5
5
  export async function decode(gltfData, options) {
@@ -29,14 +29,16 @@ function processMeshPrimitiveFeatures(scenegraph, primitive, options) {
29
29
  }
30
30
  for (const featureId of featureIds) {
31
31
  var _options$gltf2;
32
- let featureIdData = null;
32
+ let featureIdData;
33
33
  if (typeof featureId.attribute !== 'undefined') {
34
- const accessorKey = "_FEATURE_ID_".concat(featureId.attribute);
34
+ const accessorKey = `_FEATURE_ID_${featureId.attribute}`;
35
35
  const accessorIndex = primitive.attributes[accessorKey];
36
36
  featureIdData = scenegraph.getTypedArrayForAccessor(accessorIndex);
37
37
  } else if (typeof featureId.texture !== 'undefined' && options !== null && options !== void 0 && (_options$gltf2 = options.gltf) !== null && _options$gltf2 !== void 0 && _options$gltf2.loadImages) {
38
38
  featureIdData = getPrimitiveTextureData(scenegraph, featureId.texture, primitive);
39
- } else {}
39
+ } else {
40
+ featureIdData = [];
41
+ }
40
42
  featureId.data = featureIdData;
41
43
  }
42
44
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EXT_mesh_features.js","names":["GLTFScenegraph","getPrimitiveTextureData","EXT_MESH_FEATURES_NAME","name","decode","gltfData","options","scenegraph","decodeExtMeshFeatures","json","gltf","meshes","mesh","primitive","primitives","processMeshPrimitiveFeatures","_options$gltf","_primitive$extensions","loadBuffers","extension","extensions","featureIds","featureId","_options$gltf2","featureIdData","attribute","accessorKey","accessorIndex","attributes","getTypedArrayForAccessor","texture","loadImages","data"],"sources":["../../../src/lib/extensions/EXT_mesh_features.ts"],"sourcesContent":["// GLTF EXTENSION: EXT_mesh_features\n// https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_mesh_features\n/* eslint-disable camelcase */\nimport type {NumericArray} from '@loaders.gl/loader-utils';\nimport type {GLTF, GLTFMeshPrimitive} from '../types/gltf-json-schema';\nimport {GLTFLoaderOptions} from '../../gltf-loader';\nimport type {\n GLTF_EXT_mesh_features,\n GLTF_EXT_mesh_features_featureId\n} from '../types/gltf-ext-mesh-features-schema';\n\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\nimport {getPrimitiveTextureData} from './utils/3d-tiles-utils';\n\nconst EXT_MESH_FEATURES_NAME = 'EXT_mesh_features';\nexport const name = EXT_MESH_FEATURES_NAME;\n\nexport async function decode(gltfData: {json: GLTF}, options: GLTFLoaderOptions): Promise<void> {\n const scenegraph = new GLTFScenegraph(gltfData);\n decodeExtMeshFeatures(scenegraph, options);\n}\n\n/**\n * Decodes feature metadata from extension.\n * @param {GLTFScenegraph} scenegraph - Instance of the class for structured access to GLTF data.\n * @param {GLTFLoaderOptions} options - GLTFLoader options.\n */\nfunction decodeExtMeshFeatures(scenegraph: GLTFScenegraph, options: GLTFLoaderOptions): void {\n const json = scenegraph.gltf.json;\n if (!json.meshes) {\n return;\n }\n\n // Iterate through all meshes/primitives.\n for (const mesh of json.meshes) {\n for (const primitive of mesh.primitives) {\n processMeshPrimitiveFeatures(scenegraph, primitive, options);\n }\n }\n}\n\n/**\n * Takes data from EXT_mesh_features and store it in 'data' property of featureIds.\n * If combined with EXT_structural_metadata, corresponding data are taken from the property tables of that extension.\n * @param {GLTFScenegraph} scenegraph - Instance of the class for structured access to GLTF data.\n * @param {GLTFMeshPrimitive} primitive - Primitive that contains extensions.\n * @param {GLTFLoaderOptions} options - GLTFLoader options.\n */\nfunction processMeshPrimitiveFeatures(\n scenegraph: GLTFScenegraph,\n primitive: GLTFMeshPrimitive,\n options: GLTFLoaderOptions\n): void {\n // Processing of mesh primitive features requires buffers to be loaded.\n if (!options?.gltf?.loadBuffers) {\n return;\n }\n\n const extension = primitive.extensions?.[EXT_MESH_FEATURES_NAME] as GLTF_EXT_mesh_features;\n const featureIds: GLTF_EXT_mesh_features_featureId[] = extension?.featureIds;\n\n if (!featureIds) {\n return;\n }\n\n for (const featureId of featureIds) {\n let featureIdData: NumericArray;\n // Process \"Feature ID by Vertex\"\n if (typeof featureId.attribute !== 'undefined') {\n const accessorKey = `_FEATURE_ID_${featureId.attribute}`;\n const accessorIndex = primitive.attributes[accessorKey];\n featureIdData = scenegraph.getTypedArrayForAccessor(accessorIndex);\n }\n\n // Process \"Feature ID by Texture Coordinates\"\n else if (typeof featureId.texture !== 'undefined' && options?.gltf?.loadImages) {\n featureIdData = getPrimitiveTextureData(scenegraph, featureId.texture, primitive);\n }\n\n // Process \"Feature ID by Index\"\n else {\n /*\n When both featureId.attribute and featureId.texture are undefined,\n then the feature ID value for each vertex is given implicitly, via the index of the vertex.\n In this case, the featureCount must match the number of vertices of the mesh primitive.\n */\n // TODO: At the moment of writing we don't have a tileset with the data of that kind. Implement it later.\n featureIdData = [];\n }\n\n featureId.data = featureIdData;\n }\n}\n"],"mappings":"SAWQA,cAAc;AAAA,SACdC,uBAAuB;AAE/B,MAAMC,sBAAsB,GAAG,mBAAmB;AAClD,OA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;MACxD,MAAME,aAAa,GAAGd,SAAS,CAACe,UAAU,CAACF,WAAW,CAAC;MACvDF,aAAa,GAAGjB,UAAU,CAACsB,wBAAwB,CAACF,aAAa,CAAC;IACpE,CAAC,MAGI,IAAI,OAAOL,SAAS,CAACQ,OAAO,KAAK,WAAW,IAAIxB,OAAO,aAAPA,OAAO,gBAAAiB,cAAA,GAAPjB,OAAO,CAAEI,IAAI,cAAAa,cAAA,eAAbA,cAAA,CAAeQ,UAAU,EAAE;MAC9EP,aAAa,GAAGvB,uBAAuB,CAACM,UAAU,EAAEe,SAAS,CAACQ,OAAO,EAAEjB,SAAS,CAAC;IACnF,CAAC,MAGI;MAOHW,aAAa,GAAG,EAAE;IACpB;IAEAF,SAAS,CAACU,IAAI,GAAGR,aAAa;EAChC;AACF"}
@@ -1,5 +1,5 @@
1
- import { GLTFScenegraph } from '../api/gltf-scenegraph';
2
- import { meshoptDecodeGltfBuffer } from '../../meshopt/meshopt-decoder';
1
+ import { GLTFScenegraph } from "../api/gltf-scenegraph.js";
2
+ import { meshoptDecodeGltfBuffer } from "../../meshopt/meshopt-decoder.js";
3
3
  const DEFAULT_MESHOPT_OPTIONS = {
4
4
  byteOffset: 0,
5
5
  filter: 'NONE'
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EXT_meshopt_compression.js","names":["GLTFScenegraph","meshoptDecodeGltfBuffer","DEFAULT_MESHOPT_OPTIONS","byteOffset","filter","EXT_MESHOPT_COMPRESSION","name","decode","gltfData","options","_options$gltf","_options$gltf2","scenegraph","gltf","decompressMeshes","loadBuffers","promises","bufferViewIndex","json","bufferViews","push","decodeMeshoptBufferView","Promise","all","removeExtension","bufferView","meshoptExtension","getObjectExtension","byteLength","byteStride","count","mode","buffer","bufferIndex","buffers","source","Uint8Array","arrayBuffer","result","removeObjectExtension"],"sources":["../../../src/lib/extensions/EXT_meshopt_compression.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport type {GLTF, GLTFBufferView, GLTF_EXT_meshopt_compression} from '../types/gltf-json-schema';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\nimport {meshoptDecodeGltfBuffer} from '../../meshopt/meshopt-decoder';\n\n// @ts-ignore\n// eslint-disable-next-line\nconst DEFAULT_MESHOPT_OPTIONS = {\n byteOffset: 0,\n filter: 'NONE'\n};\n\n/** Extension name */\nconst EXT_MESHOPT_COMPRESSION = 'EXT_meshopt_compression';\n\nexport const name = EXT_MESHOPT_COMPRESSION;\n\nexport async function decode(gltfData: {json: GLTF}, options: GLTFLoaderOptions) {\n const scenegraph = new GLTFScenegraph(gltfData);\n\n if (!options?.gltf?.decompressMeshes || !options.gltf?.loadBuffers) {\n return;\n }\n\n const promises: Promise<any>[] = [];\n for (const bufferViewIndex of gltfData.json.bufferViews || []) {\n promises.push(decodeMeshoptBufferView(scenegraph, bufferViewIndex));\n }\n\n // Decompress meshes in parallel\n await Promise.all(promises);\n\n // We have now decompressed all primitives, so remove the top-level extension\n scenegraph.removeExtension(EXT_MESHOPT_COMPRESSION);\n}\n\n/** Decode one meshopt buffer view */\nasync function decodeMeshoptBufferView(\n scenegraph: GLTFScenegraph,\n bufferView: GLTFBufferView\n): Promise<void> {\n const meshoptExtension = scenegraph.getObjectExtension<GLTF_EXT_meshopt_compression>(\n bufferView,\n EXT_MESHOPT_COMPRESSION\n );\n if (meshoptExtension) {\n const {\n byteOffset = 0,\n byteLength = 0,\n byteStride,\n count,\n mode,\n filter = 'NONE',\n buffer: bufferIndex\n } = meshoptExtension;\n const buffer = scenegraph.gltf.buffers[bufferIndex];\n\n const source = new Uint8Array(buffer.arrayBuffer, buffer.byteOffset + byteOffset, byteLength);\n const result = new Uint8Array(\n scenegraph.gltf.buffers[bufferView.buffer].arrayBuffer,\n bufferView.byteOffset,\n bufferView.byteLength\n );\n await meshoptDecodeGltfBuffer(result, count, byteStride, source, mode, filter);\n scenegraph.removeObjectExtension(bufferView, EXT_MESHOPT_COMPRESSION);\n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B;IACpB,MAAMM,MAAM,GAAGpB,UAAU,CAACC,IAAI,CAACqB,OAAO,CAACD,WAAW,CAAC;IAEnD,MAAME,MAAM,GAAG,IAAIC,UAAU,CAACJ,MAAM,CAACK,WAAW,EAAEL,MAAM,CAAC7B,UAAU,GAAGA,UAAU,EAAEyB,UAAU,CAAC;IAC7F,MAAMU,MAAM,GAAG,IAAIF,UAAU,CAC3BxB,UAAU,CAACC,IAAI,CAACqB,OAAO,CAACT,UAAU,CAACO,MAAM,CAAC,CAACK,WAAW,EACtDZ,UAAU,CAACtB,UAAU,EACrBsB,UAAU,CAACG,UACb,CAAC;IACD,MAAM3B,uBAAuB,CAACqC,MAAM,EAAER,KAAK,EAAED,UAAU,EAAEM,MAAM,EAAEJ,IAAI,EAAE3B,MAAM,CAAC;IAC9EQ,UAAU,CAAC2B,qBAAqB,CAACd,UAAU,EAAEpB,uBAAuB,CAAC;EACvE;AACF"}
@@ -1,5 +1,5 @@
1
- import { GLTFScenegraph } from '../api/gltf-scenegraph';
2
- import { convertRawBufferToMetadataArray, getPrimitiveTextureData, primitivePropertyDataToAttributes, getArrayElementByteSize, getOffsetsForProperty, parseVariableLengthArrayNumeric, parseFixedLengthArrayNumeric, getPropertyDataString } from './utils/3d-tiles-utils';
1
+ import { GLTFScenegraph } from "../api/gltf-scenegraph.js";
2
+ import { convertRawBufferToMetadataArray, getPrimitiveTextureData, primitivePropertyDataToAttributes, getArrayElementByteSize, getOffsetsForProperty, parseVariableLengthArrayNumeric, parseFixedLengthArrayNumeric, getPropertyDataString } from "./utils/3d-tiles-utils.js";
3
3
  const EXT_STRUCTURAL_METADATA_NAME = 'EXT_structural_metadata';
4
4
  export const name = EXT_STRUCTURAL_METADATA_NAME;
5
5
  export async function decode(gltfData, options) {
@@ -100,7 +100,7 @@ function processPrimitivePropertyTexture(scenegraph, propertyTexture, primitive,
100
100
  const className = propertyTexture.class;
101
101
  for (const propertyName in propertyTexture.properties) {
102
102
  var _propertyTexture$prop;
103
- const attributeName = "".concat(className, "_").concat(propertyName);
103
+ const attributeName = `${className}_${propertyName}`;
104
104
  const textureInfoTopLevel = (_propertyTexture$prop = propertyTexture.properties) === null || _propertyTexture$prop === void 0 ? void 0 : _propertyTexture$prop[propertyName];
105
105
  if (!textureInfoTopLevel) {
106
106
  continue;
@@ -122,7 +122,7 @@ function processPropertyTable(scenegraph, schema, propertyTable) {
122
122
  var _schema$classes;
123
123
  const schemaClass = (_schema$classes = schema.classes) === null || _schema$classes === void 0 ? void 0 : _schema$classes[propertyTable.class];
124
124
  if (!schemaClass) {
125
- throw new Error("Incorrect data in the EXT_structural_metadata extension: no schema class with name ".concat(propertyTable.class));
125
+ throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`);
126
126
  }
127
127
  const numberOfElements = propertyTable.count;
128
128
  for (const propertyName in schemaClass.properties) {
@@ -155,7 +155,7 @@ function getPropertyDataFromBinarySource(scenegraph, schema, classProperty, numb
155
155
  }
156
156
  case 'BOOLEAN':
157
157
  {
158
- throw new Error("Not implemented - classProperty.type=".concat(classProperty.type));
158
+ throw new Error(`Not implemented - classProperty.type=${classProperty.type}`);
159
159
  }
160
160
  case 'STRING':
161
161
  {
@@ -168,7 +168,7 @@ function getPropertyDataFromBinarySource(scenegraph, schema, classProperty, numb
168
168
  break;
169
169
  }
170
170
  default:
171
- throw new Error("Unknown classProperty type ".concat(classProperty.type));
171
+ throw new Error(`Unknown classProperty type ${classProperty.type}`);
172
172
  }
173
173
  return data;
174
174
  }
@@ -214,7 +214,7 @@ function getPropertyDataENUM(schema, classProperty, numberOfElements, valuesData
214
214
  }
215
215
  const enumEntry = (_schema$enums = schema.enums) === null || _schema$enums === void 0 ? void 0 : _schema$enums[enumType];
216
216
  if (!enumEntry) {
217
- throw new Error("Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ".concat(enumType));
217
+ throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${enumType}`);
218
218
  }
219
219
  const enumValueType = enumEntry.valueType || 'UINT16';
220
220
  const elementSize = getArrayElementByteSize(classProperty.type, enumValueType);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EXT_structural_metadata.js","names":["GLTFScenegraph","convertRawBufferToMetadataArray","getPrimitiveTextureData","primitivePropertyDataToAttributes","getArrayElementByteSize","getOffsetsForProperty","parseVariableLengthArrayNumeric","parseFixedLengthArrayNumeric","getPropertyDataString","EXT_STRUCTURAL_METADATA_NAME","name","decode","gltfData","options","scenegraph","decodeExtStructuralMetadata","getPropertyTableFromExtStructuralMetadata","extension","metadataClass","propertyTables","firstPropertyTable","propertyTableWithData","propertyName","properties","data","propertyTextures","firstPropertyTexture","console","warn","_options$gltf","_options$gltf2","gltf","loadBuffers","getExtension","loadImages","decodePropertyTextures","decodePropertyTables","json","meshes","mesh","primitive","primitives","processPrimitivePropertyTextures","schema","schemaClasses","classes","schemaName","propertyTable","findPropertyTableByClass","processPropertyTable","schemaClassName","class","_primitive$extensions","primitiveExtension","extensions","primitivePropertyTextureIndices","primitivePropertyTextureIndex","propertyTexture","processPrimitivePropertyTexture","dataAttributeNames","className","_propertyTexture$prop","attributeName","textureInfoTopLevel","featureTextureTable","propertyData","push","_schema$classes","schemaClass","Error","numberOfElements","count","_propertyTable$proper","classProperty","propertyTableProperty","getPropertyDataFromBinarySource","valuesBufferView","values","valuesDataBytes","getTypedArrayForBufferView","arrayOffsets","getArrayOffsetsForProperty","stringOffsets","getStringOffsetsForProperty","type","getPropertyDataNumeric","getPropertyDataENUM","array","arrayOffsetType","stringOffsetType","isArray","arrayCount","elementSize","componentType","elementCount","byteLength","valuesData","length","_schema$enums","enumType","enumEntry","enums","enumValueType","valueType","parseVariableLengthArrayENUM","valuesDataBytesLength","parseFixedLengthArrayENUM","getEnumsArray","params","attributeValueArray","index","arrayOffset","arrayByteSize","typedArrayOffset","elementOffset","offset","i","BigInt64Array","BigUint64Array","value","enumObject","getEnumByValue","enumValue"],"sources":["../../../src/lib/extensions/EXT_structural_metadata.ts"],"sourcesContent":["// GLTF EXTENSION: EXT_structural_metadata\n// https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata\n/* eslint-disable camelcase */\nimport type {BigTypedArray, TypedArray} from '@loaders.gl/schema';\nimport type {GLTF, GLTFTextureInfoMetadata, GLTFMeshPrimitive} from '../types/gltf-json-schema';\nimport type {\n GLTF_EXT_structural_metadata_Schema,\n GLTF_EXT_structural_metadata_ClassProperty,\n GLTF_EXT_structural_metadata_Enum,\n GLTF_EXT_structural_metadata_EnumValue,\n GLTF_EXT_structural_metadata_PropertyTable,\n GLTF_EXT_structural_metadata_GLTF,\n GLTF_EXT_structural_metadata_PropertyTexture,\n GLTF_EXT_structural_metadata_PropertyTable_Property,\n GLTF_EXT_structural_metadata_Primitive\n} from '../types/gltf-ext-structural-metadata-schema';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\nimport type {FeatureTableJson} from '../types/gltf-types';\n\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\nimport {\n convertRawBufferToMetadataArray,\n getPrimitiveTextureData,\n primitivePropertyDataToAttributes,\n getArrayElementByteSize,\n NumericComponentType,\n getOffsetsForProperty,\n parseVariableLengthArrayNumeric,\n parseFixedLengthArrayNumeric,\n getPropertyDataString\n} from './utils/3d-tiles-utils';\n\nconst EXT_STRUCTURAL_METADATA_NAME = 'EXT_structural_metadata';\nexport const name = EXT_STRUCTURAL_METADATA_NAME;\n\nexport async function decode(gltfData: {json: GLTF}, options: GLTFLoaderOptions): Promise<void> {\n const scenegraph = new GLTFScenegraph(gltfData);\n decodeExtStructuralMetadata(scenegraph, options);\n}\n\n/**\n * Handles EXT_structural_metadata to get property table.\n * @param extension - Global level of EXT_STRUCTURAL_METADATA extension.\n * @param metadataClass - User selected feature metadata class name.\n * @returns {FeatureTableJson | null} Property table or null if the extension can't be handled properly.\n */\nexport function getPropertyTableFromExtStructuralMetadata(\n extension: GLTF_EXT_structural_metadata_GLTF,\n metadataClass?: string\n): FeatureTableJson | null {\n if (extension.propertyTables) {\n /**\n * Take only first feature table to generate attributes storage info object.\n * TODO: Think about getting data from all feature tables?\n * It can be tricky just because 3dTiles is able to have multiple featureId attributes and multiple feature tables.\n * In I3S we should decide which featureIds attribute will be passed to geometry data.\n */\n const firstPropertyTable = extension?.propertyTables[0];\n const propertyTableWithData = {};\n\n for (const propertyName in firstPropertyTable.properties) {\n propertyTableWithData[propertyName] = firstPropertyTable.properties[propertyName].data;\n }\n\n return propertyTableWithData;\n }\n\n if (extension.propertyTextures) {\n // TODO: Think about getting data from all property textures.\n const firstPropertyTexture = extension?.propertyTextures[0];\n const propertyTableWithData = {};\n\n for (const propertyName in firstPropertyTexture.properties) {\n propertyTableWithData[propertyName] = firstPropertyTexture.properties[propertyName].data;\n }\n\n return propertyTableWithData;\n }\n\n // eslint-disable-next-line no-console\n console.warn(\n 'Cannot get property table from EXT_structural_metadata extension. There is neither propertyTables, nor propertyTextures in the extension.'\n );\n return null;\n}\n\n/*\n// Example of the extension.\n// See more info at https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata\nconst extensions = {\n \"extensions\": {\n \"EXT_structural_metadata\": {\n \"schema\": {\n \"classes\": {\n \"tree\": {\n \"name\": \"Tree\",\n \"description\": \"Woody, perennial plant.\",\n \"properties\": {\n \"species\": {\n \"description\": \"Type of tree.\",\n \"type\": \"ENUM\",\n \"enumType\": \"speciesEnum\",\n \"required\": true\n },\n \"age\": {\n \"description\": \"The age of the tree, in years\",\n \"type\": \"SCALAR\",\n \"componentType\": \"UINT8\",\n \"required\": true\n }\n }\n }\n },\n \"enums\": {\n \"speciesEnum\": {\n \"name\": \"Species\",\n \"description\": \"An example enum for tree species.\",\n // valueType is not defined here. Default is \"UINT16\"\n \"values\": [\n { \"name\": \"Unspecified\", \"value\": 0 },\n { \"name\": \"Oak\", \"value\": 1 }\n ]\n }\n }\n },\n \"propertyTables\": [{\n \"name\": \"tree_survey_2021-09-29\",\n \"class\": \"tree\",\n \"count\": 10, // The number of elements in each property array (in `species`, in `age`).\n \"properties\": {\n \"species\": {\n \"values\": 0, // It's an index of the buffer view containing property values.\n },\n \"age\": {\n \"values\": 1\n }\n }\n }]\n }\n }\n}\n*/\n\n/**\n * Decodes feature metadata from extension.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param options - GLTFLoader options.\n */\nfunction decodeExtStructuralMetadata(scenegraph: GLTFScenegraph, options: GLTFLoaderOptions): void {\n // Decoding metadata involves buffers processing.\n // So, if buffers have not been loaded, there is no reason to process metadata.\n if (!options.gltf?.loadBuffers) {\n return;\n }\n const extension: GLTF_EXT_structural_metadata_GLTF | null = scenegraph.getExtension(\n EXT_STRUCTURAL_METADATA_NAME\n );\n if (!extension) {\n return;\n }\n\n if (options.gltf?.loadImages) {\n decodePropertyTextures(scenegraph, extension);\n }\n\n decodePropertyTables(scenegraph, extension);\n}\n\n/**\n * Processes the data stored in the textures\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param extension - Top-level extension.\n */\nfunction decodePropertyTextures(\n scenegraph: GLTFScenegraph,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n const propertyTextures = extension.propertyTextures;\n const json = scenegraph.gltf.json;\n if (propertyTextures && json.meshes) {\n // Iterate through all meshes/primitives.\n for (const mesh of json.meshes) {\n for (const primitive of mesh.primitives) {\n processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension);\n }\n }\n }\n}\n\n/**\n * Processes the data stored in the property tables.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param extension - Top-level extension.\n */\nfunction decodePropertyTables(\n scenegraph: GLTFScenegraph,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n const schema = extension.schema;\n if (!schema) {\n return;\n }\n const schemaClasses = schema.classes;\n const propertyTables = extension.propertyTables;\n if (schemaClasses && propertyTables) {\n for (const schemaName in schemaClasses) {\n const propertyTable = findPropertyTableByClass(propertyTables, schemaName);\n if (propertyTable) {\n processPropertyTable(scenegraph, schema, propertyTable);\n }\n }\n }\n}\n\n/**\n * Finds the property table by class name.\n * @param propertyTables - propertyTable definition taken from the top-level extension.\n * @param schemaClassName - class name in the extension schema.\n */\nfunction findPropertyTableByClass(\n propertyTables: GLTF_EXT_structural_metadata_PropertyTable[],\n schemaClassName: string\n): GLTF_EXT_structural_metadata_PropertyTable | null {\n for (const propertyTable of propertyTables) {\n if (propertyTable.class === schemaClassName) {\n return propertyTable;\n }\n }\n\n return null;\n}\n\n/**\n * Takes data from property textures reffered by the primitive.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param propertyTextures - propertyTexture definition taken from the top-level extention.\n * @param primitive - Primitive object.\n * @param extension - Top-level extension.\n */\nfunction processPrimitivePropertyTextures(\n scenegraph: GLTFScenegraph,\n propertyTextures: GLTF_EXT_structural_metadata_PropertyTexture[],\n primitive: GLTFMeshPrimitive,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n if (!propertyTextures) {\n return;\n }\n const primitiveExtension: GLTF_EXT_structural_metadata_Primitive = primitive.extensions?.[\n EXT_STRUCTURAL_METADATA_NAME\n ] as GLTF_EXT_structural_metadata_Primitive;\n const primitivePropertyTextureIndices = primitiveExtension?.propertyTextures;\n if (!primitivePropertyTextureIndices) {\n return;\n }\n\n for (const primitivePropertyTextureIndex of primitivePropertyTextureIndices) {\n const propertyTexture = propertyTextures[primitivePropertyTextureIndex];\n processPrimitivePropertyTexture(scenegraph, propertyTexture, primitive, extension);\n }\n}\n\n/**\n * Takes property data from the texture pointed by the primitive and appends them to `exension.data`.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param propertyTexture - propertyTexture definition taken from the top-level extension.\n * @param primitive - Primitive object.\n * @param extension - Top-level extension.\n */\nfunction processPrimitivePropertyTexture(\n scenegraph: GLTFScenegraph,\n propertyTexture: GLTF_EXT_structural_metadata_PropertyTexture,\n primitive: GLTFMeshPrimitive,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n if (!propertyTexture.properties) {\n return;\n }\n\n if (!extension.dataAttributeNames) {\n extension.dataAttributeNames = [];\n }\n\n /* Iterate through all properties defined in propertyTexture, e.g. \"speed\" and \"direction\":\n {\n \"class\": \"wind\",\n \"properties\": {\n \"speed\": {\n \"index\": 0,\n \"texCoord\": 0,\n \"channels\": [0]\n },\n \"direction\": {\n \"index\": 0,\n \"texCoord\": 0,\n \"channels\": [1, 2]\n }\n }\n }\n */\n const className = propertyTexture.class;\n for (const propertyName in propertyTexture.properties) {\n // propertyName has values like \"speed\", \"direction\"\n // Make attributeName as a combination of the class name and the propertyName like \"wind_speed\" or \"wind_direction\"\n const attributeName = `${className}_${propertyName}`;\n const textureInfoTopLevel: GLTFTextureInfoMetadata | undefined =\n propertyTexture.properties?.[propertyName];\n if (!textureInfoTopLevel) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n // The data taken from all meshes/primitives (the same property, e.g. \"speed\" or \"direction\") will be combined into one array and saved in textureInfoTopLevel.data\n // Initially textureInfoTopLevel.data will be initialized with an empty array.\n if (!textureInfoTopLevel.data) {\n textureInfoTopLevel.data = [];\n }\n const featureTextureTable: number[] = textureInfoTopLevel.data as number[];\n\n const propertyData: number[] | null = getPrimitiveTextureData(\n scenegraph,\n textureInfoTopLevel,\n primitive\n );\n if (propertyData === null) {\n // eslint-disable-next-line no-continue\n continue;\n }\n primitivePropertyDataToAttributes(\n scenegraph,\n attributeName,\n propertyData,\n featureTextureTable,\n primitive\n );\n textureInfoTopLevel.data = featureTextureTable;\n extension.dataAttributeNames.push(attributeName);\n }\n}\n\n/**\n * Navigates through all properies in the property table, gets properties data,\n * and put the data to `propertyTable.data` as an array.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param schema - schema object.\n * @param propertyTable - propertyTable definition taken from the top-level extension.\n */\nfunction processPropertyTable(\n scenegraph: GLTFScenegraph,\n schema: GLTF_EXT_structural_metadata_Schema,\n propertyTable: GLTF_EXT_structural_metadata_PropertyTable\n): void {\n const schemaClass = schema.classes?.[propertyTable.class];\n if (!schemaClass) {\n throw new Error(\n `Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`\n );\n }\n\n const numberOfElements = propertyTable.count; // `propertyTable.count` is a number of elements in each property array.\n\n for (const propertyName in schemaClass.properties) {\n const classProperty = schemaClass.properties[propertyName];\n const propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property | undefined =\n propertyTable.properties?.[propertyName];\n\n if (propertyTableProperty) {\n // Getting all elements (`numberOfElements`) of the array in the `propertyTableProperty`\n const data = getPropertyDataFromBinarySource(\n scenegraph,\n schema,\n classProperty,\n numberOfElements,\n propertyTableProperty\n );\n propertyTableProperty.data = data;\n }\n }\n}\n\n/**\n * Decodes a propertyTable column from binary source based on property type.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param schema - Schema object.\n * @param classProperty - class property object.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @returns {string[] | number[] | string[][] | number[][]}\n */\nfunction getPropertyDataFromBinarySource(\n scenegraph: GLTFScenegraph,\n schema: GLTF_EXT_structural_metadata_Schema,\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property\n): string[] | BigTypedArray | string[][] | BigTypedArray[] {\n let data: string[] | BigTypedArray | string[][] | BigTypedArray[] = [];\n const valuesBufferView = propertyTableProperty.values;\n const valuesDataBytes: Uint8Array = scenegraph.getTypedArrayForBufferView(valuesBufferView);\n\n const arrayOffsets = getArrayOffsetsForProperty(\n scenegraph,\n classProperty,\n propertyTableProperty,\n numberOfElements\n );\n const stringOffsets = getStringOffsetsForProperty(\n scenegraph,\n propertyTableProperty,\n numberOfElements\n );\n\n switch (classProperty.type) {\n case 'SCALAR':\n case 'VEC2':\n case 'VEC3':\n case 'VEC4':\n case 'MAT2':\n case 'MAT3':\n case 'MAT4': {\n data = getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes, arrayOffsets);\n break;\n }\n case 'BOOLEAN': {\n // TODO: implement it as soon as we have the corresponding tileset\n throw new Error(`Not implemented - classProperty.type=${classProperty.type}`);\n }\n case 'STRING': {\n data = getPropertyDataString(numberOfElements, valuesDataBytes, arrayOffsets, stringOffsets);\n break;\n }\n case 'ENUM': {\n data = getPropertyDataENUM(\n schema,\n classProperty,\n numberOfElements,\n valuesDataBytes,\n arrayOffsets\n );\n break;\n }\n default:\n throw new Error(`Unknown classProperty type ${classProperty.type}`);\n }\n\n return data;\n}\n\n/**\n * Parses propertyTable.property.arrayOffsets that are offsets of sub-arrays in a flatten array of values.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param classProperty - class property object.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @returns Typed array with offset values.\n * @see https://github.com/CesiumGS/glTF/blob/2976f1183343a47a29e4059a70961371cd2fcee8/extensions/2.0/Vendor/EXT_structural_metadata/schema/propertyTable.property.schema.json#L21\n */\nfunction getArrayOffsetsForProperty(\n scenegraph: GLTFScenegraph,\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property,\n numberOfElements: number\n): TypedArray | null {\n if (\n classProperty.array &&\n // `count` is a number of array elements. May only be defined when `array` is true.\n // If `count` is NOT defined, it's a VARIABLE-length array\n typeof classProperty.count === 'undefined' &&\n // `arrayOffsets` is an index of the buffer view containing offsets for variable-length arrays.\n typeof propertyTableProperty.arrayOffsets !== 'undefined'\n ) {\n // Data are in a VARIABLE-length array\n return getOffsetsForProperty(\n scenegraph,\n propertyTableProperty.arrayOffsets,\n propertyTableProperty.arrayOffsetType || 'UINT32',\n numberOfElements\n );\n }\n return null;\n}\n\n/**\n * Parses propertyTable.property.stringOffsets.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @returns Typed array with offset values.\n * @see https://github.com/CesiumGS/glTF/blob/2976f1183343a47a29e4059a70961371cd2fcee8/extensions/2.0/Vendor/EXT_structural_metadata/schema/propertyTable.property.schema.json#L29C10-L29C23\n */\nfunction getStringOffsetsForProperty(\n scenegraph: GLTFScenegraph,\n propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property,\n numberOfElements: number\n): TypedArray | null {\n if (\n typeof propertyTableProperty.stringOffsets !== 'undefined' // `stringOffsets` is an index of the buffer view containing offsets for strings.\n ) {\n // Data are in a FIXED-length array\n return getOffsetsForProperty(\n scenegraph,\n propertyTableProperty.stringOffsets,\n propertyTableProperty.stringOffsetType || 'UINT32',\n numberOfElements\n );\n }\n return null;\n}\n\n/**\n * Decodes properties of SCALAR, VEC-N, MAT-N types from binary sourse.\n * @param classProperty - class property object.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param valuesDataBytes - Data taken from values property of the property table property.\n * @param arrayOffsets - Offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @returns Property values in a typed array or in an array of typed arrays.\n */\nfunction getPropertyDataNumeric(\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n valuesDataBytes: Uint8Array,\n arrayOffsets: TypedArray | null\n): BigTypedArray | BigTypedArray[] {\n const isArray = classProperty.array;\n const arrayCount = classProperty.count;\n\n const elementSize = getArrayElementByteSize(classProperty.type, classProperty.componentType);\n const elementCount = valuesDataBytes.byteLength / elementSize;\n\n let valuesData: BigTypedArray;\n if (classProperty.componentType) {\n valuesData = convertRawBufferToMetadataArray(\n valuesDataBytes,\n classProperty.type,\n // The datatype of the element's components. Only applicable to `SCALAR`, `VECN`, and `MATN` types.\n classProperty.componentType as NumericComponentType,\n elementCount\n );\n } else {\n // The spec doesn't provide any info what to do if componentType is not set.\n valuesData = valuesDataBytes;\n }\n\n if (isArray) {\n if (arrayOffsets) {\n // VARIABLE-length array\n return parseVariableLengthArrayNumeric(\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytes.length,\n elementSize\n );\n }\n if (arrayCount) {\n // FIXED-length array\n return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);\n }\n return [];\n }\n\n return valuesData;\n}\n\n/**\n * Decodes properties of enum type from binary source.\n * @param schema - Schema object.\n * @param classProperty - Class property object.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param valuesDataBytes - Data taken from values property of the property table property.\n * @param arrayOffsets - Offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @returns Strings array of nested strings array.\n */\nfunction getPropertyDataENUM(\n schema: GLTF_EXT_structural_metadata_Schema,\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n valuesDataBytes: Uint8Array,\n arrayOffsets: TypedArray | null\n): string[] | string[][] {\n const enumType = classProperty.enumType;\n // Enum ID as declared in the `enums` dictionary. Required when `type` is `ENUM`.\n if (!enumType) {\n throw new Error(\n 'Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM'\n );\n }\n\n const enumEntry: GLTF_EXT_structural_metadata_Enum | undefined = schema.enums?.[enumType];\n if (!enumEntry) {\n throw new Error(\n `Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${enumType}`\n );\n }\n\n const enumValueType = enumEntry.valueType || 'UINT16';\n const elementSize = getArrayElementByteSize(classProperty.type, enumValueType);\n const elementCount = valuesDataBytes.byteLength / elementSize;\n let valuesData: BigTypedArray | null = convertRawBufferToMetadataArray(\n valuesDataBytes,\n classProperty.type,\n enumValueType,\n elementCount\n );\n if (!valuesData) {\n valuesData = valuesDataBytes;\n }\n\n if (classProperty.array) {\n if (arrayOffsets) {\n // VARIABLE-length array\n return parseVariableLengthArrayENUM({\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytesLength: valuesDataBytes.length,\n elementSize,\n enumEntry\n });\n }\n\n const arrayCount = classProperty.count;\n if (arrayCount) {\n // FIXED-length array\n return parseFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry);\n }\n return [];\n }\n\n // Single value (not an array)\n return getEnumsArray(valuesData, 0, numberOfElements, enumEntry);\n}\n\n/**\n * Parses variable length nested ENUM arrays.\n * @param params.valuesData - Values in a flat typed array.\n * @param params.numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param params.arrayOffsets - Offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @param params.valuesDataBytesLength - Byte length of values array.\n * @param params.elementSize - Single element byte size.\n * @param params.enumEntry - Enums dictionary.\n * @returns Nested strings array.\n */\nfunction parseVariableLengthArrayENUM(params: {\n valuesData: BigTypedArray;\n numberOfElements: number;\n arrayOffsets: TypedArray;\n valuesDataBytesLength: number;\n elementSize: number;\n enumEntry: GLTF_EXT_structural_metadata_Enum;\n}): string[][] {\n const {\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytesLength,\n elementSize,\n enumEntry\n } = params;\n const attributeValueArray: string[][] = [];\n for (let index = 0; index < numberOfElements; index++) {\n const arrayOffset = arrayOffsets[index];\n const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];\n if (arrayByteSize + arrayOffset > valuesDataBytesLength) {\n break;\n }\n\n const typedArrayOffset = arrayOffset / elementSize;\n const elementCount = arrayByteSize / elementSize;\n const array: string[] = getEnumsArray(valuesData, typedArrayOffset, elementCount, enumEntry);\n attributeValueArray.push(array);\n }\n return attributeValueArray;\n}\n\n/**\n * Parses fixed length ENUM arrays.\n * @param valuesData - Values in a flat typed array.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param arrayCount - Nested arrays length.\n * @param enumEntry - Enums dictionary.\n * @returns Nested strings array.\n */\nfunction parseFixedLengthArrayENUM(\n valuesData: BigTypedArray,\n numberOfElements: number,\n arrayCount: number,\n enumEntry: GLTF_EXT_structural_metadata_Enum\n): string[][] {\n const attributeValueArray: string[][] = [];\n for (let index = 0; index < numberOfElements; index++) {\n const elementOffset = arrayCount * index;\n const array: string[] = getEnumsArray(valuesData, elementOffset, arrayCount, enumEntry);\n attributeValueArray.push(array);\n }\n return attributeValueArray;\n}\n\n/**\n * Parses ENUM values into a string array.\n * @param valuesData - Values in a flat typed array.\n * @param offset - Offset to start parse from.\n * @param count - Values length to parse.\n * @param enumEntry - Enums dictionary.\n * @returns Array of strings with parsed ENUM names.\n */\nfunction getEnumsArray(\n valuesData: BigTypedArray,\n offset: number,\n count: number,\n enumEntry: GLTF_EXT_structural_metadata_Enum\n): string[] {\n const array: string[] = [];\n for (let i = 0; i < count; i++) {\n // At the moment we don't support BigInt. It requires additional calculations logic\n // and might be an issue in Safari\n if (valuesData instanceof BigInt64Array || valuesData instanceof BigUint64Array) {\n array.push('');\n } else {\n const value = valuesData[offset + i];\n\n const enumObject = getEnumByValue(enumEntry, value);\n if (enumObject) {\n array.push(enumObject.name);\n } else {\n array.push('');\n }\n }\n }\n return array;\n}\n\n/**\n * Looks up ENUM whose `value` property matches the specified number in the parameter `value`.\n * @param {GLTF_EXT_structural_metadata_Enum} enumEntry - ENUM entry containing the array of possible enums.\n * @param {number} value - The value of the ENUM to locate.\n * @returns {GLTF_EXT_structural_metadata_EnumValue | null} ENUM matcihng the specified value or null of no ENUM object was found.\n */\nfunction getEnumByValue(\n enumEntry: GLTF_EXT_structural_metadata_Enum,\n value: number\n): GLTF_EXT_structural_metadata_EnumValue | null {\n for (const enumValue of enumEntry.values) {\n if (enumValue.value === value) {\n return enumValue;\n }\n }\n\n return null;\n}\n"],"mappings":"SAmBQA,cAAc;AAAA,SAEpBC,+BAA+B,EAC/BC,uBAAuB,EACvBC,iCAAiC,EACjCC,uBAAuB,EAEvBC,qBAAqB,EACrBC,+BAA+B,EAC/BC,4BAA4B,EAC5BC,qBAA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D,IAAIC,UAAU,EAAE;QACdjC,KAAK,CAACrB,IAAI,CAACsD,UAAU,CAAC9G,IAAI,CAAC;MAC7B,CAAC,MAAM;QACL6E,KAAK,CAACrB,IAAI,CAAC,EAAE,CAAC;MAChB;IACF;EACF;EACA,OAAOqB,KAAK;AACd;AAQA,SAASkC,cAAcA,CACrBrB,SAA4C,EAC5CmB,KAAa,EACkC;EAC/C,KAAK,MAAMG,SAAS,IAAItB,SAAS,CAACvB,MAAM,EAAE;IACxC,IAAI6C,SAAS,CAACH,KAAK,KAAKA,KAAK,EAAE;MAC7B,OAAOG,SAAS;IAClB;EACF;EAEA,OAAO,IAAI;AACb"}
@@ -1,12 +1,12 @@
1
1
  import { isImageFormatSupported } from '@loaders.gl/images';
2
- import { GLTFScenegraph } from '../api/gltf-scenegraph';
2
+ import { GLTFScenegraph } from "../api/gltf-scenegraph.js";
3
3
  const EXT_TEXTURE_WEBP = 'EXT_texture_webp';
4
4
  export const name = EXT_TEXTURE_WEBP;
5
5
  export function preprocess(gltfData, options) {
6
6
  const scenegraph = new GLTFScenegraph(gltfData);
7
7
  if (!isImageFormatSupported('image/webp')) {
8
8
  if (scenegraph.getRequiredExtensions().includes(EXT_TEXTURE_WEBP)) {
9
- throw new Error("gltf: Required extension ".concat(EXT_TEXTURE_WEBP, " not supported by browser"));
9
+ throw new Error(`gltf: Required extension ${EXT_TEXTURE_WEBP} not supported by browser`);
10
10
  }
11
11
  return;
12
12
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EXT_texture_webp.js","names":["isImageFormatSupported","GLTFScenegraph","EXT_TEXTURE_WEBP","name","preprocess","gltfData","options","scenegraph","getRequiredExtensions","includes","Error","json","texture","textures","extension","getObjectExtension","source","removeObjectExtension","removeExtension"],"sources":["../../../src/lib/extensions/EXT_texture_webp.ts"],"sourcesContent":["// GLTF EXTENSION: EXT_TEXTURE_WEBP\n// https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/EXT_TEXTURE_WEBP\n/* eslint-disable camelcase */\n\nimport type {GLTF, GLTF_EXT_texture_webp} from '../types/gltf-json-schema';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\n\nimport {isImageFormatSupported} from '@loaders.gl/images';\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\n\nconst EXT_TEXTURE_WEBP = 'EXT_texture_webp';\n\n/** Extension name */\nexport const name = EXT_TEXTURE_WEBP;\n\n/**\n * Replaces a texture source reference with the extension texture\n * Done in preprocess() to prevent load of default image\n */\nexport function preprocess(gltfData: {json: GLTF}, options: GLTFLoaderOptions): void {\n const scenegraph = new GLTFScenegraph(gltfData);\n\n if (!isImageFormatSupported('image/webp')) {\n if (scenegraph.getRequiredExtensions().includes(EXT_TEXTURE_WEBP)) {\n throw new Error(`gltf: Required extension ${EXT_TEXTURE_WEBP} not supported by browser`);\n }\n return;\n }\n\n const {json} = scenegraph;\n\n for (const texture of json.textures || []) {\n const extension = scenegraph.getObjectExtension<GLTF_EXT_texture_webp>(\n texture,\n EXT_TEXTURE_WEBP\n );\n if (extension) {\n // TODO - if multiple texture extensions are present which one wins?\n texture.source = extension.source;\n }\n scenegraph.removeObjectExtension(texture, EXT_TEXTURE_WEBP);\n }\n\n // Remove the top-level extension\n scenegraph.removeExtension(EXT_TEXTURE_WEBP);\n}\n"],"mappings":"AAOA,SAAQA,sBAAsB,QAAO,oBAAoB;AAAC,SAClDC,cAAc;AAEtB,MAAMC,gBAAgB,GAAG,kBAAkB;AAG3C,OAAO,MAAMC,IAAI,GAAGD,gBAAgB;AAMpC,OAAO,SAASE,UAAUA,CAACC,QAAsB,EAAEC,OAA0B,EAAQ;EACnF,MAAMC,UAAU,GAAG,IAAIN,cAAc,CAACI,QAAQ,CAAC;EAE/C,IAAI,CAACL,sBAAsB,CAAC,YAAY,CAAC,EAAE;IACzC,IAAIO,UAAU,CAACC,qBAAqB,CAAC,CAAC,CAACC,QAAQ,CAACP,gBAAgB,CAAC,EAAE;MACjE,MAAM,IAAIQ,KAAK,CAAE,4BAA2BR,gBAAiB,2BAA0B,CAAC;IAC1F;IACA;EACF;EAEA,MAAM;IAACS;EAAI,CAAC,GAAGJ,UAAU;EAEzB,KAAK,MAAMK,OAAO,IAAID,IAAI,CAACE,QAAQ,IAAI,EAAE,EAAE;IACzC,MAAMC,SAAS,GAAGP,UAAU,CAACQ,kBAAkB,CAC7CH,OAAO,EACPV,gBACF,CAAC;IACD,IAAIY,SAAS,EAAE;MAEbF,OAAO,CAACI,MAAM,GAAGF,SAAS,CAACE,MAAM;IACnC;IACAT,UAAU,CAACU,qBAAqB,CAACL,OAAO,EAAEV,gBAAgB,CAAC;EAC7D;EAGAK,UAAU,CAACW,eAAe,CAAChB,gBAAgB,CAAC;AAC9C"}
@@ -1,4 +1,4 @@
1
- import { GLTFScenegraph } from '../api/gltf-scenegraph';
1
+ import { GLTFScenegraph } from "../api/gltf-scenegraph.js";
2
2
  const KHR_BINARY_GLTF = 'KHR_binary_glTF';
3
3
  export const name = KHR_BINARY_GLTF;
4
4
  export function preprocess(gltfData) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KHR_binary_gltf.js","names":["GLTFScenegraph","KHR_BINARY_GLTF","name","preprocess","gltfData","gltfScenegraph","json","image","images","extension","getObjectExtension","Object","assign","removeObjectExtension","buffers","uri","removeExtension"],"sources":["../../../src/lib/extensions/KHR_binary_gltf.ts"],"sourcesContent":["// GLTF 1.0 EXTENSION: KHR_binary_glTF\n// https://github.com/KhronosGroup/glTF/tree/master/extensions/1.0/Khronos/KHR_binary_glTF\n/* eslint-disable camelcase */\n\nimport type {GLTF, GLTF_KHR_binary_glTF} from '../types/gltf-json-schema';\n\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\n\nconst KHR_BINARY_GLTF = 'KHR_binary_glTF';\n\n/** Extension name */\nexport const name = KHR_BINARY_GLTF;\n\nexport function preprocess(gltfData: {json: GLTF}): void {\n const gltfScenegraph = new GLTFScenegraph(gltfData);\n const {json} = gltfScenegraph;\n\n // Note: json.buffers.binary_glTF also needs to be replaced\n // This is currently done during gltf normalization\n\n // Image and shader nodes can have the extension\n // https://github.com/KhronosGroup/glTF/blob/master/extensions/1.0/Khronos/KHR_binary_glTF/schema/image.KHR_binary_glTF.schema.json\n for (const image of json.images || []) {\n const extension = gltfScenegraph.getObjectExtension<GLTF_KHR_binary_glTF>(\n image,\n KHR_BINARY_GLTF\n );\n // The data in the extension is valid as glTF 2.0 data inside the object, so just copy it in\n if (extension) {\n Object.assign(image, extension);\n }\n gltfScenegraph.removeObjectExtension(image, KHR_BINARY_GLTF);\n }\n\n // TODO shaders - At least traverse and throw error if used?\n // https://github.com/KhronosGroup/glTF/blob/master/extensions/1.0/Khronos/KHR_binary_glTF/schema/shader.KHR_binary_glTF.schema.json\n\n // glTF v1 one files have a partially formed URI field that is not expected in (and causes problems in) 2.0\n if (json.buffers && json.buffers[0]) {\n delete json.buffers[0].uri;\n }\n\n // Remove the top-level extension as it has now been processed\n gltfScenegraph.removeExtension(KHR_BINARY_GLTF);\n}\n\n// KHR_binary_gltf is a 1.0 extension that is supported natively by 2.0\n// export function encode() {\n// throw new Error(KHR_BINARY_GLTF);\n// }\n"],"mappings":"SAMQA,cAAc;AAEtB,MAAMC,eAAe,GAAG,iBAAiB;AAGzC,OAAO,MAAMC,IAAI,GAAGD,eAAe;AAEnC,OAAO,SAASE,UAAUA,CAACC,QAAsB,EAAQ;EACvD,MAAMC,cAAc,GAAG,IAAIL,cAAc,CAACI,QAAQ,CAAC;EACnD,MAAM;IAACE;EAAI,CAAC,GAAGD,cAAc;EAO7B,KAAK,MAAME,KAAK,IAAID,IAAI,CAACE,MAAM,IAAI,EAAE,EAAE;IACrC,MAAMC,SAAS,GAAGJ,cAAc,CAACK,kBAAkB,CACjDH,KAAK,EACLN,eACF,CAAC;IAED,IAAIQ,SAAS,EAAE;MACbE,MAAM,CAACC,MAAM,CAACL,KAAK,EAAEE,SAAS,CAAC;IACjC;IACAJ,cAAc,CAACQ,qBAAqB,CAACN,KAAK,EAAEN,eAAe,CAAC;EAC9D;EAMA,IAAIK,IAAI,CAACQ,OAAO,IAAIR,IAAI,CAACQ,OAAO,CAAC,CAAC,CAAC,EAAE;IACnC,OAAOR,IAAI,CAACQ,OAAO,CAAC,CAAC,CAAC,CAACC,GAAG;EAC5B;EAGAV,cAAc,CAACW,eAAe,CAACf,eAAe,CAAC;AACjD"}
@@ -1,7 +1,7 @@
1
1
  import { sliceArrayBuffer, parseFromContext } from '@loaders.gl/loader-utils';
2
2
  import { DracoLoader } from '@loaders.gl/draco';
3
- import { GLTFScenegraph } from '../api/gltf-scenegraph';
4
- import { getGLTFAccessors, getGLTFAccessor } from '../gltf-utils/gltf-attribute-utils';
3
+ import { GLTFScenegraph } from "../api/gltf-scenegraph.js";
4
+ import { getGLTFAccessors, getGLTFAccessor } from "../gltf-utils/gltf-attribute-utils.js";
5
5
  const KHR_DRACO_MESH_COMPRESSION = 'KHR_draco_mesh_compression';
6
6
  export const name = KHR_DRACO_MESH_COMPRESSION;
7
7
  export function preprocess(gltfData, options, context) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KHR_draco_mesh_compression.js","names":["sliceArrayBuffer","parseFromContext","DracoLoader","GLTFScenegraph","getGLTFAccessors","getGLTFAccessor","KHR_DRACO_MESH_COMPRESSION","name","preprocess","gltfData","options","context","scenegraph","primitive","makeMeshPrimitiveIterator","getObjectExtension","decode","_options$gltf","gltf","decompressMeshes","promises","push","decompressPrimitive","Promise","all","removeExtension","encode","arguments","length","undefined","mesh","json","meshes","compressMesh","addRequiredExtension","dracoExtension","buffer","getTypedArrayForBufferView","bufferView","bufferCopy","byteOffset","dracoOptions","decodedData","decodedAttributes","attributes","attributeName","decodedAttribute","Object","entries","accessorIndex","accessor","getAccessor","min","max","indices","removeObjectExtension","checkPrimitive","_context$parseSync","mode","DracoWriter","Error","compressedData","encodeSync","parseSync","call","fauxAccessors","_addFauxAttributes","bufferViewIndex","addBufferView","glTFMesh","primitives","extensions","keys"],"sources":["../../../src/lib/extensions/KHR_draco_mesh_compression.ts"],"sourcesContent":["// https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression\n// Only TRIANGLES: 0x0004 and TRIANGLE_STRIP: 0x0005 are supported\n/* eslint-disable camelcase */\n\nimport type {LoaderContext} from '@loaders.gl/loader-utils';\nimport {sliceArrayBuffer, parseFromContext} from '@loaders.gl/loader-utils';\n\nimport {DracoLoader} from '@loaders.gl/draco';\nimport {DracoLoaderOptions} from '@loaders.gl/draco';\n\nimport type {\n GLTF,\n GLTFAccessor,\n GLTFMeshPrimitive,\n GLTF_KHR_draco_mesh_compression\n} from '../types/gltf-json-schema';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\n\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\nimport {getGLTFAccessors, getGLTFAccessor} from '../gltf-utils/gltf-attribute-utils';\n\nconst KHR_DRACO_MESH_COMPRESSION = 'KHR_draco_mesh_compression';\n\n/** Extension name */\nexport const name = KHR_DRACO_MESH_COMPRESSION;\n\nexport function preprocess(\n gltfData: {json: GLTF},\n options: GLTFLoaderOptions,\n context: LoaderContext\n): void {\n const scenegraph = new GLTFScenegraph(gltfData);\n for (const primitive of makeMeshPrimitiveIterator(scenegraph)) {\n if (scenegraph.getObjectExtension(primitive, KHR_DRACO_MESH_COMPRESSION)) {\n // TODO - Remove fallback accessors to make sure we don't load unnecessary buffers\n }\n }\n}\n\nexport async function decode(\n gltfData: {json: GLTF},\n options: GLTFLoaderOptions,\n context: LoaderContext\n): Promise<void> {\n if (!options?.gltf?.decompressMeshes) {\n return;\n }\n\n const scenegraph = new GLTFScenegraph(gltfData);\n const promises: Promise<void>[] = [];\n for (const primitive of makeMeshPrimitiveIterator(scenegraph)) {\n if (scenegraph.getObjectExtension(primitive, KHR_DRACO_MESH_COMPRESSION)) {\n promises.push(decompressPrimitive(scenegraph, primitive, options, context));\n }\n }\n\n // Decompress meshes in parallel\n await Promise.all(promises);\n\n // We have now decompressed all primitives, so remove the top-level extension\n scenegraph.removeExtension(KHR_DRACO_MESH_COMPRESSION);\n}\n\nexport function encode(gltfData, options: GLTFLoaderOptions = {}): void {\n const scenegraph = new GLTFScenegraph(gltfData);\n\n for (const mesh of scenegraph.json.meshes || []) {\n // eslint-disable-next-line camelcase\n // @ts-ignore\n compressMesh(mesh, options);\n // NOTE: Only add the extension if something was actually compressed\n scenegraph.addRequiredExtension(KHR_DRACO_MESH_COMPRESSION);\n }\n}\n\n// DECODE\n\n// Unpacks one mesh primitive and removes the extension from the primitive\n// DracoDecoder needs to be imported and registered by app\n// Returns: Promise that resolves when all pending draco decoder jobs for this mesh complete\n\n// TODO - Implement fallback behavior per KHR_DRACO_MESH_COMPRESSION spec\n\nasync function decompressPrimitive(\n scenegraph: GLTFScenegraph,\n primitive: GLTFMeshPrimitive,\n options: GLTFLoaderOptions,\n context: LoaderContext\n): Promise<void> {\n const dracoExtension = scenegraph.getObjectExtension<GLTF_KHR_draco_mesh_compression>(\n primitive,\n KHR_DRACO_MESH_COMPRESSION\n );\n if (!dracoExtension) {\n return;\n }\n\n const buffer = scenegraph.getTypedArrayForBufferView(dracoExtension.bufferView);\n // TODO - parse does not yet deal well with byte offsets embedded in typed arrays. Copy buffer\n // TODO - remove when `parse` is fixed to handle `byteOffset`s\n const bufferCopy = sliceArrayBuffer(buffer.buffer, buffer.byteOffset); // , buffer.byteLength);\n\n const dracoOptions: DracoLoaderOptions = {...options};\n\n // TODO - remove hack: The entire tileset might be included, too expensive to serialize\n delete dracoOptions['3d-tiles'];\n const decodedData = await parseFromContext(bufferCopy, DracoLoader, dracoOptions, context);\n\n const decodedAttributes: {[key: string]: GLTFAccessor} = getGLTFAccessors(decodedData.attributes);\n\n // Restore min/max values\n for (const [attributeName, decodedAttribute] of Object.entries(decodedAttributes)) {\n if (attributeName in primitive.attributes) {\n const accessorIndex: number = primitive.attributes[attributeName];\n const accessor = scenegraph.getAccessor(accessorIndex);\n if (accessor?.min && accessor?.max) {\n decodedAttribute.min = accessor.min;\n decodedAttribute.max = accessor.max;\n }\n }\n }\n\n // @ts-ignore\n primitive.attributes = decodedAttributes;\n if (decodedData.indices) {\n // @ts-ignore\n primitive.indices = getGLTFAccessor(decodedData.indices);\n }\n\n // Extension has been processed, delete it\n scenegraph.removeObjectExtension(primitive, KHR_DRACO_MESH_COMPRESSION);\n\n checkPrimitive(primitive);\n}\n\n// ENCODE\n\n// eslint-disable-next-line max-len\n// Only TRIANGLES: 0x0004 and TRIANGLE_STRIP: 0x0005 are supported\nfunction compressMesh(attributes, indices, mode: number = 4, options, context: LoaderContext) {\n if (!options.DracoWriter) {\n throw new Error('options.gltf.DracoWriter not provided');\n }\n\n // TODO - use DracoWriter using encode w/ registered DracoWriter...\n const compressedData = options.DracoWriter.encodeSync({attributes});\n\n // Draco compression may change the order and number of vertices in a mesh.\n // To satisfy the requirement that accessors properties be correct for both\n // compressed and uncompressed data, generators should create uncompressed\n // attributes and indices using data that has been decompressed from the Draco buffer,\n // rather than the original source data.\n // @ts-ignore TODO this needs to be fixed\n const decodedData = context?.parseSync?.({attributes});\n const fauxAccessors = options._addFauxAttributes(decodedData.attributes);\n\n const bufferViewIndex = options.addBufferView(compressedData);\n\n const glTFMesh = {\n primitives: [\n {\n attributes: fauxAccessors, // TODO - verify with spec\n mode, // GL.POINTS\n extensions: {\n [KHR_DRACO_MESH_COMPRESSION]: {\n bufferView: bufferViewIndex,\n attributes: fauxAccessors // TODO - verify with spec\n }\n }\n }\n ]\n };\n\n return glTFMesh;\n}\n\n// UTILS\n\nfunction checkPrimitive(primitive: GLTFMeshPrimitive) {\n if (!primitive.attributes && Object.keys(primitive.attributes).length > 0) {\n throw new Error('glTF: Empty primitive detected: Draco decompression failure?');\n }\n}\n\nfunction* makeMeshPrimitiveIterator(scenegraph) {\n for (const mesh of scenegraph.json.meshes || []) {\n for (const primitive of mesh.primitives) {\n yield primitive;\n }\n }\n}\n"],"mappings":"AAKA,SAAQA,gBAAgB,EAAEC,gBAAgB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AO,EAAc;IAACiC;EAAU,CAAC,CAAC;EACtD,MAAMqB,aAAa,GAAGvD,OAAO,CAACwD,kBAAkB,CAACxB,WAAW,CAACE,UAAU,CAAC;EAExE,MAAMuB,eAAe,GAAGzD,OAAO,CAAC0D,aAAa,CAACP,cAAc,CAAC;EAE7D,MAAMQ,QAAQ,GAAG;IACfC,UAAU,EAAE,CACV;MACE1B,UAAU,EAAEqB,aAAa;MACzBP,IAAI;MACJa,UAAU,EAAE;QACV,CAACjE,0BAA0B,GAAG;UAC5BgC,UAAU,EAAE6B,eAAe;UAC3BvB,UAAU,EAAEqB;QACd;MACF;IACF,CAAC;EAEL,CAAC;EAED,OAAOI,QAAQ;AACjB;AAIA,SAASb,cAAcA,CAAC3C,SAA4B,EAAE;EACpD,IAAI,CAACA,SAAS,CAAC+B,UAAU,IAAIG,MAAM,CAACyB,IAAI,CAAC3D,SAAS,CAAC+B,UAAU,CAAC,CAAChB,MAAM,GAAG,CAAC,EAAE;IACzE,MAAM,IAAIgC,KAAK,CAAC,8DAA8D,CAAC;EACjF;AACF;AAEA,UAAU9C,yBAAyBA,CAACF,UAAU,EAAE;EAC9C,KAAK,MAAMkB,IAAI,IAAIlB,UAAU,CAACmB,IAAI,CAACC,MAAM,IAAI,EAAE,EAAE;IAC/C,KAAK,MAAMnB,SAAS,IAAIiB,IAAI,CAACwC,UAAU,EAAE;MACvC,MAAMzD,SAAS;IACjB;EACF;AACF"}
@@ -1,4 +1,4 @@
1
- import { GLTFScenegraph } from '../api/gltf-scenegraph';
1
+ import { GLTFScenegraph } from "../api/gltf-scenegraph.js";
2
2
  const KHR_TEXTURE_BASISU = 'KHR_texture_basisu';
3
3
  export const name = KHR_TEXTURE_BASISU;
4
4
  export function preprocess(gltfData, options) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KHR_texture_basisu.js","names":["GLTFScenegraph","KHR_TEXTURE_BASISU","name","preprocess","gltfData","options","scene","json","texture","textures","extension","getObjectExtension","source","removeObjectExtension","removeExtension"],"sources":["../../../src/lib/extensions/KHR_texture_basisu.ts"],"sourcesContent":["// GLTF EXTENSION: KHR_texture_basisu\n// https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_basisu\n/* eslint-disable camelcase */\n\nimport type {GLTF, GLTF_KHR_texture_basisu} from '../types/gltf-json-schema';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\n\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\n\nconst KHR_TEXTURE_BASISU = 'KHR_texture_basisu';\n\n/** Extension name */\nexport const name = KHR_TEXTURE_BASISU;\n\n/**\n * Replaces a texture source reference with the extension texture\n * Done in preprocess() to prevent load of default image\n */\nexport function preprocess(gltfData: {json: GLTF}, options: GLTFLoaderOptions): void {\n const scene = new GLTFScenegraph(gltfData);\n const {json} = scene;\n\n for (const texture of json.textures || []) {\n const extension = scene.getObjectExtension<GLTF_KHR_texture_basisu>(\n texture,\n KHR_TEXTURE_BASISU\n );\n if (extension) {\n // TODO - if multiple texture extensions are present which one wins?\n texture.source = extension.source;\n scene.removeObjectExtension(texture, KHR_TEXTURE_BASISU);\n }\n }\n\n // Remove the top-level extension\n scene.removeExtension(KHR_TEXTURE_BASISU);\n}\n"],"mappings":"SAOQA,cAAc;AAEtB,MAAMC,kBAAkB,GAAG,oBAAoB;AAG/C,OAAO,MAAMC,IAAI,GAAGD,kBAAkB;AAMtC,OAAO,SAASE,UAAUA,CAACC,QAAsB,EAAEC,OAA0B,EAAQ;EACnF,MAAMC,KAAK,GAAG,IAAIN,cAAc,CAACI,QAAQ,CAAC;EAC1C,MAAM;IAACG;EAAI,CAAC,GAAGD,KAAK;EAEpB,KAAK,MAAME,OAAO,IAAID,IAAI,CAACE,QAAQ,IAAI,EAAE,EAAE;IACzC,MAAMC,SAAS,GAAGJ,KAAK,CAACK,kBAAkB,CACxCH,OAAO,EACPP,kBACF,CAAC;IACD,IAAIS,SAAS,EAAE;MAEbF,OAAO,CAACI,MAAM,GAAGF,SAAS,CAACE,MAAM;MACjCN,KAAK,CAACO,qBAAqB,CAACL,OAAO,EAAEP,kBAAkB,CAAC;IAC1D;EACF;EAGAK,KAAK,CAACQ,eAAe,CAACb,kBAAkB,CAAC;AAC3C"}
@@ -1,8 +1,8 @@
1
1
  import { Vector3, Matrix3 } from '@math.gl/core';
2
- import { getAccessorArrayTypeAndLength } from '../gltf-utils/gltf-utils';
3
- import { BYTES, COMPONENTS } from '../gltf-utils/gltf-constants';
4
- import '../types/gltf-json-schema';
5
- import { GLTFScenegraph } from '../api/gltf-scenegraph';
2
+ import { getAccessorArrayTypeAndLength } from "../gltf-utils/gltf-utils.js";
3
+ import { BYTES, COMPONENTS } from "../gltf-utils/gltf-constants.js";
4
+ import "../types/gltf-json-schema.js";
5
+ import { GLTFScenegraph } from "../api/gltf-scenegraph.js";
6
6
  const EXT_MESHOPT_TRANSFORM = 'KHR_texture_transform';
7
7
  export const name = EXT_MESHOPT_TRANSFORM;
8
8
  const scratchVector = new Vector3();
@@ -93,7 +93,7 @@ function transformPrimitive(gltfData, primitive, transformParameters) {
93
93
  texCoord,
94
94
  matrix
95
95
  } = transformParameters;
96
- const texCoordAccessor = primitive.attributes["TEXCOORD_".concat(originalTexCoord)];
96
+ const texCoordAccessor = primitive.attributes[`TEXCOORD_${originalTexCoord}`];
97
97
  if (Number.isFinite(texCoordAccessor)) {
98
98
  var _gltfData$json$access;
99
99
  const accessor = (_gltfData$json$access = gltfData.json.accessors) === null || _gltfData$json$access === void 0 ? void 0 : _gltfData$json$access[texCoordAccessor];
@@ -167,7 +167,7 @@ function createAttribute(newTexCoord, originalAccessor, primitive, gltfData, new
167
167
  count: originalAccessor.count,
168
168
  type: 'VEC2'
169
169
  });
170
- primitive.attributes["TEXCOORD_".concat(newTexCoord)] = accessors.length - 1;
170
+ primitive.attributes[`TEXCOORD_${newTexCoord}`] = accessors.length - 1;
171
171
  }
172
172
  function makeTransformationMatrix(extensionData) {
173
173
  const {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KHR_texture_transform.js","names":["Vector3","Matrix3","getAccessorArrayTypeAndLength","BYTES","COMPONENTS","GLTFScenegraph","EXT_MESHOPT_TRANSFORM","name","scratchVector","scratchRotationMatrix","scratchScaleMatrix","decode","gltfData","options","_options$gltf","gltfScenegraph","hasExtension","gltf","loadBuffers","materials","json","i","length","transformTexCoords","materialIndex","_gltfData$json$materi","_material$pbrMetallic","_material$pbrMetallic2","processedTexCoords","material","baseColorTexture","pbrMetallicRoughness","transformPrimitives","emisiveTexture","emissiveTexture","normalTexture","occlusionTexture","metallicRoughnessTexture","texture","transformParameters","getTransformParameters","meshes","mesh","primitive","primitives","Number","isFinite","transformPrimitive","_texture$extensions","textureInfo","extensions","texCoord","originalTexCoord","isProcessed","findIndex","_ref","original","newTexCoord","matrix","makeTransformationMatrix","push","texCoordAccessor","attributes","_gltfData$json$access","accessor","accessors","bufferView","_gltfData$json$buffer","bufferViews","arrayBuffer","byteOffset","bufferByteOffset","buffers","buffer","ArrayType","bytes","componentType","components","type","elementAddressScale","byteStride","result","Float32Array","count","uv","set","transformByMatrix3","updateGltf","createAttribute","newTexCoordArray","byteLength","originalAccessor","extensionData","offset","rotation","scale","translationMatrix","rotationMatrix","Math","cos","sin","scaleMatrix","multiplyRight"],"sources":["../../../src/lib/extensions/KHR_texture_transform.ts"],"sourcesContent":["/**\n * https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_transform/README.md\n */\n\nimport {Vector3, Matrix3} from '@math.gl/core';\nimport type {GLTFWithBuffers} from '../types/gltf-types';\nimport type {\n GLTFMeshPrimitive,\n GLTFAccessor,\n GLTFBufferView,\n GLTFMaterialNormalTextureInfo,\n GLTFMaterialOcclusionTextureInfo,\n GLTFTextureInfo\n} from '../types/gltf-json-schema';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\n\nimport {getAccessorArrayTypeAndLength} from '../gltf-utils/gltf-utils';\nimport {BYTES, COMPONENTS} from '../gltf-utils/gltf-constants';\nimport {} from '../types/gltf-json-schema';\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\n\n/** Extension name */\nconst EXT_MESHOPT_TRANSFORM = 'KHR_texture_transform';\n\nexport const name = EXT_MESHOPT_TRANSFORM;\n\nconst scratchVector = new Vector3();\nconst scratchRotationMatrix = new Matrix3();\nconst scratchScaleMatrix = new Matrix3();\n\n/** Extension textureInfo https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_transform#gltf-schema-updates */\ntype TextureInfo = {\n /** The offset of the UV coordinate origin as a factor of the texture dimensions. */\n offset?: [number, number];\n /** Rotate the UVs by this many radians counter-clockwise around the origin. This is equivalent to a similar rotation of the image clockwise. */\n rotation?: number;\n /** The scale factor applied to the components of the UV coordinates. */\n scale?: [number, number];\n /** Overrides the textureInfo texCoord value if supplied, and if this extension is supported. */\n texCoord?: number;\n};\n/** Intersection of all GLTF textures */\ntype CompoundGLTFTextureInfo = GLTFTextureInfo &\n GLTFMaterialNormalTextureInfo &\n GLTFMaterialOcclusionTextureInfo;\n/** Parameters for TEXCOORD transformation */\ntype TransformParameters = {\n /** Original texCoord value https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#_textureinfo_texcoord */\n originalTexCoord: number;\n /** New texCoord value from extension https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_transform#gltf-schema-updates */\n texCoord: number;\n /** Transformation matrix */\n matrix: Matrix3;\n};\n\n/**\n * The extension entry to process the transformation\n * @param gltfData gltf buffers and json\n * @param options GLTFLoader options\n */\nexport async function decode(gltfData: GLTFWithBuffers, options: GLTFLoaderOptions) {\n const gltfScenegraph = new GLTFScenegraph(gltfData);\n const hasExtension = gltfScenegraph.hasExtension(EXT_MESHOPT_TRANSFORM);\n if (!hasExtension || !options.gltf?.loadBuffers) {\n return;\n }\n const materials = gltfData.json.materials || [];\n for (let i = 0; i < materials.length; i++) {\n transformTexCoords(i, gltfData);\n }\n}\n\n/**\n * Transform TEXCOORD by material\n * @param materialIndex processing material index\n * @param gltfData gltf buffers and json\n */\nfunction transformTexCoords(materialIndex: number, gltfData: GLTFWithBuffers): void {\n // Save processed texCoords in order no to process the same twice\n const processedTexCoords: [number, number][] = [];\n const material = gltfData.json.materials?.[materialIndex];\n const baseColorTexture = material?.pbrMetallicRoughness?.baseColorTexture;\n if (baseColorTexture) {\n transformPrimitives(gltfData, materialIndex, baseColorTexture, processedTexCoords);\n }\n const emisiveTexture = material?.emissiveTexture;\n if (emisiveTexture) {\n transformPrimitives(gltfData, materialIndex, emisiveTexture, processedTexCoords);\n }\n const normalTexture = material?.normalTexture;\n if (normalTexture) {\n transformPrimitives(gltfData, materialIndex, normalTexture, processedTexCoords);\n }\n const occlusionTexture = material?.occlusionTexture;\n if (occlusionTexture) {\n transformPrimitives(gltfData, materialIndex, occlusionTexture, processedTexCoords);\n }\n const metallicRoughnessTexture = material?.pbrMetallicRoughness?.metallicRoughnessTexture;\n if (metallicRoughnessTexture) {\n transformPrimitives(gltfData, materialIndex, metallicRoughnessTexture, processedTexCoords);\n }\n}\n\n/**\n * Transform primitives of the particular material\n * @param gltfData gltf data\n * @param materialIndex primitives with this material will be transformed\n * @param texture texture object\n * @param processedTexCoords storage to save already processed texCoords\n */\nfunction transformPrimitives(\n gltfData: GLTFWithBuffers,\n materialIndex: number,\n texture: CompoundGLTFTextureInfo,\n processedTexCoords: [number, number][]\n) {\n const transformParameters = getTransformParameters(texture, processedTexCoords);\n if (!transformParameters) {\n return;\n }\n const meshes = gltfData.json.meshes || [];\n for (const mesh of meshes) {\n for (const primitive of mesh.primitives) {\n const material = primitive.material;\n if (Number.isFinite(material) && materialIndex === material) {\n transformPrimitive(gltfData, primitive, transformParameters);\n }\n }\n }\n}\n\n/**\n * Get parameters for TEXCOORD transformation\n * @param texture texture object\n * @param processedTexCoords storage to save already processed texCoords\n * @returns texCoord couple and transformation matrix\n */\nfunction getTransformParameters(\n texture: CompoundGLTFTextureInfo,\n processedTexCoords: [number, number][]\n): TransformParameters | null {\n const textureInfo = texture.extensions?.[EXT_MESHOPT_TRANSFORM];\n const {texCoord: originalTexCoord = 0} = texture;\n // If texCoord is not set in the extension, original attribute data will be replaced\n const {texCoord = originalTexCoord} = textureInfo;\n // Make sure that couple [originalTexCoord, extensionTexCoord] is not processed twice\n const isProcessed =\n processedTexCoords.findIndex(\n ([original, newTexCoord]) => original === originalTexCoord && newTexCoord === texCoord\n ) !== -1;\n if (!isProcessed) {\n const matrix = makeTransformationMatrix(textureInfo);\n if (originalTexCoord !== texCoord) {\n texture.texCoord = texCoord;\n }\n processedTexCoords.push([originalTexCoord, texCoord]);\n return {originalTexCoord, texCoord, matrix};\n }\n return null;\n}\n\n/**\n * Transform `TEXCOORD_0` attribute in the primitive\n * @param gltfData gltf data\n * @param primitive primitive object\n * @param transformParameters texCoord couple and transformation matrix\n */\nfunction transformPrimitive(\n gltfData: GLTFWithBuffers,\n primitive: GLTFMeshPrimitive,\n transformParameters: TransformParameters\n) {\n const {originalTexCoord, texCoord, matrix} = transformParameters;\n const texCoordAccessor = primitive.attributes[`TEXCOORD_${originalTexCoord}`];\n if (Number.isFinite(texCoordAccessor)) {\n // Get accessor of the `TEXCOORD_0` attribute\n const accessor = gltfData.json.accessors?.[texCoordAccessor];\n if (accessor && accessor.bufferView) {\n // Get `bufferView` of the `accessor`\n const bufferView = gltfData.json.bufferViews?.[accessor.bufferView];\n if (bufferView) {\n // Get `arrayBuffer` the `bufferView` look at\n const {arrayBuffer, byteOffset: bufferByteOffset} = gltfData.buffers[bufferView.buffer];\n // Resulting byteOffset is sum of the buffer, accessor and bufferView byte offsets\n const byteOffset =\n (bufferByteOffset || 0) + (accessor.byteOffset || 0) + (bufferView.byteOffset || 0);\n // Deduce TypedArray type and its length from `accessor` and `bufferView` data\n const {ArrayType, length} = getAccessorArrayTypeAndLength(accessor, bufferView);\n // Number of bytes each component occupies\n const bytes = BYTES[accessor.componentType];\n // Number of components. For the `TEXCOORD_0` with `VEC2` type, it must return 2\n const components = COMPONENTS[accessor.type];\n // Multiplier to calculate the address of the `TEXCOORD_0` element in the arrayBuffer\n const elementAddressScale = bufferView.byteStride || bytes * components;\n // Data transform to Float32Array\n const result = new Float32Array(length);\n for (let i = 0; i < accessor.count; i++) {\n // Take [u, v] couple from the arrayBuffer\n const uv = new ArrayType(arrayBuffer, byteOffset + i * elementAddressScale, 2);\n // Set and transform Vector3 per https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_transform#overview\n scratchVector.set(uv[0], uv[1], 1);\n scratchVector.transformByMatrix3(matrix);\n // Save result in Float32Array\n result.set([scratchVector[0], scratchVector[1]], i * components);\n }\n // If texCoord the same, replace gltf structural data\n if (originalTexCoord === texCoord) {\n updateGltf(accessor, bufferView, gltfData.buffers, result);\n } else {\n // If texCoord change, create new attribute\n createAttribute(texCoord, accessor, primitive, gltfData, result);\n }\n }\n }\n }\n}\n\n/**\n * Update GLTF structural objects with new data as we create new `Float32Array` for `TEXCOORD_0`.\n * @param accessor accessor to change\n * @param bufferView bufferView to change\n * @param buffers binary buffers\n * @param newTexcoordArray typed array with data after transformation\n */\nfunction updateGltf(\n accessor: GLTFAccessor,\n bufferView: GLTFBufferView,\n buffers: {arrayBuffer: ArrayBuffer; byteOffset: number; byteLength: number}[],\n newTexCoordArray: Float32Array\n): void {\n accessor.componentType = 5126;\n buffers.push({\n arrayBuffer: newTexCoordArray.buffer,\n byteOffset: 0,\n byteLength: newTexCoordArray.buffer.byteLength\n });\n bufferView.buffer = buffers.length - 1;\n bufferView.byteLength = newTexCoordArray.buffer.byteLength;\n bufferView.byteOffset = 0;\n delete bufferView.byteStride;\n}\n\n/**\n *\n * @param newTexCoord new `texCoord` value\n * @param originalAccessor original accessor object, that store data before transformation\n * @param primitive primitive object\n * @param gltfData gltf data\n * @param newTexCoordArray typed array with data after transformation\n * @returns\n */\nfunction createAttribute(\n newTexCoord: number,\n originalAccessor: GLTFAccessor,\n primitive: GLTFMeshPrimitive,\n gltfData: GLTFWithBuffers,\n newTexCoordArray: Float32Array\n) {\n gltfData.buffers.push({\n arrayBuffer: newTexCoordArray.buffer,\n byteOffset: 0,\n byteLength: newTexCoordArray.buffer.byteLength\n });\n const bufferViews = gltfData.json.bufferViews;\n if (!bufferViews) {\n return;\n }\n bufferViews.push({\n buffer: gltfData.buffers.length - 1,\n byteLength: newTexCoordArray.buffer.byteLength,\n byteOffset: 0\n });\n const accessors = gltfData.json.accessors;\n if (!accessors) {\n return;\n }\n accessors.push({\n bufferView: bufferViews?.length - 1,\n byteOffset: 0,\n componentType: 5126,\n count: originalAccessor.count,\n type: 'VEC2'\n });\n primitive.attributes[`TEXCOORD_${newTexCoord}`] = accessors.length - 1;\n}\n\n/**\n * Construct transformation matrix from the extension data (transition, rotation, scale)\n * @param extensionData extension data\n * @returns transformation matrix\n */\nfunction makeTransformationMatrix(extensionData: TextureInfo): Matrix3 {\n const {offset = [0, 0], rotation = 0, scale = [1, 1]} = extensionData;\n const translationMatrix = new Matrix3().set(1, 0, 0, 0, 1, 0, offset[0], offset[1], 1);\n const rotationMatrix = scratchRotationMatrix.set(\n Math.cos(rotation),\n Math.sin(rotation),\n 0,\n -Math.sin(rotation),\n Math.cos(rotation),\n 0,\n 0,\n 0,\n 1\n );\n const scaleMatrix = scratchScaleMatrix.set(scale[0], 0, 0, 0, scale[1], 0, 0, 0, 1);\n return translationMatrix.multiplyRight(rotationMatrix).multiplyRight(scaleMatrix);\n}\n"],"mappings":"AAIA,SAAQA,OAAO,EAAEC,OAAO,QAAO,eAAe;AAAC,SAYvCC,6BAA6B;AAAA,SAC7BC,KAAK,EAAEC,UAAU;AAAA;AAAA,SAEjBC,cAAc;AAGtB,MAAMC,qBAAqB,GAAG,uBAAuB;AAErD,OAAO,MAAMC,IAAI,GAAGD,qBAAqB;AAEzC,MAAME,aAAa,GAAG,IAAIR,OAAO,CAAC,CAAC;AACnC,MAAMS,qBAAqB,GAAG,IAAIR,OAAO,CAAC,CAAC;AAC3C,MAAMS,kBA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,EAAE,CAAC,EAAE,CAAC,EAAEQ,MAAM,CAAC,CAAC,CAAC,EAAEA,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;EACtF,MAAMI,cAAc,GAAGxF,qBAAqB,CAAC4E,GAAG,CAC9Ca,IAAI,CAACC,GAAG,CAACL,QAAQ,CAAC,EAClBI,IAAI,CAACE,GAAG,CAACN,QAAQ,CAAC,EAClB,CAAC,EACD,CAACI,IAAI,CAACE,GAAG,CAACN,QAAQ,CAAC,EACnBI,IAAI,CAACC,GAAG,CAACL,QAAQ,CAAC,EAClB,CAAC,EACD,CAAC,EACD,CAAC,EACD,CACF,CAAC;EACD,MAAMO,WAAW,GAAG3F,kBAAkB,CAAC2E,GAAG,CAACU,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAEA,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;EACnF,OAAOC,iBAAiB,CAACM,aAAa,CAACL,cAAc,CAAC,CAACK,aAAa,CAACD,WAAW,CAAC;AACnF"}
@@ -1,5 +1,5 @@
1
- import { GLTFScenegraph } from '../../api/gltf-scenegraph';
2
- import { convertRawBufferToMetadataArray, getPrimitiveTextureData, primitivePropertyDataToAttributes, getArrayElementByteSize, getOffsetsForProperty, parseVariableLengthArrayNumeric, parseFixedLengthArrayNumeric, getPropertyDataString } from '../utils/3d-tiles-utils';
1
+ import { GLTFScenegraph } from "../../api/gltf-scenegraph.js";
2
+ import { convertRawBufferToMetadataArray, getPrimitiveTextureData, primitivePropertyDataToAttributes, getArrayElementByteSize, getOffsetsForProperty, parseVariableLengthArrayNumeric, parseFixedLengthArrayNumeric, getPropertyDataString } from "../utils/3d-tiles-utils.js";
3
3
  const EXT_FEATURE_METADATA_NAME = 'EXT_feature_metadata';
4
4
  export const name = EXT_FEATURE_METADATA_NAME;
5
5
  export async function decode(gltfData, options) {
@@ -113,7 +113,7 @@ function processPropertyTable(scenegraph, schema, propertyTable) {
113
113
  }
114
114
  const schemaClass = (_schema$classes = schema.classes) === null || _schema$classes === void 0 ? void 0 : _schema$classes[propertyTable.class];
115
115
  if (!schemaClass) {
116
- throw new Error("Incorrect data in the EXT_structural_metadata extension: no schema class with name ".concat(propertyTable.class));
116
+ throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`);
117
117
  }
118
118
  const numberOfElements = propertyTable.count;
119
119
  for (const propertyName in schemaClass.properties) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EXT_feature_metadata.js","names":["GLTFScenegraph","convertRawBufferToMetadataArray","getPrimitiveTextureData","primitivePropertyDataToAttributes","getArrayElementByteSize","getOffsetsForProperty","parseVariableLengthArrayNumeric","parseFixedLengthArrayNumeric","getPropertyDataString","EXT_FEATURE_METADATA_NAME","name","decode","gltfData","options","scenegraph","decodeExtFeatureMetadata","getPropertyTableFromExtFeatureMetadata","extension","metadataClass","featureTables","_Object$keys","firstFeatureTableName","Object","keys","featureTable","propertyTable","propertyName","properties","data","featureTextures","featureTexture","textureKey","texture","class","console","warn","_options$gltf","_options$gltf2","gltf","loadBuffers","getExtension","loadImages","decodePropertyTextures","decodePropertyTables","schema","schemaClasses","classes","schemaName","schemaClass","findFeatureTextureByClass","handleFeatureTextureProperties","propertyTables","findPropertyTableByClass","processPropertyTable","schemaClassName","propertyTableName","featureTexturesName","_schema$classes","Error","numberOfElements","count","_propertyTable$proper","classProperty","propertyTableProperty","getPropertyDataFromBinarySource","attributeName","_featureTexture$prope","featureTextureProperty","getPropertyDataFromTexture","numberOfFeatures","featureTableProperty","bufferView","dataArray","getTypedArrayForBufferView","arrayOffsets","getArrayOffsetsForProperty","stringOffsets","getStringOffsetsForProperty","type","componentType","isNumericProperty","getPropertyDataNumeric","componentCount","arrayOffsetBufferView","offsetType","stringOffsetBufferView","schemaProperty","types","includes","valuesDataBytes","isArray","arrayCount","attributeType","elementSize","elementCount","byteLength","valuesData","length","json","meshes","featureTextureTable","mesh","primitive","primitives","processPrimitiveTextures","textureInfoTopLevel","channels","propertyData"],"sources":["../../../../src/lib/extensions/deprecated/EXT_feature_metadata.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport type {GLTF, GLTFTextureInfoMetadata} from '../../types/gltf-json-schema';\nimport type {\n GLTF_EXT_feature_metadata_Class,\n GLTF_EXT_feature_metadata_ClassProperty,\n GLTF_EXT_feature_metadata_FeatureTable,\n GLTF_EXT_feature_metadata_FeatureTableProperty,\n GLTF_EXT_feature_metadata_FeatureTexture,\n GLTF_EXT_feature_metadata_GLTF,\n GLTF_EXT_feature_metadata_TextureAccessor,\n GLTF_EXT_feature_metadata_Schema\n} from '../../types/gltf-ext-feature-metadata-schema';\nimport type {BigTypedArray, TypedArray} from '@loaders.gl/schema';\nimport type {FeatureTableJson} from '../../types/gltf-types';\nimport {GLTFScenegraph} from '../../api/gltf-scenegraph';\nimport {GLTFMeshPrimitive} from '../../types/gltf-json-schema';\nimport {GLTFLoaderOptions} from '../../../gltf-loader';\nimport {\n convertRawBufferToMetadataArray,\n getPrimitiveTextureData,\n primitivePropertyDataToAttributes,\n getArrayElementByteSize,\n NumericComponentType,\n getOffsetsForProperty,\n parseVariableLengthArrayNumeric,\n parseFixedLengthArrayNumeric,\n getPropertyDataString\n} from '../utils/3d-tiles-utils';\n\n/** Extension name */\nconst EXT_FEATURE_METADATA_NAME = 'EXT_feature_metadata';\nexport const name = EXT_FEATURE_METADATA_NAME;\n\nexport async function decode(gltfData: {json: GLTF}, options: GLTFLoaderOptions): Promise<void> {\n const scenegraph = new GLTFScenegraph(gltfData);\n decodeExtFeatureMetadata(scenegraph, options);\n}\n\n/**\n * Handles EXT_feature_metadata to get property table.\n * @param extension - Global level of EXT_FEATURE_METADATA extension.\n * @param metadataClass - User selected feature metadata class name.\n * @returns {FeatureTableJson | null} Property table or null if the extension can't be handled properly.\n */\nexport function getPropertyTableFromExtFeatureMetadata(\n extension: GLTF_EXT_feature_metadata_GLTF,\n metadataClass?: string\n): FeatureTableJson | null {\n if (extension.featureTables) {\n /**\n * Take only first feature table to generate attributes storage info object.\n * TODO: Think about getting data from all feature tables?\n * It can be tricky just because 3dTiles is able to have multiple featureId attributes and multiple feature tables.\n * In I3S we should decide which featureIds attribute will be passed to geometry data.\n */\n const firstFeatureTableName = Object.keys(extension.featureTables)?.[0];\n\n if (firstFeatureTableName) {\n const featureTable = extension.featureTables[firstFeatureTableName];\n const propertyTable = {};\n\n for (const propertyName in featureTable.properties) {\n propertyTable[propertyName] = featureTable.properties[propertyName].data;\n }\n\n return propertyTable;\n }\n }\n\n if (extension.featureTextures) {\n let featureTexture: string | undefined;\n for (const textureKey in extension.featureTextures) {\n const texture = extension.featureTextures[textureKey];\n if (texture.class === metadataClass) {\n featureTexture = textureKey;\n }\n }\n\n if (typeof featureTexture === 'string') {\n const featureTable = extension.featureTextures[featureTexture];\n const propertyTable = {};\n\n for (const propertyName in featureTable.properties) {\n propertyTable[propertyName] = featureTable.properties[propertyName].data;\n }\n\n return propertyTable;\n }\n }\n\n // eslint-disable-next-line no-console\n console.warn(\n 'Cannot get property table from EXT_feature_metadata extension. There is neither featureTables, nor featureTextures in the extension.'\n );\n return null;\n}\n\n/**\n * Decodes feature metadata from extension.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param options - GLTFLoader options.\n */\nfunction decodeExtFeatureMetadata(scenegraph: GLTFScenegraph, options: GLTFLoaderOptions): void {\n // Decoding metadata involves buffers processing.\n // So, if buffers have not been loaded, there is no reason to process metadata.\n if (!options.gltf?.loadBuffers) {\n return;\n }\n const extension: GLTF_EXT_feature_metadata_GLTF | null =\n scenegraph.getExtension(EXT_FEATURE_METADATA_NAME);\n if (!extension) {\n return;\n }\n\n if (options.gltf?.loadImages) {\n decodePropertyTextures(scenegraph, extension);\n }\n\n decodePropertyTables(scenegraph, extension);\n}\n\n/**\n * Processes the data stored in the textures\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param extension - Top-level extension.\n */\nfunction decodePropertyTextures(\n scenegraph: GLTFScenegraph,\n extension: GLTF_EXT_feature_metadata_GLTF\n): void {\n const schema = extension.schema;\n if (!schema) {\n return;\n }\n const schemaClasses = schema.classes;\n\n const {featureTextures} = extension;\n if (schemaClasses && featureTextures) {\n for (const schemaName in schemaClasses) {\n const schemaClass = schemaClasses[schemaName];\n const featureTexture = findFeatureTextureByClass(featureTextures, schemaName);\n\n if (featureTexture) {\n handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass);\n }\n }\n }\n}\n\n/**\n * Processes the data stored in the property tables.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param extension - Top-level extension.\n */\nfunction decodePropertyTables(\n scenegraph: GLTFScenegraph,\n extension: GLTF_EXT_feature_metadata_GLTF\n): void {\n const schema = extension.schema;\n if (!schema) {\n return;\n }\n const schemaClasses = schema.classes;\n const propertyTables = extension.featureTables;\n if (schemaClasses && propertyTables) {\n for (const schemaName in schemaClasses) {\n const propertyTable = findPropertyTableByClass(propertyTables, schemaName);\n if (propertyTable) {\n processPropertyTable(scenegraph, schema, propertyTable);\n }\n }\n }\n}\n\n/**\n * Finds the property table by class name.\n * @param propertyTables - propertyTable definition taken from the top-level extension.\n * @param schemaClassName - class name in the extension schema.\n */\nfunction findPropertyTableByClass(\n propertyTables: {[key: string]: GLTF_EXT_feature_metadata_FeatureTable},\n schemaClassName: string\n): GLTF_EXT_feature_metadata_FeatureTable | null {\n for (const propertyTableName in propertyTables) {\n const propertyTable = propertyTables[propertyTableName];\n if (propertyTable.class === schemaClassName) {\n return propertyTable;\n }\n }\n\n return null;\n}\n\nfunction findFeatureTextureByClass(\n featureTextures: {[key: string]: GLTF_EXT_feature_metadata_FeatureTexture},\n schemaClassName: string\n): GLTF_EXT_feature_metadata_FeatureTexture | null {\n for (const featureTexturesName in featureTextures) {\n const featureTable = featureTextures[featureTexturesName];\n\n if (featureTable.class === schemaClassName) {\n return featureTable;\n }\n }\n\n return null;\n}\n\n/**\n * Navigates through all properies in the property table, gets properties data,\n * and put the data to `propertyTable.data` as an array.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param schema - schema object.\n * @param propertyTable - propertyTable definition taken from the top-level extension.\n */\nfunction processPropertyTable(\n scenegraph: GLTFScenegraph,\n schema: GLTF_EXT_feature_metadata_Schema,\n propertyTable: GLTF_EXT_feature_metadata_FeatureTable\n): void {\n // Though 'class' is not required by spec, it doesn't make any scence when it's not provided.\n // So, bale out here.\n if (!propertyTable.class) {\n return;\n }\n\n const schemaClass = schema.classes?.[propertyTable.class];\n if (!schemaClass) {\n throw new Error(\n `Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`\n );\n }\n\n const numberOfElements = propertyTable.count; // `propertyTable.count` is a number of elements in each property array.\n\n for (const propertyName in schemaClass.properties) {\n const classProperty = schemaClass.properties[propertyName];\n const propertyTableProperty: GLTF_EXT_feature_metadata_FeatureTableProperty | undefined =\n propertyTable.properties?.[propertyName];\n\n if (propertyTableProperty) {\n // Getting all elements (`numberOfElements`) of the array in the `propertyTableProperty`\n const data = getPropertyDataFromBinarySource(\n scenegraph,\n schema,\n classProperty,\n numberOfElements,\n propertyTableProperty\n );\n propertyTableProperty.data = data;\n }\n }\n}\n\n/**\n * Navigates through all properies in feature texture and gets properties data.\n * Data will be stored in featureTexture.properties[propertyName].data.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param featureTexture\n * @param schemaClass\n */\nfunction handleFeatureTextureProperties(\n scenegraph: GLTFScenegraph,\n featureTexture: GLTF_EXT_feature_metadata_FeatureTexture,\n schemaClass: GLTF_EXT_feature_metadata_Class\n): void {\n const attributeName = featureTexture.class;\n\n for (const propertyName in schemaClass.properties) {\n const featureTextureProperty = featureTexture?.properties?.[propertyName];\n\n if (featureTextureProperty) {\n const data = getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName);\n featureTextureProperty.data = data;\n }\n }\n}\n\n/**\n * Decodes properties from binary sourse based on property type.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param schemaProperty\n * @param numberOfFeatures\n * @param featureTableProperty\n */\nfunction getPropertyDataFromBinarySource(\n scenegraph: GLTFScenegraph,\n schema: GLTF_EXT_feature_metadata_Schema,\n classProperty: GLTF_EXT_feature_metadata_ClassProperty,\n numberOfFeatures: number,\n featureTableProperty: GLTF_EXT_feature_metadata_FeatureTableProperty\n): string[] | BigTypedArray | string[][] | BigTypedArray[] {\n let data: string[] | BigTypedArray | string[][] | BigTypedArray[] = [];\n const bufferView = featureTableProperty.bufferView;\n const dataArray: Uint8Array = scenegraph.getTypedArrayForBufferView(bufferView);\n\n const arrayOffsets = getArrayOffsetsForProperty(\n scenegraph,\n classProperty,\n featureTableProperty,\n numberOfFeatures\n );\n const stringOffsets = getStringOffsetsForProperty(\n scenegraph,\n classProperty,\n featureTableProperty,\n numberOfFeatures\n );\n\n if (classProperty.type === 'STRING' || classProperty.componentType === 'STRING') {\n data = getPropertyDataString(numberOfFeatures, dataArray, arrayOffsets, stringOffsets);\n } else if (isNumericProperty(classProperty)) {\n data = getPropertyDataNumeric(classProperty, numberOfFeatures, dataArray, arrayOffsets);\n }\n\n return data;\n}\n\n/**\n * Parses propertyTable.property.arrayOffsets that are offsets of sub-arrays in a flatten array of values.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param classProperty - class property object.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @returns Typed array with offset values.\n * @see https://github.com/CesiumGS/glTF/blob/2976f1183343a47a29e4059a70961371cd2fcee8/extensions/2.0/Vendor/EXT_structural_metadata/schema/propertyTable.property.schema.json#L21\n */\nfunction getArrayOffsetsForProperty(\n scenegraph: GLTFScenegraph,\n classProperty: GLTF_EXT_feature_metadata_ClassProperty,\n propertyTableProperty: GLTF_EXT_feature_metadata_FeatureTableProperty,\n numberOfElements: number\n): TypedArray | null {\n /*\n If ARRAY is used, then componentType must also be specified.\n ARRAY is a fixed-length array when componentCount is defined, and variable-length otherwise.\n*/\n if (\n classProperty.type === 'ARRAY' &&\n // `componentCount` is a number of fixed-length array elements.\n // If `componentCount` is NOT defined, it's a VARIABLE-length array\n typeof classProperty.componentCount === 'undefined' &&\n // `arrayOffsetBufferView` is an index of the buffer view containing offsets for variable-length arrays.\n typeof propertyTableProperty.arrayOffsetBufferView !== 'undefined'\n ) {\n // Data are in a VARIABLE-length array\n return getOffsetsForProperty(\n scenegraph,\n propertyTableProperty.arrayOffsetBufferView,\n propertyTableProperty.offsetType || 'UINT32', // offsetType is used both for stringOffsetBufferView and arrayOffsetBufferView\n numberOfElements\n );\n }\n return null;\n}\n\n/**\n * Parses featureTable.property.stringOffsetBufferView.\n * String offsets is an array of offsets of strings in the united array of characters.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @returns Typed array of offset values. The number of offsets in the array is equal to `numberOfElements` plus one.\n * @see https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_feature_metadata/schema/featureTable.property.schema.json#L50C10-L50C32\n */\nfunction getStringOffsetsForProperty(\n scenegraph: GLTFScenegraph,\n classProperty: GLTF_EXT_feature_metadata_ClassProperty,\n propertyTableProperty: GLTF_EXT_feature_metadata_FeatureTableProperty,\n numberOfElements: number\n): TypedArray | null {\n if (\n typeof propertyTableProperty.stringOffsetBufferView !== 'undefined' // `stringOffsetBufferView` is an index of the buffer view containing offsets for strings.\n ) {\n // Data are in a FIXED-length array\n return getOffsetsForProperty(\n scenegraph,\n propertyTableProperty.stringOffsetBufferView,\n propertyTableProperty.offsetType || 'UINT32', // offsetType is used both for stringOffsetBufferView and arrayOffsetBufferView\n numberOfElements\n );\n }\n return null;\n}\n\n/**\n * Checks if the feature table property is of numeric type.\n * @param schemaPropertyType - feature table property\n * @returns true if property is numeric, else - false\n */\nfunction isNumericProperty(schemaProperty: GLTF_EXT_feature_metadata_ClassProperty): boolean {\n const types = [\n 'UINT8',\n 'INT16',\n 'UINT16',\n 'INT32',\n 'UINT32',\n 'INT64',\n 'UINT64',\n 'FLOAT32',\n 'FLOAT64'\n ];\n return (\n types.includes(schemaProperty.type) ||\n (typeof schemaProperty.componentType !== 'undefined' &&\n types.includes(schemaProperty.componentType))\n );\n}\n\n/**\n * Decodes properties of numeric types from binary sourse.\n * @param classProperty - class property object.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param valuesDataBytes - Data taken from values property of the property table property.\n * @param arrayOffsets - Offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @returns Property values in a typed array or in an array of typed arrays.\n */\nfunction getPropertyDataNumeric(\n classProperty: GLTF_EXT_feature_metadata_ClassProperty,\n numberOfElements: number,\n valuesDataBytes: Uint8Array,\n arrayOffsets: TypedArray | null\n): BigTypedArray | BigTypedArray[] {\n const isArray = classProperty.type === 'ARRAY';\n const arrayCount = classProperty.componentCount;\n\n /*\n We are getting Numeric data. So,\n the component type can be one of NumericComponentType,\n the attribute type should be 'SCALAR'\n */\n const attributeType = 'SCALAR';\n const componentType = classProperty.componentType || classProperty.type;\n const elementSize = getArrayElementByteSize(attributeType, componentType);\n const elementCount = valuesDataBytes.byteLength / elementSize;\n\n const valuesData: BigTypedArray = convertRawBufferToMetadataArray(\n valuesDataBytes,\n attributeType,\n componentType as NumericComponentType,\n elementCount\n );\n\n if (isArray) {\n if (arrayOffsets) {\n // VARIABLE-length array\n return parseVariableLengthArrayNumeric(\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytes.length,\n elementSize\n );\n }\n if (arrayCount) {\n // FIXED-length array\n return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);\n }\n return [];\n }\n\n return valuesData;\n}\n\n/**\n * Gets properties from texture associated with all mesh primitives.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param featureTextureProperty\n * @param attributeName\n * @returns Feature texture data\n */\nfunction getPropertyDataFromTexture(\n scenegraph: GLTFScenegraph,\n featureTextureProperty: GLTF_EXT_feature_metadata_TextureAccessor,\n attributeName: string\n): number[] {\n const json = scenegraph.gltf.json;\n if (!json.meshes) {\n return [];\n }\n const featureTextureTable: number[] = [];\n for (const mesh of json.meshes) {\n for (const primitive of mesh.primitives) {\n processPrimitiveTextures(\n scenegraph,\n attributeName,\n featureTextureProperty,\n featureTextureTable,\n primitive\n );\n }\n }\n return featureTextureTable;\n}\n\n/**\n * Processes data encoded in the texture associated with the primitive. This data will be accessible through the attributes.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param attributeName\n * @param featureTextureProperty\n * @param featureTextureTable\n * @param primitive\n */\nfunction processPrimitiveTextures(\n scenegraph: GLTFScenegraph,\n attributeName: string,\n featureTextureProperty: GLTF_EXT_feature_metadata_TextureAccessor,\n featureTextureTable: number[],\n primitive: GLTFMeshPrimitive\n): void {\n const textureInfoTopLevel: GLTFTextureInfoMetadata = {\n channels: featureTextureProperty.channels,\n ...featureTextureProperty.texture\n };\n const propertyData: number[] | null = getPrimitiveTextureData(\n scenegraph,\n textureInfoTopLevel,\n primitive\n );\n if (!propertyData) {\n return;\n }\n primitivePropertyDataToAttributes(\n scenegraph,\n attributeName,\n propertyData,\n featureTextureTable,\n primitive\n );\n}\n"],"mappings":"SAcQA,cAAc;AAAA,SAIpBC,+BAA+B,EAC/BC,uBAAuB,EACvBC,iCAAiC,EACjCC,uBAAuB,EAEvBC,qBAAqB,EACrBC,+BAA+B,EAC/BC,4BAA4B,EAC5BC,qBAAqB;AAIvB,MAAMC,yBAAyB,GAAG,sBAAsB;AACxD,OAAO,MAAMC,IAAI,GAAGD,yBAAyB;AAE7C,OAAO,eAAeE,MAAMA,CAACC,QAAsB,EAAEC,OAA0B,EAAiB;EAC9F,MAAMC,UAAU,GAAG,IAAId,cAAc,CAACY,QAAQ,CAAC;E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ACQ,MAAM,EACtBJ,WACF,CAAC;IACH;IACA,IAAIF,UAAU,EAAE;MAEd,OAAOpF,4BAA4B,CAACyF,UAAU,EAAErC,gBAAgB,EAAEgC,UAAU,CAAC;IAC/E;IACA,OAAO,EAAE;EACX;EAEA,OAAOK,UAAU;AACnB;AASA,SAAS5B,0BAA0BA,CACjCtD,UAA0B,EAC1BqD,sBAAiE,EACjEF,aAAqB,EACX;EACV,MAAMiC,IAAI,GAAGpF,UAAU,CAACwB,IAAI,CAAC4D,IAAI;EACjC,IAAI,CAACA,IAAI,CAACC,MAAM,EAAE;IAChB,OAAO,EAAE;EACX;EACA,MAAMC,mBAA6B,GAAG,EAAE;EACxC,KAAK,MAAMC,IAAI,IAAIH,IAAI,CAACC,MAAM,EAAE;IAC9B,KAAK,MAAMG,SAAS,IAAID,IAAI,CAACE,UAAU,EAAE;MACvCC,wBAAwB,CACtB1F,UAAU,EACVmD,aAAa,EACbE,sBAAsB,EACtBiC,mBAAmB,EACnBE,SACF,CAAC;IACH;EACF;EACA,OAAOF,mBAAmB;AAC5B;AAUA,SAASI,wBAAwBA,CAC/B1F,UAA0B,EAC1BmD,aAAqB,EACrBE,sBAAiE,EACjEiC,mBAA6B,EAC7BE,SAA4B,EACtB;EACN,MAAMG,mBAA4C,GAAG;IACnDC,QAAQ,EAAEvC,sBAAsB,CAACuC,QAAQ;IACzC,GAAGvC,sBAAsB,CAACnC;EAC5B,CAAC;EACD,MAAM2E,YAA6B,GAAGzG,uBAAuB,CAC3DY,UAAU,EACV2F,mBAAmB,EACnBH,SACF,CAAC;EACD,IAAI,CAACK,YAAY,EAAE;IACjB;EACF;EACAxG,iCAAiC,CAC/BW,UAAU,EACVmD,aAAa,EACb0C,YAAY,EACZP,mBAAmB,EACnBE,SACF,CAAC;AACH"}
@@ -1,5 +1,5 @@
1
- import { assert } from '../../utils/assert';
2
- import { GLTFScenegraph } from '../../api/gltf-scenegraph';
1
+ import { assert } from "../../utils/assert.js";
2
+ import { GLTFScenegraph } from "../../api/gltf-scenegraph.js";
3
3
  const KHR_LIGHTS_PUNCTUAL = 'KHR_lights_punctual';
4
4
  export const name = KHR_LIGHTS_PUNCTUAL;
5
5
  export async function decode(gltfData) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KHR_lights_punctual.js","names":["assert","GLTFScenegraph","KHR_LIGHTS_PUNCTUAL","name","decode","gltfData","gltfScenegraph","json","extension","getExtension","lights","removeExtension","node","nodes","nodeExtension","getObjectExtension","light","removeObjectExtension","encode","addExtension","addObjectExtension"],"sources":["../../../../src/lib/extensions/deprecated/KHR_lights_punctual.ts"],"sourcesContent":["// GLTF EXTENSION: KHR_lights_punctual\n// https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual\n\nimport type {GLTF} from '../../types/gltf-json-schema';\n\nimport {assert} from '../../utils/assert';\nimport {GLTFScenegraph} from '../../api/gltf-scenegraph';\n\nconst KHR_LIGHTS_PUNCTUAL = 'KHR_lights_punctual';\n\nexport const name = KHR_LIGHTS_PUNCTUAL;\n\nexport async function decode(gltfData: {json: GLTF}): Promise<void> {\n const gltfScenegraph = new GLTFScenegraph(gltfData);\n const {json} = gltfScenegraph;\n\n // Move the light array out of the extension and remove the extension\n const extension = gltfScenegraph.getExtension(KHR_LIGHTS_PUNCTUAL);\n if (extension) {\n // @ts-ignore\n gltfScenegraph.json.lights = extension.lights;\n gltfScenegraph.removeExtension(KHR_LIGHTS_PUNCTUAL);\n }\n\n // Any nodes that have the extension, add lights field pointing to light object\n // and remove the extension\n for (const node of json.nodes || []) {\n const nodeExtension = gltfScenegraph.getObjectExtension(node, KHR_LIGHTS_PUNCTUAL);\n if (nodeExtension) {\n // @ts-ignore\n node.light = nodeExtension.light;\n }\n gltfScenegraph.removeObjectExtension(node, KHR_LIGHTS_PUNCTUAL);\n }\n}\n\n// Move the light ar ray out of the extension and remove the extension\nexport async function encode(gltfData): Promise<void> {\n const gltfScenegraph = new GLTFScenegraph(gltfData);\n const {json} = gltfScenegraph;\n\n // @ts-ignore\n if (json.lights) {\n const extension = gltfScenegraph.addExtension(KHR_LIGHTS_PUNCTUAL);\n // @ts-ignore\n assert(!extension.lights);\n // @ts-ignore\n extension.lights = json.lights;\n // @ts-ignore\n delete json.lights;\n }\n\n // Any nodes that have lights field pointing to light object\n // add the extension\n // @ts-ignore\n if (gltfScenegraph.json.lights) {\n // @ts-ignore\n for (const light of gltfScenegraph.json.lights) {\n const node = light.node;\n gltfScenegraph.addObjectExtension(node, KHR_LIGHTS_PUNCTUAL, light);\n }\n // @ts-ignore\n delete gltfScenegraph.json.lights;\n }\n}\n"],"mappings":"SAKQA,MAAM;AAAA,SACNC,cAAc;AAEtB,MAAMC,mBAAmB,GAAG,qBAAqB;AAEjD,OAAO,MAAMC,IAAI,GAAGD,mBAAmB;AAEvC,OAAO,eAAeE,MAAMA,CAACC,QAAsB,EAAiB;EAClE,MAAMC,cAAc,GAAG,IAAIL,cAAc,CAACI,QAAQ,CAAC;EACnD,MAAM;IAACE;EAAI,CAAC,GAAGD,cAAc;EAG7B,MAAME,SAAS,GAAGF,cAAc,CAACG,YAAY,CAACP,mBAAmB,CAAC;EAClE,IAAIM,SAAS,EAAE;IAEbF,cAAc,CAACC,IAAI,CAACG,MAAM,GAAGF,SAAS,CAACE,MAAM;IAC7CJ,cAAc,CAACK,eAAe,CAACT,mBAAmB,CAAC;EACrD;EAIA,KAAK,MAAMU,IAAI,IAAIL,IAAI,CAACM,KAAK,IAAI,EAAE,EAAE;IACnC,MAAMC,aAAa,GAAGR,cAAc,CAACS,kBAAkB,CAACH,IAAI,EAAEV,mBAAmB,CAAC;IAClF,IAAIY,aAAa,EAAE;MAEjBF,IAAI,CAACI,KAAK,GAAGF,aAAa,CAACE,KAAK;IAClC;IACAV,cAAc,CAACW,qBAAqB,CAACL,IAAI,EAAEV,mBAAmB,CAAC;EACjE;AACF;AAGA,OAAO,eAAegB,MAAMA,CAACb,QAAQ,EAAiB;EACpD,MAAMC,cAAc,GAAG,IAAIL,cAAc,CAACI,QAAQ,CAAC;EACnD,MAAM;IAACE;EAAI,CAAC,GAAGD,cAAc;EAG7B,IAAIC,IAAI,CAACG,MAAM,EAAE;IACf,MAAMF,SAAS,GAAGF,cAAc,CAACa,YAAY,CAACjB,mBAAmB,CAAC;IAElEF,MAAM,CAAC,CAACQ,SAAS,CAACE,MAAM,CAAC;IAEzBF,SAAS,CAACE,MAAM,GAAGH,IAAI,CAACG,MAAM;IAE9B,OAAOH,IAAI,CAACG,MAAM;EACpB;EAKA,IAAIJ,cAAc,CAACC,IAAI,CAACG,MAAM,EAAE;IAE9B,KAAK,MAAMM,KAAK,IAAIV,cAAc,CAACC,IAAI,CAACG,MAAM,EAAE;MAC9C,MAAME,IAAI,GAAGI,KAAK,CAACJ,IAAI;MACvBN,cAAc,CAACc,kBAAkB,CAACR,IAAI,EAAEV,mBAAmB,EAAEc,KAAK,CAAC;IACrE;IAEA,OAAOV,cAAc,CAACC,IAAI,CAACG,MAAM;EACnC;AACF"}
@@ -1,4 +1,4 @@
1
- import { GLTFScenegraph } from '../../api/gltf-scenegraph';
1
+ import { GLTFScenegraph } from "../../api/gltf-scenegraph.js";
2
2
  const KHR_MATERIALS_UNLIT = 'KHR_materials_unlit';
3
3
  export const name = KHR_MATERIALS_UNLIT;
4
4
  export async function decode(gltfData) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KHR_materials_unlit.js","names":["GLTFScenegraph","KHR_MATERIALS_UNLIT","name","decode","gltfData","gltfScenegraph","json","material","materials","extension","extensions","KHR_materials_unlit","unlit","removeObjectExtension","removeExtension","encode","addObjectExtension","addExtension"],"sources":["../../../../src/lib/extensions/deprecated/KHR_materials_unlit.ts"],"sourcesContent":["// GLTF EXTENSION: KHR_materials_unlit\n// https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit\n\nimport type {GLTF} from '../../types/gltf-json-schema';\n\nimport {GLTFScenegraph} from '../../api/gltf-scenegraph';\n\nconst KHR_MATERIALS_UNLIT = 'KHR_materials_unlit';\n\nexport const name = KHR_MATERIALS_UNLIT;\n\nexport async function decode(gltfData: {json: GLTF}): Promise<void> {\n const gltfScenegraph = new GLTFScenegraph(gltfData);\n const {json} = gltfScenegraph;\n\n // Any nodes that have the extension, add lights field pointing to light object\n // and remove the extension\n for (const material of json.materials || []) {\n const extension = material.extensions && material.extensions.KHR_materials_unlit;\n if (extension) {\n // @ts-ignore TODO\n material.unlit = true;\n }\n gltfScenegraph.removeObjectExtension(material, KHR_MATERIALS_UNLIT);\n }\n\n // Remove the top-level extension\n gltfScenegraph.removeExtension(KHR_MATERIALS_UNLIT);\n}\n\nexport function encode(gltfData) {\n const gltfScenegraph = new GLTFScenegraph(gltfData);\n const {json} = gltfScenegraph;\n\n // Any nodes that have lights field pointing to light object\n // add the extension\n // @ts-ignore\n if (gltfScenegraph.materials) {\n for (const material of json.materials || []) {\n // @ts-ignore\n if (material.unlit) {\n // @ts-ignore\n delete material.unlit;\n gltfScenegraph.addObjectExtension(material, KHR_MATERIALS_UNLIT, {});\n gltfScenegraph.addExtension(KHR_MATERIALS_UNLIT);\n }\n }\n }\n}\n"],"mappings":"SAKQA,cAAc;AAEtB,MAAMC,mBAAmB,GAAG,qBAAqB;AAEjD,OAAO,MAAMC,IAAI,GAAGD,mBAAmB;AAEvC,OAAO,eAAeE,MAAMA,CAACC,QAAsB,EAAiB;EAClE,MAAMC,cAAc,GAAG,IAAIL,cAAc,CAACI,QAAQ,CAAC;EACnD,MAAM;IAACE;EAAI,CAAC,GAAGD,cAAc;EAI7B,KAAK,MAAME,QAAQ,IAAID,IAAI,CAACE,SAAS,IAAI,EAAE,EAAE;IAC3C,MAAMC,SAAS,GAAGF,QAAQ,CAACG,UAAU,IAAIH,QAAQ,CAACG,UAAU,CAACC,mBAAmB;IAChF,IAAIF,SAAS,EAAE;MAEbF,QAAQ,CAACK,KAAK,GAAG,IAAI;IACvB;IACAP,cAAc,CAACQ,qBAAqB,CAACN,QAAQ,EAAEN,mBAAmB,CAAC;EACrE;EAGAI,cAAc,CAACS,eAAe,CAACb,mBAAmB,CAAC;AACrD;AAEA,OAAO,SAASc,MAAMA,CAACX,QAAQ,EAAE;EAC/B,MAAMC,cAAc,GAAG,IAAIL,cAAc,CAACI,QAAQ,CAAC;EACnD,MAAM;IAACE;EAAI,CAAC,GAAGD,cAAc;EAK7B,IAAIA,cAAc,CAACG,SAAS,EAAE;IAC5B,KAAK,MAAMD,QAAQ,IAAID,IAAI,CAACE,SAAS,IAAI,EAAE,EAAE;MAE3C,IAAID,QAAQ,CAACK,KAAK,EAAE;QAElB,OAAOL,QAAQ,CAACK,KAAK;QACrBP,cAAc,CAACW,kBAAkB,CAACT,QAAQ,EAAEN,mBAAmB,EAAE,CAAC,CAAC,CAAC;QACpEI,cAAc,CAACY,YAAY,CAAChB,mBAAmB,CAAC;MAClD;IACF;EACF;AACF"}
@@ -1,4 +1,4 @@
1
- import { GLTFScenegraph } from '../../api/gltf-scenegraph';
1
+ import { GLTFScenegraph } from "../../api/gltf-scenegraph.js";
2
2
  const KHR_TECHNIQUES_WEBGL = 'KHR_techniques_webgl';
3
3
  export const name = KHR_TECHNIQUES_WEBGL;
4
4
  export async function decode(gltfData) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KHR_techniques_webgl.js","names":["GLTFScenegraph","KHR_TECHNIQUES_WEBGL","name","decode","gltfData","gltfScenegraph","json","extension","getExtension","techniques","resolveTechniques","material","materials","materialExtension","getObjectExtension","technique","Object","assign","values","resolveValues","removeObjectExtension","removeExtension","encode","options","techniquesExtension","programs","shaders","textDecoder","TextDecoder","forEach","shader","Number","isFinite","bufferView","code","getTypedArrayForBufferView","Error","program","fragmentShader","vertexShader","keys","uniforms","uniform","value","index","undefined","texture","getTexture"],"sources":["../../../../src/lib/extensions/deprecated/KHR_techniques_webgl.ts"],"sourcesContent":["// GLTF EXTENSION: KHR_techniques_webgl\n// https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_techniques_webgl\n\nimport type {GLTF} from '../../types/gltf-json-schema';\n\nimport {GLTFScenegraph} from '../../api/gltf-scenegraph';\n\nconst KHR_TECHNIQUES_WEBGL = 'KHR_techniques_webgl';\n\nexport const name = KHR_TECHNIQUES_WEBGL;\n\nexport async function decode(gltfData: {json: GLTF}): Promise<void> {\n const gltfScenegraph = new GLTFScenegraph(gltfData);\n const {json} = gltfScenegraph;\n\n const extension = gltfScenegraph.getExtension(KHR_TECHNIQUES_WEBGL);\n if (extension) {\n const techniques = resolveTechniques(extension, gltfScenegraph);\n\n for (const material of json.materials || []) {\n const materialExtension = gltfScenegraph.getObjectExtension(material, KHR_TECHNIQUES_WEBGL);\n if (materialExtension) {\n // @ts-ignore TODO\n material.technique = Object.assign(\n {},\n materialExtension,\n // @ts-ignore\n techniques[materialExtension.technique]\n );\n // @ts-ignore TODO\n material.technique.values = resolveValues(material.technique, gltfScenegraph);\n }\n gltfScenegraph.removeObjectExtension(material, KHR_TECHNIQUES_WEBGL);\n }\n\n // Remove the top-level extension\n gltfScenegraph.removeExtension(KHR_TECHNIQUES_WEBGL);\n }\n}\n// eslint-disable-next-line\nexport async function encode(gltfData, options): Promise<void> {\n // TODO\n}\n\nfunction resolveTechniques(\n techniquesExtension: {[key: string]: any},\n // programs: {[key: string]: any}[],\n // shaders: {[key: string]: any}[],\n // techniques: {[key: string]: any}[]\n gltfScenegraph\n) {\n const {programs = [], shaders = [], techniques = []} = techniquesExtension;\n const textDecoder = new TextDecoder();\n\n shaders.forEach((shader) => {\n if (Number.isFinite(shader.bufferView)) {\n shader.code = textDecoder.decode(\n gltfScenegraph.getTypedArrayForBufferView(shader.bufferView)\n );\n } else {\n // TODO: handle URI shader\n throw new Error('KHR_techniques_webgl: no shader code');\n }\n });\n\n programs.forEach((program) => {\n program.fragmentShader = shaders[program.fragmentShader];\n program.vertexShader = shaders[program.vertexShader];\n });\n\n techniques.forEach((technique) => {\n technique.program = programs[technique.program];\n });\n\n return techniques;\n}\n\nfunction resolveValues(technique, gltfScenegraph) {\n const values = Object.assign({}, technique.values);\n\n // merge values from uniforms\n Object.keys(technique.uniforms || {}).forEach((uniform) => {\n if (technique.uniforms[uniform].value && !(uniform in values)) {\n values[uniform] = technique.uniforms[uniform].value;\n }\n });\n\n // resolve textures\n Object.keys(values).forEach((uniform) => {\n if (typeof values[uniform] === 'object' && values[uniform].index !== undefined) {\n // Assume this is a texture\n // TODO: find if there are any other types that can be referenced\n values[uniform].texture = gltfScenegraph.getTexture(values[uniform].index);\n }\n });\n\n return values;\n}\n"],"mappings":"SAKQA,cAAc;AAEtB,MAAMC,oBAAoB,GAAG,sBAAsB;AAEnD,OAAO,MAAMC,IAAI,GAAGD,oBAAoB;AAExC,OAAO,eAAeE,MAAMA,CAACC,QAAsB,EAAiB;EAClE,MAAMC,cAAc,GAAG,IAAIL,cAAc,CAACI,QAAQ,CAAC;EACnD,MAAM;IAACE;EAAI,CAAC,GAAGD,cAAc;EAE7B,MAAME,SAAS,GAAGF,cAAc,CAACG,YAAY,CAACP,oBAAoB,CAAC;EACnE,IAAIM,SAAS,EAAE;IACb,MAAME,UAAU,GAAGC,iBAAiB,CAACH,SAAS,EAAEF,cAAc,CAAC;IAE/D,KAAK,MAAMM,QAAQ,IAAIL,IAAI,CAACM,SAAS,IAAI,EAAE,EAAE;MAC3C,MAAMC,iBAAiB,GAAGR,cAAc,CAACS,kBAAkB,CAACH,QAAQ,EAAEV,oBAAoB,CAAC;MAC3F,IAAIY,iBAAiB,EAAE;QAErBF,QAAQ,CAACI,SAAS,GAAGC,MAAM,CAACC,MAAM,CAChC,CAAC,CAAC,EACFJ,iBAAiB,EAEjBJ,UAAU,CAACI,iBAAiB,CAACE,SAAS,CACxC,CAAC;QAEDJ,QAAQ,CAACI,SAAS,CAACG,MAAM,GAAGC,aAAa,CAACR,QAAQ,CAACI,SAAS,EAAEV,cAAc,CAAC;MAC/E;MACAA,cAAc,CAACe,qBAAqB,CAACT,QAAQ,EAAEV,oBAAoB,CA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AS,CAAC0B,QAAQ,IAAI,CAAC,CAAC,CAAC,CAACZ,OAAO,CAAEa,OAAO,IAAK;IACzD,IAAI3B,SAAS,CAAC0B,QAAQ,CAACC,OAAO,CAAC,CAACC,KAAK,IAAI,EAAED,OAAO,IAAIxB,MAAM,CAAC,EAAE;MAC7DA,MAAM,CAACwB,OAAO,CAAC,GAAG3B,SAAS,CAAC0B,QAAQ,CAACC,OAAO,CAAC,CAACC,KAAK;IACrD;EACF,CAAC,CAAC;EAGF3B,MAAM,CAACwB,IAAI,CAACtB,MAAM,CAAC,CAACW,OAAO,CAAEa,OAAO,IAAK;IACvC,IAAI,OAAOxB,MAAM,CAACwB,OAAO,CAAC,KAAK,QAAQ,IAAIxB,MAAM,CAACwB,OAAO,CAAC,CAACE,KAAK,KAAKC,SAAS,EAAE;MAG9E3B,MAAM,CAACwB,OAAO,CAAC,CAACI,OAAO,GAAGzC,cAAc,CAAC0C,UAAU,CAAC7B,MAAM,CAACwB,OAAO,CAAC,CAACE,KAAK,CAAC;IAC5E;EACF,CAAC,CAAC;EAEF,OAAO1B,MAAM;AACf"}
@@ -36,7 +36,7 @@ export declare function convertRawBufferToMetadataArray(data: Uint8Array, attrib
36
36
  * @param primitive - Primitive object in the mesh.
37
37
  * @returns Array of data taken. Null if data can't be taken from the texture.
38
38
  */
39
- export declare function getPrimitiveTextureData(scenegraph: GLTFScenegraph, textureInfo: GLTFTextureInfoMetadata, primitive: GLTFMeshPrimitive): number[] | null;
39
+ export declare function getPrimitiveTextureData(scenegraph: GLTFScenegraph, textureInfo: GLTFTextureInfoMetadata, primitive: GLTFMeshPrimitive): number[];
40
40
  /**
41
41
  * Puts property data to attributes.
42
42
  * It creates corresponding buffer, bufferView and accessor