super-three 0.168.0 → 0.169.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +384 -700
- package/build/three.module.js +384 -700
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +24644 -22406
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +79941 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/jsm/Addons.js +0 -6
- package/examples/jsm/controls/TrackballControls.js +32 -12
- package/examples/jsm/controls/TransformControls.js +97 -62
- package/examples/jsm/exporters/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- package/examples/jsm/exporters/KTX2Exporter.js +21 -13
- package/examples/jsm/exporters/OBJExporter.js +5 -1
- package/examples/jsm/exporters/PLYExporter.js +9 -7
- package/examples/jsm/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +1 -1
- package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
- package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/LightProbeGenerator.js +24 -10
- package/examples/jsm/loaders/ColladaLoader.js +9 -6
- package/examples/jsm/loaders/DRACOLoader.js +3 -1
- package/examples/jsm/loaders/FBXLoader.js +30 -20
- package/examples/jsm/loaders/GLTFLoader.js +5 -10
- package/examples/jsm/loaders/KTX2Loader.js +10 -7
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +29 -10
- package/examples/jsm/loaders/OBJLoader.js +5 -3
- package/examples/jsm/loaders/PCDLoader.js +5 -4
- package/examples/jsm/loaders/PDBLoader.js +3 -2
- package/examples/jsm/loaders/PLYLoader.js +8 -5
- package/examples/jsm/loaders/STLLoader.js +3 -2
- package/examples/jsm/loaders/VRMLLoader.js +10 -10
- package/examples/jsm/loaders/VTKLoader.js +4 -3
- package/examples/jsm/loaders/XYZLoader.js +3 -2
- package/examples/jsm/misc/Timer.js +1 -1
- package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
- package/examples/jsm/objects/LensflareMesh.js +322 -0
- package/examples/jsm/objects/SkyMesh.js +1 -2
- package/examples/jsm/objects/Water2Mesh.js +2 -3
- package/examples/jsm/objects/WaterMesh.js +1 -2
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/physics/RapierPhysics.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
- package/examples/jsm/utils/ShadowMapViewer.js +3 -8
- package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
- package/examples/jsm/utils/SkeletonUtils.js +84 -66
- package/examples/jsm/utils/TextureUtils.js +1 -0
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/package.json +2 -2
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +2 -1
- package/src/audio/Audio.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +0 -9
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +0 -9
- package/src/extras/Controls.js +1 -1
- package/src/geometries/CylinderGeometry.js +11 -4
- package/src/loaders/MaterialLoader.js +7 -1
- package/src/loaders/nodes/NodeLoader.js +24 -4
- package/src/loaders/nodes/NodeMaterialLoader.js +21 -17
- package/src/loaders/nodes/NodeObjectLoader.js +19 -0
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +19 -34
- package/src/materials/nodes/Line2NodeMaterial.js +26 -26
- package/src/materials/nodes/LineBasicNodeMaterial.js +7 -3
- package/src/materials/nodes/LineDashedNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshBasicNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshLambertNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshNormalNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshPhongNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +6 -3
- package/src/materials/nodes/MeshSSSNodeMaterial.js +6 -3
- package/src/materials/nodes/MeshStandardNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshToonNodeMaterial.js +7 -3
- package/src/materials/nodes/NodeMaterial.js +20 -45
- package/src/materials/nodes/NodeMaterials.js +2 -0
- package/src/materials/nodes/PointsNodeMaterial.js +7 -3
- package/src/materials/nodes/ShadowNodeMaterial.js +7 -3
- package/src/materials/nodes/SpriteNodeMaterial.js +39 -6
- package/src/materials/nodes/VolumeNodeMaterial.js +13 -9
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- package/src/math/Triangle.js +24 -0
- package/src/nodes/Nodes.js +3 -3
- package/src/nodes/TSL.js +96 -93
- package/src/nodes/accessors/BatchNode.js +7 -3
- package/src/nodes/accessors/BufferAttributeNode.js +6 -3
- package/src/nodes/accessors/BufferNode.js +6 -3
- package/src/nodes/accessors/Camera.js +10 -16
- package/src/nodes/accessors/ClippingNode.js +7 -3
- package/src/nodes/accessors/CubeTextureNode.js +6 -3
- package/src/nodes/accessors/InstanceNode.js +11 -11
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +6 -3
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +8 -4
- package/src/nodes/accessors/MaterialReferenceNode.js +6 -3
- package/src/nodes/accessors/ModelNode.js +42 -7
- package/src/nodes/accessors/ModelViewProjectionNode.js +9 -5
- package/src/nodes/accessors/MorphNode.js +7 -3
- package/src/nodes/accessors/Normal.js +32 -6
- package/src/nodes/accessors/Object3DNode.js +11 -27
- package/src/nodes/accessors/PointUVNode.js +7 -3
- package/src/nodes/accessors/ReferenceBaseNode.js +32 -4
- package/src/nodes/accessors/ReferenceNode.js +40 -3
- package/src/nodes/accessors/RendererReferenceNode.js +9 -3
- package/src/nodes/accessors/SceneNode.js +7 -3
- package/src/nodes/accessors/SkinningNode.js +7 -3
- package/src/nodes/accessors/StorageBufferNode.js +21 -3
- package/src/nodes/accessors/StorageTextureNode.js +7 -4
- package/src/nodes/accessors/Texture3DNode.js +7 -4
- package/src/nodes/accessors/TextureNode.js +19 -8
- package/src/nodes/accessors/TextureSizeNode.js +8 -5
- package/src/nodes/accessors/UniformArrayNode.js +12 -9
- package/src/nodes/accessors/UserDataNode.js +9 -6
- package/src/nodes/accessors/VelocityNode.js +74 -23
- package/src/nodes/accessors/VertexColorNode.js +6 -3
- package/src/nodes/code/CodeNode.js +7 -3
- package/src/nodes/code/ExpressionNode.js +8 -4
- package/src/nodes/code/FunctionCallNode.js +6 -3
- package/src/nodes/code/FunctionNode.js +6 -3
- package/src/nodes/code/ScriptableNode.js +11 -6
- package/src/nodes/code/ScriptableValueNode.js +7 -3
- package/src/nodes/core/AssignNode.js +9 -6
- package/src/nodes/core/AttributeNode.js +7 -3
- package/src/nodes/core/BypassNode.js +8 -4
- package/src/nodes/core/CacheNode.js +8 -4
- package/src/nodes/core/ConstNode.js +6 -3
- package/src/nodes/core/ContextNode.js +7 -3
- package/src/nodes/core/IndexNode.js +25 -3
- package/src/nodes/core/InputNode.js +7 -3
- package/src/nodes/core/MRTNode.js +6 -3
- package/src/nodes/core/Node.js +10 -51
- package/src/nodes/core/NodeBuilder.js +71 -5
- package/src/nodes/core/NodeUtils.js +48 -6
- package/src/nodes/core/OutputStructNode.js +8 -4
- package/src/nodes/core/ParameterNode.js +6 -3
- package/src/nodes/core/PropertyNode.js +7 -3
- package/src/nodes/core/StackNode.js +7 -3
- package/src/nodes/core/StructTypeNode.js +7 -3
- package/src/nodes/core/TempNode.js +8 -4
- package/src/nodes/core/UniformGroupNode.js +10 -6
- package/src/nodes/core/UniformNode.js +6 -3
- package/src/nodes/core/VarNode.js +8 -4
- package/src/nodes/core/VaryingNode.js +7 -3
- package/src/nodes/display/AfterImageNode.js +6 -0
- package/src/nodes/display/AnaglyphPassNode.js +6 -0
- package/src/nodes/display/AnamorphicNode.js +6 -0
- package/src/nodes/display/BloomNode.js +6 -0
- package/src/nodes/display/BumpMapNode.js +6 -0
- package/src/nodes/display/ColorSpaceFunctions.js +4 -4
- package/src/nodes/display/ColorSpaceNode.js +43 -14
- package/src/nodes/display/DenoiseNode.js +6 -3
- package/src/nodes/display/DepthOfFieldNode.js +6 -3
- package/src/nodes/display/DotScreenNode.js +8 -5
- package/src/nodes/display/FXAANode.js +6 -3
- package/src/nodes/display/FilmNode.js +6 -3
- package/src/nodes/display/FrontFacingNode.js +7 -3
- package/src/nodes/display/GTAONode.js +6 -3
- package/src/nodes/display/GaussianBlurNode.js +6 -3
- package/src/nodes/display/Lut3DNode.js +6 -3
- package/src/nodes/display/NormalMapNode.js +8 -6
- package/src/nodes/display/ParallaxBarrierPassNode.js +8 -5
- package/src/nodes/display/PassNode.js +18 -7
- package/src/nodes/display/PixelationPassNode.js +12 -5
- package/src/nodes/display/PosterizeNode.js +6 -3
- package/src/nodes/display/RGBShiftNode.js +6 -3
- package/src/nodes/display/RenderOutputNode.js +12 -8
- package/src/nodes/display/SSAAPassNode.js +6 -3
- package/src/nodes/display/ScreenNode.js +181 -0
- package/src/nodes/display/SobelOperatorNode.js +6 -3
- package/src/nodes/display/StereoCompositePassNode.js +6 -3
- package/src/nodes/display/StereoPassNode.js +6 -3
- package/src/nodes/display/ToneMappingFunctions.js +12 -12
- package/src/nodes/display/ToneMappingNode.js +8 -7
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +6 -3
- package/src/nodes/display/ViewportDepthNode.js +7 -3
- package/src/nodes/display/ViewportDepthTextureNode.js +8 -5
- package/src/nodes/display/ViewportSharedTextureNode.js +8 -5
- package/src/nodes/display/ViewportTextureNode.js +8 -5
- package/src/nodes/fog/FogExp2Node.js +6 -3
- package/src/nodes/fog/FogNode.js +7 -3
- package/src/nodes/fog/FogRangeNode.js +6 -3
- package/src/nodes/functions/PhysicalLightingModel.js +2 -2
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/src/nodes/geometry/RangeNode.js +7 -3
- package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
- package/src/nodes/gpgpu/BarrierNode.js +40 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
- package/src/nodes/gpgpu/ComputeNode.js +8 -4
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +6 -3
- package/src/nodes/lighting/AmbientLightNode.js +6 -3
- package/src/nodes/lighting/AnalyticLightNode.js +198 -30
- package/src/nodes/lighting/BasicEnvironmentNode.js +6 -3
- package/src/nodes/lighting/BasicLightMapNode.js +6 -3
- package/src/nodes/lighting/DirectionalLightNode.js +7 -4
- package/src/nodes/lighting/EnvironmentNode.js +6 -3
- package/src/nodes/lighting/HemisphereLightNode.js +10 -6
- package/src/nodes/lighting/IESSpotLightNode.js +6 -3
- package/src/nodes/lighting/IrradianceNode.js +6 -3
- package/src/nodes/lighting/LightProbeNode.js +8 -31
- package/src/nodes/lighting/LightingContextNode.js +6 -3
- package/src/nodes/lighting/LightingNode.js +7 -3
- package/src/nodes/lighting/LightsNode.js +24 -5
- package/src/nodes/lighting/PointLightNode.js +11 -7
- package/src/nodes/lighting/RectAreaLightNode.js +11 -7
- package/src/nodes/lighting/SpotLightNode.js +13 -10
- package/src/nodes/math/ConditionalNode.js +23 -6
- package/src/nodes/math/MathNode.js +6 -3
- package/src/nodes/math/OperatorNode.js +6 -3
- package/src/nodes/pmrem/PMREMNode.js +6 -3
- package/src/nodes/utils/ArrayElementNode.js +8 -4
- package/src/nodes/utils/ConvertNode.js +7 -3
- package/src/nodes/utils/CubeMapNode.js +6 -3
- package/src/nodes/utils/EquirectUVNode.js +6 -3
- package/src/nodes/utils/FlipNode.js +7 -4
- package/src/nodes/utils/FunctionOverloadingNode.js +7 -3
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +7 -3
- package/src/nodes/utils/MatcapUVNode.js +6 -3
- package/src/nodes/utils/MaxMipLevelNode.js +6 -3
- package/src/nodes/utils/OscNode.js +7 -3
- package/src/nodes/utils/RTTNode.js +6 -3
- package/src/nodes/utils/ReflectorNode.js +8 -5
- package/src/nodes/utils/RemapNode.js +7 -3
- package/src/nodes/utils/RotateNode.js +6 -3
- package/src/nodes/utils/SetNode.js +7 -4
- package/src/nodes/utils/SplitNode.js +7 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +7 -3
- package/src/nodes/utils/StorageArrayElementNode.js +9 -8
- package/src/nodes/utils/TimerNode.js +6 -3
- package/src/nodes/utils/TriplanarTexturesNode.js +7 -3
- package/src/nodes/utils/ViewportUtils.js +2 -2
- package/src/objects/BatchedMesh.js +76 -10
- package/src/objects/LOD.js +21 -0
- package/src/objects/Line.js +1 -0
- package/src/objects/Mesh.js +7 -23
- package/src/objects/Points.js +2 -0
- package/src/renderers/WebGLRenderer.js +65 -50
- package/src/renderers/common/BundleGroup.js +26 -0
- package/src/renderers/common/ClippingContext.js +4 -3
- package/src/renderers/common/RenderContext.js +4 -5
- package/src/renderers/common/RenderObject.js +116 -5
- package/src/renderers/common/RenderObjects.js +8 -1
- package/src/renderers/common/Renderer.js +57 -49
- package/src/renderers/common/extras/PMREMGenerator.js +7 -9
- package/src/renderers/common/nodes/NodeBuilderState.js +3 -3
- package/src/renderers/common/nodes/Nodes.js +33 -14
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/src/renderers/webgl/WebGLAttributes.js +45 -14
- package/src/renderers/webgl/WebGLCapabilities.js +9 -0
- package/src/renderers/webgl/WebGLProgram.js +2 -0
- package/src/renderers/webgl/WebGLPrograms.js +21 -17
- package/src/renderers/webgl/WebGLState.js +21 -0
- package/src/renderers/webgl/WebGLTextures.js +22 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +50 -45
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +4 -4
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +1 -4
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +61 -16
- package/src/renderers/webgpu/WebGPUBackend.js +33 -25
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/src/renderers/webgpu/WebGPURenderer.js +5 -2
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/{common → webgpu}/nodes/StandardNodeLibrary.js +11 -11
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +91 -11
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +7 -5
- package/src/renderers/webgpu/utils/WebGPUUtils.js +1 -1
- package/src/utils.js +33 -1
- package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/utils/GPUStatsPanel.js +0 -95
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/src/nodes/display/ViewportNode.js +0 -138
- package/src/nodes/lighting/LightNode.js +0 -57
- package/src/renderers/common/StandardRenderer.js +0 -18
- package/src/renderers/webvr/WebVRManager.js +0 -495
- package/src/renderers/webvr/WebVRUtils.js +0 -66
|
@@ -52,11 +52,10 @@ import { WebGLState } from './webgl/WebGLState.js';
|
|
|
52
52
|
import { WebGLTextures } from './webgl/WebGLTextures.js';
|
|
53
53
|
import { WebGLUniforms } from './webgl/WebGLUniforms.js';
|
|
54
54
|
import { WebGLUtils } from './webgl/WebGLUtils.js';
|
|
55
|
-
import { WebVRManager } from './webvr/WebVRManager.js';
|
|
56
55
|
import { WebXRManager } from './webxr/WebXRManager.js';
|
|
57
56
|
import { WebGLMaterials } from './webgl/WebGLMaterials.js';
|
|
58
57
|
import { WebGLUniformsGroups } from './webgl/WebGLUniformsGroups.js';
|
|
59
|
-
import { createCanvasElement, probeAsync, warnOnce } from '../utils.js';
|
|
58
|
+
import { createCanvasElement, probeAsync, toNormalizedProjectionMatrix, toReversedProjectionMatrix, warnOnce } from '../utils.js';
|
|
60
59
|
import { ColorManagement } from '../math/ColorManagement.js';
|
|
61
60
|
|
|
62
61
|
class WebGLRenderer {
|
|
@@ -199,6 +198,7 @@ class WebGLRenderer {
|
|
|
199
198
|
|
|
200
199
|
// camera matrices cache
|
|
201
200
|
|
|
201
|
+
const _currentProjectionMatrix = new Matrix4();
|
|
202
202
|
const _projScreenMatrix = new Matrix4();
|
|
203
203
|
|
|
204
204
|
const _vector3 = new Vector3();
|
|
@@ -295,6 +295,8 @@ class WebGLRenderer {
|
|
|
295
295
|
|
|
296
296
|
state = new WebGLState( _gl );
|
|
297
297
|
|
|
298
|
+
if ( capabilities.reverseDepthBuffer ) state.buffers.depth.setReversed( true );
|
|
299
|
+
|
|
298
300
|
info = new WebGLInfo( _gl );
|
|
299
301
|
properties = new WebGLProperties();
|
|
300
302
|
textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
|
|
@@ -334,7 +336,7 @@ class WebGLRenderer {
|
|
|
334
336
|
|
|
335
337
|
// xr
|
|
336
338
|
|
|
337
|
-
const xr =
|
|
339
|
+
const xr = new WebXRManager( _this, _gl );
|
|
338
340
|
|
|
339
341
|
this.xr = xr;
|
|
340
342
|
|
|
@@ -595,7 +597,13 @@ class WebGLRenderer {
|
|
|
595
597
|
|
|
596
598
|
}
|
|
597
599
|
|
|
598
|
-
if ( depth )
|
|
600
|
+
if ( depth ) {
|
|
601
|
+
|
|
602
|
+
bits |= _gl.DEPTH_BUFFER_BIT;
|
|
603
|
+
_gl.clearDepth( this.capabilities.reverseDepthBuffer ? 0 : 1 );
|
|
604
|
+
|
|
605
|
+
}
|
|
606
|
+
|
|
599
607
|
if ( stencil ) {
|
|
600
608
|
|
|
601
609
|
bits |= _gl.STENCIL_BUFFER_BIT;
|
|
@@ -984,6 +992,12 @@ class WebGLRenderer {
|
|
|
984
992
|
|
|
985
993
|
scene.traverse( function ( object ) {
|
|
986
994
|
|
|
995
|
+
if ( ! ( object.isMesh || object.isPoints || object.isLine || object.isSprite ) ) {
|
|
996
|
+
|
|
997
|
+
return;
|
|
998
|
+
|
|
999
|
+
}
|
|
1000
|
+
|
|
987
1001
|
const material = object.material;
|
|
988
1002
|
|
|
989
1003
|
if ( material ) {
|
|
@@ -1282,13 +1296,6 @@ class WebGLRenderer {
|
|
|
1282
1296
|
|
|
1283
1297
|
if ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );
|
|
1284
1298
|
|
|
1285
|
-
textures.runDeferredUploads();
|
|
1286
|
-
|
|
1287
|
-
if ( xr.enabled && xr.submitFrame ) {
|
|
1288
|
-
|
|
1289
|
-
xr.submitFrame();
|
|
1290
|
-
|
|
1291
|
-
}
|
|
1292
1299
|
// _gl.finish();
|
|
1293
1300
|
|
|
1294
1301
|
bindingStates.resetDefaultState();
|
|
@@ -2001,7 +2008,21 @@ class WebGLRenderer {
|
|
|
2001
2008
|
|
|
2002
2009
|
} else {
|
|
2003
2010
|
|
|
2004
|
-
|
|
2011
|
+
if ( capabilities.reverseDepthBuffer ) {
|
|
2012
|
+
|
|
2013
|
+
_currentProjectionMatrix.copy( camera.projectionMatrix );
|
|
2014
|
+
|
|
2015
|
+
toNormalizedProjectionMatrix( _currentProjectionMatrix );
|
|
2016
|
+
toReversedProjectionMatrix( _currentProjectionMatrix );
|
|
2017
|
+
|
|
2018
|
+
p_uniforms.setValue( _gl, 'projectionMatrix', _currentProjectionMatrix );
|
|
2019
|
+
|
|
2020
|
+
} else {
|
|
2021
|
+
|
|
2022
|
+
p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
|
|
2023
|
+
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2005
2026
|
p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
|
|
2006
2027
|
|
|
2007
2028
|
}
|
|
@@ -2519,61 +2540,55 @@ class WebGLRenderer {
|
|
|
2519
2540
|
|
|
2520
2541
|
if ( framebuffer ) {
|
|
2521
2542
|
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
const texture = renderTarget.texture;
|
|
2527
|
-
const textureFormat = texture.format;
|
|
2528
|
-
const textureType = texture.type;
|
|
2529
|
-
|
|
2530
|
-
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
2531
|
-
|
|
2532
|
-
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
|
|
2543
|
+
const texture = renderTarget.texture;
|
|
2544
|
+
const textureFormat = texture.format;
|
|
2545
|
+
const textureType = texture.type;
|
|
2533
2546
|
|
|
2534
|
-
|
|
2547
|
+
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
2535
2548
|
|
|
2536
|
-
|
|
2549
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
|
|
2537
2550
|
|
|
2538
|
-
|
|
2551
|
+
}
|
|
2539
2552
|
|
|
2540
|
-
|
|
2553
|
+
if ( ! capabilities.textureTypeReadable( textureType ) ) {
|
|
2541
2554
|
|
|
2542
|
-
|
|
2543
|
-
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
|
|
2555
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.' );
|
|
2544
2556
|
|
|
2545
|
-
|
|
2546
|
-
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
2547
|
-
_gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
|
|
2548
|
-
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
|
|
2549
|
-
_gl.flush();
|
|
2557
|
+
}
|
|
2550
2558
|
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
await probeAsync( _gl, sync, 4 );
|
|
2559
|
+
// the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
|
|
2560
|
+
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
|
|
2554
2561
|
|
|
2555
|
-
|
|
2562
|
+
// set the active frame buffer to the one we want to read
|
|
2563
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
2556
2564
|
|
|
2557
|
-
|
|
2558
|
-
|
|
2565
|
+
const glBuffer = _gl.createBuffer();
|
|
2566
|
+
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
2567
|
+
_gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
|
|
2568
|
+
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
|
|
2559
2569
|
|
|
2560
|
-
|
|
2570
|
+
// reset the frame buffer to the currently set buffer before waiting
|
|
2571
|
+
const currFramebuffer = _currentRenderTarget !== null ? properties.get( _currentRenderTarget ).__webglFramebuffer : null;
|
|
2572
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, currFramebuffer );
|
|
2561
2573
|
|
|
2562
|
-
|
|
2563
|
-
|
|
2574
|
+
// check if the commands have finished every 8 ms
|
|
2575
|
+
const sync = _gl.fenceSync( _gl.SYNC_GPU_COMMANDS_COMPLETE, 0 );
|
|
2564
2576
|
|
|
2565
|
-
|
|
2577
|
+
_gl.flush();
|
|
2566
2578
|
|
|
2567
|
-
|
|
2579
|
+
await probeAsync( _gl, sync, 4 );
|
|
2568
2580
|
|
|
2569
|
-
|
|
2581
|
+
// read the data and delete the buffer
|
|
2582
|
+
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
2583
|
+
_gl.getBufferSubData( _gl.PIXEL_PACK_BUFFER, 0, buffer );
|
|
2584
|
+
_gl.deleteBuffer( glBuffer );
|
|
2585
|
+
_gl.deleteSync( sync );
|
|
2570
2586
|
|
|
2571
|
-
|
|
2587
|
+
return buffer;
|
|
2572
2588
|
|
|
2573
|
-
|
|
2589
|
+
} else {
|
|
2574
2590
|
|
|
2575
|
-
|
|
2576
|
-
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
2591
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.' );
|
|
2577
2592
|
|
|
2578
2593
|
}
|
|
2579
2594
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Group } from '../../objects/Group.js';
|
|
2
|
+
|
|
3
|
+
class BundleGroup extends Group {
|
|
4
|
+
|
|
5
|
+
constructor() {
|
|
6
|
+
|
|
7
|
+
super();
|
|
8
|
+
|
|
9
|
+
this.isBundleGroup = true;
|
|
10
|
+
|
|
11
|
+
this.type = 'BundleGroup';
|
|
12
|
+
|
|
13
|
+
this.static = true;
|
|
14
|
+
this.version = 0;
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
set needsUpdate( value ) {
|
|
19
|
+
|
|
20
|
+
if ( value === true ) this.version ++;
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default BundleGroup;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Matrix3 } from '../../math/Matrix3.js';
|
|
2
2
|
import { Plane } from '../../math/Plane.js';
|
|
3
3
|
import { Vector4 } from '../../math/Vector4.js';
|
|
4
|
+
import { hash } from '../../nodes/core/NodeUtils.js';
|
|
4
5
|
|
|
5
6
|
const _plane = /*@__PURE__*/ new Plane();
|
|
6
7
|
|
|
@@ -20,7 +21,7 @@ class ClippingContext {
|
|
|
20
21
|
|
|
21
22
|
this.parentVersion = 0;
|
|
22
23
|
this.viewNormalMatrix = new Matrix3();
|
|
23
|
-
this.cacheKey =
|
|
24
|
+
this.cacheKey = 0;
|
|
24
25
|
|
|
25
26
|
}
|
|
26
27
|
|
|
@@ -95,7 +96,7 @@ class ClippingContext {
|
|
|
95
96
|
if ( update ) {
|
|
96
97
|
|
|
97
98
|
this.version ++;
|
|
98
|
-
this.cacheKey =
|
|
99
|
+
this.cacheKey = hash( this.globalClippingCount, this.localClippingEnabled === true ? 1 : 0 );
|
|
99
100
|
|
|
100
101
|
}
|
|
101
102
|
|
|
@@ -165,7 +166,7 @@ class ClippingContext {
|
|
|
165
166
|
if ( update ) {
|
|
166
167
|
|
|
167
168
|
this.version += parent.version;
|
|
168
|
-
this.cacheKey = parent.cacheKey
|
|
169
|
+
this.cacheKey = hash( parent.cacheKey, this.localClippingCount, this.localClipIntersection === true ? 1 : 0 );
|
|
169
170
|
|
|
170
171
|
}
|
|
171
172
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Vector4 } from '../../math/Vector4.js';
|
|
2
|
+
import { hashArray } from '../../nodes/core/NodeUtils.js';
|
|
2
3
|
|
|
3
4
|
let id = 0;
|
|
4
5
|
|
|
@@ -50,17 +51,15 @@ export function getCacheKey( renderContext ) {
|
|
|
50
51
|
|
|
51
52
|
const { textures, activeCubeFace } = renderContext;
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
const values = [ activeCubeFace ];
|
|
54
55
|
|
|
55
56
|
for ( const texture of textures ) {
|
|
56
57
|
|
|
57
|
-
|
|
58
|
+
values.push( texture.id );
|
|
58
59
|
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return key;
|
|
62
|
+
return hashArray( values );
|
|
64
63
|
|
|
65
64
|
}
|
|
66
65
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hashString } from '../../nodes/core/NodeUtils.js';
|
|
1
2
|
import ClippingContext from './ClippingContext.js';
|
|
2
3
|
|
|
3
4
|
let _id = 0;
|
|
@@ -61,6 +62,9 @@ export default class RenderObject {
|
|
|
61
62
|
this.attributes = null;
|
|
62
63
|
this.pipeline = null;
|
|
63
64
|
this.vertexBuffers = null;
|
|
65
|
+
this.drawParams = null;
|
|
66
|
+
|
|
67
|
+
this.bundle = null;
|
|
64
68
|
|
|
65
69
|
this.updateClipping( renderContext.clippingContext );
|
|
66
70
|
|
|
@@ -71,6 +75,7 @@ export default class RenderObject {
|
|
|
71
75
|
|
|
72
76
|
this._nodeBuilderState = null;
|
|
73
77
|
this._bindings = null;
|
|
78
|
+
this._monitor = null;
|
|
74
79
|
|
|
75
80
|
this.onDispose = null;
|
|
76
81
|
|
|
@@ -127,6 +132,12 @@ export default class RenderObject {
|
|
|
127
132
|
|
|
128
133
|
}
|
|
129
134
|
|
|
135
|
+
getMonitor() {
|
|
136
|
+
|
|
137
|
+
return this._monitor || ( this._monitor = this.getNodeBuilderState().monitor );
|
|
138
|
+
|
|
139
|
+
}
|
|
140
|
+
|
|
130
141
|
getBindings() {
|
|
131
142
|
|
|
132
143
|
return this._bindings || ( this._bindings = this.getNodeBuilderState().createBindings() );
|
|
@@ -183,6 +194,90 @@ export default class RenderObject {
|
|
|
183
194
|
|
|
184
195
|
}
|
|
185
196
|
|
|
197
|
+
getDrawParameters() {
|
|
198
|
+
|
|
199
|
+
const { object, material, geometry, group, drawRange } = this;
|
|
200
|
+
|
|
201
|
+
const drawParams = this.drawParams || ( this.drawParams = {
|
|
202
|
+
vertexCount: 0,
|
|
203
|
+
firstVertex: 0,
|
|
204
|
+
instanceCount: 0,
|
|
205
|
+
firstInstance: 0
|
|
206
|
+
} );
|
|
207
|
+
|
|
208
|
+
const index = this.getIndex();
|
|
209
|
+
const hasIndex = ( index !== null );
|
|
210
|
+
const instanceCount = geometry.isInstancedBufferGeometry ? geometry.instanceCount : ( object.count > 1 ? object.count : 1 );
|
|
211
|
+
|
|
212
|
+
if ( instanceCount === 0 ) return null;
|
|
213
|
+
|
|
214
|
+
drawParams.instanceCount = instanceCount;
|
|
215
|
+
|
|
216
|
+
if ( object.isBatchedMesh === true ) return drawParams;
|
|
217
|
+
|
|
218
|
+
let rangeFactor = 1;
|
|
219
|
+
|
|
220
|
+
if ( material.wireframe === true && ! object.isPoints && ! object.isLineSegments && ! object.isLine && ! object.isLineLoop ) {
|
|
221
|
+
|
|
222
|
+
rangeFactor = 2;
|
|
223
|
+
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
let firstVertex = drawRange.start * rangeFactor;
|
|
227
|
+
let lastVertex = ( drawRange.start + drawRange.count ) * rangeFactor;
|
|
228
|
+
|
|
229
|
+
if ( group !== null ) {
|
|
230
|
+
|
|
231
|
+
firstVertex = Math.max( firstVertex, group.start * rangeFactor );
|
|
232
|
+
lastVertex = Math.min( lastVertex, ( group.start + group.count ) * rangeFactor );
|
|
233
|
+
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const itemCount = hasIndex === true ? index.count : geometry.attributes.position.count;
|
|
237
|
+
|
|
238
|
+
firstVertex = Math.max( firstVertex, 0 );
|
|
239
|
+
lastVertex = Math.min( lastVertex, itemCount );
|
|
240
|
+
|
|
241
|
+
const count = lastVertex - firstVertex;
|
|
242
|
+
|
|
243
|
+
if ( count < 0 || count === Infinity ) return null;
|
|
244
|
+
|
|
245
|
+
drawParams.vertexCount = count;
|
|
246
|
+
drawParams.firstVertex = firstVertex;
|
|
247
|
+
|
|
248
|
+
return drawParams;
|
|
249
|
+
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
getGeometryCacheKey() {
|
|
253
|
+
|
|
254
|
+
const { geometry } = this;
|
|
255
|
+
|
|
256
|
+
let cacheKey = '';
|
|
257
|
+
|
|
258
|
+
for ( const name of Object.keys( geometry.attributes ).sort() ) {
|
|
259
|
+
|
|
260
|
+
const attribute = geometry.attributes[ name ];
|
|
261
|
+
|
|
262
|
+
cacheKey += name + ',';
|
|
263
|
+
|
|
264
|
+
if ( attribute.data ) cacheKey += attribute.data.stride + ',';
|
|
265
|
+
if ( attribute.offset ) cacheKey += attribute.offset + ',';
|
|
266
|
+
if ( attribute.itemSize ) cacheKey += attribute.itemSize + ',';
|
|
267
|
+
if ( attribute.normalized ) cacheKey += 'n,';
|
|
268
|
+
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if ( geometry.index ) {
|
|
272
|
+
|
|
273
|
+
cacheKey += 'index,';
|
|
274
|
+
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return cacheKey;
|
|
278
|
+
|
|
279
|
+
}
|
|
280
|
+
|
|
186
281
|
getMaterialCacheKey() {
|
|
187
282
|
|
|
188
283
|
const { object, material } = this;
|
|
@@ -237,6 +332,12 @@ export default class RenderObject {
|
|
|
237
332
|
|
|
238
333
|
cacheKey += this.clippingContext.cacheKey + ',';
|
|
239
334
|
|
|
335
|
+
if ( object.geometry ) {
|
|
336
|
+
|
|
337
|
+
cacheKey += this.getGeometryCacheKey();
|
|
338
|
+
|
|
339
|
+
}
|
|
340
|
+
|
|
240
341
|
if ( object.skeleton ) {
|
|
241
342
|
|
|
242
343
|
cacheKey += object.skeleton.bones.length + ',';
|
|
@@ -263,17 +364,19 @@ export default class RenderObject {
|
|
|
263
364
|
|
|
264
365
|
if ( object.count > 1 ) {
|
|
265
366
|
|
|
266
|
-
|
|
367
|
+
// TODO: https://github.com/mrdoob/three.js/pull/29066#issuecomment-2269400850
|
|
368
|
+
|
|
369
|
+
cacheKey += object.uuid + ',';
|
|
267
370
|
|
|
268
371
|
}
|
|
269
372
|
|
|
270
|
-
return cacheKey;
|
|
373
|
+
return hashString( cacheKey );
|
|
271
374
|
|
|
272
375
|
}
|
|
273
376
|
|
|
274
377
|
get needsUpdate() {
|
|
275
378
|
|
|
276
|
-
return this.initialNodesCacheKey !== this.getDynamicCacheKey() || this.clippingNeedsUpdate;
|
|
379
|
+
return /*this.object.static !== true &&*/ ( this.initialNodesCacheKey !== this.getDynamicCacheKey() || this.clippingNeedsUpdate );
|
|
277
380
|
|
|
278
381
|
}
|
|
279
382
|
|
|
@@ -281,13 +384,21 @@ export default class RenderObject {
|
|
|
281
384
|
|
|
282
385
|
// Environment Nodes Cache Key
|
|
283
386
|
|
|
284
|
-
|
|
387
|
+
let cacheKey = this._nodes.getCacheKey( this.scene, this.lightsNode );
|
|
388
|
+
|
|
389
|
+
if ( this.object.receiveShadow ) {
|
|
390
|
+
|
|
391
|
+
cacheKey += 1;
|
|
392
|
+
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
return cacheKey;
|
|
285
396
|
|
|
286
397
|
}
|
|
287
398
|
|
|
288
399
|
getCacheKey() {
|
|
289
400
|
|
|
290
|
-
return this.getMaterialCacheKey() +
|
|
401
|
+
return this.getMaterialCacheKey() + this.getDynamicCacheKey();
|
|
291
402
|
|
|
292
403
|
}
|
|
293
404
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import ChainMap from './ChainMap.js';
|
|
2
2
|
import RenderObject from './RenderObject.js';
|
|
3
3
|
|
|
4
|
+
const chainArray = [];
|
|
5
|
+
|
|
4
6
|
class RenderObjects {
|
|
5
7
|
|
|
6
8
|
constructor( renderer, nodes, geometries, pipelines, bindings, info ) {
|
|
@@ -19,7 +21,12 @@ class RenderObjects {
|
|
|
19
21
|
get( object, material, scene, camera, lightsNode, renderContext, passId ) {
|
|
20
22
|
|
|
21
23
|
const chainMap = this.getChainMap( passId );
|
|
22
|
-
|
|
24
|
+
|
|
25
|
+
// reuse chainArray
|
|
26
|
+
chainArray[ 0 ] = object;
|
|
27
|
+
chainArray[ 1 ] = material;
|
|
28
|
+
chainArray[ 2 ] = renderContext;
|
|
29
|
+
chainArray[ 3 ] = lightsNode;
|
|
23
30
|
|
|
24
31
|
let renderObject = chainMap.get( chainArray );
|
|
25
32
|
|