Skip to content

Commit

Permalink
Merge pull request #171 from arenaxr/docstring
Browse files Browse the repository at this point in the history
feat(objects, attributes): added automated support for full schema with docstrings
  • Loading branch information
mwfarb committed Jan 30, 2024
2 parents 014957e + cf23f56 commit 359181f
Show file tree
Hide file tree
Showing 73 changed files with 1,268 additions and 341 deletions.
76 changes: 52 additions & 24 deletions arena/attributes/__init__.py
@@ -1,40 +1,68 @@
from .animation_mixer import AnimationMixer
from .animation import Animation
from .attribute import Attribute
from .color import Color
from .data import Data
from .goto_url import GotoUrl
from .impulse import Impulse
from .jitsi_video import JitsiVideo
from .material import Material
from .morph import Morph
from .physics import Physics
from .position import Position
from .rotation import Rotation
from .scale import Scale
from .sound import Sound
from .spe_particles import SpeParticles
from .text_input import TextInput
from .video_control import VideoControl
# This file is auto-generated from github.com/arenaxr/arena-schema, changes here may be overwritten.

from .translate import *
from .attribute import *
from .color import *
from .data import *
from .animation import *
from .animation_mixer import *
from .armarker import *
from .attribution import *
from .blip import *
from .box_collision_listener import *
from .click_listener import *
from .dynamic_body import *
from .gltf_model_lod import *
from .gltf_morph import *
from .goto_landmark import *
from .goto_url import *
from .impulse import *
from .jitsi_video import *
from .landmark import *
from .material import *
from .material_extras import *
from .multisrc import *
from .position import *
from .remote_render import *
from .rotation import *
from .scale import *
from .shadow import *
from .sound import *
from .spe_particles import *
from .static_body import *
from .textinput import *
from .video_control import *

# [TODO]: do something with this
ATTRIBUTE_TYPE_MAP = {
"animation-mixer": AnimationMixer,
"animation": Animation,
"attribute": Attribute,
"color": Color,
"data": Data,
"animation": Animation,
"animation_mixer": AnimationMixer,
"armarker": Armarker,
"attribution": Attribution,
"blip": Blip,
"box_collision_listener": BoxCollisionListener,
"click_listener": ClickListener,
"dynamic_body": DynamicBody,
"gltf_model_lod": GltfModelLod,
"gltf_morph": GltfMorph,
"goto_landmark": GotoLandmark,
"goto_url": GotoUrl,
"impulse": Impulse,
"jitsi_video": JitsiVideo,
"landmark": Landmark,
"material": Material,
"morph": Morph,
"physics": Physics,
"material_extras": MaterialExtras,
"multisrc": Multisrc,
"position": Position,
"remote_render": RemoteRender,
"rotation": Rotation,
"scale": Scale,
"shadow": Shadow,
"sound": Sound,
"spe_particles": SpeParticles,
"text_input": TextInput,
"static_body": StaticBody,
"textinput": Textinput,
"video_control": VideoControl,
}
22 changes: 20 additions & 2 deletions arena/attributes/animation.py
Expand Up @@ -6,8 +6,26 @@

