threers 0.0.7

Drop-in three.js replacement for Rust and WebAssembly (wgpu) — THREE.* API, scene graph, PBR, post-fx, mesh BVH, CSG, an OpenSCAD front end with a watertight exact-CSG kernel, headless render, and native media codecs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
// `Arc` is not decorative on wasm32, it is the same `Arc` the native build
// needs. The handles inside it — wgpu devices, queues, surfaces — are `Send +
// Sync` natively and are not on wasm, where the API is single-threaded by
// construction. One shared type has to satisfy both targets, so on wasm the
// lint fires on code that has no other form.
#![cfg_attr(
    target_arch = "wasm32",
    allow(clippy::arc_with_non_send_sync)
)]
// On docs.rs (nightly, `--cfg docsrs`), every feature-gated item is badged
// with the features it needs.
#![cfg_attr(docsrs, feature(doc_cfg))]
//! threers — a drop-in three.js replacement for Rust and WebAssembly.
//!
//! Implements the three.js architecture and API surface: a scene graph of
//! [`Object3D`]s, [`BufferGeometry`] with named attributes, [`Material`]s,
//! cameras, and a [`Renderer`] that walks the graph and draws. Backed by
//! wgpu on native and WebGPU in the browser.
//!
//! # Crates and targets
//!
//! - **`rlib`**: native desktop / tooling (`cargo run --example cube`)
//! - **`cdylib`**: wasm32 WebAssembly (`wasm-pack build`)
//!
//! # Web usage
//!
//! Import `web/threejs-shim.js` for a drop-in `THREE.*` API over the wasm
//! bindings. Existing three.js r165-style apps can swap in with minimal changes.
//!
//! # Feature flags
//!
//! The three.js API surface — scene graph, geometry, materials, lights,
//! cameras, controls, loaders, post-processing, renderer — is unconditional.
//! Everything below is a self-contained subsystem: turning one off removes its
//! module and its re-exports and touches nothing else.
//!
//! ## Leaf features
//!
//! | Feature | Default | Role | Extra deps |
//! |---------|---------|------|------------|
//! | `captions` | **on** | Subtitles — SRT + WebVTT, on-screen and burned in | — |
//! | `mesh-bvh` | | Accelerated raycast / shapecast | — |
//! | `raytrace` | | Path tracer: global illumination, area lights, refraction, DoF; CPU + wgpu-compute backends | — |
//! | `bvh-csg` | | Constructive solid geometry (implies `mesh-bvh`) | — |
//! | `openscad` | | `.scad` front end + `Solid` DSL + exact-CSG kernel (implies `bvh-csg`) | — |
//! | `manifold` | | Optional Manifold kernel behind OpenSCAD booleans (implies `openscad`) | manifold-rust |
//! | `planet` | | Planets, moons, starfields, map generation | — |
//! | `fluid` | | Interactive 2D and 3D fluids on the GPU, as render passes (runs on WebGL2) | — |
//! | `usd` | | Universal Scene Description — `.usda`, `.usdc`, `.usdz`, read and written | — |
//! | `video` | | Native frame-sequence export via ffmpeg (implies `captions`) | — |
//! | `native-codec` | | Pure-Rust GIF, APNG, VP9/WebM, H.264/MP4, HEVC (wasm-safe) | — |
//! | `metal` | | A second renderer on Metal directly, via the Objective-C runtime (macOS/iOS) | — |
//! | `visionos` | | CompositorServices frame loop + ARKit world tracking, stereo and reverse-Z (implies `metal`) | — |
//! | `videotoolbox` | | In-process VideoToolbox encode (macOS) | — |
//! | `parallel` | | rayon-backed CSG/BVH work (native; a no-op on wasm32) | rayon |
//! | `async` | | tokio runtime for callers driving loaders concurrently (native) | tokio |
//! | `rlx` | | Tensors ↔ geometry and pixels, graph runner, convolution, mesh smoothing, fitted colour grades, palettes | rlx |
//! | `rlx-geo` | | Exact Delaunay + adaptive refinement + Voronoi cell textures | rlx-geo |
//! | `nurbs` | | NURBS curves/surfaces: derivatives, knots, tessellation | — |
//! | `brep` | | Analytic surface provenance on geometry (implies `nurbs`) | — |
//! | `brep-csg` | | Closed-form SSI fast paths in the CSG kernel (implies `brep` + `openscad`) | — |
//! | `brep-kernel` | | True B-rep topology, boolean, fillets (implies `brep-csg`) | — |
//! | `step` | | STEP AP203/214 import + export (implies `brep-kernel`) | — |
//! | `assembly-check` | | Assembly motion checks (body correspondence, axis recovery, swept volume) | — |
//! | `learned-denoise` | | Trained U-Net denoiser beside À-Trous (implies `raytrace`) | — |
//! | `learned-denoise-metal`, `learned-denoise-gpu` | | The same network on Metal or wgpu (imply `learned-denoise`) | — |
//! | `webgl` | | WebGL2 in the browser through wgpu's GL backend, where WebGPU is missing | — |
//!
//! ## Meta bundles
//!
//! | Bundle | Enables |
//! |--------|---------|
//! | `cad` | `openscad` + `nurbs` + `brep` + `brep-csg` + `parallel` |
//! | `media` | `video` + `native-codec` + `captions` |
//! | `gi` | `raytrace` + `learned-denoise` |
//! | `apple` | `metal` + `videotoolbox` |
//! | `full` | `cad` + `media` + `gi` + `planet` + `fluid` + `usd` + `rlx` + `rlx-geo` + `assembly-check` + `async` + `step` + `brep-kernel` |
//! | `wasm-full` | Browser kitchen sink: `captions` + `openscad` + `native-codec` + `nurbs` + `planet` + `raytrace` + `fluid` + `usd` |
//!
//! ```toml
//! # CAD stack in one flag
//! threers = { version = "0.0.7", features = ["cad"] }
//! # everything
//! threers = { version = "0.0.7", features = ["full"] }
//! # browser wasm kitchen sink
//! threers = { version = "0.0.7", features = ["wasm-full"] }
//! # nothing but the renderer
//! threers = { version = "0.0.7", default-features = false }
//! ```
//!
//! Rigid-body physics lives in the companion crate
//! [`threers-physics`](https://docs.rs/threers-physics). Language bindings:
//! see [`docs/bindings.md`](https://github.com/eugenehp/threers/blob/main/docs/bindings.md)
//! (wasm ESM, napi-rs Node native, PyO3).
//!
//! # Modules
//!
//! | Module | Role |
//! |--------|------|
//! | [`prelude`] | One glob import for the types nearly every scene uses; nested modules for controls / animation / … |
//! | [`core`] | Scene graph, geometry, raycaster |
//! | [`origami`] | Rigid origami: crease patterns, degree-4 kinematics, folded meshes |
//! | [`renderer`] | wgpu draw + post-processing; headless offscreen (native) |
//! | `raytrace` | Path-traced rendering — global illumination, on CPU or GPU (`raytrace`) |
//! | [`postprocessing`] | three.js EffectComposer and passes (native and browser) |
//! | [`loaders`] | glTF, OBJ, HDR, … |
//! | [`extras`] | PMREM, noise, marching cubes, … |
//! | [`geometries::lattice`] | 35 lattice generators, and what they are worth: stiffness, conductivity, strength, porosity, pore size |
//! | [`materials`] | PBR materials and [`ShaderMaterial`] |
//! | `captions` | subtitles — SRT + WebVTT, on-screen and burned in (`captions`) |
//! | `planet` | Planets, moons, starfields (`planet` feature) |
//! | `mesh_bvh` | Opt-in BVH (`mesh-bvh` feature) |
//! | `csg` | Opt-in CSG (`bvh-csg` feature) |
//! | `nurbs` / `brep` / `step` | CAD surface stack (feature-gated) |
//! | `video` | Opt-in video export (`video` feature, native) |
//! | `codec` | Opt-in media codecs (`native-codec` feature) |
//! | `rlx` | Opt-in RLX bridge (`rlx`, `rlx-geo` features) |

