diff options
-rw-r--r-- | src/client/views/nodes/PhysicsSimulationBox.tsx | 112 |
1 files changed, 53 insertions, 59 deletions
diff --git a/src/client/views/nodes/PhysicsSimulationBox.tsx b/src/client/views/nodes/PhysicsSimulationBox.tsx index f9baac431..a78d899e0 100644 --- a/src/client/views/nodes/PhysicsSimulationBox.tsx +++ b/src/client/views/nodes/PhysicsSimulationBox.tsx @@ -54,44 +54,32 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi constructor(props: any) { super(props); - this.dataDoc.accelerationXDisplay = 0; - this.dataDoc.accelerationYDisplay = 0; - this.dataDoc.adjustPendulumAngle = true; - this.dataDoc.coefficientOfKineticFriction = 0; - this.dataDoc.coefficientOfStaticFriction = 0; - this.dataDoc.currentForceSketch = []; - this.dataDoc.deleteMode = false; - this.dataDoc.updateDisplay = false; - this.dataDoc.elasticCollisions = false; - this.dataDoc.forceSketches = []; - this.dataDoc.pendulum = false; - this.dataDoc.pendulumAngle = 0; - this.dataDoc.pendulumLength = 300; - this.dataDoc.positionXDisplay = 0; - this.dataDoc.positionYDisplay = 0; - this.dataDoc.showAcceleration = false; - this.dataDoc.showForceMagnitudes = false; - this.dataDoc.showForces = false; - this.dataDoc.showVelocity = false; - this.dataDoc.simulationPaused = true; - this.dataDoc.simulationReset = false; - this.dataDoc.simulationType = "Inclined Plane"; - this.dataDoc.sketching = false; - this.dataDoc.startForces = [this.forceOfGravity]; - this.dataDoc.startPendulumAngle = 0; - this.dataDoc.startPosX = 0; - this.dataDoc.startPosY = 0; - this.dataDoc.stepNumber = 0; - this.dataDoc.timer = 0; - this.dataDoc.updatedForces = [this.forceOfGravity]; - this.dataDoc.velocityXDisplay = 0; - this.dataDoc.velocityYDisplay = 0; - this.dataDoc.wallPositions = []; - this.dataDoc.wedge = false; - this.dataDoc.wedgeAngle = 26; - this.dataDoc.wedgeHeight = Math.tan((26 * Math.PI) / 180) * this.xMax*0.6; - this.dataDoc.wedgeWidth = this.xMax*0.6; - this.dataDoc.weight = false; + // this.dataDoc.coefficientOfKineticFriction = 0; + // this.dataDoc.coefficientOfStaticFriction = 0; + // this.dataDoc.currentForceSketch = []; + // this.dataDoc.updateDisplay = false; + // this.dataDoc.elasticCollisions = false; + // this.dataDoc.forceSketches = []; + // this.dataDoc.pendulumAngle = 0; + // this.dataDoc.pendulumLength = 300; + // this.dataDoc.positionXDisplay = 0; + // this.dataDoc.positionYDisplay = 0; + // this.dataDoc.showAcceleration = false; + // this.dataDoc.showForceMagnitudes = false; + // this.dataDoc.showForces = false; + // this.dataDoc.showVelocity = false; + // this.dataDoc.startForces = [this.forceOfGravity]; + // this.dataDoc.startPendulumAngle = 0; + // this.dataDoc.startPosX = 0; + // this.dataDoc.startPosY = 0; + // this.dataDoc.stepNumber = 0; + // this.dataDoc.updatedForces = [this.forceOfGravity]; + // this.dataDoc.velocityXDisplay = 0; + // this.dataDoc.velocityYDisplay = 0; + // this.dataDoc.wallPositions = []; + // this.dataDoc.wedgeAngle = 26; + // this.dataDoc.wedgeHeight = Math.tan((26 * Math.PI) / 180) * this.xMax*0.6; + // this.dataDoc.wedgeWidth = this.xMax*0.6; } // Add one weight to the simulation @@ -267,13 +255,11 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi // Add floor and walls to simulation addWalls = () => { - if (this.dataDoc.wallPositions.length == 0) { - let walls = []; - walls.push({ length: 100, xPos: 0, yPos: 97, angleInDegrees: 0 }); - walls.push({ length: 100, xPos: 0, yPos: 0, angleInDegrees: 90 }); - walls.push({ length: 100, xPos: 97, yPos: 0, angleInDegrees: 90 }); - this.dataDoc.wallPositions = walls - } + let walls = []; + walls.push({ length: 100, xPos: 0, yPos: 97, angleInDegrees: 0 }); + walls.push({ length: 100, xPos: 0, yPos: 0, angleInDegrees: 90 }); + walls.push({ length: 100, xPos: 97, yPos: 0, angleInDegrees: 90 }); + this.dataDoc.wallPositions = walls }; @@ -289,7 +275,8 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi } else if (this.dataDoc.simulationType == "Pendulum") { console.log('add pendulum on mount') this.addPendulum() - } else if (this.dataDoc.simulationType == "Free Weight") { + } else { + this.dataDoc.simulationType = "Free Weight" console.log('add weight on mount') this.addWeight() } @@ -306,7 +293,12 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi } }); - this.dataDoc['simulationPaused'] = true; + this.dataDoc.simulationPaused = true; + this.dataDoc.simulationReset = false; + this.dataDoc.accelerationXDisplay = 0; + this.dataDoc.accelerationYDisplay = 0; + this.dataDoc.adjustPendulumAngle = true; + this.dataDoc.timer = 0; } render () { @@ -340,18 +332,20 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi )} </div> <div> - {this.dataDoc.wallPositions.map((element: { length: number; xPos: number; yPos: number; angleInDegrees: number; }, index: React.Key | null | undefined) => { - return ( - <div key={index}> - <Wall - length={element.length} - xPos={element.xPos} - yPos={element.yPos} - angleInDegrees={element.angleInDegrees} - /> - </div> - ); - })} + {/* {this.dataDoc.wallPositions && ( + {this.dataDoc.wallPositions.map((element: { length: number; xPos: number; yPos: number; angleInDegrees: number; }, index: React.Key | null | undefined) => { + return ( + <div key={index}> + <Wall + length={element.length} + xPos={element.xPos} + yPos={element.yPos} + angleInDegrees={element.angleInDegrees} + /> + </div> + ); + })} + )} */} </div> </div> </div> |