Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I control line width using the THREE.js createMultiMaterialObject function?

Tags:

three.js

webgl

I'm experimenting with the createMultiMaterialObject function in THREE.js to create shaded objects that also display a wireframe. The problem is the lines appear broken & don't seem to respond to the wireframeLinewidth parameter.

My materials are defined as follows:

var mat1 = new THREE.MeshBasicMaterial( { color: 0xd02000, transparent: true, blending: THREE.AdditiveBlending } )
var blackLines = new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, wireframeLinewidth: 4 } );

And the object is here:

 var object = THREE.SceneUtils.createMultiMaterialObject( new THREE.CubeGeometry( 100, 100, 100, 4, 4, 4 ), materials );
                object.position.set( -100, 150, 0 );
                scene.add( object );

But this produces this result:Bad WireFrame on MultiMaterial

Any help would be appreciated. Thanks!

like image 750
Jack Avatar asked Dec 14 '25 20:12

Jack


1 Answers

Your code is fine. Are you running Windows? If so, it is possibly an ANGLE issue, in which case the line width cannot be changed. See this related question.

If you are unable to increase the line width, a work-around in your case is to make the wireframe mesh just a bit larger than the solid mesh, like so:

object.children[ 1 ].scale.multiplyScalar( 1.01 );

If you do that, there will be no more broken lines and it will be beautiful. :-)

three.js r.55

like image 77
WestLangley Avatar answered Dec 18 '25 20:12

WestLangley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!