babylon.geometry.js 27 KB

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