1. A concise explanation of the problem you're experiencing.
I want to add water material to 3dtiles,But it's not feasibl
2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
<script>
var worldTerrain = Cesium.createWorldTerrain({
requestWaterMask: true,
requestVertexNormals: true
});
var viewer = new Cesium.Viewer('cesiumContainer', {
terrainProvider: worldTerrain
});
var tileset = new Cesium.Cesium3DTileset({
// url: ‘../../cesiumLab3dtiles/tileset.json’
url: ‘http://localhost:8030/jinjiangData_3dtiles/tileset.json’
});
var rectangle;
tileset.readyPromise.then(function (tileset) {
viewer.scene.primitives.add(tileset);
var cartographic = Cesium.Cartographic.fromCartesian(tileset.boundingSphere.center);
var surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0);
var offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 2.0);
var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
viewer.zoomTo(tileset);
}).otherwise(function(error) {
console.log(error);
});
function createPrimitives(scene) {
rectangle = scene.primitives.add(new Cesium.GroundPrimitive({
geometryInstances : new Cesium.GeometryInstance({
geometry : new Cesium.PolygonGeometry({
polygonHierarchy : new Cesium.PolygonHierarchy(
Cesium.Cartesian3.fromDegreesArray( [112.16245241220456,22.26306407983288,112.16471144587265,22.26259584538233,112.16488040107146,22.26228180104898,112.16531192642532,22.26178655362098,112.16544305720755,22.262004561143097,112.16603461588957,22.26178718090819,112.1658874569952,22.26116962178944,112.16533945017264,22.26087417748411,112.16459935219373,22.26045067488058,112.16495228305284,22.2593670578392,112.16523853725937,22.258686629225963,112.1653752618481,22.25823538504829,112.16548886914792,22.25752735407626,112.16546121933982,22.256823942104013,112.16505423738998,22.256778880111597,112.16417391635653,22.247614376360875,112.16320701238239,22.246638177345762,112.16199919280076,22.245053935888226,112.16137620080613,22.24473864515594,112.1613019420769,22.243944197129153,112.16101776254885,22.243892101295508,112.16084462629308,22.243916071451103,112.16059341739938,22.243475029948865,112.16067364765551,22.24289679840787,112.16054491403355,22.2429510632919,112.15811464977565,22.24298244587892,112.15786729312002,22.24383679772685,112.1568784598097,22.243773277785877,112.1566834626063,22.244713117225032,112.155808823767,22.244762083245078,112.15586425189474,22.247551963170142,112.15389234965383,22.247539862570665,112.15376227800613,22.248530331906483,112.1527889697874,22.248504624994368,112.15282033195271,22.248573577120187,112.15268069785994,22.249511927660606,112.15210652740747,22.24987051996244,112.15190549594676,22.25295003520852,112.14757789914799,22.259234514524877,112.14268914304724,22.26158624919961,112.14261437418023,22.262897175306257,112.14341389120706,22.262980705405145,112.14441209969013,22.263089370414963,112.14456889198357,22.263907089781025,112.14632580645994,22.26377400428064,112.14769406779865,22.264659145302275,112.14981696909862,22.264604608772288,112.1495338397549,22.265618359592615,112.15119898151433,22.265573388663167,112.15108535107538,22.266652734866,112.1511315179183,22.266810737987683,112.15313976934056,22.266857680838562,112.15320521963447,22.2675975522776,112.15334554226354,22.267850672101144,112.15521364029752,22.267696045873688,112.16156586042219,22.261730762857038,112.1625290416967,22.263010804888378])
),
vertexFormat : Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT
})
}),
appearance : new Cesium.EllipsoidSurfaceAppearance({
aboveGround : false
}),
classificationType : Cesium.ClassificationType.CESIUM_3D_TILE
}));
}
function applyWaterMaterial(primitive, scene) {
primitive.appearance.material = new Cesium.Material({
fabric : {
type : 'Water',
uniforms : {
normalMap: './WaterMaterialHelper/waterNormals.jpg',
frequency: 10000.0,
animationSpeed: 0.01,
amplitude: 1.0
}
}
});
}
var scene = viewer.scene;
createPrimitives(scene);
applyWaterMaterial(rectangle, scene);
</script>
Hint error : All GeometryInstances must have the same color attribute except via GroundPrimitives
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
I want to add water material to the 3dtiles model to simulate a surface effect.
4. The Cesium version you're using, your operating system and browser.
webkit 63.0