module
scene_bridge
Converts canvas2d / scene3d element subtrees into graphics data.
canvas2d(width, height) { rect(x,y,w,h,r) circle(cx,cy,r) arc(cx,cy,r,inner,start,end)
line(x1,y1,x2,y2) path(points: "x,y …", closed, smooth)
text(x,y,size,align,weight) "…" }
scene3d(width, height, background, fog, backdrop, backdrop-colors,
backdrop-intensity, backdrop-speed) {
camera(x,y,z,fov,tx,ty,tz) light(x,y,z,ambient,color,sky,ground,cast-shadow)
pointLight(position,color,intensity,distance,cast-shadow)
spotLight(position,target,color,intensity,distance,angle,penumbra,cast-shadow)
particles(count,radius,shape,color,color2,size,speed,seed,x,y,z)
cube(size) sphere(radius) plane(size) torus(radius,tube) torus-knot(radius,tube,p,q)
icosphere(radius,detail) cylinder(radius,height) cone(radius,height)
text3d(font,size,depth,bevel,align,line-height,letter-spacing,curve,text) "…"
model(src,node,animation,animation-speed,loop)
mesh { …Geometry(args) meshStandardMaterial(…) | meshPhysicalMaterial(…) | shaderMaterial(…) } }
meshPhysicalMaterial(color, metallic, roughness, emissive, emissive-intensity, opacity,
env-intensity, map, metallic-roughness-map, roughness-map,
metallic-map, normal-map, normal-scale, occlusion-map,
occlusion-strength, emissive-map)
shaderMaterial(vertex, fragment, uniforms, attributes, texture, transparent,
side, blending, depth-write, opacity) {
uniform(name, value | texture, wrap, filter, flip-y)
attribute(name, size, values) }
shader(preset | fragment, colors, speed, intensity)
particles2d(count, density, color, shape, size, links, speed, hover, click, …)Any object element may have a material child (meshStandardMaterial, which also takes map, meshPhysicalMaterial (also pbr), or shaderMaterial); on a model it replaces the model's own materials. pbr: true on an object or a standard material makes it physical too. Shadows are opt-in: cast-shadow on a light (with shadow-map-size, shadow-bias, shadow-softness), and cast-shadow / receive-shadow on objects. Shapes take fill, fill-to (+ radial), stroke, line-width, glow and opacity. 3D objects take x y z, rotate-x/y/z (degrees), scale, color, color2, shininess, rim, rim-color, emissive, wobble, opacity, motion (spin-x/y/z °/s, float, pulse, speed) and transition (ms). Any item may have a label (exposed to assistive technology) and event handlers.
Structs
- CanvasBuild
A
canvas2delement turned into shapes, with what each one is in the template. - HtmlAnchor
An
htmlelement in a scene: where its DOM goes. - ItemMeta
Per-item metadata kept alongside shapes/objects (same order).
- SceneBuild
A
scene3delement turned into a scene: its objects, what each one is in the template, and the HTML placed in it.
Enums
- Placement
Where an
htmllayer goes this frame.
Functions
build_canvas
pub fn build_canvas(el: &VElement) -> CanvasBuildShapes (in draw order) for a canvas2d element.
build_particles
pub fn build_particles(el: &VElement) -> ParticleOptionsThe options for a particles2d background.
build_scene
pub fn build_scene(el: &VElement) -> SceneBuildCamera, lights, objects and particles for a scene3d element.
build_shader
pub fn build_shader(el: &VElement) -> ShaderSpecThe shader a shader element describes: its preset, colours, speed and the rest.
color_attr
pub fn color_attr(el: &VElement, name: &str) -> Option<Color>The colour attribute name of el, if it's set to one Color::parse reads.
html_placement
pub fn html_placement(a: &HtmlAnchor, scene: &Scene, w: f32, h: f32, time: f32, overrides: &[(Transform, Color)], size: (f32, f32)) -> PlacementWhere a's layer goes in a w×h (CSS pixel) view at time. size is the layer's own size in CSS pixels (for centring and planes).
is_html_in_scene
pub fn is_html_in_scene(tag: &str) -> boolWhether a scene child is an html element: real DOM placed in the scene.
num_attr
pub fn num_attr(el: &VElement, name: &str, default: f32) -> f32Numeric attribute (numeric strings accepted) or default.
parse_colors
pub fn parse_colors(s: &str) -> Vec<Color>Parse "#000 #fff, red" into colors (invalid entries are skipped).
parse_points
pub fn parse_points(s: &str) -> Vec<(f32, f32)>Parse "x,y x,y …", skipping malformed pairs.
surface_size
pub fn surface_size(el: &VElement) -> (f32, f32)Pixel size of a drawing surface (HTML canvas default 300×150).