Skip to content

Commit

Permalink
reduce the number of typescript errors
Browse files Browse the repository at this point in the history
  • Loading branch information
TheHappyKoala committed Oct 31, 2020
1 parent 5e2ca56 commit 4729e51
Show file tree
Hide file tree
Showing 37 changed files with 149 additions and 228 deletions.
5 changes: 1 addition & 4 deletions src/components/Content/Physics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface PhysicsProps {
modifyScenarioProperty: typeof modifyScenarioProperty;
masses: MassType[];
integrator: string;
useBarnesHut?: boolean;
useBarnesHut: boolean;
systemBarycenter: boolean;
collisions: boolean;
dt: number;
Expand Down Expand Up @@ -73,7 +73,6 @@ export default ({
dropdownWrapperCssClassName="tabs-dropdown-wrapper"
selectedOptionCssClassName="selected-option"
optionsWrapperCssClass="options"
dynamicChildrenLen={masses.length}
>
{masses.map(mass => (
<div
Expand Down Expand Up @@ -102,7 +101,6 @@ export default ({
dropdownWrapperCssClassName="tabs-dropdown-wrapper"
selectedOptionCssClassName="selected-option"
optionsWrapperCssClass="options"
dynamicChildrenLen={masses.length}
>
{masses.map(mass => (
<div
Expand Down Expand Up @@ -133,7 +131,6 @@ export default ({
selectedOptionCssClassName="selected-option"
dropdownWrapperCssClassName="tabs-dropdown-wrapper"
optionsWrapperCssClass="options"
dynamicChildrenLen={integrators.length}
>
{integrators.map(integrator => (
<div
Expand Down
4 changes: 2 additions & 2 deletions src/components/Head/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface HeadProps {
pageDescription: string;
pathName: string;
bodyCssClass?: string;
pageType: string;
pageType?: string;
image?: string;
fileName?: string;
}
Expand Down Expand Up @@ -76,7 +76,7 @@ export default ({
description: pageDescription,
about: {
"@type": "Thing",
description: "gravity, simulation, space"
description: "gravity, simulation, space"
},
creator: {
"@type": "Person",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import "./Header.less";
interface HeaderProps {
pageTitle: string;
pageDescription: string;
pageType: string;
pageType?: string;
image?: string;
location: any;
}
Expand Down
36 changes: 0 additions & 36 deletions src/components/LazyDog/LazyDog.less

This file was deleted.

38 changes: 0 additions & 38 deletions src/components/LazyDog/index.tsx

This file was deleted.

11 changes: 3 additions & 8 deletions src/components/Modal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import React, {
ReactElement,
MouseEvent,
ReactChildren,
ReactChild
} from "react";
import React, { ReactElement, MouseEvent, ReactNode } from "react";
import "./Modal.less";

interface ModalProps {
children: ReactChildren | ReactChild;
children: ReactNode;
callback: (event: MouseEvent<HTMLButtonElement>) => void;
modalWrapperCssClass: string;
modalCssClass: string;
modalCssClass?: string;
}

export default ({
Expand Down
15 changes: 3 additions & 12 deletions src/components/Pagination/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@ interface PaginationProps {
};
}

export default ({
itemsPerPage,
pagination
}: PaginationProps): ReactElement => {
const renderRange = (
range: { start: number; end: number },
itemsPerPage: number
) => {
export default ({ pagination }: PaginationProps): ReactElement => {
const renderRange = (range: { start: number; end: number }) => {
const items = [
<Link to={pagination.path}>
<NavItem key="pagination-first-page">First Page</NavItem>
Expand All @@ -49,10 +43,7 @@ export default ({

return (
<Nav css={{ border: "none", borderBottom: "1px solid #545454" }}>
{renderRange(
getPaginationRange(pagination.page, pagination.count),
itemsPerPage
)}
{renderRange(getPaginationRange(pagination.page, pagination.count))}
</Nav>
);
};
5 changes: 1 addition & 4 deletions src/components/Renderer/ForAllMankindRenderer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { memo, ReactElement, useEffect, Fragment, useRef } from "react";
import forAllMankindScene from "../../scene/forAllMankindScene";
import "./Renderer.less";
import { resetScenario } from "../../state/creators/scenario";

interface RendererProps {
scenarioName: string;
Expand All @@ -11,20 +10,18 @@ export default memo(
({ scenarioName }: RendererProps): ReactElement => {
const graphics2DCanvas = useRef(null);
const webGlCanvas = useRef(null);
const audio = useRef(null);

useEffect(() => {
scenarioName &&
forAllMankindScene
.reset()
.init(webGlCanvas.current, graphics2DCanvas.current, audio.current);
.init(webGlCanvas.current, graphics2DCanvas.current);
});

return (
<Fragment>
<canvas ref={webGlCanvas} />
<canvas ref={graphics2DCanvas} className="graphics-2d-canvas" />
<audio ref={audio} style={{ display: "none" }} />
</Fragment>
);
},
Expand Down
7 changes: 1 addition & 6 deletions src/components/Renderer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { memo, ReactElement, useEffect, Fragment, useRef } from "react";
import scene from "../../scene";
import "./Renderer.less";
import { resetScenario } from "../../state/creators/scenario";

interface RendererProps {
scenarioName: string;
Expand All @@ -11,20 +10,16 @@ export default memo(
({ scenarioName }: RendererProps): ReactElement => {
const graphics2DCanvas = useRef(null);
const webGlCanvas = useRef(null);
const audio = useRef(null);

useEffect(() => {
scenarioName &&
scene
.reset()
.init(webGlCanvas.current, graphics2DCanvas.current, audio.current);
scene.reset().init(webGlCanvas.current, graphics2DCanvas.current);
});

return (
<Fragment>
<canvas ref={webGlCanvas} />
<canvas ref={graphics2DCanvas} className="graphics-2d-canvas" />
<audio ref={audio} style={{ display: "none" }} />
</Fragment>
);
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/Simulator/Simulator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ export default ({
}}
className="iframe-scroll-wrapper"
/>
) : (
) : scenarioWikiUrl ? (
<Iframe url={scenarioWikiUrl} />
)}
) : null}
</Modal>
)}
</ReactCSSTransitionGroup>
Expand Down
5 changes: 0 additions & 5 deletions src/components/Simulator/StarshipSimulator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ import "./StarshipSimulator.less";
interface SimulatorProps {
scenario: ScenarioState;
modifyScenarioProperty: typeof scenarioActionCreators.modifyScenarioProperty;
modifyMassProperty: typeof scenarioActionCreators.modifyMassProperty;
deleteMass: typeof scenarioActionCreators.deleteMass;
addMass: typeof scenarioActionCreators.addMass;
resetScenario: typeof scenarioActionCreators.resetScenario;
getTrajectory: typeof scenarioActionCreators.getTrajectory;
app: any;
}

export default ({
Expand Down
22 changes: 12 additions & 10 deletions src/components/Spaceship/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ export default ({
39.5 * spacecraft.currentSOI.m
);

orbitalElements.a = orbitalElements.a.toFixed(5);
orbitalElements.e = orbitalElements.e.toFixed(5);
orbitalElements.i = orbitalElements.i.toFixed(5);
orbitalElements.argP = orbitalElements.argP.toFixed(5);
orbitalElements.lAn = orbitalElements.lAn.toFixed(5);
orbitalElements.a = parseFloat(orbitalElements.a.toFixed(5));
orbitalElements.e = parseFloat(orbitalElements.e.toFixed(5));
orbitalElements.i = parseFloat(orbitalElements.i.toFixed(5));
orbitalElements.argP = parseFloat(orbitalElements.argP.toFixed(5));
orbitalElements.lAn = parseFloat(orbitalElements.lAn.toFixed(5));

const { name } = currentSOI;

Expand All @@ -110,11 +110,13 @@ export default ({
orbitalElements,
currentSOI,
targetSOI: radiusSOI(scenario.masses[1], target),
velocity: getVelocityMagnitude({
x: spacecraftMass.vx,
y: spacecraftMass.vy,
z: spacecraftMass.vz
}).toFixed(5)
velocity: parseFloat(
getVelocityMagnitude({
x: spacecraftMass.vx,
y: spacecraftMass.vy,
z: spacecraftMass.vz
}).toFixed(5)
)
});

modifyScenarioProperty({
Expand Down
22 changes: 12 additions & 10 deletions src/components/spaceship/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ export default ({
39.5 * spacecraft.currentSOI.m
);

orbitalElements.a = orbitalElements.a.toFixed(5);
orbitalElements.e = orbitalElements.e.toFixed(5);
orbitalElements.i = orbitalElements.i.toFixed(5);
orbitalElements.argP = orbitalElements.argP.toFixed(5);
orbitalElements.lAn = orbitalElements.lAn.toFixed(5);
orbitalElements.a = parseFloat(orbitalElements.a.toFixed(5));
orbitalElements.e = parseFloat(orbitalElements.e.toFixed(5));
orbitalElements.i = parseFloat(orbitalElements.i.toFixed(5));
orbitalElements.argP = parseFloat(orbitalElements.argP.toFixed(5));
orbitalElements.lAn = parseFloat(orbitalElements.lAn.toFixed(5));

const { name } = currentSOI;

Expand All @@ -110,11 +110,13 @@ export default ({
orbitalElements,
currentSOI,
targetSOI: radiusSOI(scenario.masses[1], target),
velocity: getVelocityMagnitude({
x: spacecraftMass.vx,
y: spacecraftMass.vy,
z: spacecraftMass.vz
}).toFixed(5)
velocity: parseFloat(
getVelocityMagnitude({
x: spacecraftMass.vx,
y: spacecraftMass.vy,
z: spacecraftMass.vz
}).toFixed(5)
)
});

modifyScenarioProperty({
Expand Down
2 changes: 1 addition & 1 deletion src/data/scenarios/boris.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type": "Solar System",
"particlesFun": false,
"g": 39.5,
"dt": 0.001,
"dt": 0.001,
"distMax": 50,
"distMin": -50,
"rotatingReferenceFrame": "Sun",
Expand Down
2 changes: 1 addition & 1 deletion src/data/scenarios/jovanSystem.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"sortOrder": 4,
"description": "Gravity simulation of Jupiter and its Galilean moons - the four largest moons of Jupiter — Io, Europa, Ganymede, and Callisto - and the Juno spacecraft.",
"type": "Solar System",
"particlesFun": false,
"particlesFun": false,
"g": 39.5,
"dt": 0.000006,
"soi": "Earth",
Expand Down
2 changes: 1 addition & 1 deletion src/data/scenarios/martianSystem.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"sortOrder": 12,
"description": "Gravity simulation of Mars and its two Moons Phobos and Deimos. They are irregular in shape and much smaller than Earth's Moon",
"particlesFun": false,
"type": "Solar System",
"type": "Solar System",
"g": 39.5,
"dt": 9e-7,
"distMax": 50,
Expand Down
2 changes: 1 addition & 1 deletion src/data/scenarios/oumuamua.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "Solar System",
"particlesFun": false,
"g": 39.5,
"dt": 0.001,
"dt": 0.001,
"distMax": 50,
"distMin": -50,
"rotatingReferenceFrame": "Sun",
Expand Down
Loading

0 comments on commit 4729e51

Please sign in to comment.