Documentation
¶
Overview ¶
Package gltf implements a glTF 2.0 file decoder, encoder and validator.
The glTF 2.0 specification is at https://github.com/KhronosGroup/glTF/tree/master/specification/2.0/.
Index ¶
- Constants
- func Save(doc *Document, name string, asBinary bool) error
- type Accessor
- type AccessorType
- type AlphaMode
- type Animation
- type AnimationSampler
- type Asset
- type Attribute
- type Buffer
- type BufferView
- type Camera
- type CameraType
- type Channel
- type ChannelTarget
- type ComponentType
- type Decoder
- type Document
- type Encoder
- type Extensions
- type Image
- type Interpolation
- type MagFilter
- type Material
- type Mesh
- type MinFilter
- type Node
- type NormalTexture
- type OcclusionTexture
- type Orthographic
- type PBRMetallicRoughness
- type PBRSpecularGlossiness
- type Perspective
- type Primitive
- type PrimitiveMode
- type ReadQuotas
- type ReadResourceCallback
- type Sampler
- type Scene
- type Skin
- type Sparse
- type SparseIndices
- type SparseValues
- type TRSProperty
- type Target
- type Texture
- type TextureInfo
- type WrappingMode
- type WriteResourceCallback
Examples ¶
Constants ¶
const ( // Byte corresponds to a Int8Array. Byte ComponentType = 5120 // UnsignedByte corresponds to a Uint8Array. UnsignedByte = 5121 // Short corresponds to a Int16Array. Short = 5122 // UnsignedShort corresponds to a Uint16Array. UnsignedShort = 5123 // UnsignedInt corresponds to a Uint32Array. UnsignedInt = 5125 // Float corresponds to a Float32Array. Float = 5126 )
const ( // Scalar corresponds to a single dimension value. Scalar AccessorType = "SCALAR" // Vec2 corresponds to a two dimensions array. Vec2 = "VEC2" // Vec3 corresponds to a three dimensions array. Vec3 = "VEC3" // Vec4 corresponds to a four dimensions array. Vec4 = "VEC4" // Mat2 corresponds to a 2x2 matrix. Mat2 = "MAT2" // Mat3 corresponds to a 3x3 matrix. Mat3 = "MAT3" // Mat4 corresponds to a 4x4 matrix. Mat4 = "MAT4" )
const ( // Points corresponds to a Point primitive. Points PrimitiveMode = 0 // Lines corresponds to a Line primitive. Lines = 1 // LineLoop corresponds to a Line Loop primitive. LineLoop = 2 // LineStrip corresponds to a Line Strip primitive. LineStrip = 3 // Triangles corresponds to a Triangle primitive. Triangles = 4 // TriangleStrip corresponds to a Triangle Strip primitive. TriangleStrip = 5 // TriangleFan corresponds to a Triangle Fan primitive. TriangleFan = 6 )
const ( // Opaque corresponds to an Opaque material. Opaque AlphaMode = "OPAQUE" // Mask corresponds to a masked material. Mask = "MASK" // Blend corresponds to a Blend material. Blend = "BLEND" )
const ( // MinNearest corresponds to a nearest minification filter. MinNearest MinFilter = 9728 // MinLinear corresponds to a linear minification filter. MinLinear = 9729 // MinNearestMipMapNearest corresponds to a nearest mipmap nearest minification filter. MinNearestMipMapNearest = 9984 // MinLinearMipMapNearest corresponds to a linear mipmap nearest minification filter. MinLinearMipMapNearest = 9985 // MinNearestMipMapLinear corresponds to a nearest mipmap linear minification filter. MinNearestMipMapLinear = 9986 // MinLinearMipMapLinear corresponds to a linear mipmap linear minification filter. MinLinearMipMapLinear = 9987 )
const ( // ClampToEdge corresponds to a clamp to edge wrapping. ClampToEdge WrappingMode = 33071 // MirroredRepeat corresponds to a mirrored repeat wrapping. MirroredRepeat = 33648 // Repeat corresponds to a repeat wrapping. Repeat = 10497 )
const ( // Linear corresponds to a linear interpolation. Linear Interpolation = "LINEAR" // Step corresponds to a step interpolation. Step = "STEP" // CubicSpline corresponds to a cubic spline interpolation. CubicSpline = "CUBICSPLINE" )
const ( // Translation corresponds to a translation transform. Translation TRSProperty = "translation" // Rotation corresponds to a rotation transform. Rotation = "rotation" // Scale corresponds to a scale transform. Scale = "scale" // Weights corresponds to a weights transform. Weights = "weights" )
const (
ExtPBRSpecularGlossiness = "KHR_materials_pbrSpecularGlossiness"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Accessor ¶
type Accessor struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Name string `json:"name,omitempty"` BufferView int32 `json:"bufferView" validate:"gte=-1"` ByteOffset uint32 `json:"byteOffset,omitempty"` ComponentType ComponentType `json:"componentType" validate:"oneof=5120 5121 5122 5123 5125 5126"` Normalized bool `json:"normalized,omitempty"` // Specifies whether integer data values should be normalized. Count uint32 `json:"count" validate:"required"` // The number of attributes referenced by this accessor. Type AccessorType `json:"type" validate:"oneof=SCALAR VEC2 VEC3 VEC4 MAT2 MAT3 MAT4"` Max []float64 `json:"max,omitempty" validate:"omitempty,lte=16"` // Maximum value of each component in this attribute. Min []float64 `json:"min,omitempty" validate:"omitempty,lte=16"` // Minimum value of each component in this attribute. Sparse *Sparse `json:"sparse,omitempty"` // Sparse storage of attributes that deviate from their initialization value. }
An Accessor is a typed view into a bufferView. 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.
func (*Accessor) MarshalJSON ¶
MarshalJSON marshal the accessor with the correct default values.
func (*Accessor) UnmarshalJSON ¶
UnmarshalJSON unmarshal the accessor with the correct default values.
type AccessorType ¶
type AccessorType string
AccessorType specifies if the attribute is a scalar, vector, or matrix.
type AlphaMode ¶
type AlphaMode string
The AlphaMode enumeration specifying the interpretation of the alpha value of the main factor and texture.
type Animation ¶
type Animation struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Name string `json:"name,omitempty"` Channels []Channel `json:"channels" validate:"required,gt=0,dive"` Samplers []AnimationSampler `json:"samplers" validate:"required,gt=0,dive"` }
An Animation keyframe.
type AnimationSampler ¶
type AnimationSampler struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Input int32 `json:"input" validate:"gte=-1"` // The index of an accessor containing keyframe input values. Interpolation Interpolation `json:"interpolation,omitempty" validate:"omitempty,oneof=LINEAR STEP CUBICSPLINE"` Output int32 `json:"output" validate:"gte=-1"` // The index of an accessor containing keyframe output values. }
AnimationSampler combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target).
func NewAnimationSampler ¶
func NewAnimationSampler() *AnimationSampler
NewAnimationSampler returns a default AnimationSampler.
func (*AnimationSampler) UnmarshalJSON ¶
func (as *AnimationSampler) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshal the animation sampler with the correct default values.
type Asset ¶
type Asset struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Copyright string `json:"copyright,omitempty"` // A copyright message suitable for display to credit the content creator. Generator string `json:"generator,omitempty"` // Tool that generated this glTF model. Useful for debugging. Version string `json:"version" validate:"required"` // The glTF version that this asset targets. MinVersion string `json:"minVersion,omitempty"` // The minimum glTF version that this asset targets. }
An Asset is metadata about the glTF asset.
type Attribute ¶
Attribute is a map that each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data.
type Buffer ¶
type Buffer struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Name string `json:"name,omitempty"` URI string `json:"uri,omitempty" validate:"omitempty"` ByteLength uint32 `json:"byteLength" validate:"required"` Data []uint8 `json:"-"` }
A Buffer points to binary geometry, animation, or skins.
func (*Buffer) EmbeddedResource ¶
func (b *Buffer) EmbeddedResource()
EmbeddedResource defines the buffer as an embedded resource and encodes the URI so it points to the the resource.
func (*Buffer) IsEmbeddedResource ¶
IsEmbeddedResource returns true if the buffer points to an embedded resource.
type BufferView ¶
type BufferView struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Buffer int32 `json:"buffer" validate:"gte=-1"` ByteOffset uint32 `json:"byteOffset,omitempty"` ByteLength uint32 `json:"byteLength" validate:"required"` ByteStride uint32 `json:"byteStride,omitempty" validate:"omitempty,gte=4,lte=252"` Target Target `json:"target,omitempty" validate:"omitempty,oneof=34962 34963"` }
BufferView is a view into a buffer generally representing a subset of the buffer.
func (*BufferView) MarshalJSON ¶
func (b *BufferView) MarshalJSON() ([]byte, error)
MarshalJSON marshal the buffer view with the correct default values.
func (*BufferView) UnmarshalJSON ¶
func (b *BufferView) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshal the buffer view with the correct default values.
type Camera ¶
type Camera struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Name string `json:"name,omitempty"` Orthographic *Orthographic `json:"orthographic,omitempty"` Perspective *Perspective `json:"perspective,omitempty"` Type CameraType `json:"type" validate:"oneof=perspective orthographic"` }
A Camera projection. A node can reference a camera to apply a transform to place the camera in the scene.
type CameraType ¶
type CameraType string
CameraType specifies if the camera uses a perspective or orthographic projection. Based on this, either the camera's perspective or orthographic property will be defined.
const ( // PerspectiveType corresponds to a perspective camera. PerspectiveType CameraType = "perspective" // OrthographicType corresponds to an orthographic camera. OrthographicType = "orthographic" )
type Channel ¶
type Channel struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Sampler int32 `json:"sampler" validate:"gte=-1"` Target ChannelTarget `json:"target"` }
The Channel targets an animation's sampler at a node's property.
func (*Channel) MarshalJSON ¶
MarshalJSON marshal the channel with the correct default values.
func (*Channel) UnmarshalJSON ¶
UnmarshalJSON unmarshal the channel with the correct default values.
type ChannelTarget ¶
type ChannelTarget struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Node int32 `json:"node" validate:"gte=-1"` Path TRSProperty `json:"path" validate:"oneof=translation rotation scale weights"` }
ChannelTarget describes the index of the node and TRS property that an animation channel targets. The Path represents the name of the node's TRS property to modify, 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.
func NewChannelTarget ¶
func NewChannelTarget(path TRSProperty) *ChannelTarget
NewChannelTarget returns a default ChannelTarget.
func (*ChannelTarget) MarshalJSON ¶
func (ch *ChannelTarget) MarshalJSON() ([]byte, error)
MarshalJSON marshal the channel target with the correct default values.
func (*ChannelTarget) UnmarshalJSON ¶
func (ch *ChannelTarget) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshal the channel target with the correct default values.
type ComponentType ¶
type ComponentType uint16
The ComponentType is the datatype of components in the attribute. All valid values correspond to WebGL enums. 5125 (UNSIGNED_INT) is only allowed when the accessor contains indices.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
A Decoder reads and decodes glTF and GLB values from an input stream.
func NewDecoder ¶
func NewDecoder(r io.Reader, cb ReadResourceCallback) *Decoder
NewDecoder returns a new decoder that reads from r.
func (*Decoder) Decode ¶
Decode reads the next JSON-encoded value from its input and stores it in the value pointed to by doc.
func (*Decoder) SetQuotas ¶
func (d *Decoder) SetQuotas(quotas ReadQuotas) *Decoder
SetQuotas sets the read memory limits. The return value is the same decoder.
type Document ¶
type Document struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` ExtensionsUsed []string `json:"extensionsUsed,omitempty"` ExtensionsRequired []string `json:"extensionsRequired,omitempty"` Accessors []Accessor `json:"accessors,omitempty" validate:"dive"` Animations []Animation `json:"animations,omitempty" validate:"dive"` Asset Asset `json:"asset"` Buffers []Buffer `json:"buffers,omitempty" validate:"dive"` BufferViews []BufferView `json:"bufferViews,omitempty" validate:"dive"` Cameras []Camera `json:"cameras,omitempty" validate:"dive"` Images []Image `json:"images,omitempty" validate:"dive"` Materials []Material `json:"materials,omitempty" validate:"dive"` Meshes []Mesh `json:"meshes,omitempty" validate:"dive"` Nodes []Node `json:"nodes,omitempty" validate:"dive"` Samplers []Sampler `json:"samplers,omitempty" validate:"dive"` Scene int32 `json:"scene" validate:"gte=-1"` Scenes []Scene `json:"scenes,omitempty" validate:"dive"` Skins []Skin `json:"skins,omitempty" validate:"dive"` Textures []Texture `json:"textures,omitempty" validate:"dive"` }
Document defines the root object for a glTF asset.
func Open ¶
Open will open a glTF or GLB file specified by name and return the Document.
Example ¶
doc, err := Open("fake") if err != nil { panic(err) } fmt.Print(doc.Asset)
Output:
func (*Document) MarshalJSON ¶
MarshalJSON marshal the document with the correct default values.
func (*Document) UnmarshalJSON ¶
UnmarshalJSON unmarshal the document with the correct default values.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
An Encoder writes a GLTF to an output stream.
func NewEncoder ¶
func NewEncoder(w io.Writer, cb WriteResourceCallback, asBinary bool) *Encoder
NewEncoder returns a new encoder that writes to w as a normal glTF file.
type Extensions ¶
type Extensions map[string]interface{}
Extension is map where the keys are the extension identifiers and the values are the extensions payloads. If a key matches with one of the supported extensions the value will be marshalled as a pointer to the extension struct. If a key does not match with any of the supported extensions the value will be a json.RawMessage so its decoding can be delayed.
func (*Extensions) UnmarshalJSON ¶
func (ext *Extensions) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshal the extensions with the supported extensions initialized.
type Image ¶
type Image struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Name string `json:"name,omitempty"` URI string `json:"uri,omitempty" validate:"omitempty"` MimeType string `json:"mimeType,omitempty" validate:"omitempty,oneof=image/jpeg image/png"` // Manadatory if BufferView is defined. BufferView uint32 `json:"bufferView,omitempty"` // Use this instead of the image's uri property. }
Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case.
func (*Image) IsEmbeddedResource ¶
IsEmbeddedResource returns true if the buffer points to an embedded resource.
func (*Image) MarshalData ¶
MarshalData decode the image from the URI. If the image is not en embedded resource the returned array will be empty.
type MagFilter ¶
type MagFilter uint16
MagFilter is the magnification filter.
const ( // MagNearest corresponds to a nearest magnification filter. MagNearest MagFilter = 9728 // MagLinear corresponds to a linear magnification filter. MagLinear = 9729 )
type Material ¶
type Material struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Name string `json:"name,omitempty"` PBRMetallicRoughness *PBRMetallicRoughness `json:"pbrMetallicRoughness,omitempty"` NormalTexture *NormalTexture `json:"normalTexture,omitempty"` OcclusionTexture *OcclusionTexture `json:"occlusionTexture,omitempty"` EmissiveTexture *TextureInfo `json:"emissiveTexture,omitempty"` EmissiveFactor [3]float64 `json:"emissiveFactor,omitempty" validate:"dive,gte=0,lte=1"` AlphaMode AlphaMode `json:"alphaMode,omitempty" validate:"oneof=OPAQUE MASK BLEND"` AlphaCutoff float64 `json:"alphaCutoff" validate:"gte=0"` DoubleSided bool `json:"doubleSided,omitempty"` }
The Material appearance of a primitive.
func (*Material) MarshalJSON ¶
MarshalJSON marshal the material with the correct default values.
func (*Material) UnmarshalJSON ¶
UnmarshalJSON unmarshal the material with the correct default values.
type Mesh ¶
type Mesh struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Name string `json:"name,omitempty"` Primitives []Primitive `json:"primitives" validate:"required,gt=0,dive"` Weights []float64 `json:"weights,omitempty"` }
A Mesh is a set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene.
type Node ¶
type Node struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Name string `json:"name,omitempty"` Camera int32 `json:"camera" validate:"gte=-1"` Children []uint32 `json:"children,omitempty" validate:"omitempty,unique"` Skin int32 `json:"skin" validate:"gte=-1"` Matrix [16]float64 `json:"matrix"` // A 4x4 transformation matrix stored in column-major order. Mesh int32 `json:"mesh" validate:"gte=-1"` Rotation [4]float64 `json:"rotation" validate:"omitempty,dive,gte=-1,lte=1"` // The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar. Scale [3]float64 `json:"scale"` Translation [3]float64 `json:"translation"` Weights []float64 `json:"weights,omitempty"` // The weights of the instantiated Morph Target. }
A Node in the node hierarchy. It can have either a matrix or any combination of translation/rotation/scale (TRS) properties.
func (*Node) MarshalJSON ¶
MarshalJSON marshal the node with the correct default values.
func (*Node) UnmarshalJSON ¶
UnmarshalJSON unmarshal the node with the correct default values.
type NormalTexture ¶
type NormalTexture struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Index int32 `json:"index" validate:"gte=-1"` TexCoord uint32 `json:"texCoord,omitempty"` // The index of texture's TEXCOORD attribute used for texture coordinate mapping. Scale float64 `json:"scale"` }
A NormalTexture references to a normal texture.
func NewNormalTexture ¶
func NewNormalTexture(index int32) *NormalTexture
NewNormalTexture returns a default NormalTexture.
func (*NormalTexture) MarshalJSON ¶
func (n *NormalTexture) MarshalJSON() ([]byte, error)
MarshalJSON marshal the texture info with the correct default values.
func (*NormalTexture) UnmarshalJSON ¶
func (n *NormalTexture) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshal the texture info with the correct default values.
type OcclusionTexture ¶
type OcclusionTexture struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Index int32 `json:"index" validate:"gte=-1"` TexCoord uint32 `json:"texCoord,omitempty"` // The index of texture's TEXCOORD attribute used for texture coordinate mapping. Strength float64 `json:"strength" validate:"gte=0,lte=1"` }
An OcclusionTexture references to an occlusion texture
func NewOcclusionTexture ¶
func NewOcclusionTexture(index int32) *OcclusionTexture
NewOcclusionTexture returns a default OcclusionTexture.
func (*OcclusionTexture) MarshalJSON ¶
func (o *OcclusionTexture) MarshalJSON() ([]byte, error)
MarshalJSON marshal the texture info with the correct default values.
func (*OcclusionTexture) UnmarshalJSON ¶
func (o *OcclusionTexture) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshal the texture info with the correct default values.
type Orthographic ¶
type Orthographic struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Xmag float64 `json:"xmag"` // The horizontal magnification of the view. Ymag float64 `json:"ymag"` // The vertical magnification of the view. Zfar float64 `json:"zfar" validate:"gt=0,gtfield=Znear"` // The distance to the far clipping plane. Znear float64 `json:"znear" validate:"gte=0"` // The distance to the near clipping plane. }
Orthographic camera containing properties to create an orthographic projection matrix.
type PBRMetallicRoughness ¶
type PBRMetallicRoughness struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` BaseColorFactor [4]float64 `json:"baseColorFactor" validate:"dive,gte=0,lte=1"` BaseColorTexture *TextureInfo `json:"baseColorTexture,omitempty"` MetallicFactor float64 `json:"metallicFactor" validate:"gte=0,lte=1"` RoughnessFactor float64 `json:"roughnessFactor" validate:"gte=0,lte=1"` MetallicRoughnessTexture *TextureInfo `json:"metallicRoughnessTexture,omitempty"` }
PBRMetallicRoughness defines a set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology.
func NewPBRMetallicRoughness ¶
func NewPBRMetallicRoughness() *PBRMetallicRoughness
NewPBRMetallicRoughness returns a default PBRMetallicRoughness.
func (*PBRMetallicRoughness) MarshalJSON ¶
func (p *PBRMetallicRoughness) MarshalJSON() ([]byte, error)
MarshalJSON marshal the pbr with the correct default values.
func (*PBRMetallicRoughness) UnmarshalJSON ¶
func (p *PBRMetallicRoughness) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshal the pbr with the correct default values.
type PBRSpecularGlossiness ¶
type PBRSpecularGlossiness struct { DiffuseFactor [4]float64 `json:"diffuseFactor" validate:"dive,gte=0,lte=1"` DiffuseTexture *TextureInfo `json:"diffuseTexture,omitempty"` SpecularFactor [3]float64 `json:"specularFactor" validate:"dive,gte=0,lte=1"` GlossinessFactor float64 `json:"glossinessFactor" validate:"gte=0,lte=1"` SpecularGlossinessTexture *TextureInfo `json:"specularGlossinessTexture,omitempty"` }
func NewPBRSpecularGlossiness ¶
func NewPBRSpecularGlossiness() *PBRSpecularGlossiness
PBRSpecularGlossiness returns a default PBRSpecularGlossiness.
func (*PBRSpecularGlossiness) MarshalJSON ¶
func (p *PBRSpecularGlossiness) MarshalJSON() ([]byte, error)
MarshalJSON marshal the pbr with the correct default values.
func (*PBRSpecularGlossiness) UnmarshalJSON ¶
func (p *PBRSpecularGlossiness) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshal the pbr with the correct default values.
type Perspective ¶
type Perspective struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` AspectRatio float64 `json:"aspectRatio,omitempty"` Yfov float64 `json:"yfov"` // The vertical field of view in radians. Zfar float64 `json:"zfar,omitempty"` // The distance to the far clipping plane. Znear float64 `json:"znear"` // The distance to the near clipping plane. }
Perspective camera containing properties to create a perspective projection matrix.
type Primitive ¶
type Primitive struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Attributes Attribute `json:"attributes"` Indices int32 `json:"indices" validate:"gte=-1"` // The index of the accessor that contains the indices. Material int32 `json:"material" validate:"gte=-1"` Mode PrimitiveMode `json:"mode" validate:"lte=6"` Targets []Attribute `json:"targets,omitempty" validate:"omitempty,dive,dive,keys,oneof=POSITION NORMAL TANGENT,endkeys"` // Only POSITION, NORMAL, and TANGENT supported. }
Primitive defines the geometry to be rendered with the given material.
func (*Primitive) MarshalJSON ¶
MarshalJSON marshal the primitive with the correct default values.
func (*Primitive) UnmarshalJSON ¶
UnmarshalJSON unmarshal the primitive with the correct default values.
type PrimitiveMode ¶
type PrimitiveMode uint8
PrimitiveMode defines the type of primitives to render. All valid values correspond to WebGL enums.
type ReadQuotas ¶
ReadQuotas defines maximum allocation sizes to prevent DOS's from malicious files.
type ReadResourceCallback ¶
type ReadResourceCallback = func(string) (io.ReadCloser, error)
ReadResourceCallback defines a callback that will be called when an external resource should be loaded. The string parameter is the URI of the resource.
type Sampler ¶
type Sampler struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Name string `json:"name,omitempty"` MagFilter MagFilter `json:"magFilter,omitempty" validate:"omitempty,oneof=9728 9729"` MinFilter MinFilter `json:"minFilter,omitempty" validate:"omitempty,oneof=9728 9729 9984 9985 9986 9987"` WrapS WrappingMode `json:"wrapS,omitempty" validate:"omitempty,oneof=33071 33648 10497"` WrapT WrappingMode `json:"wrapT,omitempty" validate:"omitempty,oneof=33071 33648 10497"` }
Sampler of a texture for filtering and wrapping modes.
func (*Sampler) UnmarshalJSON ¶
UnmarshalJSON unmarshal the sampler with the correct default values.
type Scene ¶
type Scene struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Name string `json:"name,omitempty"` Nodes []uint32 `json:"nodes,omitempty" validate:"omitempty,unique"` }
The Scene contains a list of root nodes.
type Skin ¶
type Skin struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Name string `json:"name,omitempty"` InverseBindMatrices int32 `json:"inverseBindMatrices" validate:"gte=-1"` // The index of the accessor containing the floating-point 4x4 inverse-bind matrices. Skeleton int32 `json:"skeleton" validate:"gte=-1"` // The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root. Joints []uint32 `json:"joints" validate:"omitempty,unique"` // Indices of skeleton nodes, used as joints in this skin. }
Skin defines joints and matrices.
func (*Skin) MarshalJSON ¶
MarshalJSON marshal the skin with the correct default values.
func (*Skin) UnmarshalJSON ¶
UnmarshalJSON unmarshal the skin with the correct default values.
type Sparse ¶
type Sparse struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Count uint32 `json:"count" validate:"gte=1"` // Number of entries stored in the sparse array. Indices SparseIndices `json:"indices"` // Index array of size count that points to those accessor attributes that deviate from their initialization value. Values SparseValues `json:"values"` // Array of size count times number of components, storing the displaced accessor attributes pointed by indices. }
Sparse storage of attributes that deviate from their initialization value.
type SparseIndices ¶
type SparseIndices struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` BufferView uint32 `json:"bufferView"` ByteOffset uint32 `json:"byteOffset,omitempty"` ComponentType ComponentType `json:"componentType" validate:"oneof=5121 5123 5125"` }
SparseIndices defines the indices of those attributes that deviate from their initialization value.
type SparseValues ¶
type SparseValues struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` BufferView uint32 `json:"bufferView"` ByteOffset uint32 `json:"byteOffset,omitempty"` }
SparseValues stores the displaced accessor attributes pointed by accessor.sparse.indices.
type TRSProperty ¶
type TRSProperty string
TRSProperty defines a local space transformation. TRSproperties are converted to matrices and postmultiplied in the T * R * S order to compose the transformation matrix.
type Target ¶
type Target uint16
The Target that the GPU buffer should be bound to.
const ( // ArrayBuffer corresponds to an array buffer. ArrayBuffer Target = 34962 // ElementArrayBuffer corresponds to an element array buffer. ElementArrayBuffer = 34963 )
type Texture ¶
type Texture struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Name string `json:"name,omitempty"` Sampler int32 `json:"sampler" validate:"gte=-1"` Source int32 `json:"source" validate:"gte=-1"` }
A Texture and its sampler.
func (*Texture) MarshalJSON ¶
MarshalJSON marshal the texture with the correct default values.
func (*Texture) UnmarshalJSON ¶
UnmarshalJSON unmarshal the texture with the correct default values.
type TextureInfo ¶
type TextureInfo struct { Extensions Extensions `json:"extensions,omitempty"` Extras interface{} `json:"extras,omitempty"` Index int32 `json:"index" validate:"gte=-1"` TexCoord uint32 `json:"texCoord,omitempty"` // The index of texture's TEXCOORD attribute used for texture coordinate mapping. }
TextureInfo references to a texture.
func NewTextureInfo ¶
func NewTextureInfo(index int32) *TextureInfo
NewTextureInfo returns a default TextureInfo.
func (*TextureInfo) MarshalJSON ¶
func (t *TextureInfo) MarshalJSON() ([]byte, error)
MarshalJSON marshal the texture info with the correct default values.
func (*TextureInfo) UnmarshalJSON ¶
func (t *TextureInfo) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshal the texture info with the correct default values.
type WriteResourceCallback ¶
type WriteResourceCallback = func(string, int) (io.WriteCloser, error)
WriteResourceCallback defines a callback that will be called when an external resource should be writed. The string parameter is the URI of the resource.