anythreejs 0.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.
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2025, Mridul Seth.
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ * Neither the name of the vector package developers nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,169 @@
1
+ Metadata-Version: 2.4
2
+ Name: anythreejs
3
+ Version: 0.0.1
4
+ Summary: Anywidget wrapper for three.js
5
+ Keywords: jupyter,widgets,threejs,3d,visualization,anywidget
6
+ Author: Mridul Seth
7
+ Author-email: Mridul Seth <mail@mriduls.com>
8
+ License-Expression: BSD-3-Clause
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Framework :: Jupyter
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: BSD License
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Requires-Dist: anywidget>=0.9.21
19
+ Requires-Dist: numpy>=2
20
+ Requires-Dist: traitlets>=5.14.3
21
+ Requires-Python: >=3.11
22
+ Project-URL: Homepage, https://github.com/MridulS/anythreejs
23
+ Project-URL: Repository, https://github.com/MridulS/anythreejs
24
+ Description-Content-Type: text/markdown
25
+
26
+ # anythreejs
27
+
28
+ A Python / Three.js bridge for Jupyter notebooks, built on [anywidget](https://anywidget.dev/).
29
+
30
+ This comes out of the need to have a lightweight wrapper around Three.js which is easy to maintain and extend, while being compatible with existing codebases using [pythreejs](https://github.com/jupyter-widgets/pythreejs).
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install anythreejs
36
+ ```
37
+
38
+ ## Quick Start
39
+
40
+ ```python
41
+ from anythreejs import (
42
+ Renderer,
43
+ Scene,
44
+ PerspectiveCamera,
45
+ OrbitControls,
46
+ Mesh,
47
+ BoxGeometry,
48
+ MeshStandardMaterial,
49
+ AmbientLight,
50
+ DirectionalLight,
51
+ )
52
+
53
+ # Create a scene
54
+ scene = Scene(
55
+ children=[
56
+ Mesh(
57
+ geometry=BoxGeometry(1, 1, 1),
58
+ material=MeshStandardMaterial(color="#ff0c0cff", roughness=0.4),
59
+ ),
60
+ AmbientLight(intensity=0.4),
61
+ DirectionalLight(position=[5, 5, 5], intensity=1),
62
+ ],
63
+ background="#e5e5faff",
64
+ )
65
+
66
+ camera = PerspectiveCamera(position=[3, 3, 3])
67
+ controls = OrbitControls(controlling=camera)
68
+
69
+ # Display the widget (renderer is the widget)
70
+ renderer = Renderer(
71
+ camera=camera,
72
+ scene=scene,
73
+ controls=[controls],
74
+ width=700,
75
+ height=450,
76
+ )
77
+ renderer
78
+ ```
79
+
80
+ ## API Overview
81
+
82
+ anythreejs provides a subset of Three.js objects as Python classes. Currently we only cover the parts used by [plopp](https://github.com/scipp/plopp/). We should ideally automatically generate these classes from the Three.js documentation in the future.
83
+
84
+ ## Renderer Options
85
+
86
+ ```python
87
+ Renderer(
88
+ scene=scene, # Scene object
89
+ camera=camera, # Camera object
90
+ controls=[controls], # Controls list (e.g., OrbitControls)
91
+ width=800, # Canvas width in pixels
92
+ height=600, # Canvas height in pixels
93
+ antialias=True, # Enable antialiasing
94
+ alpha=False, # Canvas transparency
95
+ )
96
+ ```
97
+
98
+ ## Interaction
99
+
100
+ ### Click Events
101
+
102
+ ```python
103
+ import anythreejs as p3
104
+
105
+ renderer = p3.Renderer(camera=camera, scene=scene, controls=[controls])
106
+
107
+ def handle_click(change):
108
+ info = change.get("new", {})
109
+ if info:
110
+ print(f"Clicked: {info.get('name')} at {info.get('point')}")
111
+
112
+ renderer.observe(handle_click, names=["_click_info"])
113
+ renderer
114
+ ```
115
+
116
+ ## pythreejs Compatibility
117
+
118
+ anythreejs tries to be API-compatible with the original `pythreejs`. For projects that already use pythreejs
119
+ (like [plopp](https://github.com/scipp/plopp)), you can switch with minimal changes:
120
+
121
+ ```python
122
+ # Instead of:
123
+ # import pythreejs as p3
124
+
125
+ # Use:
126
+ import anythreejs as p3
127
+ ```
128
+
129
+ ### Example (pythreejs-style usage)
130
+
131
+ ```python
132
+ import anythreejs as p3
133
+
134
+ # Create camera
135
+ camera = p3.PerspectiveCamera(aspect=800/600)
136
+ camera.position = [5, 5, 5]
137
+
138
+ # Create scene
139
+ axes = p3.AxesHelper()
140
+ scene = p3.Scene(children=[camera, axes], background="#f0f0f0")
141
+
142
+ # Create controls
143
+ controls = p3.OrbitControls(controlling=camera)
144
+
145
+ # Create renderer (this is the widget)
146
+ renderer = p3.Renderer(
147
+ camera=camera,
148
+ scene=scene,
149
+ controls=[controls],
150
+ width=800,
151
+ height=600,
152
+ )
153
+
154
+ # Add objects dynamically
155
+ mesh = p3.Mesh(
156
+ geometry=p3.BoxGeometry(1, 1, 1),
157
+ material=p3.MeshStandardMaterial(color="#ff0000"),
158
+ )
159
+ scene.add(mesh)
160
+
161
+ # Display
162
+ renderer
163
+ ```
164
+
165
+ ## Credits
166
+
167
+ - Inspired by the original [pythreejs](https://github.com/jupyter-widgets/pythreejs)
168
+ - Built with [anywidget](https://anywidget.dev/)
169
+ - Powered by [Three.js](https://threejs.org/)
@@ -0,0 +1,144 @@
1
+ # anythreejs
2
+
3
+ A Python / Three.js bridge for Jupyter notebooks, built on [anywidget](https://anywidget.dev/).
4
+
5
+ This comes out of the need to have a lightweight wrapper around Three.js which is easy to maintain and extend, while being compatible with existing codebases using [pythreejs](https://github.com/jupyter-widgets/pythreejs).
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install anythreejs
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```python
16
+ from anythreejs import (
17
+ Renderer,
18
+ Scene,
19
+ PerspectiveCamera,
20
+ OrbitControls,
21
+ Mesh,
22
+ BoxGeometry,
23
+ MeshStandardMaterial,
24
+ AmbientLight,
25
+ DirectionalLight,
26
+ )
27
+
28
+ # Create a scene
29
+ scene = Scene(
30
+ children=[
31
+ Mesh(
32
+ geometry=BoxGeometry(1, 1, 1),
33
+ material=MeshStandardMaterial(color="#ff0c0cff", roughness=0.4),
34
+ ),
35
+ AmbientLight(intensity=0.4),
36
+ DirectionalLight(position=[5, 5, 5], intensity=1),
37
+ ],
38
+ background="#e5e5faff",
39
+ )
40
+
41
+ camera = PerspectiveCamera(position=[3, 3, 3])
42
+ controls = OrbitControls(controlling=camera)
43
+
44
+ # Display the widget (renderer is the widget)
45
+ renderer = Renderer(
46
+ camera=camera,
47
+ scene=scene,
48
+ controls=[controls],
49
+ width=700,
50
+ height=450,
51
+ )
52
+ renderer
53
+ ```
54
+
55
+ ## API Overview
56
+
57
+ anythreejs provides a subset of Three.js objects as Python classes. Currently we only cover the parts used by [plopp](https://github.com/scipp/plopp/). We should ideally automatically generate these classes from the Three.js documentation in the future.
58
+
59
+ ## Renderer Options
60
+
61
+ ```python
62
+ Renderer(
63
+ scene=scene, # Scene object
64
+ camera=camera, # Camera object
65
+ controls=[controls], # Controls list (e.g., OrbitControls)
66
+ width=800, # Canvas width in pixels
67
+ height=600, # Canvas height in pixels
68
+ antialias=True, # Enable antialiasing
69
+ alpha=False, # Canvas transparency
70
+ )
71
+ ```
72
+
73
+ ## Interaction
74
+
75
+ ### Click Events
76
+
77
+ ```python
78
+ import anythreejs as p3
79
+
80
+ renderer = p3.Renderer(camera=camera, scene=scene, controls=[controls])
81
+
82
+ def handle_click(change):
83
+ info = change.get("new", {})
84
+ if info:
85
+ print(f"Clicked: {info.get('name')} at {info.get('point')}")
86
+
87
+ renderer.observe(handle_click, names=["_click_info"])
88
+ renderer
89
+ ```
90
+
91
+ ## pythreejs Compatibility
92
+
93
+ anythreejs tries to be API-compatible with the original `pythreejs`. For projects that already use pythreejs
94
+ (like [plopp](https://github.com/scipp/plopp)), you can switch with minimal changes:
95
+
96
+ ```python
97
+ # Instead of:
98
+ # import pythreejs as p3
99
+
100
+ # Use:
101
+ import anythreejs as p3
102
+ ```
103
+
104
+ ### Example (pythreejs-style usage)
105
+
106
+ ```python
107
+ import anythreejs as p3
108
+
109
+ # Create camera
110
+ camera = p3.PerspectiveCamera(aspect=800/600)
111
+ camera.position = [5, 5, 5]
112
+
113
+ # Create scene
114
+ axes = p3.AxesHelper()
115
+ scene = p3.Scene(children=[camera, axes], background="#f0f0f0")
116
+
117
+ # Create controls
118
+ controls = p3.OrbitControls(controlling=camera)
119
+
120
+ # Create renderer (this is the widget)
121
+ renderer = p3.Renderer(
122
+ camera=camera,
123
+ scene=scene,
124
+ controls=[controls],
125
+ width=800,
126
+ height=600,
127
+ )
128
+
129
+ # Add objects dynamically
130
+ mesh = p3.Mesh(
131
+ geometry=p3.BoxGeometry(1, 1, 1),
132
+ material=p3.MeshStandardMaterial(color="#ff0000"),
133
+ )
134
+ scene.add(mesh)
135
+
136
+ # Display
137
+ renderer
138
+ ```
139
+
140
+ ## Credits
141
+
142
+ - Inspired by the original [pythreejs](https://github.com/jupyter-widgets/pythreejs)
143
+ - Built with [anywidget](https://anywidget.dev/)
144
+ - Powered by [Three.js](https://threejs.org/)
@@ -0,0 +1,41 @@
1
+ [project]
2
+ name = "anythreejs"
3
+ version = "0.0.1"
4
+ description = "Anywidget wrapper for three.js"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Mridul Seth", email = "mail@mriduls.com" }
8
+ ]
9
+ license = "BSD-3-Clause"
10
+ license-files = ["LICENSE"]
11
+ requires-python = ">=3.11"
12
+ dependencies = [
13
+ "anywidget>=0.9.21",
14
+ "numpy>=2",
15
+ "traitlets>=5.14.3",
16
+ ]
17
+ keywords = ["jupyter", "widgets", "threejs", "3d", "visualization", "anywidget"]
18
+ classifiers = [
19
+ "Development Status :: 3 - Alpha",
20
+ "Framework :: Jupyter",
21
+ "Intended Audience :: Developers",
22
+ "Intended Audience :: Science/Research",
23
+ "License :: OSI Approved :: BSD License",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: 3.13",
27
+ ]
28
+ [project.urls]
29
+ Homepage = "https://github.com/MridulS/anythreejs"
30
+ Repository = "https://github.com/MridulS/anythreejs"
31
+
32
+ [build-system]
33
+ requires = ["uv_build>=0.9.17,<0.10.0"]
34
+ build-backend = "uv_build"
35
+
36
+ [dependency-groups]
37
+ dev = [
38
+ "jupyterlab>=4.5.0",
39
+ "prek>=0.2.21",
40
+ "ruff>=0.14.9",
41
+ ]
@@ -0,0 +1,153 @@
1
+ """
2
+ anythreejs - A modern Python/Three.js bridge for Jupyter
3
+
4
+ Quick start:
5
+ from anythreejs import Renderer, Scene, PerspectiveCamera, OrbitControls
6
+ from anythreejs import Mesh, BoxGeometry, MeshStandardMaterial, AmbientLight
7
+
8
+ scene = Scene(background="#1a1a2e")
9
+ scene.add(Mesh(BoxGeometry(1, 1, 1), MeshStandardMaterial(color="#ff6600")))
10
+ scene.add(AmbientLight(intensity=0.5))
11
+
12
+ camera = PerspectiveCamera(position=(0, 0, 5))
13
+ controls = OrbitControls(controlling=camera)
14
+
15
+ renderer = Renderer(camera=camera, scene=scene, controls=[controls])
16
+ renderer # Display in notebook
17
+
18
+ For pythreejs-style namespace imports:
19
+ import anythreejs as p3
20
+ # Then use p3.Scene, p3.Renderer, etc.
21
+ """
22
+
23
+ from .renderer import Renderer
24
+ from .core import (
25
+ # Base
26
+ ThreeJSBase,
27
+ Object3D,
28
+ # Scene
29
+ Scene,
30
+ # Cameras
31
+ PerspectiveCamera,
32
+ OrthographicCamera,
33
+ # Controls
34
+ OrbitControls,
35
+ TrackballControls,
36
+ # Geometry
37
+ BufferGeometry,
38
+ BoxGeometry,
39
+ BoxBufferGeometry,
40
+ SphereGeometry,
41
+ SphereBufferGeometry,
42
+ PlaneGeometry,
43
+ PlaneBufferGeometry,
44
+ CylinderGeometry,
45
+ CylinderBufferGeometry,
46
+ TorusGeometry,
47
+ EdgesGeometry,
48
+ # Material
49
+ Material,
50
+ MeshBasicMaterial,
51
+ MeshStandardMaterial,
52
+ MeshPhongMaterial,
53
+ MeshLambertMaterial,
54
+ PointsMaterial,
55
+ LineBasicMaterial,
56
+ LineDashedMaterial,
57
+ SpriteMaterial,
58
+ # Objects
59
+ Mesh,
60
+ Points,
61
+ Line,
62
+ LineSegments,
63
+ Group,
64
+ Sprite,
65
+ # Lights
66
+ AmbientLight,
67
+ DirectionalLight,
68
+ PointLight,
69
+ HemisphereLight,
70
+ SpotLight,
71
+ # Helpers
72
+ AxesHelper,
73
+ GridHelper,
74
+ # Buffer
75
+ BufferAttribute,
76
+ Float32BufferAttribute,
77
+ Uint32BufferAttribute,
78
+ Uint16BufferAttribute,
79
+ Int32BufferAttribute,
80
+ # Textures
81
+ TextTexture,
82
+ )
83
+
84
+ # Convenience alias for pythreejs-style imports: `import anythreejs as p3`
85
+ import sys as _sys
86
+
87
+ p3 = _sys.modules[__name__]
88
+
89
+ __version__ = "0.0.1"
90
+
91
+ __all__ = [
92
+ # Renderer
93
+ "Renderer",
94
+ # Base
95
+ "ThreeJSBase",
96
+ "Object3D",
97
+ # Scene
98
+ "Scene",
99
+ # Cameras
100
+ "PerspectiveCamera",
101
+ "OrthographicCamera",
102
+ # Controls
103
+ "OrbitControls",
104
+ "TrackballControls",
105
+ # Geometry
106
+ "BufferGeometry",
107
+ "BoxGeometry",
108
+ "BoxBufferGeometry",
109
+ "SphereGeometry",
110
+ "SphereBufferGeometry",
111
+ "PlaneGeometry",
112
+ "PlaneBufferGeometry",
113
+ "CylinderGeometry",
114
+ "CylinderBufferGeometry",
115
+ "TorusGeometry",
116
+ "EdgesGeometry",
117
+ # Material
118
+ "Material",
119
+ "MeshBasicMaterial",
120
+ "MeshStandardMaterial",
121
+ "MeshPhongMaterial",
122
+ "MeshLambertMaterial",
123
+ "PointsMaterial",
124
+ "LineBasicMaterial",
125
+ "LineDashedMaterial",
126
+ "SpriteMaterial",
127
+ # Objects
128
+ "Mesh",
129
+ "Points",
130
+ "Line",
131
+ "LineSegments",
132
+ "Group",
133
+ "Sprite",
134
+ # Lights
135
+ "AmbientLight",
136
+ "DirectionalLight",
137
+ "PointLight",
138
+ "HemisphereLight",
139
+ "SpotLight",
140
+ # Helpers
141
+ "AxesHelper",
142
+ "GridHelper",
143
+ # Buffer
144
+ "BufferAttribute",
145
+ "Float32BufferAttribute",
146
+ "Uint32BufferAttribute",
147
+ "Uint16BufferAttribute",
148
+ "Int32BufferAttribute",
149
+ # Textures
150
+ "TextTexture",
151
+ # Convenience alias
152
+ "p3",
153
+ ]
@@ -0,0 +1,109 @@
1
+ """
2
+ Core Three.js components.
3
+ """
4
+
5
+ from .base import ThreeJSBase, Object3D
6
+ from .scene import Scene
7
+ from .camera import PerspectiveCamera, OrthographicCamera
8
+ from .controls import OrbitControls, TrackballControls
9
+ from .geometry import (
10
+ BufferGeometry,
11
+ BoxGeometry,
12
+ BoxBufferGeometry,
13
+ SphereGeometry,
14
+ SphereBufferGeometry,
15
+ PlaneGeometry,
16
+ PlaneBufferGeometry,
17
+ CylinderGeometry,
18
+ CylinderBufferGeometry,
19
+ TorusGeometry,
20
+ EdgesGeometry,
21
+ )
22
+ from .material import (
23
+ Material,
24
+ MeshBasicMaterial,
25
+ MeshStandardMaterial,
26
+ MeshPhongMaterial,
27
+ MeshLambertMaterial,
28
+ PointsMaterial,
29
+ LineBasicMaterial,
30
+ LineDashedMaterial,
31
+ SpriteMaterial,
32
+ )
33
+ from .objects import Mesh, Points, Line, LineSegments, Group, Sprite
34
+ from .lights import (
35
+ AmbientLight,
36
+ DirectionalLight,
37
+ PointLight,
38
+ HemisphereLight,
39
+ SpotLight,
40
+ )
41
+ from .helpers import AxesHelper, GridHelper
42
+ from .buffer import (
43
+ BufferAttribute,
44
+ Float32BufferAttribute,
45
+ Uint32BufferAttribute,
46
+ Uint16BufferAttribute,
47
+ Int32BufferAttribute,
48
+ )
49
+ from .textures import TextTexture
50
+
51
+ __all__ = [
52
+ # Base
53
+ "ThreeJSBase",
54
+ "Object3D",
55
+ # Scene
56
+ "Scene",
57
+ # Cameras
58
+ "PerspectiveCamera",
59
+ "OrthographicCamera",
60
+ # Controls
61
+ "OrbitControls",
62
+ "TrackballControls",
63
+ # Geometry
64
+ "BufferGeometry",
65
+ "BoxGeometry",
66
+ "BoxBufferGeometry",
67
+ "SphereGeometry",
68
+ "SphereBufferGeometry",
69
+ "PlaneGeometry",
70
+ "PlaneBufferGeometry",
71
+ "CylinderGeometry",
72
+ "CylinderBufferGeometry",
73
+ "TorusGeometry",
74
+ "EdgesGeometry",
75
+ # Material
76
+ "Material",
77
+ "MeshBasicMaterial",
78
+ "MeshStandardMaterial",
79
+ "MeshPhongMaterial",
80
+ "MeshLambertMaterial",
81
+ "PointsMaterial",
82
+ "LineBasicMaterial",
83
+ "LineDashedMaterial",
84
+ "SpriteMaterial",
85
+ # Objects
86
+ "Mesh",
87
+ "Points",
88
+ "Line",
89
+ "LineSegments",
90
+ "Group",
91
+ "Sprite",
92
+ # Lights
93
+ "AmbientLight",
94
+ "DirectionalLight",
95
+ "PointLight",
96
+ "HemisphereLight",
97
+ "SpotLight",
98
+ # Helpers
99
+ "AxesHelper",
100
+ "GridHelper",
101
+ # Buffer
102
+ "BufferAttribute",
103
+ "Float32BufferAttribute",
104
+ "Uint32BufferAttribute",
105
+ "Uint16BufferAttribute",
106
+ "Int32BufferAttribute",
107
+ # Textures
108
+ "TextTexture",
109
+ ]