mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
102.82k stars 35.38k forks source link

Collada import don't work - Error: "shader is null" #813

Closed Xroy closed 12 years ago

Xroy commented 12 years ago

Hi,

I'm trying to load a collada file on a application, and I'm getting this error:

shader is null

shader.material.opacity = !shader.material.opacity ? 1 : shader.material.opacity;

on ColladaLoader.js (linha 621)

createSceneGraph () on ColladaLoader.js (line 621)
node = Node { id="ID3", name="X", nodes=[52], more...}
parent = Node { id="ID2", name="instance_0", nodes=[1], more...}

createSceneGraph () on ColladaLoader.js (line 690)
node = Node { id="ID2", name="instance_0", nodes=[1], more...}
parent = Node { name="SketchUp", nodes=[1], controllers=[0], more...}

createSceneGraph () on ColladaLoader.js (line 690)
node = Node { name="SketchUp", nodes=[1], controllers=[0], more...}
parent = undefined

parse () on ColladaLoader.js (line 109)
doc = Document
callBack = collada_load_handler()
url = "test.dae?rnd=0.9813711857463775"

onreadystatechange() on ColladaLoader.js (line 61)

Anyone knows why?

mrdoob commented 12 years ago

Do you mind sharing the .dae file? :)

Xroy commented 12 years ago

Humm... I don't know if i can do that. It's a building's final modeling... I will ask the permission to the liable company. =/

But, seeing the code, i think the shader var isn't mandatory, right?

What I did here, for testing, was just add an if to the code on line 621, as below:

if (shader) {
    shader.material.opacity = !shader.material.opacity ? 1 : shader.material.opacity;
    used_materials[inst_material.symbol] = shader.material;
    first_material = shader.material;
    num_materials ++;
}

The load code run with no errors. I'll try to render now, to see if will work.

mrdoob commented 12 years ago

Do you mind trying it with the version in the dev branch?

Xroy commented 12 years ago

I've got the same error

Xroy commented 12 years ago

I tryed to run my code with the if clause, but it doesn't work. I've returned the code to normal and made some simpler model to test. The test rendered, but with bugs.

See this examples:

http://temp.projetosredirect.com.br/canvas/teste_webgl.html http://temp.projetosredirect.com.br/canvas/teste_canvas.html

The model should look like this:

http://temp.projetosredirect.com.br/canvas/printscreen.jpg

I think the problem is some dirt on the collada code, I'm generating it with SketchUP version 8.

I don't have the permission to show the collada code of the original object yet, but as soon I get it I'll post it here.

mrdoob commented 12 years ago

I think you just need to add a light to the scene.