server/src/game/sphere.object.ts

21 lines
614 B
TypeScript

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