Skip to content

Latest commit

 

History

History
508 lines (398 loc) · 24 KB

ObjectModel.adoc

File metadata and controls

508 lines (398 loc) · 24 KB

glTF 2.0 Asset Object Model Specification

Note
Note

Khronos posts the AsciiDoc source of the glTF specification to enable community feedback and remixing under CC-BY 4.0. Published versions of the Specification are located in the glTF Registry.

1. Foreword

Copyright 2023 The Khronos Group Inc.

This Document is protected by copyright laws and contains material proprietary to Khronos. Except as described by these terms, it or any components may not be reproduced, republished, distributed, transmitted, displayed, broadcast or otherwise exploited in any manner without the express prior written permission of Khronos.

Khronos grants a conditional copyright license to use and reproduce the unmodified Document for any purpose, without fee or royalty, EXCEPT no licenses to any patent, trademark or other intellectual property rights are granted under these terms.

Khronos makes no, and expressly disclaims any, representations or warranties, express or implied, regarding this Document, including, without limitation: merchantability, fitness for a particular purpose, non-infringement of any intellectual property, correctness, accuracy, completeness, timeliness, and reliability. Under no circumstances will Khronos, or any of its Promoters, Contributors or Members, or their respective partners, officers, directors, employees, agents or representatives be liable for any damages, whether direct, indirect, special or consequential damages for lost revenues, lost profits, or otherwise, arising from or in connection with these materials.

Khronos® is a registered trademark and glTF™ is a trademark of The Khronos Group Inc. All other product names, trademarks, and/or company names are used solely for identification and belong to their respective owners.

2. Introduction

2.1. General

This document, referred to as the “glTF 2.0 Asset Object Model Specification” or just the “Object Model” hereafter, describes a portable runtime object model of a glTF asset.

2.1.1. Normative References

The following documents are referenced by normative sections of the specification:

2.1.1.1. External Specifications

2.2. Motivation and Design Goals (Informative)

Although glTF 2.0 Specification does not define any runtime behavior, there is a growing demand for manipulating glTF assets at runtime and querying their state in a portable way.

Upon loading, applications usually parse glTF JSON into implementation-specific internal structures and therefore do not have a common protocol to manipulate asset contents.

This document defines a set of JSON pointers that glTF implementations are expected to support for identifying asset properties that could be manipulated at runtime.

3. Object Model Basics

  1. The Object Model is defined only for valid glTF assets. Querying or setting properties of invalid glTF assets are undefined.

  2. Upon loading an asset, an implementation registers specific glTF object properties for the Object Model by resolving JSON pointers identified by templates provided by this document to JSON properties of the asset being loaded. Undefined glTF properties that have schema-default values are considered defined with their default values.

  3. Each instance of empty curly braces ({}) in the pointer templates is replaced with the corresponding array element index for each glTF asset property matching the template.

  4. Since JSON does not natively support vectors and matrices, the Object Model defines explicit types for all supported properties. JSON pointers to properties of these types are resolved into implementation-specific vectors and matrices, not raw JSON arrays. Pointers to individual vector or matrix components are not resolved.

  5. Pointers to properties of explicit array types (as defined below) are resolved to implementation-defined arrays; pointers to array elements of properties of explicit array types are resolved to the corresponding array elements.

  6. In addition to properties directly linked to glTF JSON, the Object Model defines extra read-only properties that reflect commonly-used parts of the glTF runtime state. Specifically, array sizes and current node transforms.

  7. If a JSON pointer cannot be resolved to a glTF property, operations with it are undefined.

3.1. Data Types

The following data types are assumed by this document:

float

single or double precision IEEE-754 floating-point type

float[]

an array of float values

float2

a two-component vector of float values read from or set to JSON array elements with indices 0 and 1

float3

a three-component vector of float values read from or set to JSON array elements with indices 0, 1, and 2

float4

a four-component vector of float values read from or set to JSON array elements with indices 0, 1, 2, and 3

float4x4

a 4x4 matrix of float values

int

a signed integer type with width of at least 32 bits

4. Core Pointers

The following pointer templates represent mutable properties defined in the core glTF 2.0 Specification.

Pointer Type

/cameras/{}/orthographic/xmag

float

/cameras/{}/orthographic/ymag

float

/cameras/{}/orthographic/zfar

float

/cameras/{}/orthographic/znear

float

/cameras/{}/perspective/aspectRatio

float

