Extends
Members
_fov
Field of view in degrees
_height
height is set by target or canvas size automatically @readonly
_target :Framebuffer2D
Render target for this camera. if null then gl context canvas is used as target.
Type:
_width
width is set by target or canvas size automatically @readonly
(readonly) children :Array.<Transform>
- Source:
- Inherited From:
children Transforms of this. Use Transform#addChild instead of changing this directly.
Type:
- Array.<Transform>
(readonly) id :Number
- Source:
- Inherited From:
a random number assigned at creation.
Type:
- Number
localPos :Vec3
- Source:
- Inherited From:
Translation in localSpace. set Transform#matrixNeedsUpdate true after modifying manually!
Type:
localRot :Quat
- Source:
- Inherited From:
Rotation in localSpace. set Transform#matrixNeedsUpdate true after modifying manually!
Type:
localScale :Vec3
- Source:
- Inherited From:
Scale in localSpace. set Transform#matrixNeedsUpdate true after modifying manually!
Type:
localToWorld :Mat4
- Source:
- Inherited From:
transformation from localSpace to world space. This is used as model matrix in glsl.
Calculated from Transform#localPos,Transform#localRot,Transform#localScale
and Transform#parent matrix.
if Transform#matrixNeedsUpdate is true, it will be recalculated at next Transform#update call.
Type:
matrixNeedsUpdate :Boolean
- Source:
- Inherited From:
if true, Transform#localToWorld is recalculated at next Transform#update call.
This avoids recalculation of matrices after every additional transformation.
Type:
- Boolean
mesh :Mesh
- Source:
- Inherited From:
mesh linked to this transformation.
Type:
(readonly) parent :Transform
- Source:
- Inherited From:
parent transformation of this. It will affect the Transform#localToWorld matrix.
use Transform#setparent instead of changing this directly.
Type:
program :ShaderProgram
- Source:
- Inherited From:
shader program which is used when drawing Transform#mesh
Type:
projectionNeedsUpdate :Boolean
If true, the projection matrix is updated the next time this camera is set active.
This is set true if any of the projection realted parameters have been changed.
This is set true if any of the projection realted parameters have been changed.
Type:
- Boolean
uniforms :Object.<String, Uniform>
- Source:
- Inherited From:
optional uniforms for this transform. they will override the uniforms in Transform#program
Type:
- Object.<String, Uniform>
visible :Boolean
- Source:
- Inherited From:
controls wether this object is rendered or not.
Type:
- Boolean
worldToLocal :Mat4
- Source:
- Inherited From:
transformation from world space to local space. This is just Transform#localToWorld inverted.
Type:
Methods
addChild(child)
- Source:
- Inherited From:
pushes the transform to this.children. Does nothing when given transform is already a child.
Parameters:
Name | Type | Description |
---|---|---|
child |
Transform | new child. |
draw(gl, viewMatrix)
- Source:
- Inherited From:
main method to draw this.mesh. binds the shaderprogram and assigns uniforms to it.
Parameters:
Name | Type | Description |
---|---|---|
gl |
WebglRenderingContext | gl context |
viewMatrix |
Camera | camera that is used to get view and projection |
NDCToWorld(point)
Transforms the vector from NDC to world space.
Parameters:
Name | Type | Description |
---|---|---|
point |
Vec3 | Screen point in NDC(normalized device coordinates). |
onBeforeDraw(gl)
- Source:
- Inherited From:
an overridable method to be called before drawing.
Parameters:
Name | Type | Description |
---|---|---|
gl |
WebglRenderingContext | gl context |
screenToWorld(point)
Transforms the vector from screen pixel coordinates to world space.
Parameters:
Name | Type | Description |
---|---|---|
point |
Vec3 | Screen point in pixel coordinates. |
setActive(gl)
Call this before drawing to set up the gl viewport and update projection matrix if needed.
Parameters:
Name | Type | Description |
---|---|---|
gl |
WebGLRenderingContext |
setParent(parent)
- Source:
- Inherited From:
sets the parent for this transformation object. This affects the localToWorld and worldToLocal matrices.
Parameters:
Name | Type | Description |
---|---|---|
parent |
Transform | new parent. |
update()
- Source:
- Inherited From:
this should be called from your mainloop implementation before rendering a frame.
updateMatrix()
- Source:
- Overrides:
updates localToWorld and worldToLocal matrices.
it Is called from Transform#update if Transform#matrixNeedsUpdate is true.
Also recursively updates the bounds of this and the parent chain.
updateProjectionMatrix()
Updates the projection matrix. This is done automatically if Camera#projectionNeedsUpdate is true when Camera#setActive is called.
updateViewProjectionMatrix()
Updates the viewProjection combined matrix. this is done when camera transformation matrix is updated and if the projection matrix is updated.