compas-threejs 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. compas_threejs-1.0.1/LICENSE +21 -0
  2. compas_threejs-1.0.1/MANIFEST.in +1 -0
  3. compas_threejs-1.0.1/PKG-INFO +89 -0
  4. compas_threejs-1.0.1/README.md +43 -0
  5. compas_threejs-1.0.1/pyproject.toml +118 -0
  6. compas_threejs-1.0.1/setup.cfg +4 -0
  7. compas_threejs-1.0.1/src/compas_threejs/__init__.py +8 -0
  8. compas_threejs-1.0.1/src/compas_threejs/lights/__init__.py +15 -0
  9. compas_threejs-1.0.1/src/compas_threejs/lights/ambientlight.py +19 -0
  10. compas_threejs-1.0.1/src/compas_threejs/lights/light.py +11 -0
  11. compas_threejs-1.0.1/src/compas_threejs/lights/pointlight.py +76 -0
  12. compas_threejs-1.0.1/src/compas_threejs/lights/rectlight.py +73 -0
  13. compas_threejs-1.0.1/src/compas_threejs/lights/sky.py +57 -0
  14. compas_threejs-1.0.1/src/compas_threejs/lights/spotlight.py +143 -0
  15. compas_threejs-1.0.1/src/compas_threejs/lights/sunlight.py +72 -0
  16. compas_threejs-1.0.1/src/compas_threejs/materials/__init__.py +6 -0
  17. compas_threejs-1.0.1/src/compas_threejs/materials/generic_material.py +11 -0
  18. compas_threejs-1.0.1/src/compas_threejs/materials/line_material.py +30 -0
  19. compas_threejs-1.0.1/src/compas_threejs/materials/material.py +161 -0
  20. compas_threejs-1.0.1/src/compas_threejs/materials/physical_material.py +377 -0
  21. compas_threejs-1.0.1/src/compas_threejs/materials/point_material.py +34 -0
  22. compas_threejs-1.0.1/src/compas_threejs/metadata/__init__.py +4 -0
  23. compas_threejs-1.0.1/src/compas_threejs/metadata/metadata.py +22 -0
  24. compas_threejs-1.0.1/src/compas_threejs/tag/__init__.py +3 -0
  25. compas_threejs-1.0.1/src/compas_threejs/tag/tag.py +51 -0
  26. compas_threejs-1.0.1/src/compas_threejs/text/__init__.py +3 -0
  27. compas_threejs-1.0.1/src/compas_threejs/text/text_geometry.py +72 -0
  28. compas_threejs-1.0.1/src/compas_threejs/ui/__init__.py +8 -0
  29. compas_threejs-1.0.1/src/compas_threejs/ui/button.py +27 -0
  30. compas_threejs-1.0.1/src/compas_threejs/ui/checkbox.py +36 -0
  31. compas_threejs-1.0.1/src/compas_threejs/ui/load_json_button.py +27 -0
  32. compas_threejs-1.0.1/src/compas_threejs/ui/number_field.py +56 -0
  33. compas_threejs-1.0.1/src/compas_threejs/ui/select_menu.py +33 -0
  34. compas_threejs-1.0.1/src/compas_threejs/ui/slider.py +37 -0
  35. compas_threejs-1.0.1/src/compas_threejs/ui/ui_element.py +11 -0
  36. compas_threejs-1.0.1/src/compas_threejs/viewer/__init__.py +5 -0
  37. compas_threejs-1.0.1/src/compas_threejs/viewer/app.py +454 -0
  38. compas_threejs-1.0.1/src/compas_threejs/viewer/frontend/assets/compas_icon_white.png +0 -0
  39. compas_threejs-1.0.1/src/compas_threejs/viewer/frontend/assets/index.css +2 -0
  40. compas_threejs-1.0.1/src/compas_threejs/viewer/frontend/assets/index.js +4170 -0
  41. compas_threejs-1.0.1/src/compas_threejs/viewer/frontend/index.html +25 -0
  42. compas_threejs-1.0.1/src/compas_threejs/viewer/inbox.py +153 -0
  43. compas_threejs-1.0.1/src/compas_threejs/viewer/outbox.py +79 -0
  44. compas_threejs-1.0.1/src/compas_threejs/viewer/remote.py +279 -0
  45. compas_threejs-1.0.1/src/compas_threejs/viewer/server.py +158 -0
  46. compas_threejs-1.0.1/src/compas_threejs/viewer/workspace.py +566 -0
  47. compas_threejs-1.0.1/src/compas_threejs.egg-info/PKG-INFO +89 -0
  48. compas_threejs-1.0.1/src/compas_threejs.egg-info/SOURCES.txt +50 -0
  49. compas_threejs-1.0.1/src/compas_threejs.egg-info/dependency_links.txt +1 -0
  50. compas_threejs-1.0.1/src/compas_threejs.egg-info/requires.txt +20 -0
  51. compas_threejs-1.0.1/src/compas_threejs.egg-info/top_level.txt +1 -0
  52. compas_threejs-1.0.1/tests/test_compas_pb_compatibility.py +61 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 COMPAS Association
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ recursive-include src/compas_threejs/viewer/frontend/ *
@@ -0,0 +1,89 @@
1
+ Metadata-Version: 2.4
2
+ Name: compas_threejs
3
+ Version: 1.0.1
4
+ Summary: A lightweight Three.js viewer for COMPAS using Protobuf
5
+ Author-email: Eric Gozzi <eric.gozzi@arch.ethz.ch>, Nicolas Benjamin Boscoboinik <boscoboinik@arch.ethz.ch>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://compas.dev/compas_threejs
8
+ Project-URL: Documentation, https://compas.dev/compas_threejs
9
+ Project-URL: Repository, https://github.com/compas-dev/compas_threejs
10
+ Project-URL: Changelog, https://github.com/compas-dev/compas_threejs/blob/main/CHANGELOG.md
11
+ Project-URL: Forum, https://forum.compas-framework.org/
12
+ Project-URL: Issues, https://github.com/compas-dev/compas_threejs/issues
13
+ Keywords: compas,viewer,threejs,protobuf
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Topic :: Scientific/Engineering
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: compas
27
+ Requires-Dist: compas-pb<2,>=1
28
+ Requires-Dist: compas_brep[occ]
29
+ Requires-Dist: websockets
30
+ Requires-Dist: fastapi
31
+ Requires-Dist: uvicorn
32
+ Requires-Dist: rich
33
+ Provides-Extra: dev
34
+ Requires-Dist: build; extra == "dev"
35
+ Requires-Dist: bump-my-version; extra == "dev"
36
+ Requires-Dist: invoke; extra == "dev"
37
+ Requires-Dist: mkdocs; extra == "dev"
38
+ Requires-Dist: mkdocs-material; extra == "dev"
39
+ Requires-Dist: mkdocstrings; extra == "dev"
40
+ Requires-Dist: mkdocstrings-python; extra == "dev"
41
+ Requires-Dist: compas_invocations2[mkdocs]>=1.0.2; extra == "dev"
42
+ Requires-Dist: ruff; extra == "dev"
43
+ Requires-Dist: wheel; extra == "dev"
44
+ Requires-Dist: pytest>=8.4.2; extra == "dev"
45
+ Dynamic: license-file
46
+
47
+ # COMPAS ThreeJS
48
+
49
+ <p align="center">
50
+ <a href="https://pypi.org/project/compas-threejs/"><img src="https://img.shields.io/pypi/v/compas-threejs.svg" alt="PyPI version"></a>
51
+ <a href="https://pypi.org/project/compas-threejs/"><img src="https://img.shields.io/pypi/pyversions/compas-threejs.svg" alt="Python versions"></a>
52
+ <a href="https://github.com/compas-dev/compas_threejs/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License MIT"></a>
53
+ <a href="https://github.com/compas-dev/compas_threejs/actions"><img src="https://github.com/compas-dev/compas_threejs/actions/workflows/build.yml/badge.svg" alt="Build Status"></a>
54
+ <a href="https://compas.dev/compas_threejs"><img src="https://img.shields.io/badge/docs-latest-brightgreen.svg" alt="Documentation"></a>
55
+ <a href="https://compas.dev/mission-control/#compas_threejs"><img src="https://compas.dev/badge.svg" alt="Made with COMPAS"></a>
56
+ </p>
57
+
58
+ `compas_threejs` is a browser-based 3D viewer for COMPAS geometry. The Python
59
+ package serves a bundled Three.js frontend and exchanges geometry, scene, and
60
+ interaction messages through COMPAS Protobuf and WebSockets.
61
+
62
+ ## Installation
63
+
64
+ ```bash
65
+ pip install compas_threejs
66
+ ```
67
+
68
+ ## Quick start
69
+
70
+ ```python
71
+ from compas.geometry import Box
72
+ from compas_threejs.viewer import App
73
+
74
+ viewer = App()
75
+ viewer.add_geometry(Box(2, 3, 1))
76
+ viewer.start(show=True)
77
+ ```
78
+
79
+ The viewer runs until interrupted with `Ctrl+C`.
80
+
81
+ ## Related projects
82
+
83
+ - [TypeScript viewer](https://github.com/compas-dev/compas_threejs_ts)
84
+ - [COMPAS](https://github.com/compas-dev/compas)
85
+ - [COMPAS Protobuf](https://github.com/compas-dev/compas_pb)
86
+
87
+ ## License
88
+
89
+ MIT, copyright COMPAS Association. See [LICENSE](LICENSE).
@@ -0,0 +1,43 @@
1
+ # COMPAS ThreeJS
2
+
3
+ <p align="center">
4
+ <a href="https://pypi.org/project/compas-threejs/"><img src="https://img.shields.io/pypi/v/compas-threejs.svg" alt="PyPI version"></a>
5
+ <a href="https://pypi.org/project/compas-threejs/"><img src="https://img.shields.io/pypi/pyversions/compas-threejs.svg" alt="Python versions"></a>
6
+ <a href="https://github.com/compas-dev/compas_threejs/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License MIT"></a>
7
+ <a href="https://github.com/compas-dev/compas_threejs/actions"><img src="https://github.com/compas-dev/compas_threejs/actions/workflows/build.yml/badge.svg" alt="Build Status"></a>
8
+ <a href="https://compas.dev/compas_threejs"><img src="https://img.shields.io/badge/docs-latest-brightgreen.svg" alt="Documentation"></a>
9
+ <a href="https://compas.dev/mission-control/#compas_threejs"><img src="https://compas.dev/badge.svg" alt="Made with COMPAS"></a>
10
+ </p>
11
+
12
+ `compas_threejs` is a browser-based 3D viewer for COMPAS geometry. The Python
13
+ package serves a bundled Three.js frontend and exchanges geometry, scene, and
14
+ interaction messages through COMPAS Protobuf and WebSockets.
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ pip install compas_threejs
20
+ ```
21
+
22
+ ## Quick start
23
+
24
+ ```python
25
+ from compas.geometry import Box
26
+ from compas_threejs.viewer import App
27
+
28
+ viewer = App()
29
+ viewer.add_geometry(Box(2, 3, 1))
30
+ viewer.start(show=True)
31
+ ```
32
+
33
+ The viewer runs until interrupted with `Ctrl+C`.
34
+
35
+ ## Related projects
36
+
37
+ - [TypeScript viewer](https://github.com/compas-dev/compas_threejs_ts)
38
+ - [COMPAS](https://github.com/compas-dev/compas)
39
+ - [COMPAS Protobuf](https://github.com/compas-dev/compas_pb)
40
+
41
+ ## License
42
+
43
+ MIT, copyright COMPAS Association. See [LICENSE](LICENSE).
@@ -0,0 +1,118 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "compas_threejs"
7
+ dynamic = ["version"]
8
+ description = "A lightweight Three.js viewer for COMPAS using Protobuf"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ authors = [
12
+ { name = "Eric Gozzi", email = "eric.gozzi@arch.ethz.ch" },
13
+ { name = "Nicolas Benjamin Boscoboinik", email = "boscoboinik@arch.ethz.ch" },
14
+ ]
15
+ keywords = ["compas", "viewer", "threejs", "protobuf"]
16
+ license = "MIT"
17
+ license-files = ["LICENSE"]
18
+ classifiers = [
19
+ "Development Status :: 4 - Beta",
20
+ "Intended Audience :: Developers",
21
+ "Topic :: Scientific/Engineering",
22
+ "Operating System :: OS Independent",
23
+ "Programming Language :: Python",
24
+ "Programming Language :: Python :: 3",
25
+ "Programming Language :: Python :: 3.9",
26
+ "Programming Language :: Python :: 3.10",
27
+ "Programming Language :: Python :: 3.11",
28
+ ]
29
+ dependencies = [
30
+ "compas",
31
+ "compas-pb>=1,<2",
32
+ "compas_brep[occ]",
33
+ "websockets",
34
+ "fastapi",
35
+ "uvicorn",
36
+ "rich",
37
+ ]
38
+
39
+ [project.optional-dependencies]
40
+ dev = [
41
+ "build",
42
+ "bump-my-version",
43
+ "invoke",
44
+ "mkdocs",
45
+ "mkdocs-material",
46
+ "mkdocstrings",
47
+ "mkdocstrings-python",
48
+ "compas_invocations2[mkdocs]>=1.0.2",
49
+ "ruff",
50
+ "wheel",
51
+ "pytest>=8.4.2",
52
+ ]
53
+
54
+ [project.urls]
55
+ Homepage = "https://compas.dev/compas_threejs"
56
+ Documentation = "https://compas.dev/compas_threejs"
57
+ Repository = "https://github.com/compas-dev/compas_threejs"
58
+ Changelog = "https://github.com/compas-dev/compas_threejs/blob/main/CHANGELOG.md"
59
+ Forum = "https://forum.compas-framework.org/"
60
+ Issues = "https://github.com/compas-dev/compas_threejs/issues"
61
+
62
+ [tool.pytest.ini_options]
63
+ testpaths = ["tests"]
64
+
65
+ [tool.ruff]
66
+ line-length = 179
67
+ indent-width = 4
68
+ target-version = "py39"
69
+
70
+ [tool.ruff.lint]
71
+ select = ["E", "F", "I"]
72
+
73
+ [tool.ruff.lint.per-file-ignores]
74
+ "__init__.py" = ["I001"]
75
+ "tasks.py" = ["I001"]
76
+
77
+ [tool.ruff.lint.isort]
78
+ force-single-line = true
79
+ known-first-party = ["compas_threejs"]
80
+
81
+ [tool.ruff.lint.pydocstyle]
82
+ convention = "numpy"
83
+
84
+ [tool.ruff.lint.pycodestyle]
85
+ max-doc-length = 179
86
+
87
+ [tool.ruff.format]
88
+ docstring-code-format = true
89
+ docstring-code-line-length = "dynamic"
90
+
91
+ [tool.bumpversion]
92
+ current_version = "1.0.1"
93
+ message = "Bump version to {new_version}"
94
+ commit = true
95
+ tag = true
96
+
97
+ [[tool.bumpversion.files]]
98
+ filename = "src/compas_threejs/__init__.py"
99
+ search = "{current_version}"
100
+ replace = "{new_version}"
101
+
102
+ [[tool.bumpversion.files]]
103
+ filename = "CHANGELOG.md"
104
+ search = "Unreleased"
105
+ replace = "[{new_version}] - {now:%Y-%m-%d}"
106
+
107
+ # -- DISCOVERY --
108
+ # Tells setuptools that the code is inside the 'src' folder
109
+ [tool.setuptools.packages.find]
110
+ where = ["src"]
111
+
112
+ # -- STATIC FILES --
113
+ # Critical: Tells setuptools to look at MANIFEST.in for non-python files (html, js)
114
+ [tool.setuptools]
115
+ include-package-data = true
116
+
117
+ [tool.setuptools.dynamic]
118
+ version = { attr = "compas_threejs.__version__" }
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,8 @@
1
+ """COMPAS ThreeJS - A lightweight Three.js viewer for COMPAS using Protobuf."""
2
+
3
+ __version__ = "1.0.1"
4
+ __author__ = "Eric Gozzi, Nicolas Benjamin Boscoboinik"
5
+ __email__ = "eric.gozzi@arch.ethz.ch"
6
+ __license__ = "MIT"
7
+
8
+ __all__ = ["__version__", "__author__", "__email__", "__license__"]
@@ -0,0 +1,15 @@
1
+ from .ambientlight import AmbientLight
2
+ from .pointlight import PointLight
3
+ from .rectlight import RectLight
4
+ from .sky import Sky
5
+ from .spotlight import SpotLight
6
+ from .sunlight import Sunlight
7
+
8
+ __all__ = [
9
+ "PointLight",
10
+ "SpotLight",
11
+ "RectLight",
12
+ "Sunlight",
13
+ "Sky",
14
+ "AmbientLight",
15
+ ]
@@ -0,0 +1,19 @@
1
+ import uuid
2
+
3
+ from compas.colors import Color
4
+
5
+
6
+ class AmbientLight:
7
+ def __init__(self, color: Color = Color.white(), intensity: float = 500):
8
+ self.color = color
9
+ self.intensity = intensity
10
+ self.guid = str(uuid.uuid4())
11
+
12
+ def as_dict(self) -> dict:
13
+ return {
14
+ "dispatch": "light",
15
+ "type": "ambient_light",
16
+ "guid": self.guid,
17
+ "color": self.color.hex,
18
+ "intensity": self.intensity,
19
+ }
@@ -0,0 +1,11 @@
1
+ from abc import ABC
2
+ from abc import abstractmethod
3
+
4
+
5
+ class Light(ABC):
6
+ def __init__(self, **kwargs):
7
+ self.attributes = kwargs
8
+
9
+ @abstractmethod
10
+ def as_dict(self):
11
+ raise NotImplementedError
@@ -0,0 +1,76 @@
1
+ from uuid import uuid4
2
+
3
+ from compas.colors import Color
4
+ from compas.geometry import Point
5
+
6
+ from .light import Light
7
+
8
+
9
+ class PointLight(Light):
10
+ """
11
+
12
+ Constructs a new PointLight instance.
13
+
14
+ Parameters
15
+ ----------
16
+ color : int | Color | str, optional
17
+ The color of the light. Can be specified as an integer, a Color object, or a string.
18
+ Default is 0xffffff (white).
19
+
20
+ intensity : float, optional
21
+ The intensity or strength of the light, measured in candela (cd).
22
+ Default is 1.
23
+
24
+ distance : float, optional
25
+ The maximum range of the light. A value of 0 indicates no limit.
26
+ Default is 0.
27
+
28
+ decay : float, optional
29
+ The rate at which the light diminishes over distance.
30
+ Default is 2.
31
+
32
+ """
33
+
34
+ def __init__(
35
+ self,
36
+ point: Point = Point(0, 0, 0),
37
+ color: Color = Color.white(),
38
+ intensity: float = 100,
39
+ distance: float = 0,
40
+ decay: float = 2,
41
+ helper: bool = False,
42
+ **kwargs,
43
+ ):
44
+ super().__init__(**kwargs)
45
+ self.point = point
46
+ self.color = color
47
+ self.intensity = intensity
48
+ self.distance = distance
49
+ self.decay = decay
50
+ self.helper = helper
51
+ self.guid = str(uuid4())
52
+
53
+ def as_dict(self) -> dict:
54
+ return {
55
+ "dispatch": "light",
56
+ "type": "point_light",
57
+ "x": self.point.x,
58
+ "y": self.point.y,
59
+ "z": self.point.z,
60
+ "color": self.color.hex,
61
+ "intensity": self.intensity,
62
+ "distance": self.distance,
63
+ "decay": self.decay,
64
+ "helper": self.helper,
65
+ "guid": self.guid,
66
+ }
67
+
68
+ @property
69
+ def color(self) -> Color:
70
+ return self._color
71
+
72
+ @color.setter
73
+ def color(self, value: Color):
74
+ if not isinstance(value, Color):
75
+ raise TypeError("color must be an instance of Color")
76
+ self._color = value
@@ -0,0 +1,73 @@
1
+ import uuid
2
+
3
+ from compas.colors import Color
4
+ from compas.geometry import Point
5
+
6
+ from .light import Light
7
+
8
+
9
+ class RectLight(Light):
10
+ """
11
+ A rectangular light source.
12
+
13
+ The `RectLight` class represents a light source with a rectangular shape,
14
+ defined by its position, target direction, color, intensity, width, and height.
15
+
16
+ Attributes
17
+ ----------
18
+ point : :class:`compas.geometry.Point`
19
+ The position of the light source in 3D space. Defaults to the origin (0, 0, 0).
20
+ target : :class:`compas.geometry.Point`
21
+ The target point that the light is directed towards. Defaults to (0, -1, 0).
22
+ color : :class:`compas.colors.Color`
23
+ The color of the light. Defaults to white.
24
+ intensity : float
25
+ The intensity of the light. Defaults to 1.
26
+ width : float
27
+ The width of the rectangular light source. Defaults to 10.
28
+ height : float
29
+ The height of the rectangular light source. Defaults to 10.
30
+ helper : bool
31
+ Whether to display a helper visualization for the light. Defaults to False.
32
+ guid : str
33
+ A unique identifier for the light instance, automatically generated.
34
+ """
35
+
36
+ def __init__(
37
+ self,
38
+ point: Point = Point(0, 0, 0),
39
+ target: Point = Point(0, -1, 0),
40
+ color: Color = Color.white(),
41
+ intensity: float = 1,
42
+ width: float = 10,
43
+ height: float = 10,
44
+ helper: bool = False,
45
+ **kwargs,
46
+ ):
47
+ super().__init__(**kwargs)
48
+ self.point = point
49
+ self.target = target
50
+ self.color = color
51
+ self.intensity = intensity
52
+ self.width = width
53
+ self.height = height
54
+ self.helper = helper
55
+ self.guid = str(uuid.uuid4())
56
+
57
+ def as_dict(self) -> dict:
58
+ return {
59
+ "dispatch": "light",
60
+ "type": "rect_light",
61
+ "x": self.point.x,
62
+ "y": self.point.y,
63
+ "z": self.point.z,
64
+ "tx": self.target.x,
65
+ "ty": self.target.y,
66
+ "tz": self.target.z,
67
+ "color": self.color.hex,
68
+ "intensity": self.intensity,
69
+ "width": self.width,
70
+ "height": self.height,
71
+ "helper": self.helper,
72
+ "guid": self.guid,
73
+ }
@@ -0,0 +1,57 @@
1
+ import uuid
2
+
3
+ from .light import Light
4
+
5
+
6
+ class Sky(Light):
7
+ """
8
+ The Sky class represents a type of light source that simulates the sky's appearance
9
+ based on various atmospheric parameters.
10
+
11
+ Attributes:
12
+ turbidity (float): The amount of particles in the atmosphere that scatter light.
13
+ Higher values result in a hazier sky. Default is 5.
14
+ rayleigh (float): The scattering coefficient for Rayleigh scattering, which affects
15
+ the sky's blue color intensity. Default is 0.15.
16
+ mie_coefficient (float): The scattering coefficient for Mie scattering, which affects
17
+ the appearance of haze and fog. Default is 0.002.
18
+ mie_directional_g (float): The anisotropy factor for Mie scattering, controlling the
19
+ directionality of scattered light. Default is 0.95.
20
+ azimuth (float): The horizontal angle of the sun in degrees, measured clockwise from
21
+ the north. Default is 45.
22
+ elevation (float): The vertical angle of the sun in degrees, measured from the horizon.
23
+ Default is 20.
24
+ guid (str): A unique identifier for the Sky instance, generated automatically.
25
+ """
26
+
27
+ def __init__(
28
+ self,
29
+ turbidity: float = 5,
30
+ rayleigh: float = 0.15,
31
+ mie_coefficient: float = 0.002,
32
+ mie_directional_g: float = 0.95,
33
+ azimuth: float = 45,
34
+ elevation: float = 20,
35
+ **kwargs,
36
+ ):
37
+ super().__init__(**kwargs)
38
+ self.turbidity = turbidity
39
+ self.rayleigh = rayleigh
40
+ self.mie_coefficient = mie_coefficient
41
+ self.mie_directional_g = mie_directional_g
42
+ self.azimuth = azimuth
43
+ self.elevation = elevation
44
+ self.guid = str(uuid.uuid4())
45
+
46
+ def as_dict(self) -> dict:
47
+ return {
48
+ "dispatch": "light",
49
+ "type": "sky",
50
+ "turbidity": self.turbidity,
51
+ "rayleigh": self.rayleigh,
52
+ "mie_coefficient": self.mie_coefficient,
53
+ "mie_directional_g": self.mie_directional_g,
54
+ "azimuth": self.azimuth,
55
+ "elevation": self.elevation,
56
+ "guid": self.guid,
57
+ }