mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-16 00:03:29 +00:00
Single-object viewer POC (#14)
This commit implements a Sketchfab-style single-object viewer as a minimal proof-of-concept. ### `@storyteller/studio-web` This is a new package to house web components for interfacing with the `@storyteller/studio` WASM library. It currently includes a single component, `<sts-viewer />`, which is exported from `@storyteller/studio-web/viewer`. ### `react-frontend` This is a new application intended as a proof-of-concept and testbed for React interop with `@storyteller/studio-web`. Web components are currently a little bit fiddly to use in a React application. `react-frontend/src/app/studio-viewer.tsx` demonstrates how a React-idiomatic component can be written as a thin wrapper around a web component, and `react-frontend/src/app/app.tsx` demonstrates that wrapper component in use.
This commit is contained in:
+25
-1
@@ -7,11 +7,18 @@ use bevy_mod_picking::debug::DebugPickingMode;
|
||||
use crate::{
|
||||
camera_controller::{CameraController, CameraMotionSystem},
|
||||
input::{Action, InputAction, Lifecycle},
|
||||
MainCamera,
|
||||
};
|
||||
|
||||
#[derive(Resource, Deref, DerefMut)]
|
||||
pub struct DebugMode(bool);
|
||||
|
||||
#[derive(Component, Clone, Copy, Debug)]
|
||||
pub struct DebugPoint {
|
||||
pub point: Vec3,
|
||||
pub color: Color,
|
||||
}
|
||||
|
||||
pub struct DebugPlugin;
|
||||
impl Plugin for DebugPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
@@ -31,7 +38,7 @@ impl Plugin for DebugPlugin {
|
||||
toggle_debug_mode,
|
||||
update_debug_picking_mode.run_if(resource_changed::<DebugMode>()),
|
||||
update_gizmo_line_thickness,
|
||||
draw_world_axes
|
||||
(draw_world_axes, draw_debug_points)
|
||||
.after(CameraMotionSystem)
|
||||
.run_if(is_debug_mode),
|
||||
),
|
||||
@@ -84,6 +91,23 @@ fn draw_world_axes(mut gizmos: Gizmos, q: Query<&CameraController>) {
|
||||
draw_axis(Vec3::Z, Color::BLUE);
|
||||
}
|
||||
|
||||
fn draw_debug_points(
|
||||
mut gizmos: Gizmos,
|
||||
q_debug_points: Query<&DebugPoint>,
|
||||
q_cam_xform: Query<&GlobalTransform, With<MainCamera>>,
|
||||
) {
|
||||
let Ok(cam_xform) = q_cam_xform.get_single() else {
|
||||
return;
|
||||
};
|
||||
for &DebugPoint { point, color } in q_debug_points.iter() {
|
||||
let dist = cam_xform.translation().distance(point);
|
||||
gizmos.cuboid(
|
||||
Transform::from_translation(point).with_scale(Vec3::splat(dist / 300.)),
|
||||
color,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[allow(dead_code)]
|
||||
pub fn write_mat3(w: &mut impl fmt::Write, m: &Mat3) -> fmt::Result {
|
||||
|
||||
Reference in New Issue
Block a user