super-three 0.161.0 → 0.162.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 +490 -393
- package/build/three.module.js +490 -391
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/DragControls.js +91 -30
- package/examples/jsm/controls/OrbitControls.js +32 -6
- package/examples/jsm/controls/TransformControls.js +6 -6
- package/examples/jsm/exporters/GLTFExporter.js +11 -1
- package/examples/jsm/interactive/InteractiveGroup.js +15 -25
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +1 -8723
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +1 -8734
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/libs/tween.module.js +32 -14
- package/examples/jsm/loaders/3DMLoader.js +13 -21
- package/examples/jsm/loaders/VOXLoader.js +9 -2
- package/examples/jsm/loaders/VRMLLoader.js +6 -2
- package/examples/jsm/misc/ProgressiveLightMap.js +1 -0
- package/examples/jsm/nodes/Nodes.js +9 -7
- package/examples/jsm/nodes/accessors/AccessorsUtils.js +10 -0
- package/examples/jsm/nodes/accessors/ClippingNode.js +144 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +2 -2
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -12
- package/examples/jsm/nodes/accessors/MorphNode.js +8 -8
- package/examples/jsm/nodes/accessors/ReferenceNode.js +87 -29
- package/examples/jsm/nodes/accessors/SkinningNode.js +31 -10
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +18 -0
- package/examples/jsm/nodes/accessors/TangentNode.js +8 -2
- package/examples/jsm/nodes/accessors/TextureNode.js +1 -1
- package/examples/jsm/nodes/accessors/UniformsNode.js +140 -0
- package/examples/jsm/nodes/code/CodeNode.js +6 -0
- package/examples/jsm/nodes/core/AssignNode.js +68 -12
- package/examples/jsm/nodes/core/Node.js +14 -4
- package/examples/jsm/nodes/core/NodeBuilder.js +3 -9
- package/examples/jsm/nodes/core/NodeFrame.js +2 -2
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/display/BlendModeNode.js +30 -1
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -5
- package/examples/jsm/nodes/materials/NodeMaterial.js +37 -6
- package/examples/jsm/nodes/math/CondNode.js +42 -7
- package/examples/jsm/nodes/math/MathNode.js +20 -0
- package/examples/jsm/nodes/utils/ArrayElementNode.js +0 -6
- package/examples/jsm/nodes/utils/LoopNode.js +2 -0
- package/examples/jsm/nodes/utils/StorageArrayElementNode.js +91 -0
- package/examples/jsm/postprocessing/OutputPass.js +2 -0
- package/examples/jsm/renderers/common/Background.js +2 -2
- package/examples/jsm/renderers/common/ClippingContext.js +165 -0
- package/examples/jsm/renderers/common/RenderContext.js +2 -0
- package/examples/jsm/renderers/common/RenderContexts.js +2 -13
- package/examples/jsm/renderers/common/RenderObject.js +44 -1
- package/examples/jsm/renderers/common/RenderObjects.js +3 -1
- package/examples/jsm/renderers/common/Renderer.js +94 -37
- package/examples/jsm/renderers/common/StorageBufferAttribute.js +2 -2
- package/examples/jsm/renderers/common/StorageInstancedBufferAttribute.js +17 -0
- package/examples/jsm/renderers/common/Textures.js +3 -13
- package/examples/jsm/renderers/common/UniformsGroup.js +6 -4
- package/examples/jsm/renderers/common/nodes/NodeStorageBuffer.js +23 -0
- package/examples/jsm/renderers/common/nodes/NodeUniformBuffer.js +23 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +1 -0
- package/examples/jsm/renderers/webgl/WebGLBackend.js +26 -6
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +135 -10
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +7 -1
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +47 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +1 -0
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +13 -12
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +15 -40
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +7 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +2 -2
- package/examples/jsm/shaders/OutputShader.js +4 -0
- package/examples/jsm/utils/SkeletonUtils.js +14 -3
- package/examples/jsm/webxr/VRButton.js +13 -5
- package/examples/jsm/webxr/XRButton.js +0 -1
- package/examples/jsm/webxr/XRControllerModelFactory.js +8 -0
- package/package.json +4 -3
- package/src/Three.Legacy.js +20 -0
- package/src/Three.js +0 -1
- package/src/constants.js +2 -5
- package/src/core/BufferAttribute.js +0 -11
- package/src/core/BufferGeometry.js +23 -29
- package/src/core/Object3D.js +11 -0
- package/src/core/Raycaster.js +18 -4
- package/src/core/RenderTarget.js +44 -21
- package/src/extras/PMREMGenerator.js +2 -0
- package/src/extras/curves/EllipseCurve.js +2 -2
- package/src/helpers/SpotLightHelper.js +18 -1
- package/src/loaders/DataTextureLoader.js +0 -4
- package/src/loaders/MaterialLoader.js +1 -0
- package/src/loaders/ObjectLoader.js +2 -1
- package/src/materials/Material.js +2 -1
- package/src/materials/MeshBasicMaterial.js +3 -0
- package/src/materials/MeshLambertMaterial.js +3 -0
- package/src/materials/MeshPhongMaterial.js +3 -0
- package/src/materials/MeshStandardMaterial.js +3 -0
- package/src/math/Quaternion.js +13 -12
- package/src/math/Vector3.js +7 -7
- package/src/objects/InstancedMesh.js +53 -0
- package/src/objects/Mesh.js +0 -1
- package/src/renderers/WebGLCubeRenderTarget.js +1 -10
- package/src/renderers/WebGLRenderer.js +15 -22
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -0
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +11 -2
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +23 -0
- package/src/renderers/shaders/ShaderChunk.js +2 -0
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +3 -2
- 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/linedashed.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/points.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib.js +2 -1
- package/src/renderers/shaders/UniformsLib.js +1 -0
- package/src/renderers/webgl/WebGLBackground.js +18 -0
- package/src/renderers/webgl/WebGLMaterials.js +24 -1
- package/src/renderers/webgl/WebGLMorphtargets.js +15 -8
- package/src/renderers/webgl/WebGLProgram.js +12 -1
- package/src/renderers/webgl/WebGLPrograms.js +19 -16
- package/src/renderers/webgl/WebGLState.js +11 -21
- package/src/renderers/webgl/WebGLTextures.js +80 -50
- package/src/scenes/Scene.js +8 -0
- package/src/textures/Texture.js +1 -29
- package/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
- package/src/renderers/WebGLMultipleRenderTargets.js +0 -82
|
@@ -45,7 +45,7 @@ class NodeFrame {
|
|
|
45
45
|
updateBeforeNode( node ) {
|
|
46
46
|
|
|
47
47
|
const updateType = node.getUpdateBeforeType();
|
|
48
|
-
const reference = node.
|
|
48
|
+
const reference = node.setReference( this );
|
|
49
49
|
|
|
50
50
|
if ( updateType === NodeUpdateType.FRAME ) {
|
|
51
51
|
|
|
@@ -86,7 +86,7 @@ class NodeFrame {
|
|
|
86
86
|
updateNode( node ) {
|
|
87
87
|
|
|
88
88
|
const updateType = node.getUpdateType();
|
|
89
|
-
const reference = node.
|
|
89
|
+
const reference = node.setReference( this );
|
|
90
90
|
|
|
91
91
|
if ( updateType === NodeUpdateType.FRAME ) {
|
|
92
92
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import { EPSILON } from '../math/MathNode.js';
|
|
2
|
+
import { /*mix, step,*/ EPSILON } from '../math/MathNode.js';
|
|
3
3
|
import { addNodeClass } from '../core/Node.js';
|
|
4
4
|
import { addNodeElement, tslFn, nodeProxy, vec3 } from '../shadernode/ShaderNode.js';
|
|
5
5
|
|
|
@@ -9,6 +9,13 @@ export const BurnNode = tslFn( ( { base, blend } ) => {
|
|
|
9
9
|
|
|
10
10
|
return vec3( fn( 'x' ), fn( 'y' ), fn( 'z' ) );
|
|
11
11
|
|
|
12
|
+
} ).setLayout( {
|
|
13
|
+
name: 'burnColor',
|
|
14
|
+
type: 'vec3',
|
|
15
|
+
inputs: [
|
|
16
|
+
{ name: 'base', type: 'vec3' },
|
|
17
|
+
{ name: 'blend', type: 'vec3' }
|
|
18
|
+
]
|
|
12
19
|
} );
|
|
13
20
|
|
|
14
21
|
export const DodgeNode = tslFn( ( { base, blend } ) => {
|
|
@@ -17,6 +24,13 @@ export const DodgeNode = tslFn( ( { base, blend } ) => {
|
|
|
17
24
|
|
|
18
25
|
return vec3( fn( 'x' ), fn( 'y' ), fn( 'z' ) );
|
|
19
26
|
|
|
27
|
+
} ).setLayout( {
|
|
28
|
+
name: 'dodgeColor',
|
|
29
|
+
type: 'vec3',
|
|
30
|
+
inputs: [
|
|
31
|
+
{ name: 'base', type: 'vec3' },
|
|
32
|
+
{ name: 'blend', type: 'vec3' }
|
|
33
|
+
]
|
|
20
34
|
} );
|
|
21
35
|
|
|
22
36
|
export const ScreenNode = tslFn( ( { base, blend } ) => {
|
|
@@ -25,14 +39,29 @@ export const ScreenNode = tslFn( ( { base, blend } ) => {
|
|
|
25
39
|
|
|
26
40
|
return vec3( fn( 'x' ), fn( 'y' ), fn( 'z' ) );
|
|
27
41
|
|
|
42
|
+
} ).setLayout( {
|
|
43
|
+
name: 'screenColor',
|
|
44
|
+
type: 'vec3',
|
|
45
|
+
inputs: [
|
|
46
|
+
{ name: 'base', type: 'vec3' },
|
|
47
|
+
{ name: 'blend', type: 'vec3' }
|
|
48
|
+
]
|
|
28
49
|
} );
|
|
29
50
|
|
|
30
51
|
export const OverlayNode = tslFn( ( { base, blend } ) => {
|
|
31
52
|
|
|
32
53
|
const fn = ( c ) => base[ c ].lessThan( 0.5 ).cond( base[ c ].mul( blend[ c ], 2.0 ), base[ c ].oneMinus().mul( blend[ c ].oneMinus() ).oneMinus() );
|
|
54
|
+
//const fn = ( c ) => mix( base[ c ].oneMinus().mul( blend[ c ].oneMinus() ).oneMinus(), base[ c ].mul( blend[ c ], 2.0 ), step( base[ c ], 0.5 ) );
|
|
33
55
|
|
|
34
56
|
return vec3( fn( 'x' ), fn( 'y' ), fn( 'z' ) );
|
|
35
57
|
|
|
58
|
+
} ).setLayout( {
|
|
59
|
+
name: 'overlayColor',
|
|
60
|
+
type: 'vec3',
|
|
61
|
+
inputs: [
|
|
62
|
+
{ name: 'base', type: 'vec3' },
|
|
63
|
+
{ name: 'blend', type: 'vec3' }
|
|
64
|
+
]
|
|
36
65
|
} );
|
|
37
66
|
|
|
38
67
|
class BlendModeNode extends TempNode {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
2
|
import { add } from '../math/OperatorNode.js';
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
import { modelNormalMatrix } from '../accessors/ModelNode.js';
|
|
5
5
|
import { normalView } from '../accessors/NormalNode.js';
|
|
6
6
|
import { positionView } from '../accessors/PositionNode.js';
|
|
7
|
-
import {
|
|
7
|
+
import { TBNViewMatrix } from '../accessors/AccessorsUtils.js';
|
|
8
8
|
import { uv } from '../accessors/UVNode.js';
|
|
9
9
|
import { faceDirection } from './FrontFacingNode.js';
|
|
10
10
|
import { addNodeClass } from '../core/Node.js';
|
|
11
|
-
import { addNodeElement, tslFn, nodeProxy, vec3
|
|
11
|
+
import { addNodeElement, tslFn, nodeProxy, vec3 } from '../shadernode/ShaderNode.js';
|
|
12
12
|
|
|
13
13
|
import { TangentSpaceNormalMap, ObjectSpaceNormalMap } from 'three';
|
|
14
14
|
|
|
@@ -101,8 +101,6 @@ export default NormalMapNode;
|
|
|
101
101
|
|
|
102
102
|
export const normalMap = nodeProxy( NormalMapNode );
|
|
103
103
|
|
|
104
|
-
export const TBNViewMatrix = mat3( tangentView, bitangentView, normalView );
|
|
105
|
-
|
|
106
104
|
addNodeElement( 'normalMap', normalMap );
|
|
107
105
|
|
|
108
106
|
addNodeClass( 'NormalMapNode', NormalMapNode );
|
|
@@ -7,8 +7,8 @@ import { modelViewProjection } from '../accessors/ModelViewProjectionNode.js';
|
|
|
7
7
|
import { transformedNormalView } from '../accessors/NormalNode.js';
|
|
8
8
|
import { instance } from '../accessors/InstanceNode.js';
|
|
9
9
|
import { positionLocal, positionView } from '../accessors/PositionNode.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { skinningReference } from '../accessors/SkinningNode.js';
|
|
11
|
+
import { morphReference } from '../accessors/MorphNode.js';
|
|
12
12
|
import { texture } from '../accessors/TextureNode.js';
|
|
13
13
|
import { cubeTexture } from '../accessors/CubeTextureNode.js';
|
|
14
14
|
import { lightsNode } from '../lighting/LightsNode.js';
|
|
@@ -19,6 +19,8 @@ import { lightingContext } from '../lighting/LightingContextNode.js';
|
|
|
19
19
|
import EnvironmentNode from '../lighting/EnvironmentNode.js';
|
|
20
20
|
import { depthPixel } from '../display/ViewportDepthNode.js';
|
|
21
21
|
import { cameraLogDepth } from '../accessors/CameraNode.js';
|
|
22
|
+
import { clipping, clippingAlpha } from '../accessors/ClippingNode.js';
|
|
23
|
+
import { faceDirection } from '../display/FrontFacingNode.js';
|
|
22
24
|
|
|
23
25
|
const NodeMaterials = new Map();
|
|
24
26
|
|
|
@@ -90,6 +92,8 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
90
92
|
|
|
91
93
|
let resultNode;
|
|
92
94
|
|
|
95
|
+
const clippingNode = this.setupClipping( builder );
|
|
96
|
+
|
|
93
97
|
if ( this.fragmentNode === null ) {
|
|
94
98
|
|
|
95
99
|
if ( this.depthWrite === true ) this.setupDepth( builder );
|
|
@@ -101,6 +105,8 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
101
105
|
|
|
102
106
|
const outgoingLightNode = this.setupLighting( builder );
|
|
103
107
|
|
|
108
|
+
if ( clippingNode !== null ) builder.stack.add( clippingNode );
|
|
109
|
+
|
|
104
110
|
resultNode = this.setupOutput( builder, vec4( outgoingLightNode, diffuseColor.a ) );
|
|
105
111
|
|
|
106
112
|
// OUTPUT NODE
|
|
@@ -123,6 +129,31 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
123
129
|
|
|
124
130
|
}
|
|
125
131
|
|
|
132
|
+
setupClipping( builder ) {
|
|
133
|
+
|
|
134
|
+
const { globalClippingCount, localClippingCount } = builder.clippingContext;
|
|
135
|
+
|
|
136
|
+
let result = null;
|
|
137
|
+
|
|
138
|
+
if ( globalClippingCount || localClippingCount ) {
|
|
139
|
+
|
|
140
|
+
if ( this.alphaToCoverage ) {
|
|
141
|
+
|
|
142
|
+
// to be added to flow when the color/alpha value has been determined
|
|
143
|
+
result = clippingAlpha();
|
|
144
|
+
|
|
145
|
+
} else {
|
|
146
|
+
|
|
147
|
+
builder.stack.add( clipping() );
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return result;
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
126
157
|
setupDepth( builder ) {
|
|
127
158
|
|
|
128
159
|
const { renderer } = builder;
|
|
@@ -158,13 +189,13 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
158
189
|
|
|
159
190
|
if ( geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color ) {
|
|
160
191
|
|
|
161
|
-
|
|
192
|
+
morphReference( object ).append();
|
|
162
193
|
|
|
163
194
|
}
|
|
164
195
|
|
|
165
196
|
if ( object.isSkinnedMesh === true ) {
|
|
166
197
|
|
|
167
|
-
|
|
198
|
+
skinningReference( object ).append();
|
|
168
199
|
|
|
169
200
|
}
|
|
170
201
|
|
|
@@ -236,13 +267,13 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
236
267
|
|
|
237
268
|
const normalNode = positionView.dFdx().cross( positionView.dFdy() ).normalize();
|
|
238
269
|
|
|
239
|
-
transformedNormalView.assign( normalNode );
|
|
270
|
+
transformedNormalView.assign( normalNode.mul( faceDirection ) );
|
|
240
271
|
|
|
241
272
|
} else {
|
|
242
273
|
|
|
243
274
|
const normalNode = this.normalNode ? vec3( this.normalNode ) : materialNormal;
|
|
244
275
|
|
|
245
|
-
transformedNormalView.assign( normalNode );
|
|
276
|
+
transformedNormalView.assign( normalNode.mul( faceDirection ) );
|
|
246
277
|
|
|
247
278
|
}
|
|
248
279
|
|
|
@@ -36,23 +36,45 @@ class CondNode extends Node {
|
|
|
36
36
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
generate( builder ) {
|
|
39
|
+
generate( builder, output ) {
|
|
40
40
|
|
|
41
41
|
const type = this.getNodeType( builder );
|
|
42
42
|
const context = { tempWrite: false };
|
|
43
43
|
|
|
44
|
+
const nodeData = builder.getDataFromNode( this );
|
|
45
|
+
|
|
46
|
+
if ( nodeData.nodeProperty !== undefined ) {
|
|
47
|
+
|
|
48
|
+
return nodeData.nodeProperty;
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
44
52
|
const { ifNode, elseNode } = this;
|
|
45
53
|
|
|
46
|
-
const
|
|
47
|
-
const nodeProperty =
|
|
54
|
+
const needsOutput = output !== 'void';
|
|
55
|
+
const nodeProperty = needsOutput ? property( type ).build( builder ) : '';
|
|
56
|
+
|
|
57
|
+
nodeData.nodeProperty = nodeProperty;
|
|
48
58
|
|
|
49
59
|
const nodeSnippet = contextNode( this.condNode/*, context*/ ).build( builder, 'bool' );
|
|
50
60
|
|
|
51
61
|
builder.addFlowCode( `\n${ builder.tab }if ( ${ nodeSnippet } ) {\n\n` ).addFlowTab();
|
|
52
62
|
|
|
53
|
-
let ifSnippet = contextNode(
|
|
63
|
+
let ifSnippet = contextNode( ifNode, context ).build( builder, type );
|
|
64
|
+
|
|
65
|
+
if ( ifSnippet ) {
|
|
66
|
+
|
|
67
|
+
if ( needsOutput ) {
|
|
68
|
+
|
|
69
|
+
ifSnippet = nodeProperty + ' = ' + ifSnippet + ';';
|
|
70
|
+
|
|
71
|
+
} else {
|
|
72
|
+
|
|
73
|
+
ifSnippet = 'return ' + ifSnippet + ';';
|
|
54
74
|
|
|
55
|
-
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
}
|
|
56
78
|
|
|
57
79
|
builder.removeFlowTab().addFlowCode( builder.tab + '\t' + ifSnippet + '\n\n' + builder.tab + '}' );
|
|
58
80
|
|
|
@@ -61,7 +83,20 @@ class CondNode extends Node {
|
|
|
61
83
|
builder.addFlowCode( ' else {\n\n' ).addFlowTab();
|
|
62
84
|
|
|
63
85
|
let elseSnippet = contextNode( elseNode, context ).build( builder, type );
|
|
64
|
-
|
|
86
|
+
|
|
87
|
+
if ( elseSnippet ) {
|
|
88
|
+
|
|
89
|
+
if ( needsOutput ) {
|
|
90
|
+
|
|
91
|
+
elseSnippet = nodeProperty + ' = ' + elseSnippet + ';';
|
|
92
|
+
|
|
93
|
+
} else {
|
|
94
|
+
|
|
95
|
+
elseSnippet = 'return ' + elseSnippet + ';';
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
}
|
|
65
100
|
|
|
66
101
|
builder.removeFlowTab().addFlowCode( builder.tab + '\t' + elseSnippet + '\n\n' + builder.tab + '}\n\n' );
|
|
67
102
|
|
|
@@ -71,7 +106,7 @@ class CondNode extends Node {
|
|
|
71
106
|
|
|
72
107
|
}
|
|
73
108
|
|
|
74
|
-
return nodeProperty;
|
|
109
|
+
return builder.format( nodeProperty, type, output );
|
|
75
110
|
|
|
76
111
|
}
|
|
77
112
|
|
|
@@ -57,6 +57,14 @@ class MathNode extends TempNode {
|
|
|
57
57
|
|
|
58
58
|
return 'vec3';
|
|
59
59
|
|
|
60
|
+
} else if ( method === MathNode.ALL ) {
|
|
61
|
+
|
|
62
|
+
return 'bool';
|
|
63
|
+
|
|
64
|
+
} else if ( method === MathNode.EQUALS ) {
|
|
65
|
+
|
|
66
|
+
return builder.changeComponentType( this.aNode.getNodeType( builder ), 'bool' );
|
|
67
|
+
|
|
60
68
|
} else if ( method === MathNode.MOD ) {
|
|
61
69
|
|
|
62
70
|
return this.aNode.getNodeType( builder );
|
|
@@ -195,6 +203,10 @@ class MathNode extends TempNode {
|
|
|
195
203
|
|
|
196
204
|
// 1 input
|
|
197
205
|
|
|
206
|
+
MathNode.ALL = 'all';
|
|
207
|
+
MathNode.ANY = 'any';
|
|
208
|
+
MathNode.EQUALS = 'equals';
|
|
209
|
+
|
|
198
210
|
MathNode.RADIANS = 'radians';
|
|
199
211
|
MathNode.DEGREES = 'degrees';
|
|
200
212
|
MathNode.EXP = 'exp';
|
|
@@ -256,6 +268,10 @@ export const INFINITY = float( 1e6 );
|
|
|
256
268
|
export const PI = float( Math.PI );
|
|
257
269
|
export const PI2 = float( Math.PI * 2 );
|
|
258
270
|
|
|
271
|
+
export const all = nodeProxy( MathNode, MathNode.ALL );
|
|
272
|
+
export const any = nodeProxy( MathNode, MathNode.ANY );
|
|
273
|
+
export const equals = nodeProxy( MathNode, MathNode.EQUALS );
|
|
274
|
+
|
|
259
275
|
export const radians = nodeProxy( MathNode, MathNode.RADIANS );
|
|
260
276
|
export const degrees = nodeProxy( MathNode, MathNode.DEGREES );
|
|
261
277
|
export const exp = nodeProxy( MathNode, MathNode.EXP );
|
|
@@ -315,6 +331,10 @@ export const faceForward = nodeProxy( MathNode, MathNode.FACEFORWARD );
|
|
|
315
331
|
export const mixElement = ( t, e1, e2 ) => mix( e1, e2, t );
|
|
316
332
|
export const smoothstepElement = ( x, low, high ) => smoothstep( low, high, x );
|
|
317
333
|
|
|
334
|
+
addNodeElement( 'all', all );
|
|
335
|
+
addNodeElement( 'any', any );
|
|
336
|
+
addNodeElement( 'equals', equals );
|
|
337
|
+
|
|
318
338
|
addNodeElement( 'radians', radians );
|
|
319
339
|
addNodeElement( 'degrees', degrees );
|
|
320
340
|
addNodeElement( 'exp', exp );
|
|
@@ -24,12 +24,6 @@ class ArrayElementNode extends Node { // @TODO: If extending from TempNode it br
|
|
|
24
24
|
const nodeSnippet = this.node.build( builder );
|
|
25
25
|
const indexSnippet = this.indexNode.build( builder, 'uint' );
|
|
26
26
|
|
|
27
|
-
if ( this.node.isStorageBufferNode && ! builder.isAvailable( 'storageBuffer' ) ) {
|
|
28
|
-
|
|
29
|
-
return nodeSnippet;
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
27
|
return `${nodeSnippet}[ ${indexSnippet} ]`;
|
|
34
28
|
|
|
35
29
|
}
|
|
@@ -192,6 +192,8 @@ class LoopNode extends Node {
|
|
|
192
192
|
export default LoopNode;
|
|
193
193
|
|
|
194
194
|
export const loop = ( ...params ) => nodeObject( new LoopNode( nodeArray( params, 'int' ) ) ).append();
|
|
195
|
+
export const Continue = () => expression( 'continue' ).append();
|
|
196
|
+
export const Break = () => expression( 'break' ).append();
|
|
195
197
|
|
|
196
198
|
addNodeElement( 'loop', ( returns, ...params ) => bypass( returns, loop( ...params ) ) );
|
|
197
199
|
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { addNodeClass } from '../core/Node.js';
|
|
2
|
+
import { nodeProxy, addNodeElement } from '../shadernode/ShaderNode.js';
|
|
3
|
+
import ArrayElementNode from './ArrayElementNode.js';
|
|
4
|
+
|
|
5
|
+
class StorageArrayElementNode extends ArrayElementNode {
|
|
6
|
+
|
|
7
|
+
constructor( storageBufferNode, indexNode ) {
|
|
8
|
+
|
|
9
|
+
super( storageBufferNode, indexNode );
|
|
10
|
+
|
|
11
|
+
this.isStorageArrayElementNode = true;
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
set storageBufferNode( value ) {
|
|
16
|
+
|
|
17
|
+
this.node = value;
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get storageBufferNode() {
|
|
22
|
+
|
|
23
|
+
return this.node;
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
setup( builder ) {
|
|
28
|
+
|
|
29
|
+
if ( builder.isAvailable( 'storageBuffer' ) === false ) {
|
|
30
|
+
|
|
31
|
+
if ( ! this.node.instanceIndex && this.node.bufferObject === true ) {
|
|
32
|
+
|
|
33
|
+
builder.setupPBO( this.node );
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return super.setup( builder );
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
generate( builder, output ) {
|
|
44
|
+
|
|
45
|
+
let snippet;
|
|
46
|
+
|
|
47
|
+
const isAssignContext = builder.context.assign;
|
|
48
|
+
|
|
49
|
+
//
|
|
50
|
+
|
|
51
|
+
if ( builder.isAvailable( 'storageBuffer' ) === false ) {
|
|
52
|
+
|
|
53
|
+
const { node } = this;
|
|
54
|
+
|
|
55
|
+
if ( ! node.instanceIndex && this.node.bufferObject === true && isAssignContext !== true ) {
|
|
56
|
+
|
|
57
|
+
snippet = builder.generatePBO( this );
|
|
58
|
+
|
|
59
|
+
} else {
|
|
60
|
+
|
|
61
|
+
snippet = node.build( builder );
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
} else {
|
|
66
|
+
|
|
67
|
+
snippet = super.generate( builder );
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if ( isAssignContext !== true ) {
|
|
72
|
+
|
|
73
|
+
const type = this.getNodeType( builder );
|
|
74
|
+
|
|
75
|
+
snippet = builder.format( snippet, type, output );
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return snippet;
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export default StorageArrayElementNode;
|
|
86
|
+
|
|
87
|
+
export const storageElement = nodeProxy( StorageArrayElementNode );
|
|
88
|
+
|
|
89
|
+
addNodeElement( 'storageElement', storageElement );
|
|
90
|
+
|
|
91
|
+
addNodeClass( 'StorageArrayElementNode', StorageArrayElementNode );
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
CineonToneMapping,
|
|
8
8
|
AgXToneMapping,
|
|
9
9
|
ACESFilmicToneMapping,
|
|
10
|
+
NeutralToneMapping,
|
|
10
11
|
SRGBTransfer
|
|
11
12
|
} from 'three';
|
|
12
13
|
import { Pass, FullScreenQuad } from './Pass.js';
|
|
@@ -61,6 +62,7 @@ class OutputPass extends Pass {
|
|
|
61
62
|
else if ( this._toneMapping === CineonToneMapping ) this.material.defines.CINEON_TONE_MAPPING = '';
|
|
62
63
|
else if ( this._toneMapping === ACESFilmicToneMapping ) this.material.defines.ACES_FILMIC_TONE_MAPPING = '';
|
|
63
64
|
else if ( this._toneMapping === AgXToneMapping ) this.material.defines.AGX_TONE_MAPPING = '';
|
|
65
|
+
else if ( this._toneMapping === NeutralToneMapping ) this.material.defines.NEUTRAL_TONE_MAPPING = '';
|
|
64
66
|
|
|
65
67
|
this.material.needsUpdate = true;
|
|
66
68
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import DataMap from './DataMap.js';
|
|
2
2
|
import Color4 from './Color4.js';
|
|
3
3
|
import { Mesh, SphereGeometry, BackSide } from 'three';
|
|
4
|
-
import { vec4, context, normalWorld, backgroundBlurriness, backgroundIntensity, NodeMaterial, modelViewProjection } from '../../nodes/Nodes.js';
|
|
4
|
+
import { vec4, context, normalWorld, backgroundBlurriness, backgroundIntensity, NodeMaterial, modelViewProjection, maxMipLevel } from '../../nodes/Nodes.js';
|
|
5
5
|
|
|
6
6
|
const _clearColor = new Color4();
|
|
7
7
|
|
|
@@ -53,7 +53,7 @@ class Background extends DataMap {
|
|
|
53
53
|
const backgroundMeshNode = context( vec4( backgroundNode ), {
|
|
54
54
|
// @TODO: Add Texture2D support using node context
|
|
55
55
|
getUV: () => normalWorld,
|
|
56
|
-
getTextureLevel: () => backgroundBlurriness
|
|
56
|
+
getTextureLevel: ( textureNode ) => backgroundBlurriness.mul( maxMipLevel( textureNode ) )
|
|
57
57
|
} ).mul( backgroundIntensity );
|
|
58
58
|
|
|
59
59
|
let viewProj = modelViewProjection();
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { Matrix3, Plane, Vector4 } from 'three';
|
|
2
|
+
|
|
3
|
+
const _plane = new Plane();
|
|
4
|
+
const _viewNormalMatrix = new Matrix3();
|
|
5
|
+
|
|
6
|
+
let _clippingContextVersion = 0;
|
|
7
|
+
|
|
8
|
+
class ClippingContext {
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
|
|
12
|
+
this.version = ++ _clippingContextVersion;
|
|
13
|
+
|
|
14
|
+
this.globalClippingCount = 0;
|
|
15
|
+
|
|
16
|
+
this.localClippingCount = 0;
|
|
17
|
+
this.localClippingEnabled = false;
|
|
18
|
+
this.localClipIntersection = false;
|
|
19
|
+
|
|
20
|
+
this.planes = [];
|
|
21
|
+
|
|
22
|
+
this.parentVersion = 0;
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
projectPlanes( source, offset ) {
|
|
27
|
+
|
|
28
|
+
const l = source.length;
|
|
29
|
+
const planes = this.planes;
|
|
30
|
+
|
|
31
|
+
for ( let i = 0; i < l; i ++ ) {
|
|
32
|
+
|
|
33
|
+
_plane.copy( source[ i ] ).applyMatrix4( this.viewMatrix, _viewNormalMatrix );
|
|
34
|
+
|
|
35
|
+
const v = planes[ offset + i ];
|
|
36
|
+
const normal = _plane.normal;
|
|
37
|
+
|
|
38
|
+
v.x = - normal.x;
|
|
39
|
+
v.y = - normal.y;
|
|
40
|
+
v.z = - normal.z;
|
|
41
|
+
v.w = _plane.constant;
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
updateGlobal( renderer, camera ) {
|
|
48
|
+
|
|
49
|
+
const rendererClippingPlanes = renderer.clippingPlanes;
|
|
50
|
+
this.viewMatrix = camera.matrixWorldInverse;
|
|
51
|
+
|
|
52
|
+
_viewNormalMatrix.getNormalMatrix( this.viewMatrix );
|
|
53
|
+
|
|
54
|
+
let update = false;
|
|
55
|
+
|
|
56
|
+
if ( Array.isArray( rendererClippingPlanes ) && rendererClippingPlanes.length !== 0 ) {
|
|
57
|
+
|
|
58
|
+
const l = rendererClippingPlanes.length;
|
|
59
|
+
|
|
60
|
+
if ( l !== this.globalClippingCount ) {
|
|
61
|
+
|
|
62
|
+
const planes = [];
|
|
63
|
+
|
|
64
|
+
for ( let i = 0; i < l; i ++ ) {
|
|
65
|
+
|
|
66
|
+
planes.push( new Vector4() );
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this.globalClippingCount = l;
|
|
71
|
+
this.planes = planes;
|
|
72
|
+
|
|
73
|
+
update = true;
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
this.projectPlanes( rendererClippingPlanes, 0 );
|
|
78
|
+
|
|
79
|
+
} else if ( this.globalClippingCount !== 0 ) {
|
|
80
|
+
|
|
81
|
+
this.globalClippingCount = 0;
|
|
82
|
+
this.planes = [];
|
|
83
|
+
update = true;
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if ( renderer.localClippingEnabled !== this.localClippingEnabled ) {
|
|
88
|
+
|
|
89
|
+
this.localClippingEnabled = renderer.localClippingEnabled;
|
|
90
|
+
update = true;
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if ( update ) this.version = _clippingContextVersion ++;
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
update( parent, material ) {
|
|
99
|
+
|
|
100
|
+
let update = false;
|
|
101
|
+
|
|
102
|
+
if ( this !== parent && parent.version !== this.parentVersion ) {
|
|
103
|
+
|
|
104
|
+
this.globalClippingCount = material.isShadowNodeMaterial ? 0 : parent.globalClippingCount;
|
|
105
|
+
this.localClippingEnabled = parent.localClippingEnabled;
|
|
106
|
+
this.planes = Array.from( parent.planes );
|
|
107
|
+
this.parentVersion = parent.version;
|
|
108
|
+
this.viewMatrix = parent.viewMatrix;
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
update = true;
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if ( this.localClippingEnabled ) {
|
|
116
|
+
|
|
117
|
+
const localClippingPlanes = material.clippingPlanes;
|
|
118
|
+
|
|
119
|
+
if ( ( Array.isArray( localClippingPlanes ) && localClippingPlanes.length !== 0 ) ) {
|
|
120
|
+
|
|
121
|
+
const l = localClippingPlanes.length;
|
|
122
|
+
const planes = this.planes;
|
|
123
|
+
const offset = this.globalClippingCount;
|
|
124
|
+
|
|
125
|
+
if ( update || l !== this.localClippingCount ) {
|
|
126
|
+
|
|
127
|
+
planes.length = offset + l;
|
|
128
|
+
|
|
129
|
+
for ( let i = 0; i < l; i ++ ) {
|
|
130
|
+
|
|
131
|
+
planes[ offset + i ] = new Vector4();
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
this.localClippingCount = l;
|
|
136
|
+
update = true;
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
this.projectPlanes( localClippingPlanes, offset );
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
} else if ( this.localClippingCount !== 0 ) {
|
|
144
|
+
|
|
145
|
+
this.localClippingCount = 0;
|
|
146
|
+
update = true;
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if ( this.localClipIntersection !== material.clipIntersection ) {
|
|
151
|
+
|
|
152
|
+
this.localClipIntersection = material.clipIntersection;
|
|
153
|
+
update = true;
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if ( update ) this.version = _clippingContextVersion ++;
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export default ClippingContext;
|
|
@@ -21,19 +21,8 @@ class RenderContexts {
|
|
|
21
21
|
|
|
22
22
|
} else {
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if ( renderTarget.isWebGLMultipleRenderTargets ) {
|
|
27
|
-
|
|
28
|
-
format = renderTarget.texture[ 0 ].format;
|
|
29
|
-
count = renderTarget.texture.length;
|
|
30
|
-
|
|
31
|
-
} else {
|
|
32
|
-
|
|
33
|
-
format = renderTarget.texture.format;
|
|
34
|
-
count = 1;
|
|
35
|
-
|
|
36
|
-
}
|
|
24
|
+
const format = renderTarget.texture.format;
|
|
25
|
+
const count = renderTarget.count;
|
|
37
26
|
|
|
38
27
|
attachmentState = `${ count }:${ format }:${ renderTarget.samples }:${ renderTarget.depthBuffer }:${ renderTarget.stencilBuffer }`;
|
|
39
28
|
|