Class CameraComponent_EX

Hierarchy

  • CameraComponent
    • CameraComponent_EX

Constructors

  • Create a new CameraComponent instance.

    Parameters

    • system: CameraComponentSystem

      The ComponentSystem that created this Component.

    • entity: Entity

      The Entity that this Component is attached to.

    Returns CameraComponent_EX

Properties

_camera: Camera
_disablePostEffectsLayer: number
_postEffects: PostEffectQueue
_priority: number
aspectRatio: number
onPostRender: Function

Custom function that is called after the camera renders the scene.

onPreRender: Function

Custom function that is called before the camera renders the scene.

Accessors

  • get aspectRatioMode(): number
  • Returns number

  • set aspectRatioMode(arg: number): void
  • Parameters

    • arg: number

    Returns void

  • get calculateProjection(): CalculateMatrixCallback
  • Returns CalculateMatrixCallback

  • set calculateProjection(arg: CalculateMatrixCallback): void
  • Parameters

    • arg: CalculateMatrixCallback

    Returns void

  • get calculateTransform(): CalculateMatrixCallback
  • Returns CalculateMatrixCallback

  • set calculateTransform(arg: CalculateMatrixCallback): void
  • Parameters

    • arg: CalculateMatrixCallback

    Returns void

  • get clearColor(): Color
  • Returns Color

  • set clearColor(arg: Color): void
  • Parameters

    • arg: Color

    Returns void

  • get clearColorBuffer(): boolean
  • Returns boolean

  • set clearColorBuffer(arg: boolean): void
  • If true the camera will clear the color buffer to the color set in clearColor. Defaults to true.

    Parameters

    • arg: boolean

    Returns void

  • get clearDepthBuffer(): boolean
  • Returns boolean

  • set clearDepthBuffer(arg: boolean): void
  • If true the camera will clear the depth buffer. Defaults to true.

    Parameters

    • arg: boolean

    Returns void

  • get clearStencilBuffer(): boolean
  • Returns boolean

  • set clearStencilBuffer(arg: boolean): void
  • If true the camera will clear the stencil buffer. Defaults to true.

    Parameters

    • arg: boolean

    Returns void

  • get cullFaces(): boolean
  • Returns boolean

  • set cullFaces(arg: boolean): void
  • Parameters

    • arg: boolean

    Returns void

  • get disablePostEffectsLayer(): number
  • Returns number

  • set disablePostEffectsLayer(arg: number): void
  • 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.

    Parameters

    • arg: number

    Returns void

  • get enabled(): boolean
  • Returns boolean

  • set enabled(arg: boolean): void
  • Parameters

    • arg: boolean

    Returns void

  • get farClip(): number
  • Returns number

  • set farClip(arg: number): void
  • Parameters

    • arg: number

    Returns void

  • get flipFaces(): boolean
  • Returns boolean

  • set flipFaces(arg: boolean): void
  • Parameters

    • arg: boolean

    Returns void

  • get fov(): number
  • Returns number

  • set fov(arg: number): void
  • Parameters

    • arg: number

    Returns void

  • get frustum(): Frustum
  • Queries the camera's frustum shape.

    Returns Frustum

  • get frustumCulling(): boolean
  • Returns boolean

  • set frustumCulling(arg: boolean): void
  • Parameters

    • arg: boolean

    Returns void

  • get horizontalFov(): boolean
  • Returns boolean

  • set horizontalFov(arg: boolean): void
  • Parameters

    • arg: boolean

    Returns void

  • get layers(): number[]
  • Returns number[]

  • set layers(arg: number[]): void
  • 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].

    Parameters

    • arg: number[]

    Returns void

  • get nearClip(): number
  • Returns number

  • set nearClip(arg: number): void
  • Parameters

    • arg: number

    Returns void

  • get orthoHeight(): number
  • Returns number

  • set orthoHeight(arg: number): void
  • Parameters

    • arg: number

    Returns void

  • get postEffects(): PostEffectQueue
  • Returns PostEffectQueue

  • get postEffectsEnabled(): PostEffectQueue
  • The post effects queue for this camera. Use this to add or remove post effects from the camera.

    Returns PostEffectQueue

  • get priority(): number
  • Returns number

  • set priority(arg: number): void
  • Controls the order in which cameras are rendered. Cameras with smaller values for priority are rendered first. Defaults to 0.

    Parameters

    • arg: number

    Returns void

  • get projection(): number
  • Returns number

  • set projection(arg: number): void
  • Parameters

    • arg: number

    Returns void

  • get projectionMatrix(): Mat4
  • Queries the camera's projection matrix.

    Returns Mat4

  • get rect(): Vec4
  • Returns Vec4

  • set rect(arg: Vec4): void
  • Controls where on the screen the camera will be rendered in normalized screen coordinates. Defaults to [0, 0, 1, 1].

    Parameters

    • arg: Vec4

    Returns void

  • get renderSceneColorMap(): boolean
  • Returns boolean

  • get renderSceneDepthMap(): boolean
  • Returns boolean

  • get renderTarget(): any
  • Returns any

  • set renderTarget(arg: any): void
  • Render target to which rendering of the cameras is performed. If not set, it will render simply to the screen.

    Parameters

    • arg: any

    Returns void

  • get scissorRect(): Vec4
  • Returns Vec4

  • set scissorRect(arg: Vec4): void
  • Parameters

    • arg: Vec4

    Returns void

  • get viewMatrix(): Mat4
  • Queries the camera's view matrix.

    Returns Mat4

