Просмотр исходного кода

Merge branch 'master' of https://github.com/royibernthal/Babylon.js

Royi Bernthal 7 лет назад
Родитель
Сommit
36049a7201
1 измененных файлов с 16 добавлено и 0 удалено
  1. 16 0
      gui/src/advancedDynamicTexture.ts

+ 16 - 0
gui/src/advancedDynamicTexture.ts

@@ -527,6 +527,22 @@ module BABYLON.GUI {
             this._attachToOnPointerOut(scene);
             this._attachToOnPointerOut(scene);
         }
         }
 
 
+        public getMeshPosition(mesh: BABYLON.Mesh): BABYLON.Vector3 {
+            var scene = this.getScene();
+
+            if (!scene) {
+                return BABYLON.Vector3.Zero();
+            }
+
+            var globalViewport = this._getGlobalViewport(scene);
+            var position = mesh.getBoundingInfo().boundingSphere.center;
+            var projectedPosition = Vector3.Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
+
+            projectedPosition.scaleInPlace(this.renderScale);
+            
+            return projectedPosition;
+        }
+
         public moveFocusToControl(control: IFocusableControl): void {
         public moveFocusToControl(control: IFocusableControl): void {
             this.focusedControl = control;
             this.focusedControl = control;
             this._lastPickedControl = <any>control;
             this._lastPickedControl = <any>control;