NoiseNode.js 917 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. THREE.NoiseNode = function ( coord ) {
  5. THREE.TempNode.call( this, 'fv1' );
  6. this.coord = coord;
  7. };
  8. THREE.NoiseNode.prototype = Object.create( THREE.TempNode.prototype );
  9. THREE.NoiseNode.prototype.constructor = THREE.NoiseNode;
  10. THREE.NoiseNode.prototype.nodeType = "Noise";
  11. THREE.NoiseNode.prototype.generate = function ( builder, output ) {
  12. builder.include( 'snoise' );
  13. return builder.format( 'snoise(' + this.coord.build( builder, 'v2' ) + ')', this.getType( builder ), output );
  14. };
  15. THREE.NoiseNode.prototype.copy = function ( source ) {
  16. THREE.GLNode.prototype.copy.call( this, source );
  17. this.coord = source.coord;
  18. };
  19. THREE.NoiseNode.prototype.toJSON = function ( meta ) {
  20. var data = this.getJSONNode( meta );
  21. if ( ! data ) {
  22. data = this.createJSONNode( meta );
  23. data.coord = this.coord.toJSON( meta ).uuid;
  24. }
  25. return data;
  26. };