a3js API Documentation - v1.3.1
    Preparing search index...

    Class CarControl

    4輪車の物理演算を管理するオブジェクトです。

    左右対称の4輪車を前提としており、Rapier3D の DynamicRayCastVehicleController を使って 車体・タイヤの動きをシミュレーションします。

    このオブジェクトは内部に transCarTransformer)と motionCarMotion)を持ちます。 ActionObject に対して trans を Transformer、motion を Motion として設定して使用します。

    const car = new CarControl({ mass: 20 });
    const carObj = new GLTF('car.glb');
    await carObj.ready;
    carObj.setTransformer(car.trans);
    carObj.setMotion('default', car.motion);
    scene.add(carObj);

    // ゲームループ内で操作
    car.steer(0.3); // ハンドル操作(ラジアン)
    car.accelerate(500); // アクセル
    car.brake(0); // ブレーキ
    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    motion: CarMotion

    Methods

    • アクセルを操作します。全4輪にエンジン力を加えます。

      Parameters

      • value: number

        エンジン力(ニュートン)。正の値で前進、負の値で後退します。

      Returns void

    • ブレーキを操作します。全4輪にブレーキ力を加えます。

      Parameters

      • b: number

        ブレーキ力(大きいほど強くブレーキがかかります)。0 でブレーキ解除。

      Returns void

    • 車をリセットします。指定した位置・回転に車体を瞬間移動させ、速度をゼロにします。 省略時は defaultLocation / defaultQuat に戻します。

      Parameters

      • Optionalloc: Vec3

        リセット先の位置。省略時は初期位置。

      • Optionalquat: Quat

        リセット先の回転。省略時は初期回転。

      Returns void

    • ハンドルを操作します。

      Parameters

      • angle: number

        ステアリング角度(ラジアン)。正の値で右方向に曲がります。

      Returns void