diff --git a/Documentation/Contributors/BuildGuide/README.md b/Documentation/Contributors/BuildGuide/README.md index 56fc44d621f7..529152c2b433 100644 --- a/Documentation/Contributors/BuildGuide/README.md +++ b/Documentation/Contributors/BuildGuide/README.md @@ -147,6 +147,7 @@ Here's the full set of scripts and what they do. - `eslint` - Runs [ESLint](http://eslint.org/), a static code analysis tool, on the entire source tree - `prettier` - Formats the code base using [Prettier](https://prettier.io/) - `prettier-check` - Verifies prettier formatting, but does not write the output + - `download-schemas` and `generate-types` in `@cesium/gltf` (run with `-w @cesium/gltf`) - Download the glTF JSON Schemas and generate TypeScript types for glTF JSON from them. See [Generated glTF types](../../../packages/gltf/README.md#generated-gltf-types). - **Testing scripts** -- build and run the unit tests - `test` - Runs all tests with [Karma](http://karma-runner.github.io/0.13/index.html) using the default browser specified in the Karma config file. - `test-all` - Runs all tests with Karma using all browsers installed on the current system diff --git a/Documentation/Contributors/CodingGuide/README.md b/Documentation/Contributors/CodingGuide/README.md index 8ea6b19aabe7..6f69b5a1354b 100644 --- a/Documentation/Contributors/CodingGuide/README.md +++ b/Documentation/Contributors/CodingGuide/README.md @@ -225,6 +225,13 @@ When referencing external documentation and examples — including TypeScript do const x = "hello world"; // good const x = /** @type {string} */ ("hello world"); // bad ``` +7. **Use the generated glTF types for glTF JSON.** `@cesium/gltf` exports types generated from the glTF JSON Schemas, such as `Gltf2`, `Gltf2.Accessor`, and `EXT_structural_metadata.Mesh.Primitive`. Use them for glTF JSON in place of `object` or a hand-written type: + + ```javascript + /** @import { Gltf2 } from "@cesium/gltf"; */ + ``` + + If code reads an extension that has no generated type, add the extension to the generated types. See [Generated glTF types](../../../packages/gltf/README.md#generated-gltf-types). ## Units diff --git a/Specs/Data/Models/glTF-1.0/box-textured-embedded/box-textured-embedded.gltf b/Specs/Data/Models/glTF-1.0/box-textured-embedded/box-textured-embedded.gltf index 35bb72100427..d4f2e2eccdb6 100644 --- a/Specs/Data/Models/glTF-1.0/box-textured-embedded/box-textured-embedded.gltf +++ b/Specs/Data/Models/glTF-1.0/box-textured-embedded/box-textured-embedded.gltf @@ -1 +1 @@ -{"accessors":{"accessor_indices":{"bufferView":"bufferView_1","byteOffset":0,"byteStride":0,"componentType":5123,"count":36,"type":"SCALAR"},"accessor_positions":{"bufferView":"bufferView_0","byteOffset":0,"byteStride":0,"componentType":5126,"count":24,"max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5],"type":"VEC3"},"accessor_normals":{"bufferView":"bufferView_0","byteOffset":288,"byteStride":0,"componentType":5126,"count":24,"max":[1,1,1],"min":[-1,-1,-1],"type":"VEC3"},"accessor_texcoord":{"bufferView":"bufferView_0","byteOffset":576,"byteStride":0,"componentType":5126,"count":24,"max":[6,1],"min":[0,0],"type":"VEC2"}},"animations":{},"asset":{"generator":"collada2gltf@ceec062e3d5793f2f249f53cbd843aee382ad40b","premultipliedAlpha":true,"profile":{"api":"WebGL","version":"1.0.2"},"version":1},"bufferViews":{"bufferView_0":{"buffer":"CesiumTexturedBoxTest","byteLength":768,"byteOffset":0,"target":34962},"bufferView_1":{"buffer":"CesiumTexturedBoxTest","byteLength":72,"byteOffset":768,"target":34963}},"buffers":{"CesiumTexturedBoxTest":{"type":"arraybuffer","byteLength":840,"uri":"data:application/octet-stream;base64,AAAAvwAAAD8AAAA/AAAAPwAAAD8AAAA/AAAAvwAAAD8AAAC/AAAAPwAAAD8AAAC/AAAAPwAAAD8AAAC/AAAAPwAAAD8AAAA/AAAAPwAAAL8AAAC/AAAAPwAAAL8AAAA/AAAAvwAAAD8AAAC/AAAAPwAAAD8AAAC/AAAAvwAAAL8AAAC/AAAAPwAAAL8AAAC/AAAAPwAAAD8AAAA/AAAAvwAAAD8AAAA/AAAAPwAAAL8AAAA/AAAAvwAAAL8AAAA/AAAAvwAAAD8AAAA/AAAAvwAAAD8AAAC/AAAAvwAAAL8AAAA/AAAAvwAAAL8AAAC/AAAAvwAAAL8AAAA/AAAAvwAAAL8AAAC/AAAAPwAAAL8AAAA/AAAAPwAAAL8AAAC/AAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAADAQAAAAAAAAKBAAAAAAAAAwED+/38/AACgQP7/fz8AAIBAAAAAAAAAoEAAAAAAAACAQAAAgD8AAKBAAACAPwAAAEAAAAAAAACAPwAAAAAAAABAAACAPwAAgD8AAIA/AABAQAAAAAAAAIBAAAAAAAAAQEAAAIA/AACAQAAAgD8AAEBAAAAAAAAAAEAAAAAAAABAQAAAgD8AAABAAACAPwAAAAAAAAAAAAAAAP7/fz8AAIA/AAAAAAAAgD/+/38/AAABAAIAAwACAAEABAAFAAYABwAGAAUACAAJAAoACwAKAAkADAANAA4ADwAOAA0AEAARABIAEwASABEAFAAVABYAFwAWABUA"}},"images":{"Image0001":{"name":"Image0001","uri":"data:image/png;base64,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"}},"materials":{"Effect-Texture":{"name":"Texture","technique":"technique0","values":{"diffuse":"texture_Image0001","shininess":256,"specular":[0.2,0.2,0.2,1]}}},"meshes":{"Geometry-mesh002":{"name":"Mesh","primitives":[{"attributes":{"NORMAL":"accessor_normals","POSITION":"accessor_positions","TEXCOORD_0":"accessor_texcoord"},"indices":"accessor_indices","material":"Effect-Texture","mode":4}]}},"nodes":{"rootNode":{"children":[],"meshes":["Geometry-mesh002"],"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}},"programs":{"program_0":{"attributes":["a_normal","a_position","a_texcoord0"],"fragmentShader":"CesiumTexturedBoxTest0FS","vertexShader":"CesiumTexturedBoxTest0VS"}},"samplers":{"sampler_0":{"magFilter":9729,"minFilter":9987,"wrapS":10497,"wrapT":10497}},"scene":"defaultScene","scenes":{"defaultScene":{"nodes":["rootNode"]}},"shaders":{"CesiumTexturedBoxTest0FS":{"type":35632,"uri":"data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0Owp2YXJ5aW5nIHZlYzMgdl9ub3JtYWw7CnZhcnlpbmcgdmVjMiB2X3RleGNvb3JkMDsKdW5pZm9ybSBzYW1wbGVyMkQgdV9kaWZmdXNlOwp1bmlmb3JtIHZlYzQgdV9zcGVjdWxhcjsKdW5pZm9ybSBmbG9hdCB1X3NoaW5pbmVzczsKdm9pZCBtYWluKHZvaWQpIHsKdmVjMyBub3JtYWwgPSBub3JtYWxpemUodl9ub3JtYWwpOwp2ZWM0IGNvbG9yID0gdmVjNCgwLiwgMC4sIDAuLCAwLik7CnZlYzQgZGlmZnVzZSA9IHZlYzQoMC4sIDAuLCAwLiwgMS4pOwp2ZWM0IHNwZWN1bGFyOwpkaWZmdXNlID0gdGV4dHVyZTJEKHVfZGlmZnVzZSwgdl90ZXhjb29yZDApOwpzcGVjdWxhciA9IHVfc3BlY3VsYXI7CmRpZmZ1c2UueHl6ICo9IG1heChkb3Qobm9ybWFsLHZlYzMoMC4sMC4sMS4pKSwgMC4pOwpjb2xvci54eXogKz0gZGlmZnVzZS54eXo7CmNvbG9yID0gdmVjNChjb2xvci5yZ2IgKiBkaWZmdXNlLmEsIGRpZmZ1c2UuYSk7CmdsX0ZyYWdDb2xvciA9IGNvbG9yOwp9Cg=="},"CesiumTexturedBoxTest0VS":{"type":35633,"uri":"data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0OwphdHRyaWJ1dGUgdmVjMyBhX3Bvc2l0aW9uOwphdHRyaWJ1dGUgdmVjMyBhX25vcm1hbDsKdmFyeWluZyB2ZWMzIHZfbm9ybWFsOwp1bmlmb3JtIG1hdDMgdV9ub3JtYWxNYXRyaXg7CnVuaWZvcm0gbWF0NCB1X21vZGVsVmlld01hdHJpeDsKdW5pZm9ybSBtYXQ0IHVfcHJvamVjdGlvbk1hdHJpeDsKYXR0cmlidXRlIHZlYzIgYV90ZXhjb29yZDA7CnZhcnlpbmcgdmVjMiB2X3RleGNvb3JkMDsKdm9pZCBtYWluKHZvaWQpIHsKdmVjNCBwb3MgPSB1X21vZGVsVmlld01hdHJpeCAqIHZlYzQoYV9wb3NpdGlvbiwxLjApOwp2X25vcm1hbCA9IHVfbm9ybWFsTWF0cml4ICogYV9ub3JtYWw7CnZfdGV4Y29vcmQwID0gYV90ZXhjb29yZDA7CmdsX1Bvc2l0aW9uID0gdV9wcm9qZWN0aW9uTWF0cml4ICogcG9zOwp9Cg=="}},"skins":{},"techniques":{"technique0":{"attributes":{"a_normal":"normal","a_position":"position","a_texcoord0":"texcoord0"},"parameters":{"diffuse":{"type":35678},"modelViewMatrix":{"semantic":"MODELVIEW","type":35676},"normal":{"semantic":"NORMAL","type":35665},"normalMatrix":{"semantic":"MODELVIEWINVERSETRANSPOSE","type":35675},"position":{"semantic":"POSITION","type":35665},"projectionMatrix":{"semantic":"PROJECTION","type":35676},"shininess":{"type":5126},"specular":{"type":35666},"texcoord0":{"semantic":"TEXCOORD_0","type":35664}},"program":"program_0","states":{"enable":[2929,2884]},"uniforms":{"u_diffuse":"diffuse","u_modelViewMatrix":"modelViewMatrix","u_normalMatrix":"normalMatrix","u_projectionMatrix":"projectionMatrix","u_shininess":"shininess","u_specular":"specular"}}},"textures":{"texture_Image0001":{"format":6408,"internalFormat":6408,"sampler":"sampler_0","source":"Image0001","target":3553,"type":5121}},"cameras":{},"extensionsUsed":[]} +{"accessors":{"accessor_indices":{"bufferView":"bufferView_1","byteOffset":0,"byteStride":0,"componentType":5123,"count":36,"type":"SCALAR"},"accessor_positions":{"bufferView":"bufferView_0","byteOffset":0,"byteStride":0,"componentType":5126,"count":24,"max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5],"type":"VEC3"},"accessor_normals":{"bufferView":"bufferView_0","byteOffset":288,"byteStride":0,"componentType":5126,"count":24,"max":[1,1,1],"min":[-1,-1,-1],"type":"VEC3"},"accessor_texcoord":{"bufferView":"bufferView_0","byteOffset":576,"byteStride":0,"componentType":5126,"count":24,"max":[6,1],"min":[0,0],"type":"VEC2"}},"animations":{},"asset":{"generator":"collada2gltf@ceec062e3d5793f2f249f53cbd843aee382ad40b","premultipliedAlpha":true,"profile":{"api":"WebGL","version":"1.0.2"},"version":"1.0"},"bufferViews":{"bufferView_0":{"buffer":"CesiumTexturedBoxTest","byteLength":768,"byteOffset":0,"target":34962},"bufferView_1":{"buffer":"CesiumTexturedBoxTest","byteLength":72,"byteOffset":768,"target":34963}},"buffers":{"CesiumTexturedBoxTest":{"type":"arraybuffer","byteLength":840,"uri":"data:application/octet-stream;base64,AAAAvwAAAD8AAAA/AAAAPwAAAD8AAAA/AAAAvwAAAD8AAAC/AAAAPwAAAD8AAAC/AAAAPwAAAD8AAAC/AAAAPwAAAD8AAAA/AAAAPwAAAL8AAAC/AAAAPwAAAL8AAAA/AAAAvwAAAD8AAAC/AAAAPwAAAD8AAAC/AAAAvwAAAL8AAAC/AAAAPwAAAL8AAAC/AAAAPwAAAD8AAAA/AAAAvwAAAD8AAAA/AAAAPwAAAL8AAAA/AAAAvwAAAL8AAAA/AAAAvwAAAD8AAAA/AAAAvwAAAD8AAAC/AAAAvwAAAL8AAAA/AAAAvwAAAL8AAAC/AAAAvwAAAL8AAAA/AAAAvwAAAL8AAAC/AAAAPwAAAL8AAAA/AAAAPwAAAL8AAAC/AAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAADAQAAAAAAAAKBAAAAAAAAAwED+/38/AACgQP7/fz8AAIBAAAAAAAAAoEAAAAAAAACAQAAAgD8AAKBAAACAPwAAAEAAAAAAAACAPwAAAAAAAABAAACAPwAAgD8AAIA/AABAQAAAAAAAAIBAAAAAAAAAQEAAAIA/AACAQAAAgD8AAEBAAAAAAAAAAEAAAAAAAABAQAAAgD8AAABAAACAPwAAAAAAAAAAAAAAAP7/fz8AAIA/AAAAAAAAgD/+/38/AAABAAIAAwACAAEABAAFAAYABwAGAAUACAAJAAoACwAKAAkADAANAA4ADwAOAA0AEAARABIAEwASABEAFAAVABYAFwAWABUA"}},"images":{"Image0001":{"name":"Image0001","uri":"data:image/png;base64,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"}},"materials":{"Effect-Texture":{"name":"Texture","technique":"technique0","values":{"diffuse":"texture_Image0001","shininess":256,"specular":[0.2,0.2,0.2,1]}}},"meshes":{"Geometry-mesh002":{"name":"Mesh","primitives":[{"attributes":{"NORMAL":"accessor_normals","POSITION":"accessor_positions","TEXCOORD_0":"accessor_texcoord"},"indices":"accessor_indices","material":"Effect-Texture","mode":4}]}},"nodes":{"rootNode":{"children":[],"meshes":["Geometry-mesh002"],"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}},"programs":{"program_0":{"attributes":["a_normal","a_position","a_texcoord0"],"fragmentShader":"CesiumTexturedBoxTest0FS","vertexShader":"CesiumTexturedBoxTest0VS"}},"samplers":{"sampler_0":{"magFilter":9729,"minFilter":9987,"wrapS":10497,"wrapT":10497}},"scene":"defaultScene","scenes":{"defaultScene":{"nodes":["rootNode"]}},"shaders":{"CesiumTexturedBoxTest0FS":{"type":35632,"uri":"data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0Owp2YXJ5aW5nIHZlYzMgdl9ub3JtYWw7CnZhcnlpbmcgdmVjMiB2X3RleGNvb3JkMDsKdW5pZm9ybSBzYW1wbGVyMkQgdV9kaWZmdXNlOwp1bmlmb3JtIHZlYzQgdV9zcGVjdWxhcjsKdW5pZm9ybSBmbG9hdCB1X3NoaW5pbmVzczsKdm9pZCBtYWluKHZvaWQpIHsKdmVjMyBub3JtYWwgPSBub3JtYWxpemUodl9ub3JtYWwpOwp2ZWM0IGNvbG9yID0gdmVjNCgwLiwgMC4sIDAuLCAwLik7CnZlYzQgZGlmZnVzZSA9IHZlYzQoMC4sIDAuLCAwLiwgMS4pOwp2ZWM0IHNwZWN1bGFyOwpkaWZmdXNlID0gdGV4dHVyZTJEKHVfZGlmZnVzZSwgdl90ZXhjb29yZDApOwpzcGVjdWxhciA9IHVfc3BlY3VsYXI7CmRpZmZ1c2UueHl6ICo9IG1heChkb3Qobm9ybWFsLHZlYzMoMC4sMC4sMS4pKSwgMC4pOwpjb2xvci54eXogKz0gZGlmZnVzZS54eXo7CmNvbG9yID0gdmVjNChjb2xvci5yZ2IgKiBkaWZmdXNlLmEsIGRpZmZ1c2UuYSk7CmdsX0ZyYWdDb2xvciA9IGNvbG9yOwp9Cg=="},"CesiumTexturedBoxTest0VS":{"type":35633,"uri":"data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0OwphdHRyaWJ1dGUgdmVjMyBhX3Bvc2l0aW9uOwphdHRyaWJ1dGUgdmVjMyBhX25vcm1hbDsKdmFyeWluZyB2ZWMzIHZfbm9ybWFsOwp1bmlmb3JtIG1hdDMgdV9ub3JtYWxNYXRyaXg7CnVuaWZvcm0gbWF0NCB1X21vZGVsVmlld01hdHJpeDsKdW5pZm9ybSBtYXQ0IHVfcHJvamVjdGlvbk1hdHJpeDsKYXR0cmlidXRlIHZlYzIgYV90ZXhjb29yZDA7CnZhcnlpbmcgdmVjMiB2X3RleGNvb3JkMDsKdm9pZCBtYWluKHZvaWQpIHsKdmVjNCBwb3MgPSB1X21vZGVsVmlld01hdHJpeCAqIHZlYzQoYV9wb3NpdGlvbiwxLjApOwp2X25vcm1hbCA9IHVfbm9ybWFsTWF0cml4ICogYV9ub3JtYWw7CnZfdGV4Y29vcmQwID0gYV90ZXhjb29yZDA7CmdsX1Bvc2l0aW9uID0gdV9wcm9qZWN0aW9uTWF0cml4ICogcG9zOwp9Cg=="}},"skins":{},"techniques":{"technique0":{"attributes":{"a_normal":"normal","a_position":"position","a_texcoord0":"texcoord0"},"parameters":{"diffuse":{"type":35678},"modelViewMatrix":{"semantic":"MODELVIEW","type":35676},"normal":{"semantic":"NORMAL","type":35665},"normalMatrix":{"semantic":"MODELVIEWINVERSETRANSPOSE","type":35675},"position":{"semantic":"POSITION","type":35665},"projectionMatrix":{"semantic":"PROJECTION","type":35676},"shininess":{"type":5126},"specular":{"type":35666},"texcoord0":{"semantic":"TEXCOORD_0","type":35664}},"program":"program_0","states":{"enable":[2929,2884]},"uniforms":{"u_diffuse":"diffuse","u_modelViewMatrix":"modelViewMatrix","u_normalMatrix":"normalMatrix","u_projectionMatrix":"projectionMatrix","u_shininess":"shininess","u_specular":"specular"}}},"textures":{"texture_Image0001":{"format":6408,"internalFormat":6408,"sampler":"sampler_0","source":"Image0001","target":3553,"type":5121}},"cameras":{},"extensionsUsed":[]} diff --git a/eslint.config.js b/eslint.config.js index d26e30fdf7a3..d57e8462d519 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -136,13 +136,20 @@ export default [ }, { // The core rule reports parameter names in function types as unused. - files: ["packages/*/Source/**/*.ts", "packages/gltf/gltf.entry.d.ts"], + // The core rule also reports interfaces and namespaces that share a name. + files: [ + "packages/*/Source/**/*.ts", + "packages/gltf/SchemaTypes/**/*.ts", + "packages/gltf/gltf.entry.d.ts", + ], rules: { "no-unused-vars": "off", "@typescript-eslint/no-unused-vars": [ "error", { vars: "all", args: "none", caughtErrors: "none" }, ], + "no-redeclare": "off", + "@typescript-eslint/no-redeclare": "error", }, }, { diff --git a/packages/engine/Source/Scene/Cesium3DTileset.js b/packages/engine/Source/Scene/Cesium3DTileset.js index 46e93b0ebc86..fde98ab815e9 100644 --- a/packages/engine/Source/Scene/Cesium3DTileset.js +++ b/packages/engine/Source/Scene/Cesium3DTileset.js @@ -4394,6 +4394,8 @@ Cesium3DTileset.checkSupportedExtensions = function (extensionsRequired) { } }; +// Add each extension to the glTF types in @cesium/gltf; see the "Generated glTF types" +// section of packages/gltf/README.md. Cesium3DTileset.supportedGltfExtensions = { "3DTILES_tileset": true, "3DTILES_implicit_tiling": true, diff --git a/packages/engine/Source/Scene/Model/ModelUtility.js b/packages/engine/Source/Scene/Model/ModelUtility.js index e78f59fe3fd3..d5d2c8f73da3 100644 --- a/packages/engine/Source/Scene/Model/ModelUtility.js +++ b/packages/engine/Source/Scene/Model/ModelUtility.js @@ -346,6 +346,8 @@ ModelUtility.sanitizeGlslIdentifier = function (identifier) { }; // Keep the list of supported extensions in the Model.js class docstring in sync with this object. +// Also add each extension to the glTF types in @cesium/gltf; see the "Generated glTF types" +// section of packages/gltf/README.md. ModelUtility.supportedExtensions = { AGI_articulations: true, CESIUM_mesh_vector: true, diff --git a/packages/gltf/README.md b/packages/gltf/README.md index 60e7ab2edf70..fe659a3767f6 100644 --- a/packages/gltf/README.md +++ b/packages/gltf/README.md @@ -32,6 +32,57 @@ Or, install with yarn: yarn add @cesium/gltf ``` +## Generated glTF types + +`SchemaTypes` contains TypeScript types for glTF JSON, generated from the [glTF JSON Schemas](https://github.com/KhronosGroup/glTF/tree/main/specification/2.0/schema): `Gltf1` for glTF 1.0, `Gltf2` for glTF 2.0 and 2.1, and a namespace for each extension, such as `EXT_structural_metadata`. Don't edit them by hand; regenerate them as described below. + +`scripts/gltfSchemaSources.json` lists where each schema comes from. `npm run download-schemas -w @cesium/gltf` downloads the listed schemas into `Build/Schemas`, and `npm run generate-types -w @cesium/gltf` generates the types from them. + +### Adding an extension + +When CesiumJS adds support for a glTF extension, add the extension to the generated types: + +1. Add an entry for the extension to `scripts/gltfSchemaSources.json`, as described below. +2. Run `npm run download-schemas -w @cesium/gltf`. +3. Run `npm run generate-types -w @cesium/gltf`. +4. Run `npm run tsc -w @cesium/gltf`. +5. Commit `gltfSchemaSources.json` with the regenerated files in `SchemaTypes`. + +For example, this entry adds `3DTILES_shape_ellipsoid_region`, whose schema appears in a glTF 2.1 shape's `extensions`: + +```json +"3DTILES_shape_ellipsoid_region": { + "repository": "CesiumGS/glTF", + "branch": "3d-tiles-2.0", + "commit": "e68efc9086f60743c331a2c757a1ffadcdb5d532", + "schemaDirectory": "extensions/2.1/Vendor/3DTILES_shape_ellipsoid_region/schema", + "core": ["2.1"], + "extends": { + "shape.3DTILES_shape_ellipsoid_region.schema.json": ["shape"] + } +} +``` + +### Updating a schema + +To use a newer version of a schema, change its `commit`, and its `branch` if needed, then follow steps 2 to 5 above. In the pull request, link the upstream changes, such as `https://github.com/KhronosGroup/glTF/compare/...`. + +### Entries in `gltfSchemaSources.json` + +`core` has an entry for each glTF version: `1.0`, `2.0`, and `2.1`. `extensions` has an entry for each extension, with these properties: + +- `repository`: The GitHub repository with the schemas. +- `branch`: The branch that `commit` is from. The scripts don't read it; it records where to look for newer versions. +- `commit`: The commit to download the schemas from. +- `schemaDirectory`: The directory in the repository with the extension's `*.schema.json` files. +- `core`: The glTF versions the extension applies to: `1.0`, `2.x` for glTF 2.0 and later, or `2.1` for an extension that uses anything glTF 2.1 adds, such as shapes. +- `extends`: For each of the extension's schemas that can appear in an object's `extensions`, the objects it can appear in. List every such schema: a schema left out still gets a type, but no object's `extensions` refers to it. Name an object by its schema file name without `.schema.json`: + - a glTF object, like `node` or `material.textureInfo`, or `glTF` for the root object; + - `*` for any glTF object; + - an object of another extension, as `/`, like `EXT_geospatial_crs/EXT_geospatial_crs`. + +An extension without a published schema, like `KHR_mesh_quantization`, has only `core`, and gets no types. + ## Community Have questions? Ask them on the [community forum](https://community.cesium.com/). diff --git a/packages/gltf/SchemaTypes/Extensions/3DTILES_implicit_tiling.ts b/packages/gltf/SchemaTypes/Extensions/3DTILES_implicit_tiling.ts new file mode 100644 index 000000000000..7b2393198eb2 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/3DTILES_implicit_tiling.ts @@ -0,0 +1,47 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/e68efc9086f60743c331a2c757a1ffadcdb5d532/extensions/2.1/Vendor/3DTILES_implicit_tiling/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace _3DTILES_implicit_tiling { + /** + * Implicit tiling defines a concise representation of quadtrees and octrees + * in 3D Tiles. + */ + export interface Node extends Gltf2.Property { + /** + * A template URI pointing to tile content. It contains placeholders + * `{level}`, `{x}`, `{y}`, and optionally `{z}` (for OCTREE subdivision + * scheme) that are substituted with a tile's coordinate to resolve the + * actual file. Example: `content/{level}/{x}/{y}.glb`. + */ + contentUri: string; + /** + * A template URI pointing to subtree files. It contains placeholders + * `{level}`, `{x}`, `{y}`, and optionally `{z}` (for OCTREE subdivision + * scheme) that are substituted with a subtree's coordinate to resolve the + * actual file. Example: `subtrees/{level}/{x}/{y}.json`. + */ + subtreeUri: string; + /** + * Either QUADTREE or OCTREE. See Subdivision scheme. + * + * Allowed values: + * + * - `"QUADTREE"` + * - `"OCTREE"` + */ + subdivisionScheme: string; + /** + * How many levels there are in the tree with available tiles. + */ + availableLevels: number; + /** + * How many levels there are in each subtree. + */ + subtreeLevels: number; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/3DTILES_subtree.ts b/packages/gltf/SchemaTypes/Extensions/3DTILES_subtree.ts new file mode 100644 index 000000000000..42ab826de45b --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/3DTILES_subtree.ts @@ -0,0 +1,101 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/e68efc9086f60743c331a2c757a1ffadcdb5d532/extensions/2.1/Vendor/3DTILES_subtree/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace _3DTILES_subtree { + /** + * An object describing the availability of a set of elements. + */ + export interface Availability extends Gltf2.Property { + /** + * Index of a buffer view that contains availability bits. If an element is + * available, its bit is 1, and if it is unavailable, its bit is 0. + */ + bitstream?: number; + /** + * A number indicating how many 1 bits exist in the availability bitstream. + */ + availableCount?: number; + /** + * Integer indicating whether all of the elements are available (1) or all + * are unavailable (0). + * + * Allowed values: + * + * - `0`: UNAVAILABLE + * - `1`: AVAILABLE + */ + constant?: number; + } + /** + * An object describing the availability of tiles and content in a subtree, as + * well as availability of children subtrees. May also store attributes and + * application-specific properties for available tiles and contents. + */ + export interface Gltf extends Gltf2.Property { + /** + * The availability of tiles in the subtree. The availability bitstream is a + * 1D boolean array where tiles are ordered by their level in the subtree + * and Morton index within that level. A tile's availability is determined + * by a single bit, 1 meaning a tile exists at that spatial index, and 0 + * meaning it does not. The number of elements in the array is + * `(N^subtreeLevels - 1)/(N - 1)` where N is 4 for subdivision scheme + * `QUADTREE` and 8 for `OCTREE`. Availability may be stored in a buffer + * view or as a constant value that applies to all tiles. If a non-root + * tile's availability is 1 its parent tile's availability must also be 1. + * `tileAvailability.constant: 0` is disallowed, as subtrees must have at + * least one tile. + */ + tileAvailability: _3DTILES_subtree.Availability; + /** + * The availability of contents in the subtree. + */ + contentAvailability?: _3DTILES_subtree.Availability; + /** + * The availability of children subtrees. The availability bitstream is a 1D + * boolean array where subtrees are ordered by their Morton index in the + * level of the tree immediately below the bottom row of the subtree. A + * child subtree's availability is determined by a single bit, 1 meaning a + * subtree exists at that spatial index, and 0 meaning it does not. The + * number of elements in the array is `N^subtreeLevels` where N is 4 for + * subdivision scheme `QUADTREE` and 8 for `OCTREE`. Availability may be + * stored in a buffer view or as a constant value that applies to all child + * subtrees. If availability is 0 for all child subtrees, then the tileset + * does not subdivide further. + */ + childSubtreeAvailability: _3DTILES_subtree.Availability; + /** + * A plain JSON object, where each key corresponds to a tile attribute + * semantic and each value is the index of the accessor containing + * attribute's data. Attribute values only exists for available tiles and + * are ordered by increasing tile index. + */ + tileAttributes?: Record; + /** + * A plain JSON object, where each key corresponds to a content attribute + * semantic and each value is the index of the accessor containing + * attribute's data. Attribute values only exists for available contents and + * are ordered by increasing tile index. + */ + contentAttributes?: Record; + /** + * Index of the property table containing tile properties. Tile properties + * only exist for available tiles and are tightly packed by increasing tile + * index. To access individual tile properties, implementations may create a + * mapping from tile indices to tile property indices. + */ + tileProperties?: number; + /** + * Index of the property table containing content properties. Content + * properties only exist for available contents and are tightly packed by + * increasing tile index. To access individual content properties, + * implementations may create a mapping from tile indices to content + * property indices. + */ + contentProperties?: number; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/3DTILES_tileset.ts b/packages/gltf/SchemaTypes/Extensions/3DTILES_tileset.ts new file mode 100644 index 000000000000..d6820e6bc185 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/3DTILES_tileset.ts @@ -0,0 +1,67 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/e68efc9086f60743c331a2c757a1ffadcdb5d532/extensions/2.1/Vendor/3DTILES_tileset/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace _3DTILES_tileset { + /** + * Content object in node-level 3DTILES_tileset extension. + */ + export interface Content extends Gltf2.Property { + /** + * The content bounding volume. + */ + boundingVolume?: Gltf2.Node.BoundingVolume; + } + /** + * glTF-level 3DTILES_tileset extension. + */ + export interface Gltf extends Gltf2.Property { + /** + * The tileset geometric error. A nonnegative number that defines the error, + * in meters, that determines if the tileset is rendered. At runtime, the + * geometric error is used to compute Screen-Space Error (SSE), the error + * measured in pixels. If the SSE does not exceed a required minimum, the + * tileset should not be rendered, and none of its tiles should be + * considered for rendering. + */ + geometricError: number; + } + /** + * Node-level 3DTILES_tileset extension. + */ + export interface Node extends Gltf2.Property { + /** + * The tile geometric error. A nonnegative number that defines the error, in + * meters, introduced if this tile is rendered and its children are not. At + * runtime, the geometric error is used to compute Screen-Space Error (SSE), + * the error measured in pixels. The SSE determines if a tile is + * sufficiently detailed for the current view or if its children should be + * considered. + */ + geometricError: number; + /** + * Specifies the refinement type. A string that is either "REPLACE" for + * replacement refinement or "ADD" for additive refinement. It is required + * for the root tile of a tileset; it is optional for all other tiles. A + * tileset can use any combination of additive and replacement refinement. + * When the refine property is omitted, it is inherited from the parent + * tile. + * + * Allowed values: + * + * - `"REPLACE"` + * - `"ADD"` + */ + refine?: string; + /** + * An object that provides additional information about the tile's content. + * If the tile does not have content (i.e. the node's `externalAsset` + * property is not defined) then `content` **MUST** be omitted. + */ + content?: _3DTILES_tileset.Content; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/3DTILES_tileset_voxels.ts b/packages/gltf/SchemaTypes/Extensions/3DTILES_tileset_voxels.ts new file mode 100644 index 000000000000..16ff81588a58 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/3DTILES_tileset_voxels.ts @@ -0,0 +1,41 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/e68efc9086f60743c331a2c757a1ffadcdb5d532/extensions/2.1/Vendor/3DTILES_tileset_voxels/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace _3DTILES_tileset_voxels { + /** + * Voxels are stored as glTFs with the EXT_voxels extension and are paired + * with EXT_structural_metadata to unify the schema between a tileset and its + * tiles. This extension is paired with Implicit Tiling for efficient + * representation of massive sparse voxel datasets. This extension lets + * runtimes detect voxel content in advance to allocate necessary resources + * before tiles load. + */ + export interface Gltf extends Gltf2.Property { + /** + * Dimensions of the voxel grid. + */ + dimensions: [number, number, number]; + /** + * The optional padding of the voxels. + */ + padding?: _3DTILES_tileset_voxels.Padding; + /** + * The class that property values conform to. The value shall be a class ID + * declared in the `classes` dictionary. + */ + class: string; + } + /** + * The padding around a voxel grid. Specifies how many rows of attribute data + * come from neighboring grids in each dimension. + */ + export interface Padding extends Gltf2.Property { + before: [number, number, number]; + after: [number, number, number]; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/AGI_articulations.ts b/packages/gltf/SchemaTypes/Extensions/AGI_articulations.ts new file mode 100644 index 000000000000..0ff55c69aa50 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/AGI_articulations.ts @@ -0,0 +1,99 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Vendor/AGI_articulations/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace AGI_articulations { + /** + * A model articulation definition. + */ + export interface Articulation extends Gltf2.Property { + /** + * The name of this articulation. The articulation name must be unique + * within this model. Articulation names may not contain spaces. + */ + name: string; + /** + * An array of stages, each of which defines a degree of freedom of + * movement. + */ + stages: AGI_articulations.Articulation.Stage[]; + /** + * The local forward vector for the associated node, for the purpose of + * pointing at a target or other object. + */ + pointingVector?: [number, number, number]; + } + export namespace Articulation { + /** + * One stage of a model articulation definition. + */ + export interface Stage extends Gltf2.Property { + /** + * The name of this articulation stage. The articulation stage name must + * be unique only within the containing articulation. Articulation Stage + * names may not contain spaces. + */ + name: string; + /** + * The type of motion applied by this articulation stage. + */ + type: + | "xTranslate" + | "yTranslate" + | "zTranslate" + | "xRotate" + | "yRotate" + | "zRotate" + | "xScale" + | "yScale" + | "zScale" + | "uniformScale" + | string; + /** + * The minimum value for the range of motion of this articulation stage. + */ + minimumValue: number; + /** + * The maximum value for the range of motion of this articulation stage. + */ + maximumValue: number; + /** + * The initial value for this articulation stage. + */ + initialValue: number; + } + } + /** + * glTF Extension that defines metadata for applying external analysis or + * effects to a model. + */ + export interface Gltf extends Gltf2.Property { + /** + * An array of articulations. An articulation indicates a named range of + * motion available to one or more nodes within the model. + */ + articulations?: AGI_articulations.Articulation[]; + } + /** + * glTF Extension for an individual node in a glTF model, to associate it with + * the model's root AGI_articulations object. + */ + export interface Node extends Gltf2.Property { + /** + * Set to true to indicate that this node's origin and orientation act as an + * attach point for external objects, analysis, or effects. + */ + isAttachPoint?: boolean; + /** + * The name of an Articulation that applies to this node. Articulations are + * defined in the glTF root extension. A single articulation may apply to + * more than one node, and its stage values set the transform for all + * assigned nodes simultaneously. + */ + articulationName?: string; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/BENTLEY_materials_line_style.ts b/packages/gltf/SchemaTypes/Extensions/BENTLEY_materials_line_style.ts new file mode 100644 index 000000000000..878680fa7bfd --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/BENTLEY_materials_line_style.ts @@ -0,0 +1,45 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/c3fa3604e240616d021aca3ebf61d7b61379b986/extensions/2.0/Vendor/BENTLEY_materials_line_style/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace BENTLEY_materials_line_style { + /** + * glTF extension that specifies line width and a GPU-friendly dash pattern + * for CAD-style visualization. + */ + export interface Material extends Gltf2.Property { + /** + * The thickness of the line in screen pixels. Must be greater than 0. + * Implementations typically render wide lines via tessellated geometry + * extruded from the line centerline. + * + * @default 1 + */ + width?: number; + /** + * An unsigned integer whose bits encode a repeating on/off pattern along + * the line. Bit value 1 indicates a lit (on) segment, and bit value 0 + * indicates an unlit (off) segment. The least significant bit (bit 0) + * corresponds to the start of the pattern and represents the first segment + * drawn along the line. The bit pattern repeats cyclically once all + * supported bits have been consumed. If a pattern uses fewer bits than the + * maximum supported width, unused higher bits MUST be set to zero. For + * example, a value of 0xFFFF produces a solid line, and a value of 0xAAAA + * produces a dotted line. + * + * @default 65535 + */ + pattern?: number; + } + export namespace Mesh { + /** + * Indicates that a mesh primitive supplies the BENTLEY_materials_line_style + * cumulative distance attribute semantic. + */ + export interface Primitive extends Gltf2.Property {} + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/BENTLEY_materials_planar_fill.ts b/packages/gltf/SchemaTypes/Extensions/BENTLEY_materials_planar_fill.ts new file mode 100644 index 000000000000..5ca1e62a4a6a --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/BENTLEY_materials_planar_fill.ts @@ -0,0 +1,45 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/c3fa3604e240616d021aca3ebf61d7b61379b986/extensions/2.0/Vendor/BENTLEY_materials_planar_fill/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace BENTLEY_materials_planar_fill { + /** + * Specifies planar fill behavior for CAD-style visualization. + */ + export interface Material extends Gltf2.Property { + /** + * Specifies whether and when the interior fill is displayed in wireframe + * view mode. 0 = NONE (never drawn), 1 = ALWAYS (always drawn), 2 = TOGGLE + * (drawn when fill display is enabled). + * + * Allowed values: + * + * - `0`: NONE - The fill is never drawn in wireframe view. + * - `1`: ALWAYS - The fill is always drawn in wireframe view. + * - `2`: TOGGLE - The fill is drawn only if the user or application has + * enabled toggleable fill display. + * + * @default 0 + */ + wireframeFill?: 0 | 1 | 2; + /** + * If true, the fill should be drawn using the view's background color, + * creating an invisible masking polygon. + * + * @default false + */ + backgroundFill?: boolean; + /** + * If true, the fill should be drawn behind other coplanar geometry + * belonging to the same logical object, useful for mitigating z-fighting + * with overlaid geometry such as hatch patterns or text. + * + * @default false + */ + behind?: boolean; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/BENTLEY_materials_point_style.ts b/packages/gltf/SchemaTypes/Extensions/BENTLEY_materials_point_style.ts new file mode 100644 index 000000000000..fecd042d0704 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/BENTLEY_materials_point_style.ts @@ -0,0 +1,19 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/c3fa3604e240616d021aca3ebf61d7b61379b986/extensions/2.0/Vendor/BENTLEY_materials_point_style/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace BENTLEY_materials_point_style { + /** + * Specifies point diameter for CAD-style visualization. + */ + export interface Material extends Gltf2.Property { + /** + * Diameter of the point in screen pixels. Must be > 0. + */ + diameter: number; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/CESIUM_RTC.ts b/packages/gltf/SchemaTypes/Extensions/CESIUM_RTC.ts new file mode 100644 index 000000000000..2110ee9c86c5 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/CESIUM_RTC.ts @@ -0,0 +1,16 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/1.0/Vendor/CESIUM_RTC +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +/** + * glTF CESIUM_RTC extension. + * + * @internal + */ +export interface CESIUM_RTC { + /** + * Center that vertex positions are relative to. + */ + center: [number, number, number]; +} diff --git a/packages/gltf/SchemaTypes/Extensions/CESIUM_primitive_outline.ts b/packages/gltf/SchemaTypes/Extensions/CESIUM_primitive_outline.ts new file mode 100644 index 000000000000..f746aade0aa9 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/CESIUM_primitive_outline.ts @@ -0,0 +1,21 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Vendor/CESIUM_primitive_outline/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace CESIUM_primitive_outline { + /** + * glTF extension for indicating that some edges of a primitive's triangles + * should be outlined. + */ + export interface Primitive extends Gltf2.Property { + /** + * The index of the accessor providing the list of highlighted lines at the + * edge of this primitive's triangles. + */ + indices?: number; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/CESIUM_tile_edges.ts b/packages/gltf/SchemaTypes/Extensions/CESIUM_tile_edges.ts new file mode 100644 index 000000000000..0e78525e43a9 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/CESIUM_tile_edges.ts @@ -0,0 +1,36 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/e68efc9086f60743c331a2c757a1ffadcdb5d532/extensions/2.0/Vendor/CESIUM_tile_edges/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace CESIUM_tile_edges { + export namespace Mesh { + /** + * `CESIUM_tile_edges` extension for a primitive in a glTF model. + */ + export interface Primitive extends Gltf2.Property { + /** + * The index of the accessor containing indices that make up the left + * edge. + */ + left: number; + /** + * The index of the accessor containing indices that make up the bottom + * edge. + */ + bottom: number; + /** + * The index of the accessor containing indices that make up the right + * edge. + */ + right: number; + /** + * The index of the accessor containing indices that make up the top edge. + */ + top: number; + } + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/EXT_feature_metadata.ts b/packages/gltf/SchemaTypes/Extensions/EXT_feature_metadata.ts new file mode 100644 index 000000000000..717a37aa3419 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/EXT_feature_metadata.ts @@ -0,0 +1,572 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/e68efc9086f60743c331a2c757a1ffadcdb5d532/extensions/2.0/Vendor/EXT_feature_metadata/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace EXT_feature_metadata { + /** + * An object describing per-instance feature IDs to be used as indices to + * property arrays in the feature table. + */ + export interface EXT_mesh_gpu_instancing extends Gltf2.Property { + /** + * An array of objects mapping per-instance feature IDs to property arrays + * in a feature table. + */ + featureIdAttributes?: EXT_feature_metadata.FeatureIdAttribute[]; + } + /** + * A class containing a set of properties. + */ + export interface Class extends Gltf2.Property { + /** + * The name of the class, e.g. for display purposes. + */ + name?: string; + /** + * The description of the class. + */ + description?: string; + /** + * A dictionary, where each key is a property ID and each value is an object + * defining the property. + */ + properties?: Record; + } + export namespace Class { + /** + * A class property. + */ + export interface Property extends Gltf2.Property { + /** + * The name of the property, e.g. for display purposes. + */ + name?: string; + /** + * The description of the property. + */ + description?: string; + /** + * The property type. If `ENUM` is used, then `enumType` must also be + * specified. If `ARRAY` is used, then `componentType` must also be + * specified. `ARRAY` is a fixed-length array when `componentCount` is + * defined, and variable-length otherwise. + * + * Allowed values: + * + * - `"INT8"` + * - `"UINT8"` + * - `"INT16"` + * - `"UINT16"` + * - `"INT32"` + * - `"UINT32"` + * - `"INT64"` + * - `"UINT64"` + * - `"FLOAT32"` + * - `"FLOAT64"` + * - `"BOOLEAN"` + * - `"STRING"` + * - `"ENUM"` + * - `"ARRAY"` + */ + type: string; + /** + * An enum ID as declared in the `enums` dictionary. This value must be + * specified when `type` or `componentType` is `ENUM`. + */ + enumType?: string; + /** + * When `type` is `ARRAY` this indicates the type of each component of the + * array. If `ENUM` is used, then `enumType` must also be specified. + * + * Allowed values: + * + * - `"INT8"` + * - `"UINT8"` + * - `"INT16"` + * - `"UINT16"` + * - `"INT32"` + * - `"UINT32"` + * - `"INT64"` + * - `"UINT64"` + * - `"FLOAT32"` + * - `"FLOAT64"` + * - `"BOOLEAN"` + * - `"STRING"` + * - `"ENUM"` + */ + componentType?: string; + /** + * The number of components per element for `ARRAY` elements. + */ + componentCount?: number; + /** + * Specifies whether integer values are normalized. This applies both when + * `type` is an integer type, or when `type` is `ARRAY` with a + * `componentType` that is an integer type. For unsigned integer types, + * values are normalized between `[0.0, 1.0]`. For signed integer types, + * values are normalized between `[-1.0, 1.0]`. For all other types, this + * property is ignored. + * + * @default false + */ + normalized?: boolean; + /** + * Maximum allowed values for property values. Only applicable for numeric + * types and fixed-length arrays of numeric types. For numeric types this + * is a single number. For fixed-length arrays this is an array with + * `componentCount` number of elements. The `normalized` property has no + * effect on these values: they always correspond to the integer values. + */ + max?: number | number[]; + /** + * Minimum allowed values for property values. Only applicable for numeric + * types and fixed-length arrays of numeric types. For numeric types this + * is a single number. For fixed-length arrays this is an array with + * `componentCount` number of elements. The `normalized` property has no + * effect on these values: they always correspond to the integer values. + */ + min?: number | number[]; + /** + * A default value to use when the property value is not defined. If used, + * `optional` must be set to true. The type of the default value must + * match the property definition: For `BOOLEAN` use `true` or `false`. For + * `STRING` use a JSON string. For a numeric type use a JSON number. For + * `ENUM` use the enum `name`, not the integer value. For `ARRAY` use a + * JSON array containing values matching the `componentType`. + */ + default?: boolean | number | string | unknown[]; + /** + * If true, this property is optional. + * + * @default false + */ + optional?: boolean; + /** + * An identifier that describes how this property should be interpreted. + * The semantic cannot be used by other properties in the class. + */ + semantic?: string; + } + } + /** + * An object defining the values of an enum. + */ + export interface Enum extends Gltf2.Property { + /** + * The name of the enum, e.g. for display purposes. + */ + name?: string; + /** + * The description of the enum. + */ + description?: string; + /** + * The type of the integer enum value. + * + * Allowed values: + * + * - `"INT8"` + * - `"UINT8"` + * - `"INT16"` + * - `"UINT16"` + * - `"INT32"` + * - `"UINT32"` + * - `"INT64"` + * - `"UINT64"` + * + * @default "UINT16" + */ + valueType?: string; + /** + * An array of enum values. Duplicate names or duplicate integer values are + * not allowed. + */ + values: EXT_feature_metadata.Enum.Value[]; + } + export namespace Enum { + /** + * An enum value. + */ + export interface Value extends Gltf2.Property { + /** + * The name of the enum value. + */ + name: string; + /** + * The description of the enum value. + */ + description?: string; + /** + * The integer enum value. + */ + value: number; + } + } + /** + * An object mapping feature IDs to a feature table. + */ + export interface FeatureIdAttribute extends Gltf2.Property { + /** + * The ID of the feature table in the model's root + * `EXT_feature_metadata.featureTables` dictionary. + */ + featureTable: string; + /** + * An object describing feature IDs to be used as indices to property arrays + * in the feature table. Feature IDs must be whole numbers in the range + * `[0, count - 1]` (inclusive), where `count` is the total number of + * features in the feature table. + */ + featureIds: EXT_feature_metadata.FeatureIdAttribute.FeatureIds; + } + export namespace FeatureIdAttribute { + /** + * Feature IDs to be used as indices to property arrays in the feature + * table. + */ + export interface FeatureIds extends Gltf2.Property { + /** + * The name of the attribute containing feature IDs. + */ + attribute?: string; + /** + * Sets a constant feature ID when the attribute property is omitted. + * + * @default 0 + */ + constant?: number; + /** + * The rate at which feature IDs increment. If `divisor` is 0 then + * `constant` is used. If `divisor` is non-zero the feature ID increments + * once per `divisor` sets of elements, starting at `constant`. For + * example, if `constant` is 0 and `divisor` is 1 the feature IDs are [0, + * 1, 2, ...]; if `constant` is 2 and `divisor` is 3 the feature IDs are + * [2, 2, 2, 3, 3, 3, 4, 4, 4, ...] + * + * @default 0 + */ + divisor?: number; + } + } + /** + * An object describing a texture used for storing per-texel feature IDs. + */ + export interface FeatureIdTexture extends Gltf2.Property { + /** + * The ID of the feature table in the model's root + * `EXT_feature_metadata.featureTables` dictionary. + */ + featureTable: string; + /** + * A description of the texture and channel to use for feature IDs. The + * `channels` property must have a single channel. Furthermore, feature IDs + * must be whole numbers in the range `[0, count - 1]` (inclusive), where + * `count` is the total number of features in the feature table. Texel + * values must be read as integers. Texture filtering should be disabled + * when fetching feature IDs. + */ + featureIds: EXT_feature_metadata.TextureAccessor; + } + /** + * A feature table defined by a class and property values stored in arrays. + */ + export interface FeatureTable extends Gltf2.Property { + /** + * The class that property values conform to. The value must be a class ID + * declared in the `classes` dictionary. + */ + class?: string; + /** + * The number of features, as well as the number of elements in each + * property array. + */ + count: number; + /** + * A dictionary, where each key corresponds to a property ID in the class' + * `properties` dictionary and each value is an object describing where + * property values are stored. Optional properties may be excluded from this + * dictionary. + */ + properties?: Record; + } + export namespace FeatureTable { + /** + * An array of binary property values. + */ + export interface Property extends Gltf2.Property { + /** + * The index of the buffer view containing property values. The data type + * of property values is determined by the property definition: When + * `type` is `BOOLEAN` values are packed into a bitfield. When `type` is + * `STRING` values are stored as byte sequences and decoded as UTF-8 + * strings. When `type` is a numeric type values are stored as the + * provided `type`. When `type` is `ENUM` values are stored as the enum's + * `valueType`. Each enum value in the buffer must match one of the + * allowed values in the enum definition. When `type` is `ARRAY` elements + * are packed tightly together and the data type is based on the + * `componentType` following the same rules as above. + * `arrayOffsetBufferView` is required for variable-size arrays and + * `stringOffsetBufferView` is required for strings (for variable-length + * arrays of strings, both are required). The buffer view `byteOffset` + * must be aligned to a multiple of 8 bytes. If the buffer view's `buffer` + * is the GLB-stored `BIN` chunk, the byte offset is measured relative to + * the beginning of the GLB. Otherwise, it is measured relative to the + * beginning of the buffer. + */ + bufferView: number; + /** + * The type of values in `arrayOffsetBufferView` and + * `stringOffsetBufferView`. + * + * Allowed values: + * + * - `"UINT8"` + * - `"UINT16"` + * - `"UINT32"` + * - `"UINT64"` + * + * @default "UINT32" + */ + offsetType?: string; + /** + * The index of the buffer view containing offsets for variable-length + * arrays. The number of offsets is equal to the feature table `count` + * plus one. The offsets represent the start positions of each array, with + * the last offset representing the position after the last array. The + * array length is computed using the difference between the current + * offset and the subsequent offset. If `componentType` is `STRING` the + * offsets index into the string offsets array (stored in + * `stringOffsetBufferView`), otherwise they index into the property array + * (stored in `bufferView`). The data type of these offsets is determined + * by `offsetType`. The buffer view `byteOffset` must be aligned to a + * multiple of 8 bytes in the same manner as the main `bufferView` + */ + arrayOffsetBufferView?: number; + /** + * The index of the buffer view containing offsets for strings. The number + * of offsets is equal to the number of string components plus one. The + * offsets represent the byte offsets of each string in the main + * `bufferView`, with the last offset representing the byte offset after + * the last string. The string byte length is computed using the + * difference between the current offset and the subsequent offset. The + * data type of these offsets is determined by `offsetType`. The buffer + * view `byteOffset` must be aligned to a multiple of 8 bytes in the same + * manner as the main `bufferView`. + */ + stringOffsetBufferView?: number; + } + } + /** + * Features whose property values are stored directly in texture channels. + * This is not to be confused with feature ID textures which store feature IDs + * for use with a feature table. + */ + export interface FeatureTexture extends Gltf2.Property { + /** + * The class this feature texture conforms to. The value must be a class ID + * declared in the `classes` dictionary. + */ + class: string; + /** + * A dictionary, where each key corresponds to a property ID in the class' + * `properties` dictionary and each value describes the texture channels + * containing property values. + */ + properties: Record; + } + /** + * glTF extension that assigns metadata to features in a model. + */ + export interface Gltf extends Gltf2.Property { + /** + * An object defining classes and enums. + */ + schema?: EXT_feature_metadata.Schema; + /** + * The URI (or IRI) of the external schema file. + */ + schemaUri?: string; + /** + * An object containing statistics about features. + */ + statistics?: EXT_feature_metadata.Statistics; + /** + * A dictionary, where each key is a feature table ID and each value is an + * object defining the feature table. + */ + featureTables?: Record; + /** + * A dictionary, where each key is a feature texture ID and each value is an + * object defining the feature texture. + */ + featureTextures?: Record; + } + export namespace Mesh { + /** + * `EXT_feature_metadata extension` for a primitive in a glTF model, to + * associate it with the root `EXT_feature_metadata` object. + */ + export interface Primitive extends Gltf2.Property { + /** + * An array of objects mapping per-vertex feature IDs to a feature table. + */ + featureIdAttributes?: EXT_feature_metadata.FeatureIdAttribute[]; + /** + * An array of objects mapping per-texel feature IDs to a feature table. + */ + featureIdTextures?: EXT_feature_metadata.FeatureIdTexture[]; + /** + * An array of IDs of feature textures from the root + * `EXT_feature_metadata` object. + */ + featureTextures?: string[]; + } + } + /** + * An object defining classes and enums. + */ + export interface Schema extends Gltf2.Property { + /** + * The name of the schema. + */ + name?: string; + /** + * The description of the schema. + */ + description?: string; + /** + * Application-specific version of the schema. + */ + version?: string; + /** + * A dictionary, where each key is a class ID and each value is an object + * defining the class. + */ + classes?: Record; + /** + * A dictionary, where each key is an enum ID and each value is an object + * defining the values for the enum. + */ + enums?: Record; + } + /** + * Statistics about features. + */ + export interface Statistics extends Gltf2.Property { + /** + * A dictionary, where each key is a class ID declared in the `classes` + * dictionary and each value is an object containing statistics about + * features that conform to the class. + */ + classes?: Record; + } + export namespace Statistics { + /** + * Statistics about features that conform to the class. + */ + export interface Class extends Gltf2.Property { + /** + * The number of features that conform to the class. + */ + count?: number; + /** + * A dictionary, where each key corresponds to a property ID in the class' + * `properties` dictionary and each value is an object containing + * statistics about property values. + */ + properties?: Record< + string, + EXT_feature_metadata.Statistics.Class.Property + >; + } + export namespace Class { + /** + * Statistics about property values. + */ + export interface Property extends Gltf2.Property { + /** + * The minimum property value. Only applicable for numeric types and + * fixed-length arrays of numeric types. For numeric types this is a + * single number. For fixed-length arrays this is an array with + * `componentCount` number of elements. The `normalized` property has no + * effect on these values. + */ + min?: number | number[]; + /** + * The maximum property value. Only applicable for numeric types and + * fixed-length arrays of numeric types. For numeric types this is a + * single number. For fixed-length arrays this is an array with + * `componentCount` number of elements. The `normalized` property has no + * effect on these values. + */ + max?: number | number[]; + /** + * The arithmetic mean of the property values. Only applicable for + * numeric types and fixed-length arrays of numeric types. For numeric + * types this is a single number. For fixed-length arrays this is an + * array with `componentCount` number of elements. The `normalized` + * property has no effect on these values. + */ + mean?: number | number[]; + /** + * The median of the property values. Only applicable for numeric types + * and fixed-length arrays of numeric types. For numeric types this is a + * single number. For fixed-length arrays this is an array with + * `componentCount` number of elements. The `normalized` property has no + * effect on these values. + */ + median?: number | number[]; + /** + * The standard deviation of the property values. Only applicable for + * numeric types and fixed-length arrays of numeric types. For numeric + * types this is a single number. For fixed-length arrays this is an + * array with `componentCount` number of elements. The `normalized` + * property has no effect on these values. + */ + standardDeviation?: number | number[]; + /** + * The variance of the property values. Only applicable for numeric + * types and fixed-length arrays of numeric types. For numeric types + * this is a single number. For fixed-length arrays this is an array + * with `componentCount` number of elements. The `normalized` property + * has no effect on these values. + */ + variance?: number | number[]; + /** + * The sum of the property values. Only applicable for numeric types and + * fixed-length arrays of numeric types. For numeric types this is a + * single number. For fixed-length arrays this is an array with + * `componentCount` number of elements. The `normalized` property has no + * effect on these values. + */ + sum?: number | number[]; + /** + * A dictionary, where each key corresponds to an enum `name` and each + * value is the number of occurrences of that enum. Only applicable when + * `type` or `componentType` is `ENUM`. For fixed-length arrays, this is + * an array with `componentCount` number of elements. + */ + occurrences?: Record; + } + } + } + /** + * A description of how to access property values from the color channels of a + * texture. + */ + export interface TextureAccessor extends Gltf2.Property { + /** + * Texture channels containing property values. Channels are labeled by + * `rgba` and are swizzled with a string of 1-4 characters. + */ + channels: string; + /** + * The glTF texture and texture coordinates to use. + */ + texture: Gltf2.Material.TextureInfo; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/EXT_geospatial_crs.ts b/packages/gltf/SchemaTypes/Extensions/EXT_geospatial_crs.ts new file mode 100644 index 000000000000..7a8d3359e63c --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/EXT_geospatial_crs.ts @@ -0,0 +1,37 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/e68efc9086f60743c331a2c757a1ffadcdb5d532/extensions/2.1/Vendor/EXT_geospatial_crs/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { EXT_geospatial_crs_wkid } from "./EXT_geospatial_crs_wkid.js"; +import type { Gltf2 } from "../Gltf2.js"; + +/** + * This extension declares the Coordinate Reference System (CRS) in which a glTF + * 2.1 asset was authored. + * + * @internal + */ +export interface EXT_geospatial_crs extends Gltf2.Property { + /** + * The coordinate reference system format, whose value must be defined by + * additional extensions. + */ + format: string; + /** + * JSON object with extension objects. Property names correspond to glTF + * extension names and property values are extension-specific objects. + */ + extensions?: EXT_geospatial_crs.Extensions; +} +/** @internal */ +export namespace EXT_geospatial_crs { + export interface Extensions extends Gltf2.Property.Extensions { + /** + * This extension declares the Coordinate Reference System (CRS) in which a + * glTF 2.1 asset was authored. The CRS is provided as a Well-Known ID + * (WKID), commonly an EPSG code. (glTF 2.1) + */ + EXT_geospatial_crs_wkid?: EXT_geospatial_crs_wkid; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/EXT_geospatial_crs_wkid.ts b/packages/gltf/SchemaTypes/Extensions/EXT_geospatial_crs_wkid.ts new file mode 100644 index 000000000000..b51807d552f0 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/EXT_geospatial_crs_wkid.ts @@ -0,0 +1,34 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/e68efc9086f60743c331a2c757a1ffadcdb5d532/extensions/2.1/Vendor/EXT_geospatial_crs_wkid/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** + * This extension declares the Coordinate Reference System (CRS) in which a glTF + * 2.1 asset was authored. The CRS is provided as a Well-Known ID (WKID), + * commonly an EPSG code. + * + * @internal + */ +export interface EXT_geospatial_crs_wkid extends Gltf2.Property { + /** + * The organization that defines and manages a specific CRS identifier. + */ + authority: string; + /** + * An integer that identifies the CRS. + */ + wkid: number; + /** + * An integer that identifies the vertical CRS if wkid identifies a horizontal + * CRS. + */ + vcsWkid?: number; + /** + * An epoch for coordinates that are referenced to a dynamic CRS such as + * WGS 84. Expressed as a decimal year (e.g. '2019.81'). + */ + epoch?: string; +} diff --git a/packages/gltf/SchemaTypes/Extensions/EXT_implicit_cylinder_region.ts b/packages/gltf/SchemaTypes/Extensions/EXT_implicit_cylinder_region.ts new file mode 100644 index 000000000000..1e3914da9199 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/EXT_implicit_cylinder_region.ts @@ -0,0 +1,50 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/e68efc9086f60743c331a2c757a1ffadcdb5d532/extensions/2.0/Vendor/EXT_implicit_cylinder_region/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace EXT_implicit_cylinder_region { + export namespace Gltf { + export namespace KHR_implicit_shapes { + /** + * Extension of `KHR_implicit_shapes.shape` to represent an implicit + * cylinder region in a glTF model. + */ + export interface Shape extends Gltf2.Property { + /** + * The inner radius of the cylinder region along the X and Z axes, in + * meters. + */ + minRadius: number; + /** + * The outer radius of the cylinder region along the X and Z axes, in + * meters. + */ + maxRadius: number; + /** + * The height of the cylinder in meters along the Y-axis, in meters. + */ + height: number; + /** + * The minimum angle of the cylinder region in radians. In other words, + * this is the angle where the cylinder region starts. Must be in the + * range [-pi, pi]. + * + * @default -3.14159265359 + */ + minAngle?: number; + /** + * The maximum angle of the cylinder region in radians. In other words, + * this is the angle where the cylinder region ends. Must be in the + * range [-pi, pi]. + * + * @default 3.14159265359 + */ + maxAngle?: number; + } + } + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/EXT_implicit_ellipsoid_region.ts b/packages/gltf/SchemaTypes/Extensions/EXT_implicit_ellipsoid_region.ts new file mode 100644 index 000000000000..27d5574d095a --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/EXT_implicit_ellipsoid_region.ts @@ -0,0 +1,68 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/e68efc9086f60743c331a2c757a1ffadcdb5d532/extensions/2.0/Vendor/EXT_implicit_ellipsoid_region/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace EXT_implicit_ellipsoid_region { + export namespace Gltf { + export namespace KHR_implicit_shapes { + /** + * Extension of `KHR_implicit_shapes.shape` to represent an implicit + * ellipsoid region in a glTF model. + */ + export interface Shape extends Gltf2.Property { + /** + * The radius along the semi-major axis of the reference ellipsoid in + * meters. Corresponds to the radii along the X and Z axes. + */ + semiMajorAxisRadius: number; + /** + * The radius along the semi-minor axis of the reference ellipsoid in + * meters. Corresponds to the radius along the Y-axis. + */ + semiMinorAxisRadius: number; + /** + * The minimum height of the region relative to the ellipsoid's surface, + * in meters. May be negative. + */ + minHeight: number; + /** + * The maximum height of the region relative to the ellipsoid's surface, + * in meters. May be negative. + */ + maxHeight: number; + /** + * The minimum latitude (a.k.a. polar angle) of the region, in radians. + * Must be in the range [-pi/2, pi/2]. + * + * @default -1.57079632679 + */ + minLatitude?: number; + /** + * The maximum latitude (a.k.a. polar angle) of the region, in radians. + * Must be in the range [-pi/2, pi/2]. + * + * @default 1.57079632679 + */ + maxLatitude?: number; + /** + * The minimum longitude (a.k.a. azimuthal angle) of the region, in + * radians. Must be in the range [-pi, pi]. + * + * @default -3.14159265359 + */ + minLongitude?: number; + /** + * The maximum longitude (a.k.a. azimuthal angle) of the region, in + * radians. Must be in the range [-pi, pi]. + * + * @default 3.14159265359 + */ + maxLongitude?: number; + } + } + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/EXT_instance_features.ts b/packages/gltf/SchemaTypes/Extensions/EXT_instance_features.ts new file mode 100644 index 000000000000..5f64331b2c3e --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/EXT_instance_features.ts @@ -0,0 +1,47 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/e68efc9086f60743c331a2c757a1ffadcdb5d532/extensions/2.0/Vendor/EXT_instance_features/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace EXT_instance_features { + /** + * Feature IDs stored in a GPU mesh instancing attribute + */ + export interface FeatureId extends Gltf2.Property { + /** + * The number of unique features in the attribute. + */ + featureCount: number; + /** + * A value that indicates that no feature is associated with this instance. + */ + nullFeatureId?: number; + /** + * A label assigned to this feature ID set. Labels must be alphanumeric + * identifiers matching the regular expression `^[a-zA-Z_][a-zA-Z0-9_]*$`. + */ + label?: string; + /** + * An attribute containing feature IDs. When this is omitted, then the + * feature IDs are assigned to the GPU instances by their index. + */ + attribute?: number; + /** + * The index of the property table containing per-feature property values. + * Only applicable when using the `EXT_structural_metadata` extension. + */ + propertyTable?: number; + } + /** + * An object describing per-instance feature IDs. + */ + export interface Node extends Gltf2.Property { + /** + * An array of feature ID sets. + */ + featureIds: EXT_instance_features.FeatureId[]; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/EXT_mesh_features.ts b/packages/gltf/SchemaTypes/Extensions/EXT_mesh_features.ts new file mode 100644 index 000000000000..83152d585f6c --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/EXT_mesh_features.ts @@ -0,0 +1,68 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/e68efc9086f60743c331a2c757a1ffadcdb5d532/extensions/2.0/Vendor/EXT_mesh_features/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace EXT_mesh_features { + /** + * Feature IDs stored in an attribute or texture. + */ + export interface FeatureId extends Gltf2.Property { + /** + * The number of unique features in the attribute or texture. + */ + featureCount: number; + /** + * A value that indicates that no feature is associated with this vertex or + * texel. + */ + nullFeatureId?: number; + /** + * A label assigned to this feature ID set. Labels must be alphanumeric + * identifiers matching the regular expression `^[a-zA-Z_][a-zA-Z0-9_]*$`. + */ + label?: string; + /** + * An attribute containing feature IDs. When `attribute` and `texture` are + * omitted the feature IDs are assigned to vertices by their index. + */ + attribute?: number; + /** + * A texture containing feature IDs. + */ + texture?: EXT_mesh_features.FeatureIdTexture; + /** + * The index of the property table containing per-feature property values. + * Only applicable when using the `EXT_structural_metadata` extension. + */ + propertyTable?: number; + } + /** + * A texture containing feature IDs + */ + export interface FeatureIdTexture extends Gltf2.Material.TextureInfo { + /** + * Texture channels containing feature IDs, identified by index. Feature IDs + * may be packed into multiple channels if a single channel does not have + * sufficient bit depth to represent all feature ID values. The values are + * packed in little-endian order. + * + * @default [0] + */ + channels?: number[]; + } + export namespace Mesh { + /** + * An object describing feature IDs for a mesh primitive. + */ + export interface Primitive extends Gltf2.Property { + /** + * An array of feature ID sets. + */ + featureIds: EXT_mesh_features.FeatureId[]; + } + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/EXT_mesh_gpu_instancing.ts b/packages/gltf/SchemaTypes/Extensions/EXT_mesh_gpu_instancing.ts new file mode 100644 index 000000000000..0190959d6948 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/EXT_mesh_gpu_instancing.ts @@ -0,0 +1,42 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Vendor/EXT_mesh_gpu_instancing/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { EXT_feature_metadata } from "./EXT_feature_metadata.js"; +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace EXT_mesh_gpu_instancing { + /** + * glTF extension defines instance attributes for a node with a mesh. + */ + export interface Gltf extends Gltf2.Property { + /** + * A dictionary object, where each key corresponds to instance attribute and + * each value is the index of the accessor containing attribute's data. + * Attributes TRANSLATION, ROTATION, SCALE define instance transformation. + * For "TRANSLATION" the values are FLOAT_VEC3's specifying translation + * along the x, y, and z axes. For "ROTATION" the values are VEC4's + * specifying rotation as a quaternion in the order (x, y, z, w), where w is + * the scalar, with component type `FLOAT` or normalized integer. For + * "SCALE" the values are FLOAT_VEC3's specifying scaling factors along the + * x, y, and z axes. + */ + attributes?: Record; + /** + * JSON object with extension objects. Property names correspond to glTF + * extension names and property values are extension-specific objects. + */ + extensions?: EXT_mesh_gpu_instancing.Gltf.Extensions; + } + export namespace Gltf { + export interface Extensions extends Gltf2.Property.Extensions { + /** + * An object describing per-instance feature IDs to be used as indices to + * property arrays in the feature table. + */ + EXT_feature_metadata?: EXT_feature_metadata.EXT_mesh_gpu_instancing; + } + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/EXT_mesh_polygon.ts b/packages/gltf/SchemaTypes/Extensions/EXT_mesh_polygon.ts new file mode 100644 index 000000000000..2362dc0dbbaa --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/EXT_mesh_polygon.ts @@ -0,0 +1,36 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/c3fa3604e240616d021aca3ebf61d7b61379b986/extensions/2.0/Vendor/EXT_mesh_polygon +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** + * glTF extension adding an encoding of polygon primitive topology + * + * @internal + */ +export interface EXT_mesh_polygon extends Gltf2.Property { + /** + * Integer number of polygons encoded in the mesh primitive. + */ + count: number; + /** + * Index of an accessor containing indices of the polygons' exterior and + * interior loops. The accessor MUST have SCALAR type and an unsigned integer + * component type. + */ + loopIndices: number; + /** + * Index of an accessor containing one integer offset per polygon in the + * primitive, indicating the first index of the first linear ring associated + * with that polygon. + */ + loopIndicesOffsets: number; + /** + * Index of an accessor containing one integer offset per polygon in the + * primitive, indicating the first index of the first triangle associated with + * that polygon. + */ + indicesOffsets: number; +} diff --git a/packages/gltf/SchemaTypes/Extensions/EXT_mesh_primitive_edge_visibility.ts b/packages/gltf/SchemaTypes/Extensions/EXT_mesh_primitive_edge_visibility.ts new file mode 100644 index 000000000000..ac929acf230e --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/EXT_mesh_primitive_edge_visibility.ts @@ -0,0 +1,57 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Vendor/EXT_mesh_primitive_edge_visibility/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace EXT_mesh_primitive_edge_visibility { + /** + * Represents one or more line strings to be drawn as edges of a triangle mesh + */ + export interface LineString extends Gltf2.Property { + /** + * The index of the accessor that contains the vertex indices. The accessor + * **MUST** have `SCALAR` type and an unsigned integer component type. The + * indices are permitted to include the maximal index value for the + * component type, indicating the start of a new line string. + */ + indices: number; + /** + * The index of a glTF material with which the edges are to be drawn. If + * omitted, the edges are drawn using the same material as the edges encoded + * by the extension's `visibility` field, or else that of the triangle mesh + * primitive. + */ + material?: number; + } + /** + * glTF extension encoding the visibility of the edges of a triangles + * primitive + */ + export interface Primitive extends Gltf2.Property { + /** + * An edge visibility of 0 indicates the edge is never drawn; 1 indicates + * the edge is only drawn in silhouette; 2 indicates a 'hard' (always-drawn) + * edge; and 3 indicates a repeated occurrence of a 'hard' edge. + */ + visibility?: number; + /** + * The index of a glTF material with which the edges are to be drawn. If + * omitted, the edges are drawn using the same material as the triangle mesh + * primitive. + */ + material?: number; + /** + * This property **MUST** be defined if and only if `visibility` encodes at + * least one edge with visibility value `1`. + */ + silhouetteNormals?: number; + /** + * Edges encoded as line strings **MUST NOT** also be encoded by the + * `visibility` property. + */ + lineStrings?: EXT_mesh_primitive_edge_visibility.LineString[]; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/EXT_mesh_primitive_restart.ts b/packages/gltf/SchemaTypes/Extensions/EXT_mesh_primitive_restart.ts new file mode 100644 index 000000000000..be1e3d1b4370 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/EXT_mesh_primitive_restart.ts @@ -0,0 +1,44 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Vendor/EXT_mesh_primitive_restart/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** + * glTF extension enabling the use of primitive restart values in index buffers + * + * @internal + */ +export interface EXT_mesh_primitive_restart extends Gltf2.Property { + /** + * The list of groups of primitives that can be drawn using a single index + * buffer with primitive restart + */ + primitiveGroups: EXT_mesh_primitive_restart.PrimitiveGroup[]; +} +/** @internal */ +export namespace EXT_mesh_primitive_restart { + /** + * A group of primitives that can be drawn together using a single index + * buffer containing restart values + */ + export interface PrimitiveGroup extends Gltf2.Property { + /** + * The indices of the primitives that will be combined and drawn using a + * single set of indices. All properties except for `indices` (e.g., + * `material`, `mode`, and `attributes`) will be obtained from the first + * primitive in the list, and all other primitives in the list **MUST** have + * identical values for those properties. The `mode` must be TRIANGLE_FAN, + * TRIANGLE_STRIP, LINE_LOOP, or LINE_STRIP. + */ + primitives: number[]; + /** + * The index of the accessor that contains the vertex indices. The accessor + * **MUST** have `SCALAR` type and an unsigned integer component type. The + * indices are permitted to include the maximal index value for the + * component type, indicating the start of a new primitive. + */ + indices: number; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/EXT_meshopt_compression.ts b/packages/gltf/SchemaTypes/Extensions/EXT_meshopt_compression.ts new file mode 100644 index 000000000000..4016ae994e04 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/EXT_meshopt_compression.ts @@ -0,0 +1,73 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Vendor/EXT_meshopt_compression/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace EXT_meshopt_compression { + /** + * Compressed data for bufferView. + */ + export interface Buffer extends Gltf2.Property { + /** + * Set to true to indicate that the buffer is only referenced by bufferViews + * that have EXT_meshopt_compression extension and as such doesn't need to + * be loaded. + * + * @default false + */ + fallback?: boolean; + } + /** + * Compressed data for bufferView. + */ + export interface BufferView extends Gltf2.Property { + /** + * The index of the buffer with compressed data. + */ + buffer: number; + /** + * The offset into the buffer in bytes. + * + * @default 0 + */ + byteOffset?: number; + /** + * The length of the compressed data in bytes. + */ + byteLength: number; + /** + * The stride, in bytes. + */ + byteStride: number; + /** + * The number of elements. + */ + count: number; + /** + * The compression mode. + * + * Allowed values: + * + * - `"ATTRIBUTES"` + * - `"TRIANGLES"` + * - `"INDICES"` + */ + mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES"; + /** + * The compression filter. + * + * Allowed values: + * + * - `"NONE"` + * - `"OCTAHEDRAL"` + * - `"QUATERNION"` + * - `"EXPONENTIAL"` + * + * @default "NONE" + */ + filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL"; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/EXT_primitive_voxels.ts b/packages/gltf/SchemaTypes/Extensions/EXT_primitive_voxels.ts new file mode 100644 index 000000000000..787e1bb09f31 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/EXT_primitive_voxels.ts @@ -0,0 +1,47 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/e68efc9086f60743c331a2c757a1ffadcdb5d532/extensions/2.0/Vendor/EXT_primitive_voxels/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace EXT_primitive_voxels { + export namespace Mesh { + /** + * `EXT_primitive_voxels` extension for a primitive in a glTF model to + * indicate voxel-based volumetric data + */ + export interface Primitive extends Gltf2.Property { + /** + * The index of the shape in `KHR_implicit_shapes` that the voxel grid + * adheres to. + */ + shape: number; + /** + * Dimensions of the voxel grid. The values are interpreted with respect + * to the shape indicated by `KHR_implicit_shapes`. + */ + dimensions: [number, number, number]; + /** + * The optional padding of the voxels. + */ + padding?: EXT_primitive_voxels.Padding; + /** + * A plain JSON object, where each key corresponds to an existing semantic + * in the primitive's `attributes`, and each value is the attribute's + * `noData` value. A `noData` value represents missing data — also known + * as a sentinel value — wherever it appears. + */ + noData?: Record; + } + } + /** + * The padding around a voxel grid. Specifies how many rows of attribute data + * come from neighboring grids in each dimension. + */ + export interface Padding extends Gltf2.Property { + before: [number, number, number]; + after: [number, number, number]; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/EXT_structural_metadata.ts b/packages/gltf/SchemaTypes/Extensions/EXT_structural_metadata.ts new file mode 100644 index 000000000000..1c9ecdf626dc --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/EXT_structural_metadata.ts @@ -0,0 +1,701 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/e68efc9086f60743c331a2c757a1ffadcdb5d532/extensions/2.0/Vendor/EXT_structural_metadata/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** + * Structural metadata about a glTF element. + * + * @internal + */ +export interface EXT_structural_metadata extends Gltf2.Property { + /** + * The class that property values conform to. The value shall be a class ID + * declared in the `classes` dictionary of the metadata schema. + */ + class?: string; + /** + * A dictionary, where each key corresponds to a property ID in the class' + * `properties` dictionary and each value contains the property values. The + * type of the value shall match the property definition: For `BOOLEAN` use + * `true` or `false`. For `STRING` use a JSON string. For numeric types use a + * JSON number. For `ENUM` use a valid enum `name`, not an integer value. For + * `ARRAY`, `VECN`, and `MATN` types use a JSON array containing values + * matching the `componentType`. Required properties shall be included in this + * dictionary. + */ + properties?: Record< + string, + number | string | boolean | number[] | string[] | boolean[] | number[][] + >; +} +/** @internal */ +export namespace EXT_structural_metadata { + /** + * A class containing a set of properties. + */ + export interface Class extends Gltf2.Property { + /** + * The name of the class, e.g. for display purposes. + */ + name?: string; + /** + * The description of the class. + */ + description?: string; + /** + * A dictionary, where each key is a property ID and each value is an object + * defining the property. Property IDs must be alphanumeric identifiers + * matching the regular expression `^[a-zA-Z_][a-zA-Z0-9_]*$`. + */ + properties?: Record; + } + export namespace Class { + /** + * A class property. + */ + export interface Property extends Gltf2.Property { + /** + * The name of the property, e.g. for display purposes. + */ + name?: string; + /** + * The description of the property. + */ + description?: string; + /** + * The element type. + * + * Allowed values: + * + * - `"SCALAR"` + * - `"VEC2"` + * - `"VEC3"` + * - `"VEC4"` + * - `"MAT2"` + * - `"MAT3"` + * - `"MAT4"` + * - `"STRING"` + * - `"BOOLEAN"` + * - `"ENUM"` + */ + type: string; + /** + * The datatype of the element's components. Only applicable to `SCALAR`, + * `VECN`, and `MATN` types. + * + * Allowed values: + * + * - `"INT8"` + * - `"UINT8"` + * - `"INT16"` + * - `"UINT16"` + * - `"INT32"` + * - `"UINT32"` + * - `"INT64"` + * - `"UINT64"` + * - `"FLOAT32"` + * - `"FLOAT64"` + */ + componentType?: string; + /** + * Enum ID as declared in the `enums` dictionary. Required when `type` is + * `ENUM`. + */ + enumType?: string; + /** + * Whether the property is an array. When `count` is defined the property + * is a fixed-length array. Otherwise the property is a variable-length + * array. + * + * @default false + */ + array?: boolean; + /** + * The number of array elements. May only be defined when `array` is true. + */ + count?: number; + /** + * Specifies whether integer values are normalized. Only applicable to + * `SCALAR`, `VECN`, and `MATN` types with integer component types. For + * unsigned integer component types, values are normalized between + * `[0.0, 1.0]`. For signed integer component types, values are normalized + * between `[-1.0, 1.0]`. For all other component types, this property + * must be false. + * + * @default false + */ + normalized?: boolean; + /** + * An offset to apply to property values. Only applicable to `SCALAR`, + * `VECN`, and `MATN` types when the component type is `FLOAT32` or + * `FLOAT64`, or when the property is `normalized`. + */ + offset?: number | number[] | number[][]; + /** + * A scale to apply to property values. Only applicable to `SCALAR`, + * `VECN`, and `MATN` types when the component type is `FLOAT32` or + * `FLOAT64`, or when the property is `normalized`. + */ + scale?: number | number[] | number[][]; + /** + * Maximum allowed value for the property. Only applicable to `SCALAR`, + * `VECN`, and `MATN` types. This is the maximum of all property values, + * after the transforms based on the `normalized`, `offset`, and `scale` + * properties have been applied. + */ + max?: number | number[] | number[][]; + /** + * Minimum allowed value for the property. Only applicable to `SCALAR`, + * `VECN`, and `MATN` types. This is the minimum of all property values, + * after the transforms based on the `normalized`, `offset`, and `scale` + * properties have been applied. + */ + min?: number | number[] | number[][]; + /** + * If required, the property must be present in every entity conforming to + * the class. If not required, individual entities may include `noData` + * values, or the entire property may be omitted. As a result, `noData` + * has no effect on a required property. Client implementations may use + * required properties to make performance optimizations. + * + * @default false + */ + required?: boolean; + /** + * A `noData` value represents missing data — also known as a sentinel + * value — wherever it appears. `BOOLEAN` properties may not specify + * `noData` values. This is given as the plain property value, without the + * transforms from the `normalized`, `offset`, and `scale` properties. + * Must not be defined if `required` is true. + */ + noData?: number | string | number[] | string[] | number[][]; + /** + * A default value to use when encountering a `noData` value or an omitted + * property. The value is given in its final form, taking the effect of + * `normalized`, `offset`, and `scale` properties into account. Must not + * be defined if `required` is true. + */ + default?: + | number + | string + | boolean + | number[] + | string[] + | boolean[] + | number[][]; + /** + * An identifier that describes how this property should be interpreted. + * The semantic cannot be used by other properties in the class. + */ + semantic?: string; + } + } + /** + * An object defining the values of an enum. + */ + export interface Enum extends Gltf2.Property { + /** + * The name of the enum, e.g. for display purposes. + */ + name?: string; + /** + * The description of the enum. + */ + description?: string; + /** + * The type of the integer enum value. + * + * Allowed values: + * + * - `"INT8"` + * - `"UINT8"` + * - `"INT16"` + * - `"UINT16"` + * - `"INT32"` + * - `"UINT32"` + * - `"INT64"` + * - `"UINT64"` + * + * @default "UINT16" + */ + valueType?: string; + /** + * An array of enum values. Duplicate names or duplicate integer values are + * not allowed. + */ + values: EXT_structural_metadata.Enum.Value[]; + } + export namespace Enum { + /** + * An enum value. + */ + export interface Value extends Gltf2.Property { + /** + * The name of the enum value. + */ + name: string; + /** + * The description of the enum value. + */ + description?: string; + /** + * The integer enum value. + */ + value: number; + } + } + /** + * glTF extension that provides structural metadata about vertices, texels, + * and features in a glTF asset. + */ + export interface Gltf extends Gltf2.Property { + /** + * An object defining classes and enums. + */ + schema?: EXT_structural_metadata.Schema; + /** + * The URI (or IRI) of the external schema file. + */ + schemaUri?: string; + /** + * An array of property table definitions, which may be referenced by index. + */ + propertyTables?: EXT_structural_metadata.PropertyTable[]; + /** + * An array of property texture definitions, which may be referenced by + * index. + */ + propertyTextures?: EXT_structural_metadata.PropertyTexture[]; + /** + * An array of property attribute definitions, which may be referenced by + * index. + */ + propertyAttributes?: EXT_structural_metadata.PropertyAttribute[]; + /** + * An object containing statistics about metadata entities. + */ + statistics?: EXT_structural_metadata.Statistics; + } + export namespace Mesh { + /** + * Structural metadata about a glTF primitive. + */ + export interface Primitive extends Gltf2.Property { + /** + * An array of indexes of property textures in the root + * `EXT_structural_metadata` object. + */ + propertyTextures?: number[]; + /** + * An array of indexes of property attributes in the root + * `EXT_structural_metadata` object. + */ + propertyAttributes?: number[]; + } + } + export namespace Node { + /** + * Structural metadata about EXT_voxels attributes. + */ + export interface EXT_voxels extends Gltf2.Property { + /** + * An array of indexes of property attributes in the root + * `EXT_structural_metadata` object. + */ + propertyAttributes?: number[]; + } + } + /** + * Properties conforming to a class, organized as property values stored in + * attributes. + */ + export interface PropertyAttribute extends Gltf2.Property { + /** + * The name of the property attribute, e.g. for display purposes. + */ + name?: string; + /** + * The class that property values conform to. The value must be a class ID + * declared in the `classes` dictionary. + */ + class: string; + /** + * A dictionary, where each key corresponds to a property ID in the class' + * `properties` dictionary and each value is an object describing where + * property values are stored. Required properties must be included in this + * dictionary. + */ + properties?: Record< + string, + EXT_structural_metadata.PropertyAttribute.Property + >; + } + export namespace PropertyAttribute { + /** + * An attribute containing property values. + */ + export interface Property extends Gltf2.Property { + /** + * The name of the attribute containing property values. + */ + attribute: string; + /** + * An offset to apply to property values. Only applicable when the + * component type is `FLOAT32` or `FLOAT64`, or when the property is + * `normalized`. Overrides the class property's `offset` if both are + * defined. + */ + offset?: number | number[] | number[][]; + /** + * A scale to apply to property values. Only applicable when the component + * type is `FLOAT32` or `FLOAT64`, or when the property is `normalized`. + * Overrides the class property's `scale` if both are defined. + */ + scale?: number | number[] | number[][]; + /** + * Maximum value present in the property values. Only applicable to + * `SCALAR`, `VECN`, and `MATN` types. This is the maximum of all property + * values, after the transforms based on the `normalized`, `offset`, and + * `scale` properties have been applied. + */ + max?: number | number[] | number[][]; + /** + * Minimum value present in the property values. Only applicable to + * `SCALAR`, `VECN`, and `MATN` types. This is the minimum of all property + * values, after the transforms based on the `normalized`, `offset`, and + * `scale` properties have been applied. + */ + min?: number | number[] | number[][]; + } + } + /** + * Properties conforming to a class, organized as property values stored in + * binary columnar arrays. + */ + export interface PropertyTable extends Gltf2.Property { + /** + * The name of the property table, e.g. for display purposes. + */ + name?: string; + /** + * The class that property values conform to. The value must be a class ID + * declared in the `classes` dictionary. + */ + class: string; + /** + * The number of elements in each property array. + */ + count: number; + /** + * A dictionary, where each key corresponds to a property ID in the class' + * `properties` dictionary and each value is an object describing where + * property values are stored. Required properties must be included in this + * dictionary. + */ + properties?: Record; + } + export namespace PropertyTable { + /** + * An array of binary property values. + */ + export interface Property extends Gltf2.Property { + /** + * The index of the buffer view containing property values. The data type + * of property values is determined by the property definition: When + * `type` is `BOOLEAN` values are packed into a bitstream. When `type` is + * `STRING` values are stored as byte sequences and decoded as UTF-8 + * strings. When `type` is `SCALAR`, `VECN`, or `MATN` the values are + * stored as the provided `componentType` and the buffer view `byteOffset` + * must be aligned to a multiple of the `componentType` size. When `type` + * is `ENUM` values are stored as the enum's `valueType` and the buffer + * view `byteOffset` must be aligned to a multiple of the `valueType` + * size. Each enum value in the array must match one of the allowed values + * in the enum definition. `arrayOffsets` is required for variable-length + * arrays and `stringOffsets` is required for strings (for variable-length + * arrays of strings, both are required). + */ + values: number; + /** + * The index of the buffer view containing offsets for variable-length + * arrays. The number of offsets is equal to the property table `count` + * plus one. The offsets represent the start positions of each array, with + * the last offset representing the position after the last array. The + * array length is computed using the difference between the subsequent + * offset and the current offset. If `type` is `STRING` the offsets index + * into the string offsets array (stored in `stringOffsets`), otherwise + * they index into the property array (stored in `values`). The data type + * of these offsets is determined by `arrayOffsetType`. The buffer view + * `byteOffset` must be aligned to a multiple of the `arrayOffsetType` + * size. + */ + arrayOffsets?: number; + /** + * The index of the buffer view containing offsets for strings. The number + * of offsets is equal to the number of string elements plus one. The + * offsets represent the byte offsets of each string in the property array + * (stored in `values`), with the last offset representing the byte offset + * after the last string. The string byte length is computed using the + * difference between the subsequent offset and the current offset. The + * data type of these offsets is determined by `stringOffsetType`. The + * buffer view `byteOffset` must be aligned to a multiple of the + * `stringOffsetType` size. + */ + stringOffsets?: number; + /** + * The type of values in `arrayOffsets`. + * + * Allowed values: + * + * - `"UINT8"` + * - `"UINT16"` + * - `"UINT32"` + * - `"UINT64"` + * + * @default "UINT32" + */ + arrayOffsetType?: string; + /** + * The type of values in `stringOffsets`. + * + * Allowed values: + * + * - `"UINT8"` + * - `"UINT16"` + * - `"UINT32"` + * - `"UINT64"` + * + * @default "UINT32" + */ + stringOffsetType?: string; + /** + * An offset to apply to property values. Only applicable when the + * component type is `FLOAT32` or `FLOAT64`, or when the property is + * `normalized`. Overrides the class property's `offset` if both are + * defined. + */ + offset?: number | number[] | number[][]; + /** + * A scale to apply to property values. Only applicable when the component + * type is `FLOAT32` or `FLOAT64`, or when the property is `normalized`. + * Overrides the class property's `scale` if both are defined. + */ + scale?: number | number[] | number[][]; + /** + * Maximum value present in the property values. Only applicable to + * `SCALAR`, `VECN`, and `MATN` types. This is the maximum of all property + * values, after the transforms based on the `normalized`, `offset`, and + * `scale` properties have been applied. + */ + max?: number | number[] | number[][]; + /** + * Minimum value present in the property values. Only applicable to + * `SCALAR`, `VECN`, and `MATN` types. This is the minimum of all property + * values, after the transforms based on the `normalized`, `offset`, and + * `scale` properties have been applied. + */ + min?: number | number[] | number[][]; + } + } + /** + * Properties conforming to a class, organized as property values stored in + * textures. + */ + export interface PropertyTexture extends Gltf2.Property { + /** + * The name of the property texture, e.g. for display purposes. + */ + name?: string; + /** + * The class that property values conform to. The value must be a class ID + * declared in the `classes` dictionary. + */ + class: string; + /** + * A dictionary, where each key corresponds to a property ID in the class' + * `properties` dictionary and each value is an object describing where + * property values are stored. Required properties must be included in this + * dictionary. + */ + properties?: Record< + string, + EXT_structural_metadata.PropertyTexture.Property + >; + } + export namespace PropertyTexture { + /** + * A texture containing property values. + */ + export interface Property extends Gltf2.Material.TextureInfo { + /** + * Texture channels containing property values, identified by index. The + * values may be packed into multiple channels if a single channel does + * not have sufficient bit depth. The values are packed in little-endian + * order. + * + * @default [0] + */ + channels?: number[]; + /** + * An offset to apply to property values. Only applicable when the + * component type is `FLOAT32` or `FLOAT64`, or when the property is + * `normalized`. Overrides the class property's `offset` if both are + * defined. + */ + offset?: number | number[] | number[][]; + /** + * A scale to apply to property values. Only applicable when the component + * type is `FLOAT32` or `FLOAT64`, or when the property is `normalized`. + * Overrides the class property's `scale` if both are defined. + */ + scale?: number | number[] | number[][]; + /** + * Maximum value present in the property values. Only applicable to + * `SCALAR`, `VECN`, and `MATN` types. This is the maximum of all property + * values, after the transforms based on the `normalized`, `offset`, and + * `scale` properties have been applied. + */ + max?: number | number[] | number[][]; + /** + * Minimum value present in the property values. Only applicable to + * `SCALAR`, `VECN`, and `MATN` types. This is the minimum of all property + * values, after the transforms based on the `normalized`, `offset`, and + * `scale` properties have been applied. + */ + min?: number | number[] | number[][]; + } + } + /** + * An object defining classes and enums. + */ + export interface Schema extends Gltf2.Property { + /** + * Unique identifier for the schema. Schema IDs must be alphanumeric + * identifiers matching the regular expression `^[a-zA-Z_][a-zA-Z0-9_]*$`. + */ + id: string; + /** + * The name of the schema, e.g. for display purposes. + */ + name?: string; + /** + * The description of the schema. + */ + description?: string; + /** + * Application-specific version of the schema. + */ + version?: string; + /** + * A dictionary, where each key is a class ID and each value is an object + * defining the class. Class IDs must be alphanumeric identifiers matching + * the regular expression `^[a-zA-Z_][a-zA-Z0-9_]*$`. + */ + classes?: Record; + /** + * A dictionary, where each key is an enum ID and each value is an object + * defining the values for the enum. Enum IDs must be alphanumeric + * identifiers matching the regular expression `^[a-zA-Z_][a-zA-Z0-9_]*$`. + */ + enums?: Record; + } + /** + * Statistics about entities. + */ + export interface Statistics extends Gltf2.Property { + /** + * A dictionary, where each key corresponds to a class ID in the `classes` + * dictionary of the metatata schema that was defined for the asset that + * contains these statistics. Each value is an object containing statistics + * about entities that conform to the class. + */ + classes?: Record; + } + export namespace Statistics { + /** + * Statistics about entities that conform to a class that was defined in a + * metadata schema. + */ + export interface Class extends Gltf2.Property { + /** + * The number of entities that conform to the class. + */ + count?: number; + /** + * A dictionary, where each key corresponds to a property ID in the class' + * `properties` dictionary and each value is an object containing + * statistics about property values. + */ + properties?: Record< + string, + EXT_structural_metadata.Statistics.Class.Property + >; + } + export namespace Class { + /** + * Statistics about property values. + */ + export interface Property extends Gltf2.Property { + /** + * The minimum property value occurring in the asset. Only applicable to + * `SCALAR`, `VECN`, and `MATN` types. This is the minimum of all + * property values, after the transforms based on the `normalized`, + * `offset`, and `scale` properties have been applied. + */ + min?: number | number[] | number[][]; + /** + * The maximum property value occurring in the asset. Only applicable to + * `SCALAR`, `VECN`, and `MATN` types. This is the maximum of all + * property values, after the transforms based on the `normalized`, + * `offset`, and `scale` properties have been applied. + */ + max?: number | number[] | number[][]; + /** + * The arithmetic mean of property values occurring in the asset. Only + * applicable to `SCALAR`, `VECN`, and `MATN` types. This is the mean of + * all property values, after the transforms based on the `normalized`, + * `offset`, and `scale` properties have been applied. + */ + mean?: number | number[] | number[][]; + /** + * The median of property values occurring in the asset. Only applicable + * to `SCALAR`, `VECN`, and `MATN` types. This is the median of all + * property values, after the transforms based on the `normalized`, + * `offset`, and `scale` properties have been applied. + */ + median?: number | number[] | number[][]; + /** + * The standard deviation of property values occurring in the asset. + * Only applicable to `SCALAR`, `VECN`, and `MATN` types. This is the + * standard deviation of all property values, after the transforms based + * on the `normalized`, `offset`, and `scale` properties have been + * applied. + */ + standardDeviation?: number | number[] | number[][]; + /** + * The variance of property values occurring in the asset. Only + * applicable to `SCALAR`, `VECN`, and `MATN` types. This is the + * variance of all property values, after the transforms based on the + * `normalized`, `offset`, and `scale` properties have been applied. + */ + variance?: number | number[] | number[][]; + /** + * The sum of property values occurring in the asset. Only applicable to + * `SCALAR`, `VECN`, and `MATN` types. This is the sum of all property + * values, after the transforms based on the `normalized`, `offset`, and + * `scale` properties have been applied. + */ + sum?: number | number[] | number[][]; + /** + * A dictionary, where each key corresponds to an enum `name` and each + * value is the number of occurrences of that enum. Only applicable when + * `type` is `ENUM`. For fixed-length arrays, this is an array of + * component-wise occurrences. + */ + occurrences?: Record; + } + } + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/EXT_textureInfo_constant_lod.ts b/packages/gltf/SchemaTypes/Extensions/EXT_textureInfo_constant_lod.ts new file mode 100644 index 000000000000..786436260dbb --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/EXT_textureInfo_constant_lod.ts @@ -0,0 +1,42 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/c3fa3604e240616d021aca3ebf61d7b61379b986/extensions/2.0/Vendor/EXT_textureInfo_constant_lod/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace EXT_textureInfo_constant_lod { + /** + * Enables dynamically calculated UV coordinates to keep the texture near a + * constant level of detail + */ + export interface TextureInfo extends Gltf2.Property { + /** + * The number of times the texture is repeated per meter. + * + * @default 1 + */ + repetitions?: number; + /** + * The offset in meters used to shift the texture. + * + * @default [0,0] + */ + offset?: [number, number]; + /** + * The minimum distance in meters from the eye to the surface at which to + * clamp the texture. + * + * @default 1 + */ + minClampDistance?: number; + /** + * The maximum distance in meters from the eye to the surface at which to + * clamp the texture. + * + * @default 4294967296 + */ + maxClampDistance?: number; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/EXT_texture_webp.ts b/packages/gltf/SchemaTypes/Extensions/EXT_texture_webp.ts new file mode 100644 index 000000000000..c17628263aaa --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/EXT_texture_webp.ts @@ -0,0 +1,19 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Vendor/EXT_texture_webp/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace EXT_texture_webp { + /** + * glTF extension to specify textures using the WebP image format. + */ + export interface Gltf extends Gltf2.Property { + /** + * The index of the WebP image. + */ + source?: number; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/EXT_voxels.ts b/packages/gltf/SchemaTypes/Extensions/EXT_voxels.ts new file mode 100644 index 000000000000..50fa3bc88063 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/EXT_voxels.ts @@ -0,0 +1,60 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/e68efc9086f60743c331a2c757a1ffadcdb5d532/extensions/2.1/Vendor/EXT_voxels/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { EXT_structural_metadata } from "./EXT_structural_metadata.js"; +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace EXT_voxels { + /** + * `EXT_voxels` extension for a node in a glTF model to indicate voxel-based + * volumetric data + */ + export interface Node extends Gltf2.Property { + /** + * Dimensions of the voxel grid. The values are interpreted with respect to + * the shape indicated by `shape`. + */ + dimensions: [number, number, number]; + /** + * The optional padding of the voxels. + */ + padding?: EXT_voxels.Padding; + /** + * A plain JSON object, where each key corresponds to an attribute semantic + * and each value is the index of the accessor containing the attribute's + * data. + */ + attributes: Record; + /** + * A plain JSON object, where each key corresponds to an existing semantic + * in `attributes`, and each value is the attribute's `noData` value. A + * `noData` value represents missing data—also known as a sentinel + * value—wherever it appears. + */ + noData?: Record; + /** + * JSON object with extension objects. Property names correspond to glTF + * extension names and property values are extension-specific objects. + */ + extensions?: EXT_voxels.Node.Extensions; + } + export namespace Node { + export interface Extensions extends Gltf2.Property.Extensions { + /** + * Structural metadata about EXT_voxels attributes. + */ + EXT_structural_metadata?: EXT_structural_metadata.Node.EXT_voxels; + } + } + /** + * The padding around a voxel grid. Specifies how many rows of attribute data + * come from neighboring grids in each dimension. + */ + export interface Padding extends Gltf2.Property { + before: [number, number, number]; + after: [number, number, number]; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/KHR_binary_glTF.ts b/packages/gltf/SchemaTypes/Extensions/KHR_binary_glTF.ts new file mode 100644 index 000000000000..3b2e55c980e3 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/KHR_binary_glTF.ts @@ -0,0 +1,34 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/1.0/Khronos/KHR_binary_glTF/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +/** @internal */ +export namespace KHR_binary_glTF { + export interface Image { + /** + * The id (JSON property name) of the buffer-view that references the image. + * Use this instead of the image's uri property. + */ + bufferView: string; + /** + * The image's MIME type. + */ + mimeType: string; + /** + * The width of the image in pixels. + */ + width: number; + /** + * The height of the image in pixels. + */ + height: number; + } + export interface Shader { + /** + * The id (JSON property name) of the buffer-view that references the shader + * source. Use this instead of the shader's uri property. + */ + bufferView: string; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/KHR_draco_mesh_compression.ts b/packages/gltf/SchemaTypes/Extensions/KHR_draco_mesh_compression.ts new file mode 100644 index 000000000000..763162b43c0c --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/KHR_draco_mesh_compression.ts @@ -0,0 +1,23 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Khronos/KHR_draco_mesh_compression/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace KHR_draco_mesh_compression { + export namespace Mesh { + export interface Primitive extends Gltf2.Property { + /** + * The index of the bufferView. + */ + bufferView: number; + /** + * A dictionary object, where each key corresponds to an attribute and its + * unique attribute id stored in the compressed geometry. + */ + attributes: Record; + } + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/KHR_gaussian_splatting.ts b/packages/gltf/SchemaTypes/Extensions/KHR_gaussian_splatting.ts new file mode 100644 index 000000000000..d6cb1fd1d67f --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/KHR_gaussian_splatting.ts @@ -0,0 +1,68 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Khronos/KHR_gaussian_splatting/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { KHR_gaussian_splatting_compression_spz_2 } from "./KHR_gaussian_splatting_compression_spz_2.js"; +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace KHR_gaussian_splatting { + export namespace Mesh { + /** + * Data defining a 3D Gaussian Splat primitive. + */ + export interface Primitive extends Gltf2.Property { + /** + * The kernel used to generate the Gaussians. + * + * Allowed values: + * + * - `"ellipse"` + */ + kernel: string; + /** + * The color space of the reconstructed color values. + * + * Allowed values: + * + * - `"srgb_rec709_display"` + * - `"lin_rec709_display"` + */ + colorSpace: string; + /** + * The projection method for rendering the Gaussians. + * + * Allowed values: + * + * - `"perspective"` + * + * @default "perspective" + */ + projection?: string; + /** + * The sorting method for rendering the Gaussians. + * + * Allowed values: + * + * - `"cameraDistance"` + * + * @default "cameraDistance" + */ + sortingMethod?: string; + /** + * JSON object with extension objects. Property names correspond to glTF + * extension names and property values are extension-specific objects. + */ + extensions?: KHR_gaussian_splatting.Mesh.Primitive.Extensions; + } + export namespace Primitive { + export interface Extensions extends Gltf2.Property.Extensions { + /** + * Compressed data for SPZ v2 primitive. + */ + KHR_gaussian_splatting_compression_spz_2?: KHR_gaussian_splatting_compression_spz_2.Mesh.Primitive; + } + } + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/KHR_gaussian_splatting_compression_spz_2.ts b/packages/gltf/SchemaTypes/Extensions/KHR_gaussian_splatting_compression_spz_2.ts new file mode 100644 index 000000000000..a0a8d147f33a --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/KHR_gaussian_splatting_compression_spz_2.ts @@ -0,0 +1,21 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/c3fa3604e240616d021aca3ebf61d7b61379b986/extensions/2.0/Khronos/KHR_gaussian_splatting_compression_spz_2/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace KHR_gaussian_splatting_compression_spz_2 { + export namespace Mesh { + /** + * Compressed data for SPZ v2 primitive. + */ + export interface Primitive extends Gltf2.Property { + /** + * The index of the bufferView. + */ + bufferView: number; + } + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/KHR_implicit_shapes.ts b/packages/gltf/SchemaTypes/Extensions/KHR_implicit_shapes.ts new file mode 100644 index 000000000000..aebcdecfd4fe --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/KHR_implicit_shapes.ts @@ -0,0 +1,151 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/c3fa3604e240616d021aca3ebf61d7b61379b986/extensions/2.0/Khronos/KHR_implicit_shapes/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { EXT_implicit_cylinder_region } from "./EXT_implicit_cylinder_region.js"; +import type { EXT_implicit_ellipsoid_region } from "./EXT_implicit_ellipsoid_region.js"; +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace KHR_implicit_shapes { + /** + * Top level implicit shapes. + */ + export interface Gltf extends Gltf2.Property { + /** + * An array of shape descriptions. + */ + shapes: KHR_implicit_shapes.Gltf.Shape[]; + } + export namespace Gltf { + /** + * Parameters describing an implicit shape. + */ + export interface Shape extends Gltf2.ChildOfRootProperty { + /** + * Specifies the shape type. + * + * Allowed values: + * + * - `"sphere"`: A sphere with a specified radius, centered at the origin + * in local space. + * - `"box"`: An axis-aligned box with a size per-axis, centered at the + * origin in local space + * - `"capsule"`: A capsule shape, centered at the origin in local space, + * equivalent to the convex hull of two spheres located along the Y axis + * (in local space) at a specified distance. + * - `"cylinder"`: A cylinder shape, centered at the origin in local + * space, equivalent to the convex hull of two circles in the X/Z plane + * positioned along the Y axis at a specified distance. + */ + type: string; + /** + * A set of parameter values that are used to define a sphere shape. + */ + sphere?: KHR_implicit_shapes.Gltf.Shape.Sphere; + /** + * A set of parameter values that are used to define a box shape. + */ + box?: KHR_implicit_shapes.Gltf.Shape.Box; + /** + * A set of parameter values that are used to define a capsule shape. + */ + capsule?: KHR_implicit_shapes.Gltf.Shape.Capsule; + /** + * A set of parameter values that are used to define a cylinder shape. + */ + cylinder?: KHR_implicit_shapes.Gltf.Shape.Cylinder; + /** + * JSON object with extension objects. Property names correspond to glTF + * extension names and property values are extension-specific objects. + */ + extensions?: KHR_implicit_shapes.Gltf.Shape.Extensions; + } + export namespace Shape { + /** + * Parameters describing a box shape. + */ + export interface Box extends Gltf2.Property { + /** + * The extents of the box in each axis in local space. + * + * @default [1,1,1] + */ + size?: [number, number, number]; + } + /** + * Parameters describing a capsule shape. + */ + export interface Capsule extends Gltf2.Property { + /** + * The distance between the centers of the two capping spheres of + * capsule. + * + * @default 0.5 + */ + height?: number; + /** + * The radius of the sphere located at the bottom of the capsule (i.e. + * the sphere at the half-height along -Y) + * + * @default 0.25 + */ + radiusBottom?: number; + /** + * The radius of the sphere located at the top of the capsule (i.e. the + * sphere at the half-height along +Y) + * + * @default 0.25 + */ + radiusTop?: number; + } + /** + * Parameters describing a cylinder shape. + */ + export interface Cylinder extends Gltf2.Property { + /** + * The height of the cylinder, centered along the Y axis. + * + * @default 0.5 + */ + height?: number; + /** + * The radius of the bottom of the cylinder (the disk located along -Y.) + * + * @default 0.25 + */ + radiusBottom?: number; + /** + * The radius of the top of the cylinder (the disk located along +Y.) + * + * @default 0.25 + */ + radiusTop?: number; + } + export interface Extensions extends Gltf2.Property.Extensions { + /** + * Extension of `KHR_implicit_shapes.shape` to represent an implicit + * cylinder region in a glTF model. + */ + EXT_implicit_cylinder_region?: EXT_implicit_cylinder_region.Gltf.KHR_implicit_shapes.Shape; + /** + * Extension of `KHR_implicit_shapes.shape` to represent an implicit + * ellipsoid region in a glTF model. + */ + EXT_implicit_ellipsoid_region?: EXT_implicit_ellipsoid_region.Gltf.KHR_implicit_shapes.Shape; + } + /** + * Parameters describing a sphere shape. + */ + export interface Sphere extends Gltf2.Property { + /** + * The radius of the sphere. + * + * @default 0.5 + */ + radius?: number; + } + } + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/KHR_materials_anisotropy.ts b/packages/gltf/SchemaTypes/Extensions/KHR_materials_anisotropy.ts new file mode 100644 index 000000000000..fc23a8fc7307 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/KHR_materials_anisotropy.ts @@ -0,0 +1,38 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Khronos/KHR_materials_anisotropy/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace KHR_materials_anisotropy { + /** + * glTF extension that defines anisotropy. + */ + export interface Material extends Gltf2.Property { + /** + * The anisotropy strength. When the anisotropy texture is present, this + * value is multiplied by the texture's blue channel. + * + * @default 0 + */ + anisotropyStrength?: number; + /** + * The rotation of the anisotropy in tangent, bitangent space, measured in + * radians counter-clockwise from the tangent. When the anisotropy texture + * is present, this value provides additional rotation to the vectors in the + * texture. + * + * @default 0 + */ + anisotropyRotation?: number; + /** + * The anisotropy texture. Red and green channels represent the anisotropy + * direction in $[-1, 1]$ tangent, bitangent space, to be rotated by the + * anisotropy rotation. The blue channel contains strength as $[0, 1]$ to be + * multiplied by the anisotropy strength. + */ + anisotropyTexture?: Gltf2.Material.TextureInfo; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/KHR_materials_clearcoat.ts b/packages/gltf/SchemaTypes/Extensions/KHR_materials_clearcoat.ts new file mode 100644 index 000000000000..1ab542adef4d --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/KHR_materials_clearcoat.ts @@ -0,0 +1,46 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Khronos/KHR_materials_clearcoat/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace KHR_materials_clearcoat { + /** + * glTF extension that defines the clearcoat material layer. + */ + export interface Material extends Gltf2.Property { + /** + * The clearcoat layer intensity (aka opacity) of the material. A value of + * 0.0 means the material has no clearcoat layer enabled. + * + * @default 0 + */ + clearcoatFactor?: number; + /** + * The clearcoat layer intensity texture. These values are sampled from the + * R channel. The values are linear. Use value 1.0 if no texture is + * supplied. + */ + clearcoatTexture?: Gltf2.Material.TextureInfo; + /** + * The clearcoat layer roughness of the material. + * + * @default 0 + */ + clearcoatRoughnessFactor?: number; + /** + * The clearcoat layer roughness texture. These values are sampled from the + * G channel. The values are linear. Use value 1.0 if no texture is + * supplied. + */ + clearcoatRoughnessTexture?: Gltf2.Material.TextureInfo; + /** + * A tangent space normal map for the clearcoat layer. If desired, this may + * be a reference to the same normal map used by the base material. If not + * supplied, no normal mapping is applied to the clear coat layer. + */ + clearcoatNormalTexture?: Gltf2.Material.NormalTextureInfo; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/KHR_materials_emissive_strength.ts b/packages/gltf/SchemaTypes/Extensions/KHR_materials_emissive_strength.ts new file mode 100644 index 000000000000..c452d94a21fc --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/KHR_materials_emissive_strength.ts @@ -0,0 +1,22 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Khronos/KHR_materials_emissive_strength/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace KHR_materials_emissive_strength { + /** + * glTF extension that adjusts the strength of emissive material properties. + */ + export interface Material extends Gltf2.Property { + /** + * The strength adjustment to be multiplied with the material's emissive + * value. + * + * @default 1 + */ + emissiveStrength?: number; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/KHR_materials_pbrSpecularGlossiness.ts b/packages/gltf/SchemaTypes/Extensions/KHR_materials_pbrSpecularGlossiness.ts new file mode 100644 index 000000000000..de2b974e9b9e --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/KHR_materials_pbrSpecularGlossiness.ts @@ -0,0 +1,55 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace KHR_materials_pbrSpecularGlossiness { + /** + * glTF extension that defines the specular-glossiness material model from + * Physically-Based Rendering (PBR) methodology. + */ + export interface Gltf extends Gltf2.Property { + /** + * The RGBA components of the reflected diffuse color of the material. + * Metals have a diffuse value of `[0.0, 0.0, 0.0]`. The fourth component + * (A) is the alpha coverage of the material. The `alphaMode` property + * specifies how alpha is interpreted. The values are linear. + * + * @default [1,1,1,1] + */ + diffuseFactor?: [number, number, number, number]; + /** + * The diffuse texture. This texture contains RGB components of the + * reflected diffuse color of the material encoded with the sRGB transfer + * function. If the fourth component (A) is present, it represents the + * linear alpha coverage of the material. Otherwise, an alpha of 1.0 is + * assumed. The `alphaMode` property specifies how alpha is interpreted. The + * stored texels must not be premultiplied. + */ + diffuseTexture?: Gltf2.Material.TextureInfo; + /** + * The specular RGB color of the material. This value is linear. + * + * @default [1,1,1] + */ + specularFactor?: [number, number, number]; + /** + * The glossiness or smoothness of the material. A value of 1.0 means the + * material has full glossiness or is perfectly smooth. A value of 0.0 means + * the material has no glossiness or is completely rough. This value is + * linear. + * + * @default 1 + */ + glossinessFactor?: number; + /** + * The specular-glossiness texture is an RGBA texture, containing the + * specular color (RGB) encoded with the sRGB transfer function and the + * linear glossiness value (A). + */ + specularGlossinessTexture?: Gltf2.Material.TextureInfo; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/KHR_materials_specular.ts b/packages/gltf/SchemaTypes/Extensions/KHR_materials_specular.ts new file mode 100644 index 000000000000..505050a41e9f --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/KHR_materials_specular.ts @@ -0,0 +1,41 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Khronos/KHR_materials_specular/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace KHR_materials_specular { + /** + * glTF extension that defines the strength of the specular reflection. + */ + export interface Material extends Gltf2.Property { + /** + * This parameter scales the amount of specular reflection on non-metallic + * surfaces. It has no effect on metals. + * + * @default 1 + */ + specularFactor?: number; + /** + * A texture that defines the specular factor in the alpha channel. This + * will be multiplied by specularFactor. + */ + specularTexture?: Gltf2.Material.TextureInfo; + /** + * This is an additional RGB color parameter that tints the specular + * reflection of non-metallic surfaces. At grazing angles, the reflection + * still blends to white, and the parameter has not effect on metals. The + * value is linear. + * + * @default [1,1,1] + */ + specularColorFactor?: [number, number, number]; + /** + * A texture that defines the specular color in the RGB channels (encoded in + * sRGB). This will be multiplied by specularColorFactor. + */ + specularColorTexture?: Gltf2.Material.TextureInfo; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/KHR_materials_transmission.ts b/packages/gltf/SchemaTypes/Extensions/KHR_materials_transmission.ts new file mode 100644 index 000000000000..b34f12ef51ab --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/KHR_materials_transmission.ts @@ -0,0 +1,33 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Khronos/KHR_materials_transmission/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace KHR_materials_transmission { + /** + * glTF extension that defines the optical transmission of a material. + */ + export interface Material extends Gltf2.Property { + /** + * The base percentage of non-specularly reflected light that is transmitted + * through the surface. i.e. of the light that penetrates a surface (isn't + * specularly reflected), this is the percentage that is transmitted and not + * diffusely re-emitted. + * + * @default 0 + */ + transmissionFactor?: number; + /** + * A texture that defines the transmission percentage of the surface, + * sampled from the R channel. These values are linear, and will be + * multiplied by transmissionFactor. This indicates the percentage of + * non-specularly reflected light that is transmitted through the surface. + * i.e. of the light that penetrates a surface (isn't specularly reflected), + * this is the percentage is transmitted and not diffusely re-emitted. + */ + transmissionTexture?: Gltf2.Material.TextureInfo; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/KHR_materials_unlit.ts b/packages/gltf/SchemaTypes/Extensions/KHR_materials_unlit.ts new file mode 100644 index 000000000000..2874c8f13a9d --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/KHR_materials_unlit.ts @@ -0,0 +1,14 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Khronos/KHR_materials_unlit/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace KHR_materials_unlit { + /** + * glTF extension that defines the unlit material model. + */ + export interface Material extends Gltf2.Property {} +} diff --git a/packages/gltf/SchemaTypes/Extensions/KHR_meshopt_compression.ts b/packages/gltf/SchemaTypes/Extensions/KHR_meshopt_compression.ts new file mode 100644 index 000000000000..5cb48e56b806 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/KHR_meshopt_compression.ts @@ -0,0 +1,74 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Khronos/KHR_meshopt_compression/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace KHR_meshopt_compression { + /** + * Compressed data for bufferView. + */ + export interface Buffer extends Gltf2.Property { + /** + * Set to true to indicate that the buffer is only referenced by bufferViews + * that have KHR_meshopt_compression extension and as such doesn't need to + * be loaded. + * + * @default false + */ + fallback?: boolean; + } + /** + * Compressed data for bufferView. + */ + export interface BufferView extends Gltf2.Property { + /** + * The index of the buffer with compressed data. + */ + buffer: number; + /** + * The offset into the buffer in bytes. + * + * @default 0 + */ + byteOffset?: number; + /** + * The length of the compressed data in bytes. + */ + byteLength: number; + /** + * The stride, in bytes. + */ + byteStride: number; + /** + * The number of elements. + */ + count: number; + /** + * The compression mode. + * + * Allowed values: + * + * - `"ATTRIBUTES"` + * - `"TRIANGLES"` + * - `"INDICES"` + */ + mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES"; + /** + * The compression filter. + * + * Allowed values: + * + * - `"NONE"` + * - `"OCTAHEDRAL"` + * - `"QUATERNION"` + * - `"EXPONENTIAL"` + * - `"COLOR"` + * + * @default "NONE" + */ + filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL" | "COLOR"; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/KHR_node_visibility.ts b/packages/gltf/SchemaTypes/Extensions/KHR_node_visibility.ts new file mode 100644 index 000000000000..fccde35d1b7e --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/KHR_node_visibility.ts @@ -0,0 +1,22 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Khronos/KHR_node_visibility/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace KHR_node_visibility { + /** + * glTF extension that defines node's visibility. + */ + export interface Node extends Gltf2.Property { + /** + * Specifies whether the node is visible. A value of false means that the + * node and all its children are hidden. + * + * @default true + */ + visible?: boolean; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/KHR_spz_gaussian_splats_compression.ts b/packages/gltf/SchemaTypes/Extensions/KHR_spz_gaussian_splats_compression.ts new file mode 100644 index 000000000000..93aa775b0454 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/KHR_spz_gaussian_splats_compression.ts @@ -0,0 +1,21 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/CesiumGS/glTF/tree/a4d88217e20f1ad86f4539bbae55ab6b931cb9cc/extensions/2.0/Khronos/KHR_spz_gaussian_splats_compression/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace KHR_spz_gaussian_splats_compression { + export namespace Mesh { + /** + * Compressed data for SPZ primitive. + */ + export interface Primitive extends Gltf2.Property { + /** + * The index of the bufferView. + */ + bufferView: number; + } + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/KHR_techniques_webgl.ts b/packages/gltf/SchemaTypes/Extensions/KHR_techniques_webgl.ts new file mode 100644 index 000000000000..7502d0ad2aa5 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/KHR_techniques_webgl.ts @@ -0,0 +1,217 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Archived/KHR_techniques_webgl/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace KHR_techniques_webgl { + /** + * Instances of shading techniques with external shader programs along with + * their parameterized values. Shading techniques describe data types and + * semantics for GLSL vertex and fragment shader programs. + */ + export interface Gltf extends Gltf2.Property { + /** + * An array of `Program` objects. + */ + programs: KHR_techniques_webgl.Program[]; + /** + * An array of `Shader` objects. + */ + shaders: KHR_techniques_webgl.Shader[]; + /** + * An array of `Technique` objects. A technique is a template for a material + * appearance. + */ + techniques: KHR_techniques_webgl.Technique[]; + } + /** + * The technique to use for a material and any additional uniform values. + */ + export interface Material extends Gltf2.Property { + /** + * The index of the technique. + */ + technique: number; + /** + * Dictionary object of uniform values. Uniforms with the same name as the + * technique's uniform must conform to the referenced `type` and `count` (if + * present) properties, and override the technique's uniform value. A + * uniform value must be supplied here if not present in the technique + * uniforms. + * + * @default {} + */ + values?: Record< + string, + number | boolean | number[] | boolean[] | Gltf2.Material.TextureInfo + >; + } + /** + * A shader program, including its vertex and fragment shaders. + */ + export interface Program extends Gltf2.ChildOfRootProperty { + /** + * The index of the fragment shader. + */ + fragmentShader: number; + /** + * The index of the vertex shader. + */ + vertexShader: number; + /** + * The names of required WebGL 1.0 extensions. + */ + glExtensions?: string[]; + } + /** + * A vertex or fragment shader. Exactly one of `uri` or `bufferView` must be + * provided for the GLSL source. + */ + export interface Shader extends Gltf2.ChildOfRootProperty { + /** + * The uri of the GLSL source. Relative paths are relative to the `.gltf` + * file. Instead of referencing an external file, the uri can also be a + * data-uri. + */ + uri?: string; + /** + * The shader stage. All valid values correspond to WebGL enums. + * + * Allowed values: + * + * - `35632`: FRAGMENT_SHADER + * - `35633`: VERTEX_SHADER + */ + type: 35632 | 35633; + /** + * The index of the bufferView that contains the GLSL shader source. Use + * this instead of the shader's uri property. + */ + bufferView?: number; + } + /** + * A template for material appearances. + */ + export interface Technique extends Gltf2.ChildOfRootProperty { + /** + * The index of the program. + */ + program: number; + /** + * A dictionary object of `Attribute` objects. Each object defines an + * attribute input with a type and a semantic. + */ + attributes?: Record; + /** + * A dictionary object of `Uniform` objects. Each object defines a uniform + * input with a type and an optional semantic and value. + */ + uniforms?: Record; + } + export namespace Technique { + /** + * An attribute input to a technique and the corresponding semantic. + */ + export interface Attribute extends Gltf2.Property { + /** + * Identifies a mesh attribute semantic. Attribute semantics include + * `"POSITION"`, `"NORMAL"`, `"TEXCOORD"`, `"COLOR"`, `"JOINT"`, and + * `"WEIGHT"`. `"TEXCOORD"` and `"COLOR"` attribute semantic property + * names must be of the form `[semantic]_[set_index]`, e.g., + * `"TEXCOORD_0"`, `"TEXCOORD_1"`, `"COLOR_1"`, etc. For + * forward-compatibility, application-specific semantics must start with + * an underscore, e.g., `"_SIMULATION_TIME"`. + */ + semantic: string; + } + /** + * A uniform input to a technique, and an optional semantic and value. + */ + export interface Uniform extends Gltf2.Property { + /** + * When defined, the uniform is an array of `count` elements of the + * specified type. Otherwise, the uniform is not an array. When defined, + * `value`'s length must equal `count`, times the number of components in + * the `type`, e.g., `3` for `FLOAT_VEC3`. A uniform array of scalar + * values is not the same as a uniform vector of the same size; for + * example, when count is 2 and type is `5126` (`FLOAT`), the uniform is + * an array of two floating-point values, not a `FLOAT_VEC2`. When a + * glTF-defined semantic is used, the semantic must be `JOINTMATRIX`; + * application-specific uniforms can be arrays and, therefore, define + * `count`. + */ + count?: number; + /** + * The index of the node whose transform is used as the uniform's value. + * When this is defined, `type` must be `35676` (`FLOAT_MAT4`), therefore, + * when the semantic is `"MODELINVERSETRANSPOSE"`, + * `"MODELVIEWINVERSETRANSPOSE"`, or `"VIEWPORT"`, the node property can't + * be defined. + */ + node?: number; + /** + * The uniform type. All valid values correspond to WebGL enums. + * + * Allowed values: + * + * - `5124`: INT + * - `5126`: FLOAT + * - `35664`: FLOAT_VEC2 + * - `35665`: FLOAT_VEC3 + * - `35666`: FLOAT_VEC4 + * - `35667`: INT_VEC2 + * - `35668`: INT_VEC3 + * - `35669`: INT_VEC4 + * - `35670`: BOOL + * - `35671`: BOOL_VEC2 + * - `35672`: BOOL_VEC3 + * - `35673`: BOOL_VEC4 + * - `35674`: FLOAT_MAT2 + * - `35675`: FLOAT_MAT3 + * - `35676`: FLOAT_MAT4 + * - `35678`: SAMPLER_2D + */ + type: + | 5124 + | 5126 + | 35664 + | 35665 + | 35666 + | 35667 + | 35668 + | 35669 + | 35670 + | 35671 + | 35672 + | 35673 + | 35674 + | 35675 + | 35676 + | 35678; + /** + * Identifies a uniform with a well-known meaning. Uniform semantics + * include `"LOCAL"` (FLOAT_MAT4), `"MODEL"` (FLOAT_MAT4), `"VIEW"` + * (FLOAT_MAT4), `"PROJECTION"` (FLOAT_MAT4), `"MODELVIEW"` (FLOAT_MAT4), + * `"MODELVIEWPROJECTION"` (FLOAT_MAT4), `"MODELINVERSE"` (FLOAT_MAT4), + * `"VIEWINVERSE"` (FLOAT_MAT4), `"PROJECTIONINVERSE"` (FLOAT_MAT4), + * `"MODELVIEWINVERSE"` (FLOAT_MAT4), `"MODELVIEWPROJECTIONINVERSE"` + * (FLOAT_MAT4), `"MODELINVERSETRANSPOSE"` (FLOAT_MAT3), + * `"MODELVIEWINVERSETRANSPOSE"` (FLOAT_MAT3), `"VIEWPORT"` (FLOAT_VEC4), + * `"JOINTMATRIX"` (FLOAT_MAT4[]). For forward-compatibility, + * application-specific semantics must start with an underscore, e.g., + * `"_SIMULATION_TIME"`. + */ + semantic?: string; + /** + * The value of the uniform. The length is determined by the values of the + * `type` and `count` (if present) properties. A material uniform value + * with the same name, when specified, overrides this value. + */ + value?: + number | boolean | number[] | boolean[] | Gltf2.Material.TextureInfo; + } + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/KHR_texture_basisu.ts b/packages/gltf/SchemaTypes/Extensions/KHR_texture_basisu.ts new file mode 100644 index 000000000000..6d882e553b0f --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/KHR_texture_basisu.ts @@ -0,0 +1,21 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Khronos/KHR_texture_basisu/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace KHR_texture_basisu { + /** + * glTF extension to specify textures using the KTX v2 images with Basis + * Universal supercompression. + */ + export interface Texture extends Gltf2.Property { + /** + * The index of the image which points to a KTX v2 resource with Basis + * Universal supercompression. + */ + source?: number; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/KHR_texture_transform.ts b/packages/gltf/SchemaTypes/Extensions/KHR_texture_transform.ts new file mode 100644 index 000000000000..c101c60cae8a --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/KHR_texture_transform.ts @@ -0,0 +1,40 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/2.0/Khronos/KHR_texture_transform/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { Gltf2 } from "../Gltf2.js"; + +/** @internal */ +export namespace KHR_texture_transform { + /** + * glTF extension that enables shifting and scaling UV coordinates on a + * per-texture basis + */ + export interface TextureInfo extends Gltf2.Property { + /** + * The offset of the UV coordinate origin as a factor of the texture + * dimensions. + * + * @default [0,0] + */ + offset?: [number, number]; + /** + * Rotate the UVs by this many radians counter-clockwise around the origin. + * + * @default 0 + */ + rotation?: number; + /** + * The scale factor applied to the components of the UV coordinates. + * + * @default [1,1] + */ + scale?: [number, number]; + /** + * Overrides the textureInfo texCoord value if supplied, and if this + * extension is supported. + */ + texCoord?: number; + } +} diff --git a/packages/gltf/SchemaTypes/Extensions/WEB3D_quantized_attributes.ts b/packages/gltf/SchemaTypes/Extensions/WEB3D_quantized_attributes.ts new file mode 100644 index 000000000000..9807c1f9b4f3 --- /dev/null +++ b/packages/gltf/SchemaTypes/Extensions/WEB3D_quantized_attributes.ts @@ -0,0 +1,24 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/extensions/1.0/Vendor/WEB3D_quantized_attributes/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +/** @internal */ +export namespace WEB3D_quantized_attributes { + export interface Accessor { + /** + * A homogenous floating-point transformation matrix stored in column-major + * order. This matrix is used to decode the compressed, quantized data of + * this accessor. + */ + decodeMatrix: number[]; + /** + * Maximum decoded value of each component in this attribute. + */ + decodedMax: number[]; + /** + * Minimum decoded value of each component in this attribute. + */ + decodedMin: number[]; + } +} diff --git a/packages/gltf/SchemaTypes/Gltf1.ts b/packages/gltf/SchemaTypes/Gltf1.ts new file mode 100644 index 000000000000..94f828b1fbd7 --- /dev/null +++ b/packages/gltf/SchemaTypes/Gltf1.ts @@ -0,0 +1,1234 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/specification/1.0/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { CESIUM_RTC } from "./Extensions/CESIUM_RTC.js"; +import type { KHR_binary_glTF } from "./Extensions/KHR_binary_glTF.js"; +import type { WEB3D_quantized_attributes } from "./Extensions/WEB3D_quantized_attributes.js"; + +/** + * The root object for a glTF asset. + * + * @internal + */ +export interface Gltf1 extends Gltf1.Property { + /** + * Names of extensions used somewhere in this asset. + * + * @default [] + */ + extensionsUsed?: string[]; + /** + * A dictionary object of accessors. The name of each accessor is an ID in the + * global glTF namespace that is used to reference the accessor. An accessor + * is a typed view into a bufferView. + * + * @default {} + */ + accessors?: Record; + /** + * A dictionary object of keyframe animations. The name of each animation is + * an ID in the global glTF namespace that is used to reference the animation. + * + * @default {} + */ + animations?: Record; + /** + * Metadata about the glTF asset. + * + * @default {} + */ + asset?: Gltf1.Asset; + /** + * A dictionary object of buffers. The name of each buffer is an ID in the + * global glTF namespace that is used to reference the buffer. A buffer points + * to binary geometry, animation, or skins. + * + * @default {} + */ + buffers?: Record; + /** + * A dictionary object of bufferViews. The name of each bufferView is an ID in + * the global glTF namespace that is used to reference the bufferView. A + * bufferView is a view into a buffer generally representing a subset of the + * buffer. + * + * @default {} + */ + bufferViews?: Record; + /** + * A dictionary object of cameras. The name of each camera is an ID in the + * global glTF namespace that is used to reference the camera. A camera + * defines a projection matrix. + * + * @default {} + */ + cameras?: Record; + /** + * A dictionary object of images. The name of each image is an ID in the + * global glTF namespace that is used to reference the image. An image defines + * data used to create a texture. + * + * @default {} + */ + images?: Record; + /** + * A dictionary object of materials. The name of each material is an ID in the + * global glTF namespace that is used to reference the material. A material + * defines the appearance of a primitive. + * + * @default {} + */ + materials?: Record; + /** + * A dictionary object of meshes. The name of each mesh is an ID in the global + * glTF namespace that is used to reference the mesh. A mesh is a set of + * primitives to be rendered. + * + * @default {} + */ + meshes?: Record; + /** + * A dictionary object of nodes in the node hierarchy. The name of each node + * is an ID in the global glTF namespace that is used to reference the node. + * + * @default {} + */ + nodes?: Record; + /** + * A dictionary object of shader programs. The name of each program is an ID + * in the global glTF namespace that is used to reference the program. + * + * @default {} + */ + programs?: Record; + /** + * A dictionary object of samplers. The name of each sampler is an ID in the + * global glTF namespace that is used to reference the sampler. A sampler + * contains properties for texture filtering and wrapping modes. + * + * @default {} + */ + samplers?: Record; + /** + * The ID of the default scene. + */ + scene?: string; + /** + * A dictionary object of scenes. The name of each scene is an ID in the + * global glTF namespace that is used to reference the scene. + * + * @default {} + */ + scenes?: Record; + /** + * A dictionary object of shaders. The name of each shader is an ID in the + * global glTF namespace that is used to reference the shader. + * + * @default {} + */ + shaders?: Record; + /** + * A dictionary object of skins. The name of each skin is an ID in the global + * glTF namespace that is used to reference the skin. A skin is defined by + * joints and matrices. + * + * @default {} + */ + skins?: Record; + /** + * A dictionary object of techniques. The name of each technique is an ID in + * the global glTF namespace that is used to reference the technique. A + * technique is a template for a material appearance. + * + * @default {} + */ + techniques?: Record; + /** + * A dictionary object of textures. The name of each texture is an ID in the + * global glTF namespace that is used to reference the texture. + * + * @default {} + */ + textures?: Record; + /** + * Dictionary object with extension-specific objects. + */ + extensions?: Gltf1.Extensions; +} +/** @internal */ +export namespace Gltf1 { + /** + * A typed view into a bufferView. A bufferView contains raw binary data. An + * accessor provides a typed view into a bufferView or a subset of a + * bufferView similar to how WebGL's `vertexAttribPointer()` defines an + * attribute in a buffer. + */ + export interface Accessor extends Gltf1.ChildOfRootProperty { + /** + * The ID of the bufferView. + */ + bufferView: string; + /** + * The offset relative to the start of the bufferView in bytes. This must be + * a multiple of the size of the data type. + */ + byteOffset: number; + /** + * The stride, in bytes, between attributes referenced by this accessor. + * When this is zero, the attributes are tightly packed. + * + * @default 0 + */ + byteStride?: number; + /** + * The datatype of components in the attribute. All valid values correspond + * to WebGL enums. The corresponding typed arrays are `Int8Array`, + * `Uint8Array`, `Int16Array`, `Uint16Array`, and `Float32Array`, + * respectively. + * + * Allowed values: + * + * - `5120`: BYTE + * - `5121`: UNSIGNED_BYTE + * - `5122`: SHORT + * - `5123`: UNSIGNED_SHORT + * - `5126`: FLOAT + */ + componentType: 5120 | 5121 | 5122 | 5123 | 5126; + /** + * The number of attributes referenced by this accessor, not to be confused + * with the number of bytes or number of components. + */ + count: number; + /** + * Specifies if the attribute is a scalar, vector, or matrix, and the number + * of elements in the vector or matrix. + * + * Allowed values: + * + * - `"SCALAR"` + * - `"VEC2"` + * - `"VEC3"` + * - `"VEC4"` + * - `"MAT2"` + * - `"MAT3"` + * - `"MAT4"` + */ + type: "SCALAR" | "VEC2" | "VEC3" | "VEC4" | "MAT2" | "MAT3" | "MAT4"; + /** + * Maximum value of each component in this attribute. When both min and max + * arrays are defined, they have the same length. The length is determined + * by the value of the type property; it can be 1, 2, 3, 4, 9, or 16. + */ + max?: number[]; + /** + * Minimum value of each component in this attribute. When both min and max + * arrays are defined, they have the same length. The length is determined + * by the value of the type property; it can be 1, 2, 3, 4, 9, or 16. + */ + min?: number[]; + /** + * Dictionary object with extension-specific objects. + */ + extensions?: Gltf1.Accessor.Extensions; + } + export namespace Accessor { + export interface Extensions extends Gltf1.Property.Extensions { + WEB3D_quantized_attributes?: WEB3D_quantized_attributes.Accessor; + } + } + /** + * A keyframe animation. + */ + export interface Animation extends Gltf1.ChildOfRootProperty { + /** + * An array of channels, each of which targets an animation's sampler at a + * node's property. + * + * @default [] + */ + channels?: Gltf1.Animation.Channel[]; + /** + * A dictionary object of strings whose values are IDs of accessors with + * keyframe data, e.g., time, translation, rotation, etc. + * + * @default {} + */ + parameters?: Record; + /** + * A dictionary object of samplers that combines input and output parameters + * with an interpolation algorithm to define a keyframe graph (but not its + * target). + * + * @default {} + */ + samplers?: Record; + } + export namespace Animation { + /** + * Targets an animation's sampler at a node's property. + */ + export interface Channel extends Gltf1.Property { + /** + * The ID of a sampler in this animation used to compute the value for the + * target, e.g., a node's translation, rotation, or scale (TRS). + */ + sampler: string; + /** + * The ID of the node and TRS property to target. + */ + target: Gltf1.Animation.Channel.Target; + } + export namespace Channel { + /** + * The ID of the node and TRS property that an animation channel targets. + */ + export interface Target extends Gltf1.Property { + /** + * The ID of the node to target. + */ + id: string; + /** + * The name of the node's TRS property to modify. + * + * Allowed values: + * + * - `"translation"` + * - `"rotation"` + * - `"scale"` + */ + path: "translation" | "rotation" | "scale"; + } + } + /** + * Combines input and output parameters with an interpolation algorithm to + * define a keyframe graph (but not its target). + */ + export interface Sampler extends Gltf1.Property { + /** + * The ID of a parameter in this animation to use as keyframe input. This + * parameter must have type `FLOAT`. The values represent time in seconds + * with `time[0] >= 0.0`, and monotonically increasing values, i.e., + * `time[n + 1] >= time[n]`. + */ + input: string; + /** + * Interpolation algorithm. When an animation targets a node's rotation, + * and the animation's interpolation is `"LINEAR"`, spherical linear + * interpolation (slerp) should be used to interpolate quaternions. + * + * Allowed values: + * + * - `"LINEAR"` + * + * @default "LINEAR" + */ + interpolation?: "LINEAR"; + /** + * The ID of a parameter in this animation to use as keyframe output. + */ + output: string; + } + } + /** + * Metadata about the glTF asset. + */ + export interface Asset extends Gltf1.Property { + /** + * A copyright message suitable for display to credit the content creator. + */ + copyright?: string; + /** + * Tool that generated this glTF model. Useful for debugging. + */ + generator?: string; + /** + * Specifies if the shaders were generated with premultiplied alpha. + * + * @default false + */ + premultipliedAlpha?: boolean; + /** + * Specifies the target rendering API and version, e.g., WebGL 1.0.3. + * + * @default {} + */ + profile?: Gltf1.Asset.Profile; + /** + * The glTF version. + */ + version: string; + } + export namespace Asset { + /** + * Specifies the target rendering API and version, e.g., WebGL 1.0.3. + */ + export interface Profile extends Gltf1.Property { + /** + * Specifies the target rendering API. + * + * @default "WebGL" + */ + api?: string; + /** + * The API version. + * + * @default "1.0.3" + */ + version?: string; + } + } + /** + * A buffer points to binary geometry, animation, or skins. + */ + export interface Buffer extends Gltf1.ChildOfRootProperty { + /** + * The uri of the buffer. Relative paths are relative to the .gltf file. + * Instead of referencing an external file, the uri can also be a data-uri. + */ + uri: string; + /** + * The length of the buffer in bytes. + * + * @default 0 + */ + byteLength?: number; + /** + * XMLHttpRequest `responseType`. + * + * Allowed values: + * + * - `"arraybuffer"` + * - `"text"` + * + * @default "arraybuffer" + */ + type?: "arraybuffer" | "text"; + } + /** + * A view into a buffer generally representing a subset of the buffer. + */ + export interface BufferView extends Gltf1.ChildOfRootProperty { + /** + * The ID of the buffer. + */ + buffer: string; + /** + * The offset into the buffer in bytes. + */ + byteOffset: number; + /** + * The length of the bufferView in bytes. + * + * @default 0 + */ + byteLength?: number; + /** + * The target that the WebGL buffer should be bound to. All valid values + * correspond to WebGL enums. When this is not provided, the bufferView + * contains animation or skin data. + * + * Allowed values: + * + * - `34962`: ARRAY_BUFFER + * - `34963`: ELEMENT_ARRAY_BUFFER + */ + target?: 34962 | 34963; + } + /** + * A camera's projection. A node can reference a camera ID to apply a + * transform to place the camera in the scene. + */ + export interface Camera extends Gltf1.ChildOfRootProperty { + /** + * An orthographic camera containing properties to create an orthographic + * projection matrix. + */ + orthographic?: Gltf1.Camera.Orthographic; + /** + * A perspective camera containing properties to create a perspective + * projection matrix. + */ + perspective?: Gltf1.Camera.Perspective; + /** + * Specifies if the camera uses a perspective or orthographic projection. + * Based on this, either the camera's `perspective` or `orthographic` + * property will be defined. + * + * Allowed values: + * + * - `"perspective"` + * - `"orthographic"` + */ + type: "perspective" | "orthographic"; + } + export namespace Camera { + /** + * An orthographic camera containing properties to create an orthographic + * projection matrix. + */ + export interface Orthographic extends Gltf1.Property { + /** + * The floating-point horizontal magnification of the view. + */ + xmag: number; + /** + * The floating-point vertical magnification of the view. + */ + ymag: number; + /** + * The floating-point distance to the far clipping plane. + */ + zfar: number; + /** + * The floating-point distance to the near clipping plane. + */ + znear: number; + } + /** + * A perspective camera containing properties to create a perspective + * projection matrix. + */ + export interface Perspective extends Gltf1.Property { + /** + * The floating-point aspect ratio of the field of view. When this is + * undefined, the aspect ratio of the canvas is used. + */ + aspectRatio?: number; + /** + * The floating-point vertical field of view in radians. + */ + yfov: number; + /** + * The floating-point distance to the far clipping plane. zfar must be + * greater than znear. + */ + zfar: number; + /** + * The floating-point distance to the near clipping plane. zfar must be + * greater than znear. + */ + znear: number; + } + } + export interface Extensions extends Gltf1.Property.Extensions { + /** + * glTF CESIUM_RTC extension. + */ + CESIUM_RTC?: CESIUM_RTC; + } + export interface ChildOfRootProperty extends Gltf1.Property { + /** + * The user-defined name of this object. This is not necessarily unique, + * e.g., an accessor and a buffer could have the same name, or two accessors + * could even have the same name. + */ + name?: string; + } + export interface Property { + /** + * Application-specific data. + */ + extras?: unknown; + /** + * Dictionary object with extension-specific objects. + */ + extensions?: Gltf1.Property.Extensions; + } + export namespace Property { + export interface Extensions { + [name: string]: unknown; + } + } + /** + * Image data used to create a texture. + */ + export interface Image extends Gltf1.ChildOfRootProperty { + /** + * The uri of the image. Relative paths are relative to the .gltf file. + * Instead of referencing an external file, the uri can also be a data-uri. + * The image format must be jpg, png, bmp, or gif. + */ + uri: string; + /** + * Dictionary object with extension-specific objects. + */ + extensions?: Gltf1.Image.Extensions; + } + export namespace Image { + export interface Extensions extends Gltf1.Property.Extensions { + KHR_binary_glTF?: KHR_binary_glTF.Image; + } + } + /** + * The material appearance of a primitive. + */ + export interface Material extends Gltf1.ChildOfRootProperty { + /** + * The ID of the technique. If this is not supplied, and no extension is + * present that defines material properties, then the primitive should be + * rendered using a default material with 50% gray emissive color. + */ + technique?: string; + /** + * A dictionary object of parameter values. Parameters with the same name as + * the technique's parameter override the technique's parameter value. + * + * @default {} + */ + values?: Record< + string, + number | boolean | string | (number | boolean | string)[] + >; + } + /** + * A set of primitives to be rendered. A node can contain one or more meshes. + * A node's transform places the mesh in the scene. + */ + export interface Mesh extends Gltf1.ChildOfRootProperty { + /** + * An array of primitives, each defining geometry to be rendered with a + * material. + * + * @default [] + */ + primitives?: Gltf1.Mesh.Primitive[]; + } + export namespace Mesh { + /** + * Geometry to be rendered with the given material. + */ + export interface Primitive extends Gltf1.Property { + /** + * A dictionary object of strings, where each string is the ID of the + * accessor containing an attribute. + * + * @default {} + */ + attributes?: Record; + /** + * The ID of the accessor that contains the indices. When this is not + * defined, the primitives should be rendered without indices using + * `drawArrays()`. When defined, the accessor must contain indices: the + * bufferView referenced by the accessor must have a target equal to 34963 + * (ELEMENT_ARRAY_BUFFER); a byteStride that is tightly packed, i.e., 0 or + * the byte size of componentType in bytes; componentType must be 5121 + * (UNSIGNED_BYTE) or 5123 (UNSIGNED_SHORT); and type must be "SCALAR". + */ + indices?: string; + /** + * The ID of the material to apply to this primitive when rendering. + */ + material: string; + /** + * The type of primitives to render. All valid values correspond to WebGL + * enums. + * + * Allowed values: + * + * - `0`: POINTS + * - `1`: LINES + * - `2`: LINE_LOOP + * - `3`: LINE_STRIP + * - `4`: TRIANGLES + * - `5`: TRIANGLE_STRIP + * - `6`: TRIANGLE_FAN + * + * @default 4 + */ + mode?: 0 | 1 | 2 | 3 | 4 | 5 | 6; + } + } + /** + * A node in the node hierarchy. A node can have either the `camera`, + * `meshes`, or `skeletons`/`skin`/`meshes` properties defined. In the later + * case, all `primitives` in the referenced `meshes` contain `JOINT` and + * `WEIGHT` attributes and the referenced `material`/`technique` from each + * `primitive` has parameters with `JOINT` and `WEIGHT` semantics. A node can + * have either a `matrix` or any combination of + * `translation`/`rotation`/`scale` (TRS) properties. TRS properties are + * converted to matrices and postmultiplied in the `T * R * S` order to + * compose the transformation matrix; first the scale is applied to the + * vertices, then the rotation, and then the translation. If none are + * provided, the transform is the identity. When a node is targeted for + * animation (referenced by an animation.channel.target), only TRS properties + * may be present; `matrix` will not be present. + */ + export interface Node extends Gltf1.ChildOfRootProperty { + /** + * The ID of the camera referenced by this node. + */ + camera?: string; + /** + * The IDs of this node's children. + * + * @default [] + */ + children?: string[]; + /** + * The ID of skeleton nodes. Each node defines a subtree, which has a + * `jointName` of the corresponding element in the referenced + * `skin.jointNames`. + */ + skeletons?: string[]; + /** + * The ID of the skin referenced by this node. + */ + skin?: string; + /** + * Name used when this node is a joint in a skin. + */ + jointName?: string; + /** + * A floating-point 4x4 transformation matrix stored in column-major order. + * + * @default [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1] + */ + matrix?: number[]; + /** + * The IDs of the meshes in this node. Multiple meshes are allowed so each + * can share the same transform matrix. + */ + meshes?: string[]; + /** + * The node's unit quaternion rotation in the order (x, y, z, w), where w is + * the scalar. + * + * @default [0,0,0,1] + */ + rotation?: [number, number, number, number]; + /** + * The node's non-uniform scale. + * + * @default [1,1,1] + */ + scale?: [number, number, number]; + /** + * The node's translation. + * + * @default [0,0,0] + */ + translation?: [number, number, number]; + } + /** + * A shader program, including its vertex and fragment shader, and names of + * vertex shader attributes. + */ + export interface Program extends Gltf1.ChildOfRootProperty { + /** + * Names of GLSL vertex shader attributes. + * + * @default [] + */ + attributes?: string[]; + /** + * The ID of the fragment shader. + */ + fragmentShader: string; + /** + * The ID of the vertex shader. + */ + vertexShader: string; + } + /** + * Texture sampler properties for filtering and wrapping modes. + */ + export interface Sampler extends Gltf1.ChildOfRootProperty { + /** + * Magnification filter. Valid values correspond to WebGL enums: `9728` + * (NEAREST) and `9729` (LINEAR). + * + * Allowed values: + * + * - `9728`: NEAREST + * - `9729`: LINEAR + * + * @default 9729 + */ + magFilter?: 9728 | 9729; + /** + * Minification filter. All valid values correspond to WebGL enums. + * + * Allowed values: + * + * - `9728`: NEAREST + * - `9729`: LINEAR + * - `9984`: NEAREST_MIPMAP_NEAREST + * - `9985`: LINEAR_MIPMAP_NEAREST + * - `9986`: NEAREST_MIPMAP_LINEAR + * - `9987`: LINEAR_MIPMAP_LINEAR + * + * @default 9986 + */ + minFilter?: 9728 | 9729 | 9984 | 9985 | 9986 | 9987; + /** + * s wrapping mode. All valid values correspond to WebGL enums. + * + * Allowed values: + * + * - `33071`: CLAMP_TO_EDGE + * - `33648`: MIRRORED_REPEAT + * - `10497`: REPEAT + * + * @default 10497 + */ + wrapS?: 33071 | 33648 | 10497; + /** + * t wrapping mode. All valid values correspond to WebGL enums. + * + * Allowed values: + * + * - `33071`: CLAMP_TO_EDGE + * - `33648`: MIRRORED_REPEAT + * - `10497`: REPEAT + * + * @default 10497 + */ + wrapT?: 33071 | 33648 | 10497; + } + /** + * The root nodes of a scene. + */ + export interface Scene extends Gltf1.ChildOfRootProperty { + /** + * The IDs of each root node. + * + * @default [] + */ + nodes?: string[]; + } + /** + * A vertex or fragment shader. + */ + export interface Shader extends Gltf1.ChildOfRootProperty { + /** + * The uri of the GLSL source. Relative paths are relative to the .gltf + * file. Instead of referencing an external file, the uri can also be a + * data-uri. + */ + uri: string; + /** + * The shader stage. All valid values correspond to WebGL enums. + * + * Allowed values: + * + * - `35632`: FRAGMENT_SHADER + * - `35633`: VERTEX_SHADER + */ + type: 35632 | 35633; + /** + * Dictionary object with extension-specific objects. + */ + extensions?: Gltf1.Shader.Extensions; + } + export namespace Shader { + export interface Extensions extends Gltf1.Property.Extensions { + KHR_binary_glTF?: KHR_binary_glTF.Shader; + } + } + /** + * Joints and matrices defining a skin. + */ + export interface Skin extends Gltf1.ChildOfRootProperty { + /** + * Floating-point 4x4 transformation matrix stored in column-major order. + * + * @default [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1] + */ + bindShapeMatrix?: number[]; + /** + * The ID of the accessor containing the floating-point 4x4 inverse-bind + * matrices. + */ + inverseBindMatrices: string; + /** + * Joint names of the joints (nodes with a `jointName` property) in this + * skin. The array length is the same as the `count` property of the + * `inverseBindMatrices` accessor, and the same as the total quantity of all + * skeleton nodes from node-trees referenced by the skinned mesh instance + * node's `skeletons` array. + */ + jointNames: string[]; + } + /** + * A template for material appearances. + */ + export interface Technique extends Gltf1.ChildOfRootProperty { + /** + * A dictionary object of technique.parameters objects. Each parameter + * defines an attribute or uniform input, and an optional semantic and + * value. + * + * @default {} + */ + parameters?: Record; + /** + * A dictionary object of strings that maps GLSL attribute names to + * technique parameter IDs. + * + * @default {} + */ + attributes?: Record; + /** + * The ID of the program. + */ + program: string; + /** + * A dictionary object of strings that maps GLSL uniform names to technique + * parameter IDs. + * + * @default {} + */ + uniforms?: Record; + /** + * Fixed-function rendering states. + * + * @default {} + */ + states?: Gltf1.Technique.States; + } + export namespace Technique { + /** + * An attribute or uniform input to a technique, and an optional semantic + * and value. + */ + export interface Parameters extends Gltf1.Property { + /** + * When defined, the parameter is an array of count elements of the + * specified type. Otherwise, the parameter is not an array. When defined, + * `value` is an array with length equal to count, times the number of + * components in the type, e.g., `3` for `FLOAT_VEC3`. An array parameter + * of scalar values is not the same as a vector parameter of the same + * size; for example, when count is 2 and type is 5126 (FLOAT), the + * parameter is an array of two floating-point values, not a FLOAT_VEC2. + */ + count?: number; + /** + * The id of the node whose transform is used as the parameter's value. + * When this is defined, `type` must be `35676` (FLOAT_MAT4), therefore, + * when the semantic is "MODELINVERSETRANSPOSE", + * "MODELVIEWINVERSETRANSPOSE", or "VIEWPORT", the node property can't be + * defined. + */ + node?: string; + /** + * The datatype. All valid values correspond to WebGL enums. + * + * Allowed values: + * + * - `5120`: BYTE + * - `5121`: UNSIGNED_BYTE + * - `5122`: SHORT + * - `5123`: UNSIGNED_SHORT + * - `5124`: INT + * - `5125`: UNSIGNED_INT + * - `5126`: FLOAT + * - `35664`: FLOAT_VEC2 + * - `35665`: FLOAT_VEC3 + * - `35666`: FLOAT_VEC4 + * - `35667`: INT_VEC2 + * - `35668`: INT_VEC3 + * - `35669`: INT_VEC4 + * - `35670`: BOOL + * - `35671`: BOOL_VEC2 + * - `35672`: BOOL_VEC3 + * - `35673`: BOOL_VEC4 + * - `35674`: FLOAT_MAT2 + * - `35675`: FLOAT_MAT3 + * - `35676`: FLOAT_MAT4 + * - `35678`: SAMPLER_2D + */ + type: + | 5120 + | 5121 + | 5122 + | 5123 + | 5124 + | 5125 + | 5126 + | 35664 + | 35665 + | 35666 + | 35667 + | 35668 + | 35669 + | 35670 + | 35671 + | 35672 + | 35673 + | 35674 + | 35675 + | 35676 + | 35678; + /** + * Identifies a parameter with a well-known meaning. Uniform semantics + * include `"LOCAL"` (FLOAT_MAT4), `"MODEL"` (FLOAT_MAT4), `"VIEW"` + * (FLOAT_MAT4), `"PROJECTION"` (FLOAT_MAT4), `"MODELVIEW"` (FLOAT_MAT4), + * `"MODELVIEWPROJECTION"` (FLOAT_MAT4), `"MODELINVERSE"` (FLOAT_MAT4), + * `"VIEWINVERSE"` (FLOAT_MAT4), `"PROJECTIONINVERSE"` (FLOAT_MAT4), + * `"MODELVIEWINVERSE"` (FLOAT_MAT4), `"MODELVIEWPROJECTIONINVERSE"` + * (FLOAT_MAT4), `"MODELINVERSETRANSPOSE"` (FLOAT_MAT3), + * `"MODELVIEWINVERSETRANSPOSE"` (FLOAT_MAT3), `"VIEWPORT"` (FLOAT_VEC4), + * `"JOINTMATRIX"` (FLOAT_MAT4). Attribute semantics include `"POSITION"`, + * `"NORMAL"`, `"TEXCOORD"`, `"COLOR"`, `"JOINT"`, and `"WEIGHT"`. + * Attribute semantic property names can be of the form + * `[semantic]_[set_index]`, e.g., `"TEXCOORD_0"`. + */ + semantic?: string; + /** + * The value of the parameter. A material value with the same name, when + * specified, overrides this value. + */ + value?: number | boolean | string | (number | boolean | string)[]; + } + /** + * Fixed-function rendering states. + */ + export interface States extends Gltf1.Property { + /** + * WebGL states to enable. States not in the array are disabled. All valid + * values correspond to WebGL enums. + * + * Allowed values for each element: + * + * - `3042`: BLEND + * - `2884`: CULL_FACE + * - `2929`: DEPTH_TEST + * - `32823`: POLYGON_OFFSET_FILL + * - `32926`: SAMPLE_ALPHA_TO_COVERAGE + * - `3089`: SCISSOR_TEST + * + * @default [] + */ + enable?: (3042 | 2884 | 2929 | 32823 | 32926 | 3089)[]; + /** + * Arguments for fixed-function rendering state functions other than + * `enable()`/`disable()`. + */ + functions?: Gltf1.Technique.States.Functions; + } + export namespace States { + /** + * Arguments for fixed-function rendering state functions other than + * `enable()`/`disable()`. + */ + export interface Functions extends Gltf1.Property { + /** + * Floating-point values passed to `blendColor()`. [red, green, blue, + * alpha] + * + * @default [0,0,0,0] + */ + blendColor?: [number, number, number, number]; + /** + * Integer values passed to `blendEquationSeparate()`. [rgb, alpha]. All + * valid values correspond to WebGL enums. + * + * Allowed values for each element: + * + * - `32774`: FUNC_ADD + * - `32778`: FUNC_SUBTRACT + * - `32779`: FUNC_REVERSE_SUBTRACT + * + * @default [32774,32774] + */ + blendEquationSeparate?: (32774 | 32778 | 32779)[]; + /** + * Integer values passed to `blendFuncSeparate()`. [srcRGB, dstRGB, + * srcAlpha, dstAlpha]. All valid values correspond to WebGL enums. + * + * Allowed values for each element: + * + * - `0`: ZERO + * - `1`: ONE + * - `768`: SRC_COLOR + * - `769`: ONE_MINUS_SRC_COLOR + * - `774`: DST_COLOR + * - `775`: ONE_MINUS_DST_COLOR + * - `770`: SRC_ALPHA + * - `771`: ONE_MINUS_SRC_ALPHA + * - `772`: DST_ALPHA + * - `773`: ONE_MINUS_DST_ALPHA + * - `32769`: CONSTANT_COLOR + * - `32770`: ONE_MINUS_CONSTANT_COLOR + * - `32771`: CONSTANT_ALPHA + * - `32772`: ONE_MINUS_CONSTANT_ALPHA + * - `776`: SRC_ALPHA_SATURATE + * + * @default [1,0,1,0] + */ + blendFuncSeparate?: ( + | 0 + | 1 + | 768 + | 769 + | 774 + | 775 + | 770 + | 771 + | 772 + | 773 + | 32769 + | 32770 + | 32771 + | 32772 + | 776 + )[]; + /** + * Boolean values passed to `colorMask()`. [red, green, blue, alpha]. + * + * @default [true,true,true,true] + */ + colorMask?: [boolean, boolean, boolean, boolean]; + /** + * Integer value passed to `cullFace()`. All valid values correspond to + * WebGL enums. + * + * Allowed values for each element: + * + * - `1028`: FRONT + * - `1029`: BACK + * - `1032`: FRONT_AND_BACK + * + * @default [1029] + */ + cullFace?: (1028 | 1029 | 1032)[]; + /** + * Integer values passed to `depthFunc()`. All valid values correspond + * to WebGL enums. + * + * Allowed values for each element: + * + * - `512`: NEVER + * - `513`: LESS + * - `515`: LEQUAL + * - `514`: EQUAL + * - `516`: GREATER + * - `517`: NOTEQUAL + * - `518`: GEQUAL + * - `519`: ALWAYS + * + * @default [513] + */ + depthFunc?: (512 | 513 | 515 | 514 | 516 | 517 | 518 | 519)[]; + /** + * Boolean value passed to `depthMask()`. + * + * @default [true] + */ + depthMask?: [boolean]; + /** + * Floating-point values passed to `depthRange()`. [zNear, zFar] + * + * @default [0,1] + */ + depthRange?: [number, number]; + /** + * Integer value passed to `frontFace()`. All valid values correspond to + * WebGL enums. + * + * Allowed values for each element: + * + * - `2304`: CW + * - `2305`: CCW + * + * @default [2305] + */ + frontFace?: (2304 | 2305)[]; + /** + * Floating-point value passed to `lineWidth()`. + * + * @default [1] + */ + lineWidth?: [number]; + /** + * Floating-point value passed to `polygonOffset()`. [factor, units] + * + * @default [0,0] + */ + polygonOffset?: [number, number]; + /** + * Floating-point value passed to `scissor()`. [x, y, width, height]. + * The default is the dimensions of the canvas when the WebGL context is + * created. width and height must be greater than zero. + * + * @default [0,0,0,0] + */ + scissor?: [number, number, number, number]; + } + } + } + /** + * A texture and its sampler. + */ + export interface Texture extends Gltf1.ChildOfRootProperty { + /** + * The texture's format. Valid values correspond to WebGL enums: `6406` + * (ALPHA), `6407` (RGB), `6408` (RGBA), `6409` (LUMINANCE), and `6410` + * (LUMINANCE_ALPHA). + * + * Allowed values: + * + * - `6406`: ALPHA + * - `6407`: RGB + * - `6408`: RGBA + * - `6409`: LUMINANCE + * - `6410`: LUMINANCE_ALPHA + * + * @default 6408 + */ + format?: 6406 | 6407 | 6408 | 6409 | 6410; + /** + * The texture's internal format. Valid values correspond to WebGL enums: + * `6406` (ALPHA), `6407` (RGB), `6408` (RGBA), `6409` (LUMINANCE), and + * `6410` (LUMINANCE_ALPHA). Defaults to same value as format. + * + * Allowed values: + * + * - `6406`: ALPHA + * - `6407`: RGB + * - `6408`: RGBA + * - `6409`: LUMINANCE + * - `6410`: LUMINANCE_ALPHA + * + * @default 6408 + */ + internalFormat?: 6406 | 6407 | 6408 | 6409 | 6410; + /** + * The ID of the sampler used by this texture. + */ + sampler: string; + /** + * The ID of the image used by this texture. + */ + source: string; + /** + * The target that the WebGL texture should be bound to. Valid values + * correspond to WebGL enums: `3553` (TEXTURE_2D). + * + * Allowed values: + * + * - `3553`: TEXTURE_2D + * + * @default 3553 + */ + target?: 3553; + /** + * Texel datatype. Valid values correspond to WebGL enums: `5121` + * (UNSIGNED_BYTE), `33635` (UNSIGNED_SHORT_5_6_5), `32819` + * (UNSIGNED_SHORT_4_4_4_4), and `32820` (UNSIGNED_SHORT_5_5_5_1). + * + * Allowed values: + * + * - `5121`: UNSIGNED_BYTE + * - `33635`: UNSIGNED_SHORT_5_6_5 + * - `32819`: UNSIGNED_SHORT_4_4_4_4 + * - `32820`: UNSIGNED_SHORT_5_5_5_1 + * + * @default 5121 + */ + type?: 5121 | 33635 | 32819 | 32820; + } +} diff --git a/packages/gltf/SchemaTypes/Gltf2.ts b/packages/gltf/SchemaTypes/Gltf2.ts new file mode 100644 index 000000000000..47840cf9415a --- /dev/null +++ b/packages/gltf/SchemaTypes/Gltf2.ts @@ -0,0 +1,1502 @@ +// Generated from the glTF JSON schemas at: +// https://github.com/KhronosGroup/glTF/tree/da88a3bbbe168cc728eddf71fa5e1915cc2c0629/specification/2.0/schema +// https://github.com/KhronosGroup/glTF/tree/c330f9e5a324c9858145be183d2a1e63718fd3e8/specification/2.1/schema +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +import type { _3DTILES_implicit_tiling } from "./Extensions/3DTILES_implicit_tiling.js"; +import type { _3DTILES_subtree } from "./Extensions/3DTILES_subtree.js"; +import type { _3DTILES_tileset } from "./Extensions/3DTILES_tileset.js"; +import type { _3DTILES_tileset_voxels } from "./Extensions/3DTILES_tileset_voxels.js"; +import type { AGI_articulations } from "./Extensions/AGI_articulations.js"; +import type { BENTLEY_materials_line_style } from "./Extensions/BENTLEY_materials_line_style.js"; +import type { BENTLEY_materials_planar_fill } from "./Extensions/BENTLEY_materials_planar_fill.js"; +import type { BENTLEY_materials_point_style } from "./Extensions/BENTLEY_materials_point_style.js"; +import type { CESIUM_primitive_outline } from "./Extensions/CESIUM_primitive_outline.js"; +import type { CESIUM_RTC } from "./Extensions/CESIUM_RTC.js"; +import type { CESIUM_tile_edges } from "./Extensions/CESIUM_tile_edges.js"; +import type { EXT_feature_metadata } from "./Extensions/EXT_feature_metadata.js"; +import type { EXT_geospatial_crs } from "./Extensions/EXT_geospatial_crs.js"; +import type { EXT_instance_features } from "./Extensions/EXT_instance_features.js"; +import type { EXT_mesh_features } from "./Extensions/EXT_mesh_features.js"; +import type { EXT_mesh_gpu_instancing } from "./Extensions/EXT_mesh_gpu_instancing.js"; +import type { EXT_mesh_polygon } from "./Extensions/EXT_mesh_polygon.js"; +import type { EXT_mesh_primitive_edge_visibility } from "./Extensions/EXT_mesh_primitive_edge_visibility.js"; +import type { EXT_mesh_primitive_restart } from "./Extensions/EXT_mesh_primitive_restart.js"; +import type { EXT_meshopt_compression } from "./Extensions/EXT_meshopt_compression.js"; +import type { EXT_primitive_voxels } from "./Extensions/EXT_primitive_voxels.js"; +import type { EXT_structural_metadata } from "./Extensions/EXT_structural_metadata.js"; +import type { EXT_texture_webp } from "./Extensions/EXT_texture_webp.js"; +import type { EXT_textureInfo_constant_lod } from "./Extensions/EXT_textureInfo_constant_lod.js"; +import type { EXT_voxels } from "./Extensions/EXT_voxels.js"; +import type { KHR_draco_mesh_compression } from "./Extensions/KHR_draco_mesh_compression.js"; +import type { KHR_gaussian_splatting } from "./Extensions/KHR_gaussian_splatting.js"; +import type { KHR_implicit_shapes } from "./Extensions/KHR_implicit_shapes.js"; +import type { KHR_materials_anisotropy } from "./Extensions/KHR_materials_anisotropy.js"; +import type { KHR_materials_clearcoat } from "./Extensions/KHR_materials_clearcoat.js"; +import type { KHR_materials_emissive_strength } from "./Extensions/KHR_materials_emissive_strength.js"; +import type { KHR_materials_pbrSpecularGlossiness } from "./Extensions/KHR_materials_pbrSpecularGlossiness.js"; +import type { KHR_materials_specular } from "./Extensions/KHR_materials_specular.js"; +import type { KHR_materials_transmission } from "./Extensions/KHR_materials_transmission.js"; +import type { KHR_materials_unlit } from "./Extensions/KHR_materials_unlit.js"; +import type { KHR_meshopt_compression } from "./Extensions/KHR_meshopt_compression.js"; +import type { KHR_node_visibility } from "./Extensions/KHR_node_visibility.js"; +import type { KHR_spz_gaussian_splats_compression } from "./Extensions/KHR_spz_gaussian_splats_compression.js"; +import type { KHR_techniques_webgl } from "./Extensions/KHR_techniques_webgl.js"; +import type { KHR_texture_basisu } from "./Extensions/KHR_texture_basisu.js"; +import type { KHR_texture_transform } from "./Extensions/KHR_texture_transform.js"; +import type { WEB3D_quantized_attributes } from "./Extensions/WEB3D_quantized_attributes.js"; + +/** + * The root object for a glTF asset. + * + * @internal + */ +export interface Gltf2 extends Gltf2.Property { + /** + * An array of accessors. + */ + accessors?: Gltf2.Accessor[]; + /** + * An array of animations. + */ + animations?: Gltf2.Animation[]; + /** + * Metadata about the glTF asset. + */ + asset: Gltf2.Asset; + /** + * An array of buffer views. + */ + bufferViews?: Gltf2.BufferView[]; + /** + * An array of buffers. + */ + buffers?: Gltf2.Buffer[]; + /** + * An array of cameras. + */ + cameras?: Gltf2.Camera[]; + /** + * Names of glTF extensions required to properly load the asset. + */ + extensionsRequired?: string[]; + /** + * Names of glTF extensions used in the asset. + */ + extensionsUsed?: string[]; + /** + * An array of external assets. (glTF 2.1) + */ + externalAssets?: Gltf2.ExternalAsset[]; + /** + * An array of file references. (glTF 2.1) + */ + files?: Gltf2.File[]; + /** + * An array of images. + */ + images?: Gltf2.Image[]; + /** + * An array of materials. + */ + materials?: Gltf2.Material[]; + /** + * An array of meshes. + */ + meshes?: Gltf2.Mesh[]; + /** + * An array of nodes. + */ + nodes?: Gltf2.Node[]; + /** + * An array of samplers. + */ + samplers?: Gltf2.Sampler[]; + /** + * The index of the default scene. + */ + scene?: number; + /** + * An array of scenes. + */ + scenes?: Gltf2.Scene[]; + /** + * An array of shapes. (glTF 2.1) + */ + shapes?: Gltf2.Shape[]; + /** + * An array of skins. + */ + skins?: Gltf2.Skin[]; + /** + * An array of textures. + */ + textures?: Gltf2.Texture[]; + /** + * A dictionary mapping file-unique IDs to objects that contain a JSON + * pointer. (glTF 2.1) + */ + uniqueIds?: Record< + string, + Gltf2.Property & { + /** + * JSON pointer to an existing element within the same glTF asset. + */ + pointer: string; + } + >; + /** + * JSON object with extension objects. Property names correspond to glTF + * extension names and property values are extension-specific objects. + */ + extensions?: Gltf2.Extensions; +} +/** @internal */ +export namespace Gltf2 { + /** + * Descriptor of a finite non-empty sequence of typed values usually sourced + * from a buffer view. + */ + export interface Accessor extends Gltf2.ChildOfRootProperty { + /** + * The index of the buffer view. When undefined, elements are sourced from + * an infinite sequence of zero bytes or provided by an extension. + */ + bufferView?: number; + /** + * The offset into the buffer view in bytes. + * + * @default 0 + */ + byteOffset?: number; + /** + * The data type of the accessor's components. + * + * Allowed values: + * + * - `5120`: 8-bit signed integer (sint8) or 8-bit signed normalized integer + * (snorm8). + * - `5121`: 8-bit unsigned integer (uint8) or 8-bit unsigned normalized + * integer (unorm8). + * - `5122`: 16-bit signed integer (sint16) or 16-bit signed normalized + * integer (snorm16). + * - `5123`: 16-bit unsigned integer (uint16) or 16-bit unsigned normalized + * integer (unorm16). + * - `5124`: 32-bit signed integer (sint32). (glTF 2.1) + * - `5125`: 32-bit unsigned integer (uint32). + * - `5126`: 32-bit floating-point number (float32) in IEEE 754 + * single-precision format (binary32). + * - `5130`: 64-bit floating-point number (float64) in IEEE 754 + * double-precision format (binary64). (glTF 2.1) + * - `5131`: 16-bit floating-point number (float16) in IEEE 754 + * half-precision format (binary16). (glTF 2.1) + * - `5134`: 64-bit signed integer (sint64). (glTF 2.1) + * - `5135`: 64-bit unsigned integer (uint64). (glTF 2.1) + */ + componentType: number; + /** + * The number of elements provided by the accessor. + */ + count: number; + /** + * Maximum value of each component as provided by the accessor. Array length + * corresponds to the accessor's type. + */ + max?: number[]; + /** + * Minimum value of each component as provided by the accessor. Array length + * corresponds to the accessor's type. + */ + min?: number[]; + /** + * Specifies whether integer values are normalized (divided by the component + * type's maximum possible value) before usage. + * + * @default false + */ + normalized?: boolean; + /** + * The descriptor of sparsely-encoded accessor elements. + */ + sparse?: Gltf2.Accessor.Sparse; + /** + * The dimensionality of the accessor elements. + * + * Allowed values: + * + * - `"SCALAR"`: Scalar + * - `"VEC2"`: Two-component Vector + * - `"VEC3"`: Three-component Vector + * - `"VEC4"`: Four-component Vector + * - `"MAT2"`: 2x2 Matrix + * - `"MAT3"`: 3x3 Matrix + * - `"MAT4"`: 4x4 Matrix + */ + type: string; + /** + * JSON object with extension objects. Property names correspond to glTF + * extension names and property values are extension-specific objects. + */ + extensions?: Gltf2.Accessor.Extensions; + } + export namespace Accessor { + export interface Extensions extends Gltf2.Property.Extensions { + WEB3D_quantized_attributes?: WEB3D_quantized_attributes.Accessor; + } + /** + * The descriptor of sparsely-encoded accessor elements. + */ + export interface Sparse extends Gltf2.Property { + /** + * The number of replaced accessor elements. + */ + count: number; + /** + * The descriptor of the indices of replaced accessor elements. + */ + indices: Gltf2.Accessor.Sparse.Indices; + /** + * The descriptor of the source of replacement elements. + */ + values: Gltf2.Accessor.Sparse.Values; + } + export namespace Sparse { + /** + * The descriptor of the indices of replaced accessor elements. + */ + export interface Indices extends Gltf2.Property { + /** + * The index of the buffer view containing the indices of the replaced + * elements. + */ + bufferView: number; + /** + * The offset into the buffer view in bytes. + * + * @default 0 + */ + byteOffset?: number; + /** + * The data type of the indices of the replaced elements. + * + * Allowed values: + * + * - `5121`: 8-bit unsigned integer (uint8). + * - `5123`: 16-bit unsigned integer (uint16). + * - `5125`: 32-bit unsigned integer (uint32). + */ + componentType: number; + } + /** + * The descriptor of the source of replacement elements. + */ + export interface Values extends Gltf2.Property { + /** + * The index of the buffer view containing replacement accessor + * elements. + */ + bufferView: number; + /** + * The offset into the buffer view in bytes. + * + * @default 0 + */ + byteOffset?: number; + } + } + } + /** + * Descriptors of the animated properties (channels) and their keyframe data + * (samplers). + */ + export interface Animation extends Gltf2.ChildOfRootProperty { + /** + * An array of animation channels. + */ + channels: Gltf2.Animation.Channel[]; + /** + * An array of animation samplers. + */ + samplers: Gltf2.Animation.Sampler[]; + } + export namespace Animation { + /** + * The descriptor of the animated property combined with the sampler + * providing its keyframe data. + */ + export interface Channel extends Gltf2.Property { + /** + * The index of the animation sampler. + */ + sampler: number; + /** + * The descriptor of the animated property. + */ + target: Gltf2.Animation.Channel.Target; + } + export namespace Channel { + /** + * The descriptor of the animated property. + */ + export interface Target extends Gltf2.Property { + /** + * The index of the node containing the animated property. When + * undefined, the target is defined by other means. + */ + node?: number; + /** + * The identifier of the animated property, such as the property name. + * + * Allowed values: + * + * - `"rotation"`: Rotation + * - `"scale"`: Scale + * - `"translation"`: Translation + * - `"weights"`: Weights + */ + path: string; + } + } + /** + * Combination of timestamps, keyframe data, and the interpolation mode. + */ + export interface Sampler extends Gltf2.Property { + /** + * The index of the accessor providing keyframe timestamps. + */ + input: number; + /** + * Interpolation mode used to compute animated property values between + * keyframes. + * + * Allowed values: + * + * - `"CUBICSPLINE"`: Values between the keyframes are interpolated using + * Hermite cubic splines. + * - `"LINEAR"`: Values between the keyframes are interpolated linearly. + * Rotation values use spherical linear interpolation. + * - `"STEP"`: Values between the keyframes are equal to the output of the + * last played keyframe. + * + * @default "LINEAR" + */ + interpolation?: string; + /** + * The index of the accessor providing keyframe property values and + * additional values as needed by the interpolation mode. + */ + output: number; + } + } + /** + * Metadata about the glTF asset. + */ + export interface Asset extends Gltf2.Property { + /** + * The copyright message suitable for display to credit the content creator. + */ + copyright?: string; + /** + * The tool used to generate the asset. + */ + generator?: string; + /** + * The minimum glTF version that the asset targets. + */ + minVersion?: string; + /** + * The index of the image in the `images` array to use as a thumbnail for + * this asset. The image **SHOULD** be a common, widely-supported format, + * but **MAY** have any media type. (glTF 2.1) + */ + thumbnail?: number; + /** + * The glTF version that the asset targets. + */ + version: string; + } + /** + * Reference to a binary buffer resource. + */ + export interface Buffer extends Gltf2.ChildOfRootProperty { + /** + * The length of the buffer in bytes. + */ + byteLength: number; + /** + * The index of the chunk that contains the buffer data. If neither `chunk` + * nor `uri` is defined on buffer 0, then buffer 0 implicitly refers to + * chunk 1. There is no default chunk index for other buffers. (glTF 2.1) + */ + chunk?: number; + /** + * The identifier used to retrieve the buffer data. + */ + uri?: string; + /** + * JSON object with extension objects. Property names correspond to glTF + * extension names and property values are extension-specific objects. + */ + extensions?: Gltf2.Buffer.Extensions; + } + export namespace Buffer { + export interface Extensions extends Gltf2.Property.Extensions { + /** + * Compressed data for bufferView. + */ + EXT_meshopt_compression?: EXT_meshopt_compression.Buffer; + /** + * Compressed data for bufferView. + */ + KHR_meshopt_compression?: KHR_meshopt_compression.Buffer; + } + } + /** + * A span of bytes in a buffer. + */ + export interface BufferView extends Gltf2.ChildOfRootProperty { + /** + * The index of the buffer. + */ + buffer: number; + /** + * The length of the buffer view in bytes. + */ + byteLength: number; + /** + * The offset into the buffer in bytes. + * + * @default 0 + */ + byteOffset?: number; + /** + * The stride, in bytes, between consecutive vertex attribute values. + */ + byteStride?: number; + /** + * The optional hint specifying buffer view usage. + * + * Allowed values: + * + * - `34962`: The buffer view is used for vertex attributes. + * - `34963`: The buffer view is used for vertex indices. + */ + target?: number; + /** + * JSON object with extension objects. Property names correspond to glTF + * extension names and property values are extension-specific objects. + */ + extensions?: Gltf2.BufferView.Extensions; + } + export namespace BufferView { + export interface Extensions extends Gltf2.Property.Extensions { + /** + * Compressed data for bufferView. + */ + EXT_meshopt_compression?: EXT_meshopt_compression.BufferView; + /** + * Compressed data for bufferView. + */ + KHR_meshopt_compression?: KHR_meshopt_compression.BufferView; + } + } + /** + * Camera's parameters. + */ + export interface Camera extends Gltf2.ChildOfRootProperty { + /** + * Orthographic projection parameters. + */ + orthographic?: Gltf2.Camera.Orthographic; + /** + * Perspective projection parameters. + */ + perspective?: Gltf2.Camera.Perspective; + /** + * The projection type. + * + * Allowed values: + * + * - `"orthographic"`: Orthographic + * - `"perspective"`: Perspective + */ + type: string; + } + export namespace Camera { + /** + * Orthographic projection parameters. + */ + export interface Orthographic extends Gltf2.Property { + /** + * Horizontal magnification of the view. + */ + xmag: number; + /** + * The vertical magnification of the view. + */ + ymag: number; + /** + * The distance to the far clipping plane. + */ + zfar: number; + /** + * The distance to the near clipping plane. + */ + znear: number; + } + /** + * Perspective projection parameters. + */ + export interface Perspective extends Gltf2.Property { + /** + * The floating-point aspect ratio of the field of view. When undefined, + * the camera uses the viewport's aspect ratio. + */ + aspectRatio?: number; + /** + * The vertical field of view in radians. + */ + yfov: number; + /** + * The distance to the far clipping plane. When undefined, the far + * clipping plane is at infinity. + */ + zfar?: number; + /** + * The floating-point distance to the near clipping plane. + */ + znear: number; + } + } + /** + * An external asset that references a file in the `files` array and may be + * instantiated by any node. (glTF 2.1) + */ + export interface ExternalAsset extends Gltf2.ChildOfRootProperty { + /** + * The index of the file reference in the top-level `files` array used for + * this external asset. + */ + file: number; + } + /** + * A reference to an external file. Files **MAY** be referenced by a URI (or + * IRI) or a buffer view index. (glTF 2.1) + */ + export interface File extends Gltf2.ChildOfRootProperty { + /** + * An array of aliases used for files within this external file. Aliases + * allow overriding inner file URIs. + */ + aliases?: Gltf2.File.Alias[]; + /** + * The index of the bufferView that contains the file data. This field + * **MUST NOT** be defined when `uri` is defined. + */ + bufferView?: number; + /** + * The media type or MIME type of the external file. This field is required + * and **MUST** always be defined. + * + * Allowed values: + * + * - `"model/gltf+json"` + * - `"model/gltf-binary"` + */ + mimeType: string; + /** + * The URI (or IRI) of the external file. Relative paths are relative to the + * current glTF asset. Instead of referencing an external file, this field + * **MAY** contain a `data:`-URI. This field **MUST NOT** be defined when + * `bufferView` is defined. + */ + uri?: string; + } + export namespace File { + /** + * Used to alias files referenced within an external file to other paths by + * the parent. (glTF 2.1) + */ + export interface Alias extends Gltf2.Property { + /** + * String alias matched against an inner path. + */ + alias: string; + /** + * The index of the file in the files array. + */ + file: number; + } + } + export interface Extensions extends Gltf2.Property.Extensions { + /** + * An object describing the availability of tiles and content in a subtree, + * as well as availability of children subtrees. May also store attributes + * and application-specific properties for available tiles and contents. + * (glTF 2.1) + */ + "3DTILES_subtree"?: _3DTILES_subtree.Gltf; + /** + * glTF-level 3DTILES_tileset extension. (glTF 2.1) + */ + "3DTILES_tileset"?: _3DTILES_tileset.Gltf; + /** + * Voxels are stored as glTFs with the EXT_voxels extension and are paired + * with EXT_structural_metadata to unify the schema between a tileset and + * its tiles. This extension is paired with Implicit Tiling for efficient + * representation of massive sparse voxel datasets. This extension lets + * runtimes detect voxel content in advance to allocate necessary resources + * before tiles load. (glTF 2.1) + */ + "3DTILES_tileset_voxels"?: _3DTILES_tileset_voxels.Gltf; + /** + * glTF Extension that defines metadata for applying external analysis or + * effects to a model. + */ + AGI_articulations?: AGI_articulations.Gltf; + /** + * glTF CESIUM_RTC extension. + */ + CESIUM_RTC?: CESIUM_RTC; + /** + * glTF extension that assigns metadata to features in a model. + */ + EXT_feature_metadata?: EXT_feature_metadata.Gltf; + /** + * This extension declares the Coordinate Reference System (CRS) in which a + * glTF 2.1 asset was authored. (glTF 2.1) + */ + EXT_geospatial_crs?: EXT_geospatial_crs; + /** + * glTF extension that provides structural metadata about vertices, texels, + * and features in a glTF asset. + */ + EXT_structural_metadata?: EXT_structural_metadata.Gltf; + /** + * Top level implicit shapes. + */ + KHR_implicit_shapes?: KHR_implicit_shapes.Gltf; + /** + * Instances of shading techniques with external shader programs along with + * their parameterized values. Shading techniques describe data types and + * semantics for GLSL vertex and fragment shader programs. + */ + KHR_techniques_webgl?: KHR_techniques_webgl.Gltf; + } + /** + * Common type for all glTF JSON objects that are elements of top-level + * arrays. + */ + export interface ChildOfRootProperty extends Gltf2.Property { + /** + * The user-defined object name. + */ + name?: string; + } + /** + * Common type for all glTF JSON objects that are not used as plain JSON + * objects. + */ + export interface Property { + /** + * Application-specific data usually stored as a JSON object. + */ + extras?: unknown; + /** + * JSON object with extension objects. Property names correspond to glTF + * extension names and property values are extension-specific objects. + */ + extensions?: Gltf2.Property.Extensions; + } + export namespace Property { + export interface Extensions { + /** + * Structural metadata about a glTF element. + */ + EXT_structural_metadata?: EXT_structural_metadata; + [name: string]: unknown; + } + } + /** + * Reference to an image resource. + */ + export interface Image extends Gltf2.ChildOfRootProperty { + /** + * The index of the buffer view that contains the image data. Not applicable + * to images sourced from IRIs. + */ + bufferView?: number; + /** + * The media type of the image. Required when the image is sourced from a + * buffer view. + * + * Allowed values: + * + * - `"image/jpeg"`: JPEG + * - `"image/png"`: PNG + */ + mimeType?: string; + /** + * The identifier used to retrieve the image data. Not applicable to images + * sourced from buffer views. + */ + uri?: string; + } + /** + * The material parameters. + */ + export interface Material extends Gltf2.ChildOfRootProperty { + /** + * The alpha cutoff value. Applies only when the alpha rendering mode is + * Mask. + * + * @default 0.5 + */ + alphaCutoff?: number; + /** + * The alpha rendering mode. + * + * Allowed values: + * + * - `"BLEND"`: The alpha value is used to composite the source and + * destination areas. The rendered output is combined with the background + * using the alpha over operator. + * - `"MASK"`: If the alpha value is greater than or equal to the alpha + * cutoff value, the material is rendered as fully opaque; otherwise, it + * is rendered as fully transparent. + * - `"OPAQUE"`: The alpha value is ignored, and the rendered output is + * fully opaque. + * + * @default "OPAQUE" + */ + alphaMode?: string; + /** + * Specifies whether the material is double sided. + * + * @default false + */ + doubleSided?: boolean; + /** + * The linear factors for the emissive color of the material. + * + * @default [0,0,0] + */ + emissiveFactor?: [number, number, number]; + /** + * The emissive texture binding object. + */ + emissiveTexture?: Gltf2.Material.TextureInfo; + /** + * The tangent-space normal texture binding object. + */ + normalTexture?: Gltf2.Material.NormalTextureInfo; + /** + * The occlusion texture binding object. + */ + occlusionTexture?: Gltf2.Material.OcclusionTextureInfo; + /** + * A set of parameter values that are used to define the metallic-roughness + * material model from Physically-Based Rendering (PBR) methodology. + * + * @default {} + */ + pbrMetallicRoughness?: Gltf2.Material.PbrMetallicRoughness; + /** + * JSON object with extension objects. Property names correspond to glTF + * extension names and property values are extension-specific objects. + */ + extensions?: Gltf2.Material.Extensions; + } + export namespace Material { + /** + * Tangent-space normal texture index, its scale, and the index of the + * associated texture coordinate set. + */ + export interface NormalTextureInfo extends Gltf2.Material.TextureInfo { + /** + * The scalar parameter applied to each normal vector of the texture. This + * value scales the normal vector in X and Y directions after it is + * reconstructed from the texture's RGB values. + * + * @default 1 + */ + scale?: number; + } + /** + * Occlusion texture index, its strength, and the index of the associated + * texture coordinate set. + */ + export interface OcclusionTextureInfo extends Gltf2.Material.TextureInfo { + /** + * A scalar parameter controlling the amount of occlusion applied. A value + * of zero means no occlusion; a value of one means the occlusion value + * sampled from the occlusion texture; intermediate values interpolate the + * occlusion linearly. + * + * @default 1 + */ + strength?: number; + } + /** + * A set of parameter values that are used to define the metallic-roughness + * material model from Physically-Based Rendering (PBR) methodology. + */ + export interface PbrMetallicRoughness extends Gltf2.Property { + /** + * The linear factors for the base color of the material. + * + * @default [1,1,1,1] + */ + baseColorFactor?: [number, number, number, number]; + /** + * The base color texture binding object. + */ + baseColorTexture?: Gltf2.Material.TextureInfo; + /** + * The linear factor for the metalness of the material. + * + * @default 1 + */ + metallicFactor?: number; + /** + * The metallic-roughness texture binding object. + */ + metallicRoughnessTexture?: Gltf2.Material.TextureInfo; + /** + * The linear factor for the roughness of the material. + * + * @default 1 + */ + roughnessFactor?: number; + } + export interface Extensions extends Gltf2.Property.Extensions { + /** + * glTF extension that specifies line width and a GPU-friendly dash + * pattern for CAD-style visualization. + */ + BENTLEY_materials_line_style?: BENTLEY_materials_line_style.Material; + /** + * Specifies planar fill behavior for CAD-style visualization. + */ + BENTLEY_materials_planar_fill?: BENTLEY_materials_planar_fill.Material; + /** + * Specifies point diameter for CAD-style visualization. + */ + BENTLEY_materials_point_style?: BENTLEY_materials_point_style.Material; + /** + * glTF extension that defines anisotropy. + */ + KHR_materials_anisotropy?: KHR_materials_anisotropy.Material; + /** + * glTF extension that defines the clearcoat material layer. + */ + KHR_materials_clearcoat?: KHR_materials_clearcoat.Material; + /** + * glTF extension that adjusts the strength of emissive material + * properties. + */ + KHR_materials_emissive_strength?: KHR_materials_emissive_strength.Material; + /** + * glTF extension that defines the specular-glossiness material model from + * Physically-Based Rendering (PBR) methodology. + */ + KHR_materials_pbrSpecularGlossiness?: KHR_materials_pbrSpecularGlossiness.Gltf; + /** + * glTF extension that defines the strength of the specular reflection. + */ + KHR_materials_specular?: KHR_materials_specular.Material; + /** + * glTF extension that defines the optical transmission of a material. + */ + KHR_materials_transmission?: KHR_materials_transmission.Material; + /** + * glTF extension that defines the unlit material model. + */ + KHR_materials_unlit?: KHR_materials_unlit.Material; + /** + * The technique to use for a material and any additional uniform values. + */ + KHR_techniques_webgl?: KHR_techniques_webgl.Material; + } + /** + * Texture index and the index of the associated texture coordinate set. + */ + export interface TextureInfo extends Gltf2.Property { + /** + * The index of the texture. + */ + index: number; + /** + * The index of the texture coordinate set. + * + * @default 0 + */ + texCoord?: number; + /** + * JSON object with extension objects. Property names correspond to glTF + * extension names and property values are extension-specific objects. + */ + extensions?: Gltf2.Material.TextureInfo.Extensions; + } + export namespace TextureInfo { + export interface Extensions extends Gltf2.Property.Extensions { + /** + * Enables dynamically calculated UV coordinates to keep the texture + * near a constant level of detail + */ + EXT_textureInfo_constant_lod?: EXT_textureInfo_constant_lod.TextureInfo; + /** + * glTF extension that enables shifting and scaling UV coordinates on a + * per-texture basis + */ + KHR_texture_transform?: KHR_texture_transform.TextureInfo; + } + } + } + /** + * Mesh primitives to instantiate. + */ + export interface Mesh extends Gltf2.ChildOfRootProperty { + /** + * An array of mesh primitives. + */ + primitives: Gltf2.Mesh.Primitive[]; + /** + * Default morph target weights. The number of array elements matches the + * number of morph targets of the mesh. + */ + weights?: number[]; + /** + * JSON object with extension objects. Property names correspond to glTF + * extension names and property values are extension-specific objects. + */ + extensions?: Gltf2.Mesh.Extensions; + } + export namespace Mesh { + /** + * Geometry to be rendered with the given material. + */ + export interface Primitive extends Gltf2.Property { + /** + * A JSON object that maps attribute semantic names to the indices of + * accessors providing the corresponding data. + */ + attributes: Record; + /** + * The index of the accessor that provides the vertex indices. When + * undefined, the mesh primitive uses non-indexed geometry. + */ + indices?: number; + /** + * The index of the material to apply to the mesh primitive. + */ + material?: number; + /** + * The topology type of the mesh primitive. + * + * Allowed values: + * + * - `0`: Point List + * - `1`: Line List + * - `2`: Line Loop + * - `3`: Line Strip + * - `4`: Triangle List + * - `5`: Triangle Strip + * - `6`: Triangle Fan + * + * @default 4 + */ + mode?: number; + /** + * An array of morph targets. + */ + targets?: Record[]; + /** + * JSON object with extension objects. Property names correspond to glTF + * extension names and property values are extension-specific objects. + */ + extensions?: Gltf2.Mesh.Primitive.Extensions; + } + export namespace Primitive { + export interface Extensions extends Gltf2.Property.Extensions { + /** + * Indicates that a mesh primitive supplies the + * BENTLEY_materials_line_style cumulative distance attribute semantic. + */ + BENTLEY_materials_line_style?: BENTLEY_materials_line_style.Mesh.Primitive; + /** + * glTF extension for indicating that some edges of a primitive's + * triangles should be outlined. + */ + CESIUM_primitive_outline?: CESIUM_primitive_outline.Primitive; + /** + * `CESIUM_tile_edges` extension for a primitive in a glTF model. + */ + CESIUM_tile_edges?: CESIUM_tile_edges.Mesh.Primitive; + /** + * `EXT_feature_metadata extension` for a primitive in a glTF model, to + * associate it with the root `EXT_feature_metadata` object. + */ + EXT_feature_metadata?: EXT_feature_metadata.Mesh.Primitive; + /** + * An object describing feature IDs for a mesh primitive. + */ + EXT_mesh_features?: EXT_mesh_features.Mesh.Primitive; + /** + * glTF extension adding an encoding of polygon primitive topology + */ + EXT_mesh_polygon?: EXT_mesh_polygon; + /** + * glTF extension encoding the visibility of the edges of a triangles + * primitive + */ + EXT_mesh_primitive_edge_visibility?: EXT_mesh_primitive_edge_visibility.Primitive; + /** + * `EXT_primitive_voxels` extension for a primitive in a glTF model to + * indicate voxel-based volumetric data + */ + EXT_primitive_voxels?: EXT_primitive_voxels.Mesh.Primitive; + /** + * Structural metadata about a glTF primitive. + */ + EXT_structural_metadata?: EXT_structural_metadata.Mesh.Primitive; + KHR_draco_mesh_compression?: KHR_draco_mesh_compression.Mesh.Primitive; + /** + * Data defining a 3D Gaussian Splat primitive. + */ + KHR_gaussian_splatting?: KHR_gaussian_splatting.Mesh.Primitive; + /** + * Compressed data for SPZ primitive. + */ + KHR_spz_gaussian_splats_compression?: KHR_spz_gaussian_splats_compression.Mesh.Primitive; + } + } + export interface Extensions extends Gltf2.Property.Extensions { + /** + * glTF extension enabling the use of primitive restart values in index + * buffers + */ + EXT_mesh_primitive_restart?: EXT_mesh_primitive_restart; + } + } + /** + * A node in the node hierarchy. + */ + export interface Node extends Gltf2.ChildOfRootProperty { + /** + * The bounding volume of the node. (glTF 2.1) + */ + boundingVolume?: Gltf2.Node.BoundingVolume; + /** + * The index of the camera. + */ + camera?: number; + /** + * The indices of the node's children. + */ + children?: number[]; + /** + * The index of the external asset in this node. Cannot be used together + * with `mesh`. (glTF 2.1) + */ + externalAsset?: number; + /** + * A 4x4 transformation matrix stored in column-major order. + * + * @default [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1] + */ + matrix?: number[]; + /** + * The index of the mesh. + */ + mesh?: number; + /** + * The node's unit quaternion rotation in the order (x, y, z, w), where w is + * the scalar. + * + * @default [0,0,0,1] + */ + rotation?: [number, number, number, number]; + /** + * The node's non-uniform scale, given as the scaling factors along the x, + * y, and z axes. + * + * @default [1,1,1] + */ + scale?: [number, number, number]; + /** + * The index of the skin to use for instantiating a mesh. + */ + skin?: number; + /** + * The node's translation along the x, y, and z axes. + * + * @default [0,0,0] + */ + translation?: [number, number, number]; + /** + * The weights to use for instantiating mesh primitives with morph targets. + * The number of array elements matches the number of morph targets of the + * mesh. + */ + weights?: number[]; + /** + * JSON object with extension objects. Property names correspond to glTF + * extension names and property values are extension-specific objects. + */ + extensions?: Gltf2.Node.Extensions; + } + export namespace Node { + /** + * A bounding volume. (glTF 2.1) + */ + export interface BoundingVolume extends Gltf2.Property { + /** + * The bounding volume's unit quaternion rotation relative to the node's + * local coordinate system. + * + * @default [0,0,0,1] + */ + rotation?: [number, number, number, number]; + /** + * The bounding volume's scale along the rotated local X, Y, and Z axes. + * + * @default [1,1,1] + */ + scale?: [number, number, number]; + /** + * The index of the shape in the top-level `shapes` array used for this + * bounding volume. Required. + */ + shape: number; + /** + * The bounding volume's translation along the node's local X, Y, and Z + * axes. + * + * @default [0,0,0] + */ + translation?: [number, number, number]; + } + export interface Extensions extends Gltf2.Property.Extensions { + /** + * Implicit tiling defines a concise representation of quadtrees and + * octrees in 3D Tiles. (glTF 2.1) + */ + "3DTILES_implicit_tiling"?: _3DTILES_implicit_tiling.Node; + /** + * Node-level 3DTILES_tileset extension. (glTF 2.1) + */ + "3DTILES_tileset"?: _3DTILES_tileset.Node; + /** + * glTF Extension for an individual node in a glTF model, to associate it + * with the model's root AGI_articulations object. + */ + AGI_articulations?: AGI_articulations.Node; + /** + * An object describing per-instance feature IDs. + */ + EXT_instance_features?: EXT_instance_features.Node; + /** + * glTF extension defines instance attributes for a node with a mesh. + */ + EXT_mesh_gpu_instancing?: EXT_mesh_gpu_instancing.Gltf; + /** + * `EXT_voxels` extension for a node in a glTF model to indicate + * voxel-based volumetric data (glTF 2.1) + */ + EXT_voxels?: EXT_voxels.Node; + /** + * glTF extension that defines node's visibility. + */ + KHR_node_visibility?: KHR_node_visibility.Node; + } + } + /** + * Texture sampler properties for filtering and wrapping modes. + */ + export interface Sampler extends Gltf2.ChildOfRootProperty { + /** + * Filter used when the texture's rendered dimensions are greater than its + * original dimensions. + * + * Allowed values: + * + * - `9728`: Nearest-neighbor filtering, also known as point filtering. + * - `9729`: Linear filtering. + */ + magFilter?: number; + /** + * Filter used when the texture's rendered dimensions are less than its + * original dimensions. + * + * Allowed values: + * + * - `9728`: Nearest-neighbor filtering, also known as point filtering, + * without mipmapping. + * - `9729`: Linear filtering without mipmapping. + * - `9984`: Nearest-neighbor filtering from the closest mipmap. + * - `9985`: Linear filtering from the closest mipmap. + * - `9986`: Nearest-neighbor filtering from the two closest mipmaps + * followed by linear filtering between them. + * - `9987`: Linear filtering from the two closest mipmaps followed by + * linear filtering between them, also known as trilinear filtering. + */ + minFilter?: number; + /** + * Wrapping mode for horizontal texture coordinates less than zero or + * greater than or equal to one. + * + * Allowed values: + * + * - `10497`: The normalized range is repeated infinitely. + * - `33071`: The out-of-bounds texture coordinates are clamped. + * - `33648`: The normalized range is repeated infinitely, reversing the + * direction on every repeat. + * + * @default 10497 + */ + wrapS?: number; + /** + * Wrapping mode for vertical texture coordinates less than zero or greater + * than or equal to one. + * + * Allowed values: + * + * - `10497`: The normalized range is repeated infinitely. + * - `33071`: The out-of-bounds texture coordinates are clamped. + * - `33648`: The normalized range is repeated infinitely, reversing the + * direction on every repeat. + * + * @default 10497 + */ + wrapT?: number; + } + /** + * Visual objects, such as nodes, to render. + */ + export interface Scene extends Gltf2.ChildOfRootProperty { + /** + * The root node indices. + */ + nodes?: number[]; + } + /** + * A generic, re-usable shape definition with no inherent meaning attached to + * it. (glTF 2.1) + */ + export interface Shape extends Gltf2.ChildOfRootProperty { + /** + * The type of shape this shape object represents. If any properties are + * explicitly specified for the shape, the shape properties object MUST + * match the shape type. + * + * Allowed values: + * + * - `"box"` + * - `"capsule"` + * - `"convexMesh"` + * - `"cylinder"` + * - `"mesh"` + * - `"plane"` + * - `"sphere"` + */ + type: string; + /** + * Parameter values defining a box shape. + */ + box?: Gltf2.Shape.Box; + /** + * Parameter values defining a capsule shape. + */ + capsule?: Gltf2.Shape.Capsule; + /** + * Parameter values defining a convex mesh shape. + */ + convexMesh?: Gltf2.Shape.ConvexMesh; + /** + * Parameter values defining a cylinder shape. + */ + cylinder?: Gltf2.Shape.Cylinder; + /** + * Parameter values defining a generic mesh shape. + */ + mesh?: Gltf2.Shape.Mesh; + /** + * Parameter values defining a plane shape. + */ + plane?: Gltf2.Shape.Plane; + /** + * Parameter values defining a sphere shape. + */ + sphere?: Gltf2.Shape.Sphere; + } + export namespace Shape { + /** + * An axis-aligned box with a size per-axis, centered at the origin in local + * space, with normals facing outwards along each axis. (glTF 2.1) + */ + export interface Box extends Gltf2.Property { + /** + * The size of the box in each axis in local space. + * + * @default [1,1,1] + */ + size?: [number, number, number]; + } + /** + * A capsule, centered at the origin in local space with potentially + * different radii at each end, equivalent to the convex hull of two spheres + * located along the Y axis (in local space) at a specified distance, with + * normals facing outwards. (glTF 2.1) + */ + export interface Capsule extends Gltf2.Property { + /** + * The distance between the centers of the two capping spheres of capsule, + * also known as the mid-height. + * + * @default 1 + */ + height?: number; + /** + * The radius of the sphere located at the bottom of the capsule (i.e. the + * sphere at the half-height along -Y) + * + * @default 0.5 + */ + radiusBottom?: number; + /** + * The radius of the sphere located at the top of the capsule (i.e. the + * sphere at the half-height along +Y) + * + * @default 0.5 + */ + radiusTop?: number; + } + /** + * A convex triangular mesh shape. (glTF 2.1) + */ + export interface ConvexMesh extends Gltf2.Property { + /** + * The index of the mesh defining the geometry for this shape. + */ + mesh: number; + } + /** + * A cylinder, centered at the origin in local space with potentially + * different radii at each end, equivalent to the convex hull of two circles + * in the X/Z plane positioned along the Y axis at a specified distance, + * with the top cap normal facing along the +Y axis, the bottom cap normal + * facing along the -Y axis, and the side normals facing outwards along the + * X/Z plane. (glTF 2.1) + */ + export interface Cylinder extends Gltf2.Property { + /** + * The height of the cylinder, centered along the Y axis. + * + * @default 2 + */ + height?: number; + /** + * The radius of the bottom of the cylinder (the disc located along -Y.) + * + * @default 0.5 + */ + radiusBottom?: number; + /** + * The radius of the top of the cylinder (the disc located along +Y.) + * + * @default 0.5 + */ + radiusTop?: number; + } + /** + * A generic triangular mesh shape, which may be either concave or convex. + * (glTF 2.1) + */ + export interface Mesh extends Gltf2.Property { + /** + * The index of the mesh defining the geometry for this shape. + */ + mesh: number; + } + /** + * A plane centered at the origin in local space, optionally with finite + * extents, with normal along the +Y axis in local space. The plane is + * one-sided. (glTF 2.1) + */ + export interface Plane extends Gltf2.Property { + /** + * The extents along the X axis in local space. If not provided, this + * dimension should be considered infinite. + */ + sizeX?: number; + /** + * The extents along the Z axis in local space. If not provided, this + * dimension should be considered infinite. + */ + sizeZ?: number; + } + /** + * A sphere, centered at the origin in local space with a radius equal in + * all directions, with normals facing outwards. (glTF 2.1) + */ + export interface Sphere extends Gltf2.Property { + /** + * The radius of the sphere. + * + * @default 0.5 + */ + radius?: number; + } + } + /** + * Joints and matrices defining a skin. + */ + export interface Skin extends Gltf2.ChildOfRootProperty { + /** + * The index of the accessor providing the inverse bind matrices. When + * undefined, all inverse bind matrices are identity. + */ + inverseBindMatrices?: number; + /** + * Indices of the joint nodes. + */ + joints: number[]; + /** + * The index of the node to use as the skeleton root. + */ + skeleton?: number; + } + /** + * Combination of the texture's source and sampler. + */ + export interface Texture extends Gltf2.ChildOfRootProperty { + /** + * The index of the sampler. + */ + sampler?: number; + /** + * The index of the image. + */ + source?: number; + /** + * JSON object with extension objects. Property names correspond to glTF + * extension names and property values are extension-specific objects. + */ + extensions?: Gltf2.Texture.Extensions; + } + export namespace Texture { + export interface Extensions extends Gltf2.Property.Extensions { + /** + * glTF extension to specify textures using the WebP image format. + */ + EXT_texture_webp?: EXT_texture_webp.Gltf; + /** + * glTF extension to specify textures using the KTX v2 images with Basis + * Universal supercompression. + */ + KHR_texture_basisu?: KHR_texture_basisu.Texture; + } + } +} diff --git a/packages/gltf/SchemaTypes/index.ts b/packages/gltf/SchemaTypes/index.ts new file mode 100644 index 000000000000..ea50f808817d --- /dev/null +++ b/packages/gltf/SchemaTypes/index.ts @@ -0,0 +1,52 @@ +// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead. +// See packages/gltf/README.md#generated-gltf-types. + +export type * from "./Gltf1.js"; +export type * from "./Gltf2.js"; +export type * from "./Extensions/3DTILES_implicit_tiling.js"; +export type * from "./Extensions/3DTILES_subtree.js"; +export type * from "./Extensions/3DTILES_tileset.js"; +export type * from "./Extensions/3DTILES_tileset_voxels.js"; +export type * from "./Extensions/AGI_articulations.js"; +export type * from "./Extensions/BENTLEY_materials_line_style.js"; +export type * from "./Extensions/BENTLEY_materials_planar_fill.js"; +export type * from "./Extensions/BENTLEY_materials_point_style.js"; +export type * from "./Extensions/CESIUM_RTC.js"; +export type * from "./Extensions/CESIUM_primitive_outline.js"; +export type * from "./Extensions/CESIUM_tile_edges.js"; +export type * from "./Extensions/EXT_feature_metadata.js"; +export type * from "./Extensions/EXT_geospatial_crs.js"; +export type * from "./Extensions/EXT_geospatial_crs_wkid.js"; +export type * from "./Extensions/EXT_implicit_cylinder_region.js"; +export type * from "./Extensions/EXT_implicit_ellipsoid_region.js"; +export type * from "./Extensions/EXT_instance_features.js"; +export type * from "./Extensions/EXT_mesh_features.js"; +export type * from "./Extensions/EXT_mesh_gpu_instancing.js"; +export type * from "./Extensions/EXT_mesh_polygon.js"; +export type * from "./Extensions/EXT_mesh_primitive_edge_visibility.js"; +export type * from "./Extensions/EXT_mesh_primitive_restart.js"; +export type * from "./Extensions/EXT_meshopt_compression.js"; +export type * from "./Extensions/EXT_primitive_voxels.js"; +export type * from "./Extensions/EXT_structural_metadata.js"; +export type * from "./Extensions/EXT_textureInfo_constant_lod.js"; +export type * from "./Extensions/EXT_texture_webp.js"; +export type * from "./Extensions/EXT_voxels.js"; +export type * from "./Extensions/KHR_binary_glTF.js"; +export type * from "./Extensions/KHR_draco_mesh_compression.js"; +export type * from "./Extensions/KHR_gaussian_splatting.js"; +export type * from "./Extensions/KHR_gaussian_splatting_compression_spz_2.js"; +export type * from "./Extensions/KHR_implicit_shapes.js"; +export type * from "./Extensions/KHR_materials_anisotropy.js"; +export type * from "./Extensions/KHR_materials_clearcoat.js"; +export type * from "./Extensions/KHR_materials_emissive_strength.js"; +export type * from "./Extensions/KHR_materials_pbrSpecularGlossiness.js"; +export type * from "./Extensions/KHR_materials_specular.js"; +export type * from "./Extensions/KHR_materials_transmission.js"; +export type * from "./Extensions/KHR_materials_unlit.js"; +export type * from "./Extensions/KHR_meshopt_compression.js"; +export type * from "./Extensions/KHR_node_visibility.js"; +export type * from "./Extensions/KHR_spz_gaussian_splats_compression.js"; +export type * from "./Extensions/KHR_techniques_webgl.js"; +export type * from "./Extensions/KHR_texture_basisu.js"; +export type * from "./Extensions/KHR_texture_transform.js"; +export type * from "./Extensions/WEB3D_quantized_attributes.js"; diff --git a/packages/gltf/gltf.entry.d.ts b/packages/gltf/gltf.entry.d.ts index 8d9aa242794c..d77918aece06 100644 --- a/packages/gltf/gltf.entry.d.ts +++ b/packages/gltf/gltf.entry.d.ts @@ -1,3 +1,4 @@ export * from "./Build/Types/index.js"; +export type * from "./Build/Types/SchemaTypes/index.js"; export type { ComponentReader } from "./Build/Types/Source/ComponentReader.js"; export type { ForEachElementHandler } from "./Build/Types/Source/ForEachElementHandler.js"; diff --git a/packages/gltf/package.json b/packages/gltf/package.json index 5d90ec1eef80..80839d539e27 100644 --- a/packages/gltf/package.json +++ b/packages/gltf/package.json @@ -34,6 +34,8 @@ "build": "gulp build --workspace @cesium/gltf", "build-ts": "node scripts/buildTs.js", "coverage": "gulp coverage --workspace @cesium/gltf", + "download-schemas": "node scripts/downloadGltfSchemas.js", + "generate-types": "node scripts/generateGltfTypes.js", "tsc": "gulp tsc --workspace @cesium/gltf", "test": "gulp test --workspace @cesium/gltf", "postversion": "gulp postversion --workspace @cesium/gltf" diff --git a/packages/gltf/scripts/downloadGltfSchemas.js b/packages/gltf/scripts/downloadGltfSchemas.js new file mode 100644 index 000000000000..d6dd7c133a87 --- /dev/null +++ b/packages/gltf/scripts/downloadGltfSchemas.js @@ -0,0 +1,118 @@ +// @ts-check + +// Downloads the glTF JSON schemas listed in `gltfSchemaSources.json`, at their +// pinned commits, into `Build/Schemas`, which `generateGltfTypes.js` reads. +// The glTF schemas go in `Build/Schemas/`, and each extension's +// schemas in `Build/Schemas/Extensions/`. See the "Generated glTF types" +// section of `packages/gltf/README.md`. + +import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { dirname, join } from "node:path"; + +/** + * Where a set of schemas comes from, as listed in `gltfSchemaSources.json`. + * + * @typedef {object} SchemaSource + * @property {string} repository + * @property {string} commit + * @property {string} schemaDirectory + */ + +const schemasDirectory = join(import.meta.dirname, "../Build/Schemas"); + +/** @type {{core: Record, extensions: Record}} */ +const sources = JSON.parse( + readFileSync(join(import.meta.dirname, "gltfSchemaSources.json"), "utf8"), +); + +/** @type {Map>} */ +const repositoryFiles = new Map(); + +rmSync(schemasDirectory, { recursive: true, force: true }); + +for (const [version, source] of Object.entries(sources.core)) { + await downloadSchemas(source, join(schemasDirectory, version), version); +} +for (const [name, source] of Object.entries(sources.extensions)) { + // An extension without a schema has nothing to download + if ("schemaDirectory" in source) { + await downloadSchemas( + source, + join(schemasDirectory, "Extensions", name), + name, + ); + } +} + +/** + * Downloads every `*.schema.json` file under a source's schema directory, + * keeping its path relative to that directory. + * + * @param {SchemaSource} source + * @param {string} outputDirectory + * @param {string} label + */ +async function downloadSchemas(source, outputDirectory, label) { + const { repository, commit, schemaDirectory } = source; + const prefix = `${schemaDirectory}/`; + const schemaPaths = (await listFiles(repository, commit)) + .filter((path) => path.startsWith(prefix) && path.endsWith(".schema.json")) + .map((path) => path.slice(prefix.length)); + if (schemaPaths.length === 0) { + throw new Error( + `No schemas found for ${label} in ${repository}@${commit}/${schemaDirectory}`, + ); + } + + await Promise.all( + schemaPaths.map(async (schemaPath) => { + const text = await fetchText( + `https://raw.githubusercontent.com/${repository}/${commit}/${prefix}${schemaPath}`, + ); + const outputPath = join(outputDirectory, schemaPath); + mkdirSync(dirname(outputPath), { recursive: true }); + writeFileSync(outputPath, text); + }), + ); + console.log(`${label}: ${schemaPaths.length} schemas`); +} + +/** + * Lists the paths of all files in a repository at a commit, fetching each + * repository and commit only once. + * + * @param {string} repository + * @param {string} commit + * @returns {Promise} + */ +function listFiles(repository, commit) { + const key = `${repository}@${commit}`; + let files = repositoryFiles.get(key); + if (files === undefined) { + files = fetchText( + `https://api.github.com/repos/${repository}/git/trees/${commit}?recursive=1`, + ).then((text) => { + const tree = JSON.parse(text); + if (tree.truncated) { + throw new Error(`File list for ${key} is truncated`); + } + return tree.tree + .filter((/** @type {{type: string}} */ entry) => entry.type === "blob") + .map((/** @type {{path: string}} */ entry) => entry.path); + }); + repositoryFiles.set(key, files); + } + return files; +} + +/** + * @param {string} url + * @returns {Promise} + */ +async function fetchText(url) { + const response = await fetch(url); + if (!response.ok) { + throw new Error(`${response.status} ${response.statusText}: ${url}`); + } + return response.text(); +} diff --git a/packages/gltf/scripts/generateGltfTypes.js b/packages/gltf/scripts/generateGltfTypes.js new file mode 100644 index 000000000000..2217b3431205 --- /dev/null +++ b/packages/gltf/scripts/generateGltfTypes.js @@ -0,0 +1,1034 @@ +// @ts-check + +// Generates TypeScript types for glTF JSON from the glTF JSON schemas, which +// `npm run download-schemas -w @cesium/gltf` downloads into `Build/Schemas`. +// Each schema describes one kind of glTF object, such as a node or a material, +// and becomes an interface. The types are written to `SchemaTypes`: `Gltf1.ts` +// for glTF 1.0, `Gltf2.ts` for glTF 2.0 and 2.1, and a file per extension in +// `SchemaTypes/Extensions`. + +import { + mkdirSync, + readFileSync, + readdirSync, + rmSync, + writeFileSync, +} from "node:fs"; +import { join, posix, sep } from "node:path"; +import { format, resolveConfig } from "prettier"; + +/** + * The keywords of the glTF JSON schemas that this generator reads. Most are + * JSON Schema keywords; the `gltf_` keywords are glTF additions. + * + * @typedef {object} SchemaKeywords + * @property {string} [$ref] + * @property {string} [title] + * @property {string} [description] + * @property {string} [gltf_detailedDescription] + * @property {string[]} [gltf_enumNames] + * @property {string | string[]} [type] + * @property {Record} [properties] + * @property {string[]} [required] + * @property {SchemaKeywords | boolean} [additionalProperties] + * @property {SchemaKeywords[]} [allOf] + * @property {SchemaKeywords[]} [anyOf] + * @property {SchemaKeywords[]} [oneOf] + * @property {unknown[]} [enum] + * @property {unknown} [const] + * @property {SchemaKeywords} [items] + * @property {number} [minItems] + * @property {number} [maxItems] + * @property {unknown} [default] + */ + +/** + * The schemas of one generated file: glTF 1.0, glTF 2.x, or one extension. + * + * @typedef {object} SchemaSet + * @property {string} rootName The name of the root interface and namespace, like `Gltf2`. + * @property {string} modulePath Path in `SchemaTypes`, without an extension. + * @property {Map} schemas Keyed by path in the schema directory. + * @property {Map} [baseline] For glTF 2.x, the glTF 2.0 schemas, to mark what glTF 2.1 adds. + * @property {string} [extensionName] + * @property {SchemaSet} [core] For an extension, the glTF schemas to look in for a referenced schema that the extension doesn't have. + * @property {Map} extensionsByFile For each object that can have extensions, the extensions it can have, keyed by the path of the object's schema. + * @property {Set} imports The schema sets the generated file refers to. + */ + +/** + * A schema found by a reference, in the schema set that holds it. + * + * @typedef {object} SchemaTarget + * @property {SchemaSet} schemaSet + * @property {string} fileName + * @property {SchemaKeywords} schema + */ + +/** + * An extension that an object can have in its `extensions`. + * + * @typedef {object} Attachment + * @property {string} name + * @property {SchemaTarget} target The extension's schema for that object. + * @property {boolean} isGltf21 Whether the extension needs glTF 2.1. + */ + +/** + * A node in the tree of generated types. A node has an interface, a namespace + * of the same name holding its children, or both: `Gltf2.Material` is an + * interface, and also a namespace holding `Gltf2.Material.TextureInfo`. + * + * @typedef {object} TypeNode + * @property {string} [interfaceCode] The code of the node's interface, if it has one. + * @property {Map} children Keyed by name. + */ + +/** + * One allowed value of an enum property, with its description. + * + * @typedef {object} EnumValue + * @property {unknown} value + * @property {string} [description] + */ + +/** + * Where a set of schemas comes from, as listed in `gltfSchemaSources.json`. + * + * @typedef {object} SchemaSource + * @property {string} repository + * @property {string} commit + * @property {string} schemaDirectory + */ + +/** + * Where an extension's schemas come from, as listed in `gltfSchemaSources.json`. + * + * @typedef {object} ExtensionSource + * @property {string} repository + * @property {string} commit + * @property {string} schemaDirectory + * @property {string[]} core The glTF versions the extension applies to: `1.0`, `2.x`, or `2.1`. + * @property {Record} extends For each of the extension's schemas, the glTF objects whose `extensions` it can appear in. + */ + +const packageDirectory = join(import.meta.dirname, ".."); +const schemasDirectory = join(packageDirectory, "Build/Schemas"); +const outputDirectory = join(packageDirectory, "SchemaTypes"); +// The base of every glTF object, which declares `extensions` and `extras` +const propertySchema = "glTFProperty.schema.json"; + +/** @type {{core: Record, extensions: Record}} */ +const sources = JSON.parse( + readFileSync(join(import.meta.dirname, "gltfSchemaSources.json"), "utf8"), +); + +const gltf1 = createSchemaSet("Gltf1", "Gltf1", "1.0"); +// Gltf2 is generated from the glTF 2.1 schemas, which include all of glTF 2.0. +// The glTF 2.0 schemas are loaded to mark what glTF 2.1 adds. +const gltf2 = createSchemaSet("Gltf2", "Gltf2", "2.1"); +gltf2.baseline = loadSchemas("2.0"); + +/** @type {Map} */ +const extensionSets = new Map(); +for (const [name, source] of Object.entries(sources.extensions)) { + // An extension without a schema has no types to generate + if (!("schemaDirectory" in source)) { + continue; + } + // A TypeScript name can't start with a digit. 3DTILES_tileset becomes _3DTILES_tileset + let rootName = name; + if (/^\d/.test(name)) { + rootName = `_${name}`; + } + const extensionSet = createSchemaSet( + rootName, + `Extensions/${name}`, + `Extensions/${name}`, + ); + extensionSet.extensionName = name; + extensionSet.core = gltf2; + if (source.core.every((version) => version === "1.0")) { + extensionSet.core = gltf1; + } + extensionSets.set(name, extensionSet); +} +attachExtensions(); + +// Write a file per schema set, and an index.ts that re-exports them all +rmSync(join(outputDirectory, "Extensions"), { recursive: true, force: true }); +mkdirSync(join(outputDirectory, "Extensions"), { recursive: true }); +await writeSchemaSet(gltf1, [sources.core["1.0"]]); +await writeSchemaSet(gltf2, [sources.core["2.0"], sources.core["2.1"]]); +let indexCode = `${getHeader([])}export type * from "./Gltf1.js";\nexport type * from "./Gltf2.js";\n`; +for (const [name, extensionSet] of extensionSets) { + const source = /** @type {ExtensionSource} */ (sources.extensions[name]); + await writeSchemaSet(extensionSet, [source]); + indexCode += `export type * from "./${extensionSet.modulePath}.js";\n`; +} +await writeTypeScript("index.ts", indexCode); + +/** + * Loads a schema directory into a new schema set. + * + * @param {string} rootName The name of the root interface and namespace, like `Gltf2`. + * @param {string} modulePath The generated file's path in `SchemaTypes`, without an extension. + * @param {string} directory The schema directory, in `Build/Schemas`. + * @returns {SchemaSet} + */ +function createSchemaSet(rootName, modulePath, directory) { + /** @type {Map} */ + const extensionsByFile = new Map(); + // Give glTFProperty an `Extensions` interface even when no extension applies + // to every object, since every other object's `Extensions` extends it + if (!directory.startsWith("Extensions/")) { + extensionsByFile.set(propertySchema, []); + } + return { + rootName: rootName, + modulePath: modulePath, + schemas: loadSchemas(directory), + extensionsByFile: extensionsByFile, + imports: new Set(), + }; +} + +/** + * Loads the schemas in a directory and its subdirectories. + * + * @param {string} directory The schema directory, in `Build/Schemas`. + * @returns {Map} + */ +function loadSchemas(directory) { + const fullDirectory = join(schemasDirectory, directory); + const fileNames = readdirSync(fullDirectory, { + recursive: true, + encoding: "utf8", + }) + .filter((fileName) => fileName.endsWith(".schema.json")) + .map((fileName) => fileName.split(sep).join("/")) + .sort(); + /** @type {Map} */ + const schemas = new Map(); + for (const fileName of fileNames) { + schemas.set( + fileName, + JSON.parse(readFileSync(join(fullDirectory, fileName), "utf8")), + ); + } + return schemas; +} + +/** + * Records, for each glTF object, the extensions that `gltfSchemaSources.json` + * lists for its `extensions` property, in `extensionsByFile`. + */ +function attachExtensions() { + for (const [name, extensionSet] of extensionSets) { + const source = /** @type {ExtensionSource} */ (sources.extensions[name]); + const isGltf21 = source.core.includes("2.1"); + for (const [fileName, objects] of Object.entries(source.extends)) { + const target = { + schemaSet: extensionSet, + fileName: fileName, + schema: getSchema(extensionSet, fileName), + }; + for (const object of objects) { + for (const owner of getExtendedObjects(source, object)) { + let attachments = owner.schemaSet.extensionsByFile.get( + owner.fileName, + ); + if (attachments === undefined) { + attachments = []; + owner.schemaSet.extensionsByFile.set(owner.fileName, attachments); + } + attachments.push({ name: name, target: target, isGltf21: isGltf21 }); + } + } + } + } +} + +/** + * Returns the objects that an `extends` entry names: a glTF object like `node`, + * `*` for any glTF object, or `/` for an object of another + * extension. A glTF object is returned for each glTF version the extension + * applies to. + * + * @param {ExtensionSource} source + * @param {string} object + * @returns {{schemaSet: SchemaSet, fileName: string}[]} + */ +function getExtendedObjects(source, object) { + if (object.includes("/")) { + const [extensionName, objectName] = object.split("/"); + const extensionSet = /** @type {SchemaSet} */ ( + extensionSets.get(extensionName) + ); + return [{ schemaSet: extensionSet, fileName: `${objectName}.schema.json` }]; + } + + let fileName = `${object}.schema.json`; + if (object === "*") { + fileName = propertySchema; + } + return source.core.map((version) => { + let coreSet = gltf2; + if (version === "1.0") { + coreSet = gltf1; + } + return { schemaSet: coreSet, fileName: fileName }; + }); +} + +/** + * Returns the comment at the top of a generated file. + * + * @param {SchemaSource[]} schemaSources + * @returns {string} + */ +function getHeader(schemaSources) { + const lines = []; + if (schemaSources.length > 0) { + lines.push("// Generated from the glTF JSON schemas at:"); + for (const { repository, commit, schemaDirectory } of schemaSources) { + lines.push( + `// https://github.com/${repository}/tree/${commit}/${schemaDirectory}`, + ); + } + } + lines.push( + "// Do not edit; rerun `npm run generate-types -w @cesium/gltf` instead.", + "// See packages/gltf/README.md#generated-gltf-types.", + ); + return `${lines.join("\n")}\n\n`; +} + +/** + * Writes a schema set's types, with imports of the schema sets they use. + * + * @param {SchemaSet} schemaSet + * @param {SchemaSource[]} schemaSources + */ +async function writeSchemaSet(schemaSet, schemaSources) { + const types = generateTypes(schemaSet); + const imported = [...schemaSet.imports].sort((left, right) => + left.modulePath.localeCompare(right.modulePath, "en"), + ); + let imports = ""; + for (const { rootName, modulePath } of imported) { + let path = posix.relative(posix.dirname(schemaSet.modulePath), modulePath); + if (!path.startsWith(".")) { + path = `./${path}`; + } + imports += `import type { ${rootName} } from "${path}.js";\n`; + } + await writeTypeScript( + `${schemaSet.modulePath}.ts`, + `${getHeader(schemaSources)}${imports}\n${types}`, + ); +} + +/** + * Formats code with prettier and writes it to a file in `SchemaTypes`. + * + * @param {string} fileName + * @param {string} code + */ +async function writeTypeScript(fileName, code) { + const path = join(outputDirectory, fileName); + const options = await resolveConfig(path); + const formatted = await format(code, { ...options, filepath: path }); + writeFileSync( + path, + await wrapDocComments(formatted, options?.printWidth ?? 80), + ); +} + +/** + * Wraps doc comments to the print width; prettier leaves comments as they are. + * + * @param {string} code + * @param {number} width + * @returns {Promise} + */ +async function wrapDocComments(code, width) { + const lines = code.split("\n"); + const output = []; + let index = 0; + while (index < lines.length) { + const line = lines[index]; + output.push(line); + index++; + if (line.trim() !== "/**") { + continue; + } + + // Take the comment's text without its ` * ` line prefixes, wrap it as + // markdown, and put the prefixes back + const bodyStart = index; + while (lines[index].trim() !== "*/") { + index++; + } + const prefix = lines[index].replace("*/", "* "); + const text = lines + .slice(bodyStart, index) + .map((bodyLine) => bodyLine.slice(prefix.length)) + .join("\n"); + const wrapped = await format(text, { + parser: "markdown", + proseWrap: "always", + printWidth: width - prefix.length, + }); + for (const wrappedLine of wrapped.trimEnd().split("\n")) { + output.push(`${prefix}${wrappedLine}`.trimEnd()); + } + } + return output.join("\n"); +} + +/** + * Generates a schema set's types. Each schema with properties becomes an + * interface, nested in namespaces by the parts of its file name: + * `material.textureInfo.schema.json` becomes `Gltf2.Material.TextureInfo`. + * Other schemas get no interface; their types are written where they're used. + * + * @param {SchemaSet} schemaSet + * @returns {string} + */ +function generateTypes(schemaSet) { + /** @type {TypeNode} */ + const root = { children: new Map() }; + for (const [fileName, schema] of schemaSet.schemas) { + if (!hasInterface(schema)) { + continue; + } + // The root schema, like `glTF.schema.json`, has no name parts + const nameParts = getNameParts(schemaSet, fileName); + let node = root; + for (const part of nameParts) { + let child = node.children.get(part); + if (child === undefined) { + child = { children: new Map() }; + node.children.set(part, child); + } + node = child; + } + node.interfaceCode = generateInterface( + schemaSet, + fileName, + schema, + nameParts.at(-1) ?? schemaSet.rootName, + nameParts.length === 0, + ); + // An object that can have extensions gets an `Extensions` interface in + // its namespace + if (schemaSet.extensionsByFile.has(fileName)) { + node.children.set("Extensions", { + interfaceCode: generateExtensions(schemaSet, fileName, schema), + children: new Map(), + }); + } + } + return generateNode(schemaSet.rootName, root, true); +} + +/** + * Generates a node's interface, followed by a namespace of the same name + * holding its children. + * + * @param {string} name + * @param {TypeNode} node + * @param {boolean} isRoot + * @returns {string} + */ +function generateNode(name, node, isRoot) { + let code = node.interfaceCode ?? ""; + if (node.children.size > 0) { + if (isRoot) { + code += "/** @internal */\n"; + } + code += `export namespace ${name} {\n`; + for (const [childName, child] of node.children) { + code += generateNode(childName, child, false); + } + code += "}\n"; + } + return code; +} + +/** + * Generates the interface of a schema with properties. + * + * @param {SchemaSet} schemaSet + * @param {string} fileName + * @param {SchemaKeywords} schema + * @param {string} name The last part of the interface's name, like `TextureInfo`. + * @param {boolean} isRoot + * @returns {string} + */ +function generateInterface(schemaSet, fileName, schema, name, isRoot) { + const docLines = getDescriptionLines(schema); + if (schemaSet.baseline !== undefined && !schemaSet.baseline.has(fileName)) { + appendGltf21Marker(docLines); + } + if (isRoot) { + docLines.push("@internal"); + } + + // A schema that refers to a base schema, like `glTFProperty`, extends the + // base's interface + let heritage = ""; + const reference = getReference(schema); + if (reference !== undefined) { + const base = resolveReference(schemaSet, reference); + heritage = ` extends ${getTypeName(schemaSet, base)}`; + } + + let extensionsType; + if (schemaSet.extensionsByFile.has(fileName)) { + const self = { schemaSet: schemaSet, fileName: fileName, schema: schema }; + extensionsType = `${getTypeName(schemaSet, self)}.Extensions`; + } + return `${formatDoc(docLines)}export interface ${name}${heritage} {\n${generateProperties(schemaSet, schema, fileName, extensionsType)}}\n`; +} + +/** + * Generates an object's `Extensions` interface, listing the extensions the + * object can have. It extends the `Extensions` interface of the object's base + * schema, if there is one. Otherwise it also accepts any other extension, as + * `unknown`. + * + * @param {SchemaSet} schemaSet + * @param {string} fileName + * @param {SchemaKeywords} schema + * @returns {string} + */ +function generateExtensions(schemaSet, fileName, schema) { + const baseName = getBaseExtensionsName(schemaSet, schema); + let heritage = ""; + if (baseName !== undefined) { + heritage = ` extends ${baseName}`; + } + + const attachments = [ + ...(schemaSet.extensionsByFile.get(fileName) ?? []), + ].sort((left, right) => left.name.localeCompare(right.name, "en")); + let code = `export interface Extensions${heritage} {\n`; + for (const { name, target, isGltf21 } of attachments) { + const docLines = getDescriptionLines(target.schema); + if (isGltf21) { + appendGltf21Marker(docLines); + } + const type = getTypeName(schemaSet, target); + code += `${formatDoc(docLines)}${formatPropertyName(name)}?: ${type};\n`; + } + if (baseName === undefined) { + code += "[name: string]: unknown;\n"; + } + return `${code}}\n`; +} + +/** + * Returns the `Extensions` interface of the nearest base schema that has one, + * following each schema's reference to its base schema. + * + * @param {SchemaSet} schemaSet + * @param {SchemaKeywords} schema + * @returns {string | undefined} + */ +function getBaseExtensionsName(schemaSet, schema) { + let lookupSet = schemaSet; + let reference = getReference(schema); + while (reference !== undefined) { + const base = resolveReference(lookupSet, reference); + if (base.schemaSet.extensionsByFile.has(base.fileName)) { + return `${getTypeName(schemaSet, base)}.Extensions`; + } + lookupSet = base.schemaSet; + reference = getReference(base.schema); + } + return undefined; +} + +/** + * Generates the properties of a schema. The glTF 1.0 schemas list the + * properties they inherit from their base schema as empty schemas, like + * `"name": {}`. These are skipped, since the base interface declares them. + * + * @param {SchemaSet} schemaSet + * @param {SchemaKeywords} schema + * @param {string} [fileName] The schema's file name, if it isn't an inline object schema. + * @param {string} [extensionsType] The type of `extensions`, if the object has its own `Extensions`. + * @returns {string} + */ +function generateProperties(schemaSet, schema, fileName, extensionsType) { + const required = schema.required ?? []; + let baselineProperties; + if (schemaSet.baseline !== undefined && fileName !== undefined) { + baselineProperties = schemaSet.baseline.get(fileName)?.properties; + } + + let code = ""; + for (const [name, property] of Object.entries(schema.properties ?? {})) { + if (Object.keys(property).length === 0) { + continue; + } + // An object with its own `Extensions` interface declares `extensions` below + if (name === "extensions" && extensionsType !== undefined) { + continue; + } + const baselineProperty = baselineProperties?.[name]; + const docLines = getPropertyDocLines(schemaSet, property); + if (baselineProperties !== undefined && baselineProperty === undefined) { + appendGltf21Marker(docLines); + } + docLines.push(...getEnumDocLines(property, baselineProperty)); + if (property.default !== undefined) { + docLines.push(`@default ${JSON.stringify(property.default)}`); + } + + let optional = "?"; + if (required.includes(name)) { + optional = ""; + } + code += `${formatDoc(docLines)}${formatPropertyName(name)}${optional}: ${resolveType(schemaSet, property)};\n`; + } + + // Declare `extensions` with the object's `Extensions` interface, and the + // description of `extensions` in glTFProperty + if (extensionsType !== undefined) { + const coreSet = schemaSet.core ?? schemaSet; + const coreProperties = getSchema(coreSet, propertySchema).properties ?? {}; + const docLines = getPropertyDocLines(coreSet, coreProperties.extensions); + code += `${formatDoc(docLines)}extensions?: ${extensionsType};\n`; + } + return code; +} + +/** + * Returns a property's description, or else that of the schema it refers to. + * + * @param {SchemaSet} schemaSet + * @param {SchemaKeywords} property + * @returns {string[]} + */ +function getPropertyDocLines(schemaSet, property) { + const docLines = getDescriptionLines(property); + const reference = getReference(property); + if (docLines.length === 0 && reference !== undefined) { + return getDescriptionLines(resolveReference(schemaSet, reference).schema); + } + return docLines; +} + +/** + * Returns the TypeScript type of a schema, such as the schema of a property. + * + * @param {SchemaSet} schemaSet + * @param {SchemaKeywords} schema + * @returns {string} + */ +function resolveType(schemaSet, schema) { + // A schema can refer to another schema. If that schema has properties, use + // its interface. Otherwise use its type: in glTF 2.x, `glTFid.schema.json` + // is a `number`. Any properties of the referring schema are added to the type. + const reference = getReference(schema); + if (reference !== undefined) { + const target = resolveReference(schemaSet, reference); + let referenceType; + if (hasInterface(target.schema)) { + referenceType = getTypeName(schemaSet, target); + } else { + referenceType = resolveType(schemaSet, target.schema); + } + if (schema.properties !== undefined) { + return `${referenceType} & {\n${generateProperties(schemaSet, schema)}}`; + } + return referenceType; + } + + // A schema with a list of allowed values is the union of those values. + // Some lists also allow any other value of a type, written as an `anyOf` + // member with a `type` instead of a value, like accessor `componentType`'s + // `{ "type": "integer" }`. The schema then has that member's type. + const enumValues = getEnumValues(schema); + if (enumValues !== undefined) { + const fallback = schema.anyOf?.find((member) => !("const" in member)); + if (fallback !== undefined) { + return resolveType(schemaSet, fallback); + } + return enumValues + .map((enumValue) => JSON.stringify(enumValue.value)) + .join(" | "); + } + + // A schema that matches any of several schemas is the union of their types + const alternatives = schema.anyOf ?? schema.oneOf; + if (alternatives !== undefined) { + return alternatives + .map((alternative) => resolveType(schemaSet, alternative)) + .join(" | "); + } + + // A schema can describe several types. Resolve each one individually, + // passing the whole schema along with each type. + if (Array.isArray(schema.type)) { + return schema.type + .map((type) => resolveType(schemaSet, { ...schema, type: type })) + .join(" | "); + } + + // A schema without a type allows any value + switch (schema.type) { + case "integer": + case "number": + return "number"; + case "string": + return "string"; + case "boolean": + return "boolean"; + case "array": + return resolveArrayType(schemaSet, schema); + case "object": + return resolveObjectType(schemaSet, schema); + default: + return "unknown"; + } +} + +/** + * Returns the type of an array schema, using the schema of its elements + * (`items`). An array whose length is fixed at 4 or less, like a node's + * `translation`, is a tuple: `[number, number, number]`. Longer arrays, like a + * node's 16-element `matrix`, and arrays of enum values are plain arrays. + * + * @param {SchemaSet} schemaSet + * @param {SchemaKeywords} schema + * @returns {string} + */ +function resolveArrayType(schemaSet, schema) { + const items = schema.items; + if (items === undefined) { + return "unknown[]"; + } + const itemType = resolveType(schemaSet, items); + const length = schema.minItems; + if ( + length !== undefined && + length === schema.maxItems && + length <= 4 && + getEnumValues(items) === undefined + ) { + return `[${Array(length).fill(itemType).join(", ")}]`; + } + return `${wrapUnion(itemType)}[]`; +} + +/** + * Returns the type of an object schema written inside another schema: an + * object type for one with properties, a `Record` for a dictionary whose + * values all have the same schema (`additionalProperties`), or else `object`. + * + * @param {SchemaSet} schemaSet + * @param {SchemaKeywords} schema + * @returns {string} + */ +function resolveObjectType(schemaSet, schema) { + if (hasInterface(schema)) { + return `{\n${generateProperties(schemaSet, schema)}}`; + } + const additionalProperties = schema.additionalProperties; + if (typeof additionalProperties === "object") { + return `Record`; + } + return "object"; +} + +/** + * Whether a schema gets its own interface, which only schemas with properties do. + * + * @param {SchemaKeywords} schema + * @returns {boolean} + */ +function hasInterface(schema) { + return ( + schema.properties !== undefined && Object.keys(schema.properties).length > 0 + ); +} + +/** + * Returns a schema set's schema with a file name, throwing if there is none. + * + * @param {SchemaSet} schemaSet + * @param {string} fileName + * @returns {SchemaKeywords} + */ +function getSchema(schemaSet, fileName) { + const schema = schemaSet.schemas.get(fileName); + if (schema === undefined) { + throw new Error(`${schemaSet.rootName}: unknown schema ${fileName}`); + } + return schema; +} + +/** + * Finds the schema a reference names. A reference is a file name, optionally + * followed by `#` and a path to a schema inside that file, like + * `definitions.schema.json#/definitions/numericValue`. An extension's + * reference to a schema it doesn't have names a glTF schema, by its name or + * the end of its name: `textureInfo.schema.json` names + * `material.textureInfo.schema.json`. + * + * @param {SchemaSet} schemaSet + * @param {string} reference + * @returns {SchemaTarget} + */ +function resolveReference(schemaSet, reference) { + const [path, pointer] = reference.split("#"); + // A schema in a subdirectory refers to the schemas above it with `../`. + const fileName = path.replace(/^(\.\.\/)+/, ""); + let target = { + schemaSet: schemaSet, + fileName: fileName, + schema: schemaSet.schemas.get(fileName), + }; + const core = schemaSet.core; + if (target.schema === undefined && core !== undefined) { + let coreFileName = fileName; + if (!core.schemas.has(fileName)) { + const matches = [...core.schemas.keys()].filter((name) => + name.endsWith(`.${fileName}`), + ); + if (matches.length !== 1) { + throw new Error( + `${schemaSet.rootName}: ${reference} matches ${matches.length} core schemas`, + ); + } + coreFileName = matches[0]; + } + target = { + schemaSet: core, + fileName: coreFileName, + schema: core.schemas.get(coreFileName), + }; + } + + let schema = target.schema; + if (schema === undefined) { + throw new Error(`${schemaSet.rootName}: unknown schema ${reference}`); + } + // Follow the path after `#` to the schema inside the file + for (const key of (pointer ?? "").split("/")) { + if (key !== "") { + schema = /** @type {Record} */ (schema)[key]; + } + } + return { + schemaSet: target.schemaSet, + fileName: target.fileName, + schema: schema, + }; +} + +/** + * Returns the parts of a schema's type name, from the parts of its file name: + * `material.textureInfo.schema.json` gives `["Material", "TextureInfo"]`. + * A glTF schema drops a leading `glTF`, so `glTFProperty.schema.json` gives + * `["Property"]`, and the root `glTF.schema.json` gives `[]`. An extension's + * schema drops the extension's name, so + * `glTF.EXT_structural_metadata.schema.json` gives `["Gltf"]`. + * + * @param {SchemaSet} schemaSet + * @param {string} fileName + * @returns {string[]} + */ +function getNameParts(schemaSet, fileName) { + let parts = fileName.replace(/\.schema\.json$/, "").split(/[./]/); + if (schemaSet.extensionName === undefined) { + parts[0] = parts[0].replace(/^glTF/, ""); + if (parts[0] === "") { + parts.shift(); + } + } else { + parts = parts.filter((part) => part !== schemaSet.extensionName); + } + return parts.map((part) => { + if (part === "glTF" || part === "gltf") { + return "Gltf"; + } + return part[0].toUpperCase() + part.slice(1); + }); +} + +/** + * Returns the qualified name of a schema's interface, recording the import it + * needs. + * + * @param {SchemaSet} schemaSet The schema set of the file that uses the name. + * @param {SchemaTarget} target + * @returns {string} + */ +function getTypeName(schemaSet, target) { + if (target.schemaSet !== schemaSet) { + schemaSet.imports.add(target.schemaSet); + } + return [ + target.schemaSet.rootName, + ...getNameParts(target.schemaSet, target.fileName), + ].join("."); +} + +/** + * Returns the reference to another schema in a schema, written as `$ref`, or + * as the `$ref` of the first member of `allOf`. + * + * @param {SchemaKeywords} schema + * @returns {string | undefined} + */ +function getReference(schema) { + return schema.$ref ?? schema.allOf?.[0].$ref; +} + +/** + * Returns the allowed values of a schema that lists them, or undefined. glTF + * 2.x lists each value as a member of `anyOf` with a `const`. glTF 1.0 lists + * them in `enum`, with their names in `gltf_enumNames`. + * + * @param {SchemaKeywords} schema + * @returns {EnumValue[] | undefined} + */ +function getEnumValues(schema) { + if (schema.anyOf?.some((member) => "const" in member)) { + return schema.anyOf + .filter((member) => "const" in member) + .map((member) => ({ + value: member.const, + description: member.description ?? member.title, + })); + } + if (schema.enum !== undefined) { + return schema.enum.map((value, index) => ({ + value: value, + description: schema.gltf_enumNames?.[index], + })); + } + return undefined; +} + +/** + * Returns a schema's description as doc comment lines, using the longer + * `gltf_detailedDescription` when there is one. + * + * @param {SchemaKeywords} schema + * @returns {string[]} + */ +function getDescriptionLines(schema) { + const description = schema.gltf_detailedDescription ?? schema.description; + if (description === undefined) { + return []; + } + return [description]; +} + +/** + * Marks the subject of a doc comment as added in glTF 2.1. + * + * @param {string[]} docLines + */ +function appendGltf21Marker(docLines) { + if (docLines.length === 0) { + docLines.push("(glTF 2.1)"); + } else { + docLines[docLines.length - 1] += " (glTF 2.1)"; + } +} + +/** + * Lists the allowed values of an enum property or of its array items, + * marking those absent from glTF 2.0. + * + * @param {SchemaKeywords} property + * @param {SchemaKeywords} [baselineProperty] + * @returns {string[]} + */ +function getEnumDocLines(property, baselineProperty) { + let enumSchema = property; + let baselineEnumSchema = baselineProperty; + let heading = "Allowed values:"; + if (property.type === "array" && property.items !== undefined) { + enumSchema = property.items; + baselineEnumSchema = baselineProperty?.items; + heading = "Allowed values for each element:"; + } + const enumValues = getEnumValues(enumSchema); + if (enumValues === undefined) { + return []; + } + let baselineValues; + if (baselineEnumSchema !== undefined) { + baselineValues = (getEnumValues(baselineEnumSchema) ?? []).map( + (enumValue) => enumValue.value, + ); + } + + const lines = ["", heading]; + for (const { value, description } of enumValues) { + let line = `- \`${JSON.stringify(value)}\``; + if (description !== undefined) { + line += `: ${description}`; + } + if (baselineValues !== undefined && !baselineValues.includes(value)) { + line += " (glTF 2.1)"; + } + lines.push(line); + } + return lines; +} + +/** + * Formats lines as a doc comment. + * + * @param {string[]} lines + * @returns {string} + */ +function formatDoc(lines) { + if (lines.length === 0) { + return ""; + } + // A blank line keeps markdown wrapping from joining tags to the description. + let docLines = lines; + const tagStart = lines.findIndex((line) => line.startsWith("@")); + if (tagStart > 0) { + docLines = [...lines.slice(0, tagStart), "", ...lines.slice(tagStart)]; + } + const body = docLines.map((line) => ` * ${line}`.trimEnd()).join("\n"); + return `/**\n${body}\n */\n`; +} + +/** + * Quotes a property name that isn't a valid identifier, like `3DTILES_tileset`. + * + * @param {string} name + * @returns {string} + */ +function formatPropertyName(name) { + if (/^[A-Za-z_$][\w$]*$/.test(name)) { + return name; + } + return JSON.stringify(name); +} + +/** + * Puts parentheses around a union or intersection type, so that a following + * `[]` applies to all of it. + * + * @param {string} type + * @returns {string} + */ +function wrapUnion(type) { + if (type.includes(" | ") || type.includes(" & ")) { + return `(${type})`; + } + return type; +} diff --git a/packages/gltf/scripts/gltfSchemaSources.json b/packages/gltf/scripts/gltfSchemaSources.json new file mode 100644 index 000000000000..9f106bda47a0 --- /dev/null +++ b/packages/gltf/scripts/gltfSchemaSources.json @@ -0,0 +1,730 @@ +{ + "core": { + "1.0": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "specification/1.0/schema" + }, + "2.0": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "specification/2.0/schema" + }, + "2.1": { + "repository": "KhronosGroup/glTF", + "branch": "draft-2.1", + "commit": "c330f9e5a324c9858145be183d2a1e63718fd3e8", + "schemaDirectory": "specification/2.1/schema" + } + }, + "extensions": { + "3DTILES_implicit_tiling": { + "repository": "CesiumGS/glTF", + "branch": "3d-tiles-2.0", + "commit": "e68efc9086f60743c331a2c757a1ffadcdb5d532", + "schemaDirectory": "extensions/2.1/Vendor/3DTILES_implicit_tiling/schema", + "core": [ + "2.1" + ], + "extends": { + "node.3DTILES_implicit_tiling.schema.json": [ + "node" + ] + } + }, + "3DTILES_subtree": { + "repository": "CesiumGS/glTF", + "branch": "3d-tiles-2.0", + "commit": "e68efc9086f60743c331a2c757a1ffadcdb5d532", + "schemaDirectory": "extensions/2.1/Vendor/3DTILES_subtree/schema", + "core": [ + "2.1" + ], + "extends": { + "glTF.3DTILES_subtree.schema.json": [ + "glTF" + ] + } + }, + "3DTILES_tileset": { + "repository": "CesiumGS/glTF", + "branch": "3d-tiles-2.0", + "commit": "e68efc9086f60743c331a2c757a1ffadcdb5d532", + "schemaDirectory": "extensions/2.1/Vendor/3DTILES_tileset/schema", + "core": [ + "2.1" + ], + "extends": { + "glTF.3DTILES_tileset.schema.json": [ + "glTF" + ], + "node.3DTILES_tileset.schema.json": [ + "node" + ] + } + }, + "3DTILES_tileset_voxels": { + "repository": "CesiumGS/glTF", + "branch": "3d-tiles-2.0", + "commit": "e68efc9086f60743c331a2c757a1ffadcdb5d532", + "schemaDirectory": "extensions/2.1/Vendor/3DTILES_tileset_voxels/schema", + "core": [ + "2.1" + ], + "extends": { + "glTF.3DTILES_tileset_voxels.schema.json": [ + "glTF" + ] + } + }, + "AGI_articulations": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Vendor/AGI_articulations/schema", + "core": [ + "2.x" + ], + "extends": { + "gltf.AGI_articulations.schema.json": [ + "glTF" + ], + "node.AGI_articulations.schema.json": [ + "node" + ] + } + }, + "BENTLEY_materials_line_style": { + "repository": "CesiumGS/glTF", + "branch": "cesium-native", + "commit": "c3fa3604e240616d021aca3ebf61d7b61379b986", + "schemaDirectory": "extensions/2.0/Vendor/BENTLEY_materials_line_style/schema", + "core": [ + "2.x" + ], + "extends": { + "material.BENTLEY_materials_line_style.schema.json": [ + "material" + ], + "mesh.primitive.BENTLEY_materials_line_style.schema.json": [ + "mesh.primitive" + ] + } + }, + "BENTLEY_materials_planar_fill": { + "repository": "CesiumGS/glTF", + "branch": "cesium-native", + "commit": "c3fa3604e240616d021aca3ebf61d7b61379b986", + "schemaDirectory": "extensions/2.0/Vendor/BENTLEY_materials_planar_fill/schema", + "core": [ + "2.x" + ], + "extends": { + "material.BENTLEY_materials_planar_fill.schema.json": [ + "material" + ] + } + }, + "BENTLEY_materials_point_style": { + "repository": "CesiumGS/glTF", + "branch": "cesium-native", + "commit": "c3fa3604e240616d021aca3ebf61d7b61379b986", + "schemaDirectory": "extensions/2.0/Vendor/BENTLEY_materials_point_style/schema", + "core": [ + "2.x" + ], + "extends": { + "material.BENTLEY_materials_point_style.schema.json": [ + "material" + ] + } + }, + "CESIUM_RTC": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/1.0/Vendor/CESIUM_RTC", + "core": [ + "1.0", + "2.x" + ], + "extends": { + "CESIUM_RTC.schema.json": [ + "glTF" + ] + } + }, + "CESIUM_primitive_outline": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Vendor/CESIUM_primitive_outline/schema", + "core": [ + "2.x" + ], + "extends": { + "primitive.CESIUM_primitive_outline.schema.json": [ + "mesh.primitive" + ] + } + }, + "CESIUM_tile_edges": { + "repository": "CesiumGS/glTF", + "branch": "3d-tiles-2.0", + "commit": "e68efc9086f60743c331a2c757a1ffadcdb5d532", + "schemaDirectory": "extensions/2.0/Vendor/CESIUM_tile_edges/schema", + "core": [ + "2.x" + ], + "extends": { + "mesh.primitive.CESIUM_tile_edges.schema.json": [ + "mesh.primitive" + ] + } + }, + "EXT_feature_metadata": { + "repository": "CesiumGS/glTF", + "branch": "3d-tiles-2.0", + "commit": "e68efc9086f60743c331a2c757a1ffadcdb5d532", + "schemaDirectory": "extensions/2.0/Vendor/EXT_feature_metadata/schema", + "core": [ + "2.x" + ], + "extends": { + "glTF.EXT_feature_metadata.schema.json": [ + "glTF" + ], + "mesh.primitive.EXT_feature_metadata.schema.json": [ + "mesh.primitive" + ], + "EXT_mesh_gpu_instancing/EXT_feature_metadata.schema.json": [ + "EXT_mesh_gpu_instancing/glTF.EXT_mesh_gpu_instancing" + ] + } + }, + "EXT_geospatial_crs": { + "repository": "CesiumGS/glTF", + "branch": "3d-tiles-2.0", + "commit": "e68efc9086f60743c331a2c757a1ffadcdb5d532", + "schemaDirectory": "extensions/2.1/Vendor/EXT_geospatial_crs/schema", + "core": [ + "2.1" + ], + "extends": { + "EXT_geospatial_crs.schema.json": [ + "glTF" + ] + } + }, + "EXT_geospatial_crs_wkid": { + "repository": "CesiumGS/glTF", + "branch": "3d-tiles-2.0", + "commit": "e68efc9086f60743c331a2c757a1ffadcdb5d532", + "schemaDirectory": "extensions/2.1/Vendor/EXT_geospatial_crs_wkid/schema", + "core": [ + "2.1" + ], + "extends": { + "EXT_geospatial_crs_wkid.schema.json": [ + "EXT_geospatial_crs/EXT_geospatial_crs" + ] + } + }, + "EXT_implicit_cylinder_region": { + "repository": "CesiumGS/glTF", + "branch": "3d-tiles-2.0", + "commit": "e68efc9086f60743c331a2c757a1ffadcdb5d532", + "schemaDirectory": "extensions/2.0/Vendor/EXT_implicit_cylinder_region/schema", + "core": [ + "2.x" + ], + "extends": { + "glTF.KHR_implicit_shapes.shape.EXT_implicit_cylinder_region.schema.json": [ + "KHR_implicit_shapes/glTF.KHR_implicit_shapes.shape" + ] + } + }, + "EXT_implicit_ellipsoid_region": { + "repository": "CesiumGS/glTF", + "branch": "3d-tiles-2.0", + "commit": "e68efc9086f60743c331a2c757a1ffadcdb5d532", + "schemaDirectory": "extensions/2.0/Vendor/EXT_implicit_ellipsoid_region/schema", + "core": [ + "2.x" + ], + "extends": { + "glTF.KHR_implicit_shapes.shape.EXT_implicit_ellipsoid_region.schema.json": [ + "KHR_implicit_shapes/glTF.KHR_implicit_shapes.shape" + ] + } + }, + "EXT_instance_features": { + "repository": "CesiumGS/glTF", + "branch": "3d-tiles-2.0", + "commit": "e68efc9086f60743c331a2c757a1ffadcdb5d532", + "schemaDirectory": "extensions/2.0/Vendor/EXT_instance_features/schema", + "core": [ + "2.x" + ], + "extends": { + "node.EXT_instance_features.schema.json": [ + "node" + ] + } + }, + "EXT_mesh_features": { + "repository": "CesiumGS/glTF", + "branch": "3d-tiles-2.0", + "commit": "e68efc9086f60743c331a2c757a1ffadcdb5d532", + "schemaDirectory": "extensions/2.0/Vendor/EXT_mesh_features/schema", + "core": [ + "2.x" + ], + "extends": { + "mesh.primitive.EXT_mesh_features.schema.json": [ + "mesh.primitive" + ] + } + }, + "EXT_mesh_gpu_instancing": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Vendor/EXT_mesh_gpu_instancing/schema", + "core": [ + "2.x" + ], + "extends": { + "glTF.EXT_mesh_gpu_instancing.schema.json": [ + "node" + ] + } + }, + "EXT_mesh_polygon": { + "repository": "CesiumGS/glTF", + "branch": "cesium-native", + "commit": "c3fa3604e240616d021aca3ebf61d7b61379b986", + "schemaDirectory": "extensions/2.0/Vendor/EXT_mesh_polygon", + "core": [ + "2.x" + ], + "extends": { + "EXT_mesh_polygon.schema.json": [ + "mesh.primitive" + ] + } + }, + "EXT_mesh_primitive_edge_visibility": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Vendor/EXT_mesh_primitive_edge_visibility/schema", + "core": [ + "2.x" + ], + "extends": { + "primitive.EXT_mesh_primitive_edge_visibility.schema.json": [ + "mesh.primitive" + ] + } + }, + "EXT_mesh_primitive_restart": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Vendor/EXT_mesh_primitive_restart/schema", + "core": [ + "2.x" + ], + "extends": { + "EXT_mesh_primitive_restart.schema.json": [ + "mesh" + ] + } + }, + "EXT_meshopt_compression": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Vendor/EXT_meshopt_compression/schema", + "core": [ + "2.x" + ], + "extends": { + "buffer.EXT_meshopt_compression.schema.json": [ + "buffer" + ], + "bufferView.EXT_meshopt_compression.schema.json": [ + "bufferView" + ] + } + }, + "EXT_primitive_voxels": { + "repository": "CesiumGS/glTF", + "branch": "3d-tiles-2.0", + "commit": "e68efc9086f60743c331a2c757a1ffadcdb5d532", + "schemaDirectory": "extensions/2.0/Vendor/EXT_primitive_voxels/schema", + "core": [ + "2.x" + ], + "extends": { + "mesh.primitive.EXT_primitive_voxels.schema.json": [ + "mesh.primitive" + ] + } + }, + "EXT_structural_metadata": { + "repository": "CesiumGS/glTF", + "branch": "3d-tiles-2.0", + "commit": "e68efc9086f60743c331a2c757a1ffadcdb5d532", + "schemaDirectory": "extensions/2.0/Vendor/EXT_structural_metadata/schema", + "core": [ + "2.x" + ], + "extends": { + "EXT_structural_metadata.schema.json": [ + "*" + ], + "glTF.EXT_structural_metadata.schema.json": [ + "glTF" + ], + "mesh.primitive.EXT_structural_metadata.schema.json": [ + "mesh.primitive" + ], + "node.EXT_voxels.EXT_structural_metadata.schema.json": [ + "EXT_voxels/node.EXT_voxels" + ] + } + }, + "EXT_textureInfo_constant_lod": { + "repository": "CesiumGS/glTF", + "branch": "cesium-native", + "commit": "c3fa3604e240616d021aca3ebf61d7b61379b986", + "schemaDirectory": "extensions/2.0/Vendor/EXT_textureInfo_constant_lod/schema", + "core": [ + "2.x" + ], + "extends": { + "textureInfo.EXT_textureInfo_constant_lod.schema.json": [ + "material.textureInfo" + ] + } + }, + "EXT_texture_webp": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Vendor/EXT_texture_webp/schema", + "core": [ + "2.x" + ], + "extends": { + "glTF.EXT_texture_webp.schema.json": [ + "texture" + ] + } + }, + "EXT_voxels": { + "repository": "CesiumGS/glTF", + "branch": "3d-tiles-2.0", + "commit": "e68efc9086f60743c331a2c757a1ffadcdb5d532", + "schemaDirectory": "extensions/2.1/Vendor/EXT_voxels/schema", + "core": [ + "2.1" + ], + "extends": { + "node.EXT_voxels.schema.json": [ + "node" + ] + } + }, + "KHR_binary_glTF": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/1.0/Khronos/KHR_binary_glTF/schema", + "core": [ + "1.0" + ], + "extends": { + "image.KHR_binary_glTF.schema.json": [ + "image" + ], + "shader.KHR_binary_glTF.schema.json": [ + "shader" + ] + } + }, + "KHR_draco_mesh_compression": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Khronos/KHR_draco_mesh_compression/schema", + "core": [ + "2.x" + ], + "extends": { + "mesh.primitive.KHR_draco_mesh_compression.schema.json": [ + "mesh.primitive" + ] + } + }, + "KHR_gaussian_splatting": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Khronos/KHR_gaussian_splatting/schema", + "core": [ + "2.x" + ], + "extends": { + "mesh.primitive.KHR_gaussian_splatting.schema.json": [ + "mesh.primitive" + ] + } + }, + "KHR_gaussian_splatting_compression_spz_2": { + "repository": "CesiumGS/glTF", + "branch": "cesium-native", + "commit": "c3fa3604e240616d021aca3ebf61d7b61379b986", + "schemaDirectory": "extensions/2.0/Khronos/KHR_gaussian_splatting_compression_spz_2/schema", + "core": [ + "2.x" + ], + "extends": { + "mesh.primitive.KHR_gaussian_splatting_compression_spz_2.schema.json": [ + "KHR_gaussian_splatting/mesh.primitive.KHR_gaussian_splatting" + ] + } + }, + "KHR_implicit_shapes": { + "repository": "CesiumGS/glTF", + "branch": "cesium-native", + "commit": "c3fa3604e240616d021aca3ebf61d7b61379b986", + "schemaDirectory": "extensions/2.0/Khronos/KHR_implicit_shapes/schema", + "core": [ + "2.x" + ], + "extends": { + "glTF.KHR_implicit_shapes.schema.json": [ + "glTF" + ] + } + }, + "KHR_materials_anisotropy": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Khronos/KHR_materials_anisotropy/schema", + "core": [ + "2.x" + ], + "extends": { + "material.KHR_materials_anisotropy.schema.json": [ + "material" + ] + } + }, + "KHR_materials_clearcoat": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Khronos/KHR_materials_clearcoat/schema", + "core": [ + "2.x" + ], + "extends": { + "material.KHR_materials_clearcoat.schema.json": [ + "material" + ] + } + }, + "KHR_materials_emissive_strength": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Khronos/KHR_materials_emissive_strength/schema", + "core": [ + "2.x" + ], + "extends": { + "material.KHR_materials_emissive_strength.schema.json": [ + "material" + ] + } + }, + "KHR_materials_pbrSpecularGlossiness": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness/schema", + "core": [ + "2.x" + ], + "extends": { + "glTF.KHR_materials_pbrSpecularGlossiness.schema.json": [ + "material" + ] + } + }, + "KHR_materials_specular": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Khronos/KHR_materials_specular/schema", + "core": [ + "2.x" + ], + "extends": { + "material.KHR_materials_specular.schema.json": [ + "material" + ] + } + }, + "KHR_materials_transmission": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Khronos/KHR_materials_transmission/schema", + "core": [ + "2.x" + ], + "extends": { + "material.KHR_materials_transmission.schema.json": [ + "material" + ] + } + }, + "KHR_materials_unlit": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Khronos/KHR_materials_unlit/schema", + "core": [ + "2.x" + ], + "extends": { + "material.KHR_materials_unlit.schema.json": [ + "material" + ] + } + }, + "KHR_mesh_primitive_restart": { + "core": [ + "2.x" + ] + }, + "KHR_mesh_quantization": { + "core": [ + "2.x" + ] + }, + "KHR_meshopt_compression": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Khronos/KHR_meshopt_compression/schema", + "core": [ + "2.x" + ], + "extends": { + "buffer.KHR_meshopt_compression.schema.json": [ + "buffer" + ], + "bufferView.KHR_meshopt_compression.schema.json": [ + "bufferView" + ] + } + }, + "KHR_node_visibility": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Khronos/KHR_node_visibility/schema", + "core": [ + "2.x" + ], + "extends": { + "node.KHR_node_visibility.schema.json": [ + "node" + ] + } + }, + "KHR_spz_gaussian_splats_compression": { + "repository": "CesiumGS/glTF", + "branch": "draft-spz-splat-compression", + "commit": "a4d88217e20f1ad86f4539bbae55ab6b931cb9cc", + "schemaDirectory": "extensions/2.0/Khronos/KHR_spz_gaussian_splats_compression/schema", + "core": [ + "2.x" + ], + "extends": { + "mesh.primitive.KHR_spz_gaussian_splats_compression.schema.json": [ + "mesh.primitive" + ] + } + }, + "KHR_techniques_webgl": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Archived/KHR_techniques_webgl/schema", + "core": [ + "2.x" + ], + "extends": { + "glTF.KHR_techniques_webgl.schema.json": [ + "glTF" + ], + "material.KHR_techniques_webgl.schema.json": [ + "material" + ] + } + }, + "KHR_texture_basisu": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Khronos/KHR_texture_basisu/schema", + "core": [ + "2.x" + ], + "extends": { + "texture.KHR_texture_basisu.schema.json": [ + "texture" + ] + } + }, + "KHR_texture_transform": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/2.0/Khronos/KHR_texture_transform/schema", + "core": [ + "2.x" + ], + "extends": { + "textureInfo.KHR_texture_transform.schema.json": [ + "material.textureInfo" + ] + } + }, + "WEB3D_quantized_attributes": { + "repository": "KhronosGroup/glTF", + "branch": "main", + "commit": "da88a3bbbe168cc728eddf71fa5e1915cc2c0629", + "schemaDirectory": "extensions/1.0/Vendor/WEB3D_quantized_attributes/schema", + "core": [ + "1.0", + "2.x" + ], + "extends": { + "WEB3D_quantized_attributes.accessor.schema.json": [ + "accessor" + ] + } + } + } +} diff --git a/packages/gltf/tsconfig.json b/packages/gltf/tsconfig.json index 563bbcd83520..7fbda422eb6b 100644 --- a/packages/gltf/tsconfig.json +++ b/packages/gltf/tsconfig.json @@ -1,5 +1,5 @@ { - "include": ["index.js", "Source/*.js"], + "include": ["index.js", "Source/*.js", "SchemaTypes/**/*.ts"], "extends": ["../../tsconfig.json"], "compilerOptions": { // The "strict mode" family of options is turned off by default to ease