Documentation ¶
Index ¶
- Constants
- Variables
- func Save(modelPath string, scene PolyformScene) error
- func SaveBinary(gltfPath string, scene PolyformScene) error
- func SaveText(gltfPath string, scene PolyformScene) error
- func WriteBinary(scene PolyformScene, out io.Writer) error
- func WriteText(scene PolyformScene, out io.Writer) error
- type Accessor
- type AccessorComponentType
- type AccessorType
- type Animation
- type AnimationChannel
- type AnimationChannelTarget
- type AnimationChannelTargetPath
- type AnimationSampler
- type AnimationSamplerInterpolation
- type Artifact
- type Asset
- type Buffer
- type BufferEmbeddingStrategy
- type BufferView
- type BufferViewTarget
- type Camera
- type ChildOfRootProperty
- type ExtGpuInstancing
- type Extensions
- type Extra
- type Gltf
- type GltfArtifact
- type GltfArtifactData
- type GltfId
- type GltfMaterialAnisotropyExtensionNode
- type GltfMaterialAnisotropyExtensionNodeData
- type GltfMaterialClearcoatExtensionNode
- type GltfMaterialClearcoatExtensionNodeData
- type GltfMaterialNode
- type GltfMaterialNodeData
- type GltfMaterialTransmissionExtensionNode
- type GltfMaterialTransmissionExtensionNodeData
- type GltfMaterialVolumeExtensionNode
- type GltfMaterialVolumeExtensionNodeData
- type GltfModel
- type GltfModelNodeData
- type Image
- type ImageMimeType
- type KHR_LightsPunctual
- type KHR_LightsPunctualType
- type Material
- type MaterialAlphaMode
- type MaterialExtension
- type Mesh
- type Node
- type NormalTexture
- type OcclusionTexture
- type PbrMetallicRoughness
- type PolyformAnisotropy
- type PolyformClearcoat
- type PolyformDispersion
- type PolyformEmissiveStrength
- type PolyformIndexOfRefraction
- type PolyformIridescence
- type PolyformMaterial
- type PolyformModel
- type PolyformNormal
- type PolyformOcclusion
- type PolyformPbrMetallicRoughness
- type PolyformPbrSpecularGlossiness
- type PolyformScene
- type PolyformSheen
- type PolyformSpecular
- type PolyformTexture
- type PolyformTextureTransform
- type PolyformTransmission
- type PolyformUnlit
- type PolyformVolume
- type Primitive
- type PrimitiveMode
- type Property
- type Sampler
- type SamplerMagFilter
- type SamplerMinFilter
- type SamplerWrap
- type Scene
- type Skin
- type Texture
- type TextureExtension
- type TextureInfo
- type TextureNode
- type TextureNodeData
- type Writer
- func (w *Writer) AddAnimations(animations []animation.Sequence, skeleton animation.Skeleton, skeletonNode int)
- func (w *Writer) AddLight(light KHR_LightsPunctual)
- func (w *Writer) AddMaterial(mat *PolyformMaterial) (*int, error)
- func (w *Writer) AddMesh(model PolyformModel) (_ int, err error)
- func (w *Writer) AddScene(scene PolyformScene) error
- func (w *Writer) AddSkin(skeleton animation.Skeleton) (*int, int)
- func (w *Writer) AddTexture(polyTex *PolyformTexture) *TextureInfo
- func (w Writer) ToGLTF(embeddingStrategy BufferEmbeddingStrategy) Gltf
- func (w Writer) WriteGLB(out io.Writer) error
- func (w *Writer) WriteIndices(indices *iter.ArrayIterator[int], attributeSize int)
- func (w *Writer) WriteVector2(accessorComponentType AccessorComponentType, ...)
- func (w Writer) WriteVector2AsByte(v vector2.Float64)
- func (w Writer) WriteVector2AsFloat32(v vector2.Float64)
- func (w *Writer) WriteVector3(accessorComponentType AccessorComponentType, ...)
- func (w Writer) WriteVector3AsByte(v vector3.Float64)
- func (w Writer) WriteVector3AsFloat32(v vector3.Float64)
- func (w *Writer) WriteVector4(accessorComponentType AccessorComponentType, ...)
- func (w Writer) WriteVector4AsByte(v vector4.Float64)
- func (w Writer) WriteVector4AsFloat32(v vector4.Float64)
Constants ¶
const ( POSITION = "POSITION" NORMAL = "NORMAL" TANGENT = "TANGENT" TEXCOORD_0 = "TEXCOORD_0" COLOR_0 = "COLOR_0" JOINTS_0 = "JOINTS_0" WEIGHTS_0 = "WEIGHTS_0" )
https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.pdf Page 39
Variables ¶
var ErrInvalidInput = errors.New("invalid input")
Functions ¶
func Save ¶ added in v0.14.0
func Save(modelPath string, scene PolyformScene) error
Save writes the mesh to the path in the format dictated by the extension in the path
func SaveBinary ¶ added in v0.9.0
func SaveBinary(gltfPath string, scene PolyformScene) error
SaveBinary writes the mesh to the path specified in GLB format
func SaveText ¶
func SaveText(gltfPath string, scene PolyformScene) error
SaveText writes the mesh to the path specified in GLTF format
func WriteBinary ¶ added in v0.9.0
func WriteBinary(scene PolyformScene, out io.Writer) error
Types ¶
type Accessor ¶
type Accessor struct { ChildOfRootProperty BufferView *GltfId `json:"bufferView,omitempty"` // The index of the buffer view. When undefined, the accessor **MUST** be initialized with zeros; `sparse` property or extensions **MAY** override zeros with actual values. ByteOffset int `json:"byteOffset,omitempty"` // The offset relative to the start of the buffer view in bytes. This **MUST** be a multiple of the size of the component datatype. This property **MUST NOT** be defined when `bufferView` is undefined. ComponentType AccessorComponentType `json:"componentType"` // The datatype of the accessor's components. UNSIGNED_INT type **MUST NOT** be used for any accessor that is not referenced by `mesh.primitive.indices`. Normalized bool `json:"normalized,omitempty"` // Specifies whether integer data values are normalized (`true`) to [0, 1] (for unsigned types) or to [-1, 1] (for signed types) when they are accessed. This property **MUST NOT** be set to `true` for accessors with `FLOAT` or `UNSIGNED_INT` component type. Type AccessorType `json:"type"` // Specifies if the accessor's elements are scalars, vectors, or matrices. Count int `json:"count"` // The number of elements referenced by this accessor, not to be confused with the number of bytes or number of components. Max []float64 `json:"max,omitempty"` // Maximum value of each component in this accessor. Array elements **MUST** be treated as having the same data type as accessor's `componentType`. Both `min` and `max` arrays have the same length. The length is determined by the value of the `type` property; it can be 1, 2, 3, 4, 9, or 16.\n\n`normalized` property has no effect on array values: they always correspond to the actual values stored in the buffer. When the accessor is sparse, this property **MUST** contain maximum values of accessor data with sparse substitution applied. Min []float64 `json:"min,omitempty"` // Minimum value of each component in this accessor. Array elements **MUST** be treated as having the same data type as accessor's `componentType`. Both `min` and `max` arrays have the same length. The length is determined by the value of the `type` property; it can be 1, 2, 3, 4, 9, or 16.\n\n`normalized` property has no effect on array values: they always correspond to the actual values stored in the buffer. When the accessor is sparse, this property **MUST** contain minimum values of accessor data with sparse substitution applied. }
A typed view into a buffer view that contains raw binary data. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/accessor.schema.json
type AccessorComponentType ¶
type AccessorComponentType int
const ( AccessorComponentType_BYTE AccessorComponentType = 5120 AccessorComponentType_UNSIGNED_BYTE AccessorComponentType = 5121 AccessorComponentType_SHORT AccessorComponentType = 5122 AccessorComponentType_UNSIGNED_SHORT AccessorComponentType = 5123 AccessorComponentType_UNSIGNED_INT AccessorComponentType = 5125 AccessorComponentType_FLOAT AccessorComponentType = 5126 )
func (AccessorComponentType) Size ¶ added in v0.5.0
func (act AccessorComponentType) Size() int
type AccessorType ¶
type AccessorType string
const ( AccessorType_SCALAR AccessorType = "SCALAR" AccessorType_VEC2 AccessorType = "VEC2" AccessorType_VEC3 AccessorType = "VEC3" AccessorType_VEC4 AccessorType = "VEC4" AccessorType_MAT2 AccessorType = "MAT2" AccessorType_MAT3 AccessorType = "MAT3" AccessorType_MAT4 AccessorType = "MAT4" )
type Animation ¶
type Animation struct { ChildOfRootProperty Channels []AnimationChannel `json:"channels"` // An array of animation channels. An animation channel combines an animation sampler with a target property being animated. Different channels of the same animation **MUST NOT** have the same targets. Samplers []AnimationSampler `json:"samplers"` // An array of animation samplers. An animation sampler combines timestamps with a sequence of output values and defines an interpolation algorithm. }
A keyframe animation. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/animation.schema.json
type AnimationChannel ¶
type AnimationChannel struct { Property Sampler GltfId `json:"sampler"` // The index of a sampler in this animation used to compute the value for the target, e.g., a node's translation, rotation, or scale (TRS). Target AnimationChannelTarget `json:"target"` // The descriptor of the animated property. }
An animation channel combines an animation sampler with a target property being animated. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/animation.channel.schema.json
type AnimationChannelTarget ¶
type AnimationChannelTarget struct { Property Node GltfId `json:"node,omitempty"` Path AnimationChannelTargetPath `json:"path"` }
The descriptor of the animated property. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/animation.channel.target.schema.json
type AnimationChannelTargetPath ¶
type AnimationChannelTargetPath string
const ( AnimationChannelTargetPath_TRANSLATION AnimationChannelTargetPath = "translation" AnimationChannelTargetPath_ROTATION AnimationChannelTargetPath = "rotation" AnimationChannelTargetPath_SCALE AnimationChannelTargetPath = "scale" AnimationChannelTargetPath_WEIGHTS AnimationChannelTargetPath = "weights" )
type AnimationSampler ¶
type AnimationSampler struct { Property Input GltfId `json:"input"` // The index of an accessor containing keyframe timestamps. The accessor **MUST** be of scalar type with floating-point components. The values represent time in seconds with `time[0] >= 0.0`, and strictly increasing values, i.e., `time[n + 1] > time[n]`. Output GltfId `json:"output"` // The index of an accessor, containing keyframe output values. Interpolation AnimationSamplerInterpolation `json:"interpolation,omitempty"` // The index of an accessor, containing keyframe output values. }
An animation sampler combines timestamps with a sequence of output values and defines an interpolation algorithm. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/animation.sampler.schema.json
type AnimationSamplerInterpolation ¶
type AnimationSamplerInterpolation string
const ( AnimationSamplerInterpolation_LINEAR AnimationSamplerInterpolation = "LINEAR" // The animated values are linearly interpolated between keyframes. When targeting a rotation, spherical linear interpolation (slerp) **SHOULD** be used to interpolate quaternions. The number of output elements **MUST** equal the number of input elements. AnimationSamplerInterpolation_STEP AnimationSamplerInterpolation = "STEP" // The animated values remain constant to the output of the first keyframe, until the next keyframe. The number of output elements **MUST** equal the number of input elements. AnimationSamplerInterpolation_CUBICSPLINE AnimationSamplerInterpolation = "CUBICSPLINE" // The animation's interpolation is computed using a cubic spline with specified tangents. The number of output elements **MUST** equal three times the number of input elements. For each input element, the output stores three elements, an in-tangent, a spline vertex, and an out-tangent. There **MUST** be at least two keyframes when using this interpolation. )
type Artifact ¶ added in v0.21.0
type Artifact struct {
Scene PolyformScene
}
type Asset ¶
type Asset struct { Property Version string `json:"version"` // The glTF version in the form of `<major>.<minor>` that this asset targets. Generator string `json:"generator,omitempty"` // Tool that generated this glTF model. Useful for debugging. Copyright string `json:"copyright,omitempty"` // A copyright message suitable for display to credit the content creator. MinVersion string `json:"minVersion,omitempty"` // The minimum glTF version in the form of `<major>.<minor>` that this asset targets. This property **MUST NOT** be greater than the asset version. }
Metadata about the glTF asset. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/asset.schema.json
type Buffer ¶
type Buffer struct { ChildOfRootProperty ByteLength int `json:"byteLength"` // The length of the buffer in bytes. URI string `json:"uri,omitempty"` // The URI (or IRI) of the buffer. Relative paths are relative to the current glTF asset. Instead of referencing an external file, this field **MAY** contain a `data:`-URI. }
A buffer points to binary geometry, animation, or skins. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/buffer.schema.json
type BufferEmbeddingStrategy ¶ added in v0.9.0
type BufferEmbeddingStrategy int
const ( BufferEmbeddingStrategy_Base64Encode BufferEmbeddingStrategy = iota BufferEmbeddingStrategy_GLB )
type BufferView ¶
type BufferView struct { ChildOfRootProperty Buffer int `json:"buffer"` // The index of the buffer ByteOffset int `json:"byteOffset,omitempty"` // The offset into the buffer in bytes. ByteLength int `json:"byteLength"` // The length of the bufferView in bytes. ByteStride *int `json:"byteStride,omitempty"` // The stride, in bytes, between vertex attributes. When this is not defined, data is tightly packed. When two or more accessors use the same buffer view, this field **MUST** be defined. Target BufferViewTarget `json:"target,omitempty"` // The hint representing the intended GPU buffer type to use with this buffer view. }
A view into a buffer generally representing a subset of the buffer. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/bufferView.schema.json
type BufferViewTarget ¶
type BufferViewTarget int
const ( ARRAY_BUFFER BufferViewTarget = 34962 ELEMENT_ARRAY_BUFFER BufferViewTarget = 34963 )
type ChildOfRootProperty ¶
type ExtGpuInstancing ¶ added in v0.18.0
type Extensions ¶ added in v0.9.0
JSON object with extension-specific objects. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/extension.schema.json
type Extra ¶
Although `extras` **MAY** have any type, it is common for applications to store and access custom data as key/value pairs. Therefore, `extras` **SHOULD** be a JSON object rather than a primitive value for best portability. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/extras.schema.json
type Gltf ¶
type Gltf struct { Property ExtensionsUsed []string `json:"extensionsUsed,omitempty"` // Names of glTF extensions used in this asset. ExtensionsRequired []string `json:"extensionsRequired,omitempty"` // Names of glTF extensions required to properly load this asset. Accessors []Accessor `json:"accessors,omitempty"` // An array of accessors. An accessor is a typed view into a bufferView. Animations []Animation `json:"animations,omitempty"` // An array of keyframe animations. Asset Asset `json:"asset"` // Metadata about the glTF asset. Buffers []Buffer `json:"buffers,omitempty"` // An array of buffers. A buffer points to binary geometry, animation, or skins. BufferViews []BufferView `json:"bufferViews,omitempty"` // An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer Cameras []Camera `json:"cameras,omitempty"` // An array of cameras. A camera defines a projection matrix. Images []Image `json:"images,omitempty"` // An array of images. An image defines data used to create a texture. Materials []Material `json:"materials,omitempty"` // An array of materials. A material defines the appearance of a primitive. Meshes []Mesh `json:"meshes,omitempty"` // An array of meshes. A mesh is a set of primitives to be rendered Nodes []Node `json:"nodes,omitempty"` // An array of nodes. Samplers []Sampler `json:"samplers,omitempty"` // An array of samplers. A sampler contains properties for texture filtering and wrapping modes. Scene int `json:"scene,omitempty"` // The index of the default scene. This property **MUST NOT** be defined, when `scenes` is undefined. Scenes []Scene `json:"scenes,omitempty"` // An array of scenes. Skins []Skin `json:"skins,omitempty"` // An array of skins. A skin is defined by joints and matrices. Textures []Texture `json:"textures,omitempty"` // An array of textures }
The root object for a glTF asset. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/glTF.schema.json
type GltfArtifact ¶ added in v0.21.0
type GltfArtifact = nodes.Struct[artifact.Artifact, GltfArtifactData]
type GltfArtifactData ¶ added in v0.21.0
type GltfArtifactData struct {
Models []nodes.NodeOutput[PolyformModel]
}
type GltfMaterialAnisotropyExtensionNode ¶ added in v0.21.0
type GltfMaterialAnisotropyExtensionNode = nodes.Struct[PolyformAnisotropy, GltfMaterialAnisotropyExtensionNodeData]
type GltfMaterialAnisotropyExtensionNodeData ¶ added in v0.21.0
type GltfMaterialAnisotropyExtensionNodeData struct { AnisotropyStrength nodes.NodeOutput[float64] AnisotropyRotation nodes.NodeOutput[float64] }
func (GltfMaterialAnisotropyExtensionNodeData) Description ¶ added in v0.21.0
func (gmvend GltfMaterialAnisotropyExtensionNodeData) Description() string
func (GltfMaterialAnisotropyExtensionNodeData) Process ¶ added in v0.21.0
func (gmvend GltfMaterialAnisotropyExtensionNodeData) Process() (PolyformAnisotropy, error)
type GltfMaterialClearcoatExtensionNode ¶ added in v0.21.0
type GltfMaterialClearcoatExtensionNode = nodes.Struct[PolyformClearcoat, GltfMaterialClearcoatExtensionNodeData]
type GltfMaterialClearcoatExtensionNodeData ¶ added in v0.21.0
type GltfMaterialClearcoatExtensionNodeData struct { ClearcoatFactor nodes.NodeOutput[float64] ClearcoatRoughnessFactor nodes.NodeOutput[float64] }
func (GltfMaterialClearcoatExtensionNodeData) Description ¶ added in v0.21.0
func (gmcend GltfMaterialClearcoatExtensionNodeData) Description() string
func (GltfMaterialClearcoatExtensionNodeData) Process ¶ added in v0.21.0
func (gmcend GltfMaterialClearcoatExtensionNodeData) Process() (PolyformClearcoat, error)
type GltfMaterialNode ¶ added in v0.21.0
type GltfMaterialNode = nodes.Struct[PolyformMaterial, GltfMaterialNodeData]
type GltfMaterialNodeData ¶ added in v0.21.0
type GltfMaterialNodeData struct { Color nodes.NodeOutput[coloring.WebColor] ColorTexture nodes.NodeOutput[string] MetallicFactor nodes.NodeOutput[float64] RoughnessFactor nodes.NodeOutput[float64] MetallicRoughnessTexture nodes.NodeOutput[string] EmissiveFactor nodes.NodeOutput[coloring.WebColor] // Extensions IndexOfRefraction nodes.NodeOutput[float64] Transmission nodes.NodeOutput[PolyformTransmission] Volume nodes.NodeOutput[PolyformVolume] Anisotropy nodes.NodeOutput[PolyformAnisotropy] Clearcoat nodes.NodeOutput[PolyformClearcoat] EmissiveStrength nodes.NodeOutput[float64] }
func (GltfMaterialNodeData) Description ¶ added in v0.21.0
func (gmnd GltfMaterialNodeData) Description() string
func (GltfMaterialNodeData) Process ¶ added in v0.21.0
func (gmnd GltfMaterialNodeData) Process() (PolyformMaterial, error)
type GltfMaterialTransmissionExtensionNode ¶ added in v0.21.0
type GltfMaterialTransmissionExtensionNode = nodes.Struct[PolyformTransmission, GltfMaterialTransmissionExtensionNodeData]
type GltfMaterialTransmissionExtensionNodeData ¶ added in v0.21.0
type GltfMaterialTransmissionExtensionNodeData struct { Factor nodes.NodeOutput[float64] Texture nodes.NodeOutput[PolyformTexture] }
func (GltfMaterialTransmissionExtensionNodeData) Description ¶ added in v0.21.0
func (gmvend GltfMaterialTransmissionExtensionNodeData) Description() string
func (GltfMaterialTransmissionExtensionNodeData) Process ¶ added in v0.21.0
func (gmvend GltfMaterialTransmissionExtensionNodeData) Process() (PolyformTransmission, error)
type GltfMaterialVolumeExtensionNode ¶ added in v0.21.0
type GltfMaterialVolumeExtensionNode = nodes.Struct[PolyformVolume, GltfMaterialVolumeExtensionNodeData]
type GltfMaterialVolumeExtensionNodeData ¶ added in v0.21.0
type GltfMaterialVolumeExtensionNodeData struct { ThicknessFactor nodes.NodeOutput[float64] AttenuationDistance nodes.NodeOutput[float64] AttenuationColor nodes.NodeOutput[coloring.WebColor] }
func (GltfMaterialVolumeExtensionNodeData) Description ¶ added in v0.21.0
func (gmvend GltfMaterialVolumeExtensionNodeData) Description() string
func (GltfMaterialVolumeExtensionNodeData) Process ¶ added in v0.21.0
func (gmvend GltfMaterialVolumeExtensionNodeData) Process() (PolyformVolume, error)
type GltfModel ¶ added in v0.21.0
type GltfModel = nodes.Struct[PolyformModel, GltfModelNodeData]
type GltfModelNodeData ¶ added in v0.21.0
type GltfModelNodeData struct { Mesh nodes.NodeOutput[modeling.Mesh] Material nodes.NodeOutput[PolyformMaterial] Translation nodes.NodeOutput[vector3.Float64] Rotation nodes.NodeOutput[quaternion.Quaternion] Scale nodes.NodeOutput[vector3.Float64] GpuInstances nodes.NodeOutput[[]trs.TRS] }
func (GltfModelNodeData) Process ¶ added in v0.21.0
func (gmnd GltfModelNodeData) Process() (PolyformModel, error)
type Image ¶
type Image struct { ChildOfRootProperty MimeType ImageMimeType `json:"mimeType,omitempty"` // The image's media type. This field **MUST** be defined when `bufferView` is defined. URI string `json:"uri,omitempty"` // The URI (or IRI) of the image. Relative paths are relative to the current glTF asset. Instead of referencing an external file, this field **MAY** contain a `data:`-URI. This field **MUST NOT** be defined when `bufferView` is defined. BufferView GltfId `json:"bufferView,omitempty"` // The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined. }
Image data used to create a texture. Image **MAY** be referenced by an URI (or IRI) or a buffer view index. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/image.schema.json
type ImageMimeType ¶
type ImageMimeType string
const ( ImageMimeType_JPEG ImageMimeType = "image/jpeg" ImageMimeType_PNG ImageMimeType = "image/png" )
type KHR_LightsPunctual ¶ added in v0.9.0
type KHR_LightsPunctual struct { Type KHR_LightsPunctualType Name *string Color color.Color Intensity *float64 Range *float64 Position vector3.Float64 }
func (KHR_LightsPunctual) ToExtension ¶ added in v0.9.0
func (khr_lp KHR_LightsPunctual) ToExtension() map[string]any
type KHR_LightsPunctualType ¶ added in v0.9.0
type KHR_LightsPunctualType string
const ( KHR_LightsPunctualType_Directional KHR_LightsPunctualType = "directional" KHR_LightsPunctualType_Point KHR_LightsPunctualType = "point" KHR_LightsPunctualType_Spot KHR_LightsPunctualType = "spot" )
type Material ¶
type Material struct { ChildOfRootProperty // A set of parameter values that are used to define the metallic-roughness material model from Physically Based Rendering (PBR) methodology. When undefined, all the default values of `pbrMetallicRoughness` **MUST** apply. PbrMetallicRoughness *PbrMetallicRoughness `json:"pbrMetallicRoughness,omitempty"` // The tangent space normal texture. The texture encodes RGB components with linear transfer function. Each texel represents the XYZ components of a normal vector in tangent space. The normal vectors use the convention +X is right and +Y is up. +Z points toward the viewer. If a fourth component (A) is present, it **MUST** be ignored. When undefined, the material does not have a tangent space normal texture. NormalTexture *NormalTexture `json:"normalTexture,omitempty"` // The occlusion texture. The occlusion values are linearly sampled from the R channel. Higher values indicate areas that receive full indirect lighting and lower values indicate no indirect lighting. If other channels are present (GBA), they **MUST** be ignored for occlusion calculations. When undefined, the material does not have an occlusion texture. OcclusionTexture *OcclusionTexture `json:"occlusionTexture,omitempty"` // The emissive texture. It controls the color and intensity of the light being emitted by the material. This texture contains RGB components encoded with the sRGB transfer function. If a fourth component (A) is present, it **MUST** be ignored. When undefined, the texture **MUST** be sampled as having `1.0` in RGB components. EmissiveTexture *TextureInfo `json:"emissiveTexture,omitempty"` // The factors for the emissive color of the material. This value defines linear multipliers for the sampled texels of the emissive texture. EmissiveFactor *[3]float64 `json:"emissiveFactor,omitempty"` // The material's alpha rendering mode enumeration specifying the interpretation of the alpha value of the base color." AlphaMode *MaterialAlphaMode `json:"alphaMode,omitempty"` // Specifies the cutoff threshold when in `MASK` alpha mode. If the alpha value is greater than or equal to this value then it is rendered as fully opaque, otherwise, it is rendered as fully transparent. A value greater than `1.0` will render the entire material as fully transparent. This value **MUST** be ignored for other alpha modes. When `alphaMode` is not defined, this value **MUST NOT** be defined. AlphaCutoff *float64 `json:"alphaCutoff,omitempty"` // Specifies whether the material is double sided. When this value is false, back-face culling is enabled. When this value is true, back-face culling is disabled and double-sided lighting is enabled. The back-face **MUST** have its normals reversed before the lighting equation is evaluated. DoubleSided *bool `json:"doubleSided,omitempty"` }
The material appearance of a primitive. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/material.schema.json
type MaterialAlphaMode ¶
type MaterialAlphaMode string
The alpha rendering mode of the material https://github.com/KhronosGroup/glTF/blob/0890b76c62cc762ce82d4010df9bfebb1634839b/specification/2.0/schema/material.schema.json#L43
const ( MaterialAlphaMode_OPAQUE MaterialAlphaMode = "OPAQUE" // The alpha value is ignored, and the rendered output is fully opaque. Default behaviour if alphaMode is not explicitly set. MaterialAlphaMode_MASK MaterialAlphaMode = "MASK" // The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified `alphaCutoff` value; the exact appearance of the edges **MAY** be subject to implementation-specific techniques such as \"`Alpha-to-Coverage`\". MaterialAlphaMode_BLEND MaterialAlphaMode = "BLEND" // The alpha value is used to composite the source and destination areas. The rendered output is combined with the background using the normal painting operation (i.e. the Porter and Duff over operator). )
type MaterialExtension ¶ added in v0.9.0
type Mesh ¶
type Mesh struct { ChildOfRootProperty Primitives []Primitive `json:"primitives"` Weights []float64 `json:"weights,omitempty"` }
A set of primitives to be rendered. Its global transform is defined by a node that references it. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/mesh.schema.json
type Node ¶
type Node struct { ChildOfRootProperty Camera *GltfId `json:"camera,omitempty"` // The index of the camera referenced by this node. Children []GltfId `json:"children,omitempty"` // The indices of this node's children. Skin *GltfId `json:"skin,omitempty"` // The index of the skin referenced by this node. When a skin is referenced by a node within a scene, all joints used by the skin **MUST** belong to the same scene. When defined, `mesh` **MUST** also be defined. Matrix *[16]float64 `json:"matrix,omitempty"` // A floating-point 4x4 transformation matrix stored in column-major order. Mesh *GltfId `json:"mesh,omitempty"` // The index of the mesh in this node. Rotation *[4]float64 `json:"rotation,omitempty"` // The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar. Scale *[3]float64 `json:"scale,omitempty"` // The node's non-uniform scale, given as the scaling factors along the x, y, and z axes. Translation *[3]float64 `json:"translation,omitempty"` // The node's translation along the x, y, and z axes. Weights []float64 `json:"weights,omitempty"` // The weights of the instantiated morph target. The number of array elements **MUST** match the number of morph targets of the referenced mesh. When defined, `mesh` **MUST** also be defined. Name string `json:"name,omitempty"` }
A node in the node hierarchy. When the node contains `skin`, all `mesh.primitives` **MUST** contain `JOINTS_0` and `WEIGHTS_0` attributes. A node **MAY** have either a `matrix` or any combination of `translation`/`rotation`/`scale` (TRS) properties. TRS properties are converted to matrices and postmultiplied in the `T * R * S` order to compose the transformation matrix; first the scale is applied to the vertices, then the rotation, and then the translation. If none are provided, the transform is the identity. When a node is targeted for animation (referenced by an animation.channel.target), `matrix` **MUST NOT** be present. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/node.schema.json
type NormalTexture ¶
type NormalTexture struct { TextureInfo Scale *float64 `json:"scale,omitempty"` // The scalar parameter applied to each normal vector of the texture. This value scales the normal vector in X and Y directions using the formula: `scaledNormal = normalize((<sampled normal texture value> * 2.0 - 1.0) * vec3(<normal scale>, <normal scale>, 1.0))`. }
type OcclusionTexture ¶
type OcclusionTexture struct { TextureInfo Strength *float64 `json:"strength,omitempty"` // A scalar parameter controlling the amount of occlusion applied. A value of `0.0` means no occlusion. A value of `1.0` means full occlusion. This value affects the final occlusion value as: `1.0 + strength * (<sampled occlusion texture value> - 1.0)`. }
type PbrMetallicRoughness ¶
type PbrMetallicRoughness struct { Property BaseColorFactor *[4]float64 `json:"baseColorFactor,omitempty"` // The factors for the base color of the material. This value defines linear multipliers for the sampled texels of the base color texture. BaseColorTexture *TextureInfo `json:"baseColorTexture,omitempty"` // The base color texture. The first three components (RGB) **MUST** be encoded with the sRGB transfer function. They specify the base color of the material. If the fourth component (A) is present, it represents the linear alpha coverage of the material. Otherwise, the alpha coverage is equal to `1.0`. The `material.alphaMode` property specifies how alpha is interpreted. The stored texels **MUST NOT** be premultiplied. When undefined, the texture **MUST** be sampled as having `1.0` in all components. MetallicFactor *float64 `json:"metallicFactor,omitempty"` // The factor for the metalness of the material. This value defines a linear multiplier for the sampled metalness values of the metallic-roughness texture. RoughnessFactor *float64 `json:"roughnessFactor,omitempty"` // The factor for the roughness of the material. This value defines a linear multiplier for the sampled roughness values of the metallic-roughness texture. MetallicRoughnessTexture *TextureInfo `json:"metallicRoughnessTexture,omitempty"` // The metallic-roughness texture. The metalness values are sampled from the B channel. The roughness values are sampled from the G channel. These values **MUST** be encoded with a linear transfer function. If other channels are present (R or A), they **MUST** be ignored for metallic-roughness calculations. When undefined, the texture **MUST** be sampled as having `1.0` in G and B components. }
A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/material.pbrMetallicRoughness.schema.json
type PolyformAnisotropy ¶ added in v0.17.0
type PolyformAnisotropy struct { // The anisotropy strength. When the anisotropy texture is present, this // value is multiplied by the texture's blue channel. AnisotropyStrength float64 // The rotation of the anisotropy in tangent, bitangent space, measured in // radians counter-clockwise from the tangent. When the anisotropy texture // is present, this value provides additional rotation to the vectors in // the texture. AnisotropyRotation float64 // The anisotropy texture. Red and green channels represent the anisotropy // direction in $[-1, 1]$ tangent, bitangent space, to be rotated by the // anisotropy rotation. The blue channel contains strength as $[0, 1]$ to // be multiplied by the anisotropy strength. AnisotropyTexture *PolyformTexture }
glTF extension that defines anisotropy
func (PolyformAnisotropy) ExtensionID ¶ added in v0.17.0
func (pa PolyformAnisotropy) ExtensionID() string
func (PolyformAnisotropy) ToMaterialExtensionData ¶ added in v0.18.0
func (pa PolyformAnisotropy) ToMaterialExtensionData(w *Writer) map[string]any
type PolyformClearcoat ¶ added in v0.17.0
type PolyformClearcoat struct { ClearcoatFactor float64 ClearcoatTexture *PolyformTexture ClearcoatRoughnessFactor float64 ClearcoatRoughnessTexture *PolyformTexture ClearcoatNormalTexture *PolyformNormal }
func (PolyformClearcoat) ExtensionID ¶ added in v0.17.0
func (pmc PolyformClearcoat) ExtensionID() string
func (PolyformClearcoat) ToMaterialExtensionData ¶ added in v0.18.0
func (pmc PolyformClearcoat) ToMaterialExtensionData(w *Writer) map[string]any
type PolyformDispersion ¶ added in v0.17.0
type PolyformDispersion struct { // This parameter defines dispersion in terms of the 20/Abbe number // formulation. Dispersion float64 }
glTF extension that defines the strength of dispersion.
func (PolyformDispersion) ExtensionID ¶ added in v0.17.0
func (pd PolyformDispersion) ExtensionID() string
func (PolyformDispersion) ToMaterialExtensionData ¶ added in v0.18.0
func (pd PolyformDispersion) ToMaterialExtensionData(w *Writer) map[string]any
type PolyformEmissiveStrength ¶ added in v0.17.0
type PolyformEmissiveStrength struct { // The strength adjustment to be multiplied with the material's emissive value. EmissiveStrength *float64 }
glTF extension that adjusts the strength of emissive material properties.
func (PolyformEmissiveStrength) ExtensionID ¶ added in v0.17.0
func (pmes PolyformEmissiveStrength) ExtensionID() string
func (PolyformEmissiveStrength) ToMaterialExtensionData ¶ added in v0.18.0
func (pmes PolyformEmissiveStrength) ToMaterialExtensionData(w *Writer) map[string]any
type PolyformIndexOfRefraction ¶ added in v0.9.0
type PolyformIndexOfRefraction struct { // The index of refraction // Air 1.0 // Water 1.33 // Eyes 1.38 // Window Glass 1.52 // Sapphire 1.76 // Diamond 2.42 IOR *float64 }
https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_ior/README.md
func (PolyformIndexOfRefraction) ExtensionID ¶ added in v0.9.0
func (sg PolyformIndexOfRefraction) ExtensionID() string
func (PolyformIndexOfRefraction) ToMaterialExtensionData ¶ added in v0.18.0
func (sg PolyformIndexOfRefraction) ToMaterialExtensionData(w *Writer) map[string]any
type PolyformIridescence ¶ added in v0.17.0
type PolyformIridescence struct { // The iridescence intensity factor IridescenceFactor float64 // The iridescence intensity texture. The values are sampled from the R // channel. These values are linear. If a texture is not given, a value // of `1.0` **MUST** be assumed. If other channels are present (GBA), they // are ignored for iridescence intensity calculations IridescenceTexture *PolyformTexture // The index of refraction of the dielectric thin-film layer. IridescenceIor *float64 // The minimum thickness of the thin-film layer given in nanometers. The // value **MUST** be less than or equal to the value of // `iridescenceThicknessMaximum`. IridescenceThicknessMinimum *float64 // The maximum thickness of the thin-film layer given in nanometers. The // value **MUST** be greater than or equal to the value of // `iridescenceThicknessMinimum`. IridescenceThicknessMaximum *float64 // The thickness texture of the thin-film layer to linearly interpolate // between the minimum and maximum thickness given by the corresponding // properties, where a sampled value of `0.0` represents the minimum // thickness and a sampled value of `1.0` represents the maximum thickness. // The values are sampled from the G channel. These values are linear. If a // texture is not given, the maximum thickness **MUST** be assumed. If // other channels are present (RBA), they are ignored for thickness // calculations. IridescenceThicknessTexture *PolyformTexture }
glTF extension that defines an iridescence effect
func (PolyformIridescence) ExtensionID ¶ added in v0.17.0
func (pmi PolyformIridescence) ExtensionID() string
func (PolyformIridescence) ToMaterialExtensionData ¶ added in v0.18.0
func (pmi PolyformIridescence) ToMaterialExtensionData(w *Writer) map[string]any
type PolyformMaterial ¶ added in v0.9.0
type PolyformMaterial struct { Name string Extras map[string]any AlphaMode *MaterialAlphaMode AlphaCutoff *float64 PbrMetallicRoughness *PolyformPbrMetallicRoughness Extensions []MaterialExtension NormalTexture *PolyformNormal OcclusionTexture *PolyformOcclusion EmissiveFactor color.Color }
type PolyformModel ¶ added in v0.9.0
type PolyformModel struct { Name string Mesh *modeling.Mesh Material *PolyformMaterial Translation *vector3.Float64 Scale *vector3.Float64 Rotation *quaternion.Quaternion // Utilizes the EXT_mesh_gpu_instancing extension to duplicate the model // without increasing the mesh data footprint on the GPU GpuInstances []trs.TRS Skeleton *animation.Skeleton Animations []animation.Sequence }
PolyformModel is a utility structure for reading/writing to GLTF format within polyform, and not an actual concept found within the GLTF format.
type PolyformNormal ¶ added in v0.10.0
type PolyformNormal struct { *PolyformTexture Scale *float64 }
type PolyformOcclusion ¶ added in v0.19.0
type PolyformOcclusion struct { *PolyformTexture Strength *float64 }
type PolyformPbrMetallicRoughness ¶ added in v0.9.0
type PolyformPbrMetallicRoughness struct { BaseColorFactor color.Color BaseColorTexture *PolyformTexture MetallicFactor *float64 RoughnessFactor *float64 MetallicRoughnessTexture *PolyformTexture }
type PolyformPbrSpecularGlossiness ¶ added in v0.9.0
type PolyformPbrSpecularGlossiness struct { // The RGBA components of the reflected diffuse color of the material. // Metals have a diffuse value of [0.0, 0.0, 0.0]. The fourth component (A) // is the opacity of the material. The values are linear. DiffuseFactor color.Color // The diffuse texture. This texture contains RGB(A) components of the // reflected diffuse color of the material in sRGB color space. If the // fourth component (A) is present, it represents the alpha coverage of the // material. Otherwise, an alpha of 1.0 is assumed. The alphaMode property // specifies how alpha is interpreted. The stored texels must not be // premultiplied. DiffuseTexture *PolyformTexture // The specular RGB color of the material. This value is linear. SpecularFactor color.Color // The glossiness or smoothness of the material. A value of 1.0 means the // material has full glossiness or is perfectly smooth. A value of 0.0 // means the material has no glossiness or is perfectly rough. This value // is linear. // Default value is 1.0 GlossinessFactor *float64 // The specular-glossiness texture is a RGBA texture, containing the // specular color (RGB) in sRGB space and the glossiness value (A) in // linear space. SpecularGlossinessTexture *PolyformTexture }
https://kcoley.github.io/glTF/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/
func (PolyformPbrSpecularGlossiness) ExtensionID ¶ added in v0.9.0
func (ppsg PolyformPbrSpecularGlossiness) ExtensionID() string
func (PolyformPbrSpecularGlossiness) ToMaterialExtensionData ¶ added in v0.18.0
func (sg PolyformPbrSpecularGlossiness) ToMaterialExtensionData(w *Writer) map[string]any
type PolyformScene ¶ added in v0.9.0
type PolyformScene struct { Models []PolyformModel Lights []KHR_LightsPunctual }
type PolyformSheen ¶ added in v0.17.0
type PolyformSheen struct { // Color of the sheen layer (in linear space). SheenColorFactor color.Color // The sheen color (RGB) texture. Stored in channel RGB, the sheen color is // in sRGB transfer function. SheenColorTexture *PolyformTexture // The sheen layer roughness of the material. SheenRoughnessFactor float64 // The sheen roughness (Alpha) texture. Stored in alpha channel, the // roughness value is in linear space. SheenRoughnessTexture *PolyformTexture }
glTF extension that defines the sheen material model.
func (PolyformSheen) ExtensionID ¶ added in v0.17.0
func (ps PolyformSheen) ExtensionID() string
func (PolyformSheen) ToMaterialExtensionData ¶ added in v0.18.0
func (ps PolyformSheen) ToMaterialExtensionData(w *Writer) map[string]any
type PolyformSpecular ¶ added in v0.9.0
type PolyformSpecular struct { // The strength of the specular reflection. // Default: 1.0 Factor *float64 // A texture that defines the strength of the specular reflection, stored // in the alpha (A) channel. This will be multiplied by specularFactor. Texture *PolyformTexture // The F0 color of the specular reflection (linear RGB). ColorFactor color.Color // A texture that defines the F0 color of the specular reflection, stored // in the RGB channels and encoded in sRGB. This texture will be multiplied // by specularColorFactor. ColorTexture *PolyformTexture }
func (PolyformSpecular) ExtensionID ¶ added in v0.9.0
func (ps PolyformSpecular) ExtensionID() string
func (PolyformSpecular) ToMaterialExtensionData ¶ added in v0.18.0
func (ps PolyformSpecular) ToMaterialExtensionData(w *Writer) map[string]any
type PolyformTexture ¶ added in v0.9.0
type PolyformTexture struct { URI string Sampler *Sampler Extensions []TextureExtension }
type PolyformTextureTransform ¶ added in v0.18.0
type PolyformTextureTransform struct { // Whether to make this extension required for the given model. // If set - extension will be added to `extensionsRequired` list at the GLTF file top level. Required bool Offset *vector2.Float64 // The offset of the UV coordinate origin as a factor of the texture dimensions. Rotation *float64 // Rotate the UVs by this many radians counter-clockwise around the origin. This is equivalent to a similar rotation of the image clockwise. Scale *vector2.Float64 // The scale factor applied to the components of the UV coordinates. TexCoord *int // Overrides the textureInfo texCoord value if supplied, and if this extension is supported. }
PolyformTextureTransform is a glTF extension that defines texture transformations.
func (PolyformTextureTransform) ExtensionID ¶ added in v0.18.0
func (ptt PolyformTextureTransform) ExtensionID() string
func (PolyformTextureTransform) IsInfo ¶ added in v0.18.0
func (ptt PolyformTextureTransform) IsInfo() bool
func (PolyformTextureTransform) IsRequired ¶ added in v0.18.0
func (ptt PolyformTextureTransform) IsRequired() bool
func (PolyformTextureTransform) ToTextureExtensionData ¶ added in v0.18.0
func (ptt PolyformTextureTransform) ToTextureExtensionData(w *Writer) map[string]any
type PolyformTransmission ¶ added in v0.9.0
type PolyformTransmission struct { // The base percentage of light that is transmitted through the surface. // Default: 0.0 Factor float64 // A texture that defines the transmission percentage of the surface, // stored in the R channel. This will be multiplied by transmissionFactor. Texture *PolyformTexture }
func (PolyformTransmission) ExtensionID ¶ added in v0.9.0
func (tr PolyformTransmission) ExtensionID() string
func (PolyformTransmission) ToMaterialExtensionData ¶ added in v0.18.0
func (tr PolyformTransmission) ToMaterialExtensionData(w *Writer) map[string]any
type PolyformUnlit ¶ added in v0.17.0
type PolyformUnlit struct { }
func (PolyformUnlit) ExtensionID ¶ added in v0.17.0
func (ps PolyformUnlit) ExtensionID() string
func (PolyformUnlit) ToMaterialExtensionData ¶ added in v0.18.0
func (ps PolyformUnlit) ToMaterialExtensionData(w *Writer) map[string]any
type PolyformVolume ¶ added in v0.9.0
type PolyformVolume struct { // The thickness of the volume beneath the surface. The value is given in // the coordinate space of the mesh. If the value is 0 the material is // thin-walled. Otherwise the material is a volume boundary. The // doubleSided property has no effect on volume boundaries. Range is // [0, +inf). // Default: 0 ThicknessFactor float64 // A texture that defines the thickness, stored in the G channel. This will // be multiplied by thicknessFactor. Range is [0, 1]. ThicknessTexture *PolyformTexture // Density of the medium given as the average distance that light travels // in the medium before interacting with a particle. The value is given in // world space. Range is (0, +inf). // Default: +Infinity AttenuationDistance *float64 // The color that white light turns into due to absorption when reaching // the attenuation distance. AttenuationColor color.Color }
https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_volume/README.md
func (PolyformVolume) ExtensionID ¶ added in v0.9.0
func (v PolyformVolume) ExtensionID() string
func (PolyformVolume) ToMaterialExtensionData ¶ added in v0.18.0
func (v PolyformVolume) ToMaterialExtensionData(w *Writer) map[string]any
type Primitive ¶
type Primitive struct { Property Attributes map[string]GltfId `json:"attributes"` // A plain JSON object, where each key corresponds to a mesh attribute semantic and each value is the index of the accessor containing attribute's data. Indices *GltfId `json:"indices,omitempty"` // The index of the accessor that contains the vertex indices. When this is undefined, the primitive defines non-indexed geometry. When defined, the accessor **MUST** have `SCALAR` type and an unsigned integer component type. Material *GltfId `json:"material,omitempty"` // The index of the material to apply to this primitive when rendering. Targets []GltfId `json:"targets,omitempty"` // A plain JSON object specifying attributes displacements in a morph target, where each key corresponds to one of the three supported attribute semantic (`POSITION`, `NORMAL`, or `TANGENT`) and each value is the index of the accessor containing the attribute displacements' data. Mode *PrimitiveMode `json:"mode,omitempty"` // The topology type of primitives to render. }
Geometry to be rendered with the given material. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/mesh.primitive.schema.json
type PrimitiveMode ¶
type PrimitiveMode int
const ( PrimitiveMode_POINTS PrimitiveMode = 0 PrimitiveMode_LINES PrimitiveMode = 1 PrimitiveMode_LINE_LOOP PrimitiveMode = 2 PrimitiveMode_LINE_STRIP PrimitiveMode = 3 PrimitiveMode_TRIANGLES PrimitiveMode = 4 PrimitiveMode_TRIANGLE_STRIP PrimitiveMode = 5 PrimitiveMode_TRIANGLE_FAN PrimitiveMode = 6 )
type Property ¶
type Property struct { Extensions Extensions `json:"extensions,omitempty"` Extras Extra `json:"extras,omitempty"` }
https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/glTFProperty.schema.json
type Sampler ¶
type Sampler struct { ChildOfRootProperty MagFilter SamplerMagFilter `json:"magFilter,omitempty"` // Magnification filter. MinFilter SamplerMinFilter `json:"minFilter,omitempty"` // Minification filter WrapS SamplerWrap `json:"wrapS,omitempty"` // S (U) wrapping mode. All valid values correspond to WebGL enums. WrapT SamplerWrap `json:"wrapT,omitempty"` // T (V) wrapping mode. }
Texture sampler properties for filtering and wrapping modes. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/sampler.schema.json
type SamplerMagFilter ¶
type SamplerMagFilter int
const ( SamplerMagFilter_NEAREST SamplerMagFilter = 9728 SamplerMagFilter_LINEAR SamplerMagFilter = 9729 )
type SamplerMinFilter ¶
type SamplerMinFilter int
const ( SamplerMinFilter_NEAREST SamplerMinFilter = 9728 SamplerMinFilter_LINEAR SamplerMinFilter = 9729 SamplerMinFilter_NEAREST_MIPMAP_NEAREST SamplerMinFilter = 9984 SamplerMinFilter_LINEAR_MIPMAP_NEAREST SamplerMinFilter = 9985 SamplerMinFilter_NEAREST_MIPMAP_LINEAR SamplerMinFilter = 9986 SamplerMinFilter_LINEAR_MIPMAP_LINEAR SamplerMinFilter = 9987 )
type SamplerWrap ¶
type SamplerWrap int
const ( SamplerWrap_CLAMP_TO_EDGE SamplerWrap = 33071 SamplerWrap_MIRRORED_REPEAT SamplerWrap = 33648 SamplerWrap_REPEAT SamplerWrap = 10497 )
type Scene ¶
type Scene struct { ChildOfRootProperty Nodes []GltfId `json:"nodes,omitempty"` // The indices of each root node. }
The root nodes of a scene. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/scene.schema.json
type Skin ¶
type Skin struct { ChildOfRootProperty InverseBindMatrices GltfId `json:"inverseBindMatrices,omitempty"` // The index of the accessor containing the floating-point 4x4 inverse-bind matrices. Its `accessor.count` property **MUST** be greater than or equal to the number of elements of the `joints` array. When undefined, each matrix is a 4x4 identity matrix. Skeleton GltfId `json:"skeleton,omitempty"` // The index of the node used as a skeleton root. The node **MUST** be the closest common root of the joints hierarchy or a direct or indirect parent node of the closest common root. Joints []GltfId `json:"joints"` // Indices of skeleton nodes, used as joints in this skin. }
Joints and matrices defining a skin. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/skin.schema.json
type Texture ¶
type Texture struct { ChildOfRootProperty Sampler *GltfId `json:"sampler,omitempty"` Source *GltfId `json:"source,omitempty"` Extensions Extensions `json:"extensions,omitempty"` }
"A texture and its sampler. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/texture.schema.json
type TextureExtension ¶ added in v0.18.0
type TextureInfo ¶
type TextureInfo struct { Property Index GltfId `json:"index"` // The index of the texture. TexCoord int `json:"texCoord,omitempty"` // "This integer value is used to construct a string in the format `TEXCOORD_<set index>` which is a reference to a key in `mesh.primitives.attributes` (e.g. a value of `0` corresponds to `TEXCOORD_0`). A mesh primitive **MUST** have the corresponding texture coordinate attributes for the material to be applicable to it. Extensions Extensions `json:"extensions,omitempty"` }
Reference to a texture https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/textureInfo.schema.json
type TextureNode ¶ added in v0.21.0
type TextureNode = nodes.Struct[PolyformTexture, TextureNodeData]
type TextureNodeData ¶ added in v0.21.0
type TextureNodeData struct {
URI nodes.NodeOutput[string]
}
func (TextureNodeData) Description ¶ added in v0.21.0
func (gmnd TextureNodeData) Description() string
func (TextureNodeData) Process ¶ added in v0.21.0
func (tnd TextureNodeData) Process() (PolyformTexture, error)
type Writer ¶ added in v0.9.0
type Writer struct {
// contains filtered or unexported fields
}
func NewWriterFromScene ¶ added in v0.18.0
func NewWriterFromScene(scene PolyformScene) (*Writer, error)
func (*Writer) AddAnimations ¶ added in v0.9.0
func (*Writer) AddLight ¶ added in v0.9.0
func (w *Writer) AddLight(light KHR_LightsPunctual)
func (*Writer) AddMaterial ¶ added in v0.9.0
func (w *Writer) AddMaterial(mat *PolyformMaterial) (*int, error)
func (*Writer) AddMesh ¶ added in v0.9.0
func (w *Writer) AddMesh(model PolyformModel) (_ int, err error)
func (*Writer) AddScene ¶ added in v0.18.0
func (w *Writer) AddScene(scene PolyformScene) error
func (*Writer) AddTexture ¶ added in v0.9.0
func (w *Writer) AddTexture(polyTex *PolyformTexture) *TextureInfo
func (Writer) ToGLTF ¶ added in v0.9.0
func (w Writer) ToGLTF(embeddingStrategy BufferEmbeddingStrategy) Gltf
func (*Writer) WriteIndices ¶ added in v0.9.0
func (w *Writer) WriteIndices(indices *iter.ArrayIterator[int], attributeSize int)
func (*Writer) WriteVector2 ¶ added in v0.9.0
func (w *Writer) WriteVector2(accessorComponentType AccessorComponentType, data *iter.ArrayIterator[vector2.Float64])
func (Writer) WriteVector2AsByte ¶ added in v0.9.0
func (Writer) WriteVector2AsFloat32 ¶ added in v0.9.0
func (*Writer) WriteVector3 ¶ added in v0.9.0
func (w *Writer) WriteVector3(accessorComponentType AccessorComponentType, data *iter.ArrayIterator[vector3.Float64])
func (Writer) WriteVector3AsByte ¶ added in v0.9.0
func (Writer) WriteVector3AsFloat32 ¶ added in v0.9.0
func (*Writer) WriteVector4 ¶ added in v0.9.0
func (w *Writer) WriteVector4(accessorComponentType AccessorComponentType, data *iter.ArrayIterator[vector4.Float64])