Coding Challenge #86: Cube Wave by Bees and Bombs

Sdílet
Vložit
  • čas přidán 5. 08. 2024
  • The artist BeesandBombs makes amazing algorithmic looping GIFs! Here's my attempt to recreate one of my favorite GIFs in JavaScript with p5.js and the WEBGL renderer. Code: thecodingtrain.com/challenges...
    🤖GIF: / 940639806522085376
    🕹️ p5.js Web Editor Sketch: editor.p5js.org/codingtrain/s...
    🎥 Previous video: • Coding Challenge #85: ...
    🎥 Next video: • Coding Challenge #87: ...
    🎥 All videos: • Coding Challenges
    References:
    💾 p5.js reference: p5js.org/reference/
    🖌 Bees and Bombs: / beesandbombs
    Videos:
    🚂 Simple Harmonic Motion: • 3.5 Simple Harmonic Mo...
    🎥 Back to School on the Coding Train: • Back to School on the ...
    🔴 Coding Train Live 109: • Coding Train Live 109:...
    Related Coding Challenges:
    🚂 #87 3D Knots: • Coding Challenge #87: ...
    🚂 #135 Making a GIF Loop in Processing: • Coding Challenge #135:...
    Timestamps:
    0:00:00 Coding Cube Wave by Bees and Bombs
    0:02:41 Applying Oscillation
    0:07:43 Moving to 3D
    0:11:33 Adding Perspectives and Movement
    0:23:25 Applying an Offset
    0:28:32 Final wave and suggestion for improvements
    Editing by Mathieu Blanchette
    Animations by Jason Heglund
    Music from Epidemic Sound
    🚂 Website: thecodingtrain.com/
    👾 Share Your Creation! thecodingtrain.com/guides/pas...
    🚩 Suggest Topics: github.com/CodingTrain/Sugges...
    💡 GitHub: github.com/CodingTrain
    💬 Discord: thecodingtrain.com/discord
    💖 Membership: czcams.com/users/thecodingtrainjoin
    🛒 Store: standard.tv/codingtrain
    🖋️ Twitter: / thecodingtrain
    📸 Instagram: / the.coding.train
    🎥 Coding Challenges: • Coding Challenges
    🎥 Intro to Programming: • Start learning here!
    🔗 p5.js: p5js.org
    🔗 p5.js Web Editor: editor.p5js.org/
    🔗 Processing: processing.org
    📄 Code of Conduct: github.com/CodingTrain/Code-o...
    This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecod...
    #webgl #simpleharmonicmotion #3d #beesandbombs #javascript #p5js

