Vector2Node.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. THREE.Vector2Node = function ( x, y ) {
  5. THREE.InputNode.call( this, 'v2' );
  6. this.value = x instanceof THREE.Vector2 ? x : new THREE.Vector2( x, y );
  7. };
  8. THREE.Vector2Node.prototype = Object.create( THREE.InputNode.prototype );
  9. THREE.Vector2Node.prototype.constructor = THREE.Vector2Node;
  10. THREE.Vector2Node.prototype.nodeType = "Vector2";
  11. THREE.NodeMaterial.addShortcuts( THREE.Vector2Node.prototype, 'value', [ 'x', 'y' ] );
  12. THREE.Vector2Node.prototype.generateReadonly = function ( builder, output, uuid, type, ns, needsUpdate ) {
  13. return builder.format( "vec2( " + this.x + ", " + this.y + " )", type, output );
  14. };
  15. THREE.Vector2Node.prototype.copy = function ( source ) {
  16. THREE.InputNode.prototype.copy.call( this, source );
  17. this.value.copy( source );
  18. };
  19. THREE.Vector2Node.prototype.toJSON = function ( meta ) {
  20. var data = this.getJSONNode( meta );
  21. if ( ! data ) {
  22. data = this.createJSONNode( meta );
  23. data.x = this.x;
  24. data.y = this.y;
  25. if ( this.readonly === true ) data.readonly = true;
  26. }
  27. return data;
  28. };