Skip to content

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

Open
@davepagurek

Description

@davepagurek

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Open for Discussion

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions