2
0

Vector4Node.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. import { InputNode } from '../core/InputNode.js';
  5. import { NodeUtils } from '../core/NodeUtils.js';
  6. function Vector4Node( x, y, z, w ) {
  7. InputNode.call( this, 'v4' );
  8. this.value = x instanceof THREE.Vector4 ? x : new THREE.Vector4( x, y, z, w );
  9. };
  10. Vector4Node.prototype = Object.create( InputNode.prototype );
  11. Vector4Node.prototype.constructor = Vector4Node;
  12. Vector4Node.prototype.nodeType = "Vector4";
  13. NodeUtils.addShortcuts( Vector4Node.prototype, 'value', [ 'x', 'y', 'z', 'w' ] );
  14. Vector4Node.prototype.generateReadonly = function ( builder, output, uuid, type, ns, needsUpdate ) {
  15. return builder.format( "vec4( " + this.x + ", " + this.y + ", " + this.z + ", " + this.w + " )", type, output );
  16. };
  17. Vector4Node.prototype.copy = function ( source ) {
  18. InputNode.prototype.copy.call( this, source );
  19. this.value.copy( source );
  20. };
  21. Vector4Node.prototype.toJSON = function ( meta ) {
  22. var data = this.getJSONNode( meta );
  23. if ( ! data ) {
  24. data = this.createJSONNode( meta );
  25. data.x = this.x;
  26. data.y = this.y;
  27. data.z = this.z;
  28. data.w = this.w;
  29. if ( this.readonly === true ) data.readonly = true;
  30. }
  31. return data;
  32. };
  33. export { Vector4Node };