dsl

package
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2025 License: MIT Imports: 26 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildModelResource

func BuildModelResource(gltfDoc *gltf.Document, forceCollision bool) (*mdl.Model, error)

func CreateDigest

func CreateDigest(name string, params ...any) ([]byte, error)

CreateDigest calculates the digest of the provided operation and supplementing parameters.

func Run

func Run(registry *asset.Registry, modelNames []string) error

Run runs the DSL algorithm on the provided registry. If modelNames is not empty, only the models with the provided names will be processed.

func StringDigest

func StringDigest(digestable Digestable) (string, error)

StringDigest calculates the digest of the provided digestable and returns it as a hex-encoded string.

Types

type ApplyFunc

type ApplyFunc func(target any) error

ApplyFunc is a function that applies an operation to a target.

type DigestFunc

type DigestFunc func() ([]byte, error)

DigestFunc is a function that calculates a digest.

type Digestable

type Digestable interface {

	// Digest calculates the digest of the object.
	Digest() ([]byte, error)
}

Digestable represents an object that can be digested.

type GetFunc

type GetFunc[T any] func() (T, error)

GetFunc is a function that returns a value of a specific type.

type Operation

type Operation interface {
	Digestable
	Apply(target any) error
}

Operation is an operation that can be applied to a target.

func AddBlob added in v0.22.0

func AddBlob(blobProvider Provider[*mdl.Blob]) Operation

AddBlob creates an operation that adds a blob to the target model.

func AddForwardPass

func AddForwardPass(passProvider Provider[*mdl.MaterialPass]) Operation

AddForwardPass creates an operation that adds a new forward pass to the target.

func AddFragment

func AddFragment(fragmentProvider Provider[*mdl.Fragment]) Operation

AddFragment adds the specified fragment to the target geometry.

func AddGeometryPass

func AddGeometryPass(passProvider Provider[*mdl.MaterialPass]) Operation

AddGeometryPass creates an operation that adds a new geometry pass to the target.

func AddNode

func AddNode(nodeProvider Provider[*mdl.Node]) Operation

AddNode adds the specified node to the target node container.

func AppendModel

func AppendModel(modelProvider Provider[*mdl.Model]) Operation

AppendModel creates an operation that appends the contents of the provided model to the target model.

func BindProperty

func BindProperty[T any](name string, valueProvider Provider[T]) Operation

BindProperty sets the specified property on the target property holder.

func BindSampler

func BindSampler(name string, samplerProvider Provider[*mdl.Sampler]) Operation

BindSampler sets the sampler of the target.

func Clear

func Clear() Operation

Clear creates an operation that clears all data from the target.

func EditMaterial

func EditMaterial(name string, opts ...Operation) Operation

EditMaterial creates an operation that edits the material with the provided name in the target node holder.

func ForceCollision

func ForceCollision() Operation

ForceCollision creates an operation that forces the target model to have a collision mesh.

func FuncOperation

func FuncOperation(apply ApplyFunc, digest DigestFunc) Operation

FuncOperation creates an operation from an apply and a digest functions.

func SetCastShadow added in v0.20.0

func SetCastShadow(castShadowProvider Provider[bool]) Operation

SetCastShadow configures the cast shadow of the target.

func SetCulling added in v0.22.0

func SetCulling(modeProvider Provider[mdl.CullMode]) Operation

SetCulling creates an operation that sets the culling mode of the target.

func SetEmitAngleInner

func SetEmitAngleInner(angleProvider Provider[dprec.Angle]) Operation

SetEmitAngleInner configures the inner emit angle of the target.

func SetEmitAngleOuter

func SetEmitAngleOuter(angleProvider Provider[dprec.Angle]) Operation

SetEmitAngleOuter configures the outer emit angle of the target.

func SetEmitColor

func SetEmitColor(colorProvider Provider[dprec.Vec4]) Operation

SetEmitColor configures the emit color of the target.

func SetEmitDistance

func SetEmitDistance(distanceProvider Provider[float64]) Operation

SetEmitDistance configures the emit distance of the target.

func SetFilterMode

func SetFilterMode(filterModeProvider Provider[mdl.FilterMode]) Operation

SetFilterMode sets the filter mode of the target.

