Skip to content

Commit

Permalink
Merge pull request #6235 from AnalyticalGraphicsInc/CEsiUm-IOn
Browse files Browse the repository at this point in the history
Add default Cesium ion token
  • Loading branch information
lilleyse authored Feb 20, 2018
2 parents 11cf8f2 + e530ee1 commit fcba110
Show file tree
Hide file tree
Showing 23 changed files with 446 additions and 533 deletions.
40 changes: 19 additions & 21 deletions Apps/Sandcastle/gallery/3D Tiles Adjust Height.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,27 @@
var toolbar = document.getElementById('toolbar');
Cesium.knockout.applyBindings(viewModel, toolbar);

Cesium.CesiumIon.create3DTileset(3883, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' })
.then(function(tileset) {
viewer.scene.primitives.add(tileset);
viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0.0, -0.5, tileset.boundingSphere.radius * 2.0));
onLoad(tileset);
}).otherwise(function(error) {
console.log(error);
});
var tileset = new Cesium.Cesium3DTileset({ url: Cesium.CesiumIon.createResource(3883) });
tileset.readyPromise.then(function(tileset) {
viewer.scene.primitives.add(tileset);
viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0.0, -0.5, tileset.boundingSphere.radius * 2.0));
}).otherwise(function(error) {
console.log(error);
});

function onLoad(tileset) {
Cesium.knockout.getObservable(viewModel, 'height').subscribe(function(height) {
height = Number(height);
if (isNaN(height)) {
return;
}
Cesium.knockout.getObservable(viewModel, 'height').subscribe(function(height) {
height = Number(height);
if (isNaN(height)) {
return;
}

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, height);
var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
});

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, height);
var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
});
}
//Sandcastle_End
Sandcastle.finishedLoading();
}
Expand Down
15 changes: 8 additions & 7 deletions Apps/Sandcastle/gallery/3D Tiles BIM.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@
// Power Plant design model provided by Bentley Systems
var viewer = new Cesium.Viewer('cesiumContainer');

Cesium.CesiumIon.create3DTileset(1459, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzNjUyM2I5Yy01YmRhLTQ0MjktOGI0Zi02MDdmYzBjMmY0MjYiLCJpZCI6NDQsImFzc2V0cyI6WzE0NTldLCJpYXQiOjE0OTkyNjQ3ODF9.SW_rwY-ic0TwQBeiweXNqFyywoxnnUBtcVjeCmDGef4' })
.then(function(tileset) {
viewer.scene.primitives.add(tileset);
viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0.5, -0.2, tileset.boundingSphere.radius * 4.0));
}).otherwise(function(error) {
console.log(error);
});
var tileset = new Cesium.Cesium3DTileset({ url: Cesium.CesiumIon.createResource(3837) });

tileset.readyPromise.then(function(tileset) {
viewer.scene.primitives.add(tileset);
viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0.5, -0.2, tileset.boundingSphere.radius * 4.0));
}).otherwise(function(error) {
console.log(error);
});
//Sandcastle_End
Sandcastle.finishedLoading();
}
Expand Down
208 changes: 101 additions & 107 deletions Apps/Sandcastle/gallery/3D Tiles Batch Table Hierarchy.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,125 +84,119 @@
var viewer = new Cesium.Viewer('cesiumContainer');
viewer.clock.currentTime = new Cesium.JulianDate(2457522.154792);

Cesium.CesiumIon.create3DTileset(3875, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' })
.then(function(tileset) {
viewer.scene.primitives.add(tileset);
viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0.0, -0.3, 0.0));
onLoad(tileset);
}).otherwise(function(error) {
console.log(error);
});
var tileset = new Cesium.Cesium3DTileset({ url: Cesium.CesiumIon.createResource(3875) });

function onLoad(tileset) {
var styles = [];
function addStyle(name, style) {
styles.push({
name : name,
style : style
});
}
viewer.scene.primitives.add(tileset);
viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0.0, -0.3, 0.0));

addStyle('No style', {});

