diff --git a/src/viser/_messages.py b/src/viser/_messages.py index d6c5d7694..9bdbed6ef 100644 --- a/src/viser/_messages.py +++ b/src/viser/_messages.py @@ -724,6 +724,8 @@ class IcosphereProps: """Number of subdivisions to use when creating the icosphere.""" color: Tuple[int, int, int] """Color of the icosphere as RGB integers. """ + scale: Tuple[float, float, float] + """Tuple of (x, y, z) scaling values for the icosphere.""" wireframe: bool """Boolean indicating if the icosphere should be rendered as a wireframe. """ diff --git a/src/viser/_scene_api.py b/src/viser/_scene_api.py index 7c296cfda..19a8956cc 100644 --- a/src/viser/_scene_api.py +++ b/src/viser/_scene_api.py @@ -2012,6 +2012,7 @@ def add_icosphere( color: RgbTupleOrArray = (255, 0, 0), *, subdivisions: int = 3, + scale: tuple[float, float, float] = (1.0, 1.0, 1.0), wireframe: bool = False, opacity: float | None = None, material: Literal["standard", "toon3", "toon5"] = "standard", @@ -2032,6 +2033,7 @@ def add_icosphere( color: Color of the icosphere as an RGB tuple. subdivisions: Number of subdivisions to use when creating the icosphere. wireframe: Boolean indicating if the icosphere should be rendered as a wireframe. + scale: Tuple of (x, y, z) scaling values for the icosphere. opacity: Opacity of the icosphere. None means opaque. material: Material type of the icosphere ('standard', 'toon3', 'toon5'). flat_shading: Whether to do flat shading. @@ -2054,6 +2056,7 @@ def add_icosphere( radius=radius, subdivisions=subdivisions, color=_encode_rgb(color), + scale=scale, wireframe=wireframe, opacity=opacity, flat_shading=flat_shading, diff --git a/src/viser/client/src/WebsocketMessages.ts b/src/viser/client/src/WebsocketMessages.ts index 48b7efb4e..2918a0c5c 100644 --- a/src/viser/client/src/WebsocketMessages.ts +++ b/src/viser/client/src/WebsocketMessages.ts @@ -281,6 +281,7 @@ export interface IcosphereMessage { radius: number; subdivisions: number; color: [number, number, number]; + scale: [number, number, number]; wireframe: boolean; opacity: number | null; flat_shading: boolean; diff --git a/src/viser/client/src/mesh/IcosphereMesh.tsx b/src/viser/client/src/mesh/IcosphereMesh.tsx index 3d3d6a8c8..577f835b1 100644 --- a/src/viser/client/src/mesh/IcosphereMesh.tsx +++ b/src/viser/client/src/mesh/IcosphereMesh.tsx @@ -65,11 +65,14 @@ export const IcosphereMesh = React.forwardRef< }); }, [shadowOpacity]); + // Calculate scaling values. + const scale = message.props.scale.map((s: number) => s * message.props.radius) as [number, number, number]; + return (