gltf: github.com/qmuntal/gltf Index | Examples | Files

package gltf

import "github.com/qmuntal/gltf"

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

Examples

Package Files

const.go decoder.go doc.go encode.go extensions.go struct.go validator.go

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"
)

func Save Uses

func Save(doc *Document, name string, asBinary bool) error

Save will save a document as a glTF or a GLB file specified by name.

type Accessor Uses

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 NewAccessor Uses

func NewAccessor() *Accessor

NewAccessor returns a default accessor.

func (*Accessor) MarshalJSON Uses

func (a *Accessor) MarshalJSON() ([]byte, error)

MarshalJSON marshal the accessor with the correct default values.

func (*Accessor) UnmarshalJSON Uses

func (a *Accessor) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the accessor with the correct default values.

type AccessorType Uses

type AccessorType string

AccessorType specifies if the attribute is a scalar, vector, or matrix.

type AlphaMode Uses

type AlphaMode string

The AlphaMode enumeration specifying the interpretation of the alpha value of the main factor and texture.

type Animation Uses

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 Uses

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 Uses

func NewAnimationSampler() *AnimationSampler

NewAnimationSampler returns a default AnimationSampler.

func (*AnimationSampler) UnmarshalJSON Uses

func (as *AnimationSampler) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the animation sampler with the correct default values.

type Asset Uses

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 Uses

type Attribute = map[string]uint32

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 Uses

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 Uses

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 Uses

func (b *Buffer) IsEmbeddedResource() bool

IsEmbeddedResource returns true if the buffer points to an embedded resource.

type BufferView Uses

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 Uses

func (b *BufferView) MarshalJSON() ([]byte, error)

MarshalJSON marshal the buffer view with the correct default values.

func (*BufferView) UnmarshalJSON Uses

func (b *BufferView) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the buffer view with the correct default values.

type Camera Uses

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 Uses

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 Uses

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 NewChannel Uses

func NewChannel(sampler int32) *Channel

NewChannel returns a default Channel.

func (*Channel) MarshalJSON Uses

func (ch *Channel) MarshalJSON() ([]byte, error)

MarshalJSON marshal the channel with the correct default values.

func (*Channel) UnmarshalJSON Uses

func (ch *Channel) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the channel with the correct default values.

type ChannelTarget Uses

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 Uses

func NewChannelTarget(path TRSProperty) *ChannelTarget

NewChannelTarget returns a default ChannelTarget.

func (*ChannelTarget) MarshalJSON Uses

func (ch *ChannelTarget) MarshalJSON() ([]byte, error)

MarshalJSON marshal the channel target with the correct default values.

func (*ChannelTarget) UnmarshalJSON Uses

func (ch *ChannelTarget) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the channel target with the correct default values.

type ComponentType Uses

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 Uses

type Decoder struct {
    // contains filtered or unexported fields
}

A Decoder reads and decodes glTF and GLB values from an input stream.

func NewDecoder Uses

func NewDecoder(r io.Reader, cb ReadResourceCallback) *Decoder

NewDecoder returns a new decoder that reads from r.

func (*Decoder) Decode Uses

func (d *Decoder) Decode(doc *Document) error

Decode reads the next JSON-encoded value from its input and stores it in the value pointed to by doc.

func (*Decoder) SetQuotas Uses

func (d *Decoder) SetQuotas(quotas ReadQuotas) *Decoder

SetQuotas sets the read memory limits. The return value is the same decoder.

type Document Uses

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 Uses

func Open(name string) (*Document, error)

Open will open a glTF or GLB file specified by name and return the Document.

Code:

doc, err := Open("fake")
if err != nil {
    panic(err)
}
fmt.Print(doc.Asset)

func (*Document) MarshalJSON Uses

func (d *Document) MarshalJSON() ([]byte, error)

MarshalJSON marshal the document with the correct default values.

func (*Document) UnmarshalJSON Uses

func (d *Document) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the document with the correct default values.

func (*Document) Validate Uses

func (d *Document) Validate() error

Validate ensures that a document follows the glTF 2.0 specs.

type Encoder Uses

type Encoder struct {
    // contains filtered or unexported fields
}

An Encoder writes a GLTF to an output stream.

func NewEncoder Uses

func NewEncoder(w io.Writer, cb WriteResourceCallback, asBinary bool) *Encoder

NewEncoder returns a new encoder that writes to w as a normal glTF file.

func (*Encoder) Encode Uses

func (e *Encoder) Encode(doc *Document) error

Encode writes the encoding of doc to the stream.

type Extensions Uses

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 Uses

func (ext *Extensions) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the extensions with the supported extensions initialized.

type Image Uses

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 Uses

func (im *Image) IsEmbeddedResource() bool

IsEmbeddedResource returns true if the buffer points to an embedded resource.

func (*Image) MarshalData Uses

func (im *Image) MarshalData() ([]uint8, error)

MarshalData decode the image from the URI. If the image is not en embedded resource the returned array will be empty.

type Interpolation Uses

type Interpolation string

Interpolation algorithm.

type MagFilter Uses

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 Uses

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 NewMaterial Uses

func NewMaterial() *Material

NewMaterial create a default Material.

func (*Material) MarshalJSON Uses

