Liking cljdoc? Tell your friends :D

threeagent.tsl.material

Node materials described as data.

{:shader my-shader ; (fn [uniforms] node-or-output-map) :type :standard ; see material-types, default :basic :uniforms {:time 0 :tint [1 0 0]} :transparent true ; any other key is a material property :blending :additive}

The shader fn receives a map of uniform nodes keyed like :uniforms and returns a node (the material's colorNode) or a map of outputs: {:color .. :opacity .. :position .. :normal .. :emissive .. :fragment ..}, each key k setting the material's <k>Node property.

Materials without :uniforms are shared between every owner using the same spec. Materials with :uniforms are per owner. Changing only uniform values writes uniform.value and never rebuilds the shader. Changing the shader fn, the type, a property, or the set/kind of uniforms builds a new material. So a hot reload that redefines the shader fn swaps materials in place the next time the scene renders.

Node materials described as data.

  {:shader   my-shader         ; (fn [uniforms] node-or-output-map)
   :type     :standard         ; see `material-types`, default :basic
   :uniforms {:time 0 :tint [1 0 0]}
   :transparent true           ; any other key is a material property
   :blending :additive}

The shader fn receives a map of uniform nodes keyed like `:uniforms` and
returns a node (the material's colorNode) or a map of outputs:
`{:color .. :opacity .. :position .. :normal .. :emissive .. :fragment ..}`,
each key `k` setting the material's `<k>Node` property.

Materials without `:uniforms` are shared between every owner using the same
spec. Materials with `:uniforms` are per owner. Changing only uniform values
writes `uniform.value` and never rebuilds the shader. Changing the shader
fn, the type, a property, or the set/kind of uniforms builds a new material.
So a hot reload that redefines the shader fn swaps materials in place the
next time the scene renders.
raw docstring

acquire!cljs

(acquire! owner spec)

Material for owner (any object, typically the Mesh) described by spec.

Material for `owner` (any object, typically the Mesh) described by `spec`.
raw docstring

dispose-unused!cljs

(dispose-unused!)

Dispose shared materials no owner holds anymore. threeagent calls this when a scene is reset (hot reload).

Dispose shared materials no owner holds anymore. threeagent calls this when
a scene is reset (hot reload).
raw docstring

material-ofcljs

(material-of owner)

The material currently held by owner, if any.

The material currently held by `owner`, if any.
raw docstring

material-typescljs


release!cljs

(release! owner)

Drop owner's claim on its material. Per-owner materials are disposed; shared ones stay cached until dispose-unused!.

Drop `owner`'s claim on its material. Per-owner materials are disposed;
shared ones stay cached until `dispose-unused!`.
raw docstring

spec?cljs

(spec? x)

True when x describes a node material.

True when `x` describes a node material.
raw docstring

uniforms-ofcljs

(uniforms-of owner)

The uniform nodes of owner's material, keyed like its spec's :uniforms. Handy for driving values imperatively (e.g. every frame from a system).

The uniform nodes of `owner`'s material, keyed like its spec's `:uniforms`.
Handy for driving values imperatively (e.g. every frame from a system).
raw docstring

update!cljs

(update! owner spec)

Bring owner's material in line with spec: writes uniform values when only they changed, otherwise builds (or finds) a new material.

Bring `owner`'s material in line with `spec`: writes uniform values when only
they changed, otherwise builds (or finds) a new material.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close