package stl2gltf import "encoding/binary" // Triangle 50B type Triangle struct { Normal []byte // 4 * 3 12 Position []byte // 4 * 3 * 3 36 Attribute []byte // 2 02 XYZ []float32 } // // header num // |----80B------|-4B-|-----triangle1--------|--------triangle2-------|-----------... // Normal(xyz) 4 x 3 position1 position2 position3 attribute // each triangle: |--------12--------|--------12--------|--------12--------|--------12--------|---2-------| // // // // type STL struct { Header string TriangleNum int Triangles []Triangle Max []float32 Min []float32 } type Asset struct { Version string `json:"version"` } type Scene struct { Nodes []int `json:"nodes"` } type Node struct { Mesh int `json:"mesh"` } type Primitive struct { Attributes map[string]int `json:"attributes"` Indices int `json:"indices"` Mode int `json:"mode"` } type Mesh struct { Primitives []Primitive `json:"primitives"` } type Buffer struct { Uri string `json:"uri"` ByteLength int `json:"byteLength"` } type BufferView struct { Buffer int `json:"buffer"` ByteOffset int `json:"byteOffset"` ByteLength int `json:"byteLength"` Target int `json:"target"` } type Accessor struct { BufferView int `json:"bufferView"` ByteOffset int `json:"byteOffset"` ComponentType int `json:"componentType"` Count int `json:"count"` Type string `json:"type"` Max []float32 `json:"max,omitempty"` Min []float32 `json:"min,omitempty"` } type GLTF struct { Asset Asset `json:"asset"` Scenes []Scene `json:"scenes"` Nodes []Node `json:"nodes"` Meshes []Mesh `json:"meshes"` Buffers []Buffer `json:"buffers"` BufferViews []BufferView `json:"bufferViews"` Accessors []Accessor `json:"accessors"` }