func (m *Material) MarshalJSON() ([]byte, error)

MarshalJSON marshal the material with the correct default values.

func (*Material) UnmarshalJSON Uses

func (m *Material) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the material with the correct default values.

type Mesh Uses

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 MinFilter Uses

type MinFilter uint16

MinFilter is the minification filter.

type Node Uses

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 NewNode Uses

func NewNode() *Node

NewNode returns a default Node.

func (*Node) MarshalJSON Uses

func (n *Node) MarshalJSON() ([]byte, error)

MarshalJSON marshal the node with the correct default values.

func (*Node) UnmarshalJSON Uses

func (n *Node) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the node with the correct default values.

type NormalTexture Uses

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 Uses

func NewNormalTexture(index int32) *NormalTexture

NewNormalTexture returns a default NormalTexture.

func (*NormalTexture) MarshalJSON Uses

func (n *NormalTexture) MarshalJSON() ([]byte, error)

MarshalJSON marshal the texture info with the correct default values.

func (*NormalTexture) UnmarshalJSON Uses

func (n *NormalTexture) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the texture info with the correct default values.

type OcclusionTexture Uses

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 Uses

func NewOcclusionTexture(index int32) *OcclusionTexture

NewOcclusionTexture returns a default OcclusionTexture.

func (*OcclusionTexture) MarshalJSON Uses

func (o *OcclusionTexture) MarshalJSON() ([]byte, error)

MarshalJSON marshal the texture info with the correct default values.

func (*OcclusionTexture) UnmarshalJSON Uses

func (o *OcclusionTexture) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the texture info with the correct default values.

type Orthographic Uses

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 Uses

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 Uses

func NewPBRMetallicRoughness() *PBRMetallicRoughness

NewPBRMetallicRoughness returns a default PBRMetallicRoughness.

func (*PBRMetallicRoughness) MarshalJSON Uses

func (p *PBRMetallicRoughness) MarshalJSON() ([]byte, error)

MarshalJSON marshal the pbr with the correct default values.

func (*PBRMetallicRoughness) UnmarshalJSON Uses

func (p *PBRMetallicRoughness) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the pbr with the correct default values.

type PBRSpecularGlossiness Uses

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 Uses

func NewPBRSpecularGlossiness() *PBRSpecularGlossiness

PBRSpecularGlossiness returns a default PBRSpecularGlossiness.

func (*PBRSpecularGlossiness) MarshalJSON Uses

func (p *PBRSpecularGlossiness) MarshalJSON() ([]byte, error)

MarshalJSON marshal the pbr with the correct default values.

func (*PBRSpecularGlossiness) UnmarshalJSON Uses

func (p *PBRSpecularGlossiness) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the pbr with the correct default values.

type Perspective Uses

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 Uses

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 NewPrimitive Uses

func NewPrimitive() *Primitive

NewPrimitive create a default Primitive.

func (*Primitive) MarshalJSON Uses

func (p *Primitive) MarshalJSON() ([]byte, error)

MarshalJSON marshal the primitive with the correct default values.

func (*Primitive) UnmarshalJSON Uses

func (p *Primitive) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the primitive with the correct default values.

type PrimitiveMode Uses

type PrimitiveMode uint8

PrimitiveMode defines the type of primitives to render. All valid values correspond to WebGL enums.

type ReadQuotas Uses

type ReadQuotas struct {
    MaxBufferCount      int
    MaxMemoryAllocation int
}

ReadQuotas defines maximum allocation sizes to prevent DOS's from malicious files.

type ReadResourceCallback Uses

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 Uses

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 NewSampler Uses

func NewSampler() *Sampler

NewSampler returns a default Sampler.

func (*Sampler) UnmarshalJSON Uses

func (s *Sampler) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the sampler with the correct default values.

type Scene Uses

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 Uses

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 NewSkin Uses

func NewSkin() *Skin

NewSkin create a default Skin.

func (*Skin) MarshalJSON Uses

func (s *Skin) MarshalJSON() ([]byte, error)

MarshalJSON marshal the skin with the correct default values.

func (*Skin) UnmarshalJSON Uses

func (s *Skin) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the skin with the correct default values.

type Sparse Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 NewTexture Uses

func NewTexture() *Texture

NewTexture returns a default Texture.

func (*Texture) MarshalJSON Uses

func (t *Texture) MarshalJSON() ([]byte, error)

MarshalJSON marshal the texture with the correct default values.

func (*Texture) UnmarshalJSON Uses

func (t *Texture) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the texture with the correct default values.

type TextureInfo Uses

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 Uses

func NewTextureInfo(index int32) *TextureInfo

NewTextureInfo returns a default TextureInfo.

func (*TextureInfo) MarshalJSON Uses

func (t *TextureInfo) MarshalJSON() ([]byte, error)

MarshalJSON marshal the texture info with the correct default values.

func (*TextureInfo) UnmarshalJSON Uses

func (t *TextureInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the texture info with the correct default values.

type WrappingMode Uses

type WrappingMode uint16

WrappingMode is the wrapping mode of a texture.

type WriteResourceCallback Uses

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.

Package gltf imports 13 packages (graph). Updated 2019-03-15. Refresh now. Tools for package owners.