Documentation ¶
Overview ¶
Package gltf 实现了加载glTF格式3D模型的数据结构和方法
Index ¶
- Constants
- func ReadGLB(r io.Reader) (json, bin []byte, err error)
- func WriteGLB(w io.Writer, json, bin []byte) (err error)
- type Accessor
- type Animation
- type AnimationChannel
- type AnimationSampler
- type AnimationTarget
- type Asset
- type Attributes
- type Buffer
- type BufferView
- type Camera
- type ComponentType
- type DataType
- type GLTF
- func (p *GLTF) ReadAccessor(i uint32) (data []byte, stride uint32, a *Accessor, err error)
- func (p *GLTF) ReadBuffer(i uint32) (data []byte, mime string, err error)
- func (p *GLTF) ReadBufferView(i uint32) (data []byte, mime string, bv *BufferView, err error)
- func (p *GLTF) ReadImage(i uint32) (data []byte, mime string, img *Image, err error)
- type Image
- type KHR_materials_clearcoat
- type KHR_materials_pbrSpecularGlossiness
- type KHR_materials_unlit
- type Material
- type Matrix
- type Mesh
- type MorphTarget
- type Node
- type NormalTextureInfo
- type OcclusionTextureInfo
- type Primitive
- type Rotation
- type Sampler
- type Scale
- type Scene
- type Skin
- type Texture
- type TextureInfo
- type Translation
Constants ¶
View Source
const ( ChunkJSON = 0x4E4F534A ChunkBIN = 0x004E4942 )
View Source
const ( POINTS = 0 LINES = 1 LINE_LOOP = 2 LINE_STRIP = 3 TRIANGLES = 4 TRIANGLE_STRIP = 5 TRIANGLE_FAN = 6 )
View Source
const ( NEAREST = 9728 LINEAR = 9729 NEAREST_MIPMAP_NEAREST = 9984 LINEAR_MIPMAP_NEAREST = 9985 NEAREST_MIPMAP_LINEAR = 9986 LINEAR_MIPMAP_LINEAR = 9987 )
View Source
const ( CLAMP_TO_EDGE = 33071 MIRRORED_REPEAT = 33648 REPEAT = 10497 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Accessor ¶
type Accessor struct { BufferView uint32 ByteOffset uint32 ComponentType ComponentType Count uint32 Max []float32 Min []float32 Type DataType Sparse *struct { Count uint32 Indices struct { BufferView uint32 ByteOffset uint32 ComponentType ComponentType } Values struct { BufferView uint32 ByteOffset uint32 } } }
func (Accessor) NumElemBytes ¶
func (Accessor) NumTotalBytes ¶
type Animation ¶
type Animation struct { Channels []AnimationChannel AniSamplers []AnimationSampler `json:"Samplers"` Name string }
type AnimationChannel ¶
type AnimationChannel struct { AniSampler uint32 `json:"Sampler"` // 指向所属Animation的Samplers, 不是数据的Sampler Target AnimationTarget }
type AnimationSampler ¶
type AnimationTarget ¶
type Attributes ¶
type Attributes struct { POSITION *uint32 NORMAL *uint32 TANGENT *uint32 TEXCOORD_0 *uint32 TEXCOORD_1 *uint32 TEXCOORD_2 *uint32 TEXCOORD_3 *uint32 COLOR_0 *uint32 COLOR_1 *uint32 COLOR_2 *uint32 COLOR_3 *uint32 JOINTS_0 *uint32 JOINTS_1 *uint32 JOINTS_2 *uint32 JOINTS_3 *uint32 WEIGHTS_0 *uint32 WEIGHTS_1 *uint32 WEIGHTS_2 *uint32 WEIGHTS_3 *uint32 }
type Buffer ¶
type Buffer struct { URI string ByteLength uint32 Name string // contains filtered or unexported fields }
func (Buffer) IsExternal ¶
type BufferView ¶
type ComponentType ¶
type ComponentType uint32
const ( BYTE ComponentType = 5120 UNSIGNED_BYTE ComponentType = 5121 SHORT ComponentType = 5122 UNSIGNED_SHORT ComponentType = 5123 UNSIGNED_INT ComponentType = 5125 FLOAT ComponentType = 5126 )
func (ComponentType) MarshalJSON ¶
func (t ComponentType) MarshalJSON() ([]byte, error)
func (ComponentType) NumBytes ¶
func (t ComponentType) NumBytes() uint32
func (ComponentType) String ¶
func (t ComponentType) String() string
func (*ComponentType) UnmarshalJSON ¶
func (t *ComponentType) UnmarshalJSON(b []byte) error
type GLTF ¶
type GLTF struct { Asset Asset Nodes []*Node Scenes []*Scene Scene *uint32 Accessors []*Accessor Meshes []*Mesh Skins []*Skin Textures []*Texture Images []*Image Samplers []*Sampler Materials []*Material Cameras []*Camera BufferViews []*BufferView Buffers []*Buffer Animations []*Animation ExtensionsUsed []string ExtensionsRequired []string BIN []byte `json:"-"` }
func (*GLTF) ReadAccessor ¶
func (*GLTF) ReadBufferView ¶
type KHR_materials_clearcoat ¶
type KHR_materials_clearcoat struct { ClearcoatFactor float32 ClearcoatTexture *TextureInfo ClearcoatRoughnessFactor float32 ClearcoatRoughnessTexture *TextureInfo ClearcoatNormalTexture *NormalTextureInfo }
type KHR_materials_pbrSpecularGlossiness ¶
type KHR_materials_pbrSpecularGlossiness struct { DiffuseFactor *[4]float32 SpecularFactor *[3]float32 DiffuseTexture TextureInfo GlossinessFactor *float32 SpecularGlossinessTexture TextureInfo }
type KHR_materials_unlit ¶
type KHR_materials_unlit struct { }
type Material ¶
type Material struct { Name string PbrMetallicRoughness *struct { BaseColorFactor *[4]float32 // default 1 BaseColorTexture *TextureInfo MetallicFactor *float32 // default 1 RoughnessFactor *float32 // default 1 MetallicRoughnessTexture *TextureInfo } NormalTexture *NormalTextureInfo OcclusionTexture *OcclusionTextureInfo EmissiveFactor [3]float32 // default [0 0 0] EmissiveTexture *TextureInfo AlphaMode string AlphaCutoff *float32 // default 0.5 DoubleSided bool Extensions struct { KHR_materials_pbrSpecularGlossiness *KHR_materials_pbrSpecularGlossiness KHR_materials_clearcoat *KHR_materials_clearcoat KHR_materials_unlit *KHR_materials_unlit } }
type MorphTarget ¶
顶点变形动画的目标.
type NormalTextureInfo ¶
type OcclusionTextureInfo ¶
type Primitive ¶
type Primitive struct { Attributes Attributes // 顶点属性 Indices *uint32 // 顶点索引 Material *uint32 // 材质 Mode *uint32 // 图元类型 default 4 TRIANGLES Targets []MorphTarget // 顶点变形动画的目标 }
几何图元
type Skin ¶
type Skin struct { Name string InverseBindMatrices *uint32 Joints []uint32 // 骨骼的公共根节点LCA(非必填). // glTF文档里虽然没明确指出骨骼的范围, 我们理解为当前Skin的骨骼的LCA. Skeleton *uint32 }
皮肤. glTF的皮肤可以理解为Bind Pose, 不是通常意义上的皮肤. 它通常和Mesh配套使用, 把Mesh绑到骨骼上. 当然它也可以不绑Mesh, Bind Pose本身可独立使用, 比如用来画骨骼. 皮肤里最有意义的数据是IBM数据, IBM和Bind Pose其实是一回事, 知道骨骼姿势就能算出IBM, 反之亦然.
type TextureInfo ¶
type Translation ¶
type Translation [3]float32
Click to show internal directories.
Click to hide internal directories.