super-three 0.181.0 → 0.185.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.
- package/LICENSE +1 -1
- package/README.md +3 -4
- package/build/three.cjs +21332 -19201
- package/build/three.core.js +20908 -19853
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +1947 -862
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +37 -16
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +33628 -25197
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +33394 -25000
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +14 -3
- package/examples/jsm/animation/CCDIKSolver.js +7 -3
- package/examples/jsm/controls/ArcballControls.js +13 -6
- package/examples/jsm/controls/DragControls.js +2 -2
- package/examples/jsm/controls/FirstPersonControls.js +127 -86
- package/examples/jsm/controls/FlyControls.js +4 -0
- package/examples/jsm/controls/MapControls.js +55 -1
- package/examples/jsm/controls/OrbitControls.js +111 -8
- package/examples/jsm/controls/TrackballControls.js +8 -8
- package/examples/jsm/controls/TransformControls.js +102 -17
- package/examples/jsm/csm/CSM.js +2 -1
- package/examples/jsm/csm/CSMFrustum.js +31 -6
- package/examples/jsm/csm/CSMShadowNode.js +10 -3
- package/examples/jsm/effects/AnaglyphEffect.js +102 -7
- package/examples/jsm/effects/AsciiEffect.js +14 -1
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/RoomEnvironment.js +3 -0
- package/examples/jsm/exporters/DRACOExporter.js +27 -6
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +266 -21
- package/examples/jsm/exporters/PLYExporter.js +286 -73
- package/examples/jsm/exporters/USDZExporter.js +353 -99
- package/examples/jsm/generators/CityGenerator.js +346 -0
- package/examples/jsm/generators/ForestGenerator.js +347 -0
- package/examples/jsm/generators/TerrainGenerator.js +504 -0
- package/examples/jsm/generators/TreeGenerator.js +377 -0
- package/examples/jsm/generators/city/SidewalkGenerator.js +253 -0
- package/examples/jsm/generators/city/SkyscraperGenerator.js +1357 -0
- package/examples/jsm/geometries/DecalGeometry.js +1 -1
- package/examples/jsm/geometries/LoftGeometry.js +355 -0
- package/examples/jsm/geometries/TextGeometry.js +18 -0
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +221 -0
- package/examples/jsm/helpers/LightProbeHelper.js +5 -4
- package/examples/jsm/helpers/LightProbeHelperGPU.js +1 -1
- package/examples/jsm/helpers/TextureHelperGPU.js +1 -1
- package/examples/jsm/helpers/ViewHelper.js +83 -14
- package/examples/jsm/inspector/Extension.js +13 -0
- package/examples/jsm/inspector/Inspector.js +244 -91
- package/examples/jsm/inspector/RendererInspector.js +165 -39
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +916 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +281 -0
- package/examples/jsm/inspector/tabs/Console.js +241 -25
- package/examples/jsm/inspector/tabs/Memory.js +136 -0
- package/examples/jsm/inspector/tabs/Parameters.js +115 -7
- package/examples/jsm/inspector/tabs/Performance.js +24 -9
- package/examples/jsm/inspector/tabs/Settings.js +306 -0
- package/examples/jsm/inspector/tabs/Timeline.js +1696 -0
- package/examples/jsm/inspector/tabs/Viewer.js +723 -9
- package/examples/jsm/inspector/ui/Graph.js +162 -25
- package/examples/jsm/inspector/ui/Item.js +92 -13
- package/examples/jsm/inspector/ui/List.js +2 -2
- package/examples/jsm/inspector/ui/Profiler.js +1991 -44
- package/examples/jsm/inspector/ui/Style.js +1943 -543
- package/examples/jsm/inspector/ui/Tab.js +226 -5
- package/examples/jsm/inspector/ui/Values.js +126 -8
- package/examples/jsm/inspector/ui/utils.js +143 -10
- package/examples/jsm/interaction/InteractionManager.js +226 -0
- package/examples/jsm/libs/basis/README.md +0 -1
- package/examples/jsm/libs/demuxer_mp4.js +3 -3
- package/examples/jsm/libs/draco/README.md +0 -1
- package/examples/jsm/libs/meshopt_clusterizer.module.js +421 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +9 -8
- package/examples/jsm/libs/meshopt_simplifier.module.js +627 -0
- package/examples/jsm/libs/mikktspace.module.js +34 -9
- package/examples/jsm/lighting/ClusteredLighting.js +55 -0
- package/examples/jsm/lighting/DynamicLighting.js +82 -0
- package/examples/jsm/lighting/LightProbeGrid.js +681 -0
- package/examples/jsm/lines/LineMaterial.js +45 -16
- package/examples/jsm/lines/LineSegments2.js +8 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +8 -0
- package/examples/jsm/loaders/3DMLoader.js +6 -5
- package/examples/jsm/loaders/3MFLoader.js +2 -2
- package/examples/jsm/loaders/AMFLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +24 -4026
- package/examples/jsm/loaders/DRACOLoader.js +51 -18
- package/examples/jsm/loaders/EXRLoader.js +701 -90
- package/examples/jsm/loaders/FBXLoader.js +235 -37
- package/examples/jsm/loaders/GCodeLoader.js +34 -8
- package/examples/jsm/loaders/GLTFLoader.js +146 -178
- package/examples/jsm/loaders/HDRLoader.js +7 -30
- package/examples/jsm/loaders/KMZLoader.js +5 -5
- package/examples/jsm/loaders/KTX2Loader.js +58 -17
- package/examples/jsm/loaders/LDrawLoader.js +49 -58
- package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
- package/examples/jsm/loaders/LUTCubeLoader.js +2 -2
- package/examples/jsm/loaders/LWOLoader.js +11 -39
- package/examples/jsm/loaders/LottieLoader.js +1 -1
- package/examples/jsm/loaders/MaterialXLoader.js +31 -9
- package/examples/jsm/loaders/NRRDLoader.js +5 -5
- package/examples/jsm/loaders/PCDLoader.js +11 -9
- package/examples/jsm/loaders/PLYLoader.js +218 -55
- package/examples/jsm/loaders/SVGLoader.js +549 -497
- package/examples/jsm/loaders/TDSLoader.js +0 -2
- package/examples/jsm/loaders/TGALoader.js +0 -2
- package/examples/jsm/loaders/TTFLoader.js +1 -1
- package/examples/jsm/loaders/USDLoader.js +127 -43
- package/examples/jsm/loaders/UltraHDRLoader.js +285 -160
- package/examples/jsm/loaders/VOXLoader.js +660 -117
- package/examples/jsm/loaders/VRMLLoader.js +80 -3
- package/examples/jsm/loaders/VTKLoader.js +42 -25
- package/examples/jsm/loaders/collada/ColladaComposer.js +3044 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1977 -0
- package/examples/jsm/loaders/usd/USDAParser.js +504 -344
- package/examples/jsm/loaders/usd/USDCParser.js +1867 -6
- package/examples/jsm/loaders/usd/USDComposer.js +4627 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +2 -2
- package/examples/jsm/materials/WoodNodeMaterial.js +11 -11
- package/examples/jsm/math/Octree.js +131 -1
- package/examples/jsm/misc/GPUComputationRenderer.js +2 -0
- package/examples/jsm/misc/RollerCoaster.js +42 -4
- package/examples/jsm/misc/TileCreasedNormalsPlugin.js +270 -0
- package/examples/jsm/misc/Volume.js +2 -3
- package/examples/jsm/misc/VolumeSlice.js +0 -1
- package/examples/jsm/modifiers/TessellateModifier.js +1 -1
- package/examples/jsm/objects/GroundedSkybox.js +1 -1
- package/examples/jsm/objects/LensflareMesh.js +1 -1
- package/examples/jsm/objects/Reflector.js +72 -25
- package/examples/jsm/objects/Sky.js +90 -6
- package/examples/jsm/objects/SkyMesh.js +150 -16
- package/examples/jsm/objects/Water.js +4 -3
- package/examples/jsm/objects/Water2.js +5 -3
- package/examples/jsm/objects/Water2Mesh.js +1 -1
- package/examples/jsm/objects/WaterMesh.js +5 -7
- package/examples/jsm/physics/AmmoPhysics.js +27 -15
- package/examples/jsm/physics/JoltPhysics.js +10 -6
- package/examples/jsm/physics/RapierPhysics.js +36 -7
- package/examples/jsm/postprocessing/EffectComposer.js +7 -5
- package/examples/jsm/postprocessing/OutputPass.js +9 -0
- package/examples/jsm/postprocessing/RenderPass.js +10 -0
- package/examples/jsm/postprocessing/RenderTransitionPass.js +1 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +48 -18
- package/examples/jsm/renderers/CSS3DRenderer.js +1 -1
- package/examples/jsm/renderers/Projector.js +246 -28
- package/examples/jsm/renderers/SVGRenderer.js +174 -60
- package/examples/jsm/shaders/GTAOShader.js +19 -6
- package/examples/jsm/shaders/HalftoneShader.js +12 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +6 -2
- package/examples/jsm/shaders/SAOShader.js +17 -4
- package/examples/jsm/shaders/SSAOShader.js +11 -1
- package/examples/jsm/shaders/SSRShader.js +6 -5
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -4
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/shaders/VolumeShader.js +31 -44
- package/examples/jsm/transpiler/AST.js +44 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +65 -8
- package/examples/jsm/transpiler/Linker.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -0
- package/examples/jsm/transpiler/TSLEncoder.js +46 -3
- package/examples/jsm/transpiler/TranspilerUtils.js +3 -3
- package/examples/jsm/transpiler/WGSLEncoder.js +27 -0
- package/examples/jsm/tsl/WebGLNodesHandler.js +605 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +11 -1
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +458 -16
- package/examples/jsm/tsl/display/BilateralBlurNode.js +374 -0
- package/examples/jsm/tsl/display/BloomNode.js +75 -25
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +3 -36
- package/examples/jsm/tsl/display/DenoiseNode.js +1 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +3 -3
- package/examples/jsm/tsl/display/DotScreenNode.js +1 -1
- package/examples/jsm/tsl/display/FSR1Node.js +477 -0
- package/examples/jsm/tsl/display/FXAANode.js +13 -14
- package/examples/jsm/tsl/display/GTAONode.js +40 -17
- package/examples/jsm/tsl/display/GaussianBlurNode.js +21 -2
- package/examples/jsm/tsl/display/GodraysNode.js +615 -0
- package/examples/jsm/tsl/display/ImportanceSampledEnvironment.js +560 -0
- package/examples/jsm/tsl/display/LensflareNode.js +1 -1
- package/examples/jsm/tsl/display/Lut3DNode.js +1 -1
- package/examples/jsm/tsl/display/OutlineNode.js +69 -19
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +9 -8
- package/examples/jsm/tsl/display/RGBShiftNode.js +2 -2
- package/examples/jsm/tsl/display/RecurrentDenoiseNode.js +912 -0
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +2 -2
- package/examples/jsm/tsl/display/SSAAPassNode.js +15 -27
- package/examples/jsm/tsl/display/SSGINode.js +96 -62
- package/examples/jsm/tsl/display/SSRNode.js +831 -134
- package/examples/jsm/tsl/display/SSSNode.js +8 -6
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/examples/jsm/tsl/display/SharpenNode.js +283 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +2 -2
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +8 -1
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -2
- package/examples/jsm/tsl/display/TAAUNode.js +835 -0
- package/examples/jsm/tsl/display/TRAANode.js +315 -126
- package/examples/jsm/tsl/display/TemporalReprojectNode.js +1023 -0
- package/examples/jsm/tsl/display/TransitionNode.js +1 -1
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/tsl/lighting/ClusteredLightsNode.js +622 -0
- package/examples/jsm/tsl/lighting/DynamicLightsNode.js +300 -0
- package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +61 -0
- package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +111 -0
- package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +99 -0
- package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +134 -0
- package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +161 -0
- package/examples/jsm/tsl/math/Bayer.js +53 -3
- package/examples/jsm/tsl/math/curlNoise.js +107 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +1 -1
- package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +3 -3
- package/examples/jsm/tsl/utils/GroundedSkybox.js +62 -0
- package/examples/jsm/tsl/utils/RNoise.js +51 -0
- package/examples/jsm/tsl/utils/SpecularHelpers.js +325 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +128 -62
- package/examples/jsm/utils/ColorUtils.js +76 -0
- package/examples/jsm/utils/GeometryCompressionUtils.js +1 -1
- package/examples/jsm/utils/LDrawUtils.js +1 -1
- package/examples/jsm/utils/SceneOptimizer.js +1 -1
- package/examples/jsm/utils/ShadowMapViewer.js +24 -10
- package/examples/jsm/utils/ShadowMapViewerGPU.js +1 -1
- package/examples/jsm/utils/SkeletonUtils.js +14 -8
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/examples/jsm/webxr/ARButton.js +1 -1
- package/examples/jsm/webxr/WebGLXRFallback.js +89 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +2 -2
- package/examples/jsm/webxr/XRHandMeshModel.js +36 -10
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -1
- package/package.json +28 -34
- package/src/Three.Core.js +3 -1
- package/src/Three.TSL.js +35 -14
- package/src/Three.WebGPU.Nodes.js +5 -0
- package/src/Three.WebGPU.js +13 -0
- package/src/Three.js +1 -0
- package/src/animation/AnimationAction.js +18 -4
- package/src/animation/AnimationClip.js +0 -139
- package/src/animation/AnimationMixer.js +6 -0
- package/src/animation/AnimationUtils.js +1 -12
- package/src/animation/KeyframeTrack.js +47 -8
- package/src/animation/PropertyBinding.js +2 -2
- package/src/animation/PropertyMixer.js +4 -4
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/ColorKeyframeTrack.js +1 -1
- package/src/animation/tracks/NumberKeyframeTrack.js +1 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/animation/tracks/VectorKeyframeTrack.js +1 -1
- package/src/audio/Audio.js +1 -1
- package/src/audio/AudioContext.js +2 -2
- package/src/audio/AudioListener.js +5 -3
- package/src/cameras/Camera.js +34 -4
- package/src/cameras/CubeCamera.js +20 -0
- package/src/cameras/StereoCamera.js +5 -2
- package/src/constants.js +90 -5
- package/src/core/BufferAttribute.js +13 -1
- package/src/core/BufferGeometry.js +43 -9
- package/src/core/Clock.js +7 -0
- package/src/core/Object3D.js +69 -11
- package/src/core/Raycaster.js +3 -3
- package/src/core/RenderTarget.js +19 -6
- package/src/extras/PMREMGenerator.js +13 -22
- package/src/extras/TextureUtils.js +6 -2
- package/src/extras/core/ShapePath.js +149 -160
- package/src/extras/curves/CatmullRomCurve3.js +3 -2
- package/src/geometries/ExtrudeGeometry.js +2 -2
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/geometries/SphereGeometry.js +8 -3
- package/src/geometries/TorusGeometry.js +8 -3
- package/src/helpers/CameraHelper.js +3 -0
- package/src/helpers/DirectionalLightHelper.js +6 -1
- package/src/helpers/HemisphereLightHelper.js +5 -0
- package/src/helpers/PointLightHelper.js +3 -25
- package/src/helpers/SpotLightHelper.js +4 -1
- package/src/lights/DirectionalLight.js +13 -0
- package/src/lights/HemisphereLight.js +10 -0
- package/src/lights/Light.js +1 -11
- package/src/lights/LightProbe.js +0 -15
- package/src/lights/LightShadow.js +15 -6
- package/src/lights/PointLight.js +15 -0
- package/src/lights/PointLightShadow.js +0 -86
- package/src/lights/SpotLight.js +22 -1
- package/src/lights/webgpu/IESSpotLight.js +2 -1
- package/src/loaders/AudioLoader.js +11 -1
- package/src/loaders/Cache.js +28 -0
- package/src/loaders/DataTextureLoader.js +75 -42
- package/src/loaders/FileLoader.js +2 -3
- package/src/loaders/ImageBitmapLoader.js +12 -9
- package/src/loaders/Loader.js +6 -0
- package/src/loaders/LoadingManager.js +5 -0
- package/src/loaders/MaterialLoader.js +37 -266
- package/src/loaders/ObjectLoader.js +48 -6
- package/src/loaders/nodes/NodeLoader.js +2 -2
- package/src/loaders/nodes/NodeObjectLoader.js +18 -0
- package/src/materials/LineBasicMaterial.js +4 -0
- package/src/materials/Material.js +198 -1
- package/src/materials/MeshBasicMaterial.js +24 -0
- package/src/materials/MeshDepthMaterial.js +10 -0
- package/src/materials/MeshDistanceMaterial.js +10 -0
- package/src/materials/MeshLambertMaterial.js +49 -1
- package/src/materials/MeshMatcapMaterial.js +25 -1
- package/src/materials/MeshNormalMaterial.js +9 -1
- package/src/materials/MeshPhongMaterial.js +49 -1
- package/src/materials/MeshPhysicalMaterial.js +38 -0
- package/src/materials/MeshStandardMaterial.js +42 -1
- package/src/materials/MeshToonMaterial.js +35 -2
- package/src/materials/PointsMaterial.js +7 -0
- package/src/materials/ShaderMaterial.js +106 -1
- package/src/materials/SpriteMaterial.js +7 -0
- package/src/materials/nodes/Line2NodeMaterial.js +380 -297
- package/src/materials/nodes/MeshBasicNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhongNodeMaterial.js +0 -9
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +3 -30
- package/src/materials/nodes/MeshSSSNodeMaterial.js +0 -13
- package/src/materials/nodes/MeshStandardNodeMaterial.js +5 -15
- package/src/materials/nodes/NodeMaterial.js +153 -89
- package/src/materials/nodes/SpriteNodeMaterial.js +0 -10
- package/src/materials/nodes/manager/NodeMaterialObserver.js +234 -100
- package/src/math/Box3.js +5 -0
- package/src/math/FrustumArray.js +103 -133
- package/src/math/Interpolant.js +1 -1
- package/src/math/Line3.js +6 -5
- package/src/math/MathUtils.js +12 -12
- package/src/math/Matrix2.js +13 -9
- package/src/math/Matrix3.js +24 -9
- package/src/math/Matrix4.js +112 -74
- package/src/math/Plane.js +4 -3
- package/src/math/Quaternion.js +3 -29
- package/src/math/Sphere.js +1 -1
- package/src/math/Triangle.js +1 -1
- package/src/math/Vector2.js +13 -9
- package/src/math/Vector3.js +17 -15
- package/src/math/Vector4.js +15 -11
- package/src/math/interpolants/BezierInterpolant.js +106 -0
- package/src/nodes/Nodes.js +86 -71
- package/src/nodes/TSL.js +15 -13
- package/src/nodes/accessors/Arrays.js +5 -5
- package/src/nodes/accessors/Batch.js +108 -0
- package/src/nodes/accessors/Bitangent.js +7 -7
- package/src/nodes/accessors/BufferAttributeNode.js +120 -17
- package/src/nodes/accessors/BufferNode.js +29 -2
- package/src/nodes/accessors/Camera.js +149 -28
- package/src/nodes/accessors/ClippingNode.js +5 -5
- package/src/nodes/accessors/CubeTextureNode.js +27 -2
- package/src/nodes/accessors/Instance.js +264 -0
- package/src/nodes/accessors/MaterialNode.js +27 -3
- package/src/nodes/accessors/MaterialProperties.js +6 -8
- package/src/nodes/accessors/MaterialReferenceNode.js +1 -2
- package/src/nodes/accessors/ModelNode.js +1 -1
- package/src/nodes/accessors/{MorphNode.js → Morph.js} +99 -112
- package/src/nodes/accessors/Normal.js +24 -24
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/Position.js +39 -3
- package/src/nodes/accessors/ReferenceBaseNode.js +6 -6
- package/src/nodes/accessors/ReferenceNode.js +9 -8
- package/src/nodes/accessors/ReflectVector.js +3 -3
- package/src/nodes/accessors/RendererReferenceNode.js +1 -2
- package/src/nodes/accessors/SceneProperties.js +47 -0
- package/src/nodes/accessors/Skinning.js +263 -0
- package/src/nodes/accessors/StorageBufferNode.js +16 -27
- package/src/nodes/accessors/StorageTexture3DNode.js +100 -0
- package/src/nodes/accessors/StorageTextureNode.js +74 -11
- package/src/nodes/accessors/Tangent.js +8 -18
- package/src/nodes/accessors/Texture3DNode.js +32 -35
- package/src/nodes/accessors/TextureNode.js +124 -25
- package/src/nodes/accessors/UniformArrayNode.js +6 -4
- package/src/nodes/accessors/UserDataNode.js +1 -2
- package/src/nodes/accessors/VertexColorNode.js +1 -2
- package/src/nodes/code/FunctionCallNode.js +1 -1
- package/src/nodes/code/FunctionNode.js +4 -19
- package/src/nodes/core/ArrayNode.js +21 -2
- package/src/nodes/core/AssignNode.js +3 -3
- package/src/nodes/core/AttributeNode.js +3 -3
- package/src/nodes/core/BypassNode.js +1 -1
- package/src/nodes/core/ContextNode.js +104 -5
- package/src/nodes/core/IndexNode.js +2 -1
- package/src/nodes/core/InputNode.js +1 -1
- package/src/nodes/core/InspectorNode.js +1 -1
- package/src/nodes/core/IsolateNode.js +1 -1
- package/src/nodes/core/MRTNode.js +55 -4
- package/src/nodes/core/Node.js +151 -17
- package/src/nodes/core/NodeBuilder.js +479 -101
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeFrame.js +12 -4
- package/src/nodes/core/NodeUtils.js +20 -18
- package/src/nodes/core/OutputStructNode.js +13 -11
- package/src/nodes/core/OverrideContextNode.js +153 -0
- package/src/nodes/core/ParameterNode.js +4 -4
- package/src/nodes/core/PropertyNode.js +66 -4
- package/src/nodes/core/StackNode.js +91 -20
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +20 -8
- package/src/nodes/core/StructTypeNode.js +17 -23
- package/src/nodes/core/SubBuildNode.js +2 -2
- package/src/nodes/core/UniformGroupNode.js +36 -6
- package/src/nodes/core/UniformNode.js +21 -5
- package/src/nodes/core/VarNode.js +56 -23
- package/src/nodes/core/VaryingNode.js +14 -21
- package/src/nodes/display/BlendModes.js +1 -105
- package/src/nodes/display/BumpMapNode.js +6 -1
- package/src/nodes/display/ColorAdjustment.js +27 -9
- package/src/nodes/display/ColorSpaceNode.js +3 -3
- package/src/nodes/display/FrontFacingNode.js +38 -9
- package/src/nodes/display/NormalMapNode.js +41 -6
- package/src/nodes/display/PassNode.js +157 -56
- package/src/nodes/display/PremultiplyAlphaFunctions.js +39 -0
- package/src/nodes/display/RenderOutputNode.js +19 -10
- package/src/nodes/display/ScreenNode.js +4 -2
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +2 -2
- package/src/nodes/display/ViewportDepthNode.js +52 -4
- package/src/nodes/display/ViewportDepthTextureNode.js +11 -15
- package/src/nodes/display/ViewportTextureNode.js +39 -11
- package/src/nodes/fog/Fog.js +18 -35
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +3 -3
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/PhysicalLightingModel.js +126 -45
- package/src/nodes/functions/VolumetricLightingModel.js +40 -7
- package/src/nodes/geometry/RangeNode.js +5 -3
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/BarrierNode.js +9 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +2 -3
- package/src/nodes/gpgpu/ComputeNode.js +74 -48
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +2 -2
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +5 -5
- package/src/nodes/lighting/AnalyticLightNode.js +53 -0
- package/src/nodes/lighting/EnvironmentNode.js +30 -5
- package/src/nodes/lighting/IESSpotLightNode.js +40 -2
- package/src/nodes/lighting/LightingContextNode.js +10 -2
- package/src/nodes/lighting/LightsNode.js +97 -65
- package/src/nodes/lighting/PointShadowNode.js +166 -148
- package/src/nodes/lighting/ShadowFilterNode.js +74 -117
- package/src/nodes/lighting/ShadowNode.js +149 -51
- package/src/nodes/materialx/lib/mx_noise.js +2 -2
- package/src/nodes/math/BitcastNode.js +1 -1
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/ConditionalNode.js +6 -6
- package/src/nodes/math/MathNode.js +115 -52
- package/src/nodes/math/OperatorNode.js +24 -23
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/parsers/GLSLNodeFunction.js +1 -1
- package/src/nodes/pmrem/PMREMNode.js +34 -3
- package/src/nodes/pmrem/PMREMUtils.js +9 -15
- package/src/nodes/tsl/TSLBase.js +1 -1
- package/src/nodes/tsl/TSLCore.js +99 -33
- package/src/nodes/utils/ArrayElementNode.js +14 -1
- package/src/nodes/utils/ConvertNode.js +1 -1
- package/src/nodes/utils/DebugNode.js +12 -12
- package/src/nodes/utils/EquirectUV.js +30 -5
- package/src/nodes/utils/EventNode.js +31 -2
- package/src/nodes/utils/FlipNode.js +1 -1
- package/src/nodes/utils/FunctionOverloadingNode.js +2 -2
- package/src/nodes/utils/JoinNode.js +3 -3
- package/src/nodes/utils/LoopNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +2 -2
- package/src/nodes/utils/Packing.js +48 -5
- package/src/nodes/utils/PostProcessingUtils.js +33 -1
- package/src/nodes/utils/RTTNode.js +41 -25
- package/src/nodes/utils/ReflectorNode.js +4 -4
- package/src/nodes/utils/Remap.js +48 -0
- package/src/nodes/utils/RotateNode.js +1 -1
- package/src/nodes/utils/SampleNode.js +1 -1
- package/src/nodes/utils/SetNode.js +1 -1
- package/src/nodes/utils/SplitNode.js +1 -1
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/StorageArrayElementNode.js +1 -1
- package/src/nodes/utils/UVUtils.js +28 -0
- package/src/objects/BatchedMesh.js +66 -30
- package/src/objects/InstancedMesh.js +19 -3
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/objects/SkinnedMesh.js +26 -9
- package/src/renderers/WebGLRenderer.js +344 -156
- package/src/renderers/common/Animation.js +3 -3
- package/src/renderers/common/Attributes.js +15 -1
- package/src/renderers/common/Backend.js +78 -13
- package/src/renderers/common/Background.js +26 -13
- package/src/renderers/common/BindGroup.js +1 -16
- package/src/renderers/common/Binding.js +11 -0
- package/src/renderers/common/Bindings.js +141 -57
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/Buffer.js +49 -0
- package/src/renderers/common/BundleGroup.js +1 -1
- package/src/renderers/common/ChainMap.js +30 -6
- package/src/renderers/common/ClippingContext.js +10 -2
- package/src/renderers/common/ComputePipeline.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +51 -7
- package/src/renderers/common/Geometries.js +29 -3
- package/src/renderers/common/Info.js +374 -4
- package/src/renderers/common/InspectorBase.js +6 -1
- package/src/renderers/common/Lighting.js +51 -19
- package/src/renderers/common/Pipelines.js +40 -7
- package/src/renderers/common/PostProcessing.js +8 -206
- package/src/renderers/common/ReadbackBuffer.js +78 -0
- package/src/renderers/common/RenderBundle.js +3 -1
- package/src/renderers/common/RenderBundles.js +7 -3
- package/src/renderers/common/RenderContext.js +16 -0
- package/src/renderers/common/RenderContexts.js +33 -49
- package/src/renderers/common/RenderList.js +41 -4
- package/src/renderers/common/RenderLists.js +2 -1
- package/src/renderers/common/RenderObject.js +88 -16
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +21 -5
- package/src/renderers/common/RenderPipeline.js +232 -17
- package/src/renderers/common/Renderer.js +700 -163
- package/src/renderers/common/Sampler.js +16 -48
- package/src/renderers/common/StorageBuffer.js +13 -1
- package/src/renderers/common/Textures.js +121 -9
- package/src/renderers/common/TimestampQueryPool.js +6 -4
- package/src/renderers/common/Uniform.js +8 -0
- package/src/renderers/common/UniformsGroup.js +84 -1
- package/src/renderers/common/XRManager.js +377 -51
- package/src/renderers/common/extras/PMREMGenerator.js +40 -61
- package/src/renderers/common/nodes/NodeBuilderState.js +10 -2
- package/src/renderers/common/nodes/NodeLibrary.js +4 -4
- package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +298 -106
- package/src/renderers/common/nodes/NodeStorageBuffer.js +13 -2
- package/src/renderers/common/nodes/NodeUniformBuffer.js +65 -0
- package/src/renderers/shaders/DFGLUTData.js +19 -34
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +13 -4
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +0 -6
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +9 -13
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lightprobes_pars_fragment.glsl.js +80 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +13 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +3 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +112 -53
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +225 -186
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +12 -2
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk.js +5 -3
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +2 -3
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +7 -6
- package/src/renderers/shaders/UniformsLib.js +7 -5
- package/src/renderers/shaders/UniformsUtils.js +27 -5
- package/src/renderers/webgl/WebGLAnimation.js +2 -1
- package/src/renderers/webgl/WebGLBackground.js +15 -15
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLCapabilities.js +9 -4
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLGeometries.js +10 -7
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLMaterials.js +24 -13
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLOutput.js +271 -0
- package/src/renderers/webgl/WebGLProgram.js +54 -113
- package/src/renderers/webgl/WebGLPrograms.js +74 -55
- package/src/renderers/webgl/WebGLRenderLists.js +24 -1
- package/src/renderers/webgl/WebGLRenderStates.js +13 -2
- package/src/renderers/webgl/WebGLShaderCache.js +5 -11
- package/src/renderers/webgl/WebGLShadowMap.js +188 -24
- package/src/renderers/webgl/WebGLState.js +75 -37
- package/src/renderers/webgl/WebGLTextures.js +230 -56
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUniformsGroups.js +82 -35
- package/src/renderers/webgl/WebGLUtils.js +6 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +322 -92
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +0 -41
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +295 -66
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +53 -19
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +25 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +223 -6
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +118 -73
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +10 -10
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +9 -3
- package/src/renderers/webgpu/WebGPUBackend.js +733 -302
- package/src/renderers/webgpu/WebGPURenderer.js +2 -1
- package/src/renderers/webgpu/descriptors/GPUBindGroupDescriptor.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUBufferDescriptor.js +57 -0
- package/src/renderers/webgpu/descriptors/GPUCommandEncoderDescriptor.js +30 -0
- package/src/renderers/webgpu/descriptors/GPUComputePassDescriptor.js +38 -0
- package/src/renderers/webgpu/descriptors/GPUComputePipelineDescriptor.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUCopyExternalImageDestInfo.js +47 -0
- package/src/renderers/webgpu/descriptors/GPUCopyExternalImageSourceInfo.js +50 -0
- package/src/renderers/webgpu/descriptors/GPUExtent3D.js +51 -0
- package/src/renderers/webgpu/descriptors/GPUPipelineLayoutDescriptor.js +39 -0
- package/src/renderers/webgpu/descriptors/GPUQuerySetDescriptor.js +47 -0
- package/src/renderers/webgpu/descriptors/GPURenderBundleEncoderDescriptor.js +74 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassColorAttachment.js +72 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassDepthStencilAttachment.js +99 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassDescriptor.js +72 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassTimestampWrites.js +49 -0
- package/src/renderers/webgpu/descriptors/GPURenderPipelineDescriptor.js +130 -0
- package/src/renderers/webgpu/descriptors/GPUSamplerDescriptor.js +119 -0
- package/src/renderers/webgpu/descriptors/GPUShaderModuleDescriptor.js +46 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyBufferInfo.js +57 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyBufferLayout.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyTextureInfo.js +61 -0
- package/src/renderers/webgpu/descriptors/GPUTextureDescriptor.js +99 -0
- package/src/renderers/webgpu/descriptors/GPUTextureViewDescriptor.js +108 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +0 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +526 -93
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +194 -61
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +395 -234
- package/src/renderers/webgpu/utils/WebGPUCapabilities.js +48 -0
- package/src/renderers/webgpu/utils/WebGPUConstants.js +10 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +224 -91
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +228 -213
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +428 -175
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +40 -25
- package/src/renderers/webgpu/utils/WebGPUUtils.js +70 -13
- package/src/renderers/webxr/WebXRController.js +12 -0
- package/src/renderers/webxr/WebXRManager.js +4 -2
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/DepthTexture.js +1 -1
- package/src/textures/ExternalTexture.js +0 -3
- package/src/textures/HTMLTexture.js +74 -0
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +16 -5
- package/src/utils.js +280 -3
- package/examples/fonts/LICENSE +0 -13
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +0 -91
- package/examples/fonts/README.md +0 -11
- package/examples/fonts/droid/NOTICE +0 -190
- package/examples/fonts/droid/README.txt +0 -18
- package/examples/fonts/droid/droid_sans_bold.typeface.json +0 -1
- package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +0 -1
- package/examples/fonts/droid/droid_sans_regular.typeface.json +0 -1
- package/examples/fonts/droid/droid_serif_bold.typeface.json +0 -1
- package/examples/fonts/droid/droid_serif_regular.typeface.json +0 -1
- package/examples/fonts/gentilis_bold.typeface.json +0 -1
- package/examples/fonts/gentilis_regular.typeface.json +0 -1
- package/examples/fonts/helvetiker_bold.typeface.json +0 -1
- package/examples/fonts/helvetiker_regular.typeface.json +0 -1
- package/examples/fonts/optimer_bold.typeface.json +0 -1
- package/examples/fonts/optimer_regular.typeface.json +0 -1
- package/examples/fonts/ttf/README.md +0 -9
- package/examples/fonts/ttf/kenpixel.ttf +0 -0
- package/examples/jsm/libs/ammo.wasm.js +0 -822
- package/examples/jsm/libs/ammo.wasm.wasm +0 -0
- package/examples/jsm/libs/draco/draco_encoder.js +0 -33
- package/examples/jsm/libs/draco/gltf/draco_encoder.js +0 -33
- package/examples/jsm/libs/lottie_canvas.module.js +0 -14849
- package/examples/jsm/libs/opentype.module.js +0 -14506
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +0 -21
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +0 -16
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/lighting/TiledLighting.js +0 -42
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -434
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -167
- package/examples/jsm/shaders/GodRaysShader.js +0 -333
- package/examples/jsm/tsl/display/AnamorphicNode.js +0 -282
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +0 -442
- package/src/nodes/accessors/BatchNode.js +0 -163
- package/src/nodes/accessors/InstanceNode.js +0 -244
- package/src/nodes/accessors/InstancedMeshNode.js +0 -50
- package/src/nodes/accessors/SceneNode.js +0 -145
- package/src/nodes/accessors/SkinningNode.js +0 -327
- package/src/nodes/code/ScriptableNode.js +0 -726
- package/src/nodes/code/ScriptableValueNode.js +0 -253
- package/src/nodes/display/PosterizeNode.js +0 -65
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -71
- package/src/nodes/utils/RemapNode.js +0 -125
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
RGFormat,
|
|
10
10
|
RGBAFormat
|
|
11
11
|
} from 'three';
|
|
12
|
-
import
|
|
12
|
+
import { unzlibSync } from '../libs/fflate.module.js';
|
|
13
13
|
|
|
14
14
|
// Referred to the original Industrial Light & Magic OpenEXR implementation and the TinyEXR / Syoyo Fujita
|
|
15
15
|
// implementation, so I have preserved their copyright notices.
|
|
@@ -83,7 +83,7 @@ import * as fflate from '../libs/fflate.module.js';
|
|
|
83
83
|
/**
|
|
84
84
|
* A loader for the OpenEXR texture format.
|
|
85
85
|
*
|
|
86
|
-
* `EXRLoader` currently supports uncompressed, ZIP(S), RLE, PIZ and DWA/B compression.
|
|
86
|
+
* `EXRLoader` currently supports uncompressed, ZIP(S), RLE, PIZ, B44/A and DWA/B compression.
|
|
87
87
|
* Supports reading as UnsignedByte, HalfFloat and Float type data texture.
|
|
88
88
|
*
|
|
89
89
|
* ```js
|
|
@@ -121,6 +121,14 @@ class EXRLoader extends DataTextureLoader {
|
|
|
121
121
|
*/
|
|
122
122
|
this.outputFormat = RGBAFormat;
|
|
123
123
|
|
|
124
|
+
/**
|
|
125
|
+
* For multi-part EXR files, the index of the part to load.
|
|
126
|
+
*
|
|
127
|
+
* @type {number}
|
|
128
|
+
* @default 0
|
|
129
|
+
*/
|
|
130
|
+
this.part = 0;
|
|
131
|
+
|
|
124
132
|
}
|
|
125
133
|
|
|
126
134
|
/**
|
|
@@ -164,6 +172,8 @@ class EXRLoader extends DataTextureLoader {
|
|
|
164
172
|
|
|
165
173
|
const logBase = Math.pow( 2.7182818, 2.2 );
|
|
166
174
|
|
|
175
|
+
let b44LogTable = null; // lazily initialized for pLinear B44 channels
|
|
176
|
+
|
|
167
177
|
function reverseLutFromBitmap( bitmap, lut ) {
|
|
168
178
|
|
|
169
179
|
let k = 0;
|
|
@@ -266,7 +276,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
266
276
|
|
|
267
277
|
if ( p.value - inOffset.value > ni ) {
|
|
268
278
|
|
|
269
|
-
throw new Error( 'Something wrong with hufUnpackEncTable' );
|
|
279
|
+
throw new Error( 'THREE.EXRLoader: Something wrong with hufUnpackEncTable' );
|
|
270
280
|
|
|
271
281
|
}
|
|
272
282
|
|
|
@@ -278,7 +288,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
278
288
|
|
|
279
289
|
if ( im + zerun > iM + 1 ) {
|
|
280
290
|
|
|
281
|
-
throw new Error( 'Something wrong with hufUnpackEncTable' );
|
|
291
|
+
throw new Error( 'THREE.EXRLoader: Something wrong with hufUnpackEncTable' );
|
|
282
292
|
|
|
283
293
|
}
|
|
284
294
|
|
|
@@ -292,7 +302,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
292
302
|
|
|
293
303
|
if ( im + zerun > iM + 1 ) {
|
|
294
304
|
|
|
295
|
-
throw new Error( 'Something wrong with hufUnpackEncTable' );
|
|
305
|
+
throw new Error( 'THREE.EXRLoader: Something wrong with hufUnpackEncTable' );
|
|
296
306
|
|
|
297
307
|
}
|
|
298
308
|
|
|
@@ -329,7 +339,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
329
339
|
|
|
330
340
|
if ( c >> l ) {
|
|
331
341
|
|
|
332
|
-
throw new Error( 'Invalid table entry' );
|
|
342
|
+
throw new Error( 'THREE.EXRLoader: Invalid table entry' );
|
|
333
343
|
|
|
334
344
|
}
|
|
335
345
|
|
|
@@ -339,7 +349,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
339
349
|
|
|
340
350
|
if ( pl.len ) {
|
|
341
351
|
|
|
342
|
-
throw new Error( 'Invalid table entry' );
|
|
352
|
+
throw new Error( 'THREE.EXRLoader: Invalid table entry' );
|
|
343
353
|
|
|
344
354
|
}
|
|
345
355
|
|
|
@@ -374,7 +384,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
374
384
|
|
|
375
385
|
if ( pl.len || pl.p ) {
|
|
376
386
|
|
|
377
|
-
throw new Error( 'Invalid table entry' );
|
|
387
|
+
throw new Error( 'THREE.EXRLoader: Invalid table entry' );
|
|
378
388
|
|
|
379
389
|
}
|
|
380
390
|
|
|
@@ -663,7 +673,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
663
673
|
|
|
664
674
|
if ( ! pl.p ) {
|
|
665
675
|
|
|
666
|
-
throw new Error( 'hufDecode issues' );
|
|
676
|
+
throw new Error( 'THREE.EXRLoader: hufDecode issues' );
|
|
667
677
|
|
|
668
678
|
}
|
|
669
679
|
|
|
@@ -703,7 +713,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
703
713
|
|
|
704
714
|
if ( j == pl.lit ) {
|
|
705
715
|
|
|
706
|
-
throw new Error( 'hufDecode issues' );
|
|
716
|
+
throw new Error( 'THREE.EXRLoader: hufDecode issues' );
|
|
707
717
|
|
|
708
718
|
}
|
|
709
719
|
|
|
@@ -733,7 +743,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
733
743
|
|
|
734
744
|
} else {
|
|
735
745
|
|
|
736
|
-
throw new Error( 'hufDecode issues' );
|
|
746
|
+
throw new Error( 'THREE.EXRLoader: hufDecode issues' );
|
|
737
747
|
|
|
738
748
|
}
|
|
739
749
|
|
|
@@ -759,7 +769,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
759
769
|
|
|
760
770
|
if ( im < 0 || im >= HUF_ENCSIZE || iM < 0 || iM >= HUF_ENCSIZE ) {
|
|
761
771
|
|
|
762
|
-
throw new Error( 'Something wrong with HUF_ENCSIZE' );
|
|
772
|
+
throw new Error( 'THREE.EXRLoader: Something wrong with HUF_ENCSIZE' );
|
|
763
773
|
|
|
764
774
|
}
|
|
765
775
|
|
|
@@ -774,7 +784,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
774
784
|
|
|
775
785
|
if ( nBits > 8 * ( nCompressed - ( inOffset.value - initialInOffset ) ) ) {
|
|
776
786
|
|
|
777
|
-
throw new Error( 'Something wrong with hufUncompress' );
|
|
787
|
+
throw new Error( 'THREE.EXRLoader: Something wrong with hufUncompress' );
|
|
778
788
|
|
|
779
789
|
}
|
|
780
790
|
|
|
@@ -1363,7 +1373,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
1363
1373
|
|
|
1364
1374
|
const compressed = info.array.slice( info.offset.value, info.offset.value + info.size );
|
|
1365
1375
|
|
|
1366
|
-
const rawBuffer =
|
|
1376
|
+
const rawBuffer = unzlibSync( compressed );
|
|
1367
1377
|
const tmpBuffer = new Uint8Array( rawBuffer.length );
|
|
1368
1378
|
|
|
1369
1379
|
predictor( rawBuffer ); // revert predictor
|
|
@@ -1405,7 +1415,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
1405
1415
|
|
|
1406
1416
|
if ( maxNonZero >= BITMAP_SIZE ) {
|
|
1407
1417
|
|
|
1408
|
-
throw new Error( 'Something is wrong with PIZ_COMPRESSION BITMAP_SIZE' );
|
|
1418
|
+
throw new Error( 'THREE.EXRLoader: Something is wrong with PIZ_COMPRESSION BITMAP_SIZE' );
|
|
1409
1419
|
|
|
1410
1420
|
}
|
|
1411
1421
|
|
|
@@ -1480,7 +1490,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
1480
1490
|
|
|
1481
1491
|
const compressed = info.array.slice( info.offset.value, info.offset.value + info.size );
|
|
1482
1492
|
|
|
1483
|
-
const rawBuffer =
|
|
1493
|
+
const rawBuffer = unzlibSync( compressed );
|
|
1484
1494
|
|
|
1485
1495
|
const byteSize = info.inputChannels.length * info.lines * info.columns * info.totalBytes;
|
|
1486
1496
|
const tmpBuffer = new ArrayBuffer( byteSize );
|
|
@@ -1548,6 +1558,205 @@ class EXRLoader extends DataTextureLoader {
|
|
|
1548
1558
|
|
|
1549
1559
|
}
|
|
1550
1560
|
|
|
1561
|
+
function uncompressB44( info ) {
|
|
1562
|
+
|
|
1563
|
+
const src = info.array;
|
|
1564
|
+
let srcOffset = info.offset.value;
|
|
1565
|
+
|
|
1566
|
+
const width = info.columns;
|
|
1567
|
+
const height = info.lines;
|
|
1568
|
+
const channels = info.inputChannels;
|
|
1569
|
+
const totalBytes = info.totalBytes;
|
|
1570
|
+
|
|
1571
|
+
// B44A allows 3-byte flat blocks; B44 always uses 14-byte blocks
|
|
1572
|
+
const isB44A = EXRHeader.compression === 'B44A_COMPRESSION';
|
|
1573
|
+
|
|
1574
|
+
// Output buffer organised as:
|
|
1575
|
+
// for each scanline y: [ ch0 pixels (w×2 bytes) | ch1 pixels | … ]
|
|
1576
|
+
const outBuffer = new Uint8Array( height * width * totalBytes );
|
|
1577
|
+
|
|
1578
|
+
// Reusable 4×4 block buffer
|
|
1579
|
+
const block = new Uint16Array( 16 );
|
|
1580
|
+
|
|
1581
|
+
// chByteOffset mirrors channelByteOffsets accumulation in setupDecoder
|
|
1582
|
+
let chByteOffset = 0;
|
|
1583
|
+
|
|
1584
|
+
for ( let c = 0; c < channels.length; c ++ ) {
|
|
1585
|
+
|
|
1586
|
+
const channel = channels[ c ];
|
|
1587
|
+
const pixelSize = channel.pixelType * 2; // HALF=2, FLOAT=4
|
|
1588
|
+
|
|
1589
|
+
// Effective dimensions for this channel (subsampled channels are smaller)
|
|
1590
|
+
const chanWidth = Math.ceil( width / channel.xSampling );
|
|
1591
|
+
const chanHeight = Math.ceil( height / channel.ySampling );
|
|
1592
|
+
const isFullRes = channel.xSampling === 1 && channel.ySampling === 1;
|
|
1593
|
+
|
|
1594
|
+
if ( channel.pixelType !== 1 ) {
|
|
1595
|
+
|
|
1596
|
+
// Non-HALF channels are stored raw, scanline by scanline
|
|
1597
|
+
for ( let y = 0; y < chanHeight; y ++ ) {
|
|
1598
|
+
|
|
1599
|
+
if ( isFullRes ) {
|
|
1600
|
+
|
|
1601
|
+
const lineBase = y * width * totalBytes + chByteOffset * width;
|
|
1602
|
+
for ( let x = 0; x < chanWidth * pixelSize; x ++ ) {
|
|
1603
|
+
|
|
1604
|
+
outBuffer[ lineBase + x ] = src[ srcOffset ++ ];
|
|
1605
|
+
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
} else {
|
|
1609
|
+
|
|
1610
|
+
srcOffset += chanWidth * pixelSize;
|
|
1611
|
+
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
chByteOffset += pixelSize;
|
|
1617
|
+
continue;
|
|
1618
|
+
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
// HALF channel — process 4×4 blocks at effective channel dimensions
|
|
1622
|
+
const numBlocksX = Math.ceil( chanWidth / 4 );
|
|
1623
|
+
const numBlocksY = Math.ceil( chanHeight / 4 );
|
|
1624
|
+
|
|
1625
|
+
for ( let by = 0; by < numBlocksY; by ++ ) {
|
|
1626
|
+
|
|
1627
|
+
for ( let bx = 0; bx < numBlocksX; bx ++ ) {
|
|
1628
|
+
|
|
1629
|
+
// B44A only: flat-block when shift ≥ 13 (byte[2] ≥ 52)
|
|
1630
|
+
if ( isB44A && src[ srcOffset + 2 ] >= 52 ) {
|
|
1631
|
+
|
|
1632
|
+
// 3-byte flat block — all 16 pixels share one value
|
|
1633
|
+
const t = ( src[ srcOffset ] << 8 ) | src[ srcOffset + 1 ];
|
|
1634
|
+
const h = ( t & 0x8000 ) ? ( t & 0x7fff ) : ( ( ~ t ) & 0xffff );
|
|
1635
|
+
block.fill( h );
|
|
1636
|
+
srcOffset += 3;
|
|
1637
|
+
|
|
1638
|
+
} else {
|
|
1639
|
+
|
|
1640
|
+
// 14-byte B44 block
|
|
1641
|
+
const s0 = ( src[ srcOffset ] << 8 ) | src[ srcOffset + 1 ];
|
|
1642
|
+
const shift = src[ srcOffset + 2 ] >> 2;
|
|
1643
|
+
const bias = 0x20 << shift;
|
|
1644
|
+
|
|
1645
|
+
// Reconstruct 16 ordered-magnitude values from 6-bit running deltas.
|
|
1646
|
+
// Prediction structure (row = 4 pixels wide):
|
|
1647
|
+
// column 0 top-to-bottom: s0 → s4 → s8 → s12
|
|
1648
|
+
// then row-wise: s0 → s1 → s2 → s3
|
|
1649
|
+
// s4 → s5 → s6 → s7 etc.
|
|
1650
|
+
|
|
1651
|
+
const s4 = ( s0 + ( ( ( src[ srcOffset + 2 ] << 4 ) | ( src[ srcOffset + 3 ] >> 4 ) ) & 0x3f ) * ( 1 << shift ) - bias ) & 0xffff;
|
|
1652
|
+
const s8 = ( s4 + ( ( ( src[ srcOffset + 3 ] << 2 ) | ( src[ srcOffset + 4 ] >> 6 ) ) & 0x3f ) * ( 1 << shift ) - bias ) & 0xffff;
|
|
1653
|
+
const s12 = ( s8 + ( src[ srcOffset + 4 ] & 0x3f ) * ( 1 << shift ) - bias ) & 0xffff;
|
|
1654
|
+
|
|
1655
|
+
const s1 = ( s0 + ( ( src[ srcOffset + 5 ] >> 2 ) & 0x3f ) * ( 1 << shift ) - bias ) & 0xffff;
|
|
1656
|
+
const s5 = ( s4 + ( ( ( src[ srcOffset + 5 ] << 4 ) | ( src[ srcOffset + 6 ] >> 4 ) ) & 0x3f ) * ( 1 << shift ) - bias ) & 0xffff;
|
|
1657
|
+
const s9 = ( s8 + ( ( ( src[ srcOffset + 6 ] << 2 ) | ( src[ srcOffset + 7 ] >> 6 ) ) & 0x3f ) * ( 1 << shift ) - bias ) & 0xffff;
|
|
1658
|
+
const s13 = ( s12 + ( src[ srcOffset + 7 ] & 0x3f ) * ( 1 << shift ) - bias ) & 0xffff;
|
|
1659
|
+
|
|
1660
|
+
const s2 = ( s1 + ( ( src[ srcOffset + 8 ] >> 2 ) & 0x3f ) * ( 1 << shift ) - bias ) & 0xffff;
|
|
1661
|
+
const s6 = ( s5 + ( ( ( src[ srcOffset + 8 ] << 4 ) | ( src[ srcOffset + 9 ] >> 4 ) ) & 0x3f ) * ( 1 << shift ) - bias ) & 0xffff;
|
|
1662
|
+
const s10 = ( s9 + ( ( ( src[ srcOffset + 9 ] << 2 ) | ( src[ srcOffset + 10 ] >> 6 ) ) & 0x3f ) * ( 1 << shift ) - bias ) & 0xffff;
|
|
1663
|
+
const s14 = ( s13 + ( src[ srcOffset + 10 ] & 0x3f ) * ( 1 << shift ) - bias ) & 0xffff;
|
|
1664
|
+
|
|
1665
|
+
const s3 = ( s2 + ( ( src[ srcOffset + 11 ] >> 2 ) & 0x3f ) * ( 1 << shift ) - bias ) & 0xffff;
|
|
1666
|
+
const s7 = ( s6 + ( ( ( src[ srcOffset + 11 ] << 4 ) | ( src[ srcOffset + 12 ] >> 4 ) ) & 0x3f ) * ( 1 << shift ) - bias ) & 0xffff;
|
|
1667
|
+
const s11 = ( s10 + ( ( ( src[ srcOffset + 12 ] << 2 ) | ( src[ srcOffset + 13 ] >> 6 ) ) & 0x3f ) * ( 1 << shift ) - bias ) & 0xffff;
|
|
1668
|
+
const s15 = ( s14 + ( src[ srcOffset + 13 ] & 0x3f ) * ( 1 << shift ) - bias ) & 0xffff;
|
|
1669
|
+
|
|
1670
|
+
// Convert ordered-magnitude → half-float:
|
|
1671
|
+
// positive (bit15=1): clear sign bit; negative (bit15=0): invert all bits
|
|
1672
|
+
const t = [ s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15 ];
|
|
1673
|
+
for ( let i = 0; i < 16; i ++ ) {
|
|
1674
|
+
|
|
1675
|
+
block[ i ] = ( t[ i ] & 0x8000 ) ? ( t[ i ] & 0x7fff ) : ( ( ~ t[ i ] ) & 0xffff );
|
|
1676
|
+
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
srcOffset += 14;
|
|
1680
|
+
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
// pLinear channels: data was stored as exp(x/8), convert back with 8·log(x)
|
|
1684
|
+
if ( channel.pLinear ) {
|
|
1685
|
+
|
|
1686
|
+
if ( b44LogTable === null ) {
|
|
1687
|
+
|
|
1688
|
+
b44LogTable = new Uint16Array( 65536 );
|
|
1689
|
+
for ( let i = 0; i < 65536; i ++ ) {
|
|
1690
|
+
|
|
1691
|
+
if ( ( i & 0x7c00 ) === 0x7c00 || i > 0x8000 ) {
|
|
1692
|
+
|
|
1693
|
+
b44LogTable[ i ] = 0;
|
|
1694
|
+
|
|
1695
|
+
} else {
|
|
1696
|
+
|
|
1697
|
+
const f = decodeFloat16( i );
|
|
1698
|
+
b44LogTable[ i ] = ( f <= 0 ) ? 0 : DataUtils.toHalfFloat( 8 * Math.log( f ) );
|
|
1699
|
+
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
for ( let i = 0; i < 16; i ++ ) block[ i ] = b44LogTable[ block[ i ] ];
|
|
1707
|
+
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
// Scatter the 16 pixels into the scanline-interleaved output buffer.
|
|
1711
|
+
// For subsampled channels (e.g. RY/BY with xSampling=ySampling=2) each decoded
|
|
1712
|
+
// pixel is replicated across its xSampling×ySampling footprint so the output
|
|
1713
|
+
// buffer has uniform full-resolution scanlines that parseScanline can read directly.
|
|
1714
|
+
for ( let py = 0; py < 4; py ++ ) {
|
|
1715
|
+
|
|
1716
|
+
const chanY = by * 4 + py;
|
|
1717
|
+
if ( chanY >= chanHeight ) continue;
|
|
1718
|
+
|
|
1719
|
+
for ( let px = 0; px < 4; px ++ ) {
|
|
1720
|
+
|
|
1721
|
+
const chanX = bx * 4 + px;
|
|
1722
|
+
if ( chanX >= chanWidth ) continue;
|
|
1723
|
+
|
|
1724
|
+
const val = block[ py * 4 + px ];
|
|
1725
|
+
|
|
1726
|
+
for ( let dy = 0; dy < channel.ySampling; dy ++ ) {
|
|
1727
|
+
|
|
1728
|
+
const fullY = chanY * channel.ySampling + dy;
|
|
1729
|
+
if ( fullY >= height ) continue;
|
|
1730
|
+
|
|
1731
|
+
for ( let dx = 0; dx < channel.xSampling; dx ++ ) {
|
|
1732
|
+
|
|
1733
|
+
const fullX = chanX * channel.xSampling + dx;
|
|
1734
|
+
if ( fullX >= width ) continue;
|
|
1735
|
+
|
|
1736
|
+
const outIdx = fullY * width * totalBytes + chByteOffset * width + fullX * 2;
|
|
1737
|
+
outBuffer[ outIdx ] = val & 0xff;
|
|
1738
|
+
outBuffer[ outIdx + 1 ] = ( val >> 8 ) & 0xff;
|
|
1739
|
+
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
chByteOffset += 2; // HALF = 2 bytes per pixel
|
|
1753
|
+
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
return new DataView( outBuffer.buffer );
|
|
1757
|
+
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1551
1760
|
function uncompressDWA( info ) {
|
|
1552
1761
|
|
|
1553
1762
|
const inDataView = info.viewer;
|
|
@@ -1572,7 +1781,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
1572
1781
|
};
|
|
1573
1782
|
|
|
1574
1783
|
if ( dwaHeader.version < 2 )
|
|
1575
|
-
throw new Error( 'EXRLoader
|
|
1784
|
+
throw new Error( 'THREE.EXRLoader: ' + EXRHeader.compression + ' version ' + dwaHeader.version + ' is unsupported' );
|
|
1576
1785
|
|
|
1577
1786
|
// Read channel ruleset information
|
|
1578
1787
|
const channelRules = new Array();
|
|
@@ -1625,11 +1834,14 @@ class EXRLoader extends DataTextureLoader {
|
|
|
1625
1834
|
|
|
1626
1835
|
const cd = channelData[ offset ];
|
|
1627
1836
|
|
|
1837
|
+
const dotIndex = cd.name.lastIndexOf( '.' );
|
|
1838
|
+
const suffix = dotIndex >= 0 ? cd.name.substring( dotIndex + 1 ) : cd.name;
|
|
1839
|
+
|
|
1628
1840
|
for ( let i = 0; i < channelRules.length; ++ i ) {
|
|
1629
1841
|
|
|
1630
1842
|
const rule = channelRules[ i ];
|
|
1631
1843
|
|
|
1632
|
-
if (
|
|
1844
|
+
if ( suffix === rule.name && cd.type === rule.type ) {
|
|
1633
1845
|
|
|
1634
1846
|
cd.compression = rule.compression;
|
|
1635
1847
|
|
|
@@ -1663,7 +1875,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
1663
1875
|
case DEFLATE:
|
|
1664
1876
|
|
|
1665
1877
|
const compressed = info.array.slice( inOffset.value, inOffset.value + dwaHeader.totalAcUncompressedCount );
|
|
1666
|
-
const data =
|
|
1878
|
+
const data = unzlibSync( compressed );
|
|
1667
1879
|
acBuffer = new Uint16Array( data.buffer );
|
|
1668
1880
|
inOffset.value += dwaHeader.totalAcUncompressedCount;
|
|
1669
1881
|
break;
|
|
@@ -1690,7 +1902,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
1690
1902
|
if ( dwaHeader.rleRawSize > 0 ) {
|
|
1691
1903
|
|
|
1692
1904
|
const compressed = info.array.slice( inOffset.value, inOffset.value + dwaHeader.rleCompressedSize );
|
|
1693
|
-
const data =
|
|
1905
|
+
const data = unzlibSync( compressed );
|
|
1694
1906
|
rleBuffer = decodeRunLength( data.buffer );
|
|
1695
1907
|
|
|
1696
1908
|
inOffset.value += dwaHeader.rleCompressedSize;
|
|
@@ -1767,7 +1979,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
1767
1979
|
break;
|
|
1768
1980
|
|
|
1769
1981
|
default:
|
|
1770
|
-
throw new Error( 'EXRLoader
|
|
1982
|
+
throw new Error( 'THREE.EXRLoader: unsupported channel compression' );
|
|
1771
1983
|
|
|
1772
1984
|
}
|
|
1773
1985
|
|
|
@@ -1870,17 +2082,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
1870
2082
|
|
|
1871
2083
|
const parseInt64 = function ( dataView, offset ) {
|
|
1872
2084
|
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
if ( 'getBigInt64' in DataView.prototype ) {
|
|
1876
|
-
|
|
1877
|
-
int = Number( dataView.getBigInt64( offset.value, true ) );
|
|
1878
|
-
|
|
1879
|
-
} else {
|
|
1880
|
-
|
|
1881
|
-
int = dataView.getUint32( offset.value + 4, true ) + Number( dataView.getUint32( offset.value, true ) << 32 );
|
|
1882
|
-
|
|
1883
|
-
}
|
|
2085
|
+
const int = Number( dataView.getBigInt64( offset.value, true ) );
|
|
1884
2086
|
|
|
1885
2087
|
offset.value += ULONG_SIZE;
|
|
1886
2088
|
|
|
@@ -2145,8 +2347,9 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2145
2347
|
|
|
2146
2348
|
return parseTimecode( dataView, offset );
|
|
2147
2349
|
|
|
2148
|
-
} else if ( type === 'preview' ) {
|
|
2350
|
+
} else if ( type === 'preview' || type === 'deepImageState' || type === 'idmanifest' ) {
|
|
2149
2351
|
|
|
2352
|
+
// Known metadata-only types: silently skip, they carry no pixel data.
|
|
2150
2353
|
offset.value += size;
|
|
2151
2354
|
return 'skipped';
|
|
2152
2355
|
|
|
@@ -2282,11 +2485,9 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2282
2485
|
|
|
2283
2486
|
offset.value += EXRDecoder.size;
|
|
2284
2487
|
|
|
2285
|
-
for ( let line_y = 0; line_y < EXRDecoder.
|
|
2488
|
+
for ( let line_y = 0; line_y < EXRDecoder.lines; line_y ++ ) {
|
|
2286
2489
|
|
|
2287
|
-
const
|
|
2288
|
-
const true_y = line_y + EXRDecoder.scanOrder( scan_y );
|
|
2289
|
-
if ( true_y >= EXRDecoder.height ) continue;
|
|
2490
|
+
const true_y = line + line_y;
|
|
2290
2491
|
|
|
2291
2492
|
const lineOffset = line_y * bytesPerLine;
|
|
2292
2493
|
const outLineOffset = ( EXRDecoder.height - 1 - true_y ) * EXRDecoder.outLineWidth;
|
|
@@ -2316,9 +2517,299 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2316
2517
|
|
|
2317
2518
|
}
|
|
2318
2519
|
|
|
2319
|
-
function
|
|
2520
|
+
function parseMultiPartScanline() {
|
|
2521
|
+
|
|
2522
|
+
const EXRDecoder = this;
|
|
2523
|
+
const chunkOffsets = EXRDecoder.chunkOffsets;
|
|
2524
|
+
const tmpOffset = { value: 0 };
|
|
2320
2525
|
|
|
2321
|
-
|
|
2526
|
+
for ( let chunkIdx = 0; chunkIdx < chunkOffsets.length; chunkIdx ++ ) {
|
|
2527
|
+
|
|
2528
|
+
const offset = { value: chunkOffsets[ chunkIdx ] };
|
|
2529
|
+
|
|
2530
|
+
offset.value += INT32_SIZE; // skip part number
|
|
2531
|
+
|
|
2532
|
+
const line = parseInt32( EXRDecoder.viewer, offset ) - EXRHeader.dataWindow.yMin;
|
|
2533
|
+
EXRDecoder.size = parseUint32( EXRDecoder.viewer, offset );
|
|
2534
|
+
EXRDecoder.lines = ( ( line + EXRDecoder.blockHeight > EXRDecoder.height ) ? ( EXRDecoder.height - line ) : EXRDecoder.blockHeight );
|
|
2535
|
+
|
|
2536
|
+
const bytesPerLine = EXRDecoder.columns * EXRDecoder.totalBytes;
|
|
2537
|
+
const isCompressed = EXRDecoder.size < EXRDecoder.lines * bytesPerLine;
|
|
2538
|
+
|
|
2539
|
+
const savedOffset = EXRDecoder.offset;
|
|
2540
|
+
EXRDecoder.offset = offset;
|
|
2541
|
+
const viewer = isCompressed ? EXRDecoder.uncompress( EXRDecoder ) : uncompressRAW( EXRDecoder );
|
|
2542
|
+
EXRDecoder.offset = savedOffset;
|
|
2543
|
+
|
|
2544
|
+
for ( let line_y = 0; line_y < EXRDecoder.lines; line_y ++ ) {
|
|
2545
|
+
|
|
2546
|
+
const true_y = line + line_y;
|
|
2547
|
+
|
|
2548
|
+
const lineOffset = line_y * bytesPerLine;
|
|
2549
|
+
const outLineOffset = ( EXRDecoder.height - 1 - true_y ) * EXRDecoder.outLineWidth;
|
|
2550
|
+
|
|
2551
|
+
for ( let channelID = 0; channelID < EXRDecoder.inputChannels.length; channelID ++ ) {
|
|
2552
|
+
|
|
2553
|
+
const name = EXRHeader.channels[ channelID ].name;
|
|
2554
|
+
const lOff = EXRDecoder.channelByteOffsets[ name ] * EXRDecoder.columns;
|
|
2555
|
+
const cOff = EXRDecoder.decodeChannels[ name ];
|
|
2556
|
+
|
|
2557
|
+
if ( cOff === undefined ) continue;
|
|
2558
|
+
|
|
2559
|
+
tmpOffset.value = lineOffset + lOff;
|
|
2560
|
+
|
|
2561
|
+
for ( let x = 0; x < EXRDecoder.columns; x ++ ) {
|
|
2562
|
+
|
|
2563
|
+
const outIndex = outLineOffset + x * EXRDecoder.outputChannels + cOff;
|
|
2564
|
+
EXRDecoder.byteArray[ outIndex ] = EXRDecoder.getter( viewer, tmpOffset );
|
|
2565
|
+
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
function decompressDeepData( array, compressedOffset, compressedSize, compression ) {
|
|
2577
|
+
|
|
2578
|
+
if ( compressedSize === 0 ) return null;
|
|
2579
|
+
|
|
2580
|
+
const compressed = array.slice( compressedOffset, compressedOffset + compressedSize );
|
|
2581
|
+
|
|
2582
|
+
switch ( compression ) {
|
|
2583
|
+
|
|
2584
|
+
case 'NO_COMPRESSION':
|
|
2585
|
+
return new DataView( compressed.buffer, compressed.byteOffset, compressed.byteLength );
|
|
2586
|
+
|
|
2587
|
+
case 'RLE_COMPRESSION': {
|
|
2588
|
+
|
|
2589
|
+
const rawBuffer = new Uint8Array( decodeRunLength( compressed.buffer.slice( compressed.byteOffset, compressed.byteOffset + compressed.byteLength ) ) );
|
|
2590
|
+
const tmpBuffer = new Uint8Array( rawBuffer.length );
|
|
2591
|
+
predictor( rawBuffer );
|
|
2592
|
+
interleaveScalar( rawBuffer, tmpBuffer );
|
|
2593
|
+
return new DataView( tmpBuffer.buffer );
|
|
2594
|
+
|
|
2595
|
+
}
|
|
2596
|
+
|
|
2597
|
+
case 'ZIPS_COMPRESSION': {
|
|
2598
|
+
|
|
2599
|
+
const rawBuffer = unzlibSync( compressed );
|
|
2600
|
+
const tmpBuffer = new Uint8Array( rawBuffer.length );
|
|
2601
|
+
predictor( rawBuffer );
|
|
2602
|
+
interleaveScalar( rawBuffer, tmpBuffer );
|
|
2603
|
+
return new DataView( tmpBuffer.buffer );
|
|
2604
|
+
|
|
2605
|
+
}
|
|
2606
|
+
|
|
2607
|
+
default:
|
|
2608
|
+
throw new Error( 'THREE.EXRLoader: ' + compression + ' is unsupported for deep data' );
|
|
2609
|
+
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
function parseDeepScanline() {
|
|
2615
|
+
|
|
2616
|
+
const EXRDecoder = this;
|
|
2617
|
+
const chunkOffsets = EXRDecoder.chunkOffsets;
|
|
2618
|
+
const width = EXRDecoder.width;
|
|
2619
|
+
const height = EXRDecoder.height;
|
|
2620
|
+
const deepChannels = EXRDecoder.deepChannels;
|
|
2621
|
+
const compression = EXRHeader.compression;
|
|
2622
|
+
const isMultiPart = EXRDecoder.multiPart;
|
|
2623
|
+
|
|
2624
|
+
// Build a map from channel name to decode output slot
|
|
2625
|
+
const decodeChannels = EXRDecoder.decodeChannels;
|
|
2626
|
+
const outputChannels = EXRDecoder.outputChannels;
|
|
2627
|
+
const isHalfOutput = EXRDecoder.byteArray instanceof Uint16Array;
|
|
2628
|
+
|
|
2629
|
+
// Find the alpha channel index in deepChannels (for compositing)
|
|
2630
|
+
let alphaChannelIdx = - 1;
|
|
2631
|
+
|
|
2632
|
+
for ( let i = 0; i < deepChannels.length; i ++ ) {
|
|
2633
|
+
|
|
2634
|
+
if ( deepChannels[ i ].name === 'A' ) {
|
|
2635
|
+
|
|
2636
|
+
alphaChannelIdx = i;
|
|
2637
|
+
break;
|
|
2638
|
+
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2643
|
+
for ( let chunkIdx = 0; chunkIdx < chunkOffsets.length; chunkIdx ++ ) {
|
|
2644
|
+
|
|
2645
|
+
const chunkOffset = { value: chunkOffsets[ chunkIdx ] };
|
|
2646
|
+
|
|
2647
|
+
// Multi-part files have a part number prefix per chunk
|
|
2648
|
+
if ( isMultiPart ) chunkOffset.value += INT32_SIZE;
|
|
2649
|
+
|
|
2650
|
+
const line = parseInt32( EXRDecoder.viewer, chunkOffset ) - EXRHeader.dataWindow.yMin;
|
|
2651
|
+
|
|
2652
|
+
// Read deep scanline sizes
|
|
2653
|
+
const sctCompressedSize = parseInt64( EXRDecoder.viewer, chunkOffset );
|
|
2654
|
+
const dataCompressedSize = parseInt64( EXRDecoder.viewer, chunkOffset );
|
|
2655
|
+
parseInt64( EXRDecoder.viewer, chunkOffset ); // uncompressed data size (unused)
|
|
2656
|
+
|
|
2657
|
+
// Decompress sample count table
|
|
2658
|
+
const sctView = decompressDeepData( EXRDecoder.array, chunkOffset.value, sctCompressedSize, compression );
|
|
2659
|
+
chunkOffset.value += sctCompressedSize;
|
|
2660
|
+
|
|
2661
|
+
if ( sctView === null ) continue;
|
|
2662
|
+
|
|
2663
|
+
// Parse cumulative sample counts
|
|
2664
|
+
const cumulativeCounts = new Uint32Array( width );
|
|
2665
|
+
|
|
2666
|
+
for ( let x = 0; x < width; x ++ ) {
|
|
2667
|
+
|
|
2668
|
+
cumulativeCounts[ x ] = sctView.getUint32( x * 4, true );
|
|
2669
|
+
|
|
2670
|
+
}
|
|
2671
|
+
|
|
2672
|
+
const totalSamples = cumulativeCounts[ width - 1 ];
|
|
2673
|
+
|
|
2674
|
+
if ( totalSamples === 0 ) {
|
|
2675
|
+
|
|
2676
|
+
chunkOffset.value += dataCompressedSize;
|
|
2677
|
+
continue;
|
|
2678
|
+
|
|
2679
|
+
}
|
|
2680
|
+
|
|
2681
|
+
// Decompress pixel data
|
|
2682
|
+
const pixelView = decompressDeepData( EXRDecoder.array, chunkOffset.value, dataCompressedSize, compression );
|
|
2683
|
+
|
|
2684
|
+
// Compute channel byte offsets within the decompressed pixel data.
|
|
2685
|
+
// Deep data layout: channels are contiguous, each has totalSamples values.
|
|
2686
|
+
const channelOffsets = [];
|
|
2687
|
+
let bytePos = 0;
|
|
2688
|
+
|
|
2689
|
+
for ( let i = 0; i < deepChannels.length; i ++ ) {
|
|
2690
|
+
|
|
2691
|
+
channelOffsets.push( bytePos );
|
|
2692
|
+
bytePos += totalSamples * deepChannels[ i ].bytesPerSample;
|
|
2693
|
+
|
|
2694
|
+
}
|
|
2695
|
+
|
|
2696
|
+
// Flatten deep samples: front-to-back composite with premultiplied alpha
|
|
2697
|
+
const outLineOffset = ( height - 1 - line ) * EXRDecoder.outLineWidth;
|
|
2698
|
+
|
|
2699
|
+
for ( let x = 0; x < width; x ++ ) {
|
|
2700
|
+
|
|
2701
|
+
const startSample = x === 0 ? 0 : cumulativeCounts[ x - 1 ];
|
|
2702
|
+
const endSample = cumulativeCounts[ x ];
|
|
2703
|
+
const numSamples = endSample - startSample;
|
|
2704
|
+
|
|
2705
|
+
if ( numSamples === 0 ) continue;
|
|
2706
|
+
|
|
2707
|
+
// Composite samples front-to-back (premultiplied alpha)
|
|
2708
|
+
const composited = new Float32Array( outputChannels );
|
|
2709
|
+
let compositedAlpha = 0;
|
|
2710
|
+
|
|
2711
|
+
for ( let s = 0; s < numSamples; s ++ ) {
|
|
2712
|
+
|
|
2713
|
+
const sampleIdx = startSample + s;
|
|
2714
|
+
const factor = 1 - compositedAlpha;
|
|
2715
|
+
|
|
2716
|
+
if ( factor <= 0 ) break;
|
|
2717
|
+
|
|
2718
|
+
// Read alpha for this sample
|
|
2719
|
+
let sampleAlpha = 1;
|
|
2720
|
+
|
|
2721
|
+
if ( alphaChannelIdx >= 0 ) {
|
|
2722
|
+
|
|
2723
|
+
const aBps = deepChannels[ alphaChannelIdx ].bytesPerSample;
|
|
2724
|
+
const aOff = channelOffsets[ alphaChannelIdx ] + sampleIdx * aBps;
|
|
2725
|
+
|
|
2726
|
+
sampleAlpha = aBps === 2
|
|
2727
|
+
? decodeFloat16( pixelView.getUint16( aOff, true ) )
|
|
2728
|
+
: pixelView.getFloat32( aOff, true );
|
|
2729
|
+
|
|
2730
|
+
}
|
|
2731
|
+
|
|
2732
|
+
// Read and composite each output channel
|
|
2733
|
+
for ( let ci = 0; ci < deepChannels.length; ci ++ ) {
|
|
2734
|
+
|
|
2735
|
+
const ch = deepChannels[ ci ];
|
|
2736
|
+
const cOff = decodeChannels[ ch.name ];
|
|
2737
|
+
|
|
2738
|
+
if ( cOff === undefined ) continue;
|
|
2739
|
+
|
|
2740
|
+
const bps = ch.bytesPerSample;
|
|
2741
|
+
const dataOff = channelOffsets[ ci ] + sampleIdx * bps;
|
|
2742
|
+
|
|
2743
|
+
const value = bps === 2
|
|
2744
|
+
? decodeFloat16( pixelView.getUint16( dataOff, true ) )
|
|
2745
|
+
: pixelView.getFloat32( dataOff, true );
|
|
2746
|
+
|
|
2747
|
+
composited[ cOff ] += value * factor;
|
|
2748
|
+
|
|
2749
|
+
}
|
|
2750
|
+
|
|
2751
|
+
compositedAlpha += sampleAlpha * factor;
|
|
2752
|
+
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2755
|
+
// If alpha channel is being output, set it
|
|
2756
|
+
if ( decodeChannels[ 'A' ] !== undefined ) {
|
|
2757
|
+
|
|
2758
|
+
composited[ decodeChannels[ 'A' ] ] = compositedAlpha;
|
|
2759
|
+
|
|
2760
|
+
}
|
|
2761
|
+
|
|
2762
|
+
// Write to output buffer
|
|
2763
|
+
const outIndex = outLineOffset + x * outputChannels;
|
|
2764
|
+
|
|
2765
|
+
for ( let c = 0; c < outputChannels; c ++ ) {
|
|
2766
|
+
|
|
2767
|
+
EXRDecoder.byteArray[ outIndex + c ] = isHalfOutput
|
|
2768
|
+
? DataUtils.toHalfFloat( composited[ c ] )
|
|
2769
|
+
: composited[ c ];
|
|
2770
|
+
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2773
|
+
}
|
|
2774
|
+
|
|
2775
|
+
}
|
|
2776
|
+
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2779
|
+
function parsePartHeader( dataView, buffer, offset ) {
|
|
2780
|
+
|
|
2781
|
+
const header = {};
|
|
2782
|
+
let hasAttributes = false;
|
|
2783
|
+
|
|
2784
|
+
while ( true ) {
|
|
2785
|
+
|
|
2786
|
+
const attributeName = parseNullTerminatedString( buffer, offset );
|
|
2787
|
+
|
|
2788
|
+
if ( attributeName === '' ) break;
|
|
2789
|
+
|
|
2790
|
+
hasAttributes = true;
|
|
2791
|
+
|
|
2792
|
+
const attributeType = parseNullTerminatedString( buffer, offset );
|
|
2793
|
+
const attributeSize = parseUint32( dataView, offset );
|
|
2794
|
+
const attributeValue = parseValue( dataView, buffer, offset, attributeType, attributeSize );
|
|
2795
|
+
|
|
2796
|
+
if ( attributeValue === undefined ) {
|
|
2797
|
+
|
|
2798
|
+
console.warn( `THREE.EXRLoader: Skipped unknown header attribute type \'${attributeType}\'.` );
|
|
2799
|
+
|
|
2800
|
+
} else {
|
|
2801
|
+
|
|
2802
|
+
header[ attributeName ] = attributeValue;
|
|
2803
|
+
|
|
2804
|
+
}
|
|
2805
|
+
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
return hasAttributes ? header : null;
|
|
2809
|
+
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2812
|
+
function parseHeader( dataView, buffer, offset ) {
|
|
2322
2813
|
|
|
2323
2814
|
if ( dataView.getUint32( 0, true ) != 20000630 ) { // magic
|
|
2324
2815
|
|
|
@@ -2326,11 +2817,11 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2326
2817
|
|
|
2327
2818
|
}
|
|
2328
2819
|
|
|
2329
|
-
|
|
2820
|
+
const version = dataView.getUint8( 4 );
|
|
2330
2821
|
|
|
2331
2822
|
const spec = dataView.getUint8( 5 ); // fullMask
|
|
2332
2823
|
|
|
2333
|
-
|
|
2824
|
+
const flags = {
|
|
2334
2825
|
singleTile: !! ( spec & 2 ),
|
|
2335
2826
|
longName: !! ( spec & 4 ),
|
|
2336
2827
|
deepFormat: !! ( spec & 8 ),
|
|
@@ -2341,44 +2832,43 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2341
2832
|
|
|
2342
2833
|
offset.value = 8; // start at 8 - after pre-amble
|
|
2343
2834
|
|
|
2344
|
-
|
|
2835
|
+
const headers = [];
|
|
2345
2836
|
|
|
2346
|
-
|
|
2837
|
+
if ( flags.multiPart ) {
|
|
2347
2838
|
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
keepReading = false;
|
|
2353
|
-
|
|
2354
|
-
} else {
|
|
2839
|
+
// Multi-part files: parse all part headers.
|
|
2840
|
+
// Each part header ends with an empty attribute name (null byte).
|
|
2841
|
+
// The header section ends when a null byte is read with no preceding attributes.
|
|
2355
2842
|
|
|
2356
|
-
|
|
2357
|
-
const attributeSize = parseUint32( dataView, offset );
|
|
2358
|
-
const attributeValue = parseValue( dataView, buffer, offset, attributeType, attributeSize );
|
|
2843
|
+
while ( true ) {
|
|
2359
2844
|
|
|
2360
|
-
|
|
2845
|
+
const header = parsePartHeader( dataView, buffer, offset );
|
|
2846
|
+
if ( header === null ) break;
|
|
2361
2847
|
|
|
2362
|
-
|
|
2848
|
+
header.version = version;
|
|
2849
|
+
header.spec = flags;
|
|
2850
|
+
headers.push( header );
|
|
2363
2851
|
|
|
2364
|
-
|
|
2852
|
+
}
|
|
2365
2853
|
|
|
2366
|
-
|
|
2854
|
+
if ( headers.length === 0 ) {
|
|
2367
2855
|
|
|
2368
|
-
|
|
2856
|
+
throw new Error( 'THREE.EXRLoader: No valid part headers found.' );
|
|
2369
2857
|
|
|
2370
2858
|
}
|
|
2371
2859
|
|
|
2372
|
-
}
|
|
2860
|
+
} else {
|
|
2373
2861
|
|
|
2374
|
-
|
|
2862
|
+
// Single-part (standard or deep): one header
|
|
2375
2863
|
|
|
2376
|
-
|
|
2377
|
-
|
|
2864
|
+
const header = parsePartHeader( dataView, buffer, offset );
|
|
2865
|
+
header.version = version;
|
|
2866
|
+
header.spec = flags;
|
|
2867
|
+
headers.push( header );
|
|
2378
2868
|
|
|
2379
2869
|
}
|
|
2380
2870
|
|
|
2381
|
-
return
|
|
2871
|
+
return headers;
|
|
2382
2872
|
|
|
2383
2873
|
}
|
|
2384
2874
|
|
|
@@ -2394,7 +2884,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2394
2884
|
inputChannels: EXRHeader.channels,
|
|
2395
2885
|
channelByteOffsets: {},
|
|
2396
2886
|
shouldExpand: false,
|
|
2397
|
-
|
|
2887
|
+
yCbCr: false,
|
|
2398
2888
|
totalBytes: null,
|
|
2399
2889
|
columns: null,
|
|
2400
2890
|
lines: null,
|
|
@@ -2437,6 +2927,12 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2437
2927
|
EXRDecoder.uncompress = uncompressPXR;
|
|
2438
2928
|
break;
|
|
2439
2929
|
|
|
2930
|
+
case 'B44_COMPRESSION':
|
|
2931
|
+
case 'B44A_COMPRESSION':
|
|
2932
|
+
EXRDecoder.blockHeight = 32;
|
|
2933
|
+
EXRDecoder.uncompress = uncompressB44;
|
|
2934
|
+
break;
|
|
2935
|
+
|
|
2440
2936
|
case 'DWAA_COMPRESSION':
|
|
2441
2937
|
EXRDecoder.blockHeight = 32;
|
|
2442
2938
|
EXRDecoder.uncompress = uncompressDWA;
|
|
@@ -2448,7 +2944,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2448
2944
|
break;
|
|
2449
2945
|
|
|
2450
2946
|
default:
|
|
2451
|
-
throw new Error( 'EXRLoader
|
|
2947
|
+
throw new Error( 'THREE.EXRLoader: ' + EXRHeader.compression + ' is unsupported' );
|
|
2452
2948
|
|
|
2453
2949
|
}
|
|
2454
2950
|
|
|
@@ -2457,6 +2953,8 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2457
2953
|
|
|
2458
2954
|
switch ( channel.name ) {
|
|
2459
2955
|
|
|
2956
|
+
case 'BY':
|
|
2957
|
+
case 'RY':
|
|
2460
2958
|
case 'Y':
|
|
2461
2959
|
case 'R':
|
|
2462
2960
|
case 'G':
|
|
@@ -2474,7 +2972,12 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2474
2972
|
let invalidOutput = false;
|
|
2475
2973
|
|
|
2476
2974
|
// Validate if input texture contain supported channels
|
|
2477
|
-
if ( channels.
|
|
2975
|
+
if ( channels.Y && channels.RY && channels.BY ) {
|
|
2976
|
+
|
|
2977
|
+
EXRDecoder.outputChannels = 4;
|
|
2978
|
+
EXRDecoder.yCbCr = true;
|
|
2979
|
+
|
|
2980
|
+
} else if ( channels.R && channels.G && channels.B ) {
|
|
2478
2981
|
|
|
2479
2982
|
EXRDecoder.outputChannels = 4;
|
|
2480
2983
|
|
|
@@ -2484,7 +2987,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2484
2987
|
|
|
2485
2988
|
} else {
|
|
2486
2989
|
|
|
2487
|
-
throw new Error( 'EXRLoader
|
|
2990
|
+
throw new Error( 'THREE.EXRLoader: file contains unsupported data channels.' );
|
|
2488
2991
|
|
|
2489
2992
|
}
|
|
2490
2993
|
|
|
@@ -2563,7 +3066,17 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2563
3066
|
|
|
2564
3067
|
}
|
|
2565
3068
|
|
|
2566
|
-
if ( invalidOutput ) throw new Error( 'EXRLoader
|
|
3069
|
+
if ( invalidOutput ) throw new Error( 'THREE.EXRLoader: invalid output format for specified file.' );
|
|
3070
|
+
|
|
3071
|
+
// Luminance/chroma images always decode to RGBA; override whatever the output-format switch selected.
|
|
3072
|
+
if ( EXRDecoder.yCbCr ) {
|
|
3073
|
+
|
|
3074
|
+
EXRDecoder.format = RGBAFormat;
|
|
3075
|
+
EXRDecoder.outputChannels = 4;
|
|
3076
|
+
EXRDecoder.decodeChannels = { Y: 0, RY: 1, BY: 2 };
|
|
3077
|
+
fillAlpha = true;
|
|
3078
|
+
|
|
3079
|
+
}
|
|
2567
3080
|
|
|
2568
3081
|
if ( EXRDecoder.type == 1 ) {
|
|
2569
3082
|
|
|
@@ -2596,7 +3109,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2596
3109
|
|
|
2597
3110
|
} else {
|
|
2598
3111
|
|
|
2599
|
-
throw new Error( 'EXRLoader
|
|
3112
|
+
throw new Error( 'THREE.EXRLoader: unsupported pixelType ' + EXRDecoder.type + ' for ' + EXRHeader.compression + '.' );
|
|
2600
3113
|
|
|
2601
3114
|
}
|
|
2602
3115
|
|
|
@@ -2644,17 +3157,33 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2644
3157
|
EXRDecoder.totalBytes = byteOffset;
|
|
2645
3158
|
EXRDecoder.outLineWidth = EXRDecoder.width * EXRDecoder.outputChannels;
|
|
2646
3159
|
|
|
2647
|
-
if ( EXRHeader.
|
|
3160
|
+
if ( EXRHeader.spec.deepFormat ) {
|
|
2648
3161
|
|
|
2649
|
-
|
|
3162
|
+
// Deep format: offset tables are already parsed in the main flow.
|
|
3163
|
+
// Compute per-channel byte sizes for the deep pixel data layout.
|
|
2650
3164
|
|
|
2651
|
-
|
|
3165
|
+
EXRDecoder.deepChannels = [];
|
|
3166
|
+
let deepBytesPerSample = 0;
|
|
2652
3167
|
|
|
2653
|
-
|
|
3168
|
+
for ( const channel of EXRHeader.channels ) {
|
|
2654
3169
|
|
|
2655
|
-
|
|
3170
|
+
// UINT=0→4bytes, HALF=1→2bytes, FLOAT=2→4bytes
|
|
3171
|
+
const bytesPerSample = channel.pixelType === 0 ? 4 : channel.pixelType * 2;
|
|
3172
|
+
EXRDecoder.deepChannels.push( {
|
|
3173
|
+
name: channel.name,
|
|
3174
|
+
pixelType: channel.pixelType,
|
|
3175
|
+
bytesPerSample: bytesPerSample,
|
|
3176
|
+
} );
|
|
3177
|
+
deepBytesPerSample += bytesPerSample;
|
|
3178
|
+
|
|
3179
|
+
}
|
|
3180
|
+
|
|
3181
|
+
EXRDecoder.deepBytesPerSample = deepBytesPerSample;
|
|
3182
|
+
EXRDecoder.chunkOffsets = EXRHeader._chunkOffsets;
|
|
3183
|
+
EXRDecoder.multiPart = EXRHeader.spec.multiPart;
|
|
3184
|
+
EXRDecoder.decode = parseDeepScanline.bind( EXRDecoder );
|
|
2656
3185
|
|
|
2657
|
-
if ( EXRHeader.spec.singleTile ) {
|
|
3186
|
+
} else if ( EXRHeader.spec.singleTile ) {
|
|
2658
3187
|
|
|
2659
3188
|
EXRDecoder.blockHeight = EXRHeader.tiles.ySize;
|
|
2660
3189
|
EXRDecoder.blockWidth = EXRHeader.tiles.xSize;
|
|
@@ -2674,6 +3203,13 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2674
3203
|
|
|
2675
3204
|
EXRDecoder.decode = parseTiles.bind( EXRDecoder );
|
|
2676
3205
|
|
|
3206
|
+
} else if ( EXRHeader.spec.multiPart ) {
|
|
3207
|
+
|
|
3208
|
+
// Multi-part scanline: offsets already parsed in main flow.
|
|
3209
|
+
EXRDecoder.blockWidth = EXRDecoder.width;
|
|
3210
|
+
EXRDecoder.chunkOffsets = EXRHeader._chunkOffsets;
|
|
3211
|
+
EXRDecoder.decode = parseMultiPartScanline.bind( EXRDecoder );
|
|
3212
|
+
|
|
2677
3213
|
} else {
|
|
2678
3214
|
|
|
2679
3215
|
EXRDecoder.blockWidth = EXRDecoder.width;
|
|
@@ -2696,7 +3232,38 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2696
3232
|
const uInt8Array = new Uint8Array( buffer );
|
|
2697
3233
|
|
|
2698
3234
|
// get header information and validate format.
|
|
2699
|
-
const
|
|
3235
|
+
const EXRHeaders = parseHeader( bufferDataView, buffer, offset );
|
|
3236
|
+
|
|
3237
|
+
// select part to decode
|
|
3238
|
+
const partIndex = Math.max( 0, Math.min( this.part, EXRHeaders.length - 1 ) );
|
|
3239
|
+
const EXRHeader = EXRHeaders[ partIndex ];
|
|
3240
|
+
|
|
3241
|
+
// for multi-part deep files, skip offset tables for other parts
|
|
3242
|
+
if ( EXRHeader.spec.multiPart || EXRHeader.spec.deepFormat ) {
|
|
3243
|
+
|
|
3244
|
+
for ( let p = 0; p < EXRHeaders.length; p ++ ) {
|
|
3245
|
+
|
|
3246
|
+
const chunkCount = EXRHeaders[ p ].chunkCount;
|
|
3247
|
+
|
|
3248
|
+
if ( p === partIndex ) {
|
|
3249
|
+
|
|
3250
|
+
// store offset table for the selected part
|
|
3251
|
+
EXRHeader._chunkOffsets = [];
|
|
3252
|
+
|
|
3253
|
+
for ( let i = 0; i < chunkCount; i ++ )
|
|
3254
|
+
EXRHeader._chunkOffsets.push( parseInt64( bufferDataView, offset ) );
|
|
3255
|
+
|
|
3256
|
+
} else {
|
|
3257
|
+
|
|
3258
|
+
// skip other parts' offset tables
|
|
3259
|
+
for ( let i = 0; i < chunkCount; i ++ )
|
|
3260
|
+
parseInt64( bufferDataView, offset );
|
|
3261
|
+
|
|
3262
|
+
}
|
|
3263
|
+
|
|
3264
|
+
}
|
|
3265
|
+
|
|
3266
|
+
}
|
|
2700
3267
|
|
|
2701
3268
|
// get input compression information and prepare decoding.
|
|
2702
3269
|
const EXRDecoder = setupDecoder( EXRHeader, bufferDataView, uInt8Array, offset, this.type, this.outputFormat );
|
|
@@ -2723,6 +3290,51 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2723
3290
|
|
|
2724
3291
|
}
|
|
2725
3292
|
|
|
3293
|
+
// Luminance/chroma → RGB conversion (second pass).
|
|
3294
|
+
// Y/RY/BY were decoded into output slots 0/1/2; convert in-place using Rec.709 coefficients:
|
|
3295
|
+
// R = ( 1 + RY ) * Y, B = ( 1 + BY ) * Y, G = ( Y − R·0.2126 − B·0.0722 ) / 0.7152
|
|
3296
|
+
if ( EXRDecoder.yCbCr ) {
|
|
3297
|
+
|
|
3298
|
+
const byteArray = EXRDecoder.byteArray;
|
|
3299
|
+
const nPixels = EXRDecoder.width * EXRDecoder.height;
|
|
3300
|
+
|
|
3301
|
+
if ( this.type === HalfFloatType ) {
|
|
3302
|
+
|
|
3303
|
+
for ( let i = 0; i < nPixels; i ++ ) {
|
|
3304
|
+
|
|
3305
|
+
const base = i * 4;
|
|
3306
|
+
const Y = decodeFloat16( byteArray[ base ] );
|
|
3307
|
+
const RY = decodeFloat16( byteArray[ base + 1 ] );
|
|
3308
|
+
const BY = decodeFloat16( byteArray[ base + 2 ] );
|
|
3309
|
+
const R = ( 1 + RY ) * Y;
|
|
3310
|
+
const B = ( 1 + BY ) * Y;
|
|
3311
|
+
const G = ( Y - R * 0.2126 - B * 0.0722 ) / 0.7152;
|
|
3312
|
+
byteArray[ base ] = DataUtils.toHalfFloat( Math.max( 0, R ) );
|
|
3313
|
+
byteArray[ base + 1 ] = DataUtils.toHalfFloat( Math.max( 0, G ) );
|
|
3314
|
+
byteArray[ base + 2 ] = DataUtils.toHalfFloat( Math.max( 0, B ) );
|
|
3315
|
+
|
|
3316
|
+
}
|
|
3317
|
+
|
|
3318
|
+
} else {
|
|
3319
|
+
|
|
3320
|
+
for ( let i = 0; i < nPixels; i ++ ) {
|
|
3321
|
+
|
|
3322
|
+
const base = i * 4;
|
|
3323
|
+
const Y = byteArray[ base ];
|
|
3324
|
+
const RY = byteArray[ base + 1 ];
|
|
3325
|
+
const BY = byteArray[ base + 2 ];
|
|
3326
|
+
const R = ( 1 + RY ) * Y;
|
|
3327
|
+
const B = ( 1 + BY ) * Y;
|
|
3328
|
+
byteArray[ base ] = Math.max( 0, R );
|
|
3329
|
+
byteArray[ base + 1 ] = Math.max( 0, ( Y - R * 0.2126 - B * 0.0722 ) / 0.7152 );
|
|
3330
|
+
byteArray[ base + 2 ] = Math.max( 0, B );
|
|
3331
|
+
|
|
3332
|
+
}
|
|
3333
|
+
|
|
3334
|
+
}
|
|
3335
|
+
|
|
3336
|
+
}
|
|
3337
|
+
|
|
2726
3338
|
return {
|
|
2727
3339
|
header: EXRHeader,
|
|
2728
3340
|
width: EXRDecoder.width,
|
|
@@ -2731,6 +3343,10 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2731
3343
|
format: EXRDecoder.format,
|
|
2732
3344
|
colorSpace: EXRDecoder.colorSpace,
|
|
2733
3345
|
type: this.type,
|
|
3346
|
+
minFilter: LinearFilter,
|
|
3347
|
+
magFilter: LinearFilter,
|
|
3348
|
+
generateMipmaps: false,
|
|
3349
|
+
flipY: false,
|
|
2734
3350
|
};
|
|
2735
3351
|
|
|
2736
3352
|
}
|
|
@@ -2761,21 +3377,16 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2761
3377
|
|
|
2762
3378
|
}
|
|
2763
3379
|
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
texture.generateMipmaps = false;
|
|
2772
|
-
texture.flipY = false;
|
|
2773
|
-
|
|
2774
|
-
if ( onLoad ) onLoad( texture, texData );
|
|
2775
|
-
|
|
2776
|
-
}
|
|
3380
|
+
/**
|
|
3381
|
+
* For multi-part EXR files, sets which part to load.
|
|
3382
|
+
*
|
|
3383
|
+
* @param {number} value - The part index to load.
|
|
3384
|
+
* @return {EXRLoader} A reference to this loader.
|
|
3385
|
+
*/
|
|
3386
|
+
setPart( value ) {
|
|
2777
3387
|
|
|
2778
|
-
|
|
3388
|
+
this.part = value;
|
|
3389
|
+
return this;
|
|
2779
3390
|
|
|
2780
3391
|
}
|
|
2781
3392
|
|