@plastic-software/three 0.181.2 → 0.182.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 -4
- package/build/three.cjs +1192 -522
- package/build/three.core.js +345 -219
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +864 -328
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +15 -3
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +3660 -1545
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +3659 -1544
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/controls/MapControls.js +55 -1
- package/examples/jsm/controls/OrbitControls.js +6 -6
- package/examples/jsm/controls/TrackballControls.js +6 -6
- package/examples/jsm/csm/CSM.js +2 -1
- package/examples/jsm/environments/RoomEnvironment.js +2 -0
- package/examples/jsm/geometries/DecalGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelperGPU.js +1 -1
- package/examples/jsm/helpers/TextureHelperGPU.js +1 -1
- package/examples/jsm/inspector/Inspector.js +53 -9
- package/examples/jsm/inspector/RendererInspector.js +12 -2
- package/examples/jsm/inspector/tabs/Console.js +2 -2
- package/examples/jsm/inspector/tabs/Parameters.js +2 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Viewer.js +4 -4
- package/examples/jsm/inspector/ui/Profiler.js +1836 -31
- package/examples/jsm/inspector/ui/Style.js +948 -13
- package/examples/jsm/inspector/ui/Tab.js +188 -1
- package/examples/jsm/inspector/ui/Values.js +17 -1
- package/examples/jsm/loaders/3DMLoader.js +5 -4
- package/examples/jsm/loaders/DRACOLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +0 -2
- package/examples/jsm/loaders/HDRLoader.js +0 -1
- package/examples/jsm/loaders/KTX2Loader.js +16 -0
- package/examples/jsm/loaders/LDrawLoader.js +2 -3
- package/examples/jsm/loaders/PCDLoader.js +1 -0
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/TDSLoader.js +0 -2
- package/examples/jsm/loaders/TGALoader.js +0 -2
- package/examples/jsm/loaders/UltraHDRLoader.js +110 -137
- package/examples/jsm/loaders/VOXLoader.js +660 -117
- package/examples/jsm/loaders/VRMLLoader.js +2 -2
- package/examples/jsm/loaders/usd/USDCParser.js +1 -1
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +1 -1
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -1
- package/examples/jsm/materials/WoodNodeMaterial.js +11 -11
- package/examples/jsm/math/Octree.js +131 -1
- package/examples/jsm/misc/Volume.js +0 -1
- package/examples/jsm/misc/VolumeSlice.js +0 -1
- package/examples/jsm/objects/SkyMesh.js +13 -3
- package/examples/jsm/physics/AmmoPhysics.js +12 -7
- package/examples/jsm/physics/JoltPhysics.js +3 -1
- package/examples/jsm/physics/RapierPhysics.js +3 -1
- package/examples/jsm/postprocessing/OutputPass.js +9 -0
- package/examples/jsm/postprocessing/RenderPass.js +10 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.js +48 -18
- package/examples/jsm/renderers/Projector.js +268 -30
- package/examples/jsm/renderers/SVGRenderer.js +191 -58
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -4
- package/examples/jsm/transpiler/AST.js +44 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +61 -4
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -0
- package/examples/jsm/transpiler/TSLEncoder.js +46 -3
- package/examples/jsm/transpiler/TranspilerUtils.js +3 -3
- package/examples/jsm/transpiler/WGSLEncoder.js +27 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +2 -0
- package/examples/jsm/tsl/display/BloomNode.js +11 -1
- package/examples/jsm/tsl/display/GTAONode.js +3 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +2 -1
- package/examples/jsm/tsl/display/SSGINode.js +7 -19
- package/examples/jsm/tsl/display/SSRNode.js +1 -1
- package/examples/jsm/tsl/display/SSSNode.js +4 -2
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +8 -1
- package/examples/jsm/tsl/display/TRAANode.js +265 -114
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/utils/ShadowMapViewer.js +24 -10
- package/examples/jsm/utils/ShadowMapViewerGPU.js +1 -1
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/package.json +14 -12
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +14 -2
- package/src/animation/AnimationUtils.js +1 -12
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/ColorKeyframeTrack.js +1 -1
- package/src/animation/tracks/NumberKeyframeTrack.js +1 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/animation/tracks/VectorKeyframeTrack.js +1 -1
- package/src/constants.js +61 -5
- package/src/core/BufferGeometry.js +14 -2
- package/src/core/Raycaster.js +2 -2
- package/src/extras/PMREMGenerator.js +3 -10
- package/src/extras/TextureUtils.js +5 -1
- package/src/geometries/ExtrudeGeometry.js +2 -2
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/helpers/PointLightHelper.js +1 -1
- package/src/lights/DirectionalLight.js +13 -0
- package/src/lights/HemisphereLight.js +10 -0
- package/src/lights/Light.js +1 -11
- package/src/lights/LightProbe.js +0 -15
- package/src/lights/LightShadow.js +0 -3
- package/src/lights/PointLight.js +15 -0
- package/src/lights/PointLightShadow.js +0 -86
- package/src/lights/SpotLight.js +22 -1
- package/src/loaders/MaterialLoader.js +2 -1
- package/src/loaders/ObjectLoader.js +3 -1
- package/src/loaders/nodes/NodeLoader.js +2 -2
- package/src/materials/Material.js +2 -0
- package/src/materials/ShaderMaterial.js +20 -1
- package/src/materials/nodes/Line2NodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +3 -2
- package/src/materials/nodes/MeshStandardNodeMaterial.js +5 -4
- package/src/materials/nodes/NodeMaterial.js +59 -3
- package/src/materials/nodes/manager/NodeMaterialObserver.js +1 -1
- package/src/math/Matrix4.js +40 -40
- package/src/math/Sphere.js +1 -1
- package/src/math/Vector3.js +0 -2
- package/src/nodes/TSL.js +4 -1
- package/src/nodes/accessors/BatchNode.js +10 -10
- package/src/nodes/accessors/BufferAttributeNode.js +98 -12
- package/src/nodes/accessors/BufferNode.js +29 -2
- package/src/nodes/accessors/ClippingNode.js +4 -4
- package/src/nodes/accessors/CubeTextureNode.js +20 -1
- package/src/nodes/accessors/InstanceNode.js +69 -29
- package/src/nodes/accessors/MaterialNode.js +9 -1
- package/src/nodes/accessors/MaterialReferenceNode.js +1 -2
- package/src/nodes/accessors/ModelNode.js +1 -1
- package/src/nodes/accessors/Normal.js +2 -2
- package/src/nodes/accessors/ReferenceBaseNode.js +4 -4
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/RendererReferenceNode.js +1 -2
- package/src/nodes/accessors/SkinningNode.js +15 -2
- package/src/nodes/accessors/StorageBufferNode.js +4 -2
- package/src/nodes/accessors/Tangent.js +1 -11
- package/src/nodes/accessors/Texture3DNode.js +26 -1
- package/src/nodes/accessors/UniformArrayNode.js +2 -2
- package/src/nodes/accessors/UserDataNode.js +1 -2
- package/src/nodes/accessors/VertexColorNode.js +1 -2
- package/src/nodes/code/FunctionNode.js +1 -2
- package/src/nodes/core/ArrayNode.js +20 -1
- package/src/nodes/core/AssignNode.js +2 -2
- package/src/nodes/core/AttributeNode.js +2 -2
- package/src/nodes/core/ContextNode.js +103 -4
- package/src/nodes/core/NodeBuilder.js +56 -14
- package/src/nodes/core/NodeFrame.js +12 -4
- package/src/nodes/core/NodeUtils.js +5 -5
- package/src/nodes/core/ParameterNode.js +1 -2
- package/src/nodes/core/PropertyNode.js +19 -3
- package/src/nodes/core/StackNode.js +56 -8
- package/src/nodes/core/StructNode.js +1 -2
- package/src/nodes/core/StructTypeNode.js +11 -17
- package/src/nodes/core/UniformNode.js +19 -4
- package/src/nodes/core/VarNode.js +46 -21
- package/src/nodes/display/NormalMapNode.js +37 -2
- package/src/nodes/display/PassNode.js +77 -7
- package/src/nodes/display/ScreenNode.js +1 -0
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +3 -3
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
- package/src/nodes/functions/PhysicalLightingModel.js +102 -43
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -2
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -3
- package/src/nodes/lighting/AnalyticLightNode.js +53 -0
- package/src/nodes/lighting/LightsNode.js +2 -2
- package/src/nodes/lighting/PointShadowNode.js +141 -140
- package/src/nodes/lighting/ShadowFilterNode.js +53 -37
- package/src/nodes/lighting/ShadowNode.js +53 -19
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/pmrem/PMREMNode.js +1 -1
- package/src/nodes/tsl/TSLCore.js +4 -4
- package/src/nodes/utils/ArrayElementNode.js +13 -0
- package/src/nodes/utils/EventNode.js +1 -2
- package/src/nodes/utils/Packing.js +13 -1
- package/src/nodes/utils/PostProcessingUtils.js +33 -1
- package/src/nodes/utils/ReflectorNode.js +1 -1
- package/src/nodes/utils/SampleNode.js +1 -1
- package/src/nodes/utils/UVUtils.js +26 -0
- package/src/objects/BatchedMesh.js +5 -2
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/objects/Skeleton.js +9 -0
- package/src/renderers/WebGLRenderer.js +145 -33
- package/src/renderers/common/Backend.js +8 -0
- package/src/renderers/common/Background.js +19 -9
- package/src/renderers/common/Binding.js +11 -0
- package/src/renderers/common/Bindings.js +7 -7
- package/src/renderers/common/Buffer.js +40 -0
- package/src/renderers/common/ChainMap.js +30 -6
- package/src/renderers/common/Geometries.js +12 -0
- package/src/renderers/common/RenderContexts.js +8 -1
- package/src/renderers/common/RenderObject.js +14 -1
- package/src/renderers/common/Renderer.js +53 -35
- package/src/renderers/common/Textures.js +1 -1
- package/src/renderers/common/UniformsGroup.js +1 -0
- package/src/renderers/common/XRManager.js +1 -0
- package/src/renderers/common/extras/PMREMGenerator.js +2 -8
- package/src/renderers/common/nodes/NodeUniformBuffer.js +52 -0
- package/src/renderers/shaders/DFGLUTData.js +19 -34
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +5 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +90 -51
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +194 -186
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +3 -3
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +3 -3
- package/src/renderers/webgl/WebGLCapabilities.js +3 -4
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLOutput.js +267 -0
- package/src/renderers/webgl/WebGLProgram.js +43 -107
- package/src/renderers/webgl/WebGLPrograms.js +35 -45
- package/src/renderers/webgl/WebGLShadowMap.js +188 -25
- package/src/renderers/webgl/WebGLState.js +20 -20
- package/src/renderers/webgl/WebGLTextures.js +89 -28
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUtils.js +6 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +79 -13
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +59 -7
- package/src/renderers/webgl-fallback/utils/WebGLState.js +18 -3
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +5 -3
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -9
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +6 -2
- package/src/renderers/webgpu/WebGPUBackend.js +61 -4
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +65 -23
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +354 -186
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +20 -7
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +40 -17
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +7 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +7 -5
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +1 -1
- package/src/utils.js +13 -1
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -71
|
@@ -3167,8 +3167,8 @@ class VRMLLoader extends Loader {
|
|
|
3167
3167
|
*
|
|
3168
3168
|
* @param {BufferGeometry} geometry
|
|
3169
3169
|
* @param {number} radius
|
|
3170
|
-
* @param {
|
|
3171
|
-
* @param {
|
|
3170
|
+
* @param {Array} angles
|
|
3171
|
+
* @param {Array} colors
|
|
3172
3172
|
* @param {boolean} topDown - Whether to work top down or bottom up.
|
|
3173
3173
|
*/
|
|
3174
3174
|
function paintFaces( geometry, radius, angles, colors, topDown ) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Color } from 'three';
|
|
1
|
+
import { Color } from 'three/webgpu';
|
|
2
2
|
import { attribute, cameraProjectionMatrix, dot, float, Fn, modelViewMatrix, modelViewProjection, NodeMaterial, normalize, positionGeometry, sign, uniform, varyingProperty, vec2, vec4 } from 'three/tsl';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -297,7 +297,7 @@ const woodParams = {
|
|
|
297
297
|
teak: {
|
|
298
298
|
transformationMatrix: new THREE.Matrix4().identity(),
|
|
299
299
|
centerSize: 1.11, largeWarpScale: 0.32, largeGrainStretch: 0.24, smallWarpStrength: 0.059,
|
|
300
|
-
smallWarpScale: 2, fineWarpStrength: 0.006, fineWarpScale: 32.8, ringThickness: 1/34,
|
|
300
|
+
smallWarpScale: 2, fineWarpStrength: 0.006, fineWarpScale: 32.8, ringThickness: 1 / 34,
|
|
301
301
|
ringBias: 0.03, ringSizeVariance: 0.03, ringVarianceScale: 4.4, barkThickness: 0.3,
|
|
302
302
|
splotchScale: 0.2, splotchIntensity: 0.541, cellScale: 910, cellSize: 0.1,
|
|
303
303
|
darkGrainColor: '#0c0504', lightGrainColor: '#926c50'
|
|
@@ -305,7 +305,7 @@ const woodParams = {
|
|
|
305
305
|
walnut: {
|
|
306
306
|
transformationMatrix: new THREE.Matrix4().identity(),
|
|
307
307
|
centerSize: 1.07, largeWarpScale: 0.42, largeGrainStretch: 0.34, smallWarpStrength: 0.016,
|
|
308
|
-
smallWarpScale: 10.3, fineWarpStrength: 0.028, fineWarpScale: 12.7, ringThickness: 1/32,
|
|
308
|
+
smallWarpScale: 10.3, fineWarpStrength: 0.028, fineWarpScale: 12.7, ringThickness: 1 / 32,
|
|
309
309
|
ringBias: 0.08, ringSizeVariance: 0.03, ringVarianceScale: 5.5, barkThickness: 0.98,
|
|
310
310
|
splotchScale: 1.84, splotchIntensity: 0.97, cellScale: 710, cellSize: 0.31,
|
|
311
311
|
darkGrainColor: '#311e13', lightGrainColor: '#523424'
|
|
@@ -313,7 +313,7 @@ const woodParams = {
|
|
|
313
313
|
white_oak: {
|
|
314
314
|
transformationMatrix: new THREE.Matrix4().identity(),
|
|
315
315
|
centerSize: 1.23, largeWarpScale: 0.21, largeGrainStretch: 0.21, smallWarpStrength: 0.034,
|
|
316
|
-
smallWarpScale: 2.44, fineWarpStrength: 0.01, fineWarpScale: 14.3, ringThickness: 1/34,
|
|
316
|
+
smallWarpScale: 2.44, fineWarpStrength: 0.01, fineWarpScale: 14.3, ringThickness: 1 / 34,
|
|
317
317
|
ringBias: 0.82, ringSizeVariance: 0.16, ringVarianceScale: 1.4, barkThickness: 0.7,
|
|
318
318
|
splotchScale: 0.2, splotchIntensity: 0.541, cellScale: 800, cellSize: 0.28,
|
|
319
319
|
darkGrainColor: '#8b4c21', lightGrainColor: '#c57e43'
|
|
@@ -321,7 +321,7 @@ const woodParams = {
|
|
|
321
321
|
pine: {
|
|
322
322
|
transformationMatrix: new THREE.Matrix4().identity(),
|
|
323
323
|
centerSize: 1.23, largeWarpScale: 0.21, largeGrainStretch: 0.18, smallWarpStrength: 0.041,
|
|
324
|
-
smallWarpScale: 2.44, fineWarpStrength: 0.006, fineWarpScale: 23.2, ringThickness: 1/24,
|
|
324
|
+
smallWarpScale: 2.44, fineWarpStrength: 0.006, fineWarpScale: 23.2, ringThickness: 1 / 24,
|
|
325
325
|
ringBias: 0.1, ringSizeVariance: 0.07, ringVarianceScale: 5, barkThickness: 0.35,
|
|
326
326
|
splotchScale: 0.51, splotchIntensity: 3.32, cellScale: 1480, cellSize: 0.07,
|
|
327
327
|
darkGrainColor: '#c58355', lightGrainColor: '#d19d61'
|
|
@@ -329,7 +329,7 @@ const woodParams = {
|
|
|
329
329
|
poplar: {
|
|
330
330
|
transformationMatrix: new THREE.Matrix4().identity(),
|
|
331
331
|
centerSize: 1.43, largeWarpScale: 0.33, largeGrainStretch: 0.18, smallWarpStrength: 0.04,
|
|
332
|
-
smallWarpScale: 4.3, fineWarpStrength: 0.004, fineWarpScale: 33.6, ringThickness: 1/37,
|
|
332
|
+
smallWarpScale: 4.3, fineWarpStrength: 0.004, fineWarpScale: 33.6, ringThickness: 1 / 37,
|
|
333
333
|
ringBias: 0.07, ringSizeVariance: 0.03, ringVarianceScale: 3.8, barkThickness: 0.3,
|
|
334
334
|
splotchScale: 1.92, splotchIntensity: 0.71, cellScale: 830, cellSize: 0.04,
|
|
335
335
|
darkGrainColor: '#716347', lightGrainColor: '#998966'
|
|
@@ -337,7 +337,7 @@ const woodParams = {
|
|
|
337
337
|
maple: {
|
|
338
338
|
transformationMatrix: new THREE.Matrix4().identity(),
|
|
339
339
|
centerSize: 1.4, largeWarpScale: 0.38, largeGrainStretch: 0.25, smallWarpStrength: 0.067,
|
|
340
|
-
smallWarpScale: 2.5, fineWarpStrength: 0.005, fineWarpScale: 33.6, ringThickness: 1/35,
|
|
340
|
+
smallWarpScale: 2.5, fineWarpStrength: 0.005, fineWarpScale: 33.6, ringThickness: 1 / 35,
|
|
341
341
|
ringBias: 0.1, ringSizeVariance: 0.07, ringVarianceScale: 4.6, barkThickness: 0.61,
|
|
342
342
|
splotchScale: 0.46, splotchIntensity: 1.49, cellScale: 800, cellSize: 0.03,
|
|
343
343
|
darkGrainColor: '#b08969', lightGrainColor: '#bc9d7d'
|
|
@@ -345,7 +345,7 @@ const woodParams = {
|
|
|
345
345
|
red_oak: {
|
|
346
346
|
transformationMatrix: new THREE.Matrix4().identity(),
|
|
347
347
|
centerSize: 1.21, largeWarpScale: 0.24, largeGrainStretch: 0.25, smallWarpStrength: 0.044,
|
|
348
|
-
smallWarpScale: 2.54, fineWarpStrength: 0.01, fineWarpScale: 14.5, ringThickness: 1/34,
|
|
348
|
+
smallWarpScale: 2.54, fineWarpStrength: 0.01, fineWarpScale: 14.5, ringThickness: 1 / 34,
|
|
349
349
|
ringBias: 0.92, ringSizeVariance: 0.03, ringVarianceScale: 5.6, barkThickness: 1.01,
|
|
350
350
|
splotchScale: 0.28, splotchIntensity: 3.48, cellScale: 800, cellSize: 0.25,
|
|
351
351
|
darkGrainColor: '#af613b', lightGrainColor: '#e0a27a'
|
|
@@ -353,7 +353,7 @@ const woodParams = {
|
|
|
353
353
|
cherry: {
|
|
354
354
|
transformationMatrix: new THREE.Matrix4().identity(),
|
|
355
355
|
centerSize: 1.33, largeWarpScale: 0.11, largeGrainStretch: 0.33, smallWarpStrength: 0.024,
|
|
356
|
-
smallWarpScale: 2.48, fineWarpStrength: 0.01, fineWarpScale: 15.3, ringThickness: 1/36,
|
|
356
|
+
smallWarpScale: 2.48, fineWarpStrength: 0.01, fineWarpScale: 15.3, ringThickness: 1 / 36,
|
|
357
357
|
ringBias: 0.02, ringSizeVariance: 0.04, ringVarianceScale: 6.5, barkThickness: 0.09,
|
|
358
358
|
splotchScale: 1.27, splotchIntensity: 1.24, cellScale: 1530, cellSize: 0.15,
|
|
359
359
|
darkGrainColor: '#913f27', lightGrainColor: '#b45837'
|
|
@@ -361,7 +361,7 @@ const woodParams = {
|
|
|
361
361
|
cedar: {
|
|
362
362
|
transformationMatrix: new THREE.Matrix4().identity(),
|
|
363
363
|
centerSize: 1.11, largeWarpScale: 0.39, largeGrainStretch: 0.12, smallWarpStrength: 0.061,
|
|
364
|
-
smallWarpScale: 1.9, fineWarpStrength: 0.006, fineWarpScale: 4.8, ringThickness: 1/25,
|
|
364
|
+
smallWarpScale: 1.9, fineWarpStrength: 0.006, fineWarpScale: 4.8, ringThickness: 1 / 25,
|
|
365
365
|
ringBias: 0.01, ringSizeVariance: 0.07, ringVarianceScale: 6.7, barkThickness: 0.1,
|
|
366
366
|
splotchScale: 0.61, splotchIntensity: 2.54, cellScale: 630, cellSize: 0.19,
|
|
367
367
|
darkGrainColor: '#9a5b49', lightGrainColor: '#ae745e'
|
|
@@ -369,7 +369,7 @@ const woodParams = {
|
|
|
369
369
|
mahogany: {
|
|
370
370
|
transformationMatrix: new THREE.Matrix4().identity(),
|
|
371
371
|
centerSize: 1.25, largeWarpScale: 0.26, largeGrainStretch: 0.29, smallWarpStrength: 0.044,
|
|
372
|
-
smallWarpScale: 2.54, fineWarpStrength: 0.01, fineWarpScale: 15.3, ringThickness: 1/38,
|
|
372
|
+
smallWarpScale: 2.54, fineWarpStrength: 0.01, fineWarpScale: 15.3, ringThickness: 1 / 38,
|
|
373
373
|
ringBias: 0.01, ringSizeVariance: 0.33, ringVarianceScale: 1.2, barkThickness: 0.07,
|
|
374
374
|
splotchScale: 0.77, splotchIntensity: 1.39, cellScale: 1400, cellSize: 0.23,
|
|
375
375
|
darkGrainColor: '#501d12', lightGrainColor: '#6d3722'
|
|
@@ -433,7 +433,7 @@ uniforms.lightGrainColor = TSL.uniform( new THREE.Color( params.lightGrainColor
|
|
|
433
433
|
uniforms.transformationMatrix = TSL.uniform( new THREE.Matrix4().copy( params.transformationMatrix ) ).onObjectUpdate( ( { material } ) => material.transformationMatrix );
|
|
434
434
|
|
|
435
435
|
const colorNode = wood(
|
|
436
|
-
uniforms.transformationMatrix.mul( TSL.vec4(TSL.positionLocal, 1) ).xyz,
|
|
436
|
+
uniforms.transformationMatrix.mul( TSL.vec4( TSL.positionLocal, 1 ) ).xyz,
|
|
437
437
|
uniforms.centerSize,
|
|
438
438
|
uniforms.largeWarpScale,
|
|
439
439
|
uniforms.largeGrainStretch,
|
|
@@ -17,8 +17,10 @@ const _point2 = new Vector3();
|
|
|
17
17
|
const _plane = new Plane();
|
|
18
18
|
const _line1 = new Line3();
|
|
19
19
|
const _line2 = new Line3();
|
|
20
|
+
const _box = new Box3();
|
|
20
21
|
const _sphere = new Sphere();
|
|
21
22
|
const _capsule = new Capsule();
|
|
23
|
+
const _center = new Vector3();
|
|
22
24
|
|
|
23
25
|
const _temp1 = new Vector3();
|
|
24
26
|
const _temp2 = new Vector3();
|
|
@@ -373,6 +375,61 @@ class Octree {
|
|
|
373
375
|
|
|
374
376
|
}
|
|
375
377
|
|
|
378
|
+
/**
|
|
379
|
+
* Computes the intersection between the given bounding box and triangle.
|
|
380
|
+
*
|
|
381
|
+
* @param {Box3} box - The bounding box to test.
|
|
382
|
+
* @param {Triangle} triangle - The triangle to test.
|
|
383
|
+
* @return {Object|false} The intersection object. If no intersection
|
|
384
|
+
* is detected, the method returns `false`.
|
|
385
|
+
*/
|
|
386
|
+
triangleBoxIntersect( box, triangle ) {
|
|
387
|
+
|
|
388
|
+
// cheap check
|
|
389
|
+
|
|
390
|
+
if ( Math.max( triangle.a.x, triangle.b.x, triangle.c.x ) < box.min.x ||
|
|
391
|
+
Math.min( triangle.a.x, triangle.b.x, triangle.c.x ) > box.max.x ||
|
|
392
|
+
Math.max( triangle.a.y, triangle.b.y, triangle.c.y ) < box.min.y ||
|
|
393
|
+
Math.min( triangle.a.y, triangle.b.y, triangle.c.y ) > box.max.y ||
|
|
394
|
+
Math.max( triangle.a.z, triangle.b.z, triangle.c.z ) < box.min.z ||
|
|
395
|
+
Math.min( triangle.a.z, triangle.b.z, triangle.c.z ) > box.max.z ) {
|
|
396
|
+
|
|
397
|
+
return false;
|
|
398
|
+
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// expensive check
|
|
402
|
+
|
|
403
|
+
if ( ! box.intersectsTriangle( triangle ) ) return false;
|
|
404
|
+
|
|
405
|
+
// there is an intersection, now compute collision data
|
|
406
|
+
|
|
407
|
+
triangle.getPlane( _plane );
|
|
408
|
+
|
|
409
|
+
// determine which corner of the box is "deepest" into the plane
|
|
410
|
+
|
|
411
|
+
_v1.x = ( _plane.normal.x > 0 ) ? box.min.x : box.max.x;
|
|
412
|
+
_v1.y = ( _plane.normal.y > 0 ) ? box.min.y : box.max.y;
|
|
413
|
+
_v1.z = ( _plane.normal.z > 0 ) ? box.min.z : box.max.z;
|
|
414
|
+
|
|
415
|
+
// Calculate the distance from the plane to that corner (the distance will be negative
|
|
416
|
+
// because of the intersection)
|
|
417
|
+
|
|
418
|
+
const distance = _plane.distanceToPoint( _v1 );
|
|
419
|
+
|
|
420
|
+
const intersection = {
|
|
421
|
+
depth: - distance, // Flip sign so depth is positive
|
|
422
|
+
normal: _plane.normal.clone(),
|
|
423
|
+
point: _v1.clone()
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
// project the point onto the triangle surface
|
|
427
|
+
intersection.point.addScaledVector( intersection.normal, distance );
|
|
428
|
+
|
|
429
|
+
return intersection;
|
|
430
|
+
|
|
431
|
+
}
|
|
432
|
+
|
|
376
433
|
/**
|
|
377
434
|
* Computes the intersection between the given sphere and triangle.
|
|
378
435
|
*
|
|
@@ -455,6 +512,38 @@ class Octree {
|
|
|
455
512
|
|
|
456
513
|
}
|
|
457
514
|
|
|
515
|
+
/**
|
|
516
|
+
* Computes the triangles that potentially intersect with the given bounding box.
|
|
517
|
+
*
|
|
518
|
+
* @param {Box3} box - The bounding box.
|
|
519
|
+
* @param {Array<Triangle>} triangles - The target array that holds the triangles.
|
|
520
|
+
*/
|
|
521
|
+
getBoxTriangles( box, triangles ) {
|
|
522
|
+
|
|
523
|
+
for ( let i = 0; i < this.subTrees.length; i ++ ) {
|
|
524
|
+
|
|
525
|
+
const subTree = this.subTrees[ i ];
|
|
526
|
+
|
|
527
|
+
if ( ! box.intersectsBox( subTree.box ) ) continue;
|
|
528
|
+
|
|
529
|
+
if ( subTree.triangles.length > 0 ) {
|
|
530
|
+
|
|
531
|
+
for ( let j = 0; j < subTree.triangles.length; j ++ ) {
|
|
532
|
+
|
|
533
|
+
if ( triangles.indexOf( subTree.triangles[ j ] ) === - 1 ) triangles.push( subTree.triangles[ j ] );
|
|
534
|
+
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
} else {
|
|
538
|
+
|
|
539
|
+
subTree.getBoxTriangles( box, triangles );
|
|
540
|
+
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
}
|
|
546
|
+
|
|
458
547
|
/**
|
|
459
548
|
* Computes the triangles that potentially intersect with the given capsule.
|
|
460
549
|
*
|
|
@@ -487,6 +576,47 @@ class Octree {
|
|
|
487
576
|
|
|
488
577
|
}
|
|
489
578
|
|
|
579
|
+
/**
|
|
580
|
+
* Performs a bounding box intersection test with this Octree.
|
|
581
|
+
*
|
|
582
|
+
* @param {Box3} box - The bounding box to test.
|
|
583
|
+
* @return {Object|boolean} The intersection object. If no intersection
|
|
584
|
+
* is detected, the method returns `false`.
|
|
585
|
+
*/
|
|
586
|
+
boxIntersect( box ) {
|
|
587
|
+
|
|
588
|
+
_box.copy( box );
|
|
589
|
+
|
|
590
|
+
const triangles = [];
|
|
591
|
+
let result, hit = false;
|
|
592
|
+
|
|
593
|
+
this.getBoxTriangles( box, triangles );
|
|
594
|
+
|
|
595
|
+
for ( let i = 0; i < triangles.length; i ++ ) {
|
|
596
|
+
|
|
597
|
+
if ( result = this.triangleBoxIntersect( _box, triangles[ i ] ) ) {
|
|
598
|
+
|
|
599
|
+
hit = true;
|
|
600
|
+
|
|
601
|
+
_box.translate( result.normal.multiplyScalar( result.depth ) );
|
|
602
|
+
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
if ( hit ) {
|
|
608
|
+
|
|
609
|
+
const collisionVector = _box.getCenter( _center ).sub( box.getCenter( _v1 ) );
|
|
610
|
+
const depth = collisionVector.length();
|
|
611
|
+
|
|
612
|
+
return { normal: collisionVector.normalize(), depth: depth };
|
|
613
|
+
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
return false;
|
|
617
|
+
|
|
618
|
+
}
|
|
619
|
+
|
|
490
620
|
/**
|
|
491
621
|
* Performs a bounding sphere intersection test with this Octree.
|
|
492
622
|
*
|
|
@@ -558,7 +688,7 @@ class Octree {
|
|
|
558
688
|
|
|
559
689
|
if ( hit ) {
|
|
560
690
|
|
|
561
|
-
const collisionVector = _capsule.getCenter(
|
|
691
|
+
const collisionVector = _capsule.getCenter( _center ).sub( capsule.getCenter( _v1 ) );
|
|
562
692
|
const depth = collisionVector.length();
|
|
563
693
|
|
|
564
694
|
return { normal: collisionVector.normalize(), depth: depth };
|
|
@@ -12,8 +12,8 @@ import { Fn, float, vec3, acos, add, mul, clamp, cos, dot, exp, max, mix, modelV
|
|
|
12
12
|
* Represents a skydome for scene backgrounds. Based on [A Practical Analytic Model for Daylight](https://www.researchgate.net/publication/220720443_A_Practical_Analytic_Model_for_Daylight)
|
|
13
13
|
* aka The Preetham Model, the de facto standard for analytical skydomes.
|
|
14
14
|
*
|
|
15
|
-
* Note that this class can only be used with {@link
|
|
16
|
-
* When using {@link
|
|
15
|
+
* Note that this class can only be used with {@link WebGPURenderer}.
|
|
16
|
+
* When using {@link WebGLRenderer}, use {@link Sky}.
|
|
17
17
|
*
|
|
18
18
|
* More references:
|
|
19
19
|
*
|
|
@@ -88,8 +88,18 @@ class SkyMesh extends Mesh {
|
|
|
88
88
|
* @type {boolean}
|
|
89
89
|
* @readonly
|
|
90
90
|
* @default true
|
|
91
|
+
* @deprecated Use isSkyMesh instead.
|
|
91
92
|
*/
|
|
92
|
-
this.isSky = true;
|
|
93
|
+
this.isSky = true; // @deprecated, r182
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* This flag can be used for type testing.
|
|
97
|
+
*
|
|
98
|
+
* @type {boolean}
|
|
99
|
+
* @readonly
|
|
100
|
+
* @default true
|
|
101
|
+
*/
|
|
102
|
+
this.isSkyMesh = true;
|
|
93
103
|
|
|
94
104
|
// Varyings
|
|
95
105
|
|
|
@@ -23,7 +23,7 @@ async function AmmoPhysics() {
|
|
|
23
23
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const AmmoLib = await Ammo();
|
|
26
|
+
const AmmoLib = await Ammo();
|
|
27
27
|
|
|
28
28
|
const frameRate = 60;
|
|
29
29
|
|
|
@@ -66,6 +66,8 @@ async function AmmoPhysics() {
|
|
|
66
66
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
console.error( 'AmmoPhysics: Unsupported geometry type:', geometry.type );
|
|
70
|
+
|
|
69
71
|
return null;
|
|
70
72
|
|
|
71
73
|
}
|
|
@@ -83,7 +85,7 @@ async function AmmoPhysics() {
|
|
|
83
85
|
|
|
84
86
|
if ( physics ) {
|
|
85
87
|
|
|
86
|
-
addMesh( child, physics.mass );
|
|
88
|
+
addMesh( child, physics.mass, physics.restitution );
|
|
87
89
|
|
|
88
90
|
}
|
|
89
91
|
|
|
@@ -93,7 +95,7 @@ async function AmmoPhysics() {
|
|
|
93
95
|
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
function addMesh( mesh, mass = 0 ) {
|
|
98
|
+
function addMesh( mesh, mass = 0, restitution = 0 ) {
|
|
97
99
|
|
|
98
100
|
const shape = getShape( mesh.geometry );
|
|
99
101
|
|
|
@@ -101,11 +103,11 @@ async function AmmoPhysics() {
|
|
|
101
103
|
|
|
102
104
|
if ( mesh.isInstancedMesh ) {
|
|
103
105
|
|
|
104
|
-
handleInstancedMesh( mesh, mass,
|
|
106
|
+
handleInstancedMesh( mesh, shape, mass, restitution );
|
|
105
107
|
|
|
106
108
|
} else if ( mesh.isMesh ) {
|
|
107
109
|
|
|
108
|
-
handleMesh( mesh, mass,
|
|
110
|
+
handleMesh( mesh, shape, mass, restitution );
|
|
109
111
|
|
|
110
112
|
}
|
|
111
113
|
|
|
@@ -113,7 +115,7 @@ async function AmmoPhysics() {
|
|
|
113
115
|
|
|
114
116
|
}
|
|
115
117
|
|
|
116
|
-
function handleMesh( mesh, mass,
|
|
118
|
+
function handleMesh( mesh, shape, mass, restitution ) {
|
|
117
119
|
|
|
118
120
|
const position = mesh.position;
|
|
119
121
|
const quaternion = mesh.quaternion;
|
|
@@ -129,6 +131,7 @@ async function AmmoPhysics() {
|
|
|
129
131
|
shape.calculateLocalInertia( mass, localInertia );
|
|
130
132
|
|
|
131
133
|
const rbInfo = new AmmoLib.btRigidBodyConstructionInfo( mass, motionState, shape, localInertia );
|
|
134
|
+
rbInfo.set_m_restitution( restitution );
|
|
132
135
|
|
|
133
136
|
const body = new AmmoLib.btRigidBody( rbInfo );
|
|
134
137
|
// body.setFriction( 4 );
|
|
@@ -144,7 +147,7 @@ async function AmmoPhysics() {
|
|
|
144
147
|
|
|
145
148
|
}
|
|
146
149
|
|
|
147
|
-
function handleInstancedMesh( mesh, mass,
|
|
150
|
+
function handleInstancedMesh( mesh, shape, mass, restitution ) {
|
|
148
151
|
|
|
149
152
|
const array = mesh.instanceMatrix.array;
|
|
150
153
|
|
|
@@ -163,6 +166,7 @@ async function AmmoPhysics() {
|
|
|
163
166
|
shape.calculateLocalInertia( mass, localInertia );
|
|
164
167
|
|
|
165
168
|
const rbInfo = new AmmoLib.btRigidBodyConstructionInfo( mass, motionState, shape, localInertia );
|
|
169
|
+
rbInfo.set_m_restitution( restitution );
|
|
166
170
|
|
|
167
171
|
const body = new AmmoLib.btRigidBody( rbInfo );
|
|
168
172
|
world.addRigidBody( body );
|
|
@@ -302,6 +306,7 @@ async function AmmoPhysics() {
|
|
|
302
306
|
* @name AmmoPhysics#addMesh
|
|
303
307
|
* @param {Mesh} mesh The mesh to add.
|
|
304
308
|
* @param {number} [mass=0] The mass in kg of the mesh.
|
|
309
|
+
* @param {number} [restitution=0] The restitution of the mesh, usually from 0 to 1. Represents how "bouncy" objects are when they collide with each other.
|
|
305
310
|
*/
|
|
306
311
|
addMesh: addMesh,
|
|
307
312
|
|
|
@@ -28,6 +28,8 @@ function getShape( geometry ) {
|
|
|
28
28
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
console.error( 'JoltPhysics: Unsupported geometry type:', geometry.type );
|
|
32
|
+
|
|
31
33
|
return null;
|
|
32
34
|
|
|
33
35
|
}
|
|
@@ -305,7 +307,7 @@ async function JoltPhysics() {
|
|
|
305
307
|
* @name JoltPhysics#addMesh
|
|
306
308
|
* @param {Mesh} mesh The mesh to add.
|
|
307
309
|
* @param {number} [mass=0] The mass in kg of the mesh.
|
|
308
|
-
* @param {number} [restitution=0] The restitution
|
|
310
|
+
* @param {number} [restitution=0] The restitution of the mesh, usually from 0 to 1. Represents how "bouncy" objects are when they collide with each other.
|
|
309
311
|
*/
|
|
310
312
|
addMesh: addMesh,
|
|
311
313
|
|
|
@@ -73,6 +73,8 @@ function getShape( geometry ) {
|
|
|
73
73
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
console.error( 'RapierPhysics: Unsupported geometry type:', geometry.type );
|
|
77
|
+
|
|
76
78
|
return null;
|
|
77
79
|
|
|
78
80
|
}
|
|
@@ -372,7 +374,7 @@ async function RapierPhysics() {
|
|
|
372
374
|
* @name RapierPhysics#addMesh
|
|
373
375
|
* @param {Mesh} mesh The mesh to add.
|
|
374
376
|
* @param {number} [mass=0] The mass in kg of the mesh.
|
|
375
|
-
* @param {number} [restitution=0] The restitution
|
|
377
|
+
* @param {number} [restitution=0] The restitution of the mesh, usually from 0 to 1. Represents how "bouncy" objects are when they collide with each other.
|
|
376
378
|
*/
|
|
377
379
|
addMesh: addMesh,
|
|
378
380
|
|
|
@@ -93,6 +93,16 @@ class RenderPass extends Pass {
|
|
|
93
93
|
* @default false
|
|
94
94
|
*/
|
|
95
95
|
this.needsSwap = false;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* This flag indicates that this pass renders the scene itself.
|
|
99
|
+
*
|
|
100
|
+
* @type {boolean}
|
|
101
|
+
* @readonly
|
|
102
|
+
* @default true
|
|
103
|
+
*/
|
|
104
|
+
this.isRenderPass = true;
|
|
105
|
+
|
|
96
106
|
this._oldClearColor = new Color();
|
|
97
107
|
|
|
98
108
|
}
|
|
@@ -56,7 +56,7 @@ class UnrealBloomPass extends Pass {
|
|
|
56
56
|
this.strength = strength;
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
* The Bloom radius.
|
|
59
|
+
* The Bloom radius. Must be in the range `[0,1]`.
|
|
60
60
|
*
|
|
61
61
|
* @type {number}
|
|
62
62
|
*/
|
|
@@ -187,6 +187,7 @@ class UnrealBloomPass extends Pass {
|
|
|
187
187
|
uniforms: this.copyUniforms,
|
|
188
188
|
vertexShader: CopyShader.vertexShader,
|
|
189
189
|
fragmentShader: CopyShader.fragmentShader,
|
|
190
|
+
premultipliedAlpha: true,
|
|
190
191
|
blending: AdditiveBlending,
|
|
191
192
|
depthTest: false,
|
|
192
193
|
depthWrite: false,
|
|
@@ -399,33 +400,46 @@ class UnrealBloomPass extends Pass {
|
|
|
399
400
|
'gaussianCoefficients': { value: coefficients } // precomputed Gaussian coefficients
|
|
400
401
|
},
|
|
401
402
|
|
|
402
|
-
vertexShader:
|
|
403
|
-
|
|
403
|
+
vertexShader: /* glsl */`
|
|
404
|
+
|
|
405
|
+
varying vec2 vUv;
|
|
406
|
+
|
|
404
407
|
void main() {
|
|
408
|
+
|
|
405
409
|
vUv = uv;
|
|
406
410
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
411
|
+
|
|
407
412
|
}`,
|
|
408
413
|
|
|
409
|
-
fragmentShader:
|
|
410
|
-
|
|
414
|
+
fragmentShader: /* glsl */`
|
|
415
|
+
|
|
416
|
+
#include <common>
|
|
417
|
+
|
|
411
418
|
varying vec2 vUv;
|
|
419
|
+
|
|
412
420
|
uniform sampler2D colorTexture;
|
|
413
421
|
uniform vec2 invSize;
|
|
414
422
|
uniform vec2 direction;
|
|
415
423
|
uniform float gaussianCoefficients[KERNEL_RADIUS];
|
|
416
424
|
|
|
417
425
|
void main() {
|
|
426
|
+
|
|
418
427
|
float weightSum = gaussianCoefficients[0];
|
|
419
428
|
vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;
|
|
420
|
-
|
|
421
|
-
|
|
429
|
+
|
|
430
|
+
for ( int i = 1; i < KERNEL_RADIUS; i ++ ) {
|
|
431
|
+
|
|
432
|
+
float x = float( i );
|
|
422
433
|
float w = gaussianCoefficients[i];
|
|
423
434
|
vec2 uvOffset = direction * invSize * x;
|
|
424
435
|
vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;
|
|
425
436
|
vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;
|
|
426
437
|
diffuseSum += ( sample1 + sample2 ) * w;
|
|
438
|
+
|
|
427
439
|
}
|
|
440
|
+
|
|
428
441
|
gl_FragColor = vec4( diffuseSum, 1.0 );
|
|
442
|
+
|
|
429
443
|
}`
|
|
430
444
|
} );
|
|
431
445
|
|
|
@@ -451,15 +465,21 @@ class UnrealBloomPass extends Pass {
|
|
|
451
465
|
'bloomRadius': { value: 0.0 }
|
|
452
466
|
},
|
|
453
467
|
|
|
454
|
-
vertexShader:
|
|
455
|
-
|
|
468
|
+
vertexShader: /* glsl */`
|
|
469
|
+
|
|
470
|
+
varying vec2 vUv;
|
|
471
|
+
|
|
456
472
|
void main() {
|
|
473
|
+
|
|
457
474
|
vUv = uv;
|
|
458
475
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
476
|
+
|
|
459
477
|
}`,
|
|
460
478
|
|
|
461
|
-
fragmentShader:
|
|
462
|
-
|
|
479
|
+
fragmentShader: /* glsl */`
|
|
480
|
+
|
|
481
|
+
varying vec2 vUv;
|
|
482
|
+
|
|
463
483
|
uniform sampler2D blurTexture1;
|
|
464
484
|
uniform sampler2D blurTexture2;
|
|
465
485
|
uniform sampler2D blurTexture3;
|
|
@@ -470,17 +490,27 @@ class UnrealBloomPass extends Pass {
|
|
|
470
490
|
uniform float bloomFactors[NUM_MIPS];
|
|
471
491
|
uniform vec3 bloomTintColors[NUM_MIPS];
|
|
472
492
|
|
|
473
|
-
float lerpBloomFactor(const in float factor) {
|
|
493
|
+
float lerpBloomFactor( const in float factor ) {
|
|
494
|
+
|
|
474
495
|
float mirrorFactor = 1.2 - factor;
|
|
475
|
-
return mix(factor, mirrorFactor, bloomRadius);
|
|
496
|
+
return mix( factor, mirrorFactor, bloomRadius );
|
|
497
|
+
|
|
476
498
|
}
|
|
477
499
|
|
|
478
500
|
void main() {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
lerpBloomFactor(bloomFactors[
|
|
483
|
-
lerpBloomFactor(bloomFactors[
|
|
501
|
+
|
|
502
|
+
// 3.0 for backwards compatibility with previous alpha-based intensity
|
|
503
|
+
vec3 bloom = 3.0 * bloomStrength * (
|
|
504
|
+
lerpBloomFactor( bloomFactors[ 0 ] ) * bloomTintColors[ 0 ] * texture2D( blurTexture1, vUv ).rgb +
|
|
505
|
+
lerpBloomFactor( bloomFactors[ 1 ] ) * bloomTintColors[ 1 ] * texture2D( blurTexture2, vUv ).rgb +
|
|
506
|
+
lerpBloomFactor( bloomFactors[ 2 ] ) * bloomTintColors[ 2 ] * texture2D( blurTexture3, vUv ).rgb +
|
|
507
|
+
lerpBloomFactor( bloomFactors[ 3 ] ) * bloomTintColors[ 3 ] * texture2D( blurTexture4, vUv ).rgb +
|
|
508
|
+
lerpBloomFactor( bloomFactors[ 4 ] ) * bloomTintColors[ 4 ] * texture2D( blurTexture5, vUv ).rgb
|
|
509
|
+
);
|
|
510
|
+
|
|
511
|
+
float bloomAlpha = max( bloom.r, max( bloom.g, bloom.b ) );
|
|
512
|
+
gl_FragColor = vec4( bloom, bloomAlpha );
|
|
513
|
+
|
|
484
514
|
}`
|
|
485
515
|
} );
|
|
486
516
|
|