Skip to content

SgCylinder

Generates a standard 3D cylinder, with customizable top and bottom radii and height. Often used for pillars, barrels, or mechanical components. Can be used as a base for more complex shapes or animations.

Inherits from

SceneObject

Usage

To use this class, add the following require at the top of your script:

local SgCylinder = require 'engine/sceneobjects/sgcylinder'

Reference

create

static create(self, options, parent)

Create a new cylinder object in the scenegraph.

Parameters

  • self
  • options (table): A table of options to fill the parameters
  • parent (SceneObject): The parent scene object to add this to

Returns

  • Promise: promise which will resolve to the created object

Example

-- Options can be omitted. This example shows the defaults,
-- only specify the ones you want different.
SgCylinder.create({
    active = true,
    name = "",
    transform = Transform.new(),
    layers = {0},
    tags = {},
    receiveShadow = false,
    castShadow = false,
    material = nil,
    radiusTop = 1,
    radiusBottom = 1,
    radialSegments = 8,
    height = 1,
    heightSegments = 1,
    openEnded = false,
    thetaStart = 0,
    thetaLength = 360,
    uvScale = Vector2.new(1, 1)
})

Properties

You can access these properties directly on the object or through :get("propertyName") or :set("propertyName", value) methods.

Property Type Default Description
active Boolean true Indicates if the 3D object is currently active or inactive. When set to true, the object is active.
static Boolean false Marks the object as immovable during play. Static objects ignore transform changes at runtime and use a fixed physics collider with zero mass.
transform Transform Transform.new() Describes the object's transformation attributes including its position, rotation, and scale in the 3D space.
layers Layers [0] Defines the layers that the 3D object is part of. Layers are used for managing object interactions and visibility in the scene.
tags Tags [] Lists tags associated with the 3D object. Tags are useful for categorizing and searching objects in the scene.
receiveShadow Boolean false Determines whether the object can receive shadows from other objects. Set to true if the object should display shadows cast upon it.
castShadow Boolean false Controls whether the object casts shadows in the presence of light sources. Set to true to enable shadow casting from this object.
rendered Boolean true When disabled, the object and its descendants are not drawn, but may still simulate physics or run scripts.
radiusTop Float 1 Radius at the top cap. Equal to bottom radius for a straight cylinder.
radiusBottom Float 1 Radius at the bottom cap.
radialSegments Integer 8 Number of sides around the circumference.
height Float 1 Height along the cylinder's local Y axis.
heightSegments Integer 1 Vertical subdivisions along the height.
openEnded Boolean false When disabled, adds top and bottom caps to close the cylinder.
thetaStart Float 0 Starting angle in radians for partial cylinders.
thetaLength Float 360 Angular span in radians (2π = full cylinder).
uVScale Vector2d Vector2.new(1, 1) Multiplier for texture coordinates.
physicsEnabled Boolean false Turns physics simulation on or off for this object. When disabled, the object keeps its visual transform but does not participate in collisions or forces.