@xort/cga 0.0.89 → 0.0.91
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/dist/alg/extrude.js +2 -2
- package/dist/math/vecs.js +30 -22
- package/package.json +1 -1
- package/src/alg/extrude.ts +2 -2
- package/src/math/vecs.ts +29 -21
package/dist/alg/extrude.js
CHANGED
|
@@ -169,7 +169,7 @@ function linkSides(options) {
|
|
|
169
169
|
var startHoles = (0, common_1.clone)(holess[0]);
|
|
170
170
|
allVertics.push(startHoles);
|
|
171
171
|
}
|
|
172
|
-
var startTris = (0, trianglution_1.triangulation)(orgShape, orgHoles, { feature:
|
|
172
|
+
var startTris = (0, trianglution_1.triangulation)(orgShape, orgHoles, { feature: options.axisPlane });
|
|
173
173
|
if (index) {
|
|
174
174
|
startTris.forEach(function (v, i) {
|
|
175
175
|
startTris[i] = v + (index === null || index === void 0 ? void 0 : index.index);
|
|
@@ -189,7 +189,7 @@ function linkSides(options) {
|
|
|
189
189
|
var endHoles = (0, common_1.clone)((0, common_1.clone)(holess[holess.length - 1]));
|
|
190
190
|
allVertics.push(endHoles);
|
|
191
191
|
}
|
|
192
|
-
var endTris = (0, trianglution_1.triangulation)(orgShape, orgHoles, { feature:
|
|
192
|
+
var endTris = (0, trianglution_1.triangulation)(orgShape, orgHoles, { feature: options.axisPlane });
|
|
193
193
|
if (index) {
|
|
194
194
|
endTris.forEach(function (v, i) {
|
|
195
195
|
endTris[i] = v + (index === null || index === void 0 ? void 0 : index.index);
|
package/dist/math/vecs.js
CHANGED
|
@@ -336,44 +336,52 @@ var vecs = /** @class */ (function () {
|
|
|
336
336
|
* @returns {Array<Number>} 数字数组
|
|
337
337
|
*/
|
|
338
338
|
vecs.verctorToNumbers = function (vectors, comSort) {
|
|
339
|
-
if (comSort === void 0) { comSort = "xyz"; }
|
|
340
339
|
if (!(vectors instanceof Array)) {
|
|
341
340
|
console.error("传入参数必须是数组");
|
|
342
341
|
return [];
|
|
343
342
|
}
|
|
344
343
|
var numbers = [];
|
|
345
|
-
if (
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
for (var
|
|
349
|
-
|
|
344
|
+
if (!comSort) {
|
|
345
|
+
if (vectors[0].x !== undefined && vectors[0].y !== undefined && vectors[0].z !== undefined && vectors[0].w !== undefined) {
|
|
346
|
+
comSort = !comSort ? 'xyzw' : comSort;
|
|
347
|
+
for (var i = 0; i < vectors.length; i++) {
|
|
348
|
+
for (var j = 0; j < comSort.length; j++) {
|
|
349
|
+
numbers.push(vectors[i][comSort[j]]);
|
|
350
|
+
}
|
|
350
351
|
}
|
|
351
352
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
353
|
+
if (vectors[0].x !== undefined && vectors[0].y !== undefined && vectors[0].z !== undefined) {
|
|
354
|
+
comSort = !comSort ? 'xyz' : comSort;
|
|
355
|
+
for (var i = 0; i < vectors.length; i++) {
|
|
356
|
+
for (var j = 0; j < comSort.length; j++) {
|
|
357
|
+
numbers.push(vectors[i][comSort[j]]);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
else if (vectors[0].x !== undefined && vectors[0].y !== undefined) {
|
|
362
|
+
comSort = !comSort ? 'xy' : comSort;
|
|
363
|
+
for (var i = 0; i < vectors.length; i++) {
|
|
364
|
+
for (var j = 0; j < comSort.length; j++) {
|
|
365
|
+
numbers.push(vectors[i][comSort[j]]);
|
|
366
|
+
}
|
|
358
367
|
}
|
|
359
368
|
}
|
|
369
|
+
else if (vectors[0] instanceof Array) {
|
|
370
|
+
for (var i = 0; i < vectors.length; i++) {
|
|
371
|
+
numbers = numbers.concat(vecs.verctorToNumbers(vectors[i]));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
console.error("数组内部的元素不是向量");
|
|
376
|
+
}
|
|
360
377
|
}
|
|
361
|
-
else
|
|
362
|
-
comSort = comSort.length !== 2 ? 'xy' : comSort;
|
|
378
|
+
else {
|
|
363
379
|
for (var i = 0; i < vectors.length; i++) {
|
|
364
380
|
for (var j = 0; j < comSort.length; j++) {
|
|
365
381
|
numbers.push(vectors[i][comSort[j]]);
|
|
366
382
|
}
|
|
367
383
|
}
|
|
368
384
|
}
|
|
369
|
-
else if (vectors[0] instanceof Array) {
|
|
370
|
-
for (var i = 0; i < vectors.length; i++) {
|
|
371
|
-
numbers = numbers.concat(vecs.verctorToNumbers(vectors[i]));
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
else {
|
|
375
|
-
console.error("数组内部的元素不是向量");
|
|
376
|
-
}
|
|
377
385
|
return numbers;
|
|
378
386
|
};
|
|
379
387
|
vecs.vec = function (component) {
|
package/package.json
CHANGED
package/src/alg/extrude.ts
CHANGED
|
@@ -211,7 +211,7 @@ export function linkSides(options: ILinkSideOptions): IGeometry {
|
|
|
211
211
|
allVertics.push(startHoles)
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
var startTris = triangulation(orgShape, orgHoles, { feature:
|
|
214
|
+
var startTris = triangulation(orgShape, orgHoles, { feature: options.axisPlane });
|
|
215
215
|
if (index) {
|
|
216
216
|
startTris.forEach((v: number, i: number) => {
|
|
217
217
|
startTris[i] = v + index?.index;
|
|
@@ -234,7 +234,7 @@ export function linkSides(options: ILinkSideOptions): IGeometry {
|
|
|
234
234
|
var endHoles = clone(clone(holess[holess.length - 1]));
|
|
235
235
|
allVertics.push(endHoles)
|
|
236
236
|
}
|
|
237
|
-
var endTris = triangulation(orgShape, orgHoles, { feature:
|
|
237
|
+
var endTris = triangulation(orgShape, orgHoles, { feature: options.axisPlane });
|
|
238
238
|
if (index) {
|
|
239
239
|
endTris.forEach((v: number, i: number) => {
|
|
240
240
|
endTris[i] = v + index?.index;
|
package/src/math/vecs.ts
CHANGED
|
@@ -353,43 +353,51 @@ export class vecs {
|
|
|
353
353
|
* @param {String} comSort 'x','y','z','w' 按顺序选取后自由组合
|
|
354
354
|
* @returns {Array<Number>} 数字数组
|
|
355
355
|
*/
|
|
356
|
-
static verctorToNumbers(vectors: Array<Vec4 | Vec3 | Vec2 | any> | any, comSort
|
|
356
|
+
static verctorToNumbers(vectors: Array<Vec4 | Vec3 | Vec2 | any> | any, comSort?: string): number[] {
|
|
357
357
|
if (!(vectors instanceof Array)) {
|
|
358
358
|
console.error("传入参数必须是数组");
|
|
359
359
|
return [];
|
|
360
360
|
}
|
|
361
361
|
|
|
362
362
|
var numbers: number[] = [];
|
|
363
|
-
if (
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
for (
|
|
367
|
-
|
|
363
|
+
if (!comSort) {
|
|
364
|
+
if (vectors[0].x !== undefined && vectors[0].y !== undefined && vectors[0].z !== undefined && vectors[0].w !== undefined) {
|
|
365
|
+
comSort = !comSort ? 'xyzw' : comSort;
|
|
366
|
+
for (var i = 0; i < vectors.length; i++) {
|
|
367
|
+
for (let j = 0; j < comSort.length; j++) {
|
|
368
|
+
numbers.push(vectors[i][comSort[j]]);
|
|
369
|
+
}
|
|
368
370
|
}
|
|
369
371
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
372
|
+
if (vectors[0].x !== undefined && vectors[0].y !== undefined && vectors[0].z !== undefined) {
|
|
373
|
+
comSort = !comSort ? 'xyz' : comSort;
|
|
374
|
+
for (var i = 0; i < vectors.length; i++) {
|
|
375
|
+
for (let j = 0; j < comSort.length; j++) {
|
|
376
|
+
numbers.push(vectors[i][comSort[j]]);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
} else if (vectors[0].x !== undefined && vectors[0].y !== undefined) {
|
|
380
|
+
comSort = !comSort ? 'xy' : comSort;
|
|
381
|
+
for (var i = 0; i < vectors.length; i++) {
|
|
382
|
+
for (let j = 0; j < comSort.length; j++) {
|
|
383
|
+
numbers.push(vectors[i][comSort[j]]);
|
|
384
|
+
}
|
|
376
385
|
}
|
|
377
386
|
}
|
|
378
|
-
|
|
379
|
-
|
|
387
|
+
else if (vectors[0] instanceof Array) {
|
|
388
|
+
for (var i = 0; i < vectors.length; i++) {
|
|
389
|
+
numbers = numbers.concat(vecs.verctorToNumbers(vectors[i]));
|
|
390
|
+
}
|
|
391
|
+
} else {
|
|
392
|
+
console.error("数组内部的元素不是向量");
|
|
393
|
+
}
|
|
394
|
+
} else {
|
|
380
395
|
for (var i = 0; i < vectors.length; i++) {
|
|
381
396
|
for (let j = 0; j < comSort.length; j++) {
|
|
382
397
|
numbers.push(vectors[i][comSort[j]]);
|
|
383
398
|
}
|
|
384
399
|
}
|
|
385
400
|
}
|
|
386
|
-
else if (vectors[0] instanceof Array) {
|
|
387
|
-
for (var i = 0; i < vectors.length; i++) {
|
|
388
|
-
numbers = numbers.concat(vecs.verctorToNumbers(vectors[i]));
|
|
389
|
-
}
|
|
390
|
-
} else {
|
|
391
|
-
console.error("数组内部的元素不是向量");
|
|
392
|
-
}
|
|
393
401
|
|
|
394
402
|
return numbers;
|
|
395
403
|
}
|