processing / processing/p5.js

[p5.js 2.0 Bug Report]: buildGeometry isn't saving per-vertex stroke colors

Open
#7,840 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area:WebGL p5.js 2.0+
Dominant language
JavaScript
Stars
24k
Forks
3.8k
Avg merge
3d 16h
Merged PRs (30d)
25

Description

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

2.0.2

Web browser and version

Firefox

Operating system

MacOS

Steps to reproduce this
Steps:
  1. In buildGeometry, draw a shape with per-vertex stroke colors
  2. Draw the geometry
  3. The stroke colors do not show up

The stroke vertex colors property of the geometry is an empty array, so it seems it's not getting created. Not sure if this is related or just a documentation/FES bug, but it also logs this message:

Expected number at the first parameter, but received null in color().

Snippet:
let geom

function setup() {
  createCanvas(400, 400, WEBGL);
  angleMode(DEGREES)
  
  strokeWeight(5)
  noFill()
  randomSeed(5)
  geom = buildGeometry(() => {
    // *** remove/replace POINTS and works as expected
    beginShape(LINES) // LINES or TRIANGLES or empty works fine
    for(let i=0; i < 50; i++){
      //push()
      stroke(random(255), random(255), random(255))
      let x = random(-width/2, width/2)
      let y = random(-width/2, width/2)
      let z = random(-width/2, width/2)
      vertex(x, y, z)
      vertex(x, y, z+10)
      //pop()
    }
    endShape()
  })
}

function draw() {
  background(0);
  orbitControl(3)
  rotateY(frameCount/3)
  
  strokeWeight(5)
  // stroke(255) // uncomment to show points
  model(geom)
}

Live: https://editor.p5js.org/davepagurek/sketches/uEPGri4DK

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the provided p5.js sketch in Firefox and inspect the WebGL paths used by buildGeometry and model, focusing on how POINTS captures per-vertex stroke colors. Done means the geometry retains those colors and model(geom) renders the expected strokes without the reported color() warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.