super-three 0.170.0 → 0.171.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/build/three.cjs +24410 -24422
- package/build/three.core.js +37002 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +10573 -47578
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +533 -0
- package/build/three.tsl.min.js +6 -0
- package/build/three.webgpu.js +2907 -37975
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +2914 -37959
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/capabilities/WebGPU.js +1 -10
- package/examples/jsm/controls/ArcballControls.js +25 -21
- package/examples/jsm/controls/OrbitControls.js +41 -9
- package/examples/jsm/controls/PointerLockControls.js +2 -5
- package/examples/jsm/csm/CSMShadowNode.js +7 -5
- package/examples/jsm/geometries/DecalGeometry.js +5 -1
- package/examples/jsm/lighting/TiledLighting.js +1 -1
- package/examples/jsm/lines/LineGeometry.js +25 -0
- package/examples/jsm/lines/LineMaterial.js +1 -7
- package/examples/jsm/lines/webgpu/Line2.js +2 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +2 -1
- package/examples/jsm/lines/webgpu/Wireframe.js +2 -1
- package/examples/jsm/loaders/KTX2Loader.js +3 -0
- package/examples/jsm/loaders/MMDLoader.js +2 -6
- package/examples/jsm/loaders/MaterialXLoader.js +2 -2
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -6
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +2 -2
- package/examples/jsm/objects/InstancedPoints.js +2 -4
- package/examples/jsm/objects/LensflareMesh.js +4 -2
- package/examples/jsm/objects/SkyMesh.js +5 -3
- package/examples/jsm/objects/Water2Mesh.js +7 -3
- package/examples/jsm/objects/WaterMesh.js +5 -3
- package/examples/jsm/transpiler/AST.js +2 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +57 -25
- package/examples/jsm/transpiler/TSLEncoder.js +11 -6
- package/examples/jsm/tsl/display/AfterImageNode.js +3 -3
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +2 -2
- package/examples/jsm/tsl/display/AnamorphicNode.js +2 -2
- package/examples/jsm/tsl/display/BloomNode.js +3 -3
- package/examples/jsm/tsl/display/DenoiseNode.js +48 -12
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +3 -2
- package/examples/jsm/tsl/display/DotScreenNode.js +2 -2
- package/examples/jsm/tsl/display/FXAANode.js +3 -3
- package/examples/jsm/tsl/display/FilmNode.js +3 -2
- package/examples/jsm/tsl/display/GTAONode.js +62 -27
- package/examples/jsm/tsl/display/GaussianBlurNode.js +6 -8
- package/examples/jsm/tsl/display/LensflareNode.js +3 -3
- package/examples/jsm/tsl/display/Lut3DNode.js +3 -2
- package/examples/jsm/tsl/display/OutlineNode.js +2 -2
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -1
- package/examples/jsm/tsl/display/PixelationPassNode.js +4 -4
- package/examples/jsm/tsl/display/RGBShiftNode.js +2 -1
- package/examples/jsm/tsl/display/SMAANode.js +3 -3
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/SSRNode.js +31 -8
- package/examples/jsm/tsl/display/SobelOperatorNode.js +3 -3
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +4 -4
- package/examples/jsm/tsl/display/StereoPassNode.js +2 -2
- package/examples/jsm/tsl/display/TRAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/TransitionNode.js +3 -2
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +6 -9
- package/examples/jsm/utils/SceneOptimizer.js +410 -0
- package/examples/jsm/utils/UVsDebug.js +1 -1
- package/package.json +3 -3
- package/src/Three.Core.js +178 -0
- package/src/Three.TSL.js +526 -0
- package/src/Three.WebGPU.Nodes.js +5 -186
- package/src/Three.WebGPU.js +4 -186
- package/src/Three.js +1 -177
- package/src/animation/AnimationClip.js +2 -2
- package/src/animation/AnimationObjectGroup.js +2 -2
- package/src/audio/Audio.js +38 -0
- package/src/cameras/PerspectiveCamera.js +6 -6
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferGeometry.js +5 -3
- package/src/core/InterleavedBuffer.js +4 -4
- package/src/core/Object3D.js +2 -2
- package/src/extras/core/Curve.js +3 -3
- package/src/extras/core/Shape.js +2 -2
- package/src/geometries/EdgesGeometry.js +2 -2
- package/src/geometries/LatheGeometry.js +2 -2
- package/src/lights/SpotLightShadow.js +2 -2
- package/src/materials/LineBasicMaterial.js +2 -6
- package/src/materials/LineDashedMaterial.js +1 -6
- package/src/materials/Material.js +3 -16
- package/src/materials/MeshBasicMaterial.js +2 -6
- package/src/materials/MeshDepthMaterial.js +2 -6
- package/src/materials/MeshDistanceMaterial.js +2 -6
- package/src/materials/MeshLambertMaterial.js +2 -6
- package/src/materials/MeshMatcapMaterial.js +2 -6
- package/src/materials/MeshNormalMaterial.js +2 -6
- package/src/materials/MeshPhongMaterial.js +3 -7
- package/src/materials/MeshPhysicalMaterial.js +4 -8
- package/src/materials/MeshStandardMaterial.js +2 -6
- package/src/materials/MeshToonMaterial.js +2 -6
- package/src/materials/PointsMaterial.js +2 -6
- package/src/materials/RawShaderMaterial.js +2 -6
- package/src/materials/ShaderMaterial.js +2 -6
- package/src/materials/ShadowMaterial.js +2 -6
- package/src/materials/SpriteMaterial.js +2 -6
- package/src/materials/nodes/Line2NodeMaterial.js +32 -13
- package/src/materials/nodes/LineDashedNodeMaterial.js +4 -2
- package/src/materials/nodes/NodeMaterial.js +64 -16
- package/src/materials/nodes/manager/NodeMaterialObserver.js +13 -10
- package/src/math/ColorManagement.js +130 -122
- package/src/math/Line3.js +2 -2
- package/src/math/Quaternion.js +2 -2
- package/src/math/Spherical.js +3 -3
- package/src/math/Vector2.js +7 -7
- package/src/math/Vector3.js +9 -9
- package/src/math/Vector4.js +11 -9
- package/src/nodes/Nodes.js +1 -0
- package/src/nodes/TSL.js +3 -1
- package/src/nodes/accessors/Arrays.js +27 -0
- package/src/nodes/accessors/BuiltinNode.js +26 -0
- package/src/nodes/accessors/ClippingNode.js +76 -42
- package/src/nodes/accessors/InstanceNode.js +17 -20
- package/src/nodes/accessors/InstancedMeshNode.js +26 -0
- package/src/nodes/accessors/Lights.js +32 -0
- package/src/nodes/accessors/StorageBufferNode.js +29 -9
- package/src/nodes/accessors/StorageTextureNode.js +10 -4
- package/src/nodes/accessors/TextureNode.js +1 -1
- package/src/nodes/core/NodeBuilder.js +2 -9
- package/src/nodes/core/NodeUtils.js +28 -0
- package/src/nodes/core/constants.js +6 -0
- package/src/nodes/display/BlendModes.js +99 -0
- package/src/nodes/display/ToonOutlinePassNode.js +3 -3
- package/src/nodes/display/ViewportDepthNode.js +21 -6
- package/src/nodes/functions/material/getAlphaHashThreshold.js +13 -7
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +1 -1
- package/src/nodes/lighting/AnalyticLightNode.js +12 -4
- package/src/nodes/lighting/PointLightNode.js +10 -1
- package/src/nodes/lighting/PointShadowNode.js +254 -0
- package/src/nodes/lighting/ShadowNode.js +176 -67
- package/src/nodes/lighting/SpotLightNode.js +14 -2
- package/src/nodes/utils/RTTNode.js +9 -1
- package/src/nodes/utils/StorageArrayElementNode.js +2 -2
- package/src/objects/BatchedMesh.js +54 -95
- package/src/objects/ClippingGroup.js +19 -0
- package/src/objects/Skeleton.js +2 -2
- package/src/renderers/WebGLRenderer.js +94 -23
- package/src/renderers/common/Animation.js +23 -11
- package/src/renderers/common/Background.js +1 -1
- package/src/renderers/common/Bindings.js +20 -4
- package/src/renderers/common/ClippingContext.js +77 -85
- package/src/renderers/common/RenderList.js +9 -6
- package/src/renderers/common/RenderObject.js +27 -27
- package/src/renderers/common/RenderObjects.js +12 -6
- package/src/renderers/common/Renderer.js +63 -57
- package/src/renderers/common/Textures.js +11 -3
- package/src/renderers/common/UniformsGroup.js +16 -4
- package/src/renderers/common/extras/PMREMGenerator.js +89 -13
- package/src/renderers/common/nodes/NodeLibrary.js +2 -2
- package/src/renderers/common/nodes/NodeStorageBuffer.js +2 -3
- package/src/renderers/common/nodes/NodeUniform.js +42 -0
- package/src/renderers/webgl/WebGLBackground.js +20 -1
- package/src/renderers/webgl/WebGLGeometries.js +0 -28
- package/src/renderers/webgl-fallback/WebGLBackend.js +13 -6
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +43 -12
- package/src/renderers/webgl-fallback/utils/WebGLState.js +26 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +4 -1
- package/src/renderers/webgpu/WebGPUBackend.js +47 -31
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +13 -26
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +184 -74
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -2
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -7
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +5 -1
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/src/nodes/display/BlendMode.js +0 -54
|
@@ -22,18 +22,6 @@ function WebGLGeometries( gl, attributes, info, bindingStates ) {
|
|
|
22
22
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
for ( const name in geometry.morphAttributes ) {
|
|
26
|
-
|
|
27
|
-
const array = geometry.morphAttributes[ name ];
|
|
28
|
-
|
|
29
|
-
for ( let i = 0, l = array.length; i < l; i ++ ) {
|
|
30
|
-
|
|
31
|
-
attributes.remove( array[ i ] );
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
25
|
geometry.removeEventListener( 'dispose', onGeometryDispose );
|
|
38
26
|
|
|
39
27
|
delete geometries[ geometry.id ];
|
|
@@ -87,22 +75,6 @@ function WebGLGeometries( gl, attributes, info, bindingStates ) {
|
|
|
87
75
|
|
|
88
76
|
}
|
|
89
77
|
|
|
90
|
-
// morph targets
|
|
91
|
-
|
|
92
|
-
const morphAttributes = geometry.morphAttributes;
|
|
93
|
-
|
|
94
|
-
for ( const name in morphAttributes ) {
|
|
95
|
-
|
|
96
|
-
const array = morphAttributes[ name ];
|
|
97
|
-
|
|
98
|
-
for ( let i = 0, l = array.length; i < l; i ++ ) {
|
|
99
|
-
|
|
100
|
-
attributes.update( array[ i ], gl.ARRAY_BUFFER );
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
78
|
}
|
|
107
79
|
|
|
108
80
|
function updateWireframeAttribute( geometry ) {
|
|
@@ -166,7 +166,7 @@ class WebGLBackend extends Backend {
|
|
|
166
166
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
|
|
169
|
+
async resolveTimestampAsync( renderContext, type = 'render' ) {
|
|
170
170
|
|
|
171
171
|
if ( ! this.disjoint || ! this.trackTimestamp ) return;
|
|
172
172
|
|
|
@@ -641,7 +641,7 @@ class WebGLBackend extends Backend {
|
|
|
641
641
|
|
|
642
642
|
draw( renderObject/*, info*/ ) {
|
|
643
643
|
|
|
644
|
-
const { object, pipeline, material, context } = renderObject;
|
|
644
|
+
const { object, pipeline, material, context, hardwareClippingPlanes } = renderObject;
|
|
645
645
|
const { programGPU } = this.get( pipeline );
|
|
646
646
|
|
|
647
647
|
const { gl, state } = this;
|
|
@@ -658,15 +658,17 @@ class WebGLBackend extends Backend {
|
|
|
658
658
|
|
|
659
659
|
const frontFaceCW = ( object.isMesh && object.matrixWorld.determinant() < 0 );
|
|
660
660
|
|
|
661
|
-
state.setMaterial( material, frontFaceCW );
|
|
661
|
+
state.setMaterial( material, frontFaceCW, hardwareClippingPlanes );
|
|
662
662
|
|
|
663
663
|
state.useProgram( programGPU );
|
|
664
664
|
|
|
665
665
|
//
|
|
666
666
|
|
|
667
|
-
|
|
667
|
+
const renderObjectData = this.get( renderObject );
|
|
668
668
|
|
|
669
|
-
|
|
669
|
+
let vaoGPU = renderObjectData.staticVao;
|
|
670
|
+
|
|
671
|
+
if ( vaoGPU === undefined || renderObjectData.geometryId !== renderObject.geometry.id ) {
|
|
670
672
|
|
|
671
673
|
const vaoKey = this._getVaoKey( renderObject.getIndex(), renderObject.getAttributes() );
|
|
672
674
|
|
|
@@ -678,7 +680,12 @@ class WebGLBackend extends Backend {
|
|
|
678
680
|
|
|
679
681
|
( { vaoGPU, staticVao } = this._createVao( renderObject.getIndex(), renderObject.getAttributes() ) );
|
|
680
682
|
|
|
681
|
-
if ( staticVao )
|
|
683
|
+
if ( staticVao ) {
|
|
684
|
+
|
|
685
|
+
renderObjectData.staticVao = vaoGPU;
|
|
686
|
+
renderObjectData.geometryId = renderObject.geometry.id;
|
|
687
|
+
|
|
688
|
+
}
|
|
682
689
|
|
|
683
690
|
}
|
|
684
691
|
|
|
@@ -55,12 +55,13 @@ class GLSLNodeBuilder extends NodeBuilder {
|
|
|
55
55
|
this.uniformGroups = {};
|
|
56
56
|
this.transforms = [];
|
|
57
57
|
this.extensions = {};
|
|
58
|
+
this.builtins = { vertex: [], fragment: [], compute: [] };
|
|
58
59
|
|
|
59
60
|
this.useComparisonMethod = true;
|
|
60
61
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
|
|
64
|
+
needsToWorkingColorSpace( texture ) {
|
|
64
65
|
|
|
65
66
|
return texture.isVideoTexture === true && texture.colorSpace !== NoColorSpace;
|
|
66
67
|
|
|
@@ -123,7 +124,6 @@ ${ flowData.code }
|
|
|
123
124
|
|
|
124
125
|
let format = isInteger ? RedIntegerFormat : RedFormat;
|
|
125
126
|
|
|
126
|
-
|
|
127
127
|
if ( itemSize === 2 ) {
|
|
128
128
|
|
|
129
129
|
format = isInteger ? RGIntegerFormat : RGFormat;
|
|
@@ -201,7 +201,6 @@ ${ flowData.code }
|
|
|
201
201
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
|
|
205
204
|
const nodeUniform = this.getUniformFromNode( attribute.pboNode, 'texture', this.shaderStage, this.context.label );
|
|
206
205
|
const textureName = this.getPropertyName( nodeUniform );
|
|
207
206
|
|
|
@@ -571,7 +570,7 @@ ${ flowData.code }
|
|
|
571
570
|
for ( const varying of varyings ) {
|
|
572
571
|
|
|
573
572
|
if ( shaderStage === 'compute' ) varying.needsInterpolation = true;
|
|
574
|
-
const type = varying.type;
|
|
573
|
+
const type = this.getType( varying.type );
|
|
575
574
|
const flat = type.includes( 'int' ) || type.includes( 'uv' ) || type.includes( 'iv' ) ? 'flat ' : '';
|
|
576
575
|
|
|
577
576
|
snippet += `${flat}${varying.needsInterpolation ? 'out' : '/*out*/'} ${type} ${varying.name};\n`;
|
|
@@ -584,7 +583,7 @@ ${ flowData.code }
|
|
|
584
583
|
|
|
585
584
|
if ( varying.needsInterpolation ) {
|
|
586
585
|
|
|
587
|
-
const type = varying.type;
|
|
586
|
+
const type = this.getType( varying.type );
|
|
588
587
|
const flat = type.includes( 'int' ) || type.includes( 'uv' ) || type.includes( 'iv' ) ? 'flat ' : '';
|
|
589
588
|
|
|
590
589
|
snippet += `${flat}in ${type} ${varying.name};\n`;
|
|
@@ -595,6 +594,12 @@ ${ flowData.code }
|
|
|
595
594
|
|
|
596
595
|
}
|
|
597
596
|
|
|
597
|
+
for ( const builtin of this.builtins[ shaderStage ] ) {
|
|
598
|
+
|
|
599
|
+
snippet += `${builtin};\n`;
|
|
600
|
+
|
|
601
|
+
}
|
|
602
|
+
|
|
598
603
|
return snippet;
|
|
599
604
|
|
|
600
605
|
}
|
|
@@ -701,24 +706,42 @@ ${ flowData.code }
|
|
|
701
706
|
|
|
702
707
|
}
|
|
703
708
|
|
|
709
|
+
getClipDistance() {
|
|
710
|
+
|
|
711
|
+
return 'gl_ClipDistance';
|
|
712
|
+
|
|
713
|
+
}
|
|
714
|
+
|
|
704
715
|
isAvailable( name ) {
|
|
705
716
|
|
|
706
717
|
let result = supports[ name ];
|
|
707
718
|
|
|
708
719
|
if ( result === undefined ) {
|
|
709
720
|
|
|
710
|
-
|
|
721
|
+
let extensionName;
|
|
711
722
|
|
|
712
|
-
|
|
723
|
+
result = false;
|
|
713
724
|
|
|
714
|
-
|
|
725
|
+
switch ( name ) {
|
|
715
726
|
|
|
716
|
-
|
|
717
|
-
|
|
727
|
+
case 'float32Filterable':
|
|
728
|
+
extensionName = 'OES_texture_float_linear';
|
|
729
|
+
break;
|
|
718
730
|
|
|
719
|
-
|
|
731
|
+
case 'clipDistance':
|
|
732
|
+
extensionName = 'WEBGL_clip_cull_distance';
|
|
733
|
+
break;
|
|
720
734
|
|
|
721
|
-
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
if ( extensionName !== undefined ) {
|
|
738
|
+
|
|
739
|
+
const extensions = this.renderer.backend.extensions;
|
|
740
|
+
|
|
741
|
+
if ( extensions.has( extensionName ) ) {
|
|
742
|
+
|
|
743
|
+
extensions.get( extensionName );
|
|
744
|
+
result = true;
|
|
722
745
|
|
|
723
746
|
}
|
|
724
747
|
|
|
@@ -738,6 +761,14 @@ ${ flowData.code }
|
|
|
738
761
|
|
|
739
762
|
}
|
|
740
763
|
|
|
764
|
+
enableHardwareClipping( planeCount ) {
|
|
765
|
+
|
|
766
|
+
this.enableExtension( 'GL_ANGLE_clip_cull_distance', 'require' );
|
|
767
|
+
|
|
768
|
+
this.builtins[ 'vertex' ].push( `out float gl_ClipDistance[ ${ planeCount } ]` );
|
|
769
|
+
|
|
770
|
+
}
|
|
771
|
+
|
|
741
772
|
registerTransform( varyingName, attributeNode ) {
|
|
742
773
|
|
|
743
774
|
this.transforms.push( { varyingName, attributeNode } );
|
|
@@ -41,6 +41,7 @@ class WebGLState {
|
|
|
41
41
|
this.currentStencilZPass = null;
|
|
42
42
|
this.currentStencilMask = null;
|
|
43
43
|
this.currentLineWidth = null;
|
|
44
|
+
this.currentClippingPlanes = 0;
|
|
44
45
|
|
|
45
46
|
this.currentBoundFramebuffers = {};
|
|
46
47
|
this.currentDrawbuffers = new WeakMap();
|
|
@@ -478,7 +479,7 @@ class WebGLState {
|
|
|
478
479
|
|
|
479
480
|
}
|
|
480
481
|
|
|
481
|
-
setMaterial( material, frontFaceCW ) {
|
|
482
|
+
setMaterial( material, frontFaceCW, hardwareClippingPlanes ) {
|
|
482
483
|
|
|
483
484
|
const { gl } = this;
|
|
484
485
|
|
|
@@ -516,6 +517,30 @@ class WebGLState {
|
|
|
516
517
|
? this.enable( gl.SAMPLE_ALPHA_TO_COVERAGE )
|
|
517
518
|
: this.disable( gl.SAMPLE_ALPHA_TO_COVERAGE );
|
|
518
519
|
|
|
520
|
+
if ( hardwareClippingPlanes > 0 ) {
|
|
521
|
+
|
|
522
|
+
if ( this.currentClippingPlanes !== hardwareClippingPlanes ) {
|
|
523
|
+
|
|
524
|
+
const CLIP_DISTANCE0_WEBGL = 0x3000;
|
|
525
|
+
|
|
526
|
+
for ( let i = 0; i < 8; i ++ ) {
|
|
527
|
+
|
|
528
|
+
if ( i < hardwareClippingPlanes ) {
|
|
529
|
+
|
|
530
|
+
this.enable( CLIP_DISTANCE0_WEBGL + i );
|
|
531
|
+
|
|
532
|
+
} else {
|
|
533
|
+
|
|
534
|
+
this.disable( CLIP_DISTANCE0_WEBGL + i );
|
|
535
|
+
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
}
|
|
543
|
+
|
|
519
544
|
}
|
|
520
545
|
|
|
521
546
|
setPolygonOffset( polygonOffset, factor, units ) {
|
|
@@ -415,7 +415,10 @@ class WebGLTextureUtils {
|
|
|
415
415
|
|
|
416
416
|
return source.image.data;
|
|
417
417
|
|
|
418
|
-
} else if (
|
|
418
|
+
} else if ( ( typeof HTMLImageElement !== 'undefined' && source instanceof HTMLImageElement ) ||
|
|
419
|
+
( typeof HTMLCanvasElement !== 'undefined' && source instanceof HTMLCanvasElement ) ||
|
|
420
|
+
( typeof ImageBitmap !== 'undefined' && source instanceof ImageBitmap ) ||
|
|
421
|
+
source instanceof OffscreenCanvas ) {
|
|
419
422
|
|
|
420
423
|
return source;
|
|
421
424
|
|
|
@@ -64,7 +64,7 @@ class WebGPUBackend extends Backend {
|
|
|
64
64
|
powerPreference: parameters.powerPreference
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
const adapter = await navigator.gpu.requestAdapter( adapterOptions );
|
|
67
|
+
const adapter = ( typeof navigator !== 'undefined' ) ? await navigator.gpu.requestAdapter( adapterOptions ) : null;
|
|
68
68
|
|
|
69
69
|
if ( adapter === null ) {
|
|
70
70
|
|
|
@@ -332,7 +332,7 @@ class WebGPUBackend extends Backend {
|
|
|
332
332
|
|
|
333
333
|
//
|
|
334
334
|
|
|
335
|
-
occlusionQuerySet = device.createQuerySet( { type: 'occlusion', count: occlusionQueryCount } );
|
|
335
|
+
occlusionQuerySet = device.createQuerySet( { type: 'occlusion', count: occlusionQueryCount, label: `occlusionQuerySet_${ renderContext.id }` } );
|
|
336
336
|
|
|
337
337
|
renderContextData.occlusionQuerySet = occlusionQuerySet;
|
|
338
338
|
renderContextData.occlusionQueryIndex = 0;
|
|
@@ -1061,7 +1061,7 @@ class WebGPUBackend extends Backend {
|
|
|
1061
1061
|
data.sampleCount !== sampleCount || data.colorSpace !== colorSpace ||
|
|
1062
1062
|
data.colorFormat !== colorFormat || data.depthStencilFormat !== depthStencilFormat ||
|
|
1063
1063
|
data.primitiveTopology !== primitiveTopology ||
|
|
1064
|
-
data.clippingContextCacheKey !== renderObject.
|
|
1064
|
+
data.clippingContextCacheKey !== renderObject.clippingContextCacheKey
|
|
1065
1065
|
) {
|
|
1066
1066
|
|
|
1067
1067
|
data.material = material; data.materialVersion = material.version;
|
|
@@ -1079,7 +1079,7 @@ class WebGPUBackend extends Backend {
|
|
|
1079
1079
|
data.colorFormat = colorFormat;
|
|
1080
1080
|
data.depthStencilFormat = depthStencilFormat;
|
|
1081
1081
|
data.primitiveTopology = primitiveTopology;
|
|
1082
|
-
data.clippingContextCacheKey = renderObject.
|
|
1082
|
+
data.clippingContextCacheKey = renderObject.clippingContextCacheKey;
|
|
1083
1083
|
|
|
1084
1084
|
needsUpdate = true;
|
|
1085
1085
|
|
|
@@ -1110,7 +1110,7 @@ class WebGPUBackend extends Backend {
|
|
|
1110
1110
|
utils.getCurrentColorSpace( renderContext ), utils.getCurrentColorFormat( renderContext ), utils.getCurrentDepthStencilFormat( renderContext ),
|
|
1111
1111
|
utils.getPrimitiveTopology( object, material ),
|
|
1112
1112
|
renderObject.getGeometryCacheKey(),
|
|
1113
|
-
renderObject.
|
|
1113
|
+
renderObject.clippingContextCacheKey
|
|
1114
1114
|
].join();
|
|
1115
1115
|
|
|
1116
1116
|
}
|
|
@@ -1174,9 +1174,9 @@ class WebGPUBackend extends Backend {
|
|
|
1174
1174
|
|
|
1175
1175
|
if ( ! renderContextData.timeStampQuerySet ) {
|
|
1176
1176
|
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
const timeStampQuerySet = this.device.createQuerySet( { type: 'timestamp', count: 2 } );
|
|
1177
|
+
|
|
1178
|
+
const type = renderContext.isComputeNode ? 'compute' : 'render';
|
|
1179
|
+
const timeStampQuerySet = this.device.createQuerySet( { type: 'timestamp', count: 2, label: `timestamp_${type}_${renderContext.id}` } );
|
|
1180
1180
|
|
|
1181
1181
|
const timestampWrites = {
|
|
1182
1182
|
querySet: timeStampQuerySet,
|
|
@@ -1184,9 +1184,7 @@ class WebGPUBackend extends Backend {
|
|
|
1184
1184
|
endOfPassWriteIndex: 1, // Write timestamp in index 1 when pass ends.
|
|
1185
1185
|
};
|
|
1186
1186
|
|
|
1187
|
-
Object.assign( descriptor, {
|
|
1188
|
-
timestampWrites,
|
|
1189
|
-
} );
|
|
1187
|
+
Object.assign( descriptor, { timestampWrites } );
|
|
1190
1188
|
|
|
1191
1189
|
renderContextData.timeStampQuerySet = timeStampQuerySet;
|
|
1192
1190
|
|
|
@@ -1217,18 +1215,21 @@ class WebGPUBackend extends Backend {
|
|
|
1217
1215
|
label: 'timestamp result buffer',
|
|
1218
1216
|
size: size,
|
|
1219
1217
|
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ,
|
|
1220
|
-
} )
|
|
1221
|
-
isMappingPending: false,
|
|
1218
|
+
} )
|
|
1222
1219
|
};
|
|
1223
1220
|
|
|
1224
1221
|
}
|
|
1225
1222
|
|
|
1226
|
-
const { resolveBuffer, resultBuffer
|
|
1223
|
+
const { resolveBuffer, resultBuffer } = renderContextData.currentTimestampQueryBuffers;
|
|
1227
1224
|
|
|
1228
|
-
if ( isMappingPending === true ) return;
|
|
1229
1225
|
|
|
1230
1226
|
encoder.resolveQuerySet( renderContextData.timeStampQuerySet, 0, 2, resolveBuffer, 0 );
|
|
1231
|
-
|
|
1227
|
+
|
|
1228
|
+
if ( resultBuffer.mapState === 'unmapped' ) {
|
|
1229
|
+
|
|
1230
|
+
encoder.copyBufferToBuffer( resolveBuffer, 0, resultBuffer, 0, size );
|
|
1231
|
+
|
|
1232
|
+
}
|
|
1232
1233
|
|
|
1233
1234
|
}
|
|
1234
1235
|
|
|
@@ -1240,25 +1241,26 @@ class WebGPUBackend extends Backend {
|
|
|
1240
1241
|
|
|
1241
1242
|
if ( renderContextData.currentTimestampQueryBuffers === undefined ) return;
|
|
1242
1243
|
|
|
1243
|
-
const { resultBuffer
|
|
1244
|
+
const { resultBuffer } = renderContextData.currentTimestampQueryBuffers;
|
|
1244
1245
|
|
|
1245
|
-
|
|
1246
|
+
await this.device.queue.onSubmittedWorkDone();
|
|
1246
1247
|
|
|
1247
|
-
|
|
1248
|
+
if ( resultBuffer.mapState === 'unmapped' ) {
|
|
1248
1249
|
|
|
1249
|
-
|
|
1250
|
+
resultBuffer.mapAsync( GPUMapMode.READ ).then( () => {
|
|
1250
1251
|
|
|
1251
|
-
|
|
1252
|
-
|
|
1252
|
+
const times = new BigUint64Array( resultBuffer.getMappedRange() );
|
|
1253
|
+
const duration = Number( times[ 1 ] - times[ 0 ] ) / 1000000;
|
|
1253
1254
|
|
|
1254
1255
|
|
|
1255
|
-
|
|
1256
|
+
this.renderer.info.updateTimestamp( type, duration );
|
|
1256
1257
|
|
|
1257
|
-
|
|
1258
|
+
resultBuffer.unmap();
|
|
1258
1259
|
|
|
1259
|
-
renderContextData.currentTimestampQueryBuffers.isMappingPending = false;
|
|
1260
1260
|
|
|
1261
|
-
|
|
1261
|
+
} );
|
|
1262
|
+
|
|
1263
|
+
}
|
|
1262
1264
|
|
|
1263
1265
|
}
|
|
1264
1266
|
|
|
@@ -1341,15 +1343,15 @@ class WebGPUBackend extends Backend {
|
|
|
1341
1343
|
|
|
1342
1344
|
// bindings
|
|
1343
1345
|
|
|
1344
|
-
createBindings( bindGroup ) {
|
|
1346
|
+
createBindings( bindGroup, bindings, cacheIndex, version ) {
|
|
1345
1347
|
|
|
1346
|
-
this.bindingUtils.createBindings( bindGroup );
|
|
1348
|
+
this.bindingUtils.createBindings( bindGroup, bindings, cacheIndex, version );
|
|
1347
1349
|
|
|
1348
1350
|
}
|
|
1349
1351
|
|
|
1350
|
-
updateBindings( bindGroup ) {
|
|
1352
|
+
updateBindings( bindGroup, bindings, cacheIndex, version ) {
|
|
1351
1353
|
|
|
1352
|
-
this.bindingUtils.createBindings( bindGroup );
|
|
1354
|
+
this.bindingUtils.createBindings( bindGroup, bindings, cacheIndex, version );
|
|
1353
1355
|
|
|
1354
1356
|
}
|
|
1355
1357
|
|
|
@@ -1537,7 +1539,7 @@ class WebGPUBackend extends Backend {
|
|
|
1537
1539
|
encoder.copyTextureToTexture(
|
|
1538
1540
|
{
|
|
1539
1541
|
texture: sourceGPU,
|
|
1540
|
-
origin:
|
|
1542
|
+
origin: [ rectangle.x, rectangle.y, 0 ],
|
|
1541
1543
|
},
|
|
1542
1544
|
{
|
|
1543
1545
|
texture: destinationGPU
|
|
@@ -1566,6 +1568,20 @@ class WebGPUBackend extends Backend {
|
|
|
1566
1568
|
renderContextData.currentPass = encoder.beginRenderPass( descriptor );
|
|
1567
1569
|
renderContextData.currentSets = { attributes: {}, bindingGroups: [], pipeline: null, index: null };
|
|
1568
1570
|
|
|
1571
|
+
if ( renderContext.viewport ) {
|
|
1572
|
+
|
|
1573
|
+
this.updateViewport( renderContext );
|
|
1574
|
+
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
if ( renderContext.scissor ) {
|
|
1578
|
+
|
|
1579
|
+
const { x, y, width, height } = renderContext.scissorValue;
|
|
1580
|
+
|
|
1581
|
+
renderContextData.currentPass.setScissorRect( x, y, width, height );
|
|
1582
|
+
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1569
1585
|
} else {
|
|
1570
1586
|
|
|
1571
1587
|
this.device.queue.submit( [ encoder.finish() ] );
|
|
@@ -1,31 +1,18 @@
|
|
|
1
1
|
import NodeLibrary from '../../common/nodes/NodeLibrary.js';
|
|
2
2
|
|
|
3
3
|
// Materials
|
|
4
|
-
import { MeshPhongMaterial } from '../../../materials/MeshPhongMaterial.js';
|
|
5
4
|
import MeshPhongNodeMaterial from '../../../materials/nodes/MeshPhongNodeMaterial.js';
|
|
6
|
-
import { MeshStandardMaterial } from '../../../materials/MeshStandardMaterial.js';
|
|
7
5
|
import MeshStandardNodeMaterial from '../../../materials/nodes/MeshStandardNodeMaterial.js';
|
|
8
|
-
import { MeshPhysicalMaterial } from '../../../materials/MeshPhysicalMaterial.js';
|
|
9
6
|
import MeshPhysicalNodeMaterial from '../../../materials/nodes/MeshPhysicalNodeMaterial.js';
|
|
10
|
-
import { MeshToonMaterial } from '../../../materials/MeshToonMaterial.js';
|
|
11
7
|
import MeshToonNodeMaterial from '../../../materials/nodes/MeshToonNodeMaterial.js';
|
|
12
|
-
import { MeshBasicMaterial } from '../../../materials/MeshBasicMaterial.js';
|
|
13
8
|
import MeshBasicNodeMaterial from '../../../materials/nodes/MeshBasicNodeMaterial.js';
|
|
14
|
-
import { MeshLambertMaterial } from '../../../materials/MeshLambertMaterial.js';
|
|
15
9
|
import MeshLambertNodeMaterial from '../../../materials/nodes/MeshLambertNodeMaterial.js';
|
|
16
|
-
import { MeshNormalMaterial } from '../../../materials/MeshNormalMaterial.js';
|
|
17
10
|
import MeshNormalNodeMaterial from '../../../materials/nodes/MeshNormalNodeMaterial.js';
|
|
18
|
-
import { MeshMatcapMaterial } from '../../../materials/MeshMatcapMaterial.js';
|
|
19
11
|
import MeshMatcapNodeMaterial from '../../../materials/nodes/MeshMatcapNodeMaterial.js';
|
|
20
|
-
import { LineBasicMaterial } from '../../../materials/LineBasicMaterial.js';
|
|
21
12
|
import LineBasicNodeMaterial from '../../../materials/nodes/LineBasicNodeMaterial.js';
|
|
22
|
-
import { LineDashedMaterial } from '../../../materials/LineDashedMaterial.js';
|
|
23
13
|
import LineDashedNodeMaterial from '../../../materials/nodes/LineDashedNodeMaterial.js';
|
|
24
|
-
import { PointsMaterial } from '../../../materials/PointsMaterial.js';
|
|
25
14
|
import PointsNodeMaterial from '../../../materials/nodes/PointsNodeMaterial.js';
|
|
26
|
-
import { SpriteMaterial } from '../../../materials/SpriteMaterial.js';
|
|
27
15
|
import SpriteNodeMaterial from '../../../materials/nodes/SpriteNodeMaterial.js';
|
|
28
|
-
import { ShadowMaterial } from '../../../materials/ShadowMaterial.js';
|
|
29
16
|
import ShadowNodeMaterial from '../../../materials/nodes/ShadowNodeMaterial.js';
|
|
30
17
|
//import { MeshDepthMaterial } from '../../../materials/MeshDepthMaterial.js';
|
|
31
18
|
//import MeshDepthNodeMaterial from '../../../materials/nodes/MeshDepthNodeMaterial.js';
|
|
@@ -60,19 +47,19 @@ class StandardNodeLibrary extends NodeLibrary {
|
|
|
60
47
|
|
|
61
48
|
super();
|
|
62
49
|
|
|
63
|
-
this.addMaterial( MeshPhongNodeMaterial, MeshPhongMaterial );
|
|
64
|
-
this.addMaterial( MeshStandardNodeMaterial, MeshStandardMaterial );
|
|
65
|
-
this.addMaterial( MeshPhysicalNodeMaterial, MeshPhysicalMaterial );
|
|
66
|
-
this.addMaterial( MeshToonNodeMaterial, MeshToonMaterial );
|
|
67
|
-
this.addMaterial( MeshBasicNodeMaterial, MeshBasicMaterial );
|
|
68
|
-
this.addMaterial( MeshLambertNodeMaterial, MeshLambertMaterial );
|
|
69
|
-
this.addMaterial( MeshNormalNodeMaterial, MeshNormalMaterial );
|
|
70
|
-
this.addMaterial( MeshMatcapNodeMaterial, MeshMatcapMaterial );
|
|
71
|
-
this.addMaterial( LineBasicNodeMaterial, LineBasicMaterial );
|
|
72
|
-
this.addMaterial( LineDashedNodeMaterial, LineDashedMaterial );
|
|
73
|
-
this.addMaterial( PointsNodeMaterial, PointsMaterial );
|
|
74
|
-
this.addMaterial( SpriteNodeMaterial, SpriteMaterial );
|
|
75
|
-
this.addMaterial( ShadowNodeMaterial, ShadowMaterial );
|
|
50
|
+
this.addMaterial( MeshPhongNodeMaterial, 'MeshPhongMaterial' );
|
|
51
|
+
this.addMaterial( MeshStandardNodeMaterial, 'MeshStandardMaterial' );
|
|
52
|
+
this.addMaterial( MeshPhysicalNodeMaterial, 'MeshPhysicalMaterial' );
|
|
53
|
+
this.addMaterial( MeshToonNodeMaterial, 'MeshToonMaterial' );
|
|
54
|
+
this.addMaterial( MeshBasicNodeMaterial, 'MeshBasicMaterial' );
|
|
55
|
+
this.addMaterial( MeshLambertNodeMaterial, 'MeshLambertMaterial' );
|
|
56
|
+
this.addMaterial( MeshNormalNodeMaterial, 'MeshNormalMaterial' );
|
|
57
|
+
this.addMaterial( MeshMatcapNodeMaterial, 'MeshMatcapMaterial' );
|
|
58
|
+
this.addMaterial( LineBasicNodeMaterial, 'LineBasicMaterial' );
|
|
59
|
+
this.addMaterial( LineDashedNodeMaterial, 'LineDashedMaterial' );
|
|
60
|
+
this.addMaterial( PointsNodeMaterial, 'PointsMaterial' );
|
|
61
|
+
this.addMaterial( SpriteNodeMaterial, 'SpriteMaterial' );
|
|
62
|
+
this.addMaterial( ShadowNodeMaterial, 'ShadowMaterial' );
|
|
76
63
|
|
|
77
64
|
this.addLight( PointLightNode, PointLight );
|
|
78
65
|
this.addLight( DirectionalLightNode, DirectionalLight );
|