Methods

  • Parameters

    • value: any

    Returns boolean

  • Returns void

  • Parameters

    • schema: any

    Returns void

  • Calculates aspect ratio value for a given render target.

    Returns

    The aspect ratio of the render target (or backbuffer).

    Parameters

    • Optional rt: RenderTarget

      Optional render target. If unspecified, the backbuffer is used.

    Returns number

  • Parameters

    • source: any

    Returns void

  • Returns void

  • Attempt to end XR session of this camera.

    Example

    // On an entity with a camera component
    this.entity.camera.endXr(function (err) {
    // not anymore in XR
    });

    Parameters

    • Optional callback: XrErrorCallback

      Optional callback function called once session is ended. The callback has one argument Error - it is null if successfully ended XR session.

    Returns void

  • Fire an event, all additional arguments are passed on to the event listener.

    Returns

    Self for chaining.

    Example

    obj.fire('test', 'This is the message');
    

    Parameters

    • name: string

      Name of event to fire.

    • Optional arg1: any

      First argument that is passed to the event handler.

    • Optional arg2: any

      Second argument that is passed to the event handler.

    • Optional arg3: any

      Third argument that is passed to the event handler.

    • Optional arg4: any

      Fourth argument that is passed to the event handler.

    • Optional arg5: any

      Fifth argument that is passed to the event handler.

    • Optional arg6: any

      Sixth argument that is passed to the event handler.

    • Optional arg7: any

      Seventh argument that is passed to the event handler.

    • Optional arg8: any

      Eighth argument that is passed to the event handler.

    Returns EventHandler

  • 跟随另一个相机(与另一相机的几何信息保持相同)

    Parameters

    • camera: CameraComponent

      要跟随的相机

    Returns void

  • Test if there are any handlers bound to an event name.

    Returns

    True if the object has handlers bound to the specified event name.

    Example

    obj.on('test', function () { }); // bind an event to 'test'
    obj.hasEvent('test'); // returns true
    obj.hasEvent('hello'); // returns false

    Parameters

    • name: string

      The name of the event to test.

    Returns boolean

  • 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.

    Returns

    Self for chaining.

    Example

    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

    Parameters

    • Optional name: string

      Name of the event to unbind.

    • Optional callback: HandleEventCallback

      Function to be unbound.

    • Optional scope: object

      Scope that was used as the this when the event is fired.

    Returns EventHandler

  • Attach an event handler to an event.

    Returns

    Self for chaining.

    Example

    obj.on('test', function (a, b) {
    console.log(a + b);
    });
    obj.fire('test', 1, 2); // prints 3 to the console

    Parameters

    • name: string

      Name of the event to bind the callback to.

    • callback: HandleEventCallback

      Function that is called when event is fired. Note the callback is limited to 8 arguments.

    • Optional scope: object

      Object to use as 'this' when the event is fired, defaults to current this.

    Returns EventHandler

  • Returns void

  • Returns void

  • Returns void

  • Parameters

    • layer: any

    Returns void

  • Parameters

    • layer: any

    Returns void

  • Parameters

    • oldComp: any
    • newComp: any

    Returns void

  • Returns void

  • Returns void

  • Parameters

    • name: any
    • oldValue: any
    • newValue: any

    Returns void

  • Attach an event handler to an event. This handler will be removed after being fired once.

    Returns

    Self for chaining.

    Example

    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

    Parameters

    • name: string

      Name of the event to bind the callback to.

    • callback: HandleEventCallback

      Function that is called when event is fired. Note the callback is limited to 8 arguments.

    • Optional scope: object

      Object to use as 'this' when the event is fired, defaults to current this.

    Returns EventHandler

  • 从此相机发射射线,检测一系列mesh的交点

    Returns

    交点集合

    Parameters

    • ray: Ray

      要检测的射线

    • meshInstances: MeshInstance[]

      要检测的meshInstance集合

    Returns intersect[]

  • Returns void

  • 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.

    Parameters

    • enabled: boolean

      True to request the generation, false to disable it.

    Returns void

  • 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.

    Parameters

    • enabled: boolean

      True to request the generation, false to disable it.

    Returns void

  • Convert a point from 2D screen space to 3D world space.

    Example

    // 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");
    });

    Returns

    The world space coordinate.

    Parameters

    • screenx: number

      X coordinate on PlayCanvas' canvas element. Should be in the range 0 to canvas.offsetWidth of the application's canvas element.

    • screeny: number

      Y coordinate on PlayCanvas' canvas element. Should be in the range 0 to canvas.offsetHeight of the application's canvas element.

    • cameraz: number

      The distance from the camera in world space to create the new point.

    • Optional worldCoord: Vec3

      3D vector to receive world coordinate result.

    Returns Vec3

  • Attempt to start XR session with this camera.

    Example

    // 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
    }
    }
    });

    Parameters

    • type: string

      The type of session. Can be one of the following:

      • XRTYPE_INLINE: Inline - always available type of session. It has limited feature availability and is rendered into HTML element.
      • XRTYPE_VR: Immersive VR - session that provides exclusive access to the VR device with the best available tracking features.
      • XRTYPE_AR: Immersive AR - session that provides exclusive access to the VR/AR device that is intended to be blended with the real-world environment.
    • spaceType: string

      Reference space type. Can be one of the following:

      • XRSPACE_VIEWER: Viewer - always supported space with some basic tracking capabilities.
      • XRSPACE_LOCAL: Local - represents a tracking space with a native origin near the viewer at the time of creation. It is meant for seated or basic local XR sessions.
      • XRSPACE_LOCALFLOOR: Local Floor - represents a tracking space with a native origin at the floor in a safe position for the user to stand. The y-axis equals 0 at floor level. Floor level value might be estimated by the underlying platform. It is meant for seated or basic local XR sessions.
      • XRSPACE_BOUNDEDFLOOR: Bounded Floor - represents a tracking space with its native origin at the floor, where the user is expected to move within a pre-established boundary.
      • XRSPACE_UNBOUNDED: Unbounded - represents a tracking space where the user is expected to move freely around their environment, potentially long distances from their starting point.
    • Optional options: { callback?: XrErrorCallback; depthSensing?: { dataFormatPreference?: string; usagePreference?: string }; imageTracking?: boolean; optionalFeatures?: string[]; planeDetection?: boolean }

      Object with options for XR session initialization.

      • Optional callback?: XrErrorCallback

        Optional callback function called once the session is started. The callback has one argument Error - it is null if the XR session started successfully.

      • Optional depthSensing?: { dataFormatPreference?: string; usagePreference?: string }

        Optional object with depth sensing parameters to attempt to enable XrDepthSensing.

        • Optional dataFormatPreference?: string
        • Optional usagePreference?: string
      • Optional imageTracking?: boolean

        Set to true to attempt to enable XrImageTracking.

      • Optional optionalFeatures?: string[]

        Optional features for XRSession start. It is used for getting access to additional WebXR spec extensions.

      • Optional planeDetection?: boolean

        Set to true to attempt to enable XrPlaneDetection.

    Returns void

  • Convert a point from 3D world space to 2D screen space.

    Returns

    The screen space coordinate.

    Parameters

    • worldCoord: Vec3

      The world space coordinate.

    • Optional screenCoord: Vec3

      3D vector to receive screen coordinate result.

    Returns Vec3

  • Parameters

    • obj: any
    • schema: any

    Returns void