guansss / pixi-live2d-display

A PixiJS plugin to display Live2D models of any kind.
https://guansss.github.io/pixi-live2d-display/
MIT License
870 stars 132 forks source link

Question #51

Closed IntroEvEivie closed 2 years ago

IntroEvEivie commented 2 years ago

is it possible to display local .moc or .json files without using the server side?

guansss commented 2 years ago

Sure. The Live2DModel.from() method can accept a flat array of Files containing all the files of a model, e.g. Live2DModel.from(files). Though working, it's an experimental feature and so not mentioned the docs.

The files array can be obtained by a file input or the drag and drop API.

IntroEvEivie commented 2 years ago

Sure. The Live2DModel.from() method can accept a flat array of Files containing all the files of a model, e.g. Live2DModel.from(files). Though working, it's an experimental feature and so not mentioned the docs.

The files array can be obtained by a file input or the drag and drop API.

If you can, please explain in more detail. i'm facing problem loading .json and .moc files from local resource. But usually there is an error "Access to XMLHttpRequest at 'file:///...test.json' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https. log.ts:25 [XHRLoader] Failed to load resource as json (Status 0): test.json". As far as I understand, it will not work if you use the server, but I want to display local resources on the Android platform in a webview and use it when this server is extremely difficult.

guansss commented 2 years ago

This is due to the security policy of the browser, and is out of the scope of this project, you can search the web for solutions. Basically, as long as you're able to load the files, there's no problem to use this plugin.