@loaders.gl/gltf 3.2.5 → 3.3.0-alpha.1

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 (33) hide show
  1. package/dist/dist.min.js +1402 -36
  2. package/dist/es5/lib/api/gltf-extensions.js +3 -1
  3. package/dist/es5/lib/api/gltf-extensions.js.map +1 -1
  4. package/dist/es5/lib/extensions/KHR_texture_transform.js +293 -0
  5. package/dist/es5/lib/extensions/KHR_texture_transform.js.map +1 -0
  6. package/dist/es5/lib/gltf-utils/gltf-constants.js +3 -0
  7. package/dist/es5/lib/gltf-utils/gltf-constants.js.map +1 -1
  8. package/dist/es5/lib/utils/version.js +1 -1
  9. package/dist/es5/lib/utils/version.js.map +1 -1
  10. package/dist/esm/lib/api/gltf-extensions.js +2 -1
  11. package/dist/esm/lib/api/gltf-extensions.js.map +1 -1
  12. package/dist/esm/lib/extensions/KHR_texture_transform.js +218 -0
  13. package/dist/esm/lib/extensions/KHR_texture_transform.js.map +1 -0
  14. package/dist/esm/lib/gltf-utils/gltf-constants.js +2 -2
  15. package/dist/esm/lib/gltf-utils/gltf-constants.js.map +1 -1
  16. package/dist/esm/lib/utils/version.js +1 -1
  17. package/dist/esm/lib/utils/version.js.map +1 -1
  18. package/dist/lib/api/gltf-extensions.d.ts +5 -0
  19. package/dist/lib/api/gltf-extensions.d.ts.map +1 -1
  20. package/dist/lib/api/gltf-extensions.js +3 -1
  21. package/dist/lib/extensions/KHR_texture_transform.d.ts +13 -0
  22. package/dist/lib/extensions/KHR_texture_transform.d.ts.map +1 -0
  23. package/dist/lib/extensions/KHR_texture_transform.js +230 -0
  24. package/dist/lib/gltf-utils/gltf-constants.d.ts +17 -0
  25. package/dist/lib/gltf-utils/gltf-constants.d.ts.map +1 -1
  26. package/dist/lib/gltf-utils/gltf-constants.js +5 -5
  27. package/dist/lib/types/gltf-json-schema.d.ts +2 -2
  28. package/dist/lib/types/gltf-json-schema.d.ts.map +1 -1
  29. package/package.json +7 -6
  30. package/src/lib/api/gltf-extensions.ts +11 -2
  31. package/src/lib/extensions/KHR_texture_transform.ts +305 -0
  32. package/src/lib/gltf-utils/gltf-constants.ts +2 -2
  33. package/src/lib/types/gltf-json-schema.ts +2 -2
