Vector4Node.js 1.2 KB

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