Hello everyone sorry if this topic already exist but I don’t found solution of my problem.
So I want to move an 3D object in vr scene but when i do this with my raycaster he don’t found my object on my group I think it’s because I add a object3d and not a mesh but I can had mesh because on these object I have 3 mesh and I want to move them at same time.
Well, an easy approach is to merge all meshes into one. This can be done with BufferGeometryUtils.mergeBufferGeometries() but only if the geometries have compatible attributes. Besides, it’s best for performance when the meshes share the same material.
Another option is to transform the parent object of an intersection. Instead of doing this:
var object = intersection.object;
try it with
var object = intersection.object.parent;
Keep in mind that you can’t modify the material property in this case since the parent is of type Object3D.
When I want to merge my meshes it say that:
Cannot convert undefined or null to object
And I do that:
var geometry=[]
for (var i = 0; i <object3d.children.length; i++) {
geometry.push(object3d.children[i]);
}
console.log(geometry);
var mergedGeo = THREE.BufferGeometryUtils.mergeBufferGeometries(geometry);
My console.log show me an array of 3 mesh. I think I m just a noob sorry XD
Besides, please take your time and properly format code snippets in your posts. Don’t just copy/paste them. You can use three ` signs to start and end a code listing.
I have encountered this problem recently, and I think it is necessary to modify the official documents.
When you use intersectObject() or intersectObjects() and you pass in groups, you have to set the second parameter to true, otherwise you’re not going to return anything, which seems a little unreasonable and a little misleading.
In addition, in the case of many mesh in the scene, whether setting the second parameter to true will have some impact on the performance.
This behavior is actually noted in the documentation of both methods. Meaning the recursive parameter controls whether to check the descendants of the given object(s) or not.