@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
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor,
|
|
6
6
|
OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor,
|
|
7
7
|
NeverDepth, AlwaysDepth, LessDepth, LessEqualDepth, EqualDepth, GreaterEqualDepth, GreaterDepth, NotEqualDepth
|
|
8
|
-
} from '
|
|
8
|
+
} from '../../../constants.js';
|
|
9
9
|
|
|
10
10
|
let initialized = false, equationToGL, factorToGL;
|
|
11
11
|
|
|
@@ -48,6 +48,7 @@ class WebGLState {
|
|
|
48
48
|
this.maxTextures = this.gl.getParameter( this.gl.MAX_TEXTURE_IMAGE_UNITS );
|
|
49
49
|
this.currentTextureSlot = null;
|
|
50
50
|
this.currentBoundTextures = {};
|
|
51
|
+
this.currentBoundBufferBases = {};
|
|
51
52
|
|
|
52
53
|
if ( initialized === false ) {
|
|
53
54
|
|
|
@@ -511,7 +512,7 @@ class WebGLState {
|
|
|
511
512
|
|
|
512
513
|
this.setPolygonOffset( material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits );
|
|
513
514
|
|
|
514
|
-
material.alphaToCoverage === true
|
|
515
|
+
material.alphaToCoverage === true && this.backend.renderer.samples > 1
|
|
515
516
|
? this.enable( gl.SAMPLE_ALPHA_TO_COVERAGE )
|
|
516
517
|
: this.disable( gl.SAMPLE_ALPHA_TO_COVERAGE );
|
|
517
518
|
|
|
@@ -648,7 +649,6 @@ class WebGLState {
|
|
|
648
649
|
|
|
649
650
|
}
|
|
650
651
|
|
|
651
|
-
|
|
652
652
|
}
|
|
653
653
|
|
|
654
654
|
|
|
@@ -710,12 +710,30 @@ class WebGLState {
|
|
|
710
710
|
boundTexture.type = webglType;
|
|
711
711
|
boundTexture.texture = webglTexture;
|
|
712
712
|
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
bindBufferBase( target, index, buffer ) {
|
|
718
|
+
|
|
719
|
+
const { gl } = this;
|
|
720
|
+
|
|
721
|
+
const key = `${target}-${index}`;
|
|
722
|
+
|
|
723
|
+
if ( this.currentBoundBufferBases[ key ] !== buffer ) {
|
|
724
|
+
|
|
725
|
+
gl.bindBufferBase( target, index, buffer );
|
|
726
|
+
this.currentBoundBufferBases[ key ] = buffer;
|
|
727
|
+
|
|
728
|
+
return true;
|
|
713
729
|
|
|
714
730
|
}
|
|
715
731
|
|
|
732
|
+
return false;
|
|
716
733
|
|
|
717
734
|
}
|
|
718
735
|
|
|
736
|
+
|
|
719
737
|
unbindTexture() {
|
|
720
738
|
|
|
721
739
|
const { gl, currentTextureSlot, currentBoundTextures } = this;
|
package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLTextureUtils.js
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, FloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, SRGBColorSpace, NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare } from '
|
|
1
|
+
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, FloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, SRGBColorSpace, NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare } from '../../../constants.js';
|
|
2
2
|
|
|
3
3
|
let initialized = false, wrappingToGL, filterToGL, compareToGL;
|
|
4
4
|
|
|
@@ -79,10 +79,14 @@ class WebGLTextureUtils {
|
|
|
79
79
|
|
|
80
80
|
glTextureType = gl.TEXTURE_CUBE_MAP;
|
|
81
81
|
|
|
82
|
-
} else if ( texture.isDataArrayTexture === true ) {
|
|
82
|
+
} else if ( texture.isDataArrayTexture === true || texture.isCompressedArrayTexture === true ) {
|
|
83
83
|
|
|
84
84
|
glTextureType = gl.TEXTURE_2D_ARRAY;
|
|
85
85
|
|
|
86
|
+
} else if ( texture.isData3DTexture === true ) { // TODO: isCompressed3DTexture, wait for #26642
|
|
87
|
+
|
|
88
|
+
glTextureType = gl.TEXTURE_3D;
|
|
89
|
+
|
|
86
90
|
} else {
|
|
87
91
|
|
|
88
92
|
glTextureType = gl.TEXTURE_2D;
|
|
@@ -113,6 +117,11 @@ class WebGLTextureUtils {
|
|
|
113
117
|
if ( glType === gl.FLOAT ) internalFormat = gl.R32F;
|
|
114
118
|
if ( glType === gl.HALF_FLOAT ) internalFormat = gl.R16F;
|
|
115
119
|
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.R8;
|
|
120
|
+
if ( glType === gl.UNSIGNED_SHORT ) internalFormat = gl.R16;
|
|
121
|
+
if ( glType === gl.UNSIGNED_INT ) internalFormat = gl.R32UI;
|
|
122
|
+
if ( glType === gl.BYTE ) internalFormat = gl.R8I;
|
|
123
|
+
if ( glType === gl.SHORT ) internalFormat = gl.R16I;
|
|
124
|
+
if ( glType === gl.INT ) internalFormat = gl.R32I;
|
|
116
125
|
|
|
117
126
|
}
|
|
118
127
|
|
|
@@ -132,6 +141,22 @@ class WebGLTextureUtils {
|
|
|
132
141
|
if ( glType === gl.FLOAT ) internalFormat = gl.RG32F;
|
|
133
142
|
if ( glType === gl.HALF_FLOAT ) internalFormat = gl.RG16F;
|
|
134
143
|
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.RG8;
|
|
144
|
+
if ( glType === gl.UNSIGNED_SHORT ) internalFormat = gl.RG16;
|
|
145
|
+
if ( glType === gl.UNSIGNED_INT ) internalFormat = gl.RG32UI;
|
|
146
|
+
if ( glType === gl.BYTE ) internalFormat = gl.RG8I;
|
|
147
|
+
if ( glType === gl.SHORT ) internalFormat = gl.RG16I;
|
|
148
|
+
if ( glType === gl.INT ) internalFormat = gl.RG32I;
|
|
149
|
+
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if ( glFormat === gl.RG_INTEGER ) {
|
|
153
|
+
|
|
154
|
+
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.RG8UI;
|
|
155
|
+
if ( glType === gl.UNSIGNED_SHORT ) internalFormat = gl.RG16UI;
|
|
156
|
+
if ( glType === gl.UNSIGNED_INT ) internalFormat = gl.RG32UI;
|
|
157
|
+
if ( glType === gl.BYTE ) internalFormat = gl.RG8I;
|
|
158
|
+
if ( glType === gl.SHORT ) internalFormat = gl.RG16I;
|
|
159
|
+
if ( glType === gl.INT ) internalFormat = gl.RG32I;
|
|
135
160
|
|
|
136
161
|
}
|
|
137
162
|
|
|
@@ -140,9 +165,27 @@ class WebGLTextureUtils {
|
|
|
140
165
|
if ( glType === gl.FLOAT ) internalFormat = gl.RGB32F;
|
|
141
166
|
if ( glType === gl.HALF_FLOAT ) internalFormat = gl.RGB16F;
|
|
142
167
|
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.RGB8;
|
|
168
|
+
if ( glType === gl.UNSIGNED_SHORT ) internalFormat = gl.RGB16;
|
|
169
|
+
if ( glType === gl.UNSIGNED_INT ) internalFormat = gl.RGB32UI;
|
|
170
|
+
if ( glType === gl.BYTE ) internalFormat = gl.RGB8I;
|
|
171
|
+
if ( glType === gl.SHORT ) internalFormat = gl.RGB16I;
|
|
172
|
+
if ( glType === gl.INT ) internalFormat = gl.RGB32I;
|
|
173
|
+
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = ( colorSpace === SRGBColorSpace && forceLinearTransfer === false ) ? gl.SRGB8 : gl.RGB8;
|
|
143
174
|
if ( glType === gl.UNSIGNED_SHORT_5_6_5 ) internalFormat = gl.RGB565;
|
|
144
175
|
if ( glType === gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = gl.RGB5_A1;
|
|
145
176
|
if ( glType === gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = gl.RGB4;
|
|
177
|
+
if ( glType === gl.UNSIGNED_INT_5_9_9_9_REV ) internalFormat = gl.RGB9_E5;
|
|
178
|
+
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if ( glFormat === gl.RGB_INTEGER ) {
|
|
182
|
+
|
|
183
|
+
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.RGB8UI;
|
|
184
|
+
if ( glType === gl.UNSIGNED_SHORT ) internalFormat = gl.RGB16UI;
|
|
185
|
+
if ( glType === gl.UNSIGNED_INT ) internalFormat = gl.RGB32UI;
|
|
186
|
+
if ( glType === gl.BYTE ) internalFormat = gl.RGB8I;
|
|
187
|
+
if ( glType === gl.SHORT ) internalFormat = gl.RGB16I;
|
|
188
|
+
if ( glType === gl.INT ) internalFormat = gl.RGB32I;
|
|
146
189
|
|
|
147
190
|
}
|
|
148
191
|
|
|
@@ -150,12 +193,29 @@ class WebGLTextureUtils {
|
|
|
150
193
|
|
|
151
194
|
if ( glType === gl.FLOAT ) internalFormat = gl.RGBA32F;
|
|
152
195
|
if ( glType === gl.HALF_FLOAT ) internalFormat = gl.RGBA16F;
|
|
196
|
+
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.RGBA8;
|
|
197
|
+
if ( glType === gl.UNSIGNED_SHORT ) internalFormat = gl.RGBA16;
|
|
198
|
+
if ( glType === gl.UNSIGNED_INT ) internalFormat = gl.RGBA32UI;
|
|
199
|
+
if ( glType === gl.BYTE ) internalFormat = gl.RGBA8I;
|
|
200
|
+
if ( glType === gl.SHORT ) internalFormat = gl.RGBA16I;
|
|
201
|
+
if ( glType === gl.INT ) internalFormat = gl.RGBA32I;
|
|
153
202
|
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = ( colorSpace === SRGBColorSpace && forceLinearTransfer === false ) ? gl.SRGB8_ALPHA8 : gl.RGBA8;
|
|
154
203
|
if ( glType === gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = gl.RGBA4;
|
|
155
204
|
if ( glType === gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = gl.RGB5_A1;
|
|
156
205
|
|
|
157
206
|
}
|
|
158
207
|
|
|
208
|
+
if ( glFormat === gl.RGBA_INTEGER ) {
|
|
209
|
+
|
|
210
|
+
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.RGBA8UI;
|
|
211
|
+
if ( glType === gl.UNSIGNED_SHORT ) internalFormat = gl.RGBA16UI;
|
|
212
|
+
if ( glType === gl.UNSIGNED_INT ) internalFormat = gl.RGBA32UI;
|
|
213
|
+
if ( glType === gl.BYTE ) internalFormat = gl.RGBA8I;
|
|
214
|
+
if ( glType === gl.SHORT ) internalFormat = gl.RGBA16I;
|
|
215
|
+
if ( glType === gl.INT ) internalFormat = gl.RGBA32I;
|
|
216
|
+
|
|
217
|
+
}
|
|
218
|
+
|
|
159
219
|
if ( glFormat === gl.DEPTH_COMPONENT ) {
|
|
160
220
|
|
|
161
221
|
if ( glType === gl.UNSIGNED_INT ) internalFormat = gl.DEPTH24_STENCIL8;
|
|
@@ -185,7 +245,11 @@ class WebGLTextureUtils {
|
|
|
185
245
|
|
|
186
246
|
const { gl, extensions, backend } = this;
|
|
187
247
|
|
|
188
|
-
|
|
248
|
+
|
|
249
|
+
gl.pixelStorei( gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
|
|
250
|
+
gl.pixelStorei( gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
|
|
251
|
+
gl.pixelStorei( gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
|
|
252
|
+
gl.pixelStorei( gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE );
|
|
189
253
|
|
|
190
254
|
gl.texParameteri( textureType, gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
|
|
191
255
|
gl.texParameteri( textureType, gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
|
|
@@ -199,8 +263,10 @@ class WebGLTextureUtils {
|
|
|
199
263
|
gl.texParameteri( textureType, gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );
|
|
200
264
|
|
|
201
265
|
|
|
266
|
+
const hasMipmaps = texture.mipmaps !== undefined && texture.mipmaps.length > 0;
|
|
267
|
+
|
|
202
268
|
// follow WebGPU backend mapping for texture filtering
|
|
203
|
-
const minFilter =
|
|
269
|
+
const minFilter = texture.minFilter === LinearFilter && hasMipmaps ? LinearMipmapLinearFilter : texture.minFilter;
|
|
204
270
|
|
|
205
271
|
gl.texParameteri( textureType, gl.TEXTURE_MIN_FILTER, filterToGL[ minFilter ] );
|
|
206
272
|
|
|
@@ -217,11 +283,10 @@ class WebGLTextureUtils {
|
|
|
217
283
|
if ( texture.minFilter !== NearestMipmapLinearFilter && texture.minFilter !== LinearMipmapLinearFilter ) return;
|
|
218
284
|
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension for WebGL 1 and WebGL 2
|
|
219
285
|
|
|
220
|
-
if ( texture.anisotropy > 1
|
|
286
|
+
if ( texture.anisotropy > 1 ) {
|
|
221
287
|
|
|
222
288
|
const extension = extensions.get( 'EXT_texture_filter_anisotropic' );
|
|
223
289
|
gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, backend.getMaxAnisotropy() ) );
|
|
224
|
-
backend.get( texture ).currentAnisotropy = texture.anisotropy;
|
|
225
290
|
|
|
226
291
|
}
|
|
227
292
|
|
|
@@ -274,17 +339,16 @@ class WebGLTextureUtils {
|
|
|
274
339
|
|
|
275
340
|
backend.state.bindTexture( glTextureType, textureGPU );
|
|
276
341
|
|
|
277
|
-
gl.pixelStorei( gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
|
|
278
|
-
gl.pixelStorei( gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
|
|
279
|
-
gl.pixelStorei( gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
|
|
280
|
-
gl.pixelStorei( gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE );
|
|
281
|
-
|
|
282
342
|
this.setTextureParameters( glTextureType, texture );
|
|
283
343
|
|
|
284
|
-
if ( texture.isDataArrayTexture ) {
|
|
344
|
+
if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
|
|
285
345
|
|
|
286
346
|
gl.texStorage3D( gl.TEXTURE_2D_ARRAY, levels, glInternalFormat, width, height, depth );
|
|
287
347
|
|
|
348
|
+
} else if ( texture.isData3DTexture ) {
|
|
349
|
+
|
|
350
|
+
gl.texStorage3D( gl.TEXTURE_3D, levels, glInternalFormat, width, height, depth );
|
|
351
|
+
|
|
288
352
|
} else if ( ! texture.isVideoTexture ) {
|
|
289
353
|
|
|
290
354
|
gl.texStorage2D( glTextureType, levels, glInternalFormat, width, height );
|
|
@@ -363,9 +427,12 @@ class WebGLTextureUtils {
|
|
|
363
427
|
|
|
364
428
|
this.backend.state.bindTexture( glTextureType, textureGPU );
|
|
365
429
|
|
|
430
|
+
this.setTextureParameters( glTextureType, texture );
|
|
431
|
+
|
|
366
432
|
if ( texture.isCompressedTexture ) {
|
|
367
433
|
|
|
368
434
|
const mipmaps = texture.mipmaps;
|
|
435
|
+
const image = options.image;
|
|
369
436
|
|
|
370
437
|
for ( let i = 0; i < mipmaps.length; i ++ ) {
|
|
371
438
|
|
|
@@ -373,7 +440,6 @@ class WebGLTextureUtils {
|
|
|
373
440
|
|
|
374
441
|
if ( texture.isCompressedArrayTexture ) {
|
|
375
442
|
|
|
376
|
-
const image = options.image;
|
|
377
443
|
|
|
378
444
|
if ( texture.format !== gl.RGBA ) {
|
|
379
445
|
|
|
@@ -410,6 +476,7 @@ class WebGLTextureUtils {
|
|
|
410
476
|
|
|
411
477
|
}
|
|
412
478
|
|
|
479
|
+
|
|
413
480
|
} else if ( texture.isCubeTexture ) {
|
|
414
481
|
|
|
415
482
|
const images = options.images;
|
|
@@ -428,6 +495,12 @@ class WebGLTextureUtils {
|
|
|
428
495
|
|
|
429
496
|
gl.texSubImage3D( gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
|
|
430
497
|
|
|
498
|
+
} else if ( texture.isData3DTexture ) {
|
|
499
|
+
|
|
500
|
+
const image = options.image;
|
|
501
|
+
|
|
502
|
+
gl.texSubImage3D( gl.TEXTURE_3D, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
|
|
503
|
+
|
|
431
504
|
} else if ( texture.isVideoTexture ) {
|
|
432
505
|
|
|
433
506
|
texture.update();
|
|
@@ -457,7 +530,6 @@ class WebGLTextureUtils {
|
|
|
457
530
|
|
|
458
531
|
deallocateRenderBuffers( renderTarget ) {
|
|
459
532
|
|
|
460
|
-
|
|
461
533
|
const { gl, backend } = this;
|
|
462
534
|
|
|
463
535
|
// remove framebuffer reference
|
|
@@ -467,31 +539,36 @@ class WebGLTextureUtils {
|
|
|
467
539
|
|
|
468
540
|
renderContextData.renderBufferStorageSetup = undefined;
|
|
469
541
|
|
|
470
|
-
if ( renderContextData.
|
|
542
|
+
if ( renderContextData.framebuffers ) {
|
|
471
543
|
|
|
472
|
-
|
|
473
|
-
|
|
544
|
+
for ( const cacheKey in renderContextData.framebuffers ) {
|
|
545
|
+
|
|
546
|
+
gl.deleteFramebuffer( renderContextData.framebuffers[ cacheKey ] );
|
|
547
|
+
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
delete renderContextData.framebuffers;
|
|
474
551
|
|
|
475
552
|
}
|
|
476
553
|
|
|
477
554
|
if ( renderContextData.depthRenderbuffer ) {
|
|
478
555
|
|
|
479
556
|
gl.deleteRenderbuffer( renderContextData.depthRenderbuffer );
|
|
480
|
-
renderContextData.depthRenderbuffer
|
|
557
|
+
delete renderContextData.depthRenderbuffer;
|
|
481
558
|
|
|
482
559
|
}
|
|
483
560
|
|
|
484
561
|
if ( renderContextData.stencilRenderbuffer ) {
|
|
485
562
|
|
|
486
563
|
gl.deleteRenderbuffer( renderContextData.stencilRenderbuffer );
|
|
487
|
-
renderContextData.stencilRenderbuffer
|
|
564
|
+
delete renderContextData.stencilRenderbuffer;
|
|
488
565
|
|
|
489
566
|
}
|
|
490
567
|
|
|
491
568
|
if ( renderContextData.msaaFrameBuffer ) {
|
|
492
569
|
|
|
493
570
|
gl.deleteFramebuffer( renderContextData.msaaFrameBuffer );
|
|
494
|
-
renderContextData.msaaFrameBuffer
|
|
571
|
+
delete renderContextData.msaaFrameBuffer;
|
|
495
572
|
|
|
496
573
|
}
|
|
497
574
|
|
|
@@ -503,7 +580,7 @@ class WebGLTextureUtils {
|
|
|
503
580
|
|
|
504
581
|
}
|
|
505
582
|
|
|
506
|
-
renderContextData.msaaRenderbuffers
|
|
583
|
+
delete renderContextData.msaaRenderbuffers;
|
|
507
584
|
|
|
508
585
|
}
|
|
509
586
|
|
|
@@ -523,39 +600,174 @@ class WebGLTextureUtils {
|
|
|
523
600
|
|
|
524
601
|
}
|
|
525
602
|
|
|
526
|
-
|
|
603
|
+
copyTextureToTexture( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
|
|
604
|
+
|
|
605
|
+
const { gl, backend } = this;
|
|
606
|
+
const { state } = this.backend;
|
|
607
|
+
|
|
608
|
+
const { textureGPU: dstTextureGPU, glTextureType, glType, glFormat } = backend.get( dstTexture );
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
let width, height, minX, minY;
|
|
612
|
+
let dstX, dstY;
|
|
613
|
+
if ( srcRegion !== null ) {
|
|
614
|
+
|
|
615
|
+
width = srcRegion.max.x - srcRegion.min.x;
|
|
616
|
+
height = srcRegion.max.y - srcRegion.min.y;
|
|
617
|
+
minX = srcRegion.min.x;
|
|
618
|
+
minY = srcRegion.min.y;
|
|
619
|
+
|
|
620
|
+
} else {
|
|
621
|
+
|
|
622
|
+
width = srcTexture.image.width;
|
|
623
|
+
height = srcTexture.image.height;
|
|
624
|
+
minX = 0;
|
|
625
|
+
minY = 0;
|
|
626
|
+
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
if ( dstPosition !== null ) {
|
|
630
|
+
|
|
631
|
+
dstX = dstPosition.x;
|
|
632
|
+
dstY = dstPosition.y;
|
|
633
|
+
|
|
634
|
+
} else {
|
|
635
|
+
|
|
636
|
+
dstX = 0;
|
|
637
|
+
dstY = 0;
|
|
638
|
+
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
state.bindTexture( glTextureType, dstTextureGPU );
|
|
642
|
+
|
|
643
|
+
// As another texture upload may have changed pixelStorei
|
|
644
|
+
// parameters, make sure they are correct for the dstTexture
|
|
645
|
+
gl.pixelStorei( gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
646
|
+
gl.pixelStorei( gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
|
|
647
|
+
gl.pixelStorei( gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
648
|
+
gl.pixelStorei( gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
649
|
+
|
|
650
|
+
const currentUnpackRowLen = gl.getParameter( gl.UNPACK_ROW_LENGTH );
|
|
651
|
+
const currentUnpackImageHeight = gl.getParameter( gl.UNPACK_IMAGE_HEIGHT );
|
|
652
|
+
const currentUnpackSkipPixels = gl.getParameter( gl.UNPACK_SKIP_PIXELS );
|
|
653
|
+
const currentUnpackSkipRows = gl.getParameter( gl.UNPACK_SKIP_ROWS );
|
|
654
|
+
const currentUnpackSkipImages = gl.getParameter( gl.UNPACK_SKIP_IMAGES );
|
|
655
|
+
|
|
656
|
+
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
657
|
+
|
|
658
|
+
gl.pixelStorei( gl.UNPACK_ROW_LENGTH, image.width );
|
|
659
|
+
gl.pixelStorei( gl.UNPACK_IMAGE_HEIGHT, image.height );
|
|
660
|
+
gl.pixelStorei( gl.UNPACK_SKIP_PIXELS, minX );
|
|
661
|
+
gl.pixelStorei( gl.UNPACK_SKIP_ROWS, minY );
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
if ( srcTexture.isDataTexture ) {
|
|
665
|
+
|
|
666
|
+
gl.texSubImage2D( gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image.data );
|
|
667
|
+
|
|
668
|
+
} else {
|
|
669
|
+
|
|
670
|
+
if ( srcTexture.isCompressedTexture ) {
|
|
671
|
+
|
|
672
|
+
gl.compressedTexSubImage2D( gl.TEXTURE_2D, level, dstX, dstY, image.width, image.height, glFormat, image.data );
|
|
673
|
+
|
|
674
|
+
} else {
|
|
675
|
+
|
|
676
|
+
gl.texSubImage2D( gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image );
|
|
677
|
+
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
gl.pixelStorei( gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
|
|
683
|
+
gl.pixelStorei( gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
|
|
684
|
+
gl.pixelStorei( gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
|
|
685
|
+
gl.pixelStorei( gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
|
|
686
|
+
gl.pixelStorei( gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
|
|
687
|
+
|
|
688
|
+
// Generate mipmaps only when copying level 0
|
|
689
|
+
if ( level === 0 && dstTexture.generateMipmaps ) gl.generateMipmap( gl.TEXTURE_2D );
|
|
690
|
+
|
|
691
|
+
state.unbindTexture();
|
|
692
|
+
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
copyFramebufferToTexture( texture, renderContext, rectangle ) {
|
|
527
696
|
|
|
528
697
|
const { gl } = this;
|
|
529
698
|
const { state } = this.backend;
|
|
530
699
|
|
|
531
700
|
const { textureGPU } = this.backend.get( texture );
|
|
532
701
|
|
|
533
|
-
const width =
|
|
534
|
-
|
|
702
|
+
const { x, y, z: width, w: height } = rectangle;
|
|
703
|
+
|
|
704
|
+
const requireDrawFrameBuffer = texture.isDepthTexture === true || ( renderContext.renderTarget && renderContext.renderTarget.samples > 0 );
|
|
535
705
|
|
|
536
|
-
|
|
706
|
+
const srcHeight = renderContext.renderTarget ? renderContext.renderTarget.height : this.backend.gerDrawingBufferSize().y;
|
|
537
707
|
|
|
538
|
-
|
|
708
|
+
if ( requireDrawFrameBuffer ) {
|
|
539
709
|
|
|
540
|
-
|
|
710
|
+
const partial = ( x !== 0 || y !== 0 );
|
|
711
|
+
let mask;
|
|
712
|
+
let attachment;
|
|
541
713
|
|
|
542
|
-
|
|
714
|
+
if ( texture.isDepthTexture === true ) {
|
|
715
|
+
|
|
716
|
+
mask = gl.DEPTH_BUFFER_BIT;
|
|
717
|
+
attachment = gl.DEPTH_ATTACHMENT;
|
|
718
|
+
|
|
719
|
+
if ( renderContext.stencil ) {
|
|
720
|
+
|
|
721
|
+
mask |= gl.STENCIL_BUFFER_BIT;
|
|
722
|
+
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
} else {
|
|
726
|
+
|
|
727
|
+
mask = gl.COLOR_BUFFER_BIT;
|
|
728
|
+
attachment = gl.COLOR_ATTACHMENT0;
|
|
543
729
|
|
|
544
730
|
}
|
|
545
731
|
|
|
546
|
-
|
|
547
|
-
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, fb );
|
|
732
|
+
if ( partial ) {
|
|
548
733
|
|
|
549
|
-
|
|
734
|
+
const renderTargetContextData = this.backend.get( renderContext.renderTarget );
|
|
550
735
|
|
|
551
|
-
|
|
736
|
+
const fb = renderTargetContextData.framebuffers[ renderContext.getCacheKey() ];
|
|
737
|
+
const msaaFrameBuffer = renderTargetContextData.msaaFrameBuffer;
|
|
552
738
|
|
|
553
|
-
|
|
739
|
+
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, fb );
|
|
740
|
+
state.bindFramebuffer( gl.READ_FRAMEBUFFER, msaaFrameBuffer );
|
|
741
|
+
|
|
742
|
+
const flippedY = srcHeight - y - height;
|
|
743
|
+
|
|
744
|
+
gl.blitFramebuffer( x, flippedY, x + width, flippedY + height, x, flippedY, x + width, flippedY + height, mask, gl.NEAREST );
|
|
745
|
+
|
|
746
|
+
state.bindFramebuffer( gl.READ_FRAMEBUFFER, fb );
|
|
747
|
+
|
|
748
|
+
state.bindTexture( gl.TEXTURE_2D, textureGPU );
|
|
749
|
+
|
|
750
|
+
gl.copyTexSubImage2D( gl.TEXTURE_2D, 0, 0, 0, x, flippedY, width, height );
|
|
751
|
+
|
|
752
|
+
state.unbindTexture();
|
|
753
|
+
|
|
754
|
+
} else {
|
|
755
|
+
|
|
756
|
+
const fb = gl.createFramebuffer();
|
|
757
|
+
|
|
758
|
+
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, fb );
|
|
759
|
+
|
|
760
|
+
gl.framebufferTexture2D( gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, textureGPU, 0 );
|
|
761
|
+
gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, gl.NEAREST );
|
|
762
|
+
|
|
763
|
+
gl.deleteFramebuffer( fb );
|
|
764
|
+
|
|
765
|
+
}
|
|
554
766
|
|
|
555
767
|
} else {
|
|
556
768
|
|
|
557
769
|
state.bindTexture( gl.TEXTURE_2D, textureGPU );
|
|
558
|
-
gl.copyTexSubImage2D( gl.TEXTURE_2D, 0, 0, 0,
|
|
770
|
+
gl.copyTexSubImage2D( gl.TEXTURE_2D, 0, 0, 0, x, srcHeight - height - y, width, height );
|
|
559
771
|
|
|
560
772
|
state.unbindTexture();
|
|
561
773
|
|
|
@@ -583,7 +795,6 @@ class WebGLTextureUtils {
|
|
|
583
795
|
|
|
584
796
|
if ( samples > 0 ) {
|
|
585
797
|
|
|
586
|
-
|
|
587
798
|
if ( depthTexture && depthTexture.isDepthTexture ) {
|
|
588
799
|
|
|
589
800
|
if ( depthTexture.type === gl.FLOAT ) {
|
|
@@ -623,7 +834,7 @@ class WebGLTextureUtils {
|
|
|
623
834
|
|
|
624
835
|
}
|
|
625
836
|
|
|
626
|
-
async copyTextureToBuffer( texture, x, y, width, height ) {
|
|
837
|
+
async copyTextureToBuffer( texture, x, y, width, height, faceIndex ) {
|
|
627
838
|
|
|
628
839
|
const { backend, gl } = this;
|
|
629
840
|
|
|
@@ -632,10 +843,13 @@ class WebGLTextureUtils {
|
|
|
632
843
|
const fb = gl.createFramebuffer();
|
|
633
844
|
|
|
634
845
|
gl.bindFramebuffer( gl.READ_FRAMEBUFFER, fb );
|
|
635
|
-
|
|
846
|
+
|
|
847
|
+
const target = texture.isCubeTexture ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex : gl.TEXTURE_2D;
|
|
848
|
+
|
|
849
|
+
gl.framebufferTexture2D( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, target, textureGPU, 0 );
|
|
636
850
|
|
|
637
851
|
const typedArrayType = this._getTypedArrayType( glType );
|
|
638
|
-
const bytesPerTexel = this._getBytesPerTexel( glFormat );
|
|
852
|
+
const bytesPerTexel = this._getBytesPerTexel( glType, glFormat );
|
|
639
853
|
|
|
640
854
|
const elementCount = width * height;
|
|
641
855
|
const byteLength = elementCount * bytesPerTexel;
|
|
@@ -649,7 +863,7 @@ class WebGLTextureUtils {
|
|
|
649
863
|
|
|
650
864
|
await backend.utils._clientWaitAsync();
|
|
651
865
|
|
|
652
|
-
const dstBuffer = new typedArrayType(
|
|
866
|
+
const dstBuffer = new typedArrayType( byteLength / typedArrayType.BYTES_PER_ELEMENT );
|
|
653
867
|
|
|
654
868
|
gl.bindBuffer( gl.PIXEL_PACK_BUFFER, buffer );
|
|
655
869
|
gl.getBufferSubData( gl.PIXEL_PACK_BUFFER, 0, dstBuffer );
|
|
@@ -673,19 +887,33 @@ class WebGLTextureUtils {
|
|
|
673
887
|
if ( glType === gl.UNSIGNED_SHORT ) return Uint16Array;
|
|
674
888
|
if ( glType === gl.UNSIGNED_INT ) return Uint32Array;
|
|
675
889
|
|
|
890
|
+
if ( glType === gl.HALF_FLOAT ) return Uint16Array;
|
|
676
891
|
if ( glType === gl.FLOAT ) return Float32Array;
|
|
677
892
|
|
|
678
893
|
throw new Error( `Unsupported WebGL type: ${glType}` );
|
|
679
894
|
|
|
680
895
|
}
|
|
681
896
|
|
|
682
|
-
_getBytesPerTexel( glFormat ) {
|
|
897
|
+
_getBytesPerTexel( glType, glFormat ) {
|
|
683
898
|
|
|
684
899
|
const { gl } = this;
|
|
685
900
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
if (
|
|
901
|
+
let bytesPerComponent = 0;
|
|
902
|
+
|
|
903
|
+
if ( glType === gl.UNSIGNED_BYTE ) bytesPerComponent = 1;
|
|
904
|
+
|
|
905
|
+
if ( glType === gl.UNSIGNED_SHORT_4_4_4_4 ||
|
|
906
|
+
glType === gl.UNSIGNED_SHORT_5_5_5_1 ||
|
|
907
|
+
glType === gl.UNSIGNED_SHORT_5_6_5 ||
|
|
908
|
+
glType === gl.UNSIGNED_SHORT ||
|
|
909
|
+
glType === gl.HALF_FLOAT ) bytesPerComponent = 2;
|
|
910
|
+
|
|
911
|
+
if ( glType === gl.UNSIGNED_INT ||
|
|
912
|
+
glType === gl.FLOAT ) bytesPerComponent = 4;
|
|
913
|
+
|
|
914
|
+
if ( glFormat === gl.RGBA ) return bytesPerComponent * 4;
|
|
915
|
+
if ( glFormat === gl.RGB ) return bytesPerComponent * 3;
|
|
916
|
+
if ( glFormat === gl.ALPHA ) return bytesPerComponent;
|
|
689
917
|
|
|
690
918
|
}
|
|
691
919
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format,
|
|
1
|
+
import { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, SRGBColorSpace, NoColorSpace } from '../../../constants.js';
|
|
2
2
|
|
|
3
3
|
class WebGLUtils {
|
|
4
4
|
|
|
@@ -20,6 +20,7 @@ class WebGLUtils {
|
|
|
20
20
|
if ( p === UnsignedByteType ) return gl.UNSIGNED_BYTE;
|
|
21
21
|
if ( p === UnsignedShort4444Type ) return gl.UNSIGNED_SHORT_4_4_4_4;
|
|
22
22
|
if ( p === UnsignedShort5551Type ) return gl.UNSIGNED_SHORT_5_5_5_1;
|
|
23
|
+
if ( p === UnsignedInt5999Type ) return gl.UNSIGNED_INT_5_9_9_9_REV;
|
|
23
24
|
|
|
24
25
|
if ( p === ByteType ) return gl.BYTE;
|
|
25
26
|
if ( p === ShortType ) return gl.SHORT;
|
|
@@ -35,7 +36,7 @@ class WebGLUtils {
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
if ( p === AlphaFormat ) return gl.ALPHA;
|
|
38
|
-
if ( p ===
|
|
39
|
+
if ( p === RGBFormat ) return gl.RGB;
|
|
39
40
|
if ( p === RGBAFormat ) return gl.RGBA;
|
|
40
41
|
if ( p === LuminanceFormat ) return gl.LUMINANCE;
|
|
41
42
|
if ( p === LuminanceAlphaFormat ) return gl.LUMINANCE_ALPHA;
|
|
@@ -113,33 +114,15 @@ class WebGLUtils {
|
|
|
113
114
|
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
//
|
|
117
|
+
// ETC
|
|
117
118
|
|
|
118
|
-
if ( p === RGB_ETC1_Format ) {
|
|
119
|
-
|
|
120
|
-
extension = extensions.get( 'WEBGL_compressed_texture_etc1' );
|
|
121
|
-
|
|
122
|
-
if ( extension !== null ) {
|
|
123
|
-
|
|
124
|
-
return extension.COMPRESSED_RGB_ETC1_WEBGL;
|
|
125
|
-
|
|
126
|
-
} else {
|
|
127
|
-
|
|
128
|
-
return null;
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// ETC2
|
|
135
|
-
|
|
136
|
-
if ( p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {
|
|
119
|
+
if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {
|
|
137
120
|
|
|
138
121
|
extension = extensions.get( 'WEBGL_compressed_texture_etc' );
|
|
139
122
|
|
|
140
123
|
if ( extension !== null ) {
|
|
141
124
|
|
|
142
|
-
if ( p === RGB_ETC2_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
|
|
125
|
+
if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
|
|
143
126
|
if ( p === RGBA_ETC2_EAC_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
|
|
144
127
|
|
|
145
128
|
} else {
|