Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[p5.js 2.0+ Bug Report]: TRIANGLES Requires Multiples of 3

Đang mở Phù hợp với người mới
#9,319 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
66/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện trường hợp được báo cáo trong sketch của trình chỉnh sửa p5.js được liên kết: gọi beginShape(TRIANGLES), thêm bốn đỉnh rồi gọi endShape(). So sánh kết quả với p5.js 1, phiên bản đã bỏ qua đỉnh thừa. Hoàn thành khi p5.js 2 xử lý đỉnh thừa mà không gây lỗi runtime và vẽ được tam giác hoàn chỉnh.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Area:Core p5.js 2.0+
Most appropriate sub-area of p5.js?
  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • WebGPU
  • p5.strands
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)
p5.js version

2.3.4

Web browser and version

No response

Operating system

No response

Steps to reproduce this
Steps:

Creating a custom shape using the beginShape(TRIANGLES) option in v2.0+ requires the number of vertices to be exactly a multiple of 3 or it will hit a runtime error and not draw anything. The error is not a particularly friendly one: TypeError: can't access property "position", v1 is undefined

In p5 V1, extra vertices that could not be wrangled into a triangle (e.g. a shape with 4 vertices) were simply ignored.

I think the V1 method makes a lot more sense, and we should go back to ignoring extra vertices. This would also maintain some continuity for people porting V1 code to V2.

Snippet:

https://editor.p5js.org/lewi0622/sketches/lnZLG0GhN


  beginShape(TRIANGLES);
  vertex(random(width), random(height));
  vertex(random(width), random(height));
  vertex(random(width), random(height));
  //uncommment fourth vertex to see issue in v2+, not in an issue in v1
  // vertex(random(width), random(height));
  endShape();

Ngôn ngữ chính
JavaScript
Star
24.2k
Fork
3.9k
Merge trung bình
2 ngày 17 giờ
Pull request đã merge (30 ngày)
35

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của processing/p5.js

Tất cả issue của processing/p5.js

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.