live2d搭建API
2019-04-27
原生js静态加载 使用cdn 遇到的问题(未解决)
Uncaught DOMException: Failed to execute 'texImage2D' on 'WebGLRenderingContext': The image element contains cross-origin data, and may not be loaded.
Access to XMLHttpRequest at 'file:///home/lynx/webGL/assets/Epsilon/Epsilon.model.json' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
main.js:7588 Failed to load (0) : new/assets/Epsilon/Epsilon.model.json
不使用cdn php动态加载
参考fghrsh的API实现
原代码分析 结构
live2d_api/-+-add/---index.php | +-get/---index.php | +-model/---{模型}/ | +-rand/---index.php | +-rand_textures/---index.php | +-switch/---index.php | +-switch_textures/---index.php | +-tools/-+-jsonCompatible.php | | | +-modelList.php | | | +-modelTextures.php | | | `name-to-lower.php | `-model_list.json
live2d_fore/-+-lib/-+-jquery-ui.min.js | | | `-jquery.min.js | +-css/-+-font-awesome.min.css | | | +-flat-ui-icons-regular.eot | | | +-flat-ui-icons-regular.svg | | | +-flat-ui-icons-regular.ttf | | | +-flat-ui-icons-regular.woff | | | `-tips.css | +-live2d.min.js | +-autoload.js | +-tips.js | +-tips.json | `-fuck.json
文件功能 前端
lib/
里面的是必备的jquery
由于作者使用了font-awesome图标,所以font-awesome
和flat-ui-icons-regular
都必备
live2d.min.js 作者将Live2DFramework
,live2d.min.js
,LAppDefine
,LAppLive2DManager
,LAppModel
,PlatformManager
,MatrixStack
,ModelSettingJson
全部合并到了live2d.min.js
(舍去SampleApp
)
! function (t ) // 这个参数貌似也没有用 { ...; }([function ( ) {}, function ( ) {}, ..., function ( ) {}]);
function (t, e, i ) // Live2DFramework { ..., t.exports = { l2dtargetpoint: p, Live2DFramework: c, L2DViewMatrix: f, L2DPose: $, L2DPartsParam: u, L2DPhysics: l, L2DMotionManager: h, L2DModelMatrix: a, L2DMatrix44: _, EYE_STATE: g, L2DEyeBlink: s, L2DExpressionParam: n, L2DExpressionMotion: o, L2DBaseModel: r } },
function (t, e, i ) // LAppDefine { "use strict" ; t.exports = { ... } },
function (t, e, i ) // 不清楚哪一部分,和网页问候语有关 { ; },
function (t, e, i ) // MatrixStack { ..., t.exports = r; },
function (t, e, i ) // 不知道干嘛的,删掉感觉没影响 { t.exports = i(5 ); }
后端 add get rand rand_textures switch switch_textures 重构(官方SDK + API)