const bending = 5;
const dirLightOpt = new Bit.Inputs.BabylonScene.DirectionalLightDto();
dirLightOpt.intensity = 3;
dirLightOpt.shadowGeneratorMapSize = 3000;
bitbybit.babylon.scene.drawDirectionalLight(dirLightOpt);
const start = async () => {
const line1 = await bitbybit.occt.shapes.wire.createLineWire({
start: [5, bending, -5],
end: [-5, -bending, -5]
});
const line2 = await bitbybit.occt.shapes.wire.createLineWire({
start: [5, -bending, 5],
end: [-5, bending, 5]
});
const loft = await bitbybit.occt.operations.loft({
shapes: [line1, line2],
makeSolid: false,
});
const span = bitbybit.vector.span({
min: -2,
max: 2,
step: 0.3,
});
const vectors = span.map(y => [0, y, 0] as Bit.Inputs.Base.Vector3);
const translationPromises = vectors.map(v => bitbybit.occt.transforms.translate({ shape: loft, translation: v }));
const translatedShapes = await Promise.all(translationPromises);
const sphere = await bitbybit.occt.shapes.solid.createSphere({
radius: 3,
center: [0, 0, 0],
});
const splitShapes = await bitbybit.occt.operations.splitShapeWithShapes({
shape: sphere,
shapes: translatedShapes,
nonDestructive: false,
localFuzzyTolerance: 1e-4
});
const removedSplitShapes = bitbybit.lists.removeItemsAtIndexes({
list: splitShapes,
indexes: [0, 3, 4, 7, 8, 11, 12],
});
const compoundSplitShapes = await bitbybit.occt.shapes.compound.makeCompound({
shapes: removedSplitShapes
});
const drawOpt = new Bit.Inputs.Draw.DrawOcctShapeOptions();
drawOpt.faceColour = "#7300ff";
drawOpt.precision = 0.001;
bitbybit.draw.drawAnyAsync({
entity: compoundSplitShapes,
options: drawOpt
});
}
start();