Hierarchy

  • __type<typeof Group, this> & Group<this>
    • RigidBodyComponent

Accessors

  • get disposed(): boolean
  • Gets the disposed status of the entity.

    Returns boolean

    The disposed status.

  • get elementsResolved(): any[]
  • An array of the elements that this component instance exposes. In the case that this component does not expose any elements of its own, this will be an array of the elements exposed by this component's children.

    Returns any[]

  • get lockedResolved(): boolean
  • Returns true if this component, or any of its parents, are marked as locked.

    Returns boolean

Constructors

Methods

  • Returns [[number, number, number], [number, number, number, number]]

  • Parameters

    • position: Vector3
    • quaternion: Quaternion
    • scene: Scene

    Returns void

  • Adds a behavior to the component.

    Parameters

    • b: Behavior<Component<any, ConstructorProps>>

      The behavior to add.

    Returns void

  • Parameters

    • c: Component<any, ConstructorProps>

    Returns void

  • Applies a force to a physics body at a given location.

    Parameters

    • force: Vector3 | [number, number, number]

      The force vector to apply.

    • Optionallocation: Vector3 | [number, number, number]

      The location in world space to apply the impulse.

      This method is useful for applying a force to a physics body at a given location. This can be used to simulate physical forces such as explosions, collisions, and gravity.

      If location is not provided, the force will be applied to the center of the body.

    Returns void

  • Applies an impulse to a physics body at a given location.

    Parameters

    • impulse: Vector3 | [number, number, number]

      The impulse vector to apply.

    • Optionallocation: Vector3 | [number, number, number]

      The location in world space to apply the impulse.

      This method is useful for applying an impulse to a physics body at a given location. This can be used to simulate physical forces such as explosions, collisions, and gravity.

      If location is not provided, the impulse will be applied to the center of the body.

    Returns void

  • Parameters

    • component: Component<any, ConstructorProps>

    Returns void

  • Constructs the children of this component.

    Parameters

    • children: ComponentChildren
    • OptionalcontextManager: ContextManager

    Returns void

  • Returns any

  • Returns never

  • Gets the angular damping of a physics body.

    Returns number

    The angular damping of the body.

    This function is useful for retrieving the angular damping of a physics body, which is used to control the rotational motion of the body. The angular damping is a value between 0 and 1, where 0 is no damping and 1 is full damping.

  • Gets a behavior of a specific type from the component.

    Type Parameters

    • T extends (new (contextManager: ContextManager, instance: Component<any, ConstructorProps>, ...args: any[]) => Behavior<Component<any, ConstructorProps>>)

      The behavior type.

    Parameters

    • type: T

      The type of behavior to get.

    Returns undefined | InstanceType<T>

    The behavior of the specified type, or undefined if no such behavior exists.

  • Gets all behaviors of a specific type from the component.

    Type Parameters

    • T extends (new (contextManager: ContextManager, instance: Component<any, ConstructorProps>, ...args: any[]) => Behavior<Component<any, ConstructorProps>>)

      The behavior type.

    Parameters

    • type: T

      The type of behaviors to get.

    Returns InstanceType<T>[]

    An array of behaviors of the specified type.

  • Gets the gravity factor of a body.

    Returns number

    The gravity factor of the body.

  • Gets the linear damping of a physics body.

    Returns number

    The linear damping of the body.

  • Gets the linear velocity of a physics body and stores it in a given vector.

    Parameters

    • linVel: Vector3

    Returns void

  • Gets the mass properties of a physics body.

    Returns PhysicsMassProperties

    The mass properties of the body.

  • Get the instance of the ZComponent that constructed this entity.

    If you pass the class of a ZComponent as the type parameter, this function will ensure that it returns an instance of that ZComponent. If this component or behavior was constructed by a different ZComponent class, or by a different entity altogether, the function with throw an error.

    Type Parameters

    • T extends ZComponent<any, T> = ZComponent<any>

    Parameters

    • Optionaltype: ConstructorForComponent<T>

      The ZComponent class that you are expecting to receive

    Returns T

    The instance of the ZComponent that constructed this component or behavior

  • Register a function to be called when an Event is fired, or an Observable's value changes. The function will only be bound to the underlying Event or Observable while this entity is enabled.

    Using this function, rather than attaching your handler directly to the Event or Observable, ensures your handler is automatically released when this entity is disposed.

    Type Parameters

    • Args extends any[]

    Parameters

    • evt: Event<Args>

      The Event or Observable to listen to

    • fn: ((...args: Args) => void)

      A function that will be called when the event fires, or the Observable value changes

        • (...args): void
        • Parameters

          Returns void

    • Optionalpriority: number

    Returns any

  • Type Parameters

    • Args extends any[]

    Parameters

    Returns any

  • Type Parameters

    • Type

    Parameters

    • observable: Observable<Type, never>
    • fn: ((v: Type) => void)
        • (v): void
        • Parameters

          Returns void

    • Optionalpriority: number

    Returns any

  • Type Parameters

    • Type

    Parameters

    Returns any

  • Removes this component from its parent component.

    Returns void

  • Removes a behavior from the component.

    Parameters

    • b: Behavior<Component<any, ConstructorProps>>

      The behavior to remove.

    Returns void

  • Parameters

    • c: Component<any, ConstructorProps>

    Returns void

  • Sets the angular damping of a physics body.

    Parameters

    • damping: number

      The angular damping value to set.

      This function is useful for controlling the angular velocity of a physics body. By setting the angular damping, the body's angular velocity will be reduced over time, allowing for more realistic physics simulations.

    Returns void

  • Sets the angular velocity of a physics body.

    Parameters

    • angVel: Vector3 | [number, number, number]

      The angular velocity vector to set.

    Returns void

  • Sets the gravity factor of a body.

    Parameters

    • factor: number

      The gravity factor to set.

    Returns void

  • Sets the linear damping of the given body.

    Parameters

    • damping: number

      The linear damping to set.

      This method is useful for controlling the linear damping of a body in a physics engine. Linear damping is a force that opposes the motion of the body, and is proportional to the velocity of the body. This method allows the user to set the linear damping of a body, which can be used to control the motion of the body.

    Returns void

  • Sets the linear velocity of a physics body.

    Parameters

    • linVel: Vector3 | [number, number, number]

      The linear velocity vector to set.

    Returns void

  • Sets the motion type of a physics body. Can be STATIC, DYNAMIC, or KINEMATIC.

    Parameters

    Returns void

  • Unregisters a function that was previously registered to an Event or Observable.

    Type Parameters

    • Args extends any[]

    Parameters

    • evt: Event<Args>

      The Event or Observable

    • fn: ((...args: Args) => void)

      The function that was passed in the call to register

        • (...args): void
        • Parameters

          Returns void

    Returns any

  • Type Parameters

    • Type

    Parameters

    • observable: Observable<Type, never>
    • fn: ((v: Type) => void)
        • (v): void
        • Parameters

          Returns void

    Returns any

