vinoton / jsc3d

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

STL Perspective Issue #93

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. STL File uploaded to website
2. STL File loaded into page
3.

What is the expected output? What do you see instead?
File loaded is fine, but the perspectives seem wrong, as though part of the STL 
is mesh. File works fine in desktop STL viewers.

What version of the product are you using? On what operating system?
All Operating systems
Using version 1.6.5

Please provide any additional information below.
The site in question is handing many STL files and a lot of them are working 
fine - however there are a few (such as this one) which are causing this 
perspective issue - please see attached images.

Code used:
-- START CODE --
var canvas = document.getElementById('stl_content');
var viewer = new JSC3D.Viewer(canvas);
viewer.setParameter('SceneUrl', '*STL FILE URL*');
viewer.setParameter('RenderMode', 'textureflat');
viewer.setParameter('Renderer', 'webgl');
viewer.setParameter('ModelColor', '#666666');
viewer.setParameter('Definition', 'high');
viewer.setParameter('ProgressBar', 'on');
viewer.setParameter('BackgroundColor1', '#09090a');
viewer.setParameter('BackgroundColor2', '#676767');
viewer.init();
viewer.update();
-- END CODE --

Thanks for your help in advance.

Original issue reported on code.google.com by j...@onlinefusion.co.uk on 8 Aug 2014 at 3:40

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
It seems as if the face normal vectors are defined in wrong directions, which 
are required in rendering to detect and cull back faces. The solution is 
simple: use a modeling tool such as meshlab or 3dsmax to flip the vertex 
normals and regenerate the stl files to fix this issue.

If it is not convenient to fix the models manually, you can add the following 
short snippet immediately after the initialization of the viewer:

  viewer.onloadingcomplete = function() {
    var scene = viewer.getScene();
    if (scene) {
      scene.forEachChild( function(mesh) {
        mesh.isDoubleSided = true;
      } );
      viewer.update();
    }
  };

which marks the meshes to be double-sided to diable back-face culling. Current 
implementation of the WebGL renderer has an issue in drawing double-sided 
faces. So in this case this line should be removed:

  viewer.setParameter('Renderer', 'webgl');

from your initialization code to let the software render work instead.

Original comment by Humu2...@gmail.com on 8 Aug 2014 at 5:19

GoogleCodeExporter commented 9 years ago
Sorry. In fact the WebGL renderer works fine for double-sided faces. So just 
keep it please.

Original comment by Humu2...@gmail.com on 9 Aug 2014 at 4:56

GoogleCodeExporter commented 9 years ago
Thank you so much for this - worked like a charm!

Original comment by j...@onlinefusion.co.uk on 11 Aug 2014 at 8:13