ambiera home ambiera home

Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name:  Password:
Ambiera Forum > CopperLicht
OBJ loader
Author Text

Registered User
2012-01-06 02:51:20

Link to an OBJ loader, have not tested it extensively. It loads only the vertices/face/normal data, not anything else, such as materials and hierarchy. Don't load too big objects.

Again, most of it is based on CopperLicht code, so the same license applies to it.



var duck = new ObjLoaderNode();
duck.load(engine, "ducky.obj", 0.05); //filename + scale

EDIT: One remark: Since the loader doesn't stop the execution of the rest of the program, I had difficulty implementing collisions for the object.
To resolve this issue, I had to add the TriangleSelector after the mesh was loaded. Before loading the mesh, create a MetaSelector and apply it to the camera. Then, in the pastebin code, at line 113, create a TriangleSelector and add that to the allready existing MetaSelector.

2012-01-06 15:00:08

that's cool. I think a few people in this forum wanted something like this :)

Registered User
2012-01-11 04:51:03

ty for sharing!
I just dug into CopperLicht yesterday and knew this would be the first task at hand.
Sadly, it seems to only render every other poly for me. I am set on finding out why though :)

Registered User
2012-01-11 22:52:34

In the meanwhile, I've been improving the routine somewhat more, experimenting with more models.
One model was also showing only half of its faces.
I don't remember exactly how, but it was fixed. So try this version, perhaps it works better:
This version includes an 'On Load' function (written without space)
If this still doesn't work correctly, I could have a look if you can link me the model.

Registered User
2012-01-14 22:24:01

Thanks warner yes it works now! I am using a cube exported from blender with the default settings

2014-06-12 16:28:26

hi Warner,

I am testing this solution in WebGL target ,

I put the Pasterbin code in the html page into the head section,
in the click event / run java script, I put the code

var vaso = new ObjLoaderNode();
vaso.load(engine, "vaso.obj", 0.05);

but it does not work, does not load the object in my scene

the application is correct?
Should I change something?

not good programming notions, could you please guide me

Registered User
2018-05-19 20:59:42

I am very thankful for this. It works for me. I used it with version 1.14 of CopperLicht.

(In case anyone is wondering, I didn't use the script from warner's first post. I used the one from his second post.)

When I first tried it, I thought it didn't work, like the person named "quintella" mentioned above, but I changed the scale from "0.05" to "1", and the object appeared. Different graphic-design programs use different measurements, so my first OBJ image appeared small at the size of "1", while another object looked gigantic at that size, so I set the scale of that second object to "0.05" to shrink it, while the first object was invisible at that scale!

In the console of my Firefox browser, I saw this error, even though the OBJ file seems to be imported normally:
XML Parsing Error: not well-formed
Location: sampleobject.obj
Line Number 1, Column 2:

It says an error is in Column 2 of Line 1 of my "OBJ" file. As far as I'm aware, some errors in consoles are safe to ignore, but I am not qualified to claim whether that error is important. In case people want to see the contents of my OBJ file so they can try to discern what causes the error, I opened it with a text editor so I could share what I see (an octothorpe symbol is in the file, right before the word "Exported", but it won't appear on this forum because of strong security):
Exported from 3D Builder
mtllib sampleobject.mtl

o Object.1
v -20.000000 -20.000000 0.000000
v 20.000000 -20.000000 0.000000
v 0.001999 0.001999 39.998001
v -20.000000 20.000000 0.000000
v 20.000000 20.000000 0.000000

usemtl Indigo
f 1 2 3
f 4 2 1
f 1 3 4
f 2 5 3
f 5 4 3
f 5 2 4

I haven't tried to interact with the objects imported with this OBJ loader yet, so I don't know how reliable the script is. I tested only to see if they appear on my screen.

Create reply:

Posted by: (you are not logged in)

Enter the missing letter in: "Int?rnational" (you are not logged in)




Forum Codes

Feature Code
Link [url] [/url]
Bold [b]bold text[/b]
Image [img][/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]



Software: Ambiera Light Forum. © 2008-2019 Nikolaus Gebhardt, Ambiera e.U.