aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx')
-rw-r--r--src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx59
1 files changed, 39 insertions, 20 deletions
diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx
index 4e7d0e7e6..3ab78e339 100644
--- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx
+++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx
@@ -151,16 +151,29 @@ export default class Weight extends React.Component<IWeightProps, IState> {
// Set display values based on real values
setYPosDisplay = (yPos: number) => {
const displayPos = this.getDisplayYPos(yPos);
- this.props.dataDoc['positionYDisplay'] = Math.round(displayPos * 100) / 100
+ if (this.props.color == 'red') {
+ this.props.dataDoc['positionYDisplay'] = Math.round(displayPos * 100) / 100
+ } else {
+ this.props.dataDoc['positionYDisplay2'] = Math.round(displayPos * 100) / 100
+ }
};
setXPosDisplay = (xPos: number) => {
- this.props.dataDoc['positionXDisplay'] = Math.round(xPos * 100) / 100;
+ if (this.props.color == 'red') {
+ this.props.dataDoc['positionXDisplay'] = Math.round(xPos * 100) / 100;
+ } else {
+ this.props.dataDoc['positionXDisplay2'] = Math.round(xPos * 100) / 100;}
};
setYVelDisplay = (yVel: number) => {
- this.props.dataDoc['velocityYDisplay'] = (-1 * Math.round(yVel * 100)) / 100;
+ if (this.props.color == 'red') {
+ this.props.dataDoc['velocityYDisplay'] = (-1 * Math.round(yVel * 100)) / 100;
+ } else {
+ this.props.dataDoc['velocityYDisplay2'] = (-1 * Math.round(yVel * 100)) / 100;}
};
setXVelDisplay = (xVel: number) => {
- this.props.dataDoc['velocityXDisplay'] = Math.round(xVel * 100) / 100;
+ if (this.props.color == 'red') {
+ this.props.dataDoc['velocityXDisplay'] = Math.round(xVel * 100) / 100;
+ } else {
+ this.props.dataDoc['velocityXDisplay2'] = Math.round(xVel * 100) / 100;}
};
// Update display values when simulation updates
@@ -213,7 +226,11 @@ export default class Weight extends React.Component<IWeightProps, IState> {
x = Math.min(x, this.props.xMax - 2 * this.props.radius);
this.setState({updatedStartPosX: x})
this.setState({xPosition: x})
+ if (this.props.color == 'red') {
this.props.dataDoc['positionXDisplay'] = x
+ } else {
+ this.props.dataDoc['positionXDisplay2'] = x
+ }
}
if (this.props.updateDisplay.yDisplay != this.getDisplayYPos(this.state.yPosition)) {
@@ -223,19 +240,31 @@ export default class Weight extends React.Component<IWeightProps, IState> {
let coordinatePosition = this.getYPosFromDisplay(y);
this.setState({updatedStartPosY: coordinatePosition})
this.setState({yPosition: coordinatePosition})
+ if (this.props.color == 'red') {
this.props.dataDoc['positionYDisplay'] = y
+ } else {
+ this.props.dataDoc['positionYDisplay2'] = y
+ }
}
if (this.props.displayXVelocity != this.state.xVelocity) {
let x = this.props.displayXVelocity;
this.setState({xVelocity: x})
- this.props.dataDoc['velocityXDisplay'] = x
+ if (this.props.color == 'red') {
+ this.props.dataDoc['velocityXDisplay'] = x
+ } else {
+ this.props.dataDoc['velocityXDisplay2'] = x
+ }
}
if (this.props.displayYVelocity != -this.state.yVelocity) {
let y = this.props.displayYVelocity;
this.setState({yVelocity: -y})
- this.props.dataDoc['velocityYDisplay'] = y
+ if (this.props.color == 'red') {
+ this.props.dataDoc['velocityYDisplay'] = y
+ } else {
+ this.props.dataDoc['velocityYDisplay2'] = y
+ }
}
}
@@ -474,18 +503,20 @@ export default class Weight extends React.Component<IWeightProps, IState> {
this.props.dataDoc['pendulumAngle'] = this.props.dataDoc['startPendulumAngle']
this.props.dataDoc['updatedForces'] = (this.props.dataDoc['startForces'])
this.props.dataDoc['updatedForces2'] = (this.props.dataDoc['startForces2'])
- this.props.dataDoc['accelerationXDisplay'] = 0
- this.props.dataDoc['accelerationYDisplay'] = 0
if (this.props.color == 'red') {
this.props.dataDoc['positionXDisplay'] = this.state.updatedStartPosX
this.props.dataDoc['positionYDisplay'] = this.state.updatedStartPosY
this.props.dataDoc['velocityXDisplay'] = this.props.startVelX ?? 0
this.props.dataDoc['velocityYDisplay'] = this.props.startVelY ?? 0
+ this.props.dataDoc['accelerationXDisplay'] = 0
+ this.props.dataDoc['accelerationYDisplay'] = 0
} else {
this.props.dataDoc['positionXDisplay2'] = this.state.updatedStartPosX
this.props.dataDoc['positionYDisplay2'] = this.state.updatedStartPosY
this.props.dataDoc['velocityXDisplay2'] = this.props.startVelX ?? 0
this.props.dataDoc['velocityYDisplay2'] = this.props.startVelY ?? 0
+ this.props.dataDoc['accelerationXDisplay2'] = 0
+ this.props.dataDoc['accelerationYDisplay2'] = 0
}
this.setState({angleLabel: Math.round(this.props.dataDoc['pendulumAngle'] ?? 0 * 100) / 100})
};
@@ -1174,18 +1205,6 @@ export default class Weight extends React.Component<IWeightProps, IState> {
) / 100}
°
</p>
- </div>
- )}
- {this.props.dataDoc['simulationType'] == "Suspension" && (
- <div
- className="rod"
- style={{
- pointerEvents: "none",
- position: "absolute",
- left: 0,
- top: 0,
- }}
- >
<svg width={this.props.xMax + "px"} height={this.props.layoutDoc._height + "px"}>
<line
x1={this.state.xPosition + this.props.radius}