server/src/game/geometries.ts

44 lines
1.0 KiB
TypeScript

import { BoxGeometry } from 'three';
export class WedgeGeometry extends BoxGeometry {
type = 'WedgeGeometry';
constructor() {
super();
const pos = this.attributes.position;
for (let i = 0; i < pos.count; i++) {
if (pos.getX(i) < 0 && pos.getY(i) > 0) pos.setY(i, -0.5);
}
this.computeVertexNormals();
}
}
export class WedgeCornerGeometry extends BoxGeometry {
type = 'WedgeCornerGeometry';
constructor() {
super();
const pos = this.attributes.position;
for (let i = 0; i < pos.count; i++) {
if (pos.getY(i) > 0 && (pos.getX(i) !== 0.5 || pos.getZ(i) !== -0.5)) {
pos.setY(i, -0.5);
}
}
this.computeVertexNormals();
}
}
export class WedgeInnerCornerGeometry extends BoxGeometry {
type = 'WedgeInnerCornerGeometry';
constructor() {
super();
const pos = this.attributes.position;
for (let i = 0; i < pos.count; i++) {
if (pos.getY(i) > 0 && pos.getX(i) === 0.5 && pos.getZ(i) === 0.5) {
pos.setY(i, -0.5);
}
}
this.computeVertexNormals();
}
}