// `PlaneGeometry::new` returns a `BufferGeometry`, and `AxesHelper::new` an
// `Object3D`, because `new THREE.PlaneGeometry(...)` does. Mirroring three.js is
// the point of this crate, so the constructors mirror what three.js constructs
// rather than what Rust convention would have them construct.
#![allow(clippy::new_ret_no_self)]
// Graphics signatures are wide because the quantities are independent, not
// because they want grouping: a ray through a pixel takes an x, a y, a width, a
// height, a sub-pixel jitter, a lens sample and a shutter instant, and no two of
// those belong in a struct together. Bundling them to get under a threshold of
// seven would hide which of them a caller is actually varying.
#![allow(clippy::too_many_arguments)]

pub mod animation;
/// Generic checks for assemblies that move: body correspondence across poses,
/// axis recovery, and swept free volume. Knows nothing about what it inspects.
#[cfg(feature = "assembly-check")]
pub mod assembly;
pub mod audio;
pub mod cameras;
#[cfg(feature = "captions")]
pub mod captions;
pub mod controls;
pub mod core;
pub mod curves;
pub mod exporters;
pub mod extras;
/// Fur by shells: [`FurMaterial`] on any mesh (`fur::fur_object`).
pub mod fur;
pub use fur::{FurGroom, FurMaterial};
pub mod geometries;
pub mod helpers;
/// Inverse kinematics: damped least squares joint solving for serial arms,
/// with position and tool direction as separate residuals rather than a
/// weighted sum. See [`kinematics`].
pub mod kinematics;
/// Rigid origami: degree-4 vertex kinematics, crease-pattern closure, and a
/// dual walk that folds a consistent assignment off the plane.
pub mod origami;
pub mod lights;
pub mod loaders;
pub mod marks;
pub mod materials;
pub mod math;
pub mod postprocessing;
/// One import for the things nearly every scene uses — see [`prelude`].
pub mod prelude;
pub mod renderers;
pub mod scene;
pub mod stats;
pub mod textures;
pub mod utils;
pub mod volume;

