Documentation ¶
Overview ¶
Package modeler implements helper methods to write common glTF entities (indices, positions, colors, ...) into buffers.
Example ¶
package main import ( "github.com/qmuntal/gltf" "github.com/qmuntal/gltf/modeler" ) func main() { doc := gltf.NewDocument() positionAccessor := modeler.WritePosition(doc, [][3]float32{{43, 43, 0}, {83, 43, 0}, {63, 63, 40}, {43, 83, 0}, {83, 83, 0}}) indicesAccessor := modeler.WriteIndices(doc, []uint8{0, 1, 2, 3, 1, 0, 0, 2, 3, 1, 4, 2, 4, 3, 2, 4, 1, 3}) colorIndices := modeler.WriteColor(doc, [][3]uint8{{50, 155, 255}, {0, 100, 200}, {255, 155, 50}, {155, 155, 155}, {25, 25, 25}}) doc.Meshes = []*gltf.Mesh{{ Name: "Pyramid", Primitives: []*gltf.Primitive{ { Indices: gltf.Index(indicesAccessor), Attributes: map[string]uint32{ "POSITION": positionAccessor, "COLOR_0": colorIndices, }, }, }, }} doc.Nodes = []*gltf.Node{{Name: "Root", Mesh: gltf.Index(0)}} doc.Scenes[0].Nodes = append(doc.Scenes[0].Nodes, 0) if err := gltf.SaveBinary(doc, "./example.glb"); err != nil { panic(err) } }
Output:
Index ¶
- func WriteAccessor(doc *gltf.Document, target gltf.Target, data interface{}) uint32
- func WriteBufferView(doc *gltf.Document, target gltf.Target, data interface{}) uint32
- func WriteColor(doc *gltf.Document, data interface{}) uint32
- func WriteImage(doc *gltf.Document, name string, mimeType string, r io.Reader) (uint32, error)
- func WriteIndices(doc *gltf.Document, data interface{}) uint32
- func WriteJoints(doc *gltf.Document, data interface{}) uint32
- func WriteNormal(doc *gltf.Document, data [][3]float32) uint32
- func WritePosition(doc *gltf.Document, data [][3]float32) uint32
- func WriteTangent(doc *gltf.Document, data [][4]float32) uint32
- func WriteTextureCoord(doc *gltf.Document, data interface{}) uint32
- func WriteWeights(doc *gltf.Document, data interface{}) uint32
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteAccessor ¶ added in v0.16.0
WriteAccessor adds a new Accessor to doc and fills the buffer with data. If success it returns the index of the new accessor.
func WriteBufferView ¶ added in v0.16.0
WriteBufferView adds a new BufferView to doc and fills the buffer with the data. If success it returns the index of the new buffer view.
func WriteColor ¶ added in v0.16.0
WriteColor adds a new COLOR accessor to doc and fills the buffer with the color data. If success it returns the index of the new accessor.
func WriteImage ¶ added in v0.16.0
WriteImage adds a new image to doc and fills the buffer with the image data. If success it returns the index of the new image.
func WriteIndices ¶ added in v0.16.0
WriteIndices adds a new INDICES accessor to doc and fills the last buffer with the indices data. If success it returns the index of the new accessor.
func WriteJoints ¶ added in v0.16.0
WriteJoints adds a new JOINTS accessor to doc and fills the last buffer with the joints data. If success it returns the index of the new accessor.
func WriteNormal ¶ added in v0.16.0
WriteNormal adds a new NORMAL accessor to doc and fills the last buffer with the indices data. If success it returns the index of the new accessor.
func WritePosition ¶ added in v0.16.0
WritePosition adds a new POSITION accessor to doc and fills the last buffer with the vertices data. If success it returns the index of the new accessor.
func WriteTangent ¶ added in v0.16.0
WriteTangent adds a new TANGENT accessor to doc and fills the last buffer with the indices data. If success it returns the index of the new accessor.
func WriteTextureCoord ¶ added in v0.16.0
WriteTextureCoord adds a new TEXTURECOORD accessor to doc and fills the last buffer with the texturecoord data. If success it returns the index of the new accessor.
func WriteWeights ¶ added in v0.16.0
WriteWeights adds a new WEIGHTS accessor to doc and fills the last buffer with the weights data. If success it returns the index of the new accessor.
Types ¶
This section is empty.