mirror of
https://github.com/nasa/openmct.git
synced 2025-01-03 20:04: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 = [],
|
lengthArray = [],
|
||||||
bufferArray = [];
|
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
|
// Make sure there is enough space in a buffer to accomodate a
|
||||||
// new point at the specified index. This will updates buffers[id]
|
// new point at the specified index. This will updates buffers[id]
|
||||||
// if necessary.
|
// if necessary.
|
||||||
function ensureBufferSize(buffer, id, index) {
|
function ensureBufferSize(buffer, id, index) {
|
||||||
// Check if we don't have enough room
|
// 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 we don't, can we expand?
|
||||||
if (index < MAX_POINTS) {
|
if (index < MAX_POINTS) {
|
||||||
// Double the buffer size
|
// Double the buffer size
|
||||||
buffer = buffers[id] = new Float32Array(
|
buffer = buffers[id] = doubleSize(buffer);
|
||||||
buffer,
|
|
||||||
0,
|
|
||||||
buffer.length * 2
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
// Just shift the existing buffer
|
// Just shift the existing buffer
|
||||||
buffer.copyWithin(0, 2);
|
buffer.copyWithin(0, 2);
|
||||||
|
Loading…
Reference in New Issue
Block a user