mirror of
https://github.com/nasa/openmct.git
synced 2024-12-20 13:43:09 +00:00
[Plot] Fix disappearing plot bug
Fix buffer resize operation as plots fill, WTD-782.
This commit is contained in:
parent
4fb750c0e0
commit
b1485e716c
@ -32,20 +32,23 @@ define(
|
||||
lengthArray = [],
|
||||
bufferArray = [];
|
||||
|
||||
// Double the size of a Float32Array
|
||||
function doubleSize(buffer) {
|
||||
var doubled = new Float32Array(buffer.length * 2);
|
||||
doubled.set(buffer); // Copy contents of original
|
||||
return doubled;
|
||||
}
|
||||
|
||||
// Make sure there is enough space in a buffer to accomodate a
|
||||
// new point at the specified index. This will updates buffers[id]
|
||||
// if necessary.
|
||||
function ensureBufferSize(buffer, id, index) {
|
||||
// Check if we don't have enough room
|
||||
if (index > buffer.length / 2) {
|
||||
if (index > (buffer.length / 2 - 1)) {
|
||||
// If we don't, can we expand?
|
||||
if (index < MAX_POINTS) {
|
||||
// Double the buffer size
|
||||
buffer = buffers[id] = new Float32Array(
|
||||
buffer,
|
||||
0,
|
||||
buffer.length * 2
|
||||
);
|
||||
buffer = buffers[id] = doubleSize(buffer);
|
||||
} else {
|
||||
// Just shift the existing buffer
|
||||
buffer.copyWithin(0, 2);
|
||||
|
Loading…
Reference in New Issue
Block a user