/// Easing curves — the shape of a transition in time.
pub mod easing;
pub mod overlay;
// A retained UI: CSS-subset styles, flexbox layout, painting, hit-testing.
// (Its docs are the module's own `//!`; an outer `///` here would make their
// intra-doc links resolve in this scope, where `Ui` is not.)
#[cfg(feature = "ui")]
pub mod ui;
/// A window, a scene and a loop in one call. Native only.
#[cfg(not(target_arch = "wasm32"))]
pub mod sketch;
pub mod renderer;

// No outer doc comment: `gpu.rs` carries `//!` docs, and an outer `///` here
// would make the intra-doc links inside them resolve in this scope.
pub mod gpu;
/// The `THREE.*` JS shim's bindings (WebRenderer, WebMesh, loaders, ...).
/// Built with `--cfg threers_no_js_bindings` they are left out: a consumer
/// driving the Rust API from its own wasm-bindgen crate otherwise ships
/// ~1,200 exports it never calls (exports are roots, so nothing prunes them).
#[cfg(all(target_arch = "wasm32", not(threers_no_js_bindings)))]
pub mod wasm;
/// The trained denoiser in a browser, split so the work can go to web workers.
#[cfg(all(target_arch = "wasm32", feature = "raytrace"))]
pub mod wasm_denoise;
/// Progressive path tracing for the browser.
#[cfg(all(target_arch = "wasm32", feature = "raytrace", not(threers_no_js_bindings)))]
pub mod wasm_pathtrace;
/// three-bvh-csg's boolean evaluation for the browser.
#[cfg(all(target_arch = "wasm32", feature = "bvh-csg"))]
pub mod wasm_csg;

/// A second renderer that talks to Metal directly, with no `metal-rs`, no
/// `objc` crate and no C in the build — see [`metal`](crate::metal) for what it
/// covers. macOS and iOS only; the `metal` feature is inert elsewhere.
#[cfg(all(feature = "metal", any(target_os = "macos", target_os = "ios")))]
pub mod metal;

/// In-process hardware video encoding through VideoToolbox, so frames reach the
/// encoder without crossing a process boundary. macOS only; see
/// [`videotoolbox`](crate::videotoolbox).
#[cfg(all(feature = "videotoolbox", target_os = "macos"))]
pub mod videotoolbox;
#[cfg(all(feature = "videotoolbox", feature = "native-codec", target_os = "macos"))]
pub mod videotoolbox_decode;

#[cfg(feature = "mesh-bvh")]
pub mod mesh_bvh;

/// A physically-based path tracer beside the rasteriser — global illumination,
/// area lights, refraction, depth of field. CPU and wgpu-compute backends over
/// one scene form. Enable the `raytrace` feature.
#[cfg(feature = "raytrace")]
pub mod raytrace;

#[cfg(feature = "bvh-csg")]
pub mod csg;

#[cfg(feature = "openscad")]
pub mod openscad;

