poly-extrude 0.8.0 → 0.9.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.
package/src/tube.js CHANGED
@@ -16,8 +16,8 @@ export function expandTubes(lines, options) {
16
16
  const result = generateTubeVertexData(pathPointList, options);
17
17
  result.line = line;
18
18
  result.position = new Float32Array(result.points);
19
- result.indices = new Uint32Array(result.index);
20
- result.uv = new Float32Array(result.uvs);
19
+ result.indices = new Uint32Array(result.indices);
20
+ result.uv = new Float32Array(result.uv);
21
21
  result.normal = new Float32Array(result.normal);
22
22
  return result;
23
23
  });
@@ -46,9 +46,9 @@ function generateTubeVertexData(pathPointList, options) {
46
46
  // modify data
47
47
  const points = [];
48
48
  const normal = [];
49
- const uvs = [];
49
+ const uv = [];
50
50
  // const uv2 = [];
51
- const index = [];
51
+ const indices = [];
52
52
  let verticesCount = 0;
53
53
 
54
54
  const normalDir = new Vector3();
@@ -78,8 +78,8 @@ function generateTubeVertexData(pathPointList, options) {
78
78
  normal[++nIndex] = normalDir.y;
79
79
  normal[++nIndex] = normalDir.z;
80
80
 
81
- uvs[++uIndex] = uvDist;
82
- uvs[++uIndex] = i / radialSegments;
81
+ uv[++uIndex] = uvDist;
82
+ uv[++uIndex] = i / radialSegments;
83
83
 
84
84
  // uvs.push(uvDist, r / radialSegments);
85
85
 
@@ -95,12 +95,12 @@ function generateTubeVertexData(pathPointList, options) {
95
95
  const begin2 = verticesCount - (radialSegments + 1);
96
96
 
97
97
  for (let i = 0; i < radialSegments; i++) {
98
- index[++iIndex] = begin2 + i;
99
- index[++iIndex] = begin1 + i;
100
- index[++iIndex] = begin1 + i + 1;
101
- index[++iIndex] = begin2 + i;
102
- index[++iIndex] = begin1 + i + 1;
103
- index[++iIndex] = begin2 + i + 1;
98
+ indices[++iIndex] = begin2 + i;
99
+ indices[++iIndex] = begin1 + i;
100
+ indices[++iIndex] = begin1 + i + 1;
101
+ indices[++iIndex] = begin2 + i;
102
+ indices[++iIndex] = begin1 + i + 1;
103
+ indices[++iIndex] = begin2 + i + 1;
104
104
  // index.push(
105
105
  // begin2 + i,
106
106
  // begin1 + i,
@@ -138,9 +138,9 @@ function generateTubeVertexData(pathPointList, options) {
138
138
  return {
139
139
  points,
140
140
  normal,
141
- uvs,
141
+ uv,
142
142
  // uv2,
143
- index,
143
+ indices,
144
144
  count
145
145
  };
146
146
  }
package/src/util.js CHANGED
@@ -176,17 +176,35 @@ export function generateSideWallUV(uvs, vertices, indexA, indexB, indexC, indexD
176
176
  const d_y = vertices[idx4 + 1];
177
177
  const d_z = vertices[idx4 + 2];
178
178
 
179
+ let uIndex = uvs.length - 1;
179
180
  if (Math.abs(a_y - b_y) < Math.abs(a_x - b_x)) {
180
-
181
- uvs.push(a_x, 1 - a_z);
182
- uvs.push(b_x, 1 - b_z);
183
- uvs.push(c_x, 1 - c_z);
184
- uvs.push(d_x, 1 - d_z);
181
+ uvs[++uIndex] = a_x;
182
+ uvs[++uIndex] = 1 - a_z;
183
+ uvs[++uIndex] = b_x;
184
+ uvs[++uIndex] = 1 - b_z;
185
+ uvs[++uIndex] = c_x;
186
+ uvs[++uIndex] = 1 - c_z;
187
+ uvs[++uIndex] = d_x;
188
+ uvs[++uIndex] = 1 - d_z;
189
+
190
+ // uvs.push(a_x, 1 - a_z);
191
+ // uvs.push(b_x, 1 - b_z);
192
+ // uvs.push(c_x, 1 - c_z);
193
+ // uvs.push(d_x, 1 - d_z);
185
194
  } else {
186
- uvs.push(a_y, 1 - a_z);
187
- uvs.push(b_y, 1 - b_z);
188
- uvs.push(c_y, 1 - c_z);
189
- uvs.push(d_y, 1 - d_z);
195
+ uvs[++uIndex] = a_y;
196
+ uvs[++uIndex] = 1 - a_z;
197
+ uvs[++uIndex] = b_y;
198
+ uvs[++uIndex] = 1 - b_z;
199
+ uvs[++uIndex] = c_y;
200
+ uvs[++uIndex] = 1 - c_z;
201
+ uvs[++uIndex] = d_y;
202
+ uvs[++uIndex] = 1 - d_z;
203
+
204
+ // uvs.push(a_y, 1 - a_z);
205
+ // uvs.push(b_y, 1 - b_z);
206
+ // uvs.push(c_y, 1 - c_z);
207
+ // uvs.push(d_y, 1 - d_z);
190
208
  }
191
209
 
192
210
  }