Nocturna
    Preparing search index...

    Class Utils

    Utils provides static utility functions for mesh, vector, and asset operations.

    Index

    Constructors

    Methods

    • Calculates the position of a child relative to its parent node's rotation.

      Parameters

      • parent: ParentNode

        The parent node.

      • position: Vector3

        The local position.

      Returns Vector3

      The transformed global position.

    • Calculates the rotation of a child relative to its parent node's rotation.

      Parameters

      • parent: ParentNode

        The parent node.

      • rotation: Vector3

        The child's rotation.

      Returns Vector3

      The relative rotation as Euler angles.

    • Configures the mesh's position, rotation, scale, and bounding info based on the config.

      Parameters

      • meshes: Mesh[]

        The array of meshes to configure.

      • config: GameObjectConfig

        The configuration object.

      Returns void

    • Creates a mesh loading task for the assets manager.

      Parameters

      • config: GameObjectConfig

        The game object configuration.

      • name: string

        The mesh name.

      • file: string

        The mesh file.

      • callback: (task: any) => void

        Callback when the mesh is loaded.

      Returns MeshAssetTask

    • Creates a Vector3 from a plain object with _x, _y, _z properties.

      Parameters

      • data: any

        The data object.

      Returns Vector3

      The created Vector3 or undefined if data is invalid.

    • Returns the size of a mesh's bounding box.

      Parameters

      • mesh: Mesh

      Returns Vector3

    • Returns the center and radius of a mesh's bounding sphere.

      Parameters

      • mesh: Mesh

      Returns { center: Vector3; radius: number }

    • Calculates the total bounding box for an array of meshes.

      Parameters

      • meshes: Mesh[]

      Returns { maximum: Vector3; minimum: Vector3 }

    • Calculates the total bounding sphere for an array of meshes.

      Parameters

      • meshes: Mesh[]

      Returns { center: Vector3; radius: number }

    • Loads a sound file using the assets manager.

      Parameters

      • assetsManager: AssetsManager

        The assets manager.

      • name: string

        The sound name.

      • file: string

        The sound file path.

      • callback: (sound: StaticSound) => void

        Callback when the sound is loaded.

      • Optionalspatial: boolean

        Whether the sound is spatialized.

      Returns void