#[cfg(feature = "planet")]
pub mod planet;

// No outer doc comment on purpose: `fluid/mod.rs` carries `//!` docs, and an
// outer `///` here would make the intra-doc links inside them resolve in this
// scope instead of the module's.
#[cfg(feature = "fluid")]
pub mod fluid;

/// NURBS curves and surfaces in f64 — derivatives, knot operations, exact conic
/// and quadric constructors, curvature-adaptive tessellation. Stage 0 of the
/// B-rep roadmap; see `docs/brep-nurbs-plan.md`.
///
/// Distinct from [`curves::NURBSCurve`] / [`curves::NURBSSurface`], which are
/// the unconditional f32 three.js parity types and convert into these.
#[cfg(feature = "nurbs")]
pub mod nurbs;

/// Analytic surface provenance: every triangle knows the surface it was sampled
/// from, so normals, UVs and re-tessellation derive from the surface rather than
/// the mesh. Stage 1 of the B-rep roadmap; see `docs/brep-nurbs-plan.md`.
#[cfg(feature = "brep")]
pub mod brep;

/// STEP (ISO 10303) AP203/AP214 advanced B-rep import and export. Stage 5 of
/// the B-rep roadmap; see `docs/brep-nurbs-plan.md`.
#[cfg(feature = "step")]
pub mod step;

/// Robust boolean kernel (M1 scaffold) — winding-number classification +
/// straddle detection. See `docs/openscad-plan.md`.
#[cfg(feature = "openscad")]
pub mod exact_csg;

/// The RLX bridge: tensors ↔ geometry and pixels, a compiled-graph runner, and
/// exact Delaunay/Voronoi. One module, two independent features (`rlx`,
/// `rlx-geo`) — the renderer itself is unchanged either way.
#[cfg(any(feature = "rlx", feature = "rlx-geo"))]
pub mod rlx;

#[cfg(target_arch = "wasm32")]
#[macro_export]
macro_rules! log {
    ($($t:tt)*) => {{
        let s = format!($($t)*);
        web_sys::console::log_1(&wasm_bindgen::JsValue::from_str(&s));
    }};
}

#[cfg(not(target_arch = "wasm32"))]
#[macro_export]
macro_rules! log {
    ($($t:tt)*) => {{ eprintln!($($t)*); }};
}

