Problem adding 3d tile building

1. A concise explanation of the problem you’re experiencing.

Hı all ,

I described the function of adding a radio buton 3d tile building. I want the color of the building to change with another button. But compared with some problems.

the color change function does not work if you do as in the first code.

firts code ==>

var scene = viewer.scene;

function Lod1Add(ar){

     if (ar === 'a') {  

                        var lod1 = new Cesium.Cesium3DTileset({
                        url : '03_data/lod1',
                        skipLevelOfDetail : true,
                        maximumScreenSpaceError : 24

                    });

                    var myPrimitive = lod1;  

     scene.primitives.add(myPrimitive);
                   }
                     else if(ar === 'r'){

     scene.primitives.removeAll();
                   }

}

function Color(){

var colorAdd= new Cesium.Cesium3DTileStyle({
color : “rgb(255,0,218)” ,
show : true
});
scene.primitives.add(myPrimitive).style = colorAdd;
}

``

in the second code ; buildings are displayed only once . It does not come up when I try to add buildings for the second time.

Second Code ==>

var scene = viewer.scene;

var lod1 = new Cesium.Cesium3DTileset({
url : ‘03_data/lod1’,
skipLevelOfDetail : true,
maximumScreenSpaceError : 24
});

var myPrimitive = lod1;

function Lod1Add(ar){

     if (ar === 'a') {  
     scene.primitives.add(myPrimitive);
                   }
                     else if(ar === 'r'){

     scene.primitives.removeAll();
                   }

}

function Color(){

var colorAdd= new Cesium.Cesium3DTileStyle({
color : “rgb(255,0,218)” ,
show : true
});
scene.primitives.add(myPrimitive).style = colorAdd;
}

``

How can I add or remove buildings to change their colors.?

Thank you.

4. The Cesium version you’re using, your operating system and browser.

Cesium 1.39

is there anyone who can help?

Does the Color function need to add the tileset again? It seems like it would work if you set myPrimitive’s style directly, like myPrimitive.style = colorAdd;

Hopefully I’ve understood the problem correctly, let me know if I’m missing something.

Sean ,

I could not produce a solution .

the color function tileset must not be added again.

I can change colors but I can add buildings only once.

I am sending sample HTML file for review.

thank you Sean

22 Aralık 2017 Cuma 04:21:33 UTC+3 tarihinde Sean Lilley yazdı:

cesium.rar (1.35 KB)

Thanks for sending the full code.

The problem is that when scene.primitives.removeAll() is called myPrimitive is destroyed, so trying to add it back later will not work. In a debug build of Cesium this would throw a Developer Error.

To fix this you have a few options:

When the “Add Lod1” button is clicked you will need to create a new Cesium3DTileset. Or…

Use the Cesium3DTile’s “show” property instead of removing the tileset and re-adding the tileset.

Correction: use Cesium3DTileset’s “show” property.

Yes , everything is OK .

Thank you very much Sean :slight_smile:

24 Aralık 2017 Pazar 21:10:09 UTC+3 tarihinde Sean Lilley yazdı: