@needle-tools/three 0.145.4 → 0.146.2
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/README.md +1 -1
- package/build/three.cjs +32586 -35951
- package/build/three.js +32600 -35965
- package/build/three.min.js +6 -7
- package/build/three.module.js +1547 -1154
- package/examples/js/animation/AnimationClipCreator.js +0 -8
- package/examples/js/animation/CCDIKSolver.js +49 -66
- package/examples/js/animation/MMDAnimationHelper.js +66 -137
- package/examples/js/animation/MMDPhysics.js +70 -134
- package/examples/js/cameras/CinematicCamera.js +33 -22
- package/examples/js/controls/ArcballControls.js +138 -405
- package/examples/js/controls/DragControls.js +8 -33
- package/examples/js/controls/FirstPersonControls.js +32 -54
- package/examples/js/controls/FlyControls.js +29 -55
- package/examples/js/controls/OrbitControls.js +85 -95
- package/examples/js/controls/PointerLockControls.js +5 -14
- package/examples/js/controls/TrackballControls.js +33 -86
- package/examples/js/controls/TransformControls.js +84 -169
- package/examples/js/csm/CSM.js +4 -39
- package/examples/js/csm/CSMFrustum.js +3 -9
- package/examples/js/csm/CSMHelper.js +24 -4
- package/examples/js/csm/CSMShader.js +2 -6
- package/examples/js/curves/CurveExtras.js +27 -27
- package/examples/js/curves/NURBSCurve.js +4 -16
- package/examples/js/curves/NURBSSurface.js +3 -9
- package/examples/js/curves/NURBSUtils.js +8 -45
- package/examples/js/effects/AnaglyphEffect.js +4 -18
- package/examples/js/effects/AsciiEffect.js +32 -31
- package/examples/js/effects/OutlineEffect.js +26 -30
- package/examples/js/effects/ParallaxBarrierEffect.js +0 -13
- package/examples/js/effects/PeppersGhostEffect.js +12 -39
- package/examples/js/effects/StereoEffect.js +0 -4
- package/examples/js/environments/RoomEnvironment.js +12 -10
- package/examples/js/exporters/ColladaExporter.js +48 -65
- package/examples/js/exporters/DRACOExporter.js +22 -22
- package/examples/js/exporters/EXRExporter.js +15 -18
- package/examples/js/exporters/GLTFExporter.js +143 -261
- package/examples/js/exporters/MMDExporter.js +5 -12
- package/examples/js/exporters/OBJExporter.js +42 -33
- package/examples/js/exporters/PLYExporter.js +38 -33
- package/examples/js/exporters/STLExporter.js +5 -7
- package/examples/js/exporters/USDZExporter.js +110 -25
- package/examples/js/geometries/BoxLineGeometry.js +0 -1
- package/examples/js/geometries/ConvexGeometry.js +11 -6
- package/examples/js/geometries/DecalGeometry.js +53 -20
- package/examples/js/geometries/LightningStrike.js +54 -67
- package/examples/js/geometries/ParametricGeometries.js +8 -7
- package/examples/js/geometries/ParametricGeometry.js +25 -12
- package/examples/js/geometries/RoundedBoxGeometry.js +21 -19
- package/examples/js/geometries/TeapotGeometry.js +54 -50
- package/examples/js/geometries/TextGeometry.js +6 -4
- package/examples/js/helpers/LightProbeHelper.js +1 -2
- package/examples/js/helpers/OctreeHelper.js +22 -20
- package/examples/js/helpers/PositionalAudioHelper.js +8 -6
- package/examples/js/helpers/RectAreaLightHelper.js +6 -7
- package/examples/js/helpers/VertexNormalsHelper.js +15 -13
- package/examples/js/helpers/VertexTangentsHelper.js +15 -9
- package/examples/js/helpers/ViewHelper.js +31 -16
- package/examples/js/interactive/HTMLMesh.js +22 -33
- package/examples/js/interactive/InteractiveGroup.js +6 -12
- package/examples/js/interactive/SelectionBox.js +3 -70
- package/examples/js/interactive/SelectionHelper.js +0 -8
- package/examples/js/lights/LightProbeGenerator.js +32 -39
- package/examples/js/lights/RectAreaLightUniformsLib.js +5 -1
- package/examples/js/lines/LineGeometry.js +3 -5
- package/examples/js/lines/LineMaterial.js +4 -11
- package/examples/js/lines/LineSegments2.js +38 -89
- package/examples/js/lines/LineSegmentsGeometry.js +7 -28
- package/examples/js/lines/Wireframe.js +2 -7
- package/examples/js/lines/WireframeGeometry2.js +3 -1
- package/examples/js/loaders/3DMLoader.js +58 -155
- package/examples/js/loaders/3MFLoader.js +72 -106
- package/examples/js/loaders/AMFLoader.js +0 -25
- package/examples/js/loaders/BVHLoader.js +44 -43
- package/examples/js/loaders/BasisTextureLoader.js +16 -46
- package/examples/js/loaders/ColladaLoader.js +201 -359
- package/examples/js/loaders/DDSLoader.js +24 -25
- package/examples/js/loaders/DRACOLoader.js +29 -66
- package/examples/js/loaders/EXRLoader.js +67 -164
- package/examples/js/loaders/FBXLoader.js +286 -441
- package/examples/js/loaders/FontLoader.js +6 -15
- package/examples/js/loaders/GCodeLoader.js +15 -16
- package/examples/js/loaders/GLTFLoader.js +354 -405
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -6
- package/examples/js/loaders/KMZLoader.js +3 -7
- package/examples/js/loaders/KTXLoader.js +12 -30
- package/examples/js/loaders/LDrawLoader.js +178 -289
- package/examples/js/loaders/LUT3dlLoader.js +7 -11
- package/examples/js/loaders/LUTCubeLoader.js +0 -8
- package/examples/js/loaders/LWOLoader.js +59 -124
- package/examples/js/loaders/LogLuvLoader.js +27 -77
- package/examples/js/loaders/LottieLoader.js +4 -4
- package/examples/js/loaders/MD2Loader.js +26 -27
- package/examples/js/loaders/MDDLoader.js +6 -10
- package/examples/js/loaders/MMDLoader.js +180 -189
- package/examples/js/loaders/MTLLoader.js +18 -47
- package/examples/js/loaders/MaterialXLoader.js +392 -0
- package/examples/js/loaders/NRRDLoader.js +44 -84
- package/examples/js/loaders/OBJLoader.js +50 -65
- package/examples/js/loaders/PCDLoader.js +34 -29
- package/examples/js/loaders/PDBLoader.js +17 -13
- package/examples/js/loaders/PLYLoader.js +9 -39
- package/examples/js/loaders/PRWMLoader.js +11 -22
- package/examples/js/loaders/PVRLoader.js +7 -16
- package/examples/js/loaders/RGBELoader.js +36 -61
- package/examples/js/loaders/RGBMLoader.js +26 -87
- package/examples/js/loaders/STLLoader.js +20 -27
- package/examples/js/loaders/SVGLoader.js +361 -233
- package/examples/js/loaders/TDSLoader.js +81 -118
- package/examples/js/loaders/TGALoader.js +39 -41
- package/examples/js/loaders/TIFFLoader.js +0 -1
- package/examples/js/loaders/TTFLoader.js +0 -8
- package/examples/js/loaders/TiltLoader.js +14 -15
- package/examples/js/loaders/VOXLoader.js +8 -16
- package/examples/js/loaders/VRMLLoader.js +243 -340
- package/examples/js/loaders/VTKLoader.js +101 -118
- package/examples/js/loaders/XYZLoader.js +2 -4
- package/examples/js/loaders/lwo/IFFParser.js +55 -136
- package/examples/js/loaders/lwo/LWO2Parser.js +32 -83
- package/examples/js/loaders/lwo/LWO3Parser.js +31 -73
- package/examples/js/materials/MeshGouraudMaterial.js +15 -13
- package/examples/js/math/Capsule.js +0 -17
- package/examples/js/math/ColorConverter.js +3 -3
- package/examples/js/math/ConvexHull.js +183 -139
- package/examples/js/math/ImprovedNoise.js +1 -1
- package/examples/js/math/Lut.js +8 -15
- package/examples/js/math/MeshSurfaceSampler.js +6 -28
- package/examples/js/math/OBB.js +90 -49
- package/examples/js/math/Octree.js +2 -57
- package/examples/js/math/SimplexNoise.js +74 -88
- package/examples/js/misc/ConvexObjectBreaker.js +37 -48
- package/examples/js/misc/GPUComputationRenderer.js +14 -18
- package/examples/js/misc/Gyroscope.js +5 -9
- package/examples/js/misc/MD2Character.js +14 -23
- package/examples/js/misc/MD2CharacterComplex.js +73 -54
- package/examples/js/misc/MorphAnimMesh.js +0 -6
- package/examples/js/misc/MorphBlendMesh.js +3 -30
- package/examples/js/misc/ProgressiveLightMap.js +47 -43
- package/examples/js/misc/RollerCoaster.js +17 -24
- package/examples/js/misc/TubePainter.js +18 -12
- package/examples/js/misc/Volume.js +16 -45
- package/examples/js/misc/VolumeSlice.js +14 -24
- package/examples/js/modifiers/CurveModifier.js +19 -21
- package/examples/js/modifiers/EdgeSplitModifier.js +0 -30
- package/examples/js/modifiers/SimplifyModifier.js +56 -59
- package/examples/js/modifiers/TessellateModifier.js +2 -9
- package/examples/js/objects/GroundProjectedEnv.js +2 -14
- package/examples/js/objects/Lensflare.js +47 -38
- package/examples/js/objects/LightningStorm.js +10 -13
- package/examples/js/objects/MarchingCubes.js +80 -59
- package/examples/js/objects/Reflector.js +22 -20
- package/examples/js/objects/ReflectorForSSRPass.js +19 -23
- package/examples/js/objects/Refractor.js +52 -30
- package/examples/js/objects/ShadowMesh.js +1 -2
- package/examples/js/objects/Sky.js +2 -7
- package/examples/js/objects/Water.js +23 -18
- package/examples/js/objects/Water2.js +20 -19
- package/examples/js/physics/AmmoPhysics.js +23 -20
- package/examples/js/physics/OimoPhysics.js +19 -17
- package/examples/js/postprocessing/AdaptiveToneMappingPass.js +13 -20
- package/examples/js/postprocessing/AfterimagePass.js +19 -12
- package/examples/js/postprocessing/BloomPass.js +38 -17
- package/examples/js/postprocessing/BokehPass.js +29 -12
- package/examples/js/postprocessing/ClearPass.js +1 -6
- package/examples/js/postprocessing/CubeTexturePass.js +12 -9
- package/examples/js/postprocessing/DotScreenPass.js +7 -5
- package/examples/js/postprocessing/EffectComposer.js +25 -32
- package/examples/js/postprocessing/FilmPass.js +7 -5
- package/examples/js/postprocessing/GlitchPass.js +10 -11
- package/examples/js/postprocessing/HalftonePass.js +9 -9
- package/examples/js/postprocessing/LUTPass.js +2 -15
- package/examples/js/postprocessing/MaskPass.js +20 -17
- package/examples/js/postprocessing/OutlinePass.js +45 -36
- package/examples/js/postprocessing/Pass.js +11 -14
- package/examples/js/postprocessing/RenderPass.js +3 -7
- package/examples/js/postprocessing/SAOPass.js +40 -32
- package/examples/js/postprocessing/SMAAPass.js +34 -17
- package/examples/js/postprocessing/SSAARenderPass.js +14 -14
- package/examples/js/postprocessing/SSAOPass.js +56 -42
- package/examples/js/postprocessing/SSRPass.js +78 -61
- package/examples/js/postprocessing/SavePass.js +14 -6
- package/examples/js/postprocessing/ShaderPass.js +9 -8
- package/examples/js/postprocessing/TAARenderPass.js +11 -9
- package/examples/js/postprocessing/TexturePass.js +7 -4
- package/examples/js/postprocessing/UnrealBloomPass.js +43 -25
- package/examples/js/renderers/CSS2DRenderer.js +2 -21
- package/examples/js/renderers/CSS3DRenderer.js +3 -24
- package/examples/js/renderers/Projector.js +29 -85
- package/examples/js/renderers/SVGRenderer.js +4 -50
- package/examples/js/shaders/ACESFilmicToneMappingShader.js +3 -6
- package/examples/js/shaders/AfterimageShader.js +3 -6
- package/examples/js/shaders/BasicShader.js +3 -6
- package/examples/js/shaders/BleachBypassShader.js +3 -6
- package/examples/js/shaders/BlendShader.js +3 -6
- package/examples/js/shaders/BokehShader.js +3 -6
- package/examples/js/shaders/BokehShader2.js +4 -13
- package/examples/js/shaders/BrightnessContrastShader.js +3 -6
- package/examples/js/shaders/ColorCorrectionShader.js +2 -6
- package/examples/js/shaders/ColorifyShader.js +2 -6
- package/examples/js/shaders/ConvolutionShader.js +5 -10
- package/examples/js/shaders/CopyShader.js +3 -6
- package/examples/js/shaders/DOFMipMapShader.js +3 -6
- package/examples/js/shaders/DepthLimitedBlurShader.js +2 -9
- package/examples/js/shaders/DigitalGlitch.js +3 -6
- package/examples/js/shaders/DotScreenShader.js +2 -6
- package/examples/js/shaders/FXAAShader.js +1 -3
- package/examples/js/shaders/FilmShader.js +3 -6
- package/examples/js/shaders/FocusShader.js +3 -6
- package/examples/js/shaders/FreiChenShader.js +2 -6
- package/examples/js/shaders/GammaCorrectionShader.js +3 -6
- package/examples/js/shaders/GodRaysShader.js +11 -24
- package/examples/js/shaders/HalftoneShader.js +3 -6
- package/examples/js/shaders/HorizontalBlurShader.js +3 -6
- package/examples/js/shaders/HorizontalTiltShiftShader.js +3 -6
- package/examples/js/shaders/HueSaturationShader.js +3 -6
- package/examples/js/shaders/KaleidoShader.js +3 -6
- package/examples/js/shaders/LuminosityHighPassShader.js +2 -6
- package/examples/js/shaders/LuminosityShader.js +3 -6
- package/examples/js/shaders/MMDToonShader.js +2 -6
- package/examples/js/shaders/MirrorShader.js +3 -6
- package/examples/js/shaders/NormalMapShader.js +2 -6
- package/examples/js/shaders/RGBShiftShader.js +3 -6
- package/examples/js/shaders/SAOShader.js +2 -6
- package/examples/js/shaders/SMAAShader.js +6 -18
- package/examples/js/shaders/SSAOShader.js +2 -6
- package/examples/js/shaders/SSRShader.js +6 -18
- package/examples/js/shaders/SepiaShader.js +3 -6
- package/examples/js/shaders/SobelOperatorShader.js +2 -6
- package/examples/js/shaders/TechnicolorShader.js +3 -6
- package/examples/js/shaders/ToneMapShader.js +3 -6
- package/examples/js/shaders/ToonShader.js +8 -24
- package/examples/js/shaders/TriangleBlurShader.js +2 -6
- package/examples/js/shaders/UnpackDepthRGBAShader.js +3 -6
- package/examples/js/shaders/VelocityShader.js +126 -0
- package/examples/js/shaders/VerticalBlurShader.js +3 -6
- package/examples/js/shaders/VerticalTiltShiftShader.js +3 -6
- package/examples/js/shaders/VignetteShader.js +3 -6
- package/examples/js/shaders/VolumeShader.js +2 -6
- package/examples/js/shaders/WaterRefractionShader.js +2 -6
- package/examples/js/textures/FlakesTexture.js +0 -1
- package/examples/js/utils/BufferGeometryUtils.js +234 -168
- package/examples/js/utils/CameraUtils.js +5 -20
- package/examples/js/utils/GPUStatsPanel.js +3 -12
- package/examples/js/utils/GeometryCompressionUtils.js +19 -44
- package/examples/js/utils/GeometryUtils.js +13 -18
- package/examples/js/utils/LDrawUtils.js +8 -11
- package/examples/js/utils/PackedPhongMaterial.js +6 -4
- package/examples/js/utils/SceneUtils.js +117 -6
- package/examples/js/utils/ShadowMapViewer.js +17 -14
- package/examples/js/utils/SkeletonUtils.js +13 -27
- package/examples/js/utils/UVsDebug.js +20 -12
- package/examples/js/utils/WorkerPool.js +1 -11
- package/examples/jsm/animation/CCDIKSolver.js +1 -1
- package/examples/jsm/capabilities/WebGPU.js +3 -1
- package/examples/jsm/controls/OrbitControls.js +44 -4
- package/examples/jsm/exporters/GLTFExporter.js +17 -131
- package/examples/jsm/exporters/USDZExporter.js +75 -19
- package/examples/jsm/interactive/HTMLMesh.js +2 -0
- package/examples/jsm/libs/lottie_canvas.module.js +14844 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -2
- package/examples/jsm/loaders/ColladaLoader.js +28 -0
- package/examples/jsm/loaders/FBXLoader.js +16 -2
- package/examples/jsm/loaders/GLTFLoader.js +204 -377
- package/examples/jsm/loaders/KTX2Loader.js +68 -29
- package/examples/jsm/loaders/LDrawLoader.js +14 -13
- package/examples/jsm/loaders/LottieLoader.js +4 -2
- package/examples/jsm/loaders/MaterialXLoader.js +728 -0
- package/examples/jsm/loaders/PCDLoader.js +1 -1
- package/examples/jsm/loaders/PLYLoader.js +68 -16
- package/examples/jsm/loaders/SVGLoader.js +227 -14
- package/examples/jsm/loaders/USDZLoader.js +31 -16
- package/examples/jsm/nodes/Nodes.js +14 -2
- package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +6 -0
- package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
- package/examples/jsm/nodes/accessors/SkinningNode.js +1 -1
- package/examples/jsm/nodes/core/Node.js +1 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +36 -4
- package/examples/jsm/nodes/core/NodeFrame.js +2 -2
- package/examples/jsm/nodes/core/NodeVarying.js +7 -4
- package/examples/jsm/nodes/core/VaryingNode.js +6 -4
- package/examples/jsm/nodes/core/constants.js +13 -13
- package/examples/jsm/nodes/display/PosterizeNode.js +25 -0
- package/examples/jsm/nodes/display/ViewportNode.js +106 -0
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +3 -1
- package/examples/jsm/nodes/materials/Materials.js +9 -7
- package/examples/jsm/nodes/materials/NodeMaterial.js +9 -1
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +6 -2
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +18 -0
- package/examples/jsm/nodes/math/MathNode.js +5 -0
- package/examples/jsm/nodes/math/OperatorNode.js +6 -1
- package/examples/jsm/nodes/shadernode/ShaderNode.js +26 -13
- package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +2 -0
- package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +18 -0
- package/examples/jsm/nodes/utils/EquirectUVNode.js +27 -0
- package/examples/jsm/nodes/utils/JoinNode.js +8 -2
- package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -4
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +8 -10
- package/examples/jsm/nodes/utils/TimerNode.js +1 -1
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +51 -0
- package/examples/jsm/postprocessing/AfterimagePass.js +17 -4
- package/examples/jsm/postprocessing/BloomPass.js +22 -3
- package/examples/jsm/postprocessing/BokehPass.js +18 -4
- package/examples/jsm/postprocessing/CubeTexturePass.js +12 -5
- package/examples/jsm/postprocessing/DotScreenPass.js +8 -0
- package/examples/jsm/postprocessing/EffectComposer.js +9 -0
- package/examples/jsm/postprocessing/FilmPass.js +8 -0
- package/examples/jsm/postprocessing/GlitchPass.js +13 -1
- package/examples/jsm/postprocessing/HalftonePass.js +8 -0
- package/examples/jsm/postprocessing/OutlinePass.js +10 -0
- package/examples/jsm/postprocessing/Pass.js +2 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +234 -0
- package/examples/jsm/postprocessing/SAOPass.js +20 -0
- package/examples/jsm/postprocessing/SMAAPass.js +16 -0
- package/examples/jsm/postprocessing/SSAARenderPass.js +4 -0
- package/examples/jsm/postprocessing/SavePass.js +17 -1
- package/examples/jsm/postprocessing/ShaderPass.js +8 -0
- package/examples/jsm/postprocessing/TAARenderPass.js +9 -0
- package/examples/jsm/postprocessing/TexturePass.js +8 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.js +16 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +39 -16
- package/examples/jsm/renderers/webgpu/WebGPUAnimation.js +58 -0
- package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +63 -5
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +36 -7
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +47 -12
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +35 -5
- package/examples/jsm/shaders/MMDToonShader.js +0 -2
- package/examples/jsm/shaders/VelocityShader.js +128 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +130 -6
- package/examples/jsm/utils/SceneUtils.js +129 -4
- package/examples/jsm/utils/TextureUtils.js +85 -0
- package/examples/jsm/webxr/OculusHandModel.js +1 -1
- package/examples/jsm/webxr/XRHandMeshModel.js +6 -3
- package/package.json +11 -12
- package/src/Three.js +1 -0
- package/src/audio/AudioContext.js +5 -5
- package/src/cameras/CubeCamera.js +14 -14
- package/src/constants.js +1 -1
- package/src/core/InstancedBufferGeometry.js +1 -7
- package/src/extras/Earcut.js +67 -67
- package/src/helpers/DirectionalLightHelper.js +5 -1
- package/src/helpers/HemisphereLightHelper.js +4 -1
- package/src/helpers/PointLightHelper.js +2 -1
- package/src/helpers/SpotLightHelper.js +4 -2
- package/src/lights/PointLight.js +2 -2
- package/src/lights/SpotLight.js +2 -2
- package/src/loaders/FileLoader.js +4 -1
- package/src/loaders/ObjectLoader.js +5 -1
- package/src/materials/Material.js +1 -1
- package/src/math/Color.js +5 -5
- package/src/math/Matrix3.js +53 -18
- package/src/math/Ray.js +2 -5
- package/src/math/Sphere.js +19 -26
- package/src/objects/InstancedMesh.js +7 -0
- package/src/objects/LOD.js +25 -6
- package/src/renderers/WebGL3DRenderTarget.js +1 -1
- package/src/renderers/WebGLArrayRenderTarget.js +1 -1
- package/src/renderers/WebGLCubeRenderTarget.js +1 -1
- package/src/renderers/WebGLMultipleRenderTargets.js +1 -1
- package/src/renderers/WebGLRenderTarget.js +1 -1
- package/src/renderers/WebGLRenderer.js +36 -62
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -4
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk.js +3 -0
- package/src/renderers/shaders/ShaderLib/background.glsl.js +7 -2
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +20 -6
- package/src/renderers/shaders/UniformsLib.js +1 -1
- package/src/renderers/shaders/UniformsUtils.js +15 -0
- package/src/renderers/webgl/WebGLAttributes.js +2 -0
- package/src/renderers/webgl/WebGLBackground.js +15 -7
- package/src/renderers/webgl/WebGLLights.js +0 -4
- package/src/renderers/webgl/WebGLMaterials.js +2 -1
- package/src/renderers/webgl/WebGLShadowMap.js +3 -1
- package/src/renderers/webgl/WebGLState.js +31 -1
- package/src/renderers/webgl/WebGLTextures.js +71 -18
- package/src/renderers/webgl/WebGLUniforms.js +116 -20
- package/src/renderers/webgl/WebGLUtils.js +1 -1
- package/src/renderers/webxr/WebXRController.js +46 -13
- package/src/renderers/webxr/WebXRManager.js +85 -3
- package/src/scenes/Scene.js +8 -0
- package/src/textures/CompressedArrayTexture.js +18 -0
- package/examples/js/libs/lottie_canvas.js +0 -12751
- package/examples/js/shaders/PixelShader.js +0 -51
- package/examples/jsm/shaders/PixelShader.js +0 -44
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* Referred to the original Industrial Light & Magic OpenEXR implementation and the TinyEXR / Syoyo Fujita
|
|
8
8
|
* implementation, so I have preserved their copyright notices.
|
|
9
9
|
*/
|
|
10
|
+
|
|
10
11
|
// /*
|
|
11
12
|
// Copyright (c) 2014 - 2017, Syoyo Fujita
|
|
12
13
|
// All rights reserved.
|
|
14
|
+
|
|
13
15
|
// Redistribution and use in source and binary forms, with or without
|
|
14
16
|
// modification, are permitted provided that the following conditions are met:
|
|
15
17
|
// * Redistributions of source code must retain the above copyright
|
|
@@ -20,6 +22,7 @@
|
|
|
20
22
|
// * Neither the name of the Syoyo Fujita nor the
|
|
21
23
|
// names of its contributors may be used to endorse or promote products
|
|
22
24
|
// derived from this software without specific prior written permission.
|
|
25
|
+
|
|
23
26
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
24
27
|
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
25
28
|
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
@@ -31,7 +34,9 @@
|
|
|
31
34
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
32
35
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
33
36
|
// */
|
|
37
|
+
|
|
34
38
|
// // TinyEXR contains some OpenEXR code, which is licensed under ------------
|
|
39
|
+
|
|
35
40
|
// ///////////////////////////////////////////////////////////////////////////
|
|
36
41
|
// //
|
|
37
42
|
// // Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
|
@@ -65,6 +70,7 @@
|
|
|
65
70
|
// // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
66
71
|
// //
|
|
67
72
|
// ///////////////////////////////////////////////////////////////////////////
|
|
73
|
+
|
|
68
74
|
// // End of OpenEXR license -------------------------------------------------
|
|
69
75
|
|
|
70
76
|
class EXRLoader extends THREE.DataTextureLoader {
|
|
@@ -75,19 +81,15 @@
|
|
|
75
81
|
this.type = THREE.HalfFloatType;
|
|
76
82
|
|
|
77
83
|
}
|
|
78
|
-
|
|
79
84
|
parse( buffer ) {
|
|
80
85
|
|
|
81
86
|
const USHORT_RANGE = 1 << 16;
|
|
82
87
|
const BITMAP_SIZE = USHORT_RANGE >> 3;
|
|
83
88
|
const HUF_ENCBITS = 16; // literal (value) bit length
|
|
84
|
-
|
|
85
89
|
const HUF_DECBITS = 14; // decoding bit size (>= 8)
|
|
86
90
|
|
|
87
91
|
const HUF_ENCSIZE = ( 1 << HUF_ENCBITS ) + 1; // encoding table size
|
|
88
|
-
|
|
89
92
|
const HUF_DECSIZE = 1 << HUF_DECBITS; // decoding table size
|
|
90
|
-
|
|
91
93
|
const HUF_DECMASK = HUF_DECSIZE - 1;
|
|
92
94
|
const NBITS = 16;
|
|
93
95
|
const A_OFFSET = 1 << NBITS - 1;
|
|
@@ -106,11 +108,9 @@
|
|
|
106
108
|
const LOSSY_DCT = 1;
|
|
107
109
|
const RLE = 2;
|
|
108
110
|
const logBase = Math.pow( 2.7182818, 2.2 );
|
|
109
|
-
|
|
110
111
|
function reverseLutFromBitmap( bitmap, lut ) {
|
|
111
112
|
|
|
112
113
|
let k = 0;
|
|
113
|
-
|
|
114
114
|
for ( let i = 0; i < USHORT_RANGE; ++ i ) {
|
|
115
115
|
|
|
116
116
|
if ( i == 0 || bitmap[ i >> 3 ] & 1 << ( i & 7 ) ) {
|
|
@@ -122,9 +122,7 @@
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
const n = k - 1;
|
|
125
|
-
|
|
126
125
|
while ( k < USHORT_RANGE ) lut[ k ++ ] = 0;
|
|
127
|
-
|
|
128
126
|
return n;
|
|
129
127
|
|
|
130
128
|
}
|
|
@@ -147,7 +145,6 @@
|
|
|
147
145
|
c: 0,
|
|
148
146
|
lc: 0
|
|
149
147
|
};
|
|
150
|
-
|
|
151
148
|
function getBits( nBits, c, lc, uInt8Array, inOffset ) {
|
|
152
149
|
|
|
153
150
|
while ( lc < nBits ) {
|
|
@@ -165,15 +162,11 @@
|
|
|
165
162
|
}
|
|
166
163
|
|
|
167
164
|
const hufTableBuffer = new Array( 59 );
|
|
168
|
-
|
|
169
165
|
function hufCanonicalCodeTable( hcode ) {
|
|
170
166
|
|
|
171
167
|
for ( let i = 0; i <= 58; ++ i ) hufTableBuffer[ i ] = 0;
|
|
172
|
-
|
|
173
168
|
for ( let i = 0; i < HUF_ENCSIZE; ++ i ) hufTableBuffer[ hcode[ i ] ] += 1;
|
|
174
|
-
|
|
175
169
|
let c = 0;
|
|
176
|
-
|
|
177
170
|
for ( let i = 58; i > 0; -- i ) {
|
|
178
171
|
|
|
179
172
|
const nc = c + hufTableBuffer[ i ] >> 1;
|
|
@@ -196,7 +189,6 @@
|
|
|
196
189
|
const p = inOffset;
|
|
197
190
|
let c = 0;
|
|
198
191
|
let lc = 0;
|
|
199
|
-
|
|
200
192
|
for ( ; im <= iM; im ++ ) {
|
|
201
193
|
|
|
202
194
|
if ( p.value - inOffset.value > ni ) return false;
|
|
@@ -205,7 +197,6 @@
|
|
|
205
197
|
c = getBitsReturn.c;
|
|
206
198
|
lc = getBitsReturn.lc;
|
|
207
199
|
hcode[ im ] = l;
|
|
208
|
-
|
|
209
200
|
if ( l == LONG_ZEROCODE_RUN ) {
|
|
210
201
|
|
|
211
202
|
if ( p.value - inOffset.value > ni ) {
|
|
@@ -218,7 +209,6 @@
|
|
|
218
209
|
let zerun = getBitsReturn.l + SHORTEST_LONG_RUN;
|
|
219
210
|
c = getBitsReturn.c;
|
|
220
211
|
lc = getBitsReturn.lc;
|
|
221
|
-
|
|
222
212
|
if ( im + zerun > iM + 1 ) {
|
|
223
213
|
|
|
224
214
|
throw new Error( 'Something wrong with hufUnpackEncTable' );
|
|
@@ -226,13 +216,11 @@
|
|
|
226
216
|
}
|
|
227
217
|
|
|
228
218
|
while ( zerun -- ) hcode[ im ++ ] = 0;
|
|
229
|
-
|
|
230
219
|
im --;
|
|
231
220
|
|
|
232
221
|
} else if ( l >= SHORT_ZEROCODE_RUN ) {
|
|
233
222
|
|
|
234
223
|
let zerun = l - SHORT_ZEROCODE_RUN + 2;
|
|
235
|
-
|
|
236
224
|
if ( im + zerun > iM + 1 ) {
|
|
237
225
|
|
|
238
226
|
throw new Error( 'Something wrong with hufUnpackEncTable' );
|
|
@@ -240,7 +228,6 @@
|
|
|
240
228
|
}
|
|
241
229
|
|
|
242
230
|
while ( zerun -- ) hcode[ im ++ ] = 0;
|
|
243
|
-
|
|
244
231
|
im --;
|
|
245
232
|
|
|
246
233
|
}
|
|
@@ -269,7 +256,6 @@
|
|
|
269
256
|
|
|
270
257
|
const c = hufCode( hcode[ im ] );
|
|
271
258
|
const l = hufLength( hcode[ im ] );
|
|
272
|
-
|
|
273
259
|
if ( c >> l ) {
|
|
274
260
|
|
|
275
261
|
throw new Error( 'Invalid table entry' );
|
|
@@ -279,7 +265,6 @@
|
|
|
279
265
|
if ( l > HUF_DECBITS ) {
|
|
280
266
|
|
|
281
267
|
const pl = hdecod[ c >> l - HUF_DECBITS ];
|
|
282
|
-
|
|
283
268
|
if ( pl.len ) {
|
|
284
269
|
|
|
285
270
|
throw new Error( 'Invalid table entry' );
|
|
@@ -287,12 +272,10 @@
|
|
|
287
272
|
}
|
|
288
273
|
|
|
289
274
|
pl.lit ++;
|
|
290
|
-
|
|
291
275
|
if ( pl.p ) {
|
|
292
276
|
|
|
293
277
|
const p = pl.p;
|
|
294
278
|
pl.p = new Array( pl.lit );
|
|
295
|
-
|
|
296
279
|
for ( let i = 0; i < pl.lit - 1; ++ i ) {
|
|
297
280
|
|
|
298
281
|
pl.p[ i ] = p[ i ];
|
|
@@ -310,11 +293,9 @@
|
|
|
310
293
|
} else if ( l ) {
|
|
311
294
|
|
|
312
295
|
let plOffset = 0;
|
|
313
|
-
|
|
314
296
|
for ( let i = 1 << HUF_DECBITS - l; i > 0; i -- ) {
|
|
315
297
|
|
|
316
298
|
const pl = hdecod[ ( c << HUF_DECBITS - l ) + plOffset ];
|
|
317
|
-
|
|
318
299
|
if ( pl.len || pl.p ) {
|
|
319
300
|
|
|
320
301
|
throw new Error( 'Invalid table entry' );
|
|
@@ -339,7 +320,6 @@
|
|
|
339
320
|
c: 0,
|
|
340
321
|
lc: 0
|
|
341
322
|
};
|
|
342
|
-
|
|
343
323
|
function getChar( c, lc, uInt8Array, inOffset ) {
|
|
344
324
|
|
|
345
325
|
c = c << 8 | parseUint8Array( uInt8Array, inOffset );
|
|
@@ -353,7 +333,6 @@
|
|
|
353
333
|
c: 0,
|
|
354
334
|
lc: 0
|
|
355
335
|
};
|
|
356
|
-
|
|
357
336
|
function getCode( po, rlc, c, lc, uInt8Array, inOffset, outBuffer, outBufferOffset, outBufferEndOffset ) {
|
|
358
337
|
|
|
359
338
|
if ( po == rlc ) {
|
|
@@ -369,7 +348,6 @@
|
|
|
369
348
|
lc -= 8;
|
|
370
349
|
let cs = c >> lc;
|
|
371
350
|
cs = new Uint8Array( [ cs ] )[ 0 ];
|
|
372
|
-
|
|
373
351
|
if ( outBufferOffset.value + cs > outBufferEndOffset ) {
|
|
374
352
|
|
|
375
353
|
return false;
|
|
@@ -377,7 +355,6 @@
|
|
|
377
355
|
}
|
|
378
356
|
|
|
379
357
|
const s = outBuffer[ outBufferOffset.value - 1 ];
|
|
380
|
-
|
|
381
358
|
while ( cs -- > 0 ) {
|
|
382
359
|
|
|
383
360
|
outBuffer[ outBufferOffset.value ++ ] = s;
|
|
@@ -416,7 +393,6 @@
|
|
|
416
393
|
a: 0,
|
|
417
394
|
b: 0
|
|
418
395
|
};
|
|
419
|
-
|
|
420
396
|
function wdec14( l, h ) {
|
|
421
397
|
|
|
422
398
|
const ls = Int16( l );
|
|
@@ -448,13 +424,10 @@
|
|
|
448
424
|
let p = 1;
|
|
449
425
|
let p2;
|
|
450
426
|
let py;
|
|
451
|
-
|
|
452
427
|
while ( p <= n ) p <<= 1;
|
|
453
|
-
|
|
454
428
|
p >>= 1;
|
|
455
429
|
p2 = p;
|
|
456
430
|
p >>= 1;
|
|
457
|
-
|
|
458
431
|
while ( p >= 1 ) {
|
|
459
432
|
|
|
460
433
|
py = 0;
|
|
@@ -464,18 +437,15 @@
|
|
|
464
437
|
const ox1 = ox * p;
|
|
465
438
|
const ox2 = ox * p2;
|
|
466
439
|
let i00, i01, i10, i11;
|
|
467
|
-
|
|
468
440
|
for ( ; py <= ey; py += oy2 ) {
|
|
469
441
|
|
|
470
442
|
let px = py;
|
|
471
443
|
const ex = py + ox * ( nx - p2 );
|
|
472
|
-
|
|
473
444
|
for ( ; px <= ex; px += ox2 ) {
|
|
474
445
|
|
|
475
446
|
const p01 = px + ox1;
|
|
476
447
|
const p10 = px + oy1;
|
|
477
448
|
const p11 = p10 + ox1;
|
|
478
|
-
|
|
479
449
|
if ( w14 ) {
|
|
480
450
|
|
|
481
451
|
wdec14( buffer[ px + j ], buffer[ p10 + j ] );
|
|
@@ -526,7 +496,6 @@
|
|
|
526
496
|
|
|
527
497
|
let px = py;
|
|
528
498
|
const ex = py + ox * ( nx - p2 );
|
|
529
|
-
|
|
530
499
|
for ( ; px <= ex; px += ox2 ) {
|
|
531
500
|
|
|
532
501
|
const p01 = px + ox1;
|
|
@@ -554,18 +523,15 @@
|
|
|
554
523
|
let lc = 0;
|
|
555
524
|
const outBufferEndOffset = no;
|
|
556
525
|
const inOffsetEnd = Math.trunc( inOffset.value + ( ni + 7 ) / 8 );
|
|
557
|
-
|
|
558
526
|
while ( inOffset.value < inOffsetEnd ) {
|
|
559
527
|
|
|
560
528
|
getChar( c, lc, uInt8Array, inOffset );
|
|
561
529
|
c = getCharReturn.c;
|
|
562
530
|
lc = getCharReturn.lc;
|
|
563
|
-
|
|
564
531
|
while ( lc >= HUF_DECBITS ) {
|
|
565
532
|
|
|
566
533
|
const index = c >> lc - HUF_DECBITS & HUF_DECMASK;
|
|
567
534
|
const pl = decodingTable[ index ];
|
|
568
|
-
|
|
569
535
|
if ( pl.len ) {
|
|
570
536
|
|
|
571
537
|
lc -= pl.len;
|
|
@@ -582,11 +548,9 @@
|
|
|
582
548
|
}
|
|
583
549
|
|
|
584
550
|
let j;
|
|
585
|
-
|
|
586
551
|
for ( j = 0; j < pl.lit; j ++ ) {
|
|
587
552
|
|
|
588
553
|
const l = hufLength( encodingTable[ pl.p[ j ] ] );
|
|
589
|
-
|
|
590
554
|
while ( lc < l && inOffset.value < inOffsetEnd ) {
|
|
591
555
|
|
|
592
556
|
getChar( c, lc, uInt8Array, inOffset );
|
|
@@ -626,11 +590,9 @@
|
|
|
626
590
|
const i = 8 - ni & 7;
|
|
627
591
|
c >>= i;
|
|
628
592
|
lc -= i;
|
|
629
|
-
|
|
630
593
|
while ( lc > 0 ) {
|
|
631
594
|
|
|
632
595
|
const pl = decodingTable[ c << HUF_DECBITS - lc & HUF_DECMASK ];
|
|
633
|
-
|
|
634
596
|
if ( pl.len ) {
|
|
635
597
|
|
|
636
598
|
lc -= pl.len;
|
|
@@ -661,7 +623,6 @@
|
|
|
661
623
|
inOffset.value += 4;
|
|
662
624
|
const nBits = parseUint32( inDataView, inOffset );
|
|
663
625
|
inOffset.value += 4;
|
|
664
|
-
|
|
665
626
|
if ( im < 0 || im >= HUF_ENCSIZE || iM < 0 || iM >= HUF_ENCSIZE ) {
|
|
666
627
|
|
|
667
628
|
throw new Error( 'Something wrong with HUF_ENCSIZE' );
|
|
@@ -673,7 +634,6 @@
|
|
|
673
634
|
hufClearDecTable( hdec );
|
|
674
635
|
const ni = nCompressed - ( inOffset.value - initialInOffset );
|
|
675
636
|
hufUnpackEncTable( uInt8Array, inOffset, ni, im, iM, freq );
|
|
676
|
-
|
|
677
637
|
if ( nBits > 8 * ( nCompressed - ( inOffset.value - initialInOffset ) ) ) {
|
|
678
638
|
|
|
679
639
|
throw new Error( 'Something wrong with hufUncompress' );
|
|
@@ -712,7 +672,6 @@
|
|
|
712
672
|
let t2 = Math.floor( ( source.length + 1 ) / 2 );
|
|
713
673
|
let s = 0;
|
|
714
674
|
const stop = source.length - 1;
|
|
715
|
-
|
|
716
675
|
while ( true ) {
|
|
717
676
|
|
|
718
677
|
if ( s > stop ) break;
|
|
@@ -730,16 +689,13 @@
|
|
|
730
689
|
const out = new Array();
|
|
731
690
|
let p = 0;
|
|
732
691
|
const reader = new DataView( source );
|
|
733
|
-
|
|
734
692
|
while ( size > 0 ) {
|
|
735
693
|
|
|
736
694
|
const l = reader.getInt8( p ++ );
|
|
737
|
-
|
|
738
695
|
if ( l < 0 ) {
|
|
739
696
|
|
|
740
697
|
const count = - l;
|
|
741
698
|
size -= count + 1;
|
|
742
|
-
|
|
743
699
|
for ( let i = 0; i < count; i ++ ) {
|
|
744
700
|
|
|
745
701
|
out.push( reader.getUint8( p ++ ) );
|
|
@@ -751,7 +707,6 @@
|
|
|
751
707
|
const count = l;
|
|
752
708
|
size -= 2;
|
|
753
709
|
const value = reader.getUint8( p ++ );
|
|
754
|
-
|
|
755
710
|
for ( let i = 0; i < count + 1; i ++ ) {
|
|
756
711
|
|
|
757
712
|
out.push( value );
|
|
@@ -785,7 +740,6 @@
|
|
|
785
740
|
const halfZigBlock = new Array( numComp );
|
|
786
741
|
const rowBlock = new Array( numComp );
|
|
787
742
|
const rowOffsets = new Array( numComp );
|
|
788
|
-
|
|
789
743
|
for ( let comp = 0; comp < numComp; ++ comp ) {
|
|
790
744
|
|
|
791
745
|
rowOffsets[ comp ] = rowPtrs[ cscSet.idx[ comp ] ];
|
|
@@ -801,21 +755,21 @@
|
|
|
801
755
|
let maxY = 8;
|
|
802
756
|
if ( blocky == numBlocksY - 1 ) maxY = leftoverY;
|
|
803
757
|
let maxX = 8;
|
|
804
|
-
|
|
805
758
|
for ( let blockx = 0; blockx < numBlocksX; ++ blockx ) {
|
|
806
759
|
|
|
807
760
|
if ( blockx == numBlocksX - 1 ) maxX = leftoverX;
|
|
808
|
-
|
|
809
761
|
for ( let comp = 0; comp < numComp; ++ comp ) {
|
|
810
762
|
|
|
811
|
-
halfZigBlock[ comp ].fill( 0 );
|
|
763
|
+
halfZigBlock[ comp ].fill( 0 );
|
|
812
764
|
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
unZigZag( halfZigBlock[ comp ], dctData[ comp ] ); // decode float dct
|
|
765
|
+
// set block DC component
|
|
766
|
+
halfZigBlock[ comp ][ 0 ] = dcBuffer[ currDcComp[ comp ] ++ ];
|
|
767
|
+
// set block AC components
|
|
768
|
+
unRleAC( currAcComp, acBuffer, halfZigBlock[ comp ] );
|
|
818
769
|
|
|
770
|
+
// UnZigZag block to float
|
|
771
|
+
unZigZag( halfZigBlock[ comp ], dctData[ comp ] );
|
|
772
|
+
// decode float dct
|
|
819
773
|
dctInverse( dctData[ comp ] );
|
|
820
774
|
|
|
821
775
|
}
|
|
@@ -834,17 +788,13 @@
|
|
|
834
788
|
|
|
835
789
|
} // blockx
|
|
836
790
|
|
|
837
|
-
|
|
838
791
|
let offset = 0;
|
|
839
|
-
|
|
840
792
|
for ( let comp = 0; comp < numComp; ++ comp ) {
|
|
841
793
|
|
|
842
794
|
const type = channelData[ cscSet.idx[ comp ] ].type;
|
|
843
|
-
|
|
844
795
|
for ( let y = 8 * blocky; y < 8 * blocky + maxY; ++ y ) {
|
|
845
796
|
|
|
846
797
|
offset = rowOffsets[ comp ][ y ];
|
|
847
|
-
|
|
848
798
|
for ( let blockx = 0; blockx < numFullBlocksX; ++ blockx ) {
|
|
849
799
|
|
|
850
800
|
const src = blockx * 64 + ( y & 0x7 ) * 8;
|
|
@@ -860,16 +810,15 @@
|
|
|
860
810
|
|
|
861
811
|
}
|
|
862
812
|
|
|
863
|
-
}
|
|
864
|
-
|
|
813
|
+
}
|
|
865
814
|
|
|
815
|
+
// handle partial X blocks
|
|
866
816
|
if ( numFullBlocksX != numBlocksX ) {
|
|
867
817
|
|
|
868
818
|
for ( let y = 8 * blocky; y < 8 * blocky + maxY; ++ y ) {
|
|
869
819
|
|
|
870
820
|
const offset = rowOffsets[ comp ][ y ] + 8 * numFullBlocksX * INT16_SIZE * type;
|
|
871
821
|
const src = numFullBlocksX * 64 + ( y & 0x7 ) * 8;
|
|
872
|
-
|
|
873
822
|
for ( let x = 0; x < maxX; ++ x ) {
|
|
874
823
|
|
|
875
824
|
dataView.setUint16( offset + x * INT16_SIZE * type, rowBlock[ comp ][ src + x ], true );
|
|
@@ -884,20 +833,18 @@
|
|
|
884
833
|
|
|
885
834
|
} // blocky
|
|
886
835
|
|
|
887
|
-
|
|
888
836
|
const halfRow = new Uint16Array( width );
|
|
889
|
-
dataView = new DataView( outBuffer.buffer );
|
|
837
|
+
dataView = new DataView( outBuffer.buffer );
|
|
890
838
|
|
|
839
|
+
// convert channels back to float, if needed
|
|
891
840
|
for ( let comp = 0; comp < numComp; ++ comp ) {
|
|
892
841
|
|
|
893
842
|
channelData[ cscSet.idx[ comp ] ].decoded = true;
|
|
894
843
|
const type = channelData[ cscSet.idx[ comp ] ].type;
|
|
895
844
|
if ( channelData[ comp ].type != 2 ) continue;
|
|
896
|
-
|
|
897
845
|
for ( let y = 0; y < height; ++ y ) {
|
|
898
846
|
|
|
899
847
|
const offset = rowOffsets[ comp ][ y ];
|
|
900
|
-
|
|
901
848
|
for ( let x = 0; x < width; ++ x ) {
|
|
902
849
|
|
|
903
850
|
halfRow[ x ] = dataView.getUint16( offset + x * INT16_SIZE * type, true );
|
|
@@ -920,11 +867,9 @@
|
|
|
920
867
|
|
|
921
868
|
let acValue;
|
|
922
869
|
let dctComp = 1;
|
|
923
|
-
|
|
924
870
|
while ( dctComp < 64 ) {
|
|
925
871
|
|
|
926
872
|
acValue = acBuffer[ currAcComp.value ];
|
|
927
|
-
|
|
928
873
|
if ( acValue == 0xff00 ) {
|
|
929
874
|
|
|
930
875
|
dctComp = 64;
|
|
@@ -1028,7 +973,6 @@
|
|
|
1028
973
|
const beta = new Array( 4 );
|
|
1029
974
|
const theta = new Array( 4 );
|
|
1030
975
|
const gamma = new Array( 4 );
|
|
1031
|
-
|
|
1032
976
|
for ( let row = 0; row < 8; ++ row ) {
|
|
1033
977
|
|
|
1034
978
|
const rowPtr = row * 8;
|
|
@@ -1151,7 +1095,6 @@
|
|
|
1151
1095
|
function uncompressZIP( info ) {
|
|
1152
1096
|
|
|
1153
1097
|
const compressed = info.array.slice( info.offset.value, info.offset.value + info.size );
|
|
1154
|
-
|
|
1155
1098
|
if ( typeof fflate === 'undefined' ) {
|
|
1156
1099
|
|
|
1157
1100
|
console.error( 'THREE.EXRLoader: External library fflate.min.js required.' );
|
|
@@ -1159,7 +1102,6 @@
|
|
|
1159
1102
|
}
|
|
1160
1103
|
|
|
1161
1104
|
const rawBuffer = fflate.unzlibSync( compressed ); // eslint-disable-line no-undef
|
|
1162
|
-
|
|
1163
1105
|
const tmpBuffer = new Uint8Array( rawBuffer.length );
|
|
1164
1106
|
predictor( rawBuffer ); // revert predictor
|
|
1165
1107
|
|
|
@@ -1176,11 +1118,11 @@
|
|
|
1176
1118
|
value: info.offset.value
|
|
1177
1119
|
};
|
|
1178
1120
|
const outBuffer = new Uint16Array( info.width * info.scanlineBlockSize * ( info.channels * info.type ) );
|
|
1179
|
-
const bitmap = new Uint8Array( BITMAP_SIZE );
|
|
1121
|
+
const bitmap = new Uint8Array( BITMAP_SIZE );
|
|
1180
1122
|
|
|
1123
|
+
// Setup channel info
|
|
1181
1124
|
let outBufferEnd = 0;
|
|
1182
1125
|
const pizChannelData = new Array( info.channels );
|
|
1183
|
-
|
|
1184
1126
|
for ( let i = 0; i < info.channels; i ++ ) {
|
|
1185
1127
|
|
|
1186
1128
|
pizChannelData[ i ] = {};
|
|
@@ -1191,12 +1133,12 @@
|
|
|
1191
1133
|
pizChannelData[ i ][ 'size' ] = info.type;
|
|
1192
1134
|
outBufferEnd += pizChannelData[ i ].nx * pizChannelData[ i ].ny * pizChannelData[ i ].size;
|
|
1193
1135
|
|
|
1194
|
-
}
|
|
1136
|
+
}
|
|
1195
1137
|
|
|
1138
|
+
// Read range compression data
|
|
1196
1139
|
|
|
1197
1140
|
const minNonZero = parseUint16( inDataView, inOffset );
|
|
1198
1141
|
const maxNonZero = parseUint16( inDataView, inOffset );
|
|
1199
|
-
|
|
1200
1142
|
if ( maxNonZero >= BITMAP_SIZE ) {
|
|
1201
1143
|
|
|
1202
1144
|
throw new Error( 'Something is wrong with PIZ_COMPRESSION BITMAP_SIZE' );
|
|
@@ -1211,33 +1153,34 @@
|
|
|
1211
1153
|
|
|
1212
1154
|
}
|
|
1213
1155
|
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1156
|
+
}
|
|
1216
1157
|
|
|
1158
|
+
// Reverse LUT
|
|
1217
1159
|
const lut = new Uint16Array( USHORT_RANGE );
|
|
1218
1160
|
const maxValue = reverseLutFromBitmap( bitmap, lut );
|
|
1219
|
-
const length = parseUint32( inDataView, inOffset );
|
|
1161
|
+
const length = parseUint32( inDataView, inOffset );
|
|
1220
1162
|
|
|
1221
|
-
|
|
1163
|
+
// Huffman decoding
|
|
1164
|
+
hufUncompress( info.array, inDataView, inOffset, length, outBuffer, outBufferEnd );
|
|
1222
1165
|
|
|
1166
|
+
// Wavelet decoding
|
|
1223
1167
|
for ( let i = 0; i < info.channels; ++ i ) {
|
|
1224
1168
|
|
|
1225
1169
|
const cd = pizChannelData[ i ];
|
|
1226
|
-
|
|
1227
1170
|
for ( let j = 0; j < pizChannelData[ i ].size; ++ j ) {
|
|
1228
1171
|
|
|
1229
1172
|
wav2Decode( outBuffer, cd.start + j, cd.nx, cd.size, cd.ny, cd.nx * cd.size, maxValue );
|
|
1230
1173
|
|
|
1231
1174
|
}
|
|
1232
1175
|
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1176
|
+
}
|
|
1235
1177
|
|
|
1236
|
-
|
|
1178
|
+
// Expand the pixel data to their original range
|
|
1179
|
+
applyLut( lut, outBuffer, outBufferEnd );
|
|
1237
1180
|
|
|
1181
|
+
// Rearrange the pixel data into the format expected by the caller.
|
|
1238
1182
|
let tmpOffset = 0;
|
|
1239
1183
|
const tmpBuffer = new Uint8Array( outBuffer.buffer.byteLength );
|
|
1240
|
-
|
|
1241
1184
|
for ( let y = 0; y < info.lines; y ++ ) {
|
|
1242
1185
|
|
|
1243
1186
|
for ( let c = 0; c < info.channels; c ++ ) {
|
|
@@ -1260,7 +1203,6 @@
|
|
|
1260
1203
|
function uncompressPXR( info ) {
|
|
1261
1204
|
|
|
1262
1205
|
const compressed = info.array.slice( info.offset.value, info.offset.value + info.size );
|
|
1263
|
-
|
|
1264
1206
|
if ( typeof fflate === 'undefined' ) {
|
|
1265
1207
|
|
|
1266
1208
|
console.error( 'THREE.EXRLoader: External library fflate.min.js required.' );
|
|
@@ -1274,20 +1216,17 @@
|
|
|
1274
1216
|
let tmpBufferEnd = 0;
|
|
1275
1217
|
let writePtr = 0;
|
|
1276
1218
|
const ptr = new Array( 4 );
|
|
1277
|
-
|
|
1278
1219
|
for ( let y = 0; y < info.lines; y ++ ) {
|
|
1279
1220
|
|
|
1280
1221
|
for ( let c = 0; c < info.channels; c ++ ) {
|
|
1281
1222
|
|
|
1282
1223
|
let pixel = 0;
|
|
1283
|
-
|
|
1284
1224
|
switch ( info.type ) {
|
|
1285
1225
|
|
|
1286
1226
|
case 1:
|
|
1287
1227
|
ptr[ 0 ] = tmpBufferEnd;
|
|
1288
1228
|
ptr[ 1 ] = ptr[ 0 ] + info.width;
|
|
1289
1229
|
tmpBufferEnd = ptr[ 1 ] + info.width;
|
|
1290
|
-
|
|
1291
1230
|
for ( let j = 0; j < info.width; ++ j ) {
|
|
1292
1231
|
|
|
1293
1232
|
const diff = rawBuffer[ ptr[ 0 ] ++ ] << 8 | rawBuffer[ ptr[ 1 ] ++ ];
|
|
@@ -1298,13 +1237,11 @@
|
|
|
1298
1237
|
}
|
|
1299
1238
|
|
|
1300
1239
|
break;
|
|
1301
|
-
|
|
1302
1240
|
case 2:
|
|
1303
1241
|
ptr[ 0 ] = tmpBufferEnd;
|
|
1304
1242
|
ptr[ 1 ] = ptr[ 0 ] + info.width;
|
|
1305
1243
|
ptr[ 2 ] = ptr[ 1 ] + info.width;
|
|
1306
1244
|
tmpBufferEnd = ptr[ 2 ] + info.width;
|
|
1307
|
-
|
|
1308
1245
|
for ( let j = 0; j < info.width; ++ j ) {
|
|
1309
1246
|
|
|
1310
1247
|
const diff = rawBuffer[ ptr[ 0 ] ++ ] << 24 | rawBuffer[ ptr[ 1 ] ++ ] << 16 | rawBuffer[ ptr[ 2 ] ++ ] << 8;
|
|
@@ -1332,8 +1269,9 @@
|
|
|
1332
1269
|
const inOffset = {
|
|
1333
1270
|
value: info.offset.value
|
|
1334
1271
|
};
|
|
1335
|
-
const outBuffer = new Uint8Array( info.width * info.lines * ( info.channels * info.type * INT16_SIZE ) );
|
|
1272
|
+
const outBuffer = new Uint8Array( info.width * info.lines * ( info.channels * info.type * INT16_SIZE ) );
|
|
1336
1273
|
|
|
1274
|
+
// Read compression header information
|
|
1337
1275
|
const dwaHeader = {
|
|
1338
1276
|
version: parseInt64( inDataView, inOffset ),
|
|
1339
1277
|
unknownUncompressedSize: parseInt64( inDataView, inOffset ),
|
|
@@ -1347,11 +1285,11 @@
|
|
|
1347
1285
|
totalDcUncompressedCount: parseInt64( inDataView, inOffset ),
|
|
1348
1286
|
acCompression: parseInt64( inDataView, inOffset )
|
|
1349
1287
|
};
|
|
1350
|
-
if ( dwaHeader.version < 2 ) throw new Error( 'EXRLoader.parse: ' + EXRHeader.compression + ' version ' + dwaHeader.version + ' is unsupported' );
|
|
1288
|
+
if ( dwaHeader.version < 2 ) throw new Error( 'EXRLoader.parse: ' + EXRHeader.compression + ' version ' + dwaHeader.version + ' is unsupported' );
|
|
1351
1289
|
|
|
1290
|
+
// Read channel ruleset information
|
|
1352
1291
|
const channelRules = new Array();
|
|
1353
1292
|
let ruleSize = parseUint16( inDataView, inOffset ) - INT16_SIZE;
|
|
1354
|
-
|
|
1355
1293
|
while ( ruleSize > 0 ) {
|
|
1356
1294
|
|
|
1357
1295
|
const name = parseNullTerminatedString( inDataView.buffer, inOffset );
|
|
@@ -1368,12 +1306,11 @@
|
|
|
1368
1306
|
} );
|
|
1369
1307
|
ruleSize -= name.length + 3;
|
|
1370
1308
|
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1309
|
+
}
|
|
1373
1310
|
|
|
1311
|
+
// Classify channels
|
|
1374
1312
|
const channels = EXRHeader.channels;
|
|
1375
1313
|
const channelData = new Array( info.channels );
|
|
1376
|
-
|
|
1377
1314
|
for ( let i = 0; i < info.channels; ++ i ) {
|
|
1378
1315
|
|
|
1379
1316
|
const cd = channelData[ i ] = {};
|
|
@@ -1391,19 +1328,15 @@
|
|
|
1391
1328
|
const cscSet = {
|
|
1392
1329
|
idx: new Array( 3 )
|
|
1393
1330
|
};
|
|
1394
|
-
|
|
1395
1331
|
for ( let offset = 0; offset < info.channels; ++ offset ) {
|
|
1396
1332
|
|
|
1397
1333
|
const cd = channelData[ offset ];
|
|
1398
|
-
|
|
1399
1334
|
for ( let i = 0; i < channelRules.length; ++ i ) {
|
|
1400
1335
|
|
|
1401
1336
|
const rule = channelRules[ i ];
|
|
1402
|
-
|
|
1403
1337
|
if ( cd.name == rule.name ) {
|
|
1404
1338
|
|
|
1405
1339
|
cd.compression = rule.compression;
|
|
1406
|
-
|
|
1407
1340
|
if ( rule.index >= 0 ) {
|
|
1408
1341
|
|
|
1409
1342
|
cscSet.idx[ rule.index ] = offset;
|
|
@@ -1418,8 +1351,9 @@
|
|
|
1418
1351
|
|
|
1419
1352
|
}
|
|
1420
1353
|
|
|
1421
|
-
let acBuffer, dcBuffer, rleBuffer;
|
|
1354
|
+
let acBuffer, dcBuffer, rleBuffer;
|
|
1422
1355
|
|
|
1356
|
+
// Read DCT - AC component data
|
|
1423
1357
|
if ( dwaHeader.acCompressedSize > 0 ) {
|
|
1424
1358
|
|
|
1425
1359
|
switch ( dwaHeader.acCompression ) {
|
|
@@ -1428,20 +1362,18 @@
|
|
|
1428
1362
|
acBuffer = new Uint16Array( dwaHeader.totalAcUncompressedCount );
|
|
1429
1363
|
hufUncompress( info.array, inDataView, inOffset, dwaHeader.acCompressedSize, acBuffer, dwaHeader.totalAcUncompressedCount );
|
|
1430
1364
|
break;
|
|
1431
|
-
|
|
1432
1365
|
case DEFLATE:
|
|
1433
1366
|
const compressed = info.array.slice( inOffset.value, inOffset.value + dwaHeader.totalAcUncompressedCount );
|
|
1434
1367
|
const data = fflate.unzlibSync( compressed ); // eslint-disable-line no-undef
|
|
1435
|
-
|
|
1436
1368
|
acBuffer = new Uint16Array( data.buffer );
|
|
1437
1369
|
inOffset.value += dwaHeader.totalAcUncompressedCount;
|
|
1438
1370
|
break;
|
|
1439
1371
|
|
|
1440
1372
|
}
|
|
1441
1373
|
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1374
|
+
}
|
|
1444
1375
|
|
|
1376
|
+
// Read DCT - DC component data
|
|
1445
1377
|
if ( dwaHeader.dcCompressedSize > 0 ) {
|
|
1446
1378
|
|
|
1447
1379
|
const zlibInfo = {
|
|
@@ -1452,23 +1384,21 @@
|
|
|
1452
1384
|
dcBuffer = new Uint16Array( uncompressZIP( zlibInfo ).buffer );
|
|
1453
1385
|
inOffset.value += dwaHeader.dcCompressedSize;
|
|
1454
1386
|
|
|
1455
|
-
}
|
|
1456
|
-
|
|
1387
|
+
}
|
|
1457
1388
|
|
|
1389
|
+
// Read RLE compressed data
|
|
1458
1390
|
if ( dwaHeader.rleRawSize > 0 ) {
|
|
1459
1391
|
|
|
1460
1392
|
const compressed = info.array.slice( inOffset.value, inOffset.value + dwaHeader.rleCompressedSize );
|
|
1461
1393
|
const data = fflate.unzlibSync( compressed ); // eslint-disable-line no-undef
|
|
1462
|
-
|
|
1463
1394
|
rleBuffer = decodeRunLength( data.buffer );
|
|
1464
1395
|
inOffset.value += dwaHeader.rleCompressedSize;
|
|
1465
1396
|
|
|
1466
|
-
}
|
|
1467
|
-
|
|
1397
|
+
}
|
|
1468
1398
|
|
|
1399
|
+
// Prepare outbuffer data offset
|
|
1469
1400
|
let outBufferEnd = 0;
|
|
1470
1401
|
const rowOffsets = new Array( channelData.length );
|
|
1471
|
-
|
|
1472
1402
|
for ( let i = 0; i < rowOffsets.length; ++ i ) {
|
|
1473
1403
|
|
|
1474
1404
|
rowOffsets[ i ] = new Array();
|
|
@@ -1484,26 +1414,24 @@
|
|
|
1484
1414
|
|
|
1485
1415
|
}
|
|
1486
1416
|
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1417
|
+
}
|
|
1489
1418
|
|
|
1490
|
-
|
|
1419
|
+
// Lossy DCT decode RGB channels
|
|
1420
|
+
lossyDctDecode( cscSet, rowOffsets, channelData, acBuffer, dcBuffer, outBuffer );
|
|
1491
1421
|
|
|
1422
|
+
// Decode other channels
|
|
1492
1423
|
for ( let i = 0; i < channelData.length; ++ i ) {
|
|
1493
1424
|
|
|
1494
1425
|
const cd = channelData[ i ];
|
|
1495
1426
|
if ( cd.decoded ) continue;
|
|
1496
|
-
|
|
1497
1427
|
switch ( cd.compression ) {
|
|
1498
1428
|
|
|
1499
1429
|
case RLE:
|
|
1500
1430
|
let row = 0;
|
|
1501
1431
|
let rleOffset = 0;
|
|
1502
|
-
|
|
1503
1432
|
for ( let y = 0; y < info.lines; ++ y ) {
|
|
1504
1433
|
|
|
1505
1434
|
let rowOffsetBytes = rowOffsets[ i ][ row ];
|
|
1506
|
-
|
|
1507
1435
|
for ( let x = 0; x < cd.width; ++ x ) {
|
|
1508
1436
|
|
|
1509
1437
|
for ( let byte = 0; byte < INT16_SIZE * cd.type; ++ byte ) {
|
|
@@ -1521,7 +1449,6 @@
|
|
|
1521
1449
|
}
|
|
1522
1450
|
|
|
1523
1451
|
break;
|
|
1524
|
-
|
|
1525
1452
|
case LOSSY_DCT: // skip
|
|
1526
1453
|
|
|
1527
1454
|
default:
|
|
@@ -1539,7 +1466,6 @@
|
|
|
1539
1466
|
|
|
1540
1467
|
const uintBuffer = new Uint8Array( buffer );
|
|
1541
1468
|
let endOffset = 0;
|
|
1542
|
-
|
|
1543
1469
|
while ( uintBuffer[ offset.value + endOffset ] != 0 ) {
|
|
1544
1470
|
|
|
1545
1471
|
endOffset += 1;
|
|
@@ -1628,9 +1554,9 @@
|
|
|
1628
1554
|
|
|
1629
1555
|
return THREE.DataUtils.toHalfFloat( parseFloat32( dataView, offset ) );
|
|
1630
1556
|
|
|
1631
|
-
}
|
|
1632
|
-
|
|
1557
|
+
}
|
|
1633
1558
|
|
|
1559
|
+
// https://stackoverflow.com/questions/5678432/decompressing-half-precision-floats-in-javascript
|
|
1634
1560
|
function decodeFloat16( binary ) {
|
|
1635
1561
|
|
|
1636
1562
|
const exponent = ( binary & 0x7C00 ) >> 10,
|
|
@@ -1657,14 +1583,12 @@
|
|
|
1657
1583
|
|
|
1658
1584
|
const startOffset = offset.value;
|
|
1659
1585
|
const channels = [];
|
|
1660
|
-
|
|
1661
1586
|
while ( offset.value < startOffset + size - 1 ) {
|
|
1662
1587
|
|
|
1663
1588
|
const name = parseNullTerminatedString( buffer, offset );
|
|
1664
1589
|
const pixelType = parseInt32( dataView, offset );
|
|
1665
1590
|
const pLinear = parseUint8( dataView, offset );
|
|
1666
1591
|
offset.value += 3; // reserved, three chars
|
|
1667
|
-
|
|
1668
1592
|
const xSampling = parseInt32( dataView, offset );
|
|
1669
1593
|
const ySampling = parseInt32( dataView, offset );
|
|
1670
1594
|
channels.push( {
|
|
@@ -1820,10 +1744,10 @@
|
|
|
1820
1744
|
function parseHeader( dataView, buffer, offset ) {
|
|
1821
1745
|
|
|
1822
1746
|
const EXRHeader = {};
|
|
1823
|
-
|
|
1824
1747
|
if ( dataView.getUint32( 0, true ) != 20000630 ) {
|
|
1825
1748
|
|
|
1826
1749
|
// magic
|
|
1750
|
+
|
|
1827
1751
|
throw new Error( 'THREE.EXRLoader: provided file doesn\'t appear to be in OpenEXR format.' );
|
|
1828
1752
|
|
|
1829
1753
|
}
|
|
@@ -1836,16 +1760,16 @@
|
|
|
1836
1760
|
longName: !! ( spec & 4 ),
|
|
1837
1761
|
deepFormat: !! ( spec & 8 ),
|
|
1838
1762
|
multiPart: !! ( spec & 16 )
|
|
1839
|
-
};
|
|
1763
|
+
};
|
|
1764
|
+
|
|
1765
|
+
// start of header
|
|
1840
1766
|
|
|
1841
1767
|
offset.value = 8; // start at 8 - after pre-amble
|
|
1842
1768
|
|
|
1843
1769
|
let keepReading = true;
|
|
1844
|
-
|
|
1845
1770
|
while ( keepReading ) {
|
|
1846
1771
|
|
|
1847
1772
|
const attributeName = parseNullTerminatedString( buffer, offset );
|
|
1848
|
-
|
|
1849
1773
|
if ( attributeName == 0 ) {
|
|
1850
1774
|
|
|
1851
1775
|
keepReading = false;
|
|
@@ -1855,7 +1779,6 @@
|
|
|
1855
1779
|
const attributeType = parseNullTerminatedString( buffer, offset );
|
|
1856
1780
|
const attributeSize = parseUint32( dataView, offset );
|
|
1857
1781
|
const attributeValue = parseValue( dataView, buffer, offset, attributeType, attributeSize );
|
|
1858
|
-
|
|
1859
1782
|
if ( attributeValue === undefined ) {
|
|
1860
1783
|
|
|
1861
1784
|
console.warn( `EXRLoader.parse: skipped unknown header attribute type \'${attributeType}\'.` );
|
|
@@ -1873,6 +1796,7 @@
|
|
|
1873
1796
|
if ( ( spec & ~ 0x04 ) != 0 ) {
|
|
1874
1797
|
|
|
1875
1798
|
// unsupported tiled, deep-image, multi-part
|
|
1799
|
+
|
|
1876
1800
|
console.error( 'EXRHeader:', EXRHeader );
|
|
1877
1801
|
throw new Error( 'THREE.EXRLoader: provided file is currently unsupported.' );
|
|
1878
1802
|
|
|
@@ -1901,56 +1825,46 @@
|
|
|
1901
1825
|
format: null,
|
|
1902
1826
|
encoding: null
|
|
1903
1827
|
};
|
|
1904
|
-
|
|
1905
1828
|
switch ( EXRHeader.compression ) {
|
|
1906
1829
|
|
|
1907
1830
|
case 'NO_COMPRESSION':
|
|
1908
1831
|
EXRDecoder.lines = 1;
|
|
1909
1832
|
EXRDecoder.uncompress = uncompressRAW;
|
|
1910
1833
|
break;
|
|
1911
|
-
|
|
1912
1834
|
case 'RLE_COMPRESSION':
|
|
1913
1835
|
EXRDecoder.lines = 1;
|
|
1914
1836
|
EXRDecoder.uncompress = uncompressRLE;
|
|
1915
1837
|
break;
|
|
1916
|
-
|
|
1917
1838
|
case 'ZIPS_COMPRESSION':
|
|
1918
1839
|
EXRDecoder.lines = 1;
|
|
1919
1840
|
EXRDecoder.uncompress = uncompressZIP;
|
|
1920
1841
|
break;
|
|
1921
|
-
|
|
1922
1842
|
case 'ZIP_COMPRESSION':
|
|
1923
1843
|
EXRDecoder.lines = 16;
|
|
1924
1844
|
EXRDecoder.uncompress = uncompressZIP;
|
|
1925
1845
|
break;
|
|
1926
|
-
|
|
1927
1846
|
case 'PIZ_COMPRESSION':
|
|
1928
1847
|
EXRDecoder.lines = 32;
|
|
1929
1848
|
EXRDecoder.uncompress = uncompressPIZ;
|
|
1930
1849
|
break;
|
|
1931
|
-
|
|
1932
1850
|
case 'PXR24_COMPRESSION':
|
|
1933
1851
|
EXRDecoder.lines = 16;
|
|
1934
1852
|
EXRDecoder.uncompress = uncompressPXR;
|
|
1935
1853
|
break;
|
|
1936
|
-
|
|
1937
1854
|
case 'DWAA_COMPRESSION':
|
|
1938
1855
|
EXRDecoder.lines = 32;
|
|
1939
1856
|
EXRDecoder.uncompress = uncompressDWA;
|
|
1940
1857
|
break;
|
|
1941
|
-
|
|
1942
1858
|
case 'DWAB_COMPRESSION':
|
|
1943
1859
|
EXRDecoder.lines = 256;
|
|
1944
1860
|
EXRDecoder.uncompress = uncompressDWA;
|
|
1945
1861
|
break;
|
|
1946
|
-
|
|
1947
1862
|
default:
|
|
1948
1863
|
throw new Error( 'EXRLoader.parse: ' + EXRHeader.compression + ' is unsupported' );
|
|
1949
1864
|
|
|
1950
1865
|
}
|
|
1951
1866
|
|
|
1952
1867
|
EXRDecoder.scanlineBlockSize = EXRDecoder.lines;
|
|
1953
|
-
|
|
1954
1868
|
if ( EXRDecoder.type == 1 ) {
|
|
1955
1869
|
|
|
1956
1870
|
// half
|
|
@@ -1960,7 +1874,6 @@
|
|
|
1960
1874
|
EXRDecoder.getter = parseFloat16;
|
|
1961
1875
|
EXRDecoder.inputSize = INT16_SIZE;
|
|
1962
1876
|
break;
|
|
1963
|
-
|
|
1964
1877
|
case THREE.HalfFloatType:
|
|
1965
1878
|
EXRDecoder.getter = parseUint16;
|
|
1966
1879
|
EXRDecoder.inputSize = INT16_SIZE;
|
|
@@ -1977,7 +1890,6 @@
|
|
|
1977
1890
|
EXRDecoder.getter = parseFloat32;
|
|
1978
1891
|
EXRDecoder.inputSize = FLOAT32_SIZE;
|
|
1979
1892
|
break;
|
|
1980
|
-
|
|
1981
1893
|
case THREE.HalfFloatType:
|
|
1982
1894
|
EXRDecoder.getter = decodeFloat32;
|
|
1983
1895
|
EXRDecoder.inputSize = FLOAT32_SIZE;
|
|
@@ -1991,29 +1903,26 @@
|
|
|
1991
1903
|
}
|
|
1992
1904
|
|
|
1993
1905
|
EXRDecoder.blockCount = ( EXRHeader.dataWindow.yMax + 1 ) / EXRDecoder.scanlineBlockSize;
|
|
1994
|
-
|
|
1995
1906
|
for ( let i = 0; i < EXRDecoder.blockCount; i ++ ) parseInt64( dataView, offset ); // scanlineOffset
|
|
1996
|
-
// we should be passed the scanline offset table, ready to start reading pixel data.
|
|
1997
|
-
// RGB images will be converted to RGBA format, preventing software emulation in select devices.
|
|
1998
1907
|
|
|
1908
|
+
// we should be passed the scanline offset table, ready to start reading pixel data.
|
|
1999
1909
|
|
|
1910
|
+
// RGB images will be converted to RGBA format, preventing software emulation in select devices.
|
|
2000
1911
|
EXRDecoder.outputChannels = EXRDecoder.channels == 3 ? 4 : EXRDecoder.channels;
|
|
2001
1912
|
const size = EXRDecoder.width * EXRDecoder.height * EXRDecoder.outputChannels;
|
|
2002
|
-
|
|
2003
1913
|
switch ( outputType ) {
|
|
2004
1914
|
|
|
2005
1915
|
case THREE.FloatType:
|
|
2006
|
-
EXRDecoder.byteArray = new Float32Array( size );
|
|
1916
|
+
EXRDecoder.byteArray = new Float32Array( size );
|
|
2007
1917
|
|
|
1918
|
+
// Fill initially with 1s for the alpha value if the texture is not RGBA, RGB values will be overwritten
|
|
2008
1919
|
if ( EXRDecoder.channels < EXRDecoder.outputChannels ) EXRDecoder.byteArray.fill( 1, 0, size );
|
|
2009
1920
|
break;
|
|
2010
|
-
|
|
2011
1921
|
case THREE.HalfFloatType:
|
|
2012
1922
|
EXRDecoder.byteArray = new Uint16Array( size );
|
|
2013
1923
|
if ( EXRDecoder.channels < EXRDecoder.outputChannels ) EXRDecoder.byteArray.fill( 0x3C00, 0, size ); // Uint16Array holds half float data, 0x3C00 is 1
|
|
2014
1924
|
|
|
2015
1925
|
break;
|
|
2016
|
-
|
|
2017
1926
|
default:
|
|
2018
1927
|
console.error( 'THREE.EXRLoader: unsupported type: ', outputType );
|
|
2019
1928
|
break;
|
|
@@ -2021,7 +1930,6 @@
|
|
|
2021
1930
|
}
|
|
2022
1931
|
|
|
2023
1932
|
EXRDecoder.bytesPerLine = EXRDecoder.width * EXRDecoder.inputSize * EXRDecoder.channels;
|
|
2024
|
-
|
|
2025
1933
|
if ( EXRDecoder.outputChannels == 4 ) {
|
|
2026
1934
|
|
|
2027
1935
|
EXRDecoder.format = THREE.RGBAFormat;
|
|
@@ -2036,17 +1944,20 @@
|
|
|
2036
1944
|
|
|
2037
1945
|
return EXRDecoder;
|
|
2038
1946
|
|
|
2039
|
-
}
|
|
1947
|
+
}
|
|
2040
1948
|
|
|
1949
|
+
// start parsing file [START]
|
|
2041
1950
|
|
|
2042
1951
|
const bufferDataView = new DataView( buffer );
|
|
2043
1952
|
const uInt8Array = new Uint8Array( buffer );
|
|
2044
1953
|
const offset = {
|
|
2045
1954
|
value: 0
|
|
2046
|
-
};
|
|
1955
|
+
};
|
|
2047
1956
|
|
|
2048
|
-
|
|
1957
|
+
// get header information and validate format.
|
|
1958
|
+
const EXRHeader = parseHeader( bufferDataView, buffer, offset );
|
|
2049
1959
|
|
|
1960
|
+
// get input compression information and prepare decoding.
|
|
2050
1961
|
const EXRDecoder = setupDecoder( EXRHeader, bufferDataView, uInt8Array, offset, this.type );
|
|
2051
1962
|
const tmpOffset = {
|
|
2052
1963
|
value: 0
|
|
@@ -2058,27 +1969,21 @@
|
|
|
2058
1969
|
A: 3,
|
|
2059
1970
|
Y: 0
|
|
2060
1971
|
};
|
|
2061
|
-
|
|
2062
1972
|
for ( let scanlineBlockIdx = 0; scanlineBlockIdx < EXRDecoder.height / EXRDecoder.scanlineBlockSize; scanlineBlockIdx ++ ) {
|
|
2063
1973
|
|
|
2064
1974
|
const line = parseUint32( bufferDataView, offset ); // line_no
|
|
2065
|
-
|
|
2066
1975
|
EXRDecoder.size = parseUint32( bufferDataView, offset ); // data_len
|
|
2067
|
-
|
|
2068
1976
|
EXRDecoder.lines = line + EXRDecoder.scanlineBlockSize > EXRDecoder.height ? EXRDecoder.height - line : EXRDecoder.scanlineBlockSize;
|
|
2069
1977
|
const isCompressed = EXRDecoder.size < EXRDecoder.lines * EXRDecoder.bytesPerLine;
|
|
2070
1978
|
const viewer = isCompressed ? EXRDecoder.uncompress( EXRDecoder ) : uncompressRAW( EXRDecoder );
|
|
2071
1979
|
offset.value += EXRDecoder.size;
|
|
2072
|
-
|
|
2073
1980
|
for ( let line_y = 0; line_y < EXRDecoder.scanlineBlockSize; line_y ++ ) {
|
|
2074
1981
|
|
|
2075
1982
|
const true_y = line_y + scanlineBlockIdx * EXRDecoder.scanlineBlockSize;
|
|
2076
1983
|
if ( true_y >= EXRDecoder.height ) break;
|
|
2077
|
-
|
|
2078
1984
|
for ( let channelID = 0; channelID < EXRDecoder.channels; channelID ++ ) {
|
|
2079
1985
|
|
|
2080
1986
|
const cOff = channelOffsets[ EXRHeader.channels[ channelID ].name ];
|
|
2081
|
-
|
|
2082
1987
|
for ( let x = 0; x < EXRDecoder.width; x ++ ) {
|
|
2083
1988
|
|
|
2084
1989
|
tmpOffset.value = ( line_y * ( EXRDecoder.channels * EXRDecoder.width ) + channelID * EXRDecoder.width + x ) * EXRDecoder.inputSize;
|
|
@@ -2104,14 +2009,12 @@
|
|
|
2104
2009
|
};
|
|
2105
2010
|
|
|
2106
2011
|
}
|
|
2107
|
-
|
|
2108
2012
|
setDataType( value ) {
|
|
2109
2013
|
|
|
2110
2014
|
this.type = value;
|
|
2111
2015
|
return this;
|
|
2112
2016
|
|
|
2113
2017
|
}
|
|
2114
|
-
|
|
2115
2018
|
load( url, onLoad, onProgress, onError ) {
|
|
2116
2019
|
|
|
2117
2020
|
function onLoadCallback( texture, texData ) {
|