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 Object
s’ 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 Primitive Geometric Mesh Objects
Box
Create a box:
Box(material, ...)
Capsule
Create a capsule:
Capsule(material, ...)
Circle
Create a flat circle:
Circle(material, ...)
Cone
Create a cone:
Cone(material, ...)
Cylinder
Create a cylinder:
Cylinder(material, ...)
Dodecahedron
Create a dodecahedron:
Dodecahedron(material, ...)
Icosahedron
Create an icosahedron:
Icosahedron(material, ...)
Octahedron
Create an octahedron:
Octahedron(material, ...)
Plane
Create a flat plane:
Plane(material, ...)
Ring
Create a flat ring:
Ring(material, ...)
Rounded Box
Create a rounded-box:
Roundedbox(material, ...)
Sphere
Create a sphere:
Sphere(material, ...)
Tetrahedron
Create a tetrahedron:
Tetrahedron(material, ...)
Torus
Create a torus:
Torus(material, ...)
TorusKnot
Create a torus-knot:
TorusKnot(material, ...)
Triangle
Create a flat triangle:
Triangle(material, ...)
All Objects
ARENA UI Card
Create an arenaui-card
Card(title, body, ...)
ARENA UI ButtonPanel
Create an arenaui-button-panel
ButtonPanel(title, buttons=[Button(...), ...], ...)
ARENA UI Prompt
Create an arenaui-prompt
Prompt(title, description, ...)
Camera
Camera(object_id, ...)
GLTF
Create a gltf 3D model:
GLTF(url, ...)
Hands
HandLeft(object_id, ...)
HandRight(object_id, ...)
Image
Create a flat image:
Image(url, width, height,...)
Light
Create a light:
Light(color, ...)
Line
Create a thin line:
Line(start, end, color, ...)
OBJ
Create a OBJ 3D model:
ObjModel(url, joints, ...)
Ocean
Create an animated ocean plane:
Ocean(color, ...)
Point Cloud
Create a pcd model:
PcdModel(url, pointColor, ...)
Gaussian Splat
Create a Gaussian splat model:
GaussianSplatting(src, ...)
Text
Write 3D text:
Text(value, color, ...)
THREE.js Scene
Create a three-js scene model:
ThreejsScene(url, ...)
ThickLine
Create a thick-line:
ThickLine(path, lineWidth, color, ...)
URDF
Create a urdf 3D model:
UrdfModel(url, joints, ...)
Videosphere
Create a videosphere:
Videosphere(src, material, ...)
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, ...)