@@ -0,0 +1,218 @@
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 GLTFScenegraph from '../api/gltf-scenegraph';
5
+ const EXT_MESHOPT_TRANSFORM = 'KHR_texture_transform';
6
+ export const name = EXT_MESHOPT_TRANSFORM;
7
+ const scratchVector = new Vector3();
8
+ const scratchRotationMatrix = new Matrix3();
9
+ const scratchScaleMatrix = new Matrix3();
10
+ export async function decode(gltfData, options) {
11
+ const gltfScenegraph = new GLTFScenegraph(gltfData);
12
+ const extension = gltfScenegraph.getExtension(EXT_MESHOPT_TRANSFORM);
13
+
14
+ if (!extension) {
15
+ return;
16
+ }
17
+
18
+ const materials = gltfData.json.materials || [];
19
+
20
+ for (let i = 0; i < materials.length; i++) {
21
+ transformTexCoords(i, gltfData);
22
+ }
23
+ }
24
+
25
+ function transformTexCoords(materialIndex, gltfData) {
26
+ var _gltfData$json$materi, _material$pbrMetallic, _material$pbrMetallic2;
27
+
28
+ const processedTexCoords = [];
29
+ const material = (_gltfData$json$materi = gltfData.json.materials) === null || _gltfData$json$materi === void 0 ? void 0 : _gltfData$json$materi[materialIndex];
30
+ const baseColorTexture = material === null || material === void 0 ? void 0 : (_material$pbrMetallic = material.pbrMetallicRoughness) === null || _material$pbrMetallic === void 0 ? void 0 : _material$pbrMetallic.baseColorTexture;
31
+
32
+ if (baseColorTexture) {
33
+ transformPrimitives(gltfData, materialIndex, baseColorTexture, processedTexCoords);
34
+ }
35
+
36
+ const emisiveTexture = material === null || material === void 0 ? void 0 : material.emissiveTexture;
37
+
38
+ if (emisiveTexture) {
39
+ transformPrimitives(gltfData, materialIndex, emisiveTexture, processedTexCoords);
40
+ }
41
+
42
+ const normalTexture = material === null || material === void 0 ? void 0 : material.normalTexture;
43
+
44
+ if (normalTexture) {
45
+ transformPrimitives(gltfData, materialIndex, normalTexture, processedTexCoords);
46
+ }
47
+
48
+ const occlusionTexture = material === null || material === void 0 ? void 0 : material.occlusionTexture;
49
+
50
+ if (occlusionTexture) {
51
+ transformPrimitives(gltfData, materialIndex, occlusionTexture, processedTexCoords);
52
+ }
53
+
54
+ const metallicRoughnessTexture = material === null || material === void 0 ? void 0 : (_material$pbrMetallic2 = material.pbrMetallicRoughness) === null || _material$pbrMetallic2 === void 0 ? void 0 : _material$pbrMetallic2.metallicRoughnessTexture;
55
+
56
+ if (metallicRoughnessTexture) {
57
+ transformPrimitives(gltfData, materialIndex, metallicRoughnessTexture, processedTexCoords);
58
+ }
59
+ }
60
+
61
+ function transformPrimitives(gltfData, materialIndex, texture, processedTexCoords) {
62
+ const transformParameters = getTransformParameters(texture, processedTexCoords);
63
+
64
+ if (!transformParameters) {
65
+ return;
66
+ }
67
+
68
+ const meshes = gltfData.json.meshes || [];
69
+
70
+ for (const mesh of meshes) {
71
+ for (const primitive of mesh.primitives) {
72
+ const material = primitive.material;
73
+
74
+ if (Number.isFinite(material) && materialIndex === material) {
75
+ transformPrimitive(gltfData, primitive, transformParameters);
76
+ }
77
+ }
78
+ }
79
+ }
80
+
81
+ function getTransformParameters(texture, processedTexCoords) {
82
+ var _texture$extensions;
83
+
84
+ const textureInfo = (_texture$extensions = texture.extensions) === null || _texture$extensions === void 0 ? void 0 : _texture$extensions[EXT_MESHOPT_TRANSFORM];
85
+ const {
86
+ texCoord: originalTexCoord = 0
87
+ } = texture;
88
+ const {
89
+ texCoord = originalTexCoord
90
+ } = textureInfo;
91
+ const isProcessed = processedTexCoords.findIndex(([original, newTexCoord]) => original === originalTexCoord && newTexCoord === texCoord) !== -1;
92
+
93
+ if (!isProcessed) {
94
+ const matrix = makeTransformationMatrix(textureInfo);
95
+
96
+ if (originalTexCoord !== texCoord) {
97
+ texture.texCoord = texCoord;
98
+ }
99
+
100
+ processedTexCoords.push([originalTexCoord, texCoord]);
101
+ return {
102
+ originalTexCoord,
103
+ texCoord,
104
+ matrix
105
+ };
106
+ }
107
+
108
+ return null;
109
+ }
110
+
111
+ function transformPrimitive(gltfData, primitive, transformParameters) {
112
+ const {
113
+ originalTexCoord,
114
+ texCoord,
115
+ matrix
116
+ } = transformParameters;
117
+ const texCoordAccessor = primitive.attributes["TEXCOORD_".concat(originalTexCoord)];
118
+
119
+ if (Number.isFinite(texCoordAccessor)) {
120
+ var _gltfData$json$access;
121
+
122
+ const accessor = (_gltfData$json$access = gltfData.json.accessors) === null || _gltfData$json$access === void 0 ? void 0 : _gltfData$json$access[texCoordAccessor];
123
+
124
+ if (accessor && accessor.bufferView) {
125
+ var _gltfData$json$buffer;
126
+
127
+ const bufferView = (_gltfData$json$buffer = gltfData.json.bufferViews) === null || _gltfData$json$buffer === void 0 ? void 0 : _gltfData$json$buffer[accessor.bufferView];
128
+
129
+ if (bufferView) {
130
+ const {
131
+ arrayBuffer,
132
+ byteOffset: bufferByteOffset
133
+ } = gltfData.buffers[bufferView.buffer];
134
+ const byteOffset = (bufferByteOffset || 0) + (accessor.byteOffset || 0) + (bufferView.byteOffset || 0);
135
+ const {
136
+ ArrayType,
137
+ length
138
+ } = getAccessorArrayTypeAndLength(accessor, bufferView);
139
+ const bytes = BYTES[accessor.componentType];
140
+ const components = COMPONENTS[accessor.type];
141
+ const elementAddressScale = bufferView.byteStride || bytes * components;
142
+ const result = new Float32Array(length);
143
+
144
+ for (let i = 0; i < accessor.count; i++) {
145
+ const uv = new ArrayType(arrayBuffer, byteOffset + i * elementAddressScale, 2);
146
+ scratchVector.set(uv[0], uv[1], 1);
147
+ scratchVector.transformByMatrix3(matrix);
148
+ result.set([scratchVector[0], scratchVector[1]], i * components);
149
+ }
150
+
151
+ if (originalTexCoord === texCoord) {
152
+ updateGltf(accessor, bufferView, gltfData.buffers, result);
153
+ } else {
154
+ createAttribute(texCoord, accessor, primitive, gltfData, result);
155
+ }
156
+ }
157
+ }
158
+ }
159
+ }
160
+
161
+ function updateGltf(accessor, bufferView, buffers, newTexCoordArray) {
162
+ accessor.componentType = 5126;
163
+ buffers.push({
164
+ arrayBuffer: newTexCoordArray.buffer,
165
+ byteOffset: 0,
166
+ byteLength: newTexCoordArray.buffer.byteLength
167
+ });
168
+ bufferView.buffer = buffers.length - 1;
169
+ bufferView.byteLength = newTexCoordArray.buffer.byteLength;
170
+ bufferView.byteOffset = 0;
171
+ delete bufferView.byteStride;
172
+ }
173
+
174
+ function createAttribute(newTexCoord, originalAccessor, primitive, gltfData, newTexCoordArray) {
175
+ gltfData.buffers.push({
176
+ arrayBuffer: newTexCoordArray.buffer,
177
+ byteOffset: 0,
178
+ byteLength: newTexCoordArray.buffer.byteLength
179
+ });
180
+ const bufferViews = gltfData.json.bufferViews;
181
+
182
+ if (!bufferViews) {
183
+ return;
184
+ }
185
+
186
+ bufferViews.push({
187
+ buffer: gltfData.buffers.length - 1,
188
+ byteLength: newTexCoordArray.buffer.byteLength,
189
+ byteOffset: 0
190
+ });
191
+ const accessors = gltfData.json.accessors;
192
+
193
+ if (!accessors) {
194
+ return;
195
+ }
196
+
197
+ accessors.push({
198
+ bufferView: (bufferViews === null || bufferViews === void 0 ? void 0 : bufferViews.length) - 1,
199
+ byteOffset: 0,
200
+ componentType: 5126,
201
+ count: originalAccessor.count,
202
+ type: 'VEC2'
203
+ });
204
+ primitive.attributes["TEXCOORD_".concat(newTexCoord)] = accessors.length - 1;
205
+ }
206
+
207
+ function makeTransformationMatrix(extensionData) {
208
+ const {
209
+ offset = [0, 0],
210
+ rotation = 0,
211
+ scale = [1, 1]
212
+ } = extensionData;
213
+ const translationMatirx = new Matrix3().set(1, 0, 0, 0, 1, 0, offset[0], offset[1], 1);
214
+ const rotationMatirx = scratchRotationMatrix.set(Math.cos(rotation), Math.sin(rotation), 0, -Math.sin(rotation), Math.cos(rotation), 0, 0, 0, 1);
215
+ const scaleMatrix = scratchScaleMatrix.set(scale[0], 0, 0, 0, scale[1], 0, 0, 0, 1);
216
+ return translationMatirx.multiplyRight(rotationMatirx).multiplyRight(scaleMatrix);
217
+ }
218
+ //# sourceMappingURL=KHR_texture_transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/lib/extensions/KHR_texture_transform.ts"],"names":["Vector3","Matrix3","getAccessorArrayTypeAndLength","BYTES","COMPONENTS","GLTFScenegraph","EXT_MESHOPT_TRANSFORM","name","scratchVector","scratchRotationMatrix","scratchScaleMatrix","decode","gltfData","options","gltfScenegraph","extension","getExtension","materials","json","i","length","transformTexCoords","materialIndex","processedTexCoords","material","baseColorTexture","pbrMetallicRoughness","transformPrimitives","emisiveTexture","emissiveTexture","normalTexture","occlusionTexture","metallicRoughnessTexture","texture","transformParameters","getTransformParameters","meshes","mesh","primitive","primitives","Number","isFinite","transformPrimitive","textureInfo","extensions","texCoord","originalTexCoord","isProcessed","findIndex","original","newTexCoord","matrix","makeTransformationMatrix","push","texCoordAccessor","attributes","accessor","accessors","bufferView","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","translationMatirx","rotationMatirx","Math","cos","sin","scaleMatrix","multiplyRight"],"mappings":"AAIA,SAAQA,OAAR,EAAiBC,OAAjB,QAA+B,eAA/B;AAGA,SAAQC,6BAAR,QAA4C,0BAA5C;AACA,SAAQC,KAAR,EAAeC,UAAf,QAAgC,8BAAhC;AAQA,OAAOC,cAAP,MAA2B,wBAA3B;AAGA,MAAMC,qBAAqB,GAAG,uBAA9B;AAEA,OAAO,MAAMC,IAAI,GAAGD,qBAAb;AAEP,MAAME,aAAa,GAAG,IAAIR,OAAJ,EAAtB;AACA,MAAMS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AAjC,EAAoCQ,MAAM,CAAC,CAAD,CAA1C,EAA+CA,MAAM,CAAC,CAAD,CAArD,EAA0D,CAA1D,CAA1B;AACA,QAAMI,cAAc,GAAG/E,qBAAqB,CAACmE,GAAtB,CACrBa,IAAI,CAACC,GAAL,CAASL,QAAT,CADqB,EAErBI,IAAI,CAACE,GAAL,CAASN,QAAT,CAFqB,EAGrB,CAHqB,EAIrB,CAACI,IAAI,CAACE,GAAL,CAASN,QAAT,CAJoB,EAKrBI,IAAI,CAACC,GAAL,CAASL,QAAT,CALqB,EAMrB,CANqB,EAOrB,CAPqB,EAQrB,CARqB,EASrB,CATqB,CAAvB;AAWA,QAAMO,WAAW,GAAGlF,kBAAkB,CAACkE,GAAnB,CAAuBU,KAAK,CAAC,CAAD,CAA5B,EAAiC,CAAjC,EAAoC,CAApC,EAAuC,CAAvC,EAA0CA,KAAK,CAAC,CAAD,CAA/C,EAAoD,CAApD,EAAuD,CAAvD,EAA0D,CAA1D,EAA6D,CAA7D,CAApB;AACA,SAAOC,iBAAiB,CAACM,aAAlB,CAAgCL,cAAhC,EAAgDK,aAAhD,CAA8DD,WAA9D,CAAP;AACD","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 {GLTFMeshPrimitive, GLTFWithBuffers} from '../types/gltf-types';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\nimport {getAccessorArrayTypeAndLength} from '../gltf-utils/gltf-utils';\nimport {BYTES, COMPONENTS} from '../gltf-utils/gltf-constants';\nimport {\n Accessor,\n BufferView,\n MaterialNormalTextureInfo,\n MaterialOcclusionTextureInfo,\n TextureInfo as GLTFTextureInfo\n} 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 MaterialNormalTextureInfo &\n MaterialOcclusionTextureInfo;\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 extension = gltfScenegraph.getExtension(EXT_MESHOPT_TRANSFORM);\n if (!extension) {\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: Accessor,\n bufferView: BufferView,\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: Accessor,\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 translationMatirx = new Matrix3().set(1, 0, 0, 0, 1, 0, offset[0], offset[1], 1);\n const rotationMatirx = 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 translationMatirx.multiplyRight(rotationMatirx).multiplyRight(scaleMatrix);\n}\n"],"file":"KHR_texture_transform.js"}
@@ -1,4 +1,4 @@
1
- const COMPONENTS = {
1
+ export const COMPONENTS = {
2
2
  SCALAR: 1,
3
3
  VEC2: 2,
4
4
  VEC3: 3,
@@ -7,7 +7,7 @@ const COMPONENTS = {
7
7
  MAT3: 9,
8
8
  MAT4: 16
9
9
  };
10
- const BYTES = {
10
+ export const BYTES = {
11
11
  5120: 1,
12
12
  5121: 1,
13
13
  5122: 2,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/gltf-utils/gltf-constants.ts"],"names":["COMPONENTS","SCALAR","VEC2","VEC3","VEC4","MAT2","MAT3","MAT4","BYTES","getBytesFromComponentType","componentType","getSizeFromAccessorType","type","getGLEnumFromSamplerParameter","parameter","GL_TEXTURE_MAG_FILTER","GL_TEXTURE_MIN_FILTER","GL_TEXTURE_WRAP_S","GL_TEXTURE_WRAP_T","PARAMETER_MAP","magFilter","minFilter","wrapS","wrapT"],"mappings":"AAAA,MAAMA,UAAU,GAAG;AACjBC,EAAAA,MAAM,EAAE,CADS;AAEjBC,EAAAA,IAAI,EAAE,CAFW;AAGjBC,EAAAA,IAAI,EAAE,CAHW;AAIjBC,EAAAA,IAAI,EAAE,CAJW;AAKjBC,EAAAA,IAAI,EAAE,CALW;AAMjBC,EAAAA,IAAI,EAAE,CANW;AAOjBC,EAAAA,IAAI,EAAE;AAPW,CAAnB;AAUA,MAAMC,KAAK,GAAG;AACZ,QAAM,CADM;AAEZ,QAAM,CAFM;AAGZ,QAAM,CAHM;AAIZ,QAAM,CAJM;AAKZ,QAAM,CALM;AAMZ,QAAM;AANM,CAAd;AAWA,OAAO,SAASC,yBAAT,CAAmCC,aAAnC,EAAkD;AACvD,SAAOF,KAAK,CAACE,aAAD,CAAZ;AACD;AAED,OAAO,SAASC,uBAAT,CAAiCC,IAAjC,EAAuC;AAC5C,SAAOZ,UAAU,CAACY,IAAD,CAAjB;AACD;AAED,OAAO,SAASC,6BAAT,CAAuCC,SAAvC,EAAkD;AACvD,QAAMC,qBAAqB,GAAG,MAA9B;AACA,QAAMC,qBAAqB,GAAG,MAA9B;AACA,QAAMC,iBAAiB,GAAG,MAA1B;AACA,QAAMC,iBAAiB,GAAG,MAA1B;AAEA,QAAMC,aAAa,GAAG;AACpBC,IAAAA,SAAS,EAAEL,qBADS;AAEpBM,IAAAA,SAAS,EAAEL,qBAFS;AAGpBM,IAAAA,KAAK,EAAEL,iBAHa;AAIpBM,IAAAA,KAAK,EAAEL;AAJa,GAAtB;AAOA,SAAOC,aAAa,CAACL,SAAD,CAApB;AACD","sourcesContent":["const COMPONENTS = {\n SCALAR: 1,\n VEC2: 2,\n VEC3: 3,\n VEC4: 4,\n MAT2: 4,\n MAT3: 9,\n MAT4: 16\n};\n\nconst BYTES = {\n 5120: 1, // BYTE\n 5121: 1, // UNSIGNED_BYTE\n 5122: 2, // SHORT\n 5123: 2, // UNSIGNED_SHORT\n 5125: 4, // UNSIGNED_INT\n 5126: 4 // FLOAT\n};\n\n// ENUM LOOKUP\n\nexport function getBytesFromComponentType(componentType) {\n return BYTES[componentType];\n}\n\nexport function getSizeFromAccessorType(type) {\n return COMPONENTS[type];\n}\n\nexport function getGLEnumFromSamplerParameter(parameter) {\n const GL_TEXTURE_MAG_FILTER = 0x2800;\n const GL_TEXTURE_MIN_FILTER = 0x2801;\n const GL_TEXTURE_WRAP_S = 0x2802;\n const GL_TEXTURE_WRAP_T = 0x2803;\n\n const PARAMETER_MAP = {\n magFilter: GL_TEXTURE_MAG_FILTER,\n minFilter: GL_TEXTURE_MIN_FILTER,\n wrapS: GL_TEXTURE_WRAP_S,\n wrapT: GL_TEXTURE_WRAP_T\n };\n\n return PARAMETER_MAP[parameter];\n}\n"],"file":"gltf-constants.js"}
1
+ {"version":3,"sources":["../../../../src/lib/gltf-utils/gltf-constants.ts"],"names":["COMPONENTS","SCALAR","VEC2","VEC3","VEC4","MAT2","MAT3","MAT4","BYTES","getBytesFromComponentType","componentType","getSizeFromAccessorType","type","getGLEnumFromSamplerParameter","parameter","GL_TEXTURE_MAG_FILTER","GL_TEXTURE_MIN_FILTER","GL_TEXTURE_WRAP_S","GL_TEXTURE_WRAP_T","PARAMETER_MAP","magFilter","minFilter","wrapS","wrapT"],"mappings":"AAAA,OAAO,MAAMA,UAAU,GAAG;AACxBC,EAAAA,MAAM,EAAE,CADgB;AAExBC,EAAAA,IAAI,EAAE,CAFkB;AAGxBC,EAAAA,IAAI,EAAE,CAHkB;AAIxBC,EAAAA,IAAI,EAAE,CAJkB;AAKxBC,EAAAA,IAAI,EAAE,CALkB;AAMxBC,EAAAA,IAAI,EAAE,CANkB;AAOxBC,EAAAA,IAAI,EAAE;AAPkB,CAAnB;AAUP,OAAO,MAAMC,KAAK,GAAG;AACnB,QAAM,CADa;AAEnB,QAAM,CAFa;AAGnB,QAAM,CAHa;AAInB,QAAM,CAJa;AAKnB,QAAM,CALa;AAMnB,QAAM;AANa,CAAd;AAWP,OAAO,SAASC,yBAAT,CAAmCC,aAAnC,EAAkD;AACvD,SAAOF,KAAK,CAACE,aAAD,CAAZ;AACD;AAED,OAAO,SAASC,uBAAT,CAAiCC,IAAjC,EAAuC;AAC5C,SAAOZ,UAAU,CAACY,IAAD,CAAjB;AACD;AAED,OAAO,SAASC,6BAAT,CAAuCC,SAAvC,EAAkD;AACvD,QAAMC,qBAAqB,GAAG,MAA9B;AACA,QAAMC,qBAAqB,GAAG,MAA9B;AACA,QAAMC,iBAAiB,GAAG,MAA1B;AACA,QAAMC,iBAAiB,GAAG,MAA1B;AAEA,QAAMC,aAAa,GAAG;AACpBC,IAAAA,SAAS,EAAEL,qBADS;AAEpBM,IAAAA,SAAS,EAAEL,qBAFS;AAGpBM,IAAAA,KAAK,EAAEL,iBAHa;AAIpBM,IAAAA,KAAK,EAAEL;AAJa,GAAtB;AAOA,SAAOC,aAAa,CAACL,SAAD,CAApB;AACD","sourcesContent":["export const COMPONENTS = {\n SCALAR: 1,\n VEC2: 2,\n VEC3: 3,\n VEC4: 4,\n MAT2: 4,\n MAT3: 9,\n MAT4: 16\n};\n\nexport const BYTES = {\n 5120: 1, // BYTE\n 5121: 1, // UNSIGNED_BYTE\n 5122: 2, // SHORT\n 5123: 2, // UNSIGNED_SHORT\n 5125: 4, // UNSIGNED_INT\n 5126: 4 // FLOAT\n};\n\n// ENUM LOOKUP\n\nexport function getBytesFromComponentType(componentType) {\n return BYTES[componentType];\n}\n\nexport function getSizeFromAccessorType(type) {\n return COMPONENTS[type];\n}\n\nexport function getGLEnumFromSamplerParameter(parameter) {\n const GL_TEXTURE_MAG_FILTER = 0x2800;\n const GL_TEXTURE_MIN_FILTER = 0x2801;\n const GL_TEXTURE_WRAP_S = 0x2802;\n const GL_TEXTURE_WRAP_T = 0x2803;\n\n const PARAMETER_MAP = {\n magFilter: GL_TEXTURE_MAG_FILTER,\n minFilter: GL_TEXTURE_MIN_FILTER,\n wrapS: GL_TEXTURE_WRAP_S,\n wrapT: GL_TEXTURE_WRAP_T\n };\n\n return PARAMETER_MAP[parameter];\n}\n"],"file":"gltf-constants.js"}
@@ -1,2 +1,2 @@
1
- export const VERSION = typeof "3.2.5" !== 'undefined' ? "3.2.5" : 'latest';
1
+ export const VERSION = typeof "3.3.0-alpha.1" !== 'undefined' ? "3.3.0-alpha.1" : 'latest';
2
2
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/utils/version.ts"],"names":["VERSION"],"mappings":"AAGA,OAAO,MAAMA,OAAO,GAAG,mBAAuB,WAAvB,aAAmD,QAAnE","sourcesContent":["// Version constant cannot be imported, it needs to correspond to the build version of **this** module.\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nexport const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n"],"file":"version.js"}
1
+ {"version":3,"sources":["../../../../src/lib/utils/version.ts"],"names":["VERSION"],"mappings":"AAGA,OAAO,MAAMA,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE","sourcesContent":["// Version constant cannot be imported, it needs to correspond to the build version of **this** module.\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nexport const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n"],"file":"version.js"}
@@ -7,6 +7,11 @@ declare type GLTFExtensionPlugin = {
7
7
  }, options: GLTFLoaderOptions, context: any) => void;
8
8
  decode?: (gltfData: {
9
9
  json: GLTF;
10
+ buffers: {
11
+ arrayBuffer: ArrayBuffer;
12
+ byteOffset: number;
13
+ byteLength: number;
14
+ }[];
10
15
  }, options: GLTFLoaderOptions, context: any) => Promise<void>;
11
16
  encode?: (gltfData: {
12
17
  json: GLTF;
@@ -1 +1 @@
1
- {"version":3,"file":"gltf-extensions.d.ts","sourceRoot":"","sources":["../../../src/lib/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,IAAI,EAAE,IAAI,CAAA;KAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,KAAA,KAAK,IAAI,CAAC;IACnF,MAAM,CAAC,EAAE,CACP,QAAQ,EAAE;QACR,IAAI,EAAE,IAAI,CAAC;QACX,OAAO,EAAE;YAAC,WAAW,EAAE,WAAW,CAAC;YAAC,UAAU,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAA;SAAC,EAAE,CAAC;KAC/E,EACD,OAAO,EAAE,iBAAiB,EAC1B,OAAO,KAAA,KACJ,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE;QAAC,IAAI,EAAE,IAAI,CAAA;KAAC,EAAE,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAC;CACvE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,mBAAmB,EAe3C,CAAC;AAEF,8CAA8C;AAC9C,wBAAgB,oBAAoB,CAAC,IAAI,KAAA,EAAE,OAAO,GAAE,iBAAsB,EAAE,OAAO,CAAC,KAAA,QAKnF;AAED,kCAAkC;AAClC,wBAAsB,gBAAgB,CAAC,IAAI,KAAA,EAAE,OAAO,GAAE,iBAAsB,EAAE,OAAO,CAAC,KAAA,iBAOrF"}
@@ -27,6 +27,7 @@ const EXT_meshopt_compression = __importStar(require("../extensions/EXT_meshopt_
27
27
  const EXT_texture_webp = __importStar(require("../extensions/EXT_texture_webp"));
28
28
  const KHR_texture_basisu = __importStar(require("../extensions/KHR_texture_basisu"));
29
29
  const KHR_draco_mesh_compression = __importStar(require("../extensions/KHR_draco_mesh_compression"));
30
+ const KHR_texture_transform = __importStar(require("../extensions/KHR_texture_transform"));
30
31
  // Deprecated. These should be handled by rendering library (e.g. luma.gl), not the loader.
31
32
  const KHR_lights_punctual = __importStar(require("../extensions/deprecated/KHR_lights_punctual"));
32
33
  const KHR_materials_unlit = __importStar(require("../extensions/deprecated/KHR_materials_unlit"));
@@ -48,7 +49,8 @@ exports.EXTENSIONS = [
48
49
  KHR_draco_mesh_compression,
49
50
  KHR_lights_punctual,
50
51
  KHR_materials_unlit,
51
- KHR_techniques_webgl
52
+ KHR_techniques_webgl,
53
+ KHR_texture_transform
52
54
  ];
53
55
  /** Call before any resource loading starts */
54
56
  function preprocessExtensions(gltf, options = {}, context) {
@@ -0,0 +1,13 @@
1
+ /**
2
+ * https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_transform/README.md
3
+ */
4
+ import type { GLTFWithBuffers } from '../types/gltf-types';
5
+ import type { GLTFLoaderOptions } from '../../gltf-loader';
6
+ export declare const name = "KHR_texture_transform";
7
+ /**
8
+ * The extension entry to process the transformation
9
+ * @param gltfData gltf buffers and json
10
+ * @param options GLTFLoader options
11
+ */
12
+ export declare function decode(gltfData: GLTFWithBuffers, options: GLTFLoaderOptions): Promise<void>;
13
+ //# sourceMappingURL=KHR_texture_transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KHR_texture_transform.d.ts","sourceRoot":"","sources":["../../../src/lib/extensions/KHR_texture_transform.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAoB,eAAe,EAAC,MAAM,qBAAqB,CAAC;AAC5E,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AAezD,eAAO,MAAM,IAAI,0BAAwB,CAAC;AA+B1C;;;;GAIG;AACH,wBAAsB,MAAM,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,iBAAiB,iBAUjF"}
@@ -0,0 +1,230 @@
1
+ "use strict";
2
+ /**
3
+ * https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_transform/README.md
4
+ */
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.decode = exports.name = void 0;
10
+ const core_1 = require("@math.gl/core");
11
+ const gltf_utils_1 = require("../gltf-utils/gltf-utils");
12
+ const gltf_constants_1 = require("../gltf-utils/gltf-constants");
13
+ const gltf_scenegraph_1 = __importDefault(require("../api/gltf-scenegraph"));
14
+ /** Extension name */
15
+ const EXT_MESHOPT_TRANSFORM = 'KHR_texture_transform';
16
+ exports.name = EXT_MESHOPT_TRANSFORM;
17
+ const scratchVector = new core_1.Vector3();
18
+ const scratchRotationMatrix = new core_1.Matrix3();
19
+ const scratchScaleMatrix = new core_1.Matrix3();
20
+ /**
21
+ * The extension entry to process the transformation
22
+ * @param gltfData gltf buffers and json
23
+ * @param options GLTFLoader options
24
+ */
25
+ async function decode(gltfData, options) {
26
+ const gltfScenegraph = new gltf_scenegraph_1.default(gltfData);
27
+ const extension = gltfScenegraph.getExtension(EXT_MESHOPT_TRANSFORM);
28
+ if (!extension) {
29
+ return;
30
+ }
31
+ const materials = gltfData.json.materials || [];
32
+ for (let i = 0; i < materials.length; i++) {
33
+ transformTexCoords(i, gltfData);
34
+ }
35
+ }
36
+ exports.decode = decode;
37
+ /**
38
+ * Transform TEXCOORD by material
39
+ * @param materialIndex processing material index
40
+ * @param gltfData gltf buffers and json
41
+ */
42
+ function transformTexCoords(materialIndex, gltfData) {
43
+ // Save processed texCoords in order no to process the same twice
44
+ const processedTexCoords = [];
45
+ const material = gltfData.json.materials?.[materialIndex];
46
+ const baseColorTexture = material?.pbrMetallicRoughness?.baseColorTexture;
47
+ if (baseColorTexture) {
48
+ transformPrimitives(gltfData, materialIndex, baseColorTexture, processedTexCoords);
49
+ }
50
+ const emisiveTexture = material?.emissiveTexture;
51
+ if (emisiveTexture) {
52
+ transformPrimitives(gltfData, materialIndex, emisiveTexture, processedTexCoords);
53
+ }
54
+ const normalTexture = material?.normalTexture;
55
+ if (normalTexture) {
56
+ transformPrimitives(gltfData, materialIndex, normalTexture, processedTexCoords);
57
+ }
58
+ const occlusionTexture = material?.occlusionTexture;
59
+ if (occlusionTexture) {
60
+ transformPrimitives(gltfData, materialIndex, occlusionTexture, processedTexCoords);
61
+ }
62
+ const metallicRoughnessTexture = material?.pbrMetallicRoughness?.metallicRoughnessTexture;
63
+ if (metallicRoughnessTexture) {
64
+ transformPrimitives(gltfData, materialIndex, metallicRoughnessTexture, processedTexCoords);
65
+ }
66
+ }
67
+ /**
68
+ * Transform primitives of the particular material
69
+ * @param gltfData gltf data
70
+ * @param materialIndex primitives with this material will be transformed
71
+ * @param texture texture object
72
+ * @param processedTexCoords storage to save already processed texCoords
73
+ */
74
+ function transformPrimitives(gltfData, materialIndex, texture, processedTexCoords) {
75
+ const transformParameters = getTransformParameters(texture, processedTexCoords);
76
+ if (!transformParameters) {
77
+ return;
78
+ }
79
+ const meshes = gltfData.json.meshes || [];
80
+ for (const mesh of meshes) {
81
+ for (const primitive of mesh.primitives) {
82
+ const material = primitive.material;
83
+ if (Number.isFinite(material) && materialIndex === material) {
84
+ transformPrimitive(gltfData, primitive, transformParameters);
85
+ }
86
+ }
87
+ }
88
+ }
89
+ /**
90
+ * Get parameters for TEXCOORD transformation
91
+ * @param texture texture object
92
+ * @param processedTexCoords storage to save already processed texCoords
93
+ * @returns texCoord couple and transformation matrix
94
+ */
95
+ function getTransformParameters(texture, processedTexCoords) {
96
+ const textureInfo = texture.extensions?.[EXT_MESHOPT_TRANSFORM];
97
+ const { texCoord: originalTexCoord = 0 } = texture;
98
+ // If texCoord is not set in the extension, original attribute data will be replaced
99
+ const { texCoord = originalTexCoord } = textureInfo;
100
+ // Make sure that couple [originalTexCoord, extensionTexCoord] is not processed twice
101
+ const isProcessed = processedTexCoords.findIndex(([original, newTexCoord]) => original === originalTexCoord && newTexCoord === texCoord) !== -1;
102
+ if (!isProcessed) {
103
+ const matrix = makeTransformationMatrix(textureInfo);
104
+ if (originalTexCoord !== texCoord) {
105
+ texture.texCoord = texCoord;
106
+ }
107
+ processedTexCoords.push([originalTexCoord, texCoord]);
108
+ return { originalTexCoord, texCoord, matrix };
109
+ }
110
+ return null;
111
+ }
112
+ /**
113
+ * Transform `TEXCOORD_0` attribute in the primitive
114
+ * @param gltfData gltf data
115
+ * @param primitive primitive object
116
+ * @param transformParameters texCoord couple and transformation matrix
117
+ */
118
+ function transformPrimitive(gltfData, primitive, transformParameters) {
119
+ const { originalTexCoord, texCoord, matrix } = transformParameters;
120
+ const texCoordAccessor = primitive.attributes[`TEXCOORD_${originalTexCoord}`];
121
+ if (Number.isFinite(texCoordAccessor)) {
122
+ // Get accessor of the `TEXCOORD_0` attribute
123
+ const accessor = gltfData.json.accessors?.[texCoordAccessor];
124
+ if (accessor && accessor.bufferView) {
125
+ // Get `bufferView` of the `accessor`
126
+ const bufferView = gltfData.json.bufferViews?.[accessor.bufferView];
127
+ if (bufferView) {
128
+ // Get `arrayBuffer` the `bufferView` look at
129
+ const { arrayBuffer, byteOffset: bufferByteOffset } = gltfData.buffers[bufferView.buffer];
130
+ // Resulting byteOffset is sum of the buffer, accessor and bufferView byte offsets
131
+ const byteOffset = (bufferByteOffset || 0) + (accessor.byteOffset || 0) + (bufferView.byteOffset || 0);
132
+ // Deduce TypedArray type and its length from `accessor` and `bufferView` data
133
+ const { ArrayType, length } = (0, gltf_utils_1.getAccessorArrayTypeAndLength)(accessor, bufferView);
134
+ // Number of bytes each component occupies
135
+ const bytes = gltf_constants_1.BYTES[accessor.componentType];
136
+ // Number of components. For the `TEXCOORD_0` with `VEC2` type, it must return 2
137
+ const components = gltf_constants_1.COMPONENTS[accessor.type];
138
+ // Multiplier to calculate the address of the `TEXCOORD_0` element in the arrayBuffer
139
+ const elementAddressScale = bufferView.byteStride || bytes * components;
140
+ // Data transform to Float32Array
141
+ const result = new Float32Array(length);
142
+ for (let i = 0; i < accessor.count; i++) {
143
+ // Take [u, v] couple from the arrayBuffer
144
+ const uv = new ArrayType(arrayBuffer, byteOffset + i * elementAddressScale, 2);
145
+ // Set and transform Vector3 per https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_transform#overview
146
+ scratchVector.set(uv[0], uv[1], 1);
147
+ scratchVector.transformByMatrix3(matrix);
148
+ // Save result in Float32Array
149
+ result.set([scratchVector[0], scratchVector[1]], i * components);
150
+ }
151
+ // If texCoord the same, replace gltf structural data
152
+ if (originalTexCoord === texCoord) {
153
+ updateGltf(accessor, bufferView, gltfData.buffers, result);
154
+ }
155
+ else {
156
+ // If texCoord change, create new attribute
157
+ createAttribute(texCoord, accessor, primitive, gltfData, result);
158
+ }
159
+ }
160
+ }
161
+ }
162
+ }
163
+ /**
164
+ * Update GLTF structural objects with new data as we create new `Float32Array` for `TEXCOORD_0`.
165
+ * @param accessor accessor to change
166
+ * @param bufferView bufferView to change
167
+ * @param buffers binary buffers
168
+ * @param newTexcoordArray typed array with data after transformation
169
+ */
170
+ function updateGltf(accessor, bufferView, buffers, newTexCoordArray) {
171
+ accessor.componentType = 5126;
172
+ buffers.push({
173
+ arrayBuffer: newTexCoordArray.buffer,
174
+ byteOffset: 0,
175
+ byteLength: newTexCoordArray.buffer.byteLength
176
+ });
177
+ bufferView.buffer = buffers.length - 1;
178
+ bufferView.byteLength = newTexCoordArray.buffer.byteLength;
179
+ bufferView.byteOffset = 0;
180
+ delete bufferView.byteStride;
181
+ }
182
+ /**
183
+ *
184
+ * @param newTexCoord new `texCoord` value
185
+ * @param originalAccessor original accessor object, that store data before transformation
186
+ * @param primitive primitive object
187
+ * @param gltfData gltf data
188
+ * @param newTexCoordArray typed array with data after transformation
189
+ * @returns
190
+ */
191
+ function createAttribute(newTexCoord, originalAccessor, primitive, gltfData, newTexCoordArray) {
192
+ gltfData.buffers.push({
193
+ arrayBuffer: newTexCoordArray.buffer,
194
+ byteOffset: 0,
195
+ byteLength: newTexCoordArray.buffer.byteLength
196
+ });
197
+ const bufferViews = gltfData.json.bufferViews;
198
+ if (!bufferViews) {
199
+ return;
200
+ }
201
+ bufferViews.push({
202
+ buffer: gltfData.buffers.length - 1,
203
+ byteLength: newTexCoordArray.buffer.byteLength,
204
+ byteOffset: 0
205
+ });
206
+ const accessors = gltfData.json.accessors;
207
+ if (!accessors) {
208
+ return;
209
+ }
210
+ accessors.push({
211
+ bufferView: bufferViews?.length - 1,
212
+ byteOffset: 0,
213
+ componentType: 5126,
214
+ count: originalAccessor.count,
215
+ type: 'VEC2'
216
+ });
217
+ primitive.attributes[`TEXCOORD_${newTexCoord}`] = accessors.length - 1;
218
+ }
219
+ /**
220
+ * Construct transformation matrix from the extension data (transition, rotation, scale)
221
+ * @param extensionData extension data
222
+ * @returns transformation matrix
223
+ */
224
+ function makeTransformationMatrix(extensionData) {
225
+ const { offset = [0, 0], rotation = 0, scale = [1, 1] } = extensionData;
226
+ const translationMatirx = new core_1.Matrix3().set(1, 0, 0, 0, 1, 0, offset[0], offset[1], 1);
227
+ const rotationMatirx = scratchRotationMatrix.set(Math.cos(rotation), Math.sin(rotation), 0, -Math.sin(rotation), Math.cos(rotation), 0, 0, 0, 1);
228
+ const scaleMatrix = scratchScaleMatrix.set(scale[0], 0, 0, 0, scale[1], 0, 0, 0, 1);
229
+ return translationMatirx.multiplyRight(rotationMatirx).multiplyRight(scaleMatrix);
230
+ }
@@ -1,3 +1,20 @@
1
+ export declare const COMPONENTS: {
2
+ SCALAR: number;
3
+ VEC2: number;
4
+ VEC3: number;
5
+ VEC4: number;
6
+ MAT2: number;
7
+ MAT3: number;
8
+ MAT4: number;
9
+ };
10
+ export declare const BYTES: {
11
+ 5120: number;
12
+ 5121: number;
13
+ 5122: number;
14
+ 5123: number;
15
+ 5125: number;
16
+ 5126: number;
17
+ };
1
18
  export declare function getBytesFromComponentType(componentType: any): any;
2
19
  export declare function getSizeFromAccessorType(type: any): any;
3
20
  export declare function getGLEnumFromSamplerParameter(parameter: any): any;
@@ -1 +1 @@
1
- {"version":3,"file":"gltf-constants.d.ts","sourceRoot":"","sources":["../../../src/lib/gltf-utils/gltf-constants.ts"],"names":[],"mappings":"AAqBA,wBAAgB,yBAAyB,CAAC,aAAa,KAAA,OAEtD;AAED,wBAAgB,uBAAuB,CAAC,IAAI,KAAA,OAE3C;AAED,wBAAgB,6BAA6B,CAAC,SAAS,KAAA,OActD"}
1
+ {"version":3,"file":"gltf-constants.d.ts","sourceRoot":"","sources":["../../../src/lib/gltf-utils/gltf-constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;;;;;;;CAQtB,CAAC;AAEF,eAAO,MAAM,KAAK;;;;;;;CAOjB,CAAC;AAIF,wBAAgB,yBAAyB,CAAC,aAAa,KAAA,OAEtD;AAED,wBAAgB,uBAAuB,CAAC,IAAI,KAAA,OAE3C;AAED,wBAAgB,6BAA6B,CAAC,SAAS,KAAA,OActD"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getGLEnumFromSamplerParameter = exports.getSizeFromAccessorType = exports.getBytesFromComponentType = void 0;
4
- const COMPONENTS = {
3
+ exports.getGLEnumFromSamplerParameter = exports.getSizeFromAccessorType = exports.getBytesFromComponentType = exports.BYTES = exports.COMPONENTS = void 0;
4
+ exports.COMPONENTS = {
5
5
  SCALAR: 1,
6
6
  VEC2: 2,
7
7
  VEC3: 3,
@@ -10,7 +10,7 @@ const COMPONENTS = {
10
10
  MAT3: 9,
11
11
  MAT4: 16
12
12
  };
13
- const BYTES = {
13
+ exports.BYTES = {
14
14
  5120: 1,
15
15
  5121: 1,
16
16
  5122: 2,
@@ -20,11 +20,11 @@ const BYTES = {
20
20
  };
21
21
  // ENUM LOOKUP
22
22
  function getBytesFromComponentType(componentType) {
23
- return BYTES[componentType];
23
+ return exports.BYTES[componentType];
24
24
  }
25
25
  exports.getBytesFromComponentType = getBytesFromComponentType;
26
26
  function getSizeFromAccessorType(type) {
27
- return COMPONENTS[type];
27
+ return exports.COMPONENTS[type];
28
28
  }
29
29
  exports.getSizeFromAccessorType = getSizeFromAccessorType;
30
30
  function getGLEnumFromSamplerParameter(parameter) {