super-three 0.157.1 → 0.158.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/README.md +6 -4
- package/build/three.cjs +1013 -790
- package/build/three.js +1013 -790
- package/build/three.min.js +1 -1
- package/build/three.module.js +1008 -791
- package/build/three.module.min.js +1 -1
- package/examples/jsm/Addons.js +290 -0
- package/examples/jsm/controls/FlyControls.js +26 -0
- package/examples/jsm/controls/OrbitControls.js +12 -1
- package/examples/jsm/controls/TransformControls.js +27 -11
- package/examples/jsm/csm/CSMShader.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +72 -2
- package/examples/jsm/geometries/InstancedPointsGeometry.js +174 -0
- package/examples/jsm/geometries/SDFGeometryGenerator.js +144 -0
- package/examples/jsm/libs/lottie_canvas.module.js +6 -1
- package/examples/jsm/libs/opentype.module.js +13 -75
- package/examples/jsm/libs/surfaceNet.js +201 -0
- package/examples/jsm/loaders/GLTFLoader.js +12 -3
- package/examples/jsm/loaders/LUTImageLoader.js +162 -0
- package/examples/jsm/loaders/lwo/IFFParser.js +89 -93
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -0
- package/examples/jsm/math/Capsule.js +0 -55
- package/examples/jsm/math/Octree.js +70 -3
- package/examples/jsm/modifiers/SimplifyModifier.js +103 -11
- package/examples/jsm/modifiers/TessellateModifier.js +3 -3
- package/examples/jsm/nodes/Nodes.js +6 -6
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +3 -3
- package/examples/jsm/nodes/accessors/InstanceNode.js +3 -3
- package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +21 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +68 -31
- package/examples/jsm/nodes/accessors/ModelNode.js +1 -2
- package/examples/jsm/nodes/accessors/MorphNode.js +5 -5
- package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
- package/examples/jsm/nodes/accessors/SkinningNode.js +13 -3
- package/examples/jsm/nodes/accessors/TextureNode.js +3 -3
- package/examples/jsm/nodes/code/FunctionNode.js +1 -1
- package/examples/jsm/nodes/core/AssignNode.js +72 -0
- package/examples/jsm/nodes/core/LightingModel.js +3 -1
- package/examples/jsm/nodes/core/Node.js +7 -12
- package/examples/jsm/nodes/core/NodeBuilder.js +126 -16
- package/examples/jsm/nodes/core/NodeUtils.js +4 -2
- package/examples/jsm/nodes/core/OutputStructNode.js +1 -1
- package/examples/jsm/nodes/core/ParameterNode.js +33 -0
- package/examples/jsm/nodes/core/PropertyNode.js +4 -10
- package/examples/jsm/nodes/core/StackNode.js +7 -17
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/core/VarNode.js +6 -35
- package/examples/jsm/nodes/core/VaryingNode.js +2 -0
- package/examples/jsm/nodes/display/BumpMapNode.js +35 -13
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -1
- package/examples/jsm/nodes/display/ViewportNode.js +14 -4
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +20 -6
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +8 -7
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +8 -3
- package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +8 -0
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +8 -0
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +93 -43
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +2 -2
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +19 -5
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +0 -6
- package/examples/jsm/nodes/lighting/LightingContextNode.js +21 -57
- package/examples/jsm/nodes/lighting/LightsNode.js +62 -4
- package/examples/jsm/nodes/lighting/PointLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/SpotLightNode.js +1 -1
- package/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +162 -0
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +70 -71
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +5 -5
- package/examples/jsm/nodes/materials/Materials.js +1 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +47 -20
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +6 -6
- package/examples/jsm/nodes/materials/NodeMaterial.js +17 -20
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +5 -5
- package/examples/jsm/nodes/math/OperatorNode.js +5 -21
- package/examples/jsm/nodes/shadernode/ShaderNode.js +128 -9
- package/examples/jsm/nodes/utils/ArrayElementNode.js +2 -0
- package/examples/jsm/nodes/utils/DiscardNode.js +3 -2
- package/examples/jsm/nodes/utils/JoinNode.js +11 -1
- package/examples/jsm/nodes/utils/LoopNode.js +36 -24
- package/examples/jsm/nodes/utils/SplitNode.js +2 -0
- package/examples/jsm/objects/BatchedMesh.js +586 -0
- package/examples/jsm/objects/InstancedPoints.js +21 -0
- package/examples/jsm/objects/Lensflare.js +20 -0
- package/examples/jsm/objects/ReflectorForSSRPass.js +3 -0
- package/examples/jsm/objects/Refractor.js +3 -0
- package/examples/jsm/objects/Sky.js +5 -3
- package/examples/jsm/objects/Water.js +5 -2
- package/examples/jsm/objects/Water2.js +3 -0
- package/examples/jsm/physics/AmmoPhysics.js +21 -0
- package/examples/jsm/physics/RapierPhysics.js +21 -0
- package/examples/jsm/postprocessing/BokehPass.js +3 -2
- package/examples/jsm/postprocessing/LUTPass.js +2 -1
- package/examples/jsm/postprocessing/OutputPass.js +1 -0
- package/examples/jsm/postprocessing/Pass.js +14 -3
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SMAAPass.js +0 -2
- package/examples/jsm/postprocessing/TAARenderPass.js +1 -2
- package/examples/jsm/renderers/CSS3DRenderer.js +3 -9
- package/examples/jsm/renderers/SVGRenderer.js +9 -6
- package/examples/jsm/renderers/common/Bindings.js +1 -1
- package/examples/jsm/renderers/common/RenderObject.js +8 -1
- package/examples/jsm/renderers/common/RenderObjects.js +1 -1
- package/examples/jsm/renderers/common/Textures.js +4 -36
- package/examples/jsm/renderers/common/nodes/Nodes.js +53 -18
- package/examples/jsm/renderers/webgl/WebGLBackend.js +291 -50
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +88 -12
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +40 -5
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +14 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +2 -0
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +36 -4
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +2 -0
- package/examples/jsm/shaders/AfterimageShader.js +2 -0
- package/examples/jsm/shaders/BasicShader.js +2 -0
- package/examples/jsm/shaders/BlendShader.js +2 -0
- package/examples/jsm/shaders/BokehShader.js +2 -0
- package/examples/jsm/shaders/BokehShader2.js +4 -0
- package/examples/jsm/shaders/BrightnessContrastShader.js +2 -0
- package/examples/jsm/shaders/ColorCorrectionShader.js +2 -0
- package/examples/jsm/shaders/DOFMipMapShader.js +2 -0
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +5 -0
- package/examples/jsm/shaders/FXAAShader.js +2 -0
- package/examples/jsm/shaders/FilmShader.js +1 -1
- package/examples/jsm/shaders/FocusShader.js +2 -0
- package/examples/jsm/shaders/FreiChenShader.js +2 -0
- package/examples/jsm/shaders/GodRaysShader.js +8 -0
- package/examples/jsm/shaders/HalftoneShader.js +2 -0
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +2 -0
- package/examples/jsm/shaders/HueSaturationShader.js +2 -0
- package/examples/jsm/shaders/KaleidoShader.js +2 -0
- package/examples/jsm/shaders/LuminosityHighPassShader.js +2 -0
- package/examples/jsm/shaders/LuminosityShader.js +2 -0
- package/examples/jsm/shaders/MMDToonShader.js +2 -0
- package/examples/jsm/shaders/MirrorShader.js +2 -0
- package/examples/jsm/shaders/NormalMapShader.js +2 -0
- package/examples/jsm/shaders/OutputShader.js +4 -5
- package/examples/jsm/shaders/SAOShader.js +5 -0
- package/examples/jsm/shaders/SMAAShader.js +6 -0
- package/examples/jsm/shaders/SSAOShader.js +6 -0
- package/examples/jsm/shaders/SSRShader.js +6 -0
- package/examples/jsm/shaders/SobelOperatorShader.js +2 -0
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +2 -0
- package/examples/jsm/shaders/TechnicolorShader.js +2 -0
- package/examples/jsm/shaders/TriangleBlurShader.js +2 -0
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -0
- package/examples/jsm/shaders/VelocityShader.js +2 -0
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +2 -0
- package/examples/jsm/shaders/WaterRefractionShader.js +2 -0
- package/examples/jsm/transpiler/AST.js +231 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +899 -0
- package/examples/jsm/transpiler/ShaderToyDecoder.js +49 -0
- package/examples/jsm/transpiler/TSLEncoder.js +611 -0
- package/examples/jsm/transpiler/Transpiler.js +18 -0
- package/examples/jsm/webxr/VRButton.js +1 -1
- package/examples/jsm/webxr/XRButton.js +7 -5
- package/examples/jsm/webxr/XREstimatedLight.js +1 -1
- package/package.json +4 -1
- package/src/constants.js +7 -1
- package/src/extras/PMREMGenerator.js +7 -1
- package/src/loaders/MaterialLoader.js +10 -2
- package/src/materials/Material.js +27 -13
- package/src/math/Box3.js +35 -18
- package/src/math/Vector3.js +11 -12
- package/src/objects/SkinnedMesh.js +6 -7
- package/src/renderers/WebGLRenderer.js +142 -25
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +3 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +8 -6
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +2 -2
- package/src/renderers/webgl/WebGLProgram.js +80 -50
- package/src/renderers/webgl/WebGLPrograms.js +3 -0
- package/src/renderers/webgl/WebGLState.js +25 -4
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +0 -76
- package/examples/jsm/nodes/accessors/LineMaterialNode.js +0 -29
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BufferGeometry,
|
|
3
3
|
Float32BufferAttribute,
|
|
4
|
-
|
|
4
|
+
Vector2,
|
|
5
|
+
Vector3,
|
|
6
|
+
Vector4
|
|
5
7
|
} from 'three';
|
|
6
8
|
import * as BufferGeometryUtils from '../utils/BufferGeometryUtils.js';
|
|
7
9
|
|
|
@@ -20,13 +22,17 @@ class SimplifyModifier {
|
|
|
20
22
|
modify( geometry, count ) {
|
|
21
23
|
|
|
22
24
|
geometry = geometry.clone();
|
|
25
|
+
|
|
26
|
+
// currently morphAttributes are not supported
|
|
27
|
+
delete geometry.morphAttributes.position;
|
|
28
|
+
delete geometry.morphAttributes.normal;
|
|
23
29
|
const attributes = geometry.attributes;
|
|
24
30
|
|
|
25
|
-
// this modifier can only process indexed and non-indexed geomtries with a position attribute
|
|
31
|
+
// this modifier can only process indexed and non-indexed geomtries with at least a position attribute
|
|
26
32
|
|
|
27
33
|
for ( const name in attributes ) {
|
|
28
34
|
|
|
29
|
-
if ( name !== 'position' ) geometry.deleteAttribute( name );
|
|
35
|
+
if ( name !== 'position' && name !== 'uv' && name !== 'normal' && name !== 'tangent' && name !== 'color' ) geometry.deleteAttribute( name );
|
|
30
36
|
|
|
31
37
|
}
|
|
32
38
|
|
|
@@ -42,12 +48,44 @@ class SimplifyModifier {
|
|
|
42
48
|
// add vertices
|
|
43
49
|
|
|
44
50
|
const positionAttribute = geometry.getAttribute( 'position' );
|
|
51
|
+
const uvAttribute = geometry.getAttribute( 'uv' );
|
|
52
|
+
const normalAttribute = geometry.getAttribute( 'normal' );
|
|
53
|
+
const tangentAttribute = geometry.getAttribute( 'tangent' );
|
|
54
|
+
const colorAttribute = geometry.getAttribute( 'color' );
|
|
55
|
+
|
|
56
|
+
let t = null;
|
|
57
|
+
let v2 = null;
|
|
58
|
+
let nor = null;
|
|
59
|
+
let col = null;
|
|
45
60
|
|
|
46
61
|
for ( let i = 0; i < positionAttribute.count; i ++ ) {
|
|
47
62
|
|
|
48
63
|
const v = new Vector3().fromBufferAttribute( positionAttribute, i );
|
|
64
|
+
if ( uvAttribute ) {
|
|
65
|
+
|
|
66
|
+
v2 = new Vector2().fromBufferAttribute( uvAttribute, i );
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if ( normalAttribute ) {
|
|
71
|
+
|
|
72
|
+
nor = new Vector3().fromBufferAttribute( normalAttribute, i );
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if ( tangentAttribute ) {
|
|
77
|
+
|
|
78
|
+
t = new Vector4().fromBufferAttribute( tangentAttribute, i );
|
|
79
|
+
|
|
80
|
+
}
|
|
49
81
|
|
|
50
|
-
|
|
82
|
+
if ( colorAttribute ) {
|
|
83
|
+
|
|
84
|
+
col = new THREE.Color().fromBufferAttribute( colorAttribute, i );
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const vertex = new Vertex( v, v2, nor, t, col );
|
|
51
89
|
vertices.push( vertex );
|
|
52
90
|
|
|
53
91
|
}
|
|
@@ -115,6 +153,10 @@ class SimplifyModifier {
|
|
|
115
153
|
|
|
116
154
|
const simplifiedGeometry = new BufferGeometry();
|
|
117
155
|
const position = [];
|
|
156
|
+
const uv = [];
|
|
157
|
+
const normal = [];
|
|
158
|
+
const tangent = [];
|
|
159
|
+
const color = [];
|
|
118
160
|
|
|
119
161
|
index = [];
|
|
120
162
|
|
|
@@ -122,10 +164,35 @@ class SimplifyModifier {
|
|
|
122
164
|
|
|
123
165
|
for ( let i = 0; i < vertices.length; i ++ ) {
|
|
124
166
|
|
|
125
|
-
const vertex = vertices[ i ]
|
|
126
|
-
position.push( vertex.x, vertex.y, vertex.z );
|
|
167
|
+
const vertex = vertices[ i ];
|
|
168
|
+
position.push( vertex.position.x, vertex.position.y, vertex.position.z );
|
|
169
|
+
if ( vertex.uv ) {
|
|
170
|
+
|
|
171
|
+
uv.push( vertex.uv.x, vertex.uv.y );
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if ( vertex.normal ) {
|
|
176
|
+
|
|
177
|
+
normal.push( vertex.normal.x, vertex.normal.y, vertex.normal.z );
|
|
178
|
+
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if ( vertex.tangent ) {
|
|
182
|
+
|
|
183
|
+
tangent.push( vertex.tangent.x, vertex.tangent.y, vertex.tangent.z, vertex.tangent.w );
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if ( vertex.color ) {
|
|
188
|
+
|
|
189
|
+
color.push( vertex.color.r, vertex.color.g, vertex.color.b );
|
|
190
|
+
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
|
|
127
194
|
// cache final index to GREATLY speed up faces reconstruction
|
|
128
|
-
|
|
195
|
+
vertex.id = i;
|
|
129
196
|
|
|
130
197
|
}
|
|
131
198
|
|
|
@@ -138,9 +205,12 @@ class SimplifyModifier {
|
|
|
138
205
|
|
|
139
206
|
}
|
|
140
207
|
|
|
141
|
-
//
|
|
142
|
-
|
|
143
208
|
simplifiedGeometry.setAttribute( 'position', new Float32BufferAttribute( position, 3 ) );
|
|
209
|
+
if ( uv.length > 0 ) simplifiedGeometry.setAttribute( 'uv', new Float32BufferAttribute( uv, 2 ) );
|
|
210
|
+
if ( normal.length > 0 ) simplifiedGeometry.setAttribute( 'normal', new Float32BufferAttribute( normal, 3 ) );
|
|
211
|
+
if ( tangent.length > 0 ) simplifiedGeometry.setAttribute( 'tangent', new Float32BufferAttribute( tangent, 4 ) );
|
|
212
|
+
if ( color.length > 0 ) simplifiedGeometry.setAttribute( 'color', new Float32BufferAttribute( color, 3 ) );
|
|
213
|
+
|
|
144
214
|
simplifiedGeometry.setIndex( index );
|
|
145
215
|
|
|
146
216
|
return simplifiedGeometry;
|
|
@@ -318,7 +388,7 @@ function removeFace( f, faces ) {
|
|
|
318
388
|
|
|
319
389
|
}
|
|
320
390
|
|
|
321
|
-
function collapse( vertices, faces, u, v ) {
|
|
391
|
+
function collapse( vertices, faces, u, v ) {
|
|
322
392
|
|
|
323
393
|
// Collapse the edge uv by moving vertex u onto v
|
|
324
394
|
|
|
@@ -330,6 +400,24 @@ function collapse( vertices, faces, u, v ) { // u and v are pointers to vertices
|
|
|
330
400
|
|
|
331
401
|
}
|
|
332
402
|
|
|
403
|
+
if ( v.uv ) {
|
|
404
|
+
|
|
405
|
+
u.uv.copy( v.uv );
|
|
406
|
+
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
if ( v.normal ) {
|
|
410
|
+
|
|
411
|
+
v.normal.add( u.normal ).normalize();
|
|
412
|
+
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
if ( v.tangent ) {
|
|
416
|
+
|
|
417
|
+
v.tangent.add( u.tangent ).normalize();
|
|
418
|
+
|
|
419
|
+
}
|
|
420
|
+
|
|
333
421
|
const tmpVertices = [];
|
|
334
422
|
|
|
335
423
|
for ( let i = 0; i < u.neighbors.length; i ++ ) {
|
|
@@ -480,9 +568,13 @@ class Triangle {
|
|
|
480
568
|
|
|
481
569
|
class Vertex {
|
|
482
570
|
|
|
483
|
-
constructor( v ) {
|
|
571
|
+
constructor( v, uv, normal, tangent, color ) {
|
|
484
572
|
|
|
485
573
|
this.position = v;
|
|
574
|
+
this.uv = uv;
|
|
575
|
+
this.normal = normal;
|
|
576
|
+
this.tangent = tangent;
|
|
577
|
+
this.color = color;
|
|
486
578
|
|
|
487
579
|
this.id = - 1; // external use position in vertices list (for e.g. face generation)
|
|
488
580
|
|
|
@@ -111,9 +111,9 @@ class TessellateModifier {
|
|
|
111
111
|
const c2 = cs[ b ];
|
|
112
112
|
const c3 = cs[ c ];
|
|
113
113
|
|
|
114
|
-
colors2.push( c1.
|
|
115
|
-
colors2.push( c2.
|
|
116
|
-
colors2.push( c3.
|
|
114
|
+
colors2.push( c1.r, c1.g, c1.b );
|
|
115
|
+
colors2.push( c2.r, c2.g, c2.b );
|
|
116
|
+
colors2.push( c3.r, c3.g, c3.b );
|
|
117
117
|
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -6,6 +6,7 @@ export * from './core/constants.js';
|
|
|
6
6
|
|
|
7
7
|
// core
|
|
8
8
|
export { default as ArrayUniformNode /* @TODO: arrayUniform */ } from './core/ArrayUniformNode.js';
|
|
9
|
+
export { default as AssignNode, assign } from './core/AssignNode.js';
|
|
9
10
|
export { default as AttributeNode, attribute } from './core/AttributeNode.js';
|
|
10
11
|
export { default as BypassNode, bypass } from './core/BypassNode.js';
|
|
11
12
|
export { default as CacheNode, cache } from './core/CacheNode.js';
|
|
@@ -14,6 +15,7 @@ export { default as ContextNode, context, label } from './core/ContextNode.js';
|
|
|
14
15
|
export { default as IndexNode, vertexIndex, instanceIndex } from './core/IndexNode.js';
|
|
15
16
|
export { default as LightingModel } from './core/LightingModel.js';
|
|
16
17
|
export { default as Node, addNodeClass, createNodeFromType } from './core/Node.js';
|
|
18
|
+
export { default as VarNode, temp } from './core/VarNode.js';
|
|
17
19
|
export { default as NodeAttribute } from './core/NodeAttribute.js';
|
|
18
20
|
export { default as NodeBuilder } from './core/NodeBuilder.js';
|
|
19
21
|
export { default as NodeCache } from './core/NodeCache.js';
|
|
@@ -24,11 +26,11 @@ export { default as NodeKeywords } from './core/NodeKeywords.js';
|
|
|
24
26
|
export { default as NodeUniform } from './core/NodeUniform.js';
|
|
25
27
|
export { default as NodeVar } from './core/NodeVar.js';
|
|
26
28
|
export { default as NodeVarying } from './core/NodeVarying.js';
|
|
27
|
-
export { default as
|
|
29
|
+
export { default as ParameterNode, parameter } from './core/ParameterNode.js';
|
|
30
|
+
export { default as PropertyNode, property, output, diffuseColor, roughness, metalness, clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness, specularColor, shininess, dashSize, gapSize, pointWidth } from './core/PropertyNode.js';
|
|
28
31
|
export { default as StackNode, stack } from './core/StackNode.js';
|
|
29
32
|
export { default as TempNode } from './core/TempNode.js';
|
|
30
33
|
export { default as UniformNode, uniform } from './core/UniformNode.js';
|
|
31
|
-
export { default as VarNode, temp } from './core/VarNode.js';
|
|
32
34
|
export { default as VaryingNode, varying } from './core/VaryingNode.js';
|
|
33
35
|
export { default as OutputStructNode, outputStruct } from './core/OutputStructNode.js';
|
|
34
36
|
|
|
@@ -37,7 +39,7 @@ export { NodeUtils };
|
|
|
37
39
|
|
|
38
40
|
// math
|
|
39
41
|
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';
|
|
40
|
-
export { default as OperatorNode, add, sub, mul, div, remainder, equal,
|
|
42
|
+
export { default as OperatorNode, add, sub, mul, div, remainder, equal, lessThan, greaterThan, lessThanEqual, greaterThanEqual, and, or, xor, bitAnd, bitOr, bitXor, shiftLeft, shiftRight } from './math/OperatorNode.js';
|
|
41
43
|
export { default as CondNode, cond } from './math/CondNode.js';
|
|
42
44
|
export { default as HashNode, hash } from './math/HashNode.js';
|
|
43
45
|
|
|
@@ -70,10 +72,8 @@ export { default as BufferAttributeNode, bufferAttribute, dynamicBufferAttribute
|
|
|
70
72
|
export { default as BufferNode, buffer } from './accessors/BufferNode.js';
|
|
71
73
|
export { default as CameraNode, cameraProjectionMatrix, cameraViewMatrix, cameraNormalMatrix, cameraWorldMatrix, cameraPosition, cameraNear, cameraFar } from './accessors/CameraNode.js';
|
|
72
74
|
export { default as CubeTextureNode, cubeTexture } from './accessors/CubeTextureNode.js';
|
|
73
|
-
export { default as ExtendedMaterialNode, materialNormal } from './accessors/ExtendedMaterialNode.js';
|
|
74
75
|
export { default as InstanceNode, instance } from './accessors/InstanceNode.js';
|
|
75
|
-
export { default as
|
|
76
|
-
export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecularColor, materialReflectivity, materialRoughness, materialMetalness, materialRotation, materialSheen, materialSheenRoughness } from './accessors/MaterialNode.js';
|
|
76
|
+
export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecularColor, materialSpecularStrength, materialReflectivity, materialRoughness, materialMetalness, materialNormal, materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialRotation, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineWidth, materialLineDashOffset, materialPointWidth } from './accessors/MaterialNode.js';
|
|
77
77
|
export { default as MaterialReferenceNode, materialReference } from './accessors/MaterialReferenceNode.js';
|
|
78
78
|
export { default as MorphNode, morph } from './accessors/MorphNode.js';
|
|
79
79
|
export { default as TextureBicubicNode, textureBicubic } from './accessors/TextureBicubicNode.js';
|
|
@@ -54,7 +54,6 @@ class CubeTextureNode extends TextureNode {
|
|
|
54
54
|
|
|
55
55
|
} else {
|
|
56
56
|
|
|
57
|
-
const nodeType = this.getNodeType( builder );
|
|
58
57
|
const nodeData = builder.getDataFromNode( this );
|
|
59
58
|
|
|
60
59
|
let propertyName = nodeData.propertyName;
|
|
@@ -64,7 +63,7 @@ class CubeTextureNode extends TextureNode {
|
|
|
64
63
|
const cubeUV = vec3( uvNode.x.negate(), uvNode.yz );
|
|
65
64
|
const uvSnippet = cubeUV.build( builder, 'vec3' );
|
|
66
65
|
|
|
67
|
-
const nodeVar = builder.getVarFromNode( this
|
|
66
|
+
const nodeVar = builder.getVarFromNode( this );
|
|
68
67
|
|
|
69
68
|
propertyName = builder.getPropertyName( nodeVar );
|
|
70
69
|
|
|
@@ -94,6 +93,7 @@ class CubeTextureNode extends TextureNode {
|
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
let snippet = propertyName;
|
|
96
|
+
const nodeType = this.getNodeType( builder );
|
|
97
97
|
|
|
98
98
|
if ( builder.needsColorSpaceToLinear( this.value ) ) {
|
|
99
99
|
|
|
@@ -101,7 +101,7 @@ class CubeTextureNode extends TextureNode {
|
|
|
101
101
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
return builder.format( snippet,
|
|
104
|
+
return builder.format( snippet, nodeType, output );
|
|
105
105
|
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -17,7 +17,7 @@ class InstanceNode extends Node {
|
|
|
17
17
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
setup( builder ) {
|
|
20
|
+
setup( /*builder*/ ) {
|
|
21
21
|
|
|
22
22
|
let instanceMatrixNode = this.instanceMatrixNode;
|
|
23
23
|
|
|
@@ -57,8 +57,8 @@ class InstanceNode extends Node {
|
|
|
57
57
|
|
|
58
58
|
// ASSIGNS
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
positionLocal.assign( instancePosition );
|
|
61
|
+
normalLocal.assign( instanceNormal );
|
|
62
62
|
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import MaterialNode from './MaterialNode.js';
|
|
2
|
+
import { addNodeClass } from '../core/Node.js';
|
|
3
|
+
import { nodeImmutable } from '../shadernode/ShaderNode.js';
|
|
4
|
+
|
|
5
|
+
class InstancedPointsMaterialNode extends MaterialNode {
|
|
6
|
+
|
|
7
|
+
setup( /*builder*/ ) {
|
|
8
|
+
|
|
9
|
+
return this.getFloat( this.scope );
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
InstancedPointsMaterialNode.POINT_WIDTH = 'pointWidth';
|
|
16
|
+
|
|
17
|
+
export default InstancedPointsMaterialNode;
|
|
18
|
+
|
|
19
|
+
export const materialPointWidth = nodeImmutable( InstancedPointsMaterialNode, InstancedPointsMaterialNode.POINT_WIDTH );
|
|
20
|
+
|
|
21
|
+
addNodeClass( 'InstancedPointsMaterialNode', InstancedPointsMaterialNode );
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Node, { addNodeClass } from '../core/Node.js';
|
|
2
2
|
import { reference } from './ReferenceNode.js';
|
|
3
3
|
import { materialReference } from './MaterialReferenceNode.js';
|
|
4
|
+
import { normalView } from './NormalNode.js';
|
|
4
5
|
import { nodeImmutable, float } from '../shadernode/ShaderNode.js';
|
|
5
6
|
|
|
6
7
|
const _propertyCache = new Map();
|
|
@@ -45,7 +46,7 @@ class MaterialNode extends Node {
|
|
|
45
46
|
|
|
46
47
|
getTexture( property ) {
|
|
47
48
|
|
|
48
|
-
return this.getCache( property, 'texture' );
|
|
49
|
+
return this.getCache( property === 'map' ? 'map' : property + 'Map', 'texture' );
|
|
49
50
|
|
|
50
51
|
}
|
|
51
52
|
|
|
@@ -56,17 +57,9 @@ class MaterialNode extends Node {
|
|
|
56
57
|
|
|
57
58
|
let node = null;
|
|
58
59
|
|
|
59
|
-
if ( scope === MaterialNode.
|
|
60
|
+
if ( scope === MaterialNode.COLOR ) {
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
} else if ( scope === MaterialNode.SPECULAR_COLOR ) {
|
|
64
|
-
|
|
65
|
-
node = this.getColor( 'specular' );
|
|
66
|
-
|
|
67
|
-
} else if ( scope === MaterialNode.COLOR ) {
|
|
68
|
-
|
|
69
|
-
const colorNode = this.getColor( 'color' );
|
|
62
|
+
const colorNode = this.getColor( scope );
|
|
70
63
|
|
|
71
64
|
if ( material.map && material.map.isTexture === true ) {
|
|
72
65
|
|
|
@@ -80,11 +73,11 @@ class MaterialNode extends Node {
|
|
|
80
73
|
|
|
81
74
|
} else if ( scope === MaterialNode.OPACITY ) {
|
|
82
75
|
|
|
83
|
-
const opacityNode = this.getFloat(
|
|
76
|
+
const opacityNode = this.getFloat( scope );
|
|
84
77
|
|
|
85
78
|
if ( material.alphaMap && material.alphaMap.isTexture === true ) {
|
|
86
79
|
|
|
87
|
-
node = opacityNode.mul( this.getTexture( '
|
|
80
|
+
node = opacityNode.mul( this.getTexture( 'alpha' ) );
|
|
88
81
|
|
|
89
82
|
} else {
|
|
90
83
|
|
|
@@ -96,7 +89,7 @@ class MaterialNode extends Node {
|
|
|
96
89
|
|
|
97
90
|
if ( material.specularMap && material.specularMap.isTexture === true ) {
|
|
98
91
|
|
|
99
|
-
node = this.getTexture(
|
|
92
|
+
node = this.getTexture( scope ).r;
|
|
100
93
|
|
|
101
94
|
} else {
|
|
102
95
|
|
|
@@ -104,13 +97,13 @@ class MaterialNode extends Node {
|
|
|
104
97
|
|
|
105
98
|
}
|
|
106
99
|
|
|
107
|
-
} else if ( scope === MaterialNode.ROUGHNESS ) {
|
|
100
|
+
} else if ( scope === MaterialNode.ROUGHNESS ) { // TODO: cleanup similar branches
|
|
108
101
|
|
|
109
|
-
const roughnessNode = this.getFloat(
|
|
102
|
+
const roughnessNode = this.getFloat( scope );
|
|
110
103
|
|
|
111
104
|
if ( material.roughnessMap && material.roughnessMap.isTexture === true ) {
|
|
112
105
|
|
|
113
|
-
node = roughnessNode.mul( this.getTexture(
|
|
106
|
+
node = roughnessNode.mul( this.getTexture( scope ).g );
|
|
114
107
|
|
|
115
108
|
} else {
|
|
116
109
|
|
|
@@ -120,11 +113,11 @@ class MaterialNode extends Node {
|
|
|
120
113
|
|
|
121
114
|
} else if ( scope === MaterialNode.METALNESS ) {
|
|
122
115
|
|
|
123
|
-
const metalnessNode = this.getFloat(
|
|
116
|
+
const metalnessNode = this.getFloat( scope );
|
|
124
117
|
|
|
125
118
|
if ( material.metalnessMap && material.metalnessMap.isTexture === true ) {
|
|
126
119
|
|
|
127
|
-
node = metalnessNode.mul( this.getTexture(
|
|
120
|
+
node = metalnessNode.mul( this.getTexture( scope ).b );
|
|
128
121
|
|
|
129
122
|
} else {
|
|
130
123
|
|
|
@@ -134,11 +127,11 @@ class MaterialNode extends Node {
|
|
|
134
127
|
|
|
135
128
|
} else if ( scope === MaterialNode.EMISSIVE ) {
|
|
136
129
|
|
|
137
|
-
const emissiveNode = this.getColor(
|
|
130
|
+
const emissiveNode = this.getColor( scope );
|
|
138
131
|
|
|
139
132
|
if ( material.emissiveMap && material.emissiveMap.isTexture === true ) {
|
|
140
133
|
|
|
141
|
-
node = emissiveNode.mul( this.getTexture(
|
|
134
|
+
node = emissiveNode.mul( this.getTexture( scope ) );
|
|
142
135
|
|
|
143
136
|
} else {
|
|
144
137
|
|
|
@@ -146,13 +139,29 @@ class MaterialNode extends Node {
|
|
|
146
139
|
|
|
147
140
|
}
|
|
148
141
|
|
|
142
|
+
} else if ( scope === MaterialNode.NORMAL ) {
|
|
143
|
+
|
|
144
|
+
if ( material.normalMap ) {
|
|
145
|
+
|
|
146
|
+
node = this.getTexture( 'normal' ).normalMap( this.getCache( 'normalScale', 'vec2' ) );
|
|
147
|
+
|
|
148
|
+
} else if ( material.bumpMap ) {
|
|
149
|
+
|
|
150
|
+
node = this.getTexture( 'bump' ).r.bumpMap( this.getFloat( 'bumpScale' ) );
|
|
151
|
+
|
|
152
|
+
} else {
|
|
153
|
+
|
|
154
|
+
node = normalView;
|
|
155
|
+
|
|
156
|
+
}
|
|
157
|
+
|
|
149
158
|
} else if ( scope === MaterialNode.CLEARCOAT ) {
|
|
150
159
|
|
|
151
|
-
const clearcoatNode = this.getFloat(
|
|
160
|
+
const clearcoatNode = this.getFloat( scope );
|
|
152
161
|
|
|
153
162
|
if ( material.clearcoatMap && material.clearcoatMap.isTexture === true ) {
|
|
154
163
|
|
|
155
|
-
node = clearcoatNode.mul( this.getTexture(
|
|
164
|
+
node = clearcoatNode.mul( this.getTexture( scope ).r );
|
|
156
165
|
|
|
157
166
|
} else {
|
|
158
167
|
|
|
@@ -162,11 +171,11 @@ class MaterialNode extends Node {
|
|
|
162
171
|
|
|
163
172
|
} else if ( scope === MaterialNode.CLEARCOAT_ROUGHNESS ) {
|
|
164
173
|
|
|
165
|
-
const clearcoatRoughnessNode = this.getFloat(
|
|
174
|
+
const clearcoatRoughnessNode = this.getFloat( scope );
|
|
166
175
|
|
|
167
176
|
if ( material.clearcoatRoughnessMap && material.clearcoatRoughnessMap.isTexture === true ) {
|
|
168
177
|
|
|
169
|
-
node = clearcoatRoughnessNode.mul( this.getTexture(
|
|
178
|
+
node = clearcoatRoughnessNode.mul( this.getTexture( scope ).r );
|
|
170
179
|
|
|
171
180
|
} else {
|
|
172
181
|
|
|
@@ -174,13 +183,25 @@ class MaterialNode extends Node {
|
|
|
174
183
|
|
|
175
184
|
}
|
|
176
185
|
|
|
186
|
+
} else if ( scope === MaterialNode.CLEARCOAT_NORMAL ) {
|
|
187
|
+
|
|
188
|
+
if ( material.clearcoatNormalMap ) {
|
|
189
|
+
|
|
190
|
+
node = this.getTexture( scope ).normalMap( this.getCache( scope + 'Scale', 'vec2' ) );
|
|
191
|
+
|
|
192
|
+
} else {
|
|
193
|
+
|
|
194
|
+
node = normalView;
|
|
195
|
+
|
|
196
|
+
}
|
|
197
|
+
|
|
177
198
|
} else if ( scope === MaterialNode.SHEEN ) {
|
|
178
199
|
|
|
179
200
|
const sheenNode = this.getColor( 'sheenColor' ).mul( this.getFloat( 'sheen' ) ); // Move this mul() to CPU
|
|
180
201
|
|
|
181
202
|
if ( material.sheenColorMap && material.sheenColorMap.isTexture === true ) {
|
|
182
203
|
|
|
183
|
-
node = sheenNode.mul( this.getTexture( '
|
|
204
|
+
node = sheenNode.mul( this.getTexture( 'sheenColor' ).rgb );
|
|
184
205
|
|
|
185
206
|
} else {
|
|
186
207
|
|
|
@@ -190,11 +211,11 @@ class MaterialNode extends Node {
|
|
|
190
211
|
|
|
191
212
|
} else if ( scope === MaterialNode.SHEEN_ROUGHNESS ) {
|
|
192
213
|
|
|
193
|
-
const sheenRoughnessNode = this.getFloat(
|
|
214
|
+
const sheenRoughnessNode = this.getFloat( scope );
|
|
194
215
|
|
|
195
216
|
if ( material.sheenRoughnessMap && material.sheenRoughnessMap.isTexture === true ) {
|
|
196
217
|
|
|
197
|
-
node = sheenRoughnessNode.mul( this.getTexture(
|
|
218
|
+
node = sheenRoughnessNode.mul( this.getTexture( scope ).a );
|
|
198
219
|
|
|
199
220
|
} else {
|
|
200
221
|
|
|
@@ -212,7 +233,7 @@ class MaterialNode extends Node {
|
|
|
212
233
|
|
|
213
234
|
const iridescenceThicknessMinimum = reference( 0, 'float', material.iridescenceThicknessRange );
|
|
214
235
|
|
|
215
|
-
node = iridescenceThicknessMaximum.sub( iridescenceThicknessMinimum ).mul( this.getTexture(
|
|
236
|
+
node = iridescenceThicknessMaximum.sub( iridescenceThicknessMinimum ).mul( this.getTexture( scope ).g ).add( iridescenceThicknessMinimum );
|
|
216
237
|
|
|
217
238
|
} else {
|
|
218
239
|
|
|
@@ -224,7 +245,7 @@ class MaterialNode extends Node {
|
|
|
224
245
|
|
|
225
246
|
const outputType = this.getNodeType( builder );
|
|
226
247
|
|
|
227
|
-
node =
|
|
248
|
+
node = this.getCache( scope, outputType );
|
|
228
249
|
|
|
229
250
|
}
|
|
230
251
|
|
|
@@ -238,13 +259,15 @@ MaterialNode.ALPHA_TEST = 'alphaTest';
|
|
|
238
259
|
MaterialNode.COLOR = 'color';
|
|
239
260
|
MaterialNode.OPACITY = 'opacity';
|
|
240
261
|
MaterialNode.SHININESS = 'shininess';
|
|
241
|
-
MaterialNode.
|
|
262
|
+
MaterialNode.SPECULAR_COLOR = 'specular';
|
|
242
263
|
MaterialNode.SPECULAR_STRENGTH = 'specularStrength';
|
|
243
264
|
MaterialNode.REFLECTIVITY = 'reflectivity';
|
|
244
265
|
MaterialNode.ROUGHNESS = 'roughness';
|
|
245
266
|
MaterialNode.METALNESS = 'metalness';
|
|
267
|
+
MaterialNode.NORMAL = 'normal';
|
|
246
268
|
MaterialNode.CLEARCOAT = 'clearcoat';
|
|
247
269
|
MaterialNode.CLEARCOAT_ROUGHNESS = 'clearcoatRoughness';
|
|
270
|
+
MaterialNode.CLEARCOAT_NORMAL = 'clearcoatNormal';
|
|
248
271
|
MaterialNode.EMISSIVE = 'emissive';
|
|
249
272
|
MaterialNode.ROTATION = 'rotation';
|
|
250
273
|
MaterialNode.SHEEN = 'sheen';
|
|
@@ -252,6 +275,12 @@ MaterialNode.SHEEN_ROUGHNESS = 'sheenRoughness';
|
|
|
252
275
|
MaterialNode.IRIDESCENCE = 'iridescence';
|
|
253
276
|
MaterialNode.IRIDESCENCE_IOR = 'iridescenceIOR';
|
|
254
277
|
MaterialNode.IRIDESCENCE_THICKNESS = 'iridescenceThickness';
|
|
278
|
+
MaterialNode.LINE_SCALE = 'scale';
|
|
279
|
+
MaterialNode.LINE_DASH_SIZE = 'dashSize';
|
|
280
|
+
MaterialNode.LINE_GAP_SIZE = 'gapSize';
|
|
281
|
+
MaterialNode.LINE_WIDTH = 'linewidth';
|
|
282
|
+
MaterialNode.LINE_DASH_OFFSET = 'dashOffset';
|
|
283
|
+
MaterialNode.POINT_WIDTH = 'pointWidth';
|
|
255
284
|
|
|
256
285
|
export default MaterialNode;
|
|
257
286
|
|
|
@@ -265,13 +294,21 @@ export const materialSpecularStrength = nodeImmutable( MaterialNode, MaterialNod
|
|
|
265
294
|
export const materialReflectivity = nodeImmutable( MaterialNode, MaterialNode.REFLECTIVITY );
|
|
266
295
|
export const materialRoughness = nodeImmutable( MaterialNode, MaterialNode.ROUGHNESS );
|
|
267
296
|
export const materialMetalness = nodeImmutable( MaterialNode, MaterialNode.METALNESS );
|
|
297
|
+
export const materialNormal = nodeImmutable( MaterialNode, MaterialNode.NORMAL );
|
|
268
298
|
export const materialClearcoat = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT );
|
|
269
299
|
export const materialClearcoatRoughness = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_ROUGHNESS );
|
|
300
|
+
export const materialClearcoatNormal = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_NORMAL );
|
|
270
301
|
export const materialRotation = nodeImmutable( MaterialNode, MaterialNode.ROTATION );
|
|
271
302
|
export const materialSheen = nodeImmutable( MaterialNode, MaterialNode.SHEEN );
|
|
272
303
|
export const materialSheenRoughness = nodeImmutable( MaterialNode, MaterialNode.SHEEN_ROUGHNESS );
|
|
273
304
|
export const materialIridescence = nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE );
|
|
274
305
|
export const materialIridescenceIOR = nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE_IOR );
|
|
275
306
|
export const materialIridescenceThickness = nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE_THICKNESS );
|
|
307
|
+
export const materialLineScale = nodeImmutable( MaterialNode, MaterialNode.LINE_SCALE );
|
|
308
|
+
export const materialLineDashSize = nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_SIZE );
|
|
309
|
+
export const materialLineGapSize = nodeImmutable( MaterialNode, MaterialNode.LINE_GAP_SIZE );
|
|
310
|
+
export const materialLineWidth = nodeImmutable( MaterialNode, MaterialNode.LINE_WIDTH );
|
|
311
|
+
export const materialLineDashOffset = nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_OFFSET );
|
|
312
|
+
export const materialPointWidth = nodeImmutable( MaterialNode, MaterialNode.POINT_WIDTH );
|
|
276
313
|
|
|
277
314
|
addNodeClass( 'MaterialNode', MaterialNode );
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Object3DNode from './Object3DNode.js';
|
|
2
2
|
import { addNodeClass } from '../core/Node.js';
|
|
3
|
-
import { label } from '../core/ContextNode.js';
|
|
4
3
|
import { nodeImmutable } from '../shadernode/ShaderNode.js';
|
|
5
4
|
|
|
6
5
|
class ModelNode extends Object3DNode {
|
|
@@ -24,7 +23,7 @@ class ModelNode extends Object3DNode {
|
|
|
24
23
|
export default ModelNode;
|
|
25
24
|
|
|
26
25
|
export const modelDirection = nodeImmutable( ModelNode, ModelNode.DIRECTION );
|
|
27
|
-
export const modelViewMatrix =
|
|
26
|
+
export const modelViewMatrix = nodeImmutable( ModelNode, ModelNode.VIEW_MATRIX ).temp( 'ModelViewMatrix' );
|
|
28
27
|
export const modelNormalMatrix = nodeImmutable( ModelNode, ModelNode.NORMAL_MATRIX );
|
|
29
28
|
export const modelWorldMatrix = nodeImmutable( ModelNode, ModelNode.WORLD_MATRIX );
|
|
30
29
|
export const modelPosition = nodeImmutable( ModelNode, ModelNode.POSITION );
|
|
@@ -19,12 +19,12 @@ class MorphNode extends Node {
|
|
|
19
19
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
setupAttribute(
|
|
22
|
+
setupAttribute( name, assignNode = positionLocal ) {
|
|
23
23
|
|
|
24
24
|
const mesh = this.mesh;
|
|
25
25
|
const attributes = mesh.geometry.morphAttributes[ name ];
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
assignNode.mulAssign( this.morphBaseInfluence );
|
|
28
28
|
|
|
29
29
|
for ( let i = 0; i < attributes.length; i ++ ) {
|
|
30
30
|
|
|
@@ -33,15 +33,15 @@ class MorphNode extends Node {
|
|
|
33
33
|
const bufferAttrib = bufferAttribute( attribute.array, 'vec3' );
|
|
34
34
|
const influence = reference( i, 'float', mesh.morphTargetInfluences );
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
assignNode.addAssign( bufferAttrib.mul( influence ) );
|
|
37
37
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
setup( builder ) {
|
|
42
|
+
setup( /*builder*/ ) {
|
|
43
43
|
|
|
44
|
-
this.setupAttribute(
|
|
44
|
+
this.setupAttribute( 'position' );
|
|
45
45
|
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -86,7 +86,7 @@ NormalNode.WORLD = 'world';
|
|
|
86
86
|
export default NormalNode;
|
|
87
87
|
|
|
88
88
|
export const normalGeometry = nodeImmutable( NormalNode, NormalNode.GEOMETRY );
|
|
89
|
-
export const normalLocal = nodeImmutable( NormalNode, NormalNode.LOCAL );
|
|
89
|
+
export const normalLocal = nodeImmutable( NormalNode, NormalNode.LOCAL ).temp( 'Normal' );
|
|
90
90
|
export const normalView = nodeImmutable( NormalNode, NormalNode.VIEW );
|
|
91
91
|
export const normalWorld = nodeImmutable( NormalNode, NormalNode.WORLD );
|
|
92
92
|
export const transformedNormalView = property( 'vec3', 'TransformedNormalView' );
|
|
@@ -95,7 +95,7 @@ PositionNode.VIEW_DIRECTION = 'viewDirection';
|
|
|
95
95
|
export default PositionNode;
|
|
96
96
|
|
|
97
97
|
export const positionGeometry = nodeImmutable( PositionNode, PositionNode.GEOMETRY );
|
|
98
|
-
export const positionLocal = nodeImmutable( PositionNode, PositionNode.LOCAL );
|
|
98
|
+
export const positionLocal = nodeImmutable( PositionNode, PositionNode.LOCAL ).temp( 'Position' );
|
|
99
99
|
export const positionWorld = nodeImmutable( PositionNode, PositionNode.WORLD );
|
|
100
100
|
export const positionWorldDirection = nodeImmutable( PositionNode, PositionNode.WORLD_DIRECTION );
|
|
101
101
|
export const positionView = nodeImmutable( PositionNode, PositionNode.VIEW );
|