day 4
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { Object3D } from "three";
|
||||
import { ThreeC } from "../ThreeC";
|
||||
import { PhysicsBody, PhysicsLayer } from "../PhysicsC";
|
||||
|
||||
export class Map {
|
||||
static Init() {
|
||||
const mapObject = ThreeC.getObject("map");
|
||||
if (!mapObject) {
|
||||
console.warn("Map model resource not found: map");
|
||||
return;
|
||||
}
|
||||
|
||||
mapObject.position.set(0, 0, 0);
|
||||
ThreeC.setShadowsStateForChildren(mapObject, true, true);
|
||||
ThreeC.addToScene(mapObject);
|
||||
|
||||
const colliders = mapObject.getObjectByName("Colliders");
|
||||
if (colliders) {
|
||||
colliders.visible = false;
|
||||
this.buildColliders(colliders);
|
||||
}
|
||||
}
|
||||
|
||||
private static buildColliders(collidersRoot: Object3D) {
|
||||
collidersRoot.traverse((child) => {
|
||||
if (child === collidersRoot) return;
|
||||
if ((child as any).isMesh) {
|
||||
new PhysicsBody(child, false, 0, PhysicsLayer.Wall, PhysicsLayer.Player);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user