/cameras/{}/perspective/yfov

float

/cameras/{}/perspective/zfar

float

/cameras/{}/perspective/znear

float

/materials/{}/alphaCutoff

float

/materials/{}/emissiveFactor

float3

/materials/{}/normalTexture/scale

float

/materials/{}/occlusionTexture/strength

float

/materials/{}/pbrMetallicRoughness/baseColorFactor

float4

/materials/{}/pbrMetallicRoughness/metallicFactor

float

/materials/{}/pbrMetallicRoughness/roughnessFactor

float

/meshes/{}/weights

float[]

/meshes/{}/weights/{}

float

/nodes/{}/translation

float3

/nodes/{}/rotation

float4

/nodes/{}/scale

float3

/nodes/{}/weights

float[]

/nodes/{}/weights/{}

float

Note
Note

As in the core glTF 2.0 Specification, lengths of the weights arrays match the number of the associated morph targets.

Additionally, the following pointer templates represent read-only runtime properties.

Pointer Type Comment

/animations.length

int

Number of animations

/cameras.length

int

Number of cameras

/materials.length

int

Number of materials

/meshes.length

int

Number of meshes

/meshes/{}/weights.length

int

Number of morph targets

/nodes.length

int

Number of nodes

/nodes/{}/matrix

float4x4

Local transformation matrix of a node

/nodes/{}/globalMatrix

float4x4

Global transformation matrix of a node

/nodes/{}/weights.length

int

Number of the associated mesh’s morph targets; undefined if the node has no mesh

/scenes.length

int

Number of scenes

5. Extension Pointers

The following pointer templates represent mutable properties defined in glTF 2.0 extensions.

5.1. KHR_texture_transform

Pointer Type

/materials/{}/normalTexture/extensions/KHR_texture_transform/offset

float2

/materials/{}/normalTexture/extensions/KHR_texture_transform/rotation

float

/materials/{}/normalTexture/extensions/KHR_texture_transform/scale

float2

/materials/{}/occlusionTexture/extensions/KHR_texture_transform/offset

float2

/materials/{}/occlusionTexture/extensions/KHR_texture_transform/rotation

float

/materials/{}/occlusionTexture/extensions/KHR_texture_transform/scale

float2

/materials/{}/emissiveTexture/extensions/KHR_texture_transform/offset

float2

/materials/{}/emissiveTexture/extensions/KHR_texture_transform/rotation

float

/materials/{}/emissiveTexture/extensions/KHR_texture_transform/scale

float2

/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset

float2

/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/rotation

float

/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale

float2

/materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/extensions/KHR_texture_transform/offset

float2

/materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/extensions/KHR_texture_transform/rotation

float

/materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/extensions/KHR_texture_transform/scale

float2

By definition, this extension applies to all properties of textureInfo type, including texture properties defined in other glTF 2.0 extensions.

5.2. KHR_lights_punctual

Pointer Type

/extensions/KHR_lights_punctual/lights/{}/color

float3

/extensions/KHR_lights_punctual/lights/{}/intensity

float

/extensions/KHR_lights_punctual/lights/{}/range

float

/extensions/KHR_lights_punctual/lights/{}/spot/innerConeAngle

float

/extensions/KHR_lights_punctual/lights/{}/spot/outerConeAngle

float

Additional read-only properties

Pointer Type Comment

/extensions/KHR_lights_punctual/lights.length

int

Number of punctual lights

5.3. KHR_materials_anisotropy

Pointer Type

/materials/{}/extensions/KHR_materials_anisotropy/anisotropyStrength

float

/materials/{}/extensions/KHR_materials_anisotropy/anisotropyRotation

float

5.3.1. Interaction with KHR_texture_transform

Pointer Type

/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/offset

float2

/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/rotation

float

/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/scale

float2

5.4. KHR_materials_clearcoat

Pointer Type

/materials/{}/extensions/KHR_materials_clearcoat/clearcoatFactor

float

/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor

float

/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/scale

float

5.4.1. Interaction with KHR_texture_transform

Pointer Type

/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/offset

float2

/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/rotation

float

/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/scale

float2

/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/offset

float2

/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/rotation

float

/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/scale

float2

/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/offset

float2

/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/rotation

float

/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/scale

float2

5.5. KHR_materials_dispersion

Pointer Type

/materials/{}/extensions/KHR_materials_dispersion/dispersion

float

