-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
206 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
interface gltf { | ||
use material.{material}; | ||
use mesh.{mesh}; | ||
use node.{node}; | ||
use scene.{scene}; | ||
|
||
// A glTF document. | ||
// Can be saved or loaded independently of the rest of the world. | ||
resource gltf { | ||
constructor(); | ||
|
||
// 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. | ||
default-scene: func() -> option<scene>; | ||
set-default-scene: func(value: borrow<scene>); | ||
|
||
list-materials: func() -> list<material>; | ||
add-material: func(value: borrow<material>); | ||
remove-material: func(value: borrow<material>); | ||
|
||
list-meshes: func() -> list<mesh>; | ||
add-mesh: func(value: borrow<mesh>); | ||
remove-mesh: func(value: borrow<mesh>); | ||
|
||
list-nodes: func() -> list<node>; | ||
add-node: func(value: borrow<node>); | ||
remove-node: func(value: borrow<node>); | ||
|
||
list-scenes: func() -> list<scene>; | ||
add-scene: func(value: borrow<scene>); | ||
remove-scene: func(value: borrow<scene>); | ||
} | ||
} | ||
|
||
interface material { | ||
record color { | ||
r: f32, | ||
g: f32, | ||
b: f32, | ||
a: f32, | ||
} | ||
|
||
resource material { | ||
constructor(); | ||
|
||
id: func() -> u32; | ||
|
||
name: func() -> string; | ||
set-name: func(value: string); | ||
|
||
color: func() -> color; | ||
set-color: func(value: color); | ||
} | ||
} | ||
|
||
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; | ||
|
||
name: func() -> string; | ||
set-name: func(value: string); | ||
|
||
list-primitives: func() -> list<primitive>; | ||
create-primitive: func() -> primitive; | ||
remove-primitive: func(value: borrow<primitive>); | ||
} | ||
} | ||
|
||
interface node { | ||
use mesh.{mesh}; | ||
use wired:input/handler.{input-handler}; | ||
use wired:math/types.{transform}; | ||
use wired:physics/types.{collider, rigid-body}; | ||
|
||
resource node { | ||
constructor(); | ||
|
||
id: func() -> u32; | ||
|
||
name: func() -> string; | ||
set-name: func(value: string); | ||
|
||
children: func() -> list<node>; | ||
add-child: func(value: borrow<node>); | ||
remove-child: func(value: borrow<node>); | ||
|
||
parent: func() -> option<node>; | ||
|
||
transform: func() -> transform; | ||
set-transform: func(value: transform); | ||
|
||
mesh: func() -> option<mesh>; | ||
set-mesh: func(value: option<borrow<mesh>>); | ||
|
||
collider: func() -> option<collider>; | ||
set-collider: func(value: option<borrow<collider>>); | ||
|
||
rigid-body: func() -> option<rigid-body>; | ||
set-rigid-body: func(value: option<borrow<rigid-body>>); | ||
|
||
input-handler: func() -> option<input-handler>; | ||
set-input-handler: func(value: option<borrow<input-handler>>); | ||
} | ||
} | ||
|
||
interface scene { | ||
use node.{node}; | ||
|
||
resource scene { | ||
constructor(); | ||
|
||
nodes: func() -> list<node>; | ||
add-node: func(value: borrow<node>); | ||
remove-node: func(value: borrow<node>); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
interface glxf { | ||
use gltf.{gltf}; | ||
use node.{node}; | ||
|
||
// 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. | ||
resource glxf { | ||
constructor(); | ||
|
||
list-assets: func() -> list<asset>; | ||
add-asset: func(value: asset); | ||
remove-asset: func(value: asset); | ||
|
||
list-nodes: func() -> list<glxf-node>; | ||
add-node: func(value: borrow<glxf-node>); | ||
remove-node: func(value: borrow<glxf-node>); | ||
} | ||
|
||
variant asset { | ||
gltf(asset-gltf), | ||
glxf(asset-glxf), | ||
} | ||
|
||
resource asset-gltf { | ||
constructor(document: borrow<gltf>); | ||
|
||
document: func() -> gltf; | ||
|
||
list-nodes: func() -> list<node>; | ||
add-node: func(value: borrow<node>); | ||
remove-node: func(value: borrow<node>); | ||
} | ||
|
||
resource asset-glxf { | ||
constructor(document: borrow<glxf>); | ||
|
||
document: func() -> glxf; | ||
|
||
list-nodes: func() -> list<glxf-node>; | ||
add-node: func(value: borrow<glxf-node>); | ||
remove-node: func(value: borrow<glxf-node>); | ||
} | ||
|
||
resource glxf-node { | ||
constructor(); | ||
|
||
id: func() -> u32; | ||
|
||
name: func() -> string; | ||
set-name: func(value: string); | ||
|
||
parent: func() -> option<glxf-node>; | ||
|
||
children: func() -> children; | ||
set-children: func(value: children); | ||
} | ||
|
||
variant children { | ||
asset(asset), | ||
nodes(list<glxf-node>), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +1,10 @@ | ||
package wired:scene; | ||
|
||
world host { | ||
world prelude { | ||
import gltf; | ||
import glxf; | ||
import material; | ||
import mesh; | ||
import node; | ||
} | ||
|
||
interface material { | ||
record color { | ||
r: f32, | ||
g: f32, | ||
b: f32, | ||
a: f32, | ||
} | ||
|
||
resource material { | ||
id: func() -> u32; | ||
|
||
name: func() -> string; | ||
set-name: func(value: string); | ||
|
||
color: func() -> color; | ||
set-color: func(value: color); | ||
} | ||
|
||
list-materials: func() -> list<material>; | ||
create-material: func() -> material; | ||
remove-material: func(value: material); | ||
} | ||
|
||
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 { | ||
id: func() -> u32; | ||
|
||
name: func() -> string; | ||
set-name: func(value: string); | ||
|
||
list-primitives: func() -> list<primitive>; | ||
create-primitive: func() -> primitive; | ||
remove-primitive: func(value: primitive); | ||
} | ||
|
||
list-meshes: func() -> list<mesh>; | ||
create-mesh: func() -> mesh; | ||
remove-mesh: func(value: mesh); | ||
} | ||
|
||
interface node { | ||
use mesh.{mesh}; | ||
use wired:input/handler.{input-handler}; | ||
use wired:math/types.{transform}; | ||
use wired:physics/types.{collider, rigid-body}; | ||
|
||
resource node { | ||
id: func() -> u32; | ||
|
||
name: func() -> string; | ||
set-name: func(value: string); | ||
|
||
children: func() -> list<node>; | ||
add-child: func(value: borrow<node>); | ||
remove-child: func(value: borrow<node>); | ||
|
||
parent: func() -> option<node>; | ||
|
||
transform: func() -> transform; | ||
set-transform: func(value: transform); | ||
|
||
mesh: func() -> option<mesh>; | ||
set-mesh: func(value: option<borrow<mesh>>); | ||
|
||
collider: func() -> option<collider>; | ||
set-collider: func(value: option<borrow<collider>>); | ||
|
||
rigid-body: func() -> option<rigid-body>; | ||
set-rigid-body: func(value: option<borrow<rigid-body>>); | ||
|
||
input-handler: func() -> option<input-handler>; | ||
set-input-handler: func(value: option<borrow<input-handler>>); | ||
} | ||
|
||
list-nodes: func() -> list<node>; | ||
create-node: func() -> node; | ||
remove-node: func(value: node); | ||
import scene; | ||
} |