super-three 0.162.0 → 0.163.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 +407 -1014
- package/build/three.module.js +406 -1013
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/TransformControls.js +3 -3
- package/examples/jsm/exporters/GLTFExporter.js +21 -4
- package/examples/jsm/exporters/USDZExporter.js +15 -0
- package/examples/jsm/geometries/TextGeometry.js +10 -2
- package/examples/jsm/interactive/HTMLMesh.js +7 -9
- package/examples/jsm/libs/fflate.module.js +694 -496
- package/examples/jsm/lines/LineMaterial.js +0 -2
- package/examples/jsm/loaders/3MFLoader.js +2 -0
- package/examples/jsm/loaders/EXRLoader.js +89 -19
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +6 -0
- package/examples/jsm/loaders/KTX2Loader.js +2 -6
- package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
- package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
- package/examples/jsm/loaders/LUTImageLoader.js +0 -14
- package/examples/jsm/loaders/RGBMLoader.js +16 -0
- package/examples/jsm/misc/GPUComputationRenderer.js +0 -6
- package/examples/jsm/nodes/Nodes.js +6 -1
- package/examples/jsm/nodes/accessors/BatchNode.js +78 -0
- package/examples/jsm/nodes/accessors/InstanceNode.js +25 -2
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +1 -1
- package/examples/jsm/nodes/accessors/MorphNode.js +13 -3
- package/examples/jsm/nodes/accessors/NormalNode.js +12 -2
- package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
- package/examples/jsm/nodes/accessors/RendererReferenceNode.js +29 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +30 -7
- package/examples/jsm/nodes/core/Node.js +55 -4
- package/examples/jsm/nodes/core/NodeBuilder.js +21 -16
- package/examples/jsm/nodes/core/NodeFrame.js +10 -10
- package/examples/jsm/nodes/core/NodeUtils.js +2 -2
- package/examples/jsm/nodes/core/UniformNode.js +20 -0
- package/examples/jsm/nodes/display/PassNode.js +17 -1
- package/examples/jsm/nodes/display/ToneMappingNode.js +8 -4
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -0
- package/examples/jsm/nodes/fog/FogExp2Node.js +4 -5
- package/examples/jsm/nodes/fog/FogNode.js +13 -3
- package/examples/jsm/nodes/fog/FogRangeNode.js +4 -3
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +12 -69
- package/examples/jsm/nodes/materials/NodeMaterial.js +33 -11
- package/examples/jsm/nodes/pmrem/PMREMNode.js +193 -0
- package/examples/jsm/nodes/pmrem/PMREMUtils.js +288 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +1 -1
- package/examples/jsm/nodes/utils/EquirectUVNode.js +1 -1
- package/examples/jsm/objects/QuadMesh.js +7 -23
- package/examples/jsm/physics/RapierPhysics.js +4 -4
- package/examples/jsm/postprocessing/GlitchPass.js +0 -3
- package/examples/jsm/postprocessing/LUTPass.js +5 -71
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SSAOPass.js +0 -3
- package/examples/jsm/renderers/common/Animation.js +3 -0
- package/examples/jsm/renderers/common/Background.js +5 -5
- package/examples/jsm/renderers/common/Info.js +11 -19
- package/examples/jsm/renderers/common/PostProcessing.js +12 -4
- package/examples/jsm/renderers/common/RenderContext.js +1 -1
- package/examples/jsm/renderers/common/RenderObject.js +4 -4
- package/examples/jsm/renderers/common/RenderObjects.js +1 -1
- package/examples/jsm/renderers/common/Renderer.js +25 -8
- package/examples/jsm/renderers/common/extras/PMREMGenerator.js +777 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +5 -18
- package/examples/jsm/renderers/webgl/WebGLBackend.js +148 -24
- package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +141 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +3 -3
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +1 -1
- package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +1 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +43 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -2
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -2
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +54 -25
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +5 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +25 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +18 -4
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +92 -18
- package/examples/jsm/utils/GPUStatsPanel.js +10 -45
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/package.json +1 -1
- package/src/Three.js +0 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/constants.js +3 -3
- package/src/core/Object3D.js +10 -7
- package/src/extras/PMREMGenerator.js +9 -0
- package/src/loaders/ObjectLoader.js +2 -0
- package/src/materials/ShaderMaterial.js +0 -4
- package/src/math/Spherical.js +4 -5
- package/src/objects/BatchedMesh.js +4 -3
- package/src/objects/InstancedMesh.js +10 -0
- package/src/renderers/WebGLRenderer.js +55 -114
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +32 -22
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib.js +1 -1
- package/src/renderers/shaders/UniformsUtils.js +10 -1
- package/src/renderers/webgl/WebGLAttributes.js +6 -33
- package/src/renderers/webgl/WebGLBindingStates.js +14 -51
- package/src/renderers/webgl/WebGLBufferRenderer.js +3 -25
- package/src/renderers/webgl/WebGLCapabilities.js +2 -12
- package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
- package/src/renderers/webgl/WebGLExtensions.js +4 -19
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +3 -25
- package/src/renderers/webgl/WebGLLights.js +6 -32
- package/src/renderers/webgl/WebGLMaterials.js +2 -3
- package/src/renderers/webgl/WebGLMorphtargets.js +79 -217
- package/src/renderers/webgl/WebGLProgram.js +18 -47
- package/src/renderers/webgl/WebGLPrograms.js +20 -32
- package/src/renderers/webgl/WebGLRenderStates.js +8 -6
- package/src/renderers/webgl/WebGLState.js +15 -59
- package/src/renderers/webgl/WebGLTextures.js +75 -237
- package/src/renderers/webgl/WebGLUniformsGroups.js +1 -1
- package/src/renderers/webgl/WebGLUtils.js +6 -57
- package/src/renderers/webxr/WebXRDepthSensing.js +2 -3
- package/src/renderers/webxr/WebXRManager.js +2 -2
- package/src/scenes/Scene.js +7 -1
- package/src/textures/Texture.js +11 -1
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
- package/src/renderers/WebGL1Renderer.js +0 -7
|
@@ -195,8 +195,7 @@ class BatchedMesh extends Mesh {
|
|
|
195
195
|
const { array, itemSize, normalized } = srcAttribute;
|
|
196
196
|
|
|
197
197
|
const dstArray = new array.constructor( maxVertexCount * itemSize );
|
|
198
|
-
const dstAttribute = new
|
|
199
|
-
dstAttribute.setUsage( srcAttribute.usage );
|
|
198
|
+
const dstAttribute = new BufferAttribute( dstArray, itemSize, normalized );
|
|
200
199
|
|
|
201
200
|
geometry.setAttribute( attributeName, dstAttribute );
|
|
202
201
|
|
|
@@ -223,7 +222,7 @@ class BatchedMesh extends Mesh {
|
|
|
223
222
|
|
|
224
223
|
}
|
|
225
224
|
|
|
226
|
-
// Make sure the geometry is compatible with the existing combined geometry
|
|
225
|
+
// Make sure the geometry is compatible with the existing combined geometry attributes
|
|
227
226
|
_validateGeometry( geometry ) {
|
|
228
227
|
|
|
229
228
|
// check that the geometry doesn't have a version of our reserved id attribute
|
|
@@ -514,6 +513,7 @@ class BatchedMesh extends Mesh {
|
|
|
514
513
|
}
|
|
515
514
|
|
|
516
515
|
dstAttribute.needsUpdate = true;
|
|
516
|
+
dstAttribute.addUpdateRange( vertexStart * itemSize, vertexCount * itemSize );
|
|
517
517
|
|
|
518
518
|
}
|
|
519
519
|
|
|
@@ -537,6 +537,7 @@ class BatchedMesh extends Mesh {
|
|
|
537
537
|
}
|
|
538
538
|
|
|
539
539
|
dstIndex.needsUpdate = true;
|
|
540
|
+
dstIndex.addUpdateRange( indexStart, reservedRange.indexCount );
|
|
540
541
|
|
|
541
542
|
}
|
|
542
543
|
|
|
@@ -109,6 +109,7 @@ class InstancedMesh extends Mesh {
|
|
|
109
109
|
|
|
110
110
|
this.instanceMatrix.copy( source.instanceMatrix );
|
|
111
111
|
|
|
112
|
+
if ( source.morphTexture !== null ) this.morphTexture = source.morphTexture.clone();
|
|
112
113
|
if ( source.instanceColor !== null ) this.instanceColor = source.instanceColor.clone();
|
|
113
114
|
|
|
114
115
|
this.count = source.count;
|
|
@@ -260,6 +261,15 @@ class InstancedMesh extends Mesh {
|
|
|
260
261
|
|
|
261
262
|
this.dispatchEvent( { type: 'dispose' } );
|
|
262
263
|
|
|
264
|
+
if ( this.morphTexture !== null ) {
|
|
265
|
+
|
|
266
|
+
this.morphTexture.dispose();
|
|
267
|
+
this.morphTexture = null;
|
|
268
|
+
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return this;
|
|
272
|
+
|
|
263
273
|
}
|
|
264
274
|
|
|
265
275
|
}
|
|
@@ -29,7 +29,6 @@ import { Matrix4 } from '../math/Matrix4.js';
|
|
|
29
29
|
import { Vector2 } from '../math/Vector2.js';
|
|
30
30
|
import { Vector3 } from '../math/Vector3.js';
|
|
31
31
|
import { Vector4 } from '../math/Vector4.js';
|
|
32
|
-
import { floorPowerOfTwo } from '../math/MathUtils.js';
|
|
33
32
|
import { WebGLAnimation } from './webgl/WebGLAnimation.js';
|
|
34
33
|
import { WebGLAttributes } from './webgl/WebGLAttributes.js';
|
|
35
34
|
import { WebGLBackground } from './webgl/WebGLBackground.js';
|
|
@@ -71,7 +70,7 @@ class WebGLRenderer {
|
|
|
71
70
|
canvas = createCanvasElement(),
|
|
72
71
|
context = null,
|
|
73
72
|
depth = true,
|
|
74
|
-
stencil =
|
|
73
|
+
stencil = false,
|
|
75
74
|
alpha = false,
|
|
76
75
|
antialias = false,
|
|
77
76
|
premultipliedAlpha = true,
|
|
@@ -87,6 +86,12 @@ class WebGLRenderer {
|
|
|
87
86
|
|
|
88
87
|
if ( context !== null ) {
|
|
89
88
|
|
|
89
|
+
if ( typeof WebGLRenderingContext !== 'undefined' && context instanceof WebGLRenderingContext ) {
|
|
90
|
+
|
|
91
|
+
throw new Error( 'THREE.WebGLRenderer: WebGL 1 is not supported since r163.' );
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
90
95
|
_alpha = context.getContextAttributes().alpha;
|
|
91
96
|
|
|
92
97
|
} else {
|
|
@@ -199,10 +204,6 @@ class WebGLRenderer {
|
|
|
199
204
|
let _clippingEnabled = false;
|
|
200
205
|
let _localClippingEnabled = false;
|
|
201
206
|
|
|
202
|
-
// transmission
|
|
203
|
-
|
|
204
|
-
let _transmissionRenderTarget = null;
|
|
205
|
-
|
|
206
207
|
// camera matrices cache
|
|
207
208
|
|
|
208
209
|
const _projScreenMatrix = new Matrix4();
|
|
@@ -222,15 +223,10 @@ class WebGLRenderer {
|
|
|
222
223
|
|
|
223
224
|
let _gl = context;
|
|
224
225
|
|
|
225
|
-
function getContext(
|
|
226
|
+
function getContext( contextName, contextAttributes ) {
|
|
226
227
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const contextName = contextNames[ i ];
|
|
230
|
-
const context = canvas.getContext( contextName, contextAttributes );
|
|
231
|
-
if ( context !== null ) return context;
|
|
232
|
-
|
|
233
|
-
}
|
|
228
|
+
const context = canvas.getContext( contextName, contextAttributes );
|
|
229
|
+
if ( context !== null ) return context;
|
|
234
230
|
|
|
235
231
|
return null;
|
|
236
232
|
|
|
@@ -259,19 +255,13 @@ class WebGLRenderer {
|
|
|
259
255
|
|
|
260
256
|
if ( _gl === null ) {
|
|
261
257
|
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
if ( _this.isWebGL1Renderer === true ) {
|
|
258
|
+
const contextName = 'webgl2';
|
|
265
259
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
_gl = getContext( contextNames, contextAttributes );
|
|
260
|
+
_gl = getContext( contextName, contextAttributes );
|
|
271
261
|
|
|
272
262
|
if ( _gl === null ) {
|
|
273
263
|
|
|
274
|
-
if ( getContext(
|
|
264
|
+
if ( getContext( contextName ) ) {
|
|
275
265
|
|
|
276
266
|
throw new Error( 'Error creating WebGL context with your selected attributes.' );
|
|
277
267
|
|
|
@@ -285,24 +275,6 @@ class WebGLRenderer {
|
|
|
285
275
|
|
|
286
276
|
}
|
|
287
277
|
|
|
288
|
-
if ( typeof WebGLRenderingContext !== 'undefined' && _gl instanceof WebGLRenderingContext ) { // @deprecated, r153
|
|
289
|
-
|
|
290
|
-
console.warn( 'THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163.' );
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// Some experimental-webgl implementations do not have getShaderPrecisionFormat
|
|
295
|
-
|
|
296
|
-
if ( _gl.getShaderPrecisionFormat === undefined ) {
|
|
297
|
-
|
|
298
|
-
_gl.getShaderPrecisionFormat = function () {
|
|
299
|
-
|
|
300
|
-
return { 'rangeMin': 1, 'rangeMax': 1, 'precision': 1 };
|
|
301
|
-
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
|
|
306
278
|
} catch ( error ) {
|
|
307
279
|
|
|
308
280
|
console.error( 'THREE.WebGLRenderer: ' + error.message );
|
|
@@ -322,22 +294,21 @@ class WebGLRenderer {
|
|
|
322
294
|
function initGLContext() {
|
|
323
295
|
|
|
324
296
|
extensions = new WebGLExtensions( _gl );
|
|
297
|
+
extensions.init();
|
|
325
298
|
|
|
326
299
|
capabilities = new WebGLCapabilities( _gl, extensions, parameters );
|
|
327
300
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
utils = new WebGLUtils( _gl, extensions, capabilities );
|
|
301
|
+
utils = new WebGLUtils( _gl, extensions );
|
|
331
302
|
|
|
332
|
-
state = new WebGLState( _gl
|
|
303
|
+
state = new WebGLState( _gl );
|
|
333
304
|
|
|
334
305
|
info = new WebGLInfo( _gl );
|
|
335
306
|
properties = new WebGLProperties();
|
|
336
307
|
textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
|
|
337
308
|
cubemaps = new WebGLCubeMaps( _this );
|
|
338
309
|
cubeuvmaps = new WebGLCubeUVMaps( _this );
|
|
339
|
-
attributes = new WebGLAttributes( _gl
|
|
340
|
-
bindingStates = new WebGLBindingStates( _gl,
|
|
310
|
+
attributes = new WebGLAttributes( _gl );
|
|
311
|
+
bindingStates = new WebGLBindingStates( _gl, attributes );
|
|
341
312
|
geometries = new WebGLGeometries( _gl, attributes, info, bindingStates );
|
|
342
313
|
objects = new WebGLObjects( _gl, geometries, attributes, info );
|
|
343
314
|
morphtargets = new WebGLMorphtargets( _gl, capabilities, textures );
|
|
@@ -345,14 +316,14 @@ class WebGLRenderer {
|
|
|
345
316
|
programCache = new WebGLPrograms( _this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping );
|
|
346
317
|
materials = new WebGLMaterials( _this, properties );
|
|
347
318
|
renderLists = new WebGLRenderLists();
|
|
348
|
-
renderStates = new WebGLRenderStates( extensions
|
|
319
|
+
renderStates = new WebGLRenderStates( extensions );
|
|
349
320
|
background = new WebGLBackground( _this, cubemaps, cubeuvmaps, state, objects, _alpha, premultipliedAlpha );
|
|
350
321
|
multiview = new WebGLMultiview( _this, extensions, _gl );
|
|
351
322
|
shadowMap = new WebGLShadowMap( _this, objects, capabilities );
|
|
352
323
|
uniformsGroups = new WebGLUniformsGroups( _gl, info, capabilities, state );
|
|
353
324
|
|
|
354
|
-
bufferRenderer = new WebGLBufferRenderer( _gl, extensions, info
|
|
355
|
-
indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info
|
|
325
|
+
bufferRenderer = new WebGLBufferRenderer( _gl, extensions, info );
|
|
326
|
+
indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info );
|
|
356
327
|
|
|
357
328
|
info.programs = programCache.programs;
|
|
358
329
|
|
|
@@ -684,13 +655,6 @@ class WebGLRenderer {
|
|
|
684
655
|
xr.removeEventListener( 'sessionstart', onXRSessionStart );
|
|
685
656
|
xr.removeEventListener( 'sessionend', onXRSessionEnd );
|
|
686
657
|
|
|
687
|
-
if ( _transmissionRenderTarget ) {
|
|
688
|
-
|
|
689
|
-
_transmissionRenderTarget.dispose();
|
|
690
|
-
_transmissionRenderTarget = null;
|
|
691
|
-
|
|
692
|
-
}
|
|
693
|
-
|
|
694
658
|
animation.stop();
|
|
695
659
|
|
|
696
660
|
};
|
|
@@ -1459,17 +1423,19 @@ class WebGLRenderer {
|
|
|
1459
1423
|
|
|
1460
1424
|
}
|
|
1461
1425
|
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
if ( _transmissionRenderTarget === null ) {
|
|
1426
|
+
if ( currentRenderState.state.transmissionRenderTarget === null ) {
|
|
1465
1427
|
|
|
1466
|
-
|
|
1428
|
+
currentRenderState.state.transmissionRenderTarget = new WebGLRenderTarget( 1, 1, {
|
|
1467
1429
|
generateMipmaps: true,
|
|
1468
|
-
type: extensions.has( 'EXT_color_buffer_half_float' ) ? HalfFloatType : UnsignedByteType,
|
|
1430
|
+
type: ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) ) ? HalfFloatType : UnsignedByteType,
|
|
1469
1431
|
minFilter: LinearMipmapLinearFilter,
|
|
1470
|
-
samples:
|
|
1432
|
+
samples: 4,
|
|
1433
|
+
stencilBuffer: stencil
|
|
1471
1434
|
} );
|
|
1472
1435
|
|
|
1436
|
+
const renderTargetProperties = properties.get( currentRenderState.state.transmissionRenderTarget );
|
|
1437
|
+
renderTargetProperties.__isTransmissionRenderTarget = true;
|
|
1438
|
+
|
|
1473
1439
|
// debug
|
|
1474
1440
|
|
|
1475
1441
|
/*
|
|
@@ -1482,22 +1448,15 @@ class WebGLRenderer {
|
|
|
1482
1448
|
|
|
1483
1449
|
}
|
|
1484
1450
|
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
if ( isWebGL2 ) {
|
|
1488
|
-
|
|
1489
|
-
_transmissionRenderTarget.setSize( _vector2.x, _vector2.y );
|
|
1451
|
+
const transmissionRenderTarget = currentRenderState.state.transmissionRenderTarget;
|
|
1490
1452
|
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
_transmissionRenderTarget.setSize( floorPowerOfTwo( _vector2.x ), floorPowerOfTwo( _vector2.y ) );
|
|
1494
|
-
|
|
1495
|
-
}
|
|
1453
|
+
_this.getDrawingBufferSize( _vector2 );
|
|
1454
|
+
transmissionRenderTarget.setSize( _vector2.x, _vector2.y );
|
|
1496
1455
|
|
|
1497
1456
|
//
|
|
1498
1457
|
|
|
1499
1458
|
const currentRenderTarget = _this.getRenderTarget();
|
|
1500
|
-
_this.setRenderTarget(
|
|
1459
|
+
_this.setRenderTarget( transmissionRenderTarget );
|
|
1501
1460
|
|
|
1502
1461
|
_this.getClearColor( _currentClearColor );
|
|
1503
1462
|
_currentClearAlpha = _this.getClearAlpha();
|
|
@@ -1512,8 +1471,8 @@ class WebGLRenderer {
|
|
|
1512
1471
|
|
|
1513
1472
|
renderObjects( opaqueObjects, scene, camera );
|
|
1514
1473
|
|
|
1515
|
-
textures.updateMultisampleRenderTarget(
|
|
1516
|
-
textures.updateRenderTargetMipmap(
|
|
1474
|
+
textures.updateMultisampleRenderTarget( transmissionRenderTarget );
|
|
1475
|
+
textures.updateRenderTargetMipmap( transmissionRenderTarget );
|
|
1517
1476
|
|
|
1518
1477
|
let renderTargetNeedsUpdate = false;
|
|
1519
1478
|
|
|
@@ -1546,8 +1505,8 @@ class WebGLRenderer {
|
|
|
1546
1505
|
|
|
1547
1506
|
if ( renderTargetNeedsUpdate === true ) {
|
|
1548
1507
|
|
|
1549
|
-
textures.updateMultisampleRenderTarget(
|
|
1550
|
-
textures.updateRenderTargetMipmap(
|
|
1508
|
+
textures.updateMultisampleRenderTarget( transmissionRenderTarget );
|
|
1509
|
+
textures.updateRenderTargetMipmap( transmissionRenderTarget );
|
|
1551
1510
|
|
|
1552
1511
|
}
|
|
1553
1512
|
|
|
@@ -1907,7 +1866,7 @@ class WebGLRenderer {
|
|
|
1907
1866
|
|
|
1908
1867
|
needsProgramChange = true;
|
|
1909
1868
|
|
|
1910
|
-
} else if (
|
|
1869
|
+
} else if ( materialProperties.morphTargetsCount !== morphTargetsCount ) {
|
|
1911
1870
|
|
|
1912
1871
|
needsProgramChange = true;
|
|
1913
1872
|
|
|
@@ -2029,17 +1988,9 @@ class WebGLRenderer {
|
|
|
2029
1988
|
|
|
2030
1989
|
if ( skeleton ) {
|
|
2031
1990
|
|
|
2032
|
-
if (
|
|
2033
|
-
|
|
2034
|
-
if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture();
|
|
1991
|
+
if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture();
|
|
2035
1992
|
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
} else {
|
|
2039
|
-
|
|
2040
|
-
console.warn( 'THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required.' );
|
|
2041
|
-
|
|
2042
|
-
}
|
|
1993
|
+
p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );
|
|
2043
1994
|
|
|
2044
1995
|
}
|
|
2045
1996
|
|
|
@@ -2054,7 +2005,7 @@ class WebGLRenderer {
|
|
|
2054
2005
|
|
|
2055
2006
|
const morphAttributes = geometry.morphAttributes;
|
|
2056
2007
|
|
|
2057
|
-
if ( morphAttributes.position !== undefined || morphAttributes.normal !== undefined || ( morphAttributes.color !== undefined
|
|
2008
|
+
if ( morphAttributes.position !== undefined || morphAttributes.normal !== undefined || ( morphAttributes.color !== undefined ) ) {
|
|
2058
2009
|
|
|
2059
2010
|
morphtargets.update( object, geometry, program );
|
|
2060
2011
|
|
|
@@ -2077,6 +2028,12 @@ class WebGLRenderer {
|
|
|
2077
2028
|
|
|
2078
2029
|
}
|
|
2079
2030
|
|
|
2031
|
+
if ( material.isMeshStandardMaterial && material.envMap === null && scene.environment !== null ) {
|
|
2032
|
+
|
|
2033
|
+
m_uniforms.envMapIntensity.value = scene.environmentIntensity;
|
|
2034
|
+
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2080
2037
|
if ( refreshMaterial ) {
|
|
2081
2038
|
|
|
2082
2039
|
p_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );
|
|
@@ -2104,7 +2061,7 @@ class WebGLRenderer {
|
|
|
2104
2061
|
|
|
2105
2062
|
}
|
|
2106
2063
|
|
|
2107
|
-
materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height,
|
|
2064
|
+
materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, currentRenderState.state.transmissionRenderTarget );
|
|
2108
2065
|
|
|
2109
2066
|
WebGLUniforms.upload( _gl, getUniformList( materialProperties ), m_uniforms, textures );
|
|
2110
2067
|
|
|
@@ -2146,18 +2103,10 @@ class WebGLRenderer {
|
|
|
2146
2103
|
|
|
2147
2104
|
for ( let i = 0, l = groups.length; i < l; i ++ ) {
|
|
2148
2105
|
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
const group = groups[ i ];
|
|
2152
|
-
|
|
2153
|
-
uniformsGroups.update( group, program );
|
|
2154
|
-
uniformsGroups.bind( group, program );
|
|
2155
|
-
|
|
2156
|
-
} else {
|
|
2106
|
+
const group = groups[ i ];
|
|
2157
2107
|
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
}
|
|
2108
|
+
uniformsGroups.update( group, program );
|
|
2109
|
+
uniformsGroups.bind( group, program );
|
|
2161
2110
|
|
|
2162
2111
|
}
|
|
2163
2112
|
|
|
@@ -2326,7 +2275,7 @@ class WebGLRenderer {
|
|
|
2326
2275
|
|
|
2327
2276
|
isCube = true;
|
|
2328
2277
|
|
|
2329
|
-
} else if ( (
|
|
2278
|
+
} else if ( ( renderTarget.samples > 0 ) && textures.useMultisampledRTT( renderTarget ) === false ) {
|
|
2330
2279
|
|
|
2331
2280
|
framebuffer = properties.get( renderTarget ).__webglMultisampledFramebuffer;
|
|
2332
2281
|
|
|
@@ -2358,7 +2307,7 @@ class WebGLRenderer {
|
|
|
2358
2307
|
|
|
2359
2308
|
const framebufferBound = state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
2360
2309
|
|
|
2361
|
-
if ( framebufferBound &&
|
|
2310
|
+
if ( framebufferBound && useDefaultFramebuffer ) {
|
|
2362
2311
|
|
|
2363
2312
|
state.drawBuffers( renderTarget, framebuffer );
|
|
2364
2313
|
|
|
@@ -2419,11 +2368,10 @@ class WebGLRenderer {
|
|
|
2419
2368
|
|
|
2420
2369
|
}
|
|
2421
2370
|
|
|
2422
|
-
const halfFloatSupportedByExt = ( textureType === HalfFloatType ) && ( extensions.has( 'EXT_color_buffer_half_float' ) ||
|
|
2371
|
+
const halfFloatSupportedByExt = ( textureType === HalfFloatType ) && ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) );
|
|
2423
2372
|
|
|
2424
2373
|
if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // Edge and Chrome Mac < 52 (#9513)
|
|
2425
|
-
|
|
2426
|
-
! halfFloatSupportedByExt ) {
|
|
2374
|
+
textureType !== FloatType && ! halfFloatSupportedByExt ) {
|
|
2427
2375
|
|
|
2428
2376
|
console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );
|
|
2429
2377
|
return;
|
|
@@ -2507,13 +2455,6 @@ class WebGLRenderer {
|
|
|
2507
2455
|
|
|
2508
2456
|
this.copyTextureToTexture3D = function ( sourceBox, position, srcTexture, dstTexture, level = 0 ) {
|
|
2509
2457
|
|
|
2510
|
-
if ( _this.isWebGL1Renderer ) {
|
|
2511
|
-
|
|
2512
|
-
console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.' );
|
|
2513
|
-
return;
|
|
2514
|
-
|
|
2515
|
-
}
|
|
2516
|
-
|
|
2517
2458
|
const width = Math.round( sourceBox.max.x - sourceBox.min.x );
|
|
2518
2459
|
const height = Math.round( sourceBox.max.y - sourceBox.min.y );
|
|
2519
2460
|
const depth = sourceBox.max.z - sourceBox.min.z + 1;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export default /* glsl */`
|
|
2
|
-
#if defined( USE_LOGDEPTHBUF )
|
|
2
|
+
#if defined( USE_LOGDEPTHBUF )
|
|
3
3
|
|
|
4
4
|
// Doing a strict comparison with == 1.0 can cause noise artifacts
|
|
5
5
|
// on some platforms. See issue #17623.
|
|
6
|
-
|
|
6
|
+
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
7
7
|
|
|
8
8
|
#endif
|
|
9
9
|
`;
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
export default /* glsl */`
|
|
2
2
|
#ifdef USE_LOGDEPTHBUF
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
varying float vFragDepth;
|
|
7
|
-
varying float vIsPerspective;
|
|
8
|
-
|
|
9
|
-
#else
|
|
10
|
-
|
|
11
|
-
uniform float logDepthBufFC;
|
|
12
|
-
|
|
13
|
-
#endif
|
|
4
|
+
varying float vFragDepth;
|
|
5
|
+
varying float vIsPerspective;
|
|
14
6
|
|
|
15
7
|
#endif
|
|
16
8
|
`;
|
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
export default /* glsl */`
|
|
2
2
|
#ifdef USE_LOGDEPTHBUF
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
vFragDepth = 1.0 + gl_Position.w;
|
|
7
|
-
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
8
|
-
|
|
9
|
-
#else
|
|
10
|
-
|
|
11
|
-
if ( isPerspectiveMatrix( projectionMatrix ) ) {
|
|
12
|
-
|
|
13
|
-
gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
|
|
14
|
-
|
|
15
|
-
gl_Position.z *= gl_Position.w;
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
#endif
|
|
4
|
+
vFragDepth = 1.0 + gl_Position.w;
|
|
5
|
+
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
20
6
|
|
|
21
7
|
#endif
|
|
22
8
|
`;
|
|
@@ -273,40 +273,50 @@ export default /* glsl */`
|
|
|
273
273
|
|
|
274
274
|
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
|
275
275
|
|
|
276
|
-
|
|
276
|
+
float shadow = 1.0;
|
|
277
277
|
|
|
278
278
|
// for point lights, the uniform @vShadowCoord is re-purposed to hold
|
|
279
279
|
// the vector from the light to the world-space position of the fragment.
|
|
280
280
|
vec3 lightToPosition = shadowCoord.xyz;
|
|
281
|
+
|
|
282
|
+
float lightToPositionLength = length( lightToPosition );
|
|
281
283
|
|
|
282
|
-
|
|
283
|
-
float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?
|
|
284
|
-
dp += shadowBias;
|
|
284
|
+
if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
|
|
285
285
|
|
|
286
|
-
|
|
287
|
-
|
|
286
|
+
// dp = normalized distance from light to fragment position
|
|
287
|
+
float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?
|
|
288
|
+
dp += shadowBias;
|
|
288
289
|
|
|
289
|
-
|
|
290
|
+
// bd3D = base direction 3D
|
|
291
|
+
vec3 bd3D = normalize( lightToPosition );
|
|
290
292
|
|
|
291
|
-
vec2
|
|
293
|
+
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
|
292
294
|
|
|
293
|
-
|
|
294
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
|
|
295
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
|
|
296
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
|
|
297
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
|
|
298
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
|
|
299
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
|
|
300
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
|
|
301
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
|
|
302
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
|
|
303
|
-
) * ( 1.0 / 9.0 );
|
|
295
|
+
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
|
|
304
296
|
|
|
305
|
-
|
|
297
|
+
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
|
|
306
298
|
|
|
307
|
-
|
|
299
|
+
shadow = (
|
|
300
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
|
|
301
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
|
|
302
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
|
|
303
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
|
|
304
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
|
|
305
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
|
|
306
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
|
|
307
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
|
|
308
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
|
|
309
|
+
) * ( 1.0 / 9.0 );
|
|
308
310
|
|
|
309
|
-
|
|
311
|
+
#else // no percentage-closer filtering
|
|
312
|
+
|
|
313
|
+
shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
|
|
314
|
+
|
|
315
|
+
#endif
|
|
316
|
+
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return shadow;
|
|
310
320
|
|
|
311
321
|
}
|
|
312
322
|
|
|
@@ -185,7 +185,7 @@ vec3 NeutralToneMapping( vec3 color ) {
|
|
|
185
185
|
color *= newPeak / peak;
|
|
186
186
|
|
|
187
187
|
float g = 1. - 1. / (desaturation * (peak - newPeak) + 1.);
|
|
188
|
-
return mix(color, vec3(1, 1, 1), g);
|
|
188
|
+
return mix(color, newPeak * vec3(1, 1, 1), g);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
vec3 CustomToneMapping( vec3 color ) { return color; }
|
|
@@ -86,13 +86,22 @@ export function cloneUniformsGroups( src ) {
|
|
|
86
86
|
|
|
87
87
|
export function getUnlitUniformColorSpace( renderer ) {
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
const currentRenderTarget = renderer.getRenderTarget();
|
|
90
|
+
|
|
91
|
+
if ( currentRenderTarget === null ) {
|
|
90
92
|
|
|
91
93
|
// https://github.com/mrdoob/three.js/pull/23937#issuecomment-1111067398
|
|
92
94
|
return renderer.outputColorSpace;
|
|
93
95
|
|
|
94
96
|
}
|
|
95
97
|
|
|
98
|
+
// https://github.com/mrdoob/three.js/issues/27868
|
|
99
|
+
if ( currentRenderTarget.isXRRenderTarget === true ) {
|
|
100
|
+
|
|
101
|
+
return currentRenderTarget.texture.colorSpace;
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
96
105
|
return ColorManagement.workingColorSpace;
|
|
97
106
|
|
|
98
107
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
function WebGLAttributes( gl
|
|
2
|
-
|
|
3
|
-
const isWebGL2 = capabilities.isWebGL2;
|
|
1
|
+
function WebGLAttributes( gl ) {
|
|
4
2
|
|
|
5
3
|
const buffers = new WeakMap();
|
|
6
4
|
|
|
@@ -27,15 +25,7 @@ function WebGLAttributes( gl, capabilities ) {
|
|
|
27
25
|
|
|
28
26
|
if ( attribute.isFloat16BufferAttribute ) {
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
type = gl.HALF_FLOAT;
|
|
33
|
-
|
|
34
|
-
} else {
|
|
35
|
-
|
|
36
|
-
throw new Error( 'THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.' );
|
|
37
|
-
|
|
38
|
-
}
|
|
28
|
+
type = gl.HALF_FLOAT;
|
|
39
29
|
|
|
40
30
|
} else {
|
|
41
31
|
|
|
@@ -103,17 +93,9 @@ function WebGLAttributes( gl, capabilities ) {
|
|
|
103
93
|
for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
|
|
104
94
|
|
|
105
95
|
const range = updateRanges[ i ];
|
|
106
|
-
if ( isWebGL2 ) {
|
|
107
|
-
|
|
108
|
-
gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
|
|
109
|
-
array, range.start, range.count );
|
|
110
|
-
|
|
111
|
-
} else {
|
|
112
96
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
97
|
+
gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
|
|
98
|
+
array, range.start, range.count );
|
|
117
99
|
|
|
118
100
|
}
|
|
119
101
|
|
|
@@ -124,17 +106,8 @@ function WebGLAttributes( gl, capabilities ) {
|
|
|
124
106
|
// @deprecated, r159
|
|
125
107
|
if ( updateRange.count !== - 1 ) {
|
|
126
108
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
|
|
130
|
-
array, updateRange.offset, updateRange.count );
|
|
131
|
-
|
|
132
|
-
} else {
|
|
133
|
-
|
|
134
|
-
gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
|
|
135
|
-
array.subarray( updateRange.offset, updateRange.offset + updateRange.count ) );
|
|
136
|
-
|
|
137
|
-
}
|
|
109
|
+
gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
|
|
110
|
+
array, updateRange.offset, updateRange.count );
|
|
138
111
|
|
|
139
112
|
updateRange.count = - 1; // reset range
|
|
140
113
|
|