Skip to content

Class: Scene3D ​

Experimental

The live scene (see the module comment). Get it with acquireScene.

Constructors ​

Constructor ​

ts
new Scene3D(
   id,
   viewport,
   layout,
   full
): Scene3D;

Experimental

Parameters ​

ParameterType
idstring
viewportViewport
layoutSceneLayout
fullRecord<string, unknown>

Returns ​

Scene3D

Properties ​

PropertyModifierTypeDefault valueDescription
camerapublicSceneCameraundefinedExperimental The camera in use (scene units); the controls move it, the layout's camera resets it.
idreadonlystringundefinedExperimental
initialreadonlyobjectundefinedExperimental The camera and aspect ratio of the first drawn view (double-click, "reset to last save").
initial.aspectpublicVec3undefined-
initial.aspectmodepublicunknownundefined-
initial.camerapublicSceneCameraundefined-
layoutpublicSceneLayoutundefinedExperimental The scene as laid out by the latest pass that laid it out.
lightingreadonlySceneLightingundefinedExperimental The scene's lights (layout.sceneN.lighting, E8.7; see scene-lighting.ts).
orthoZoompublicnumber1Experimental Orthographic zoom not committed yet: Plotly zooms orthographic scenes by scaling their aspectratio, which the controls commit when the gesture ends; until then the view zooms.
projectionpublicSceneProjection'perspective'Experimental camera.projection.type in use.
viewportreadonlyViewportundefinedExperimental

Accessors ​

transform ​

Get Signature ​

ts
get transform(): Required<DataTransform>;

Experimental

Linear coordinates → scene units (all three axes; see SceneLayout.transform).

Returns ​

Required<DataTransform>

Methods ​

apply() ​

ts
apply(fullLayout, layout): void;

Experimental

Take a pass's layout: a camera the layout changed replaces the live one (an app's relayout, a reset, or the controls' own commit, which then changes nothing).

Parameters ​

ParameterType
fullLayoutFullLayout
layoutSceneLayout | undefined

Returns ​

void


cameraPayload() ​

ts
cameraPayload(commit?): Record<string, unknown>;

Experimental

The scene.camera of a relayout for the live camera. With commit, the layout camera it becomes will not replace the live one (see apply).

Parameters ​

ParameterTypeDefault value
commitbooleanfalse

Returns ​

Record<string, unknown>


commitZoom() ​

ts
commitZoom(): Record<string, unknown>;

Experimental

Commit an orthographic zoom as an aspect ratio (see orthoZoom).

Returns ​

Record<string, unknown>


onCameraChange() ​

ts
onCameraChange(listener): () => void;

Experimental

Called with this scene whenever the camera moved (the axes redraw, views may re-sort).

Parameters ​

ParameterType
listener(scene) => void

Returns ​

() => void


project() ​

ts
project(
   x,
   y,
   z,
   out?
): ScreenPoint;

Experimental

Scene units → screen: container px (top-left origin) and NDC depth. Uses the camera as of the last sync.

Parameters ​

ParameterType
xnumber
ynumber
znumber
outScreenPoint

Returns ​

ScreenPoint


setCamera() ​

ts
setCamera(camera): void;

Experimental

Move the camera (controls, animations): the view follows on the next frame.

Parameters ​

ParameterType
cameraSceneCamera

Returns ​

void


sync() ​

ts
sync(): void;

Experimental

Push the camera to the viewport's three.js camera and tell the listeners.

Returns ​

void


toWorld() ​

ts
toWorld(
   x,
   y,
   z,
   out?
): Vec3;

Experimental

Linear coordinates → scene units.

Parameters ​

ParameterType
xnumber
ynumber
znumber
outVec3

Returns ​

Vec3


useLightRig() ​

ts
useLightRig(mesh): () => void;

Experimental

Light a mesh primitive with the scene's lights (scene.lighting, E8.7): now and whenever they change. Returns the function that stops it (call it when the mesh is disposed).

Parameters ​

ParameterType
meshLightRigUser

Returns ​

() => void

Released under the MIT License.