ResolutionNode.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. };
  27. ResolutionNode.prototype.toJSON = function ( meta ) {
  28. var data = this.getJSONNode( meta );
  29. if ( ! data ) {
  30. data = this.createJSONNode( meta );
  31. data.renderer = this.renderer.uuid;
  32. }
  33. return data;
  34. };
  35. export { ResolutionNode };