chetto1983 / jsc3d

Automatically exported from code.google.com/p/jsc3d
0 stars 0 forks source link

Rotation/Translation not working under event handler #155

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. A simple cube mesh is defined and get rendered using JSC3D. The following 
code segment is working fine.

    <script type="text/javascript" src="../jsc3dNew.js"></script>
    <script type="text/javascript" src="../jsc3d.webgl.js"></script>
    <script type="text/javascript" src="../jsc3d.touch.js"></script>
    <script type="text/javascript">
    var canvas = document.getElementById('cv');
    var viewer = new JSC3D.Viewer(canvas);
    viewer.setParameter('SceneUrl', '');
    viewer.setParameter('InitRotationX', 0);
    viewer.setParameter('InitRotationY', 0);
    viewer.setParameter('InitRotationZ', 0);
    viewer.setParameter('ModelColor', '#CAA618');
    viewer.setParameter('BackgroundColor1', '#FFFFFF');
    viewer.setParameter('BackgroundColor2', '#383840');
        viewer.setParameter('RenderMode', 'wireframe');
    viewer.setParameter('Renderer', 'webgl');

    viewer.init();
    viewer.update();

        var myobj =  new JSC3D.Mesh;
    myobj.creaseAngle = 30;

    myobj.vertexBuffer = [ 0,0,0, 10,0,0, 10,10,0, 0,10,0, 0,0,10, 10,0,10, 10,10,10, 0,10,10];
        myobj.indexBuffer = [0,1,2,3,-1, 0,4,7,3,-1,  4,5,6,7,-1,  5,1,2,6,-1,  3,2,6,7,-1, 0,1,5,4,-1];
        myobj.texCoordBuffer = [ 0,.5,   .25,.5,  .25,1,  0,1];
        myobj.texCoordIndexBuffer = [0,1,2,3,-1, 0,1,2,3,-1, 0,1,2,3,-1, 0,1,2,3,-1,  0,1,2,3,-1, 0,1,2,3,-1];

        myobj.isDoubleSided = true;
    myobj.setMaterial(mat1);
    myobj.init();   
    scene.addChild(myobj);
        viewer.replaceScene(scene);
        /***********************************************/
        /* run additional step to rotate around z-axis */
        /***********************************************/
        var rotMat = new JSC3D.Matrix3x4;
        rotMat.rotateAboutZAxis(30);
        JSC3D.Math3D.transformVectors(rotMat, myobj.vertexBuffer, 
                              myobj.vertexBuffer);
        JSC3D.Math3D.transformVectors(rotMat, myobj.vertexNormalBuffer,
                              myobj.vertexNormalBuffer);
        JSC3D.Math3D.transformVectors(rotMat, myobj.faceNormalBuffer, 
             myobj.faceNormalBuffer);
        viewer.update();

2. While trying to run the above additional steps under a event handler 
function 
   it is not working.

     function myrotate(){
        var rotMat = new JSC3D.Matrix3x4;
        rotMat.rotateAboutZAxis(30);
        JSC3D.Math3D.transformVectors(rotMat, myobj.vertexBuffer, 
                              myobj.vertexBuffer);
        JSC3D.Math3D.transformVectors(rotMat, myobj.vertexNormalBuffer,
                              myobj.vertexNormalBuffer);
        JSC3D.Math3D.transformVectors(rotMat, myobj.faceNormalBuffer, 
             myobj.faceNormalBuffer);
        viewer.update();
     } 
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

I am using jsc3d v.1.6.5 version

Please provide any additional information below.

Original issue reported on code.google.com by ucdu...@gmail.com on 22 May 2015 at 1:27