super-three 0.164.0 → 0.167.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/build/three.cjs +1273 -503
- package/build/three.module.js +1269 -504
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +76086 -0
- package/build/three.webgpu.min.js +6 -0
- package/examples/jsm/Addons.js +2 -1
- package/examples/jsm/controls/TransformControls.js +1 -1
- package/examples/jsm/csm/CSMShader.js +4 -4
- package/examples/jsm/environments/RoomEnvironment.js +1 -5
- package/examples/jsm/exporters/GLTFExporter.js +8 -4
- package/examples/jsm/exporters/USDZExporter.js +6 -4
- package/examples/jsm/geometries/TeapotGeometry.js +1 -1
- package/examples/jsm/helpers/ViewHelper.js +75 -61
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +91 -0
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +8 -63
- package/examples/jsm/lines/LineMaterial.js +1 -15
- 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/DRACOLoader.js +1 -1
- package/examples/jsm/loaders/FBXLoader.js +47 -58
- package/examples/jsm/loaders/GLTFLoader.js +12 -4
- package/examples/jsm/loaders/LDrawLoader.js +3 -2
- package/examples/jsm/loaders/MMDLoader.js +31 -12
- package/examples/jsm/loaders/MaterialXLoader.js +2 -9
- package/examples/jsm/loaders/USDZLoader.js +124 -76
- package/examples/jsm/loaders/UltraHDRLoader.js +583 -0
- package/examples/jsm/loaders/VTKLoader.js +76 -3
- package/examples/jsm/misc/GPUComputationRenderer.js +9 -19
- package/examples/jsm/modifiers/CurveModifier.js +11 -9
- 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/postprocessing/RenderPass.js +1 -1
- package/examples/jsm/postprocessing/RenderTransitionPass.js +13 -38
- package/examples/jsm/postprocessing/SSAOPass.js +6 -9
- 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/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/transpiler/GLSLDecoder.js +46 -4
- package/examples/jsm/transpiler/TSLEncoder.js +17 -15
- package/examples/jsm/utils/BufferGeometryUtils.js +18 -16
- package/examples/jsm/utils/GPUStatsPanel.js +2 -0
- package/examples/jsm/utils/SortUtils.js +8 -5
- package/package.json +9 -7
- package/src/Three.WebGPU.js +194 -0
- package/src/Three.js +2 -0
- 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/constants.js +4 -1
- package/src/core/Object3D.js +24 -22
- package/src/core/Raycaster.js +6 -2
- package/src/extras/TextureUtils.js +210 -0
- 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 +4 -0
- package/src/loaders/LoaderUtils.js +3 -1
- package/src/loaders/ObjectLoader.js +34 -2
- package/src/materials/Material.js +13 -4
- 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/Vector4.js +13 -0
- package/{examples/jsm → src}/nodes/Nodes.js +39 -20
- package/{examples/jsm → src}/nodes/accessors/BatchNode.js +28 -10
- package/src/nodes/accessors/BitangentNode.js +13 -0
- package/{examples/jsm → src}/nodes/accessors/BufferAttributeNode.js +36 -1
- package/{examples/jsm → src}/nodes/accessors/BufferNode.js +6 -0
- package/src/nodes/accessors/CameraNode.js +19 -0
- package/{examples/jsm → src}/nodes/accessors/CubeTextureNode.js +22 -5
- package/src/nodes/accessors/InstanceNode.js +140 -0
- package/{examples/jsm → src}/nodes/accessors/MaterialNode.js +24 -2
- package/{examples/jsm → src}/nodes/accessors/ModelNode.js +4 -0
- package/{examples/jsm → src}/nodes/accessors/MorphNode.js +24 -20
- package/src/nodes/accessors/NormalNode.js +14 -0
- package/{examples/jsm → src}/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/PositionNode.js +10 -0
- package/{examples/jsm → src}/nodes/accessors/ReferenceNode.js +7 -1
- package/src/nodes/accessors/ReflectVectorNode.js +10 -0
- package/{examples/jsm → src}/nodes/accessors/StorageBufferNode.js +50 -1
- package/{examples/jsm/nodes/accessors/TextureStoreNode.js → src/nodes/accessors/StorageTextureNode.js} +28 -6
- package/src/nodes/accessors/TangentNode.js +23 -0
- package/src/nodes/accessors/Texture3DNode.js +100 -0
- package/{examples/jsm → src}/nodes/accessors/TextureNode.js +55 -18
- package/src/nodes/accessors/UVNode.js +3 -0
- package/{examples/jsm → src}/nodes/accessors/UniformsNode.js +7 -1
- package/{examples/jsm → src}/nodes/accessors/VertexColorNode.js +2 -1
- package/{examples/jsm → src}/nodes/code/ScriptableNode.js +14 -0
- package/{examples/jsm → src}/nodes/code/ScriptableValueNode.js +2 -1
- package/{examples/jsm → src}/nodes/core/AttributeNode.js +34 -8
- package/{examples/jsm → src}/nodes/core/CacheNode.js +7 -10
- package/{examples/jsm → src}/nodes/core/ContextNode.js +6 -0
- package/{examples/jsm → src}/nodes/core/IndexNode.js +6 -0
- package/{examples/jsm → src}/nodes/core/LightingModel.js +2 -2
- package/src/nodes/core/MRTNode.js +76 -0
- package/{examples/jsm → src}/nodes/core/Node.js +33 -14
- package/{examples/jsm → src}/nodes/core/NodeBuilder.js +194 -45
- package/src/nodes/core/NodeCache.js +36 -0
- package/{examples/jsm → src}/nodes/core/NodeFrame.js +42 -0
- package/{examples/jsm → src}/nodes/core/NodeFunction.js +2 -2
- package/{examples/jsm → src}/nodes/core/NodeKeywords.js +1 -1
- package/{examples/jsm → src}/nodes/core/NodeUniform.js +1 -2
- package/{examples/jsm → src}/nodes/core/NodeUtils.js +6 -1
- package/{examples/jsm → src}/nodes/core/OutputStructNode.js +1 -5
- package/{examples/jsm → src}/nodes/core/PropertyNode.js +2 -0
- package/{examples/jsm → src}/nodes/core/TempNode.js +2 -2
- package/{examples/jsm → src}/nodes/core/UniformGroupNode.js +20 -0
- package/{examples/jsm → src}/nodes/core/UniformNode.js +10 -1
- package/{examples/jsm → src}/nodes/core/VarNode.js +2 -6
- package/src/nodes/core/VaryingNode.js +104 -0
- package/{examples/jsm → src}/nodes/display/AfterImageNode.js +24 -20
- package/{examples/jsm → src}/nodes/display/AnamorphicNode.js +18 -21
- package/src/nodes/display/BloomNode.js +333 -0
- package/{examples/jsm → src}/nodes/display/ColorAdjustmentNode.js +7 -2
- package/{examples/jsm → src}/nodes/display/ColorSpaceNode.js +1 -1
- package/src/nodes/display/DenoiseNode.js +198 -0
- package/src/nodes/display/DepthOfFieldNode.js +119 -0
- package/src/nodes/display/DotScreenNode.js +75 -0
- package/src/nodes/display/FXAANode.js +327 -0
- package/src/nodes/display/FilmNode.js +52 -0
- package/{examples/jsm → src}/nodes/display/FrontFacingNode.js +2 -1
- package/src/nodes/display/GTAONode.js +324 -0
- package/{examples/jsm → src}/nodes/display/GaussianBlurNode.js +34 -17
- package/src/nodes/display/Lut3DNode.js +53 -0
- package/{examples/jsm → src}/nodes/display/NormalMapNode.js +1 -1
- package/src/nodes/display/PassNode.js +291 -0
- package/src/nodes/display/PixelationPassNode.js +201 -0
- package/src/nodes/display/RGBShiftNode.js +49 -0
- package/src/nodes/display/RenderOutputNode.js +56 -0
- package/src/nodes/display/SobelOperatorNode.js +121 -0
- package/{examples/jsm → src}/nodes/display/ToneMappingNode.js +44 -5
- package/src/nodes/display/TransitionNode.js +76 -0
- package/{examples/jsm → src}/nodes/display/ViewportDepthNode.js +39 -16
- package/{examples/jsm → src}/nodes/display/ViewportDepthTextureNode.js +2 -1
- package/{examples/jsm → src}/nodes/display/ViewportNode.js +3 -2
- package/{examples/jsm → src}/nodes/display/ViewportSharedTextureNode.js +2 -1
- package/{examples/jsm → src}/nodes/display/ViewportTextureNode.js +5 -2
- package/src/nodes/functions/BSDF/LTC.js +131 -0
- package/src/nodes/functions/BasicLightingModel.js +78 -0
- package/{examples/jsm → src}/nodes/functions/PhongLightingModel.js +5 -3
- package/{examples/jsm → src}/nodes/functions/PhysicalLightingModel.js +103 -18
- package/src/nodes/functions/ToonLightingModel.js +51 -0
- package/{examples/jsm → src}/nodes/geometry/RangeNode.js +19 -6
- package/{examples/jsm → src}/nodes/lighting/AONode.js +1 -4
- package/{examples/jsm → src}/nodes/lighting/AmbientLightNode.js +1 -1
- package/src/nodes/lighting/AnalyticLightNode.js +333 -0
- package/src/nodes/lighting/BasicEnvironmentNode.js +26 -0
- package/src/nodes/lighting/BasicLightMapNode.js +29 -0
- package/{examples/jsm → src}/nodes/lighting/DirectionalLightNode.js +2 -3
- package/{examples/jsm → src}/nodes/lighting/EnvironmentNode.js +5 -4
- package/{examples/jsm → src}/nodes/lighting/HemisphereLightNode.js +2 -1
- package/{examples/jsm → src}/nodes/lighting/IESSpotLightNode.js +1 -1
- package/{examples/jsm → src}/nodes/lighting/LightingNode.js +2 -0
- package/{examples/jsm → src}/nodes/lighting/LightsNode.js +18 -3
- package/{examples/jsm → src}/nodes/lighting/PointLightNode.js +2 -3
- package/src/nodes/lighting/RectAreaLightNode.js +97 -0
- package/{examples/jsm → src}/nodes/lighting/SpotLightNode.js +2 -3
- package/{examples/jsm → src}/nodes/loaders/NodeLoader.js +3 -1
- package/{examples/jsm → src}/nodes/loaders/NodeMaterialLoader.js +2 -1
- package/{examples/jsm → src}/nodes/loaders/NodeObjectLoader.js +2 -1
- package/{examples/jsm → src}/nodes/materials/InstancedPointsNodeMaterial.js +3 -3
- package/{examples/jsm → src}/nodes/materials/Line2NodeMaterial.js +4 -4
- package/{examples/jsm → src}/nodes/materials/LineBasicNodeMaterial.js +3 -3
- package/{examples/jsm → src}/nodes/materials/LineDashedNodeMaterial.js +4 -3
- package/{examples/jsm → src}/nodes/materials/Materials.js +3 -0
- package/src/nodes/materials/MeshBasicNodeMaterial.js +73 -0
- package/{examples/jsm → src}/nodes/materials/MeshLambertNodeMaterial.js +12 -3
- package/src/nodes/materials/MeshMatcapNodeMaterial.js +53 -0
- package/{examples/jsm → src}/nodes/materials/MeshNormalNodeMaterial.js +5 -3
- package/{examples/jsm → src}/nodes/materials/MeshPhongNodeMaterial.js +11 -3
- package/{examples/jsm → src}/nodes/materials/MeshPhysicalNodeMaterial.js +26 -8
- package/{examples/jsm → src}/nodes/materials/MeshStandardNodeMaterial.js +14 -3
- package/src/nodes/materials/MeshToonNodeMaterial.js +34 -0
- package/{examples/jsm → src}/nodes/materials/NodeMaterial.js +97 -24
- package/{examples/jsm → src}/nodes/materials/PointsNodeMaterial.js +3 -3
- package/{examples/jsm → src}/nodes/materials/ShadowNodeMaterial.js +3 -3
- package/{examples/jsm → src}/nodes/materials/SpriteNodeMaterial.js +3 -3
- package/src/nodes/materials/VolumeNodeMaterial.js +106 -0
- package/{examples/jsm → src}/nodes/materialx/lib/mx_hsv.js +9 -17
- package/{examples/jsm → src}/nodes/materialx/lib/mx_noise.js +474 -577
- package/{examples/jsm → src}/nodes/materialx/lib/mx_transform_color.js +2 -8
- package/{examples/jsm → src}/nodes/math/CondNode.js +13 -6
- package/{examples/jsm → src}/nodes/math/HashNode.js +2 -2
- package/{examples/jsm → src}/nodes/math/MathNode.js +14 -1
- package/{examples/jsm → src}/nodes/math/OperatorNode.js +6 -6
- package/{examples/jsm → src}/nodes/parsers/GLSLNodeFunction.js +7 -7
- package/{examples/jsm → src}/nodes/pmrem/PMREMNode.js +2 -1
- package/{examples/jsm → src}/nodes/shadernode/ShaderNode.js +57 -33
- package/{examples/jsm → src}/nodes/utils/ArrayElementNode.js +1 -1
- package/{examples/jsm → src}/nodes/utils/DiscardNode.js +1 -0
- package/{examples/jsm → src}/nodes/utils/FunctionOverloadingNode.js +2 -0
- package/{examples/jsm → src}/nodes/utils/LoopNode.js +7 -6
- package/{examples/jsm → src}/nodes/utils/MatcapUVNode.js +1 -1
- package/{examples/jsm → src}/nodes/utils/MaxMipLevelNode.js +8 -2
- package/src/nodes/utils/RTTNode.js +130 -0
- package/{examples/jsm → src}/nodes/utils/ReflectorNode.js +9 -1
- package/{examples/jsm → src}/nodes/utils/TimerNode.js +1 -1
- package/src/objects/BatchedMesh.js +232 -162
- package/src/objects/InstancedMesh.js +1 -1
- package/src/renderers/WebGLRenderer.js +312 -68
- 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 +9 -3
- package/src/renderers/common/BindGroup.js +16 -0
- package/{examples/jsm → src}/renderers/common/Bindings.js +54 -22
- package/src/renderers/common/ChainMap.js +59 -0
- package/{examples/jsm → src}/renderers/common/ClippingContext.js +8 -6
- package/{examples/jsm → src}/renderers/common/Color4.js +1 -1
- package/{examples/jsm → src}/renderers/common/CubeRenderTarget.js +7 -1
- package/{examples/jsm → src}/renderers/common/Geometries.js +37 -5
- package/{examples/jsm → src}/renderers/common/Info.js +34 -6
- package/{examples/jsm → src}/renderers/common/Pipelines.js +2 -2
- package/src/renderers/common/PostProcessing.js +87 -0
- package/{examples/jsm/objects → src/renderers/common}/QuadMesh.js +6 -3
- package/src/renderers/common/RenderBundle.js +18 -0
- package/src/renderers/common/RenderBundles.js +38 -0
- package/{examples/jsm → src}/renderers/common/RenderContext.js +1 -1
- package/{examples/jsm → src}/renderers/common/RenderContexts.js +1 -1
- package/{examples/jsm → src}/renderers/common/RenderList.js +9 -0
- package/{examples/jsm → src}/renderers/common/RenderObject.js +50 -11
- package/{examples/jsm → src}/renderers/common/Renderer.js +220 -40
- package/{examples/jsm → src}/renderers/common/SampledTexture.js +2 -2
- 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 +6 -2
- package/{examples/jsm → src}/renderers/common/Uniform.js +10 -5
- package/{examples/jsm → src}/renderers/common/UniformsGroup.js +69 -31
- package/{examples/jsm → src}/renderers/common/extras/PMREMGenerator.js +13 -12
- package/src/renderers/common/nodes/NodeBuilderState.js +58 -0
- package/{examples/jsm → src}/renderers/common/nodes/NodeSampledTexture.js +19 -4
- 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 +37 -16
- 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/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 +7 -4
- 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/ShaderLib/depth.glsl.js +8 -0
- package/src/renderers/shaders/UniformsLib.js +3 -0
- package/src/renderers/webgl/WebGLAttributes.js +2 -2
- package/src/renderers/webgl/WebGLBackground.js +6 -0
- package/src/renderers/webgl/WebGLBufferRenderer.js +6 -19
- package/src/renderers/webgl/WebGLExtensions.js +3 -1
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +6 -18
- package/src/renderers/webgl/WebGLLights.js +15 -12
- package/src/renderers/webgl/WebGLMaterials.js +1 -5
- package/src/renderers/webgl/WebGLMorphtargets.js +1 -2
- package/src/renderers/webgl/WebGLProgram.js +28 -31
- package/src/renderers/webgl/WebGLPrograms.js +15 -15
- package/src/renderers/webgl/WebGLRenderStates.js +2 -2
- package/src/renderers/webgl/WebGLTextures.js +100 -70
- package/src/renderers/webgl/WebGLUniforms.js +12 -2
- package/src/renderers/webgl/WebGLUniformsGroups.js +7 -7
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBackend.js +156 -54
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/nodes/GLSLNodeBuilder.js +188 -41
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLAttributeUtils.js +2 -2
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLConstants.js +1 -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 +1 -1
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLTextureUtils.js +126 -7
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLUtils.js +1 -1
- package/{examples/jsm → src}/renderers/webgpu/WebGPUBackend.js +212 -78
- package/{examples/jsm → src}/renderers/webgpu/WebGPURenderer.js +2 -2
- package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeBuilder.js +245 -49
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +159 -0
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUAttributeUtils.js +2 -1
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUBindingUtils.js +30 -14
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUConstants.js +9 -1
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUPipelineUtils.js +74 -24
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTextureUtils.js +101 -25
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUUtils.js +24 -3
- package/src/renderers/webxr/WebXRDepthSensing.js +9 -3
- package/src/renderers/webxr/WebXRManager.js +12 -2
- package/src/textures/CompressedArrayTexture.js +14 -0
- package/src/textures/DataArrayTexture.js +14 -0
- package/src/textures/DepthTexture.js +1 -3
- package/src/utils.js +30 -1
- package/examples/jsm/nodes/accessors/BitangentNode.js +0 -89
- package/examples/jsm/nodes/accessors/CameraNode.js +0 -119
- package/examples/jsm/nodes/accessors/InstanceNode.js +0 -94
- package/examples/jsm/nodes/accessors/NormalNode.js +0 -106
- package/examples/jsm/nodes/accessors/PositionNode.js +0 -104
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +0 -35
- package/examples/jsm/nodes/accessors/TangentNode.js +0 -109
- package/examples/jsm/nodes/accessors/UVNode.js +0 -47
- package/examples/jsm/nodes/core/NodeCache.js +0 -26
- package/examples/jsm/nodes/core/VaryingNode.js +0 -65
- package/examples/jsm/nodes/display/PassNode.js +0 -199
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +0 -255
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -28
- package/examples/jsm/renderers/common/ChainMap.js +0 -89
- package/examples/jsm/renderers/common/PostProcessing.js +0 -33
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +0 -44
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +0 -104
- /package/{examples/jsm → src}/nodes/accessors/AccessorsUtils.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/ClippingNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/InstancedPointsMaterialNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/MaterialReferenceNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/ModelViewProjectionNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/PointUVNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/RendererReferenceNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/SceneNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/SkinningNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/TextureBicubicNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/TextureSizeNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/UserDataNode.js +0 -0
- /package/{examples/jsm → src}/nodes/code/CodeNode.js +0 -0
- /package/{examples/jsm → src}/nodes/code/ExpressionNode.js +0 -0
- /package/{examples/jsm → src}/nodes/code/FunctionCallNode.js +0 -0
- /package/{examples/jsm → src}/nodes/code/FunctionNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/AssignNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/BypassNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/ConstNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/InputNode.js +0 -0
- /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/ParameterNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/StackNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/StructTypeNode.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/display/BlendModeNode.js +0 -0
- /package/{examples/jsm → src}/nodes/display/BumpMapNode.js +0 -0
- /package/{examples/jsm → src}/nodes/display/PosterizeNode.js +0 -0
- /package/{examples/jsm → src}/nodes/fog/FogExp2Node.js +0 -0
- /package/{examples/jsm → src}/nodes/fog/FogNode.js +0 -0
- /package/{examples/jsm → src}/nodes/fog/FogRangeNode.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_GGX.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Lambert.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Sheen.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/DFGApprox.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX_Anisotropic.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/EnvironmentBRDF.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/F_Schlick.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/Schlick_to_F0.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/ShadowMaskModel.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/material/getGeometryRoughness.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/material/getRoughness.js +0 -0
- /package/{examples/jsm → src}/nodes/gpgpu/ComputeNode.js +0 -0
- /package/{examples/jsm → src}/nodes/lighting/IrradianceNode.js +0 -0
- /package/{examples/jsm → src}/nodes/lighting/LightNode.js +0 -0
- /package/{examples/jsm → src}/nodes/lighting/LightUtils.js +0 -0
- /package/{examples/jsm → src}/nodes/lighting/LightingContextNode.js +0 -0
- /package/{examples/jsm → src}/nodes/materials/MeshSSSNodeMaterial.js +0 -0
- /package/{examples/jsm → src}/nodes/materialx/DISCLAIMER.md +0 -0
- /package/{examples/jsm → src}/nodes/materialx/MaterialXNodes.js +0 -0
- /package/{examples/jsm → src}/nodes/math/MathUtils.js +0 -0
- /package/{examples/jsm → src}/nodes/math/TriNoise3D.js +0 -0
- /package/{examples/jsm → src}/nodes/parsers/GLSLNodeParser.js +0 -0
- /package/{examples/jsm → src}/nodes/pmrem/PMREMUtils.js +0 -0
- /package/{examples/jsm → src}/nodes/procedural/CheckerNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/ConvertNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/EquirectUVNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/JoinNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/OscNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/PackingNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/RemapNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/RotateNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/RotateUVNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/SetNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/SplitNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/SpriteSheetUVNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/StorageArrayElementNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/TriplanarTexturesNode.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Animation.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/RenderObjects.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}/WebGLBufferRenderer.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
- /package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTexturePassUtils.js +0 -0
package/build/three.cjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
-
const REVISION = '
|
|
8
|
+
const REVISION = '167';
|
|
9
9
|
|
|
10
10
|
const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
|
|
11
11
|
const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
|
|
@@ -110,6 +110,7 @@ const RedFormat = 1028;
|
|
|
110
110
|
const RedIntegerFormat = 1029;
|
|
111
111
|
const RGFormat = 1030;
|
|
112
112
|
const RGIntegerFormat = 1031;
|
|
113
|
+
const RGBIntegerFormat = 1032;
|
|
113
114
|
const RGBAIntegerFormat = 1033;
|
|
114
115
|
|
|
115
116
|
const RGB_S3TC_DXT1_Format = 33776;
|
|
@@ -160,6 +161,8 @@ const TriangleStripDrawMode = 1;
|
|
|
160
161
|
const TriangleFanDrawMode = 2;
|
|
161
162
|
const BasicDepthPacking = 3200;
|
|
162
163
|
const RGBADepthPacking = 3201;
|
|
164
|
+
const RGBDepthPacking = 3202;
|
|
165
|
+
const RGDepthPacking = 3203;
|
|
163
166
|
const TangentSpaceNormalMap = 0;
|
|
164
167
|
const ObjectSpaceNormalMap = 1;
|
|
165
168
|
|
|
@@ -1562,6 +1565,35 @@ function warnOnce( message ) {
|
|
|
1562
1565
|
|
|
1563
1566
|
}
|
|
1564
1567
|
|
|
1568
|
+
function probeAsync( gl, sync, interval ) {
|
|
1569
|
+
|
|
1570
|
+
return new Promise( function ( resolve, reject ) {
|
|
1571
|
+
|
|
1572
|
+
function probe() {
|
|
1573
|
+
|
|
1574
|
+
switch ( gl.clientWaitSync( sync, gl.SYNC_FLUSH_COMMANDS_BIT, 0 ) ) {
|
|
1575
|
+
|
|
1576
|
+
case gl.WAIT_FAILED:
|
|
1577
|
+
reject();
|
|
1578
|
+
break;
|
|
1579
|
+
|
|
1580
|
+
case gl.TIMEOUT_EXPIRED:
|
|
1581
|
+
setTimeout( probe, interval );
|
|
1582
|
+
break;
|
|
1583
|
+
|
|
1584
|
+
default:
|
|
1585
|
+
resolve();
|
|
1586
|
+
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
setTimeout( probe, interval );
|
|
1592
|
+
|
|
1593
|
+
} );
|
|
1594
|
+
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1565
1597
|
/**
|
|
1566
1598
|
* Matrices converting P3 <-> Rec. 709 primaries, without gamut mapping
|
|
1567
1599
|
* or clipping. Based on W3C specifications for sRGB and Display P3,
|
|
@@ -1594,24 +1626,28 @@ const COLOR_SPACES = {
|
|
|
1594
1626
|
[ LinearSRGBColorSpace ]: {
|
|
1595
1627
|
transfer: LinearTransfer,
|
|
1596
1628
|
primaries: Rec709Primaries,
|
|
1629
|
+
luminanceCoefficients: [ 0.2126, 0.7152, 0.0722 ],
|
|
1597
1630
|
toReference: ( color ) => color,
|
|
1598
1631
|
fromReference: ( color ) => color,
|
|
1599
1632
|
},
|
|
1600
1633
|
[ SRGBColorSpace ]: {
|
|
1601
1634
|
transfer: SRGBTransfer,
|
|
1602
1635
|
primaries: Rec709Primaries,
|
|
1636
|
+
luminanceCoefficients: [ 0.2126, 0.7152, 0.0722 ],
|
|
1603
1637
|
toReference: ( color ) => color.convertSRGBToLinear(),
|
|
1604
1638
|
fromReference: ( color ) => color.convertLinearToSRGB(),
|
|
1605
1639
|
},
|
|
1606
1640
|
[ LinearDisplayP3ColorSpace ]: {
|
|
1607
1641
|
transfer: LinearTransfer,
|
|
1608
1642
|
primaries: P3Primaries,
|
|
1643
|
+
luminanceCoefficients: [ 0.2289, 0.6917, 0.0793 ],
|
|
1609
1644
|
toReference: ( color ) => color.applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB ),
|
|
1610
1645
|
fromReference: ( color ) => color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ),
|
|
1611
1646
|
},
|
|
1612
1647
|
[ DisplayP3ColorSpace ]: {
|
|
1613
1648
|
transfer: SRGBTransfer,
|
|
1614
1649
|
primaries: P3Primaries,
|
|
1650
|
+
luminanceCoefficients: [ 0.2289, 0.6917, 0.0793 ],
|
|
1615
1651
|
toReference: ( color ) => color.convertSRGBToLinear().applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB ),
|
|
1616
1652
|
fromReference: ( color ) => color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ).convertLinearToSRGB(),
|
|
1617
1653
|
},
|
|
@@ -1684,6 +1720,12 @@ const ColorManagement = {
|
|
|
1684
1720
|
|
|
1685
1721
|
},
|
|
1686
1722
|
|
|
1723
|
+
getLuminanceCoefficients: function ( target, colorSpace = this._workingColorSpace ) {
|
|
1724
|
+
|
|
1725
|
+
return target.fromArray( COLOR_SPACES[ colorSpace ].luminanceCoefficients );
|
|
1726
|
+
|
|
1727
|
+
},
|
|
1728
|
+
|
|
1687
1729
|
};
|
|
1688
1730
|
|
|
1689
1731
|
|
|
@@ -2665,6 +2707,19 @@ class Vector4 {
|
|
|
2665
2707
|
|
|
2666
2708
|
}
|
|
2667
2709
|
|
|
2710
|
+
setFromMatrixPosition( m ) {
|
|
2711
|
+
|
|
2712
|
+
const e = m.elements;
|
|
2713
|
+
|
|
2714
|
+
this.x = e[ 12 ];
|
|
2715
|
+
this.y = e[ 13 ];
|
|
2716
|
+
this.z = e[ 14 ];
|
|
2717
|
+
this.w = e[ 15 ];
|
|
2718
|
+
|
|
2719
|
+
return this;
|
|
2720
|
+
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2668
2723
|
min( v ) {
|
|
2669
2724
|
|
|
2670
2725
|
this.x = Math.min( this.x, v.x );
|
|
@@ -3079,6 +3134,20 @@ class DataArrayTexture extends Texture {
|
|
|
3079
3134
|
this.flipY = false;
|
|
3080
3135
|
this.unpackAlignment = 1;
|
|
3081
3136
|
|
|
3137
|
+
this.layerUpdates = new Set();
|
|
3138
|
+
|
|
3139
|
+
}
|
|
3140
|
+
|
|
3141
|
+
addLayerUpdate( layerIndex ) {
|
|
3142
|
+
|
|
3143
|
+
this.layerUpdates.add( layerIndex );
|
|
3144
|
+
|
|
3145
|
+
}
|
|
3146
|
+
|
|
3147
|
+
clearLayerUpdates() {
|
|
3148
|
+
|
|
3149
|
+
this.layerUpdates.clear();
|
|
3150
|
+
|
|
3082
3151
|
}
|
|
3083
3152
|
|
|
3084
3153
|
}
|
|
@@ -4791,9 +4860,9 @@ class Box3 {
|
|
|
4791
4860
|
|
|
4792
4861
|
containsPoint( point ) {
|
|
4793
4862
|
|
|
4794
|
-
return point.x
|
|
4795
|
-
point.y
|
|
4796
|
-
point.z
|
|
4863
|
+
return point.x >= this.min.x && point.x <= this.max.x &&
|
|
4864
|
+
point.y >= this.min.y && point.y <= this.max.y &&
|
|
4865
|
+
point.z >= this.min.z && point.z <= this.max.z;
|
|
4797
4866
|
|
|
4798
4867
|
}
|
|
4799
4868
|
|
|
@@ -4821,9 +4890,9 @@ class Box3 {
|
|
|
4821
4890
|
intersectsBox( box ) {
|
|
4822
4891
|
|
|
4823
4892
|
// using 6 splitting planes to rule out intersections.
|
|
4824
|
-
return box.max.x
|
|
4825
|
-
box.max.y
|
|
4826
|
-
box.max.z
|
|
4893
|
+
return box.max.x >= this.min.x && box.min.x <= this.max.x &&
|
|
4894
|
+
box.max.y >= this.min.y && box.min.y <= this.max.y &&
|
|
4895
|
+
box.max.z >= this.min.z && box.min.z <= this.max.z;
|
|
4827
4896
|
|
|
4828
4897
|
}
|
|
4829
4898
|
|
|
@@ -4897,14 +4966,14 @@ class Box3 {
|
|
|
4897
4966
|
_extents.subVectors( this.max, _center );
|
|
4898
4967
|
|
|
4899
4968
|
// translate triangle to aabb origin
|
|
4900
|
-
_v0$
|
|
4969
|
+
_v0$3.subVectors( triangle.a, _center );
|
|
4901
4970
|
_v1$7.subVectors( triangle.b, _center );
|
|
4902
4971
|
_v2$4.subVectors( triangle.c, _center );
|
|
4903
4972
|
|
|
4904
4973
|
// compute edge vectors for triangle
|
|
4905
|
-
_f0.subVectors( _v1$7, _v0$
|
|
4974
|
+
_f0.subVectors( _v1$7, _v0$3 );
|
|
4906
4975
|
_f1.subVectors( _v2$4, _v1$7 );
|
|
4907
|
-
_f2.subVectors( _v0$
|
|
4976
|
+
_f2.subVectors( _v0$3, _v2$4 );
|
|
4908
4977
|
|
|
4909
4978
|
// test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb
|
|
4910
4979
|
// make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation
|
|
@@ -4914,7 +4983,7 @@ class Box3 {
|
|
|
4914
4983
|
_f0.z, 0, - _f0.x, _f1.z, 0, - _f1.x, _f2.z, 0, - _f2.x,
|
|
4915
4984
|
- _f0.y, _f0.x, 0, - _f1.y, _f1.x, 0, - _f2.y, _f2.x, 0
|
|
4916
4985
|
];
|
|
4917
|
-
if ( ! satForAxes( axes, _v0$
|
|
4986
|
+
if ( ! satForAxes( axes, _v0$3, _v1$7, _v2$4, _extents ) ) {
|
|
4918
4987
|
|
|
4919
4988
|
return false;
|
|
4920
4989
|
|
|
@@ -4922,7 +4991,7 @@ class Box3 {
|
|
|
4922
4991
|
|
|
4923
4992
|
// test 3 face normals from the aabb
|
|
4924
4993
|
axes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ];
|
|
4925
|
-
if ( ! satForAxes( axes, _v0$
|
|
4994
|
+
if ( ! satForAxes( axes, _v0$3, _v1$7, _v2$4, _extents ) ) {
|
|
4926
4995
|
|
|
4927
4996
|
return false;
|
|
4928
4997
|
|
|
@@ -4933,7 +5002,7 @@ class Box3 {
|
|
|
4933
5002
|
_triangleNormal.crossVectors( _f0, _f1 );
|
|
4934
5003
|
axes = [ _triangleNormal.x, _triangleNormal.y, _triangleNormal.z ];
|
|
4935
5004
|
|
|
4936
|
-
return satForAxes( axes, _v0$
|
|
5005
|
+
return satForAxes( axes, _v0$3, _v1$7, _v2$4, _extents );
|
|
4937
5006
|
|
|
4938
5007
|
}
|
|
4939
5008
|
|
|
@@ -5043,7 +5112,7 @@ const _box$4 = /*@__PURE__*/ new Box3();
|
|
|
5043
5112
|
|
|
5044
5113
|
// triangle centered vertices
|
|
5045
5114
|
|
|
5046
|
-
const _v0$
|
|
5115
|
+
const _v0$3 = /*@__PURE__*/ new Vector3();
|
|
5047
5116
|
const _v1$7 = /*@__PURE__*/ new Vector3();
|
|
5048
5117
|
const _v2$4 = /*@__PURE__*/ new Vector3();
|
|
5049
5118
|
|
|
@@ -7676,13 +7745,17 @@ class Object3D extends EventDispatcher {
|
|
|
7676
7745
|
|
|
7677
7746
|
if ( this.matrixWorldNeedsUpdate || force ) {
|
|
7678
7747
|
|
|
7679
|
-
if ( this.
|
|
7748
|
+
if ( this.matrixWorldAutoUpdate === true ) {
|
|
7680
7749
|
|
|
7681
|
-
|
|
7750
|
+
if ( this.parent === null ) {
|
|
7682
7751
|
|
|
7683
|
-
|
|
7752
|
+
this.matrixWorld.copy( this.matrix );
|
|
7684
7753
|
|
|
7685
|
-
|
|
7754
|
+
} else {
|
|
7755
|
+
|
|
7756
|
+
this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
|
|
7757
|
+
|
|
7758
|
+
}
|
|
7686
7759
|
|
|
7687
7760
|
}
|
|
7688
7761
|
|
|
@@ -7692,7 +7765,7 @@ class Object3D extends EventDispatcher {
|
|
|
7692
7765
|
|
|
7693
7766
|
}
|
|
7694
7767
|
|
|
7695
|
-
//
|
|
7768
|
+
// make sure descendants are updated if required
|
|
7696
7769
|
|
|
7697
7770
|
const children = this.children;
|
|
7698
7771
|
|
|
@@ -7700,11 +7773,7 @@ class Object3D extends EventDispatcher {
|
|
|
7700
7773
|
|
|
7701
7774
|
const child = children[ i ];
|
|
7702
7775
|
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
child.updateMatrixWorld( force );
|
|
7706
|
-
|
|
7707
|
-
}
|
|
7776
|
+
child.updateMatrixWorld( force );
|
|
7708
7777
|
|
|
7709
7778
|
}
|
|
7710
7779
|
|
|
@@ -7714,7 +7783,7 @@ class Object3D extends EventDispatcher {
|
|
|
7714
7783
|
|
|
7715
7784
|
const parent = this.parent;
|
|
7716
7785
|
|
|
7717
|
-
if ( updateParents === true && parent !== null
|
|
7786
|
+
if ( updateParents === true && parent !== null ) {
|
|
7718
7787
|
|
|
7719
7788
|
parent.updateWorldMatrix( true, false );
|
|
7720
7789
|
|
|
@@ -7722,17 +7791,21 @@ class Object3D extends EventDispatcher {
|
|
|
7722
7791
|
|
|
7723
7792
|
if ( this.matrixAutoUpdate ) this.updateMatrix();
|
|
7724
7793
|
|
|
7725
|
-
if ( this.
|
|
7794
|
+
if ( this.matrixWorldAutoUpdate === true ) {
|
|
7795
|
+
|
|
7796
|
+
if ( this.parent === null ) {
|
|
7726
7797
|
|
|
7727
|
-
|
|
7798
|
+
this.matrixWorld.copy( this.matrix );
|
|
7728
7799
|
|
|
7729
|
-
|
|
7800
|
+
} else {
|
|
7730
7801
|
|
|
7731
|
-
|
|
7802
|
+
this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
|
|
7803
|
+
|
|
7804
|
+
}
|
|
7732
7805
|
|
|
7733
7806
|
}
|
|
7734
7807
|
|
|
7735
|
-
//
|
|
7808
|
+
// make sure descendants are updated
|
|
7736
7809
|
|
|
7737
7810
|
if ( updateChildren === true ) {
|
|
7738
7811
|
|
|
@@ -7742,11 +7815,7 @@ class Object3D extends EventDispatcher {
|
|
|
7742
7815
|
|
|
7743
7816
|
const child = children[ i ];
|
|
7744
7817
|
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
child.updateWorldMatrix( false, true );
|
|
7748
|
-
|
|
7749
|
-
}
|
|
7818
|
+
child.updateWorldMatrix( false, true );
|
|
7750
7819
|
|
|
7751
7820
|
}
|
|
7752
7821
|
|
|
@@ -7839,7 +7908,7 @@ class Object3D extends EventDispatcher {
|
|
|
7839
7908
|
sphereCenter: bound.sphere.center.toArray()
|
|
7840
7909
|
} ) );
|
|
7841
7910
|
|
|
7842
|
-
object.
|
|
7911
|
+
object.maxInstanceCount = this._maxInstanceCount;
|
|
7843
7912
|
object.maxVertexCount = this._maxVertexCount;
|
|
7844
7913
|
object.maxIndexCount = this._maxIndexCount;
|
|
7845
7914
|
|
|
@@ -7848,6 +7917,8 @@ class Object3D extends EventDispatcher {
|
|
|
7848
7917
|
|
|
7849
7918
|
object.matricesTexture = this._matricesTexture.toJSON( meta );
|
|
7850
7919
|
|
|
7920
|
+
if ( this._colorsTexture !== null ) object.colorsTexture = this._colorsTexture.toJSON( meta );
|
|
7921
|
+
|
|
7851
7922
|
if ( this.boundingSphere !== null ) {
|
|
7852
7923
|
|
|
7853
7924
|
object.boundingSphere = {
|
|
@@ -8106,7 +8177,7 @@ Object3D.DEFAULT_UP = /*@__PURE__*/ new Vector3( 0, 1, 0 );
|
|
|
8106
8177
|
Object3D.DEFAULT_MATRIX_AUTO_UPDATE = true;
|
|
8107
8178
|
Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = true;
|
|
8108
8179
|
|
|
8109
|
-
const _v0$
|
|
8180
|
+
const _v0$2 = /*@__PURE__*/ new Vector3();
|
|
8110
8181
|
const _v1$3 = /*@__PURE__*/ new Vector3();
|
|
8111
8182
|
const _v2$2 = /*@__PURE__*/ new Vector3();
|
|
8112
8183
|
const _v3$2 = /*@__PURE__*/ new Vector3();
|
|
@@ -8131,8 +8202,8 @@ class Triangle {
|
|
|
8131
8202
|
static getNormal( a, b, c, target ) {
|
|
8132
8203
|
|
|
8133
8204
|
target.subVectors( c, b );
|
|
8134
|
-
_v0$
|
|
8135
|
-
target.cross( _v0$
|
|
8205
|
+
_v0$2.subVectors( a, b );
|
|
8206
|
+
target.cross( _v0$2 );
|
|
8136
8207
|
|
|
8137
8208
|
const targetLengthSq = target.lengthSq();
|
|
8138
8209
|
if ( targetLengthSq > 0 ) {
|
|
@@ -8149,13 +8220,13 @@ class Triangle {
|
|
|
8149
8220
|
// based on: http://www.blackpawn.com/texts/pointinpoly/default.html
|
|
8150
8221
|
static getBarycoord( point, a, b, c, target ) {
|
|
8151
8222
|
|
|
8152
|
-
_v0$
|
|
8223
|
+
_v0$2.subVectors( c, a );
|
|
8153
8224
|
_v1$3.subVectors( b, a );
|
|
8154
8225
|
_v2$2.subVectors( point, a );
|
|
8155
8226
|
|
|
8156
|
-
const dot00 = _v0$
|
|
8157
|
-
const dot01 = _v0$
|
|
8158
|
-
const dot02 = _v0$
|
|
8227
|
+
const dot00 = _v0$2.dot( _v0$2 );
|
|
8228
|
+
const dot01 = _v0$2.dot( _v1$3 );
|
|
8229
|
+
const dot02 = _v0$2.dot( _v2$2 );
|
|
8159
8230
|
const dot11 = _v1$3.dot( _v1$3 );
|
|
8160
8231
|
const dot12 = _v1$3.dot( _v2$2 );
|
|
8161
8232
|
|
|
@@ -8214,11 +8285,11 @@ class Triangle {
|
|
|
8214
8285
|
|
|
8215
8286
|
static isFrontFacing( a, b, c, direction ) {
|
|
8216
8287
|
|
|
8217
|
-
_v0$
|
|
8288
|
+
_v0$2.subVectors( c, b );
|
|
8218
8289
|
_v1$3.subVectors( a, b );
|
|
8219
8290
|
|
|
8220
8291
|
// strictly front facing
|
|
8221
|
-
return ( _v0$
|
|
8292
|
+
return ( _v0$2.cross( _v1$3 ).dot( direction ) < 0 ) ? true : false;
|
|
8222
8293
|
|
|
8223
8294
|
}
|
|
8224
8295
|
|
|
@@ -8270,10 +8341,10 @@ class Triangle {
|
|
|
8270
8341
|
|
|
8271
8342
|
getArea() {
|
|
8272
8343
|
|
|
8273
|
-
_v0$
|
|
8344
|
+
_v0$2.subVectors( this.c, this.b );
|
|
8274
8345
|
_v1$3.subVectors( this.a, this.b );
|
|
8275
8346
|
|
|
8276
|
-
return _v0$
|
|
8347
|
+
return _v0$2.cross( _v1$3 ).length() * 0.5;
|
|
8277
8348
|
|
|
8278
8349
|
}
|
|
8279
8350
|
|
|
@@ -9129,10 +9200,6 @@ class Material extends EventDispatcher {
|
|
|
9129
9200
|
|
|
9130
9201
|
}
|
|
9131
9202
|
|
|
9132
|
-
onBuild( /* shaderobject, renderer */ ) {}
|
|
9133
|
-
|
|
9134
|
-
onBeforeRender( /* renderer, scene, camera, geometry, object, group */ ) {}
|
|
9135
|
-
|
|
9136
9203
|
onBeforeCompile( /* shaderobject, renderer */ ) {}
|
|
9137
9204
|
|
|
9138
9205
|
customProgramCacheKey() {
|
|
@@ -9549,6 +9616,19 @@ class Material extends EventDispatcher {
|
|
|
9549
9616
|
|
|
9550
9617
|
}
|
|
9551
9618
|
|
|
9619
|
+
onBuild( /* shaderobject, renderer */ ) {
|
|
9620
|
+
|
|
9621
|
+
console.warn( 'Material: onBuild() has been removed.' ); // @deprecated, r166
|
|
9622
|
+
|
|
9623
|
+
}
|
|
9624
|
+
|
|
9625
|
+
onBeforeRender( /* renderer, scene, camera, geometry, object, group */ ) {
|
|
9626
|
+
|
|
9627
|
+
console.warn( 'Material: onBeforeRender() has been removed.' ); // @deprecated, r166
|
|
9628
|
+
|
|
9629
|
+
}
|
|
9630
|
+
|
|
9631
|
+
|
|
9552
9632
|
}
|
|
9553
9633
|
|
|
9554
9634
|
class MeshBasicMaterial extends Material {
|
|
@@ -13597,6 +13677,8 @@ function WebGLAttributes( gl ) {
|
|
|
13597
13677
|
|
|
13598
13678
|
function update( attribute, bufferType ) {
|
|
13599
13679
|
|
|
13680
|
+
if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;
|
|
13681
|
+
|
|
13600
13682
|
if ( attribute.isGLBufferAttribute ) {
|
|
13601
13683
|
|
|
13602
13684
|
const cached = buffers.get( attribute );
|
|
@@ -13616,8 +13698,6 @@ function WebGLAttributes( gl ) {
|
|
|
13616
13698
|
|
|
13617
13699
|
}
|
|
13618
13700
|
|
|
13619
|
-
if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;
|
|
13620
|
-
|
|
13621
13701
|
const data = buffers.get( attribute );
|
|
13622
13702
|
|
|
13623
13703
|
if ( data === undefined ) {
|
|
@@ -13760,9 +13840,9 @@ var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D(
|
|
|
13760
13840
|
|
|
13761
13841
|
var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif";
|
|
13762
13842
|
|
|
13763
|
-
var batching_pars_vertex = "#ifdef USE_BATCHING\n\
|
|
13843
|
+
var batching_pars_vertex = "#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec3 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n\t}\n#endif";
|
|
13764
13844
|
|
|
13765
|
-
var batching_vertex = "#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix(
|
|
13845
|
+
var batching_vertex = "#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif";
|
|
13766
13846
|
|
|
13767
13847
|
var begin_vertex = "vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif";
|
|
13768
13848
|
|
|
@@ -13786,11 +13866,11 @@ var color_fragment = "#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\
|
|
|
13786
13866
|
|
|
13787
13867
|
var color_pars_fragment = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif";
|
|
13788
13868
|
|
|
13789
|
-
var color_pars_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif";
|
|
13869
|
+
var color_pars_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif";
|
|
13790
13870
|
|
|
13791
|
-
var color_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif";
|
|
13871
|
+
var color_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif";
|
|
13792
13872
|
|
|
13793
|
-
var common = "#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\
|
|
13873
|
+
var common = "#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated";
|
|
13794
13874
|
|
|
13795
13875
|
var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif";
|
|
13796
13876
|
|
|
@@ -13806,7 +13886,7 @@ var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emi
|
|
|
13806
13886
|
|
|
13807
13887
|
var colorspace_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
|
|
13808
13888
|
|
|
13809
|
-
var colorspace_pars_fragment = "\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}
|
|
13889
|
+
var colorspace_pars_fragment = "\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}";
|
|
13810
13890
|
|
|
13811
13891
|
var envmap_fragment = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif";
|
|
13812
13892
|
|
|
@@ -13834,7 +13914,7 @@ var lights_lambert_fragment = "LambertMaterial material;\nmaterial.diffuseColor
|
|
|
13834
13914
|
|
|
13835
13915
|
var lights_lambert_pars_fragment = "varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert";
|
|
13836
13916
|
|
|
13837
|
-
var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\
|
|
13917
|
+
var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif";
|
|
13838
13918
|
|
|
13839
13919
|
var envmap_physical_pars_fragment = "#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif";
|
|
13840
13920
|
|
|
@@ -13850,7 +13930,7 @@ var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColo
|
|
|
13850
13930
|
|
|
13851
13931
|
var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
|
|
13852
13932
|
|
|
13853
|
-
var lights_fragment_begin = "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
|
|
13933
|
+
var lights_fragment_begin = "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
|
|
13854
13934
|
|
|
13855
13935
|
var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif";
|
|
13856
13936
|
|
|
@@ -13876,15 +13956,15 @@ var metalnessmap_fragment = "float metalnessFactor = metalness;\n#ifdef USE_META
|
|
|
13876
13956
|
|
|
13877
13957
|
var metalnessmap_pars_fragment = "#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif";
|
|
13878
13958
|
|
|
13879
|
-
var morphinstance_vertex = "#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[MORPHTARGETS_COUNT];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif";
|
|
13959
|
+
var morphinstance_vertex = "#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif";
|
|
13880
13960
|
|
|
13881
|
-
var morphcolor_vertex = "#if defined( USE_MORPHCOLORS )
|
|
13961
|
+
var morphcolor_vertex = "#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif";
|
|
13882
13962
|
|
|
13883
|
-
var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\
|
|
13963
|
+
var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif";
|
|
13884
13964
|
|
|
13885
|
-
var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t
|
|
13965
|
+
var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif";
|
|
13886
13966
|
|
|
13887
|
-
var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\
|
|
13967
|
+
var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif";
|
|
13888
13968
|
|
|
13889
13969
|
var normal_fragment_begin = "float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;";
|
|
13890
13970
|
|
|
@@ -13908,7 +13988,7 @@ var iridescence_pars_fragment = "#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D
|
|
|
13908
13988
|
|
|
13909
13989
|
var opaque_fragment = "#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );";
|
|
13910
13990
|
|
|
13911
|
-
var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst
|
|
13991
|
+
var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}";
|
|
13912
13992
|
|
|
13913
13993
|
var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif";
|
|
13914
13994
|
|
|
@@ -13922,13 +14002,13 @@ var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUG
|
|
|
13922
14002
|
|
|
13923
14003
|
var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif";
|
|
13924
14004
|
|
|
13925
|
-
var shadowmap_pars_fragment = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n#endif";
|
|
14005
|
+
var shadowmap_pars_fragment = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif";
|
|
13926
14006
|
|
|
13927
|
-
var shadowmap_pars_vertex = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif";
|
|
14007
|
+
var shadowmap_pars_vertex = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif";
|
|
13928
14008
|
|
|
13929
14009
|
var shadowmap_vertex = "#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif";
|
|
13930
14010
|
|
|
13931
|
-
var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}";
|
|
14011
|
+
var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}";
|
|
13932
14012
|
|
|
13933
14013
|
var skinbase_vertex = "#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";
|
|
13934
14014
|
|
|
@@ -13972,7 +14052,7 @@ const fragment$f = "uniform samplerCube tCube;\nuniform float tFlip;\nuniform fl
|
|
|
13972
14052
|
|
|
13973
14053
|
const vertex$e = "#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}";
|
|
13974
14054
|
|
|
13975
|
-
const fragment$e = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}";
|
|
14055
|
+
const fragment$e = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}";
|
|
13976
14056
|
|
|
13977
14057
|
const vertex$d = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}";
|
|
13978
14058
|
|
|
@@ -14299,6 +14379,7 @@ const UniformsLib = {
|
|
|
14299
14379
|
} },
|
|
14300
14380
|
|
|
14301
14381
|
directionalLightShadows: { value: [], properties: {
|
|
14382
|
+
shadowIntensity: 1,
|
|
14302
14383
|
shadowBias: {},
|
|
14303
14384
|
shadowNormalBias: {},
|
|
14304
14385
|
shadowRadius: {},
|
|
@@ -14319,6 +14400,7 @@ const UniformsLib = {
|
|
|
14319
14400
|
} },
|
|
14320
14401
|
|
|
14321
14402
|
spotLightShadows: { value: [], properties: {
|
|
14403
|
+
shadowIntensity: 1,
|
|
14322
14404
|
shadowBias: {},
|
|
14323
14405
|
shadowNormalBias: {},
|
|
14324
14406
|
shadowRadius: {},
|
|
@@ -14337,6 +14419,7 @@ const UniformsLib = {
|
|
|
14337
14419
|
} },
|
|
14338
14420
|
|
|
14339
14421
|
pointLightShadows: { value: [], properties: {
|
|
14422
|
+
shadowIntensity: 1,
|
|
14340
14423
|
shadowBias: {},
|
|
14341
14424
|
shadowNormalBias: {},
|
|
14342
14425
|
shadowRadius: {},
|
|
@@ -14809,6 +14892,12 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
14809
14892
|
|
|
14810
14893
|
if ( renderer.autoClear || forceClear ) {
|
|
14811
14894
|
|
|
14895
|
+
// buffers might not be writable which is required to ensure a correct clear
|
|
14896
|
+
|
|
14897
|
+
state.buffers.depth.setTest( true );
|
|
14898
|
+
state.buffers.depth.setMask( true );
|
|
14899
|
+
state.buffers.color.setMask( true );
|
|
14900
|
+
|
|
14812
14901
|
renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );
|
|
14813
14902
|
|
|
14814
14903
|
}
|
|
@@ -15629,30 +15718,17 @@ function WebGLBufferRenderer( gl, extensions, info ) {
|
|
|
15629
15718
|
if ( drawCount === 0 ) return;
|
|
15630
15719
|
|
|
15631
15720
|
const extension = extensions.get( 'WEBGL_multi_draw' );
|
|
15721
|
+
extension.multiDrawArraysWEBGL( mode, starts, 0, counts, 0, drawCount );
|
|
15632
15722
|
|
|
15633
|
-
|
|
15634
|
-
|
|
15635
|
-
for ( let i = 0; i < drawCount; i ++ ) {
|
|
15636
|
-
|
|
15637
|
-
this.render( starts[ i ], counts[ i ] );
|
|
15638
|
-
|
|
15639
|
-
}
|
|
15640
|
-
|
|
15641
|
-
} else {
|
|
15723
|
+
let elementCount = 0;
|
|
15724
|
+
for ( let i = 0; i < drawCount; i ++ ) {
|
|
15642
15725
|
|
|
15643
|
-
|
|
15644
|
-
|
|
15645
|
-
let elementCount = 0;
|
|
15646
|
-
for ( let i = 0; i < drawCount; i ++ ) {
|
|
15647
|
-
|
|
15648
|
-
elementCount += counts[ i ];
|
|
15649
|
-
|
|
15650
|
-
}
|
|
15651
|
-
|
|
15652
|
-
info.update( elementCount, mode, 1 );
|
|
15726
|
+
elementCount += counts[ i ];
|
|
15653
15727
|
|
|
15654
15728
|
}
|
|
15655
15729
|
|
|
15730
|
+
info.update( elementCount, mode, 1 );
|
|
15731
|
+
|
|
15656
15732
|
}
|
|
15657
15733
|
|
|
15658
15734
|
function renderMultiDrawInstances( starts, counts, drawCount, primcount ) {
|
|
@@ -17322,7 +17398,7 @@ function WebGLExtensions( gl ) {
|
|
|
17322
17398
|
|
|
17323
17399
|
if ( extension === null ) {
|
|
17324
17400
|
|
|
17325
|
-
|
|
17401
|
+
warnOnce( 'THREE.WebGLRenderer: ' + name + ' extension not supported.' );
|
|
17326
17402
|
|
|
17327
17403
|
}
|
|
17328
17404
|
|
|
@@ -17582,29 +17658,17 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
|
|
|
17582
17658
|
if ( drawCount === 0 ) return;
|
|
17583
17659
|
|
|
17584
17660
|
const extension = extensions.get( 'WEBGL_multi_draw' );
|
|
17661
|
+
extension.multiDrawElementsWEBGL( mode, counts, 0, type, starts, 0, drawCount );
|
|
17585
17662
|
|
|
17586
|
-
|
|
17587
|
-
|
|
17588
|
-
for ( let i = 0; i < drawCount; i ++ ) {
|
|
17589
|
-
|
|
17590
|
-
this.render( starts[ i ] / bytesPerElement, counts[ i ] );
|
|
17591
|
-
|
|
17592
|
-
}
|
|
17593
|
-
|
|
17594
|
-
} else {
|
|
17595
|
-
|
|
17596
|
-
extension.multiDrawElementsWEBGL( mode, counts, 0, type, starts, 0, drawCount );
|
|
17597
|
-
|
|
17598
|
-
let elementCount = 0;
|
|
17599
|
-
for ( let i = 0; i < drawCount; i ++ ) {
|
|
17663
|
+
let elementCount = 0;
|
|
17664
|
+
for ( let i = 0; i < drawCount; i ++ ) {
|
|
17600
17665
|
|
|
17601
|
-
|
|
17666
|
+
elementCount += counts[ i ];
|
|
17602
17667
|
|
|
17603
|
-
|
|
17668
|
+
}
|
|
17604
17669
|
|
|
17605
|
-
|
|
17670
|
+
info.update( elementCount, mode, 1 );
|
|
17606
17671
|
|
|
17607
|
-
}
|
|
17608
17672
|
|
|
17609
17673
|
}
|
|
17610
17674
|
|
|
@@ -17732,8 +17796,7 @@ function WebGLMorphtargets( gl, capabilities, textures ) {
|
|
|
17732
17796
|
|
|
17733
17797
|
const objectInfluences = object.morphTargetInfluences;
|
|
17734
17798
|
|
|
17735
|
-
//
|
|
17736
|
-
// into an array of data textures. Each layer represents a single morph target.
|
|
17799
|
+
// the following encodes morph targets into an array of data textures. Each layer represents a single morph target.
|
|
17737
17800
|
|
|
17738
17801
|
const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
|
|
17739
17802
|
const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
|
|
@@ -18074,9 +18137,7 @@ function WebGLObjects( gl, geometries, attributes, info ) {
|
|
|
18074
18137
|
|
|
18075
18138
|
class DepthTexture extends Texture {
|
|
18076
18139
|
|
|
18077
|
-
constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) {
|
|
18078
|
-
|
|
18079
|
-
format = format !== undefined ? format : DepthFormat;
|
|
18140
|
+
constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format = DepthFormat ) {
|
|
18080
18141
|
|
|
18081
18142
|
if ( format !== DepthFormat && format !== DepthStencilFormat ) {
|
|
18082
18143
|
|
|
@@ -18173,7 +18234,6 @@ class DepthTexture extends Texture {
|
|
|
18173
18234
|
const emptyTexture = /*@__PURE__*/ new Texture();
|
|
18174
18235
|
|
|
18175
18236
|
const emptyShadowTexture = /*@__PURE__*/ new DepthTexture( 1, 1 );
|
|
18176
|
-
emptyShadowTexture.compareFunction = LessEqualCompare;
|
|
18177
18237
|
|
|
18178
18238
|
const emptyArrayTexture = /*@__PURE__*/ new DataArrayTexture();
|
|
18179
18239
|
const empty3dTexture = /*@__PURE__*/ new Data3DTexture();
|
|
@@ -18691,7 +18751,18 @@ function setValueT1( gl, v, textures ) {
|
|
|
18691
18751
|
|
|
18692
18752
|
}
|
|
18693
18753
|
|
|
18694
|
-
|
|
18754
|
+
let emptyTexture2D;
|
|
18755
|
+
|
|
18756
|
+
if ( this.type === gl.SAMPLER_2D_SHADOW ) {
|
|
18757
|
+
|
|
18758
|
+
emptyShadowTexture.compareFunction = LessEqualCompare; // #28670
|
|
18759
|
+
emptyTexture2D = emptyShadowTexture;
|
|
18760
|
+
|
|
18761
|
+
} else {
|
|
18762
|
+
|
|
18763
|
+
emptyTexture2D = emptyTexture;
|
|
18764
|
+
|
|
18765
|
+
}
|
|
18695
18766
|
|
|
18696
18767
|
textures.setTexture2D( v || emptyTexture2D, unit );
|
|
18697
18768
|
|
|
@@ -19424,6 +19495,30 @@ function getToneMappingFunction( functionName, toneMapping ) {
|
|
|
19424
19495
|
|
|
19425
19496
|
}
|
|
19426
19497
|
|
|
19498
|
+
const _v0$1 = /*@__PURE__*/ new Vector3();
|
|
19499
|
+
|
|
19500
|
+
function getLuminanceFunction() {
|
|
19501
|
+
|
|
19502
|
+
ColorManagement.getLuminanceCoefficients( _v0$1 );
|
|
19503
|
+
|
|
19504
|
+
const r = _v0$1.x.toFixed( 4 );
|
|
19505
|
+
const g = _v0$1.y.toFixed( 4 );
|
|
19506
|
+
const b = _v0$1.z.toFixed( 4 );
|
|
19507
|
+
|
|
19508
|
+
return [
|
|
19509
|
+
|
|
19510
|
+
'float luminance( const in vec3 rgb ) {',
|
|
19511
|
+
|
|
19512
|
+
` const vec3 weights = vec3( ${ r }, ${ g }, ${ b } );`,
|
|
19513
|
+
|
|
19514
|
+
' return dot( weights, rgb );',
|
|
19515
|
+
|
|
19516
|
+
'}'
|
|
19517
|
+
|
|
19518
|
+
].join( '\n' );
|
|
19519
|
+
|
|
19520
|
+
}
|
|
19521
|
+
|
|
19427
19522
|
function generateVertexExtensions( parameters ) {
|
|
19428
19523
|
|
|
19429
19524
|
const chunks = [
|
|
@@ -19806,6 +19901,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19806
19901
|
|
|
19807
19902
|
parameters.extensionClipCullDistance ? '#define USE_CLIP_DISTANCE' : '',
|
|
19808
19903
|
parameters.batching ? '#define USE_BATCHING' : '',
|
|
19904
|
+
parameters.batchingColor ? '#define USE_BATCHING_COLOR' : '',
|
|
19809
19905
|
parameters.instancing ? '#define USE_INSTANCING' : '',
|
|
19810
19906
|
parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '',
|
|
19811
19907
|
parameters.instancingMorph ? '#define USE_INSTANCING_MORPH' : '',
|
|
@@ -19902,7 +19998,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19902
19998
|
parameters.morphTargets ? '#define USE_MORPHTARGETS' : '',
|
|
19903
19999
|
parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '',
|
|
19904
20000
|
( parameters.morphColors ) ? '#define USE_MORPHCOLORS' : '',
|
|
19905
|
-
( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE' : '',
|
|
19906
20001
|
( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE_STRIDE ' + parameters.morphTextureStride : '',
|
|
19907
20002
|
( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '',
|
|
19908
20003
|
parameters.doubleSided ? '#define DOUBLE_SIDED' : '',
|
|
@@ -19915,8 +20010,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19915
20010
|
|
|
19916
20011
|
parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
|
|
19917
20012
|
|
|
19918
|
-
parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
|
|
19919
|
-
|
|
19920
20013
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
19921
20014
|
|
|
19922
20015
|
'uniform mat4 modelMatrix;',
|
|
@@ -19983,31 +20076,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19983
20076
|
|
|
19984
20077
|
'#endif',
|
|
19985
20078
|
|
|
19986
|
-
'#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )',
|
|
19987
|
-
|
|
19988
|
-
' attribute vec3 morphTarget0;',
|
|
19989
|
-
' attribute vec3 morphTarget1;',
|
|
19990
|
-
' attribute vec3 morphTarget2;',
|
|
19991
|
-
' attribute vec3 morphTarget3;',
|
|
19992
|
-
|
|
19993
|
-
' #ifdef USE_MORPHNORMALS',
|
|
19994
|
-
|
|
19995
|
-
' attribute vec3 morphNormal0;',
|
|
19996
|
-
' attribute vec3 morphNormal1;',
|
|
19997
|
-
' attribute vec3 morphNormal2;',
|
|
19998
|
-
' attribute vec3 morphNormal3;',
|
|
19999
|
-
|
|
20000
|
-
' #else',
|
|
20001
|
-
|
|
20002
|
-
' attribute vec3 morphTarget4;',
|
|
20003
|
-
' attribute vec3 morphTarget5;',
|
|
20004
|
-
' attribute vec3 morphTarget6;',
|
|
20005
|
-
' attribute vec3 morphTarget7;',
|
|
20006
|
-
|
|
20007
|
-
' #endif',
|
|
20008
|
-
|
|
20009
|
-
'#endif',
|
|
20010
|
-
|
|
20011
20079
|
'#ifdef USE_SKINNING',
|
|
20012
20080
|
|
|
20013
20081
|
' attribute vec4 skinIndex;',
|
|
@@ -20083,7 +20151,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
20083
20151
|
parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '',
|
|
20084
20152
|
|
|
20085
20153
|
parameters.vertexTangents && parameters.flatShading === false ? '#define USE_TANGENT' : '',
|
|
20086
|
-
parameters.vertexColors || parameters.instancingColor ? '#define USE_COLOR' : '',
|
|
20154
|
+
parameters.vertexColors || parameters.instancingColor || parameters.batchingColor ? '#define USE_COLOR' : '',
|
|
20087
20155
|
parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '',
|
|
20088
20156
|
parameters.vertexUv1s ? '#define USE_UV1' : '',
|
|
20089
20157
|
parameters.vertexUv2s ? '#define USE_UV2' : '',
|
|
@@ -20105,8 +20173,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
20105
20173
|
|
|
20106
20174
|
parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
|
|
20107
20175
|
|
|
20108
|
-
parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
|
|
20109
|
-
|
|
20110
20176
|
parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
|
|
20111
20177
|
|
|
20112
20178
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
@@ -20124,6 +20190,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
20124
20190
|
|
|
20125
20191
|
ShaderChunk[ 'colorspace_pars_fragment' ], // this code is required here because it is used by the various encoding/decoding function defined below
|
|
20126
20192
|
getTexelEncodingFunction( 'linearToOutputTexel', parameters.outputColorSpace ),
|
|
20193
|
+
getLuminanceFunction(),
|
|
20127
20194
|
|
|
20128
20195
|
parameters.useDepthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '',
|
|
20129
20196
|
|
|
@@ -20729,6 +20796,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20729
20796
|
precision: precision,
|
|
20730
20797
|
|
|
20731
20798
|
batching: IS_BATCHEDMESH,
|
|
20799
|
+
batchingColor: IS_BATCHEDMESH && object._colorsTexture !== null,
|
|
20732
20800
|
instancing: IS_INSTANCEDMESH,
|
|
20733
20801
|
instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
|
|
20734
20802
|
instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,
|
|
@@ -20874,7 +20942,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20874
20942
|
shadowMapType: renderer.shadowMap.type,
|
|
20875
20943
|
|
|
20876
20944
|
toneMapping: toneMapping,
|
|
20877
|
-
useLegacyLights: renderer._useLegacyLights,
|
|
20878
20945
|
|
|
20879
20946
|
decodeVideoTexture: HAS_MAP && ( material.map.isVideoTexture === true ) && ( ColorManagement.getTransfer( material.map.colorSpace ) === SRGBTransfer ),
|
|
20880
20947
|
|
|
@@ -20889,7 +20956,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20889
20956
|
index0AttributeName: material.index0AttributeName,
|
|
20890
20957
|
|
|
20891
20958
|
extensionClipCullDistance: HAS_EXTENSIONS && material.extensions.clipCullDistance === true && extensions.has( 'WEBGL_clip_cull_distance' ),
|
|
20892
|
-
extensionMultiDraw: HAS_EXTENSIONS && material.extensions.multiDraw === true && extensions.has( 'WEBGL_multi_draw' ),
|
|
20959
|
+
extensionMultiDraw: ( HAS_EXTENSIONS && material.extensions.multiDraw === true || IS_BATCHEDMESH ) && extensions.has( 'WEBGL_multi_draw' ),
|
|
20893
20960
|
|
|
20894
20961
|
rendererExtensionParallelShaderCompile: extensions.has( 'KHR_parallel_shader_compile' ),
|
|
20895
20962
|
|
|
@@ -21048,6 +21115,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
21048
21115
|
_programLayers.enable( 19 );
|
|
21049
21116
|
if ( parameters.dispersion )
|
|
21050
21117
|
_programLayers.enable( 20 );
|
|
21118
|
+
if ( parameters.batchingColor )
|
|
21119
|
+
_programLayers.enable( 21 );
|
|
21051
21120
|
|
|
21052
21121
|
array.push( _programLayers.mask );
|
|
21053
21122
|
_programLayers.disableAll();
|
|
@@ -21072,30 +21141,28 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
21072
21141
|
_programLayers.enable( 8 );
|
|
21073
21142
|
if ( parameters.shadowMapEnabled )
|
|
21074
21143
|
_programLayers.enable( 9 );
|
|
21075
|
-
if ( parameters.useLegacyLights )
|
|
21076
|
-
_programLayers.enable( 10 );
|
|
21077
21144
|
if ( parameters.doubleSided )
|
|
21078
|
-
_programLayers.enable(
|
|
21145
|
+
_programLayers.enable( 10 );
|
|
21079
21146
|
if ( parameters.flipSided )
|
|
21080
|
-
_programLayers.enable(
|
|
21147
|
+
_programLayers.enable( 11 );
|
|
21081
21148
|
if ( parameters.useDepthPacking )
|
|
21082
|
-
_programLayers.enable(
|
|
21149
|
+
_programLayers.enable( 12 );
|
|
21083
21150
|
if ( parameters.dithering )
|
|
21084
|
-
_programLayers.enable(
|
|
21151
|
+
_programLayers.enable( 13 );
|
|
21085
21152
|
if ( parameters.transmission )
|
|
21086
|
-
_programLayers.enable(
|
|
21153
|
+
_programLayers.enable( 14 );
|
|
21087
21154
|
if ( parameters.sheen )
|
|
21088
|
-
_programLayers.enable(
|
|
21155
|
+
_programLayers.enable( 15 );
|
|
21089
21156
|
if ( parameters.opaque )
|
|
21090
|
-
_programLayers.enable(
|
|
21157
|
+
_programLayers.enable( 16 );
|
|
21091
21158
|
if ( parameters.pointsUvs )
|
|
21092
|
-
_programLayers.enable(
|
|
21159
|
+
_programLayers.enable( 17 );
|
|
21093
21160
|
if ( parameters.decodeVideoTexture )
|
|
21094
|
-
_programLayers.enable(
|
|
21161
|
+
_programLayers.enable( 18 );
|
|
21095
21162
|
if ( parameters.alphaToCoverage )
|
|
21096
|
-
_programLayers.enable(
|
|
21163
|
+
_programLayers.enable( 19 );
|
|
21097
21164
|
if ( parameters.numMultiviewViews )
|
|
21098
|
-
_programLayers.enable(
|
|
21165
|
+
_programLayers.enable( 20 );
|
|
21099
21166
|
|
|
21100
21167
|
array.push( _programLayers.mask );
|
|
21101
21168
|
|
|
@@ -21571,6 +21638,7 @@ function ShadowUniformsCache() {
|
|
|
21571
21638
|
|
|
21572
21639
|
case 'DirectionalLight':
|
|
21573
21640
|
uniforms = {
|
|
21641
|
+
shadowIntensity: 1,
|
|
21574
21642
|
shadowBias: 0,
|
|
21575
21643
|
shadowNormalBias: 0,
|
|
21576
21644
|
shadowRadius: 1,
|
|
@@ -21580,6 +21648,7 @@ function ShadowUniformsCache() {
|
|
|
21580
21648
|
|
|
21581
21649
|
case 'SpotLight':
|
|
21582
21650
|
uniforms = {
|
|
21651
|
+
shadowIntensity: 1,
|
|
21583
21652
|
shadowBias: 0,
|
|
21584
21653
|
shadowNormalBias: 0,
|
|
21585
21654
|
shadowRadius: 1,
|
|
@@ -21589,6 +21658,7 @@ function ShadowUniformsCache() {
|
|
|
21589
21658
|
|
|
21590
21659
|
case 'PointLight':
|
|
21591
21660
|
uniforms = {
|
|
21661
|
+
shadowIntensity: 1,
|
|
21592
21662
|
shadowBias: 0,
|
|
21593
21663
|
shadowNormalBias: 0,
|
|
21594
21664
|
shadowRadius: 1,
|
|
@@ -21677,7 +21747,7 @@ function WebGLLights( extensions ) {
|
|
|
21677
21747
|
const matrix4 = new Matrix4();
|
|
21678
21748
|
const matrix42 = new Matrix4();
|
|
21679
21749
|
|
|
21680
|
-
function setup( lights
|
|
21750
|
+
function setup( lights ) {
|
|
21681
21751
|
|
|
21682
21752
|
let r = 0, g = 0, b = 0;
|
|
21683
21753
|
|
|
@@ -21700,9 +21770,6 @@ function WebGLLights( extensions ) {
|
|
|
21700
21770
|
// ordering : [shadow casting + map texturing, map texturing, shadow casting, none ]
|
|
21701
21771
|
lights.sort( shadowCastingAndTexturingLightsFirst );
|
|
21702
21772
|
|
|
21703
|
-
// artist-friendly light intensity scaling factor
|
|
21704
|
-
const scaleFactor = ( useLegacyLights === true ) ? Math.PI : 1;
|
|
21705
|
-
|
|
21706
21773
|
for ( let i = 0, l = lights.length; i < l; i ++ ) {
|
|
21707
21774
|
|
|
21708
21775
|
const light = lights[ i ];
|
|
@@ -21715,9 +21782,9 @@ function WebGLLights( extensions ) {
|
|
|
21715
21782
|
|
|
21716
21783
|
if ( light.isAmbientLight ) {
|
|
21717
21784
|
|
|
21718
|
-
r += color.r * intensity
|
|
21719
|
-
g += color.g * intensity
|
|
21720
|
-
b += color.b * intensity
|
|
21785
|
+
r += color.r * intensity;
|
|
21786
|
+
g += color.g * intensity;
|
|
21787
|
+
b += color.b * intensity;
|
|
21721
21788
|
|
|
21722
21789
|
} else if ( light.isLightProbe ) {
|
|
21723
21790
|
|
|
@@ -21733,7 +21800,7 @@ function WebGLLights( extensions ) {
|
|
|
21733
21800
|
|
|
21734
21801
|
const uniforms = cache.get( light );
|
|
21735
21802
|
|
|
21736
|
-
uniforms.color.copy( light.color ).multiplyScalar( light.intensity
|
|
21803
|
+
uniforms.color.copy( light.color ).multiplyScalar( light.intensity );
|
|
21737
21804
|
|
|
21738
21805
|
if ( light.castShadow ) {
|
|
21739
21806
|
|
|
@@ -21741,6 +21808,7 @@ function WebGLLights( extensions ) {
|
|
|
21741
21808
|
|
|
21742
21809
|
const shadowUniforms = shadowCache.get( light );
|
|
21743
21810
|
|
|
21811
|
+
shadowUniforms.shadowIntensity = shadow.intensity;
|
|
21744
21812
|
shadowUniforms.shadowBias = shadow.bias;
|
|
21745
21813
|
shadowUniforms.shadowNormalBias = shadow.normalBias;
|
|
21746
21814
|
shadowUniforms.shadowRadius = shadow.radius;
|
|
@@ -21764,7 +21832,7 @@ function WebGLLights( extensions ) {
|
|
|
21764
21832
|
|
|
21765
21833
|
uniforms.position.setFromMatrixPosition( light.matrixWorld );
|
|
21766
21834
|
|
|
21767
|
-
uniforms.color.copy( color ).multiplyScalar( intensity
|
|
21835
|
+
uniforms.color.copy( color ).multiplyScalar( intensity );
|
|
21768
21836
|
uniforms.distance = distance;
|
|
21769
21837
|
|
|
21770
21838
|
uniforms.coneCos = Math.cos( light.angle );
|
|
@@ -21794,6 +21862,7 @@ function WebGLLights( extensions ) {
|
|
|
21794
21862
|
|
|
21795
21863
|
const shadowUniforms = shadowCache.get( light );
|
|
21796
21864
|
|
|
21865
|
+
shadowUniforms.shadowIntensity = shadow.intensity;
|
|
21797
21866
|
shadowUniforms.shadowBias = shadow.bias;
|
|
21798
21867
|
shadowUniforms.shadowNormalBias = shadow.normalBias;
|
|
21799
21868
|
shadowUniforms.shadowRadius = shadow.radius;
|
|
@@ -21825,7 +21894,7 @@ function WebGLLights( extensions ) {
|
|
|
21825
21894
|
|
|
21826
21895
|
const uniforms = cache.get( light );
|
|
21827
21896
|
|
|
21828
|
-
uniforms.color.copy( light.color ).multiplyScalar( light.intensity
|
|
21897
|
+
uniforms.color.copy( light.color ).multiplyScalar( light.intensity );
|
|
21829
21898
|
uniforms.distance = light.distance;
|
|
21830
21899
|
uniforms.decay = light.decay;
|
|
21831
21900
|
|
|
@@ -21835,6 +21904,7 @@ function WebGLLights( extensions ) {
|
|
|
21835
21904
|
|
|
21836
21905
|
const shadowUniforms = shadowCache.get( light );
|
|
21837
21906
|
|
|
21907
|
+
shadowUniforms.shadowIntensity = shadow.intensity;
|
|
21838
21908
|
shadowUniforms.shadowBias = shadow.bias;
|
|
21839
21909
|
shadowUniforms.shadowNormalBias = shadow.normalBias;
|
|
21840
21910
|
shadowUniforms.shadowRadius = shadow.radius;
|
|
@@ -21858,8 +21928,8 @@ function WebGLLights( extensions ) {
|
|
|
21858
21928
|
|
|
21859
21929
|
const uniforms = cache.get( light );
|
|
21860
21930
|
|
|
21861
|
-
uniforms.skyColor.copy( light.color ).multiplyScalar( intensity
|
|
21862
|
-
uniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity
|
|
21931
|
+
uniforms.skyColor.copy( light.color ).multiplyScalar( intensity );
|
|
21932
|
+
uniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity );
|
|
21863
21933
|
|
|
21864
21934
|
state.hemi[ hemiLength ] = uniforms;
|
|
21865
21935
|
|
|
@@ -22060,9 +22130,9 @@ function WebGLRenderState( extensions ) {
|
|
|
22060
22130
|
|
|
22061
22131
|
}
|
|
22062
22132
|
|
|
22063
|
-
function setupLights(
|
|
22133
|
+
function setupLights() {
|
|
22064
22134
|
|
|
22065
|
-
lights.setup( lightsArray
|
|
22135
|
+
lights.setup( lightsArray );
|
|
22066
22136
|
|
|
22067
22137
|
}
|
|
22068
22138
|
|
|
@@ -23912,6 +23982,213 @@ function WebGLState( gl ) {
|
|
|
23912
23982
|
|
|
23913
23983
|
}
|
|
23914
23984
|
|
|
23985
|
+
function contain( texture, aspect ) {
|
|
23986
|
+
|
|
23987
|
+
const imageAspect = ( texture.image && texture.image.width ) ? texture.image.width / texture.image.height : 1;
|
|
23988
|
+
|
|
23989
|
+
if ( imageAspect > aspect ) {
|
|
23990
|
+
|
|
23991
|
+
texture.repeat.x = 1;
|
|
23992
|
+
texture.repeat.y = imageAspect / aspect;
|
|
23993
|
+
|
|
23994
|
+
texture.offset.x = 0;
|
|
23995
|
+
texture.offset.y = ( 1 - texture.repeat.y ) / 2;
|
|
23996
|
+
|
|
23997
|
+
} else {
|
|
23998
|
+
|
|
23999
|
+
texture.repeat.x = aspect / imageAspect;
|
|
24000
|
+
texture.repeat.y = 1;
|
|
24001
|
+
|
|
24002
|
+
texture.offset.x = ( 1 - texture.repeat.x ) / 2;
|
|
24003
|
+
texture.offset.y = 0;
|
|
24004
|
+
|
|
24005
|
+
}
|
|
24006
|
+
|
|
24007
|
+
return texture;
|
|
24008
|
+
|
|
24009
|
+
}
|
|
24010
|
+
|
|
24011
|
+
function cover( texture, aspect ) {
|
|
24012
|
+
|
|
24013
|
+
const imageAspect = ( texture.image && texture.image.width ) ? texture.image.width / texture.image.height : 1;
|
|
24014
|
+
|
|
24015
|
+
if ( imageAspect > aspect ) {
|
|
24016
|
+
|
|
24017
|
+
texture.repeat.x = aspect / imageAspect;
|
|
24018
|
+
texture.repeat.y = 1;
|
|
24019
|
+
|
|
24020
|
+
texture.offset.x = ( 1 - texture.repeat.x ) / 2;
|
|
24021
|
+
texture.offset.y = 0;
|
|
24022
|
+
|
|
24023
|
+
} else {
|
|
24024
|
+
|
|
24025
|
+
texture.repeat.x = 1;
|
|
24026
|
+
texture.repeat.y = imageAspect / aspect;
|
|
24027
|
+
|
|
24028
|
+
texture.offset.x = 0;
|
|
24029
|
+
texture.offset.y = ( 1 - texture.repeat.y ) / 2;
|
|
24030
|
+
|
|
24031
|
+
}
|
|
24032
|
+
|
|
24033
|
+
return texture;
|
|
24034
|
+
|
|
24035
|
+
}
|
|
24036
|
+
|
|
24037
|
+
function fill( texture ) {
|
|
24038
|
+
|
|
24039
|
+
texture.repeat.x = 1;
|
|
24040
|
+
texture.repeat.y = 1;
|
|
24041
|
+
|
|
24042
|
+
texture.offset.x = 0;
|
|
24043
|
+
texture.offset.y = 0;
|
|
24044
|
+
|
|
24045
|
+
return texture;
|
|
24046
|
+
|
|
24047
|
+
}
|
|
24048
|
+
|
|
24049
|
+
|
|
24050
|
+
|
|
24051
|
+
/**
|
|
24052
|
+
* Given the width, height, format, and type of a texture. Determines how many
|
|
24053
|
+
* bytes must be used to represent the texture.
|
|
24054
|
+
*/
|
|
24055
|
+
function getByteLength( width, height, format, type ) {
|
|
24056
|
+
|
|
24057
|
+
const typeByteLength = getTextureTypeByteLength( type );
|
|
24058
|
+
|
|
24059
|
+
switch ( format ) {
|
|
24060
|
+
|
|
24061
|
+
// https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml
|
|
24062
|
+
case AlphaFormat:
|
|
24063
|
+
return width * height;
|
|
24064
|
+
case LuminanceFormat:
|
|
24065
|
+
return width * height;
|
|
24066
|
+
case LuminanceAlphaFormat:
|
|
24067
|
+
return width * height * 2;
|
|
24068
|
+
case RedFormat:
|
|
24069
|
+
return ( ( width * height ) / typeByteLength.components ) * typeByteLength.byteLength;
|
|
24070
|
+
case RedIntegerFormat:
|
|
24071
|
+
return ( ( width * height ) / typeByteLength.components ) * typeByteLength.byteLength;
|
|
24072
|
+
case RGFormat:
|
|
24073
|
+
return ( ( width * height * 2 ) / typeByteLength.components ) * typeByteLength.byteLength;
|
|
24074
|
+
case RGIntegerFormat:
|
|
24075
|
+
return ( ( width * height * 2 ) / typeByteLength.components ) * typeByteLength.byteLength;
|
|
24076
|
+
case RGBFormat:
|
|
24077
|
+
return ( ( width * height * 3 ) / typeByteLength.components ) * typeByteLength.byteLength;
|
|
24078
|
+
case RGBAFormat:
|
|
24079
|
+
return ( ( width * height * 4 ) / typeByteLength.components ) * typeByteLength.byteLength;
|
|
24080
|
+
case RGBAIntegerFormat:
|
|
24081
|
+
return ( ( width * height * 4 ) / typeByteLength.components ) * typeByteLength.byteLength;
|
|
24082
|
+
|
|
24083
|
+
// https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_s3tc_srgb/
|
|
24084
|
+
case RGB_S3TC_DXT1_Format:
|
|
24085
|
+
case RGBA_S3TC_DXT1_Format:
|
|
24086
|
+
return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 8;
|
|
24087
|
+
case RGBA_S3TC_DXT3_Format:
|
|
24088
|
+
case RGBA_S3TC_DXT5_Format:
|
|
24089
|
+
return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
|
|
24090
|
+
|
|
24091
|
+
// https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_pvrtc/
|
|
24092
|
+
case RGB_PVRTC_2BPPV1_Format:
|
|
24093
|
+
case RGBA_PVRTC_2BPPV1_Format:
|
|
24094
|
+
return ( Math.max( width, 16 ) * Math.max( height, 8 ) ) / 4;
|
|
24095
|
+
case RGB_PVRTC_4BPPV1_Format:
|
|
24096
|
+
case RGBA_PVRTC_4BPPV1_Format:
|
|
24097
|
+
return ( Math.max( width, 8 ) * Math.max( height, 8 ) ) / 2;
|
|
24098
|
+
|
|
24099
|
+
// https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_etc/
|
|
24100
|
+
case RGB_ETC1_Format:
|
|
24101
|
+
case RGB_ETC2_Format:
|
|
24102
|
+
return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 8;
|
|
24103
|
+
case RGBA_ETC2_EAC_Format:
|
|
24104
|
+
return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
|
|
24105
|
+
|
|
24106
|
+
// https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_astc/
|
|
24107
|
+
case RGBA_ASTC_4x4_Format:
|
|
24108
|
+
return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
|
|
24109
|
+
case RGBA_ASTC_5x4_Format:
|
|
24110
|
+
return Math.floor( ( width + 4 ) / 5 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
|
|
24111
|
+
case RGBA_ASTC_5x5_Format:
|
|
24112
|
+
return Math.floor( ( width + 4 ) / 5 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
|
|
24113
|
+
case RGBA_ASTC_6x5_Format:
|
|
24114
|
+
return Math.floor( ( width + 5 ) / 6 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
|
|
24115
|
+
case RGBA_ASTC_6x6_Format:
|
|
24116
|
+
return Math.floor( ( width + 5 ) / 6 ) * Math.floor( ( height + 5 ) / 6 ) * 16;
|
|
24117
|
+
case RGBA_ASTC_8x5_Format:
|
|
24118
|
+
return Math.floor( ( width + 7 ) / 8 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
|
|
24119
|
+
case RGBA_ASTC_8x6_Format:
|
|
24120
|
+
return Math.floor( ( width + 7 ) / 8 ) * Math.floor( ( height + 5 ) / 6 ) * 16;
|
|
24121
|
+
case RGBA_ASTC_8x8_Format:
|
|
24122
|
+
return Math.floor( ( width + 7 ) / 8 ) * Math.floor( ( height + 7 ) / 8 ) * 16;
|
|
24123
|
+
case RGBA_ASTC_10x5_Format:
|
|
24124
|
+
return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
|
|
24125
|
+
case RGBA_ASTC_10x6_Format:
|
|
24126
|
+
return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 5 ) / 6 ) * 16;
|
|
24127
|
+
case RGBA_ASTC_10x8_Format:
|
|
24128
|
+
return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 7 ) / 8 ) * 16;
|
|
24129
|
+
case RGBA_ASTC_10x10_Format:
|
|
24130
|
+
return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 9 ) / 10 ) * 16;
|
|
24131
|
+
case RGBA_ASTC_12x10_Format:
|
|
24132
|
+
return Math.floor( ( width + 11 ) / 12 ) * Math.floor( ( height + 9 ) / 10 ) * 16;
|
|
24133
|
+
case RGBA_ASTC_12x12_Format:
|
|
24134
|
+
return Math.floor( ( width + 11 ) / 12 ) * Math.floor( ( height + 11 ) / 12 ) * 16;
|
|
24135
|
+
|
|
24136
|
+
// https://registry.khronos.org/webgl/extensions/EXT_texture_compression_bptc/
|
|
24137
|
+
case RGBA_BPTC_Format:
|
|
24138
|
+
case RGB_BPTC_SIGNED_Format:
|
|
24139
|
+
case RGB_BPTC_UNSIGNED_Format:
|
|
24140
|
+
return Math.ceil( width / 4 ) * Math.ceil( height / 4 ) * 16;
|
|
24141
|
+
|
|
24142
|
+
// https://registry.khronos.org/webgl/extensions/EXT_texture_compression_rgtc/
|
|
24143
|
+
case RED_RGTC1_Format:
|
|
24144
|
+
case SIGNED_RED_RGTC1_Format:
|
|
24145
|
+
return Math.ceil( width / 4 ) * Math.ceil( height / 4 ) * 8;
|
|
24146
|
+
case RED_GREEN_RGTC2_Format:
|
|
24147
|
+
case SIGNED_RED_GREEN_RGTC2_Format:
|
|
24148
|
+
return Math.ceil( width / 4 ) * Math.ceil( height / 4 ) * 16;
|
|
24149
|
+
|
|
24150
|
+
}
|
|
24151
|
+
|
|
24152
|
+
throw new Error(
|
|
24153
|
+
`Unable to determine texture byte length for ${format} format.`,
|
|
24154
|
+
);
|
|
24155
|
+
|
|
24156
|
+
}
|
|
24157
|
+
|
|
24158
|
+
function getTextureTypeByteLength( type ) {
|
|
24159
|
+
|
|
24160
|
+
switch ( type ) {
|
|
24161
|
+
|
|
24162
|
+
case UnsignedByteType:
|
|
24163
|
+
case ByteType:
|
|
24164
|
+
return { byteLength: 1, components: 1 };
|
|
24165
|
+
case UnsignedShortType:
|
|
24166
|
+
case ShortType:
|
|
24167
|
+
case HalfFloatType:
|
|
24168
|
+
return { byteLength: 2, components: 1 };
|
|
24169
|
+
case UnsignedShort4444Type:
|
|
24170
|
+
case UnsignedShort5551Type:
|
|
24171
|
+
return { byteLength: 2, components: 4 };
|
|
24172
|
+
case UnsignedIntType:
|
|
24173
|
+
case IntType:
|
|
24174
|
+
case FloatType:
|
|
24175
|
+
return { byteLength: 4, components: 1 };
|
|
24176
|
+
case UnsignedInt5999Type:
|
|
24177
|
+
return { byteLength: 4, components: 3 };
|
|
24178
|
+
|
|
24179
|
+
}
|
|
24180
|
+
|
|
24181
|
+
throw new Error( `Unknown texture type ${type}.` );
|
|
24182
|
+
|
|
24183
|
+
}
|
|
24184
|
+
|
|
24185
|
+
const TextureUtils = {
|
|
24186
|
+
contain,
|
|
24187
|
+
cover,
|
|
24188
|
+
fill,
|
|
24189
|
+
getByteLength
|
|
24190
|
+
};
|
|
24191
|
+
|
|
23915
24192
|
function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
|
|
23916
24193
|
|
|
23917
24194
|
const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
|
|
@@ -24109,6 +24386,48 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24109
24386
|
|
|
24110
24387
|
}
|
|
24111
24388
|
|
|
24389
|
+
function getInternalDepthFormat( useStencil, depthType ) {
|
|
24390
|
+
|
|
24391
|
+
let glInternalFormat;
|
|
24392
|
+
if ( useStencil ) {
|
|
24393
|
+
|
|
24394
|
+
if ( depthType === null || depthType === UnsignedIntType || depthType === UnsignedInt248Type ) {
|
|
24395
|
+
|
|
24396
|
+
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
24397
|
+
|
|
24398
|
+
} else if ( depthType === FloatType ) {
|
|
24399
|
+
|
|
24400
|
+
glInternalFormat = _gl.DEPTH32F_STENCIL8;
|
|
24401
|
+
|
|
24402
|
+
} else if ( depthType === UnsignedShortType ) {
|
|
24403
|
+
|
|
24404
|
+
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
24405
|
+
console.warn( 'DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.' );
|
|
24406
|
+
|
|
24407
|
+
}
|
|
24408
|
+
|
|
24409
|
+
} else {
|
|
24410
|
+
|
|
24411
|
+
if ( depthType === null || depthType === UnsignedIntType || depthType === UnsignedInt248Type ) {
|
|
24412
|
+
|
|
24413
|
+
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
24414
|
+
|
|
24415
|
+
} else if ( depthType === FloatType ) {
|
|
24416
|
+
|
|
24417
|
+
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
24418
|
+
|
|
24419
|
+
} else if ( depthType === UnsignedShortType ) {
|
|
24420
|
+
|
|
24421
|
+
glInternalFormat = _gl.DEPTH_COMPONENT16;
|
|
24422
|
+
|
|
24423
|
+
}
|
|
24424
|
+
|
|
24425
|
+
}
|
|
24426
|
+
|
|
24427
|
+
return glInternalFormat;
|
|
24428
|
+
|
|
24429
|
+
}
|
|
24430
|
+
|
|
24112
24431
|
function getMipLevels( texture, image ) {
|
|
24113
24432
|
|
|
24114
24433
|
if ( textureNeedsGenerateMipmaps( texture ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) {
|
|
@@ -24663,23 +24982,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24663
24982
|
|
|
24664
24983
|
if ( texture.isDepthTexture ) {
|
|
24665
24984
|
|
|
24666
|
-
|
|
24667
|
-
|
|
24668
|
-
glInternalFormat = _gl.DEPTH_COMPONENT16;
|
|
24669
|
-
|
|
24670
|
-
if ( texture.type === FloatType ) {
|
|
24671
|
-
|
|
24672
|
-
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
24673
|
-
|
|
24674
|
-
} else if ( texture.type === UnsignedIntType ) {
|
|
24675
|
-
|
|
24676
|
-
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
24677
|
-
|
|
24678
|
-
} else if ( texture.type === UnsignedInt248Type ) {
|
|
24679
|
-
|
|
24680
|
-
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
24681
|
-
|
|
24682
|
-
}
|
|
24985
|
+
glInternalFormat = getInternalDepthFormat( texture.format === DepthStencilFormat, texture.type );
|
|
24683
24986
|
|
|
24684
24987
|
//
|
|
24685
24988
|
|
|
@@ -24779,7 +25082,27 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24779
25082
|
|
|
24780
25083
|
if ( dataReady ) {
|
|
24781
25084
|
|
|
24782
|
-
|
|
25085
|
+
if ( texture.layerUpdates.size > 0 ) {
|
|
25086
|
+
|
|
25087
|
+
const layerByteLength = getByteLength( mipmap.width, mipmap.height, texture.format, texture.type );
|
|
25088
|
+
|
|
25089
|
+
for ( const layerIndex of texture.layerUpdates ) {
|
|
25090
|
+
|
|
25091
|
+
const layerData = mipmap.data.subarray(
|
|
25092
|
+
layerIndex * layerByteLength / mipmap.data.BYTES_PER_ELEMENT,
|
|
25093
|
+
( layerIndex + 1 ) * layerByteLength / mipmap.data.BYTES_PER_ELEMENT
|
|
25094
|
+
);
|
|
25095
|
+
state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, layerIndex, mipmap.width, mipmap.height, 1, glFormat, layerData, 0, 0 );
|
|
25096
|
+
|
|
25097
|
+
}
|
|
25098
|
+
|
|
25099
|
+
texture.clearLayerUpdates();
|
|
25100
|
+
|
|
25101
|
+
} else {
|
|
25102
|
+
|
|
25103
|
+
state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data, 0, 0 );
|
|
25104
|
+
|
|
25105
|
+
}
|
|
24783
25106
|
|
|
24784
25107
|
}
|
|
24785
25108
|
|
|
@@ -24885,7 +25208,27 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24885
25208
|
|
|
24886
25209
|
if ( dataReady ) {
|
|
24887
25210
|
|
|
24888
|
-
|
|
25211
|
+
if ( texture.layerUpdates.size > 0 ) {
|
|
25212
|
+
|
|
25213
|
+
const layerByteLength = getByteLength( image.width, image.height, texture.format, texture.type );
|
|
25214
|
+
|
|
25215
|
+
for ( const layerIndex of texture.layerUpdates ) {
|
|
25216
|
+
|
|
25217
|
+
const layerData = image.data.subarray(
|
|
25218
|
+
layerIndex * layerByteLength / image.data.BYTES_PER_ELEMENT,
|
|
25219
|
+
( layerIndex + 1 ) * layerByteLength / image.data.BYTES_PER_ELEMENT
|
|
25220
|
+
);
|
|
25221
|
+
state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, layerIndex, image.width, image.height, 1, glFormat, glType, layerData );
|
|
25222
|
+
|
|
25223
|
+
}
|
|
25224
|
+
|
|
25225
|
+
texture.clearLayerUpdates();
|
|
25226
|
+
|
|
25227
|
+
} else {
|
|
25228
|
+
|
|
25229
|
+
state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
|
|
25230
|
+
|
|
25231
|
+
}
|
|
24889
25232
|
|
|
24890
25233
|
}
|
|
24891
25234
|
|
|
@@ -25329,7 +25672,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
25329
25672
|
|
|
25330
25673
|
}
|
|
25331
25674
|
|
|
25332
|
-
|
|
25333
25675
|
// Setup storage for internal depth/stencil buffers and bind to correct framebuffer
|
|
25334
25676
|
function setupRenderBufferStorage( renderbuffer, renderTarget, isMultisample ) {
|
|
25335
25677
|
|
|
@@ -25389,66 +25731,30 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
25389
25731
|
|
|
25390
25732
|
} else if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {
|
|
25391
25733
|
|
|
25392
|
-
|
|
25393
|
-
|
|
25394
|
-
|
|
25395
|
-
|
|
25396
|
-
|
|
25397
|
-
|
|
25398
|
-
if ( depthTexture && depthTexture.isDepthTexture ) {
|
|
25399
|
-
|
|
25400
|
-
if ( depthTexture.type === FloatType ) {
|
|
25401
|
-
|
|
25402
|
-
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
25403
|
-
|
|
25404
|
-
} else if ( depthTexture.type === UnsignedIntType ) {
|
|
25405
|
-
|
|
25406
|
-
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
25407
|
-
|
|
25408
|
-
}
|
|
25409
|
-
|
|
25410
|
-
}
|
|
25411
|
-
|
|
25412
|
-
const samples = getRenderTargetSamples( renderTarget );
|
|
25413
|
-
|
|
25414
|
-
if ( useMultisampledRTT( renderTarget ) ) {
|
|
25415
|
-
|
|
25416
|
-
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
25417
|
-
|
|
25418
|
-
} else {
|
|
25419
|
-
|
|
25420
|
-
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
25421
|
-
|
|
25422
|
-
}
|
|
25423
|
-
|
|
25424
|
-
} else {
|
|
25425
|
-
|
|
25426
|
-
_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
25427
|
-
|
|
25428
|
-
}
|
|
25429
|
-
|
|
25430
|
-
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );
|
|
25431
|
-
|
|
25432
|
-
} else if ( renderTarget.depthBuffer && renderTarget.stencilBuffer ) {
|
|
25734
|
+
// retrieve the depth attachment types
|
|
25735
|
+
const depthTexture = renderTarget.depthTexture;
|
|
25736
|
+
const depthType = depthTexture && depthTexture.isDepthTexture ? depthTexture.type : null;
|
|
25737
|
+
const glInternalFormat = getInternalDepthFormat( renderTarget.stencilBuffer, depthType );
|
|
25738
|
+
const glAttachmentType = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
25433
25739
|
|
|
25740
|
+
// set up the attachment
|
|
25434
25741
|
const samples = getRenderTargetSamples( renderTarget );
|
|
25742
|
+
const isUseMultisampledRTT = useMultisampledRTT( renderTarget );
|
|
25743
|
+
if ( isUseMultisampledRTT ) {
|
|
25435
25744
|
|
|
25436
|
-
|
|
25745
|
+
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
25437
25746
|
|
|
25438
|
-
|
|
25747
|
+
} else if ( isMultisample ) {
|
|
25439
25748
|
|
|
25440
|
-
|
|
25441
|
-
|
|
25442
|
-
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height );
|
|
25749
|
+
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
25443
25750
|
|
|
25444
25751
|
} else {
|
|
25445
25752
|
|
|
25446
|
-
_gl.renderbufferStorage( _gl.RENDERBUFFER,
|
|
25753
|
+
_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
25447
25754
|
|
|
25448
25755
|
}
|
|
25449
25756
|
|
|
25450
|
-
|
|
25451
|
-
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );
|
|
25757
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, glAttachmentType, _gl.RENDERBUFFER, renderbuffer );
|
|
25452
25758
|
|
|
25453
25759
|
} else {
|
|
25454
25760
|
|
|
@@ -27359,7 +27665,7 @@ class WebXRDepthSensing {
|
|
|
27359
27665
|
|
|
27360
27666
|
}
|
|
27361
27667
|
|
|
27362
|
-
|
|
27668
|
+
getMesh( cameraXR ) {
|
|
27363
27669
|
|
|
27364
27670
|
if ( this.texture !== null ) {
|
|
27365
27671
|
|
|
@@ -27380,10 +27686,10 @@ class WebXRDepthSensing {
|
|
|
27380
27686
|
|
|
27381
27687
|
}
|
|
27382
27688
|
|
|
27383
|
-
renderer.render( this.mesh, cameraXR );
|
|
27384
|
-
|
|
27385
27689
|
}
|
|
27386
27690
|
|
|
27691
|
+
return this.mesh;
|
|
27692
|
+
|
|
27387
27693
|
}
|
|
27388
27694
|
|
|
27389
27695
|
reset() {
|
|
@@ -27393,6 +27699,12 @@ class WebXRDepthSensing {
|
|
|
27393
27699
|
|
|
27394
27700
|
}
|
|
27395
27701
|
|
|
27702
|
+
getDepthTexture() {
|
|
27703
|
+
|
|
27704
|
+
return this.texture;
|
|
27705
|
+
|
|
27706
|
+
}
|
|
27707
|
+
|
|
27396
27708
|
}
|
|
27397
27709
|
|
|
27398
27710
|
class WebXRManager extends EventDispatcher {
|
|
@@ -27815,6 +28127,12 @@ class WebXRManager extends EventDispatcher {
|
|
|
27815
28127
|
session.updateRenderState( { layers: layersCopy } );
|
|
27816
28128
|
};
|
|
27817
28129
|
|
|
28130
|
+
this.getDepthTexture = function () {
|
|
28131
|
+
|
|
28132
|
+
return depthSensing.getDepthTexture();
|
|
28133
|
+
|
|
28134
|
+
};
|
|
28135
|
+
|
|
27818
28136
|
function onInputSourcesChange( event ) {
|
|
27819
28137
|
|
|
27820
28138
|
// Notify disconnected
|
|
@@ -28107,6 +28425,12 @@ class WebXRManager extends EventDispatcher {
|
|
|
28107
28425
|
|
|
28108
28426
|
};
|
|
28109
28427
|
|
|
28428
|
+
this.getDepthSensingMesh = function () {
|
|
28429
|
+
|
|
28430
|
+
return depthSensing.getMesh( cameraXR );
|
|
28431
|
+
|
|
28432
|
+
};
|
|
28433
|
+
|
|
28110
28434
|
// Animation Loop
|
|
28111
28435
|
|
|
28112
28436
|
let onAnimationFrameCallback = null;
|
|
@@ -28232,8 +28556,6 @@ class WebXRManager extends EventDispatcher {
|
|
|
28232
28556
|
|
|
28233
28557
|
}
|
|
28234
28558
|
|
|
28235
|
-
depthSensing.render( renderer, cameraXR );
|
|
28236
|
-
|
|
28237
28559
|
if ( onAnimationFrameCallback ) onAnimationFrameCallback( time, frame );
|
|
28238
28560
|
|
|
28239
28561
|
if ( frame.detectedPlanes ) {
|
|
@@ -28508,11 +28830,7 @@ function WebGLMaterials( renderer, properties ) {
|
|
|
28508
28830
|
if ( material.lightMap ) {
|
|
28509
28831
|
|
|
28510
28832
|
uniforms.lightMap.value = material.lightMap;
|
|
28511
|
-
|
|
28512
|
-
// artist-friendly light intensity scaling factor
|
|
28513
|
-
const scaleFactor = ( renderer._useLegacyLights === true ) ? Math.PI : 1;
|
|
28514
|
-
|
|
28515
|
-
uniforms.lightMapIntensity.value = material.lightMapIntensity * scaleFactor;
|
|
28833
|
+
uniforms.lightMapIntensity.value = material.lightMapIntensity;
|
|
28516
28834
|
|
|
28517
28835
|
refreshTransformUniform( material.lightMap, uniforms.lightMapTransform );
|
|
28518
28836
|
|
|
@@ -29093,27 +29411,27 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
|
|
|
29093
29411
|
|
|
29094
29412
|
const info = getUniformSize( value );
|
|
29095
29413
|
|
|
29096
|
-
//
|
|
29097
|
-
const
|
|
29414
|
+
const chunkOffset = offset % chunkSize; // offset in the current chunk
|
|
29415
|
+
const chunkPadding = chunkOffset % info.boundary; // required padding to match boundary
|
|
29416
|
+
const chunkStart = chunkOffset + chunkPadding; // the start position in the current chunk for the data
|
|
29417
|
+
|
|
29418
|
+
offset += chunkPadding;
|
|
29098
29419
|
|
|
29099
29420
|
// Check for chunk overflow
|
|
29100
|
-
if (
|
|
29421
|
+
if ( chunkStart !== 0 && ( chunkSize - chunkStart ) < info.storage ) {
|
|
29101
29422
|
|
|
29102
29423
|
// Add padding and adjust offset
|
|
29103
|
-
offset += ( chunkSize -
|
|
29424
|
+
offset += ( chunkSize - chunkStart );
|
|
29104
29425
|
|
|
29105
29426
|
}
|
|
29106
29427
|
|
|
29107
29428
|
// the following two properties will be used for partial buffer updates
|
|
29108
|
-
|
|
29109
29429
|
uniform.__data = new Float32Array( info.storage / Float32Array.BYTES_PER_ELEMENT );
|
|
29110
29430
|
uniform.__offset = offset;
|
|
29111
29431
|
|
|
29112
|
-
|
|
29113
29432
|
// Update the global offset
|
|
29114
29433
|
offset += info.storage;
|
|
29115
29434
|
|
|
29116
|
-
|
|
29117
29435
|
}
|
|
29118
29436
|
|
|
29119
29437
|
}
|
|
@@ -29330,10 +29648,6 @@ class WebGLRenderer {
|
|
|
29330
29648
|
|
|
29331
29649
|
this._outputColorSpace = SRGBColorSpace;
|
|
29332
29650
|
|
|
29333
|
-
// physical lights
|
|
29334
|
-
|
|
29335
|
-
this._useLegacyLights = false;
|
|
29336
|
-
|
|
29337
29651
|
// tone mapping
|
|
29338
29652
|
|
|
29339
29653
|
this.toneMapping = NoToneMapping;
|
|
@@ -29389,8 +29703,12 @@ class WebGLRenderer {
|
|
|
29389
29703
|
|
|
29390
29704
|
const _vector3 = new Vector3();
|
|
29391
29705
|
|
|
29706
|
+
const _vector4 = new Vector4();
|
|
29707
|
+
|
|
29392
29708
|
const _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };
|
|
29393
29709
|
|
|
29710
|
+
let _renderBackground = false;
|
|
29711
|
+
|
|
29394
29712
|
function getTargetPixelRatio() {
|
|
29395
29713
|
|
|
29396
29714
|
return _currentRenderTarget === null ? _pixelRatio : 1;
|
|
@@ -30046,7 +30364,25 @@ class WebGLRenderer {
|
|
|
30046
30364
|
|
|
30047
30365
|
} else {
|
|
30048
30366
|
|
|
30049
|
-
|
|
30367
|
+
if ( ! extensions.get( 'WEBGL_multi_draw' ) ) {
|
|
30368
|
+
|
|
30369
|
+
const starts = object._multiDrawStarts;
|
|
30370
|
+
const counts = object._multiDrawCounts;
|
|
30371
|
+
const drawCount = object._multiDrawCount;
|
|
30372
|
+
const bytesPerElement = index ? attributes.get( index ).bytesPerElement : 1;
|
|
30373
|
+
const uniforms = properties.get( material ).currentProgram.getUniforms();
|
|
30374
|
+
for ( let i = 0; i < drawCount; i ++ ) {
|
|
30375
|
+
|
|
30376
|
+
uniforms.setValue( _gl, '_gl_DrawID', i );
|
|
30377
|
+
renderer.render( starts[ i ] / bytesPerElement, counts[ i ] );
|
|
30378
|
+
|
|
30379
|
+
}
|
|
30380
|
+
|
|
30381
|
+
} else {
|
|
30382
|
+
|
|
30383
|
+
renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
|
|
30384
|
+
|
|
30385
|
+
}
|
|
30050
30386
|
|
|
30051
30387
|
}
|
|
30052
30388
|
|
|
@@ -30140,7 +30476,7 @@ class WebGLRenderer {
|
|
|
30140
30476
|
|
|
30141
30477
|
}
|
|
30142
30478
|
|
|
30143
|
-
currentRenderState.setupLights(
|
|
30479
|
+
currentRenderState.setupLights();
|
|
30144
30480
|
|
|
30145
30481
|
// Only initialize materials in the new scene, not the targetScene.
|
|
30146
30482
|
|
|
@@ -30330,6 +30666,18 @@ class WebGLRenderer {
|
|
|
30330
30666
|
|
|
30331
30667
|
renderListStack.push( currentRenderList );
|
|
30332
30668
|
|
|
30669
|
+
if ( xr.enabled === true && xr.isPresenting === true ) {
|
|
30670
|
+
|
|
30671
|
+
const depthSensingMesh = _this.xr.getDepthSensingMesh();
|
|
30672
|
+
|
|
30673
|
+
if ( depthSensingMesh !== null ) {
|
|
30674
|
+
|
|
30675
|
+
projectObject( depthSensingMesh, camera, - Infinity, _this.sortObjects );
|
|
30676
|
+
|
|
30677
|
+
}
|
|
30678
|
+
|
|
30679
|
+
}
|
|
30680
|
+
|
|
30333
30681
|
projectObject( scene, camera, 0, _this.sortObjects );
|
|
30334
30682
|
|
|
30335
30683
|
currentRenderList.finish();
|
|
@@ -30340,8 +30688,8 @@ class WebGLRenderer {
|
|
|
30340
30688
|
|
|
30341
30689
|
}
|
|
30342
30690
|
|
|
30343
|
-
|
|
30344
|
-
if (
|
|
30691
|
+
_renderBackground = xr.enabled === false || xr.isPresenting === false || xr.hasDepthSensing() === false;
|
|
30692
|
+
if ( _renderBackground ) {
|
|
30345
30693
|
|
|
30346
30694
|
background.addToRenderList( currentRenderList, scene );
|
|
30347
30695
|
|
|
@@ -30368,7 +30716,7 @@ class WebGLRenderer {
|
|
|
30368
30716
|
const opaqueObjects = currentRenderList.opaque;
|
|
30369
30717
|
const transmissiveObjects = currentRenderList.transmissive;
|
|
30370
30718
|
|
|
30371
|
-
currentRenderState.setupLights(
|
|
30719
|
+
currentRenderState.setupLights();
|
|
30372
30720
|
|
|
30373
30721
|
if ( camera.isArrayCamera ) {
|
|
30374
30722
|
|
|
@@ -30386,7 +30734,7 @@ class WebGLRenderer {
|
|
|
30386
30734
|
|
|
30387
30735
|
}
|
|
30388
30736
|
|
|
30389
|
-
if (
|
|
30737
|
+
if ( _renderBackground ) background.render( scene );
|
|
30390
30738
|
|
|
30391
30739
|
if ( xr.enabled && xr.isMultiview ) {
|
|
30392
30740
|
|
|
@@ -30410,7 +30758,7 @@ class WebGLRenderer {
|
|
|
30410
30758
|
|
|
30411
30759
|
if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
|
|
30412
30760
|
|
|
30413
|
-
if (
|
|
30761
|
+
if ( _renderBackground ) background.render( scene );
|
|
30414
30762
|
|
|
30415
30763
|
renderScene( currentRenderList, scene, camera );
|
|
30416
30764
|
|
|
@@ -30507,7 +30855,7 @@ class WebGLRenderer {
|
|
|
30507
30855
|
|
|
30508
30856
|
if ( sortObjects ) {
|
|
30509
30857
|
|
|
30510
|
-
|
|
30858
|
+
_vector4.setFromMatrixPosition( object.matrixWorld )
|
|
30511
30859
|
.applyMatrix4( _projScreenMatrix );
|
|
30512
30860
|
|
|
30513
30861
|
}
|
|
@@ -30517,7 +30865,7 @@ class WebGLRenderer {
|
|
|
30517
30865
|
|
|
30518
30866
|
if ( material.visible ) {
|
|
30519
30867
|
|
|
30520
|
-
currentRenderList.push( object, geometry, material, groupOrder,
|
|
30868
|
+
currentRenderList.push( object, geometry, material, groupOrder, _vector4.z, null );
|
|
30521
30869
|
|
|
30522
30870
|
}
|
|
30523
30871
|
|
|
@@ -30535,16 +30883,16 @@ class WebGLRenderer {
|
|
|
30535
30883
|
if ( object.boundingSphere !== undefined ) {
|
|
30536
30884
|
|
|
30537
30885
|
if ( object.boundingSphere === null ) object.computeBoundingSphere();
|
|
30538
|
-
|
|
30886
|
+
_vector4.copy( object.boundingSphere.center );
|
|
30539
30887
|
|
|
30540
30888
|
} else {
|
|
30541
30889
|
|
|
30542
30890
|
if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
|
|
30543
|
-
|
|
30891
|
+
_vector4.copy( geometry.boundingSphere.center );
|
|
30544
30892
|
|
|
30545
30893
|
}
|
|
30546
30894
|
|
|
30547
|
-
|
|
30895
|
+
_vector4
|
|
30548
30896
|
.applyMatrix4( object.matrixWorld )
|
|
30549
30897
|
.applyMatrix4( _projScreenMatrix );
|
|
30550
30898
|
|
|
@@ -30561,7 +30909,7 @@ class WebGLRenderer {
|
|
|
30561
30909
|
|
|
30562
30910
|
if ( groupMaterial && groupMaterial.visible ) {
|
|
30563
30911
|
|
|
30564
|
-
currentRenderList.push( object, geometry, groupMaterial, groupOrder,
|
|
30912
|
+
currentRenderList.push( object, geometry, groupMaterial, groupOrder, _vector4.z, group );
|
|
30565
30913
|
|
|
30566
30914
|
}
|
|
30567
30915
|
|
|
@@ -30569,7 +30917,7 @@ class WebGLRenderer {
|
|
|
30569
30917
|
|
|
30570
30918
|
} else if ( material.visible ) {
|
|
30571
30919
|
|
|
30572
|
-
currentRenderList.push( object, geometry, material, groupOrder,
|
|
30920
|
+
currentRenderList.push( object, geometry, material, groupOrder, _vector4.z, null );
|
|
30573
30921
|
|
|
30574
30922
|
}
|
|
30575
30923
|
|
|
@@ -30634,7 +30982,8 @@ class WebGLRenderer {
|
|
|
30634
30982
|
samples: 4,
|
|
30635
30983
|
stencilBuffer: stencil,
|
|
30636
30984
|
resolveDepthBuffer: false,
|
|
30637
|
-
resolveStencilBuffer: false
|
|
30985
|
+
resolveStencilBuffer: false,
|
|
30986
|
+
colorSpace: ColorManagement.workingColorSpace,
|
|
30638
30987
|
} );
|
|
30639
30988
|
|
|
30640
30989
|
// debug
|
|
@@ -30665,6 +31014,8 @@ class WebGLRenderer {
|
|
|
30665
31014
|
|
|
30666
31015
|
_this.clear();
|
|
30667
31016
|
|
|
31017
|
+
if ( _renderBackground ) background.render( scene );
|
|
31018
|
+
|
|
30668
31019
|
// Turn off the features which can affect the frag color for opaque objects pass.
|
|
30669
31020
|
// Otherwise they are applied twice in opaque objects pass and transmission objects pass.
|
|
30670
31021
|
const currentToneMapping = _this.toneMapping;
|
|
@@ -30764,8 +31115,6 @@ class WebGLRenderer {
|
|
|
30764
31115
|
object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
|
|
30765
31116
|
object.normalMatrix.getNormalMatrix( object.modelViewMatrix );
|
|
30766
31117
|
|
|
30767
|
-
material.onBeforeRender( _this, scene, camera, geometry, object, group );
|
|
30768
|
-
|
|
30769
31118
|
if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) {
|
|
30770
31119
|
|
|
30771
31120
|
material.side = BackSide;
|
|
@@ -30840,8 +31189,6 @@ class WebGLRenderer {
|
|
|
30840
31189
|
|
|
30841
31190
|
parameters.uniforms = programCache.getUniforms( material );
|
|
30842
31191
|
|
|
30843
|
-
material.onBuild( object, parameters, _this );
|
|
30844
|
-
|
|
30845
31192
|
material.onBeforeCompile( parameters, _this );
|
|
30846
31193
|
|
|
30847
31194
|
program = programCache.acquireProgram( parameters, programCacheKey );
|
|
@@ -30920,6 +31267,7 @@ class WebGLRenderer {
|
|
|
30920
31267
|
|
|
30921
31268
|
materialProperties.outputColorSpace = parameters.outputColorSpace;
|
|
30922
31269
|
materialProperties.batching = parameters.batching;
|
|
31270
|
+
materialProperties.batchingColor = parameters.batchingColor;
|
|
30923
31271
|
materialProperties.instancing = parameters.instancing;
|
|
30924
31272
|
materialProperties.instancingColor = parameters.instancingColor;
|
|
30925
31273
|
materialProperties.instancingMorph = parameters.instancingMorph;
|
|
@@ -31012,6 +31360,14 @@ class WebGLRenderer {
|
|
|
31012
31360
|
|
|
31013
31361
|
needsProgramChange = true;
|
|
31014
31362
|
|
|
31363
|
+
} else if ( object.isBatchedMesh && materialProperties.batchingColor === true && object.colorTexture === null ) {
|
|
31364
|
+
|
|
31365
|
+
needsProgramChange = true;
|
|
31366
|
+
|
|
31367
|
+
} else if ( object.isBatchedMesh && materialProperties.batchingColor === false && object.colorTexture !== null ) {
|
|
31368
|
+
|
|
31369
|
+
needsProgramChange = true;
|
|
31370
|
+
|
|
31015
31371
|
} else if ( object.isInstancedMesh && materialProperties.instancing === false ) {
|
|
31016
31372
|
|
|
31017
31373
|
needsProgramChange = true;
|
|
@@ -31217,6 +31573,16 @@ class WebGLRenderer {
|
|
|
31217
31573
|
p_uniforms.setOptional( _gl, object, 'batchingTexture' );
|
|
31218
31574
|
p_uniforms.setValue( _gl, 'batchingTexture', object._matricesTexture, textures );
|
|
31219
31575
|
|
|
31576
|
+
p_uniforms.setOptional( _gl, object, 'batchingIdTexture' );
|
|
31577
|
+
p_uniforms.setValue( _gl, 'batchingIdTexture', object._indirectTexture, textures );
|
|
31578
|
+
|
|
31579
|
+
p_uniforms.setOptional( _gl, object, 'batchingColorTexture' );
|
|
31580
|
+
if ( object._colorsTexture !== null ) {
|
|
31581
|
+
|
|
31582
|
+
p_uniforms.setValue( _gl, 'batchingColorTexture', object._colorsTexture, textures );
|
|
31583
|
+
|
|
31584
|
+
}
|
|
31585
|
+
|
|
31220
31586
|
}
|
|
31221
31587
|
|
|
31222
31588
|
const morphAttributes = geometry.morphAttributes;
|
|
@@ -31612,24 +31978,159 @@ class WebGLRenderer {
|
|
|
31612
31978
|
|
|
31613
31979
|
};
|
|
31614
31980
|
|
|
31615
|
-
this.
|
|
31981
|
+
this.readRenderTargetPixelsAsync = async function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {
|
|
31982
|
+
|
|
31983
|
+
if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
|
|
31984
|
+
|
|
31985
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );
|
|
31986
|
+
|
|
31987
|
+
}
|
|
31988
|
+
|
|
31989
|
+
let framebuffer = properties.get( renderTarget ).__webglFramebuffer;
|
|
31990
|
+
if ( renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined ) {
|
|
31991
|
+
|
|
31992
|
+
framebuffer = framebuffer[ activeCubeFaceIndex ];
|
|
31993
|
+
|
|
31994
|
+
}
|
|
31995
|
+
|
|
31996
|
+
if ( framebuffer ) {
|
|
31997
|
+
|
|
31998
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
31999
|
+
|
|
32000
|
+
try {
|
|
32001
|
+
|
|
32002
|
+
const texture = renderTarget.texture;
|
|
32003
|
+
const textureFormat = texture.format;
|
|
32004
|
+
const textureType = texture.type;
|
|
32005
|
+
|
|
32006
|
+
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
32007
|
+
|
|
32008
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
|
|
32009
|
+
|
|
32010
|
+
}
|
|
32011
|
+
|
|
32012
|
+
if ( ! capabilities.textureTypeReadable( textureType ) ) {
|
|
32013
|
+
|
|
32014
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.' );
|
|
32015
|
+
|
|
32016
|
+
}
|
|
32017
|
+
|
|
32018
|
+
// the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
|
|
32019
|
+
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
|
|
32020
|
+
|
|
32021
|
+
const glBuffer = _gl.createBuffer();
|
|
32022
|
+
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
32023
|
+
_gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
|
|
32024
|
+
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
|
|
32025
|
+
_gl.flush();
|
|
32026
|
+
|
|
32027
|
+
// check if the commands have finished every 8 ms
|
|
32028
|
+
const sync = _gl.fenceSync( _gl.SYNC_GPU_COMMANDS_COMPLETE, 0 );
|
|
32029
|
+
await probeAsync( _gl, sync, 4 );
|
|
32030
|
+
|
|
32031
|
+
try {
|
|
32032
|
+
|
|
32033
|
+
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
32034
|
+
_gl.getBufferSubData( _gl.PIXEL_PACK_BUFFER, 0, buffer );
|
|
32035
|
+
|
|
32036
|
+
} finally {
|
|
32037
|
+
|
|
32038
|
+
_gl.deleteBuffer( glBuffer );
|
|
32039
|
+
_gl.deleteSync( sync );
|
|
32040
|
+
|
|
32041
|
+
}
|
|
32042
|
+
|
|
32043
|
+
return buffer;
|
|
32044
|
+
|
|
32045
|
+
}
|
|
32046
|
+
|
|
32047
|
+
} finally {
|
|
32048
|
+
|
|
32049
|
+
// restore framebuffer of current render target if necessary
|
|
32050
|
+
|
|
32051
|
+
const framebuffer = ( _currentRenderTarget !== null ) ? properties.get( _currentRenderTarget ).__webglFramebuffer : null;
|
|
32052
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
32053
|
+
|
|
32054
|
+
}
|
|
32055
|
+
|
|
32056
|
+
}
|
|
32057
|
+
|
|
32058
|
+
};
|
|
32059
|
+
|
|
32060
|
+
this.copyFramebufferToTexture = function ( texture, position = null, level = 0 ) {
|
|
32061
|
+
|
|
32062
|
+
// support previous signature with position first
|
|
32063
|
+
if ( texture.isTexture !== true ) {
|
|
32064
|
+
|
|
32065
|
+
// @deprecated, r165
|
|
32066
|
+
warnOnce( 'WebGLRenderer: copyFramebufferToTexture function signature has changed.' );
|
|
32067
|
+
|
|
32068
|
+
position = arguments[ 0 ] || null;
|
|
32069
|
+
texture = arguments[ 1 ];
|
|
32070
|
+
|
|
32071
|
+
}
|
|
31616
32072
|
|
|
31617
32073
|
const levelScale = Math.pow( 2, - level );
|
|
31618
32074
|
const width = Math.floor( texture.image.width * levelScale );
|
|
31619
32075
|
const height = Math.floor( texture.image.height * levelScale );
|
|
31620
32076
|
|
|
32077
|
+
const x = position !== null ? position.x : 0;
|
|
32078
|
+
const y = position !== null ? position.y : 0;
|
|
32079
|
+
|
|
31621
32080
|
textures.setTexture2D( texture, 0 );
|
|
31622
32081
|
|
|
31623
|
-
_gl.copyTexSubImage2D( _gl.TEXTURE_2D, level, 0, 0,
|
|
32082
|
+
_gl.copyTexSubImage2D( _gl.TEXTURE_2D, level, 0, 0, x, y, width, height );
|
|
31624
32083
|
|
|
31625
32084
|
state.unbindTexture();
|
|
31626
32085
|
|
|
31627
32086
|
};
|
|
31628
32087
|
|
|
31629
|
-
this.copyTextureToTexture = function (
|
|
32088
|
+
this.copyTextureToTexture = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
|
|
32089
|
+
|
|
32090
|
+
// support previous signature with dstPosition first
|
|
32091
|
+
if ( srcTexture.isTexture !== true ) {
|
|
32092
|
+
|
|
32093
|
+
// @deprecated, r165
|
|
32094
|
+
warnOnce( 'WebGLRenderer: copyTextureToTexture function signature has changed.' );
|
|
32095
|
+
|
|
32096
|
+
dstPosition = arguments[ 0 ] || null;
|
|
32097
|
+
srcTexture = arguments[ 1 ];
|
|
32098
|
+
dstTexture = arguments[ 2 ];
|
|
32099
|
+
level = arguments[ 3 ] || 0;
|
|
32100
|
+
srcRegion = null;
|
|
32101
|
+
|
|
32102
|
+
}
|
|
32103
|
+
|
|
32104
|
+
let width, height, minX, minY;
|
|
32105
|
+
let dstX, dstY;
|
|
32106
|
+
if ( srcRegion !== null ) {
|
|
32107
|
+
|
|
32108
|
+
width = srcRegion.max.x - srcRegion.min.x;
|
|
32109
|
+
height = srcRegion.max.y - srcRegion.min.y;
|
|
32110
|
+
minX = srcRegion.min.x;
|
|
32111
|
+
minY = srcRegion.min.y;
|
|
32112
|
+
|
|
32113
|
+
} else {
|
|
32114
|
+
|
|
32115
|
+
width = srcTexture.image.width;
|
|
32116
|
+
height = srcTexture.image.height;
|
|
32117
|
+
minX = 0;
|
|
32118
|
+
minY = 0;
|
|
32119
|
+
|
|
32120
|
+
}
|
|
32121
|
+
|
|
32122
|
+
if ( dstPosition !== null ) {
|
|
32123
|
+
|
|
32124
|
+
dstX = dstPosition.x;
|
|
32125
|
+
dstY = dstPosition.y;
|
|
32126
|
+
|
|
32127
|
+
} else {
|
|
32128
|
+
|
|
32129
|
+
dstX = 0;
|
|
32130
|
+
dstY = 0;
|
|
32131
|
+
|
|
32132
|
+
}
|
|
31630
32133
|
|
|
31631
|
-
const width = srcTexture.image.width;
|
|
31632
|
-
const height = srcTexture.image.height;
|
|
31633
32134
|
const glFormat = utils.convert( dstTexture.format );
|
|
31634
32135
|
const glType = utils.convert( dstTexture.type );
|
|
31635
32136
|
|
|
@@ -31641,24 +32142,43 @@ class WebGLRenderer {
|
|
|
31641
32142
|
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
31642
32143
|
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
31643
32144
|
|
|
32145
|
+
const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
|
|
32146
|
+
const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
|
|
32147
|
+
const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
|
|
32148
|
+
const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
|
|
32149
|
+
const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
|
|
32150
|
+
|
|
32151
|
+
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
32152
|
+
|
|
32153
|
+
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
|
|
32154
|
+
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
|
|
32155
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
|
|
32156
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
|
|
32157
|
+
|
|
31644
32158
|
if ( srcTexture.isDataTexture ) {
|
|
31645
32159
|
|
|
31646
|
-
_gl.texSubImage2D( _gl.TEXTURE_2D, level,
|
|
32160
|
+
_gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image.data );
|
|
31647
32161
|
|
|
31648
32162
|
} else {
|
|
31649
32163
|
|
|
31650
32164
|
if ( srcTexture.isCompressedTexture ) {
|
|
31651
32165
|
|
|
31652
|
-
_gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level,
|
|
32166
|
+
_gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, image.width, image.height, glFormat, image.data );
|
|
31653
32167
|
|
|
31654
32168
|
} else {
|
|
31655
32169
|
|
|
31656
|
-
_gl.texSubImage2D( _gl.TEXTURE_2D, level,
|
|
32170
|
+
_gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image );
|
|
31657
32171
|
|
|
31658
32172
|
}
|
|
31659
32173
|
|
|
31660
32174
|
}
|
|
31661
32175
|
|
|
32176
|
+
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
|
|
32177
|
+
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
|
|
32178
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
|
|
32179
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
|
|
32180
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
|
|
32181
|
+
|
|
31662
32182
|
// Generate mipmaps only when copying level 0
|
|
31663
32183
|
if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );
|
|
31664
32184
|
|
|
@@ -31666,11 +32186,59 @@ class WebGLRenderer {
|
|
|
31666
32186
|
|
|
31667
32187
|
};
|
|
31668
32188
|
|
|
31669
|
-
this.copyTextureToTexture3D = function (
|
|
32189
|
+
this.copyTextureToTexture3D = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
|
|
32190
|
+
|
|
32191
|
+
// support previous signature with source box first
|
|
32192
|
+
if ( srcTexture.isTexture !== true ) {
|
|
32193
|
+
|
|
32194
|
+
// @deprecated, r165
|
|
32195
|
+
warnOnce( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
|
|
32196
|
+
|
|
32197
|
+
srcRegion = arguments[ 0 ] || null;
|
|
32198
|
+
dstPosition = arguments[ 1 ] || null;
|
|
32199
|
+
srcTexture = arguments[ 2 ];
|
|
32200
|
+
dstTexture = arguments[ 3 ];
|
|
32201
|
+
level = arguments[ 4 ] || 0;
|
|
32202
|
+
|
|
32203
|
+
}
|
|
32204
|
+
|
|
32205
|
+
let width, height, depth, minX, minY, minZ;
|
|
32206
|
+
let dstX, dstY, dstZ;
|
|
32207
|
+
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
32208
|
+
if ( srcRegion !== null ) {
|
|
32209
|
+
|
|
32210
|
+
width = srcRegion.max.x - srcRegion.min.x;
|
|
32211
|
+
height = srcRegion.max.y - srcRegion.min.y;
|
|
32212
|
+
depth = srcRegion.max.z - srcRegion.min.z;
|
|
32213
|
+
minX = srcRegion.min.x;
|
|
32214
|
+
minY = srcRegion.min.y;
|
|
32215
|
+
minZ = srcRegion.min.z;
|
|
32216
|
+
|
|
32217
|
+
} else {
|
|
32218
|
+
|
|
32219
|
+
width = image.width;
|
|
32220
|
+
height = image.height;
|
|
32221
|
+
depth = image.depth;
|
|
32222
|
+
minX = 0;
|
|
32223
|
+
minY = 0;
|
|
32224
|
+
minZ = 0;
|
|
32225
|
+
|
|
32226
|
+
}
|
|
32227
|
+
|
|
32228
|
+
if ( dstPosition !== null ) {
|
|
32229
|
+
|
|
32230
|
+
dstX = dstPosition.x;
|
|
32231
|
+
dstY = dstPosition.y;
|
|
32232
|
+
dstZ = dstPosition.z;
|
|
32233
|
+
|
|
32234
|
+
} else {
|
|
32235
|
+
|
|
32236
|
+
dstX = 0;
|
|
32237
|
+
dstY = 0;
|
|
32238
|
+
dstZ = 0;
|
|
32239
|
+
|
|
32240
|
+
}
|
|
31670
32241
|
|
|
31671
|
-
const width = sourceBox.max.x - sourceBox.min.x;
|
|
31672
|
-
const height = sourceBox.max.y - sourceBox.min.y;
|
|
31673
|
-
const depth = sourceBox.max.z - sourceBox.min.z;
|
|
31674
32242
|
const glFormat = utils.convert( dstTexture.format );
|
|
31675
32243
|
const glType = utils.convert( dstTexture.type );
|
|
31676
32244
|
let glTarget;
|
|
@@ -31696,43 +32264,41 @@ class WebGLRenderer {
|
|
|
31696
32264
|
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
31697
32265
|
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
31698
32266
|
|
|
31699
|
-
const
|
|
31700
|
-
const
|
|
31701
|
-
const
|
|
31702
|
-
const
|
|
31703
|
-
const
|
|
31704
|
-
|
|
31705
|
-
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
32267
|
+
const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
|
|
32268
|
+
const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
|
|
32269
|
+
const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
|
|
32270
|
+
const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
|
|
32271
|
+
const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
|
|
31706
32272
|
|
|
31707
32273
|
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
|
|
31708
32274
|
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
|
|
31709
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS,
|
|
31710
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS,
|
|
31711
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES,
|
|
32275
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
|
|
32276
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
|
|
32277
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, minZ );
|
|
31712
32278
|
|
|
31713
32279
|
if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
|
|
31714
32280
|
|
|
31715
|
-
_gl.texSubImage3D( glTarget, level,
|
|
32281
|
+
_gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image.data );
|
|
31716
32282
|
|
|
31717
32283
|
} else {
|
|
31718
32284
|
|
|
31719
32285
|
if ( dstTexture.isCompressedArrayTexture ) {
|
|
31720
32286
|
|
|
31721
|
-
_gl.compressedTexSubImage3D( glTarget, level,
|
|
32287
|
+
_gl.compressedTexSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, image.data );
|
|
31722
32288
|
|
|
31723
32289
|
} else {
|
|
31724
32290
|
|
|
31725
|
-
_gl.texSubImage3D( glTarget, level,
|
|
32291
|
+
_gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image );
|
|
31726
32292
|
|
|
31727
32293
|
}
|
|
31728
32294
|
|
|
31729
32295
|
}
|
|
31730
32296
|
|
|
31731
|
-
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH,
|
|
31732
|
-
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT,
|
|
31733
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS,
|
|
31734
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS,
|
|
31735
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES,
|
|
32297
|
+
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
|
|
32298
|
+
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
|
|
32299
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
|
|
32300
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
|
|
32301
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
|
|
31736
32302
|
|
|
31737
32303
|
// Generate mipmaps only when copying level 0
|
|
31738
32304
|
if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( glTarget );
|
|
@@ -31741,6 +32307,16 @@ class WebGLRenderer {
|
|
|
31741
32307
|
|
|
31742
32308
|
};
|
|
31743
32309
|
|
|
32310
|
+
this.initRenderTarget = function ( target ) {
|
|
32311
|
+
|
|
32312
|
+
if ( properties.get( target ).__webglFramebuffer === undefined ) {
|
|
32313
|
+
|
|
32314
|
+
textures.setupRenderTarget( target );
|
|
32315
|
+
|
|
32316
|
+
}
|
|
32317
|
+
|
|
32318
|
+
};
|
|
32319
|
+
|
|
31744
32320
|
this.initTexture = function ( texture ) {
|
|
31745
32321
|
|
|
31746
32322
|
if ( texture.isCubeTexture ) {
|
|
@@ -31806,20 +32382,6 @@ class WebGLRenderer {
|
|
|
31806
32382
|
|
|
31807
32383
|
}
|
|
31808
32384
|
|
|
31809
|
-
get useLegacyLights() { // @deprecated, r155
|
|
31810
|
-
|
|
31811
|
-
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.' );
|
|
31812
|
-
return this._useLegacyLights;
|
|
31813
|
-
|
|
31814
|
-
}
|
|
31815
|
-
|
|
31816
|
-
set useLegacyLights( value ) { // @deprecated, r155
|
|
31817
|
-
|
|
31818
|
-
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.' );
|
|
31819
|
-
this._useLegacyLights = value;
|
|
31820
|
-
|
|
31821
|
-
}
|
|
31822
|
-
|
|
31823
32385
|
}
|
|
31824
32386
|
|
|
31825
32387
|
class FogExp2 {
|
|
@@ -33680,7 +34242,7 @@ class InstancedMesh extends Mesh {
|
|
|
33680
34242
|
|
|
33681
34243
|
if ( this.instanceColor === null ) {
|
|
33682
34244
|
|
|
33683
|
-
this.instanceColor = new InstancedBufferAttribute( new Float32Array( this.instanceMatrix.count * 3 ), 3 );
|
|
34245
|
+
this.instanceColor = new InstancedBufferAttribute( new Float32Array( this.instanceMatrix.count * 3 ).fill( 1 ), 3 );
|
|
33684
34246
|
|
|
33685
34247
|
}
|
|
33686
34248
|
|
|
@@ -33769,7 +34331,7 @@ class MultiDrawRenderList {
|
|
|
33769
34331
|
|
|
33770
34332
|
}
|
|
33771
34333
|
|
|
33772
|
-
push( drawRange, z ) {
|
|
34334
|
+
push( drawRange, z, index ) {
|
|
33773
34335
|
|
|
33774
34336
|
const pool = this.pool;
|
|
33775
34337
|
const list = this.list;
|
|
@@ -33780,6 +34342,7 @@ class MultiDrawRenderList {
|
|
|
33780
34342
|
start: - 1,
|
|
33781
34343
|
count: - 1,
|
|
33782
34344
|
z: - 1,
|
|
34345
|
+
index: - 1,
|
|
33783
34346
|
|
|
33784
34347
|
} );
|
|
33785
34348
|
|
|
@@ -33792,6 +34355,7 @@ class MultiDrawRenderList {
|
|
|
33792
34355
|
item.start = drawRange.start;
|
|
33793
34356
|
item.count = drawRange.count;
|
|
33794
34357
|
item.z = z;
|
|
34358
|
+
item.index = index;
|
|
33795
34359
|
|
|
33796
34360
|
}
|
|
33797
34361
|
|
|
@@ -33804,15 +34368,17 @@ class MultiDrawRenderList {
|
|
|
33804
34368
|
|
|
33805
34369
|
}
|
|
33806
34370
|
|
|
33807
|
-
const ID_ATTR_NAME = 'batchId';
|
|
33808
34371
|
const _matrix$1 = /*@__PURE__*/ new Matrix4();
|
|
33809
34372
|
const _invMatrixWorld = /*@__PURE__*/ new Matrix4();
|
|
33810
34373
|
const _identityMatrix = /*@__PURE__*/ new Matrix4();
|
|
34374
|
+
const _whiteColor = /*@__PURE__*/ new Color( 1, 1, 1 );
|
|
33811
34375
|
const _projScreenMatrix$2 = /*@__PURE__*/ new Matrix4();
|
|
33812
34376
|
const _frustum = /*@__PURE__*/ new Frustum();
|
|
33813
34377
|
const _box$1 = /*@__PURE__*/ new Box3();
|
|
33814
34378
|
const _sphere$2 = /*@__PURE__*/ new Sphere();
|
|
33815
34379
|
const _vector$5 = /*@__PURE__*/ new Vector3();
|
|
34380
|
+
const _forward = /*@__PURE__*/ new Vector3();
|
|
34381
|
+
const _temp = /*@__PURE__*/ new Vector3();
|
|
33816
34382
|
const _renderList = /*@__PURE__*/ new MultiDrawRenderList();
|
|
33817
34383
|
const _mesh = /*@__PURE__*/ new Mesh();
|
|
33818
34384
|
const _batchIntersects = [];
|
|
@@ -33856,13 +34422,13 @@ function copyAttributeData( src, target, targetOffset = 0 ) {
|
|
|
33856
34422
|
|
|
33857
34423
|
class BatchedMesh extends Mesh {
|
|
33858
34424
|
|
|
33859
|
-
get
|
|
34425
|
+
get maxInstanceCount() {
|
|
33860
34426
|
|
|
33861
|
-
return this.
|
|
34427
|
+
return this._maxInstanceCount;
|
|
33862
34428
|
|
|
33863
34429
|
}
|
|
33864
34430
|
|
|
33865
|
-
constructor(
|
|
34431
|
+
constructor( maxInstanceCount, maxVertexCount, maxIndexCount = maxVertexCount * 2, material ) {
|
|
33866
34432
|
|
|
33867
34433
|
super( new BufferGeometry(), material );
|
|
33868
34434
|
|
|
@@ -33873,29 +34439,33 @@ class BatchedMesh extends Mesh {
|
|
|
33873
34439
|
this.boundingSphere = null;
|
|
33874
34440
|
this.customSort = null;
|
|
33875
34441
|
|
|
34442
|
+
// stores visible, active, and geometry id per object
|
|
34443
|
+
this._drawInfo = [];
|
|
34444
|
+
|
|
34445
|
+
// geometry information
|
|
33876
34446
|
this._drawRanges = [];
|
|
33877
34447
|
this._reservedRanges = [];
|
|
33878
|
-
|
|
33879
|
-
this._visibility = [];
|
|
33880
|
-
this._active = [];
|
|
33881
34448
|
this._bounds = [];
|
|
33882
34449
|
|
|
33883
|
-
this.
|
|
34450
|
+
this._maxInstanceCount = maxInstanceCount;
|
|
33884
34451
|
this._maxVertexCount = maxVertexCount;
|
|
33885
34452
|
this._maxIndexCount = maxIndexCount;
|
|
33886
34453
|
|
|
33887
34454
|
this._geometryInitialized = false;
|
|
33888
34455
|
this._geometryCount = 0;
|
|
33889
|
-
this._multiDrawCounts = new Int32Array(
|
|
33890
|
-
this._multiDrawStarts = new Int32Array(
|
|
34456
|
+
this._multiDrawCounts = new Int32Array( maxInstanceCount );
|
|
34457
|
+
this._multiDrawStarts = new Int32Array( maxInstanceCount );
|
|
33891
34458
|
this._multiDrawCount = 0;
|
|
33892
34459
|
this._multiDrawInstances = null;
|
|
33893
34460
|
this._visibilityChanged = true;
|
|
33894
34461
|
|
|
33895
34462
|
// Local matrix per geometry by using data texture
|
|
33896
34463
|
this._matricesTexture = null;
|
|
34464
|
+
this._indirectTexture = null;
|
|
34465
|
+
this._colorsTexture = null;
|
|
33897
34466
|
|
|
33898
34467
|
this._initMatricesTexture();
|
|
34468
|
+
this._initIndirectTexture();
|
|
33899
34469
|
|
|
33900
34470
|
}
|
|
33901
34471
|
|
|
@@ -33908,7 +34478,7 @@ class BatchedMesh extends Mesh {
|
|
|
33908
34478
|
// 32x32 pixel texture max 256 matrices * 4 pixels = (32 * 32)
|
|
33909
34479
|
// 64x64 pixel texture max 1024 matrices * 4 pixels = (64 * 64)
|
|
33910
34480
|
|
|
33911
|
-
let size = Math.sqrt( this.
|
|
34481
|
+
let size = Math.sqrt( this._maxInstanceCount * 4 ); // 4 pixels needed for 1 matrix
|
|
33912
34482
|
size = Math.ceil( size / 4 ) * 4;
|
|
33913
34483
|
size = Math.max( size, 4 );
|
|
33914
34484
|
|
|
@@ -33919,11 +34489,36 @@ class BatchedMesh extends Mesh {
|
|
|
33919
34489
|
|
|
33920
34490
|
}
|
|
33921
34491
|
|
|
34492
|
+
_initIndirectTexture() {
|
|
34493
|
+
|
|
34494
|
+
let size = Math.sqrt( this._maxInstanceCount );
|
|
34495
|
+
size = Math.ceil( size );
|
|
34496
|
+
|
|
34497
|
+
const indirectArray = new Uint32Array( size * size );
|
|
34498
|
+
const indirectTexture = new DataTexture( indirectArray, size, size, RedIntegerFormat, UnsignedIntType );
|
|
34499
|
+
|
|
34500
|
+
this._indirectTexture = indirectTexture;
|
|
34501
|
+
|
|
34502
|
+
}
|
|
34503
|
+
|
|
34504
|
+
_initColorsTexture() {
|
|
34505
|
+
|
|
34506
|
+
let size = Math.sqrt( this._maxIndexCount );
|
|
34507
|
+
size = Math.ceil( size );
|
|
34508
|
+
|
|
34509
|
+
// 4 floats per RGBA pixel initialized to white
|
|
34510
|
+
const colorsArray = new Float32Array( size * size * 4 ).fill( 1 );
|
|
34511
|
+
const colorsTexture = new DataTexture( colorsArray, size, size, RGBAFormat, FloatType );
|
|
34512
|
+
colorsTexture.colorSpace = ColorManagement.workingColorSpace;
|
|
34513
|
+
|
|
34514
|
+
this._colorsTexture = colorsTexture;
|
|
34515
|
+
|
|
34516
|
+
}
|
|
34517
|
+
|
|
33922
34518
|
_initializeGeometry( reference ) {
|
|
33923
34519
|
|
|
33924
34520
|
const geometry = this.geometry;
|
|
33925
34521
|
const maxVertexCount = this._maxVertexCount;
|
|
33926
|
-
const maxGeometryCount = this._maxGeometryCount;
|
|
33927
34522
|
const maxIndexCount = this._maxIndexCount;
|
|
33928
34523
|
if ( this._geometryInitialized === false ) {
|
|
33929
34524
|
|
|
@@ -33941,7 +34536,8 @@ class BatchedMesh extends Mesh {
|
|
|
33941
34536
|
|
|
33942
34537
|
if ( reference.getIndex() !== null ) {
|
|
33943
34538
|
|
|
33944
|
-
|
|
34539
|
+
// Reserve last u16 index for primitive restart.
|
|
34540
|
+
const indexArray = maxVertexCount > 65535
|
|
33945
34541
|
? new Uint32Array( maxIndexCount )
|
|
33946
34542
|
: new Uint16Array( maxIndexCount );
|
|
33947
34543
|
|
|
@@ -33949,11 +34545,6 @@ class BatchedMesh extends Mesh {
|
|
|
33949
34545
|
|
|
33950
34546
|
}
|
|
33951
34547
|
|
|
33952
|
-
const idArray = maxGeometryCount > 65536
|
|
33953
|
-
? new Uint32Array( maxVertexCount )
|
|
33954
|
-
: new Uint16Array( maxVertexCount );
|
|
33955
|
-
geometry.setAttribute( ID_ATTR_NAME, new BufferAttribute( idArray, 1 ) );
|
|
33956
|
-
|
|
33957
34548
|
this._geometryInitialized = true;
|
|
33958
34549
|
|
|
33959
34550
|
}
|
|
@@ -33963,13 +34554,6 @@ class BatchedMesh extends Mesh {
|
|
|
33963
34554
|
// Make sure the geometry is compatible with the existing combined geometry attributes
|
|
33964
34555
|
_validateGeometry( geometry ) {
|
|
33965
34556
|
|
|
33966
|
-
// check that the geometry doesn't have a version of our reserved id attribute
|
|
33967
|
-
if ( geometry.getAttribute( ID_ATTR_NAME ) ) {
|
|
33968
|
-
|
|
33969
|
-
throw new Error( `BatchedMesh: Geometry cannot use attribute "${ ID_ATTR_NAME }"` );
|
|
33970
|
-
|
|
33971
|
-
}
|
|
33972
|
-
|
|
33973
34557
|
// check to ensure the geometries are using consistent attributes and indices
|
|
33974
34558
|
const batchGeometry = this.geometry;
|
|
33975
34559
|
if ( Boolean( geometry.getIndex() ) !== Boolean( batchGeometry.getIndex() ) ) {
|
|
@@ -33980,12 +34564,6 @@ class BatchedMesh extends Mesh {
|
|
|
33980
34564
|
|
|
33981
34565
|
for ( const attributeName in batchGeometry.attributes ) {
|
|
33982
34566
|
|
|
33983
|
-
if ( attributeName === ID_ATTR_NAME ) {
|
|
33984
|
-
|
|
33985
|
-
continue;
|
|
33986
|
-
|
|
33987
|
-
}
|
|
33988
|
-
|
|
33989
34567
|
if ( ! geometry.hasAttribute( attributeName ) ) {
|
|
33990
34568
|
|
|
33991
34569
|
throw new Error( `BatchedMesh: Added geometry missing "${ attributeName }". All geometries must have consistent attributes.` );
|
|
@@ -34021,15 +34599,16 @@ class BatchedMesh extends Mesh {
|
|
|
34021
34599
|
|
|
34022
34600
|
const geometryCount = this._geometryCount;
|
|
34023
34601
|
const boundingBox = this.boundingBox;
|
|
34024
|
-
const
|
|
34602
|
+
const drawInfo = this._drawInfo;
|
|
34025
34603
|
|
|
34026
34604
|
boundingBox.makeEmpty();
|
|
34027
34605
|
for ( let i = 0; i < geometryCount; i ++ ) {
|
|
34028
34606
|
|
|
34029
|
-
if (
|
|
34607
|
+
if ( drawInfo[ i ].active === false ) continue;
|
|
34030
34608
|
|
|
34609
|
+
const geometryId = drawInfo[ i ].geometryIndex;
|
|
34031
34610
|
this.getMatrixAt( i, _matrix$1 );
|
|
34032
|
-
this.getBoundingBoxAt(
|
|
34611
|
+
this.getBoundingBoxAt( geometryId, _box$1 ).applyMatrix4( _matrix$1 );
|
|
34033
34612
|
boundingBox.union( _box$1 );
|
|
34034
34613
|
|
|
34035
34614
|
}
|
|
@@ -34044,23 +34623,59 @@ class BatchedMesh extends Mesh {
|
|
|
34044
34623
|
|
|
34045
34624
|
}
|
|
34046
34625
|
|
|
34047
|
-
const geometryCount = this._geometryCount;
|
|
34048
34626
|
const boundingSphere = this.boundingSphere;
|
|
34049
|
-
const
|
|
34627
|
+
const drawInfo = this._drawInfo;
|
|
34050
34628
|
|
|
34051
34629
|
boundingSphere.makeEmpty();
|
|
34052
|
-
for ( let i = 0; i <
|
|
34630
|
+
for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
|
|
34053
34631
|
|
|
34054
|
-
if (
|
|
34632
|
+
if ( drawInfo[ i ].active === false ) continue;
|
|
34055
34633
|
|
|
34634
|
+
const geometryId = drawInfo[ i ].geometryIndex;
|
|
34056
34635
|
this.getMatrixAt( i, _matrix$1 );
|
|
34057
|
-
this.getBoundingSphereAt(
|
|
34636
|
+
this.getBoundingSphereAt( geometryId, _sphere$2 ).applyMatrix4( _matrix$1 );
|
|
34058
34637
|
boundingSphere.union( _sphere$2 );
|
|
34059
34638
|
|
|
34060
34639
|
}
|
|
34061
34640
|
|
|
34062
34641
|
}
|
|
34063
34642
|
|
|
34643
|
+
addInstance( geometryId ) {
|
|
34644
|
+
|
|
34645
|
+
// ensure we're not over geometry
|
|
34646
|
+
if ( this._drawInfo.length >= this._maxInstanceCount ) {
|
|
34647
|
+
|
|
34648
|
+
throw new Error( 'BatchedMesh: Maximum item count reached.' );
|
|
34649
|
+
|
|
34650
|
+
}
|
|
34651
|
+
|
|
34652
|
+
this._drawInfo.push( {
|
|
34653
|
+
|
|
34654
|
+
visible: true,
|
|
34655
|
+
active: true,
|
|
34656
|
+
geometryIndex: geometryId,
|
|
34657
|
+
|
|
34658
|
+
} );
|
|
34659
|
+
|
|
34660
|
+
// initialize the matrix
|
|
34661
|
+
const drawId = this._drawInfo.length - 1;
|
|
34662
|
+
const matricesTexture = this._matricesTexture;
|
|
34663
|
+
const matricesArray = matricesTexture.image.data;
|
|
34664
|
+
_identityMatrix.toArray( matricesArray, drawId * 16 );
|
|
34665
|
+
matricesTexture.needsUpdate = true;
|
|
34666
|
+
|
|
34667
|
+
const colorsTexture = this._colorsTexture;
|
|
34668
|
+
if ( colorsTexture ) {
|
|
34669
|
+
|
|
34670
|
+
_whiteColor.toArray( colorsTexture.image.data, drawId * 4 );
|
|
34671
|
+
colorsTexture.needsUpdate = true;
|
|
34672
|
+
|
|
34673
|
+
}
|
|
34674
|
+
|
|
34675
|
+
return drawId;
|
|
34676
|
+
|
|
34677
|
+
}
|
|
34678
|
+
|
|
34064
34679
|
addGeometry( geometry, vertexCount = - 1, indexCount = - 1 ) {
|
|
34065
34680
|
|
|
34066
34681
|
this._initializeGeometry( geometry );
|
|
@@ -34068,9 +34683,9 @@ class BatchedMesh extends Mesh {
|
|
|
34068
34683
|
this._validateGeometry( geometry );
|
|
34069
34684
|
|
|
34070
34685
|
// ensure we're not over geometry
|
|
34071
|
-
if ( this.
|
|
34686
|
+
if ( this._drawInfo.length >= this._maxInstanceCount ) {
|
|
34072
34687
|
|
|
34073
|
-
throw new Error( 'BatchedMesh: Maximum
|
|
34688
|
+
throw new Error( 'BatchedMesh: Maximum item count reached.' );
|
|
34074
34689
|
|
|
34075
34690
|
}
|
|
34076
34691
|
|
|
@@ -34148,23 +34763,10 @@ class BatchedMesh extends Mesh {
|
|
|
34148
34763
|
|
|
34149
34764
|
}
|
|
34150
34765
|
|
|
34151
|
-
const visibility = this._visibility;
|
|
34152
|
-
const active = this._active;
|
|
34153
|
-
const matricesTexture = this._matricesTexture;
|
|
34154
|
-
const matricesArray = this._matricesTexture.image.data;
|
|
34155
|
-
|
|
34156
|
-
// push new visibility states
|
|
34157
|
-
visibility.push( true );
|
|
34158
|
-
active.push( true );
|
|
34159
|
-
|
|
34160
34766
|
// update id
|
|
34161
34767
|
const geometryId = this._geometryCount;
|
|
34162
34768
|
this._geometryCount ++;
|
|
34163
34769
|
|
|
34164
|
-
// initialize matrix information
|
|
34165
|
-
_identityMatrix.toArray( matricesArray, geometryId * 16 );
|
|
34166
|
-
matricesTexture.needsUpdate = true;
|
|
34167
|
-
|
|
34168
34770
|
// add the reserved range and draw range objects
|
|
34169
34771
|
reservedRanges.push( reservedRange );
|
|
34170
34772
|
drawRanges.push( {
|
|
@@ -34179,16 +34781,6 @@ class BatchedMesh extends Mesh {
|
|
|
34179
34781
|
sphere: new Sphere()
|
|
34180
34782
|
} );
|
|
34181
34783
|
|
|
34182
|
-
// set the id for the geometry
|
|
34183
|
-
const idAttribute = this.geometry.getAttribute( ID_ATTR_NAME );
|
|
34184
|
-
for ( let i = 0; i < reservedRange.vertexCount; i ++ ) {
|
|
34185
|
-
|
|
34186
|
-
idAttribute.setX( reservedRange.vertexStart + i, geometryId );
|
|
34187
|
-
|
|
34188
|
-
}
|
|
34189
|
-
|
|
34190
|
-
idAttribute.needsUpdate = true;
|
|
34191
|
-
|
|
34192
34784
|
// update the geometry
|
|
34193
34785
|
this.setGeometryAt( geometryId, geometry );
|
|
34194
34786
|
|
|
@@ -34196,9 +34788,9 @@ class BatchedMesh extends Mesh {
|
|
|
34196
34788
|
|
|
34197
34789
|
}
|
|
34198
34790
|
|
|
34199
|
-
setGeometryAt(
|
|
34791
|
+
setGeometryAt( geometryId, geometry ) {
|
|
34200
34792
|
|
|
34201
|
-
if (
|
|
34793
|
+
if ( geometryId >= this._geometryCount ) {
|
|
34202
34794
|
|
|
34203
34795
|
throw new Error( 'BatchedMesh: Maximum geometry count reached.' );
|
|
34204
34796
|
|
|
@@ -34210,7 +34802,7 @@ class BatchedMesh extends Mesh {
|
|
|
34210
34802
|
const hasIndex = batchGeometry.getIndex() !== null;
|
|
34211
34803
|
const dstIndex = batchGeometry.getIndex();
|
|
34212
34804
|
const srcIndex = geometry.getIndex();
|
|
34213
|
-
const reservedRange = this._reservedRanges[
|
|
34805
|
+
const reservedRange = this._reservedRanges[ geometryId ];
|
|
34214
34806
|
if (
|
|
34215
34807
|
hasIndex &&
|
|
34216
34808
|
srcIndex.count > reservedRange.indexCount ||
|
|
@@ -34226,12 +34818,6 @@ class BatchedMesh extends Mesh {
|
|
|
34226
34818
|
const vertexCount = reservedRange.vertexCount;
|
|
34227
34819
|
for ( const attributeName in batchGeometry.attributes ) {
|
|
34228
34820
|
|
|
34229
|
-
if ( attributeName === ID_ATTR_NAME ) {
|
|
34230
|
-
|
|
34231
|
-
continue;
|
|
34232
|
-
|
|
34233
|
-
}
|
|
34234
|
-
|
|
34235
34821
|
// copy attribute data
|
|
34236
34822
|
const srcAttribute = geometry.getAttribute( attributeName );
|
|
34237
34823
|
const dstAttribute = batchGeometry.getAttribute( attributeName );
|
|
@@ -34280,7 +34866,7 @@ class BatchedMesh extends Mesh {
|
|
|
34280
34866
|
}
|
|
34281
34867
|
|
|
34282
34868
|
// store the bounding boxes
|
|
34283
|
-
const bound = this._bounds[
|
|
34869
|
+
const bound = this._bounds[ geometryId ];
|
|
34284
34870
|
if ( geometry.boundingBox !== null ) {
|
|
34285
34871
|
|
|
34286
34872
|
bound.box.copy( geometry.boundingBox );
|
|
@@ -34304,67 +34890,54 @@ class BatchedMesh extends Mesh {
|
|
|
34304
34890
|
}
|
|
34305
34891
|
|
|
34306
34892
|
// set drawRange count
|
|
34307
|
-
const drawRange = this._drawRanges[
|
|
34893
|
+
const drawRange = this._drawRanges[ geometryId ];
|
|
34308
34894
|
const posAttr = geometry.getAttribute( 'position' );
|
|
34309
34895
|
drawRange.count = hasIndex ? srcIndex.count : posAttr.count;
|
|
34310
34896
|
this._visibilityChanged = true;
|
|
34311
34897
|
|
|
34312
|
-
return
|
|
34898
|
+
return geometryId;
|
|
34313
34899
|
|
|
34314
34900
|
}
|
|
34315
34901
|
|
|
34902
|
+
/*
|
|
34316
34903
|
deleteGeometry( geometryId ) {
|
|
34317
34904
|
|
|
34318
|
-
//
|
|
34319
|
-
|
|
34320
|
-
const active = this._active;
|
|
34321
|
-
if ( geometryId >= active.length || active[ geometryId ] === false ) {
|
|
34322
|
-
|
|
34323
|
-
return this;
|
|
34324
|
-
|
|
34325
|
-
}
|
|
34326
|
-
|
|
34327
|
-
active[ geometryId ] = false;
|
|
34328
|
-
this._visibilityChanged = true;
|
|
34329
|
-
|
|
34330
|
-
return this;
|
|
34905
|
+
// TODO: delete geometry and associated instances
|
|
34331
34906
|
|
|
34332
34907
|
}
|
|
34908
|
+
*/
|
|
34333
34909
|
|
|
34334
|
-
|
|
34335
|
-
|
|
34336
|
-
if ( this._multiDrawInstances === null ) return null;
|
|
34337
|
-
|
|
34338
|
-
return this._multiDrawInstances[ id ];
|
|
34339
|
-
|
|
34340
|
-
}
|
|
34910
|
+
/*
|
|
34911
|
+
deleteInstance( instanceId ) {
|
|
34341
34912
|
|
|
34342
|
-
|
|
34913
|
+
// Note: User needs to call optimize() afterward to pack the data.
|
|
34343
34914
|
|
|
34344
|
-
|
|
34915
|
+
const drawInfo = this._drawInfo;
|
|
34916
|
+
if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
|
|
34345
34917
|
|
|
34346
|
-
|
|
34918
|
+
return this;
|
|
34347
34919
|
|
|
34348
34920
|
}
|
|
34349
34921
|
|
|
34350
|
-
|
|
34922
|
+
drawInfo[ instanceId ].active = false;
|
|
34923
|
+
this._visibilityChanged = true;
|
|
34351
34924
|
|
|
34352
|
-
return
|
|
34925
|
+
return this;
|
|
34353
34926
|
|
|
34354
34927
|
}
|
|
34928
|
+
*/
|
|
34355
34929
|
|
|
34356
34930
|
// get bounding box and compute it if it doesn't exist
|
|
34357
|
-
getBoundingBoxAt(
|
|
34931
|
+
getBoundingBoxAt( geometryId, target ) {
|
|
34358
34932
|
|
|
34359
|
-
|
|
34360
|
-
if ( active[ id ] === false ) {
|
|
34933
|
+
if ( geometryId >= this._geometryCount ) {
|
|
34361
34934
|
|
|
34362
34935
|
return null;
|
|
34363
34936
|
|
|
34364
34937
|
}
|
|
34365
34938
|
|
|
34366
34939
|
// compute bounding box
|
|
34367
|
-
const bound = this._bounds[
|
|
34940
|
+
const bound = this._bounds[ geometryId ];
|
|
34368
34941
|
const box = bound.box;
|
|
34369
34942
|
const geometry = this.geometry;
|
|
34370
34943
|
if ( bound.boxInitialized === false ) {
|
|
@@ -34373,7 +34946,7 @@ class BatchedMesh extends Mesh {
|
|
|
34373
34946
|
|
|
34374
34947
|
const index = geometry.index;
|
|
34375
34948
|
const position = geometry.attributes.position;
|
|
34376
|
-
const drawRange = this._drawRanges[
|
|
34949
|
+
const drawRange = this._drawRanges[ geometryId ];
|
|
34377
34950
|
for ( let i = drawRange.start, l = drawRange.start + drawRange.count; i < l; i ++ ) {
|
|
34378
34951
|
|
|
34379
34952
|
let iv = i;
|
|
@@ -34397,29 +34970,28 @@ class BatchedMesh extends Mesh {
|
|
|
34397
34970
|
}
|
|
34398
34971
|
|
|
34399
34972
|
// get bounding sphere and compute it if it doesn't exist
|
|
34400
|
-
getBoundingSphereAt(
|
|
34973
|
+
getBoundingSphereAt( geometryId, target ) {
|
|
34401
34974
|
|
|
34402
|
-
|
|
34403
|
-
if ( active[ id ] === false ) {
|
|
34975
|
+
if ( geometryId >= this._geometryCount ) {
|
|
34404
34976
|
|
|
34405
34977
|
return null;
|
|
34406
34978
|
|
|
34407
34979
|
}
|
|
34408
34980
|
|
|
34409
34981
|
// compute bounding sphere
|
|
34410
|
-
const bound = this._bounds[
|
|
34982
|
+
const bound = this._bounds[ geometryId ];
|
|
34411
34983
|
const sphere = bound.sphere;
|
|
34412
34984
|
const geometry = this.geometry;
|
|
34413
34985
|
if ( bound.sphereInitialized === false ) {
|
|
34414
34986
|
|
|
34415
34987
|
sphere.makeEmpty();
|
|
34416
34988
|
|
|
34417
|
-
this.getBoundingBoxAt(
|
|
34989
|
+
this.getBoundingBoxAt( geometryId, _box$1 );
|
|
34418
34990
|
_box$1.getCenter( sphere.center );
|
|
34419
34991
|
|
|
34420
34992
|
const index = geometry.index;
|
|
34421
34993
|
const position = geometry.attributes.position;
|
|
34422
|
-
const drawRange = this._drawRanges[
|
|
34994
|
+
const drawRange = this._drawRanges[ geometryId ];
|
|
34423
34995
|
|
|
34424
34996
|
let maxRadiusSq = 0;
|
|
34425
34997
|
for ( let i = drawRange.start, l = drawRange.start + drawRange.count; i < l; i ++ ) {
|
|
@@ -34446,91 +35018,122 @@ class BatchedMesh extends Mesh {
|
|
|
34446
35018
|
|
|
34447
35019
|
}
|
|
34448
35020
|
|
|
34449
|
-
setMatrixAt(
|
|
35021
|
+
setMatrixAt( instanceId, matrix ) {
|
|
34450
35022
|
|
|
34451
35023
|
// @TODO: Map geometryId to index of the arrays because
|
|
34452
35024
|
// optimize() can make geometryId mismatch the index
|
|
34453
35025
|
|
|
34454
|
-
const
|
|
35026
|
+
const drawInfo = this._drawInfo;
|
|
34455
35027
|
const matricesTexture = this._matricesTexture;
|
|
34456
35028
|
const matricesArray = this._matricesTexture.image.data;
|
|
34457
|
-
|
|
34458
|
-
if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
|
|
35029
|
+
if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
|
|
34459
35030
|
|
|
34460
35031
|
return this;
|
|
34461
35032
|
|
|
34462
35033
|
}
|
|
34463
35034
|
|
|
34464
|
-
matrix.toArray( matricesArray,
|
|
35035
|
+
matrix.toArray( matricesArray, instanceId * 16 );
|
|
34465
35036
|
matricesTexture.needsUpdate = true;
|
|
34466
35037
|
|
|
34467
35038
|
return this;
|
|
34468
35039
|
|
|
34469
35040
|
}
|
|
34470
35041
|
|
|
34471
|
-
getMatrixAt(
|
|
35042
|
+
getMatrixAt( instanceId, matrix ) {
|
|
34472
35043
|
|
|
34473
|
-
const
|
|
35044
|
+
const drawInfo = this._drawInfo;
|
|
34474
35045
|
const matricesArray = this._matricesTexture.image.data;
|
|
34475
|
-
|
|
34476
|
-
if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
|
|
35046
|
+
if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
|
|
34477
35047
|
|
|
34478
35048
|
return null;
|
|
34479
35049
|
|
|
34480
35050
|
}
|
|
34481
35051
|
|
|
34482
|
-
return matrix.fromArray( matricesArray,
|
|
35052
|
+
return matrix.fromArray( matricesArray, instanceId * 16 );
|
|
34483
35053
|
|
|
34484
35054
|
}
|
|
34485
35055
|
|
|
34486
|
-
|
|
35056
|
+
setColorAt( instanceId, color ) {
|
|
34487
35057
|
|
|
34488
|
-
|
|
34489
|
-
|
|
34490
|
-
|
|
35058
|
+
if ( this._colorsTexture === null ) {
|
|
35059
|
+
|
|
35060
|
+
this._initColorsTexture();
|
|
35061
|
+
|
|
35062
|
+
}
|
|
35063
|
+
|
|
35064
|
+
// @TODO: Map id to index of the arrays because
|
|
35065
|
+
// optimize() can make id mismatch the index
|
|
35066
|
+
|
|
35067
|
+
const colorsTexture = this._colorsTexture;
|
|
35068
|
+
const colorsArray = this._colorsTexture.image.data;
|
|
35069
|
+
const drawInfo = this._drawInfo;
|
|
35070
|
+
if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
|
|
35071
|
+
|
|
35072
|
+
return this;
|
|
35073
|
+
|
|
35074
|
+
}
|
|
35075
|
+
|
|
35076
|
+
color.toArray( colorsArray, instanceId * 4 );
|
|
35077
|
+
colorsTexture.needsUpdate = true;
|
|
35078
|
+
|
|
35079
|
+
return this;
|
|
35080
|
+
|
|
35081
|
+
}
|
|
35082
|
+
|
|
35083
|
+
getColorAt( instanceId, color ) {
|
|
35084
|
+
|
|
35085
|
+
const colorsArray = this._colorsTexture.image.data;
|
|
35086
|
+
const drawInfo = this._drawInfo;
|
|
35087
|
+
if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
|
|
35088
|
+
|
|
35089
|
+
return null;
|
|
35090
|
+
|
|
35091
|
+
}
|
|
35092
|
+
|
|
35093
|
+
return color.fromArray( colorsArray, instanceId * 4 );
|
|
35094
|
+
|
|
35095
|
+
}
|
|
35096
|
+
|
|
35097
|
+
setVisibleAt( instanceId, value ) {
|
|
34491
35098
|
|
|
34492
35099
|
// if the geometry is out of range, not active, or visibility state
|
|
34493
35100
|
// does not change then return early
|
|
35101
|
+
const drawInfo = this._drawInfo;
|
|
34494
35102
|
if (
|
|
34495
|
-
|
|
34496
|
-
|
|
34497
|
-
|
|
35103
|
+
instanceId >= drawInfo.length ||
|
|
35104
|
+
drawInfo[ instanceId ].active === false ||
|
|
35105
|
+
drawInfo[ instanceId ].visible === value
|
|
34498
35106
|
) {
|
|
34499
35107
|
|
|
34500
35108
|
return this;
|
|
34501
35109
|
|
|
34502
35110
|
}
|
|
34503
35111
|
|
|
34504
|
-
|
|
35112
|
+
drawInfo[ instanceId ].visible = value;
|
|
34505
35113
|
this._visibilityChanged = true;
|
|
34506
35114
|
|
|
34507
35115
|
return this;
|
|
34508
35116
|
|
|
34509
35117
|
}
|
|
34510
35118
|
|
|
34511
|
-
getVisibleAt(
|
|
34512
|
-
|
|
34513
|
-
const visibility = this._visibility;
|
|
34514
|
-
const active = this._active;
|
|
34515
|
-
const geometryCount = this._geometryCount;
|
|
35119
|
+
getVisibleAt( instanceId ) {
|
|
34516
35120
|
|
|
34517
35121
|
// return early if the geometry is out of range or not active
|
|
34518
|
-
|
|
35122
|
+
const drawInfo = this._drawInfo;
|
|
35123
|
+
if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
|
|
34519
35124
|
|
|
34520
35125
|
return false;
|
|
34521
35126
|
|
|
34522
35127
|
}
|
|
34523
35128
|
|
|
34524
|
-
return
|
|
35129
|
+
return drawInfo[ instanceId ].visible;
|
|
34525
35130
|
|
|
34526
35131
|
}
|
|
34527
35132
|
|
|
34528
35133
|
raycast( raycaster, intersects ) {
|
|
34529
35134
|
|
|
34530
|
-
const
|
|
34531
|
-
const active = this._active;
|
|
35135
|
+
const drawInfo = this._drawInfo;
|
|
34532
35136
|
const drawRanges = this._drawRanges;
|
|
34533
|
-
const geometryCount = this._geometryCount;
|
|
34534
35137
|
const matrixWorld = this.matrixWorld;
|
|
34535
35138
|
const batchGeometry = this.geometry;
|
|
34536
35139
|
|
|
@@ -34550,21 +35153,22 @@ class BatchedMesh extends Mesh {
|
|
|
34550
35153
|
|
|
34551
35154
|
}
|
|
34552
35155
|
|
|
34553
|
-
for ( let i = 0; i <
|
|
35156
|
+
for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
|
|
34554
35157
|
|
|
34555
|
-
if ( !
|
|
35158
|
+
if ( ! drawInfo[ i ].visible || ! drawInfo[ i ].active ) {
|
|
34556
35159
|
|
|
34557
35160
|
continue;
|
|
34558
35161
|
|
|
34559
35162
|
}
|
|
34560
35163
|
|
|
34561
|
-
const
|
|
35164
|
+
const geometryId = drawInfo[ i ].geometryIndex;
|
|
35165
|
+
const drawRange = drawRanges[ geometryId ];
|
|
34562
35166
|
_mesh.geometry.setDrawRange( drawRange.start, drawRange.count );
|
|
34563
35167
|
|
|
34564
35168
|
// ge the intersects
|
|
34565
35169
|
this.getMatrixAt( i, _mesh.matrixWorld ).premultiply( matrixWorld );
|
|
34566
|
-
this.getBoundingBoxAt(
|
|
34567
|
-
this.getBoundingSphereAt(
|
|
35170
|
+
this.getBoundingBoxAt( geometryId, _mesh.geometry.boundingBox );
|
|
35171
|
+
this.getBoundingSphereAt( geometryId, _mesh.geometry.boundingSphere );
|
|
34568
35172
|
_mesh.raycast( raycaster, _batchIntersects );
|
|
34569
35173
|
|
|
34570
35174
|
// add batch id to the intersects
|
|
@@ -34601,8 +35205,7 @@ class BatchedMesh extends Mesh {
|
|
|
34601
35205
|
this._drawRanges = source._drawRanges.map( range => ( { ...range } ) );
|
|
34602
35206
|
this._reservedRanges = source._reservedRanges.map( range => ( { ...range } ) );
|
|
34603
35207
|
|
|
34604
|
-
this.
|
|
34605
|
-
this._active = source._active.slice();
|
|
35208
|
+
this._drawInfo = source._drawInfo.map( inf => ( { ...inf } ) );
|
|
34606
35209
|
this._bounds = source._bounds.map( bound => ( {
|
|
34607
35210
|
boxInitialized: bound.boxInitialized,
|
|
34608
35211
|
box: bound.box.clone(),
|
|
@@ -34611,7 +35214,7 @@ class BatchedMesh extends Mesh {
|
|
|
34611
35214
|
sphere: bound.sphere.clone()
|
|
34612
35215
|
} ) );
|
|
34613
35216
|
|
|
34614
|
-
this.
|
|
35217
|
+
this._maxInstanceCount = source._maxInstanceCount;
|
|
34615
35218
|
this._maxVertexCount = source._maxVertexCount;
|
|
34616
35219
|
this._maxIndexCount = source._maxIndexCount;
|
|
34617
35220
|
|
|
@@ -34621,7 +35224,14 @@ class BatchedMesh extends Mesh {
|
|
|
34621
35224
|
this._multiDrawStarts = source._multiDrawStarts.slice();
|
|
34622
35225
|
|
|
34623
35226
|
this._matricesTexture = source._matricesTexture.clone();
|
|
34624
|
-
this._matricesTexture.image.data = this._matricesTexture.image.slice();
|
|
35227
|
+
this._matricesTexture.image.data = this._matricesTexture.image.data.slice();
|
|
35228
|
+
|
|
35229
|
+
if ( this._colorsTexture !== null ) {
|
|
35230
|
+
|
|
35231
|
+
this._colorsTexture = source._colorsTexture.clone();
|
|
35232
|
+
this._colorsTexture.image.data = this._colorsTexture.image.data.slice();
|
|
35233
|
+
|
|
35234
|
+
}
|
|
34625
35235
|
|
|
34626
35236
|
return this;
|
|
34627
35237
|
|
|
@@ -34634,6 +35244,17 @@ class BatchedMesh extends Mesh {
|
|
|
34634
35244
|
|
|
34635
35245
|
this._matricesTexture.dispose();
|
|
34636
35246
|
this._matricesTexture = null;
|
|
35247
|
+
|
|
35248
|
+
this._indirectTexture.dispose();
|
|
35249
|
+
this._indirectTexture = null;
|
|
35250
|
+
|
|
35251
|
+
if ( this._colorsTexture !== null ) {
|
|
35252
|
+
|
|
35253
|
+
this._colorsTexture.dispose();
|
|
35254
|
+
this._colorsTexture = null;
|
|
35255
|
+
|
|
35256
|
+
}
|
|
35257
|
+
|
|
34637
35258
|
return this;
|
|
34638
35259
|
|
|
34639
35260
|
}
|
|
@@ -34653,12 +35274,13 @@ class BatchedMesh extends Mesh {
|
|
|
34653
35274
|
const index = geometry.getIndex();
|
|
34654
35275
|
const bytesPerElement = index === null ? 1 : index.array.BYTES_PER_ELEMENT;
|
|
34655
35276
|
|
|
34656
|
-
const
|
|
34657
|
-
const visibility = this._visibility;
|
|
35277
|
+
const drawInfo = this._drawInfo;
|
|
34658
35278
|
const multiDrawStarts = this._multiDrawStarts;
|
|
34659
35279
|
const multiDrawCounts = this._multiDrawCounts;
|
|
34660
35280
|
const drawRanges = this._drawRanges;
|
|
34661
35281
|
const perObjectFrustumCulled = this.perObjectFrustumCulled;
|
|
35282
|
+
const indirectTexture = this._indirectTexture;
|
|
35283
|
+
const indirectArray = indirectTexture.image.data;
|
|
34662
35284
|
|
|
34663
35285
|
// prepare the frustum in the local frame
|
|
34664
35286
|
if ( perObjectFrustumCulled ) {
|
|
@@ -34679,14 +35301,17 @@ class BatchedMesh extends Mesh {
|
|
|
34679
35301
|
// get the camera position in the local frame
|
|
34680
35302
|
_invMatrixWorld.copy( this.matrixWorld ).invert();
|
|
34681
35303
|
_vector$5.setFromMatrixPosition( camera.matrixWorld ).applyMatrix4( _invMatrixWorld );
|
|
35304
|
+
_forward.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld ).transformDirection( _invMatrixWorld );
|
|
34682
35305
|
|
|
34683
|
-
for ( let i = 0, l =
|
|
35306
|
+
for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
|
|
34684
35307
|
|
|
34685
|
-
if (
|
|
35308
|
+
if ( drawInfo[ i ].visible && drawInfo[ i ].active ) {
|
|
35309
|
+
|
|
35310
|
+
const geometryId = drawInfo[ i ].geometryIndex;
|
|
34686
35311
|
|
|
34687
35312
|
// get the bounds in world space
|
|
34688
35313
|
this.getMatrixAt( i, _matrix$1 );
|
|
34689
|
-
this.getBoundingSphereAt(
|
|
35314
|
+
this.getBoundingSphereAt( geometryId, _sphere$2 ).applyMatrix4( _matrix$1 );
|
|
34690
35315
|
|
|
34691
35316
|
// determine whether the batched geometry is within the frustum
|
|
34692
35317
|
let culled = false;
|
|
@@ -34699,8 +35324,8 @@ class BatchedMesh extends Mesh {
|
|
|
34699
35324
|
if ( ! culled ) {
|
|
34700
35325
|
|
|
34701
35326
|
// get the distance from camera used for sorting
|
|
34702
|
-
const z =
|
|
34703
|
-
_renderList.push( drawRanges[
|
|
35327
|
+
const z = _temp.subVectors( _sphere$2.center, _vector$5 ).dot( _forward );
|
|
35328
|
+
_renderList.push( drawRanges[ geometryId ], z, i );
|
|
34704
35329
|
|
|
34705
35330
|
}
|
|
34706
35331
|
|
|
@@ -34726,6 +35351,7 @@ class BatchedMesh extends Mesh {
|
|
|
34726
35351
|
const item = list[ i ];
|
|
34727
35352
|
multiDrawStarts[ count ] = item.start * bytesPerElement;
|
|
34728
35353
|
multiDrawCounts[ count ] = item.count;
|
|
35354
|
+
indirectArray[ count ] = item.index;
|
|
34729
35355
|
count ++;
|
|
34730
35356
|
|
|
34731
35357
|
}
|
|
@@ -34734,9 +35360,11 @@ class BatchedMesh extends Mesh {
|
|
|
34734
35360
|
|
|
34735
35361
|
} else {
|
|
34736
35362
|
|
|
34737
|
-
for ( let i = 0, l =
|
|
35363
|
+
for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
|
|
35364
|
+
|
|
35365
|
+
if ( drawInfo[ i ].visible && drawInfo[ i ].active ) {
|
|
34738
35366
|
|
|
34739
|
-
|
|
35367
|
+
const geometryId = drawInfo[ i ].geometryIndex;
|
|
34740
35368
|
|
|
34741
35369
|
// determine whether the batched geometry is within the frustum
|
|
34742
35370
|
let culled = false;
|
|
@@ -34744,16 +35372,17 @@ class BatchedMesh extends Mesh {
|
|
|
34744
35372
|
|
|
34745
35373
|
// get the bounds in world space
|
|
34746
35374
|
this.getMatrixAt( i, _matrix$1 );
|
|
34747
|
-
this.getBoundingSphereAt(
|
|
35375
|
+
this.getBoundingSphereAt( geometryId, _sphere$2 ).applyMatrix4( _matrix$1 );
|
|
34748
35376
|
culled = ! _frustum.intersectsSphere( _sphere$2 );
|
|
34749
35377
|
|
|
34750
35378
|
}
|
|
34751
35379
|
|
|
34752
35380
|
if ( ! culled ) {
|
|
34753
35381
|
|
|
34754
|
-
const range = drawRanges[
|
|
35382
|
+
const range = drawRanges[ geometryId ];
|
|
34755
35383
|
multiDrawStarts[ count ] = range.start * bytesPerElement;
|
|
34756
35384
|
multiDrawCounts[ count ] = range.count;
|
|
35385
|
+
indirectArray[ count ] = i;
|
|
34757
35386
|
count ++;
|
|
34758
35387
|
|
|
34759
35388
|
}
|
|
@@ -34764,6 +35393,7 @@ class BatchedMesh extends Mesh {
|
|
|
34764
35393
|
|
|
34765
35394
|
}
|
|
34766
35395
|
|
|
35396
|
+
indirectTexture.needsUpdate = true;
|
|
34767
35397
|
this._multiDrawCount = count;
|
|
34768
35398
|
this._visibilityChanged = false;
|
|
34769
35399
|
|
|
@@ -35429,6 +36059,20 @@ class CompressedArrayTexture extends CompressedTexture {
|
|
|
35429
36059
|
this.image.depth = depth;
|
|
35430
36060
|
this.wrapR = ClampToEdgeWrapping;
|
|
35431
36061
|
|
|
36062
|
+
this.layerUpdates = new Set();
|
|
36063
|
+
|
|
36064
|
+
}
|
|
36065
|
+
|
|
36066
|
+
addLayerUpdate( layerIndex ) {
|
|
36067
|
+
|
|
36068
|
+
this.layerUpdates.add( layerIndex );
|
|
36069
|
+
|
|
36070
|
+
}
|
|
36071
|
+
|
|
36072
|
+
clearLayerUpdates() {
|
|
36073
|
+
|
|
36074
|
+
this.layerUpdates.clear();
|
|
36075
|
+
|
|
35432
36076
|
}
|
|
35433
36077
|
|
|
35434
36078
|
}
|
|
@@ -43593,7 +44237,16 @@ KeyframeTrack.prototype.DefaultInterpolation = InterpolateLinear;
|
|
|
43593
44237
|
/**
|
|
43594
44238
|
* A Track of Boolean keyframe values.
|
|
43595
44239
|
*/
|
|
43596
|
-
class BooleanKeyframeTrack extends KeyframeTrack {
|
|
44240
|
+
class BooleanKeyframeTrack extends KeyframeTrack {
|
|
44241
|
+
|
|
44242
|
+
// No interpolation parameter because only InterpolateDiscrete is valid.
|
|
44243
|
+
constructor( name, times, values ) {
|
|
44244
|
+
|
|
44245
|
+
super( name, times, values );
|
|
44246
|
+
|
|
44247
|
+
}
|
|
44248
|
+
|
|
44249
|
+
}
|
|
43597
44250
|
|
|
43598
44251
|
BooleanKeyframeTrack.prototype.ValueTypeName = 'bool';
|
|
43599
44252
|
BooleanKeyframeTrack.prototype.ValueBufferType = Array;
|
|
@@ -43664,13 +44317,22 @@ class QuaternionKeyframeTrack extends KeyframeTrack {
|
|
|
43664
44317
|
|
|
43665
44318
|
QuaternionKeyframeTrack.prototype.ValueTypeName = 'quaternion';
|
|
43666
44319
|
// ValueBufferType is inherited
|
|
43667
|
-
|
|
44320
|
+
// DefaultInterpolation is inherited;
|
|
43668
44321
|
QuaternionKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined;
|
|
43669
44322
|
|
|
43670
44323
|
/**
|
|
43671
44324
|
* A Track that interpolates Strings
|
|
43672
44325
|
*/
|
|
43673
|
-
class StringKeyframeTrack extends KeyframeTrack {
|
|
44326
|
+
class StringKeyframeTrack extends KeyframeTrack {
|
|
44327
|
+
|
|
44328
|
+
// No interpolation parameter because only InterpolateDiscrete is valid.
|
|
44329
|
+
constructor( name, times, values ) {
|
|
44330
|
+
|
|
44331
|
+
super( name, times, values );
|
|
44332
|
+
|
|
44333
|
+
}
|
|
44334
|
+
|
|
44335
|
+
}
|
|
43674
44336
|
|
|
43675
44337
|
StringKeyframeTrack.prototype.ValueTypeName = 'string';
|
|
43676
44338
|
StringKeyframeTrack.prototype.ValueBufferType = Array;
|
|
@@ -44543,6 +45205,10 @@ class FileLoader extends Loader {
|
|
|
44543
45205
|
|
|
44544
45206
|
}
|
|
44545
45207
|
|
|
45208
|
+
}, ( e ) => {
|
|
45209
|
+
|
|
45210
|
+
controller.error( e );
|
|
45211
|
+
|
|
44546
45212
|
} );
|
|
44547
45213
|
|
|
44548
45214
|
}
|
|
@@ -45204,6 +45870,7 @@ class Light extends Object3D {
|
|
|
45204
45870
|
if ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra;
|
|
45205
45871
|
|
|
45206
45872
|
if ( this.shadow !== undefined ) data.object.shadow = this.shadow.toJSON();
|
|
45873
|
+
if ( this.target !== undefined ) data.object.target = this.target.uuid;
|
|
45207
45874
|
|
|
45208
45875
|
return data;
|
|
45209
45876
|
|
|
@@ -45250,6 +45917,8 @@ class LightShadow {
|
|
|
45250
45917
|
|
|
45251
45918
|
this.camera = camera;
|
|
45252
45919
|
|
|
45920
|
+
this.intensity = 1;
|
|
45921
|
+
|
|
45253
45922
|
this.bias = 0;
|
|
45254
45923
|
this.normalBias = 0;
|
|
45255
45924
|
this.radius = 1;
|
|
@@ -45347,6 +46016,8 @@ class LightShadow {
|
|
|
45347
46016
|
|
|
45348
46017
|
this.camera = source.camera.clone();
|
|
45349
46018
|
|
|
46019
|
+
this.intensity = source.intensity;
|
|
46020
|
+
|
|
45350
46021
|
this.bias = source.bias;
|
|
45351
46022
|
this.radius = source.radius;
|
|
45352
46023
|
|
|
@@ -45366,6 +46037,7 @@ class LightShadow {
|
|
|
45366
46037
|
|
|
45367
46038
|
const object = {};
|
|
45368
46039
|
|
|
46040
|
+
if ( this.intensity !== 1 ) object.intensity = this.intensity;
|
|
45369
46041
|
if ( this.bias !== 0 ) object.bias = this.bias;
|
|
45370
46042
|
if ( this.normalBias !== 0 ) object.normalBias = this.normalBias;
|
|
45371
46043
|
if ( this.radius !== 1 ) object.radius = this.radius;
|
|
@@ -46378,7 +47050,9 @@ class MaterialLoader extends Loader {
|
|
|
46378
47050
|
|
|
46379
47051
|
class LoaderUtils {
|
|
46380
47052
|
|
|
46381
|
-
static decodeText( array ) {
|
|
47053
|
+
static decodeText( array ) { // @deprecated, r165
|
|
47054
|
+
|
|
47055
|
+
console.warn( 'THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead.' );
|
|
46382
47056
|
|
|
46383
47057
|
if ( typeof TextDecoder !== 'undefined' ) {
|
|
46384
47058
|
|
|
@@ -46792,6 +47466,7 @@ class ObjectLoader extends Loader {
|
|
|
46792
47466
|
const skeletons = this.parseSkeletons( json.skeletons, object );
|
|
46793
47467
|
|
|
46794
47468
|
this.bindSkeletons( object, skeletons );
|
|
47469
|
+
this.bindLightTargets( object );
|
|
46795
47470
|
|
|
46796
47471
|
//
|
|
46797
47472
|
|
|
@@ -46833,6 +47508,7 @@ class ObjectLoader extends Loader {
|
|
|
46833
47508
|
const skeletons = this.parseSkeletons( json.skeletons, object );
|
|
46834
47509
|
|
|
46835
47510
|
this.bindSkeletons( object, skeletons );
|
|
47511
|
+
this.bindLightTargets( object );
|
|
46836
47512
|
|
|
46837
47513
|
return object;
|
|
46838
47514
|
|
|
@@ -47477,6 +48153,7 @@ class ObjectLoader extends Loader {
|
|
|
47477
48153
|
case 'DirectionalLight':
|
|
47478
48154
|
|
|
47479
48155
|
object = new DirectionalLight( data.color, data.intensity );
|
|
48156
|
+
object.target = data.target || '';
|
|
47480
48157
|
|
|
47481
48158
|
break;
|
|
47482
48159
|
|
|
@@ -47495,6 +48172,7 @@ class ObjectLoader extends Loader {
|
|
|
47495
48172
|
case 'SpotLight':
|
|
47496
48173
|
|
|
47497
48174
|
object = new SpotLight( data.color, data.intensity, data.distance, data.angle, data.penumbra, data.decay );
|
|
48175
|
+
object.target = data.target || '';
|
|
47498
48176
|
|
|
47499
48177
|
break;
|
|
47500
48178
|
|
|
@@ -47551,7 +48229,7 @@ class ObjectLoader extends Loader {
|
|
|
47551
48229
|
geometry = getGeometry( data.geometry );
|
|
47552
48230
|
material = getMaterial( data.material );
|
|
47553
48231
|
|
|
47554
|
-
object = new BatchedMesh( data.
|
|
48232
|
+
object = new BatchedMesh( data.maxInstanceCount, data.maxVertexCount, data.maxIndexCount, material );
|
|
47555
48233
|
object.geometry = geometry;
|
|
47556
48234
|
object.perObjectFrustumCulled = data.perObjectFrustumCulled;
|
|
47557
48235
|
object.sortObjects = data.sortObjects;
|
|
@@ -47581,7 +48259,7 @@ class ObjectLoader extends Loader {
|
|
|
47581
48259
|
|
|
47582
48260
|
} );
|
|
47583
48261
|
|
|
47584
|
-
object.
|
|
48262
|
+
object._maxInstanceCount = data.maxInstanceCount;
|
|
47585
48263
|
object._maxVertexCount = data.maxVertexCount;
|
|
47586
48264
|
object._maxIndexCount = data.maxIndexCount;
|
|
47587
48265
|
|
|
@@ -47589,6 +48267,7 @@ class ObjectLoader extends Loader {
|
|
|
47589
48267
|
object._geometryCount = data.geometryCount;
|
|
47590
48268
|
|
|
47591
48269
|
object._matricesTexture = getTexture( data.matricesTexture.uuid );
|
|
48270
|
+
if ( data.colorsTexture !== undefined ) object._colorsTexture = getTexture( data.colorsTexture.uuid );
|
|
47592
48271
|
|
|
47593
48272
|
break;
|
|
47594
48273
|
|
|
@@ -47674,6 +48353,7 @@ class ObjectLoader extends Loader {
|
|
|
47674
48353
|
|
|
47675
48354
|
if ( data.shadow ) {
|
|
47676
48355
|
|
|
48356
|
+
if ( data.shadow.intensity !== undefined ) object.shadow.intensity = data.shadow.intensity;
|
|
47677
48357
|
if ( data.shadow.bias !== undefined ) object.shadow.bias = data.shadow.bias;
|
|
47678
48358
|
if ( data.shadow.normalBias !== undefined ) object.shadow.normalBias = data.shadow.normalBias;
|
|
47679
48359
|
if ( data.shadow.radius !== undefined ) object.shadow.radius = data.shadow.radius;
|
|
@@ -47765,6 +48445,32 @@ class ObjectLoader extends Loader {
|
|
|
47765
48445
|
|
|
47766
48446
|
}
|
|
47767
48447
|
|
|
48448
|
+
bindLightTargets( object ) {
|
|
48449
|
+
|
|
48450
|
+
object.traverse( function ( child ) {
|
|
48451
|
+
|
|
48452
|
+
if ( child.isDirectionalLight || child.isSpotLight ) {
|
|
48453
|
+
|
|
48454
|
+
const uuid = child.target;
|
|
48455
|
+
|
|
48456
|
+
const target = object.getObjectByProperty( 'uuid', uuid );
|
|
48457
|
+
|
|
48458
|
+
if ( target !== undefined ) {
|
|
48459
|
+
|
|
48460
|
+
child.target = target;
|
|
48461
|
+
|
|
48462
|
+
} else {
|
|
48463
|
+
|
|
48464
|
+
child.target = new Object3D();
|
|
48465
|
+
|
|
48466
|
+
}
|
|
48467
|
+
|
|
48468
|
+
}
|
|
48469
|
+
|
|
48470
|
+
} );
|
|
48471
|
+
|
|
48472
|
+
}
|
|
48473
|
+
|
|
47768
48474
|
}
|
|
47769
48475
|
|
|
47770
48476
|
const TEXTURE_MAPPING = {
|
|
@@ -52051,13 +52757,17 @@ function ascSort( a, b ) {
|
|
|
52051
52757
|
|
|
52052
52758
|
function intersect( object, raycaster, intersects, recursive ) {
|
|
52053
52759
|
|
|
52760
|
+
let propagate = true;
|
|
52761
|
+
|
|
52054
52762
|
if ( object.layers.test( raycaster.layers ) ) {
|
|
52055
52763
|
|
|
52056
|
-
object.raycast( raycaster, intersects );
|
|
52764
|
+
const result = object.raycast( raycaster, intersects );
|
|
52765
|
+
|
|
52766
|
+
if ( result === false ) propagate = false;
|
|
52057
52767
|
|
|
52058
52768
|
}
|
|
52059
52769
|
|
|
52060
|
-
if ( recursive === true ) {
|
|
52770
|
+
if ( propagate === true && recursive === true ) {
|
|
52061
52771
|
|
|
52062
52772
|
const children = object.children;
|
|
52063
52773
|
|
|
@@ -52213,6 +52923,61 @@ class Cylindrical {
|
|
|
52213
52923
|
|
|
52214
52924
|
}
|
|
52215
52925
|
|
|
52926
|
+
class Matrix2 {
|
|
52927
|
+
|
|
52928
|
+
constructor( n11, n12, n21, n22 ) {
|
|
52929
|
+
|
|
52930
|
+
Matrix2.prototype.isMatrix2 = true;
|
|
52931
|
+
|
|
52932
|
+
this.elements = [
|
|
52933
|
+
1, 0,
|
|
52934
|
+
0, 1,
|
|
52935
|
+
];
|
|
52936
|
+
|
|
52937
|
+
if ( n11 !== undefined ) {
|
|
52938
|
+
|
|
52939
|
+
this.set( n11, n12, n21, n22 );
|
|
52940
|
+
|
|
52941
|
+
}
|
|
52942
|
+
|
|
52943
|
+
}
|
|
52944
|
+
|
|
52945
|
+
identity() {
|
|
52946
|
+
|
|
52947
|
+
this.set(
|
|
52948
|
+
1, 0,
|
|
52949
|
+
0, 1,
|
|
52950
|
+
);
|
|
52951
|
+
|
|
52952
|
+
return this;
|
|
52953
|
+
|
|
52954
|
+
}
|
|
52955
|
+
|
|
52956
|
+
fromArray( array, offset = 0 ) {
|
|
52957
|
+
|
|
52958
|
+
for ( let i = 0; i < 4; i ++ ) {
|
|
52959
|
+
|
|
52960
|
+
this.elements[ i ] = array[ i + offset ];
|
|
52961
|
+
|
|
52962
|
+
}
|
|
52963
|
+
|
|
52964
|
+
return this;
|
|
52965
|
+
|
|
52966
|
+
}
|
|
52967
|
+
|
|
52968
|
+
set( n11, n12, n21, n22 ) {
|
|
52969
|
+
|
|
52970
|
+
const te = this.elements;
|
|
52971
|
+
|
|
52972
|
+
te[ 0 ] = n11; te[ 2 ] = n12;
|
|
52973
|
+
te[ 1 ] = n21; te[ 3 ] = n22;
|
|
52974
|
+
|
|
52975
|
+
return this;
|
|
52976
|
+
|
|
52977
|
+
}
|
|
52978
|
+
|
|
52979
|
+
}
|
|
52980
|
+
|
|
52216
52981
|
const _vector$4 = /*@__PURE__*/ new Vector2();
|
|
52217
52982
|
|
|
52218
52983
|
class Box2 {
|
|
@@ -52332,8 +53097,8 @@ class Box2 {
|
|
|
52332
53097
|
|
|
52333
53098
|
containsPoint( point ) {
|
|
52334
53099
|
|
|
52335
|
-
return point.x
|
|
52336
|
-
point.y
|
|
53100
|
+
return point.x >= this.min.x && point.x <= this.max.x &&
|
|
53101
|
+
point.y >= this.min.y && point.y <= this.max.y;
|
|
52337
53102
|
|
|
52338
53103
|
}
|
|
52339
53104
|
|
|
@@ -52360,8 +53125,8 @@ class Box2 {
|
|
|
52360
53125
|
|
|
52361
53126
|
// using 4 splitting planes to rule out intersections
|
|
52362
53127
|
|
|
52363
|
-
return box.max.x
|
|
52364
|
-
box.max.y
|
|
53128
|
+
return box.max.x >= this.min.x && box.min.x <= this.max.x &&
|
|
53129
|
+
box.max.y >= this.min.y && box.min.y <= this.max.y;
|
|
52365
53130
|
|
|
52366
53131
|
}
|
|
52367
53132
|
|
|
@@ -54287,6 +55052,7 @@ exports.MOUSE = MOUSE;
|
|
|
54287
55052
|
exports.Material = Material;
|
|
54288
55053
|
exports.MaterialLoader = MaterialLoader;
|
|
54289
55054
|
exports.MathUtils = MathUtils;
|
|
55055
|
+
exports.Matrix2 = Matrix2;
|
|
54290
55056
|
exports.Matrix3 = Matrix3;
|
|
54291
55057
|
exports.Matrix4 = Matrix4;
|
|
54292
55058
|
exports.MaxEquation = MaxEquation;
|
|
@@ -54386,7 +55152,9 @@ exports.RGBA_PVRTC_4BPPV1_Format = RGBA_PVRTC_4BPPV1_Format;
|
|
|
54386
55152
|
exports.RGBA_S3TC_DXT1_Format = RGBA_S3TC_DXT1_Format;
|
|
54387
55153
|
exports.RGBA_S3TC_DXT3_Format = RGBA_S3TC_DXT3_Format;
|
|
54388
55154
|
exports.RGBA_S3TC_DXT5_Format = RGBA_S3TC_DXT5_Format;
|
|
55155
|
+
exports.RGBDepthPacking = RGBDepthPacking;
|
|
54389
55156
|
exports.RGBFormat = RGBFormat;
|
|
55157
|
+
exports.RGBIntegerFormat = RGBIntegerFormat;
|
|
54390
55158
|
exports.RGB_BPTC_SIGNED_Format = RGB_BPTC_SIGNED_Format;
|
|
54391
55159
|
exports.RGB_BPTC_UNSIGNED_Format = RGB_BPTC_UNSIGNED_Format;
|
|
54392
55160
|
exports.RGB_ETC1_Format = RGB_ETC1_Format;
|
|
@@ -54394,6 +55162,7 @@ exports.RGB_ETC2_Format = RGB_ETC2_Format;
|
|
|
54394
55162
|
exports.RGB_PVRTC_2BPPV1_Format = RGB_PVRTC_2BPPV1_Format;
|
|
54395
55163
|
exports.RGB_PVRTC_4BPPV1_Format = RGB_PVRTC_4BPPV1_Format;
|
|
54396
55164
|
exports.RGB_S3TC_DXT1_Format = RGB_S3TC_DXT1_Format;
|
|
55165
|
+
exports.RGDepthPacking = RGDepthPacking;
|
|
54397
55166
|
exports.RGFormat = RGFormat;
|
|
54398
55167
|
exports.RGIntegerFormat = RGIntegerFormat;
|
|
54399
55168
|
exports.RawShaderMaterial = RawShaderMaterial;
|
|
@@ -54454,6 +55223,7 @@ exports.TangentSpaceNormalMap = TangentSpaceNormalMap;
|
|
|
54454
55223
|
exports.TetrahedronGeometry = TetrahedronGeometry;
|
|
54455
55224
|
exports.Texture = Texture;
|
|
54456
55225
|
exports.TextureLoader = TextureLoader;
|
|
55226
|
+
exports.TextureUtils = TextureUtils;
|
|
54457
55227
|
exports.TorusGeometry = TorusGeometry;
|
|
54458
55228
|
exports.TorusKnotGeometry = TorusKnotGeometry;
|
|
54459
55229
|
exports.Triangle = Triangle;
|