Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
madil4 committed Nov 10, 2023
1 parent 0a1c71e commit 402bb0d
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 39 deletions.
20 changes: 11 additions & 9 deletions package-lock.json

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

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,26 @@
"homepage": "https://awatif.co",
"devDependencies": {
"@storybook/html-vite": "^7.1.1",
"@tweakpane/core": "^1.1.9",
"@tweakpane/core": "^2.0.1",
"@types/jest": "^29.5.3",
"@types/three": "^0.154.0",
"autoprefixer": "^10.4.14",
"chromatic": "^6.20.0",
"daisyui": "^3.5.0",
"jest": "^29.6.2",
"postcss": "^8.4.27",
"storybook": "^7.1.1",
"tailwindcss": "^3.3.3",
"ts-jest": "^29.1.1",
"vite": "^4.4.7",
"vite-plugin-solid": "^2.7.0",
"jest": "^29.6.2",
"ts-jest": "^29.1.1"
"vite-plugin-solid": "^2.7.0"
},
"dependencies": {
"@supabase/supabase-js": "^2.31.0",
"mathjs": "^11.9.1",
"monaco-editor": "^0.40.0",
"solid-js": "^1.7.8",
"three": "^0.155.0",
"tweakpane": "^3.1.10"
"tweakpane": "^4.0.1"
}
}
4 changes: 3 additions & 1 deletion src/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,9 @@ export const analysisResults = analyzing(nodes, elements, assignments);`;

<Parameters
parameters={parameters()}
onChange={(e) => solveModel({ key: e.presetKey || "", value: e.value })}
onChange={(e) =>
solveModel({ key: (e.target as any).tag, value: e.value })
}
/>
</Layouter>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ export default {
step: 5,
label: "another height",
},
toggle: {
value: true,
},
}}
/>
),
Expand Down
16 changes: 8 additions & 8 deletions src/Parameters/Parameters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import { createEffect } from "solid-js";
import { Pane, TpChangeEvent } from "tweakpane";

type Parameter = {
value: unknown;
value: number;
min?: number;
max?: number;
step?: number;
label?: string;
};
export type ParametersType = Record<string, Parameter>;

export type SettingsProps = {
export type ParametersProps = {
parameters: ParametersType;
onChange?: (ev: TpChangeEvent<unknown>) => void;
onChange?: (e: TpChangeEvent<unknown>) => void;
};

export function Parameters(props: SettingsProps) {
export function Parameters(props: ParametersProps) {
let pane = new Pane({ title: "Parameters" });
let inputs: any[] = [];

Expand All @@ -27,19 +27,19 @@ export function Parameters(props: SettingsProps) {
Object.keys(props.parameters).forEach((key) => {
const parameter = props.parameters[key];
inputs.push(
pane.addInput(parameter, "value", {
pane.addBinding(parameter, "value", {
min: parameter.min,
max: parameter.max,
step: parameter.step,
label: parameter.label || key,
presetKey: key,
tag: key,
})
);
});
});

pane.on("change", (ev) => {
if (props.onChange) props.onChange(ev);
pane.on("change", (e) => {
if (props.onChange) props.onChange(e);
});

return <div class="absolute bottom-0 right-5 w-[19rem]">{pane.element}</div>;
Expand Down
26 changes: 13 additions & 13 deletions src/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,30 @@ export type SettingsProps = {
export function Settings(props: SettingsProps) {
let pane = new Pane({ title: "Settings", expanded: false });

pane.addInput(props.settings, "gridSize", { label: "grid size", min: 1 });
pane.addInput(props.settings, "displayScale", {
pane.addBinding(props.settings, "gridSize", { label: "grid size", min: 1 });
pane.addBinding(props.settings, "displayScale", {
label: "display scale",
min: -10,
max: 10,
step: 1,
});
pane.addInput(props.settings, "nodes");
pane.addInput(props.settings, "elements");
pane.addInput(props.settings, "nodesIndices", { label: "nodes indices" });
pane.addInput(props.settings, "elementsIndices", {
pane.addBinding(props.settings, "nodes");
pane.addBinding(props.settings, "elements");
pane.addBinding(props.settings, "nodesIndices", { label: "nodes indices" });
pane.addBinding(props.settings, "elementsIndices", {
label: "elements indices",
});
pane.addInput(props.settings, "supports");
pane.addInput(props.settings, "loads");
pane.addInput(props.settings, "deformedShape", { label: "deformed shape" });
pane.addInput(props.settings, "elementResults", {
pane.addBinding(props.settings, "supports");
pane.addBinding(props.settings, "loads");
pane.addBinding(props.settings, "deformedShape", { label: "deformed shape" });
pane.addBinding(props.settings, "elementResults", {
options: {
none: "none",
normal: "normal",
},
label: "element results",
});
pane.addInput(props.settings, "nodeResults", {
pane.addBinding(props.settings, "nodeResults", {
options: {
none: "none",
deformation: "deformation",
Expand All @@ -56,8 +56,8 @@ export function Settings(props: SettingsProps) {
label: "node results",
});

pane.on("change", (ev) => {
if (props.onChange) props.onChange(ev);
pane.on("change", (e) => {
if (props.onChange) props.onChange(e);
});

createEffect(() => {
Expand Down

0 comments on commit 402bb0d

Please sign in to comment.