Issue 1:
Description of the problem

Every face in a Geometry has a materialIndex. When Three converts from a Geometry to a BufferGeometry...

var bufferGeometry = THREE.BufferGeometry.new().fromGeometry(geometry);

...there's an intermediary step where a DirectGeometry is used...

fromGeometry: function ( geometry ) {
geometry.__directGeometry = new DirectGeometry().fromGeometry( geometry );

Note that a DirectGeometry defines an indices array, then does nothing with it.

So it's not surprising when BufferGeometry checks the intermediary directGeometry.indices.length, it won't ever be populated.

When the BufferGeometry comes out the other end, it has no indices. bufferGeometry.getIndex() is null.

It looks like DirectGeometry's ability to handle indices was removed two years ago.

Here's a CodePen demonstrating the problem. Check the logs. The merged geometry should have indices returned, but it doesn't. https://codepen.io/andrewray/pen/gRyrzR?editors=0010

Three.js version

Dev

r85

Browser

All of them

OS

All of them

Issue 2:
Description of the problem

There is a very useful object property colorWrite described here:

https://stackoverflow.com/questions/28869268/three-js-transparent-object-occlusion

http://jsfiddle.net/4vnsbdz6/1/

http://jsfiddle.net/4vnsbdz6/4/

However, it relies on manually setting the render order and excludes rendering of objects behind other objects.

What I would find useful is a rendering option that does this kind of occlusion but for object groups inside or perhaps just behind another geometry and using its alpha map to determine the visibility of the objects inside, with the option to set an influence value to do inverse.

For example, there would be a cube with an alpha map on it.

There would be a THREE.Group with a property that uses one or more objects as a mask with a mask influence such as the cube.

If the group is inside the cube, it would render the group objects according to the alpha map.

The group would have the list of mask objects and if any of the pixels in the group are behind an opaque pixel in the cube, they'd be rendered, otherwise not rendered.

This would behave like world-space alpha maps. It can probably be achieved using a custom shader but the shader would need to be applied per object. This would allow easily doing things like cutaways for architectural models:

https://cdn1.28dayslater.co.uk/xf/2017/07/1458657_8291f7d765e875b0ce71ac9087b1350b.jpg

For that, a full architecture geometry would be modelled and put in a group and then one or more masking geometries made with alpha maps. The architecture group would set the masking geometries as properties but with a negative influence so that only pixels outside the masking geometry are drawn fully and inside, according to the alpha map.

I guess it can be applied per material using a loop, it would just be easier to do per group.

The colorWrite examples above are almost usable for this but it's not possible to set an inverse on it, it doesn't use alpha maps so would have to model intricate masks but the most important aspect is being able to easily exclude or include geometry in the occlusion - being able to set a list of masks on a specific set of objects would be much easier than using render order, especially with multiple masks.

Three.js version

Dev

[x ] r109

...

Browser

All of them

Chrome

Firefox

Internet Explorer

OS

All of them

Windows

macOS

Linux

Android

iOS

Hardware Requirements (graphics card, VR Device, ...)