From dbb81cd0b6cf2a03a25de04a9bc4004352b41704 Mon Sep 17 00:00:00 2001 From: sunag Date: Wed, 4 Jul 2018 23:47:29 -0300 Subject: [PATCH] fix node examples --- examples/js/nodes/THREE.Nodes.js | 4 +- examples/js/nodes/accessors/ColorsNode.js | 2 +- examples/js/nodes/materials/NodeMaterial.js | 5 -- .../js/nodes/materials/nodes/SpriteNode.js | 14 ++-- .../js/nodes/materials/nodes/StandardNode.js | 6 +- examples/js/nodes/postprocessing/NodePass.js | 3 +- examples/webgl_loader_nodes.html | 73 +----------------- examples/webgl_materials_nodes.html | 3 +- examples/webgl_mirror_nodes.html | 72 ++---------------- examples/webgl_postprocessing_nodes.html | 68 +++-------------- examples/webgl_sprites_nodes.html | 75 ++----------------- 11 files changed, 46 insertions(+), 279 deletions(-) diff --git a/examples/js/nodes/THREE.Nodes.js b/examples/js/nodes/THREE.Nodes.js index 74cdfb9bab..c146898050 100644 --- a/examples/js/nodes/THREE.Nodes.js +++ b/examples/js/nodes/THREE.Nodes.js @@ -92,7 +92,7 @@ import { StandardNode, MeshStandardNode, - // utils + // materials NodeMaterial, SpriteNodeMaterial, @@ -200,4 +200,4 @@ THREE.NodeMaterial = NodeMaterial; THREE.SpriteNodeMaterial = SpriteNodeMaterial; THREE.PhongNodeMaterial = PhongNodeMaterial; THREE.StandardNodeMaterial = StandardNodeMaterial; -THREE.MeshStandardNodeMaterial = MeshStandardNodeMaterial; \ No newline at end of file +THREE.MeshStandardNodeMaterial = MeshStandardNodeMaterial; diff --git a/examples/js/nodes/accessors/ColorsNode.js b/examples/js/nodes/accessors/ColorsNode.js index 5c95bf991f..14d3738ed0 100644 --- a/examples/js/nodes/accessors/ColorsNode.js +++ b/examples/js/nodes/accessors/ColorsNode.js @@ -21,7 +21,7 @@ ColorsNode.prototype.constructor = ColorsNode; ColorsNode.prototype.generate = function ( builder, output ) { - builder.material.requires.color[ this.index ] = true; + builder.requires.color[ this.index ] = true; var result = builder.isShader( 'vertex' ) ? vertexDict[ this.index ] : fragmentDict[ this.index ]; diff --git a/examples/js/nodes/materials/NodeMaterial.js b/examples/js/nodes/materials/NodeMaterial.js index f1cabe3578..a6e20ded6c 100644 --- a/examples/js/nodes/materials/NodeMaterial.js +++ b/examples/js/nodes/materials/NodeMaterial.js @@ -3,11 +3,6 @@ */ import { NodeBuilder } from '../core/NodeBuilder.js'; -import { NodeUniform } from '../core/NodeUniform.js'; -import { NodeLib } from '../core/NodeLib.js'; -import { FunctionNode } from '../core/FunctionNode.js'; -import { ConstNode } from '../core/ConstNode.js'; -import { StructNode } from '../core/StructNode.js'; import { ColorNode } from '../inputs/ColorNode.js'; import { PositionNode } from '../accessors/PositionNode.js'; import { RawNode } from './nodes/RawNode.js'; diff --git a/examples/js/nodes/materials/nodes/SpriteNode.js b/examples/js/nodes/materials/nodes/SpriteNode.js index 4ca393ac25..83e49f300a 100644 --- a/examples/js/nodes/materials/nodes/SpriteNode.js +++ b/examples/js/nodes/materials/nodes/SpriteNode.js @@ -20,23 +20,22 @@ SpriteNode.prototype.nodeType = "Sprite"; SpriteNode.prototype.build = function ( builder ) { - var material = builder.material; var output, code; - material.define( 'SPRITE' ); + builder.define( 'SPRITE' ); - material.requires.lights = false; - material.requires.transparent = this.alpha != undefined; + builder.requires.lights = false; + builder.requires.transparent = this.alpha != undefined; if ( builder.isShader( 'vertex' ) ) { var transform = this.transform ? this.transform.parseAndBuildCode( builder, 'v3', { cache: 'transform' } ) : undefined; - material.mergeUniform( THREE.UniformsUtils.merge( [ + builder.mergeUniform( THREE.UniformsUtils.merge( [ THREE.UniformsLib[ "fog" ] ] ) ); - material.addVertexPars( [ + builder.addParsCode( [ "#include " ].join( "\n" ) ); @@ -105,13 +104,14 @@ SpriteNode.prototype.build = function ( builder ) { } else { - material.addFragmentPars( [ + builder.addParsCode( [ "#include ", ].join( "\n" ) ); // parse all nodes to reuse generate codes this.color.parse( builder, { slot: 'color' } ); + if ( this.alpha ) this.alpha.parse( builder ); // build code diff --git a/examples/js/nodes/materials/nodes/StandardNode.js b/examples/js/nodes/materials/nodes/StandardNode.js index 26205316ad..212513b195 100644 --- a/examples/js/nodes/materials/nodes/StandardNode.js +++ b/examples/js/nodes/materials/nodes/StandardNode.js @@ -43,7 +43,7 @@ StandardNode.prototype.build = function ( builder ) { ] ) ); - builder.addVertexParsCode( [ + builder.addParsCode( [ "varying vec3 vViewPosition;", "#ifndef FLAT_SHADED", @@ -170,9 +170,9 @@ StandardNode.prototype.build = function ( builder ) { var clearCoatEnv = useClearCoat && environment ? this.environment.buildCode( builder, 'c', { cache: 'clearCoat', context: contextEnvironment, slot: 'environment' } ) : undefined; - builder.requires.transparent = alpha != undefined; + builder.requires.transparent = alpha !== undefined; - builder.addFragmentParsCode( [ + builder.addParsCode( [ "varying vec3 vViewPosition;", diff --git a/examples/js/nodes/postprocessing/NodePass.js b/examples/js/nodes/postprocessing/NodePass.js index 77e36c643f..20d5775b47 100644 --- a/examples/js/nodes/postprocessing/NodePass.js +++ b/examples/js/nodes/postprocessing/NodePass.js @@ -2,6 +2,7 @@ * @author sunag / http://www.sunag.com.br/ */ +import { NodeUtils } from '../core/NodeUtils.js'; import { NodeMaterial } from '../materials/NodeMaterial.js'; import { RawNode } from '../materials/nodes/RawNode.js'; import { ScreenNode } from '../inputs/ScreenNode.js'; @@ -29,7 +30,7 @@ function NodePass() { NodePass.prototype = Object.create( THREE.ShaderPass.prototype ); NodePass.prototype.constructor = NodePass; -NodeMaterial.addShortcuts( NodePass.prototype, 'fragment', [ 'value' ] ); +NodeUtils.addShortcuts( NodePass.prototype, 'fragment', [ 'value' ] ); NodePass.prototype.render = function () { diff --git a/examples/webgl_loader_nodes.html b/examples/webgl_loader_nodes.html index fe7e580acf..c192f21067 100644 --- a/examples/webgl_loader_nodes.html +++ b/examples/webgl_loader_nodes.html @@ -40,75 +40,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -