Link Search Menu Expand Document

Objects in ARENA-py

Objects are the main interface for placing content into the ARENA.

See object definition reference.

Creating an Object and Adding Attributes

See Appendix for all types of Objects.

Attributes can be added upon Object creation in the three ways used below (special attributes like position, rotation, scale, color, etc. can be added with tuples, lists, or dictionaries).

box = Box(
    object_id="my_box",
    position=Position(0,4,-2),
    rotation=(0,0,0,1),
    scale={"x":2,"y":2,"z":2}
)

# objects can be added to a scene with the add_object method
scene.add_object(box)

Adding Attributes

# use update_attributes with kwargs to add attributes
box.update_attributes(physics=Physics(type="dynamic"))

# shorthand way:
box.data.physics = Physics(type="dynamic")

# don't forget to call scene.update_object to see your chnages in the ARENA!
scene.update_object(box)

Updating Attributes

Most attributes (except object_id, persist, ttl, and parent) are under the “data” field. Access these by using obj.data.

box.data.position.x = 2
# box.update_attributes(position=Position(2,4,-2)) works too
scene.update_object(box)

Removing Object Attributes

obj.data.click_listener = None # or, obj.data.clickable = None
# obj.update_attributes(click_listener=None) works too

Update Handler

The update_handler will be called whenever the object is updated by the library of by some external program

# [obj] is the Object that called the update handler
def update(obj):
    print(obj)

obj.update_handler = update
# obj.update_attributes(update_handler=update) works too

Automatic Updates

ARENA-py will keep track of internal states of active objects in a scene, so the library user doesn’t have to. This means if you create an Object in a Scene, the Scene instance will listen to incoming messages and update your Object instance’s attributes automatically!

This allows ARENA-py programs to interact with the build page, with users, and even with other ARENA-py programs. As long as your program is running, you do not need to manually keep track of your Objects’ current state in the scene.

For instance, if you create an Object in ARENA-py and you update its position with the build page or with another program, that Object’s position in the original ARENA-py program will automatically be updated for you!

All Objects

Box

Create a box:

Box(...)

Circle

Create a flat circle:

Circle(...)

Cone

Create a cone:

Cone(...)

Cylinder

Create a cylinder:

Cylinder(...)

Dodecahedron

Create a dodecahedron:

Dodecahedron(...)

GLTF

Create a gltf 3D model:

GLTF(url, ...)

Icosahedron

Create an icosahedron:

Icosahedron(...)

Image

Create a flat image:

Image(url, ...)

Light

Create a light:

Light(...)

Line

Create a thin line:

Line(path, ...)

Octahedron

Create an octahedron:

Octahedron(...)

Plane

Create a flat plane:

Plane(...)

Ring

Create a flat ring:

Ring(...)

Sphere

Create a sphere:

Sphere(...)

Tetrahedron

Create a tetrahedron:

Tetrahedron(...)

Text

Write 3D text:

Text(...)

ThickLine

Create a thickline:

ThickLine(path, lineWidth, ...)

Torus

Create a torus:

Torus(...)

TorusKnot

Create a torus-knot:

TorusKnot(...)

Triangle

Create a flat triangle:

Triangle(...)

Particle

Add a particle effect (may be unsupported):

Particle(...)

Camera

Camera(object_id, ...)

Generic Object

For objects that might not exist yet (but may exist in AFRAME). Inherit from this class to create custom objects.

Object(object_type, ...)