Appearance
@tmrw-realityos/charm • Docs
@tmrw-realityos/charm / Camera
Class: Camera
A camera that can be manipulated in various ways:
- rotate around an axis of choice
- lookAt a coordinate
- orbit around the target coordinate
- move position
- serialized or deserialized to/from JSON
Camera supports perspective and orthographic modes.
Constructors
new Camera()
new Camera():
Camera
Returns
Defined in
packages/charm/src/scene/camera.ts:72
Properties
front
front:
vec3
Defined in
packages/charm/src/scene/camera.ts:63
inv_viewprojection_matrix
inv_viewprojection_matrix:
mat4
Defined in
packages/charm/src/scene/camera.ts:48
model_matrix
model_matrix:
mat4
Defined in
packages/charm/src/scene/camera.ts:47
projection_matrix
projection_matrix:
mat4
Defined in
packages/charm/src/scene/camera.ts:45
right
right:
vec3
Defined in
packages/charm/src/scene/camera.ts:64
top
top:
vec3
Defined in
packages/charm/src/scene/camera.ts:65
view_matrix
view_matrix:
mat4
Defined in
packages/charm/src/scene/camera.ts:44
viewprojection_matrix
viewprojection_matrix:
mat4
Defined in
packages/charm/src/scene/camera.ts:46
_move_vec3
static
_move_vec3:vec3
Defined in
packages/charm/src/scene/camera.ts:306
_rotate_quat
static
_rotate_quat:quat
Defined in
packages/charm/src/scene/camera.ts:336
_rotate_vec3
static
_rotate_vec3:vec3
Defined in
packages/charm/src/scene/camera.ts:334
_rotate_vec3B
static
_rotate_vec3B:vec3
Defined in
packages/charm/src/scene/camera.ts:335
current
static
current:undefined
|Camera
=undefined
Defined in
packages/charm/src/scene/camera.ts:42
Accessors
aspect
get
aspect():number
set
aspect(v
):void
Parameters
• v: number
Returns
number
Defined in
packages/charm/src/scene/camera.ts:122
far
get
far():number
set
far(v
):void
Parameters
• v: number
Returns
number
Defined in
packages/charm/src/scene/camera.ts:136
fov
get
fov():number
set
fov(v
):void
Parameters
• v: number
Returns
number
Defined in
packages/charm/src/scene/camera.ts:115
frustum_size
get
frustum_size():number
set
frustum_size(v
):void
Parameters
• v: number
Returns
number
Defined in
packages/charm/src/scene/camera.ts:144
near
get
near():number
set
near(v
):void
Parameters
• v: number
Returns
number
Defined in
packages/charm/src/scene/camera.ts:129
position
get
position():vec3
set
position(v
):void
Parameters
• v: vec3
Returns
vec3
Defined in
packages/charm/src/scene/camera.ts:152
target
get
target():vec3
set
target(v
):void
Parameters
• v: vec3
Returns
vec3
Defined in
packages/charm/src/scene/camera.ts:159
type
get
type():eCameraType
Returns
eCameraType
Defined in
packages/charm/src/scene/camera.ts:108
up
get
up():vec3
set
up(v
):void
Parameters
• v: vec3
Returns
vec3
Defined in
packages/charm/src/scene/camera.ts:166
Methods
batchUpdate()
batchUpdate(
updater
):void
Postpones calculation of the camera matrices until after a batch of updates.
Parameters
• updater
Returns
void
Defined in
packages/charm/src/scene/camera.ts:581
changeDistanceFactor()
changeDistanceFactor(
f
):void
Parameters
• f: number
Returns
void
Defined in
packages/charm/src/scene/camera.ts:365
configure()
configure(
o
):void
Reads camera attributes from a JSON object
Parameters
• o: ICamera
Returns
void
Defined in
packages/charm/src/scene/camera.ts:483
getLocalVector()
getLocalVector(
v
,result
?):vec3
transform vector (only rotates) from local to global
Parameters
• v: vec3
• result?: vec3
[Optional]
Returns
vec3
local point transformed
Method
getLocalVector
Defined in
packages/charm/src/scene/camera.ts:248
getRayDirection()
getRayDirection(
x
,y
,viewport
,result
?):vec3
returns the direction vector of a ray that passes through a pixel in the screen
Parameters
• x: number
number pixel x
• y: number
number pixel y
• viewport: number
[] | vec4
area of the screen [0,0,w,h]
• result?: vec3
to store the result [optional]
Returns
vec3
the result
Method
getRayDirection
Defined in
packages/charm/src/scene/camera.ts:468
getRayOrigin()
getRayOrigin(
x
,y
,viewport
,result
?):vec3
returns the origin position of a ray that passes through a pixel in the screen
Parameters
• x: number
number pixel x
• y: number
number pixel y
• viewport: number
[] | vec4
area of the screen [0,0,w,h]
• result?: vec3
to store the result [optional]
Returns
vec3
the result
Method
getRayOrigin
Defined in
packages/charm/src/scene/camera.ts:444
getTargetDistance()
getTargetDistance():
number
Returns
number
Defined in
packages/charm/src/scene/camera.ts:376
globalToLocal()
globalToLocal(
v
,result
?):vec3
transform point from global coordinates (world space) to local coordinates (view space)
Parameters
• v: vec3
• result?: vec3
[Optional]
Returns
vec3
local point
Method
globalToLocal
Defined in
packages/charm/src/scene/camera.ts:276
localToGlobal()
localToGlobal(
v
,result
?):vec3
transform point from local to global coordinates
Parameters
• v: vec3
• result?: vec3
[Optional]
Returns
vec3
local point transformed
Method
localToGlobal
Defined in
packages/charm/src/scene/camera.ts:262
lookAt()
lookAt(
position
,target
,up
):void
Parameters
• position: vec3
• target: vec3
• up: vec3
Returns
void
Defined in
packages/charm/src/scene/camera.ts:170
makeCurrent()
makeCurrent():
void
Returns
void
Defined in
packages/charm/src/scene/camera.ts:104
move()
move(
v
,scalar
,isLocal
):void
move the position and the target the same amount so no rotation is produced
Parameters
• v: vec3
global (if local use the thirth parameter)
• scalar: number
= 1
[optional] it will be multiplied by the vector
• isLocal: boolean
= false
[optional] tells v is in local camera space
Returns
void
Method
move
Defined in
packages/charm/src/scene/camera.ts:290
orbit()
orbit(
angleInRadians
,axis
,isLocal
):void
rotate over its target position
Parameters
• angleInRadians: number
in radians
• axis: vec3
• isLocal: boolean
= false
tells v is in local camera space
Returns
void
Method
orbit
Defined in
packages/charm/src/scene/camera.ts:345
orthographic()
orthographic(
frustumSize
,near
,far
,aspect
):void
Parameters
• frustumSize: number
• near: number
• far: number
• aspect: number
Returns
void
Defined in
packages/charm/src/scene/camera.ts:186
perspective()
perspective(
fov
,aspect
,near
,far
):void
Parameters
• fov: number
• aspect: number
• near: number
• far: number
Returns
void
Defined in
packages/charm/src/scene/camera.ts:177
project()
project(
vec
,viewport
,result
?):vec3
projects a point from 3D to 2D
Parameters
• vec: vec3
coordinate to project
• viewport: vec4
viewport
• result?: vec3
alternative return
Returns
vec3
projected point
Method
project
Defined in
packages/charm/src/scene/camera.ts:388
rotate()
rotate(
angleInRadians
,axis
,isLocal
):void
rotate over its position
Parameters
• angleInRadians: number
angle in radians
• axis: vec3
• isLocal: boolean
= false
tells v is in local camera space
Returns
void
Method
rotate
Defined in
packages/charm/src/scene/camera.ts:315
serialize()
serialize():
ICamera
Writes camera attributes to a JSON object
Returns
Defined in
packages/charm/src/scene/camera.ts:500
testAABBInside()
testAABBInside(
center
,halfsize
):eTestResult
Test if AABB defined by center and halfsize is inside the frustum
Parameters
• center: vec3
• halfsize: vec3
Returns
eTestResult
Defined in
packages/charm/src/scene/camera.ts:558
testSphereInside()
testSphereInside(
center
,radius
):eTestResult
Test if a sphere, defined by a center point and a radius, is inside the frustum
Parameters
• center: vec3
• radius: number
Returns
eTestResult
Defined in
packages/charm/src/scene/camera.ts:542
unproject()
unproject(
vec
,viewport
,out
?):vec3
projects a point from 2D to 3D
Parameters
• vec: vec3
3d coordinate to unproject
• viewport: number
[] | vec4
area
• out?: vec3
where to store the result [optional]
Returns
vec3
the projected point
Method
unproject