@@ -715,58 +715,48 @@ describe 'Slicing', ->
715715
716716 describe ' Wall Print Order with Holes' , ->
717717
718- test ' should print outer boundary walls before hole walls' , ->
719-
720- # This test uses three-bvh-csg to create a sheet with holes.
721- # Import CSG dependencies.
722- { Brush , Evaluator , SUBTRACTION } = require (' three-bvh-csg' )
723-
724- # Suppress MeshBVH deprecation warnings from three-bvh-csg.
725- originalWarn = console .warn
726- console .warn = jest .fn ()
718+ SHEET_SIZE = 50
719+ THICKNESS = 5
720+ GRID_SIZE = 2
721+ HOLE_RADIUS = 3
727722
728- # Create a sheet with holes using CSG operations.
729- sheetGeometry = new THREE.BoxGeometry (50 , 50 , 5 )
730- sheetBrush = new Brush (sheetGeometry)
731- sheetBrush .updateMatrixWorld ()
732-
733- csgEvaluator = new Evaluator ()
723+ buildSheetWithHolesMesh = ->
734724
735- # Create 2x2 grid of holes.
736- gridSize = 2
737- spacing = 50 / (gridSize + 1 )
738- offsetX = - 50 / 2 + spacing
739- offsetY = - 50 / 2 + spacing
740- holeRadius = 3
725+ spacing = SHEET_SIZE / (GRID_SIZE + 1 )
726+ offsetX = - SHEET_SIZE / 2 + spacing
727+ offsetY = - SHEET_SIZE / 2 + spacing
728+ half = SHEET_SIZE / 2
741729
742- resultBrush = sheetBrush
730+ sheetShape = new THREE.Shape ()
731+ sheetShape .moveTo (- half, - half)
732+ sheetShape .lineTo (half, - half)
733+ sheetShape .lineTo (half, half)
734+ sheetShape .lineTo (- half, half)
735+ sheetShape .closePath ()
743736
744- for row in [0 ... gridSize ]
737+ for row in [0 ... GRID_SIZE ]
745738
746- for col in [0 ... gridSize ]
739+ for col in [0 ... GRID_SIZE ]
747740
748- # Calculate hole position.
749741 holeX = offsetX + col * spacing
750742 holeY = offsetY + row * spacing
751743
752- # Create cylinder for hole.
753- holeGeometry = new THREE.CylinderGeometry (holeRadius, holeRadius, 10 , 32 )
754- holeMesh = new Brush (holeGeometry )
744+ holePath = new THREE.Path ()
745+ holePath . absarc (holeX, holeY, HOLE_RADIUS, 0 , Math . PI * 2 , false )
746+ sheetShape . holes . push (holePath )
755747
756- holeMesh .rotation .x = Math .PI / 2
757- holeMesh .position .set (holeX, holeY, 0 )
758- holeMesh .updateMatrixWorld ()
748+ sheetGeometry = new THREE.ExtrudeGeometry (sheetShape, { depth : THICKNESS, bevelEnabled : false })
759749
760- # Subtract hole from sheet.
761- resultBrush = csgEvaluator .evaluate (resultBrush, holeMesh, SUBTRACTION)
750+ mesh = new THREE.Mesh (sheetGeometry, new THREE.MeshBasicMaterial ())
751+ mesh .position .set (0 , 0 , 0 )
752+ mesh .updateMatrixWorld ()
762753
763- # Restore console.warn.
764- console .warn = originalWarn
754+ return mesh
765755
766- # Create final mesh.
767- finalMesh = new THREE.Mesh ( resultBrush . geometry , new THREE.MeshBasicMaterial ())
768- finalMesh . position . set ( 0 , 0 , 2.5 )
769- finalMesh . updateMatrixWorld ()
756+ test ' should print outer boundary walls before hole walls ' , ->
757+
758+ # Create a sheet with holes using ExtrudeGeometry (no CSG required).
759+ finalMesh = buildSheetWithHolesMesh ()
770760
771761 # Configure slicer.
772762 slicer .setLayerHeight (0.2 )
@@ -896,56 +886,8 @@ describe 'Slicing', ->
896886
897887 test ' should generate skin walls immediately after regular walls for holes on skin layers' , ->
898888
899- # This test validates the skin wall integration feature.
900- # Import CSG dependencies.
901- { Brush , Evaluator , SUBTRACTION } = require (' three-bvh-csg' )
902-
903- # Suppress MeshBVH deprecation warnings from three-bvh-csg.
904- originalWarn = console .warn
905- console .warn = jest .fn ()
906-
907- # Create a sheet with holes using CSG operations.
908- sheetGeometry = new THREE.BoxGeometry (50 , 50 , 5 )
909- sheetBrush = new Brush (sheetGeometry)
910- sheetBrush .updateMatrixWorld ()
911-
912- csgEvaluator = new Evaluator ()
913-
914- # Create 2x2 grid of holes.
915- gridSize = 2
916- spacing = 50 / (gridSize + 1 )
917- offsetX = - 50 / 2 + spacing
918- offsetY = - 50 / 2 + spacing
919- holeRadius = 3
920-
921- resultBrush = sheetBrush
922-
923- for row in [0 ... gridSize]
924-
925- for col in [0 ... gridSize]
926-
927- # Calculate hole position.
928- holeX = offsetX + col * spacing
929- holeY = offsetY + row * spacing
930-
931- # Create cylinder for hole.
932- holeGeometry = new THREE.CylinderGeometry (holeRadius, holeRadius, 10 , 32 )
933- holeMesh = new Brush (holeGeometry)
934-
935- holeMesh .rotation .x = Math .PI / 2
936- holeMesh .position .set (holeX, holeY, 0 )
937- holeMesh .updateMatrixWorld ()
938-
939- # Subtract hole from sheet.
940- resultBrush = csgEvaluator .evaluate (resultBrush, holeMesh, SUBTRACTION)
941-
942- # Restore console.warn.
943- console .warn = originalWarn
944-
945- # Create final mesh.
946- finalMesh = new THREE.Mesh (resultBrush .geometry , new THREE.MeshBasicMaterial ())
947- finalMesh .position .set (0 , 0 , 2.5 )
948- finalMesh .updateMatrixWorld ()
889+ # Create a sheet with holes using ExtrudeGeometry (no CSG required).
890+ finalMesh = buildSheetWithHolesMesh ()
949891
950892 # Configure slicer.
951893 slicer .setLayerHeight (0.2 )
0 commit comments