The SceneModule
class exposes properties and methods to access the objects in a scene.
//============================================================================== // 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] })();
Property | Description |
---|---|
root | (get) root: Scene 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. |
Method | Description |
---|---|
create | create(className: string, initialState?: {[key: string]: any}): Promise<SceneObjectBase> Create a scene object asynchronously. When creating the scene objects, keep the following in mind: - All objects must have an existing class. - New objects always get assigned a globally unique identifier .`- initialState is optional, but encouraged to be used.- initialState can contain any key: value pair for any settable property of the class being instantiated.- name in initialState is being used, unless it's not provided - then dynamicObject is used.) |
destroy | destroy(sceneObject: string | SceneObjectBase): Promise<void> Destroy a scene object, asynchronously. When destroying scene objects, keep the following in mind: - All bound properties will be automatically unbound on destruction. - Destroying a scene object automatically removes it from any parent. - Destroying a scene object automatically removes it all children from it. - Destroying a scene object that doesn't exist fails the Promise .- Destroying a scene object that was created in Studio fails the Promise . |
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') |
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') |
Class | Description |
---|---|
AmbientLightSource | The AmbientLightSource class describes an ambient lighting source. |
BlendShape | The BlendShape class describes a shape attached to a mesh or face mesh which can be used to change the shape of that mesh. |
BlockInstanceInputs | The BlockInstanceInputs class encapsulates methods for setting inputs to the block instance. |
BlockInstanceOutputs | The BlockInstanceOutputs class encapsulates methods for getting outputs of the block instance. |
BlockSceneRoot | The BlockSceneRoot class describes the root scene object of a block. |
BoundingBox | The BoundingBox class describes the bounds of a scene element in the local coordinate system. |
Bounds2D | The Bounds2D class describes the bounds of a scene element. |
Camera | The Camera class exposes details about the device camera focal area. |
CameraVisibility | The CameraVisibility class describes whether or not an object is visible from various camera views. |
Canvas | The Canvas class describes a scene canvas. |
DirectionalLightSource | The DirectionalLightSource class describes a directional light source. |
DynamicExtrusion | The DynamicExtrusion class provides functionality for creating extruded 3D objects using a brush. |
EnvironmentLightSource | The EnvironmentLightSource class describes an environment lighting source. |
FaceMesh | The FaceMesh class describes a face mesh. |
FaceTracker | "The FaceTracker class propagates details of detected faces to the scene." |
FocalDistance | The FocalDistance class describes a focal distance. |
FocalPlane | The FocalPlane class exposes details about the focal plane of the device camera. |
HandTracker | This class represents the hand tracker scene object, used to track the position of hands in the scene. |
Joint | The Joint class encapsulates a joint scene object. |
Mesh | The Mesh class describes a scene mesh. |
MeshSurface | The MeshSurface class describes a surface in a mesh. |
OutputVisibility | The OutputVisibility class describes whether or not an object is visible from various outputs. |
ParticleSystem | The ParticleSystem class implements the particle management system for the scene. |
ParticleTypeDescription | The ParticleTypeDescription class provides functionality for setting particle sprite densities in the scene. |
PlanarDiv | The PlanarDiv class describes a div on a plane. |
PlanarFlexContainer | The PlanarFlexContainer class describes a flex container on a plane. |
PlanarFlexItem | The PlanarFlexItem class describes a flex item on a plane. |
PlanarImage | The PlanarImage class describes an image rendered on a plane. |
PlanarObject | The PlanarObject class describes an object on a plane. |
PlanarStack | The PlanarImage class describes an image rendered on a plane. |
PlanarText | The PlanarText class describes text on a plane. |
Plane | The Plane class describes a plane. |
PlaneTracker | The PlaneTracker class provides functionality for locating a 3D plane based on 2D screen coordinates. |
PointLightSource | The PointLightSource class describes a point light source. |
Scene | The Scene class implements properties and methods to access the objects in a scene. |
SceneObject | The SceneObject class describes an object in a scene. |
ScreenPlane | The ScreenPlane class describes a screen plane. |
Skeleton | The Skeleton class describes a skeleton object. |
Speaker | The Speaker class encapsulates an speaker for a scene. Old class name is AudioSource . |
SpotLightSource | The SpotLightSource class describes a spot light source. |
SvgImage | The SvgImage class describes an SVG asset for a scene. |
TargetTracker | The TargetTracker encapsulates a tracker for some target. |
TextAlignmentWrapper | The TextAlignmentWrapper class contains text alignment details. |
TextExtrusion | "The TextExtrusion class describes a 3D text scene object. |
ThreeDObject | The ThreeDObject class describes a scene 3d object. |
Transform | The Transform class describes an object transform for a scene. |
WorldTransform | The WorldTransform class describes an object tranform for a sceneObject in world space. |
Enum | Description |
---|---|
Direction | The Direction enum describes the stack layout's direction. |
HorizontalAlignment | The HorizontalAlignment enum describes how an element is aligned horizontally. |
RenderMode | The RenderMode enum describes how to render a scene object. |
ScalingOption | The ScalingOption enum describes how an element is scaled. |
StackAlign | The StackAlign enum describes the stack children's alignment. |
StackDistribute | The StackDistribute enum describes the stack children's distribution. |
TextAlignment | The TextAlignment enum describes how a text element is aligned horizontally. |
TrackingMode | The TrackingMode enum describes how a PlaneTracker is tracking an object. |
VerticalAlignment | The VerticalAlignment enum describes how an element is aligned vertically. |
VerticalTextAlignment | The VerticalTextAlignment enum describes how a text element is aligned vertically. |