Luce packages
LuceLuce BaseLuciaOS

dymokomi/luced-3d

Source of release 0.11.5

0.11.5 / src / edit_kinds.luc

## The Edit node kinds. A kind is registered by two lines here: its node
## kind in `edit_kind_names`, and its module's kind() in edit_kind. The
## framework (the recipe, the viewport and the inspector) finds a node's
## kind here; edit_types.luc has what a kind plugs in.
from edit_types import EditKind
import edit_mesh
import edit_cad
import edit_sdf
import edit_gsplats

## The node kinds of the Edit kinds, in node menu order.
pub func edit_kind_names() -> list[str]:
    return [edit_mesh.kind_name, edit_cad.kind_name, edit_sdf.kind_name, edit_gsplats.kind_name]

## The kind of node kind `name` (built on each call: callers keep it), or
## none when it is not an Edit node.
pub func edit_kind(name: str) -> EditKind?:
    if name == edit_mesh.kind_name:
        return edit_mesh.kind()
    if name == edit_cad.kind_name:
        return edit_cad.kind()
    if name == edit_sdf.kind_name:
        return edit_sdf.kind()
    if name == edit_gsplats.kind_name:
        return edit_gsplats.kind()
    return none

pub func is_edit(name: str) -> bool:
    return name in edit_kind_names()

## Every kind's tools, then every kind's primitives, each name once in
## registry order: the commands the viewport's tool strip offers.
pub func edit_tool_names() -> list[str]:
    let result: list[str] = []
    for name in edit_kind_names():
        let kind = edit_kind(name) else continue
        for tool in kind.tools:
            if not (tool.name in result): result.append(tool.name)
    return result

pub func edit_primitive_names() -> list[str]:
    let result: list[str] = []
    for name in edit_kind_names():
        let kind = edit_kind(name) else continue
        for primitive in kind.primitives:
            if not (primitive in result): result.append(primitive)
    return result