vuer 0.0.15rc1__py3-none-any.whl → 0.0.15rc2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of vuer might be problematic. Click here for more details.

Binary file
Binary file
Binary file
Binary file
Binary file
vuer/base.py CHANGED
@@ -16,13 +16,9 @@ async def default_handler(request, ws):
16
16
 
17
17
 
18
18
  async def websocket_handler(request, handler, **ws_kwargs):
19
- print("New connection!!!")
20
-
21
19
  ws = web.WebSocketResponse(**ws_kwargs)
22
20
  await ws.prepare(request)
23
21
 
24
- print("Socket stored")
25
-
26
22
  try:
27
23
  await handler(request, ws)
28
24
 
@@ -101,7 +97,8 @@ class Server:
101
97
  site = web.TCPSite(runner, self.host, self.port)
102
98
  await site.start()
103
99
 
104
- print(f"Serving on http://{self.host}:{self.port}")
100
+ # This print has been very confusing to the user. Remove. - Ge
101
+ # print(f"Serving on http://{self.host}:{self.port}")
105
102
 
106
103
  event_loop = asyncio.get_event_loop()
107
104
 
vuer/events.py CHANGED
@@ -89,14 +89,19 @@ NOOP = Noop()
89
89
 
90
90
 
91
91
  class Set(ServerEvent):
92
- """
92
+ """Set Operation (Server Event).
93
+
93
94
  SET Operator is used exclusively to set the root Scene node. Throws an error (on the client side)
94
95
  if the data is not a Scene object.
