x_ite 9.4.4 → 9.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +19 -5
  2. package/dist/assets/components/Annotation.js +13 -13
  3. package/dist/assets/components/Annotation.min.js +1 -1
  4. package/dist/assets/components/CADGeometry.js +33 -17
  5. package/dist/assets/components/CADGeometry.min.js +1 -1
  6. package/dist/assets/components/CubeMapTexturing.js +25 -25
  7. package/dist/assets/components/CubeMapTexturing.min.js +1 -1
  8. package/dist/assets/components/DIS.js +13 -13
  9. package/dist/assets/components/DIS.min.js +1 -1
  10. package/dist/assets/components/EventUtilities.js +9 -9
  11. package/dist/assets/components/EventUtilities.min.js +1 -1
  12. package/dist/assets/components/Geometry2D.js +20 -20
  13. package/dist/assets/components/Geometry2D.min.js +1 -1
  14. package/dist/assets/components/Geospatial.js +45 -60
  15. package/dist/assets/components/Geospatial.min.js +1 -1
  16. package/dist/assets/components/HAnim.js +37 -34
  17. package/dist/assets/components/HAnim.min.js +1 -1
  18. package/dist/assets/components/KeyDeviceSensor.js +8 -8
  19. package/dist/assets/components/KeyDeviceSensor.min.js +1 -1
  20. package/dist/assets/components/Layout.js +27 -27
  21. package/dist/assets/components/Layout.min.js +1 -1
  22. package/dist/assets/components/NURBS.js +23 -23
  23. package/dist/assets/components/NURBS.min.js +1 -1
  24. package/dist/assets/components/ParticleSystems.js +107 -155
  25. package/dist/assets/components/ParticleSystems.min.js +1 -1
  26. package/dist/assets/components/Picking.js +18 -18
  27. package/dist/assets/components/Picking.min.js +1 -1
  28. package/dist/assets/components/RigidBodyPhysics.js +17 -17
  29. package/dist/assets/components/RigidBodyPhysics.min.js +1 -1
  30. package/dist/assets/components/Scripting.js +38 -38
  31. package/dist/assets/components/Scripting.min.js +1 -1
  32. package/dist/assets/components/Text.js +24 -24
  33. package/dist/assets/components/Text.min.js +1 -1
  34. package/dist/assets/components/TextureProjection.js +15 -15
  35. package/dist/assets/components/TextureProjection.min.js +1 -1
  36. package/dist/assets/components/Texturing3D.js +1956 -2567
  37. package/dist/assets/components/Texturing3D.min.js +1 -1
  38. package/dist/assets/components/VolumeRendering.js +19 -19
  39. package/dist/assets/components/VolumeRendering.min.js +1 -1
  40. package/dist/assets/components/X_ITE.js +303 -8
  41. package/dist/assets/components/X_ITE.min.js +1 -1
  42. package/dist/assets/lib/libktx.js +1 -1
  43. package/dist/x_ite.css +1 -1
  44. package/dist/x_ite.js +1264 -866
  45. package/dist/x_ite.min.js +1 -1
  46. package/dist/x_ite.min.mjs +1 -1
  47. package/dist/x_ite.mjs +1264 -866
  48. package/dist/x_ite.zip +0 -0
  49. package/package.json +6 -6
