83 lines
2.7 KiB
HTML
83 lines
2.7 KiB
HTML
|
|
<!DOCTYPE html>
|
||
|
|
<html lang="en">
|
||
|
|
<head>
|
||
|
|
<meta charset="utf-8">
|
||
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
|
||
|
|
<meta name="description" content="Clamp a model to a 3D Tileset using the clampToHeight function.">
|
||
|
|
<meta name="cesium-sandcastle-labels" content="Showcases, 3D Tiles">
|
||
|
|
<title>Cesium Demo</title>
|
||
|
|
<script type="text/javascript" src="../Sandcastle-header.js"></script>
|
||
|
|
<script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.20/require.js"></script>
|
||
|
|
<script type="text/javascript">
|
||
|
|
if(typeof require === 'function') {
|
||
|
|
require.config({
|
||
|
|
baseUrl : '../../../Source',
|
||
|
|
waitSeconds : 120
|
||
|
|
});
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
</head>
|
||
|
|
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html">
|
||
|
|
<style>
|
||
|
|
@import url(../templates/bucket.css);
|
||
|
|
</style>
|
||
|
|
<div id="cesiumContainer" class="fullSize"></div>
|
||
|
|
<div id="loadingOverlay"><h1>Loading...</h1></div>
|
||
|
|
<div id="toolbar"></div>
|
||
|
|
<script id="cesium_sandcastle_script">
|
||
|
|
function startup(Cesium) {
|
||
|
|
'use strict';
|
||
|
|
//Sandcastle_Begin
|
||
|
|
var viewer = new Cesium.Viewer('cesiumContainer', {
|
||
|
|
terrainProvider : Cesium.createWorldTerrain()
|
||
|
|
});
|
||
|
|
var scene = viewer.scene;
|
||
|
|
var clock = viewer.clock;
|
||
|
|
|
||
|
|
var entity;
|
||
|
|
var positionProperty;
|
||
|
|
var dataSourcePromise = Cesium.CzmlDataSource.load('../../SampleData/ClampToGround.czml');
|
||
|
|
viewer.dataSources.add(dataSourcePromise).then(function(dataSource) {
|
||
|
|
entity = dataSource.entities.getById('CesiumMilkTruck');
|
||
|
|
positionProperty = entity.position;
|
||
|
|
});
|
||
|
|
|
||
|
|
var tileset = scene.primitives.add(
|
||
|
|
new Cesium.Cesium3DTileset({
|
||
|
|
url: Cesium.IonResource.fromAssetId(6074)
|
||
|
|
})
|
||
|
|
);
|
||
|
|
|
||
|
|
viewer.camera.setView({
|
||
|
|
destination: new Cesium.Cartesian3(1216403.8845586285, -4736357.493351395, 4081299.715698949),
|
||
|
|
orientation: new Cesium.HeadingPitchRoll(4.2892217081808806, -0.4799070147502502, 6.279789177843313),
|
||
|
|
endTransform : Cesium.Matrix4.IDENTITY
|
||
|
|
});
|
||
|
|
|
||
|
|
if (scene.clampToHeightSupported) {
|
||
|
|
tileset.initialTilesLoaded.addEventListener(start);
|
||
|
|
} else {
|
||
|
|
console.log('This browser does not support clampToHeight.');
|
||
|
|
}
|
||
|
|
|
||
|
|
function start() {
|
||
|
|
clock.shouldAnimate = true;
|
||
|
|
var objectsToExclude = [entity];
|
||
|
|
scene.postRender.addEventListener(function() {
|
||
|
|
var position = positionProperty.getValue(clock.currentTime);
|
||
|
|
entity.position = scene.clampToHeight(position, objectsToExclude);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
//Sandcastle_End
|
||
|
|
Sandcastle.finishedLoading();
|
||
|
|
}
|
||
|
|
if (typeof Cesium !== 'undefined') {
|
||
|
|
startup(Cesium);
|
||
|
|
} else if (typeof require === 'function') {
|
||
|
|
require(['Cesium'], startup);
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
</body>
|
||
|
|
</html>
|