babylon.geometry.js 26 KB

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