Vector3Node.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. THREE.Vector3Node = function ( x, y, z ) {
  5. THREE.InputNode.call( this, 'v3' );
  6. this.value = x instanceof THREE.Vector3 ? x : new THREE.Vector3( x, y, z );
  7. };
  8. THREE.Vector3Node.prototype = Object.create( THREE.InputNode.prototype );
  9. THREE.Vector3Node.prototype.constructor = THREE.Vector3Node;
  10. THREE.Vector3Node.prototype.nodeType = "Vector3";
  11. THREE.NodeMaterial.addShortcuts( THREE.Vector3Node.prototype, 'value', [ 'x', 'y', 'z' ] );
  12. THREE.Vector3Node.prototype.generateReadonly = function ( builder, output, uuid, type, ns, needsUpdate ) {
  13. return builder.format( "vec3( " + this.x + ", " + this.y + ", " + this.z + " )", type, output );
  14. };
  15. THREE.Vector3Node.prototype.copy = function ( source ) {
  16. THREE.InputNode.prototype.copy.call( this, source );
  17. this.value.copy( source );
  18. };
  19. THREE.Vector3Node.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. data.z = this.z;
  26. if ( this.readonly === true ) data.readonly = true;
  27. }
  28. return data;
  29. };