95
96
  """
96
97
 
97
98
  etype = "SET"
99
+ """The Event Type."""
98
100
 
99
- def __init__(self, data: Type[Scene]):
101
+ def __init__(self, data: Scene):
102
+ """
103
+ :param data: The data to set.
104
+ """
100
105
  super().__init__(data)
101
106
 
102
107
 
@@ -276,14 +281,18 @@ class GrabRender(ServerRPC):
276
281
 
277
282
  etype = "GRAB_RENDER"
278
283
 
279
- def __init__(self, key="DEFAULT", **kwargs):
280
- super().__init__(data=kwargs, key=key)
284
+ def __init__(self, *, key: str = "DEFAULT", **kwargs):
285
+ super().__init__(data=kwargs)
286
+ self.key = key
281
287
  self.rtype = f"GRAB_RENDER_RESPONSE@{self.uuid}"
282
288
 
283
- # if __name__ == "__main__":
284
- # e = Frame @ {"hey": "yo"}
285
- # print(e)
286
- # print(e.data)
287
- #
288
- # e = Set @ {"data": "new"}
289
- # print(e.serialize())
289
+
290
+ if __name__ == "__main__":
291
+ # e = Frame @ {"hey": "yo"}
292
+ # print(e)
293
+ # print(e.data)
294
+ #
295
+ # e = Set @ {"data": "new"}
296
+ # print(e.serialize())
297
+ e = GrabRender({"message": "hey"})
298
+ print(e.serialize())
vuer/schemas.py CHANGED
@@ -1,4 +1,4 @@
1
- from typing import Union
1
+ from typing import Union, Tuple, List
2
2
 
3
3
  import numpy as np
4
4
  import PIL.Image as pil_image
@@ -262,8 +262,8 @@ class Scene(BlockElement):
262
262
  rawChildren=None,
263
263
  htmlChildren=None,
264
264
  bgChildren=None,
265
- # default to z-up
266
- up=[0, 0, 1],
265
+ # default to y-up to be consistent with three.js. Blender uses z-up though.
266
+ up=[0, 1, 0],
267
267
  **kwargs,
268
268
  ):
269
269
  super().__init__(*children, up=up, **kwargs)
@@ -334,10 +334,34 @@ class TriMesh(SceneElement):
334
334
 
335
335
 
336
336
  class PointCloud(SceneElement):
337
- tag = "PointCloud"
338
- children = []
337
+ """PointCould element, highly optimized for payload size and speed.
338
+
339
+ :param vertices: An optional numpy array of shape (N, 3) containing the vertices of the pointcloud.
340
+ :type vertices: NDArray[np.float16]
341
+ :param colors: An optional numpy array of shape (N, 3) containing the colors of the point cloud.
342
+ :type color: NDArray[np.uint8]
343
+ :param size: An optional float that sets the size of the points.
344
+ :type size: float
345
+ :param key: str An optional string that sets the key of the element.
346
+ :type key: str
347
+
348
+ Usage::
349
+
350
+ sess.upsert @ PointCloud(
351
+ vertices=np.random.rand(1000, 3),
352
+ colors=np.random.rand(1000, 3),
353
+ size=0.01,
354
+ key="pointcloud",
355
+ )
356
+
357
+ """
358
+
359
+ tag: str = "PointCloud"
339
360
  vertices: NDArray[np.float16] = None
361
+ """An optional numpy array of shape (N, 3) containing the vertices of the point cloud."""
340
362
  colors: NDArray[np.uint8] = None
363
+ """An optional numpy array of shape (N, 3) containing the colors of the point cloud."""
364
+ children = []
341
365
 
342
366
  def __post_init__(self, **kwargs):
343
367
  self.vertices = self.vertices.astype(np.float16).flatten().tobytes()
@@ -573,23 +597,70 @@ class Grid(SceneElement):
573
597
 
574
598
  class GrabRender(SceneElement):
575
599
  tag = "GrabRender"
600
+ key = "DEFAULT"
601
+ """We do not want the client to set keys automatically since GrabRender is
602
+ usually used a singleton component as default."""
576
603
 
577
604
 
578
605
  class TimelineControls(SceneElement):
579
606
  tag = "TimelineControls"
607
+ # todo: consider adding default component keys here.
580
608
 
581
609
 
582
610
  class PointerControls(SceneElement):
583
611
  tag = "PointerControls"
612
+ # todo: consider adding default component keys here.
584
613
 
585
614
 
586
615
  class DefaultScene(Scene):
616
+ """Default Scene that includes a basic setup of ambient lights.
617
+
618
+
619
+ :param children: list of children elements to be rendered in the scene.
620
+ :type children: SceneElement, ...
621
+ :param rawChildren: list of children elements to be rendered in the scene.
622
+ :param htmlChildren: list of children elements to be rendered in the scene.
623
+ :param bgChildren: list of children elements to be rendered in the scene.
624
+ :param show_helper: list of children elements to be rendered in the scene.
625
+ :param startStep: list of children elements to be rendered in the scene.
626
+ :param endStep: list of children elements to be rendered in the scene.
627
+ :param up: list of children elements to be rendered in the scene.
628
+ :param kwargs: list of children elements to be rendered in the scene.
629
+
630
+ Example Usage::
631
+
632
+ DefaultScene(
633
+ # Ambient Light does not have helper because it is ambient.
634
+ AmbientLight(intensity=1.0, key="default_ambient_light"),
635
+ DirectionalLight(
636
+ intensity=1, key="default_directional_light", helper=show_helper
637
+ ),
638
+ *children,
639
+ rawChildren=rawChildren,
640
+ htmlChildren=htmlChildren,
641
+ bgChildren=[
642
+ GrabRender(),
643
+ *[
644
+ # we use a key here so that we can replace the timeline controls via update
645
+ TimelineControls(start=startStep, end=endStep, key="timeline")
646
+ if endStep
647
+ else None,
648
+ ],
649
+ PointerControls(),
650
+ Grid(),
651
+ *bgChildren,
652
+ ],
653
+ up=up,
654
+ **kwargs,
655
+ )
656
+ """
657
+
587
658
  def __init__(
588
659
  self,
589
- *children,
590
- rawChildren=None,
591
- htmlChildren=None,
592
- bgChildren=[],
660
+ *children: SceneElement,
661
+ rawChildren: List[SceneElement] = None,
662
+ htmlChildren: List[Element] = None,
663
+ bgChildren: List[SceneElement] = [],
593
664
  show_helper=True,
594
665
  startStep=0,
595
666
  endStep=None,
@@ -599,9 +670,7 @@ class DefaultScene(Scene):
599
670
  ):
600
671
  rawChildren = [
601
672
  AmbientLight(intensity=1.0, key="default_ambient_light"),
602
- DirectionalLight(
603
- intensity=1, key="default_directional_light", helper=show_helper
604
- ),
673
+ DirectionalLight(intensity=1, key="default_directional_light", helper=show_helper),
605
674
  *(rawChildren or []),
606
675
  ]
607
676
 
@@ -611,7 +680,8 @@ class DefaultScene(Scene):
611
680
  rawChildren=rawChildren,
612
681
  htmlChildren=htmlChildren,
613
682
  bgChildren=[
614
- GrabRender(),
683
+ # skey spec here is a little redundant.
684
+ GrabRender(key="DEFAULT"),
615
685
  *[
616
686
  # we use a key here so that we can replace the timeline controls via update
617
687
  TimelineControls(start=startStep, end=endStep, key="timeline")
vuer/server.py CHANGED
@@ -92,7 +92,7 @@ class VuerSession:
92
92
 
93
93
  event = GrabRender(**kwargs)
94
94
 
95
- return await self.vuer.rpc(self.vuer.CURRENT_WS_ID, event, ttl=ttl)
95
+ return await self.vuer.rpc(self.CURRENT_WS_ID, event, ttl=ttl)
96
96
 
97
97
  @property
98
98
  def set(self) -> At:
@@ -116,7 +116,7 @@ class VuerSession:
116
116
  Supports passing in a list of elements. (Thank God I implemented this...
117
117
  so handy! - Ge)
118
118
 
119
- Example Usage:
119
+ Example Usage::
120
120
 
121
121
  app.update @ [element1, element2, ...]
122
122
  """
