Documentation ¶
Overview ¶
Example ¶
package main import ( "github.com/qmuntal/gltf" "github.com/qmuntal/gltf/modeler" ) func main() { m := modeler.NewModeler() positionAccessor := m.AddPosition(0, [][3]float32{{43, 43, 0}, {83, 43, 0}, {63, 63, 40}, {43, 83, 0}, {83, 83, 0}}) indicesAccessor := m.AddIndices(0, []uint8{0, 1, 2, 3, 1, 0, 0, 2, 3, 1, 4, 2, 4, 3, 2, 4, 1, 3}) colorIndices := m.AddColor(0, [][3]uint8{{50, 155, 255}, {0, 100, 200}, {255, 155, 50}, {155, 155, 155}, {25, 25, 25}}) m.Document.Meshes = []gltf.Mesh{{ Name: "Pyramid", Primitives: []gltf.Primitive{ { Indices: gltf.Index(indicesAccessor), Attributes: map[string]uint32{ "POSITION": positionAccessor, "COLOR_0": colorIndices, }, }, }, }} m.Nodes = []gltf.Node{{Name: "Root", Mesh: gltf.Index(0)}} m.Scenes[0].Nodes = append(m.Scenes[0].Nodes, 0) if err := gltf.SaveBinary(m.Document, "./example.glb"); err != nil { panic(err) } }
Output:
Index ¶
- type CompressionLevel
- type Modeler
- func (m *Modeler) AddColor(bufferIndex uint32, data interface{}) uint32
- func (m *Modeler) AddImage(bufferIndex uint32, name, mimeType string, r io.Reader) (uint32, error)
- func (m *Modeler) AddIndices(bufferIndex uint32, data interface{}) uint32
- func (m *Modeler) AddJoints(bufferIndex uint32, data interface{}) uint32
- func (m *Modeler) AddNormal(bufferIndex uint32, data [][3]float32) uint32
- func (m *Modeler) AddPosition(bufferIndex uint32, data [][3]float32) uint32
- func (m *Modeler) AddTangent(bufferIndex uint32, data [][4]float32) uint32
- func (m *Modeler) AddTextureCoord(bufferIndex uint32, data interface{}) uint32
- func (m *Modeler) AddWeights(bufferIndex uint32, data interface{}) uint32
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompressionLevel ¶
type CompressionLevel uint8
CompressionLevel defines the different levels of compression.
const ( // CompressionNone will not apply any compression. CompressionNone CompressionLevel = iota // CompressionLossless will reduce the byte size without sacrificing quality. CompressionLossless )
type Modeler ¶
type Modeler struct { *gltf.Document Compression CompressionLevel }
Modeler wraps a Document and add useful methods to build it. If Compress is true, all the data added to accessors that support different component types will be evaluated to see if it fits in a smaller component type.
func (*Modeler) AddColor ¶
AddColor adds a new COLOR accessor to the Document and fills the buffer with the color data. If success it returns the index of the new accessor.
func (*Modeler) AddImage ¶
AddImage adds a new image to the Document and fills the buffer with the image data. If success it returns the index of the new image.
func (*Modeler) AddIndices ¶
AddIndices adds a new INDICES accessor to the Document and fills the buffer with the indices data. If success it returns the index of the new accessor.
func (*Modeler) AddJoints ¶
AddJoints adds a new JOINTS accessor to the Document and fills the buffer with the joints data. If success it returns the index of the new accessor.
func (*Modeler) AddNormal ¶
AddNormal adds a new NORMAL accessor to the Document and fills the buffer with the indices data. If success it returns the index of the new accessor.
func (*Modeler) AddPosition ¶
AddPosition adds a new POSITION accessor to the Document and fills the buffer with the vertices data. If success it returns the index of the new accessor.
func (*Modeler) AddTangent ¶
AddTangent adds a new TANGENT accessor to the Document and fills the buffer with the indices data. If success it returns the index of the new accessor.
func (*Modeler) AddTextureCoord ¶
AddTextureCoord adds a new TEXTURECOORD accessor to the Document and fills the buffer with the texturecoord data. If success it returns the index of the new accessor.
func (*Modeler) AddWeights ¶
AddWeights adds a new WEIGHTS accessor to the Document and fills the buffer with the weights data. If success it returns the index of the new accessor.