super-three 0.156.0 → 0.157.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 +753 -277
- package/build/three.js +753 -277
- package/build/three.min.js +2 -2
- package/build/three.module.js +750 -276
- package/build/three.module.min.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +17 -0
- package/examples/jsm/controls/DragControls.js +3 -2
- package/examples/jsm/csm/CSMShader.js +25 -21
- package/examples/jsm/exporters/EXRExporter.js +102 -24
- package/examples/jsm/exporters/GLTFExporter.js +1 -1
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +8726 -4
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +8737 -4
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/lights/LightProbeGenerator.js +37 -3
- package/examples/jsm/lines/LineMaterial.js +90 -156
- package/examples/jsm/loaders/3DMLoader.js +378 -104
- package/examples/jsm/loaders/GLTFLoader.js +1 -1
- package/examples/jsm/loaders/LDrawLoader.js +22 -16
- package/examples/jsm/loaders/RGBELoader.js +1 -1
- package/examples/jsm/loaders/USDZLoader.js +215 -12
- package/examples/jsm/materials/MeshGouraudMaterial.js +22 -18
- package/examples/jsm/nodes/Nodes.js +5 -1
- package/examples/jsm/nodes/accessors/BitangentNode.js +1 -1
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +2 -2
- package/examples/jsm/nodes/accessors/BufferNode.js +1 -1
- package/examples/jsm/nodes/accessors/CameraNode.js +1 -1
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +2 -2
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +6 -5
- package/examples/jsm/nodes/accessors/InstanceNode.js +2 -2
- package/examples/jsm/nodes/accessors/LineMaterialNode.js +7 -9
- package/examples/jsm/nodes/accessors/MaterialNode.js +34 -46
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +9 -9
- package/examples/jsm/nodes/accessors/ModelNode.js +1 -1
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +5 -4
- package/examples/jsm/nodes/accessors/MorphNode.js +4 -4
- package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
- package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
- package/examples/jsm/nodes/accessors/PointUVNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
- package/examples/jsm/nodes/accessors/ReferenceNode.js +13 -7
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -2
- package/examples/jsm/nodes/accessors/SceneNode.js +2 -2
- package/examples/jsm/nodes/accessors/SkinningNode.js +2 -2
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +1 -1
- package/examples/jsm/nodes/accessors/TangentNode.js +1 -1
- package/examples/jsm/nodes/accessors/TextureBicubicNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureNode.js +12 -6
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureStoreNode.js +1 -1
- package/examples/jsm/nodes/accessors/UVNode.js +1 -1
- package/examples/jsm/nodes/accessors/UserDataNode.js +2 -2
- package/examples/jsm/nodes/code/CodeNode.js +1 -1
- package/examples/jsm/nodes/code/ExpressionNode.js +1 -1
- package/examples/jsm/nodes/code/FunctionCallNode.js +1 -1
- package/examples/jsm/nodes/code/FunctionNode.js +18 -7
- package/examples/jsm/nodes/code/ScriptableNode.js +2 -2
- package/examples/jsm/nodes/code/ScriptableValueNode.js +2 -2
- package/examples/jsm/nodes/core/ArrayUniformNode.js +1 -1
- package/examples/jsm/nodes/core/AttributeNode.js +1 -1
- package/examples/jsm/nodes/core/BypassNode.js +1 -1
- package/examples/jsm/nodes/core/CacheNode.js +1 -1
- package/examples/jsm/nodes/core/ConstNode.js +1 -1
- package/examples/jsm/nodes/core/ContextNode.js +2 -2
- package/examples/jsm/nodes/core/IndexNode.js +1 -1
- package/examples/jsm/nodes/core/InputNode.js +1 -1
- package/examples/jsm/nodes/core/Node.js +28 -13
- package/examples/jsm/nodes/core/NodeBuilder.js +3 -17
- package/examples/jsm/nodes/core/NodeFrame.js +37 -14
- package/examples/jsm/nodes/core/OutputStructNode.js +8 -4
- package/examples/jsm/nodes/core/PropertyNode.js +3 -3
- package/examples/jsm/nodes/core/StackNode.js +1 -1
- package/examples/jsm/nodes/core/StructTypeNode.js +1 -1
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/core/UniformNode.js +3 -1
- package/examples/jsm/nodes/core/VarNode.js +1 -1
- package/examples/jsm/nodes/core/VaryingNode.js +1 -1
- package/examples/jsm/nodes/core/constants.js +1 -1
- package/examples/jsm/nodes/display/BlendModeNode.js +2 -2
- package/examples/jsm/nodes/display/BumpMapNode.js +2 -2
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +2 -2
- package/examples/jsm/nodes/display/ColorSpaceNode.js +2 -2
- package/examples/jsm/nodes/display/FrontFacingNode.js +1 -1
- package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
- package/examples/jsm/nodes/display/PosterizeNode.js +2 -2
- package/examples/jsm/nodes/display/ToneMappingNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportDepthNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -1
- package/examples/jsm/nodes/display/ViewportNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +1 -1
- package/examples/jsm/nodes/display/ViewportTextureNode.js +1 -1
- package/examples/jsm/nodes/fog/FogExp2Node.js +2 -2
- package/examples/jsm/nodes/fog/FogNode.js +2 -2
- package/examples/jsm/nodes/fog/FogRangeNode.js +2 -2
- package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
- package/examples/jsm/nodes/lighting/AONode.js +2 -2
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +4 -4
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +4 -4
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +2 -2
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/IESSpotLightNode.js +2 -2
- package/examples/jsm/nodes/lighting/LightNode.js +2 -2
- package/examples/jsm/nodes/lighting/LightingContextNode.js +3 -3
- package/examples/jsm/nodes/lighting/LightingNode.js +1 -1
- package/examples/jsm/nodes/lighting/LightsNode.js +4 -4
- package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/SpotLightNode.js +4 -4
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +449 -0
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/Materials.js +1 -0
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +2 -2
- 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 +6 -6
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/NodeMaterial.js +27 -26
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
- package/examples/jsm/nodes/math/CondNode.js +1 -1
- package/examples/jsm/nodes/math/HashNode.js +8 -9
- package/examples/jsm/nodes/math/MathNode.js +2 -2
- 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 +81 -28
- package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
- package/examples/jsm/nodes/utils/ConvertNode.js +1 -1
- package/examples/jsm/nodes/utils/DiscardNode.js +1 -1
- package/examples/jsm/nodes/utils/EquirectUVNode.js +2 -2
- package/examples/jsm/nodes/utils/JoinNode.js +1 -1
- package/examples/jsm/nodes/utils/LoopNode.js +11 -11
- package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -2
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
- package/examples/jsm/nodes/utils/OscNode.js +2 -2
- package/examples/jsm/nodes/utils/PackingNode.js +2 -2
- package/examples/jsm/nodes/utils/RemapNode.js +2 -2
- package/examples/jsm/nodes/utils/RotateUVNode.js +2 -2
- package/examples/jsm/nodes/utils/SetNode.js +62 -0
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +2 -2
- package/examples/jsm/nodes/utils/SplitNode.js +1 -1
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +2 -2
- package/examples/jsm/nodes/utils/TimerNode.js +2 -2
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +2 -2
- package/examples/jsm/objects/Sky.js +1 -3
- package/examples/jsm/postprocessing/OutputPass.js +3 -2
- package/examples/jsm/renderers/common/Background.js +2 -2
- package/examples/jsm/renderers/common/Bindings.js +3 -5
- package/examples/jsm/renderers/common/Pipelines.js +7 -7
- package/examples/jsm/renderers/common/RenderContext.js +3 -0
- package/examples/jsm/renderers/common/RenderObject.js +40 -16
- package/examples/jsm/renderers/common/RenderObjects.js +8 -14
- package/examples/jsm/renderers/common/Renderer.js +40 -13
- package/examples/jsm/renderers/common/SampledTexture.js +4 -2
- package/examples/jsm/renderers/common/StorageTexture.js +19 -0
- package/examples/jsm/renderers/common/Textures.js +14 -9
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +35 -0
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +20 -10
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +0 -6
- package/examples/jsm/renderers/common/nodes/Nodes.js +51 -24
- package/examples/jsm/renderers/webgl/WebGLBackend.js +100 -5
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +92 -6
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +13 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +3 -3
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +14 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +5 -5
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +6 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +5 -5
- package/examples/jsm/renderers/webgpu/utils/WebGPUTexturePassUtils.js +285 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +197 -167
- package/examples/jsm/shaders/GammaCorrectionShader.js +1 -1
- package/examples/jsm/shaders/MMDToonShader.js +4 -4
- package/examples/jsm/shaders/OutputShader.js +2 -2
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +6 -6
- package/examples/jsm/utils/BufferGeometryUtils.js +6 -4
- package/package.json +1 -1
- package/src/Three.js +0 -2
- package/src/animation/AnimationUtils.js +3 -20
- package/src/animation/KeyframeTrack.js +8 -8
- package/src/cameras/Camera.js +1 -5
- package/src/cameras/CubeCamera.js +14 -8
- package/src/constants.js +7 -1
- package/src/core/RenderTarget.js +16 -7
- package/src/extras/core/CurvePath.js +4 -1
- package/src/loaders/MaterialLoader.js +1 -1
- package/src/loaders/ObjectLoader.js +6 -0
- package/src/materials/Material.js +8 -8
- package/src/math/Color.js +1 -5
- package/src/math/ColorManagement.js +82 -60
- package/src/objects/Sprite.js +2 -2
- package/src/renderers/WebGLMultiviewRenderTarget.js +35 -0
- package/src/renderers/WebGLRenderer.js +78 -22
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +35 -2
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -9
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +19 -15
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +4 -4
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +11 -6
- package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +4 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +16 -16
- package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -1
- package/src/renderers/shaders/UniformsUtils.js +2 -2
- package/src/renderers/webgl/WebGLBackground.js +5 -4
- package/src/renderers/webgl/WebGLLights.js +14 -3
- package/src/renderers/webgl/WebGLMultiview.js +100 -0
- package/src/renderers/webgl/WebGLProgram.js +84 -5
- package/src/renderers/webgl/WebGLPrograms.js +11 -2
- package/src/renderers/webgl/WebGLTextures.js +214 -26
- package/src/renderers/webgl/WebGLUtils.js +21 -23
- package/src/renderers/webxr/WebXRManager.js +36 -12
- package/src/scenes/Fog.js +1 -0
- package/src/scenes/FogExp2.js +1 -0
- package/src/textures/Source.js +2 -2
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureMipmapUtils.js +0 -163
- package/src/lights/AmbientLightProbe.js +0 -21
- package/src/lights/HemisphereLightProbe.js +0 -30
|
@@ -29,7 +29,7 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
29
29
|
|
|
30
30
|
this.isNodeMaterial = true;
|
|
31
31
|
|
|
32
|
-
this.type = this.constructor.
|
|
32
|
+
this.type = this.constructor.type;
|
|
33
33
|
|
|
34
34
|
this.forceSinglePass = false;
|
|
35
35
|
|
|
@@ -65,17 +65,17 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
65
65
|
|
|
66
66
|
build( builder ) {
|
|
67
67
|
|
|
68
|
-
this.
|
|
68
|
+
this.setup( builder );
|
|
69
69
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
setup( builder ) {
|
|
73
73
|
|
|
74
74
|
// < VERTEX STAGE >
|
|
75
75
|
|
|
76
76
|
builder.addStack();
|
|
77
77
|
|
|
78
|
-
builder.stack.outputNode = this.
|
|
78
|
+
builder.stack.outputNode = this.setupPosition( builder );
|
|
79
79
|
|
|
80
80
|
builder.addFlow( 'vertex', builder.removeStack() );
|
|
81
81
|
|
|
@@ -87,14 +87,14 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
87
87
|
|
|
88
88
|
if ( this.unlit === false ) {
|
|
89
89
|
|
|
90
|
-
if ( this.normals === true ) this.
|
|
90
|
+
if ( this.normals === true ) this.setupNormal( builder );
|
|
91
91
|
|
|
92
|
-
this.
|
|
93
|
-
this.
|
|
92
|
+
this.setupDiffuseColor( builder );
|
|
93
|
+
this.setupVariants( builder );
|
|
94
94
|
|
|
95
|
-
const outgoingLightNode = this.
|
|
95
|
+
const outgoingLightNode = this.setupLighting( builder );
|
|
96
96
|
|
|
97
|
-
outputNode = this.
|
|
97
|
+
outputNode = this.setupOutput( builder, vec4( outgoingLightNode, diffuseColor.a ) );
|
|
98
98
|
|
|
99
99
|
// OUTPUT NODE
|
|
100
100
|
|
|
@@ -106,7 +106,7 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
106
106
|
|
|
107
107
|
} else {
|
|
108
108
|
|
|
109
|
-
outputNode = this.
|
|
109
|
+
outputNode = this.setupOutput( builder, this.outputNode || vec4( 0, 0, 0, 1 ) );
|
|
110
110
|
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -116,7 +116,7 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
116
116
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
setupPosition( builder ) {
|
|
120
120
|
|
|
121
121
|
const object = builder.object;
|
|
122
122
|
const geometry = object.geometry;
|
|
@@ -153,7 +153,7 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
153
153
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
setupDiffuseColor( { stack, geometry } ) {
|
|
157
157
|
|
|
158
158
|
let colorNode = this.colorNode ? vec4( this.colorNode ) : materialColor;
|
|
159
159
|
|
|
@@ -186,20 +186,20 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
186
186
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
|
|
189
|
+
setupVariants( /*builder*/ ) {
|
|
190
190
|
|
|
191
191
|
// Interface function.
|
|
192
192
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
setupNormal( { stack } ) {
|
|
196
196
|
|
|
197
197
|
// NORMAL VIEW
|
|
198
198
|
|
|
199
199
|
if ( this.flatShading === true ) {
|
|
200
200
|
|
|
201
201
|
const fdx = dFdx( positionView );
|
|
202
|
-
const fdy = dFdy( positionView
|
|
202
|
+
const fdy = dFdy( positionView );
|
|
203
203
|
const normalNode = fdx.cross( fdy ).normalize();
|
|
204
204
|
|
|
205
205
|
stack.assign( transformedNormalView, normalNode );
|
|
@@ -236,7 +236,7 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
236
236
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
|
|
239
|
+
setupLights( builder ) {
|
|
240
240
|
|
|
241
241
|
const envNode = this.getEnvNode( builder );
|
|
242
242
|
|
|
@@ -268,13 +268,13 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
268
268
|
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
|
|
271
|
+
setupLightingModel( /*builder*/ ) {
|
|
272
272
|
|
|
273
273
|
// Interface function.
|
|
274
274
|
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
|
|
277
|
+
setupLighting( builder ) {
|
|
278
278
|
|
|
279
279
|
const { material } = builder;
|
|
280
280
|
const { backdropNode, backdropAlphaNode, emissiveNode } = this;
|
|
@@ -283,13 +283,13 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
283
283
|
|
|
284
284
|
const lights = this.lights === true || this.lightsNode !== null;
|
|
285
285
|
|
|
286
|
-
const lightsNode = lights ? this.
|
|
286
|
+
const lightsNode = lights ? this.setupLights( builder ) : null;
|
|
287
287
|
|
|
288
288
|
let outgoingLightNode = diffuseColor.rgb;
|
|
289
289
|
|
|
290
290
|
if ( lightsNode && lightsNode.hasLight !== false ) {
|
|
291
291
|
|
|
292
|
-
const lightingModelNode = this.
|
|
292
|
+
const lightingModelNode = this.setupLightingModel( builder );
|
|
293
293
|
|
|
294
294
|
outgoingLightNode = lightingContext( lightsNode, lightingModelNode, backdropNode, backdropAlphaNode );
|
|
295
295
|
|
|
@@ -311,7 +311,7 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
311
311
|
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
-
|
|
314
|
+
setupOutput( builder, outputNode ) {
|
|
315
315
|
|
|
316
316
|
const renderer = builder.renderer;
|
|
317
317
|
|
|
@@ -521,12 +521,13 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
521
521
|
|
|
522
522
|
export default NodeMaterial;
|
|
523
523
|
|
|
524
|
-
export function addNodeMaterial( nodeMaterial ) {
|
|
524
|
+
export function addNodeMaterial( type, nodeMaterial ) {
|
|
525
525
|
|
|
526
|
-
if ( typeof nodeMaterial !== 'function' || !
|
|
527
|
-
if ( NodeMaterials.has(
|
|
526
|
+
if ( typeof nodeMaterial !== 'function' || ! type ) throw new Error( `Node material ${ type } is not a class` );
|
|
527
|
+
if ( NodeMaterials.has( type ) ) throw new Error( `Redefinition of node material ${ type }` );
|
|
528
528
|
|
|
529
|
-
NodeMaterials.set(
|
|
529
|
+
NodeMaterials.set( type, nodeMaterial );
|
|
530
|
+
nodeMaterial.type = type;
|
|
530
531
|
|
|
531
532
|
}
|
|
532
533
|
|
|
@@ -542,4 +543,4 @@ export function createNodeMaterialFromType( type ) {
|
|
|
542
543
|
|
|
543
544
|
}
|
|
544
545
|
|
|
545
|
-
addNodeMaterial( NodeMaterial );
|
|
546
|
+
addNodeMaterial( 'NodeMaterial', NodeMaterial );
|
|
@@ -38,7 +38,7 @@ class SpriteNodeMaterial extends NodeMaterial {
|
|
|
38
38
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
setupPosition( { object, context } ) {
|
|
42
42
|
|
|
43
43
|
// < VERTEX STAGE >
|
|
44
44
|
|
|
@@ -100,4 +100,4 @@ class SpriteNodeMaterial extends NodeMaterial {
|
|
|
100
100
|
|
|
101
101
|
export default SpriteNodeMaterial;
|
|
102
102
|
|
|
103
|
-
addNodeMaterial( SpriteNodeMaterial );
|
|
103
|
+
addNodeMaterial( 'SpriteNodeMaterial', SpriteNodeMaterial );
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Node, { addNodeClass } from '../core/Node.js';
|
|
2
|
-
import {
|
|
3
|
-
import { addNodeElement, nodeProxy, uint } from '../shadernode/ShaderNode.js';
|
|
2
|
+
import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js';
|
|
4
3
|
|
|
5
4
|
class HashNode extends Node {
|
|
6
5
|
|
|
@@ -12,15 +11,15 @@ class HashNode extends Node {
|
|
|
12
11
|
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
setup( /*builder*/ ) {
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
// Taken from https://www.shadertoy.com/view/XlGcRh, originally from pcg-random.org
|
|
18
17
|
|
|
19
|
-
const state =
|
|
20
|
-
const word =
|
|
21
|
-
const
|
|
18
|
+
const state = this.seedNode.uint().mul( 747796405 ).add( 2891336453 );
|
|
19
|
+
const word = state.shiftRight( state.shiftRight( 28 ).add( 4 ) ).bitXor( state ).mul( 277803737 );
|
|
20
|
+
const result = word.shiftRight( 22 ).bitXor( word );
|
|
22
21
|
|
|
23
|
-
return mul( 1 / 2 ** 32
|
|
22
|
+
return result.float().mul( 1 / 2 ** 32 ); // Convert to range [0, 1)
|
|
24
23
|
|
|
25
24
|
}
|
|
26
25
|
|
|
@@ -32,4 +31,4 @@ export const hash = nodeProxy( HashNode );
|
|
|
32
31
|
|
|
33
32
|
addNodeElement( 'hash', hash );
|
|
34
33
|
|
|
35
|
-
addNodeClass( HashNode );
|
|
34
|
+
addNodeClass( 'HashNode', HashNode );
|
|
@@ -102,7 +102,7 @@ class MathNode extends TempNode {
|
|
|
102
102
|
|
|
103
103
|
} else if ( method === MathNode.NEGATE ) {
|
|
104
104
|
|
|
105
|
-
return builder.format( '-' + a.build( builder, inputType ), type, output );
|
|
105
|
+
return builder.format( '( - ' + a.build( builder, inputType ) + ' )', type, output );
|
|
106
106
|
|
|
107
107
|
} else if ( method === MathNode.ONE_MINUS ) {
|
|
108
108
|
|
|
@@ -356,4 +356,4 @@ addNodeElement( 'faceForward', faceForward );
|
|
|
356
356
|
addNodeElement( 'difference', difference );
|
|
357
357
|
addNodeElement( 'saturate', saturate );
|
|
358
358
|
|
|
359
|
-
addNodeClass( MathNode );
|
|
359
|
+
addNodeClass( 'MathNode', MathNode );
|
|
@@ -25,9 +25,9 @@ class CheckerNode extends TempNode {
|
|
|
25
25
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
setup() {
|
|
29
29
|
|
|
30
|
-
return checkerShaderNode( { uv: this.uvNode } )
|
|
30
|
+
return checkerShaderNode( { uv: this.uvNode } );
|
|
31
31
|
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -39,4 +39,4 @@ export const checker = nodeProxy( CheckerNode );
|
|
|
39
39
|
|
|
40
40
|
addNodeElement( 'checker', checker );
|
|
41
41
|
|
|
42
|
-
addNodeClass( CheckerNode );
|
|
42
|
+
addNodeClass( 'CheckerNode', CheckerNode );
|
|
@@ -3,6 +3,7 @@ import ArrayElementNode from '../utils/ArrayElementNode.js';
|
|
|
3
3
|
import ConvertNode from '../utils/ConvertNode.js';
|
|
4
4
|
import JoinNode from '../utils/JoinNode.js';
|
|
5
5
|
import SplitNode from '../utils/SplitNode.js';
|
|
6
|
+
import SetNode from '../utils/SetNode.js';
|
|
6
7
|
import ConstNode from '../core/ConstNode.js';
|
|
7
8
|
import { getValueFromType, getValueType } from '../core/NodeUtils.js';
|
|
8
9
|
|
|
@@ -17,9 +18,11 @@ export function addNodeElement( name, nodeElement ) {
|
|
|
17
18
|
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
const parseSwizzle = ( props ) => props.replace( /r|s/g, 'x' ).replace( /g|t/g, 'y' ).replace( /b|p/g, 'z' ).replace( /a|q/g, 'w' );
|
|
22
|
+
|
|
20
23
|
const shaderNodeHandler = {
|
|
21
24
|
|
|
22
|
-
|
|
25
|
+
setup( NodeClosure, params ) {
|
|
23
26
|
|
|
24
27
|
const inputs = params.shift();
|
|
25
28
|
|
|
@@ -51,19 +54,31 @@ const shaderNodeHandler = {
|
|
|
51
54
|
|
|
52
55
|
// accessing properties ( swizzle )
|
|
53
56
|
|
|
54
|
-
prop = prop
|
|
55
|
-
.replace( /r|s/g, 'x' )
|
|
56
|
-
.replace( /g|t/g, 'y' )
|
|
57
|
-
.replace( /b|p/g, 'z' )
|
|
58
|
-
.replace( /a|q/g, 'w' );
|
|
57
|
+
prop = parseSwizzle( prop );
|
|
59
58
|
|
|
60
59
|
return nodeObject( new SplitNode( node, prop ) );
|
|
61
60
|
|
|
62
|
-
} else if ( prop
|
|
61
|
+
} else if ( /^set[XYZWRGBASTPQ]{1,4}$/.test( prop ) === true ) {
|
|
62
|
+
|
|
63
|
+
// set properties ( swizzle )
|
|
64
|
+
|
|
65
|
+
prop = parseSwizzle( prop.slice( 3 ).toLowerCase() );
|
|
66
|
+
|
|
67
|
+
// sort to xyzw sequence
|
|
68
|
+
|
|
69
|
+
prop = prop.split( '' ).sort().join( '' );
|
|
70
|
+
|
|
71
|
+
return ( value ) => nodeObject( new SetNode( node, prop, value ) );
|
|
72
|
+
|
|
73
|
+
} else if ( prop === 'width' || prop === 'height' || prop === 'depth' ) {
|
|
63
74
|
|
|
64
75
|
// accessing property
|
|
65
76
|
|
|
66
|
-
|
|
77
|
+
if ( prop === 'width' ) prop = 'x';
|
|
78
|
+
else if ( prop === 'height' ) prop = 'y';
|
|
79
|
+
else if ( prop === 'depth' ) prop = 'z';
|
|
80
|
+
|
|
81
|
+
return nodeObject( new SplitNode( node, prop ) );
|
|
67
82
|
|
|
68
83
|
} else if ( /^\d+$/.test( prop ) === true ) {
|
|
69
84
|
|
|
@@ -181,42 +196,86 @@ const ShaderNodeImmutable = function ( NodeClass, ...params ) {
|
|
|
181
196
|
|
|
182
197
|
};
|
|
183
198
|
|
|
184
|
-
class
|
|
199
|
+
class ShaderCallNodeInternal extends Node {
|
|
185
200
|
|
|
186
|
-
constructor(
|
|
201
|
+
constructor( shaderNode, inputNodes ) {
|
|
187
202
|
|
|
188
203
|
super();
|
|
189
204
|
|
|
190
|
-
this.
|
|
205
|
+
this.shaderNode = shaderNode;
|
|
206
|
+
this.inputNodes = inputNodes;
|
|
191
207
|
|
|
192
208
|
}
|
|
193
209
|
|
|
194
|
-
|
|
210
|
+
getNodeType( builder ) {
|
|
195
211
|
|
|
196
|
-
|
|
212
|
+
const { outputNode } = builder.getNodeProperties( this );
|
|
197
213
|
|
|
198
|
-
return
|
|
214
|
+
return outputNode ? outputNode.getNodeType( builder ) : super.getNodeType( builder );
|
|
199
215
|
|
|
200
216
|
}
|
|
201
217
|
|
|
202
|
-
|
|
218
|
+
call( builder ) {
|
|
203
219
|
|
|
204
|
-
const {
|
|
220
|
+
const { shaderNode, inputNodes } = this;
|
|
205
221
|
|
|
206
|
-
|
|
222
|
+
const jsFunc = shaderNode.jsFunc;
|
|
223
|
+
const outputNode = inputNodes !== null ? jsFunc( nodeObjects( inputNodes ), builder.stack, builder ) : jsFunc( builder.stack, builder );
|
|
224
|
+
|
|
225
|
+
return nodeObject( outputNode );
|
|
207
226
|
|
|
208
227
|
}
|
|
209
228
|
|
|
210
|
-
|
|
229
|
+
setup( builder ) {
|
|
211
230
|
|
|
212
231
|
builder.addStack();
|
|
213
232
|
|
|
214
|
-
builder.stack.outputNode =
|
|
233
|
+
builder.stack.outputNode = this.call( builder );
|
|
215
234
|
|
|
216
235
|
return builder.removeStack();
|
|
217
236
|
|
|
218
237
|
}
|
|
219
238
|
|
|
239
|
+
generate( builder, output ) {
|
|
240
|
+
|
|
241
|
+
const { outputNode } = builder.getNodeProperties( this );
|
|
242
|
+
|
|
243
|
+
if ( outputNode === null ) {
|
|
244
|
+
|
|
245
|
+
// TSL: It's recommended to use `tslFn` in setup() pass.
|
|
246
|
+
|
|
247
|
+
return this.call( builder ).build( builder, output );
|
|
248
|
+
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return super.generate( builder, output );
|
|
252
|
+
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
class ShaderNodeInternal extends Node {
|
|
258
|
+
|
|
259
|
+
constructor( jsFunc ) {
|
|
260
|
+
|
|
261
|
+
super();
|
|
262
|
+
|
|
263
|
+
this.jsFunc = jsFunc;
|
|
264
|
+
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
call( inputs = null ) {
|
|
268
|
+
|
|
269
|
+
return nodeObject( new ShaderCallNodeInternal( this, inputs ) );
|
|
270
|
+
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
setup() {
|
|
274
|
+
|
|
275
|
+
return this.call();
|
|
276
|
+
|
|
277
|
+
}
|
|
278
|
+
|
|
220
279
|
}
|
|
221
280
|
|
|
222
281
|
const bools = [ false, true ];
|
|
@@ -334,19 +393,13 @@ export const shader = ( jsFunc ) => { // @deprecated, r154
|
|
|
334
393
|
|
|
335
394
|
export const tslFn = ( jsFunc ) => {
|
|
336
395
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
return ( ...params ) => {
|
|
340
|
-
|
|
341
|
-
if ( shaderNode === null ) shaderNode = new ShaderNode( jsFunc );
|
|
342
|
-
|
|
343
|
-
return shaderNode.call( ...params );
|
|
396
|
+
const shaderNode = new ShaderNode( jsFunc );
|
|
344
397
|
|
|
345
|
-
|
|
398
|
+
return ( inputs ) => shaderNode.call( inputs );
|
|
346
399
|
|
|
347
400
|
};
|
|
348
401
|
|
|
349
|
-
addNodeClass( ShaderNode );
|
|
402
|
+
addNodeClass( 'ShaderNode', ShaderNode );
|
|
350
403
|
|
|
351
404
|
// types
|
|
352
405
|
// @TODO: Maybe export from ConstNode.js?
|
|
@@ -13,7 +13,7 @@ class EquirectUVNode extends TempNode {
|
|
|
13
13
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
setup() {
|
|
17
17
|
|
|
18
18
|
const dir = this.dirNode;
|
|
19
19
|
|
|
@@ -30,4 +30,4 @@ export default EquirectUVNode;
|
|
|
30
30
|
|
|
31
31
|
export const equirectUV = nodeProxy( EquirectUVNode );
|
|
32
32
|
|
|
33
|
-
addNodeClass( EquirectUVNode );
|
|
33
|
+
addNodeClass( 'EquirectUVNode', EquirectUVNode );
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Node, { addNodeClass } from '../core/Node.js';
|
|
2
2
|
import { expression } from '../code/ExpressionNode.js';
|
|
3
3
|
import { bypass } from '../core/BypassNode.js';
|
|
4
|
-
import { context
|
|
4
|
+
import { context } from '../core/ContextNode.js';
|
|
5
5
|
import { addNodeElement, nodeObject, nodeArray } from '../shadernode/ShaderNode.js';
|
|
6
6
|
|
|
7
7
|
class LoopNode extends Node {
|
|
@@ -53,9 +53,9 @@ class LoopNode extends Node {
|
|
|
53
53
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
setup( builder ) {
|
|
57
57
|
|
|
58
|
-
//
|
|
58
|
+
// setup properties
|
|
59
59
|
|
|
60
60
|
this.getProperties( builder );
|
|
61
61
|
|
|
@@ -65,13 +65,11 @@ class LoopNode extends Node {
|
|
|
65
65
|
|
|
66
66
|
const properties = this.getProperties( builder );
|
|
67
67
|
|
|
68
|
-
const
|
|
68
|
+
const contextData = { tempWrite: false };
|
|
69
69
|
|
|
70
70
|
const params = this.params;
|
|
71
71
|
const stackNode = properties.stackNode;
|
|
72
72
|
|
|
73
|
-
const returnsSnippet = properties.returnsNode ? properties.returnsNode.build( builder ) : '';
|
|
74
|
-
|
|
75
73
|
for ( let i = 0, l = params.length - 1; i < l; i ++ ) {
|
|
76
74
|
|
|
77
75
|
const param = params[ i ];
|
|
@@ -82,7 +80,7 @@ class LoopNode extends Node {
|
|
|
82
80
|
if ( param.isNode ) {
|
|
83
81
|
|
|
84
82
|
start = '0';
|
|
85
|
-
end = param.
|
|
83
|
+
end = param.build( builder, 'int' );
|
|
86
84
|
direction = 'forward';
|
|
87
85
|
|
|
88
86
|
} else {
|
|
@@ -92,10 +90,10 @@ class LoopNode extends Node {
|
|
|
92
90
|
direction = param.direction;
|
|
93
91
|
|
|
94
92
|
if ( typeof start === 'number' ) start = start.toString();
|
|
95
|
-
else if ( start && start.isNode ) start = start.
|
|
93
|
+
else if ( start && start.isNode ) start = start.build( builder, 'int' );
|
|
96
94
|
|
|
97
95
|
if ( typeof end === 'number' ) end = end.toString();
|
|
98
|
-
else if ( end && end.isNode ) end = end.
|
|
96
|
+
else if ( end && end.isNode ) end = end.build( builder, 'int' );
|
|
99
97
|
|
|
100
98
|
if ( start !== undefined && end === undefined ) {
|
|
101
99
|
|
|
@@ -159,7 +157,9 @@ class LoopNode extends Node {
|
|
|
159
157
|
|
|
160
158
|
}
|
|
161
159
|
|
|
162
|
-
const stackSnippet =
|
|
160
|
+
const stackSnippet = context( stackNode, contextData ).build( builder, 'void' );
|
|
161
|
+
|
|
162
|
+
const returnsSnippet = properties.returnsNode ? properties.returnsNode.build( builder ) : '';
|
|
163
163
|
|
|
164
164
|
builder.removeFlowTab().addFlowCode( '\n' + builder.tab + stackSnippet );
|
|
165
165
|
|
|
@@ -183,4 +183,4 @@ export const loop = ( ...params ) => nodeObject( new LoopNode( nodeArray( params
|
|
|
183
183
|
|
|
184
184
|
addNodeElement( 'loop', ( returns, ...params ) => bypass( returns, loop( ...params ) ) );
|
|
185
185
|
|
|
186
|
-
addNodeClass( LoopNode );
|
|
186
|
+
addNodeClass( 'LoopNode', LoopNode );
|
|
@@ -12,7 +12,7 @@ class MatcapUVNode extends TempNode {
|
|
|
12
12
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
setup() {
|
|
16
16
|
|
|
17
17
|
const x = vec3( positionViewDirection.z, 0, positionViewDirection.x.negate() ).normalize();
|
|
18
18
|
const y = positionViewDirection.cross( x );
|
|
@@ -27,4 +27,4 @@ export default MatcapUVNode;
|
|
|
27
27
|
|
|
28
28
|
export const matcapUV = nodeImmutable( MatcapUVNode );
|
|
29
29
|
|
|
30
|
-
addNodeClass( MatcapUVNode );
|
|
30
|
+
addNodeClass( 'MatcapUVNode', MatcapUVNode );
|
|
@@ -19,7 +19,7 @@ class OscNode extends Node {
|
|
|
19
19
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
setup() {
|
|
23
23
|
|
|
24
24
|
const method = this.method;
|
|
25
25
|
const timeNode = nodeObject( this.timeNode );
|
|
@@ -78,4 +78,4 @@ export const oscSquare = nodeProxy( OscNode, OscNode.SQUARE );
|
|
|
78
78
|
export const oscTriangle = nodeProxy( OscNode, OscNode.TRIANGLE );
|
|
79
79
|
export const oscSawtooth = nodeProxy( OscNode, OscNode.SAWTOOTH );
|
|
80
80
|
|
|
81
|
-
addNodeClass( OscNode );
|
|
81
|
+
addNodeClass( 'OscNode', OscNode );
|
|
@@ -19,7 +19,7 @@ class PackingNode extends TempNode {
|
|
|
19
19
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
setup() {
|
|
23
23
|
|
|
24
24
|
const { scope, node } = this;
|
|
25
25
|
|
|
@@ -52,4 +52,4 @@ export const colorToDirection = nodeProxy( PackingNode, PackingNode.COLOR_TO_DIR
|
|
|
52
52
|
addNodeElement( 'directionToColor', directionToColor );
|
|
53
53
|
addNodeElement( 'colorToDirection', colorToDirection );
|
|
54
54
|
|
|
55
|
-
addNodeClass( PackingNode );
|
|
55
|
+
addNodeClass( 'PackingNode', PackingNode );
|
|
@@ -17,7 +17,7 @@ class RemapNode extends Node {
|
|
|
17
17
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
setup() {
|
|
21
21
|
|
|
22
22
|
const { node, inLowNode, inHighNode, outLowNode, outHighNode, doClamp } = this;
|
|
23
23
|
|
|
@@ -39,4 +39,4 @@ export const remapClamp = nodeProxy( RemapNode );
|
|
|
39
39
|
addNodeElement( 'remap', remap );
|
|
40
40
|
addNodeElement( 'remapClamp', remapClamp );
|
|
41
41
|
|
|
42
|
-
addNodeClass( RemapNode );
|
|
42
|
+
addNodeClass( 'RemapNode', RemapNode );
|
|
@@ -14,7 +14,7 @@ class RotateUVNode extends TempNode {
|
|
|
14
14
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
setup() {
|
|
18
18
|
|
|
19
19
|
const { uvNode, rotationNode, centerNode } = this;
|
|
20
20
|
|
|
@@ -40,4 +40,4 @@ export const rotateUV = nodeProxy( RotateUVNode );
|
|
|
40
40
|
|
|
41
41
|
addNodeElement( 'rotateUV', rotateUV );
|
|
42
42
|
|
|
43
|
-
addNodeClass( RotateUVNode );
|
|
43
|
+
addNodeClass( 'RotateUVNode', RotateUVNode );
|