pub use animation::{
    AnimationAction, AnimationClip, AnimationMixer, Interpolation, KeyframeTrack, TrackTarget,
};
pub use audio::{Audio, AudioAnalyser, AudioBackend, AudioListener, NoopBackend, PositionalAudio};
#[cfg(feature = "brep")]
pub use brep::{retessellate, Surface, SurfaceTable};
pub use cameras::{Camera, OrthographicCamera, PerspectiveCamera, ScreenProjector};
#[cfg(feature = "captions")]
pub use captions::{
    CaptionAlign, CaptionAnchor, CaptionError, CaptionFont, CaptionFormat, CaptionOverlay,
    CaptionPainter, CaptionStyle, CaptionTrack, Cue,
};
pub use controls::{
    ArcballControls, DragControls, FirstPersonControls, GlobeControls, MapControls, OrbitControls,
    PointerEvent,
    PointerLockControls, TrackballControls,
};
pub use core::{
    Bone, BufferAttribute, BufferGeometry, Clock, InstancedMesh, Intersection, Layers,
    DEFAULT_INFER_QUADS_ANGLE,
    LineSegments, Mesh, MorphAttributes, MorphTarget, Object3D, ObjectArena, ObjectId, ObjectKind,
    Points, Raycaster, Skeleton, SkinnedMesh, Sprite,
};
pub use curves::{
    parse_svg_subpaths, segments_to_path_data, CatmullRomCurve3, CubicBezierCurve,
    CubicBezierCurve3, Curve2, Curve3, CurvePath, EllipseCurve, LineCurve, LineCurve3, NURBSCurve,
    NURBSSurface, Path, PathSegment, QuadraticBezierCurve, QuadraticBezierCurve3, Shape,
    SplineCurve, SvgPathError,
};
pub use extras::{
    CcdIkSolver, IkBone, MarchingCubes, Octree, PmremGenerator, SimplexNoise, PMREM_MIP_LEVELS,
};
#[cfg(feature = "nurbs")]
pub use geometries::NurbsGeometry;
pub use geometries::{
    BoxGeometry, BoxLineGeometry, CapsuleGeometry, CircleGeometry, ConeGeometry, ConvexGeometry,
    CylinderGeometry, DecalGeometry, DodecahedronGeometry, EdgesGeometry, ExtrudeGeometry, Glyph,
    IcosahedronGeometry, Infill, KirigamiAssembly, KirigamiCell, KirigamiCoreLattice,
    KirigamiCrease, KirigamiCreaseKind,
    KirigamiExpandedMiura, KirigamiFace, KirigamiFaceKind, KirigamiMesh, KirigamiNet,
    KirigamiNetPanel, KirigamiPreset, KIRIGAMI_NET_VARIANT, LatheGeometry, Lattice, LatticeGeometry, LatticeKind, LatticeStyle,
    OctahedronGeometry, ParametricGeometry, PlaneGeometry, PolygonGeometry, PolyhedronGeometry, QuadGeometry, Region,
    RingGeometry, SphereGeometry, Strut, TetrahedronGeometry, TextGeometry, TorusGeometry,
    TorusKnotGeometry, Tpms, TubeGeometry, WireframeGeometry, ChiralRule, Cuboct, CuboctAssembly,
    CuboctAssemblyPlan, CuboctAssemblyStep, CuboctFrame, CuboctJoint, CuboctJointKind, FrameMaterial,
    FrameResponse, Hand, Conductivity, Conform, Field, LatticeMetrics, SolidMaterial, Stiffness,
    Solver, Stochastic, Strength,
};
pub use helpers::{
    ArrowHelper, AxesHelper, BoxHelper, CameraHelper, DirectionalLightHelper, GridHelper,
    HemisphereLightHelper, PointLightHelper, PolarGridHelper, SkeletonHelper, SpotLightHelper,
    VertexNormalsHelper, VertexTangentsHelper,
};
pub use origami::{
    book_cardinal_cp, book_cardinal_stages, classic_bird_cp, classic_bird_stages, eagle_cp,
    eagle_stages, frog_cp, frog_stages, giang_cardinal_cp, giang_cardinal_stages, AssembledBird,
    Assignment, BirdKind, BookCardinalStage, ClassicBirdStage, ClosureReport, CreasePattern,
    Degree4, EagleStage, Edge, EdgeKind, FoldedBirdPart, FoldedState, FrogStage, GiangCardinalStage,
    PartPose, TWIST_ALPHA, VertexMode,
};
pub use lights::{
    AmbientLight, DirectionalLight, HemisphereLight, Light, PointLight, RectAreaLight,
    ShadowSettings, ShadowType, SpotLight,
};
pub use loaders::{
    AlembicArchive, AlembicError, ColladaError, ColladaLoader, DracoError, DracoHeader, ExrError,
    ExrLoader, FbxError, FbxLoader, FbxScene, GltfError, GltfImages, GltfLoader, GltfScene,
    HdrError, HdrLoader, Ktx2, Ktx2Error, MeshoptError, ObjLoader, PlyLoader, PolyMesh, StlLoader,
    TtfError, TtfFont, TtfGlyph,
};
// Writing, which the loaders module also provides.
pub use loaders::{scene_to_glb, scene_to_gltf, GltfExportOptions};
pub use materials::MirrorMaterial;
pub use materials::{Blending, DepthFunc, RenderState};
pub use materials::{
    AtmosphereMaterial, BasicMaterial, DepthMaterial, LambertMaterial, LineBasicMaterial,
    MatcapMaterial, Material, MaterialKind, MaterialTextureSlots, NormalMaterial, PhongMaterial,
    PhysicalMaterial, PointsMaterial, ShaderMaterial, SpriteMaterial, StandardMaterial,
    ToonMaterial, TransparencyMode,
};
pub use math::{
    Box2, Box3, Color, Cylindrical, Euler, EulerOrder, Frustum, Line3, Matrix3, Matrix4, Plane, Quaternion,
    Ray, Sphere, Spherical, Triangle, Vector2, Vector3, Vector4,
};
// Colour beyond `Color`: spaces and CSS parsing, ramps and schemes, scales.
pub use math::{
    ColorParseError, ColorRamp, ColorScale, ColorSpace, Palette, RampSpace, ScaleKind, SchemeKind,
};
#[cfg(feature = "nurbs")]
pub use nurbs::{NurbsCurve, NurbsSurface, TessellationOptions};
pub use postprocessing::{
    BloomPass, CopyPass, EffectComposer, FilmPass, FxaaPass, GlitchPass, OutlinePass,
    OutputPass, Pass, RenderPass, ShaderPass, SsaoPass, SsrPass, UnrealBloomPass,
};
#[cfg(not(target_arch = "wasm32"))]
pub use renderer::headless::{
    GpuVendor, HeadlessBuilder, HeadlessConfig, HeadlessRenderer, MappedFrame,
};
/// The `wgpu` this crate was built against, re-exported.
///
/// [`Renderer::new`] takes a `wgpu::Device`, a `wgpu::Queue` and a
/// `wgpu::TextureFormat`, so a caller on the native path necessarily has its own
/// `wgpu` — and a Rust type is scoped to the exact crate version it came from.
/// `wgpu::Device` from 0.20 and `wgpu::Device` from 30 are two unrelated types
/// that happen to print the same, and cargo will happily build both into one
/// graph, so the mismatch surfaces as `expected `wgpu::Device`, found
/// `wgpu::Device`` and no obvious cause.
///
/// Going through `threers::wgpu` makes that impossible to get wrong: it is by
/// construction the same crate this renderer was compiled against.
///
/// ```no_run
/// use threers::wgpu;
///
/// fn take(device: std::sync::Arc<wgpu::Device>, queue: std::sync::Arc<wgpu::Queue>) {
///     let _ = threers::Renderer::new(device, queue, wgpu::TextureFormat::Bgra8UnormSrgb, 800, 600);
/// }
/// ```
pub use wgpu;

