@plastic-software/three 0.178.0 → 0.180.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/three.cjs +950 -230
- package/build/three.core.js +754 -138
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +197 -96
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +99 -25
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +4586 -1499
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +4544 -1499
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +2 -3
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +7 -7
- package/examples/jsm/controls/DragControls.js +6 -56
- package/examples/jsm/controls/FirstPersonControls.js +2 -2
- package/examples/jsm/controls/PointerLockControls.js +0 -8
- package/examples/jsm/csm/CSMShadowNode.js +4 -4
- package/examples/jsm/environments/RoomEnvironment.js +8 -3
- package/examples/jsm/exporters/GLTFExporter.js +30 -22
- package/examples/jsm/exporters/KTX2Exporter.js +4 -2
- package/examples/jsm/exporters/PLYExporter.js +1 -1
- package/examples/jsm/exporters/USDZExporter.js +676 -299
- package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
- package/examples/jsm/interactive/HTMLMesh.js +5 -3
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
- package/examples/jsm/lights/LightProbeGenerator.js +14 -3
- package/examples/jsm/lines/Line2.js +3 -3
- package/examples/jsm/lines/LineGeometry.js +1 -1
- package/examples/jsm/lines/LineSegments2.js +2 -2
- package/examples/jsm/lines/Wireframe.js +2 -2
- package/examples/jsm/lines/WireframeGeometry2.js +1 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +1 -1
- package/examples/jsm/lines/webgpu/Wireframe.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +210 -22
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +9 -5
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +5 -5
- package/examples/jsm/loaders/HDRLoader.js +486 -0
- package/examples/jsm/loaders/KTX2Loader.js +112 -32
- package/examples/jsm/loaders/MaterialXLoader.js +212 -30
- package/examples/jsm/loaders/RGBELoader.js +7 -473
- package/examples/jsm/loaders/TTFLoader.js +13 -1
- package/examples/jsm/loaders/USDLoader.js +219 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -892
- package/examples/jsm/loaders/UltraHDRLoader.js +1 -1
- package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
- package/examples/jsm/loaders/usd/USDAParser.js +741 -0
- package/examples/jsm/loaders/usd/USDCParser.js +17 -0
- package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
- package/examples/jsm/math/ColorSpaces.js +19 -1
- package/examples/jsm/math/ConvexHull.js +2 -2
- package/examples/jsm/math/Lut.js +2 -2
- package/examples/jsm/misc/MD2CharacterComplex.js +1 -1
- package/examples/jsm/misc/ProgressiveLightMap.js +1 -1
- package/examples/jsm/misc/Volume.js +1 -1
- package/examples/jsm/objects/LensflareMesh.js +3 -3
- package/examples/jsm/objects/SkyMesh.js +2 -2
- package/examples/jsm/physics/RapierPhysics.js +14 -5
- package/examples/jsm/postprocessing/GTAOPass.js +10 -9
- package/examples/jsm/postprocessing/OutlinePass.js +17 -17
- package/examples/jsm/postprocessing/SSAOPass.js +10 -9
- package/examples/jsm/postprocessing/SSRPass.js +37 -8
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +23 -20
- package/examples/jsm/transpiler/TSLEncoder.js +2 -10
- package/examples/jsm/transpiler/WGSLEncoder.js +24 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +27 -4
- package/examples/jsm/tsl/display/BloomNode.js +7 -6
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +2 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +439 -90
- package/examples/jsm/tsl/display/GTAONode.js +8 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +51 -41
- package/examples/jsm/tsl/display/OutlineNode.js +2 -2
- package/examples/jsm/tsl/display/SSRNode.js +180 -65
- package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
- package/examples/jsm/tsl/display/boxBlur.js +64 -0
- package/examples/jsm/tsl/display/hashBlur.js +15 -18
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
- package/examples/jsm/utils/ShadowMapViewerGPU.js +12 -5
- package/examples/jsm/webxr/OculusHandModel.js +1 -1
- package/package.json +1 -1
- package/src/Three.Core.js +2 -0
- package/src/Three.TSL.js +98 -24
- package/src/animation/AnimationClip.js +17 -2
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/cameras/Camera.js +14 -0
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/constants.js +11 -3
- package/src/core/BufferGeometry.js +2 -2
- package/{examples/jsm/misc → src/core}/Timer.js +4 -42
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/extras/TextureUtils.js +2 -1
- package/src/extras/lib/earcut.js +1 -1
- package/src/helpers/CameraHelper.js +41 -11
- package/src/helpers/SkeletonHelper.js +35 -6
- package/src/lights/LightShadow.js +21 -8
- package/src/lights/PointLightShadow.js +1 -1
- package/src/lights/webgpu/ProjectorLight.js +1 -1
- package/src/loaders/FileLoader.js +25 -2
- package/src/loaders/ImageBitmapLoader.js +23 -0
- package/src/loaders/Loader.js +14 -0
- package/src/loaders/LoadingManager.js +23 -0
- package/src/materials/Material.js +12 -0
- package/src/materials/MeshBasicMaterial.js +1 -1
- package/src/materials/MeshDistanceMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +0 -8
- package/src/materials/nodes/NodeMaterial.js +1 -1
- package/src/materials/nodes/PointsNodeMaterial.js +86 -28
- package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
- package/src/math/ColorManagement.js +7 -1
- package/src/math/Frustum.js +19 -8
- package/src/math/FrustumArray.js +10 -5
- package/src/math/Line3.js +129 -2
- package/src/math/Matrix4.js +48 -27
- package/src/math/Spherical.js +2 -2
- package/src/nodes/Nodes.js +4 -0
- package/src/nodes/TSL.js +4 -0
- package/src/nodes/accessors/BufferNode.js +1 -1
- package/src/nodes/accessors/Camera.js +142 -16
- package/src/nodes/accessors/ClippingNode.js +6 -5
- package/src/nodes/accessors/CubeTextureNode.js +2 -2
- package/src/nodes/accessors/InstanceNode.js +3 -1
- package/src/nodes/accessors/Normal.js +11 -11
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
- package/src/nodes/accessors/ReferenceNode.js +19 -4
- package/src/nodes/accessors/SceneNode.js +1 -1
- package/src/nodes/accessors/StorageTextureNode.js +1 -1
- package/src/nodes/accessors/Texture3DNode.js +13 -0
- package/src/nodes/accessors/TextureNode.js +83 -19
- package/src/nodes/code/FunctionCallNode.js +19 -0
- package/src/nodes/code/FunctionNode.js +23 -0
- package/src/nodes/core/ArrayNode.js +12 -0
- package/src/nodes/core/AssignNode.js +6 -2
- package/src/nodes/core/ContextNode.js +44 -1
- package/src/nodes/core/Node.js +30 -22
- package/src/nodes/core/NodeBuilder.js +71 -32
- package/src/nodes/core/NodeFrame.js +1 -1
- package/src/nodes/core/NodeUniform.js +1 -1
- package/src/nodes/core/NodeUtils.js +5 -3
- package/src/nodes/core/StackNode.js +71 -4
- package/src/nodes/core/StructNode.js +5 -5
- package/src/nodes/core/StructTypeNode.js +1 -0
- package/src/nodes/core/SubBuildNode.js +2 -2
- package/src/nodes/core/UniformNode.js +79 -14
- package/src/nodes/core/VarNode.js +83 -15
- package/src/nodes/display/FrontFacingNode.js +4 -8
- package/src/nodes/display/PassNode.js +148 -2
- package/src/nodes/display/ScreenNode.js +42 -13
- package/src/nodes/display/ViewportDepthTextureNode.js +16 -4
- package/src/nodes/display/ViewportSharedTextureNode.js +12 -0
- package/src/nodes/display/ViewportTextureNode.js +94 -4
- package/src/nodes/functions/PhysicalLightingModel.js +2 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +67 -23
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +430 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
- package/src/nodes/lighting/LightsNode.js +1 -1
- package/src/nodes/lighting/ProjectorLightNode.js +19 -6
- package/src/nodes/lighting/ShadowFilterNode.js +1 -1
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +165 -1
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/ConditionalNode.js +19 -3
- package/src/nodes/math/MathNode.js +72 -60
- package/src/nodes/math/OperatorNode.js +26 -25
- package/src/nodes/tsl/TSLCore.js +477 -142
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EventNode.js +83 -0
- package/src/nodes/utils/JoinNode.js +3 -1
- package/src/nodes/utils/MemberNode.js +58 -7
- package/src/nodes/utils/RTTNode.js +10 -1
- package/src/nodes/utils/ReflectorNode.js +51 -7
- package/src/nodes/utils/SampleNode.js +12 -2
- package/src/nodes/utils/SplitNode.js +11 -0
- package/src/nodes/utils/Timer.js +0 -47
- package/src/objects/BatchedMesh.js +6 -4
- package/src/objects/LOD.js +1 -1
- package/src/objects/Sprite.js +2 -2
- package/src/renderers/WebGLRenderer.js +21 -31
- package/src/renderers/common/Attributes.js +1 -1
- package/src/renderers/common/Backend.js +19 -1
- package/src/renderers/common/Bindings.js +21 -18
- package/src/renderers/common/ChainMap.js +1 -1
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/DataMap.js +1 -1
- package/src/renderers/common/Pipelines.js +1 -1
- package/src/renderers/common/PostProcessing.js +60 -5
- package/src/renderers/common/RenderContext.js +2 -2
- package/src/renderers/common/RenderObject.js +14 -2
- package/src/renderers/common/Renderer.js +55 -32
- package/src/renderers/common/SampledTexture.js +4 -72
- package/src/renderers/common/Sampler.js +91 -0
- package/src/renderers/common/Storage3DTexture.js +21 -0
- package/src/renderers/common/StorageArrayTexture.js +21 -0
- package/src/renderers/common/StorageTexture.js +19 -0
- package/src/renderers/common/Textures.js +52 -14
- package/src/renderers/common/TimestampQueryPool.js +3 -3
- package/src/renderers/common/XRManager.js +51 -17
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +5 -5
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +21 -11
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLMaterials.js +6 -6
- package/src/renderers/webgl/WebGLProgram.js +24 -18
- package/src/renderers/webgl/WebGLPrograms.js +4 -4
- package/src/renderers/webgl/WebGLShadowMap.js +11 -1
- package/src/renderers/webgl/WebGLTextures.js +20 -7
- package/src/renderers/webgl/WebGLUtils.js +3 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +207 -146
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +112 -19
- package/src/renderers/webgl-fallback/utils/WebGLState.js +1 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +52 -3
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -10
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +3 -2
- package/src/renderers/webgpu/WebGPUBackend.js +87 -44
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +169 -99
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +35 -31
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -2
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +10 -19
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +120 -84
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +3 -3
- package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +86 -11
- package/src/textures/ExternalTexture.js +56 -0
- package/src/textures/FramebufferTexture.js +2 -2
- package/src/textures/Source.js +12 -2
- package/src/textures/VideoTexture.js +27 -2
- package/examples/jsm/loaders/RGBMLoader.js +0 -1148
|
@@ -38,7 +38,7 @@ class Backend {
|
|
|
38
38
|
* This weak map holds backend-specific data of objects
|
|
39
39
|
* like textures, attributes or render targets.
|
|
40
40
|
*
|
|
41
|
-
* @type {WeakMap}
|
|
41
|
+
* @type {WeakMap<Object, Object>}
|
|
42
42
|
*/
|
|
43
43
|
this.data = new WeakMap();
|
|
44
44
|
|
|
@@ -439,6 +439,24 @@ class Backend {
|
|
|
439
439
|
|
|
440
440
|
// utils
|
|
441
441
|
|
|
442
|
+
/**
|
|
443
|
+
* Returns a unique identifier for the given render context that can be used
|
|
444
|
+
* to allocate resources like occlusion queries or timestamp queries.
|
|
445
|
+
*
|
|
446
|
+
* @param {RenderContext|ComputeNode} abstractRenderContext - The render context.
|
|
447
|
+
* @return {string} The unique identifier.
|
|
448
|
+
*/
|
|
449
|
+
getTimestampUID( abstractRenderContext ) {
|
|
450
|
+
|
|
451
|
+
const contextData = this.get( abstractRenderContext );
|
|
452
|
+
|
|
453
|
+
let uid = abstractRenderContext.isComputeNode === true ? 'c' : 'r';
|
|
454
|
+
uid += ':' + contextData.frameCalls + ':' + abstractRenderContext.id;
|
|
455
|
+
|
|
456
|
+
return uid;
|
|
457
|
+
|
|
458
|
+
}
|
|
459
|
+
|
|
442
460
|
/**
|
|
443
461
|
* Returns `true` if the given 3D object is fully occluded by other
|
|
444
462
|
* 3D objects in the scene. Backends must implement this method by using
|
|
@@ -244,24 +244,33 @@ class Bindings extends DataMap {
|
|
|
244
244
|
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
} else if ( binding.isSampler ) {
|
|
248
|
-
|
|
249
|
-
binding.update();
|
|
250
|
-
|
|
251
247
|
} else if ( binding.isSampledTexture ) {
|
|
252
248
|
|
|
253
|
-
const texturesTextureData = this.textures.get( binding.texture );
|
|
254
|
-
|
|
255
|
-
if ( binding.needsBindingsUpdate( texturesTextureData.generation ) ) needsBindingsUpdate = true;
|
|
256
|
-
|
|
257
249
|
const updated = binding.update();
|
|
258
250
|
|
|
251
|
+
// get the texture data after the update, to sync the texture reference from node
|
|
252
|
+
|
|
259
253
|
const texture = binding.texture;
|
|
254
|
+
const texturesTextureData = this.textures.get( texture );
|
|
260
255
|
|
|
261
256
|
if ( updated ) {
|
|
262
257
|
|
|
258
|
+
// version: update the texture data or create a new one
|
|
259
|
+
|
|
263
260
|
this.textures.updateTexture( texture );
|
|
264
261
|
|
|
262
|
+
// generation: update the bindings if a new texture has been created
|
|
263
|
+
|
|
264
|
+
if ( binding.generation !== texturesTextureData.generation ) {
|
|
265
|
+
|
|
266
|
+
binding.generation = texturesTextureData.generation;
|
|
267
|
+
|
|
268
|
+
needsBindingsUpdate = true;
|
|
269
|
+
|
|
270
|
+
cacheBindings = false;
|
|
271
|
+
|
|
272
|
+
}
|
|
273
|
+
|
|
265
274
|
}
|
|
266
275
|
|
|
267
276
|
const textureData = backend.get( texture );
|
|
@@ -277,16 +286,6 @@ class Bindings extends DataMap {
|
|
|
277
286
|
|
|
278
287
|
}
|
|
279
288
|
|
|
280
|
-
if ( backend.isWebGPUBackend === true && textureData.texture === undefined && textureData.externalTexture === undefined ) {
|
|
281
|
-
|
|
282
|
-
// TODO: Remove this once we found why updated === false isn't bound to a texture in the WebGPU backend
|
|
283
|
-
console.error( 'Bindings._update: binding should be available:', binding, updated, texture, binding.textureNode.value, needsBindingsUpdate );
|
|
284
|
-
|
|
285
|
-
this.textures.updateTexture( texture );
|
|
286
|
-
needsBindingsUpdate = true;
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
|
|
290
289
|
if ( texture.isStorageTexture === true ) {
|
|
291
290
|
|
|
292
291
|
const textureData = this.get( texture );
|
|
@@ -305,6 +304,10 @@ class Bindings extends DataMap {
|
|
|
305
304
|
|
|
306
305
|
}
|
|
307
306
|
|
|
307
|
+
} else if ( binding.isSampler ) {
|
|
308
|
+
|
|
309
|
+
binding.update();
|
|
310
|
+
|
|
308
311
|
}
|
|
309
312
|
|
|
310
313
|
}
|
|
@@ -34,8 +34,8 @@ class Color4 extends Color {
|
|
|
34
34
|
* string argument to this method.
|
|
35
35
|
*
|
|
36
36
|
* @param {number|string|Color} r - The red value.
|
|
37
|
-
* @param {number} g - The green value.
|
|
38
|
-
* @param {number} b - The blue value.
|
|
37
|
+
* @param {number} [g] - The green value.
|
|
38
|
+
* @param {number} [b] - The blue value.
|
|
39
39
|
* @param {number} [a=1] - The alpha value.
|
|
40
40
|
* @return {Color4} A reference to this object.
|
|
41
41
|
*/
|
|
@@ -58,7 +58,7 @@ class Pipelines extends DataMap {
|
|
|
58
58
|
* fragment and compute) the programmable stage objects which
|
|
59
59
|
* represent the actual shader code.
|
|
60
60
|
*
|
|
61
|
-
* @type {Object<string,Map
|
|
61
|
+
* @type {Object<string,Map<string, ProgrammableStage>>}
|
|
62
62
|
*/
|
|
63
63
|
this.programs = {
|
|
64
64
|
vertex: new Map(),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
2
|
+
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
2
3
|
import { vec4, renderOutput } from '../../nodes/TSL.js';
|
|
3
|
-
import {
|
|
4
|
+
import { NoToneMapping } from '../../constants.js';
|
|
4
5
|
import QuadMesh from '../../renderers/common/QuadMesh.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -82,6 +83,15 @@ class PostProcessing {
|
|
|
82
83
|
*/
|
|
83
84
|
this._quadMesh = new QuadMesh( material );
|
|
84
85
|
|
|
86
|
+
/**
|
|
87
|
+
* The context of the post processing stack.
|
|
88
|
+
*
|
|
89
|
+
* @private
|
|
90
|
+
* @type {?Object}
|
|
91
|
+
* @default null
|
|
92
|
+
*/
|
|
93
|
+
this._context = null;
|
|
94
|
+
|
|
85
95
|
}
|
|
86
96
|
|
|
87
97
|
/**
|
|
@@ -91,15 +101,17 @@ class PostProcessing {
|
|
|
91
101
|
*/
|
|
92
102
|
render() {
|
|
93
103
|
|
|
104
|
+
const renderer = this.renderer;
|
|
105
|
+
|
|
94
106
|
this._update();
|
|
95
107
|
|
|
96
|
-
|
|
108
|
+
if ( this._context.onBeforePostProcessing !== null ) this._context.onBeforePostProcessing();
|
|
97
109
|
|
|
98
110
|
const toneMapping = renderer.toneMapping;
|
|
99
111
|
const outputColorSpace = renderer.outputColorSpace;
|
|
100
112
|
|
|
101
113
|
renderer.toneMapping = NoToneMapping;
|
|
102
|
-
renderer.outputColorSpace =
|
|
114
|
+
renderer.outputColorSpace = ColorManagement.workingColorSpace;
|
|
103
115
|
|
|
104
116
|
//
|
|
105
117
|
|
|
@@ -115,6 +127,20 @@ class PostProcessing {
|
|
|
115
127
|
renderer.toneMapping = toneMapping;
|
|
116
128
|
renderer.outputColorSpace = outputColorSpace;
|
|
117
129
|
|
|
130
|
+
if ( this._context.onAfterPostProcessing !== null ) this._context.onAfterPostProcessing();
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Returns the current context of the post processing stack.
|
|
136
|
+
*
|
|
137
|
+
* @readonly
|
|
138
|
+
* @type {?Object}
|
|
139
|
+
*/
|
|
140
|
+
get context() {
|
|
141
|
+
|
|
142
|
+
return this._context;
|
|
143
|
+
|
|
118
144
|
}
|
|
119
145
|
|
|
120
146
|
/**
|
|
@@ -140,7 +166,32 @@ class PostProcessing {
|
|
|
140
166
|
const toneMapping = renderer.toneMapping;
|
|
141
167
|
const outputColorSpace = renderer.outputColorSpace;
|
|
142
168
|
|
|
143
|
-
|
|
169
|
+
const context = {
|
|
170
|
+
postProcessing: this,
|
|
171
|
+
onBeforePostProcessing: null,
|
|
172
|
+
onAfterPostProcessing: null
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
let outputNode = this.outputNode;
|
|
176
|
+
|
|
177
|
+
if ( this.outputColorTransform === true ) {
|
|
178
|
+
|
|
179
|
+
outputNode = outputNode.context( context );
|
|
180
|
+
|
|
181
|
+
outputNode = renderOutput( outputNode, toneMapping, outputColorSpace );
|
|
182
|
+
|
|
183
|
+
} else {
|
|
184
|
+
|
|
185
|
+
context.toneMapping = toneMapping;
|
|
186
|
+
context.outputColorSpace = outputColorSpace;
|
|
187
|
+
|
|
188
|
+
outputNode = outputNode.context( context );
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
this._context = context;
|
|
193
|
+
|
|
194
|
+
this._quadMesh.material.fragmentNode = outputNode;
|
|
144
195
|
this._quadMesh.material.needsUpdate = true;
|
|
145
196
|
|
|
146
197
|
this.needsUpdate = false;
|
|
@@ -161,13 +212,15 @@ class PostProcessing {
|
|
|
161
212
|
|
|
162
213
|
this._update();
|
|
163
214
|
|
|
215
|
+
if ( this._context.onBeforePostProcessing !== null ) this._context.onBeforePostProcessing();
|
|
216
|
+
|
|
164
217
|
const renderer = this.renderer;
|
|
165
218
|
|
|
166
219
|
const toneMapping = renderer.toneMapping;
|
|
167
220
|
const outputColorSpace = renderer.outputColorSpace;
|
|
168
221
|
|
|
169
222
|
renderer.toneMapping = NoToneMapping;
|
|
170
|
-
renderer.outputColorSpace =
|
|
223
|
+
renderer.outputColorSpace = ColorManagement.workingColorSpace;
|
|
171
224
|
|
|
172
225
|
//
|
|
173
226
|
|
|
@@ -183,6 +236,8 @@ class PostProcessing {
|
|
|
183
236
|
renderer.toneMapping = toneMapping;
|
|
184
237
|
renderer.outputColorSpace = outputColorSpace;
|
|
185
238
|
|
|
239
|
+
if ( this._context.onAfterPostProcessing !== null ) this._context.onAfterPostProcessing();
|
|
240
|
+
|
|
186
241
|
}
|
|
187
242
|
|
|
188
243
|
}
|
|
@@ -248,9 +248,9 @@ class RenderContext {
|
|
|
248
248
|
*/
|
|
249
249
|
export function getCacheKey( renderContext ) {
|
|
250
250
|
|
|
251
|
-
const { textures, activeCubeFace } = renderContext;
|
|
251
|
+
const { textures, activeCubeFace, activeMipmapLevel } = renderContext;
|
|
252
252
|
|
|
253
|
-
const values = [ activeCubeFace ];
|
|
253
|
+
const values = [ activeCubeFace, activeMipmapLevel ];
|
|
254
254
|
|
|
255
255
|
for ( const texture of textures ) {
|
|
256
256
|
|
|
@@ -682,7 +682,7 @@ class RenderObject {
|
|
|
682
682
|
*/
|
|
683
683
|
getMaterialCacheKey() {
|
|
684
684
|
|
|
685
|
-
const { object, material } = this;
|
|
685
|
+
const { object, material, renderer } = this;
|
|
686
686
|
|
|
687
687
|
let cacheKey = material.customProgramCacheKey();
|
|
688
688
|
|
|
@@ -712,6 +712,18 @@ class RenderObject {
|
|
|
712
712
|
|
|
713
713
|
valueKey += value.mapping;
|
|
714
714
|
|
|
715
|
+
// WebGPU must honor the sampler data because they are part of the bindings
|
|
716
|
+
|
|
717
|
+
if ( renderer.backend.isWebGPUBackend === true ) {
|
|
718
|
+
|
|
719
|
+
valueKey += value.magFilter;
|
|
720
|
+
valueKey += value.minFilter;
|
|
721
|
+
valueKey += value.wrapS;
|
|
722
|
+
valueKey += value.wrapT;
|
|
723
|
+
valueKey += value.wrapR;
|
|
724
|
+
|
|
725
|
+
}
|
|
726
|
+
|
|
715
727
|
}
|
|
716
728
|
|
|
717
729
|
valueKey += '}';
|
|
@@ -758,7 +770,7 @@ class RenderObject {
|
|
|
758
770
|
|
|
759
771
|
}
|
|
760
772
|
|
|
761
|
-
if ( object.count > 1 ) {
|
|
773
|
+
if ( object.isInstancedMesh || object.count > 1 ) {
|
|
762
774
|
|
|
763
775
|
// TODO: https://github.com/mrdoob/three.js/pull/29066#issuecomment-2269400850
|
|
764
776
|
|
|
@@ -21,13 +21,14 @@ import XRManager from './XRManager.js';
|
|
|
21
21
|
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
22
22
|
|
|
23
23
|
import { Scene } from '../../scenes/Scene.js';
|
|
24
|
+
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
24
25
|
import { Frustum } from '../../math/Frustum.js';
|
|
25
26
|
import { FrustumArray } from '../../math/FrustumArray.js';
|
|
26
27
|
import { Matrix4 } from '../../math/Matrix4.js';
|
|
27
28
|
import { Vector2 } from '../../math/Vector2.js';
|
|
28
29
|
import { Vector4 } from '../../math/Vector4.js';
|
|
29
30
|
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
30
|
-
import { DoubleSide, BackSide, FrontSide, SRGBColorSpace, NoToneMapping, LinearFilter,
|
|
31
|
+
import { DoubleSide, BackSide, FrontSide, SRGBColorSpace, NoToneMapping, LinearFilter, HalfFloatType, RGBAFormat, PCFShadowMap } from '../../constants.js';
|
|
31
32
|
|
|
32
33
|
import { highpModelNormalViewMatrix, highpModelViewMatrix } from '../../nodes/accessors/ModelNode.js';
|
|
33
34
|
|
|
@@ -1210,7 +1211,7 @@ class Renderer {
|
|
|
1210
1211
|
const { currentToneMapping, currentColorSpace } = this;
|
|
1211
1212
|
|
|
1212
1213
|
const useToneMapping = currentToneMapping !== NoToneMapping;
|
|
1213
|
-
const useColorSpace = currentColorSpace !==
|
|
1214
|
+
const useColorSpace = currentColorSpace !== ColorManagement.workingColorSpace;
|
|
1214
1215
|
|
|
1215
1216
|
if ( useToneMapping === false && useColorSpace === false ) return null;
|
|
1216
1217
|
|
|
@@ -1226,7 +1227,7 @@ class Renderer {
|
|
|
1226
1227
|
stencilBuffer: stencil,
|
|
1227
1228
|
type: this._colorBufferType,
|
|
1228
1229
|
format: RGBAFormat,
|
|
1229
|
-
colorSpace:
|
|
1230
|
+
colorSpace: ColorManagement.workingColorSpace,
|
|
1230
1231
|
generateMipmaps: false,
|
|
1231
1232
|
minFilter: LinearFilter,
|
|
1232
1233
|
magFilter: LinearFilter,
|
|
@@ -1412,7 +1413,7 @@ class Renderer {
|
|
|
1412
1413
|
if ( ! camera.isArrayCamera ) {
|
|
1413
1414
|
|
|
1414
1415
|
_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
|
|
1415
|
-
frustum.setFromProjectionMatrix( _projScreenMatrix, coordinateSystem );
|
|
1416
|
+
frustum.setFromProjectionMatrix( _projScreenMatrix, camera.coordinateSystem, camera.reversedDepth );
|
|
1416
1417
|
|
|
1417
1418
|
}
|
|
1418
1419
|
|
|
@@ -1449,8 +1450,8 @@ class Renderer {
|
|
|
1449
1450
|
|
|
1450
1451
|
renderContext.textures = null;
|
|
1451
1452
|
renderContext.depthTexture = null;
|
|
1452
|
-
renderContext.width =
|
|
1453
|
-
renderContext.height =
|
|
1453
|
+
renderContext.width = _drawingBufferSize.width;
|
|
1454
|
+
renderContext.height = _drawingBufferSize.height;
|
|
1454
1455
|
renderContext.depth = this.depth;
|
|
1455
1456
|
renderContext.stencil = this.stencil;
|
|
1456
1457
|
|
|
@@ -1464,6 +1465,22 @@ class Renderer {
|
|
|
1464
1465
|
|
|
1465
1466
|
//
|
|
1466
1467
|
|
|
1468
|
+
renderContext.scissorValue.max( _vector4.set( 0, 0, 0, 0 ) );
|
|
1469
|
+
|
|
1470
|
+
if ( renderContext.scissorValue.x + renderContext.scissorValue.width > renderContext.width ) {
|
|
1471
|
+
|
|
1472
|
+
renderContext.scissorValue.width = Math.max( renderContext.width - renderContext.scissorValue.x, 0 );
|
|
1473
|
+
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
if ( renderContext.scissorValue.y + renderContext.scissorValue.height > renderContext.height ) {
|
|
1477
|
+
|
|
1478
|
+
renderContext.scissorValue.height = Math.max( renderContext.height - renderContext.scissorValue.y, 0 );
|
|
1479
|
+
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
//
|
|
1483
|
+
|
|
1467
1484
|
this._background.update( sceneRef, renderList, renderContext );
|
|
1468
1485
|
|
|
1469
1486
|
//
|
|
@@ -2130,8 +2147,8 @@ class Renderer {
|
|
|
2130
2147
|
}
|
|
2131
2148
|
|
|
2132
2149
|
/**
|
|
2133
|
-
* The current
|
|
2134
|
-
* the
|
|
2150
|
+
* The current tone mapping of the renderer. When not producing screen output,
|
|
2151
|
+
* the tone mapping is always `NoToneMapping`.
|
|
2135
2152
|
*
|
|
2136
2153
|
* @type {number}
|
|
2137
2154
|
*/
|
|
@@ -2142,14 +2159,14 @@ class Renderer {
|
|
|
2142
2159
|
}
|
|
2143
2160
|
|
|
2144
2161
|
/**
|
|
2145
|
-
* The current
|
|
2146
|
-
* the
|
|
2162
|
+
* The current color space of the renderer. When not producing screen output,
|
|
2163
|
+
* the color space is always the working color space.
|
|
2147
2164
|
*
|
|
2148
2165
|
* @type {string}
|
|
2149
2166
|
*/
|
|
2150
2167
|
get currentColorSpace() {
|
|
2151
2168
|
|
|
2152
|
-
return this.isOutputTarget ? this.outputColorSpace :
|
|
2169
|
+
return this.isOutputTarget ? this.outputColorSpace : ColorManagement.workingColorSpace;
|
|
2153
2170
|
|
|
2154
2171
|
}
|
|
2155
2172
|
|
|
@@ -2170,25 +2187,29 @@ class Renderer {
|
|
|
2170
2187
|
*/
|
|
2171
2188
|
dispose() {
|
|
2172
2189
|
|
|
2173
|
-
this.
|
|
2174
|
-
this.backend.dispose();
|
|
2190
|
+
if ( this._initialized === true ) {
|
|
2175
2191
|
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
this._pipelines.dispose();
|
|
2179
|
-
this._nodes.dispose();
|
|
2180
|
-
this._bindings.dispose();
|
|
2181
|
-
this._renderLists.dispose();
|
|
2182
|
-
this._renderContexts.dispose();
|
|
2183
|
-
this._textures.dispose();
|
|
2192
|
+
this.info.dispose();
|
|
2193
|
+
this.backend.dispose();
|
|
2184
2194
|
|
|
2185
|
-
|
|
2195
|
+
this._animation.dispose();
|
|
2196
|
+
this._objects.dispose();
|
|
2197
|
+
this._pipelines.dispose();
|
|
2198
|
+
this._nodes.dispose();
|
|
2199
|
+
this._bindings.dispose();
|
|
2200
|
+
this._renderLists.dispose();
|
|
2201
|
+
this._renderContexts.dispose();
|
|
2202
|
+
this._textures.dispose();
|
|
2186
2203
|
|
|
2187
|
-
|
|
2204
|
+
if ( this._frameBufferTarget !== null ) this._frameBufferTarget.dispose();
|
|
2188
2205
|
|
|
2189
|
-
|
|
2206
|
+
Object.values( this.backend.timestampQueryPool ).forEach( queryPool => {
|
|
2190
2207
|
|
|
2191
|
-
|
|
2208
|
+
if ( queryPool !== null ) queryPool.dispose();
|
|
2209
|
+
|
|
2210
|
+
} );
|
|
2211
|
+
|
|
2212
|
+
}
|
|
2192
2213
|
|
|
2193
2214
|
this.setRenderTarget( null );
|
|
2194
2215
|
this.setAnimationLoop( null );
|
|
@@ -2308,9 +2329,10 @@ class Renderer {
|
|
|
2308
2329
|
* if the renderer has been initialized.
|
|
2309
2330
|
*
|
|
2310
2331
|
* @param {Node|Array<Node>} computeNodes - The compute node(s).
|
|
2332
|
+
* @param {?(Array<number>|number)} [dispatchSizeOrCount=null] - Array with [ x, y, z ] values for dispatch or a single number for the count.
|
|
2311
2333
|
* @return {Promise|undefined} A Promise that resolve when the compute has finished. Only returned when the renderer has not been initialized.
|
|
2312
2334
|
*/
|
|
2313
|
-
compute( computeNodes ) {
|
|
2335
|
+
compute( computeNodes, dispatchSizeOrCount = null ) {
|
|
2314
2336
|
|
|
2315
2337
|
if ( this._isDeviceLost === true ) return;
|
|
2316
2338
|
|
|
@@ -2389,7 +2411,7 @@ class Renderer {
|
|
|
2389
2411
|
const computeBindings = bindings.getForCompute( computeNode );
|
|
2390
2412
|
const computePipeline = pipelines.getForCompute( computeNode, computeBindings );
|
|
2391
2413
|
|
|
2392
|
-
backend.compute( computeNodes, computeNode, computeBindings, computePipeline );
|
|
2414
|
+
backend.compute( computeNodes, computeNode, computeBindings, computePipeline, dispatchSizeOrCount );
|
|
2393
2415
|
|
|
2394
2416
|
}
|
|
2395
2417
|
|
|
@@ -2406,13 +2428,14 @@ class Renderer {
|
|
|
2406
2428
|
*
|
|
2407
2429
|
* @async
|
|
2408
2430
|
* @param {Node|Array<Node>} computeNodes - The compute node(s).
|
|
2431
|
+
* @param {?(Array<number>|number)} [dispatchSizeOrCount=null] - Array with [ x, y, z ] values for dispatch or a single number for the count.
|
|
2409
2432
|
* @return {Promise} A Promise that resolve when the compute has finished.
|
|
2410
2433
|
*/
|
|
2411
|
-
async computeAsync( computeNodes ) {
|
|
2434
|
+
async computeAsync( computeNodes, dispatchSizeOrCount = null ) {
|
|
2412
2435
|
|
|
2413
2436
|
if ( this._initialized === false ) await this.init();
|
|
2414
2437
|
|
|
2415
|
-
this.compute( computeNodes );
|
|
2438
|
+
this.compute( computeNodes, dispatchSizeOrCount );
|
|
2416
2439
|
|
|
2417
2440
|
}
|
|
2418
2441
|
|
|
@@ -2511,7 +2534,7 @@ class Renderer {
|
|
|
2511
2534
|
* Copies the current bound framebuffer into the given texture.
|
|
2512
2535
|
*
|
|
2513
2536
|
* @param {FramebufferTexture} framebufferTexture - The texture.
|
|
2514
|
-
* @param {?Vector2|Vector4} [rectangle=null] - A two or four dimensional vector that defines the rectangular portion of the framebuffer that should be copied.
|
|
2537
|
+
* @param {?(Vector2|Vector4)} [rectangle=null] - A two or four dimensional vector that defines the rectangular portion of the framebuffer that should be copied.
|
|
2515
2538
|
*/
|
|
2516
2539
|
copyFramebufferToTexture( framebufferTexture, rectangle = null ) {
|
|
2517
2540
|
|
|
@@ -2961,7 +2984,7 @@ class Renderer {
|
|
|
2961
2984
|
* @param {LightsNode} lightsNode - The current lights node.
|
|
2962
2985
|
* @param {?{start: number, count: number}} group - Only relevant for objects using multiple materials. This represents a group entry from the respective `BufferGeometry`.
|
|
2963
2986
|
* @param {ClippingContext} clippingContext - The clipping context.
|
|
2964
|
-
* @param {
|
|
2987
|
+
* @param {string} [passId] - An optional ID for identifying the pass.
|
|
2965
2988
|
*/
|
|
2966
2989
|
_renderObjectDirect( object, material, scene, camera, lightsNode, group, clippingContext, passId ) {
|
|
2967
2990
|
|
|
@@ -3016,7 +3039,7 @@ class Renderer {
|
|
|
3016
3039
|
* @param {LightsNode} lightsNode - The current lights node.
|
|
3017
3040
|
* @param {?{start: number, count: number}} group - Only relevant for objects using multiple materials. This represents a group entry from the respective `BufferGeometry`.
|
|
3018
3041
|
* @param {ClippingContext} clippingContext - The clipping context.
|
|
3019
|
-
* @param {
|
|
3042
|
+
* @param {string} [passId] - An optional ID for identifying the pass.
|
|
3020
3043
|
*/
|
|
3021
3044
|
_createObjectPipeline( object, material, scene, camera, lightsNode, group, clippingContext, passId ) {
|
|
3022
3045
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Sampler from './Sampler.js';
|
|
2
2
|
|
|
3
3
|
let _id = 0;
|
|
4
4
|
|
|
@@ -6,9 +6,9 @@ let _id = 0;
|
|
|
6
6
|
* Represents a sampled texture binding type.
|
|
7
7
|
*
|
|
8
8
|
* @private
|
|
9
|
-
* @augments
|
|
9
|
+
* @augments Sampler
|
|
10
10
|
*/
|
|
11
|
-
class SampledTexture extends
|
|
11
|
+
class SampledTexture extends Sampler {
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Constructs a new sampled texture.
|
|
@@ -18,7 +18,7 @@ class SampledTexture extends Binding {
|
|
|
18
18
|
*/
|
|
19
19
|
constructor( name, texture ) {
|
|
20
20
|
|
|
21
|
-
super( name );
|
|
21
|
+
super( name, texture );
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* This identifier.
|
|
@@ -27,20 +27,6 @@ class SampledTexture extends Binding {
|
|
|
27
27
|
*/
|
|
28
28
|
this.id = _id ++;
|
|
29
29
|
|
|
30
|
-
/**
|
|
31
|
-
* The texture this binding is referring to.
|
|
32
|
-
*
|
|
33
|
-
* @type {?Texture}
|
|
34
|
-
*/
|
|
35
|
-
this.texture = texture;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The binding's version.
|
|
39
|
-
*
|
|
40
|
-
* @type {number}
|
|
41
|
-
*/
|
|
42
|
-
this.version = texture ? texture.version : 0;
|
|
43
|
-
|
|
44
30
|
/**
|
|
45
31
|
* Whether the texture is a storage texture or not.
|
|
46
32
|
*
|
|
@@ -49,15 +35,6 @@ class SampledTexture extends Binding {
|
|
|
49
35
|
*/
|
|
50
36
|
this.store = false;
|
|
51
37
|
|
|
52
|
-
/**
|
|
53
|
-
* The binding's generation which is an additional version
|
|
54
|
-
* qualifier.
|
|
55
|
-
*
|
|
56
|
-
* @type {?number}
|
|
57
|
-
* @default null
|
|
58
|
-
*/
|
|
59
|
-
this.generation = null;
|
|
60
|
-
|
|
61
38
|
/**
|
|
62
39
|
* This flag can be used for type testing.
|
|
63
40
|
*
|
|
@@ -69,51 +46,6 @@ class SampledTexture extends Binding {
|
|
|
69
46
|
|
|
70
47
|
}
|
|
71
48
|
|
|
72
|
-
/**
|
|
73
|
-
* Returns `true` whether this binding requires an update for the
|
|
74
|
-
* given generation.
|
|
75
|
-
*
|
|
76
|
-
* @param {number} generation - The generation.
|
|
77
|
-
* @return {boolean} Whether an update is required or not.
|
|
78
|
-
*/
|
|
79
|
-
needsBindingsUpdate( generation ) {
|
|
80
|
-
|
|
81
|
-
const { texture } = this;
|
|
82
|
-
|
|
83
|
-
if ( generation !== this.generation ) {
|
|
84
|
-
|
|
85
|
-
this.generation = generation;
|
|
86
|
-
|
|
87
|
-
return true;
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return texture.isVideoTexture;
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Updates the binding.
|
|
97
|
-
*
|
|
98
|
-
* @return {boolean} Whether the texture has been updated and must be
|
|
99
|
-
* uploaded to the GPU.
|
|
100
|
-
*/
|
|
101
|
-
update() {
|
|
102
|
-
|
|
103
|
-
const { texture, version } = this;
|
|
104
|
-
|
|
105
|
-
if ( version !== texture.version ) {
|
|
106
|
-
|
|
107
|
-
this.version = texture.version;
|
|
108
|
-
|
|
109
|
-
return true;
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return false;
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
49
|
}
|
|
118
50
|
|
|
119
51
|
/**
|