33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import * as THREE from 'three';
|
|
import * as CONSTANTS from '../../../../types/world/worldConstants';
|
|
import * as Types from "../../../../types/world/worldTypes";
|
|
|
|
function addRoofToScene(
|
|
shape: Types.Shape,
|
|
floor: Types.Number,
|
|
userData: Types.UserData,
|
|
floorGroup: Types.RefGroup
|
|
): void {
|
|
|
|
////////// Creating a Polygon roof from the shape of the Polygon floor //////////
|
|
|
|
const extrudeSettings: THREE.ExtrudeGeometryOptions = {
|
|
depth: CONSTANTS.roofConfig.height,
|
|
bevelEnabled: false
|
|
};
|
|
|
|
const geometry = new THREE.ExtrudeGeometry(shape, extrudeSettings);
|
|
const material = new THREE.MeshStandardMaterial({ color: CONSTANTS.roofConfig.defaultColor, side: THREE.DoubleSide, transparent: true, depthWrite: false });
|
|
const mesh = new THREE.Mesh(geometry, material);
|
|
mesh.position.y = CONSTANTS.wallConfig.height + floor;
|
|
mesh.castShadow = true;
|
|
mesh.receiveShadow = true;
|
|
mesh.rotateX(Math.PI / 2);
|
|
mesh.userData.uuids = userData;
|
|
mesh.name = `Roof_Layer_${(floor / CONSTANTS.wallConfig.height) + 1}`;
|
|
|
|
floorGroup.current.add(mesh);
|
|
}
|
|
|
|
export default addRoofToScene;
|