Code Monkey home page Code Monkey logo

live2d-assets's Introduction

为你的网站加入响应式的2D模型

预览:Live 2D

live-2d

国内仓库:Gitee
  1. 在你的网站根目录下新建一个文件夹,命名为live2d
  2. 将你喜欢的模型所对应assets-*文件夹,及两个js文件放入你的live2d文件夹中
  3. 将assets-*文件夹重命名为assets
  4. 在你希望出现2D模型的页面的html代码中加入如下代码(注意更改代码中的模型名):
<div>
    <canvas id="live2dcanvas" width="150" height="300"></canvas>
</div>
<style>
    #live2dcanvas {
        position: fixed;
        width: 150px;
        height: 300px;
        opacity: 0.7;
        right: 0px;
        z-index: 999;
        pointer-events: none;
        bottom: -20px;
    }
</style>
<script type="text/javascript" src="/live2d/device.min.js"></script>
<script type="text/javascript">
    const loadScript = function loadScript(c, b) {
        var a = document.createElement("script");
        a.type = "text/javascript";
        "undefined" != typeof b && (a.readyState ? a.onreadystatechange = function () {
            if ("loaded" == a.readyState || "complete" == a.readyState) a.onreadystatechange = null, b()
        } : a.onload = function () {
            b()
        });
        a.src = c;
        document.body.appendChild(a)
    };
    (function () {
        if ((typeof(device) != 'undefined') && (device.mobile())) {
            document.getElementById("live2dcanvas").style.width = '75px';
            document.getElementById("live2dcanvas").style.height = '150px';
        } else if (typeof(device) === 'undefined') console.error('Cannot find current-device script.');
        loadScript("/live2d/script.js", function () {
            loadlive2d("live2dcanvas", "/live2d/assets/模型名.model.json", 0.5);
        });
    })();
</script>  

live2d-assets's People

Contributors

lnnt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.