设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2911|回复: 0
打印 上一主题 下一主题

[已经解决] mv如何使用three.js?

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1232
在线时间
1017 小时
注册时间
2011-4-30
帖子
1516
跳转到指定楼层
1
发表于 2015-12-23 10:59:06 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 汪汪 于 2015-12-25 15:11 编辑

如题,

参考 live2d的那个试了试,结果只能获得一个静态的图......
如何让它动起来呢?

原始的
http://www.hewebgl.com/article/getarticle/50

        var scene = new THREE.Scene();
        var camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000);
        var renderer = new THREE.WebGLRenderer();
        renderer.setSize(window.innerWidth, window.innerHeight);
        document.body.appendChild(renderer.domElement);
        var geometry = new THREE.CubeGeometry(1,1,1);
        var material = new THREE.MeshBasicMaterial({color: 0x00ff00});
        var cube = new THREE.Mesh(geometry, material); scene.add(cube);
        camera.position.z = 5;
        function render() {
            requestAnimationFrame(render);
            cube.rotation.x += 0.1;
            cube.rotation.y += 0.1;
            renderer.render(scene, camera);
        }
        render();
参考live2d那个.修改成的
https://rpg.blue/forum.php?mod=viewthread&tid=385505
function L2d_Sprite(){
        this.initialize.apply(this, arguments);
}

/**
* RMMV Live2D Sprite 物件
*/

L2d_Sprite.prototype = Object.create(PIXI.Sprite.prototype);
L2d_Sprite.prototype.constructor = L2d_Sprite;
L2d_Sprite.prototype.initialize = function() {

    this.scene = new THREE.Scene();
    this.camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000);
    this.renderer = new THREE.WebGLRenderer({ alpha:true, });
    this.renderer.setSize(300, 300);
    this.geometry = new THREE.CubeGeometry(1,1,1);
    this.material = new THREE.MeshBasicMaterial({color: 0x00ff00});
    this.cube = new THREE.Mesh(this.geometry, this.material);
    this.scene.add(this.cube);
    this.camera.position.z = 5;
        var texture=new PIXI.Texture.fromCanvas(this.renderer.domElement);
        PIXI.Sprite.call(this, texture);
}










已自己解决.....


function T3_Sprite(){
        this.initialize.apply(this, arguments);
}
(function() {

       
T3_Sprite.prototype = Object.create(Sprite.prototype);
T3_Sprite.prototype.constructor = T3_Sprite;
T3_Sprite.prototype.initialize = function() {

    this.scene = new THREE.Scene();
    this.camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000);
    this.renderer = new THREE.WebGLRenderer({alpha:true});
    this.renderer.setSize(300, 300);
    this.geometry = new THREE.CubeGeometry(1,1,1);
    this.material = new THREE.MeshBasicMaterial({color: 0x00ff00});
    this.cube = new THREE.Mesh(this.geometry, this.material);
    this.scene.add(this.cube);
    this.camera.position.z = 5;
    this.renderer.render(this.scene, this.camera);
   
    this._canvas = this.renderer.domElement

        var texture=new PIXI.Texture.fromCanvas(this._canvas)
        PIXI.Sprite.call(this, texture);

    this._bitmap = null;
    this._frame = new Rectangle();   

    this._frame.width = this._canvas.width;
    this._frame.height = this._canvas.height;

   
    this._realFrame = new Rectangle();
    this._offset = new Point();
    this._blendColor = [0, 0, 0, 0];
    this._colorTone = [0, 0, 0, 0];
    this._context = null;
    this._tintTexture = null;

    this.spriteId = Sprite._counter++;
    this.opaque = false;


        this.requestID
    this.updateAnimation()
}







T3_Sprite.prototype.stopAnimation =function () {
         var cancelAnimationFrame =
            window.cancelAnimationFrame ||
            window.mozCancelAnimationFrame;
        //取消动画帧
        cancelAnimationFrame(this.requestID);
       
}




T3_Sprite.prototype.updateAnimation =function () {
        this.cube.rotation.x += 100;
    this.renderer.render(this.scene, this.camera)
    this.texture.baseTexture =new PIXI.BaseTexture(this._canvas);
        
        var requestAnimationFrame =
                     window.requestAnimationFrame ||
                     window.mozRequestAnimationFrame ||
            window.webkitRequestAnimationFrame ||
            window.msRequestAnimationFrame;
        this.requestID = requestAnimationFrame( this.updateAnimation.bind(this))
}



Object.defineProperty(T3_Sprite.prototype, 'bitmap', {
    configurable: false
});



})();
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-12-22 20:37

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表