@needle-tools/three 0.145.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 (1160) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +84 -0
  3. package/build/three.cjs +36042 -0
  4. package/build/three.js +36048 -0
  5. package/build/three.min.js +6 -0
  6. package/build/three.module.js +49769 -0
  7. package/examples/fonts/LICENSE +13 -0
  8. package/examples/fonts/README.md +11 -0
  9. package/examples/fonts/droid/NOTICE +190 -0
  10. package/examples/fonts/droid/README.txt +18 -0
  11. package/examples/fonts/droid/droid_sans_bold.typeface.json +1 -0
  12. package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +1 -0
  13. package/examples/fonts/droid/droid_sans_regular.typeface.json +1 -0
  14. package/examples/fonts/droid/droid_serif_bold.typeface.json +1 -0
  15. package/examples/fonts/droid/droid_serif_regular.typeface.json +1 -0
  16. package/examples/fonts/gentilis_bold.typeface.json +1 -0
  17. package/examples/fonts/gentilis_regular.typeface.json +1 -0
  18. package/examples/fonts/helvetiker_bold.typeface.json +1 -0
  19. package/examples/fonts/helvetiker_regular.typeface.json +1 -0
  20. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff +0 -0
  21. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff2 +0 -0
  22. package/examples/fonts/open-sans/open-sans.css +9 -0
  23. package/examples/fonts/optimer_bold.typeface.json +1 -0
  24. package/examples/fonts/optimer_regular.typeface.json +1 -0
  25. package/examples/fonts/tabler-icons/fonts/tabler-icons.eot +0 -0
  26. package/examples/fonts/tabler-icons/fonts/tabler-icons.svg +3966 -0
  27. package/examples/fonts/tabler-icons/fonts/tabler-icons.ttf +0 -0
  28. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff +0 -0
  29. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff2 +0 -0
  30. package/examples/fonts/tabler-icons/tabler-icons.min.css +4 -0
  31. package/examples/fonts/ttf/README.md +9 -0
  32. package/examples/fonts/ttf/kenpixel.ttf +0 -0
  33. package/examples/js/animation/AnimationClipCreator.js +97 -0
  34. package/examples/js/animation/CCDIKSolver.js +433 -0
  35. package/examples/js/animation/MMDAnimationHelper.js +1117 -0
  36. package/examples/js/animation/MMDPhysics.js +1238 -0
  37. package/examples/js/cameras/CinematicCamera.js +157 -0
  38. package/examples/js/controls/ArcballControls.js +3037 -0
  39. package/examples/js/controls/DragControls.js +230 -0
  40. package/examples/js/controls/FirstPersonControls.js +334 -0
  41. package/examples/js/controls/FlyControls.js +347 -0
  42. package/examples/js/controls/OrbitControls.js +1075 -0
  43. package/examples/js/controls/PointerLockControls.js +153 -0
  44. package/examples/js/controls/TrackballControls.js +782 -0
  45. package/examples/js/controls/TransformControls.js +1386 -0
  46. package/examples/js/csm/CSM.js +382 -0
  47. package/examples/js/csm/CSMFrustum.js +133 -0
  48. package/examples/js/csm/CSMHelper.js +145 -0
  49. package/examples/js/csm/CSMShader.js +257 -0
  50. package/examples/js/curves/CurveExtras.js +348 -0
  51. package/examples/js/curves/NURBSCurve.js +75 -0
  52. package/examples/js/curves/NURBSSurface.js +54 -0
  53. package/examples/js/curves/NURBSUtils.js +476 -0
  54. package/examples/js/effects/AnaglyphEffect.js +100 -0
  55. package/examples/js/effects/AsciiEffect.js +259 -0
  56. package/examples/js/effects/OutlineEffect.js +454 -0
  57. package/examples/js/effects/ParallaxBarrierEffect.js +75 -0
  58. package/examples/js/effects/PeppersGhostEffect.js +166 -0
  59. package/examples/js/effects/StereoEffect.js +50 -0
  60. package/examples/js/environments/DebugEnvironment.js +53 -0
  61. package/examples/js/environments/RoomEnvironment.js +122 -0
  62. package/examples/js/exporters/ColladaExporter.js +504 -0
  63. package/examples/js/exporters/DRACOExporter.js +212 -0
  64. package/examples/js/exporters/EXRExporter.js +458 -0
  65. package/examples/js/exporters/GLTFExporter.js +2543 -0
  66. package/examples/js/exporters/MMDExporter.js +194 -0
  67. package/examples/js/exporters/OBJExporter.js +251 -0
  68. package/examples/js/exporters/PLYExporter.js +422 -0
  69. package/examples/js/exporters/STLExporter.js +190 -0
  70. package/examples/js/exporters/USDZExporter.js +523 -0
  71. package/examples/js/geometries/BoxLineGeometry.js +60 -0
  72. package/examples/js/geometries/ConvexGeometry.js +48 -0
  73. package/examples/js/geometries/DecalGeometry.js +291 -0
  74. package/examples/js/geometries/LightningStrike.js +874 -0
  75. package/examples/js/geometries/ParametricGeometries.js +215 -0
  76. package/examples/js/geometries/ParametricGeometry.js +108 -0
  77. package/examples/js/geometries/RoundedBoxGeometry.js +140 -0
  78. package/examples/js/geometries/TeapotGeometry.js +331 -0
  79. package/examples/js/geometries/TextGeometry.js +51 -0
  80. package/examples/js/helpers/LightProbeHelper.js +49 -0
  81. package/examples/js/helpers/OctreeHelper.js +74 -0
  82. package/examples/js/helpers/PositionalAudioHelper.js +89 -0
  83. package/examples/js/helpers/RectAreaLightHelper.js +74 -0
  84. package/examples/js/helpers/VertexNormalsHelper.js +72 -0
  85. package/examples/js/helpers/VertexTangentsHelper.js +62 -0
  86. package/examples/js/helpers/ViewHelper.js +266 -0
  87. package/examples/js/interactive/HTMLMesh.js +508 -0
  88. package/examples/js/interactive/InteractiveGroup.js +101 -0
  89. package/examples/js/interactive/SelectionBox.js +262 -0
  90. package/examples/js/interactive/SelectionHelper.js +91 -0
  91. package/examples/js/libs/ammo.wasm.js +822 -0
  92. package/examples/js/libs/ammo.wasm.wasm +0 -0
  93. package/examples/js/libs/basis/README.md +46 -0
  94. package/examples/js/libs/basis/basis_transcoder.js +21 -0
  95. package/examples/js/libs/basis/basis_transcoder.wasm +0 -0
  96. package/examples/js/libs/chevrotain.min.js +3 -0
  97. package/examples/js/libs/draco/README.md +32 -0
  98. package/examples/js/libs/draco/draco_decoder.js +52 -0
  99. package/examples/js/libs/draco/draco_decoder.wasm +0 -0
  100. package/examples/js/libs/draco/draco_encoder.js +33 -0
  101. package/examples/js/libs/draco/draco_wasm_wrapper.js +104 -0
  102. package/examples/js/libs/draco/gltf/draco_decoder.js +48 -0
  103. package/examples/js/libs/draco/gltf/draco_decoder.wasm +0 -0
  104. package/examples/js/libs/draco/gltf/draco_encoder.js +33 -0
  105. package/examples/js/libs/draco/gltf/draco_wasm_wrapper.js +104 -0
  106. package/examples/js/libs/fflate.min.js +7 -0
  107. package/examples/js/libs/ktx-parse.umd.js +1 -0
  108. package/examples/js/libs/lottie_canvas.js +12751 -0
  109. package/examples/js/libs/meshopt_decoder.js +188 -0
  110. package/examples/js/libs/opentype.min.js +1 -0
  111. package/examples/js/libs/stats.min.js +5 -0
  112. package/examples/js/lights/LightProbeGenerator.js +228 -0
  113. package/examples/js/lights/RectAreaLightUniformsLib.js +56 -0
  114. package/examples/js/lines/Line2.js +19 -0
  115. package/examples/js/lines/LineGeometry.js +71 -0
  116. package/examples/js/lines/LineMaterial.js +642 -0
  117. package/examples/js/lines/LineSegments2.js +362 -0
  118. package/examples/js/lines/LineSegmentsGeometry.js +219 -0
  119. package/examples/js/lines/Wireframe.js +52 -0
  120. package/examples/js/lines/WireframeGeometry2.js +18 -0
  121. package/examples/js/loaders/3DMLoader.js +1370 -0
  122. package/examples/js/loaders/3MFLoader.js +1340 -0
  123. package/examples/js/loaders/AMFLoader.js +529 -0
  124. package/examples/js/loaders/BVHLoader.js +394 -0
  125. package/examples/js/loaders/BasisTextureLoader.js +736 -0
  126. package/examples/js/loaders/ColladaLoader.js +3821 -0
  127. package/examples/js/loaders/DDSLoader.js +245 -0
  128. package/examples/js/loaders/DRACOLoader.js +548 -0
  129. package/examples/js/loaders/EXRLoader.js +2136 -0
  130. package/examples/js/loaders/FBXLoader.js +3835 -0
  131. package/examples/js/loaders/FontLoader.js +169 -0
  132. package/examples/js/loaders/GCodeLoader.js +256 -0
  133. package/examples/js/loaders/GLTFLoader.js +4159 -0
  134. package/examples/js/loaders/HDRCubeTextureLoader.js +93 -0
  135. package/examples/js/loaders/KMZLoader.js +125 -0
  136. package/examples/js/loaders/KTXLoader.js +177 -0
  137. package/examples/js/loaders/LDrawLoader.js +2374 -0
  138. package/examples/js/loaders/LUT3dlLoader.js +139 -0
  139. package/examples/js/loaders/LUTCubeLoader.js +140 -0
  140. package/examples/js/loaders/LWOLoader.js +966 -0
  141. package/examples/js/loaders/LogLuvLoader.js +765 -0
  142. package/examples/js/loaders/LottieLoader.js +62 -0
  143. package/examples/js/loaders/MD2Loader.js +249 -0
  144. package/examples/js/loaders/MDDLoader.js +95 -0
  145. package/examples/js/loaders/MMDLoader.js +1924 -0
  146. package/examples/js/loaders/MTLLoader.js +501 -0
  147. package/examples/js/loaders/NRRDLoader.js +649 -0
  148. package/examples/js/loaders/OBJLoader.js +804 -0
  149. package/examples/js/loaders/PCDLoader.js +408 -0
  150. package/examples/js/loaders/PDBLoader.js +313 -0
  151. package/examples/js/loaders/PLYLoader.js +562 -0
  152. package/examples/js/loaders/PRWMLoader.js +260 -0
  153. package/examples/js/loaders/PVRLoader.js +227 -0
  154. package/examples/js/loaders/RGBELoader.js +467 -0
  155. package/examples/js/loaders/RGBMLoader.js +1415 -0
  156. package/examples/js/loaders/STLLoader.js +371 -0
  157. package/examples/js/loaders/SVGLoader.js +2655 -0
  158. package/examples/js/loaders/TDSLoader.js +1029 -0
  159. package/examples/js/loaders/TGALoader.js +486 -0
  160. package/examples/js/loaders/TIFFLoader.js +31 -0
  161. package/examples/js/loaders/TTFLoader.js +211 -0
  162. package/examples/js/loaders/TiltLoader.js +460 -0
  163. package/examples/js/loaders/VOXLoader.js +248 -0
  164. package/examples/js/loaders/VRMLLoader.js +3237 -0
  165. package/examples/js/loaders/VTKLoader.js +1095 -0
  166. package/examples/js/loaders/XYZLoader.js +91 -0
  167. package/examples/js/loaders/lwo/IFFParser.js +1148 -0
  168. package/examples/js/loaders/lwo/LWO2Parser.js +448 -0
  169. package/examples/js/loaders/lwo/LWO3Parser.js +402 -0
  170. package/examples/js/materials/MeshGouraudMaterial.js +385 -0
  171. package/examples/js/math/Capsule.js +120 -0
  172. package/examples/js/math/ColorConverter.js +33 -0
  173. package/examples/js/math/ConvexHull.js +1110 -0
  174. package/examples/js/math/ImprovedNoise.js +66 -0
  175. package/examples/js/math/Lut.js +171 -0
  176. package/examples/js/math/MeshSurfaceSampler.js +193 -0
  177. package/examples/js/math/OBB.js +341 -0
  178. package/examples/js/math/Octree.js +465 -0
  179. package/examples/js/math/SimplexNoise.js +459 -0
  180. package/examples/js/misc/ConvexObjectBreaker.js +485 -0
  181. package/examples/js/misc/GPUComputationRenderer.js +397 -0
  182. package/examples/js/misc/Gyroscope.js +60 -0
  183. package/examples/js/misc/MD2Character.js +244 -0
  184. package/examples/js/misc/MD2CharacterComplex.js +494 -0
  185. package/examples/js/misc/MorphAnimMesh.js +69 -0
  186. package/examples/js/misc/MorphBlendMesh.js +292 -0
  187. package/examples/js/misc/ProgressiveLightMap.js +331 -0
  188. package/examples/js/misc/RollerCoaster.js +437 -0
  189. package/examples/js/misc/TubePainter.js +161 -0
  190. package/examples/js/misc/Volume.js +466 -0
  191. package/examples/js/misc/VolumeSlice.js +224 -0
  192. package/examples/js/modifiers/CurveModifier.js +311 -0
  193. package/examples/js/modifiers/EdgeSplitModifier.js +258 -0
  194. package/examples/js/modifiers/SimplifyModifier.js +468 -0
  195. package/examples/js/modifiers/TessellateModifier.js +283 -0
  196. package/examples/js/objects/GroundProjectedEnv.js +193 -0
  197. package/examples/js/objects/Lensflare.js +347 -0
  198. package/examples/js/objects/LightningStorm.js +209 -0
  199. package/examples/js/objects/MarchingCubes.js +738 -0
  200. package/examples/js/objects/Reflector.js +214 -0
  201. package/examples/js/objects/ReflectorForSSRPass.js +319 -0
  202. package/examples/js/objects/Refractor.js +261 -0
  203. package/examples/js/objects/ShadowMesh.js +60 -0
  204. package/examples/js/objects/Sky.js +223 -0
  205. package/examples/js/objects/Water.js +287 -0
  206. package/examples/js/objects/Water2.js +306 -0
  207. package/examples/js/physics/AmmoPhysics.js +256 -0
  208. package/examples/js/physics/OimoPhysics.js +215 -0
  209. package/examples/js/postprocessing/AdaptiveToneMappingPass.js +342 -0
  210. package/examples/js/postprocessing/AfterimagePass.js +70 -0
  211. package/examples/js/postprocessing/BloomPass.js +114 -0
  212. package/examples/js/postprocessing/BokehPass.js +103 -0
  213. package/examples/js/postprocessing/ClearPass.js +44 -0
  214. package/examples/js/postprocessing/CubeTexturePass.js +57 -0
  215. package/examples/js/postprocessing/DotScreenPass.js +49 -0
  216. package/examples/js/postprocessing/EffectComposer.js +279 -0
  217. package/examples/js/postprocessing/FilmPass.js +50 -0
  218. package/examples/js/postprocessing/GlitchPass.js +105 -0
  219. package/examples/js/postprocessing/HalftonePass.js +75 -0
  220. package/examples/js/postprocessing/LUTPass.js +184 -0
  221. package/examples/js/postprocessing/MaskPass.js +92 -0
  222. package/examples/js/postprocessing/OutlinePass.js +589 -0
  223. package/examples/js/postprocessing/Pass.js +75 -0
  224. package/examples/js/postprocessing/RenderPass.js +74 -0
  225. package/examples/js/postprocessing/SAOPass.js +366 -0
  226. package/examples/js/postprocessing/SMAAPass.js +153 -0
  227. package/examples/js/postprocessing/SSAARenderPass.js +156 -0
  228. package/examples/js/postprocessing/SSAOPass.js +351 -0
  229. package/examples/js/postprocessing/SSRPass.js +550 -0
  230. package/examples/js/postprocessing/SavePass.js +51 -0
  231. package/examples/js/postprocessing/ShaderPass.js +63 -0
  232. package/examples/js/postprocessing/TAARenderPass.js +128 -0
  233. package/examples/js/postprocessing/TexturePass.js +46 -0
  234. package/examples/js/postprocessing/UnrealBloomPass.js +357 -0
  235. package/examples/js/renderers/CSS2DRenderer.js +197 -0
  236. package/examples/js/renderers/CSS3DRenderer.js +258 -0
  237. package/examples/js/renderers/Projector.js +874 -0
  238. package/examples/js/renderers/SVGRenderer.js +537 -0
  239. package/examples/js/shaders/ACESFilmicToneMappingShader.js +92 -0
  240. package/examples/js/shaders/AfterimageShader.js +63 -0
  241. package/examples/js/shaders/BasicShader.js +30 -0
  242. package/examples/js/shaders/BleachBypassShader.js +65 -0
  243. package/examples/js/shaders/BlendShader.js +57 -0
  244. package/examples/js/shaders/BokehShader.js +159 -0
  245. package/examples/js/shaders/BokehShader2.js +428 -0
  246. package/examples/js/shaders/BrightnessContrastShader.js +61 -0
  247. package/examples/js/shaders/ColorCorrectionShader.js +56 -0
  248. package/examples/js/shaders/ColorifyShader.js +51 -0
  249. package/examples/js/shaders/ConvolutionShader.js +97 -0
  250. package/examples/js/shaders/CopyShader.js +48 -0
  251. package/examples/js/shaders/DOFMipMapShader.js +63 -0
  252. package/examples/js/shaders/DepthLimitedBlurShader.js +180 -0
  253. package/examples/js/shaders/DigitalGlitch.js +130 -0
  254. package/examples/js/shaders/DotScreenShader.js +76 -0
  255. package/examples/js/shaders/FXAAShader.js +286 -0
  256. package/examples/js/shaders/FilmShader.js +113 -0
  257. package/examples/js/shaders/FocusShader.js +98 -0
  258. package/examples/js/shaders/FreiChenShader.js +97 -0
  259. package/examples/js/shaders/GammaCorrectionShader.js +44 -0
  260. package/examples/js/shaders/GodRaysShader.js +297 -0
  261. package/examples/js/shaders/HalftoneShader.js +339 -0
  262. package/examples/js/shaders/HorizontalBlurShader.js +62 -0
  263. package/examples/js/shaders/HorizontalTiltShiftShader.js +68 -0
  264. package/examples/js/shaders/HueSaturationShader.js +72 -0
  265. package/examples/js/shaders/KaleidoShader.js +63 -0
  266. package/examples/js/shaders/LuminosityHighPassShader.js +71 -0
  267. package/examples/js/shaders/LuminosityShader.js +49 -0
  268. package/examples/js/shaders/MMDToonShader.js +100 -0
  269. package/examples/js/shaders/MirrorShader.js +59 -0
  270. package/examples/js/shaders/NormalMapShader.js +59 -0
  271. package/examples/js/shaders/PixelShader.js +51 -0
  272. package/examples/js/shaders/RGBShiftShader.js +59 -0
  273. package/examples/js/shaders/SAOShader.js +213 -0
  274. package/examples/js/shaders/SMAAShader.js +466 -0
  275. package/examples/js/shaders/SSAOShader.js +299 -0
  276. package/examples/js/shaders/SSRShader.js +393 -0
  277. package/examples/js/shaders/SepiaShader.js +55 -0
  278. package/examples/js/shaders/SobelOperatorShader.js +92 -0
  279. package/examples/js/shaders/SubsurfaceScatteringShader.js +49 -0
  280. package/examples/js/shaders/TechnicolorShader.js +46 -0
  281. package/examples/js/shaders/ToneMapShader.js +87 -0
  282. package/examples/js/shaders/ToonShader.js +351 -0
  283. package/examples/js/shaders/TriangleBlurShader.js +74 -0
  284. package/examples/js/shaders/UnpackDepthRGBAShader.js +50 -0
  285. package/examples/js/shaders/VerticalBlurShader.js +62 -0
  286. package/examples/js/shaders/VerticalTiltShiftShader.js +68 -0
  287. package/examples/js/shaders/VignetteShader.js +56 -0
  288. package/examples/js/shaders/VolumeShader.js +300 -0
  289. package/examples/js/shaders/WaterRefractionShader.js +88 -0
  290. package/examples/js/textures/FlakesTexture.js +41 -0
  291. package/examples/js/utils/BufferGeometryUtils.js +1094 -0
  292. package/examples/js/utils/CameraUtils.js +86 -0
  293. package/examples/js/utils/GPUStatsPanel.js +134 -0
  294. package/examples/js/utils/GeometryCompressionUtils.js +574 -0
  295. package/examples/js/utils/GeometryUtils.js +173 -0
  296. package/examples/js/utils/LDrawUtils.js +182 -0
  297. package/examples/js/utils/PackedPhongMaterial.js +107 -0
  298. package/examples/js/utils/SceneUtils.js +103 -0
  299. package/examples/js/utils/ShadowMapViewer.js +180 -0
  300. package/examples/js/utils/SkeletonUtils.js +507 -0
  301. package/examples/js/utils/UVsDebug.js +135 -0
  302. package/examples/js/utils/WorkerPool.js +115 -0
  303. package/examples/jsm/animation/AnimationClipCreator.js +114 -0
  304. package/examples/jsm/animation/CCDIKSolver.js +482 -0
  305. package/examples/jsm/animation/MMDAnimationHelper.js +1207 -0
  306. package/examples/jsm/animation/MMDPhysics.js +1406 -0
  307. package/examples/jsm/cameras/CinematicCamera.js +209 -0
  308. package/examples/jsm/capabilities/WebGL.js +91 -0
  309. package/examples/jsm/capabilities/WebGPU.js +39 -0
  310. package/examples/jsm/controls/ArcballControls.js +3216 -0
  311. package/examples/jsm/controls/DragControls.js +220 -0
  312. package/examples/jsm/controls/FirstPersonControls.js +325 -0
  313. package/examples/jsm/controls/FlyControls.js +284 -0
  314. package/examples/jsm/controls/OrbitControls.js +1249 -0
  315. package/examples/jsm/controls/PointerLockControls.js +157 -0
  316. package/examples/jsm/controls/TrackballControls.js +814 -0
  317. package/examples/jsm/controls/TransformControls.js +1558 -0
  318. package/examples/jsm/csm/CSM.js +378 -0
  319. package/examples/jsm/csm/CSMFrustum.js +152 -0
  320. package/examples/jsm/csm/CSMHelper.js +193 -0
  321. package/examples/jsm/csm/CSMShader.js +251 -0
  322. package/examples/jsm/curves/CurveExtras.js +422 -0
  323. package/examples/jsm/curves/NURBSCurve.js +80 -0
  324. package/examples/jsm/curves/NURBSSurface.js +52 -0
  325. package/examples/jsm/curves/NURBSUtils.js +487 -0
  326. package/examples/jsm/effects/AnaglyphEffect.js +168 -0
  327. package/examples/jsm/effects/AsciiEffect.js +266 -0
  328. package/examples/jsm/effects/OutlineEffect.js +553 -0
  329. package/examples/jsm/effects/ParallaxBarrierEffect.js +116 -0
  330. package/examples/jsm/effects/PeppersGhostEffect.js +153 -0
  331. package/examples/jsm/effects/StereoEffect.js +55 -0
  332. package/examples/jsm/environments/DebugEnvironment.js +52 -0
  333. package/examples/jsm/environments/RoomEnvironment.js +144 -0
  334. package/examples/jsm/exporters/ColladaExporter.js +713 -0
  335. package/examples/jsm/exporters/DRACOExporter.js +225 -0
  336. package/examples/jsm/exporters/EXRExporter.js +507 -0
  337. package/examples/jsm/exporters/GLTFExporter.js +2870 -0
  338. package/examples/jsm/exporters/KTX2Exporter.js +281 -0
  339. package/examples/jsm/exporters/MMDExporter.js +217 -0
  340. package/examples/jsm/exporters/OBJExporter.js +284 -0
  341. package/examples/jsm/exporters/PLYExporter.js +521 -0
  342. package/examples/jsm/exporters/STLExporter.js +195 -0
  343. package/examples/jsm/exporters/USDZExporter.js +1112 -0
  344. package/examples/jsm/geometries/BoxLineGeometry.js +69 -0
  345. package/examples/jsm/geometries/ConvexGeometry.js +59 -0
  346. package/examples/jsm/geometries/DecalGeometry.js +356 -0
  347. package/examples/jsm/geometries/LightningStrike.js +1017 -0
  348. package/examples/jsm/geometries/ParametricGeometries.js +254 -0
  349. package/examples/jsm/geometries/ParametricGeometry.js +129 -0
  350. package/examples/jsm/geometries/RoundedBoxGeometry.js +155 -0
  351. package/examples/jsm/geometries/TeapotGeometry.js +704 -0
  352. package/examples/jsm/geometries/TextGeometry.js +57 -0
  353. package/examples/jsm/helpers/LightProbeHelper.js +130 -0
  354. package/examples/jsm/helpers/OctreeHelper.js +72 -0
  355. package/examples/jsm/helpers/PositionalAudioHelper.js +109 -0
  356. package/examples/jsm/helpers/RectAreaLightHelper.js +85 -0
  357. package/examples/jsm/helpers/VertexNormalsHelper.js +96 -0
  358. package/examples/jsm/helpers/VertexTangentsHelper.js +88 -0
  359. package/examples/jsm/helpers/ViewHelper.js +319 -0
  360. package/examples/jsm/interactive/HTMLMesh.js +550 -0
  361. package/examples/jsm/interactive/InteractiveGroup.js +116 -0
  362. package/examples/jsm/interactive/SelectionBox.js +227 -0
  363. package/examples/jsm/interactive/SelectionHelper.js +97 -0
  364. package/examples/jsm/libs/OimoPhysics/OimoPhysics.js +37071 -0
  365. package/examples/jsm/libs/OimoPhysics/index.js +43 -0
  366. package/examples/jsm/libs/chevrotain.module.min.js +141 -0
  367. package/examples/jsm/libs/ecsy.module.js +1792 -0
  368. package/examples/jsm/libs/fflate.module.js +2474 -0
  369. package/examples/jsm/libs/flow.module.js +4552 -0
  370. package/examples/jsm/libs/ktx-parse.module.js +1 -0
  371. package/examples/jsm/libs/lil-gui.module.min.js +8 -0
  372. package/examples/jsm/libs/meshopt_decoder.module.js +178 -0
  373. package/examples/jsm/libs/mikktspace.module.js +128 -0
  374. package/examples/jsm/libs/mmdparser.module.js +11530 -0
  375. package/examples/jsm/libs/motion-controllers.module.js +397 -0
  376. package/examples/jsm/libs/opentype.module.js +14568 -0
  377. package/examples/jsm/libs/potpack.module.js +125 -0
  378. package/examples/jsm/libs/rhino3dm/rhino3dm.js +21 -0
  379. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +16 -0
  380. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  381. package/examples/jsm/libs/stats.module.js +167 -0
  382. package/examples/jsm/libs/tween.module.min.js +3 -0
  383. package/examples/jsm/libs/utif.module.js +1579 -0
  384. package/examples/jsm/libs/zstddec.module.js +1 -0
  385. package/examples/jsm/lights/LightProbeGenerator.js +250 -0
  386. package/examples/jsm/lights/RectAreaLightUniformsLib.js +79 -0
  387. package/examples/jsm/lines/Line2.js +19 -0
  388. package/examples/jsm/lines/LineGeometry.js +79 -0
  389. package/examples/jsm/lines/LineMaterial.js +702 -0
  390. package/examples/jsm/lines/LineSegments2.js +355 -0
  391. package/examples/jsm/lines/LineSegmentsGeometry.js +241 -0
  392. package/examples/jsm/lines/Wireframe.js +56 -0
  393. package/examples/jsm/lines/WireframeGeometry2.js +24 -0
  394. package/examples/jsm/loaders/3DMLoader.js +1495 -0
  395. package/examples/jsm/loaders/3MFLoader.js +1473 -0
  396. package/examples/jsm/loaders/AMFLoader.js +518 -0
  397. package/examples/jsm/loaders/BVHLoader.js +437 -0
  398. package/examples/jsm/loaders/BasisTextureLoader.js +790 -0
  399. package/examples/jsm/loaders/ColladaLoader.js +4092 -0
  400. package/examples/jsm/loaders/DDSLoader.js +274 -0
  401. package/examples/jsm/loaders/DRACOLoader.js +561 -0
  402. package/examples/jsm/loaders/EXRLoader.js +2310 -0
  403. package/examples/jsm/loaders/FBXLoader.js +4137 -0
  404. package/examples/jsm/loaders/FontLoader.js +183 -0
  405. package/examples/jsm/loaders/GCodeLoader.js +262 -0
  406. package/examples/jsm/loaders/GLTFLoader.js +5221 -0
  407. package/examples/jsm/loaders/HDRCubeTextureLoader.js +115 -0
  408. package/examples/jsm/loaders/IFCLoader.js +2431 -0
  409. package/examples/jsm/loaders/KMZLoader.js +130 -0
  410. package/examples/jsm/loaders/KTX2Loader.js +753 -0
  411. package/examples/jsm/loaders/KTXLoader.js +176 -0
  412. package/examples/jsm/loaders/LDrawLoader.js +2464 -0
  413. package/examples/jsm/loaders/LUT3dlLoader.js +151 -0
  414. package/examples/jsm/loaders/LUTCubeLoader.js +153 -0
  415. package/examples/jsm/loaders/LWOLoader.js +1069 -0
  416. package/examples/jsm/loaders/LogLuvLoader.js +606 -0
  417. package/examples/jsm/loaders/LottieLoader.js +73 -0
  418. package/examples/jsm/loaders/MD2Loader.js +399 -0
  419. package/examples/jsm/loaders/MDDLoader.js +102 -0
  420. package/examples/jsm/loaders/MMDLoader.js +2242 -0
  421. package/examples/jsm/loaders/MTLLoader.js +567 -0
  422. package/examples/jsm/loaders/NRRDLoader.js +671 -0
  423. package/examples/jsm/loaders/OBJLoader.js +905 -0
  424. package/examples/jsm/loaders/PCDLoader.js +453 -0
  425. package/examples/jsm/loaders/PDBLoader.js +227 -0
  426. package/examples/jsm/loaders/PLYLoader.js +564 -0
  427. package/examples/jsm/loaders/PRWMLoader.js +299 -0
  428. package/examples/jsm/loaders/PVRLoader.js +251 -0
  429. package/examples/jsm/loaders/RGBELoader.js +468 -0
  430. package/examples/jsm/loaders/RGBMLoader.js +1065 -0
  431. package/examples/jsm/loaders/STLLoader.js +399 -0
  432. package/examples/jsm/loaders/SVGLoader.js +2950 -0
  433. package/examples/jsm/loaders/TDSLoader.js +1124 -0
  434. package/examples/jsm/loaders/TGALoader.js +517 -0
  435. package/examples/jsm/loaders/TIFFLoader.js +36 -0
  436. package/examples/jsm/loaders/TTFLoader.js +221 -0
  437. package/examples/jsm/loaders/TiltLoader.js +514 -0
  438. package/examples/jsm/loaders/USDZLoader.js +618 -0
  439. package/examples/jsm/loaders/VOXLoader.js +305 -0
  440. package/examples/jsm/loaders/VRMLLoader.js +3493 -0
  441. package/examples/jsm/loaders/VTKLoader.js +1154 -0
  442. package/examples/jsm/loaders/XYZLoader.js +100 -0
  443. package/examples/jsm/loaders/ifc/web-ifc-api.js +47504 -0
  444. package/examples/jsm/loaders/ifc/web-ifc.wasm +0 -0
  445. package/examples/jsm/loaders/lwo/IFFParser.js +1218 -0
  446. package/examples/jsm/loaders/lwo/LWO2Parser.js +414 -0
  447. package/examples/jsm/loaders/lwo/LWO3Parser.js +373 -0
  448. package/examples/jsm/materials/MeshGouraudMaterial.js +423 -0
  449. package/examples/jsm/math/Capsule.js +137 -0
  450. package/examples/jsm/math/ColorConverter.js +36 -0
  451. package/examples/jsm/math/ConvexHull.js +1271 -0
  452. package/examples/jsm/math/ImprovedNoise.js +71 -0
  453. package/examples/jsm/math/Lut.js +203 -0
  454. package/examples/jsm/math/MeshSurfaceSampler.js +211 -0
  455. package/examples/jsm/math/OBB.js +423 -0
  456. package/examples/jsm/math/Octree.js +462 -0
  457. package/examples/jsm/math/SimplexNoise.js +444 -0
  458. package/examples/jsm/misc/ConvexObjectBreaker.js +525 -0
  459. package/examples/jsm/misc/GPUComputationRenderer.js +454 -0
  460. package/examples/jsm/misc/Gyroscope.js +66 -0
  461. package/examples/jsm/misc/MD2Character.js +276 -0
  462. package/examples/jsm/misc/MD2CharacterComplex.js +576 -0
  463. package/examples/jsm/misc/MorphAnimMesh.js +75 -0
  464. package/examples/jsm/misc/MorphBlendMesh.js +322 -0
  465. package/examples/jsm/misc/ProgressiveLightMap.js +321 -0
  466. package/examples/jsm/misc/RollerCoaster.js +560 -0
  467. package/examples/jsm/misc/TubePainter.js +205 -0
  468. package/examples/jsm/misc/Volume.js +460 -0
  469. package/examples/jsm/misc/VolumeSlice.js +227 -0
  470. package/examples/jsm/modifiers/CurveModifier.js +325 -0
  471. package/examples/jsm/modifiers/EdgeSplitModifier.js +279 -0
  472. package/examples/jsm/modifiers/SimplifyModifier.js +525 -0
  473. package/examples/jsm/modifiers/TessellateModifier.js +307 -0
  474. package/examples/jsm/node-editor/NodeEditor.js +857 -0
  475. package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +14 -0
  476. package/examples/jsm/node-editor/accessors/NormalEditor.js +30 -0
  477. package/examples/jsm/node-editor/accessors/PositionEditor.js +30 -0
  478. package/examples/jsm/node-editor/accessors/UVEditor.js +25 -0
  479. package/examples/jsm/node-editor/core/BaseNode.js +96 -0
  480. package/examples/jsm/node-editor/core/DataFile.js +59 -0
  481. package/examples/jsm/node-editor/core/FileEditor.js +20 -0
  482. package/examples/jsm/node-editor/core/FileURLEditor.js +29 -0
  483. package/examples/jsm/node-editor/display/BlendEditor.js +44 -0
  484. package/examples/jsm/node-editor/display/NormalMapEditor.js +49 -0
  485. package/examples/jsm/node-editor/examples/animate-uv.json +1 -0
  486. package/examples/jsm/node-editor/examples/fake-top-light.json +1 -0
  487. package/examples/jsm/node-editor/examples/matcap.json +1 -0
  488. package/examples/jsm/node-editor/examples/oscillator-color.json +1 -0
  489. package/examples/jsm/node-editor/examples/rim.json +1 -0
  490. package/examples/jsm/node-editor/inputs/ColorEditor.js +96 -0
  491. package/examples/jsm/node-editor/inputs/FloatEditor.js +23 -0
  492. package/examples/jsm/node-editor/inputs/SliderEditor.js +67 -0
  493. package/examples/jsm/node-editor/inputs/TextureEditor.js +155 -0
  494. package/examples/jsm/node-editor/inputs/Vector2Editor.js +28 -0
  495. package/examples/jsm/node-editor/inputs/Vector3Editor.js +30 -0
  496. package/examples/jsm/node-editor/inputs/Vector4Editor.js +37 -0
  497. package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +84 -0
  498. package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +102 -0
  499. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +118 -0
  500. package/examples/jsm/node-editor/math/AngleEditor.js +40 -0
  501. package/examples/jsm/node-editor/math/DotEditor.js +35 -0
  502. package/examples/jsm/node-editor/math/InvertEditor.js +39 -0
  503. package/examples/jsm/node-editor/math/LimiterEditor.js +62 -0
  504. package/examples/jsm/node-editor/math/NormalizeEditor.js +28 -0
  505. package/examples/jsm/node-editor/math/OperatorEditor.js +63 -0
  506. package/examples/jsm/node-editor/math/PowerEditor.js +44 -0
  507. package/examples/jsm/node-editor/math/TrigonometryEditor.js +45 -0
  508. package/examples/jsm/node-editor/procedural/CheckerEditor.js +27 -0
  509. package/examples/jsm/node-editor/scene/MeshEditor.js +102 -0
  510. package/examples/jsm/node-editor/scene/Object3DEditor.js +160 -0
  511. package/examples/jsm/node-editor/scene/PointsEditor.js +99 -0
  512. package/examples/jsm/node-editor/utils/JoinEditor.js +58 -0
  513. package/examples/jsm/node-editor/utils/OscillatorEditor.js +43 -0
  514. package/examples/jsm/node-editor/utils/PreviewEditor.js +170 -0
  515. package/examples/jsm/node-editor/utils/SplitEditor.js +39 -0
  516. package/examples/jsm/node-editor/utils/TimerEditor.js +58 -0
  517. package/examples/jsm/nodes/Nodes.js +346 -0
  518. package/examples/jsm/nodes/accessors/BitangentNode.js +62 -0
  519. package/examples/jsm/nodes/accessors/BufferNode.js +24 -0
  520. package/examples/jsm/nodes/accessors/CameraNode.js +67 -0
  521. package/examples/jsm/nodes/accessors/CubeTextureNode.js +107 -0
  522. package/examples/jsm/nodes/accessors/InstanceNode.js +58 -0
  523. package/examples/jsm/nodes/accessors/MaterialNode.js +152 -0
  524. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +23 -0
  525. package/examples/jsm/nodes/accessors/ModelNode.js +21 -0
  526. package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +30 -0
  527. package/examples/jsm/nodes/accessors/NormalNode.js +79 -0
  528. package/examples/jsm/nodes/accessors/Object3DNode.js +122 -0
  529. package/examples/jsm/nodes/accessors/PointUVNode.js +21 -0
  530. package/examples/jsm/nodes/accessors/PositionNode.js +83 -0
  531. package/examples/jsm/nodes/accessors/ReferenceNode.js +65 -0
  532. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +31 -0
  533. package/examples/jsm/nodes/accessors/SkinningNode.js +109 -0
  534. package/examples/jsm/nodes/accessors/StorageBufferNode.js +21 -0
  535. package/examples/jsm/nodes/accessors/TangentNode.js +95 -0
  536. package/examples/jsm/nodes/accessors/TextureNode.js +100 -0
  537. package/examples/jsm/nodes/accessors/UVNode.js +41 -0
  538. package/examples/jsm/nodes/accessors/UserDataNode.js +23 -0
  539. package/examples/jsm/nodes/core/ArrayUniformNode.js +23 -0
  540. package/examples/jsm/nodes/core/AttributeNode.js +94 -0
  541. package/examples/jsm/nodes/core/BypassNode.js +38 -0
  542. package/examples/jsm/nodes/core/CodeNode.js +50 -0
  543. package/examples/jsm/nodes/core/ConstNode.js +29 -0
  544. package/examples/jsm/nodes/core/ContextNode.js +52 -0
  545. package/examples/jsm/nodes/core/ExpressionNode.js +32 -0
  546. package/examples/jsm/nodes/core/FunctionCallNode.js +82 -0
  547. package/examples/jsm/nodes/core/FunctionNode.js +105 -0
  548. package/examples/jsm/nodes/core/InputNode.js +62 -0
  549. package/examples/jsm/nodes/core/InstanceIndexNode.js +21 -0
  550. package/examples/jsm/nodes/core/Node.js +354 -0
  551. package/examples/jsm/nodes/core/NodeAttribute.js +14 -0
  552. package/examples/jsm/nodes/core/NodeBuilder.js +815 -0
  553. package/examples/jsm/nodes/core/NodeCode.js +15 -0
  554. package/examples/jsm/nodes/core/NodeFrame.js +59 -0
  555. package/examples/jsm/nodes/core/NodeFunction.js +22 -0
  556. package/examples/jsm/nodes/core/NodeFunctionInput.js +17 -0
  557. package/examples/jsm/nodes/core/NodeKeywords.js +80 -0
  558. package/examples/jsm/nodes/core/NodeParser.js +11 -0
  559. package/examples/jsm/nodes/core/NodeUniform.js +28 -0
  560. package/examples/jsm/nodes/core/NodeUtils.js +125 -0
  561. package/examples/jsm/nodes/core/NodeVar.js +14 -0
  562. package/examples/jsm/nodes/core/NodeVarying.js +14 -0
  563. package/examples/jsm/nodes/core/PropertyNode.js +36 -0
  564. package/examples/jsm/nodes/core/TempNode.js +50 -0
  565. package/examples/jsm/nodes/core/UniformNode.js +46 -0
  566. package/examples/jsm/nodes/core/VarNode.js +97 -0
  567. package/examples/jsm/nodes/core/VaryingNode.js +54 -0
  568. package/examples/jsm/nodes/core/constants.js +21 -0
  569. package/examples/jsm/nodes/display/BlendModeNode.js +85 -0
  570. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +84 -0
  571. package/examples/jsm/nodes/display/ColorSpaceNode.js +95 -0
  572. package/examples/jsm/nodes/display/FrontFacingNode.js +21 -0
  573. package/examples/jsm/nodes/display/NormalMapNode.js +93 -0
  574. package/examples/jsm/nodes/display/ToneMappingNode.js +51 -0
  575. package/examples/jsm/nodes/fog/FogNode.js +31 -0
  576. package/examples/jsm/nodes/fog/FogRangeNode.js +27 -0
  577. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +33 -0
  578. package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +9 -0
  579. package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +27 -0
  580. package/examples/jsm/nodes/functions/BSDF/D_GGX.js +18 -0
  581. package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +18 -0
  582. package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +18 -0
  583. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +94 -0
  584. package/examples/jsm/nodes/functions/light/getDistanceAttenuation.js +22 -0
  585. package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +12 -0
  586. package/examples/jsm/nodes/functions/material/getRoughness.js +18 -0
  587. package/examples/jsm/nodes/geometry/RangeNode.js +109 -0
  588. package/examples/jsm/nodes/gpgpu/ComputeNode.js +65 -0
  589. package/examples/jsm/nodes/lighting/AONode.js +25 -0
  590. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +37 -0
  591. package/examples/jsm/nodes/lighting/EnvironmentNode.js +66 -0
  592. package/examples/jsm/nodes/lighting/HemisphereLightNode.js +50 -0
  593. package/examples/jsm/nodes/lighting/LightingContextNode.js +75 -0
  594. package/examples/jsm/nodes/lighting/LightingNode.js +19 -0
  595. package/examples/jsm/nodes/lighting/LightsNode.js +120 -0
  596. package/examples/jsm/nodes/lighting/PunctualLightNode.js +68 -0
  597. package/examples/jsm/nodes/loaders/NodeLoader.js +107 -0
  598. package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +73 -0
  599. package/examples/jsm/nodes/loaders/NodeObjectLoader.js +70 -0
  600. package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +46 -0
  601. package/examples/jsm/nodes/materials/Materials.js +53 -0
  602. package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +48 -0
  603. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +70 -0
  604. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +168 -0
  605. package/examples/jsm/nodes/materials/NodeMaterial.js +229 -0
  606. package/examples/jsm/nodes/materials/PointsNodeMaterial.js +52 -0
  607. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +106 -0
  608. package/examples/jsm/nodes/materialx/DISCLAIMER.md +199 -0
  609. package/examples/jsm/nodes/materialx/MaterialXNodes.js +55 -0
  610. package/examples/jsm/nodes/materialx/lib/mx_hsv.js +56 -0
  611. package/examples/jsm/nodes/materialx/lib/mx_noise.js +617 -0
  612. package/examples/jsm/nodes/math/CondNode.js +60 -0
  613. package/examples/jsm/nodes/math/MathNode.js +243 -0
  614. package/examples/jsm/nodes/math/OperatorNode.js +214 -0
  615. package/examples/jsm/nodes/parsers/GLSLNodeFunction.js +152 -0
  616. package/examples/jsm/nodes/parsers/GLSLNodeParser.js +14 -0
  617. package/examples/jsm/nodes/parsers/WGSLNodeFunction.js +104 -0
  618. package/examples/jsm/nodes/parsers/WGSLNodeParser.js +14 -0
  619. package/examples/jsm/nodes/procedural/CheckerNode.js +34 -0
  620. package/examples/jsm/nodes/shadernode/ShaderNode.js +264 -0
  621. package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +299 -0
  622. package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +131 -0
  623. package/examples/jsm/nodes/utils/ArrayElementNode.js +31 -0
  624. package/examples/jsm/nodes/utils/ConvertNode.js +47 -0
  625. package/examples/jsm/nodes/utils/JoinNode.js +42 -0
  626. package/examples/jsm/nodes/utils/MatcapUVNode.js +25 -0
  627. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +33 -0
  628. package/examples/jsm/nodes/utils/OscNode.js +74 -0
  629. package/examples/jsm/nodes/utils/RemapNode.js +34 -0
  630. package/examples/jsm/nodes/utils/RotateUVNode.js +32 -0
  631. package/examples/jsm/nodes/utils/SplitNode.js +102 -0
  632. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +58 -0
  633. package/examples/jsm/nodes/utils/TimerNode.js +84 -0
  634. package/examples/jsm/objects/GroundProjectedEnv.js +186 -0
  635. package/examples/jsm/objects/Lensflare.js +378 -0
  636. package/examples/jsm/objects/LightningStorm.js +245 -0
  637. package/examples/jsm/objects/MarchingCubes.js +1172 -0
  638. package/examples/jsm/objects/Reflector.js +269 -0
  639. package/examples/jsm/objects/ReflectorForSSRPass.js +349 -0
  640. package/examples/jsm/objects/Refractor.js +332 -0
  641. package/examples/jsm/objects/ShadowMesh.js +80 -0
  642. package/examples/jsm/objects/Sky.js +219 -0
  643. package/examples/jsm/objects/Water.js +329 -0
  644. package/examples/jsm/objects/Water2.js +358 -0
  645. package/examples/jsm/offscreen/jank.js +45 -0
  646. package/examples/jsm/offscreen/offscreen.js +8 -0
  647. package/examples/jsm/offscreen/scene.js +86 -0
  648. package/examples/jsm/physics/AmmoPhysics.js +286 -0
  649. package/examples/jsm/physics/OimoPhysics.js +231 -0
  650. package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +369 -0
  651. package/examples/jsm/postprocessing/AfterimagePass.js +90 -0
  652. package/examples/jsm/postprocessing/BloomPass.js +150 -0
  653. package/examples/jsm/postprocessing/BokehPass.js +131 -0
  654. package/examples/jsm/postprocessing/ClearPass.js +46 -0
  655. package/examples/jsm/postprocessing/CubeTexturePass.js +78 -0
  656. package/examples/jsm/postprocessing/DotScreenPass.js +58 -0
  657. package/examples/jsm/postprocessing/EffectComposer.js +310 -0
  658. package/examples/jsm/postprocessing/FilmPass.js +59 -0
  659. package/examples/jsm/postprocessing/GlitchPass.js +118 -0
  660. package/examples/jsm/postprocessing/HalftonePass.js +77 -0
  661. package/examples/jsm/postprocessing/LUTPass.js +173 -0
  662. package/examples/jsm/postprocessing/MaskPass.js +101 -0
  663. package/examples/jsm/postprocessing/OutlinePass.js +646 -0
  664. package/examples/jsm/postprocessing/Pass.js +80 -0
  665. package/examples/jsm/postprocessing/RenderPass.js +81 -0
  666. package/examples/jsm/postprocessing/SAOPass.js +413 -0
  667. package/examples/jsm/postprocessing/SMAAPass.js +188 -0
  668. package/examples/jsm/postprocessing/SSAARenderPass.js +224 -0
  669. package/examples/jsm/postprocessing/SSAOPass.js +450 -0
  670. package/examples/jsm/postprocessing/SSRPass.js +645 -0
  671. package/examples/jsm/postprocessing/SavePass.js +62 -0
  672. package/examples/jsm/postprocessing/ShaderPass.js +68 -0
  673. package/examples/jsm/postprocessing/TAARenderPass.js +167 -0
  674. package/examples/jsm/postprocessing/TexturePass.js +60 -0
  675. package/examples/jsm/postprocessing/UnrealBloomPass.js +403 -0
  676. package/examples/jsm/renderers/CSS2DRenderer.js +210 -0
  677. package/examples/jsm/renderers/CSS3DRenderer.js +313 -0
  678. package/examples/jsm/renderers/Projector.js +918 -0
  679. package/examples/jsm/renderers/SVGRenderer.js +553 -0
  680. package/examples/jsm/renderers/webgl/nodes/SlotNode.js +26 -0
  681. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +733 -0
  682. package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +49 -0
  683. package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +129 -0
  684. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +144 -0
  685. package/examples/jsm/renderers/webgpu/WebGPUBinding.js +22 -0
  686. package/examples/jsm/renderers/webgpu/WebGPUBindings.js +255 -0
  687. package/examples/jsm/renderers/webgpu/WebGPUBuffer.js +43 -0
  688. package/examples/jsm/renderers/webgpu/WebGPUBufferUtils.js +33 -0
  689. package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +78 -0
  690. package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +82 -0
  691. package/examples/jsm/renderers/webgpu/WebGPUInfo.js +74 -0
  692. package/examples/jsm/renderers/webgpu/WebGPUObjects.js +36 -0
  693. package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +22 -0
  694. package/examples/jsm/renderers/webgpu/WebGPUProperties.js +38 -0
  695. package/examples/jsm/renderers/webgpu/WebGPURenderLists.js +199 -0
  696. package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +735 -0
  697. package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +296 -0
  698. package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +66 -0
  699. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +969 -0
  700. package/examples/jsm/renderers/webgpu/WebGPUSampledTexture.js +73 -0
  701. package/examples/jsm/renderers/webgpu/WebGPUSampler.js +29 -0
  702. package/examples/jsm/renderers/webgpu/WebGPUStorageBuffer.js +20 -0
  703. package/examples/jsm/renderers/webgpu/WebGPUTextureRenderer.js +40 -0
  704. package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +183 -0
  705. package/examples/jsm/renderers/webgpu/WebGPUTextures.js +794 -0
  706. package/examples/jsm/renderers/webgpu/WebGPUUniform.js +136 -0
  707. package/examples/jsm/renderers/webgpu/WebGPUUniformBuffer.js +18 -0
  708. package/examples/jsm/renderers/webgpu/WebGPUUniformsGroup.js +299 -0
  709. package/examples/jsm/renderers/webgpu/WebGPUUtils.js +81 -0
  710. package/examples/jsm/renderers/webgpu/constants.js +261 -0
  711. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +801 -0
  712. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeSampledTexture.js +39 -0
  713. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeSampler.js +21 -0
  714. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeUniform.js +135 -0
  715. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +83 -0
  716. package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +87 -0
  717. package/examples/jsm/shaders/AfterimageShader.js +56 -0
  718. package/examples/jsm/shaders/BasicShader.js +27 -0
  719. package/examples/jsm/shaders/BleachBypassShader.js +60 -0
  720. package/examples/jsm/shaders/BlendShader.js +48 -0
  721. package/examples/jsm/shaders/BokehShader.js +143 -0
  722. package/examples/jsm/shaders/BokehShader2.js +390 -0
  723. package/examples/jsm/shaders/BrightnessContrastShader.js +54 -0
  724. package/examples/jsm/shaders/ColorCorrectionShader.js +50 -0
  725. package/examples/jsm/shaders/ColorifyShader.js +49 -0
  726. package/examples/jsm/shaders/ConvolutionShader.js +101 -0
  727. package/examples/jsm/shaders/CopyShader.js +43 -0
  728. package/examples/jsm/shaders/DOFMipMapShader.js +54 -0
  729. package/examples/jsm/shaders/DepthLimitedBlurShader.js +166 -0
  730. package/examples/jsm/shaders/DigitalGlitch.js +101 -0
  731. package/examples/jsm/shaders/DotScreenShader.js +68 -0
  732. package/examples/jsm/shaders/FXAAShader.js +286 -0
  733. package/examples/jsm/shaders/FilmShader.js +100 -0
  734. package/examples/jsm/shaders/FocusShader.js +87 -0
  735. package/examples/jsm/shaders/FreiChenShader.js +94 -0
  736. package/examples/jsm/shaders/GammaCorrectionShader.js +41 -0
  737. package/examples/jsm/shaders/GodRaysShader.js +313 -0
  738. package/examples/jsm/shaders/HalftoneShader.js +310 -0
  739. package/examples/jsm/shaders/HorizontalBlurShader.js +57 -0
  740. package/examples/jsm/shaders/HorizontalTiltShiftShader.js +61 -0
  741. package/examples/jsm/shaders/HueSaturationShader.js +65 -0
  742. package/examples/jsm/shaders/KaleidoShader.js +56 -0
  743. package/examples/jsm/shaders/LuminosityHighPassShader.js +64 -0
  744. package/examples/jsm/shaders/LuminosityShader.js +46 -0
  745. package/examples/jsm/shaders/MMDToonShader.js +123 -0
  746. package/examples/jsm/shaders/MirrorShader.js +54 -0
  747. package/examples/jsm/shaders/NormalMapShader.js +53 -0
  748. package/examples/jsm/shaders/PixelShader.js +44 -0
  749. package/examples/jsm/shaders/RGBShiftShader.js +52 -0
  750. package/examples/jsm/shaders/SAOShader.js +188 -0
  751. package/examples/jsm/shaders/SMAAShader.js +460 -0
  752. package/examples/jsm/shaders/SSAOShader.js +288 -0
  753. package/examples/jsm/shaders/SSRShader.js +364 -0
  754. package/examples/jsm/shaders/SepiaShader.js +50 -0
  755. package/examples/jsm/shaders/SobelOperatorShader.js +90 -0
  756. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +88 -0
  757. package/examples/jsm/shaders/TechnicolorShader.js +43 -0
  758. package/examples/jsm/shaders/ToneMapShader.js +73 -0
  759. package/examples/jsm/shaders/ToonShader.js +318 -0
  760. package/examples/jsm/shaders/TriangleBlurShader.js +72 -0
  761. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +45 -0
  762. package/examples/jsm/shaders/VerticalBlurShader.js +57 -0
  763. package/examples/jsm/shaders/VerticalTiltShiftShader.js +61 -0
  764. package/examples/jsm/shaders/VignetteShader.js +49 -0
  765. package/examples/jsm/shaders/VolumeShader.js +289 -0
  766. package/examples/jsm/shaders/WaterRefractionShader.js +90 -0
  767. package/examples/jsm/textures/FlakesTexture.js +40 -0
  768. package/examples/jsm/utils/BufferGeometryUtils.js +1222 -0
  769. package/examples/jsm/utils/CameraUtils.js +73 -0
  770. package/examples/jsm/utils/GPUStatsPanel.js +128 -0
  771. package/examples/jsm/utils/GeometryCompressionUtils.js +639 -0
  772. package/examples/jsm/utils/GeometryUtils.js +221 -0
  773. package/examples/jsm/utils/LDrawUtils.js +202 -0
  774. package/examples/jsm/utils/PackedPhongMaterial.js +251 -0
  775. package/examples/jsm/utils/SceneUtils.js +125 -0
  776. package/examples/jsm/utils/ShadowMapViewer.js +210 -0
  777. package/examples/jsm/utils/SkeletonUtils.js +596 -0
  778. package/examples/jsm/utils/UVsDebug.js +165 -0
  779. package/examples/jsm/utils/WorkerPool.js +102 -0
  780. package/examples/jsm/webxr/ARButton.js +208 -0
  781. package/examples/jsm/webxr/OculusHandModel.js +108 -0
  782. package/examples/jsm/webxr/OculusHandPointerModel.js +394 -0
  783. package/examples/jsm/webxr/Text2D.js +38 -0
  784. package/examples/jsm/webxr/VRButton.js +201 -0
  785. package/examples/jsm/webxr/XRControllerModelFactory.js +310 -0
  786. package/examples/jsm/webxr/XREstimatedLight.js +223 -0
  787. package/examples/jsm/webxr/XRHandMeshModel.js +108 -0
  788. package/examples/jsm/webxr/XRHandModelFactory.js +105 -0
  789. package/examples/jsm/webxr/XRHandPrimitiveModel.js +103 -0
  790. package/package.json +179 -0
  791. package/src/Three.Legacy.js +320 -0
  792. package/src/Three.js +180 -0
  793. package/src/animation/AnimationAction.js +700 -0
  794. package/src/animation/AnimationClip.js +473 -0
  795. package/src/animation/AnimationMixer.js +770 -0
  796. package/src/animation/AnimationObjectGroup.js +387 -0
  797. package/src/animation/AnimationUtils.js +361 -0
  798. package/src/animation/KeyframeTrack.js +462 -0
  799. package/src/animation/PropertyBinding.js +719 -0
  800. package/src/animation/PropertyMixer.js +318 -0
  801. package/src/animation/tracks/BooleanKeyframeTrack.js +19 -0
  802. package/src/animation/tracks/ColorKeyframeTrack.js +15 -0
  803. package/src/animation/tracks/NumberKeyframeTrack.js +12 -0
  804. package/src/animation/tracks/QuaternionKeyframeTrack.js +23 -0
  805. package/src/animation/tracks/StringKeyframeTrack.js +15 -0
  806. package/src/animation/tracks/VectorKeyframeTrack.js +12 -0
  807. package/src/audio/Audio.js +391 -0
  808. package/src/audio/AudioAnalyser.js +40 -0
  809. package/src/audio/AudioContext.js +25 -0
  810. package/src/audio/AudioListener.js +137 -0
  811. package/src/audio/PositionalAudio.js +138 -0
  812. package/src/cameras/ArrayCamera.js +17 -0
  813. package/src/cameras/Camera.js +68 -0
  814. package/src/cameras/CubeCamera.js +107 -0
  815. package/src/cameras/OrthographicCamera.js +136 -0
  816. package/src/cameras/PerspectiveCamera.js +233 -0
  817. package/src/cameras/StereoCamera.js +100 -0
  818. package/src/constants.js +181 -0
  819. package/src/core/BufferAttribute.js +493 -0
  820. package/src/core/BufferGeometry.js +1092 -0
  821. package/src/core/Clock.js +74 -0
  822. package/src/core/EventDispatcher.js +87 -0
  823. package/src/core/GLBufferAttribute.js +58 -0
  824. package/src/core/InstancedBufferAttribute.js +39 -0
  825. package/src/core/InstancedBufferGeometry.js +46 -0
  826. package/src/core/InstancedInterleavedBuffer.js +48 -0
  827. package/src/core/InterleavedBuffer.js +145 -0
  828. package/src/core/InterleavedBufferAttribute.js +331 -0
  829. package/src/core/Layers.js +60 -0
  830. package/src/core/Object3D.js +944 -0
  831. package/src/core/Raycaster.js +110 -0
  832. package/src/core/Uniform.js +17 -0
  833. package/src/core/UniformsGroup.js +92 -0
  834. package/src/extras/DataUtils.js +170 -0
  835. package/src/extras/Earcut.js +789 -0
  836. package/src/extras/ImageUtils.js +129 -0
  837. package/src/extras/PMREMGenerator.js +900 -0
  838. package/src/extras/ShapeUtils.js +92 -0
  839. package/src/extras/core/Curve.js +416 -0
  840. package/src/extras/core/CurvePath.js +252 -0
  841. package/src/extras/core/Interpolations.js +79 -0
  842. package/src/extras/core/Path.js +196 -0
  843. package/src/extras/core/Shape.js +102 -0
  844. package/src/extras/core/ShapePath.js +291 -0
  845. package/src/extras/curves/ArcCurve.js +17 -0
  846. package/src/extras/curves/CatmullRomCurve3.js +255 -0
  847. package/src/extras/curves/CubicBezierCurve.js +78 -0
  848. package/src/extras/curves/CubicBezierCurve3.js +79 -0
  849. package/src/extras/curves/Curves.js +10 -0
  850. package/src/extras/curves/EllipseCurve.js +156 -0
  851. package/src/extras/curves/LineCurve.js +90 -0
  852. package/src/extras/curves/LineCurve3.js +75 -0
  853. package/src/extras/curves/QuadraticBezierCurve.js +74 -0
  854. package/src/extras/curves/QuadraticBezierCurve3.js +75 -0
  855. package/src/extras/curves/SplineCurve.js +97 -0
  856. package/src/geometries/BoxGeometry.js +170 -0
  857. package/src/geometries/CapsuleGeometry.js +33 -0
  858. package/src/geometries/CircleGeometry.js +91 -0
  859. package/src/geometries/ConeGeometry.js +31 -0
  860. package/src/geometries/CylinderGeometry.js +276 -0
  861. package/src/geometries/DodecahedronGeometry.js +66 -0
  862. package/src/geometries/EdgesGeometry.js +142 -0
  863. package/src/geometries/ExtrudeGeometry.js +804 -0
  864. package/src/geometries/Geometries.js +21 -0
  865. package/src/geometries/IcosahedronGeometry.js +42 -0
  866. package/src/geometries/LatheGeometry.js +179 -0
  867. package/src/geometries/OctahedronGeometry.js +37 -0
  868. package/src/geometries/PlaneGeometry.js +88 -0
  869. package/src/geometries/PolyhedronGeometry.js +309 -0
  870. package/src/geometries/RingGeometry.js +118 -0
  871. package/src/geometries/ShapeGeometry.js +185 -0
  872. package/src/geometries/SphereGeometry.js +127 -0
  873. package/src/geometries/TetrahedronGeometry.js +34 -0
  874. package/src/geometries/TorusGeometry.js +110 -0
  875. package/src/geometries/TorusKnotGeometry.js +157 -0
  876. package/src/geometries/TubeGeometry.js +193 -0
  877. package/src/geometries/WireframeGeometry.js +137 -0
  878. package/src/helpers/ArrowHelper.js +114 -0
  879. package/src/helpers/AxesHelper.js +68 -0
  880. package/src/helpers/Box3Helper.js +56 -0
  881. package/src/helpers/BoxHelper.js +113 -0
  882. package/src/helpers/CameraHelper.js +269 -0
  883. package/src/helpers/DirectionalLightHelper.js +89 -0
  884. package/src/helpers/GridHelper.js +56 -0
  885. package/src/helpers/HemisphereLightHelper.js +85 -0
  886. package/src/helpers/PlaneHelper.js +63 -0
  887. package/src/helpers/PointLightHelper.js +91 -0
  888. package/src/helpers/PolarGridHelper.js +96 -0
  889. package/src/helpers/SkeletonHelper.js +128 -0
  890. package/src/helpers/SpotLightHelper.js +92 -0
  891. package/src/lights/AmbientLight.js +17 -0
  892. package/src/lights/AmbientLightProbe.js +21 -0
  893. package/src/lights/DirectionalLight.js +43 -0
  894. package/src/lights/DirectionalLightShadow.js +16 -0
  895. package/src/lights/HemisphereLight.js +34 -0
  896. package/src/lights/HemisphereLightProbe.js +30 -0
  897. package/src/lights/Light.js +58 -0
  898. package/src/lights/LightProbe.js +47 -0
  899. package/src/lights/LightShadow.js +147 -0
  900. package/src/lights/PointLight.js +57 -0
  901. package/src/lights/PointLightShadow.js +96 -0
  902. package/src/lights/RectAreaLight.js +56 -0
  903. package/src/lights/SpotLight.js +71 -0
  904. package/src/lights/SpotLightShadow.js +50 -0
  905. package/src/loaders/AnimationLoader.js +66 -0
  906. package/src/loaders/AudioLoader.js +60 -0
  907. package/src/loaders/BufferGeometryLoader.js +224 -0
  908. package/src/loaders/Cache.js +42 -0
  909. package/src/loaders/CompressedTextureLoader.js +134 -0
  910. package/src/loaders/CubeTextureLoader.js +56 -0
  911. package/src/loaders/DataTextureLoader.js +114 -0
  912. package/src/loaders/FileLoader.js +281 -0
  913. package/src/loaders/ImageBitmapLoader.js +99 -0
  914. package/src/loaders/ImageLoader.js +91 -0
  915. package/src/loaders/Loader.js +70 -0
  916. package/src/loaders/LoaderUtils.js +75 -0
  917. package/src/loaders/LoadingManager.js +142 -0
  918. package/src/loaders/MaterialLoader.js +355 -0
  919. package/src/loaders/ObjectLoader.js +1081 -0
  920. package/src/loaders/TextureLoader.js +41 -0
  921. package/src/materials/LineBasicMaterial.js +45 -0
  922. package/src/materials/LineDashedMaterial.js +35 -0
  923. package/src/materials/Material.js +493 -0
  924. package/src/materials/Materials.js +39 -0
  925. package/src/materials/MeshBasicMaterial.js +81 -0
  926. package/src/materials/MeshDepthMaterial.js +54 -0
  927. package/src/materials/MeshDistanceMaterial.js +52 -0
  928. package/src/materials/MeshLambertMaterial.js +116 -0
  929. package/src/materials/MeshMatcapMaterial.js +81 -0
  930. package/src/materials/MeshNormalMaterial.js +61 -0
  931. package/src/materials/MeshPhongMaterial.js +120 -0
  932. package/src/materials/MeshPhysicalMaterial.js +198 -0
  933. package/src/materials/MeshStandardMaterial.js +124 -0
  934. package/src/materials/MeshToonMaterial.js +102 -0
  935. package/src/materials/PointsMaterial.js +50 -0
  936. package/src/materials/RawShaderMaterial.js +17 -0
  937. package/src/materials/ShaderMaterial.js +182 -0
  938. package/src/materials/ShadowMaterial.js +37 -0
  939. package/src/materials/SpriteMaterial.js +54 -0
  940. package/src/math/Box2.js +203 -0
  941. package/src/math/Box3.js +532 -0
  942. package/src/math/Color.js +605 -0
  943. package/src/math/ColorManagement.js +74 -0
  944. package/src/math/Cylindrical.js +61 -0
  945. package/src/math/Euler.js +324 -0
  946. package/src/math/Frustum.js +162 -0
  947. package/src/math/Interpolant.js +241 -0
  948. package/src/math/Line3.js +115 -0
  949. package/src/math/MathUtils.js +321 -0
  950. package/src/math/Matrix3.js +333 -0
  951. package/src/math/Matrix4.js +860 -0
  952. package/src/math/Plane.js +205 -0
  953. package/src/math/Quaternion.js +678 -0
  954. package/src/math/Ray.js +496 -0
  955. package/src/math/Sphere.js +250 -0
  956. package/src/math/Spherical.js +86 -0
  957. package/src/math/SphericalHarmonics3.js +243 -0
  958. package/src/math/Triangle.js +299 -0
  959. package/src/math/Vector2.js +464 -0
  960. package/src/math/Vector3.js +715 -0
  961. package/src/math/Vector4.js +644 -0
  962. package/src/math/interpolants/CubicInterpolant.js +151 -0
  963. package/src/math/interpolants/DiscreteInterpolant.js +26 -0
  964. package/src/math/interpolants/LinearInterpolant.js +38 -0
  965. package/src/math/interpolants/QuaternionLinearInterpolant.js +39 -0
  966. package/src/objects/Bone.js +17 -0
  967. package/src/objects/Group.js +17 -0
  968. package/src/objects/InstancedMesh.js +126 -0
  969. package/src/objects/LOD.js +195 -0
  970. package/src/objects/Line.js +222 -0
  971. package/src/objects/LineLoop.js +17 -0
  972. package/src/objects/LineSegments.js +55 -0
  973. package/src/objects/Mesh.js +397 -0
  974. package/src/objects/Points.js +166 -0
  975. package/src/objects/Skeleton.js +281 -0
  976. package/src/objects/SkinnedMesh.js +151 -0
  977. package/src/objects/Sprite.js +181 -0
  978. package/src/renderers/WebGL1Renderer.js +7 -0
  979. package/src/renderers/WebGL3DRenderTarget.js +22 -0
  980. package/src/renderers/WebGLArrayRenderTarget.js +22 -0
  981. package/src/renderers/WebGLCubeRenderTarget.js +146 -0
  982. package/src/renderers/WebGLMultipleRenderTargets.js +82 -0
  983. package/src/renderers/WebGLRenderTarget.js +110 -0
  984. package/src/renderers/WebGLRenderer.js +2280 -0
  985. package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +7 -0
  986. package/src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js +7 -0
  987. package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +7 -0
  988. package/src/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js +5 -0
  989. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +18 -0
  990. package/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js +8 -0
  991. package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +3 -0
  992. package/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js +9 -0
  993. package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +304 -0
  994. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +42 -0
  995. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +7 -0
  996. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +18 -0
  997. package/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js +21 -0
  998. package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +33 -0
  999. package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js +9 -0
  1000. package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js +7 -0
  1001. package/src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js +7 -0
  1002. package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +11 -0
  1003. package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +11 -0
  1004. package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +11 -0
  1005. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +23 -0
  1006. package/src/renderers/shaders/ShaderChunk/common.glsl.js +118 -0
  1007. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +191 -0
  1008. package/src/renderers/shaders/ShaderChunk/default_fragment.glsl.js +5 -0
  1009. package/src/renderers/shaders/ShaderChunk/default_vertex.glsl.js +5 -0
  1010. package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +36 -0
  1011. package/src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js +9 -0
  1012. package/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js +7 -0
  1013. package/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js +7 -0
  1014. package/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js +20 -0
  1015. package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +9 -0
  1016. package/src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js +7 -0
  1017. package/src/renderers/shaders/ShaderChunk/encodings_fragment.glsl.js +3 -0
  1018. package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +11 -0
  1019. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +14 -0
  1020. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +66 -0
  1021. package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +21 -0
  1022. package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +22 -0
  1023. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +46 -0
  1024. package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +37 -0
  1025. package/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js +17 -0
  1026. package/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js +19 -0
  1027. package/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js +7 -0
  1028. package/src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js +7 -0
  1029. package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +27 -0
  1030. package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +121 -0
  1031. package/src/renderers/shaders/ShaderChunk/iridescence_pars_fragment.glsl.js +14 -0
  1032. package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +10 -0
  1033. package/src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js +8 -0
  1034. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +199 -0
  1035. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +13 -0
  1036. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +32 -0
  1037. package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
  1038. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +30 -0
  1039. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +223 -0
  1040. package/src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js +7 -0
  1041. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +34 -0
  1042. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +120 -0
  1043. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +264 -0
  1044. package/src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js +4 -0
  1045. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +28 -0
  1046. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +9 -0
  1047. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +9 -0
  1048. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +16 -0
  1049. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +22 -0
  1050. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +17 -0
  1051. package/src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js +7 -0
  1052. package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +19 -0
  1053. package/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js +19 -0
  1054. package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +12 -0
  1055. package/src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js +7 -0
  1056. package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +24 -0
  1057. package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +27 -0
  1058. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +38 -0
  1059. package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +36 -0
  1060. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +46 -0
  1061. package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +41 -0
  1062. package/src/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js +14 -0
  1063. package/src/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js +14 -0
  1064. package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +14 -0
  1065. package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +43 -0
  1066. package/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js +12 -0
  1067. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +54 -0
  1068. package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +8 -0
  1069. package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +13 -0
  1070. package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +12 -0
  1071. package/src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js +7 -0
  1072. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +321 -0
  1073. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +68 -0
  1074. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +63 -0
  1075. package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +66 -0
  1076. package/src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js +10 -0
  1077. package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +33 -0
  1078. package/src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js +15 -0
  1079. package/src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js +20 -0
  1080. package/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js +14 -0
  1081. package/src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js +7 -0
  1082. package/src/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js +7 -0
  1083. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +77 -0
  1084. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +36 -0
  1085. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +116 -0
  1086. package/src/renderers/shaders/ShaderChunk/uv2_pars_fragment.glsl.js +7 -0
  1087. package/src/renderers/shaders/ShaderChunk/uv2_pars_vertex.glsl.js +10 -0
  1088. package/src/renderers/shaders/ShaderChunk/uv2_vertex.glsl.js +7 -0
  1089. package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +7 -0
  1090. package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +17 -0
  1091. package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +7 -0
  1092. package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +15 -0
  1093. package/src/renderers/shaders/ShaderChunk.js +265 -0
  1094. package/src/renderers/shaders/ShaderLib/background.glsl.js +35 -0
  1095. package/src/renderers/shaders/ShaderLib/cube.glsl.js +38 -0
  1096. package/src/renderers/shaders/ShaderLib/depth.glsl.js +92 -0
  1097. package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +73 -0
  1098. package/src/renderers/shaders/ShaderLib/equirect.glsl.js +35 -0
  1099. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +70 -0
  1100. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +115 -0
  1101. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +123 -0
  1102. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +107 -0
  1103. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +82 -0
  1104. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +125 -0
  1105. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +216 -0
  1106. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +117 -0
  1107. package/src/renderers/shaders/ShaderLib/points.glsl.js +71 -0
  1108. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +49 -0
  1109. package/src/renderers/shaders/ShaderLib/sprite.glsl.js +79 -0
  1110. package/src/renderers/shaders/ShaderLib/vsm.glsl.js +53 -0
  1111. package/src/renderers/shaders/ShaderLib.js +331 -0
  1112. package/src/renderers/shaders/UniformsLib.js +218 -0
  1113. package/src/renderers/shaders/UniformsUtils.js +80 -0
  1114. package/src/renderers/webgl/WebGLAnimation.js +53 -0
  1115. package/src/renderers/webgl/WebGLAttributes.js +193 -0
  1116. package/src/renderers/webgl/WebGLBackground.js +228 -0
  1117. package/src/renderers/webgl/WebGLBindingStates.js +623 -0
  1118. package/src/renderers/webgl/WebGLBufferRenderer.js +61 -0
  1119. package/src/renderers/webgl/WebGLCapabilities.js +121 -0
  1120. package/src/renderers/webgl/WebGLClipping.js +167 -0
  1121. package/src/renderers/webgl/WebGLCubeMaps.js +99 -0
  1122. package/src/renderers/webgl/WebGLCubeUVMaps.js +130 -0
  1123. package/src/renderers/webgl/WebGLExtensions.js +96 -0
  1124. package/src/renderers/webgl/WebGLGeometries.js +195 -0
  1125. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +71 -0
  1126. package/src/renderers/webgl/WebGLInfo.js +72 -0
  1127. package/src/renderers/webgl/WebGLLights.js +574 -0
  1128. package/src/renderers/webgl/WebGLMaterials.js +677 -0
  1129. package/src/renderers/webgl/WebGLMorphtargets.js +300 -0
  1130. package/src/renderers/webgl/WebGLObjects.js +72 -0
  1131. package/src/renderers/webgl/WebGLProgram.js +901 -0
  1132. package/src/renderers/webgl/WebGLPrograms.js +542 -0
  1133. package/src/renderers/webgl/WebGLProperties.js +48 -0
  1134. package/src/renderers/webgl/WebGLRenderLists.js +238 -0
  1135. package/src/renderers/webgl/WebGLRenderStates.js +107 -0
  1136. package/src/renderers/webgl/WebGLShader.js +12 -0
  1137. package/src/renderers/webgl/WebGLShaderCache.js +124 -0
  1138. package/src/renderers/webgl/WebGLShadowMap.js +374 -0
  1139. package/src/renderers/webgl/WebGLState.js +1263 -0
  1140. package/src/renderers/webgl/WebGLTextures.js +1944 -0
  1141. package/src/renderers/webgl/WebGLUniforms.js +1050 -0
  1142. package/src/renderers/webgl/WebGLUniformsGroups.js +372 -0
  1143. package/src/renderers/webgl/WebGLUtils.js +266 -0
  1144. package/src/renderers/webxr/WebXRController.js +307 -0
  1145. package/src/renderers/webxr/WebXRManager.js +731 -0
  1146. package/src/scenes/Fog.js +37 -0
  1147. package/src/scenes/FogExp2.js +34 -0
  1148. package/src/scenes/Scene.js +71 -0
  1149. package/src/textures/CanvasTexture.js +17 -0
  1150. package/src/textures/CompressedTexture.js +28 -0
  1151. package/src/textures/CubeTexture.js +33 -0
  1152. package/src/textures/Data3DTexture.js +35 -0
  1153. package/src/textures/DataArrayTexture.js +27 -0
  1154. package/src/textures/DataTexture.js +22 -0
  1155. package/src/textures/DepthTexture.js +36 -0
  1156. package/src/textures/FramebufferTexture.js +25 -0
  1157. package/src/textures/Source.js +123 -0
  1158. package/src/textures/Texture.js +308 -0
  1159. package/src/textures/VideoTexture.js +55 -0
  1160. package/src/utils.js +71 -0
