text: import { __extends } from "tslib";
  import { Tools } from "@babylonjs/core/Misc/tools";
  import { Matrix, TmpVectors, Vector3 } from "@babylonjs/core/Maths/math.vector";
  import { VolumeBasedPanel } from "./volumeBasedPanel";
  import { Container3D } from "./container3D";
  import { Axis, Space } from '@babylonjs/core/Maths/math.axis';
  /**
   * Class used to create a container panel deployed on the surface of a sphere
   */
  var SpherePanel = /** @class */ (function (_super) {
      __extends(SpherePanel, _super);
      function SpherePanel() {
          var _this = _super !== null && _super.apply(this, arguments) || this;
          _this._radius = 5.0;
          return _this;
      }
      Object.defineProperty(SpherePanel.prototype, "radius", {
          /**
           * Gets or sets the radius of the sphere where to project controls (5 by default)
           */
          get: function () {
              return this._radius;
          },
          set: function (value) {
              var _this = this;
              if (this._radius === value) {
                  return;
              }
              this._radius = value;
              Tools.SetImmediate(function () {
                  _this._arrangeChildren();
              });
          },
          enumerable: false,
          configurable: true
      });
      SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
          var mesh = control.mesh;
          if (!mesh) {
              return;
          }
          var newPos = this._sphericalMapping(nodePosition);
          control.position = newPos;
          switch (this.orientation) {
              case Container3D.FACEORIGIN_ORIENTATION:
                  mesh.lookAt(new Vector3(2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
                  break;
              case Container3D.FACEORIGINREVERSED_ORIENTATION:
                  mesh.lookAt(new Vector3(-newPos.x, -newPos.y, -newPos.z));
                  break;
              case Container3D.FACEFORWARD_ORIENTATION:
                  break;
              case Container3D.FACEFORWARDREVERSED_ORIENTATION:
                  mesh.rotate(Axis.Y, Math.PI, Space.LOCAL);
                  break;
          }
      };
      SpherePanel.prototype._sphericalMapping = function (source) {
          var newPos = new Vector3(0, 0, this._radius);
          var xAngle = (source.y / this._radius);
          var yAngle = -(source.x / this._radius);
          Matrix.RotationYawPitchRollToRef(yAngle, xAngle, 0, TmpVectors.Matrix[0]);
          return Vector3.TransformNormal(newPos, TmpVectors.Matrix[0]);
      };
      return SpherePanel;
  }(VolumeBasedPanel));
  export { SpherePanel };
  //# sourceMappingURL=spherePanel.js.map