93 lines
2.0 KiB
JavaScript
93 lines
2.0 KiB
JavaScript
|
/**
|
||
|
* R3.Renderer.D3.Canvas
|
||
|
* @param apiComponent
|
||
|
* @param inherited
|
||
|
* @constructor
|
||
|
*/
|
||
|
R3.Renderer.D3.Canvas = function(
|
||
|
apiComponent,
|
||
|
inherited
|
||
|
) {
|
||
|
|
||
|
if (R3.Utils.UndefinedOrNull(inherited)) {
|
||
|
inherited = false;
|
||
|
}
|
||
|
|
||
|
if (!inherited) {
|
||
|
__RUNTIME_COMPONENT__;
|
||
|
}
|
||
|
|
||
|
R3.Renderer.D3.call(
|
||
|
this,
|
||
|
true
|
||
|
);
|
||
|
|
||
|
};
|
||
|
|
||
|
R3.Renderer.D3.Canvas.prototype = Object.create(R3.Renderer.D3.prototype);
|
||
|
R3.Renderer.D3.Canvas.prototype.constructor = R3.Renderer.D3.Canvas;
|
||
|
|
||
|
/**
|
||
|
* Create R3.Renderer.D3 Instance
|
||
|
* @returns {*}
|
||
|
*/
|
||
|
R3.Renderer.D3.Canvas.prototype.createInstance = function() {
|
||
|
|
||
|
if (
|
||
|
R3.Utils.UndefinedOrNull(this.canvas) ||
|
||
|
R3.Utils.UndefinedOrNull(this.canvas.instance)
|
||
|
) {
|
||
|
console.warn('no canvas instance or canvas not ready');
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
this.instance = this.graphics.Renderer3D(
|
||
|
this.canvas,
|
||
|
this.alpha,
|
||
|
this.premultipliedAlpha,
|
||
|
this.antialias,
|
||
|
this.stencil,
|
||
|
this.preserveDrawingBuffer,
|
||
|
this.depth,
|
||
|
this.logarithmicDepthBuffer
|
||
|
);
|
||
|
|
||
|
R3.Renderer.D3.prototype.createInstance.call(this);
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Update Renderer.D3 Instance
|
||
|
*/
|
||
|
R3.Renderer.D3.Canvas.prototype.updateInstance = function(property) {
|
||
|
|
||
|
if (property === 'canvas') {
|
||
|
|
||
|
if (this.canvas && this.canvas.instance) {
|
||
|
this.instance.dispose();
|
||
|
this.createInstance();
|
||
|
|
||
|
R3.Event.Emit(
|
||
|
R3.Event.RENDERER_SIZE_CHANGE,
|
||
|
this
|
||
|
)
|
||
|
|
||
|
} else {
|
||
|
/**
|
||
|
* The canvas object was unassigned
|
||
|
*/
|
||
|
console.warn('The canvas object was unassigned - this will break something - do not save now')
|
||
|
}
|
||
|
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
R3.Renderer.D3.prototype.updateInstance.call(this, property);
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Return the size of the canvas
|
||
|
* @returns {{width: *, height: *}}
|
||
|
*/
|
||
|
R3.Renderer.D3.Canvas.prototype.getSize = function() {
|
||
|
return R3.API.Renderer.D3.Canvas.prototype.getSize.call(this);
|
||
|
};
|