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
|
@@ -6,18 +6,14 @@ import default_fragment from '../renderers/shaders/ShaderChunk/default_fragment.
|
|
|
6
6
|
|
|
7
7
|
class ShaderMaterial extends Material {
|
|
8
8
|
|
|
9
|
-
static get type() {
|
|
10
|
-
|
|
11
|
-
return 'ShaderMaterial';
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
9
|
constructor( parameters ) {
|
|
16
10
|
|
|
17
11
|
super();
|
|
18
12
|
|
|
19
13
|
this.isShaderMaterial = true;
|
|
20
14
|
|
|
15
|
+
this.type = 'ShaderMaterial';
|
|
16
|
+
|
|
21
17
|
this.defines = {};
|
|
22
18
|
this.uniforms = {};
|
|
23
19
|
this.uniformsGroups = [];
|
|
@@ -3,18 +3,14 @@ import { Color } from '../math/Color.js';
|
|
|
3
3
|
|
|
4
4
|
class ShadowMaterial extends Material {
|
|
5
5
|
|
|
6
|
-
static get type() {
|
|
7
|
-
|
|
8
|
-
return 'ShadowMaterial';
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
6
|
constructor( parameters ) {
|
|
13
7
|
|
|
14
8
|
super();
|
|
15
9
|
|
|
16
10
|
this.isShadowMaterial = true;
|
|
17
11
|
|
|
12
|
+
this.type = 'ShadowMaterial';
|
|
13
|
+
|
|
18
14
|
this.color = new Color( 0x000000 );
|
|
19
15
|
this.transparent = true;
|
|
20
16
|
|
|
@@ -3,18 +3,14 @@ import { Color } from '../math/Color.js';
|
|
|
3
3
|
|
|
4
4
|
class SpriteMaterial extends Material {
|
|
5
5
|
|
|
6
|
-
static get type() {
|
|
7
|
-
|
|
8
|
-
return 'SpriteMaterial';
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
6
|
constructor( parameters ) {
|
|
13
7
|
|
|
14
8
|
super();
|
|
15
9
|
|
|
16
10
|
this.isSpriteMaterial = true;
|
|
17
11
|
|
|
12
|
+
this.type = 'SpriteMaterial';
|
|
13
|
+
|
|
18
14
|
this.color = new Color( 0xffffff );
|
|
19
15
|
|
|
20
16
|
this.map = null;
|
|
@@ -2,16 +2,18 @@ import NodeMaterial from './NodeMaterial.js';
|
|
|
2
2
|
import { varyingProperty } from '../../nodes/core/PropertyNode.js';
|
|
3
3
|
import { attribute } from '../../nodes/core/AttributeNode.js';
|
|
4
4
|
import { cameraProjectionMatrix } from '../../nodes/accessors/Camera.js';
|
|
5
|
-
import { materialColor, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineDashOffset, materialLineWidth } from '../../nodes/accessors/MaterialNode.js';
|
|
5
|
+
import { materialColor, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineDashOffset, materialLineWidth, materialOpacity } from '../../nodes/accessors/MaterialNode.js';
|
|
6
6
|
import { modelViewMatrix } from '../../nodes/accessors/ModelNode.js';
|
|
7
7
|
import { positionGeometry } from '../../nodes/accessors/Position.js';
|
|
8
8
|
import { mix, smoothstep } from '../../nodes/math/MathNode.js';
|
|
9
|
-
import { Fn,
|
|
9
|
+
import { Fn, float, vec2, vec3, vec4, If } from '../../nodes/tsl/TSLBase.js';
|
|
10
10
|
import { uv } from '../../nodes/accessors/UV.js';
|
|
11
11
|
import { viewport } from '../../nodes/display/ScreenNode.js';
|
|
12
12
|
import { dashSize, gapSize } from '../../nodes/core/PropertyNode.js';
|
|
13
|
+
import { viewportSharedTexture } from '../../nodes/display/ViewportSharedTextureNode.js';
|
|
13
14
|
|
|
14
15
|
import { LineDashedMaterial } from '../LineDashedMaterial.js';
|
|
16
|
+
import { NoBlending } from '../../constants.js';
|
|
15
17
|
|
|
16
18
|
const _defaultValues = /*@__PURE__*/ new LineDashedMaterial();
|
|
17
19
|
|
|
@@ -46,6 +48,8 @@ class Line2NodeMaterial extends NodeMaterial {
|
|
|
46
48
|
this.dashSizeNode = null;
|
|
47
49
|
this.gapSizeNode = null;
|
|
48
50
|
|
|
51
|
+
this.blending = NoBlending;
|
|
52
|
+
|
|
49
53
|
this.setValues( params );
|
|
50
54
|
|
|
51
55
|
}
|
|
@@ -94,6 +98,21 @@ class Line2NodeMaterial extends NodeMaterial {
|
|
|
94
98
|
const start = vec4( modelViewMatrix.mul( vec4( instanceStart, 1.0 ) ) ).toVar( 'start' );
|
|
95
99
|
const end = vec4( modelViewMatrix.mul( vec4( instanceEnd, 1.0 ) ) ).toVar( 'end' );
|
|
96
100
|
|
|
101
|
+
if ( useDash ) {
|
|
102
|
+
|
|
103
|
+
const dashScaleNode = this.dashScaleNode ? float( this.dashScaleNode ) : materialLineScale;
|
|
104
|
+
const offsetNode = this.offsetNode ? float( this.offsetNodeNode ) : materialLineDashOffset;
|
|
105
|
+
|
|
106
|
+
const instanceDistanceStart = attribute( 'instanceDistanceStart' );
|
|
107
|
+
const instanceDistanceEnd = attribute( 'instanceDistanceEnd' );
|
|
108
|
+
|
|
109
|
+
let lineDistance = positionGeometry.y.lessThan( 0.5 ).select( dashScaleNode.mul( instanceDistanceStart ), dashScaleNode.mul( instanceDistanceEnd ) );
|
|
110
|
+
lineDistance = lineDistance.add( offsetNode );
|
|
111
|
+
|
|
112
|
+
varyingProperty( 'float', 'lineDistance' ).assign( lineDistance );
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
97
116
|
if ( useWorldUnits ) {
|
|
98
117
|
|
|
99
118
|
varyingProperty( 'vec3', 'worldStart' ).assign( start.xyz );
|
|
@@ -252,30 +271,22 @@ class Line2NodeMaterial extends NodeMaterial {
|
|
|
252
271
|
|
|
253
272
|
} );
|
|
254
273
|
|
|
255
|
-
this.
|
|
274
|
+
this.colorNode = Fn( () => {
|
|
256
275
|
|
|
257
276
|
const vUv = uv();
|
|
258
277
|
|
|
259
278
|
if ( useDash ) {
|
|
260
279
|
|
|
261
|
-
const offsetNode = this.offsetNode ? float( this.offsetNodeNode ) : materialLineDashOffset;
|
|
262
|
-
const dashScaleNode = this.dashScaleNode ? float( this.dashScaleNode ) : materialLineScale;
|
|
263
280
|
const dashSizeNode = this.dashSizeNode ? float( this.dashSizeNode ) : materialLineDashSize;
|
|
264
281
|
const gapSizeNode = this.dashSizeNode ? float( this.dashGapNode ) : materialLineGapSize;
|
|
265
282
|
|
|
266
283
|
dashSize.assign( dashSizeNode );
|
|
267
284
|
gapSize.assign( gapSizeNode );
|
|
268
285
|
|
|
269
|
-
const
|
|
270
|
-
const instanceDistanceEnd = attribute( 'instanceDistanceEnd' );
|
|
271
|
-
|
|
272
|
-
const lineDistance = positionGeometry.y.lessThan( 0.5 ).select( dashScaleNode.mul( instanceDistanceStart ), materialLineScale.mul( instanceDistanceEnd ) );
|
|
273
|
-
|
|
274
|
-
const vLineDistance = varying( lineDistance.add( materialLineDashOffset ) );
|
|
275
|
-
const vLineDistanceOffset = offsetNode ? vLineDistance.add( offsetNode ) : vLineDistance;
|
|
286
|
+
const vLineDistance = varyingProperty( 'float', 'lineDistance' );
|
|
276
287
|
|
|
277
288
|
vUv.y.lessThan( - 1.0 ).or( vUv.y.greaterThan( 1.0 ) ).discard(); // discard endcaps
|
|
278
|
-
|
|
289
|
+
vLineDistance.mod( dashSize.add( gapSize ) ).greaterThan( dashSize ).discard(); // todo - FIX
|
|
279
290
|
|
|
280
291
|
}
|
|
281
292
|
|
|
@@ -376,6 +387,14 @@ class Line2NodeMaterial extends NodeMaterial {
|
|
|
376
387
|
|
|
377
388
|
} )();
|
|
378
389
|
|
|
390
|
+
if ( this.transparent ) {
|
|
391
|
+
|
|
392
|
+
const opacityNode = this.opacityNode ? float( this.opacityNode ) : materialOpacity;
|
|
393
|
+
|
|
394
|
+
this.outputNode = vec4( this.colorNode.rgb.mul( opacityNode ).add( viewportSharedTexture().rgb.mul( opacityNode.oneMinus() ) ), this.colorNode.a );
|
|
395
|
+
|
|
396
|
+
}
|
|
397
|
+
|
|
379
398
|
}
|
|
380
399
|
|
|
381
400
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import NodeMaterial from './NodeMaterial.js';
|
|
2
2
|
import { attribute } from '../../nodes/core/AttributeNode.js';
|
|
3
|
-
import { materialLineDashSize, materialLineGapSize, materialLineScale } from '../../nodes/accessors/MaterialNode.js';
|
|
3
|
+
import { materialLineDashOffset, materialLineDashSize, materialLineGapSize, materialLineScale } from '../../nodes/accessors/MaterialNode.js';
|
|
4
4
|
import { dashSize, gapSize } from '../../nodes/core/PropertyNode.js';
|
|
5
5
|
import { varying, float } from '../../nodes/tsl/TSLBase.js';
|
|
6
6
|
|
|
@@ -26,6 +26,8 @@ class LineDashedNodeMaterial extends NodeMaterial {
|
|
|
26
26
|
|
|
27
27
|
this.setDefaultValues( _defaultValues );
|
|
28
28
|
|
|
29
|
+
this.dashOffset = 0;
|
|
30
|
+
|
|
29
31
|
this.offsetNode = null;
|
|
30
32
|
this.dashScaleNode = null;
|
|
31
33
|
this.dashSizeNode = null;
|
|
@@ -37,7 +39,7 @@ class LineDashedNodeMaterial extends NodeMaterial {
|
|
|
37
39
|
|
|
38
40
|
setupVariants() {
|
|
39
41
|
|
|
40
|
-
const offsetNode = this.offsetNode;
|
|
42
|
+
const offsetNode = this.offsetNode ? float( this.offsetNodeNode ) : materialLineDashOffset;
|
|
41
43
|
const dashScaleNode = this.dashScaleNode ? float( this.dashScaleNode ) : materialLineScale;
|
|
42
44
|
const dashSizeNode = this.dashSizeNode ? float( this.dashSizeNode ) : materialLineDashSize;
|
|
43
45
|
const gapSizeNode = this.dashSizeNode ? float( this.dashGapNode ) : materialLineGapSize;
|
|
@@ -7,7 +7,7 @@ import { output, diffuseColor, emissive, varyingProperty } from '../../nodes/cor
|
|
|
7
7
|
import { materialAlphaTest, materialColor, materialOpacity, materialEmissive, materialNormal, materialLightMap, materialAOMap } from '../../nodes/accessors/MaterialNode.js';
|
|
8
8
|
import { modelViewProjection } from '../../nodes/accessors/ModelViewProjectionNode.js';
|
|
9
9
|
import { normalLocal } from '../../nodes/accessors/Normal.js';
|
|
10
|
-
import {
|
|
10
|
+
import { instancedMesh } from '../../nodes/accessors/InstancedMeshNode.js';
|
|
11
11
|
import { batch } from '../../nodes/accessors/BatchNode.js';
|
|
12
12
|
import { materialReference } from '../../nodes/accessors/MaterialReferenceNode.js';
|
|
13
13
|
import { positionLocal, positionView } from '../../nodes/accessors/Position.js';
|
|
@@ -18,9 +18,9 @@ import { float, vec3, vec4 } from '../../nodes/tsl/TSLBase.js';
|
|
|
18
18
|
import AONode from '../../nodes/lighting/AONode.js';
|
|
19
19
|
import { lightingContext } from '../../nodes/lighting/LightingContextNode.js';
|
|
20
20
|
import IrradianceNode from '../../nodes/lighting/IrradianceNode.js';
|
|
21
|
-
import { depth,
|
|
21
|
+
import { depth, viewZToLogarithmicDepth, viewZToOrthographicDepth } from '../../nodes/display/ViewportDepthNode.js';
|
|
22
22
|
import { cameraFar, cameraNear } from '../../nodes/accessors/Camera.js';
|
|
23
|
-
import { clipping, clippingAlpha } from '../../nodes/accessors/ClippingNode.js';
|
|
23
|
+
import { clipping, clippingAlpha, hardwareClipping } from '../../nodes/accessors/ClippingNode.js';
|
|
24
24
|
import NodeMaterialObserver from './manager/NodeMaterialObserver.js';
|
|
25
25
|
import getAlphaHashThreshold from '../../nodes/functions/material/getAlphaHashThreshold.js';
|
|
26
26
|
|
|
@@ -32,18 +32,25 @@ class NodeMaterial extends Material {
|
|
|
32
32
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
get type() {
|
|
36
|
+
|
|
37
|
+
return this.constructor.type;
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
set type( _value ) { /* */ }
|
|
42
|
+
|
|
35
43
|
constructor() {
|
|
36
44
|
|
|
37
45
|
super();
|
|
38
46
|
|
|
39
47
|
this.isNodeMaterial = true;
|
|
40
48
|
|
|
41
|
-
this.type = this.constructor.type;
|
|
42
|
-
|
|
43
49
|
this.forceSinglePass = false;
|
|
44
50
|
|
|
45
51
|
this.fog = true;
|
|
46
52
|
this.lights = false;
|
|
53
|
+
this.hardwareClipping = false;
|
|
47
54
|
|
|
48
55
|
this.lightsNode = null;
|
|
49
56
|
this.envNode = null;
|
|
@@ -60,8 +67,9 @@ class NodeMaterial extends Material {
|
|
|
60
67
|
this.geometryNode = null;
|
|
61
68
|
|
|
62
69
|
this.depthNode = null;
|
|
63
|
-
this.shadowNode = null;
|
|
64
70
|
this.shadowPositionNode = null;
|
|
71
|
+
this.receivedShadowNode = null;
|
|
72
|
+
this.castShadowNode = null;
|
|
65
73
|
|
|
66
74
|
this.outputNode = null;
|
|
67
75
|
this.mrtNode = null;
|
|
@@ -93,6 +101,9 @@ class NodeMaterial extends Material {
|
|
|
93
101
|
|
|
94
102
|
builder.context.setupNormal = () => this.setupNormal( builder );
|
|
95
103
|
|
|
104
|
+
const renderer = builder.renderer;
|
|
105
|
+
const renderTarget = renderer.getRenderTarget();
|
|
106
|
+
|
|
96
107
|
// < VERTEX STAGE >
|
|
97
108
|
|
|
98
109
|
builder.addStack();
|
|
@@ -115,7 +126,21 @@ class NodeMaterial extends Material {
|
|
|
115
126
|
|
|
116
127
|
const clippingNode = this.setupClipping( builder );
|
|
117
128
|
|
|
118
|
-
if ( this.depthWrite === true )
|
|
129
|
+
if ( this.depthWrite === true ) {
|
|
130
|
+
|
|
131
|
+
// only write depth if depth buffer is configured
|
|
132
|
+
|
|
133
|
+
if ( renderTarget !== null ) {
|
|
134
|
+
|
|
135
|
+
if ( renderTarget.depthBuffer === true ) this.setupDepth( builder );
|
|
136
|
+
|
|
137
|
+
} else {
|
|
138
|
+
|
|
139
|
+
if ( renderer.depth === true ) this.setupDepth( builder );
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
}
|
|
119
144
|
|
|
120
145
|
if ( this.fragmentNode === null ) {
|
|
121
146
|
|
|
@@ -142,11 +167,9 @@ class NodeMaterial extends Material {
|
|
|
142
167
|
|
|
143
168
|
// MRT
|
|
144
169
|
|
|
145
|
-
const renderTarget = builder.renderer.getRenderTarget();
|
|
146
|
-
|
|
147
170
|
if ( renderTarget !== null ) {
|
|
148
171
|
|
|
149
|
-
const mrt =
|
|
172
|
+
const mrt = renderer.getMRT();
|
|
150
173
|
const materialMRT = this.mrtNode;
|
|
151
174
|
|
|
152
175
|
if ( mrt !== null ) {
|
|
@@ -195,11 +218,11 @@ class NodeMaterial extends Material {
|
|
|
195
218
|
|
|
196
219
|
if ( builder.clippingContext === null ) return null;
|
|
197
220
|
|
|
198
|
-
const {
|
|
221
|
+
const { unionPlanes, intersectionPlanes } = builder.clippingContext;
|
|
199
222
|
|
|
200
223
|
let result = null;
|
|
201
224
|
|
|
202
|
-
if (
|
|
225
|
+
if ( unionPlanes.length > 0 || intersectionPlanes.length > 0 ) {
|
|
203
226
|
|
|
204
227
|
const samples = builder.renderer.samples;
|
|
205
228
|
|
|
@@ -220,6 +243,28 @@ class NodeMaterial extends Material {
|
|
|
220
243
|
|
|
221
244
|
}
|
|
222
245
|
|
|
246
|
+
setupHardwareClipping( builder ) {
|
|
247
|
+
|
|
248
|
+
this.hardwareClipping = false;
|
|
249
|
+
|
|
250
|
+
if ( builder.clippingContext === null ) return;
|
|
251
|
+
|
|
252
|
+
const candidateCount = builder.clippingContext.unionPlanes.length;
|
|
253
|
+
|
|
254
|
+
// 8 planes supported by WebGL ANGLE_clip_cull_distance and WebGPU clip-distances
|
|
255
|
+
|
|
256
|
+
if ( candidateCount > 0 && candidateCount <= 8 && builder.isAvailable( 'clipDistance' ) ) {
|
|
257
|
+
|
|
258
|
+
builder.stack.add( hardwareClipping() );
|
|
259
|
+
|
|
260
|
+
this.hardwareClipping = true;
|
|
261
|
+
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return;
|
|
265
|
+
|
|
266
|
+
}
|
|
267
|
+
|
|
223
268
|
setupDepth( builder ) {
|
|
224
269
|
|
|
225
270
|
const { renderer, camera } = builder;
|
|
@@ -240,7 +285,7 @@ class NodeMaterial extends Material {
|
|
|
240
285
|
|
|
241
286
|
if ( camera.isPerspectiveCamera ) {
|
|
242
287
|
|
|
243
|
-
depthNode =
|
|
288
|
+
depthNode = viewZToLogarithmicDepth( positionView.z, cameraNear, cameraFar );
|
|
244
289
|
|
|
245
290
|
} else {
|
|
246
291
|
|
|
@@ -297,9 +342,9 @@ class NodeMaterial extends Material {
|
|
|
297
342
|
|
|
298
343
|
}
|
|
299
344
|
|
|
300
|
-
if ( ( object.instanceMatrix && object.instanceMatrix.isInstancedBufferAttribute === true ) ) {
|
|
345
|
+
if ( ( object.isInstancedMesh && object.instanceMatrix && object.instanceMatrix.isInstancedBufferAttribute === true ) ) {
|
|
301
346
|
|
|
302
|
-
|
|
347
|
+
instancedMesh( object ).append();
|
|
303
348
|
|
|
304
349
|
}
|
|
305
350
|
|
|
@@ -309,6 +354,8 @@ class NodeMaterial extends Material {
|
|
|
309
354
|
|
|
310
355
|
}
|
|
311
356
|
|
|
357
|
+
this.setupHardwareClipping( builder );
|
|
358
|
+
|
|
312
359
|
const mvp = modelViewProjection();
|
|
313
360
|
|
|
314
361
|
builder.context.vertex = builder.removeStack();
|
|
@@ -646,8 +693,9 @@ class NodeMaterial extends Material {
|
|
|
646
693
|
this.geometryNode = source.geometryNode;
|
|
647
694
|
|
|
648
695
|
this.depthNode = source.depthNode;
|
|
649
|
-
this.shadowNode = source.shadowNode;
|
|
650
696
|
this.shadowPositionNode = source.shadowPositionNode;
|
|
697
|
+
this.receivedShadowNode = source.receivedShadowNode;
|
|
698
|
+
this.castShadowNode = source.castShadowNode;
|
|
651
699
|
|
|
652
700
|
this.outputNode = source.outputNode;
|
|
653
701
|
this.mrtNode = source.mrtNode;
|
|
@@ -85,7 +85,7 @@ class NodeMaterialObserver {
|
|
|
85
85
|
|
|
86
86
|
if ( data === undefined ) {
|
|
87
87
|
|
|
88
|
-
const { geometry, material } = renderObject;
|
|
88
|
+
const { geometry, material, object } = renderObject;
|
|
89
89
|
|
|
90
90
|
data = {
|
|
91
91
|
material: this.getMaterialData( material ),
|
|
@@ -94,18 +94,18 @@ class NodeMaterialObserver {
|
|
|
94
94
|
indexVersion: geometry.index ? geometry.index.version : null,
|
|
95
95
|
drawRange: { start: geometry.drawRange.start, count: geometry.drawRange.count }
|
|
96
96
|
},
|
|
97
|
-
worldMatrix:
|
|
97
|
+
worldMatrix: object.matrixWorld.clone()
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
if (
|
|
100
|
+
if ( object.center ) {
|
|
101
101
|
|
|
102
|
-
data.center =
|
|
102
|
+
data.center = object.center.clone();
|
|
103
103
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
if (
|
|
106
|
+
if ( object.morphTargetInfluences ) {
|
|
107
107
|
|
|
108
|
-
data.morphTargetInfluences =
|
|
108
|
+
data.morphTargetInfluences = object.morphTargetInfluences.slice();
|
|
109
109
|
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -289,7 +289,8 @@ class NodeMaterialObserver {
|
|
|
289
289
|
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
//
|
|
292
|
+
// compare each attribute
|
|
293
|
+
|
|
293
294
|
for ( const name of storedAttributeNames ) {
|
|
294
295
|
|
|
295
296
|
const storedAttributeData = storedAttributes[ name ];
|
|
@@ -297,7 +298,7 @@ class NodeMaterialObserver {
|
|
|
297
298
|
|
|
298
299
|
if ( attribute === undefined ) {
|
|
299
300
|
|
|
300
|
-
//
|
|
301
|
+
// attribute was removed
|
|
301
302
|
delete storedAttributes[ name ];
|
|
302
303
|
return false;
|
|
303
304
|
|
|
@@ -312,7 +313,8 @@ class NodeMaterialObserver {
|
|
|
312
313
|
|
|
313
314
|
}
|
|
314
315
|
|
|
315
|
-
//
|
|
316
|
+
// check index
|
|
317
|
+
|
|
316
318
|
const index = geometry.index;
|
|
317
319
|
const storedIndexVersion = storedGeometryData.indexVersion;
|
|
318
320
|
const currentIndexVersion = index ? index.version : null;
|
|
@@ -324,7 +326,8 @@ class NodeMaterialObserver {
|
|
|
324
326
|
|
|
325
327
|
}
|
|
326
328
|
|
|
327
|
-
//
|
|
329
|
+
// check drawRange
|
|
330
|
+
|
|
328
331
|
if ( storedGeometryData.drawRange.start !== geometry.drawRange.start || storedGeometryData.drawRange.count !== geometry.drawRange.count ) {
|
|
329
332
|
|
|
330
333
|
storedGeometryData.drawRange.start = geometry.drawRange.start;
|