kick.scene.Camera Class
Creates a game camera
Constructor
kick.scene.Camera
-
configuration
Parameters:
-
configuration
Configwith same properties as the Camera
Example:
// create a game object in [0,0,0] facing down the -z axis
var cameraObject = engine.activeScene.createGameObject();
cameraObject.transform.position = [0,0,5];
// create a orthographic camera
var camera = new kick.scene.Camera({
perspective: false,
left:-5,
right:5,
top:5,
bottom:-5
});
cameraObject.addComponent(camera);
Item Index
Methods
Properties
Events
Methods
activated
()
Handles the camera setup (get fast reference to transform and glcontext). Also register component listener on scene
compareRenderOrder
-
a
-
b
Compare two objects based on renderOrder value, then on material.shader.uid (if exist) and finally on mesh.
Parameters:
-
a
Component -
b
Component
Returns:
Number
componentAdded
-
component
Add components that implements the render function and match the camera layerMask to cameras renderable components
Parameters:
-
component
kick.scene.Component
componentRemoved
-
component
Parameters:
-
component
kick.scene.Component
Returns:
deactivated
()
Deregister component listener on scene
destroy
()
Destroy camera component
pick
-
gameObjectPickedFn
-
x
-
y
-
[width=1]
-
[height=1]
Schedules a camera picking session. During next repaint a picking session is done. If the pick hits some game objects, then a callback is added to the event queue (and will run in next frame). Note since the WebGL window coordinate has the origin in the lower left corner and browsers coordinate system has the origin in the upper left corner, you may need to compute y as canvas.height - mouseCoordinate.y
Parameters:
-
gameObjectPickedFn
Functioncallback function with the signature function(gameObject, hitCount)
-
x
Numbercoordinate in screen coordinates (between 0 and canvas width - 1)
-
y
Numbercoordinate in screen coordinates (between 0 and canvas height - 1)
-
[width=1]
Number optional -
[height=1]
Number optional
pickPoint
-
gameObjectPickedFn
-
x
-
y
Schedules a camera picking session. During next repaint a picking session is done. If the pick hits some game objects, then a callback is added to the event queue (and will run in next frame). The pickObject can be used for getting UV coordinate for the point (if available)
Parameters:
-
gameObjectPickedFn
Functioncallback function with the signature function(pickObject)
-
x
Numbercoordinate in screen coordinates (between 0 and canvas width - 1)
-
y
Numbercoordinate in screen coordinates (between 0 and canvas height - 1)
render
-
engineUniforms
-
[overwriteMaterial]
Abstract method called every at every rendering of the object. May be undefined.
Parameters:
-
engineUniforms
kick.scene.EngineUniforms -
[overwriteMaterial]
kick.material.Material optional
renderSceneObjects
-
sceneLightObj
-
shader
Parameters:
-
sceneLightObj
Object -
shader
Object
setupCamera
()
Clear the screen and set the projectionMatrix and modelViewMatrix on the glState object. Called during renderScene
setupClearFlags
-
clearColor
-
clearDepth
Reset the camera clear flags
Parameters:
-
clearColor
Boolean -
clearDepth
Boolean
toJSON
()
Object
Serialize object
Returns:
data object
update
()
Abstract method called every update. May be undefined.
Properties
aabb
kick.math.Aabb
Defines the axis aligned bounding box used for view frustum culling May be undefined or null.
bottom
Number
Only used when orthogonal camera type (!cameraTypePerspective). Default -1
cameraIndex
Number
The sorting order when multiple cameras exists in the scene.
Cameras with lowest number is rendered first.
Default: 1
clearColor
kick.math.Vec4
Only used when orthogonal camera type (!cameraTypePerspective). Default [0,0,0,1]
clearFlagColor
Boolean
Indicates if the camera should clear color buffer.
Default value is true
clearFlagDepth
Boolean
Indicates if the camera should clear the depth buffer.
Default is true.
componentType
String
final
Name of the component componentType = "camera".
Example:
var camera = gameObject.camera;
enabled
Boolean
Default is true
far
Number
Set the far clipping plane of the view volume
Used in both perspective and orthogonale camera.
Default 1000.0
fieldOfView
Number
Set the field of view Y in degrees
Only used when perspective camera type. Default 60.0.
Must be between 1 and 179
gameObject
kick.scene.GameObject
The gameObject owning the component. Initially undefined. The value is set when the Component object is added to a GameObject
layerMask
Number
Camera renders only objects where the components layer exist in the layer mask.
left
Number
Only used for orthogonal camera type (!cameraTypePerspective). Default -1
near
Number
Set the near clipping plane of the view volume
Used in both perspective and orthogonale camera.
Default 0.1
normalizedViewportRect
Array_Number
Normalized viewport rect [xOffset,yOffset,xWidth,yHeight]
Default is [0,0,1,1]
perspective
Boolean
True means camera is perspective projection, false means orthogonale projection
Default true
renderOrder
Number
Default value is 1000
< 1999 default geometry
1999 skybox
2001 - 2999 transparent geometry (sorted back-to-front when rendered)
> 3000 overlay geometry rendered on top
renderShadow
Boolean
Default false
renderTarget
kick.texture.RenderTexture
Set the render target of the camera. Null means screen framebuffer.
replacementMaterial
kick.material.Shader
Allows usage of replacement material on camera rendering Default value is null.
right
Number
Only used for orthogonal camera type (!cameraTypePerspective). Default 1
scriptPriority
Number
Components with largest priority are invoked first. (optional - default 0). Cannot be modified after creation.
top
Number
Only used when orthogonal camera type (!cameraTypePerspective). Default 1
viewportRect
Array_Number
Viewport rect [xOffset,yOffset,xWidth,yHeight]
Events
componentUpdated
Fire events when components are updated. May be undefined. Must be defined before adding to gameObject.
Event Payload:
-
component
kick.scene.Component