Class: Light

Class contents

Methods list

These are special functions (or methods) that you may call on the object. these functions typically instruct the object to perform a certain operation.
  • destroy() - Marks the light for destruction, it will be removed from all clients.

Public properties list

Properties are attributes of the object, this directly affect the object in question. Some of them can be read or written, or both.
Name Type Description
x float The current X position of the light in world space
y float The current Y position of the light in world space
z float The current Z position of the light in world space
targetX float [Directional Only] The target X position of where the directional light will point "at" (in world space)
targetY float [Directional Only] The target Y position of where the directional light will point "at" (in world space)
targetZ float [Directional Only] The target Z position of where the directional light will point "at" (in world space)

Events list

Events are functions you add to your objects, that will be called by Cubiverse when certain things (events) occur.
    No events

Class Information

Constructor

new Light(visible, intensity, Directional and Point Onlyopt)

Light - You cannot instigate a Light directly from normal Java-script code, WORLD.createLight

Cubiverse allows you to spawn a number of lights to help illuminate your world. In addition to any user created lights, the world automatically contains a "sun" which can be controlled through the Environment object (you can change the "time of day" or remove the sun completely).

Performance Limitation : Be aware that each light has a large performance hit for a client; depending on your account you will be limited to 4, 8 or 16 lights per world. You should also try not to create lights in real-time, every time a light is created the clients must recalculate alot of information. This can cause "lag" on clients as the light is created (i.e. on slower clients they may notice a pause when the light is created, this can ruin the smooth rendering of the game). It is recommended that you create any lights when the world is first created. You can then move them, or change their color and intensity in real-time without any performance hit. {enum} [READ ONLY] lightType The type of light, this cannot be changed. Delete and WORLD.createLight to change the light type.

lightType.ambient - An ambient light that lights all cubes ( remember that the "sun" in Cubiverse is made up of an ambient and directional light )

lightType.directional - A directional light, it accepts a target position to "point" towards ( remember that the "sun" in Cubiverse is made up of an ambient and directional light )

lightType.point - A point light, this emmits light from a central point.

Parameters:
Name Type Attributes Description
visible float Sets whether the light is initially spawned as "on"
intensity float Sets the intensity of directional and point lights
Directional and Point Only float <optional>
distance Maximum distance (in units) from origin where light will shine whose intensity is attenuated linearly based on distance from origin (directional and point lights only)

Properties:

Name Type Description
x float The current X position of the light in world space
y float The current Y position of the light in world space
z float The current Z position of the light in world space
targetX float [Directional Only] The target X position of where the directional light will point "at" (in world space)
targetY float [Directional Only] The target Y position of where the directional light will point "at" (in world space)
targetZ float [Directional Only] The target Z position of where the directional light will point "at" (in world space)
Important:
  • You cannot instigate a Light directly from normal Java-script code, you must use WORLD.createLight

Methods

destroy()

Marks the light for destruction, it will be removed from all clients.