0

I have an array with multiple mesh objects in an array called objMesh. within each attribute I have a children. And within each I have an array with more objects mesh. (These are countries and attribute the islands are children of the same country) .how I can do that by passing the mouse pointer over each figure I choose to mesh with their children ?.

Currently I have a code that allows you to mark the region to bypass the mouse pointer, but only a region of paints me my figure, I need to paint all partners. I put this line in the array with my subject that has all the mesh.

ray.intersectObjects intersects = var (objMesh);

In summary. I need you to move the mouse pointer over the parent mesh is selected as the mesh children who are in the children attribute.

WestLangley
  • 102,557
  • 10
  • 276
  • 276
  • Sorry, I am having a difficult time understanding your English... Every child object should have a property called `parent`. So if you mouse over a child, you can easily access the child's parent. – WestLangley Aug 17 '15 at 06:41
  • @WestLangley I hope to make you understand. I have a mesh and into the mesh in the children property, an array with more mesh. i need....I pass the mouse pointer in the parent mesh and mesh also the children are selected. –  Aug 17 '15 at 06:51
  • @WestLangley can you give a example of these? –  Aug 17 '15 at 06:51
  • You use `Raycaster` to select objects in three.js. Do you know how to use `Raycaster` to select an object and change the object's color? – WestLangley Aug 17 '15 at 06:56
  • @WestLangley Yes, I was the next part of changing the color. But I want to do the entire mesh, including the mesh that are in the "children" property var = new THREE.Raycaster ray (camera.position, vector.sub (camera.position) .normalize ()); ray.intersectObjects intersects = var (meshObj); –  Aug 17 '15 at 07:00
  • @WestLangley I take this opportunity to ask you, as I can change the "amount" property after the extrusion being created? –  Aug 17 '15 at 07:01
  • [Here](http://threejs.org/examples/webgl_interactive_cubes.html) is how to use Raycaster. Once you change the color of a mesh, it is easy to change the color of the mesh's children, too. – WestLangley Aug 17 '15 at 07:25
  • Or look here http://stackoverflow.com/questions/26371847/three-js-raycaster-intersection/26380737#26380737 – gevaraweb Aug 17 '15 at 08:14
  • @WestLangley Thanks, I looked both codes but do not understand how to do what I need. if I put var intersects = raycaster.intersectObjects (scene.children);It followed by selecting a single part of my figure. I need to figure and also the mesh that are associated with it is selected. –  Aug 17 '15 at 15:12
  • Try `intersects = raycaster.intersectObjects( scene.children, true );` – WestLangley Aug 17 '15 at 15:14
  • as usual, the part where the mouse pointer is above is selected. And the fund also selected lines. You select all that the mouse touches. i need something like this ray.intersectObjects intersects = var (objMesh.children); –  Aug 17 '15 at 15:40
  • @WestLangley or what is the best you can do for what I need? –  Aug 17 '15 at 16:55
  • Show a simple jsfiddle with 2 countries (each wiith child islands) to demonstrate your problem. – WestLangley Aug 17 '15 at 17:27
  • @WestLangley I am too complicated I upload my project. I have database data with the coordinates. But the question is simple. How I can make the MouseHover show me all stakeholders in a country with islands ?. each island keep within the "children" property. passing the mouse pointer over each part of this country, just select one, which corresponds to the principal, not to the islands that are in the children property. I do understand? –  Aug 17 '15 at 18:02
  • @WestLangley I'm trying with this: (objMesh-> master piece, objChildren -> piece of island) objMesh.add (objChildren); and I put var intersects = ray.intersectObjects (objMesh); but only recognizes the objMesh and not the islands (objChildren) –  Aug 17 '15 at 18:15
  • @WestLangley I need to do is select all that the mesh is associated –  Aug 17 '15 at 18:32

1 Answers1

0

I think you can use this:

var raycaster = new THREE.Raycaster(camera.position, vector.sub(camera.position).normalize());
    var intersects = raycaster.intersectObjects(meshObj.children, true);
if (intersects.length > 0) {
..
}

inside the if condition you can use your code.

disciple
  • 252
  • 1
  • 3
  • 13