ShaderColorLayer

A color layer where the color is fully computed in the shader.

Constructor

new ShaderColorLayer(properties)

A color layer where the color is fully computed in the shader. The given shader glsl code will be inserted in the main planet shader and color per fragment will be computed via a call to "vec3 getShaderLayerColor(vec3 llh, vec3 xyz, vec3 normal, float level);". Note that the normal is in world space. The given textures map will be automatically loaded and will be accessible in the shader by name (map keys) Only one visible ShaderColorLayer will be taken into account at a time.
Parameters:
NameTypeDescription
propertiesObject
Properties
NameTypeAttributesDefaultDescription
idString | Numberlayer id should be unique
nameStringthe name can be anything you want and is intended for labeling
shaderStringa string representing shader code to be injected. Should at least implement the method : vec3 getShaderLayerColor(vec3 llh, vec3 xyz, vec3 normal, float level)
texturesObject<optional>
an object containing texture names and THREE.Texture objects as key-value pairs
transparencyNumber<optional>
0the layer's transparency (0 to 1)
boundsArray.<Number><optional>
[-180, -90, 180, 90]min longitude, min latitude, max longitude, max latitude in degrees
visibleBoolean<optional>
truelayer will be rendered if true (true by default)

Extends

Methods

addListener(key, listener)

Adds a listener for layer events
Parameters:
NameTypeDescription
key*can be anything but should be unique
listenerfunctiona function : (layer, eventType)=>{}

dispose()

disposes of any resources used by this layer
Overrides

getBounds() → {THREE.Box2}

Returns:
bounds in longitude latitude (degrees)
Type: 
THREE.Box2

getCenter(sfct) → {THREE.Vector3}

Moves a given point to this layer's center in degree longitude/latitude
Parameters:
NameTypeDescription
sfctTHREE.Vector3a point to move
Returns:
the input point
Type: 
THREE.Vector3

getID()

Overrides
Returns:
layer id

getName()

Overrides
Returns:
layer name

getSelectableObjects()

Get all the selectable objects of this layer.
Returns:
an array of ray-castable objects with a property "layer" pointing to this layer.

removeListener(key)

Removes the listener associated to the given key
Parameters:
NameTypeDescription
key*can be anything but should be unique

select(objectsToSelect) → {Boolean}

selects an object from this layer
Parameters:
NameTypeDescription
objectsToSelectObject
Overrides
Returns:
true if the object was selected, false otherwise
Type: 
Boolean

setName(name)

change the layer name
Parameters:
NameTypeDescription
nameString
Overrides

setVisible(visible)

Modifies the layer visibility
Parameters:
NameTypeDescription
visibleBoolean

unselect(objectsToUnselect) → {Boolean}

un-selects an object from this layer
Parameters:
NameTypeDescription
objectsToUnselectObject
Returns:
true if the object was un-selected, false otherwise
Type: 
Boolean