@2112-lab/central-plant 0.1.4 → 0.1.6

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 (88) hide show
  1. package/dist/bundle/index.js +33146 -1
  2. package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +432 -1
  3. package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1448 -1
  4. package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1853 -1
  5. package/dist/cjs/node_modules/three/examples/jsm/exporters/GLTFExporter.js +3537 -1
  6. package/dist/cjs/node_modules/three/examples/jsm/exporters/OBJExporter.js +305 -1
  7. package/dist/cjs/node_modules/three/examples/jsm/exporters/PLYExporter.js +542 -1
  8. package/dist/cjs/node_modules/three/examples/jsm/exporters/STLExporter.js +218 -1
  9. package/dist/cjs/node_modules/three/examples/jsm/loaders/DRACOLoader.js +683 -1
  10. package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4811 -1
  11. package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +480 -1
  12. package/dist/cjs/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +309 -1
  13. package/dist/cjs/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +120 -1
  14. package/dist/cjs/src/analysis/analysis.js +560 -1
  15. package/dist/cjs/src/analysis/testing.js +958 -1
  16. package/dist/cjs/src/core/centralPlant.js +1149 -1
  17. package/dist/cjs/src/core/debugLogger.js +175 -1
  18. package/dist/cjs/src/core/mathUtils.js +574 -1
  19. package/dist/cjs/src/core/nameUtils.js +93 -1
  20. package/dist/cjs/src/data/export.js +716 -1
  21. package/dist/cjs/src/data/import.js +380 -1
  22. package/dist/cjs/src/data/numerics.js +522 -1
  23. package/dist/cjs/src/helpers/sceneHelper.js +572 -1
  24. package/dist/cjs/src/index.js +69 -1
  25. package/dist/cjs/src/managers/components/animationManager.js +123 -1
  26. package/dist/cjs/src/managers/components/componentManager.js +332 -1
  27. package/dist/cjs/src/managers/components/pathfindingManager.js +1441 -1
  28. package/dist/cjs/src/managers/controls/TransformControls.js +1063 -1
  29. package/dist/cjs/src/managers/controls/cameraControlsManager.js +79 -1
  30. package/dist/cjs/src/managers/controls/dragDropManager.js +1026 -1
  31. package/dist/cjs/src/managers/controls/keyboardControlsManager.js +395 -1
  32. package/dist/cjs/src/managers/controls/transformControlsManager.js +1807 -1
  33. package/dist/cjs/src/managers/environment/environmentManager.js +714 -1
  34. package/dist/cjs/src/managers/environment/textureConfig.js +229 -1
  35. package/dist/cjs/src/managers/scene/sceneExportManager.js +264 -1
  36. package/dist/cjs/src/managers/scene/sceneInitializationManager.js +346 -1
  37. package/dist/cjs/src/managers/scene/sceneOperationsManager.js +1509 -1
  38. package/dist/cjs/src/managers/scene/sceneTooltipsManager.js +661 -1
  39. package/dist/cjs/src/managers/system/disposalManager.js +444 -1
  40. package/dist/cjs/src/managers/system/hotReloadManager.js +291 -1
  41. package/dist/cjs/src/managers/system/performanceMonitor.js +863 -1
  42. package/dist/cjs/src/rendering/modelPreloader.js +369 -1
  43. package/dist/cjs/src/rendering/rendering2D.js +631 -1
  44. package/dist/cjs/src/rendering/rendering3D.js +685 -1
  45. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +396 -1
  46. package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1444 -1
  47. package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1849 -1
  48. package/dist/esm/node_modules/three/examples/jsm/exporters/GLTFExporter.js +3533 -1
  49. package/dist/esm/node_modules/three/examples/jsm/exporters/OBJExporter.js +301 -1
  50. package/dist/esm/node_modules/three/examples/jsm/exporters/PLYExporter.js +538 -1
  51. package/dist/esm/node_modules/three/examples/jsm/exporters/STLExporter.js +214 -1
  52. package/dist/esm/node_modules/three/examples/jsm/loaders/DRACOLoader.js +679 -1
  53. package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4807 -1
  54. package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +476 -1
  55. package/dist/esm/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +304 -1
  56. package/dist/esm/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +116 -1
  57. package/dist/esm/src/analysis/analysis.js +536 -1
  58. package/dist/esm/src/analysis/testing.js +954 -1
  59. package/dist/esm/src/core/centralPlant.js +1144 -1
  60. package/dist/esm/src/core/debugLogger.js +167 -1
  61. package/dist/esm/src/core/mathUtils.js +570 -1
  62. package/dist/esm/src/core/nameUtils.js +87 -1
  63. package/dist/esm/src/data/export.js +712 -1
  64. package/dist/esm/src/data/import.js +356 -1
  65. package/dist/esm/src/data/numerics.js +518 -1
  66. package/dist/esm/src/helpers/sceneHelper.js +547 -1
  67. package/dist/esm/src/index.js +35 -1
  68. package/dist/esm/src/managers/components/animationManager.js +119 -1
  69. package/dist/esm/src/managers/components/componentManager.js +328 -1
  70. package/dist/esm/src/managers/components/pathfindingManager.js +1417 -1
  71. package/dist/esm/src/managers/controls/TransformControls.js +1057 -1
  72. package/dist/esm/src/managers/controls/cameraControlsManager.js +75 -1
  73. package/dist/esm/src/managers/controls/dragDropManager.js +1002 -1
  74. package/dist/esm/src/managers/controls/keyboardControlsManager.js +371 -1
  75. package/dist/esm/src/managers/controls/transformControlsManager.js +1782 -1
  76. package/dist/esm/src/managers/environment/environmentManager.js +690 -1
  77. package/dist/esm/src/managers/environment/textureConfig.js +202 -1
  78. package/dist/esm/src/managers/scene/sceneExportManager.js +260 -1
  79. package/dist/esm/src/managers/scene/sceneInitializationManager.js +322 -1
  80. package/dist/esm/src/managers/scene/sceneOperationsManager.js +1485 -1
  81. package/dist/esm/src/managers/scene/sceneTooltipsManager.js +637 -1
  82. package/dist/esm/src/managers/system/disposalManager.js +440 -1
  83. package/dist/esm/src/managers/system/hotReloadManager.js +287 -1
  84. package/dist/esm/src/managers/system/performanceMonitor.js +858 -1
  85. package/dist/esm/src/rendering/modelPreloader.js +364 -1
  86. package/dist/esm/src/rendering/rendering2D.js +627 -1
  87. package/dist/esm/src/rendering/rendering3D.js +661 -1
  88. package/package.json +1 -1
