Skip to content

Commit

Permalink
wired-scene refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhhh committed Oct 2, 2024
1 parent aab8841 commit bc7de8f
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 259 deletions.
38 changes: 38 additions & 0 deletions spatial/wit/wired-scene/composition.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
interface composition {
use document.{document};
use wired:math/types.{transform};

variant asset {
composition(composition),
document(document),
}

resource asset-node {
constructor();

asset: func() -> option<asset>;
set-asset: func(value: option<asset>);

name: func() -> string;
set-name: func(value: string);

parent: func() -> option<asset-node>;
children: func() -> list<asset-node>;
add-child: func(value: borrow<asset-node>);
remove-child: func(value: borrow<asset-node>);

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

/// A composition of assets.
/// Roughly equivalent to a glXF file.
resource composition {
constructor();

nodes: func() -> list<asset-node>;
add-node: func(value: borrow<asset-node>);
remove-node: func(value: borrow<asset-node>);
}
}
21 changes: 21 additions & 0 deletions spatial/wit/wired-scene/document.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
interface document {
use scene.{scene};

/// A save-able collection of resources with an active scene.
/// Roughly equivalent to a glTF file.
resource document {
constructor();

active-scene: func() -> option<scene>;
set-active-scene: func(value: option<borrow<scene>>);

/// The initial active scene, set on document load.
/// If none is provided, the first scene will be used.
default-scene: func() -> option<scene>;
set-default-scene: func(value: option<borrow<scene>>);

scenes: func() -> list<scene>;
add-scene: func(value: borrow<scene>);
remove-scene: func(value: borrow<scene>);
}
}
149 changes: 0 additions & 149 deletions spatial/wit/wired-scene/gltf.wit

This file was deleted.

108 changes: 0 additions & 108 deletions spatial/wit/wired-scene/glxf.wit

This file was deleted.

22 changes: 22 additions & 0 deletions spatial/wit/wired-scene/material.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
interface material {
record color {
r: f32,
g: f32,
b: f32,
a: f32,
}

resource material {
constructor();

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

name: func() -> string;
set-name: func(value: string);

color: func() -> color;
set-color: func(value: color);
}
}
30 changes: 30 additions & 0 deletions spatial/wit/wired-scene/mesh.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
interface mesh {
use material.{material};

resource primitive {
id: func() -> u32;

material: func() -> option<material>;
set-material: func(value: option<borrow<material>>);

set-indices: func(value: list<u32>);
set-normals: func(value: list<f32>);
set-positions: func(value: list<f32>);
set-uvs: func(value: list<f32>);
}

resource mesh {
constructor();

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

name: func() -> string;
set-name: func(value: string);

list-primitives: func() -> list<primitive>;
create-primitive: func() -> primitive;
remove-primitive: func(value: primitive);
}
}
Loading

0 comments on commit bc7de8f

Please sign in to comment.