Oolite JavaScript Reference: VisualEffect

From Elite Wiki
Revision as of 09:31, 8 September 2012 by Cim (talk | contribs) (Properties: dataKey)

This is a new class planned for 1.77 and may be subject to significant change before 1.77 is released.

Prototype: Entity

The VisualEffect class is an Entity representing a visible but non-solid object defined from effectdata.plist. It has all the properties and methods of an Entity, and several others.

Properties

This property was added in Oolite test release 1.77.

dataKey

dataKey : String (read-only)

The data key from effectdata.plist used to generate this visual effect.

hullHeatLevel

hullHeatLevel : Float (read/write)

While visual effects do not have a temperature as such, this property is provided to allow easy compatibility with the default Oolite shader for ships.

isBreakPattern

allowsDocking : Boolean (read/write)

If this is true, the VisualEffect object will remain visible while break patterns on docking, launching or witchspace are being displayed (or not displayed). Normally all objects other than the break pattern itself are hidden.

scannerDisplayColor1

scannerDisplayColor1 : Colour specifier (read/write)

The first of two colours used by the ship’s scanner “lollipop”. When read, this will always be an array of four numbers in the range 0..1 (representing red, green, blue and alpha components). Any colour specifier format may be assigned to it. Assigning null will restore the value from effectdata.plist.

If both this and scannerDisplayColor2 are set to null, and no value is set for either in effectdata.plist then the effect will not appear on scanners.

See also: scannerDisplayColor2

scannerDisplayColor2

scannerDisplayColor2 : Colour specifier (read/write)

The second scanner colour. If both scannerDisplayColor1 and scannerDisplayColor2 are specified, the scanner lollipop will alternate between the two colours.

See also: scannerDisplayColor1

shader*

shaderFloat1 : Number (read/write)
shaderFloat2 : Number (read/write)
shaderInt1 : Number (read/write)
shaderInt2 : Number (read/write)
shaderVector1 : Vector (read/write)
shaderVector2 : Vector (read/write)

Since visual effects have very few intrinsic properties, some arbitrary parameters which may be bound as shader uniforms are provided.

Methods

This method was added in Oolite test release 1.77.

getMaterials

function getMaterials() : Object

getMaterials() returns the effect's current materials dictionary, or if none present an empty dictionary.

See also: setMaterials(), getShaders()

getShaders

function getShaders() : Object

getShaders() returns the effect's current shaders dictionary, or if none present an empty dictionary.

See also: setShaders(), getMaterials()

remove

function remove()

Immediately removes the effect from the universe.

scale

function scale(factor : Number)

Multiplies the size of the visual effect by factor. Subentities will be rescaled as well, and moved further from the centre of the effect as appropriate. An error will occur if factor is less than or equal to zero.

setMaterials

function setMaterials(materialDictionary : Object [, shaderDictionary : Object]) : Boolean

Set the materials of the effect’s model. This works exactly like the materials dictionary in effectdata.plist. The optional shaderDictionary argument overrides materialDictionary if shaders are active.

Example:

effect.setMaterials({"my_effect_diffuse.png": { diffuse_map: "my_effect_damaged_diffuse.png" }});

See also: setShaders(), getMaterials()

setShaders

function setShaders(shaderDictionary : Object) : Boolean

Set the shader materials of the effect’s model. Equivalent to setMaterials() with the materialDictionary value set to the effect’s current material dictionary.

See also: setMaterials(), getShaders()