# Adressing "isSelected" in gltf-object after Raycasting

**URL:** <https://discourse.threejs.org/t/adressing-isselected-in-gltf-object-after-raycasting/49555>\
**Category:** Questions\
**Tags:** gltf-loader, raycaster, gltf, geometry\
**Created:** [March 24, 2023, 3:52pm UTC](https://discourse.threejs.org/t/adressing-isselected-in-gltf-object-after-raycasting/49555 "2023-03-24T15:52:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Laulau](https://avatars.discourse-cdn.com/v4/letter/l/bbe5ce/32.png) [@Laulau](https://discourse.threejs.org/u/Laulau)\
**Post date:** [March 24, 2023, 3:52pm UTC](https://discourse.threejs.org/t/adressing-isselected-in-gltf-object-after-raycasting/49555/1 "2023-03-24T15:52:14Z")

</div>

Hello

I’m using a raycaster on GLTF-objects.

I had a working project where I used a few standard geometries that could be selected by double clicking:

```javascript
const object1 = new THREE.Mesh(
    new THREE.BoxGeometry(1.01, 1.01, 1.01),
    new THREE.MeshStandardMaterial({color: colorBase})
)
object1.isSelected = false

const object2 = new THREE.Mesh(
    new THREE.SphereGeometry(0.65, 16, 64),
    new THREE.MeshStandardMaterial({color: colorBase})
)
object2.isSelected = false

```

Whenever there was interaction with one of the objects through a raycaster, I could easily adress my custom added “isSelected”-property as shown here:

```javascript
 window.addEventListener("dblclick", (event) =>
 {
     if(currentIntersect && currentIntersect.object.isSelected === false){
         currentIntersect.object.material.color.set(colorSelected)
         currentIntersect.object.isSelected = true
     }
     else if(currentIntersect && currentIntersect.object.isSelected === true){
         currentIntersect.object.material.color.set(colorBase)
         currentIntersect.object.isSelected = false
     }
 })

```

I try to use the same method with a GLTF-object. First I add the same “isSelected”-property:

```javascript
loader.load(
    "model.gltf",
    function(gltf){
        model = gltf.scene
        model.isSelected = false
        scene.add(model)    
        }
)

```

which shows up when I do a `console.log(model)`

> Group  
> animations: (0)  
> castShadow: false  
> children: [Object3D] (1)  
> frustumCulled: true  
> id: 25  
> **isSelected: false**

But this doesn’t seem to work the same way as with simple geometries.  
When passed to the `eventListener`, `object.isSelected` cannot be found and returns as `undefined`.

What I figured out so far, is that a GLTF-object is a group of Object3D’s and Meshes, whereas a simple native geometry only seems to be a mesh that remembers previously added properties.  
Does a raycaster “transform” whatever he intersects with into new meshes? If so, how can I add properties to this object?

Thanks!

---

<div class="post-metadata">

**Author:** ![Lawrence3DPK](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/lawrence3dpk/32/29184_2.png) [@Lawrence3DPK](https://discourse.threejs.org/u/Lawrence3DPK)\
**Post date:** [March 24, 2023, 3:59pm UTC](https://discourse.threejs.org/t/adressing-isselected-in-gltf-object-after-raycasting/49555/2 "2023-03-24T15:59:41Z")

</div>

You seem to be assigning isSelected to the gltf.scene, which contains the mesh you are raycasting against, you either need to assign isSelected to the mesh inside your gltf scene in your load function or check intersects[0].object.parent (gltf.scene) for isSelected…
