Skip to content

Commit 1cea201

Browse files
authored
feat: define typescript interfaces for gltf accessor sparse property and update environment setup (#5174)
1 parent fae2a75 commit 1cea201

4 files changed

Lines changed: 36 additions & 44 deletions

File tree

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "packages/shared-assets/models/glTF-Sample-Assets"]
22
path = packages/shared-assets/models/glTF-Sample-Assets
3-
url = git@github.com:KhronosGroup/glTF-Sample-Assets
3+
url = https://github.com/KhronosGroup/glTF-Sample-Assets.git

package-lock.json

Lines changed: 10 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
},
4141
"homepage": "https://github.com/google/model-viewer#readme",
4242
"devDependencies": {
43+
"@types/chai": "^4.3.20",
4344
"@typescript-eslint/eslint-plugin": "^8.26.1",
4445
"@typescript-eslint/parser": "^8.26.1",
4546
"clang-format": "^1.8.0",

packages/model-viewer/src/three-components/gltf-instance/gltf-2.0.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,29 @@ export interface Scene {
224224

225225
export type AccessorType = 'SCALAR'|'VEC2'|'VEC3'|'VEC4'|'MAT2'|'MAT3'|'MAT4';
226226

227+
export interface AccessorSparseIndices {
228+
bufferView: number;
229+
byteOffset?: number;
230+
componentType: number;
231+
extensions?: ExtensionDictionary;
232+
extras?: Extras;
233+
}
234+
235+
export interface AccessorSparseValues {
236+
bufferView: number;
237+
byteOffset?: number;
238+
extensions?: ExtensionDictionary;
239+
extras?: Extras;
240+
}
241+
242+
export interface AccessorSparse {
243+
count: number;
244+
indices: AccessorSparseIndices;
245+
values: AccessorSparseValues;
246+
extensions?: ExtensionDictionary;
247+
extras?: Extras;
248+
}
249+
227250
export interface Accessor {
228251
name?: string;
229252
bufferView?: number;
@@ -237,9 +260,8 @@ export interface Accessor {
237260
extensions?: ExtensionDictionary;
238261
extras?: Extras;
239262

240-
// TODO: What is this?
241263
// @see https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#accessorsparse
242-
sparse?: any;
264+
sparse?: AccessorSparse;
243265
}
244266

245267
export type ChannelTargetPath = 'rotation'|'scale'|'translation'|'weights';

0 commit comments

Comments
 (0)