ResolutionNode.js 1.0 KB

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