OK. It sounds like you are trying to modify the CesiumViewer application directly, which is an AMD application. In that case, yes, you’ll need to include the AMD modules for the sensors plugin, modify CesiumViewerStartup.js to add the proper RequireJS configuration to locate the sensor modules, then modify CesiumViewer.js to require in the modules for the sensors that you’d like to use. The sensors plugin also includes an initialize
module, which is a function that hooks up CZML processing for sensors in CZML, which you can use if you’re using sensor definitions in CZML.
I tried it out locally and here’s the changes I made. If you want, you can organize things differently, and update the paths accordingly.
-
copy the contents of the Source folder from the sensors plugin into the Cesium directory Apps/CesiumViewer/Sensors
-
copy the RequireJS text plugin from the sensors plugin (in the ThirdParty/requirejs-2.1.14 directory) into the Cesium directory Apps/CesiumViewer
3a) Modify the config in CesiumViewerStartup to configure the location of those items.
3b) Because the sensors plugin expects the Cesium modules to be available under a Cesium package prefix, we also need to add mappings so it can find them there. This could be improved in the future by making CesiumViewer use the Cesium prefix on the modules by default. Conceptually, CesiumViewer is an application that builds on top of Cesium, so it really shouldn’t use the Cesium Source directory as its baseUrl.
The result config object I ended up with is:
{
baseUrl : ‘…/…/Source’,
paths : {
CesiumViewer : ‘…/Apps/CesiumViewer’,
domReady : ‘…/ThirdParty/requirejs-2.1.9/domReady’,
text : ‘…/Apps/CesiumViewer/text’,
CesiumSensors : ‘…/Apps/CesiumViewer/Sensors’
},
map : {
‘*’ : {
‘Cesium/Core’ : ‘Core’,
‘Cesium/DataSources’ : ‘DataSources’,
‘Cesium/Renderer’ : ‘Renderer’,
‘Cesium/Scene’ : ‘Scene’
}
}
}
- Modify CesiumViewer.js to include the feature(s) from the plugin that you’d like to use. In my case, I added
‘CesiumSensors/initialize’,
to the list of module IDs, and then added a parameter
cesiumSensorsInitialize
to the corresponding location in the parameter list.
Then, inside the function, I can call the initialize function, which installs support for the sensor-related CZML properties.
cesiumSensorsInitialize();
In your case, if you want to use one of the primitive types directly, for example, RectangularPyramidSensorVolume, you could include that module the same way, and then construct an instance and add it to the scene’s primitives as normal.