func SetFormat

func SetFormat(formatProvider Provider[mdl.TextureFormat]) Operation

SetFormat configures the format of the target.

func SetGenerateMipmaps

func SetGenerateMipmaps(generateMipmapsProvider Provider[bool]) Operation

SetGenerateMipmaps configures the generate mipmaps flag of the target.

func SetHeight

func SetHeight(heightProvider Provider[float64]) Operation

SetHeight sets the width of the target.

func SetLength

func SetLength(lengthProvider Provider[float64]) Operation

SetLength sets the width of the target.

func SetMipmapping

func SetMipmapping(mipmappingProvider Provider[bool]) Operation

SetMipmapping sets the mipmapping of the target.

func SetReflectionTexture

func SetReflectionTexture(textureProvider Provider[*mdl.Texture]) Operation

SetReflectionTexture configures the reflection texture of the target.

func SetRefractionTexture

func SetRefractionTexture(textureProvider Provider[*mdl.Texture]) Operation

SetRefractionTexture configures the refraction texture of the target.

func SetRotation

func SetRotation(rotationProvider Provider[dprec.Quat]) Operation

SetRotation sets the rotation of the target.

func SetSampleCount

func SetSampleCount(countProvider Provider[int]) Operation

SetSampleCount configures the sample count of the target.

func SetScale

func SetScale(scaleProvider Provider[dprec.Vec3]) Operation

SetScale sets the scale of the target.

func SetShader

func SetShader(shaderProvider Provider[*mdl.Shader]) Operation

SetShader creates an operation that sets the shader of the target.

func SetSource

func SetSource[T any](nodeSourceProvider Provider[T]) Operation

SetSource sets the transformation source of the node.

func SetTarget

func SetTarget[T any](nodeTargetProvider Provider[T]) Operation

SetTarget sets the transformation target of the node.

func SetTranslation

func SetTranslation(translationProvider Provider[dprec.Vec3]) Operation

SetTranslation sets the translation of the target.

func SetVertexFormat

func SetVertexFormat(format mdl.VertexFormat) Operation

SetVertexFormat sets the vertex format of the target geometry.

func SetWidth

func SetWidth(widthProvider Provider[float64]) Operation

SetWidth sets the width of the target.

func SetWrapMode

func SetWrapMode(wrapModeProvider Provider[mdl.WrapMode]) Operation

SetWrapMode sets the wrap mode of the target.

type Provider

type Provider[T any] interface {
	Digestable
	Get() (T, error)
}

Provider is an interface that provides a value of a specific type.

func Const

func Const[T any](value T) Provider[T]

StaticProvider creates a provider that always returns the same value.

func Create2DTexture

func Create2DTexture(imageProvider Provider[*mdl.Image], opts ...Operation) Provider[*mdl.Texture]

Create2DTexture creates a new 2D texture with the specified format and source image.

func CreateAmbientLight

func CreateAmbientLight(opts ...Operation) Provider[*mdl.AmbientLight]

CreateAmbientLight creates a new ambient light.

func CreateColorSkyMaterial

func CreateColorSkyMaterial(colorProvider Provider[dprec.Vec4]) Provider[*mdl.Material]

CreateColorSkyMaterial creates a new color sky material.

func CreateCubeMipmapTexture added in v0.21.0

func CreateCubeMipmapTexture(cubeImagesProvider Provider[[]*mdl.CubeImage], opts ...Operation) Provider[*mdl.Texture]

CreateCubeMipmapTexture creates a new cube texture with the specified format and source mipmap images.

func CreateCubeTexture

func CreateCubeTexture(cubeImageProvider Provider[*mdl.CubeImage], opts ...Operation) Provider[*mdl.Texture]

CreateCubeTexture creates a new cube texture with the specified format and source image.

func CreateDirectionalLight

func CreateDirectionalLight(opts ...Operation) Provider[*mdl.DirectionalLight]

CreateDirectionalLight creates a new directional light.

func CreateFragment

func CreateFragment(name string, topology mdl.Topology, opts ...Operation) Provider[*mdl.Fragment]

CreateFragment creates a new geometry fragment.

func CreateGeometry

func CreateGeometry(name string, opts ...Operation) Provider[*mdl.Geometry]

