@loaders.gl/gltf 3.1.3 → 4.0.0-alpha.5

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 (211) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/bundle.js.map +1 -0
  3. package/dist/dist.min.js +13 -13
  4. package/dist/glb-loader.js +28 -33
  5. package/dist/glb-loader.js.map +1 -0
  6. package/dist/glb-writer.js +26 -34
  7. package/dist/glb-writer.js.map +1 -0
  8. package/dist/gltf-loader.js +43 -46
  9. package/dist/gltf-loader.js.map +1 -0
  10. package/dist/gltf-writer.js +26 -29
  11. package/dist/gltf-writer.js.map +1 -0
  12. package/dist/index.js +7 -21
  13. package/dist/index.js.map +1 -0
  14. package/dist/lib/api/gltf-extensions.js +31 -71
  15. package/dist/lib/api/gltf-extensions.js.map +1 -0
  16. package/dist/lib/api/gltf-scenegraph.js +512 -550
  17. package/dist/lib/api/gltf-scenegraph.js.map +1 -0
  18. package/dist/lib/api/normalize-gltf-v1.js +229 -274
  19. package/dist/lib/api/normalize-gltf-v1.js.map +1 -0
  20. package/dist/lib/api/post-process-gltf.js +376 -324
  21. package/dist/lib/api/post-process-gltf.js.map +1 -0
  22. package/dist/lib/encoders/encode-glb.js +58 -56
  23. package/dist/lib/encoders/encode-glb.js.map +1 -0
  24. package/dist/lib/encoders/encode-gltf.js +12 -25
  25. package/dist/lib/encoders/encode-gltf.js.map +1 -0
  26. package/dist/lib/extensions/EXT_meshopt_compression.js +49 -47
  27. package/dist/lib/extensions/EXT_meshopt_compression.js.map +1 -0
  28. package/dist/lib/extensions/EXT_texture_webp.js +28 -34
  29. package/dist/lib/extensions/EXT_texture_webp.js.map +1 -0
  30. package/dist/lib/extensions/KHR_binary_gltf.js +23 -39
  31. package/dist/lib/extensions/KHR_binary_gltf.js.map +1 -0
  32. package/dist/lib/extensions/KHR_draco_mesh_compression.js +111 -126
  33. package/dist/lib/extensions/KHR_draco_mesh_compression.js.map +1 -0
  34. package/dist/lib/extensions/KHR_texture_basisu.js +19 -28
  35. package/dist/lib/extensions/KHR_texture_basisu.js.map +1 -0
  36. package/dist/lib/extensions/deprecated/KHR_lights_punctual.js +44 -57
  37. package/dist/lib/extensions/deprecated/KHR_lights_punctual.js.map +1 -0
  38. package/dist/lib/extensions/deprecated/KHR_materials_unlit.js +32 -42
  39. package/dist/lib/extensions/deprecated/KHR_materials_unlit.js.map +1 -0
  40. package/dist/lib/extensions/deprecated/KHR_techniques_webgl.js +62 -75
  41. package/dist/lib/extensions/deprecated/KHR_techniques_webgl.js.map +1 -0
  42. package/dist/lib/gltf-utils/get-typed-array.js +14 -39
  43. package/dist/lib/gltf-utils/get-typed-array.js.map +1 -0
  44. package/dist/lib/gltf-utils/gltf-attribute-utils.js +65 -65
  45. package/dist/lib/gltf-utils/gltf-attribute-utils.js.map +1 -0
  46. package/dist/lib/gltf-utils/gltf-constants.js +30 -36
  47. package/dist/lib/gltf-utils/gltf-constants.js.map +1 -0
  48. package/dist/lib/gltf-utils/gltf-utils.js +45 -52
  49. package/dist/lib/gltf-utils/gltf-utils.js.map +1 -0
  50. package/dist/lib/gltf-utils/resolve-url.js +15 -17
  51. package/dist/lib/gltf-utils/resolve-url.js.map +1 -0
  52. package/dist/lib/parsers/parse-glb.js +107 -120
  53. package/dist/lib/parsers/parse-glb.js.map +1 -0
  54. package/dist/lib/parsers/parse-gltf.js +154 -173
  55. package/dist/lib/parsers/parse-gltf.js.map +1 -0
  56. package/dist/lib/types/glb-types.js +2 -2
  57. package/dist/{es5/lib → lib}/types/glb-types.js.map +0 -0
  58. package/dist/lib/types/gltf-json-schema.js +2 -4
  59. package/dist/{es5/lib → lib}/types/gltf-json-schema.js.map +0 -0
  60. package/dist/lib/types/gltf-postprocessed-schema.js +2 -4
  61. package/dist/{es5/lib → lib}/types/gltf-postprocessed-schema.js.map +0 -0
  62. package/dist/lib/types/gltf-types.js +2 -3
  63. package/dist/{es5/lib → lib}/types/gltf-types.js.map +0 -0
  64. package/dist/lib/utils/assert.js +5 -11
  65. package/dist/lib/utils/assert.js.map +1 -0
  66. package/dist/lib/utils/version.js +2 -7
  67. package/dist/lib/utils/version.js.map +1 -0
  68. package/dist/meshopt/meshopt-decoder.js +82 -97
  69. package/dist/meshopt/meshopt-decoder.js.map +1 -0
  70. package/dist/{es5/meshopt → meshopt}/meshopt-encoder.ts.disabled +0 -0
  71. package/dist/webp/webp.js +23 -32
  72. package/dist/webp/webp.js.map +1 -0
  73. package/package.json +8 -11
  74. package/src/lib/parsers/parse-gltf.ts +1 -1
  75. package/dist/es5/bundle.js +0 -7
  76. package/dist/es5/bundle.js.map +0 -1
  77. package/dist/es5/glb-loader.js +0 -70
  78. package/dist/es5/glb-loader.js.map +0 -1
  79. package/dist/es5/glb-writer.js +0 -41
  80. package/dist/es5/glb-writer.js.map +0 -1
  81. package/dist/es5/gltf-loader.js +0 -97
  82. package/dist/es5/gltf-loader.js.map +0 -1
  83. package/dist/es5/gltf-writer.js +0 -40
  84. package/dist/es5/gltf-writer.js.map +0 -1
  85. package/dist/es5/index.js +0 -56
  86. package/dist/es5/index.js.map +0 -1
  87. package/dist/es5/lib/api/gltf-extensions.js +0 -146
  88. package/dist/es5/lib/api/gltf-extensions.js.map +0 -1
  89. package/dist/es5/lib/api/gltf-scenegraph.js +0 -623
  90. package/dist/es5/lib/api/gltf-scenegraph.js.map +0 -1
  91. package/dist/es5/lib/api/normalize-gltf-v1.js +0 -392
  92. package/dist/es5/lib/api/normalize-gltf-v1.js.map +0 -1
  93. package/dist/es5/lib/api/post-process-gltf.js +0 -502
  94. package/dist/es5/lib/api/post-process-gltf.js.map +0 -1
  95. package/dist/es5/lib/encoders/encode-glb.js +0 -75
  96. package/dist/es5/lib/encoders/encode-glb.js.map +0 -1
  97. package/dist/es5/lib/encoders/encode-gltf.js +0 -26
  98. package/dist/es5/lib/encoders/encode-gltf.js.map +0 -1
  99. package/dist/es5/lib/extensions/EXT_meshopt_compression.js +0 -137
  100. package/dist/es5/lib/extensions/EXT_meshopt_compression.js.map +0 -1
  101. package/dist/es5/lib/extensions/EXT_texture_webp.js +0 -60
  102. package/dist/es5/lib/extensions/EXT_texture_webp.js.map +0 -1
  103. package/dist/es5/lib/extensions/KHR_binary_gltf.js +0 -53
  104. package/dist/es5/lib/extensions/KHR_binary_gltf.js.map +0 -1
  105. package/dist/es5/lib/extensions/KHR_draco_mesh_compression.js +0 -331
  106. package/dist/es5/lib/extensions/KHR_draco_mesh_compression.js.map +0 -1
  107. package/dist/es5/lib/extensions/KHR_texture_basisu.js +0 -49
  108. package/dist/es5/lib/extensions/KHR_texture_basisu.js.map +0 -1
  109. package/dist/es5/lib/extensions/deprecated/KHR_lights_punctual.js +0 -129
  110. package/dist/es5/lib/extensions/deprecated/KHR_lights_punctual.js.map +0 -1
  111. package/dist/es5/lib/extensions/deprecated/KHR_materials_unlit.js +0 -97
  112. package/dist/es5/lib/extensions/deprecated/KHR_materials_unlit.js.map +0 -1
  113. package/dist/es5/lib/extensions/deprecated/KHR_techniques_webgl.js +0 -139
  114. package/dist/es5/lib/extensions/deprecated/KHR_techniques_webgl.js.map +0 -1
  115. package/dist/es5/lib/gltf-utils/get-typed-array.js +0 -26
  116. package/dist/es5/lib/gltf-utils/get-typed-array.js.map +0 -1
  117. package/dist/es5/lib/gltf-utils/gltf-attribute-utils.js +0 -85
  118. package/dist/es5/lib/gltf-utils/gltf-attribute-utils.js.map +0 -1
  119. package/dist/es5/lib/gltf-utils/gltf-constants.js +0 -48
  120. package/dist/es5/lib/gltf-utils/gltf-constants.js.map +0 -1
  121. package/dist/es5/lib/gltf-utils/gltf-utils.js +0 -69
  122. package/dist/es5/lib/gltf-utils/gltf-utils.js.map +0 -1
  123. package/dist/es5/lib/gltf-utils/resolve-url.js +0 -23
  124. package/dist/es5/lib/gltf-utils/resolve-url.js.map +0 -1
  125. package/dist/es5/lib/parsers/parse-glb.js +0 -142
  126. package/dist/es5/lib/parsers/parse-glb.js.map +0 -1
  127. package/dist/es5/lib/parsers/parse-gltf.js +0 -353
  128. package/dist/es5/lib/parsers/parse-gltf.js.map +0 -1
  129. package/dist/es5/lib/types/glb-types.js +0 -2
  130. package/dist/es5/lib/types/gltf-json-schema.js +0 -2
  131. package/dist/es5/lib/types/gltf-postprocessed-schema.js +0 -2
  132. package/dist/es5/lib/types/gltf-types.js +0 -2
  133. package/dist/es5/lib/utils/assert.js +0 -13
  134. package/dist/es5/lib/utils/assert.js.map +0 -1
  135. package/dist/es5/lib/utils/version.js +0 -9
  136. package/dist/es5/lib/utils/version.js.map +0 -1
  137. package/dist/es5/meshopt/meshopt-decoder.js +0 -270
  138. package/dist/es5/meshopt/meshopt-decoder.js.map +0 -1
  139. package/dist/es5/webp/webp.js +0 -104
  140. package/dist/es5/webp/webp.js.map +0 -1
  141. package/dist/esm/bundle.js +0 -5
  142. package/dist/esm/bundle.js.map +0 -1
  143. package/dist/esm/glb-loader.js +0 -34
  144. package/dist/esm/glb-loader.js.map +0 -1
  145. package/dist/esm/glb-writer.js +0 -29
  146. package/dist/esm/glb-writer.js.map +0 -1
  147. package/dist/esm/gltf-loader.js +0 -47
  148. package/dist/esm/gltf-loader.js.map +0 -1
  149. package/dist/esm/gltf-writer.js +0 -29
  150. package/dist/esm/gltf-writer.js.map +0 -1
  151. package/dist/esm/index.js +0 -7
  152. package/dist/esm/index.js.map +0 -1
  153. package/dist/esm/lib/api/gltf-extensions.js +0 -35
  154. package/dist/esm/lib/api/gltf-extensions.js.map +0 -1
  155. package/dist/esm/lib/api/gltf-scenegraph.js +0 -515
  156. package/dist/esm/lib/api/gltf-scenegraph.js.map +0 -1
  157. package/dist/esm/lib/api/normalize-gltf-v1.js +0 -250
  158. package/dist/esm/lib/api/normalize-gltf-v1.js.map +0 -1
  159. package/dist/esm/lib/api/post-process-gltf.js +0 -422
  160. package/dist/esm/lib/api/post-process-gltf.js.map +0 -1
  161. package/dist/esm/lib/encoders/encode-glb.js +0 -63
  162. package/dist/esm/lib/encoders/encode-glb.js.map +0 -1
  163. package/dist/esm/lib/encoders/encode-gltf.js +0 -14
  164. package/dist/esm/lib/encoders/encode-gltf.js.map +0 -1
  165. package/dist/esm/lib/extensions/EXT_meshopt_compression.js +0 -56
  166. package/dist/esm/lib/extensions/EXT_meshopt_compression.js.map +0 -1
  167. package/dist/esm/lib/extensions/EXT_texture_webp.js +0 -32
  168. package/dist/esm/lib/extensions/EXT_texture_webp.js.map +0 -1
  169. package/dist/esm/lib/extensions/KHR_binary_gltf.js +0 -26
  170. package/dist/esm/lib/extensions/KHR_binary_gltf.js.map +0 -1
  171. package/dist/esm/lib/extensions/KHR_draco_mesh_compression.js +0 -126
  172. package/dist/esm/lib/extensions/KHR_draco_mesh_compression.js.map +0 -1
  173. package/dist/esm/lib/extensions/KHR_texture_basisu.js +0 -22
  174. package/dist/esm/lib/extensions/KHR_texture_basisu.js.map +0 -1
  175. package/dist/esm/lib/extensions/deprecated/KHR_lights_punctual.js +0 -49
  176. package/dist/esm/lib/extensions/deprecated/KHR_lights_punctual.js.map +0 -1
  177. package/dist/esm/lib/extensions/deprecated/KHR_materials_unlit.js +0 -37
  178. package/dist/esm/lib/extensions/deprecated/KHR_materials_unlit.js.map +0 -1
  179. package/dist/esm/lib/extensions/deprecated/KHR_techniques_webgl.js +0 -68
  180. package/dist/esm/lib/extensions/deprecated/KHR_techniques_webgl.js.map +0 -1
  181. package/dist/esm/lib/gltf-utils/get-typed-array.js +0 -16
  182. package/dist/esm/lib/gltf-utils/get-typed-array.js.map +0 -1
  183. package/dist/esm/lib/gltf-utils/gltf-attribute-utils.js +0 -73
  184. package/dist/esm/lib/gltf-utils/gltf-attribute-utils.js.map +0 -1
  185. package/dist/esm/lib/gltf-utils/gltf-constants.js +0 -37
  186. package/dist/esm/lib/gltf-utils/gltf-constants.js.map +0 -1
  187. package/dist/esm/lib/gltf-utils/gltf-utils.js +0 -56
  188. package/dist/esm/lib/gltf-utils/gltf-utils.js.map +0 -1
  189. package/dist/esm/lib/gltf-utils/resolve-url.js +0 -16
  190. package/dist/esm/lib/gltf-utils/resolve-url.js.map +0 -1
  191. package/dist/esm/lib/parsers/parse-glb.js +0 -128
  192. package/dist/esm/lib/parsers/parse-glb.js.map +0 -1
  193. package/dist/esm/lib/parsers/parse-gltf.js +0 -170
  194. package/dist/esm/lib/parsers/parse-gltf.js.map +0 -1
  195. package/dist/esm/lib/types/glb-types.js +0 -2
  196. package/dist/esm/lib/types/glb-types.js.map +0 -1
  197. package/dist/esm/lib/types/gltf-json-schema.js +0 -2
  198. package/dist/esm/lib/types/gltf-json-schema.js.map +0 -1
  199. package/dist/esm/lib/types/gltf-postprocessed-schema.js +0 -2
  200. package/dist/esm/lib/types/gltf-postprocessed-schema.js.map +0 -1
  201. package/dist/esm/lib/types/gltf-types.js +0 -2
  202. package/dist/esm/lib/types/gltf-types.js.map +0 -1
  203. package/dist/esm/lib/utils/assert.js +0 -6
  204. package/dist/esm/lib/utils/assert.js.map +0 -1
  205. package/dist/esm/lib/utils/version.js +0 -2
  206. package/dist/esm/lib/utils/version.js.map +0 -1
  207. package/dist/esm/meshopt/meshopt-decoder.js +0 -103
  208. package/dist/esm/meshopt/meshopt-decoder.js.map +0 -1
  209. package/dist/esm/meshopt/meshopt-encoder.ts.disabled +0 -409
  210. package/dist/esm/webp/webp.js +0 -29
  211. package/dist/esm/webp/webp.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/api/gltf-scenegraph.ts"],"names":["getBinaryImageMetadata","padToNBytes","copyToArray","assert","getAccessorArrayTypeAndLength","getAccessorTypeFromSize","getComponentTypeFromArray","DEFAULT_GLTF_JSON","asset","version","generator","buffers","GLTFScenegraph","constructor","gltf","json","sourceBuffers","byteLength","getApplicationData","key","data","getExtraData","extras","getExtension","extensionName","isExtension","getUsedExtensions","find","name","extensions","getRequiredExtension","isRequired","getRequiredExtensions","extensionsRequired","extensionsUsed","getObjectExtension","object","getScene","index","getObject","getNode","getSkin","getMesh","getMaterial","getAccessor","getTexture","getSampler","getImage","getBufferView","getBuffer","array","Error","getTypedArrayForBufferView","bufferView","bufferIndex","buffer","binChunk","byteOffset","Uint8Array","arrayBuffer","getTypedArrayForAccessor","accessor","ArrayType","length","getTypedArrayForImageData","image","addApplicationData","addExtraData","addObjectExtension","registerUsedExtension","setObjectExtension","removeObjectExtension","extension","addExtension","extensionData","addRequiredExtension","registerRequiredExtension","ext","push","removeExtension","_removeStringFromArray","setDefaultScene","sceneIndex","scene","addScene","nodeIndices","scenes","nodes","addNode","node","meshIndex","matrix","nodeData","mesh","addMesh","attributes","indices","material","mode","accessors","_addAttributes","glTFMesh","primitives","indicesAccessor","_addIndices","Number","isFinite","meshes","addPointCloud","accessorIndices","addImage","imageData","mimeTypeOpt","metadata","mimeType","bufferViewIndex","addBufferView","glTFImage","images","glTFBufferView","bufferViews","addAccessor","glTFAccessor","type","size","componentType","count","max","min","addBinaryBuffer","sourceBuffer","minMax","_getAccessorMinMax","accessorDefaults","Math","round","Object","assign","addTexture","texture","imageIndex","glTFTexture","source","textures","addMaterial","pbrMaterialInfo","materials","createBinaryChunk","totalByteLength","ArrayBuffer","targetArray","dstByteOffset","binary","string","found","indexOf","splice","result","attributeKey","attributeData","attrName","_getGltfAttributeName","value","attributeName","toLowerCase","initValues","subarray","componentIndex"],"mappings":";AAeA,SAAQA,sBAAR,QAAqC,oBAArC;AACA,SAAQC,WAAR,EAAqBC,WAArB,QAAuC,0BAAvC;AACA,SAAQC,MAAR,QAAqB,iBAArB;AACA,SACEC,6BADF,EAEEC,uBAFF,EAGEC,yBAHF,QAIO,0BAJP;AAYA,MAAMC,iBAAuB,GAAG;AAC9BC,EAAAA,KAAK,EAAE;AACLC,IAAAA,OAAO,EAAE,KADJ;AAELC,IAAAA,SAAS,EAAE;AAFN,GADuB;AAK9BC,EAAAA,OAAO,EAAE;AALqB,CAAhC;AAYA,eAAe,MAAMC,cAAN,CAAqB;AAMlCC,EAAAA,WAAW,CAACC,IAAD,EAAuC;AAAA;;AAAA;;A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AAGiB,MAAM,CAACQ,MAAtC,EAA8CzB,KAAK,IAAIsF,IAAvD,EAA6D;AAC3D,WAAK,IAAI2C,cAAc,GAAG,CAA1B,EAA6BA,cAAc,GAAG3C,IAA9C,EAAoD2C,cAAc,EAAlE,EAAsE;AAEpEV,QAAAA,MAAM,CAAC7B,GAAP,CAAW,IAAIuC,cAAf,IAAiCjC,IAAI,CAACN,GAAL,CAE/B6B,MAAM,CAAC7B,GAAP,CAAW,IAAIuC,cAAf,CAF+B,EAG/BhH,MAAM,CAACjB,KAAK,GAAGiI,cAAT,CAHyB,CAAjC;AAMAV,QAAAA,MAAM,CAAC9B,GAAP,CAAW,IAAIwC,cAAf,IAAiCjC,IAAI,CAACP,GAAL,CAE/B8B,MAAM,CAAC9B,GAAP,CAAW,IAAIwC,cAAf,CAF+B,EAG/BhH,MAAM,CAACjB,KAAK,GAAGiI,cAAT,CAHyB,CAAjC;AAKD;AACF;;AACD,WAAOV,MAAP;AACD;;AA/mBiC","sourcesContent":["import type {\n GLTF,\n GLTFScene,\n GLTFNode,\n GLTFMesh,\n GLTFSkin,\n GLTFMaterial,\n GLTFAccessor,\n GLTFSampler,\n GLTFTexture,\n GLTFImage,\n GLTFBuffer,\n GLTFBufferView\n} from '../types/gltf-types';\n\nimport {getBinaryImageMetadata} from '@loaders.gl/images';\nimport {padToNBytes, copyToArray} from '@loaders.gl/loader-utils';\nimport {assert} from '../utils/assert';\nimport {\n getAccessorArrayTypeAndLength,\n getAccessorTypeFromSize,\n getComponentTypeFromArray\n} from '../gltf-utils/gltf-utils';\n\ntype GLTFWithBuffers = {\n json: GLTF;\n buffers: any[];\n binary?: ArrayBuffer;\n};\n\nconst DEFAULT_GLTF_JSON: GLTF = {\n asset: {\n version: '2.0',\n generator: 'loaders.gl'\n },\n buffers: []\n};\n\ntype Extension = {[key: string]: any};\n/**\n * Class for structured access to GLTF data\n */\nexport default class GLTFScenegraph {\n // internal\n gltf: GLTFWithBuffers;\n sourceBuffers: any[];\n byteLength: number;\n\n constructor(gltf?: {json: GLTF; buffers?: any[]}) {\n // @ts-ignore\n this.gltf = gltf || {\n json: {...DEFAULT_GLTF_JSON},\n buffers: []\n };\n this.sourceBuffers = [];\n this.byteLength = 0;\n\n // Initialize buffers\n if (this.gltf.buffers && this.gltf.buffers[0]) {\n this.byteLength = this.gltf.buffers[0].byteLength;\n this.sourceBuffers = [this.gltf.buffers[0]];\n }\n }\n\n // Accessors\n\n get json(): GLTF {\n return this.gltf.json;\n }\n\n getApplicationData(key: string): {[key: string]: any} {\n // TODO - Data is already unpacked by GLBParser\n const data = this.json[key];\n return data;\n }\n\n getExtraData(key: string): {[key: string]: any} {\n // TODO - Data is already unpacked by GLBParser\n const extras = this.json.extras || {};\n return extras[key];\n }\n\n getExtension<T = Extension>(extensionName: string): T | null {\n const isExtension = this.getUsedExtensions().find((name) => name === extensionName);\n const extensions = this.json.extensions || {};\n return isExtension ? extensions[extensionName] || true : null;\n }\n\n getRequiredExtension<T = Extension>(extensionName: string): T | null {\n const isRequired = this.getRequiredExtensions().find((name) => name === extensionName);\n return isRequired ? this.getExtension(extensionName) : null;\n }\n\n getRequiredExtensions(): string[] {\n return this.json.extensionsRequired || [];\n }\n\n getUsedExtensions(): string[] {\n return this.json.extensionsUsed || [];\n }\n\n getObjectExtension<T = Extension>(object: {[key: string]: any}, extensionName: string): T | null {\n const extensions = object.extensions || {};\n return extensions[extensionName];\n }\n\n getScene(index: number): GLTFScene {\n return this.getObject('scenes', index) as GLTFScene;\n }\n\n getNode(index: number): GLTFNode {\n return this.getObject('nodes', index) as GLTFNode;\n }\n\n getSkin(index: number): GLTFSkin {\n return this.getObject('skins', index) as GLTFSkin;\n }\n\n getMesh(index: number): GLTFMesh {\n return this.getObject('meshes', index) as GLTFMesh;\n }\n\n getMaterial(index: number): GLTFMaterial {\n return this.getObject('materials', index) as GLTFMaterial;\n }\n\n getAccessor(index: number): GLTFAccessor {\n return this.getObject('accessors', index) as GLTFAccessor;\n }\n\n // getCamera(index: number): object | null {\n // return null; // TODO: fix thi: object as null;\n // }\n\n getTexture(index: number): GLTFTexture {\n return this.getObject('textures', index) as GLTFTexture;\n }\n\n getSampler(index: number): GLTFSampler {\n return this.getObject('samplers', index) as GLTFSampler;\n }\n\n getImage(index: number): GLTFImage {\n return this.getObject('images', index) as GLTFImage;\n }\n\n getBufferView(index: number | object): GLTFBufferView {\n return this.getObject('bufferViews', index) as GLTFBufferView;\n }\n\n getBuffer(index: number): GLTFBuffer {\n return this.getObject('buffers', index) as GLTFBuffer;\n }\n\n getObject(array: string, index: number | object): object {\n // check if already resolved\n if (typeof index === 'object') {\n return index;\n }\n const object = this.json[array] && this.json[array][index];\n if (!object) {\n throw new Error(`glTF file error: Could not find ${array}[${index}]`); // eslint-disable-line\n }\n return object;\n }\n\n /**\n * Accepts buffer view index or buffer view object\n * @returns a `Uint8Array`\n */\n getTypedArrayForBufferView(bufferView: number | object): Uint8Array {\n bufferView = this.getBufferView(bufferView);\n // @ts-ignore\n const bufferIndex = bufferView.buffer;\n\n // Get hold of the arrayBuffer\n // const buffer = this.getBuffer(bufferIndex);\n const binChunk = this.gltf.buffers[bufferIndex];\n assert(binChunk);\n\n // @ts-ignore\n const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;\n // @ts-ignore\n return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);\n }\n\n /** Accepts accessor index or accessor object\n * @returns a typed array with type that matches the types\n */\n getTypedArrayForAccessor(accessor: number | object): any {\n // @ts-ignore\n accessor = this.getAccessor(accessor);\n // @ts-ignore\n const bufferView = this.getBufferView(accessor.bufferView);\n const buffer = this.getBuffer(bufferView.buffer);\n // @ts-ignore\n const arrayBuffer = buffer.data;\n\n // Create a new typed array as a view into the combined buffer\n const {ArrayType, length} = getAccessorArrayTypeAndLength(accessor, bufferView);\n // @ts-ignore\n const byteOffset = bufferView.byteOffset + accessor.byteOffset;\n return new ArrayType(arrayBuffer, byteOffset, length);\n }\n\n /** accepts accessor index or accessor object\n * returns a `Uint8Array`\n */\n getTypedArrayForImageData(image: number | object): Uint8Array {\n // @ts-ignore\n image = this.getAccessor(image);\n // @ts-ignore\n const bufferView = this.getBufferView(image.bufferView);\n const buffer = this.getBuffer(bufferView.buffer);\n // @ts-ignore\n const arrayBuffer = buffer.data;\n\n const byteOffset = bufferView.byteOffset || 0;\n return new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);\n }\n\n // MODIFERS\n\n /**\n * Add an extra application-defined key to the top-level data structure\n */\n addApplicationData(key: string, data: object): GLTFScenegraph {\n this.json[key] = data;\n return this;\n }\n\n /**\n * `extras` - Standard GLTF field for storing application specific data\n */\n addExtraData(key: string, data: object): GLTFScenegraph {\n this.json.extras = this.json.extras || {};\n this.json.extras[key] = data;\n return this;\n }\n\n addObjectExtension(object: object, extensionName: string, data: object): GLTFScenegraph {\n // @ts-ignore\n object.extensions = object.extensions || {};\n // TODO - clobber or merge?\n // @ts-ignore\n object.extensions[extensionName] = data;\n this.registerUsedExtension(extensionName);\n return this;\n }\n\n setObjectExtension(object: object, extensionName: string, data: object): void {\n // @ts-ignore\n const extensions = object.extensions || {};\n extensions[extensionName] = data;\n // TODO - add to usedExtensions...\n }\n\n removeObjectExtension(object: object, extensionName: string): object {\n // @ts-ignore\n const extensions = object.extensions || {};\n const extension = extensions[extensionName];\n delete extensions[extensionName];\n return extension;\n }\n\n /**\n * Add to standard GLTF top level extension object, mark as used\n */\n addExtension(extensionName: string, extensionData: object = {}): object {\n assert(extensionData);\n this.json.extensions = this.json.extensions || {};\n this.json.extensions[extensionName] = extensionData;\n this.registerUsedExtension(extensionName);\n return extensionData;\n }\n\n /**\n * Standard GLTF top level extension object, mark as used and required\n */\n addRequiredExtension(extensionName, extensionData: object = {}): object {\n assert(extensionData);\n this.addExtension(extensionName, extensionData);\n this.registerRequiredExtension(extensionName);\n return extensionData;\n }\n\n /**\n * Add extensionName to list of used extensions\n */\n registerUsedExtension(extensionName: string): void {\n this.json.extensionsUsed = this.json.extensionsUsed || [];\n if (!this.json.extensionsUsed.find((ext) => ext === extensionName)) {\n this.json.extensionsUsed.push(extensionName);\n }\n }\n\n /**\n * Add extensionName to list of required extensions\n */\n registerRequiredExtension(extensionName: string): void {\n this.registerUsedExtension(extensionName);\n this.json.extensionsRequired = this.json.extensionsRequired || [];\n if (!this.json.extensionsRequired.find((ext) => ext === extensionName)) {\n this.json.extensionsRequired.push(extensionName);\n }\n }\n\n /**\n * Removes an extension from the top-level list\n */\n removeExtension(extensionName: string): void {\n if (this.json.extensionsRequired) {\n this._removeStringFromArray(this.json.extensionsRequired, extensionName);\n }\n if (this.json.extensionsUsed) {\n this._removeStringFromArray(this.json.extensionsUsed, extensionName);\n }\n if (this.json.extensions) {\n delete this.json.extensions[extensionName];\n }\n }\n\n /**\n * Set default scene which is to be displayed at load time\n */\n setDefaultScene(sceneIndex: number): void {\n this.json.scene = sceneIndex;\n }\n\n /**\n * @todo: add more properties for scene initialization:\n * name`, `extensions`, `extras`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-scene\n */\n addScene(scene: {nodeIndices: number[]}): number {\n const {nodeIndices} = scene;\n this.json.scenes = this.json.scenes || [];\n this.json.scenes.push({nodes: nodeIndices});\n return this.json.scenes.length - 1;\n }\n\n /**\n * @todo: add more properties for node initialization:\n * `name`, `extensions`, `extras`, `camera`, `children`, `skin`, `rotation`, `scale`, `translation`, `weights`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#node\n */\n addNode(node: {meshIndex: number; matrix?: number[]}): number {\n const {meshIndex, matrix} = node;\n this.json.nodes = this.json.nodes || [];\n const nodeData = {mesh: meshIndex};\n if (matrix) {\n // @ts-ignore\n nodeData.matrix = matrix;\n }\n this.json.nodes.push(nodeData);\n return this.json.nodes.length - 1;\n }\n\n /** Adds a mesh to the json part */\n addMesh(mesh: {attributes: object; indices?: object; material?: number; mode?: number}): number {\n const {attributes, indices, material, mode = 4} = mesh;\n const accessors = this._addAttributes(attributes);\n\n const glTFMesh = {\n primitives: [\n {\n attributes: accessors,\n mode\n }\n ]\n };\n\n if (indices) {\n const indicesAccessor = this._addIndices(indices);\n // @ts-ignore\n glTFMesh.primitives[0].indices = indicesAccessor;\n }\n\n if (Number.isFinite(material)) {\n // @ts-ignore\n glTFMesh.primitives[0].material = material;\n }\n\n this.json.meshes = this.json.meshes || [];\n this.json.meshes.push(glTFMesh);\n return this.json.meshes.length - 1;\n }\n\n addPointCloud(attributes: object): number {\n // @ts-ignore\n const accessorIndices = this._addAttributes(attributes);\n\n const glTFMesh = {\n primitives: [\n {\n attributes: accessorIndices,\n mode: 0 // GL.POINTS\n }\n ]\n };\n\n this.json.meshes = this.json.meshes || [];\n this.json.meshes.push(glTFMesh);\n return this.json.meshes.length - 1;\n }\n\n /**\n * Adds a binary image. Builds glTF \"JSON metadata\" and saves buffer reference\n * Buffer will be copied into BIN chunk during \"pack\"\n * Currently encodes as glTF image\n * @param imageData\n * @param mimeType\n */\n addImage(imageData: any, mimeTypeOpt?: string): number {\n // If image is referencing a bufferView instead of URI, mimeType must be defined:\n // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#images\n // \"a reference to a bufferView; in that case mimeType must be defined.\"\n const metadata = getBinaryImageMetadata(imageData);\n const mimeType = mimeTypeOpt || metadata?.mimeType;\n\n const bufferViewIndex = this.addBufferView(imageData);\n\n const glTFImage = {\n bufferView: bufferViewIndex,\n mimeType\n };\n\n this.json.images = this.json.images || [];\n this.json.images.push(glTFImage);\n return this.json.images.length - 1;\n }\n\n /**\n * Add one untyped source buffer, create a matching glTF `bufferView`, and return its index\n * @param buffer\n */\n addBufferView(buffer: any): number {\n const byteLength = buffer.byteLength;\n assert(Number.isFinite(byteLength));\n\n // Add this buffer to the list of buffers to be written to the body.\n this.sourceBuffers = this.sourceBuffers || [];\n this.sourceBuffers.push(buffer);\n\n const glTFBufferView = {\n buffer: 0,\n // Write offset from the start of the binary body\n byteOffset: this.byteLength,\n byteLength\n };\n\n // We've now added the contents to the body, so update the total length\n // Every sub-chunk needs to be 4-byte align ed\n this.byteLength += padToNBytes(byteLength, 4);\n\n // Add a bufferView indicating start and length of this binary sub-chunk\n this.json.bufferViews = this.json.bufferViews || [];\n this.json.bufferViews.push(glTFBufferView);\n return this.json.bufferViews.length - 1;\n }\n\n /**\n * Adds an accessor to a bufferView\n * @param bufferViewIndex\n * @param accessor\n */\n addAccessor(bufferViewIndex: number, accessor: object): number {\n const glTFAccessor = {\n bufferView: bufferViewIndex,\n // @ts-ignore\n type: getAccessorTypeFromSize(accessor.size),\n // @ts-ignore\n componentType: accessor.componentType,\n // @ts-ignore\n count: accessor.count,\n // @ts-ignore\n max: accessor.max,\n // @ts-ignore\n min: accessor.min\n };\n\n this.json.accessors = this.json.accessors || [];\n this.json.accessors.push(glTFAccessor);\n return this.json.accessors.length - 1;\n }\n\n /**\n * Add a binary buffer. Builds glTF \"JSON metadata\" and saves buffer reference\n * Buffer will be copied into BIN chunk during \"pack\"\n * Currently encodes buffers as glTF accessors, but this could be optimized\n * @param sourceBuffer\n * @param accessor\n */\n addBinaryBuffer(sourceBuffer: any, accessor: object = {size: 3}): number {\n const bufferViewIndex = this.addBufferView(sourceBuffer);\n // @ts-ignore\n let minMax = {min: accessor.min, max: accessor.max};\n if (!minMax.min || !minMax.max) {\n // @ts-ignore\n minMax = this._getAccessorMinMax(sourceBuffer, accessor.size);\n }\n\n const accessorDefaults = {\n // @ts-ignore\n size: accessor.size,\n componentType: getComponentTypeFromArray(sourceBuffer),\n // @ts-ignore\n count: Math.round(sourceBuffer.length / accessor.size),\n min: minMax.min,\n max: minMax.max\n };\n\n return this.addAccessor(bufferViewIndex, Object.assign(accessorDefaults, accessor));\n }\n\n /**\n * Adds a texture to the json part\n * @todo: add more properties for texture initialization\n * `sampler`, `name`, `extensions`, `extras`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#texture\n */\n addTexture(texture: {imageIndex: number}): number {\n const {imageIndex} = texture;\n const glTFTexture = {\n source: imageIndex\n };\n\n this.json.textures = this.json.textures || [];\n this.json.textures.push(glTFTexture);\n return this.json.textures.length - 1;\n }\n\n /** Adds a material to the json part */\n addMaterial(pbrMaterialInfo: Object): number {\n this.json.materials = this.json.materials || [];\n this.json.materials.push(pbrMaterialInfo);\n return this.json.materials.length - 1;\n }\n\n /** Pack the binary chunk */\n createBinaryChunk(): void {\n // Encoder expects this array undefined or empty\n this.gltf.buffers = [];\n\n // Allocate total array\n const totalByteLength = this.byteLength;\n const arrayBuffer = new ArrayBuffer(totalByteLength);\n const targetArray = new Uint8Array(arrayBuffer);\n\n // Copy each array into\n let dstByteOffset = 0;\n for (const sourceBuffer of this.sourceBuffers || []) {\n dstByteOffset = copyToArray(sourceBuffer, targetArray, dstByteOffset);\n }\n\n // Update the glTF BIN CHUNK byte length\n if (this.json?.buffers?.[0]) {\n this.json.buffers[0].byteLength = totalByteLength;\n } else {\n this.json.buffers = [{byteLength: totalByteLength}];\n }\n\n // Save generated arrayBuffer\n this.gltf.binary = arrayBuffer;\n\n // Put arrayBuffer to sourceBuffers for possible additional writing data in the chunk\n this.sourceBuffers = [arrayBuffer];\n }\n\n // PRIVATE\n\n _removeStringFromArray(array, string) {\n let found = true;\n while (found) {\n const index = array.indexOf(string);\n if (index > -1) {\n array.splice(index, 1);\n } else {\n found = false;\n }\n }\n }\n\n /**\n * Add attributes to buffers and create `attributes` object which is part of `mesh`\n */\n _addAttributes(attributes = {}) {\n const result = {};\n for (const attributeKey in attributes) {\n const attributeData = attributes[attributeKey];\n const attrName = this._getGltfAttributeName(attributeKey);\n const accessor = this.addBinaryBuffer(attributeData.value, attributeData);\n result[attrName] = accessor;\n }\n return result;\n }\n\n /**\n * Add indices to buffers\n */\n _addIndices(indices) {\n return this.addBinaryBuffer(indices, {size: 1});\n }\n\n /**\n * Deduce gltf specific attribue name from input attribute name\n */\n _getGltfAttributeName(attributeName) {\n switch (attributeName.toLowerCase()) {\n case 'position':\n case 'positions':\n case 'vertices':\n return 'POSITION';\n case 'normal':\n case 'normals':\n return 'NORMAL';\n case 'color':\n case 'colors':\n return 'COLOR_0';\n case 'texcoord':\n case 'texcoords':\n return 'TEXCOORD_0';\n default:\n return attributeName;\n }\n }\n\n /**\n * Calculate `min` and `max` arrays of accessor according to spec:\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-accessor\n */\n _getAccessorMinMax(buffer, size) {\n const result = {min: null, max: null};\n if (buffer.length < size) {\n return result;\n }\n // @ts-ignore\n result.min = [];\n // @ts-ignore\n result.max = [];\n const initValues = buffer.subarray(0, size);\n for (const value of initValues) {\n // @ts-ignore\n result.min.push(value);\n // @ts-ignore\n result.max.push(value);\n }\n\n for (let index = size; index < buffer.length; index += size) {\n for (let componentIndex = 0; componentIndex < size; componentIndex++) {\n // @ts-ignore\n result.min[0 + componentIndex] = Math.min(\n // @ts-ignore\n result.min[0 + componentIndex],\n buffer[index + componentIndex]\n );\n // @ts-ignore\n result.max[0 + componentIndex] = Math.max(\n // @ts-ignore\n result.max[0 + componentIndex],\n buffer[index + componentIndex]\n );\n }\n }\n return result;\n }\n}\n"],"file":"gltf-scenegraph.js"}
@@ -1,295 +1,250 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.normalizeGLTFV1 = void 0;
23
- /* eslint-disable camelcase */
24
- const KHR_binary_glTF = __importStar(require("../extensions/KHR_binary_gltf"));
25
- // Binary format changes (mainly implemented by GLBLoader)
26
- // https://github.com/KhronosGroup/glTF/tree/master/extensions/1.0/Khronos/KHR_binary_glTF
27
- // JSON format changes:
28
- // https://github.com/khronosgroup/gltf/issues/605
29
- // - [x] Top-level JSON objects are arrays now
30
- // - [ ] Removed indirection from animation: sampler now refers directly to accessors, #712
31
- // - [ ] material.parameter.value and technique.parameter.value must be an array, #690
32
- // - [ ] Node can have only one mesh #821
33
- // - [ ] Added reqs on JSON encoding
34
- // - [ ] Added reqs on binary data alignment #802 (comment)
35
- // Additions:
36
- // - [ ] Added accessor.normalized, #691, #706
37
- // - [ ] Added glExtensionsUsed property and 5125 (UNSIGNED_INT) accessor.componentType value, #619
38
- // - [ ] Added extensionsRequired property, #720, #721
39
- // - [ ] Added "STEP" as valid animation.sampler.interpolation value, #712
40
- // Removals:
41
- // - [x] Removed buffer.type, #786, #629
42
- // - [ ] Removed revision number from profile.version, #709
43
- // - [ ] Removed technique.functions.scissor and removed 3089 (SCISSOR_TEST) as a valid value for technique.states.enable, #681
44
- // - [ ] Techniques, programs, and shaders were moved out to KHR_technique_webgl extension.
45
- // Other edits:
46
- // - [x] asset is now required, #642
47
- // - [ ] buffer.byteLength and bufferView.byteLength are now required, #560.
48
- // - [ ] accessor.min and accessor.max are now required, #593, and clarified that the JSON value and binary data must be the same, #628.
49
- // - [ ] Clarified animation.sampler and animation.channel restrictions, #712
50
- // - [ ] skin.inverseBindMatrices is now optional, #461.
51
- // - [ ] Attribute parameters can't have a value defined in the technique or parameter, #563 (comment).
52
- // - [ ] Only TEXCOORD and COLOR attribute semantics can be written in the form [semantic]_[set_index], #563 (comment).
53
- // - [ ] TEXCOORD and COLOR attribute semantics must be written in the form [semantic]_[set_index], e.g., just TEXCOORD should be TEXCOORD_0, and just COLOR should be COLOR_0, #649
54
- // - [ ] camera.perspective.aspectRatio and camera.perspective.yfov must now be > 0, not >= 0, #563 (comment).
55
- // - [ ] Application-specific parameter semantics must start with an underscore, e.g., _TEMPERATURE and _SIMULATION_TIME, #563 (comment).
56
- // - [ ] Properties in technique.parameters must be defined in technique.uniforms or technique.attributes,
57
- // #563 (comment).
58
- // - [ ] technique.parameter.count can only be defined when the semantic is JOINTMATRIX or an application-specific semantic is used. It can never be defined for attribute parameters; only uniforms, d2f6945
59
- // - [ ] technique.parameter.semantic is required when the parameter is an attribute, 28e113d
60
- // - [ ] Mesh-only models are allowed, e.g., without materials, #642
61
- // - [ ] Skeleton hierarchies (nodes containing jointName) must be separated from non-skeleton hierarchies., #647
62
- // - [ ] technique.states.functions.blendColor and technique.states.functions.depthRange parameters now must match WebGL function min/max, #707
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import * as KHR_binary_glTF from '../extensions/KHR_binary_gltf';
63
3
  const GLTF_ARRAYS = {
64
- accessors: 'accessor',
65
- animations: 'animation',
66
- buffers: 'buffer',
67
- bufferViews: 'bufferView',
68
- images: 'image',
69
- materials: 'material',
70
- meshes: 'mesh',
71
- nodes: 'node',
72
- samplers: 'sampler',
73
- scenes: 'scene',
74
- skins: 'skin',
75
- textures: 'texture'
4
+ accessors: 'accessor',
5
+ animations: 'animation',
6
+ buffers: 'buffer',
7
+ bufferViews: 'bufferView',
8
+ images: 'image',
9
+ materials: 'material',
10
+ meshes: 'mesh',
11
+ nodes: 'node',
12
+ samplers: 'sampler',
13
+ scenes: 'scene',
14
+ skins: 'skin',
15
+ textures: 'texture'
76
16
  };
77
17
  const GLTF_KEYS = {
78
- accessor: 'accessors',
79
- animations: 'animation',
80
- buffer: 'buffers',
81
- bufferView: 'bufferViews',
82
- image: 'images',
83
- material: 'materials',
84
- mesh: 'meshes',
85
- node: 'nodes',
86
- sampler: 'samplers',
87
- scene: 'scenes',
88
- skin: 'skins',
89
- texture: 'textures'
18
+ accessor: 'accessors',
19
+ animations: 'animation',
20
+ buffer: 'buffers',
21
+ bufferView: 'bufferViews',
22
+ image: 'images',
23
+ material: 'materials',
24
+ mesh: 'meshes',
25
+ node: 'nodes',
26
+ sampler: 'samplers',
27
+ scene: 'scenes',
28
+ skin: 'skins',
29
+ texture: 'textures'
90
30
  };
91
- /**
92
- * Converts (normalizes) glTF v1 to v2
93
- */
31
+
94
32
  class GLTFV1Normalizer {
95
- constructor() {
96
- this.idToIndexMap = {
97
- animations: {},
98
- accessors: {},
99
- buffers: {},
100
- bufferViews: {},
101
- images: {},
102
- materials: {},
103
- meshes: {},
104
- nodes: {},
105
- samplers: {},
106
- scenes: {},
107
- skins: {},
108
- textures: {}
109
- };
33
+ constructor() {
34
+ _defineProperty(this, "idToIndexMap", {
35
+ animations: {},
36
+ accessors: {},
37
+ buffers: {},
38
+ bufferViews: {},
39
+ images: {},
40
+ materials: {},
41
+ meshes: {},
42
+ nodes: {},
43
+ samplers: {},
44
+ scenes: {},
45
+ skins: {},
46
+ textures: {}
47
+ });
48
+
49
+ _defineProperty(this, "json", void 0);
50
+ }
51
+
52
+ normalize(gltf, options) {
53
+ this.json = gltf.json;
54
+ const json = gltf.json;
55
+
56
+ switch (json.asset && json.asset.version) {
57
+ case '2.0':
58
+ return;
59
+
60
+ case undefined:
61
+ case '1.0':
62
+ break;
63
+
64
+ default:
65
+ console.warn("glTF: Unknown version ".concat(json.asset.version));
66
+ return;
67
+ }
68
+
69
+ if (!options.normalize) {
70
+ throw new Error('glTF v1 is not supported.');
71
+ }
72
+
73
+ console.warn('Converting glTF v1 to glTF v2 format. This is experimental and may fail.');
74
+
75
+ this._addAsset(json);
76
+
77
+ this._convertTopLevelObjectsToArrays(json);
78
+
79
+ KHR_binary_glTF.preprocess(gltf);
80
+
81
+ this._convertObjectIdsToArrayIndices(json);
82
+
83
+ this._updateObjects(json);
84
+
85
+ this._updateMaterial(json);
86
+ }
87
+
88
+ _addAsset(json) {
89
+ json.asset = json.asset || {};
90
+ json.asset.version = '2.0';
91
+ json.asset.generator = json.asset.generator || 'Normalized to glTF 2.0 by loaders.gl';
92
+ }
93
+
94
+ _convertTopLevelObjectsToArrays(json) {
95
+ for (const arrayName in GLTF_ARRAYS) {
96
+ this._convertTopLevelObjectToArray(json, arrayName);
97
+ }
98
+ }
99
+
100
+ _convertTopLevelObjectToArray(json, mapName) {
101
+ const objectMap = json[mapName];
102
+
103
+ if (!objectMap || Array.isArray(objectMap)) {
104
+ return;
110
105
  }
111
- // constructor() {}
112
- /**
113
- * Convert (normalize) glTF < 2.0 to glTF 2.0
114
- * @param gltf - object with json and binChunks
115
- * @param options
116
- * @param options normalize Whether to actually normalize
117
- */
118
- normalize(gltf, options) {
119
- this.json = gltf.json;
120
- const json = gltf.json;
121
- // Check version
122
- switch (json.asset && json.asset.version) {
123
- // We are converting to v2 format. Return if there is nothing to do
124
- case '2.0':
125
- return;
126
- // This class is written to convert 1.0
127
- case undefined:
128
- case '1.0':
129
- break;
130
- default:
131
- // eslint-disable-next-line no-undef, no-console
132
- console.warn(`glTF: Unknown version ${json.asset.version}`);
133
- return;
134
- }
135
- if (!options.normalize) {
136
- // We are still missing a few conversion tricks, remove once addressed
137
- throw new Error('glTF v1 is not supported.');
138
- }
139
- // eslint-disable-next-line no-undef, no-console
140
- console.warn('Converting glTF v1 to glTF v2 format. This is experimental and may fail.');
141
- this._addAsset(json);
142
- // In glTF2 top-level fields are Arrays not Object maps
143
- this._convertTopLevelObjectsToArrays(json);
144
- // Extract bufferView indices for images
145
- // (this extension needs to be invoked early in the normalization process)
146
- // TODO can this be handled by standard extension processing instead of called explicitly?
147
- KHR_binary_glTF.preprocess(gltf);
148
- // Convert object references from ids to indices
149
- this._convertObjectIdsToArrayIndices(json);
150
- this._updateObjects(json);
151
- this._updateMaterial(json);
106
+
107
+ json[mapName] = [];
108
+
109
+ for (const id in objectMap) {
110
+ const object = objectMap[id];
111
+ object.id = object.id || id;
112
+ const index = json[mapName].length;
113
+ json[mapName].push(object);
114
+ this.idToIndexMap[mapName][id] = index;
152
115
  }
153
- // asset is now required, #642 https://github.com/KhronosGroup/glTF/issues/639
154
- _addAsset(json) {
155
- json.asset = json.asset || {};
156
- // We are normalizing to glTF v2, so change version to "2.0"
157
- json.asset.version = '2.0';
158
- json.asset.generator = json.asset.generator || 'Normalized to glTF 2.0 by loaders.gl';
116
+ }
117
+
118
+ _convertObjectIdsToArrayIndices(json) {
119
+ for (const arrayName in GLTF_ARRAYS) {
120
+ this._convertIdsToIndices(json, arrayName);
159
121
  }
160
- _convertTopLevelObjectsToArrays(json) {
161
- // TODO check that all arrays are covered
162
- for (const arrayName in GLTF_ARRAYS) {
163
- this._convertTopLevelObjectToArray(json, arrayName);
164
- }
122
+
123
+ if ('scene' in json) {
124
+ json.scene = this._convertIdToIndex(json.scene, 'scene');
165
125
  }
166
- /** Convert one top level object to array */
167
- _convertTopLevelObjectToArray(json, mapName) {
168
- const objectMap = json[mapName];
169
- if (!objectMap || Array.isArray(objectMap)) {
170
- return;
171
- }
172
- // Rewrite the top-level field as an array
173
- json[mapName] = [];
174
- // Copy the map key into object.id
175
- for (const id in objectMap) {
176
- const object = objectMap[id];
177
- object.id = object.id || id; // Mutates the loaded object
178
- const index = json[mapName].length;
179
- json[mapName].push(object);
180
- this.idToIndexMap[mapName][id] = index;
181
- }
126
+
127
+ for (const texture of json.textures) {
128
+ this._convertTextureIds(texture);
182
129
  }
183
- /** Go through all objects in all top-level arrays and replace ids with indices */
184
- _convertObjectIdsToArrayIndices(json) {
185
- for (const arrayName in GLTF_ARRAYS) {
186
- this._convertIdsToIndices(json, arrayName);
187
- }
188
- if ('scene' in json) {
189
- json.scene = this._convertIdToIndex(json.scene, 'scene');
190
- }
191
- // Convert any index references that are not using array names
192
- // texture.source (image)
193
- for (const texture of json.textures) {
194
- this._convertTextureIds(texture);
195
- }
196
- for (const mesh of json.meshes) {
197
- this._convertMeshIds(mesh);
198
- }
199
- for (const node of json.nodes) {
200
- this._convertNodeIds(node);
201
- }
202
- for (const node of json.scenes) {
203
- this._convertSceneIds(node);
204
- }
130
+
131
+ for (const mesh of json.meshes) {
132
+ this._convertMeshIds(mesh);
205
133
  }
206
- _convertTextureIds(texture) {
207
- if (texture.source) {
208
- texture.source = this._convertIdToIndex(texture.source, 'image');
209
- }
134
+
135
+ for (const node of json.nodes) {
136
+ this._convertNodeIds(node);
210
137
  }
211
- _convertMeshIds(mesh) {
212
- for (const primitive of mesh.primitives) {
213
- const { attributes, indices, material } = primitive;
214
- for (const attributeName in attributes) {
215
- attributes[attributeName] = this._convertIdToIndex(attributes[attributeName], 'accessor');
216
- }
217
- if (indices) {
218
- primitive.indices = this._convertIdToIndex(indices, 'accessor');
219
- }
220
- if (material) {
221
- primitive.material = this._convertIdToIndex(material, 'material');
222
- }
223
- }
138
+
139
+ for (const node of json.scenes) {
140
+ this._convertSceneIds(node);
224
141
  }
225
- _convertNodeIds(node) {
226
- if (node.children) {
227
- node.children = node.children.map((child) => this._convertIdToIndex(child, 'node'));
228
- }
229
- if (node.meshes) {
230
- node.meshes = node.meshes.map((mesh) => this._convertIdToIndex(mesh, 'mesh'));
231
- }
142
+ }
143
+
144
+ _convertTextureIds(texture) {
145
+ if (texture.source) {
146
+ texture.source = this._convertIdToIndex(texture.source, 'image');
232
147
  }
233
- _convertSceneIds(scene) {
234
- if (scene.nodes) {
235
- scene.nodes = scene.nodes.map((node) => this._convertIdToIndex(node, 'node'));
236
- }
148
+ }
149
+
150
+ _convertMeshIds(mesh) {
151
+ for (const primitive of mesh.primitives) {
152
+ const {
153
+ attributes,
154
+ indices,
155
+ material
156
+ } = primitive;
157
+
158
+ for (const attributeName in attributes) {
159
+ attributes[attributeName] = this._convertIdToIndex(attributes[attributeName], 'accessor');
160
+ }
161
+
162
+ if (indices) {
163
+ primitive.indices = this._convertIdToIndex(indices, 'accessor');
164
+ }
165
+
166
+ if (material) {
167
+ primitive.material = this._convertIdToIndex(material, 'material');
168
+ }
237
169
  }
238
- /** Go through all objects in a top-level array and replace ids with indices */
239
- _convertIdsToIndices(json, topLevelArrayName) {
240
- if (!json[topLevelArrayName]) {
241
- console.warn(`gltf v1: json doesn't contain attribute ${topLevelArrayName}`); // eslint-disable-line no-console, no-undef
242
- json[topLevelArrayName] = [];
243
- }
244
- for (const object of json[topLevelArrayName]) {
245
- for (const key in object) {
246
- const id = object[key];
247
- const index = this._convertIdToIndex(id, key);
248
- object[key] = index;
249
- }
250
- }
170
+ }
171
+
172
+ _convertNodeIds(node) {
173
+ if (node.children) {
174
+ node.children = node.children.map(child => this._convertIdToIndex(child, 'node'));
251
175
  }
252
- _convertIdToIndex(id, key) {
253
- const arrayName = GLTF_KEYS[key];
254
- if (arrayName in this.idToIndexMap) {
255
- const index = this.idToIndexMap[arrayName][id];
256
- if (!Number.isFinite(index)) {
257
- throw new Error(`gltf v1: failed to resolve ${key} with id ${id}`);
258
- }
259
- return index;
260
- }
261
- return id;
176
+
177
+ if (node.meshes) {
178
+ node.meshes = node.meshes.map(mesh => this._convertIdToIndex(mesh, 'mesh'));
262
179
  }
263
- /**
264
- *
265
- * @param {*} json
266
- */
267
- _updateObjects(json) {
268
- for (const buffer of this.json.buffers) {
269
- // - [x] Removed buffer.type, #786, #629
270
- delete buffer.type;
271
- }
180
+ }
181
+
182
+ _convertSceneIds(scene) {
183
+ if (scene.nodes) {
184
+ scene.nodes = scene.nodes.map(node => this._convertIdToIndex(node, 'node'));
272
185
  }
273
- /**
274
- * Update material (set pbrMetallicRoughness)
275
- * @param {*} json
276
- */
277
- _updateMaterial(json) {
278
- for (const material of json.materials) {
279
- material.pbrMetallicRoughness = {
280
- baseColorFactor: [1, 1, 1, 1],
281
- metallicFactor: 1,
282
- roughnessFactor: 1
283
- };
284
- const textureId = material.values && material.values.tex;
285
- const textureIndex = json.textures.findIndex((texture) => texture.id === textureId);
286
- if (textureIndex !== -1) {
287
- material.pbrMetallicRoughness.baseColorTexture = { index: textureIndex };
288
- }
289
- }
186
+ }
187
+
188
+ _convertIdsToIndices(json, topLevelArrayName) {
189
+ if (!json[topLevelArrayName]) {
190
+ console.warn("gltf v1: json doesn't contain attribute ".concat(topLevelArrayName));
191
+ json[topLevelArrayName] = [];
192
+ }
193
+
194
+ for (const object of json[topLevelArrayName]) {
195
+ for (const key in object) {
196
+ const id = object[key];
197
+
198
+ const index = this._convertIdToIndex(id, key);
199
+
200
+ object[key] = index;
201
+ }
202
+ }
203
+ }
204
+
205
+ _convertIdToIndex(id, key) {
206
+ const arrayName = GLTF_KEYS[key];
207
+
208
+ if (arrayName in this.idToIndexMap) {
209
+ const index = this.idToIndexMap[arrayName][id];
210
+
211
+ if (!Number.isFinite(index)) {
212
+ throw new Error("gltf v1: failed to resolve ".concat(key, " with id ").concat(id));
213
+ }
214
+
215
+ return index;
216
+ }
217
+
218
+ return id;
219
+ }
220
+
221
+ _updateObjects(json) {
222
+ for (const buffer of this.json.buffers) {
223
+ delete buffer.type;
224
+ }
225
+ }
226
+
227
+ _updateMaterial(json) {
228
+ for (const material of json.materials) {
229
+ material.pbrMetallicRoughness = {
230
+ baseColorFactor: [1, 1, 1, 1],
231
+ metallicFactor: 1,
232
+ roughnessFactor: 1
233
+ };
234
+ const textureId = material.values && material.values.tex;
235
+ const textureIndex = json.textures.findIndex(texture => texture.id === textureId);
236
+
237
+ if (textureIndex !== -1) {
238
+ material.pbrMetallicRoughness.baseColorTexture = {
239
+ index: textureIndex
240
+ };
241
+ }
290
242
  }
243
+ }
244
+
291
245
  }
292
- function normalizeGLTFV1(gltf, options = {}) {
293
- return new GLTFV1Normalizer().normalize(gltf, options);
246
+
247
+ export function normalizeGLTFV1(gltf, options = {}) {
248
+ return new GLTFV1Normalizer().normalize(gltf, options);
294
249
  }
295
- exports.normalizeGLTFV1 = normalizeGLTFV1;
250
+ //# sourceMappingURL=normalize-gltf-v1.js.map