super-three 0.161.0 → 0.163.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 +822 -1332
- package/build/three.module.js +820 -1328
- 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 +9 -9
- package/examples/jsm/exporters/GLTFExporter.js +30 -3
- package/examples/jsm/exporters/USDZExporter.js +15 -0
- package/examples/jsm/geometries/TextGeometry.js +10 -2
- package/examples/jsm/interactive/HTMLMesh.js +7 -9
- package/examples/jsm/interactive/InteractiveGroup.js +15 -25
- package/examples/jsm/libs/fflate.module.js +694 -496
- 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/lines/LineMaterial.js +0 -2
- package/examples/jsm/loaders/3DMLoader.js +13 -21
- package/examples/jsm/loaders/3MFLoader.js +2 -0
- package/examples/jsm/loaders/EXRLoader.js +89 -19
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +6 -0
- package/examples/jsm/loaders/KTX2Loader.js +2 -6
- package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
- package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
- package/examples/jsm/loaders/LUTImageLoader.js +0 -14
- package/examples/jsm/loaders/RGBMLoader.js +16 -0
- package/examples/jsm/loaders/VOXLoader.js +9 -2
- package/examples/jsm/loaders/VRMLLoader.js +6 -2
- package/examples/jsm/misc/GPUComputationRenderer.js +0 -6
- package/examples/jsm/misc/ProgressiveLightMap.js +1 -0
- package/examples/jsm/nodes/Nodes.js +15 -8
- package/examples/jsm/nodes/accessors/AccessorsUtils.js +10 -0
- package/examples/jsm/nodes/accessors/BatchNode.js +78 -0
- package/examples/jsm/nodes/accessors/ClippingNode.js +144 -0
- package/examples/jsm/nodes/accessors/InstanceNode.js +25 -2
- 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 +20 -10
- package/examples/jsm/nodes/accessors/NormalNode.js +12 -2
- package/examples/jsm/nodes/accessors/ReferenceNode.js +87 -29
- package/examples/jsm/nodes/accessors/RendererReferenceNode.js +29 -0
- 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 +30 -7
- 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 +67 -6
- package/examples/jsm/nodes/core/NodeBuilder.js +23 -24
- package/examples/jsm/nodes/core/NodeFrame.js +8 -8
- package/examples/jsm/nodes/core/NodeUtils.js +2 -2
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/core/UniformNode.js +20 -0
- package/examples/jsm/nodes/display/BlendModeNode.js +30 -1
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -5
- package/examples/jsm/nodes/display/PassNode.js +17 -1
- package/examples/jsm/nodes/display/ToneMappingNode.js +8 -4
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -0
- package/examples/jsm/nodes/fog/FogExp2Node.js +4 -5
- package/examples/jsm/nodes/fog/FogNode.js +13 -3
- package/examples/jsm/nodes/fog/FogRangeNode.js +4 -3
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +12 -69
- package/examples/jsm/nodes/materials/NodeMaterial.js +70 -17
- package/examples/jsm/nodes/math/CondNode.js +42 -7
- package/examples/jsm/nodes/math/MathNode.js +20 -0
- package/examples/jsm/nodes/pmrem/PMREMNode.js +193 -0
- package/examples/jsm/nodes/pmrem/PMREMUtils.js +288 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +1 -1
- package/examples/jsm/nodes/utils/ArrayElementNode.js +0 -6
- package/examples/jsm/nodes/utils/EquirectUVNode.js +1 -1
- package/examples/jsm/nodes/utils/LoopNode.js +2 -0
- package/examples/jsm/nodes/utils/StorageArrayElementNode.js +91 -0
- package/examples/jsm/objects/QuadMesh.js +7 -23
- package/examples/jsm/physics/RapierPhysics.js +4 -4
- package/examples/jsm/postprocessing/GlitchPass.js +0 -3
- package/examples/jsm/postprocessing/LUTPass.js +5 -71
- package/examples/jsm/postprocessing/OutputPass.js +2 -0
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SSAOPass.js +0 -3
- package/examples/jsm/renderers/common/Animation.js +3 -0
- package/examples/jsm/renderers/common/Background.js +3 -3
- package/examples/jsm/renderers/common/ClippingContext.js +165 -0
- package/examples/jsm/renderers/common/Info.js +11 -19
- package/examples/jsm/renderers/common/PostProcessing.js +12 -4
- package/examples/jsm/renderers/common/RenderContext.js +3 -1
- package/examples/jsm/renderers/common/RenderContexts.js +2 -13
- package/examples/jsm/renderers/common/RenderObject.js +46 -3
- package/examples/jsm/renderers/common/RenderObjects.js +2 -0
- package/examples/jsm/renderers/common/Renderer.js +113 -39
- 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/extras/PMREMGenerator.js +777 -0
- 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 +6 -18
- package/examples/jsm/renderers/webgl/WebGLBackend.js +174 -30
- package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +141 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +136 -11
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +8 -2
- package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +1 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +90 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -2
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +67 -37
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +20 -43
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +32 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +18 -4
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +94 -20
- package/examples/jsm/shaders/OutputShader.js +4 -0
- package/examples/jsm/utils/GPUStatsPanel.js +10 -45
- package/examples/jsm/utils/SkeletonUtils.js +14 -3
- package/examples/jsm/utils/TextureUtils.js +1 -1
- 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 -2
- package/src/animation/AnimationClip.js +1 -1
- package/src/constants.js +4 -7
- package/src/core/BufferAttribute.js +0 -11
- package/src/core/BufferGeometry.js +23 -29
- package/src/core/Object3D.js +21 -7
- package/src/core/Raycaster.js +18 -4
- package/src/core/RenderTarget.js +44 -21
- package/src/extras/PMREMGenerator.js +11 -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 +4 -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/materials/ShaderMaterial.js +0 -4
- package/src/math/Quaternion.js +13 -12
- package/src/math/Spherical.js +4 -5
- package/src/math/Vector3.js +7 -7
- package/src/objects/BatchedMesh.js +4 -3
- package/src/objects/InstancedMesh.js +63 -0
- package/src/objects/Mesh.js +0 -1
- package/src/renderers/WebGLCubeRenderTarget.js +1 -10
- package/src/renderers/WebGLRenderer.js +70 -136
- 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/logdepthbuf_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
- 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/shadowmap_pars_fragment.glsl.js +32 -22
- 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 +3 -2
- package/src/renderers/shaders/UniformsLib.js +1 -0
- package/src/renderers/shaders/UniformsUtils.js +10 -1
- package/src/renderers/webgl/WebGLAttributes.js +6 -33
- package/src/renderers/webgl/WebGLBackground.js +18 -0
- package/src/renderers/webgl/WebGLBindingStates.js +14 -51
- package/src/renderers/webgl/WebGLBufferRenderer.js +3 -25
- package/src/renderers/webgl/WebGLCapabilities.js +2 -12
- package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
- package/src/renderers/webgl/WebGLExtensions.js +4 -19
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +3 -25
- package/src/renderers/webgl/WebGLLights.js +6 -32
- package/src/renderers/webgl/WebGLMaterials.js +26 -4
- package/src/renderers/webgl/WebGLMorphtargets.js +79 -210
- package/src/renderers/webgl/WebGLProgram.js +30 -48
- package/src/renderers/webgl/WebGLPrograms.js +5 -14
- package/src/renderers/webgl/WebGLRenderStates.js +8 -6
- package/src/renderers/webgl/WebGLState.js +21 -75
- package/src/renderers/webgl/WebGLTextures.js +143 -275
- package/src/renderers/webgl/WebGLUniformsGroups.js +1 -1
- package/src/renderers/webgl/WebGLUtils.js +6 -57
- package/src/renderers/webxr/WebXRDepthSensing.js +2 -3
- package/src/renderers/webxr/WebXRManager.js +2 -2
- package/src/scenes/Scene.js +14 -0
- package/src/textures/Texture.js +6 -24
- package/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
- package/src/renderers/WebGL1Renderer.js +0 -7
- package/src/renderers/WebGLMultipleRenderTargets.js +0 -82
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { addNodeClass } from '../core/Node.js';
|
|
2
2
|
import TempNode from '../core/TempNode.js';
|
|
3
3
|
import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js';
|
|
4
|
+
import { vectorComponents } from '../core/constants.js';
|
|
4
5
|
|
|
5
6
|
class AssignNode extends TempNode {
|
|
6
7
|
|
|
@@ -25,40 +26,95 @@ class AssignNode extends TempNode {
|
|
|
25
26
|
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
needsSplitAssign( builder ) {
|
|
30
|
+
|
|
31
|
+
const { targetNode } = this;
|
|
32
|
+
|
|
33
|
+
if ( builder.isAvailable( 'swizzleAssign' ) === false && targetNode.isSplitNode && targetNode.components.length > 1 ) {
|
|
34
|
+
|
|
35
|
+
const targetLength = builder.getTypeLength( targetNode.node.getNodeType( builder ) );
|
|
36
|
+
const assignDiferentVector = vectorComponents.join( '' ).slice( 0, targetLength ) !== targetNode.components;
|
|
37
|
+
|
|
38
|
+
return assignDiferentVector;
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return false;
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
28
46
|
generate( builder, output ) {
|
|
29
47
|
|
|
30
|
-
const targetNode = this
|
|
31
|
-
|
|
48
|
+
const { targetNode, sourceNode } = this;
|
|
49
|
+
|
|
50
|
+
const needsSplitAssign = this.needsSplitAssign( builder );
|
|
32
51
|
|
|
33
52
|
const targetType = targetNode.getNodeType( builder );
|
|
34
53
|
|
|
35
|
-
const target = targetNode.build( builder );
|
|
54
|
+
const target = targetNode.context( { assign: true } ).build( builder );
|
|
36
55
|
const source = sourceNode.build( builder, targetType );
|
|
37
56
|
|
|
38
|
-
const
|
|
57
|
+
const sourceType = sourceNode.getNodeType( builder );
|
|
58
|
+
|
|
59
|
+
const nodeData = builder.getDataFromNode( this );
|
|
60
|
+
|
|
61
|
+
//
|
|
39
62
|
|
|
40
|
-
|
|
63
|
+
let snippet;
|
|
41
64
|
|
|
42
|
-
|
|
65
|
+
if ( nodeData.initialized === true ) {
|
|
66
|
+
|
|
67
|
+
if ( output !== 'void' ) {
|
|
68
|
+
|
|
69
|
+
snippet = target;
|
|
70
|
+
|
|
71
|
+
}
|
|
43
72
|
|
|
44
|
-
|
|
73
|
+
} else if ( needsSplitAssign ) {
|
|
74
|
+
|
|
75
|
+
const sourceVar = builder.getVarFromNode( this, null, targetType );
|
|
76
|
+
const sourceProperty = builder.getPropertyName( sourceVar );
|
|
77
|
+
|
|
78
|
+
builder.addLineFlowCode( `${ sourceProperty } = ${ source }` );
|
|
79
|
+
|
|
80
|
+
const targetRoot = targetNode.node.context( { assign: true } ).build( builder );
|
|
81
|
+
|
|
82
|
+
for ( let i = 0; i < targetNode.components.length; i ++ ) {
|
|
83
|
+
|
|
84
|
+
const component = targetNode.components[ i ];
|
|
85
|
+
|
|
86
|
+
builder.addLineFlowCode( `${ targetRoot }.${ component } = ${ sourceProperty }[ ${ i } ]` );
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if ( output !== 'void' ) {
|
|
91
|
+
|
|
92
|
+
snippet = target;
|
|
93
|
+
|
|
94
|
+
}
|
|
45
95
|
|
|
46
96
|
} else {
|
|
47
97
|
|
|
48
|
-
|
|
98
|
+
snippet = `${ target } = ${ source }`;
|
|
49
99
|
|
|
50
|
-
if ( sourceType === 'void' ) {
|
|
100
|
+
if ( output === 'void' || sourceType === 'void' ) {
|
|
51
101
|
|
|
52
102
|
builder.addLineFlowCode( snippet );
|
|
53
103
|
|
|
54
|
-
|
|
104
|
+
if ( output !== 'void' ) {
|
|
55
105
|
|
|
56
|
-
|
|
106
|
+
snippet = target;
|
|
57
107
|
|
|
58
|
-
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
}
|
|
59
111
|
|
|
60
112
|
}
|
|
61
113
|
|
|
114
|
+
nodeData.initialized = true;
|
|
115
|
+
|
|
116
|
+
return builder.format( snippet, targetType, output );
|
|
117
|
+
|
|
62
118
|
}
|
|
63
119
|
|
|
64
120
|
}
|
|
@@ -20,18 +20,60 @@ class Node extends EventDispatcher {
|
|
|
20
20
|
|
|
21
21
|
this.uuid = MathUtils.generateUUID();
|
|
22
22
|
|
|
23
|
+
this.version = 0;
|
|
24
|
+
|
|
25
|
+
this._cacheKey = null;
|
|
26
|
+
this._cacheKeyVersion = 0;
|
|
27
|
+
|
|
23
28
|
this.isNode = true;
|
|
24
29
|
|
|
25
30
|
Object.defineProperty( this, 'id', { value: _nodeId ++ } );
|
|
26
31
|
|
|
27
32
|
}
|
|
28
33
|
|
|
34
|
+
set needsUpdate( value ) {
|
|
35
|
+
|
|
36
|
+
if ( value === true ) {
|
|
37
|
+
|
|
38
|
+
this.version ++;
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
29
44
|
get type() {
|
|
30
45
|
|
|
31
46
|
return this.constructor.type;
|
|
32
47
|
|
|
33
48
|
}
|
|
34
49
|
|
|
50
|
+
onUpdate( callback, updateType ) {
|
|
51
|
+
|
|
52
|
+
this.updateType = updateType;
|
|
53
|
+
this.update = callback.bind( this.getSelf() );
|
|
54
|
+
|
|
55
|
+
return this;
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
onFrameUpdate( callback ) {
|
|
60
|
+
|
|
61
|
+
return this.onUpdate( callback, NodeUpdateType.FRAME );
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
onRenderUpdate( callback ) {
|
|
66
|
+
|
|
67
|
+
return this.onUpdate( callback, NodeUpdateType.RENDER );
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
onObjectUpdate( callback ) {
|
|
72
|
+
|
|
73
|
+
return this.onUpdate( callback, NodeUpdateType.OBJECT );
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
35
77
|
getSelf() {
|
|
36
78
|
|
|
37
79
|
// Returns non-node object.
|
|
@@ -40,7 +82,7 @@ class Node extends EventDispatcher {
|
|
|
40
82
|
|
|
41
83
|
}
|
|
42
84
|
|
|
43
|
-
updateReference() {
|
|
85
|
+
updateReference( /*state*/ ) {
|
|
44
86
|
|
|
45
87
|
return this;
|
|
46
88
|
|
|
@@ -80,9 +122,18 @@ class Node extends EventDispatcher {
|
|
|
80
122
|
|
|
81
123
|
}
|
|
82
124
|
|
|
83
|
-
getCacheKey() {
|
|
125
|
+
getCacheKey( force = false ) {
|
|
126
|
+
|
|
127
|
+
force = force || this.version !== this._cacheKeyVersion;
|
|
128
|
+
|
|
129
|
+
if ( force === true || this._cacheKey === null ) {
|
|
130
|
+
|
|
131
|
+
this._cacheKey = getCacheKey( this, force );
|
|
132
|
+
this._cacheKeyVersion = this.version;
|
|
84
133
|
|
|
85
|
-
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return this._cacheKey;
|
|
86
137
|
|
|
87
138
|
}
|
|
88
139
|
|
|
@@ -150,12 +201,20 @@ class Node extends EventDispatcher {
|
|
|
150
201
|
|
|
151
202
|
}
|
|
152
203
|
|
|
153
|
-
|
|
204
|
+
increaseUsage( builder ) {
|
|
154
205
|
|
|
155
206
|
const nodeData = builder.getDataFromNode( this );
|
|
156
|
-
nodeData.
|
|
207
|
+
nodeData.usageCount = nodeData.usageCount === undefined ? 1 : nodeData.usageCount + 1;
|
|
208
|
+
|
|
209
|
+
return nodeData.usageCount;
|
|
210
|
+
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
analyze( builder ) {
|
|
157
214
|
|
|
158
|
-
|
|
215
|
+
const usageCount = this.increaseUsage( builder );
|
|
216
|
+
|
|
217
|
+
if ( usageCount === 1 ) {
|
|
159
218
|
|
|
160
219
|
// node flow children
|
|
161
220
|
|
|
@@ -223,6 +282,8 @@ class Node extends EventDispatcher {
|
|
|
223
282
|
|
|
224
283
|
if ( buildStage === 'setup' ) {
|
|
225
284
|
|
|
285
|
+
this.updateReference( builder );
|
|
286
|
+
|
|
226
287
|
const properties = builder.getNodeProperties( this );
|
|
227
288
|
|
|
228
289
|
if ( properties.initialized !== true || builder.context.tempRead === false ) {
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
ColorNodeUniform, Matrix3NodeUniform, Matrix4NodeUniform
|
|
16
16
|
} from '../../renderers/common/nodes/NodeUniform.js';
|
|
17
17
|
|
|
18
|
-
import { REVISION, RenderTarget,
|
|
18
|
+
import { REVISION, RenderTarget, Color, Vector2, Vector3, Vector4, IntType, UnsignedIntType, Float16BufferAttribute } from 'three';
|
|
19
19
|
|
|
20
20
|
import { stack } from './StackNode.js';
|
|
21
21
|
import { getCurrentStack, setCurrentStack } from '../shadernode/ShaderNode.js';
|
|
@@ -23,6 +23,8 @@ import { getCurrentStack, setCurrentStack } from '../shadernode/ShaderNode.js';
|
|
|
23
23
|
import CubeRenderTarget from '../../renderers/common/CubeRenderTarget.js';
|
|
24
24
|
import ChainMap from '../../renderers/common/ChainMap.js';
|
|
25
25
|
|
|
26
|
+
import PMREMGenerator from '../../renderers/common/extras/PMREMGenerator.js';
|
|
27
|
+
|
|
26
28
|
const uniformsGroupCache = new ChainMap();
|
|
27
29
|
|
|
28
30
|
const typeFromLength = new Map( [
|
|
@@ -72,6 +74,8 @@ class NodeBuilder {
|
|
|
72
74
|
this.fogNode = null;
|
|
73
75
|
this.toneMappingNode = null;
|
|
74
76
|
|
|
77
|
+
this.clippingContext = null;
|
|
78
|
+
|
|
75
79
|
this.vertexShader = null;
|
|
76
80
|
this.fragmentShader = null;
|
|
77
81
|
this.computeShader = null;
|
|
@@ -111,18 +115,26 @@ class NodeBuilder {
|
|
|
111
115
|
|
|
112
116
|
}
|
|
113
117
|
|
|
114
|
-
|
|
118
|
+
createRenderTarget( width, height, options ) {
|
|
115
119
|
|
|
116
120
|
return new RenderTarget( width, height, options );
|
|
117
121
|
|
|
118
122
|
}
|
|
119
123
|
|
|
120
|
-
|
|
124
|
+
createCubeRenderTarget( size, options ) {
|
|
121
125
|
|
|
122
126
|
return new CubeRenderTarget( size, options );
|
|
123
127
|
|
|
124
128
|
}
|
|
125
129
|
|
|
130
|
+
createPMREMGenerator() {
|
|
131
|
+
|
|
132
|
+
// TODO: Move Materials.js to outside of the Nodes.js in order to remove this function and improve tree-shaking support
|
|
133
|
+
|
|
134
|
+
return new PMREMGenerator( this.renderer );
|
|
135
|
+
|
|
136
|
+
}
|
|
137
|
+
|
|
126
138
|
includes( node ) {
|
|
127
139
|
|
|
128
140
|
return this.nodes.includes( node );
|
|
@@ -472,33 +484,18 @@ class NodeBuilder {
|
|
|
472
484
|
|
|
473
485
|
}
|
|
474
486
|
|
|
475
|
-
|
|
476
|
-
getTextureEncodingFromMap( map ) {
|
|
477
|
-
|
|
478
|
-
console.warn( 'THREE.NodeBuilder: Method .getTextureEncodingFromMap replaced by .getTextureColorSpaceFromMap in r152+.' );
|
|
479
|
-
return this.getTextureColorSpaceFromMap( map ) === SRGBColorSpace ? sRGBEncoding : LinearEncoding;
|
|
480
|
-
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
getTextureColorSpaceFromMap( map ) {
|
|
484
|
-
|
|
485
|
-
let colorSpace;
|
|
487
|
+
getComponentTypeFromTexture( texture ) {
|
|
486
488
|
|
|
487
|
-
|
|
489
|
+
const type = texture.type;
|
|
488
490
|
|
|
489
|
-
|
|
491
|
+
if ( texture.isDataTexture ) {
|
|
490
492
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
colorSpace = map.texture.colorSpace;
|
|
494
|
-
|
|
495
|
-
} else {
|
|
496
|
-
|
|
497
|
-
colorSpace = NoColorSpace;
|
|
493
|
+
if ( type === IntType ) return 'int';
|
|
494
|
+
if ( type === UnsignedIntType ) return 'uint';
|
|
498
495
|
|
|
499
496
|
}
|
|
500
497
|
|
|
501
|
-
return
|
|
498
|
+
return 'float';
|
|
502
499
|
|
|
503
500
|
}
|
|
504
501
|
|
|
@@ -1174,6 +1171,8 @@ class NodeBuilder {
|
|
|
1174
1171
|
|
|
1175
1172
|
createNodeMaterial( type = 'NodeMaterial' ) {
|
|
1176
1173
|
|
|
1174
|
+
// TODO: Move Materials.js to outside of the Nodes.js in order to remove this function and improve tree-shaking support
|
|
1175
|
+
|
|
1177
1176
|
return createNodeMaterialFromType( type );
|
|
1178
1177
|
|
|
1179
1178
|
}
|
|
@@ -51,11 +51,11 @@ class NodeFrame {
|
|
|
51
51
|
|
|
52
52
|
const { frameMap } = this._getMaps( this.updateBeforeMap, reference );
|
|
53
53
|
|
|
54
|
-
if ( frameMap.get(
|
|
54
|
+
if ( frameMap.get( reference ) !== this.frameId ) {
|
|
55
55
|
|
|
56
56
|
if ( node.updateBefore( this ) !== false ) {
|
|
57
57
|
|
|
58
|
-
frameMap.set(
|
|
58
|
+
frameMap.set( reference, this.frameId );
|
|
59
59
|
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -65,11 +65,11 @@ class NodeFrame {
|
|
|
65
65
|
|
|
66
66
|
const { renderMap } = this._getMaps( this.updateBeforeMap, reference );
|
|
67
67
|
|
|
68
|
-
if ( renderMap.get(
|
|
68
|
+
if ( renderMap.get( reference ) !== this.renderId ) {
|
|
69
69
|
|
|
70
70
|
if ( node.updateBefore( this ) !== false ) {
|
|
71
71
|
|
|
72
|
-
renderMap.set(
|
|
72
|
+
renderMap.set( reference, this.renderId );
|
|
73
73
|
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -92,11 +92,11 @@ class NodeFrame {
|
|
|
92
92
|
|
|
93
93
|
const { frameMap } = this._getMaps( this.updateMap, reference );
|
|
94
94
|
|
|
95
|
-
if ( frameMap.get(
|
|
95
|
+
if ( frameMap.get( reference ) !== this.frameId ) {
|
|
96
96
|
|
|
97
97
|
if ( node.update( this ) !== false ) {
|
|
98
98
|
|
|
99
|
-
frameMap.set(
|
|
99
|
+
frameMap.set( reference, this.frameId );
|
|
100
100
|
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -106,11 +106,11 @@ class NodeFrame {
|
|
|
106
106
|
|
|
107
107
|
const { renderMap } = this._getMaps( this.updateMap, reference );
|
|
108
108
|
|
|
109
|
-
if ( renderMap.get(
|
|
109
|
+
if ( renderMap.get( reference ) !== this.renderId ) {
|
|
110
110
|
|
|
111
111
|
if ( node.update( this ) !== false ) {
|
|
112
112
|
|
|
113
|
-
renderMap.set(
|
|
113
|
+
renderMap.set( reference, this.renderId );
|
|
114
114
|
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Color, Matrix3, Matrix4, Vector2, Vector3, Vector4 } from 'three';
|
|
2
2
|
|
|
3
|
-
export function getCacheKey( object ) {
|
|
3
|
+
export function getCacheKey( object, force = false ) {
|
|
4
4
|
|
|
5
5
|
let cacheKey = '{';
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ export function getCacheKey( object ) {
|
|
|
12
12
|
|
|
13
13
|
for ( const { property, childNode } of getNodeChildren( object ) ) {
|
|
14
14
|
|
|
15
|
-
cacheKey += ',' + property.slice( 0, - 4 ) + ':' + childNode.getCacheKey();
|
|
15
|
+
cacheKey += ',' + property.slice( 0, - 4 ) + ':' + childNode.getCacheKey( force );
|
|
16
16
|
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -35,6 +35,26 @@ class UniformNode extends InputNode {
|
|
|
35
35
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
onUpdate( callback, updateType ) {
|
|
39
|
+
|
|
40
|
+
const self = this.getSelf();
|
|
41
|
+
|
|
42
|
+
callback = callback.bind( self );
|
|
43
|
+
|
|
44
|
+
return super.onUpdate( ( frame ) => {
|
|
45
|
+
|
|
46
|
+
const value = callback( frame, self );
|
|
47
|
+
|
|
48
|
+
if ( value !== undefined ) {
|
|
49
|
+
|
|
50
|
+
this.value = value;
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}, updateType );
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
38
58
|
generate( builder, output ) {
|
|
39
59
|
|
|
40
60
|
const type = this.getNodeType( builder );
|
|
@@ -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 );
|
|
@@ -66,6 +66,7 @@ class PassNode extends TempNode {
|
|
|
66
66
|
this._depthTextureNode = nodeObject( new PassTextureNode( this, depthTexture ) );
|
|
67
67
|
|
|
68
68
|
this._depthNode = null;
|
|
69
|
+
this._viewZNode = null;
|
|
69
70
|
this._cameraNear = uniform( 0 );
|
|
70
71
|
this._cameraFar = uniform( 0 );
|
|
71
72
|
|
|
@@ -91,6 +92,21 @@ class PassNode extends TempNode {
|
|
|
91
92
|
|
|
92
93
|
}
|
|
93
94
|
|
|
95
|
+
getViewZNode() {
|
|
96
|
+
|
|
97
|
+
if ( this._viewZNode === null ) {
|
|
98
|
+
|
|
99
|
+
const cameraNear = this._cameraNear;
|
|
100
|
+
const cameraFar = this._cameraFar;
|
|
101
|
+
|
|
102
|
+
this._viewZNode = perspectiveDepthToViewZ( this._depthTextureNode, cameraNear, cameraFar );
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return this._viewZNode;
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
94
110
|
getDepthNode() {
|
|
95
111
|
|
|
96
112
|
if ( this._depthNode === null ) {
|
|
@@ -98,7 +114,7 @@ class PassNode extends TempNode {
|
|
|
98
114
|
const cameraNear = this._cameraNear;
|
|
99
115
|
const cameraFar = this._cameraFar;
|
|
100
116
|
|
|
101
|
-
this._depthNode = viewZToOrthographicDepth(
|
|
117
|
+
this._depthNode = viewZToOrthographicDepth( this.getViewZNode(), cameraNear, cameraFar );
|
|
102
118
|
|
|
103
119
|
}
|
|
104
120
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
2
|
import { addNodeClass } from '../core/Node.js';
|
|
3
|
-
import { tslFn, nodeObject, float, mat3, vec3 } from '../shadernode/ShaderNode.js';
|
|
4
|
-
|
|
5
|
-
import { NoToneMapping, LinearToneMapping, ReinhardToneMapping, CineonToneMapping, ACESFilmicToneMapping, AgXToneMapping } from 'three';
|
|
3
|
+
import { addNodeElement, tslFn, nodeObject, float, mat3, vec3 } from '../shadernode/ShaderNode.js';
|
|
4
|
+
import { rendererReference } from '../accessors/RendererReferenceNode.js';
|
|
6
5
|
import { clamp, log2, max, pow } from '../math/MathNode.js';
|
|
7
6
|
import { mul } from '../math/OperatorNode.js';
|
|
8
7
|
|
|
8
|
+
import { NoToneMapping, LinearToneMapping, ReinhardToneMapping, CineonToneMapping, ACESFilmicToneMapping, AgXToneMapping } from 'three';
|
|
9
|
+
|
|
9
10
|
// exposure only
|
|
10
11
|
const LinearToneMappingNode = tslFn( ( { color, exposure } ) => {
|
|
11
12
|
|
|
@@ -127,7 +128,7 @@ const toneMappingLib = {
|
|
|
127
128
|
|
|
128
129
|
class ToneMappingNode extends TempNode {
|
|
129
130
|
|
|
130
|
-
constructor( toneMapping = NoToneMapping, exposureNode =
|
|
131
|
+
constructor( toneMapping = NoToneMapping, exposureNode = toneMappingExposure, colorNode = null ) {
|
|
131
132
|
|
|
132
133
|
super( 'vec3' );
|
|
133
134
|
|
|
@@ -180,5 +181,8 @@ class ToneMappingNode extends TempNode {
|
|
|
180
181
|
export default ToneMappingNode;
|
|
181
182
|
|
|
182
183
|
export const toneMapping = ( mapping, exposure, color ) => nodeObject( new ToneMappingNode( mapping, nodeObject( exposure ), nodeObject( color ) ) );
|
|
184
|
+
export const toneMappingExposure = rendererReference( 'toneMappingExposure', 'float' );
|
|
185
|
+
|
|
186
|
+
addNodeElement( 'toneMapping', ( color, mapping, exposure ) => toneMapping( mapping, exposure, color ) );
|
|
183
187
|
|
|
184
188
|
addNodeClass( 'ToneMappingNode', ToneMappingNode );
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import FogNode from './FogNode.js';
|
|
2
|
-
import { positionView } from '../accessors/PositionNode.js';
|
|
3
2
|
import { addNodeClass } from '../core/Node.js';
|
|
4
3
|
import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js';
|
|
5
4
|
|
|
@@ -15,12 +14,12 @@ class FogExp2Node extends FogNode {
|
|
|
15
14
|
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
setup() {
|
|
17
|
+
setup( builder ) {
|
|
19
18
|
|
|
20
|
-
const
|
|
21
|
-
const
|
|
19
|
+
const viewZ = this.getViewZNode( builder );
|
|
20
|
+
const density = this.densityNode;
|
|
22
21
|
|
|
23
|
-
return
|
|
22
|
+
return density.mul( density, viewZ, viewZ ).negate().exp().oneMinus();
|
|
24
23
|
|
|
25
24
|
}
|
|
26
25
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Node, { addNodeClass } from '../core/Node.js';
|
|
2
|
-
import {
|
|
2
|
+
import { positionView } from '../accessors/PositionNode.js';
|
|
3
3
|
import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js';
|
|
4
4
|
|
|
5
5
|
class FogNode extends Node {
|
|
@@ -15,9 +15,19 @@ class FogNode extends Node {
|
|
|
15
15
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
getViewZNode( builder ) {
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
let viewZ;
|
|
21
|
+
|
|
22
|
+
const getViewZ = builder.context.getViewZ;
|
|
23
|
+
|
|
24
|
+
if ( getViewZ !== undefined ) {
|
|
25
|
+
|
|
26
|
+
viewZ = getViewZ( this );
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return ( viewZ || positionView.z ).negate();
|
|
21
31
|
|
|
22
32
|
}
|
|
23
33
|
|