Documentation
¶
Index ¶
- Constants
- type Accessor
- type AccessorTypeEnum
- type Animation
- type AnimationChannel
- type AnimationChannelTarget
- type AnimationChannelTargetPath
- type AnimationSampler
- type AnimationSamplerInterpolation
- type Asset
- type AttributeKey
- type Buffer
- type BufferTargetEnum
- type BufferView
- type Camera
- type CameraOrthographic
- type CameraPerpsective
- type CameraType
- type ComponentTypeEnum
- type Extensions
- type Extras
- type GlTF
- type GlTFId
- type Image
- type Material
- type Mesh
- type ModeEnum
- type Node
- type Primitive
- type ResolvedAccessor
- type ResolvedAnimation
- type ResolvedAnimationChannel
- type ResolvedAnimationChannelTarget
- type ResolvedAnimationSampler
- type ResolvedBuffer
- type ResolvedBufferView
- type ResolvedCamera
- type ResolvedGlTF
- type ResolvedMaterial
- type ResolvedMesh
- type ResolvedNode
- type ResolvedPrimitive
- type ResolvedScene
- type Sampler
- type Scene
- type Skin
- type SparseAccessor
- type Texture
Constants ¶
const ( POSITION AttributeKey = "POSITION" NORMAL = "NORMAL" TANGENT = "TANGENT" TEXCOORD_0 = "TEXCOORD_0" TEXCOORD_1 = "TEXCOORD_1" COLOR_0 = "COLOR_0" JOINTS_0 = "JOINTS_0" WEIGHTS_0 = "WEIGHTS_0" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Accessor ¶
type Accessor struct {
BufferView uint `json:"bufferView"`
ByteOffset uint `json:"byteOffset"`
ComponentType ComponentTypeEnum `json:"componentType"`
Normalized bool `json:"normalized"`
Count int `json:"count"`
Type AccessorTypeEnum `json:"type"`
Max []float64 `json:"max"`
Min []float64 `json:"min"`
Sparse SparseAccessor `json:"sparse"`
Name GlTFId `json:"name,omitempty"`
Extensions `json:"extensions,omitempty"`
Extras `json:"extras,omitempty"`
}
Accessor: see https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#schema-reference-accessor
type AccessorTypeEnum ¶
type AccessorTypeEnum string
const ( SCALAR AccessorTypeEnum = "SCALAR" VEC2 AccessorTypeEnum = "VEC2" VEC3 AccessorTypeEnum = "VEC3" VEC4 AccessorTypeEnum = "VEC4" MAT2 AccessorTypeEnum = "MAT2" MAT3 AccessorTypeEnum = "MAT3" MAT4 AccessorTypeEnum = "MAT4" )
func (AccessorTypeEnum) Count ¶
func (ate AccessorTypeEnum) Count() int
Count returns the number of individual components, without regard to the byte size of that component, in each element as defined by an Accessor. This function will panic() if called on an enum value not defined by this module.
type Animation ¶
type Animation struct {
Channels []AnimationChannel `json:"channels"`
Samplers []AnimationSampler `json:"samplers"`
Name GlTFId `json:"name,omitempty"`
Extensions `json:"extensions,omitempty"`
Extras `json:"extras,omitempty"`
}
type AnimationChannel ¶
type AnimationChannel struct {
Sampler uint `json:"sampler"`
Target AnimationChannelTarget `json:"target"`
Extensions `json:"extensions,omitempty"`
Extras `json:"extras,omitempty"`
}
type AnimationChannelTarget ¶
type AnimationChannelTarget struct {
Node *uint `json:"node,omitempty"`
Path AnimationChannelTargetPath `json:"path"`
Extensions `json:"extensions,omitempty"`
Extras `json:"extras,omitempty"`
}
type AnimationChannelTargetPath ¶
type AnimationChannelTargetPath string
const ( TRANSLATION AnimationChannelTargetPath = "translation" ROTATION AnimationChannelTargetPath = "rotation" SCALE AnimationChannelTargetPath = "scale" WEIGHTS AnimationChannelTargetPath = "weights" )
type AnimationSampler ¶
type AnimationSampler struct {
Input int `json:"input"`
Interpolation AnimationSamplerInterpolation `json:"interpolation,omitempty"`
Output int `json:"output"`
Extensions `json:"extensions,omitempty"`
Extras `json:"extras,omitempty"`
}
type AnimationSamplerInterpolation ¶
type AnimationSamplerInterpolation string
const ( LINEAR AnimationSamplerInterpolation = "linear" STEP AnimationSamplerInterpolation = "step" CUBIC_SPLINE AnimationSamplerInterpolation = "cubicspline" )
type Asset ¶
type Asset struct {
// Spec: A copyright message suitable for display to credit the content creator.
Copyright string `json:"copyright,omitempty"`
// Spec: Tool that generated this glTF model. Useful for debugging.
Generator string `json:"generator,omitempty"`
// Spec: The glTF version in the form of `<major>.<minor>` that this asset targets.
Version string `json:"version"`
// 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 `json:"minVersion,omitempty"`
}
Spec: Metadata about the glTF asset.
type AttributeKey ¶
type AttributeKey string
type Buffer ¶
type Buffer struct {
Uri string `json:"uri,omitempty"`
ByteLength uint `json:"byteLength"`
Name GlTFId `json:"name"`
Extensions `json:"extensions"`
Extras `json:"extras"`
}
type BufferTargetEnum ¶
type BufferTargetEnum int
const ( ARRAY_BUFFER BufferTargetEnum = 34962 ELEMENT_ARRAY_BUFFER BufferTargetEnum = 34963 )
type BufferView ¶
type BufferView struct {
Buffer uint `json:"buffer"`
ByteOffset uint `json:"byteOffset"`
ByteLength uint `json:"byteLength"`
ByteStride uint `json:"byteStride"`
Target BufferTargetEnum `json:"target"`
Name GlTFId `json:"name,omitempty"`
Extensions `json:"extensions,omitempty"`
Extras `json:"extras,omitempty"`
}
type Camera ¶
type Camera struct {
Orthographic CameraOrthographic `json:"orthographic,omitempty"`
Perspective CameraPerpsective `json:"perspective,omitempty"`
Type CameraType `json:"type"`
Name GlTFId `json:"name,omitempty"`
Extensions `json:"extensions,omitempty"`
Extras `json:"extras,omitempty"`
}
type CameraOrthographic ¶
type CameraPerpsective ¶
type CameraType ¶
type CameraType string
const ( PERSPECTIVE CameraType = "perspective" ORTHOGRAPHIC CameraType = "orthographic" )
type ComponentTypeEnum ¶
type ComponentTypeEnum int
const ( BYTE ComponentTypeEnum = 5120 UNSIGNED_BYTE ComponentTypeEnum = 5121 SHORT ComponentTypeEnum = 5122 UNSIGNED_SHORT ComponentTypeEnum = 5123 UNSIGNED_INT ComponentTypeEnum = 5125 FLOAT ComponentTypeEnum = 5126 )
func (ComponentTypeEnum) Size ¶
func (c ComponentTypeEnum) Size() int
Size returns the byte size of the component specified by an Accessor. Note that the size of component types are determined by the glTF spec, not the machine that the file is being interpreted by. This function will panic() if called on an enum value not defined by this module.
type GlTF ¶
type GlTF struct {
// Asset is a required field
Asset Asset `json:"asset"`
ExtensionsUsed []string `json:"extensionsUsed"`
ExtensionsRequired []string `json:"extensionsRequired"`
Accessors []Accessor `json:"accessors"`
Animations []Animation `json:"animations"`
Buffers []Buffer `json:"buffers"`
BufferViews []BufferView `json:"bufferViews"`
Cameras []Camera `json:"cameras"`
Images []Image `json:"images"`
Materials []Material `json:"materials"`
Meshes []Mesh `json:"meshes"`
Nodes []Node `json:"nodes"`
Samplers []Sampler `json:"samplers"`
Scene *uint `json:"scene,omitempty"` // Spec: Scene is an optional reference to the default scene for this asset, as an index in the Scenes array.
Scenes []Scene `json:"scenes"`
Skins []Skin `json:"skins"`
Textures []Texture `json:"textures"`
Extensions `json:"extensions,omitempty"`
Extras `json:"extras,omitempty"`
// contains filtered or unexported fields
}
Spec: The root object for a glTF asset.
func FromFilename ¶
func (*GlTF) Resolve ¶
func (gltf *GlTF) Resolve(uriSearchPath []string) (*ResolvedGlTF, error)
Resolve processes a glTF structure and returns a ResolvedGlTF that can be used in a program without further processing. The returned value will have:
* All indexed resource references resolved as pointers to that resource. For example, an array of Node indices will be converted to pointers to the actual Nodes. * All binary resources will be loaded into their Buffer objects, using the provided uriSearchPaths for name resolution. Note that the binary load will not interpret or validate the data, it will simply be loaded as-is into the buffer. An error will be raised if the binary data provided is shorter than the Buffer's ByteLength. NOTE HOWEVER, that the data will still be loaded into the Buffer and zero padded. The any data at the URI beyond the Buffer's ByteLength will be ignored.
Paths will be searched in the order provided and the first matching file will be used. If the GlTF instance was loaded from a file object, or from a file name, and if uriSearchPath is empty, then that location will be searched by default.
type Material ¶
type Material struct {
Name GlTFId `json:"name,omitempty"`
Extensions `json:"extensions,omitempty"`
Extras `json:"extras,omitempty"`
}
type Mesh ¶
type Mesh struct {
Primitives []Primitive `json:"primitives"`
Weights []float32 `json:"weights"`
Name GlTFId `json:"name,omitempty"`
Extensions `json:"extensions,omitempty"`
Extras `json:"extras,omitempty"`
}
type Node ¶
type Node struct {
Camera *int `json:"camera"`
Children []uint `json:"children"`
Skin *int `json:"skin"`
Matrix [16]float32 `json:"matrix"`
Mesh *uint `json:"mesh,omitempty"`
Rotation *vkm.Vec `json:"rotation"`
Scale *vkm.Vec3 `json:"scale"`
Translation *vkm.Vec3 `json:"translation"`
Weights []float32 `json:"weights"`
Name GlTFId `json:"name,omitempty"`
Extensions `json:"extensions,omitempty"`
Extras `json:"extras,omitempty"`
}
type Primitive ¶
type Primitive struct {
Attributes map[AttributeKey]int `json:"attributes"`
Indices *uint `json:"indices,omitempty"`
// May be null, indicating "default" material
Material *int `json:"material,omitempty"`
Mode *ModeEnum `json:"mode,omitempty"`
Targets []string `json:"targets"` // TODO
Extensions `json:"extensions,omitempty"`
Extras `json:"extras,omitempty"`
}
type ResolvedAccessor ¶
type ResolvedAccessor struct {
*Accessor
BufferView *ResolvedBufferView
}
type ResolvedAnimation ¶
type ResolvedAnimation struct {
*Animation
Channels []ResolvedAnimationChannel
Samplers []ResolvedAnimationSampler
}
type ResolvedAnimationChannel ¶
type ResolvedAnimationChannel struct {
*AnimationChannel
Sampler *ResolvedAnimationSampler
Target ResolvedAnimationChannelTarget
}
type ResolvedAnimationChannelTarget ¶
type ResolvedAnimationChannelTarget struct {
*AnimationChannelTarget
Node *ResolvedNode
}
type ResolvedAnimationSampler ¶
type ResolvedAnimationSampler struct {
*AnimationSampler
Input *ResolvedAccessor
Output *ResolvedAccessor
}
type ResolvedBuffer ¶
type ResolvedBufferView ¶
type ResolvedBufferView struct {
*BufferView
Buffer *ResolvedBuffer
// Data in the BufferView is a subslice (i.e. shared memory) from the source buffer data
Data []byte
}
type ResolvedCamera ¶
type ResolvedGlTF ¶
type ResolvedGlTF struct {
*GlTF
Animations []ResolvedAnimation
Buffers []ResolvedBuffer
BufferViews []ResolvedBufferView
Cameras []ResolvedCamera
Accessors []ResolvedAccessor
Materials []ResolvedMaterial
Meshes []ResolvedMesh
Nodes []ResolvedNode
Scene *ResolvedScene
Scenes []ResolvedScene
}
ResolvedGlTF is a GlTF with all indexed node references and binary data resolved and loaded. The source GlTF struct is included as a pointer, so all of the source data can be referenced as neccessary. Fields for resolved data types are named the same as the sources in a GlTF struct, masking the original data. The original data can still be accessed through the embedded GlTF pointer: ``` var resolved *ResolvedGlTF ... resolved.Nodes => slice of ResolvedNode resolved.GlTF.Nodes => slice of Node ```
type ResolvedMaterial ¶
type ResolvedMaterial struct {
*Material
}
type ResolvedMesh ¶
type ResolvedMesh struct {
*Mesh
Primitives []ResolvedPrimitive
}
type ResolvedNode ¶
type ResolvedNode struct {
*Node
Camera *ResolvedCamera
Children []*ResolvedNode
Mesh *ResolvedMesh
}
type ResolvedPrimitive ¶
type ResolvedPrimitive struct {
*Primitive
Attributes map[AttributeKey]*ResolvedAccessor
Indices *ResolvedAccessor
Material *ResolvedMaterial
}
type ResolvedScene ¶
type ResolvedScene struct {
*Scene
Nodes []*ResolvedNode
}
type Scene ¶
type Scene struct {
Nodes []uint `json:"nodes"`
Name GlTFId `json:"name,omitempty"`
Extensions `json:"extensions,omitempty"`
Extras `json:"extras,omitempty"`
}