Answer the question
In order to leave comments, you need to log in
How to convert Uint8Array?
There is data in the form of a Uint8Array array.
Here is the structure:
Here, theoretically, there should be data that is in the picture below:
How to convert the Uint8Array array to the data in the table ???
PS torn from webgl inspector extension
Answer the question
In order to leave comments, you need to log in
In general, to convert Uint8Array to Float32Array can be done in 2 lines
var uint8array = ...
var point1 = new Float32Array(uint8array.buffer);
for(var i=0;i<uint8array.length;i+=32){ // перебираем элементы каждой записи (строки из последней табл.)
var p1bytes = uint8array.subarray(i,i+12); // получаем данные для первой точки, 12 байт
var p1 = new Float32Array(p1bytes.buffer); // получили 3 элемента float
var p2bytes = uint8array.subarray(i+12,i+20); // теперь следующие 8 байт
var p2 = new Float32Array(p2bytes.buffer); // 2 элемента
// дальше идут массивы из элементов по 2 байта (short)
var p3bytes = uint8array.subarray(i+20,i+24);
var p3 = new Uint16Array(p1bytes.buffer);
// и т.д.
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question