diff options
-rw-r--r-- | src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx index 785e40057..27f57070e 100644 --- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx +++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx @@ -178,8 +178,13 @@ export default class Weight extends React.Component<IWeightProps, IState> { (-1 * Math.round(this.getNewAccelerationY(this.props.updatedForces) * 100)) / 100 ; this.props.dataDoc['accelerationXDisplay'] = - Math.round(this.getNewAccelerationX(this.props.dataDoc.updatedForces) * 100) / 100 + Math.round(this.getNewAccelerationX(this.props.updatedForces) * 100) / 100 ; + + this.setState({xAccel : (Math.round(this.getNewAccelerationX(this.props.updatedForces) * 100) / 100)}) + this.setState({yAccel : + (-1 * Math.round(this.getNewAccelerationY(this.props.updatedForces) * 100)) / 100 + }); }; componentDidUpdate(prevProps: Readonly<IWeightProps>, prevState: Readonly<IState>, snapshot?: any): void { @@ -471,10 +476,17 @@ export default class Weight extends React.Component<IWeightProps, IState> { this.props.dataDoc['updatedForces2'] = (this.props.dataDoc['startForces2']) this.props.dataDoc['accelerationXDisplay'] = 0 this.props.dataDoc['accelerationYDisplay'] = 0 - 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 + 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 + } 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.setState({angleLabel: Math.round(this.props.dataDoc['pendulumAngle'] ?? 0 * 100) / 100}) }; |