Some STL models appears in black in the editor (https://threejs.org/editor), for example: https://www.thingiverse.com/thing:45177
The following two lines of code are required to fix this at the moment to load the model:
geometry.computeFaceNormals();
geometry.computeVertexNormals();
The model's normals are all zero. So either the model is in error, or the loader has a bug.
After converting the following 3DS model from the Three.js Web (https://threejs.org/examples/models/3ds/portalgun/portalgun.3ds) into a STL model, i got the same issue, fixed with those two lines of code.


Maybe it's not relevant but you need to add a light source to your scene. Otherwise the model remains black. The editor applies per default an instance of MeshStandardMaterial to a Mesh that uses the geometry of a STL file.
So when i load this file in the editor and add a light source, the result looks good.

Sometimes I wonder if we should add a default lighting to the scene if the user hasn't added lights. Or maybe a default HemisphereLight in the editor?
When adding a light source, some STL objects (The portalgun.stl and the Trumpet Mouthpiece) are not affected by it. It works fine with the other STL object (the Einstein model). This can be fixed by adding those two lines of code.


Sometimes I wonder if we should add a default lighting to the scene if the user hasn't added lights.
I like the idea. Unity for example provides a directional light in new projects.

@lrusso I don't think this is a problem by the loader. Users have to ensure that their STL files have valid normal data. If they don't have these information they can try to generate them with geometry.computeVertexNormals(). But from my point of view, it's not a task of the loader.
https://github.com/mrdoob/three.js/issues/12499#issuecomment-339534784
It should be easy enough to determine if the loader is correctly loading the normals as specified in the model.
@mrdoob I would suggest this pattern if you want to add default lighting to the editor:
scene.add( camera );
camera.add( pointLight );
Sometimes I wonder if we should add a default lighting to the scene if the user hasn't added lights.
I like the idea. Unity for example provides a directional light in new projects.
Good to know! Yeah, I think this makes sense. I find myself adding a DirectionalLight every single time anyway.
@mrdoob I would suggest this pattern if you want to add default lighting to the editor:
scene.add( camera ); camera.add( pointLight );
I think that would be a bit confusing for the user...
+1 for a default light source. 馃檪
Closing since STLLoader does its job correctly. Adding a default lighting to the editor will be considered separately.
Most helpful comment
@lrusso I don't think this is a problem by the loader. Users have to ensure that their
STLfiles have valid normal data. If they don't have these information they can try to generate them withgeometry.computeVertexNormals(). But from my point of view, it's not a task of the loader.