{"id":20661005,"url":"https://github.com/liatemplates/mec2","last_synced_at":"2026-02-21T16:41:22.813Z","repository":{"id":107256837,"uuid":"302027630","full_name":"LiaTemplates/mec2","owner":"LiaTemplates","description":"Port of the mec2 2D physics simulation engine to LiaScript","archived":false,"fork":false,"pushed_at":"2020-12-02T19:33:16.000Z","size":73,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-24T11:42:33.734Z","etag":null,"topics":["liascript","liascript-template","mec2","oer","physics","simulation"],"latest_commit_sha":null,"homepage":"https://liascript.github.io/course/?https://raw.githubusercontent.com/LiaTemplates/mec2/main/README.md","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LiaTemplates.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-07T12:21:48.000Z","updated_at":"2024-10-29T15:40:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"f630d608-18cc-426e-bdae-63952016df3f","html_url":"https://github.com/LiaTemplates/mec2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LiaTemplates/mec2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2Fmec2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2Fmec2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2Fmec2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2Fmec2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LiaTemplates","download_url":"https://codeload.github.com/LiaTemplates/mec2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2Fmec2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29686802,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T15:51:39.154Z","status":"ssl_error","status_checked_at":"2026-02-21T15:49:03.425Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["liascript","liascript-template","mec2","oer","physics","simulation"],"created_at":"2024-11-16T19:06:46.273Z","updated_at":"2026-02-21T16:41:22.797Z","avatar_url":"https://github.com/LiaTemplates.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\nauthor:   André Dietrich\n\nemail:    LiaScript@web.de\n\nlogo:     logo.png\n\nversion:  0.0.1\n\nlanguage: de\n\nnarrator: US English Female\n\ncomment:  Port of the Mec2 Simulator from https://github.com/goessner/mec2\n          to LiaScript.\n\nscript:   https://jauhl.github.io/mecEdit/scripts/g2.js\n          https://jauhl.github.io/mecEdit/scripts/mec2.min.js\n          https://jauhl.github.io/mecEdit/scripts/mecelement/canvasInteractor.js\n          https://jauhl.github.io/mecEdit/scripts/mecelement/g2.selector.js\n          https://jauhl.github.io/mecEdit/scripts/mecelement/mec.htmlelement.js\n\n\n@mec2\n\u003clia-keep\u003e\n\u003cMEC-2 width=800 height=600 grid cartesian darkmode x0=385 y0=139 \u003e\n@0\n\u003c/MEC-2\u003e\n\u003c/lia-keep\u003e\n@end\n\n@mec2.eval: @mec2.eval_(@uid)\n\n@mec2.eval_\n\u003cscript\u003e\nlet json=`@input`\n\ndocument.getElementById(\"@0\").innerHTML = \"\u003cMEC-2 id='test' width=1530 height=680 grid cartesian darkmode x0=385 y0=139 \u003e\" + json + \"\u003c/MEC-2\u003e\"\n\n\"LIA: stop\"\n\u003c/script\u003e\n\n\u003cdiv id=\"@0\"\u003e\u003c/div\u003e\n\n@end\n\n--\u003e\n\n# mec2\n\n    --{{0}}--\nThis document defines some basic macros for applying the\n[mec2](https://goessner.github.io/mec2/) 2D physics simulation in\n[LiaScript](https://LiaScript.github.io).\n\n__Try it on LiaScript:__\n\nhttps://liascript.github.io/course/?https://raw.githubusercontent.com/LiaTemplates/mec2/main/README.md\n\n__See the project on Github:__\n\nhttps://github.com/liaTemplates/mec2\n\n    --{{1}}--\nThere are three ways to use this template. The easiest way is to use the\n`import` statement and the url of the raw text-file of the master branch or any\nother branch or version. But you can also copy the required functionionality\ndirectly into the header of your Markdown document, see therefor the\n[last slide](#Implementation). And of course, you could also clone this project\nand change it, as you wish.\n\n    {{1}}\n1. Load the macros via\n\n   `import: https://raw.githubusercontent.com/LiaTemplates/mec2/main/README.md`\n\n2. Copy the definitions into your Project\n\n3. Clone this repository on GitHub\n\n\n## `@mec2`\n\n    --{{0}}--\nSimply add `@mec2` directly to the head of your Markdown code-snippet to execute\nit directly within LiaScript.\n\n``` json @mec2\n{\n  \"id\":\"chaos-pendulums\",\n  \"gravity\":true,\n  \"nodes\": [\n    { \"id\":\"A0\",\"x\":200,\"y\":400,\"base\":true },\n    { \"id\":\"A1\",\"x\":280,\"y\":480,\"m\":2 },\n    { \"id\":\"B1\",\"x\":279,\"y\":481,\"m\":2 },\n    { \"id\":\"C1\",\"x\":278,\"y\":482,\"m\":2 },\n    { \"id\":\"D1\",\"x\":277,\"y\":483,\"m\":2 },\n    { \"id\":\"A2\",\"x\":360,\"y\":560,\"m\":3 },\n    { \"id\":\"B2\",\"x\":359,\"y\":561,\"m\":3 },\n    { \"id\":\"C2\",\"x\":358,\"y\":562,\"m\":3 },\n    { \"id\":\"D2\",\"x\":357,\"y\":563,\"m\":3 },\n    { \"id\":\"A3\",\"x\":440,\"y\":640,\"m\":4.7 },\n    { \"id\":\"B3\",\"x\":439,\"y\":641,\"m\":4.7 },\n    { \"id\":\"C3\",\"x\":438,\"y\":642,\"m\":4.7 },\n    { \"id\":\"D3\",\"x\":437,\"y\":643,\"m\":4.7 }\n  ],\n  \"constraints\": [\n    { \"id\":\"a1\",\"p1\":\"A0\",\"p2\":\"A1\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"a2\",\"p1\":\"A1\",\"p2\":\"A2\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"a3\",\"p1\":\"A2\",\"p2\":\"A3\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"b1\",\"p1\":\"A0\",\"p2\":\"B1\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"b2\",\"p1\":\"B1\",\"p2\":\"B2\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"b3\",\"p1\":\"B2\",\"p2\":\"B3\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"c1\",\"p1\":\"A0\",\"p2\":\"C1\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"c2\",\"p1\":\"C1\",\"p2\":\"C2\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"c3\",\"p1\":\"C2\",\"p2\":\"C3\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"d1\",\"p1\":\"A0\",\"p2\":\"D1\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"d2\",\"p1\":\"D1\",\"p2\":\"D2\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"d3\",\"p1\":\"D2\",\"p2\":\"D3\",\"len\":{ \"type\":\"const\" } }\n  ],\n  \"views\": [\n    { \"show\":\"pos\",\"of\":\"A3\",\"as\":\"trace\",\"id\":\"view1\",\"stroke\":\"rgba(255,0,0,.5)\" },\n    { \"show\":\"pos\",\"of\":\"B3\",\"as\":\"trace\",\"id\":\"view2\",\"stroke\":\"rgba(0,255,0,.5)\" },\n    { \"show\":\"pos\",\"of\":\"C3\",\"as\":\"trace\",\"id\":\"view3\",\"stroke\":\"rgba(255,255,0,.5)\" },\n    { \"show\":\"pos\",\"of\":\"D3\",\"as\":\"trace\",\"id\":\"view4\",\"stroke\":\"rgba(255,0,255,.5)\" }\n  ]\n}\n```\n\n\n## `@mec2.eval`\n\n    --{{0}}--\nAttach `@mec2.eval` to the end of your Markdown code-snippet to create an\neditable  and executeable simulation.\n\n``` json\n{\n  \"id\":\"chaos-pendulums\",\n  \"gravity\":true,\n  \"nodes\": [\n    { \"id\":\"A0\",\"x\":200,\"y\":400,\"base\":true },\n    { \"id\":\"A1\",\"x\":280,\"y\":480,\"m\":2 },\n    { \"id\":\"B1\",\"x\":279,\"y\":481,\"m\":2 },\n    { \"id\":\"C1\",\"x\":278,\"y\":482,\"m\":2 },\n    { \"id\":\"D1\",\"x\":277,\"y\":483,\"m\":2 },\n    { \"id\":\"A2\",\"x\":360,\"y\":560,\"m\":3 },\n    { \"id\":\"B2\",\"x\":359,\"y\":561,\"m\":3 },\n    { \"id\":\"C2\",\"x\":358,\"y\":562,\"m\":3 },\n    { \"id\":\"D2\",\"x\":357,\"y\":563,\"m\":3 },\n    { \"id\":\"A3\",\"x\":440,\"y\":640,\"m\":4.7 },\n    { \"id\":\"B3\",\"x\":439,\"y\":641,\"m\":4.7 },\n    { \"id\":\"C3\",\"x\":438,\"y\":642,\"m\":4.7 },\n    { \"id\":\"D3\",\"x\":437,\"y\":643,\"m\":4.7 }\n  ],\n  \"constraints\": [\n    { \"id\":\"a1\",\"p1\":\"A0\",\"p2\":\"A1\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"a2\",\"p1\":\"A1\",\"p2\":\"A2\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"a3\",\"p1\":\"A2\",\"p2\":\"A3\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"b1\",\"p1\":\"A0\",\"p2\":\"B1\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"b2\",\"p1\":\"B1\",\"p2\":\"B2\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"b3\",\"p1\":\"B2\",\"p2\":\"B3\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"c1\",\"p1\":\"A0\",\"p2\":\"C1\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"c2\",\"p1\":\"C1\",\"p2\":\"C2\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"c3\",\"p1\":\"C2\",\"p2\":\"C3\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"d1\",\"p1\":\"A0\",\"p2\":\"D1\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"d2\",\"p1\":\"D1\",\"p2\":\"D2\",\"len\":{ \"type\":\"const\" } },\n    { \"id\":\"d3\",\"p1\":\"D2\",\"p2\":\"D3\",\"len\":{ \"type\":\"const\" } }\n  ],\n  \"views\": [\n    { \"show\":\"pos\",\"of\":\"A3\",\"as\":\"trace\",\"id\":\"view1\",\"stroke\":\"rgba(255,0,0,.5)\" },\n    { \"show\":\"pos\",\"of\":\"B3\",\"as\":\"trace\",\"id\":\"view2\",\"stroke\":\"rgba(0,255,0,.5)\" },\n    { \"show\":\"pos\",\"of\":\"C3\",\"as\":\"trace\",\"id\":\"view3\",\"stroke\":\"rgba(255,255,0,.5)\" },\n    { \"show\":\"pos\",\"of\":\"D3\",\"as\":\"trace\",\"id\":\"view4\",\"stroke\":\"rgba(255,0,255,.5)\" }\n  ]\n}\n```\n@mec2.eval\n\n## Implementation\n\n```html\nscript: https://jauhl.github.io/mecEdit/scripts/g2.js\n        https://jauhl.github.io/mecEdit/scripts/mec2.min.js\n        https://jauhl.github.io/mecEdit/scripts/mecelement/canvasInteractor.js\n        https://jauhl.github.io/mecEdit/scripts/mecelement/g2.selector.js\n        https://jauhl.github.io/mecEdit/scripts/mecelement/mec.htmlelement.js\n\n\n@mec2\n\u003clia-keep\u003e\n\u003cMEC-2 width=800 height=600 grid cartesian darkmode x0=385 y0=139 \u003e\n@0\n\u003c/MEC-2\u003e\n\u003c/lia-keep\u003e\n@end\n\n@mec2.eval: @mec2.eval_(@uid)\n\n@mec2.eval_\n\u003cscript\u003e\nlet json=`@input`\n\ndocument.getElementById(\"@0\").innerHTML = \"\u003cMEC-2 id='test' width=1530 height=680 grid cartesian darkmode x0=385 y0=139 \u003e\" + json + \"\u003c/MEC-2\u003e\"\n\n\"LIA: stop\"\n\u003c/script\u003e\n\n\u003cdiv id=\"@0\"\u003e\u003c/div\u003e\n\n@end\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliatemplates%2Fmec2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliatemplates%2Fmec2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliatemplates%2Fmec2/lists"}