How to hide a single geometry instance?

Hi all,

I need to hide a single geometry instance after batching. Please see the code example below. Is it possible to do this? Thanks in advance.

var instances = ;

for(i=0; i<10000; i++){

var instance = new GeometryInstance({

geometry: new RectangleGeometry({

rectangle: new Rectangle(

CesiumMath.toRadians(west),

CesiumMath.toRadians(south),

CesiumMath.toRadians(east),

CesiumMath.toRadians(north)

)

}),

attributes:{

color: ColorGeometryInstanceAttribute.fromColor(extentColor)

},

id: i

});

instances.push(instance);

}

var primitive = new Primitive({

geometryInstances: instances,

appearance: new PerInstanceColorAppearance(),

releaseGeometryInstances: false,

asynchronous: false

});

viewer.scene.primitives.add(primitive);

primitive.geometryInstances[0].show = false; //After batching, since I set releaseGeometryInstances to be false, I can do primitive.geometryInstances[0]. However, GeometryInstance doesn’t have a show property. How do I show or hide a single geometry instance?

Hi all,

I’ve found the solution. Solution is posted below just to help the folks who have similar problem.

var instances = ;

for(i=0; i<10000; i++){

var instance = new GeometryInstance({

geometry: new RectangleGeometry({

rectangle: new Rectangle(

CesiumMath.toRadians(west),

CesiumMath.toRadians(south),

CesiumMath.toRadians(east),

CesiumMath.toRadians(north)

)

}),

attributes:{

color: ColorGeometryInstanceAttribute.fromColor(extentColor)

show: new ShowGeometryInstanceAttribute(true) //This line is important. If you skip this line, then later you can set this property to false.

},

id: i

});

instances.push(instance);

}

var primitive = new Primitive({

geometryInstances: instances,

appearance: new PerInstanceColorAppearance(),

releaseGeometryInstances: false,

asynchronous: false

});

viewer.scene.primitives.add(primitive);

//Now hide only one geometry instance from 10000 geometry instances batched into primitive.

var id = instances[0].id;

var attributes = primitive.getGeometryInstanceAttributes(id);

attributes.show = ShowGeometryInstanceAttribute.toValue(false);

在 2014年11月17日星期一UTC-8下午1时12分31秒,Steven写道: