three 基础库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
913 B

2 years ago
import { Vector2 } from '../../../../build/three.module.js';
import { Vector2Node } from '../inputs/Vector2Node.js';
class ResolutionNode extends Vector2Node {
constructor() {
super();
this.size = new Vector2();
}
updateFrame( frame ) {
if ( frame.renderer ) {
frame.renderer.getSize( this.size );
const pixelRatio = frame.renderer.getPixelRatio();
this.x = this.size.width * pixelRatio;
this.y = this.size.height * pixelRatio;
} else {
console.warn( 'ResolutionNode need a renderer in NodeFrame' );
}
}
copy( source ) {
super.copy( source );
this.renderer = source.renderer;
return this;
}
toJSON( meta ) {
let data = this.getJSONNode( meta );
if ( ! data ) {
data = this.createJSONNode( meta );
data.renderer = this.renderer.uuid;
}
return data;
}
}
ResolutionNode.prototype.nodeType = 'Resolution';
export { ResolutionNode };