Komentáře • 435

  • @multiapples6215
    @multiapples6215 Před 6 lety +603

    Ok, the reason why the isometric view is off is because you did the rotates wrongly.
    Replace:
    RotateX(-QUARTER_PI)
    RotateY(ma)
    With:
    RotateX(ma)
    RotateY(-QUATER_PI)

    • @TheCodingTrain
      @TheCodingTrain  Před 6 lety +166

      Thank you!!! (Actually I think I it should be. . . )
      rotateX(-ma);
      rotateY(-QUARTER_PI)

    • @joaovitordossantos9949
      @joaovitordossantos9949 Před 6 lety +38

      YES
      The wiki for iso view refers to plane rotation while the p5 function rotates around the said axis

    • @TriatomicKey52
      @TriatomicKey52 Před 6 lety +33

      Thought it was abit wacky when he called x vertical

    • @TheCodingTrain
      @TheCodingTrain  Před 6 lety +78

      Yeah, so painful for me to watch this back!

    • @multiapples6215
      @multiapples6215 Před 6 lety +7

      Glad to help ^_^

  • @goobi8617
    @goobi8617 Před 5 lety +223

    This dude can literally create anything with his mind

  • @RetroGamingClashOfClans
    @RetroGamingClashOfClans Před 4 lety +78

    15:24 lmao every programmer 30 min after enthusiastically starting a new project;

  • @jackdaddypfc
    @jackdaddypfc Před 6 lety +330

    As some one who taught himself assembly language on a commodore 64, may I say you are exactly what aspiring young programmers need. Good work sir.

    • @Roundtablist
      @Roundtablist Před 6 lety +15

      I did the same thing on an Apple ][ and I thoroughly agree. Dan has helped me try to restore some fun to my coding. To approach it with the same sense of wonder and excitement that motivated me to push through the incredibly difficult thing I was trying to do back then.

    • @reyariass
      @reyariass Před 6 lety +5

      I salute you both. I don’t know what I would do without today’s IDEs and their auto-completion. Probably a whole lot of single syntax typing then testing immediately after to see if did something spectacular.

    • @vittim1998
      @vittim1998 Před 5 lety +1

      where ddi you guys learn to code by yourselfs?

    • @KayOScode
      @KayOScode Před 5 lety +3

      I did all of the above and built 3d render engines from scratch. Im talking from scratch meaning no libraries, not even a graphics api.

    • @ritageraghty4404
      @ritageraghty4404 Před 5 lety

      Father Mark I guess you are from Ireland. Gee, how well I remember Father Mark's repetitive quotes: "Drink, drink drink!"..."Girls, girls, girls!" ...."Feck, feck, feck!"

  • @steeperdrip9188
    @steeperdrip9188 Před 6 lety +186

    So happy that you've gotten back to graphical coding challenges

  • @aditya95sriram
    @aditya95sriram Před 6 lety +89

    Please, please do more from Bees and Bombs. Some of those are really mind-boggling and I have no clue how he does them in processing.

  • @alvaroplol
    @alvaroplol Před 6 lety +13

    Using distance to do the offset is genius. I'm adding that to my toolbox.

  • @armanterrell7215
    @armanterrell7215 Před 2 lety

    Just started a coding camp and found your channel. You're brilliant friend. Absolutely brilliant, thank you for sharing your knowledge and your thought process while breaking down the code!

  • @HalNuevemillones
    @HalNuevemillones Před 6 lety

    I stop programing a long time ago. But look at you doing this CZcams . Make me remember my past and the exitment when i finish a program :). THANK YOU.

  • @jaronfeld123
    @jaronfeld123 Před 6 lety +54

    Lmao "Rotate 45 degrees..." PI/8
    That was funny

    • @Mizu2023
      @Mizu2023 Před 2 lety

      it was 22.5 instead of 45 lmao

  • @oliverpieternmonochromeand3897

    Wow, i Love the awesome animation loops from Dave (Bees and Bombs) and I like your tutorials too. Thanks for this Christmas gift :-)

  • @DenisRezendeD
    @DenisRezendeD Před 5 lety +52

    Nobody: ...
    This guy: Translate();

  • @arturitoproductions
    @arturitoproductions Před 3 lety +4

    Super exciting to see you doing these real time coding, I learn a lot from you and, specially important, I get a lot of inspiration

    • @armanterrell7215
      @armanterrell7215 Před 2 lety +1

      Seriously right? Sometimes I think I can't move forward. Then I see a video like this knowing I NEED to move forward because this looks HELLA fun.

  • @terraflops
    @terraflops Před 2 lety +5

    wow, i enjoyed this so much, i watched it and coded along, only took me 2 hours (yes, i know about the source code being available but wanted to code it)

  • @zyzo99
    @zyzo99 Před 6 lety +1

    This guy is fantastic,kudos to him!

  • @rosslahive
    @rosslahive Před 6 lety

    Really enjoyed this episode, thanks Dan.

  • @btiwari-games5279
    @btiwari-games5279 Před 5 lety

    You are so cool, i feel very creative while watching your videos hats off to you man

  • @BirinderSingh
    @BirinderSingh Před 4 lety +47

    WebGL: can't handle 2d, runs 3d perfectly.
    "My powers are massive, not catered to your lowly tasks... "

    • @DaChrisstar
      @DaChrisstar Před 4 lety +3

      Webgl can, p5js can't

    • @Mizu2023
      @Mizu2023 Před 2 lety

      the rect() function in webgl p5.js actually draws so many triangles that webgl starts lagging when the triangles move to each other

  • @live_destin-3408
    @live_destin-3408 Před 6 lety

    Wow this is awesome Dan I fallowed along tru the hole thing great video

  • @huagnerxavier9632
    @huagnerxavier9632 Před 4 lety

    I like so much this video!!! Congrats

  • @DIDIameli13
    @DIDIameli13 Před 6 lety

    So cool and well done vid, thanks a lot !

  • @abhishekkumarsingh6090

    your videos are really relaxing thanks

  • @peoplethesedaysberetarded

    Another good video, Daniel. Thanks! :)

  • @bemresolvido8856
    @bemresolvido8856 Před 6 lety

    congrats , man: you're an excellent coder!

  • @rigby1083
    @rigby1083 Před 5 lety +1

    It's amazing ! You are the amazing programmer !!! :O

  • @chanasiegel2706
    @chanasiegel2706 Před 4 lety +1

    You just explained a sine wave to me better than anyone ever did, in like 30 seconds!

  • @stevewu9372
    @stevewu9372 Před 5 lety

    Love your videos!

  • @deadmusik9969
    @deadmusik9969 Před 4 lety

    fantastic to watch, just fantastic.

  • @MarkJay
    @MarkJay Před 6 lety

    I love these animated style coding challenges.

  • @usernamedeww983
    @usernamedeww983 Před 5 lety +5

    Gid. I love watching him code. Even though I haven't started learning JavaScript yet and a lot of what he does confuses me a bit, his code looks so AMAZING. Mine is all jumbled and stuff and I only put space between my code when I'm done with a concept completely, he does when he's done with a thought, and that doesn't usually look good, but this guy pulls it off and it looks amazing! Lmao

  • @akashkumardas6521
    @akashkumardas6521 Před 6 lety +4

    Your laughing style is amazing ... I like it ..

  • @arshadjaveed7877
    @arshadjaveed7877 Před 6 lety +2

    Awesome video...you are the best

  • @alonattar3836
    @alonattar3836 Před 6 lety

    Beautiful!!

  • @JW-pq1ml
    @JW-pq1ml Před 6 lety

    Your excitement at 18:17 is wonderfully awesome.

  • @klausbdl
    @klausbdl Před 6 lety

    Pls never stop doing those videos. I'll be a famous programmer like you.

  • @dan-garden
    @dan-garden Před 6 lety

    I love your channel Dan, nice name aswell! ❤️

  • @emmettdja
    @emmettdja Před 4 lety +4

    2:11 "so if we just let h equal 100..." and there you go. all done.

  • @Min3vidz
    @Min3vidz Před 6 lety +7

    You should have made it in a rainbow color in order to honour your old channel name! Keep up the good work!

  • @boyiscola
    @boyiscola Před 3 měsíci

    That’s a pretty good LD impression!

  • @Rafael-wq4sn
    @Rafael-wq4sn Před 6 lety

    Hahaha I like your videos very much! And I'm learning a lot.
    Thanks!

  • @driziiD
    @driziiD Před 3 lety +1

    orthographic projection: flashes back to all my TD (Technical Drawing) classes in secondary school

  • @tech1779
    @tech1779 Před 2 lety

    He made it, unbelievable

  • @kerhabplays
    @kerhabplays Před 3 lety

    U are the master of Coding!

  • @AB-Prince
    @AB-Prince Před 6 lety +3

    For an ofset centered around zero, you could square the numbers so they eminate from the origin

  • @guiltazaour2871
    @guiltazaour2871 Před 6 lety +1

    very nice man!!

  • @goddersgaming2186
    @goddersgaming2186 Před 6 lety

    This fricking made my day

  • @modiddymo
    @modiddymo Před 6 lety

    Well done!

  • @FERCHO8075
    @FERCHO8075 Před 6 lety

    I love this !!!

  • @N0D0hNuts
    @N0D0hNuts Před 3 lety +2

    You know someone is a real programmer when you type the same word over and over doing mistakes because your mind is going faster than your hands

  • @gaimz1855
    @gaimz1855 Před 6 lety

    Brilliant!

  • @jeanmercedes841
    @jeanmercedes841 Před 5 lety +1

    This guys awesome

  • @ashishkingdom
    @ashishkingdom Před 6 lety

    This is really cool! ^_^

  • @2000yearOldYogiAspirant

    Loool funny video, gj man.
    At the very end it looks like a jellyfish

  • @mariogamer929
    @mariogamer929 Před 5 lety +6

    Holy cow. you can program so fast! I made the same thing in C++ and OpenGL, and it took me nearly a day. Most of the time I'm just thinking what to do next in my code, and you just keep going somehow. How do you do that?

  • @urgisjot
    @urgisjot Před 6 lety +2

    You my dear sir are fantastic, when i watch it for breakfast it gives a positive charge for the whole day!

  • @mitalisharma440
    @mitalisharma440 Před 3 lety

    so much of thenks. :)

  • @danielkatz5925
    @danielkatz5925 Před 6 lety

    Amazing video.

  • @apalepeks2000
    @apalepeks2000 Před 3 lety

    Amazing

  • @marcellomarianetti1770

    Really impressive

  • @philtoa334
    @philtoa334 Před 4 lety

    Nice, nice. Thx

  • @endone3661
    @endone3661 Před 6 lety +1

    wow! magic!

  • @barboygaming3807
    @barboygaming3807 Před 6 lety

    You are amazing person in the world

  • @PalikkaFilms
    @PalikkaFilms Před 6 lety

    this is great, I'm trying to do the same you did but in Unity and with c#. good practice

  • @hazmishaidi
    @hazmishaidi Před 6 lety +17

    Okay, I admit.. you nailed it.
    ...as usual. :)

    • @ophello
      @ophello Před 6 lety +1

      No he didn't...but close!

  • @philmourelle
    @philmourelle Před 5 lety

    U r the man !!!!

  • @IbakonFerba
    @IbakonFerba Před 6 lety +7

    12:37 ah, the Unity forum, one of my most frequently visited websites xD

  • @druskus5449
    @druskus5449 Před 6 lety

    10:37 how do I make that black borders? I tried copying the same program and i just got flat colours without edges

  • @akj7
    @akj7 Před 5 lety +2

    Instead of working on each block individually, you could have create and animated f(x) = (sinx, sinx, constant), then use the method used for Riemann Integral (creating blocks under the curve of each sinus function).
    Edit: Then mirror it on one axis.

  • @kevinpham3805
    @kevinpham3805 Před 6 lety

    on the face for the animation you made is it possible that you could make the sine wavelengths half the size to match the animation? because it looks like your one has 1 wavelength when the birds and bees looks like it has 2

  • @nandhum5859
    @nandhum5859 Před 6 lety

    You are a genius

  • @yashsehgal251
    @yashsehgal251 Před 5 lety

    Its awesome

  • @pypunk6248
    @pypunk6248 Před 5 lety +2

    you made me want to try this out myself, but in c++ XD

  • @caiozowyecamachocabral5413

    Why would someone dislike it? Love to watch his videos...

  • @riko_2048
    @riko_2048 Před 6 lety

    Can someone help me?
    The boxes that have been drawes have no black-colored edges. They have the same color as the box. And when I try my program on the Website of P5 everything works how it should. what can I do?

  • @jayh5992
    @jayh5992 Před 6 lety +1

    Its an orthographic projection but a isometric view. Isometric view is that the lines going in the back are 1:1 in length and 30 degrees angle going to the back

  • @Fuzzietomato1
    @Fuzzietomato1 Před 6 lety

    Please do more of these!!!

  • @BaronVonTacocat
    @BaronVonTacocat Před 6 lety

    Sweet!

  • @kalapita226
    @kalapita226 Před 6 lety +4

    Greetings from Laponia

  • @pascalladal8125
    @pascalladal8125 Před 6 lety

    Man I'm not coding in js but that gave me the kick to start back Unity and c#. It can be easily translated to basic Unity goof around. Lots of fun incoming I believe!

    • @Mizu2023
      @Mizu2023 Před 2 lety

      what's better is,you don't have to code physics because unity already has it

  • @tusharmaurya1668
    @tusharmaurya1668 Před 6 lety

    YOu are insane!

  • @PhilippeHenrique
    @PhilippeHenrique Před 6 lety +25

    OMG! You are amazing

  • @krening
    @krening Před 6 lety

    Cool Stuff

  • @zdargahi
    @zdargahi Před 4 lety

    pretty pretty pretty close 🥰

  • @nidomika
    @nidomika Před 6 lety

    I know nearly nothing about JS or programming itself, yet I found this video quite interesting to watch

    • @TheCodingTrain
      @TheCodingTrain  Před 6 lety +1

      Try either of these playlists to start from scratch!
      czcams.com/users/shiffmanplaylists?view=50&shelf_id=14&sort=dd
      czcams.com/users/shiffmanplaylists?view=50&shelf_id=2&sort=dd

    • @nidomika
      @nidomika Před 6 lety

      The Coding Train I will definitely try! Thanks so much :))

  • @MuhammadTajammulZia
    @MuhammadTajammulZia Před 3 lety

    Which IDE does he use? I still use p5.js web editor but I want to use an IDE. Can someone recommend please?

  • @haithem8906
    @haithem8906 Před 4 lety

    you can do it in a simpler way such as
    making all the boxes (4*4) and one in the middle who have all the script
    it will detect how mush far is the other boxes and their high will be angle*(offsent+distance)

  • @Protegit
    @Protegit Před 6 lety +1

    Whats the difference between void setup() size(x, y); and setup() {
    createCanvas(x, y);}?

    • @TheCodingTrain
      @TheCodingTrain  Před 6 lety +3

      One is Processing, one is p5.js, see: czcams.com/video/AmlAiKsiy0o/video.html

    • @Protegit
      @Protegit Před 6 lety

      thx a lot!

  • @SamuelSebastianWorld
    @SamuelSebastianWorld Před 6 lety

    Can you upgrade, simplify or convert my version of KAREL 3D in WebGL with Three.js to p5.js?

  • @generic_programmer
    @generic_programmer Před 6 lety +3

    8:55 What purpose does the push() and pop() fill?

    • @Meoiswa
      @Meoiswa Před 4 lety +2

      They create a "block" of instructions that all get sent together to the Graphics Layer, thus reducing the number of "housekeeping" operations it has to perform.
      It's also commonly used to "temporarily" apply transforms/rotates, and have them all "revert" with a pop.

  • @DaCosmoz
    @DaCosmoz Před 6 lety +2

    Is there a youtube channel like this but with other programming languages? Python for example? This channel is so cool.

  • @kennethpace9887
    @kennethpace9887 Před 5 lety

    Coding along, I add ortho() and and my boxes disappear, comment it out and they reappear. Why?

  • @lmmartinez97
    @lmmartinez97 Před 6 lety

    I was thinking of a completely different approach. I learnt programming in Fortran, so the first thing for me is almost always going for arrays. Like you could make an array that stores a position for every little box and then assign a dynamic value of height to each value of that array? I know pretty much anything about p5 and processing, but I do want to learn!

  • @MathGrove
    @MathGrove Před rokem

    It took me so long to figure out how to make it spherical vs the shape of a sine wave. You see a lot of people saying to "just square the offset" but that didn't immediately click for me. The solution was to simply square both the distance and the max distance, doh. Update your offset to this and it looks just like the original: let offset = map(d * d, 0, maxD * maxD, -PI, PI)

  • @adammcgrogan8490
    @adammcgrogan8490 Před 4 lety

    What's the command you're doing to re-format the code?

  • @ilustrado7291
    @ilustrado7291 Před 6 lety +84

    SHIFFMAN IS THE NEW BOB ROSS

  • @mark_walet
    @mark_walet Před 6 lety +1

    I really get the urge to make a hacky 2d css transition version of this

  • @danielradosa
    @danielradosa Před 3 lety

    my god, thhis is free tutorial... damn love it

  • @mdtanvirislam3408
    @mdtanvirislam3408 Před 6 lety +15

    26:20 Larry David reference xD

  • @thelavagod
    @thelavagod Před 3 lety +1

    I actually tried to improve the version.
    editor.p5js.org/lavagod/present/M2tExTqYd

  • @porx
    @porx Před 5 lety

    A bit of a late question to ask on this, but what do you use to host to localhost:8000?

    • @TheCodingTrain
      @TheCodingTrain  Před 5 lety

      This workflow video series might help! czcams.com/play/PLRqwX-V7Uu6Zu_uqEA6NqhLzKLACwU74X.html (TLDR: node http-server or python SimpleHTTPServer)