xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

Chrome Extension: TypedArray to Matrix table All In One

Chrome Extension: TypedArray to Matrix table All In One

difficulty: Medium / 难度: 中等

glMatrix

TypedArray

ArrayBuffer

Flaot32Array(16)

console.table()

Unit Matrix / 单位矩阵

demos


    import {glMatrix, mat4 } from './gl-matrix-modules/esm/index.js';
    console.log(`glMatrix =`, glMatrix);
    console.log(`mat4 =`, mat4);
   // Unit Matrix / 单位矩阵
    let matrix4Uint = mat4.create()
    console.log(matrix4Uint);
    let arr2 = [];
    let temp = [];
    for(let i = 0; i < matrix4Uint.length; i++) {
      temp.push(matrix4Uint[i]);
      if((i + 1) % 4 === 0) {
        arr2.push(temp);
        temp = [];
      }
    }
    console.log(arr2);
    console.table(arr2);
    import {glMatrix, mat4 } from './gl-matrix-modules/esm/index.js';
    console.log(`glMatrix =`, glMatrix);
    console.log(`mat4 =`, mat4);
   // Unit Matrix / 单位矩阵
    let matrix4Uint = mat4.create()
    console.log(matrix4Uint);
    let arr2 = [];
    let temp = [];
    for(let i = 1; i <= matrix4Uint.length; i++) {
      console.log(`i =`, i, `matrix4Uint[i-1] =`, matrix4Uint[i-1]);
      temp.push(matrix4Uint[i - 1]);
      if(i === 16) {
        console.log(`temp`, temp);
      }
      if(i % 4 === 0) {
        arr2.push(temp);
        temp = [];
      }
    }
    console.log(arr2);
    console.table(arr2);

image


    import {glMatrix, mat4 } from './gl-matrix-modules/esm/index.js';
    console.log(`glMatrix =`, glMatrix);
    console.log(`mat4 =`, mat4);
    // Unit Matrix / 单位矩阵
    let matrix4Uint = mat4.create()
    console.log(matrix4Uint);
    let arr2 = [];
    let temp = [];
    for(let i = 0; i < matrix4Uint.length; i++) {
      temp.push(matrix4Uint[i]);
      if((i + 1) % 4 === 0) {
        arr2.push(temp);
        temp = [];
      }
    }
    console.log(arr2);
    // console.table(arr2);
    function ArrObj(arr) {
      for (let i = 0; i < arr.length; i++) {
        this[`column${i}`] = arr[i];
      }
    }
    let arrObjs = [];
    for (let i = 0; i < arr2.length; i++) {
      arrObjs.push(new ArrObj(arr2[i]));
    }
    console.table(arrObjs, ['column0', 'column1', 'column2', 'column3']);
    // console.log(JSON.stringify(arr2, null, 4));
    for(let i = 0; i < arr2.length; i++) {
      let temp = [];
      for (const arr of arr2) {
        temp.push(arr[i]);
      }
      // console.log(temp);
      console.log(`[`, temp.join(` `), `]`);
      // console.log(temp.toString());
      // console.log(JSON.stringify(temp, null, 4));
    }

image

    import {glMatrix, mat4 } from './gl-matrix-modules/esm/index.js';
    console.log(`glMatrix =`, glMatrix);
    console.log(`mat4 =`, mat4);
    // Unit Matrix / 单位矩阵
    let matrix4Uint = mat4.create()
    console.log(matrix4Uint);
    let arr2 = [];
    let temp = [];
    for(let i = 0; i < matrix4Uint.length; i++) {
      temp.push(matrix4Uint[i]);
      if((i + 1) % 4 === 0) {
        arr2.push(temp);
        temp = [];
      }
    }
    console.log(arr2);
    // console.table(arr2);
    function ArrObj(arr) {
      for (let i = 0; i < arr.length; i++) {
        this[`column ${i + 1}`] = arr[i];
      }
    }
    let arrObjs = [];
    for (let i = 0; i < arr2.length; i++) {
      arrObjs.push(new ArrObj(arr2[i]));
    }
    const columns = Object.keys((new ArrObj(arr2[0])));
    console.log(columns);
    console.table(arrObjs, columns);
    // console.table(arrObjs, [...columns]);
    // console.table(arrObjs, ['column0', 'column1', 'column2', 'column3']);
    // console.log(JSON.stringify(arr2, null, 4));
    for(let i = 0; i < arr2.length; i++) {
      let temp = [];
      for (const arr of arr2) {
        temp.push(arr[i]);
      }
      // console.log(temp);
      console.log(`[`, temp.join(` `), `]`);
      // console.log(temp.toString());
      // console.log(JSON.stringify(temp, null, 4));
    }

image

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

console.table(data)
console.table(data, columns)

https://developer.mozilla.org/en-US/docs/Web/API/console/table_static

refs

https://encrypted.google.com/search?oq=extension+typedarray+to+matrix&sourceid=chrome&ie=UTF-8&q=extension+typedarray+to+matrix



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2025-12-24 14:25  xgqfrms  阅读(4)  评论(2)    收藏  举报