regex fix, camera default fix
This commit is contained in:
@ -25,7 +25,7 @@ class Command:
|
||||
|
||||
|
||||
class CommandChainParser:
|
||||
CHAIN_PATTERN = r"^(([a-zA-Z0-9]+(?:\(([^()]*|(?1)+)(\s*\,\s*(?1))*\))?)(\.(?1))*)"
|
||||
CHAIN_PATTERN = r"^(([a-zA-Z0-9\-+]+(?:\(([^()]*|(?1)+)(\s*\,\s*(?1))*\))?)(\.(?1))*)"
|
||||
|
||||
def __init__(self, _command_chain: str) -> None:
|
||||
self.command_chain = _command_chain
|
||||
|
||||
@ -271,7 +271,7 @@ class Camera(Object):
|
||||
def __init__(self, _focus: float = 2.0) -> None:
|
||||
super().__init__()
|
||||
self.focus = _focus
|
||||
self.transform.translate(8.0, 8.0, 8.0).lookat(0.0, 0.0, 0.0)
|
||||
# self.transform.translate(8.0, 8.0, 8.0).lookat(0.0, 0.0, 0.0)
|
||||
|
||||
def parse_args(self, args: list[str]):
|
||||
self.focus = ArgParser.as_float(args)
|
||||
|
||||
@ -14,12 +14,14 @@ class Scene:
|
||||
from konabot.plugins.marchtoy.obj import Object, Camera, OBJECT_ENTRIES
|
||||
logger.info(f"building scene: {_instruction}")
|
||||
self.canvas_objs: list[tuple[Object, str]] = []
|
||||
self.camera: Camera = Camera()
|
||||
self.camera: Camera = Camera(1.0 / np.tan(np.deg2rad(30.0)))
|
||||
self.camera.transform.translate(8.0, 8.0, 8.0).lookat(0.0, 0.0, 0.0)
|
||||
|
||||
for raw_cmd in CommandChainParser(_instruction):
|
||||
cmd_queue = CommandParser(raw_cmd)
|
||||
cmd_obj = next(cmd_queue)
|
||||
obj_id, obj_args = cmd_obj.id, cmd_obj.args
|
||||
# logger.info(f"parsing object: {obj_id} with args {obj_args}")
|
||||
logger.info(f"parsing object: {obj_id} with args {obj_args}")
|
||||
obj_instance: Optional[Object] = None
|
||||
if obj_id in OBJECT_ENTRIES:
|
||||
obj_cls = OBJECT_ENTRIES[obj_id]
|
||||
@ -35,11 +37,11 @@ class Scene:
|
||||
) from e
|
||||
else:
|
||||
raise Exception(f"{obj_id} is not a valid object type.")
|
||||
# logger.info(f"parsed object {obj_id}({obj_args})")
|
||||
logger.info(f"parsed object {obj_id}({obj_args})")
|
||||
if obj_instance != None:
|
||||
for cmd in cmd_queue:
|
||||
op_id, op_args = cmd.id, cmd.args
|
||||
# logger.info(f"parsing operation {op_id} with args {op_args}")
|
||||
logger.info(f"parsing operation {op_id} with args {op_args}")
|
||||
if op_id in OPERATION_ENTRIES:
|
||||
op_func = OPERATION_ENTRIES[op_id]
|
||||
if not callable(op_func):
|
||||
@ -47,12 +49,12 @@ class Scene:
|
||||
op_func(obj_instance, op_args)
|
||||
else:
|
||||
raise Exception(f"{op_id} is not a valid operation.")
|
||||
# logger.info(f"parsed operation {op_id}({op_args})")
|
||||
logger.info(f"parsed operation {op_id}({op_args})")
|
||||
|
||||
try:
|
||||
sdf_block = obj_instance.sdf_block_glsl()
|
||||
self.canvas_objs.append((obj_instance, sdf_block))
|
||||
# logger.info(f"parsed sdf {sdf_block}")
|
||||
logger.info(f"parsed sdf {sdf_block}")
|
||||
except:
|
||||
# logger.info(f"parsed camera")
|
||||
if type(obj_instance) == Camera:
|
||||
|
||||
Reference in New Issue
Block a user