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.tsx58
1 files changed, 19 insertions, 39 deletions
diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx
index 368f35f3c..f78f14704 100644
--- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx
+++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx
@@ -179,7 +179,6 @@ export default class Weight extends React.Component<IWeightProps, IState> {
componentDidUpdate(prevProps: Readonly<IWeightProps>, prevState: Readonly<IState>, snapshot?: any): void {
// Change pendulum angle from input field
if (prevProps.adjustPendulumAngle != this.props.adjustPendulumAngle) {
- console.log('pendulum angle')
let length = this.props.adjustPendulumAngle.length;
const x =
length * Math.cos(((90 - this.props.adjustPendulumAngle.angle) * Math.PI) / 180);
@@ -197,7 +196,6 @@ export default class Weight extends React.Component<IWeightProps, IState> {
// When display values updated by user, update real values
if (prevProps.updateDisplay != this.props.updateDisplay) {
- console.log('update display')
if (this.props.updateDisplay.xDisplay != this.state.xPosition) {
let x = this.props.updateDisplay.xDisplay;
x = Math.max(0, x);
@@ -232,26 +230,25 @@ export default class Weight extends React.Component<IWeightProps, IState> {
// Prevent bug when switching between sims
if (prevProps.startForces != this.props.startForces) {
- console.log('switch sims')
this.setState({xVelocity: this.props.startVelX})
this.setState({yVelocity: this.props.startVelY})
this.setDisplayValues();
}
- // Make sure weight doesn't go above max height
- if (prevState.updatedStartPosY != this.state.updatedStartPosY || prevProps.startVelY != this.props.startVelY) {
- console.log('max height check')
- if (this.props.dataDoc['simulationType'] == "One Weight") {
- let maxYPos = this.state.updatedStartPosY;
- if (this.props.startVelY != 0) {
- maxYPos -= (this.props.startVelY * this.props.startVelY) / (2 * Math.abs(this.props.gravity));
- }
- if (maxYPos < 0) {
- maxYPos = 0;
- }
- this.setState({maxPosYConservation: maxYPos})
- }
- }
+ // // Make sure weight doesn't go above max height
+ // if (prevState.updatedStartPosY != this.state.updatedStartPosY || prevProps.startVelY != this.props.startVelY) {
+ // console.log('max height check')
+ // if (this.props.dataDoc['simulationType'] == "One Weight") {
+ // let maxYPos = this.state.updatedStartPosY;
+ // if (this.props.startVelY != 0) {
+ // maxYPos -= (this.props.startVelY * this.props.startVelY) / (2 * Math.abs(this.props.gravity));
+ // }
+ // if (maxYPos < 0) {
+ // maxYPos = 0;
+ // }
+ // this.setState({maxPosYConservation: maxYPos})
+ // }
+ // }
// Check for collisions and update
if (prevState.timer != this.state.timer) {
@@ -416,8 +413,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
// Update x position when start pos x changes
if (prevProps.startPosX != this.props.startPosX) {
- console.log('xpos')
- if (this.props.paused) {
+ if (this.props.paused && !isNaN(this.props.startPosX)) {
this.setState({xPosition: this.props.startPosX})
this.setState({updatedStartPosX: this.props.startPosX})
this.setXPosDisplay(this.props.startPosX)
@@ -426,11 +422,10 @@ export default class Weight extends React.Component<IWeightProps, IState> {
// Update y position when start pos y changes TODO debug
if (prevProps.startPosY != this.props.startPosY) {
- console.log('ypos')
- if (this.props.paused) {
- // this.setState({yPosition: this.props.startPosY})
- this.setState({updatedStartPosY: this.props.startPosY})
- this.setYPosDisplay(this.props.startPosY)
+ if (this.props.paused && !isNaN(this.props.startPosY)) {
+ this.setState({yPosition: this.props.startPosY})
+ this.setState({updatedStartPosY: this.props.startPosY ?? 0})
+ this.setYPosDisplay(this.props.startPosY ?? 0)
}
}
@@ -1110,7 +1105,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={this.props.layoutDoc._height + "px"}>
@@ -1133,7 +1127,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={this.props.layoutDoc._height + "px"}>
@@ -1149,7 +1142,6 @@ export default class Weight extends React.Component<IWeightProps, IState> {
<p
style={{
position: "absolute",
- zIndex: 10,
left: (this.props.xMax + this.props.xMin) / 2 - this.props.radius - this.props.yMin - 200 + 80 + "px",
top: 10 + "px",
backgroundColor: this.labelBackgroundColor,
@@ -1178,7 +1170,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={this.props.layoutDoc._height + "px"}>
@@ -1195,7 +1186,6 @@ export default class Weight extends React.Component<IWeightProps, IState> {
<p
style={{
position: "absolute",
- zIndex: 10,
left: (this.props.xMax + this.props.xMin) / 2 + this.props.yMin + 200 + this.props.radius - 80 + "px",
top: 10 + "px",
backgroundColor: this.labelBackgroundColor,
@@ -1226,7 +1216,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={this.props.layoutDoc._height + "px"}>
@@ -1249,7 +1238,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={this.props.layoutDoc._height + "px"}>
@@ -1278,7 +1266,6 @@ export default class Weight extends React.Component<IWeightProps, IState> {
<p
style={{
position: "absolute",
- zIndex: -1,
left: this.props.xMax / 2 + "px",
top: 30 + "px",
backgroundColor: this.labelBackgroundColor,
@@ -1320,7 +1307,6 @@ export default class Weight extends React.Component<IWeightProps, IState> {
style={{
pointerEvents: "none",
position: "absolute",
- zIndex: -1,
left: 0,
top: 0,
}}
@@ -1355,7 +1341,6 @@ export default class Weight extends React.Component<IWeightProps, IState> {
position: "absolute",
left: this.state.xPosition + this.props.radius + this.state.xAccel * 3 + 25 + "px",
top: this.state.yPosition + this.props.radius + this.state.yAccel * 3 + 70 + "px",
- zIndex: -1,
lineHeight: 0.5,
}}
>
@@ -1376,7 +1361,6 @@ export default class Weight extends React.Component<IWeightProps, IState> {
style={{
pointerEvents: "none",
position: "absolute",
- zIndex: -1,
left: 0,
top: 0,
}}
@@ -1411,7 +1395,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,
}}
>
@@ -1473,7 +1456,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,
}}
@@ -1526,7 +1508,6 @@ export default class Weight extends React.Component<IWeightProps, IState> {
position: "absolute",
left: labelLeft + "px",
top: labelTop + "px",
- // zIndex: -1,
lineHeight: 0.5,
backgroundColor: this.labelBackgroundColor,
}}
@@ -1584,7 +1565,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,
}}