Nocturna
    Preparing search index...

    Class Cube

    Cube represents the main cubic structure in Nocturna, serving as the central environment for gameplay.

    Responsibilities:

    • Creates and manages the six faces of the cube, each as a Face object.
    • Handles physics setup for each face, including collision detection (especially for the bottom/lava face).
    • Supports observer pattern for collision events (CubeCollisionObserver).
    • Provides serialization for saving/loading cube state.
    • Supports multiplayer setup by adding separators and portal effects for multi-mode.
    • Manages cleanup and disposal of all cube resources.
    Index

    Constructors

    • Constructs a new Cube.

      Parameters

      • scene: Scene

        The Babylon.js scene.

      • size: number

        The size of the cube.

      Returns Cube

    Properties

    Type: string = "Cube"

    Methods

    • Disposes all resources associated with the cube, including faces, meshes, materials, and observers.

      Returns void

    • Returns the main mesh of the cube.

      Returns any

    • Returns the size of the cube.

      Returns number

    • Removes physics bodies from all cube faces.

      Returns void

    • Serializes the cube's position and size for saving or exporting.

      Returns any

      An object containing the cube's position and size.

    • Sets up the cube for multiplayer mode by adding separator platforms and portal effects. Adds physics and materials to the separators.

      Returns void

    • Static factory to create and initialize a Cube in the scene.

      Parameters

      • scene: Scene

        The Babylon.js scene.

      • position: Vector3 = ...

        The position of the cube.

      • size: number

        The size of the cube.

      Returns Cube

      The created Cube instance.