From 61a85912ee8ffe6957411a022c4ea0abeb18460f Mon Sep 17 00:00:00 2001 From: Joe Heffernan Date: Thu, 13 Jun 2024 14:03:00 -0700 Subject: [PATCH] convert vis-type to visType at parse time (#393) * convert vis-type to visType at parse time * remove todo comments * remove all references to vis-type and use visType * remove vis-type merge artifact --- src/constants.ts | 2 +- src/simularium/VisData.ts | 1 - src/simularium/types.ts | 5 ++--- src/test/VisData.test.ts | 20 ++++++++++---------- src/visGeometry/VisAgent.ts | 6 +++--- src/visGeometry/index.ts | 2 +- 6 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 42c7f026..7f53a886 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -36,7 +36,7 @@ export const DEFAULT_FRAME_RATE = 60; // frames per second export const nullAgent = (): AgentData => { return { - "vis-type": -1, + visType: -1, instanceId: -1, type: -1, x: 0, diff --git a/src/simularium/VisData.ts b/src/simularium/VisData.ts index ea491f2d..d6dd1385 100644 --- a/src/simularium/VisData.ts +++ b/src/simularium/VisData.ts @@ -48,7 +48,6 @@ class VisData { const parsedAgentData: AgentData[] = []; let j = AGENTS_OFFSET; for (let i = 0; i < expectedNumAgents; i++) { - //TODO use visType in AgentData and convert from "vis-type" here at parse time const agentData: AgentData = nullAgent(); for (let k = 0; k < AGENT_OBJECT_KEYS.length; ++k) { diff --git a/src/simularium/types.ts b/src/simularium/types.ts index 9c92c6ba..21be13fe 100644 --- a/src/simularium/types.ts +++ b/src/simularium/types.ts @@ -154,8 +154,7 @@ export interface FileReturn { // IMPORTANT: Order of this array needs to perfectly match the incoming data. export const AGENT_OBJECT_KEYS = [ - // TODO: convert "vis-type" to visType at parse time - "vis-type", + "visType", "instanceId", "type", "x", @@ -179,7 +178,7 @@ export interface AgentData { yrot: number; zrot: number; instanceId: number; - ["vis-type"]: number; + visType: number; type: number; cr: number; subpoints: number[]; diff --git a/src/test/VisData.test.ts b/src/test/VisData.test.ts index 474e9641..aea69945 100644 --- a/src/test/VisData.test.ts +++ b/src/test/VisData.test.ts @@ -47,7 +47,7 @@ const parsedData = [ subpoints: [], type: 7, instanceId: 0, - "vis-type": 1000, + visType: 1000, x: 1, xrot: 0, y: 1, @@ -63,7 +63,7 @@ const parsedData = [ subpoints: [], type: 7, instanceId: 0, - "vis-type": 1000, + visType: 1000, x: 2, xrot: 0, y: 2, @@ -79,7 +79,7 @@ const parsedData = [ subpoints: [], type: 7, instanceId: 0, - "vis-type": 1000, + visType: 1000, x: 3, xrot: 0, y: 3, @@ -95,7 +95,7 @@ const parsedData = [ subpoints: [], type: 7, instanceId: 0, - "vis-type": 1000, + visType: 1000, x: 4, xrot: 0, y: 4, @@ -111,7 +111,7 @@ const parsedData = [ subpoints: [], type: 7, instanceId: 0, - "vis-type": 1000, + visType: 1000, x: 5, xrot: 0, y: 5, @@ -126,7 +126,7 @@ describe("VisData module", () => { describe("VisData parse", () => { test("it returns an array of objects of agent data and time stamp data", () => { const testData = [ - 10, //"vis-type", + 10, //"visType", 15, //"instanceId", 20, //"type", 30, //"x", @@ -166,7 +166,7 @@ describe("VisData module", () => { subpoints: [60, 61, 62], //"subpoint-1", "subpoint-2", "subpoint-3"], type: 20, //"type", instanceId: 15, //"instanceId", - "vis-type": 10, //"vis-type", + visType: 10, //"visType", x: 30, //"x", xrot: 40, //"xrot", y: 31, //"y", @@ -179,7 +179,7 @@ describe("VisData module", () => { }); test("it throws an error if number of supoints does not match the nSubpoints value", () => { const tooShort = [ - 10, //"vis-type", + 10, //"visType", 15, //"instanceId", 20, //"type", 30, //"x", @@ -209,7 +209,7 @@ describe("VisData module", () => { fileName: "", }; const tooLong = [ - 10, //"vis-type", + 10, //"visType", 15, //"instanceId", 20, //"type", 30, //"x", @@ -272,7 +272,7 @@ describe("VisData module", () => { subpoints: [], type: 7, instanceId: 0, - "vis-type": 1000, + visType: 1000, x: 1, xrot: 0, y: 1, diff --git a/src/visGeometry/VisAgent.ts b/src/visGeometry/VisAgent.ts index 3012ed05..a6f021e8 100644 --- a/src/visGeometry/VisAgent.ts +++ b/src/visGeometry/VisAgent.ts @@ -31,7 +31,7 @@ export default class VisAgent { yrot: 0, zrot: 0, instanceId: NO_AGENT, - "vis-type": VisTypes.ID_VIS_TYPE_DEFAULT, + visType: VisTypes.ID_VIS_TYPE_DEFAULT, type: 0, cr: 1.0, subpoints: [], @@ -62,7 +62,7 @@ export default class VisAgent { yrot: 0, zrot: 0, instanceId: NO_AGENT, - "vis-type": VisTypes.ID_VIS_TYPE_DEFAULT, + visType: VisTypes.ID_VIS_TYPE_DEFAULT, type: 0, cr: 1.0, subpoints: [], @@ -165,7 +165,7 @@ export default class VisAgent { this.agentData.z ); if ( - this.agentData["vis-type"] === VisTypes.ID_VIS_TYPE_FIBER && + this.agentData.visType === VisTypes.ID_VIS_TYPE_FIBER && this.fiberCurve ) { return this.fiberCurve.getPoint(0.5).add(pos); diff --git a/src/visGeometry/index.ts b/src/visGeometry/index.ts index fab9cb73..5b7c76fc 100644 --- a/src/visGeometry/index.ts +++ b/src/visGeometry/index.ts @@ -1562,7 +1562,7 @@ class VisGeometry { } agents.forEach((agentData) => { - const visType = agentData["vis-type"]; + const visType = agentData.visType; const instanceId = agentData.instanceId; const typeId = agentData.type; lastx = agentData.x;