feat: added default project
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 1m48s
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 1m48s
This commit is contained in:
parent
c1e6d141bf
commit
66ae9e6c72
@ -1,2 +1,3 @@
|
|||||||
export { grid } from "./grid";
|
export { grid } from "./grid";
|
||||||
export { tree } from "./tree";
|
export { tree } from "./tree";
|
||||||
|
export { plant } from "./plant";
|
||||||
|
12
app/src/lib/graph-templates/plant.ts
Normal file
12
app/src/lib/graph-templates/plant.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
export const plant = {
|
||||||
|
"settings": { "resolution.circle": 26, "resolution.curve": 39 },
|
||||||
|
"nodes": [
|
||||||
|
{ "id": 9, "position": [180, 80], "type": "max/plantarium/output", "props": {} },
|
||||||
|
{ "id": 10, "position": [55, 80], "type": "max/plantarium/stem", "props": { "amount": 1, "length": 11, "thickness": 0.71 } },
|
||||||
|
{ "id": 11, "position": [80, 80], "type": "max/plantarium/noise", "props": { "strength": 35, "scale": 4.6, "fixBottom": 1, "directionalStrength": [1, 0.74, 0.083], "depth": 1 } },
|
||||||
|
{ "id": 12, "position": [105, 80], "type": "max/plantarium/branch", "props": { "length": 3, "thickness": 0.6, "amount": 10, "rotation": 180, "offsetSingle": 0.34, "lowestBranch": 0.53, "highestBranch": 1, "depth": 1 } },
|
||||||
|
{ "id": 13, "position": [130, 80], "type": "max/plantarium/noise", "props": { "strength": 8, "scale": 7.7, "fixBottom": 1, "directionalStrength": [1, 0, 1], "depth": 1 } },
|
||||||
|
{ "id": 14, "position": [155, 80], "type": "max/plantarium/gravity", "props": { "strength": 0.11, "scale": 39, "fixBottom": 0, "directionalStrength": [1, 1, 1], "depth": 1, "curviness": 1 } }
|
||||||
|
],
|
||||||
|
"edges": [[10, 0, 11, "plant"], [11, 0, 12, "plant"], [12, 0, 13, "plant"], [13, 0, 14, "plant"], [14, 0, 9, "input"]]
|
||||||
|
}
|
76
app/src/lib/result-viewer/Camera.svelte
Normal file
76
app/src/lib/result-viewer/Camera.svelte
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import localStore from "$lib/helpers/localStore";
|
||||||
|
import { T, useTask } from "@threlte/core";
|
||||||
|
import { OrbitControls } from "@threlte/extras";
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import { Vector3 } from "three";
|
||||||
|
import type { PerspectiveCamera, Vector3Tuple } from "three";
|
||||||
|
import type { OrbitControls as OrbitControlsType } from "three/examples/jsm/controls/OrbitControls.js";
|
||||||
|
|
||||||
|
let camera: PerspectiveCamera;
|
||||||
|
let controls: OrbitControlsType;
|
||||||
|
|
||||||
|
export let center: Vector3;
|
||||||
|
export let centerCamera: boolean = true;
|
||||||
|
|
||||||
|
const cameraTransform = localStore<{
|
||||||
|
camera: Vector3Tuple;
|
||||||
|
target: Vector3Tuple;
|
||||||
|
}>("nodes.camera.transform", {
|
||||||
|
camera: [0, 0, 10],
|
||||||
|
target: [0, 0, 0],
|
||||||
|
});
|
||||||
|
|
||||||
|
function saveCameraState() {
|
||||||
|
if (!camera) return;
|
||||||
|
let cPos = camera.position.toArray();
|
||||||
|
let tPos = controls.target.toArray();
|
||||||
|
// check if tPos is NaN or tPos is NaN
|
||||||
|
if (tPos.some((v) => isNaN(v)) || cPos.some((v) => isNaN(v))) return;
|
||||||
|
$cameraTransform = {
|
||||||
|
camera: cPos,
|
||||||
|
target: tPos,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let isRunning = false;
|
||||||
|
const task = useTask(() => {
|
||||||
|
let length = center.clone().sub(controls.target).length();
|
||||||
|
if (length < 0.01) {
|
||||||
|
isRunning = false;
|
||||||
|
task.stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
controls.target.lerp(center, 0.02);
|
||||||
|
controls.update();
|
||||||
|
});
|
||||||
|
task.stop();
|
||||||
|
|
||||||
|
$: if (
|
||||||
|
center &&
|
||||||
|
controls &&
|
||||||
|
centerCamera &&
|
||||||
|
(center.x !== controls.target.x ||
|
||||||
|
center.y !== controls.target.y ||
|
||||||
|
center.z !== controls.target.z) &&
|
||||||
|
!isRunning
|
||||||
|
) {
|
||||||
|
isRunning = true;
|
||||||
|
task.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
controls.target.fromArray($cameraTransform.target);
|
||||||
|
controls.update();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<T.PerspectiveCamera
|
||||||
|
bind:ref={camera}
|
||||||
|
position={$cameraTransform.camera}
|
||||||
|
makeDefault
|
||||||
|
fov={50}
|
||||||
|
>
|
||||||
|
<OrbitControls bind:ref={controls} on:change={saveCameraState} />
|
||||||
|
</T.PerspectiveCamera>
|
@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { T, useTask } from "@threlte/core";
|
import { T } from "@threlte/core";
|
||||||
import {
|
import {
|
||||||
MeshLineGeometry,
|
MeshLineGeometry,
|
||||||
MeshLineMaterial,
|
MeshLineMaterial,
|
||||||
@ -9,42 +9,22 @@
|
|||||||
import {
|
import {
|
||||||
type Group,
|
type Group,
|
||||||
type BufferGeometry,
|
type BufferGeometry,
|
||||||
type PerspectiveCamera,
|
|
||||||
Vector3,
|
Vector3,
|
||||||
type Vector3Tuple,
|
type Vector3Tuple,
|
||||||
Box3,
|
Box3,
|
||||||
} from "three";
|
} from "three";
|
||||||
import type { OrbitControls as OrbitControlsType } from "three/addons/controls/OrbitControls.js";
|
|
||||||
import { OrbitControls } from "@threlte/extras";
|
|
||||||
import { AppSettings } from "../settings/app-settings";
|
import { AppSettings } from "../settings/app-settings";
|
||||||
import localStore from "$lib/helpers/localStore";
|
import Camera from "./Camera.svelte";
|
||||||
|
|
||||||
export let geometries: BufferGeometry[];
|
export let geometries: BufferGeometry[];
|
||||||
export let lines: Vector3[][];
|
export let lines: Vector3[][];
|
||||||
let geos: Group;
|
let geos: Group;
|
||||||
|
|
||||||
let camera: PerspectiveCamera;
|
|
||||||
let controls: OrbitControlsType;
|
|
||||||
export let centerCamera: boolean = true;
|
export let centerCamera: boolean = true;
|
||||||
|
let center = new Vector3(0, 4, 0);
|
||||||
|
|
||||||
const matcap = useTexture("/matcap_green.jpg");
|
const matcap = useTexture("/matcap_green.jpg");
|
||||||
|
|
||||||
const cameraTransform = localStore<{
|
|
||||||
camera: Vector3Tuple;
|
|
||||||
target: Vector3Tuple;
|
|
||||||
}>("nodes.camera.transform", {
|
|
||||||
camera: [0, 0, 10],
|
|
||||||
target: [0, 0, 0],
|
|
||||||
});
|
|
||||||
|
|
||||||
function saveCameraState() {
|
|
||||||
if (!camera) return;
|
|
||||||
$cameraTransform = {
|
|
||||||
camera: camera.position.toArray(),
|
|
||||||
target: controls.target.toArray(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function getPosition(geo: BufferGeometry, i: number) {
|
function getPosition(geo: BufferGeometry, i: number) {
|
||||||
return [
|
return [
|
||||||
geo.attributes.position.array[i],
|
geo.attributes.position.array[i],
|
||||||
@ -53,62 +33,21 @@
|
|||||||
] as Vector3Tuple;
|
] as Vector3Tuple;
|
||||||
}
|
}
|
||||||
|
|
||||||
let cameraTarget: Vector3;
|
|
||||||
let duration = 0;
|
|
||||||
let totalDuration = 5;
|
|
||||||
const { start, stop, started } = useTask((delta) => {
|
|
||||||
duration += delta;
|
|
||||||
if (!cameraTarget) {
|
|
||||||
stop();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// This function will be executed on every frame
|
|
||||||
if (duration >= totalDuration) {
|
|
||||||
controls.target.copy(cameraTarget);
|
|
||||||
stop();
|
|
||||||
controls.update();
|
|
||||||
} else {
|
|
||||||
const t = duration / totalDuration;
|
|
||||||
controls.target.lerp(cameraTarget, t);
|
|
||||||
controls.update();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
stop();
|
|
||||||
|
|
||||||
$: if (geometries && geos && centerCamera) {
|
$: if (geometries && geos && centerCamera) {
|
||||||
const aabb = new Box3();
|
const aabb = new Box3().setFromObject(geos);
|
||||||
aabb.setFromObject(geos);
|
center = aabb
|
||||||
const newCenter = aabb.getCenter(new Vector3());
|
.getCenter(new Vector3())
|
||||||
if (
|
.max(new Vector3(-4, -4, -4))
|
||||||
newCenter &&
|
.min(new Vector3(4, 4, 4));
|
||||||
newCenter.x !== 0 &&
|
|
||||||
newCenter.y !== 0 &&
|
|
||||||
newCenter.z !== 0
|
|
||||||
) {
|
|
||||||
cameraTarget = newCenter;
|
|
||||||
duration = 0;
|
|
||||||
start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<Camera {center} {centerCamera} />
|
||||||
|
|
||||||
{#if $AppSettings.showGrid}
|
{#if $AppSettings.showGrid}
|
||||||
<T.GridHelper args={[20, 20]} />
|
<T.GridHelper args={[20, 20]} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<T.PerspectiveCamera
|
|
||||||
bind:ref={camera}
|
|
||||||
position={$cameraTransform.camera}
|
|
||||||
makeDefault
|
|
||||||
fov={50}
|
|
||||||
>
|
|
||||||
<OrbitControls
|
|
||||||
bind:ref={controls}
|
|
||||||
on:change={saveCameraState}
|
|
||||||
target={$cameraTransform.target}
|
|
||||||
/>
|
|
||||||
</T.PerspectiveCamera>
|
|
||||||
|
|
||||||
<T.DirectionalLight position={[0, 10, 10]} />
|
<T.DirectionalLight position={[0, 10, 10]} />
|
||||||
<T.AmbientLight intensity={2} />
|
<T.AmbientLight intensity={2} />
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
let graph = localStorage.getItem("graph")
|
let graph = localStorage.getItem("graph")
|
||||||
? JSON.parse(localStorage.getItem("graph")!)
|
? JSON.parse(localStorage.getItem("graph")!)
|
||||||
: templates.grid(3, 3);
|
: templates.plant;
|
||||||
|
|
||||||
let manager: GraphManager;
|
let manager: GraphManager;
|
||||||
let managerStatus: Writable<"loading" | "error" | "idle">;
|
let managerStatus: Writable<"loading" | "error" | "idle">;
|
||||||
|
@ -64,15 +64,15 @@
|
|||||||
inputEl.focus();
|
inputEl.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
// setTimeout(() => {
|
||||||
if (value >= 0) {
|
// if (value >= 0) {
|
||||||
max = getBoundingValue(value);
|
// max = getBoundingValue(value);
|
||||||
min = 0;
|
// min = 0;
|
||||||
} else {
|
// } else {
|
||||||
min = getBoundingValue(value);
|
// min = getBoundingValue(value);
|
||||||
max = 0;
|
// max = 0;
|
||||||
}
|
// }
|
||||||
}, 500);
|
// }, 500);
|
||||||
|
|
||||||
document.body.style.cursor = "unset";
|
document.body.style.cursor = "unset";
|
||||||
window.removeEventListener("mouseup", handleMouseUp);
|
window.removeEventListener("mouseup", handleMouseUp);
|
||||||
|
@ -1,47 +1,27 @@
|
|||||||
use crate::decode_float;
|
use crate::decode_float;
|
||||||
|
|
||||||
pub fn split_args(args: &[i32]) -> Vec<&[i32]> {
|
pub fn split_args(args: &[i32]) -> Vec<&[i32]> {
|
||||||
println!("-------------------");
|
|
||||||
println!("{:?}", args);
|
|
||||||
|
|
||||||
let mut out_args: Vec<&[i32]> = Vec::new();
|
let mut out_args: Vec<&[i32]> = Vec::new();
|
||||||
let mut depth = 0;
|
let mut depth = 0;
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
let mut start_index = 0;
|
let mut start_index = 0;
|
||||||
let mut nbi = 0;
|
let mut next_bracket_index = 0;
|
||||||
let len = args.len();
|
let len = args.len();
|
||||||
|
|
||||||
while i < len {
|
while i < len {
|
||||||
print!("{:2} ", i);
|
// check if we are at a bracket
|
||||||
let val = args[i];
|
if i == next_bracket_index {
|
||||||
let is_bracket = i == nbi;
|
next_bracket_index = i + args[i + 1] as usize + 1;
|
||||||
let is_opening_bracket = val == 0;
|
// check if the bracket is opening
|
||||||
if i >= len - 1 {
|
if args[i] == 0 {
|
||||||
break;
|
|
||||||
}
|
|
||||||
if is_bracket {
|
|
||||||
nbi = i + args[i + 1] as usize + 1;
|
|
||||||
if !is_opening_bracket {
|
|
||||||
depth -= 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _ in 0..depth {
|
|
||||||
print!("-");
|
|
||||||
}
|
|
||||||
|
|
||||||
if is_bracket {
|
|
||||||
if is_opening_bracket {
|
|
||||||
if depth == 1 {
|
if depth == 1 {
|
||||||
start_index = i;
|
start_index = i;
|
||||||
}
|
}
|
||||||
println!("[ {}", start_index);
|
|
||||||
depth += 1;
|
depth += 1;
|
||||||
} else {
|
} else {
|
||||||
println!("] {}", start_index);
|
depth -= 1;
|
||||||
if depth == 1 {
|
if depth == 1 {
|
||||||
out_args.push(&args[start_index..i + 2]);
|
out_args.push(&args[start_index..i + 2]);
|
||||||
println!("-> {:?}", &args[start_index..i + 2]);
|
|
||||||
start_index = i + 2;
|
start_index = i + 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -49,12 +29,8 @@ pub fn split_args(args: &[i32]) -> Vec<&[i32]> {
|
|||||||
continue;
|
continue;
|
||||||
} else if depth == 1 {
|
} else if depth == 1 {
|
||||||
out_args.push(&args[i..i + 1]);
|
out_args.push(&args[i..i + 1]);
|
||||||
println!("-> {:?}", &args[i..i + 1]);
|
|
||||||
start_index = i + 1;
|
start_index = i + 1;
|
||||||
} else {
|
|
||||||
println!("{}", val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user