super-three 0.177.0 → 0.179.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 +959 -231
- package/build/three.core.js +751 -170
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +210 -64
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +78 -29
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +3269 -1545
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +3093 -1545
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +1 -2
- package/examples/jsm/capabilities/WebGL.js +0 -27
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +1 -1
- package/examples/jsm/controls/TransformControls.js +61 -14
- package/examples/jsm/csm/CSMShadowNode.js +4 -4
- package/examples/jsm/environments/RoomEnvironment.js +8 -3
- 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/meshopt_decoder.module.js +75 -58
- package/examples/jsm/lights/LightProbeGenerator.js +14 -3
- package/examples/jsm/loaders/ColladaLoader.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +210 -22
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- package/examples/jsm/loaders/MaterialXLoader.js +212 -30
- 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/usd/USDAParser.js +741 -0
- package/examples/jsm/loaders/usd/USDCParser.js +17 -0
- package/examples/jsm/objects/LensflareMesh.js +3 -3
- package/examples/jsm/objects/SkyMesh.js +2 -2
- package/examples/jsm/physics/RapierPhysics.js +95 -16
- 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/shaders/UnpackDepthRGBAShader.js +11 -2
- package/examples/jsm/transpiler/AST.js +381 -30
- package/examples/jsm/transpiler/GLSLDecoder.js +226 -86
- package/examples/jsm/transpiler/Linker.js +327 -0
- package/examples/jsm/transpiler/TSLEncoder.js +197 -92
- package/examples/jsm/transpiler/Transpiler.js +17 -1
- package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/examples/jsm/transpiler/WGSLEncoder.js +788 -0
- package/examples/jsm/tsl/display/BloomNode.js +8 -7
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +206 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +8 -10
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
- package/examples/jsm/tsl/display/hashBlur.js +3 -3
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
- package/package.json +1 -1
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +77 -28
- package/src/Three.WebGPU.js +2 -0
- 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 +3 -3
- package/src/core/BufferAttribute.js +3 -3
- package/src/core/Clock.js +2 -8
- package/src/core/GLBufferAttribute.js +13 -1
- package/src/core/Object3D.js +1 -1
- package/{examples/jsm/misc → src/core}/Timer.js +4 -42
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/extras/core/Path.js +22 -22
- 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/loaders/FileLoader.js +27 -4
- package/src/loaders/ImageBitmapLoader.js +27 -4
- package/src/loaders/ImageLoader.js +55 -8
- package/src/loaders/Loader.js +14 -0
- package/src/loaders/LoadingManager.js +23 -0
- package/src/materials/MeshBasicMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +0 -8
- package/src/materials/nodes/MeshBasicNodeMaterial.js +4 -3
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +1 -1
- package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -1
- package/src/materials/nodes/MeshSSSNodeMaterial.js +2 -2
- package/src/materials/nodes/NodeMaterial.js +28 -5
- package/src/materials/nodes/PointsNodeMaterial.js +5 -0
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
- package/src/math/Frustum.js +25 -9
- package/src/math/FrustumArray.js +10 -5
- package/src/math/Line3.js +129 -2
- package/src/math/Matrix4.js +48 -27
- package/src/math/Quaternion.js +1 -1
- package/src/math/Spherical.js +2 -2
- package/src/nodes/Nodes.js +2 -3
- package/src/nodes/TSL.js +5 -3
- package/src/nodes/accessors/AccessorsUtils.js +7 -8
- package/src/nodes/accessors/Bitangent.js +31 -25
- package/src/nodes/accessors/Camera.js +12 -12
- package/src/nodes/accessors/Normal.js +95 -29
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/Position.js +7 -7
- package/src/nodes/accessors/ReferenceNode.js +18 -3
- package/src/nodes/accessors/ReflectVector.js +3 -3
- package/src/nodes/accessors/SceneNode.js +1 -1
- package/src/nodes/accessors/StorageTextureNode.js +1 -1
- package/src/nodes/accessors/Tangent.js +25 -17
- package/src/nodes/accessors/TangentUtils.js +46 -0
- package/src/nodes/accessors/TextureBicubic.js +21 -3
- package/src/nodes/accessors/TextureNode.js +12 -0
- package/src/nodes/accessors/UniformArrayNode.js +0 -16
- package/src/nodes/core/ArrayNode.js +12 -0
- package/src/nodes/core/AssignNode.js +3 -0
- package/src/nodes/core/CacheNode.js +0 -14
- package/src/nodes/core/ContextNode.js +20 -1
- package/src/nodes/core/Node.js +15 -3
- package/src/nodes/core/NodeBuilder.js +228 -92
- package/src/nodes/core/NodeUtils.js +4 -1
- package/src/nodes/core/StackNode.js +49 -29
- package/src/nodes/core/SubBuildNode.js +89 -0
- package/src/nodes/core/UniformNode.js +63 -5
- package/src/nodes/core/VarNode.js +91 -2
- package/src/nodes/core/VaryingNode.js +6 -4
- package/src/nodes/display/BlendModes.js +2 -2
- package/src/nodes/display/FrontFacingNode.js +34 -2
- package/src/nodes/display/NormalMapNode.js +19 -50
- package/src/nodes/display/PassNode.js +157 -9
- package/src/nodes/display/ScreenNode.js +0 -26
- package/src/nodes/display/ViewportTextureNode.js +67 -7
- package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
- package/src/nodes/functions/PhongLightingModel.js +3 -3
- package/src/nodes/functions/PhysicalLightingModel.js +16 -16
- package/src/nodes/functions/material/getGeometryRoughness.js +2 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +67 -23
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
- package/src/nodes/lighting/EnvironmentNode.js +5 -5
- package/src/nodes/lighting/LightsNode.js +4 -4
- package/src/nodes/lighting/ProjectorLightNode.js +19 -6
- package/src/nodes/lighting/ShadowFilterNode.js +1 -1
- package/src/nodes/lighting/ShadowNode.js +2 -2
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +165 -1
- package/src/nodes/math/ConditionalNode.js +1 -20
- package/src/nodes/math/MathNode.js +90 -55
- package/src/nodes/math/OperatorNode.js +22 -39
- package/src/nodes/tsl/TSLBase.js +1 -0
- package/src/nodes/tsl/TSLCore.js +114 -55
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EquirectUV.js +27 -0
- package/src/nodes/utils/EventNode.js +83 -0
- package/src/nodes/utils/LoopNode.js +0 -17
- package/src/nodes/utils/MatcapUV.js +22 -0
- package/src/nodes/utils/RTTNode.js +22 -5
- package/src/nodes/utils/ReflectorNode.js +11 -4
- package/src/nodes/utils/SampleNode.js +81 -0
- package/src/nodes/utils/TriplanarTextures.js +65 -0
- package/src/objects/BatchedMesh.js +4 -2
- package/src/renderers/WebGLRenderer.js +26 -24
- package/src/renderers/common/Background.js +2 -2
- package/src/renderers/common/Bindings.js +19 -18
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/CubeRenderTarget.js +1 -1
- package/src/renderers/common/PostProcessing.js +60 -5
- package/src/renderers/common/RenderObject.js +68 -3
- package/src/renderers/common/Renderer.js +19 -16
- package/src/renderers/common/SampledTexture.js +3 -71
- package/src/renderers/common/Sampler.js +79 -0
- package/src/renderers/common/Storage3DTexture.js +100 -0
- package/src/renderers/common/StorageArrayTexture.js +84 -0
- package/src/renderers/common/StorageTexture.js +19 -0
- package/src/renderers/common/Textures.js +19 -3
- package/src/renderers/common/XRManager.js +31 -12
- package/src/renderers/common/XRRenderTarget.js +21 -4
- package/src/renderers/common/extras/PMREMGenerator.js +1 -1
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +20 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
- package/src/renderers/webgl/WebGLAttributes.js +4 -0
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLProgram.js +12 -6
- package/src/renderers/webgl/WebGLPrograms.js +6 -4
- package/src/renderers/webgl/WebGLShadowMap.js +11 -1
- package/src/renderers/webgl/WebGLState.js +4 -4
- package/src/renderers/webgl/WebGLTextures.js +19 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +103 -72
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +3 -5
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +4 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +4 -4
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +2 -0
- package/src/renderers/webgpu/WebGPUBackend.js +63 -16
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +64 -79
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -0
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -31
- package/src/renderers/webgpu/utils/WebGPUConstants.js +7 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +5 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +12 -65
- package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +68 -6
- package/src/textures/ExternalTexture.js +45 -0
- package/src/textures/FramebufferTexture.js +2 -2
- package/src/textures/Source.js +11 -1
- package/src/textures/VideoTexture.js +30 -2
- package/src/nodes/utils/EquirectUVNode.js +0 -65
- package/src/nodes/utils/MatcapUVNode.js +0 -49
- package/src/nodes/utils/TriplanarTexturesNode.js +0 -148
|
@@ -171,6 +171,16 @@ class RenderObject {
|
|
|
171
171
|
*/
|
|
172
172
|
this.attributes = null;
|
|
173
173
|
|
|
174
|
+
/**
|
|
175
|
+
* An object holding the version of the
|
|
176
|
+
* attributes. The keys are the attribute names
|
|
177
|
+
* and the values are the attribute versions.
|
|
178
|
+
*
|
|
179
|
+
* @type {?Object<string, number>}
|
|
180
|
+
* @default null
|
|
181
|
+
*/
|
|
182
|
+
this.attributesId = null;
|
|
183
|
+
|
|
174
184
|
/**
|
|
175
185
|
* A reference to a render pipeline the render
|
|
176
186
|
* object is processed with.
|
|
@@ -290,7 +300,7 @@ class RenderObject {
|
|
|
290
300
|
|
|
291
301
|
/**
|
|
292
302
|
* An event listener which is executed when `dispose()` is called on
|
|
293
|
-
* the render object
|
|
303
|
+
* the material of this render object.
|
|
294
304
|
*
|
|
295
305
|
* @method
|
|
296
306
|
*/
|
|
@@ -300,7 +310,23 @@ class RenderObject {
|
|
|
300
310
|
|
|
301
311
|
};
|
|
302
312
|
|
|
313
|
+
/**
|
|
314
|
+
* An event listener which is executed when `dispose()` is called on
|
|
315
|
+
* the geometry of this render object.
|
|
316
|
+
*
|
|
317
|
+
* @method
|
|
318
|
+
*/
|
|
319
|
+
this.onGeometryDispose = () => {
|
|
320
|
+
|
|
321
|
+
// clear geometry cache attributes
|
|
322
|
+
|
|
323
|
+
this.attributes = null;
|
|
324
|
+
this.attributesId = null;
|
|
325
|
+
|
|
326
|
+
};
|
|
327
|
+
|
|
303
328
|
this.material.addEventListener( 'dispose', this.onMaterialDispose );
|
|
329
|
+
this.geometry.addEventListener( 'dispose', this.onGeometryDispose );
|
|
304
330
|
|
|
305
331
|
}
|
|
306
332
|
|
|
@@ -439,6 +465,7 @@ class RenderObject {
|
|
|
439
465
|
|
|
440
466
|
this.geometry = geometry;
|
|
441
467
|
this.attributes = null;
|
|
468
|
+
this.attributesId = null;
|
|
442
469
|
|
|
443
470
|
}
|
|
444
471
|
|
|
@@ -458,9 +485,25 @@ class RenderObject {
|
|
|
458
485
|
const attributes = [];
|
|
459
486
|
const vertexBuffers = new Set();
|
|
460
487
|
|
|
488
|
+
const attributesId = {};
|
|
489
|
+
|
|
461
490
|
for ( const nodeAttribute of nodeAttributes ) {
|
|
462
491
|
|
|
463
|
-
|
|
492
|
+
let attribute;
|
|
493
|
+
|
|
494
|
+
if ( nodeAttribute.node && nodeAttribute.node.attribute ) {
|
|
495
|
+
|
|
496
|
+
// node attribute
|
|
497
|
+
attribute = nodeAttribute.node.attribute;
|
|
498
|
+
|
|
499
|
+
} else {
|
|
500
|
+
|
|
501
|
+
// geometry attribute
|
|
502
|
+
attribute = geometry.getAttribute( nodeAttribute.name );
|
|
503
|
+
|
|
504
|
+
attributesId[ nodeAttribute.name ] = attribute.version;
|
|
505
|
+
|
|
506
|
+
}
|
|
464
507
|
|
|
465
508
|
if ( attribute === undefined ) continue;
|
|
466
509
|
|
|
@@ -472,6 +515,7 @@ class RenderObject {
|
|
|
472
515
|
}
|
|
473
516
|
|
|
474
517
|
this.attributes = attributes;
|
|
518
|
+
this.attributesId = attributesId;
|
|
475
519
|
this.vertexBuffers = Array.from( vertexBuffers.values() );
|
|
476
520
|
|
|
477
521
|
return attributes;
|
|
@@ -736,7 +780,27 @@ class RenderObject {
|
|
|
736
780
|
*/
|
|
737
781
|
get needsGeometryUpdate() {
|
|
738
782
|
|
|
739
|
-
|
|
783
|
+
if ( this.geometry.id !== this.object.geometry.id ) return true;
|
|
784
|
+
|
|
785
|
+
if ( this.attributes !== null ) {
|
|
786
|
+
|
|
787
|
+
const attributesId = this.attributesId;
|
|
788
|
+
|
|
789
|
+
for ( const name in attributesId ) {
|
|
790
|
+
|
|
791
|
+
const attribute = this.geometry.getAttribute( name );
|
|
792
|
+
|
|
793
|
+
if ( attribute === undefined || attributesId[ name ] !== attribute.id ) {
|
|
794
|
+
|
|
795
|
+
return true;
|
|
796
|
+
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
return false;
|
|
740
804
|
|
|
741
805
|
}
|
|
742
806
|
|
|
@@ -814,6 +878,7 @@ class RenderObject {
|
|
|
814
878
|
dispose() {
|
|
815
879
|
|
|
816
880
|
this.material.removeEventListener( 'dispose', this.onMaterialDispose );
|
|
881
|
+
this.geometry.removeEventListener( 'dispose', this.onGeometryDispose );
|
|
817
882
|
|
|
818
883
|
this.onDispose();
|
|
819
884
|
|
|
@@ -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,
|
|
@@ -1260,7 +1261,7 @@ class Renderer {
|
|
|
1260
1261
|
frameBufferTarget.scissorTest = this._scissorTest;
|
|
1261
1262
|
frameBufferTarget.multiview = outputRenderTarget !== null ? outputRenderTarget.multiview : false;
|
|
1262
1263
|
frameBufferTarget.resolveDepthBuffer = outputRenderTarget !== null ? outputRenderTarget.resolveDepthBuffer : true;
|
|
1263
|
-
frameBufferTarget.
|
|
1264
|
+
frameBufferTarget._autoAllocateDepthBuffer = outputRenderTarget !== null ? outputRenderTarget._autoAllocateDepthBuffer : false;
|
|
1264
1265
|
|
|
1265
1266
|
return frameBufferTarget;
|
|
1266
1267
|
|
|
@@ -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
|
|
|
@@ -2130,8 +2131,8 @@ class Renderer {
|
|
|
2130
2131
|
}
|
|
2131
2132
|
|
|
2132
2133
|
/**
|
|
2133
|
-
* The current
|
|
2134
|
-
* the
|
|
2134
|
+
* The current tone mapping of the renderer. When not producing screen output,
|
|
2135
|
+
* the tone mapping is always `NoToneMapping`.
|
|
2135
2136
|
*
|
|
2136
2137
|
* @type {number}
|
|
2137
2138
|
*/
|
|
@@ -2142,14 +2143,14 @@ class Renderer {
|
|
|
2142
2143
|
}
|
|
2143
2144
|
|
|
2144
2145
|
/**
|
|
2145
|
-
* The current
|
|
2146
|
-
* the
|
|
2146
|
+
* The current color space of the renderer. When not producing screen output,
|
|
2147
|
+
* the color space is always the working color space.
|
|
2147
2148
|
*
|
|
2148
2149
|
* @type {string}
|
|
2149
2150
|
*/
|
|
2150
2151
|
get currentColorSpace() {
|
|
2151
2152
|
|
|
2152
|
-
return this.isOutputTarget ? this.outputColorSpace :
|
|
2153
|
+
return this.isOutputTarget ? this.outputColorSpace : ColorManagement.workingColorSpace;
|
|
2153
2154
|
|
|
2154
2155
|
}
|
|
2155
2156
|
|
|
@@ -2308,9 +2309,10 @@ class Renderer {
|
|
|
2308
2309
|
* if the renderer has been initialized.
|
|
2309
2310
|
*
|
|
2310
2311
|
* @param {Node|Array<Node>} computeNodes - The compute node(s).
|
|
2312
|
+
* @param {Array<number>|number} [dispatchSizeOrCount=null] - Array with [ x, y, z ] values for dispatch or a single number for the count.
|
|
2311
2313
|
* @return {Promise|undefined} A Promise that resolve when the compute has finished. Only returned when the renderer has not been initialized.
|
|
2312
2314
|
*/
|
|
2313
|
-
compute( computeNodes ) {
|
|
2315
|
+
compute( computeNodes, dispatchSizeOrCount = null ) {
|
|
2314
2316
|
|
|
2315
2317
|
if ( this._isDeviceLost === true ) return;
|
|
2316
2318
|
|
|
@@ -2389,7 +2391,7 @@ class Renderer {
|
|
|
2389
2391
|
const computeBindings = bindings.getForCompute( computeNode );
|
|
2390
2392
|
const computePipeline = pipelines.getForCompute( computeNode, computeBindings );
|
|
2391
2393
|
|
|
2392
|
-
backend.compute( computeNodes, computeNode, computeBindings, computePipeline );
|
|
2394
|
+
backend.compute( computeNodes, computeNode, computeBindings, computePipeline, dispatchSizeOrCount );
|
|
2393
2395
|
|
|
2394
2396
|
}
|
|
2395
2397
|
|
|
@@ -2406,13 +2408,14 @@ class Renderer {
|
|
|
2406
2408
|
*
|
|
2407
2409
|
* @async
|
|
2408
2410
|
* @param {Node|Array<Node>} computeNodes - The compute node(s).
|
|
2411
|
+
* @param {Array<number>|number} [dispatchSizeOrCount=null] - Array with [ x, y, z ] values for dispatch or a single number for the count.
|
|
2409
2412
|
* @return {Promise} A Promise that resolve when the compute has finished.
|
|
2410
2413
|
*/
|
|
2411
|
-
async computeAsync( computeNodes ) {
|
|
2414
|
+
async computeAsync( computeNodes, dispatchSizeOrCount = null ) {
|
|
2412
2415
|
|
|
2413
2416
|
if ( this._initialized === false ) await this.init();
|
|
2414
2417
|
|
|
2415
|
-
this.compute( computeNodes );
|
|
2418
|
+
this.compute( computeNodes, dispatchSizeOrCount );
|
|
2416
2419
|
|
|
2417
2420
|
}
|
|
2418
2421
|
|
|
@@ -2961,7 +2964,7 @@ class Renderer {
|
|
|
2961
2964
|
* @param {LightsNode} lightsNode - The current lights node.
|
|
2962
2965
|
* @param {?{start: number, count: number}} group - Only relevant for objects using multiple materials. This represents a group entry from the respective `BufferGeometry`.
|
|
2963
2966
|
* @param {ClippingContext} clippingContext - The clipping context.
|
|
2964
|
-
* @param {
|
|
2967
|
+
* @param {string} [passId] - An optional ID for identifying the pass.
|
|
2965
2968
|
*/
|
|
2966
2969
|
_renderObjectDirect( object, material, scene, camera, lightsNode, group, clippingContext, passId ) {
|
|
2967
2970
|
|
|
@@ -3016,7 +3019,7 @@ class Renderer {
|
|
|
3016
3019
|
* @param {LightsNode} lightsNode - The current lights node.
|
|
3017
3020
|
* @param {?{start: number, count: number}} group - Only relevant for objects using multiple materials. This represents a group entry from the respective `BufferGeometry`.
|
|
3018
3021
|
* @param {ClippingContext} clippingContext - The clipping context.
|
|
3019
|
-
* @param {
|
|
3022
|
+
* @param {string} [passId] - An optional ID for identifying the pass.
|
|
3020
3023
|
*/
|
|
3021
3024
|
_createObjectPipeline( object, material, scene, camera, lightsNode, group, clippingContext, passId ) {
|
|
3022
3025
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Sampler from './Sampler.js';
|
|
2
2
|
|
|
3
3
|
let _id = 0;
|
|
4
4
|
|
|
@@ -8,7 +8,7 @@ let _id = 0;
|
|
|
8
8
|
* @private
|
|
9
9
|
* @augments Binding
|
|
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
|
/**
|
|
@@ -18,6 +18,17 @@ class Sampler extends Binding {
|
|
|
18
18
|
|
|
19
19
|
super( name );
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* This function is called when the texture is disposed.
|
|
23
|
+
* @type {function}
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
this._onDisposeTexture = () => {
|
|
27
|
+
|
|
28
|
+
this.texture = null;
|
|
29
|
+
|
|
30
|
+
};
|
|
31
|
+
|
|
21
32
|
/**
|
|
22
33
|
* The texture the sampler is referring to.
|
|
23
34
|
*
|
|
@@ -32,6 +43,15 @@ class Sampler extends Binding {
|
|
|
32
43
|
*/
|
|
33
44
|
this.version = texture ? texture.version : 0;
|
|
34
45
|
|
|
46
|
+
/**
|
|
47
|
+
* The binding's generation which is an additional version
|
|
48
|
+
* qualifier.
|
|
49
|
+
*
|
|
50
|
+
* @type {?number}
|
|
51
|
+
* @default null
|
|
52
|
+
*/
|
|
53
|
+
this.generation = null;
|
|
54
|
+
|
|
35
55
|
/**
|
|
36
56
|
* This flag can be used for type testing.
|
|
37
57
|
*
|
|
@@ -43,6 +63,65 @@ class Sampler extends Binding {
|
|
|
43
63
|
|
|
44
64
|
}
|
|
45
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Sets the texture of this sampler.
|
|
68
|
+
* @param {?Texture} value - The texture to set.
|
|
69
|
+
*/
|
|
70
|
+
set texture( value ) {
|
|
71
|
+
|
|
72
|
+
if ( this._texture === value ) return;
|
|
73
|
+
|
|
74
|
+
if ( this._texture ) {
|
|
75
|
+
|
|
76
|
+
this._texture.removeEventListener( 'dispose', this._onDisposeTexture );
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
this._texture = value;
|
|
81
|
+
|
|
82
|
+
this.generation = null;
|
|
83
|
+
this.version = 0;
|
|
84
|
+
|
|
85
|
+
if ( this._texture ) {
|
|
86
|
+
|
|
87
|
+
this._texture.addEventListener( 'dispose', this._onDisposeTexture );
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Gets the texture of this sampler.
|
|
95
|
+
* @return {?Texture} The texture.
|
|
96
|
+
*/
|
|
97
|
+
get texture() {
|
|
98
|
+
|
|
99
|
+
return this._texture;
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Updates the binding.
|
|
105
|
+
*
|
|
106
|
+
* @return {boolean} Whether the texture has been updated and must be
|
|
107
|
+
* uploaded to the GPU.
|
|
108
|
+
*/
|
|
109
|
+
update() {
|
|
110
|
+
|
|
111
|
+
const { texture, version } = this;
|
|
112
|
+
|
|
113
|
+
if ( version !== texture.version ) {
|
|
114
|
+
|
|
115
|
+
this.version = texture.version;
|
|
116
|
+
|
|
117
|
+
return true;
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return false;
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
|
|
46
125
|
}
|
|
47
126
|
|
|
48
127
|
export default Sampler;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Texture } from '../../textures/Texture.js';
|
|
2
|
+
import { LinearFilter, ClampToEdgeWrapping } from '../../constants.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This special type of texture is intended for compute shaders.
|
|
6
|
+
* It can be used to compute the data of a texture with a compute shader.
|
|
7
|
+
*
|
|
8
|
+
* Note: This type of texture can only be used with `WebGPURenderer`
|
|
9
|
+
* and a WebGPU backend.
|
|
10
|
+
*
|
|
11
|
+
* @augments Texture
|
|
12
|
+
*/
|
|
13
|
+
class Storage3DTexture extends Texture {
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Constructs a new storage texture.
|
|
17
|
+
*
|
|
18
|
+
* @param {number} [width=1] - The storage texture's width.
|
|
19
|
+
* @param {number} [height=1] - The storage texture's height.
|
|
20
|
+
* @param {number} [depth=1] - The storage texture's depth.
|
|
21
|
+
*/
|
|
22
|
+
constructor( width = 1, height = 1, depth = 1 ) {
|
|
23
|
+
|
|
24
|
+
super();
|
|
25
|
+
|
|
26
|
+
//inherited from texture. Must be false for 3DTexture
|
|
27
|
+
this.isArrayTexture = false;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The image object which just represents the texture's dimension.
|
|
31
|
+
*
|
|
32
|
+
* @type {{width: number, height: number, depth: number}}
|
|
33
|
+
*/
|
|
34
|
+
this.image = { width, height, depth };
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The default `magFilter` for storage textures is `THREE.LinearFilter`.
|
|
38
|
+
*
|
|
39
|
+
* @type {number}
|
|
40
|
+
*/
|
|
41
|
+
this.magFilter = LinearFilter;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The default `minFilter` for storage textures is `THREE.LinearFilter`.
|
|
45
|
+
*
|
|
46
|
+
* @type {number}
|
|
47
|
+
*/
|
|
48
|
+
this.minFilter = LinearFilter;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* This defines how the texture is wrapped in the depth direction and corresponds to
|
|
52
|
+
* *W* in UVW mapping.
|
|
53
|
+
*
|
|
54
|
+
* @type {number}
|
|
55
|
+
*/
|
|
56
|
+
this.wrapR = ClampToEdgeWrapping;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* This flag can be used for type testing.
|
|
60
|
+
*
|
|
61
|
+
* @type {boolean}
|
|
62
|
+
* @readonly
|
|
63
|
+
* @default true
|
|
64
|
+
*/
|
|
65
|
+
this.isStorageTexture = true;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Indicates whether this texture is a 3D texture.
|
|
69
|
+
*
|
|
70
|
+
* @type {boolean}
|
|
71
|
+
*
|
|
72
|
+
*/
|
|
73
|
+
this.is3DTexture = true;
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Sets the size of the storage 3d texture.
|
|
79
|
+
*
|
|
80
|
+
* @param {number} width - The new width of the storage texture.
|
|
81
|
+
* @param {number} height - The new height of the storage texture.
|
|
82
|
+
* @param {number} depth - The new depth of the storage texture.
|
|
83
|
+
*/
|
|
84
|
+
setSize( width, height, depth ) {
|
|
85
|
+
|
|
86
|
+
if ( this.image.width !== width || this.image.height !== height || this.image.depth !== depth ) {
|
|
87
|
+
|
|
88
|
+
this.image.width = width;
|
|
89
|
+
this.image.height = height;
|
|
90
|
+
this.image.depth = depth;
|
|
91
|
+
|
|
92
|
+
this.dispose();
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export default Storage3DTexture;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Texture } from '../../textures/Texture.js';
|
|
2
|
+
import { LinearFilter } from '../../constants.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This special type of texture is intended for compute shaders.
|
|
6
|
+
* It can be used to compute the data of a texture with a compute shader.
|
|
7
|
+
*
|
|
8
|
+
* Note: This type of texture can only be used with `WebGPURenderer`
|
|
9
|
+
* and a WebGPU backend.
|
|
10
|
+
*
|
|
11
|
+
* @augments Texture
|
|
12
|
+
*/
|
|
13
|
+
class StorageArrayTexture extends Texture {
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Constructs a new storage texture.
|
|
17
|
+
*
|
|
18
|
+
* @param {number} [width=1] - The storage texture's width.
|
|
19
|
+
* @param {number} [height=1] - The storage texture's height.
|
|
20
|
+
* @param {number} [depth=1] - The storage texture's depth.
|
|
21
|
+
*/
|
|
22
|
+
constructor( width = 1, height = 1, depth = 1 ) {
|
|
23
|
+
|
|
24
|
+
super();
|
|
25
|
+
|
|
26
|
+
//inherited from texture
|
|
27
|
+
this.isArrayTexture = true;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The image object which just represents the texture's dimension.
|
|
31
|
+
*
|
|
32
|
+
* @type {{width: number, height: number, depth: number}}
|
|
33
|
+
*/
|
|
34
|
+
this.image = { width, height, depth };
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The default `magFilter` for storage textures is `THREE.LinearFilter`.
|
|
38
|
+
*
|
|
39
|
+
* @type {number}
|
|
40
|
+
*/
|
|
41
|
+
this.magFilter = LinearFilter;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The default `minFilter` for storage textures is `THREE.LinearFilter`.
|
|
45
|
+
*
|
|
46
|
+
* @type {number}
|
|
47
|
+
*/
|
|
48
|
+
this.minFilter = LinearFilter;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* This flag can be used for type testing.
|
|
52
|
+
*
|
|
53
|
+
* @type {boolean}
|
|
54
|
+
* @readonly
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
this.isStorageTexture = true;
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Sets the size of the storage array texture.
|
|
63
|
+
*
|
|
64
|
+
* @param {number} width - The new width of the storage texture.
|
|
65
|
+
* @param {number} height - The new height of the storage texture.
|
|
66
|
+
* @param {number} depth - The new depth of the storage texture.
|
|
67
|
+
*/
|
|
68
|
+
setSize( width, height, depth ) {
|
|
69
|
+
|
|
70
|
+
if ( this.image.width !== width || this.image.height !== height || this.image.depth !== depth ) {
|
|
71
|
+
|
|
72
|
+
this.image.width = width;
|
|
73
|
+
this.image.height = height;
|
|
74
|
+
this.image.depth = depth;
|
|
75
|
+
|
|
76
|
+
this.dispose();
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default StorageArrayTexture;
|
|
@@ -54,6 +54,25 @@ class StorageTexture extends Texture {
|
|
|
54
54
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Sets the size of the storage texture.
|
|
59
|
+
*
|
|
60
|
+
* @param {number} width - The new width of the storage texture.
|
|
61
|
+
* @param {number} height - The new height of the storage texture.
|
|
62
|
+
*/
|
|
63
|
+
setSize( width, height ) {
|
|
64
|
+
|
|
65
|
+
if ( this.image.width !== width || this.image.height !== height ) {
|
|
66
|
+
|
|
67
|
+
this.image.width = width;
|
|
68
|
+
this.image.height = height;
|
|
69
|
+
|
|
70
|
+
this.dispose();
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
57
76
|
}
|
|
58
77
|
|
|
59
78
|
export default StorageTexture;
|
|
@@ -366,9 +366,25 @@ class Textures extends DataMap {
|
|
|
366
366
|
|
|
367
367
|
if ( image.image !== undefined ) image = image.image;
|
|
368
368
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
369
|
+
if ( image instanceof HTMLVideoElement ) {
|
|
370
|
+
|
|
371
|
+
target.width = image.videoWidth || 1;
|
|
372
|
+
target.height = image.videoHeight || 1;
|
|
373
|
+
target.depth = 1;
|
|
374
|
+
|
|
375
|
+
} else if ( image instanceof VideoFrame ) {
|
|
376
|
+
|
|
377
|
+
target.width = image.displayWidth || 1;
|
|
378
|
+
target.height = image.displayHeight || 1;
|
|
379
|
+
target.depth = 1;
|
|
380
|
+
|
|
381
|
+
} else {
|
|
382
|
+
|
|
383
|
+
target.width = image.width || 1;
|
|
384
|
+
target.height = image.height || 1;
|
|
385
|
+
target.depth = texture.isCubeTexture ? 6 : ( image.depth || 1 );
|
|
386
|
+
|
|
387
|
+
}
|
|
372
388
|
|
|
373
389
|
} else {
|
|
374
390
|
|