super-three 0.155.0 → 0.156.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 +107 -125
- package/build/three.js +107 -125
- package/build/three.min.js +1 -1
- package/build/three.module.js +104 -126
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/OrbitControls.js +13 -5
- package/examples/jsm/csm/CSMShader.js +35 -1
- package/examples/jsm/libs/tween.module.js +790 -735
- package/examples/jsm/libs/utif.module.js +1644 -1558
- package/examples/jsm/loaders/DDSLoader.js +46 -3
- package/examples/jsm/loaders/EXRLoader.js +4 -4
- package/examples/jsm/loaders/FBXLoader.js +2 -0
- package/examples/jsm/loaders/GLTFLoader.js +17 -7
- package/examples/jsm/loaders/KTX2Loader.js +126 -77
- package/examples/jsm/loaders/LogLuvLoader.js +2 -2
- package/examples/jsm/loaders/MMDLoader.js +10 -7
- package/examples/jsm/loaders/RGBELoader.js +48 -66
- package/examples/jsm/loaders/STLLoader.js +7 -0
- package/examples/jsm/nodes/Nodes.js +3 -0
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +28 -2
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +18 -3
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +2 -4
- package/examples/jsm/nodes/accessors/LineMaterialNode.js +31 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +55 -33
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +3 -0
- package/examples/jsm/nodes/accessors/Object3DNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureNode.js +6 -2
- package/examples/jsm/nodes/accessors/TextureStoreNode.js +29 -0
- package/examples/jsm/nodes/core/AttributeNode.js +2 -2
- package/examples/jsm/nodes/core/Node.js +17 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +94 -12
- package/examples/jsm/nodes/core/NodeUniform.js +1 -1
- package/examples/jsm/nodes/core/OutputStructNode.js +58 -0
- package/examples/jsm/nodes/core/PropertyNode.js +2 -0
- package/examples/jsm/nodes/core/StackNode.js +4 -4
- package/examples/jsm/nodes/core/StructTypeNode.js +24 -0
- package/examples/jsm/nodes/display/ViewportNode.js +19 -5
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -0
- package/examples/jsm/nodes/materials/Materials.js +1 -0
- package/examples/jsm/nodes/materials/NodeMaterial.js +12 -3
- package/examples/jsm/nodes/math/HashNode.js +35 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +4 -0
- package/examples/jsm/nodes/utils/SplitNode.js +1 -1
- package/examples/jsm/postprocessing/FilmPass.js +3 -5
- package/examples/jsm/postprocessing/RenderPass.js +30 -12
- package/examples/jsm/postprocessing/SAOPass.js +23 -98
- package/examples/jsm/postprocessing/SSAOPass.js +10 -30
- package/examples/jsm/renderers/common/Backend.js +11 -8
- package/examples/jsm/renderers/common/Binding.js +6 -0
- package/examples/jsm/renderers/common/Bindings.js +5 -4
- package/examples/jsm/renderers/common/Pipelines.js +2 -2
- package/examples/jsm/renderers/common/RenderContexts.js +26 -1
- package/examples/jsm/renderers/common/RenderList.js +12 -4
- package/examples/jsm/renderers/common/RenderObject.js +6 -2
- package/examples/jsm/renderers/common/Renderer.js +12 -3
- package/examples/jsm/renderers/common/SampledTexture.js +2 -1
- package/examples/jsm/renderers/common/Sampler.js +1 -1
- package/examples/jsm/renderers/common/StorageBuffer.js +1 -1
- package/examples/jsm/renderers/common/Textures.js +155 -15
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +1 -1
- package/examples/jsm/renderers/common/nodes/Nodes.js +43 -9
- package/examples/jsm/renderers/webgl/WebGLBackend.js +607 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +118 -17
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +84 -0
- package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +26 -0
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +529 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +199 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +242 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +340 -0
- package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodeBuilder.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +279 -40
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +18 -2
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +89 -59
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -2
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +15 -2
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +34 -9
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +26 -135
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +6 -5
- package/examples/jsm/shaders/FilmShader.js +11 -54
- package/examples/jsm/shaders/SAOShader.js +0 -13
- package/examples/jsm/shaders/SSAOShader.js +33 -26
- package/package.json +1 -1
- package/src/Three.js +1 -0
- package/src/audio/Audio.js +6 -0
- package/src/constants.js +4 -1
- package/src/core/Object3D.js +1 -14
- package/src/core/UniformsGroup.js +2 -2
- package/src/loaders/DataTextureLoader.js +0 -2
- package/src/materials/Material.js +2 -2
- package/src/math/Vector2.js +2 -2
- package/src/math/Vector3.js +3 -3
- package/src/math/Vector4.js +4 -4
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/renderers/WebGLRenderer.js +21 -49
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +11 -1
- package/src/renderers/shaders/ShaderLib/background.glsl.js +8 -0
- package/src/renderers/webgl/WebGLBackground.js +5 -14
- package/src/renderers/webgl/WebGLProgram.js +2 -0
- package/src/renderers/webgl/WebGLPrograms.js +5 -1
- package/src/renderers/webgl/WebGLTextures.js +4 -4
- package/src/renderers/webgl/WebGLUtils.js +27 -20
- package/src/textures/Texture.js +2 -2
- package/src/utils.js +9 -1
- /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/SlotNode.js +0 -0
- /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodes.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Node, { addNodeClass } from '../core/Node.js';
|
|
2
2
|
import { NodeUpdateType } from '../core/constants.js';
|
|
3
|
-
import
|
|
3
|
+
import UniformNode from '../core/UniformNode.js';
|
|
4
4
|
import { nodeProxy } from '../shadernode/ShaderNode.js';
|
|
5
5
|
|
|
6
6
|
import { Vector3 } from 'three';
|
|
@@ -16,7 +16,7 @@ class Object3DNode extends Node {
|
|
|
16
16
|
|
|
17
17
|
this.updateType = NodeUpdateType.OBJECT;
|
|
18
18
|
|
|
19
|
-
this._uniformNode =
|
|
19
|
+
this._uniformNode = new UniformNode( null );
|
|
20
20
|
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -168,8 +168,12 @@ class TextureNode extends UniformNode {
|
|
|
168
168
|
|
|
169
169
|
builder.addLineFlowCode( `${propertyName} = ${snippet}` );
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
if ( builder.context.tempWrite !== false ) {
|
|
172
|
+
|
|
173
|
+
nodeData.snippet = snippet;
|
|
174
|
+
nodeData.propertyName = propertyName;
|
|
175
|
+
|
|
176
|
+
}
|
|
173
177
|
|
|
174
178
|
}
|
|
175
179
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { addNodeClass } from '../core/Node.js';
|
|
2
|
+
import TextureNode from './TextureNode.js';
|
|
3
|
+
import { nodeProxy } from '../shadernode/ShaderNode.js';
|
|
4
|
+
|
|
5
|
+
class TextureStoreNode extends TextureNode {
|
|
6
|
+
|
|
7
|
+
constructor( value, uvNode, storeNode = null ) {
|
|
8
|
+
|
|
9
|
+
super( value, uvNode );
|
|
10
|
+
|
|
11
|
+
this.storeNode = storeNode;
|
|
12
|
+
|
|
13
|
+
this.isStoreTextureNode = true;
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getNodeType( /*builder*/ ) {
|
|
18
|
+
|
|
19
|
+
return 'void';
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default TextureStoreNode;
|
|
26
|
+
|
|
27
|
+
export const textureStore = nodeProxy( TextureStoreNode );
|
|
28
|
+
|
|
29
|
+
addNodeClass( TextureStoreNode );
|
|
@@ -20,12 +20,12 @@ class AttributeNode extends Node {
|
|
|
20
20
|
|
|
21
21
|
getNodeType( builder ) {
|
|
22
22
|
|
|
23
|
-
const attributeName = this.getAttributeName( builder );
|
|
24
|
-
|
|
25
23
|
let nodeType = super.getNodeType( builder );
|
|
26
24
|
|
|
27
25
|
if ( nodeType === null ) {
|
|
28
26
|
|
|
27
|
+
const attributeName = this.getAttributeName( builder );
|
|
28
|
+
|
|
29
29
|
if ( builder.hasGeometryAttribute( attributeName ) ) {
|
|
30
30
|
|
|
31
31
|
const attribute = builder.geometry.getAttribute( attributeName );
|
|
@@ -32,6 +32,14 @@ class Node extends EventDispatcher {
|
|
|
32
32
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
getSelf() {
|
|
36
|
+
|
|
37
|
+
// Returns non-node object.
|
|
38
|
+
|
|
39
|
+
return this.self || this;
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
35
43
|
isGlobal( /*builder*/ ) {
|
|
36
44
|
|
|
37
45
|
return false;
|
|
@@ -97,7 +105,15 @@ class Node extends EventDispatcher {
|
|
|
97
105
|
|
|
98
106
|
}
|
|
99
107
|
|
|
100
|
-
getNodeType(
|
|
108
|
+
getNodeType( builder ) {
|
|
109
|
+
|
|
110
|
+
const nodeProperties = builder.getNodeProperties( this );
|
|
111
|
+
|
|
112
|
+
if ( nodeProperties.outputNode ) {
|
|
113
|
+
|
|
114
|
+
return nodeProperties.outputNode.getNodeType( builder );
|
|
115
|
+
|
|
116
|
+
}
|
|
101
117
|
|
|
102
118
|
return this.nodeType;
|
|
103
119
|
|
|
@@ -8,11 +8,18 @@ import NodeCache from './NodeCache.js';
|
|
|
8
8
|
import { createNodeMaterialFromType } from '../materials/NodeMaterial.js';
|
|
9
9
|
import { NodeUpdateType, defaultBuildStages, shaderStages } from './constants.js';
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
FloatNodeUniform, Vector2NodeUniform, Vector3NodeUniform, Vector4NodeUniform,
|
|
13
|
+
ColorNodeUniform, Matrix3NodeUniform, Matrix4NodeUniform
|
|
14
|
+
} from '../../renderers/common/nodes/NodeUniform.js';
|
|
15
|
+
|
|
16
|
+
import { REVISION, RenderTarget, NoColorSpace, LinearEncoding, sRGBEncoding, SRGBColorSpace, Color, Vector2, Vector3, Vector4, Float16BufferAttribute } from 'three';
|
|
12
17
|
|
|
13
18
|
import { stack } from './StackNode.js';
|
|
14
19
|
import { maxMipLevel } from '../utils/MaxMipLevelNode.js';
|
|
15
20
|
|
|
21
|
+
import CubeRenderTarget from '../../renderers/common/CubeRenderTarget.js';
|
|
22
|
+
|
|
16
23
|
const typeFromLength = new Map( [
|
|
17
24
|
[ 2, 'vec2' ],
|
|
18
25
|
[ 3, 'vec3' ],
|
|
@@ -69,6 +76,7 @@ class NodeBuilder {
|
|
|
69
76
|
this.flowNodes = { vertex: [], fragment: [], compute: [] };
|
|
70
77
|
this.flowCode = { vertex: '', fragment: '', compute: [] };
|
|
71
78
|
this.uniforms = { vertex: [], fragment: [], compute: [], index: 0 };
|
|
79
|
+
this.structs = { vertex: [], fragment: [], compute: [], index: 0 };
|
|
72
80
|
this.codes = { vertex: [], fragment: [], compute: [] };
|
|
73
81
|
this.bindings = { vertex: [], fragment: [], compute: [] };
|
|
74
82
|
this.bindingsOffset = { vertex: 0, fragment: 0, compute: 0 };
|
|
@@ -98,12 +106,38 @@ class NodeBuilder {
|
|
|
98
106
|
|
|
99
107
|
}
|
|
100
108
|
|
|
109
|
+
getRenderTarget( width, height, options ) {
|
|
110
|
+
|
|
111
|
+
return new RenderTarget( width, height, options );
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
getCubeRenderTarget( size, options ) {
|
|
116
|
+
|
|
117
|
+
return new CubeRenderTarget( size, options );
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
101
121
|
includes( node ) {
|
|
102
122
|
|
|
103
123
|
return this.nodes.includes( node );
|
|
104
124
|
|
|
105
125
|
}
|
|
106
126
|
|
|
127
|
+
createBindings() {
|
|
128
|
+
|
|
129
|
+
const bindingsArray = [];
|
|
130
|
+
|
|
131
|
+
for ( const binding of this.getBindings() ) {
|
|
132
|
+
|
|
133
|
+
bindingsArray.push( binding.clone() );
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return bindingsArray;
|
|
138
|
+
|
|
139
|
+
}
|
|
140
|
+
|
|
107
141
|
getBindings() {
|
|
108
142
|
|
|
109
143
|
let bindingsArray = this.bindingsArray;
|
|
@@ -128,14 +162,26 @@ class NodeBuilder {
|
|
|
128
162
|
|
|
129
163
|
addNode( node ) {
|
|
130
164
|
|
|
131
|
-
if ( this.nodes.
|
|
165
|
+
if ( this.nodes.includes( node ) === false ) {
|
|
166
|
+
|
|
167
|
+
this.nodes.push( node );
|
|
168
|
+
|
|
169
|
+
this.setHashNode( node, node.getHash( this ) );
|
|
170
|
+
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
buildUpdateNodes() {
|
|
176
|
+
|
|
177
|
+
for ( const node of this.nodes ) {
|
|
132
178
|
|
|
133
179
|
const updateType = node.getUpdateType();
|
|
134
180
|
const updateBeforeType = node.getUpdateBeforeType();
|
|
135
181
|
|
|
136
182
|
if ( updateType !== NodeUpdateType.NONE ) {
|
|
137
183
|
|
|
138
|
-
this.updateNodes.push( node );
|
|
184
|
+
this.updateNodes.push( node.getSelf() );
|
|
139
185
|
|
|
140
186
|
}
|
|
141
187
|
|
|
@@ -145,10 +191,6 @@ class NodeBuilder {
|
|
|
145
191
|
|
|
146
192
|
}
|
|
147
193
|
|
|
148
|
-
this.nodes.push( node );
|
|
149
|
-
|
|
150
|
-
this.setHashNode( node, node.getHash( this ) );
|
|
151
|
-
|
|
152
194
|
}
|
|
153
195
|
|
|
154
196
|
}
|
|
@@ -331,6 +373,8 @@ class NodeBuilder {
|
|
|
331
373
|
|
|
332
374
|
getType( type ) {
|
|
333
375
|
|
|
376
|
+
if ( type === 'color' ) return 'vec3';
|
|
377
|
+
|
|
334
378
|
return type;
|
|
335
379
|
|
|
336
380
|
}
|
|
@@ -561,17 +605,19 @@ class NodeBuilder {
|
|
|
561
605
|
|
|
562
606
|
if ( nodeData === undefined ) {
|
|
563
607
|
|
|
564
|
-
nodeData = {
|
|
608
|
+
nodeData = {};
|
|
565
609
|
|
|
566
610
|
cache.setNodeData( node, nodeData );
|
|
567
611
|
|
|
568
612
|
}
|
|
569
613
|
|
|
570
|
-
|
|
614
|
+
if ( nodeData[ shaderStage ] === undefined ) nodeData[ shaderStage ] = {};
|
|
615
|
+
|
|
616
|
+
return nodeData[ shaderStage ];
|
|
571
617
|
|
|
572
618
|
}
|
|
573
619
|
|
|
574
|
-
getNodeProperties( node, shaderStage =
|
|
620
|
+
getNodeProperties( node, shaderStage = 'any' ) {
|
|
575
621
|
|
|
576
622
|
const nodeData = this.getDataFromNode( node, shaderStage );
|
|
577
623
|
|
|
@@ -601,6 +647,27 @@ class NodeBuilder {
|
|
|
601
647
|
|
|
602
648
|
}
|
|
603
649
|
|
|
650
|
+
getStructTypeFromNode( node, shaderStage = this.shaderStage, name = null ) {
|
|
651
|
+
|
|
652
|
+
const nodeData = this.getDataFromNode( node, shaderStage );
|
|
653
|
+
|
|
654
|
+
let nodeStruct = nodeData.structType;
|
|
655
|
+
|
|
656
|
+
if ( nodeStruct === undefined ) {
|
|
657
|
+
|
|
658
|
+
const index = this.structs.index ++;
|
|
659
|
+
|
|
660
|
+
node.name = `StructType${index}`;
|
|
661
|
+
this.structs[ shaderStage ].push( node );
|
|
662
|
+
|
|
663
|
+
nodeData.structType = node;
|
|
664
|
+
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
return node;
|
|
668
|
+
|
|
669
|
+
}
|
|
670
|
+
|
|
604
671
|
getUniformFromNode( node, type, shaderStage = this.shaderStage, name = null ) {
|
|
605
672
|
|
|
606
673
|
const nodeData = this.getDataFromNode( node, shaderStage );
|
|
@@ -648,7 +715,7 @@ class NodeBuilder {
|
|
|
648
715
|
|
|
649
716
|
getVaryingFromNode( node, type ) {
|
|
650
717
|
|
|
651
|
-
const nodeData = this.getDataFromNode( node,
|
|
718
|
+
const nodeData = this.getDataFromNode( node, 'any' );
|
|
652
719
|
|
|
653
720
|
let nodeVarying = nodeData.varying;
|
|
654
721
|
|
|
@@ -812,7 +879,7 @@ class NodeBuilder {
|
|
|
812
879
|
|
|
813
880
|
getVar( type, name ) {
|
|
814
881
|
|
|
815
|
-
return `${type} ${name}`;
|
|
882
|
+
return `${ this.getType( type ) } ${ name }`;
|
|
816
883
|
|
|
817
884
|
}
|
|
818
885
|
|
|
@@ -936,11 +1003,26 @@ class NodeBuilder {
|
|
|
936
1003
|
// stage 4: build code for a specific output
|
|
937
1004
|
|
|
938
1005
|
this.buildCode();
|
|
1006
|
+
this.buildUpdateNodes();
|
|
939
1007
|
|
|
940
1008
|
return this;
|
|
941
1009
|
|
|
942
1010
|
}
|
|
943
1011
|
|
|
1012
|
+
getNodeUniform( uniformNode, type ) {
|
|
1013
|
+
|
|
1014
|
+
if ( type === 'float' ) return new FloatNodeUniform( uniformNode );
|
|
1015
|
+
if ( type === 'vec2' ) return new Vector2NodeUniform( uniformNode );
|
|
1016
|
+
if ( type === 'vec3' ) return new Vector3NodeUniform( uniformNode );
|
|
1017
|
+
if ( type === 'vec4' ) return new Vector4NodeUniform( uniformNode );
|
|
1018
|
+
if ( type === 'color' ) return new ColorNodeUniform( uniformNode );
|
|
1019
|
+
if ( type === 'mat3' ) return new Matrix3NodeUniform( uniformNode );
|
|
1020
|
+
if ( type === 'mat4' ) return new Matrix4NodeUniform( uniformNode );
|
|
1021
|
+
|
|
1022
|
+
throw new Error( `Uniform "${type}" not declared.` );
|
|
1023
|
+
|
|
1024
|
+
}
|
|
1025
|
+
|
|
944
1026
|
createNodeMaterial( type ) {
|
|
945
1027
|
|
|
946
1028
|
return createNodeMaterialFromType( type );
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import Node, { addNodeClass } from './Node.js';
|
|
2
|
+
import StructTypeNode from './StructTypeNode.js';
|
|
3
|
+
import { nodeProxy } from '../shadernode/ShaderNode.js';
|
|
4
|
+
|
|
5
|
+
class OutputStructNode extends Node {
|
|
6
|
+
|
|
7
|
+
constructor( ...members ) {
|
|
8
|
+
|
|
9
|
+
super();
|
|
10
|
+
|
|
11
|
+
this.isOutputStructNode = true;
|
|
12
|
+
this.members = members;
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
construct( builder ) {
|
|
17
|
+
|
|
18
|
+
super.construct( builder );
|
|
19
|
+
|
|
20
|
+
const members = this.members;
|
|
21
|
+
const types = [];
|
|
22
|
+
|
|
23
|
+
for ( let i = 0; i < members.length; i++ ) {
|
|
24
|
+
|
|
25
|
+
types.push( members[ i ].getNodeType( builder ) );
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
this.nodeType = builder.getStructTypeFromNode( new StructTypeNode( types ) ).name;
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
generate( builder, output ) {
|
|
34
|
+
|
|
35
|
+
const nodeVar = builder.getVarFromNode( this, this.nodeType );
|
|
36
|
+
const propertyName = builder.getPropertyName( nodeVar );
|
|
37
|
+
|
|
38
|
+
const members = this.members;
|
|
39
|
+
|
|
40
|
+
for ( let i = 0; i < members.length; i++ ) {
|
|
41
|
+
|
|
42
|
+
const snippet = members[ i ].build( builder, output );
|
|
43
|
+
|
|
44
|
+
builder.addLineFlowCode( `${propertyName}.m${i} = ${snippet}` );
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return propertyName;
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default OutputStructNode;
|
|
55
|
+
|
|
56
|
+
export const outputStruct = nodeProxy( OutputStructNode );
|
|
57
|
+
|
|
58
|
+
addNodeClass( OutputStructNode );
|
|
@@ -57,5 +57,7 @@ export const iridescenceThickness = nodeImmutable( PropertyNode, 'float', 'Iride
|
|
|
57
57
|
export const specularColor = nodeImmutable( PropertyNode, 'color', 'SpecularColor' );
|
|
58
58
|
export const shininess = nodeImmutable( PropertyNode, 'float', 'Shininess' );
|
|
59
59
|
export const output = nodeImmutable( PropertyNode, 'vec4', 'Output' );
|
|
60
|
+
export const dashSize = nodeImmutable( PropertyNode, 'float', 'dashScale' );
|
|
61
|
+
export const gapSize= nodeImmutable( PropertyNode, 'float', 'gapSize' );
|
|
60
62
|
|
|
61
63
|
addNodeClass( PropertyNode );
|
|
@@ -4,7 +4,7 @@ import { bypass } from '../core/BypassNode.js';
|
|
|
4
4
|
import { expression } from '../code/ExpressionNode.js';
|
|
5
5
|
import { cond } from '../math/CondNode.js';
|
|
6
6
|
import { loop } from '../utils/LoopNode.js';
|
|
7
|
-
import {
|
|
7
|
+
import { ShaderNode, nodeProxy } from '../shadernode/ShaderNode.js';
|
|
8
8
|
|
|
9
9
|
class StackNode extends Node {
|
|
10
10
|
|
|
@@ -39,7 +39,7 @@ class StackNode extends Node {
|
|
|
39
39
|
|
|
40
40
|
if( boolNode, method ) {
|
|
41
41
|
|
|
42
|
-
const methodNode =
|
|
42
|
+
const methodNode = new ShaderNode( method );
|
|
43
43
|
this._currentCond = cond( boolNode, methodNode );
|
|
44
44
|
|
|
45
45
|
return this.add( this._currentCond );
|
|
@@ -48,7 +48,7 @@ class StackNode extends Node {
|
|
|
48
48
|
|
|
49
49
|
elseif( boolNode, method ) {
|
|
50
50
|
|
|
51
|
-
const methodNode =
|
|
51
|
+
const methodNode = new ShaderNode( method );
|
|
52
52
|
const ifNode = cond( boolNode, methodNode );
|
|
53
53
|
|
|
54
54
|
this._currentCond.elseNode = ifNode;
|
|
@@ -60,7 +60,7 @@ class StackNode extends Node {
|
|
|
60
60
|
|
|
61
61
|
else( method ) {
|
|
62
62
|
|
|
63
|
-
this._currentCond.elseNode =
|
|
63
|
+
this._currentCond.elseNode = new ShaderNode( method );
|
|
64
64
|
|
|
65
65
|
return this;
|
|
66
66
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Node, { addNodeClass } from './Node.js';
|
|
2
|
+
|
|
3
|
+
class StructTypeNode extends Node {
|
|
4
|
+
|
|
5
|
+
constructor( types ) {
|
|
6
|
+
|
|
7
|
+
super();
|
|
8
|
+
|
|
9
|
+
this.types = types;
|
|
10
|
+
this.isStructTypeNode = true;
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getMemberTypes() {
|
|
15
|
+
|
|
16
|
+
return this.types;
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default StructTypeNode;
|
|
23
|
+
|
|
24
|
+
addNodeClass( StructTypeNode );
|
|
@@ -3,9 +3,9 @@ import { NodeUpdateType } from '../core/constants.js';
|
|
|
3
3
|
import { uniform } from '../core/UniformNode.js';
|
|
4
4
|
import { nodeImmutable, vec2 } from '../shadernode/ShaderNode.js';
|
|
5
5
|
|
|
6
|
-
import { Vector2 } from 'three';
|
|
6
|
+
import { Vector2, Vector4 } from 'three';
|
|
7
7
|
|
|
8
|
-
let resolution;
|
|
8
|
+
let resolution, viewportResult;
|
|
9
9
|
|
|
10
10
|
class ViewportNode extends Node {
|
|
11
11
|
|
|
@@ -21,7 +21,7 @@ class ViewportNode extends Node {
|
|
|
21
21
|
|
|
22
22
|
getNodeType() {
|
|
23
23
|
|
|
24
|
-
return this.scope === ViewportNode.COORDINATE ? 'vec4' : 'vec2';
|
|
24
|
+
return this.scope === ViewportNode.COORDINATE || this.scope === ViewportNode.VIEWPORT ? 'vec4' : 'vec2';
|
|
25
25
|
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -29,7 +29,7 @@ class ViewportNode extends Node {
|
|
|
29
29
|
|
|
30
30
|
let updateType = NodeUpdateType.NONE;
|
|
31
31
|
|
|
32
|
-
if ( this.scope === ViewportNode.RESOLUTION ) {
|
|
32
|
+
if ( this.scope === ViewportNode.RESOLUTION || this.scope === ViewportNode.VIEWPORT ) {
|
|
33
33
|
|
|
34
34
|
updateType = NodeUpdateType.FRAME;
|
|
35
35
|
|
|
@@ -43,7 +43,15 @@ class ViewportNode extends Node {
|
|
|
43
43
|
|
|
44
44
|
update( { renderer } ) {
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
if ( this.scope === ViewportNode.VIEWPORT ) {
|
|
47
|
+
|
|
48
|
+
renderer.getViewport( viewportResult );
|
|
49
|
+
|
|
50
|
+
} else {
|
|
51
|
+
|
|
52
|
+
renderer.getDrawingBufferSize( resolution );
|
|
53
|
+
|
|
54
|
+
}
|
|
47
55
|
|
|
48
56
|
}
|
|
49
57
|
|
|
@@ -59,6 +67,10 @@ class ViewportNode extends Node {
|
|
|
59
67
|
|
|
60
68
|
output = uniform( resolution || ( resolution = new Vector2() ) );
|
|
61
69
|
|
|
70
|
+
} else if ( scope === ViewportNode.VIEWPORT ) {
|
|
71
|
+
|
|
72
|
+
output = uniform( viewportResult || ( viewportResult = new Vector4() ) );
|
|
73
|
+
|
|
62
74
|
} else {
|
|
63
75
|
|
|
64
76
|
const coordinateNode = vec2( new ViewportNode( ViewportNode.COORDINATE ) );
|
|
@@ -98,6 +110,7 @@ class ViewportNode extends Node {
|
|
|
98
110
|
|
|
99
111
|
ViewportNode.COORDINATE = 'coordinate';
|
|
100
112
|
ViewportNode.RESOLUTION = 'resolution';
|
|
113
|
+
ViewportNode.VIEWPORT = 'viewport';
|
|
101
114
|
ViewportNode.TOP_LEFT = 'topLeft';
|
|
102
115
|
ViewportNode.BOTTOM_LEFT = 'bottomLeft';
|
|
103
116
|
ViewportNode.TOP_RIGHT = 'topRight';
|
|
@@ -107,6 +120,7 @@ export default ViewportNode;
|
|
|
107
120
|
|
|
108
121
|
export const viewportCoordinate = nodeImmutable( ViewportNode, ViewportNode.COORDINATE );
|
|
109
122
|
export const viewportResolution = nodeImmutable( ViewportNode, ViewportNode.RESOLUTION );
|
|
123
|
+
export const viewport = nodeImmutable( ViewportNode, ViewportNode.VIEWPORT );
|
|
110
124
|
export const viewportTopLeft = nodeImmutable( ViewportNode, ViewportNode.TOP_LEFT );
|
|
111
125
|
export const viewportBottomLeft = nodeImmutable( ViewportNode, ViewportNode.BOTTOM_LEFT );
|
|
112
126
|
export const viewportTopRight = nodeImmutable( ViewportNode, ViewportNode.TOP_RIGHT );
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';
|
|
2
|
+
import { attribute } from '../core/AttributeNode.js';
|
|
3
|
+
import { varying } from '../core/VaryingNode.js';
|
|
4
|
+
import { materialLineDashSize, materialLineGapSize, materialLineScale } from '../accessors/LineMaterialNode.js';
|
|
5
|
+
import { dashSize, gapSize } from '../core/PropertyNode.js';
|
|
6
|
+
import { float } from '../shadernode/ShaderNode.js';
|
|
7
|
+
import { LineDashedMaterial } from 'three';
|
|
8
|
+
|
|
9
|
+
const defaultValues = new LineDashedMaterial();
|
|
10
|
+
|
|
11
|
+
class LineDashedNodeMaterial extends NodeMaterial {
|
|
12
|
+
|
|
13
|
+
constructor( parameters ) {
|
|
14
|
+
|
|
15
|
+
super();
|
|
16
|
+
|
|
17
|
+
this.isLineDashedNodeMaterial = true;
|
|
18
|
+
|
|
19
|
+
this.lights = false;
|
|
20
|
+
this.normals = false;
|
|
21
|
+
|
|
22
|
+
this.setDefaultValues( defaultValues );
|
|
23
|
+
|
|
24
|
+
this.offsetNode = null;
|
|
25
|
+
this.dashScaleNode = null;
|
|
26
|
+
this.dashSizeNode = null;
|
|
27
|
+
this.gapSizeNode = null;
|
|
28
|
+
|
|
29
|
+
this.setValues( parameters );
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
constructVariants( { stack } ) {
|
|
34
|
+
|
|
35
|
+
const offsetNode = this.offsetNode;
|
|
36
|
+
const dashScaleNode = this.dashScaleNode ? float( this.dashScaleNode ) : materialLineScale;
|
|
37
|
+
const dashSizeNode = this.dashSizeNode ? float( this.dashSizeNode ) : materialLineDashSize;
|
|
38
|
+
const gapSizeNode = this.dashSizeNode ? float( this.dashGapNode ) : materialLineGapSize;
|
|
39
|
+
|
|
40
|
+
stack.assign( dashSize, dashSizeNode );
|
|
41
|
+
stack.assign( gapSize, gapSizeNode );
|
|
42
|
+
|
|
43
|
+
const vLineDistance = varying( attribute( 'lineDistance' ).mul( dashScaleNode ) );
|
|
44
|
+
const vLineDistanceOffset = offsetNode ? vLineDistance.add( offsetNode ) : vLineDistance;
|
|
45
|
+
|
|
46
|
+
stack.add( vLineDistanceOffset.mod( dashSize.add( gapSize ) ).greaterThan( dashSize ).discard() );
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default LineDashedNodeMaterial;
|
|
53
|
+
|
|
54
|
+
addNodeMaterial( LineDashedNodeMaterial );
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
export { default as NodeMaterial, addNodeMaterial, createNodeMaterialFromType } from './NodeMaterial.js';
|
|
4
4
|
export { default as LineBasicNodeMaterial } from './LineBasicNodeMaterial.js';
|
|
5
|
+
export { default as LineDashedNodeMaterial } from './LineDashedNodeMaterial.js';
|
|
5
6
|
export { default as MeshNormalNodeMaterial } from './MeshNormalNodeMaterial.js';
|
|
6
7
|
export { default as MeshBasicNodeMaterial } from './MeshBasicNodeMaterial.js';
|
|
7
8
|
export { default as MeshLambertNodeMaterial } from './MeshLambertNodeMaterial.js';
|
|
@@ -16,6 +16,7 @@ import { lightsWithoutWrap } from '../lighting/LightsNode.js';
|
|
|
16
16
|
import { mix, dFdx, dFdy } from '../math/MathNode.js';
|
|
17
17
|
import { float, vec3, vec4 } from '../shadernode/ShaderNode.js';
|
|
18
18
|
import AONode from '../lighting/AONode.js';
|
|
19
|
+
import { lightingContext } from '../lighting/LightingContextNode.js';
|
|
19
20
|
import EnvironmentNode from '../lighting/EnvironmentNode.js';
|
|
20
21
|
|
|
21
22
|
const NodeMaterials = new Map();
|
|
@@ -290,7 +291,7 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
290
291
|
|
|
291
292
|
const lightingModelNode = this.constructLightingModel( builder );
|
|
292
293
|
|
|
293
|
-
outgoingLightNode =
|
|
294
|
+
outgoingLightNode = lightingContext( lightsNode, lightingModelNode, backdropNode, backdropAlphaNode );
|
|
294
295
|
|
|
295
296
|
} else if ( backdropNode !== null ) {
|
|
296
297
|
|
|
@@ -302,7 +303,7 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
302
303
|
|
|
303
304
|
if ( ( emissiveNode && emissiveNode.isNode === true ) || ( material.emissive && material.emissive.isColor === true ) ) {
|
|
304
305
|
|
|
305
|
-
outgoingLightNode = outgoingLightNode.add( emissiveNode ?
|
|
306
|
+
outgoingLightNode = outgoingLightNode.add( vec3( emissiveNode ? emissiveNode : materialEmissive ) );
|
|
306
307
|
|
|
307
308
|
}
|
|
308
309
|
|
|
@@ -344,7 +345,15 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
344
345
|
|
|
345
346
|
if ( renderTarget !== null ) {
|
|
346
347
|
|
|
347
|
-
|
|
348
|
+
if ( Array.isArray( renderTarget.texture ) ) {
|
|
349
|
+
|
|
350
|
+
outputColorSpace = renderTarget.texture[ 0 ].colorSpace;
|
|
351
|
+
|
|
352
|
+
} else {
|
|
353
|
+
|
|
354
|
+
outputColorSpace = renderTarget.texture.colorSpace;
|
|
355
|
+
|
|
356
|
+
}
|
|
348
357
|
|
|
349
358
|
} else {
|
|
350
359
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Node, { addNodeClass } from '../core/Node.js';
|
|
2
|
+
import { add, mul, bitXor, shiftRight } from './OperatorNode.js';
|
|
3
|
+
import { addNodeElement, nodeProxy, uint } from '../shadernode/ShaderNode.js';
|
|
4
|
+
|
|
5
|
+
class HashNode extends Node {
|
|
6
|
+
|
|
7
|
+
constructor( seedNode ) {
|
|
8
|
+
|
|
9
|
+
super();
|
|
10
|
+
|
|
11
|
+
this.seedNode = seedNode;
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
construct( /*builder*/ ) {
|
|
16
|
+
|
|
17
|
+
const seed = this.seedNode;
|
|
18
|
+
|
|
19
|
+
const state = add( mul( uint( seed ), 747796405 ), 2891336453 );
|
|
20
|
+
const word = mul( bitXor( shiftRight( state, add( shiftRight( state, 28 ), 4 ) ), state ), 277803737 );
|
|
21
|
+
const uintResult = bitXor( shiftRight( word, 22 ), word );
|
|
22
|
+
|
|
23
|
+
return mul( 1 / 2 ** 32, uintResult ); // Convert to range [0, 1)
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default HashNode;
|
|
30
|
+
|
|
31
|
+
export const hash = nodeProxy( HashNode );
|
|
32
|
+
|
|
33
|
+
addNodeElement( 'hash', hash );
|
|
34
|
+
|
|
35
|
+
addNodeClass( HashNode );
|
|
@@ -37,6 +37,10 @@ const shaderNodeHandler = {
|
|
|
37
37
|
|
|
38
38
|
return ( ...params ) => nodeElement( nodeObj, ...params );
|
|
39
39
|
|
|
40
|
+
} else if ( prop === 'self' ) {
|
|
41
|
+
|
|
42
|
+
return node;
|
|
43
|
+
|
|
40
44
|
} else if ( prop.endsWith( 'Assign' ) && NodeElements.has( prop.slice( 0, prop.length - 'Assign'.length ) ) ) {
|
|
41
45
|
|
|
42
46
|
const nodeElement = NodeElements.get( prop.slice( 0, prop.length - 'Assign'.length ) );
|