@@ -1,7 +1,7 @@
1
- /* X_ITE v9.4.4 */(() => { // webpackBootstrap
1
+ /* X_ITE v9.5.0 */(() => { // webpackBootstrap
2
2
  /******/ var __webpack_modules__ = ({
3
3
 
4
- /***/ 544:
4
+ /***/ 470:
5
5
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6
6
 
7
7
  var __dirname = "/";
@@ -38,7 +38,7 @@ var Ib=[cx,_q,cr,Yr,as,fs,hs,Hu,Su,cx,cx,cx,cx,cx,cx,cx];var Jb=[dx,si,gi,Wh,Kh,
38
38
 
39
39
  /***/ }),
40
40
 
41
- /***/ 154:
41
+ /***/ 976:
42
42
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
43
43
 
44
44
  var __dirname = "/";
@@ -72,7 +72,7 @@ var _a=[yj,od,ef,yj];var $a=[zj,Li,di,bi,Kb,Lb,Mb,Nb,Rc,Sc,Uc,jd,xd,Ye,lf,yd,zd,
72
72
 
73
73
  /***/ }),
74
74
 
75
- /***/ 706:
75
+ /***/ 44:
76
76
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
77
77
 
78
78
  /*! dicom-parser - 1.8.12 - 2023-02-20 | (c) 2017 Chris Hafey | https://github.com/cornerstonejs/dicomParser */
@@ -4028,7 +4028,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_zlib__;
4028
4028
 
4029
4029
  /***/ }),
4030
4030
 
4031
- /***/ 306:
4031
+ /***/ 80:
4032
4032
  /***/ ((module) => {
4033
4033
 
4034
4034
  /* -*- tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
@@ -5183,2774 +5183,2161 @@ function decode(jpegData, userOpts = {}) {
5183
5183
 
5184
5184
  /***/ }),
5185
5185
 
5186
- /***/ 490:
5186
+ /***/ 823:
5187
5187
  /***/ ((module) => {
5188
5188
 
5189
- (function(f){if(true){module.exports=f()}else { var g; }})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=undefined;if(!f&&c)return require(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u=undefined,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
5190
- /*
5191
- * Copyright (C) 2015 Michael Martinez
5192
- * Changes: Added support for selection values 2-7, fixed minor bugs &
5193
- * warnings, split into multiple class files, and general clean up.
5194
- *
5195
- * 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.
5196
- */
5197
-
5198
- /*
5199
- * Copyright (C) Helmut Dersch
5200
- *
5201
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5202
- * of this software and associated documentation files (the "Software"), to deal
5203
- * in the Software without restriction, including without limitation the rights
5204
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5205
- * copies of the Software, and to permit persons to whom the Software is
5206
- * furnished to do so, subject to the following conditions:
5207
-
5208
- * The above copyright notice and this permission notice shall be included in
5209
- * all copies or substantial portions of the Software.
5210
-
5211
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5212
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5213
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5214
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5215
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5216
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
5217
- * THE SOFTWARE.
5218
- */
5219
-
5220
- /*jslint browser: true, node: true */
5221
- /*global require, module */
5222
-
5223
5189
  "use strict";
5190
+ module.exports = window [Symbol .for ("X_ITE.X3D-9.5.0")] .require ("lib/jquery");
5224
5191
 
5225
- /*** Imports ***/
5226
- var jpeg = jpeg || {};
5227
- jpeg.lossless = jpeg.lossless || {};
5192
+ /***/ }),
5228
5193
 
5194
+ /***/ 497:
5195
+ /***/ (() => {
5229
5196
 
5230
- /*** Constructor ***/
5231
- jpeg.lossless.ComponentSpec = jpeg.lossless.ComponentSpec || function () {
5232
- this.hSamp = 0; // Horizontal sampling factor
5233
- this.quantTableSel = 0; // Quantization table destination selector
5234
- this.vSamp = 0; // Vertical
5235
- };
5197
+ /* (ignored) */
5236
5198
 
5199
+ /***/ }),
5237
5200
 
5238
- /*** Exports ***/
5201
+ /***/ 13:
5202
+ /***/ (() => {
5239
5203
 
5240
- var moduleType = typeof module;
5241
- if ((moduleType !== 'undefined') && module.exports) {
5242
- module.exports = jpeg.lossless.ComponentSpec;
5243
- }
5204
+ /* (ignored) */
5244
5205
 
5245
- },{}],2:[function(require,module,exports){
5246
- /*
5247
- * Copyright (C) 2015 Michael Martinez
5248
- * Changes: Added support for selection values 2-7, fixed minor bugs &
5249
- * warnings, split into multiple class files, and general clean up.
5250
- *
5251
- * 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.
5252
- */
5206
+ /***/ }),
5253
5207
 
5254
- /*
5255
- * Copyright (C) Helmut Dersch
5256
- *
5257
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5258
- * of this software and associated documentation files (the "Software"), to deal
5259
- * in the Software without restriction, including without limitation the rights
5260
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5261
- * copies of the Software, and to permit persons to whom the Software is
5262
- * furnished to do so, subject to the following conditions:
5263
-
5264
- * The above copyright notice and this permission notice shall be included in
5265
- * all copies or substantial portions of the Software.
5266
-
5267
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5268
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5269
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5270
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5271
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5272
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
5273
- * THE SOFTWARE.
5274
- */
5208
+ /***/ 722:
5209
+ /***/ (() => {
5275
5210
 
5276
- /*jslint browser: true, node: true */
5277
- /*global require, module */
5211
+ /* (ignored) */
5278
5212
 
5279
- "use strict";
5213
+ /***/ }),
5280
5214
 
5281
- /*** Imports ***/
5282
- var jpeg = jpeg || {};
5283
- jpeg.lossless = jpeg.lossless || {};
5215
+ /***/ 978:
5216
+ /***/ (() => {
5284
5217
 
5218
+ /* (ignored) */
5285
5219
 
5286
- /*** Constructor ***/
5287
- jpeg.lossless.DataStream = jpeg.lossless.DataStream || function (data, offset, length) {
5288
- if (offset === undefined && length === undefined) { // Old api
5289
- this.buffer = new Uint8Array(data);
5290
- } else {
5291
- this.buffer = new Uint8Array(data, offset, length);
5292
- }
5293
- this.index = 0;
5294
- };
5220
+ /***/ }),
5295
5221
 
5222
+ /***/ 559:
5223
+ /***/ (() => {
5296
5224
 
5225
+ /* (ignored) */
5297
5226
 
5298
- jpeg.lossless.DataStream.prototype.get16 = function () {
5299
- // var value = this.buffer.getUint16(this.index, false);
5300
- var value = (this.buffer[this.index] << 8) + this.buffer[this.index + 1]; // DataView is big-endian by default
5301
- this.index += 2;
5302
- return value;
5303
- };
5227
+ /***/ })
5304
5228
 
5229
+ /******/ });
5230
+ /************************************************************************/
5231
+ /******/ // The module cache
5232
+ /******/ var __webpack_module_cache__ = {};
5233
+ /******/
5234
+ /******/ // The require function
5235
+ /******/ function __webpack_require__(moduleId) {
5236
+ /******/ // Check if module is in cache
5237
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
5238
+ /******/ if (cachedModule !== undefined) {
5239
+ /******/ return cachedModule.exports;
5240
+ /******/ }
5241
+ /******/ // Create a new module (and put it into the cache)
5242
+ /******/ var module = __webpack_module_cache__[moduleId] = {
5243
+ /******/ // no module.id needed
5244
+ /******/ // no module.loaded needed
5245
+ /******/ exports: {}
5246
+ /******/ };
5247
+ /******/
5248
+ /******/ // Execute the module function
5249
+ /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
5250
+ /******/
5251
+ /******/ // Return the exports of the module
5252
+ /******/ return module.exports;
5253
+ /******/ }
5254
+ /******/
5255
+ /************************************************************************/
5256
+ /******/ /* webpack/runtime/compat get default export */
5257
+ /******/ (() => {
5258
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
5259
+ /******/ __webpack_require__.n = (module) => {
5260
+ /******/ var getter = module && module.__esModule ?
5261
+ /******/ () => (module['default']) :
5262
+ /******/ () => (module);
5263
+ /******/ __webpack_require__.d(getter, { a: getter });
5264
+ /******/ return getter;
5265
+ /******/ };
5266
+ /******/ })();
5267
+ /******/
5268
+ /******/ /* webpack/runtime/define property getters */
5269
+ /******/ (() => {
5270
+ /******/ // define getter functions for harmony exports
5271
+ /******/ __webpack_require__.d = (exports, definition) => {
5272
+ /******/ for(var key in definition) {
5273
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
5274
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
5275
+ /******/ }
5276
+ /******/ }
5277
+ /******/ };
5278
+ /******/ })();
5279
+ /******/
5280
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
5281
+ /******/ (() => {
5282
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
5283
+ /******/ })();
5284
+ /******/
5285
+ /************************************************************************/
5286
+ var __webpack_exports__ = {};
5287
+ // This entry need to be wrapped in an IIFE because it need to be in strict mode.
5288
+ (() => {
5289
+ "use strict";
5305
5290
 
5291
+ // UNUSED EXPORTS: default
5306
5292
 
5307
- jpeg.lossless.DataStream.prototype.get8 = function () {
5308
- // var value = this.buffer.getUint8(this.index);
5309
- var value = this.buffer[this.index];
5310
- this.index += 1;
5311
- return value;
5312
- };
5293
+ ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Components\")"
5294
+ const Components_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.0")] .require ("x_ite/Components");
5295
+ var Components_default = /*#__PURE__*/__webpack_require__.n(Components_namespaceObject);
5296
+ ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Fields\")"
5297
+ const Fields_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.0")] .require ("x_ite/Fields");
5298
+ var Fields_default = /*#__PURE__*/__webpack_require__.n(Fields_namespaceObject);
5299
+ ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Base/X3DFieldDefinition\")"
5300
+ const X3DFieldDefinition_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.0")] .require ("x_ite/Base/X3DFieldDefinition");
5301
+ var X3DFieldDefinition_default = /*#__PURE__*/__webpack_require__.n(X3DFieldDefinition_namespaceObject);
5302
+ ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Base/FieldDefinitionArray\")"
5303
+ const FieldDefinitionArray_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.0")] .require ("x_ite/Base/FieldDefinitionArray");
5304
+ var FieldDefinitionArray_default = /*#__PURE__*/__webpack_require__.n(FieldDefinitionArray_namespaceObject);
5305
+ ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Components/Texturing/X3DSingleTextureNode\")"
5306
+ const X3DSingleTextureNode_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.0")] .require ("x_ite/Components/Texturing/X3DSingleTextureNode");
5307
+ var X3DSingleTextureNode_default = /*#__PURE__*/__webpack_require__.n(X3DSingleTextureNode_namespaceObject);
5308
+ ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Base/X3DConstants\")"
5309
+ const X3DConstants_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.0")] .require ("x_ite/Base/X3DConstants");
5310
+ var X3DConstants_default = /*#__PURE__*/__webpack_require__.n(X3DConstants_namespaceObject);
5311
+ ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Namespace\")"
5312
+ const Namespace_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.0")] .require ("x_ite/Namespace");
5313
+ var Namespace_default = /*#__PURE__*/__webpack_require__.n(Namespace_namespaceObject);
5314
+ ;// CONCATENATED MODULE: ./src/x_ite/Components/Texturing3D/X3DTexture3DNode.js
5315
+ /*******************************************************************************
5316
+ *
5317
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5318
+ *
5319
+ * Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022.
5320
+ *
5321
+ * All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
5322
+ *
5323
+ * The copyright notice above does not evidence any actual of intended
5324
+ * publication of such source code, and is an unpublished work by create3000.
5325
+ * This material contains CONFIDENTIAL INFORMATION that is the property of
5326
+ * create3000.
5327
+ *
5328
+ * No permission is granted to copy, distribute, or create derivative works from
5329
+ * the contents of this software, in whole or in part, without the prior written
5330
+ * permission of create3000.
5331
+ *
5332
+ * NON-MILITARY USE ONLY
5333
+ *
5334
+ * All create3000 software are effectively free software with a non-military use
5335
+ * restriction. It is free. Well commented source is provided. You may reuse the
5336
+ * source in any way you please with the exception anything that uses it must be
5337
+ * marked to indicate is contains 'non-military use only' components.
5338
+ *
5339
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5340
+ *
5341
+ * Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>.
5342
+ *
5343
+ * This file is part of the X_ITE Project.
5344
+ *
5345
+ * X_ITE is free software: you can redistribute it and/or modify it under the
5346
+ * terms of the GNU General Public License version 3 only, as published by the
5347
+ * Free Software Foundation.
5348
+ *
5349
+ * X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
5350
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
5351
+ * A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
5352
+ * details (a copy is included in the LICENSE file that accompanied this code).
5353
+ *
5354
+ * You should have received a copy of the GNU General Public License version 3
5355
+ * along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a
5356
+ * copy of the GPLv3 License.
5357
+ *
5358
+ * For Silvio, Joy and Adi.
5359
+ *
5360
+ ******************************************************************************/
5313
5361
 
5314
5362
 
5315
- /*** Exports ***/
5316
5363
 
5317
- var moduleType = typeof module;
5318
- if ((moduleType !== 'undefined') && module.exports) {
5319
- module.exports = jpeg.lossless.DataStream;
5320
- }
5321
5364
 
5322
- },{}],3:[function(require,module,exports){
5323
- /*
5324
- * Copyright (C) 2015 Michael Martinez
5325
- * Changes: Added support for selection values 2-7, fixed minor bugs &
5326
- * warnings, split into multiple class files, and general clean up.
5327
- *
5328
- * 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.
5329
- */
5365
+ const defaultData = new Uint8Array ([ 255, 255, 255, 255 ]);
5330
5366
 
5331
- /*
5332
- * Copyright (C) Helmut Dersch
5333
- *
5334
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5335
- * of this software and associated documentation files (the "Software"), to deal
5336
- * in the Software without restriction, including without limitation the rights
5337
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5338
- * copies of the Software, and to permit persons to whom the Software is
5339
- * furnished to do so, subject to the following conditions:
5340
-
5341
- * The above copyright notice and this permission notice shall be included in
5342
- * all copies or substantial portions of the Software.
5343
-
5344
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5345
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5346
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5347
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5348
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5349
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
5350
- * THE SOFTWARE.
5351
- */
5367
+ function X3DTexture3DNode (executionContext)
5368
+ {
5369
+ X3DSingleTextureNode_default().call (this, executionContext);
5352
5370
 
5353
- /*jslint browser: true, node: true */
5354
- /*global require, module */
5371
+ this .addType ((X3DConstants_default()).X3DTexture3DNode);
5355
5372
 
5356
- "use strict";
5373
+ const gl = this .getBrowser () .getContext ();
5357
5374
 
5358
- /*** Imports ***/
5359
- var jpeg = jpeg || {};
5360
- jpeg.lossless = jpeg.lossless || {};
5361
- jpeg.lossless.DataStream = jpeg.lossless.DataStream || ((typeof require !== 'undefined') ? require('./data-stream.js') : null);
5362
- jpeg.lossless.HuffmanTable = jpeg.lossless.HuffmanTable || ((typeof require !== 'undefined') ? require('./huffman-table.js') : null);
5363
- jpeg.lossless.QuantizationTable = jpeg.lossless.QuantizationTable || ((typeof require !== 'undefined') ? require('./quantization-table.js') : null);
5364
- jpeg.lossless.ScanHeader = jpeg.lossless.ScanHeader || ((typeof require !== 'undefined') ? require('./scan-header.js') : null);
5365
- jpeg.lossless.FrameHeader = jpeg.lossless.FrameHeader || ((typeof require !== 'undefined') ? require('./frame-header.js') : null);
5366
- jpeg.lossless.Utils = jpeg.lossless.Utils || ((typeof require !== 'undefined') ? require('./utils.js') : null);
5375
+ this .target = gl .TEXTURE_3D;
5376
+ this .width = 0;
5377
+ this .height = 0;
5378
+ this .depth = 0;
5379
+ }
5367
5380
 
5381
+ Object .assign (Object .setPrototypeOf (X3DTexture3DNode .prototype, (X3DSingleTextureNode_default()).prototype),
5382
+ {
5383
+ initialize ()
5384
+ {
5385
+ X3DSingleTextureNode_default().prototype .initialize .call (this);
5368
5386
 
5369
- /*** Constructor ***/
5387
+ this ._repeatS .addInterest ("updateTextureParameters", this);
5388
+ this ._repeatT .addInterest ("updateTextureParameters", this);
5389
+ this ._repeatR .addInterest ("updateTextureParameters", this);
5370
5390
 
5371
- /**
5372
- * The Decoder constructor.
5373
- * @property {number} xDim - size of x dimension
5374
- * @property {number} yDim - size of y dimension
5375
- * @property {number} numComp - number of components
5376
- * @property {number} numBytes - number of bytes per component
5377
- * @type {Function}
5378
- */
5379
- jpeg.lossless.Decoder = jpeg.lossless.Decoder || function (buffer, numBytes) {
5380
- this.buffer = buffer;
5381
- this.frame = new jpeg.lossless.FrameHeader();
5382
- this.huffTable = new jpeg.lossless.HuffmanTable();
5383
- this.quantTable = new jpeg.lossless.QuantizationTable();
5384
- this.scan = new jpeg.lossless.ScanHeader();
5385
- this.DU = jpeg.lossless.Utils.createArray(10, 4, 64); // at most 10 data units in a MCU, at most 4 data units in one component
5386
- this.HuffTab = jpeg.lossless.Utils.createArray(4, 2, 50 * 256);
5387
- this.IDCT_Source = [];
5388
- this.nBlock = []; // number of blocks in the i-th Comp in a scan
5389
- this.acTab = jpeg.lossless.Utils.createArray(10, 1); // ac HuffTab for the i-th Comp in a scan
5390
- this.dcTab = jpeg.lossless.Utils.createArray(10, 1); // dc HuffTab for the i-th Comp in a scan
5391
- this.qTab = jpeg.lossless.Utils.createArray(10, 1); // quantization table for the i-th Comp in a scan
5392
- this.marker = 0;
5393
- this.markerIndex = 0;
5394
- this.numComp = 0;
5395
- this.restartInterval = 0;
5396
- this.selection = 0;
5397
- this.xDim = 0;
5398
- this.yDim = 0;
5399
- this.xLoc = 0;
5400
- this.yLoc = 0;
5401
- this.numBytes = 0;
5402
- this.outputData = null;
5403
- this.restarting = false;
5404
- this.mask = 0;
5391
+ const gl = this .getBrowser () .getContext ();
5405
5392
 
5406
- if (typeof numBytes !== "undefined") {
5407
- this.numBytes = numBytes;
5408
- }
5409
- };
5393
+ if (gl .getVersion () < 2)
5394
+ return;
5410
5395
 
5396
+ gl .bindTexture (gl .TEXTURE_3D, this .getTexture ());
5397
+ gl .texImage3D (gl .TEXTURE_3D, 0, gl .RGBA, 1, 1, 1, 0, gl .RGBA, gl .UNSIGNED_BYTE, defaultData);
5398
+ },
5399
+ getTarget ()
5400
+ {
5401
+ return this .target;
5402
+ },
5403
+ getTextureType ()
5404
+ {
5405
+ return 3;
5406
+ },
5407
+ getWidth ()
5408
+ {
5409
+ return this .width;
5410
+ },
5411
+ setWidth (value)
5412
+ {
5413
+ this .width = value;
5414
+ },
5415
+ getHeight ()
5416
+ {
5417
+ return this .height;
5418
+ },
5419
+ setHeight (value)
5420
+ {
5421
+ this .height = value;
5422
+ },
5423
+ getDepth ()
5424
+ {
5425
+ return this .depth;
5426
+ },
5427
+ setDepth (value)
5428
+ {
5429
+ this .depth = value;
5430
+ },
5431
+ clearTexture ()
5432
+ {
5433
+ const gl = this .getBrowser () .getContext ();
5411
5434
 
5412
- /*** Static Pseudo-constants ***/
5435
+ this .setTextureFromData (1, 1, 1, false, gl .RGBA, defaultData);
5436
+ },
5437
+ setTextureFromData (width, height, depth, transparent, format, data)
5438
+ {
5439
+ this .width = width;
5440
+ this .height = height;
5441
+ this .depth = depth;
5413
5442
 
5414
- jpeg.lossless.Decoder.IDCT_P = [0, 5, 40, 16, 45, 2, 7, 42, 21, 56, 8, 61, 18, 47, 1, 4, 41, 23, 58, 13, 32, 24, 37, 10, 63, 17, 44, 3, 6, 43, 20,
5415
- 57, 15, 34, 29, 48, 53, 26, 39, 9, 60, 19, 46, 22, 59, 12, 33, 31, 50, 55, 25, 36, 11, 62, 14, 35, 28, 49, 52, 27, 38, 30, 51, 54];
5416
- jpeg.lossless.Decoder.TABLE = [0, 1, 5, 6, 14, 15, 27, 28, 2, 4, 7, 13, 16, 26, 29, 42, 3, 8, 12, 17, 25, 30, 41, 43, 9, 11, 18, 24, 31, 40, 44, 53,
5417
- 10, 19, 23, 32, 39, 45, 52, 54, 20, 22, 33, 38, 46, 51, 55, 60, 21, 34, 37, 47, 50, 56, 59, 61, 35, 36, 48, 49, 57, 58, 62, 63];
5418
- jpeg.lossless.Decoder.MAX_HUFFMAN_SUBTREE = 50;
5419
- jpeg.lossless.Decoder.MSB = 0x80000000;
5420
- jpeg.lossless.Decoder.RESTART_MARKER_BEGIN = 0xFFD0;
5421
- jpeg.lossless.Decoder.RESTART_MARKER_END = 0xFFD7;
5443
+ const gl = this .getBrowser () .getContext ();
5422
5444
 
5423
- /*** Prototype Methods ***/
5445
+ if (gl .getVersion () < 2)
5446
+ return;
5424
5447
 
5425
- /**
5426
- * Returns decompressed data.
5427
- * @param {ArrayBuffer} buffer
5428
- * @param {number} [offset]
5429
- * @param {number} [length]
5430
- * @returns {ArrayBufer}
5431
- */
5432
- jpeg.lossless.Decoder.prototype.decompress = function (buffer, offset, length) {
5433
- return this.decode(buffer, offset, length).buffer;
5434
- };
5435
-
5436
-
5437
-
5438
- jpeg.lossless.Decoder.prototype.decode = function (buffer, offset, length, numBytes) {
5439
- /*jslint bitwise: true */
5448
+ gl .bindTexture (gl .TEXTURE_3D, this .getTexture ());
5449
+ gl .texImage3D (gl .TEXTURE_3D, 0, format, width, height, depth, 0, format, gl .UNSIGNED_BYTE, data);
5440
5450
 
5441
- var current, scanNum = 0, pred = [], i, compN, temp = [], index = [], mcuNum;
5451
+ this .setTransparent (transparent);
5452
+ this .updateTextureParameters ();
5453
+ this .addNodeEvent ();
5454
+ },
5455
+ updateTextureParameters ()
5456
+ {
5457
+ X3DSingleTextureNode_default().prototype .updateTextureParameters .call (this,
5458
+ this .target,
5459
+ this ._textureProperties .getValue (),
5460
+ this .texturePropertiesNode,
5461
+ this .width,
5462
+ this .height,
5463
+ this ._repeatS .getValue (),
5464
+ this ._repeatT .getValue (),
5465
+ this ._repeatR .getValue ());
5466
+ },
5467
+ setShaderUniforms (gl, shaderObject, renderObject, channel = shaderObject .x3d_Texture [0])
5468
+ {
5469
+ const textureUnit = this .getBrowser () .getTexture3DUnit ();
5442
5470
 
5443
- if (typeof buffer !== "undefined") {
5444
- this.buffer = buffer;
5445
- }
5471
+ gl .activeTexture (gl .TEXTURE0 + textureUnit);
5472
+ gl .bindTexture (gl .TEXTURE_3D, this .getTexture ());
5473
+ gl .uniform1i (channel .texture3D, textureUnit);
5474
+ },
5475
+ });
5446
5476
 
5447
- if (typeof numBytes !== "undefined") {
5448
- this.numBytes = numBytes;
5449
- }
5477
+ Object .defineProperties (X3DTexture3DNode,
5478
+ {
5479
+ typeName:
5480
+ {
5481
+ value: "X3DTexture3DNode",
5482
+ enumerable: true,
5483
+ },
5484
+ componentInfo:
5485
+ {
5486
+ value: Object .freeze ({ name: "Texturing3D", level: 1 }),
5487
+ enumerable: true,
5488
+ },
5489
+ });
5450
5490
 
5451
- this.stream = new jpeg.lossless.DataStream(this.buffer, offset, length);
5452
- this.buffer = null;
5491
+ const __default__ = X3DTexture3DNode;
5492
+ ;
5453
5493
 
5454
- this.xLoc = 0;
5455
- this.yLoc = 0;
5456
- current = this.stream.get16();
5494
+ Namespace_default().add ("X3DTexture3DNode", "x_ite/Components/Texturing3D/X3DTexture3DNode", __default__);
5495
+ /* harmony default export */ const Texturing3D_X3DTexture3DNode = (__default__);
5496
+ ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Base/X3DCast\")"
5497
+ const X3DCast_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.0")] .require ("x_ite/Base/X3DCast");
5498
+ var X3DCast_default = /*#__PURE__*/__webpack_require__.n(X3DCast_namespaceObject);
5499
+ ;// CONCATENATED MODULE: ./src/x_ite/Components/Texturing3D/ComposedTexture3D.js
5500
+ /*******************************************************************************
5501
+ *
5502
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5503
+ *
5504
+ * Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022.
5505
+ *
5506
+ * All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
5507
+ *
5508
+ * The copyright notice above does not evidence any actual of intended
5509
+ * publication of such source code, and is an unpublished work by create3000.
5510
+ * This material contains CONFIDENTIAL INFORMATION that is the property of
5511
+ * create3000.
5512
+ *
5513
+ * No permission is granted to copy, distribute, or create derivative works from
5514
+ * the contents of this software, in whole or in part, without the prior written
5515
+ * permission of create3000.
5516
+ *
5517
+ * NON-MILITARY USE ONLY
5518
+ *
5519
+ * All create3000 software are effectively free software with a non-military use
5520
+ * restriction. It is free. Well commented source is provided. You may reuse the
5521
+ * source in any way you please with the exception anything that uses it must be
5522
+ * marked to indicate is contains 'non-military use only' components.
5523
+ *
5524
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5525
+ *
5526
+ * Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>.
5527
+ *
5528
+ * This file is part of the X_ITE Project.
5529
+ *
5530
+ * X_ITE is free software: you can redistribute it and/or modify it under the
5531
+ * terms of the GNU General Public License version 3 only, as published by the
5532
+ * Free Software Foundation.
5533
+ *
5534
+ * X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
5535
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
5536
+ * A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
5537
+ * details (a copy is included in the LICENSE file that accompanied this code).
5538
+ *
5539
+ * You should have received a copy of the GNU General Public License version 3
5540
+ * along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a
5541
+ * copy of the GPLv3 License.
5542
+ *
5543
+ * For Silvio, Joy and Adi.
5544
+ *
5545
+ ******************************************************************************/
5457
5546
 
5458
- if (current !== 0xFFD8) { // SOI
5459
- throw new Error("Not a JPEG file");
5460
- }
5461
5547
 
5462
- current = this.stream.get16();
5463
5548
 
5464
- while ((((current >> 4) !== 0x0FFC) || (current === 0xFFC4))) { // SOF 0~15
5465
- switch (current) {
5466
- case 0xFFC4: // DHT
5467
- this.huffTable.read(this.stream, this.HuffTab);
5468
- break;
5469
- case 0xFFCC: // DAC
5470
- throw new Error("Program doesn't support arithmetic coding. (format throw new IOException)");
5471
- case 0xFFDB:
5472
- this.quantTable.read(this.stream, jpeg.lossless.Decoder.TABLE);
5473
- break;
5474
- case 0xFFDD:
5475
- this.restartInterval = this.readNumber();
5476
- break;
5477
- case 0xFFE0:
5478
- case 0xFFE1:
5479
- case 0xFFE2:
5480
- case 0xFFE3:
5481
- case 0xFFE4:
5482
- case 0xFFE5:
5483
- case 0xFFE6:
5484
- case 0xFFE7:
5485
- case 0xFFE8:
5486
- case 0xFFE9:
5487
- case 0xFFEA:
5488
- case 0xFFEB:
5489
- case 0xFFEC:
5490
- case 0xFFED:
5491
- case 0xFFEE:
5492
- case 0xFFEF:
5493
- this.readApp();
5494
- break;
5495
- case 0xFFFE:
5496
- this.readComment();
5497
- break;
5498
- default:
5499
- if ((current >> 8) !== 0xFF) {
5500
- throw new Error("ERROR: format throw new IOException! (decode)");
5501
- }
5502
- }
5503
5549
 
5504
- current = this.stream.get16();
5505
- }
5506
5550
 
5507
- if ((current < 0xFFC0) || (current > 0xFFC7)) {
5508
- throw new Error("ERROR: could not handle arithmetic code!");
5509
- }
5510
5551
 
5511
- this.frame.read(this.stream);
5512
- current = this.stream.get16();
5513
5552
 
5514
- do {
5515
- while (current !== 0x0FFDA) { // SOS
5516
- switch (current) {
5517
- case 0xFFC4: // DHT
5518
- this.huffTable.read(this.stream, this.HuffTab);
5519
- break;
5520
- case 0xFFCC: // DAC
5521
- throw new Error("Program doesn't support arithmetic coding. (format throw new IOException)");
5522
- case 0xFFDB:
5523
- this.quantTable.read(this.stream, jpeg.lossless.Decoder.TABLE);
5524
- break;
5525
- case 0xFFDD:
5526
- this.restartInterval = this.readNumber();
5527
- break;
5528
- case 0xFFE0:
5529
- case 0xFFE1:
5530
- case 0xFFE2:
5531
- case 0xFFE3:
5532
- case 0xFFE4:
5533
- case 0xFFE5:
5534
- case 0xFFE6:
5535
- case 0xFFE7:
5536
- case 0xFFE8:
5537
- case 0xFFE9:
5538
- case 0xFFEA:
5539
- case 0xFFEB:
5540
- case 0xFFEC:
5541
- case 0xFFED:
5542
- case 0xFFEE:
5543
- case 0xFFEF:
5544
- this.readApp();
5545
- break;
5546
- case 0xFFFE:
5547
- this.readComment();
5548
- break;
5549
- default:
5550
- if ((current >> 8) !== 0xFF) {
5551
- throw new Error("ERROR: format throw new IOException! (Parser.decode)");
5552
- }
5553
- }
5554
5553
 
5555
- current = this.stream.get16();
5556
- }
5554
+ function ComposedTexture3D (executionContext)
5555
+ {
5556
+ Texturing3D_X3DTexture3DNode .call (this, executionContext);
5557
5557
 
5558
- this.precision = this.frame.precision;
5559
- this.components = this.frame.components;
5558
+ this .addType ((X3DConstants_default()).ComposedTexture3D);
5560
5559
 
5561
- if (!this.numBytes) {
5562
- this.numBytes = parseInt(Math.ceil(this.precision / 8));
5563
- }
5560
+ this .addChildObjects ((X3DConstants_default()).inputOutput, "update", new (Fields_default()).SFTime ());
5564
5561
 
5565
- if (this.numBytes == 1) {
5566
- this.mask = 0xFF;
5567
- } else {
5568
- this.mask = 0xFFFF;
5569
- }
5562
+ this .textureNodes = [ ];
5563
+ }
5570
5564
 
5571
- this.scan.read(this.stream);
5572
- this.numComp = this.scan.numComp;
5573
- this.selection = this.scan.selection;
5565
+ Object .assign (Object .setPrototypeOf (ComposedTexture3D .prototype, Texturing3D_X3DTexture3DNode .prototype),
5566
+ {
5567
+ initialize ()
5568
+ {
5569
+ Texturing3D_X3DTexture3DNode .prototype .initialize .call (this);
5574
5570
 
5575
- if (this.numBytes === 1) {
5576
- if (this.numComp === 3) {
5577
- this.getter = this.getValueRGB;
5578
- this.setter = this.setValueRGB;
5579
- this.output = this.outputRGB;
5580
- } else {
5581
- this.getter = this.getValue8;
5582
- this.setter = this.setValue8;
5583
- this.output = this.outputSingle;
5584
- }
5585
- } else {
5586
- this.getter = this.getValue16;
5587
- this.setter = this.setValue16;
5588
- this.output = this.outputSingle;
5589
- }
5571
+ this ._texture .addInterest ("set_texture__", this);
5572
+ this ._update .addInterest ("update", this);
5590
5573
 
5591
- switch (this.selection) {
5592
- case 2:
5593
- this.selector = this.select2;
5594
- break;
5595
- case 3:
5596
- this.selector = this.select3;
5597
- break;
5598
- case 4:
5599
- this.selector = this.select4;
5600
- break;
5601
- case 5:
5602
- this.selector = this.select5;
5603
- break;
5604
- case 6:
5605
- this.selector = this.select6;
5606
- break;
5607
- case 7:
5608
- this.selector = this.select7;
5609
- break;
5610
- default:
5611
- this.selector = this.select1;
5612
- break;
5613
- }
5574
+ this .set_texture__ ();
5575
+ },
5576
+ set_texture__ ()
5577
+ {
5578
+ const textureNodes = this .textureNodes;
5614
5579
 
5615
- this.scanComps = this.scan.components;
5616
- this.quantTables = this.quantTable.quantTables;
5580
+ for (const textureNode of textureNodes)
5581
+ textureNode .removeInterest ("set_update__", this);
5617
5582
 
5618
- for (i = 0; i < this.numComp; i+=1) {
5619
- compN = this.scanComps[i].scanCompSel;
5620
- this.qTab[i] = this.quantTables[this.components[compN].quantTableSel];
5621
- this.nBlock[i] = this.components[compN].vSamp * this.components[compN].hSamp;
5622
- this.dcTab[i] = this.HuffTab[this.scanComps[i].dcTabSel][0];
5623
- this.acTab[i] = this.HuffTab[this.scanComps[i].acTabSel][1];
5624
- }
5583
+ textureNodes .length = 0;
5625
5584
 
5626
- this.xDim = this.frame.dimX;
5627
- this.yDim = this.frame.dimY;
5628
- if (this.numBytes == 1) {
5629
- this.outputData = new Uint8Array(new ArrayBuffer(this.xDim * this.yDim * this.numBytes * this.numComp));
5630
- } else {
5631
- this.outputData = new Uint16Array(new ArrayBuffer(this.xDim * this.yDim * this.numBytes * this.numComp));
5632
- }
5585
+ for (const node of this ._texture)
5586
+ {
5587
+ const textureNode = X3DCast_default() ((X3DConstants_default()).X3DTexture2DNode, node);
5633
5588
 
5634
- scanNum+=1;
5589
+ if (textureNode)
5590
+ textureNodes .push (textureNode);
5591
+ }
5635
5592
 
5636
- while (true) { // Decode one scan
5637
- temp[0] = 0;
5638
- index[0] = 0;
5593
+ for (const textureNode of textureNodes)
5594
+ textureNode .addInterest ("set_update__", this);
5639
5595
 
5640
- for (i = 0; i < 10; i+=1) {
5641
- pred[i] = (1 << (this.precision - 1));
5642
- }
5596
+ this .set_update__ ();
5597
+ },
5598
+ set_update__ ()
5599
+ {
5600
+ this ._update .addEvent ();
5601
+ },
5602
+ isComplete ()
5603
+ {
5604
+ return this .textureNodes .every (textureNode => textureNode .checkLoadState () === (X3DConstants_default()).COMPLETE_STATE);
5605
+ },
5606
+ update ()
5607
+ {
5608
+ const textureNodes = this .textureNodes
5643
5609
 
5644
- if (this.restartInterval === 0) {
5645
- current = this.decodeUnit(pred, temp, index);
5610
+ if (textureNodes .length === 0 || !this .isComplete ())
5611
+ {
5612
+ this .clearTexture ();
5613
+ }
5614
+ else
5615
+ {
5616
+ const
5617
+ gl = this .getBrowser () .getContext (),
5618
+ width = textureNodes [0] .getWidth (),
5619
+ height = textureNodes [0] .getHeight (),
5620
+ depth = textureNodes .length,
5621
+ frameBuffer = gl .createFramebuffer ();
5646
5622
 
5647
- while ((current === 0) && ((this.xLoc < this.xDim) && (this.yLoc < this.yDim))) {
5648
- this.output(pred);
5649
- current = this.decodeUnit(pred, temp, index);
5650
- }
5623
+ gl .bindFramebuffer (gl .FRAMEBUFFER, frameBuffer);
5624
+ gl .bindTexture (gl .TEXTURE_3D, this .getTexture ());
5651
5625
 
5652
- break; //current=MARKER
5653
- }
5626
+ if (width !== this .getWidth () || height !== this .getHeight () || depth !== this .getDepth ())
5627
+ {
5628
+ const defaultData = new Uint8Array (width * height * depth * 4);
5654
5629
 
5655
- for (mcuNum = 0; mcuNum < this.restartInterval; mcuNum+=1) {
5656
- this.restarting = (mcuNum == 0);
5657
- current = this.decodeUnit(pred, temp, index);
5658
- this.output(pred);
5630
+ gl .texImage3D (gl .TEXTURE_3D, 0, gl .RGBA, width, height, depth, 0, gl .RGBA, gl .UNSIGNED_BYTE, defaultData);
5631
+ }
5659
5632
 
5660
- if (current !== 0) {
5661
- break;
5662
- }
5663
- }
5633
+ for (const [i, textureNode] of this .textureNodes .entries ())
5634
+ {
5635
+ if (textureNode .getWidth () === width && textureNode .getHeight () === height)
5636
+ {
5637
+ gl .bindTexture (gl .TEXTURE_2D, textureNode .getTexture ());
5638
+ gl .framebufferTexture2D (gl .FRAMEBUFFER, gl .COLOR_ATTACHMENT0, gl .TEXTURE_2D, textureNode .getTexture (), 0);
5664
5639
 
5665
- if (current === 0) {
5666
- if (this.markerIndex !== 0) {
5667
- current = (0xFF00 | this.marker);
5668
- this.markerIndex = 0;
5669
- } else {
5670
- current = this.stream.get16();
5671
- }
5640
+ if (textureNode .getTextureType () === 1)
5641
+ {
5642
+ // Copy and flip Y.
5643
+ for (let y = 0; y < height; ++ y)
5644
+ gl .copyTexSubImage3D (gl .TEXTURE_3D, 0, 0, height - y - 1, i, 0, y, width, 1);
5645
+ }
5646
+ else
5647
+ {
5648
+ gl .copyTexSubImage3D (gl .TEXTURE_3D, 0, 0, 0, i, 0, 0, width, height);
5649
+ }
5672
5650
  }
5673
-
5674
- if (!((current >= jpeg.lossless.Decoder.RESTART_MARKER_BEGIN) &&
5675
- (current <= jpeg.lossless.Decoder.RESTART_MARKER_END))) {
5676
- break; //current=MARKER
5651
+ else
5652
+ {
5653
+ console .warn ("ComposedTexture3D: all textures must have same size.");
5677
5654
  }
5678
- }
5679
-
5680
- if ((current === 0xFFDC) && (scanNum === 1)) { //DNL
5681
- this.readNumber();
5682
- current = this.stream.get16();
5683
- }
5684
- } while ((current !== 0xFFD9) && ((this.xLoc < this.xDim) && (this.yLoc < this.yDim)) && (scanNum === 0));
5685
-
5686
- return this.outputData;
5687
- };
5688
-
5689
-
5690
-
5691
- jpeg.lossless.Decoder.prototype.decodeUnit = function (prev, temp, index) {
5692
- if (this.numComp == 1) {
5693
- return this.decodeSingle(prev, temp, index);
5694
- } else if (this.numComp == 3) {
5695
- return this.decodeRGB(prev, temp, index);
5696
- } else {
5697
- return -1;
5698
- }
5699
- };
5655
+ }
5700
5656
 
5657
+ gl .deleteFramebuffer (frameBuffer);
5701
5658
 
5659
+ this .setWidth (width);
5660
+ this .setHeight (height);
5661
+ this .setDepth (depth);
5662
+ this .setTransparent (textureNodes .some (textureNode => textureNode .isTransparent ()));
5663
+ this .setLinear (textureNodes .some (textureNode => textureNode .isLinear ()));
5664
+ this .updateTextureParameters ();
5665
+ }
5666
+ },
5667
+ });
5702
5668
 
5703
- jpeg.lossless.Decoder.prototype.select1 = function (compOffset) {
5704
- return this.getPreviousX(compOffset);
5705
- };
5706
-
5707
-
5708
-
5709
- jpeg.lossless.Decoder.prototype.select2 = function (compOffset) {
5710
- return this.getPreviousY(compOffset);
5711
- };
5712
-
5669
+ Object .defineProperties (ComposedTexture3D,
5670
+ {
5671
+ typeName:
5672
+ {
5673
+ value: "ComposedTexture3D",
5674
+ enumerable: true,
5675
+ },
5676
+ componentInfo:
5677
+ {
5678
+ value: Object .freeze ({ name: "Texturing3D", level: 1 }),
5679
+ enumerable: true,
5680
+ },
5681
+ containerField:
5682
+ {
5683
+ value: "texture",
5684
+ enumerable: true,
5685
+ },
5686
+ specificationRange:
5687
+ {
5688
+ value: Object .freeze ({ from: "3.1", to: "Infinity" }),
5689
+ enumerable: true,
5690
+ },
5691
+ fieldDefinitions:
5692
+ {
5693
+ value: new (FieldDefinitionArray_default()) ([
5694
+ new (X3DFieldDefinition_default()) ((X3DConstants_default()).inputOutput, "metadata", new (Fields_default()).SFNode ()),
5695
+ new (X3DFieldDefinition_default()) ((X3DConstants_default()).inputOutput, "description", new (Fields_default()).SFString ()),
5696
+ new (X3DFieldDefinition_default()) ((X3DConstants_default()).initializeOnly, "repeatS", new (Fields_default()).SFBool ()),
5697
+ new (X3DFieldDefinition_default()) ((X3DConstants_default()).initializeOnly, "repeatT", new (Fields_default()).SFBool ()),
5698
+ new (X3DFieldDefinition_default()) ((X3DConstants_default()).initializeOnly, "repeatR", new (Fields_default()).SFBool ()),
5699
+ new (X3DFieldDefinition_default()) ((X3DConstants_default()).initializeOnly, "textureProperties", new (Fields_default()).SFNode ()),
5700
+ new (X3DFieldDefinition_default()) ((X3DConstants_default()).inputOutput, "texture", new (Fields_default()).MFNode ()),
5701
+ ]),
5702
+ enumerable: true,
5703
+ },
5704
+ });
5713
5705
 
5706
+ const ComposedTexture3D_default_ = ComposedTexture3D;
5707
+ ;
5714
5708
 
5715
- jpeg.lossless.Decoder.prototype.select3 = function (compOffset) {
5716
- return this.getPreviousXY(compOffset);
5717
- };
5709
+ Namespace_default().add ("ComposedTexture3D", "x_ite/Components/Texturing3D/ComposedTexture3D", ComposedTexture3D_default_);
5710
+ /* harmony default export */ const Texturing3D_ComposedTexture3D = (ComposedTexture3D_default_);
5711
+ ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Components/Networking/X3DUrlObject\")"
5712
+ const X3DUrlObject_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.0")] .require ("x_ite/Components/Networking/X3DUrlObject");
5713
+ var X3DUrlObject_default = /*#__PURE__*/__webpack_require__.n(X3DUrlObject_namespaceObject);
5714
+ ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Parser/Expressions\")"
5715
+ const Expressions_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.0")] .require ("x_ite/Parser/Expressions");
5716
+ var Expressions_default = /*#__PURE__*/__webpack_require__.n(Expressions_namespaceObject);
5717
+ // EXTERNAL MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"lib/jquery\")"
5718
+ var jquery_ = __webpack_require__(823);
5719
+ var jquery_default = /*#__PURE__*/__webpack_require__.n(jquery_);
5720
+ ;// CONCATENATED MODULE: ./src/x_ite/Browser/Texturing3D/NRRDParser.js
5721
+ /*******************************************************************************
5722
+ *
5723
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5724
+ *
5725
+ * Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022.
5726
+ *
5727
+ * All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
5728
+ *
5729
+ * The copyright notice above does not evidence any actual of intended
5730
+ * publication of such source code, and is an unpublished work by create3000.
5731
+ * This material contains CONFIDENTIAL INFORMATION that is the property of
5732
+ * create3000.
5733
+ *
5734
+ * No permission is granted to copy, distribute, or create derivative works from
5735
+ * the contents of this software, in whole or in part, without the prior written
5736
+ * permission of create3000.
5737
+ *
5738
+ * NON-MILITARY USE ONLY
5739
+ *
5740
+ * All create3000 software are effectively free software with a non-military use
5741
+ * restriction. It is free. Well commented source is provided. You may reuse the
5742
+ * source in any way you please with the exception anything that uses it must be
5743
+ * marked to indicate is contains 'non-military use only' components.
5744
+ *
5745
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5746
+ *
5747
+ * Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>.
5748
+ *
5749
+ * This file is part of the X_ITE Project.
5750
+ *
5751
+ * X_ITE is free software: you can redistribute it and/or modify it under the
5752
+ * terms of the GNU General Public License version 3 only, as published by the
5753
+ * Free Software Foundation.
5754
+ *
5755
+ * X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
5756
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
5757
+ * A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
5758
+ * details (a copy is included in the LICENSE file that accompanied this code).
5759
+ *
5760
+ * You should have received a copy of the GNU General Public License version 3
5761
+ * along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a
5762
+ * copy of the GPLv3 License.
5763
+ *
5764
+ * For Silvio, Joy and Adi.
5765
+ *
5766
+ ******************************************************************************/
5718
5767
 
5719
5768
 
5720
5769
 
5721
- jpeg.lossless.Decoder.prototype.select4 = function (compOffset) {
5722
- return (this.getPreviousX(compOffset) + this.getPreviousY(compOffset)) - this.getPreviousXY(compOffset);
5723
- };
5724
5770
 
5771
+ // Grammar
5725
5772
 
5773
+ const Grammar = Expressions_default() ({
5774
+ NRRD: /^NRRD(\d+)\n/gy,
5775
+ field: /([\w\s]+):\s*(.+?)\n/gy,
5776
+ comment: /#[^\n]*\n/gy,
5777
+ newLine: /\n/gy,
5778
+ data: /(.*)$/sgy,
5779
+ });
5726
5780
 
5727
- jpeg.lossless.Decoder.prototype.select5 = function (compOffset) {
5728
- return this.getPreviousX(compOffset) + ((this.getPreviousY(compOffset) - this.getPreviousXY(compOffset)) >> 1);
5729
- };
5781
+ // Parser
5730
5782
 
5783
+ function NRRDParser ()
5784
+ {
5785
+ this .fieldFunction = new Map ([
5786
+ ["type", this .getType],
5787
+ ["encoding", this .getEncoding],
5788
+ ["dimension", this .getDimension],
5789
+ ["sizes", this .getSizes],
5790
+ ["endian", this .getEndian],
5791
+ ]);
5792
+ }
5731
5793
 
5794
+ Object .assign (NRRDParser .prototype,
5795
+ {
5796
+ parse (input)
5797
+ {
5798
+ this .setInput (input);
5732
5799
 
5733
- jpeg.lossless.Decoder.prototype.select6 = function (compOffset) {
5734
- return this.getPreviousY(compOffset) + ((this.getPreviousX(compOffset) - this.getPreviousXY(compOffset)) >> 1);
5735
- };
5800
+ if (this .getNRRD ())
5801
+ {
5802
+ this .getFields ();
5803
+ this .getData ();
5804
+ }
5736
5805
 
5806
+ return this .nrrd;
5807
+ },
5808
+ setInput (value)
5809
+ {
5810
+ this .dataView = new DataView (value);
5811
+ this .input = jquery_default().decodeText (value);
5812
+ this .lastIndex = 0;
5813
+ this .nrrd = { };
5814
+ this .littleEndian = true;
5815
+ },
5816
+ getNRRD ()
5817
+ {
5818
+ if (Grammar .NRRD .parse (this))
5819
+ {
5820
+ this .nrrd .nrrd = true;
5821
+ this .nrrd .version = parseInt (this .result [1]);
5822
+ return true;
5823
+ }
5737
5824
 
5825
+ this .nrrd .nrrd = false;
5826
+ return false;
5827
+ },
5828
+ getFields ()
5829
+ {
5830
+ while (Grammar .comment .parse (this))
5831
+ ;
5738
5832
 
5739
- jpeg.lossless.Decoder.prototype.select7 = function (compOffset) {
5740
- return ((this.getPreviousX(compOffset) + this.getPreviousY(compOffset)) / 2);
5741
- };
5833
+ while (Grammar .field .parse (this))
5834
+ {
5835
+ const
5836
+ key = this .result [1] .toLowerCase (),
5837
+ value = this .result [2] .trim () .toLowerCase (),
5838
+ fun = this .fieldFunction .get (key);
5742
5839
 
5840
+ if (fun)
5841
+ fun .call (this, value);
5743
5842
 
5843
+ while (Grammar .comment .parse (this))
5844
+ ;
5845
+ }
5846
+ },
5847
+ getType: (() =>
5848
+ {
5849
+ const types = new Map ([
5850
+ ["signed char", ["signed char", 1]],
5851
+ ["int8", ["signed char", 1]],
5852
+ ["int8_t", ["signed char", 1]],
5853
+ ["uchar", ["unsigned char", 1]],
5854
+ ["unsigned char", ["unsigned char", 1]],
5855
+ ["uint8", ["unsigned char", 1]],
5856
+ ["uint8_t", ["unsigned char", 1]],
5857
+ ["short", ["signed short", 2]],
5858
+ ["short int", ["signed short", 2]],
5859
+ ["signed short", ["signed short", 2]],
5860
+ ["signed short int", ["signed short", 2]],
5861
+ ["int16", ["signed short", 2]],
5862
+ ["int16_t", ["signed short", 2]],
5863
+ ["ushort", ["unsigned short", 2]],
5864
+ ["unsigned short", ["unsigned short", 2]],
5865
+ ["unsigned short int", ["unsigned short", 2]],
5866
+ ["uint16", ["unsigned short", 2]],
5867
+ ["uint16_t", ["unsigned short", 2]],
5868
+ ["int", ["signed int", 4]],
5869
+ ["signed int", ["signed int", 4]],
5870
+ ["int32", ["signed int", 4]],
5871
+ ["int32_t", ["signed int", 4]],
5872
+ ["uint", ["unsigned int", 4]],
5873
+ ["unsigned int", ["unsigned int", 4]],
5874
+ ["uint32", ["unsigned int", 4]],
5875
+ ["uint32_t", ["unsigned int", 4]],
5876
+ ["float", ["float", 4]],
5877
+ ["double", ["double", 8]],
5878
+ ]);
5744
5879
 
5745
- jpeg.lossless.Decoder.prototype.decodeRGB = function (prev, temp, index) {
5746
- /*jslint bitwise: true */
5880
+ return function (value)
5881
+ {
5882
+ const type = types .get (value);
5747
5883
 
5748
- var value, actab, dctab, qtab, ctrC, i, k, j;
5884
+ if (type === undefined)
5885
+ throw new Error ("Unsupported NRRD type '" + value + "'.");
5749
5886
 
5750
- prev[0] = this.selector(0);
5751
- prev[1] = this.selector(1);
5752
- prev[2] = this.selector(2);
5887
+ this .byteType = type [0];
5888
+ this .bytes = type [1];
5889
+ };
5890
+ })(),
5891
+ getEncoding: (() =>
5892
+ {
5893
+ const encodings = new Map ([
5894
+ ["ascii", "ascii"],
5895
+ ["txt", "ascii"],
5896
+ ["text", "ascii"],
5897
+ ["raw", "raw"],
5898
+ ["hex", "hex"],
5899
+ ["gz", "gzip"],
5900
+ ["gzip", "gzip"],
5901
+ ]);
5753
5902
 
5754
- for (ctrC = 0; ctrC < this.numComp; ctrC+=1) {
5755
- qtab = this.qTab[ctrC];
5756
- actab = this.acTab[ctrC];
5757
- dctab = this.dcTab[ctrC];
5758
- for (i = 0; i < this.nBlock[ctrC]; i+=1) {
5759
- for (k = 0; k < this.IDCT_Source.length; k+=1) {
5760
- this.IDCT_Source[k] = 0;
5761
- }
5903
+ return function (value)
5904
+ {
5905
+ const encoding = encodings .get (value);
5762
5906
 
5763
- value = this.getHuffmanValue(dctab, temp, index);
5907
+ if (encoding === undefined)
5908
+ throw new Error ("Unsupported NRRD encoding '" + value + "'.");
5764
5909
 
5765
- if (value >= 0xFF00) {
5766
- return value;
5767
- }
5910
+ this .encoding = encoding;
5911
+ };
5912
+ })(),
5913
+ getDimension (value)
5914
+ {
5915
+ const result = value .match (/(\d+)/);
5768
5916
 
5769
- prev[ctrC] = this.IDCT_Source[0] = prev[ctrC] + this.getn(index, value, temp, index);
5770
- this.IDCT_Source[0] *= qtab[0];
5917
+ if (result)
5918
+ {
5919
+ const value = parseInt (result [1]);
5771
5920
 
5772
- for (j = 1; j < 64; j+=1) {
5773
- value = this.getHuffmanValue(actab, temp, index);
5774
-
5775
- if (value >= 0xFF00) {
5776
- return value;
5777
- }
5778
-
5779
- j += (value >> 4);
5780
-
5781
- if ((value & 0x0F) === 0) {
5782
- if ((value >> 4) === 0) {
5783
- break;
5784
- }
5785
- } else {
5786
- this.IDCT_Source[jpeg.lossless.Decoder.IDCT_P[j]] = this.getn(index, value & 0x0F, temp, index) * qtab[j];
5787
- }
5788
- }
5789
- }
5790
- }
5791
-
5792
- return 0;
5793
- };
5921
+ switch (value)
5922
+ {
5923
+ case 1:
5924
+ case 2:
5925
+ case 3:
5926
+ case 4:
5927
+ this .dimension = value;
5928
+ return;
5929
+ }
5930
+ }
5794
5931
 
5932
+ throw new Error (`Unsupported NRRD dimension '${result ?.[1]}', must be 1, 2, 3, or 4.`);
5933
+ },
5934
+ getSizes (value)
5935
+ {
5936
+ const
5937
+ num = /\s*(\d+)/gy,
5938
+ sizes = [ ];
5795
5939
 
5940
+ let result;
5796
5941
 
5797
- jpeg.lossless.Decoder.prototype.decodeSingle = function (prev, temp, index) {
5798
- /*jslint bitwise: true */
5942
+ while (result = num .exec (value))
5943
+ {
5944
+ sizes .push (parseInt (result [1]));
5945
+ }
5799
5946
 
5800
- var value, i, n, nRestart;
5947
+ switch (sizes .length)
5948
+ {
5949
+ case 1:
5950
+ {
5951
+ this .nrrd .components = 1;
5952
+ this .nrrd .width = sizes [0];
5953
+ this .nrrd .height = 1;
5954
+ this .nrrd .depth = 1;
5955
+ return;
5956
+ }
5957
+ case 2:
5958
+ {
5959
+ this .nrrd .components = 1;
5960
+ this .nrrd .width = sizes [0];
5961
+ this .nrrd .height = sizes [1];
5962
+ this .nrrd .depth = 1;
5963
+ return;
5964
+ }
5965
+ case 3:
5966
+ {
5967
+ this .nrrd .components = 1;
5968
+ this .nrrd .width = sizes [0];
5969
+ this .nrrd .height = sizes [1];
5970
+ this .nrrd .depth = sizes [2];
5971
+ return;
5972
+ }
5973
+ case 4:
5974
+ {
5975
+ this .nrrd .components = sizes [0];
5976
+ this .nrrd .width = sizes [1];
5977
+ this .nrrd .height = sizes [2];
5978
+ this .nrrd .depth = sizes [3];
5979
+ return;
5980
+ }
5981
+ default:
5982
+ throw new Error ("Unsupported NRRD sizes.");
5983
+ }
5984
+ },
5985
+ getEndian (value)
5986
+ {
5987
+ if (value === "little")
5988
+ {
5989
+ this .littleEndian = true;
5990
+ return;
5991
+ }
5801
5992
 
5802
- if (this.restarting) {
5803
- this.restarting = false;
5804
- prev[0] = (1 << (this.frame.precision - 1));
5805
- } else {
5806
- prev[0] = this.selector();
5807
- }
5993
+ if (value === "big")
5994
+ {
5995
+ this .littleEndian = false;
5996
+ return;
5997
+ }
5808
5998
 
5809
- for (i = 0; i < this.nBlock[0]; i+=1) {
5810
- value = this.getHuffmanValue(this.dcTab[0], temp, index);
5811
- if (value >= 0xFF00) {
5812
- return value;
5813
- }
5999
+ throw new Error ("Unsupported NRRD endian, must be either 'little' or 'big'.");
6000
+ },
6001
+ getData ()
6002
+ {
6003
+ switch (this .encoding)
6004
+ {
6005
+ case "ascii":
6006
+ {
6007
+ this .ascii ();
6008
+ break;
6009
+ }
6010
+ case "raw":
6011
+ {
6012
+ this .raw ();
6013
+ break;
6014
+ }
6015
+ case "hex":
6016
+ {
6017
+ this .hex ();
6018
+ break;
6019
+ }
6020
+ case "gzip":
6021
+ {
6022
+ this .gzip ();
6023
+ break;
6024
+ }
6025
+ }
6026
+ },
6027
+ ascii ()
6028
+ {
6029
+ const
6030
+ dataLength = this .nrrd .components * this .nrrd .width * this .nrrd .height * this .nrrd .depth,
6031
+ data = new Uint8Array (dataLength);
5814
6032
 
5815
- n = this.getn(prev, value, temp, index);
5816
- nRestart = (n >> 8);
6033
+ this .nrrd .data = data;
5817
6034
 
5818
- if ((nRestart >= jpeg.lossless.Decoder.RESTART_MARKER_BEGIN) && (nRestart <= jpeg.lossless.Decoder.RESTART_MARKER_END)) {
5819
- return nRestart;
5820
- }
6035
+ if (!Grammar .data .parse (this))
6036
+ return;
5821
6037
 
5822
- prev[0] += n;
5823
- }
6038
+ const
6039
+ numbers = this .result [1] .trim () .split (/\s+/),
6040
+ numNumbers = numbers .length;
5824
6041
 
5825
- return 0;
5826
- };
6042
+ switch (this .byteType)
6043
+ {
6044
+ case "signed char":
6045
+ case "unsigned char":
6046
+ {
6047
+ for (let i = 0; i < numNumbers; ++ i)
6048
+ data [i] = parseInt (numbers [i]);
5827
6049
 
6050
+ return;
6051
+ }
6052
+ case "signed short":
6053
+ case "unsigned short":
6054
+ {
6055
+ for (let i = 0; i < numNumbers; ++ i)
6056
+ data [i] = parseInt (numbers [i]) / 256;
5828
6057
 
6058
+ return;
6059
+ }
6060
+ case "signed int":
6061
+ case "unsigned int":
6062
+ {
6063
+ for (let i = 0; i < numNumbers; ++ i)
6064
+ data [i] = parseInt (numbers [i]) / 16777216;
5829
6065
 
5830
- // Huffman table for fast search: (HuffTab) 8-bit Look up table 2-layer search architecture, 1st-layer represent 256 node (8 bits) if codeword-length > 8
5831
- // bits, then the entry of 1st-layer = (# of 2nd-layer table) | MSB and it is stored in the 2nd-layer Size of tables in each layer are 256.
5832
- // HuffTab[*][*][0-256] is always the only 1st-layer table.
5833
- //
5834
- // An entry can be: (1) (# of 2nd-layer table) | MSB , for code length > 8 in 1st-layer (2) (Code length) << 8 | HuffVal
5835
- //
5836
- // HuffmanValue(table HuffTab[x][y] (ex) HuffmanValue(HuffTab[1][0],...)
5837
- // ):
5838
- // return: Huffman Value of table
5839
- // 0xFF?? if it receives a MARKER
5840
- // Parameter: table HuffTab[x][y] (ex) HuffmanValue(HuffTab[1][0],...)
5841
- // temp temp storage for remainded bits
5842
- // index index to bit of temp
5843
- // in FILE pointer
5844
- // Effect:
5845
- // temp store new remainded bits
5846
- // index change to new index
5847
- // in change to new position
5848
- // NOTE:
5849
- // Initial by temp=0; index=0;
5850
- // NOTE: (explain temp and index)
5851
- // temp: is always in the form at calling time or returning time
5852
- // | byte 4 | byte 3 | byte 2 | byte 1 |
5853
- // | 0 | 0 | 00000000 | 00000??? | if not a MARKER
5854
- // ^index=3 (from 0 to 15)
5855
- // 321
5856
- // NOTE (marker and marker_index):
5857
- // If get a MARKER from 'in', marker=the low-byte of the MARKER
5858
- // and marker_index=9
5859
- // If marker_index=9 then index is always > 8, or HuffmanValue()
5860
- // will not be called
5861
- jpeg.lossless.Decoder.prototype.getHuffmanValue = function (table, temp, index) {
5862
- /*jslint bitwise: true */
5863
-
5864
- var code, input, mask;
5865
- mask = 0xFFFF;
6066
+ return;
6067
+ }
6068
+ case "float":
6069
+ {
6070
+ for (let i = 0; i < numNumbers; ++ i)
6071
+ data [i] = parseFloat (numbers [i]) / 256;
5866
6072
 
5867
- if (index[0] < 8) {
5868
- temp[0] <<= 8;
5869
- input = this.stream.get8();
5870
- if (input === 0xFF) {
5871
- this.marker = this.stream.get8();
5872
- if (this.marker !== 0) {
5873
- this.markerIndex = 9;
5874
- }
5875
- }
5876
- temp[0] |= input;
5877
- } else {
5878
- index[0] -= 8;
5879
- }
6073
+ return;
6074
+ }
6075
+ case "double":
6076
+ {
6077
+ for (let i = 0; i < numNumbers; ++ i)
6078
+ data [i] = parseFloat (numbers [i]) / 16777216;
5880
6079
 
5881
- code = table[temp[0] >> index[0]];
6080
+ return;
6081
+ }
6082
+ }
6083
+ },
6084
+ raw ()
6085
+ {
6086
+ const
6087
+ dataView = this .dataView,
6088
+ byteLength = dataView .byteLength,
6089
+ dataLength = this .nrrd .components * this .nrrd .width * this .nrrd .height * this .nrrd .depth,
6090
+ length = dataLength * this .bytes,
6091
+ data = new Uint8Array (dataLength);
5882
6092
 
5883
- if ((code & jpeg.lossless.Decoder.MSB) !== 0) {
5884
- if (this.markerIndex !== 0) {
5885
- this.markerIndex = 0;
5886
- return 0xFF00 | this.marker;
5887
- }
6093
+ this .nrrd .data = data;
5888
6094
 
5889
- temp[0] &= (mask >> (16 - index[0]));
5890
- temp[0] <<= 8;
5891
- input = this.stream.get8();
6095
+ switch (this .byteType)
6096
+ {
6097
+ case "signed char":
6098
+ case "unsigned char":
6099
+ {
6100
+ for (let i = byteLength - length, d = 0; i < byteLength; ++ i, ++ d)
6101
+ data [d] = dataView .getUint8 (i);
5892
6102
 
5893
- if (input === 0xFF) {
5894
- this.marker = this.stream.get8();
5895
- if (this.marker !== 0) {
5896
- this.markerIndex = 9;
5897
- }
5898
- }
6103
+ return;
6104
+ }
6105
+ case "signed short":
6106
+ case "unsigned short":
6107
+ {
6108
+ for (let i = byteLength - length, d = 0; i < byteLength; i += 2, ++ d)
6109
+ data [d] = dataView .getUint16 (i, this .littleEndian) / 256;
5899
6110
 
5900
- temp[0] |= input;
5901
- code = table[((code & 0xFF) * 256) + (temp[0] >> index[0])];
5902
- index[0] += 8;
5903
- }
6111
+ return;
6112
+ }
6113
+ case "signed int":
6114
+ case "unsigned int":
6115
+ {
6116
+ for (let i = byteLength - length, d = 0; i < byteLength; i += 4, ++ d)
6117
+ data [d] = dataView .getUint32 (i, this .littleEndian) / 16777216;
5904
6118
 
5905
- index[0] += 8 - (code >> 8);
6119
+ return;
6120
+ }
6121
+ case "float":
6122
+ {
6123
+ for (let i = byteLength - length, d = 0; i < byteLength; i += 4, ++ d)
6124
+ data [d] = dataView .getFloat32 (i, this .littleEndian) / 256;
5906
6125
 
5907
- if (index[0] < 0) {
5908
- throw new Error("index=" + index[0] + " temp=" + temp[0] + " code=" + code + " in HuffmanValue()");
5909
- }
6126
+ return;
6127
+ }
6128
+ case "double":
6129
+ {
6130
+ for (let i = byteLength - length, d = 0; i < byteLength; i += 8, ++ d)
6131
+ data [d] = dataView .getFloat64 (i, this .littleEndian) / 16777216;
5910
6132
 
5911
- if (index[0] < this.markerIndex) {
5912
- this.markerIndex = 0;
5913
- return 0xFF00 | this.marker;
5914
- }
6133
+ return;
6134
+ }
6135
+ }
6136
+ },
6137
+ hex ()
6138
+ {
6139
+ if (Grammar .data .parse (this))
6140
+ {
6141
+ const match = this .result [1] .match (/([0-9a-fA-F]{2})/g);
5915
6142
 
5916
- temp[0] &= (mask >> (16 - index[0]));
5917
- return code & 0xFF;
5918
- };
6143
+ if (match)
6144
+ {
6145
+ const array = Uint8Array .from (match, value => parseInt (value, 16));
5919
6146
 
6147
+ this .dataView = new DataView (array .buffer);
5920
6148
 
6149
+ this .raw ();
6150
+ return;
6151
+ }
6152
+ }
5921
6153
 
5922
- jpeg.lossless.Decoder.prototype.getn = function (PRED, n, temp, index) {
5923
- /*jslint bitwise: true */
6154
+ throw new Error ("Invalid NRRD data.");
6155
+ },
6156
+ gzip ()
6157
+ {
6158
+ try
6159
+ {
6160
+ if (!Grammar .newLine .parse (this))
6161
+ throw new Error ("Invalid NRRD data.");
5924
6162
 
5925
- var result, one, n_one, mask, input;
5926
- one = 1;
5927
- n_one = -1;
5928
- mask = 0xFFFF;
6163
+ const
6164
+ input = this .dataView .buffer .slice (this .lastIndex),
6165
+ arrayBuffer = jquery_default().ungzip (input);
5929
6166
 
5930
- if (n === 0) {
5931
- return 0;
5932
- }
6167
+ this .dataView = new DataView (arrayBuffer);
5933
6168
 
5934
- if (n === 16) {
5935
- if (PRED[0] >= 0) {
5936
- return -32768;
5937
- } else {
5938
- return 32768;
5939
- }
5940
- }
5941
-
5942
- index[0] -= n;
5943
-
5944
- if (index[0] >= 0) {
5945
- if ((index[0] < this.markerIndex) && !this.isLastPixel()) { // this was corrupting the last pixel in some cases
5946
- this.markerIndex = 0;
5947
- return (0xFF00 | this.marker) << 8;
5948
- }
5949
-
5950
- result = temp[0] >> index[0];
5951
- temp[0] &= (mask >> (16 - index[0]));
5952
- } else {
5953
- temp[0] <<= 8;
5954
- input = this.stream.get8();
5955
-
5956
- if (input === 0xFF) {
5957
- this.marker = this.stream.get8();
5958
- if (this.marker !== 0) {
5959
- this.markerIndex = 9;
5960
- }
5961
- }
5962
-
5963
- temp[0] |= input;
5964
- index[0] += 8;
5965
-
5966
- if (index[0] < 0) {
5967
- if (this.markerIndex !== 0) {
5968
- this.markerIndex = 0;
5969
- return (0xFF00 | this.marker) << 8;
5970
- }
5971
-
5972
- temp[0] <<= 8;
5973
- input = this.stream.get8();
5974
-
5975
- if (input === 0xFF) {
5976
- this.marker = this.stream.get8();
5977
- if (this.marker !== 0) {
5978
- this.markerIndex = 9;
5979
- }
5980
- }
5981
-
5982
- temp[0] |= input;
5983
- index[0] += 8;
5984
- }
5985
-
5986
- if (index[0] < 0) {
5987
- throw new Error("index=" + index[0] + " in getn()");
5988
- }
5989
-
5990
- if (index[0] < this.markerIndex) {
5991
- this.markerIndex = 0;
5992
- return (0xFF00 | this.marker) << 8;
5993
- }
5994
-
5995
- result = temp[0] >> index[0];
5996
- temp[0] &= (mask >> (16 - index[0]));
5997
- }
5998
-
5999
- if (result < (one << (n - 1))) {
6000
- result += (n_one << n) + 1;
6001
- }
6002
-
6003
- return result;
6004
- };
6005
-
6006
-
6007
-
6008
- jpeg.lossless.Decoder.prototype.getPreviousX = function (compOffset) {
6009
- /*jslint bitwise: true */
6010
-
6011
- if (this.xLoc > 0) {
6012
- return this.getter((((this.yLoc * this.xDim) + this.xLoc) - 1), compOffset);
6013
- } else if (this.yLoc > 0) {
6014
- return this.getPreviousY(compOffset);
6015
- } else {
6016
- return (1 << (this.frame.precision - 1));
6017
- }
6018
- };
6019
-
6020
-
6021
-
6022
- jpeg.lossless.Decoder.prototype.getPreviousXY = function (compOffset) {
6023
- /*jslint bitwise: true */
6024
-
6025
- if ((this.xLoc > 0) && (this.yLoc > 0)) {
6026
- return this.getter(((((this.yLoc - 1) * this.xDim) + this.xLoc) - 1), compOffset);
6027
- } else {
6028
- return this.getPreviousY(compOffset);
6029
- }
6030
- };
6031
-
6032
-
6033
-
6034
- jpeg.lossless.Decoder.prototype.getPreviousY = function (compOffset) {
6035
- /*jslint bitwise: true */
6036
-
6037
- if (this.yLoc > 0) {
6038
- return this.getter((((this.yLoc - 1) * this.xDim) + this.xLoc), compOffset);
6039
- } else {
6040
- return this.getPreviousX(compOffset);
6041
- }
6042
- };
6043
-
6044
-
6045
-
6046
- jpeg.lossless.Decoder.prototype.isLastPixel = function () {
6047
- return (this.xLoc === (this.xDim - 1)) && (this.yLoc === (this.yDim - 1));
6048
- };
6049
-
6050
-
6051
-
6052
- jpeg.lossless.Decoder.prototype.outputSingle = function (PRED) {
6053
- if ((this.xLoc < this.xDim) && (this.yLoc < this.yDim)) {
6054
- this.setter((((this.yLoc * this.xDim) + this.xLoc)), this.mask & PRED[0]);
6055
-
6056
- this.xLoc+=1;
6057
-
6058
- if (this.xLoc >= this.xDim) {
6059
- this.yLoc+=1;
6060
- this.xLoc = 0;
6061
- }
6062
- }
6063
- };
6064
-
6065
-
6066
-
6067
- jpeg.lossless.Decoder.prototype.outputRGB = function (PRED) {
6068
- var offset = ((this.yLoc * this.xDim) + this.xLoc);
6069
-
6070
- if ((this.xLoc < this.xDim) && (this.yLoc < this.yDim)) {
6071
- this.setter(offset, PRED[0], 0);
6072
- this.setter(offset, PRED[1], 1);
6073
- this.setter(offset, PRED[2], 2);
6074
-
6075
- this.xLoc+=1;
6076
-
6077
- if (this.xLoc >= this.xDim) {
6078
- this.yLoc+=1;
6079
- this.xLoc = 0;
6080
- }
6081
- }
6082
- };
6083
-
6084
- jpeg.lossless.Decoder.prototype.setValue8 = function (index, val) {
6085
- this.outputData[index] = val;
6086
- };
6087
-
6088
- jpeg.lossless.Decoder.prototype.getValue8 = function (index) {
6089
- return this.outputData[index]; // mask should not be necessary because outputData is either Int8Array or Int16Array
6090
- };
6091
-
6092
- var littleEndian = (function() {
6093
- var buffer = new ArrayBuffer(2);
6094
- new DataView(buffer).setInt16(0, 256, true /* littleEndian */);
6095
- // Int16Array uses the platform's endianness.
6096
- return new Int16Array(buffer)[0] === 256;
6097
- })();
6098
-
6099
- if (littleEndian) {
6100
- // just reading from an array is fine then. Int16Array will use platform endianness.
6101
- jpeg.lossless.Decoder.prototype.setValue16 = jpeg.lossless.Decoder.prototype.setValue8;
6102
- jpeg.lossless.Decoder.prototype.getValue16 = jpeg.lossless.Decoder.prototype.getValue8;
6103
- }
6104
- else {
6105
- // If platform is big-endian, we will need to convert to little-endian
6106
- jpeg.lossless.Decoder.prototype.setValue16 = function (index, val) {
6107
- this.outputData[index] = ((val & 0xFF) << 8) | ((val >> 8) & 0xFF);
6108
- };
6109
-
6110
- jpeg.lossless.Decoder.prototype.getValue16 = function (index) {
6111
- var val = this.outputData[index];
6112
- return ((val & 0xFF) << 8) | ((val >> 8) & 0xFF);
6113
- };
6114
- }
6115
-
6116
- jpeg.lossless.Decoder.prototype.setValueRGB = function (index, val, compOffset) {
6117
- // this.outputData.setUint8(index * 3 + compOffset, val);
6118
- this.outputData[index * 3 + compOffset] = val;
6119
- };
6120
-
6121
- jpeg.lossless.Decoder.prototype.getValueRGB = function (index, compOffset) {
6122
- // return this.outputData.getUint8(index * 3 + compOffset);
6123
- return this.outputData[index * 3 + compOffset];
6124
- };
6125
-
6126
-
6127
-
6128
- jpeg.lossless.Decoder.prototype.readApp = function() {
6129
- var count = 0, length = this.stream.get16();
6130
- count += 2;
6131
-
6132
- while (count < length) {
6133
- this.stream.get8();
6134
- count+=1;
6135
- }
6136
-
6137
- return length;
6138
- };
6139
-
6140
-
6141
-
6142
- jpeg.lossless.Decoder.prototype.readComment = function () {
6143
- var sb = "", count = 0, length;
6144
-
6145
- length = this.stream.get16();
6146
- count += 2;
6169
+ this .raw ();
6170
+ }
6171
+ catch (error)
6172
+ {
6173
+ throw new Error (`Invalid NRRD data: ${error}.`);
6174
+ }
6175
+ },
6176
+ });
6147
6177
 
6148
- while (count < length) {
6149
- sb += this.stream.get8();
6150
- count+=1;
6151
- }
6178
+ const NRRDParser_default_ = NRRDParser;
6179
+ ;
6152
6180
 
6153
- return sb;
6181
+ Namespace_default().add ("NRRDParser", "x_ite/Browser/Texturing3D/NRRDParser", NRRDParser_default_);
6182
+ /* harmony default export */ const Texturing3D_NRRDParser = (NRRDParser_default_);
6183
+ ;// CONCATENATED MODULE: ./node_modules/jpeg-lossless-decoder-js/release/lossless.js
6184
+ var __defProp = Object.defineProperty;
6185
+ var __export = (target, all) => {
6186
+ for (var name in all)
6187
+ __defProp(target, name, { get: all[name], enumerable: true });
6154
6188
  };
6155
6189
 
6156
-
6157
-
6158
- jpeg.lossless.Decoder.prototype.readNumber = function() {
6159
- var Ld = this.stream.get16();
6160
-
6161
- if (Ld !== 4) {
6162
- throw new Error("ERROR: Define number format throw new IOException [Ld!=4]");
6163
- }
6164
-
6165
- return this.stream.get16();
6190
+ // src/component-spec.ts
6191
+ var ComponentSpec = {
6192
+ hSamp: 0,
6193
+ quantTableSel: 0,
6194
+ vSamp: 0
6166
6195
  };
6167
6196
 
6168
-
6169
-
6170
- /*** Exports ***/
6171
-
6172
- var moduleType = typeof module;
6173
- if ((moduleType !== 'undefined') && module.exports) {
6174
- module.exports = jpeg.lossless.Decoder;
6175
- }
6176
-
6177
- },{"./data-stream.js":2,"./frame-header.js":4,"./huffman-table.js":5,"./quantization-table.js":7,"./scan-header.js":9,"./utils.js":10}],4:[function(require,module,exports){
6178
- /*
6179
- * Copyright (C) 2015 Michael Martinez
6180
- * Changes: Added support for selection values 2-7, fixed minor bugs &
6181
- * warnings, split into multiple class files, and general clean up.
6182
- *
6183
- * 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.
6184
- */
6185
-
6186
- /*
6187
- * Copyright (C) Helmut Dersch
6188
- *
6189
- * Permission is hereby granted, free of charge, to any person obtaining a copy
6190
- * of this software and associated documentation files (the "Software"), to deal
6191
- * in the Software without restriction, including without limitation the rights
6192
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6193
- * copies of the Software, and to permit persons to whom the Software is
6194
- * furnished to do so, subject to the following conditions:
6195
-
6196
- * The above copyright notice and this permission notice shall be included in
6197
- * all copies or substantial portions of the Software.
6198
-
6199
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6200
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6201
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6202
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6203
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
6204
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
6205
- * THE SOFTWARE.
6206
- */
6207
-
6208
- /*jslint browser: true, node: true */
6209
- /*global require, module */
6210
-
6211
- "use strict";
6212
-
6213
- /*** Imports ***/
6214
- var jpeg = jpeg || {};
6215
- jpeg.lossless = jpeg.lossless || {};
6216
- jpeg.lossless.ComponentSpec = jpeg.lossless.ComponentSpec || ((typeof require !== 'undefined') ? require('./component-spec.js') : null);
6217
- jpeg.lossless.DataStream = jpeg.lossless.DataStream || ((typeof require !== 'undefined') ? require('./data-stream.js') : null);
6218
-
6219
-
6220
- /*** Constructor ***/
6221
- jpeg.lossless.FrameHeader = jpeg.lossless.FrameHeader || function () {
6222
- this.components = []; // Components
6223
- this.dimX = 0; // Number of samples per line
6224
- this.dimY = 0; // Number of lines
6225
- this.numComp = 0; // Number of component in the frame
6226
- this.precision = 0; // Sample Precision (from the original image)
6197
+ // src/data-stream.ts
6198
+ var DataStream = class {
6199
+ buffer;
6200
+ index;
6201
+ constructor(data, offset, length) {
6202
+ this.buffer = new Uint8Array(data, offset, length);
6203
+ this.index = 0;
6204
+ }
6205
+ get16() {
6206
+ const value = (this.buffer[this.index] << 8) + this.buffer[this.index + 1];
6207
+ this.index += 2;
6208
+ return value;
6209
+ }
6210
+ get8() {
6211
+ const value = this.buffer[this.index];
6212
+ this.index += 1;
6213
+ return value;
6214
+ }
6227
6215
  };
6228
6216
 
6229
-
6230
-
6231
- /*** Prototype Methods ***/
6232
-
6233
- jpeg.lossless.FrameHeader.prototype.read = function (data) {
6234
- /*jslint bitwise: true */
6235
-
6236
- var count = 0, length, i, c, temp;
6237
-
6238
- length = data.get16();
6217
+ // src/frame-header.ts
6218
+ var FrameHeader = class {
6219
+ dimX = 0;
6220
+ dimY = 0;
6221
+ numComp = 0;
6222
+ precision = 0;
6223
+ components = [];
6224
+ read(data) {
6225
+ let count = 0;
6226
+ let temp;
6227
+ const length = data.get16();
6239
6228
  count += 2;
6240
-
6241
6229
  this.precision = data.get8();
6242
- count+=1;
6243
-
6230
+ count += 1;
6244
6231
  this.dimY = data.get16();
6245
6232
  count += 2;
6246
-
6247
6233
  this.dimX = data.get16();
6248
6234
  count += 2;
6249
-
6250
6235
  this.numComp = data.get8();
6251
- count+=1;
6252
- for (i = 1; i <= this.numComp; i+=1) {
6253
- if (count > length) {
6254
- throw new Error("ERROR: frame format error");
6255
- }
6256
-
6257
- c = data.get8();
6258
- count+=1;
6259
-
6260
- if (count >= length) {
6261
- throw new Error("ERROR: frame format error [c>=Lf]");
6262
- }
6263
-
6264
- temp = data.get8();
6265
- count+=1;
6266
-
6267
- if (!this.components[c]) {
6268
- this.components[c] = new jpeg.lossless.ComponentSpec();
6269
- }
6270
-
6271
- this.components[c].hSamp = temp >> 4;
6272
- this.components[c].vSamp = temp & 0x0F;
6273
- this.components[c].quantTableSel = data.get8();
6274
- count+=1;
6236
+ count += 1;
6237
+ for (let i = 1; i <= this.numComp; i += 1) {
6238
+ if (count > length) {
6239
+ throw new Error("ERROR: frame format error");
6240
+ }
6241
+ const c = data.get8();
6242
+ count += 1;
6243
+ if (count >= length) {
6244
+ throw new Error("ERROR: frame format error [c>=Lf]");
6245
+ }
6246
+ temp = data.get8();
6247
+ count += 1;
6248
+ if (!this.components[c]) {
6249
+ this.components[c] = { ...ComponentSpec };
6250
+ }
6251
+ this.components[c].hSamp = temp >> 4;
6252
+ this.components[c].vSamp = temp & 15;
6253
+ this.components[c].quantTableSel = data.get8();
6254
+ count += 1;
6275
6255
  }
6276
-
6277
6256
  if (count !== length) {
6278
- throw new Error("ERROR: frame format error [Lf!=count]");
6257
+ throw new Error("ERROR: frame format error [Lf!=count]");
6279
6258
  }
6280
-
6281
6259
  return 1;
6260
+ }
6282
6261
  };
6283
6262
 
6284
-
6285
- /*** Exports ***/
6286
-
6287
- var moduleType = typeof module;
6288
- if ((moduleType !== 'undefined') && module.exports) {
6289
- module.exports = jpeg.lossless.FrameHeader;
6290
- }
6291
-
6292
- },{"./component-spec.js":1,"./data-stream.js":2}],5:[function(require,module,exports){
6293
- /*
6294
- * Copyright (C) 2015 Michael Martinez
6295
- * Changes: Added support for selection values 2-7, fixed minor bugs &
6296
- * warnings, split into multiple class files, and general clean up.
6297
- *
6298
- * 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.
6299
- */
6300
-
6301
- /*
6302
- * Copyright (C) Helmut Dersch
6303
- *
6304
- * Permission is hereby granted, free of charge, to any person obtaining a copy
6305
- * of this software and associated documentation files (the "Software"), to deal
6306
- * in the Software without restriction, including without limitation the rights
6307
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6308
- * copies of the Software, and to permit persons to whom the Software is
6309
- * furnished to do so, subject to the following conditions:
6310
-
6311
- * The above copyright notice and this permission notice shall be included in
6312
- * all copies or substantial portions of the Software.
6313
-
6314
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6315
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6316
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6317
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6318
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
6319
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
6320
- * THE SOFTWARE.
6321
- */
6322
-
6323
- /*jslint browser: true, node: true */
6324
- /*global require, module */
6325
-
6326
- "use strict";
6327
-
6328
- /*** Imports ***/
6329
- var jpeg = jpeg || {};
6330
- jpeg.lossless = jpeg.lossless || {};
6331
- jpeg.lossless.DataStream = jpeg.lossless.DataStream || ((typeof require !== 'undefined') ? require('./data-stream.js') : null);
6332
- jpeg.lossless.Utils = jpeg.lossless.Utils || ((typeof require !== 'undefined') ? require('./utils.js') : null);
6333
-
6334
-
6335
- /*** Constructor ***/
6336
- jpeg.lossless.HuffmanTable = jpeg.lossless.HuffmanTable || function () {
6337
- this.l = jpeg.lossless.Utils.createArray(4, 2, 16);
6338
- this.th = [];
6339
- this.v = jpeg.lossless.Utils.createArray(4, 2, 16, 200);
6340
- this.tc = jpeg.lossless.Utils.createArray(4, 2);
6341
-
6342
- this.tc[0][0] = 0;
6343
- this.tc[1][0] = 0;
6344
- this.tc[2][0] = 0;
6345
- this.tc[3][0] = 0;
6346
- this.tc[0][1] = 0;
6347
- this.tc[1][1] = 0;
6348
- this.tc[2][1] = 0;
6349
- this.tc[3][1] = 0;
6350
- this.th[0] = 0;
6351
- this.th[1] = 0;
6352
- this.th[2] = 0;
6353
- this.th[3] = 0;
6263
+ // src/utils.ts
6264
+ var utils_exports = {};
6265
+ __export(utils_exports, {
6266
+ crc32: () => crc32,
6267
+ crcTable: () => crcTable,
6268
+ createArray: () => createArray,
6269
+ makeCRCTable: () => makeCRCTable
6270
+ });
6271
+ var createArray = (...dimensions) => {
6272
+ if (dimensions.length > 1) {
6273
+ const dim = dimensions[0];
6274
+ const rest = dimensions.slice(1);
6275
+ const newArray = [];
6276
+ for (let i = 0; i < dim; i++) {
6277
+ newArray[i] = createArray(...rest);
6278
+ }
6279
+ return newArray;
6280
+ } else {
6281
+ return Array(dimensions[0]).fill(void 0);
6282
+ }
6283
+ };
6284
+ var makeCRCTable = function() {
6285
+ let c;
6286
+ const crcTable2 = [];
6287
+ for (let n = 0; n < 256; n++) {
6288
+ c = n;
6289
+ for (let k = 0; k < 8; k++) {
6290
+ c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
6291
+ }
6292
+ crcTable2[n] = c;
6293
+ }
6294
+ return crcTable2;
6295
+ };
6296
+ var crcTable = makeCRCTable();
6297
+ var crc32 = function(buffer) {
6298
+ const uint8view = new Uint8Array(buffer);
6299
+ let crc = 0 ^ -1;
6300
+ for (let i = 0; i < uint8view.length; i++) {
6301
+ crc = crc >>> 8 ^ crcTable[(crc ^ uint8view[i]) & 255];
6302
+ }
6303
+ return (crc ^ -1) >>> 0;
6354
6304
  };
6355
6305
 
6356
-
6357
-
6358
- /*** Static Pseudo-constants ***/
6359
-
6360
- jpeg.lossless.HuffmanTable.MSB = 0x80000000;
6361
-
6362
-
6363
- /*** Prototype Methods ***/
6364
-
6365
- jpeg.lossless.HuffmanTable.prototype.read = function(data, HuffTab) {
6366
- /*jslint bitwise: true */
6367
-
6368
- var count = 0, length, temp, t, c, i, j;
6369
-
6370
- length = data.get16();
6306
+ // src/huffman-table.ts
6307
+ var HuffmanTable = class _HuffmanTable {
6308
+ static MSB = 2147483648;
6309
+ l;
6310
+ th;
6311
+ v;
6312
+ tc;
6313
+ constructor() {
6314
+ this.l = createArray(4, 2, 16);
6315
+ this.th = [0, 0, 0, 0];
6316
+ this.v = createArray(4, 2, 16, 200);
6317
+ this.tc = [
6318
+ [0, 0],
6319
+ [0, 0],
6320
+ [0, 0],
6321
+ [0, 0]
6322
+ ];
6323
+ }
6324
+ read(data, HuffTab) {
6325
+ let count = 0;
6326
+ let temp;
6327
+ let t;
6328
+ let c;
6329
+ let i;
6330
+ let j;
6331
+ const length = data.get16();
6371
6332
  count += 2;
6372
-
6373
6333
  while (count < length) {
6374
- temp = data.get8();
6375
- count+=1;
6376
- t = temp & 0x0F;
6377
- if (t > 3) {
6378
- throw new Error("ERROR: Huffman table ID > 3");
6379
- }
6380
-
6381
- c = temp >> 4;
6382
- if (c > 2) {
6383
- throw new Error("ERROR: Huffman table [Table class > 2 ]");
6384
- }
6385
-
6386
- this.th[t] = 1;
6387
- this.tc[t][c] = 1;
6388
-
6389
- for (i = 0; i < 16; i+=1) {
6390
- this.l[t][c][i] = data.get8();
6391
- count+=1;
6392
- }
6393
-
6394
- for (i = 0; i < 16; i+=1) {
6395
- for (j = 0; j < this.l[t][c][i]; j+=1) {
6396
- if (count > length) {
6397
- throw new Error("ERROR: Huffman table format error [count>Lh]");
6398
- }
6399
-
6400
- this.v[t][c][i][j] = data.get8();
6401
- count+=1;
6402
- }
6334
+ temp = data.get8();
6335
+ count += 1;
6336
+ t = temp & 15;
6337
+ if (t > 3) {
6338
+ throw new Error("ERROR: Huffman table ID > 3");
6339
+ }
6340
+ c = temp >> 4;
6341
+ if (c > 2) {
6342
+ throw new Error("ERROR: Huffman table [Table class > 2 ]");
6343
+ }
6344
+ this.th[t] = 1;
6345
+ this.tc[t][c] = 1;
6346
+ for (i = 0; i < 16; i += 1) {
6347
+ this.l[t][c][i] = data.get8();
6348
+ count += 1;
6349
+ }
6350
+ for (i = 0; i < 16; i += 1) {
6351
+ for (j = 0; j < this.l[t][c][i]; j += 1) {
6352
+ if (count > length) {
6353
+ throw new Error("ERROR: Huffman table format error [count>Lh]");
6354
+ }
6355
+ this.v[t][c][i][j] = data.get8();
6356
+ count += 1;
6403
6357
  }
6358
+ }
6404
6359
  }
6405
-
6406
6360
  if (count !== length) {
6407
- throw new Error("ERROR: Huffman table format error [count!=Lf]");
6361
+ throw new Error("ERROR: Huffman table format error [count!=Lf]");
6408
6362
  }
6409
-
6410
- for (i = 0; i < 4; i+=1) {
6411
- for (j = 0; j < 2; j+=1) {
6412
- if (this.tc[i][j] !== 0) {
6413
- this.buildHuffTable(HuffTab[i][j], this.l[i][j], this.v[i][j]);
6414
- }
6363
+ for (i = 0; i < 4; i += 1) {
6364
+ for (j = 0; j < 2; j += 1) {
6365
+ if (this.tc[i][j] !== 0) {
6366
+ this.buildHuffTable(HuffTab[i][j], this.l[i][j], this.v[i][j]);
6415
6367
  }
6368
+ }
6416
6369
  }
6417
-
6418
6370
  return 1;
6419
- };
6420
-
6421
-
6422
-
6423
- // Build_HuffTab()
6424
- // Parameter: t table ID
6425
- // c table class ( 0 for DC, 1 for AC )
6426
- // L[i] # of codewords which length is i
6427
- // V[i][j] Huffman Value (length=i)
6428
- // Effect:
6429
- // build up HuffTab[t][c] using L and V.
6430
- jpeg.lossless.HuffmanTable.prototype.buildHuffTable = function(tab, L, V) {
6431
- /*jslint bitwise: true */
6432
-
6433
- var currentTable, temp, k, i, j, n;
6434
- temp = 256;
6371
+ }
6372
+ // Build_HuffTab()
6373
+ // Parameter: t table ID
6374
+ // c table class ( 0 for DC, 1 for AC )
6375
+ // L[i] # of codewords which length is i
6376
+ // V[i][j] Huffman Value (length=i)
6377
+ // Effect:
6378
+ // build up HuffTab[t][c] using L and V.
6379
+ buildHuffTable(tab, L, V) {
6380
+ let currentTable, k, i, j, n;
6381
+ const temp = 256;
6435
6382
  k = 0;
6436
-
6437
- for (i = 0; i < 8; i+=1) { // i+1 is Code length
6438
- for (j = 0; j < L[i]; j+=1) {
6439
- for (n = 0; n < (temp >> (i + 1)); n+=1) {
6440
- tab[k] = V[i][j] | ((i + 1) << 8);
6441
- k+=1;
6442
- }
6383
+ for (i = 0; i < 8; i += 1) {
6384
+ for (j = 0; j < L[i]; j += 1) {
6385
+ for (n = 0; n < temp >> i + 1; n += 1) {
6386
+ tab[k] = V[i][j] | i + 1 << 8;
6387
+ k += 1;
6443
6388
  }
6389
+ }
6444
6390
  }
6445
-
6446
- for (i = 1; k < 256; i+=1, k+=1) {
6447
- tab[k] = i | jpeg.lossless.HuffmanTable.MSB;
6391
+ for (i = 1; k < 256; i += 1, k += 1) {
6392
+ tab[k] = i | _HuffmanTable.MSB;
6448
6393
  }
6449
-
6450
6394
  currentTable = 1;
6451
6395
  k = 0;
6452
-
6453
- for (i = 8; i < 16; i+=1) { // i+1 is Code length
6454
- for (j = 0; j < L[i]; j+=1) {
6455
- for (n = 0; n < (temp >> (i - 7)); n+=1) {
6456
- tab[(currentTable * 256) + k] = V[i][j] | ((i + 1) << 8);
6457
- k+=1;
6458
- }
6459
-
6460
- if (k >= 256) {
6461
- if (k > 256) {
6462
- throw new Error("ERROR: Huffman table error(1)!");
6463
- }
6464
-
6465
- k = 0;
6466
- currentTable+=1;
6467
- }
6396
+ for (i = 8; i < 16; i += 1) {
6397
+ for (j = 0; j < L[i]; j += 1) {
6398
+ for (n = 0; n < temp >> i - 7; n += 1) {
6399
+ tab[currentTable * 256 + k] = V[i][j] | i + 1 << 8;
6400
+ k += 1;
6468
6401
  }
6402
+ if (k >= 256) {
6403
+ if (k > 256) {
6404
+ throw new Error("ERROR: Huffman table error(1)!");
6405
+ }
6406
+ k = 0;
6407
+ currentTable += 1;
6408
+ }
6409
+ }
6469
6410
  }
6411
+ }
6470
6412
  };
6471
6413
 
6472
-
6473
- /*** Exports ***/
6474
-
6475
- var moduleType = typeof module;
6476
- if ((moduleType !== 'undefined') && module.exports) {
6477
- module.exports = jpeg.lossless.HuffmanTable;
6478
- }
6479
-
6480
- },{"./data-stream.js":2,"./utils.js":10}],6:[function(require,module,exports){
6481
- /*jslint browser: true, node: true */
6482
- /*global require, module */
6483
-
6484
- "use strict";
6485
-
6486
- /*** Imports ****/
6487
-
6488
- /**
6489
- * jpeg
6490
- * @type {*|{}}
6491
- */
6492
- var jpeg = jpeg || {};
6493
-
6494
- /**
6495
- * jpeg.lossless
6496
- * @type {*|{}}
6497
- */
6498
- jpeg.lossless = jpeg.lossless || {};
6499
-
6500
-
6501
- jpeg.lossless.ComponentSpec = jpeg.lossless.ComponentSpec || ((typeof require !== 'undefined') ? require('./component-spec.js') : null);
6502
- jpeg.lossless.DataStream = jpeg.lossless.DataStream || ((typeof require !== 'undefined') ? require('./data-stream.js') : null);
6503
- jpeg.lossless.Decoder = jpeg.lossless.Decoder || ((typeof require !== 'undefined') ? require('./decoder.js') : null);
6504
- jpeg.lossless.FrameHeader = jpeg.lossless.FrameHeader || ((typeof require !== 'undefined') ? require('./frame-header.js') : null);
6505
- jpeg.lossless.HuffmanTable = jpeg.lossless.HuffmanTable || ((typeof require !== 'undefined') ? require('./huffman-table.js') : null);
6506
- jpeg.lossless.QuantizationTable = jpeg.lossless.QuantizationTable || ((typeof require !== 'undefined') ? require('./quantization-table.js') : null);
6507
- jpeg.lossless.ScanComponent = jpeg.lossless.ScanComponent || ((typeof require !== 'undefined') ? require('./scan-component.js') : null);
6508
- jpeg.lossless.ScanHeader = jpeg.lossless.ScanHeader || ((typeof require !== 'undefined') ? require('./scan-header.js') : null);
6509
- jpeg.lossless.Utils = jpeg.lossless.Utils || ((typeof require !== 'undefined') ? require('./utils.js') : null);
6510
-
6511
-
6512
- /*** Exports ***/
6513
- var moduleType = typeof module;
6514
- if ((moduleType !== 'undefined') && module.exports) {
6515
- module.exports = jpeg;
6516
- }
6517
-
6518
- },{"./component-spec.js":1,"./data-stream.js":2,"./decoder.js":3,"./frame-header.js":4,"./huffman-table.js":5,"./quantization-table.js":7,"./scan-component.js":8,"./scan-header.js":9,"./utils.js":10}],7:[function(require,module,exports){
6519
- /*
6520
- * Copyright (C) 2015 Michael Martinez
6521
- * Changes: Added support for selection values 2-7, fixed minor bugs &
6522
- * warnings, split into multiple class files, and general clean up.
6523
- *
6524
- * 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.
6525
- */
6526
-
6527
- /*
6528
- * Copyright (C) Helmut Dersch
6529
- *
6530
- * Permission is hereby granted, free of charge, to any person obtaining a copy
6531
- * of this software and associated documentation files (the "Software"), to deal
6532
- * in the Software without restriction, including without limitation the rights
6533
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6534
- * copies of the Software, and to permit persons to whom the Software is
6535
- * furnished to do so, subject to the following conditions:
6536
-
6537
- * The above copyright notice and this permission notice shall be included in
6538
- * all copies or substantial portions of the Software.
6539
-
6540
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6541
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6542
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6543
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6544
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
6545
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
6546
- * THE SOFTWARE.
6547
- */
6548
-
6549
- /*jslint browser: true, node: true */
6550
- /*global require, module */
6551
-
6552
- "use strict";
6553
-
6554
- /*** Imports ***/
6555
- var jpeg = jpeg || {};
6556
- jpeg.lossless = jpeg.lossless || {};
6557
- jpeg.lossless.DataStream = jpeg.lossless.DataStream || ((typeof require !== 'undefined') ? require('./data-stream.js') : null);
6558
- jpeg.lossless.Utils = jpeg.lossless.Utils || ((typeof require !== 'undefined') ? require('./utils.js') : null);
6559
-
6560
-
6561
- /*** Constructor ***/
6562
- jpeg.lossless.QuantizationTable = jpeg.lossless.QuantizationTable || function () {
6563
- this.precision = []; // Quantization precision 8 or 16
6564
- this.tq = []; // 1: this table is presented
6565
- this.quantTables = jpeg.lossless.Utils.createArray(4, 64); // Tables
6566
-
6567
- this.tq[0] = 0;
6568
- this.tq[1] = 0;
6569
- this.tq[2] = 0;
6570
- this.tq[3] = 0;
6571
- };
6572
-
6573
-
6574
-
6575
- /*** Static Methods ***/
6576
-
6577
- jpeg.lossless.QuantizationTable.enhanceQuantizationTable = function(qtab, table) {
6578
- /*jslint bitwise: true */
6579
-
6580
- var i;
6581
-
6582
- for (i = 0; i < 8; i+=1) {
6583
- qtab[table[(0 * 8) + i]] *= 90;
6584
- qtab[table[(4 * 8) + i]] *= 90;
6585
- qtab[table[(2 * 8) + i]] *= 118;
6586
- qtab[table[(6 * 8) + i]] *= 49;
6587
- qtab[table[(5 * 8) + i]] *= 71;
6588
- qtab[table[(1 * 8) + i]] *= 126;
6589
- qtab[table[(7 * 8) + i]] *= 25;
6590
- qtab[table[(3 * 8) + i]] *= 106;
6591
- }
6592
-
6593
- for (i = 0; i < 8; i+=1) {
6594
- qtab[table[0 + (8 * i)]] *= 90;
6595
- qtab[table[4 + (8 * i)]] *= 90;
6596
- qtab[table[2 + (8 * i)]] *= 118;
6597
- qtab[table[6 + (8 * i)]] *= 49;
6598
- qtab[table[5 + (8 * i)]] *= 71;
6599
- qtab[table[1 + (8 * i)]] *= 126;
6600
- qtab[table[7 + (8 * i)]] *= 25;
6601
- qtab[table[3 + (8 * i)]] *= 106;
6602
- }
6603
-
6604
- for (i = 0; i < 64; i+=1) {
6605
- qtab[i] >>= 6;
6606
- }
6607
- };
6608
-
6609
-
6610
- /*** Prototype Methods ***/
6611
-
6612
- jpeg.lossless.QuantizationTable.prototype.read = function (data, table) {
6613
- /*jslint bitwise: true */
6614
-
6615
- var count = 0, length, temp, t, i;
6616
-
6617
- length = data.get16();
6414
+ // src/quantization-table.ts
6415
+ var QuantizationTable = class _QuantizationTable {
6416
+ precision = [];
6417
+ // Quantization precision 8 or 16
6418
+ tq = [0, 0, 0, 0];
6419
+ // 1: this table is presented
6420
+ quantTables = createArray(4, 64);
6421
+ // Tables
6422
+ static enhanceQuantizationTable = function(qtab, table) {
6423
+ for (let i = 0; i < 8; i += 1) {
6424
+ qtab[table[0 * 8 + i]] *= 90;
6425
+ qtab[table[4 * 8 + i]] *= 90;
6426
+ qtab[table[2 * 8 + i]] *= 118;
6427
+ qtab[table[6 * 8 + i]] *= 49;
6428
+ qtab[table[5 * 8 + i]] *= 71;
6429
+ qtab[table[1 * 8 + i]] *= 126;
6430
+ qtab[table[7 * 8 + i]] *= 25;
6431
+ qtab[table[3 * 8 + i]] *= 106;
6432
+ }
6433
+ for (let i = 0; i < 8; i += 1) {
6434
+ qtab[table[0 + 8 * i]] *= 90;
6435
+ qtab[table[4 + 8 * i]] *= 90;
6436
+ qtab[table[2 + 8 * i]] *= 118;
6437
+ qtab[table[6 + 8 * i]] *= 49;
6438
+ qtab[table[5 + 8 * i]] *= 71;
6439
+ qtab[table[1 + 8 * i]] *= 126;
6440
+ qtab[table[7 + 8 * i]] *= 25;
6441
+ qtab[table[3 + 8 * i]] *= 106;
6442
+ }
6443
+ for (let i = 0; i < 64; i += 1) {
6444
+ qtab[i] >>= 6;
6445
+ }
6446
+ };
6447
+ read(data, table) {
6448
+ let count = 0;
6449
+ let temp;
6450
+ let t;
6451
+ let i;
6452
+ const length = data.get16();
6618
6453
  count += 2;
6619
-
6620
6454
  while (count < length) {
6621
- temp = data.get8();
6622
- count+=1;
6623
- t = temp & 0x0F;
6624
-
6625
- if (t > 3) {
6626
- throw new Error("ERROR: Quantization table ID > 3");
6627
- }
6628
-
6629
- this.precision[t] = temp >> 4;
6630
-
6631
- if (this.precision[t] === 0) {
6632
- this.precision[t] = 8;
6633
- } else if (this.precision[t] === 1) {
6634
- this.precision[t] = 16;
6635
- } else {
6636
- throw new Error("ERROR: Quantization table precision error");
6455
+ temp = data.get8();
6456
+ count += 1;
6457
+ t = temp & 15;
6458
+ if (t > 3) {
6459
+ throw new Error("ERROR: Quantization table ID > 3");
6460
+ }
6461
+ this.precision[t] = temp >> 4;
6462
+ if (this.precision[t] === 0) {
6463
+ this.precision[t] = 8;
6464
+ } else if (this.precision[t] === 1) {
6465
+ this.precision[t] = 16;
6466
+ } else {
6467
+ throw new Error("ERROR: Quantization table precision error");
6468
+ }
6469
+ this.tq[t] = 1;
6470
+ if (this.precision[t] === 8) {
6471
+ for (i = 0; i < 64; i += 1) {
6472
+ if (count > length) {
6473
+ throw new Error("ERROR: Quantization table format error");
6474
+ }
6475
+ this.quantTables[t][i] = data.get8();
6476
+ count += 1;
6637
6477
  }
6638
-
6639
- this.tq[t] = 1;
6640
-
6641
- if (this.precision[t] === 8) {
6642
- for (i = 0; i < 64; i+=1) {
6643
- if (count > length) {
6644
- throw new Error("ERROR: Quantization table format error");
6645
- }
6646
-
6647
- this.quantTables[t][i] = data.get8();
6648
- count+=1;
6649
- }
6650
-
6651
- jpeg.lossless.QuantizationTable.enhanceQuantizationTable(this.quantTables[t], table);
6652
- } else {
6653
- for (i = 0; i < 64; i+=1) {
6654
- if (count > length) {
6655
- throw new Error("ERROR: Quantization table format error");
6656
- }
6657
-
6658
- this.quantTables[t][i] = data.get16();
6659
- count += 2;
6660
- }
6661
-
6662
- jpeg.lossless.QuantizationTable.enhanceQuantizationTable(this.quantTables[t], table);
6478
+ _QuantizationTable.enhanceQuantizationTable(this.quantTables[t], table);
6479
+ } else {
6480
+ for (i = 0; i < 64; i += 1) {
6481
+ if (count > length) {
6482
+ throw new Error("ERROR: Quantization table format error");
6483
+ }
6484
+ this.quantTables[t][i] = data.get16();
6485
+ count += 2;
6663
6486
  }
6487
+ _QuantizationTable.enhanceQuantizationTable(this.quantTables[t], table);
6488
+ }
6664
6489
  }
6665
-
6666
6490
  if (count !== length) {
6667
- throw new Error("ERROR: Quantization table error [count!=Lq]");
6491
+ throw new Error("ERROR: Quantization table error [count!=Lq]");
6668
6492
  }
6669
-
6670
6493
  return 1;
6494
+ }
6671
6495
  };
6672
6496
 
6673
-
6674
-
6675
- /*** Exports ***/
6676
-
6677
- var moduleType = typeof module;
6678
- if ((moduleType !== 'undefined') && module.exports) {
6679
- module.exports = jpeg.lossless.QuantizationTable;
6680
- }
6681
-
6682
- },{"./data-stream.js":2,"./utils.js":10}],8:[function(require,module,exports){
6683
- /*
6684
- * Copyright (C) 2015 Michael Martinez
6685
- * Changes: Added support for selection values 2-7, fixed minor bugs &
6686
- * warnings, split into multiple class files, and general clean up.
6687
- *
6688
- * 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.
6689
- */
6690
-
6691
- /*
6692
- * Copyright (C) Helmut Dersch
6693
- *
6694
- * Permission is hereby granted, free of charge, to any person obtaining a copy
6695
- * of this software and associated documentation files (the "Software"), to deal
6696
- * in the Software without restriction, including without limitation the rights
6697
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6698
- * copies of the Software, and to permit persons to whom the Software is
6699
- * furnished to do so, subject to the following conditions:
6700
-
6701
- * The above copyright notice and this permission notice shall be included in
6702
- * all copies or substantial portions of the Software.
6703
-
6704
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6705
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6706
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6707
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6708
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
6709
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
6710
- * THE SOFTWARE.
6711
- */
6712
-
6713
- /*jslint browser: true, node: true */
6714
- /*global require, module */
6715
-
6716
- "use strict";
6717
-
6718
- /*** Imports ***/
6719
- var jpeg = jpeg || {};
6720
- jpeg.lossless = jpeg.lossless || {};
6721
-
6722
-
6723
- /*** Constructor ***/
6724
- jpeg.lossless.ScanComponent = jpeg.lossless.ScanComponent || function () {
6725
- this.acTabSel = 0; // AC table selector
6726
- this.dcTabSel = 0; // DC table selector
6727
- this.scanCompSel = 0; // Scan component selector
6728
- };
6729
-
6730
-
6731
-
6732
- /*** Exports ***/
6733
-
6734
- var moduleType = typeof module;
6735
- if ((moduleType !== 'undefined') && module.exports) {
6736
- module.exports = jpeg.lossless.ScanComponent;
6737
- }
6738
-
6739
- },{}],9:[function(require,module,exports){
6740
- /*
6741
- * Copyright (C) 2015 Michael Martinez
6742
- * Changes: Added support for selection values 2-7, fixed minor bugs &
6743
- * warnings, split into multiple class files, and general clean up.
6744
- *
6745
- * 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.
6746
- */
6747
-
6748
- /*
6749
- * Copyright (C) Helmut Dersch
6750
- *
6751
- * Permission is hereby granted, free of charge, to any person obtaining a copy
6752
- * of this software and associated documentation files (the "Software"), to deal
6753
- * in the Software without restriction, including without limitation the rights
6754
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6755
- * copies of the Software, and to permit persons to whom the Software is
6756
- * furnished to do so, subject to the following conditions:
6757
-
6758
- * The above copyright notice and this permission notice shall be included in
6759
- * all copies or substantial portions of the Software.
6760
-
6761
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6762
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6763
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6764
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6765
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
6766
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
6767
- * THE SOFTWARE.
6768
- */
6769
-
6770
- /*jslint browser: true, node: true */
6771
- /*global require, module */
6772
-
6773
- "use strict";
6774
-
6775
- /*** Imports ***/
6776
- var jpeg = jpeg || {};
6777
- jpeg.lossless = jpeg.lossless || {};
6778
- jpeg.lossless.DataStream = jpeg.lossless.DataStream || ((typeof require !== 'undefined') ? require('./data-stream.js') : null);
6779
- jpeg.lossless.ScanComponent = jpeg.lossless.ScanComponent || ((typeof require !== 'undefined') ? require('./scan-component.js') : null);
6780
-
6781
-
6782
- /*** Constructor ***/
6783
- jpeg.lossless.ScanHeader = jpeg.lossless.ScanHeader || function () {
6784
- this.ah = 0;
6785
- this.al = 0;
6786
- this.numComp = 0; // Number of components in the scan
6787
- this.selection = 0; // Start of spectral or predictor selection
6788
- this.spectralEnd = 0; // End of spectral selection
6789
- this.components = [];
6497
+ // src/scan-component.ts
6498
+ var ScanComponent = {
6499
+ acTabSel: 0,
6500
+ // AC table selector
6501
+ dcTabSel: 0,
6502
+ // DC table selector
6503
+ scanCompSel: 0
6504
+ // Scan component selector
6790
6505
  };
6791
6506
 
6792
-
6793
- /*** Prototype Methods ***/
6794
-
6795
- jpeg.lossless.ScanHeader.prototype.read = function(data) {
6796
- /*jslint bitwise: true */
6797
-
6798
- var count = 0, length, i, temp;
6799
-
6800
- length = data.get16();
6507
+ // src/scan-header.ts
6508
+ var ScanHeader = class {
6509
+ ah = 0;
6510
+ al = 0;
6511
+ numComp = 0;
6512
+ // Number of components in the scan
6513
+ selection = 0;
6514
+ // Start of spectral or predictor selection
6515
+ spectralEnd = 0;
6516
+ // End of spectral selection
6517
+ components = [];
6518
+ read(data) {
6519
+ let count = 0;
6520
+ let i;
6521
+ let temp;
6522
+ const length = data.get16();
6801
6523
  count += 2;
6802
-
6803
6524
  this.numComp = data.get8();
6804
- count+=1;
6805
-
6806
- for (i = 0; i < this.numComp; i+=1) {
6807
- this.components[i] = new jpeg.lossless.ScanComponent();
6808
-
6809
- if (count > length) {
6810
- throw new Error("ERROR: scan header format error");
6811
- }
6812
-
6813
- this.components[i].scanCompSel = data.get8();
6814
- count+=1;
6815
-
6816
- temp = data.get8();
6817
- count+=1;
6818
-
6819
- this.components[i].dcTabSel = (temp >> 4);
6820
- this.components[i].acTabSel = (temp & 0x0F);
6525
+ count += 1;
6526
+ for (i = 0; i < this.numComp; i += 1) {
6527
+ this.components[i] = { ...ScanComponent };
6528
+ if (count > length) {
6529
+ throw new Error("ERROR: scan header format error");
6530
+ }
6531
+ this.components[i].scanCompSel = data.get8();
6532
+ count += 1;
6533
+ temp = data.get8();
6534
+ count += 1;
6535
+ this.components[i].dcTabSel = temp >> 4;
6536
+ this.components[i].acTabSel = temp & 15;
6821
6537
  }
6822
-
6823
6538
  this.selection = data.get8();
6824
- count+=1;
6825
-
6539
+ count += 1;
6826
6540
  this.spectralEnd = data.get8();
6827
- count+=1;
6828
-
6541
+ count += 1;
6829
6542
  temp = data.get8();
6830
- this.ah = (temp >> 4);
6831
- this.al = (temp & 0x0F);
6832
- count+=1;
6833
-
6543
+ this.ah = temp >> 4;
6544
+ this.al = temp & 15;
6545
+ count += 1;
6834
6546
  if (count !== length) {
6835
- throw new Error("ERROR: scan header format error [count!=Ns]");
6547
+ throw new Error("ERROR: scan header format error [count!=Ns]");
6836
6548
  }
6837
-
6838
6549
  return 1;
6550
+ }
6839
6551
  };
6840
6552
 
6841
-
6842
-
6843
- /*** Exports ***/
6844
-
6845
- var moduleType = typeof module;
6846
- if ((moduleType !== 'undefined') && module.exports) {
6847
- module.exports = jpeg.lossless.ScanHeader;
6848
- }
6849
-
6850
- },{"./data-stream.js":2,"./scan-component.js":8}],10:[function(require,module,exports){
6851
- /*
6852
- * Copyright (C) 2015 Michael Martinez
6853
- * Changes: Added support for selection values 2-7, fixed minor bugs &
6854
- * warnings, split into multiple class files, and general clean up.
6855
- *
6856
- * 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.
6857
- */
6858
-
6859
- /*
6860
- * Copyright (C) Helmut Dersch
6861
- *
6862
- * Permission is hereby granted, free of charge, to any person obtaining a copy
6863
- * of this software and associated documentation files (the "Software"), to deal
6864
- * in the Software without restriction, including without limitation the rights
6865
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6866
- * copies of the Software, and to permit persons to whom the Software is
6867
- * furnished to do so, subject to the following conditions:
6868
-
6869
- * The above copyright notice and this permission notice shall be included in
6870
- * all copies or substantial portions of the Software.
6871
-
6872
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6873
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6874
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6875
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6876
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
6877
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
6878
- * THE SOFTWARE.
6879
- */
6880
-
6881
- /*jslint browser: true, node: true */
6882
- /*global require, module */
6883
-
6884
- "use strict";
6885
-
6886
- /*** Imports ***/
6887
- var jpeg = jpeg || {};
6888
- jpeg.lossless = jpeg.lossless || {};
6889
-
6890
-
6891
- /*** Constructor ***/
6892
- jpeg.lossless.Utils = jpeg.lossless.Utils || {};
6893
-
6894
-
6895
- /*** Static methods ***/
6896
-
6897
- // http://stackoverflow.com/questions/966225/how-can-i-create-a-two-dimensional-array-in-javascript
6898
- jpeg.lossless.Utils.createArray = function (length) {
6899
- var arr = new Array(length || 0),
6900
- i = length;
6901
-
6902
- if (arguments.length > 1) {
6903
- var args = Array.prototype.slice.call(arguments, 1);
6904
- while(i--) arr[length-1 - i] = jpeg.lossless.Utils.createArray.apply(this, args);
6553
+ // src/decoder.ts
6554
+ var littleEndian = function() {
6555
+ const buffer = new ArrayBuffer(2);
6556
+ new DataView(buffer).setInt16(
6557
+ 0,
6558
+ 256,
6559
+ true
6560
+ /* littleEndian */
6561
+ );
6562
+ return new Int16Array(buffer)[0] === 256;
6563
+ }();
6564
+ var Decoder = class _Decoder {
6565
+ static IDCT_P = [
6566
+ 0,
6567
+ 5,
6568
+ 40,
6569
+ 16,
6570
+ 45,
6571
+ 2,
6572
+ 7,
6573
+ 42,
6574
+ 21,
6575
+ 56,
6576
+ 8,
6577
+ 61,
6578
+ 18,
6579
+ 47,
6580
+ 1,
6581
+ 4,
6582
+ 41,
6583
+ 23,
6584
+ 58,
6585
+ 13,
6586
+ 32,
6587
+ 24,
6588
+ 37,
6589
+ 10,
6590
+ 63,
6591
+ 17,
6592
+ 44,
6593
+ 3,
6594
+ 6,
6595
+ 43,
6596
+ 20,
6597
+ 57,
6598
+ 15,
6599
+ 34,
6600
+ 29,
6601
+ 48,
6602
+ 53,
6603
+ 26,
6604
+ 39,
6605
+ 9,
6606
+ 60,
6607
+ 19,
6608
+ 46,
6609
+ 22,
6610
+ 59,
6611
+ 12,
6612
+ 33,
6613
+ 31,
6614
+ 50,
6615
+ 55,
6616
+ 25,
6617
+ 36,
6618
+ 11,
6619
+ 62,
6620
+ 14,
6621
+ 35,
6622
+ 28,
6623
+ 49,
6624
+ 52,
6625
+ 27,
6626
+ 38,
6627
+ 30,
6628
+ 51,
6629
+ 54
6630
+ ];
6631
+ static TABLE = [
6632
+ 0,
6633
+ 1,
6634
+ 5,
6635
+ 6,
6636
+ 14,
6637
+ 15,
6638
+ 27,
6639
+ 28,
6640
+ 2,
6641
+ 4,
6642
+ 7,
6643
+ 13,
6644
+ 16,
6645
+ 26,
6646
+ 29,
6647
+ 42,
6648
+ 3,
6649
+ 8,
6650
+ 12,
6651
+ 17,
6652
+ 25,
6653
+ 30,
6654
+ 41,
6655
+ 43,
6656
+ 9,
6657
+ 11,
6658
+ 18,
6659
+ 24,
6660
+ 31,
6661
+ 40,
6662
+ 44,
6663
+ 53,
6664
+ 10,
6665
+ 19,
6666
+ 23,
6667
+ 32,
6668
+ 39,
6669
+ 45,
6670
+ 52,
6671
+ 54,
6672
+ 20,
6673
+ 22,
6674
+ 33,
6675
+ 38,
6676
+ 46,
6677
+ 51,
6678
+ 55,
6679
+ 60,
6680
+ 21,
6681
+ 34,
6682
+ 37,
6683
+ 47,
6684
+ 50,
6685
+ 56,
6686
+ 59,
6687
+ 61,
6688
+ 35,
6689
+ 36,
6690
+ 48,
6691
+ 49,
6692
+ 57,
6693
+ 58,
6694
+ 62,
6695
+ 63
6696
+ ];
6697
+ static MAX_HUFFMAN_SUBTREE = 50;
6698
+ static MSB = 2147483648;
6699
+ static RESTART_MARKER_BEGIN = 65488;
6700
+ static RESTART_MARKER_END = 65495;
6701
+ buffer = null;
6702
+ stream = null;
6703
+ frame = new FrameHeader();
6704
+ huffTable = new HuffmanTable();
6705
+ quantTable = new QuantizationTable();
6706
+ scan = new ScanHeader();
6707
+ DU = createArray(10, 4, 64);
6708
+ // at most 10 data units in a MCU, at most 4 data units in one component
6709
+ HuffTab = createArray(4, 2, 50 * 256);
6710
+ IDCT_Source = [];
6711
+ nBlock = [];
6712
+ // number of blocks in the i-th Comp in a scan
6713
+ acTab = createArray(10, 1);
6714
+ // ac HuffTab for the i-th Comp in a scan
6715
+ dcTab = createArray(10, 1);
6716
+ // dc HuffTab for the i-th Comp in a scan
6717
+ qTab = createArray(10, 1);
6718
+ // quantization table for the i-th Comp in a scan
6719
+ marker = 0;
6720
+ markerIndex = 0;
6721
+ numComp = 0;
6722
+ restartInterval = 0;
6723
+ selection = 0;
6724
+ xDim = 0;
6725
+ yDim = 0;
6726
+ xLoc = 0;
6727
+ yLoc = 0;
6728
+ outputData = null;
6729
+ restarting = false;
6730
+ mask = 0;
6731
+ numBytes = 0;
6732
+ precision = void 0;
6733
+ components = [];
6734
+ getter = null;
6735
+ setter = null;
6736
+ output = null;
6737
+ selector = null;
6738
+ /**
6739
+ * The Decoder constructor.
6740
+ * @property {number} numBytes - number of bytes per component
6741
+ * @type {Function}
6742
+ */
6743
+ constructor(buffer, numBytes) {
6744
+ this.buffer = buffer ?? null;
6745
+ this.numBytes = numBytes ?? 0;
6746
+ }
6747
+ /**
6748
+ * Returns decompressed data.
6749
+ */
6750
+ decompress(buffer, offset, length) {
6751
+ const result = this.decode(buffer, offset, length);
6752
+ return result.buffer;
6753
+ }
6754
+ decode(buffer, offset, length, numBytes) {
6755
+ let scanNum = 0;
6756
+ const pred = [];
6757
+ let i;
6758
+ let compN;
6759
+ const temp = [];
6760
+ const index = [];
6761
+ let mcuNum;
6762
+ if (buffer) {
6763
+ this.buffer = buffer;
6764
+ }
6765
+ if (numBytes !== void 0) {
6766
+ this.numBytes = numBytes;
6767
+ }
6768
+ this.stream = new DataStream(this.buffer, offset, length);
6769
+ this.buffer = null;
6770
+ this.xLoc = 0;
6771
+ this.yLoc = 0;
6772
+ let current = this.stream.get16();
6773
+ if (current !== 65496) {
6774
+ throw new Error("Not a JPEG file");
6905
6775
  }
6906
-
6907
- return arr;
6908
- };
6909
-
6910
-
6911
- // http://stackoverflow.com/questions/18638900/javascript-crc32
6912
- jpeg.lossless.Utils.makeCRCTable = function(){
6913
- var c;
6914
- var crcTable = [];
6915
- for(var n =0; n < 256; n++){
6916
- c = n;
6917
- for(var k =0; k < 8; k++){
6918
- c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
6919
- }
6920
- crcTable[n] = c;
6776
+ current = this.stream.get16();
6777
+ while (current >> 4 !== 4092 || current === 65476) {
6778
+ switch (current) {
6779
+ case 65476:
6780
+ this.huffTable.read(this.stream, this.HuffTab);
6781
+ break;
6782
+ case 65484:
6783
+ throw new Error("Program doesn't support arithmetic coding. (format throw new IOException)");
6784
+ case 65499:
6785
+ this.quantTable.read(this.stream, _Decoder.TABLE);
6786
+ break;
6787
+ case 65501:
6788
+ this.restartInterval = this.readNumber() ?? 0;
6789
+ break;
6790
+ case 65504:
6791
+ case 65505:
6792
+ case 65506:
6793
+ case 65507:
6794
+ case 65508:
6795
+ case 65509:
6796
+ case 65510:
6797
+ case 65511:
6798
+ case 65512:
6799
+ case 65513:
6800
+ case 65514:
6801
+ case 65515:
6802
+ case 65516:
6803
+ case 65517:
6804
+ case 65518:
6805
+ case 65519:
6806
+ this.readApp();
6807
+ break;
6808
+ case 65534:
6809
+ this.readComment();
6810
+ break;
6811
+ default:
6812
+ if (current >> 8 !== 255) {
6813
+ throw new Error("ERROR: format throw new IOException! (decode)");
6814
+ }
6815
+ }
6816
+ current = this.stream.get16();
6921
6817
  }
6922
- return crcTable;
6923
- };
6924
-
6925
- jpeg.lossless.Utils.crc32 = function(dataView) {
6926
- var uint8view = new Uint8Array(dataView.buffer);
6927
- var crcTable = jpeg.lossless.Utils.crcTable || (jpeg.lossless.Utils.crcTable = jpeg.lossless.Utils.makeCRCTable());
6928
- var crc = 0 ^ (-1);
6929
-
6930
- for (var i = 0; i < uint8view.length; i++ ) {
6931
- crc = (crc >>> 8) ^ crcTable[(crc ^ uint8view[i]) & 0xFF];
6818
+ if (current < 65472 || current > 65479) {
6819
+ throw new Error("ERROR: could not handle arithmetic code!");
6932
6820
  }
6933
-
6934
- return (crc ^ (-1)) >>> 0;
6935
- };
6936
-
6937
-
6938
- /*** Exports ***/
6939
-
6940
- var moduleType = typeof module;
6941
- if ((moduleType !== 'undefined') && module.exports) {
6942
- module.exports = jpeg.lossless.Utils;
6943
- }
6944
-
6945
- },{}]},{},[6])(6)
6946
- });
6947
-
6948
-
6949
- /***/ }),
6950
-
6951
- /***/ 823:
6952
- /***/ ((module) => {
6953
-
6954
- "use strict";
6955
- module.exports = window [Symbol .for ("X_ITE.X3D-9.4.4")] .require ("lib/jquery");
6956
-
6957
- /***/ }),
6958
-
6959
- /***/ 497:
6960
- /***/ (() => {
6961
-
6962
- /* (ignored) */
6963
-
6964
- /***/ }),
6965
-
6966
- /***/ 13:
6967
- /***/ (() => {
6968
-
6969
- /* (ignored) */
6970
-
6971
- /***/ }),
6972
-
6973
- /***/ 722:
6974
- /***/ (() => {
6975
-
6976
- /* (ignored) */
6977
-
6978
- /***/ }),
6979
-
6980
- /***/ 978:
6981
- /***/ (() => {
6982
-
6983
- /* (ignored) */
6984
-
6985
- /***/ }),
6986
-
6987
- /***/ 559:
6988
- /***/ (() => {
6989
-
6990
- /* (ignored) */
6991
-
6992
- /***/ })
6993
-
6994
- /******/ });
6995
- /************************************************************************/
6996
- /******/ // The module cache
6997
- /******/ var __webpack_module_cache__ = {};
6998
- /******/
6999
- /******/ // The require function
7000
- /******/ function __webpack_require__(moduleId) {
7001
- /******/ // Check if module is in cache
7002
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
7003
- /******/ if (cachedModule !== undefined) {
7004
- /******/ return cachedModule.exports;
7005
- /******/ }
7006
- /******/ // Create a new module (and put it into the cache)
7007
- /******/ var module = __webpack_module_cache__[moduleId] = {
7008
- /******/ // no module.id needed
7009
- /******/ // no module.loaded needed
7010
- /******/ exports: {}
7011
- /******/ };
7012
- /******/
7013
- /******/ // Execute the module function
7014
- /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
7015
- /******/
7016
- /******/ // Return the exports of the module
7017
- /******/ return module.exports;
7018
- /******/ }
7019
- /******/
7020
- /************************************************************************/
7021
- /******/ /* webpack/runtime/compat get default export */
7022
- /******/ (() => {
7023
- /******/ // getDefaultExport function for compatibility with non-harmony modules
7024
- /******/ __webpack_require__.n = (module) => {
7025
- /******/ var getter = module && module.__esModule ?
7026
- /******/ () => (module['default']) :
7027
- /******/ () => (module);
7028
- /******/ __webpack_require__.d(getter, { a: getter });
7029
- /******/ return getter;
7030
- /******/ };
7031
- /******/ })();
7032
- /******/
7033
- /******/ /* webpack/runtime/define property getters */
7034
- /******/ (() => {
7035
- /******/ // define getter functions for harmony exports
7036
- /******/ __webpack_require__.d = (exports, definition) => {
7037
- /******/ for(var key in definition) {
7038
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
7039
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
7040
- /******/ }
7041
- /******/ }
7042
- /******/ };
7043
- /******/ })();
7044
- /******/
7045
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
7046
- /******/ (() => {
7047
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
7048
- /******/ })();
7049
- /******/
7050
- /************************************************************************/
7051
- var __webpack_exports__ = {};
7052
- // This entry need to be wrapped in an IIFE because it need to be in strict mode.
7053
- (() => {
7054
- "use strict";
7055
-
7056
- // UNUSED EXPORTS: default
7057
-
7058
- ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Components\")"
7059
- const Components_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.4.4")] .require ("x_ite/Components");
7060
- var Components_default = /*#__PURE__*/__webpack_require__.n(Components_namespaceObject);
7061
- ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Fields\")"
7062
- const Fields_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.4.4")] .require ("x_ite/Fields");
7063
- var Fields_default = /*#__PURE__*/__webpack_require__.n(Fields_namespaceObject);
7064
- ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Base/X3DFieldDefinition\")"
7065
- const X3DFieldDefinition_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.4.4")] .require ("x_ite/Base/X3DFieldDefinition");
7066
- var X3DFieldDefinition_default = /*#__PURE__*/__webpack_require__.n(X3DFieldDefinition_namespaceObject);
7067
- ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Base/FieldDefinitionArray\")"
7068
- const FieldDefinitionArray_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.4.4")] .require ("x_ite/Base/FieldDefinitionArray");
7069
- var FieldDefinitionArray_default = /*#__PURE__*/__webpack_require__.n(FieldDefinitionArray_namespaceObject);
7070
- ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Components/Texturing/X3DSingleTextureNode\")"
7071
- const X3DSingleTextureNode_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.4.4")] .require ("x_ite/Components/Texturing/X3DSingleTextureNode");
7072
- var X3DSingleTextureNode_default = /*#__PURE__*/__webpack_require__.n(X3DSingleTextureNode_namespaceObject);
7073
- ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Base/X3DConstants\")"
7074
- const X3DConstants_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.4.4")] .require ("x_ite/Base/X3DConstants");
7075
- var X3DConstants_default = /*#__PURE__*/__webpack_require__.n(X3DConstants_namespaceObject);
7076
- ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Namespace\")"
7077
- const Namespace_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.4.4")] .require ("x_ite/Namespace");
7078
- var Namespace_default = /*#__PURE__*/__webpack_require__.n(Namespace_namespaceObject);
7079
- ;// CONCATENATED MODULE: ./src/x_ite/Components/Texturing3D/X3DTexture3DNode.js
7080
- /*******************************************************************************
7081
- *
7082
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7083
- *
7084
- * Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022.
7085
- *
7086
- * All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
7087
- *
7088
- * The copyright notice above does not evidence any actual of intended
7089
- * publication of such source code, and is an unpublished work by create3000.
7090
- * This material contains CONFIDENTIAL INFORMATION that is the property of
7091
- * create3000.
7092
- *
7093
- * No permission is granted to copy, distribute, or create derivative works from
7094
- * the contents of this software, in whole or in part, without the prior written
7095
- * permission of create3000.
7096
- *
7097
- * NON-MILITARY USE ONLY
7098
- *
7099
- * All create3000 software are effectively free software with a non-military use
7100
- * restriction. It is free. Well commented source is provided. You may reuse the
7101
- * source in any way you please with the exception anything that uses it must be
7102
- * marked to indicate is contains 'non-military use only' components.
7103
- *
7104
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7105
- *
7106
- * Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>.
7107
- *
7108
- * This file is part of the X_ITE Project.
7109
- *
7110
- * X_ITE is free software: you can redistribute it and/or modify it under the
7111
- * terms of the GNU General Public License version 3 only, as published by the
7112
- * Free Software Foundation.
7113
- *
7114
- * X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
7115
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
7116
- * A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
7117
- * details (a copy is included in the LICENSE file that accompanied this code).
7118
- *
7119
- * You should have received a copy of the GNU General Public License version 3
7120
- * along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a
7121
- * copy of the GPLv3 License.
7122
- *
7123
- * For Silvio, Joy and Adi.
7124
- *
7125
- ******************************************************************************/
7126
-
7127
-
7128
-
7129
-
7130
- const defaultData = new Uint8Array ([ 255, 255, 255, 255 ]);
7131
-
7132
- function X3DTexture3DNode (executionContext)
7133
- {
7134
- X3DSingleTextureNode_default().call (this, executionContext);
7135
-
7136
- this .addType ((X3DConstants_default()).X3DTexture3DNode);
7137
-
7138
- const gl = this .getBrowser () .getContext ();
7139
-
7140
- this .target = gl .TEXTURE_3D;
7141
- this .width = 0;
7142
- this .height = 0;
7143
- this .depth = 0;
7144
- }
7145
-
7146
- Object .assign (Object .setPrototypeOf (X3DTexture3DNode .prototype, (X3DSingleTextureNode_default()).prototype),
7147
- {
7148
- initialize ()
7149
- {
7150
- X3DSingleTextureNode_default().prototype .initialize .call (this);
7151
-
7152
- this ._repeatS .addInterest ("updateTextureParameters", this);
7153
- this ._repeatT .addInterest ("updateTextureParameters", this);
7154
- this ._repeatR .addInterest ("updateTextureParameters", this);
7155
-
7156
- const gl = this .getBrowser () .getContext ();
7157
-
7158
- if (gl .getVersion () < 2)
7159
- return;
7160
-
7161
- gl .bindTexture (gl .TEXTURE_3D, this .getTexture ());
7162
- gl .texImage3D (gl .TEXTURE_3D, 0, gl .RGBA, 1, 1, 1, 0, gl .RGBA, gl .UNSIGNED_BYTE, defaultData);
7163
- },
7164
- getTarget ()
7165
- {
7166
- return this .target;
7167
- },
7168
- getTextureType ()
7169
- {
7170
- return 3;
7171
- },
7172
- getWidth ()
7173
- {
7174
- return this .width;
7175
- },
7176
- setWidth (value)
7177
- {
7178
- this .width = value;
7179
- },
7180
- getHeight ()
7181
- {
7182
- return this .height;
7183
- },
7184
- setHeight (value)
7185
- {
7186
- this .height = value;
7187
- },
7188
- getDepth ()
7189
- {
7190
- return this .depth;
7191
- },
7192
- setDepth (value)
7193
- {
7194
- this .depth = value;
7195
- },
7196
- clearTexture ()
7197
- {
7198
- const gl = this .getBrowser () .getContext ();
7199
-
7200
- this .setTextureFromData (1, 1, 1, false, gl .RGBA, defaultData);
7201
- },
7202
- setTextureFromData (width, height, depth, transparent, format, data)
7203
- {
7204
- this .width = width;
7205
- this .height = height;
7206
- this .depth = depth;
7207
-
7208
- const gl = this .getBrowser () .getContext ();
7209
-
7210
- if (gl .getVersion () < 2)
7211
- return;
7212
-
7213
- gl .bindTexture (gl .TEXTURE_3D, this .getTexture ());
7214
- gl .texImage3D (gl .TEXTURE_3D, 0, format, width, height, depth, 0, format, gl .UNSIGNED_BYTE, data);
7215
-
7216
- this .setTransparent (transparent);
7217
- this .updateTextureParameters ();
7218
- this .addNodeEvent ();
7219
- },
7220
- updateTextureParameters ()
7221
- {
7222
- X3DSingleTextureNode_default().prototype .updateTextureParameters .call (this,
7223
- this .target,
7224
- this ._textureProperties .getValue (),
7225
- this .texturePropertiesNode,
7226
- this .width,
7227
- this .height,
7228
- this ._repeatS .getValue (),
7229
- this ._repeatT .getValue (),
7230
- this ._repeatR .getValue ());
7231
- },
7232
- setShaderUniforms (gl, shaderObject, renderObject, channel = shaderObject .x3d_Texture [0])
7233
- {
7234
- const textureUnit = this .getBrowser () .getTexture3DUnit ();
7235
-
7236
- gl .activeTexture (gl .TEXTURE0 + textureUnit);
7237
- gl .bindTexture (gl .TEXTURE_3D, this .getTexture ());
7238
- gl .uniform1i (channel .texture3D, textureUnit);
7239
- },
7240
- });
7241
-
7242
- Object .defineProperties (X3DTexture3DNode,
7243
- {
7244
- typeName:
7245
- {
7246
- value: "X3DTexture3DNode",
7247
- enumerable: true,
7248
- },
7249
- componentInfo:
7250
- {
7251
- value: Object .freeze ({ name: "Texturing3D", level: 1 }),
7252
- enumerable: true,
7253
- },
7254
- });
7255
-
7256
- const __default__ = X3DTexture3DNode;
7257
- ;
7258
-
7259
- Namespace_default().add ("X3DTexture3DNode", "x_ite/Components/Texturing3D/X3DTexture3DNode", __default__);
7260
- /* harmony default export */ const Texturing3D_X3DTexture3DNode = (__default__);
7261
- ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Base/X3DCast\")"
7262
- const X3DCast_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.4.4")] .require ("x_ite/Base/X3DCast");
7263
- var X3DCast_default = /*#__PURE__*/__webpack_require__.n(X3DCast_namespaceObject);
7264
- ;// CONCATENATED MODULE: ./src/x_ite/Components/Texturing3D/ComposedTexture3D.js
7265
- /*******************************************************************************
7266
- *
7267
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7268
- *
7269
- * Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022.
7270
- *
7271
- * All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
7272
- *
7273
- * The copyright notice above does not evidence any actual of intended
7274
- * publication of such source code, and is an unpublished work by create3000.
7275
- * This material contains CONFIDENTIAL INFORMATION that is the property of
7276
- * create3000.
7277
- *
7278
- * No permission is granted to copy, distribute, or create derivative works from
7279
- * the contents of this software, in whole or in part, without the prior written
7280
- * permission of create3000.
7281
- *
7282
- * NON-MILITARY USE ONLY
7283
- *
7284
- * All create3000 software are effectively free software with a non-military use
7285
- * restriction. It is free. Well commented source is provided. You may reuse the
7286
- * source in any way you please with the exception anything that uses it must be
7287
- * marked to indicate is contains 'non-military use only' components.
7288
- *
7289
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7290
- *
7291
- * Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>.
7292
- *
7293
- * This file is part of the X_ITE Project.
7294
- *
7295
- * X_ITE is free software: you can redistribute it and/or modify it under the
7296
- * terms of the GNU General Public License version 3 only, as published by the
7297
- * Free Software Foundation.
7298
- *
7299
- * X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
7300
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
7301
- * A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
7302
- * details (a copy is included in the LICENSE file that accompanied this code).
7303
- *
7304
- * You should have received a copy of the GNU General Public License version 3
7305
- * along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a
7306
- * copy of the GPLv3 License.
7307
- *
7308
- * For Silvio, Joy and Adi.
7309
- *
7310
- ******************************************************************************/
7311
-
7312
-
7313
-
7314
-
7315
-
7316
-
7317
-
7318
-
7319
- function ComposedTexture3D (executionContext)
7320
- {
7321
- Texturing3D_X3DTexture3DNode .call (this, executionContext);
7322
-
7323
- this .addType ((X3DConstants_default()).ComposedTexture3D);
7324
-
7325
- this .addChildObjects ((X3DConstants_default()).inputOutput, "update", new (Fields_default()).SFTime ());
7326
-
7327
- this .textureNodes = [ ];
7328
- }
7329
-
7330
- Object .assign (Object .setPrototypeOf (ComposedTexture3D .prototype, Texturing3D_X3DTexture3DNode .prototype),
7331
- {
7332
- initialize ()
7333
- {
7334
- Texturing3D_X3DTexture3DNode .prototype .initialize .call (this);
7335
-
7336
- this ._texture .addInterest ("set_texture__", this);
7337
- this ._update .addInterest ("update", this);
7338
-
7339
- this .set_texture__ ();
7340
- },
7341
- set_texture__ ()
7342
- {
7343
- const textureNodes = this .textureNodes;
7344
-
7345
- for (const textureNode of textureNodes)
7346
- textureNode .removeInterest ("set_update__", this);
7347
-
7348
- textureNodes .length = 0;
7349
-
7350
- for (const node of this ._texture)
7351
- {
7352
- const textureNode = X3DCast_default() ((X3DConstants_default()).X3DTexture2DNode, node);
7353
-
7354
- if (textureNode)
7355
- textureNodes .push (textureNode);
6821
+ this.frame.read(this.stream);
6822
+ current = this.stream.get16();
6823
+ do {
6824
+ while (current !== 65498) {
6825
+ switch (current) {
6826
+ case 65476:
6827
+ this.huffTable.read(this.stream, this.HuffTab);
6828
+ break;
6829
+ case 65484:
6830
+ throw new Error("Program doesn't support arithmetic coding. (format throw new IOException)");
6831
+ case 65499:
6832
+ this.quantTable.read(this.stream, _Decoder.TABLE);
6833
+ break;
6834
+ case 65501:
6835
+ this.restartInterval = this.readNumber() ?? 0;
6836
+ break;
6837
+ case 65504:
6838
+ case 65505:
6839
+ case 65506:
6840
+ case 65507:
6841
+ case 65508:
6842
+ case 65509:
6843
+ case 65510:
6844
+ case 65511:
6845
+ case 65512:
6846
+ case 65513:
6847
+ case 65514:
6848
+ case 65515:
6849
+ case 65516:
6850
+ case 65517:
6851
+ case 65518:
6852
+ case 65519:
6853
+ this.readApp();
6854
+ break;
6855
+ case 65534:
6856
+ this.readComment();
6857
+ break;
6858
+ default:
6859
+ if (current >> 8 !== 255) {
6860
+ throw new Error("ERROR: format throw new IOException! (Parser.decode)");
6861
+ }
6862
+ }
6863
+ current = this.stream.get16();
7356
6864
  }
7357
-
7358
- for (const textureNode of textureNodes)
7359
- textureNode .addInterest ("set_update__", this);
7360
-
7361
- this .set_update__ ();
7362
- },
7363
- set_update__ ()
7364
- {
7365
- this ._update .addEvent ();
7366
- },
7367
- isComplete ()
7368
- {
7369
- return this .textureNodes .every (textureNode => textureNode .checkLoadState () === (X3DConstants_default()).COMPLETE_STATE);
7370
- },
7371
- update ()
7372
- {
7373
- const textureNodes = this .textureNodes
7374
-
7375
- if (textureNodes .length === 0 || !this .isComplete ())
7376
- {
7377
- this .clearTexture ();
6865
+ this.precision = this.frame.precision;
6866
+ this.components = this.frame.components;
6867
+ if (!this.numBytes) {
6868
+ this.numBytes = Math.round(Math.ceil(this.precision / 8));
7378
6869
  }
7379
- else
7380
- {
7381
- const
7382
- gl = this .getBrowser () .getContext (),
7383
- width = textureNodes [0] .getWidth (),
7384
- height = textureNodes [0] .getHeight (),
7385
- depth = textureNodes .length,
7386
- frameBuffer = gl .createFramebuffer ();
7387
-
7388
- gl .bindFramebuffer (gl .FRAMEBUFFER, frameBuffer);
7389
- gl .bindTexture (gl .TEXTURE_3D, this .getTexture ());
7390
-
7391
- if (width !== this .getWidth () || height !== this .getHeight () || depth !== this .getDepth ())
7392
- {
7393
- const defaultData = new Uint8Array (width * height * depth * 4);
7394
-
7395
- gl .texImage3D (gl .TEXTURE_3D, 0, gl .RGBA, width, height, depth, 0, gl .RGBA, gl .UNSIGNED_BYTE, defaultData);
7396
- }
7397
-
7398
- for (const [i, textureNode] of this .textureNodes .entries ())
7399
- {
7400
- if (textureNode .getWidth () === width && textureNode .getHeight () === height)
7401
- {
7402
- gl .bindTexture (gl .TEXTURE_2D, textureNode .getTexture ());
7403
- gl .framebufferTexture2D (gl .FRAMEBUFFER, gl .COLOR_ATTACHMENT0, gl .TEXTURE_2D, textureNode .getTexture (), 0);
7404
-
7405
- if (textureNode .getTextureType () === 1)
7406
- {
7407
- // Copy and flip Y.
7408
- for (let y = 0; y < height; ++ y)
7409
- gl .copyTexSubImage3D (gl .TEXTURE_3D, 0, 0, height - y - 1, i, 0, y, width, 1);
7410
- }
7411
- else
7412
- {
7413
- gl .copyTexSubImage3D (gl .TEXTURE_3D, 0, 0, 0, i, 0, 0, width, height);
7414
- }
7415
- }
7416
- else
7417
- {
7418
- console .warn ("ComposedTexture3D: all textures must have same size.");
7419
- }
7420
- }
7421
-
7422
- gl .deleteFramebuffer (frameBuffer);
7423
-
7424
- this .setWidth (width);
7425
- this .setHeight (height);
7426
- this .setDepth (depth);
7427
- this .setTransparent (textureNodes .some (textureNode => textureNode .isTransparent ()));
7428
- this .setLinear (textureNodes .some (textureNode => textureNode .isLinear ()));
7429
- this .updateTextureParameters ();
6870
+ if (this.numBytes === 1) {
6871
+ this.mask = 255;
6872
+ } else {
6873
+ this.mask = 65535;
7430
6874
  }
7431
- },
7432
- });
7433
-
7434
- Object .defineProperties (ComposedTexture3D,
7435
- {
7436
- typeName:
7437
- {
7438
- value: "ComposedTexture3D",
7439
- enumerable: true,
7440
- },
7441
- componentInfo:
7442
- {
7443
- value: Object .freeze ({ name: "Texturing3D", level: 1 }),
7444
- enumerable: true,
7445
- },
7446
- containerField:
7447
- {
7448
- value: "texture",
7449
- enumerable: true,
7450
- },
7451
- specificationRange:
7452
- {
7453
- value: Object .freeze ({ from: "3.1", to: "Infinity" }),
7454
- enumerable: true,
7455
- },
7456
- fieldDefinitions:
7457
- {
7458
- value: new (FieldDefinitionArray_default()) ([
7459
- new (X3DFieldDefinition_default()) ((X3DConstants_default()).inputOutput, "metadata", new (Fields_default()).SFNode ()),
7460
- new (X3DFieldDefinition_default()) ((X3DConstants_default()).inputOutput, "description", new (Fields_default()).SFString ()),
7461
- new (X3DFieldDefinition_default()) ((X3DConstants_default()).initializeOnly, "repeatS", new (Fields_default()).SFBool ()),
7462
- new (X3DFieldDefinition_default()) ((X3DConstants_default()).initializeOnly, "repeatT", new (Fields_default()).SFBool ()),
7463
- new (X3DFieldDefinition_default()) ((X3DConstants_default()).initializeOnly, "repeatR", new (Fields_default()).SFBool ()),
7464
- new (X3DFieldDefinition_default()) ((X3DConstants_default()).initializeOnly, "textureProperties", new (Fields_default()).SFNode ()),
7465
- new (X3DFieldDefinition_default()) ((X3DConstants_default()).inputOutput, "texture", new (Fields_default()).MFNode ()),
7466
- ]),
7467
- enumerable: true,
7468
- },
7469
- });
7470
-
7471
- const ComposedTexture3D_default_ = ComposedTexture3D;
7472
- ;
7473
-
7474
- Namespace_default().add ("ComposedTexture3D", "x_ite/Components/Texturing3D/ComposedTexture3D", ComposedTexture3D_default_);
7475
- /* harmony default export */ const Texturing3D_ComposedTexture3D = (ComposedTexture3D_default_);
7476
- ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Components/Networking/X3DUrlObject\")"
7477
- const X3DUrlObject_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.4.4")] .require ("x_ite/Components/Networking/X3DUrlObject");
7478
- var X3DUrlObject_default = /*#__PURE__*/__webpack_require__.n(X3DUrlObject_namespaceObject);
7479
- ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Parser/Expressions\")"
7480
- const Expressions_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.4.4")] .require ("x_ite/Parser/Expressions");
7481
- var Expressions_default = /*#__PURE__*/__webpack_require__.n(Expressions_namespaceObject);
7482
- // EXTERNAL MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"lib/jquery\")"
7483
- var jquery_ = __webpack_require__(823);
7484
- var jquery_default = /*#__PURE__*/__webpack_require__.n(jquery_);
7485
- ;// CONCATENATED MODULE: ./src/x_ite/Browser/Texturing3D/NRRDParser.js
7486
- /*******************************************************************************
7487
- *
7488
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7489
- *
7490
- * Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022.
7491
- *
7492
- * All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
7493
- *
7494
- * The copyright notice above does not evidence any actual of intended
7495
- * publication of such source code, and is an unpublished work by create3000.
7496
- * This material contains CONFIDENTIAL INFORMATION that is the property of
7497
- * create3000.
7498
- *
7499
- * No permission is granted to copy, distribute, or create derivative works from
7500
- * the contents of this software, in whole or in part, without the prior written
7501
- * permission of create3000.
7502
- *
7503
- * NON-MILITARY USE ONLY
7504
- *
7505
- * All create3000 software are effectively free software with a non-military use
7506
- * restriction. It is free. Well commented source is provided. You may reuse the
7507
- * source in any way you please with the exception anything that uses it must be
7508
- * marked to indicate is contains 'non-military use only' components.
7509
- *
7510
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7511
- *
7512
- * Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>.
7513
- *
7514
- * This file is part of the X_ITE Project.
7515
- *
7516
- * X_ITE is free software: you can redistribute it and/or modify it under the
7517
- * terms of the GNU General Public License version 3 only, as published by the
7518
- * Free Software Foundation.
7519
- *
7520
- * X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
7521
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
7522
- * A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
7523
- * details (a copy is included in the LICENSE file that accompanied this code).
7524
- *
7525
- * You should have received a copy of the GNU General Public License version 3
7526
- * along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a
7527
- * copy of the GPLv3 License.
7528
- *
7529
- * For Silvio, Joy and Adi.
7530
- *
7531
- ******************************************************************************/
7532
-
7533
-
7534
-
7535
-
7536
- // Grammar
7537
-
7538
- const Grammar = Expressions_default() ({
7539
- NRRD: /^NRRD(\d+)\n/gy,
7540
- field: /([\w\s]+):\s*(.+?)\n/gy,
7541
- comment: /#[^\n]*\n/gy,
7542
- newLine: /\n/gy,
7543
- data: /(.*)$/sgy,
7544
- });
7545
-
7546
- // Parser
7547
-
7548
- function NRRDParser ()
7549
- {
7550
- this .fieldFunction = new Map ([
7551
- ["type", this .getType],
7552
- ["encoding", this .getEncoding],
7553
- ["dimension", this .getDimension],
7554
- ["sizes", this .getSizes],
7555
- ["endian", this .getEndian],
7556
- ]);
7557
- }
7558
-
7559
- Object .assign (NRRDParser .prototype,
7560
- {
7561
- parse (input)
7562
- {
7563
- this .setInput (input);
7564
-
7565
- if (this .getNRRD ())
7566
- {
7567
- this .getFields ();
7568
- this .getData ();
6875
+ this.scan.read(this.stream);
6876
+ this.numComp = this.scan.numComp;
6877
+ this.selection = this.scan.selection;
6878
+ if (this.numBytes === 1) {
6879
+ if (this.numComp === 3) {
6880
+ this.getter = this.getValueRGB;
6881
+ this.setter = this.setValueRGB;
6882
+ this.output = this.outputRGB;
6883
+ } else {
6884
+ this.getter = this.getValue8;
6885
+ this.setter = this.setValue8;
6886
+ this.output = this.outputSingle;
6887
+ }
6888
+ } else {
6889
+ this.getter = this.getValue8;
6890
+ this.setter = this.setValue8;
6891
+ this.output = this.outputSingle;
6892
+ }
6893
+ switch (this.selection) {
6894
+ case 2:
6895
+ this.selector = this.select2;
6896
+ break;
6897
+ case 3:
6898
+ this.selector = this.select3;
6899
+ break;
6900
+ case 4:
6901
+ this.selector = this.select4;
6902
+ break;
6903
+ case 5:
6904
+ this.selector = this.select5;
6905
+ break;
6906
+ case 6:
6907
+ this.selector = this.select6;
6908
+ break;
6909
+ case 7:
6910
+ this.selector = this.select7;
6911
+ break;
6912
+ default:
6913
+ this.selector = this.select1;
6914
+ break;
7569
6915
  }
7570
-
7571
- return this .nrrd;
7572
- },
7573
- setInput (value)
7574
- {
7575
- this .dataView = new DataView (value);
7576
- this .input = jquery_default().decodeText (value);
7577
- this .lastIndex = 0;
7578
- this .nrrd = { };
7579
- this .littleEndian = true;
7580
- },
7581
- getNRRD ()
7582
- {
7583
- if (Grammar .NRRD .parse (this))
7584
- {
7585
- this .nrrd .nrrd = true;
7586
- this .nrrd .version = parseInt (this .result [1]);
7587
- return true;
6916
+ for (i = 0; i < this.numComp; i += 1) {
6917
+ compN = this.scan.components[i].scanCompSel;
6918
+ this.qTab[i] = this.quantTable.quantTables[this.components[compN].quantTableSel];
6919
+ this.nBlock[i] = this.components[compN].vSamp * this.components[compN].hSamp;
6920
+ this.dcTab[i] = this.HuffTab[this.scan.components[i].dcTabSel][0];
6921
+ this.acTab[i] = this.HuffTab[this.scan.components[i].acTabSel][1];
7588
6922
  }
7589
-
7590
- this .nrrd .nrrd = false;
7591
- return false;
7592
- },
7593
- getFields ()
7594
- {
7595
- while (Grammar .comment .parse (this))
7596
- ;
7597
-
7598
- while (Grammar .field .parse (this))
7599
- {
7600
- const
7601
- key = this .result [1] .toLowerCase (),
7602
- value = this .result [2] .trim () .toLowerCase (),
7603
- fun = this .fieldFunction .get (key);
7604
-
7605
- if (fun)
7606
- fun .call (this, value);
7607
-
7608
- while (Grammar .comment .parse (this))
7609
- ;
6923
+ this.xDim = this.frame.dimX;
6924
+ this.yDim = this.frame.dimY;
6925
+ if (this.numBytes === 1) {
6926
+ this.outputData = new Uint8Array(new ArrayBuffer(this.xDim * this.yDim * this.numBytes * this.numComp));
6927
+ } else {
6928
+ this.outputData = new Uint16Array(new ArrayBuffer(this.xDim * this.yDim * this.numBytes * this.numComp));
7610
6929
  }
7611
- },
7612
- getType: (() =>
7613
- {
7614
- const types = new Map ([
7615
- ["signed char", ["signed char", 1]],
7616
- ["int8", ["signed char", 1]],
7617
- ["int8_t", ["signed char", 1]],
7618
- ["uchar", ["unsigned char", 1]],
7619
- ["unsigned char", ["unsigned char", 1]],
7620
- ["uint8", ["unsigned char", 1]],
7621
- ["uint8_t", ["unsigned char", 1]],
7622
- ["short", ["signed short", 2]],
7623
- ["short int", ["signed short", 2]],
7624
- ["signed short", ["signed short", 2]],
7625
- ["signed short int", ["signed short", 2]],
7626
- ["int16", ["signed short", 2]],
7627
- ["int16_t", ["signed short", 2]],
7628
- ["ushort", ["unsigned short", 2]],
7629
- ["unsigned short", ["unsigned short", 2]],
7630
- ["unsigned short int", ["unsigned short", 2]],
7631
- ["uint16", ["unsigned short", 2]],
7632
- ["uint16_t", ["unsigned short", 2]],
7633
- ["int", ["signed int", 4]],
7634
- ["signed int", ["signed int", 4]],
7635
- ["int32", ["signed int", 4]],
7636
- ["int32_t", ["signed int", 4]],
7637
- ["uint", ["unsigned int", 4]],
7638
- ["unsigned int", ["unsigned int", 4]],
7639
- ["uint32", ["unsigned int", 4]],
7640
- ["uint32_t", ["unsigned int", 4]],
7641
- ["float", ["float", 4]],
7642
- ["double", ["double", 8]],
7643
- ]);
7644
-
7645
- return function (value)
7646
- {
7647
- const type = types .get (value);
7648
-
7649
- if (type === undefined)
7650
- throw new Error ("Unsupported NRRD type '" + value + "'.");
7651
-
7652
- this .byteType = type [0];
7653
- this .bytes = type [1];
7654
- };
7655
- })(),
7656
- getEncoding: (() =>
7657
- {
7658
- const encodings = new Map ([
7659
- ["ascii", "ascii"],
7660
- ["txt", "ascii"],
7661
- ["text", "ascii"],
7662
- ["raw", "raw"],
7663
- ["hex", "hex"],
7664
- ["gz", "gzip"],
7665
- ["gzip", "gzip"],
7666
- ]);
7667
-
7668
- return function (value)
7669
- {
7670
- const encoding = encodings .get (value);
7671
-
7672
- if (encoding === undefined)
7673
- throw new Error ("Unsupported NRRD encoding '" + value + "'.");
7674
-
7675
- this .encoding = encoding;
7676
- };
7677
- })(),
7678
- getDimension (value)
7679
- {
7680
- const result = value .match (/(\d+)/);
7681
-
7682
- if (result)
7683
- {
7684
- const value = parseInt (result [1]);
7685
-
7686
- switch (value)
7687
- {
7688
- case 1:
7689
- case 2:
7690
- case 3:
7691
- case 4:
7692
- this .dimension = value;
7693
- return;
7694
- }
6930
+ scanNum += 1;
6931
+ while (true) {
6932
+ temp[0] = 0;
6933
+ index[0] = 0;
6934
+ for (i = 0; i < 10; i += 1) {
6935
+ pred[i] = 1 << this.precision - 1;
6936
+ }
6937
+ if (this.restartInterval === 0) {
6938
+ current = this.decodeUnit(pred, temp, index);
6939
+ while (current === 0 && this.xLoc < this.xDim && this.yLoc < this.yDim) {
6940
+ this.output(pred);
6941
+ current = this.decodeUnit(pred, temp, index);
6942
+ }
6943
+ break;
6944
+ }
6945
+ for (mcuNum = 0; mcuNum < this.restartInterval; mcuNum += 1) {
6946
+ this.restarting = mcuNum === 0;
6947
+ current = this.decodeUnit(pred, temp, index);
6948
+ this.output(pred);
6949
+ if (current !== 0) {
6950
+ break;
6951
+ }
6952
+ }
6953
+ if (current === 0) {
6954
+ if (this.markerIndex !== 0) {
6955
+ current = 65280 | this.marker;
6956
+ this.markerIndex = 0;
6957
+ } else {
6958
+ current = this.stream.get16();
6959
+ }
6960
+ }
6961
+ if (!(current >= _Decoder.RESTART_MARKER_BEGIN && current <= _Decoder.RESTART_MARKER_END)) {
6962
+ break;
6963
+ }
7695
6964
  }
7696
-
7697
- throw new Error (`Unsupported NRRD dimension '${result ?.[1]}', must be 1, 2, 3, or 4.`);
7698
- },
7699
- getSizes (value)
7700
- {
7701
- const
7702
- num = /\s*(\d+)/gy,
7703
- sizes = [ ];
7704
-
7705
- let result;
7706
-
7707
- while (result = num .exec (value))
7708
- {
7709
- sizes .push (parseInt (result [1]));
6965
+ if (current === 65500 && scanNum === 1) {
6966
+ this.readNumber();
6967
+ current = this.stream.get16();
7710
6968
  }
7711
-
7712
- switch (sizes .length)
7713
- {
7714
- case 1:
7715
- {
7716
- this .nrrd .components = 1;
7717
- this .nrrd .width = sizes [0];
7718
- this .nrrd .height = 1;
7719
- this .nrrd .depth = 1;
7720
- return;
7721
- }
7722
- case 2:
7723
- {
7724
- this .nrrd .components = 1;
7725
- this .nrrd .width = sizes [0];
7726
- this .nrrd .height = sizes [1];
7727
- this .nrrd .depth = 1;
7728
- return;
7729
- }
7730
- case 3:
7731
- {
7732
- this .nrrd .components = 1;
7733
- this .nrrd .width = sizes [0];
7734
- this .nrrd .height = sizes [1];
7735
- this .nrrd .depth = sizes [2];
7736
- return;
7737
- }
7738
- case 4:
7739
- {
7740
- this .nrrd .components = sizes [0];
7741
- this .nrrd .width = sizes [1];
7742
- this .nrrd .height = sizes [2];
7743
- this .nrrd .depth = sizes [3];
7744
- return;
7745
- }
7746
- default:
7747
- throw new Error ("Unsupported NRRD sizes.");
6969
+ } while (current !== 65497 && this.xLoc < this.xDim && this.yLoc < this.yDim && scanNum === 0);
6970
+ return this.outputData;
6971
+ }
6972
+ decodeUnit(prev, temp, index) {
6973
+ if (this.numComp === 1) {
6974
+ return this.decodeSingle(prev, temp, index);
6975
+ } else if (this.numComp === 3) {
6976
+ return this.decodeRGB(prev, temp, index);
6977
+ } else {
6978
+ return -1;
6979
+ }
6980
+ }
6981
+ select1(compOffset) {
6982
+ return this.getPreviousX(compOffset);
6983
+ }
6984
+ select2(compOffset) {
6985
+ return this.getPreviousY(compOffset);
6986
+ }
6987
+ select3(compOffset) {
6988
+ return this.getPreviousXY(compOffset);
6989
+ }
6990
+ select4(compOffset) {
6991
+ return this.getPreviousX(compOffset) + this.getPreviousY(compOffset) - this.getPreviousXY(compOffset);
6992
+ }
6993
+ select5(compOffset) {
6994
+ return this.getPreviousX(compOffset) + (this.getPreviousY(compOffset) - this.getPreviousXY(compOffset) >> 1);
6995
+ }
6996
+ select6(compOffset) {
6997
+ return this.getPreviousY(compOffset) + (this.getPreviousX(compOffset) - this.getPreviousXY(compOffset) >> 1);
6998
+ }
6999
+ select7(compOffset) {
7000
+ return (this.getPreviousX(compOffset) + this.getPreviousY(compOffset)) / 2;
7001
+ }
7002
+ decodeRGB(prev, temp, index) {
7003
+ if (this.selector === null)
7004
+ throw new Error("decode hasn't run yet");
7005
+ let actab, dctab, qtab, ctrC, i, k, j;
7006
+ prev[0] = this.selector(0);
7007
+ prev[1] = this.selector(1);
7008
+ prev[2] = this.selector(2);
7009
+ for (ctrC = 0; ctrC < this.numComp; ctrC += 1) {
7010
+ qtab = this.qTab[ctrC];
7011
+ actab = this.acTab[ctrC];
7012
+ dctab = this.dcTab[ctrC];
7013
+ for (i = 0; i < this.nBlock[ctrC]; i += 1) {
7014
+ for (k = 0; k < this.IDCT_Source.length; k += 1) {
7015
+ this.IDCT_Source[k] = 0;
7016
+ }
7017
+ let value = this.getHuffmanValue(dctab, temp, index);
7018
+ if (value >= 65280) {
7019
+ return value;
7020
+ }
7021
+ prev[ctrC] = this.IDCT_Source[0] = prev[ctrC] + this.getn(index, value, temp, index);
7022
+ this.IDCT_Source[0] *= qtab[0];
7023
+ for (j = 1; j < 64; j += 1) {
7024
+ value = this.getHuffmanValue(actab, temp, index);
7025
+ if (value >= 65280) {
7026
+ return value;
7027
+ }
7028
+ j += value >> 4;
7029
+ if ((value & 15) === 0) {
7030
+ if (value >> 4 === 0) {
7031
+ break;
7032
+ }
7033
+ } else {
7034
+ this.IDCT_Source[_Decoder.IDCT_P[j]] = this.getn(index, value & 15, temp, index) * qtab[j];
7035
+ }
7036
+ }
7748
7037
  }
7749
- },
7750
- getEndian (value)
7751
- {
7752
- if (value === "little")
7753
- {
7754
- this .littleEndian = true;
7755
- return;
7038
+ }
7039
+ return 0;
7040
+ }
7041
+ decodeSingle(prev, temp, index) {
7042
+ if (this.selector === null)
7043
+ throw new Error("decode hasn't run yet");
7044
+ let value, i, n, nRestart;
7045
+ if (this.restarting) {
7046
+ this.restarting = false;
7047
+ prev[0] = 1 << this.frame.precision - 1;
7048
+ } else {
7049
+ prev[0] = this.selector();
7050
+ }
7051
+ for (i = 0; i < this.nBlock[0]; i += 1) {
7052
+ value = this.getHuffmanValue(this.dcTab[0], temp, index);
7053
+ if (value >= 65280) {
7054
+ return value;
7055
+ }
7056
+ n = this.getn(prev, value, temp, index);
7057
+ nRestart = n >> 8;
7058
+ if (nRestart >= _Decoder.RESTART_MARKER_BEGIN && nRestart <= _Decoder.RESTART_MARKER_END) {
7059
+ return nRestart;
7060
+ }
7061
+ prev[0] += n;
7062
+ }
7063
+ return 0;
7064
+ }
7065
+ // Huffman table for fast search: (HuffTab) 8-bit Look up table 2-layer search architecture, 1st-layer represent 256 node (8 bits) if codeword-length > 8
7066
+ // bits, then the entry of 1st-layer = (# of 2nd-layer table) | MSB and it is stored in the 2nd-layer Size of tables in each layer are 256.
7067
+ // HuffTab[*][*][0-256] is always the only 1st-layer table.
7068
+ //
7069
+ // An entry can be: (1) (# of 2nd-layer table) | MSB , for code length > 8 in 1st-layer (2) (Code length) << 8 | HuffVal
7070
+ //
7071
+ // HuffmanValue(table HuffTab[x][y] (ex) HuffmanValue(HuffTab[1][0],...)
7072
+ // ):
7073
+ // return: Huffman Value of table
7074
+ // 0xFF?? if it receives a MARKER
7075
+ // Parameter: table HuffTab[x][y] (ex) HuffmanValue(HuffTab[1][0],...)
7076
+ // temp temp storage for remainded bits
7077
+ // index index to bit of temp
7078
+ // in FILE pointer
7079
+ // Effect:
7080
+ // temp store new remainded bits
7081
+ // index change to new index
7082
+ // in change to new position
7083
+ // NOTE:
7084
+ // Initial by temp=0; index=0;
7085
+ // NOTE: (explain temp and index)
7086
+ // temp: is always in the form at calling time or returning time
7087
+ // | byte 4 | byte 3 | byte 2 | byte 1 |
7088
+ // | 0 | 0 | 00000000 | 00000??? | if not a MARKER
7089
+ // ^index=3 (from 0 to 15)
7090
+ // 321
7091
+ // NOTE (marker and marker_index):
7092
+ // If get a MARKER from 'in', marker=the low-byte of the MARKER
7093
+ // and marker_index=9
7094
+ // If marker_index=9 then index is always > 8, or HuffmanValue()
7095
+ // will not be called
7096
+ getHuffmanValue(table, temp, index) {
7097
+ let code, input;
7098
+ const mask = 65535;
7099
+ if (!this.stream)
7100
+ throw new Error("stream not initialized");
7101
+ if (index[0] < 8) {
7102
+ temp[0] <<= 8;
7103
+ input = this.stream.get8();
7104
+ if (input === 255) {
7105
+ this.marker = this.stream.get8();
7106
+ if (this.marker !== 0) {
7107
+ this.markerIndex = 9;
7108
+ }
7109
+ }
7110
+ temp[0] |= input;
7111
+ } else {
7112
+ index[0] -= 8;
7113
+ }
7114
+ code = table[temp[0] >> index[0]];
7115
+ if ((code & _Decoder.MSB) !== 0) {
7116
+ if (this.markerIndex !== 0) {
7117
+ this.markerIndex = 0;
7118
+ return 65280 | this.marker;
7119
+ }
7120
+ temp[0] &= mask >> 16 - index[0];
7121
+ temp[0] <<= 8;
7122
+ input = this.stream.get8();
7123
+ if (input === 255) {
7124
+ this.marker = this.stream.get8();
7125
+ if (this.marker !== 0) {
7126
+ this.markerIndex = 9;
7127
+ }
7128
+ }
7129
+ temp[0] |= input;
7130
+ code = table[(code & 255) * 256 + (temp[0] >> index[0])];
7131
+ index[0] += 8;
7132
+ }
7133
+ index[0] += 8 - (code >> 8);
7134
+ if (index[0] < 0) {
7135
+ throw new Error("index=" + index[0] + " temp=" + temp[0] + " code=" + code + " in HuffmanValue()");
7136
+ }
7137
+ if (index[0] < this.markerIndex) {
7138
+ this.markerIndex = 0;
7139
+ return 65280 | this.marker;
7140
+ }
7141
+ temp[0] &= mask >> 16 - index[0];
7142
+ return code & 255;
7143
+ }
7144
+ getn(PRED, n, temp, index) {
7145
+ let result, input;
7146
+ const one = 1;
7147
+ const n_one = -1;
7148
+ const mask = 65535;
7149
+ if (this.stream === null)
7150
+ throw new Error("stream not initialized");
7151
+ if (n === 0) {
7152
+ return 0;
7153
+ }
7154
+ if (n === 16) {
7155
+ if (PRED[0] >= 0) {
7156
+ return -32768;
7157
+ } else {
7158
+ return 32768;
7756
7159
  }
7757
-
7758
- if (value === "big")
7759
- {
7760
- this .littleEndian = false;
7761
- return;
7160
+ }
7161
+ index[0] -= n;
7162
+ if (index[0] >= 0) {
7163
+ if (index[0] < this.markerIndex && !this.isLastPixel()) {
7164
+ this.markerIndex = 0;
7165
+ return (65280 | this.marker) << 8;
7762
7166
  }
7763
-
7764
- throw new Error ("Unsupported NRRD endian, must be either 'little' or 'big'.");
7765
- },
7766
- getData ()
7767
- {
7768
- switch (this .encoding)
7769
- {
7770
- case "ascii":
7771
- {
7772
- this .ascii ();
7773
- break;
7774
- }
7775
- case "raw":
7776
- {
7777
- this .raw ();
7778
- break;
7779
- }
7780
- case "hex":
7781
- {
7782
- this .hex ();
7783
- break;
7784
- }
7785
- case "gzip":
7786
- {
7787
- this .gzip ();
7788
- break;
7789
- }
7167
+ result = temp[0] >> index[0];
7168
+ temp[0] &= mask >> 16 - index[0];
7169
+ } else {
7170
+ temp[0] <<= 8;
7171
+ input = this.stream.get8();
7172
+ if (input === 255) {
7173
+ this.marker = this.stream.get8();
7174
+ if (this.marker !== 0) {
7175
+ this.markerIndex = 9;
7176
+ }
7790
7177
  }
7791
- },
7792
- ascii ()
7793
- {
7794
- const
7795
- dataLength = this .nrrd .components * this .nrrd .width * this .nrrd .height * this .nrrd .depth,
7796
- data = new Uint8Array (dataLength);
7797
-
7798
- this .nrrd .data = data;
7799
-
7800
- if (!Grammar .data .parse (this))
7801
- return;
7802
-
7803
- const
7804
- numbers = this .result [1] .trim () .split (/\s+/),
7805
- numNumbers = numbers .length;
7806
-
7807
- switch (this .byteType)
7808
- {
7809
- case "signed char":
7810
- case "unsigned char":
7811
- {
7812
- for (let i = 0; i < numNumbers; ++ i)
7813
- data [i] = parseInt (numbers [i]);
7814
-
7815
- return;
7816
- }
7817
- case "signed short":
7818
- case "unsigned short":
7819
- {
7820
- for (let i = 0; i < numNumbers; ++ i)
7821
- data [i] = parseInt (numbers [i]) / 256;
7822
-
7823
- return;
7824
- }
7825
- case "signed int":
7826
- case "unsigned int":
7827
- {
7828
- for (let i = 0; i < numNumbers; ++ i)
7829
- data [i] = parseInt (numbers [i]) / 16777216;
7830
-
7831
- return;
7832
- }
7833
- case "float":
7834
- {
7835
- for (let i = 0; i < numNumbers; ++ i)
7836
- data [i] = parseFloat (numbers [i]) / 256;
7837
-
7838
- return;
7839
- }
7840
- case "double":
7841
- {
7842
- for (let i = 0; i < numNumbers; ++ i)
7843
- data [i] = parseFloat (numbers [i]) / 16777216;
7844
-
7845
- return;
7846
- }
7178
+ temp[0] |= input;
7179
+ index[0] += 8;
7180
+ if (index[0] < 0) {
7181
+ if (this.markerIndex !== 0) {
7182
+ this.markerIndex = 0;
7183
+ return (65280 | this.marker) << 8;
7184
+ }
7185
+ temp[0] <<= 8;
7186
+ input = this.stream.get8();
7187
+ if (input === 255) {
7188
+ this.marker = this.stream.get8();
7189
+ if (this.marker !== 0) {
7190
+ this.markerIndex = 9;
7191
+ }
7192
+ }
7193
+ temp[0] |= input;
7194
+ index[0] += 8;
7847
7195
  }
7848
- },
7849
- raw ()
7850
- {
7851
- const
7852
- dataView = this .dataView,
7853
- byteLength = dataView .byteLength,
7854
- dataLength = this .nrrd .components * this .nrrd .width * this .nrrd .height * this .nrrd .depth,
7855
- length = dataLength * this .bytes,
7856
- data = new Uint8Array (dataLength);
7857
-
7858
- this .nrrd .data = data;
7859
-
7860
- switch (this .byteType)
7861
- {
7862
- case "signed char":
7863
- case "unsigned char":
7864
- {
7865
- for (let i = byteLength - length, d = 0; i < byteLength; ++ i, ++ d)
7866
- data [d] = dataView .getUint8 (i);
7867
-
7868
- return;
7869
- }
7870
- case "signed short":
7871
- case "unsigned short":
7872
- {
7873
- for (let i = byteLength - length, d = 0; i < byteLength; i += 2, ++ d)
7874
- data [d] = dataView .getUint16 (i, this .littleEndian) / 256;
7875
-
7876
- return;
7877
- }
7878
- case "signed int":
7879
- case "unsigned int":
7880
- {
7881
- for (let i = byteLength - length, d = 0; i < byteLength; i += 4, ++ d)
7882
- data [d] = dataView .getUint32 (i, this .littleEndian) / 16777216;
7883
-
7884
- return;
7885
- }
7886
- case "float":
7887
- {
7888
- for (let i = byteLength - length, d = 0; i < byteLength; i += 4, ++ d)
7889
- data [d] = dataView .getFloat32 (i, this .littleEndian) / 256;
7890
-
7891
- return;
7892
- }
7893
- case "double":
7894
- {
7895
- for (let i = byteLength - length, d = 0; i < byteLength; i += 8, ++ d)
7896
- data [d] = dataView .getFloat64 (i, this .littleEndian) / 16777216;
7897
-
7898
- return;
7899
- }
7196
+ if (index[0] < 0) {
7197
+ throw new Error("index=" + index[0] + " in getn()");
7900
7198
  }
7901
- },
7902
- hex ()
7903
- {
7904
- if (Grammar .data .parse (this))
7905
- {
7906
- const match = this .result [1] .match (/([0-9a-fA-F]{2})/g);
7907
-
7908
- if (match)
7909
- {
7910
- const array = Uint8Array .from (match, value => parseInt (value, 16));
7911
-
7912
- this .dataView = new DataView (array .buffer);
7913
-
7914
- this .raw ();
7915
- return;
7916
- }
7199
+ if (index[0] < this.markerIndex) {
7200
+ this.markerIndex = 0;
7201
+ return (65280 | this.marker) << 8;
7917
7202
  }
7918
-
7919
- throw new Error ("Invalid NRRD data.");
7920
- },
7921
- gzip ()
7922
- {
7923
- try
7924
- {
7925
- if (!Grammar .newLine .parse (this))
7926
- throw new Error ("Invalid NRRD data.");
7927
-
7928
- const
7929
- input = this .dataView .buffer .slice (this .lastIndex),
7930
- arrayBuffer = jquery_default().ungzip (input);
7931
-
7932
- this .dataView = new DataView (arrayBuffer);
7933
-
7934
- this .raw ();
7203
+ result = temp[0] >> index[0];
7204
+ temp[0] &= mask >> 16 - index[0];
7205
+ }
7206
+ if (result < one << n - 1) {
7207
+ result += (n_one << n) + 1;
7208
+ }
7209
+ return result;
7210
+ }
7211
+ getPreviousX(compOffset = 0) {
7212
+ if (this.getter === null)
7213
+ throw new Error("decode hasn't run yet");
7214
+ if (this.xLoc > 0) {
7215
+ return this.getter(this.yLoc * this.xDim + this.xLoc - 1, compOffset);
7216
+ } else if (this.yLoc > 0) {
7217
+ return this.getPreviousY(compOffset);
7218
+ } else {
7219
+ return 1 << this.frame.precision - 1;
7220
+ }
7221
+ }
7222
+ getPreviousXY(compOffset = 0) {
7223
+ if (this.getter === null)
7224
+ throw new Error("decode hasn't run yet");
7225
+ if (this.xLoc > 0 && this.yLoc > 0) {
7226
+ return this.getter((this.yLoc - 1) * this.xDim + this.xLoc - 1, compOffset);
7227
+ } else {
7228
+ return this.getPreviousY(compOffset);
7229
+ }
7230
+ }
7231
+ getPreviousY(compOffset = 0) {
7232
+ if (this.getter === null)
7233
+ throw new Error("decode hasn't run yet");
7234
+ if (this.yLoc > 0) {
7235
+ return this.getter((this.yLoc - 1) * this.xDim + this.xLoc, compOffset);
7236
+ } else {
7237
+ return this.getPreviousX(compOffset);
7238
+ }
7239
+ }
7240
+ isLastPixel() {
7241
+ return this.xLoc === this.xDim - 1 && this.yLoc === this.yDim - 1;
7242
+ }
7243
+ outputSingle(PRED) {
7244
+ if (this.setter === null)
7245
+ throw new Error("decode hasn't run yet");
7246
+ if (this.xLoc < this.xDim && this.yLoc < this.yDim) {
7247
+ this.setter(this.yLoc * this.xDim + this.xLoc, this.mask & PRED[0]);
7248
+ this.xLoc += 1;
7249
+ if (this.xLoc >= this.xDim) {
7250
+ this.yLoc += 1;
7251
+ this.xLoc = 0;
7935
7252
  }
7936
- catch (error)
7937
- {
7938
- throw new Error (`Invalid NRRD data: ${error}.`);
7253
+ }
7254
+ }
7255
+ outputRGB(PRED) {
7256
+ if (this.setter === null)
7257
+ throw new Error("decode hasn't run yet");
7258
+ const offset = this.yLoc * this.xDim + this.xLoc;
7259
+ if (this.xLoc < this.xDim && this.yLoc < this.yDim) {
7260
+ this.setter(offset, PRED[0], 0);
7261
+ this.setter(offset, PRED[1], 1);
7262
+ this.setter(offset, PRED[2], 2);
7263
+ this.xLoc += 1;
7264
+ if (this.xLoc >= this.xDim) {
7265
+ this.yLoc += 1;
7266
+ this.xLoc = 0;
7939
7267
  }
7940
- },
7941
- });
7942
-
7943
- const NRRDParser_default_ = NRRDParser;
7944
- ;
7268
+ }
7269
+ }
7270
+ setValue8(index, val) {
7271
+ if (!this.outputData)
7272
+ throw new Error("output data not ready");
7273
+ if (littleEndian) {
7274
+ this.outputData[index] = val;
7275
+ } else {
7276
+ this.outputData[index] = (val & 255) << 8 | val >> 8 & 255;
7277
+ }
7278
+ }
7279
+ getValue8(index) {
7280
+ if (this.outputData === null)
7281
+ throw new Error("output data not ready");
7282
+ if (littleEndian) {
7283
+ return this.outputData[index];
7284
+ } else {
7285
+ const val = this.outputData[index];
7286
+ return (val & 255) << 8 | val >> 8 & 255;
7287
+ }
7288
+ }
7289
+ setValueRGB(index, val, compOffset = 0) {
7290
+ if (this.outputData === null)
7291
+ return;
7292
+ this.outputData[index * 3 + compOffset] = val;
7293
+ }
7294
+ getValueRGB(index, compOffset) {
7295
+ if (this.outputData === null)
7296
+ throw new Error("output data not ready");
7297
+ return this.outputData[index * 3 + compOffset];
7298
+ }
7299
+ readApp() {
7300
+ if (this.stream === null)
7301
+ return null;
7302
+ let count = 0;
7303
+ const length = this.stream.get16();
7304
+ count += 2;
7305
+ while (count < length) {
7306
+ this.stream.get8();
7307
+ count += 1;
7308
+ }
7309
+ return length;
7310
+ }
7311
+ readComment() {
7312
+ if (this.stream === null)
7313
+ return null;
7314
+ let sb = "";
7315
+ let count = 0;
7316
+ const length = this.stream.get16();
7317
+ count += 2;
7318
+ while (count < length) {
7319
+ sb += this.stream.get8();
7320
+ count += 1;
7321
+ }
7322
+ return sb;
7323
+ }
7324
+ readNumber() {
7325
+ if (this.stream === null)
7326
+ return null;
7327
+ const Ld = this.stream.get16();
7328
+ if (Ld !== 4) {
7329
+ throw new Error("ERROR: Define number format throw new IOException [Ld!=4]");
7330
+ }
7331
+ return this.stream.get16();
7332
+ }
7333
+ };
7945
7334
 
7946
- Namespace_default().add ("NRRDParser", "x_ite/Browser/Texturing3D/NRRDParser", NRRDParser_default_);
7947
- /* harmony default export */ const Texturing3D_NRRDParser = (NRRDParser_default_);
7335
+ //#
7948
7336
  ;// CONCATENATED MODULE: ./src/x_ite/Browser/Texturing3D/DICOMParser.js
7949
- /* provided dependency */ var dicomParser = __webpack_require__(706);
7950
- /* provided dependency */ var JpegImage = __webpack_require__(306);
7951
- /* provided dependency */ var jpeg = __webpack_require__(490);
7952
- /* provided dependency */ var CharLS = __webpack_require__(544);
7953
- /* provided dependency */ var OpenJPEG = __webpack_require__(154);
7337
+ /* provided dependency */ var dicomParser = __webpack_require__(44);
7338
+ /* provided dependency */ var JpegImage = __webpack_require__(80);
7339
+ /* provided dependency */ var CharLS = __webpack_require__(470);
7340
+ /* provided dependency */ var OpenJPEG = __webpack_require__(976);
7954
7341
  /*******************************************************************************
7955
7342
  *
7956
7343
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -7998,6 +7385,8 @@ Namespace_default().add ("NRRDParser", "x_ite/Browser/Texturing3D/NRRDParser", N
7998
7385
  *
7999
7386
  ******************************************************************************/
8000
7387
 
7388
+
7389
+
8001
7390
  function DicomParser ()
8002
7391
  {
8003
7392
  this .dicom = { dicom: false };
@@ -8646,7 +8035,7 @@ Object .assign (DicomParser .prototype,
8646
8035
  decodeJPEGLossless (pixelData)
8647
8036
  {
8648
8037
  const
8649
- decoder = new jpeg .lossless .Decoder (),
8038
+ decoder = new Decoder (),
8650
8039
  buffer = decoder .decompress (pixelData);
8651
8040
 
8652
8041
  return new Uint8Array (buffer);
@@ -9052,10 +8441,10 @@ const DICOMParser_default_ = DicomParser;
9052
8441
  Namespace_default().add ("DICOMParser", "x_ite/Browser/Texturing3D/DICOMParser", DICOMParser_default_);
9053
8442
  /* harmony default export */ const DICOMParser = (DICOMParser_default_);
9054
8443
  ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/InputOutput/FileLoader\")"
9055
- const FileLoader_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.4.4")] .require ("x_ite/InputOutput/FileLoader");
8444
+ const FileLoader_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.0")] .require ("x_ite/InputOutput/FileLoader");
9056
8445
  var FileLoader_default = /*#__PURE__*/__webpack_require__.n(FileLoader_namespaceObject);
9057
8446
  ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/DEVELOPMENT\")"
9058
- const DEVELOPMENT_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.4.4")] .require ("x_ite/DEVELOPMENT");
8447
+ const DEVELOPMENT_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.0")] .require ("x_ite/DEVELOPMENT");
9059
8448
  var DEVELOPMENT_default = /*#__PURE__*/__webpack_require__.n(DEVELOPMENT_namespaceObject);
9060
8449
  ;// CONCATENATED MODULE: ./src/x_ite/Components/Texturing3D/ImageTexture3D.js
9061
8450
  /*******************************************************************************
@@ -9756,10 +9145,10 @@ const PixelTexture3D_default_ = PixelTexture3D;
9756
9145
  Namespace_default().add ("PixelTexture3D", "x_ite/Components/Texturing3D/PixelTexture3D", PixelTexture3D_default_);
9757
9146
  /* harmony default export */ const Texturing3D_PixelTexture3D = (PixelTexture3D_default_);
9758
9147
  ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Components/Texturing/X3DSingleTextureCoordinateNode\")"
9759
- const X3DSingleTextureCoordinateNode_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.4.4")] .require ("x_ite/Components/Texturing/X3DSingleTextureCoordinateNode");
9148
+ const X3DSingleTextureCoordinateNode_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.0")] .require ("x_ite/Components/Texturing/X3DSingleTextureCoordinateNode");
9760
9149
  var X3DSingleTextureCoordinateNode_default = /*#__PURE__*/__webpack_require__.n(X3DSingleTextureCoordinateNode_namespaceObject);
9761
9150
  ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"standard/Math/Numbers/Vector4\")"
9762
- const Vector4_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.4.4")] .require ("standard/Math/Numbers/Vector4");
9151
+ const Vector4_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.0")] .require ("standard/Math/Numbers/Vector4");
9763
9152
  ;// CONCATENATED MODULE: ./src/x_ite/Components/Texturing3D/TextureCoordinate3D.js
9764
9153
  /*******************************************************************************
9765
9154
  *
@@ -10063,16 +9452,16 @@ const TextureCoordinate4D_default_ = TextureCoordinate4D;
10063
9452
  Namespace_default().add ("TextureCoordinate4D", "x_ite/Components/Texturing3D/TextureCoordinate4D", TextureCoordinate4D_default_);
10064
9453
  /* harmony default export */ const Texturing3D_TextureCoordinate4D = (TextureCoordinate4D_default_);
10065
9454
  ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Components/Texturing/X3DSingleTextureTransformNode\")"
10066
- const X3DSingleTextureTransformNode_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.4.4")] .require ("x_ite/Components/Texturing/X3DSingleTextureTransformNode");
9455
+ const X3DSingleTextureTransformNode_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.0")] .require ("x_ite/Components/Texturing/X3DSingleTextureTransformNode");
10067
9456
  var X3DSingleTextureTransformNode_default = /*#__PURE__*/__webpack_require__.n(X3DSingleTextureTransformNode_namespaceObject);
10068
9457
  ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"standard/Math/Numbers/Vector3\")"
10069
- const Vector3_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.4.4")] .require ("standard/Math/Numbers/Vector3");
9458
+ const Vector3_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.0")] .require ("standard/Math/Numbers/Vector3");
10070
9459
  var Vector3_default = /*#__PURE__*/__webpack_require__.n(Vector3_namespaceObject);
10071
9460
  ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"standard/Math/Numbers/Rotation4\")"
10072
- const Rotation4_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.4.4")] .require ("standard/Math/Numbers/Rotation4");
9461
+ const Rotation4_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.0")] .require ("standard/Math/Numbers/Rotation4");
10073
9462
  var Rotation4_default = /*#__PURE__*/__webpack_require__.n(Rotation4_namespaceObject);
10074
9463
  ;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"standard/Math/Numbers/Matrix4\")"
10075
- const Matrix4_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.4.4")] .require ("standard/Math/Numbers/Matrix4");
9464
+ const Matrix4_namespaceObject = window [Symbol .for ("X_ITE.X3D-9.5.0")] .require ("standard/Math/Numbers/Matrix4");
10076
9465
  var Matrix4_default = /*#__PURE__*/__webpack_require__.n(Matrix4_namespaceObject);
10077
9466
  ;// CONCATENATED MODULE: ./src/x_ite/Components/Texturing3D/TextureTransform3D.js
10078
9467
  /*******************************************************************************