@loaders.gl/gltf 4.0.0-alpha.9 → 4.0.0-beta.2

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 (152) hide show
  1. package/dist/dist.min.js +3777 -3105
  2. package/dist/es5/glb-loader.js +1 -3
  3. package/dist/es5/glb-loader.js.map +1 -1
  4. package/dist/es5/index.js +33 -0
  5. package/dist/es5/index.js.map +1 -1
  6. package/dist/es5/lib/api/gltf-extensions.js +3 -1
  7. package/dist/es5/lib/api/gltf-extensions.js.map +1 -1
  8. package/dist/es5/lib/extensions/EXT_mesh_features.js +99 -0
  9. package/dist/es5/lib/extensions/EXT_mesh_features.js.map +1 -0
  10. package/dist/es5/lib/extensions/EXT_meshopt_compression.js +2 -2
  11. package/dist/es5/lib/extensions/EXT_meshopt_compression.js.map +1 -1
  12. package/dist/es5/lib/extensions/EXT_structural_metadata.js +375 -0
  13. package/dist/es5/lib/extensions/EXT_structural_metadata.js.map +1 -0
  14. package/dist/es5/lib/extensions/KHR_draco_mesh_compression.js +6 -7
  15. package/dist/es5/lib/extensions/KHR_draco_mesh_compression.js.map +1 -1
  16. package/dist/es5/lib/extensions/KHR_texture_transform.js +2 -1
  17. package/dist/es5/lib/extensions/KHR_texture_transform.js.map +1 -1
  18. package/dist/es5/lib/extensions/deprecated/EXT_feature_metadata.js +162 -183
  19. package/dist/es5/lib/extensions/deprecated/EXT_feature_metadata.js.map +1 -1
  20. package/dist/es5/lib/extensions/utils/3d-tiles-utils.js +254 -0
  21. package/dist/es5/lib/extensions/utils/3d-tiles-utils.js.map +1 -0
  22. package/dist/es5/lib/gltf-utils/gltf-utils.js +29 -0
  23. package/dist/es5/lib/gltf-utils/gltf-utils.js.map +1 -1
  24. package/dist/es5/lib/parsers/parse-gltf.js +7 -4
  25. package/dist/es5/lib/parsers/parse-gltf.js.map +1 -1
  26. package/dist/es5/lib/types/gltf-ext-feature-metadata-schema.js +2 -0
  27. package/dist/es5/lib/types/gltf-ext-feature-metadata-schema.js.map +1 -0
  28. package/dist/es5/lib/types/gltf-ext-mesh-features-schema.js +2 -0
  29. package/dist/es5/lib/types/gltf-ext-mesh-features-schema.js.map +1 -0
  30. package/dist/es5/lib/types/gltf-ext-structural-metadata-schema.js +2 -0
  31. package/dist/es5/lib/types/gltf-ext-structural-metadata-schema.js.map +1 -0
  32. package/dist/es5/lib/types/gltf-json-schema.js.map +1 -1
  33. package/dist/es5/lib/types/gltf-types.js.map +1 -1
  34. package/dist/es5/lib/utils/version.js +1 -1
  35. package/dist/es5/lib/utils/version.js.map +1 -1
  36. package/dist/esm/glb-loader.js +0 -1
  37. package/dist/esm/glb-loader.js.map +1 -1
  38. package/dist/esm/index.js +5 -0
  39. package/dist/esm/index.js.map +1 -1
  40. package/dist/esm/lib/api/gltf-extensions.js +3 -1
  41. package/dist/esm/lib/api/gltf-extensions.js.map +1 -1
  42. package/dist/esm/lib/extensions/EXT_mesh_features.js +43 -0
  43. package/dist/esm/lib/extensions/EXT_mesh_features.js.map +1 -0
  44. package/dist/esm/lib/extensions/EXT_meshopt_compression.js +2 -2
  45. package/dist/esm/lib/extensions/EXT_meshopt_compression.js.map +1 -1
  46. package/dist/esm/lib/extensions/EXT_structural_metadata.js +302 -0
  47. package/dist/esm/lib/extensions/EXT_structural_metadata.js.map +1 -0
  48. package/dist/esm/lib/extensions/KHR_draco_mesh_compression.js +2 -5
  49. package/dist/esm/lib/extensions/KHR_draco_mesh_compression.js.map +1 -1
  50. package/dist/esm/lib/extensions/KHR_texture_transform.js +2 -1
  51. package/dist/esm/lib/extensions/KHR_texture_transform.js.map +1 -1
  52. package/dist/esm/lib/extensions/deprecated/EXT_feature_metadata.js +156 -167
  53. package/dist/esm/lib/extensions/deprecated/EXT_feature_metadata.js.map +1 -1
  54. package/dist/esm/lib/extensions/utils/3d-tiles-utils.js +215 -0
  55. package/dist/esm/lib/extensions/utils/3d-tiles-utils.js.map +1 -0
  56. package/dist/esm/lib/gltf-utils/gltf-utils.js +30 -0
  57. package/dist/esm/lib/gltf-utils/gltf-utils.js.map +1 -1
  58. package/dist/esm/lib/parsers/parse-gltf.js +6 -6
  59. package/dist/esm/lib/parsers/parse-gltf.js.map +1 -1
  60. package/dist/esm/lib/types/gltf-ext-feature-metadata-schema.js +2 -0
  61. package/dist/esm/lib/types/gltf-ext-feature-metadata-schema.js.map +1 -0
  62. package/dist/esm/lib/types/gltf-ext-mesh-features-schema.js +2 -0
  63. package/dist/esm/lib/types/gltf-ext-mesh-features-schema.js.map +1 -0
  64. package/dist/esm/lib/types/gltf-ext-structural-metadata-schema.js +2 -0
  65. package/dist/esm/lib/types/gltf-ext-structural-metadata-schema.js.map +1 -0
  66. package/dist/esm/lib/types/gltf-json-schema.js.map +1 -1
  67. package/dist/esm/lib/types/gltf-types.js.map +1 -1
  68. package/dist/esm/lib/utils/version.js +1 -1
  69. package/dist/esm/lib/utils/version.js.map +1 -1
  70. package/dist/glb-loader.d.ts +3 -1
  71. package/dist/glb-loader.d.ts.map +1 -1
  72. package/dist/index.d.ts +10 -2
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/lib/api/gltf-extensions.d.ts.map +1 -1
  75. package/dist/lib/extensions/EXT_mesh_features.d.ts +7 -0
  76. package/dist/lib/extensions/EXT_mesh_features.d.ts.map +1 -0
  77. package/dist/lib/extensions/EXT_structural_metadata.d.ts +16 -0
  78. package/dist/lib/extensions/EXT_structural_metadata.d.ts.map +1 -0
  79. package/dist/lib/extensions/KHR_draco_mesh_compression.d.ts +1 -1
  80. package/dist/lib/extensions/KHR_draco_mesh_compression.d.ts.map +1 -1
  81. package/dist/lib/extensions/deprecated/EXT_feature_metadata.d.ts +9 -0
  82. package/dist/lib/extensions/deprecated/EXT_feature_metadata.d.ts.map +1 -1
  83. package/dist/lib/extensions/utils/3d-tiles-utils.d.ts +82 -0
  84. package/dist/lib/extensions/utils/3d-tiles-utils.d.ts.map +1 -0
  85. package/dist/lib/gltf-utils/gltf-utils.d.ts +2 -0
  86. package/dist/lib/gltf-utils/gltf-utils.d.ts.map +1 -1
  87. package/dist/lib/parsers/parse-gltf.d.ts.map +1 -1
  88. package/dist/lib/types/gltf-ext-feature-metadata-schema.d.ts +421 -0
  89. package/dist/lib/types/gltf-ext-feature-metadata-schema.d.ts.map +1 -0
  90. package/dist/lib/types/gltf-ext-mesh-features-schema.d.ts +43 -0
  91. package/dist/lib/types/gltf-ext-mesh-features-schema.d.ts.map +1 -0
  92. package/dist/lib/types/gltf-ext-structural-metadata-schema.d.ts +329 -0
  93. package/dist/lib/types/gltf-ext-structural-metadata-schema.d.ts.map +1 -0
  94. package/dist/lib/types/gltf-json-schema.d.ts +12 -404
  95. package/dist/lib/types/gltf-json-schema.d.ts.map +1 -1
  96. package/dist/lib/types/gltf-types.d.ts +4 -1
  97. package/dist/lib/types/gltf-types.d.ts.map +1 -1
  98. package/package.json +6 -6
  99. package/src/glb-loader.ts +3 -3
  100. package/src/index.ts +37 -6
  101. package/src/lib/api/gltf-extensions.ts +6 -2
  102. package/src/lib/extensions/EXT_mesh_features.ts +91 -0
  103. package/src/lib/extensions/EXT_meshopt_compression.ts +1 -1
  104. package/src/lib/extensions/EXT_structural_metadata.ts +750 -0
  105. package/src/lib/extensions/KHR_draco_mesh_compression.ts +7 -7
  106. package/src/lib/extensions/KHR_texture_transform.ts +1 -1
  107. package/src/lib/extensions/deprecated/EXT_feature_metadata.ts +407 -281
  108. package/src/lib/extensions/utils/3d-tiles-utils.ts +430 -0
  109. package/src/lib/gltf-utils/gltf-utils.ts +38 -0
  110. package/src/lib/parsers/parse-gltf.ts +14 -6
  111. package/src/lib/types/gltf-ext-feature-metadata-schema.ts +470 -0
  112. package/src/lib/types/gltf-ext-mesh-features-schema.ts +46 -0
  113. package/src/lib/types/gltf-ext-structural-metadata-schema.ts +378 -0
  114. package/src/lib/types/gltf-json-schema.ts +26 -465
  115. package/src/lib/types/gltf-types.ts +5 -3
  116. package/dist/bundle.js +0 -5
  117. package/dist/glb-loader.js +0 -36
  118. package/dist/glb-writer.js +0 -35
  119. package/dist/gltf-loader.js +0 -50
  120. package/dist/gltf-writer.js +0 -32
  121. package/dist/index.js +0 -28
  122. package/dist/lib/api/gltf-extensions.js +0 -83
  123. package/dist/lib/api/gltf-scenegraph.js +0 -580
  124. package/dist/lib/api/normalize-gltf-v1.js +0 -299
  125. package/dist/lib/api/post-process-gltf.js +0 -433
  126. package/dist/lib/encoders/encode-glb.js +0 -72
  127. package/dist/lib/encoders/encode-gltf.js +0 -32
  128. package/dist/lib/extensions/EXT_meshopt_compression.js +0 -41
  129. package/dist/lib/extensions/EXT_texture_webp.js +0 -36
  130. package/dist/lib/extensions/KHR_binary_gltf.js +0 -39
  131. package/dist/lib/extensions/KHR_draco_mesh_compression.js +0 -138
  132. package/dist/lib/extensions/KHR_texture_basisu.js +0 -29
  133. package/dist/lib/extensions/KHR_texture_transform.js +0 -227
  134. package/dist/lib/extensions/deprecated/EXT_feature_metadata.js +0 -290
  135. package/dist/lib/extensions/deprecated/KHR_lights_punctual.js +0 -59
  136. package/dist/lib/extensions/deprecated/KHR_materials_unlit.js +0 -44
  137. package/dist/lib/extensions/deprecated/KHR_techniques_webgl.js +0 -79
  138. package/dist/lib/gltf-utils/get-typed-array.js +0 -41
  139. package/dist/lib/gltf-utils/gltf-attribute-utils.js +0 -73
  140. package/dist/lib/gltf-utils/gltf-constants.js +0 -43
  141. package/dist/lib/gltf-utils/gltf-utils.js +0 -90
  142. package/dist/lib/gltf-utils/resolve-url.js +0 -18
  143. package/dist/lib/parsers/parse-glb.js +0 -166
  144. package/dist/lib/parsers/parse-gltf.js +0 -179
  145. package/dist/lib/types/glb-types.js +0 -2
  146. package/dist/lib/types/gltf-json-schema.js +0 -4
  147. package/dist/lib/types/gltf-postprocessed-schema.js +0 -4
  148. package/dist/lib/types/gltf-types.js +0 -3
  149. package/dist/lib/utils/assert.js +0 -12
  150. package/dist/lib/utils/version.js +0 -7
  151. package/dist/meshopt/meshopt-decoder.js +0 -118
  152. package/dist/webp/webp.js +0 -38
