SceneModule

The SceneModule class exposes properties and methods to access the objects in a scene.

Example

//==============================================================================
// The following example demonstrates how to access named elements from a Scene.
//==============================================================================

// Load in the required module
const Scene = require('Scene');

// Enable async/await in JS [part 1]
(async function() {
  // Locate the camera in the Scene using the child method
  const [[camera], focalDistance] = await Promise.all([
    // findByPath returns array of results as it supports wildcards
    Scene.root.findByPath('Device/Camera'),
    Scene.root.findFirst('Focal Distance')
  ]);
// Enable async/await in JS [part 2]
})();

Properties

PropertyDescription
root
(get) root: Scene
(set) (Not Available)


Returns an object that is the root of the scene tree. Other objects are accessed by walking down the scene tree from the root using the SceneObjectBase.child and SceneObjectBase.find methods.

Methods

MethodDescription
projectToScreen
projectToScreen(point: PointSignal): Point2DSignal


Returns a signal with the value that corresponds to the 2D point value (in Screen Space) of the given world coordinate.
Screen space positions are represented in the range of (0, 0) to (CameraInfo.previewSize.width, CameraInfo.previewSize.height),
with the coordinate start being the top left point of the screen and previewSize.width/height being the bottom right.

The values in the returned signal are not capped to the size of the screen space and can lie outside of the visible screen area.

This functionality can be used for precisely positioning 2D screen elements or to add additional effects that apply to the entire camera texture, based on contents of the scene.
unprojectToFocalPlane
unprojectToFocalPlane(location: Point2DSignal): PointSignal


Returns a signal with the value that corresponds to the 3d point (in World Space, in current units) of the given screenSpace point from the Point2DSignal.
The z coordinate of the PointSignal will be calculated so that the 3d point will always be on the canvas (which should be on the Focal Plane).
This function can be combined with TouchGestures to create a 3d point signal.


var S = require('Scene')
TouchGestures.onPan().subscribe(function(gesture) {
var signal = S.unprojectToFocalPlane(gesture.location);
});
unprojectWithDepth
unprojectWithDepth(location: Point2DSignal, depth: number): PointSignal


Returns a signal with the value that corresponds to the 3d point value (in World Space, in current units) of the given screenSpace point from the Point2DSignal.
The z coordinate of the PointSignal will always be equal to the given depth value. The depth should be given in current units.
This function can be combined with TouchGestures to create a 3d point signal.
var Scene = require('Scene')
var TouchGestures = require('TouchGestures')
TouchGestures.onPan().subscribe(function(gesture) {
var signal = Scene.unprojectWithDepth(gesture.location, 0.5);
});

Classes

ClassDescription
AmbientLightSourceThe AmbientLightSource class describes an ambient lighting source.
BlendShapeThe BlendShape class describes a shape attached to a mesh or face mesh which can be used to change the shape of that mesh.
BlendShapesMeshThe BlendShapesMesh class encapsulates multiple blendable meshes.
BlockInstanceInputsThe BlockInstanceInputs class encapsulates methods for setting inputs to the block instance.
BlockInstanceOutputsThe BlockInstanceOutputs class encapsulates methods for getting outputs of the block instance.
BlockSceneRootThe BlockSceneRoot class describes the root scene object of a block.
BoundingBoxThe BoundingBox class describes the bounds of a scene element in the local coordinate system.
Bounds2DThe Bounds2D class describes the bounds of a scene element.
CameraThe Camera class exposes details about the device camera focal area.
CameraVisibilityThe CameraVisibility class describes whether or not an object is visible from various camera views.
CanvasThe Canvas class describes a scene canvas.
DirectionalLightSourceThe DirectionalLightSource class describes a directional light source.
DynamicExtrusionThe DynamicExtrusion class provides functionality for creating extruded 3D objects using a brush.
FaceAnchorThe FaceAnchor class describes an anchored face.
FaceMeshThe FaceMesh class describes a face mesh.
FaceTrackerThe FaceTracker class propagates details of detected faces to the scene.
FocalDistanceThe FocalDistance class describes a focal distance.
FocalPlaneThe FocalPlane class exposes details about the focal plane of the device camera.
HandTrackerThis class represents the hand tracker scene object, used to track the position of hands in the scene.
JointThe Joint class encapsulates a joint scene object.
MeshThe Mesh class describes a scene mesh.
MeshSurfaceThe MeshSurface class describes a surface in a mesh.
OutputVisibilityThe OutputVisibility class describes whether or not an object is visible from various outputs.
ParticleSystemThe ParticleSystem class implements the particle management system for the scene.
ParticleTypeDescriptionThe ParticleTypeDescription class provides functionality for setting particle sprite densities in the scene.
ParticleTypeDescriptionsThe ParticleTypeDescriptions class provides a container for particle type descriptions.
PlanarDivThe PlanarDiv class describes a div on a plane.
PlanarFlexContainerThe PlanarFlexContainer class describes a flex container on a plane.
PlanarFlexItemThe PlanarFlexItem class describes a flex item on a plane.
PlanarImageThe PlanarImage class describes an image rendered on a plane.
PlanarObjectThe PlanarObject class describes an object on a plane.
PlanarTextThe PlanarText class describes text on a plane.
PlaneThe Plane class describes a plane.
PlaneTrackerThe PlaneTracker class provides functionality for locating a 3D plane based on 2D screen coordinates.
PointLightSourceThe PointLightSource class describes a point light source.
SceneThe Scene class implements properties and methods to access the objects in a scene.
SceneObjectThe SceneObject class describes an object in a scene.
SceneObjectBaseThe SceneObjectBase class describes a scene object.
ScreenPlaneThe ScreenPlane class describes a screen plane.
SkeletonThe Skeleton class describes a skeleton object.
SpeakerThe Speaker class encapsulates an speaker for a scene. Old class name is AudioSource.
SpotLightSourceThe SpotLightSource class describes a spot light source.
SvgImageThe SvgImage class describes an SVG asset for a scene.
TargetTrackerThe TargetTracker encapsulates a tracker for some target.
TextAlignmentWrapperThe TextAlignmentWrapper class contains text alignment details.
TextExtrusionThe TextExtrusion class describes a 3D text scene object.
TransformThe Transform class describes an object transform for a scene.
WorldTransformThe WorldTransform class describes an object tranform for a sceneObject in world space.

Enums

EnumDescription
HorizontalAlignmentThe HorizontalAlignment enum describes how an element is aligned horizontally.
RenderModeThe RenderMode enum describes how to render a scene object.
ScalingOptionThe ScalingOption enum describes how an element is scaled.
TextAlignmentThe TextAlignment enum describes how a text element is aligned horizontally.
TrackingModeThe TrackingMode enum describes how a PlaneTracker is tracking an object.
VerticalAlignmentThe VerticalAlignment enum describes how an element is aligned vertically.
VerticalTextAlignmentThe VerticalTextAlignment enum describes how a text element is aligned vertically.