What’s wrong with my grammar? Why does the Earth not display properly and there are no error messages when using a uniform value. Here is my code:
const position_array = new Float64Array([-2703397.67177676, 5141216.455900496, 2625796.3218083465]);
const color_array = new Float32Array([1.0, 0.0, 0.0, 1.0]);
const indices = new Uint16Array([0]);
const attributes = new Cesium.GeometryAttributes();
attributes.position = new Cesium.GeometryAttribute({
componentDatatype: Cesium.ComponentDatatype.DOUBLE,
componentsPerAttribute: 3,
values: position_array
});
attributes.color = new Cesium.GeometryAttribute({
componentDatatype: Cesium.ComponentDatatype.FLOAT,
componentsPerAttribute: 4,
values: color_array
});
const geometry = new Cesium.Geometry({
attributes,
primitiveType: Cesium.PrimitiveType.POINTS,
indices,
boundingSphere: Cesium.BoundingSphere.fromVertices(position_array as any)
});
const appearance = new Cesium.Appearance({
translucent: false,
renderState: {
blending: Cesium.BlendingState.PRE_MULTIPLIED_ALPHA_BLEND,
depthTest: { enabled: true },
depthMask: true
},
material: new Cesium.Material({
fabric: {
type: "map1",
uniforms: {
size: 0.5
}
},
translucent: true,
}),
vertexShaderSource: `
in vec3 position3DHigh;
in vec3 position3DLow;
in float batchId;
in vec4 color;
out vec4 v_color;
uniform float size;
void main() {
v_color = color;
vec4 p = czm_computePosition();
p = czm_modelViewProjectionRelativeToEye * p;
gl_Position = p;
//If you access the size variable of the uniform here, it will not render properly
gl_PointSize = size * 2000.0 / p.z;
}
`,
fragmentShaderSource: `
in vec4 v_color;
void main() {
out_FragColor = vec4(1.0,0.0,0.0,1.0);
}
`
});
const primitive = new Cesium.Primitive({
geometryInstances: new Cesium.GeometryInstance({
geometry: geometry
}),
appearance: appearance,
asynchronous: false
});
this.scene?.primitives.add(primitive);