Dominical1 / jsc3d

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

How to load 3ds with bmp file as texture? #164

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago

The jsc3d works very nice. I have a question when load 3ds files:

How to load 3ds file with a texture of bmp file?

For example: RoseR.3ds with RoseRT.bmp.  
                  -> currentMaterial.colorMap.url = 'rose/RoseRT.bmp'; ???

    var canvas = document.getElementById('cv');
    var viewer = new JSC3D.Viewer(canvas);
    viewer.setParameter('SceneUrl', 'rose/RoseR.3ds');
    viewer.setParameter('InitRotationX', 0);
    viewer.setParameter('InitRotationY', 0);
    viewer.setParameter('InitRotationZ', 0);
    viewer.setParameter('ModelColor', '#AAAAAA');
    viewer.setParameter('BackgroundColor1', '#007FFF');
    viewer.setParameter('BackgroundColor2', '#007FFF');
    viewer.setParameter('RenderMode', 'texturesmooth');
    viewer.setParameter('MipMapping', JSC3D.PlatformInfo.supportWebGL ? 'off' : 'on');
    viewer.setParameter('Renderer', 'webgl');
    viewer.init();
    viewer.update();

Thank you.

Original issue reported on code.google.com by lujian1...@gmail.com on 11 Jul 2015 at 1:49

GoogleCodeExporter commented 8 years ago
You can get test 3ds files from 
http://www.toucan.co.jp/3DCG/3ds/FlowerModelsE.html

Original comment by lujian1...@gmail.com on 11 Jul 2015 at 1:51

GoogleCodeExporter commented 8 years ago
Found a way to load texture bmp file as following:
      // create a new Texture instance
      var myTexture = new JSC3D.Texture;
      // setup the handler which will be called when texture is ready
      myTexture.onready = function() {
            // assume a single model has already been loaded
            var scene = viewer.getScene();
            var myMesh = scene.getChildren()[0];
            // set texture to the model
            myMesh.setTexture(this);
            // notify viewer to deliver a new frame
            viewer.update();
      }
      // begin to load this texture from a given url
      myTexture.createFromUrl('rose/RoseRT.bmp');

Original comment by lujian1...@gmail.com on 11 Jul 2015 at 2:18

GoogleCodeExporter commented 8 years ago
This ticket can be closed. Thanks.

Original comment by lujian1...@gmail.com on 11 Jul 2015 at 2:20

GoogleCodeExporter commented 8 years ago
The only drawback is jsc3d does not have good lightness to the object. 

You can compare with http://www.ibiblio.org/e-notes/webgl/deflate/roseR.html

A little disappoint with the results. Any way to improve the lightness?

    var canvas = document.getElementById('cv');
    var viewer = new JSC3D.Viewer(canvas);
    viewer.setParameter('SceneUrl', 'rose/RoseR.3ds');
    viewer.setParameter('InitRotationX', 0);
    viewer.setParameter('InitRotationY', 0);
    viewer.setParameter('InitRotationZ', 0);
    viewer.setParameter('ModelColor', '#AAAAAA');
    viewer.setParameter('BackgroundColor1', '#007FFF');
    viewer.setParameter('BackgroundColor2', '#007FFF');
    viewer.setParameter('RenderMode', 'texturesmooth');
    viewer.setParameter('MipMapping', JSC3D.PlatformInfo.supportWebGL ? 'off' : 'on');
    viewer.setParameter('Renderer', 'webgl');
    viewer.init();
    viewer.update();

      var myTexture = new JSC3D.Texture;
      myTexture.onready = function() {
            var scene = viewer.getScene();
            var myMesh = scene.getChildren()[0];
            myMesh.setTexture(this);
            viewer.update();
      }
      myTexture.createFromUrl('rose/RoseRT.bmp');

Original comment by lujian1...@gmail.com on 11 Jul 2015 at 2:34