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.tsx19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx
index ed219652a..3b2c2e270 100644
--- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx
+++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx
@@ -65,13 +65,12 @@ interface IState {
kineticFriction: boolean,
maxPosYConservation: number,
timer: number,
- update: boolean,
- updatedStartPosX: number,
- updatedStartPosY: number,
+ updatedStartPosX: any,
+ updatedStartPosY: any,
walls: IWallProps[],
- xPosition: number,
+ xPosition: any,
xVelocity: number,
- yPosition: number,
+ yPosition: any,
yVelocity: number,
xAccel: number,
yAccel: number,
@@ -584,7 +583,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
if (this.state.xVelocity != 0) {
this.state.walls.forEach((wall) => {
if (wall.angleInDegrees == 90) {
- const wallX = (wall.xPos / 100) * this.props.layoutDoc._width ?? 500;
+ const wallX = (wall.xPos / 100) * this.props.layoutDoc._width;
if (wall.xPos < 0.35) {
if (minX <= wallX) {
this.setState({xPosition: wallX+0.01});
@@ -620,7 +619,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
if (this.state.yVelocity > 0) {
this.state.walls.forEach((wall) => {
if (wall.angleInDegrees == 0 && wall.yPos > 0.4) {
- const groundY = (wall.yPos / 100) * this.props.layoutDoc._height ?? 500;
+ const groundY = (wall.yPos / 100) * this.props.layoutDoc._height;
if (maxY > groundY) {
this.setState({yPosition: groundY- 2 * this.props.radius-0.01});
if (this.props.elasticCollisions) {
@@ -666,7 +665,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
if (this.state.yVelocity < 0) {
this.state.walls.forEach((wall) => {
if (wall.angleInDegrees == 0 && wall.yPos < 0.4) {
- const groundY = (wall.yPos / 100) * this.props.layoutDoc._height ?? 500;
+ const groundY = (wall.yPos / 100) * this.props.layoutDoc._height;
if (minY < groundY) {
this.setState({yPosition: groundY + 0.01});
if (this.props.elasticCollisions) {
@@ -1281,7 +1280,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
position: "absolute",
zIndex: 500,
left: Math.round(this.props.xMax * 0.5 - 200 + this.props.wedgeWidth - 80) + "px",
- top: Math.round(this.props.layoutDoc._height * 0.8 - 40) + "px",
+ top: Math.round(this.yMax - 40) + "px",
}}
>
{Math.round(
@@ -1518,7 +1517,7 @@ export default class Weight extends React.Component<IWeightProps, IState> {
);
})}
{!this.state.dragging &&
- this.props.showForces &&
+ this.props.showForces && this.props.updatedForces &&
this.props.updatedForces.map((force, index) => {
if (force.magnitude < this.epsilon) {
return;