Use Primitive Shapes¶
Primitive shape is a feature that is introduced in 1.21.90. It allows the server to draw a set of different types of shapes client-side, which would be very useful.
Adding Primitive Shapes to a Dimension¶
To add a primitive shape to a dimension, use the addPrimitiveShape method provided by the Dimension interface. Here's an example of adding a primitive box:
After the primitive shape is added to the dimension, it will be sent to the player who joined the dimension, and will be automatically removed from the player when the player leaves the dimension.
Removing Primitive Shapes¶
To remove a primitive shape, use the removePrimitiveShape method:
To remove all primitive shapes in a dimension, use:
Types of Primitive Shapes¶
Allay provides several types of primitive shapes, each with unique properties:
PrimitiveBox¶
A box with customizable position, color, scale, and bounds.
PrimitiveLine¶
A line with a start and end position.
PrimitiveArrow¶
An arrow with a start and end position, and customizable arrowhead properties.
PrimitiveCircle¶
A circle with customizable position, color, scale, and segments.
PrimitiveSphere¶
A sphere with customizable position, color, scale, and segments.
PrimitiveText¶
A text marker with customizable position, color, scale, and text content.
Viewing Primitive Shapes¶
Primitive shapes are visible to players who are added as viewers. Use the addViewer method to make a primitive shape visible to a specific player:
To remove a viewer: