@luma.gl/gltf 9.3.0-alpha.9 → 9.3.0
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.
- package/dist/dist.dev.js +4396 -3081
- package/dist/dist.min.js +33 -14
- package/dist/gltf/animations/animations.d.ts +43 -3
- package/dist/gltf/animations/animations.d.ts.map +1 -1
- package/dist/gltf/animations/interpolate.d.ts +2 -0
- package/dist/gltf/animations/interpolate.d.ts.map +1 -1
- package/dist/gltf/animations/interpolate.js +27 -22
- package/dist/gltf/animations/interpolate.js.map +1 -1
- package/dist/gltf/create-gltf-model.d.ts.map +1 -1
- package/dist/gltf/create-gltf-model.js +29 -10
- package/dist/gltf/create-gltf-model.js.map +1 -1
- package/dist/gltf/create-scenegraph-from-gltf.js +2 -2
- package/dist/gltf/create-scenegraph-from-gltf.js.map +1 -1
- package/dist/gltf/gltf-animator.d.ts +12 -1
- package/dist/gltf/gltf-animator.d.ts.map +1 -1
- package/dist/gltf/gltf-animator.js +98 -6
- package/dist/gltf/gltf-animator.js.map +1 -1
- package/dist/gltf/gltf-extension-support.d.ts +3 -0
- package/dist/gltf/gltf-extension-support.d.ts.map +1 -1
- package/dist/gltf/gltf-extension-support.js +10 -5
- package/dist/gltf/gltf-extension-support.js.map +1 -1
- package/dist/index.cjs +763 -272
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/parsers/parse-gltf-animations.d.ts.map +1 -1
- package/dist/parsers/parse-gltf-animations.js +319 -18
- package/dist/parsers/parse-gltf-animations.js.map +1 -1
- package/dist/parsers/parse-gltf-lights.d.ts +6 -2
- package/dist/parsers/parse-gltf-lights.d.ts.map +1 -1
- package/dist/parsers/parse-gltf-lights.js +9 -6
- package/dist/parsers/parse-gltf-lights.js.map +1 -1
- package/dist/parsers/parse-gltf.d.ts +2 -0
- package/dist/parsers/parse-gltf.d.ts.map +1 -1
- package/dist/parsers/parse-gltf.js +21 -7
- package/dist/parsers/parse-gltf.js.map +1 -1
- package/dist/parsers/parse-pbr-material.d.ts.map +1 -1
- package/dist/parsers/parse-pbr-material.js +114 -81
- package/dist/parsers/parse-pbr-material.js.map +1 -1
- package/dist/pbr/pbr-environment.d.ts.map +1 -1
- package/dist/pbr/pbr-environment.js +7 -3
- package/dist/pbr/pbr-environment.js.map +1 -1
- package/dist/pbr/texture-transform.d.ts +24 -0
- package/dist/pbr/texture-transform.d.ts.map +1 -0
- package/dist/pbr/texture-transform.js +98 -0
- package/dist/pbr/texture-transform.js.map +1 -0
- package/dist/webgl-to-webgpu/convert-webgl-topology.js +1 -1
- package/dist/webgl-to-webgpu/convert-webgl-topology.js.map +1 -1
- package/package.json +5 -5
- package/src/gltf/animations/animations.ts +73 -3
- package/src/gltf/animations/interpolate.ts +50 -43
- package/src/gltf/create-gltf-model.ts +29 -10
- package/src/gltf/create-scenegraph-from-gltf.ts +2 -2
- package/src/gltf/gltf-animator.ts +177 -8
- package/src/gltf/gltf-extension-support.ts +17 -5
- package/src/index.ts +1 -1
- package/src/parsers/parse-gltf-animations.ts +461 -21
- package/src/parsers/parse-gltf-lights.ts +27 -8
- package/src/parsers/parse-gltf.ts +23 -7
- package/src/parsers/parse-pbr-material.ts +184 -79
- package/src/pbr/pbr-environment.ts +10 -3
- package/src/pbr/texture-transform.ts +263 -0
- package/src/webgl-to-webgpu/convert-webgl-topology.ts +1 -1
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {Matrix3} from '@math.gl/core';
|
|
6
|
+
|
|
7
|
+
export type PBRTextureTransformSlot =
|
|
8
|
+
| 'baseColor'
|
|
9
|
+
| 'metallicRoughness'
|
|
10
|
+
| 'normal'
|
|
11
|
+
| 'occlusion'
|
|
12
|
+
| 'emissive'
|
|
13
|
+
| 'specularColor'
|
|
14
|
+
| 'specularIntensity'
|
|
15
|
+
| 'transmission'
|
|
16
|
+
| 'thickness'
|
|
17
|
+
| 'clearcoat'
|
|
18
|
+
| 'clearcoatRoughness'
|
|
19
|
+
| 'clearcoatNormal'
|
|
20
|
+
| 'sheenColor'
|
|
21
|
+
| 'sheenRoughness'
|
|
22
|
+
| 'iridescence'
|
|
23
|
+
| 'iridescenceThickness'
|
|
24
|
+
| 'anisotropy';
|
|
25
|
+
|
|
26
|
+
export type PBRTextureTransformPath = 'offset' | 'rotation' | 'scale';
|
|
27
|
+
|
|
28
|
+
export type PBRTextureTransform = {
|
|
29
|
+
offset: [number, number];
|
|
30
|
+
rotation: number;
|
|
31
|
+
scale: [number, number];
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type PBRTextureTransformSlotDefinition = {
|
|
35
|
+
slot: PBRTextureTransformSlot;
|
|
36
|
+
binding: string;
|
|
37
|
+
displayName: string;
|
|
38
|
+
pathSegments: string[];
|
|
39
|
+
uvSetUniform: string;
|
|
40
|
+
uvTransformUniform: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const IDENTITY_TEXTURE_TRANSFORM: PBRTextureTransform = {
|
|
44
|
+
offset: [0, 0],
|
|
45
|
+
rotation: 0,
|
|
46
|
+
scale: [1, 1]
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const TEXTURE_TRANSFORM_SLOT_DEFINITIONS: PBRTextureTransformSlotDefinition[] = [
|
|
50
|
+
createTextureTransformSlotDefinition('baseColor', 'pbr_baseColorSampler', 'baseColorTexture', [
|
|
51
|
+
'pbrMetallicRoughness',
|
|
52
|
+
'baseColorTexture'
|
|
53
|
+
]),
|
|
54
|
+
createTextureTransformSlotDefinition(
|
|
55
|
+
'metallicRoughness',
|
|
56
|
+
'pbr_metallicRoughnessSampler',
|
|
57
|
+
'metallicRoughnessTexture',
|
|
58
|
+
['pbrMetallicRoughness', 'metallicRoughnessTexture']
|
|
59
|
+
),
|
|
60
|
+
createTextureTransformSlotDefinition('normal', 'pbr_normalSampler', 'normalTexture', [
|
|
61
|
+
'normalTexture'
|
|
62
|
+
]),
|
|
63
|
+
createTextureTransformSlotDefinition('occlusion', 'pbr_occlusionSampler', 'occlusionTexture', [
|
|
64
|
+
'occlusionTexture'
|
|
65
|
+
]),
|
|
66
|
+
createTextureTransformSlotDefinition('emissive', 'pbr_emissiveSampler', 'emissiveTexture', [
|
|
67
|
+
'emissiveTexture'
|
|
68
|
+
]),
|
|
69
|
+
createTextureTransformSlotDefinition(
|
|
70
|
+
'specularColor',
|
|
71
|
+
'pbr_specularColorSampler',
|
|
72
|
+
'KHR_materials_specular.specularColorTexture',
|
|
73
|
+
['extensions', 'KHR_materials_specular', 'specularColorTexture']
|
|
74
|
+
),
|
|
75
|
+
createTextureTransformSlotDefinition(
|
|
76
|
+
'specularIntensity',
|
|
77
|
+
'pbr_specularIntensitySampler',
|
|
78
|
+
'KHR_materials_specular.specularTexture',
|
|
79
|
+
['extensions', 'KHR_materials_specular', 'specularTexture']
|
|
80
|
+
),
|
|
81
|
+
createTextureTransformSlotDefinition(
|
|
82
|
+
'transmission',
|
|
83
|
+
'pbr_transmissionSampler',
|
|
84
|
+
'KHR_materials_transmission.transmissionTexture',
|
|
85
|
+
['extensions', 'KHR_materials_transmission', 'transmissionTexture']
|
|
86
|
+
),
|
|
87
|
+
createTextureTransformSlotDefinition(
|
|
88
|
+
'thickness',
|
|
89
|
+
'pbr_thicknessSampler',
|
|
90
|
+
'KHR_materials_volume.thicknessTexture',
|
|
91
|
+
['extensions', 'KHR_materials_volume', 'thicknessTexture']
|
|
92
|
+
),
|
|
93
|
+
createTextureTransformSlotDefinition(
|
|
94
|
+
'clearcoat',
|
|
95
|
+
'pbr_clearcoatSampler',
|
|
96
|
+
'KHR_materials_clearcoat.clearcoatTexture',
|
|
97
|
+
['extensions', 'KHR_materials_clearcoat', 'clearcoatTexture']
|
|
98
|
+
),
|
|
99
|
+
createTextureTransformSlotDefinition(
|
|
100
|
+
'clearcoatRoughness',
|
|
101
|
+
'pbr_clearcoatRoughnessSampler',
|
|
102
|
+
'KHR_materials_clearcoat.clearcoatRoughnessTexture',
|
|
103
|
+
['extensions', 'KHR_materials_clearcoat', 'clearcoatRoughnessTexture']
|
|
104
|
+
),
|
|
105
|
+
createTextureTransformSlotDefinition(
|
|
106
|
+
'clearcoatNormal',
|
|
107
|
+
'pbr_clearcoatNormalSampler',
|
|
108
|
+
'KHR_materials_clearcoat.clearcoatNormalTexture',
|
|
109
|
+
['extensions', 'KHR_materials_clearcoat', 'clearcoatNormalTexture']
|
|
110
|
+
),
|
|
111
|
+
createTextureTransformSlotDefinition(
|
|
112
|
+
'sheenColor',
|
|
113
|
+
'pbr_sheenColorSampler',
|
|
114
|
+
'KHR_materials_sheen.sheenColorTexture',
|
|
115
|
+
['extensions', 'KHR_materials_sheen', 'sheenColorTexture']
|
|
116
|
+
),
|
|
117
|
+
createTextureTransformSlotDefinition(
|
|
118
|
+
'sheenRoughness',
|
|
119
|
+
'pbr_sheenRoughnessSampler',
|
|
120
|
+
'KHR_materials_sheen.sheenRoughnessTexture',
|
|
121
|
+
['extensions', 'KHR_materials_sheen', 'sheenRoughnessTexture']
|
|
122
|
+
),
|
|
123
|
+
createTextureTransformSlotDefinition(
|
|
124
|
+
'iridescence',
|
|
125
|
+
'pbr_iridescenceSampler',
|
|
126
|
+
'KHR_materials_iridescence.iridescenceTexture',
|
|
127
|
+
['extensions', 'KHR_materials_iridescence', 'iridescenceTexture']
|
|
128
|
+
),
|
|
129
|
+
createTextureTransformSlotDefinition(
|
|
130
|
+
'iridescenceThickness',
|
|
131
|
+
'pbr_iridescenceThicknessSampler',
|
|
132
|
+
'KHR_materials_iridescence.iridescenceThicknessTexture',
|
|
133
|
+
['extensions', 'KHR_materials_iridescence', 'iridescenceThicknessTexture']
|
|
134
|
+
),
|
|
135
|
+
createTextureTransformSlotDefinition(
|
|
136
|
+
'anisotropy',
|
|
137
|
+
'pbr_anisotropySampler',
|
|
138
|
+
'KHR_materials_anisotropy.anisotropyTexture',
|
|
139
|
+
['extensions', 'KHR_materials_anisotropy', 'anisotropyTexture']
|
|
140
|
+
)
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
const TEXTURE_TRANSFORM_SLOT_DEFINITION_MAP = new Map(
|
|
144
|
+
TEXTURE_TRANSFORM_SLOT_DEFINITIONS.map(definition => [definition.slot, definition])
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
function createTextureTransformSlotDefinition(
|
|
148
|
+
slot: PBRTextureTransformSlot,
|
|
149
|
+
binding: string,
|
|
150
|
+
displayName: string,
|
|
151
|
+
pathSegments: string[]
|
|
152
|
+
): PBRTextureTransformSlotDefinition {
|
|
153
|
+
return {
|
|
154
|
+
slot,
|
|
155
|
+
binding,
|
|
156
|
+
displayName,
|
|
157
|
+
pathSegments,
|
|
158
|
+
uvSetUniform: `${slot}UVSet`,
|
|
159
|
+
uvTransformUniform: `${slot}UVTransform`
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function getTextureTransformSlotDefinitions(): PBRTextureTransformSlotDefinition[] {
|
|
164
|
+
return TEXTURE_TRANSFORM_SLOT_DEFINITIONS;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function getTextureTransformSlotDefinition(
|
|
168
|
+
slot: PBRTextureTransformSlot
|
|
169
|
+
): PBRTextureTransformSlotDefinition {
|
|
170
|
+
const definition = TEXTURE_TRANSFORM_SLOT_DEFINITION_MAP.get(slot);
|
|
171
|
+
if (!definition) {
|
|
172
|
+
throw new Error(`Unknown PBR texture transform slot ${slot}`);
|
|
173
|
+
}
|
|
174
|
+
return definition;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export function getDefaultTextureTransform(): PBRTextureTransform {
|
|
178
|
+
return {
|
|
179
|
+
offset: [...IDENTITY_TEXTURE_TRANSFORM.offset] as [number, number],
|
|
180
|
+
rotation: IDENTITY_TEXTURE_TRANSFORM.rotation,
|
|
181
|
+
scale: [...IDENTITY_TEXTURE_TRANSFORM.scale] as [number, number]
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export function resolveTextureTransform(
|
|
186
|
+
textureInfo: Record<string, any> | undefined
|
|
187
|
+
): PBRTextureTransform {
|
|
188
|
+
const extensionTextureTransform = textureInfo?.['extensions']?.['KHR_texture_transform'];
|
|
189
|
+
return {
|
|
190
|
+
offset: extensionTextureTransform?.offset
|
|
191
|
+
? [extensionTextureTransform.offset[0], extensionTextureTransform.offset[1]]
|
|
192
|
+
: [0, 0],
|
|
193
|
+
rotation: extensionTextureTransform?.rotation ?? 0,
|
|
194
|
+
scale: extensionTextureTransform?.scale
|
|
195
|
+
? [extensionTextureTransform.scale[0], extensionTextureTransform.scale[1]]
|
|
196
|
+
: [1, 1]
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export function resolveTextureCoordinateSet(textureInfo: Record<string, any> | undefined): number {
|
|
201
|
+
const extensionTextureTransform = textureInfo?.['extensions']?.['KHR_texture_transform'];
|
|
202
|
+
return extensionTextureTransform?.['texCoord'] ?? textureInfo?.['texCoord'] ?? 0;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function resolveTextureTransformSlot(
|
|
206
|
+
pointerSegments: string[]
|
|
207
|
+
): PBRTextureTransformSlotDefinition | null {
|
|
208
|
+
return (
|
|
209
|
+
TEXTURE_TRANSFORM_SLOT_DEFINITIONS.find(
|
|
210
|
+
definition =>
|
|
211
|
+
definition.pathSegments.length === pointerSegments.length &&
|
|
212
|
+
definition.pathSegments.every((segment, index) => pointerSegments[index] === segment)
|
|
213
|
+
) || null
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export function getTextureTransformMatrix(transform: PBRTextureTransform): number[] {
|
|
218
|
+
const translationMatrix = new Matrix3().set(
|
|
219
|
+
1,
|
|
220
|
+
0,
|
|
221
|
+
0,
|
|
222
|
+
0,
|
|
223
|
+
1,
|
|
224
|
+
0,
|
|
225
|
+
transform.offset[0],
|
|
226
|
+
transform.offset[1],
|
|
227
|
+
1
|
|
228
|
+
);
|
|
229
|
+
const rotationMatrix = new Matrix3().set(
|
|
230
|
+
Math.cos(transform.rotation),
|
|
231
|
+
Math.sin(transform.rotation),
|
|
232
|
+
0,
|
|
233
|
+
-Math.sin(transform.rotation),
|
|
234
|
+
Math.cos(transform.rotation),
|
|
235
|
+
0,
|
|
236
|
+
0,
|
|
237
|
+
0,
|
|
238
|
+
1
|
|
239
|
+
);
|
|
240
|
+
const scaleMatrix = new Matrix3().set(
|
|
241
|
+
transform.scale[0],
|
|
242
|
+
0,
|
|
243
|
+
0,
|
|
244
|
+
0,
|
|
245
|
+
transform.scale[1],
|
|
246
|
+
0,
|
|
247
|
+
0,
|
|
248
|
+
0,
|
|
249
|
+
1
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
return Array.from(translationMatrix.multiplyRight(rotationMatrix).multiplyRight(scaleMatrix));
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export function getTextureTransformDeltaMatrix(
|
|
256
|
+
baseTransform: PBRTextureTransform,
|
|
257
|
+
currentTransform: PBRTextureTransform
|
|
258
|
+
): number[] {
|
|
259
|
+
const baseMatrix = new Matrix3(getTextureTransformMatrix(baseTransform));
|
|
260
|
+
const currentMatrix = new Matrix3(getTextureTransformMatrix(currentTransform));
|
|
261
|
+
const inverseBaseMatrix = new Matrix3(baseMatrix).invert();
|
|
262
|
+
return Array.from(currentMatrix.multiplyRight(inverseBaseMatrix));
|
|
263
|
+
}
|
|
@@ -16,7 +16,7 @@ export function convertGLDrawModeToTopology(
|
|
|
16
16
|
| GLEnum.TRIANGLE_STRIP
|
|
17
17
|
| GLEnum.TRIANGLE_FAN
|
|
18
18
|
): PrimitiveTopology {
|
|
19
|
-
//
|
|
19
|
+
// biome-ignore format: preserve layout
|
|
20
20
|
switch (drawMode) {
|
|
21
21
|
case GLEnum.POINTS: return 'point-list';
|
|
22
22
|
case GLEnum.LINES: return 'line-list';
|