Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plane implementation #1861

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/ThreeEditor/Simulation/Base/Plane.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Object3D } from 'three';

import { AdditionalGeometryDataType } from '../../../util/AdditionalGeometryData';
import { YaptideEditor } from '../../js/YaptideEditor';
import { SimulationElement, SimulationElementJSON } from './SimulationElement';
import { SimulationMesh } from './SimulationMesh';

export type SimulationPlaneJSON = Omit<
SimulationElementJSON & {
value?: number;
visible: boolean;
},
never
>;

export default class Plane extends SimulationElement {
value: number;
constructor(editor: YaptideEditor, value: number = 0) {
super(editor, 'XYP', 'integer');
this.value = value;
}
}

export const isPlane = (x: unknown): x is Plane => x instanceof Plane;
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Object3D } from 'three';

import { useSmartWatchEditorState } from '../../../../../util/hooks/signals';
import { YaptideEditor } from '../../../../js/YaptideEditor';
// import { isPlaneConfiguration } from
import Plane, { isPlane } from '../../../../Simulation/Base/Plane';
import { NumberPropertyField } from '../fields/PropertyField';
import { PropertiesCategory } from './PropertiesCategory';

export default function PlaneConfiguration(props: { editor: YaptideEditor; object: Plane }) {
const { object, editor } = props;
const { state: watchedObject } = useSmartWatchEditorState(
editor,
isPlane(object) ? object : null
);

const visibleFlag = isPlane(watchedObject);

function handleChanged(event) {
const num = event.target!.value;
}

return (
<PropertiesCategory
category='Plane value'
visible={visibleFlag}>
{watchedObject && (
<NumberPropertyField
label='Value'
value={object.value}
unit={editor.unit.name}
min={0}
onChange={v => {}}
/>
)}
</PropertiesCategory>
);
}
Loading