NoiseNode.js 771 B

123456789101112131415161718192021222324252627282930313233343536373839
  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.toJSON = function ( meta ) {
  16. var data = this.getJSONNode( meta );
  17. if ( ! data ) {
  18. data = this.createJSONNode( meta );
  19. data.coord = this.coord.toJSON( meta ).uuid;
  20. }
  21. return data;
  22. };