omega-game-engine
    Preparing search index...

    The base class for all renderer behaviours, responsible for drawing meshes to the canvas. This class handles the core rendering logic, including setting up WebGL states, managing shaders, and drawing meshes.

    Hierarchy (View Summary)

    Implements

    Indexable

    • [key: string]: any
    Index

    Constructors

    Properties

    _className: string = "RendererBehaviour"
    _depthRenderbuffer: null | WebGLRenderbuffer = null

    The WebGL renderbuffer object for depth testing in off-screen rendering.

    _framebuffer: null | WebGLFramebuffer = null

    The WebGL framebuffer object used for off-screen rendering.

    _gl: WebGL2RenderingContext

    The WebGL2 rendering context.

    _initialized: boolean = false

    A flag indicating if the behaviour has been initialized.

    _serializationIgnoreKeys: string[]
    _time: number = 0

    The elapsed time since the renderer was initialized.

    _uuid: string
    _worldInverseTransposeMatrixUniformLocation: null | WebGLUniformLocation = null

    The uniform location for the world inverse transpose matrix.

    _worldMatrixUniformLocation: null | WebGLUniformLocation = null

    The uniform location for the world matrix.

    active: boolean = true

    Indicates whether the behaviour is currently active. An inactive behaviour will not have its update method called.

    blendMode: BlendingMode = ...

    The blending mode.

    castShadows: boolean = true
    cullFace: CullFace = CullFace.BACK

    The face culling mode.

    dephMode: DephFunction = DephFunction.Less

    The depth testing mode.

    drawPrimitiveType: GLPrimitiveType = GLPrimitiveType.LINES

    The WebGL primitive type used for drawing the mesh.

    enableBlend: boolean = true

    Determines if blending is enabled.

    enableCullFace: boolean = true

    Determines if face culling is enabled.

    enableDephTest: boolean = true

    Determines if depth testing is enabled.

    faceWinding: FaceWinding = FaceWinding.CounterClockwise

    The face winding order.

    mesh: Mesh

    The mesh data to be rendered.

    name: string = ''
    parent: SceneEntity

    The parent entity to which this behaviour is attached.

    renderLayer: RenderLayer = RenderLayer.OPAQUE

    The render layer.

    shader?: Shader

    The shader program used for rendering.

    writeToDephBuffer: boolean = true

    Determines if writing to the depth buffer is enabled.

    Accessors

    • get transform(): Transform

      Gets the transform component of the parent entity. This provides easy access to the position, rotation, and scale of the entity.

      Returns Transform

    Methods

    • Clears the current render target and returns rendering to the main canvas. This function unbinds the Framebuffer Object and restores the original viewport.

      Returns void

    • Calculates the view, projection, and model-view-projection matrices for a light source. These matrices are used in shadow mapping to render the scene from the light's perspective.

      Parameters

      • cameraTransform: Transform

        The transform of the main camera.

      • light: Light

        The light source entity.

      • OptionalfrustumSize: number = 60.0

        The size of the orthographic frustum used for the light's projection.

      • Optionalnear: number = 0.1

        The near clipping plane of the light's frustum.

      • Optionalfar: number = 200.0

        The far clipping plane of the light's frustum.

      Returns { lightMvpMatrix: mat4; lightProjectionMatrix: mat4; lightViewMatrix: mat4 }

      An object containing the calculated matrices.

    • Draws a line between two specified coordinates using the current shader. This method temporarily uses a vertex buffer to upload the line's data and draws it using GL_LINES.

      Parameters

      • start: Vector3

        The 3D coordinates of the line's starting point, e.g., [x, y, z].

      • end: Vector3

        The 3D coordinates of the line's ending point, e.g., [x, y, z].

      Returns void

    • Draws a single point at the specified coordinates using the current shader. This method temporarily uses a vertex buffer to upload the point's data and draws it using GL_POINTS.

      Parameters

      • point: Vector3

        The 3D coordinates of the point to draw`.

      • OptionalpointSize: number = 10.0

        The size of the point to draw.

      • Optionalshader: Shader = ...

        The shader to use for drawing.

      Returns void

    • Sets the current render target to a specific texture. This function creates or reuses a Framebuffer Object (FBO) and attaches the provided texture. All subsequent drawing calls will be rendered to this texture.

      Parameters

      • texture: WebGLTexture

        The texture to which the scene will be rendered.

      • width: number

        The width of the render target.

      • height: number

        The height of the render target.

      Returns void

    • Starts a new rendering pass to a specific off-screen texture. This function sets up the render target and clears its contents.

      Parameters

      • texture: WebGLTexture

        The texture to which the scene will be rendered.

      • width: number

        The width of the render target.

      • height: number

        The height of the render target.

      • OptionalclearColor: [number, number, number, number] = ...

        The color to clear the framebuffer with. Defaults to a transparent black.

      Returns void

    • Updates the behaviour specifically for editor mode. This method is called on every frame when the engine is in editor mode.

      Parameters

      • elapsed: number

        The time elapsed since the last frame in seconds.

      Returns void