babylon.geometry.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. var __extends = (this && 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 Geometry = (function () {
  10. function Geometry(id, scene, vertexData, updatable, mesh) {
  11. this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NONE;
  12. this._totalVertices = 0;
  13. this._indices = [];
  14. this._isDisposed = false;
  15. this.id = id;
  16. this._engine = scene.getEngine();
  17. this._meshes = [];
  18. this._scene = scene;
  19. // vertexData
  20. if (vertexData) {
  21. this.setAllVerticesData(vertexData, updatable);
  22. }
  23. else {
  24. this._totalVertices = 0;
  25. this._indices = [];
  26. }
  27. // applyToMesh
  28. if (mesh) {
  29. this.applyToMesh(mesh);
  30. mesh.computeWorldMatrix(true);
  31. }
  32. }
  33. Geometry.prototype.getScene = function () {
  34. return this._scene;
  35. };
  36. Geometry.prototype.getEngine = function () {
  37. return this._engine;
  38. };
  39. Geometry.prototype.isReady = function () {
  40. return this.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_LOADED || this.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_NONE;
  41. };
  42. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  43. vertexData.applyToGeometry(this, updatable);
  44. this.notifyUpdate();
  45. };
  46. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  47. this._vertexBuffers = this._vertexBuffers || {};
  48. if (this._vertexBuffers[kind]) {
  49. this._vertexBuffers[kind].dispose();
  50. }
  51. this._vertexBuffers[kind] = new BABYLON.VertexBuffer(this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  52. if (kind === BABYLON.VertexBuffer.PositionKind) {
  53. stride = this._vertexBuffers[kind].getStrideSize();
  54. this._totalVertices = data.length / stride;
  55. var extend = BABYLON.Tools.ExtractMinAndMax(data, 0, this._totalVertices);
  56. var meshes = this._meshes;
  57. var numOfMeshes = meshes.length;
  58. for (var index = 0; index < numOfMeshes; index++) {
  59. var mesh = meshes[index];
  60. mesh._resetPointsArrayCache();
  61. mesh._boundingInfo = new BABYLON.BoundingInfo(extend.minimum, extend.maximum);
  62. mesh._createGlobalSubMesh();
  63. mesh.computeWorldMatrix(true);
  64. }
  65. }
  66. this.notifyUpdate(kind);
  67. };
  68. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset) {
  69. var vertexBuffer = this.getVertexBuffer(kind);
  70. if (!vertexBuffer) {
  71. return;
  72. }
  73. vertexBuffer.updateDirectly(data, offset);
  74. this.notifyUpdate(kind);
  75. };
  76. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  77. var vertexBuffer = this.getVertexBuffer(kind);
  78. if (!vertexBuffer) {
  79. return;
  80. }
  81. vertexBuffer.update(data);
  82. if (kind === BABYLON.VertexBuffer.PositionKind) {
  83. var extend;
  84. var stride = vertexBuffer.getStrideSize();
  85. this._totalVertices = data.length / stride;
  86. if (updateExtends) {
  87. extend = BABYLON.Tools.ExtractMinAndMax(data, 0, this._totalVertices);
  88. }
  89. var meshes = this._meshes;
  90. var numOfMeshes = meshes.length;
  91. for (var index = 0; index < numOfMeshes; index++) {
  92. var mesh = meshes[index];
  93. mesh._resetPointsArrayCache();
  94. if (updateExtends) {
  95. mesh._boundingInfo = new BABYLON.BoundingInfo(extend.minimum, extend.maximum);
  96. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  97. var subMesh = mesh.subMeshes[subIndex];
  98. subMesh.refreshBoundingInfo();
  99. }
  100. }
  101. }
  102. }
  103. this.notifyUpdate(kind);
  104. };
  105. Geometry.prototype.getTotalVertices = function () {
  106. if (!this.isReady()) {
  107. return 0;
  108. }
  109. return this._totalVertices;
  110. };
  111. Geometry.prototype.getVerticesData = function (kind, copyWhenShared) {
  112. var vertexBuffer = this.getVertexBuffer(kind);
  113. if (!vertexBuffer) {
  114. return null;
  115. }
  116. var orig = vertexBuffer.getData();
  117. if (!copyWhenShared || this._meshes.length === 1) {
  118. return orig;
  119. }
  120. else {
  121. var len = orig.length;
  122. var copy = [];
  123. for (var i = 0; i < len; i++) {
  124. copy.push(orig[i]);
  125. }
  126. return copy;
  127. }
  128. };
  129. Geometry.prototype.getVertexBuffer = function (kind) {
  130. if (!this.isReady()) {
  131. return null;
  132. }
  133. return this._vertexBuffers[kind];
  134. };
  135. Geometry.prototype.getVertexBuffers = function () {
  136. if (!this.isReady()) {
  137. return null;
  138. }
  139. return this._vertexBuffers;
  140. };
  141. Geometry.prototype.isVerticesDataPresent = function (kind) {
  142. if (!this._vertexBuffers) {
  143. if (this._delayInfo) {
  144. return this._delayInfo.indexOf(kind) !== -1;
  145. }
  146. return false;
  147. }
  148. return this._vertexBuffers[kind] !== undefined;
  149. };
  150. Geometry.prototype.getVerticesDataKinds = function () {
  151. var result = [];
  152. if (!this._vertexBuffers && this._delayInfo) {
  153. for (var kind in this._delayInfo) {
  154. result.push(kind);
  155. }
  156. }
  157. else {
  158. for (kind in this._vertexBuffers) {
  159. result.push(kind);
  160. }
  161. }
  162. return result;
  163. };
  164. Geometry.prototype.setIndices = function (indices, totalVertices) {
  165. if (this._indexBuffer) {
  166. this._engine._releaseBuffer(this._indexBuffer);
  167. }
  168. this._indices = indices;
  169. if (this._meshes.length !== 0 && this._indices) {
  170. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  171. }
  172. if (totalVertices !== undefined) {
  173. this._totalVertices = totalVertices;
  174. }
  175. var meshes = this._meshes;
  176. var numOfMeshes = meshes.length;
  177. for (var index = 0; index < numOfMeshes; index++) {
  178. meshes[index]._createGlobalSubMesh();
  179. }
  180. this.notifyUpdate();
  181. };
  182. Geometry.prototype.getTotalIndices = function () {
  183. if (!this.isReady()) {
  184. return 0;
  185. }
  186. return this._indices.length;
  187. };
  188. Geometry.prototype.getIndices = function (copyWhenShared) {
  189. if (!this.isReady()) {
  190. return null;
  191. }
  192. var orig = this._indices;
  193. if (!copyWhenShared || this._meshes.length === 1) {
  194. return orig;
  195. }
  196. else {
  197. var len = orig.length;
  198. var copy = [];
  199. for (var i = 0; i < len; i++) {
  200. copy.push(orig[i]);
  201. }
  202. return copy;
  203. }
  204. };
  205. Geometry.prototype.getIndexBuffer = function () {
  206. if (!this.isReady()) {
  207. return null;
  208. }
  209. return this._indexBuffer;
  210. };
  211. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  212. var meshes = this._meshes;
  213. var index = meshes.indexOf(mesh);
  214. if (index === -1) {
  215. return;
  216. }
  217. for (var kind in this._vertexBuffers) {
  218. this._vertexBuffers[kind].dispose();
  219. }
  220. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  221. this._indexBuffer = null;
  222. }
  223. meshes.splice(index, 1);
  224. mesh._geometry = null;
  225. if (meshes.length === 0 && shouldDispose) {
  226. this.dispose();
  227. }
  228. };
  229. Geometry.prototype.applyToMesh = function (mesh) {
  230. if (mesh._geometry === this) {
  231. return;
  232. }
  233. var previousGeometry = mesh._geometry;
  234. if (previousGeometry) {
  235. previousGeometry.releaseForMesh(mesh);
  236. }
  237. var meshes = this._meshes;
  238. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  239. mesh._geometry = this;
  240. this._scene.pushGeometry(this);
  241. meshes.push(mesh);
  242. if (this.isReady()) {
  243. this._applyToMesh(mesh);
  244. }
  245. else {
  246. mesh._boundingInfo = this._boundingInfo;
  247. }
  248. };
  249. Geometry.prototype._applyToMesh = function (mesh) {
  250. var numOfMeshes = this._meshes.length;
  251. // vertexBuffers
  252. for (var kind in this._vertexBuffers) {
  253. if (numOfMeshes === 1) {
  254. this._vertexBuffers[kind].create();
  255. }
  256. this._vertexBuffers[kind]._buffer.references = numOfMeshes;
  257. if (kind === BABYLON.VertexBuffer.PositionKind) {
  258. mesh._resetPointsArrayCache();
  259. var extend = BABYLON.Tools.ExtractMinAndMax(this._vertexBuffers[kind].getData(), 0, this._totalVertices);
  260. mesh._boundingInfo = new BABYLON.BoundingInfo(extend.minimum, extend.maximum);
  261. mesh._createGlobalSubMesh();
  262. //bounding info was just created again, world matrix should be applied again.
  263. mesh._updateBoundingInfo();
  264. }
  265. }
  266. // indexBuffer
  267. if (numOfMeshes === 1 && this._indices) {
  268. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  269. }
  270. if (this._indexBuffer) {
  271. this._indexBuffer.references = numOfMeshes;
  272. }
  273. };
  274. Geometry.prototype.notifyUpdate = function (kind) {
  275. if (this.onGeometryUpdated) {
  276. this.onGeometryUpdated(this, kind);
  277. }
  278. };
  279. Geometry.prototype.load = function (scene, onLoaded) {
  280. var _this = this;
  281. if (this.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_LOADING) {
  282. return;
  283. }
  284. if (this.isReady()) {
  285. if (onLoaded) {
  286. onLoaded();
  287. }
  288. return;
  289. }
  290. this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_LOADING;
  291. scene._addPendingData(this);
  292. BABYLON.Tools.LoadFile(this.delayLoadingFile, function (data) {
  293. _this._delayLoadingFunction(JSON.parse(data), _this);
  294. _this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_LOADED;
  295. _this._delayInfo = [];
  296. scene._removePendingData(_this);
  297. var meshes = _this._meshes;
  298. var numOfMeshes = meshes.length;
  299. for (var index = 0; index < numOfMeshes; index++) {
  300. _this._applyToMesh(meshes[index]);
  301. }
  302. if (onLoaded) {
  303. onLoaded();
  304. }
  305. }, function () { }, scene.database);
  306. };
  307. Geometry.prototype.isDisposed = function () {
  308. return this._isDisposed;
  309. };
  310. Geometry.prototype.dispose = function () {
  311. var meshes = this._meshes;
  312. var numOfMeshes = meshes.length;
  313. var index;
  314. for (index = 0; index < numOfMeshes; index++) {
  315. this.releaseForMesh(meshes[index]);
  316. }
  317. this._meshes = [];
  318. for (var kind in this._vertexBuffers) {
  319. this._vertexBuffers[kind].dispose();
  320. }
  321. this._vertexBuffers = [];
  322. this._totalVertices = 0;
  323. if (this._indexBuffer) {
  324. this._engine._releaseBuffer(this._indexBuffer);
  325. }
  326. this._indexBuffer = null;
  327. this._indices = [];
  328. this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NONE;
  329. this.delayLoadingFile = null;
  330. this._delayLoadingFunction = null;
  331. this._delayInfo = [];
  332. this._boundingInfo = null; // todo: .dispose()
  333. this._scene.removeGeometry(this);
  334. this._isDisposed = true;
  335. };
  336. Geometry.prototype.copy = function (id) {
  337. var vertexData = new BABYLON.VertexData();
  338. vertexData.indices = [];
  339. var indices = this.getIndices();
  340. for (var index = 0; index < indices.length; index++) {
  341. vertexData.indices.push(indices[index]);
  342. }
  343. var updatable = false;
  344. var stopChecking = false;
  345. for (var kind in this._vertexBuffers) {
  346. // using slice() to make a copy of the array and not just reference it
  347. vertexData.set(this.getVerticesData(kind).slice(0), kind);
  348. if (!stopChecking) {
  349. updatable = this.getVertexBuffer(kind).isUpdatable();
  350. stopChecking = !updatable;
  351. }
  352. }
  353. var geometry = new Geometry(id, this._scene, vertexData, updatable, null);
  354. geometry.delayLoadState = this.delayLoadState;
  355. geometry.delayLoadingFile = this.delayLoadingFile;
  356. geometry._delayLoadingFunction = this._delayLoadingFunction;
  357. for (kind in this._delayInfo) {
  358. geometry._delayInfo = geometry._delayInfo || [];
  359. geometry._delayInfo.push(kind);
  360. }
  361. // Bounding info
  362. var extend = BABYLON.Tools.ExtractMinAndMax(this.getVerticesData(BABYLON.VertexBuffer.PositionKind), 0, this.getTotalVertices());
  363. geometry._boundingInfo = new BABYLON.BoundingInfo(extend.minimum, extend.maximum);
  364. return geometry;
  365. };
  366. // Statics
  367. Geometry.ExtractFromMesh = function (mesh, id) {
  368. var geometry = mesh._geometry;
  369. if (!geometry) {
  370. return null;
  371. }
  372. return geometry.copy(id);
  373. };
  374. // from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  375. // be aware Math.random() could cause collisions
  376. Geometry.RandomId = function () {
  377. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  378. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  379. return v.toString(16);
  380. });
  381. };
  382. return Geometry;
  383. })();
  384. BABYLON.Geometry = Geometry;
  385. /////// Primitives //////////////////////////////////////////////
  386. var Geometry;
  387. (function (Geometry) {
  388. var Primitives;
  389. (function (Primitives) {
  390. /// Abstract class
  391. var _Primitive = (function (_super) {
  392. __extends(_Primitive, _super);
  393. function _Primitive(id, scene, vertexData, canBeRegenerated, mesh) {
  394. this._beingRegenerated = true;
  395. this._canBeRegenerated = canBeRegenerated;
  396. _super.call(this, id, scene, vertexData, false, mesh); // updatable = false to be sure not to update vertices
  397. this._beingRegenerated = false;
  398. }
  399. _Primitive.prototype.canBeRegenerated = function () {
  400. return this._canBeRegenerated;
  401. };
  402. _Primitive.prototype.regenerate = function () {
  403. if (!this._canBeRegenerated) {
  404. return;
  405. }
  406. this._beingRegenerated = true;
  407. this.setAllVerticesData(this._regenerateVertexData(), false);
  408. this._beingRegenerated = false;
  409. };
  410. _Primitive.prototype.asNewGeometry = function (id) {
  411. return _super.prototype.copy.call(this, id);
  412. };
  413. // overrides
  414. _Primitive.prototype.setAllVerticesData = function (vertexData, updatable) {
  415. if (!this._beingRegenerated) {
  416. return;
  417. }
  418. _super.prototype.setAllVerticesData.call(this, vertexData, false);
  419. };
  420. _Primitive.prototype.setVerticesData = function (kind, data, updatable) {
  421. if (!this._beingRegenerated) {
  422. return;
  423. }
  424. _super.prototype.setVerticesData.call(this, kind, data, false);
  425. };
  426. // to override
  427. // protected
  428. _Primitive.prototype._regenerateVertexData = function () {
  429. throw new Error("Abstract method");
  430. };
  431. _Primitive.prototype.copy = function (id) {
  432. throw new Error("Must be overriden in sub-classes.");
  433. };
  434. return _Primitive;
  435. })(Geometry);
  436. Primitives._Primitive = _Primitive;
  437. var Ribbon = (function (_super) {
  438. __extends(Ribbon, _super);
  439. function Ribbon(id, scene, pathArray, closeArray, closePath, offset, canBeRegenerated, mesh, side) {
  440. if (side === void 0) { side = BABYLON.Mesh.DEFAULTSIDE; }
  441. this.pathArray = pathArray;
  442. this.closeArray = closeArray;
  443. this.closePath = closePath;
  444. this.offset = offset;
  445. this.side = side;
  446. _super.call(this, id, scene, this._regenerateVertexData(), canBeRegenerated, mesh);
  447. }
  448. Ribbon.prototype._regenerateVertexData = function () {
  449. return BABYLON.VertexData.CreateRibbon(this.pathArray, this.closeArray, this.closePath, this.offset, this.side);
  450. };
  451. Ribbon.prototype.copy = function (id) {
  452. return new Ribbon(id, this.getScene(), this.pathArray, this.closeArray, this.closePath, this.offset, this.canBeRegenerated(), null, this.side);
  453. };
  454. return Ribbon;
  455. })(_Primitive);
  456. Primitives.Ribbon = Ribbon;
  457. var Box = (function (_super) {
  458. __extends(Box, _super);
  459. function Box(id, scene, size, canBeRegenerated, mesh, side) {
  460. if (side === void 0) { side = BABYLON.Mesh.DEFAULTSIDE; }
  461. this.size = size;
  462. this.side = side;
  463. _super.call(this, id, scene, this._regenerateVertexData(), canBeRegenerated, mesh);
  464. }
  465. Box.prototype._regenerateVertexData = function () {
  466. return BABYLON.VertexData.CreateBox(this.size, this.side);
  467. };
  468. Box.prototype.copy = function (id) {
  469. return new Box(id, this.getScene(), this.size, this.canBeRegenerated(), null, this.side);
  470. };
  471. return Box;
  472. })(_Primitive);
  473. Primitives.Box = Box;
  474. var Sphere = (function (_super) {
  475. __extends(Sphere, _super);
  476. function Sphere(id, scene, segments, diameter, canBeRegenerated, mesh, side) {
  477. if (side === void 0) { side = BABYLON.Mesh.DEFAULTSIDE; }
  478. this.segments = segments;
  479. this.diameter = diameter;
  480. this.side = side;
  481. _super.call(this, id, scene, this._regenerateVertexData(), canBeRegenerated, mesh);
  482. }
  483. Sphere.prototype._regenerateVertexData = function () {
  484. return BABYLON.VertexData.CreateSphere(this.segments, this.diameter, this.side);
  485. };
  486. Sphere.prototype.copy = function (id) {
  487. return new Sphere(id, this.getScene(), this.segments, this.diameter, this.canBeRegenerated(), null, this.side);
  488. };
  489. return Sphere;
  490. })(_Primitive);
  491. Primitives.Sphere = Sphere;
  492. var Cylinder = (function (_super) {
  493. __extends(Cylinder, _super);
  494. function Cylinder(id, scene, height, diameterTop, diameterBottom, tessellation, subdivisions, canBeRegenerated, mesh, side) {
  495. if (subdivisions === void 0) { subdivisions = 1; }
  496. if (side === void 0) { side = BABYLON.Mesh.DEFAULTSIDE; }
  497. this.height = height;
  498. this.diameterTop = diameterTop;
  499. this.diameterBottom = diameterBottom;
  500. this.tessellation = tessellation;
  501. this.subdivisions = subdivisions;
  502. this.side = side;
  503. _super.call(this, id, scene, this._regenerateVertexData(), canBeRegenerated, mesh);
  504. }
  505. Cylinder.prototype._regenerateVertexData = function () {
  506. return BABYLON.VertexData.CreateCylinder(this.height, this.diameterTop, this.diameterBottom, this.tessellation, this.subdivisions, this.side);
  507. };
  508. Cylinder.prototype.copy = function (id) {
  509. return new Cylinder(id, this.getScene(), this.height, this.diameterTop, this.diameterBottom, this.tessellation, this.subdivisions, this.canBeRegenerated(), null, this.side);
  510. };
  511. return Cylinder;
  512. })(_Primitive);
  513. Primitives.Cylinder = Cylinder;
  514. var Torus = (function (_super) {
  515. __extends(Torus, _super);
  516. function Torus(id, scene, diameter, thickness, tessellation, canBeRegenerated, mesh, side) {
  517. if (side === void 0) { side = BABYLON.Mesh.DEFAULTSIDE; }
  518. this.diameter = diameter;
  519. this.thickness = thickness;
  520. this.tessellation = tessellation;
  521. this.side = side;
  522. _super.call(this, id, scene, this._regenerateVertexData(), canBeRegenerated, mesh);
  523. }
  524. Torus.prototype._regenerateVertexData = function () {
  525. return BABYLON.VertexData.CreateTorus(this.diameter, this.thickness, this.tessellation, this.side);
  526. };
  527. Torus.prototype.copy = function (id) {
  528. return new Torus(id, this.getScene(), this.diameter, this.thickness, this.tessellation, this.canBeRegenerated(), null, this.side);
  529. };
  530. return Torus;
  531. })(_Primitive);
  532. Primitives.Torus = Torus;
  533. var Ground = (function (_super) {
  534. __extends(Ground, _super);
  535. function Ground(id, scene, width, height, subdivisions, canBeRegenerated, mesh) {
  536. this.width = width;
  537. this.height = height;
  538. this.subdivisions = subdivisions;
  539. _super.call(this, id, scene, this._regenerateVertexData(), canBeRegenerated, mesh);
  540. }
  541. Ground.prototype._regenerateVertexData = function () {
  542. return BABYLON.VertexData.CreateGround(this.width, this.height, this.subdivisions);
  543. };
  544. Ground.prototype.copy = function (id) {
  545. return new Ground(id, this.getScene(), this.width, this.height, this.subdivisions, this.canBeRegenerated(), null);
  546. };
  547. return Ground;
  548. })(_Primitive);
  549. Primitives.Ground = Ground;
  550. var TiledGround = (function (_super) {
  551. __extends(TiledGround, _super);
  552. function TiledGround(id, scene, xmin, zmin, xmax, zmax, subdivisions, precision, canBeRegenerated, mesh) {
  553. this.xmin = xmin;
  554. this.zmin = zmin;
  555. this.xmax = xmax;
  556. this.zmax = zmax;
  557. this.subdivisions = subdivisions;
  558. this.precision = precision;
  559. _super.call(this, id, scene, this._regenerateVertexData(), canBeRegenerated, mesh);
  560. }
  561. TiledGround.prototype._regenerateVertexData = function () {
  562. return BABYLON.VertexData.CreateTiledGround(this.xmin, this.zmin, this.xmax, this.zmax, this.subdivisions, this.precision);
  563. };
  564. TiledGround.prototype.copy = function (id) {
  565. return new TiledGround(id, this.getScene(), this.xmin, this.zmin, this.xmax, this.zmax, this.subdivisions, this.precision, this.canBeRegenerated(), null);
  566. };
  567. return TiledGround;
  568. })(_Primitive);
  569. Primitives.TiledGround = TiledGround;
  570. var Plane = (function (_super) {
  571. __extends(Plane, _super);
  572. function Plane(id, scene, size, canBeRegenerated, mesh, side) {
  573. if (side === void 0) { side = BABYLON.Mesh.DEFAULTSIDE; }
  574. this.size = size;
  575. this.side = side;
  576. _super.call(this, id, scene, this._regenerateVertexData(), canBeRegenerated, mesh);
  577. }
  578. Plane.prototype._regenerateVertexData = function () {
  579. return BABYLON.VertexData.CreatePlane(this.size, this.side);
  580. };
  581. Plane.prototype.copy = function (id) {
  582. return new Plane(id, this.getScene(), this.size, this.canBeRegenerated(), null, this.side);
  583. };
  584. return Plane;
  585. })(_Primitive);
  586. Primitives.Plane = Plane;
  587. var TorusKnot = (function (_super) {
  588. __extends(TorusKnot, _super);
  589. function TorusKnot(id, scene, radius, tube, radialSegments, tubularSegments, p, q, canBeRegenerated, mesh, side) {
  590. if (side === void 0) { side = BABYLON.Mesh.DEFAULTSIDE; }
  591. this.radius = radius;
  592. this.tube = tube;
  593. this.radialSegments = radialSegments;
  594. this.tubularSegments = tubularSegments;
  595. this.p = p;
  596. this.q = q;
  597. this.side = side;
  598. _super.call(this, id, scene, this._regenerateVertexData(), canBeRegenerated, mesh);
  599. }
  600. TorusKnot.prototype._regenerateVertexData = function () {
  601. return BABYLON.VertexData.CreateTorusKnot(this.radius, this.tube, this.radialSegments, this.tubularSegments, this.p, this.q, this.side);
  602. };
  603. TorusKnot.prototype.copy = function (id) {
  604. return new TorusKnot(id, this.getScene(), this.radius, this.tube, this.radialSegments, this.tubularSegments, this.p, this.q, this.canBeRegenerated(), null, this.side);
  605. };
  606. return TorusKnot;
  607. })(_Primitive);
  608. Primitives.TorusKnot = TorusKnot;
  609. })(Primitives = Geometry.Primitives || (Geometry.Primitives = {}));
  610. })(Geometry = BABYLON.Geometry || (BABYLON.Geometry = {}));
  611. })(BABYLON || (BABYLON = {}));
  612. //# sourceMappingURL=babylon.geometry.js.map