diff options
author | brynnchernosky <56202540+brynnchernosky@users.noreply.github.com> | 2023-05-02 18:02:04 -0400 |
---|---|---|
committer | brynnchernosky <56202540+brynnchernosky@users.noreply.github.com> | 2023-05-02 18:02:04 -0400 |
commit | 232773a787fc619c9b23a6bd96da492837fea743 (patch) | |
tree | a7baa0d0bab452ab9c3fb784f84b9d1f69e44321 /src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx | |
parent | e5439cac0d08f37b2a1ab4927d1739c171d771ff (diff) |
debugging
Diffstat (limited to 'src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx')
-rw-r--r-- | src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx index 38af55635..368f35f3c 100644 --- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx +++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationWeight.tsx @@ -179,6 +179,7 @@ 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); @@ -196,6 +197,7 @@ 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); @@ -230,6 +232,7 @@ 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(); @@ -237,6 +240,7 @@ export default class Weight extends React.Component<IWeightProps, IState> { // 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) { @@ -251,6 +255,7 @@ export default class Weight extends React.Component<IWeightProps, IState> { // Check for collisions and update if (prevState.timer != this.state.timer) { + console.log('update') if (!this.props.paused && !this.props.noMovement) { let collisions = false; if ( @@ -275,11 +280,13 @@ export default class Weight extends React.Component<IWeightProps, IState> { // Reset everything on reset button click if (prevProps.reset != this.props.reset) { + console.log('reset') this.resetEverything(); } // Convert from static to kinetic friction if/when weight slips on inclined plane if (prevState.xVelocity != this.state.xVelocity) { + console.log('friction') if ( this.props.dataDoc['simulationType'] == "Inclined Plane" && Math.abs(this.state.xVelocity) > 0.1 && @@ -396,6 +403,7 @@ export default class Weight extends React.Component<IWeightProps, IState> { // Add/remove walls when simulation type changes if (prevProps.simulationType != this.props.simulationType) { + console.log('walls') let w: IWallProps[] = []; if (this.props.dataDoc['simulationType'] == "One Weight" || this.props.dataDoc['simulationType'] == "Inclined Plane") { w.push({ length: 70, xPos: 0, yPos: 0, angleInDegrees: 0 }); @@ -408,25 +416,27 @@ 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) { - console.log('update start x to ', this.props.startPosX) this.setState({xPosition: this.props.startPosX}) this.setState({updatedStartPosX: this.props.startPosX}) this.setXPosDisplay(this.props.startPosX) } } - // // Update y position when start pos y changes TODO debug - // if (prevProps.startPosY != this.props.startPosY) { - // if (this.props.paused) { - // this.setState({yPosition: this.props.startPosY}) - // this.setState({updatedStartPosY: this.props.startPosY}) - // this.setYPosDisplay(this.props.startPosY) - // } - // } + // 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) + } + } // Update wedge coordinates if (prevProps.wedgeWidth != this.props.wedgeWidth || prevProps.wedgeHeight != this.props.wedgeHeight) { + console.log('wedge') const left = this.props.xMax * 0.5 - 200; const coordinatePair1 = Math.round(left) + "," + this.props.yMax + " "; const coordinatePair2 = Math.round(left + this.props.wedgeWidth) + "," + this.props.yMax + " "; @@ -436,6 +446,7 @@ export default class Weight extends React.Component<IWeightProps, IState> { } if (this.state.xPosition != prevState.xPosition || this.state.yPosition != prevState.yPosition) { + console.log('style') this.weightStyle = { alignItems: "center", backgroundColor: this.props.color, |