1616from . import transformations as tf
1717from .base import Trimesh
1818from .constants import log , tol
19+ from .typed import ArrayLike , Integer , Number , Optional
1920
2021# immutable identity matrix for checks
2122_IDENTITY = np .eye (4 )
@@ -57,7 +58,8 @@ def faces(self):
5758
5859 @faces .setter
5960 def faces (self , values ):
60- log .warning ("primitive faces are immutable: not setting!" )
61+ if values is not None :
62+ raise ValueError ("primitive faces are immutable: not setting!" )
6163
6264 @property
6365 def vertices (self ):
@@ -71,7 +73,7 @@ def vertices(self):
7173 @vertices .setter
7274 def vertices (self , values ):
7375 if values is not None :
74- log . warning ("primitive vertices are immutable: not setting!" )
76+ raise ValueError ("primitive vertices are immutable: not setting!" )
7577
7678 @property
7779 def face_normals (self ):
@@ -550,28 +552,32 @@ def _create_mesh(self):
550552
551553class Sphere (Primitive ):
552554 def __init__ (
553- self , radius = 1.0 , center = None , transform = None , subdivisions = 3 , mutable = True
555+ self ,
556+ radius : Number = 1.0 ,
557+ center : Optional [ArrayLike ] = None ,
558+ transform : Optional [ArrayLike ] = None ,
559+ subdivisions : Integer = 3 ,
560+ mutable : bool = True ,
554561 ):
555562 """
556563 Create a Sphere Primitive, a subclass of Trimesh.
557564
558565 Parameters
559566 ----------
560- radius : float
567+ radius
561568 Radius of sphere
562569 center : None or (3,) float
563570 Center of sphere.
564571 transform : None or (4, 4) float
565572 Full homogeneous transform. Pass `center` OR `transform.
566- subdivisions : int
573+ subdivisions
567574 Number of subdivisions for icosphere.
568- mutable : bool
575+ mutable
569576 Are extents and transform mutable after creation.
570577 """
571578
572579 super ().__init__ ()
573580
574- defaults = {"radius" : 1.0 , "transform" : np .eye (4 ), "subdivisions" : 3 }
575581 constructor = {"radius" : float (radius ), "subdivisions" : int (subdivisions )}
576582 # center is a helper method for "transform"
577583 # since a sphere is rotationally symmetric
@@ -586,7 +592,10 @@ def __init__(
586592
587593 # create the attributes object
588594 self .primitive = PrimitiveAttributes (
589- self , defaults = defaults , kwargs = constructor , mutable = mutable
595+ self ,
596+ defaults = {"radius" : 1.0 , "transform" : np .eye (4 ), "subdivisions" : 3 },
597+ kwargs = constructor ,
598+ mutable = mutable ,
590599 )
591600
592601 @property
0 commit comments