WireframeGeometry from loaded object does not work

geometry

#1

I am trying to make a Wireframe-object from a loaded object, using WireframeGeometry like this:

  var objGeo=object._3DObject.children[0].geometry;
  var edgeGeo=THREE.WireframeGeometry(objGeo);
  var edgeLines = new THREE.LineSegments( edgeGeo, new THREE.LineBasicMaterial( { color: 0xd8aa77} ) );

The second line causes a “TypeError: this.addAttribute is not a function” in three.min.js

I made sure child #0 is a mesh, and it has a geometry attribute. I have tried it on different loaded objects and in every case I get this message. The objects are all FBX files.


#2

I assume just marking the material as wireframe doesn’t work for your project?


#3

It might work, if I can clone the object cause I need the normal version with a wireframe overlay… I’ll give it a try…


#4

It should be:

var edgeGeo = new THREE.WireframeGeometry( objGeo );

Notice the new operator.


#5

Ha, wow how stupid! How could I mis that.


#6

That works a lot better, but it looks like WireFrameMaterial does not go together with the OutlineEffect I am using. When I leave the effect out, it all works fine but when OutlineEffect is used I get a lot of shader errors like these:

TypeError: material.uniforms.outlineAlpha is undefined

and

[...]
33: attribute vec3 morphTarget5; 
34: attribute vec3 morphTarget6; 
35: attrib…

[three.min.js:54:477](http://dev.ngongo-b.net/adv3d/three/three.min.js)

THREE.WebGLProgram: shader error: 0 35715 false gl.getProgramInfoLog Must have a compiled vertex shader attached. ERROR: 0:185: 'outlineThickness' : redefinition ERROR: 0:186: 'calculateOutline' : function already has a body ERROR: 0:302: 'objectNormal' : redefinition [three.min.js:72:388](http://dev.ngongo-b.net/adv3d/three/three.min.js)

THREE.WebGLShader: Shader couldn't compile. [three.min.js:54:388](http://dev.ngongo-b.net/adv3d/three/three.min.js)

THREE.WebGLShader: gl.getShaderInfoLog() vertex ERROR: 0:201: 'outlineThickness' : redefinition ERROR: 0:202: 'calculateOutline' : function already has a body

1: precision highp float; 
2: precision highp int; 
3: #define SHADER_NAME ShaderMaterial 
4: #define VERTEX_TEXTURES 
5: #define GAMMA_FA
[...]

#7

What is WireFrameMaterial? Are you referring to a class of three.js?

In any event, sharing a live example will make it easier to debug this issue.


#8

…stupid typo… i meant LineBasicMaterial - I will try to mock up an example.


#9

Somehow I can not reproduce it, but I did do some debugging:

I noticed the first error is in OutlineEffect.js (line 305) and when I place a console.log dump of the material that is being mentioned in every case is a simple material used by a sprite.

A workaround for now is to insert a line that exits the function if the outline parameters are not in place.

But somehow I can not get my head arround where I messed up to get this problem. I am pretty sure sprites did not give me this problem before.