Przeglądaj źródła

charting cleanup

David Catuhe 7 lat temu
rodzic
commit
7dc659e5c4

+ 4 - 5
gui/src/3D/charting/barGraph.ts

@@ -1,4 +1,4 @@
-import { Nullable, Scene, Mesh, StandardMaterial, Animation, Engine, Matrix } from "babylonjs";
+import { Nullable, Scene, Mesh, StandardMaterial, Animation, Engine, Matrix, AbstractMesh } from "babylonjs";
 import { Chart } from ".";
 import { AdvancedDynamicTexture, DisplayGrid } from "../../2D";
 
@@ -9,7 +9,7 @@ import { AdvancedDynamicTexture, DisplayGrid } from "../../2D";
 export class BarGraph extends Chart {
     private _margin = 1;
     private _maxBarHeight = 10;
-    private _barMeshes: Nullable<Array<Mesh>>;
+    private _barMeshes: Nullable<Array<AbstractMesh>>;
     private _backgroundMesh: Nullable<Mesh>;
     private _backgroundADT : Nullable<AdvancedDynamicTexture>;
     
@@ -177,7 +177,7 @@ export class BarGraph extends Chart {
         let index = 0;
         data.forEach(entry => {
 
-            var barMesh: Mesh;
+            var barMesh: AbstractMesh;
             if (createMesh) {
                 barMesh = this._createBarMesh(this.name + "_box_" + index++, scene);
                 barMesh.enablePointerMoveEvents = true;
@@ -186,6 +186,7 @@ export class BarGraph extends Chart {
                 barMesh = this._barMeshes![index++];
             }
 
+            barMesh.material = this._defaultMaterial;
             barMesh.metadata = entry;
             barMesh.parent = this._rootNode;
             barMesh.position.x = left;
@@ -195,8 +196,6 @@ export class BarGraph extends Chart {
             var easing = new BABYLON.CircleEase();
             Animation.CreateAndStartAnimation("entryScale", barMesh, "scaling.y", 30, 30, currentScalingYState, entry.value * ratio, 0, easing);
 
-            barMesh.material = this._defaultMaterial;
-
             this.onElementCreatedObservable.notifyObservers(barMesh);
 
             left += this._elementWidth + this.margin;

+ 1 - 1
gui/src/3D/charting/chart.ts

@@ -33,7 +33,7 @@ export abstract class Chart {
     public onRefreshObservable  = new Observable<Chart>();
 
     /** Observable raised when a new element is created */
-    public onElementCreatedObservable  = new Observable<Mesh>();
+    public onElementCreatedObservable  = new Observable<AbstractMesh>();
 
     /**
      * Observable raised when the point picked by the pointer events changed

+ 3 - 3
gui/src/3D/charting/mapGraph.ts

@@ -1,5 +1,5 @@
 import { Chart } from ".";
-import { Engine, Scene, Nullable, Mesh, Animation, Texture, Matrix, Observer, Vector3, Material } from "babylonjs";
+import { Engine, Scene, Nullable, Mesh, Animation, Texture, Matrix, Observer, Vector3, Material, AbstractMesh } from "babylonjs";
 import { FluentMaterial } from "../materials";
 
 /** 
@@ -8,7 +8,7 @@ import { FluentMaterial } from "../materials";
  */
 export class MapGraph extends Chart {
 
-    private _cylinderMeshes: Nullable<Array<Mesh>>;
+    private _cylinderMeshes: Nullable<Array<AbstractMesh>>;
     private _maxCylinderHeight = 10;
     private _worldMap: Nullable<Mesh>;
     private _mercatorMaterial: Nullable<FluentMaterial>;
@@ -206,7 +206,7 @@ export class MapGraph extends Chart {
         let index = 0;
         data.forEach(entry => {
 
-            var cylinderMesh: Mesh;
+            var cylinderMesh: AbstractMesh;
             if (createMesh) {
                 cylinderMesh = this._createCylinderMesh(this.name + "_cylinder_" + index++, scene);
                 cylinderMesh.enablePointerMoveEvents = true;

+ 2 - 1
src/Mesh/babylon.mesh.ts

@@ -2147,7 +2147,8 @@
          * - rotationQuaternion
          * - setPivotMatrix
          * - scaling
-         * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
+         * 
+         * @see http://doc.babylonjs.com/how_to/how_to_use_instances
          * Warning : this method is not supported for Line mesh and LineSystem
          */
         public createInstance(name: string): InstancedMesh {