babylon.groundMesh.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. var __extends = this.__extends || function (d, b) {
  2. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3. function __() { this.constructor = d; }
  4. __.prototype = b.prototype;
  5. d.prototype = new __();
  6. };
  7. var BABYLON;
  8. (function (BABYLON) {
  9. var GroundMesh = (function (_super) {
  10. __extends(GroundMesh, _super);
  11. function GroundMesh(name, scene) {
  12. _super.call(this, name, scene);
  13. this._worldInverse = new BABYLON.Matrix();
  14. }
  15. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  16. get: function () {
  17. return this._subdivisions;
  18. },
  19. enumerable: true,
  20. configurable: true
  21. });
  22. GroundMesh.prototype._setReady = function (state) {
  23. if (state) {
  24. if (this._subdivisions > 10) {
  25. this.subdivide(this._subdivisions);
  26. this.createOrUpdateSubmeshesOctree(32);
  27. }
  28. }
  29. _super.prototype._setReady.call(this, state);
  30. };
  31. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  32. var ray = new BABYLON.Ray(new BABYLON.Vector3(x, this.getBoundingInfo().boundingBox.maximumWorld.y + 1, z), new BABYLON.Vector3(0, -1, 0));
  33. this.getWorldMatrix().invertToRef(this._worldInverse);
  34. ray = BABYLON.Ray.Transform(ray, this._worldInverse);
  35. var pickInfo = this.intersects(ray);
  36. if (pickInfo.hit) {
  37. var result = BABYLON.Vector3.TransformCoordinates(pickInfo.pickedPoint, this.getWorldMatrix());
  38. return result.y;
  39. }
  40. return 0;
  41. };
  42. return GroundMesh;
  43. })(BABYLON.Mesh);
  44. BABYLON.GroundMesh = GroundMesh;
  45. })(BABYLON || (BABYLON = {}));
  46. //# sourceMappingURL=babylon.groundMesh.js.map