pub use renderer::{halton, stratified_jitter, RenderTarget, Renderer, ToneMapping};
pub use renderers::{
    svg_from_rgba, Css2dRenderer, Css3dRenderer, SvgOptions, SvgRenderer, SvgShading,
};
pub use scene::Scene;
pub use stats::Stats;
pub use textures::{
    pack_rgba16f, CubeTexture, DataTexture, DepthTexture, Texture, TextureFilter, TextureFormat,
    TextureWrap,
};
pub use volume::Data3DTexture;
pub use utils::png::{decode_png, encode_png, PngImage};

/// Rendering a sequence: stills, a video, or both from one pass.
pub mod sequence;
pub use sequence::{
    render_sequence, video_available, SequenceError, SequenceOptions, SequenceReport,
};
pub use utils::{
    center as center_geometry, compute_tangents, compute_vertex_normals, merge_geometries,
    scale as scale_geometry,
};

/// Native video export (frame sequence → ffmpeg). Enable the `video` feature.
#[cfg(all(feature = "video", not(target_arch = "wasm32")))]
pub mod video;
#[cfg(all(feature = "video", not(target_arch = "wasm32")))]
pub use video::{
    export_video, export_video_with_progress, format_video_progress, CaptionExport, CaptionMode,
    VideoCodec, VideoError, VideoExportEvent, VideoExportPhase, VideoExportProgress, VideoExporter,
    VideoOptions, VideoQuality,
};

/// From-scratch, pure-Rust media codecs (H.264/MP4, HEVC, VP9/WebM, APNG, GIF,
/// bitstream) — no ffmpeg, no C bindings, and wasm-compatible. Enable the
/// `native-codec` feature.
#[cfg(feature = "native-codec")]
pub mod codec;
#[cfg(feature = "native-codec")]
pub use codec::animation::{
    encode_animation_rgba, encode_animation_rgba_with_progress, format_animation_progress,
    AnimationEncodeError, AnimationEncodeOptions, AnimationExportPhase, AnimationExportProgress,
    BrowserCodec,
};
#[cfg(feature = "native-codec")]
pub use codec::apng::ApngEncoder;
#[cfg(feature = "gif")]
pub use codec::gif::{
    decode_gif, encode_gif, DisposalMethod, DisposalMode, GifDecoder, GifEncoder, GifError,
    GifFrame, GifFrameMeta, GifInfo, GifOptions, GifVersion, GifWriter, LzwClearMode, PaletteMode,
    QuantizerKind,
};
#[cfg(feature = "gif")]
#[allow(deprecated)]
pub use codec::gif::DecodedFrame;
#[cfg(feature = "native-codec")]
pub use codec::h264::{encode_mp4, encode_mp4_with_captions, H264Encoder};
#[cfg(feature = "native-codec")]
pub use codec::hevc::{HevcEncoder, TransparentEncoder, Yuv420Frame};
#[cfg(feature = "native-codec")]
pub use codec::vp9::{
    encode_inter_frame, encode_inter_frame_altref, encode_inter_frame_compound,
    encode_inter_frame_golden, encode_inter_frame_refresh, encode_inter_newmv_residual,
    encode_inter_newmv_skip, encode_inter_residual, encode_inter_zeromv_skip, encode_intra_frame,
    encode_intra_gray, Reconstruction,
};
#[cfg(feature = "native-codec")]
pub use codec::webm::{encode_gray_webm, encode_webm, mux_webm, WebmCodec, WebmFrame, WebmParams};

