server/src/game/brick.object.ts

23 lines
618 B
TypeScript

import { PhysicsObject } from './physics.object';
import type Rapier from '@dimforge/rapier3d-compat';
import { Vector3 } from 'three';
export class Brick extends PhysicsObject {
public objectType = 'Brick';
public name = 'Brick';
protected override createCollider(
factory: typeof Rapier,
world: Rapier.World,
body?: Rapier.RigidBody,
) {
const scale = this.getWorldScale(new Vector3()).divideScalar(2);
const collider = factory.ColliderDesc.cuboid(
Math.abs(scale.x),
Math.abs(scale.y),
Math.abs(scale.z),
);
return world.createCollider(collider, body);
}
}