@@ -136,11 +136,11 @@ class VuerSession:
136
136
 
137
137
  Requires a parentKey, or treats the Scene root node as the default parent.
138
138
 
139
- Example Usage:
139
+ Example Usage::
140
140
 
141
141
  app.add(element1, element2, ..., to=parentKey.)
142
142
 
143
- or using the Scene root node as the default parent:
143
+ or using the Scene root node as the default parent: ::
144
144
 
145
145
  app.add @ element1
146
146
 
@@ -161,11 +161,11 @@ class VuerSession:
161
161
 
162
162
  Requires a parentKey, or treats the Scene root node as the default parent.
163
163
 
164
- Example Usage:
164
+ Example Usage::
165
165
 
166
166
  app.upsert(element1, element2, ..., to=parentKey.)
167
167
 
168
- or using the Scene root node as the default parent:
168
+ or using the Scene root node as the default parent: ::
169
169
 
170
170
  app.upsert @ element1
171
171
 
@@ -184,11 +184,11 @@ class VuerSession:
184
184
  def remove(self) -> At:
185
185
  """Remove elements by keys.
186
186
 
187
- Example Usage:
187
+ Example Usage::
188
188
 
189
189
  app.remove @ ["key1", "key2", ...]
190
190
 
191
- or a single key:
191
+ or a single key: ::
192
192
 
193
193
  app.remove @ "key1"
194
194
 
@@ -269,7 +269,6 @@ class Vuer(PrefixProto, Server):
269
269
  self.ws = {}
270
270
  self.spawned_fn: Spawnable = None
271
271
  self.spawned_coroutines = []
272
- self.CURRENT_WS_ID = None
273
272
 
274
273
  async def relay(self, request):
275
274
  """This is the relay object for sending events to the server.
@@ -436,7 +435,7 @@ class Vuer(PrefixProto, Server):
436
435
  # note: by-pass the uplink message queue entirely, rendering it immune
437
436
  # to the effects of queue length.
438
437
  await self.send(ws_id, event)
439
- await sleep(0.5)
438
+ # await sleep(0.5)
440
439
  try:
441
440
  await asyncio.wait_for(rpc_event.wait(), ttl)
442
441
  except asyncio.TimeoutError as e:
