Render¶
For task-oriented examples and help choosing between render() and observe(),
see the rendering and viewers guide.
Compile and render a Layer or Figure with the selected backend.
Figure scene settings supply camera, lighting, environment, and output
intent only when config is omitted. An explicit Config overrides the
complete Figure-derived Config; backend keyword arguments override their
corresponding backend-facing settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Layer | Figure
|
Layer tree or declarative Figure to render. |
required |
config
|
Config | None
|
Explicit invocation configuration, or Figure/default settings. |
None
|
filename
|
Path | str | None
|
Main output path; WebGL rewrites non-HTML suffixes to HTML. |
None
|
backend
|
BackendName | None
|
|
None
|
**kwargs
|
Any
|
Backend-specific options such as WebGL |
{}
|
Returns:
| Type | Description |
|---|---|
RenderResult
|
RenderResult with the backend, primary path/image, and output manifest. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If backend-specific keyword arguments are unknown. |
Examples:
>>> import hakowan as hkw
>>> result = hkw.render(hkw.layer("mesh.obj"), filename="viewer.html")
>>> result.path
PosixPath('viewer.html')
Source code in hakowan/render/__init__.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
RenderResult¶
hkw.render() returns a RenderResult bundling the in-memory image (Mitsuba, Blender),
the main output path, and the manifest of all files produced (including per-pass
sidecars).
The outcome of a :func:render call.
Attributes:
| Name | Type | Description |
|---|---|---|
backend |
BackendName
|
Name of the backend that produced this result. |
outputs |
dict[str, Path | str]
|
Manifest mapping |
image |
Any
|
The in-memory rendered image when the backend produces one
(Mitsuba, Blender); |
path |
Path | None
|
The main output path when written to disk; |
The object is also a :pep:519 path-like (__fspath__), so it can be
passed straight to open(), :class:~pathlib.Path, etc. when a main
output file was written.
Source code in hakowan/render/__init__.py
__fspath__()
¶
Return the main output path for os.PathLike consumers.
Raises:
| Type | Description |
|---|---|
TypeError
|
If rendering produced no file path. |
Source code in hakowan/render/__init__.py
embed_html(*, src=None, title='Hakowan Interactive 3D Visualization', width='100%', height=500)
¶
Return an iframe snippet for a published WebGL viewer.
src must be a relative path or HTTP(S) URL. By default, the
published viewer filename is URL-encoded and resolved beside the page.
Publish the entire output directory when rendering with offline=True.
Source code in hakowan/render/__init__.py
Related Functions¶
set_default_backend¶
Set the default rendering backend for subsequent render calls.
import hakowan as hkw
# Set Blender as default
hkw.set_default_backend("blender")
# All subsequent renders will use Blender unless overridden
hkw.render(layer, filename="output.png")
Set the default rendering backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
BackendName
|
Backend name. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If backend is not registered. |
Source code in hakowan/backends/__init__.py
list_backends¶
List all available rendering backends.
import hakowan as hkw
backends = hkw.list_backends()
print(backends)
# Output: ['blender', 'mitsuba', 'webgl']
List the rendering backends whose dependencies are installed.
Availability is probed without importing the heavy backend modules.