Skip to content
🎉 Angular Three v4 is here! Read the announcement

Vehicles

angular-three-ecctrl/vehicle is the optional vehicle entrypoint for Rapier-backed cars and drones. It exports the vehicle, wheel, and propeller directives together with their public configuration, input, runtime-state, handle, and options types.

ExportPurpose
NgteEcctrlVehicleThe vehicle rigid-body controller. Its selector is ngte-ecctrl-vehicle and its exportAs value is ecctrlVehicle.
NgteShapeCastWheelA wheel ground-query directive. Its selector is ngte-shape-cast-wheel and its exportAs value is shapeCastWheel.
NgteThrustPropellerA thrust-propeller directive. Its selector is ngte-thrust-propeller and its exportAs value is thrustPropeller.
NgteVehicleJoystickA vehicle-input source for supplying movement values.
NgteVehicleInput / NgteReadonlyVehicleInputWritable and readonly vehicle movement shapes.
NgteCarConfig / NgteDroneConfigCar and drone configuration shapes used by vehicle options.
NgteEcctrlVehicleOptions / NgteEcctrlVehicleRigidBodyOptionsVehicle and Rapier rigid-body configuration shapes.
NgteEcctrlVehicleHandleImperative vehicle control surface.
NgteEcctrlVehicleRuntimeStateCurrent public vehicle runtime state.
NgteWheelControlConfig / NgteWheelControlDemand / NgteWheelInfoPublic wheel-control configuration, demand, and runtime info shapes.
NgtePropellerInfoPublic propeller runtime-info shape.
NgteWheelGroundDetection / NgteShapeCastWheelOptionsWheel ground-detection and configuration shapes.
NgteThrustPropellerOptionsThrust-propeller configuration shape.
DEFAULT_ECCTRL_CAR_CONFIG / DEFAULT_ECCTRL_DRONE_CONFIGThe public default car and drone configurations.
DEFAULT_ECCTRL_SHAPE_CAST_WHEEL_OPTIONS / DEFAULT_ECCTRL_THRUST_PROPELLER_OPTIONSPublic default wheel and propeller options.
DirectiveInputs and modelsEvents and readonly surface
NgteEcctrlVehicleoptions, position, rotation, quaternion, scale, userData, rigidBodyOptions, and the movement modelwake, sleep, collisionEnter, collisionExit, intersectionEnter, intersectionExit, contactForce; rigidBody/body, state, and handle
NgteShapeCastWheelid, options, position, rotation, quaternion, and scaleReadonly info: NgteWheelInfo
NgteThrustPropellerid, options, position, rotation, quaternion, and scaleReadonly info: NgtePropellerInfo

An ecctrlVehicle reference exposes the public rigidBody/body, state, and handle values, as well as setMovement, setTarget, and setGear. Use its movement model or setMovement for input sources, with the boolean fields listed below.

Project Rapier colliders inside ngte-ecctrl-vehicle; they become the colliders for that vehicle body.

Public configurationUse
NgteEcctrlVehicleOptions / NgteEcctrlVehicleRigidBodyOptionsConfigure vehicle behavior and its Rapier rigid body.
NgteCarConfig / DEFAULT_ECCTRL_CAR_CONFIGConfigure car behavior or begin from the public car defaults.
NgteDroneConfig / DEFAULT_ECCTRL_DRONE_CONFIGConfigure drone behavior or begin from the public drone defaults.
NgteShapeCastWheelOptions / DEFAULT_ECCTRL_SHAPE_CAST_WHEEL_OPTIONSConfigure wheel ground queries and wheel behavior or begin from the public defaults.
NgteThrustPropellerOptions / DEFAULT_ECCTRL_THRUST_PROPELLER_OPTIONSConfigure a thrust propeller or begin from the public defaults.

NgteVehicleInput uses boolean directional controls, plus its joystickL and joystickR values:

CarDroneShared
forward, backward, steerLeft, steerRight, brakethrottleUp, throttleDown, yawLeft, yawRight, pitchForward, pitchBackward, rollLeft, rollRightjoystickL, joystickR

