admin管理员组

文章数量:1295953

so i've made made an update on my GLB files
As you can see this is my chair in blender

And these are the child nodes that make up the figure of the chair

As you can see its only an one child node
But this happens, when i setup raycaster to select one object of my scene and paint it random colour

it doesnt paints the entire chair, it paints a part of the chair like if were more nodes to paint, i dont know
fun fact: in the past that was possible because the chair in blender was divided into various nodes, but i unified them, and overwrited the old .glb file. but it still happening like if it was reading an old .glb file. I restarted my project, and it doesnt worked


this is my raycaster code:

const raycaster = new three.Raycaster()

document.addEventListener('mousedown', onMouseDown)

function onMouseDown(event){
  const coords = new three.Vector2(
    (event.clientX / renderer.domElement.clientWidth) * 2 -1,
    -((event.clientY / renderer.domElement.clientHeight) * 2 -1)
  )

  raycaster.setFromCamera(coords, camera)

  const intersects = raycaster.intersectObjects(scene.children, true)
  if(intersects.length > 0){
    const selectedObject = intersects[0].object
    
    const color = new three.Color(Math.random(), Math.random(), Math.random())
    selectedObject.material.color = color
   
    console.log(`${selectedObject.name}`)
  }
}

本文标签: javascriptThreeJS Raycaster selecting oldwrong nodesStack Overflow