561e2232969740ccad66b1f6026f5de7b7e4ec8f1a9997d191535973f7c06d31.json 13 KB

1
  1. {"ast":null,"code":"/* eslint-disable @typescript-eslint/naming-convention */\nimport { Logger } from \"../../../../Misc/logger.js\";\nimport { ParseNullTerminatedString, ParseUint32, ParseValue } from \"./exrLoader.core.js\";\n/**\n * Inspired by https://github.com/sciecode/three.js/blob/dev/examples/jsm/loaders/EXRLoader.js\n * Referred to the original Industrial Light & Magic OpenEXR implementation and the TinyEXR / Syoyo Fujita\n * implementation.\n */\n// /*\n// Copyright (c) 2014 - 2017, Syoyo Fujita\n// All rights reserved.\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are met:\n// * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n// * Redistributions in binary form must reproduce the above copyright\n// notice, this list of conditions and the following disclaimer in the\n// documentation and/or other materials provided with the distribution.\n// * Neither the name of the Syoyo Fujita nor the\n// names of its contributors may be used to endorse or promote products\n// derived from this software without specific prior written permission.\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n// DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY\n// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n// */\n// // TinyEXR contains some OpenEXR code, which is licensed under ------------\n// ///////////////////////////////////////////////////////////////////////////\n// //\n// // Copyright (c) 2002, Industrial Light & Magic, a division of Lucas\n// // Digital Ltd. LLC\n// //\n// // All rights reserved.\n// //\n// // Redistribution and use in source and binary forms, with or without\n// // modification, are permitted provided that the following conditions are\n// // met:\n// // * Redistributions of source code must retain the above copyright\n// // notice, this list of conditions and the following disclaimer.\n// // * Redistributions in binary form must reproduce the above\n// // copyright notice, this list of conditions and the following disclaimer\n// // in the documentation and/or other materials provided with the\n// // distribution.\n// // * Neither the name of Industrial Light & Magic nor the names of\n// // its contributors may be used to endorse or promote products derived\n// // from this software without specific prior written permission.\n// //\n// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// // \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n// //\n// ///////////////////////////////////////////////////////////////////////////\n// // End of OpenEXR license -------------------------------------------------\nconst EXR_MAGIC = 20000630;\n/**\n * Gets the EXR header\n * @param dataView defines the data view to read from\n * @param offset defines the offset to start reading from\n * @returns the header\n */\nexport function GetExrHeader(dataView, offset) {\n if (dataView.getUint32(0, true) != EXR_MAGIC) {\n throw new Error(\"Incorrect OpenEXR format\");\n }\n const version = dataView.getUint8(4);\n const specData = dataView.getUint8(5); // fullMask\n const spec = {\n singleTile: !!(specData & 2),\n longName: !!(specData & 4),\n deepFormat: !!(specData & 8),\n multiPart: !!(specData & 16)\n };\n offset.value = 8;\n const headerData = {};\n let keepReading = true;\n while (keepReading) {\n const attributeName = ParseNullTerminatedString(dataView.buffer, offset);\n if (!attributeName) {\n keepReading = false;\n } else {\n const attributeType = ParseNullTerminatedString(dataView.buffer, offset);\n const attributeSize = ParseUint32(dataView, offset);\n const attributeValue = ParseValue(dataView, offset, attributeType, attributeSize);\n if (attributeValue === undefined) {\n Logger.Warn(`Unknown header attribute type ${attributeType}'.`);\n } else {\n headerData[attributeName] = attributeValue;\n }\n }\n }\n if ((specData & ~0x04) != 0) {\n throw new Error(\"Unsupported file format\");\n }\n return {\n version: version,\n spec: spec,\n ...headerData\n };\n}","map":{"version":3,"names":["Logger","ParseNullTerminatedString","ParseUint32","ParseValue","EXR_MAGIC","GetExrHeader","dataView","offset","getUint32","Error","version","getUint8","specData","spec","singleTile","longName","deepFormat","multiPart","value","headerData","keepReading","attributeName","buffer","attributeType","attributeSize","attributeValue","undefined","Warn"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/Textures/Loaders/EXR/exrLoader.header.js"],"sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport { Logger } from \"../../../../Misc/logger.js\";\nimport { ParseNullTerminatedString, ParseUint32, ParseValue } from \"./exrLoader.core.js\";\n/**\n * Inspired by https://github.com/sciecode/three.js/blob/dev/examples/jsm/loaders/EXRLoader.js\n * Referred to the original Industrial Light & Magic OpenEXR implementation and the TinyEXR / Syoyo Fujita\n * implementation.\n */\n// /*\n// Copyright (c) 2014 - 2017, Syoyo Fujita\n// All rights reserved.\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are met:\n// * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n// * Redistributions in binary form must reproduce the above copyright\n// notice, this list of conditions and the following disclaimer in the\n// documentation and/or other materials provided with the distribution.\n// * Neither the name of the Syoyo Fujita nor the\n// names of its contributors may be used to endorse or promote products\n// derived from this software without specific prior written permission.\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n// DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY\n// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n// */\n// // TinyEXR contains some OpenEXR code, which is licensed under ------------\n// ///////////////////////////////////////////////////////////////////////////\n// //\n// // Copyright (c) 2002, Industrial Light & Magic, a division of Lucas\n// // Digital Ltd. LLC\n// //\n// // All rights reserved.\n// //\n// // Redistribution and use in source and binary forms, with or without\n// // modification, are permitted provided that the following conditions are\n// // met:\n// // * Redistributions of source code must retain the above copyright\n// // notice, this list of conditions and the following disclaimer.\n// // * Redistributions in binary form must reproduce the above\n// // copyright notice, this list of conditions and the following disclaimer\n// // in the documentation and/or other materials provided with the\n// // distribution.\n// // * Neither the name of Industrial Light & Magic nor the names of\n// // its contributors may be used to endorse or promote products derived\n// // from this software without specific prior written permission.\n// //\n// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// // \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n// //\n// ///////////////////////////////////////////////////////////////////////////\n// // End of OpenEXR license -------------------------------------------------\nconst EXR_MAGIC = 20000630;\n/**\n * Gets the EXR header\n * @param dataView defines the data view to read from\n * @param offset defines the offset to start reading from\n * @returns the header\n */\nexport function GetExrHeader(dataView, offset) {\n if (dataView.getUint32(0, true) != EXR_MAGIC) {\n throw new Error(\"Incorrect OpenEXR format\");\n }\n const version = dataView.getUint8(4);\n const specData = dataView.getUint8(5); // fullMask\n const spec = {\n singleTile: !!(specData & 2),\n longName: !!(specData & 4),\n deepFormat: !!(specData & 8),\n multiPart: !!(specData & 16),\n };\n offset.value = 8;\n const headerData = {};\n let keepReading = true;\n while (keepReading) {\n const attributeName = ParseNullTerminatedString(dataView.buffer, offset);\n if (!attributeName) {\n keepReading = false;\n }\n else {\n const attributeType = ParseNullTerminatedString(dataView.buffer, offset);\n const attributeSize = ParseUint32(dataView, offset);\n const attributeValue = ParseValue(dataView, offset, attributeType, attributeSize);\n if (attributeValue === undefined) {\n Logger.Warn(`Unknown header attribute type ${attributeType}'.`);\n }\n else {\n headerData[attributeName] = attributeValue;\n }\n }\n }\n if ((specData & ~0x04) != 0) {\n throw new Error(\"Unsupported file format\");\n }\n return { version: version, spec: spec, ...headerData };\n}\n"],"mappings":"AAAA;AACA,SAASA,MAAM,QAAQ,4BAA4B;AACnD,SAASC,yBAAyB,EAAEC,WAAW,EAAEC,UAAU,QAAQ,qBAAqB;AACxF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,SAAS,GAAG,QAAQ;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAACC,QAAQ,EAAEC,MAAM,EAAE;EAC3C,IAAID,QAAQ,CAACE,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,IAAIJ,SAAS,EAAE;IAC1C,MAAM,IAAIK,KAAK,CAAC,0BAA0B,CAAC;EAC/C;EACA,MAAMC,OAAO,GAAGJ,QAAQ,CAACK,QAAQ,CAAC,CAAC,CAAC;EACpC,MAAMC,QAAQ,GAAGN,QAAQ,CAACK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;EACvC,MAAME,IAAI,GAAG;IACTC,UAAU,EAAE,CA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