CreateGeometry creates a new geometry.

func CreateMaterialPass

func CreateMaterialPass(opts ...Operation) Provider[*mdl.MaterialPass]

CreateMaterialPass creates a provider that will create a material pass with the specified options.

func CreateModel

func CreateModel(name string, operations ...Operation) Provider[*mdl.Model]

CreateModel creates a new model with the specified name and operations.

func CreateNode

func CreateNode(name string, operations ...Operation) Provider[*mdl.Node]

CreateNode creates a new node with the specified name and operations.

func CreatePointLight

func CreatePointLight(opts ...Operation) Provider[*mdl.PointLight]

CreatePointLight creates a new point light.

func CreateSampler

func CreateSampler(textureProvider Provider[*mdl.Texture], operations ...Operation) Provider[*mdl.Sampler]

CreateSampler creates a new sampler with the provided texture and operations.

func CreateShader

func CreateShader(shaderType mdl.ShaderType, code string) Provider[*mdl.Shader]

CreateShader creates a provider that will create a shader with the specified type and source code.

func CreateSky

func CreateSky(materialProvider Provider[*mdl.Material], opts ...Operation) Provider[*mdl.Sky]

CreateSky creates a new sky with the provided name and operations.

func CreateSpotLight

func CreateSpotLight(opts ...Operation) Provider[*mdl.SpotLight]

CreateSpotLight creates a new spot light.

func CreateTextureSkyMaterial

func CreateTextureSkyMaterial(samplerProvider Provider[*mdl.Sampler]) Provider[*mdl.Material]

CreateTextureSkyMaterial creates a new texture sky material.

func CubeImageFromEquirectangular

func CubeImageFromEquirectangular(imageProvider Provider[*mdl.Image]) Provider[*mdl.CubeImage]

CubeImageFromEquirectangular creates a cube image from an equirectangular image.

func DPVec4ToSPVec4

func DPVec4ToSPVec4(inputProvider Provider[dprec.Vec4]) Provider[sprec.Vec4]

DPVec4ToSPVec4 converts the double precision vec4 to single precision vec4.

func Degrees

func Degrees(value float64) Provider[dprec.Angle]

Degrees returns an angle constant.

func FuncProvider

func FuncProvider[T any](get GetFunc[T], digest DigestFunc) Provider[T]

FuncProvider creates a provider from a get and a digest function.

func IrradianceCubeImage

func IrradianceCubeImage(imageProvider Provider[*mdl.CubeImage], opts ...Operation) Provider[*mdl.CubeImage]

IrradianceCubeImage creates an irradiance cube image from the provided HDR skybox cube image.

func OnceProvider

func OnceProvider[T any](delegate Provider[T]) Provider[T]

OnceProvider creates a provider that caches the result of the delegate provider.

func OpenBlob added in v0.22.0

func OpenBlob(name, path string) Provider[*mdl.Blob]

OpenBlob opens an binary file from the provided path.

func OpenGLTFModel

func OpenGLTFModel(path string, opts ...Operation) Provider[*mdl.Model]

OpenGLTFModel creates a new model provider that loads a model from the specified path.

func OpenImage

func OpenImage(path string) Provider[*mdl.Image]

OpenImage opens an image file from the provided path.

func RGB

func RGB(r, g, b float64) Provider[dprec.Vec4]

RGB returns a color constant.

func RGBA

func RGBA(r, g, b, a float64) Provider[dprec.Vec4]

RGBA returns a color constant.

func ReflectionCubeImages added in v0.21.0

func ReflectionCubeImages(imageProvider Provider[*mdl.CubeImage], opts ...Operation) Provider[[]*mdl.CubeImage]

ReflectionCubeImages creates a reflection cube image mipmap set from the provided HDR skybox cube image.

func ResizedCubeImage

func ResizedCubeImage(imageProvider Provider[*mdl.CubeImage], newSizeProvider Provider[int]) Provider[*mdl.CubeImage]

ResizedCubeImage returns a cube image with the provided dimensions.

func ResizedImage

func ResizedImage(imageProvider Provider[*mdl.Image], newWidthProvider, newHeightProvider Provider[int]) Provider[*mdl.Image]

ResizedImage returns an image with the provided dimensions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL