super-three 0.158.0 → 0.160.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 +1720 -380
- package/build/three.js +1720 -380
- package/build/three.min.js +1 -1
- package/build/three.module.js +1719 -381
- package/build/three.module.min.js +1 -1
- package/examples/jsm/Addons.js +2 -1
- package/examples/jsm/controls/OrbitControls.js +50 -40
- package/examples/jsm/csm/CSMShader.js +52 -47
- package/examples/jsm/exporters/GLTFExporter.js +79 -1
- package/examples/jsm/exporters/USDZExporter.js +27 -19
- package/examples/jsm/helpers/TextureHelper.js +237 -0
- package/examples/jsm/interactive/HTMLMesh.js +9 -2
- package/examples/jsm/lines/LineMaterial.js +16 -33
- package/examples/jsm/loaders/ColladaLoader.js +0 -6
- package/examples/jsm/loaders/DRACOLoader.js +4 -3
- package/examples/jsm/loaders/FBXLoader.js +294 -124
- package/examples/jsm/loaders/GLTFLoader.js +71 -3
- package/examples/jsm/loaders/MaterialXLoader.js +73 -54
- package/examples/jsm/loaders/NRRDLoader.js +0 -13
- package/examples/jsm/loaders/SVGLoader.js +4 -4
- package/examples/jsm/loaders/USDZLoader.js +3 -17
- package/examples/jsm/math/Octree.js +15 -4
- package/examples/jsm/misc/Timer.js +119 -0
- package/examples/jsm/misc/TubePainter.js +3 -6
- package/examples/jsm/modifiers/CurveModifier.js +20 -2
- package/examples/jsm/nodes/Nodes.js +11 -7
- package/examples/jsm/nodes/accessors/CameraNode.js +18 -2
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +5 -73
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +11 -2
- package/examples/jsm/nodes/accessors/ModelNode.js +1 -1
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +12 -3
- package/examples/jsm/nodes/accessors/MorphNode.js +191 -16
- package/examples/jsm/nodes/accessors/ReferenceNode.js +25 -1
- package/examples/jsm/nodes/accessors/TextureNode.js +122 -36
- package/examples/jsm/nodes/code/CodeNode.js +3 -3
- package/examples/jsm/nodes/core/AttributeNode.js +7 -1
- package/examples/jsm/nodes/core/CacheNode.js +4 -1
- package/examples/jsm/nodes/core/ConstNode.js +1 -1
- package/examples/jsm/nodes/core/Node.js +6 -3
- package/examples/jsm/nodes/core/NodeBuilder.js +84 -27
- package/examples/jsm/nodes/core/NodeFrame.js +10 -8
- package/examples/jsm/nodes/core/NodeUniform.js +12 -0
- package/examples/jsm/nodes/core/NodeUtils.js +3 -7
- package/examples/jsm/nodes/core/OutputStructNode.js +3 -3
- package/examples/jsm/nodes/core/PropertyNode.js +17 -2
- package/examples/jsm/nodes/core/StructTypeNode.js +4 -4
- package/examples/jsm/nodes/core/UniformGroup.js +13 -0
- package/examples/jsm/nodes/core/UniformGroupNode.js +36 -0
- package/examples/jsm/nodes/core/UniformNode.js +17 -0
- package/examples/jsm/nodes/core/VarNode.js +2 -0
- package/examples/jsm/nodes/core/VaryingNode.js +1 -7
- package/examples/jsm/nodes/display/BumpMapNode.js +1 -1
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +6 -10
- package/examples/jsm/nodes/display/GaussianBlurNode.js +170 -0
- package/examples/jsm/nodes/display/PassNode.js +182 -0
- package/examples/jsm/nodes/display/ViewportDepthNode.js +31 -3
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportNode.js +5 -8
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +52 -17
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +8 -12
- package/examples/jsm/nodes/lighting/LightsNode.js +34 -32
- package/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +12 -12
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/NodeMaterial.js +66 -41
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +0 -10
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -7
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +10 -10
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +128 -54
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +1430 -618
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +24 -14
- package/examples/jsm/nodes/math/MathNode.js +2 -0
- package/examples/jsm/nodes/math/OperatorNode.js +19 -6
- package/examples/jsm/nodes/shadernode/ShaderNode.js +32 -3
- package/examples/jsm/nodes/utils/FunctionOverloadingNode.js +95 -0
- package/examples/jsm/nodes/utils/RemapNode.js +2 -2
- package/examples/jsm/nodes/utils/SplitNode.js +8 -2
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +3 -3
- package/examples/jsm/objects/QuadMesh.js +60 -0
- package/examples/jsm/postprocessing/GTAOPass.js +572 -0
- package/examples/jsm/postprocessing/OutputPass.js +2 -0
- package/examples/jsm/renderers/common/Animation.js +10 -21
- package/examples/jsm/renderers/common/Backend.js +19 -3
- package/examples/jsm/renderers/common/Background.js +20 -22
- package/examples/jsm/renderers/common/Bindings.js +30 -21
- package/examples/jsm/renderers/common/ChainMap.js +3 -3
- package/examples/jsm/renderers/common/Color4.js +37 -0
- package/examples/jsm/renderers/common/Geometries.js +4 -4
- package/examples/jsm/renderers/common/Info.js +12 -2
- package/examples/jsm/renderers/common/Pipelines.js +3 -51
- package/examples/jsm/renderers/common/PostProcessing.js +25 -0
- package/examples/jsm/renderers/common/RenderContext.js +1 -1
- package/examples/jsm/renderers/common/RenderContexts.js +1 -1
- package/examples/jsm/renderers/common/RenderObject.js +13 -1
- package/examples/jsm/renderers/common/RenderObjects.js +4 -2
- package/examples/jsm/renderers/common/Renderer.js +137 -37
- package/examples/jsm/renderers/common/StorageTexture.js +1 -0
- package/examples/jsm/renderers/common/Textures.js +4 -1
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +10 -2
- package/examples/jsm/renderers/common/nodes/NodeUniformsGroup.js +44 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +74 -7
- package/examples/jsm/renderers/webgl/WebGLBackend.js +91 -33
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +100 -31
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +57 -5
- package/examples/jsm/renderers/webgl/utils/WebGLCapabilities.js +36 -0
- package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +11 -1
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +71 -2
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +42 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +33 -3
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +4 -14
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +186 -137
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +1 -1
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +209 -90
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -10
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +11 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +2 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +88 -6
- package/examples/jsm/shaders/FXAAShader.js +133 -133
- package/examples/jsm/shaders/GTAOShader.js +424 -0
- package/examples/jsm/shaders/OutputShader.js +4 -0
- package/examples/jsm/shaders/PoissonDenoiseShader.js +226 -0
- package/examples/jsm/shaders/SAOShader.js +2 -3
- package/examples/jsm/shaders/SSAOShader.js +2 -3
- package/examples/jsm/transpiler/AST.js +40 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +50 -8
- package/examples/jsm/transpiler/ShaderToyDecoder.js +4 -4
- package/examples/jsm/transpiler/TSLEncoder.js +124 -20
- package/examples/jsm/utils/SortUtils.js +158 -0
- package/examples/jsm/utils/TextureUtils.js +33 -21
- package/examples/jsm/webxr/ARButton.js +14 -0
- package/examples/jsm/webxr/VRButton.js +23 -8
- package/examples/jsm/webxr/XRButton.js +25 -11
- package/package.json +5 -6
- package/src/Three.js +1 -0
- package/src/constants.js +2 -1
- package/src/core/BufferAttribute.js +21 -2
- package/src/core/InterleavedBuffer.js +21 -1
- package/src/core/Object3D.js +60 -12
- package/src/core/UniformsGroup.js +7 -1
- package/src/extras/curves/LineCurve3.js +4 -0
- package/src/loaders/AudioLoader.js +1 -1
- package/src/loaders/BufferGeometryLoader.js +0 -7
- package/src/loaders/ImageBitmapLoader.js +25 -1
- package/src/loaders/ObjectLoader.js +49 -0
- package/src/materials/ShaderMaterial.js +2 -1
- package/src/math/ColorManagement.js +0 -16
- package/src/math/Quaternion.js +5 -4
- package/src/math/Sphere.js +2 -0
- package/src/math/Triangle.js +17 -5
- package/src/objects/BatchedMesh.js +1020 -0
- package/src/objects/Skeleton.js +1 -3
- package/src/renderers/WebGL3DRenderTarget.js +2 -2
- package/src/renderers/WebGLArrayRenderTarget.js +2 -2
- package/src/renderers/WebGLRenderer.js +24 -19
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +19 -0
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +0 -5
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +31 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +9 -4
- package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +9 -17
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +84 -0
- package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk.js +4 -0
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +3 -0
- package/src/renderers/webgl/WebGLAttributes.js +39 -5
- package/src/renderers/webgl/WebGLBufferRenderer.js +31 -0
- package/src/renderers/webgl/WebGLCubeMaps.js +1 -1
- package/src/renderers/webgl/WebGLExtensions.js +1 -0
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +31 -0
- package/src/renderers/webgl/WebGLLights.js +11 -2
- package/src/renderers/webgl/WebGLProgram.js +20 -1
- package/src/renderers/webgl/WebGLPrograms.js +5 -0
- package/src/renderers/webgl/WebGLShadowMap.js +35 -0
- package/src/renderers/webgl/WebGLTextures.js +7 -11
- package/src/renderers/webgl/WebGLUniforms.js +11 -1
- package/src/renderers/webgl/WebGLUniformsGroups.js +72 -93
- package/src/renderers/webxr/WebXRManager.js +16 -0
- package/examples/jsm/objects/BatchedMesh.js +0 -586
|
@@ -2,7 +2,7 @@ import ViewportTextureNode from './ViewportTextureNode.js';
|
|
|
2
2
|
import { addNodeClass } from '../core/Node.js';
|
|
3
3
|
import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js';
|
|
4
4
|
import { viewportTopLeft } from './ViewportNode.js';
|
|
5
|
-
import { DepthTexture,
|
|
5
|
+
import { DepthTexture, NearestMipmapNearestFilter, DepthFormat, UnsignedIntType } from 'three';
|
|
6
6
|
|
|
7
7
|
let sharedDepthbuffer = null;
|
|
8
8
|
|
|
@@ -13,7 +13,7 @@ class ViewportDepthTextureNode extends ViewportTextureNode {
|
|
|
13
13
|
if ( sharedDepthbuffer === null ) {
|
|
14
14
|
|
|
15
15
|
sharedDepthbuffer = new DepthTexture();
|
|
16
|
-
sharedDepthbuffer.minFilter =
|
|
16
|
+
sharedDepthbuffer.minFilter = NearestMipmapNearestFilter;
|
|
17
17
|
sharedDepthbuffer.type = UnsignedIntType;
|
|
18
18
|
sharedDepthbuffer.format = DepthFormat;
|
|
19
19
|
|
|
@@ -21,7 +21,7 @@ class ViewportNode extends Node {
|
|
|
21
21
|
|
|
22
22
|
getNodeType() {
|
|
23
23
|
|
|
24
|
-
return this.scope === ViewportNode.
|
|
24
|
+
return this.scope === ViewportNode.VIEWPORT ? 'vec4' : 'vec2';
|
|
25
25
|
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -55,7 +55,7 @@ class ViewportNode extends Node {
|
|
|
55
55
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
setup( builder ) {
|
|
58
|
+
setup( /*builder*/ ) {
|
|
59
59
|
|
|
60
60
|
const scope = this.scope;
|
|
61
61
|
|
|
@@ -73,10 +73,7 @@ class ViewportNode extends Node {
|
|
|
73
73
|
|
|
74
74
|
} else {
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
const resolutionNode = new ViewportNode( ViewportNode.RESOLUTION );
|
|
78
|
-
|
|
79
|
-
output = coordinateNode.div( resolutionNode );
|
|
76
|
+
output = viewportCoordinate.div( viewportResolution );
|
|
80
77
|
|
|
81
78
|
let outX = output.x;
|
|
82
79
|
let outY = output.y;
|
|
@@ -102,9 +99,9 @@ class ViewportNode extends Node {
|
|
|
102
99
|
|
|
103
100
|
// follow webgpu standards
|
|
104
101
|
|
|
105
|
-
const resolution = viewportResolution.build( builder );
|
|
102
|
+
const resolution = builder.getNodeProperties( viewportResolution ).outputNode.build( builder );
|
|
106
103
|
|
|
107
|
-
coord = `${ builder.getType( 'vec2' ) }( ${ coord }.x, ${ resolution}.y - ${ coord }.y )`;
|
|
104
|
+
coord = `${ builder.getType( 'vec2' ) }( ${ coord }.x, ${ resolution }.y - ${ coord }.y )`;
|
|
108
105
|
|
|
109
106
|
}
|
|
110
107
|
|
|
@@ -371,7 +371,7 @@ class PhysicalLightingModel extends LightingModel {
|
|
|
371
371
|
f90: clearcoatF90
|
|
372
372
|
} );
|
|
373
373
|
|
|
374
|
-
const clearcoatLight = outgoingLight.mul( clearcoat.mul( Fcc ).oneMinus() ).add( this.clearcoatSpecularDirect
|
|
374
|
+
const clearcoatLight = outgoingLight.mul( clearcoat.mul( Fcc ).oneMinus() ).add( this.clearcoatSpecularDirect.add( this.clearcoatSpecularIndirect ).mul( clearcoat ) );
|
|
375
375
|
|
|
376
376
|
outgoingLight.assign( clearcoatLight );
|
|
377
377
|
|
|
@@ -28,11 +28,21 @@ class AnalyticLightNode extends LightingNode {
|
|
|
28
28
|
this.shadowNode = null;
|
|
29
29
|
|
|
30
30
|
this.color = new Color();
|
|
31
|
-
this.
|
|
31
|
+
this._defaultColorNode = uniform( this.color );
|
|
32
|
+
|
|
33
|
+
this.colorNode = this._defaultColorNode;
|
|
34
|
+
|
|
35
|
+
this.isAnalyticLightNode = true;
|
|
32
36
|
|
|
33
37
|
}
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
getCacheKey() {
|
|
40
|
+
|
|
41
|
+
return super.getCacheKey() + '-' + ( this.light.id + '-' + ( this.light.castShadow ? '1' : '0' ) );
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
getHash() {
|
|
36
46
|
|
|
37
47
|
return this.light.uuid;
|
|
38
48
|
|
|
@@ -74,25 +84,20 @@ class AnalyticLightNode extends LightingNode {
|
|
|
74
84
|
.and( shadowCoord.y.lessThanEqual( 1 ) )
|
|
75
85
|
.and( shadowCoord.z.lessThanEqual( 1 ) );
|
|
76
86
|
|
|
87
|
+
let coordZ = shadowCoord.z.add( bias );
|
|
77
88
|
|
|
78
89
|
if ( builder.renderer.coordinateSystem === WebGPUCoordinateSystem ) {
|
|
79
90
|
|
|
80
|
-
|
|
81
|
-
shadowCoord.x,
|
|
82
|
-
shadowCoord.y.oneMinus(), // WebGPU: Flip Y
|
|
83
|
-
shadowCoord.z.add( bias ).mul( 2 ).sub( 1 ) // WebGPU: Convertion [ 0, 1 ] to [ - 1, 1 ]
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
} else {
|
|
87
|
-
|
|
88
|
-
shadowCoord = vec3(
|
|
89
|
-
shadowCoord.x,
|
|
90
|
-
shadowCoord.y,
|
|
91
|
-
shadowCoord.z.add( bias )
|
|
92
|
-
);
|
|
91
|
+
coordZ = coordZ.mul( 2 ).sub( 1 ); // WebGPU: Convertion [ 0, 1 ] to [ - 1, 1 ]
|
|
93
92
|
|
|
94
93
|
}
|
|
95
94
|
|
|
95
|
+
shadowCoord = vec3(
|
|
96
|
+
shadowCoord.x,
|
|
97
|
+
shadowCoord.y.oneMinus(), // follow webgpu standards
|
|
98
|
+
coordZ
|
|
99
|
+
);
|
|
100
|
+
|
|
96
101
|
const textureCompare = ( depthTexture, shadowCoord, compare ) => texture( depthTexture, shadowCoord ).compare( compare );
|
|
97
102
|
//const textureCompare = ( depthTexture, shadowCoord, compare ) => compare.step( texture( depthTexture, shadowCoord ) );
|
|
98
103
|
|
|
@@ -153,6 +158,7 @@ class AnalyticLightNode extends LightingNode {
|
|
|
153
158
|
setup( builder ) {
|
|
154
159
|
|
|
155
160
|
if ( this.light.castShadow ) this.setupShadow( builder );
|
|
161
|
+
else if ( this.shadowNode !== null ) this.disposeShadow();
|
|
156
162
|
|
|
157
163
|
}
|
|
158
164
|
|
|
@@ -161,17 +167,46 @@ class AnalyticLightNode extends LightingNode {
|
|
|
161
167
|
const { rtt, light } = this;
|
|
162
168
|
const { renderer, scene } = frame;
|
|
163
169
|
|
|
170
|
+
const currentOverrideMaterial = scene.overrideMaterial;
|
|
171
|
+
|
|
164
172
|
scene.overrideMaterial = depthMaterial;
|
|
165
173
|
|
|
166
174
|
rtt.setSize( light.shadow.mapSize.width, light.shadow.mapSize.height );
|
|
167
175
|
|
|
168
176
|
light.shadow.updateMatrices( light );
|
|
169
177
|
|
|
178
|
+
const currentRenderTarget = renderer.getRenderTarget();
|
|
179
|
+
const currentRenderObjectFunction = renderer.getRenderObjectFunction();
|
|
180
|
+
|
|
181
|
+
renderer.setRenderObjectFunction( ( object, ...params ) => {
|
|
182
|
+
|
|
183
|
+
if ( object.castShadow === true ) {
|
|
184
|
+
|
|
185
|
+
renderer.renderObject( object, ...params );
|
|
186
|
+
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
} );
|
|
190
|
+
|
|
170
191
|
renderer.setRenderTarget( rtt );
|
|
192
|
+
|
|
171
193
|
renderer.render( scene, light.shadow.camera );
|
|
172
|
-
renderer.setRenderTarget( null );
|
|
173
194
|
|
|
174
|
-
|
|
195
|
+
renderer.setRenderTarget( currentRenderTarget );
|
|
196
|
+
renderer.setRenderObjectFunction( currentRenderObjectFunction );
|
|
197
|
+
|
|
198
|
+
scene.overrideMaterial = currentOverrideMaterial;
|
|
199
|
+
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
disposeShadow() {
|
|
203
|
+
|
|
204
|
+
this.rtt.dispose();
|
|
205
|
+
|
|
206
|
+
this.shadowNode = null;
|
|
207
|
+
this.rtt = null;
|
|
208
|
+
|
|
209
|
+
this.colorNode = this._defaultColorNode;
|
|
175
210
|
|
|
176
211
|
}
|
|
177
212
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import LightingNode from './LightingNode.js';
|
|
2
2
|
import { cache } from '../core/CacheNode.js';
|
|
3
3
|
import { context } from '../core/ContextNode.js';
|
|
4
|
+
import { maxMipLevel } from '../utils/MaxMipLevelNode.js';
|
|
4
5
|
import { roughness, clearcoatRoughness } from '../core/PropertyNode.js';
|
|
5
6
|
import { equirectUV } from '../utils/EquirectUVNode.js';
|
|
6
7
|
import { specularMIPLevel } from '../utils/SpecularMIPLevelNode.js';
|
|
@@ -8,7 +9,7 @@ import { cameraViewMatrix } from '../accessors/CameraNode.js';
|
|
|
8
9
|
import { transformedClearcoatNormalView, transformedNormalView, transformedNormalWorld } from '../accessors/NormalNode.js';
|
|
9
10
|
import { positionViewDirection } from '../accessors/PositionNode.js';
|
|
10
11
|
import { addNodeClass } from '../core/Node.js';
|
|
11
|
-
import {
|
|
12
|
+
import { vec2 } from '../shadernode/ShaderNode.js';
|
|
12
13
|
import { cubeTexture } from '../accessors/CubeTextureNode.js';
|
|
13
14
|
import { reference } from '../accessors/ReferenceNode.js';
|
|
14
15
|
|
|
@@ -88,7 +89,7 @@ const createRadianceContext = ( roughnessNode, normalViewNode ) => {
|
|
|
88
89
|
let textureUVNode = null;
|
|
89
90
|
|
|
90
91
|
return {
|
|
91
|
-
|
|
92
|
+
getUV: ( textureNode ) => {
|
|
92
93
|
|
|
93
94
|
let node = null;
|
|
94
95
|
|
|
@@ -121,12 +122,12 @@ const createRadianceContext = ( roughnessNode, normalViewNode ) => {
|
|
|
121
122
|
return node;
|
|
122
123
|
|
|
123
124
|
},
|
|
124
|
-
|
|
125
|
+
getTextureLevel: () => {
|
|
125
126
|
|
|
126
127
|
return roughnessNode;
|
|
127
128
|
|
|
128
129
|
},
|
|
129
|
-
|
|
130
|
+
getTextureLevelAlgorithm: ( textureNode, levelNode ) => {
|
|
130
131
|
|
|
131
132
|
return specularMIPLevel( textureNode, levelNode );
|
|
132
133
|
|
|
@@ -140,7 +141,7 @@ const createIrradianceContext = ( normalWorldNode ) => {
|
|
|
140
141
|
let textureUVNode = null;
|
|
141
142
|
|
|
142
143
|
return {
|
|
143
|
-
|
|
144
|
+
getUV: ( textureNode ) => {
|
|
144
145
|
|
|
145
146
|
let node = null;
|
|
146
147
|
|
|
@@ -166,14 +167,9 @@ const createIrradianceContext = ( normalWorldNode ) => {
|
|
|
166
167
|
return node;
|
|
167
168
|
|
|
168
169
|
},
|
|
169
|
-
|
|
170
|
+
getTextureLevel: ( textureNode ) => {
|
|
170
171
|
|
|
171
|
-
return
|
|
172
|
-
|
|
173
|
-
},
|
|
174
|
-
getMIPLevelAlgorithmNode: ( textureNode, levelNode ) => {
|
|
175
|
-
|
|
176
|
-
return specularMIPLevel( textureNode, levelNode );
|
|
172
|
+
return maxMipLevel( textureNode );
|
|
177
173
|
|
|
178
174
|
}
|
|
179
175
|
};
|
|
@@ -33,6 +33,26 @@ class LightsNode extends Node {
|
|
|
33
33
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
getHash() {
|
|
37
|
+
|
|
38
|
+
if ( this._hash === null ) {
|
|
39
|
+
|
|
40
|
+
const hash = [];
|
|
41
|
+
|
|
42
|
+
for ( const lightNode of this.lightNodes ) {
|
|
43
|
+
|
|
44
|
+
hash.push( lightNode.getHash() );
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
this._hash = 'lights-' + hash.join( ',' );
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return this._hash;
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
36
56
|
setup( builder ) {
|
|
37
57
|
|
|
38
58
|
const context = builder.context;
|
|
@@ -57,7 +77,7 @@ class LightsNode extends Node {
|
|
|
57
77
|
for ( const lightNode of lightNodes ) {
|
|
58
78
|
|
|
59
79
|
lightNode.build( builder );
|
|
60
|
-
|
|
80
|
+
|
|
61
81
|
}
|
|
62
82
|
|
|
63
83
|
//
|
|
@@ -76,7 +96,7 @@ class LightsNode extends Node {
|
|
|
76
96
|
if ( backdrop !== null ) {
|
|
77
97
|
|
|
78
98
|
totalDiffuse = vec3( backdropAlpha !== null ? backdropAlpha.mix( totalDiffuse, backdrop ) : backdrop );
|
|
79
|
-
|
|
99
|
+
|
|
80
100
|
}
|
|
81
101
|
|
|
82
102
|
totalDiffuseNode.assign( totalDiffuse );
|
|
@@ -98,35 +118,11 @@ class LightsNode extends Node {
|
|
|
98
118
|
|
|
99
119
|
}
|
|
100
120
|
|
|
101
|
-
|
|
121
|
+
_getLightNodeById( id ) {
|
|
102
122
|
|
|
103
|
-
|
|
123
|
+
for ( const lightNode of this.lightNodes ) {
|
|
104
124
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const lightNodes = this.lightNodes;
|
|
108
|
-
|
|
109
|
-
for ( const lightNode of lightNodes ) {
|
|
110
|
-
|
|
111
|
-
hash += lightNode.getHash( builder ) + ' ';
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
this._hash = hash;
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return this._hash;
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
getLightNodeByHash( hash ) {
|
|
124
|
-
|
|
125
|
-
const lightNodes = this.lightNodes;
|
|
126
|
-
|
|
127
|
-
for ( const lightNode of lightNodes ) {
|
|
128
|
-
|
|
129
|
-
if ( lightNode.light.uuid === hash ) {
|
|
125
|
+
if ( lightNode.isAnalyticLightNode && lightNode.light.id === id ) {
|
|
130
126
|
|
|
131
127
|
return lightNode;
|
|
132
128
|
|
|
@@ -146,7 +142,7 @@ class LightsNode extends Node {
|
|
|
146
142
|
|
|
147
143
|
for ( const light of lights ) {
|
|
148
144
|
|
|
149
|
-
let lightNode = this.
|
|
145
|
+
let lightNode = this._getLightNodeById( light.id );
|
|
150
146
|
|
|
151
147
|
if ( lightNode === null ) {
|
|
152
148
|
|
|
@@ -173,11 +169,17 @@ class LightsNode extends Node {
|
|
|
173
169
|
export default LightsNode;
|
|
174
170
|
|
|
175
171
|
export const lights = ( lights ) => nodeObject( new LightsNode().fromLights( lights ) );
|
|
176
|
-
export const
|
|
172
|
+
export const lightNodes = nodeProxy( LightsNode );
|
|
177
173
|
|
|
178
174
|
export function addLightNode( lightClass, lightNodeClass ) {
|
|
179
175
|
|
|
180
|
-
if ( LightNodes.has( lightClass ) )
|
|
176
|
+
if ( LightNodes.has( lightClass ) ) {
|
|
177
|
+
|
|
178
|
+
console.warn( `Redefinition of light node ${ lightNodeClass.type }` );
|
|
179
|
+
return;
|
|
180
|
+
|
|
181
|
+
}
|
|
182
|
+
|
|
181
183
|
if ( typeof lightClass !== 'function' ) throw new Error( `Light ${ lightClass.name } is not a class` );
|
|
182
184
|
if ( typeof lightNodeClass !== 'function' || ! lightNodeClass.type ) throw new Error( `Light node ${ lightNodeClass.type } is not a class` );
|
|
183
185
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';
|
|
2
2
|
import { temp } from '../core/VarNode.js';
|
|
3
3
|
import { varying } from '../core/VaryingNode.js';
|
|
4
|
-
import { property } from '../core/PropertyNode.js';
|
|
4
|
+
import { property, varyingProperty } from '../core/PropertyNode.js';
|
|
5
5
|
import { attribute } from '../core/AttributeNode.js';
|
|
6
6
|
import { cameraProjectionMatrix } from '../accessors/CameraNode.js';
|
|
7
7
|
import { materialColor, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineDashOffset, materialLineWidth } from '../accessors/MaterialNode.js';
|
|
@@ -60,7 +60,7 @@ class Line2NodeMaterial extends NodeMaterial {
|
|
|
60
60
|
|
|
61
61
|
const a = cameraProjectionMatrix.element( 2 ).element( 2 ); // 3nd entry in 3th column
|
|
62
62
|
const b = cameraProjectionMatrix.element( 3 ).element( 2 ); // 3nd entry in 4th column
|
|
63
|
-
const nearEstimate = b.mul( -0.5 ).div( a );
|
|
63
|
+
const nearEstimate = b.mul( - 0.5 ).div( a );
|
|
64
64
|
|
|
65
65
|
const alpha = nearEstimate.sub( start.z ).div( end.z.sub( start.z ) );
|
|
66
66
|
|
|
@@ -70,7 +70,7 @@ class Line2NodeMaterial extends NodeMaterial {
|
|
|
70
70
|
|
|
71
71
|
this.vertexNode = tslFn( () => {
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
varyingProperty( 'vec2', 'vUv' ).assign( uv() );
|
|
74
74
|
|
|
75
75
|
const instanceStart = attribute( 'instanceStart' );
|
|
76
76
|
const instanceEnd = attribute( 'instanceEnd' );
|
|
@@ -85,8 +85,8 @@ class Line2NodeMaterial extends NodeMaterial {
|
|
|
85
85
|
|
|
86
86
|
if ( useWorldUnits ) {
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
varyingProperty( 'vec3', 'worldStart' ).assign( start.xyz );
|
|
89
|
+
varyingProperty( 'vec3', 'worldEnd' ).assign( end.xyz );
|
|
90
90
|
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -97,7 +97,7 @@ class Line2NodeMaterial extends NodeMaterial {
|
|
|
97
97
|
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
|
|
98
98
|
// perhaps there is a more elegant solution -- WestLangley
|
|
99
99
|
|
|
100
|
-
const perspective = cameraProjectionMatrix.element( 2 ).element( 3 ).equal( -1.0 ); // 4th entry in the 3rd column
|
|
100
|
+
const perspective = cameraProjectionMatrix.element( 2 ).element( 3 ).equal( - 1.0 ); // 4th entry in the 3rd column
|
|
101
101
|
|
|
102
102
|
If( perspective, () => {
|
|
103
103
|
|
|
@@ -173,7 +173,7 @@ class Line2NodeMaterial extends NodeMaterial {
|
|
|
173
173
|
|
|
174
174
|
// set the world position
|
|
175
175
|
|
|
176
|
-
const worldPos =
|
|
176
|
+
const worldPos = varyingProperty( 'vec4', 'worldPos' );
|
|
177
177
|
|
|
178
178
|
worldPos.assign( positionGeometry.y.lessThan( 0.5 ).cond( start, end ) );
|
|
179
179
|
worldPos.assign( worldPos.add( vec4( offset, 0 ) ) );
|
|
@@ -255,9 +255,9 @@ class Line2NodeMaterial extends NodeMaterial {
|
|
|
255
255
|
|
|
256
256
|
} );
|
|
257
257
|
|
|
258
|
-
this.
|
|
258
|
+
this.fragmentNode = tslFn( () => {
|
|
259
259
|
|
|
260
|
-
const vUv =
|
|
260
|
+
const vUv = varyingProperty( 'vec2', 'vUv' );
|
|
261
261
|
|
|
262
262
|
if ( useDash ) {
|
|
263
263
|
|
|
@@ -288,11 +288,11 @@ class Line2NodeMaterial extends NodeMaterial {
|
|
|
288
288
|
|
|
289
289
|
if ( useWorldUnits ) {
|
|
290
290
|
|
|
291
|
-
const worldStart =
|
|
292
|
-
const worldEnd =
|
|
291
|
+
const worldStart = varyingProperty( 'vec3', 'worldStart' );
|
|
292
|
+
const worldEnd = varyingProperty( 'vec3', 'worldEnd' );
|
|
293
293
|
|
|
294
294
|
// Find the closest points on the view ray and the line segment
|
|
295
|
-
const rayEnd =
|
|
295
|
+
const rayEnd = varyingProperty( 'vec4', 'worldPos' ).xyz.normalize().mul( 1e5 );
|
|
296
296
|
const lineDir = worldEnd.sub( worldStart );
|
|
297
297
|
const params = closestLineToLine( { p1: worldStart, p2: worldEnd, p3: vec3( 0.0, 0.0, 0.0 ), p4: rayEnd } );
|
|
298
298
|
|