Documentation
¶
Overview ¶
Package samplegltf generates and validates the deterministic glTF 2.0 sample models of the placeholder asset pack (package placeholder's models folder), which the 3D Blender pipeline documentation describes.
Index ¶
- Constants
- func GenerateCrateGLB() ([]byte, error)
- func GenerateGemGLB() ([]byte, error)
- func GenerateRobotArmGLTF() ([]byte, error)
- func PackGLB(doc *Document, bin []byte) ([]byte, error)
- func ValidateDocument(doc *Document, bin []byte) error
- func WriteSamples(dir string) error
- type Accessor
- type Animation
- type AnimationChannel
- type AnimationExtras
- type AnimationSampler
- type AnimationTarget
- type Asset
- type Buffer
- type BufferView
- type ClipEvent
- type Document
- type Material
- type Mesh
- type Node
- type PBRMetallicRoughness
- type Primitive
- type Scene
- type Skin
Constants ¶
const ( GLBMagic uint32 = 0x46546C67 // "glTF" GLBVersion uint32 = 2 ChunkTypeJSON uint32 = 0x4E4F534A // "JSON" ChunkTypeBIN uint32 = 0x004E4942 // "BIN\0" ComponentUnsignedByte = 5121 ComponentUnsignedShort = 5123 ComponentFloat = 5126 TargetArrayBuffer = 34962 TargetElementArrayBuffer = 34963 ModeTriangles = 4 )
GLB container and glTF 2.0 constants.
Variables ¶
This section is empty.
Functions ¶
func GenerateCrateGLB ¶
GenerateCrateGLB builds a deterministic binary glTF 2.0 (GLB) 1 m cube crate: right-handed +X right, +Y up, -Z forward, pivot at bottom center (Y in [0, 1]), CCW front faces, outward normals, UVs, and a PBR metallicRoughness material.
func GenerateGemGLB ¶
GenerateGemGLB builds a deterministic binary glTF 2.0 (GLB) pickup gem: a flat-shaded hexagonal bipyramid 0.8 m across and 1 m tall, pivot at its bottom point (Y in [0, 1]), with CCW outward faces, one normal per face and a glossy emerald PBR material. It uses only exactly rounded arithmetic (square roots, and products rounded before they are summed), so it writes the same bytes on every architecture.
func GenerateRobotArmGLTF ¶
GenerateRobotArmGLTF builds a deterministic embedded-buffer glTF 2.0 JSON file containing a 2-bone skinned and animated robot arm (UpperArm -> Forearm) with inverseBindMatrices, JOINTS_0, WEIGHTS_0, a Wave rotation animation, and extras.events clip markers.
func ValidateDocument ¶
ValidateDocument verifies glTF 2.0 schema bounds, geometry winding, normals, skinning joints/weights/IBMs, and animation samplers/events.
func WriteSamples ¶
WriteSamples writes crate.glb, robot_arm.gltf and gem.glb into dir.
Types ¶
type Accessor ¶
type Accessor struct {
BufferView *int `json:"bufferView,omitempty"`
ByteOffset int `json:"byteOffset,omitempty"`
ComponentType int `json:"componentType"`
Count int `json:"count"`
Type string `json:"type"`
Min []float64 `json:"min,omitempty"`
Max []float64 `json:"max,omitempty"`
}
Accessor describes a typed view into a BufferView.
type Animation ¶
type Animation struct {
Name string `json:"name,omitempty"`
Channels []AnimationChannel `json:"channels"`
Samplers []AnimationSampler `json:"samplers"`
Extras *AnimationExtras `json:"extras,omitempty"`
}
Animation stores keyframe channels, samplers, and NSGo clip events.
type AnimationChannel ¶
type AnimationChannel struct {
Sampler int `json:"sampler"`
Target AnimationTarget `json:"target"`
}
AnimationChannel binds a sampler to a node property path.
type AnimationExtras ¶
type AnimationExtras struct {
Events []ClipEvent `json:"events,omitempty"`
}
AnimationExtras holds custom metadata on an animation clip.
type AnimationSampler ¶
type AnimationSampler struct {
Input int `json:"input"`
Interpolation string `json:"interpolation,omitempty"`
Output int `json:"output"`
}
AnimationSampler maps keyframe input timestamps to output values.
type AnimationTarget ¶
AnimationTarget identifies the animated node and TRS/weights path.
type BufferView ¶
type BufferView struct {
Buffer int `json:"buffer"`
ByteOffset int `json:"byteOffset"`
ByteLength int `json:"byteLength"`
Target int `json:"target,omitempty"`
}
BufferView slices a byte range out of a Buffer.
type Document ¶
type Document struct {
Asset Asset `json:"asset"`
Scene *int `json:"scene,omitempty"`
Scenes []Scene `json:"scenes,omitempty"`
Nodes []Node `json:"nodes,omitempty"`
Meshes []Mesh `json:"meshes,omitempty"`
Materials []Material `json:"materials,omitempty"`
Skins []Skin `json:"skins,omitempty"`
Animations []Animation `json:"animations,omitempty"`
Accessors []Accessor `json:"accessors,omitempty"`
BufferViews []BufferView `json:"bufferViews,omitempty"`
Buffers []Buffer `json:"buffers,omitempty"`
}
Document is the subset of the glTF 2.0 JSON schema used by the sample models.
func ParseEmbeddedGLTF ¶
ParseEmbeddedGLTF parses a glTF 2.0 JSON file whose single buffer uses a base64 data URI.
type Material ¶
type Material struct {
Name string `json:"name,omitempty"`
PBRMetallicRoughness *PBRMetallicRoughness `json:"pbrMetallicRoughness,omitempty"`
DoubleSided bool `json:"doubleSided"`
}
Material defines PBR surface properties.
type Node ¶
type Node struct {
Name string `json:"name,omitempty"`
Children []int `json:"children,omitempty"`
Mesh *int `json:"mesh,omitempty"`
Skin *int `json:"skin,omitempty"`
Translation *[3]float64 `json:"translation,omitempty"`
Rotation *[4]float64 `json:"rotation,omitempty"`
Scale *[3]float64 `json:"scale,omitempty"`
}
Node represents an object or joint in the scene hierarchy.
type PBRMetallicRoughness ¶
type PBRMetallicRoughness struct {
BaseColorFactor [4]float64 `json:"baseColorFactor"`
MetallicFactor float64 `json:"metallicFactor"`
RoughnessFactor float64 `json:"roughnessFactor"`
}
PBRMetallicRoughness defines the glTF 2.0 metallic-roughness material model.
type Primitive ¶
type Primitive struct {
Attributes map[string]int `json:"attributes"`
Indices *int `json:"indices,omitempty"`
Material *int `json:"material,omitempty"`
Mode *int `json:"mode,omitempty"`
}
Primitive references vertex attributes, optional indices, and a material.