Scene
The container for all 3D graphical objects and state in a xeogl scene.
Usage
- Creating a Scene
- Creating and accessing components
- Controlling the camera
- Taking snapshots
- Lighting
- Clipping
- Picking
- Querying and tracking boundaries
- Controlling the viewport
- Controlling rendering
- Gamma correction
Creating a Scene
Creating a Scene with its own default canvas:
var scene = new xeogl.Scene();
Creating a Scene with an existing canvas.
var scene2 = new xeogl.Scene({
canvas: "myCanvas"
});
var scene3 = new xeogl.Scene({
canvas: document.getElementById("myCanvas");
});
Creating and accessing components
As a brief introduction to creating Scene components, we'll create a Mesh that has a TeapotGeometry and a PhongMaterial:
var teapotMesh = new xeogl.Mesh(scene, {
id: "myMesh", // <<---------- ID automatically generated if not provided
geometry: new xeogl.TeapotGeometry(scene),
material: new xeogl.PhongMaterial(scene, {
id: "myMaterial",
diffuse: [0.2, 0.2, 1.0]
})
});
Creating a Mesh within the default Scene (xeogl will automatically create the default Scene if it does not yet exist):
var teapotMesh = new xeogl.Mesh({
id: "myMesh",
geometry: new xeogl.TeapotGeometry(),
material: new xeogl.PhongMaterial({
id: "myMaterial",
diffuse: [0.2, 0.2, 1.0]
})
});
teapotMesh.scene.camera.eye = [45, 45, 45];
The default Scene can be got from either the Mesh or the xeogl namespace:
scene = teapotMesh.scene;
scene = xeogl.getDefaultScene();
You can also make any Scene instance the default scene, so that components will belong to that Scene when you don't explicitly specify a Scene for them:
var scene = new xeogl.Scene({ ... };
xeogl.setDefaultScene( scene );
Find components by ID in their Scene's components map:
var teapotMesh = scene.components["myMesh"];
teapotMesh.visible = false;
var teapotMaterial = scene.components["myMaterial"];
teapotMaterial.diffuse = [1,0,0]; // Change to red
A Scene also has a map of component instances for each Component subtype:
var meshes = scene.types["xeogl.Mesh"];
var teapotMesh = meshes["myMesh"];
teapotMesh.ghosted = true;
var phongMaterials = scene.types["xeogl.PhongMaterial"];
var teapotMaterial = phongMaterials["myMaterial"];
teapotMaterial.diffuse = [0,1,0]; // Change to green
See Object, Group and Model for how to create and access more sophisticated content.
Controlling the camera
Use the Scene's Camera to control the current viewpoint and projection:
var camera = myScene.camera;
camera.eye = [-10,0,0];
camera.look = [-10,0,0];
camera.up = [0,1,0];
camera.projection = "perspective";
camera.perspective.fov = 45;
//...
Managing the canvas, taking snapshots
The Scene's Canvas component provides various conveniences relevant to the WebGL canvas, such as getting getting snapshots, firing resize events etc:
var canvas = scene.canvas;
canvas.on("boundary", function(boundary) {
//...
});
var imageData = canvas.getSnapshot({
width: 500,
height: 500,
format: "png"
});
Lighting
The Scene's Lights component manages lighting:
var lights = scene.lights;
lights[1].color = [0.9, 0.9, 0.9];
//...
Clipping
The Scene's Clips component manages clipping planes for custom cross-sections:
var clips = scene.clips;
clips.clips = [
new xeogl.Clip({ // Clip plane on negative diagonal
pos: [1.0, 1.0, 1.0],
dir: [-1.0, -1.0, -1.0],
active: true
}),
new xeogl.Clip({ // Clip plane on positive diagonal
pos: [-1.0, -1.0, -1.0],
dir: [1.0, 1.0, 1.0],
active: true
}),
//...
];
Picking
Use the Scene's Scene#pick() method to pick and raycast meshes.
For example, to pick a point on the surface of the closest mesh at the given canvas coordinates:
var hit = scene.pick({
pickSurface: true,
canvasPos: [23, 131]
});
if (hit) { // Picked a Mesh
var mesh = hit.mesh;
var primitive = hit.primitive; // Type of primitive that was picked, usually "triangles"
var primIndex = hit.primIndex; // Position of triangle's first index in the picked Mesh's Geometry's indices array
var indices = hit.indices; // UInt32Array containing the triangle's vertex indices
var localPos = hit.localPos; // Float32Array containing the picked Local-space position on the triangle
var worldPos = hit.worldPos; // Float32Array containing the picked World-space position on the triangle
var viewPos = hit.viewPos; // Float32Array containing the picked View-space position on the triangle
var bary = hit.bary; // Float32Array containing the picked barycentric position within the triangle
var normal = hit.normal; // Float32Array containing the interpolated normal vector at the picked position on the triangle
var uv = hit.uv; // Float32Array containing the interpolated UV coordinates at the picked position on the triangle
}
Pick masking
We can use the Scene#pick() method's includeMeshes
and excludeMeshes
options to mask which Meshes we attempt to pick.
This is useful for picking through things, to pick only the Meshes of interest.
To pick only Meshes "gearbox#77.0"
and "gearbox#79.0"
, picking through any other Meshes that are
in the way, as if they weren't there:
var hit = scene.pick({
canvasPos: [23, 131],
includeMeshes: ["gearbox#77.0", "gearbox#79.0"]
});
if (hit) {
// Mesh will always be either "gearbox#77.0" or "gearbox#79.0"
var mesh = hit.mesh;
}
To pick any pickable Mesh, except for "gearbox#77.0"
and "gearbox#79.0"
, picking through those
Meshes if they happen to be in the way:
var hit = scene.pick({
canvasPos: [23, 131],
excludeMeshes: ["gearbox#77.0", "gearbox#79.0"]
});
if (hit) {
// Mesh will never be "gearbox#77.0" or "gearbox#79.0"
var mesh = hit.mesh;
}
See Scene#pick() for more info on picking.
Querying and tracking boundaries
Getting a Scene's World-space axis-aligned boundary (AABB):
var aabb = scene.aabb; // [xmin, ymin, zmin, xmax, ymax, zmax]
Subscribing to updates to the AABB, which occur whenever Meshes are transformed, their Geometries have been updated, or the Camera has moved:
scene.on("boundary", function() {
var aabb = scene.aabb;
});
Getting the AABB of the Objects with the given IDs:
scene.getAABB(); // Gets collective boundary of all Mesh Objects in the scene
scene.getAABB("saw"); // Gets boundary of an Object
scene.getAABB(["saw", "gearbox"]); // Gets collective boundary of two Objects
See Scene#getAABB() and Object for more info on querying and tracking boundaries.
Managing the viewport
The Scene's Viewport component manages the WebGL viewport:
var viewport = scene.viewport
viewport.boundary = [0, 0, 500, 400];;
Controlling rendering
You can configure a Scene to perform multiple "passes" (renders) per frame. This is useful when we want to render the scene to multiple viewports, such as for stereo effects.
In the example, below, we'll configure the Scene to render twice on each frame, each time to different viewport. We'll do this with a callback that intercepts the Scene before each render and sets its Viewport to a different portion of the canvas. By default, the Scene will clear the canvas only before the first render, allowing the two views to be shown on the canvas at the same time.
// Load a glTF model
var model = new xeogl.GLTFModel({
src: "models/gltf/GearboxAssy/glTF-MaterialsCommon/GearboxAssy.gltf"
});
var scene = model.scene;
var viewport = scene.viewport;
// Configure Scene to render twice for each frame
scene.passes = 2; // Default is 1
scene.clearEachPass = false; // Default is false
// Render to a separate viewport on each render
var viewport = scene.viewport;
viewport.autoBoundary = false;
scene.on("rendering", function (e) {
switch (e.pass) {
case 0:
viewport.boundary = [0, 0, 200, 200]; // xmin, ymin, width, height
break;
case 1:
viewport.boundary = [200, 0, 200, 200];
break;
}
});
// We can also intercept the Scene after each render,
// (though we're not using this for anything here)
scene.on("rendered", function (e) {
switch (e.pass) {
case 0:
break;
case 1:
break;
}
});
Gamma correction
Within its shaders, xeogl performs shading calculations in linear space.
By default, the Scene expects color textures (eg. PhongMaterial#diffuseMap, MetallicMaterial#baseColorMap and SphericalMaterial#diffuseMap) to be in pre-multipled gamma space, so will convert those to linear space before they are used in shaders. Other textures are always expected to be in linear space.
By default, the Scene will also gamma-correct its rendered output.
You can configure the Scene to expect all those color textures to be linear space, so that it does not gamma-correct them:
scene.gammaInput = false;
You would still need to gamma-correct the output, though, if it's going straight to the canvas, so normally we would leave that enabled:
scene.gammaOutput = true;
See Texture for more information on texture encoding and gamma.
Constructor
Scene
-
[cfg]
Parameters:
-
[cfg]
Object optionalScene parameters
-
[id]
String optionalOptional ID, unique among all Scenes in xeogl, generated automatically when omitted.
-
[meta]
String:Object optionalOptional map of user-defined metadata to attach to this Scene.
-
[canvasId]
String optionalID of existing HTML5 canvas in the DOM - creates a full-page canvas automatically if this is omitted
-
[webgl2=true]
Boolean optionalSet this false when we don't want to use WebGL 2 for our Scene; the Scene will fall back on WebGL 1 if not available. This property will be deprecated when WebGL 2 is supported everywhere.
-
[components]
Array(Object) optionalJSON array containing parameters for Component subtypes to immediately create within the Scene.
-
[ticksPerRender=1]
Number optionalThe number of Scene/tick:event that happen between each render or this Scene.
-
[passes=1]
Number optionalThe number of times this Scene renders per frame.
-
[clearEachPass=false]
Boolean optionalWhen doing multiple passes per frame, specifies whether to clear the canvas before each pass (true) or just before the first pass (false).
-
[transparent=false]
Boolean optionalWhether or not the canvas is transparent.
-
[backgroundColor]
Float32Array optionalRGBA color for canvas background, when canvas is not transparent. Overridden by backgroundImage.
-
[backgroundImage]
String optionalURL of an image to show as the canvas background, when canvas is not transparent. Overrides backgroundImage.
-
[gammaInput=false]
Boolean optionalWhen true, expects that all textures and colors are premultiplied gamma.
-
[gammaOutput=true]
Boolean optionalWhether or not to render with pre-multiplied gama.
-
[gammaFactor=2.2]
Number optionalThe gamma factor to use when rendering with pre-multiplied gamma.
-
Index
Methods
Properties
- aabb
- camera
- canvas
- center
- clearEachPass
- clips
- components
- destroyed
- edgeMaterial
- entities
- entityIds
- entityTypeIds
- entityTypeIds
- entityTypes
- gammaInput
- gammaOutput
- gammaOutput
- geometry
- ghostedEntities
- ghostedEntityIds
- ghostMaterial
- guidObjects
- highlightedEntities
- highlightedEntityIds
- highlightMaterial
- id
- input
- lightMaps
- lights
- loading
- material
- meshes
- metadata
- model
- models
- objects
- outlineMaterial
- passes
- reflectionMaps
- rootObjects
- scene
- selectedEntities
- selectedEntityIds
- selectedMaterial
- ticksPerRender
- timeCreated
- type
- types
- viewport
- visibleEntities
- visibleEntityIds
Methods
clear
()
Resets this Scene to its default state.
References to any components in this Scene will become invalid.
clearLights
()
Convenience method that destroys all light sources.
Removes all AmbientLights, PointLights, DirLights and SpotLights.
create
-
[cfg]
Convenience method for creating a Component within this Component's Scene.
The method is given a component configuration, like so:
var material = myComponent.create({
type: "xeogl.PhongMaterial",
diffuse: [1,0,0],
specular: [1,1,0]
}, "myMaterial");
Parameters:
-
[cfg]
optionalConfiguration for the component instance.
Returns:
destroy
()
Destroys this component.
Fires a destroyed event on this Component.
Automatically disassociates this component from other components, causing them to fall back on any defaults that this component overrode on them.
TODO: describe effect with respect to #create
error
-
message
Logs an error for this component to the JavaScript console.
The console message will have this format: [ERROR] [<component type> =<component id>: <message>
Also fires the message as an error event on the parent Scene.
Parameters:
-
message
StringThe message to log
fire
-
event
-
value
-
[forget=false]
Fires an event on this component.
Notifies existing subscribers to the event, optionally retains the event to give to any subsequent notifications on the event as they are made.
Parameters:
-
event
StringThe event type name
-
value
ObjectThe event parameters
-
[forget=false]
Boolean optionalWhen true, does not retain for subsequent subscribers
getAABB
-
target
Returns the collective axis-aligned bounding box of the Objects, specified by their IDs, GUIDs and/or entity types.
When no arguments are given, returns the total boundary of all objects in the scene.
Only Meshes with collidable
set true
are included in the boundary.
Usage
scene.getAABB(); // Gets collective boundary of all objects in the scene
scene.getAABB("saw"); // Gets collective boundary of all objects in saw model
scene.getAABB(["saw", "gearbox"]); // Gets collective boundary of all objects in saw and gearbox models
scene.getAABB("saw#0.1"); // Get boundary of an object in the saw model
scene.getAABB(["saw#0.1", "saw#0.2"]); // Get collective boundary of two objects in saw model
scene.getAABB(["saw#0.1", "surface", "support"]); // Get collective boundary an object, and all objects of the given two entity classes.
Parameters:
-
target
String | String{Array} Array of Object IDs, GUIDs or entity types.
Returns:
An axis-aligned World-space bounding box, given as elements [xmin, ymin, zmin, xmax, ymax, zmax]
.
hasSubs
-
event
Returns true if there are any subscribers to the given event on this component.
Parameters:
-
event
StringThe event
Returns:
True if there are any subscribers to the given event on this component.
isType
-
type
Tests if this component is of the given type, or is a subclass of the given type.
The type may be given as either a string or a component constructor.
This method works by walking up the inheritance type chain, which this component provides in property Component/superTypes:property, returning true as soon as one of the type strings in the chain matches the given type, of false if none match.
Examples:
var myRotate = new xeogl.Rotate({ ... });
myRotate.isType(xeogl.Component); // Returns true for all xeogl components
myRotate.isType("xeogl.Component"); // Returns true for all xeogl components
myRotate.isType(xeogl.Rotate); // Returns true
myRotate.isType(xeogl.Transform); // Returns true
myRotate.isType("xeogl.Transform"); // Returns true
myRotate.isType(xeogl.Mesh); // Returns false, because xeogl.Rotate does not (even indirectly) extend xeogl.Mesh
Parameters:
-
type
String | FunctionComponent type to compare with, eg "xeogl.PhongMaterial", or a xeogl component constructor.
Returns:
True if this component is of given type or is subclass of the given type.
log
-
message
Logs a console debugging message for this component.
The console message will have this format: [LOG] [<component type> <component id>: <message>
Parameters:
-
message
StringThe message to log
off
-
subId
Cancels an event subscription that was previously made with Component#on() or Component#once().
Parameters:
-
subId
StringPublication subId
on
-
event
-
callback
-
[scope=this]
Subscribes to an event on this component.
The callback is be called with this component as scope.
Parameters:
-
event
StringThe event
-
callback
FunctionCalled fired on the event
-
[scope=this]
Object optionalScope for the callback
Returns:
Handle to the subscription, which may be used to unsubscribe with {@link #off}.
once
-
event
-
callback
-
[scope=this]
Subscribes to the next occurrence of the given event, then un-subscribes as soon as the event is subIdd.
This is equivalent to calling Component#on(), and then calling Component#off() inside the callback function.
Parameters:
-
event
StringData event to listen to
-
callback
Function(data)Called when fresh data is available at the event
-
[scope=this]
Object optionalScope for the callback
pick
-
params
Attempts to pick an Mesh in this Scene.
Ignores Meshes with pickable set false.
When a Mesh is picked, fires a "pick" event on the Mesh with the hit result as parameters.
Picking the Mesh at the given canvas coordinates:
var hit = scene.pick({
canvasPos: [23, 131]
});
if (hit) { // Picked a Mesh
var mesh = hit.mesh;
}
Usage:
Picking the Mesh that intersects a ray cast through the canvas:
var hit = scene.pick({
pickSurface: true,
canvasPos: [23, 131]
});
if (hit) { // Picked a Mesh
var mesh = hit.mesh;
// These properties are only on the hit result when we do a ray-pick:
var primitive = hit.primitive; // Type of primitive that was picked, usually "triangles"
var primIndex = hit.primIndex; // Position of triangle's first index in the picked Mesh's Geometry's indices array
var indices = hit.indices; // UInt32Array containing the triangle's vertex indices
var localPos = hit.localPos; // Float32Array containing the picked Local-space position on the triangle
var worldPos = hit.worldPos; // Float32Array containing the picked World-space position on the triangle
var viewPos = hit.viewPos; // Float32Array containing the picked View-space position on the triangle
var bary = hit.bary; // Float32Array containing the picked barycentric position within the triangle
var normal = hit.normal; // Float32Array containing the interpolated normal vector at the picked position on the triangle
var uv = hit.uv; // Float32Array containing the interpolated UV coordinates at the picked position on the triangle
}
Picking the Mesh that intersects an arbitrarily-aligned World-space ray:
var hit = scene.pick({
pickSurface: true, // Picking with arbitrarily-positioned ray
origin: [0,0,-5], // Ray origin
direction: [0,0,1] // Ray direction
});
if (hit) { // Picked a Mesh with the ray
var mesh = hit.mesh;
var primitive = hit.primitive; // Type of primitive that was picked, usually "triangles"
var primIndex = hit.primIndex; // Position of triangle's first index in the picked Mesh's Geometry's indices array
var indices = hit.indices; // UInt32Array containing the triangle's vertex indices
var localPos = hit.localPos; // Float32Array containing the picked Local-space position on the triangle
var worldPos = hit.worldPos; // Float32Array containing the picked World-space position on the triangle
var viewPos = hit.viewPos; // Float32Array containing the picked View-space position on the triangle
var bary = hit.bary; // Float32Array containing the picked barycentric position within the triangle
var normal = hit.normal; // Float32Array containing the interpolated normal vector at the picked position on the triangle
var uv = hit.uv; // Float32Array containing the interpolated UV coordinates at the picked position on the triangle
var origin = hit.origin; // Float32Array containing the World-space ray origin
var direction = hit.direction; // Float32Array containing the World-space ray direction
}
Parameters:
-
params
Picking parameters.
-
[pickSurface=false]
Boolean optionalWhether to find the picked position on the surface of the Mesh.
-
[canvasPos]
Float32Array optionalCanvas-space coordinates. When ray-picking, this will override the origin and direction parameters and will cause the ray to be fired through the canvas at this position, directly along the negative View-space Z-axis.
-
[origin]
Float32Array optionalWorld-space ray origin when ray-picking. Ignored when canvasPos given.
-
[direction]
Float32Array optionalWorld-space ray direction when ray-picking. Also indicates the length of the ray. Ignored when canvasPos given.
-
[includeMeshes]
Array optional -
[excludeMeshes]
Array optional
-
Returns:
Hit record, returned when an Mesh is picked, else null. See method comments for description.
render
-
[forceRender=false]
Renders a single frame of this Scene.
The Scene will periodically render itself after any updates, but you can call this method to force a render if required. This method is typically used when we want to synchronously take a snapshot of the canvas and need everything rendered right at that moment.
Parameters:
-
[forceRender=false]
Boolean optionalForces a render when true, otherwise only renders if something has changed in this Scene since the last render.
setColorize
-
ids
-
[colorize=(1,1,1)]
Colorizes a batch of Objects, specified by their IDs, GUIDs and/or entity types.
setEdges
-
ids
-
edges
Shows or hides wireeframe edges for batch of Objects, specified by their IDs, GUIDs and/or entity types.
Parameters:
-
ids
ArrayArray of Object IDs, GUIDs or entity types.
-
edges
Float32ArrayWhether to show or hide edges.
Returns:
True if any Objects changed edges state, else false if all updates were redundant and not applied.
setGhosted
-
ids
-
ghosted
Ghosts or un-ghosts a batch of Objects, specified by their IDs, GUIDs and/or entity types.
Each Object indicates its ghosted status in its ghosted property.
Each ghosted Object is registered in the Scene's ghostedEntities map when its entityType is assigned a value.
Parameters:
-
ids
ArrayArray of Object IDs, GUIDs or entity types.
-
ghosted
Float32ArrayWhether to ghost or un-ghost.
Returns:
True if any Objects changed ghosted state, else false if all updates were redundant and not applied.
setHighlighted
-
ids
-
highlighted
Highlights or de-highlights a batch of Objects, specified by their IDs, GUIDs and/or entity types.
Each Object indicates its highlight status in its highlighted property.
Each highlighted Object is registered in the Scene's highlightedEntities map while its entityType is assigned a value.
Parameters:
-
ids
ArrayArray of Object IDs, GUIDs or entity types.
-
highlighted
BooleanWhether to highlight or un-highlight.
Returns:
True if any Objects changed highlighted state, else false if all updates were redundant and not applied.
setOpacity
-
ids
-
[opacity=1]
Updates opacities of a batch of Objects, specified by their IDs, GUIDs and/or entity types.
setOutlined
-
ids
-
outlined
Shows or hides an outline around a batch of Objects, specified by their IDs, GUIDs and/or entity types.
Each Object indicates its outlined status in its outlined property.
Each outlined Object is registered in the Scene's Scene/outlinedEntities:property map when its entityType is assigned a value.
Parameters:
-
ids
ArrayArray of Object IDs, GUIDs or entity types.
-
outlined
Float32ArrayWhether to show or hide the outline.
Returns:
True if any Objects changed outlined state, else false if all updates were redundant and not applied.
setPickable
-
ids
-
pickable
Sets a batch of Objects pickable or unpickable, specified by their IDs, GUIDs and/or entity types.
Picking is done via calls to Scene#pick().
Parameters:
-
ids
ArrayArray of Object IDs, GUIDs or entity types.
-
pickable
Float32ArrayWhether to ghost or un-ghost.
Returns:
True if any Objects changed pickable state, else false if all updates were redundant and not applied.
setSelected
-
ids
-
selected
Selects or de-selects a batch of Objects, specified by their IDs, GUIDs and/or entity types.
Each Object indicates its selected status in its selected property.
Each selected Object is registered in the Scene's selectedEntities map while its entityType is assigned a value.
Parameters:
-
ids
ArrayArray of Object IDs, GUIDs or entity types.
-
selected
BooleanWhether to select or deselect.
Returns:
True if any Objects changed selection state, else false if all updates were redundant and not applied.
setVisible
-
ids
-
culled
Culls or unculls a batch of Objects, specified by their IDs, GUIDs and/or entity types.
Each Object indicates its culled status in its Object/visibility:property property.
Parameters:
-
ids
ArrayArray of Object IDs, GUIDs or entity types.
-
culled
BooleanThe new cull state.
Returns:
True if any Objects changed culled state, else false if all updates were redundant and not applied.
setVisible
-
ids
-
visible
Shows or hides a batch of Objects, specified by their IDs, GUIDs and/or entity types.
Each Object indicates its visibility status in its Object/visibility:property property.
Each visible Object is registered in the Scene's visibleEntities map while its entityType is assigned a value.
Parameters:
-
ids
ArrayArray of Object IDs, GUIDs or entity types.
-
visible
BooleanThe new visibility state.
Returns:
True if any Objects changed visibility, else false if all updates were redundant and not applied.
warn
-
message
Logs a warning for this component to the JavaScript console.
The console message will have this format: [WARN] [<component type> =<component id>: <message>
Parameters:
-
message
StringThe message to log
Properties
aabb
Float32Array
final
World-space axis-aligned 3D boundary (AABB) of this Scene.
The AABB is represented by a six-element Float32Array containing the min/max extents of the
axis-aligned volume, ie. [xmin, ymin,zmin,xmax,ymax, zmax]
.
center
Float32Array
final
World-space 3D center of this Scene.
clearEachPass
Boolean
When doing multiple passes per frame, specifies whether to clear the canvas before each pass (true) or just before the first pass (false).
Default: false
destroyed
Boolean
True as soon as this Component has been destroyed
edgeMaterial
EdgeMaterial
final
The Scene's default EmphasisMaterial for the appearance of Meshes when edges are emphasized.
This EdgeMaterial has an id equal to "default.edgeMaterial", with all other properties initialised to their default values.
Meshes in this Scene are attached to this EdgeMaterial by default.
entities
String:Object
final
Objects in this Scene that have entity types, mapped to their IDs.
Each Object is registered in this map when its entityType is assigned a value.
entityTypes
String:{String:xeogl.Component}
final
For each entity type, a map of IDs to Objects of that entity type.
Each Object is registered in this map when its entityType is assigned a value.
gammaInput
Boolean
When true, expects all textures and colors are premultiplied gamma.
Default: false
gammaOutput
Boolean
Whether or not to render pixels with pre-multiplied gama.
Default: true
gammaOutput
Number
The gamma factor to use when Scene/property:gammaOutput is set true.
Default: 1.0
geometry
BoxGeometry
final
The default geometry for this Scene, which is a BoxGeometry.
This BoxGeometry has an id equal to "default.geometry".
Meshes in this Scene are attached to this Geometry by default.
ghostedEntities
String:Object
final
Ghosted entity Objects within this Scene, mapped to their IDs.
Each Object is registered in this map when its ghosted property is true and its entityType is assigned a value.
ghostMaterial
EmphasisMaterial
final
The Scene's default EmphasisMaterial for the appearance of Meshes when they are ghosted.
This EmphasisMaterial has an id equal to "default.ghostMaterial", with all other properties initialised to their default values.
Meshes in this Scene are attached to this EmphasisMaterial by default.
guidObjects
String:Object
final
highlightedEntities
String:Object
final
Highlighted entity Objects within this Scene, mapped to their IDs.
Each Object is registered in this map when its highlighted property is true and its entityType is assigned a value.
highlightMaterial
HighlightMaterial
final
The Scene's default EmphasisMaterial for the appearance of Meshes when they are highlighted.
This HighlightMaterial has an id equal to "default.highlightMaterial", with all other properties initialised to their default values.
Meshes in this Scene are attached to this HighlightMaterial by default.
lights
String:Object
final
The PointLight, DirLight, SpotLight and AmbientLight components in this Scene, mapped to their IDs.
loading
Number
final
The number of models currently loading.
material
PhongMaterial
final
The default drawing material for this Scene, which is a PhongMaterial.
This PhongMaterial has an id equal to "default.material", with all other properties initialised to their default values.
Meshes in this Scene are attached to this PhongMaterial by default.
model
Model
final
The Model which contains this Component, if any.
Will be null if this Component is not in a Model.
outlineMaterial
OutlineMaterial
final
The Scene's default OutlineMaterial for the appearance of Meshes when they are outlined.
This OutlineMaterial has an id equal to "default.outlineMaterial", with all other properties initialised to their default values.
Meshes in this Scene are attached to this OutlineMaterial by default.
passes
Number
The number of times this Scene renders per frame.
Default: 1
reflectionMaps
String:ReflectionMap
final
The ReflectionMap components in this Scene, mapped to their IDs.
selectedEntities
String:Object
final
Selected entity Objects within this Scene, mapped to their IDs.
Each Object is registered in this map when its selected property is true and its entityType is assigned a value.
selectedMaterial
SelectedMaterial
final
The Scene's default EmphasisMaterial for the appearance of Meshes when they are selected.
This SelectedMaterial has an id equal to "default.selectedMaterial", with all other properties initialised to their default values.
Meshes in this Scene are attached to this SelectedMaterial by default.
ticksPerRender
Number
The number of Scene/tick:property that happen between each render or this Scene.
Default: 1
timeCreated
Number
final
The epoch time (in milliseconds since 1970) when this Scene was instantiated.
type
String
final
JavaScript class name for this Component.
For example: "xeogl.AmbientLight", "xeogl.MetallicMaterial" etc.
types
String:{String:xeogl.Component}
final
For each Component type, a map of IDs to Components instances of that type.
visibleEntities
String:Object
final
Visible entity Objects within this Scene, mapped to their IDs.
Each Object is registered in this map when its visible property is true and its entityType is assigned a value.
Events
destroyed
Fired when this Component is destroyed.
error
Fired whenever an error is logged on a component within this Scene.
Event Payload:
-
value
StringThe error message
log
Fired whenever a debug message is logged on a component within this Scene.
Event Payload:
-
value
StringThe debug message
rendering
Fired when about to render a frame for a Scene.
Event Payload:
-
sceneID
StringThe ID of this Scene.
-
pass
NumberIndex of the pass we are about to render (see passes).
rendering
Fired when we have just rendered a frame for a Scene.
Event Payload:
-
sceneID
StringThe ID of this Scene.
-
pass
NumberIndex of the pass we rendered (see passes).
warn
Fired whenever a warning is logged on a component within this Scene.
Event Payload:
-
value
StringThe warning message