
Field | Type | Notes |
|---|---|---|
primitives | Vec<Primitive3D> | Geometry stored in the scene. |
Primitive3D::Mesh | vertices, indices, color | Triangle geometry expressed as positions and vertex indices. |
width / height | Option<f32> | Fixed viewport dimensions when supplied; None leaves sizing to layout. |
use fission::three_d::{Point3D, Primitive3D};
use fission::core::op::Color;
fn reading_bar(x: f32, z: f32, height: f32, color: Color) -> Primitive3D {
let half_width = 0.3;
Primitive3D::Mesh {
vertices: vec![
Point3D::new(x - half_width, 0.0, z - half_width),
Point3D::new(x + half_width, 0.0, z - half_width),
Point3D::new(x + half_width, height, z - half_width),
Point3D::new(x - half_width, height, z - half_width),
Point3D::new(x - half_width, 0.0, z + half_width),
Point3D::new(x + half_width, 0.0, z + half_width),
Point3D::new(x + half_width, height, z + half_width),
Point3D::new(x - half_width, height, z + half_width),
],
indices: vec![
0, 1, 2, 0, 2, 3,
1, 5, 6, 1, 6, 2,
5, 4, 7, 5, 7, 6,
4, 0, 3, 4, 3, 7,
3, 2, 6, 3, 6, 7,
4, 5, 1, 4, 1, 0,
],
color,
}
}
use fission::prelude::*;
use fission::three_d::Scene3D;
fission_component! {
pub StorageReadings<()> {
props {
title: TextContent,
readings: Vec<Vec<Option<f32>>>,
bar_color: Color,
}
}
view(chart, _state, _cx) {
let mut scene = Scene3D::new().height(320.0);
for (row, readings) in chart.readings.iter().enumerate() {
for (column, &reading) in readings.iter().enumerate() {
let Some(height) = reading else { continue };
if height.is_finite() && height > 0.0 {
scene = scene.add_primitive(reading_bar(
column as f32,
row as f32,
height,
chart.bar_color,
));
}
}
}
} => Column(
children: [
Text(chart.title.clone()),
scene,
],
)
}
Area | What to decide | How to check it |
|---|---|---|
Data shape | Keep measurements separate from mesh geometry, with a documented scale and missing-value policy. | Test that conversion without constructing a widget tree. |
Presentation | Reserve depth for spatial relationships, not decoration. | Inspect occlusion with the largest expected grid. |
Accessibility | Provide a summary and accessible values outside the scene. A title alone does not describe the readings. | Check that the same question can be answered without seeing the scene. |
Failure handling | Show a loading, empty, or error state when the data is not ready. | Test empty data, partial data, and a failed fetch. |
Performance | Summarize or window very large datasets; keep the full history in your data layer. | Profile frame time and interaction latency with representative data. |