@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
|
@@ -3,16 +3,12 @@ import {
|
|
|
3
3
|
BackSide,
|
|
4
4
|
FrontSide,
|
|
5
5
|
DoubleSide,
|
|
6
|
-
RGBAFormat,
|
|
7
6
|
HalfFloatType,
|
|
8
|
-
FloatType,
|
|
9
7
|
UnsignedByteType,
|
|
10
8
|
NoToneMapping,
|
|
11
9
|
LinearMipmapLinearFilter,
|
|
12
10
|
SRGBColorSpace,
|
|
13
11
|
LinearSRGBColorSpace,
|
|
14
|
-
sRGBEncoding,
|
|
15
|
-
LinearEncoding,
|
|
16
12
|
RGBAIntegerFormat,
|
|
17
13
|
RGIntegerFormat,
|
|
18
14
|
RedIntegerFormat,
|
|
@@ -28,10 +24,8 @@ import {
|
|
|
28
24
|
import { Color } from '../math/Color.js';
|
|
29
25
|
import { Frustum } from '../math/Frustum.js';
|
|
30
26
|
import { Matrix4 } from '../math/Matrix4.js';
|
|
31
|
-
import { Vector2 } from '../math/Vector2.js';
|
|
32
27
|
import { Vector3 } from '../math/Vector3.js';
|
|
33
28
|
import { Vector4 } from '../math/Vector4.js';
|
|
34
|
-
import { floorPowerOfTwo } from '../math/MathUtils.js';
|
|
35
29
|
import { WebGLAnimation } from './webgl/WebGLAnimation.js';
|
|
36
30
|
import { WebGLAttributes } from './webgl/WebGLAttributes.js';
|
|
37
31
|
import { WebGLBackground } from './webgl/WebGLBackground.js';
|
|
@@ -60,7 +54,7 @@ import { WebGLUtils } from './webgl/WebGLUtils.js';
|
|
|
60
54
|
import { WebXRManager } from './webxr/WebXRManager.js';
|
|
61
55
|
import { WebGLMaterials } from './webgl/WebGLMaterials.js';
|
|
62
56
|
import { WebGLUniformsGroups } from './webgl/WebGLUniformsGroups.js';
|
|
63
|
-
import { createCanvasElement } from '../utils.js';
|
|
57
|
+
import { createCanvasElement, probeAsync, toNormalizedProjectionMatrix, toReversedProjectionMatrix, warnOnce } from '../utils.js';
|
|
64
58
|
import { ColorManagement } from '../math/ColorManagement.js';
|
|
65
59
|
|
|
66
60
|
class WebGLRenderer {
|
|
@@ -71,7 +65,7 @@ class WebGLRenderer {
|
|
|
71
65
|
canvas = createCanvasElement(),
|
|
72
66
|
context = null,
|
|
73
67
|
depth = true,
|
|
74
|
-
stencil =
|
|
68
|
+
stencil = false,
|
|
75
69
|
alpha = false,
|
|
76
70
|
antialias = false,
|
|
77
71
|
premultipliedAlpha = true,
|
|
@@ -86,6 +80,12 @@ class WebGLRenderer {
|
|
|
86
80
|
|
|
87
81
|
if ( context !== null ) {
|
|
88
82
|
|
|
83
|
+
if ( typeof WebGLRenderingContext !== 'undefined' && context instanceof WebGLRenderingContext ) {
|
|
84
|
+
|
|
85
|
+
throw new Error( 'THREE.WebGLRenderer: WebGL 1 is not supported since r163.' );
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
89
|
_alpha = context.getContextAttributes().alpha;
|
|
90
90
|
|
|
91
91
|
} else {
|
|
@@ -145,10 +145,6 @@ class WebGLRenderer {
|
|
|
145
145
|
|
|
146
146
|
this._outputColorSpace = SRGBColorSpace;
|
|
147
147
|
|
|
148
|
-
// physical lights
|
|
149
|
-
|
|
150
|
-
this._useLegacyLights = false;
|
|
151
|
-
|
|
152
148
|
// tone mapping
|
|
153
149
|
|
|
154
150
|
this.toneMapping = NoToneMapping;
|
|
@@ -198,19 +194,19 @@ class WebGLRenderer {
|
|
|
198
194
|
let _clippingEnabled = false;
|
|
199
195
|
let _localClippingEnabled = false;
|
|
200
196
|
|
|
201
|
-
// transmission
|
|
202
|
-
|
|
203
|
-
let _transmissionRenderTarget = null;
|
|
204
|
-
|
|
205
197
|
// camera matrices cache
|
|
206
198
|
|
|
199
|
+
const _currentProjectionMatrix = new Matrix4();
|
|
207
200
|
const _projScreenMatrix = new Matrix4();
|
|
208
201
|
|
|
209
|
-
const _vector2 = new Vector2();
|
|
210
202
|
const _vector3 = new Vector3();
|
|
211
203
|
|
|
204
|
+
const _vector4 = new Vector4();
|
|
205
|
+
|
|
212
206
|
const _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };
|
|
213
207
|
|
|
208
|
+
let _renderBackground = false;
|
|
209
|
+
|
|
214
210
|
function getTargetPixelRatio() {
|
|
215
211
|
|
|
216
212
|
return _currentRenderTarget === null ? _pixelRatio : 1;
|
|
@@ -221,17 +217,9 @@ class WebGLRenderer {
|
|
|
221
217
|
|
|
222
218
|
let _gl = context;
|
|
223
219
|
|
|
224
|
-
function getContext(
|
|
225
|
-
|
|
226
|
-
for ( let i = 0; i < contextNames.length; i ++ ) {
|
|
227
|
-
|
|
228
|
-
const contextName = contextNames[ i ];
|
|
229
|
-
const context = canvas.getContext( contextName, contextAttributes );
|
|
230
|
-
if ( context !== null ) return context;
|
|
231
|
-
|
|
232
|
-
}
|
|
220
|
+
function getContext( contextName, contextAttributes ) {
|
|
233
221
|
|
|
234
|
-
return
|
|
222
|
+
return canvas.getContext( contextName, contextAttributes );
|
|
235
223
|
|
|
236
224
|
}
|
|
237
225
|
|
|
@@ -258,19 +246,13 @@ class WebGLRenderer {
|
|
|
258
246
|
|
|
259
247
|
if ( _gl === null ) {
|
|
260
248
|
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
if ( _this.isWebGL1Renderer === true ) {
|
|
264
|
-
|
|
265
|
-
contextNames.shift();
|
|
266
|
-
|
|
267
|
-
}
|
|
249
|
+
const contextName = 'webgl2';
|
|
268
250
|
|
|
269
|
-
_gl = getContext(
|
|
251
|
+
_gl = getContext( contextName, contextAttributes );
|
|
270
252
|
|
|
271
253
|
if ( _gl === null ) {
|
|
272
254
|
|
|
273
|
-
if ( getContext(
|
|
255
|
+
if ( getContext( contextName ) ) {
|
|
274
256
|
|
|
275
257
|
throw new Error( 'Error creating WebGL context with your selected attributes.' );
|
|
276
258
|
|
|
@@ -284,24 +266,6 @@ class WebGLRenderer {
|
|
|
284
266
|
|
|
285
267
|
}
|
|
286
268
|
|
|
287
|
-
if ( typeof WebGLRenderingContext !== 'undefined' && _gl instanceof WebGLRenderingContext ) { // @deprecated, r153
|
|
288
|
-
|
|
289
|
-
console.warn( 'THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163.' );
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// Some experimental-webgl implementations do not have getShaderPrecisionFormat
|
|
294
|
-
|
|
295
|
-
if ( _gl.getShaderPrecisionFormat === undefined ) {
|
|
296
|
-
|
|
297
|
-
_gl.getShaderPrecisionFormat = function () {
|
|
298
|
-
|
|
299
|
-
return { 'rangeMin': 1, 'rangeMax': 1, 'precision': 1 };
|
|
300
|
-
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
|
|
305
269
|
} catch ( error ) {
|
|
306
270
|
|
|
307
271
|
console.error( 'THREE.WebGLRenderer: ' + error.message );
|
|
@@ -320,22 +284,23 @@ class WebGLRenderer {
|
|
|
320
284
|
function initGLContext() {
|
|
321
285
|
|
|
322
286
|
extensions = new WebGLExtensions( _gl );
|
|
287
|
+
extensions.init();
|
|
323
288
|
|
|
324
|
-
|
|
289
|
+
utils = new WebGLUtils( _gl, extensions );
|
|
325
290
|
|
|
326
|
-
|
|
291
|
+
capabilities = new WebGLCapabilities( _gl, extensions, parameters, utils );
|
|
327
292
|
|
|
328
|
-
|
|
293
|
+
state = new WebGLState( _gl );
|
|
329
294
|
|
|
330
|
-
|
|
295
|
+
if ( capabilities.reverseDepthBuffer ) state.buffers.depth.setReversed( true );
|
|
331
296
|
|
|
332
297
|
info = new WebGLInfo( _gl );
|
|
333
298
|
properties = new WebGLProperties();
|
|
334
299
|
textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
|
|
335
300
|
cubemaps = new WebGLCubeMaps( _this );
|
|
336
301
|
cubeuvmaps = new WebGLCubeUVMaps( _this );
|
|
337
|
-
attributes = new WebGLAttributes( _gl
|
|
338
|
-
bindingStates = new WebGLBindingStates( _gl,
|
|
302
|
+
attributes = new WebGLAttributes( _gl );
|
|
303
|
+
bindingStates = new WebGLBindingStates( _gl, attributes );
|
|
339
304
|
geometries = new WebGLGeometries( _gl, attributes, info, bindingStates );
|
|
340
305
|
objects = new WebGLObjects( _gl, geometries, attributes, info );
|
|
341
306
|
morphtargets = new WebGLMorphtargets( _gl, capabilities, textures );
|
|
@@ -343,13 +308,13 @@ class WebGLRenderer {
|
|
|
343
308
|
programCache = new WebGLPrograms( _this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping );
|
|
344
309
|
materials = new WebGLMaterials( _this, properties );
|
|
345
310
|
renderLists = new WebGLRenderLists();
|
|
346
|
-
renderStates = new WebGLRenderStates( extensions
|
|
311
|
+
renderStates = new WebGLRenderStates( extensions );
|
|
347
312
|
background = new WebGLBackground( _this, cubemaps, cubeuvmaps, state, objects, _alpha, premultipliedAlpha );
|
|
348
313
|
shadowMap = new WebGLShadowMap( _this, objects, capabilities );
|
|
349
314
|
uniformsGroups = new WebGLUniformsGroups( _gl, info, capabilities, state );
|
|
350
315
|
|
|
351
|
-
bufferRenderer = new WebGLBufferRenderer( _gl, extensions, info
|
|
352
|
-
indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info
|
|
316
|
+
bufferRenderer = new WebGLBufferRenderer( _gl, extensions, info );
|
|
317
|
+
indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info );
|
|
353
318
|
|
|
354
319
|
info.programs = programCache.programs;
|
|
355
320
|
|
|
@@ -628,7 +593,13 @@ class WebGLRenderer {
|
|
|
628
593
|
|
|
629
594
|
}
|
|
630
595
|
|
|
631
|
-
if ( depth )
|
|
596
|
+
if ( depth ) {
|
|
597
|
+
|
|
598
|
+
bits |= _gl.DEPTH_BUFFER_BIT;
|
|
599
|
+
_gl.clearDepth( this.capabilities.reverseDepthBuffer ? 0 : 1 );
|
|
600
|
+
|
|
601
|
+
}
|
|
602
|
+
|
|
632
603
|
if ( stencil ) {
|
|
633
604
|
|
|
634
605
|
bits |= _gl.STENCIL_BUFFER_BIT;
|
|
@@ -681,13 +652,6 @@ class WebGLRenderer {
|
|
|
681
652
|
xr.removeEventListener( 'sessionstart', onXRSessionStart );
|
|
682
653
|
xr.removeEventListener( 'sessionend', onXRSessionEnd );
|
|
683
654
|
|
|
684
|
-
if ( _transmissionRenderTarget ) {
|
|
685
|
-
|
|
686
|
-
_transmissionRenderTarget.dispose();
|
|
687
|
-
_transmissionRenderTarget = null;
|
|
688
|
-
|
|
689
|
-
}
|
|
690
|
-
|
|
691
655
|
animation.stop();
|
|
692
656
|
|
|
693
657
|
};
|
|
@@ -898,7 +862,33 @@ class WebGLRenderer {
|
|
|
898
862
|
|
|
899
863
|
if ( object.isBatchedMesh ) {
|
|
900
864
|
|
|
901
|
-
|
|
865
|
+
if ( object._multiDrawInstances !== null ) {
|
|
866
|
+
|
|
867
|
+
renderer.renderMultiDrawInstances( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount, object._multiDrawInstances );
|
|
868
|
+
|
|
869
|
+
} else {
|
|
870
|
+
|
|
871
|
+
if ( ! extensions.get( 'WEBGL_multi_draw' ) ) {
|
|
872
|
+
|
|
873
|
+
const starts = object._multiDrawStarts;
|
|
874
|
+
const counts = object._multiDrawCounts;
|
|
875
|
+
const drawCount = object._multiDrawCount;
|
|
876
|
+
const bytesPerElement = index ? attributes.get( index ).bytesPerElement : 1;
|
|
877
|
+
const uniforms = properties.get( material ).currentProgram.getUniforms();
|
|
878
|
+
for ( let i = 0; i < drawCount; i ++ ) {
|
|
879
|
+
|
|
880
|
+
uniforms.setValue( _gl, '_gl_DrawID', i );
|
|
881
|
+
renderer.render( starts[ i ] / bytesPerElement, counts[ i ] );
|
|
882
|
+
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
} else {
|
|
886
|
+
|
|
887
|
+
renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
|
|
888
|
+
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
}
|
|
902
892
|
|
|
903
893
|
} else if ( object.isInstancedMesh ) {
|
|
904
894
|
|
|
@@ -948,7 +938,7 @@ class WebGLRenderer {
|
|
|
948
938
|
if ( targetScene === null ) targetScene = scene;
|
|
949
939
|
|
|
950
940
|
currentRenderState = renderStates.get( targetScene );
|
|
951
|
-
currentRenderState.init();
|
|
941
|
+
currentRenderState.init( camera );
|
|
952
942
|
|
|
953
943
|
renderStateStack.push( currentRenderState );
|
|
954
944
|
|
|
@@ -990,7 +980,7 @@ class WebGLRenderer {
|
|
|
990
980
|
|
|
991
981
|
}
|
|
992
982
|
|
|
993
|
-
currentRenderState.setupLights(
|
|
983
|
+
currentRenderState.setupLights();
|
|
994
984
|
|
|
995
985
|
// Only initialize materials in the new scene, not the targetScene.
|
|
996
986
|
|
|
@@ -998,6 +988,12 @@ class WebGLRenderer {
|
|
|
998
988
|
|
|
999
989
|
scene.traverse( function ( object ) {
|
|
1000
990
|
|
|
991
|
+
if ( ! ( object.isMesh || object.isPoints || object.isLine || object.isSprite ) ) {
|
|
992
|
+
|
|
993
|
+
return;
|
|
994
|
+
|
|
995
|
+
}
|
|
996
|
+
|
|
1001
997
|
const material = object.material;
|
|
1002
998
|
|
|
1003
999
|
if ( material ) {
|
|
@@ -1165,7 +1161,7 @@ class WebGLRenderer {
|
|
|
1165
1161
|
if ( scene.isScene === true ) scene.onBeforeRender( _this, scene, camera, _currentRenderTarget );
|
|
1166
1162
|
|
|
1167
1163
|
currentRenderState = renderStates.get( scene, renderStateStack.length );
|
|
1168
|
-
currentRenderState.init();
|
|
1164
|
+
currentRenderState.init( camera );
|
|
1169
1165
|
|
|
1170
1166
|
renderStateStack.push( currentRenderState );
|
|
1171
1167
|
|
|
@@ -1180,6 +1176,18 @@ class WebGLRenderer {
|
|
|
1180
1176
|
|
|
1181
1177
|
renderListStack.push( currentRenderList );
|
|
1182
1178
|
|
|
1179
|
+
if ( xr.enabled === true && xr.isPresenting === true ) {
|
|
1180
|
+
|
|
1181
|
+
const depthSensingMesh = _this.xr.getDepthSensingMesh();
|
|
1182
|
+
|
|
1183
|
+
if ( depthSensingMesh !== null ) {
|
|
1184
|
+
|
|
1185
|
+
projectObject( depthSensingMesh, camera, - Infinity, _this.sortObjects );
|
|
1186
|
+
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1183
1191
|
projectObject( scene, camera, 0, _this.sortObjects );
|
|
1184
1192
|
|
|
1185
1193
|
currentRenderList.finish();
|
|
@@ -1190,6 +1198,13 @@ class WebGLRenderer {
|
|
|
1190
1198
|
|
|
1191
1199
|
}
|
|
1192
1200
|
|
|
1201
|
+
_renderBackground = xr.enabled === false || xr.isPresenting === false || xr.hasDepthSensing() === false;
|
|
1202
|
+
if ( _renderBackground ) {
|
|
1203
|
+
|
|
1204
|
+
background.addToRenderList( currentRenderList, scene );
|
|
1205
|
+
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1193
1208
|
//
|
|
1194
1209
|
|
|
1195
1210
|
this.info.render.frame ++;
|
|
@@ -1206,22 +1221,30 @@ class WebGLRenderer {
|
|
|
1206
1221
|
|
|
1207
1222
|
if ( this.info.autoReset === true ) this.info.reset();
|
|
1208
1223
|
|
|
1224
|
+
// render scene
|
|
1209
1225
|
|
|
1210
|
-
|
|
1226
|
+
const opaqueObjects = currentRenderList.opaque;
|
|
1227
|
+
const transmissiveObjects = currentRenderList.transmissive;
|
|
1211
1228
|
|
|
1212
|
-
|
|
1229
|
+
currentRenderState.setupLights();
|
|
1213
1230
|
|
|
1214
|
-
|
|
1231
|
+
if ( camera.isArrayCamera ) {
|
|
1215
1232
|
|
|
1216
|
-
|
|
1233
|
+
const cameras = camera.cameras;
|
|
1217
1234
|
|
|
1218
|
-
|
|
1235
|
+
if ( transmissiveObjects.length > 0 ) {
|
|
1219
1236
|
|
|
1220
|
-
|
|
1237
|
+
for ( let i = 0, l = cameras.length; i < l; i ++ ) {
|
|
1221
1238
|
|
|
1222
|
-
|
|
1239
|
+
const camera2 = cameras[ i ];
|
|
1223
1240
|
|
|
1224
|
-
|
|
1241
|
+
renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera2 );
|
|
1242
|
+
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
if ( _renderBackground ) background.render( scene );
|
|
1225
1248
|
|
|
1226
1249
|
for ( let i = 0, l = cameras.length; i < l; i ++ ) {
|
|
1227
1250
|
|
|
@@ -1233,6 +1256,10 @@ class WebGLRenderer {
|
|
|
1233
1256
|
|
|
1234
1257
|
} else {
|
|
1235
1258
|
|
|
1259
|
+
if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
|
|
1260
|
+
|
|
1261
|
+
if ( _renderBackground ) background.render( scene );
|
|
1262
|
+
|
|
1236
1263
|
renderScene( currentRenderList, scene, camera );
|
|
1237
1264
|
|
|
1238
1265
|
}
|
|
@@ -1267,6 +1294,8 @@ class WebGLRenderer {
|
|
|
1267
1294
|
|
|
1268
1295
|
currentRenderState = renderStateStack[ renderStateStack.length - 1 ];
|
|
1269
1296
|
|
|
1297
|
+
if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, currentRenderState.state.camera );
|
|
1298
|
+
|
|
1270
1299
|
} else {
|
|
1271
1300
|
|
|
1272
1301
|
currentRenderState = null;
|
|
@@ -1319,7 +1348,7 @@ class WebGLRenderer {
|
|
|
1319
1348
|
|
|
1320
1349
|
if ( sortObjects ) {
|
|
1321
1350
|
|
|
1322
|
-
|
|
1351
|
+
_vector4.setFromMatrixPosition( object.matrixWorld )
|
|
1323
1352
|
.applyMatrix4( _projScreenMatrix );
|
|
1324
1353
|
|
|
1325
1354
|
}
|
|
@@ -1329,7 +1358,7 @@ class WebGLRenderer {
|
|
|
1329
1358
|
|
|
1330
1359
|
if ( material.visible ) {
|
|
1331
1360
|
|
|
1332
|
-
currentRenderList.push( object, geometry, material, groupOrder,
|
|
1361
|
+
currentRenderList.push( object, geometry, material, groupOrder, _vector4.z, null );
|
|
1333
1362
|
|
|
1334
1363
|
}
|
|
1335
1364
|
|
|
@@ -1347,16 +1376,16 @@ class WebGLRenderer {
|
|
|
1347
1376
|
if ( object.boundingSphere !== undefined ) {
|
|
1348
1377
|
|
|
1349
1378
|
if ( object.boundingSphere === null ) object.computeBoundingSphere();
|
|
1350
|
-
|
|
1379
|
+
_vector4.copy( object.boundingSphere.center );
|
|
1351
1380
|
|
|
1352
1381
|
} else {
|
|
1353
1382
|
|
|
1354
1383
|
if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
|
|
1355
|
-
|
|
1384
|
+
_vector4.copy( geometry.boundingSphere.center );
|
|
1356
1385
|
|
|
1357
1386
|
}
|
|
1358
1387
|
|
|
1359
|
-
|
|
1388
|
+
_vector4
|
|
1360
1389
|
.applyMatrix4( object.matrixWorld )
|
|
1361
1390
|
.applyMatrix4( _projScreenMatrix );
|
|
1362
1391
|
|
|
@@ -1373,7 +1402,7 @@ class WebGLRenderer {
|
|
|
1373
1402
|
|
|
1374
1403
|
if ( groupMaterial && groupMaterial.visible ) {
|
|
1375
1404
|
|
|
1376
|
-
currentRenderList.push( object, geometry, groupMaterial, groupOrder,
|
|
1405
|
+
currentRenderList.push( object, geometry, groupMaterial, groupOrder, _vector4.z, group );
|
|
1377
1406
|
|
|
1378
1407
|
}
|
|
1379
1408
|
|
|
@@ -1381,7 +1410,7 @@ class WebGLRenderer {
|
|
|
1381
1410
|
|
|
1382
1411
|
} else if ( material.visible ) {
|
|
1383
1412
|
|
|
1384
|
-
currentRenderList.push( object, geometry, material, groupOrder,
|
|
1413
|
+
currentRenderList.push( object, geometry, material, groupOrder, _vector4.z, null );
|
|
1385
1414
|
|
|
1386
1415
|
}
|
|
1387
1416
|
|
|
@@ -1411,8 +1440,6 @@ class WebGLRenderer {
|
|
|
1411
1440
|
|
|
1412
1441
|
if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, camera );
|
|
1413
1442
|
|
|
1414
|
-
if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
|
|
1415
|
-
|
|
1416
1443
|
if ( viewport ) state.viewport( _currentViewport.copy( viewport ) );
|
|
1417
1444
|
|
|
1418
1445
|
if ( opaqueObjects.length > 0 ) renderObjects( opaqueObjects, scene, camera );
|
|
@@ -1439,15 +1466,17 @@ class WebGLRenderer {
|
|
|
1439
1466
|
|
|
1440
1467
|
}
|
|
1441
1468
|
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
if ( _transmissionRenderTarget === null ) {
|
|
1469
|
+
if ( currentRenderState.state.transmissionRenderTarget[ camera.id ] === undefined ) {
|
|
1445
1470
|
|
|
1446
|
-
|
|
1471
|
+
currentRenderState.state.transmissionRenderTarget[ camera.id ] = new WebGLRenderTarget( 1, 1, {
|
|
1447
1472
|
generateMipmaps: true,
|
|
1448
|
-
type: extensions.has( 'EXT_color_buffer_half_float' ) ? HalfFloatType : UnsignedByteType,
|
|
1473
|
+
type: ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) ) ? HalfFloatType : UnsignedByteType,
|
|
1449
1474
|
minFilter: LinearMipmapLinearFilter,
|
|
1450
|
-
samples:
|
|
1475
|
+
samples: 4,
|
|
1476
|
+
stencilBuffer: stencil,
|
|
1477
|
+
resolveDepthBuffer: false,
|
|
1478
|
+
resolveStencilBuffer: false,
|
|
1479
|
+
colorSpace: ColorManagement.workingColorSpace,
|
|
1451
1480
|
} );
|
|
1452
1481
|
|
|
1453
1482
|
// debug
|
|
@@ -1462,22 +1491,15 @@ class WebGLRenderer {
|
|
|
1462
1491
|
|
|
1463
1492
|
}
|
|
1464
1493
|
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
if ( isWebGL2 ) {
|
|
1494
|
+
const transmissionRenderTarget = currentRenderState.state.transmissionRenderTarget[ camera.id ];
|
|
1468
1495
|
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
} else {
|
|
1472
|
-
|
|
1473
|
-
_transmissionRenderTarget.setSize( floorPowerOfTwo( _vector2.x ), floorPowerOfTwo( _vector2.y ) );
|
|
1474
|
-
|
|
1475
|
-
}
|
|
1496
|
+
const activeViewport = camera.viewport || _currentViewport;
|
|
1497
|
+
transmissionRenderTarget.setSize( activeViewport.z, activeViewport.w );
|
|
1476
1498
|
|
|
1477
1499
|
//
|
|
1478
1500
|
|
|
1479
1501
|
const currentRenderTarget = _this.getRenderTarget();
|
|
1480
|
-
_this.setRenderTarget(
|
|
1502
|
+
_this.setRenderTarget( transmissionRenderTarget );
|
|
1481
1503
|
|
|
1482
1504
|
_this.getClearColor( _currentClearColor );
|
|
1483
1505
|
_currentClearAlpha = _this.getClearAlpha();
|
|
@@ -1485,49 +1507,64 @@ class WebGLRenderer {
|
|
|
1485
1507
|
|
|
1486
1508
|
_this.clear();
|
|
1487
1509
|
|
|
1510
|
+
if ( _renderBackground ) background.render( scene );
|
|
1511
|
+
|
|
1488
1512
|
// Turn off the features which can affect the frag color for opaque objects pass.
|
|
1489
1513
|
// Otherwise they are applied twice in opaque objects pass and transmission objects pass.
|
|
1490
1514
|
const currentToneMapping = _this.toneMapping;
|
|
1491
1515
|
_this.toneMapping = NoToneMapping;
|
|
1492
1516
|
|
|
1517
|
+
// Remove viewport from camera to avoid nested render calls resetting viewport to it (e.g Reflector).
|
|
1518
|
+
// Transmission render pass requires viewport to match the transmissionRenderTarget.
|
|
1519
|
+
const currentCameraViewport = camera.viewport;
|
|
1520
|
+
if ( camera.viewport !== undefined ) camera.viewport = undefined;
|
|
1521
|
+
|
|
1522
|
+
currentRenderState.setupLightsView( camera );
|
|
1523
|
+
|
|
1524
|
+
if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, camera );
|
|
1525
|
+
|
|
1493
1526
|
renderObjects( opaqueObjects, scene, camera );
|
|
1494
1527
|
|
|
1495
|
-
textures.updateMultisampleRenderTarget(
|
|
1496
|
-
textures.updateRenderTargetMipmap(
|
|
1528
|
+
textures.updateMultisampleRenderTarget( transmissionRenderTarget );
|
|
1529
|
+
textures.updateRenderTargetMipmap( transmissionRenderTarget );
|
|
1497
1530
|
|
|
1498
|
-
|
|
1531
|
+
if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === false ) { // see #28131
|
|
1499
1532
|
|
|
1500
|
-
|
|
1533
|
+
let renderTargetNeedsUpdate = false;
|
|
1501
1534
|
|
|
1502
|
-
|
|
1535
|
+
for ( let i = 0, l = transmissiveObjects.length; i < l; i ++ ) {
|
|
1503
1536
|
|
|
1504
|
-
|
|
1505
|
-
const geometry = renderItem.geometry;
|
|
1506
|
-
const material = renderItem.material;
|
|
1507
|
-
const group = renderItem.group;
|
|
1537
|
+
const renderItem = transmissiveObjects[ i ];
|
|
1508
1538
|
|
|
1509
|
-
|
|
1539
|
+
const object = renderItem.object;
|
|
1540
|
+
const geometry = renderItem.geometry;
|
|
1541
|
+
const material = renderItem.material;
|
|
1542
|
+
const group = renderItem.group;
|
|
1510
1543
|
|
|
1511
|
-
|
|
1544
|
+
if ( material.side === DoubleSide && object.layers.test( camera.layers ) ) {
|
|
1512
1545
|
|
|
1513
|
-
|
|
1514
|
-
material.needsUpdate = true;
|
|
1546
|
+
const currentSide = material.side;
|
|
1515
1547
|
|
|
1516
|
-
|
|
1548
|
+
material.side = BackSide;
|
|
1549
|
+
material.needsUpdate = true;
|
|
1550
|
+
|
|
1551
|
+
renderObject( object, scene, camera, geometry, material, group );
|
|
1517
1552
|
|
|
1518
|
-
|
|
1519
|
-
|
|
1553
|
+
material.side = currentSide;
|
|
1554
|
+
material.needsUpdate = true;
|
|
1520
1555
|
|
|
1521
|
-
|
|
1556
|
+
renderTargetNeedsUpdate = true;
|
|
1557
|
+
|
|
1558
|
+
}
|
|
1522
1559
|
|
|
1523
1560
|
}
|
|
1524
1561
|
|
|
1525
|
-
|
|
1562
|
+
if ( renderTargetNeedsUpdate === true ) {
|
|
1526
1563
|
|
|
1527
|
-
|
|
1564
|
+
textures.updateMultisampleRenderTarget( transmissionRenderTarget );
|
|
1565
|
+
textures.updateRenderTargetMipmap( transmissionRenderTarget );
|
|
1528
1566
|
|
|
1529
|
-
|
|
1530
|
-
textures.updateRenderTargetMipmap( _transmissionRenderTarget );
|
|
1567
|
+
}
|
|
1531
1568
|
|
|
1532
1569
|
}
|
|
1533
1570
|
|
|
@@ -1535,6 +1572,8 @@ class WebGLRenderer {
|
|
|
1535
1572
|
|
|
1536
1573
|
_this.setClearColor( _currentClearColor, _currentClearAlpha );
|
|
1537
1574
|
|
|
1575
|
+
if ( currentCameraViewport !== undefined ) camera.viewport = currentCameraViewport;
|
|
1576
|
+
|
|
1538
1577
|
_this.toneMapping = currentToneMapping;
|
|
1539
1578
|
|
|
1540
1579
|
}
|
|
@@ -1725,6 +1764,7 @@ class WebGLRenderer {
|
|
|
1725
1764
|
|
|
1726
1765
|
materialProperties.outputColorSpace = parameters.outputColorSpace;
|
|
1727
1766
|
materialProperties.batching = parameters.batching;
|
|
1767
|
+
materialProperties.batchingColor = parameters.batchingColor;
|
|
1728
1768
|
materialProperties.instancing = parameters.instancing;
|
|
1729
1769
|
materialProperties.instancingColor = parameters.instancingColor;
|
|
1730
1770
|
materialProperties.instancingMorph = parameters.instancingMorph;
|
|
@@ -1814,6 +1854,14 @@ class WebGLRenderer {
|
|
|
1814
1854
|
|
|
1815
1855
|
needsProgramChange = true;
|
|
1816
1856
|
|
|
1857
|
+
} else if ( object.isBatchedMesh && materialProperties.batchingColor === true && object.colorTexture === null ) {
|
|
1858
|
+
|
|
1859
|
+
needsProgramChange = true;
|
|
1860
|
+
|
|
1861
|
+
} else if ( object.isBatchedMesh && materialProperties.batchingColor === false && object.colorTexture !== null ) {
|
|
1862
|
+
|
|
1863
|
+
needsProgramChange = true;
|
|
1864
|
+
|
|
1817
1865
|
} else if ( object.isInstancedMesh && materialProperties.instancing === false ) {
|
|
1818
1866
|
|
|
1819
1867
|
needsProgramChange = true;
|
|
@@ -1884,7 +1932,7 @@ class WebGLRenderer {
|
|
|
1884
1932
|
|
|
1885
1933
|
needsProgramChange = true;
|
|
1886
1934
|
|
|
1887
|
-
} else if (
|
|
1935
|
+
} else if ( materialProperties.morphTargetsCount !== morphTargetsCount ) {
|
|
1888
1936
|
|
|
1889
1937
|
needsProgramChange = true;
|
|
1890
1938
|
|
|
@@ -1934,7 +1982,21 @@ class WebGLRenderer {
|
|
|
1934
1982
|
|
|
1935
1983
|
// common camera uniforms
|
|
1936
1984
|
|
|
1937
|
-
|
|
1985
|
+
if ( capabilities.reverseDepthBuffer ) {
|
|
1986
|
+
|
|
1987
|
+
_currentProjectionMatrix.copy( camera.projectionMatrix );
|
|
1988
|
+
|
|
1989
|
+
toNormalizedProjectionMatrix( _currentProjectionMatrix );
|
|
1990
|
+
toReversedProjectionMatrix( _currentProjectionMatrix );
|
|
1991
|
+
|
|
1992
|
+
p_uniforms.setValue( _gl, 'projectionMatrix', _currentProjectionMatrix );
|
|
1993
|
+
|
|
1994
|
+
} else {
|
|
1995
|
+
|
|
1996
|
+
p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
|
|
1997
|
+
|
|
1998
|
+
}
|
|
1999
|
+
|
|
1938
2000
|
p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
|
|
1939
2001
|
|
|
1940
2002
|
const uCamPos = p_uniforms.map.cameraPosition;
|
|
@@ -1993,17 +2055,9 @@ class WebGLRenderer {
|
|
|
1993
2055
|
|
|
1994
2056
|
if ( skeleton ) {
|
|
1995
2057
|
|
|
1996
|
-
if (
|
|
1997
|
-
|
|
1998
|
-
if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture();
|
|
1999
|
-
|
|
2000
|
-
p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );
|
|
2001
|
-
|
|
2002
|
-
} else {
|
|
2058
|
+
if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture();
|
|
2003
2059
|
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
}
|
|
2060
|
+
p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );
|
|
2007
2061
|
|
|
2008
2062
|
}
|
|
2009
2063
|
|
|
@@ -2014,11 +2068,21 @@ class WebGLRenderer {
|
|
|
2014
2068
|
p_uniforms.setOptional( _gl, object, 'batchingTexture' );
|
|
2015
2069
|
p_uniforms.setValue( _gl, 'batchingTexture', object._matricesTexture, textures );
|
|
2016
2070
|
|
|
2071
|
+
p_uniforms.setOptional( _gl, object, 'batchingIdTexture' );
|
|
2072
|
+
p_uniforms.setValue( _gl, 'batchingIdTexture', object._indirectTexture, textures );
|
|
2073
|
+
|
|
2074
|
+
p_uniforms.setOptional( _gl, object, 'batchingColorTexture' );
|
|
2075
|
+
if ( object._colorsTexture !== null ) {
|
|
2076
|
+
|
|
2077
|
+
p_uniforms.setValue( _gl, 'batchingColorTexture', object._colorsTexture, textures );
|
|
2078
|
+
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2017
2081
|
}
|
|
2018
2082
|
|
|
2019
2083
|
const morphAttributes = geometry.morphAttributes;
|
|
2020
2084
|
|
|
2021
|
-
if ( morphAttributes.position !== undefined || morphAttributes.normal !== undefined || ( morphAttributes.color !== undefined
|
|
2085
|
+
if ( morphAttributes.position !== undefined || morphAttributes.normal !== undefined || ( morphAttributes.color !== undefined ) ) {
|
|
2022
2086
|
|
|
2023
2087
|
morphtargets.update( object, geometry, program );
|
|
2024
2088
|
|
|
@@ -2041,6 +2105,12 @@ class WebGLRenderer {
|
|
|
2041
2105
|
|
|
2042
2106
|
}
|
|
2043
2107
|
|
|
2108
|
+
if ( material.isMeshStandardMaterial && material.envMap === null && scene.environment !== null ) {
|
|
2109
|
+
|
|
2110
|
+
m_uniforms.envMapIntensity.value = scene.environmentIntensity;
|
|
2111
|
+
|
|
2112
|
+
}
|
|
2113
|
+
|
|
2044
2114
|
if ( refreshMaterial ) {
|
|
2045
2115
|
|
|
2046
2116
|
p_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );
|
|
@@ -2068,7 +2138,7 @@ class WebGLRenderer {
|
|
|
2068
2138
|
|
|
2069
2139
|
}
|
|
2070
2140
|
|
|
2071
|
-
materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height,
|
|
2141
|
+
materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, currentRenderState.state.transmissionRenderTarget[ camera.id ] );
|
|
2072
2142
|
|
|
2073
2143
|
WebGLUniforms.upload( _gl, getUniformList( materialProperties ), m_uniforms, textures );
|
|
2074
2144
|
|
|
@@ -2101,18 +2171,10 @@ class WebGLRenderer {
|
|
|
2101
2171
|
|
|
2102
2172
|
for ( let i = 0, l = groups.length; i < l; i ++ ) {
|
|
2103
2173
|
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
const group = groups[ i ];
|
|
2107
|
-
|
|
2108
|
-
uniformsGroups.update( group, program );
|
|
2109
|
-
uniformsGroups.bind( group, program );
|
|
2174
|
+
const group = groups[ i ];
|
|
2110
2175
|
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
console.warn( 'THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.' );
|
|
2114
|
-
|
|
2115
|
-
}
|
|
2176
|
+
uniformsGroups.update( group, program );
|
|
2177
|
+
uniformsGroups.bind( group, program );
|
|
2116
2178
|
|
|
2117
2179
|
}
|
|
2118
2180
|
|
|
@@ -2229,6 +2291,28 @@ class WebGLRenderer {
|
|
|
2229
2291
|
// Color and depth texture must be rebound in order for the swapchain to update.
|
|
2230
2292
|
textures.rebindTextures( renderTarget, properties.get( renderTarget.texture ).__webglTexture, properties.get( renderTarget.depthTexture ).__webglTexture );
|
|
2231
2293
|
|
|
2294
|
+
} else if ( renderTarget.depthBuffer ) {
|
|
2295
|
+
|
|
2296
|
+
// check if the depth texture is already bound to the frame buffer and that it's been initialized
|
|
2297
|
+
const depthTexture = renderTarget.depthTexture;
|
|
2298
|
+
if ( renderTargetProperties.__boundDepthTexture !== depthTexture ) {
|
|
2299
|
+
|
|
2300
|
+
// check if the depth texture is compatible
|
|
2301
|
+
if (
|
|
2302
|
+
depthTexture !== null &&
|
|
2303
|
+
properties.has( depthTexture ) &&
|
|
2304
|
+
( renderTarget.width !== depthTexture.image.width || renderTarget.height !== depthTexture.image.height )
|
|
2305
|
+
) {
|
|
2306
|
+
|
|
2307
|
+
throw new Error( 'WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.' );
|
|
2308
|
+
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
// Swap the depth buffer to the currently attached one
|
|
2312
|
+
textures.setupDepthRenderbuffer( renderTarget );
|
|
2313
|
+
|
|
2314
|
+
}
|
|
2315
|
+
|
|
2232
2316
|
}
|
|
2233
2317
|
|
|
2234
2318
|
const texture = renderTarget.texture;
|
|
@@ -2255,7 +2339,7 @@ class WebGLRenderer {
|
|
|
2255
2339
|
|
|
2256
2340
|
isCube = true;
|
|
2257
2341
|
|
|
2258
|
-
} else if ( (
|
|
2342
|
+
} else if ( ( renderTarget.samples > 0 ) && textures.useMultisampledRTT( renderTarget ) === false ) {
|
|
2259
2343
|
|
|
2260
2344
|
framebuffer = properties.get( renderTarget ).__webglMultisampledFramebuffer;
|
|
2261
2345
|
|
|
@@ -2287,7 +2371,7 @@ class WebGLRenderer {
|
|
|
2287
2371
|
|
|
2288
2372
|
const framebufferBound = state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
2289
2373
|
|
|
2290
|
-
if ( framebufferBound &&
|
|
2374
|
+
if ( framebufferBound && useDefaultFramebuffer ) {
|
|
2291
2375
|
|
|
2292
2376
|
state.drawBuffers( renderTarget, framebuffer );
|
|
2293
2377
|
|
|
@@ -2341,18 +2425,14 @@ class WebGLRenderer {
|
|
|
2341
2425
|
const textureFormat = texture.format;
|
|
2342
2426
|
const textureType = texture.type;
|
|
2343
2427
|
|
|
2344
|
-
if (
|
|
2428
|
+
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
2345
2429
|
|
|
2346
2430
|
console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );
|
|
2347
2431
|
return;
|
|
2348
2432
|
|
|
2349
2433
|
}
|
|
2350
2434
|
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // Edge and Chrome Mac < 52 (#9513)
|
|
2354
|
-
! ( textureType === FloatType && ( capabilities.isWebGL2 || extensions.has( 'OES_texture_float' ) || extensions.has( 'WEBGL_color_buffer_float' ) ) ) && // Chrome Mac >= 52 and Firefox
|
|
2355
|
-
! halfFloatSupportedByExt ) {
|
|
2435
|
+
if ( ! capabilities.textureTypeReadable( textureType ) ) {
|
|
2356
2436
|
|
|
2357
2437
|
console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );
|
|
2358
2438
|
return;
|
|
@@ -2380,24 +2460,153 @@ class WebGLRenderer {
|
|
|
2380
2460
|
|
|
2381
2461
|
};
|
|
2382
2462
|
|
|
2383
|
-
this.
|
|
2463
|
+
this.readRenderTargetPixelsAsync = async function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {
|
|
2464
|
+
|
|
2465
|
+
if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
|
|
2466
|
+
|
|
2467
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );
|
|
2468
|
+
|
|
2469
|
+
}
|
|
2470
|
+
|
|
2471
|
+
let framebuffer = properties.get( renderTarget ).__webglFramebuffer;
|
|
2472
|
+
if ( renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined ) {
|
|
2473
|
+
|
|
2474
|
+
framebuffer = framebuffer[ activeCubeFaceIndex ];
|
|
2475
|
+
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
if ( framebuffer ) {
|
|
2479
|
+
|
|
2480
|
+
const texture = renderTarget.texture;
|
|
2481
|
+
const textureFormat = texture.format;
|
|
2482
|
+
const textureType = texture.type;
|
|
2483
|
+
|
|
2484
|
+
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
2485
|
+
|
|
2486
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
|
|
2487
|
+
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
if ( ! capabilities.textureTypeReadable( textureType ) ) {
|
|
2491
|
+
|
|
2492
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.' );
|
|
2493
|
+
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2496
|
+
// the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
|
|
2497
|
+
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
|
|
2498
|
+
|
|
2499
|
+
// set the active frame buffer to the one we want to read
|
|
2500
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
2501
|
+
|
|
2502
|
+
const glBuffer = _gl.createBuffer();
|
|
2503
|
+
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
2504
|
+
_gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
|
|
2505
|
+
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
|
|
2506
|
+
|
|
2507
|
+
// reset the frame buffer to the currently set buffer before waiting
|
|
2508
|
+
const currFramebuffer = _currentRenderTarget !== null ? properties.get( _currentRenderTarget ).__webglFramebuffer : null;
|
|
2509
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, currFramebuffer );
|
|
2510
|
+
|
|
2511
|
+
// check if the commands have finished every 8 ms
|
|
2512
|
+
const sync = _gl.fenceSync( _gl.SYNC_GPU_COMMANDS_COMPLETE, 0 );
|
|
2513
|
+
|
|
2514
|
+
_gl.flush();
|
|
2515
|
+
|
|
2516
|
+
await probeAsync( _gl, sync, 4 );
|
|
2517
|
+
|
|
2518
|
+
// read the data and delete the buffer
|
|
2519
|
+
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
2520
|
+
_gl.getBufferSubData( _gl.PIXEL_PACK_BUFFER, 0, buffer );
|
|
2521
|
+
_gl.deleteBuffer( glBuffer );
|
|
2522
|
+
_gl.deleteSync( sync );
|
|
2523
|
+
|
|
2524
|
+
return buffer;
|
|
2525
|
+
|
|
2526
|
+
} else {
|
|
2527
|
+
|
|
2528
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.' );
|
|
2529
|
+
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
}
|
|
2533
|
+
|
|
2534
|
+
};
|
|
2535
|
+
|
|
2536
|
+
this.copyFramebufferToTexture = function ( texture, position = null, level = 0 ) {
|
|
2537
|
+
|
|
2538
|
+
// support previous signature with position first
|
|
2539
|
+
if ( texture.isTexture !== true ) {
|
|
2540
|
+
|
|
2541
|
+
// @deprecated, r165
|
|
2542
|
+
warnOnce( 'WebGLRenderer: copyFramebufferToTexture function signature has changed.' );
|
|
2543
|
+
|
|
2544
|
+
position = arguments[ 0 ] || null;
|
|
2545
|
+
texture = arguments[ 1 ];
|
|
2546
|
+
|
|
2547
|
+
}
|
|
2384
2548
|
|
|
2385
2549
|
const levelScale = Math.pow( 2, - level );
|
|
2386
2550
|
const width = Math.floor( texture.image.width * levelScale );
|
|
2387
2551
|
const height = Math.floor( texture.image.height * levelScale );
|
|
2388
2552
|
|
|
2553
|
+
const x = position !== null ? position.x : 0;
|
|
2554
|
+
const y = position !== null ? position.y : 0;
|
|
2555
|
+
|
|
2389
2556
|
textures.setTexture2D( texture, 0 );
|
|
2390
2557
|
|
|
2391
|
-
_gl.copyTexSubImage2D( _gl.TEXTURE_2D, level, 0, 0,
|
|
2558
|
+
_gl.copyTexSubImage2D( _gl.TEXTURE_2D, level, 0, 0, x, y, width, height );
|
|
2392
2559
|
|
|
2393
2560
|
state.unbindTexture();
|
|
2394
2561
|
|
|
2395
2562
|
};
|
|
2396
2563
|
|
|
2397
|
-
this.copyTextureToTexture = function (
|
|
2564
|
+
this.copyTextureToTexture = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
|
|
2565
|
+
|
|
2566
|
+
// support previous signature with dstPosition first
|
|
2567
|
+
if ( srcTexture.isTexture !== true ) {
|
|
2568
|
+
|
|
2569
|
+
// @deprecated, r165
|
|
2570
|
+
warnOnce( 'WebGLRenderer: copyTextureToTexture function signature has changed.' );
|
|
2571
|
+
|
|
2572
|
+
dstPosition = arguments[ 0 ] || null;
|
|
2573
|
+
srcTexture = arguments[ 1 ];
|
|
2574
|
+
dstTexture = arguments[ 2 ];
|
|
2575
|
+
level = arguments[ 3 ] || 0;
|
|
2576
|
+
srcRegion = null;
|
|
2577
|
+
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2580
|
+
let width, height, minX, minY;
|
|
2581
|
+
let dstX, dstY;
|
|
2582
|
+
if ( srcRegion !== null ) {
|
|
2583
|
+
|
|
2584
|
+
width = srcRegion.max.x - srcRegion.min.x;
|
|
2585
|
+
height = srcRegion.max.y - srcRegion.min.y;
|
|
2586
|
+
minX = srcRegion.min.x;
|
|
2587
|
+
minY = srcRegion.min.y;
|
|
2588
|
+
|
|
2589
|
+
} else {
|
|
2590
|
+
|
|
2591
|
+
width = srcTexture.image.width;
|
|
2592
|
+
height = srcTexture.image.height;
|
|
2593
|
+
minX = 0;
|
|
2594
|
+
minY = 0;
|
|
2595
|
+
|
|
2596
|
+
}
|
|
2597
|
+
|
|
2598
|
+
if ( dstPosition !== null ) {
|
|
2599
|
+
|
|
2600
|
+
dstX = dstPosition.x;
|
|
2601
|
+
dstY = dstPosition.y;
|
|
2602
|
+
|
|
2603
|
+
} else {
|
|
2604
|
+
|
|
2605
|
+
dstX = 0;
|
|
2606
|
+
dstY = 0;
|
|
2607
|
+
|
|
2608
|
+
}
|
|
2398
2609
|
|
|
2399
|
-
const width = srcTexture.image.width;
|
|
2400
|
-
const height = srcTexture.image.height;
|
|
2401
2610
|
const glFormat = utils.convert( dstTexture.format );
|
|
2402
2611
|
const glType = utils.convert( dstTexture.type );
|
|
2403
2612
|
|
|
@@ -2409,24 +2618,43 @@ class WebGLRenderer {
|
|
|
2409
2618
|
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
2410
2619
|
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
2411
2620
|
|
|
2621
|
+
const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
|
|
2622
|
+
const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
|
|
2623
|
+
const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
|
|
2624
|
+
const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
|
|
2625
|
+
const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
|
|
2626
|
+
|
|
2627
|
+
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
2628
|
+
|
|
2629
|
+
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
|
|
2630
|
+
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
|
|
2631
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
|
|
2632
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
|
|
2633
|
+
|
|
2412
2634
|
if ( srcTexture.isDataTexture ) {
|
|
2413
2635
|
|
|
2414
|
-
_gl.texSubImage2D( _gl.TEXTURE_2D, level,
|
|
2636
|
+
_gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image.data );
|
|
2415
2637
|
|
|
2416
2638
|
} else {
|
|
2417
2639
|
|
|
2418
2640
|
if ( srcTexture.isCompressedTexture ) {
|
|
2419
2641
|
|
|
2420
|
-
_gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level,
|
|
2642
|
+
_gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, image.width, image.height, glFormat, image.data );
|
|
2421
2643
|
|
|
2422
2644
|
} else {
|
|
2423
2645
|
|
|
2424
|
-
_gl.texSubImage2D( _gl.TEXTURE_2D, level,
|
|
2646
|
+
_gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image );
|
|
2425
2647
|
|
|
2426
2648
|
}
|
|
2427
2649
|
|
|
2428
2650
|
}
|
|
2429
2651
|
|
|
2652
|
+
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
|
|
2653
|
+
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
|
|
2654
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
|
|
2655
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
|
|
2656
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
|
|
2657
|
+
|
|
2430
2658
|
// Generate mipmaps only when copying level 0
|
|
2431
2659
|
if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );
|
|
2432
2660
|
|
|
@@ -2434,18 +2662,59 @@ class WebGLRenderer {
|
|
|
2434
2662
|
|
|
2435
2663
|
};
|
|
2436
2664
|
|
|
2437
|
-
this.copyTextureToTexture3D = function (
|
|
2665
|
+
this.copyTextureToTexture3D = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
|
|
2438
2666
|
|
|
2439
|
-
|
|
2667
|
+
// support previous signature with source box first
|
|
2668
|
+
if ( srcTexture.isTexture !== true ) {
|
|
2440
2669
|
|
|
2441
|
-
|
|
2442
|
-
|
|
2670
|
+
// @deprecated, r165
|
|
2671
|
+
warnOnce( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
|
|
2672
|
+
|
|
2673
|
+
srcRegion = arguments[ 0 ] || null;
|
|
2674
|
+
dstPosition = arguments[ 1 ] || null;
|
|
2675
|
+
srcTexture = arguments[ 2 ];
|
|
2676
|
+
dstTexture = arguments[ 3 ];
|
|
2677
|
+
level = arguments[ 4 ] || 0;
|
|
2678
|
+
|
|
2679
|
+
}
|
|
2680
|
+
|
|
2681
|
+
let width, height, depth, minX, minY, minZ;
|
|
2682
|
+
let dstX, dstY, dstZ;
|
|
2683
|
+
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
2684
|
+
if ( srcRegion !== null ) {
|
|
2685
|
+
|
|
2686
|
+
width = srcRegion.max.x - srcRegion.min.x;
|
|
2687
|
+
height = srcRegion.max.y - srcRegion.min.y;
|
|
2688
|
+
depth = srcRegion.max.z - srcRegion.min.z;
|
|
2689
|
+
minX = srcRegion.min.x;
|
|
2690
|
+
minY = srcRegion.min.y;
|
|
2691
|
+
minZ = srcRegion.min.z;
|
|
2692
|
+
|
|
2693
|
+
} else {
|
|
2694
|
+
|
|
2695
|
+
width = image.width;
|
|
2696
|
+
height = image.height;
|
|
2697
|
+
depth = image.depth;
|
|
2698
|
+
minX = 0;
|
|
2699
|
+
minY = 0;
|
|
2700
|
+
minZ = 0;
|
|
2701
|
+
|
|
2702
|
+
}
|
|
2703
|
+
|
|
2704
|
+
if ( dstPosition !== null ) {
|
|
2705
|
+
|
|
2706
|
+
dstX = dstPosition.x;
|
|
2707
|
+
dstY = dstPosition.y;
|
|
2708
|
+
dstZ = dstPosition.z;
|
|
2709
|
+
|
|
2710
|
+
} else {
|
|
2711
|
+
|
|
2712
|
+
dstX = 0;
|
|
2713
|
+
dstY = 0;
|
|
2714
|
+
dstZ = 0;
|
|
2443
2715
|
|
|
2444
2716
|
}
|
|
2445
2717
|
|
|
2446
|
-
const width = Math.round( sourceBox.max.x - sourceBox.min.x );
|
|
2447
|
-
const height = Math.round( sourceBox.max.y - sourceBox.min.y );
|
|
2448
|
-
const depth = sourceBox.max.z - sourceBox.min.z + 1;
|
|
2449
2718
|
const glFormat = utils.convert( dstTexture.format );
|
|
2450
2719
|
const glType = utils.convert( dstTexture.type );
|
|
2451
2720
|
let glTarget;
|
|
@@ -2471,43 +2740,41 @@ class WebGLRenderer {
|
|
|
2471
2740
|
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
2472
2741
|
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
2473
2742
|
|
|
2474
|
-
const
|
|
2475
|
-
const
|
|
2476
|
-
const
|
|
2477
|
-
const
|
|
2478
|
-
const
|
|
2479
|
-
|
|
2480
|
-
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
2743
|
+
const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
|
|
2744
|
+
const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
|
|
2745
|
+
const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
|
|
2746
|
+
const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
|
|
2747
|
+
const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
|
|
2481
2748
|
|
|
2482
2749
|
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
|
|
2483
2750
|
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
|
|
2484
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS,
|
|
2485
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS,
|
|
2486
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES,
|
|
2751
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
|
|
2752
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
|
|
2753
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, minZ );
|
|
2487
2754
|
|
|
2488
2755
|
if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
|
|
2489
2756
|
|
|
2490
|
-
_gl.texSubImage3D( glTarget, level,
|
|
2757
|
+
_gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image.data );
|
|
2491
2758
|
|
|
2492
2759
|
} else {
|
|
2493
2760
|
|
|
2494
2761
|
if ( dstTexture.isCompressedArrayTexture ) {
|
|
2495
2762
|
|
|
2496
|
-
_gl.compressedTexSubImage3D( glTarget, level,
|
|
2763
|
+
_gl.compressedTexSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, image.data );
|
|
2497
2764
|
|
|
2498
2765
|
} else {
|
|
2499
2766
|
|
|
2500
|
-
_gl.texSubImage3D( glTarget, level,
|
|
2767
|
+
_gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image );
|
|
2501
2768
|
|
|
2502
2769
|
}
|
|
2503
2770
|
|
|
2504
2771
|
}
|
|
2505
2772
|
|
|
2506
|
-
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH,
|
|
2507
|
-
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT,
|
|
2508
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS,
|
|
2509
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS,
|
|
2510
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES,
|
|
2773
|
+
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
|
|
2774
|
+
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
|
|
2775
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
|
|
2776
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
|
|
2777
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
|
|
2511
2778
|
|
|
2512
2779
|
// Generate mipmaps only when copying level 0
|
|
2513
2780
|
if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( glTarget );
|
|
@@ -2516,6 +2783,16 @@ class WebGLRenderer {
|
|
|
2516
2783
|
|
|
2517
2784
|
};
|
|
2518
2785
|
|
|
2786
|
+
this.initRenderTarget = function ( target ) {
|
|
2787
|
+
|
|
2788
|
+
if ( properties.get( target ).__webglFramebuffer === undefined ) {
|
|
2789
|
+
|
|
2790
|
+
textures.setupRenderTarget( target );
|
|
2791
|
+
|
|
2792
|
+
}
|
|
2793
|
+
|
|
2794
|
+
};
|
|
2795
|
+
|
|
2519
2796
|
this.initTexture = function ( texture ) {
|
|
2520
2797
|
|
|
2521
2798
|
if ( texture.isCubeTexture ) {
|
|
@@ -2581,34 +2858,6 @@ class WebGLRenderer {
|
|
|
2581
2858
|
|
|
2582
2859
|
}
|
|
2583
2860
|
|
|
2584
|
-
get outputEncoding() { // @deprecated, r152
|
|
2585
|
-
|
|
2586
|
-
console.warn( 'THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.' );
|
|
2587
|
-
return this.outputColorSpace === SRGBColorSpace ? sRGBEncoding : LinearEncoding;
|
|
2588
|
-
|
|
2589
|
-
}
|
|
2590
|
-
|
|
2591
|
-
set outputEncoding( encoding ) { // @deprecated, r152
|
|
2592
|
-
|
|
2593
|
-
console.warn( 'THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.' );
|
|
2594
|
-
this.outputColorSpace = encoding === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
|
|
2595
|
-
|
|
2596
|
-
}
|
|
2597
|
-
|
|
2598
|
-
get useLegacyLights() { // @deprecated, r155
|
|
2599
|
-
|
|
2600
|
-
console.warn( 'THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733.' );
|
|
2601
|
-
return this._useLegacyLights;
|
|
2602
|
-
|
|
2603
|
-
}
|
|
2604
|
-
|
|
2605
|
-
set useLegacyLights( value ) { // @deprecated, r155
|
|
2606
|
-
|
|
2607
|
-
console.warn( 'THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733.' );
|
|
2608
|
-
this._useLegacyLights = value;
|
|
2609
|
-
|
|
2610
|
-
}
|
|
2611
|
-
|
|
2612
2861
|
}
|
|
2613
2862
|
|
|
2614
2863
|
|