Hi!
I've loaded a couple of models into my scene and want to apply a color highlight upon mouse hovering a picking and a silhouette when picked. When selecting a model that was already selected at some point I get hit with
DeveloperError: This object was destroyed, i.e., destroy() was called.
Error
at new DeveloperError (webpack-internal:///./node_modules/cesium/Source/Core/DeveloperError.js:43:19)
at ShaderProgram.throwOnDestroyed (webpack-internal:///./node_modules/cesium/Source/Core/destroyObject.js:45:19)
at beginDraw (webpack-internal:///./node_modules/cesium/Source/Renderer/Context.js:967:23)
at Context.draw (webpack-internal:///./node_modules/cesium/Source/Renderer/Context.js:1033:9)
at DrawCommand.execute (webpack-internal:///./node_modules/cesium/Source/Renderer/DrawCommand.js:523:17)
at executeCommand (webpack-internal:///./node_modules/cesium/Source/Scene/Scene.js:2093:21)
at executeCommands (webpack-internal:///./node_modules/cesium/Source/Scene/Scene.js:2442:17)
at executeCommandsInViewport (webpack-internal:///./node_modules/cesium/Source/Scene/Scene.js:2853:9)
at updateAndExecuteCommands (webpack-internal:///./node_modules/cesium/Source/Scene/Scene.js:2701:13)
at render (webpack-internal:///./node_modules/cesium/Source/Scene/Scene.js:3265:9)
I load my models...
const origin = Cesium.Cartesian3.fromDegrees(lon, lat, 0.0);
const modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(origin);
const model = Cesium.Model.fromGltf({
scene,
url,
modelMatrix,
maximumScale: 1,
minimumPixelSize: 128,
id: unit.unit_uuid,
scale: 1,
incrementallyLoadTextures: false,
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
colorBlendAmount: 1.0,
colorBlendMode: Cesium.ColorBlendMode.HIGHLIGHT,
silhouetteSize: 0.0,
silhouetteColor: Cesium.Color.fromAlpha(Cesium.Color.GREENYELLOW, 1.0)
});
I am attaching a fairly simple handler...
viewer.screenSpaceEventHandler.setInputAction((movement) => {
const pickedFeature = viewer.scene.pick(movement.endPosition);
unitSelection.hover(pickedFeature);
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
viewer.screenSpaceEventHandler.setInputAction((movement) => {
const pickedFeature = viewer.scene.pick(movement.position);
if (Cesium.defined(pickedFeature)) unitSelection.select(pickedFeature);
else {
unitSelection.deselect();
clickHandler(movement);
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
and my style application looks like so...
applyHoverStyle(target) {
target.primitive.color = Cesium.Color.fromAlpha(Cesium.Color.WHITE, 1.0);
target.primitive.colorBlendAmount = 0.6;
target.primitive.colorBlendMode = Cesium.ColorBlendMode.MIX;
},
applySelectStyle(target) {
target.primitive.silhouetteSize = 2.0;
target.primitive.color = Cesium.Color.fromAlpha(Cesium.Color.GREENYELLOW, 1.0);
},
resetStyle(target) {
target.primitive.colorBlendAmount = 1.0;
target.primitive.colorBlendMode = Cesium.ColorBlendMode.HIGHLIGHT;
target.primitive.silhouetteSize = 0.0;
target.primitive.color = Cesium.Color.fromAlpha(Cesium.Color.WHITE, 1.0);
}
Cesium: 1.47
Browser: Chrome 69.0.3497.81 and Firefox 62.0 (64-bit)
OS: Ubunt 18.04
Thanks a lot for the help!
You guys are doing an amazing job.