浏览代码

RawNodeMaterial: Fix formatting

Signed-off-by: martinRenou <[email protected]>
martinRenou 5 年之前
父节点
当前提交
3706ce0feb

+ 4 - 4
examples/jsm/nodes/materials/RawNodeMaterial.d.ts

@@ -3,10 +3,10 @@ import { NodeMaterial } from './NodeMaterial';
 
 export class RawNodeMaterial extends NodeMaterial {
 
-  constructor();
+	constructor();
 
-  color: Node;
-  alpha: Node;
-  position: Node;
+	color: Node;
+	alpha: Node;
+	position: Node;
 
 }

+ 6 - 6
examples/jsm/nodes/materials/RawNodeMaterial.js

@@ -8,11 +8,11 @@ import { NodeUtils } from '../core/NodeUtils.js';
 
 function RawNodeMaterial() {
 
-  var node = new SimpleNode();
+	var node = new SimpleNode();
 
-  NodeMaterial.call( this, node, node );
+	NodeMaterial.call( this, node, node );
 
-  this.type = "RawNodeMaterial";
+	this.type = "RawNodeMaterial";
 
 }
 
@@ -20,9 +20,9 @@ RawNodeMaterial.prototype = Object.create( NodeMaterial.prototype );
 RawNodeMaterial.prototype.constructor = RawNodeMaterial;
 
 NodeUtils.addShortcuts( RawNodeMaterial.prototype, 'fragment', [
-  'color',
-  'alpha',
-  'position'
+	'color',
+	'alpha',
+	'position'
 ] );
 
 export { RawNodeMaterial };

+ 7 - 7
examples/jsm/nodes/materials/nodes/SimpleNode.d.ts

@@ -3,14 +3,14 @@ import { Node } from '../../core/Node';
 
 export class SimpleNode extends Node {
 
-  constructor();
+	constructor();
 
-  position: Node;
-  color: Node;
-  alpha: Node;
-  nodeType: string;
+	position: Node;
+	color: Node;
+	alpha: Node;
+	nodeType: string;
 
-  build( builder: NodeBuilder ): string;
-  copy( source: SimpleNode ): this;
+	build( builder: NodeBuilder ): string;
+	copy( source: SimpleNode ): this;
 
 }

+ 71 - 57
examples/jsm/nodes/materials/nodes/SimpleNode.js

@@ -3,12 +3,13 @@
  */
 
 import { Node } from '../../core/Node.js';
+import { ColorNode } from '../../inputs/ColorNode.js';
 
 function SimpleNode() {
 
-  Node.call( this );
+	Node.call( this );
 
-  this.color = new ColorNode( 0xFFFFFF );
+	this.color = new ColorNode( 0xFFFFFF );
 
 }
 
@@ -18,93 +19,106 @@ SimpleNode.prototype.nodeType = "Simple";
 
 SimpleNode.prototype.generate = function ( builder ) {
 
-  var code;
+	var code;
 
-  if (builder.isShader('vertex')) {
+	if ( builder.isShader( 'vertex' ) ) {
 
-    var position = this.position ? this.position.analyzeAndFlow( builder, 'v3', { cache: 'position' } ) : undefined;
+		var position = this.position ? this.position.analyzeAndFlow( builder, 'v3', { cache: 'position' } ) : undefined;
 
-    var output = [
-      "vec3 transformed = position;"
-    ];
+		var output = [
+			"vec3 transformed = position;"
+		];
 
-    if ( position ) {
-      output.push(
-        position.code,
-        position.result ? "gl_Position = " + position.result + ";" : ''
-      );
-    } else {
-      output.push( "gl_Position = projectionMatrix * modelViewMatrix * vec4(transformed, 1.0)" );
-    }
+		if ( position ) {
 
-    code = output.join("\n");
-  } else {
-    // Analyze all nodes to reuse generate codes
-    this.color.analyze( builder, { slot: 'color' } );
+			output.push(
+				position.code,
+				position.result ? "gl_Position = " + position.result + ";" : ''
+			);
 
-    if ( this.alpha ) this.alpha.analyze( builder );
+		} else {
 
-    // Build code
-    var color = this.color.flow(builder, 'c', { slot: 'color' });
-    var alpha = this.alpha ? this.alpha.flow( builder, 'f' ) : undefined;
+			output.push( "gl_Position = projectionMatrix * modelViewMatrix * vec4(transformed, 1.0)" );
 
-    builder.requires.transparent = alpha !== undefined;
+		}
 
-    var output = [
-      color.code,
-    ];
+		code = output.join( "\n" );
 
-    if ( alpha ) {
-      output.push(
-        alpha.code,
-        '#ifdef ALPHATEST',
+	} else {
 
-        ' if ( ' + alpha.result + ' <= ALPHATEST ) discard;',
+		// Analyze all nodes to reuse generate codes
+		this.color.analyze( builder, { slot: 'color' } );
 
-        '#endif'
-      );
-    }
+		if ( this.alpha ) this.alpha.analyze( builder );
 
-    if ( alpha ) {
-      output.push( "gl_FragColor = vec4(" + color.result + ", " + alpha.result + " );" );
-    } else {
-      output.push( "gl_FragColor = vec4(" + color.result + ", 1.0 );" );
-    }
+		// Build code
+		var color = this.color.flow( builder, 'c', { slot: 'color' } );
+		var alpha = this.alpha ? this.alpha.flow( builder, 'f' ) : undefined;
 
-    code = output.join( "\n" );
-  }
+		builder.requires.transparent = alpha !== undefined;
 
-  return code;
+		var output = [
+			color.code,
+		];
+
+		if ( alpha ) {
+
+			output.push(
+				alpha.code,
+				'#ifdef ALPHATEST',
+
+				' if ( ' + alpha.result + ' <= ALPHATEST ) discard;',
+
+				'#endif'
+			);
+
+		}
+
+		if ( alpha ) {
+
+			output.push( "gl_FragColor = vec4(" + color.result + ", " + alpha.result + " );" );
+
+		} else {
+
+			output.push( "gl_FragColor = vec4(" + color.result + ", 1.0 );" );
+
+		}
+
+		code = output.join( "\n" );
+
+	}
+
+	return code;
 
 };
 
 SimpleNode.prototype.copy = function ( source ) {
 
-  Node.prototype.copy.call( this, source );
+	Node.prototype.copy.call( this, source );
 
-  this.position = source.position;
-  this.color = source.color;
-  this.alpha = source.alpha;
+	this.position = source.position;
+	this.color = source.color;
+	this.alpha = source.alpha;
 
-  return this;
+	return this;
 
 };
 
 SimpleNode.prototype.toJSON = function ( meta ) {
 
-  var data = this.getJSONNode( meta );
+	var data = this.getJSONNode( meta );
 
-  if ( ! data ) {
+	if ( ! data ) {
 
-    data = this.createJSONNode( meta );
+		data = this.createJSONNode( meta );
 
-    data.position = this.position.toJSON( meta ).uuid;
-    data.color = this.color.toJSON( meta ).uuid;
-    data.alpha = this.alpha.toJSON( meta ).uuid;
+		data.position = this.position.toJSON( meta ).uuid;
+		data.color = this.color.toJSON( meta ).uuid;
+		data.alpha = this.alpha.toJSON( meta ).uuid;
 
-  }
+	}
 
-  return data;
+	return data;
 
 };