@@ -1,299 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.normalizeGLTFV1 = void 0;
27
- /* eslint-disable camelcase */
28
- const KHR_binary_glTF = __importStar(require("../extensions/KHR_binary_gltf"));
29
- // Binary format changes (mainly implemented by GLBLoader)
30
- // https://github.com/KhronosGroup/glTF/tree/master/extensions/1.0/Khronos/KHR_binary_glTF
31
- // JSON format changes:
32
- // https://github.com/khronosgroup/gltf/issues/605
33
- // - [x] Top-level JSON objects are arrays now
34
- // - [ ] Removed indirection from animation: sampler now refers directly to accessors, #712
35
- // - [ ] material.parameter.value and technique.parameter.value must be an array, #690
36
- // - [ ] Node can have only one mesh #821
37
- // - [ ] Added reqs on JSON encoding
38
- // - [ ] Added reqs on binary data alignment #802 (comment)
39
- // Additions:
40
- // - [ ] Added accessor.normalized, #691, #706
41
- // - [ ] Added glExtensionsUsed property and 5125 (UNSIGNED_INT) accessor.componentType value, #619
42
- // - [ ] Added extensionsRequired property, #720, #721
43
- // - [ ] Added "STEP" as valid animation.sampler.interpolation value, #712
44
- // Removals:
45
- // - [x] Removed buffer.type, #786, #629
46
- // - [ ] Removed revision number from profile.version, #709
47
- // - [ ] Removed technique.functions.scissor and removed 3089 (SCISSOR_TEST) as a valid value for technique.states.enable, #681
48
- // - [ ] Techniques, programs, and shaders were moved out to KHR_technique_webgl extension.
49
- // Other edits:
50
- // - [x] asset is now required, #642
51
- // - [ ] buffer.byteLength and bufferView.byteLength are now required, #560.
52
- // - [ ] accessor.min and accessor.max are now required, #593, and clarified that the JSON value and binary data must be the same, #628.
53
- // - [ ] Clarified animation.sampler and animation.channel restrictions, #712
54
- // - [ ] skin.inverseBindMatrices is now optional, #461.
55
- // - [ ] Attribute parameters can't have a value defined in the technique or parameter, #563 (comment).
56
- // - [ ] Only TEXCOORD and COLOR attribute semantics can be written in the form [semantic]_[set_index], #563 (comment).
57
- // - [ ] 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
58
- // - [ ] camera.perspective.aspectRatio and camera.perspective.yfov must now be > 0, not >= 0, #563 (comment).
59
- // - [ ] Application-specific parameter semantics must start with an underscore, e.g., _TEMPERATURE and _SIMULATION_TIME, #563 (comment).
60
- // - [ ] Properties in technique.parameters must be defined in technique.uniforms or technique.attributes,
61
- // #563 (comment).
62
- // - [ ] 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
63
- // - [ ] technique.parameter.semantic is required when the parameter is an attribute, 28e113d
64
- // - [ ] Mesh-only models are allowed, e.g., without materials, #642
65
- // - [ ] Skeleton hierarchies (nodes containing jointName) must be separated from non-skeleton hierarchies., #647
66
- // - [ ] technique.states.functions.blendColor and technique.states.functions.depthRange parameters now must match WebGL function min/max, #707
67
- const GLTF_ARRAYS = {
68
- accessors: 'accessor',
69
- animations: 'animation',
70
- buffers: 'buffer',
71
- bufferViews: 'bufferView',
72
- images: 'image',
73
- materials: 'material',
74
- meshes: 'mesh',
75
- nodes: 'node',
76
- samplers: 'sampler',
77
- scenes: 'scene',
78
- skins: 'skin',
79
- textures: 'texture'
80
- };
81
- const GLTF_KEYS = {
82
- accessor: 'accessors',
83
- animations: 'animation',
84
- buffer: 'buffers',
85
- bufferView: 'bufferViews',
86
- image: 'images',
87
- material: 'materials',
88
- mesh: 'meshes',
89
- node: 'nodes',
90
- sampler: 'samplers',
91
- scene: 'scenes',
92
- skin: 'skins',
93
- texture: 'textures'
94
- };
95
- /**
96
- * Converts (normalizes) glTF v1 to v2
97
- */
98
- class GLTFV1Normalizer {
99
- constructor() {
100
- this.idToIndexMap = {
101
- animations: {},
102
- accessors: {},
103
- buffers: {},
104
- bufferViews: {},
105
- images: {},
106
- materials: {},
107
- meshes: {},
108
- nodes: {},
109
- samplers: {},
110
- scenes: {},
111
- skins: {},
112
- textures: {}
113
- };
114
- }
115
- // constructor() {}
116
- /**
117
- * Convert (normalize) glTF < 2.0 to glTF 2.0
118
- * @param gltf - object with json and binChunks
119
- * @param options
120
- * @param options normalize Whether to actually normalize
121
- */
122
- normalize(gltf, options) {
123
- this.json = gltf.json;
124
- const json = gltf.json;
125
- // Check version
126
- switch (json.asset && json.asset.version) {
127
- // We are converting to v2 format. Return if there is nothing to do
128
- case '2.0':
129
- return;
130
- // This class is written to convert 1.0
131
- case undefined:
132
- case '1.0':
133
- break;
134
- default:
135
- // eslint-disable-next-line no-undef, no-console
136
- console.warn(`glTF: Unknown version ${json.asset.version}`);
137
- return;
138
- }
139
- if (!options.normalize) {
140
- // We are still missing a few conversion tricks, remove once addressed
141
- throw new Error('glTF v1 is not supported.');
142
- }
143
- // eslint-disable-next-line no-undef, no-console
144
- console.warn('Converting glTF v1 to glTF v2 format. This is experimental and may fail.');
145
- this._addAsset(json);
146
- // In glTF2 top-level fields are Arrays not Object maps
147
- this._convertTopLevelObjectsToArrays(json);
148
- // Extract bufferView indices for images
149
- // (this extension needs to be invoked early in the normalization process)
150
- // TODO can this be handled by standard extension processing instead of called explicitly?
151
- KHR_binary_glTF.preprocess(gltf);
152
- // Convert object references from ids to indices
153
- this._convertObjectIdsToArrayIndices(json);
154
- this._updateObjects(json);
155
- this._updateMaterial(json);
156
- }
157
- // asset is now required, #642 https://github.com/KhronosGroup/glTF/issues/639
158
- _addAsset(json) {
159
- json.asset = json.asset || {};
160
- // We are normalizing to glTF v2, so change version to "2.0"
161
- json.asset.version = '2.0';
162
- json.asset.generator = json.asset.generator || 'Normalized to glTF 2.0 by loaders.gl';
163
- }
164
- _convertTopLevelObjectsToArrays(json) {
165
- // TODO check that all arrays are covered
166
- for (const arrayName in GLTF_ARRAYS) {
167
- this._convertTopLevelObjectToArray(json, arrayName);
168
- }
169
- }
170
- /** Convert one top level object to array */
171
- _convertTopLevelObjectToArray(json, mapName) {
172
- const objectMap = json[mapName];
173
- if (!objectMap || Array.isArray(objectMap)) {
174
- return;
175
- }
176
- // Rewrite the top-level field as an array
177
- json[mapName] = [];
178
- // Copy the map key into object.id
179
- for (const id in objectMap) {
180
- const object = objectMap[id];
181
- object.id = object.id || id; // Mutates the loaded object
182
- const index = json[mapName].length;
183
- json[mapName].push(object);
184
- this.idToIndexMap[mapName][id] = index;
185
- }
186
- }
187
- /** Go through all objects in all top-level arrays and replace ids with indices */
188
- _convertObjectIdsToArrayIndices(json) {
189
- for (const arrayName in GLTF_ARRAYS) {
190
- this._convertIdsToIndices(json, arrayName);
191
- }
192
- if ('scene' in json) {
193
- json.scene = this._convertIdToIndex(json.scene, 'scene');
194
- }
195
- // Convert any index references that are not using array names
196
- // texture.source (image)
197
- for (const texture of json.textures) {
198
- this._convertTextureIds(texture);
199
- }
200
- for (const mesh of json.meshes) {
201
- this._convertMeshIds(mesh);
202
- }
203
- for (const node of json.nodes) {
204
- this._convertNodeIds(node);
205
- }
206
- for (const node of json.scenes) {
207
- this._convertSceneIds(node);
208
- }
209
- }
210
- _convertTextureIds(texture) {
211
- if (texture.source) {
212
- texture.source = this._convertIdToIndex(texture.source, 'image');
213
- }
214
- }
215
- _convertMeshIds(mesh) {
216
- for (const primitive of mesh.primitives) {
217
- const { attributes, indices, material } = primitive;
218
- for (const attributeName in attributes) {
219
- attributes[attributeName] = this._convertIdToIndex(attributes[attributeName], 'accessor');
220
- }
221
- if (indices) {
222
- primitive.indices = this._convertIdToIndex(indices, 'accessor');
223
- }
224
- if (material) {
225
- primitive.material = this._convertIdToIndex(material, 'material');
226
- }
227
- }
228
- }
229
- _convertNodeIds(node) {
230
- if (node.children) {
231
- node.children = node.children.map((child) => this._convertIdToIndex(child, 'node'));
232
- }
233
- if (node.meshes) {
234
- node.meshes = node.meshes.map((mesh) => this._convertIdToIndex(mesh, 'mesh'));
235
- }
236
- }
237
- _convertSceneIds(scene) {
238
- if (scene.nodes) {
239
- scene.nodes = scene.nodes.map((node) => this._convertIdToIndex(node, 'node'));
240
- }
241
- }
242
- /** Go through all objects in a top-level array and replace ids with indices */
243
- _convertIdsToIndices(json, topLevelArrayName) {
244
- if (!json[topLevelArrayName]) {
245
- console.warn(`gltf v1: json doesn't contain attribute ${topLevelArrayName}`); // eslint-disable-line no-console, no-undef
246
- json[topLevelArrayName] = [];
247
- }
248
- for (const object of json[topLevelArrayName]) {
249
- for (const key in object) {
250
- const id = object[key];
251
- const index = this._convertIdToIndex(id, key);
252
- object[key] = index;
253
- }
254
- }
255
- }
256
- _convertIdToIndex(id, key) {
257
- const arrayName = GLTF_KEYS[key];
258
- if (arrayName in this.idToIndexMap) {
259
- const index = this.idToIndexMap[arrayName][id];
260
- if (!Number.isFinite(index)) {
261
- throw new Error(`gltf v1: failed to resolve ${key} with id ${id}`);
262
- }
263
- return index;
264
- }
265
- return id;
266
- }
267
- /**
268
- *
269
- * @param {*} json
270
- */
271
- _updateObjects(json) {
272
- for (const buffer of this.json.buffers) {
273
- // - [x] Removed buffer.type, #786, #629
274
- delete buffer.type;
275
- }
276
- }
277
- /**
278
- * Update material (set pbrMetallicRoughness)
279
- * @param {*} json
280
- */
281
- _updateMaterial(json) {
282
- for (const material of json.materials) {
283
- material.pbrMetallicRoughness = {
284
- baseColorFactor: [1, 1, 1, 1],
285
- metallicFactor: 1,
286
- roughnessFactor: 1
287
- };
288
- const textureId = material.values?.tex || material.values?.texture2d_0 || material.values?.diffuseTex;
289
- const textureIndex = json.textures.findIndex((texture) => texture.id === textureId);
290
- if (textureIndex !== -1) {
291
- material.pbrMetallicRoughness.baseColorTexture = { index: textureIndex };
292
- }
293
- }
294
- }
295
- }
296
- function normalizeGLTFV1(gltf, options = {}) {
297
- return new GLTFV1Normalizer().normalize(gltf, options);
298
- }
299
- exports.normalizeGLTFV1 = normalizeGLTFV1;