diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/util/CurrentUserUtils.ts | 2 | ||||
-rw-r--r-- | src/client/views/nodes/PhysicsSimulationApp.tsx | 19 | ||||
-rw-r--r-- | src/client/views/nodes/PhysicsSimulationWedge.tsx | 1 | ||||
-rw-r--r-- | src/client/views/nodes/PhysicsSimulationWeight.tsx | 19 |
4 files changed, 15 insertions, 26 deletions
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index 23e9a2bea..c8b36ff3a 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -287,7 +287,7 @@ export class CurrentUserUtils { { toolTip: "Tap or drag to create a note board", title: "Notes", icon: "folder", dragFactory: doc.emptyNoteboard as Doc, }, { toolTip: "Tap or drag to create a collection", title: "Col", icon: "folder", dragFactory: doc.emptyCollection as Doc, clickFactory: DocCast(doc.emptyTab), scripts: { onClick: 'openOnRight(copyDragFactory(this.clickFactory))', onDragStart: '{ return copyDragFactory(this.dragFactory);}'}, }, { toolTip: "Tap or drag to create an equation", title: "Math", icon: "calculator", dragFactory: doc.emptyEquation as Doc, }, - { toolTip: "Tap or drag to create a physics simulation", title: "Simulation", icon: "calculator", dragFactory: doc.emptySimulation as Doc, }, + { toolTip: "Tap or drag to create a physics simulation", title: "Simulation", icon: "atom", dragFactory: doc.emptySimulation as Doc, }, { toolTip: "Tap or drag to create a webpage", title: "Web", icon: "globe-asia", dragFactory: doc.emptyWebpage as Doc, }, { toolTip: "Tap or drag to create a comparison box", title: "Compare", icon: "columns", dragFactory: doc.emptyComparison as Doc, }, { toolTip: "Tap or drag to create an audio recorder", title: "Audio", icon: "microphone", dragFactory: doc.emptyAudio as Doc, scripts: { onClick: 'openInOverlay(copyDragFactory(this.dragFactory))', onDragStart: '{ return copyDragFactory(this.dragFactory);}'}, }, diff --git a/src/client/views/nodes/PhysicsSimulationApp.tsx b/src/client/views/nodes/PhysicsSimulationApp.tsx index f31d92db2..6a3ab28a0 100644 --- a/src/client/views/nodes/PhysicsSimulationApp.tsx +++ b/src/client/views/nodes/PhysicsSimulationApp.tsx @@ -146,16 +146,15 @@ export default class App extends React.Component<{}, IState> { this.setState({weight: true}) this.setState({wedge: false}) this.setState({pendulum: true}) - let length = 300; - let angle = 50; + let length = this.xMax*0.7; + let angle = 40; let x = length * Math.cos(((90 - angle) * Math.PI) / 180); let y = length * Math.sin(((90 - angle) * Math.PI) / 180); - let xPos = this.xMax / 2 - x - 50; - let yPos = y - 50 - 5; - this.addPendulum(); + let xPos = this.xMax / 2 - x - this.radius; + let yPos = y - this.radius; this.setState({startPosX: xPos}) this.setState({startPosY: yPos}) - let mag = 9.81 * Math.cos((50 * Math.PI) / 180); + let mag = 9.81 * Math.cos((angle * Math.PI) / 180); let forceOfTension: IForce = { description: "Tension", magnitude: mag, @@ -163,9 +162,9 @@ export default class App extends React.Component<{}, IState> { }; this.setState({updatedForces: [this.forceOfGravity, forceOfTension]}) this.setState({startForces: [this.forceOfGravity, forceOfTension]}) - this.setState({pendulumAngle: 50}) - this.setState({pendulumLength: 300}) - this.setState({adjustPendulumAngle: {angle: 50, length: 300}}) + this.setState({pendulumAngle: 40}) + this.setState({pendulumLength: 100}) + this.setState({adjustPendulumAngle: {angle: 40, length: 100}}) this.removeWalls(); }; @@ -289,7 +288,7 @@ export default class App extends React.Component<{}, IState> { componentDidMount() { // Add weight - this.addWedge() + this.addPendulum() // Add listener for SHIFT key, which determines if sketch force arrow will be edited or deleted on click document.addEventListener("keydown", (e) => { diff --git a/src/client/views/nodes/PhysicsSimulationWedge.tsx b/src/client/views/nodes/PhysicsSimulationWedge.tsx index 43a4d69de..c5a186f18 100644 --- a/src/client/views/nodes/PhysicsSimulationWedge.tsx +++ b/src/client/views/nodes/PhysicsSimulationWedge.tsx @@ -42,7 +42,6 @@ export default class Wedge extends React.Component<IWedgeProps, IState> { Math.round(this.props.yMax - this.props.startHeight); const coord = coordinatePair1 + coordinatePair2 + coordinatePair3; this.setState({coordinates: coord}); - console.log("coordinates: ", coord) } componentDidMount() { diff --git a/src/client/views/nodes/PhysicsSimulationWeight.tsx b/src/client/views/nodes/PhysicsSimulationWeight.tsx index 63f8c965f..dfd463bbe 100644 --- a/src/client/views/nodes/PhysicsSimulationWeight.tsx +++ b/src/client/views/nodes/PhysicsSimulationWeight.tsx @@ -1,6 +1,5 @@ import React = require('react'); import { IWallProps } from "./PhysicsSimulationWall"; -import Wedge from "./PhysicsSimulationWedge"; export interface IForce { description: string; @@ -107,6 +106,7 @@ export default class Weight extends React.Component<IWeightProps, IState> { top: this.props.startPosY + "px", width: 2 * this.props.radius + "px", height: 2 * this.props.radius + "px", + zIndex: 5, borderRadius: 50 + "%", display: "flex", justifyContent: "center", @@ -215,6 +215,7 @@ export default class Weight extends React.Component<IWeightProps, IState> { height: 2 * this.props.radius + "px", borderRadius: 50 + "%", display: "flex", + zIndex: 5, justifyContent: "center", alignItems: "center", touchAction: "none", @@ -397,7 +398,6 @@ export default class Weight extends React.Component<IWeightProps, IState> { this.setState({xPosition: wallX+5}); } collision = true; - console.log('collision with wall') } } else { if (maxX >= wallX) { @@ -408,7 +408,6 @@ export default class Weight extends React.Component<IWeightProps, IState> { this.setState({xPosition: wallX - 2 * this.props.radius + 5}); } collision = true; - console.log('collision with wall') } } } @@ -425,7 +424,6 @@ export default class Weight extends React.Component<IWeightProps, IState> { if (wall.angleInDegrees == 0) { const groundY = (wall.yPos / 100) * this.props.yMax; if (maxY >= groundY) { - console.log('collision with ground ', wall, maxY) if (this.props.elasticCollisions) { this.setState({yVelocity: -this.state.yVelocity}) } else { @@ -521,7 +519,7 @@ export default class Weight extends React.Component<IWeightProps, IState> { render () { return ( - <div style={{ zIndex: -1000 }}> + <div> <div className="weightContainer" onPointerDown={(e) => { @@ -617,7 +615,6 @@ export default class Weight extends React.Component<IWeightProps, IState> { position: "absolute", left: 0, top: 0, - zIndex: -2, }} > <svg width={this.props.xMax + "px"} height={300 + "px"}> @@ -632,7 +629,7 @@ export default class Weight extends React.Component<IWeightProps, IState> { </svg> {!this.state.dragging && ( <div> - <p + {/* <p style={{ position: "absolute", zIndex: 5, @@ -642,11 +639,10 @@ export default class Weight extends React.Component<IWeightProps, IState> { }} > {Math.round(this.props.pendulumLength)} m - </p> + </p> */} <p style={{ position: "absolute", - zIndex: -1, left: this.props.xMax / 2 + "px", top: 30 + "px", backgroundColor: this.labelBackgroundColor, @@ -664,7 +660,6 @@ export default class Weight extends React.Component<IWeightProps, IState> { style={{ pointerEvents: "none", position: "absolute", - zIndex: -1, left: 0, top: 0, }} @@ -709,7 +704,6 @@ export default class Weight extends React.Component<IWeightProps, IState> { this.getNewAccelerationY(this.props.updatedForces) * 5 + 25 + "px", - zIndex: -1, lineHeight: 0.5, }} > @@ -733,7 +727,6 @@ export default class Weight extends React.Component<IWeightProps, IState> { style={{ pointerEvents: "none", position: "absolute", - zIndex: -1, left: 0, top: 0, }} @@ -768,7 +761,6 @@ export default class Weight extends React.Component<IWeightProps, IState> { position: "absolute", left: this.state.xPosition + this.props.radius + this.state.xVelocity * 3 + 25 + "px", top: this.state.yPosition + this.props.radius + this.state.yVelocity * 3 + "px", - zIndex: -1, lineHeight: 0.5, }} > @@ -826,7 +818,6 @@ export default class Weight extends React.Component<IWeightProps, IState> { style={{ pointerEvents: "none", position: "absolute", - zIndex: -1, left: this.props.xMin, top: this.props.yMin, }} |