Hi,
The following code, that draws a label “12345”, works just fine in Sandcastle:
const viewer = new Cesium.Viewer("cesiumContainer");
const label = viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(91.155017, 29.660053), // your lon, lat
label: {
text: '1234',
font: '20px sans-serif',
showBackground: true,
backgroundColor: new Cesium.Color(0.0, 0.0, 1.0, 0.8), // blue with alpha
pixelOffset: new Cesium.Cartesian2(0, -20),
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
verticalOrigin: Cesium.VerticalOrigin.CENTER,
style: Cesium.LabelStyle.FILL,
fillColor: Cesium.Color.WHITE,
scale: 1.0
}
})
viewer.zoomTo(label)
But I get the following error in dev console when I run it in local env with latest version 1.131.1 of Cesium, latest Chrome, Version 138.0.7204.49, and Node 23.8.0:
WebGL: INVALID_VALUE: uniform3fv: no array
I need a simple, lightweight way of drawing a text label without having to use a canvas image, billboard etc.
Google AI-enabled search has this to say, but I’m not sure if I can fully trust it, nor what to do even if I choose to. Why, e.g., it’d work in Sandcastle but not locally?
"The “WebGL: INVALID_VALUE: uniform3fv: no array” error in Cesium typically indicates an issue with how data is being passed to a shader. The
uniform3fv
function in WebGL expects an array of a specific length (a multiple of 3 if the uniform is an array ofvec3
s). This means that the data you’re providing to the shader, which is likely related to the label’s rendering, isn’t in the expected format.“While the code you provided for creating the label itself appears correct based on Cesium documentation, the error suggests that the issue might stem from the underlying rendering process or some external factor influencing the rendering of the label, rather than directly from your label creation code itself.”