3D in TypeScript using Ray Casting

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 มิ.ย. 2024
  • Offline Session
    More Episodes: • Raycasting in TypeScript
    References:
    - Lode's Computer Graphics Tutorial - Raycasting - lodev.org/cgtutor/raycasting....
    - Tsoding - Raycasting in Typescript - github.com/tsoding/raycasting
    - The Emacs extension I use - github.com/ananthakumaran/tide
    Support:
    - BTC: bc1qj820dmeazpeq5pjn89mlh9lhws7ghs9v34x9v9
    - Pay for my VPS: zap-hosting.com/en/shop/donat...
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 125

  • @atxorsatti
    @atxorsatti 15 วันที่ผ่านมา +141

    Can your C do that?

    • @SolathPrime
      @SolathPrime 15 วันที่ผ่านมา +11

      YES

    • @tafadzwamuzira1697
      @tafadzwamuzira1697 14 วันที่ผ่านมา

      Yes actually implemented it myself

    • @RealCatDev
      @RealCatDev 14 วันที่ผ่านมา +4

      Paper was in C...

    • @atxorsatti
      @atxorsatti 14 วันที่ผ่านมา +22

      It's true what they say about c programmers I guess, they really can't C a joke

    • @RealCatDev
      @RealCatDev 14 วันที่ผ่านมา +4

      @@atxorsatti or you can't make a joke ;3

  • @houssembousmaha3615
    @houssembousmaha3615 15 วันที่ผ่านมา +66

    Watching mista azozin in a 13 hour bus trip

    • @Pyronimous
      @Pyronimous 15 วันที่ผ่านมา +5

      It's just 3 hours tho, better watch it at 0.25x to extend it for the whole trip

    • @astrixx
      @astrixx 15 วันที่ผ่านมา +13

      nah 1.75x and watch it 7 times

    • @hedlund
      @hedlund 14 วันที่ผ่านมา +1

      Did you survive?

  • @user-bw2vq9lp2v
    @user-bw2vq9lp2v 15 วันที่ผ่านมา +21

    You're the one responsible for making me enjoy programming and math, thank you so much

    • @rubyciide5542
      @rubyciide5542 13 วันที่ผ่านมา +2

      Oh really, he made me rethink my life's decision of being a programmer 💀

  • @dfl0-
    @dfl0- 13 วันที่ผ่านมา +4

    Also not too sure if someone mentioned this already, I believe the problem you were having when trying to calculate the stripHeight was that you were assigning t = canvasHeight/perpWalldistance, and then multiplying that by the canvasHeight to get the stripHeight. However, you in fact calculated the stripHeight needed when calculating t, which looking at the values that are divided, is describing the direct proportion of the screen height to the perpendicular distance to the wall; aka. the larger the distance from the wall, the larger the value dividing the screen height so the smaller the strip.
    I very much like the solution you came up with as well with the dot products. I didn’t even think of that at first, but it is very elegant!

  • @wagsman9999
    @wagsman9999 14 วันที่ผ่านมา +15

    The coding speed is uncanny. It would have taken me a month to figure this out. Lol. Cool stuff.

    • @TsodingDaily
      @TsodingDaily  14 วันที่ผ่านมา +14

      I actually already explored some of the implementation space of this problem on Twitch live up until the introduction of the snap() function. So it may look pretty fast at first because I roughly knew what I needed to implement, but later as I entered a more unfamiliar space (and also got noticeably tired) I started to slow down.

    • @wagsman9999
      @wagsman9999 14 วันที่ผ่านมา +6

      @@TsodingDaily Still, very impressive!

  • @SolathPrime
    @SolathPrime 15 วันที่ผ่านมา +17

    A mista azozin doing raytracing on an old soviet refrigerator next

  • @omnicoinv2
    @omnicoinv2 15 วันที่ผ่านมา +7

    2:28:30 0.5 (the common factor) is being “factored out” with the distributive property of multiplication

  • @rubyciide5542
    @rubyciide5542 15 วันที่ผ่านมา +14

    Zozin OS wen?

  • @loic.bertrand
    @loic.bertrand 14 วันที่ผ่านมา +17

    29:02 You can also define an iterator on Vector2, so you can spread the object directly :
    class Vector2 {
    constructor(x, y) {
    this.x = x;
    this.y = y;
    }
    *[Symbol.iterator]() {
    yield this.x;
    yield this.y;
    }
    }
    const p1 = new Vector2(5, 9);
    doSomething(...p1);

    • @loic.bertrand
      @loic.bertrand 12 วันที่ผ่านมา +2

      Oops, I think there is no way to type this correctly in Typescript (to indicate the number of elements returned by a generator) :/

  • @kamilogorek
    @kamilogorek 15 วันที่ผ่านมา +7

    That was impressive AF, not gonna lie. Well done!

  • @JohnWasinger
    @JohnWasinger 15 วันที่ผ่านมา +5

    Love your topic choices! Next up ray casting in the TI-84 calculator basic language.
    I actually wrote a hidden line horizontal 3D plot program for that calculator. 3D plotting was natively supported in the later TI calculator models.

  • @ValentinoFilipetto
    @ValentinoFilipetto 4 วันที่ผ่านมา

    To achieve the speed of thought of this man is my dream

  • @DivineDarknesss
    @DivineDarknesss 13 วันที่ผ่านมา

    thanks for the honesty toward the end of the video

  • @11WicToR11
    @11WicToR11 14 วันที่ผ่านมา +5

    2:47:30 ....that null check with assignment, this exact thing will be fixed in next version of typescript that already has RC. We had to wait for this just 10 years, so if you have some other issues wait for twenty-forties xD

  • @bhaveshverma8629
    @bhaveshverma8629 14 วันที่ผ่านมา +1

    Very very impressive 🎉

  • @movization
    @movization 15 วันที่ผ่านมา +4

    Wow, a perfect bedtime story just in time!

    • @meanmole3212
      @meanmole3212 9 วันที่ผ่านมา +1

      That is a long ass bedtime story.

  • @bigmiraclewhips
    @bigmiraclewhips 12 วันที่ผ่านมา +1

    another banger video

  • @norm6096
    @norm6096 13 วันที่ผ่านมา

    I will try to implement the same with tweaks, thank you, for inspiration and awesome video good sir. :)

  • @101abuse
    @101abuse 15 วันที่ผ่านมา +3

    Finally! Another video 😄
    You are my favourite coding channel, i always love to watch your videos they are my only content i watch here on TH-cam alongside with shorts haha ❤

  • @kirillvoloshin2065
    @kirillvoloshin2065 15 วันที่ผ่านมา

    Легенда! я как раз недавно считал дельты и арктангенсы для канваса)

  • @Stroopwafe1
    @Stroopwafe1 14 วันที่ผ่านมา

    I definitely learned something from this stream. I always thought you needed matrix math to map 2D and 3D

    • @TsodingDaily
      @TsodingDaily  14 วันที่ผ่านมา +3

      I personally view matrices as just a compact way of encoding operations that you could've performed without them.

    • @itsmeagain1415
      @itsmeagain1415 14 วันที่ผ่านมา +2

      @@TsodingDaily brother, math from a computer science pov is just a collection of methods for encoding operations and arithmetic computations in unified frameworks like linear algebra or calculus or whatever field of math

  • @niceguy2097
    @niceguy2097 14 วันที่ผ่านมา

    just loved it

  • @levvayner4509
    @levvayner4509 15 วันที่ผ่านมา +2

    Ray casting almost got me to give up on programming. It was one of the first books I acquired when first starting to learn C. I was like 14 and the book "Tricks of the Game Programming Gurus" was a really well written book aimed at someone with a few years of C development. I tackled ray casting much later in life, and it was still pretty hard.

  • @snatvb
    @snatvb 3 วันที่ผ่านมา

    1:02:00, you know x,y and you can calculate this cell with col/row when you know cell size, when you know cell - you can get cell bounds, in fact, you can use an algorithm similar to line drawing here

  • @michabay2066
    @michabay2066 14 วันที่ผ่านมา +2

    (2:28:25) The opposite operation of distributing is called factoring.

  • @henrikholst7490
    @henrikholst7490 7 วันที่ผ่านมา

    You can use the implicit form ax + by + c = 0. (a,b) is a normal to the line. Finding an intersection beteen two lines becomes easy as solving a 2x2 system. No special case for k=0.

  • @dfl0-
    @dfl0- 14 วันที่ผ่านมา +3

    Perhaps you were talking about the extension Tide for emacs rather than Tidy?

    • @TsodingDaily
      @TsodingDaily  13 วันที่ผ่านมา +3

      omg yes! Thank you so much! I'll add it to the description...

  • @royalzsoftware
    @royalzsoftware 15 วันที่ผ่านมา +3

    Great video ❤ Next up ray casting in terminal with escape codes?😂

  • @justfly1984
    @justfly1984 15 วันที่ผ่านมา

    That was interesting!

  • @josbexerra8115
    @josbexerra8115 6 วันที่ผ่านมา

    Excelente....se nota que eres un gran progamador

  • @domprivat3955
    @domprivat3955 13 วันที่ผ่านมา

    Great Vid!

  • @hubstrangers3450
    @hubstrangers3450 10 วันที่ผ่านมา

    Thank you...

  • @tamantaman
    @tamantaman 13 วันที่ผ่านมา

    I can't stop come back to watch it again and again it's extraordinary with such a shitty language. It's really is a question of passion for programming. Hat's off sir /o.

  • @abhishekXpanda
    @abhishekXpanda 15 วันที่ผ่านมา +2

    TYPESCRIPT LETS GO!!

  • @mattshu
    @mattshu 15 วันที่ผ่านมา

    I like the new thumbnail ;)

  • @luandkg
    @luandkg 15 วันที่ผ่านมา

    ZozinTime ✅

  • @meanmole3212
    @meanmole3212 12 วันที่ผ่านมา

    TS + Canvas is actually pretty cool platform for old-school graphics programming. It is like a modern version of QBASIC where you can prototype graphics before doing implementations with more involved languages and environments.

  • @user-ej8um9yg1r
    @user-ej8um9yg1r 13 วันที่ผ่านมา +1

    I’ve only been watching you for 1 month, but I’m increasingly interested in what Linux distribution will you use?

  • @gmjammin4367
    @gmjammin4367 15 วันที่ผ่านมา +4

    the DDA algorithm! Its a classic.

  • @desertfish74
    @desertfish74 15 วันที่ผ่านมา +1

    Classic fish eye effect rears its ugly head again. It took me a long while to find the cosine solution for it in my raycaster code as well.

  • @acquite
    @acquite 14 วันที่ผ่านมา

    2:28:42 its called "factorisation" where you pull out a "factor" out of the expression

    • @RunningRay9
      @RunningRay9 14 วันที่ผ่านมา

      i would say "factoring out" is more apt

  • @hamiltonianpathondodecahed5236
    @hamiltonianpathondodecahed5236 15 วันที่ผ่านมา +13

    Are we not alive today ?

    • @TsodingDaily
      @TsodingDaily  15 วันที่ผ่านมา +19

      No

    • @cobbcoding
      @cobbcoding 15 วันที่ผ่านมา +14

      @@TsodingDaily rip zozin

  • @danielcarloschavesboll5156
    @danielcarloschavesboll5156 15 วันที่ผ่านมา +3

    Zozin time!

  • @lengors7327
    @lengors7327 4 วันที่ผ่านมา

    Any reason to define epsilon instead of using the builtin (into Number) one?

  • @catmium7974
    @catmium7974 14 วันที่ผ่านมา

    Cool

  • @rnoba1
    @rnoba1 5 วันที่ผ่านมา +1

    i had a hard time keeping up with the math :(. does anyone have any resources for me to study?

  • @RandomGeometryDashStuff
    @RandomGeometryDashStuff 15 วันที่ผ่านมา

    01:14:30 will
    if(Number.isInteger(x))return x+Math.sign(dx);
    work?

  • @ratherbyexploring4898
    @ratherbyexploring4898 15 วันที่ผ่านมา

    Mista azozin you gotta try Julia as a dynamic language. it's soo nice

  • @halfsourlizard9319
    @halfsourlizard9319 6 วันที่ผ่านมา

    2:29:00 ish, ahhhh, yes, the perspective-warping problem! The best part of ray-casting wats ... Literally everyone who's done this from-scratch has facepalmed through this exact situation.

    • @halfsourlizard9319
      @halfsourlizard9319 6 วันที่ผ่านมา

      Interesting that you solved it with linear algebra (dot product) rather than trig (cos) ... Obv, your way is cheaper to compute!

  • @Mozartenhimer
    @Mozartenhimer 13 วันที่ผ่านมา

    Didn't these things used to be implemented with interger steps?

  • @RenderDragon
    @RenderDragon 15 วันที่ผ่านมา +1

    May I ask, what happened, why these two streams got removed on twitch? Something was leaked or so?

    • @TheMelopeus
      @TheMelopeus 15 วันที่ผ่านมา +1

      They weren't very good quality so Zozin considered it's better to remove them in order to keep the quality of the vods high

    • @RenderDragon
      @RenderDragon 15 วันที่ผ่านมา

      ​@@TheMelopeusHuh, okay

  • @remrevo3944
    @remrevo3944 6 วันที่ผ่านมา

    I think the playlist is out of order.
    This should be the first entry, but is the second!

    • @TsodingDaily
      @TsodingDaily  5 วันที่ผ่านมา +1

      Thank you! Should be fixed.

    • @remrevo3944
      @remrevo3944 5 วันที่ผ่านมา

      @@TsodingDaily Thanks!

  • @Gers217
    @Gers217 5 วันที่ผ่านมา

    I didn't know that duckduckgo had access to AI models

  • @justbill9293
    @justbill9293 15 วันที่ผ่านมา

    Im in history

  • @manucaouette
    @manucaouette 15 วันที่ผ่านมา

    2:09:41 voidf is coming 👀

  • @kotofyt
    @kotofyt 15 วันที่ผ่านมา

    The coolest thing is my app crashes when I have more than 10 instances in tlas in vulkan

  • @053radadiyanikunj4
    @053radadiyanikunj4 15 วันที่ผ่านมา

    Which text editor is it?

  • @Marhaenism1930
    @Marhaenism1930 15 วันที่ผ่านมา +1

    let me in ...

  • @enjoyit4273
    @enjoyit4273 15 วันที่ผ่านมา

    next video : porting doom to html canvas

  • @11WicToR11
    @11WicToR11 15 วันที่ผ่านมา +7

    isnt it amazing to have and actual editor that helps you? i mean, i use neovim i dont wanna sht on your emacs, its just that i dont understand why wouldnt you use lsp ...you are apparently liking it as well. So why not on other languages? I understand that compiler does the same thing, but i think its much harder to fix things you wrote minutes ago when editor can tell you instantly as you finished that line or even lets you jump through issues in a buffer

    • @TsodingDaily
      @TsodingDaily  15 วันที่ผ่านมา +4

      The only reason you are asking about lsp is because you are literally incapable of understand the rest of the video. Ponder upon this fact and consider doing something about it.

    • @11WicToR11
      @11WicToR11 15 วันที่ผ่านมา +10

      @@TsodingDaily ye, why wouldnt you insult me for asking question (even with a silly typo like that), and i am still watching ...i would forget to ask if i waited to the end of the video. Very low blow, sad to see you are like that

    • @TsodingDaily
      @TsodingDaily  15 วันที่ผ่านมา +11

      Sorry... It's just I spent a lot of time and effort trying to bring interesting and meaningful sessions only end up receiving lots of surface level questions about frameworks, editors and fonts which do not matter. A single question like that is ok, but over time this is a death by thousand cuts and I can't stand it anymore.

    • @11WicToR11
      @11WicToR11 15 วันที่ผ่านมา +7

      @@TsodingDaily taken, if you dont like answering some category of questions, then ...dont? I mean you are not obligated to do so. Its just that you approach to coding is very different from most of the tech youtubers and reason why you doing so is in some sense even more interesting than raycasting (for me), which I ve already seen ton of. But i understand how this instantly leads to whole "ricing your setup topic" which is taken waaaaaaay too serious for no reason, where most of it doesnt make a difference.

    • @TsodingDaily
      @TsodingDaily  15 วันที่ผ่านมา +14

      Thank you for understanding my friend. And sorry again for my reaction. 🫂

  • @catmium7974
    @catmium7974 14 วันที่ผ่านมา

    Game Dev is one of the hardest shit I guess

  • @Zedv.0.0.1
    @Zedv.0.0.1 15 วันที่ผ่านมา

    I fear you Mr Azozin have Stockholm's syndrome for JavaScript/Typescript

  • @rogo7330
    @rogo7330 15 วันที่ผ่านมา +6

    "Pure C" sounds dumb. I propose C will be called "C" and C++ will be called "HereC".

    • @Kitulous
      @Kitulous 15 วันที่ผ่านมา +1

      as opposed to HolyC I presume?

    • @SolathPrime
      @SolathPrime 15 วันที่ผ่านมา +3

      I said that before and I'm not afraid to say it again
      "C is divine anything else is blasphemy"

    • @skilz8098
      @skilz8098 14 วันที่ผ่านมา

      @@SolathPrime Assembly: Hold my instructions can't you C I'm managing the stack!

    • @skilz8098
      @skilz8098 13 วันที่ผ่านมา

      @@SolathPrime Assembly: But I hold the keys to all of the pointers.

    • @skilz8098
      @skilz8098 13 วันที่ผ่านมา

      @@SolathPrime Assembly: When you pop from my stack frame through the kernel, Korn starts playing. "Life Is Peachy".

  • @atxorsatti
    @atxorsatti 15 วันที่ผ่านมา

    Seeing you program in js with you c voice is mind fucking

    • @TsodingDaily
      @TsodingDaily  15 วันที่ผ่านมา +6

      wtf is c voice? are you ok?

    • @atxorsatti
      @atxorsatti 15 วันที่ผ่านมา +2

      @@TsodingDaily listen this is wild
      I would have never thought I'd see you centering a div

    • @atxorsatti
      @atxorsatti 15 วันที่ผ่านมา

      ​@@TsodingDaily Also may I ask why you do ++x and not x++ in for loops?

    • @vk-hm6te
      @vk-hm6te 15 วันที่ผ่านมา

      @@atxorsatti ++x is more efficient (think about what ++x and x++ actually mean); of course, modern compilers optimize x++ and ++x to the same code, but its a good habit nonetheless

    • @sirynka
      @sirynka 15 วันที่ผ่านมา

      It basically boils down to the way x++ is computed when you're assigning it to a variable.
      x = 0
      a = x++
      print(a, x) // 0, 1
      To make it work like so you need to create a copy of x and return that copy, so when you are incrementing the actual value of x in ram, your 'a' won't change.
      But it doesn't really matter in the for loop (as long as you're using x++ as the third param)
      Note, if it's the second param, the behavior of loops would be different.
      for(int i=-5; i++;) print(i); // 4, 3, 2, 1, 0
      for(int i=-5; ++i;) print(i); // 4, 3, 2, 1
      P. S. I've omitted minutes as was lazy to type them.
      Hope I've not overcomplicated the explanation, and it does make some sense.

  • @elvis_gastelum
    @elvis_gastelum 15 วันที่ผ่านมา

    First

  • @drsensor
    @drsensor 14 วันที่ผ่านมา

    i've conflicting feeling about typescript

    • @TsodingDaily
      @TsodingDaily  14 วันที่ผ่านมา +1

      It's an alright language given the substrate it has to work in.

    • @EMEKC
      @EMEKC 13 วันที่ผ่านมา

      Personally I've had a nicer experience in general with TS when using Deno, maybe that could help, but I can't guarantee anything 🙃

  • @araz911
    @araz911 13 วันที่ผ่านมา

    ur ts goes in trash can together with ur c all that bloat ware, move towards real programming in python 👌

    • @freddie224
      @freddie224 6 วันที่ผ่านมา

      C bloatware?

    • @araz911
      @araz911 6 วันที่ผ่านมา

      @@freddie224 YESCISBLOATWARE. so what?