David Catuhe 8 年 前
コミット
86469e533a

ファイルの差分が大きいため隠しています
+ 2873 - 2873
dist/preview release/babylon.d.ts


ファイルの差分が大きいため隠しています
+ 2873 - 2873
dist/preview release/babylon.module.d.ts


ファイルの差分が大きいため隠しています
+ 5296 - 5296
dist/preview release/customConfigurations/minimalViewer/babylon.d.ts


ファイルの差分が大きいため隠しています
+ 5296 - 5296
dist/preview release/customConfigurations/minimalViewer/babylon.module.d.ts


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

@@ -30,6 +30,7 @@ declare module BABYLON.GUI {
         removeControl(control: Control): AdvancedDynamicTexture;
         removeControl(control: Control): AdvancedDynamicTexture;
         dispose(): void;
         dispose(): void;
         private _onResize();
         private _onResize();
+        _getGlobalViewport(scene: Scene): Viewport;
         private _checkUpdate(camera);
         private _checkUpdate(camera);
         private _render();
         private _render();
         private _doPicking(x, y, type);
         private _doPicking(x, y, type);
@@ -214,6 +215,7 @@ declare module BABYLON.GUI {
         readonly centerY: number;
         readonly centerY: number;
         constructor(name?: string);
         constructor(name?: string);
         protected _getTypeName(): string;
         protected _getTypeName(): string;
+        moveToVector3(position: Vector3, scene: Scene): void;
         linkWithMesh(mesh: AbstractMesh): void;
         linkWithMesh(mesh: AbstractMesh): void;
         _moveToProjectedPosition(projectedPosition: Vector3): void;
         _moveToProjectedPosition(projectedPosition: Vector3): void;
         _markMatrixAsDirty(): void;
         _markMatrixAsDirty(): void;

+ 22 - 2
dist/preview release/gui/babylon.gui.js

@@ -148,6 +148,10 @@ var BABYLON;
                     }
                     }
                 }
                 }
             };
             };
+            AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
+                var engine = scene.getEngine();
+                return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
+            };
             AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
             AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
                 if (this._layerToDispose) {
                 if (this._layerToDispose) {
                     if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
                     if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
@@ -156,8 +160,7 @@ var BABYLON;
                 }
                 }
                 if (this._isFullscreen && this._linkedControls.length) {
                 if (this._isFullscreen && this._linkedControls.length) {
                     var scene = this.getScene();
                     var scene = this.getScene();
-                    var engine = scene.getEngine();
-                    var globalViewport = this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
+                    var globalViewport = this._getGlobalViewport(scene);
                     for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
                     for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
                         var control = _a[_i];
                         var control = _a[_i];
                         var mesh = control._linkedMesh;
                         var mesh = control._linkedMesh;
@@ -999,6 +1002,23 @@ var BABYLON;
             Control.prototype._getTypeName = function () {
             Control.prototype._getTypeName = function () {
                 return "Control";
                 return "Control";
             };
             };
+            Control.prototype.moveToVector3 = function (position, scene) {
+                if (!this._host || this._root !== this._host._rootContainer) {
+                    BABYLON.Tools.Error("Cannot move a control to a vector3 if the control is not at root level");
+                    return;
+                }
+                this.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;
+                this.verticalAlignment = BABYLON.GUI.Control.VERTICAL_ALIGNMENT_TOP;
+                var engine = scene.getEngine();
+                var globalViewport = this._host._getGlobalViewport(scene);
+                var projectedPosition = BABYLON.Vector3.Project(position, BABYLON.Matrix.Identity(), scene.getTransformMatrix(), globalViewport);
+                this._moveToProjectedPosition(projectedPosition);
+                if (projectedPosition.z < 0 || projectedPosition.z > 1) {
+                    this.isVisible = false;
+                    return;
+                }
+                this.isVisible = true;
+            };
             Control.prototype.linkWithMesh = function (mesh) {
             Control.prototype.linkWithMesh = function (mesh) {
                 if (!this._host || this._root !== this._host._rootContainer) {
                 if (!this._host || this._root !== this._host._rootContainer) {
                     BABYLON.Tools.Error("Cannot link a control to a mesh if the control is not at root level");
                     BABYLON.Tools.Error("Cannot link a control to a mesh if the control is not at root level");

ファイルの差分が大きいため隠しています
+ 2 - 2
dist/preview release/gui/babylon.gui.min.js


+ 6 - 2
gui/src/advancedDynamicTexture.ts

@@ -158,6 +158,11 @@ module BABYLON.GUI {
             }
             }
         }
         }
 
 
+        public _getGlobalViewport(scene: Scene): Viewport {
+            var engine = scene.getEngine();
+            return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
+        }
+
         private _checkUpdate(camera: Camera): void {
         private _checkUpdate(camera: Camera): void {
             if (this._layerToDispose) {
             if (this._layerToDispose) {
                 if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
                 if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
@@ -167,8 +172,7 @@ module BABYLON.GUI {
 
 
             if (this._isFullscreen && this._linkedControls.length) {
             if (this._isFullscreen && this._linkedControls.length) {
                 var scene = this.getScene();
                 var scene = this.getScene();
-                var engine = scene.getEngine();
-                var globalViewport = this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
+                var globalViewport = this._getGlobalViewport(scene);
 
 
                 for (var control of this._linkedControls) {
                 for (var control of this._linkedControls) {
                     var mesh = control._linkedMesh;
                     var mesh = control._linkedMesh;

+ 22 - 0
gui/src/controls/control.ts

@@ -399,6 +399,28 @@ module BABYLON.GUI {
             return "Control";
             return "Control";
         }
         }
 
 
+        public moveToVector3(position: Vector3, scene: Scene): void {
+            if (!this._host || this._root !== this._host._rootContainer) {
+                Tools.Error("Cannot move a control to a vector3 if the control is not at root level");
+                return;
+            }
+            
+            this.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;
+            this.verticalAlignment = BABYLON.GUI.Control.VERTICAL_ALIGNMENT_TOP;
+
+            var engine = scene.getEngine();
+            var globalViewport = this._host._getGlobalViewport(scene);
+            var projectedPosition = Vector3.Project(position, Matrix.Identity(), scene.getTransformMatrix(), globalViewport);
+
+            this._moveToProjectedPosition(projectedPosition);
+
+            if (projectedPosition.z < 0 || projectedPosition.z > 1) {
+                this.isVisible = false;
+                return;
+            }
+            this.isVisible = true;
+        }
+
         public linkWithMesh(mesh: AbstractMesh): void {
         public linkWithMesh(mesh: AbstractMesh): void {
             if (!this._host || this._root !== this._host._rootContainer) {
             if (!this._host || this._root !== this._host._rootContainer) {
                 Tools.Error("Cannot link a control to a mesh if the control is not at root level");
                 Tools.Error("Cannot link a control to a mesh if the control is not at root level");