I am using the sandcastle example for styling features in 3d tiles, however when i tried to use another property to style my dataset , i got no error and no styling either .
i was uysing the following code for styling :
tileset.style = new Cesium.Cesium3DTileStyle(
{
“color” : {
“expression” : “regExp(’^1(\d)’).exec(${id})”,
“conditions” : {
“${expression} === ‘1’” : “color(’#FF0000’)”,
“${expression} === ‘2’” : “color(’#00FF00’)”,
“true” : “color(’#FFFFFF’)”
}
}
}
);
when i use the proeprty id , everything works fine but when i try to use another property in my dataset b3dm file ,which was made and tested successfully , with another property called " specific space heating demand" ,i got no result .
noting that this field have decimal numbers , i mean it has values like 45,5 … 60,89 ,etc… does this make a problem ?
Hello,
This example takes a property, in this case "id", and performs a regular expression exec operation, specifically to match strings starting with 1 and to capture the second digit. If the data values in the property you are using does not match that pattern, the first two conditional cases will not happen, and only the "true" condition will be evaluated, and the tileset will be styled all white.
See the section in the 3DTiles Styling spec on Regular Expressions, (https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/Styling/README.md#regexp), for more information on using RegExp in styling, as well as the RegExp Documentation itself, (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp.)
i use this code to style the 3d objects dynamicaly. It works but after zoom out and zoom in the color is reset and the function is not call a second time. It doesn't metter if i put it into
`tileset.readyPromise.then(function(tileset) ` or leave it outside.
see here
http://my-sandbox.de/cesium/test.html
var style = new Cesium.Cesium3DTileStyle();
style.show = {
evaluate : function(feature) {
return true;
}
};
style.color = {
evaluateColor : function(feature, result) {
return Cesium.Color.fromBytes(255, 0, 0, 255, result);
}
};
tileset.style = style;
Are you using the latest version of the 3d-tiles branch? If so, I believe the problem is that we recently merged a pull request that changes the function definition for evaluateColor and evaluateShow: https://github.com/AnalyticalGraphicsInc/cesium/pull/4626.
Your sample code should be modified to look like:
var style = new Cesium.Cesium3DTileStyle();
style.show = {
evaluate : function(frameState, feature) {
return true;
}
};
style.color = {
evaluateColor : function(frameState, feature, result) {
return Cesium.Color.fromBytes(255, 0, 0, 255, result);
}
};
tileset.style = style;
``
Let me know how this goes.
no, its a older version.
with "evaluateColor : function(frameState, feature, result)"
result is undefined
Yeah my suggestion only applies to the newest version.
If you use the latest 3d-tiles branch with my changes above it seems to be working fine.
thanks,
yes, you are right, with the newest version it works