@needle-tools/three 0.153.1 → 0.154.2
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 +1260 -1517
- package/build/three.js +1267 -1524
- package/build/three.min.js +7 -8
- package/build/three.module.js +859 -1097
- package/build/three.module.min.js +6 -7
- package/examples/jsm/controls/ArcballControls.js +2 -1
- package/examples/jsm/controls/FlyControls.js +25 -9
- package/examples/jsm/controls/OrbitControls.js +7 -1
- package/examples/jsm/csm/CSM.js +1 -1
- package/examples/jsm/effects/AnaglyphEffect.js +1 -1
- package/examples/jsm/effects/OutlineEffect.js +1 -1
- package/examples/jsm/effects/ParallaxBarrierEffect.js +1 -1
- package/examples/jsm/environments/RoomEnvironment.js +6 -2
- package/examples/jsm/lines/LineMaterial.js +1 -1
- package/examples/jsm/loaders/3DMLoader.js +1 -1
- package/examples/jsm/loaders/3MFLoader.js +5 -1
- package/examples/jsm/loaders/AMFLoader.js +5 -1
- package/examples/jsm/loaders/ColladaLoader.js +4 -1
- package/examples/jsm/loaders/FBXLoader.js +9 -2
- package/examples/jsm/loaders/GLTFLoader.js +8 -2
- package/examples/jsm/loaders/GLTFLoaderAnimationPointer.js +2 -2
- package/examples/jsm/loaders/LDrawLoader.js +4 -7
- package/examples/jsm/loaders/PLYLoader.js +16 -6
- package/examples/jsm/loaders/VRMLLoader.js +16 -4
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -2
- package/examples/jsm/math/MeshSurfaceSampler.js +76 -35
- package/examples/jsm/nodes/Nodes.js +20 -15
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +21 -8
- package/examples/jsm/nodes/accessors/CameraNode.js +25 -4
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +7 -1
- package/examples/jsm/nodes/accessors/InstanceNode.js +2 -4
- package/examples/jsm/nodes/accessors/MaterialNode.js +55 -47
- package/examples/jsm/nodes/accessors/ModelNode.js +3 -1
- package/examples/jsm/nodes/accessors/MorphNode.js +70 -0
- package/examples/jsm/nodes/accessors/NormalNode.js +3 -2
- package/examples/jsm/nodes/accessors/Object3DNode.js +10 -2
- package/examples/jsm/nodes/accessors/SceneNode.js +46 -0
- package/examples/jsm/nodes/accessors/SkinningNode.js +43 -62
- package/examples/jsm/nodes/accessors/TangentNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureBicubicNode.js +94 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +68 -6
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +35 -0
- package/examples/jsm/nodes/accessors/UVNode.js +1 -1
- package/examples/jsm/nodes/code/CodeNode.js +3 -0
- package/examples/jsm/nodes/code/FunctionNode.js +25 -4
- package/examples/jsm/nodes/core/BypassNode.js +2 -2
- package/examples/jsm/nodes/core/ContextNode.js +2 -0
- package/examples/jsm/nodes/core/IndexNode.js +66 -0
- package/examples/jsm/nodes/core/LightingModel.js +2 -1
- package/examples/jsm/nodes/core/Node.js +12 -15
- package/examples/jsm/nodes/core/NodeBuilder.js +24 -5
- package/examples/jsm/nodes/core/PropertyNode.js +4 -0
- package/examples/jsm/nodes/core/StackNode.js +1 -1
- package/examples/jsm/nodes/core/UniformNode.js +1 -1
- package/examples/jsm/nodes/core/VarNode.js +1 -3
- package/examples/jsm/nodes/display/BlendModeNode.js +9 -9
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +7 -7
- package/examples/jsm/nodes/display/ColorSpaceNode.js +50 -49
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -3
- package/examples/jsm/nodes/display/ToneMappingNode.js +8 -8
- package/examples/jsm/nodes/display/ViewportDepthNode.js +69 -0
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +34 -0
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -5
- package/examples/jsm/nodes/display/ViewportTextureNode.js +23 -15
- package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +5 -5
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -8
- package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +43 -0
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +4 -4
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/EnvironmentBRDF.js +13 -0
- package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +2 -4
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/examples/jsm/nodes/functions/PhongLightingModel.js +7 -7
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +129 -18
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +2 -2
- package/examples/jsm/nodes/functions/material/getRoughness.js +3 -3
- package/examples/jsm/nodes/geometry/RangeNode.js +1 -1
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +2 -2
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +91 -62
- package/examples/jsm/nodes/lighting/LightUtils.js +2 -2
- package/examples/jsm/nodes/lighting/LightingContextNode.js +17 -15
- package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/SpotLightNode.js +3 -3
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +0 -15
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -15
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -10
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -9
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +41 -0
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +1 -14
- package/examples/jsm/nodes/materials/NodeMaterial.js +79 -28
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +0 -9
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -7
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +3 -3
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +14 -14
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +4 -4
- package/examples/jsm/nodes/math/MathNode.js +6 -0
- package/examples/jsm/nodes/math/OperatorNode.js +1 -1
- package/examples/jsm/nodes/procedural/CheckerNode.js +3 -3
- package/examples/jsm/nodes/shadernode/ShaderNode.js +24 -4
- package/examples/jsm/nodes/utils/LoopNode.js +1 -1
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +1 -1
- package/examples/jsm/objects/GroundProjectedSkybox.js +1 -1
- package/examples/jsm/objects/Reflector.js +1 -1
- package/examples/jsm/objects/Refractor.js +1 -1
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/Water.js +1 -1
- package/examples/jsm/objects/Water2.js +1 -1
- package/examples/jsm/offscreen/scene.js +1 -0
- package/examples/jsm/postprocessing/EffectComposer.js +2 -0
- package/examples/jsm/postprocessing/OutlinePass.js +1 -3
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -12
- package/examples/jsm/postprocessing/SavePass.js +3 -1
- package/examples/jsm/postprocessing/TAARenderPass.js +14 -2
- package/examples/jsm/postprocessing/TexturePass.js +2 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +9 -10
- package/examples/jsm/renderers/common/Backend.js +2 -0
- package/examples/jsm/renderers/common/Background.js +7 -6
- package/examples/jsm/renderers/common/Pipelines.js +26 -14
- package/examples/jsm/renderers/common/RenderObject.js +18 -0
- package/examples/jsm/renderers/common/RenderObjects.js +29 -29
- package/examples/jsm/renderers/common/Renderer.js +48 -6
- package/examples/jsm/renderers/common/nodes/Nodes.js +1 -1
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +340 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +23 -19
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +123 -41
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +29 -9
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +8 -13
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +85 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +5 -1
- package/examples/jsm/shaders/BlendShader.js +1 -2
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/CopyShader.js +2 -2
- package/examples/jsm/shaders/ToonShader.js +4 -4
- package/examples/jsm/shaders/WaterRefractionShader.js +1 -1
- package/examples/jsm/webxr/OculusHandPointerModel.js +34 -13
- package/package.json +2 -1
- package/src/Three.Legacy.js +0 -228
- package/src/animation/PropertyBinding.js +1 -1
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +0 -24
- package/src/core/BufferGeometry.js +0 -7
- package/src/loaders/Loader.js +2 -0
- package/src/loaders/MaterialLoader.js +1 -0
- package/src/materials/Material.js +3 -0
- package/src/objects/Skeleton.js +0 -2
- package/src/renderers/WebGLRenderer.js +9 -21
- package/src/renderers/shaders/ShaderChunk/alphahash_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/alphahash_pars_fragment.glsl.js +68 -0
- package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +10 -6
- package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +1 -1
- 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/equirect.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/points.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +4 -2
- package/src/renderers/webgl/WebGLObjects.js +23 -3
- package/src/renderers/webgl/WebGLProgram.js +24 -5
- package/src/renderers/webgl/WebGLPrograms.js +3 -0
- package/src/renderers/webxr/WebXRManager.js +11 -33
- package/src/scenes/Scene.js +0 -14
- package/examples/jsm/nodes/core/InstanceIndexNode.js +0 -45
- /package/src/renderers/shaders/ShaderChunk/{encodings_fragment.glsl.js → colorspace_fragment.glsl.js} +0 -0
- /package/src/renderers/shaders/ShaderChunk/{encodings_pars_fragment.glsl.js → colorspace_pars_fragment.glsl.js} +0 -0
- /package/src/renderers/shaders/ShaderChunk/{output_fragment.glsl.js → opaque_fragment.glsl.js} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Triangle,
|
|
3
|
+
Vector2,
|
|
3
4
|
Vector3
|
|
4
5
|
} from 'three';
|
|
5
6
|
|
|
@@ -16,26 +17,20 @@ import {
|
|
|
16
17
|
|
|
17
18
|
const _face = new Triangle();
|
|
18
19
|
const _color = new Vector3();
|
|
20
|
+
const _uva = new Vector2(), _uvb = new Vector2(), _uvc = new Vector2();
|
|
19
21
|
|
|
20
22
|
class MeshSurfaceSampler {
|
|
21
23
|
|
|
22
24
|
constructor( mesh ) {
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if ( geometry.index ) {
|
|
27
|
-
|
|
28
|
-
console.warn( 'THREE.MeshSurfaceSampler: Converting geometry to non-indexed BufferGeometry.' );
|
|
29
|
-
|
|
30
|
-
geometry = geometry.toNonIndexed();
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
this.geometry = geometry;
|
|
26
|
+
this.geometry = mesh.geometry;
|
|
35
27
|
this.randomFunction = Math.random;
|
|
36
28
|
|
|
29
|
+
this.indexAttribute = this.geometry.index;
|
|
37
30
|
this.positionAttribute = this.geometry.getAttribute( 'position' );
|
|
31
|
+
this.normalAttribute = this.geometry.getAttribute( 'normal' );
|
|
38
32
|
this.colorAttribute = this.geometry.getAttribute( 'color' );
|
|
33
|
+
this.uvAttribute = this.geometry.getAttribute( 'uv' );
|
|
39
34
|
this.weightAttribute = null;
|
|
40
35
|
|
|
41
36
|
this.distribution = null;
|
|
@@ -52,49 +47,62 @@ class MeshSurfaceSampler {
|
|
|
52
47
|
|
|
53
48
|
build() {
|
|
54
49
|
|
|
50
|
+
const indexAttribute = this.indexAttribute;
|
|
55
51
|
const positionAttribute = this.positionAttribute;
|
|
56
52
|
const weightAttribute = this.weightAttribute;
|
|
57
53
|
|
|
58
|
-
const
|
|
54
|
+
const totalFaces = indexAttribute ? ( indexAttribute.count / 3 ) : ( positionAttribute.count / 3 );
|
|
55
|
+
const faceWeights = new Float32Array( totalFaces );
|
|
59
56
|
|
|
60
57
|
// Accumulate weights for each mesh face.
|
|
61
58
|
|
|
62
|
-
for ( let i = 0; i <
|
|
59
|
+
for ( let i = 0; i < totalFaces; i ++ ) {
|
|
63
60
|
|
|
64
61
|
let faceWeight = 1;
|
|
65
62
|
|
|
63
|
+
let i0 = 3 * i;
|
|
64
|
+
let i1 = 3 * i + 1;
|
|
65
|
+
let i2 = 3 * i + 2;
|
|
66
|
+
|
|
67
|
+
if ( indexAttribute ) {
|
|
68
|
+
|
|
69
|
+
i0 = indexAttribute.getX( i0 );
|
|
70
|
+
i1 = indexAttribute.getX( i1 );
|
|
71
|
+
i2 = indexAttribute.getX( i2 );
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
66
75
|
if ( weightAttribute ) {
|
|
67
76
|
|
|
68
|
-
faceWeight = weightAttribute.getX(
|
|
69
|
-
+ weightAttribute.getX(
|
|
70
|
-
+ weightAttribute.getX(
|
|
77
|
+
faceWeight = weightAttribute.getX( i0 )
|
|
78
|
+
+ weightAttribute.getX( i1 )
|
|
79
|
+
+ weightAttribute.getX( i2 );
|
|
71
80
|
|
|
72
81
|
}
|
|
73
82
|
|
|
74
|
-
_face.a.fromBufferAttribute( positionAttribute,
|
|
75
|
-
_face.b.fromBufferAttribute( positionAttribute,
|
|
76
|
-
_face.c.fromBufferAttribute( positionAttribute,
|
|
83
|
+
_face.a.fromBufferAttribute( positionAttribute, i0 );
|
|
84
|
+
_face.b.fromBufferAttribute( positionAttribute, i1 );
|
|
85
|
+
_face.c.fromBufferAttribute( positionAttribute, i2 );
|
|
77
86
|
faceWeight *= _face.getArea();
|
|
78
87
|
|
|
79
|
-
faceWeights[ i
|
|
88
|
+
faceWeights[ i ] = faceWeight;
|
|
80
89
|
|
|
81
90
|
}
|
|
82
91
|
|
|
83
92
|
// Store cumulative total face weights in an array, where weight index
|
|
84
93
|
// corresponds to face index.
|
|
85
94
|
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
const distribution = new Float32Array( totalFaces );
|
|
88
96
|
let cumulativeTotal = 0;
|
|
89
97
|
|
|
90
|
-
for ( let i = 0; i <
|
|
98
|
+
for ( let i = 0; i < totalFaces; i ++ ) {
|
|
91
99
|
|
|
92
100
|
cumulativeTotal += faceWeights[ i ];
|
|
93
|
-
|
|
94
|
-
this.distribution[ i ] = cumulativeTotal;
|
|
101
|
+
distribution[ i ] = cumulativeTotal;
|
|
95
102
|
|
|
96
103
|
}
|
|
97
104
|
|
|
105
|
+
this.distribution = distribution;
|
|
98
106
|
return this;
|
|
99
107
|
|
|
100
108
|
}
|
|
@@ -106,10 +114,10 @@ class MeshSurfaceSampler {
|
|
|
106
114
|
|
|
107
115
|
}
|
|
108
116
|
|
|
109
|
-
sample( targetPosition, targetNormal, targetColor ) {
|
|
117
|
+
sample( targetPosition, targetNormal, targetColor, targetUV ) {
|
|
110
118
|
|
|
111
119
|
const faceIndex = this.sampleFaceIndex();
|
|
112
|
-
return this.sampleFace( faceIndex, targetPosition, targetNormal, targetColor );
|
|
120
|
+
return this.sampleFace( faceIndex, targetPosition, targetNormal, targetColor, targetUV );
|
|
113
121
|
|
|
114
122
|
}
|
|
115
123
|
|
|
@@ -154,7 +162,7 @@ class MeshSurfaceSampler {
|
|
|
154
162
|
|
|
155
163
|
}
|
|
156
164
|
|
|
157
|
-
sampleFace( faceIndex, targetPosition, targetNormal, targetColor ) {
|
|
165
|
+
sampleFace( faceIndex, targetPosition, targetNormal, targetColor, targetUV ) {
|
|
158
166
|
|
|
159
167
|
let u = this.randomFunction();
|
|
160
168
|
let v = this.randomFunction();
|
|
@@ -166,9 +174,22 @@ class MeshSurfaceSampler {
|
|
|
166
174
|
|
|
167
175
|
}
|
|
168
176
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
177
|
+
// get the vertex attribute indices
|
|
178
|
+
const indexAttribute = this.indexAttribute;
|
|
179
|
+
let i0 = faceIndex * 3;
|
|
180
|
+
let i1 = faceIndex * 3 + 1;
|
|
181
|
+
let i2 = faceIndex * 3 + 2;
|
|
182
|
+
if ( indexAttribute ) {
|
|
183
|
+
|
|
184
|
+
i0 = indexAttribute.getX( i0 );
|
|
185
|
+
i1 = indexAttribute.getX( i1 );
|
|
186
|
+
i2 = indexAttribute.getX( i2 );
|
|
187
|
+
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
_face.a.fromBufferAttribute( this.positionAttribute, i0 );
|
|
191
|
+
_face.b.fromBufferAttribute( this.positionAttribute, i1 );
|
|
192
|
+
_face.c.fromBufferAttribute( this.positionAttribute, i2 );
|
|
172
193
|
|
|
173
194
|
targetPosition
|
|
174
195
|
.set( 0, 0, 0 )
|
|
@@ -178,15 +199,26 @@ class MeshSurfaceSampler {
|
|
|
178
199
|
|
|
179
200
|
if ( targetNormal !== undefined ) {
|
|
180
201
|
|
|
181
|
-
|
|
202
|
+
if ( this.normalAttribute !== undefined ) {
|
|
203
|
+
|
|
204
|
+
_face.a.fromBufferAttribute( this.normalAttribute, i0 );
|
|
205
|
+
_face.b.fromBufferAttribute( this.normalAttribute, i1 );
|
|
206
|
+
_face.c.fromBufferAttribute( this.normalAttribute, i2 );
|
|
207
|
+
targetNormal.set( 0, 0, 0 ).addScaledVector( _face.a, u ).addScaledVector( _face.b, v ).addScaledVector( _face.c, 1 - ( u + v ) ).normalize();
|
|
208
|
+
|
|
209
|
+
} else {
|
|
210
|
+
|
|
211
|
+
_face.getNormal( targetNormal );
|
|
212
|
+
|
|
213
|
+
}
|
|
182
214
|
|
|
183
215
|
}
|
|
184
216
|
|
|
185
217
|
if ( targetColor !== undefined && this.colorAttribute !== undefined ) {
|
|
186
218
|
|
|
187
|
-
_face.a.fromBufferAttribute( this.colorAttribute,
|
|
188
|
-
_face.b.fromBufferAttribute( this.colorAttribute,
|
|
189
|
-
_face.c.fromBufferAttribute( this.colorAttribute,
|
|
219
|
+
_face.a.fromBufferAttribute( this.colorAttribute, i0 );
|
|
220
|
+
_face.b.fromBufferAttribute( this.colorAttribute, i1 );
|
|
221
|
+
_face.c.fromBufferAttribute( this.colorAttribute, i2 );
|
|
190
222
|
|
|
191
223
|
_color
|
|
192
224
|
.set( 0, 0, 0 )
|
|
@@ -200,6 +232,15 @@ class MeshSurfaceSampler {
|
|
|
200
232
|
|
|
201
233
|
}
|
|
202
234
|
|
|
235
|
+
if ( targetUV !== undefined && this.uvAttribute !== undefined ) {
|
|
236
|
+
|
|
237
|
+
_uva.fromBufferAttribute( this.uvAttribute, i0 );
|
|
238
|
+
_uvb.fromBufferAttribute( this.uvAttribute, i1 );
|
|
239
|
+
_uvc.fromBufferAttribute( this.uvAttribute, i2 );
|
|
240
|
+
targetUV.set( 0, 0 ).addScaledVector( _uva, u ).addScaledVector( _uvb, v ).addScaledVector( _uvc, 1 - ( u + v ) );
|
|
241
|
+
|
|
242
|
+
}
|
|
243
|
+
|
|
203
244
|
return this;
|
|
204
245
|
|
|
205
246
|
}
|
|
@@ -10,8 +10,8 @@ export { default as AttributeNode, attribute } from './core/AttributeNode.js';
|
|
|
10
10
|
export { default as BypassNode, bypass } from './core/BypassNode.js';
|
|
11
11
|
export { default as CacheNode, cache } from './core/CacheNode.js';
|
|
12
12
|
export { default as ConstNode } from './core/ConstNode.js';
|
|
13
|
-
export { default as ContextNode, context } from './core/ContextNode.js';
|
|
14
|
-
export { default as
|
|
13
|
+
export { default as ContextNode, context, label } from './core/ContextNode.js';
|
|
14
|
+
export { default as IndexNode, vertexIndex, instanceIndex } from './core/IndexNode.js';
|
|
15
15
|
export { default as LightingModel, lightingModel } from './core/LightingModel.js';
|
|
16
16
|
export { default as Node, addNodeClass, createNodeFromType } from './core/Node.js';
|
|
17
17
|
export { default as NodeAttribute } from './core/NodeAttribute.js';
|
|
@@ -28,14 +28,14 @@ export { default as PropertyNode, property, diffuseColor, roughness, metalness,
|
|
|
28
28
|
export { default as StackNode, stack } from './core/StackNode.js';
|
|
29
29
|
export { default as TempNode } from './core/TempNode.js';
|
|
30
30
|
export { default as UniformNode, uniform } from './core/UniformNode.js';
|
|
31
|
-
export { default as VarNode,
|
|
31
|
+
export { default as VarNode, temp } from './core/VarNode.js';
|
|
32
32
|
export { default as VaryingNode, varying } from './core/VaryingNode.js';
|
|
33
33
|
|
|
34
34
|
import * as NodeUtils from './core/NodeUtils.js';
|
|
35
35
|
export { NodeUtils };
|
|
36
36
|
|
|
37
37
|
// math
|
|
38
|
-
export { default as MathNode, EPSILON, INFINITY, radians, degrees, exp, exp2, log, log2, sqrt, inverseSqrt, floor, ceil, normalize, fract, sin, cos, tan, asin, acos, atan, abs, sign, length, negate, oneMinus, dFdx, dFdy, round, reciprocal, atan2, min, max, mod, step, reflect, distance, difference, dot, cross, pow, pow2, pow3, pow4, transformDirection, mix, clamp, saturate, refract, smoothstep, faceForward } from './math/MathNode.js';
|
|
38
|
+
export { default as MathNode, EPSILON, INFINITY, radians, degrees, exp, exp2, log, log2, sqrt, inverseSqrt, floor, ceil, normalize, fract, sin, cos, tan, asin, acos, atan, abs, sign, length, negate, oneMinus, dFdx, dFdy, round, reciprocal, trunc, fwidth, atan2, min, max, mod, step, reflect, distance, difference, dot, cross, pow, pow2, pow3, pow4, transformDirection, mix, clamp, saturate, refract, smoothstep, faceForward } from './math/MathNode.js';
|
|
39
39
|
export { default as OperatorNode, add, sub, mul, div, remainder, equal, assign, lessThan, greaterThan, lessThanEqual, greaterThanEqual, and, or, xor, bitAnd, bitOr, bitXor, shiftLeft, shiftRight } from './math/OperatorNode.js';
|
|
40
40
|
export { default as CondNode, cond } from './math/CondNode.js';
|
|
41
41
|
|
|
@@ -63,46 +63,51 @@ export * from './shadernode/ShaderNode.js';
|
|
|
63
63
|
|
|
64
64
|
// accessors
|
|
65
65
|
export { default as BitangentNode, bitangentGeometry, bitangentLocal, bitangentView, bitangentWorld, transformedBitangentView, transformedBitangentWorld } from './accessors/BitangentNode.js';
|
|
66
|
-
export { default as BufferAttributeNode, bufferAttribute, dynamicBufferAttribute } from './accessors/BufferAttributeNode.js';
|
|
66
|
+
export { default as BufferAttributeNode, bufferAttribute, dynamicBufferAttribute, instancedBufferAttribute, instancedDynamicBufferAttribute } from './accessors/BufferAttributeNode.js';
|
|
67
67
|
export { default as BufferNode, buffer } from './accessors/BufferNode.js';
|
|
68
|
-
export { default as CameraNode, cameraProjectionMatrix, cameraViewMatrix, cameraNormalMatrix, cameraWorldMatrix, cameraPosition } from './accessors/CameraNode.js';
|
|
68
|
+
export { default as CameraNode, cameraProjectionMatrix, cameraViewMatrix, cameraNormalMatrix, cameraWorldMatrix, cameraPosition, cameraNear, cameraFar } from './accessors/CameraNode.js';
|
|
69
69
|
export { default as CubeTextureNode, cubeTexture } from './accessors/CubeTextureNode.js';
|
|
70
70
|
export { default as ExtendedMaterialNode, materialNormal } from './accessors/ExtendedMaterialNode.js';
|
|
71
71
|
export { default as InstanceNode, instance } from './accessors/InstanceNode.js';
|
|
72
|
-
export { default as MaterialNode,
|
|
72
|
+
export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecularColor, materialReflectivity, materialRoughness, materialMetalness, materialRotation, materialSheen, materialSheenRoughness } from './accessors/MaterialNode.js';
|
|
73
73
|
export { default as MaterialReferenceNode, materialReference } from './accessors/MaterialReferenceNode.js';
|
|
74
|
-
export { default as
|
|
74
|
+
export { default as MorphNode, morph } from './accessors/MorphNode.js';
|
|
75
|
+
export { default as TextureBicubicNode, textureBicubic } from './accessors/TextureBicubicNode.js';
|
|
76
|
+
export { default as ModelNode, modelDirection, modelViewMatrix, modelNormalMatrix, modelWorldMatrix, modelPosition, modelViewPosition, modelScale } from './accessors/ModelNode.js';
|
|
75
77
|
export { default as ModelViewProjectionNode, modelViewProjection } from './accessors/ModelViewProjectionNode.js';
|
|
76
|
-
export { default as NormalNode, normalGeometry, normalLocal, normalView, normalWorld, transformedNormalView, transformedNormalWorld } from './accessors/NormalNode.js';
|
|
77
|
-
export { default as Object3DNode, objectDirection, objectViewMatrix, objectNormalMatrix, objectWorldMatrix, objectPosition, objectViewPosition } from './accessors/Object3DNode.js';
|
|
78
|
+
export { default as NormalNode, normalGeometry, normalLocal, normalView, normalWorld, transformedNormalView, transformedNormalWorld, transformedClearcoatNormalView } from './accessors/NormalNode.js';
|
|
79
|
+
export { default as Object3DNode, objectDirection, objectViewMatrix, objectNormalMatrix, objectWorldMatrix, objectPosition, objectScale, objectViewPosition } from './accessors/Object3DNode.js';
|
|
78
80
|
export { default as PointUVNode, pointUV } from './accessors/PointUVNode.js';
|
|
79
81
|
export { default as PositionNode, positionGeometry, positionLocal, positionWorld, positionWorldDirection, positionView, positionViewDirection } from './accessors/PositionNode.js';
|
|
80
82
|
export { default as ReferenceNode, reference } from './accessors/ReferenceNode.js';
|
|
81
83
|
export { default as ReflectVectorNode, reflectVector } from './accessors/ReflectVectorNode.js';
|
|
82
84
|
export { default as SkinningNode, skinning } from './accessors/SkinningNode.js';
|
|
85
|
+
export { default as SceneNode, backgroundBlurriness } from './accessors/SceneNode.js';
|
|
83
86
|
export { default as StorageBufferNode, storage } from './accessors/StorageBufferNode.js';
|
|
84
87
|
export { default as TangentNode, tangentGeometry, tangentLocal, tangentView, tangentWorld, transformedTangentView, transformedTangentWorld } from './accessors/TangentNode.js';
|
|
85
|
-
export { default as TextureNode, texture, sampler } from './accessors/TextureNode.js';
|
|
88
|
+
export { default as TextureNode, texture, /*textureLevel,*/ sampler } from './accessors/TextureNode.js';
|
|
86
89
|
export { default as UVNode, uv } from './accessors/UVNode.js';
|
|
87
90
|
export { default as UserDataNode, userData } from './accessors/UserDataNode.js';
|
|
88
91
|
|
|
89
92
|
// display
|
|
90
93
|
export { default as BlendModeNode, burn, dodge, overlay, screen } from './display/BlendModeNode.js';
|
|
91
94
|
export { default as ColorAdjustmentNode, saturation, vibrance, hue, lumaCoeffs, luminance } from './display/ColorAdjustmentNode.js';
|
|
92
|
-
export { default as ColorSpaceNode,
|
|
95
|
+
export { default as ColorSpaceNode, linearToColorSpace, colorSpaceToLinear, linearTosRGB, sRGBToLinear } from './display/ColorSpaceNode.js';
|
|
93
96
|
export { default as FrontFacingNode, frontFacing, faceDirection } from './display/FrontFacingNode.js';
|
|
94
97
|
export { default as NormalMapNode, normalMap, TBNViewMatrix } from './display/NormalMapNode.js';
|
|
95
98
|
export { default as PosterizeNode, posterize } from './display/PosterizeNode.js';
|
|
96
99
|
export { default as ToneMappingNode, toneMapping } from './display/ToneMappingNode.js';
|
|
97
100
|
export { default as ViewportNode, viewportCoordinate, viewportResolution, viewportTopLeft, viewportBottomLeft, viewportTopRight, viewportBottomRight } from './display/ViewportNode.js';
|
|
98
|
-
export { default as ViewportTextureNode, viewportTexture } from './display/ViewportTextureNode.js';
|
|
101
|
+
export { default as ViewportTextureNode, viewportTexture, viewportMipTexture } from './display/ViewportTextureNode.js';
|
|
99
102
|
export { default as ViewportSharedTextureNode, viewportSharedTexture } from './display/ViewportSharedTextureNode.js';
|
|
103
|
+
export { default as ViewportDepthTextureNode, viewportDepthTexture } from './display/ViewportDepthTextureNode.js';
|
|
104
|
+
export { default as ViewportDepthNode, viewZToOrthographicDepth, orthographicDepthToViewZ, viewZToPerspectiveDepth, perspectiveDepthToViewZ, depth, depthTexture } from './display/ViewportDepthNode.js';
|
|
100
105
|
|
|
101
106
|
// code
|
|
102
107
|
export { default as ExpressionNode, expression } from './code/ExpressionNode.js';
|
|
103
|
-
export { default as CodeNode, code, js } from './code/CodeNode.js';
|
|
108
|
+
export { default as CodeNode, code, js, wgsl, glsl } from './code/CodeNode.js';
|
|
104
109
|
export { default as FunctionCallNode, call } from './code/FunctionCallNode.js';
|
|
105
|
-
export { default as FunctionNode,
|
|
110
|
+
export { default as FunctionNode, wgslFn, glslFn } from './code/FunctionNode.js';
|
|
106
111
|
export { default as ScriptableNode, scriptable, global } from './code/ScriptableNode.js';
|
|
107
112
|
export { default as ScriptableValueNode, scriptableValue } from './code/ScriptableValueNode.js';
|
|
108
113
|
|
|
@@ -17,6 +17,7 @@ class BufferAttributeNode extends InputNode {
|
|
|
17
17
|
this.bufferOffset = bufferOffset;
|
|
18
18
|
|
|
19
19
|
this.usage = StaticDrawUsage;
|
|
20
|
+
this.instanced = false;
|
|
20
21
|
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -34,7 +35,7 @@ class BufferAttributeNode extends InputNode {
|
|
|
34
35
|
buffer.setUsage( this.usage );
|
|
35
36
|
|
|
36
37
|
this.attribute = bufferAttribute;
|
|
37
|
-
this.attribute.isInstancedBufferAttribute =
|
|
38
|
+
this.attribute.isInstancedBufferAttribute = this.instanced; // @TODO: Add a possible: InstancedInterleavedBufferAttribute
|
|
38
39
|
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -69,18 +70,30 @@ class BufferAttributeNode extends InputNode {
|
|
|
69
70
|
|
|
70
71
|
}
|
|
71
72
|
|
|
73
|
+
setUsage( value ) {
|
|
74
|
+
|
|
75
|
+
this.usage = value;
|
|
76
|
+
|
|
77
|
+
return this;
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
setInstanced( value ) {
|
|
82
|
+
|
|
83
|
+
this.instanced = value;
|
|
84
|
+
|
|
85
|
+
return this;
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
72
89
|
}
|
|
73
90
|
|
|
74
91
|
export default BufferAttributeNode;
|
|
75
92
|
|
|
76
93
|
export const bufferAttribute = ( array, type, stride, offset ) => nodeObject( new BufferAttributeNode( array, type, stride, offset ) );
|
|
77
|
-
export const dynamicBufferAttribute = ( array, type, stride, offset ) =>
|
|
78
|
-
|
|
79
|
-
const node = bufferAttribute( array, type, stride, offset );
|
|
80
|
-
node.usage = DynamicDrawUsage;
|
|
81
|
-
|
|
82
|
-
return node;
|
|
94
|
+
export const dynamicBufferAttribute = ( array, type, stride, offset ) => bufferAttribute( array, type, stride, offset ).setUsage( DynamicDrawUsage );
|
|
83
95
|
|
|
84
|
-
|
|
96
|
+
export const instancedBufferAttribute = ( array, type, stride, offset ) => bufferAttribute( array, type, stride, offset ).setInstanced( true );
|
|
97
|
+
export const instancedDynamicBufferAttribute = ( array, type, stride, offset ) => dynamicBufferAttribute( array, type, stride, offset ).setInstanced( true );
|
|
85
98
|
|
|
86
99
|
addNodeClass( BufferAttributeNode );
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Object3DNode from './Object3DNode.js';
|
|
2
2
|
import { addNodeClass } from '../core/Node.js';
|
|
3
|
+
import { label } from '../core/ContextNode.js';
|
|
3
4
|
import { nodeImmutable } from '../shadernode/ShaderNode.js';
|
|
4
5
|
|
|
5
6
|
class CameraNode extends Object3DNode {
|
|
@@ -18,6 +19,10 @@ class CameraNode extends Object3DNode {
|
|
|
18
19
|
|
|
19
20
|
return 'mat4';
|
|
20
21
|
|
|
22
|
+
} else if ( scope === CameraNode.NEAR || scope === CameraNode.FAR ) {
|
|
23
|
+
|
|
24
|
+
return 'float';
|
|
25
|
+
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
return super.getNodeType( builder );
|
|
@@ -30,13 +35,21 @@ class CameraNode extends Object3DNode {
|
|
|
30
35
|
const uniformNode = this._uniformNode;
|
|
31
36
|
const scope = this.scope;
|
|
32
37
|
|
|
33
|
-
if ( scope === CameraNode.
|
|
38
|
+
if ( scope === CameraNode.VIEW_MATRIX ) {
|
|
39
|
+
|
|
40
|
+
uniformNode.value = camera.matrixWorldInverse;
|
|
41
|
+
|
|
42
|
+
} else if ( scope === CameraNode.PROJECTION_MATRIX ) {
|
|
34
43
|
|
|
35
44
|
uniformNode.value = camera.projectionMatrix;
|
|
36
45
|
|
|
37
|
-
} else if ( scope === CameraNode.
|
|
46
|
+
} else if ( scope === CameraNode.NEAR ) {
|
|
38
47
|
|
|
39
|
-
uniformNode.value = camera.
|
|
48
|
+
uniformNode.value = camera.near;
|
|
49
|
+
|
|
50
|
+
} else if ( scope === CameraNode.FAR ) {
|
|
51
|
+
|
|
52
|
+
uniformNode.value = camera.far;
|
|
40
53
|
|
|
41
54
|
} else {
|
|
42
55
|
|
|
@@ -56,6 +69,10 @@ class CameraNode extends Object3DNode {
|
|
|
56
69
|
|
|
57
70
|
this._uniformNode.nodeType = 'mat4';
|
|
58
71
|
|
|
72
|
+
} else if ( scope === CameraNode.NEAR || scope === CameraNode.FAR ) {
|
|
73
|
+
|
|
74
|
+
this._uniformNode.nodeType = 'float';
|
|
75
|
+
|
|
59
76
|
}
|
|
60
77
|
|
|
61
78
|
return super.generate( builder );
|
|
@@ -65,10 +82,14 @@ class CameraNode extends Object3DNode {
|
|
|
65
82
|
}
|
|
66
83
|
|
|
67
84
|
CameraNode.PROJECTION_MATRIX = 'projectionMatrix';
|
|
85
|
+
CameraNode.NEAR = 'near';
|
|
86
|
+
CameraNode.FAR = 'far';
|
|
68
87
|
|
|
69
88
|
export default CameraNode;
|
|
70
89
|
|
|
71
|
-
export const cameraProjectionMatrix = nodeImmutable( CameraNode, CameraNode.PROJECTION_MATRIX );
|
|
90
|
+
export const cameraProjectionMatrix = label( nodeImmutable( CameraNode, CameraNode.PROJECTION_MATRIX ), 'projectionMatrix' );
|
|
91
|
+
export const cameraNear = nodeImmutable( CameraNode, CameraNode.NEAR );
|
|
92
|
+
export const cameraFar = nodeImmutable( CameraNode, CameraNode.FAR );
|
|
72
93
|
export const cameraViewMatrix = nodeImmutable( CameraNode, CameraNode.VIEW_MATRIX );
|
|
73
94
|
export const cameraNormalMatrix = nodeImmutable( CameraNode, CameraNode.NORMAL_MATRIX );
|
|
74
95
|
export const cameraWorldMatrix = nodeImmutable( CameraNode, CameraNode.WORLD_MATRIX );
|
|
@@ -20,7 +20,7 @@ class ExtendedMaterialNode extends MaterialNode {
|
|
|
20
20
|
const scope = this.scope;
|
|
21
21
|
let type = null;
|
|
22
22
|
|
|
23
|
-
if ( scope === ExtendedMaterialNode.NORMAL ) {
|
|
23
|
+
if ( scope === ExtendedMaterialNode.NORMAL || scope === ExtendedMaterialNode.CLEARCOAT_NORMAL ) {
|
|
24
24
|
|
|
25
25
|
type = 'vec3';
|
|
26
26
|
|
|
@@ -41,6 +41,10 @@ class ExtendedMaterialNode extends MaterialNode {
|
|
|
41
41
|
|
|
42
42
|
node = material.normalMap ? normalMap( this.getTexture( 'normalMap' ), materialReference( 'normalScale', 'vec2' ) ) : normalView;
|
|
43
43
|
|
|
44
|
+
} else if ( scope === ExtendedMaterialNode.CLEARCOAT_NORMAL ) {
|
|
45
|
+
|
|
46
|
+
node = material.clearcoatNormalMap ? normalMap( this.getTexture( 'clearcoatNormalMap' ), materialReference( 'clearcoatNormalScale', 'vec2' ) ) : normalView;
|
|
47
|
+
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
return node || super.construct( builder );
|
|
@@ -50,9 +54,11 @@ class ExtendedMaterialNode extends MaterialNode {
|
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
ExtendedMaterialNode.NORMAL = 'normal';
|
|
57
|
+
ExtendedMaterialNode.CLEARCOAT_NORMAL = 'clearcoatNormal';
|
|
53
58
|
|
|
54
59
|
export default ExtendedMaterialNode;
|
|
55
60
|
|
|
56
61
|
export const materialNormal = nodeImmutable( ExtendedMaterialNode, ExtendedMaterialNode.NORMAL );
|
|
62
|
+
export const materialClearcoatNormal = nodeImmutable( ExtendedMaterialNode, ExtendedMaterialNode.CLEARCOAT_NORMAL );
|
|
57
63
|
|
|
58
64
|
addNodeClass( ExtendedMaterialNode );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Node, { addNodeClass } from '../core/Node.js';
|
|
2
|
-
import {
|
|
2
|
+
import { instancedBufferAttribute, instancedDynamicBufferAttribute } from './BufferAttributeNode.js';
|
|
3
3
|
import { normalLocal } from './NormalNode.js';
|
|
4
4
|
import { positionLocal } from './PositionNode.js';
|
|
5
5
|
import { nodeProxy, vec3, mat3, mat4 } from '../shadernode/ShaderNode.js';
|
|
@@ -27,7 +27,7 @@ class InstanceNode extends Node {
|
|
|
27
27
|
const instaceAttribute = instanceMesh.instanceMatrix;
|
|
28
28
|
const array = instaceAttribute.array;
|
|
29
29
|
|
|
30
|
-
const bufferFn = instaceAttribute.usage === DynamicDrawUsage ?
|
|
30
|
+
const bufferFn = instaceAttribute.usage === DynamicDrawUsage ? instancedDynamicBufferAttribute : instancedBufferAttribute;
|
|
31
31
|
|
|
32
32
|
const instanceBuffers = [
|
|
33
33
|
// F.Signature -> bufferAttribute( array, type, stride, offset )
|
|
@@ -60,8 +60,6 @@ class InstanceNode extends Node {
|
|
|
60
60
|
builder.stack.assign( positionLocal, instancePosition );
|
|
61
61
|
builder.stack.assign( normalLocal, instanceNormal );
|
|
62
62
|
|
|
63
|
-
return builder.stack;
|
|
64
|
-
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import Node, { addNodeClass } from '../core/Node.js';
|
|
2
|
-
import { uniform } from '../core/UniformNode.js';
|
|
3
2
|
import { materialReference } from './MaterialReferenceNode.js';
|
|
4
|
-
import {
|
|
5
|
-
import { nodeImmutable, vec3 } from '../shadernode/ShaderNode.js';
|
|
3
|
+
import { nodeImmutable } from '../shadernode/ShaderNode.js';
|
|
6
4
|
|
|
7
5
|
class MaterialNode extends Node {
|
|
8
6
|
|
|
@@ -27,15 +25,11 @@ class MaterialNode extends Node {
|
|
|
27
25
|
|
|
28
26
|
return 'float';
|
|
29
27
|
|
|
30
|
-
} else if ( scope === MaterialNode.
|
|
31
|
-
|
|
32
|
-
return 'vec2';
|
|
33
|
-
|
|
34
|
-
} else if ( scope === MaterialNode.EMISSIVE ) {
|
|
28
|
+
} else if ( scope === MaterialNode.EMISSIVE || scope === MaterialNode.SHEEN ) {
|
|
35
29
|
|
|
36
30
|
return 'vec3';
|
|
37
31
|
|
|
38
|
-
} else if ( scope === MaterialNode.ROUGHNESS || scope === MaterialNode.METALNESS || scope === MaterialNode.SPECULAR || scope === MaterialNode.SHININESS ) {
|
|
32
|
+
} else if ( scope === MaterialNode.ROUGHNESS || scope === MaterialNode.METALNESS || scope === MaterialNode.SPECULAR || scope === MaterialNode.SHININESS || scope === MaterialNode.CLEARCOAT_ROUGHNESS || scope === MaterialNode.SHEEN_ROUGHNESS ) {
|
|
39
33
|
|
|
40
34
|
return 'float';
|
|
41
35
|
|
|
@@ -64,7 +58,6 @@ class MaterialNode extends Node {
|
|
|
64
58
|
//@TODO: Check if it can be cached by property name.
|
|
65
59
|
|
|
66
60
|
const textureRefNode = materialReference( property, 'texture' );
|
|
67
|
-
textureRefNode.node.uvNode = materialUV;
|
|
68
61
|
|
|
69
62
|
return textureRefNode;
|
|
70
63
|
|
|
@@ -173,59 +166,68 @@ class MaterialNode extends Node {
|
|
|
173
166
|
|
|
174
167
|
}
|
|
175
168
|
|
|
176
|
-
} else if ( scope === MaterialNode.
|
|
169
|
+
} else if ( scope === MaterialNode.CLEARCOAT ) {
|
|
177
170
|
|
|
178
|
-
|
|
171
|
+
const clearcoatNode = this.getFloat( 'clearcoat' );
|
|
172
|
+
|
|
173
|
+
if ( material.clearcoatMap && material.clearcoatMap.isTexture === true ) {
|
|
174
|
+
|
|
175
|
+
node = clearcoatNode.mul( this.getTexture( 'clearcoatMap' ).r );
|
|
176
|
+
|
|
177
|
+
} else {
|
|
178
|
+
|
|
179
|
+
node = clearcoatNode;
|
|
180
|
+
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
} else if ( scope === MaterialNode.CLEARCOAT_ROUGHNESS ) {
|
|
184
|
+
|
|
185
|
+
const clearcoatRoughnessNode = this.getFloat( 'clearcoatRoughness' );
|
|
179
186
|
|
|
180
|
-
|
|
187
|
+
if ( material.clearcoatRoughnessMap && material.clearcoatRoughnessMap.isTexture === true ) {
|
|
181
188
|
|
|
182
|
-
|
|
189
|
+
node = clearcoatRoughnessNode.mul( this.getTexture( 'clearcoatRoughnessMap' ).r );
|
|
183
190
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
material.clearcoatNormalMap ||
|
|
196
|
-
material.clearcoatRoughnessMap ||
|
|
197
|
-
material.iridescenceMap ||
|
|
198
|
-
material.iridescenceThicknessMap ||
|
|
199
|
-
material.specularIntensityMap ||
|
|
200
|
-
material.specularColorMap ||
|
|
201
|
-
material.transmissionMap ||
|
|
202
|
-
material.thicknessMap ||
|
|
203
|
-
material.sheenColorMap ||
|
|
204
|
-
material.sheenRoughnessMap;
|
|
191
|
+
} else {
|
|
192
|
+
|
|
193
|
+
node = clearcoatRoughnessNode;
|
|
194
|
+
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
} else if ( scope === MaterialNode.SHEEN ) {
|
|
198
|
+
|
|
199
|
+
const sheenNode = this.getColor( 'sheenColor' ).mul( this.getFloat( 'sheen' ) ); // Move this mul() to CPU
|
|
200
|
+
|
|
201
|
+
if ( material.sheenColorMap && material.sheenColorMap.isTexture === true ) {
|
|
205
202
|
|
|
206
|
-
|
|
203
|
+
node = sheenNode.mul( this.getTexture( 'sheenColorMap' ).rgb );
|
|
207
204
|
|
|
208
|
-
|
|
209
|
-
if ( uvScaleMap.isWebGLRenderTarget ) {
|
|
205
|
+
} else {
|
|
210
206
|
|
|
211
|
-
|
|
207
|
+
node = sheenNode;
|
|
212
208
|
|
|
213
|
-
|
|
209
|
+
}
|
|
214
210
|
|
|
215
|
-
|
|
211
|
+
} else if ( scope === MaterialNode.SHEEN_ROUGHNESS ) {
|
|
216
212
|
|
|
217
|
-
|
|
213
|
+
const sheenRoughnessNode = this.getFloat( 'sheenRoughness' );
|
|
218
214
|
|
|
219
|
-
|
|
215
|
+
if ( material.sheenRoughnessMap && material.sheenRoughnessMap.isTexture === true ) {
|
|
220
216
|
|
|
221
|
-
node =
|
|
217
|
+
node = sheenRoughnessNode.mul( this.getTexture( 'sheenRoughnessMap' ).a );
|
|
222
218
|
|
|
223
219
|
} else {
|
|
224
220
|
|
|
225
|
-
node =
|
|
221
|
+
node = sheenRoughnessNode;
|
|
226
222
|
|
|
227
223
|
}
|
|
228
224
|
|
|
225
|
+
node = node.clamp( 0.07, 1.0 );
|
|
226
|
+
|
|
227
|
+
} else if ( scope === MaterialNode.ROTATION ) {
|
|
228
|
+
|
|
229
|
+
node = this.getFloat( 'rotation' );
|
|
230
|
+
|
|
229
231
|
} else {
|
|
230
232
|
|
|
231
233
|
const outputType = this.getNodeType( builder );
|
|
@@ -248,13 +250,15 @@ MaterialNode.SPECULAR_COLOR = 'specularColor';
|
|
|
248
250
|
MaterialNode.REFLECTIVITY = 'reflectivity';
|
|
249
251
|
MaterialNode.ROUGHNESS = 'roughness';
|
|
250
252
|
MaterialNode.METALNESS = 'metalness';
|
|
253
|
+
MaterialNode.CLEARCOAT = 'clearcoat';
|
|
254
|
+
MaterialNode.CLEARCOAT_ROUGHNESS = 'clearcoatRoughness';
|
|
251
255
|
MaterialNode.EMISSIVE = 'emissive';
|
|
252
256
|
MaterialNode.ROTATION = 'rotation';
|
|
253
|
-
MaterialNode.
|
|
257
|
+
MaterialNode.SHEEN = 'sheen';
|
|
258
|
+
MaterialNode.SHEEN_ROUGHNESS = 'sheenRoughness';
|
|
254
259
|
|
|
255
260
|
export default MaterialNode;
|
|
256
261
|
|
|
257
|
-
export const materialUV = nodeImmutable( MaterialNode, MaterialNode.UV );
|
|
258
262
|
export const materialAlphaTest = nodeImmutable( MaterialNode, MaterialNode.ALPHA_TEST );
|
|
259
263
|
export const materialColor = nodeImmutable( MaterialNode, MaterialNode.COLOR );
|
|
260
264
|
export const materialShininess = nodeImmutable( MaterialNode, MaterialNode.SHININESS );
|
|
@@ -264,6 +268,10 @@ export const materialSpecularColor = nodeImmutable( MaterialNode, MaterialNode.S
|
|
|
264
268
|
export const materialReflectivity = nodeImmutable( MaterialNode, MaterialNode.REFLECTIVITY );
|
|
265
269
|
export const materialRoughness = nodeImmutable( MaterialNode, MaterialNode.ROUGHNESS );
|
|
266
270
|
export const materialMetalness = nodeImmutable( MaterialNode, MaterialNode.METALNESS );
|
|
271
|
+
export const materialClearcoat = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT );
|
|
272
|
+
export const materialClearcoatRoughness = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_ROUGHNESS );
|
|
267
273
|
export const materialRotation = nodeImmutable( MaterialNode, MaterialNode.ROTATION );
|
|
274
|
+
export const materialSheen = nodeImmutable( MaterialNode, MaterialNode.SHEEN );
|
|
275
|
+
export const materialSheenRoughness = nodeImmutable( MaterialNode, MaterialNode.SHEEN_ROUGHNESS );
|
|
268
276
|
|
|
269
277
|
addNodeClass( MaterialNode );
|