Open GoogleCodeExporter opened 9 years ago
I see. This is a non-standard extension on binary STL file format. It is
documented in this article:
http://en.wikipedia.org/wiki/STL_(file_format)#Color_in_binary_STL. Current
implementation does not support per-triangle color. Can you convert the STL to
a wavefront obj file, which provide good support for per-face color?
Original comment by Humu2...@gmail.com
on 17 Dec 2014 at 12:58
converting my STLs to OBJs will be very uncomfortable.
The STLs are automatically generated by our PDM every time me or one of my
colleagues modifies a part.
i'm looking to code a little hack to read the color directly from the file and
set it.
file = '../stl/mymodel.stl'
viewer.setParameter('SceneUrl', file);
viewer.setParameter('ModelColor', STLRGBcolor(file));
it will surely impact performance, let's see how much.
Original comment by e.fanz...@gmail.com
on 17 Dec 2014 at 2:46
It requires modification of the JSC3D.Mesh structure, adding additional buffers
to store per face colors. The rasterization routines must also be modified to
take the color info into account.
Original comment by Humu2...@gmail.com
on 18 Dec 2014 at 1:43
Are you planning to implement this, even if it's not a standard extension of
binary STL file format?
Original comment by e.fanz...@gmail.com
on 18 Dec 2014 at 2:03
Not yet. It is not difficult to modify the STL parser to read in extra
information correctly. But it requires a lot of coding work to rewrite the
rasterization pipelines to support per face colors, without messing up the
existing implementation.
Original comment by Humu2...@gmail.com
on 20 Dec 2014 at 3:06
If you are using Jsc3d for an educational or a public project, I can write a
customized branch edition of the library with this very feature especially for
your project.
Original comment by Humu2...@gmail.com
on 20 Dec 2014 at 11:47
I'm testing jsc3d for business purposes.
I already wrote some code that can read color from the STL file and set it.
It sort of works.
I still need to find a way to properly read HEX data and give modelColor the
proper value (i'm very bad at JS)
here's some code
notes: i'm using JQuery
$("CANVAS.3dviewer").each(function() {
var fileUrl = this.innerHTML;
var modelColor = '#888888'; //default color
//keeps the canvas from stretcing my model
this.width = this.clientWidth * 2;
this.height = this.clientHeight * 2;
var viewer = new JSC3D.Viewer(this);
viewer.setParameter('SceneUrl', fileUrl);
$.ajax({
url: fileUrl,
async: false,
success: function(data) {
var search = "COLOR=";
var pos = data.indexOf(search);
if (pos >= 0) {
pos += search.length;
//modelColor = data[pos] + data[pos + 1] + data[pos + 2]
}
}
});
viewer.setParameter('ModelColor', modelColor);
viewer.init();
viewer.update();
});
i'll appreciate any suggestion/correction
Original comment by e.fanz...@gmail.com
on 20 Dec 2014 at 12:49
The solution looks good except it need to load an STL file twice.
I think I misunderstood what you meant. I had thought we were talking about the
non-standard per-face color extension on binary STL format. In fact, it seems
you actually meant the definition of the overall color for the entire model
leading by 'COLOR='. The latter is not that difficult to support based on the
current implementation.
I'm just considering to support this feature in Jsc3d's STL loader. Could you
send me some sample STL files with color defined for testing perpose? I guess
it can be done within 1 or 2 days if all goes well.
Original comment by Humu2...@gmail.com
on 21 Dec 2014 at 2:08
I did some testing and the browser (Chrome, at least) caches the STL between
the 2 requests.
Per-face color sounds pretty hard to me.
The STL file format defines one single color for the entire model.
And... that's one of my biggest concern.
The viewer i'm coding must display single parts and assemblies.
When the assembly contains parts of 2 different materials (for instance a piece
of plastic with a steel insert) i can't differentiate between the two.
That's not a JSC3D fault, it's an STL file format limitation.
Original comment by e.fanz...@gmail.com
on 21 Dec 2014 at 1:22
That's it. The STL file format was designed mainly for rapid prototyping and
CAM. The surface colors or materials are of less importance for this aim.
Original comment by Humu2...@gmail.com
on 22 Dec 2014 at 1:42
Original issue reported on code.google.com by
e.fanz...@gmail.com
on 16 Dec 2014 at 3:35