addStyle('Color by building', {
"color" : {
"conditions" : [
["${building_name} === 'building0'", "color('purple')"],
["${building_name} === 'building1'", "color('red')"],
["${building_name} === 'building2'", "color('orange')"],
["true", "color('blue')"]
]
}
var styles = [];
function addStyle(name, style) {
styles.push({
name : name,
style : style
});
}

addStyle('Color all doors', {
"color" : {
"conditions" : [
["isExactClass('door')", "color('orange')"],
["true", "color('white')"]
]
}
});
addStyle('No style', {});

addStyle('Color all features derived from door', {
"color" : {
"conditions" : [
["isClass('door')", "color('orange')"],
["true", "color('white')"]
]
}
});
addStyle('Color by building', {
"color" : {
"conditions" : [
["${building_name} === 'building0'", "color('purple')"],
["${building_name} === 'building1'", "color('red')"],
["${building_name} === 'building2'", "color('orange')"],
["true", "color('blue')"]
]
}
});

addStyle('Color all doors', {
"color" : {
"conditions" : [
["isExactClass('door')", "color('orange')"],
["true", "color('white')"]
]
}
});

addStyle('Color all features derived from door', {
"color" : {
"conditions" : [
["isClass('door')", "color('orange')"],
["true", "color('white')"]
]
}
});

addStyle('Color features by class name', {
"defines" : {
"suffix" : "regExp('door(.*)').exec(getExactClassName())"
},
"color" : {
"conditions" : [
["${suffix} === 'knob'", "color('yellow')"],
["${suffix} === ''", "color('lime')"],
["${suffix} === null", "color('gray')"],
["true", "color('blue')"]
]
}
});

addStyle('Style by height', {
"color" : {
"conditions" : [
["${height} >= 10", "color('purple')"],
["${height} >= 6", "color('red')"],
["${height} >= 5", "color('orange')"],
["true", "color('blue')"]
]
}
});

addStyle('Color features by class name', {
"defines" : {
"suffix" : "regExp('door(.*)').exec(getExactClassName())"
},
"color" : {
"conditions" : [
["${suffix} === 'knob'", "color('yellow')"],
["${suffix} === ''", "color('lime')"],
["${suffix} === null", "color('gray')"],
["true", "color('blue')"]
]
}
});
function setStyle(style) {
return function() {
tileset.style = new Cesium.Cesium3DTileStyle(style);
};
}

addStyle('Style by height', {
"color" : {
"conditions" : [
["${height} >= 10", "color('purple')"],
["${height} >= 6", "color('red')"],
["${height} >= 5", "color('orange')"],
["true", "color('blue')"]
]
}
var styleOptions = [];
for (var i = 0; i < styles.length; ++i) {
var style = styles[i];
styleOptions.push({
text : style.name,
onselect : setStyle(style.style)
});
}

function setStyle(style) {
return function() {
tileset.style = new Cesium.Cesium3DTileStyle(style);
};
}
Sandcastle.addToolbarMenu(styleOptions);

var styleOptions = [];
for (var i = 0; i < styles.length; ++i) {
var style = styles[i];
styleOptions.push({
text : style.name,
onselect : setStyle(style.style)
});
var handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);

// When a feature is left clicked, print its class name and properties
handler.setInputAction(function(movement) {
var feature = viewer.scene.pick(movement.position);
if (!Cesium.defined(feature)) {
return;
}
console.log('Class: ' + feature.getExactClassName());
console.log('Properties:');
var propertyNames = feature.getPropertyNames();
var length = propertyNames.length;
for (var i = 0; i < length; ++i) {
var name = propertyNames[i];
var value = feature.getProperty(name);
console.log(' ' + name + ': ' + value);
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);

Sandcastle.addToolbarMenu(styleOptions);

var handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);

// When a feature is left clicked, print its class name and properties
handler.setInputAction(function(movement) {
var feature = viewer.scene.pick(movement.position);
if (!Cesium.defined(feature)) {
return;
}
console.log('Class: ' + feature.getExactClassName());
console.log('Properties:');
var propertyNames = feature.getPropertyNames();
var length = propertyNames.length;
for (var i = 0; i < length; ++i) {
var name = propertyNames[i];
var value = feature.getProperty(name);
console.log(' ' + name + ': ' + value);
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);

// When a feature is middle clicked, hide it
handler.setInputAction(function(movement) {
var feature = viewer.scene.pick(movement.position);
if (!Cesium.defined(feature)) {
return;
}
feature.show = false;
}, Cesium.ScreenSpaceEventType.MIDDLE_CLICK);
}
// When a feature is middle clicked, hide it
handler.setInputAction(function(movement) {
var feature = viewer.scene.pick(movement.position);
if (!Cesium.defined(feature)) {
return;
}
feature.show = false;
}, Cesium.ScreenSpaceEventType.MIDDLE_CLICK);
//Sandcastle_End
Sandcastle.finishedLoading();
}
Expand Down
35 changes: 14 additions & 21 deletions Apps/Sandcastle/gallery/3D Tiles Clipping Planes.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,12 @@
}

// Power Plant design model provided by Bentley Systems
var bimUrl = Cesium.CesiumIon.createResource(1459, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzNjUyM2I5Yy01YmRhLTQ0MjktOGI0Zi02MDdmYzBjMmY0MjYiLCJpZCI6NDQsImFzc2V0cyI6WzE0NTldLCJpYXQiOjE0OTkyNjQ3ODF9.SW_rwY-ic0TwQBeiweXNqFyywoxnnUBtcVjeCmDGef4' });
var pointCloudUrl = Cesium.CesiumIon.createResource(1460, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyMzk2YzJiOS1jZGFmLTRlZmYtYmQ4MS00NTA3NjEwMzViZTkiLCJpZCI6NDQsImFzc2V0cyI6WzE0NjBdLCJpYXQiOjE0OTkyNjQ3NTV9.oWjvN52CRQ-dk3xtvD4e8ZnOHZhoWSpJLlw115mbQJM' });
var instancedUrl = Cesium.CesiumIon.createResource(3876, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' });
var bimUrl = Cesium.CesiumIon.createResource(3837);
var pointCloudUrl = Cesium.CesiumIon.createResource(3838);
var instancedUrl = Cesium.CesiumIon.createResource(3876);
var modelUrl = '../../SampleData/models/CesiumAir/Cesium_Air.glb';

bimUrl.then(function(resource) {
return loadTileset(resource);
});
loadTileset(bimUrl);

// Track and create the bindings for the view model
var toolbar = document.getElementById('toolbar');
Expand All @@ -222,25 +220,20 @@
Cesium.knockout.getObservable(viewModel, 'currentExampleType').subscribe(function(newValue) {
reset();

var tileset;
if (newValue === clipObjects[0]) {
bimUrl.then(function(resource) {
return loadTileset(resource);
});
return loadTileset(bimUrl);
} else if (newValue === clipObjects[1]) {
pointCloudUrl.then(function(resource) {
return loadTileset(resource);
}).then(function() {
tileset.clippingPlanes.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(tileset.boundingSphere.center);
});
tileset = loadTileset(pointCloudUrl);
tileset.clippingPlanes.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(tileset.boundingSphere.center);
return tileset;
} else if (newValue === clipObjects[2]) {
instancedUrl.then(function(resource) {
return loadTileset(resource);
}).then(function() {
tileset.clippingPlanes.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(tileset.boundingSphere.center);
});
} else {
loadModel(modelUrl);
tileset = loadTileset(instancedUrl);
tileset.clippingPlanes.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(tileset.boundingSphere.center);
return tileset;
}

loadModel(modelUrl);
});

Cesium.knockout.getObservable(viewModel, 'debugBoundingVolumesEnabled').subscribe(function(value) {
Expand Down
6 changes: 2 additions & 4 deletions Apps/Sandcastle/gallery/3D Tiles Feature Picking.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@
});

// Load the NYC buildings tileset
Cesium.CesiumIon.create3DTileset(1461, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkYWJmM2MzNS02OWM5LTQ3OWItYjEyYS0xZmNlODM5ZDNkMTYiLCJpZCI6NDQsImFzc2V0cyI6WzE0NjFdLCJpYXQiOjE0OTkyNjQ3NDN9.vuR75SqPDKcggvUrG_vpx0Av02jdiAxnnB1fNf-9f7s' })
.then(function(tileset) {
viewer.scene.primitives.add(tileset);
});
var tileset = new Cesium.Cesium3DTileset({ url: Cesium.CesiumIon.createResource(3839) });
viewer.scene.primitives.add(tileset);

// HTML overlay for showing feature name on mouseover
var nameOverlay = document.createElement('div');
Expand Down
8 changes: 1 addition & 7 deletions Apps/Sandcastle/gallery/3D Tiles Feature Styling.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
});

// Load the NYC buildings tileset.
Cesium.CesiumIon.create3DTileset(1461, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkYWJmM2MzNS02OWM5LTQ3OWItYjEyYS0xZmNlODM5ZDNkMTYiLCJpZCI6NDQsImFzc2V0cyI6WzE0NjFdLCJpYXQiOjE0OTkyNjQ3NDN9.vuR75SqPDKcggvUrG_vpx0Av02jdiAxnnB1fNf-9f7s' })
.then(function(tileset) {

var tileset = new Cesium.Cesium3DTileset({ url: Cesium.CesiumIon.createResource(3839) });
viewer.scene.primitives.add(tileset);

// Color buildings based on their height.
Expand Down Expand Up @@ -151,10 +149,6 @@
}]);

colorByHeight();
})
.otherwise(function(error) {
console.log(error);
});

//Sandcastle_End
Sandcastle.finishedLoading();
Expand Down
Loading

0 comments on commit fcba110

Please sign in to comment.