Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions src/gltf-structure/gltf-structure/Accessor.ts
Original file line number Diff line number Diff line change
@@ -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;
}
28 changes: 28 additions & 0 deletions src/gltf-structure/gltf-structure/AccessorSparse.ts
Original file line number Diff line number Diff line change
@@ -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;
}
28 changes: 28 additions & 0 deletions src/gltf-structure/gltf-structure/AccessorSparseIndices.ts
Original file line number Diff line number Diff line change
@@ -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;
}
24 changes: 24 additions & 0 deletions src/gltf-structure/gltf-structure/AccessorSparseValues.ts
Original file line number Diff line number Diff line change
@@ -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;
}
23 changes: 23 additions & 0 deletions src/gltf-structure/gltf-structure/Animation.ts
Original file line number Diff line number Diff line change
@@ -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[];
}
21 changes: 21 additions & 0 deletions src/gltf-structure/gltf-structure/AnimationChannel.ts
Original file line number Diff line number Diff line change
@@ -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;
}
25 changes: 25 additions & 0 deletions src/gltf-structure/gltf-structure/AnimationChannelTarget.ts
Original file line number Diff line number Diff line change
@@ -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;
}
24 changes: 24 additions & 0 deletions src/gltf-structure/gltf-structure/AnimationSampler.ts
Original file line number Diff line number Diff line change
@@ -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;
}
31 changes: 31 additions & 0 deletions src/gltf-structure/gltf-structure/Asset.ts
Original file line number Diff line number Diff line change
@@ -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 `<major>.<minor>` that this asset
* targets.
*/
version: string;

/**
* The minimum glTF version in the form of `<major>.<minor>` that this
* asset targets. This property **MUST NOT** be greater than the asset
* version.
*/
minVersion?: string;
}
17 changes: 17 additions & 0 deletions src/gltf-structure/gltf-structure/BufferObject.ts
Original file line number Diff line number Diff line change
@@ -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;
}
34 changes: 34 additions & 0 deletions src/gltf-structure/gltf-structure/BufferView.ts
Original file line number Diff line number Diff line change
@@ -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;
}
29 changes: 29 additions & 0 deletions src/gltf-structure/gltf-structure/Camera.ts
Original file line number Diff line number Diff line change
@@ -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;
}
32 changes: 32 additions & 0 deletions src/gltf-structure/gltf-structure/CameraOrthographic.ts
Original file line number Diff line number Diff line change
@@ -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;
}
Loading