NgteVehicleJoystick and imperative calls to setMovement can drive the same model. Send partial updates when an input source changes, for example vehicle.setMovement({ brake: true }).

Use NgteCarConfig through vehicle options to configure a car. The public car configuration covers curve-based engine, steering, and tire behavior, weighted drive torque, and optional automatic or manual transmission. Project one NgteShapeCastWheel per wheel and provide each wheel’s identifier and transform through its inputs when needed.

import { Component, CUSTOM_ELEMENTS_SCHEMA, signal } from '@angular/core';
import { NgtrCuboidCollider, NgtrPhysics } from 'angular-three-rapier';
import { NgteEcctrlVehicle, NgteShapeCastWheel, type NgteVehicleInput } from 'angular-three-ecctrl/vehicle';
@Component({
template: `
<ngtr-physics>
<ng-template>
<ngte-ecctrl-vehicle #vehicle="ecctrlVehicle" [movement]="movement()">
<ngtr-cuboid-collider />
<ngte-shape-cast-wheel #frontLeft="shapeCastWheel" />
<ngte-shape-cast-wheel #frontRight="shapeCastWheel" />
<ngte-shape-cast-wheel />
<ngte-shape-cast-wheel />
</ngte-ecctrl-vehicle>
</ng-template>
</ngtr-physics>
`,
imports: [NgtrPhysics, NgteEcctrlVehicle, NgteShapeCastWheel, NgtrCuboidCollider],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class CarScene {
readonly movement = signal<NgteVehicleInput>({
forward: true,
backward: false,
steerLeft: false,
steerRight: false,
brake: false,
});
}

NgteShapeCastWheel accepts id, options, position, rotation, quaternion, and scale, and exposes readonly info as NgteWheelInfo. Its NgteShapeCastWheelOptions include NgteWheelGroundDetection, so a wheel can use either shapeCast or rayCast ground detection. DEFAULT_ECCTRL_SHAPE_CAST_WHEEL_OPTIONS is the public default-options constant.

The option name wheelModelReversRotation is intentionally spelled this way in the public API; retain that spelling when supplying wheel options.

See the car example.

Use NgteDroneConfig through vehicle options to configure a drone. The public drone configuration supports VELOCITY and POSITION control modes. Project NgteThrustPropeller directives for propulsion; each propeller’s options and readonly NgtePropellerInfo describe its public runtime behavior.

import { Component, CUSTOM_ELEMENTS_SCHEMA, signal } from '@angular/core';
import { NgtrCuboidCollider, NgtrPhysics } from 'angular-three-rapier';
import { NgteEcctrlVehicle, NgteThrustPropeller, type NgteVehicleInput } from 'angular-three-ecctrl/vehicle';
@Component({
template: `
<ngtr-physics>
<ng-template>
<ngte-ecctrl-vehicle [movement]="movement()">
<ngtr-cuboid-collider />
<ngte-thrust-propeller #frontLeft="thrustPropeller" />
<ngte-thrust-propeller #frontRight="thrustPropeller" />
<ngte-thrust-propeller />
<ngte-thrust-propeller />
</ngte-ecctrl-vehicle>
</ng-template>
</ngtr-physics>
`,
imports: [NgtrPhysics, NgteEcctrlVehicle, NgteThrustPropeller, NgtrCuboidCollider],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class DroneScene {
readonly movement = signal<NgteVehicleInput>({
throttleUp: true,
throttleDown: false,
yawLeft: false,
yawRight: true,
pitchForward: false,
pitchBackward: false,
rollLeft: false,
rollRight: false,
});
}

NgteThrustPropeller accepts id, options, position, rotation, quaternion, and scale, and exposes readonly info as NgtePropellerInfo. Use NgteThrustPropellerOptions to configure it; DEFAULT_ECCTRL_THRUST_PROPELLER_OPTIONS is the public default-options constant.

See the drone example.