CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
12.74k stars 3.45k forks source link

Picking & GroundPrimitive in 2D model throw an error #11696

Open PhilippeSymbol opened 9 months ago

PhilippeSymbol commented 9 months ago

When using "non pickable" GroundPrimitive, picking throw an error in GroundPrimitive_updateAndQueuePickCommand command.owner = groundPrimitive; -> command is undefined

with allowPicking: true it doesn't throw

when replacing GroundPrimitive by Primitive, it doesn't throw with allowPicking: true or false, but the rendered frame is not equivalent, there are many artifact a height 0

ggetz commented 9 months ago

Thanks for the report @PhilippeSymbol. Would you be able to include a Sandcastle example that replicates the issue? That would help us give us more context to determine the issue. Thanks!

BloodlustLR commented 8 months ago

I have same problem and make the following sandcastle exmaple.In exmaple, when I move, console export erorr command.owner = groundPrimitive; -> command is undefined @ggetz

Sandcastle Example URL: https://sandcastle.cesium.com/#c=nVbbbts4EP0Vwi+VAIHRxZJvSbCG4zYB6jqw3WyBKAgYmbaJUqRAUc66i/z7ktQlUpL2Yf0icebM8MyZIeWEs1yCI8HPWIALwPAzmOGcFCm8MzYr7iVmPeNMIsKwiHv2JGYxS0zkExdbE/lvzACIe884l3FvDDzfg5E/8tUzCEee54+cEpDzQh40wu/DoTcajZQ/8N1Rf1gBGBevgChUkQM3DIduGEQVAqPWHgPfDUe+74XuIPBi9tLitkUSKWYxu9dxAFQPUAYGg8HQC8MgcL2o79Sud5v6pefB+ShHPwpCV0Ejv+93U7iRFw6HfuQNgyj8XylCk8BXT6VO9KcUv6+kP3AH/WA0CKLhoC4kZg9GI4olSJCQqruIBVelVvfat+PC0t6M50QSzgDfGS1t0+NuDMyK/GBVIzNrXHAneHqF9wLj3Krz3LsPTpP03nuw9SC91Fz2mKdYilN3Cm85Pe05+1I5LUMhK43XBAskksNp/EFE47S6hG0j0BEr2z+fuUiRBOMmFIsbNTiIJXjGKRfTLMNI6CW8m6828x+Pn5erxXSjWGvqmjWp8F3WNd06W0m7rnDcvBkuSEpBngrFcVyeIqWx3r2hZbi8TTmto4zUBmK18ca8QmzLU8u2ddoXTVurHbPyvMM8wQzDveAF294KkqrGHHEO0XZrtYvp+ru11HQU91oKUxRhEguK0RGPgRRFaUSU8udbkvwkbD8GO0Tzyt7o/K6TVF05C6RyEURf22FVOqWVpxNWw2uQ/u3QkyAJaAQuf/KUYWX7ZAT75LRdBSPqGKT52xDTGdBtDfz7+mYzh89EHqY0OyDLhaH9GvRSv1YvL2U3bN0OB7h2cxoFTpSAe6qHqcq/qk2dA1VeulDftU51A0NzrzYrfUU2C3Oj1gOLmSRSH7JqBsyaVF03pTY0mtIPmOwPcuw69XSqvIQhM7EN2mljV3iHBTYNrSq57trh7Ot0cfu4WT5+WS2/f7tqBnTSms9fnKcbbpWUbSgPmFmWDS4uS2JvKxA45Wo+K/ikBSkHPeXblrRrbVsoE1zP5t/m/tWk2V7rpFNdq+ND334X14nqAVtnKMHzo9qrAlmdrRLEjiivNc/UyKskls6ZqhD74rJSthOkYa+YSfkxa/GAOZY3LCvkNNE3qKXxzu9obdRsw8Xy+3r+uFjeze1Jz+md5/JE8WU9j3+RNFOjAQpBLQjPJE4zqpt69lQkP7GESZ6XKgJwftYOPd+SIyDbiw/+G4CEojxXnl1B6Zr8wnHv8vxM4d+FUo7UEO2X6iqm6KRhB+/ya2mEEJ6fqeXHkZJz+oTEm8z/AQ

Sandcastle Example Code: ` const viewer = new Cesium.Viewer("cesiumContainer");

const border = { "west": 121.62921213591129, "south": 24.81999135320948, "north": 24.865129705580536, "east": 121.67205922150731 };

const data = [ [ 121.63778155330164, 24.865129705580532 ], [ 121.6463509706242, 24.860615882618365 ], [ 121.6463509706242, 24.851588228512096 ], [ 121.63778155330164, 24.84707439736872 ] ];

let cartesian3Data = []; for(let position of data){ cartesian3Data.push(Cesium.Cartesian3.fromDegrees(position[0], position[1])); }

let geometry = new Cesium.PolygonGeometry({ polygonHierarchy: new Cesium.PolygonHierarchy(cartesian3Data), vertexFormat : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT }); let instance = new Cesium.GeometryInstance({ geometry: geometry, attributes: { color: Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.fromRandom()) } })

viewer.scene.groundPrimitives.add(new Cesium.GroundPrimitive({ geometryInstances: instance, interleave: true, allowPicking: false, appearance: new Cesium.PolylineMaterialAppearance({ material: new Cesium.Material({ fabric : { type : 'Color', uniforms : { color : Cesium.Color.WHITE.withAlpha(0.5) } } }) }) }), 0);

let rectangle = Cesium.Rectangle.fromDegrees(border.west, border.south, border.east, border.north); let entity = viewer.entities.add({ rectangle: { height:0, coordinates: rectangle, heightReference: Cesium.HeightReference.CLAMP_TO_GROUND } });

viewer.zoomTo(entity).then(() => { viewer.entities.remove(entity); viewer.scene.mode = Cesium.SceneMode.SCENE2D; });

let moveHandler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas); let pick = (movement)=>{ viewer.scene.pick(movement); }; moveHandler.setInputAction(pick, Cesium.ScreenSpaceEventType.MOUSE_MOVE); `

290975971-30e1b651-3e68-4022-af84-365b2d6899c1