import type { Nullable } from "../types"; import { Vector3 } from "../Maths/math.vector"; import type { Mesh } from "../Meshes/mesh"; import type { Scene } from "../scene"; import type { PhysicsImpostor } from "./v1/physicsImpostor"; import type { PhysicsBody } from "./v2/physicsBody"; /** * A helper for physics simulations * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class */ export declare class PhysicsHelper { private _scene; private _physicsEngine; private _hitData; /** * Initializes the Physics helper * @param scene Babylon.js scene */ constructor(scene: Scene); /** * Applies a radial explosion impulse * @param origin the origin of the explosion * @param radiusOrEventOptions the radius or the options of radial explosion * @param strength the explosion strength * @param falloff possible options: Constant & Linear. Defaults to Constant * @returns A physics radial explosion event, or null */ applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable; /** * Applies a radial explosion force * @param origin the origin of the explosion * @param radiusOrEventOptions the radius or the options of radial explosion * @param strength the explosion strength * @param falloff possible options: Constant & Linear. Defaults to Constant * @returns A physics radial explosion event, or null */ applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable; private _applicationForBodies; /** * Creates a gravitational field * @param origin the origin of the gravitational field * @param radiusOrEventOptions the radius or the options of radial gravitational field * @param strength the gravitational field strength * @param falloff possible options: Constant & Linear. Defaults to Constant * @returns A physics gravitational field event, or null */ gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable; /** * Creates a physics updraft event * @param origin the origin of the updraft * @param radiusOrEventOptions the radius or the options of the updraft * @param strength the strength of the updraft * @param height the height of the updraft * @param updraftMode possible options: Center & Perpendicular. Defaults to Center * @returns A physics updraft event, or null */ updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable; /** * Creates a physics vortex event * @param origin the of the vortex * @param radiusOrEventOptions the radius or the options of the vortex * @param strength the strength of the vortex * @param height the height of the vortex * @returns a Physics vortex event, or null * A physics vortex event or null */ vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable; private _copyPhysicsHitData; } /** * Represents a physics radial explosion event */ declare class PhysicsRadialExplosionEvent { private _scene; private _options; private _sphere; private _dataFetched; /** * Initializes a radial explosion event * @param _scene BabylonJS scene * @param _options The options for the vortex event */ constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions); /** * Returns the data related to the radial explosion event (sphere). * @returns The radial explosion event data */ getData(): PhysicsRadialExplosionEventData; private _getHitData; /** * Returns the force and contact point of the body or false, if the body is not affected by the force/impulse. * @param body A physics body where the transform node is an AbstractMesh * @param origin the origin of the explosion * @param data the data of the hit * @param instanceIndex the instance index of the body * @returns if there was a hit */ getBodyHitData(body: PhysicsBody, origin: Vector3, data: PhysicsHitData, instanceIndex?: number): boolean; /** * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse. * @param impostor A physics imposter * @param origin the origin of the explosion * @param data the data of the hit * @returns A physics force and contact point, or null */ getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3, data: PhysicsHitData): boolean; /** * Triggers affected impostors callbacks * @param affectedImpostorsWithData defines the list of affected impostors (including associated data) */ triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array): void; /** * Triggers affected bodies callbacks * @param affectedBodiesWithData defines the list of affected bodies (including associated data) */ triggerAffectedBodiesCallback(affectedBodiesWithData: Array): void; /** * Disposes the sphere. * @param force Specifies if the sphere should be disposed by force */ dispose(force?: boolean): void; /*** Helpers ***/ private _prepareSphere; private _intersectsWithSphere; } /** * Represents a gravitational field event */ declare class PhysicsGravitationalFieldEvent { private _physicsHelper; private _scene; private _origin; private _options; private _tickCallback; private _sphere; private _dataFetched; /** * Initializes the physics gravitational field event * @param _physicsHelper A physics helper * @param _scene BabylonJS scene * @param _origin The origin position of the gravitational field event * @param _options The options for the vortex event */ constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions); /** * Returns the data related to the gravitational field event (sphere). * @returns A gravitational field event */ getData(): PhysicsGravitationalFieldEventData; /** * Enables the gravitational field. */ enable(): void; /** * Disables the gravitational field. */ disable(): void; /** * Disposes the sphere. * @param force The force to dispose from the gravitational field event */ dispose(force?: boolean): void; private _tick; } /** * Represents a physics updraft event */ declare class PhysicsUpdraftEvent { private _scene; private _origin; private _options; private _physicsEngine; private _originTop; private _originDirection; private _tickCallback; private _cylinder; private _cylinderPosition; private _dataFetched; private static _HitData; /** * Initializes the physics updraft event * @param _scene BabylonJS scene * @param _origin The origin position of the updraft * @param _options The options for the updraft event */ constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions); /** * Returns the data related to the updraft event (cylinder). * @returns A physics updraft event */ getData(): PhysicsUpdraftEventData; /** * Enables the updraft. */ enable(): void; /** * Disables the updraft. */ disable(): void; /** * Disposes the cylinder. * @param force Specifies if the updraft should be disposed by force */ dispose(force?: boolean): void; private _getHitData; private _getBodyHitData; private _getImpostorHitData; private _tick; /*** Helpers ***/ private _prepareCylinder; private _intersectsWithCylinder; } /** * Represents a physics vortex event */ declare class PhysicsVortexEvent { private _scene; private _origin; private _options; private _physicsEngine; private _originTop; private _tickCallback; private _cylinder; private _cylinderPosition; private _dataFetched; private static _OriginOnPlane; private static _HitData; /** * Initializes the physics vortex event * @param _scene The BabylonJS scene * @param _origin The origin position of the vortex * @param _options The options for the vortex event */ constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions); /** * Returns the data related to the vortex event (cylinder). * @returns The physics vortex event data */ getData(): PhysicsVortexEventData; /** * Enables the vortex. */ enable(): void; /** * Disables the cortex. */ disable(): void; /** * Disposes the sphere. * @param force */ dispose(force?: boolean): void; private _getHitData; private _getBodyHitData; private _getImpostorHitData; private _tick; /*** Helpers ***/ private _prepareCylinder; private _intersectsWithCylinder; } /** * Options fot the radial explosion event * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class */ export declare class PhysicsRadialExplosionEventOptions { /** * The radius of the sphere for the radial explosion. */ radius: number; /** * The strength of the explosion. */ strength: number; /** * The strength of the force in correspondence to the distance of the affected object */ falloff: PhysicsRadialImpulseFalloff; /** * Sphere options for the radial explosion. */ sphere: { segments: number; diameter: number; }; /** * Sphere options for the radial explosion. */ affectedImpostorsCallback: (affectedImpostorsWithData: Array) => void; /** * Sphere options for the radial explosion. */ affectedBodiesCallback: (affectedBodiesWithData: Array) => void; } /** * Options fot the updraft event * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class */ export declare class PhysicsUpdraftEventOptions { /** * The radius of the cylinder for the vortex */ radius: number; /** * The strength of the updraft. */ strength: number; /** * The height of the cylinder for the updraft. */ height: number; /** * The mode for the updraft. */ updraftMode: PhysicsUpdraftMode; } /** * Options fot the vortex event * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class */ export declare class PhysicsVortexEventOptions { /** * The radius of the cylinder for the vortex */ radius: number; /** * The strength of the vortex. */ strength: number; /** * The height of the cylinder for the vortex. */ height: number; /** * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1 */ centripetalForceThreshold: number; /** * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the threshold. */ centripetalForceMultiplier: number; /** * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the threshold. */ centrifugalForceMultiplier: number; /** * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex. */ updraftForceMultiplier: number; } /** * The strength of the force in correspondence to the distance of the affected object * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class */ export declare enum PhysicsRadialImpulseFalloff { /** Defines that impulse is constant in strength across it's whole radius */ Constant = 0, /** Defines that impulse gets weaker if it's further from the origin */ Linear = 1 } /** * The strength of the force in correspondence to the distance of the affected object * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class */ export declare enum PhysicsUpdraftMode { /** Defines that the upstream forces will pull towards the top center of the cylinder */ Center = 0, /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */ Perpendicular = 1 } /** * Interface for a physics hit data * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class */ export interface PhysicsHitData { /** * The force applied at the contact point */ force: Vector3; /** * The contact point */ contactPoint: Vector3; /** * The distance from the origin to the contact point */ distanceFromOrigin: number; /** * For an instanced physics body (mesh with thin instances), the index of the thin instance the hit applies to */ instanceIndex?: number; } /** * Interface for radial explosion event data * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class */ export interface PhysicsRadialExplosionEventData { /** * A sphere used for the radial explosion event */ sphere: Mesh; } /** * Interface for gravitational field event data * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class */ export interface PhysicsGravitationalFieldEventData { /** * A sphere mesh used for the gravitational field event */ sphere: Mesh; } /** * Interface for updraft event data * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class */ export interface PhysicsUpdraftEventData { /** * A cylinder used for the updraft event */ cylinder?: Mesh; } /** * Interface for vortex event data * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class */ export interface PhysicsVortexEventData { /** * A cylinder used for the vortex event */ cylinder: Mesh; } /** * Interface for an affected physics impostor * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class */ export interface PhysicsAffectedImpostorWithData { /** * The impostor affected by the effect */ impostor: PhysicsImpostor; /** * The data about the hit/force from the explosion */ hitData: PhysicsHitData; } /** * Interface for an affected physics body * @see */ export interface PhysicsAffectedBodyWithData { /** * The impostor affected by the effect */ body: PhysicsBody; /** * The data about the hit/force from the explosion */ hitData: PhysicsHitData; } export {};