SgCamera

Reference

class Projection

Enumeration of the available projection modes

Name

Description

Perspective

perspective projection

Orthographic

orthographic projection

class CameraMode

Enumeration of the available camera modes

Name

Description

Free

Camera uses transform to freely rotate

LookAt

Camera uses the lookAt/upVector to handle rotation of the camera

class SgCamera
module:

Camera

create(options, parent)

Create a new camera object in the scenegraph.

Parameters:
  • options (table) – A table of options to fill the parameters

  • parent (SceneObject) – The parent scene object to add this to

Returns:

a promise which will resolve to the created object

Return type:

Promise

Usage:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
-- Options can be omitted. This example shows the defaults,
-- only specify the ones you want different.
SgCamera:create({
    active = true,
    name = "",
    transform = Transform.new(),
    layers = {0},
    tags = {},
    type = SgCamera.Projection.Perspective,
    fieldOfView = 60,
    left = -1,
    right = 1,
    top = -1,
    bottom = 1,
    nearPlane = 0.1,
    farPlane = 1000,
    mode = SgCamera.CameraMode.Free,
    lookAt = Vector3.new(0, 0, 0),
    upVector = Vector3.new(0, 1, 0)
})
fromObject(obj)

Create a camera from an object

Parameters:

obj (Object) – The object to cast

setDefault()

setDefault

fromHandle(handle, nodeId)

create a camera object from a handle. Used internally.

Parameters:
  • handle (number)

  • nodeId (str)

Returns:

result object

Return type:

SgCamera

activate()

activate the camera

lookAt(x, y, z)

Set the look at position of the camera. Camera need to be in look at mode for this to have an effect

Parameters:
  • x (number)

  • y (number)

  • z (number)

setUpVector(x, y, z)

Set up vector of the camera

Parameters:
  • x (number)

  • y (number)

  • z (number)

getProjectionMatrix()

Examples