@plastic-software/three 0.181.2 → 0.182.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 +3 -4
- package/build/three.cjs +1192 -522
- package/build/three.core.js +345 -219
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +864 -328
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +15 -3
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +3660 -1545
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +3659 -1544
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/controls/MapControls.js +55 -1
- package/examples/jsm/controls/OrbitControls.js +6 -6
- package/examples/jsm/controls/TrackballControls.js +6 -6
- package/examples/jsm/csm/CSM.js +2 -1
- package/examples/jsm/environments/RoomEnvironment.js +2 -0
- package/examples/jsm/geometries/DecalGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelperGPU.js +1 -1
- package/examples/jsm/helpers/TextureHelperGPU.js +1 -1
- package/examples/jsm/inspector/Inspector.js +53 -9
- package/examples/jsm/inspector/RendererInspector.js +12 -2
- package/examples/jsm/inspector/tabs/Console.js +2 -2
- package/examples/jsm/inspector/tabs/Parameters.js +2 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Viewer.js +4 -4
- package/examples/jsm/inspector/ui/Profiler.js +1836 -31
- package/examples/jsm/inspector/ui/Style.js +948 -13
- package/examples/jsm/inspector/ui/Tab.js +188 -1
- package/examples/jsm/inspector/ui/Values.js +17 -1
- package/examples/jsm/loaders/3DMLoader.js +5 -4
- package/examples/jsm/loaders/DRACOLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +0 -2
- package/examples/jsm/loaders/HDRLoader.js +0 -1
- package/examples/jsm/loaders/KTX2Loader.js +16 -0
- package/examples/jsm/loaders/LDrawLoader.js +2 -3
- package/examples/jsm/loaders/PCDLoader.js +1 -0
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/TDSLoader.js +0 -2
- package/examples/jsm/loaders/TGALoader.js +0 -2
- package/examples/jsm/loaders/UltraHDRLoader.js +110 -137
- package/examples/jsm/loaders/VOXLoader.js +660 -117
- package/examples/jsm/loaders/VRMLLoader.js +2 -2
- package/examples/jsm/loaders/usd/USDCParser.js +1 -1
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +1 -1
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -1
- package/examples/jsm/materials/WoodNodeMaterial.js +11 -11
- package/examples/jsm/math/Octree.js +131 -1
- package/examples/jsm/misc/Volume.js +0 -1
- package/examples/jsm/misc/VolumeSlice.js +0 -1
- package/examples/jsm/objects/SkyMesh.js +13 -3
- package/examples/jsm/physics/AmmoPhysics.js +12 -7
- package/examples/jsm/physics/JoltPhysics.js +3 -1
- package/examples/jsm/physics/RapierPhysics.js +3 -1
- package/examples/jsm/postprocessing/OutputPass.js +9 -0
- package/examples/jsm/postprocessing/RenderPass.js +10 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.js +48 -18
- package/examples/jsm/renderers/Projector.js +268 -30
- package/examples/jsm/renderers/SVGRenderer.js +191 -58
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -4
- package/examples/jsm/transpiler/AST.js +44 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +61 -4
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -0
- package/examples/jsm/transpiler/TSLEncoder.js +46 -3
- package/examples/jsm/transpiler/TranspilerUtils.js +3 -3
- package/examples/jsm/transpiler/WGSLEncoder.js +27 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +2 -0
- package/examples/jsm/tsl/display/BloomNode.js +11 -1
- package/examples/jsm/tsl/display/GTAONode.js +3 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +2 -1
- package/examples/jsm/tsl/display/SSGINode.js +7 -19
- package/examples/jsm/tsl/display/SSRNode.js +1 -1
- package/examples/jsm/tsl/display/SSSNode.js +4 -2
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +8 -1
- package/examples/jsm/tsl/display/TRAANode.js +265 -114
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/utils/ShadowMapViewer.js +24 -10
- package/examples/jsm/utils/ShadowMapViewerGPU.js +1 -1
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/package.json +14 -12
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +14 -2
- package/src/animation/AnimationUtils.js +1 -12
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/ColorKeyframeTrack.js +1 -1
- package/src/animation/tracks/NumberKeyframeTrack.js +1 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/animation/tracks/VectorKeyframeTrack.js +1 -1
- package/src/constants.js +61 -5
- package/src/core/BufferGeometry.js +14 -2
- package/src/core/Raycaster.js +2 -2
- package/src/extras/PMREMGenerator.js +3 -10
- package/src/extras/TextureUtils.js +5 -1
- package/src/geometries/ExtrudeGeometry.js +2 -2
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/helpers/PointLightHelper.js +1 -1
- package/src/lights/DirectionalLight.js +13 -0
- package/src/lights/HemisphereLight.js +10 -0
- package/src/lights/Light.js +1 -11
- package/src/lights/LightProbe.js +0 -15
- package/src/lights/LightShadow.js +0 -3
- package/src/lights/PointLight.js +15 -0
- package/src/lights/PointLightShadow.js +0 -86
- package/src/lights/SpotLight.js +22 -1
- package/src/loaders/MaterialLoader.js +2 -1
- package/src/loaders/ObjectLoader.js +3 -1
- package/src/loaders/nodes/NodeLoader.js +2 -2
- package/src/materials/Material.js +2 -0
- package/src/materials/ShaderMaterial.js +20 -1
- package/src/materials/nodes/Line2NodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +3 -2
- package/src/materials/nodes/MeshStandardNodeMaterial.js +5 -4
- package/src/materials/nodes/NodeMaterial.js +59 -3
- package/src/materials/nodes/manager/NodeMaterialObserver.js +1 -1
- package/src/math/Matrix4.js +40 -40
- package/src/math/Sphere.js +1 -1
- package/src/math/Vector3.js +0 -2
- package/src/nodes/TSL.js +4 -1
- package/src/nodes/accessors/BatchNode.js +10 -10
- package/src/nodes/accessors/BufferAttributeNode.js +98 -12
- package/src/nodes/accessors/BufferNode.js +29 -2
- package/src/nodes/accessors/ClippingNode.js +4 -4
- package/src/nodes/accessors/CubeTextureNode.js +20 -1
- package/src/nodes/accessors/InstanceNode.js +69 -29
- package/src/nodes/accessors/MaterialNode.js +9 -1
- package/src/nodes/accessors/MaterialReferenceNode.js +1 -2
- package/src/nodes/accessors/ModelNode.js +1 -1
- package/src/nodes/accessors/Normal.js +2 -2
- package/src/nodes/accessors/ReferenceBaseNode.js +4 -4
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/RendererReferenceNode.js +1 -2
- package/src/nodes/accessors/SkinningNode.js +15 -2
- package/src/nodes/accessors/StorageBufferNode.js +4 -2
- package/src/nodes/accessors/Tangent.js +1 -11
- package/src/nodes/accessors/Texture3DNode.js +26 -1
- package/src/nodes/accessors/UniformArrayNode.js +2 -2
- package/src/nodes/accessors/UserDataNode.js +1 -2
- package/src/nodes/accessors/VertexColorNode.js +1 -2
- package/src/nodes/code/FunctionNode.js +1 -2
- package/src/nodes/core/ArrayNode.js +20 -1
- package/src/nodes/core/AssignNode.js +2 -2
- package/src/nodes/core/AttributeNode.js +2 -2
- package/src/nodes/core/ContextNode.js +103 -4
- package/src/nodes/core/NodeBuilder.js +56 -14
- package/src/nodes/core/NodeFrame.js +12 -4
- package/src/nodes/core/NodeUtils.js +5 -5
- package/src/nodes/core/ParameterNode.js +1 -2
- package/src/nodes/core/PropertyNode.js +19 -3
- package/src/nodes/core/StackNode.js +56 -8
- package/src/nodes/core/StructNode.js +1 -2
- package/src/nodes/core/StructTypeNode.js +11 -17
- package/src/nodes/core/UniformNode.js +19 -4
- package/src/nodes/core/VarNode.js +46 -21
- package/src/nodes/display/NormalMapNode.js +37 -2
- package/src/nodes/display/PassNode.js +77 -7
- package/src/nodes/display/ScreenNode.js +1 -0
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +3 -3
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
- package/src/nodes/functions/PhysicalLightingModel.js +102 -43
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -2
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -3
- package/src/nodes/lighting/AnalyticLightNode.js +53 -0
- package/src/nodes/lighting/LightsNode.js +2 -2
- package/src/nodes/lighting/PointShadowNode.js +141 -140
- package/src/nodes/lighting/ShadowFilterNode.js +53 -37
- package/src/nodes/lighting/ShadowNode.js +53 -19
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/pmrem/PMREMNode.js +1 -1
- package/src/nodes/tsl/TSLCore.js +4 -4
- package/src/nodes/utils/ArrayElementNode.js +13 -0
- package/src/nodes/utils/EventNode.js +1 -2
- package/src/nodes/utils/Packing.js +13 -1
- package/src/nodes/utils/PostProcessingUtils.js +33 -1
- package/src/nodes/utils/ReflectorNode.js +1 -1
- package/src/nodes/utils/SampleNode.js +1 -1
- package/src/nodes/utils/UVUtils.js +26 -0
- package/src/objects/BatchedMesh.js +5 -2
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/objects/Skeleton.js +9 -0
- package/src/renderers/WebGLRenderer.js +145 -33
- package/src/renderers/common/Backend.js +8 -0
- package/src/renderers/common/Background.js +19 -9
- package/src/renderers/common/Binding.js +11 -0
- package/src/renderers/common/Bindings.js +7 -7
- package/src/renderers/common/Buffer.js +40 -0
- package/src/renderers/common/ChainMap.js +30 -6
- package/src/renderers/common/Geometries.js +12 -0
- package/src/renderers/common/RenderContexts.js +8 -1
- package/src/renderers/common/RenderObject.js +14 -1
- package/src/renderers/common/Renderer.js +53 -35
- package/src/renderers/common/Textures.js +1 -1
- package/src/renderers/common/UniformsGroup.js +1 -0
- package/src/renderers/common/XRManager.js +1 -0
- package/src/renderers/common/extras/PMREMGenerator.js +2 -8
- package/src/renderers/common/nodes/NodeUniformBuffer.js +52 -0
- package/src/renderers/shaders/DFGLUTData.js +19 -34
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +5 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +90 -51
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +194 -186
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +3 -3
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +3 -3
- package/src/renderers/webgl/WebGLCapabilities.js +3 -4
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLOutput.js +267 -0
- package/src/renderers/webgl/WebGLProgram.js +43 -107
- package/src/renderers/webgl/WebGLPrograms.js +35 -45
- package/src/renderers/webgl/WebGLShadowMap.js +188 -25
- package/src/renderers/webgl/WebGLState.js +20 -20
- package/src/renderers/webgl/WebGLTextures.js +89 -28
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUtils.js +6 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +79 -13
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +59 -7
- package/src/renderers/webgl-fallback/utils/WebGLState.js +18 -3
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +5 -3
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -9
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +6 -2
- package/src/renderers/webgpu/WebGPUBackend.js +61 -4
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +65 -23
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +354 -186
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +20 -7
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +40 -17
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +7 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +7 -5
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +1 -1
- package/src/utils.js +13 -1
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -71
|
@@ -44,6 +44,46 @@ class Buffer extends Binding {
|
|
|
44
44
|
*/
|
|
45
45
|
this._buffer = buffer;
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* An array of update ranges.
|
|
49
|
+
*
|
|
50
|
+
* @private
|
|
51
|
+
* @type {Array<{start: number, count: number}>}
|
|
52
|
+
*/
|
|
53
|
+
this._updateRanges = [];
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The array of update ranges.
|
|
59
|
+
*
|
|
60
|
+
* @type {Array<{start: number, count: number}>}
|
|
61
|
+
*/
|
|
62
|
+
get updateRanges() {
|
|
63
|
+
|
|
64
|
+
return this._updateRanges;
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Adds an update range.
|
|
70
|
+
*
|
|
71
|
+
* @param {number} start - The start index.
|
|
72
|
+
* @param {number} count - The number of elements.
|
|
73
|
+
*/
|
|
74
|
+
addUpdateRange( start, count ) {
|
|
75
|
+
|
|
76
|
+
this.updateRanges.push( { start, count } );
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Clears all update ranges.
|
|
82
|
+
*/
|
|
83
|
+
clearUpdateRanges() {
|
|
84
|
+
|
|
85
|
+
this.updateRanges.length = 0;
|
|
86
|
+
|
|
47
87
|
}
|
|
48
88
|
|
|
49
89
|
/**
|
|
@@ -14,11 +14,35 @@ class ChainMap {
|
|
|
14
14
|
constructor() {
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* A map of Weak Maps by their key length.
|
|
18
18
|
*
|
|
19
|
-
* @type {
|
|
19
|
+
* @type {Object<number, WeakMap>}
|
|
20
20
|
*/
|
|
21
|
-
this.
|
|
21
|
+
this.weakMaps = {};
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Returns the Weak Map for the given keys.
|
|
28
|
+
*
|
|
29
|
+
* @param {Array<Object>} keys - List of keys.
|
|
30
|
+
* @return {WeakMap} The weak map.
|
|
31
|
+
*/
|
|
32
|
+
_getWeakMap( keys ) {
|
|
33
|
+
|
|
34
|
+
const length = keys.length;
|
|
35
|
+
|
|
36
|
+
let weakMap = this.weakMaps[ length ];
|
|
37
|
+
|
|
38
|
+
if ( weakMap === undefined ) {
|
|
39
|
+
|
|
40
|
+
weakMap = new WeakMap();
|
|
41
|
+
this.weakMaps[ length ] = weakMap;
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return weakMap;
|
|
22
46
|
|
|
23
47
|
}
|
|
24
48
|
|
|
@@ -30,7 +54,7 @@ class ChainMap {
|
|
|
30
54
|
*/
|
|
31
55
|
get( keys ) {
|
|
32
56
|
|
|
33
|
-
let map = this.
|
|
57
|
+
let map = this._getWeakMap( keys );
|
|
34
58
|
|
|
35
59
|
for ( let i = 0; i < keys.length - 1; i ++ ) {
|
|
36
60
|
|
|
@@ -53,7 +77,7 @@ class ChainMap {
|
|
|
53
77
|
*/
|
|
54
78
|
set( keys, value ) {
|
|
55
79
|
|
|
56
|
-
let map = this.
|
|
80
|
+
let map = this._getWeakMap( keys );
|
|
57
81
|
|
|
58
82
|
for ( let i = 0; i < keys.length - 1; i ++ ) {
|
|
59
83
|
|
|
@@ -79,7 +103,7 @@ class ChainMap {
|
|
|
79
103
|
*/
|
|
80
104
|
delete( keys ) {
|
|
81
105
|
|
|
82
|
-
let map = this.
|
|
106
|
+
let map = this._getWeakMap( keys );
|
|
83
107
|
|
|
84
108
|
for ( let i = 0; i < keys.length - 1; i ++ ) {
|
|
85
109
|
|
|
@@ -310,6 +310,18 @@ class Geometries extends DataMap {
|
|
|
310
310
|
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
+
/**
|
|
314
|
+
* Returns the byte offset into the indirect attribute buffer of the given render object.
|
|
315
|
+
*
|
|
316
|
+
* @param {RenderObject} renderObject - The render object.
|
|
317
|
+
* @return {number} The byte offset into the indirect attribute buffer.
|
|
318
|
+
*/
|
|
319
|
+
getIndirectOffset( renderObject ) {
|
|
320
|
+
|
|
321
|
+
return renderObject.geometry.indirectOffset;
|
|
322
|
+
|
|
323
|
+
}
|
|
324
|
+
|
|
313
325
|
/**
|
|
314
326
|
* Returns the index of the given render object's geometry. This is implemented
|
|
315
327
|
* in a method to return a wireframe index if necessary.
|
|
@@ -35,13 +35,20 @@ class RenderContexts {
|
|
|
35
35
|
* @param {Scene} scene - The scene.
|
|
36
36
|
* @param {Camera} camera - The camera that is used to render the scene.
|
|
37
37
|
* @param {?RenderTarget} [renderTarget=null] - The active render target.
|
|
38
|
+
* @param {?MRT} [mrt=null] - The active multiple render target.
|
|
38
39
|
* @return {RenderContext} The render context.
|
|
39
40
|
*/
|
|
40
|
-
get( scene, camera, renderTarget = null ) {
|
|
41
|
+
get( scene, camera, renderTarget = null, mrt = null ) {
|
|
41
42
|
|
|
42
43
|
_chainKeys[ 0 ] = scene;
|
|
43
44
|
_chainKeys[ 1 ] = camera;
|
|
44
45
|
|
|
46
|
+
if ( mrt !== null ) {
|
|
47
|
+
|
|
48
|
+
_chainKeys[ 2 ] = mrt;
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
45
52
|
let attachmentState;
|
|
46
53
|
|
|
47
54
|
if ( renderTarget === null ) {
|
|
@@ -444,6 +444,17 @@ class RenderObject {
|
|
|
444
444
|
|
|
445
445
|
}
|
|
446
446
|
|
|
447
|
+
/**
|
|
448
|
+
* Returns the byte offset into the indirect attribute buffer.
|
|
449
|
+
*
|
|
450
|
+
* @return {number|Array<number>} The byte offset into the indirect attribute buffer.
|
|
451
|
+
*/
|
|
452
|
+
getIndirectOffset() {
|
|
453
|
+
|
|
454
|
+
return this._geometries.getIndirectOffset( this );
|
|
455
|
+
|
|
456
|
+
}
|
|
457
|
+
|
|
447
458
|
/**
|
|
448
459
|
* Returns an array that acts as a key for identifying the render object in a chain map.
|
|
449
460
|
*
|
|
@@ -778,6 +789,8 @@ class RenderObject {
|
|
|
778
789
|
|
|
779
790
|
}
|
|
780
791
|
|
|
792
|
+
cacheKey += this.context.id + ',';
|
|
793
|
+
|
|
781
794
|
cacheKey += object.receiveShadow + ',';
|
|
782
795
|
|
|
783
796
|
return hashString( cacheKey );
|
|
@@ -869,7 +882,7 @@ class RenderObject {
|
|
|
869
882
|
|
|
870
883
|
}
|
|
871
884
|
|
|
872
|
-
cacheKey = hash( cacheKey, this.camera.id );
|
|
885
|
+
cacheKey = hash( cacheKey, this.camera.id, this.renderer.contextNode.id, this.renderer.contextNode.version );
|
|
873
886
|
|
|
874
887
|
return cacheKey;
|
|
875
888
|
|
|
@@ -35,6 +35,7 @@ import { DoubleSide, BackSide, FrontSide, SRGBColorSpace, NoToneMapping, LinearF
|
|
|
35
35
|
import { float, vec3, vec4 } from '../../nodes/tsl/TSLCore.js';
|
|
36
36
|
import { reference } from '../../nodes/accessors/ReferenceNode.js';
|
|
37
37
|
import { highpModelNormalViewMatrix, highpModelViewMatrix } from '../../nodes/accessors/ModelNode.js';
|
|
38
|
+
import { context } from '../../nodes/core/ContextNode.js';
|
|
38
39
|
import { error, warn, warnOnce } from '../../utils.js';
|
|
39
40
|
|
|
40
41
|
const _scene = /*@__PURE__*/ new Scene();
|
|
@@ -63,7 +64,7 @@ class Renderer {
|
|
|
63
64
|
* @property {number} [samples=0] - When `antialias` is `true`, `4` samples are used by default. This parameter can set to any other integer value than 0
|
|
64
65
|
* to overwrite the default.
|
|
65
66
|
* @property {?Function} [getFallback=null] - This callback function can be used to provide a fallback backend, if the primary backend can't be targeted.
|
|
66
|
-
* @property {number} [
|
|
67
|
+
* @property {number} [outputBufferType=HalfFloatType] - Defines the type of output buffers. The default `HalfFloatType` is recommend for best
|
|
67
68
|
* quality. To save memory and bandwidth, `UnsignedByteType` might be used. This will reduce rendering quality though.
|
|
68
69
|
* @property {boolean} [multiview=false] - If set to `true`, the renderer will use multiview during WebXR rendering if supported.
|
|
69
70
|
*/
|
|
@@ -96,7 +97,7 @@ class Renderer {
|
|
|
96
97
|
antialias = false,
|
|
97
98
|
samples = 0,
|
|
98
99
|
getFallback = null,
|
|
99
|
-
|
|
100
|
+
outputBufferType = HalfFloatType,
|
|
100
101
|
multiview = false
|
|
101
102
|
} = parameters;
|
|
102
103
|
|
|
@@ -222,17 +223,13 @@ class Renderer {
|
|
|
222
223
|
this.info = new Info();
|
|
223
224
|
|
|
224
225
|
/**
|
|
225
|
-
*
|
|
226
|
+
* A global context node that stores override nodes for specific transformations or calculations.
|
|
226
227
|
* These nodes can be used to replace default behavior in the rendering pipeline.
|
|
227
228
|
*
|
|
228
|
-
* @type {
|
|
229
|
-
* @property {
|
|
230
|
-
* @property {?Node} modelNormalViewMatrix - An override node for the model normal view matrix.
|
|
229
|
+
* @type {ContextNode}
|
|
230
|
+
* @property {Object} value - The context value object.
|
|
231
231
|
*/
|
|
232
|
-
this.
|
|
233
|
-
modelViewMatrix: null,
|
|
234
|
-
modelNormalViewMatrix: null
|
|
235
|
-
};
|
|
232
|
+
this.contextNode = context();
|
|
236
233
|
|
|
237
234
|
/**
|
|
238
235
|
* The node library defines how certain library objects like materials, lights
|
|
@@ -587,7 +584,7 @@ class Renderer {
|
|
|
587
584
|
this.onDeviceLost = this._onDeviceLost;
|
|
588
585
|
|
|
589
586
|
/**
|
|
590
|
-
* Defines the type of
|
|
587
|
+
* Defines the type of output buffers. The default `HalfFloatType` is recommend for
|
|
591
588
|
* best quality. To save memory and bandwidth, `UnsignedByteType` might be used.
|
|
592
589
|
* This will reduce rendering quality though.
|
|
593
590
|
*
|
|
@@ -595,7 +592,7 @@ class Renderer {
|
|
|
595
592
|
* @type {number}
|
|
596
593
|
* @default HalfFloatType
|
|
597
594
|
*/
|
|
598
|
-
this.
|
|
595
|
+
this._outputBufferType = outputBufferType;
|
|
599
596
|
|
|
600
597
|
/**
|
|
601
598
|
* A cache for shadow nodes per material
|
|
@@ -699,7 +696,7 @@ class Renderer {
|
|
|
699
696
|
await this.compileAsync( scene, camera );
|
|
700
697
|
|
|
701
698
|
const renderList = this._renderLists.get( scene, camera );
|
|
702
|
-
const renderContext = this._renderContexts.get( scene, camera, this._renderTarget );
|
|
699
|
+
const renderContext = this._renderContexts.get( scene, camera, this._renderTarget, this._mrt );
|
|
703
700
|
|
|
704
701
|
const material = scene.overrideMaterial || object.material;
|
|
705
702
|
|
|
@@ -835,7 +832,7 @@ class Renderer {
|
|
|
835
832
|
* @param {Object3D} scene - The scene or 3D object to precompile.
|
|
836
833
|
* @param {Camera} camera - The camera that is used to render the scene.
|
|
837
834
|
* @param {?Scene} targetScene - If the first argument is a 3D object, this parameter must represent the scene the 3D object is going to be added.
|
|
838
|
-
* @return {Promise
|
|
835
|
+
* @return {Promise} A Promise that resolves when the compile has been finished.
|
|
839
836
|
*/
|
|
840
837
|
async compileAsync( scene, camera, targetScene = null ) {
|
|
841
838
|
|
|
@@ -859,7 +856,7 @@ class Renderer {
|
|
|
859
856
|
if ( targetScene === null ) targetScene = scene;
|
|
860
857
|
|
|
861
858
|
const renderTarget = this._renderTarget;
|
|
862
|
-
const renderContext = this._renderContexts.get( targetScene, camera, renderTarget );
|
|
859
|
+
const renderContext = this._renderContexts.get( targetScene, camera, renderTarget, this._mrt );
|
|
863
860
|
const activeMipmapLevel = this._activeMipmapLevel;
|
|
864
861
|
|
|
865
862
|
const compilationPromises = [];
|
|
@@ -996,11 +993,6 @@ class Renderer {
|
|
|
996
993
|
|
|
997
994
|
//
|
|
998
995
|
|
|
999
|
-
/**
|
|
1000
|
-
* Sets the inspector instance. The inspector can be any class that extends from `InspectorBase`.
|
|
1001
|
-
*
|
|
1002
|
-
* @param {InspectorBase} value - The new inspector.
|
|
1003
|
-
*/
|
|
1004
996
|
set inspector( value ) {
|
|
1005
997
|
|
|
1006
998
|
if ( this._inspector !== null ) {
|
|
@@ -1014,6 +1006,11 @@ class Renderer {
|
|
|
1014
1006
|
|
|
1015
1007
|
}
|
|
1016
1008
|
|
|
1009
|
+
/**
|
|
1010
|
+
* The inspector instance. The inspector can be any class that extends from `InspectorBase`.
|
|
1011
|
+
*
|
|
1012
|
+
* @type {InspectorBase}
|
|
1013
|
+
*/
|
|
1017
1014
|
get inspector() {
|
|
1018
1015
|
|
|
1019
1016
|
return this._inspector;
|
|
@@ -1031,15 +1028,17 @@ class Renderer {
|
|
|
1031
1028
|
*/
|
|
1032
1029
|
set highPrecision( value ) {
|
|
1033
1030
|
|
|
1031
|
+
const contextNodeData = this.contextNode.value;
|
|
1032
|
+
|
|
1034
1033
|
if ( value === true ) {
|
|
1035
1034
|
|
|
1036
|
-
|
|
1037
|
-
|
|
1035
|
+
contextNodeData.modelViewMatrix = highpModelViewMatrix;
|
|
1036
|
+
contextNodeData.modelNormalViewMatrix = highpModelNormalViewMatrix;
|
|
1038
1037
|
|
|
1039
1038
|
} else if ( this.highPrecision ) {
|
|
1040
1039
|
|
|
1041
|
-
|
|
1042
|
-
|
|
1040
|
+
delete contextNodeData.modelViewMatrix;
|
|
1041
|
+
delete contextNodeData.modelNormalViewMatrix;
|
|
1043
1042
|
|
|
1044
1043
|
}
|
|
1045
1044
|
|
|
@@ -1053,7 +1052,9 @@ class Renderer {
|
|
|
1053
1052
|
*/
|
|
1054
1053
|
get highPrecision() {
|
|
1055
1054
|
|
|
1056
|
-
|
|
1055
|
+
const contextNodeData = this.contextNode.value;
|
|
1056
|
+
|
|
1057
|
+
return contextNodeData.modelViewMatrix === highpModelViewMatrix && contextNodeData.modelNormalViewMatrix === highpModelNormalViewMatrix;
|
|
1057
1058
|
|
|
1058
1059
|
}
|
|
1059
1060
|
|
|
@@ -1083,13 +1084,27 @@ class Renderer {
|
|
|
1083
1084
|
}
|
|
1084
1085
|
|
|
1085
1086
|
/**
|
|
1086
|
-
* Returns the
|
|
1087
|
+
* Returns the output buffer type.
|
|
1088
|
+
*
|
|
1089
|
+
* @return {number} The output buffer type.
|
|
1090
|
+
*/
|
|
1091
|
+
getOutputBufferType() {
|
|
1092
|
+
|
|
1093
|
+
return this._outputBufferType;
|
|
1094
|
+
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* Returns the output buffer type.
|
|
1087
1099
|
*
|
|
1088
|
-
* @
|
|
1100
|
+
* @deprecated since r182. Use `.getOutputBufferType()` instead.
|
|
1101
|
+
* @return {number} The output buffer type.
|
|
1089
1102
|
*/
|
|
1090
|
-
getColorBufferType() {
|
|
1103
|
+
getColorBufferType() { // @deprecated, r182
|
|
1104
|
+
|
|
1105
|
+
warnOnce( 'Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".' );
|
|
1091
1106
|
|
|
1092
|
-
return this.
|
|
1107
|
+
return this.getOutputBufferType();
|
|
1093
1108
|
|
|
1094
1109
|
}
|
|
1095
1110
|
|
|
@@ -1265,7 +1280,7 @@ class Renderer {
|
|
|
1265
1280
|
frameBufferTarget = new RenderTarget( width, height, {
|
|
1266
1281
|
depthBuffer: depth,
|
|
1267
1282
|
stencilBuffer: stencil,
|
|
1268
|
-
type: this.
|
|
1283
|
+
type: this._outputBufferType,
|
|
1269
1284
|
format: RGBAFormat,
|
|
1270
1285
|
colorSpace: ColorManagement.workingColorSpace,
|
|
1271
1286
|
generateMipmaps: false,
|
|
@@ -1361,7 +1376,7 @@ class Renderer {
|
|
|
1361
1376
|
|
|
1362
1377
|
//
|
|
1363
1378
|
|
|
1364
|
-
const renderContext = this._renderContexts.get( scene, camera, renderTarget );
|
|
1379
|
+
const renderContext = this._renderContexts.get( scene, camera, renderTarget, this._mrt );
|
|
1365
1380
|
|
|
1366
1381
|
this._currentRenderContext = renderContext;
|
|
1367
1382
|
this._currentRenderObjectFunction = this._renderObjectFunction || this.renderObject;
|
|
@@ -1842,9 +1857,9 @@ class Renderer {
|
|
|
1842
1857
|
/**
|
|
1843
1858
|
* Defines the scissor rectangle.
|
|
1844
1859
|
*
|
|
1845
|
-
* @param {number | Vector4} x - The horizontal coordinate for the
|
|
1860
|
+
* @param {number | Vector4} x - The horizontal coordinate for the upper left corner of the box in logical pixel unit.
|
|
1846
1861
|
* Instead of passing four arguments, the method also works with a single four-dimensional vector.
|
|
1847
|
-
* @param {number} y - The vertical coordinate for the
|
|
1862
|
+
* @param {number} y - The vertical coordinate for the upper left corner of the box in logical pixel unit.
|
|
1848
1863
|
* @param {number} width - The width of the scissor box in logical pixel unit.
|
|
1849
1864
|
* @param {number} height - The height of the scissor box in logical pixel unit.
|
|
1850
1865
|
*/
|
|
@@ -1895,8 +1910,8 @@ class Renderer {
|
|
|
1895
1910
|
/**
|
|
1896
1911
|
* Defines the viewport.
|
|
1897
1912
|
*
|
|
1898
|
-
* @param {number | Vector4} x - The horizontal coordinate for the
|
|
1899
|
-
* @param {number} y - The vertical coordinate for the
|
|
1913
|
+
* @param {number | Vector4} x - The horizontal coordinate for the upper left corner of the viewport origin in logical pixel unit.
|
|
1914
|
+
* @param {number} y - The vertical coordinate for the upper left corner of the viewport origin in logical pixel unit.
|
|
1900
1915
|
* @param {number} width - The width of the viewport in logical pixel unit.
|
|
1901
1916
|
* @param {number} height - The height of the viewport in logical pixel unit.
|
|
1902
1917
|
* @param {number} minDepth - The minimum depth value of the viewport. WebGPU only.
|
|
@@ -2360,6 +2375,7 @@ class Renderer {
|
|
|
2360
2375
|
/**
|
|
2361
2376
|
* Resets the renderer to the initial state before WebXR started.
|
|
2362
2377
|
*
|
|
2378
|
+
* @private
|
|
2363
2379
|
*/
|
|
2364
2380
|
_resetXRState() {
|
|
2365
2381
|
|
|
@@ -2750,6 +2766,7 @@ class Renderer {
|
|
|
2750
2766
|
* Analyzes the given 3D object's hierarchy and builds render lists from the
|
|
2751
2767
|
* processed hierarchy.
|
|
2752
2768
|
*
|
|
2769
|
+
* @private
|
|
2753
2770
|
* @param {Object3D} object - The 3D object to process (usually a scene).
|
|
2754
2771
|
* @param {Camera} camera - The camera the object is rendered with.
|
|
2755
2772
|
* @param {number} groupOrder - The group order is derived from the `renderOrder` of groups and is used to group 3D objects within groups.
|
|
@@ -2975,6 +2992,7 @@ class Renderer {
|
|
|
2975
2992
|
* Retrieves shadow nodes for the given material. This is used to setup shadow passes.
|
|
2976
2993
|
* The result is cached per material and updated when the material's version changes.
|
|
2977
2994
|
*
|
|
2995
|
+
* @private
|
|
2978
2996
|
* @param {Material} material
|
|
2979
2997
|
* @returns {Object} - The shadow nodes for the material.
|
|
2980
2998
|
*/
|
|
@@ -325,7 +325,7 @@ class Textures extends DataMap {
|
|
|
325
325
|
|
|
326
326
|
//
|
|
327
327
|
|
|
328
|
-
if ( texture.isVideoTexture && ColorManagement.getTransfer( texture.colorSpace ) !== SRGBTransfer ) {
|
|
328
|
+
if ( texture.isVideoTexture && ColorManagement.enabled === true && ColorManagement.getTransfer( texture.colorSpace ) !== SRGBTransfer ) {
|
|
329
329
|
|
|
330
330
|
warn( 'WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace.' );
|
|
331
331
|
|
|
@@ -459,6 +459,7 @@ class PMREMGenerator {
|
|
|
459
459
|
( { lodMeshes: this._lodMeshes, sizeLods: this._sizeLods, sigmas: this._sigmas } = _createPlanes( _lodMax ) );
|
|
460
460
|
|
|
461
461
|
this._blurMaterial = _getBlurShader( _lodMax, renderTarget.width, renderTarget.height );
|
|
462
|
+
this._ggxMaterial = _getGGXShader( _lodMax, renderTarget.width, renderTarget.height );
|
|
462
463
|
|
|
463
464
|
}
|
|
464
465
|
|
|
@@ -650,13 +651,6 @@ class PMREMGenerator {
|
|
|
650
651
|
const renderer = this._renderer;
|
|
651
652
|
const pingPongRenderTarget = this._pingPongRenderTarget;
|
|
652
653
|
|
|
653
|
-
// Lazy create GGX material only when first used
|
|
654
|
-
if ( this._ggxMaterial === null ) {
|
|
655
|
-
|
|
656
|
-
this._ggxMaterial = _getGGXShader( this._lodMax, this._pingPongRenderTarget.width, this._pingPongRenderTarget.height );
|
|
657
|
-
|
|
658
|
-
}
|
|
659
|
-
|
|
660
654
|
const ggxMaterial = this._ggxMaterial;
|
|
661
655
|
const ggxMesh = this._lodMeshes[ lodOut ];
|
|
662
656
|
ggxMesh.material = ggxMaterial;
|
|
@@ -669,7 +663,7 @@ class PMREMGenerator {
|
|
|
669
663
|
const incrementalRoughness = Math.sqrt( targetRoughness * targetRoughness - sourceRoughness * sourceRoughness );
|
|
670
664
|
|
|
671
665
|
// Apply blur strength mapping for better quality across the roughness range
|
|
672
|
-
const blurStrength = 0.
|
|
666
|
+
const blurStrength = 0.0 + targetRoughness * 1.25;
|
|
673
667
|
const adjustedRoughness = incrementalRoughness * blurStrength;
|
|
674
668
|
|
|
675
669
|
// Calculate viewport position based on output LOD level
|
|
@@ -35,6 +35,58 @@ class NodeUniformBuffer extends UniformBuffer {
|
|
|
35
35
|
*/
|
|
36
36
|
this.groupNode = groupNode;
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* This flag can be used for type testing.
|
|
40
|
+
*
|
|
41
|
+
* @type {boolean}
|
|
42
|
+
* @readonly
|
|
43
|
+
* @default true
|
|
44
|
+
*/
|
|
45
|
+
this.isNodeUniformBuffer = true;
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The array of update ranges.
|
|
51
|
+
*
|
|
52
|
+
* @param {Array<{start: number, count: number}>} value - The update ranges.
|
|
53
|
+
*/
|
|
54
|
+
set updateRanges( value ) {
|
|
55
|
+
|
|
56
|
+
this.nodeUniform.updateRanges = value;
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The array of update ranges.
|
|
62
|
+
*
|
|
63
|
+
* @type {Array<{start: number, count: number}>}
|
|
64
|
+
*/
|
|
65
|
+
get updateRanges() {
|
|
66
|
+
|
|
67
|
+
return this.nodeUniform.updateRanges;
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Adds a range of data in the data array to be updated on the GPU.
|
|
73
|
+
*
|
|
74
|
+
* @param {number} start - Position at which to start update.
|
|
75
|
+
* @param {number} count - The number of components to update.
|
|
76
|
+
*/
|
|
77
|
+
addUpdateRange( start, count ) {
|
|
78
|
+
|
|
79
|
+
this.nodeUniform.addUpdateRange( start, count );
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Clears all update ranges.
|
|
85
|
+
*/
|
|
86
|
+
clearUpdateRanges() {
|
|
87
|
+
|
|
88
|
+
this.nodeUniform.clearUpdateRanges();
|
|
89
|
+
|
|
38
90
|
}
|
|
39
91
|
|
|
40
92
|
/**
|