Documentation ¶
Index ¶
- Constants
- Variables
- type Animation
- type AnimationBinding
- type Armature
- type Binary
- type BodyDefinition
- type BodyInstance
- type CollisionBox
- type CollisionMesh
- type CollisionSphere
- type CollisionTriangle
- type CubeTexture
- type CubeTextureSide
- type Decodable
- type Encodable
- type FilterMode
- type IndexLayout
- type Joint
- type LightInstance
- type LightType
- type Material
- type MaterialType
- type MeshDefinition
- type MeshFragment
- type MeshInstance
- type MeshTopology
- type Model
- type ModelInstance
- type Node
- type PBRMaterialView
- func (v *PBRMaterialView) BaseColor() sprec.Vec4
- func (v *PBRMaterialView) BaseColorTexture() TextureRef
- func (v *PBRMaterialView) Metallic() float32
- func (v *PBRMaterialView) MetallicRoughnessTexture() TextureRef
- func (v *PBRMaterialView) NormalScale() float32
- func (v *PBRMaterialView) NormalTexture() TextureRef
- func (v *PBRMaterialView) Roughness() float32
- func (v *PBRMaterialView) SetBaseColor(color sprec.Vec4)
- func (v *PBRMaterialView) SetBaseColorTexture(texture TextureRef)
- func (v *PBRMaterialView) SetMetallic(metallic float32)
- func (v *PBRMaterialView) SetMetallicRoughnessTexture(texture TextureRef)
- func (v *PBRMaterialView) SetNormalScale(scale float32)
- func (v *PBRMaterialView) SetNormalTexture(texture TextureRef)
- func (v *PBRMaterialView) SetRoughness(roughness float32)
- type Registry
- type RegistryLocator
- type Resource
- type RotationKeyframe
- type ScaleKeyframe
- type Scene
- type TexelFormat
- type TextureFlag
- type TextureRef
- type TranslationKeyframe
- type TwoDTexture
- type VertexLayout
- type WrapMode
Constants ¶
const ( UnspecifiedOffset = int32(-1) UnspecifiedMaterialIndex = int32(-1) UnspecifiedArmatureIndex = int32(-1) )
const UnspecifiedIndex = int32(-1)
const UnspecifiedNodeIndex = int32(-1)
Variables ¶
var ErrNotFound = fmt.Errorf("not found")
ErrNotFound indicates that the specified content is not available.
Functions ¶
This section is empty.
Types ¶
type Animation ¶ added in v0.9.0
type Animation struct { Name string StartTime float64 EndTime float64 Bindings []AnimationBinding }
type AnimationBinding ¶ added in v0.9.0
type AnimationBinding struct { NodeIndex int32 NodeName string // alternative in case of isolated animation TranslationKeyframes []TranslationKeyframe RotationKeyframes []RotationKeyframe ScaleKeyframes []ScaleKeyframe }
type BodyDefinition ¶ added in v0.8.0
type BodyDefinition struct { Name string Mass float64 MomentOfInertia dprec.Mat3 RestitutionCoefficient float64 DragFactor float64 AngularDragFactor float64 CollisionBoxes []CollisionBox CollisionSpheres []CollisionSphere CollisionMeshes []CollisionMesh }
type BodyInstance ¶ added in v0.8.0
type CollisionBox ¶ added in v0.8.0
type CollisionMesh ¶ added in v0.8.0
type CollisionMesh struct { Translation dprec.Vec3 Rotation dprec.Quat Triangles []CollisionTriangle }
type CollisionSphere ¶ added in v0.8.0
type CollisionTriangle ¶ added in v0.8.0
type CubeTexture ¶
type CubeTexture struct { Dimension uint16 Filtering FilterMode Format TexelFormat Flags TextureFlag FrontSide CubeTextureSide BackSide CubeTextureSide LeftSide CubeTextureSide RightSide CubeTextureSide TopSide CubeTextureSide BottomSide CubeTextureSide }
func (*CubeTexture) DecodeFrom ¶
func (t *CubeTexture) DecodeFrom(in io.Reader) error
type CubeTextureSide ¶
type CubeTextureSide struct {
Data []byte
}
type FilterMode ¶
type FilterMode uint8
const ( FilterModeNearest FilterMode = iota FilterModeLinear FilterModeAnisotropic )
type IndexLayout ¶ added in v0.8.0
type IndexLayout uint8
const ( IndexLayoutUint16 IndexLayout = iota IndexLayoutUint32 )
type LightInstance ¶ added in v0.10.0
type Material ¶ added in v0.8.0
type Material struct { Name string Type MaterialType BackfaceCulling bool AlphaTesting bool AlphaThreshold float32 Blending bool ScalarMask uint32 Scalars [16]float32 Textures [16]TextureRef }
type MaterialType ¶ added in v0.8.0
type MaterialType uint8
const ( MaterialTypePBR MaterialType = iota MaterialTypeAlbedo )
type MeshDefinition ¶ added in v0.8.0
type MeshDefinition struct { Name string VertexLayout VertexLayout VertexData []byte IndexLayout IndexLayout IndexData []byte Fragments []MeshFragment BoundingSphereRadius float64 }
type MeshFragment ¶ added in v0.8.0
type MeshFragment struct { Topology MeshTopology IndexOffset uint32 IndexCount uint32 MaterialIndex int32 }
type MeshInstance ¶ added in v0.8.0
type MeshTopology ¶ added in v0.8.0
type MeshTopology uint8
const ( MeshTopologyPoints MeshTopology = iota MeshTopologyLineStrip MeshTopologyLineLoop MeshTopologyLines MeshTopologyTriangleStrip MeshTopologyTriangleFan MeshTopologyTriangles )
type Model ¶ added in v0.8.0
type Model struct { Nodes []Node Animations []Animation Armatures []Armature Textures []TwoDTexture Materials []Material MeshDefinitions []MeshDefinition MeshInstances []MeshInstance BodyDefinitions []BodyDefinition BodyInstances []BodyInstance LightInstances []LightInstance }
type ModelInstance ¶ added in v0.9.0
type PBRMaterialView ¶ added in v0.9.0
type PBRMaterialView struct {
// contains filtered or unexported fields
}
func NewPBRMaterialView ¶ added in v0.9.0
func NewPBRMaterialView(delegate *Material) *PBRMaterialView
func (*PBRMaterialView) BaseColor ¶ added in v0.9.0
func (v *PBRMaterialView) BaseColor() sprec.Vec4
func (*PBRMaterialView) BaseColorTexture ¶ added in v0.9.0
func (v *PBRMaterialView) BaseColorTexture() TextureRef
func (*PBRMaterialView) Metallic ¶ added in v0.9.0
func (v *PBRMaterialView) Metallic() float32
func (*PBRMaterialView) MetallicRoughnessTexture ¶ added in v0.9.0
func (v *PBRMaterialView) MetallicRoughnessTexture() TextureRef
func (*PBRMaterialView) NormalScale ¶ added in v0.9.0
func (v *PBRMaterialView) NormalScale() float32
func (*PBRMaterialView) NormalTexture ¶ added in v0.9.0
func (v *PBRMaterialView) NormalTexture() TextureRef
func (*PBRMaterialView) Roughness ¶ added in v0.9.0
func (v *PBRMaterialView) Roughness() float32
func (*PBRMaterialView) SetBaseColor ¶ added in v0.9.0
func (v *PBRMaterialView) SetBaseColor(color sprec.Vec4)
func (*PBRMaterialView) SetBaseColorTexture ¶ added in v0.9.0
func (v *PBRMaterialView) SetBaseColorTexture(texture TextureRef)
func (*PBRMaterialView) SetMetallic ¶ added in v0.9.0
func (v *PBRMaterialView) SetMetallic(metallic float32)
func (*PBRMaterialView) SetMetallicRoughnessTexture ¶ added in v0.9.0
func (v *PBRMaterialView) SetMetallicRoughnessTexture(texture TextureRef)
func (*PBRMaterialView) SetNormalScale ¶ added in v0.9.0
func (v *PBRMaterialView) SetNormalScale(scale float32)
func (*PBRMaterialView) SetNormalTexture ¶ added in v0.9.0
func (v *PBRMaterialView) SetNormalTexture(texture TextureRef)
func (*PBRMaterialView) SetRoughness ¶ added in v0.9.0
func (v *PBRMaterialView) SetRoughness(roughness float32)
type Registry ¶
type Registry interface { Resources() []Resource ResourceByID(id string) Resource ResourceByName(name string) Resource ResourcesByName(name string) []Resource CreateResource(kind, name string) Resource // CreateIDResource is deprecated and available only due to the old // pack mechanism. CreateIDResource(id, kind, name string) Resource Save() error }
Registry represents a managment interface for assets.
func NewDirRegistry ¶
NewDirRegistry creates a Registry implementation that stores content on the filesystem. The provided dir parameter needs to point to the project root. A special assets directory will be created inside if one is not available already.
func NewWebRegistry ¶
NewWebRegistry creates a Registry implementation that reads content from the web. The provided assetsURL parameter needs to point to the web location of the assets.
This registry does not support write or delete operations.
type RegistryLocator ¶ added in v0.8.0
type RegistryLocator struct {
// contains filtered or unexported fields
}
RegistryLocator is an implementation of ReadLocator that uses a Registry to access resources.
func NewRegistryLocator ¶ added in v0.8.0
func NewRegistryLocator(registry Registry) *RegistryLocator
NewRegistryLocator returns a new *FileLocator that is configured to access resources located on the local filesystem.
func (*RegistryLocator) ReadResource ¶ added in v0.8.0
func (l *RegistryLocator) ReadResource(path string) (io.ReadCloser, error)
type Resource ¶
type Resource interface { ID() string Kind() string Name() string SetName(name string) Dependants() []Resource Dependencies() []Resource AddDependency(resource Resource) RemoveDependency(resource Resource) ReadPreview() (image.Image, error) WritePreview(image.Image) error DeletePreview() error ReadContent(target Decodable) error WriteContent(source Encodable) error DeleteContent() error Delete() }
Resource represents the generic aspects of an asset.
type RotationKeyframe ¶ added in v0.9.0
type ScaleKeyframe ¶ added in v0.9.0
type Scene ¶ added in v0.8.0
type TexelFormat ¶
type TexelFormat uint8
const ( TexelFormatR8 TexelFormat = iota TexelFormatR16 TexelFormatR16F TexelFormatR32F TexelFormatRG8 TexelFormatRG16 TexelFormatRG16F TexelFormatRG32F TexelFormatRGB8 TexelFormatRGB16 TexelFormatRGB16F TexelFormatRGB32F TexelFormatRGBA8 TexelFormatRGBA16 TexelFormatRGBA16F TexelFormatRGBA32F TexelFormatDepth16F TexelFormatDepth32F )
type TextureFlag ¶ added in v0.8.0
type TextureFlag uint8
const ( TextureFlagMipmapping TextureFlag = 1 << iota TextureFlagLinear TextureFlagNone TextureFlag = 0 )
func (TextureFlag) Has ¶ added in v0.8.0
func (f TextureFlag) Has(flag TextureFlag) bool
type TextureRef ¶ added in v0.9.0
func (TextureRef) Valid ¶ added in v0.9.0
func (r TextureRef) Valid() bool
type TranslationKeyframe ¶ added in v0.9.0
type TwoDTexture ¶
type TwoDTexture struct { Width uint16 Height uint16 Wrapping WrapMode Filtering FilterMode Format TexelFormat Flags TextureFlag Data []byte }
func (*TwoDTexture) DecodeFrom ¶
func (t *TwoDTexture) DecodeFrom(in io.Reader) error
type VertexLayout ¶ added in v0.8.0
type VertexLayout struct { CoordOffset int32 CoordStride int32 NormalOffset int32 NormalStride int32 TangentOffset int32 TangentStride int32 TexCoordOffset int32 TexCoordStride int32 ColorOffset int32 ColorStride int32 WeightsOffset int32 WeightsStride int32 JointsOffset int32 JointsStride int32 }
VertexLayout describes how vertex data is positioned within the VertexData buffer.
Coords are represented by RGB32F (i.e. three 32-bit float values). Since coords can span a bigger range, 32-bit floats are preferred.
Normals and Tangents are represented by RGB16F (i.e. three 16-bit float values). This should be more than sufficient for normals.
TexCoords are represented by RG16F (i.e. two 16-bit float values). Since texture coordinates are usually close to the zero-one range, 16-bit floats should provide sufficient precision.
Colors are represented by RGBA8UN (i.e. four 8-bit unsigned normalized values). This is sufficient for an sRGB color with alpha.
Weights are represented by RGBA8UN (i.e. four 8-bit unsigned normalized values). This should provide sufficient precision while still being fairly compact.
Joints are represented by RGBA8IU (i.e. four 8-bit integer unsigned values). This means that there can be at most 256 joints in an Armature.