#[cfg(feature = "mesh-bvh")]
pub use mesh_bvh::{
    BuildOptions as MeshBvhBuildOptions, BvhHit, BvhNodeView, MeshBvh, SerializedMeshBvh, AVERAGE, CENTER,
    CONTAINED, INTERSECTED, NOT_INTERSECTED, SAH,
};

#[cfg(feature = "raytrace")]
pub use raytrace::{
    intersect_box, Aov, BackgroundMode, CpuBackend, RaytraceBackend, RaytraceError, RaytraceRenderer,
    RaytraceScene, RaytraceSettings,
};

#[cfg(feature = "bvh-csg")]
pub use csg::{
    evaluate_hierarchy, CsgBrush, CsgEvaluator, CsgNode, CsgOperation, CsgOperationGroup, ADDITION,
    DIFFERENCE, HOLLOW_INTERSECTION, HOLLOW_SUBTRACTION, INTERSECTION, REVERSE_SUBTRACTION,
    SUBTRACTION,
};

#[cfg(feature = "openscad")]
pub use exact_csg::report::{mesh_report, DefectCluster, MeshReport};
#[cfg(feature = "openscad")]
pub use openscad::export::{
    geometry_to_3mf, geometry_to_glb, geometry_to_obj, geometry_to_off, geometry_to_ply, parts_to_glb,
};
#[cfg(feature = "openscad")]
pub use openscad::freecad::{
    fcstd_meshes, fcstd_to_geometry, fcstd_to_solid, geometry_to_fcstd, geometry_to_fcstd_with,
    parse_mesh_kernel, parse_mesh_kernel_full, parts_to_fcstd, parts_to_fcstd_with, FcstdDocument,
    FcstdDocumentMeta, FcstdError, FcstdLoader, FcstdMesh, FcstdMeshSpec, FcstdPlacement,
    FcstdReadOptions, FcstdSkipped, FcstdWriteOptions, FcstdWriteReport, FcstdWriter,
};
#[cfg(feature = "openscad")]
pub use openscad::mechanism::{
    DriveSpec, MateSpec, MateSpecKind, MechanismSpec, PartFit, PartSpec,
};
#[cfg(feature = "openscad")]
pub use openscad::scad::{
    clear_files, parse_scad, parse_scad_at, parse_scad_file, parse_scad_file_at,
    parse_scad_file_for_parts, parse_scad_file_with, parse_scad_mechanism, parse_scad_mechanism_at, parse_scad_mechanism_file,
    parse_scad_mechanism_file_at, parse_scad_with, parse_scad_with_base, register_file,
    scad_file_values, scad_value, scad_values, scad_values_in,
};
#[cfg(feature = "openscad")]
pub use openscad::schematic::{
    schematic_project, schematic_project_view, schematic_to_rgba, schematic_to_svg, Schematic,
    SchematicOptions, View,
};
#[cfg(feature = "openscad")]
pub use openscad::{build_nema17, build_printer};
#[cfg(feature = "openscad")]
pub use openscad::{
    cone, cube, cylinder, difference_all, frustum, geometry_bounds, geometry_to_stl, hull,
    intersection_all, linear_extrude, linear_extrude_holes, polyhedron, rotate_extrude,
    rotate_extrude_fn, set_origin, solid, sphere, sphere_fn, union_all, Origin, Solid,
};

#[cfg(feature = "planet")]
pub use planet::{
    generate_earth_maps, generate_starfield, Atmosphere, HeightField, MapBuffer, Planet,
    PlanetHandles, PlanetMaps, Starfield,
};
#[cfg(all(feature = "planet", not(target_arch = "wasm32")))]
pub use planet::{EarthTextures, MapSources};