浏览代码

Added GUI.DisplayGrid

Deltakosh 7 年之前
父节点
当前提交
47817f6c76

文件差异内容过多而无法显示
+ 4358 - 4330
Playground/babylon.d.txt


文件差异内容过多而无法显示
+ 5557 - 5557
dist/preview release/babylon.d.ts


+ 29 - 0
dist/preview release/gui/babylon.gui.d.ts

@@ -1806,6 +1806,35 @@ declare module BABYLON.GUI {
     }
 }
 declare module BABYLON.GUI {
+    /** Class used to render a grid  */
+    export class DisplayGrid extends Control {
+            name?: string | undefined;
+            /** Gets or sets background color (Black by default) */
+            background: string;
+            /** Gets or sets the width of each cell (20 by default) */
+            cellWidth: number;
+            /** Gets or sets the height of each cell (20 by default) */
+            cellHeight: number;
+            /** Gets or sets the tickness of minor lines (1 by default) */
+            minorLineTickness: number;
+            /** Gets or sets the color of minor lines (DarkGray by default) */
+            minorLineColor: string;
+            /** Gets or sets the tickness of major lines (2 by default) */
+            majorLineTickness: number;
+            /** Gets or sets the color of major lines (White by default) */
+            majorLineColor: string;
+            /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
+            majorLineFrequency: number;
+            /**
+                * Creates a new GridDisplayRectangle
+                * @param name defines the control name
+                */
+            constructor(name?: string | undefined);
+            _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
+            protected _getTypeName(): string;
+    }
+}
+declare module BABYLON.GUI {
     /**
       * Forcing an export so that this code will execute
       * @hidden

文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/gui/babylon.gui.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/gui/babylon.gui.min.js.map


+ 62 - 0
dist/preview release/gui/babylon.gui.module.d.ts

@@ -43,6 +43,7 @@ declare module 'babylonjs-gui/2D/controls' {
     export * from "babylonjs-gui/2D/controls/virtualKeyboard";
     export * from "babylonjs-gui/2D/controls/slider";
     export * from "babylonjs-gui/2D/controls/rectangle";
+    export * from "babylonjs-gui/2D/controls/displayGrid";
     export * from "babylonjs-gui/2D/controls/statics";
 }
 
@@ -1956,6 +1957,38 @@ declare module 'babylonjs-gui/2D/controls/rectangle' {
     }
 }
 
+declare module 'babylonjs-gui/2D/controls/displayGrid' {
+    import { Control } from "babylonjs-gui/2D/controls";
+    import { Measure } from "babylonjs-gui/2D";
+    /** Class used to render a grid  */
+    export class DisplayGrid extends Control {
+            name?: string | undefined;
+            /** Gets or sets background color (Black by default) */
+            background: string;
+            /** Gets or sets the width of each cell (20 by default) */
+            cellWidth: number;
+            /** Gets or sets the height of each cell (20 by default) */
+            cellHeight: number;
+            /** Gets or sets the tickness of minor lines (1 by default) */
+            minorLineTickness: number;
+            /** Gets or sets the color of minor lines (DarkGray by default) */
+            minorLineColor: string;
+            /** Gets or sets the tickness of major lines (2 by default) */
+            majorLineTickness: number;
+            /** Gets or sets the color of major lines (White by default) */
+            majorLineColor: string;
+            /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
+            majorLineFrequency: number;
+            /**
+                * Creates a new GridDisplayRectangle
+                * @param name defines the control name
+                */
+            constructor(name?: string | undefined);
+            _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
+            protected _getTypeName(): string;
+    }
+}
+
 declare module 'babylonjs-gui/2D/controls/statics' {
     /**
       * Forcing an export so that this code will execute
@@ -4335,6 +4368,35 @@ declare module BABYLON.GUI {
     }
 }
 declare module BABYLON.GUI {
+    /** Class used to render a grid  */
+    export class DisplayGrid extends Control {
+            name?: string | undefined;
+            /** Gets or sets background color (Black by default) */
+            background: string;
+            /** Gets or sets the width of each cell (20 by default) */
+            cellWidth: number;
+            /** Gets or sets the height of each cell (20 by default) */
+            cellHeight: number;
+            /** Gets or sets the tickness of minor lines (1 by default) */
+            minorLineTickness: number;
+            /** Gets or sets the color of minor lines (DarkGray by default) */
+            minorLineColor: string;
+            /** Gets or sets the tickness of major lines (2 by default) */
+            majorLineTickness: number;
+            /** Gets or sets the color of major lines (White by default) */
+            majorLineColor: string;
+            /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
+            majorLineFrequency: number;
+            /**
+                * Creates a new GridDisplayRectangle
+                * @param name defines the control name
+                */
+            constructor(name?: string | undefined);
+            _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
+            protected _getTypeName(): string;
+    }
+}
+declare module BABYLON.GUI {
     /**
       * Forcing an export so that this code will execute
       * @hidden

文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/inspector/babylon.inspector.bundle.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/inspector/babylon.inspector.bundle.js.map


文件差异内容过多而无法显示
+ 3 - 3
dist/preview release/viewer/babylon.viewer.js


文件差异内容过多而无法显示
+ 2 - 2
dist/preview release/viewer/babylon.viewer.max.js


+ 187 - 0
gui/src/2D/controls/displayGrid.ts

@@ -0,0 +1,187 @@
+
+import { Control } from ".";
+import { Measure } from "..";
+
+/** Class used to render a grid  */
+export class DisplayGrid extends Control {
+    private _cellWidth = 20;
+    private _cellHeight = 20;
+
+    private _minorLineTickness = 1;
+    private _minorLineColor = "DarkGray";
+
+    private _majorLineTickness = 2;
+    private _majorLineColor = "Red";
+
+    private _majorLineFrequency = 5;
+
+    private _background = "Black";
+
+    /** Gets or sets background color (Black by default) */
+    public get background(): string {
+        return this._background;
+    }
+
+    public set background(value: string) {
+        if (this._background === value) {
+            return;
+        }
+
+        this._background = value;
+        this._markAsDirty();
+    }    
+
+    /** Gets or sets the width of each cell (20 by default) */
+    public get cellWidth(): number {
+        return this._cellWidth;
+    }
+
+    public set cellWidth(value: number) {
+        this._cellWidth = value;
+
+        this._markAsDirty();
+    }
+
+    /** Gets or sets the height of each cell (20 by default) */
+    public get cellHeight(): number {
+        return this._cellHeight;
+    }
+
+    public set cellHeight(value: number) {
+        this._cellHeight = value;
+
+        this._markAsDirty();
+    }
+
+    /** Gets or sets the tickness of minor lines (1 by default) */
+    public get minorLineTickness(): number {
+        return this._minorLineTickness;
+    }
+
+    public set minorLineTickness(value: number) {
+        this._minorLineTickness = value;
+
+        this._markAsDirty();
+    }
+
+    /** Gets or sets the color of minor lines (DarkGray by default) */
+    public get minorLineColor(): string {
+        return this._minorLineColor;
+    }
+
+    public set minorLineColor(value: string) {
+        this._minorLineColor = value;
+
+        this._markAsDirty();
+    }    
+
+    /** Gets or sets the tickness of major lines (2 by default) */
+    public get majorLineTickness(): number {
+        return this._majorLineTickness;
+    }
+
+    public set majorLineTickness(value: number) {
+        this._majorLineTickness = value;
+
+        this._markAsDirty();
+    }
+
+    /** Gets or sets the color of major lines (White by default) */
+    public get majorLineColor(): string {
+        return this._majorLineColor;
+    }
+
+    public set majorLineColor(value: string) {
+        this._majorLineColor = value;
+
+        this._markAsDirty();
+    }    
+
+    /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
+    public get majorLineFrequency(): number {
+        return this._majorLineFrequency;
+    }
+
+    public set majorLineFrequency(value: number) {
+        this._majorLineFrequency = value;
+
+        this._markAsDirty();
+    }
+
+    /**
+     * Creates a new GridDisplayRectangle
+     * @param name defines the control name
+     */
+    constructor(public name?: string) {
+        super(name);
+    }
+
+    public _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void {
+        context.save();
+        
+        this._applyStates(context);
+
+        if (this._processMeasures(parentMeasure, context)) {
+
+            context.fillStyle = this._background;
+            context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
+
+            let cellCountX = this._currentMeasure.width / this._cellWidth;
+            let cellCountY = this._currentMeasure.height / this._cellHeight;
+
+            // Minor lines
+            context.strokeStyle = this._minorLineColor;
+            context.lineWidth = this._minorLineTickness;        
+
+            const left = this._currentMeasure.left + this._currentMeasure.width / 2;
+
+            for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
+                const cellX = left + x * this.cellWidth;
+
+                context.beginPath();
+                context.moveTo(cellX, this._currentMeasure.top);
+                context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
+                
+                context.stroke();                
+            }
+
+            const top = this._currentMeasure.top + this._currentMeasure.height / 2;
+
+            for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
+                const cellY = top + y * this.cellHeight;
+
+                context.beginPath();
+                context.moveTo(this._currentMeasure.left, cellY);
+                context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
+                context.stroke();
+            }
+
+            // Major lines
+            context.strokeStyle = this._majorLineColor;
+            context.lineWidth = this._majorLineTickness;        
+
+            for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
+                let cellX = left + x * this.cellWidth;
+
+                context.beginPath();    
+                context.moveTo(cellX, this._currentMeasure.top);
+                context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
+                context.stroke();
+            }
+
+            for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
+                let cellY = top + y * this.cellHeight;
+                context.moveTo(this._currentMeasure.left, cellY);
+                context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
+                context.closePath();
+                context.stroke();
+            }
+        }
+
+        context.restore();
+    }
+
+    protected _getTypeName(): string {
+        return "DisplayGrid";
+    }
+}    

