23 Feb 2016

Custom transparent meshes with View & Data API

Default blog image

By Philippe Leefsma (@F3lipek)

Here is a quick post for the road, the topic was raised by Bill Malcom in that forum thread:

"I have been adding my own custom THREE.js objects in the existing viewer.impl.scene for a while with no problem. However, I need to set the transparency on a simple THREE.CircleGeometry. For some reason these custom objects don't display the transparency in the viewer. Maybe the viewer renderer in affecting this? I have done similar in a pure THREE.js viewer (non LMV) and it works. [...]"

It comes from the fact is that the custom geometry is added to a scene which is rendered before the actual model. In order for this to work correctly, the mesh have to be rendered after the model. It works when adding it to the sceneAfter:

var transparentMaterial = new THREE.MeshBasicMaterial({
  color: 0x7094FF,
  opacity: 0.1,
  transparent: true })


var geometry = new THREE.CircleGeometry(500, 50)
var mesh = new THREE.Mesh(

// prevents issue when running viewer selection
mesh.geometry.attributes = {position:{array:[]}}


// prevents your mesh from being hidden
// when hidding other viewer components

Here is a screenshot of the transparent custom mesh circle with a loaded model:

Screen Shot 2016-02-19 at 09.55.40


Related Article