class Animation(Attribute):
"""
Animation Attribute.
Usage: Animation(...)
Animation attribute class to manage its properties in the ARENA: Animate and tween values. More properties at (https://aframe.io/docs/1.5.0/components/animation.html) A-Frame Animation component. Easing properties are detailed at (https://easings.net) easings.net.
Usage: animation=Animation(...)
:param bool autoplay: Whether or not the animation should autoplay. Should be specified if the animation is defined for the animation-timeline component (currently not supported). Defaults to 'True' (optional)
:param float delay: How long (milliseconds) to wait before starting. (optional)
:param str dir: Which dir to go from from to to. Allows [normal, alternate, reverse] Defaults to 'normal' (optional)
:param float dur: How long (milliseconds) each cycle of the animation is. Defaults to '1000' (optional)
:param str easing: Easing function of animation. To ease in, ease out, ease in and out. See easings.net for more. Allows [easeInQuad, easeInCubic, easeInQuart, easeInQuint, easeInSine, easeInExpo, easeInCirc, easeInBack, easeInElastic, easeOutQuad, easeOutCubic, easeOutQuart, easeOutQuint, easeOutSine, easeOutExpo, easeOutCirc, easeOutBack, easeOutElastic, easeInOutQuad, easeInOutCubic, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInOutExpo, easeInOutCirc, easeInOutBack, easeInOutElastic, linear] Defaults to 'easeInQuad' (optional)
:param float elasticity: How much to bounce (higher is stronger). Defaults to '400' (optional)
:param bool enabled: If disabled, animation will stop and startEvents will not trigger animation start. Defaults to 'True' (optional)
:param str from: Initial value at start of animation. If not specified, the current property value of the entity will be used (will be sampled on each animation start). It is best to specify a from value when possible for stability. (optional)
:param bool isRawProperty: Flag to animate an arbitrary object property outside of A-Frame components for better performance. If set to true, for example, we can set property to like components.material.material.opacity. If property starts with components or object3D, this will be inferred to true. (optional)
:param str loop: How many times the animation should repeat. If the value is true, the animation will repeat infinitely. (optional)
:param list[dict] pauseEvents: Comma-separated list of events to listen to trigger pause. Can be resumed with resumeEvents. (optional)
:param str property: Property to animate. Can be a component name, a dot-delimited property of a component (e.g., material.color), or a plain attribute. (optional)
:param list[dict] resumeEvents: Comma-separated list of events to listen to trigger resume after pausing. (optional)
:param bool round: Whether to round values. (optional)
:param list[dict] startEvents: Comma-separated list of events to listen to trigger a restart and play. Animation will not autoplay if specified. startEvents will restart the animation, use pauseEvents to resume it. If there are other animation components on the entity animating the same property, those animations will be automatically paused to not conflict. (optional)
:param str to: Target value at end of animation. (optional)
:param str type: Right now only supports color for tweening isRawProperty color XYZ/RGB vector values. (optional)
"""
def __init__(self, **kwargs):
if "start" in kwargs:
Expand Down
16 changes: 14 additions & 2 deletions arena/attributes/animation_mixer.py
Expand Up @@ -2,6 +2,18 @@

class AnimationMixer(Animation):
"""
Animation Attribute.
Usage: AnimationMixer(...)
AnimationMixer attribute class to manage its properties in the ARENA: A list of available animations can usually be found by inspecting the model file or its documentation. All animations will play by default. To play only a specific set of animations, use wildcards: animation-mixer='clip: run_*'. More properties at (https://github.com/n5ro/aframe-extras/tree/master/src/loaders#animation) A-Frame Extras Animation.
Usage: animation_mixer=AnimationMixer(...)
:param bool clampWhenFinished: If true, halts the animation at the last frame. (optional)
:param str clip: Name of the animation clip(s) to play. Accepts wildcards. Defaults to '*' (optional)
:param float crossFadeDuration: Duration of cross-fades between clips, in seconds. (optional)
:param float duration: Duration of the animation, in seconds (0 = auto). (optional)
:param str loop: In repeat and pingpong modes, the clip plays once plus the specified number of repetitions. For pingpong, every second clip plays in reverse. Allows [once, repeat, pingpong] Defaults to 'repeat' (optional)
:param str repetitions: Number of times to play the clip, in addition to the first play (empty string = Infinity). Repetitions are ignored for loop: once. (optional)
:param float startAt: Sets the start of an animation to a specific time (in milliseconds). This is useful when you need to jump to an exact time in an animation. The input parameter will be scaled by the mixer's timeScale. (optional)
:param float timeScale: Scaling factor for playback speed. A value of 0 causes the animation to pause. Negative values cause the animation to play backwards. Defaults to '1' (optional)
"""

def __init__(self, **kwargs):
super().__init__(**kwargs)
22 changes: 22 additions & 0 deletions arena/attributes/armarker.py
@@ -0,0 +1,22 @@
from .attribute import Attribute


class Armarker(Attribute):
"""
Armarker attribute class to manage its properties in the ARENA: A location marker (such as an AprilTag, a lightAnchor, or an UWB tag), used to anchor scenes, or scene objects, in the real world.
Usage: armarker=Armarker(...)
:param bool buildable: Whether tag has 'dynamic' toggled on click. Used to position a tag, then lock into position. (optional)
:param bool dynamic: Dynamic tag, not used for localization. E.g., to move object to which this ARMarker component is attached to. Requires permissions to update the scene (if dynamic=true). (optional)
:param float ele: Tag elevation in meters. (optional)
:param float lat: Tag latitude. (optional)
:param float long: Tag longitude. (optional)
:param str markerid: The marker id (e.g. for AprilTag 36h11 family, an integer in the range [0, 586]). Defaults to '0' (optional)
:param str markertype: The marker type, technology-based. Allows [apriltag_36h11, lightanchor, uwb, vive, optitrack] Defaults to 'apriltag_36h11' (optional)
:param bool publish: Publish detections. Send detections to external agents (e.g. external builder script that places new markers in the scene). If dynamic=true and publish=true, object position is not updated (left up to external agent). (optional)
:param float size: Tag size in millimeters. Defaults to '150' (optional)
:param str url: URL associated with the tag. (optional)
"""

