import { Utils } from '../common/Utils'
import { BasePoints } from './BasePoints';
/**
* @class PixelLineSegments
* The pixel line segments object.
* @memberof THING
* @extends THING.BasePoints
* @public
*/
class PixelLineSegments extends BasePoints {
static defaultTagArray = ['Line'];
/**
* The pixel line segments that with points and colors in scene.
* @param {Object} param The initial parameters.
*/
constructor(param = {}) {
super(param);
this._syncOptions(param);
}
// #region Private Functions
_updateSize(points) {
let bodyNode = this.bodyNode;
if (bodyNode.getSize() < points.length) {
bodyNode.setSize(points.length * 2);
}
}
_syncOptions(param) {
super.onSyncOptions(param);
}
// #endregion
// #region Overrides
onBeforeSetup(param) {
param['renderableNode'] = param['renderableNode'] || Utils.createObject('LineSegments');
super.onBeforeSetup(param);
}
onAfterSetup(param) {
super.onAfterSetup(param);
}
onGetSelfPoints(selfPoints) {
this._updateSize(selfPoints);
return selfPoints;
}
onRefreshPoints() {
let points = super.onRefreshPoints();
this._updateSize(points);
this.bodyNode.setColors(points.map(point => { return [1, 1, 1]; }));
}
onImportExternalData(external, options) {
super.onImportExternalData(external, options);
if (external) {
this._syncOptions(external);
}
}
// #endregion
// #region Accessor
// #endregion
/**
* Check whether it's PixelLineSegments type or inherit from it.
* @type {Boolean}
*/
get isPixelLineSegments() {
return true;
}
}
export { PixelLineSegments }