InputNode.js 964 字节
Newer Older
S
SUNAG 已提交
1 2 3 4
/**
 * @author sunag / http://www.sunag.com.br/
 */

S
SUNAG 已提交
5 6
THREE.InputNode = function( type, params ) {

S
SUNAG 已提交
7
	THREE.TempNode.call( this, type, params );
S
SUNAG 已提交
8

S
SUNAG 已提交
9 10
};

S
SUNAG 已提交
11 12
THREE.InputNode.prototype = Object.create( THREE.TempNode.prototype );
THREE.InputNode.prototype.constructor = THREE.InputNode;
S
SUNAG 已提交
13

S
SUNAG 已提交
14
THREE.InputNode.prototype.generate = function( builder, output, uuid, type, ns, needsUpdate ) {
S
SUNAG 已提交
15 16 17

	var material = builder.material;

18 19
	uuid = builder.getUuid( uuid || this.getUuid() );
	type = type || this.getType( builder );
S
SUNAG 已提交
20

S
SUNAG 已提交
21
	var data = material.getDataNode( uuid );
S
SUNAG 已提交
22 23 24 25 26

	if ( builder.isShader( 'vertex' ) ) {

		if ( ! data.vertex ) {

27
			data.vertex = material.createVertexUniform( type, this.value, ns, needsUpdate );
S
SUNAG 已提交
28

S
SUNAG 已提交
29
		}
S
SUNAG 已提交
30

S
SUNAG 已提交
31
		return builder.format( data.vertex.name, type, output );
S
SUNAG 已提交
32

S
SUNAG 已提交
33 34
	}
	else {
S
SUNAG 已提交
35 36 37

		if ( ! data.fragment ) {

38
			data.fragment = material.createFragmentUniform( type, this.value, ns, needsUpdate );
S
SUNAG 已提交
39

S
SUNAG 已提交
40
		}
S
SUNAG 已提交
41

S
SUNAG 已提交
42
		return builder.format( data.fragment.name, type, output );
S
SUNAG 已提交
43

S
SUNAG 已提交
44 45
	}

S
SUNAG 已提交
46
};