@@ -1 +1,476 @@
1
- import{DataTextureLoader as r,HalfFloatType as t,FloatType as e,DataUtils as n,LinearSRGBColorSpace as a,LinearFilter as s}from"three";class o extends r{constructor(r){super(r),this.type=t}parse(r){const a=function(r,t){switch(r){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(t||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(t||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(t||""));default:throw new Error("THREE.RGBELoader: Memory Error: "+(t||""))}},s=function(r,t,e){t=t||1024;let n=r.pos,a=-1,s=0,o="",i=String.fromCharCode.apply(null,new Uint16Array(r.subarray(n,n+128)));for(;0>(a=i.indexOf("\n"))&&s<t&&n<r.byteLength;)o+=i,s+=i.length,n+=128,i+=String.fromCharCode.apply(null,new Uint16Array(r.subarray(n,n+128)));return-1<a&&(!1!==e&&(r.pos+=s+a+1),o+i.slice(0,a))},o=function(r,t,e,n){const a=r[t+3],s=Math.pow(2,a-128)/255;e[n+0]=r[t+0]*s,e[n+1]=r[t+1]*s,e[n+2]=r[t+2]*s,e[n+3]=1},i=function(r,t,e,a){const s=r[t+3],o=Math.pow(2,s-128)/255;e[a+0]=n.toHalfFloat(Math.min(r[t+0]*o,65504)),e[a+1]=n.toHalfFloat(Math.min(r[t+1]*o,65504)),e[a+2]=n.toHalfFloat(Math.min(r[t+2]*o,65504)),e[a+3]=n.toHalfFloat(1)},c=new Uint8Array(r);c.pos=0;const l=function(r){const t=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,e=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,n=/^\s*FORMAT=(\S+)\s*$/,o=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,i={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let c,l;for((r.pos>=r.byteLength||!(c=s(r)))&&a(1,"no header found"),(l=c.match(/^#\?(\S+)/))||a(3,"bad initial token"),i.valid|=1,i.programtype=l[1],i.string+=c+"\n";c=s(r),!1!==c;)if(i.string+=c+"\n","#"!==c.charAt(0)){if((l=c.match(t))&&(i.gamma=parseFloat(l[1])),(l=c.match(e))&&(i.exposure=parseFloat(l[1])),(l=c.match(n))&&(i.valid|=2,i.format=l[1]),(l=c.match(o))&&(i.valid|=4,i.height=parseInt(l[1],10),i.width=parseInt(l[2],10)),2&i.valid&&4&i.valid)break}else i.comments+=c+"\n";return 2&i.valid||a(3,"missing format specifier"),4&i.valid||a(3,"missing image size specifier"),i}(c),d=l.width,f=l.height,h=function(r,t,e){const n=t;if(n<8||n>32767||2!==r[0]||2!==r[1]||128&r[2])return new Uint8Array(r);n!==(r[2]<<8|r[3])&&a(3,"wrong scanline width");const s=new Uint8Array(4*t*e);s.length||a(4,"unable to allocate buffer space");let o=0,i=0;const c=4*n,l=new Uint8Array(4),d=new Uint8Array(c);let f=e;for(;f>0&&i<r.byteLength;){i+4>r.byteLength&&a(1),l[0]=r[i++],l[1]=r[i++],l[2]=r[i++],l[3]=r[i++],2==l[0]&&2==l[1]&&(l[2]<<8|l[3])==n||a(3,"bad rgbe scanline format");let t,e=0;for(;e<c&&i<r.byteLength;){t=r[i++];const n=t>128;if(n&&(t-=128),(0===t||e+t>c)&&a(3,"bad scanline data"),n){const n=r[i++];for(let r=0;r<t;r++)d[e++]=n}else d.set(r.subarray(i,i+t),e),e+=t,i+=t}const h=n;for(let r=0;r<h;r++){let t=0;s[o]=d[r+t],t+=n,s[o+1]=d[r+t],t+=n,s[o+2]=d[r+t],t+=n,s[o+3]=d[r+t],o+=4}f--}return s}(c.subarray(c.pos),d,f);let u,w,E;switch(this.type){case e:E=h.length/4;const r=new Float32Array(4*E);for(let t=0;t<E;t++)o(h,4*t,r,4*t);u=r,w=e;break;case t:E=h.length/4;const n=new Uint16Array(4*E);for(let r=0;r<E;r++)i(h,4*r,n,4*r);u=n,w=t;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:d,height:f,data:u,header:l.string,gamma:l.gamma,exposure:l.exposure,type:w}}setDataType(r){return this.type=r,this}load(r,n,o,i){return super.load(r,function(r,o){switch(r.type){case e:case t:r.colorSpace=a,r.minFilter=s,r.magFilter=s,r.generateMipmaps=!1,r.flipY=!0}n&&n(r,o)},o,i)}}export{o as RGBELoader};
1
+ import { DataTextureLoader, HalfFloatType, FloatType, DataUtils, LinearSRGBColorSpace, LinearFilter } from 'three';
2
+
3
+ /**
4
+ * A loader for the RGBE HDR texture format.
5
+ *
6
+ * ```js
7
+ * const loader = new RGBELoader();
8
+ * const envMap = await loader.loadAsync( 'textures/equirectangular/blouberg_sunrise_2_1k.hdr' );
9
+ * envMap.mapping = THREE.EquirectangularReflectionMapping;
10
+ *
11
+ * scene.environment = envMap;
12
+ * ```
13
+ *
14
+ * @augments DataTextureLoader
15
+ * @three_import import { RGBELoader } from 'three/addons/loaders/RGBELoader.js';
16
+ */
17
+ class RGBELoader extends DataTextureLoader {
18
+
19
+ /**
20
+ * Constructs a new RGBE loader.
21
+ *
22
+ * @param {LoadingManager} [manager] - The loading manager.
23
+ */
24
+ constructor( manager ) {
25
+
26
+ super( manager );
27
+
28
+ /**
29
+ * The texture type.
30
+ *
31
+ * @type {(HalfFloatType|FloatType)}
32
+ * @default HalfFloatType
33
+ */
34
+ this.type = HalfFloatType;
35
+
36
+ }
37
+
38
+ /**
39
+ * Parses the given RGBE texture data.
40
+ *
41
+ * @param {ArrayBuffer} buffer - The raw texture data.
42
+ * @return {DataTextureLoader~TexData} An object representing the parsed texture data.
43
+ */
44
+ parse( buffer ) {
45
+
46
+ // adapted from http://www.graphics.cornell.edu/~bjw/rgbe.html
47
+
48
+ const
49
+ /* default error routine. change this to change error handling */
50
+ rgbe_read_error = 1,
51
+ rgbe_write_error = 2,
52
+ rgbe_format_error = 3,
53
+ rgbe_memory_error = 4,
54
+ rgbe_error = function ( rgbe_error_code, msg ) {
55
+
56
+ switch ( rgbe_error_code ) {
57
+
58
+ case rgbe_read_error: throw new Error( 'THREE.RGBELoader: Read Error: ' + ( msg || '' ) );
59
+ case rgbe_write_error: throw new Error( 'THREE.RGBELoader: Write Error: ' + ( msg || '' ) );
60
+ case rgbe_format_error: throw new Error( 'THREE.RGBELoader: Bad File Format: ' + ( msg || '' ) );
61
+ default:
62
+ case rgbe_memory_error: throw new Error( 'THREE.RGBELoader: Memory Error: ' + ( msg || '' ) );
63
+
64
+ }
65
+
66
+ },
67
+
68
+ /* offsets to red, green, and blue components in a data (float) pixel */
69
+ //RGBE_DATA_RED = 0,
70
+ //RGBE_DATA_GREEN = 1,
71
+ //RGBE_DATA_BLUE = 2,
72
+
73
+ /* number of floats per pixel, use 4 since stored in rgba image format */
74
+ //RGBE_DATA_SIZE = 4,
75
+
76
+ /* flags indicating which fields in an rgbe_header_info are valid */
77
+ RGBE_VALID_PROGRAMTYPE = 1,
78
+ RGBE_VALID_FORMAT = 2,
79
+ RGBE_VALID_DIMENSIONS = 4,
80
+
81
+ NEWLINE = '\n',
82
+
83
+ fgets = function ( buffer, lineLimit, consume ) {
84
+
85
+ const chunkSize = 128;
86
+
87
+ lineLimit = ! lineLimit ? 1024 : lineLimit;
88
+ let p = buffer.pos,
89
+ i = - 1, len = 0, s = '',
90
+ chunk = String.fromCharCode.apply( null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) );
91
+
92
+ while ( ( 0 > ( i = chunk.indexOf( NEWLINE ) ) ) && ( len < lineLimit ) && ( p < buffer.byteLength ) ) {
93
+
94
+ s += chunk; len += chunk.length;
95
+ p += chunkSize;
96
+ chunk += String.fromCharCode.apply( null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) );
97
+
98
+ }
99
+
100
+ if ( - 1 < i ) {
101
+
102
+ /*for (i=l-1; i>=0; i--) {
103
+ byteCode = m.charCodeAt(i);
104
+ if (byteCode > 0x7f && byteCode <= 0x7ff) byteLen++;
105
+ else if (byteCode > 0x7ff && byteCode <= 0xffff) byteLen += 2;
106
+ if (byteCode >= 0xDC00 && byteCode <= 0xDFFF) i--; //trail surrogate
107
+ }*/
108
+ if ( false !== consume ) buffer.pos += len + i + 1;
109
+ return s + chunk.slice( 0, i );
110
+
111
+ }
112
+
113
+ return false;
114
+
115
+ },
116
+
117
+ /* minimal header reading. modify if you want to parse more information */
118
+ RGBE_ReadHeader = function ( buffer ) {
119
+
120
+
121
+ // regexes to parse header info fields
122
+ const magic_token_re = /^#\?(\S+)/,
123
+ gamma_re = /^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,
124
+ exposure_re = /^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,
125
+ format_re = /^\s*FORMAT=(\S+)\s*$/,
126
+ dimensions_re = /^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,
127
+
128
+ // RGBE format header struct
129
+ header = {
130
+
131
+ valid: 0, /* indicate which fields are valid */
132
+
133
+ string: '', /* the actual header string */
134
+
135
+ comments: '', /* comments found in header */
136
+
137
+ programtype: 'RGBE', /* listed at beginning of file to identify it after "#?". defaults to "RGBE" */
138
+
139
+ format: '', /* RGBE format, default 32-bit_rle_rgbe */
140
+
141
+ gamma: 1.0, /* image has already been gamma corrected with given gamma. defaults to 1.0 (no correction) */
142
+
143
+ exposure: 1.0, /* a value of 1.0 in an image corresponds to <exposure> watts/steradian/m^2. defaults to 1.0 */
144
+
145
+ width: 0, height: 0 /* image dimensions, width/height */
146
+
147
+ };
148
+
149
+ let line, match;
150
+
151
+ if ( buffer.pos >= buffer.byteLength || ! ( line = fgets( buffer ) ) ) {
152
+
153
+ rgbe_error( rgbe_read_error, 'no header found' );
154
+
155
+ }
156
+
157
+ /* if you want to require the magic token then uncomment the next line */
158
+ if ( ! ( match = line.match( magic_token_re ) ) ) {
159
+
160
+ rgbe_error( rgbe_format_error, 'bad initial token' );
161
+
162
+ }
163
+
164
+ header.valid |= RGBE_VALID_PROGRAMTYPE;
165
+ header.programtype = match[ 1 ];
166
+ header.string += line + '\n';
167
+
168
+ while ( true ) {
169
+
170
+ line = fgets( buffer );
171
+ if ( false === line ) break;
172
+ header.string += line + '\n';
173
+
174
+ if ( '#' === line.charAt( 0 ) ) {
175
+
176
+ header.comments += line + '\n';
177
+ continue; // comment line
178
+
179
+ }
180
+
181
+ if ( match = line.match( gamma_re ) ) {
182
+
183
+ header.gamma = parseFloat( match[ 1 ] );
184
+
185
+ }
186
+
187
+ if ( match = line.match( exposure_re ) ) {
188
+
189
+ header.exposure = parseFloat( match[ 1 ] );
190
+
191
+ }
192
+
193
+ if ( match = line.match( format_re ) ) {
194
+
195
+ header.valid |= RGBE_VALID_FORMAT;
196
+ header.format = match[ 1 ];//'32-bit_rle_rgbe';
197
+
198
+ }
199
+
200
+ if ( match = line.match( dimensions_re ) ) {
201
+
202
+ header.valid |= RGBE_VALID_DIMENSIONS;
203
+ header.height = parseInt( match[ 1 ], 10 );
204
+ header.width = parseInt( match[ 2 ], 10 );
205
+
206
+ }
207
+
208
+ if ( ( header.valid & RGBE_VALID_FORMAT ) && ( header.valid & RGBE_VALID_DIMENSIONS ) ) break;
209
+
210
+ }
211
+
212
+ if ( ! ( header.valid & RGBE_VALID_FORMAT ) ) {
213
+
214
+ rgbe_error( rgbe_format_error, 'missing format specifier' );
215
+
216
+ }
217
+
218
+ if ( ! ( header.valid & RGBE_VALID_DIMENSIONS ) ) {
219
+
220
+ rgbe_error( rgbe_format_error, 'missing image size specifier' );
221
+
222
+ }
223
+
224
+ return header;
225
+
226
+ },
227
+
228
+ RGBE_ReadPixels_RLE = function ( buffer, w, h ) {
229
+
230
+ const scanline_width = w;
231
+
232
+ if (
233
+ // run length encoding is not allowed so read flat
234
+ ( ( scanline_width < 8 ) || ( scanline_width > 0x7fff ) ) ||
235
+ // this file is not run length encoded
236
+ ( ( 2 !== buffer[ 0 ] ) || ( 2 !== buffer[ 1 ] ) || ( buffer[ 2 ] & 0x80 ) )
237
+ ) {
238
+
239
+ // return the flat buffer
240
+ return new Uint8Array( buffer );
241
+
242
+ }
243
+
244
+ if ( scanline_width !== ( ( buffer[ 2 ] << 8 ) | buffer[ 3 ] ) ) {
245
+
246
+ rgbe_error( rgbe_format_error, 'wrong scanline width' );
247
+
248
+ }
249
+
250
+ const data_rgba = new Uint8Array( 4 * w * h );
251
+
252
+ if ( ! data_rgba.length ) {
253
+
254
+ rgbe_error( rgbe_memory_error, 'unable to allocate buffer space' );
255
+
256
+ }
257
+
258
+ let offset = 0, pos = 0;
259
+
260
+ const ptr_end = 4 * scanline_width;
261
+ const rgbeStart = new Uint8Array( 4 );
262
+ const scanline_buffer = new Uint8Array( ptr_end );
263
+ let num_scanlines = h;
264
+
265
+ // read in each successive scanline
266
+ while ( ( num_scanlines > 0 ) && ( pos < buffer.byteLength ) ) {
267
+
268
+ if ( pos + 4 > buffer.byteLength ) {
269
+
270
+ rgbe_error( rgbe_read_error );
271
+
272
+ }
273
+
274
+ rgbeStart[ 0 ] = buffer[ pos ++ ];
275
+ rgbeStart[ 1 ] = buffer[ pos ++ ];
276
+ rgbeStart[ 2 ] = buffer[ pos ++ ];
277
+ rgbeStart[ 3 ] = buffer[ pos ++ ];
278
+
279
+ if ( ( 2 != rgbeStart[ 0 ] ) || ( 2 != rgbeStart[ 1 ] ) || ( ( ( rgbeStart[ 2 ] << 8 ) | rgbeStart[ 3 ] ) != scanline_width ) ) {
280
+
281
+ rgbe_error( rgbe_format_error, 'bad rgbe scanline format' );
282
+
283
+ }
284
+
285
+ // read each of the four channels for the scanline into the buffer
286
+ // first red, then green, then blue, then exponent
287
+ let ptr = 0, count;
288
+
289
+ while ( ( ptr < ptr_end ) && ( pos < buffer.byteLength ) ) {
290
+
291
+ count = buffer[ pos ++ ];
292
+ const isEncodedRun = count > 128;
293
+ if ( isEncodedRun ) count -= 128;
294
+
295
+ if ( ( 0 === count ) || ( ptr + count > ptr_end ) ) {
296
+
297
+ rgbe_error( rgbe_format_error, 'bad scanline data' );
298
+
299
+ }
300
+
301
+ if ( isEncodedRun ) {
302
+
303
+ // a (encoded) run of the same value
304
+ const byteValue = buffer[ pos ++ ];
305
+ for ( let i = 0; i < count; i ++ ) {
306
+
307
+ scanline_buffer[ ptr ++ ] = byteValue;
308
+
309
+ }
310
+ //ptr += count;
311
+
312
+ } else {
313
+
314
+ // a literal-run
315
+ scanline_buffer.set( buffer.subarray( pos, pos + count ), ptr );
316
+ ptr += count; pos += count;
317
+
318
+ }
319
+
320
+ }
321
+
322
+
323
+ // now convert data from buffer into rgba
324
+ // first red, then green, then blue, then exponent (alpha)
325
+ const l = scanline_width; //scanline_buffer.byteLength;
326
+ for ( let i = 0; i < l; i ++ ) {
327
+
328
+ let off = 0;
329
+ data_rgba[ offset ] = scanline_buffer[ i + off ];
330
+ off += scanline_width; //1;
331
+ data_rgba[ offset + 1 ] = scanline_buffer[ i + off ];
332
+ off += scanline_width; //1;
333
+ data_rgba[ offset + 2 ] = scanline_buffer[ i + off ];
334
+ off += scanline_width; //1;
335
+ data_rgba[ offset + 3 ] = scanline_buffer[ i + off ];
336
+ offset += 4;
337
+
338
+ }
339
+
340
+ num_scanlines --;
341
+
342
+ }
343
+
344
+ return data_rgba;
345
+
346
+ };
347
+
348
+ const RGBEByteToRGBFloat = function ( sourceArray, sourceOffset, destArray, destOffset ) {
349
+
350
+ const e = sourceArray[ sourceOffset + 3 ];
351
+ const scale = Math.pow( 2.0, e - 128.0 ) / 255.0;
352
+
353
+ destArray[ destOffset + 0 ] = sourceArray[ sourceOffset + 0 ] * scale;
354
+ destArray[ destOffset + 1 ] = sourceArray[ sourceOffset + 1 ] * scale;
355
+ destArray[ destOffset + 2 ] = sourceArray[ sourceOffset + 2 ] * scale;
356
+ destArray[ destOffset + 3 ] = 1;
357
+
358
+ };
359
+
360
+ const RGBEByteToRGBHalf = function ( sourceArray, sourceOffset, destArray, destOffset ) {
361
+
362
+ const e = sourceArray[ sourceOffset + 3 ];
363
+ const scale = Math.pow( 2.0, e - 128.0 ) / 255.0;
364
+
365
+ // clamping to 65504, the maximum representable value in float16
366
+ destArray[ destOffset + 0 ] = DataUtils.toHalfFloat( Math.min( sourceArray[ sourceOffset + 0 ] * scale, 65504 ) );
367
+ destArray[ destOffset + 1 ] = DataUtils.toHalfFloat( Math.min( sourceArray[ sourceOffset + 1 ] * scale, 65504 ) );
368
+ destArray[ destOffset + 2 ] = DataUtils.toHalfFloat( Math.min( sourceArray[ sourceOffset + 2 ] * scale, 65504 ) );
369
+ destArray[ destOffset + 3 ] = DataUtils.toHalfFloat( 1 );
370
+
371
+ };
372
+
373
+ const byteArray = new Uint8Array( buffer );
374
+ byteArray.pos = 0;
375
+ const rgbe_header_info = RGBE_ReadHeader( byteArray );
376
+
377
+ const w = rgbe_header_info.width,
378
+ h = rgbe_header_info.height,
379
+ image_rgba_data = RGBE_ReadPixels_RLE( byteArray.subarray( byteArray.pos ), w, h );
380
+
381
+
382
+ let data, type;
383
+ let numElements;
384
+
385
+ switch ( this.type ) {
386
+
387
+ case FloatType:
388
+
389
+ numElements = image_rgba_data.length / 4;
390
+ const floatArray = new Float32Array( numElements * 4 );
391
+
392
+ for ( let j = 0; j < numElements; j ++ ) {
393
+
394
+ RGBEByteToRGBFloat( image_rgba_data, j * 4, floatArray, j * 4 );
395
+
396
+ }
397
+
398
+ data = floatArray;
399
+ type = FloatType;
400
+ break;
401
+
402
+ case HalfFloatType:
403
+
404
+ numElements = image_rgba_data.length / 4;
405
+ const halfArray = new Uint16Array( numElements * 4 );
406
+
407
+ for ( let j = 0; j < numElements; j ++ ) {
408
+
409
+ RGBEByteToRGBHalf( image_rgba_data, j * 4, halfArray, j * 4 );
410
+
411
+ }
412
+
413
+ data = halfArray;
414
+ type = HalfFloatType;
415
+ break;
416
+
417
+ default:
418
+
419
+ throw new Error( 'THREE.RGBELoader: Unsupported type: ' + this.type );
420
+
421
+ }
422
+
423
+ return {
424
+ width: w, height: h,
425
+ data: data,
426
+ header: rgbe_header_info.string,
427
+ gamma: rgbe_header_info.gamma,
428
+ exposure: rgbe_header_info.exposure,
429
+ type: type
430
+ };
431
+
432
+ }
433
+
434
+ /**
435
+ * Sets the texture type.
436
+ *
437
+ * @param {(HalfFloatType|FloatType)} value - The texture type to set.
438
+ * @return {RGBELoader} A reference to this loader.
439
+ */
440
+ setDataType( value ) {
441
+
442
+ this.type = value;
443
+ return this;
444
+
445
+ }
446
+
447
+ load( url, onLoad, onProgress, onError ) {
448
+
449
+ function onLoadCallback( texture, texData ) {
450
+
451
+ switch ( texture.type ) {
452
+
453
+ case FloatType:
454
+ case HalfFloatType:
455
+
456
+ texture.colorSpace = LinearSRGBColorSpace;
457
+ texture.minFilter = LinearFilter;
458
+ texture.magFilter = LinearFilter;
459
+ texture.generateMipmaps = false;
460
+ texture.flipY = true;
461
+
462
+ break;
463
+
464
+ }
465
+
466
+ if ( onLoad ) onLoad( texture, texData );
467
+
468
+ }
469
+
470
+ return super.load( url, onLoadCallback, onProgress, onError );
471
+
472
+ }
473
+
474
+ }
475
+
476
+ export { RGBELoader };