ResolutionNode.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. import { Vector2 } from '../../../../build/three.module.js';
  5. import { Vector2Node } from '../inputs/Vector2Node.js';
  6. function ResolutionNode() {
  7. Vector2Node.call( this );
  8. this.size = new Vector2();
  9. }
  10. ResolutionNode.prototype = Object.create( Vector2Node.prototype );
  11. ResolutionNode.prototype.constructor = ResolutionNode;
  12. ResolutionNode.prototype.nodeType = "Resolution";
  13. ResolutionNode.prototype.updateFrame = function ( frame ) {
  14. if ( frame.renderer ) {
  15. frame.renderer.getSize( this.size );
  16. var pixelRatio = frame.renderer.getPixelRatio();
  17. this.x = this.size.width * pixelRatio;
  18. this.y = this.size.height * pixelRatio;
  19. } else {
  20. console.warn( "ResolutionNode need a renderer in NodeFrame" );
  21. }
  22. };
  23. ResolutionNode.prototype.copy = function ( source ) {
  24. Vector2Node.prototype.copy.call( this, source );
  25. this.renderer = source.renderer;
  26. return this;
  27. };
  28. ResolutionNode.prototype.toJSON = function ( meta ) {
  29. var data = this.getJSONNode( meta );
  30. if ( ! data ) {
  31. data = this.createJSONNode( meta );
  32. data.renderer = this.renderer.uuid;
  33. }
  34. return data;
  35. };
  36. export { ResolutionNode };