genererFigures = {
const figures = [];
const features = { Name: "" };
const u = 3;
const rint = (n) => Math.floor(n * fxrand());
function addcube(figures, u, a, b, c, x, y, z, t, empt) {
let empty = empt ? true : fxrand() < 0.2;
figures.push({
geometry: {
type: "BoxGeometry",
args: [
a * u,
b * u,
c * u
]
},
pos: {
x: x * u,
y: y * u,
z: z * u
},
rot: {
x: 0,
y: 0,
z: 0
},
lines: empty ? true : t,
hatch: empty ? false : t,
full: empty ? false : !t
});
}
let h = 2 + rint(15);
let w = 2 + rint(15);
if (fxrand() < 0.5) {
h = 3;
} else {
w = 3;
}
let density = 0.1 + fxrand() * 0.7;
function addpass(empty) {
for (let x = -h / 2; x < h / 2; ++x) {
for (let y = -w / 2; y < w / 2; ++y) {
if (fxrand() < density) {
var a = rint(3);
if (a === 0) {
a = 0.1;
}
var b = rint(3);
if (b === 0) {
b = 0.1;
}
addcube(
figures,
u,
a,
0.1,
b,
x * 2,
rint(10),
y * 2,
fxrand() < 0.5,
empty
);
}
}
}
}
addpass();
if (density < 0.3 && fxrand() < 0.7) {
addpass();
}
if (figures.length < 10) {
density = 0.8;
addpass();
}
if (fxrand() < 0.3) {
addpass(true);
}
return { figures, features };
}