{"script":"\n// Import DTOs for configuring various operations. DTOs are objects used to pass data.\n// Import camera configuration for setting up the scene view.\nconst { CameraConfigurationDto } = Bit.Inputs.BabylonScene;\n// Import DTOs for OpenCASCADE (OCCT) geometric modeling: creating polygons, fillets, and lofts.\nconst { NGonWireDto, FilletDto, LoftAdvancedDto } = Bit.Inputs.OCCT;\n// Import DTO for specifying drawing options, like color and opacity.\nconst { DrawOcctShapeSimpleOptions } = Bit.Inputs.Draw;\n// Import a specific type for an OCCT wire, ensuring type safety in our code.\ntype TopoDSWirePointer = Bit.Inputs.OCCT.TopoDSWirePointer;\n\n// Destructure the bitbybit API to get direct access to its main modules.\n// 'scene' provides access to BabylonJS scene controls.\nconst { scene } = bitbybit.babylon;\n// 'wire', 'fillets', and 'operations' are part of the OCCT module for creating and manipulating shapes.\nconst { wire } = bitbybit.occt.shapes;\nconst { fillets, operations } = bitbybit.occt;\n\n// Define an asynchronous function to execute the main logic.\n// Using async/await is necessary because geometry creation and drawing are non-blocking operations.\nconst start = async () => {\n\n    // --- 1. Camera Configuration ---\n    // Create a new configuration object for the scene's Arc Rotate Camera.\n    const arcCameraOptions = new CameraConfigurationDto();\n    // Set the camera's position in 3D space (x, y, z).\n    arcCameraOptions.position = [15, 15, 15];\n    // Set the point the camera will look at.\n    arcCameraOptions.lookAt = [0, 3, 0];\n    // Apply these settings to the active camera in the scene.\n    scene.adjustActiveArcRotateCamera(arcCameraOptions);\n\n    // Define the number of corners for the polygonal profiles.\n    const nrCorners = 10;\n\n    // --- 2. Create the First Profile (Bottom) ---\n    // Create a DTO to define an n-sided polygon wire.\n    const ngonOpt = new NGonWireDto();\n    ngonOpt.nrCorners = nrCorners;\n    ngonOpt.radius = 3;\n    // Asynchronously create the first polygon wire shape at the default center [0,0,0].\n    const wire1 = await wire.createNGonWire(ngonOpt);\n\n    // Create a DTO for a 2D fillet operation to round the corners of a wire.\n    const filletOpt = new FilletDto<TopoDSWirePointer>();\n    filletOpt.radius = 0.3; // The radius of the rounded corners.\n    filletOpt.shape = wire1; // Specify that the fillet should be applied to wire1.\n    // Asynchronously apply the fillet and store the new, smoothed wire.\n    const filletedWire1 = await fillets.fillet2d(filletOpt);\n\n    // --- 3. Create the Second Profile (Middle) ---\n    // Reuse the ngonOpt DTO but modify its properties for the next shape.\n    ngonOpt.center = [0, 3, 0]; // Move the center up along the Y-axis.\n    ngonOpt.radius = 1; // Make this polygon smaller.\n    const wire2 = await wire.createNGonWire(ngonOpt);\n\n    // Reuse the filletOpt DTO to apply the same fillet radius to the new wire.\n    filletOpt.shape = wire2;\n    const filletedWire2 = await fillets.fillet2d(filletOpt);\n\n    // --- 4. Create the Third Profile (Top) ---\n    // Reuse and modify the DTOs again for the third and final profile.\n    ngonOpt.center = [0, 7, 0]; // Move this one even higher.\n    ngonOpt.radius = 6; // Make this polygon the largest.\n    const wire3 = await wire.createNGonWire(ngonOpt);\n\n    // Use a larger fillet radius for this larger wire.\n    filletOpt.radius = 0.5;\n    filletOpt.shape = wire3;\n    const filletedWire3 = await fillets.fillet2d(filletOpt);\n\n    // --- 5. Perform the Loft Operation ---\n    // A loft creates a 3D solid by connecting a series of 2D profiles.\n    const loftAdvancedOptions = new LoftAdvancedDto<TopoDSWirePointer>();\n    // Specify a single point where the loft should begin, creating a pointed top.\n    loftAdvancedOptions.startVertex = [0, 10, 0];\n    // Specify a single point where the loft should end, creating a pointed bottom.\n    loftAdvancedOptions.endVertex = [0, -3, 0];\n    // Provide the array of profiles to connect. The order matters.\n    loftAdvancedOptions.shapes = [filletedWire3, filletedWire2, filletedWire1];\n    // Asynchronously execute the loft operation to create the final 3D shape.\n    const loftedShape = await operations.loftAdvanced(loftAdvancedOptions)\n\n    // --- 6. Draw the Final Shape ---\n    // Create a DTO to define how the shape should be drawn.\n    const drawOptions = new DrawOcctShapeSimpleOptions();\n    // Set the color of the shape's faces to magenta.\n    drawOptions.faceColour = \"#ff00ff\";\n\n    // Call the generic drawing function to render the OCCT shape in the scene.\n    bitbybit.draw.drawAnyAsync({\n        entity: loftedShape, // The shape to draw.\n        options: drawOptions  // The drawing options to apply.\n    });\n\n}\n\n// Execute the main function to start the script.\nstart();","version":"1.4.1","type":"typescript"}