5.6. KHR_materials_emissive_strength

Pointer Type

/materials/{}/extensions/KHR_materials_emissive_strength/emissiveStrength

float

5.7. KHR_materials_ior

Pointer Type

/materials/{}/extensions/KHR_materials_ior/ior

float

5.8. KHR_materials_iridescence

Pointer Type

/materials/{}/extensions/KHR_materials_iridescence/iridescenceFactor

float

/materials/{}/extensions/KHR_materials_iridescence/iridescenceIor

float

/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMinimum

float

/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMaximum

float

5.8.1. Interaction with KHR_texture_transform

Pointer Type

/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/offset

float2

/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/rotation

float

/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/scale

float2

/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/offset

float2

/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/rotation

float

/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/scale

float2

5.9. KHR_materials_sheen

Pointer Type

/materials/{}/extensions/KHR_materials_sheen/sheenColorFactor

float3

/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessFactor

float

5.9.1. Interaction with KHR_texture_transform

Pointer Type

/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/offset

float2

/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/rotation

float

/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/scale

float2

/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/offset

float2

/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/rotation

float

/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/scale

float2

5.10. KHR_materials_specular

Pointer Type

/materials/{}/extensions/KHR_materials_specular/specularFactor

float

/materials/{}/extensions/KHR_materials_specular/specularColorFactor

float3

5.10.1. Interaction with KHR_texture_transform

Pointer Type

/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/offset

float2

/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/rotation

float

/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/scale

float2

/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/offset

float2

/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/rotation

float

/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/scale

float2

5.11. KHR_materials_transmission

Pointer Type

/materials/{}/extensions/KHR_materials_transmission/transmissionFactor

float

5.11.1. Interaction with KHR_texture_transform

Pointer Type

/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/offset

float2

/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/rotation

float

/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/scale

float2

5.12. KHR_materials_volume

Pointer Type

/materials/{}/extensions/KHR_materials_volume/thicknessFactor

float

/materials/{}/extensions/KHR_materials_volume/attenuationDistance

float

/materials/{}/extensions/KHR_materials_volume/attenuationColor

float3

5.12.1. Interaction with KHR_texture_transform

Pointer Type

/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/offset

float2

/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/rotation

float

/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/scale

float2

5.13. EXT_lights_ies

Pointer Type

/nodes/{}/extensions/EXT_lights_ies/multiplier

float

/nodes/{}/extensions/EXT_lights_ies/color

float3

Additional read-only properties

Pointer Type Comment

/extensions/EXT_lights_ies/lights.length

int

Number of IES light profiles

5.14. EXT_lights_image_based

Pointer Type

/extensions/EXT_lights_image_based/lights/{}/rotation

float4

/extensions/EXT_lights_image_based/lights/{}/intensity

float

Additional read-only properties

Pointer Type Comment

/extensions/EXT_lights_image_based/lights.length

int

Number of image-based lights

5.15. ADOBE_materials_clearcoat_specular

Pointer Type

/materials/{}/extensions/ADOBE_materials_clearcoat_specular/clearcoatIor

float

/materials/{}/extensions/ADOBE_materials_clearcoat_specular/clearcoatSpecularFactor

float

5.15.1. Interaction with KHR_texture_transform

Pointer Type

/materials/{}/extensions/ADOBE_materials_clearcoat_specular/clearcoatSpecularTexture/extensions/KHR_texture_transform/offset

float2

/materials/{}/extensions/ADOBE_materials_clearcoat_specular/clearcoatSpecularTexture/extensions/KHR_texture_transform/rotation

float

/materials/{}/extensions/ADOBE_materials_clearcoat_specular/clearcoatSpecularTexture/extensions/KHR_texture_transform/scale

float2

5.16. ADOBE_materials_clearcoat_tint

Pointer Type

/materials/{}/extensions/ADOBE_materials_clearcoat_tint/clearcoatTintFactor

float3

5.16.1. Interaction with KHR_texture_transform

Pointer Type

/materials/{}/extensions/ADOBE_materials_clearcoat_tint/clearcoatTintTexture/extensions/KHR_texture_transform/offset

float2

/materials/{}/extensions/ADOBE_materials_clearcoat_tint/clearcoatTintTexture/extensions/KHR_texture_transform/rotation

float

/materials/{}/extensions/ADOBE_materials_clearcoat_tint/clearcoatTintTexture/extensions/KHR_texture_transform/scale

float2