@@ -462,7 +461,7 @@ class Vuer(PrefixProto, Server):
462
461
  ws_id = proxy.CURRENT_WS_ID
463
462
  queue = proxy.uplink_queue
464
463
 
465
- print(f"\rUplink task running:{ws_id}")
464
+ print(f"\rUplink task running. id:{ws_id}")
466
465
  while True:
467
466
  if ws_id not in self.ws:
468
467
  print(f"uplink:{ws_id} is not in websocket pool")
@@ -599,7 +598,7 @@ class Vuer(PrefixProto, Server):
599
598
  return ttl_handler()
600
599
 
601
600
  def run(self, kill=None, *args, **kwargs):
602
- print("Vuer running at: " + self.get_url())
601
+ import os
603
602
 
604
603
  # protocol, host, _ = self.uri.split(":")
605
604
  # port = int(_)
@@ -614,7 +613,9 @@ class Vuer(PrefixProto, Server):
614
613
  self._socket("", self.downlink)
615
614
  # serve local files via /static endpoint
616
615
  self._static("/static", self.static_root)
617
- print("serving static files from", self.static_root, "at", "/static")
616
+ print("Serving file://" + os.path.abspath(self.static_root), "at", "/static")
618
617
  self._route("/relay", self.relay, method="POST")
619
618
 
619
+ print("Visit: " + self.get_url())
620
+
620
621
  super().run()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vuer
3
- Version: 0.0.15rc1
3
+ Version: 0.0.15rc2
4
4
  Home-page: https://github.com/geyang/vuer
5
5
  Author: Ge Yang<ge.ike.yang@gmail.com>
6
6
  Author-email: ge.ike.yang@gmail.com
@@ -1,16 +1,16 @@
1
1
  vuer/__init__.py,sha256=HMgKfbQAW77ukrMOnE2oKNOYbSNEkBwElpkWxLofvP8,41
2
- vuer/base.py,sha256=mODsrpH8qePkfVjx5rXdXs7xjt2zpjcSOs_jzUpNbLI,3051
3
- vuer/events.py,sha256=hPCCGZxL090rz3u_ySB_vFB0d7tgOwdQVPNL487z37k,7069
4
- vuer/schemas.py,sha256=JI2-91cvGKCuA5mjbE29YVIBNajKge9ZnxiJzqcd4m0,14403
2
+ vuer/base.py,sha256=R-PtD39ouihiEGmSfJL26chlU0XkFJP-JmBNYzDdEvM,3068
3
+ vuer/events.py,sha256=2N6B9sYkxxVv6BhegBq-dIc8mxb3A42lgJz-pD1MCRU,7272
4
+ vuer/schemas.py,sha256=_jQYPTtYQ0JoN5_bTygfX8CdB1tCTZlif6o6nPuXmAM,17502
5
5
  vuer/serdes.py,sha256=gD2iA9Yypu1QjocneOT3Nc0y6q_mdHn9zW1ko5j3I7c,2600
6
- vuer/server.py,sha256=i-ShDfxAr5KBXtgCTLDbbqpj1ExjaAROF_mv4P0jOSM,18521
6
+ vuer/server.py,sha256=vdnKH4WwvJYTkE1v3lVjY_GKGL1dOcwxq6OqSeKD8OI,18506
7
7
  vuer/types.py,sha256=YpRQrBzB2uGM1Lhu8eSaBGB88IgSnY4Czl5cgthxGkM,1003
8
8
  vuer/__pycache__/__init__.cpython-38.pyc,sha256=rS-9zzAjFEXnObk5q3E5Rex_uvoJ-Ccfz7Hs9DGNVgs,188
