@needle-tools/engine
Version:
Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in
108 lines (107 loc) • 3.62 kB
TypeScript
import { Mesh, Vector3 } from "three";
import type { PhysicsMaterial } from "../engine/engine_physics.types.js";
import type { IBoxCollider, ICollider, ISphereCollider } from "../engine/engine_types.js";
import { Behaviour } from "./Component.js";
import { Rigidbody } from "./RigidBody.js";
/**
* Collider is the base class for all colliders. A collider is a physical shape that is used to detect collisions with other objects in the scene.
* Colliders are used in combination with a Rigidbody to create physical interactions between objects.
* Colliders are registered with the physics engine when they are enabled and removed when they are disabled.
* @category Physics
* @group Components
*/
export declare class Collider extends Behaviour implements ICollider {
/** @internal */
get isCollider(): any;
/**
* The Rigidbody that this collider is attached to.
*/
attachedRigidbody: Rigidbody | null;
/**
* When `true` the collider will not be used for collision detection but will still trigger events.
*/
isTrigger: boolean;
/**
* The physics material that is used for the collider. This material defines physical properties of the collider such as friction and bounciness.
*/
sharedMaterial?: PhysicsMaterial;
/**
* The layers that the collider is assigned to.
*/
membership: number[];
/**
* The layers that the collider will interact with.
* @inheritdoc
*/
filter?: number[];
/** @internal */
awake(): void;
/** @internal */
start(): void;
/** @internal */
onEnable(): void;
/** @internal */
onDisable(): void;
/** Returns the underlying physics body from the physics engine (if any) - the component must be enabled and active in the scene */
get body(): any;
/**
* Apply the collider properties to the physics engine.
*/
updateProperties: () => void;
/** Requests an update of the physics material in the physics engine */
updatePhysicsMaterial(): void;
}
/**
* SphereCollider is a collider that represents a sphere shape.
* @category Physics
* @group Components
*/
export declare class SphereCollider extends Collider implements ISphereCollider {
radius: number;
center: Vector3;
onEnable(): void;
onDisable(): void;
onValidate(): void;
}
/**
* BoxCollider is a collider that represents a box shape.
* @category Physics
* @group Components
*/
export declare class BoxCollider extends Collider implements IBoxCollider {
static add(obj: Mesh, opts?: {
rigidbody: boolean;
}): BoxCollider;
size: Vector3;
center: Vector3;
onEnable(): void;
onDisable(): void;
onValidate(): void;
}
/**
* MeshCollider is a collider that represents a mesh shape.
* The mesh collider can be used to create a collider from a mesh.
* @category Physics
* @group Components
*/
export declare class MeshCollider extends Collider {
/**
* The mesh that is used for the collider.
*/
sharedMesh?: Mesh;
/** When `true` the collider won't have holes or entrances.
* If you wan't this mesh collider to be able to *contain* other objects this should be set to `false` */
convex: boolean;
onEnable(): void;
}
/**
* CapsuleCollider is a collider that represents a capsule shape.
* @category Physics
* @group Components
*/
export declare class CapsuleCollider extends Collider {
center: Vector3;
radius: number;
height: number;
onEnable(): void;
}