Skip to content

Commit

Permalink
Updates web example
Browse files Browse the repository at this point in the history
  • Loading branch information
codeneix committed Nov 7, 2023
1 parent a6664dd commit 9db3528
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 12 deletions.
4 changes: 4 additions & 0 deletions examples/web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ const Tools = () => {
controller && controller.activateTool(1);
}

useEffect(() => {
controller && controller.addRectangle([100, 100], [100, 100]);
}, [controller])

return (
<Stack direction="row" spacing={2}>
<Typography variant="h6">Tools: </Typography>
Expand Down
10 changes: 1 addition & 9 deletions runtime/src/wasm.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::{Arc, RwLock};

use crate::RadiantRuntime;
use crate::{RadiantNodeType, RadiantRectangleNode, RectangleTool, Runtime};
use crate::{RectangleTool, Runtime};
use wasm_bindgen::prelude::*;

#[wasm_bindgen(js_name = RadiantAppController)]
Expand All @@ -23,14 +23,6 @@ impl RadiantAppController {
.scene
.tool_manager
.register_tool(1u32, Box::new(RectangleTool::new()));
runtime
.view
.scene
.add(RadiantNodeType::Rectangle(RadiantRectangleNode::new(
1,
[100.0, 100.0],
[100.0, 100.0],
)));

let runtime = Arc::new(RwLock::new(runtime));

Expand Down
8 changes: 8 additions & 0 deletions runtime/web/lib/cjs/controller/index.js

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

2 changes: 1 addition & 1 deletion runtime/web/lib/cjs/controller/index.js.map

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

8 changes: 8 additions & 0 deletions runtime/web/lib/esm/controller/index.js

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

2 changes: 1 addition & 1 deletion runtime/web/lib/esm/controller/index.js.map

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

1 change: 1 addition & 0 deletions runtime/web/lib/types/controller/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export declare class RadiantController {
* @param tool the tool to activate.
*/
activateTool(toolId: number): void;
addRectangle(position: number[], scale: number[]): void;
setTransform(nodeId: number, position: number[], scale: number[]): void;
setFillColor(nodeId: number, color: number[]): void;
setStrokeColor(nodeId: number, color: number[]): void;
Expand Down
2 changes: 1 addition & 1 deletion runtime/web/lib/types/controller/index.d.ts.map

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

9 changes: 9 additions & 0 deletions runtime/web/src/controller/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ export class RadiantController {
});
}

addRectangle(position: number[], scale: number[]) {
this._controller.handleMessage({
AddRectangle: {
position,
scale,
},
});
}

setTransform(nodeId: number, position: number[], scale: number[]) {
this._controller.handleMessage({
SceneMessage: {
Expand Down

0 comments on commit 9db3528

Please sign in to comment.