super-three 0.155.0 → 0.156.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 +107 -125
- package/build/three.js +107 -125
- package/build/three.min.js +1 -1
- package/build/three.module.js +104 -126
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/OrbitControls.js +13 -5
- package/examples/jsm/csm/CSMShader.js +35 -1
- package/examples/jsm/libs/tween.module.js +790 -735
- package/examples/jsm/libs/utif.module.js +1644 -1558
- package/examples/jsm/loaders/DDSLoader.js +46 -3
- package/examples/jsm/loaders/EXRLoader.js +4 -4
- package/examples/jsm/loaders/FBXLoader.js +2 -0
- package/examples/jsm/loaders/GLTFLoader.js +17 -7
- package/examples/jsm/loaders/KTX2Loader.js +126 -77
- package/examples/jsm/loaders/LogLuvLoader.js +2 -2
- package/examples/jsm/loaders/MMDLoader.js +10 -7
- package/examples/jsm/loaders/RGBELoader.js +48 -66
- package/examples/jsm/loaders/STLLoader.js +7 -0
- package/examples/jsm/nodes/Nodes.js +3 -0
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +28 -2
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +18 -3
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +2 -4
- package/examples/jsm/nodes/accessors/LineMaterialNode.js +31 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +55 -33
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +3 -0
- package/examples/jsm/nodes/accessors/Object3DNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureNode.js +6 -2
- package/examples/jsm/nodes/accessors/TextureStoreNode.js +29 -0
- package/examples/jsm/nodes/core/AttributeNode.js +2 -2
- package/examples/jsm/nodes/core/Node.js +17 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +94 -12
- package/examples/jsm/nodes/core/NodeUniform.js +1 -1
- package/examples/jsm/nodes/core/OutputStructNode.js +58 -0
- package/examples/jsm/nodes/core/PropertyNode.js +2 -0
- package/examples/jsm/nodes/core/StackNode.js +4 -4
- package/examples/jsm/nodes/core/StructTypeNode.js +24 -0
- package/examples/jsm/nodes/display/ViewportNode.js +19 -5
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -0
- package/examples/jsm/nodes/materials/Materials.js +1 -0
- package/examples/jsm/nodes/materials/NodeMaterial.js +12 -3
- package/examples/jsm/nodes/math/HashNode.js +35 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +4 -0
- package/examples/jsm/nodes/utils/SplitNode.js +1 -1
- package/examples/jsm/postprocessing/FilmPass.js +3 -5
- package/examples/jsm/postprocessing/RenderPass.js +30 -12
- package/examples/jsm/postprocessing/SAOPass.js +23 -98
- package/examples/jsm/postprocessing/SSAOPass.js +10 -30
- package/examples/jsm/renderers/common/Backend.js +11 -8
- package/examples/jsm/renderers/common/Binding.js +6 -0
- package/examples/jsm/renderers/common/Bindings.js +5 -4
- package/examples/jsm/renderers/common/Pipelines.js +2 -2
- package/examples/jsm/renderers/common/RenderContexts.js +26 -1
- package/examples/jsm/renderers/common/RenderList.js +12 -4
- package/examples/jsm/renderers/common/RenderObject.js +6 -2
- package/examples/jsm/renderers/common/Renderer.js +12 -3
- package/examples/jsm/renderers/common/SampledTexture.js +2 -1
- package/examples/jsm/renderers/common/Sampler.js +1 -1
- package/examples/jsm/renderers/common/StorageBuffer.js +1 -1
- package/examples/jsm/renderers/common/Textures.js +155 -15
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +1 -1
- package/examples/jsm/renderers/common/nodes/Nodes.js +43 -9
- package/examples/jsm/renderers/webgl/WebGLBackend.js +607 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +118 -17
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +84 -0
- package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +26 -0
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +529 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +199 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +242 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +340 -0
- package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodeBuilder.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +279 -40
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +18 -2
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +89 -59
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -2
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +15 -2
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +34 -9
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +26 -135
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +6 -5
- package/examples/jsm/shaders/FilmShader.js +11 -54
- package/examples/jsm/shaders/SAOShader.js +0 -13
- package/examples/jsm/shaders/SSAOShader.js +33 -26
- package/package.json +1 -1
- package/src/Three.js +1 -0
- package/src/audio/Audio.js +6 -0
- package/src/constants.js +4 -1
- package/src/core/Object3D.js +1 -14
- package/src/core/UniformsGroup.js +2 -2
- package/src/loaders/DataTextureLoader.js +0 -2
- package/src/materials/Material.js +2 -2
- package/src/math/Vector2.js +2 -2
- package/src/math/Vector3.js +3 -3
- package/src/math/Vector4.js +4 -4
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/renderers/WebGLRenderer.js +21 -49
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +11 -1
- package/src/renderers/shaders/ShaderLib/background.glsl.js +8 -0
- package/src/renderers/webgl/WebGLBackground.js +5 -14
- package/src/renderers/webgl/WebGLProgram.js +2 -0
- package/src/renderers/webgl/WebGLPrograms.js +5 -1
- package/src/renderers/webgl/WebGLTextures.js +4 -4
- package/src/renderers/webgl/WebGLUtils.js +27 -20
- package/src/textures/Texture.js +2 -2
- package/src/utils.js +9 -1
- /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/SlotNode.js +0 -0
- /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodes.js +0 -0
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
CubeTexture, Texture,
|
|
7
|
-
NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter,
|
|
7
|
+
NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter,
|
|
8
8
|
RepeatWrapping, MirroredRepeatWrapping,
|
|
9
9
|
RGB_ETC2_Format, RGBA_ETC2_EAC_Format,
|
|
10
10
|
RGBAFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType, SRGBColorSpace, DepthFormat, DepthStencilFormat,
|
|
@@ -97,11 +97,13 @@ class WebGPUTextureUtils {
|
|
|
97
97
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
if ( options.needsMipmaps === undefined ) options.needsMipmaps = false;
|
|
101
|
+
if ( options.levels === undefined ) options.levels = 1;
|
|
102
|
+
if ( options.depth === undefined ) options.depth = 1;
|
|
103
|
+
|
|
104
|
+
const { width, height, depth, levels } = options;
|
|
101
105
|
|
|
102
|
-
const needsMipmaps = this._needsMipmaps( texture );
|
|
103
106
|
const dimension = this._getDimension( texture );
|
|
104
|
-
const mipLevelCount = this._getMipLevelCount( texture, width, height, needsMipmaps );
|
|
105
107
|
const format = texture.internalFormat || this._getFormat( texture );
|
|
106
108
|
|
|
107
109
|
const sampleCount = options.sampleCount !== undefined ? options.sampleCount : 1;
|
|
@@ -109,6 +111,12 @@ class WebGPUTextureUtils {
|
|
|
109
111
|
|
|
110
112
|
let usage = GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC;
|
|
111
113
|
|
|
114
|
+
if ( options.store === true ) {
|
|
115
|
+
|
|
116
|
+
usage |= GPUTextureUsage.STORAGE_BINDING;
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
112
120
|
if ( texture.isCompressedTexture !== true ) {
|
|
113
121
|
|
|
114
122
|
usage |= GPUTextureUsage.RENDER_ATTACHMENT;
|
|
@@ -122,7 +130,7 @@ class WebGPUTextureUtils {
|
|
|
122
130
|
height: height,
|
|
123
131
|
depthOrArrayLayers: depth,
|
|
124
132
|
},
|
|
125
|
-
mipLevelCount:
|
|
133
|
+
mipLevelCount: levels,
|
|
126
134
|
sampleCount: primarySampleCount,
|
|
127
135
|
dimension: dimension,
|
|
128
136
|
format: format,
|
|
@@ -170,7 +178,6 @@ class WebGPUTextureUtils {
|
|
|
170
178
|
|
|
171
179
|
textureData.initialized = true;
|
|
172
180
|
|
|
173
|
-
textureData.needsMipmaps = needsMipmaps;
|
|
174
181
|
textureData.textureDescriptorGPU = textureDescriptorGPU;
|
|
175
182
|
|
|
176
183
|
}
|
|
@@ -217,20 +224,20 @@ class WebGPUTextureUtils {
|
|
|
217
224
|
|
|
218
225
|
}
|
|
219
226
|
|
|
220
|
-
updateTexture( texture ) {
|
|
227
|
+
updateTexture( texture, options ) {
|
|
221
228
|
|
|
222
229
|
const textureData = this.backend.get( texture );
|
|
223
230
|
|
|
224
|
-
const {
|
|
231
|
+
const { textureDescriptorGPU } = textureData;
|
|
225
232
|
|
|
226
|
-
if ( textureDescriptorGPU === undefined
|
|
233
|
+
if ( texture.isRenderTargetTexture || ( textureDescriptorGPU === undefined /* unsupported texture format */ ) )
|
|
227
234
|
return;
|
|
228
235
|
|
|
229
236
|
// transfer texture data
|
|
230
237
|
|
|
231
238
|
if ( texture.isDataTexture || texture.isDataArrayTexture || texture.isData3DTexture ) {
|
|
232
239
|
|
|
233
|
-
this._copyBufferToTexture(
|
|
240
|
+
this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU );
|
|
234
241
|
|
|
235
242
|
} else if ( texture.isCompressedTexture ) {
|
|
236
243
|
|
|
@@ -238,15 +245,7 @@ class WebGPUTextureUtils {
|
|
|
238
245
|
|
|
239
246
|
} else if ( texture.isCubeTexture ) {
|
|
240
247
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
this._copyCubeMapToTexture( texture.image, texture, textureData.texture, textureDescriptorGPU, needsMipmaps );
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
} else if ( texture.isRenderTargetTexture ) {
|
|
248
|
-
|
|
249
|
-
if ( needsMipmaps === true ) this._generateMipmaps( textureData.texture, textureDescriptorGPU );
|
|
248
|
+
this._copyCubeMapToTexture( options.images, texture, textureData.texture, textureDescriptorGPU );
|
|
250
249
|
|
|
251
250
|
} else if ( texture.isVideoTexture ) {
|
|
252
251
|
|
|
@@ -254,13 +253,9 @@ class WebGPUTextureUtils {
|
|
|
254
253
|
|
|
255
254
|
textureData.externalTexture = video;
|
|
256
255
|
|
|
257
|
-
} else if ( texture.image !== null ) {
|
|
258
|
-
|
|
259
|
-
this._copyImageToTexture( texture.image, texture, textureData.texture, textureDescriptorGPU, needsMipmaps );
|
|
260
|
-
|
|
261
256
|
} else {
|
|
262
257
|
|
|
263
|
-
|
|
258
|
+
this._copyImageToTexture( options.image, textureData.texture );
|
|
264
259
|
|
|
265
260
|
}
|
|
266
261
|
|
|
@@ -336,7 +331,7 @@ class WebGPUTextureUtils {
|
|
|
336
331
|
texture.minFilter = NearestFilter;
|
|
337
332
|
texture.magFilter = NearestFilter;
|
|
338
333
|
|
|
339
|
-
this.createTexture( texture );
|
|
334
|
+
this.createTexture( texture, { width: 1, height: 1 } );
|
|
340
335
|
|
|
341
336
|
this.defaultTexture = defaultTexture = texture;
|
|
342
337
|
|
|
@@ -356,7 +351,7 @@ class WebGPUTextureUtils {
|
|
|
356
351
|
texture.minFilter = NearestFilter;
|
|
357
352
|
texture.magFilter = NearestFilter;
|
|
358
353
|
|
|
359
|
-
this.createTexture( texture );
|
|
354
|
+
this.createTexture( texture, { width: 1, height: 1, depth: 6 } );
|
|
360
355
|
|
|
361
356
|
this.defaultCubeTexture = defaultCubeTexture = texture;
|
|
362
357
|
|
|
@@ -366,33 +361,7 @@ class WebGPUTextureUtils {
|
|
|
366
361
|
|
|
367
362
|
}
|
|
368
363
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
if ( this._isHTMLImage( image ) ) {
|
|
372
|
-
|
|
373
|
-
this._getImageBitmapFromHTML( image, texture ).then( imageBitmap => {
|
|
374
|
-
|
|
375
|
-
this._copyExternalImageToTexture( imageBitmap, textureGPU, textureDescriptorGPU, needsMipmaps, originDepth );
|
|
376
|
-
|
|
377
|
-
} );
|
|
378
|
-
|
|
379
|
-
} else {
|
|
380
|
-
|
|
381
|
-
// assume ImageBitmap
|
|
382
|
-
|
|
383
|
-
this._copyExternalImageToTexture( image, textureGPU, textureDescriptorGPU, needsMipmaps, originDepth );
|
|
384
|
-
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
_isHTMLImage( image ) {
|
|
390
|
-
|
|
391
|
-
return ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) || ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement );
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
_copyCubeMapToTexture( images, texture, textureGPU, textureDescriptorGPU, needsMipmaps ) {
|
|
364
|
+
_copyCubeMapToTexture( images, texture, textureGPU, textureDescriptorGPU ) {
|
|
396
365
|
|
|
397
366
|
for ( let i = 0; i < 6; i ++ ) {
|
|
398
367
|
|
|
@@ -400,11 +369,11 @@ class WebGPUTextureUtils {
|
|
|
400
369
|
|
|
401
370
|
if ( image.isDataTexture ) {
|
|
402
371
|
|
|
403
|
-
this._copyBufferToTexture( image.image, textureGPU, textureDescriptorGPU,
|
|
372
|
+
this._copyBufferToTexture( image.image, textureGPU, textureDescriptorGPU, i );
|
|
404
373
|
|
|
405
374
|
} else {
|
|
406
375
|
|
|
407
|
-
this._copyImageToTexture( image,
|
|
376
|
+
this._copyImageToTexture( image, textureGPU, i );
|
|
408
377
|
|
|
409
378
|
}
|
|
410
379
|
|
|
@@ -412,7 +381,7 @@ class WebGPUTextureUtils {
|
|
|
412
381
|
|
|
413
382
|
}
|
|
414
383
|
|
|
415
|
-
|
|
384
|
+
_copyImageToTexture( image, textureGPU, originDepth = 0 ) {
|
|
416
385
|
|
|
417
386
|
const device = this.backend.device;
|
|
418
387
|
|
|
@@ -430,8 +399,6 @@ class WebGPUTextureUtils {
|
|
|
430
399
|
}
|
|
431
400
|
);
|
|
432
401
|
|
|
433
|
-
if ( needsMipmaps ) this._generateMipmaps( textureGPU, textureDescriptorGPU, originDepth );
|
|
434
|
-
|
|
435
402
|
}
|
|
436
403
|
|
|
437
404
|
_generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer = 0 ) {
|
|
@@ -446,21 +413,7 @@ class WebGPUTextureUtils {
|
|
|
446
413
|
|
|
447
414
|
}
|
|
448
415
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
const width = image.width;
|
|
452
|
-
const height = image.height;
|
|
453
|
-
|
|
454
|
-
const options = {};
|
|
455
|
-
|
|
456
|
-
options.imageOrientation = ( texture.flipY === true ) ? 'flipY' : 'none';
|
|
457
|
-
options.premultiplyAlpha = ( texture.premultiplyAlpha === true ) ? 'premultiply' : 'default';
|
|
458
|
-
|
|
459
|
-
return createImageBitmap( image, 0, 0, width, height, options );
|
|
460
|
-
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
_copyBufferToTexture( image, textureGPU, textureDescriptorGPU, needsMipmaps, originDepth = 0 ) {
|
|
416
|
+
_copyBufferToTexture( image, textureGPU, textureDescriptorGPU, originDepth = 0 ) {
|
|
464
417
|
|
|
465
418
|
// @TODO: Consider to use GPUCommandEncoder.copyBufferToTexture()
|
|
466
419
|
// @TODO: Consider to support valid buffer layouts with other formats like RGB
|
|
@@ -489,8 +442,6 @@ class WebGPUTextureUtils {
|
|
|
489
442
|
depthOrArrayLayers: ( image.depth !== undefined ) ? image.depth : 1
|
|
490
443
|
} );
|
|
491
444
|
|
|
492
|
-
if ( needsMipmaps === true ) this._generateMipmaps( textureGPU, textureDescriptorGPU, originDepth );
|
|
493
|
-
|
|
494
445
|
}
|
|
495
446
|
|
|
496
447
|
_copyCompressedBufferToTexture( mipmaps, textureGPU, textureDescriptorGPU ) {
|
|
@@ -600,44 +551,6 @@ class WebGPUTextureUtils {
|
|
|
600
551
|
|
|
601
552
|
}
|
|
602
553
|
|
|
603
|
-
_getSize( texture ) {
|
|
604
|
-
|
|
605
|
-
const image = texture.image;
|
|
606
|
-
|
|
607
|
-
let width, height, depth;
|
|
608
|
-
|
|
609
|
-
if ( texture.isCubeTexture ) {
|
|
610
|
-
|
|
611
|
-
const faceImage = image.length > 0 ? image[ 0 ].image || image[ 0 ] : null;
|
|
612
|
-
|
|
613
|
-
width = faceImage ? faceImage.width : 1;
|
|
614
|
-
height = faceImage ? faceImage.height : 1;
|
|
615
|
-
depth = 6; // one image for each side of the cube map
|
|
616
|
-
|
|
617
|
-
} else if ( image !== null ) {
|
|
618
|
-
|
|
619
|
-
width = image.width;
|
|
620
|
-
height = image.height;
|
|
621
|
-
depth = ( image.depth !== undefined ) ? image.depth : 1;
|
|
622
|
-
|
|
623
|
-
} else {
|
|
624
|
-
|
|
625
|
-
width = height = depth = 1;
|
|
626
|
-
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
return { width, height, depth };
|
|
630
|
-
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
_needsMipmaps( texture ) {
|
|
634
|
-
|
|
635
|
-
if ( this._isEnvironmentTexture( texture ) ) return true;
|
|
636
|
-
|
|
637
|
-
return ( texture.isCompressedTexture !== true ) /*&& ( texture.generateMipmaps === true )*/ && ( texture.minFilter !== NearestFilter ) && ( texture.minFilter !== LinearFilter );
|
|
638
|
-
|
|
639
|
-
}
|
|
640
|
-
|
|
641
554
|
_getBytesPerTexel( format ) {
|
|
642
555
|
|
|
643
556
|
if ( format === GPUTextureFormat.R8Unorm ) return 1;
|
|
@@ -706,28 +619,6 @@ class WebGPUTextureUtils {
|
|
|
706
619
|
|
|
707
620
|
}
|
|
708
621
|
|
|
709
|
-
_getMipLevelCount( texture, width, height, needsMipmaps ) {
|
|
710
|
-
|
|
711
|
-
let mipLevelCount;
|
|
712
|
-
|
|
713
|
-
if ( texture.isCompressedTexture ) {
|
|
714
|
-
|
|
715
|
-
mipLevelCount = texture.mipmaps.length;
|
|
716
|
-
|
|
717
|
-
} else if ( needsMipmaps ) {
|
|
718
|
-
|
|
719
|
-
mipLevelCount = Math.floor( Math.log2( Math.max( width, height ) ) ) + 1;
|
|
720
|
-
|
|
721
|
-
} else {
|
|
722
|
-
|
|
723
|
-
mipLevelCount = 1; // a texture without mipmaps has a base mip (mipLevel 0)
|
|
724
|
-
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
return mipLevelCount;
|
|
728
|
-
|
|
729
|
-
}
|
|
730
|
-
|
|
731
622
|
_getFormat( texture ) {
|
|
732
623
|
|
|
733
624
|
const format = texture.format;
|
|
@@ -40,9 +40,10 @@ class WebGPUUtils {
|
|
|
40
40
|
|
|
41
41
|
let format;
|
|
42
42
|
|
|
43
|
-
if ( renderContext.
|
|
43
|
+
if ( renderContext.textures !== null ) {
|
|
44
|
+
|
|
45
|
+
format = this.getTextureFormatGPU( renderContext.textures[ 0 ] );
|
|
44
46
|
|
|
45
|
-
format = this.getTextureFormatGPU( renderContext.texture );
|
|
46
47
|
|
|
47
48
|
} else {
|
|
48
49
|
|
|
@@ -56,9 +57,9 @@ class WebGPUUtils {
|
|
|
56
57
|
|
|
57
58
|
getCurrentColorSpace( renderContext ) {
|
|
58
59
|
|
|
59
|
-
if ( renderContext.
|
|
60
|
+
if ( renderContext.textures !== null ) {
|
|
60
61
|
|
|
61
|
-
return renderContext.
|
|
62
|
+
return renderContext.textures[ 0 ].colorSpace;
|
|
62
63
|
|
|
63
64
|
}
|
|
64
65
|
|
|
@@ -77,7 +78,7 @@ class WebGPUUtils {
|
|
|
77
78
|
|
|
78
79
|
getSampleCount( renderContext ) {
|
|
79
80
|
|
|
80
|
-
if ( renderContext.
|
|
81
|
+
if ( renderContext.textures !== null ) {
|
|
81
82
|
|
|
82
83
|
return renderContext.sampleCount;
|
|
83
84
|
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Film grain & scanlines shader
|
|
3
|
-
*
|
|
4
|
-
* - ported from HLSL to WebGL / GLSL
|
|
5
|
-
* https://web.archive.org/web/20210226214859/http://www.truevision3d.com/forums/showcase/staticnoise_colorblackwhite_scanline_shaders-t18698.0.html
|
|
6
|
-
*
|
|
7
|
-
* Screen Space Static Postprocessor
|
|
8
|
-
*
|
|
9
|
-
* Produces an analogue noise overlay similar to a film grain / TV static
|
|
10
|
-
*
|
|
11
|
-
* Original implementation and noise algorithm
|
|
12
|
-
* Pat 'Hawthorne' Shearon
|
|
13
|
-
*
|
|
14
|
-
* Optimized scanlines + noise version with intensity scaling
|
|
15
|
-
* Georg 'Leviathan' Steinrohder
|
|
16
|
-
*
|
|
17
|
-
* This version is provided under a Creative Commons Attribution 3.0 License
|
|
18
|
-
* http://creativecommons.org/licenses/by/3.0/
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
1
|
const FilmShader = {
|
|
22
2
|
|
|
23
3
|
name: 'FilmShader',
|
|
@@ -26,10 +6,8 @@ const FilmShader = {
|
|
|
26
6
|
|
|
27
7
|
'tDiffuse': { value: null },
|
|
28
8
|
'time': { value: 0.0 },
|
|
29
|
-
'
|
|
30
|
-
'
|
|
31
|
-
'sCount': { value: 4096 },
|
|
32
|
-
'grayscale': { value: 1 }
|
|
9
|
+
'intensity': { value: 0.5 },
|
|
10
|
+
'grayscale': { value: false }
|
|
33
11
|
|
|
34
12
|
},
|
|
35
13
|
|
|
@@ -48,19 +26,9 @@ const FilmShader = {
|
|
|
48
26
|
|
|
49
27
|
#include <common>
|
|
50
28
|
|
|
51
|
-
|
|
52
|
-
uniform float time;
|
|
53
|
-
|
|
29
|
+
uniform float intensity;
|
|
54
30
|
uniform bool grayscale;
|
|
55
|
-
|
|
56
|
-
// noise effect intensity value (0 = no effect, 1 = full effect)
|
|
57
|
-
uniform float nIntensity;
|
|
58
|
-
|
|
59
|
-
// scanlines effect intensity value (0 = no effect, 1 = full effect)
|
|
60
|
-
uniform float sIntensity;
|
|
61
|
-
|
|
62
|
-
// scanlines effect count value (0 = no effect, 4096 = full effect)
|
|
63
|
-
uniform float sCount;
|
|
31
|
+
uniform float time;
|
|
64
32
|
|
|
65
33
|
uniform sampler2D tDiffuse;
|
|
66
34
|
|
|
@@ -68,32 +36,21 @@ const FilmShader = {
|
|
|
68
36
|
|
|
69
37
|
void main() {
|
|
70
38
|
|
|
71
|
-
|
|
72
|
-
vec4 cTextureScreen = texture2D( tDiffuse, vUv );
|
|
73
|
-
|
|
74
|
-
// make some noise
|
|
75
|
-
float dx = rand( vUv + time );
|
|
76
|
-
|
|
77
|
-
// add noise
|
|
78
|
-
vec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx, 0.0, 1.0 );
|
|
39
|
+
vec4 base = texture2D( tDiffuse, vUv );
|
|
79
40
|
|
|
80
|
-
|
|
81
|
-
vec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );
|
|
41
|
+
float noise = rand( vUv + time );
|
|
82
42
|
|
|
83
|
-
|
|
84
|
-
cResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;
|
|
43
|
+
vec3 color = base.rgb + base.rgb * clamp( 0.1 + noise, 0.0, 1.0 );
|
|
85
44
|
|
|
86
|
-
|
|
87
|
-
cResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );
|
|
45
|
+
color = mix( base.rgb, color, intensity );
|
|
88
46
|
|
|
89
|
-
|
|
90
|
-
if( grayscale ) {
|
|
47
|
+
if ( grayscale ) {
|
|
91
48
|
|
|
92
|
-
|
|
49
|
+
color = vec3( luminance( color ) ); // assuming linear-srgb
|
|
93
50
|
|
|
94
51
|
}
|
|
95
52
|
|
|
96
|
-
gl_FragColor =
|
|
53
|
+
gl_FragColor = vec4( color, base.a );
|
|
97
54
|
|
|
98
55
|
}`,
|
|
99
56
|
|
|
@@ -11,9 +11,7 @@ const SAOShader = {
|
|
|
11
11
|
defines: {
|
|
12
12
|
'NUM_SAMPLES': 7,
|
|
13
13
|
'NUM_RINGS': 4,
|
|
14
|
-
'NORMAL_TEXTURE': 0,
|
|
15
14
|
'DIFFUSE_TEXTURE': 0,
|
|
16
|
-
'DEPTH_PACKING': 1,
|
|
17
15
|
'PERSPECTIVE_CAMERA': 1
|
|
18
16
|
},
|
|
19
17
|
uniforms: {
|
|
@@ -56,10 +54,7 @@ const SAOShader = {
|
|
|
56
54
|
#endif
|
|
57
55
|
|
|
58
56
|
uniform sampler2D tDepth;
|
|
59
|
-
|
|
60
|
-
#if NORMAL_TEXTURE == 1
|
|
61
57
|
uniform sampler2D tNormal;
|
|
62
|
-
#endif
|
|
63
58
|
|
|
64
59
|
uniform float cameraNear;
|
|
65
60
|
uniform float cameraFar;
|
|
@@ -87,11 +82,7 @@ const SAOShader = {
|
|
|
87
82
|
}
|
|
88
83
|
|
|
89
84
|
float getDepth( const in vec2 screenPosition ) {
|
|
90
|
-
#if DEPTH_PACKING == 1
|
|
91
|
-
return unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );
|
|
92
|
-
#else
|
|
93
85
|
return texture2D( tDepth, screenPosition ).x;
|
|
94
|
-
#endif
|
|
95
86
|
}
|
|
96
87
|
|
|
97
88
|
float getViewZ( const in float depth ) {
|
|
@@ -111,11 +102,7 @@ const SAOShader = {
|
|
|
111
102
|
}
|
|
112
103
|
|
|
113
104
|
vec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {
|
|
114
|
-
#if NORMAL_TEXTURE == 1
|
|
115
105
|
return unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );
|
|
116
|
-
#else
|
|
117
|
-
return normalize( cross( dFdx( viewPosition ), dFdy( viewPosition ) ) );
|
|
118
|
-
#endif
|
|
119
106
|
}
|
|
120
107
|
|
|
121
108
|
float scaleDividedByCameraFar;
|
|
@@ -19,7 +19,6 @@ const SSAOShader = {
|
|
|
19
19
|
|
|
20
20
|
uniforms: {
|
|
21
21
|
|
|
22
|
-
'tDiffuse': { value: null },
|
|
23
22
|
'tNormal': { value: null },
|
|
24
23
|
'tDepth': { value: null },
|
|
25
24
|
'tNoise': { value: null },
|
|
@@ -49,7 +48,6 @@ const SSAOShader = {
|
|
|
49
48
|
|
|
50
49
|
fragmentShader: /* glsl */`
|
|
51
50
|
|
|
52
|
-
uniform sampler2D tDiffuse;
|
|
53
51
|
uniform sampler2D tNormal;
|
|
54
52
|
uniform sampler2D tDepth;
|
|
55
53
|
uniform sampler2D tNoise;
|
|
@@ -128,47 +126,56 @@ const SSAOShader = {
|
|
|
128
126
|
void main() {
|
|
129
127
|
|
|
130
128
|
float depth = getDepth( vUv );
|
|
131
|
-
float viewZ = getViewZ( depth );
|
|
132
129
|
|
|
133
|
-
|
|
134
|
-
|
|
130
|
+
if ( depth == 1.0 ) {
|
|
131
|
+
|
|
132
|
+
gl_FragColor = vec4( 1.0 ); // don't influence background
|
|
133
|
+
|
|
134
|
+
} else {
|
|
135
|
+
|
|
136
|
+
float viewZ = getViewZ( depth );
|
|
137
|
+
|
|
138
|
+
vec3 viewPosition = getViewPosition( vUv, depth, viewZ );
|
|
139
|
+
vec3 viewNormal = getViewNormal( vUv );
|
|
135
140
|
|
|
136
|
-
|
|
137
|
-
|
|
141
|
+
vec2 noiseScale = vec2( resolution.x / 4.0, resolution.y / 4.0 );
|
|
142
|
+
vec3 random = vec3( texture2D( tNoise, vUv * noiseScale ).r );
|
|
138
143
|
|
|
139
|
-
|
|
144
|
+
// compute matrix used to reorient a kernel vector
|
|
140
145
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
146
|
+
vec3 tangent = normalize( random - viewNormal * dot( random, viewNormal ) );
|
|
147
|
+
vec3 bitangent = cross( viewNormal, tangent );
|
|
148
|
+
mat3 kernelMatrix = mat3( tangent, bitangent, viewNormal );
|
|
144
149
|
|
|
145
|
-
|
|
150
|
+
float occlusion = 0.0;
|
|
146
151
|
|
|
147
|
-
|
|
152
|
+
for ( int i = 0; i < KERNEL_SIZE; i ++ ) {
|
|
148
153
|
|
|
149
|
-
|
|
150
|
-
|
|
154
|
+
vec3 sampleVector = kernelMatrix * kernel[ i ]; // reorient sample vector in view space
|
|
155
|
+
vec3 samplePoint = viewPosition + ( sampleVector * kernelRadius ); // calculate sample point
|
|
151
156
|
|
|
152
|
-
|
|
153
|
-
|
|
157
|
+
vec4 samplePointNDC = cameraProjectionMatrix * vec4( samplePoint, 1.0 ); // project point and calculate NDC
|
|
158
|
+
samplePointNDC /= samplePointNDC.w;
|
|
154
159
|
|
|
155
|
-
|
|
160
|
+
vec2 samplePointUv = samplePointNDC.xy * 0.5 + 0.5; // compute uv coordinates
|
|
156
161
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
162
|
+
float realDepth = getLinearDepth( samplePointUv ); // get linear depth from depth texture
|
|
163
|
+
float sampleDepth = viewZToOrthographicDepth( samplePoint.z, cameraNear, cameraFar ); // compute linear depth of the sample view Z value
|
|
164
|
+
float delta = sampleDepth - realDepth;
|
|
160
165
|
|
|
161
|
-
|
|
166
|
+
if ( delta > minDistance && delta < maxDistance ) { // if fragment is before sample point, increase occlusion
|
|
162
167
|
|
|
163
|
-
|
|
168
|
+
occlusion += 1.0;
|
|
169
|
+
|
|
170
|
+
}
|
|
164
171
|
|
|
165
172
|
}
|
|
166
173
|
|
|
167
|
-
|
|
174
|
+
occlusion = clamp( occlusion / float( KERNEL_SIZE ), 0.0, 1.0 );
|
|
168
175
|
|
|
169
|
-
|
|
176
|
+
gl_FragColor = vec4( vec3( 1.0 - occlusion ), 1.0 );
|
|
170
177
|
|
|
171
|
-
|
|
178
|
+
}
|
|
172
179
|
|
|
173
180
|
}`
|
|
174
181
|
|
package/package.json
CHANGED
package/src/Three.js
CHANGED
|
@@ -158,6 +158,7 @@ export { ImageUtils } from './extras/ImageUtils.js';
|
|
|
158
158
|
export { ShapeUtils } from './extras/ShapeUtils.js';
|
|
159
159
|
export { PMREMGenerator } from './extras/PMREMGenerator.js';
|
|
160
160
|
export { WebGLUtils } from './renderers/webgl/WebGLUtils.js';
|
|
161
|
+
export { createCanvasElement } from './utils.js';
|
|
161
162
|
export * from './constants.js';
|
|
162
163
|
export * from './Three.Legacy.js';
|
|
163
164
|
|
package/src/audio/Audio.js
CHANGED
package/src/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const REVISION = '
|
|
1
|
+
export const REVISION = '156';
|
|
2
2
|
|
|
3
3
|
export const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
|
|
4
4
|
export const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
|
|
@@ -122,6 +122,8 @@ export const RGBA_ASTC_10x10_Format = 37819;
|
|
|
122
122
|
export const RGBA_ASTC_12x10_Format = 37820;
|
|
123
123
|
export const RGBA_ASTC_12x12_Format = 37821;
|
|
124
124
|
export const RGBA_BPTC_Format = 36492;
|
|
125
|
+
export const RGB_BPTC_SIGNED_Format = 36494;
|
|
126
|
+
export const RGB_BPTC_UNSIGNED_Format = 36495;
|
|
125
127
|
export const RED_RGTC1_Format = 36283;
|
|
126
128
|
export const SIGNED_RED_RGTC1_Format = 36284;
|
|
127
129
|
export const RED_GREEN_RGTC2_Format = 36285;
|
|
@@ -154,6 +156,7 @@ export const NoColorSpace = '';
|
|
|
154
156
|
export const SRGBColorSpace = 'srgb';
|
|
155
157
|
export const LinearSRGBColorSpace = 'srgb-linear';
|
|
156
158
|
export const DisplayP3ColorSpace = 'display-p3';
|
|
159
|
+
export const LinearDisplayP3ColorSpace = 'display-p3-linear';
|
|
157
160
|
|
|
158
161
|
export const ZeroStencilOp = 0;
|
|
159
162
|
export const KeepStencilOp = 7680;
|
package/src/core/Object3D.js
CHANGED
|
@@ -392,20 +392,7 @@ class Object3D extends EventDispatcher {
|
|
|
392
392
|
|
|
393
393
|
clear() {
|
|
394
394
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
const object = this.children[ i ];
|
|
398
|
-
|
|
399
|
-
object.parent = null;
|
|
400
|
-
|
|
401
|
-
object.dispatchEvent( _removedEvent );
|
|
402
|
-
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
this.children.length = 0;
|
|
406
|
-
|
|
407
|
-
return this;
|
|
408
|
-
|
|
395
|
+
return this.remove( ... this.children );
|
|
409
396
|
|
|
410
397
|
}
|
|
411
398
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EventDispatcher } from './EventDispatcher.js';
|
|
2
2
|
import { StaticDrawUsage } from '../constants.js';
|
|
3
3
|
|
|
4
|
-
let
|
|
4
|
+
let _id = 0;
|
|
5
5
|
|
|
6
6
|
class UniformsGroup extends EventDispatcher {
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ class UniformsGroup extends EventDispatcher {
|
|
|
11
11
|
|
|
12
12
|
this.isUniformsGroup = true;
|
|
13
13
|
|
|
14
|
-
Object.defineProperty( this, 'id', { value:
|
|
14
|
+
Object.defineProperty( this, 'id', { value: _id ++ } );
|
|
15
15
|
|
|
16
16
|
this.name = '';
|
|
17
17
|
|