r3-legacy/src/r3-renderer-d3-canvas-0.js

96 lines
2.2 KiB
JavaScript

/**
* R3.Renderer.D3.Canvas
* @param apiComponent
* @param inherited
* @constructor
*/
R3.Renderer.D3.Canvas = function(
apiComponent,
inherited
) {
__INHERIT_AND_INSTANTIATE__
this.linkedComponents.canvas = R3.Canvas;
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);
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);
};
/**
* Return the aspect ratio of the canvas
* @returns {*}
*/
R3.Renderer.D3.Canvas.prototype.getCanvasAspectRatio = function() {
return R3.API.Renderer.D3.Canvas.prototype.getCanvasAspectRatio.call(this);
};
/**
* Returns the size information of the canvas
* @returns {{width, aspectRatio, height}}
*/
R3.Renderer.D3.Canvas.prototype.getCanvasSize = function() {
return R3.API.Renderer.D3.Canvas.prototype.getCanvasSize.call(this);
};