# cesium-sensor material remains undefined

**URL:** <https://community.cesium.com/t/cesium-sensor-material-remains-undefined/4424>\
**Category:** CesiumJS\
**Created:** [July 26, 2016, 2:02pm UTC](https://community.cesium.com/t/cesium-sensor-material-remains-undefined/4424 "2016-07-26T14:02:46Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_D](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Jason\_D](https://community.cesium.com/u/Jason_D)\
**Post date:** [July 26, 2016, 2:02pm UTC](https://community.cesium.com/t/cesium-sensor-material-remains-undefined/4424/1 "2016-07-26T14:02:46Z")

</div>

I’m running the following script and get no errors but testCone.conicSensor.lateralSurfaceMaterial is undefined after the assignment. I’ve checked and coneSide is defined and I’ve tried assigning the material directly but it remains undefined. Anyone seen this before?

var testCone = viewer.entities.add({

name: ‘test cone’,

show: true,

position: Cesium.Cartesian3.multiplyByScalar(new Cesium.Cartesian3(0,0,1),6500000,new Cesium.Cartesian3())

});

testCone.addProperty(‘conicSensor’);

testCone.conicSensor = new CesiumSensors.ConicSensorGraphics();

testCone.conicSensor.intersectionColor = new Cesium.ConstantProperty(Cesium.Color.RED);

testCone.conicSensor.showIntersection = true;

testCone.conicSensor.radius = 1000000; //maximum cone projection distance in m

testCone.conicSensor.innerHalfAngle = Math.PI / 2;

var coneSide = Cesium.Material.fromType(‘Color’);

coneSide.uniforms.color = new Cesium.Color(0.0, 1.0, 1.0, 0.5);

testCone.conicSensor.lateralSurfaceMaterial = coneSide;

---

<div class="post-metadata">

**Author:** ![abdou](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/abdou/32/2012_2.png) [@abdou](https://community.cesium.com/u/abdou)\
**Post date:** [July 26, 2016, 6:06pm UTC](https://community.cesium.com/t/cesium-sensor-material-remains-undefined/4424/2 "2016-07-26T18:06:00Z")

</div>

Hello,  
do you use the sensor plugin or cesium pro?

---

<div class="post-metadata">

**Author:** ![Jason\_D](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Jason\_D](https://community.cesium.com/u/Jason_D)\
**Post date:** [July 26, 2016, 6:10pm UTC](https://community.cesium.com/t/cesium-sensor-material-remains-undefined/4424/3 "2016-07-26T18:10:53Z")

</div>

cesium plugin

---

<div class="post-metadata">

**Author:** ![Jason\_D](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Jason\_D](https://community.cesium.com/u/Jason_D)\
**Post date:** [July 26, 2016, 7:22pm UTC](https://community.cesium.com/t/cesium-sensor-material-remains-undefined/4424/4 "2016-07-26T19:22:01Z")

</div>

sorry, I meant sensor plugin

---

<div class="post-metadata">

**Author:** ![abdou](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/abdou/32/2012_2.png) [@abdou](https://community.cesium.com/u/abdou)\
**Post date:** [July 27, 2016, 3:42am UTC](https://community.cesium.com/t/cesium-sensor-material-remains-undefined/4424/5 "2016-07-27T03:42:30Z")

</div>

ok do you mean testCone.conicSensor.lateralSurfaceMaterial is undefined?  
This attribute is waiting a property data and not a material for me.

---

<div class="post-metadata">

**Author:** ![Jason\_D](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Jason\_D](https://community.cesium.com/u/Jason_D)\
**Post date:** [July 27, 2016, 2:47pm UTC](https://community.cesium.com/t/cesium-sensor-material-remains-undefined/4424/6 "2016-07-27T14:47:16Z")

</div>

> > sorry, I meant sensor plugin
> > 
> > > cesium plugin
> > > 
> > > > Hello,  
> > > > do you use the sensor plugin or cesium pro?
> > > > 
> > > > >

> > > > > var testCone = viewer.entities.add({

> > > > > name: ‘test cone’,

> > > > > show: true,

> > > > > position: Cesium.Cartesian3.multiplyByScalar(new Cesium.Cartesian3(0,0,1),6500000,new Cesium.Cartesian3())

> > > > > });

> > > > > testCone.addProperty(‘conicSensor’);

> > > > > testCone.conicSensor = new CesiumSensors.ConicSensorGraphics();

> > > > > testCone.conicSensor.intersectionColor = new Cesium.ConstantProperty(Cesium.Color.RED);

> > > > > testCone.conicSensor.showIntersection = true;

> > > > > testCone.conicSensor.radius = 1000000; //maximum cone projection distance in m

> > > > > testCone.conicSensor.innerHalfAngle = Math.PI / 2;

> > > > > var coneSide = Cesium.Material.fromType(‘Color’);

> > > > > coneSide.uniforms.color = new Cesium.Color(0.0, 1.0, 1.0, 0.5);

> > > > > testCone.conicSensor.lateralSurfaceMaterial = coneSide;

> > > > > I’m running the following script and get no errors but testCone.conicSensor.lateralSurfaceMaterial is undefined after the assignment. I’ve checked and coneSide is defined and I’ve tried assigning the material directly but it remains undefined. Anyone seen this before?

> ok do you mean testCone.conicSensor.lateralSurfaceMaterial is undefined?  
> This attribute is waiting a property data and not a material for me.

I don’t understand the distinction you’re making here. Is testCone.conicSensor.lateralSurfaceMaterial not a material? Can you give an example of how to assign a value to it?

---

<div class="post-metadata">

**Author:** ![Chris\_M](https://avatars.discourse-cdn.com/v4/letter/c/958977/32.png) [@Chris\_M](https://community.cesium.com/u/Chris_M)\
**Post date:** [July 27, 2016, 3:27pm UTC](https://community.cesium.com/t/cesium-sensor-material-remains-undefined/4424/7 "2016-07-27T15:27:39Z")

</div>

Hi Jason,

Check out this example [here](https://raw.githubusercontent.com/AnalyticalGraphicsInc/cesium-sensors/master/Examples/LotsOfSensors.czml). I’m not completely sure what value is being inserted programatically by your code, but maybe comparing the value of what coneSide is inserting to the hard-coded value in that example might help.

---

<div class="post-metadata">

**Author:** ![Jason\_D](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Jason\_D](https://community.cesium.com/u/Jason_D)\
**Post date:** [July 27, 2016, 3:37pm UTC](https://community.cesium.com/t/cesium-sensor-material-remains-undefined/4424/8 "2016-07-27T15:37:45Z")

</div>

The example go linked has

```auto
"lateralSurfaceMaterial":{
  "solidColor":{
    "color":{
      "rgba":[
        255,0,255,51
      ]
    }
  }
}

```

``

I thought that czml snippet is equivalent to

var coneSide = Cesium.Material.fromType(‘Color’);

coneSide.uniforms.color = new Cesium.Color(1.0, 0.0, 1.0, 0.5);

``

What am I missing here?

---

<div class="post-metadata">

**Author:** ![abdou](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/abdou/32/2012_2.png) [@abdou](https://community.cesium.com/u/abdou)\
**Post date:** [July 27, 2016, 9:36pm UTC](https://community.cesium.com/t/cesium-sensor-material-remains-undefined/4424/9 "2016-07-27T21:36:19Z")

</div>

check [https://github.com/kaktus40/cesium-sensors :](https://github.com/kaktus40/cesium-sensors)

```auto
entity.conicSensor = new CesiumSensorVolumes.ConicSensorGraphics();
entity.conicSensor.intersectionColor = new Cesium.ConstantProperty(new Cesium.Color(0.1, 0.2, 0.3, 0.4));
```

---

<div class="post-metadata">

**Author:** ![Jason\_D](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Jason\_D](https://community.cesium.com/u/Jason_D)\
**Post date:** [July 27, 2016, 10:52pm UTC](https://community.cesium.com/t/cesium-sensor-material-remains-undefined/4424/10 "2016-07-27T22:52:27Z")

</div>

Thanks that fixed that problem. But I’m still not seeing the sensor. No errors, everything seems to be assigned just fine. Here’s the snippet:  
var testCone = viewer.entities.add({

name: ‘test cone’,

show: true,

position: new Cesium.Cartesian3(4650397.56551457, -3390535.52275848, -4087729.48877329)

});

testCone.addProperty(‘conicSensor’);

testCone.conicSensor = new CesiumSensors.ConicSensorGraphics();

testCone.conicSensor.show = true;

testCone.conicSensor.intersectionColor = new Cesium.ConstantProperty(Cesium.Color.RED);

testCone.conicSensor.showIntersection = true;

testCone.conicSensor.radius = 10000000; //maximum cone projection distance in m

testCone.conicSensor.innerHalfAngle = Math.PI / 2;

testCone.conicSensor.maximumClockAngle = 2 \* Math.PI;

testCone.conicSensor.minimumClockAngle = 0;

var coneSide = Cesium.Material.fromType(‘Color’);

coneSide.uniforms.color = new Cesium.Color(255, 0, 0, 255);

testCone.conicSensor.lateralSurfaceMaterial = new Cesium.ConstantProperty(coneSide);

``

---

<div class="post-metadata">

**Author:** ![abdou](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/abdou/32/2012_2.png) [@abdou](https://community.cesium.com/u/abdou)\
**Post date:** [July 28, 2016, 3:50am UTC](https://community.cesium.com/t/cesium-sensor-material-remains-undefined/4424/11 "2016-07-28T03:50:42Z")

</div>

Did you test with lesser `innerHalfAngle and ``maximumClockAngle?`  
Int his sample, I used customSensor: [https://github.com/kaktus40/cesium-sensors/blob/master/examples/simple.html](https://github.com/kaktus40/cesium-sensors/blob/master/examples/simple.html)

---

<div class="post-metadata">

**Author:** ![Jason\_D](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Jason\_D](https://community.cesium.com/u/Jason_D)\
**Post date:** [July 28, 2016, 3:09pm UTC](https://community.cesium.com/t/cesium-sensor-material-remains-undefined/4424/12 "2016-07-28T15:09:25Z")

</div>

Yes, I’ve tried a variety of min and max clock angles, as well as orientations. No joy.

---

<div class="post-metadata">

**Author:** ![mattsmccartney](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@mattsmccartney](https://community.cesium.com/u/mattsmccartney)\
**Post date:** [October 10, 2017, 9:56pm UTC](https://community.cesium.com/t/cesium-sensor-material-remains-undefined/4424/13 "2017-10-10T21:56:31Z")

</div>

You need to specify an outerHalfAngle for the ConicSensorGraphics

testCone.conicSensor.outerHalfAngle = Math.PI / 2;

Also note that if no orientation property is applied to the entity, then the ConicSensorVisualizer.show flag will revert to false:

[https://github.com/jlouns/cesium-sensor-volumes/blob/master/lib/conic/conic-sensor-visualizer.js#L129](https://github.com/jlouns/cesium-sensor-volumes/blob/master/lib/conic/conic-sensor-visualizer.js#L129)

---

<div class="post-metadata">

**Author:** ![Jason\_D](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Jason\_D](https://community.cesium.com/u/Jason_D)\
**Post date:** [October 10, 2017, 10:13pm UTC](https://community.cesium.com/t/cesium-sensor-material-remains-undefined/4424/14 "2017-10-10T22:13:12Z")

</div>

Yep. I figured it out and forgot to come back to this thread. I was misunderstanding the terminology. For what I was trying to do, I needed to use the outerHalfAngle and set the innerHalfAngle to zero.
