2019-07-24 08:08:02 +02:00
|
|
|
/**
|
|
|
|
* R3.Renderer.D3.Canvas
|
2019-08-07 05:17:41 +02:00
|
|
|
* @param apiComponent
|
2019-10-06 21:11:18 +02:00
|
|
|
* @param inherited
|
2019-07-24 08:08:02 +02:00
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
R3.Renderer.D3.Canvas = function(
|
2019-08-07 05:17:41 +02:00
|
|
|
apiComponent,
|
2019-10-06 21:11:18 +02:00
|
|
|
inherited
|
2019-07-24 08:08:02 +02:00
|
|
|
) {
|
|
|
|
|
2019-10-15 22:21:34 +02:00
|
|
|
__INHERIT_AND_INSTANTIATE__
|
2019-10-06 21:11:18 +02:00
|
|
|
|
2019-10-15 22:21:34 +02:00
|
|
|
this.linkedComponents.canvas = R3.Canvas;
|
2019-10-06 21:11:18 +02:00
|
|
|
|
|
|
|
R3.Renderer.D3.call(
|
2019-07-24 08:08:02 +02:00
|
|
|
this,
|
2019-10-06 21:11:18 +02:00
|
|
|
true
|
2019-07-24 08:08:02 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-08-07 05:17:41 +02:00
|
|
|
R3.Renderer.D3.Canvas.prototype = Object.create(R3.Renderer.D3.prototype);
|
|
|
|
R3.Renderer.D3.Canvas.prototype.constructor = R3.Renderer.D3.Canvas;
|
2019-07-24 08:08:02 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create R3.Renderer.D3 Instance
|
|
|
|
* @returns {*}
|
|
|
|
*/
|
2019-08-07 05:17:41 +02:00
|
|
|
R3.Renderer.D3.Canvas.prototype.createInstance = function() {
|
2019-07-24 08:08:02 +02:00
|
|
|
|
|
|
|
if (
|
|
|
|
R3.Utils.UndefinedOrNull(this.canvas) ||
|
|
|
|
R3.Utils.UndefinedOrNull(this.canvas.instance)
|
|
|
|
) {
|
2019-08-07 05:17:41 +02:00
|
|
|
console.warn('no canvas instance or canvas not ready');
|
2019-07-24 08:08:02 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-10-15 22:21:34 +02:00
|
|
|
this.instance = this.graphics.Renderer3D(this);
|
2019-07-24 08:08:02 +02:00
|
|
|
|
2019-08-07 05:17:41 +02:00
|
|
|
R3.Renderer.D3.prototype.createInstance.call(this);
|
2019-07-24 08:08:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update Renderer.D3 Instance
|
|
|
|
*/
|
2019-08-07 05:17:41 +02:00
|
|
|
R3.Renderer.D3.Canvas.prototype.updateInstance = function(property) {
|
2019-07-24 08:08:02 +02:00
|
|
|
|
|
|
|
if (property === 'canvas') {
|
|
|
|
|
2019-08-07 05:17:41 +02:00
|
|
|
if (this.canvas && this.canvas.instance) {
|
2019-07-24 08:08:02 +02:00
|
|
|
this.instance.dispose();
|
|
|
|
this.createInstance();
|
|
|
|
|
2019-08-07 05:17:41 +02:00
|
|
|
R3.Event.Emit(
|
|
|
|
R3.Event.RENDERER_SIZE_CHANGE,
|
|
|
|
this
|
|
|
|
)
|
2019-07-24 08:08:02 +02:00
|
|
|
|
2019-08-07 05:17:41 +02:00
|
|
|
} else {
|
|
|
|
/**
|
|
|
|
* The canvas object was unassigned
|
|
|
|
*/
|
|
|
|
console.warn('The canvas object was unassigned - this will break something - do not save now')
|
2019-07-24 08:08:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-07 05:17:41 +02:00
|
|
|
R3.Renderer.D3.prototype.updateInstance.call(this, property);
|
2019-07-24 08:08:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2019-08-07 05:17:41 +02:00
|
|
|
* Return the size of the canvas
|
|
|
|
* @returns {{width: *, height: *}}
|
2019-07-24 08:08:02 +02:00
|
|
|
*/
|
2019-08-07 05:17:41 +02:00
|
|
|
R3.Renderer.D3.Canvas.prototype.getSize = function() {
|
|
|
|
return R3.API.Renderer.D3.Canvas.prototype.getSize.call(this);
|
|
|
|
};
|