Hello everybody.
First off, thanks for this incredible technology and helpful community.
I’ve always been helped by lurking the forum posts and BJS tutorials, but now I’m being stuck with several problems.
But let’s try to keep it simple : I want to highlight zones of imported (with SceneLoader.Append
) meshes that intersects. Like in this PG : https://playground.babylonjs.com/#15S2V0#2
PG will come soon, but let me explain first :
First solution https://www.babylonjs-playground.com/#Q9K825#11
Let’s
- select at least 2 meshes
- convert them to a CSG
- get the intersectCSG
- create a new mesh from this intersection
const firstMeshCsg = CSG.FromMesh(firstMesh);
const otherMeshCsg = CSG.FromMesh(otherMesh);
const intersectionCst = firstMeshCsg
.intersect(otherMeshCsg)
.inverse();
const intersectionMesh = intersectionCst.toMesh('qsfqsf', mat2, this.scene)
intersectionMesh.renderingGroupId = 1;
intersectionMesh.isPickable = false ;
With this code, everything works fine,
BUT !
my intersectionMesh
position (and sometimes rotation) is f****d.
Second solution https://www.babylonjs-playground.com/#Q9K825#12
Okay, lets screw firstMeshCsg
and otherMeshCsg
for good !
firstMesh.bakeCurrentTransformIntoVertices() // <--
otherMesh.bakeCurrentTransformIntoVertices() // <--
const firstMeshCsg = CSG.FromMesh(firstMesh);
const otherMeshCsg = CSG.FromMesh(otherMesh);
const intersectionCst = firstMeshCsg
.intersect(otherMeshCsg)
.inverse();
const intersectionMesh = intersectionCst.toMesh('qsfqsf', mat2, this.scene)
intersectionMesh.renderingGroupId = 1;
intersectionMesh.isPickable = false ;
Yay ! my shape is at the right place !
but i cannot interact with my scene properly : some meshes disappear when I try to click on them, and there’s a lot of WebGL: INVALID_OPERATION: drawElements: no buffer is bound to enabled attribute
in the console.
SO
My questions are :
- do my
bakeCurrentTransformIntoVertices()
misses something - can I achieve what I want in an other way ?