super-three 0.172.0 → 0.173.1
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/LICENSE +1 -1
- package/build/three.cjs +439 -380
- package/build/three.core.js +413 -41
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +28 -344
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +11 -3
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +7550 -1798
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +7551 -1798
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/animation/CCDIKSolver.js +6 -5
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +23 -21
- package/examples/jsm/exporters/GLTFExporter.js +26 -25
- package/examples/jsm/geometries/TextGeometry.js +1 -12
- package/examples/jsm/interactive/InteractiveGroup.js +108 -51
- package/examples/jsm/libs/demuxer_mp4.js +109 -0
- package/examples/jsm/loaders/GCodeLoader.js +3 -1
- package/examples/jsm/loaders/GLTFLoader.js +0 -2
- package/examples/jsm/loaders/TDSLoader.js +0 -1
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -0
- package/examples/jsm/misc/GPUComputationRenderer.js +6 -7
- package/examples/jsm/misc/ProgressiveLightMap.js +4 -3
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +4 -3
- package/examples/jsm/misc/Volume.js +7 -5
- package/examples/jsm/misc/VolumeSlice.js +5 -3
- package/examples/jsm/objects/WaterMesh.js +25 -20
- package/examples/jsm/physics/JoltPhysics.js +7 -7
- package/examples/jsm/physics/RapierPhysics.js +4 -4
- package/examples/jsm/postprocessing/EffectComposer.js +23 -2
- package/examples/jsm/postprocessing/OutputPass.js +2 -0
- package/examples/jsm/postprocessing/Pass.js +6 -1
- package/examples/jsm/shaders/OutputShader.js +5 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +2 -0
- package/package.json +1 -1
- package/src/Three.Core.js +2 -0
- package/src/Three.TSL.js +9 -1
- package/src/cameras/ArrayCamera.js +1 -0
- package/src/constants.js +6 -1
- package/src/core/BufferAttribute.js +4 -0
- package/src/core/EventDispatcher.js +8 -6
- package/src/extras/ImageUtils.js +1 -11
- package/src/loaders/nodes/NodeObjectLoader.js +1 -1
- package/src/materials/nodes/MeshBasicNodeMaterial.js +1 -1
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +1 -1
- package/src/materials/nodes/NodeMaterial.js +5 -5
- package/src/materials/nodes/NodeMaterials.js +0 -1
- package/src/materials/nodes/PointsNodeMaterial.js +109 -7
- package/src/materials/nodes/SpriteNodeMaterial.js +1 -1
- package/src/materials/nodes/VolumeNodeMaterial.js +3 -3
- package/src/materials/nodes/manager/NodeMaterialObserver.js +8 -0
- package/src/nodes/Nodes.js +4 -0
- package/src/nodes/TSL.js +4 -0
- package/src/nodes/accessors/Arrays.js +30 -8
- package/src/nodes/accessors/BatchNode.js +3 -3
- package/src/nodes/accessors/BufferAttributeNode.js +1 -1
- package/src/nodes/accessors/Camera.js +64 -3
- package/src/nodes/accessors/InstanceNode.js +1 -1
- package/src/nodes/accessors/MaterialNode.js +9 -9
- package/src/nodes/accessors/ModelViewProjectionNode.js +1 -1
- package/src/nodes/accessors/Normal.js +6 -2
- package/src/nodes/accessors/Object3DNode.js +0 -1
- package/src/nodes/accessors/Position.js +6 -6
- package/src/nodes/accessors/ReferenceBaseNode.js +2 -4
- package/src/nodes/accessors/ReferenceNode.js +2 -3
- package/src/nodes/accessors/StorageBufferNode.js +42 -5
- package/src/nodes/accessors/Tangent.js +2 -2
- package/src/nodes/accessors/Texture3DNode.js +1 -1
- package/src/nodes/accessors/TextureNode.js +12 -5
- package/src/nodes/accessors/UniformArrayNode.js +9 -3
- package/src/nodes/accessors/VelocityNode.js +0 -2
- package/src/nodes/code/ScriptableNode.js +3 -3
- package/src/nodes/core/ArrayNode.js +125 -0
- package/src/nodes/core/ConstNode.js +8 -0
- package/src/nodes/core/Node.js +14 -1
- package/src/nodes/core/NodeBuilder.js +229 -19
- package/src/nodes/core/NodeUtils.js +11 -1
- package/src/nodes/core/NodeVar.js +17 -1
- package/src/nodes/core/OutputStructNode.js +19 -9
- package/src/nodes/core/StackNode.js +20 -1
- package/src/nodes/core/StructNode.js +121 -0
- package/src/nodes/core/StructType.js +13 -0
- package/src/nodes/core/StructTypeNode.js +82 -21
- package/src/nodes/core/TempNode.js +1 -1
- package/src/nodes/core/VarNode.js +94 -7
- package/src/nodes/core/VaryingNode.js +19 -3
- package/src/nodes/display/BlendModes.js +88 -1
- package/src/nodes/display/BumpMapNode.js +6 -6
- package/src/nodes/display/NormalMapNode.js +6 -6
- package/src/nodes/display/PassNode.js +3 -1
- package/src/nodes/display/ScreenNode.js +9 -0
- package/src/nodes/fog/Fog.js +17 -0
- package/src/nodes/gpgpu/AtomicFunctionNode.js +20 -4
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +8 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +1 -1
- package/src/nodes/lighting/ShadowNode.js +1 -1
- package/src/nodes/math/ConditionalNode.js +8 -1
- package/src/nodes/math/MathNode.js +14 -1
- package/src/nodes/math/OperatorNode.js +96 -18
- package/src/nodes/pmrem/PMREMUtils.js +1 -1
- package/src/nodes/shapes/Shapes.js +33 -0
- package/src/nodes/tsl/TSLBase.js +1 -0
- package/src/nodes/tsl/TSLCore.js +22 -2
- package/src/nodes/utils/ArrayElementNode.js +1 -1
- package/src/nodes/utils/LoopNode.js +8 -1
- package/src/nodes/utils/MemberNode.js +68 -0
- package/src/nodes/utils/StorageArrayElementNode.js +14 -0
- package/src/nodes/utils/Timer.js +21 -0
- package/src/objects/BatchedMesh.js +1 -1
- package/src/objects/Line.js +6 -6
- package/src/renderers/WebGLRenderer.js +7 -0
- package/src/renderers/common/Animation.js +23 -1
- package/src/renderers/common/Backend.js +58 -15
- package/src/renderers/common/Background.js +14 -0
- package/src/renderers/common/Binding.js +1 -1
- package/src/renderers/common/BufferUtils.js +1 -1
- package/src/renderers/common/BundleGroup.js +1 -1
- package/src/renderers/common/ChainMap.js +9 -7
- package/src/renderers/common/ClippingContext.js +1 -1
- package/src/renderers/common/Color4.js +7 -3
- package/src/renderers/common/Geometries.js +2 -23
- package/src/renderers/common/Info.js +1 -45
- package/src/renderers/common/Lighting.js +8 -6
- package/src/renderers/common/Pipelines.js +3 -3
- package/src/renderers/common/PostProcessing.js +24 -8
- package/src/renderers/common/QuadMesh.js +1 -1
- package/src/renderers/common/RenderBundles.js +9 -3
- package/src/renderers/common/RenderContext.js +37 -3
- package/src/renderers/common/RenderContexts.js +30 -17
- package/src/renderers/common/RenderList.js +2 -2
- package/src/renderers/common/RenderLists.js +9 -3
- package/src/renderers/common/RenderObject.js +76 -17
- package/src/renderers/common/RenderObjects.js +9 -7
- package/src/renderers/common/Renderer.js +86 -67
- package/src/renderers/common/SampledTexture.js +0 -1
- package/src/renderers/common/StorageBufferAttribute.js +1 -1
- package/src/renderers/common/StorageInstancedBufferAttribute.js +1 -1
- package/src/renderers/common/StorageTexture.js +1 -1
- package/src/renderers/common/Textures.js +14 -7
- package/src/renderers/common/TimestampQueryPool.js +39 -0
- package/src/renderers/common/Uniform.js +37 -1
- package/src/renderers/common/UniformsGroup.js +2 -0
- package/src/renderers/common/XRManager.js +1193 -0
- package/src/renderers/common/XRRenderTarget.js +74 -0
- package/src/renderers/common/extras/PMREMGenerator.js +53 -8
- package/src/renderers/common/nodes/NodeBuilderState.js +4 -4
- package/src/renderers/common/nodes/NodeLibrary.js +5 -5
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -1
- package/src/renderers/common/nodes/NodeUniform.js +54 -2
- package/src/renderers/common/nodes/Nodes.js +25 -18
- package/src/renderers/webgl/WebGLBackground.js +4 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +295 -110
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +347 -17
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +57 -0
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +28 -0
- package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +45 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +323 -11
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +167 -21
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +359 -0
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +43 -0
- package/src/renderers/webgpu/WebGPUBackend.js +132 -149
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +6 -4
- package/src/renderers/webgpu/WebGPURenderer.js +5 -4
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +615 -41
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +85 -6
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +85 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +102 -3
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +98 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +257 -9
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +274 -0
- package/src/renderers/webgpu/utils/WebGPUUtils.js +86 -4
- package/src/renderers/webxr/WebXRManager.js +13 -2
- package/src/textures/VideoFrameTexture.js +35 -0
- package/examples/jsm/geometries/InstancedPointsGeometry.js +0 -176
- package/examples/jsm/objects/InstancedPoints.js +0 -19
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +0 -209
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +0 -37
|
@@ -3,7 +3,7 @@ let _color4 = null;
|
|
|
3
3
|
|
|
4
4
|
import Color4 from './Color4.js';
|
|
5
5
|
import { Vector2 } from '../../math/Vector2.js';
|
|
6
|
-
import { createCanvasElement } from '../../utils.js';
|
|
6
|
+
import { createCanvasElement, warnOnce } from '../../utils.js';
|
|
7
7
|
import { REVISION } from '../../constants.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -58,6 +58,16 @@ class Backend {
|
|
|
58
58
|
*/
|
|
59
59
|
this.domElement = null;
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* A reference to the timestamp query pool.
|
|
63
|
+
*
|
|
64
|
+
* @type {{render: TimestampQueryPool?, compute: TimestampQueryPool?}}
|
|
65
|
+
*/
|
|
66
|
+
this.timestampQueryPool = {
|
|
67
|
+
'render': null,
|
|
68
|
+
'compute': null
|
|
69
|
+
};
|
|
70
|
+
|
|
61
71
|
}
|
|
62
72
|
|
|
63
73
|
/**
|
|
@@ -255,7 +265,7 @@ class Backend {
|
|
|
255
265
|
// textures
|
|
256
266
|
|
|
257
267
|
/**
|
|
258
|
-
* Creates a sampler for the given texture.
|
|
268
|
+
* Creates a GPU sampler for the given texture.
|
|
259
269
|
*
|
|
260
270
|
* @abstract
|
|
261
271
|
* @param {Texture} texture - The texture to create the sampler for.
|
|
@@ -263,7 +273,7 @@ class Backend {
|
|
|
263
273
|
createSampler( /*texture*/ ) { }
|
|
264
274
|
|
|
265
275
|
/**
|
|
266
|
-
* Destroys the sampler for the given texture.
|
|
276
|
+
* Destroys the GPU sampler for the given texture.
|
|
267
277
|
*
|
|
268
278
|
* @abstract
|
|
269
279
|
* @param {Texture} texture - The texture to destroy the sampler for.
|
|
@@ -298,7 +308,7 @@ class Backend {
|
|
|
298
308
|
updateTexture( /*texture, options = {}*/ ) { }
|
|
299
309
|
|
|
300
310
|
/**
|
|
301
|
-
* Generates mipmaps for the given texture
|
|
311
|
+
* Generates mipmaps for the given texture.
|
|
302
312
|
*
|
|
303
313
|
* @abstract
|
|
304
314
|
* @param {Texture} texture - The texture.
|
|
@@ -317,15 +327,16 @@ class Backend {
|
|
|
317
327
|
* Returns texture data as a typed array.
|
|
318
328
|
*
|
|
319
329
|
* @abstract
|
|
330
|
+
* @async
|
|
320
331
|
* @param {Texture} texture - The texture to copy.
|
|
321
332
|
* @param {Number} x - The x coordinate of the copy origin.
|
|
322
333
|
* @param {Number} y - The y coordinate of the copy origin.
|
|
323
334
|
* @param {Number} width - The width of the copy.
|
|
324
335
|
* @param {Number} height - The height of the copy.
|
|
325
336
|
* @param {Number} faceIndex - The face index.
|
|
326
|
-
* @return {TypedArray}
|
|
337
|
+
* @return {Promise<TypedArray>} A Promise that resolves with a typed array when the copy operation has finished.
|
|
327
338
|
*/
|
|
328
|
-
copyTextureToBuffer( /*texture, x, y, width, height, faceIndex*/ ) {}
|
|
339
|
+
async copyTextureToBuffer( /*texture, x, y, width, height, faceIndex*/ ) {}
|
|
329
340
|
|
|
330
341
|
/**
|
|
331
342
|
* Copies data of the given source texture to the given destination texture.
|
|
@@ -352,7 +363,7 @@ class Backend {
|
|
|
352
363
|
// attributes
|
|
353
364
|
|
|
354
365
|
/**
|
|
355
|
-
* Creates the buffer of a shader attribute.
|
|
366
|
+
* Creates the GPU buffer of a shader attribute.
|
|
356
367
|
*
|
|
357
368
|
* @abstract
|
|
358
369
|
* @param {BufferAttribute} attribute - The buffer attribute.
|
|
@@ -360,7 +371,7 @@ class Backend {
|
|
|
360
371
|
createAttribute( /*attribute*/ ) { }
|
|
361
372
|
|
|
362
373
|
/**
|
|
363
|
-
* Creates the buffer of an indexed shader attribute.
|
|
374
|
+
* Creates the GPU buffer of an indexed shader attribute.
|
|
364
375
|
*
|
|
365
376
|
* @abstract
|
|
366
377
|
* @param {BufferAttribute} attribute - The indexed buffer attribute.
|
|
@@ -368,7 +379,7 @@ class Backend {
|
|
|
368
379
|
createIndexAttribute( /*attribute*/ ) { }
|
|
369
380
|
|
|
370
381
|
/**
|
|
371
|
-
* Creates the buffer of a storage attribute.
|
|
382
|
+
* Creates the GPU buffer of a storage attribute.
|
|
372
383
|
*
|
|
373
384
|
* @abstract
|
|
374
385
|
* @param {BufferAttribute} attribute - The buffer attribute.
|
|
@@ -376,7 +387,7 @@ class Backend {
|
|
|
376
387
|
createStorageAttribute( /*attribute*/ ) { }
|
|
377
388
|
|
|
378
389
|
/**
|
|
379
|
-
* Updates the buffer of a shader attribute.
|
|
390
|
+
* Updates the GPU buffer of a shader attribute.
|
|
380
391
|
*
|
|
381
392
|
* @abstract
|
|
382
393
|
* @param {BufferAttribute} attribute - The buffer attribute to update.
|
|
@@ -384,7 +395,7 @@ class Backend {
|
|
|
384
395
|
updateAttribute( /*attribute*/ ) { }
|
|
385
396
|
|
|
386
397
|
/**
|
|
387
|
-
* Destroys the buffer of a shader attribute.
|
|
398
|
+
* Destroys the GPU buffer of a shader attribute.
|
|
388
399
|
*
|
|
389
400
|
* @abstract
|
|
390
401
|
* @param {BufferAttribute} attribute - The buffer attribute to destroy.
|
|
@@ -436,11 +447,33 @@ class Backend {
|
|
|
436
447
|
*
|
|
437
448
|
* @async
|
|
438
449
|
* @abstract
|
|
439
|
-
* @param {
|
|
440
|
-
* @
|
|
441
|
-
* @return {Promise} A Promise that resolves when the time stamp has been computed.
|
|
450
|
+
* @param {String} [type='render'] - The type of the time stamp.
|
|
451
|
+
* @return {Promise<Number>} A Promise that resolves with the time stamp.
|
|
442
452
|
*/
|
|
443
|
-
async
|
|
453
|
+
async resolveTimestampsAsync( type = 'render' ) {
|
|
454
|
+
|
|
455
|
+
if ( ! this.trackTimestamp ) {
|
|
456
|
+
|
|
457
|
+
warnOnce( 'WebGPURenderer: Timestamp tracking is disabled.' );
|
|
458
|
+
return;
|
|
459
|
+
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
const queryPool = this.timestampQueryPool[ type ];
|
|
463
|
+
if ( ! queryPool ) {
|
|
464
|
+
|
|
465
|
+
warnOnce( `WebGPURenderer: No timestamp query pool for type '${type}' found.` );
|
|
466
|
+
return;
|
|
467
|
+
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
const duration = await queryPool.resolveQueriesAsync();
|
|
471
|
+
|
|
472
|
+
this.renderer.info[ type ].timestamp = duration;
|
|
473
|
+
|
|
474
|
+
return duration;
|
|
475
|
+
|
|
476
|
+
}
|
|
444
477
|
|
|
445
478
|
/**
|
|
446
479
|
* Can be used to synchronize CPU operations with GPU tasks. So when this method is called,
|
|
@@ -452,6 +485,16 @@ class Backend {
|
|
|
452
485
|
*/
|
|
453
486
|
async waitForGPU() {}
|
|
454
487
|
|
|
488
|
+
/**
|
|
489
|
+
* This method performs a readback operation by moving buffer data from
|
|
490
|
+
* a storage buffer attribute from the GPU to the CPU.
|
|
491
|
+
*
|
|
492
|
+
* @async
|
|
493
|
+
* @param {StorageBufferAttribute} attribute - The storage buffer attribute.
|
|
494
|
+
* @return {Promise<ArrayBuffer>} A promise that resolves with the buffer data when the data are ready.
|
|
495
|
+
*/
|
|
496
|
+
async getArrayBufferAsync( /* attribute */ ) {}
|
|
497
|
+
|
|
455
498
|
/**
|
|
456
499
|
* Checks if the given feature is supported by the backend.
|
|
457
500
|
*
|
|
@@ -142,6 +142,20 @@ class Background extends DataMap {
|
|
|
142
142
|
|
|
143
143
|
//
|
|
144
144
|
|
|
145
|
+
const environmentBlendMode = renderer.xr.getEnvironmentBlendMode();
|
|
146
|
+
|
|
147
|
+
if ( environmentBlendMode === 'additive' ) {
|
|
148
|
+
|
|
149
|
+
_clearColor.set( 0, 0, 0, 1 );
|
|
150
|
+
|
|
151
|
+
} else if ( environmentBlendMode === 'alpha-blend' ) {
|
|
152
|
+
|
|
153
|
+
_clearColor.set( 0, 0, 0, 0 );
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
//
|
|
158
|
+
|
|
145
159
|
if ( renderer.autoClear === true || forceClear === true ) {
|
|
146
160
|
|
|
147
161
|
const clearColorValue = renderContext.clearColorValue;
|
|
@@ -4,7 +4,7 @@ import { GPU_CHUNK_BYTES } from './Constants.js';
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* This function is usually called with the length in bytes of an array buffer.
|
|
7
|
-
* It returns an padded value
|
|
7
|
+
* It returns an padded value which ensure chunk size alignment according to STD140 layout.
|
|
8
8
|
*
|
|
9
9
|
* @function
|
|
10
10
|
* @param {Number} floatLength - The buffer length.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Group } from '../../objects/Group.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* A specialized group which
|
|
4
|
+
* A specialized group which enables applications access to the
|
|
5
5
|
* Render Bundle API of WebGPU. The group with all its descendant nodes
|
|
6
6
|
* are considered as one render bundle and processed as such by
|
|
7
7
|
* the renderer.
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* Data structure for the renderer. It allows defining values
|
|
3
3
|
* with chained, hierarchical keys. Keys are meant to be
|
|
4
4
|
* objects since the module internally works with Weak Maps
|
|
5
|
-
* for
|
|
5
|
+
* for performance reasons.
|
|
6
6
|
*
|
|
7
7
|
* @private
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
class ChainMap {
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Constructs a new
|
|
12
|
+
* Constructs a new Chain Map.
|
|
13
13
|
*/
|
|
14
14
|
constructor() {
|
|
15
15
|
|
|
@@ -32,7 +32,7 @@ export default class ChainMap {
|
|
|
32
32
|
|
|
33
33
|
let map = this.weakMap;
|
|
34
34
|
|
|
35
|
-
for ( let i = 0; i < keys.length; i ++ ) {
|
|
35
|
+
for ( let i = 0; i < keys.length - 1; i ++ ) {
|
|
36
36
|
|
|
37
37
|
map = map.get( keys[ i ] );
|
|
38
38
|
|
|
@@ -49,13 +49,13 @@ export default class ChainMap {
|
|
|
49
49
|
*
|
|
50
50
|
* @param {Array<Object>} keys - List of keys.
|
|
51
51
|
* @param {Any} value - The value to set.
|
|
52
|
-
* @return {ChainMap} A reference to this
|
|
52
|
+
* @return {ChainMap} A reference to this Chain Map.
|
|
53
53
|
*/
|
|
54
54
|
set( keys, value ) {
|
|
55
55
|
|
|
56
56
|
let map = this.weakMap;
|
|
57
57
|
|
|
58
|
-
for ( let i = 0; i < keys.length; i ++ ) {
|
|
58
|
+
for ( let i = 0; i < keys.length - 1; i ++ ) {
|
|
59
59
|
|
|
60
60
|
const key = keys[ i ];
|
|
61
61
|
|
|
@@ -81,7 +81,7 @@ export default class ChainMap {
|
|
|
81
81
|
|
|
82
82
|
let map = this.weakMap;
|
|
83
83
|
|
|
84
|
-
for ( let i = 0; i < keys.length; i ++ ) {
|
|
84
|
+
for ( let i = 0; i < keys.length - 1; i ++ ) {
|
|
85
85
|
|
|
86
86
|
map = map.get( keys[ i ] );
|
|
87
87
|
|
|
@@ -94,3 +94,5 @@ export default class ChainMap {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
}
|
|
97
|
+
|
|
98
|
+
export default ChainMap;
|
|
@@ -136,7 +136,7 @@ class ClippingContext {
|
|
|
136
136
|
*/
|
|
137
137
|
updateGlobal( scene, camera ) {
|
|
138
138
|
|
|
139
|
-
this.shadowPass = ( scene.overrideMaterial !== null && scene.overrideMaterial.
|
|
139
|
+
this.shadowPass = ( scene.overrideMaterial !== null && scene.overrideMaterial.isShadowPassMaterial );
|
|
140
140
|
this.viewMatrix = camera.matrixWorldInverse;
|
|
141
141
|
|
|
142
142
|
this.viewNormalMatrix.getNormalMatrix( this.viewMatrix );
|
|
@@ -12,10 +12,12 @@ class Color4 extends Color {
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Constructs a new four-component color.
|
|
15
|
+
* You can also pass a single THREE.Color, hex or
|
|
16
|
+
* string argument to this constructor.
|
|
15
17
|
*
|
|
16
|
-
* @param {Number|String} r - The red value.
|
|
17
|
-
* @param {Number} g - The green value.
|
|
18
|
-
* @param {Number} b - The blue value.
|
|
18
|
+
* @param {Number|String} [r=1] - The red value.
|
|
19
|
+
* @param {Number} [g=1] - The green value.
|
|
20
|
+
* @param {Number} [b=1] - The blue value.
|
|
19
21
|
* @param {Number} [a=1] - The alpha value.
|
|
20
22
|
*/
|
|
21
23
|
constructor( r, g, b, a = 1 ) {
|
|
@@ -28,6 +30,8 @@ class Color4 extends Color {
|
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
32
|
* Overwrites the default to honor alpha.
|
|
33
|
+
* You can also pass a single THREE.Color, hex or
|
|
34
|
+
* string argument to this method.
|
|
31
35
|
*
|
|
32
36
|
* @param {Number|String} r - The red value.
|
|
33
37
|
* @param {Number} g - The green value.
|
|
@@ -1,37 +1,16 @@
|
|
|
1
1
|
import DataMap from './DataMap.js';
|
|
2
2
|
import { AttributeType } from './Constants.js';
|
|
3
|
+
import { arrayNeedsUint32 } from '../../utils.js';
|
|
3
4
|
|
|
4
5
|
import { Uint16BufferAttribute, Uint32BufferAttribute } from '../../core/BufferAttribute.js';
|
|
5
6
|
|
|
6
|
-
/**
|
|
7
|
-
* Returns `true` if the given array has values that require an Uint32 array type.
|
|
8
|
-
*
|
|
9
|
-
* @private
|
|
10
|
-
* @function
|
|
11
|
-
* @param {Array<Number>} array - The array to test.
|
|
12
|
-
* @return {Booolean} Whether the given array has values that require an Uint32 array type or not.
|
|
13
|
-
*/
|
|
14
|
-
function arrayNeedsUint32( array ) {
|
|
15
|
-
|
|
16
|
-
// assumes larger values usually on last
|
|
17
|
-
|
|
18
|
-
for ( let i = array.length - 1; i >= 0; -- i ) {
|
|
19
|
-
|
|
20
|
-
if ( array[ i ] >= 65535 ) return true; // account for PRIMITIVE_RESTART_FIXED_INDEX, #24565
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return false;
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
7
|
/**
|
|
29
8
|
* Returns the wireframe version for the given geometry.
|
|
30
9
|
*
|
|
31
10
|
* @private
|
|
32
11
|
* @function
|
|
33
12
|
* @param {BufferGeometry} geometry - The geometry.
|
|
34
|
-
* @return {Number} The
|
|
13
|
+
* @return {Number} The version.
|
|
35
14
|
*/
|
|
36
15
|
function getWireframeVersion( geometry ) {
|
|
37
16
|
|
|
@@ -52,9 +52,7 @@ class Info {
|
|
|
52
52
|
* @property {Number} triangles - The number of rendered triangle primitives of the current frame.
|
|
53
53
|
* @property {Number} points - The number of rendered point primitives of the current frame.
|
|
54
54
|
* @property {Number} lines - The number of rendered line primitives of the current frame.
|
|
55
|
-
* @property {Number} previousFrameCalls - The number of render calls of the previous frame.
|
|
56
55
|
* @property {Number} timestamp - The timestamp of the frame when using `renderer.renderAsync()`.
|
|
57
|
-
* @property {Number} timestampCalls - The number of render calls using `renderer.renderAsync()`.
|
|
58
56
|
*/
|
|
59
57
|
this.render = {
|
|
60
58
|
calls: 0,
|
|
@@ -64,8 +62,6 @@ class Info {
|
|
|
64
62
|
points: 0,
|
|
65
63
|
lines: 0,
|
|
66
64
|
timestamp: 0,
|
|
67
|
-
previousFrameCalls: 0,
|
|
68
|
-
timestampCalls: 0
|
|
69
65
|
};
|
|
70
66
|
|
|
71
67
|
/**
|
|
@@ -75,16 +71,12 @@ class Info {
|
|
|
75
71
|
* @readonly
|
|
76
72
|
* @property {Number} calls - The number of compute calls since the app has been started.
|
|
77
73
|
* @property {Number} frameCalls - The number of compute calls of the current frame.
|
|
78
|
-
* @property {Number} previousFrameCalls - The number of compute calls of the previous frame.
|
|
79
74
|
* @property {Number} timestamp - The timestamp of the frame when using `renderer.computeAsync()`.
|
|
80
|
-
* @property {Number} timestampCalls - The number of render calls using `renderer.computeAsync()`.
|
|
81
75
|
*/
|
|
82
76
|
this.compute = {
|
|
83
77
|
calls: 0,
|
|
84
78
|
frameCalls: 0,
|
|
85
|
-
timestamp: 0
|
|
86
|
-
previousFrameCalls: 0,
|
|
87
|
-
timestampCalls: 0
|
|
79
|
+
timestamp: 0
|
|
88
80
|
};
|
|
89
81
|
|
|
90
82
|
/**
|
|
@@ -137,47 +129,11 @@ class Info {
|
|
|
137
129
|
|
|
138
130
|
}
|
|
139
131
|
|
|
140
|
-
/**
|
|
141
|
-
* Used by async render methods to updated timestamp metrics.
|
|
142
|
-
*
|
|
143
|
-
* @param {('render'|'compute')} type - The type of render call.
|
|
144
|
-
* @param {Number} time - The duration of the compute/render call in milliseconds.
|
|
145
|
-
*/
|
|
146
|
-
updateTimestamp( type, time ) {
|
|
147
|
-
|
|
148
|
-
if ( this[ type ].timestampCalls === 0 ) {
|
|
149
|
-
|
|
150
|
-
this[ type ].timestamp = 0;
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
this[ type ].timestamp += time;
|
|
156
|
-
|
|
157
|
-
this[ type ].timestampCalls ++;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
if ( this[ type ].timestampCalls >= this[ type ].previousFrameCalls ) {
|
|
161
|
-
|
|
162
|
-
this[ type ].timestampCalls = 0;
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
169
132
|
/**
|
|
170
133
|
* Resets frame related metrics.
|
|
171
134
|
*/
|
|
172
135
|
reset() {
|
|
173
136
|
|
|
174
|
-
const previousRenderFrameCalls = this.render.frameCalls;
|
|
175
|
-
this.render.previousFrameCalls = previousRenderFrameCalls;
|
|
176
|
-
|
|
177
|
-
const previousComputeFrameCalls = this.compute.frameCalls;
|
|
178
|
-
this.compute.previousFrameCalls = previousComputeFrameCalls;
|
|
179
|
-
|
|
180
|
-
|
|
181
137
|
this.render.drawCalls = 0;
|
|
182
138
|
this.render.frameCalls = 0;
|
|
183
139
|
this.compute.frameCalls = 0;
|
|
@@ -2,6 +2,7 @@ import { LightsNode } from '../../nodes/Nodes.js';
|
|
|
2
2
|
import ChainMap from './ChainMap.js';
|
|
3
3
|
|
|
4
4
|
const _defaultLights = /*@__PURE__*/ new LightsNode();
|
|
5
|
+
const _chainKeys = [];
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* This renderer module manages the lights nodes which are unique
|
|
@@ -28,7 +29,7 @@ class Lighting extends ChainMap {
|
|
|
28
29
|
* Creates a new lights node for the given array of lights.
|
|
29
30
|
*
|
|
30
31
|
* @param {Array<Light>} lights - The render object.
|
|
31
|
-
* @return {
|
|
32
|
+
* @return {LightsNode} The lights node.
|
|
32
33
|
*/
|
|
33
34
|
createNode( lights = [] ) {
|
|
34
35
|
|
|
@@ -49,19 +50,20 @@ class Lighting extends ChainMap {
|
|
|
49
50
|
|
|
50
51
|
if ( scene.isQuadMesh ) return _defaultLights;
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const keys = [ scene, camera ];
|
|
53
|
+
_chainKeys[ 0 ] = scene;
|
|
54
|
+
_chainKeys[ 1 ] = camera;
|
|
55
55
|
|
|
56
|
-
let node = this.get(
|
|
56
|
+
let node = this.get( _chainKeys );
|
|
57
57
|
|
|
58
58
|
if ( node === undefined ) {
|
|
59
59
|
|
|
60
60
|
node = this.createNode();
|
|
61
|
-
this.set(
|
|
61
|
+
this.set( _chainKeys, node );
|
|
62
62
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
_chainKeys.length = 0;
|
|
66
|
+
|
|
65
67
|
return node;
|
|
66
68
|
|
|
67
69
|
}
|
|
@@ -55,7 +55,7 @@ class Pipelines extends DataMap {
|
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* This dictionary maintains for each shader stage type (vertex,
|
|
58
|
-
* fragment and compute) the
|
|
58
|
+
* fragment and compute) the programmable stage objects which
|
|
59
59
|
* represent the actual shader code.
|
|
60
60
|
*
|
|
61
61
|
* @type {Object<String,Map>}
|
|
@@ -343,7 +343,7 @@ class Pipelines extends DataMap {
|
|
|
343
343
|
* @param {ProgrammableStage} stageVertex - The programmable stage representing the vertex shader.
|
|
344
344
|
* @param {ProgrammableStage} stageFragment - The programmable stage representing the fragment shader.
|
|
345
345
|
* @param {String} cacheKey - The cache key.
|
|
346
|
-
* @param {Array} promises - An array of compilation promises which is only relevant in context of `Renderer.compileAsync()`.
|
|
346
|
+
* @param {Array<Promise>?} promises - An array of compilation promises which is only relevant in context of `Renderer.compileAsync()`.
|
|
347
347
|
* @return {ComputePipeline} The compute pipeline.
|
|
348
348
|
*/
|
|
349
349
|
_getRenderPipeline( renderObject, stageVertex, stageFragment, cacheKey, promises ) {
|
|
@@ -419,7 +419,7 @@ class Pipelines extends DataMap {
|
|
|
419
419
|
* Releases the shader program.
|
|
420
420
|
*
|
|
421
421
|
* @private
|
|
422
|
-
* @param {Object} program - The
|
|
422
|
+
* @param {Object} program - The shader program to release.
|
|
423
423
|
*/
|
|
424
424
|
_releaseProgram( program ) {
|
|
425
425
|
|
|
@@ -3,9 +3,6 @@ import { vec4, renderOutput } from '../../nodes/TSL.js';
|
|
|
3
3
|
import { LinearSRGBColorSpace, NoToneMapping } from '../../constants.js';
|
|
4
4
|
import QuadMesh from '../../renderers/common/QuadMesh.js';
|
|
5
5
|
|
|
6
|
-
const _material = /*@__PURE__*/ new NodeMaterial();
|
|
7
|
-
const _quadMesh = /*@__PURE__*/ new QuadMesh( _material );
|
|
8
|
-
|
|
9
6
|
/**
|
|
10
7
|
* This module is responsible to manage the post processing setups in apps.
|
|
11
8
|
* You usually create a single instance of this class and use it to define
|
|
@@ -71,7 +68,17 @@ class PostProcessing {
|
|
|
71
68
|
*/
|
|
72
69
|
this.needsUpdate = true;
|
|
73
70
|
|
|
74
|
-
|
|
71
|
+
const material = new NodeMaterial();
|
|
72
|
+
material.name = 'PostProcessing';
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The full screen quad that is used to render
|
|
76
|
+
* the effects.
|
|
77
|
+
*
|
|
78
|
+
* @private
|
|
79
|
+
* @type {QuadMesh}
|
|
80
|
+
*/
|
|
81
|
+
this._quadMesh = new QuadMesh( material );
|
|
75
82
|
|
|
76
83
|
}
|
|
77
84
|
|
|
@@ -94,7 +101,7 @@ class PostProcessing {
|
|
|
94
101
|
|
|
95
102
|
//
|
|
96
103
|
|
|
97
|
-
_quadMesh.render( renderer );
|
|
104
|
+
this._quadMesh.render( renderer );
|
|
98
105
|
|
|
99
106
|
//
|
|
100
107
|
|
|
@@ -103,6 +110,15 @@ class PostProcessing {
|
|
|
103
110
|
|
|
104
111
|
}
|
|
105
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Frees internal resources.
|
|
115
|
+
*/
|
|
116
|
+
dispose() {
|
|
117
|
+
|
|
118
|
+
this._quadMesh.material.dispose();
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
106
122
|
/**
|
|
107
123
|
* Updates the state of the module.
|
|
108
124
|
*
|
|
@@ -117,8 +133,8 @@ class PostProcessing {
|
|
|
117
133
|
const toneMapping = renderer.toneMapping;
|
|
118
134
|
const outputColorSpace = renderer.outputColorSpace;
|
|
119
135
|
|
|
120
|
-
_quadMesh.material.fragmentNode = this.outputColorTransform === true ? renderOutput( this.outputNode, toneMapping, outputColorSpace ) : this.outputNode.context( { toneMapping, outputColorSpace } );
|
|
121
|
-
_quadMesh.material.needsUpdate = true;
|
|
136
|
+
this._quadMesh.material.fragmentNode = this.outputColorTransform === true ? renderOutput( this.outputNode, toneMapping, outputColorSpace ) : this.outputNode.context( { toneMapping, outputColorSpace } );
|
|
137
|
+
this._quadMesh.material.needsUpdate = true;
|
|
122
138
|
|
|
123
139
|
this.needsUpdate = false;
|
|
124
140
|
|
|
@@ -148,7 +164,7 @@ class PostProcessing {
|
|
|
148
164
|
|
|
149
165
|
//
|
|
150
166
|
|
|
151
|
-
await _quadMesh.renderAsync( renderer );
|
|
167
|
+
await this._quadMesh.renderAsync( renderer );
|
|
152
168
|
|
|
153
169
|
//
|
|
154
170
|
|
|
@@ -43,7 +43,7 @@ const _geometry = /*@__PURE__*/ new QuadGeometry();
|
|
|
43
43
|
* The intended usage is to reuse a single quad mesh for rendering
|
|
44
44
|
* subsequent passes by just reassigning the `material` reference.
|
|
45
45
|
*
|
|
46
|
-
* @augments
|
|
46
|
+
* @augments Mesh
|
|
47
47
|
*/
|
|
48
48
|
class QuadMesh extends Mesh {
|
|
49
49
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import ChainMap from './ChainMap.js';
|
|
2
2
|
import RenderBundle from './RenderBundle.js';
|
|
3
3
|
|
|
4
|
+
const _chainKeys = [];
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* This renderer module manages render bundles.
|
|
6
8
|
*
|
|
@@ -32,17 +34,21 @@ class RenderBundles {
|
|
|
32
34
|
get( bundleGroup, camera ) {
|
|
33
35
|
|
|
34
36
|
const bundles = this.bundles;
|
|
35
|
-
const keys = [ bundleGroup, camera ];
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
_chainKeys[ 0 ] = bundleGroup;
|
|
39
|
+
_chainKeys[ 1 ] = camera;
|
|
40
|
+
|
|
41
|
+
let bundle = bundles.get( _chainKeys );
|
|
38
42
|
|
|
39
43
|
if ( bundle === undefined ) {
|
|
40
44
|
|
|
41
45
|
bundle = new RenderBundle( bundleGroup, camera );
|
|
42
|
-
bundles.set(
|
|
46
|
+
bundles.set( _chainKeys, bundle );
|
|
43
47
|
|
|
44
48
|
}
|
|
45
49
|
|
|
50
|
+
_chainKeys.length = 0;
|
|
51
|
+
|
|
46
52
|
return bundle;
|
|
47
53
|
|
|
48
54
|
}
|