+ 0 - 111
gui/src/2D/controls/gridDisplay.ts

@@ -1,111 +0,0 @@
-
-import { Control } from ".";
-import { Measure } from "..";
-
-/** Class used to render a grid  */
-export class GridDisplay extends Control {
-    private _cellWidth = 10;
-    private _cellHeight = 10;
-    private _minorLineTickness = 1;
-    private _minorLineColor = "DarkGray";
-    private _background = "Black";
-
-    /** Gets or sets background color (Black by default) */
-    public get background(): string {
-        return this._background;
-    }
-
-    public set background(value: string) {
-        if (this._background === value) {
-            return;
-        }
-
-        this._background = value;
-        this._markAsDirty();
-    }    
-
-    /** Gets or sets the width of each cell (10 by default) */
-    public get cellWidth(): number {
-        return this._cellWidth;
-    }
-
-    public set cellWidth(value: number) {
-        this._cellWidth = value;
-
-        this._markAsDirty();
-    }
-
-    /** Gets or sets the height of each cell (10 by default) */
-    public get cellHeight(): number {
-        return this._cellHeight;
-    }
-
-    public set cellHeight(value: number) {
-        this._cellHeight = value;
-
-        this._markAsDirty();
-    }
-
-    /** Gets or sets the tickness of minor lines (1 by default) */
-    public get minorLineTickness(): number {
-        return this._minorLineTickness;
-    }
-
-    public set minorLineTickness(value: number) {
-        this._minorLineTickness = value;
-
-        this._markAsDirty();
-    }
-
-    /** Gets or sets the color of minor lines (DarkGray by default) */
-    public get minorLineColor(): string {
-        return this._minorLineColor;
-    }
-
-    public set minorLineColor(value: string) {
-        this._minorLineColor = value;
-
-        this._markAsDirty();
-    }    
-
-    /**
-     * Creates a new GridDisplayRectangle
-     * @param name defines the control name
-     */
-    constructor(public name?: string) {
-        super(name);
-    }
-
-    public _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void {
-        context.save();
-        
-        this._applyStates(context);
-
-        if (this._processMeasures(parentMeasure, context)) {
-
-            context.fillStyle = this._background;
-            context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
-
-            const cellCountX = this._currentMeasure.width / this._cellWidth;
-            const cellCountY = this._currentMeasure.height / this._cellHeight;
-
-            context.strokeStyle = this._minorLineColor;
-            context.lineWidth = this._minorLineTickness;        
-
-            const left = this._currentMeasure.left + this._currentMeasure.width / 2;
-
-            for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
-                const cellX = left + x * this.cellWidth;
-                context.moveTo(cellX, this._currentMeasure.top);
-                context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
-                context.stroke();
-            }
-        }
-
-        context.restore();
-    }
-
-    protected _getTypeName(): string {
-        return "GridDisplayRectangle";
-    }
-}    

+ 1 - 1
gui/src/2D/controls/index.ts

@@ -16,6 +16,6 @@ export * from "./textBlock";
 export * from "./virtualKeyboard";
 export * from "./slider";
 export * from "./rectangle";
-export * from "./gridDisplay";
+export * from "./displayGrid";
 
 export * from "./statics";