poly-extrude 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * poly-extrude v0.12.0
2
+ * poly-extrude v0.13.0
3
3
  */
4
4
  (function (global, factory) {
5
5
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -4659,6 +4659,79 @@
4659
4659
  };
4660
4660
  }
4661
4661
 
4662
+ function plane(width, height, devideW, devideH) {
4663
+ devideW = Math.max(1, devideW);
4664
+ devideH = Math.max(1, devideH);
4665
+ var dx = width / devideW,
4666
+ dy = height / devideH;
4667
+ var minX = -width / 2,
4668
+ maxY = height / 2,
4669
+ minY = -height / 2;
4670
+ var len = (devideW + 1) * (devideH + 1);
4671
+ var position = new Float32Array(len * 3),
4672
+ uv = new Float32Array(len * 2),
4673
+ normal = new Float32Array(len * 3),
4674
+ indices = new Uint32Array(len * 10);
4675
+ var index = 0,
4676
+ uIndex = 0,
4677
+ iIndex = 0;
4678
+
4679
+ for (var j = 0; j <= devideH; j++) {
4680
+ for (var i = 0; i <= devideW; i++) {
4681
+ var x = minX + dx * i;
4682
+ var y = maxY - dy * j;
4683
+ position[index] = x;
4684
+ position[index + 1] = y;
4685
+ position[index + 2] = 0;
4686
+ normal[index] = 0;
4687
+ normal[index + 1] = 0;
4688
+ normal[index + 2] = 1; // position.push(x, y, 0);
4689
+ // normal.push(0, 0, 1);
4690
+
4691
+ var uvx = (x - minX) / width,
4692
+ uvy = (y - minY) / height; // uv.push(uvx, uvy);
4693
+
4694
+ uv[uIndex] = uvx;
4695
+ uv[uIndex + 1] = uvy;
4696
+ index += 3;
4697
+ uIndex += 2;
4698
+
4699
+ if (i < devideW && j < devideH) {
4700
+ var a = j * (devideW + 1) + i,
4701
+ b = a + 1,
4702
+ c = (devideW + 1) * (j + 1) + i,
4703
+ d = c + 1;
4704
+ indices[iIndex] = a;
4705
+ indices[iIndex + 1] = c;
4706
+ indices[iIndex + 2] = b;
4707
+ indices[iIndex + 3] = c;
4708
+ indices[iIndex + 4] = d;
4709
+ indices[iIndex + 5] = b;
4710
+ iIndex += 6; // indexs.push(a, c, b, c, d, b);
4711
+ }
4712
+ }
4713
+ }
4714
+
4715
+ var indexArray = new Uint32Array(iIndex);
4716
+
4717
+ for (var _i = 0, _len = indexArray.length; _i < _len; _i++) {
4718
+ indexArray[_i] = indices[_i];
4719
+ } // for (let j = 0; j < devideH; j++) {
4720
+ // for (let i = 0; i < devideW; i++) {
4721
+ // const a = j * (devideW + 1) + i, b = a + 1, c = (devideW + 1) * (j + 1) + i, d = c + 1;
4722
+ // indexs.push(a, c, b, c, d, b);
4723
+ // }
4724
+ // }
4725
+
4726
+
4727
+ return {
4728
+ position: position,
4729
+ uv: uv,
4730
+ normal: normal,
4731
+ indices: indexArray
4732
+ };
4733
+ }
4734
+
4662
4735
  exports.cylinder = cylinder;
4663
4736
  exports.expandLine = expandLine;
4664
4737
  exports.expandPaths = expandPaths;
@@ -4667,6 +4740,7 @@
4667
4740
  exports.extrudePolylines = extrudePolylines;
4668
4741
  exports.extrudeSlopes = extrudeSlopes;
4669
4742
  exports.leftOnLine = leftOnLine;
4743
+ exports.plane = plane;
4670
4744
 
4671
4745
  Object.defineProperty(exports, '__esModule', { value: true });
4672
4746