ResolutionNode.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { Vector2 } from '../../../../build/three.module.js';
  2. import { Vector2Node } from '../inputs/Vector2Node.js';
  3. function ResolutionNode() {
  4. Vector2Node.call( this );
  5. this.size = new Vector2();
  6. }
  7. ResolutionNode.prototype = Object.create( Vector2Node.prototype );
  8. ResolutionNode.prototype.constructor = ResolutionNode;
  9. ResolutionNode.prototype.nodeType = 'Resolution';
  10. ResolutionNode.prototype.updateFrame = function ( frame ) {
  11. if ( frame.renderer ) {
  12. frame.renderer.getSize( this.size );
  13. var pixelRatio = frame.renderer.getPixelRatio();
  14. this.x = this.size.width * pixelRatio;
  15. this.y = this.size.height * pixelRatio;
  16. } else {
  17. console.warn( 'ResolutionNode need a renderer in NodeFrame' );
  18. }
  19. };
  20. ResolutionNode.prototype.copy = function ( source ) {
  21. Vector2Node.prototype.copy.call( this, source );
  22. this.renderer = source.renderer;
  23. return this;
  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 };