Cesium项目应用(1)-3dtiles单体化。附带源码下载

## 前言

Numbers have an important story to tell. They rely on you to give them a clear and convincing voice.只要你为数字提供清晰、服众的展现方式，数字可以告诉我们很重要的信息。
——Stephen Few（代表作：《Now You See It》）

1、分栋
2、分层
3、源码下载

## 实现思路

1、分栋

ldCollection.add(new Cesium.ClassificationPrimitive({
geometryInstances: new Cesium.GeometryInstance({
geometry: new Cesium.PolygonGeometry({
polygonHierarchy: new Cesium.PolygonHierarchy(
Cesium.Cartesian3.fromDegreesArray('坐标')
),
extrudedHeight: '高度'
}),
attributes: {
color: Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1, 1, 1, 1e-4)),
show: new Cesium.ShowGeometryInstanceAttribute(true)
},
id: '自定义id'
}),
classificationType: Cesium.ClassificationType.CESIUM_3D_TILE
}))

2、分层

// 加载楼层Primitive
var position = new Cesium.Cartesian3.fromDegrees(center[0], center[1], center[2]);
s = Cesium.Transforms.eastNorthUpToFixedFrame(position),
u = Cesium.Matrix4.fromRotationTranslation(rotation, new Cesium.Cartesian3(0, 0, 0));
Cesium.Matrix4.multiply(s, u, s);
geometryInstances: new Cesium.GeometryInstance({
geometry: Cesium.BoxGeometry.fromDimensions({
vertexFormat: Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
dimensions: new Cesium.Cartesian3(dimensions[0], dimensions[1], dimensions[2])
}),
modelMatrix: s,
attributes: {
color: Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1, 1, 1, 1e-4)),
show: new Cesium.ShowGeometryInstanceAttribute(true),
},
id: name
}),
classificationType: Cesium.ClassificationType.CESIUM_3D_TILE
}))
}

3、源码下载