@@ -926,3 +926,86 @@ def test_plot_design_face_colors(modeler: Modeler, verify_image_cache):
926
926
merge = False ,
927
927
multi_colors = True ,
928
928
)
929
+
930
+
931
+ @skip_no_xserver
932
+ def test_export_glb (modeler : Modeler , verify_image_cache ):
933
+ """Test exporting a box to glb."""
934
+ # Create a Sketch
935
+ sketch = Sketch ()
936
+ sketch .box (Point2D ([10 , 10 ], UNITS .mm ), Quantity (10 , UNITS .mm ), Quantity (10 , UNITS .mm ))
937
+
938
+ # Create your design on the server side
939
+ design = modeler .create_design ("BoxExtrusions" )
940
+
941
+ # Extrude the sketch to create a body
942
+ box_body = design .extrude_sketch ("JustABox" , sketch , Quantity (10 , UNITS .mm ))
943
+
944
+ pl = GeometryPlotter ()
945
+ pl .plot (box_body )
946
+
947
+ output_glb_path = Path (IMAGE_RESULTS_DIR , "plot_box_glb" )
948
+ pl .export_glb (screenshot = output_glb_path )
949
+
950
+
951
+ @skip_no_xserver
952
+ def test_export_glb_with_color (modeler : Modeler , verify_image_cache ):
953
+ """Test exporting a box to glb."""
954
+ # Create a Sketch
955
+ sketch = Sketch ()
956
+ sketch .box (Point2D ([10 , 10 ], UNITS .mm ), Quantity (10 , UNITS .mm ), Quantity (10 , UNITS .mm ))
957
+
958
+ # Create your design on the server side
959
+ design = modeler .create_design ("BoxExtrusions" )
960
+
961
+ # Extrude the sketch to create a body
962
+ box_body = design .extrude_sketch ("JustABox" , sketch , Quantity (10 , UNITS .mm ))
963
+ box_body .set_color ((255 , 0 , 0 ))
964
+
965
+ pl = GeometryPlotter (use_service_colors = True )
966
+ pl .plot (box_body )
967
+
968
+ output_glb_path = Path (IMAGE_RESULTS_DIR , "plot_box_glb_colored" )
969
+ pl .export_glb (screenshot = output_glb_path )
970
+
971
+
972
+ @skip_no_xserver
973
+ def test_export_glb_with_face_color (modeler : Modeler , verify_image_cache ):
974
+ """Test exporting a box to glb."""
975
+ # Create a Sketch
976
+ sketch = Sketch ()
977
+ sketch .box (Point2D ([10 , 10 ], UNITS .m ), Quantity (10 , UNITS .m ), Quantity (10 , UNITS .m ))
978
+
979
+ # Create your design on the server side
980
+ design = modeler .create_design ("BoxExtrusions" )
981
+
982
+ # Extrude the sketch to create a body
983
+ box_body = design .extrude_sketch ("JustABox" , sketch , Quantity (10 , UNITS .m ))
984
+ box_body .set_color ((255 , 0 , 0 ))
985
+ box_body .faces [0 ].set_color ((0 , 0 , 255 ))
986
+ box_body .faces [1 ].set_color ((0 , 255 , 0 ))
987
+
988
+ pl = GeometryPlotter (use_service_colors = True )
989
+
990
+ output_glb_path = Path (IMAGE_RESULTS_DIR , "plot_box_glb_face_colored" )
991
+ pl .export_glb (box_body , screenshot = output_glb_path )
992
+
993
+
994
+ @skip_no_xserver
995
+ def test_export_glb_cylinder_with_face_color (modeler : Modeler , verify_image_cache ):
996
+ """Test exporting a cylinder to glb."""
997
+ # Create your design on the server side
998
+ design = modeler .create_design ("BoxExtrusions" )
999
+
1000
+ # Create a sketch of a circle (overlapping the box slightly)
1001
+ sketch_circle = Sketch ().circle (Point2D ([20 , 0 ], unit = UNITS .m ), radius = 3 * UNITS .m )
1002
+ cyl = design .extrude_sketch ("Cylinder" , sketch_circle , 50 * UNITS .m )
1003
+
1004
+ cyl .set_color ((255 , 0 , 0 ))
1005
+ cyl .faces [0 ].set_color ((0 , 0 , 255 ))
1006
+ cyl .faces [1 ].set_color ((0 , 255 , 0 ))
1007
+
1008
+ pl = GeometryPlotter (use_service_colors = True )
1009
+
1010
+ output_glb_path = Path (IMAGE_RESULTS_DIR , "plot_cylinder_glb_face_colored" )
1011
+ pl .export_glb (cyl , screenshot = output_glb_path )
0 commit comments