babylon.geometry.js 27 KB

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