ResolutionNode.js 994 B

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