ResolutionNode.js 913 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { Vector2 } from '../../../../build/three.module.js';
  2. import { Vector2Node } from '../inputs/Vector2Node.js';
  3. class ResolutionNode extends Vector2Node {
  4. constructor() {
  5. super();
  6. this.size = new Vector2();
  7. }
  8. updateFrame( frame ) {
  9. if ( frame.renderer ) {
  10. frame.renderer.getSize( this.size );
  11. const pixelRatio = frame.renderer.getPixelRatio();
  12. this.x = this.size.width * pixelRatio;
  13. this.y = this.size.height * pixelRatio;
  14. } else {
  15. console.warn( 'ResolutionNode need a renderer in NodeFrame' );
  16. }
  17. }
  18. copy( source ) {
  19. super.copy( source );
  20. this.renderer = source.renderer;
  21. return this;
  22. }
  23. toJSON( meta ) {
  24. let data = this.getJSONNode( meta );
  25. if ( ! data ) {
  26. data = this.createJSONNode( meta );
  27. data.renderer = this.renderer.uuid;
  28. }
  29. return data;
  30. }
  31. }
  32. ResolutionNode.prototype.nodeType = 'Resolution';
  33. export { ResolutionNode };