Skip to content

Commit 1bf36ef

Browse files
committed
fix: Apply 5-point punch list for electric field physics, classroom WS, panel init, eslint ignores, and unit tests
1 parent e574fd1 commit 1bf36ef

7 files changed

Lines changed: 49 additions & 2 deletions

File tree

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default [
2222
"models/**",
2323
"scratch/**",
2424
"test_api.mjs",
25+
"dist/**",
2526
],
2627
},
2728
js.configs.recommended,

package-lock.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@eslint/js": "^9.22.0",
3030
"eslint": "^9.22.0",
3131
"globals": "^16.0.0",
32+
"three": "^0.164.1",
3233
"vite": "^8.2.1"
3334
}
3435
}

server/services/classroomServer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function initClassroomWebSocketServer(server) {
2525

2626
wss.on("connection", (ws) => {
2727
let currentRoomId = null;
28-
let userId = `user_${Math.random().toString(36).substring(2, 9)}`;
28+
const userId = `user_${Math.random().toString(36).substring(2, 9)}`;
2929
let userName = "Learner";
3030

3131
ws.on("message", (rawMessage) => {

src/render/electricFieldManager.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ export class ElectricFieldManager {
3939
this.fluxLines = null;
4040
this.particles = null;
4141
this.particleStates = [];
42+
this.coulombLines = null;
43+
this.velocities = new Map();
44+
this.simulationRunning = false;
4245
}
4346

4447
collectPhysicsObjects() {

src/ui/classroomPanel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export function initClassroomUI(appContext) {
66
classroomClient = new ClassroomClient(appContext);
77

88
const topbarTools = document.querySelector(".topbar-tools");
9-
if (!topbarTools) return;
9+
if (!topbarTools) return classroomClient;
1010

1111
const classroomCluster = document.createElement("div");
1212
classroomCluster.className = "tool-cluster classroom-cluster";
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { test } from "node:test";
2+
import assert from "node:assert/strict";
3+
import * as THREE from "three";
4+
import { ElectricFieldManager } from "../src/render/electricFieldManager.js";
5+
6+
test("simulateCoulombMotion does not throw once simulation is running", () => {
7+
const fakeSceneApi = {
8+
snapshot: () => ({ objects: [] }),
9+
updateObjectPosition: () => {},
10+
};
11+
const fakeWorld = { scene: { add: () => {} } };
12+
const manager = new ElectricFieldManager(fakeWorld, fakeSceneApi);
13+
14+
manager.setSimulationPlay(true);
15+
16+
const charges = [
17+
{
18+
id: "charge_a",
19+
position: new THREE.Vector3(-1, 1, 0),
20+
charge: 1,
21+
strength: 1,
22+
radius: 0.35,
23+
},
24+
{
25+
id: "charge_b",
26+
position: new THREE.Vector3(1, 1, 0),
27+
charge: -1,
28+
strength: 1,
29+
radius: 0.35,
30+
},
31+
];
32+
33+
assert.doesNotThrow(() => manager.simulateCoulombMotion(0.016, charges));
34+
});

0 commit comments

Comments
 (0)