babylon.meshSimplification.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. var BABYLON;
  2. (function (BABYLON) {
  3. var SimplificationSettings = (function () {
  4. function SimplificationSettings(quality, distance) {
  5. this.quality = quality;
  6. this.distance = distance;
  7. }
  8. return SimplificationSettings;
  9. })();
  10. BABYLON.SimplificationSettings = SimplificationSettings;
  11. /**
  12. * The implemented types of simplification.
  13. * At the moment only Quadratic Error Decimation is implemented.
  14. */
  15. (function (SimplificationType) {
  16. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  17. })(BABYLON.SimplificationType || (BABYLON.SimplificationType = {}));
  18. var SimplificationType = BABYLON.SimplificationType;
  19. var DecimationTriangle = (function () {
  20. function DecimationTriangle(vertices) {
  21. this.vertices = vertices;
  22. this.error = new Array(4);
  23. this.deleted = false;
  24. this.isDirty = false;
  25. this.borderFactor = 0;
  26. }
  27. return DecimationTriangle;
  28. })();
  29. BABYLON.DecimationTriangle = DecimationTriangle;
  30. var DecimationVertex = (function () {
  31. function DecimationVertex(position, normal, uv, id) {
  32. this.position = position;
  33. this.normal = normal;
  34. this.uv = uv;
  35. this.id = id;
  36. this.isBorder = true;
  37. this.q = new QuadraticMatrix();
  38. this.triangleCount = 0;
  39. this.triangleStart = 0;
  40. }
  41. return DecimationVertex;
  42. })();
  43. BABYLON.DecimationVertex = DecimationVertex;
  44. var QuadraticMatrix = (function () {
  45. function QuadraticMatrix(data) {
  46. this.data = new Array(10);
  47. for (var i = 0; i < 10; ++i) {
  48. if (data && data[i]) {
  49. this.data[i] = data[i];
  50. }
  51. else {
  52. this.data[i] = 0;
  53. }
  54. }
  55. }
  56. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  57. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] + this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] - this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  58. return det;
  59. };
  60. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  61. for (var i = 0; i < 10; ++i) {
  62. this.data[i] += matrix.data[i];
  63. }
  64. };
  65. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  66. for (var i = 0; i < 10; ++i) {
  67. this.data[i] += data[i];
  68. }
  69. };
  70. QuadraticMatrix.prototype.add = function (matrix) {
  71. var m = new QuadraticMatrix();
  72. for (var i = 0; i < 10; ++i) {
  73. m.data[i] = this.data[i] + matrix.data[i];
  74. }
  75. return m;
  76. };
  77. QuadraticMatrix.FromData = function (a, b, c, d) {
  78. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  79. };
  80. //returning an array to avoid garbage collection
  81. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  82. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  83. };
  84. return QuadraticMatrix;
  85. })();
  86. BABYLON.QuadraticMatrix = QuadraticMatrix;
  87. var Reference = (function () {
  88. function Reference(vertexId, triangleId) {
  89. this.vertexId = vertexId;
  90. this.triangleId = triangleId;
  91. }
  92. return Reference;
  93. })();
  94. BABYLON.Reference = Reference;
  95. /**
  96. * An implementation of the Quadratic Error simplification algorithm.
  97. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  98. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  99. * @author RaananW
  100. */
  101. var QuadraticErrorSimplification = (function () {
  102. function QuadraticErrorSimplification(_mesh) {
  103. this._mesh = _mesh;
  104. this.initialised = false;
  105. this.syncIterations = 5000;
  106. this.aggressiveness = 7;
  107. this.decimationIterations = 100;
  108. }
  109. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  110. var _this = this;
  111. this.initWithMesh(this._mesh, function () {
  112. _this.runDecimation(settings, successCallback);
  113. });
  114. };
  115. QuadraticErrorSimplification.prototype.runDecimation = function (settings, successCallback) {
  116. var _this = this;
  117. var targetCount = ~~(this.triangles.length * settings.quality);
  118. var deletedTriangles = 0;
  119. var triangleCount = this.triangles.length;
  120. var iterationFunction = function (iteration, callback) {
  121. setTimeout(function () {
  122. if (iteration % 5 === 0) {
  123. _this.updateMesh(iteration === 0);
  124. }
  125. for (var i = 0; i < _this.triangles.length; ++i) {
  126. _this.triangles[i].isDirty = false;
  127. }
  128. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  129. var trianglesIterator = function (i) {
  130. var tIdx = ((_this.triangles.length / 2) + i) % _this.triangles.length;
  131. var t = _this.triangles[tIdx];
  132. if (!t)
  133. return;
  134. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  135. return;
  136. }
  137. for (var j = 0; j < 3; ++j) {
  138. if (t.error[j] < threshold) {
  139. var deleted0 = [];
  140. var deleted1 = [];
  141. var i0 = t.vertices[j];
  142. var i1 = t.vertices[(j + 1) % 3];
  143. var v0 = _this.vertices[i0];
  144. var v1 = _this.vertices[i1];
  145. if (v0.isBorder !== v1.isBorder)
  146. continue;
  147. var p = BABYLON.Vector3.Zero();
  148. var n = BABYLON.Vector3.Zero();
  149. var uv = BABYLON.Vector2.Zero();
  150. _this.calculateError(v0, v1, p, n, uv);
  151. if (_this.isFlipped(v0, i1, p, deleted0, t.borderFactor))
  152. continue;
  153. if (_this.isFlipped(v1, i0, p, deleted1, t.borderFactor))
  154. continue;
  155. v0.position = p;
  156. v0.normal = n;
  157. v0.uv = uv;
  158. v0.q = v1.q.add(v0.q);
  159. var tStart = _this.references.length;
  160. deletedTriangles = _this.updateTriangles(v0.id, v0, deleted0, deletedTriangles);
  161. deletedTriangles = _this.updateTriangles(v0.id, v1, deleted1, deletedTriangles);
  162. var tCount = _this.references.length - tStart;
  163. if (tCount <= v0.triangleCount) {
  164. if (tCount) {
  165. for (var c = 0; c < tCount; c++) {
  166. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  167. }
  168. }
  169. }
  170. else {
  171. v0.triangleStart = tStart;
  172. }
  173. v0.triangleCount = tCount;
  174. break;
  175. }
  176. }
  177. };
  178. BABYLON.AsyncLoop.SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () {
  179. return (triangleCount - deletedTriangles <= targetCount);
  180. });
  181. }, 0);
  182. };
  183. BABYLON.AsyncLoop.Run(this.decimationIterations, function (loop) {
  184. if (triangleCount - deletedTriangles <= targetCount)
  185. loop.breakLoop();
  186. else {
  187. iterationFunction(loop.index, function () {
  188. loop.executeNext();
  189. });
  190. }
  191. }, function () {
  192. setTimeout(function () {
  193. successCallback(_this.reconstructMesh());
  194. }, 0);
  195. });
  196. };
  197. QuadraticErrorSimplification.prototype.initWithMesh = function (mesh, callback) {
  198. var _this = this;
  199. if (!mesh)
  200. return;
  201. this.vertices = [];
  202. this.triangles = [];
  203. this._mesh = mesh;
  204. //It is assumed that a mesh has positions, normals and either uvs or colors.
  205. var positionData = this._mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);
  206. var normalData = this._mesh.getVerticesData(BABYLON.VertexBuffer.NormalKind);
  207. var uvs = this._mesh.getVerticesData(BABYLON.VertexBuffer.UVKind);
  208. var colorsData = this._mesh.getVerticesData(BABYLON.VertexBuffer.ColorKind);
  209. var indices = mesh.getIndices();
  210. var vertexInit = function (i) {
  211. var uv;
  212. if (uvs[i * 2]) {
  213. uv = BABYLON.Vector2.FromArray(uvs, i * 2);
  214. }
  215. var vertex = new DecimationVertex(BABYLON.Vector3.FromArray(positionData, i * 3), BABYLON.Vector3.FromArray(normalData, i * 3), uv, i);
  216. if (!uv && colorsData[i * 3]) {
  217. vertex.color = BABYLON.Color3.FromArray(colorsData, i * 3);
  218. }
  219. _this.vertices.push(vertex);
  220. };
  221. var totalVertices = mesh.getTotalVertices();
  222. BABYLON.AsyncLoop.SyncAsyncForLoop(totalVertices, this.syncIterations, vertexInit, function () {
  223. var indicesInit = function (i) {
  224. var pos = i * 3;
  225. var i0 = indices[pos + 0];
  226. var i1 = indices[pos + 1];
  227. var i2 = indices[pos + 2];
  228. var triangle = new DecimationTriangle([_this.vertices[i0].id, _this.vertices[i1].id, _this.vertices[i2].id]);
  229. _this.triangles.push(triangle);
  230. };
  231. BABYLON.AsyncLoop.SyncAsyncForLoop(indices.length / 3, _this.syncIterations, indicesInit, function () {
  232. _this.init(callback);
  233. });
  234. });
  235. };
  236. QuadraticErrorSimplification.prototype.init = function (callback) {
  237. var _this = this;
  238. var triangleInit1 = function (i) {
  239. var t = _this.triangles[i];
  240. t.normal = BABYLON.Vector3.Cross(_this.vertices[t.vertices[1]].position.subtract(_this.vertices[t.vertices[0]].position), _this.vertices[t.vertices[2]].position.subtract(_this.vertices[t.vertices[0]].position)).normalize();
  241. for (var j = 0; j < 3; j++) {
  242. _this.vertices[t.vertices[j]].q.addArrayInPlace(QuadraticMatrix.DataFromNumbers(t.normal.x, t.normal.y, t.normal.z, -(BABYLON.Vector3.Dot(t.normal, _this.vertices[t.vertices[0]].position))));
  243. }
  244. };
  245. BABYLON.AsyncLoop.SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  246. var triangleInit2 = function (i) {
  247. var t = _this.triangles[i];
  248. for (var j = 0; j < 3; ++j) {
  249. t.error[j] = _this.calculateError(_this.vertices[t.vertices[j]], _this.vertices[t.vertices[(j + 1) % 3]]);
  250. }
  251. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  252. };
  253. BABYLON.AsyncLoop.SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  254. _this.initialised = true;
  255. callback();
  256. });
  257. });
  258. };
  259. QuadraticErrorSimplification.prototype.reconstructMesh = function () {
  260. var newTriangles = [];
  261. var i;
  262. for (i = 0; i < this.vertices.length; ++i) {
  263. this.vertices[i].triangleCount = 0;
  264. }
  265. var t;
  266. var j;
  267. for (i = 0; i < this.triangles.length; ++i) {
  268. if (!this.triangles[i].deleted) {
  269. t = this.triangles[i];
  270. for (j = 0; j < 3; ++j) {
  271. this.vertices[t.vertices[j]].triangleCount = 1;
  272. }
  273. newTriangles.push(t);
  274. }
  275. }
  276. var newVerticesOrder = [];
  277. //compact vertices, get the IDs of the vertices used.
  278. var dst = 0;
  279. for (i = 0; i < this.vertices.length; ++i) {
  280. if (this.vertices[i].triangleCount) {
  281. this.vertices[i].triangleStart = dst;
  282. this.vertices[dst].position = this.vertices[i].position;
  283. this.vertices[dst].normal = this.vertices[i].normal;
  284. this.vertices[dst].uv = this.vertices[i].uv;
  285. newVerticesOrder.push(i);
  286. dst++;
  287. }
  288. }
  289. for (i = 0; i < newTriangles.length; ++i) {
  290. t = newTriangles[i];
  291. for (j = 0; j < 3; ++j) {
  292. t.vertices[j] = this.vertices[t.vertices[j]].triangleStart;
  293. }
  294. }
  295. this.vertices = this.vertices.slice(0, dst);
  296. var newPositionData = [];
  297. var newNormalData = [];
  298. var newUVsData = [];
  299. var newColorsData = [];
  300. for (i = 0; i < newVerticesOrder.length; ++i) {
  301. newPositionData.push(this.vertices[i].position.x);
  302. newPositionData.push(this.vertices[i].position.y);
  303. newPositionData.push(this.vertices[i].position.z);
  304. newNormalData.push(this.vertices[i].normal.x);
  305. newNormalData.push(this.vertices[i].normal.y);
  306. newNormalData.push(this.vertices[i].normal.z);
  307. if (this.vertices[i].uv) {
  308. newUVsData.push(this.vertices[i].uv.x);
  309. newUVsData.push(this.vertices[i].uv.y);
  310. }
  311. else if (this.vertices[i].color) {
  312. newColorsData.push(this.vertices[i].color.r);
  313. newColorsData.push(this.vertices[i].color.g);
  314. newColorsData.push(this.vertices[i].color.b);
  315. }
  316. }
  317. var newIndicesArray = [];
  318. for (i = 0; i < newTriangles.length; ++i) {
  319. newIndicesArray.push(newTriangles[i].vertices[0]);
  320. newIndicesArray.push(newTriangles[i].vertices[1]);
  321. newIndicesArray.push(newTriangles[i].vertices[2]);
  322. }
  323. //not cloning, to avoid geometry problems. Creating a whole new mesh.
  324. var newMesh = new BABYLON.Mesh(this._mesh + "Decimated", this._mesh.getScene());
  325. newMesh.material = this._mesh.material;
  326. newMesh.parent = this._mesh.parent;
  327. newMesh.setIndices(newIndicesArray);
  328. newMesh.setVerticesData(BABYLON.VertexBuffer.PositionKind, newPositionData);
  329. newMesh.setVerticesData(BABYLON.VertexBuffer.NormalKind, newNormalData);
  330. if (newUVsData.length > 0)
  331. newMesh.setVerticesData(BABYLON.VertexBuffer.UVKind, newUVsData);
  332. if (newColorsData.length > 0)
  333. newMesh.setVerticesData(BABYLON.VertexBuffer.ColorKind, newColorsData);
  334. //preparing the skeleton support
  335. if (this._mesh.skeleton) {
  336. }
  337. return newMesh;
  338. };
  339. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, index2, point, deletedArray, borderFactor) {
  340. for (var i = 0; i < vertex1.triangleCount; ++i) {
  341. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  342. if (t.deleted)
  343. continue;
  344. var s = this.references[vertex1.triangleStart + i].vertexId;
  345. var id1 = t.vertices[(s + 1) % 3];
  346. var id2 = t.vertices[(s + 2) % 3];
  347. if ((id1 === index2 || id2 === index2) && borderFactor < 2) {
  348. deletedArray[i] = true;
  349. continue;
  350. }
  351. var d1 = this.vertices[id1].position.subtract(point);
  352. d1 = d1.normalize();
  353. var d2 = this.vertices[id2].position.subtract(point);
  354. d2 = d2.normalize();
  355. if (Math.abs(BABYLON.Vector3.Dot(d1, d2)) > 0.999)
  356. return true;
  357. var normal = BABYLON.Vector3.Cross(d1, d2).normalize();
  358. deletedArray[i] = false;
  359. if (BABYLON.Vector3.Dot(normal, t.normal) < 0.2)
  360. return true;
  361. }
  362. return false;
  363. };
  364. QuadraticErrorSimplification.prototype.updateTriangles = function (vertexId, vertex, deletedArray, deletedTriangles) {
  365. var newDeleted = deletedTriangles;
  366. for (var i = 0; i < vertex.triangleCount; ++i) {
  367. var ref = this.references[vertex.triangleStart + i];
  368. var t = this.triangles[ref.triangleId];
  369. if (t.deleted)
  370. continue;
  371. if (deletedArray[i]) {
  372. t.deleted = true;
  373. newDeleted++;
  374. continue;
  375. }
  376. t.vertices[ref.vertexId] = vertexId;
  377. t.isDirty = true;
  378. t.error[0] = this.calculateError(this.vertices[t.vertices[0]], this.vertices[t.vertices[1]]) + (t.borderFactor / 2);
  379. t.error[1] = this.calculateError(this.vertices[t.vertices[1]], this.vertices[t.vertices[2]]) + (t.borderFactor / 2);
  380. t.error[2] = this.calculateError(this.vertices[t.vertices[2]], this.vertices[t.vertices[0]]) + (t.borderFactor / 2);
  381. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  382. this.references.push(ref);
  383. }
  384. return newDeleted;
  385. };
  386. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  387. for (var i = 0; i < this.vertices.length; ++i) {
  388. var vCount = [];
  389. var vId = [];
  390. var v = this.vertices[i];
  391. var j;
  392. for (j = 0; j < v.triangleCount; ++j) {
  393. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  394. for (var ii = 0; ii < 3; ii++) {
  395. var ofs = 0;
  396. var id = triangle.vertices[ii];
  397. while (ofs < vCount.length) {
  398. if (vId[ofs] === id)
  399. break;
  400. ++ofs;
  401. }
  402. if (ofs === vCount.length) {
  403. vCount.push(1);
  404. vId.push(id);
  405. }
  406. else {
  407. vCount[ofs]++;
  408. }
  409. }
  410. }
  411. for (j = 0; j < vCount.length; ++j) {
  412. if (vCount[j] === 1) {
  413. this.vertices[vId[j]].isBorder = true;
  414. }
  415. else {
  416. this.vertices[vId[j]].isBorder = false;
  417. }
  418. }
  419. }
  420. };
  421. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  422. if (identifyBorders === void 0) { identifyBorders = false; }
  423. var i;
  424. if (!identifyBorders) {
  425. var newTrianglesVector = [];
  426. for (i = 0; i < this.triangles.length; ++i) {
  427. if (!this.triangles[i].deleted) {
  428. newTrianglesVector.push(this.triangles[i]);
  429. }
  430. }
  431. this.triangles = newTrianglesVector;
  432. }
  433. for (i = 0; i < this.vertices.length; ++i) {
  434. this.vertices[i].triangleCount = 0;
  435. this.vertices[i].triangleStart = 0;
  436. }
  437. var t;
  438. var j;
  439. var v;
  440. for (i = 0; i < this.triangles.length; ++i) {
  441. t = this.triangles[i];
  442. for (j = 0; j < 3; ++j) {
  443. v = this.vertices[t.vertices[j]];
  444. v.triangleCount++;
  445. }
  446. }
  447. var tStart = 0;
  448. for (i = 0; i < this.vertices.length; ++i) {
  449. this.vertices[i].triangleStart = tStart;
  450. tStart += this.vertices[i].triangleCount;
  451. this.vertices[i].triangleCount = 0;
  452. }
  453. var newReferences = new Array(this.triangles.length * 3);
  454. for (i = 0; i < this.triangles.length; ++i) {
  455. t = this.triangles[i];
  456. for (j = 0; j < 3; ++j) {
  457. v = this.vertices[t.vertices[j]];
  458. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  459. v.triangleCount++;
  460. }
  461. }
  462. this.references = newReferences;
  463. if (identifyBorders) {
  464. this.identifyBorder();
  465. }
  466. };
  467. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  468. var x = point.x;
  469. var y = point.y;
  470. var z = point.z;
  471. return q.data[0] * x * x + 2 * q.data[1] * x * y + 2 * q.data[2] * x * z + 2 * q.data[3] * x + q.data[4] * y * y + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  472. };
  473. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult, normalResult, uvResult) {
  474. var q = vertex1.q.add(vertex2.q);
  475. var border = vertex1.isBorder && vertex2.isBorder;
  476. var error = 0;
  477. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  478. if (qDet !== 0 && !border) {
  479. if (!pointResult) {
  480. pointResult = BABYLON.Vector3.Zero();
  481. }
  482. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  483. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  484. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  485. error = this.vertexError(q, pointResult);
  486. //TODO this should be correctly calculated
  487. if (normalResult) {
  488. normalResult.copyFrom(vertex1.normal);
  489. uvResult.copyFrom(vertex1.uv);
  490. }
  491. }
  492. else {
  493. var p3 = (vertex1.position.add(vertex2.position)).divide(new BABYLON.Vector3(2, 2, 2));
  494. var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new BABYLON.Vector3(2, 2, 2)).normalize();
  495. var error1 = this.vertexError(q, vertex1.position);
  496. var error2 = this.vertexError(q, vertex2.position);
  497. var error3 = this.vertexError(q, p3);
  498. error = Math.min(error1, error2, error3);
  499. if (error === error1) {
  500. if (pointResult) {
  501. pointResult.copyFrom(vertex1.position);
  502. normalResult.copyFrom(vertex1.normal);
  503. uvResult.copyFrom(vertex1.uv);
  504. }
  505. }
  506. else if (error === error2) {
  507. if (pointResult) {
  508. pointResult.copyFrom(vertex2.position);
  509. normalResult.copyFrom(vertex2.normal);
  510. uvResult.copyFrom(vertex2.uv);
  511. }
  512. }
  513. else {
  514. if (pointResult) {
  515. pointResult.copyFrom(p3);
  516. normalResult.copyFrom(norm3);
  517. uvResult.copyFrom(vertex1.uv);
  518. }
  519. }
  520. }
  521. return error;
  522. };
  523. return QuadraticErrorSimplification;
  524. })();
  525. BABYLON.QuadraticErrorSimplification = QuadraticErrorSimplification;
  526. })(BABYLON || (BABYLON = {}));
  527. //# sourceMappingURL=babylon.meshSimplification.js.map