9
- vuer/__pycache__/base.cpython-38.pyc,sha256=cxwPAy8hWCo5t9TaTaaT1gs2MpByDbAOKCMVbqVldds,3930
10
- vuer/__pycache__/events.cpython-38.pyc,sha256=7NT7W5ObDyCz542mhDQkLWYzMOIP0Ihx7syjnJZT6lE,9409
11
- vuer/__pycache__/schemas.cpython-38.pyc,sha256=D0fWjYOBNPSbQkH_aR_-yOz4BZcgflUB6c6TjnTt2DI,19936
12
- vuer/__pycache__/serdes.cpython-38.pyc,sha256=oT1A94H8ayRCxNnw0L-7Q5Dt3535MOwXZMkvyQQvB9M,2032
13
- vuer/__pycache__/server.cpython-38.pyc,sha256=aup7KkU3-iKB4LZKQRHmABOd7NQMw-iCNhl1geH4Um4,17318
9
+ vuer/__pycache__/base.cpython-38.pyc,sha256=Z5EFlRX9RqZsQUszvqPtAhLv_5QG5wlUXW7JbFd_XDc,3824
10
+ vuer/__pycache__/events.cpython-38.pyc,sha256=d8eqZPmim4QsTts1dkNmWmjcV4jbULFB3VjjqcHOtxo,9612
11
+ vuer/__pycache__/schemas.cpython-38.pyc,sha256=uqtDpdCxc8izVnUoLL4FuBKsWaG0pDdq7sxkhghoI8c,22588
12
+ vuer/__pycache__/serdes.cpython-38.pyc,sha256=KMxTjPEWuSGn2bqBAl5OLIDSCSoqfPDGfk3fvNnRDYA,2253
13
+ vuer/__pycache__/server.cpython-38.pyc,sha256=o8MqpilH06wXjccPBtg6sN36viU8lr7pkR3q1GLvi68,17302
14
14
  vuer/__pycache__/types.cpython-38.pyc,sha256=eM6bZ35nB-AYALbZXf9goHjLoHxllqbIwHloi0yCOeA,1868
15
15
  vuer/addons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  vuer/addons/nerf_vuer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -21,9 +21,9 @@ vuer/addons/nerf_vuer/render_components.py,sha256=XilHnJySJWVgmdUbPFNYyc_YWV8O5A
21
21
  vuer/addons/nerf_vuer/render_nodes.py,sha256=5TKqIbMPiOtBxfF4FQI6uB0w_9FTfGiwS8xRbhPa0_g,14441
22
22
  vuer/addons/nerfuer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  vuer/addons/nerfuer/render_nodes.py,sha256=EJK5N3xne5n7abTaAoLPX7SRqQ_tEen9zNypvSnZTTw,4465
24
- vuer-0.0.15rc1.dist-info/LICENSE,sha256=MGF-inVBUaGe2mEjqT0g6XsHIXwoNXgNHqD7Z1MzR0k,1063
25
- vuer-0.0.15rc1.dist-info/METADATA,sha256=y2jKpbzYnJYYT28RCpPyA6SMZ6lWbvc0PHjte1sZ6xQ,4280
26
- vuer-0.0.15rc1.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
27
- vuer-0.0.15rc1.dist-info/entry_points.txt,sha256=J_NM6fbpipmD9oP7cdxd1UyBR8mVEQVx0xjlE_56yss,41
28
- vuer-0.0.15rc1.dist-info/top_level.txt,sha256=ermmVkwvGFAK4gfSgDIwOmKpxwpqNt-oo7gVQQUSHok,5
29
- vuer-0.0.15rc1.dist-info/RECORD,,
24
+ vuer-0.0.15rc2.dist-info/LICENSE,sha256=MGF-inVBUaGe2mEjqT0g6XsHIXwoNXgNHqD7Z1MzR0k,1063
25
+ vuer-0.0.15rc2.dist-info/METADATA,sha256=kvvvLn_s9UAOKj-ZyxK65be2eQeXU72ovktFOmJv0nM,4280
26
+ vuer-0.0.15rc2.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
27
+ vuer-0.0.15rc2.dist-info/entry_points.txt,sha256=J_NM6fbpipmD9oP7cdxd1UyBR8mVEQVx0xjlE_56yss,41
28
+ vuer-0.0.15rc2.dist-info/top_level.txt,sha256=ermmVkwvGFAK4gfSgDIwOmKpxwpqNt-oo7gVQQUSHok,5
29
+ vuer-0.0.15rc2.dist-info/RECORD,,