babylon.groundMesh.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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.generateOctree = false;
  14. this._worldInverse = new BABYLON.Matrix();
  15. }
  16. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  17. get: function () {
  18. return this._subdivisions;
  19. },
  20. enumerable: true,
  21. configurable: true
  22. });
  23. GroundMesh.prototype.optimize = function (chunksCount) {
  24. this.subdivide(this._subdivisions);
  25. this.createOrUpdateSubmeshesOctree(32);
  26. };
  27. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  28. var ray = new BABYLON.Ray(new BABYLON.Vector3(x, this.getBoundingInfo().boundingBox.maximumWorld.y + 1, z), new BABYLON.Vector3(0, -1, 0));
  29. this.getWorldMatrix().invertToRef(this._worldInverse);
  30. ray = BABYLON.Ray.Transform(ray, this._worldInverse);
  31. var pickInfo = this.intersects(ray);
  32. if (pickInfo.hit) {
  33. var result = BABYLON.Vector3.TransformCoordinates(pickInfo.pickedPoint, this.getWorldMatrix());
  34. return result.y;
  35. }
  36. return 0;
  37. };
  38. return GroundMesh;
  39. })(BABYLON.Mesh);
  40. BABYLON.GroundMesh = GroundMesh;
  41. })(BABYLON || (BABYLON = {}));
  42. //# sourceMappingURL=babylon.groundMesh.js.map