super-three 0.158.0 → 0.160.1
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 +1720 -380
- package/build/three.js +1720 -380
- package/build/three.min.js +1 -1
- package/build/three.module.js +1719 -381
- package/build/three.module.min.js +1 -1
- package/examples/jsm/Addons.js +2 -1
- package/examples/jsm/controls/OrbitControls.js +50 -40
- package/examples/jsm/csm/CSMShader.js +52 -47
- package/examples/jsm/exporters/GLTFExporter.js +79 -1
- package/examples/jsm/exporters/USDZExporter.js +27 -19
- package/examples/jsm/helpers/TextureHelper.js +237 -0
- package/examples/jsm/interactive/HTMLMesh.js +9 -2
- package/examples/jsm/lines/LineMaterial.js +16 -33
- package/examples/jsm/loaders/ColladaLoader.js +0 -6
- package/examples/jsm/loaders/DRACOLoader.js +4 -3
- package/examples/jsm/loaders/FBXLoader.js +294 -124
- package/examples/jsm/loaders/GLTFLoader.js +71 -3
- package/examples/jsm/loaders/MaterialXLoader.js +73 -54
- package/examples/jsm/loaders/NRRDLoader.js +0 -13
- package/examples/jsm/loaders/SVGLoader.js +4 -4
- package/examples/jsm/loaders/USDZLoader.js +3 -17
- package/examples/jsm/math/Octree.js +15 -4
- package/examples/jsm/misc/Timer.js +119 -0
- package/examples/jsm/misc/TubePainter.js +3 -6
- package/examples/jsm/modifiers/CurveModifier.js +20 -2
- package/examples/jsm/nodes/Nodes.js +11 -7
- package/examples/jsm/nodes/accessors/CameraNode.js +18 -2
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +5 -73
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +11 -2
- package/examples/jsm/nodes/accessors/ModelNode.js +1 -1
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +12 -3
- package/examples/jsm/nodes/accessors/MorphNode.js +191 -16
- package/examples/jsm/nodes/accessors/ReferenceNode.js +25 -1
- package/examples/jsm/nodes/accessors/TextureNode.js +122 -36
- package/examples/jsm/nodes/code/CodeNode.js +3 -3
- package/examples/jsm/nodes/core/AttributeNode.js +7 -1
- package/examples/jsm/nodes/core/CacheNode.js +4 -1
- package/examples/jsm/nodes/core/ConstNode.js +1 -1
- package/examples/jsm/nodes/core/Node.js +6 -3
- package/examples/jsm/nodes/core/NodeBuilder.js +84 -27
- package/examples/jsm/nodes/core/NodeFrame.js +10 -8
- package/examples/jsm/nodes/core/NodeUniform.js +12 -0
- package/examples/jsm/nodes/core/NodeUtils.js +3 -7
- package/examples/jsm/nodes/core/OutputStructNode.js +3 -3
- package/examples/jsm/nodes/core/PropertyNode.js +17 -2
- package/examples/jsm/nodes/core/StructTypeNode.js +4 -4
- package/examples/jsm/nodes/core/UniformGroup.js +13 -0
- package/examples/jsm/nodes/core/UniformGroupNode.js +36 -0
- package/examples/jsm/nodes/core/UniformNode.js +17 -0
- package/examples/jsm/nodes/core/VarNode.js +2 -0
- package/examples/jsm/nodes/core/VaryingNode.js +1 -7
- package/examples/jsm/nodes/display/BumpMapNode.js +1 -1
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +6 -10
- package/examples/jsm/nodes/display/GaussianBlurNode.js +170 -0
- package/examples/jsm/nodes/display/PassNode.js +182 -0
- package/examples/jsm/nodes/display/ViewportDepthNode.js +31 -3
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportNode.js +5 -8
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +52 -17
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +8 -12
- package/examples/jsm/nodes/lighting/LightsNode.js +34 -32
- package/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +12 -12
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/NodeMaterial.js +66 -41
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +0 -10
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -7
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +10 -10
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +128 -54
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +1430 -618
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +24 -14
- package/examples/jsm/nodes/math/MathNode.js +2 -0
- package/examples/jsm/nodes/math/OperatorNode.js +19 -6
- package/examples/jsm/nodes/shadernode/ShaderNode.js +32 -3
- package/examples/jsm/nodes/utils/FunctionOverloadingNode.js +95 -0
- package/examples/jsm/nodes/utils/RemapNode.js +2 -2
- package/examples/jsm/nodes/utils/SplitNode.js +8 -2
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +3 -3
- package/examples/jsm/objects/QuadMesh.js +60 -0
- package/examples/jsm/postprocessing/GTAOPass.js +572 -0
- package/examples/jsm/postprocessing/OutputPass.js +2 -0
- package/examples/jsm/renderers/common/Animation.js +10 -21
- package/examples/jsm/renderers/common/Backend.js +19 -3
- package/examples/jsm/renderers/common/Background.js +20 -22
- package/examples/jsm/renderers/common/Bindings.js +30 -21
- package/examples/jsm/renderers/common/ChainMap.js +3 -3
- package/examples/jsm/renderers/common/Color4.js +37 -0
- package/examples/jsm/renderers/common/Geometries.js +4 -4
- package/examples/jsm/renderers/common/Info.js +12 -2
- package/examples/jsm/renderers/common/Pipelines.js +3 -51
- package/examples/jsm/renderers/common/PostProcessing.js +25 -0
- package/examples/jsm/renderers/common/RenderContext.js +1 -1
- package/examples/jsm/renderers/common/RenderContexts.js +1 -1
- package/examples/jsm/renderers/common/RenderObject.js +13 -1
- package/examples/jsm/renderers/common/RenderObjects.js +4 -2
- package/examples/jsm/renderers/common/Renderer.js +137 -37
- package/examples/jsm/renderers/common/StorageTexture.js +1 -0
- package/examples/jsm/renderers/common/Textures.js +4 -1
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +10 -2
- package/examples/jsm/renderers/common/nodes/NodeUniformsGroup.js +44 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +74 -7
- package/examples/jsm/renderers/webgl/WebGLBackend.js +91 -33
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +100 -31
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +57 -5
- package/examples/jsm/renderers/webgl/utils/WebGLCapabilities.js +36 -0
- package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +11 -1
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +71 -2
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +42 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +33 -3
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +4 -14
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +186 -137
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +1 -1
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +209 -90
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -10
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +11 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +2 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +88 -6
- package/examples/jsm/shaders/FXAAShader.js +133 -133
- package/examples/jsm/shaders/GTAOShader.js +424 -0
- package/examples/jsm/shaders/OutputShader.js +4 -0
- package/examples/jsm/shaders/PoissonDenoiseShader.js +226 -0
- package/examples/jsm/shaders/SAOShader.js +2 -3
- package/examples/jsm/shaders/SSAOShader.js +2 -3
- package/examples/jsm/transpiler/AST.js +40 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +50 -8
- package/examples/jsm/transpiler/ShaderToyDecoder.js +4 -4
- package/examples/jsm/transpiler/TSLEncoder.js +124 -20
- package/examples/jsm/utils/SortUtils.js +158 -0
- package/examples/jsm/utils/TextureUtils.js +33 -21
- package/examples/jsm/webxr/ARButton.js +14 -0
- package/examples/jsm/webxr/VRButton.js +23 -8
- package/examples/jsm/webxr/XRButton.js +25 -11
- package/package.json +5 -6
- package/src/Three.js +1 -0
- package/src/constants.js +2 -1
- package/src/core/BufferAttribute.js +21 -2
- package/src/core/InterleavedBuffer.js +21 -1
- package/src/core/Object3D.js +60 -12
- package/src/core/UniformsGroup.js +7 -1
- package/src/extras/curves/LineCurve3.js +4 -0
- package/src/loaders/AudioLoader.js +1 -1
- package/src/loaders/BufferGeometryLoader.js +0 -7
- package/src/loaders/ImageBitmapLoader.js +25 -1
- package/src/loaders/ObjectLoader.js +49 -0
- package/src/materials/ShaderMaterial.js +2 -1
- package/src/math/ColorManagement.js +0 -16
- package/src/math/Quaternion.js +5 -4
- package/src/math/Sphere.js +2 -0
- package/src/math/Triangle.js +17 -5
- package/src/objects/BatchedMesh.js +1020 -0
- package/src/objects/Skeleton.js +1 -3
- package/src/renderers/WebGL3DRenderTarget.js +2 -2
- package/src/renderers/WebGLArrayRenderTarget.js +2 -2
- package/src/renderers/WebGLRenderer.js +24 -19
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +19 -0
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +0 -5
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +31 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +9 -4
- package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +9 -17
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +84 -0
- package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk.js +4 -0
- 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/meshbasic.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +3 -0
- package/src/renderers/webgl/WebGLAttributes.js +39 -5
- package/src/renderers/webgl/WebGLBufferRenderer.js +31 -0
- package/src/renderers/webgl/WebGLCubeMaps.js +1 -1
- package/src/renderers/webgl/WebGLExtensions.js +1 -0
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +31 -0
- package/src/renderers/webgl/WebGLLights.js +11 -2
- package/src/renderers/webgl/WebGLProgram.js +20 -1
- package/src/renderers/webgl/WebGLPrograms.js +5 -0
- package/src/renderers/webgl/WebGLShadowMap.js +35 -0
- package/src/renderers/webgl/WebGLTextures.js +7 -11
- package/src/renderers/webgl/WebGLUniforms.js +11 -1
- package/src/renderers/webgl/WebGLUniformsGroups.js +72 -93
- package/src/renderers/webxr/WebXRManager.js +16 -0
- package/examples/jsm/objects/BatchedMesh.js +0 -586
|
@@ -11,12 +11,14 @@ import { skinning } from '../accessors/SkinningNode.js';
|
|
|
11
11
|
import { morph } from '../accessors/MorphNode.js';
|
|
12
12
|
import { texture } from '../accessors/TextureNode.js';
|
|
13
13
|
import { cubeTexture } from '../accessors/CubeTextureNode.js';
|
|
14
|
-
import {
|
|
14
|
+
import { lightNodes } from '../lighting/LightsNode.js';
|
|
15
15
|
import { mix } from '../math/MathNode.js';
|
|
16
16
|
import { float, vec3, vec4 } from '../shadernode/ShaderNode.js';
|
|
17
17
|
import AONode from '../lighting/AONode.js';
|
|
18
18
|
import { lightingContext } from '../lighting/LightingContextNode.js';
|
|
19
19
|
import EnvironmentNode from '../lighting/EnvironmentNode.js';
|
|
20
|
+
import { depthPixel } from '../display/ViewportDepthNode.js';
|
|
21
|
+
import { cameraLogDepth } from '../accessors/CameraNode.js';
|
|
20
22
|
|
|
21
23
|
const NodeMaterials = new Map();
|
|
22
24
|
|
|
@@ -32,12 +34,11 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
32
34
|
|
|
33
35
|
this.forceSinglePass = false;
|
|
34
36
|
|
|
35
|
-
this.unlit = this.constructor === NodeMaterial.prototype.constructor; // Extended materials are not unlit by default
|
|
36
|
-
|
|
37
37
|
this.fog = true;
|
|
38
38
|
this.lights = true;
|
|
39
39
|
this.normals = true;
|
|
40
|
-
|
|
40
|
+
|
|
41
|
+
this.colorSpaced = true;
|
|
41
42
|
|
|
42
43
|
this.lightsNode = null;
|
|
43
44
|
this.envNode = null;
|
|
@@ -51,7 +52,11 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
51
52
|
|
|
52
53
|
this.positionNode = null;
|
|
53
54
|
|
|
54
|
-
this.
|
|
55
|
+
this.depthNode = null;
|
|
56
|
+
|
|
57
|
+
this.outputNode = null;
|
|
58
|
+
|
|
59
|
+
this.fragmentNode = null;
|
|
55
60
|
this.vertexNode = null;
|
|
56
61
|
|
|
57
62
|
}
|
|
@@ -74,7 +79,7 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
74
79
|
|
|
75
80
|
builder.addStack();
|
|
76
81
|
|
|
77
|
-
builder.stack.outputNode = this.setupPosition( builder );
|
|
82
|
+
builder.stack.outputNode = this.vertexNode || this.setupPosition( builder );
|
|
78
83
|
|
|
79
84
|
builder.addFlow( 'vertex', builder.removeStack() );
|
|
80
85
|
|
|
@@ -82,9 +87,11 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
82
87
|
|
|
83
88
|
builder.addStack();
|
|
84
89
|
|
|
85
|
-
let
|
|
90
|
+
let resultNode;
|
|
91
|
+
|
|
92
|
+
if ( this.fragmentNode === null ) {
|
|
86
93
|
|
|
87
|
-
|
|
94
|
+
if ( this.depthWrite === true ) this.setupDepth( builder );
|
|
88
95
|
|
|
89
96
|
if ( this.normals === true ) this.setupNormal( builder );
|
|
90
97
|
|
|
@@ -93,35 +100,61 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
93
100
|
|
|
94
101
|
const outgoingLightNode = this.setupLighting( builder );
|
|
95
102
|
|
|
96
|
-
|
|
103
|
+
resultNode = this.setupOutput( builder, vec4( outgoingLightNode, diffuseColor.a ) );
|
|
97
104
|
|
|
98
105
|
// OUTPUT NODE
|
|
99
106
|
|
|
100
|
-
output.assign(
|
|
107
|
+
output.assign( resultNode );
|
|
101
108
|
|
|
102
109
|
//
|
|
103
110
|
|
|
104
|
-
if ( this.outputNode !== null )
|
|
111
|
+
if ( this.outputNode !== null ) resultNode = this.outputNode;
|
|
105
112
|
|
|
106
113
|
} else {
|
|
107
114
|
|
|
108
|
-
|
|
115
|
+
resultNode = this.setupOutput( builder, this.fragmentNode );
|
|
109
116
|
|
|
110
117
|
}
|
|
111
118
|
|
|
112
|
-
builder.stack.outputNode =
|
|
119
|
+
builder.stack.outputNode = resultNode;
|
|
113
120
|
|
|
114
121
|
builder.addFlow( 'fragment', builder.removeStack() );
|
|
115
122
|
|
|
116
123
|
}
|
|
117
124
|
|
|
125
|
+
setupDepth( builder ) {
|
|
126
|
+
|
|
127
|
+
const { renderer } = builder;
|
|
128
|
+
|
|
129
|
+
// Depth
|
|
130
|
+
|
|
131
|
+
let depthNode = this.depthNode;
|
|
132
|
+
|
|
133
|
+
if ( depthNode === null && renderer.logarithmicDepthBuffer === true ) {
|
|
134
|
+
|
|
135
|
+
const fragDepth = modelViewProjection().w.add( 1 );
|
|
136
|
+
|
|
137
|
+
depthNode = fragDepth.log2().mul( cameraLogDepth ).mul( 0.5 );
|
|
138
|
+
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if ( depthNode !== null ) {
|
|
142
|
+
|
|
143
|
+
depthPixel.assign( depthNode ).append();
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
|
|
118
149
|
setupPosition( builder ) {
|
|
119
150
|
|
|
120
|
-
const object = builder
|
|
151
|
+
const { object } = builder;
|
|
121
152
|
const geometry = object.geometry;
|
|
122
153
|
|
|
123
154
|
builder.addStack();
|
|
124
155
|
|
|
156
|
+
// Vertex
|
|
157
|
+
|
|
125
158
|
if ( geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color ) {
|
|
126
159
|
|
|
127
160
|
morph( object ).append();
|
|
@@ -146,9 +179,12 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
146
179
|
|
|
147
180
|
}
|
|
148
181
|
|
|
182
|
+
const mvp = modelViewProjection();
|
|
183
|
+
|
|
149
184
|
builder.context.vertex = builder.removeStack();
|
|
185
|
+
builder.context.mvp = mvp;
|
|
150
186
|
|
|
151
|
-
return
|
|
187
|
+
return mvp;
|
|
152
188
|
|
|
153
189
|
}
|
|
154
190
|
|
|
@@ -160,7 +196,7 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
160
196
|
|
|
161
197
|
if ( this.vertexColors === true && geometry.hasAttribute( 'color' ) ) {
|
|
162
198
|
|
|
163
|
-
colorNode = vec4( colorNode.xyz.mul( attribute( 'color' ) ), colorNode.a );
|
|
199
|
+
colorNode = vec4( colorNode.xyz.mul( attribute( 'color', 'vec3' ) ), colorNode.a );
|
|
164
200
|
|
|
165
201
|
}
|
|
166
202
|
|
|
@@ -257,7 +293,7 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
257
293
|
|
|
258
294
|
if ( materialLightsNode.length > 0 ) {
|
|
259
295
|
|
|
260
|
-
lightsNode =
|
|
296
|
+
lightsNode = lightNodes( [ ...lightsNode.lightNodes, ...materialLightsNode ] );
|
|
261
297
|
|
|
262
298
|
}
|
|
263
299
|
|
|
@@ -316,7 +352,7 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
316
352
|
|
|
317
353
|
const toneMappingNode = builder.toneMappingNode;
|
|
318
354
|
|
|
319
|
-
if ( toneMappingNode ) {
|
|
355
|
+
if ( this.toneMapped === true && toneMappingNode ) {
|
|
320
356
|
|
|
321
357
|
outputNode = vec4( toneMappingNode.context( { color: outputNode.rgb } ), outputNode.a );
|
|
322
358
|
|
|
@@ -334,29 +370,9 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
334
370
|
|
|
335
371
|
// ENCODING
|
|
336
372
|
|
|
337
|
-
if ( this.
|
|
338
|
-
|
|
339
|
-
const renderTarget = renderer.getRenderTarget();
|
|
340
|
-
|
|
341
|
-
let outputColorSpace;
|
|
342
|
-
|
|
343
|
-
if ( renderTarget !== null ) {
|
|
344
|
-
|
|
345
|
-
if ( Array.isArray( renderTarget.texture ) ) {
|
|
346
|
-
|
|
347
|
-
outputColorSpace = renderTarget.texture[ 0 ].colorSpace;
|
|
348
|
-
|
|
349
|
-
} else {
|
|
350
|
-
|
|
351
|
-
outputColorSpace = renderTarget.texture.colorSpace;
|
|
373
|
+
if ( this.colorSpaced === true ) {
|
|
352
374
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
} else {
|
|
356
|
-
|
|
357
|
-
outputColorSpace = renderer.outputColorSpace;
|
|
358
|
-
|
|
359
|
-
}
|
|
375
|
+
const outputColorSpace = renderer.currentColorSpace;
|
|
360
376
|
|
|
361
377
|
if ( outputColorSpace !== LinearSRGBColorSpace && outputColorSpace !== NoColorSpace ) {
|
|
362
378
|
|
|
@@ -479,7 +495,11 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
479
495
|
|
|
480
496
|
this.positionNode = source.positionNode;
|
|
481
497
|
|
|
498
|
+
this.depthNode = source.depthNode;
|
|
499
|
+
|
|
482
500
|
this.outputNode = source.outputNode;
|
|
501
|
+
|
|
502
|
+
this.fragmentNode = source.fragmentNode;
|
|
483
503
|
this.vertexNode = source.vertexNode;
|
|
484
504
|
|
|
485
505
|
return super.copy( source );
|
|
@@ -521,7 +541,12 @@ export default NodeMaterial;
|
|
|
521
541
|
export function addNodeMaterial( type, nodeMaterial ) {
|
|
522
542
|
|
|
523
543
|
if ( typeof nodeMaterial !== 'function' || ! type ) throw new Error( `Node material ${ type } is not a class` );
|
|
524
|
-
if ( NodeMaterials.has( type ) )
|
|
544
|
+
if ( NodeMaterials.has( type ) ) {
|
|
545
|
+
|
|
546
|
+
console.warn( `Redefinition of node material ${ type }` );
|
|
547
|
+
return;
|
|
548
|
+
|
|
549
|
+
}
|
|
525
550
|
|
|
526
551
|
NodeMaterials.set( type, nodeMaterial );
|
|
527
552
|
nodeMaterial.type = type;
|
|
@@ -14,20 +14,10 @@ class PointsNodeMaterial extends NodeMaterial {
|
|
|
14
14
|
|
|
15
15
|
this.lights = false;
|
|
16
16
|
this.normals = false;
|
|
17
|
-
|
|
18
17
|
this.transparent = true;
|
|
19
18
|
|
|
20
|
-
this.colorNode = null;
|
|
21
|
-
this.opacityNode = null;
|
|
22
|
-
|
|
23
|
-
this.alphaTestNode = null;
|
|
24
|
-
|
|
25
|
-
this.lightNode = null;
|
|
26
|
-
|
|
27
19
|
this.sizeNode = null;
|
|
28
20
|
|
|
29
|
-
this.positionNode = null;
|
|
30
|
-
|
|
31
21
|
this.setDefaultValues( defaultValues );
|
|
32
22
|
|
|
33
23
|
this.setValues( parameters );
|
|
@@ -21,13 +21,6 @@ class SpriteNodeMaterial extends NodeMaterial {
|
|
|
21
21
|
this.lights = false;
|
|
22
22
|
this.normals = false;
|
|
23
23
|
|
|
24
|
-
this.colorNode = null;
|
|
25
|
-
this.opacityNode = null;
|
|
26
|
-
|
|
27
|
-
this.alphaTestNode = null;
|
|
28
|
-
|
|
29
|
-
this.lightNode = null;
|
|
30
|
-
|
|
31
24
|
this.positionNode = null;
|
|
32
25
|
this.rotationNode = null;
|
|
33
26
|
this.scaleNode = null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
mx_perlin_noise_float,
|
|
2
|
+
mx_perlin_noise_float, mx_perlin_noise_vec3,
|
|
3
3
|
mx_worley_noise_float as worley_noise_float, mx_worley_noise_vec2 as worley_noise_vec2, mx_worley_noise_vec3 as worley_noise_vec3,
|
|
4
4
|
mx_cell_noise_float as cell_noise_float,
|
|
5
5
|
mx_fractal_noise_float as fractal_noise_float, mx_fractal_noise_vec2 as fractal_noise_vec2, mx_fractal_noise_vec3 as fractal_noise_vec3, mx_fractal_noise_vec4 as fractal_noise_vec4
|
|
@@ -8,7 +8,7 @@ import { mx_hsvtorgb, mx_rgbtohsv } from './lib/mx_hsv.js';
|
|
|
8
8
|
import { mx_srgb_texture_to_lin_rec709 } from './lib/mx_transform_color.js';
|
|
9
9
|
import { mix, smoothstep } from '../math/MathNode.js';
|
|
10
10
|
import { uv } from '../accessors/UVNode.js';
|
|
11
|
-
import { float, vec2, vec4 } from '../shadernode/ShaderNode.js';
|
|
11
|
+
import { float, vec2, vec4, int } from '../shadernode/ShaderNode.js';
|
|
12
12
|
|
|
13
13
|
export const mx_aastep = ( threshold, value ) => {
|
|
14
14
|
|
|
@@ -42,7 +42,7 @@ export const mx_safepower = ( in1, in2 = 1 ) => {
|
|
|
42
42
|
export const mx_contrast = ( input, amount = 1, pivot = .5 ) => float( input ).sub( pivot ).mul( amount ).add( pivot );
|
|
43
43
|
|
|
44
44
|
export const mx_noise_float = ( texcoord = uv(), amplitude = 1, pivot = 0 ) => mx_perlin_noise_float( texcoord.convert( 'vec2|vec3' ) ).mul( amplitude ).add( pivot );
|
|
45
|
-
export const mx_noise_vec2 = ( texcoord = uv(), amplitude = 1, pivot = 0 ) =>
|
|
45
|
+
//export const mx_noise_vec2 = ( texcoord = uv(), amplitude = 1, pivot = 0 ) => mx_perlin_noise_vec3( texcoord.convert( 'vec2|vec3' ) ).mul( amplitude ).add( pivot );
|
|
46
46
|
export const mx_noise_vec3 = ( texcoord = uv(), amplitude = 1, pivot = 0 ) => mx_perlin_noise_vec3( texcoord.convert( 'vec2|vec3' ) ).mul( amplitude ).add( pivot );
|
|
47
47
|
export const mx_noise_vec4 = ( texcoord = uv(), amplitude = 1, pivot = 0 ) => {
|
|
48
48
|
|
|
@@ -54,15 +54,15 @@ export const mx_noise_vec4 = ( texcoord = uv(), amplitude = 1, pivot = 0 ) => {
|
|
|
54
54
|
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
export const mx_worley_noise_float = ( texcoord = uv(), jitter = 1 ) => worley_noise_float( texcoord.convert( 'vec2|vec3' ), jitter, 1 );
|
|
58
|
-
export const mx_worley_noise_vec2 = ( texcoord = uv(), jitter = 1 ) => worley_noise_vec2( texcoord.convert( 'vec2|vec3' ), jitter, 1 );
|
|
59
|
-
export const mx_worley_noise_vec3 = ( texcoord = uv(), jitter = 1 ) => worley_noise_vec3( texcoord.convert( 'vec2|vec3' ), jitter, 1 );
|
|
57
|
+
export const mx_worley_noise_float = ( texcoord = uv(), jitter = 1 ) => worley_noise_float( texcoord.convert( 'vec2|vec3' ), jitter, int( 1 ) );
|
|
58
|
+
export const mx_worley_noise_vec2 = ( texcoord = uv(), jitter = 1 ) => worley_noise_vec2( texcoord.convert( 'vec2|vec3' ), jitter, int( 1 ) );
|
|
59
|
+
export const mx_worley_noise_vec3 = ( texcoord = uv(), jitter = 1 ) => worley_noise_vec3( texcoord.convert( 'vec2|vec3' ), jitter, int( 1 ) );
|
|
60
60
|
|
|
61
61
|
export const mx_cell_noise_float = ( texcoord = uv() ) => cell_noise_float( texcoord.convert( 'vec2|vec3' ) );
|
|
62
62
|
|
|
63
|
-
export const mx_fractal_noise_float = ( position = uv(), octaves = 3, lacunarity = 2, diminish = .5, amplitude = 1 ) => fractal_noise_float( position, octaves, lacunarity, diminish ).mul( amplitude );
|
|
64
|
-
export const mx_fractal_noise_vec2 = ( position = uv(), octaves = 3, lacunarity = 2, diminish = .5, amplitude = 1 ) => fractal_noise_vec2( position, octaves, lacunarity, diminish ).mul( amplitude );
|
|
65
|
-
export const mx_fractal_noise_vec3 = ( position = uv(), octaves = 3, lacunarity = 2, diminish = .5, amplitude = 1 ) => fractal_noise_vec3( position, octaves, lacunarity, diminish ).mul( amplitude );
|
|
66
|
-
export const mx_fractal_noise_vec4 = ( position = uv(), octaves = 3, lacunarity = 2, diminish = .5, amplitude = 1 ) => fractal_noise_vec4( position, octaves, lacunarity, diminish ).mul( amplitude );
|
|
63
|
+
export const mx_fractal_noise_float = ( position = uv(), octaves = 3, lacunarity = 2, diminish = .5, amplitude = 1 ) => fractal_noise_float( position, int( octaves ), lacunarity, diminish ).mul( amplitude );
|
|
64
|
+
export const mx_fractal_noise_vec2 = ( position = uv(), octaves = 3, lacunarity = 2, diminish = .5, amplitude = 1 ) => fractal_noise_vec2( position, int( octaves ), lacunarity, diminish ).mul( amplitude );
|
|
65
|
+
export const mx_fractal_noise_vec3 = ( position = uv(), octaves = 3, lacunarity = 2, diminish = .5, amplitude = 1 ) => fractal_noise_vec3( position, int( octaves ), lacunarity, diminish ).mul( amplitude );
|
|
66
|
+
export const mx_fractal_noise_vec4 = ( position = uv(), octaves = 3, lacunarity = 2, diminish = .5, amplitude = 1 ) => fractal_noise_vec4( position, int( octaves ), lacunarity, diminish ).mul( amplitude );
|
|
67
67
|
|
|
68
68
|
export { mx_hsvtorgb, mx_rgbtohsv, mx_srgb_texture_to_lin_rec709 };
|
|
@@ -1,56 +1,130 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// Original shader code from:
|
|
1
|
+
// Three.js Transpiler
|
|
4
2
|
// https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/libraries/stdlib/genglsl/lib/mx_hsv.glsl
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
4
|
+
import { int, float, vec3, If, tslFn } from '../../shadernode/ShaderNode.js';
|
|
5
|
+
import { add, sub, mul } from '../../math/OperatorNode.js';
|
|
6
|
+
import { floor, trunc, max, min } from '../../math/MathNode.js';
|
|
7
|
+
|
|
8
|
+
const mx_hsvtorgb = tslFn( ( [ hsv_immutable ] ) => {
|
|
9
|
+
|
|
10
|
+
const hsv = vec3( hsv_immutable ).toVar();
|
|
11
|
+
const h = float( hsv.x ).toVar();
|
|
12
|
+
const s = float( hsv.y ).toVar();
|
|
13
|
+
const v = float( hsv.z ).toVar();
|
|
14
|
+
|
|
15
|
+
If( s.lessThan( 0.0001 ), () => {
|
|
16
|
+
|
|
17
|
+
return vec3( v, v, v );
|
|
18
|
+
|
|
19
|
+
} ).else( () => {
|
|
20
|
+
|
|
21
|
+
h.assign( mul( 6.0, h.sub( floor( h ) ) ) );
|
|
22
|
+
const hi = int( trunc( h ) ).toVar();
|
|
23
|
+
const f = float( h.sub( float( hi ) ) ).toVar();
|
|
24
|
+
const p = float( v.mul( sub( 1.0, s ) ) ).toVar();
|
|
25
|
+
const q = float( v.mul( sub( 1.0, s.mul( f ) ) ) ).toVar();
|
|
26
|
+
const t = float( v.mul( sub( 1.0, s.mul( sub( 1.0, f ) ) ) ) ).toVar();
|
|
27
|
+
|
|
28
|
+
If( hi.equal( int( 0 ) ), () => {
|
|
29
|
+
|
|
30
|
+
return vec3( v, t, p );
|
|
31
|
+
|
|
32
|
+
} ).elseif( hi.equal( int( 1 ) ), () => {
|
|
33
|
+
|
|
34
|
+
return vec3( q, v, p );
|
|
35
|
+
|
|
36
|
+
} ).elseif( hi.equal( int( 2 ) ), () => {
|
|
37
|
+
|
|
38
|
+
return vec3( p, v, t );
|
|
39
|
+
|
|
40
|
+
} ).elseif( hi.equal( int( 3 ) ), () => {
|
|
41
|
+
|
|
42
|
+
return vec3( p, q, v );
|
|
43
|
+
|
|
44
|
+
} ).elseif( hi.equal( int( 4 ) ), () => {
|
|
45
|
+
|
|
46
|
+
return vec3( t, p, v );
|
|
47
|
+
|
|
48
|
+
} );
|
|
49
|
+
|
|
50
|
+
return vec3( v, p, q );
|
|
51
|
+
|
|
52
|
+
} );
|
|
53
|
+
|
|
54
|
+
} );
|
|
55
|
+
|
|
56
|
+
const mx_rgbtohsv = tslFn( ( [ c_immutable ] ) => {
|
|
57
|
+
|
|
58
|
+
const c = vec3( c_immutable ).toVar();
|
|
59
|
+
const r = float( c.x ).toVar();
|
|
60
|
+
const g = float( c.y ).toVar();
|
|
61
|
+
const b = float( c.z ).toVar();
|
|
62
|
+
const mincomp = float( min( r, min( g, b ) ) ).toVar();
|
|
63
|
+
const maxcomp = float( max( r, max( g, b ) ) ).toVar();
|
|
64
|
+
const delta = float( maxcomp.sub( mincomp ) ).toVar();
|
|
65
|
+
const h = float().toVar(), s = float().toVar(), v = float().toVar();
|
|
66
|
+
v.assign( maxcomp );
|
|
67
|
+
|
|
68
|
+
If( maxcomp.greaterThan( 0.0 ), () => {
|
|
69
|
+
|
|
70
|
+
s.assign( delta.div( maxcomp ) );
|
|
71
|
+
|
|
72
|
+
} ).else( () => {
|
|
73
|
+
|
|
74
|
+
s.assign( 0.0 );
|
|
75
|
+
|
|
76
|
+
} );
|
|
77
|
+
|
|
78
|
+
If( s.lessThanEqual( 0.0 ), () => {
|
|
79
|
+
|
|
80
|
+
h.assign( 0.0 );
|
|
81
|
+
|
|
82
|
+
} ).else( () => {
|
|
83
|
+
|
|
84
|
+
If( r.greaterThanEqual( maxcomp ), () => {
|
|
85
|
+
|
|
86
|
+
h.assign( g.sub( b ).div( delta ) );
|
|
87
|
+
|
|
88
|
+
} ).elseif( g.greaterThanEqual( maxcomp ), () => {
|
|
89
|
+
|
|
90
|
+
h.assign( add( 2.0, b.sub( r ).div( delta ) ) );
|
|
91
|
+
|
|
92
|
+
} ).else( () => {
|
|
93
|
+
|
|
94
|
+
h.assign( add( 4.0, r.sub( g ).div( delta ) ) );
|
|
95
|
+
|
|
96
|
+
} );
|
|
97
|
+
|
|
98
|
+
h.mulAssign( 1.0 / 6.0 );
|
|
99
|
+
|
|
100
|
+
If( h.lessThan( 0.0 ), () => {
|
|
101
|
+
|
|
102
|
+
h.addAssign( 1.0 );
|
|
103
|
+
|
|
104
|
+
} );
|
|
105
|
+
|
|
106
|
+
} );
|
|
107
|
+
|
|
108
|
+
return vec3( h, s, v );
|
|
109
|
+
|
|
110
|
+
} );
|
|
111
|
+
|
|
112
|
+
// layouts
|
|
113
|
+
|
|
114
|
+
mx_hsvtorgb.setLayout( {
|
|
115
|
+
name: 'mx_hsvtorgb',
|
|
116
|
+
type: 'vec3',
|
|
117
|
+
inputs: [
|
|
118
|
+
{ name: 'hsv', type: 'vec3' }
|
|
119
|
+
]
|
|
120
|
+
} );
|
|
121
|
+
|
|
122
|
+
mx_rgbtohsv.setLayout( {
|
|
123
|
+
name: 'mx_rgbtohsv',
|
|
124
|
+
type: 'vec3',
|
|
125
|
+
inputs: [
|
|
126
|
+
{ name: 'c', type: 'vec3' }
|
|
127
|
+
]
|
|
128
|
+
} );
|
|
129
|
+
|
|
130
|
+
export { mx_hsvtorgb, mx_rgbtohsv };
|