I want to wait textrue requests completion,then set primitive.show = true
function createPriv(geoDatas,info) {
let texture = ‘http://xxxxxxxxxxxxxxx/xx.jpg’
let mat = new Cesium.Material({
fabric: {
type : 'Image',
uniforms: {
image: texture,
},
},
})
result.positions = geoDatas.positions
result.uvs = geoDatas.uvs
result.indexes = geoDatas.indexes
var geometry = new Cesium.Geometry({
attributes: {
position: new Cesium.GeometryAttribute({
componentDatatype: Cesium.ComponentDatatype.DOUBLE,
componentsPerAttribute: 3,
values: result.positions,
}),
st: new Cesium.GeometryAttribute({
componentDatatype: Cesium.ComponentDatatype.FLOAT,
componentsPerAttribute: 2,
values: result.uvs,
}),
},
indices: result.indexes,
primitiveType: Cesium.PrimitiveType.TRIANGLES,
boundingSphere: Cesium.BoundingSphere.fromVertices(result.positions),
});
var c = Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.BLUE);
var myInstance = new Cesium.GeometryInstance({
geometry: geometry,
attributes: {
color: c,
},
// show: new Cesium.ShowGeometryInstanceAttribute(true),
});
var priv = new Cesium.Primitive({
shadows: Cesium.ShadowMode.ENABLED,
geometryInstances: [myInstance],
asynchronous: false,
allowPicking:false,
interleave:true,
compressVertices:true,
appearance: new Cesium.MaterialAppearance({
closed: false,
translucent: true,
material: mat,
vertexShaderSource: `
attribute vec3 position3DHigh;
attribute vec3 position3DLow;
attribute vec4 color;
varying vec4 v_color;
attribute float batchId;
attribute vec2 st;
varying vec2 v_st;
void main()
{
v_st = st;
vec4 p = czm_computePosition();
v_color =color;
p = czm_modelViewProjectionRelativeToEye * p;
gl_Position = p;
}
`,
fragmentShaderSource: `
varying vec4 v_color;
varying vec2 v_st;
uniform sampler2D depthTexture;
float almostIdentity( float x, float m, float n )
{
if( x>m ) return x;
float a = 2.0*n - m;
float b = 2.0*m - 3.0*n;
float t = x/m;
return (a*t + b)*t*t + n;
}
void main()
{
if(!gl_FrontFacing){
discard;
}
vec4 c = texture2D(image_0,v_st);
gl_FragColor = c;
}
`,
})
});
…
}