[{"data":1,"prerenderedAt":416},["ShallowReactive",2],{"project-14865184":3},{"id":4,"name":5,"line":5,"line_source":6,"title":7,"url":8,"domain":9,"maker":10,"posted_at":11,"year":12,"points":13,"comments":14,"rank_in_year":15,"shown_in_year":16,"top":17,"tier":18,"category":19,"subcategory":20,"format":21,"keywords":22,"reception":27,"sentiment":28,"stance_mix":29,"scored_comments":34,"aspects":35,"strip":42,"post_text":44,"what":45,"said":73,"maker_in_thread":207,"shape":214,"grid":217,"attempts":362,"same_week":379,"maker_shows":32,"maker_hidden":408,"reader_version":409,"card":410},"14865184","A 2D Physics Simulator in JavaScript","title","Show HN: A 2D Physics Simulator in JavaScript","http:\u002F\u002Fhtmlpreview.github.io\u002F?https:\u002F\u002Fgithub.com\u002Faguaviva\u002FPhysics\u002Fblob\u002Fmaster\u002FRigidBodyChainVSstack.html","htmlpreview.github.io","xchip",1501163271,2017,126,62,333,2242,15,"notable","learning_science","physics simulation","web_app",[23,24,25,26],"2d physics engine","javascript physics","rigid body simulation","constraint solver","debated",-0.258,{"positive":30,"neutral":31,"mixed":32,"critical":33},6,5,1,11,23,{"idea":36,"performance":37,"docs":38,"execution":41},{"positive":32,"critical":31},{"positive":32,"critical":31},{"positive":39,"critical":40},2,0,{"positive":40,"critical":32},[32,31,31,32,32,31,40,31,40,40,43,40,40,40,40,40,32,32,32,40,43,32,40,40,40,40,40,40,40,43,31,43,32,40,32,40,43,40,31,32],3,null,{"problem":46,"audience":59,"pricing":44,"motivation":64,"time_to_build":44,"stack":69,"openness":70,"stage":71,"team_size":72},{"value":47,"source":48,"evidence":49},"Physics engines are hard to understand; this demo is a simple, readable implementation for learning","maker",[50,53,56],{"id":51,"by":10,"text":52},"14868902","All those are great physics engines. Mine is just very simple and easy to understand, hopefully it inspires other people to get into the world of simulations.",{"id":54,"by":10,"text":55},"14876991","In fact that was one of the reasons that compelled me do write my own, because physics engines looked to me like voodoo magic. Thanks for understanding my obsession with learning…",{"id":57,"by":10,"text":58},"14877041","Fantastic, in fact I wrote because I had been trying to understand physics engines four a long time and it was super hard to follow the papers. I wrote it four learning my self…",{"value":60,"source":48,"evidence":61},"People learning how physics engines and simulations work",[62,63],{"id":51,"by":10,"text":52},{"id":57,"by":10,"text":58},{"value":65,"source":48,"evidence":66},"Maker wanted to learn physics engines, which seemed like magic, and share the learning",[67,68],{"id":54,"by":10,"text":55},{"id":57,"by":10,"text":58},[],"open_source","prototype","solo",{"praise":74,"objections":91,"requests":139,"questions":161,"alternatives":176},[75,83],{"value":76,"source":77,"evidence":78},"Code fits on one page and is easy to understand","commenter",[79],{"id":80,"by":81,"text":82},"14871900","ivan_ah","What's special about this simulation is that the entire code fits on one page, including linear algebra library:…",{"value":84,"source":77,"evidence":85},"Good for learning and teaching physics simulation",[86,87],{"id":80,"by":81,"text":82},{"id":88,"by":89,"text":90},"14868252","pdm55","Thanks, good show. Another one I like is http:\u002F\u002Fphysics.weber.edu\u002Fschroeder\u002Fhtml5\u002F. See Newton's cannon etc.",[92,107,118,129],{"value":93,"source":77,"evidence":94},"No friction, so motion looks unrealistic",[95,99,103],{"id":96,"by":97,"text":98},"14866509","SketchySeaBeast","In Firefox Developer Edition everything happens faster than in regular Firefox, though they seem to end at the same result. I wonder why that is. Animation doesn't seem much…",{"id":100,"by":101,"text":102},"14869441","dmitrygr","The only part missing? Physics... Somehow boxes slide along a flat floor with no deceleration until they fall off the screen",{"id":104,"by":105,"text":106},"14870186","eric_h","I think the word you were looking for was \"friction\". This certainly looks like a simulation that a physics professor would propose on a chalk board: \"Ignoring friction for the…",{"value":108,"source":77,"evidence":109},"Not interactive; cannot modify objects",[110,114],{"id":111,"by":112,"text":113},"14866323","dkonofalski","Is this really a simulation if you can't modify any of the objects? For all we know, this could all be pre-calculated or pre-animated. Everything moves exactly the same way every…",{"id":115,"by":116,"text":117},"14866867","laythea","Erm, no offense but: a) physics programs are supposed to offer interactivity. Else whats the point? b) the physics look unearthly",{"value":119,"source":77,"evidence":120},"Non-deterministic or varies across browsers",[121,125],{"id":122,"by":123,"text":124},"14866422","FroshKiller","It moves differently in different browsers for me. And neither instance seems to actually make physical sense. In Chrome, the fourth box from the top starts sliding when it hits…",{"id":126,"by":127,"text":128},"14875400","reificator","I don't mean to be rude, but if you don't know the term I'd put money on it not being deterministic. Especially if you're running in JavaScript on multiple browsers. A single…",{"value":130,"source":77,"evidence":131},"High CPU usage due to no broad phase collision detection",[132,136],{"id":133,"by":134,"text":135},"14869077","danilocesar","Out of curiosity: The chrome tab running the engine is using 55% of my CPU, an i7-4770K running at 3.5Ghz... Box2D with many more objects consumes 22%. Oimo, with a 3D rendering…",{"id":137,"by":10,"text":138},"14885473","Physics engines are like magic and it is pretty hard understand how the work even if you read the paper many times. Also physics engines are interesting not only because four the…",[140,152],{"value":141,"source":77,"evidence":142},"Add friction",[143,147,151],{"id":144,"by":145,"text":146},"14866606","santaclaus","Is there friction or non-zero restitution?",{"id":148,"by":149,"text":150},"14872338","Aeolun","It doesn't take into account surface friction? Those boxes seem covered in soap to me.",{"id":96,"by":97,"text":98},{"value":153,"source":77,"evidence":154},"Add user interaction such as mouse control",[155,158],{"id":156,"by":10,"text":157},"14866887",":D you are welcome to add objects, make the chain longer or change gravity... Having always the same animation helps debugging. But yeah I should have added the option to add a…",{"id":159,"by":116,"text":160},"14867052","Hey, again no offense meant. I just think the whole point of something like this is to mimic the real world. And after a couple of seconds my illusion is broken. Ps. It is cool,…",[162,169],{"value":163,"source":77,"evidence":164},"Is the simulation deterministic?",[165],{"id":166,"by":167,"text":168},"14865819","mobiletelephone","Cool! Is it deterministic? Does it do destructive updates?",{"value":170,"source":77,"evidence":171},"Does it conserve energy?",[172],{"id":173,"by":174,"text":175},"14869380","thanatropism","This is where I show that I know nothing about physics engines: ... does it have conservation of energy? Can you track total energy somehow? ... does it obey approximately some…",[177,188,193,197,201],{"value":178,"source":77,"evidence":179},"Matter.js",[180,184],{"id":181,"by":182,"text":183},"14868505","olegkikin","Why is this upvoted so much? In what way is it better than any of the existing JS physics engines? Matter.js: http:\u002F\u002Fbrm.io\u002Fmatter-js\u002F Cannon.js: http:\u002F\u002Fwww.cannonjs.org\u002F…",{"id":185,"by":186,"text":187},"14866537","ell0ell0","If you want to look at precedence or what other people have done successfully in this space check out http:\u002F\u002Fbrm.io\u002Fmatter-js\u002F matter JS. It's pretty sweet.",{"value":189,"source":77,"evidence":190},"Box2D",[191,192],{"id":181,"by":182,"text":183},{"id":133,"by":134,"text":135},{"value":194,"source":77,"evidence":195},"Cannon.js",[196],{"id":181,"by":182,"text":183},{"value":198,"source":77,"evidence":199},"PhysicsJS",[200],{"id":181,"by":182,"text":183},{"value":202,"source":77,"evidence":203},"myphysicslab",[204],{"id":205,"by":81,"text":206},"14871839","To add to the list, the best physics engine I've seen (not for js games, for actual physics simulations to teach people physics) is this one: https:\u002F\u002Fwww.myphysicslab.com\u002F PheT…",{"comments":208,"answered":209,"key":210},19,7,[211,212,213],{"id":51,"text":52},{"id":54,"text":55},{"id":57,"text":58},{"commenters":215,"max_depth":30,"maker_replies":208,"first_comment_mins":43,"lifespan_hours":216},33,69,[218,220,224,226,230,232,234,237,239,240,244,246,250,252,253,255,257,259,261,265,267,269,271,274,277,278,279,280,283,286,290,292,295,297,299,300,302,306,308,309,310,312,314,316,319,322,326,329,331,334,336,339,341,343,345,348,351,353,355,357,360,361],[181,40,32,219,182,40],"project\u002Fcritical\u002Fidea",[221,40,31,222,223,40],"14868888","project\u002Fpositive\u002Fidea","tachyonbeam",[51,40,40,225,10,32],"maker\u002Fneutral\u002Fidea",[227,40,31,228,229,40],"14869201","maker\u002Fpositive\u002Fnone","looki",[54,40,40,231,10,32],"maker\u002Fneutral\u002Fnone",[148,40,32,233,149,40],"project\u002Fcritical\u002Fperformance",[235,40,32,219,236,40],"14869707","opmac",[80,40,31,238,81,40],"project\u002Fpositive\u002Fdocs",[57,40,40,231,10,32],[241,40,40,242,243,40],"14870806","commenter\u002Fneutral\u002Fidea","throwaway91111",[205,40,40,245,81,40],"other\u002Fneutral\u002Fnone",[247,40,31,248,249,40],"14874090","project\u002Fpositive\u002Fperformance","tapirl",[251,40,40,228,10,32],"14881254",[185,32,40,245,186,40],[254,32,40,228,10,32],"14866996",[256,39,40,222,10,32],"14865203",[166,39,43,258,167,40],"project\u002Fneutral\u002Fperformance",[260,39,40,231,10,32],"14866106",[262,39,40,263,264,40],"14866475","commenter\u002Fneutral\u002Fnone","kroltan",[266,39,40,248,10,32],"14868950",[126,39,40,268,127,40],"commenter\u002Fcritical\u002Fperformance",[270,39,40,245,167,40],"14869078",[272,39,40,263,273,40],"14869647","gugagore",[275,39,40,245,276,40],"14869933","T-hawk",[111,43,32,219,112,40],[122,43,32,233,123,40],[96,43,32,233,97,40],[281,43,40,282,10,32],"14866830","maker\u002Fneutral\u002Fperformance",[284,43,32,233,285,40],"14867826","pjc50",[287,43,40,288,289,40],"14868200","commenter\u002Fneutral\u002Fperformance","archgoon",[291,43,40,282,10,32],"14868473",[293,43,43,282,294,40],"14868280","potench",[296,43,40,228,10,32],"14868425",[298,43,32,219,112,40],"14866658",[156,43,40,225,10,32],[301,43,40,242,289,40],"14867789",[303,304,40,245,305,40],"14867083",4,"romaniv",[307,304,40,245,10,32],"14868414",[88,31,40,245,89,40],[173,30,40,245,174,40],[311,30,40,245,145,40],"14870200",[313,30,40,245,174,40],"14871173",[315,30,40,245,145,40],"14872180",[317,30,40,318,10,32],"14881273","commenter\u002Fpositive\u002Fnone",[320,30,40,245,321,40],"14871401","yorwba",[323,209,43,324,325,40],"14865951","project\u002Fneutral\u002Fdocs","samuraiseoul",[327,209,31,238,328,40],"14866001","claar",[330,209,40,238,10,32],"14866130",[144,332,43,333,145,40],8,"project\u002Fneutral\u002Fidea",[335,332,40,225,10,32],"14866678",[100,337,32,338,101,40],9,"project\u002Fcritical\u002Fexecution",[104,337,40,340,105,40],"commenter\u002Fcritical\u002Fexecution",[115,342,32,219,116,40],10,[344,342,40,263,145,40],"14866963",[346,342,40,347,116,40],"14867035","commenter\u002Fcritical\u002Fidea",[349,342,40,350,10,32],"14866992","maker\u002Fneutral\u002Fexecution",[159,342,43,352,116,40],"project\u002Fmixed\u002Fexecution",[354,342,40,231,10,32],"14868446",[356,342,31,228,116,40],"14869313",[358,342,43,324,359,40],"14868027","hellofunk",[133,33,32,233,134,40],[137,33,40,282,10,32],[363,366,369,372,373,376],{"id":364,"t":365,"points":332,"comments":39},"5587655",1366602174,{"id":367,"t":368,"points":32,"comments":40},"5650552",1367594474,{"id":370,"t":371,"points":32,"comments":32},"7086353",1390170695,{"id":4,"t":11,"points":13,"comments":14},{"id":374,"t":375,"points":304,"comments":32},"22793308",1586178091,{"id":377,"t":378,"points":32,"comments":40},"25718400",1610306002,[380,385,389,394,399,403],{"id":381,"name":382,"points":383,"category":384},"14894653","TensorFire",564,"ai",{"id":386,"name":387,"points":388,"category":19},"14865043","The JavaScript Way",545,{"id":390,"name":391,"points":392,"category":393},"14911372","Bt",254,"languages",{"id":395,"name":396,"points":397,"category":398},"14869138","EchoMods",227,"hardware",{"id":400,"name":401,"points":402,"category":393},"14896455","see-phit",175,{"id":404,"name":405,"points":406,"category":407},"14865666","Nuclino",133,"productivity",false,"v2",{"id":411,"name":5,"line":5,"ai":408,"cat":19,"year":12,"points":13,"comments":14,"rec":27,"s":412,"top":17,"kw":413,"maker":10,"domain":9,"tier":18,"attempts":30,"strip":414,"url":8,"mix":415,"praise":76,"objection":93,"sub":20},14865184,-0.26,[23,24,25,26],"1551150500300000111031000000035310103051",[30,31,32,33],1794036557699]