Skip to content

Add Body field example by p5.strands and ml5.js - #1636

Closed
pearmini wants to merge 3 commits into
processing:strands-examplesfrom
pearmini:body-field-example
Closed

pearmini wants to merge 3 commits into
processing:strands-examplesfrom
pearmini:body-field-example

Conversation

@pearmini

Copy link
Copy Markdown

Adds an interactive Body Field example using ml5.js @shiffman body tracking and p5.strands, created at OSACC 2026. Inspired by @golanlevin and @davepagurek 's great work!

Also enables example pages to load additional libraries and the WebGPU addon.

@davepagurek

Copy link
Copy Markdown
Collaborator

Thanks for adding this @pearmini! I'm going to make updates to #1635 and get your PR merged later this weekend 🙂

height?: number;
base?: string;
scripts?: string[];
includeWebGPU?: boolean;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for wiring this up!

// Adapted from https://openprocessing.org/@golan/2405195
function bodyField() {
const points = uniformStorage(dataStorage);
const progress = uniformFloat("u_progress");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: we can simplify this a little by omitting the manual uniform name here, and then it defaults to the variable name, so you can call .setUniform('progress', something) later

const coord = filterColor.texCoord;

// Find the distance from this pixel to the nearest body point.
let minDist = 1.0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another small simplification: in strands, we use the js convention of every number being a float, so you don't need the .0 suffix in the code for it to work!

<EditableSketch code={code} />
<EditableSketch
code={code}
scripts={example.data.scripts}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe if there are other scripts to include we should add something below the code? Either automatically here when they're included, or in the description of the sketch, so people know if they copy and paste the code that they have to add some other scripts too?

@ksen0
ksen0 deleted the branch processing:strands-examples November 4, 2026 09:11
@ksen0 ksen0 closed this Nov 4, 2026
@ksen0

ksen0 commented Nov 4, 2026

Copy link
Copy Markdown
Member

Hello! I'm so sorry that this got auto-closed when I merged Dave's PR, that wasn't the intent! @pearmini are you able to reinstate the branch? I can't reopen as the branch is closed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants