UNPKG

bytev-charts

Version:

基于echarts和JavaScript及ES6封装的一个可以直接调用的图表组件库,内置主题设计,简单快捷,且支持用户自定义配置; npm 安装方式: npm install bytev-charts 若启动提示还需额外install插件,则运行 npm install @babel/runtime-corejs2 即可;

652 lines (575 loc) 26.9 kB
import _Reflect$construct from "@babel/runtime-corejs2/core-js/reflect/construct"; import _asyncToGenerator from "@babel/runtime-corejs2/helpers/asyncToGenerator"; import _slicedToArray from "@babel/runtime-corejs2/helpers/slicedToArray"; import _classCallCheck from "@babel/runtime-corejs2/helpers/classCallCheck"; import _createClass from "@babel/runtime-corejs2/helpers/createClass"; import _inherits from "@babel/runtime-corejs2/helpers/inherits"; import _possibleConstructorReturn from "@babel/runtime-corejs2/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime-corejs2/helpers/getPrototypeOf"; import _regeneratorRuntime from "@babel/runtime-corejs2/regenerator"; import "core-js/modules/es.array.iterator.js"; import "core-js/modules/es.object.to-string.js"; import "core-js/modules/es.promise.js"; import "core-js/modules/es.string.iterator.js"; import "core-js/modules/web.dom-collections.iterator.js"; import "core-js/modules/es.array-buffer.slice.js"; import "core-js/modules/es.typed-array.uint8-array.js"; import "core-js/modules/es.typed-array.copy-within.js"; import "core-js/modules/es.typed-array.every.js"; import "core-js/modules/es.typed-array.fill.js"; import "core-js/modules/es.typed-array.filter.js"; import "core-js/modules/es.typed-array.find.js"; import "core-js/modules/es.typed-array.find-index.js"; import "core-js/modules/es.typed-array.for-each.js"; import "core-js/modules/es.typed-array.includes.js"; import "core-js/modules/es.typed-array.index-of.js"; import "core-js/modules/es.typed-array.iterator.js"; import "core-js/modules/es.typed-array.join.js"; import "core-js/modules/es.typed-array.last-index-of.js"; import "core-js/modules/es.typed-array.map.js"; import "core-js/modules/es.typed-array.reduce.js"; import "core-js/modules/es.typed-array.reduce-right.js"; import "core-js/modules/es.typed-array.reverse.js"; import "core-js/modules/es.typed-array.set.js"; import "core-js/modules/es.typed-array.slice.js"; import "core-js/modules/es.typed-array.some.js"; import "core-js/modules/es.typed-array.sort.js"; import "core-js/modules/es.typed-array.subarray.js"; import "core-js/modules/es.typed-array.to-locale-string.js"; import "core-js/modules/es.typed-array.to-string.js"; import "core-js/modules/es.typed-array.uint32-array.js"; import "core-js/modules/es.regexp.flags.js"; import "core-js/modules/es.array.slice.js"; import "core-js/modules/es.data-view.js"; import _Promise from "@babel/runtime-corejs2/core-js/promise"; import _Number$isSafeInteger from "@babel/runtime-corejs2/core-js/number/is-safe-integer"; function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** * References: * - KTX: http://github.khronos.org/KTX-Specification/ * - DFD: https://www.khronos.org/registry/DataFormat/specs/1.3/dataformat.1.3.html#basicdescriptor * * To do: * - [ ] Cross-platform testing * - [ ] Specify JS/WASM transcoder path * - [ ] High-quality demo * - [ ] Documentation * - [ ] TypeScript definitions * - [ ] (Optional) Include BC5 * - [ ] (Optional) Include EAC RG on mobile (WEBGL_compressed_texture_etc) * - [ ] (Optional) Include two-texture output mode (see: clearcoat + clearcoatRoughness) * - [ ] (Optional) Support Web Workers, after #18234 */ import { CompressedTexture, CompressedTextureLoader, FileLoader, LinearEncoding, LinearFilter, LinearMipmapLinearFilter, MathUtils, RGBAFormat, RGBA_ASTC_4x4_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, UnsignedByteType, sRGBEncoding } from '../../../build/three.module.js'; import { ZSTDDecoder } from '../libs/zstddec.module.js'; // Data Format Descriptor (DFD) constants. var DFDModel = { ETC1S: 163, UASTC: 166 }; var DFDChannel = { ETC1S: { RGB: 0, RRR: 3, GGG: 4, AAA: 15 }, UASTC: { RGB: 0, RGBA: 3, RRR: 4, RRRG: 5 } }; // var KTX2Loader = /*#__PURE__*/function (_CompressedTextureLoa) { _inherits(KTX2Loader, _CompressedTextureLoa); var _super = _createSuper(KTX2Loader); function KTX2Loader(manager) { var _this; _classCallCheck(this, KTX2Loader); _this = _super.call(this, manager); _this.basisModule = null; _this.basisModulePending = null; _this.transcoderConfig = {}; return _this; } _createClass(KTX2Loader, [{ key: "detectSupport", value: function detectSupport(renderer) { this.transcoderConfig = { astcSupported: renderer.extensions.has('WEBGL_compressed_texture_astc'), etc1Supported: renderer.extensions.has('WEBGL_compressed_texture_etc1'), etc2Supported: renderer.extensions.has('WEBGL_compressed_texture_etc'), dxtSupported: renderer.extensions.has('WEBGL_compressed_texture_s3tc'), bptcSupported: renderer.extensions.has('EXT_texture_compression_bptc'), pvrtcSupported: renderer.extensions.has('WEBGL_compressed_texture_pvrtc') || renderer.extensions.has('WEBKIT_WEBGL_compressed_texture_pvrtc') }; return this; } }, { key: "initModule", value: function initModule() { if (this.basisModulePending) { return; } var scope = this; // The Emscripten wrapper returns a fake Promise, which can cause // infinite recursion when mixed with native Promises. Wrap the module // initialization to return a native Promise. scope.basisModulePending = new _Promise(function (resolve) { MSC_TRANSCODER().then(function (basisModule) { scope.basisModule = basisModule; basisModule.initTranscoders(); resolve(); }); }); } }, { key: "load", value: function load(url, onLoad, onProgress, onError) { var scope = this; var texture = new CompressedTexture(); var bufferPending = new _Promise(function (resolve, reject) { new FileLoader(scope.manager).setPath(scope.path).setResponseType('arraybuffer').load(url, resolve, onProgress, reject); }); this.initModule(); _Promise.all([bufferPending, this.basisModulePending]).then(function (_ref) { var _ref2 = _slicedToArray(_ref, 1), buffer = _ref2[0]; scope.parse(buffer, function (_texture) { texture.copy(_texture); texture.needsUpdate = true; if (onLoad) onLoad(texture); }, onError); }); return texture; } }, { key: "parse", value: function parse(buffer, onLoad, onError) { var BasisLzEtc1sImageTranscoder = this.basisModule.BasisLzEtc1sImageTranscoder; var UastcImageTranscoder = this.basisModule.UastcImageTranscoder; var TextureFormat = this.basisModule.TextureFormat; var ktx = new KTX2Container(this.basisModule, buffer); // TODO(donmccurdy): Should test if texture is transcodable before attempting // any transcoding. If supercompressionScheme is KTX_SS_BASIS_LZ and dfd // colorModel is ETC1S (163) or if dfd colorModel is UASTCF (166) // then texture must be transcoded. var transcoder = ktx.getTexFormat() === TextureFormat.UASTC4x4 ? new UastcImageTranscoder() : new BasisLzEtc1sImageTranscoder(); ktx.initMipmaps(transcoder, this.transcoderConfig).then(function () { var texture = new CompressedTexture(ktx.mipmaps, ktx.getWidth(), ktx.getHeight(), ktx.transcodedFormat, UnsignedByteType); texture.encoding = ktx.getEncoding(); texture.premultiplyAlpha = ktx.getPremultiplyAlpha(); texture.minFilter = ktx.mipmaps.length === 1 ? LinearFilter : LinearMipmapLinearFilter; texture.magFilter = LinearFilter; onLoad(texture); })["catch"](onError); return this; } }]); return KTX2Loader; }(CompressedTextureLoader); var KTX2Container = /*#__PURE__*/function () { function KTX2Container(basisModule, arrayBuffer) { _classCallCheck(this, KTX2Container); this.basisModule = basisModule; this.arrayBuffer = arrayBuffer; this.zstd = new ZSTDDecoder(); this.zstd.init(); this.mipmaps = null; this.transcodedFormat = null; // Confirm this is a KTX 2.0 file, based on the identifier in the first 12 bytes. var idByteLength = 12; var id = new Uint8Array(this.arrayBuffer, 0, idByteLength); if (id[0] !== 0xAB || // '´' id[1] !== 0x4B || // 'K' id[2] !== 0x54 || // 'T' id[3] !== 0x58 || // 'X' id[4] !== 0x20 || // ' ' id[5] !== 0x32 || // '2' id[6] !== 0x30 || // '0' id[7] !== 0xBB || // 'ª' id[8] !== 0x0D || // '\r' id[9] !== 0x0A || // '\n' id[10] !== 0x1A || // '\x1A' id[11] !== 0x0A // '\n' ) { throw new Error('THREE.KTX2Loader: Missing KTX 2.0 identifier.'); } // TODO(donmccurdy): If we need to support BE, derive this from typeSize. var littleEndian = true; /////////////////////////////////////////////////// // Header. /////////////////////////////////////////////////// var headerByteLength = 17 * Uint32Array.BYTES_PER_ELEMENT; var headerReader = new KTX2BufferReader(this.arrayBuffer, idByteLength, headerByteLength, littleEndian); this.header = { vkFormat: headerReader.nextUint32(), typeSize: headerReader.nextUint32(), pixelWidth: headerReader.nextUint32(), pixelHeight: headerReader.nextUint32(), pixelDepth: headerReader.nextUint32(), arrayElementCount: headerReader.nextUint32(), faceCount: headerReader.nextUint32(), levelCount: headerReader.nextUint32(), supercompressionScheme: headerReader.nextUint32(), dfdByteOffset: headerReader.nextUint32(), dfdByteLength: headerReader.nextUint32(), kvdByteOffset: headerReader.nextUint32(), kvdByteLength: headerReader.nextUint32(), sgdByteOffset: headerReader.nextUint64(), sgdByteLength: headerReader.nextUint64() }; if (this.header.pixelDepth > 0) { throw new Error('THREE.KTX2Loader: Only 2D textures are currently supported.'); } if (this.header.arrayElementCount > 1) { throw new Error('THREE.KTX2Loader: Array textures are not currently supported.'); } if (this.header.faceCount > 1) { throw new Error('THREE.KTX2Loader: Cube textures are not currently supported.'); } /////////////////////////////////////////////////// // Level index /////////////////////////////////////////////////// var levelByteLength = this.header.levelCount * 3 * 8; var levelReader = new KTX2BufferReader(this.arrayBuffer, idByteLength + headerByteLength, levelByteLength, littleEndian); this.levels = []; for (var i = 0; i < this.header.levelCount; i++) { this.levels.push({ byteOffset: levelReader.nextUint64(), byteLength: levelReader.nextUint64(), uncompressedByteLength: levelReader.nextUint64() }); } /////////////////////////////////////////////////// // Data Format Descriptor (DFD) /////////////////////////////////////////////////// var dfdReader = new KTX2BufferReader(this.arrayBuffer, this.header.dfdByteOffset, this.header.dfdByteLength, littleEndian); var sampleStart = 6; var sampleWords = 4; this.dfd = { vendorId: dfdReader.skip(4 /* totalSize */ ).nextUint16(), versionNumber: dfdReader.skip(2 /* descriptorType */ ).nextUint16(), descriptorBlockSize: dfdReader.nextUint16(), colorModel: dfdReader.nextUint8(), colorPrimaries: dfdReader.nextUint8(), transferFunction: dfdReader.nextUint8(), flags: dfdReader.nextUint8(), texelBlockDimension: { x: dfdReader.nextUint8() + 1, y: dfdReader.nextUint8() + 1, z: dfdReader.nextUint8() + 1, w: dfdReader.nextUint8() + 1 }, bytesPlane0: dfdReader.nextUint8(), numSamples: 0, samples: [] }; this.dfd.numSamples = (this.dfd.descriptorBlockSize / 4 - sampleStart) / sampleWords; dfdReader.skip(7 /* bytesPlane[1-7] */ ); for (var i = 0; i < this.dfd.numSamples; i++) { this.dfd.samples[i] = { channelID: dfdReader.skip(3 /* bitOffset + bitLength */ ).nextUint8() // ... remainder not implemented. }; dfdReader.skip(12 /* samplePosition[0-3], lower, upper */ ); } if (this.header.vkFormat !== 0x00 /* VK_FORMAT_UNDEFINED */ && !(this.header.supercompressionScheme === 1 /* BasisLZ */ || this.dfd.colorModel === DFDModel.UASTC)) { throw new Error('THREE.KTX2Loader: Only Basis Universal supercompression is currently supported.'); } /////////////////////////////////////////////////// // Key/Value Data (KVD) /////////////////////////////////////////////////// // Not implemented. this.kvd = {}; /////////////////////////////////////////////////// // Supercompression Global Data (SGD) /////////////////////////////////////////////////// this.sgd = {}; if (this.header.sgdByteLength <= 0) return; var sgdReader = new KTX2BufferReader(this.arrayBuffer, this.header.sgdByteOffset, this.header.sgdByteLength, littleEndian); this.sgd.endpointCount = sgdReader.nextUint16(); this.sgd.selectorCount = sgdReader.nextUint16(); this.sgd.endpointsByteLength = sgdReader.nextUint32(); this.sgd.selectorsByteLength = sgdReader.nextUint32(); this.sgd.tablesByteLength = sgdReader.nextUint32(); this.sgd.extendedByteLength = sgdReader.nextUint32(); this.sgd.imageDescs = []; this.sgd.endpointsData = null; this.sgd.selectorsData = null; this.sgd.tablesData = null; this.sgd.extendedData = null; for (var i = 0; i < this.header.levelCount; i++) { this.sgd.imageDescs.push({ imageFlags: sgdReader.nextUint32(), rgbSliceByteOffset: sgdReader.nextUint32(), rgbSliceByteLength: sgdReader.nextUint32(), alphaSliceByteOffset: sgdReader.nextUint32(), alphaSliceByteLength: sgdReader.nextUint32() }); } var endpointsByteOffset = this.header.sgdByteOffset + sgdReader.offset; var selectorsByteOffset = endpointsByteOffset + this.sgd.endpointsByteLength; var tablesByteOffset = selectorsByteOffset + this.sgd.selectorsByteLength; var extendedByteOffset = tablesByteOffset + this.sgd.tablesByteLength; this.sgd.endpointsData = new Uint8Array(this.arrayBuffer, endpointsByteOffset, this.sgd.endpointsByteLength); this.sgd.selectorsData = new Uint8Array(this.arrayBuffer, selectorsByteOffset, this.sgd.selectorsByteLength); this.sgd.tablesData = new Uint8Array(this.arrayBuffer, tablesByteOffset, this.sgd.tablesByteLength); this.sgd.extendedData = new Uint8Array(this.arrayBuffer, extendedByteOffset, this.sgd.extendedByteLength); } _createClass(KTX2Container, [{ key: "initMipmaps", value: function () { var _initMipmaps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(transcoder, config) { var TranscodeTarget, TextureFormat, ImageInfo, scope, mipmaps, width, height, texFormat, hasAlpha, isVideo, pvrtcTranscodable, numEndpoints, numSelectors, endpoints, selectors, tables, targetFormat, imageDescIndex, level, levelWidth, levelHeight, numImagesInLevel, imageOffsetInLevel, imageInfo, levelByteLength, levelUncompressedByteLength, imageIndex, result, encodedData, imageDesc, levelData; return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.next = 2; return this.zstd.init(); case 2: TranscodeTarget = this.basisModule.TranscodeTarget; TextureFormat = this.basisModule.TextureFormat; ImageInfo = this.basisModule.ImageInfo; scope = this; mipmaps = []; width = this.getWidth(); height = this.getHeight(); texFormat = this.getTexFormat(); hasAlpha = this.getAlpha(); isVideo = false; // PVRTC1 transcoders (from both ETC1S and UASTC) only support power of 2 dimensions. pvrtcTranscodable = MathUtils.isPowerOfTwo(width) && MathUtils.isPowerOfTwo(height); if (texFormat === TextureFormat.ETC1S) { numEndpoints = this.sgd.endpointCount; numSelectors = this.sgd.selectorCount; endpoints = this.sgd.endpointsData; selectors = this.sgd.selectorsData; tables = this.sgd.tablesData; transcoder.decodePalettes(numEndpoints, endpoints, numSelectors, selectors); transcoder.decodeTables(tables); } if (config.astcSupported) { targetFormat = TranscodeTarget.ASTC_4x4_RGBA; this.transcodedFormat = RGBA_ASTC_4x4_Format; } else if (config.bptcSupported && texFormat === TextureFormat.UASTC4x4) { targetFormat = TranscodeTarget.BC7_M5_RGBA; this.transcodedFormat = RGBA_BPTC_Format; } else if (config.dxtSupported) { targetFormat = hasAlpha ? TranscodeTarget.BC3_RGBA : TranscodeTarget.BC1_RGB; this.transcodedFormat = hasAlpha ? RGBA_S3TC_DXT5_Format : RGB_S3TC_DXT1_Format; } else if (config.pvrtcSupported && pvrtcTranscodable) { targetFormat = hasAlpha ? TranscodeTarget.PVRTC1_4_RGBA : TranscodeTarget.PVRTC1_4_RGB; this.transcodedFormat = hasAlpha ? RGBA_PVRTC_4BPPV1_Format : RGB_PVRTC_4BPPV1_Format; } else if (config.etc2Supported) { targetFormat = hasAlpha ? TranscodeTarget.ETC2_RGBA : TranscodeTarget.ETC1_RGB /* subset of ETC2 */ ; this.transcodedFormat = hasAlpha ? RGBA_ETC2_EAC_Format : RGB_ETC2_Format; } else if (config.etc1Supported) { targetFormat = TranscodeTarget.ETC1_RGB; this.transcodedFormat = RGB_ETC1_Format; } else { console.warn('THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32.'); targetFormat = TranscodeTarget.RGBA32; this.transcodedFormat = RGBAFormat; } if (this.basisModule.isFormatSupported(targetFormat, texFormat)) { _context.next = 17; break; } throw new Error('THREE.KTX2Loader: Selected texture format not supported by current transcoder build.'); case 17: imageDescIndex = 0; level = 0; case 19: if (!(level < this.header.levelCount)) { _context.next = 42; break; } levelWidth = width / Math.pow(2, level); levelHeight = height / Math.pow(2, level); numImagesInLevel = 1; // TODO(donmccurdy): Support cubemaps, arrays and 3D. imageOffsetInLevel = 0; imageInfo = new ImageInfo(texFormat, levelWidth, levelHeight, level); levelByteLength = this.levels[level].byteLength; levelUncompressedByteLength = this.levels[level].uncompressedByteLength; imageIndex = 0; case 28: if (!(imageIndex < numImagesInLevel)) { _context.next = 39; break; } if (texFormat === TextureFormat.UASTC4x4) { // UASTC imageInfo.flags = 0; imageInfo.rgbByteOffset = 0; imageInfo.rgbByteLength = levelUncompressedByteLength; imageInfo.alphaByteOffset = 0; imageInfo.alphaByteLength = 0; encodedData = new Uint8Array(this.arrayBuffer, this.levels[level].byteOffset + imageOffsetInLevel, levelByteLength); if (this.header.supercompressionScheme === 2 /* ZSTD */ ) { encodedData = this.zstd.decode(encodedData, levelUncompressedByteLength); } result = transcoder.transcodeImage(targetFormat, encodedData, imageInfo, 0, hasAlpha, isVideo); } else { // ETC1S imageDesc = this.sgd.imageDescs[imageDescIndex++]; imageInfo.flags = imageDesc.imageFlags; imageInfo.rgbByteOffset = 0; imageInfo.rgbByteLength = imageDesc.rgbSliceByteLength; imageInfo.alphaByteOffset = imageDesc.alphaSliceByteOffset > 0 ? imageDesc.rgbSliceByteLength : 0; imageInfo.alphaByteLength = imageDesc.alphaSliceByteLength; encodedData = new Uint8Array(this.arrayBuffer, this.levels[level].byteOffset + imageDesc.rgbSliceByteOffset, imageDesc.rgbSliceByteLength + imageDesc.alphaSliceByteLength); result = transcoder.transcodeImage(targetFormat, encodedData, imageInfo, 0, isVideo); } if (!(result.transcodedImage === undefined)) { _context.next = 32; break; } throw new Error('THREE.KTX2Loader: Unable to transcode image.'); case 32: // Transcoded image is written in memory allocated by WASM. We could avoid copying // the image by waiting until the image is uploaded to the GPU, then calling // delete(). However, (1) we don't know if the user will later need to re-upload it // e.g. after calling texture.clone(), and (2) this code will eventually be in a // Web Worker, and transferring WASM's memory seems like a very bad idea. levelData = result.transcodedImage.get_typed_memory_view().slice(); result.transcodedImage["delete"](); mipmaps.push({ data: levelData, width: levelWidth, height: levelHeight }); imageOffsetInLevel += levelByteLength; case 36: imageIndex++; _context.next = 28; break; case 39: level++; _context.next = 19; break; case 42: scope.mipmaps = mipmaps; case 43: case "end": return _context.stop(); } } }, _callee, this); })); function initMipmaps(_x, _x2) { return _initMipmaps.apply(this, arguments); } return initMipmaps; }() }, { key: "getWidth", value: function getWidth() { return this.header.pixelWidth; } }, { key: "getHeight", value: function getHeight() { return this.header.pixelHeight; } }, { key: "getEncoding", value: function getEncoding() { return this.dfd.transferFunction === 2 /* KHR_DF_TRANSFER_SRGB */ ? sRGBEncoding : LinearEncoding; } }, { key: "getTexFormat", value: function getTexFormat() { var TextureFormat = this.basisModule.TextureFormat; return this.dfd.colorModel === DFDModel.UASTC ? TextureFormat.UASTC4x4 : TextureFormat.ETC1S; } }, { key: "getAlpha", value: function getAlpha() { var TextureFormat = this.basisModule.TextureFormat; // TODO(donmccurdy): Handle all channelIDs (i.e. the R & R+G cases), // choosing appropriate transcode target formats or providing queries // for applications so they know what to do with the content. if (this.getTexFormat() === TextureFormat.UASTC4x4) { // UASTC if ((this.dfd.samples[0].channelID & 0xF) === DFDChannel.UASTC.RGBA) { return true; } return false; } // ETC1S if (this.dfd.numSamples === 2 && (this.dfd.samples[1].channelID & 0xF) === DFDChannel.ETC1S.AAA) { return true; } return false; } }, { key: "getPremultiplyAlpha", value: function getPremultiplyAlpha() { return !!(this.dfd.flags & 1 /* KHR_DF_FLAG_ALPHA_PREMULTIPLIED */ ); } }]); return KTX2Container; }(); var KTX2BufferReader = /*#__PURE__*/function () { function KTX2BufferReader(arrayBuffer, byteOffset, byteLength, littleEndian) { _classCallCheck(this, KTX2BufferReader); this.dataView = new DataView(arrayBuffer, byteOffset, byteLength); this.littleEndian = littleEndian; this.offset = 0; } _createClass(KTX2BufferReader, [{ key: "nextUint8", value: function nextUint8() { var value = this.dataView.getUint8(this.offset, this.littleEndian); this.offset += 1; return value; } }, { key: "nextUint16", value: function nextUint16() { var value = this.dataView.getUint16(this.offset, this.littleEndian); this.offset += 2; return value; } }, { key: "nextUint32", value: function nextUint32() { var value = this.dataView.getUint32(this.offset, this.littleEndian); this.offset += 4; return value; } }, { key: "nextUint64", value: function nextUint64() { // https://stackoverflow.com/questions/53103695/ var left = this.dataView.getUint32(this.offset, this.littleEndian); var right = this.dataView.getUint32(this.offset + 4, this.littleEndian); var value = this.littleEndian ? left + Math.pow(2, 32) * right : Math.pow(2, 32) * left + right; if (!_Number$isSafeInteger(value)) { console.warn('THREE.KTX2Loader: ' + value + ' exceeds MAX_SAFE_INTEGER. Precision may be lost.'); } this.offset += 8; return value; } }, { key: "skip", value: function skip(bytes) { this.offset += bytes; return this; } }]); return KTX2BufferReader; }(); export { KTX2Loader };