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