ModelUtils.ts 806 B

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * 合并
  3. * @param rowPoints
  4. * @param colPoints
  5. */
  6. export function mergePointArray(rowPoints : cc.Vec2[], colPoints: cc.Vec2[]){
  7. let result = rowPoints.concat();
  8. colPoints = colPoints.filter(function (colEle) {
  9. let repeat = false;
  10. result.forEach(function (rowEle) {
  11. if(colEle.equals(rowEle)){
  12. repeat = true
  13. }
  14. }, this);
  15. return !repeat;
  16. }, this);
  17. result.push(...colPoints);
  18. return result;
  19. }
  20. /**
  21. * 减法
  22. * @param points
  23. * @param exclusivePoint
  24. */
  25. export function exclusivePoint(points: cc.Vec2[], exclusivePoint: cc.Vec2){
  26. let result = new Array<cc.Vec2>();
  27. for(let point of points){
  28. if(!point.equals(exclusivePoint)){
  29. result.push(point);
  30. }
  31. }
  32. return result;
  33. }