@needle-tools/three 0.162.12 → 0.169.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 +3 -3
- package/build/three.cjs +29789 -1941
- package/build/three.module.js +29095 -1933
- package/build/three.module.min.js +2 -2
- package/build/three.webgpu.js +80003 -0
- package/build/three.webgpu.min.js +6 -0
- package/build/three.webgpu.nodes.js +79951 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/jsm/Addons.js +2 -5
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/animation/CCDIKSolver.js +4 -2
- package/examples/jsm/capabilities/WebGL.js +27 -21
- package/examples/jsm/controls/ArcballControls.js +174 -158
- package/examples/jsm/controls/DragControls.js +260 -132
- package/examples/jsm/controls/FirstPersonControls.js +175 -163
- package/examples/jsm/controls/FlyControls.js +194 -188
- package/examples/jsm/controls/OrbitControls.js +790 -797
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +469 -448
- package/examples/jsm/controls/TransformControls.js +98 -63
- package/examples/jsm/csm/CSMShader.js +4 -4
- package/examples/jsm/effects/AnaglyphEffect.js +6 -13
- package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
- package/examples/jsm/effects/StereoEffect.js +6 -1
- package/examples/jsm/environments/RoomEnvironment.js +2 -6
- package/examples/jsm/exporters/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- package/examples/jsm/exporters/GLTFExporter.js +77 -8
- package/examples/jsm/exporters/KTX2Exporter.js +21 -13
- package/examples/jsm/exporters/OBJExporter.js +5 -1
- package/examples/jsm/exporters/PLYExporter.js +9 -7
- package/examples/jsm/exporters/USDZExporter.js +55 -11
- package/examples/jsm/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/geometries/TeapotGeometry.js +1 -1
- package/examples/jsm/geometries/TextGeometry.js +10 -2
- package/examples/jsm/helpers/LightProbeHelper.js +43 -44
- package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
- package/examples/jsm/helpers/ViewHelper.js +75 -61
- package/examples/jsm/interactive/HTMLMesh.js +7 -9
- package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/draco/README.md +2 -2
- package/examples/jsm/libs/fflate.module.js +694 -496
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/LightProbeGenerator.js +24 -10
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +91 -0
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +8 -63
- package/examples/jsm/lines/LineMaterial.js +1 -17
- package/examples/jsm/lines/LineSegments2.js +15 -0
- package/examples/jsm/lines/Wireframe.js +16 -1
- package/examples/jsm/lines/webgpu/Line2.js +20 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +376 -0
- package/examples/jsm/loaders/3MFLoader.js +2 -0
- package/examples/jsm/loaders/ColladaLoader.js +9 -6
- package/examples/jsm/loaders/DRACOLoader.js +4 -2
- package/examples/jsm/loaders/EXRLoader.js +351 -97
- package/examples/jsm/loaders/FBXLoader.js +77 -78
- package/examples/jsm/loaders/GLTFLoader.js +76 -14
- package/examples/jsm/loaders/KTX2Loader.js +30 -22
- package/examples/jsm/loaders/LDrawLoader.js +3 -2
- package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
- package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
- package/examples/jsm/loaders/LUTImageLoader.js +0 -14
- package/examples/jsm/loaders/MMDLoader.js +31 -12
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +45 -21
- package/examples/jsm/loaders/OBJLoader.js +5 -3
- package/examples/jsm/loaders/PCDLoader.js +14 -13
- package/examples/jsm/loaders/PDBLoader.js +3 -2
- package/examples/jsm/loaders/PLYLoader.js +8 -5
- package/examples/jsm/loaders/RGBMLoader.js +16 -0
- package/examples/jsm/loaders/STLLoader.js +3 -2
- package/examples/jsm/loaders/USDZLoader.js +124 -76
- package/examples/jsm/loaders/UltraHDRLoader.js +583 -0
- package/examples/jsm/loaders/VRMLLoader.js +11 -11
- package/examples/jsm/loaders/VTKLoader.js +80 -6
- package/examples/jsm/loaders/XYZLoader.js +3 -2
- package/examples/jsm/loaders/lwo/IFFParser.js +8 -5
- package/examples/jsm/materials/MeshGouraudMaterial.js +7 -1
- package/examples/jsm/math/Octree.js +26 -20
- package/examples/jsm/misc/GPUComputationRenderer.js +9 -25
- package/examples/jsm/misc/Timer.js +1 -1
- package/examples/jsm/modifiers/CurveModifier.js +11 -9
- package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
- package/examples/jsm/modifiers/SimplifyModifier.js +2 -1
- package/examples/jsm/objects/InstancedPoints.js +2 -2
- package/examples/jsm/objects/Lensflare.js +2 -2
- package/examples/jsm/objects/LensflareMesh.js +322 -0
- package/examples/jsm/objects/SkyMesh.js +187 -0
- package/examples/jsm/objects/Water2Mesh.js +158 -0
- package/examples/jsm/objects/WaterMesh.js +101 -0
- package/examples/jsm/physics/JoltPhysics.js +281 -0
- package/examples/jsm/physics/RapierPhysics.js +25 -5
- package/examples/jsm/postprocessing/GlitchPass.js +0 -3
- package/examples/jsm/postprocessing/LUTPass.js +5 -71
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/RenderPass.js +1 -1
- package/examples/jsm/postprocessing/RenderTransitionPass.js +168 -0
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/postprocessing/SSAOPass.js +6 -12
- package/examples/jsm/postprocessing/UnrealBloomPass.js +4 -4
- package/examples/jsm/renderers/CSS2DRenderer.js +25 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +24 -3
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +1 -3
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +7 -4
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +19 -5
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/ColorifyShader.js +1 -2
- package/examples/jsm/shaders/FXAAShader.js +0 -2
- package/examples/jsm/shaders/GTAOShader.js +1 -1
- package/examples/jsm/shaders/LuminosityHighPassShader.js +1 -3
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +47 -5
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +24 -22
- package/examples/jsm/utils/BufferGeometryUtils.js +18 -16
- package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
- package/examples/jsm/utils/SceneUtils.js +60 -1
- package/examples/jsm/utils/ShadowMapViewer.js +3 -8
- package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
- package/examples/jsm/utils/SkeletonUtils.js +84 -66
- package/examples/jsm/utils/SortUtils.js +8 -5
- package/examples/jsm/utils/TextureUtils.js +3 -2
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/OculusHandModel.js +3 -2
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/examples/jsm/webxr/XRHandModelFactory.js +4 -2
- package/package.json +11 -8
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +201 -0
- package/src/Three.js +23 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +10 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -2
- package/src/animation/tracks/StringKeyframeTrack.js +10 -1
- package/src/audio/Audio.js +2 -2
- package/src/constants.js +6 -7
- package/src/core/BufferAttribute.js +0 -9
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +0 -9
- package/src/core/Object3D.js +34 -29
- package/src/core/Raycaster.js +6 -2
- package/src/core/RenderTarget.js +8 -0
- package/src/extras/Controls.js +32 -0
- package/src/extras/PMREMGenerator.js +12 -11
- package/src/extras/TextureUtils.js +210 -0
- package/src/geometries/CylinderGeometry.js +11 -4
- package/src/lights/Light.js +1 -0
- package/src/lights/LightShadow.js +5 -0
- package/{examples/jsm/lights → src/lights/webgpu}/IESSpotLight.js +1 -1
- package/src/loaders/FileLoader.js +5 -1
- package/src/loaders/LoaderUtils.js +3 -1
- package/src/loaders/MaterialLoader.js +8 -1
- package/src/loaders/ObjectLoader.js +36 -2
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeLoader.js +27 -5
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeMaterialLoader.js +22 -18
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeObjectLoader.js +21 -1
- package/src/materials/Material.js +4 -0
- package/src/materials/MeshPhysicalMaterial.js +20 -0
- package/src/materials/ShaderMaterial.js +0 -4
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +156 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/Line2NodeMaterial.js +69 -68
- package/src/materials/nodes/LineBasicNodeMaterial.js +31 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/LineDashedNodeMaterial.js +15 -12
- package/src/materials/nodes/MeshBasicNodeMaterial.js +77 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.js +47 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +57 -0
- package/src/materials/nodes/MeshNormalNodeMaterial.js +44 -0
- package/src/materials/nodes/MeshPhongNodeMaterial.js +78 -0
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +248 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshSSSNodeMaterial.js +10 -7
- package/src/materials/nodes/MeshStandardNodeMaterial.js +108 -0
- package/src/materials/nodes/MeshToonNodeMaterial.js +38 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/NodeMaterial.js +198 -157
- package/{examples/jsm/nodes/materials/Materials.js → src/materials/nodes/NodeMaterials.js} +7 -1
- package/{examples/jsm/nodes/materials → src/materials/nodes}/PointsNodeMaterial.js +10 -7
- package/src/materials/nodes/ShadowNodeMaterial.js +38 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +123 -0
- package/src/materials/nodes/VolumeNodeMaterial.js +108 -0
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- package/src/math/Box2.js +4 -4
- package/src/math/Box3.js +6 -6
- package/src/math/ColorManagement.js +10 -0
- package/src/math/Matrix2.js +54 -0
- package/src/math/Spherical.js +4 -5
- package/src/math/Triangle.js +24 -0
- package/src/math/Vector4.js +13 -0
- package/src/nodes/Nodes.js +164 -0
- package/src/nodes/TSL.js +179 -0
- package/src/nodes/accessors/AccessorsUtils.js +25 -0
- package/src/nodes/accessors/BatchNode.js +128 -0
- package/src/nodes/accessors/Bitangent.js +13 -0
- package/{examples/jsm → src}/nodes/accessors/BufferAttributeNode.js +44 -6
- package/{examples/jsm → src}/nodes/accessors/BufferNode.js +13 -4
- package/src/nodes/accessors/Camera.js +13 -0
- package/{examples/jsm → src}/nodes/accessors/ClippingNode.js +22 -15
- package/src/nodes/accessors/CubeTextureNode.js +79 -0
- package/src/nodes/accessors/InstanceNode.js +144 -0
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +24 -0
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +441 -0
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/{examples/jsm → src}/nodes/accessors/MaterialReferenceNode.js +10 -5
- package/src/nodes/accessors/ModelNode.js +72 -0
- package/src/nodes/accessors/ModelViewProjectionNode.js +42 -0
- package/{examples/jsm → src}/nodes/accessors/MorphNode.js +51 -33
- package/src/nodes/accessors/Normal.js +88 -0
- package/{examples/jsm → src}/nodes/accessors/Object3DNode.js +18 -34
- package/src/nodes/accessors/PointUVNode.js +30 -0
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +171 -0
- package/{examples/jsm → src}/nodes/accessors/ReferenceNode.js +58 -9
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +35 -0
- package/{examples/jsm → src}/nodes/accessors/SceneNode.js +9 -6
- package/src/nodes/accessors/SkinningNode.js +191 -0
- package/src/nodes/accessors/StorageBufferNode.js +147 -0
- package/{examples/jsm/nodes/accessors/TextureStoreNode.js → src/nodes/accessors/StorageTextureNode.js} +35 -10
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +103 -0
- package/{examples/jsm/nodes/accessors/TextureBicubicNode.js → src/nodes/accessors/TextureBicubic.js} +3 -32
- package/{examples/jsm → src}/nodes/accessors/TextureNode.js +123 -39
- package/src/nodes/accessors/TextureSizeNode.js +36 -0
- package/src/nodes/accessors/UV.js +3 -0
- package/{examples/jsm/nodes/accessors/UniformsNode.js → src/nodes/accessors/UniformArrayNode.js} +33 -15
- package/{examples/jsm → src}/nodes/accessors/UserDataNode.js +10 -7
- package/src/nodes/accessors/VelocityNode.js +134 -0
- package/{examples/jsm → src}/nodes/accessors/VertexColorNode.js +9 -5
- package/{examples/jsm → src}/nodes/code/CodeNode.js +9 -5
- package/{examples/jsm → src}/nodes/code/ExpressionNode.js +10 -6
- package/{examples/jsm → src}/nodes/code/FunctionCallNode.js +8 -5
- package/{examples/jsm → src}/nodes/code/FunctionNode.js +8 -31
- package/{examples/jsm → src}/nodes/code/ScriptableNode.js +24 -7
- package/{examples/jsm → src}/nodes/code/ScriptableValueNode.js +11 -8
- package/{examples/jsm → src}/nodes/core/AssignNode.js +12 -9
- package/{examples/jsm → src}/nodes/core/AttributeNode.js +29 -12
- package/{examples/jsm → src}/nodes/core/BypassNode.js +11 -7
- package/src/nodes/core/CacheNode.js +50 -0
- package/{examples/jsm → src}/nodes/core/ConstNode.js +6 -3
- package/{examples/jsm → src}/nodes/core/ContextNode.js +27 -11
- package/src/nodes/core/IndexNode.js +99 -0
- package/{examples/jsm → src}/nodes/core/InputNode.js +7 -3
- package/{examples/jsm → src}/nodes/core/LightingModel.js +2 -2
- package/src/nodes/core/MRTNode.js +85 -0
- package/{examples/jsm → src}/nodes/core/Node.js +114 -57
- package/{examples/jsm → src}/nodes/core/NodeBuilder.js +327 -90
- package/src/nodes/core/NodeCache.js +36 -0
- package/{examples/jsm → src}/nodes/core/NodeFrame.js +52 -10
- package/{examples/jsm → src}/nodes/core/NodeFunction.js +2 -2
- package/{examples/jsm → src}/nodes/core/NodeUniform.js +1 -2
- package/{examples/jsm → src}/nodes/core/NodeUtils.js +56 -8
- package/{examples/jsm → src}/nodes/core/OutputStructNode.js +13 -12
- package/{examples/jsm → src}/nodes/core/ParameterNode.js +7 -4
- package/src/nodes/core/PropertyNode.js +88 -0
- package/{examples/jsm → src}/nodes/core/StackNode.js +31 -11
- package/{examples/jsm → src}/nodes/core/StructTypeNode.js +7 -3
- package/{examples/jsm → src}/nodes/core/TempNode.js +10 -6
- package/src/nodes/core/UniformGroupNode.js +59 -0
- package/{examples/jsm → src}/nodes/core/UniformNode.js +37 -5
- package/{examples/jsm → src}/nodes/core/VarNode.js +14 -14
- package/src/nodes/core/VaryingNode.js +108 -0
- package/{examples/jsm → src}/nodes/display/AfterImageNode.js +38 -28
- package/src/nodes/display/AnaglyphPassNode.js +67 -0
- package/{examples/jsm → src}/nodes/display/AnamorphicNode.js +33 -30
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +341 -0
- package/{examples/jsm → src}/nodes/display/BumpMapNode.js +20 -38
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +114 -0
- package/src/nodes/display/DenoiseNode.js +204 -0
- package/src/nodes/display/DepthOfFieldNode.js +124 -0
- package/src/nodes/display/DotScreenNode.js +66 -0
- package/src/nodes/display/FXAANode.js +332 -0
- package/src/nodes/display/FilmNode.js +56 -0
- package/src/nodes/display/FrontFacingNode.js +45 -0
- package/src/nodes/display/GTAONode.js +331 -0
- package/{examples/jsm → src}/nodes/display/GaussianBlurNode.js +47 -24
- package/src/nodes/display/Lut3DNode.js +57 -0
- package/src/nodes/display/MotionBlur.js +25 -0
- package/{examples/jsm → src}/nodes/display/NormalMapNode.js +14 -14
- package/src/nodes/display/ParallaxBarrierPassNode.js +58 -0
- package/src/nodes/display/PassNode.js +378 -0
- package/src/nodes/display/PixelationPassNode.js +213 -0
- package/{examples/jsm → src}/nodes/display/PosterizeNode.js +8 -7
- package/src/nodes/display/RGBShiftNode.js +53 -0
- package/src/nodes/display/RenderOutputNode.js +60 -0
- package/src/nodes/display/SSAAPassNode.js +287 -0
- package/src/nodes/display/ScreenNode.js +181 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +126 -0
- package/src/nodes/display/StereoCompositePassNode.js +110 -0
- package/src/nodes/display/StereoPassNode.js +83 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +67 -0
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +80 -0
- package/src/nodes/display/ViewportDepthNode.js +125 -0
- package/src/nodes/display/ViewportDepthTextureNode.js +33 -0
- package/src/nodes/display/ViewportSharedTextureNode.js +39 -0
- package/{examples/jsm → src}/nodes/display/ViewportTextureNode.js +20 -14
- package/src/nodes/fog/FogExp2Node.js +35 -0
- package/src/nodes/fog/FogNode.js +50 -0
- package/src/nodes/fog/FogRangeNode.js +36 -0
- package/src/nodes/functions/BSDF/BRDF_GGX.js +59 -0
- package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/{examples/jsm → src}/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
- package/{examples/jsm → src}/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +131 -0
- package/{examples/jsm → src}/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -4
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
- package/src/nodes/functions/BasicLightingModel.js +78 -0
- package/{examples/jsm → src}/nodes/functions/PhongLightingModel.js +11 -9
- package/src/nodes/functions/PhysicalLightingModel.js +633 -0
- package/src/nodes/functions/ShadowMaskModel.js +31 -0
- package/src/nodes/functions/ToonLightingModel.js +51 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +13 -0
- package/{examples/jsm → src}/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/{examples/jsm → src}/nodes/geometry/RangeNode.js +28 -11
- package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
- package/src/nodes/gpgpu/BarrierNode.js +40 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
- package/{examples/jsm → src}/nodes/gpgpu/ComputeNode.js +10 -6
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +27 -0
- package/{examples/jsm → src}/nodes/lighting/AmbientLightNode.js +6 -8
- package/src/nodes/lighting/AnalyticLightNode.js +522 -0
- package/src/nodes/lighting/BasicEnvironmentNode.js +30 -0
- package/src/nodes/lighting/BasicLightMapNode.js +32 -0
- package/{examples/jsm → src}/nodes/lighting/DirectionalLightNode.js +7 -9
- package/src/nodes/lighting/EnvironmentNode.js +138 -0
- package/{examples/jsm → src}/nodes/lighting/HemisphereLightNode.js +12 -11
- package/{examples/jsm → src}/nodes/lighting/IESSpotLightNode.js +7 -9
- package/src/nodes/lighting/IrradianceNode.js +27 -0
- package/src/nodes/lighting/LightProbeNode.js +53 -0
- package/{examples/jsm → src}/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +67 -0
- package/{examples/jsm → src}/nodes/lighting/LightingNode.js +9 -3
- package/src/nodes/lighting/LightsNode.js +250 -0
- package/{examples/jsm → src}/nodes/lighting/PointLightNode.js +12 -13
- package/src/nodes/lighting/RectAreaLightNode.js +97 -0
- package/{examples/jsm → src}/nodes/lighting/SpotLightNode.js +14 -16
- package/{examples/jsm → src}/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +127 -0
- package/{examples/jsm → src}/nodes/materialx/lib/mx_noise.js +500 -603
- package/{examples/jsm → src}/nodes/materialx/lib/mx_transform_color.js +3 -9
- package/{examples/jsm/nodes/math/CondNode.js → src/nodes/math/ConditionalNode.js} +48 -13
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +407 -0
- package/{examples/jsm → src}/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +319 -0
- package/{examples/jsm → src}/nodes/math/TriNoise3D.js +19 -29
- package/{examples/jsm → src}/nodes/parsers/GLSLNodeFunction.js +7 -7
- package/src/nodes/pmrem/PMREMNode.js +240 -0
- package/src/nodes/pmrem/PMREMUtils.js +288 -0
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/{examples/jsm/nodes/shadernode/ShaderNode.js → src/nodes/tsl/TSLCore.js} +122 -96
- package/{examples/jsm → src}/nodes/utils/ArrayElementNode.js +9 -5
- package/{examples/jsm → src}/nodes/utils/ConvertNode.js +7 -3
- package/src/nodes/utils/CubeMapNode.js +160 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +36 -0
- package/src/nodes/utils/FlipNode.js +68 -0
- package/{examples/jsm → src}/nodes/utils/FunctionOverloadingNode.js +11 -5
- package/{examples/jsm → src}/nodes/utils/JoinNode.js +6 -3
- package/{examples/jsm → src}/nodes/utils/LoopNode.js +23 -12
- package/src/nodes/utils/MatcapUVNode.js +33 -0
- package/{examples/jsm → src}/nodes/utils/MaxMipLevelNode.js +16 -7
- package/{examples/jsm → src}/nodes/utils/OscNode.js +12 -8
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +133 -0
- package/{examples/jsm → src}/nodes/utils/ReflectorNode.js +21 -5
- package/{examples/jsm → src}/nodes/utils/RemapNode.js +12 -8
- package/{examples/jsm → src}/nodes/utils/RotateNode.js +8 -13
- package/{examples/jsm → src}/nodes/utils/SetNode.js +7 -4
- package/{examples/jsm → src}/nodes/utils/SplitNode.js +7 -3
- package/{examples/jsm → src}/nodes/utils/SpriteSheetUVNode.js +10 -6
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/{examples/jsm → src}/nodes/utils/StorageArrayElementNode.js +11 -12
- package/{examples/jsm → src}/nodes/utils/TimerNode.js +8 -5
- package/{examples/jsm → src}/nodes/utils/TriplanarTexturesNode.js +11 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +302 -144
- package/src/objects/InstancedMesh.js +11 -1
- package/src/objects/LOD.js +21 -0
- package/src/objects/Line.js +67 -43
- package/src/objects/Mesh.js +7 -23
- package/src/objects/Points.js +2 -0
- package/src/renderers/WebGLRenderer.js +473 -224
- package/{examples/jsm → src}/renderers/common/Animation.js +3 -0
- package/{examples/jsm → src}/renderers/common/Attributes.js +4 -1
- package/{examples/jsm → src}/renderers/common/Backend.js +30 -27
- package/{examples/jsm → src}/renderers/common/Background.js +18 -10
- package/src/renderers/common/BindGroup.js +18 -0
- package/src/renderers/common/Bindings.js +203 -0
- package/src/renderers/common/BundleGroup.js +26 -0
- package/src/renderers/common/ChainMap.js +59 -0
- package/{examples/jsm → src}/renderers/common/ClippingContext.js +24 -12
- package/{examples/jsm → src}/renderers/common/Color4.js +1 -1
- package/{examples/jsm → src}/renderers/common/CubeRenderTarget.js +16 -4
- package/{examples/jsm → src}/renderers/common/Geometries.js +37 -5
- package/{examples/jsm → src}/renderers/common/Info.js +35 -15
- package/{examples/jsm → src}/renderers/common/Pipelines.js +2 -2
- package/src/renderers/common/PostProcessing.js +90 -0
- package/src/renderers/common/QuadMesh.js +55 -0
- package/src/renderers/common/RenderBundle.js +18 -0
- package/src/renderers/common/RenderBundles.js +38 -0
- package/{examples/jsm → src}/renderers/common/RenderContext.js +25 -2
- package/{examples/jsm → src}/renderers/common/RenderContexts.js +1 -1
- package/{examples/jsm → src}/renderers/common/RenderList.js +11 -2
- package/src/renderers/common/RenderObject.js +413 -0
- package/{examples/jsm → src}/renderers/common/RenderObjects.js +9 -2
- package/{examples/jsm → src}/renderers/common/Renderer.js +431 -83
- package/{examples/jsm → src}/renderers/common/SampledTexture.js +14 -5
- package/{examples/jsm → src}/renderers/common/StorageBufferAttribute.js +1 -1
- package/{examples/jsm → src}/renderers/common/StorageInstancedBufferAttribute.js +1 -1
- package/{examples/jsm → src}/renderers/common/StorageTexture.js +2 -1
- package/{examples/jsm → src}/renderers/common/Textures.js +15 -15
- package/{examples/jsm → src}/renderers/common/Uniform.js +10 -5
- package/{examples/jsm → src}/renderers/common/UniformsGroup.js +69 -31
- package/src/renderers/common/extras/PMREMGenerator.js +771 -0
- package/src/renderers/common/nodes/NodeBuilderState.js +58 -0
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +64 -0
- package/{examples/jsm → src}/renderers/common/nodes/NodeSampler.js +8 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeStorageBuffer.js +5 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniform.js +3 -3
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniformBuffer.js +2 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniformsGroup.js +2 -8
- package/{examples/jsm → src}/renderers/common/nodes/Nodes.js +106 -68
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +31 -1
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +0 -9
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -10
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +8 -22
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -0
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
- package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +3 -14
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +10 -31
- package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +3 -23
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +45 -13
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +38 -25
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +3 -0
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +19 -11
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +47 -13
- package/src/renderers/shaders/ShaderChunk.js +0 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +8 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/src/renderers/shaders/ShaderLib.js +2 -1
- package/src/renderers/shaders/UniformsLib.js +3 -0
- package/src/renderers/shaders/UniformsUtils.js +10 -1
- package/src/renderers/webgl/WebGLAttributes.js +42 -38
- package/src/renderers/webgl/WebGLBackground.js +24 -3
- package/src/renderers/webgl/WebGLBindingStates.js +14 -51
- package/src/renderers/webgl/WebGLBufferRenderer.js +23 -22
- package/src/renderers/webgl/WebGLCapabilities.js +44 -13
- package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
- package/src/renderers/webgl/WebGLExtensions.js +7 -20
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +23 -21
- package/src/renderers/webgl/WebGLLights.js +21 -44
- package/src/renderers/webgl/WebGLMaterials.js +9 -8
- package/src/renderers/webgl/WebGLMorphtargets.js +78 -217
- package/src/renderers/webgl/WebGLProgram.js +46 -78
- package/src/renderers/webgl/WebGLPrograms.js +37 -40
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLRenderStates.js +15 -9
- package/src/renderers/webgl/WebGLShadowMap.js +25 -25
- package/src/renderers/webgl/WebGLState.js +35 -58
- package/src/renderers/webgl/WebGLTextures.js +313 -358
- package/src/renderers/webgl/WebGLUniforms.js +12 -2
- package/src/renderers/webgl/WebGLUniformsGroups.js +8 -8
- package/src/renderers/webgl/WebGLUtils.js +9 -78
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBackend.js +389 -152
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +145 -0
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/nodes/GLSLNodeBuilder.js +245 -44
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLAttributeUtils.js +7 -1
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLConstants.js +2 -0
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLExtensions.js +2 -0
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLState.js +21 -3
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLTextureUtils.js +271 -43
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLUtils.js +6 -23
- package/{examples/jsm → src}/renderers/webgpu/WebGPUBackend.js +318 -141
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/{examples/jsm → src}/renderers/webgpu/WebGPURenderer.js +10 -7
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +105 -0
- package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeBuilder.js +424 -95
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +159 -0
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUAttributeUtils.js +37 -18
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUBindingUtils.js +86 -32
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUConstants.js +10 -1
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUPipelineUtils.js +68 -27
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTextureUtils.js +235 -68
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUUtils.js +43 -5
- package/src/renderers/webxr/WebXRDepthSensing.js +11 -6
- package/src/renderers/webxr/WebXRManager.js +53 -38
- package/src/scenes/Scene.js +7 -1
- package/src/textures/CompressedArrayTexture.js +14 -0
- package/src/textures/DataArrayTexture.js +14 -0
- package/src/textures/DepthTexture.js +1 -3
- package/src/textures/Texture.js +12 -2
- package/src/utils.js +62 -1
- package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/nodes/Nodes.js +0 -195
- package/examples/jsm/nodes/accessors/AccessorsUtils.js +0 -10
- package/examples/jsm/nodes/accessors/BitangentNode.js +0 -89
- package/examples/jsm/nodes/accessors/CameraNode.js +0 -119
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +0 -61
- package/examples/jsm/nodes/accessors/InstanceNode.js +0 -71
- package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +0 -21
- package/examples/jsm/nodes/accessors/MaterialNode.js +0 -314
- package/examples/jsm/nodes/accessors/ModelNode.js +0 -33
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +0 -39
- package/examples/jsm/nodes/accessors/NormalNode.js +0 -96
- package/examples/jsm/nodes/accessors/PointUVNode.js +0 -26
- package/examples/jsm/nodes/accessors/PositionNode.js +0 -104
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +0 -35
- package/examples/jsm/nodes/accessors/SkinningNode.js +0 -124
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +0 -72
- package/examples/jsm/nodes/accessors/TangentNode.js +0 -109
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +0 -35
- package/examples/jsm/nodes/accessors/UVNode.js +0 -47
- package/examples/jsm/nodes/core/CacheNode.js +0 -49
- package/examples/jsm/nodes/core/IndexNode.js +0 -66
- package/examples/jsm/nodes/core/NodeCache.js +0 -26
- package/examples/jsm/nodes/core/NodeKeywords.js +0 -80
- package/examples/jsm/nodes/core/PropertyNode.js +0 -72
- package/examples/jsm/nodes/core/UniformGroupNode.js +0 -36
- package/examples/jsm/nodes/core/VaryingNode.js +0 -65
- package/examples/jsm/nodes/display/BlendModeNode.js +0 -128
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +0 -99
- package/examples/jsm/nodes/display/ColorSpaceNode.js +0 -108
- package/examples/jsm/nodes/display/FrontFacingNode.js +0 -27
- package/examples/jsm/nodes/display/PassNode.js +0 -183
- package/examples/jsm/nodes/display/ToneMappingNode.js +0 -184
- package/examples/jsm/nodes/display/ViewportDepthNode.js +0 -97
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +0 -31
- package/examples/jsm/nodes/display/ViewportNode.js +0 -134
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +0 -31
- package/examples/jsm/nodes/fog/FogExp2Node.js +0 -35
- package/examples/jsm/nodes/fog/FogNode.js +0 -38
- package/examples/jsm/nodes/fog/FogRangeNode.js +0 -34
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +0 -40
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +0 -393
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +0 -13
- package/examples/jsm/nodes/lighting/AONode.js +0 -27
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +0 -241
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +0 -181
- package/examples/jsm/nodes/lighting/LightNode.js +0 -57
- package/examples/jsm/nodes/lighting/LightingContextNode.js +0 -66
- package/examples/jsm/nodes/lighting/LightsNode.js +0 -188
- package/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +0 -162
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +0 -28
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -28
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +0 -34
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -40
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -65
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +0 -155
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +0 -80
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -90
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +0 -130
- package/examples/jsm/nodes/math/HashNode.js +0 -34
- package/examples/jsm/nodes/math/MathNode.js +0 -391
- package/examples/jsm/nodes/math/OperatorNode.js +0 -274
- package/examples/jsm/nodes/procedural/CheckerNode.js +0 -42
- package/examples/jsm/nodes/utils/DiscardNode.js +0 -27
- package/examples/jsm/nodes/utils/EquirectUVNode.js +0 -33
- package/examples/jsm/nodes/utils/MatcapUVNode.js +0 -30
- package/examples/jsm/nodes/utils/PackingNode.js +0 -55
- package/examples/jsm/nodes/utils/RotateUVNode.js +0 -35
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
- package/examples/jsm/objects/QuadMesh.js +0 -66
- package/examples/jsm/renderers/common/Bindings.js +0 -173
- package/examples/jsm/renderers/common/ChainMap.js +0 -89
- package/examples/jsm/renderers/common/PostProcessing.js +0 -25
- package/examples/jsm/renderers/common/RenderObject.js +0 -221
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +0 -44
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +0 -49
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +0 -104
- package/examples/jsm/utils/GPUStatsPanel.js +0 -128
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/src/renderers/WebGL1Renderer.js +0 -7
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +0 -10
- /package/{examples/jsm → src}/nodes/core/NodeAttribute.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeCode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeFunctionInput.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeParser.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeVar.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeVarying.js +0 -0
- /package/{examples/jsm → src}/nodes/core/UniformGroup.js +0 -0
- /package/{examples/jsm → src}/nodes/core/constants.js +0 -0
- /package/{examples/jsm → src}/nodes/materialx/DISCLAIMER.md +0 -0
- /package/{examples/jsm → src}/nodes/parsers/GLSLNodeParser.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Binding.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Buffer.js +0 -0
- /package/{examples/jsm → src}/renderers/common/BufferUtils.js +0 -0
- /package/{examples/jsm → src}/renderers/common/ComputePipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Constants.js +0 -0
- /package/{examples/jsm → src}/renderers/common/DataMap.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Pipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/ProgrammableStage.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderLists.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderPipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Sampler.js +0 -0
- /package/{examples/jsm → src}/renderers/common/StorageBuffer.js +0 -0
- /package/{examples/jsm → src}/renderers/common/UniformBuffer.js +0 -0
- /package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLCapabilities.js +0 -0
- /package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeParser.js +0 -0
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat,
|
|
2
|
-
import * as MathUtils from '../../math/MathUtils.js';
|
|
3
|
-
import { ImageUtils } from '../../extras/ImageUtils.js';
|
|
1
|
+
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedIntType, FloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, UnsignedByteType, NoColorSpace, LinearSRGBColorSpace, NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, SRGBTransfer, LinearTransfer, UnsignedShortType, UnsignedInt248Type } from '../../constants.js';
|
|
4
2
|
import { createElementNS } from '../../utils.js';
|
|
5
3
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
6
4
|
import { Vector2 } from '../../math/Vector2.js';
|
|
5
|
+
import { getByteLength } from '../../extras/TextureUtils.js';
|
|
7
6
|
|
|
8
7
|
function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
|
|
9
8
|
|
|
10
|
-
const isWebGL2 = capabilities.isWebGL2;
|
|
11
9
|
const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
|
|
12
10
|
const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );
|
|
13
11
|
|
|
@@ -45,7 +43,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
45
43
|
|
|
46
44
|
}
|
|
47
45
|
|
|
48
|
-
function resizeImage( image,
|
|
46
|
+
function resizeImage( image, needsNewCanvas, maxSize ) {
|
|
49
47
|
|
|
50
48
|
let scale = 1;
|
|
51
49
|
|
|
@@ -61,7 +59,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
61
59
|
|
|
62
60
|
// only perform resize if necessary
|
|
63
61
|
|
|
64
|
-
if ( scale < 1
|
|
62
|
+
if ( scale < 1 ) {
|
|
65
63
|
|
|
66
64
|
// only perform resize for certain image types
|
|
67
65
|
|
|
@@ -70,10 +68,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
70
68
|
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ||
|
|
71
69
|
( typeof VideoFrame !== 'undefined' && image instanceof VideoFrame ) ) {
|
|
72
70
|
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
const width = floor( scale * dimensions.width );
|
|
76
|
-
const height = floor( scale * dimensions.height );
|
|
71
|
+
const width = Math.floor( scale * dimensions.width );
|
|
72
|
+
const height = Math.floor( scale * dimensions.height );
|
|
77
73
|
|
|
78
74
|
if ( _canvas === undefined ) _canvas = createCanvas( width, height );
|
|
79
75
|
|
|
@@ -109,27 +105,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
109
105
|
|
|
110
106
|
}
|
|
111
107
|
|
|
112
|
-
function
|
|
113
|
-
|
|
114
|
-
const dimensions = getDimensions( image );
|
|
108
|
+
function textureNeedsGenerateMipmaps( texture ) {
|
|
115
109
|
|
|
116
|
-
return
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function textureNeedsPowerOfTwo( texture ) {
|
|
121
|
-
|
|
122
|
-
if ( isWebGL2 ) return false;
|
|
123
|
-
|
|
124
|
-
return ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) ||
|
|
125
|
-
( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter );
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function textureNeedsGenerateMipmaps( texture, supportsMips ) {
|
|
130
|
-
|
|
131
|
-
return texture.generateMipmaps && supportsMips &&
|
|
132
|
-
texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
|
|
110
|
+
return texture.generateMipmaps && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
|
|
133
111
|
|
|
134
112
|
}
|
|
135
113
|
|
|
@@ -141,8 +119,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
141
119
|
|
|
142
120
|
function getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) {
|
|
143
121
|
|
|
144
|
-
if ( isWebGL2 === false ) return glFormat;
|
|
145
|
-
|
|
146
122
|
if ( internalFormatName !== null ) {
|
|
147
123
|
|
|
148
124
|
if ( _gl[ internalFormatName ] !== undefined ) return _gl[ internalFormatName ];
|
|
@@ -191,6 +167,34 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
191
167
|
|
|
192
168
|
}
|
|
193
169
|
|
|
170
|
+
if ( glFormat === _gl.RGB_INTEGER ) {
|
|
171
|
+
|
|
172
|
+
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGB8UI;
|
|
173
|
+
if ( glType === _gl.UNSIGNED_SHORT ) internalFormat = _gl.RGB16UI;
|
|
174
|
+
if ( glType === _gl.UNSIGNED_INT ) internalFormat = _gl.RGB32UI;
|
|
175
|
+
if ( glType === _gl.BYTE ) internalFormat = _gl.RGB8I;
|
|
176
|
+
if ( glType === _gl.SHORT ) internalFormat = _gl.RGB16I;
|
|
177
|
+
if ( glType === _gl.INT ) internalFormat = _gl.RGB32I;
|
|
178
|
+
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if ( glFormat === _gl.RGBA_INTEGER ) {
|
|
182
|
+
|
|
183
|
+
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGBA8UI;
|
|
184
|
+
if ( glType === _gl.UNSIGNED_SHORT ) internalFormat = _gl.RGBA16UI;
|
|
185
|
+
if ( glType === _gl.UNSIGNED_INT ) internalFormat = _gl.RGBA32UI;
|
|
186
|
+
if ( glType === _gl.BYTE ) internalFormat = _gl.RGBA8I;
|
|
187
|
+
if ( glType === _gl.SHORT ) internalFormat = _gl.RGBA16I;
|
|
188
|
+
if ( glType === _gl.INT ) internalFormat = _gl.RGBA32I;
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if ( glFormat === _gl.RGB ) {
|
|
193
|
+
|
|
194
|
+
if ( glType === _gl.UNSIGNED_INT_5_9_9_9_REV ) internalFormat = _gl.RGB9_E5;
|
|
195
|
+
|
|
196
|
+
}
|
|
197
|
+
|
|
194
198
|
if ( glFormat === _gl.RGBA ) {
|
|
195
199
|
|
|
196
200
|
const transfer = forceLinearTransfer ? LinearTransfer : ColorManagement.getTransfer( colorSpace );
|
|
@@ -215,43 +219,71 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
215
219
|
|
|
216
220
|
}
|
|
217
221
|
|
|
218
|
-
function
|
|
222
|
+
function getInternalDepthFormat( useStencil, depthType ) {
|
|
219
223
|
|
|
220
|
-
|
|
224
|
+
let glInternalFormat;
|
|
225
|
+
if ( useStencil ) {
|
|
221
226
|
|
|
222
|
-
|
|
227
|
+
if ( depthType === null || depthType === UnsignedIntType || depthType === UnsignedInt248Type ) {
|
|
223
228
|
|
|
224
|
-
|
|
229
|
+
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
225
230
|
|
|
226
|
-
|
|
231
|
+
} else if ( depthType === FloatType ) {
|
|
227
232
|
|
|
228
|
-
|
|
233
|
+
glInternalFormat = _gl.DEPTH32F_STENCIL8;
|
|
229
234
|
|
|
230
|
-
|
|
235
|
+
} else if ( depthType === UnsignedShortType ) {
|
|
231
236
|
|
|
232
|
-
|
|
237
|
+
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
238
|
+
console.warn( 'DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.' );
|
|
239
|
+
|
|
240
|
+
}
|
|
233
241
|
|
|
234
242
|
} else {
|
|
235
243
|
|
|
236
|
-
|
|
244
|
+
if ( depthType === null || depthType === UnsignedIntType || depthType === UnsignedInt248Type ) {
|
|
237
245
|
|
|
238
|
-
|
|
246
|
+
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
247
|
+
|
|
248
|
+
} else if ( depthType === FloatType ) {
|
|
249
|
+
|
|
250
|
+
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
251
|
+
|
|
252
|
+
} else if ( depthType === UnsignedShortType ) {
|
|
253
|
+
|
|
254
|
+
glInternalFormat = _gl.DEPTH_COMPONENT16;
|
|
255
|
+
|
|
256
|
+
}
|
|
239
257
|
|
|
240
258
|
}
|
|
241
259
|
|
|
260
|
+
return glInternalFormat;
|
|
261
|
+
|
|
242
262
|
}
|
|
243
263
|
|
|
244
|
-
|
|
264
|
+
function getMipLevels( texture, image ) {
|
|
245
265
|
|
|
246
|
-
|
|
266
|
+
if ( textureNeedsGenerateMipmaps( texture ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) {
|
|
247
267
|
|
|
248
|
-
|
|
268
|
+
return Math.log2( Math.max( image.width, image.height ) ) + 1;
|
|
249
269
|
|
|
250
|
-
|
|
270
|
+
} else if ( texture.mipmaps !== undefined && texture.mipmaps.length > 0 ) {
|
|
251
271
|
|
|
252
|
-
|
|
272
|
+
// user-defined mipmaps
|
|
273
|
+
|
|
274
|
+
return texture.mipmaps.length;
|
|
275
|
+
|
|
276
|
+
} else if ( texture.isCompressedTexture && Array.isArray( texture.image ) ) {
|
|
277
|
+
|
|
278
|
+
return image.mipmaps.length;
|
|
253
279
|
|
|
254
|
-
|
|
280
|
+
} else {
|
|
281
|
+
|
|
282
|
+
// texture without mipmaps (only base level)
|
|
283
|
+
|
|
284
|
+
return 1;
|
|
285
|
+
|
|
286
|
+
}
|
|
255
287
|
|
|
256
288
|
}
|
|
257
289
|
|
|
@@ -569,7 +601,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
569
601
|
[ NotEqualCompare ]: _gl.NOTEQUAL
|
|
570
602
|
};
|
|
571
603
|
|
|
572
|
-
function setTextureParameters( textureType, texture
|
|
604
|
+
function setTextureParameters( textureType, texture ) {
|
|
573
605
|
|
|
574
606
|
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false &&
|
|
575
607
|
( texture.magFilter === LinearFilter || texture.magFilter === LinearMipmapNearestFilter || texture.magFilter === NearestMipmapLinearFilter || texture.magFilter === LinearMipmapLinearFilter ||
|
|
@@ -579,48 +611,18 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
579
611
|
|
|
580
612
|
}
|
|
581
613
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
|
|
585
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
|
|
586
|
-
|
|
587
|
-
if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
|
|
588
|
-
|
|
589
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );
|
|
590
|
-
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );
|
|
594
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );
|
|
595
|
-
|
|
596
|
-
} else {
|
|
597
|
-
|
|
598
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE );
|
|
599
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE );
|
|
614
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
|
|
615
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
|
|
600
616
|
|
|
601
|
-
|
|
617
|
+
if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
|
|
602
618
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
if ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) {
|
|
608
|
-
|
|
609
|
-
console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.' );
|
|
610
|
-
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterFallback( texture.magFilter ) );
|
|
614
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterFallback( texture.minFilter ) );
|
|
615
|
-
|
|
616
|
-
if ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) {
|
|
617
|
-
|
|
618
|
-
console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.' );
|
|
619
|
-
|
|
620
|
-
}
|
|
619
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );
|
|
621
620
|
|
|
622
621
|
}
|
|
623
622
|
|
|
623
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );
|
|
624
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );
|
|
625
|
+
|
|
624
626
|
if ( texture.compareFunction ) {
|
|
625
627
|
|
|
626
628
|
_gl.texParameteri( textureType, _gl.TEXTURE_COMPARE_MODE, _gl.COMPARE_REF_TO_TEXTURE );
|
|
@@ -632,8 +634,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
632
634
|
|
|
633
635
|
if ( texture.magFilter === NearestFilter ) return;
|
|
634
636
|
if ( texture.minFilter !== NearestMipmapLinearFilter && texture.minFilter !== LinearMipmapLinearFilter ) return;
|
|
635
|
-
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension
|
|
636
|
-
if ( isWebGL2 === false && ( texture.type === HalfFloatType && extensions.has( 'OES_texture_half_float_linear' ) === false ) ) return; // verify extension for WebGL 1 only
|
|
637
|
+
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension
|
|
637
638
|
|
|
638
639
|
if ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {
|
|
639
640
|
|
|
@@ -754,99 +755,27 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
754
755
|
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
|
|
755
756
|
_gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
|
|
756
757
|
|
|
757
|
-
|
|
758
|
-
let image = resizeImage( texture.image, needsPowerOfTwo, false, capabilities.maxTextureSize );
|
|
758
|
+
let image = resizeImage( texture.image, false, capabilities.maxTextureSize );
|
|
759
759
|
image = verifyColorSpace( texture, image );
|
|
760
760
|
|
|
761
|
-
const
|
|
762
|
-
glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
761
|
+
const glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
763
762
|
|
|
764
|
-
|
|
765
|
-
|
|
763
|
+
const glType = utils.convert( texture.type );
|
|
764
|
+
let glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture );
|
|
766
765
|
|
|
767
|
-
setTextureParameters( textureType, texture
|
|
766
|
+
setTextureParameters( textureType, texture );
|
|
768
767
|
|
|
769
768
|
let mipmap;
|
|
770
769
|
const mipmaps = texture.mipmaps;
|
|
771
770
|
|
|
772
|
-
const useTexStorage = (
|
|
771
|
+
const useTexStorage = ( texture.isVideoTexture !== true );
|
|
773
772
|
const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
|
|
774
773
|
const dataReady = source.dataReady;
|
|
775
|
-
const levels = getMipLevels( texture, image
|
|
774
|
+
const levels = getMipLevels( texture, image );
|
|
776
775
|
|
|
777
776
|
if ( texture.isDepthTexture ) {
|
|
778
777
|
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
glInternalFormat = _gl.DEPTH_COMPONENT;
|
|
782
|
-
|
|
783
|
-
if ( isWebGL2 ) {
|
|
784
|
-
|
|
785
|
-
if ( texture.type === FloatType ) {
|
|
786
|
-
|
|
787
|
-
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
788
|
-
|
|
789
|
-
} else if ( texture.type === UnsignedIntType ) {
|
|
790
|
-
|
|
791
|
-
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
792
|
-
|
|
793
|
-
} else if ( texture.type === UnsignedInt248Type ) {
|
|
794
|
-
|
|
795
|
-
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
796
|
-
|
|
797
|
-
} else {
|
|
798
|
-
|
|
799
|
-
glInternalFormat = _gl.DEPTH_COMPONENT16; // WebGL2 requires sized internalformat for glTexImage2D
|
|
800
|
-
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
} else {
|
|
804
|
-
|
|
805
|
-
if ( texture.type === FloatType ) {
|
|
806
|
-
|
|
807
|
-
console.error( 'WebGLRenderer: Floating point depth texture requires WebGL2.' );
|
|
808
|
-
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
// validation checks for WebGL 1
|
|
814
|
-
|
|
815
|
-
if ( texture.format === DepthFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {
|
|
816
|
-
|
|
817
|
-
// The error INVALID_OPERATION is generated by texImage2D if format and internalformat are
|
|
818
|
-
// DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT
|
|
819
|
-
// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
|
|
820
|
-
if ( texture.type !== UnsignedShortType && texture.type !== UnsignedIntType ) {
|
|
821
|
-
|
|
822
|
-
console.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' );
|
|
823
|
-
|
|
824
|
-
texture.type = UnsignedIntType;
|
|
825
|
-
glType = utils.convert( texture.type );
|
|
826
|
-
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
if ( texture.format === DepthStencilFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {
|
|
832
|
-
|
|
833
|
-
// Depth stencil textures need the DEPTH_STENCIL internal format
|
|
834
|
-
// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
|
|
835
|
-
glInternalFormat = _gl.DEPTH_STENCIL;
|
|
836
|
-
|
|
837
|
-
// The error INVALID_OPERATION is generated by texImage2D if format and internalformat are
|
|
838
|
-
// DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL.
|
|
839
|
-
// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
|
|
840
|
-
if ( texture.type !== UnsignedInt248Type ) {
|
|
841
|
-
|
|
842
|
-
console.warn( 'THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.' );
|
|
843
|
-
|
|
844
|
-
texture.type = UnsignedInt248Type;
|
|
845
|
-
glType = utils.convert( texture.type );
|
|
846
|
-
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
}
|
|
778
|
+
glInternalFormat = getInternalDepthFormat( texture.format === DepthStencilFormat, texture.type );
|
|
850
779
|
|
|
851
780
|
//
|
|
852
781
|
|
|
@@ -870,7 +799,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
870
799
|
// if there are no manual mipmaps
|
|
871
800
|
// set 0 level mipmap and then use GL to generate other mipmap levels
|
|
872
801
|
|
|
873
|
-
if ( mipmaps.length > 0
|
|
802
|
+
if ( mipmaps.length > 0 ) {
|
|
874
803
|
|
|
875
804
|
if ( useTexStorage && allocateMemory ) {
|
|
876
805
|
|
|
@@ -946,7 +875,27 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
946
875
|
|
|
947
876
|
if ( dataReady ) {
|
|
948
877
|
|
|
949
|
-
|
|
878
|
+
if ( texture.layerUpdates.size > 0 ) {
|
|
879
|
+
|
|
880
|
+
const layerByteLength = getByteLength( mipmap.width, mipmap.height, texture.format, texture.type );
|
|
881
|
+
|
|
882
|
+
for ( const layerIndex of texture.layerUpdates ) {
|
|
883
|
+
|
|
884
|
+
const layerData = mipmap.data.subarray(
|
|
885
|
+
layerIndex * layerByteLength / mipmap.data.BYTES_PER_ELEMENT,
|
|
886
|
+
( layerIndex + 1 ) * layerByteLength / mipmap.data.BYTES_PER_ELEMENT
|
|
887
|
+
);
|
|
888
|
+
state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, layerIndex, mipmap.width, mipmap.height, 1, glFormat, layerData, 0, 0 );
|
|
889
|
+
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
texture.clearLayerUpdates();
|
|
893
|
+
|
|
894
|
+
} else {
|
|
895
|
+
|
|
896
|
+
state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data, 0, 0 );
|
|
897
|
+
|
|
898
|
+
}
|
|
950
899
|
|
|
951
900
|
}
|
|
952
901
|
|
|
@@ -1052,7 +1001,27 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1052
1001
|
|
|
1053
1002
|
if ( dataReady ) {
|
|
1054
1003
|
|
|
1055
|
-
|
|
1004
|
+
if ( texture.layerUpdates.size > 0 ) {
|
|
1005
|
+
|
|
1006
|
+
const layerByteLength = getByteLength( image.width, image.height, texture.format, texture.type );
|
|
1007
|
+
|
|
1008
|
+
for ( const layerIndex of texture.layerUpdates ) {
|
|
1009
|
+
|
|
1010
|
+
const layerData = image.data.subarray(
|
|
1011
|
+
layerIndex * layerByteLength / image.data.BYTES_PER_ELEMENT,
|
|
1012
|
+
( layerIndex + 1 ) * layerByteLength / image.data.BYTES_PER_ELEMENT
|
|
1013
|
+
);
|
|
1014
|
+
state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, layerIndex, image.width, image.height, 1, glFormat, glType, layerData );
|
|
1015
|
+
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
texture.clearLayerUpdates();
|
|
1019
|
+
|
|
1020
|
+
} else {
|
|
1021
|
+
|
|
1022
|
+
state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
|
|
1023
|
+
|
|
1024
|
+
}
|
|
1056
1025
|
|
|
1057
1026
|
}
|
|
1058
1027
|
|
|
@@ -1117,7 +1086,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1117
1086
|
// if there are no manual mipmaps
|
|
1118
1087
|
// set 0 level mipmap and then use GL to generate other mipmap levels
|
|
1119
1088
|
|
|
1120
|
-
if ( mipmaps.length > 0
|
|
1089
|
+
if ( mipmaps.length > 0 ) {
|
|
1121
1090
|
|
|
1122
1091
|
if ( useTexStorage && allocateMemory ) {
|
|
1123
1092
|
|
|
@@ -1177,7 +1146,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1177
1146
|
|
|
1178
1147
|
}
|
|
1179
1148
|
|
|
1180
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
1149
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
1181
1150
|
|
|
1182
1151
|
generateMipmap( textureType );
|
|
1183
1152
|
|
|
@@ -1226,7 +1195,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1226
1195
|
|
|
1227
1196
|
if ( ! isCompressed && ! isDataTexture ) {
|
|
1228
1197
|
|
|
1229
|
-
cubeImage[ i ] = resizeImage( texture.image[ i ],
|
|
1198
|
+
cubeImage[ i ] = resizeImage( texture.image[ i ], true, capabilities.maxCubemapSize );
|
|
1230
1199
|
|
|
1231
1200
|
} else {
|
|
1232
1201
|
|
|
@@ -1239,17 +1208,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1239
1208
|
}
|
|
1240
1209
|
|
|
1241
1210
|
const image = cubeImage[ 0 ],
|
|
1242
|
-
supportsMips = isPowerOfTwo( image ) || isWebGL2,
|
|
1243
1211
|
glFormat = utils.convert( texture.format, texture.colorSpace ),
|
|
1244
1212
|
glType = utils.convert( texture.type ),
|
|
1245
1213
|
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
|
|
1246
1214
|
|
|
1247
|
-
const useTexStorage = (
|
|
1215
|
+
const useTexStorage = ( texture.isVideoTexture !== true );
|
|
1248
1216
|
const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
|
|
1249
1217
|
const dataReady = source.dataReady;
|
|
1250
|
-
let levels = getMipLevels( texture, image
|
|
1218
|
+
let levels = getMipLevels( texture, image );
|
|
1251
1219
|
|
|
1252
|
-
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture
|
|
1220
|
+
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture );
|
|
1253
1221
|
|
|
1254
1222
|
let mipmaps;
|
|
1255
1223
|
|
|
@@ -1414,7 +1382,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1414
1382
|
|
|
1415
1383
|
}
|
|
1416
1384
|
|
|
1417
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
1385
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
1418
1386
|
|
|
1419
1387
|
// We assume images for cube map have the same size.
|
|
1420
1388
|
generateMipmap( _gl.TEXTURE_CUBE_MAP );
|
|
@@ -1474,74 +1442,37 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1474
1442
|
|
|
1475
1443
|
}
|
|
1476
1444
|
|
|
1477
|
-
|
|
1478
1445
|
// Setup storage for internal depth/stencil buffers and bind to correct framebuffer
|
|
1479
1446
|
function setupRenderBufferStorage( renderbuffer, renderTarget, isMultisample ) {
|
|
1480
1447
|
|
|
1481
1448
|
_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );
|
|
1482
1449
|
|
|
1483
|
-
if ( renderTarget.depthBuffer
|
|
1484
|
-
|
|
1485
|
-
let glInternalFormat = ( isWebGL2 === true ) ? _gl.DEPTH_COMPONENT24 : _gl.DEPTH_COMPONENT16;
|
|
1486
|
-
|
|
1487
|
-
if ( isMultisample || useMultisampledRTT( renderTarget ) ) {
|
|
1488
|
-
|
|
1489
|
-
const depthTexture = renderTarget.depthTexture;
|
|
1490
|
-
|
|
1491
|
-
if ( depthTexture && depthTexture.isDepthTexture ) {
|
|
1492
|
-
|
|
1493
|
-
if ( depthTexture.type === FloatType ) {
|
|
1494
|
-
|
|
1495
|
-
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
1496
|
-
|
|
1497
|
-
} else if ( depthTexture.type === UnsignedIntType ) {
|
|
1498
|
-
|
|
1499
|
-
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
1500
|
-
|
|
1501
|
-
}
|
|
1502
|
-
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
const samples = getRenderTargetSamples( renderTarget );
|
|
1506
|
-
|
|
1507
|
-
if ( useMultisampledRTT( renderTarget ) ) {
|
|
1508
|
-
|
|
1509
|
-
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1510
|
-
|
|
1511
|
-
} else {
|
|
1512
|
-
|
|
1513
|
-
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1514
|
-
|
|
1515
|
-
}
|
|
1516
|
-
|
|
1517
|
-
} else {
|
|
1518
|
-
|
|
1519
|
-
_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1520
|
-
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );
|
|
1450
|
+
if ( renderTarget.depthBuffer ) {
|
|
1524
1451
|
|
|
1525
|
-
|
|
1452
|
+
// retrieve the depth attachment types
|
|
1453
|
+
const depthTexture = renderTarget.depthTexture;
|
|
1454
|
+
const depthType = depthTexture && depthTexture.isDepthTexture ? depthTexture.type : null;
|
|
1455
|
+
const glInternalFormat = getInternalDepthFormat( renderTarget.stencilBuffer, depthType );
|
|
1456
|
+
const glAttachmentType = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
1526
1457
|
|
|
1458
|
+
// set up the attachment
|
|
1527
1459
|
const samples = getRenderTargetSamples( renderTarget );
|
|
1460
|
+
const isUseMultisampledRTT = useMultisampledRTT( renderTarget );
|
|
1461
|
+
if ( isUseMultisampledRTT ) {
|
|
1528
1462
|
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height );
|
|
1463
|
+
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1532
1464
|
|
|
1533
|
-
} else if (
|
|
1465
|
+
} else if ( isMultisample ) {
|
|
1534
1466
|
|
|
1535
|
-
|
|
1467
|
+
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1536
1468
|
|
|
1537
1469
|
} else {
|
|
1538
1470
|
|
|
1539
|
-
_gl.renderbufferStorage( _gl.RENDERBUFFER,
|
|
1471
|
+
_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1540
1472
|
|
|
1541
1473
|
}
|
|
1542
1474
|
|
|
1543
|
-
|
|
1544
|
-
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );
|
|
1475
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, glAttachmentType, _gl.RENDERBUFFER, renderbuffer );
|
|
1545
1476
|
|
|
1546
1477
|
} else {
|
|
1547
1478
|
|
|
@@ -1646,6 +1577,37 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1646
1577
|
const renderTargetProperties = properties.get( renderTarget );
|
|
1647
1578
|
const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
|
|
1648
1579
|
|
|
1580
|
+
// if the bound depth texture has changed
|
|
1581
|
+
if ( renderTargetProperties.__boundDepthTexture !== renderTarget.depthTexture ) {
|
|
1582
|
+
|
|
1583
|
+
// fire the dispose event to get rid of stored state associated with the previously bound depth buffer
|
|
1584
|
+
const depthTexture = renderTarget.depthTexture;
|
|
1585
|
+
if ( renderTargetProperties.__depthDisposeCallback ) {
|
|
1586
|
+
|
|
1587
|
+
renderTargetProperties.__depthDisposeCallback();
|
|
1588
|
+
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
// set up dispose listeners to track when the currently attached buffer is implicitly unbound
|
|
1592
|
+
if ( depthTexture ) {
|
|
1593
|
+
|
|
1594
|
+
const disposeEvent = () => {
|
|
1595
|
+
|
|
1596
|
+
delete renderTargetProperties.__boundDepthTexture;
|
|
1597
|
+
delete renderTargetProperties.__depthDisposeCallback;
|
|
1598
|
+
depthTexture.removeEventListener( 'dispose', disposeEvent );
|
|
1599
|
+
|
|
1600
|
+
};
|
|
1601
|
+
|
|
1602
|
+
depthTexture.addEventListener( 'dispose', disposeEvent );
|
|
1603
|
+
renderTargetProperties.__depthDisposeCallback = disposeEvent;
|
|
1604
|
+
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
renderTargetProperties.__boundDepthTexture = depthTexture;
|
|
1608
|
+
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1649
1611
|
if ( renderTarget.depthTexture && ! renderTargetProperties.__autoAllocateDepthBuffer ) {
|
|
1650
1612
|
|
|
1651
1613
|
if ( isCube ) throw new Error( 'target.depthTexture not supported in Cube render targets' );
|
|
@@ -1661,16 +1623,42 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1661
1623
|
for ( let i = 0; i < 6; i ++ ) {
|
|
1662
1624
|
|
|
1663
1625
|
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer[ i ] );
|
|
1664
|
-
|
|
1665
|
-
|
|
1626
|
+
|
|
1627
|
+
if ( renderTargetProperties.__webglDepthbuffer[ i ] === undefined ) {
|
|
1628
|
+
|
|
1629
|
+
renderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer();
|
|
1630
|
+
setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget, false );
|
|
1631
|
+
|
|
1632
|
+
} else {
|
|
1633
|
+
|
|
1634
|
+
// attach buffer if it's been created already
|
|
1635
|
+
const glAttachmentType = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
1636
|
+
const renderbuffer = renderTargetProperties.__webglDepthbuffer[ i ];
|
|
1637
|
+
_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );
|
|
1638
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, glAttachmentType, _gl.RENDERBUFFER, renderbuffer );
|
|
1639
|
+
|
|
1640
|
+
}
|
|
1666
1641
|
|
|
1667
1642
|
}
|
|
1668
1643
|
|
|
1669
1644
|
} else {
|
|
1670
1645
|
|
|
1671
1646
|
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
1672
|
-
|
|
1673
|
-
|
|
1647
|
+
|
|
1648
|
+
if ( renderTargetProperties.__webglDepthbuffer === undefined ) {
|
|
1649
|
+
|
|
1650
|
+
renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer();
|
|
1651
|
+
setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget, false );
|
|
1652
|
+
|
|
1653
|
+
} else {
|
|
1654
|
+
|
|
1655
|
+
// attach buffer if it's been created already
|
|
1656
|
+
const glAttachmentType = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
1657
|
+
const renderbuffer = renderTargetProperties.__webglDepthbuffer;
|
|
1658
|
+
_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );
|
|
1659
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, glAttachmentType, _gl.RENDERBUFFER, renderbuffer );
|
|
1660
|
+
|
|
1661
|
+
}
|
|
1674
1662
|
|
|
1675
1663
|
}
|
|
1676
1664
|
|
|
@@ -1713,7 +1701,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1713
1701
|
|
|
1714
1702
|
const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
|
|
1715
1703
|
const isMultipleRenderTargets = ( textures.length > 1 );
|
|
1716
|
-
const supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;
|
|
1717
1704
|
|
|
1718
1705
|
if ( ! isMultipleRenderTargets ) {
|
|
1719
1706
|
|
|
@@ -1736,7 +1723,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1736
1723
|
|
|
1737
1724
|
for ( let i = 0; i < 6; i ++ ) {
|
|
1738
1725
|
|
|
1739
|
-
if (
|
|
1726
|
+
if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
1740
1727
|
|
|
1741
1728
|
renderTargetProperties.__webglFramebuffer[ i ] = [];
|
|
1742
1729
|
|
|
@@ -1756,7 +1743,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1756
1743
|
|
|
1757
1744
|
} else {
|
|
1758
1745
|
|
|
1759
|
-
if (
|
|
1746
|
+
if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
1760
1747
|
|
|
1761
1748
|
renderTargetProperties.__webglFramebuffer = [];
|
|
1762
1749
|
|
|
@@ -1774,31 +1761,23 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1774
1761
|
|
|
1775
1762
|
if ( isMultipleRenderTargets ) {
|
|
1776
1763
|
|
|
1777
|
-
|
|
1764
|
+
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
1778
1765
|
|
|
1779
|
-
|
|
1766
|
+
const attachmentProperties = properties.get( textures[ i ] );
|
|
1780
1767
|
|
|
1781
|
-
|
|
1768
|
+
if ( attachmentProperties.__webglTexture === undefined ) {
|
|
1782
1769
|
|
|
1783
|
-
|
|
1770
|
+
attachmentProperties.__webglTexture = _gl.createTexture();
|
|
1784
1771
|
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
info.memory.textures ++;
|
|
1788
|
-
|
|
1789
|
-
}
|
|
1772
|
+
info.memory.textures ++;
|
|
1790
1773
|
|
|
1791
1774
|
}
|
|
1792
1775
|
|
|
1793
|
-
} else {
|
|
1794
|
-
|
|
1795
|
-
console.warn( 'THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.' );
|
|
1796
|
-
|
|
1797
1776
|
}
|
|
1798
1777
|
|
|
1799
1778
|
}
|
|
1800
1779
|
|
|
1801
|
-
if ( (
|
|
1780
|
+
if ( ( renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
|
|
1802
1781
|
|
|
1803
1782
|
renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();
|
|
1804
1783
|
renderTargetProperties.__webglColorRenderbuffer = [];
|
|
@@ -1842,11 +1821,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1842
1821
|
if ( isCube ) {
|
|
1843
1822
|
|
|
1844
1823
|
state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );
|
|
1845
|
-
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture
|
|
1824
|
+
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture );
|
|
1846
1825
|
|
|
1847
1826
|
for ( let i = 0; i < 6; i ++ ) {
|
|
1848
1827
|
|
|
1849
|
-
if (
|
|
1828
|
+
if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
1850
1829
|
|
|
1851
1830
|
for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
|
|
1852
1831
|
|
|
@@ -1862,7 +1841,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1862
1841
|
|
|
1863
1842
|
}
|
|
1864
1843
|
|
|
1865
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
1844
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
1866
1845
|
|
|
1867
1846
|
generateMipmap( _gl.TEXTURE_CUBE_MAP );
|
|
1868
1847
|
|
|
@@ -1878,10 +1857,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1878
1857
|
const attachmentProperties = properties.get( attachment );
|
|
1879
1858
|
|
|
1880
1859
|
state.bindTexture( _gl.TEXTURE_2D, attachmentProperties.__webglTexture );
|
|
1881
|
-
setTextureParameters( _gl.TEXTURE_2D, attachment
|
|
1860
|
+
setTextureParameters( _gl.TEXTURE_2D, attachment );
|
|
1882
1861
|
setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, 0 );
|
|
1883
1862
|
|
|
1884
|
-
if ( textureNeedsGenerateMipmaps( attachment
|
|
1863
|
+
if ( textureNeedsGenerateMipmaps( attachment ) ) {
|
|
1885
1864
|
|
|
1886
1865
|
generateMipmap( _gl.TEXTURE_2D );
|
|
1887
1866
|
|
|
@@ -1897,22 +1876,14 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1897
1876
|
|
|
1898
1877
|
if ( renderTarget.isWebGL3DRenderTarget || renderTarget.isWebGLArrayRenderTarget ) {
|
|
1899
1878
|
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
glTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;
|
|
1903
|
-
|
|
1904
|
-
} else {
|
|
1905
|
-
|
|
1906
|
-
console.error( 'THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.' );
|
|
1907
|
-
|
|
1908
|
-
}
|
|
1879
|
+
glTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;
|
|
1909
1880
|
|
|
1910
1881
|
}
|
|
1911
1882
|
|
|
1912
1883
|
state.bindTexture( glTextureType, textureProperties.__webglTexture );
|
|
1913
|
-
setTextureParameters( glTextureType, texture
|
|
1884
|
+
setTextureParameters( glTextureType, texture );
|
|
1914
1885
|
|
|
1915
|
-
if (
|
|
1886
|
+
if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
1916
1887
|
|
|
1917
1888
|
for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
|
|
1918
1889
|
|
|
@@ -1926,7 +1897,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1926
1897
|
|
|
1927
1898
|
}
|
|
1928
1899
|
|
|
1929
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
1900
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
1930
1901
|
|
|
1931
1902
|
generateMipmap( glTextureType );
|
|
1932
1903
|
|
|
@@ -1948,15 +1919,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1948
1919
|
|
|
1949
1920
|
function updateRenderTargetMipmap( renderTarget ) {
|
|
1950
1921
|
|
|
1951
|
-
const supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;
|
|
1952
|
-
|
|
1953
1922
|
const textures = renderTarget.textures;
|
|
1954
1923
|
|
|
1955
1924
|
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
1956
1925
|
|
|
1957
1926
|
const texture = textures[ i ];
|
|
1958
1927
|
|
|
1959
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
1928
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
1960
1929
|
|
|
1961
1930
|
const target = renderTarget.isWebGLCubeRenderTarget ? _gl.TEXTURE_CUBE_MAP : _gl.TEXTURE_2D;
|
|
1962
1931
|
const webglTexture = properties.get( texture ).__webglTexture;
|
|
@@ -1971,109 +1940,120 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1971
1940
|
|
|
1972
1941
|
}
|
|
1973
1942
|
|
|
1943
|
+
const invalidationArrayRead = [];
|
|
1944
|
+
const invalidationArrayDraw = [];
|
|
1945
|
+
|
|
1974
1946
|
function updateMultisampleRenderTarget( renderTarget ) {
|
|
1975
1947
|
|
|
1976
|
-
if (
|
|
1948
|
+
if ( renderTarget.samples > 0 ) {
|
|
1977
1949
|
|
|
1978
|
-
|
|
1979
|
-
const width = renderTarget.width;
|
|
1980
|
-
const height = renderTarget.height;
|
|
1981
|
-
let mask = _gl.COLOR_BUFFER_BIT;
|
|
1982
|
-
const invalidationArray = [];
|
|
1983
|
-
const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
1984
|
-
const renderTargetProperties = properties.get( renderTarget );
|
|
1985
|
-
const isMultipleRenderTargets = ( textures.length > 1 );
|
|
1986
|
-
|
|
1987
|
-
// If MRT we need to remove FBO attachments
|
|
1988
|
-
if ( isMultipleRenderTargets ) {
|
|
1950
|
+
if ( useMultisampledRTT( renderTarget ) === false ) {
|
|
1989
1951
|
|
|
1990
|
-
|
|
1952
|
+
const textures = renderTarget.textures;
|
|
1953
|
+
const width = renderTarget.width;
|
|
1954
|
+
const height = renderTarget.height;
|
|
1955
|
+
let mask = _gl.COLOR_BUFFER_BIT;
|
|
1956
|
+
const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
1957
|
+
const renderTargetProperties = properties.get( renderTarget );
|
|
1958
|
+
const isMultipleRenderTargets = ( textures.length > 1 );
|
|
1991
1959
|
|
|
1992
|
-
|
|
1993
|
-
|
|
1960
|
+
// If MRT we need to remove FBO attachments
|
|
1961
|
+
if ( isMultipleRenderTargets ) {
|
|
1962
|
+
|
|
1963
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
1964
|
+
|
|
1965
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
1966
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, null );
|
|
1994
1967
|
|
|
1995
|
-
|
|
1996
|
-
|
|
1968
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
1969
|
+
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, null, 0 );
|
|
1970
|
+
|
|
1971
|
+
}
|
|
1997
1972
|
|
|
1998
1973
|
}
|
|
1999
1974
|
|
|
2000
|
-
|
|
1975
|
+
state.bindFramebuffer( _gl.READ_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
1976
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
2001
1977
|
|
|
2002
|
-
|
|
2003
|
-
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
1978
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
2004
1979
|
|
|
2005
|
-
|
|
1980
|
+
if ( renderTarget.resolveDepthBuffer ) {
|
|
2006
1981
|
|
|
2007
|
-
|
|
1982
|
+
if ( renderTarget.depthBuffer ) mask |= _gl.DEPTH_BUFFER_BIT;
|
|
2008
1983
|
|
|
2009
|
-
|
|
1984
|
+
// resolving stencil is slow with a D3D backend. disable it for all transmission render targets (see #27799)
|
|
2010
1985
|
|
|
2011
|
-
|
|
1986
|
+
if ( renderTarget.stencilBuffer && renderTarget.resolveStencilBuffer ) mask |= _gl.STENCIL_BUFFER_BIT;
|
|
2012
1987
|
|
|
2013
|
-
|
|
1988
|
+
}
|
|
2014
1989
|
|
|
2015
|
-
|
|
1990
|
+
if ( isMultipleRenderTargets ) {
|
|
2016
1991
|
|
|
2017
|
-
|
|
1992
|
+
_gl.framebufferRenderbuffer( _gl.READ_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
|
|
2018
1993
|
|
|
2019
|
-
|
|
2020
|
-
|
|
1994
|
+
const webglTexture = properties.get( textures[ i ] ).__webglTexture;
|
|
1995
|
+
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, webglTexture, 0 );
|
|
2021
1996
|
|
|
2022
|
-
|
|
1997
|
+
}
|
|
2023
1998
|
|
|
2024
|
-
|
|
1999
|
+
_gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, _gl.NEAREST );
|
|
2025
2000
|
|
|
2026
|
-
|
|
2001
|
+
if ( supportsInvalidateFramebuffer === true ) {
|
|
2027
2002
|
|
|
2028
|
-
|
|
2003
|
+
invalidationArrayRead.length = 0;
|
|
2004
|
+
invalidationArrayDraw.length = 0;
|
|
2029
2005
|
|
|
2030
|
-
|
|
2006
|
+
invalidationArrayRead.push( _gl.COLOR_ATTACHMENT0 + i );
|
|
2031
2007
|
|
|
2032
|
-
|
|
2033
|
-
_gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, [ depthStyle ] );
|
|
2008
|
+
if ( renderTarget.depthBuffer && renderTarget.resolveDepthBuffer === false ) {
|
|
2034
2009
|
|
|
2035
|
-
|
|
2010
|
+
invalidationArrayRead.push( depthStyle );
|
|
2011
|
+
invalidationArrayDraw.push( depthStyle );
|
|
2036
2012
|
|
|
2037
|
-
|
|
2013
|
+
_gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, invalidationArrayDraw );
|
|
2014
|
+
|
|
2015
|
+
}
|
|
2038
2016
|
|
|
2039
|
-
|
|
2040
|
-
|
|
2017
|
+
_gl.invalidateFramebuffer( _gl.READ_FRAMEBUFFER, invalidationArrayRead );
|
|
2018
|
+
|
|
2019
|
+
}
|
|
2041
2020
|
|
|
2042
2021
|
}
|
|
2043
2022
|
|
|
2044
|
-
|
|
2023
|
+
state.bindFramebuffer( _gl.READ_FRAMEBUFFER, null );
|
|
2024
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
|
|
2045
2025
|
|
|
2046
|
-
|
|
2026
|
+
// If MRT since pre-blit we removed the FBO we need to reconstruct the attachments
|
|
2027
|
+
if ( isMultipleRenderTargets ) {
|
|
2047
2028
|
|
|
2048
|
-
|
|
2029
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
2049
2030
|
|
|
2050
|
-
|
|
2031
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
2032
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
|
|
2051
2033
|
|
|
2034
|
+
const webglTexture = properties.get( textures[ i ] ).__webglTexture;
|
|
2052
2035
|
|
|
2053
|
-
|
|
2036
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
2037
|
+
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, webglTexture, 0 );
|
|
2054
2038
|
|
|
2055
|
-
|
|
2056
|
-
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
|
|
2039
|
+
}
|
|
2057
2040
|
|
|
2058
|
-
|
|
2059
|
-
if ( isMultipleRenderTargets ) {
|
|
2041
|
+
}
|
|
2060
2042
|
|
|
2061
|
-
|
|
2043
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
2062
2044
|
|
|
2063
|
-
|
|
2064
|
-
|
|
2045
|
+
} else {
|
|
2046
|
+
|
|
2047
|
+
if ( renderTarget.depthBuffer && renderTarget.resolveDepthBuffer === false && supportsInvalidateFramebuffer ) {
|
|
2065
2048
|
|
|
2066
|
-
const
|
|
2049
|
+
const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
2067
2050
|
|
|
2068
|
-
|
|
2069
|
-
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, webglTexture, 0 );
|
|
2051
|
+
_gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, [ depthStyle ] );
|
|
2070
2052
|
|
|
2071
2053
|
}
|
|
2072
2054
|
|
|
2073
2055
|
}
|
|
2074
2056
|
|
|
2075
|
-
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
2076
|
-
|
|
2077
2057
|
}
|
|
2078
2058
|
|
|
2079
2059
|
}
|
|
@@ -2088,7 +2068,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2088
2068
|
|
|
2089
2069
|
const renderTargetProperties = properties.get( renderTarget );
|
|
2090
2070
|
|
|
2091
|
-
return
|
|
2071
|
+
return renderTarget.samples > 0 && extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true && renderTargetProperties.__useRenderToTexture !== false;
|
|
2092
2072
|
|
|
2093
2073
|
}
|
|
2094
2074
|
|
|
@@ -2113,7 +2093,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2113
2093
|
const format = texture.format;
|
|
2114
2094
|
const type = texture.type;
|
|
2115
2095
|
|
|
2116
|
-
if ( texture.isCompressedTexture === true || texture.isVideoTexture === true
|
|
2096
|
+
if ( texture.isCompressedTexture === true || texture.isVideoTexture === true ) return image;
|
|
2117
2097
|
|
|
2118
2098
|
if ( colorSpace !== LinearSRGBColorSpace && colorSpace !== NoColorSpace ) {
|
|
2119
2099
|
|
|
@@ -2121,36 +2101,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2121
2101
|
|
|
2122
2102
|
if ( ColorManagement.getTransfer( colorSpace ) === SRGBTransfer ) {
|
|
2123
2103
|
|
|
2124
|
-
if
|
|
2104
|
+
// in WebGL 2 uncompressed textures can only be sRGB encoded if they have the RGBA8 format
|
|
2125
2105
|
|
|
2126
|
-
|
|
2106
|
+
if ( format !== RGBAFormat || type !== UnsignedByteType ) {
|
|
2127
2107
|
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
texture.format = _SRGBAFormat;
|
|
2131
|
-
|
|
2132
|
-
// it's not possible to generate mips in WebGL 1 with this extension
|
|
2133
|
-
|
|
2134
|
-
texture.minFilter = LinearFilter;
|
|
2135
|
-
texture.generateMipmaps = false;
|
|
2136
|
-
|
|
2137
|
-
} else {
|
|
2138
|
-
|
|
2139
|
-
// slow fallback (CPU decode)
|
|
2140
|
-
|
|
2141
|
-
image = ImageUtils.sRGBToLinear( image );
|
|
2142
|
-
|
|
2143
|
-
}
|
|
2144
|
-
|
|
2145
|
-
} else {
|
|
2146
|
-
|
|
2147
|
-
// in WebGL 2 uncompressed textures can only be sRGB encoded if they have the RGBA8 format
|
|
2148
|
-
|
|
2149
|
-
if ( format !== RGBAFormat || type !== UnsignedByteType ) {
|
|
2150
|
-
|
|
2151
|
-
console.warn( 'THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.' );
|
|
2152
|
-
|
|
2153
|
-
}
|
|
2108
|
+
console.warn( 'THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.' );
|
|
2154
2109
|
|
|
2155
2110
|
}
|
|
2156
2111
|
|