From 5fe0c8a79590792fd351831fe1af237c987346bf Mon Sep 17 00:00:00 2001 From: Max Richter Date: Thu, 2 May 2024 03:37:30 +0200 Subject: [PATCH] feat: add rotate node --- Cargo.lock | 15 ++++ app/src/lib/helpers/index.ts | 28 +++++++ app/src/lib/node-store/DraggableNode.svelte | 8 +- app/src/lib/node-store/NodeStore.svelte | 4 +- .../lib/settings/panels/BenchmarkPanel.svelte | 84 +++++++++++++------ app/src/routes/+page.svelte | 4 +- nodes/max/plantarium/noise/src/lib.rs | 2 +- nodes/max/plantarium/rotate/.gitignore | 6 ++ nodes/max/plantarium/rotate/Cargo.toml | 29 +++++++ nodes/max/plantarium/rotate/package.json | 6 ++ nodes/max/plantarium/rotate/src/input.json | 36 ++++++++ nodes/max/plantarium/rotate/src/lib.rs | 72 ++++++++++++++++ nodes/max/plantarium/rotate/tests/web.rs | 13 +++ packages/ui/src/lib/Input.svelte | 15 ++++ packages/ui/src/lib/elements/Float.svelte | 4 +- packages/ui/src/lib/elements/Integer.svelte | 2 +- packages/ui/src/lib/elements/Select.svelte | 2 +- packages/ui/src/lib/elements/Vec3.svelte | 2 +- 18 files changed, 294 insertions(+), 38 deletions(-) create mode 100644 nodes/max/plantarium/rotate/.gitignore create mode 100644 nodes/max/plantarium/rotate/Cargo.toml create mode 100644 nodes/max/plantarium/rotate/package.json create mode 100644 nodes/max/plantarium/rotate/src/input.json create mode 100644 nodes/max/plantarium/rotate/src/lib.rs create mode 100644 nodes/max/plantarium/rotate/tests/web.rs diff --git a/Cargo.lock b/Cargo.lock index cc03481..73dcffe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -280,6 +280,21 @@ dependencies = [ "wasm-bindgen-test", ] +[[package]] +name = "rotate" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "glam", + "macros", + "serde", + "serde-wasm-bindgen", + "utils", + "wasm-bindgen", + "wasm-bindgen-test", + "web-sys", +] + [[package]] name = "ryu" version = "1.0.17" diff --git a/app/src/lib/helpers/index.ts b/app/src/lib/helpers/index.ts index 887d751..974ab54 100644 --- a/app/src/lib/helpers/index.ts +++ b/app/src/lib/helpers/index.ts @@ -127,3 +127,31 @@ export function humanizeNumber(number: number): string { return rounded + suffixes[baseIndex]; } +export function humanizeDuration(durationInMilliseconds: number) { + const millisecondsPerSecond = 1000; + const millisecondsPerMinute = 60000; + const millisecondsPerHour = 3600000; + const millisecondsPerDay = 86400000; + + let days = Math.floor(durationInMilliseconds / millisecondsPerDay); + let hours = Math.floor((durationInMilliseconds % millisecondsPerDay) / millisecondsPerHour); + let minutes = Math.floor((durationInMilliseconds % millisecondsPerHour) / millisecondsPerMinute); + let seconds = Math.floor((durationInMilliseconds % millisecondsPerMinute) / millisecondsPerSecond); + + let durationString = ''; + + if (days > 0) { + durationString += days + 'd '; + } + if (hours > 0) { + durationString += hours + 'h '; + } + if (minutes > 0) { + durationString += minutes + 'm '; + } + if (seconds > 0 || durationString === '') { + durationString += seconds + 's'; + } + + return durationString.trim(); +} diff --git a/app/src/lib/node-store/DraggableNode.svelte b/app/src/lib/node-store/DraggableNode.svelte index 3815c76..804f7d0 100644 --- a/app/src/lib/node-store/DraggableNode.svelte +++ b/app/src/lib/node-store/DraggableNode.svelte @@ -1,14 +1,16 @@ {#if input.type === 'float'} diff --git a/packages/ui/src/lib/elements/Float.svelte b/packages/ui/src/lib/elements/Float.svelte index b3dd594..628ddca 100644 --- a/packages/ui/src/lib/elements/Float.svelte +++ b/packages/ui/src/lib/elements/Float.svelte @@ -1,7 +1,7 @@ diff --git a/packages/ui/src/lib/elements/Vec3.svelte b/packages/ui/src/lib/elements/Vec3.svelte index a0bba47..b01c884 100644 --- a/packages/ui/src/lib/elements/Vec3.svelte +++ b/packages/ui/src/lib/elements/Vec3.svelte @@ -1,7 +1,7 @@