@awayjs/view
Version:
View for AwayJS
78 lines (77 loc) • 3.71 kB
JavaScript
import { __extends } from "tslib";
import { AbstractMethodError, AbstractionBase, TransformEvent } from '@awayjs/core';
import { ContainerNodeEvent } from '../events/ContainerNodeEvent';
var BoundingVolumeBase = /** @class */ (function (_super) {
__extends(BoundingVolumeBase, _super);
function BoundingVolumeBase() {
return _super !== null && _super.apply(this, arguments) || this;
}
//protected _boundsPrimitive:Sprite;
BoundingVolumeBase.prototype.init = function (targetCoordinateSpace, pool) {
var _this = this;
_super.prototype.init.call(this, targetCoordinateSpace, pool);
var picker = pool.picker;
this._strokeFlag = pool.strokeFlag;
this._fastFlag = pool.fastFlag;
this._onInvalidateMatrix3DDelegate = function (event) { return _this._onInvalidateMatrix3D(event); };
if (targetCoordinateSpace != picker.node) {
var targetEntity = picker.node;
while (targetEntity && targetEntity != targetCoordinateSpace) {
targetEntity.container.transform.addEventListener(TransformEvent.INVALIDATE_MATRIX3D, this._onInvalidateMatrix3DDelegate);
targetEntity = targetEntity.parent;
}
if (!targetEntity) //case when targetCoordinateSpace is not part of the same displaylist ancestry
targetCoordinateSpace.addEventListener(ContainerNodeEvent.INVALIDATE_MATRIX3D, this._onInvalidateMatrix3DDelegate);
}
};
BoundingVolumeBase.prototype._onInvalidateMatrix3D = function (event) {
this._invalid = true;
};
BoundingVolumeBase.prototype.onClear = function () {
var _a;
var targetCoordinateSpace = this._asset;
var picker = this._pool.picker;
if (picker && targetCoordinateSpace != picker.node) {
var targetEntity = picker.node;
while (targetEntity && targetEntity != targetCoordinateSpace) {
(_a = targetEntity.container) === null || _a === void 0 ? void 0 : _a.transform.removeEventListener(TransformEvent.INVALIDATE_MATRIX3D, this._onInvalidateMatrix3DDelegate);
targetEntity = targetEntity.parent;
}
if (!targetEntity) //case when targetCoordinateSpace is not part of the same displaylist ancestry
targetCoordinateSpace.removeEventListener(ContainerNodeEvent.INVALIDATE_MATRIX3D, this._onInvalidateMatrix3DDelegate);
}
_super.prototype.onClear.call(this);
//this._boundsPrimitive = null;
};
// public get boundsPrimitive():DisplayObject
// {
// if (this._boundsPrimitive == null) {
// this._boundsPrimitive = this._createBoundsPrimitive();
// this._invalid = true;
// }
// if(this._invalid)
// this._update();
// this._boundsPrimitive.transform.matrix3D = this._boundingEntity.transform.concatenatedMatrix3D;
// return this._boundsPrimitive;
// }
BoundingVolumeBase.prototype.nullify = function () {
throw new AbstractMethodError();
};
BoundingVolumeBase.prototype.isInFrustum = function (planes, numPlanes) {
throw new AbstractMethodError();
};
BoundingVolumeBase.prototype.clone = function () {
throw new AbstractMethodError();
};
BoundingVolumeBase.prototype.rayIntersection = function (position, direction, targetNormal) {
return -1;
};
BoundingVolumeBase.prototype.classifyToPlane = function (plane) {
throw new AbstractMethodError();
};
BoundingVolumeBase.prototype._update = function () {
this._invalid = false;
};
return BoundingVolumeBase;
}(AbstractionBase));
export { BoundingVolumeBase };