Skip to content

Commit

Permalink
wired-input refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhhh committed Jun 27, 2024
1 parent 503eaab commit b9622a1
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 51 deletions.
4 changes: 0 additions & 4 deletions spatial/wit/wired-event/emitter.wit

This file was deleted.

2 changes: 0 additions & 2 deletions spatial/wit/wired-event/listener.wit

This file was deleted.

6 changes: 0 additions & 6 deletions spatial/wit/wired-event/world.wit

This file was deleted.

6 changes: 0 additions & 6 deletions spatial/wit/wired-input/api.wit

This file was deleted.

1 change: 1 addition & 0 deletions spatial/wit/wired-input/deps/wired-gltf
1 change: 1 addition & 0 deletions spatial/wit/wired-input/deps/wired-math
16 changes: 0 additions & 16 deletions spatial/wit/wired-input/handler.wit

This file was deleted.

3 changes: 0 additions & 3 deletions spatial/wit/wired-input/method.wit

This file was deleted.

14 changes: 7 additions & 7 deletions spatial/wit/wired-input/types.wit
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface types {
metacarpal: joint,
}

/// Hand tracking data.
// Hand tracking data.
record hand {
side: hand-side,

Expand All @@ -34,13 +34,13 @@ interface types {
elbow: option<joint>,
}

/// A line with an origin and a direction.
// A line with an origin and a direction.
record ray {
origin: vec3,
orientation: quat,
}

/// A single point of interaction, such as the tip of a stylus.
// A single point of interaction, such as the tip of a stylus.
record tip {
origin: vec3,
orientation: quat,
Expand All @@ -54,13 +54,13 @@ interface types {
}

record input-event {
/// Unique id for the event.
// Unique id for the event.
id: u64,
/// Spatial input data.
// Spatial input data.
input: input-type,
/// Distance from the input method to the handler.
// Distance from the input method to the handler.
distance: f32,
/// How many handlers received the event before this one.
// How many handlers received the event before this one.
order: u32,
}
}
27 changes: 20 additions & 7 deletions spatial/wit/wired-input/world.wit
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
package wired:input;

world imports {
world host {
import handler;
import method;
import types;
import api;
}

world host {
export api;
}
interface handler {
use types.{input-event};
use wired:gltf/node.{node};

// Input handler.
// Represents an object in 3D space that can react to input.
// Handlers can optionally capture the input method, stopping propagation to other handlers.
resource spatial-handler {
constructor(node: borrow<node>);

// Handle the next recieved input event.
// Events only last for one tick.
handle-input: func() -> option<input-event>;
}
}

// Input method.
// Represents a single point of interaction (3D pointer, hand, finger tip).
interface method {}

0 comments on commit b9622a1

Please sign in to comment.