【问题标题】:JSC3D: translating objectJSC3D:翻译对象
【发布时间】:2015-09-08 09:50:29
【问题描述】:

我正在尝试翻译空间中的对象,并且我有这个应该翻译对象的函数,它存储在 .js 文件中

 JSC3D.Matrix3x4.prototype.translate = function(tx, ty, tz) {
this.m03 += tx;
this.m13 += ty;
this.m23 += tz;
 };

但是在另一个 js 文件中,我正在尝试实现实数并移动对象,如何调用此函数并更改其参数?

【问题讨论】:

    标签: javascript jsc3d


    【解决方案1】:
    JSC3D.Matrix3x4.prototype.translate = function(tx, ty, tz) {
    
    var t=0;
    var g=0;
    var h=0;
    
     t = parseFloat(document.getElementById('translate_x').value);
     g = parseFloat(document.getElementById('translate_y').value);
     h = parseFloat(document.getElementById('translate_z').value);
    console.log(t);
    
        if(t!=0 || g!=0 || h!=0)
        {
    
            console.log(this.m03);
            this.m03 += tx;
            this.m13 += ty;
            this.m23 += tz;
            tx=t;
            ty=g;
            tz=h;
            this.m03 += tx;
           this.m13 += ty;
           this.m23 += tz;
       }
       else
       {
         this.m03 += tx;
         this.m13 += ty;
         this.m23 += tz;
       }
    };
    

    【讨论】:

    • 在另一个文件 viewer.onmousedown = function(x, y, button, depth, mesh) { if(button == 0/*left button down*/ && mesh != null) { // 创建一个不同颜色的新材质(例如蓝色) var newMat = new JSC3D.Material('', 0, 0x000080, 0, true); // 将新材质设置为选定的网格 mesh.setMaterial(newMat); // 告诉查看器渲染一个新的帧 viewer.update();
    猜你喜欢
    • 1970-01-01
    • 2016-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-01
    • 2014-01-19
    • 1970-01-01
    • 2019-06-10
    相关资源
    最近更新 更多