Vector4Node.js 1.0 KB

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