babylon.groundMesh.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. return pickInfo.pickedPoint.y;
  34. }
  35. return 0;
  36. };
  37. return GroundMesh;
  38. })(BABYLON.Mesh);
  39. BABYLON.GroundMesh = GroundMesh;
  40. })(BABYLON || (BABYLON = {}));
  41. //# sourceMappingURL=babylon.groundMesh.js.map