super-three 0.169.1 → 0.170.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 +24628 -24228
- package/build/three.core.js +37002 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +10519 -47108
- 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 +17071 -53583
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +17134 -53623
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +3 -3
- package/examples/jsm/animation/MMDAnimationHelper.js +2 -0
- package/examples/jsm/animation/MMDPhysics.js +2 -0
- 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/controls/TransformControls.js +22 -6
- package/examples/jsm/csm/CSM.js +2 -2
- package/examples/jsm/csm/CSMFrustum.js +7 -4
- package/examples/jsm/csm/CSMHelper.js +2 -0
- package/examples/jsm/csm/CSMShadowNode.js +437 -0
- package/examples/jsm/curves/NURBSCurve.js +34 -3
- package/examples/jsm/exporters/GLTFExporter.js +138 -71
- package/examples/jsm/exporters/KTX2Exporter.js +35 -12
- package/examples/jsm/exporters/MMDExporter.js +6 -0
- package/examples/jsm/exporters/USDZExporter.js +21 -3
- package/examples/jsm/geometries/DecalGeometry.js +70 -21
- package/examples/jsm/geometries/InstancedPointsGeometry.js +2 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +175 -0
- package/examples/jsm/interactive/HTMLMesh.js +1 -0
- package/examples/jsm/lighting/TiledLighting.js +18 -0
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/lines/LineGeometry.js +25 -0
- package/examples/jsm/lines/LineMaterial.js +0 -1
- package/examples/jsm/lines/LineSegmentsGeometry.js +2 -0
- package/examples/jsm/lines/webgpu/Line2.js +2 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +2 -16
- package/examples/jsm/lines/webgpu/Wireframe.js +57 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -0
- package/examples/jsm/loaders/3MFLoader.js +91 -0
- package/examples/jsm/loaders/FBXLoader.js +12 -2
- package/examples/jsm/loaders/GLTFLoader.js +2 -0
- package/examples/jsm/loaders/KTX2Loader.js +143 -49
- package/examples/jsm/loaders/LDrawLoader.js +22 -136
- package/examples/jsm/loaders/LottieLoader.js +1 -0
- package/examples/jsm/loaders/MMDLoader.js +3 -0
- package/examples/jsm/loaders/MaterialXLoader.js +2 -2
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +143 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +114 -0
- package/examples/jsm/math/ColorSpaces.js +76 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +52 -40
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +293 -0
- package/examples/jsm/misc/VolumeSlice.js +1 -0
- 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 +12 -10
- package/examples/jsm/postprocessing/AfterimagePass.js +14 -3
- package/examples/jsm/postprocessing/SSRPass.js +6 -0
- package/examples/jsm/renderers/CSS2DRenderer.js +6 -3
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -4
- package/examples/jsm/shaders/FXAAShader.js +225 -224
- package/examples/jsm/transpiler/AST.js +2 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +57 -25
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +11 -6
- package/{src/nodes → examples/jsm/tsl}/display/AfterImageNode.js +18 -21
- package/{src/nodes → examples/jsm/tsl}/display/AnaglyphPassNode.js +2 -6
- package/{src/nodes → examples/jsm/tsl}/display/AnamorphicNode.js +12 -18
- package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +1 -3
- package/{src/nodes → examples/jsm/tsl}/display/BloomNode.js +12 -41
- package/{src/nodes → examples/jsm/tsl}/display/DenoiseNode.js +60 -47
- package/{src/nodes → examples/jsm/tsl}/display/DepthOfFieldNode.js +4 -9
- package/{src/nodes → examples/jsm/tsl}/display/DotScreenNode.js +2 -9
- package/examples/jsm/tsl/display/FXAANode.js +316 -0
- package/{src/nodes → examples/jsm/tsl}/display/FilmNode.js +4 -7
- package/{src/nodes → examples/jsm/tsl}/display/GTAONode.js +73 -78
- package/{src/nodes → examples/jsm/tsl}/display/GaussianBlurNode.js +78 -42
- package/examples/jsm/tsl/display/LensflareNode.js +161 -0
- package/{src/nodes → examples/jsm/tsl}/display/Lut3DNode.js +3 -5
- package/{src/nodes → examples/jsm/tsl}/display/MotionBlur.js +2 -3
- package/examples/jsm/tsl/display/OutlineNode.js +434 -0
- package/{src/nodes → examples/jsm/tsl}/display/ParallaxBarrierPassNode.js +2 -5
- package/{src/nodes → examples/jsm/tsl}/display/PixelationPassNode.js +5 -17
- package/{src/nodes → examples/jsm/tsl}/display/RGBShiftNode.js +2 -6
- package/examples/jsm/tsl/display/SMAANode.js +620 -0
- package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +10 -25
- package/examples/jsm/tsl/display/SSRNode.js +366 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +1 -2
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +4 -12
- package/{src/nodes → examples/jsm/tsl}/display/StereoCompositePassNode.js +9 -11
- package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +10 -11
- package/examples/jsm/tsl/display/TRAAPassNode.js +355 -0
- package/{src/nodes → examples/jsm/tsl}/display/TransitionNode.js +3 -7
- package/examples/jsm/tsl/display/hashBlur.js +24 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +389 -0
- package/examples/jsm/utils/SceneOptimizer.js +410 -0
- package/examples/jsm/utils/UVsDebug.js +1 -1
- package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +2 -1
- package/examples/jsm/webxr/OculusHandPointerModel.js +21 -21
- package/examples/jsm/webxr/Text2D.js +6 -6
- package/package.json +4 -4
- package/src/Three.Core.js +178 -0
- package/src/Three.TSL.js +526 -0
- package/src/Three.WebGPU.Nodes.js +9 -186
- package/src/Three.WebGPU.js +8 -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 -6
- package/src/core/BufferGeometry.js +48 -8
- 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/CylinderGeometry.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/LineDashedMaterial.js +0 -1
- package/src/materials/Material.js +2 -2
- package/src/materials/MeshPhongMaterial.js +1 -1
- package/src/materials/MeshPhysicalMaterial.js +2 -2
- package/src/materials/MeshStandardMaterial.js +2 -2
- package/src/materials/nodes/Line2NodeMaterial.js +32 -13
- package/src/materials/nodes/LineDashedNodeMaterial.js +4 -2
- package/src/materials/nodes/NodeMaterial.js +93 -23
- package/src/materials/nodes/SpriteNodeMaterial.js +11 -2
- package/src/materials/nodes/manager/NodeMaterialObserver.js +119 -7
- package/src/math/ColorManagement.js +143 -102
- 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 +22 -9
- package/src/nodes/Nodes.js +2 -21
- package/src/nodes/TSL.js +9 -25
- package/src/nodes/accessors/Arrays.js +27 -0
- package/src/nodes/accessors/BuiltinNode.js +26 -0
- package/src/nodes/accessors/Camera.js +0 -1
- 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/SceneNode.js +35 -1
- package/src/nodes/accessors/StorageBufferNode.js +61 -19
- package/src/nodes/accessors/StorageTextureNode.js +10 -4
- package/src/nodes/accessors/TextureNode.js +1 -1
- package/src/nodes/accessors/VelocityNode.js +13 -3
- package/src/nodes/code/FunctionCallNode.js +16 -5
- package/src/nodes/code/ScriptableNode.js +4 -4
- package/src/nodes/core/Node.js +1 -0
- package/src/nodes/core/NodeBuilder.js +31 -14
- package/src/nodes/core/NodeUtils.js +28 -0
- package/src/nodes/core/VarNode.js +15 -3
- package/src/nodes/core/constants.js +6 -0
- package/src/nodes/display/BlendModes.js +99 -0
- package/src/nodes/display/ColorAdjustment.js +53 -4
- package/src/nodes/display/ColorSpaceFunctions.js +5 -5
- package/src/nodes/display/ColorSpaceNode.js +27 -39
- package/src/nodes/display/PassNode.js +6 -4
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +3 -3
- package/src/nodes/display/ViewportDepthNode.js +48 -1
- package/src/nodes/functions/PhysicalLightingModel.js +21 -15
- package/src/nodes/functions/material/getAlphaHashThreshold.js +70 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +8 -2
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +22 -0
- package/src/nodes/gpgpu/ComputeNode.js +9 -1
- package/src/nodes/lighting/AnalyticLightNode.js +23 -419
- package/src/nodes/lighting/LightsNode.js +24 -12
- package/src/nodes/lighting/PointLightNode.js +41 -22
- package/src/nodes/lighting/PointShadowNode.js +254 -0
- package/src/nodes/lighting/RectAreaLightNode.js +3 -0
- package/src/nodes/lighting/ShadowNode.js +593 -0
- package/src/nodes/lighting/SpotLightNode.js +14 -2
- package/src/nodes/utils/LoopNode.js +2 -2
- package/src/nodes/utils/Oscillators.js +6 -0
- package/src/nodes/utils/PostProcessingUtils.js +89 -0
- package/src/nodes/utils/RTTNode.js +9 -1
- package/src/nodes/utils/ReflectorNode.js +101 -15
- package/src/nodes/utils/StorageArrayElementNode.js +2 -2
- package/src/nodes/utils/Timer.js +29 -0
- package/src/objects/BatchedMesh.js +472 -296
- package/src/objects/ClippingGroup.js +19 -0
- package/src/objects/Skeleton.js +2 -2
- package/src/renderers/WebGLRenderer.js +183 -109
- package/src/renderers/common/Animation.js +23 -11
- package/src/renderers/common/Attributes.js +4 -0
- package/src/renderers/common/Backend.js +2 -0
- package/src/renderers/common/Background.js +15 -5
- package/src/renderers/common/Bindings.js +23 -6
- package/src/renderers/common/ClippingContext.js +77 -85
- package/src/renderers/common/Constants.js +2 -1
- package/src/renderers/common/Geometries.js +20 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.js +15 -0
- package/src/renderers/common/Lighting.js +45 -0
- package/src/renderers/common/PostProcessingUtils.js +86 -0
- package/src/renderers/common/RenderList.js +48 -17
- package/src/renderers/common/RenderLists.js +4 -2
- package/src/renderers/common/RenderObject.js +45 -28
- package/src/renderers/common/RenderObjects.js +12 -6
- package/src/renderers/common/Renderer.js +222 -77
- package/src/renderers/common/Textures.js +41 -17
- 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 -15
- package/src/renderers/common/nodes/NodeStorageBuffer.js +2 -3
- package/src/renderers/common/nodes/NodeUniform.js +42 -0
- package/src/renderers/common/nodes/Nodes.js +2 -2
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLBackground.js +20 -1
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +0 -7
- package/src/renderers/webgl/WebGLGeometries.js +0 -28
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLProgram.js +24 -28
- package/src/renderers/webgl/WebGLPrograms.js +5 -2
- package/src/renderers/webgl/WebGLState.js +37 -1
- package/src/renderers/webgl/WebGLTextures.js +29 -12
- package/src/renderers/webgl-fallback/WebGLBackend.js +111 -37
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +2 -7
- 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 +37 -9
- package/src/renderers/webgpu/WebGPUBackend.js +152 -56
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -1
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +0 -8
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +13 -34
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +192 -92
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +12 -4
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -2
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -7
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +29 -9
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +29 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +0 -1
- package/src/renderers/webxr/WebXRManager.js +4 -4
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/src/nodes/display/BlendMode.js +0 -54
- package/src/nodes/display/FXAANode.js +0 -332
- package/src/nodes/utils/OscNode.js +0 -85
- package/src/nodes/utils/TimerNode.js +0 -97
- /package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +0 -0
|
@@ -7,22 +7,22 @@ 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
|
-
import { positionLocal } from '../../nodes/accessors/Position.js';
|
|
13
|
+
import { positionLocal, positionView } from '../../nodes/accessors/Position.js';
|
|
14
14
|
import { skinningReference } from '../../nodes/accessors/SkinningNode.js';
|
|
15
15
|
import { morphReference } from '../../nodes/accessors/MorphNode.js';
|
|
16
|
-
import { lights } from '../../nodes/lighting/LightsNode.js';
|
|
17
16
|
import { mix } from '../../nodes/math/MathNode.js';
|
|
18
17
|
import { float, vec3, vec4 } from '../../nodes/tsl/TSLBase.js';
|
|
19
18
|
import AONode from '../../nodes/lighting/AONode.js';
|
|
20
19
|
import { lightingContext } from '../../nodes/lighting/LightingContextNode.js';
|
|
21
20
|
import IrradianceNode from '../../nodes/lighting/IrradianceNode.js';
|
|
22
|
-
import { depth } from '../../nodes/display/ViewportDepthNode.js';
|
|
23
|
-
import {
|
|
24
|
-
import { clipping, clippingAlpha } from '../../nodes/accessors/ClippingNode.js';
|
|
21
|
+
import { depth, viewZToLogarithmicDepth, viewZToOrthographicDepth } from '../../nodes/display/ViewportDepthNode.js';
|
|
22
|
+
import { cameraFar, cameraNear } from '../../nodes/accessors/Camera.js';
|
|
23
|
+
import { clipping, clippingAlpha, hardwareClipping } from '../../nodes/accessors/ClippingNode.js';
|
|
25
24
|
import NodeMaterialObserver from './manager/NodeMaterialObserver.js';
|
|
25
|
+
import getAlphaHashThreshold from '../../nodes/functions/material/getAlphaHashThreshold.js';
|
|
26
26
|
|
|
27
27
|
class NodeMaterial extends Material {
|
|
28
28
|
|
|
@@ -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;
|
|
@@ -57,10 +64,12 @@ class NodeMaterial extends Material {
|
|
|
57
64
|
this.alphaTestNode = null;
|
|
58
65
|
|
|
59
66
|
this.positionNode = null;
|
|
67
|
+
this.geometryNode = null;
|
|
60
68
|
|
|
61
69
|
this.depthNode = null;
|
|
62
|
-
this.shadowNode = null;
|
|
63
70
|
this.shadowPositionNode = null;
|
|
71
|
+
this.receivedShadowNode = null;
|
|
72
|
+
this.castShadowNode = null;
|
|
64
73
|
|
|
65
74
|
this.outputNode = null;
|
|
66
75
|
this.mrtNode = null;
|
|
@@ -92,12 +101,21 @@ class NodeMaterial extends Material {
|
|
|
92
101
|
|
|
93
102
|
builder.context.setupNormal = () => this.setupNormal( builder );
|
|
94
103
|
|
|
104
|
+
const renderer = builder.renderer;
|
|
105
|
+
const renderTarget = renderer.getRenderTarget();
|
|
106
|
+
|
|
95
107
|
// < VERTEX STAGE >
|
|
96
108
|
|
|
97
109
|
builder.addStack();
|
|
98
110
|
|
|
99
111
|
builder.stack.outputNode = this.vertexNode || this.setupPosition( builder );
|
|
100
112
|
|
|
113
|
+
if ( this.geometryNode !== null ) {
|
|
114
|
+
|
|
115
|
+
builder.stack.outputNode = builder.stack.outputNode.bypass( this.geometryNode );
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
101
119
|
builder.addFlow( 'vertex', builder.removeStack() );
|
|
102
120
|
|
|
103
121
|
// < FRAGMENT STAGE >
|
|
@@ -108,7 +126,21 @@ class NodeMaterial extends Material {
|
|
|
108
126
|
|
|
109
127
|
const clippingNode = this.setupClipping( builder );
|
|
110
128
|
|
|
111
|
-
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
|
+
}
|
|
112
144
|
|
|
113
145
|
if ( this.fragmentNode === null ) {
|
|
114
146
|
|
|
@@ -135,11 +167,9 @@ class NodeMaterial extends Material {
|
|
|
135
167
|
|
|
136
168
|
// MRT
|
|
137
169
|
|
|
138
|
-
const renderTarget = builder.renderer.getRenderTarget();
|
|
139
|
-
|
|
140
170
|
if ( renderTarget !== null ) {
|
|
141
171
|
|
|
142
|
-
const mrt =
|
|
172
|
+
const mrt = renderer.getMRT();
|
|
143
173
|
const materialMRT = this.mrtNode;
|
|
144
174
|
|
|
145
175
|
if ( mrt !== null ) {
|
|
@@ -188,11 +218,11 @@ class NodeMaterial extends Material {
|
|
|
188
218
|
|
|
189
219
|
if ( builder.clippingContext === null ) return null;
|
|
190
220
|
|
|
191
|
-
const {
|
|
221
|
+
const { unionPlanes, intersectionPlanes } = builder.clippingContext;
|
|
192
222
|
|
|
193
223
|
let result = null;
|
|
194
224
|
|
|
195
|
-
if (
|
|
225
|
+
if ( unionPlanes.length > 0 || intersectionPlanes.length > 0 ) {
|
|
196
226
|
|
|
197
227
|
const samples = builder.renderer.samples;
|
|
198
228
|
|
|
@@ -213,9 +243,31 @@ class NodeMaterial extends Material {
|
|
|
213
243
|
|
|
214
244
|
}
|
|
215
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
|
+
|
|
216
268
|
setupDepth( builder ) {
|
|
217
269
|
|
|
218
|
-
const { renderer } = builder;
|
|
270
|
+
const { renderer, camera } = builder;
|
|
219
271
|
|
|
220
272
|
// Depth
|
|
221
273
|
|
|
@@ -231,9 +283,15 @@ class NodeMaterial extends Material {
|
|
|
231
283
|
|
|
232
284
|
} else if ( renderer.logarithmicDepthBuffer === true ) {
|
|
233
285
|
|
|
234
|
-
|
|
286
|
+
if ( camera.isPerspectiveCamera ) {
|
|
287
|
+
|
|
288
|
+
depthNode = viewZToLogarithmicDepth( positionView.z, cameraNear, cameraFar );
|
|
289
|
+
|
|
290
|
+
} else {
|
|
235
291
|
|
|
236
|
-
|
|
292
|
+
depthNode = viewZToOrthographicDepth( positionView.z, cameraNear, cameraFar );
|
|
293
|
+
|
|
294
|
+
}
|
|
237
295
|
|
|
238
296
|
}
|
|
239
297
|
|
|
@@ -284,9 +342,9 @@ class NodeMaterial extends Material {
|
|
|
284
342
|
|
|
285
343
|
}
|
|
286
344
|
|
|
287
|
-
if ( ( object.instanceMatrix && object.instanceMatrix.isInstancedBufferAttribute === true ) ) {
|
|
345
|
+
if ( ( object.isInstancedMesh && object.instanceMatrix && object.instanceMatrix.isInstancedBufferAttribute === true ) ) {
|
|
288
346
|
|
|
289
|
-
|
|
347
|
+
instancedMesh( object ).append();
|
|
290
348
|
|
|
291
349
|
}
|
|
292
350
|
|
|
@@ -296,6 +354,8 @@ class NodeMaterial extends Material {
|
|
|
296
354
|
|
|
297
355
|
}
|
|
298
356
|
|
|
357
|
+
this.setupHardwareClipping( builder );
|
|
358
|
+
|
|
299
359
|
const mvp = modelViewProjection();
|
|
300
360
|
|
|
301
361
|
builder.context.vertex = builder.removeStack();
|
|
@@ -355,6 +415,14 @@ class NodeMaterial extends Material {
|
|
|
355
415
|
|
|
356
416
|
}
|
|
357
417
|
|
|
418
|
+
// ALPHA HASH
|
|
419
|
+
|
|
420
|
+
if ( this.alphaHash === true ) {
|
|
421
|
+
|
|
422
|
+
diffuseColor.a.lessThan( getAlphaHashThreshold( positionLocal ) ).discard();
|
|
423
|
+
|
|
424
|
+
}
|
|
425
|
+
|
|
358
426
|
if ( this.transparent === false && this.blending === NormalBlending && this.alphaToCoverage === false ) {
|
|
359
427
|
|
|
360
428
|
diffuseColor.a.assign( 1.0 );
|
|
@@ -447,7 +515,7 @@ class NodeMaterial extends Material {
|
|
|
447
515
|
|
|
448
516
|
if ( materialLightsNode.length > 0 ) {
|
|
449
517
|
|
|
450
|
-
lightsN =
|
|
518
|
+
lightsN = builder.renderer.lighting.createNode( [ ...lightsN.getLights(), ...materialLightsNode ] );
|
|
451
519
|
|
|
452
520
|
}
|
|
453
521
|
|
|
@@ -474,7 +542,7 @@ class NodeMaterial extends Material {
|
|
|
474
542
|
|
|
475
543
|
let outgoingLightNode = this.setupOutgoingLight( builder );
|
|
476
544
|
|
|
477
|
-
if ( lightsNode && lightsNode.getScope().
|
|
545
|
+
if ( lightsNode && lightsNode.getScope().hasLights ) {
|
|
478
546
|
|
|
479
547
|
const lightingModel = this.setupLightingModel( builder );
|
|
480
548
|
|
|
@@ -622,10 +690,12 @@ class NodeMaterial extends Material {
|
|
|
622
690
|
this.alphaTestNode = source.alphaTestNode;
|
|
623
691
|
|
|
624
692
|
this.positionNode = source.positionNode;
|
|
693
|
+
this.geometryNode = source.geometryNode;
|
|
625
694
|
|
|
626
695
|
this.depthNode = source.depthNode;
|
|
627
|
-
this.shadowNode = source.shadowNode;
|
|
628
696
|
this.shadowPositionNode = source.shadowPositionNode;
|
|
697
|
+
this.receivedShadowNode = source.receivedShadowNode;
|
|
698
|
+
this.castShadowNode = source.castShadowNode;
|
|
629
699
|
|
|
630
700
|
this.outputNode = source.outputNode;
|
|
631
701
|
this.mrtNode = source.mrtNode;
|
|
@@ -59,9 +59,18 @@ class SpriteNodeMaterial extends NodeMaterial {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
if ( ! sizeAttenuation
|
|
62
|
+
if ( ! sizeAttenuation ) {
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
if ( camera.isPerspectiveCamera ) {
|
|
65
|
+
|
|
66
|
+
scale = scale.mul( mvPosition.z.negate() );
|
|
67
|
+
|
|
68
|
+
} else {
|
|
69
|
+
|
|
70
|
+
const orthoScale = float( 2.0 ).div( cameraProjectionMatrix.element( 1 ).element( 1 ) );
|
|
71
|
+
scale = scale.mul( orthoScale.mul( 2 ) );
|
|
72
|
+
|
|
73
|
+
}
|
|
65
74
|
|
|
66
75
|
}
|
|
67
76
|
|
|
@@ -85,20 +85,27 @@ class NodeMaterialObserver {
|
|
|
85
85
|
|
|
86
86
|
if ( data === undefined ) {
|
|
87
87
|
|
|
88
|
+
const { geometry, material, object } = renderObject;
|
|
89
|
+
|
|
88
90
|
data = {
|
|
89
|
-
material: this.getMaterialData(
|
|
90
|
-
|
|
91
|
+
material: this.getMaterialData( material ),
|
|
92
|
+
geometry: {
|
|
93
|
+
attributes: this.getAttributesData( geometry.attributes ),
|
|
94
|
+
indexVersion: geometry.index ? geometry.index.version : null,
|
|
95
|
+
drawRange: { start: geometry.drawRange.start, count: geometry.drawRange.count }
|
|
96
|
+
},
|
|
97
|
+
worldMatrix: object.matrixWorld.clone()
|
|
91
98
|
};
|
|
92
99
|
|
|
93
|
-
if (
|
|
100
|
+
if ( object.center ) {
|
|
94
101
|
|
|
95
|
-
data.center =
|
|
102
|
+
data.center = object.center.clone();
|
|
96
103
|
|
|
97
104
|
}
|
|
98
105
|
|
|
99
|
-
if (
|
|
106
|
+
if ( object.morphTargetInfluences ) {
|
|
100
107
|
|
|
101
|
-
data.morphTargetInfluences =
|
|
108
|
+
data.morphTargetInfluences = object.morphTargetInfluences.slice();
|
|
102
109
|
|
|
103
110
|
}
|
|
104
111
|
|
|
@@ -108,6 +115,15 @@ class NodeMaterialObserver {
|
|
|
108
115
|
|
|
109
116
|
}
|
|
110
117
|
|
|
118
|
+
if ( data.material.transmission > 0 ) {
|
|
119
|
+
|
|
120
|
+
const { width, height } = renderObject.context;
|
|
121
|
+
|
|
122
|
+
data.bufferWidth = width;
|
|
123
|
+
data.bufferHeight = height;
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
|
|
111
127
|
this.renderObjects.set( renderObject, data );
|
|
112
128
|
|
|
113
129
|
}
|
|
@@ -116,6 +132,24 @@ class NodeMaterialObserver {
|
|
|
116
132
|
|
|
117
133
|
}
|
|
118
134
|
|
|
135
|
+
getAttributesData( attributes ) {
|
|
136
|
+
|
|
137
|
+
const attributesData = {};
|
|
138
|
+
|
|
139
|
+
for ( const name in attributes ) {
|
|
140
|
+
|
|
141
|
+
const attribute = attributes[ name ];
|
|
142
|
+
|
|
143
|
+
attributesData[ name ] = {
|
|
144
|
+
version: attribute.version
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return attributesData;
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
119
153
|
containsNode( builder ) {
|
|
120
154
|
|
|
121
155
|
const material = builder.material;
|
|
@@ -170,7 +204,7 @@ class NodeMaterialObserver {
|
|
|
170
204
|
|
|
171
205
|
equals( renderObject ) {
|
|
172
206
|
|
|
173
|
-
const { object, material } = renderObject;
|
|
207
|
+
const { object, material, geometry } = renderObject;
|
|
174
208
|
|
|
175
209
|
const renderObjectData = this.getRenderObjectData( renderObject );
|
|
176
210
|
|
|
@@ -224,6 +258,84 @@ class NodeMaterialObserver {
|
|
|
224
258
|
|
|
225
259
|
}
|
|
226
260
|
|
|
261
|
+
if ( materialData.transmission > 0 ) {
|
|
262
|
+
|
|
263
|
+
const { width, height } = renderObject.context;
|
|
264
|
+
|
|
265
|
+
if ( renderObjectData.bufferWidth !== width || renderObjectData.bufferHeight !== height ) {
|
|
266
|
+
|
|
267
|
+
renderObjectData.bufferWidth = width;
|
|
268
|
+
renderObjectData.bufferHeight = height;
|
|
269
|
+
|
|
270
|
+
return false;
|
|
271
|
+
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// geometry
|
|
277
|
+
|
|
278
|
+
const storedGeometryData = renderObjectData.geometry;
|
|
279
|
+
const attributes = geometry.attributes;
|
|
280
|
+
const storedAttributes = storedGeometryData.attributes;
|
|
281
|
+
|
|
282
|
+
const storedAttributeNames = Object.keys( storedAttributes );
|
|
283
|
+
const currentAttributeNames = Object.keys( attributes );
|
|
284
|
+
|
|
285
|
+
if ( storedAttributeNames.length !== currentAttributeNames.length ) {
|
|
286
|
+
|
|
287
|
+
renderObjectData.geometry.attributes = this.getAttributesData( attributes );
|
|
288
|
+
return false;
|
|
289
|
+
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// compare each attribute
|
|
293
|
+
|
|
294
|
+
for ( const name of storedAttributeNames ) {
|
|
295
|
+
|
|
296
|
+
const storedAttributeData = storedAttributes[ name ];
|
|
297
|
+
const attribute = attributes[ name ];
|
|
298
|
+
|
|
299
|
+
if ( attribute === undefined ) {
|
|
300
|
+
|
|
301
|
+
// attribute was removed
|
|
302
|
+
delete storedAttributes[ name ];
|
|
303
|
+
return false;
|
|
304
|
+
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if ( storedAttributeData.version !== attribute.version ) {
|
|
308
|
+
|
|
309
|
+
storedAttributeData.version = attribute.version;
|
|
310
|
+
return false;
|
|
311
|
+
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// check index
|
|
317
|
+
|
|
318
|
+
const index = geometry.index;
|
|
319
|
+
const storedIndexVersion = storedGeometryData.indexVersion;
|
|
320
|
+
const currentIndexVersion = index ? index.version : null;
|
|
321
|
+
|
|
322
|
+
if ( storedIndexVersion !== currentIndexVersion ) {
|
|
323
|
+
|
|
324
|
+
storedGeometryData.indexVersion = currentIndexVersion;
|
|
325
|
+
return false;
|
|
326
|
+
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// check drawRange
|
|
330
|
+
|
|
331
|
+
if ( storedGeometryData.drawRange.start !== geometry.drawRange.start || storedGeometryData.drawRange.count !== geometry.drawRange.count ) {
|
|
332
|
+
|
|
333
|
+
storedGeometryData.drawRange.start = geometry.drawRange.start;
|
|
334
|
+
storedGeometryData.drawRange.count = geometry.drawRange.count;
|
|
335
|
+
return false;
|
|
336
|
+
|
|
337
|
+
}
|
|
338
|
+
|
|
227
339
|
// morph targets
|
|
228
340
|
|
|
229
341
|
if ( renderObjectData.morphTargetInfluences ) {
|