Skip to content

Commit 6988ba1

Browse files
committed
switch to using strands' millis()
1 parent 6fe4553 commit 6988ba1

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

src/content/tutorials/en/intro-to-p5-strands.mdx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,13 @@ Strands provides a function, `millis()`, that returns the number of milliseconds
282282
283283
function instancingCallback() {
284284
285-
const MILLIS = uniformFloat(() => millis());
286285
function getAnimatedSpherePosition() {
287286
let id = instanceID();
288287
let theta = noise([id, 0.1234]) * TWO_PI;
289288
// change the particle's position
290289
// over time:
291290
let phi = noise([id, 3.321]) * PI +
292-
MILLIS / 10000;
291+
millis() / 10000;
293292
294293
// Change the radius to create a more
295294
//interesting shape:
@@ -537,7 +536,6 @@ With that in mind, let's manipulate the number of texture coordinates, so that m
537536
538537
function pixelateCallback() {
539538
const pixelCountX = 50;
540-
const MILLIS = uniformFloat(() => millis())
541539
filterColor.begin();
542540
const aspectRatio = filterColor.canvasSize.x /
543541
filterColor.canvasSize.y;
@@ -642,7 +640,6 @@ function bloomCallback() {
642640
}
643641
644642
function bloomCallback() {
645-
const MILLIS = uniformFloat(() => millis());
646643
// Receive the original image for use
647644
// in our shader.
648645
const preBlur = uniformTexture(getOriginalImage);
@@ -755,11 +752,10 @@ For more resources on shaders, try:
755752
756753
function starShaderCallback() {
757754
const skyRadius = 250;
758-
const MILLIS = uniformFloat(() => millis());
759755
function semiSphere() {
760756
let id = instanceID();
761-
let theta = noise([id, 0.1234]) * TWO_PI + MILLIS / 100000;
762-
let phi = noise([id, 3.321]) * PI + MILLIS / 50000;
757+
let theta = noise([id, 0.1234]) * TWO_PI + millis() / 100000;
758+
let phi = noise([id, 3.321]) * PI + millis() / 50000;
763759
764760
let r = skyRadius;
765761
r *= sin(phi);
@@ -774,7 +770,7 @@ For more resources on shaders, try:
774770
worldInputs.end();
775771
776772
objectInputs.begin();
777-
let size = 1 + 0.5 * sin(MILLIS * 0.002 + instanceID());
773+
let size = 1 + 0.5 * sin(millis() * 0.002 + instanceID());
778774
objectInputs.position *= size;
779775
objectInputs.end();
780776
}

0 commit comments

Comments
 (0)