aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrynnchernosky <56202540+brynnchernosky@users.noreply.github.com>2023-01-26 22:43:53 -0500
committerbrynnchernosky <56202540+brynnchernosky@users.noreply.github.com>2023-01-26 22:43:53 -0500
commitd2b8f997f1786c813ef5a58acef69501e1c523a3 (patch)
tree1328a1c5e140749ef8bdc8bfe8093c57400a15ac /src
parenta555303c34ec2ac79084100bdf21f9d88dba86b1 (diff)
start adding logic
Diffstat (limited to 'src')
-rw-r--r--src/client/util/CurrentUserUtils.ts2
-rw-r--r--src/client/views/nodes/PhysicsSimulationBox.scss3
-rw-r--r--src/client/views/nodes/PhysicsSimulationBox.tsx73
3 files changed, 76 insertions, 2 deletions
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index f0397b0c6..23e9a2bea 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -260,7 +260,7 @@ export class CurrentUserUtils {
{key: "Noteboard", creator: opts => Docs.Create.NoteTakingDocument([], opts), opts: { _width: 250, _height: 200 }},
{key: "Collection", creator: opts => Docs.Create.FreeformDocument([], opts), opts: { _width: 150, _height: 100 }},
{key: "Equation", creator: opts => Docs.Create.EquationDocument(opts), opts: { _width: 300, _height: 35, _backgroundGridShow: true, }},
- {key: "Simulation", creator: opts => Docs.Create.SimulationDocument(opts), opts: { _width: 300, _height: 35, _backgroundGridShow: true, }},
+ {key: "Simulation", creator: opts => Docs.Create.SimulationDocument(opts), opts: { _width: 300, _height: 300, _backgroundGridShow: true, }},
{key: "Webpage", creator: opts => Docs.Create.WebDocument("",opts), opts: { _width: 400, _height: 512, _nativeWidth: 850, useCors: true, }},
{key: "Comparison", creator: Docs.Create.ComparisonDocument, opts: { _width: 300, _height: 300 }},
{key: "Audio", creator: opts => Docs.Create.AudioDocument(nullAudio, opts),opts: { _width: 200, _height: 100, }},
diff --git a/src/client/views/nodes/PhysicsSimulationBox.scss b/src/client/views/nodes/PhysicsSimulationBox.scss
index e69de29bb..2eb6e6ff0 100644
--- a/src/client/views/nodes/PhysicsSimulationBox.scss
+++ b/src/client/views/nodes/PhysicsSimulationBox.scss
@@ -0,0 +1,3 @@
+.physicsSimulationContainer {
+
+} \ No newline at end of file
diff --git a/src/client/views/nodes/PhysicsSimulationBox.tsx b/src/client/views/nodes/PhysicsSimulationBox.tsx
index 568a5b40c..b16bccdde 100644
--- a/src/client/views/nodes/PhysicsSimulationBox.tsx
+++ b/src/client/views/nodes/PhysicsSimulationBox.tsx
@@ -3,9 +3,80 @@ import { FieldView, FieldViewProps } from './FieldView';
import React = require('react');
import { ViewBoxAnnotatableComponent } from '../DocComponent';
import { observer } from 'mobx-react';
+
+export interface IForce {
+ description: string;
+ magnitude: number;
+ directionInDegrees: number;
+}
+export interface IWallProps {
+ length: number;
+ xPos: number;
+ yPos: number;
+ angleInDegrees: number;
+}
@observer
export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
+
+ forceOfGravity: IForce = {
+ description: "Gravity",
+ magnitude: 9.81,
+ directionInDegrees: 270,
+};
+
+ // Logic for Dash integration
public static LayoutString(fieldKey: string) { return FieldView.LayoutString(PhysicsSimulationBox, fieldKey); }
- render () { return (<p>Hello world!</p>)}
+ constructor(props: any) {
+ super(props);
+ this.state = {
+ timer: 0,
+ weight: true,
+ pendulum: false,
+ wedge: false,
+ startPosX: 0,
+ startPosY: 0,
+ showVelocity: false,
+ showAcceleration: false,
+ showForces: false,
+ elasticCollisions: false,
+ updatedForces: [this.forceOfGravity],
+ wallPositions: []
+ }
+ }
+
+ // Add one weight to the simulation
+ addWeight = () => {
+ this.setState({weight: true});
+ this.setState({wedge: false});
+ this.setState({pendulum: false});
+ };
+
+// Remove floor and walls from simulation
+removeWalls = () => {
+ this.setState({wallPositions: []});
+};
+
+// Add floor and walls to simulation
+addWalls = () => {
+ const walls: IWallProps[] = [];
+ walls.push({ length: 70, xPos: 0, yPos: 80, angleInDegrees: 0 });
+ walls.push({ length: 80, xPos: 0, yPos: 0, angleInDegrees: 90 });
+ walls.push({ length: 80, xPos: 69.5, yPos: 0, angleInDegrees: 90 });
+ this.setState({wallPositions: walls});
+};
+
+ // Timer for animating the simulation
+ // setInterval(() => {
+ // const time = this.timer ?? 0
+ // this.setState({timer: time+1});
+ // }, 60);
+
+ render () {
+ return (
+ <div className = "physicsSimulationContainer">
+
+ </div>
+ );
+ }
} \ No newline at end of file