Skip to content

Commit

Permalink
feat: update flatland
Browse files Browse the repository at this point in the history
  • Loading branch information
technobaboo committed Jun 21, 2024
1 parent d7b1eab commit 8b7d381
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 48 deletions.
79 changes: 43 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions src/close_button.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::{surface::Surface, toplevel::TOPLEVEL_THICKNESS};
use stardust_xr_fusion::{
core::values::{color::rgba_linear, ResourceID},
drawable::{MaterialParameter, Model, ModelPart, ModelPartAspect},
fields::{BoxField, BoxFieldAspect},
fields::{Field, Shape},
input::{InputDataType::Pointer, InputHandler},
items::panel::{PanelItem, PanelItemAspect},
node::{NodeError, NodeType},
Expand All @@ -13,14 +14,12 @@ use stardust_xr_molecules::{
Exposure,
};

use crate::{surface::Surface, toplevel::TOPLEVEL_THICKNESS};

pub struct CloseButton {
item: PanelItem,
model: Model,
shell: ModelPart,
exposure: Exposure,
field: BoxField,
field: Field,
input: InputQueue,
distance_action: MultiActorAction,
}
Expand All @@ -42,10 +41,13 @@ impl CloseButton {
};

// compensate for the server not being able to handle scaled fields
let field = BoxField::create(&shell, Transform::none(), [1.5, 1.0, 1.0])?;
let field = Field::create(
&shell,
Transform::none(),
Shape::Box([1.5 * 0.025, 0.025, thickness].into()),
)?;
field.set_spatial_parent_in_place(&item)?;
field.set_local_transform(Transform::from_scale([1.0; 3]))?;
field.set_size([1.5 * 0.025, 0.025, thickness])?;

let input = InputHandler::create(&shell, Transform::none(), &field)?.queue()?;
let interact_action = MultiActorAction::default();
Expand Down
11 changes: 8 additions & 3 deletions src/grab_ball.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ use stardust_xr_fusion::{
Vector3,
},
drawable::{Line, LinePoint, Lines, LinesAspect},
fields::SphereField,
fields::{Field, Shape},
input::{InputDataType, InputHandler},
node::{NodeError, NodeType},
spatial::{Spatial, SpatialAspect, Transform},
};
use stardust_xr_molecules::input_action::{InputQueue, InputQueueable, SingleActorAction};

pub trait GrabBallHead {
fn root(&self) -> &impl SpatialAspect;
fn set_enabled(&mut self, enabled: bool);
Expand Down Expand Up @@ -39,7 +40,7 @@ pub struct GrabBall<H: GrabBallHead> {
connector: Lines,
connector_line: Line,
offset: Vec3,
_field: SphereField,
_field: Field,
settings: GrabBallSettings,
input: InputQueue,
grab_action: SingleActorAction,
Expand Down Expand Up @@ -76,7 +77,11 @@ impl<H: GrabBallHead> GrabBall<H> {
Transform::none(),
&vec![connector_line.clone()],
)?;
let _field = SphereField::create(head.root(), [0.0; 3], settings.radius)?;
let _field = Field::create(
head.root(),
Transform::identity(),
Shape::Sphere(settings.radius),
)?;
let input_handler =
InputHandler::create(&connect_root, Transform::none(), &_field)?.queue()?;

Expand Down
2 changes: 1 addition & 1 deletion src/panel_shell_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rustc_hash::FxHashMap;
use stardust_xr_fusion::{
core::values::{color::rgba_linear, ResourceID},
drawable::{MaterialParameter, Model, ModelPart, ModelPartAspect},
fields::{Field, FieldAspect},
fields::{Field, FieldRefAspect},
items::panel::{PanelItem, PanelItemAcceptor, PanelItemAcceptorAspect},
node::{NodeError, NodeType},
spatial::{SpatialAspect, Transform},
Expand Down
4 changes: 2 additions & 2 deletions src/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl Surface {
let keyboard = create_keyboard_panel_handler(
&item,
Transform::none(),
&touch_plane.field(),
touch_plane.field(),
&item,
id.clone(),
)?;
Expand Down Expand Up @@ -278,7 +278,7 @@ impl Surface {
pub fn root(&self) -> &Spatial {
&self.root
}
pub fn field(&self) -> Field {
pub fn field(&self) -> &Field {
self.touch_plane.field()
}
pub fn physical_size(&self) -> Vec2 {
Expand Down

0 comments on commit 8b7d381

Please sign in to comment.