Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

PrimitiveShapes

PrimitiveShapes is an API that makes it easy to use the PrimitiveShapesPacket to render 3D shapes client-side.

Text

$shape = PrimitiveShapesAPI::createText(
    position: new Vector3(100, 65, 200),
    text: "Hello World",
    color: 0xFFFF0000, // ARGB red
    scale: 2.0,
);
PrimitiveShapesAPI::send($player, $shape);

Box

$shape = PrimitiveShapesAPI::createShape(
    shapeType: ShapeType::BOX,
    position: new Vector3(100, 65, 200),
    color: 0xFF00FF00,
    extraData: ["bounds" => new Vector3(2, 2, 2)],
);
PrimitiveShapesAPI::send($player, $shape);

Sphere

$shape = PrimitiveShapesAPI::createShape(
    shapeType: ShapeType::SPHERE,
    position: new Vector3(100, 65, 200),
    color: 0xFF0000FF,
    extraData: ["segments" => 20],
);
PrimitiveShapesAPI::send($player, $shape);

Line

$shape = PrimitiveShapesAPI::createShape(
    shapeType: ShapeType::LINE,
    position: new Vector3(100, 65, 200),
    color: 0xFFFFFF00,
    extraData: ["endPosition" => new Vector3(110, 70, 210)],
);
PrimitiveShapesAPI::send($player, $shape);

Arrow

$shape = PrimitiveShapesAPI::createShape(
    shapeType: ShapeType::ARROW,
    position: new Vector3(100, 65, 200),
    color: 0xFFFF00FF,
    extraData: [
        "endPosition" => new Vector3(110, 70, 210),
        "headLength" => 1.0,
        "headRadius" => 0.5,
        "headSegments" => 8,
    ],
);
PrimitiveShapesAPI::send($player, $shape);

Cylinder

$shape = PrimitiveShapesAPI::createShape(
    shapeType: ShapeType::CYLINDER,
    position: new Vector3(100, 65, 200),
    color: 0xFF00FFFF,
    extraData: [
        "radiusX" => 1.0,
        "radiusZ" => 1.0,
        "height" => 3.0,
        "segments" => 16,
    ],
);
PrimitiveShapesAPI::send($player, $shape);

Pyramid

$shape = PrimitiveShapesAPI::createShape(
    shapeType: ShapeType::PYRAMID,
    position: new Vector3(100, 65, 200),
    color: 0xFFFFAA00,
    extraData: ["width" => 3.0, "height" => 4.0],
);
PrimitiveShapesAPI::send($player, $shape);

Ellipsoid

$shape = PrimitiveShapesAPI::createShape(
    shapeType: ShapeType::ELLIPSOID,
    position: new Vector3(100, 65, 200),
    color: 0xFFAA00FF,
    extraData: [
        "radii" => new Vector3(2, 1, 1.5),
        "segments" => 16,
    ],
);
PrimitiveShapesAPI::send($player, $shape);

Cone

$shape = PrimitiveShapesAPI::createShape(
    shapeType: ShapeType::CONE,
    position: new Vector3(100, 65, 200),
    color: 0xFF00AA55,
    extraData: [
        "radius" => 1.5,
        "height" => 3.0,
        "segments" => 16,
    ],
);
PrimitiveShapesAPI::send($player, $shape);

Remove

PrimitiveShapesAPI::remove($player, $shape->networkId);

Shape Types

ShapeType::LINE, ShapeType::BOX, ShapeType::SPHERE, ShapeType::CIRCLE, ShapeType::TEXT, ShapeType::ARROW, ShapeType::CYLINDER, ShapeType::PYRAMID, ShapeType::ELLIPSOID, ShapeType::CONE

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages