|
@@ -1244,8 +1244,8 @@ var INSPECTOR;
|
|
|
(function (INSPECTOR) {
|
|
|
var MeshAdapter = /** @class */ (function (_super) {
|
|
|
__extends(MeshAdapter, _super);
|
|
|
- function MeshAdapter(obj) {
|
|
|
- return _super.call(this, obj) || this;
|
|
|
+ function MeshAdapter(mesh) {
|
|
|
+ return _super.call(this, mesh) || this;
|
|
|
}
|
|
|
/** Returns the name displayed in the tree */
|
|
|
MeshAdapter.prototype.id = function () {
|
|
@@ -1286,13 +1286,15 @@ var INSPECTOR;
|
|
|
MeshAdapter.prototype.setBoxVisible = function (b) {
|
|
|
return this._obj.showBoundingBox = b;
|
|
|
};
|
|
|
- MeshAdapter.prototype.debug = function (b) {
|
|
|
+ MeshAdapter.prototype.debug = function (enable) {
|
|
|
// Draw axis the first time
|
|
|
if (!this._axesViewer) {
|
|
|
this._drawAxis();
|
|
|
}
|
|
|
// Display or hide axis
|
|
|
- if (!b && this._axesViewer) {
|
|
|
+ if (!enable && this._axesViewer) {
|
|
|
+ var mesh = this._obj;
|
|
|
+ mesh.getScene().onBeforeRenderObservable.remove(this.onBeforeRenderObserver);
|
|
|
this._axesViewer.dispose();
|
|
|
this._axesViewer = null;
|
|
|
}
|
|
@@ -1305,14 +1307,20 @@ var INSPECTOR;
|
|
|
* Should be called only one time as it will fill this._axis
|
|
|
*/
|
|
|
MeshAdapter.prototype._drawAxis = function () {
|
|
|
+ var _this = this;
|
|
|
this._obj.computeWorldMatrix();
|
|
|
var mesh = this._obj;
|
|
|
// Axis
|
|
|
- var x = new BABYLON.Vector3(8 / Math.abs(mesh.scaling.x), 0, 0);
|
|
|
- var y = new BABYLON.Vector3(0, 8 / Math.abs(mesh.scaling.y), 0);
|
|
|
- var z = new BABYLON.Vector3(0, 0, 8 / Math.abs(mesh.scaling.z));
|
|
|
+ var x = new BABYLON.Vector3(1, 0, 0);
|
|
|
+ var y = new BABYLON.Vector3(0, 1, 0);
|
|
|
+ var z = new BABYLON.Vector3(0, 0, 1);
|
|
|
this._axesViewer = new BABYLON.Debug.AxesViewer(this._obj.getScene());
|
|
|
- this._axesViewer.update(this._obj.position, x, y, z);
|
|
|
+ this.onBeforeRenderObserver = mesh.getScene().onBeforeRenderObservable.add(function () {
|
|
|
+ var matrix = mesh.getWorldMatrix();
|
|
|
+ var extend = mesh.getBoundingInfo().boundingBox.extendSizeWorld;
|
|
|
+ _this._axesViewer.scaleLines = Math.max(extend.x, extend.y, extend.z) * 2;
|
|
|
+ _this._axesViewer.update(_this._obj.position, BABYLON.Vector3.TransformNormal(x, matrix), BABYLON.Vector3.TransformNormal(y, matrix), BABYLON.Vector3.TransformNormal(z, matrix));
|
|
|
+ });
|
|
|
};
|
|
|
return MeshAdapter;
|
|
|
}(INSPECTOR.Adapter));
|