Cesium开发⼊门——Demo04:加载3DTiles并添加⿏标事件属性【实现效果】
点击,对象轮廓变为绿⾊;
transcendental
【代码】
<!DOCTYPE html>
<html lang="en">
<head>
<meta chart="utf-8">
<title>Creating Entities</title>
<script src="/releas/1.57/Build/Cesium/Cesium.js"></script>
<link href="/releas/1.57/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
</head>
<body>
<div id="cesiumContainer" ></div>
<script>
// A simple demo of 3D Tiles feature picking with hover and lect behavior
// Building data courtesy of NYC OpenData portal: v/site/doitt/initiatives/3d-building.page
var viewer = new Cesium.Viewer('cesiumContainer', {
怎样学英语
incorrectterrainProvider: ateWorldTerrain()
});
});
viewer.scene.globe.depthTestAgainstTerrain = true;
// Set the initial camera view to look at Manhattan
var initialPosition = Cesium.Cartesian3.fromDegrees(-74.01881302800248, 40.69114333714821, 753);
var initialOrientation = new Cesium.HeadingPitchRoll.fromDegrees(21.27879878293835, -21.34390550872461, 0.0716951918898415); viewer.scene.camera.tView({
考研考场destination: initialPosition,
orientation: initialOrientation,
endTransform: Cesium.Matrix4.IDENTITY
});
// Load the NYC buildings tilet
var tilet = new Cesium.Cesium3DTilet({currentratio
url: Cesium.IonResource.fromAstId(5741)
});
viewer.scene.primitives.add(tilet);
// HTML overlay for showing feature name on mouover
var nameOverlay = ateElement('div');
nameOverlay.className = 'backdrop';
nameOverlay.style.display = 'none';
nameOverlay.style.position = 'absolute';
nameOverlay.style.bottom = '0';
nameOverlay.style.left = '0';
nameOverlay.style['pointer-events'] = 'none';
nameOverlay.style.padding = '4px';
nameOverlay.style.backgroundColor = 'black';
// Information about the currently lected feature
var lected = {
白酒英语feature: undefined,
originalColor: new Cesium.Color()
};
// An entity object which will hold info about the currently lected feature for infobox display
var lectedEntity = new Cesium.Entity();
// Get default left click handler for when a feature is not picked on left click
var clickHandler = InputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
// If silhouettes are not supported, change the feature color to yellow on mou over and green on mou click.
if(Cesium.PostProcessStageLibrary.isSilhouetteSupported(viewer.scene)) {
// Silhouettes are supported
var silhouetteBlue = ateEdgeDetectionStage();
lor = Cesium.Color.BLUE;
silhouetteBlue.uniforms.length = 0.01;
silhouetteBlue.lected = [];
var silhouetteGreen = ateEdgeDetectionStage();
lor = Cesium.Color.LIME;
silhouetteGreen.uniforms.length = 0.01;
silhouetteGreen.lected = [];
viewer.scene.postProcessStages.add(ateSilhouetteStage([silhouetteBlue, silhouetteGreen]));
// Silhouette a feature blue on hover.
viewer.screenSpaceEventHandler.tInputAction(function onMouMove(movement) {
// If a feature was previously highlighted, undo the highlight
silhouetteBlue.lected = [];
// Pick a new feature
var pickedFeature = viewer.scene.dPosition);
if(!Cesium.defined(pickedFeature)) {
if(!Cesium.defined(pickedFeature)) {
nameOverlay.style.display = 'none';
return;
}
// Highlight the feature if it's not already lected.
if(pickedFeature !== lected.feature) {
silhouetteBlue.lected = [pickedFeature];
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
// Silhouette a feature on lection and show metadata in the InfoBox.
viewer.screenSpaceEventHandler.tInputAction(function onLeftClick(movement) {
// If a feature was previously lected, undo the highlight
silhouetteGreen.lected = [];
// Pick a new feature
var pickedFeature = viewer.scene.pick(movement.position);
if(!Cesium.defined(pickedFeature)) {
成都
clickHandler(movement);
return;
}
// Select the feature if it's not already lected
if(silhouetteGreen.lected[0] === pickedFeature) {
return;
}
// Save the lected feature's original color
var highlightedFeature = silhouetteBlue.lected[0];
if(pickedFeature === highlightedFeature) {
silhouetteBlue.lected = [];
}
// Highlight newly lected feature
silhouetteGreen.lected = [pickedFeature];
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
} el {
// Silhouettes are not supported. Instead, change the feature color.四六级成绩查询入口
// Information about the currently highlighted feature
var highlighted = {
feature: undefined,
originalColor: new Cesium.Color()
};
/
/ Color a feature yellow on hover.
viewer.screenSpaceEventHandler.tInputAction(function onMouMove(movement) { // If a feature was previously highlighted, undo the highlight
if(Cesium.defined(highlighted.feature)) {
lor = iginalColor;
highlighted.feature = undefined;
}
// Pick a new feature
var pickedFeature = viewer.scene.dPosition);blazed
if(!Cesium.defined(pickedFeature)) {
nameOverlay.style.display = 'none';
return;
xcel}
// A feature was picked, so show it's overlay content
nameOverlay.style.display = 'block';
nameOverlay.style.bottom = viewer.canvas.clientHeight - dPosition.y + 'px'; nameOverlay.style.left = dPosition.x + 'px';
var name = Property('name');
var name = Property('name');
if(!Cesium.defined(name)) {
name = Property('id');
}
// Highlight the feature if it's not already lected.
if(pickedFeature !== lected.feature) {
highlighted.feature = pickedFeature;
Cesium.Color.lor, iginalColor); lor = Cesium.Color.YELLOW;
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
}
</script>
</body>
</html>