B.Render.Instance()

Represents a renderable instance. The instance is the elementary unit of rendering (transformed mesh + material).

To create the object use device.instance().

CONSTANTS:

{Object} TRANSFORM

Instance transformation uniform placeholder. It allows to set instance transformation matrix to a uniform value automatically.

instance.uniform("mxTransform", B.Render.Instance.TRANSFORM);

{Object} NORMAL_TRANSFORM

Instance inverse transpose transformation uniform placeholder. It allows to set instance inverse transpose transformation matrix to a uniform value automatically.

instance.uniform("mxNormalTransform", B.Render.Instance.NORMAL_TRANSFORM);

METHODS:

device()

Returns linked rendering device.

RETURNS:

mesh()

Returns mesh.

RETURNS:

material()

Returns material.

RETURNS:

bounds()

Returns bounds.

RETURNS:

culling(enable)

Sets frustum culling enable.

PARAMETERS:

{boolean} enable

RETURNS:

culling()

Gets frustum culling enable.

RETURNS:

{boolean}

uniforms()

Returns array of uniforms names.

RETURNS:

{Array.<string>}

uniform(name, value)

Sets a uniform value.

instance.
    uniform("someNumber", 1.5).
    uniform("someVector2", B.Math.makeVector2(1, 2)).
    uniform("someVector3", B.Math.makeVector3(1, 2, 3)).
    uniform("someVector4", B.Math.makeVector4(1, 2, 3, 4)).
    uniform("someColor", B.Math.makeColor(1, 0, 0, 0.5)).
    uniform("someMatrix3", B.Math.makeMatrix3().setRotationX(Math.PI)).
    uniform("someMatrix4", B.Math.makeMatrix4().setTranslation(1, 2, 3)).
    uniform("someTexture", dev.makeTexture(image)).
    uniform("someTexture", dev.stage("someStage").output().color()).
    uniform("someDepth", dev.stage("someStage").output().depth());

instance.uniform("someTexture", null); // removing

PARAMETERS:

RETURNS:

uniform(name)

Gets a uniform value.

PARAMETERS:

{string} name

RETURNS:

setTransform(matrix)

Sets the instance transformation.

PARAMETERS:

RETURNS:

transform(matrix)

Add a given transformation to the instance transformation.

PARAMETERS:

RETURNS:

transform()

Gets the instance transformation.

RETURNS:

move(offset)

Moves the instance by a given offset vector.

PARAMETERS:

{B.Math.Vector3} offset

RETURNS:

move(ox, oy, oz)

Moves the instance by given offsets.

PARAMETERS:

{number} ox

offset along X-axis

{number} oy

offset along Y-axis

{number} oz

offset along Z-axis

RETURNS:

rotate(axis, angle)

Rotates the instance around an arbitrary axis.

PARAMETERS:

{B.Math.Vector3} axis

{number} angle

in radians

RETURNS:

rotate(object)

Rotates instance by a quaternion or canonized euler angles.

PARAMETERS:

RETURNS:

scale(coeffs)

Scales the instance by a given coefficient vector.

PARAMETERS:

{B.Math.Vector3} coeffs

RETURNS:

scale(cx, cy, cz)

Scales instance by given coefficients.

PARAMETERS:

{number} cx

scale along X-axis

{number} cy

scale along Y-axis

{number} cz

scale along Z-axis

RETURNS:

scale(c)

Scales (uniformly) instance by a given coefficient.

PARAMETERS:

{number} c

scale along all axis uniformly

RETURNS:

free()

Frees all internal data and detach the resource from linked rendering device.

CONSTANTS:

METHODS: