faee80d5a7be8731a8ae41aea68c4225853ef931dfb541716619bd108cefec20.json 5.6 KB

1
  1. {"ast":null,"code":"import { VertexBuffer } from \"./buffer.js\";\nimport { Logger } from \"../Misc/logger.js\";\n/**\n * Copies the given data array to the given float array.\n * @param input the input data array\n * @param size the number of components\n * @param type the component type\n * @param byteOffset the byte offset of the data\n * @param byteStride the byte stride of the data\n * @param normalized whether the data is normalized\n * @param totalVertices number of vertices in the buffer to take into account\n * @param output the output float array\n */\nexport function CopyFloatData(input, size, type, byteOffset, byteStride, normalized, totalVertices, output) {\n const tightlyPackedByteStride = size * VertexBuffer.GetTypeByteLength(type);\n const count = totalVertices * size;\n if (output.length !== count) {\n throw new Error(\"Output length is not valid\");\n }\n if (type !== VertexBuffer.FLOAT || byteStride !== tightlyPackedByteStride) {\n VertexBuffer.ForEach(input, byteOffset, byteStride, size, type, count, normalized, (value, index) => output[index] = value);\n return;\n }\n if (input instanceof Array) {\n const offset = byteOffset / 4;\n output.set(input, offset);\n } else if (input instanceof ArrayBuffer) {\n const floatData = new Float32Array(input, byteOffset, count);\n output.set(floatData);\n } else {\n const offset = input.byteOffset + byteOffset;\n // Protect against bad data\n const remainder = offset % 4;\n if (remainder) {\n Logger.Warn(\"CopyFloatData: copied misaligned data.\");\n // If not aligned, copy the data to aligned buffer\n output.set(new Float32Array(input.buffer.slice(offset, offset + count * 4)));\n return;\n }\n const floatData = new Float32Array(input.buffer, offset, count);\n output.set(floatData);\n }\n}","map":{"version":3,"names":["VertexBuffer","Logger","CopyFloatData","input","size","type","byteOffset","byteStride","normalized","totalVertices","output","tightlyPackedByteStride","GetTypeByteLength","count","length","Error","FLOAT","ForEach","value","index","Array","offset","set","ArrayBuffer","floatData","Float32Array","remainder","Warn","buffer","slice"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Buffers/bufferUtils.js"],"sourcesContent":["import { VertexBuffer } from \"./buffer.js\";\nimport { Logger } from \"../Misc/logger.js\";\n/**\n * Copies the given data array to the given float array.\n * @param input the input data array\n * @param size the number of components\n * @param type the component type\n * @param byteOffset the byte offset of the data\n * @param byteStride the byte stride of the data\n * @param normalized whether the data is normalized\n * @param totalVertices number of vertices in the buffer to take into account\n * @param output the output float array\n */\nexport function CopyFloatData(input, size, type, byteOffset, byteStride, normalized, totalVertices, output) {\n const tightlyPackedByteStride = size * VertexBuffer.GetTypeByteLength(type);\n const count = totalVertices * size;\n if (output.length !== count) {\n throw new Error(\"Output length is not valid\");\n }\n if (type !== VertexBuffer.FLOAT || byteStride !== tightlyPackedByteStride) {\n VertexBuffer.ForEach(input, byteOffset, byteStride, size, type, count, normalized, (value, index) => (output[index] = value));\n return;\n }\n if (input instanceof Array) {\n const offset = byteOffset / 4;\n output.set(input, offset);\n }\n else if (input instanceof ArrayBuffer) {\n const floatData = new Float32Array(input, byteOffset, count);\n output.set(floatData);\n }\n else {\n const offset = input.byteOffset + byteOffset;\n // Protect against bad data\n const remainder = offset % 4;\n if (remainder) {\n Logger.Warn(\"CopyFloatData: copied misaligned data.\");\n // If not aligned, copy the data to aligned buffer\n output.set(new Float32Array(input.buffer.slice(offset, offset + count * 4)));\n return;\n }\n const floatData = new Float32Array(input.buffer, offset, count);\n output.set(floatData);\n }\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,aAAa;AAC1C,SAASC,MAAM,QAAQ,mBAAmB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAACC,KAAK,EAAEC,IAAI,EAAEC,IAAI,EAAEC,UAAU,EAAEC,UAAU,EAAEC,UAAU,EAAEC,aAAa,EAAEC,MAAM,EAAE;EACxG,MAAMC,uBAAuB,GAAGP,IAAI,GAAGJ,YAAY,CAACY,iBAAiB,CAACP,IAAI,CAAC;EAC3E,MAAMQ,KAAK,GAAGJ,aAAa,GAAGL,IAAI;EAClC,IAAIM,MAAM,CAACI,MAAM,KAAKD,KAAK,EAAE;IACzB,MAAM,IAAIE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