summit/frontend/node_modules/three-stdlib/loaders/RGBELoader.cjs.map

1 line
18 KiB
Plaintext
Raw Normal View History

2025-12-08 16:31:30 +00:00
{"version":3,"file":"RGBELoader.cjs","sources":["../../src/loaders/RGBELoader.js"],"sourcesContent":["import { DataTextureLoader, DataUtils, FloatType, HalfFloatType, LinearFilter } from 'three'\n\n// https://github.com/mrdoob/three.js/issues/5552\n// http://en.wikipedia.org/wiki/RGBE_image_format\n\nclass RGBELoader extends DataTextureLoader {\n constructor(manager) {\n super(manager)\n\n this.type = HalfFloatType\n }\n\n // adapted from http://www.graphics.cornell.edu/~bjw/rgbe.html\n\n parse(buffer) {\n const /* default error routine. change this to change error handling */\n rgbe_read_error = 1,\n rgbe_write_error = 2,\n rgbe_format_error = 3,\n rgbe_memory_error = 4,\n rgbe_error = function (rgbe_error_code, msg) {\n switch (rgbe_error_code) {\n case rgbe_read_error:\n throw new Error('THREE.RGBELoader: Read Error: ' + (msg || ''))\n case rgbe_write_error:\n throw new Error('THREE.RGBELoader: Write Error: ' + (msg || ''))\n case rgbe_format_error:\n throw new Error('THREE.RGBELoader: Bad File Format: ' + (msg || ''))\n default:\n case rgbe_memory_error:\n throw new Error('THREE.RGBELoader: Memory Error: ' + (msg || ''))\n }\n },\n /* offsets to red, green, and blue components in a data (float) pixel */\n //RGBE_DATA_RED = 0,\n //RGBE_DATA_GREEN = 1,\n //RGBE_DATA_BLUE = 2,\n\n /* number of floats per pixel, use 4 since stored in rgba image format */\n //RGBE_DATA_SIZE = 4,\n\n /* flags indicating which fields in an rgbe_header_info are valid */\n RGBE_VALID_PROGRAMTYPE = 1,\n RGBE_VALID_FORMAT = 2,\n RGBE_VALID_DIMENSIONS = 4,\n NEWLINE = '\\n',\n fgets = function (buffer, lineLimit, consume) {\n const chunkSize = 128\n\n lineLimit = !lineLimit ? 1024 : lineLimit\n let p = buffer.pos,\n i = -1,\n len = 0,\n s = '',\n chunk = String.fromCharCode.apply(null, new Uint16Array(buffer.subarray(p, p + chunkSize)))\n\n while (0 > (i = chunk.indexOf(NEWLINE)) && len < lineLimit && p < buffer.byteLength) {\n s += chunk\n len += chunk.length\n p += chunkSize\n chunk += String.fromCharCode.apply(null, new Uint16Array(buffer.subarray(p, p + chunkSize)))\n }\n\n if (-1 < i) {\n /*for (i=l-1; i>=0; i--) {\n\t\t\t\t\t\tbyteCode = m.charCodeAt(i);\n\t\t\t\t\t\tif (byteCode > 0x7f && byteCode <= 0x7ff) byteLen++;\n\t\t\t\t\t\telse if (byteCode > 0x7ff && byteCode <= 0xffff) byteLen += 2;\n\t\t\t\t\t\tif (byteCode >= 0xDC00 && byteCode <= 0xDFFF) i--; //trail surrogate\n\t\t\t\t\t}*/\n if (false !== consume) buffer.pos += len + i + 1\n return s + chunk.slice(0, i)\n }\n\n return false\n },\n /* minimal header reading. modify if you want to parse more information */\n RGBE_ReadHeader = function (buffer) {\n // regexes to parse header info fields\n const magic_token_re = /^#\\?(\\S+)/,\n gamma_re = /^\\s*GAMMA\\s*=\\s*(\\d+(\\.\\d+)?)\\s*$/,\n exposure_re = /^\\s*EXPOSURE\\s*=\\s*(\\d+(\\.\\d+)?)\\s*$/,\n format_re = /^\\s*FORMAT=(\\S+)\\s*$/,\n dimensions_re = /^\\s*\\-Y\\s+(\\d+)\\s+\\+X\\s+(\\d+)\\s*$/,\n // RGBE format header struct\n header = {\n valid: 0 /* indicate which fields are valid */,\n\n string: '' /* the actual header string */,\n\n comments: '' /* comments found in header */,\n\n programtype: 'RGBE' /* listed at beginning of file to identify it after \"#?\". defaults to \"RGBE\" */,\n\n format: '' /* RGBE format, default 32-bit_rle_rgbe */,\n\n gamma: 1.0 /* image has already been gamma corrected with given gamma. defaults to 1.0 (no correction) */,\n\n exposure: 1.0 /* a value of 1.0 in an image corresponds to <exposure> watts/steradian/m^2. defaults to 1.0 */,\n\n width: 0,\n height