@@ -0,0 +1,2310 @@
1
+ import {
2
+ DataTextureLoader,
3
+ DataUtils,
4
+ FloatType,
5
+ HalfFloatType,
6
+ LinearEncoding,
7
+ LinearFilter,
8
+ RedFormat,
9
+ RGBAFormat
10
+ } from 'three';
11
+ import * as fflate from '../libs/fflate.module.js';
12
+
13
+ /**
14
+ * OpenEXR loader currently supports uncompressed, ZIP(S), RLE, PIZ and DWA/B compression.
15
+ * Supports reading as UnsignedByte, HalfFloat and Float type data texture.
16
+ *
17
+ * Referred to the original Industrial Light & Magic OpenEXR implementation and the TinyEXR / Syoyo Fujita
18
+ * implementation, so I have preserved their copyright notices.
19
+ */
20
+
21
+ // /*
22
+ // Copyright (c) 2014 - 2017, Syoyo Fujita
23
+ // All rights reserved.
24
+
25
+ // Redistribution and use in source and binary forms, with or without
26
+ // modification, are permitted provided that the following conditions are met:
27
+ // * Redistributions of source code must retain the above copyright
28
+ // notice, this list of conditions and the following disclaimer.
29
+ // * Redistributions in binary form must reproduce the above copyright
30
+ // notice, this list of conditions and the following disclaimer in the
31
+ // documentation and/or other materials provided with the distribution.
32
+ // * Neither the name of the Syoyo Fujita nor the
33
+ // names of its contributors may be used to endorse or promote products
34
+ // derived from this software without specific prior written permission.
35
+
36
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
37
+ // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
38
+ // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39
+ // DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
40
+ // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
41
+ // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42
+ // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43
+ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
45
+ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46
+ // */
47
+
48
+ // // TinyEXR contains some OpenEXR code, which is licensed under ------------
49
+
50
+ // ///////////////////////////////////////////////////////////////////////////
51
+ // //
52
+ // // Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
53
+ // // Digital Ltd. LLC
54
+ // //
55
+ // // All rights reserved.
56
+ // //
57
+ // // Redistribution and use in source and binary forms, with or without
58
+ // // modification, are permitted provided that the following conditions are
59
+ // // met:
60
+ // // * Redistributions of source code must retain the above copyright
61
+ // // notice, this list of conditions and the following disclaimer.
62
+ // // * Redistributions in binary form must reproduce the above
63
+ // // copyright notice, this list of conditions and the following disclaimer
64
+ // // in the documentation and/or other materials provided with the
65
+ // // distribution.
66
+ // // * Neither the name of Industrial Light & Magic nor the names of
67
+ // // its contributors may be used to endorse or promote products derived
68
+ // // from this software without specific prior written permission.
69
+ // //
70
+ // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
71
+ // // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
72
+ // // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
73
+ // // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
74
+ // // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
75
+ // // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
76
+ // // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
77
+ // // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
78
+ // // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
79
+ // // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
80
+ // // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
81
+ // //
82
+ // ///////////////////////////////////////////////////////////////////////////
83
+
84
+ // // End of OpenEXR license -------------------------------------------------
85
+
86
+ class EXRLoader extends DataTextureLoader {
87
+
88
+ constructor( manager ) {
89
+
90
+ super( manager );
91
+
92
+ this.type = HalfFloatType;
93
+
94
+ }
95
+
96
+ parse( buffer ) {
97
+
98
+ const USHORT_RANGE = ( 1 << 16 );
99
+ const BITMAP_SIZE = ( USHORT_RANGE >> 3 );
100
+
101
+ const HUF_ENCBITS = 16; // literal (value) bit length
102
+ const HUF_DECBITS = 14; // decoding bit size (>= 8)
103
+
104
+ const HUF_ENCSIZE = ( 1 << HUF_ENCBITS ) + 1; // encoding table size
105
+ const HUF_DECSIZE = 1 << HUF_DECBITS; // decoding table size
106
+ const HUF_DECMASK = HUF_DECSIZE - 1;
107
+
108
+ const NBITS = 16;
109
+ const A_OFFSET = 1 << ( NBITS - 1 );
110
+ const MOD_MASK = ( 1 << NBITS ) - 1;
111
+
112
+ const SHORT_ZEROCODE_RUN = 59;
113
+ const LONG_ZEROCODE_RUN = 63;
114
+ const SHORTEST_LONG_RUN = 2 + LONG_ZEROCODE_RUN - SHORT_ZEROCODE_RUN;
115
+
116
+ const ULONG_SIZE = 8;
117
+ const FLOAT32_SIZE = 4;
118
+ const INT32_SIZE = 4;
119
+ const INT16_SIZE = 2;
120
+ const INT8_SIZE = 1;
121
+
122
+ const STATIC_HUFFMAN = 0;
123
+ const DEFLATE = 1;
124
+
125
+ const UNKNOWN = 0;
126
+ const LOSSY_DCT = 1;
127
+ const RLE = 2;
128
+
129
+ const logBase = Math.pow( 2.7182818, 2.2 );
130
+
131
+ function reverseLutFromBitmap( bitmap, lut ) {
132
+
133
+ let k = 0;
134
+
135
+ for ( let i = 0; i < USHORT_RANGE; ++ i ) {
136
+
137
+ if ( ( i == 0 ) || ( bitmap[ i >> 3 ] & ( 1 << ( i & 7 ) ) ) ) {
138
+
139
+ lut[ k ++ ] = i;
140
+
141
+ }
142
+
143
+ }
144
+
145
+ const n = k - 1;
146
+
147
+ while ( k < USHORT_RANGE ) lut[ k ++ ] = 0;
148
+
149
+ return n;
150
+
151
+ }
152
+
153
+ function hufClearDecTable( hdec ) {
154
+
155
+ for ( let i = 0; i < HUF_DECSIZE; i ++ ) {
156
+
157
+ hdec[ i ] = {};
158
+ hdec[ i ].len = 0;
159
+ hdec[ i ].lit = 0;
160
+ hdec[ i ].p = null;
161
+
162
+ }
163
+
164
+ }
165
+
166
+ const getBitsReturn = { l: 0, c: 0, lc: 0 };
167
+
168
+ function getBits( nBits, c, lc, uInt8Array, inOffset ) {
169
+
170
+ while ( lc < nBits ) {
171
+
172
+ c = ( c << 8 ) | parseUint8Array( uInt8Array, inOffset );
173
+ lc += 8;
174
+
175
+ }
176
+
177
+ lc -= nBits;
178
+
179
+ getBitsReturn.l = ( c >> lc ) & ( ( 1 << nBits ) - 1 );
180
+ getBitsReturn.c = c;
181
+ getBitsReturn.lc = lc;
182
+
183
+ }
184
+
185
+ const hufTableBuffer = new Array( 59 );
186
+
187
+ function hufCanonicalCodeTable( hcode ) {
188
+
189
+ for ( let i = 0; i <= 58; ++ i ) hufTableBuffer[ i ] = 0;
190
+ for ( let i = 0; i < HUF_ENCSIZE; ++ i ) hufTableBuffer[ hcode[ i ] ] += 1;
191
+
192
+ let c = 0;
193
+
194
+ for ( let i = 58; i > 0; -- i ) {
195
+
196
+ const nc = ( ( c + hufTableBuffer[ i ] ) >> 1 );
197
+ hufTableBuffer[ i ] = c;
198
+ c = nc;
199
+
200
+ }
201
+
202
+ for ( let i = 0; i < HUF_ENCSIZE; ++ i ) {
203
+
204
+ const l = hcode[ i ];
205
+ if ( l > 0 ) hcode[ i ] = l | ( hufTableBuffer[ l ] ++ << 6 );
206
+
207
+ }
208
+
209
+ }
210
+
211
+ function hufUnpackEncTable( uInt8Array, inOffset, ni, im, iM, hcode ) {
212
+
213
+ const p = inOffset;
214
+ let c = 0;
215
+ let lc = 0;
216
+
217
+ for ( ; im <= iM; im ++ ) {
218
+
219
+ if ( p.value - inOffset.value > ni ) return false;
220
+
221
+ getBits( 6, c, lc, uInt8Array, p );
222
+
223
+ const l = getBitsReturn.l;
224
+ c = getBitsReturn.c;
225
+ lc = getBitsReturn.lc;
226
+
227
+ hcode[ im ] = l;
228
+
229
+ if ( l == LONG_ZEROCODE_RUN ) {
230
+
231
+ if ( p.value - inOffset.value > ni ) {
232
+
233
+ throw new Error( 'Something wrong with hufUnpackEncTable' );
234
+
235
+ }
236
+
237
+ getBits( 8, c, lc, uInt8Array, p );
238
+
239
+ let zerun = getBitsReturn.l + SHORTEST_LONG_RUN;
240
+ c = getBitsReturn.c;
241
+ lc = getBitsReturn.lc;
242
+
243
+ if ( im + zerun > iM + 1 ) {
244
+
245
+ throw new Error( 'Something wrong with hufUnpackEncTable' );
246
+
247
+ }
248
+
249
+ while ( zerun -- ) hcode[ im ++ ] = 0;
250
+
251
+ im --;
252
+
253
+ } else if ( l >= SHORT_ZEROCODE_RUN ) {
254
+
255
+ let zerun = l - SHORT_ZEROCODE_RUN + 2;
256
+
257
+ if ( im + zerun > iM + 1 ) {
258
+
259
+ throw new Error( 'Something wrong with hufUnpackEncTable' );
260
+
261
+ }
262
+
263
+ while ( zerun -- ) hcode[ im ++ ] = 0;
264
+
265
+ im --;
266
+
267
+ }
268
+
269
+ }
270
+
271
+ hufCanonicalCodeTable( hcode );
272
+
273
+ }
274
+
275
+ function hufLength( code ) {
276
+
277
+ return code & 63;
278
+
279
+ }
280
+
281
+ function hufCode( code ) {
282
+
283
+ return code >> 6;
284
+
285
+ }
286
+
287
+ function hufBuildDecTable( hcode, im, iM, hdecod ) {
288
+
289
+ for ( ; im <= iM; im ++ ) {
290
+
291
+ const c = hufCode( hcode[ im ] );
292
+ const l = hufLength( hcode[ im ] );
293
+
294
+ if ( c >> l ) {
295
+
296
+ throw new Error( 'Invalid table entry' );
297
+
298
+ }
299
+
300
+ if ( l > HUF_DECBITS ) {
301
+
302
+ const pl = hdecod[ ( c >> ( l - HUF_DECBITS ) ) ];
303
+
304
+ if ( pl.len ) {
305
+
306
+ throw new Error( 'Invalid table entry' );
307
+
308
+ }
309
+
310
+ pl.lit ++;
311
+
312
+ if ( pl.p ) {
313
+
314
+ const p = pl.p;
315
+ pl.p = new Array( pl.lit );
316
+
317
+ for ( let i = 0; i < pl.lit - 1; ++ i ) {
318
+
319
+ pl.p[ i ] = p[ i ];
320
+
321
+ }
322
+
323
+ } else {
324
+
325
+ pl.p = new Array( 1 );
326
+
327
+ }
328
+
329
+ pl.p[ pl.lit - 1 ] = im;
330
+
331
+ } else if ( l ) {
332
+
333
+ let plOffset = 0;
334
+
335
+ for ( let i = 1 << ( HUF_DECBITS - l ); i > 0; i -- ) {
336
+
337
+ const pl = hdecod[ ( c << ( HUF_DECBITS - l ) ) + plOffset ];
338
+
339
+ if ( pl.len || pl.p ) {
340
+
341
+ throw new Error( 'Invalid table entry' );
342
+
343
+ }
344
+
345
+ pl.len = l;
346
+ pl.lit = im;
347
+
348
+ plOffset ++;
349
+
350
+ }
351
+
352
+ }
353
+
354
+ }
355
+
356
+ return true;
357
+
358
+ }
359
+
360
+ const getCharReturn = { c: 0, lc: 0 };
361
+
362
+ function getChar( c, lc, uInt8Array, inOffset ) {
363
+
364
+ c = ( c << 8 ) | parseUint8Array( uInt8Array, inOffset );
365
+ lc += 8;
366
+
367
+ getCharReturn.c = c;
368
+ getCharReturn.lc = lc;
369
+
370
+ }
371
+
372
+ const getCodeReturn = { c: 0, lc: 0 };
373
+
374
+ function getCode( po, rlc, c, lc, uInt8Array, inOffset, outBuffer, outBufferOffset, outBufferEndOffset ) {
375
+
376
+ if ( po == rlc ) {
377
+
378
+ if ( lc < 8 ) {
379
+
380
+ getChar( c, lc, uInt8Array, inOffset );
381
+ c = getCharReturn.c;
382
+ lc = getCharReturn.lc;
383
+
384
+ }
385
+
386
+ lc -= 8;
387
+
388
+ let cs = ( c >> lc );
389
+ cs = new Uint8Array( [ cs ] )[ 0 ];
390
+
391
+ if ( outBufferOffset.value + cs > outBufferEndOffset ) {
392
+
393
+ return false;
394
+
395
+ }
396
+
397
+ const s = outBuffer[ outBufferOffset.value - 1 ];
398
+
399
+ while ( cs -- > 0 ) {
400
+
401
+ outBuffer[ outBufferOffset.value ++ ] = s;
402
+
403
+ }
404
+
405
+ } else if ( outBufferOffset.value < outBufferEndOffset ) {
406
+
407
+ outBuffer[ outBufferOffset.value ++ ] = po;
408
+
409
+ } else {
410
+
411
+ return false;
412
+
413
+ }
414
+
415
+ getCodeReturn.c = c;
416
+ getCodeReturn.lc = lc;
417
+
418
+ }
419
+
420
+ function UInt16( value ) {
421
+
422
+ return ( value & 0xFFFF );
423
+
424
+ }
425
+
426
+ function Int16( value ) {
427
+
428
+ const ref = UInt16( value );
429
+ return ( ref > 0x7FFF ) ? ref - 0x10000 : ref;
430
+
431
+ }
432
+
433
+ const wdec14Return = { a: 0, b: 0 };
434
+
435
+ function wdec14( l, h ) {
436
+
437
+ const ls = Int16( l );
438
+ const hs = Int16( h );
439
+
440
+ const hi = hs;
441
+ const ai = ls + ( hi & 1 ) + ( hi >> 1 );
442
+
443
+ const as = ai;
444
+ const bs = ai - hi;
445
+
446
+ wdec14Return.a = as;
447
+ wdec14Return.b = bs;
448
+
449
+ }
450
+
451
+ function wdec16( l, h ) {
452
+
453
+ const m = UInt16( l );
454
+ const d = UInt16( h );
455
+
456
+ const bb = ( m - ( d >> 1 ) ) & MOD_MASK;
457
+ const aa = ( d + bb - A_OFFSET ) & MOD_MASK;
458
+
459
+ wdec14Return.a = aa;
460
+ wdec14Return.b = bb;
461
+
462
+ }
463
+
464
+ function wav2Decode( buffer, j, nx, ox, ny, oy, mx ) {
465
+
466
+ const w14 = mx < ( 1 << 14 );
467
+ const n = ( nx > ny ) ? ny : nx;
468
+ let p = 1;
469
+ let p2;
470
+ let py;
471
+
472
+ while ( p <= n ) p <<= 1;
473
+
474
+ p >>= 1;
475
+ p2 = p;
476
+ p >>= 1;
477
+
478
+ while ( p >= 1 ) {
479
+
480
+ py = 0;
481
+ const ey = py + oy * ( ny - p2 );
482
+ const oy1 = oy * p;
483
+ const oy2 = oy * p2;
484
+ const ox1 = ox * p;
485
+ const ox2 = ox * p2;
486
+ let i00, i01, i10, i11;
487
+
488
+ for ( ; py <= ey; py += oy2 ) {
489
+
490
+ let px = py;
491
+ const ex = py + ox * ( nx - p2 );
492
+
493
+ for ( ; px <= ex; px += ox2 ) {
494
+
495
+ const p01 = px + ox1;
496
+ const p10 = px + oy1;
497
+ const p11 = p10 + ox1;
498
+
499
+ if ( w14 ) {
500
+
501
+ wdec14( buffer[ px + j ], buffer[ p10 + j ] );
502
+
503
+ i00 = wdec14Return.a;
504
+ i10 = wdec14Return.b;
505
+
506
+ wdec14( buffer[ p01 + j ], buffer[ p11 + j ] );
507
+
508
+ i01 = wdec14Return.a;
509
+ i11 = wdec14Return.b;
510
+
511
+ wdec14( i00, i01 );
512
+
513
+ buffer[ px + j ] = wdec14Return.a;
514
+ buffer[ p01 + j ] = wdec14Return.b;
515
+
516
+ wdec14( i10, i11 );
517
+
518
+ buffer[ p10 + j ] = wdec14Return.a;
519
+ buffer[ p11 + j ] = wdec14Return.b;
520
+
521
+ } else {
522
+
523
+ wdec16( buffer[ px + j ], buffer[ p10 + j ] );
524
+
525
+ i00 = wdec14Return.a;
526
+ i10 = wdec14Return.b;
527
+
528
+ wdec16( buffer[ p01 + j ], buffer[ p11 + j ] );
529
+
530
+ i01 = wdec14Return.a;
531
+ i11 = wdec14Return.b;
532
+
533
+ wdec16( i00, i01 );
534
+
535
+ buffer[ px + j ] = wdec14Return.a;
536
+ buffer[ p01 + j ] = wdec14Return.b;
537
+
538
+ wdec16( i10, i11 );
539
+
540
+ buffer[ p10 + j ] = wdec14Return.a;
541
+ buffer[ p11 + j ] = wdec14Return.b;
542
+
543
+
544
+ }
545
+
546
+ }
547
+
548
+ if ( nx & p ) {
549
+
550
+ const p10 = px + oy1;
551
+
552
+ if ( w14 )
553
+ wdec14( buffer[ px + j ], buffer[ p10 + j ] );
554
+ else
555
+ wdec16( buffer[ px + j ], buffer[ p10 + j ] );
556
+
557
+ i00 = wdec14Return.a;
558
+ buffer[ p10 + j ] = wdec14Return.b;
559
+
560
+ buffer[ px + j ] = i00;
561
+
562
+ }
563
+
564
+ }
565
+
566
+ if ( ny & p ) {
567
+
568
+ let px = py;
569
+ const ex = py + ox * ( nx - p2 );
570
+
571
+ for ( ; px <= ex; px += ox2 ) {
572
+
573
+ const p01 = px + ox1;
574
+
575
+ if ( w14 )
576
+ wdec14( buffer[ px + j ], buffer[ p01 + j ] );
577
+ else
578
+ wdec16( buffer[ px + j ], buffer[ p01 + j ] );
579
+
580
+ i00 = wdec14Return.a;
581
+ buffer[ p01 + j ] = wdec14Return.b;
582
+
583
+ buffer[ px + j ] = i00;
584
+
585
+ }
586
+
587
+ }
588
+
589
+ p2 = p;
590
+ p >>= 1;
591
+
592
+ }
593
+
594
+ return py;
595
+
596
+ }
597
+
598
+ function hufDecode( encodingTable, decodingTable, uInt8Array, inOffset, ni, rlc, no, outBuffer, outOffset ) {
599
+
600
+ let c = 0;
601
+ let lc = 0;
602
+ const outBufferEndOffset = no;
603
+ const inOffsetEnd = Math.trunc( inOffset.value + ( ni + 7 ) / 8 );
604
+
605
+ while ( inOffset.value < inOffsetEnd ) {
606
+
607
+ getChar( c, lc, uInt8Array, inOffset );
608
+
609
+ c = getCharReturn.c;
610
+ lc = getCharReturn.lc;
611
+
612
+ while ( lc >= HUF_DECBITS ) {
613
+
614
+ const index = ( c >> ( lc - HUF_DECBITS ) ) & HUF_DECMASK;
615
+ const pl = decodingTable[ index ];
616
+
617
+ if ( pl.len ) {
618
+
619
+ lc -= pl.len;
620
+
621
+ getCode( pl.lit, rlc, c, lc, uInt8Array, inOffset, outBuffer, outOffset, outBufferEndOffset );
622
+
623
+ c = getCodeReturn.c;
624
+ lc = getCodeReturn.lc;
625
+
626
+ } else {
627
+
628
+ if ( ! pl.p ) {
629
+
630
+ throw new Error( 'hufDecode issues' );
631
+
632
+ }
633
+
634
+ let j;
635
+
636
+ for ( j = 0; j < pl.lit; j ++ ) {
637
+
638
+ const l = hufLength( encodingTable[ pl.p[ j ] ] );
639
+
640
+ while ( lc < l && inOffset.value < inOffsetEnd ) {
641
+
642
+ getChar( c, lc, uInt8Array, inOffset );
643
+
644
+ c = getCharReturn.c;
645
+ lc = getCharReturn.lc;
646
+
647
+ }
648
+
649
+ if ( lc >= l ) {
650
+
651
+ if ( hufCode( encodingTable[ pl.p[ j ] ] ) == ( ( c >> ( lc - l ) ) & ( ( 1 << l ) - 1 ) ) ) {
652
+
653
+ lc -= l;
654
+
655
+ getCode( pl.p[ j ], rlc, c, lc, uInt8Array, inOffset, outBuffer, outOffset, outBufferEndOffset );
656
+
657
+ c = getCodeReturn.c;
658
+ lc = getCodeReturn.lc;
659
+
660
+ break;
661
+
662
+ }
663
+
664
+ }
665
+
666
+ }
667
+
668
+ if ( j == pl.lit ) {
669
+
670
+ throw new Error( 'hufDecode issues' );
671
+
672
+ }
673
+
674
+ }
675
+
676
+ }
677
+
678
+ }
679
+
680
+ const i = ( 8 - ni ) & 7;
681
+
682
+ c >>= i;
683
+ lc -= i;
684
+
685
+ while ( lc > 0 ) {
686
+
687
+ const pl = decodingTable[ ( c << ( HUF_DECBITS - lc ) ) & HUF_DECMASK ];
688
+
689
+ if ( pl.len ) {
690
+
691
+ lc -= pl.len;
692
+
693
+ getCode( pl.lit, rlc, c, lc, uInt8Array, inOffset, outBuffer, outOffset, outBufferEndOffset );
694
+
695
+ c = getCodeReturn.c;
696
+ lc = getCodeReturn.lc;
697
+
698
+ } else {
699
+
700
+ throw new Error( 'hufDecode issues' );
701
+
702
+ }
703
+
704
+ }
705
+
706
+ return true;
707
+
708
+ }
709
+
710
+ function hufUncompress( uInt8Array, inDataView, inOffset, nCompressed, outBuffer, nRaw ) {
711
+
712
+ const outOffset = { value: 0 };
713
+ const initialInOffset = inOffset.value;
714
+
715
+ const im = parseUint32( inDataView, inOffset );
716
+ const iM = parseUint32( inDataView, inOffset );
717
+
718
+ inOffset.value += 4;
719
+
720
+ const nBits = parseUint32( inDataView, inOffset );
721
+
722
+ inOffset.value += 4;
723
+
724
+ if ( im < 0 || im >= HUF_ENCSIZE || iM < 0 || iM >= HUF_ENCSIZE ) {
725
+
726
+ throw new Error( 'Something wrong with HUF_ENCSIZE' );
727
+
728
+ }
729
+
730
+ const freq = new Array( HUF_ENCSIZE );
731
+ const hdec = new Array( HUF_DECSIZE );
732
+
733
+ hufClearDecTable( hdec );
734
+
735
+ const ni = nCompressed - ( inOffset.value - initialInOffset );
736
+
737
+ hufUnpackEncTable( uInt8Array, inOffset, ni, im, iM, freq );
738
+
739
+ if ( nBits > 8 * ( nCompressed - ( inOffset.value - initialInOffset ) ) ) {
740
+
741
+ throw new Error( 'Something wrong with hufUncompress' );
742
+
743
+ }
744
+
745
+ hufBuildDecTable( freq, im, iM, hdec );
746
+
747
+ hufDecode( freq, hdec, uInt8Array, inOffset, nBits, iM, nRaw, outBuffer, outOffset );
748
+
749
+ }
750
+
751
+ function applyLut( lut, data, nData ) {
752
+
753
+ for ( let i = 0; i < nData; ++ i ) {
754
+
755
+ data[ i ] = lut[ data[ i ] ];
756
+
757
+ }
758
+
759
+ }
760
+
761
+ function predictor( source ) {
762
+
763
+ for ( let t = 1; t < source.length; t ++ ) {
764
+
765
+ const d = source[ t - 1 ] + source[ t ] - 128;
766
+ source[ t ] = d;
767
+
768
+ }
769
+
770
+ }
771
+
772
+ function interleaveScalar( source, out ) {
773
+
774
+ let t1 = 0;
775
+ let t2 = Math.floor( ( source.length + 1 ) / 2 );
776
+ let s = 0;
777
+ const stop = source.length - 1;
778
+
779
+ while ( true ) {
780
+
781
+ if ( s > stop ) break;
782
+ out[ s ++ ] = source[ t1 ++ ];
783
+
784
+ if ( s > stop ) break;
785
+ out[ s ++ ] = source[ t2 ++ ];
786
+
787
+ }
788
+
789
+ }
790
+
791
+ function decodeRunLength( source ) {
792
+
793
+ let size = source.byteLength;
794
+ const out = new Array();
795
+ let p = 0;
796
+
797
+ const reader = new DataView( source );
798
+
799
+ while ( size > 0 ) {
800
+
801
+ const l = reader.getInt8( p ++ );
802
+
803
+ if ( l < 0 ) {
804
+
805
+ const count = - l;
806
+ size -= count + 1;
807
+
808
+ for ( let i = 0; i < count; i ++ ) {
809
+
810
+ out.push( reader.getUint8( p ++ ) );
811
+
812
+ }
813
+
814
+
815
+ } else {
816
+
817
+ const count = l;
818
+ size -= 2;
819
+
820
+ const value = reader.getUint8( p ++ );
821
+
822
+ for ( let i = 0; i < count + 1; i ++ ) {
823
+
824
+ out.push( value );
825
+
826
+ }
827
+
828
+ }
829
+
830
+ }
831
+
832
+ return out;
833
+
834
+ }
835
+
836
+ function lossyDctDecode( cscSet, rowPtrs, channelData, acBuffer, dcBuffer, outBuffer ) {
837
+
838
+ let dataView = new DataView( outBuffer.buffer );
839
+
840
+ const width = channelData[ cscSet.idx[ 0 ] ].width;
841
+ const height = channelData[ cscSet.idx[ 0 ] ].height;
842
+
843
+ const numComp = 3;
844
+
845
+ const numFullBlocksX = Math.floor( width / 8.0 );
846
+ const numBlocksX = Math.ceil( width / 8.0 );
847
+ const numBlocksY = Math.ceil( height / 8.0 );
848
+ const leftoverX = width - ( numBlocksX - 1 ) * 8;
849
+ const leftoverY = height - ( numBlocksY - 1 ) * 8;
850
+
851
+ const currAcComp = { value: 0 };
852
+ const currDcComp = new Array( numComp );
853
+ const dctData = new Array( numComp );
854
+ const halfZigBlock = new Array( numComp );
855
+ const rowBlock = new Array( numComp );
856
+ const rowOffsets = new Array( numComp );
857
+
858
+ for ( let comp = 0; comp < numComp; ++ comp ) {
859
+
860
+ rowOffsets[ comp ] = rowPtrs[ cscSet.idx[ comp ] ];
861
+ currDcComp[ comp ] = ( comp < 1 ) ? 0 : currDcComp[ comp - 1 ] + numBlocksX * numBlocksY;
862
+ dctData[ comp ] = new Float32Array( 64 );
863
+ halfZigBlock[ comp ] = new Uint16Array( 64 );
864
+ rowBlock[ comp ] = new Uint16Array( numBlocksX * 64 );
865
+
866
+ }
867
+
868
+ for ( let blocky = 0; blocky < numBlocksY; ++ blocky ) {
869
+
870
+ let maxY = 8;
871
+
872
+ if ( blocky == numBlocksY - 1 )
873
+ maxY = leftoverY;
874
+
875
+ let maxX = 8;
876
+
877
+ for ( let blockx = 0; blockx < numBlocksX; ++ blockx ) {
878
+
879
+ if ( blockx == numBlocksX - 1 )
880
+ maxX = leftoverX;
881
+
882
+ for ( let comp = 0; comp < numComp; ++ comp ) {
883
+
884
+ halfZigBlock[ comp ].fill( 0 );
885
+
886
+ // set block DC component
887
+ halfZigBlock[ comp ][ 0 ] = dcBuffer[ currDcComp[ comp ] ++ ];
888
+ // set block AC components
889
+ unRleAC( currAcComp, acBuffer, halfZigBlock[ comp ] );
890
+
891
+ // UnZigZag block to float
892
+ unZigZag( halfZigBlock[ comp ], dctData[ comp ] );
893
+ // decode float dct
894
+ dctInverse( dctData[ comp ] );
895
+
896
+ }
897
+
898
+ if ( numComp == 3 ) {
899
+
900
+ csc709Inverse( dctData );
901
+
902
+ }
903
+
904
+ for ( let comp = 0; comp < numComp; ++ comp ) {
905
+
906
+ convertToHalf( dctData[ comp ], rowBlock[ comp ], blockx * 64 );
907
+
908
+ }
909
+
910
+ } // blockx
911
+
912
+ let offset = 0;
913
+
914
+ for ( let comp = 0; comp < numComp; ++ comp ) {
915
+
916
+ const type = channelData[ cscSet.idx[ comp ] ].type;
917
+
918
+ for ( let y = 8 * blocky; y < 8 * blocky + maxY; ++ y ) {
919
+
920
+ offset = rowOffsets[ comp ][ y ];
921
+
922
+ for ( let blockx = 0; blockx < numFullBlocksX; ++ blockx ) {
923
+
924
+ const src = blockx * 64 + ( ( y & 0x7 ) * 8 );
925
+
926
+ dataView.setUint16( offset + 0 * INT16_SIZE * type, rowBlock[ comp ][ src + 0 ], true );
927
+ dataView.setUint16( offset + 1 * INT16_SIZE * type, rowBlock[ comp ][ src + 1 ], true );
928
+ dataView.setUint16( offset + 2 * INT16_SIZE * type, rowBlock[ comp ][ src + 2 ], true );
929
+ dataView.setUint16( offset + 3 * INT16_SIZE * type, rowBlock[ comp ][ src + 3 ], true );
930
+
931
+ dataView.setUint16( offset + 4 * INT16_SIZE * type, rowBlock[ comp ][ src + 4 ], true );
932
+ dataView.setUint16( offset + 5 * INT16_SIZE * type, rowBlock[ comp ][ src + 5 ], true );
933
+ dataView.setUint16( offset + 6 * INT16_SIZE * type, rowBlock[ comp ][ src + 6 ], true );
934
+ dataView.setUint16( offset + 7 * INT16_SIZE * type, rowBlock[ comp ][ src + 7 ], true );
935
+
936
+ offset += 8 * INT16_SIZE * type;
937
+
938
+ }
939
+
940
+ }
941
+
942
+ // handle partial X blocks
943
+ if ( numFullBlocksX != numBlocksX ) {
944
+
945
+ for ( let y = 8 * blocky; y < 8 * blocky + maxY; ++ y ) {
946
+
947
+ const offset = rowOffsets[ comp ][ y ] + 8 * numFullBlocksX * INT16_SIZE * type;
948
+ const src = numFullBlocksX * 64 + ( ( y & 0x7 ) * 8 );
949
+
950
+ for ( let x = 0; x < maxX; ++ x ) {
951
+
952
+ dataView.setUint16( offset + x * INT16_SIZE * type, rowBlock[ comp ][ src + x ], true );
953
+
954
+ }
955
+
956
+ }
957
+
958
+ }
959
+
960
+ } // comp
961
+
962
+ } // blocky
963
+
964
+ const halfRow = new Uint16Array( width );
965
+ dataView = new DataView( outBuffer.buffer );
966
+
967
+ // convert channels back to float, if needed
968
+ for ( let comp = 0; comp < numComp; ++ comp ) {
969
+
970
+ channelData[ cscSet.idx[ comp ] ].decoded = true;
971
+ const type = channelData[ cscSet.idx[ comp ] ].type;
972
+
973
+ if ( channelData[ comp ].type != 2 ) continue;
974
+
975
+ for ( let y = 0; y < height; ++ y ) {
976
+
977
+ const offset = rowOffsets[ comp ][ y ];
978
+
979
+ for ( let x = 0; x < width; ++ x ) {
980
+
981
+ halfRow[ x ] = dataView.getUint16( offset + x * INT16_SIZE * type, true );
982
+
983
+ }
984
+
985
+ for ( let x = 0; x < width; ++ x ) {
986
+
987
+ dataView.setFloat32( offset + x * INT16_SIZE * type, decodeFloat16( halfRow[ x ] ), true );
988
+
989
+ }
990
+
991
+ }
992
+
993
+ }
994
+
995
+ }
996
+
997
+ function unRleAC( currAcComp, acBuffer, halfZigBlock ) {
998
+
999
+ let acValue;
1000
+ let dctComp = 1;
1001
+
1002
+ while ( dctComp < 64 ) {
1003
+
1004
+ acValue = acBuffer[ currAcComp.value ];
1005
+
1006
+ if ( acValue == 0xff00 ) {
1007
+
1008
+ dctComp = 64;
1009
+
1010
+ } else if ( acValue >> 8 == 0xff ) {
1011
+
1012
+ dctComp += acValue & 0xff;
1013
+
1014
+ } else {
1015
+
1016
+ halfZigBlock[ dctComp ] = acValue;
1017
+ dctComp ++;
1018
+
1019
+ }
1020
+
1021
+ currAcComp.value ++;
1022
+
1023
+ }
1024
+
1025
+ }
1026
+
1027
+ function unZigZag( src, dst ) {
1028
+
1029
+ dst[ 0 ] = decodeFloat16( src[ 0 ] );
1030
+ dst[ 1 ] = decodeFloat16( src[ 1 ] );
1031
+ dst[ 2 ] = decodeFloat16( src[ 5 ] );
1032
+ dst[ 3 ] = decodeFloat16( src[ 6 ] );
1033
+ dst[ 4 ] = decodeFloat16( src[ 14 ] );
1034
+ dst[ 5 ] = decodeFloat16( src[ 15 ] );
1035
+ dst[ 6 ] = decodeFloat16( src[ 27 ] );
1036
+ dst[ 7 ] = decodeFloat16( src[ 28 ] );
1037
+ dst[ 8 ] = decodeFloat16( src[ 2 ] );
1038
+ dst[ 9 ] = decodeFloat16( src[ 4 ] );
1039
+
1040
+ dst[ 10 ] = decodeFloat16( src[ 7 ] );
1041
+ dst[ 11 ] = decodeFloat16( src[ 13 ] );
1042
+ dst[ 12 ] = decodeFloat16( src[ 16 ] );
1043
+ dst[ 13 ] = decodeFloat16( src[ 26 ] );
1044
+ dst[ 14 ] = decodeFloat16( src[ 29 ] );
1045
+ dst[ 15 ] = decodeFloat16( src[ 42 ] );
1046
+ dst[ 16 ] = decodeFloat16( src[ 3 ] );
1047
+ dst[ 17 ] = decodeFloat16( src[ 8 ] );
1048
+ dst[ 18 ] = decodeFloat16( src[ 12 ] );
1049
+ dst[ 19 ] = decodeFloat16( src[ 17 ] );
1050
+
1051
+ dst[ 20 ] = decodeFloat16( src[ 25 ] );
1052
+ dst[ 21 ] = decodeFloat16( src[ 30 ] );
1053
+ dst[ 22 ] = decodeFloat16( src[ 41 ] );
1054
+ dst[ 23 ] = decodeFloat16( src[ 43 ] );
1055
+ dst[ 24 ] = decodeFloat16( src[ 9 ] );
1056
+ dst[ 25 ] = decodeFloat16( src[ 11 ] );
1057
+ dst[ 26 ] = decodeFloat16( src[ 18 ] );
1058
+ dst[ 27 ] = decodeFloat16( src[ 24 ] );
1059
+ dst[ 28 ] = decodeFloat16( src[ 31 ] );
1060
+ dst[ 29 ] = decodeFloat16( src[ 40 ] );
1061
+
1062
+ dst[ 30 ] = decodeFloat16( src[ 44 ] );
1063
+ dst[ 31 ] = decodeFloat16( src[ 53 ] );
1064
+ dst[ 32 ] = decodeFloat16( src[ 10 ] );
1065
+ dst[ 33 ] = decodeFloat16( src[ 19 ] );
1066
+ dst[ 34 ] = decodeFloat16( src[ 23 ] );
1067
+ dst[ 35 ] = decodeFloat16( src[ 32 ] );
1068
+ dst[ 36 ] = decodeFloat16( src[ 39 ] );
1069
+ dst[ 37 ] = decodeFloat16( src[ 45 ] );
1070
+ dst[ 38 ] = decodeFloat16( src[ 52 ] );
1071
+ dst[ 39 ] = decodeFloat16( src[ 54 ] );
1072
+
1073
+ dst[ 40 ] = decodeFloat16( src[ 20 ] );
1074
+ dst[ 41 ] = decodeFloat16( src[ 22 ] );
1075
+ dst[ 42 ] = decodeFloat16( src[ 33 ] );
1076
+ dst[ 43 ] = decodeFloat16( src[ 38 ] );
1077
+ dst[ 44 ] = decodeFloat16( src[ 46 ] );
1078
+ dst[ 45 ] = decodeFloat16( src[ 51 ] );
1079
+ dst[ 46 ] = decodeFloat16( src[ 55 ] );
1080
+ dst[ 47 ] = decodeFloat16( src[ 60 ] );
1081
+ dst[ 48 ] = decodeFloat16( src[ 21 ] );
1082
+ dst[ 49 ] = decodeFloat16( src[ 34 ] );
1083
+
1084
+ dst[ 50 ] = decodeFloat16( src[ 37 ] );
1085
+ dst[ 51 ] = decodeFloat16( src[ 47 ] );
1086
+ dst[ 52 ] = decodeFloat16( src[ 50 ] );
1087
+ dst[ 53 ] = decodeFloat16( src[ 56 ] );
1088
+ dst[ 54 ] = decodeFloat16( src[ 59 ] );
1089
+ dst[ 55 ] = decodeFloat16( src[ 61 ] );
1090
+ dst[ 56 ] = decodeFloat16( src[ 35 ] );
1091
+ dst[ 57 ] = decodeFloat16( src[ 36 ] );
1092
+ dst[ 58 ] = decodeFloat16( src[ 48 ] );
1093
+ dst[ 59 ] = decodeFloat16( src[ 49 ] );
1094
+
1095
+ dst[ 60 ] = decodeFloat16( src[ 57 ] );
1096
+ dst[ 61 ] = decodeFloat16( src[ 58 ] );
1097
+ dst[ 62 ] = decodeFloat16( src[ 62 ] );
1098
+ dst[ 63 ] = decodeFloat16( src[ 63 ] );
1099
+
1100
+ }
1101
+
1102
+ function dctInverse( data ) {
1103
+
1104
+ const a = 0.5 * Math.cos( 3.14159 / 4.0 );
1105
+ const b = 0.5 * Math.cos( 3.14159 / 16.0 );
1106
+ const c = 0.5 * Math.cos( 3.14159 / 8.0 );
1107
+ const d = 0.5 * Math.cos( 3.0 * 3.14159 / 16.0 );
1108
+ const e = 0.5 * Math.cos( 5.0 * 3.14159 / 16.0 );
1109
+ const f = 0.5 * Math.cos( 3.0 * 3.14159 / 8.0 );
1110
+ const g = 0.5 * Math.cos( 7.0 * 3.14159 / 16.0 );
1111
+
1112
+ const alpha = new Array( 4 );
1113
+ const beta = new Array( 4 );
1114
+ const theta = new Array( 4 );
1115
+ const gamma = new Array( 4 );
1116
+
1117
+ for ( let row = 0; row < 8; ++ row ) {
1118
+
1119
+ const rowPtr = row * 8;
1120
+
1121
+ alpha[ 0 ] = c * data[ rowPtr + 2 ];
1122
+ alpha[ 1 ] = f * data[ rowPtr + 2 ];
1123
+ alpha[ 2 ] = c * data[ rowPtr + 6 ];
1124
+ alpha[ 3 ] = f * data[ rowPtr + 6 ];
1125
+
1126
+ beta[ 0 ] = b * data[ rowPtr + 1 ] + d * data[ rowPtr + 3 ] + e * data[ rowPtr + 5 ] + g * data[ rowPtr + 7 ];
1127
+ beta[ 1 ] = d * data[ rowPtr + 1 ] - g * data[ rowPtr + 3 ] - b * data[ rowPtr + 5 ] - e * data[ rowPtr + 7 ];
1128
+ beta[ 2 ] = e * data[ rowPtr + 1 ] - b * data[ rowPtr + 3 ] + g * data[ rowPtr + 5 ] + d * data[ rowPtr + 7 ];
1129
+ beta[ 3 ] = g * data[ rowPtr + 1 ] - e * data[ rowPtr + 3 ] + d * data[ rowPtr + 5 ] - b * data[ rowPtr + 7 ];
1130
+
1131
+ theta[ 0 ] = a * ( data[ rowPtr + 0 ] + data[ rowPtr + 4 ] );
1132
+ theta[ 3 ] = a * ( data[ rowPtr + 0 ] - data[ rowPtr + 4 ] );
1133
+ theta[ 1 ] = alpha[ 0 ] + alpha[ 3 ];
1134
+ theta[ 2 ] = alpha[ 1 ] - alpha[ 2 ];
1135
+
1136
+ gamma[ 0 ] = theta[ 0 ] + theta[ 1 ];
1137
+ gamma[ 1 ] = theta[ 3 ] + theta[ 2 ];
1138
+ gamma[ 2 ] = theta[ 3 ] - theta[ 2 ];
1139
+ gamma[ 3 ] = theta[ 0 ] - theta[ 1 ];
1140
+
1141
+ data[ rowPtr + 0 ] = gamma[ 0 ] + beta[ 0 ];
1142
+ data[ rowPtr + 1 ] = gamma[ 1 ] + beta[ 1 ];
1143
+ data[ rowPtr + 2 ] = gamma[ 2 ] + beta[ 2 ];
1144
+ data[ rowPtr + 3 ] = gamma[ 3 ] + beta[ 3 ];
1145
+
1146
+ data[ rowPtr + 4 ] = gamma[ 3 ] - beta[ 3 ];
1147
+ data[ rowPtr + 5 ] = gamma[ 2 ] - beta[ 2 ];
1148
+ data[ rowPtr + 6 ] = gamma[ 1 ] - beta[ 1 ];
1149
+ data[ rowPtr + 7 ] = gamma[ 0 ] - beta[ 0 ];
1150
+
1151
+ }
1152
+
1153
+ for ( let column = 0; column < 8; ++ column ) {
1154
+
1155
+ alpha[ 0 ] = c * data[ 16 + column ];
1156
+ alpha[ 1 ] = f * data[ 16 + column ];
1157
+ alpha[ 2 ] = c * data[ 48 + column ];
1158
+ alpha[ 3 ] = f * data[ 48 + column ];
1159
+
1160
+ beta[ 0 ] = b * data[ 8 + column ] + d * data[ 24 + column ] + e * data[ 40 + column ] + g * data[ 56 + column ];
1161
+ beta[ 1 ] = d * data[ 8 + column ] - g * data[ 24 + column ] - b * data[ 40 + column ] - e * data[ 56 + column ];
1162
+ beta[ 2 ] = e * data[ 8 + column ] - b * data[ 24 + column ] + g * data[ 40 + column ] + d * data[ 56 + column ];
1163
+ beta[ 3 ] = g * data[ 8 + column ] - e * data[ 24 + column ] + d * data[ 40 + column ] - b * data[ 56 + column ];
1164
+
1165
+ theta[ 0 ] = a * ( data[ column ] + data[ 32 + column ] );
1166
+ theta[ 3 ] = a * ( data[ column ] - data[ 32 + column ] );
1167
+
1168
+ theta[ 1 ] = alpha[ 0 ] + alpha[ 3 ];
1169
+ theta[ 2 ] = alpha[ 1 ] - alpha[ 2 ];
1170
+
1171
+ gamma[ 0 ] = theta[ 0 ] + theta[ 1 ];
1172
+ gamma[ 1 ] = theta[ 3 ] + theta[ 2 ];
1173
+ gamma[ 2 ] = theta[ 3 ] - theta[ 2 ];
1174
+ gamma[ 3 ] = theta[ 0 ] - theta[ 1 ];
1175
+
1176
+ data[ 0 + column ] = gamma[ 0 ] + beta[ 0 ];
1177
+ data[ 8 + column ] = gamma[ 1 ] + beta[ 1 ];
1178
+ data[ 16 + column ] = gamma[ 2 ] + beta[ 2 ];
1179
+ data[ 24 + column ] = gamma[ 3 ] + beta[ 3 ];
1180
+
1181
+ data[ 32 + column ] = gamma[ 3 ] - beta[ 3 ];
1182
+ data[ 40 + column ] = gamma[ 2 ] - beta[ 2 ];
1183
+ data[ 48 + column ] = gamma[ 1 ] - beta[ 1 ];
1184
+ data[ 56 + column ] = gamma[ 0 ] - beta[ 0 ];
1185
+
1186
+ }
1187
+
1188
+ }
1189
+
1190
+ function csc709Inverse( data ) {
1191
+
1192
+ for ( let i = 0; i < 64; ++ i ) {
1193
+
1194
+ const y = data[ 0 ][ i ];
1195
+ const cb = data[ 1 ][ i ];
1196
+ const cr = data[ 2 ][ i ];
1197
+
1198
+ data[ 0 ][ i ] = y + 1.5747 * cr;
1199
+ data[ 1 ][ i ] = y - 0.1873 * cb - 0.4682 * cr;
1200
+ data[ 2 ][ i ] = y + 1.8556 * cb;
1201
+
1202
+ }
1203
+
1204
+ }
1205
+
1206
+ function convertToHalf( src, dst, idx ) {
1207
+
1208
+ for ( let i = 0; i < 64; ++ i ) {
1209
+
1210
+ dst[ idx + i ] = DataUtils.toHalfFloat( toLinear( src[ i ] ) );
1211
+
1212
+ }
1213
+
1214
+ }
1215
+
1216
+ function toLinear( float ) {
1217
+
1218
+ if ( float <= 1 ) {
1219
+
1220
+ return Math.sign( float ) * Math.pow( Math.abs( float ), 2.2 );
1221
+
1222
+ } else {
1223
+
1224
+ return Math.sign( float ) * Math.pow( logBase, Math.abs( float ) - 1.0 );
1225
+
1226
+ }
1227
+
1228
+ }
1229
+
1230
+ function uncompressRAW( info ) {
1231
+
1232
+ return new DataView( info.array.buffer, info.offset.value, info.size );
1233
+
1234
+ }
1235
+
1236
+ function uncompressRLE( info ) {
1237
+
1238
+ const compressed = info.viewer.buffer.slice( info.offset.value, info.offset.value + info.size );
1239
+
1240
+ const rawBuffer = new Uint8Array( decodeRunLength( compressed ) );
1241
+ const tmpBuffer = new Uint8Array( rawBuffer.length );
1242
+
1243
+ predictor( rawBuffer ); // revert predictor
1244
+
1245
+ interleaveScalar( rawBuffer, tmpBuffer ); // interleave pixels
1246
+
1247
+ return new DataView( tmpBuffer.buffer );
1248
+
1249
+ }
1250
+
1251
+ function uncompressZIP( info ) {
1252
+
1253
+ const compressed = info.array.slice( info.offset.value, info.offset.value + info.size );
1254
+
1255
+ if ( typeof fflate === 'undefined' ) {
1256
+
1257
+ console.error( 'THREE.EXRLoader: External library fflate.min.js required.' );
1258
+
1259
+ }
1260
+
1261
+ const rawBuffer = fflate.unzlibSync( compressed ); // eslint-disable-line no-undef
1262
+ const tmpBuffer = new Uint8Array( rawBuffer.length );
1263
+
1264
+ predictor( rawBuffer ); // revert predictor
1265
+
1266
+ interleaveScalar( rawBuffer, tmpBuffer ); // interleave pixels
1267
+
1268
+ return new DataView( tmpBuffer.buffer );
1269
+
1270
+ }
1271
+
1272
+ function uncompressPIZ( info ) {
1273
+
1274
+ const inDataView = info.viewer;
1275
+ const inOffset = { value: info.offset.value };
1276
+
1277
+ const outBuffer = new Uint16Array( info.width * info.scanlineBlockSize * ( info.channels * info.type ) );
1278
+ const bitmap = new Uint8Array( BITMAP_SIZE );
1279
+
1280
+ // Setup channel info
1281
+ let outBufferEnd = 0;
1282
+ const pizChannelData = new Array( info.channels );
1283
+ for ( let i = 0; i < info.channels; i ++ ) {
1284
+
1285
+ pizChannelData[ i ] = {};
1286
+ pizChannelData[ i ][ 'start' ] = outBufferEnd;
1287
+ pizChannelData[ i ][ 'end' ] = pizChannelData[ i ][ 'start' ];
1288
+ pizChannelData[ i ][ 'nx' ] = info.width;
1289
+ pizChannelData[ i ][ 'ny' ] = info.lines;
1290
+ pizChannelData[ i ][ 'size' ] = info.type;
1291
+
1292
+ outBufferEnd += pizChannelData[ i ].nx * pizChannelData[ i ].ny * pizChannelData[ i ].size;
1293
+
1294
+ }
1295
+
1296
+ // Read range compression data
1297
+
1298
+ const minNonZero = parseUint16( inDataView, inOffset );
1299
+ const maxNonZero = parseUint16( inDataView, inOffset );
1300
+
1301
+ if ( maxNonZero >= BITMAP_SIZE ) {
1302
+
1303
+ throw new Error( 'Something is wrong with PIZ_COMPRESSION BITMAP_SIZE' );
1304
+
1305
+ }
1306
+
1307
+ if ( minNonZero <= maxNonZero ) {
1308
+
1309
+ for ( let i = 0; i < maxNonZero - minNonZero + 1; i ++ ) {
1310
+
1311
+ bitmap[ i + minNonZero ] = parseUint8( inDataView, inOffset );
1312
+
1313
+ }
1314
+
1315
+ }
1316
+
1317
+ // Reverse LUT
1318
+ const lut = new Uint16Array( USHORT_RANGE );
1319
+ const maxValue = reverseLutFromBitmap( bitmap, lut );
1320
+
1321
+ const length = parseUint32( inDataView, inOffset );
1322
+
1323
+ // Huffman decoding
1324
+ hufUncompress( info.array, inDataView, inOffset, length, outBuffer, outBufferEnd );
1325
+
1326
+ // Wavelet decoding
1327
+ for ( let i = 0; i < info.channels; ++ i ) {
1328
+
1329
+ const cd = pizChannelData[ i ];
1330
+
1331
+ for ( let j = 0; j < pizChannelData[ i ].size; ++ j ) {
1332
+
1333
+ wav2Decode(
1334
+ outBuffer,
1335
+ cd.start + j,
1336
+ cd.nx,
1337
+ cd.size,
1338
+ cd.ny,
1339
+ cd.nx * cd.size,
1340
+ maxValue
1341
+ );
1342
+
1343
+ }
1344
+
1345
+ }
1346
+
1347
+ // Expand the pixel data to their original range
1348
+ applyLut( lut, outBuffer, outBufferEnd );
1349
+
1350
+ // Rearrange the pixel data into the format expected by the caller.
1351
+ let tmpOffset = 0;
1352
+ const tmpBuffer = new Uint8Array( outBuffer.buffer.byteLength );
1353
+ for ( let y = 0; y < info.lines; y ++ ) {
1354
+
1355
+ for ( let c = 0; c < info.channels; c ++ ) {
1356
+
1357
+ const cd = pizChannelData[ c ];
1358
+
1359
+ const n = cd.nx * cd.size;
1360
+ const cp = new Uint8Array( outBuffer.buffer, cd.end * INT16_SIZE, n * INT16_SIZE );
1361
+
1362
+ tmpBuffer.set( cp, tmpOffset );
1363
+ tmpOffset += n * INT16_SIZE;
1364
+ cd.end += n;
1365
+
1366
+ }
1367
+
1368
+ }
1369
+
1370
+ return new DataView( tmpBuffer.buffer );
1371
+
1372
+ }
1373
+
1374
+ function uncompressPXR( info ) {
1375
+
1376
+ const compressed = info.array.slice( info.offset.value, info.offset.value + info.size );
1377
+
1378
+ if ( typeof fflate === 'undefined' ) {
1379
+
1380
+ console.error( 'THREE.EXRLoader: External library fflate.min.js required.' );
1381
+
1382
+ }
1383
+
1384
+ const rawBuffer = fflate.unzlibSync( compressed ); // eslint-disable-line no-undef
1385
+
1386
+ const sz = info.lines * info.channels * info.width;
1387
+ const tmpBuffer = ( info.type == 1 ) ? new Uint16Array( sz ) : new Uint32Array( sz );
1388
+
1389
+ let tmpBufferEnd = 0;
1390
+ let writePtr = 0;
1391
+ const ptr = new Array( 4 );
1392
+
1393
+ for ( let y = 0; y < info.lines; y ++ ) {
1394
+
1395
+ for ( let c = 0; c < info.channels; c ++ ) {
1396
+
1397
+ let pixel = 0;
1398
+
1399
+ switch ( info.type ) {
1400
+
1401
+ case 1:
1402
+
1403
+ ptr[ 0 ] = tmpBufferEnd;
1404
+ ptr[ 1 ] = ptr[ 0 ] + info.width;
1405
+ tmpBufferEnd = ptr[ 1 ] + info.width;
1406
+
1407
+ for ( let j = 0; j < info.width; ++ j ) {
1408
+
1409
+ const diff = ( rawBuffer[ ptr[ 0 ] ++ ] << 8 ) | rawBuffer[ ptr[ 1 ] ++ ];
1410
+
1411
+ pixel += diff;
1412
+
1413
+ tmpBuffer[ writePtr ] = pixel;
1414
+ writePtr ++;
1415
+
1416
+ }
1417
+
1418
+ break;
1419
+
1420
+ case 2:
1421
+
1422
+ ptr[ 0 ] = tmpBufferEnd;
1423
+ ptr[ 1 ] = ptr[ 0 ] + info.width;
1424
+ ptr[ 2 ] = ptr[ 1 ] + info.width;
1425
+ tmpBufferEnd = ptr[ 2 ] + info.width;
1426
+
1427
+ for ( let j = 0; j < info.width; ++ j ) {
1428
+
1429
+ const diff = ( rawBuffer[ ptr[ 0 ] ++ ] << 24 ) | ( rawBuffer[ ptr[ 1 ] ++ ] << 16 ) | ( rawBuffer[ ptr[ 2 ] ++ ] << 8 );
1430
+
1431
+ pixel += diff;
1432
+
1433
+ tmpBuffer[ writePtr ] = pixel;
1434
+ writePtr ++;
1435
+
1436
+ }
1437
+
1438
+ break;
1439
+
1440
+ }
1441
+
1442
+ }
1443
+
1444
+ }
1445
+
1446
+ return new DataView( tmpBuffer.buffer );
1447
+
1448
+ }
1449
+
1450
+ function uncompressDWA( info ) {
1451
+
1452
+ const inDataView = info.viewer;
1453
+ const inOffset = { value: info.offset.value };
1454
+ const outBuffer = new Uint8Array( info.width * info.lines * ( info.channels * info.type * INT16_SIZE ) );
1455
+
1456
+ // Read compression header information
1457
+ const dwaHeader = {
1458
+
1459
+ version: parseInt64( inDataView, inOffset ),
1460
+ unknownUncompressedSize: parseInt64( inDataView, inOffset ),
1461
+ unknownCompressedSize: parseInt64( inDataView, inOffset ),
1462
+ acCompressedSize: parseInt64( inDataView, inOffset ),
1463
+ dcCompressedSize: parseInt64( inDataView, inOffset ),
1464
+ rleCompressedSize: parseInt64( inDataView, inOffset ),
1465
+ rleUncompressedSize: parseInt64( inDataView, inOffset ),
1466
+ rleRawSize: parseInt64( inDataView, inOffset ),
1467
+ totalAcUncompressedCount: parseInt64( inDataView, inOffset ),
1468
+ totalDcUncompressedCount: parseInt64( inDataView, inOffset ),
1469
+ acCompression: parseInt64( inDataView, inOffset )
1470
+
1471
+ };
1472
+
1473
+ if ( dwaHeader.version < 2 )
1474
+ throw new Error( 'EXRLoader.parse: ' + EXRHeader.compression + ' version ' + dwaHeader.version + ' is unsupported' );
1475
+
1476
+ // Read channel ruleset information
1477
+ const channelRules = new Array();
1478
+ let ruleSize = parseUint16( inDataView, inOffset ) - INT16_SIZE;
1479
+
1480
+ while ( ruleSize > 0 ) {
1481
+
1482
+ const name = parseNullTerminatedString( inDataView.buffer, inOffset );
1483
+ const value = parseUint8( inDataView, inOffset );
1484
+ const compression = ( value >> 2 ) & 3;
1485
+ const csc = ( value >> 4 ) - 1;
1486
+ const index = new Int8Array( [ csc ] )[ 0 ];
1487
+ const type = parseUint8( inDataView, inOffset );
1488
+
1489
+ channelRules.push( {
1490
+ name: name,
1491
+ index: index,
1492
+ type: type,
1493
+ compression: compression,
1494
+ } );
1495
+
1496
+ ruleSize -= name.length + 3;
1497
+
1498
+ }
1499
+
1500
+ // Classify channels
1501
+ const channels = EXRHeader.channels;
1502
+ const channelData = new Array( info.channels );
1503
+
1504
+ for ( let i = 0; i < info.channels; ++ i ) {
1505
+
1506
+ const cd = channelData[ i ] = {};
1507
+ const channel = channels[ i ];
1508
+
1509
+ cd.name = channel.name;
1510
+ cd.compression = UNKNOWN;
1511
+ cd.decoded = false;
1512
+ cd.type = channel.pixelType;
1513
+ cd.pLinear = channel.pLinear;
1514
+ cd.width = info.width;
1515
+ cd.height = info.lines;
1516
+
1517
+ }
1518
+
1519
+ const cscSet = {
1520
+ idx: new Array( 3 )
1521
+ };
1522
+
1523
+ for ( let offset = 0; offset < info.channels; ++ offset ) {
1524
+
1525
+ const cd = channelData[ offset ];
1526
+
1527
+ for ( let i = 0; i < channelRules.length; ++ i ) {
1528
+
1529
+ const rule = channelRules[ i ];
1530
+
1531
+ if ( cd.name == rule.name ) {
1532
+
1533
+ cd.compression = rule.compression;
1534
+
1535
+ if ( rule.index >= 0 ) {
1536
+
1537
+ cscSet.idx[ rule.index ] = offset;
1538
+
1539
+ }
1540
+
1541
+ cd.offset = offset;
1542
+
1543
+ }
1544
+
1545
+ }
1546
+
1547
+ }
1548
+
1549
+ let acBuffer, dcBuffer, rleBuffer;
1550
+
1551
+ // Read DCT - AC component data
1552
+ if ( dwaHeader.acCompressedSize > 0 ) {
1553
+
1554
+ switch ( dwaHeader.acCompression ) {
1555
+
1556
+ case STATIC_HUFFMAN:
1557
+
1558
+ acBuffer = new Uint16Array( dwaHeader.totalAcUncompressedCount );
1559
+ hufUncompress( info.array, inDataView, inOffset, dwaHeader.acCompressedSize, acBuffer, dwaHeader.totalAcUncompressedCount );
1560
+ break;
1561
+
1562
+ case DEFLATE:
1563
+
1564
+ const compressed = info.array.slice( inOffset.value, inOffset.value + dwaHeader.totalAcUncompressedCount );
1565
+ const data = fflate.unzlibSync( compressed ); // eslint-disable-line no-undef
1566
+ acBuffer = new Uint16Array( data.buffer );
1567
+ inOffset.value += dwaHeader.totalAcUncompressedCount;
1568
+ break;
1569
+
1570
+ }
1571
+
1572
+
1573
+ }
1574
+
1575
+ // Read DCT - DC component data
1576
+ if ( dwaHeader.dcCompressedSize > 0 ) {
1577
+
1578
+ const zlibInfo = {
1579
+ array: info.array,
1580
+ offset: inOffset,
1581
+ size: dwaHeader.dcCompressedSize
1582
+ };
1583
+ dcBuffer = new Uint16Array( uncompressZIP( zlibInfo ).buffer );
1584
+ inOffset.value += dwaHeader.dcCompressedSize;
1585
+
1586
+ }
1587
+
1588
+ // Read RLE compressed data
1589
+ if ( dwaHeader.rleRawSize > 0 ) {
1590
+
1591
+ const compressed = info.array.slice( inOffset.value, inOffset.value + dwaHeader.rleCompressedSize );
1592
+ const data = fflate.unzlibSync( compressed ); // eslint-disable-line no-undef
1593
+ rleBuffer = decodeRunLength( data.buffer );
1594
+
1595
+ inOffset.value += dwaHeader.rleCompressedSize;
1596
+
1597
+ }
1598
+
1599
+ // Prepare outbuffer data offset
1600
+ let outBufferEnd = 0;
1601
+ const rowOffsets = new Array( channelData.length );
1602
+ for ( let i = 0; i < rowOffsets.length; ++ i ) {
1603
+
1604
+ rowOffsets[ i ] = new Array();
1605
+
1606
+ }
1607
+
1608
+ for ( let y = 0; y < info.lines; ++ y ) {
1609
+
1610
+ for ( let chan = 0; chan < channelData.length; ++ chan ) {
1611
+
1612
+ rowOffsets[ chan ].push( outBufferEnd );
1613
+ outBufferEnd += channelData[ chan ].width * info.type * INT16_SIZE;
1614
+
1615
+ }
1616
+
1617
+ }
1618
+
1619
+ // Lossy DCT decode RGB channels
1620
+ lossyDctDecode( cscSet, rowOffsets, channelData, acBuffer, dcBuffer, outBuffer );
1621
+
1622
+ // Decode other channels
1623
+ for ( let i = 0; i < channelData.length; ++ i ) {
1624
+
1625
+ const cd = channelData[ i ];
1626
+
1627
+ if ( cd.decoded ) continue;
1628
+
1629
+ switch ( cd.compression ) {
1630
+
1631
+ case RLE:
1632
+
1633
+ let row = 0;
1634
+ let rleOffset = 0;
1635
+
1636
+ for ( let y = 0; y < info.lines; ++ y ) {
1637
+
1638
+ let rowOffsetBytes = rowOffsets[ i ][ row ];
1639
+
1640
+ for ( let x = 0; x < cd.width; ++ x ) {
1641
+
1642
+ for ( let byte = 0; byte < INT16_SIZE * cd.type; ++ byte ) {
1643
+
1644
+ outBuffer[ rowOffsetBytes ++ ] = rleBuffer[ rleOffset + byte * cd.width * cd.height ];
1645
+
1646
+ }
1647
+
1648
+ rleOffset ++;
1649
+
1650
+ }
1651
+
1652
+ row ++;
1653
+
1654
+ }
1655
+
1656
+ break;
1657
+
1658
+ case LOSSY_DCT: // skip
1659
+
1660
+ default:
1661
+ throw new Error( 'EXRLoader.parse: unsupported channel compression' );
1662
+
1663
+ }
1664
+
1665
+ }
1666
+
1667
+ return new DataView( outBuffer.buffer );
1668
+
1669
+ }
1670
+
1671
+ function parseNullTerminatedString( buffer, offset ) {
1672
+
1673
+ const uintBuffer = new Uint8Array( buffer );
1674
+ let endOffset = 0;
1675
+
1676
+ while ( uintBuffer[ offset.value + endOffset ] != 0 ) {
1677
+
1678
+ endOffset += 1;
1679
+
1680
+ }
1681
+
1682
+ const stringValue = new TextDecoder().decode(
1683
+ uintBuffer.slice( offset.value, offset.value + endOffset )
1684
+ );
1685
+
1686
+ offset.value = offset.value + endOffset + 1;
1687
+
1688
+ return stringValue;
1689
+
1690
+ }
1691
+
1692
+ function parseFixedLengthString( buffer, offset, size ) {
1693
+
1694
+ const stringValue = new TextDecoder().decode(
1695
+ new Uint8Array( buffer ).slice( offset.value, offset.value + size )
1696
+ );
1697
+
1698
+ offset.value = offset.value + size;
1699
+
1700
+ return stringValue;
1701
+
1702
+ }
1703
+
1704
+ function parseRational( dataView, offset ) {
1705
+
1706
+ const x = parseInt32( dataView, offset );
1707
+ const y = parseUint32( dataView, offset );
1708
+
1709
+ return [ x, y ];
1710
+
1711
+ }
1712
+
1713
+ function parseTimecode( dataView, offset ) {
1714
+
1715
+ const x = parseUint32( dataView, offset );
1716
+ const y = parseUint32( dataView, offset );
1717
+
1718
+ return [ x, y ];
1719
+
1720
+ }
1721
+
1722
+ function parseInt32( dataView, offset ) {
1723
+
1724
+ const Int32 = dataView.getInt32( offset.value, true );
1725
+
1726
+ offset.value = offset.value + INT32_SIZE;
1727
+
1728
+ return Int32;
1729
+
1730
+ }
1731
+
1732
+ function parseUint32( dataView, offset ) {
1733
+
1734
+ const Uint32 = dataView.getUint32( offset.value, true );
1735
+
1736
+ offset.value = offset.value + INT32_SIZE;
1737
+
1738
+ return Uint32;
1739
+
1740
+ }
1741
+
1742
+ function parseUint8Array( uInt8Array, offset ) {
1743
+
1744
+ const Uint8 = uInt8Array[ offset.value ];
1745
+
1746
+ offset.value = offset.value + INT8_SIZE;
1747
+
1748
+ return Uint8;
1749
+
1750
+ }
1751
+
1752
+ function parseUint8( dataView, offset ) {
1753
+
1754
+ const Uint8 = dataView.getUint8( offset.value );
1755
+
1756
+ offset.value = offset.value + INT8_SIZE;
1757
+
1758
+ return Uint8;
1759
+
1760
+ }
1761
+
1762
+ const parseInt64 = function ( dataView, offset ) {
1763
+
1764
+ const Int64 = Number( dataView.getBigInt64( offset.value, true ) );
1765
+
1766
+ offset.value += ULONG_SIZE;
1767
+
1768
+ return Int64;
1769
+
1770
+ };
1771
+
1772
+ function parseFloat32( dataView, offset ) {
1773
+
1774
+ const float = dataView.getFloat32( offset.value, true );
1775
+
1776
+ offset.value += FLOAT32_SIZE;
1777
+
1778
+ return float;
1779
+
1780
+ }
1781
+
1782
+ function decodeFloat32( dataView, offset ) {
1783
+
1784
+ return DataUtils.toHalfFloat( parseFloat32( dataView, offset ) );
1785
+
1786
+ }
1787
+
1788
+ // https://stackoverflow.com/questions/5678432/decompressing-half-precision-floats-in-javascript
1789
+ function decodeFloat16( binary ) {
1790
+
1791
+ const exponent = ( binary & 0x7C00 ) >> 10,
1792
+ fraction = binary & 0x03FF;
1793
+
1794
+ return ( binary >> 15 ? - 1 : 1 ) * (
1795
+ exponent ?
1796
+ (
1797
+ exponent === 0x1F ?
1798
+ fraction ? NaN : Infinity :
1799
+ Math.pow( 2, exponent - 15 ) * ( 1 + fraction / 0x400 )
1800
+ ) :
1801
+ 6.103515625e-5 * ( fraction / 0x400 )
1802
+ );
1803
+
1804
+ }
1805
+
1806
+ function parseUint16( dataView, offset ) {
1807
+
1808
+ const Uint16 = dataView.getUint16( offset.value, true );
1809
+
1810
+ offset.value += INT16_SIZE;
1811
+
1812
+ return Uint16;
1813
+
1814
+ }
1815
+
1816
+ function parseFloat16( buffer, offset ) {
1817
+
1818
+ return decodeFloat16( parseUint16( buffer, offset ) );
1819
+
1820
+ }
1821
+
1822
+ function parseChlist( dataView, buffer, offset, size ) {
1823
+
1824
+ const startOffset = offset.value;
1825
+ const channels = [];
1826
+
1827
+ while ( offset.value < ( startOffset + size - 1 ) ) {
1828
+
1829
+ const name = parseNullTerminatedString( buffer, offset );
1830
+ const pixelType = parseInt32( dataView, offset );
1831
+ const pLinear = parseUint8( dataView, offset );
1832
+ offset.value += 3; // reserved, three chars
1833
+ const xSampling = parseInt32( dataView, offset );
1834
+ const ySampling = parseInt32( dataView, offset );
1835
+
1836
+ channels.push( {
1837
+ name: name,
1838
+ pixelType: pixelType,
1839
+ pLinear: pLinear,
1840
+ xSampling: xSampling,
1841
+ ySampling: ySampling
1842
+ } );
1843
+
1844
+ }
1845
+
1846
+ offset.value += 1;
1847
+
1848
+ return channels;
1849
+
1850
+ }
1851
+
1852
+ function parseChromaticities( dataView, offset ) {
1853
+
1854
+ const redX = parseFloat32( dataView, offset );
1855
+ const redY = parseFloat32( dataView, offset );
1856
+ const greenX = parseFloat32( dataView, offset );
1857
+ const greenY = parseFloat32( dataView, offset );
1858
+ const blueX = parseFloat32( dataView, offset );
1859
+ const blueY = parseFloat32( dataView, offset );
1860
+ const whiteX = parseFloat32( dataView, offset );
1861
+ const whiteY = parseFloat32( dataView, offset );
1862
+
1863
+ return { redX: redX, redY: redY, greenX: greenX, greenY: greenY, blueX: blueX, blueY: blueY, whiteX: whiteX, whiteY: whiteY };
1864
+
1865
+ }
1866
+
1867
+ function parseCompression( dataView, offset ) {
1868
+
1869
+ const compressionCodes = [
1870
+ 'NO_COMPRESSION',
1871
+ 'RLE_COMPRESSION',
1872
+ 'ZIPS_COMPRESSION',
1873
+ 'ZIP_COMPRESSION',
1874
+ 'PIZ_COMPRESSION',
1875
+ 'PXR24_COMPRESSION',
1876
+ 'B44_COMPRESSION',
1877
+ 'B44A_COMPRESSION',
1878
+ 'DWAA_COMPRESSION',
1879
+ 'DWAB_COMPRESSION'
1880
+ ];
1881
+
1882
+ const compression = parseUint8( dataView, offset );
1883
+
1884
+ return compressionCodes[ compression ];
1885
+
1886
+ }
1887
+
1888
+ function parseBox2i( dataView, offset ) {
1889
+
1890
+ const xMin = parseUint32( dataView, offset );
1891
+ const yMin = parseUint32( dataView, offset );
1892
+ const xMax = parseUint32( dataView, offset );
1893
+ const yMax = parseUint32( dataView, offset );
1894
+
1895
+ return { xMin: xMin, yMin: yMin, xMax: xMax, yMax: yMax };
1896
+
1897
+ }
1898
+
1899
+ function parseLineOrder( dataView, offset ) {
1900
+
1901
+ const lineOrders = [
1902
+ 'INCREASING_Y'
1903
+ ];
1904
+
1905
+ const lineOrder = parseUint8( dataView, offset );
1906
+
1907
+ return lineOrders[ lineOrder ];
1908
+
1909
+ }
1910
+
1911
+ function parseV2f( dataView, offset ) {
1912
+
1913
+ const x = parseFloat32( dataView, offset );
1914
+ const y = parseFloat32( dataView, offset );
1915
+
1916
+ return [ x, y ];
1917
+
1918
+ }
1919
+
1920
+ function parseV3f( dataView, offset ) {
1921
+
1922
+ const x = parseFloat32( dataView, offset );
1923
+ const y = parseFloat32( dataView, offset );
1924
+ const z = parseFloat32( dataView, offset );
1925
+
1926
+ return [ x, y, z ];
1927
+
1928
+ }
1929
+
1930
+ function parseValue( dataView, buffer, offset, type, size ) {
1931
+
1932
+ if ( type === 'string' || type === 'stringvector' || type === 'iccProfile' ) {
1933
+
1934
+ return parseFixedLengthString( buffer, offset, size );
1935
+
1936
+ } else if ( type === 'chlist' ) {
1937
+
1938
+ return parseChlist( dataView, buffer, offset, size );
1939
+
1940
+ } else if ( type === 'chromaticities' ) {
1941
+
1942
+ return parseChromaticities( dataView, offset );
1943
+
1944
+ } else if ( type === 'compression' ) {
1945
+
1946
+ return parseCompression( dataView, offset );
1947
+
1948
+ } else if ( type === 'box2i' ) {
1949
+
1950
+ return parseBox2i( dataView, offset );
1951
+
1952
+ } else if ( type === 'lineOrder' ) {
1953
+
1954
+ return parseLineOrder( dataView, offset );
1955
+
1956
+ } else if ( type === 'float' ) {
1957
+
1958
+ return parseFloat32( dataView, offset );
1959
+
1960
+ } else if ( type === 'v2f' ) {
1961
+
1962
+ return parseV2f( dataView, offset );
1963
+
1964
+ } else if ( type === 'v3f' ) {
1965
+
1966
+ return parseV3f( dataView, offset );
1967
+
1968
+ } else if ( type === 'int' ) {
1969
+
1970
+ return parseInt32( dataView, offset );
1971
+
1972
+ } else if ( type === 'rational' ) {
1973
+
1974
+ return parseRational( dataView, offset );
1975
+
1976
+ } else if ( type === 'timecode' ) {
1977
+
1978
+ return parseTimecode( dataView, offset );
1979
+
1980
+ } else if ( type === 'preview' ) {
1981
+
1982
+ offset.value += size;
1983
+ return 'skipped';
1984
+
1985
+ } else {
1986
+
1987
+ offset.value += size;
1988
+ return undefined;
1989
+
1990
+ }
1991
+
1992
+ }
1993
+
1994
+ function parseHeader( dataView, buffer, offset ) {
1995
+
1996
+ const EXRHeader = {};
1997
+
1998
+ if ( dataView.getUint32( 0, true ) != 20000630 ) { // magic
1999
+
2000
+ throw new Error( 'THREE.EXRLoader: provided file doesn\'t appear to be in OpenEXR format.' );
2001
+
2002
+ }
2003
+
2004
+ EXRHeader.version = dataView.getUint8( 4 );
2005
+
2006
+ const spec = dataView.getUint8( 5 ); // fullMask
2007
+
2008
+ EXRHeader.spec = {
2009
+ singleTile: !! ( spec & 2 ),
2010
+ longName: !! ( spec & 4 ),
2011
+ deepFormat: !! ( spec & 8 ),
2012
+ multiPart: !! ( spec & 16 ),
2013
+ };
2014
+
2015
+ // start of header
2016
+
2017
+ offset.value = 8; // start at 8 - after pre-amble
2018
+
2019
+ let keepReading = true;
2020
+
2021
+ while ( keepReading ) {
2022
+
2023
+ const attributeName = parseNullTerminatedString( buffer, offset );
2024
+
2025
+ if ( attributeName == 0 ) {
2026
+
2027
+ keepReading = false;
2028
+
2029
+ } else {
2030
+
2031
+ const attributeType = parseNullTerminatedString( buffer, offset );
2032
+ const attributeSize = parseUint32( dataView, offset );
2033
+ const attributeValue = parseValue( dataView, buffer, offset, attributeType, attributeSize );
2034
+
2035
+ if ( attributeValue === undefined ) {
2036
+
2037
+ console.warn( `EXRLoader.parse: skipped unknown header attribute type \'${attributeType}\'.` );
2038
+
2039
+ } else {
2040
+
2041
+ EXRHeader[ attributeName ] = attributeValue;
2042
+
2043
+ }
2044
+
2045
+ }
2046
+
2047
+ }
2048
+
2049
+ if ( ( spec & ~ 0x04 ) != 0 ) { // unsupported tiled, deep-image, multi-part
2050
+
2051
+ console.error( 'EXRHeader:', EXRHeader );
2052
+ throw new Error( 'THREE.EXRLoader: provided file is currently unsupported.' );
2053
+
2054
+ }
2055
+
2056
+ return EXRHeader;
2057
+
2058
+ }
2059
+
2060
+ function setupDecoder( EXRHeader, dataView, uInt8Array, offset, outputType ) {
2061
+
2062
+ const EXRDecoder = {
2063
+ size: 0,
2064
+ viewer: dataView,
2065
+ array: uInt8Array,
2066
+ offset: offset,
2067
+ width: EXRHeader.dataWindow.xMax - EXRHeader.dataWindow.xMin + 1,
2068
+ height: EXRHeader.dataWindow.yMax - EXRHeader.dataWindow.yMin + 1,
2069
+ channels: EXRHeader.channels.length,
2070
+ bytesPerLine: null,
2071
+ lines: null,
2072
+ inputSize: null,
2073
+ type: EXRHeader.channels[ 0 ].pixelType,
2074
+ uncompress: null,
2075
+ getter: null,
2076
+ format: null,
2077
+ encoding: null,
2078
+ };
2079
+
2080
+ switch ( EXRHeader.compression ) {
2081
+
2082
+ case 'NO_COMPRESSION':
2083
+ EXRDecoder.lines = 1;
2084
+ EXRDecoder.uncompress = uncompressRAW;
2085
+ break;
2086
+
2087
+ case 'RLE_COMPRESSION':
2088
+ EXRDecoder.lines = 1;
2089
+ EXRDecoder.uncompress = uncompressRLE;
2090
+ break;
2091
+
2092
+ case 'ZIPS_COMPRESSION':
2093
+ EXRDecoder.lines = 1;
2094
+ EXRDecoder.uncompress = uncompressZIP;
2095
+ break;
2096
+
2097
+ case 'ZIP_COMPRESSION':
2098
+ EXRDecoder.lines = 16;
2099
+ EXRDecoder.uncompress = uncompressZIP;
2100
+ break;
2101
+
2102
+ case 'PIZ_COMPRESSION':
2103
+ EXRDecoder.lines = 32;
2104
+ EXRDecoder.uncompress = uncompressPIZ;
2105
+ break;
2106
+
2107
+ case 'PXR24_COMPRESSION':
2108
+ EXRDecoder.lines = 16;
2109
+ EXRDecoder.uncompress = uncompressPXR;
2110
+ break;
2111
+
2112
+ case 'DWAA_COMPRESSION':
2113
+ EXRDecoder.lines = 32;
2114
+ EXRDecoder.uncompress = uncompressDWA;
2115
+ break;
2116
+
2117
+ case 'DWAB_COMPRESSION':
2118
+ EXRDecoder.lines = 256;
2119
+ EXRDecoder.uncompress = uncompressDWA;
2120
+ break;
2121
+
2122
+ default:
2123
+ throw new Error( 'EXRLoader.parse: ' + EXRHeader.compression + ' is unsupported' );
2124
+
2125
+ }
2126
+
2127
+ EXRDecoder.scanlineBlockSize = EXRDecoder.lines;
2128
+
2129
+ if ( EXRDecoder.type == 1 ) {
2130
+
2131
+ // half
2132
+ switch ( outputType ) {
2133
+
2134
+ case FloatType:
2135
+ EXRDecoder.getter = parseFloat16;
2136
+ EXRDecoder.inputSize = INT16_SIZE;
2137
+ break;
2138
+
2139
+ case HalfFloatType:
2140
+ EXRDecoder.getter = parseUint16;
2141
+ EXRDecoder.inputSize = INT16_SIZE;
2142
+ break;
2143
+
2144
+ }
2145
+
2146
+ } else if ( EXRDecoder.type == 2 ) {
2147
+
2148
+ // float
2149
+ switch ( outputType ) {
2150
+
2151
+ case FloatType:
2152
+ EXRDecoder.getter = parseFloat32;
2153
+ EXRDecoder.inputSize = FLOAT32_SIZE;
2154
+ break;
2155
+
2156
+ case HalfFloatType:
2157
+ EXRDecoder.getter = decodeFloat32;
2158
+ EXRDecoder.inputSize = FLOAT32_SIZE;
2159
+
2160
+ }
2161
+
2162
+ } else {
2163
+
2164
+ throw new Error( 'EXRLoader.parse: unsupported pixelType ' + EXRDecoder.type + ' for ' + EXRHeader.compression + '.' );
2165
+
2166
+ }
2167
+
2168
+ EXRDecoder.blockCount = ( EXRHeader.dataWindow.yMax + 1 ) / EXRDecoder.scanlineBlockSize;
2169
+
2170
+ for ( let i = 0; i < EXRDecoder.blockCount; i ++ )
2171
+ parseInt64( dataView, offset ); // scanlineOffset
2172
+
2173
+ // we should be passed the scanline offset table, ready to start reading pixel data.
2174
+
2175
+ // RGB images will be converted to RGBA format, preventing software emulation in select devices.
2176
+ EXRDecoder.outputChannels = ( ( EXRDecoder.channels == 3 ) ? 4 : EXRDecoder.channels );
2177
+ const size = EXRDecoder.width * EXRDecoder.height * EXRDecoder.outputChannels;
2178
+
2179
+ switch ( outputType ) {
2180
+
2181
+ case FloatType:
2182
+ EXRDecoder.byteArray = new Float32Array( size );
2183
+
2184
+ // Fill initially with 1s for the alpha value if the texture is not RGBA, RGB values will be overwritten
2185
+ if ( EXRDecoder.channels < EXRDecoder.outputChannels )
2186
+ EXRDecoder.byteArray.fill( 1, 0, size );
2187
+
2188
+ break;
2189
+
2190
+ case HalfFloatType:
2191
+ EXRDecoder.byteArray = new Uint16Array( size );
2192
+
2193
+ if ( EXRDecoder.channels < EXRDecoder.outputChannels )
2194
+ EXRDecoder.byteArray.fill( 0x3C00, 0, size ); // Uint16Array holds half float data, 0x3C00 is 1
2195
+
2196
+ break;
2197
+
2198
+ default:
2199
+ console.error( 'THREE.EXRLoader: unsupported type: ', outputType );
2200
+ break;
2201
+
2202
+ }
2203
+
2204
+ EXRDecoder.bytesPerLine = EXRDecoder.width * EXRDecoder.inputSize * EXRDecoder.channels;
2205
+
2206
+ if ( EXRDecoder.outputChannels == 4 ) {
2207
+
2208
+ EXRDecoder.format = RGBAFormat;
2209
+ EXRDecoder.encoding = LinearEncoding;
2210
+
2211
+ } else {
2212
+
2213
+ EXRDecoder.format = RedFormat;
2214
+ EXRDecoder.encoding = LinearEncoding;
2215
+
2216
+ }
2217
+
2218
+ return EXRDecoder;
2219
+
2220
+ }
2221
+
2222
+ // start parsing file [START]
2223
+
2224
+ const bufferDataView = new DataView( buffer );
2225
+ const uInt8Array = new Uint8Array( buffer );
2226
+ const offset = { value: 0 };
2227
+
2228
+ // get header information and validate format.
2229
+ const EXRHeader = parseHeader( bufferDataView, buffer, offset );
2230
+
2231
+ // get input compression information and prepare decoding.
2232
+ const EXRDecoder = setupDecoder( EXRHeader, bufferDataView, uInt8Array, offset, this.type );
2233
+
2234
+ const tmpOffset = { value: 0 };
2235
+ const channelOffsets = { R: 0, G: 1, B: 2, A: 3, Y: 0 };
2236
+
2237
+ for ( let scanlineBlockIdx = 0; scanlineBlockIdx < EXRDecoder.height / EXRDecoder.scanlineBlockSize; scanlineBlockIdx ++ ) {
2238
+
2239
+ const line = parseUint32( bufferDataView, offset ); // line_no
2240
+ EXRDecoder.size = parseUint32( bufferDataView, offset ); // data_len
2241
+ EXRDecoder.lines = ( ( line + EXRDecoder.scanlineBlockSize > EXRDecoder.height ) ? ( EXRDecoder.height - line ) : EXRDecoder.scanlineBlockSize );
2242
+
2243
+ const isCompressed = EXRDecoder.size < EXRDecoder.lines * EXRDecoder.bytesPerLine;
2244
+ const viewer = isCompressed ? EXRDecoder.uncompress( EXRDecoder ) : uncompressRAW( EXRDecoder );
2245
+
2246
+ offset.value += EXRDecoder.size;
2247
+
2248
+ for ( let line_y = 0; line_y < EXRDecoder.scanlineBlockSize; line_y ++ ) {
2249
+
2250
+ const true_y = line_y + scanlineBlockIdx * EXRDecoder.scanlineBlockSize;
2251
+ if ( true_y >= EXRDecoder.height ) break;
2252
+
2253
+ for ( let channelID = 0; channelID < EXRDecoder.channels; channelID ++ ) {
2254
+
2255
+ const cOff = channelOffsets[ EXRHeader.channels[ channelID ].name ];
2256
+
2257
+ for ( let x = 0; x < EXRDecoder.width; x ++ ) {
2258
+
2259
+ tmpOffset.value = ( line_y * ( EXRDecoder.channels * EXRDecoder.width ) + channelID * EXRDecoder.width + x ) * EXRDecoder.inputSize;
2260
+ const outIndex = ( EXRDecoder.height - 1 - true_y ) * ( EXRDecoder.width * EXRDecoder.outputChannels ) + x * EXRDecoder.outputChannels + cOff;
2261
+ EXRDecoder.byteArray[ outIndex ] = EXRDecoder.getter( viewer, tmpOffset );
2262
+
2263
+ }
2264
+
2265
+ }
2266
+
2267
+ }
2268
+
2269
+ }
2270
+
2271
+ return {
2272
+ header: EXRHeader,
2273
+ width: EXRDecoder.width,
2274
+ height: EXRDecoder.height,
2275
+ data: EXRDecoder.byteArray,
2276
+ format: EXRDecoder.format,
2277
+ encoding: EXRDecoder.encoding,
2278
+ type: this.type,
2279
+ };
2280
+
2281
+ }
2282
+
2283
+ setDataType( value ) {
2284
+
2285
+ this.type = value;
2286
+ return this;
2287
+
2288
+ }
2289
+
2290
+ load( url, onLoad, onProgress, onError ) {
2291
+
2292
+ function onLoadCallback( texture, texData ) {
2293
+
2294
+ texture.encoding = texData.encoding;
2295
+ texture.minFilter = LinearFilter;
2296
+ texture.magFilter = LinearFilter;
2297
+ texture.generateMipmaps = false;
2298
+ texture.flipY = false;
2299
+
2300
+ if ( onLoad ) onLoad( texture, texData );
2301
+
2302
+ }
2303
+
2304
+ return super.load( url, onLoadCallback, onProgress, onError );
2305
+
2306
+ }
2307
+
2308
+ }
2309
+
2310
+ export { EXRLoader };