
jstopo.top
const createCarPark = (scene,obj)=>{
const arcFun = (point)=>{
const R = 0.8;
const N = 80;
const sp = 2 * Math.PI / N;
const arr = [];
for (let i = 0; i < N; i++) {
const angle = sp * i;
const x = point.x + R * Math.cos(angle);
const y = point.y + R * Math.sin(angle);
arr.push([x, y]);
}
return arr;
};
const points = [
[-11, 1.1],
[-11, 2.8],
[-9.6, 3.6],
[-5, 3.6],
[-3, 2.8],
[-3, 1.1],
...arcFun({x: -4,y: 1.1}),
[-6, 1.1],
...arcFun({x: -10,y: 1.1}),
];
const vector2 = [];
points.forEach(point=>{
vector2.push(new THREE.Vector2(...point))
})
const shape = new THREE.Shape([
...vector2
]);
const geometry = new THREE.ExtrudeBufferGeometry(
shape,{
depth: 4.2,
bevelEnabled: true,
bevelThickness: 1,
bevelSize: 1,
bevelSegments: 10,
}
);
const material = new THREE.MeshLambertMaterial({
color: obj.color||0x55dae2,
transparent: true,
opacity: obj.opacity
});
const car = new THREE.Mesh(geometry,material);
car.rotateY(Math.PI/2);
car.position.set(...obj.position);
scene.add(car);
}