Skip to content
A simple javascript parser to read .3ds
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


js3ds is a javascript library to read .3ds files.

The library is inspired by lib3ds :, so, 
if you have experience with lib3ds, many objects will look familiar (Lib3dsMesh etc.).

At the moment only meshes are read: vertices, faces and texels. 
No materials etc. yet.

I didn't actually test this, so... one thing: Endian. 
Default is now little endian, You might want to pass 'true' as
first argument to the BinaryParser constructor to setup big endian.

This library couldn't have been creeated without Jonas Raoni Soares Silva's BinaryParser:

Much :-)
I suspect that especially the chunk reading code could be much smarter.

Loading a 3ds file
 * Load up a 3DS file
 * @param url
function loadFile(url) {
	var req = new XMLHttpRequest();

	if(req.overrideMimeType) {
		req.overrideMimeType("text/plain; charset=x-user-defined"); // urgh, that took a while to google

	req.onreadystatechange = function() {
		if(req.readyState == 4) {
			if(req.status == 0 || req.status == 200) {
				// @debugDiv is some div to log some stuff, ie: document.getElementById("myDebugDiv")
			  	// @bDebugging is a boolean indicating whether to log
				var lib3ds = new Lib3ds(debugDiv, bDebugging);
				// read the 3DS
	}"GET", url, true); 
After lib3ds.readFile() was called:

// loop over the parsed meshes
var i, j;
for (i = 0; i < lib3ds.meshes.length; i++) {
	var mesh = lib3ds.meshes[i]; // a mesh is of type Lib3dsMesh

	// vertices
	for (j = 0; j < mesh.points; j++) {
		var vert = mesh.pointL[j]; // a vert is an Array(3)
	// faces
	for (j = 0; j < mesh.faces; j++) {
		var face = mesh.faceL[j] // a face is of type Lib3dsFace
		// indices into the vert array above
		var idx0 = face.points[0];
		var idx1 = face.points[1];
		var idx2 = face.points[2];
		// so the face vertices are:
		var v0 = mesh.pointL[ idx0 ];
		var v1 = mesh.pointL[ idx1 ];
		var v2 = mesh.pointL[ idx2 ];
	// texels / uv: guess you can use the face indices above
	for (j = 0; j < mesh.texels; j++) {
		var uv = mesh.texelL[j];
		var u = uv[0];
		var v = uv[1];

Something went wrong with that request. Please try again.