SDK3DVerse_Viewport

SDK3DVerse_Viewport

Viewport Object

Methods

getAreaSize() → {Array.<number>}

Retrieve viewport area size

Returns:

array - Element 0 is Width, element 1 is height

Type
Array.<number>

getCamera() → {SDK3DVerse_Entity}

Retrieve viewport camera entity

Returns:

cameraEntity Camera entity associated with the viewport.

Type
SDK3DVerse_Entity

getId() → {number}

Retrieve viewport identifier

Returns:

viewport identifier

Type
number

getOffset() → {Array.<number>}

Retrieve viewport offset within the rendering area

Returns:

array - Element 0 is left, element 1 is top

Type
Array.<number>

getProjection() → {component}

Retrieve lens component.

Returns:
Type
component

getProjectionMatrix() → {mat4}

Retrieve projection matrix

Returns:

projectionMatrix

Type
mat4

getProjectionType() → {Number}

Get viewport projection type

Returns:

Projection type, identified as :

  • perspective : 0
  • orthographic : 1
Type
Number

getTransform() → {component}

Retrieve Viewport global transform based on the latest received frame.

Returns:
Type
component

getViewProjectionMatrix() → {mat4}

Retrieve view projection matrix

Returns:

viewProjectionMatrix

Type
mat4

getWorldMatrix() → {SDK3DVerse_Entity}

Retrieve viewport camera entity

Returns:

cameraEntity Camera entity associated with the viewport.

Type
SDK3DVerse_Entity

getZoomFactor() → {Number}

Get the zoom factor of an orthographic view. No effect on perspective view

Returns:

zoomFactor

Type
Number

hasOrthographicProjection() → {Boolean}

Test if viewport has an orthographic projection

Returns:

Return true if viewport is orthographic

Type
Boolean

hasPerspectiveProjection() → {Boolean}

Test if viewport has a perspective projection

Returns:

Return true if viewport is perspective

Type
Boolean

isInArea(position) → {boolean}

Used to determine hovered viewports

Parameters:
Name Type Description
position Array.<number>

Element 0 is X coordinate, element 1 is Y coordinate

Returns:

returns true if position is within viewport area

Type
boolean

lookAt(target, propagateChangesopt)

Set the global orientation to make the camera look at the target point.

Parameters:
Name Type Attributes Default Description
target Array.<number>

Point to look at in global space

propagateChanges boolean <optional>
true

Default to true. Trigger engineAPI.propagateChanges, on this entity.

project(position) → {Array.<number>}

Project a 3D point to a 2D point on the viewport

Parameters:
Name Type Description
position Array.<number>

Element 0 is X coordinate, element 1 is Y coordinate, element 2 is Z coordinate

Returns:

Projected point in canvas coordinates. [0, 0] = Top left - [Canvas width, Canvas height] = Bottom right - [0, Canvas height] = Bottom left - [Canvas width, 0] = Top right

Type
Array.<number>

(async) reset(propagateChangesopt, travelingTimeopt)

Reset viewport camera to the default camera transformation.

Parameters:
Name Type Attributes Default Description
propagateChanges boolean <optional>
true

Trigger engineAPI.propagateChanges, on this entity.

travelingTime number <optional>
0

If superior to 0, animate a camera traveling from current point of view to default camera position and orientation at specified time of travel defined in second.

Will propagate changes in that case.

setAreaRatio(width, height, triggerViewportUpdate)

Set viewport area size

Parameters:
Name Type Description
width number

Width ratio from 0.0 to 1.0

height number

Height ratio from 0.0 to 1.0

triggerViewportUpdate bool

Set to true to propagate changes, causing the rendering service to adapt immediately to changes, set to false to avoid unnecessary updates.

setAreaSize(width, height, triggerViewportUpdate)

Set viewport area size

Parameters:
Name Type Default Description
width number

Width in pixel

height number

Height in pixel

triggerViewportUpdate bool true

Set to true to propagate changes, causing the rendering service to adapt immediately to changes, set to false to avoid unnecessary updates.

setGlobalTransform(globalTransform, propagateChangesopt)

Set the viewport Global transform.

Parameters:
Name Type Attributes Description
globalTransform transform

Global transform

propagateChanges boolean <optional>

Default to true. Trigger engineAPI.propagateChanges, on this entity.

setOffset(left, top, triggerViewportUpdate)

Set viewport offset

Parameters:
Name Type Default Description
left number

Left offset in pixel

top number

Top offset in pixel

triggerViewportUpdate bool true

Set to true to propagate changes, causing the rendering service to adapt immediately to changes, set to false to avoid unnecessary updates.

setOffsetRatio(left, top, triggerViewportUpdate)

Set viewport area size

Parameters:
Name Type Description
left number

Left offset ratio from 0.0 to 1.0

top number

Top offset ratio from 0.0 to 1.0

triggerViewportUpdate bool

Set to true to propagate changes, causing the rendering service to adapt immediately to changes, set to false to avoid unnecessary updates.

setTransform(transform, propagateChangesopt)

Set the viewport local transform.

Parameters:
Name Type Attributes Default Description
transform component

Local transform component value

propagateChanges boolean <optional>
true

Default to true. Trigger engineAPI.propagateChanges, on this entity.

setZoomFactor(factor)

Set the zoom factor of an orthographic view. No effect on perspective view. Does call SDK3DVerse.updateControllerSetting to refresh the speed setting of the camera controller. The speed Left/Right/Up/Down moves need to depend on the the zoom factor.

Parameters:
Name Type Description
factor Number

Zoom Factor to apply