Other

tags: Observable<string[], never>

An array of string 'tags' assocated with this component.

The getComponentsByTag(mgr, tag) function can be used to get an array of components with the supplied tag.

By default, tags are scoped to the ZComponent instance that a component is constructed by. Tags that begin with global: are scoped to the experience as a whole.

0

Properties - Appearance

castShadow: Observable<boolean, never>

Determines if this object casts shadows.

11

true

receiveShadow: Observable<boolean, never>

Determines if this object receives shadows.

11

true

visible: Observable<boolean, never>

Determines if this object and its children are rendered to the screen.

11

true

Properties - Behavior

enabled: Observable<boolean, never>

If false, this entity and its children will no longer participate in the experience.

Note - to read this value, you may wish to use enabledResolved which will be false if this entity, or any of its parents, have enabled set to false.

The precise implications of enabled being false will vary between entities, but in general disabled entities:

  • should not emit any events,
  • should not take any action, e.g. navigate the user to a different page,
  • should not perform any network communication,
  • should not make changes to other behaviors or components in the experience,
  • should minimise any runtime performance cost (e.g. detach from any frame handlers).

true

10

Properties - Collider Properties

bounciness: Observable<number, never> = ...

Sets the bounciness of the physics material.z

The bounciness is a factor which describes, the amount of energy that is retained after a collision, which should be a number between 0 and 1..

A bounciness of 0 means that no energy is retained and the objects will not bounce off each other, while a bounciness of 1 means that all energy is retained and the objects will bounce.

Note, though, due that due to the simulation implementation, an object with a bounciness of 1 may still lose energy over time.

If not provided, a default value of 0 will be used.

0

proportion

friction: Observable<number, never> = ...

Sets the friction used by this material

The friction determines how much an object will slow down when it is in contact with another object. This is important for simulating realistic physics, such as when an object slides across a surface.

If not provided, a default value of 0.5 will be used.

0.5

proportion

Properties - Damping

angularDamping: Observable<number, never> = ...

Sets the angular damping of a physics body.

This function is useful for controlling the angular velocity of a physics body. By setting the angular damping, the body's angular velocity will be reduced over time, allowing for more realistic physics simulations.

0

24

linearDamping: Observable<number, never> = ...

Sets the linear damping of the given body.

This method is useful for controlling the linear damping of a body in a physics engine. Linear damping is a force that opposes the motion of the body, and is proportional to the velocity of the body. This method allows the user to set the linear damping of a body, which can be used to control the motion of the body.

0

24

Properties - Density

density: Observable<number, never> = ...

Sets the density of a physics shape.

0

24

Properties - Grab

grabbable: boolean = false

When true, the object can be picked up using the RigidbodyGrabber component.

The rigid body must have a DYNAMIC motion type to be grabbable.

false

24

Properties - Gravity

gravityFactor: Observable<number, never> = ...

Sets the gravity factor of a body.

1

23

Properties - Mass

centerOfMass: Observable<undefined | [number, number, number], never> = ...

Defaults to the center of the rigid body. The center of mass, in local space. This is The point the body will rotate around when applying an angular velocity.

If not provided, the physics engine will compute an appropriate value.

22

[0,0,0]

inertia: Observable<undefined | [number, number, number], never> = ...

