new Camera(width, height, distance, target, ortho, up)
Create a combined camera (orthographic and persepctive).
Parameters:
Name | Type | Description |
---|---|---|
width |
number | canvas width. |
height |
number | canvas height. |
distance |
number | distance from the lookAt point. |
target |
THREE.Vector3 | target (Vector3) to look at. |
ortho |
boolean | flag whether the initial camera should be orthographic. |
up |
string | Z or Y to define whether Z or Y direction is camera up. |
Methods
dispose()
Remove assets.
getCamera() → {THREE.Camera}
Get the current camera.
Returns:
Camera object.
- Type
- THREE.Camera
getPosition() → {THREE.Vector3}
Get the current camera position.
Returns:
camera position.
- Type
- THREE.Vector3
getQuaternion() → {THREE.Quaternion}
Get the current camera quaternion.
Returns:
camera quaternion.
- Type
- THREE.Quaternion
getRotation() → {THREE.Euler}
Get the current camera rotation.
Returns:
camera rotation.
- Type
- THREE.Euler
getZoom() → {number}
Return current zoom value.
Returns:
zoom value.
- Type
- number
lookAtTarget()
Set the lookAt point for the camera to the provided target.
presetCamera(dir)
Move the camera to a given preset.
Parameters:
Name | Type | Description |
---|---|---|
dir |
string | can be "iso", "top", "bottom", "front", "rear", "left", "right" |
projectSize(frustum, aspect)
Calculate projected size for orthographic ca,era
Parameters:
Name | Type | Description |
---|---|---|
frustum |
number | view frustum. |
aspect |
number | viewer aspect (width / height). |
setPosition(relative, position)
Set camera position.
Parameters:
Name | Type | Description |
---|---|---|
relative |
boolean | flag whether the position is a relative (e.g. [1,1,1] for iso) or absolute point. |
position |
Array(3) | THREE.Vector3 | position as 3 dim Array [x,y,z] or as Vector3. |
setQuaternion(quaternion)
Set camera quaternion.
Parameters:
Name | Type | Description |
---|---|---|
quaternion |
Array(4) | THREE.Quaternion | quaternion as 4 dim Array or as Quaternion. |
setZoom(val)
Set zoom value.
Parameters:
Name | Type | Description |
---|---|---|
val |
number | float zoom value. |
setupCamera(relative, position, quaternion, zoom)
Setup the current camera.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
relative |
boolean | flag whether the position is a relative (e.g. [1,1,1] for iso) or absolute point. | |
position |
THREE.Vector3 | null | the camera position (relative or absolute). |
quaternion |
THREE.Quaternion | null | the camera rotation expressed by a quaternion. |
zoom |
number | null | zoom value. |
switchCamera(ortho_flag)
Switch between orthographic and perspective camera.
Parameters:
Name | Type | Description |
---|---|---|
ortho_flag |
boolean | true for orthographic camera, else persepctive camera. |
updateProjectionMatrix()
Update current camera's projection matrix.