Skip to content

Commit

Permalink
clean up + add global-transform
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhhh committed Sep 3, 2024
1 parent aa276a9 commit 9ac06c4
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 32 deletions.
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,
}
}
4 changes: 2 additions & 2 deletions spatial/wit/wired-input/world.wit
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ interface handler {
resource input-handler {
constructor();

// Handle the next recieved input event.
// Events only last for one tick.
/// Handle the next recieved input event.
/// Events only last for one tick.
handle-input: func() -> option<input-event>;
}
}
2 changes: 1 addition & 1 deletion spatial/wit/wired-log/world.wit
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface api {
debug,
info,
warn,
error
error,
}

log: func(level: log-level, message: string);
Expand Down
11 changes: 9 additions & 2 deletions spatial/wit/wired-math/world.wit
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package wired:math;

world prelude {
import types;
}

interface types {
record vec2 {
x: f32,
Expand All @@ -25,6 +29,9 @@ interface types {
translation: vec3,
}

// Codegen doesn't always include vec2, add this function to force its inclusion.
fake-fn: func() -> vec2;
/// Codegen doesn't always include types, these function force its inclusion.
fake-fn-a: func() -> vec2;
fake-fn-b: func() -> vec3;
fake-fn-c: func() -> quat;
fake-fn-d: func() -> transform;
}
2 changes: 1 addition & 1 deletion spatial/wit/wired-prelude/world.wit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package wired:prelude;

// Prelude to be included in your world for ease of use.
/// Prelude to be included in your world for ease of use.
world imports {
import wired:input/handler;
import wired:log/api;
Expand Down
18 changes: 10 additions & 8 deletions spatial/wit/wired-scene/gltf.wit
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ interface gltf {
use node.{node};
use scene.{scene};

// A glTF document.
// Can be saved or loaded independently of the rest of the world.
/// A glTF document.
/// Can be saved or loaded independently of the rest of the world.
resource gltf {
constructor();

Expand All @@ -25,12 +25,12 @@ interface gltf {
add-scene: func(value: borrow<scene>);
remove-scene: func(value: borrow<scene>);

// The currently loaded scene.
/// The currently loaded scene.
active-scene: func() -> option<scene>;
set-active-scene: func(value: option<borrow<scene>>);

// The default active scene, used when an asset is first loaded.
// If not explicitly set, the first scene will be used.
/// The default active scene, used when an asset is first loaded.
/// If not explicitly set, the first scene will be used.
default-scene: func() -> option<scene>;
set-default-scene: func(value: borrow<scene>);
}
Expand All @@ -48,7 +48,7 @@ interface material {
constructor();

id: func() -> u32;
// Returns another reference to the same resource.
/// Returns another reference to the same resource.
ref: func() -> material;

name: func() -> string;
Expand Down Expand Up @@ -78,7 +78,7 @@ interface mesh {
constructor();

id: func() -> u32;
// Returns another reference to the same resource.
/// Returns another reference to the same resource.
ref: func() -> mesh;

name: func() -> string;
Expand All @@ -100,7 +100,7 @@ interface node {
constructor();

id: func() -> u32;
// Returns another reference to the same resource.
/// Returns another reference to the same resource.
ref: func() -> node;

name: func() -> string;
Expand All @@ -112,6 +112,8 @@ interface node {

parent: func() -> option<node>;

global-transform: func() -> transform;

transform: func() -> transform;
set-transform: func(value: transform);

Expand Down
20 changes: 10 additions & 10 deletions spatial/wit/wired-scene/glxf.wit
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ interface glxf {
use node.{node};
use wired:math/types.{transform};

// Returns the root glXF that the script is attached to.
/// Returns the root glXF that the script is attached to.
get-root: func() -> glxf;

// A glXF document.
// Used to compose multiple independent glTF assets together.
/// A glXF document.
/// Used to compose multiple independent glTF assets together.
resource glxf {
constructor();

Expand All @@ -24,12 +24,12 @@ interface glxf {
add-scene: func(value: borrow<glxf-scene>);
remove-scene: func(value: borrow<glxf-scene>);

// The currently loaded scene.
/// The currently loaded scene.
active-scene: func() -> option<glxf-scene>;
set-active-scene: func(value: option<borrow<glxf-scene>>);

// The default active scene, used when an asset is first loaded.
// If not explicitly set, the first scene will be used.
/// The default active scene, used when an asset is first loaded.
/// If not explicitly set, the first scene will be used.
default-scene: func() -> option<glxf-scene>;
set-default-scene: func(value: borrow<glxf-scene>);
}
Expand All @@ -48,8 +48,8 @@ interface glxf {

document: func() -> gltf;

/// Asset nodes to use.
/// If empty, will use the default scene.
//// Asset nodes to use.
//// If empty, will use the default scene.
list-nodes: func() -> list<node>;
add-node: func(value: borrow<node>);
remove-node: func(value: borrow<node>);
Expand All @@ -60,8 +60,8 @@ interface glxf {

document: func() -> glxf;

/// Asset nodes to use.
/// If empty, will use the default scene.
//// Asset nodes to use.
//// If empty, will use the default scene.
list-nodes: func() -> list<glxf-node>;
add-node: func(value: borrow<glxf-node>);
remove-node: func(value: borrow<glxf-node>);
Expand Down
2 changes: 1 addition & 1 deletion spatial/wit/wired-script/world.wit
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ world script {
interface types {
resource script {
constructor();
// Called every tick.
//// Called every tick.
update: func(delta: f32);
}
}

0 comments on commit 9ac06c4

Please sign in to comment.