Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/viser/_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down
3 changes: 3 additions & 0 deletions src/viser/_scene_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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.
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/viser/client/src/WebsocketMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/viser/client/src/mesh/IcosphereMesh.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<group ref={ref}>
<mesh
geometry={geometry}
scale={message.props.radius}
scale={scale}
material={material}
castShadow={message.props.cast_shadow}
receiveShadow={message.props.receive_shadow === true}
Expand Down