Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from maartin0/spirograph-fix
Browse files Browse the repository at this point in the history
Spirograph fix
  • Loading branch information
maartin0 committed Sep 13, 2023
2 parents 82ccd60 + 7ee5882 commit 4e47076
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.17.1
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.17.1
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Submission for the BPhO 2023 Computational Physics Challenge<br>
A solar system viewer written in [three.js](https://github.com/mrdoob/three.js/)

Functions can be found in [src/entities/algorithms.ts](src/entities/algorithms.ts)

## Planets
Currently, the following planets are simulated:
* The Sun
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AlgorithmProps, PhysicalBody, Timestamp } from '../../types';
import { AlgorithmProps, PhysicalBody, Timestamp } from '../types';
import { Vector3 } from 'three';

const mul = Math.PI / 180;
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/entities/bodies.ts → src/entities/bodies.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PhysicalBody, PhysicalBodyType } from '../../types';
import { PhysicalBody, PhysicalBodyType } from '../types';

export const SUN: PhysicalBody = {
id: 10,
Expand Down
7 changes: 5 additions & 2 deletions src/renderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import {
} from 'three';
import { loopState } from './loop';
import { LabelProps } from '../widgets/Label';
import bodies from './entities/bodies';
import algorithms from './entities/algorithms';
import bodies from '../entities/bodies';
import algorithms from '../entities/algorithms';

export const SPEED_OPTIONS = [
{
Expand Down Expand Up @@ -66,6 +66,7 @@ export const controls: {
selectedAlgorithms: AlgorithmProps[],
spirograph: {
options: SpirographOption[],
update: SpirographOption[],
},
labels: boolean,
} = {
Expand All @@ -81,6 +82,7 @@ export const controls: {
selectedAlgorithms: Object.values(algorithms).filter(a => a.defaultSelected),
spirograph: {
options: [],
update: [],
},
labels: true,
}
Expand Down Expand Up @@ -115,6 +117,7 @@ export function update() {
o.lines.forEach(l => l.removeFromParent())
o.lines = [];
});
controls.spirograph.options = controls.spirograph.update;
loopState.speed = SPEED_OPTIONS[controls.speedIndex].value;
nodes.forEach((node: PhysicalBodyNode) => {
node.mesh.removeFromParent();
Expand Down
6 changes: 3 additions & 3 deletions src/widgets/Controller.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react';
import { useMemo, useSyncExternalStore } from 'react';
import SelectorWidget from './SelectorWidget';
import bodies, { SUN } from '../renderer/entities/bodies';
import algorithms from '../renderer/entities/algorithms';
import bodies, { SUN } from '../entities/bodies';
import algorithms from '../entities/algorithms';
import { AlgorithmProps, PhysicalBody, PhysicalBodyNode, Selectable, SpirographOption } from '../types';
import { controls, nodes, scheduleUpdate, SPEED_OPTIONS, updateSubscribe } from '../renderer';
import FpsWidget from './FpsWidget';
Expand Down Expand Up @@ -129,7 +129,7 @@ export default ({ show }: Props) => {
lastPlot: loopState.lastTick,
});
}))} setter={(selected: Selectable[]) => {
controls.spirograph.options = selected as SpirographOption[];
controls.spirograph.update = selected as SpirographOption[];
}}/>
</div>
<div>
Expand Down

0 comments on commit 4e47076

Please sign in to comment.