babylon.groundMesh.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. if (typeof chunksCount === "undefined") { chunksCount = 32; }
  25. this.subdivide(this._subdivisions);
  26. this.createOrUpdateSubmeshesOctree(chunksCount);
  27. };
  28. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  29. var ray = new BABYLON.Ray(new BABYLON.Vector3(x, this.getBoundingInfo().boundingBox.maximumWorld.y + 1, z), new BABYLON.Vector3(0, -1, 0));
  30. this.getWorldMatrix().invertToRef(this._worldInverse);
  31. ray = BABYLON.Ray.Transform(ray, this._worldInverse);
  32. var pickInfo = this.intersects(ray);
  33. if (pickInfo.hit) {
  34. var result = BABYLON.Vector3.TransformCoordinates(pickInfo.pickedPoint, this.getWorldMatrix());
  35. return result.y;
  36. }
  37. return 0;
  38. };
  39. return GroundMesh;
  40. })(BABYLON.Mesh);
  41. BABYLON.GroundMesh = GroundMesh;
  42. })(BABYLON || (BABYLON = {}));
  43. //# sourceMappingURL=babylon.groundMesh.js.map