Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: render material and render material proxy #385

Merged
merged 2 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/specklepy/objects/other.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from dataclasses import dataclass

from specklepy.objects.base import Base


@dataclass(kw_only=True)
class RenderMaterial(
Base,
speckle_type="Objects.Other.RenderMaterial",
serialize_ignore={"diffuse", "emissive"},
):
"""
Minimal physically based material DTO class. Based on references from
https://threejs.org/docs/index.html#api/en/materials/MeshStandardMaterial
"""

name: str
opacity: float = 1.0
metalness: float = 0.0
roughness: float = 1.0
diffuse: int # ARGB color as int
emissive: int = 0 # ARGB color as int, defaults to black
19 changes: 19 additions & 0 deletions src/specklepy/objects/proxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from specklepy.objects.base import Base
from specklepy.objects.interfaces import IHasUnits
from specklepy.objects.other import RenderMaterial


@dataclass(kw_only=True)
Expand Down Expand Up @@ -46,3 +47,21 @@ class InstanceDefinitionProxy(
objects: List[str]
max_depth: int
name: str


@dataclass(kw_only=True)
class RenderMaterialProxy(
Base,
speckle_type="Objects.Other.RenderMaterialProxy",
detachable={"objects"},
):
"""
used to store render material to object relationships in root collections

Args:
objects (list): the list of application ids of objects used by render material
value (RenderMaterial): the render material used by the objects
"""

objects: List[str]
value: RenderMaterial