{"id":17011145,"url":"https://github.com/mikuauahdark/lua-live2d","last_synced_at":"2025-03-22T13:21:11.481Z","repository":{"id":133073366,"uuid":"188651671","full_name":"MikuAuahDark/lua-live2d","owner":"MikuAuahDark","description":"Barebone Lua 5.1 binding to Live2D Cubism 3 Core SDK for Native","archived":false,"fork":false,"pushed_at":"2019-05-27T16:04:28.000Z","size":12,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-27T12:48:21.063Z","etag":null,"topics":["live2d","lua","lua51"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MikuAuahDark.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":"2019-05-26T07:13:51.000Z","updated_at":"2024-07-30T20:40:38.000Z","dependencies_parsed_at":"2023-03-10T15:52:25.692Z","dependency_job_id":null,"html_url":"https://github.com/MikuAuahDark/lua-live2d","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikuAuahDark%2Flua-live2d","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikuAuahDark%2Flua-live2d/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikuAuahDark%2Flua-live2d/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikuAuahDark%2Flua-live2d/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MikuAuahDark","download_url":"https://codeload.github.com/MikuAuahDark/lua-live2d/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244960051,"owners_count":20538743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["live2d","lua","lua51"],"created_at":"2024-10-14T06:06:20.940Z","updated_at":"2025-03-22T13:21:11.460Z","avatar_url":"https://github.com/MikuAuahDark.png","language":"C","readme":"lua-live2d\r\n==========\r\n\r\nBarebone Live2D Cubism 3 SDK for Native binding for Lua 5.1 (with plans to support Lua 5.2 and 5.3 coming\r\nsoon, patches welcome).\r\n\r\nThis Lua C module is meant to be used in conjunction with\r\n[lua-live2d-framework](https://www.github.com/MikuAuahDark/lua-live2d-framework).\r\n\r\nNote that only this Lua binding is MIT licensed. Live2D Cubism 3 SDK for Native is proprietary, non-free.\r\n\r\nLive2D Cubism Core\r\n------------------\r\n\r\nYour Live2D Cubism 3 SDK for Native zip should have this structure\r\n```\r\nCubism3SDKforNative-\u003cversion\u003e\r\n+ Core\r\n+ Framework\r\n+ Samples\r\n+ Package.json\r\n+ README.md\r\n```\r\nCopy the `Core` folder (only) in the zip to `live2d/Core` folder in this repository (create the `live2d` folder).\r\n\r\nExample Code\r\n------------\r\n\r\n```lua\r\nlocal lualive2dcore = require(\"lualive2d.core\")\r\nprint(\"Live2D Version: \"..lualive2dcore.Live2DVersion)\r\nprint(\"LuaJIT FFI table pointer: \"..tostring(lualive2dcore.ptr))\r\n\r\n-- modelData is the whole model file as string.\r\nlocal model = lualive2dcore.loadModelFromString(modelData)\r\n-- Model canvas information\r\nlocal width, height, centerX, centerY, pixelPerUnit = model:readCanvasInfo()\r\n-- Get model parameter defaults\r\nlocal parameterDefaults = model:getParameterDefault()\r\nfor i = 1, #parameterDefaults do\r\n\tlocal parameter = parameterDefaults[i]\r\n\tprint(\"Parameter #\"..i)\r\n\tprint(\"\\tName: \"..parameter.name)\r\n\tprint(string.format(\"\\tMinValue: %.4g  MaxValue: %.4g  DefaultValue: %.4g\", parameter.min, parameter.max, parameter.default))\r\nend\r\n-- Get parameter current value\r\nlocal parameterValue = model:getParameterValues()\r\n-- Set parameter values\r\nparameterValue[index] = math.random()\r\nmodel:setParameterValues(parameterValue)\r\n-- Update model to account for the new parameter values\r\nmodel:update()\r\n-- Get drawable data\r\nlocal drawableData = model:getDrawableData()\r\n-- drawableData[index] = {\r\n--     name = drawable data name\r\n--     flags = {\r\n--         blending = normal|add|multiply\r\n--         doublesided = true|false\r\n--     }\r\n--     texture = texture index number (start from 1)\r\n--     mask = {list of draw mask index, start from 1}\r\n--            (maybe nil if there's no mask)\r\n--     vertexCount = amount of vertices for this draw data part\r\n--     uv = texture mapping coordinates list, interleaved as {x, y, x, y, x, y, ...}\r\n--          where #uv == vertexCount * 2\r\n--     indexMap = {list of vertex mapping, 1-based index}\r\n-- }\r\nlocal dynamicDrawableData = model:getDynamicDrawableData()\r\n-- dynamicDrawableData[index] = {\r\n--     drawOrder = current drawable data draw order\r\n--     renderOrder = current drawable data render order\r\n--     opacity = current drawable data opacity\r\n--     dynamicFlags = {\r\n--         visible = true|false\r\n--         visibilityChanged = true|false\r\n--         opacityChanged = true|false\r\n--         drawOrderChanged = true|false\r\n--         renderOrderChanged = true|false\r\n--         vertexChanged = true|false\r\n--     }\r\n--     vertexPosition = list of vertex position in \"units\" units interleaved as\r\n--                      {x, y, x, y, x, y, ...}. Multiply by \"pixelPerUnits\" to get\r\n--                      pixel position of the vertex then add by modelCenterX/Y to\r\n--                      make sure drawing start at (0, 0). This table has size of\r\n--                      #vertexPosition == vertexCount * 2.\r\n-- }\r\n-- Reset dynamic drawable data\r\nmodel:resetDynamicDrawableFlags()\r\n```\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikuauahdark%2Flua-live2d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikuauahdark%2Flua-live2d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikuauahdark%2Flua-live2d/lists"}