InputNode.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. THREE.InputNode = function ( type, params ) {
  5. params = params || {};
  6. params.shared = params.shared !== undefined ? params.shared : false;
  7. THREE.TempNode.call( this, type, params );
  8. this.readonly = false;
  9. };
  10. THREE.InputNode.prototype = Object.create( THREE.TempNode.prototype );
  11. THREE.InputNode.prototype.constructor = THREE.InputNode;
  12. THREE.InputNode.prototype.generate = function ( builder, output, uuid, type, ns, needsUpdate ) {
  13. var material = builder.material;
  14. uuid = builder.getUuid( uuid || this.getUuid() );
  15. type = type || this.getType( builder );
  16. var data = material.getDataNode( uuid ),
  17. readonly = this.readonly && this.generateReadonly !== undefined;
  18. if ( readonly ) {
  19. return this.generateReadonly( builder, output, uuid, type, ns, needsUpdate );
  20. } else {
  21. if ( builder.isShader( 'vertex' ) ) {
  22. if ( ! data.vertex ) {
  23. data.vertex = material.createVertexUniform( type, this.value, ns, needsUpdate );
  24. }
  25. return builder.format( data.vertex.name, type, output );
  26. } else {
  27. if ( ! data.fragment ) {
  28. data.fragment = material.createFragmentUniform( type, this.value, ns, needsUpdate );
  29. }
  30. return builder.format( data.fragment.name, type, output );
  31. }
  32. }
  33. };