forked from 1b-agent/opencadstudio-upstream
feat(web): unify fonts and refine viewcube
Preload one language-aware font resource across the interface, drawing text, and navigation labels.\n\nRender the navigation cube, ring, outlines, and labels through a 4x MSAA target.
This commit is contained in:
1 parent
8dc642d40c
commit
53cf31f33d
26 files changed
+1337
-522
No files matched your search
@@ -1,4 +1,4 @@
|
||||
// ViewCube shader — Phong lighting + hover highlight.
|
||||
// ViewCube shader — flat surface fill, hover highlight, and edge lines.
|
||||
|
||||
struct Uniforms {
|
||||
view_proj: mat4x4<f32>,
|
||||
@@ -26,9 +26,22 @@ fn fs_main(in: VOut) -> @location(0) vec4<f32> {
|
||||
let is_hovered = abs(in.region_f - u.hover_region.x) < 0.001 && u.hover_region.x >= 0.0;
|
||||
var final_rgb = in.color;
|
||||
if is_hovered {
|
||||
let glow = vec3<f32>(0.68, 0.88, 1.0);
|
||||
final_rgb = mix(final_rgb, glow, 0.60);
|
||||
final_rgb = clamp(final_rgb * 1.30, vec3<f32>(0.0), vec3<f32>(1.0));
|
||||
final_rgb = vec3<f32>(0.20, 0.72, 0.66);
|
||||
}
|
||||
return vec4<f32>(final_rgb, 1.0);
|
||||
}
|
||||
|
||||
struct LineIn {
|
||||
@location(0) pos: vec3<f32>,
|
||||
}
|
||||
|
||||
@vertex
|
||||
fn line_vs_main(in: LineIn) -> @builtin(position) vec4<f32> {
|
||||
let rotated = (u.rotation * vec4<f32>(in.pos, 1.0)).xyz;
|
||||
return u.view_proj * vec4<f32>(rotated, 1.0);
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn line_fs_main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.05, 0.08, 0.13, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
struct VertexOutput {
|
||||
@builtin(position) position: vec4<f32>,
|
||||
@location(0) uv: vec2<f32>,
|
||||
}
|
||||
|
||||
struct CompositeUniforms {
|
||||
uv_scale: vec2<f32>,
|
||||
_pad: vec2<f32>,
|
||||
}
|
||||
|
||||
var<private> POSITIONS: array<vec2<f32>, 6> = array<vec2<f32>, 6>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>(-1.0, -1.0),
|
||||
vec2<f32>( 1.0, 1.0),
|
||||
vec2<f32>(-1.0, -1.0),
|
||||
vec2<f32>( 1.0, -1.0),
|
||||
vec2<f32>( 1.0, 1.0),
|
||||
);
|
||||
|
||||
var<private> UVS: array<vec2<f32>, 6> = array<vec2<f32>, 6>(
|
||||
vec2<f32>(0.0, 0.0),
|
||||
vec2<f32>(0.0, 1.0),
|
||||
vec2<f32>(1.0, 0.0),
|
||||
vec2<f32>(0.0, 1.0),
|
||||
vec2<f32>(1.0, 1.0),
|
||||
vec2<f32>(1.0, 0.0),
|
||||
);
|
||||
|
||||
@vertex
|
||||
fn vs_main(@builtin(vertex_index) index: u32) -> VertexOutput {
|
||||
var output: VertexOutput;
|
||||
output.position = vec4<f32>(POSITIONS[index], 0.0, 1.0);
|
||||
output.uv = UVS[index];
|
||||
return output;
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var resolved_texture: texture_2d<f32>;
|
||||
@group(0) @binding(1) var resolved_sampler: sampler;
|
||||
@group(0) @binding(2) var<uniform> uniforms: CompositeUniforms;
|
||||
|
||||
@fragment
|
||||
fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
|
||||
return textureSample(resolved_texture, resolved_sampler, input.uv * uniforms.uv_scale);
|
||||
}
|
||||
@@ -8,7 +8,7 @@ struct Uniforms {
|
||||
@group(0) @binding(2) var tex: texture_2d<f32>;
|
||||
|
||||
struct VsIn {
|
||||
@location(0) pos: vec2<f32>,
|
||||
@location(0) pos: vec3<f32>,
|
||||
@location(1) uv: vec2<f32>,
|
||||
@location(2) color: vec4<f32>,
|
||||
};
|
||||
@@ -26,7 +26,7 @@ fn vs_main(input: VsIn) -> VsOut {
|
||||
(input.pos.x / u.screen.x) * 2.0 - 1.0,
|
||||
1.0 - (input.pos.y / u.screen.y) * 2.0
|
||||
);
|
||||
out.pos = vec4<f32>(ndc, 0.0, 1.0);
|
||||
out.pos = vec4<f32>(ndc, input.pos.z, 1.0);
|
||||
out.uv = input.uv;
|
||||
out.color = input.color;
|
||||
return out;
|
||||
|
||||
Reference in new issue
Block a user