似乎发现了一个 cesium 1.73 的bug,
官方样例中的《Plane.html》 对比其他例子,如《Polygon》,《Polyline Volume》等,有个特殊之处,就是当选中一个平面后,
右上角回弹出信息展示框,点击摄像头图标,相机视角会锁定到选中平面,这时按住鼠标左键,拖动鼠标,视角会以选中平面为中心进行旋转,这种相机交互比较舒服;其他例子中就不是这样的,选中物体后,按住鼠标左键进行拖到,视角仍然以地球中心来旋转。
《Polyline Volume》中的var redTube = viewer.entities.add({ … 放到《Plane.html》中,可以看到点击小摄像机图标后的行为是跟选中对象的类型绑定的,分别选中平面 和 3d管道,出现了小摄像机图标,点击它,会发现不同的逻辑。
另一个尝试,可能是cesium自带的bug,把《Plane.html》中的任意一个平面,添加到《Polyline Volume》中,
var redPlane = viewer.entities.add({
name: "Red plane with black outline",
position: Cesium.Cartesian3.fromDegrees(-107.0, 40.0, 300000.0),
plane: {
plane: new Cesium.Plane(Cesium.Cartesian3.UNIT_Y, 0.0),
dimensions: new Cesium.Cartesian2(400000.0, 300000.0),
material: Cesium.Color.RED.withAlpha(0.5),
outline: true,
outlineColor: Cesium.Color.BLACK,
},
});
把上面代码插入到 Polyling Volume.html 的39行,
var viewer = new Cesium.Viewer("cesiumContainer");
下面,然后在webstorm打开Polyling Volume.html , 运行后报错:
An error occurred while rendering. Rendering has stopped.
DataCloneError: Failed to execute 'postMessage' on 'Worker': ArrayBuffer at index 0 is already detached.
Error: Failed to execute 'postMessage' on 'Worker': ArrayBuffer at index 0 is already detached.
at http://localhost:63342/cesium/Source/Core/TaskProcessor.js:264:23
at Promise.then (http://localhost:63342/cesium/Source/ThirdParty/when.js:194:34)
at http://localhost:63342/cesium/Source/ThirdParty/when.js:295:13
at processQueue (http://localhost:63342/cesium/Source/ThirdParty/when.js:645:4)
at _resolve (http://localhost:63342/cesium/Source/ThirdParty/when.js:331:4)
at Object.promiseResolve [as resolve] (http://localhost:63342/cesium/Source/ThirdParty/when.js:357:11)
at Worker.worker.onmessage (http://localhost:63342/cesium/Source/Core/TaskProcessor.js:47:16)
有两种解决方法,一个是把插入代码,插入到
var greenBox = viewer.entities.add({...});
的后面;
另一种是注释掉插入代码中的
outline: true,
outlineColor: Cesium.Color.BLACK,
{“pos_size”:[[32.414,-6.458,23.988,44.522],[-8.458,-22.912,23.988,48.708],[-24.912,-48.388,23.988,35.8],[12.606,-37.394,6.988,21.988],[-24.912,-48.31,37.8,63.546]]}