The ComponentSystem that created this Component.
The Entity that this Component is attached to.
Custom function that is called after the camera renders the scene.
Custom function that is called before the camera renders the scene.
If true the camera will clear the color buffer to the color set in clearColor. Defaults to true.
If true the camera will clear the depth buffer. Defaults to true.
If true the camera will clear the stencil buffer. Defaults to true.
Layer ID of a layer on which the postprocessing of the camera stops being applied to. Defaults to LAYERID_UI, which causes post processing to not be applied to UI layer and any following layers for the camera. Set to undefined for post-processing to be applied to all layers of the camera.
Queries the camera's frustum shape.
An array of layer IDs (Layer#id) to which this camera should belong. Don't push, pop, splice or modify this array, if you want to change it, set a new one instead. Defaults to [LAYERID_WORLD, LAYERID_DEPTH, LAYERID_SKYBOX, LAYERID_UI, LAYERID_IMMEDIATE].
The post effects queue for this camera. Use this to add or remove post effects from the camera.
Controls the order in which cameras are rendered. Cameras with smaller values for priority are rendered first. Defaults to 0.
Queries the camera's projection matrix.
Controls where on the screen the camera will be rendered in normalized screen coordinates. Defaults to [0, 0, 1, 1].
Render target to which rendering of the cameras is performed. If not set, it will render simply to the screen.
Queries the camera's view matrix.
Attempt to end XR session of this camera.
// On an entity with a camera component
this.entity.camera.endXr(function (err) {
// not anymore in XR
});
Optional
callback: XrErrorCallbackOptional callback function called once session is ended. The callback has one argument Error - it is null if successfully ended XR session.
Fire an event, all additional arguments are passed on to the event listener.
Self for chaining.
obj.fire('test', 'This is the message');
Name of event to fire.
Optional
arg1: anyFirst argument that is passed to the event handler.
Optional
arg2: anySecond argument that is passed to the event handler.
Optional
arg3: anyThird argument that is passed to the event handler.
Optional
arg4: anyFourth argument that is passed to the event handler.
Optional
arg5: anyFifth argument that is passed to the event handler.
Optional
arg6: anySixth argument that is passed to the event handler.
Optional
arg7: anySeventh argument that is passed to the event handler.
Optional
arg8: anyEighth argument that is passed to the event handler.
Test if there are any handlers bound to an event name.
True if the object has handlers bound to the specified event name.
obj.on('test', function () { }); // bind an event to 'test'
obj.hasEvent('test'); // returns true
obj.hasEvent('hello'); // returns false
The name of the event to test.
Detach an event handler from an event. If callback is not provided then all callbacks are unbound from the event, if scope is not provided then all events with the callback will be unbound.
Self for chaining.
var handler = function () {
};
obj.on('test', handler);
obj.off(); // Removes all events
obj.off('test'); // Removes all events called 'test'
obj.off('test', handler); // Removes all handler functions, called 'test'
obj.off('test', handler, this); // Removes all handler functions, called 'test' with scope this
Optional
name: stringName of the event to unbind.
Optional
callback: HandleEventCallbackFunction to be unbound.
Optional
scope: objectScope that was used as the this when the event is fired.
Attach an event handler to an event.
Self for chaining.
obj.on('test', function (a, b) {
console.log(a + b);
});
obj.fire('test', 1, 2); // prints 3 to the console
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: objectObject to use as 'this' when the event is fired, defaults to current this.
Attach an event handler to an event. This handler will be removed after being fired once.
Self for chaining.
obj.once('test', function (a, b) {
console.log(a + b);
});
obj.fire('test', 1, 2); // prints 3 to the console
obj.fire('test', 1, 2); // not going to get handled
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: objectObject to use as 'this' when the event is fired, defaults to current this.
Request the scene to generate a texture containing the scene color map. Note that this call is accummulative, and for each enable request, a disable request need to be called.
True to request the generation, false to disable it.
Request the scene to generate a texture containing the scene depth map. Note that this call is accummulative, and for each enable request, a disable request need to be called.
True to request the generation, false to disable it.
Convert a point from 2D screen space to 3D world space.
// Get the start and end points of a 3D ray fired from a screen click position
var start = entity.camera.screenToWorld(clickX, clickY, entity.camera.nearClip);
var end = entity.camera.screenToWorld(clickX, clickY, entity.camera.farClip);
// Use the ray coordinates to perform a raycast
app.systems.rigidbody.raycastFirst(start, end, function (result) {
console.log("Entity " + result.entity.name + " was selected");
});
The world space coordinate.
X coordinate on PlayCanvas' canvas element. Should be in the range
0 to canvas.offsetWidth
of the application's canvas element.
Y coordinate on PlayCanvas' canvas element. Should be in the range
0 to canvas.offsetHeight
of the application's canvas element.
The distance from the camera in world space to create the new point.
Optional
worldCoord: Vec33D vector to receive world coordinate result.
Attempt to start XR session with this camera.
// On an entity with a camera component
this.entity.camera.startXr(pc.XRTYPE_VR, pc.XRSPACE_LOCAL, {
callback: function (err) {
if (err) {
// failed to start XR session
} else {
// in XR
}
}
});
The type of session. Can be one of the following:
Reference space type. Can be one of the following:
Optional
options: { callback?: XrErrorCallback; depthSensing?: { dataFormatPreference?: string; usagePreference?: string }; imageTracking?: boolean; optionalFeatures?: string[]; planeDetection?: boolean }Object with options for XR session initialization.
Optional
callback?: XrErrorCallbackOptional callback function called once the session is started. The callback has one argument Error - it is null if the XR session started successfully.
Optional
depthOptional object with depth sensing parameters to attempt to enable XrDepthSensing.
Optional
dataOptional
usageOptional
imageSet to true to attempt to enable XrImageTracking.
Optional
optionalOptional features for XRSession start. It is used for getting access to additional WebXR spec extensions.
Optional
planeSet to true to attempt to enable XrPlaneDetection.
Static
_build
Create a new CameraComponent instance.