From db3ca8b671bf2fa6bdf2831b8b5641cff74cf5a8 Mon Sep 17 00:00:00 2001 From: Edward Moyse Date: Wed, 21 Apr 2021 17:35:59 +0200 Subject: [PATCH] fix(event-display): fix drawing of hits Didn't reserve space in Float32Array (oops). --- .../src/loaders/objects/phoenix-objects.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/phoenix-event-display/src/loaders/objects/phoenix-objects.ts b/packages/phoenix-event-display/src/loaders/objects/phoenix-objects.ts index 102173574..17fb12c02 100644 --- a/packages/phoenix-event-display/src/loaders/objects/phoenix-objects.ts +++ b/packages/phoenix-event-display/src/loaders/objects/phoenix-objects.ts @@ -211,9 +211,14 @@ export class PhoenixObjects { if (hitsParams.length > 0) { // Peek at first one. Would be better to make these properties of the collections. const first = hitsParams[0]; - if (Array.isArray(first)) isSimpleArray = true; - if ('type' in first) { - type = first.type; + if (Array.isArray(first)) { + isSimpleArray = true; + hitsParamsClone = { pos: hitsParams }; + } else { + hitsParamsClone = hitsParams; + if ('type' in first) { + type = first.type; + } } } else { console.log('No hits! Aborting from getHits.'); @@ -228,12 +233,12 @@ export class PhoenixObjects { // attributes let hitLength = hitsParams.length * coordlength; if (isSimpleArray) length = hitLength; // These are already arrays - const pointPos = new Float32Array(); + const pointPos = new Float32Array(hitLength); let i = 0; for (const hit of hitsParams) { for (let j = 0; j < coordlength; ++j, ++i) { if (isSimpleArray) { - pointPos[i] = hit; + pointPos[i] = hit[j]; } else { pointPos[i] = hit.pos[j]; }