genererFigures = {
const figures = [];
const features = { Name: "" };
const u = 1;
const r = fxrand;
const rint = (n) => Math.floor(r() * n);
const cube = (args, pos, full) =>
figures.push({
geometry: {
type: "BoxGeometry",
args
},
pos,
rot: {
x: 0,
y: 0,
z: 0
},
lines: !full,
hatch: !full,
full
});
const chair = {
height: 0.5 + r() * 2,
width: 0.25 + r(),
depth: 0.25 + r(),
theme: r() < 0.2
};
chair.assise = chair.height * (0.2 + r() * 0.5);
const nbTraversLateraux = r() > 0.5 ? 1 : 1 + rint(chair.height * 4);
for (let i = 0; i < nbTraversLateraux; ++i) {
cube(
[0.1, 0.1, chair.depth * 2],
{ x: -chair.width, y: chair.height - 0.05 - i * 0.2, z: 0 },
chair.theme
);
cube(
[0.1, 0.1, chair.depth * 2],
{ x: chair.width, y: chair.height - 0.05 - i * 0.2, z: 0 },
chair.theme
);
}
const nbTraversDossier = rint(chair.height * 4);
for (let i = 0; i < nbTraversDossier; ++i) {
cube(
[chair.width * 2, 0.1, 0.1],
{ x: 0, y: chair.height - 0.05 - i * 0.2, z: -chair.depth },
chair.theme
);
}
cube(
[chair.width * 2 + 0.1, 0.1, chair.depth * 2 + 0.1],
{ x: 0, y: chair.assise, z: 0 },
chair.theme
);
const nbMontantsLateraux = r() > 0.5 ? 1 : 1 + rint(chair.depth * 8);
for (let i = 0; i < nbMontantsLateraux; ++i) {
cube(
[0.1, chair.height, 0.1],
{ x: -chair.width, y: chair.height / 2, z: -chair.depth + i * 0.2 },
chair.theme
);
cube(
[0.1, chair.height, 0.1],
{ x: chair.width, y: chair.height / 2, z: -chair.depth + i * 0.2 },
chair.theme
);
}
cube(
[0.1, chair.height, 0.1],
{ x: -chair.width, y: chair.height / 2, z: chair.depth },
chair.theme
);
cube(
[0.1, chair.height, 0.1],
{ x: chair.width, y: chair.height / 2, z: chair.depth },
chair.theme
);
return { figures, features };
}