def shape_callback(event=None): camname, objid, drop = handle_panel_event(event, dropdown=True) if not camname or not drop: return shape = drop USERS[camname].set_clipboard(callback=clipboard_callback, obj_type=arena.Shape(shape)) USERS[camname].set_textright(shape) USERS[camname].target_style = shape
def __init__(self, jData): # Warning: We may lose some object detail, not useful for full copy. self.object_id = jData["object_id"] self.persist = True # by nature if "object_type" in jData["attributes"]: self.object_type = arena.Shape(jData["attributes"]["object_type"]) if "position" in jData["attributes"]: self.position = (jData["attributes"]["position"]["x"], jData["attributes"]["position"]["y"], jData["attributes"]["position"]["z"]) if "rotation" in jData["attributes"]: self.rotation = (jData["attributes"]["rotation"]["x"], jData["attributes"]["rotation"]["y"], jData["attributes"]["rotation"]["z"], jData["attributes"]["rotation"]["w"]) if "scale" in jData["attributes"]: self.scale = (jData["attributes"]["scale"]["x"], jData["attributes"]["scale"]["y"], jData["attributes"]["scale"]["z"]) if "color" in jData["attributes"]: self.color = arena_color2rgb(jData["attributes"]["color"]) if "url" in jData["attributes"]: self.url = jData["attributes"]["url"] if "material" in jData["attributes"]: if "colorWrite" in jData["attributes"]["material"]: self.transparent_occlude = not jData["attributes"]["material"][ "colorWrite"] if "color" in jData["attributes"]["material"]: self.color_material = arena_color2rgb( jData["attributes"]["material"]["color"]) if "parent" in jData["attributes"]: self.parent = jData["attributes"]["parent"] if "click-listener" in jData["attributes"]: self.clickable = True if "dynamic-body" in jData["attributes"]: if "type" in jData["attributes"]["dynamic-body"]: self.physics = arena.Physics( jData["attributes"]["dynamic-body"]["type"])
def panel_callback(event=None): camname, objid, drop = handle_panel_event(event) if not camname or not objid: return # ignore disabled if not USERS[camname].panel[objid].enabled: return update_controls(USERS[camname].target_id) mode = USERS[camname].panel[objid].mode btype = USERS[camname].panel[objid].type if btype == ButtonType.TOGGLE: USERS[camname].panel[objid].set_active( not USERS[camname].panel[objid].active) else: if mode == USERS[camname].mode: # action cancel # button click is same, then goes off and NONE USERS[camname].panel[objid].set_active(False) USERS[camname].mode = Mode.NONE mode = Mode.NONE else: # if button goes on, last button must go off prev_objid = camname + "_button_" + USERS[camname].mode.value if prev_objid in USERS[camname].panel: USERS[camname].panel[prev_objid].set_active(False) USERS[camname].panel[objid].set_active(True) USERS[camname].mode = mode USERS[camname].set_textleft(USERS[camname].mode) USERS[camname].set_textright("") USERS[camname].del_clipboard() # clear last dropdown for but in USERS[camname].dbuttons: USERS[camname].dbuttons[but].delete() USERS[camname].dbuttons.clear() active = USERS[camname].panel[objid].active # toggle buttons if mode == Mode.LOCK: USERS[camname].follow_lock = active # TODO: after lock ensure original ray keeps lock button in reticle elif mode == Mode.REDPILL: USERS[camname].redpill = active show_redpill_scene(active) elif mode == Mode.LAMP: USERS[camname].set_lamp(active) # active buttons if mode == Mode.CREATE: update_dropdown(camname, objid, mode, arblib.SHAPES, 2, shape_callback) USERS[camname].set_clipboard(callback=clipboard_callback, obj_type=arena.Shape( USERS[camname].target_style)) elif mode == Mode.MODEL: update_dropdown(camname, objid, mode, MODELS, 2, model_callback) idx = MODELS.index(USERS[camname].target_style) url = MANIFEST[idx]['url_gltf'] sca = MANIFEST[idx]['scale'] USERS[camname].set_clipboard(callback=clipboard_callback, obj_type=arena.Shape.gltf_model, scale=(sca, sca, sca), url=url) elif mode == Mode.COLOR: update_dropdown(camname, objid, mode, arblib.COLORS, -2, color_callback) elif mode == Mode.OCCLUDE: update_dropdown(camname, objid, mode, arblib.BOOLS, -2, gen_callback) elif mode == Mode.RENAME: USERS[camname].typetext = "" update_dropdown(camname, objid, mode, arblib.KEYS, -2, rename_callback) USERS[camname].set_textright(USERS[camname].typetext) elif mode == Mode.PARENT: USERS[camname].typetext = "" USERS[camname].set_textright(USERS[camname].typetext) elif mode == Mode.WALL: USERS[camname].set_clipboard(obj_type=arena.Shape.circle, callback=wall_callback, scale=(0.005, 0.005, 0.005)) USERS[camname].set_textright("Start: tap flush corner.") elif mode == Mode.NUDGE: update_dropdown(camname, objid, mode, arblib.METERS, 2, gen_callback) if USERS[camname].target_id: do_nudge_select(camname, USERS[camname].target_id) elif mode == Mode.SCALE: update_dropdown(camname, objid, mode, arblib.METERS, 2, gen_callback) if USERS[camname].target_id: do_scale_select(camname, USERS[camname].target_id) elif mode == Mode.STRETCH: update_dropdown(camname, objid, mode, arblib.METERS, 2, gen_callback) if USERS[camname].target_id: do_stretch_select(camname, USERS[camname].target_id) elif mode == Mode.ROTATE: update_dropdown(camname, objid, mode, arblib.DEGREES, 2, gen_callback) if USERS[camname].target_id: do_rotate_select(camname, USERS[camname].target_id)