super-three 0.169.0 → 0.170.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/build/three.cjs +989 -1131
- package/build/three.module.js +990 -1128
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +8398 -9842
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +8398 -9842
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +3 -3
- package/examples/jsm/animation/MMDAnimationHelper.js +2 -0
- package/examples/jsm/animation/MMDPhysics.js +2 -0
- package/examples/jsm/controls/TransformControls.js +22 -6
- package/examples/jsm/csm/CSM.js +2 -2
- package/examples/jsm/csm/CSMFrustum.js +7 -4
- package/examples/jsm/csm/CSMHelper.js +2 -0
- package/examples/jsm/csm/CSMShadowNode.js +435 -0
- package/examples/jsm/curves/NURBSCurve.js +34 -3
- package/examples/jsm/exporters/GLTFExporter.js +138 -71
- package/examples/jsm/exporters/KTX2Exporter.js +35 -12
- package/examples/jsm/exporters/MMDExporter.js +6 -0
- package/examples/jsm/exporters/USDZExporter.js +21 -3
- package/examples/jsm/geometries/DecalGeometry.js +65 -20
- package/examples/jsm/geometries/InstancedPointsGeometry.js +2 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +175 -0
- package/examples/jsm/interactive/HTMLMesh.js +1 -0
- package/examples/jsm/lighting/TiledLighting.js +18 -0
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/lines/LineMaterial.js +7 -2
- package/examples/jsm/lines/LineSegmentsGeometry.js +2 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +0 -15
- package/examples/jsm/lines/webgpu/Wireframe.js +56 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -0
- package/examples/jsm/loaders/3MFLoader.js +91 -0
- package/examples/jsm/loaders/FBXLoader.js +12 -2
- package/examples/jsm/loaders/GLTFLoader.js +2 -0
- package/examples/jsm/loaders/KTX2Loader.js +140 -49
- package/examples/jsm/loaders/LDrawLoader.js +22 -136
- package/examples/jsm/loaders/LottieLoader.js +1 -0
- package/examples/jsm/loaders/MMDLoader.js +9 -2
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +143 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +114 -0
- package/examples/jsm/materials/MeshGouraudMaterial.js +6 -2
- package/examples/jsm/math/ColorSpaces.js +76 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +52 -40
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +293 -0
- package/examples/jsm/misc/VolumeSlice.js +1 -0
- package/examples/jsm/objects/WaterMesh.js +8 -8
- package/examples/jsm/postprocessing/AfterimagePass.js +14 -3
- package/examples/jsm/postprocessing/SSRPass.js +6 -0
- package/examples/jsm/renderers/CSS2DRenderer.js +6 -3
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -4
- package/examples/jsm/shaders/FXAAShader.js +225 -224
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/{src/nodes → examples/jsm/tsl}/display/AfterImageNode.js +17 -20
- package/{src/nodes → examples/jsm/tsl}/display/AnaglyphPassNode.js +2 -6
- package/{src/nodes → examples/jsm/tsl}/display/AnamorphicNode.js +12 -18
- package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +1 -3
- package/{src/nodes → examples/jsm/tsl}/display/BloomNode.js +11 -40
- package/{src/nodes → examples/jsm/tsl}/display/DenoiseNode.js +18 -41
- package/{src/nodes → examples/jsm/tsl}/display/DepthOfFieldNode.js +2 -8
- package/{src/nodes → examples/jsm/tsl}/display/DotScreenNode.js +2 -9
- package/examples/jsm/tsl/display/FXAANode.js +316 -0
- package/{src/nodes → examples/jsm/tsl}/display/FilmNode.js +2 -6
- package/{src/nodes → examples/jsm/tsl}/display/GTAONode.js +30 -70
- package/{src/nodes → examples/jsm/tsl}/display/GaussianBlurNode.js +74 -36
- package/examples/jsm/tsl/display/LensflareNode.js +161 -0
- package/{src/nodes → examples/jsm/tsl}/display/Lut3DNode.js +1 -4
- package/{src/nodes → examples/jsm/tsl}/display/MotionBlur.js +2 -3
- package/examples/jsm/tsl/display/OutlineNode.js +434 -0
- package/{src/nodes → examples/jsm/tsl}/display/ParallaxBarrierPassNode.js +1 -5
- package/{src/nodes → examples/jsm/tsl}/display/PixelationPassNode.js +3 -15
- package/{src/nodes → examples/jsm/tsl}/display/RGBShiftNode.js +1 -6
- package/examples/jsm/tsl/display/SMAANode.js +620 -0
- package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +10 -25
- package/examples/jsm/tsl/display/SSRNode.js +343 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +1 -2
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +3 -11
- package/{src/nodes → examples/jsm/tsl}/display/StereoCompositePassNode.js +9 -11
- package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +10 -11
- package/examples/jsm/tsl/display/TRAAPassNode.js +355 -0
- package/{src/nodes → examples/jsm/tsl}/display/TransitionNode.js +1 -6
- package/examples/jsm/tsl/display/hashBlur.js +24 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +392 -0
- package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +2 -1
- package/examples/jsm/webxr/OculusHandPointerModel.js +21 -21
- package/examples/jsm/webxr/Text2D.js +6 -6
- package/package.json +2 -2
- package/src/Three.WebGPU.Nodes.js +4 -0
- package/src/Three.WebGPU.js +4 -0
- package/src/constants.js +1 -6
- package/src/core/BufferGeometry.js +44 -6
- package/src/geometries/CylinderGeometry.js +2 -2
- package/src/materials/LineBasicMaterial.js +6 -2
- package/src/materials/LineDashedMaterial.js +6 -2
- package/src/materials/Material.js +14 -1
- package/src/materials/MeshBasicMaterial.js +6 -2
- package/src/materials/MeshDepthMaterial.js +6 -2
- package/src/materials/MeshDistanceMaterial.js +6 -2
- package/src/materials/MeshLambertMaterial.js +6 -2
- package/src/materials/MeshMatcapMaterial.js +6 -2
- package/src/materials/MeshNormalMaterial.js +6 -2
- package/src/materials/MeshPhongMaterial.js +6 -2
- package/src/materials/MeshPhysicalMaterial.js +6 -2
- package/src/materials/MeshStandardMaterial.js +6 -2
- package/src/materials/MeshToonMaterial.js +6 -2
- package/src/materials/PointsMaterial.js +6 -2
- package/src/materials/RawShaderMaterial.js +6 -2
- package/src/materials/ShaderMaterial.js +6 -2
- package/src/materials/ShadowMaterial.js +6 -2
- package/src/materials/SpriteMaterial.js +6 -2
- package/src/materials/nodes/NodeMaterial.js +31 -9
- package/src/materials/nodes/SpriteNodeMaterial.js +11 -2
- package/src/materials/nodes/manager/NodeMaterialObserver.js +111 -2
- package/src/math/ColorManagement.js +118 -85
- package/src/math/Vector4.js +11 -0
- package/src/nodes/Nodes.js +1 -21
- package/src/nodes/TSL.js +6 -24
- package/src/nodes/accessors/Camera.js +0 -1
- package/src/nodes/accessors/SceneNode.js +35 -1
- package/src/nodes/accessors/StorageBufferNode.js +32 -10
- package/src/nodes/accessors/VelocityNode.js +13 -3
- package/src/nodes/code/FunctionCallNode.js +16 -5
- package/src/nodes/code/ScriptableNode.js +4 -4
- package/src/nodes/core/Node.js +1 -0
- package/src/nodes/core/NodeBuilder.js +29 -5
- package/src/nodes/core/VarNode.js +15 -3
- package/src/nodes/display/ColorAdjustment.js +53 -4
- package/src/nodes/display/ColorSpaceFunctions.js +5 -5
- package/src/nodes/display/ColorSpaceNode.js +27 -39
- package/src/nodes/display/PassNode.js +6 -4
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ViewportDepthNode.js +33 -1
- package/src/nodes/functions/PhysicalLightingModel.js +21 -15
- package/src/nodes/functions/material/getAlphaHashThreshold.js +64 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +8 -2
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +22 -0
- package/src/nodes/gpgpu/ComputeNode.js +9 -1
- package/src/nodes/lighting/AnalyticLightNode.js +12 -416
- package/src/nodes/lighting/LightsNode.js +24 -12
- package/src/nodes/lighting/PointLightNode.js +36 -26
- package/src/nodes/lighting/RectAreaLightNode.js +3 -0
- package/src/nodes/lighting/ShadowNode.js +484 -0
- package/src/nodes/utils/LoopNode.js +2 -2
- package/src/nodes/utils/Oscillators.js +6 -0
- package/src/nodes/utils/PostProcessingUtils.js +89 -0
- package/src/nodes/utils/ReflectorNode.js +101 -15
- package/src/nodes/utils/Timer.js +29 -0
- package/src/objects/BatchedMesh.js +458 -241
- package/src/renderers/WebGLRenderer.js +121 -126
- package/src/renderers/common/Attributes.js +4 -0
- package/src/renderers/common/Backend.js +2 -0
- package/src/renderers/common/Background.js +14 -4
- package/src/renderers/common/Bindings.js +3 -2
- package/src/renderers/common/Constants.js +2 -1
- package/src/renderers/common/Geometries.js +20 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.js +15 -0
- package/src/renderers/common/Lighting.js +45 -0
- package/src/renderers/common/PostProcessingUtils.js +86 -0
- package/src/renderers/common/RenderList.js +39 -11
- package/src/renderers/common/RenderLists.js +4 -2
- package/src/renderers/common/RenderObject.js +18 -1
- package/src/renderers/common/Renderer.js +165 -26
- package/src/renderers/common/Textures.js +30 -14
- package/src/renderers/common/nodes/NodeLibrary.js +1 -14
- package/src/renderers/common/nodes/Nodes.js +2 -2
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +0 -7
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLProgram.js +24 -28
- package/src/renderers/webgl/WebGLPrograms.js +5 -2
- package/src/renderers/webgl/WebGLState.js +37 -1
- package/src/renderers/webgl/WebGLTextures.js +29 -12
- package/src/renderers/webgl-fallback/WebGLBackend.js +98 -31
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +2 -7
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +33 -8
- package/src/renderers/webgpu/WebGPUBackend.js +105 -25
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -1
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +0 -8
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +0 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +10 -20
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +12 -4
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +29 -9
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +24 -6
- package/src/renderers/webgpu/utils/WebGPUUtils.js +0 -1
- package/src/renderers/webxr/WebXRManager.js +4 -4
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/src/nodes/display/FXAANode.js +0 -332
- package/src/nodes/utils/OscNode.js +0 -85
- package/src/nodes/utils/TimerNode.js +0 -97
- package/src/renderers/webvr/WebVRManager.js +0 -495
- package/src/renderers/webvr/WebVRUtils.js +0 -66
- /package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +0 -0
|
@@ -17,9 +17,7 @@ import {
|
|
|
17
17
|
UnsignedInt248Type,
|
|
18
18
|
UnsignedShort4444Type,
|
|
19
19
|
UnsignedShort5551Type,
|
|
20
|
-
WebGLCoordinateSystem
|
|
21
|
-
DisplayP3ColorSpace,
|
|
22
|
-
LinearDisplayP3ColorSpace
|
|
20
|
+
WebGLCoordinateSystem
|
|
23
21
|
} from '../constants.js';
|
|
24
22
|
import { Color } from '../math/Color.js';
|
|
25
23
|
import { Frustum } from '../math/Frustum.js';
|
|
@@ -52,7 +50,6 @@ import { WebGLState } from './webgl/WebGLState.js';
|
|
|
52
50
|
import { WebGLTextures } from './webgl/WebGLTextures.js';
|
|
53
51
|
import { WebGLUniforms } from './webgl/WebGLUniforms.js';
|
|
54
52
|
import { WebGLUtils } from './webgl/WebGLUtils.js';
|
|
55
|
-
import { WebVRManager } from './webvr/WebVRManager.js';
|
|
56
53
|
import { WebXRManager } from './webxr/WebXRManager.js';
|
|
57
54
|
import { WebGLMaterials } from './webgl/WebGLMaterials.js';
|
|
58
55
|
import { WebGLUniformsGroups } from './webgl/WebGLUniformsGroups.js';
|
|
@@ -74,6 +71,7 @@ class WebGLRenderer {
|
|
|
74
71
|
preserveDrawingBuffer = false,
|
|
75
72
|
powerPreference = 'default',
|
|
76
73
|
failIfMajorPerformanceCaveat = false,
|
|
74
|
+
reverseDepthBuffer = false,
|
|
77
75
|
multiviewStereo = false,
|
|
78
76
|
} = parameters;
|
|
79
77
|
|
|
@@ -294,9 +292,13 @@ class WebGLRenderer {
|
|
|
294
292
|
|
|
295
293
|
capabilities = new WebGLCapabilities( _gl, extensions, parameters, utils );
|
|
296
294
|
|
|
297
|
-
state = new WebGLState( _gl );
|
|
295
|
+
state = new WebGLState( _gl, extensions );
|
|
298
296
|
|
|
299
|
-
if ( capabilities.reverseDepthBuffer
|
|
297
|
+
if ( capabilities.reverseDepthBuffer && reverseDepthBuffer ) {
|
|
298
|
+
|
|
299
|
+
state.buffers.depth.setReversed( true );
|
|
300
|
+
|
|
301
|
+
}
|
|
300
302
|
|
|
301
303
|
info = new WebGLInfo( _gl );
|
|
302
304
|
properties = new WebGLProperties();
|
|
@@ -337,7 +339,7 @@ class WebGLRenderer {
|
|
|
337
339
|
|
|
338
340
|
// xr
|
|
339
341
|
|
|
340
|
-
const xr =
|
|
342
|
+
const xr = new WebXRManager( _this, _gl );
|
|
341
343
|
|
|
342
344
|
this.xr = xr;
|
|
343
345
|
|
|
@@ -601,7 +603,6 @@ class WebGLRenderer {
|
|
|
601
603
|
if ( depth ) {
|
|
602
604
|
|
|
603
605
|
bits |= _gl.DEPTH_BUFFER_BIT;
|
|
604
|
-
_gl.clearDepth( this.capabilities.reverseDepthBuffer ? 0 : 1 );
|
|
605
606
|
|
|
606
607
|
}
|
|
607
608
|
|
|
@@ -1297,13 +1298,6 @@ class WebGLRenderer {
|
|
|
1297
1298
|
|
|
1298
1299
|
if ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );
|
|
1299
1300
|
|
|
1300
|
-
textures.runDeferredUploads();
|
|
1301
|
-
|
|
1302
|
-
if ( xr.enabled && xr.submitFrame ) {
|
|
1303
|
-
|
|
1304
|
-
xr.submitFrame();
|
|
1305
|
-
|
|
1306
|
-
}
|
|
1307
1301
|
// _gl.finish();
|
|
1308
1302
|
|
|
1309
1303
|
bindingStates.resetDefaultState();
|
|
@@ -2016,7 +2010,9 @@ class WebGLRenderer {
|
|
|
2016
2010
|
|
|
2017
2011
|
} else {
|
|
2018
2012
|
|
|
2019
|
-
|
|
2013
|
+
const reverseDepthBuffer = state.buffers.depth.getReversed();
|
|
2014
|
+
|
|
2015
|
+
if ( reverseDepthBuffer ) {
|
|
2020
2016
|
|
|
2021
2017
|
_currentProjectionMatrix.copy( camera.projectionMatrix );
|
|
2022
2018
|
|
|
@@ -2648,21 +2644,27 @@ class WebGLRenderer {
|
|
|
2648
2644
|
|
|
2649
2645
|
}
|
|
2650
2646
|
|
|
2651
|
-
|
|
2652
|
-
let
|
|
2647
|
+
// gather the necessary dimensions to copy
|
|
2648
|
+
let width, height, depth, minX, minY, minZ;
|
|
2649
|
+
let dstX, dstY, dstZ;
|
|
2650
|
+
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
2653
2651
|
if ( srcRegion !== null ) {
|
|
2654
2652
|
|
|
2655
2653
|
width = srcRegion.max.x - srcRegion.min.x;
|
|
2656
2654
|
height = srcRegion.max.y - srcRegion.min.y;
|
|
2655
|
+
depth = srcRegion.isBox3 ? srcRegion.max.z - srcRegion.min.z : 1;
|
|
2657
2656
|
minX = srcRegion.min.x;
|
|
2658
2657
|
minY = srcRegion.min.y;
|
|
2658
|
+
minZ = srcRegion.isBox3 ? srcRegion.min.z : 0;
|
|
2659
2659
|
|
|
2660
2660
|
} else {
|
|
2661
2661
|
|
|
2662
|
-
width =
|
|
2663
|
-
height =
|
|
2662
|
+
width = image.width;
|
|
2663
|
+
height = image.height;
|
|
2664
|
+
depth = image.depth || 1;
|
|
2664
2665
|
minX = 0;
|
|
2665
2666
|
minY = 0;
|
|
2667
|
+
minZ = 0;
|
|
2666
2668
|
|
|
2667
2669
|
}
|
|
2668
2670
|
|
|
@@ -2670,177 +2672,143 @@ class WebGLRenderer {
|
|
|
2670
2672
|
|
|
2671
2673
|
dstX = dstPosition.x;
|
|
2672
2674
|
dstY = dstPosition.y;
|
|
2675
|
+
dstZ = dstPosition.z;
|
|
2673
2676
|
|
|
2674
2677
|
} else {
|
|
2675
2678
|
|
|
2676
2679
|
dstX = 0;
|
|
2677
2680
|
dstY = 0;
|
|
2681
|
+
dstZ = 0;
|
|
2678
2682
|
|
|
2679
2683
|
}
|
|
2680
2684
|
|
|
2685
|
+
// Set up the destination target
|
|
2681
2686
|
const glFormat = utils.convert( dstTexture.format );
|
|
2682
2687
|
const glType = utils.convert( dstTexture.type );
|
|
2688
|
+
let glTarget;
|
|
2689
|
+
|
|
2690
|
+
if ( dstTexture.isData3DTexture ) {
|
|
2683
2691
|
|
|
2684
|
-
|
|
2692
|
+
textures.setTexture3D( dstTexture, 0 );
|
|
2693
|
+
glTarget = _gl.TEXTURE_3D;
|
|
2694
|
+
|
|
2695
|
+
} else if ( dstTexture.isDataArrayTexture || dstTexture.isCompressedArrayTexture ) {
|
|
2696
|
+
|
|
2697
|
+
textures.setTexture2DArray( dstTexture, 0 );
|
|
2698
|
+
glTarget = _gl.TEXTURE_2D_ARRAY;
|
|
2699
|
+
|
|
2700
|
+
} else {
|
|
2701
|
+
|
|
2702
|
+
textures.setTexture2D( dstTexture, 0 );
|
|
2703
|
+
glTarget = _gl.TEXTURE_2D;
|
|
2704
|
+
|
|
2705
|
+
}
|
|
2685
2706
|
|
|
2686
|
-
// As another texture upload may have changed pixelStorei
|
|
2687
|
-
// parameters, make sure they are correct for the dstTexture
|
|
2688
2707
|
_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
|
|
2689
2708
|
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
2690
2709
|
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
2691
2710
|
|
|
2711
|
+
// used for copying data from cpu
|
|
2692
2712
|
const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
|
|
2693
2713
|
const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
|
|
2694
2714
|
const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
|
|
2695
2715
|
const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
|
|
2696
2716
|
const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
|
|
2697
2717
|
|
|
2698
|
-
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
2699
|
-
|
|
2700
2718
|
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
|
|
2701
2719
|
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
|
|
2702
2720
|
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
|
|
2703
2721
|
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
|
|
2722
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, minZ );
|
|
2704
2723
|
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
} else {
|
|
2710
|
-
|
|
2711
|
-
if ( srcTexture.isCompressedTexture ) {
|
|
2712
|
-
|
|
2713
|
-
_gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, image.width, image.height, glFormat, image.data );
|
|
2724
|
+
// set up the src texture
|
|
2725
|
+
const isSrc3D = srcTexture.isDataArrayTexture || srcTexture.isData3DTexture;
|
|
2726
|
+
const isDst3D = dstTexture.isDataArrayTexture || dstTexture.isData3DTexture;
|
|
2727
|
+
if ( srcTexture.isRenderTargetTexture || srcTexture.isDepthTexture ) {
|
|
2714
2728
|
|
|
2715
|
-
|
|
2729
|
+
const srcTextureProperties = properties.get( srcTexture );
|
|
2730
|
+
const dstTextureProperties = properties.get( dstTexture );
|
|
2731
|
+
const srcRenderTargetProperties = properties.get( srcTextureProperties.__renderTarget );
|
|
2732
|
+
const dstRenderTargetProperties = properties.get( dstTextureProperties.__renderTarget );
|
|
2716
2733
|
|
|
2717
|
-
|
|
2734
|
+
state.bindFramebuffer( _gl.READ_FRAMEBUFFER, srcRenderTargetProperties.__webglFramebuffer );
|
|
2735
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, dstRenderTargetProperties.__webglFramebuffer );
|
|
2718
2736
|
|
|
2719
|
-
|
|
2737
|
+
for ( let i = 0; i < depth; i ++ ) {
|
|
2720
2738
|
|
|
2721
|
-
|
|
2739
|
+
// if the source or destination are a 3d target then a layer needs to be bound
|
|
2740
|
+
if ( isSrc3D ) {
|
|
2722
2741
|
|
|
2723
|
-
|
|
2724
|
-
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
|
|
2725
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
|
|
2726
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
|
|
2727
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
|
|
2742
|
+
_gl.framebufferTextureLayer( _gl.READ_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( srcTexture ).__webglTexture, level, minZ + i );
|
|
2728
2743
|
|
|
2729
|
-
|
|
2730
|
-
if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );
|
|
2744
|
+
}
|
|
2731
2745
|
|
|
2732
|
-
|
|
2746
|
+
if ( srcTexture.isDepthTexture ) {
|
|
2733
2747
|
|
|
2734
|
-
|
|
2748
|
+
if ( isDst3D ) {
|
|
2735
2749
|
|
|
2736
|
-
|
|
2750
|
+
_gl.framebufferTextureLayer( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( dstTexture ).__webglTexture, level, dstZ + i );
|
|
2737
2751
|
|
|
2738
|
-
|
|
2739
|
-
if ( srcTexture.isTexture !== true ) {
|
|
2740
|
-
|
|
2741
|
-
// @deprecated, r165
|
|
2742
|
-
warnOnce( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
|
|
2743
|
-
|
|
2744
|
-
srcRegion = arguments[ 0 ] || null;
|
|
2745
|
-
dstPosition = arguments[ 1 ] || null;
|
|
2746
|
-
srcTexture = arguments[ 2 ];
|
|
2747
|
-
dstTexture = arguments[ 3 ];
|
|
2748
|
-
level = arguments[ 4 ] || 0;
|
|
2752
|
+
}
|
|
2749
2753
|
|
|
2750
|
-
|
|
2754
|
+
_gl.blitFramebuffer( minX, minY, width, height, dstX, dstY, width, height, _gl.DEPTH_BUFFER_BIT, _gl.NEAREST );
|
|
2751
2755
|
|
|
2752
|
-
|
|
2753
|
-
let dstX, dstY, dstZ;
|
|
2754
|
-
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
2755
|
-
if ( srcRegion !== null ) {
|
|
2756
|
+
} else if ( isDst3D ) {
|
|
2756
2757
|
|
|
2757
|
-
|
|
2758
|
-
height = srcRegion.max.y - srcRegion.min.y;
|
|
2759
|
-
depth = srcRegion.max.z - srcRegion.min.z;
|
|
2760
|
-
minX = srcRegion.min.x;
|
|
2761
|
-
minY = srcRegion.min.y;
|
|
2762
|
-
minZ = srcRegion.min.z;
|
|
2758
|
+
_gl.copyTexSubImage3D( glTarget, level, dstX, dstY, dstZ + i, minX, minY, width, height );
|
|
2763
2759
|
|
|
2764
|
-
|
|
2760
|
+
} else {
|
|
2765
2761
|
|
|
2766
|
-
|
|
2767
|
-
height = image.height;
|
|
2768
|
-
depth = image.depth;
|
|
2769
|
-
minX = 0;
|
|
2770
|
-
minY = 0;
|
|
2771
|
-
minZ = 0;
|
|
2762
|
+
_gl.copyTexSubImage2D( glTarget, level, dstX, dstY, dstZ + i, minX, minY, width, height );
|
|
2772
2763
|
|
|
2773
|
-
|
|
2764
|
+
}
|
|
2774
2765
|
|
|
2775
|
-
|
|
2766
|
+
}
|
|
2776
2767
|
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
dstZ = dstPosition.z;
|
|
2768
|
+
state.bindFramebuffer( _gl.READ_FRAMEBUFFER, null );
|
|
2769
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
|
|
2780
2770
|
|
|
2781
2771
|
} else {
|
|
2782
2772
|
|
|
2783
|
-
|
|
2784
|
-
dstY = 0;
|
|
2785
|
-
dstZ = 0;
|
|
2786
|
-
|
|
2787
|
-
}
|
|
2788
|
-
|
|
2789
|
-
const glFormat = utils.convert( dstTexture.format );
|
|
2790
|
-
const glType = utils.convert( dstTexture.type );
|
|
2791
|
-
let glTarget;
|
|
2792
|
-
|
|
2793
|
-
if ( dstTexture.isData3DTexture ) {
|
|
2773
|
+
if ( isDst3D ) {
|
|
2794
2774
|
|
|
2795
|
-
|
|
2796
|
-
|
|
2775
|
+
// copy data into the 3d texture
|
|
2776
|
+
if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
|
|
2797
2777
|
|
|
2798
|
-
|
|
2778
|
+
_gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image.data );
|
|
2799
2779
|
|
|
2800
|
-
|
|
2801
|
-
glTarget = _gl.TEXTURE_2D_ARRAY;
|
|
2780
|
+
} else if ( dstTexture.isCompressedArrayTexture ) {
|
|
2802
2781
|
|
|
2803
|
-
|
|
2782
|
+
_gl.compressedTexSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, image.data );
|
|
2804
2783
|
|
|
2805
|
-
|
|
2806
|
-
return;
|
|
2784
|
+
} else {
|
|
2807
2785
|
|
|
2808
|
-
|
|
2786
|
+
_gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image );
|
|
2809
2787
|
|
|
2810
|
-
|
|
2811
|
-
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
2812
|
-
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
2813
|
-
|
|
2814
|
-
const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
|
|
2815
|
-
const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
|
|
2816
|
-
const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
|
|
2817
|
-
const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
|
|
2818
|
-
const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
|
|
2788
|
+
}
|
|
2819
2789
|
|
|
2820
|
-
|
|
2821
|
-
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
|
|
2822
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
|
|
2823
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
|
|
2824
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, minZ );
|
|
2790
|
+
} else {
|
|
2825
2791
|
|
|
2826
|
-
|
|
2792
|
+
// copy data into the 2d texture
|
|
2793
|
+
if ( srcTexture.isDataTexture ) {
|
|
2827
2794
|
|
|
2828
|
-
|
|
2795
|
+
_gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image.data );
|
|
2829
2796
|
|
|
2830
|
-
|
|
2797
|
+
} else if ( srcTexture.isCompressedTexture ) {
|
|
2831
2798
|
|
|
2832
|
-
|
|
2799
|
+
_gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, image.width, image.height, glFormat, image.data );
|
|
2833
2800
|
|
|
2834
|
-
|
|
2801
|
+
} else {
|
|
2835
2802
|
|
|
2836
|
-
|
|
2803
|
+
_gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image );
|
|
2837
2804
|
|
|
2838
|
-
|
|
2805
|
+
}
|
|
2839
2806
|
|
|
2840
2807
|
}
|
|
2841
2808
|
|
|
2842
2809
|
}
|
|
2843
2810
|
|
|
2811
|
+
// reset values
|
|
2844
2812
|
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
|
|
2845
2813
|
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
|
|
2846
2814
|
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
|
|
@@ -2848,12 +2816,39 @@ class WebGLRenderer {
|
|
|
2848
2816
|
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
|
|
2849
2817
|
|
|
2850
2818
|
// Generate mipmaps only when copying level 0
|
|
2851
|
-
if ( level === 0 && dstTexture.generateMipmaps )
|
|
2819
|
+
if ( level === 0 && dstTexture.generateMipmaps ) {
|
|
2820
|
+
|
|
2821
|
+
_gl.generateMipmap( glTarget );
|
|
2822
|
+
|
|
2823
|
+
}
|
|
2852
2824
|
|
|
2853
2825
|
state.unbindTexture();
|
|
2854
2826
|
|
|
2855
2827
|
};
|
|
2856
2828
|
|
|
2829
|
+
this.copyTextureToTexture3D = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
|
|
2830
|
+
|
|
2831
|
+
// support previous signature with source box first
|
|
2832
|
+
if ( srcTexture.isTexture !== true ) {
|
|
2833
|
+
|
|
2834
|
+
// @deprecated, r165
|
|
2835
|
+
warnOnce( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
|
|
2836
|
+
|
|
2837
|
+
srcRegion = arguments[ 0 ] || null;
|
|
2838
|
+
dstPosition = arguments[ 1 ] || null;
|
|
2839
|
+
srcTexture = arguments[ 2 ];
|
|
2840
|
+
dstTexture = arguments[ 3 ];
|
|
2841
|
+
level = arguments[ 4 ] || 0;
|
|
2842
|
+
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2845
|
+
// @deprecated, r170
|
|
2846
|
+
warnOnce( 'WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.' );
|
|
2847
|
+
|
|
2848
|
+
return this.copyTextureToTexture( srcTexture, dstTexture, srcRegion, dstPosition, level );
|
|
2849
|
+
|
|
2850
|
+
};
|
|
2851
|
+
|
|
2857
2852
|
this.initRenderTarget = function ( target ) {
|
|
2858
2853
|
|
|
2859
2854
|
if ( properties.get( target ).__webglFramebuffer === undefined ) {
|
|
@@ -2924,8 +2919,8 @@ class WebGLRenderer {
|
|
|
2924
2919
|
this._outputColorSpace = colorSpace;
|
|
2925
2920
|
|
|
2926
2921
|
const gl = this.getContext();
|
|
2927
|
-
gl.
|
|
2928
|
-
gl.unpackColorSpace = ColorManagement.
|
|
2922
|
+
gl.drawingBufferColorspace = ColorManagement._getDrawingBufferColorSpace( colorSpace );
|
|
2923
|
+
gl.unpackColorSpace = ColorManagement._getUnpackColorSpace();
|
|
2929
2924
|
|
|
2930
2925
|
}
|
|
2931
2926
|
|
|
@@ -45,6 +45,10 @@ class Attributes extends DataMap {
|
|
|
45
45
|
|
|
46
46
|
this.backend.createStorageAttribute( attribute );
|
|
47
47
|
|
|
48
|
+
} else if ( type === AttributeType.INDIRECT ) {
|
|
49
|
+
|
|
50
|
+
this.backend.createIndirectStorageAttribute( attribute );
|
|
51
|
+
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
data.version = this._getBufferAttribute( attribute ).version;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import DataMap from './DataMap.js';
|
|
2
2
|
import Color4 from './Color4.js';
|
|
3
|
-
import { vec4, context, normalWorld, backgroundBlurriness, backgroundIntensity, modelViewProjection } from '../../nodes/TSL.js';
|
|
3
|
+
import { vec4, context, normalWorld, backgroundBlurriness, backgroundIntensity, backgroundRotation, modelViewProjection } from '../../nodes/TSL.js';
|
|
4
4
|
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
5
5
|
|
|
6
6
|
import { Mesh } from '../../objects/Mesh.js';
|
|
@@ -56,7 +56,7 @@ class Background extends DataMap {
|
|
|
56
56
|
|
|
57
57
|
const backgroundMeshNode = context( vec4( backgroundNode ).mul( backgroundIntensity ), {
|
|
58
58
|
// @TODO: Add Texture2D support using node context
|
|
59
|
-
getUV: () => normalWorld,
|
|
59
|
+
getUV: () => backgroundRotation.mul( normalWorld ),
|
|
60
60
|
getTextureLevel: () => backgroundBlurriness
|
|
61
61
|
} );
|
|
62
62
|
|
|
@@ -111,8 +111,6 @@ class Background extends DataMap {
|
|
|
111
111
|
|
|
112
112
|
if ( renderer.autoClear === true || forceClear === true ) {
|
|
113
113
|
|
|
114
|
-
_clearColor.multiplyScalar( _clearColor.a );
|
|
115
|
-
|
|
116
114
|
const clearColorValue = renderContext.clearColorValue;
|
|
117
115
|
|
|
118
116
|
clearColorValue.r = _clearColor.r;
|
|
@@ -120,6 +118,18 @@ class Background extends DataMap {
|
|
|
120
118
|
clearColorValue.b = _clearColor.b;
|
|
121
119
|
clearColorValue.a = _clearColor.a;
|
|
122
120
|
|
|
121
|
+
// premultiply alpha
|
|
122
|
+
|
|
123
|
+
if ( renderer.backend.isWebGLBackend === true || renderer.alpha === true ) {
|
|
124
|
+
|
|
125
|
+
clearColorValue.r *= clearColorValue.a;
|
|
126
|
+
clearColorValue.g *= clearColorValue.a;
|
|
127
|
+
clearColorValue.b *= clearColorValue.a;
|
|
128
|
+
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
//
|
|
132
|
+
|
|
123
133
|
renderContext.depthClearValue = renderer._clearDepth;
|
|
124
134
|
renderContext.stencilClearValue = renderer._clearStencil;
|
|
125
135
|
|
|
@@ -101,8 +101,9 @@ class Bindings extends DataMap {
|
|
|
101
101
|
} else if ( binding.isStorageBuffer ) {
|
|
102
102
|
|
|
103
103
|
const attribute = binding.attribute;
|
|
104
|
+
const attributeType = attribute.isIndirectStorageBufferAttribute ? AttributeType.INDIRECT : AttributeType.STORAGE;
|
|
104
105
|
|
|
105
|
-
this.attributes.update( attribute,
|
|
106
|
+
this.attributes.update( attribute, attributeType );
|
|
106
107
|
|
|
107
108
|
}
|
|
108
109
|
|
|
@@ -176,7 +177,7 @@ class Bindings extends DataMap {
|
|
|
176
177
|
|
|
177
178
|
textureData.needsMipmap = true;
|
|
178
179
|
|
|
179
|
-
} else if (
|
|
180
|
+
} else if ( this.textures.needsMipmaps( texture ) && textureData.needsMipmap === true ) {
|
|
180
181
|
|
|
181
182
|
this.backend.generateMipmaps( texture );
|
|
182
183
|
|
|
@@ -144,6 +144,8 @@ class Geometries extends DataMap {
|
|
|
144
144
|
|
|
145
145
|
updateAttributes( renderObject ) {
|
|
146
146
|
|
|
147
|
+
// attributes
|
|
148
|
+
|
|
147
149
|
const attributes = renderObject.getAttributes();
|
|
148
150
|
|
|
149
151
|
for ( const attribute of attributes ) {
|
|
@@ -160,6 +162,8 @@ class Geometries extends DataMap {
|
|
|
160
162
|
|
|
161
163
|
}
|
|
162
164
|
|
|
165
|
+
// indexes
|
|
166
|
+
|
|
163
167
|
const index = this.getIndex( renderObject );
|
|
164
168
|
|
|
165
169
|
if ( index !== null ) {
|
|
@@ -168,6 +172,16 @@ class Geometries extends DataMap {
|
|
|
168
172
|
|
|
169
173
|
}
|
|
170
174
|
|
|
175
|
+
// indirect
|
|
176
|
+
|
|
177
|
+
const indirect = renderObject.geometry.indirect;
|
|
178
|
+
|
|
179
|
+
if ( indirect !== null ) {
|
|
180
|
+
|
|
181
|
+
this.updateAttribute( indirect, AttributeType.INDIRECT );
|
|
182
|
+
|
|
183
|
+
}
|
|
184
|
+
|
|
171
185
|
}
|
|
172
186
|
|
|
173
187
|
updateAttribute( attribute, type ) {
|
|
@@ -206,6 +220,12 @@ class Geometries extends DataMap {
|
|
|
206
220
|
|
|
207
221
|
}
|
|
208
222
|
|
|
223
|
+
getIndirect( renderObject ) {
|
|
224
|
+
|
|
225
|
+
return renderObject.geometry.indirect;
|
|
226
|
+
|
|
227
|
+
}
|
|
228
|
+
|
|
209
229
|
getIndex( renderObject ) {
|
|
210
230
|
|
|
211
231
|
const { geometry, material } = renderObject;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import StorageBufferAttribute from './StorageBufferAttribute.js';
|
|
2
|
+
|
|
3
|
+
class IndirectStorageBufferAttribute extends StorageBufferAttribute {
|
|
4
|
+
|
|
5
|
+
constructor( array, itemSize ) {
|
|
6
|
+
|
|
7
|
+
super( array, itemSize, Uint32Array );
|
|
8
|
+
|
|
9
|
+
this.isIndirectStorageBufferAttribute = true;
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default IndirectStorageBufferAttribute;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { LightsNode } from '../../nodes/Nodes.js';
|
|
2
|
+
import ChainMap from './ChainMap.js';
|
|
3
|
+
|
|
4
|
+
const _defaultLights = /*@__PURE__*/ new LightsNode();
|
|
5
|
+
|
|
6
|
+
class Lighting extends ChainMap {
|
|
7
|
+
|
|
8
|
+
constructor() {
|
|
9
|
+
|
|
10
|
+
super();
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
createNode( lights = [] ) {
|
|
15
|
+
|
|
16
|
+
return new LightsNode().setLights( lights );
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getNode( scene, camera ) {
|
|
21
|
+
|
|
22
|
+
// ignore post-processing
|
|
23
|
+
|
|
24
|
+
if ( scene.isQuadMesh ) return _defaultLights;
|
|
25
|
+
|
|
26
|
+
// tiled lighting
|
|
27
|
+
|
|
28
|
+
const keys = [ scene, camera ];
|
|
29
|
+
|
|
30
|
+
let node = this.get( keys );
|
|
31
|
+
|
|
32
|
+
if ( node === undefined ) {
|
|
33
|
+
|
|
34
|
+
node = this.createNode();
|
|
35
|
+
this.set( keys, node );
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return node;
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default Lighting;
|