122 lines
2.5 KiB
JavaScript
122 lines
2.5 KiB
JavaScript
/**
|
|
* R3.D3.Pass.Bloom
|
|
* @param apiComponent
|
|
* @constructor
|
|
*/
|
|
R3.D3.Pass.Bloom = function(
|
|
apiComponent
|
|
) {
|
|
|
|
__RUNTIME_COMPONENT__;
|
|
|
|
R3.D3.Pass.call(this, true);
|
|
};
|
|
|
|
R3.D3.Pass.Bloom.prototype = Object.create(R3.D3.Pass.prototype);
|
|
R3.D3.Pass.Bloom.prototype.constructor = R3.D3.Pass.Bloom;
|
|
|
|
/**
|
|
* Create Pass.Bloom instance
|
|
* @returns {*}
|
|
*/
|
|
R3.D3.Pass.Bloom.prototype.createInstance = function() {
|
|
|
|
|
|
if (this.autoUpdateSize) {
|
|
|
|
if (R3.Utils.Unloaded(this.renderer)) {
|
|
throw new Error('Renderer not loaded but R3.D3.Pass.Bloom.prototype.autoUpdateSize is set - problem with storage or linking system');
|
|
}
|
|
|
|
if (R3.Utils.Unloaded(this.viewport)) {
|
|
throw new Error('Viewport not loaded but R3.D3.Pass.Bloom.prototype.autoUpdateSize is set - problem with storage or linking system');
|
|
}
|
|
|
|
this.setSize();
|
|
|
|
}
|
|
|
|
this.instance = new this.graphics.PassBloom(
|
|
this.size,
|
|
this.strength,
|
|
this.radius,
|
|
this.threshold
|
|
);
|
|
|
|
R3.D3.Pass.prototype.createInstance.call(this);
|
|
|
|
};
|
|
|
|
/**
|
|
* Update Pass.Bloom instance
|
|
*/
|
|
R3.D3.Pass.Bloom.prototype.updateInstance = function(property) {
|
|
|
|
if (
|
|
property === 'autoUpdateSize' ||
|
|
property === 'renderer' ||
|
|
property === 'viewport'
|
|
|
|
) {
|
|
|
|
if (this.autoUpdateSize) {
|
|
|
|
this.setSize();
|
|
|
|
this.graphics.updateInstance(this, 'size');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (property === 'size') {
|
|
|
|
if (this.autoUpdateSize) {
|
|
console.warn('Modifying the width and height while R3.D3.Pass.Bloom.prototype.autoUpdateSize is set has no effect');
|
|
return;
|
|
}
|
|
|
|
this.graphics.updateInstance(this, 'size');
|
|
|
|
return;
|
|
}
|
|
|
|
if (
|
|
property === 'strength' ||
|
|
property === 'radius' ||
|
|
property === 'threshold'
|
|
) {
|
|
this.graphics.updateInstance(this, property);
|
|
return;
|
|
}
|
|
|
|
R3.D3.Pass.prototype.updateInstance.call(this, property);
|
|
|
|
};
|
|
|
|
/**
|
|
* Convenience function to set size
|
|
*/
|
|
R3.D3.Pass.Bloom.prototype.setSize = function() {
|
|
|
|
if (R3.Utils.Unloaded(this.renderer)) {
|
|
console.warn('R3.D3.Pass.Render.Bloom.prototype.renderer unloaded');
|
|
return;
|
|
}
|
|
|
|
if (R3.Utils.Unloaded(this.viewport)) {
|
|
console.warn('R3.D3.Pass.Render.Bloom.prototype.viewport unloaded');
|
|
return;
|
|
}
|
|
|
|
var size = this.renderer.getSize(this.viewport);
|
|
|
|
this.size.x = size.width;
|
|
this.size.y = size.height;
|
|
|
|
};
|