diff --git a/src/gltf-structure/gltf-structure/Accessor.ts b/src/gltf-structure/gltf-structure/Accessor.ts new file mode 100644 index 00000000..f370f312 --- /dev/null +++ b/src/gltf-structure/gltf-structure/Accessor.ts @@ -0,0 +1,55 @@ +import { GlTFChildOfRootProperty } from "./GlTFChildOfRootProperty"; +import { GlTFid } from "./GlTFid"; +import { AccessorSparse } from "./AccessorSparse"; + +/** + * A typed view into a buffer view that contains raw binary data. + * @internal + */ +export interface Accessor extends GlTFChildOfRootProperty { + /** + * The index of the bufferView. + */ + bufferView?: GlTFid; + + /** + * The offset relative to the start of the buffer view in bytes. + */ + byteOffset?: number; + + /** + * The datatype of the accessor's components. + */ + componentType: number; + + /** + * Specifies whether integer data values are normalized before usage. + */ + normalized?: boolean; + + /** + * The number of elements referenced by this accessor. + */ + count: number; + + /** + * Specifies if the accessor's elements are scalars vectors or matrices. + */ + type: string; + + /** + * Maximum value of each component in this accessor. + */ + max?: number[]; + + /** + * Minimum value of each component in this accessor. + */ + min?: number[]; + + /** + * Sparse storage of elements that deviate from their initialization + * value. + */ + sparse?: AccessorSparse; +} diff --git a/src/gltf-structure/gltf-structure/AccessorSparse.ts b/src/gltf-structure/gltf-structure/AccessorSparse.ts new file mode 100644 index 00000000..25349a5e --- /dev/null +++ b/src/gltf-structure/gltf-structure/AccessorSparse.ts @@ -0,0 +1,28 @@ +import { GlTFProperty } from "./GlTFProperty"; +import { AccessorSparseIndices } from "./AccessorSparseIndices"; +import { AccessorSparseValues } from "./AccessorSparseValues"; + +/** + * Sparse storage of accessor values that deviate from their + * initialization value. + * @internal + */ +export interface AccessorSparse extends GlTFProperty { + /** + * Number of deviating accessor values stored in the sparse array. + */ + count: number; + + /** + * An object pointing to a buffer view containing the indices of + * deviating accessor values. The number of indices is equal to `count`. + * Indices **MUST** strictly increase. + */ + indices: AccessorSparseIndices; + + /** + * An object pointing to a buffer view containing the deviating accessor + * values. + */ + values: AccessorSparseValues; +} diff --git a/src/gltf-structure/gltf-structure/AccessorSparseIndices.ts b/src/gltf-structure/gltf-structure/AccessorSparseIndices.ts new file mode 100644 index 00000000..6c541d6d --- /dev/null +++ b/src/gltf-structure/gltf-structure/AccessorSparseIndices.ts @@ -0,0 +1,28 @@ +import { GlTFProperty } from "./GlTFProperty"; +import { GlTFid } from "./GlTFid"; + +/** + * An object pointing to a buffer view containing the indices of + * deviating accessor values. The number of indices is equal to + * `accessor.sparse.count`. Indices **MUST** strictly increase. + * @internal + */ +export interface AccessorSparseIndices extends GlTFProperty { + /** + * The index of the buffer view with sparse indices. The referenced + * buffer view **MUST NOT** have its `target` or `byteStride` properties + * defined. The buffer view and the optional `byteOffset` **MUST** be + * aligned to the `componentType` byte length. + */ + bufferView: GlTFid; + + /** + * The offset relative to the start of the buffer view in bytes. + */ + byteOffset?: number; + + /** + * The indices data type. + */ + componentType: number; +} diff --git a/src/gltf-structure/gltf-structure/AccessorSparseValues.ts b/src/gltf-structure/gltf-structure/AccessorSparseValues.ts new file mode 100644 index 00000000..7e79174d --- /dev/null +++ b/src/gltf-structure/gltf-structure/AccessorSparseValues.ts @@ -0,0 +1,24 @@ +import { GlTFProperty } from "./GlTFProperty"; +import { GlTFid } from "./GlTFid"; + +/** + * An object pointing to a buffer view containing the deviating accessor + * values. The number of elements is equal to `accessor.sparse.count` + * times number of components. The elements have the same component type + * as the base accessor. The elements are tightly packed. Data **MUST** + * be aligned following the same rules as the base accessor. + * @internal + */ +export interface AccessorSparseValues extends GlTFProperty { + /** + * The index of the bufferView with sparse values. The referenced buffer + * view **MUST NOT** have its `target` or `byteStride` properties + * defined. + */ + bufferView: GlTFid; + + /** + * The offset relative to the start of the bufferView in bytes. + */ + byteOffset?: number; +} diff --git a/src/gltf-structure/gltf-structure/Animation.ts b/src/gltf-structure/gltf-structure/Animation.ts new file mode 100644 index 00000000..4584145e --- /dev/null +++ b/src/gltf-structure/gltf-structure/Animation.ts @@ -0,0 +1,23 @@ +import { GlTFChildOfRootProperty } from "./GlTFChildOfRootProperty"; +import { AnimationChannel } from "./AnimationChannel"; +import { AnimationSampler } from "./AnimationSampler"; + +/** + * A keyframe animation. + * @internal + */ +export interface Animation extends GlTFChildOfRootProperty { + /** + * An array of animation channels. An animation channel combines an + * animation sampler with a target property being animated. Different + * channels of the same animation **MUST NOT** have the same targets. + */ + channels: AnimationChannel[]; + + /** + * An array of animation samplers. An animation sampler combines + * timestamps with a sequence of output values and defines an + * interpolation algorithm. + */ + samplers: AnimationSampler[]; +} diff --git a/src/gltf-structure/gltf-structure/AnimationChannel.ts b/src/gltf-structure/gltf-structure/AnimationChannel.ts new file mode 100644 index 00000000..01f83aad --- /dev/null +++ b/src/gltf-structure/gltf-structure/AnimationChannel.ts @@ -0,0 +1,21 @@ +import { GlTFProperty } from "./GlTFProperty"; +import { GlTFid } from "./GlTFid"; +import { AnimationChannelTarget } from "./AnimationChannelTarget"; + +/** + * An animation channel combines an animation sampler with a target + * property being animated. + * @internal + */ +export interface AnimationChannel extends GlTFProperty { + /** + * The index of a sampler in this animation used to compute the value for + * the target. + */ + sampler: GlTFid; + + /** + * The descriptor of the animated property. + */ + target: AnimationChannelTarget; +} diff --git a/src/gltf-structure/gltf-structure/AnimationChannelTarget.ts b/src/gltf-structure/gltf-structure/AnimationChannelTarget.ts new file mode 100644 index 00000000..18d104b3 --- /dev/null +++ b/src/gltf-structure/gltf-structure/AnimationChannelTarget.ts @@ -0,0 +1,25 @@ +import { GlTFProperty } from "./GlTFProperty"; +import { GlTFid } from "./GlTFid"; + +/** + * The descriptor of the animated property. + * @internal + */ +export interface AnimationChannelTarget extends GlTFProperty { + /** + * The index of the node to animate. When undefined the animated object + * **MAY** be defined by an extension. + */ + node?: GlTFid; + + /** + * The name of the node's TRS property to animate or the `"weights"` of + * the Morph Targets it instantiates. For the `"translation"` property + * the values that are provided by the sampler are the translation along + * the X Y and Z axes. For the `"rotation"` property the values are a + * quaternion in the order (x y z w) where w is the scalar. For the + * `"scale"` property the values are the scaling factors along the X Y + * and Z axes. + */ + path: string; +} diff --git a/src/gltf-structure/gltf-structure/AnimationSampler.ts b/src/gltf-structure/gltf-structure/AnimationSampler.ts new file mode 100644 index 00000000..d7b9657c --- /dev/null +++ b/src/gltf-structure/gltf-structure/AnimationSampler.ts @@ -0,0 +1,24 @@ +import { GlTFProperty } from "./GlTFProperty"; +import { GlTFid } from "./GlTFid"; + +/** + * An animation sampler combines timestamps with a sequence of output + * values and defines an interpolation algorithm. + * @internal + */ +export interface AnimationSampler extends GlTFProperty { + /** + * The index of an accessor containing keyframe timestamps. + */ + input: GlTFid; + + /** + * Interpolation algorithm. + */ + interpolation?: string; + + /** + * The index of an accessor containing keyframe output values. + */ + output: GlTFid; +} diff --git a/src/gltf-structure/gltf-structure/Asset.ts b/src/gltf-structure/gltf-structure/Asset.ts new file mode 100644 index 00000000..1b784d40 --- /dev/null +++ b/src/gltf-structure/gltf-structure/Asset.ts @@ -0,0 +1,31 @@ +import { GlTFProperty } from "./GlTFProperty"; + +/** + * Metadata about the glTF asset. + * @internal + */ +export interface Asset extends GlTFProperty { + /** + * A copyright message suitable for display to credit the content + * creator. + */ + copyright?: string; + + /** + * Tool that generated this glTF model. Useful for debugging. + */ + generator?: string; + + /** + * The glTF version in the form of `.` that this asset + * targets. + */ + version: string; + + /** + * The minimum glTF version in the form of `.` that this + * asset targets. This property **MUST NOT** be greater than the asset + * version. + */ + minVersion?: string; +} diff --git a/src/gltf-structure/gltf-structure/BufferObject.ts b/src/gltf-structure/gltf-structure/BufferObject.ts new file mode 100644 index 00000000..11413036 --- /dev/null +++ b/src/gltf-structure/gltf-structure/BufferObject.ts @@ -0,0 +1,17 @@ +import { GlTFChildOfRootProperty } from "./GlTFChildOfRootProperty"; + +/** + * A buffer points to binary geometry animation or skins. + * @internal + */ +export interface BufferObject extends GlTFChildOfRootProperty { + /** + * The URI (or IRI) of the buffer. + */ + uri?: string; + + /** + * The length of the buffer in bytes. + */ + byteLength: number; +} diff --git a/src/gltf-structure/gltf-structure/BufferView.ts b/src/gltf-structure/gltf-structure/BufferView.ts new file mode 100644 index 00000000..bf9b3e3e --- /dev/null +++ b/src/gltf-structure/gltf-structure/BufferView.ts @@ -0,0 +1,34 @@ +import { GlTFChildOfRootProperty } from "./GlTFChildOfRootProperty"; +import { GlTFid } from "./GlTFid"; + +/** + * A view into a buffer generally representing a subset of the buffer. + * @internal + */ +export interface BufferView extends GlTFChildOfRootProperty { + /** + * The index of the buffer. + */ + buffer: GlTFid; + + /** + * The offset into the buffer in bytes. + */ + byteOffset?: number; + + /** + * The length of the bufferView in bytes. + */ + byteLength: number; + + /** + * The stride in bytes. + */ + byteStride?: number; + + /** + * The hint representing the intended GPU buffer type to use with this + * buffer view. + */ + target?: number; +} diff --git a/src/gltf-structure/gltf-structure/Camera.ts b/src/gltf-structure/gltf-structure/Camera.ts new file mode 100644 index 00000000..f41a606d --- /dev/null +++ b/src/gltf-structure/gltf-structure/Camera.ts @@ -0,0 +1,29 @@ +import { GlTFChildOfRootProperty } from "./GlTFChildOfRootProperty"; +import { CameraOrthographic } from "./CameraOrthographic"; +import { CameraPerspective } from "./CameraPerspective"; + +/** + * A camera's projection. A node **MAY** reference a camera to apply a + * transform to place the camera in the scene. + * @internal + */ +export interface Camera extends GlTFChildOfRootProperty { + /** + * An orthographic camera containing properties to create an orthographic + * projection matrix. This property **MUST NOT** be defined when + * `perspective` is defined. + */ + orthographic?: CameraOrthographic; + + /** + * A perspective camera containing properties to create a perspective + * projection matrix. This property **MUST NOT** be defined when + * `orthographic` is defined. + */ + perspective?: CameraPerspective; + + /** + * Specifies if the camera uses a perspective or orthographic projection. + */ + type: string; +} diff --git a/src/gltf-structure/gltf-structure/CameraOrthographic.ts b/src/gltf-structure/gltf-structure/CameraOrthographic.ts new file mode 100644 index 00000000..46fc4235 --- /dev/null +++ b/src/gltf-structure/gltf-structure/CameraOrthographic.ts @@ -0,0 +1,32 @@ +import { GlTFProperty } from "./GlTFProperty"; + +/** + * An orthographic camera containing properties to create an orthographic + * projection matrix. + * @internal + */ +export interface CameraOrthographic extends GlTFProperty { + /** + * The floating-point horizontal magnification of the view. This value + * **MUST NOT** be equal to zero. This value **SHOULD NOT** be negative. + */ + xmag: number; + + /** + * The floating-point vertical magnification of the view. This value + * **MUST NOT** be equal to zero. This value **SHOULD NOT** be negative. + */ + ymag: number; + + /** + * The floating-point distance to the far clipping plane. This value + * **MUST NOT** be equal to zero. `zfar` **MUST** be greater than + * `znear`. + */ + zfar: number; + + /** + * The floating-point distance to the near clipping plane. + */ + znear: number; +} diff --git a/src/gltf-structure/gltf-structure/CameraPerspective.ts b/src/gltf-structure/gltf-structure/CameraPerspective.ts new file mode 100644 index 00000000..699e3fd7 --- /dev/null +++ b/src/gltf-structure/gltf-structure/CameraPerspective.ts @@ -0,0 +1,29 @@ +import { GlTFProperty } from "./GlTFProperty"; + +/** + * A perspective camera containing properties to create a perspective + * projection matrix. + * @internal + */ +export interface CameraPerspective extends GlTFProperty { + /** + * The floating-point aspect ratio of the field of view. + */ + aspectRatio?: number; + + /** + * The floating-point vertical field of view in radians. This value + * **SHOULD** be less than π. + */ + yfov: number; + + /** + * The floating-point distance to the far clipping plane. + */ + zfar?: number; + + /** + * The floating-point distance to the near clipping plane. + */ + znear: number; +} diff --git a/src/gltf-structure/gltf-structure/GlTF.ts b/src/gltf-structure/gltf-structure/GlTF.ts new file mode 100644 index 00000000..7ebe49b0 --- /dev/null +++ b/src/gltf-structure/gltf-structure/GlTF.ts @@ -0,0 +1,107 @@ +import { GlTFProperty } from "./GlTFProperty"; +import { Accessor } from "./Accessor"; +import { Animation } from "./Animation"; +import { Asset } from "./Asset"; +import { BufferObject } from "./BufferObject"; +import { BufferView } from "./BufferView"; +import { Camera } from "./Camera"; +import { Image } from "./Image"; +import { Material } from "./Material"; +import { Mesh } from "./Mesh"; +import { Node } from "./Node"; +import { Sampler } from "./Sampler"; +import { GlTFid } from "./GlTFid"; +import { Scene } from "./Scene"; +import { Skin } from "./Skin"; +import { Texture } from "./Texture"; + +/** + * The root object for a glTF asset. + * @internal + */ +export interface GlTF extends GlTFProperty { + /** + * Names of glTF extensions used in this asset. + */ + extensionsUsed?: string[]; + + /** + * Names of glTF extensions required to properly load this asset. + */ + extensionsRequired?: string[]; + + /** + * An array of accessors. + */ + accessors?: Accessor[]; + + /** + * An array of keyframe animations. + */ + animations?: Animation[]; + + /** + * Metadata about the glTF asset. + */ + asset: Asset; + + /** + * An array of buffers. + */ + buffers?: BufferObject[]; + + /** + * An array of bufferViews. + */ + bufferViews?: BufferView[]; + + /** + * An array of cameras. + */ + cameras?: Camera[]; + + /** + * An array of images. + */ + images?: Image[]; + + /** + * An array of materials. + */ + materials?: Material[]; + + /** + * An array of meshes. + */ + meshes?: Mesh[]; + + /** + * An array of nodes. + */ + nodes?: Node[]; + + /** + * An array of samplers. + */ + samplers?: Sampler[]; + + /** + * The index of the default scene. + */ + scene?: GlTFid; + + /** + * An array of scenes. + */ + scenes?: Scene[]; + + /** + * An array of skins. + */ + skins?: Skin[]; + + /** + * An array of textures. + */ + textures?: Texture[]; +} diff --git a/src/gltf-structure/gltf-structure/GlTFChildOfRootProperty.ts b/src/gltf-structure/gltf-structure/GlTFChildOfRootProperty.ts new file mode 100644 index 00000000..68fe2320 --- /dev/null +++ b/src/gltf-structure/gltf-structure/GlTFChildOfRootProperty.ts @@ -0,0 +1,13 @@ +import { GlTFProperty } from "./GlTFProperty"; + +/** + * glTF Child of Root Property + * + * @internal + */ +export interface GlTFChildOfRootProperty extends GlTFProperty { + /** + * The user-defined name of this object. + */ + name?: string; +} diff --git a/src/gltf-structure/gltf-structure/GlTFProperty.ts b/src/gltf-structure/gltf-structure/GlTFProperty.ts new file mode 100644 index 00000000..a696e6ad --- /dev/null +++ b/src/gltf-structure/gltf-structure/GlTFProperty.ts @@ -0,0 +1,16 @@ +/** + * glTF Property + * + * @internal + */ +export interface GlTFProperty { + /** + * The extensions of this property + */ + extensions?: { [key: string]: { [key: string]: any } }; + + /** + * The extras of this property + */ + extras?: { [key: string]: any }; +} diff --git a/src/gltf-structure/gltf-structure/GlTFid.ts b/src/gltf-structure/gltf-structure/GlTFid.ts new file mode 100644 index 00000000..9c12ea81 --- /dev/null +++ b/src/gltf-structure/gltf-structure/GlTFid.ts @@ -0,0 +1,4 @@ +/** + * @internal + */ +export type GlTFid = number; diff --git a/src/gltf-structure/gltf-structure/Image.ts b/src/gltf-structure/gltf-structure/Image.ts new file mode 100644 index 00000000..f0cd89f8 --- /dev/null +++ b/src/gltf-structure/gltf-structure/Image.ts @@ -0,0 +1,26 @@ +import { GlTFChildOfRootProperty } from "./GlTFChildOfRootProperty"; +import { GlTFid } from "./GlTFid"; + +/** + * Image data used to create a texture. Image **MAY** be referenced by an + * URI (or IRI) or a buffer view index. + * @internal + */ +export interface Image extends GlTFChildOfRootProperty { + /** + * The URI (or IRI) of the image. + */ + uri?: string; + + /** + * The image's media type. This field **MUST** be defined when + * `bufferView` is defined. + */ + mimeType?: string; + + /** + * The index of the bufferView that contains the image. This field **MUST + * NOT** be defined when `uri` is defined. + */ + bufferView?: GlTFid; +} diff --git a/src/gltf-structure/gltf-structure/Material.ts b/src/gltf-structure/gltf-structure/Material.ts new file mode 100644 index 00000000..ef69abdf --- /dev/null +++ b/src/gltf-structure/gltf-structure/Material.ts @@ -0,0 +1,54 @@ +import { GlTFChildOfRootProperty } from "./GlTFChildOfRootProperty"; +import { MaterialPbrMetallicRoughness } from "./MaterialPbrMetallicRoughness"; +import { MaterialNormalTextureInfo } from "./MaterialNormalTextureInfo"; +import { MaterialOcclusionTextureInfo } from "./MaterialOcclusionTextureInfo"; +import { TextureInfo } from "./TextureInfo"; + +/** + * The material appearance of a primitive. + * @internal + */ +export interface Material extends GlTFChildOfRootProperty { + /** + * A set of parameter values that are used to define the + * metallic-roughness material model from Physically Based Rendering + * (PBR) methodology. When undefined all the default values of + * `pbrMetallicRoughness` **MUST** apply. + */ + pbrMetallicRoughness?: MaterialPbrMetallicRoughness; + + /** + * The tangent space normal texture. + */ + normalTexture?: MaterialNormalTextureInfo; + + /** + * The occlusion texture. + */ + occlusionTexture?: MaterialOcclusionTextureInfo; + + /** + * The emissive texture. + */ + emissiveTexture?: TextureInfo; + + /** + * The factors for the emissive color of the material. + */ + emissiveFactor?: number[]; + + /** + * The alpha rendering mode of the material. + */ + alphaMode?: string; + + /** + * The alpha cutoff value of the material. + */ + alphaCutoff?: number; + + /** + * Specifies whether the material is double sided. + */ + doubleSided?: boolean; +} diff --git a/src/gltf-structure/gltf-structure/MaterialNormalTextureInfo.ts b/src/gltf-structure/gltf-structure/MaterialNormalTextureInfo.ts new file mode 100644 index 00000000..a70b009e --- /dev/null +++ b/src/gltf-structure/gltf-structure/MaterialNormalTextureInfo.ts @@ -0,0 +1,12 @@ +import { TextureInfo } from "./TextureInfo"; + +/** + * @internal + */ +export interface MaterialNormalTextureInfo extends TextureInfo { + /** + * The scalar parameter applied to each normal vector of the normal + * texture. + */ + scale?: number; +} diff --git a/src/gltf-structure/gltf-structure/MaterialOcclusionTextureInfo.ts b/src/gltf-structure/gltf-structure/MaterialOcclusionTextureInfo.ts new file mode 100644 index 00000000..752653ea --- /dev/null +++ b/src/gltf-structure/gltf-structure/MaterialOcclusionTextureInfo.ts @@ -0,0 +1,11 @@ +import { TextureInfo } from "./TextureInfo"; + +/** + * @internal + */ +export interface MaterialOcclusionTextureInfo extends TextureInfo { + /** + * A scalar multiplier controlling the amount of occlusion applied. + */ + strength?: number; +} diff --git a/src/gltf-structure/gltf-structure/MaterialPbrMetallicRoughness.ts b/src/gltf-structure/gltf-structure/MaterialPbrMetallicRoughness.ts new file mode 100644 index 00000000..bc98e044 --- /dev/null +++ b/src/gltf-structure/gltf-structure/MaterialPbrMetallicRoughness.ts @@ -0,0 +1,35 @@ +import { GlTFProperty } from "./GlTFProperty"; +import { TextureInfo } from "./TextureInfo"; + +/** + * A set of parameter values that are used to define the + * metallic-roughness material model from Physically-Based Rendering + * (PBR) methodology. + * @internal + */ +export interface MaterialPbrMetallicRoughness extends GlTFProperty { + /** + * The factors for the base color of the material. + */ + baseColorFactor?: number[]; + + /** + * The base color texture. + */ + baseColorTexture?: TextureInfo; + + /** + * The factor for the metalness of the material. + */ + metallicFactor?: number; + + /** + * The factor for the roughness of the material. + */ + roughnessFactor?: number; + + /** + * The metallic-roughness texture. + */ + metallicRoughnessTexture?: TextureInfo; +} diff --git a/src/gltf-structure/gltf-structure/Mesh.ts b/src/gltf-structure/gltf-structure/Mesh.ts new file mode 100644 index 00000000..e8b8b3d1 --- /dev/null +++ b/src/gltf-structure/gltf-structure/Mesh.ts @@ -0,0 +1,20 @@ +import { GlTFChildOfRootProperty } from "./GlTFChildOfRootProperty"; +import { MeshPrimitive } from "./MeshPrimitive"; + +/** + * A set of primitives to be rendered. Its global transform is defined by + * a node that references it. + * @internal + */ +export interface Mesh extends GlTFChildOfRootProperty { + /** + * An array of primitives each defining geometry to be rendered. + */ + primitives: MeshPrimitive[]; + + /** + * Array of weights to be applied to the morph targets. The number of + * array elements **MUST** match the number of morph targets. + */ + weights?: number[]; +} diff --git a/src/gltf-structure/gltf-structure/MeshPrimitive.ts b/src/gltf-structure/gltf-structure/MeshPrimitive.ts new file mode 100644 index 00000000..b7a59c29 --- /dev/null +++ b/src/gltf-structure/gltf-structure/MeshPrimitive.ts @@ -0,0 +1,35 @@ +import { GlTFProperty } from "./GlTFProperty"; +import { GlTFid } from "./GlTFid"; + +/** + * Geometry to be rendered with the given material. + * @internal + */ +export interface MeshPrimitive extends GlTFProperty { + /** + * A plain JSON object where each key corresponds to a mesh attribute + * semantic and each value is the index of the accessor containing + * attribute's data. + */ + attributes: { [key: string]: GlTFid }; + + /** + * The index of the accessor that contains the vertex indices. + */ + indices?: GlTFid; + + /** + * The index of the material to apply to this primitive when rendering. + */ + material?: GlTFid; + + /** + * The topology type of primitives to render. + */ + mode?: number; + + /** + * An array of morph targets. + */ + targets?: object[]; +} diff --git a/src/gltf-structure/gltf-structure/Node.ts b/src/gltf-structure/gltf-structure/Node.ts new file mode 100644 index 00000000..a490943c --- /dev/null +++ b/src/gltf-structure/gltf-structure/Node.ts @@ -0,0 +1,67 @@ +import { GlTFChildOfRootProperty } from "./GlTFChildOfRootProperty"; +import { GlTFid } from "./GlTFid"; + +/** + * A node in the node hierarchy. When the node contains `skin` all + * `mesh.primitives` **MUST** contain `JOINTS_0` and `WEIGHTS_0` + * attributes. A node **MAY** 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) `matrix` **MUST + * NOT** be present. + * @internal + */ +export interface Node extends GlTFChildOfRootProperty { + /** + * The index of the camera referenced by this node. + */ + camera?: GlTFid; + + /** + * The indices of this node's children. + */ + children?: GlTFid[]; + + /** + * The index of the skin referenced by this node. + */ + skin?: GlTFid; + + /** + * A floating-point 4x4 transformation matrix stored in column-major + * order. + */ + matrix?: number[]; + + /** + * The index of the mesh in this node. + */ + mesh?: GlTFid; + + /** + * The node's unit quaternion rotation in the order (x y z w) where w is + * the scalar. + */ + rotation?: number[]; + + /** + * The node's non-uniform scale given as the scaling factors along the x + * y and z axes. + */ + scale?: number[]; + + /** + * The node's translation along the x y and z axes. + */ + translation?: number[]; + + /** + * The weights of the instantiated morph target. The number of array + * elements **MUST** match the number of morph targets of the referenced + * mesh. When defined `mesh` **MUST** also be defined. + */ + weights?: number[]; +} diff --git a/src/gltf-structure/gltf-structure/Sampler.ts b/src/gltf-structure/gltf-structure/Sampler.ts new file mode 100644 index 00000000..74c439aa --- /dev/null +++ b/src/gltf-structure/gltf-structure/Sampler.ts @@ -0,0 +1,27 @@ +import { GlTFChildOfRootProperty } from "./GlTFChildOfRootProperty"; + +/** + * Texture sampler properties for filtering and wrapping modes. + * @internal + */ +export interface Sampler extends GlTFChildOfRootProperty { + /** + * Magnification filter. + */ + magFilter?: number; + + /** + * Minification filter. + */ + minFilter?: number; + + /** + * S (U) wrapping mode. + */ + wrapS?: number; + + /** + * T (V) wrapping mode. + */ + wrapT?: number; +} diff --git a/src/gltf-structure/gltf-structure/Scene.ts b/src/gltf-structure/gltf-structure/Scene.ts new file mode 100644 index 00000000..9068a53e --- /dev/null +++ b/src/gltf-structure/gltf-structure/Scene.ts @@ -0,0 +1,13 @@ +import { GlTFChildOfRootProperty } from "./GlTFChildOfRootProperty"; +import { GlTFid } from "./GlTFid"; + +/** + * The root nodes of a scene. + * @internal + */ +export interface Scene extends GlTFChildOfRootProperty { + /** + * The indices of each root node. + */ + nodes?: GlTFid[]; +} diff --git a/src/gltf-structure/gltf-structure/Skin.ts b/src/gltf-structure/gltf-structure/Skin.ts new file mode 100644 index 00000000..7750dcfc --- /dev/null +++ b/src/gltf-structure/gltf-structure/Skin.ts @@ -0,0 +1,24 @@ +import { GlTFChildOfRootProperty } from "./GlTFChildOfRootProperty"; +import { GlTFid } from "./GlTFid"; + +/** + * Joints and matrices defining a skin. + * @internal + */ +export interface Skin extends GlTFChildOfRootProperty { + /** + * The index of the accessor containing the floating-point 4x4 + * inverse-bind matrices. + */ + inverseBindMatrices?: GlTFid; + + /** + * The index of the node used as a skeleton root. + */ + skeleton?: GlTFid; + + /** + * Indices of skeleton nodes used as joints in this skin. + */ + joints: GlTFid[]; +} diff --git a/src/gltf-structure/gltf-structure/Texture.ts b/src/gltf-structure/gltf-structure/Texture.ts new file mode 100644 index 00000000..2463dc14 --- /dev/null +++ b/src/gltf-structure/gltf-structure/Texture.ts @@ -0,0 +1,21 @@ +import { GlTFChildOfRootProperty } from "./GlTFChildOfRootProperty"; +import { GlTFid } from "./GlTFid"; + +/** + * A texture and its sampler. + * @internal + */ +export interface Texture extends GlTFChildOfRootProperty { + /** + * The index of the sampler used by this texture. When undefined a + * sampler with repeat wrapping and auto filtering **SHOULD** be used. + */ + sampler?: GlTFid; + + /** + * The index of the image used by this texture. When undefined an + * extension or other mechanism **SHOULD** supply an alternate texture + * source otherwise behavior is undefined. + */ + source?: GlTFid; +} diff --git a/src/gltf-structure/gltf-structure/TextureInfo.ts b/src/gltf-structure/gltf-structure/TextureInfo.ts new file mode 100644 index 00000000..22bbf78e --- /dev/null +++ b/src/gltf-structure/gltf-structure/TextureInfo.ts @@ -0,0 +1,19 @@ +import { GlTFProperty } from "./GlTFProperty"; +import { GlTFid } from "./GlTFid"; + +/** + * Reference to a texture. + * @internal + */ +export interface TextureInfo extends GlTFProperty { + /** + * The index of the texture. + */ + index: GlTFid; + + /** + * The set index of texture's TEXCOORD attribute used for texture + * coordinate mapping. + */ + texCoord?: number; +} diff --git a/src/gltf-structure/index.ts b/src/gltf-structure/index.ts new file mode 100644 index 00000000..19285faf --- /dev/null +++ b/src/gltf-structure/index.ts @@ -0,0 +1,31 @@ +export * from "./gltf-structure/Accessor"; +export * from "./gltf-structure/AccessorSparse"; +export * from "./gltf-structure/AccessorSparseIndices"; +export * from "./gltf-structure/AccessorSparseValues"; +export * from "./gltf-structure/Animation"; +export * from "./gltf-structure/AnimationChannel"; +export * from "./gltf-structure/AnimationChannelTarget"; +export * from "./gltf-structure/AnimationSampler"; +export * from "./gltf-structure/Asset"; +export * from "./gltf-structure/BufferObject"; +export * from "./gltf-structure/BufferView"; +export * from "./gltf-structure/Camera"; +export * from "./gltf-structure/CameraOrthographic"; +export * from "./gltf-structure/CameraPerspective"; +export * from "./gltf-structure/GlTF"; +export * from "./gltf-structure/GlTFChildOfRootProperty"; +export * from "./gltf-structure/GlTFid"; +export * from "./gltf-structure/GlTFProperty"; +export * from "./gltf-structure/Image"; +export * from "./gltf-structure/Material"; +export * from "./gltf-structure/MaterialNormalTextureInfo"; +export * from "./gltf-structure/MaterialOcclusionTextureInfo"; +export * from "./gltf-structure/MaterialPbrMetallicRoughness"; +export * from "./gltf-structure/Mesh"; +export * from "./gltf-structure/MeshPrimitive"; +export * from "./gltf-structure/Node"; +export * from "./gltf-structure/Sampler"; +export * from "./gltf-structure/Scene"; +export * from "./gltf-structure/Skin"; +export * from "./gltf-structure/Texture"; +export * from "./gltf-structure/TextureInfo";