khora_data/render/wireframe.rs
1// Copyright 2025 eraflo
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Wireframe debug-overlay configuration.
16//!
17//! Drawing every scene mesh as edge lines is a debug view, like the editor
18//! [`GridConfig`](super::GridConfig). Only the contract type lives in
19//! `khora-data`; the GPU work is the engine-side `WireframeLane`'s job.
20//!
21//! A host application opts in by enabling this config (shared as an
22//! `Arc<Mutex<WireframeConfig>>` runtime resource). Disabled by default — the
23//! editor drives it from a viewport toggle; the sandbox leaves it off.
24
25use khora_core::math::LinearRgba;
26
27/// Wireframe debug-overlay state.
28#[derive(Debug, Clone)]
29pub struct WireframeConfig {
30 /// Whether `WireframeLane` draws the scene meshes as edge lines.
31 pub enabled: bool,
32 /// Line color (linear RGBA; alpha modulates the anti-aliased edge).
33 pub line_color: LinearRgba,
34 /// Edge line width, in the shader's barycentric units.
35 pub line_width: f32,
36}
37
38impl Default for WireframeConfig {
39 fn default() -> Self {
40 Self {
41 enabled: false,
42 // A bright cyan reads clearly over both lit surfaces and the sky.
43 line_color: LinearRgba::new(0.2, 0.9, 1.0, 1.0),
44 line_width: 1.5,
45 }
46 }
47}
48
49#[cfg(test)]
50mod tests {
51 use super::*;
52
53 #[test]
54 fn disabled_by_default() {
55 assert!(!WireframeConfig::default().enabled);
56 }
57}