def __init__(self, **kwargs):
super().__init__(**kwargs)
20 changes: 20 additions & 0 deletions arena/attributes/attribution.py
@@ -0,0 +1,20 @@
from .attribute import Attribute


class Attribution(Attribute):
"""
Attribution attribute class to manage its properties in the ARENA: Attribution Component. Saves attribution data in any entity.
Usage: attribution=Attribution(...)
:param str author: Author name; e.g. 'Vaptor-Studio'. Defaults to 'Unknown' (optional)
:param str authorURL: Author homepage/profile; e.g. https://sketchfab.com/VapTor. (optional)
:param bool extractAssetExtras: Extract attribution info from asset extras; will override attribution info given (default: true). Defaults to 'True' (optional)
:param str license: License summary/short name; e.g. 'CC-BY-4.0'. Defaults to 'Unknown' (optional)
:param str licenseURL: License URL; e.g. http://creativecommons.org/licenses/by/4.0/. (optional)
:param str source: Model source e.g. 'Sketchfab'. Defaults to 'Unknown' (optional)
:param str sourceURL: Model source URL; e.g. https://sketchfab.com/models/2135501583704537907645bf723685e7. (optional)
:param str title: Model title; e.g. 'Spinosaurus'. Defaults to 'No Title' (optional)
"""

def __init__(self, **kwargs):
super().__init__(**kwargs)
18 changes: 18 additions & 0 deletions arena/attributes/blip.py
@@ -0,0 +1,18 @@
from .attribute import Attribute


class Blip(Attribute):
"""
Blip attribute class to manage its properties in the ARENA: When the object is created or deleted, it will animate in/out of the scene instead of appearing/disappearing instantly. Must have a geometric mesh.
Usage: blip=Blip(...)
:param bool applyDescendants: Apply blipout effect to include all descendents. Does not work for blipin. (optional)
:param bool blipin: Animate in on create, set false to disable. Defaults to 'True' (optional)
:param bool blipout: Animate out on delete, set false to disable. Defaults to 'True' (optional)
:param float duration: Animation duration in milliseconds. Defaults to '750' (optional)
:param str geometry: Geometry of the blipout plane. Allows [rect, disk, ring] Defaults to 'rect' (optional)
:param str planes: Which which clipping planes to use for effect. A top plane clips above it, bottom clips below it. Allows [both, top, bottom] Defaults to 'both' (optional)
"""

def __init__(self, **kwargs):
super().__init__(**kwargs)
14 changes: 14 additions & 0 deletions arena/attributes/box_collision_listener.py
@@ -0,0 +1,14 @@
from .attribute import Attribute


class BoxCollisionListener(Attribute):
"""
BoxCollisionListener attribute class to manage its properties in the ARENA: Listen for bounding-box collisions with user camera and hands. Must be applied to an object or model with geometric mesh. Collisions are determined by course bounding-box overlaps.
Usage: box_collision_listener=BoxCollisionListener(...)
:param bool dynamic: Set true for a moving object, which should have its bounding box recalculated regularly to determine proper collision. (optional)
:param bool enabled: Publish detections, set `false` to disable. Defaults to 'True' (optional)
"""

def __init__(self, **kwargs):
super().__init__(**kwargs)
14 changes: 14 additions & 0 deletions arena/attributes/click_listener.py
@@ -0,0 +1,14 @@
from .attribute import Attribute


class ClickListener(Attribute):
"""
ClickListener attribute class to manage its properties in the ARENA: Object will listen for clicks.
Usage: click_listener=ClickListener(...)
:param bool bubble: Set false to prevent click events from bubbling up to parent objects. See <a href='https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#event_bubbling'>Event Bubbling</a>. Defaults to 'True' (optional)
:param bool enabled: Publish events, set false to disable. Defaults to 'True' (optional)
"""

def __init__(self, **kwargs):
super().__init__(**kwargs)

0 comments on commit 359181f

Please sign in to comment.