The principal moments of inertia of this object for a unit mass. This determines how easy it is for the body to rotate. A value of zero on any axis will be used as infinite interia about that axis.

If not provided, the physics engine will compute an appropriate value.

22

[0,0,0]

inertiaOrientation: Observable<undefined | [number, number, number, number], never> = ...

The rotation rotating from inertia major axis space to parent space (i.e., the rotation which, when applied to the 3x3 inertia tensor causes the inertia tensor to become a diagonal matrix). This determines how the values of inertia are aligned with the parent object.

If not provided, the physics engine will compute an appropriate value.

22

[0,0,0,0]

mass: Observable<undefined | number, never> = ...

The total mass of this object, in kilograms. This affects how easy it is to move the body. A value of zero will be used as an infinite mass.

If not provided, the physics engine will compute an appropriate value.

22

0

Properties - Other

_dirtyFlags: {
    angularDamping: boolean;
    density: boolean;
    gravityFactor: boolean;
    linearDamping: boolean;
    massProperties: boolean;
    motionType: boolean;
    targetTransform: boolean;
    transforms: boolean;
} = ...
behaviors: Behavior<Component<any, ConstructorProps>>[]

The behaviors attached to this component.

bodyId: HP_ShapeId

Identifier for the physics body associated with this collider in the physics world.

children: Component<any, ConstructorProps>[]

The children of this component.

colliders: Collider[] = []
containerShapeID: HP_ShapeId

Identifier for the shape used in the physics engine.

contextManager: ContextManager
element: Group

The THREE.Group object that represents this component.

enabledResolved: Observable<boolean, never>

This will have value false if this entity, or any of its parents, have enabled set to false.

To change the enabled status of this entity, use the enabled property instead.

The precise implications of enabled being false will vary between entities, but in general disabled entities:

  • should not emit any events,
  • should not take any action, e.g. navigate the user to a different page,
  • should not perform any network communication,
  • should not make changes to other behaviors or components in the experience,
  • should minimise any runtime performance cost.

Disabled entities will typically remain visible (if they have a visible appearance).

isRigidBody: true = ...
locked?: boolean

If true, this component can't be selected at design time in the 3D preview.

lookAt: Observable<undefined | [number, number, number], never>
motionType: Observable<MotionType, never> = ...

Sets the motion type of a physics body.

  • Static: The body is not affected by forces or collisions. It remains fixed in place unless moved manually. Use this for objects that should not move or interact with other physics objects, such as walls or stationary obstacles.

  • Dynamic: The body is affected by forces and collisions. It responds to gravity, collisions, and other physical interactions. Use this for objects that should have realistic physics behavior, such as falling boxes, projectiles, or characters.

  • Kinematic: The body is not affected by forces, but can be moved by setting its transform. It does not respond to collisions. Use this for objects that need to be animated or moved programmatically, such as moving platforms or camera-controlled objects. Note: Kinematic objects can suffer from teleportation issues and may clip through other objects if animated too quickly.

Dynamic

onClick: Event<[ThreePointerPresentEvent]>
onCollision: Event<[IPhysicsCollisionEvent]> = ...
onDispose: Event<[]>

An event that is fired as the last act of this entity being destroyed.

onGrab: Event<[RigidbodyGrabber]> = ...

Emit when a RigidbodyGrabber grabs the object.

onGrabInRange: Event<[RigidbodyGrabber]> = ...

Emitted when a RigidbodyGrabber is within range of the object.

onGrabOutOfRange: Event<[RigidbodyGrabber]> = ...

Emitted when a RigidbodyGrabber is within range of the object.

onIntersectionEnter: Event<[IntersectionPresentEvent]>
onIntersectionLeave: Event<[IntersectionEvent]>
onPointerDown: Event<[ThreePointerPresentEvent]>
onPointerEnter: Event<[ThreePointerPresentEvent]>
onPointerLeave: Event<[ThreePointerEvent]>
onPointerMove: Event<[ThreePointerPresentEvent]>
onPointerUp: Event<[ThreePointerPresentEvent]>
onRelease: Event<[RigidbodyGrabber]> = ...

Emitted when a RigidbodyGrabber releases the object.

parent?: Component<any, ConstructorProps>

The parent of this component.

physicsContex: HavokContext
propsWorldTransform: Observable<Matrix4, never> = ...
ready: Observable<boolean, never> = ...

Emitted when the rigid body is ready to be used.

reportCollisions: boolean
targetTransform: Observable<null | [[number, number, number], [number, number, number, number]], never> = ...

Properties - Transform

position: Observable<[x: number, y: number, z: number], never>

The position, in 3D space, of this node relative to its parent. The three elements of the array correspond to the x, y, and z components of position.

10

[0, 0, 0]

rotation: Observable<[x: number, y: number, z: number], never>

The rotation, in three dimensions, of this node relative to its parent. The three elements of the array correspond to Euler angles - yaw, pitch and roll.

angle-radians

10

[0, 0, 0]

scale: Observable<[x: number, y: number, z: number], never>

The scale, in three dimensions, of this node relative to its parent. The three elements of the array correspond to scales in the the x, y, and z axis.

10

[1, 1, 1]