threejs-worldgen
    Preparing search index...

    Class InstanceStates

    Per-instance material states for instanced meshes (trees, rocks, buildings, props): four floats per instance (wetness, snow, burn, damage) in an InstancedBufferAttribute, read in the shader through InstanceStates.node.

    const states = new InstanceStates(trees.count)
    applyMaterialStatesTo(barkMaterial, { ...states.node(), wetness: field.node().wetness })
    states.set(12, { burn: 1 }) // tree 12 burnt down
    states.sampleField(field, treePositions) // pick up burn scars and storm damage
    Index
    array: Float32Array

    The states, 4 floats per instance (wetness, snow, burn, damage).

    attribute: InstancedBufferAttribute

    The GPU attribute (item size 4).

    count: number

    Number of instances.

    • Adds the attribute to a geometry under name (for InstancedBufferGeometry setups).

      Parameters

      • geometry: BufferGeometry
      • name: string = 'instanceStates'

      Returns this