ResolutionNode.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. this.size = new THREE.Vector2();
  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. if ( frame.renderer ) {
  14. frame.renderer.getSize( this.size );
  15. var pixelRatio = frame.renderer.getPixelRatio();
  16. this.x = this.size.width * pixelRatio;
  17. this.y = this.size.height * pixelRatio;
  18. } else {
  19. console.warn( "ResolutionNode need a renderer in NodeFrame" );
  20. }
  21. };
  22. ResolutionNode.prototype.copy = function ( source ) {
  23. Vector2Node.prototype.copy.call( this, source );
  24. this.renderer = source.renderer;
  25. };
  26. ResolutionNode.prototype.toJSON = function ( meta ) {
  27. var data = this.getJSONNode( meta );
  28. if ( ! data ) {
  29. data = this.createJSONNode( meta );
  30. data.renderer = this.renderer.uuid;
  31. }
  32. return data;
  33. };
  34. export { ResolutionNode };