Skip to content

Commit 12bf452

Browse files
committed
chore: create examples for scene commands
1 parent 4020c9a commit 12bf452

File tree

17 files changed

+193
-26
lines changed

17 files changed

+193
-26
lines changed

content/python/basic/color.md renamed to content/python/attributes/color.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
---
22
title: Color
33
layout: default
4-
parent: Basic
4+
parent: Attributes
55
grand_parent: Python Library
66
---
77

88
# Color
99

1010
Change only the color of the already-drawn box.
1111

12-
The following source code was mirrored from the `arena-py` [color.py](https://github.com/arenaxr/arena-py/blob/master/examples/basic/color.py) example.
12+
Additional Python properties are available in the [Color API Reference](/content/python-api/attributes/color).
13+
14+
The following source code was mirrored from the `arena-py` [color.py](https://github.com/arenaxr/arena-py/blob/master/examples/attributes/color.py) example.
1315

1416
```python
1517
from arena import *

content/python/basic/parent.md renamed to content/python/attributes/parent.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Parent
33
layout: default
4-
parent: Basic
4+
parent: Attributes
55
grand_parent: Python Library
66
---
77

@@ -11,7 +11,9 @@ Child objects inherit attributes of their parent, for example scale. Scale the p
1111

1212
There is support to attach a child to an already-existing parent scene objects. When creating a child object, set the `"parent": "parent_object_id"` value in the JSON data. For example if parent object is gltf-model_Earth and child object is gltf-model_Moon, the commands would look like:
1313

14-
The following source code was mirrored from the `arena-py` [parent.py](https://github.com/arenaxr/arena-py/blob/master/examples/basic/parent.py) example.
14+
Additional Python properties are available in the [Parent API Reference](/content/python-api/attributes/parent).
15+
16+
The following source code was mirrored from the `arena-py` [parent.py](https://github.com/arenaxr/arena-py/blob/master/examples/attributes/parent.py) example.
1517

1618
```python
1719
from arena import *

content/python/basic/object_id.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: ObjectId
3+
layout: default
4+
parent: Basic
5+
grand_parent: Python Library
6+
---
7+
8+
# Object Naming
9+
10+
11+
The following source code was mirrored from the `arena-py` [object_id.py](https://github.com/arenaxr/arena-py/blob/master/examples/basic/object_id.py) example.
12+
13+
```python
14+
from arena import *
15+
16+
scene = Scene(host="arenaxr.org", scene="example")
17+
18+
@scene.run_once
19+
def make_timed_sphere():
20+
# create a box with a uuid generated name
21+
box_named_id = Box()
22+
scene.add_object(box_named_id)
23+
24+
# create a box with the name "box1"
25+
box_named_uuid = Box(
26+
object_id="box1",
27+
)
28+
scene.add_object(box_named_uuid)
29+
30+
scene.run_tasks()
31+
```

content/python/simple/anim-test.md renamed to content/python/scenes/anim-test.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
title: AnimTest
33
layout: default
4-
parent: Simple
4+
parent: Scenes
55
grand_parent: Python Library
66
---
77

88
# Animation Test
99

10-
The following source code was mirrored from the `arena-py` [anim-test.py](https://github.com/arenaxr/arena-py/blob/master/examples/simple/anim-test.py) example.
10+
The following source code was mirrored from the `arena-py` [anim-test.py](https://github.com/arenaxr/arena-py/blob/master/examples/scenes/anim-test.py) example.
1111

1212
```python
1313
from arena import *

content/python/simple/device-scene.md renamed to content/python/scenes/device-scene.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
title: DeviceScene
33
layout: default
4-
parent: Simple
4+
parent: Scenes
55
grand_parent: Python Library
66
---
77

88
# Device Scene
99

1010
Demonstrate starting two connections, for a scene and a device, and communicating between them.
1111

12-
The following source code was mirrored from the `arena-py` [device-scene.py](https://github.com/arenaxr/arena-py/blob/master/examples/simple/device-scene.py) example.
12+
The following source code was mirrored from the `arena-py` [device-scene.py](https://github.com/arenaxr/arena-py/blob/master/examples/scenes/device-scene.py) example.
1313

1414
```python
1515
import json

content/python/simple/device-sensor.md renamed to content/python/scenes/device-sensor.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
title: DeviceSensor
33
layout: default
4-
parent: Simple
4+
parent: Scenes
55
grand_parent: Python Library
66
---
77

88
# Device Sensor
99

10-
The following source code was mirrored from the `arena-py` [device-sensor.py](https://github.com/arenaxr/arena-py/blob/master/examples/simple/device-sensor.py) example.
10+
The following source code was mirrored from the `arena-py` [device-sensor.py](https://github.com/arenaxr/arena-py/blob/master/examples/scenes/device-sensor.py) example.
1111

1212
```python
1313
import json
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: GetPersistedObjs
3+
layout: default
4+
parent: Scenes
5+
grand_parent: Python Library
6+
---
7+
8+
# Get Persisted Objects
9+
10+
Tests scene `get_persisted_objs`.
11+
12+
The following source code was mirrored from the `arena-py` [get-persisted-objs.py](https://github.com/arenaxr/arena-py/blob/master/examples/scenes/get-persisted-objs.py) example.
13+
14+
```python
15+
from arena import *
16+
17+
scene = Scene(host="arenaxr.org", scene="test")
18+
19+
@scene.run_once
20+
def main():
21+
object_id = "the_box"
22+
for obj_id,obj in scene.get_persisted_objs().items():
23+
print(obj)
24+
print()
25+
26+
scene.run_tasks()
27+
```

content/python/scenes.md renamed to content/python/scenes/index.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---
22
title: Scenes
3-
nav_order: 1
3+
nav_order: 1.1
44
layout: default
5+
has_children: true
56
parent: Python Library
67
---
78

@@ -90,19 +91,19 @@ This is a list of the most common options available in this mode, (`python3 prog
9091
```
9192
-h, --help show this help message and exit
9293
-mh HOST, --host HOST
93-
ARENA webserver main host to connect to
94+
ARENA webserver main host to connect to
9495
-n NAMESPACE, --namespace NAMESPACE
95-
Namespace of scene
96+
Namespace of scene
9697
-s SCENE, --scene SCENE
97-
Scene to publish and listen to
98+
Scene to publish and listen to
9899
-d DEVICE, --device DEVICE
99-
Device to publish and listen to
100+
Device to publish and listen to
100101
-p POSITION POSITION POSITION, --position POSITION POSITION POSITION
101-
App position as cartesian.x cartesian.y cartesian.z
102+
App position as 'x y z'
102103
-r ROTATION ROTATION ROTATION, --rotation ROTATION ROTATION ROTATION
103-
App rotation as euler.x euler.y euler.z
104+
App rotation as 'x y z'
104105
-c SCALE SCALE SCALE, --scale SCALE SCALE SCALE
105-
App scale as cartesian.x cartesian.y cartesian.z
106+
App scale as 'x y z'
106107
-D, --debug Debug mode.
107108
```
108109

content/python/scenes/move-camera.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: MoveCamera
3+
layout: default
4+
parent: Scenes
5+
grand_parent: Python Library
6+
---
7+
8+
# Move Camera
9+
10+
Move cameras to a random location.
11+
12+
The following source code was mirrored from the `arena-py` [move-camera.py](https://github.com/arenaxr/arena-py/blob/master/examples/scenes/move-camera.py) example.
13+
14+
```python
15+
import random
16+
17+
from arena import *
18+
19+
def rando():
20+
return float(random.randint(-100000, 100000)) / 1000
21+
22+
def user_join_callback(camera):
23+
print(f"User found: {camera.displayName} [object_id={camera.object_id}]")
24+
25+
scene = Scene(host="arenaxr.org", scene="test")
26+
scene.user_join_callback = user_join_callback
27+
28+
# box = Box(object_id="box")
29+
# scene.add_object(box)
30+
31+
@scene.run_forever(interval_ms=500)
32+
def move_cams():
33+
for c in scene.users:
34+
scene.manipulate_camera(
35+
c,
36+
position=(rando(),1.6,rando()),
37+
rotation=(0,0,0,1)
38+
)
39+
scene.look_at(
40+
c,
41+
target=(0,0,0)
42+
)
43+
44+
scene.run_tasks()
45+
```

content/python/simple/private-objs.md renamed to content/python/scenes/private-objs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: PrivateObjs
33
layout: default
4-
parent: Simple
4+
parent: Scenes
55
grand_parent: Python Library
66
---
77

@@ -18,7 +18,7 @@ to this program via private MQTT topics as well.
1818
We also print the global private objects dict to show how it is cleaned up when
1919
a user leaves the scene.
2020

21-
The following source code was mirrored from the `arena-py` [private-objs.py](https://github.com/arenaxr/arena-py/blob/master/examples/simple/private-objs.py) example.
21+
The following source code was mirrored from the `arena-py` [private-objs.py](https://github.com/arenaxr/arena-py/blob/master/examples/scenes/private-objs.py) example.
2222

2323
```python
2424
import random
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: RotateCamera
3+
layout: default
4+
parent: Scenes
5+
grand_parent: Python Library
6+
---
7+
8+
# Rotate Camera
9+
10+
Rotate cameras around the origin.
11+
12+
The following source code was mirrored from the `arena-py` [rotate-camera.py](https://github.com/arenaxr/arena-py/blob/master/examples/scenes/rotate-camera.py) example.
13+
14+
```python
15+
import math
16+
17+
from arena import *
18+
19+
radius = 10
20+
interval = 0
21+
sign = 1
22+
23+
def user_join_callback(camera):
24+
print(f"User found: {camera.displayName} [object_id={camera.object_id}]")
25+
26+
scene = Scene(host="arenaxr.org", scene="test")
27+
scene.user_join_callback = user_join_callback
28+
29+
@scene.run_forever(interval_ms=17)
30+
def move_cams():
31+
global interval, sign
32+
for c in scene.users:
33+
xp = radius*math.cos(interval)
34+
zp = radius*math.sin(interval)
35+
scene.manipulate_camera(
36+
c,
37+
position=(
38+
xp,
39+
3,
40+
zp,
41+
),
42+
#rotation=Rotation(0,0,0)
43+
)
44+
scene.look_at(
45+
c,
46+
# target={"x": 0, "y": 0, "z": 0}
47+
# target=(0, 0, 0)
48+
target=(xp, 0, zp)
49+
)
50+
if interval > 3.14:
51+
sign = -1
52+
elif interval < 0:
53+
sign = 1
54+
55+
interval = interval + (0.01*sign)
56+
57+
scene.run_tasks()
58+
```

content/python/simple/upload-file.md renamed to content/python/scenes/upload-file.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
title: UploadFile
33
layout: default
4-
parent: Simple
4+
parent: Scenes
55
grand_parent: Python Library
66
---
77

88
# Uploading Files
99

1010
Upload some sample files to the ARENA filestore under the user's store folder and create objects to render them.
1111

12-
The following source code was mirrored from the `arena-py` [upload-file.py](https://github.com/arenaxr/arena-py/blob/master/examples/simple/upload-file.py) example.
12+
The following source code was mirrored from the `arena-py` [upload-file.py](https://github.com/arenaxr/arena-py/blob/master/examples/scenes/upload-file.py) example.
1313

1414
```python
1515
from arena import *

content/python/simple/camera-print.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ parent: Simple
55
grand_parent: Python Library
66
---
77

8-
# Camera Tracer
8+
# Camera Print
99

1010
Camera tracing program. Draws a path that follows the user.
1111

content/python/simple/socket-client.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ grand_parent: Python Library
77

88
# Socket Client
99

10-
Generate ARENA object json and send it to socket-server.py.
10+
Generate ARENA object json and send it to `socket-server.py`.
1111

1212
The following source code was mirrored from the `arena-py` [socket-client.py](https://github.com/arenaxr/arena-py/blob/master/examples/simple/socket-client.py) example.
1313

content/python/simple/ui.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ parent: Simple
55
grand_parent: Python Library
66
---
77

8-
# ARENAUI
8+
# ARENA UI Panels
99

1010
Demonstrate a multi-path set of UI panels for a user to interact with.
1111

content/python/tutorial/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Python Tutorial
3-
nav_order: 0
3+
nav_order: 1.0
44
layout: default
55
has_children: true
66
parent: Python Library

scripts/pexample/make-py-examples.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def create_python_markdown(folder, add_api=False):
6767

6868

6969
create_python_markdown("basic")
70+
create_python_markdown("scenes")
7071
create_python_markdown("callbacks")
7172
create_python_markdown("objects", add_api)
7273
create_python_markdown("attributes", add_api)

0 commit comments

Comments
 (0)