babylon.geometry.js 28 KB

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