server/src/game/cylinder.object.ts

20 lines
647 B
TypeScript

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