Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tileset urls in Sandcastle #6218

Merged
merged 1 commit into from
Feb 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions Apps/Sandcastle/gallery/3D Tiles Adjust Height.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,29 @@
var toolbar = document.getElementById('toolbar');
Cesium.knockout.applyBindings(viewModel, toolbar);

var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url : '../../../Specs/Data/Cesium3DTiles/Tilesets/Tileset'
}));

tileset.readyPromise.then(function() {
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) {
throw(error);
console.log(error);
});

Cesium.knockout.getObservable(viewModel, 'height').subscribe(function(height) {
height = Number(height);
if (isNaN(height)) {
return;
}
function onLoad(tileset) {
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
210 changes: 106 additions & 104 deletions Apps/Sandcastle/gallery/3D Tiles Batch Table Hierarchy.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,123 +84,125 @@
var viewer = new Cesium.Viewer('cesiumContainer');
viewer.clock.currentTime = new Cesium.JulianDate(2457522.154792);

var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url : '../../../Specs/Data/Cesium3DTiles/Hierarchy/BatchTableHierarchy'
}));

viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0.0, -0.3, 0.0)).otherwise(function(error) {
throw(error);
});

var styles = [];
function addStyle(name, style) {
styles.push({
name : name,
style : style
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);
});
}

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')"]
]
}
});

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')"]
]
function onLoad(tileset) {
var styles = [];
function addStyle(name, style) {
styles.push({
name : name,
style : style
});
}
});

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')"]
]
}
});

function setStyle(style) {
return function() {
tileset.style = new Cesium.Cesium3DTileStyle(style);
};
}
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 styleOptions = [];
for (var i = 0; i < styles.length; ++i) {
var style = styles[i];
styleOptions.push({
text : style.name,
onselect : setStyle(style.style)
addStyle('Color all doors', {
"color" : {
"conditions" : [
["isExactClass('door')", "color('orange')"],
["true", "color('white')"]
]
}
});
}

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

var handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);
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')"]
]
}
});

// 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);
addStyle('Style by height', {
"color" : {
"conditions" : [
["${height} >= 10", "color('purple')"],
["${height} >= 6", "color('red')"],
["${height} >= 5", "color('orange')"],
["true", "color('blue')"]
]
}
});

function setStyle(style) {
return function() {
tileset.style = new Cesium.Cesium3DTileStyle(style);
};
}
}, 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;
var styleOptions = [];
for (var i = 0; i < styles.length; ++i) {
var style = styles[i];
styleOptions.push({
text : style.name,
onselect : setStyle(style.style)
});
}
feature.show = false;
}, Cesium.ScreenSpaceEventType.MIDDLE_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);
}
//Sandcastle_End
Sandcastle.finishedLoading();
}
Expand Down
6 changes: 4 additions & 2 deletions Apps/Sandcastle/gallery/3D Tiles Clipping Planes.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
// 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 = '../../../Specs/Data/Cesium3DTiles/Instanced/InstancedOrientation/';
var instancedUrl = Cesium.CesiumIon.createResource(3876, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' });
var modelUrl = '../../SampleData/models/CesiumAir/Cesium_Air.glb';

bimUrl.then(function(resource) {
Expand All @@ -233,7 +233,9 @@
tileset.clippingPlanes.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(tileset.boundingSphere.center);
});
} else if (newValue === clipObjects[2]) {
loadTileset(instancedUrl).then(function() {
instancedUrl.then(function(resource) {
return loadTileset(resource);
}).then(function() {
tileset.clippingPlanes.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(tileset.boundingSphere.center);
});
} else {
Expand Down
39 changes: 20 additions & 19 deletions Apps/Sandcastle/gallery/3D Tiles Formats.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,43 +45,43 @@
tilesets: [
{
name: 'Tileset',
url: '../../../Specs/Data/Cesium3DTiles/Tilesets/Tileset/'
resource: Cesium.CesiumIon.createResource(3883, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' })
}, {
name: 'Translucent',
url: '../../../Specs/Data/Cesium3DTiles/Batched/BatchedTranslucent/'
resource: Cesium.CesiumIon.createResource(3871, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' })
}, {
name: 'Translucent/Opaque',
url: '../../../Specs/Data/Cesium3DTiles/Batched/BatchedTranslucentOpaqueMix/'
resource: Cesium.CesiumIon.createResource(3872, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' })
}, {
name: 'Multi-color',
url: '../../../Specs/Data/Cesium3DTiles/Batched/BatchedColors/'
resource: Cesium.CesiumIon.createResource(3870, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' })
}, {
name: 'Request Volume',
url: '../../../Specs/Data/Cesium3DTiles/Tilesets/TilesetWithViewerRequestVolume/'
resource: Cesium.CesiumIon.createResource(3884, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' })
}, {
name: 'Batched',
url: '../../../Specs/Data/Cesium3DTiles/Batched/BatchedWithBatchTable/'
resource: Cesium.CesiumIon.createResource(3873, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' })
}, {
name: 'Instanced',
url: '../../../Specs/Data/Cesium3DTiles/Instanced/InstancedWithBatchTable/'
resource: Cesium.CesiumIon.createResource(3877, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' })
}, {
name: 'Instanced/Orientation',
url: '../../../Specs/Data/Cesium3DTiles/Instanced/InstancedOrientation/'
resource: Cesium.CesiumIon.createResource(3876, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' })
}, {
name: 'Composite',
url: '../../../Specs/Data/Cesium3DTiles/Composite/Composite/'
resource: Cesium.CesiumIon.createResource(3874, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' })
}, {
name: 'PointCloud',
url: '../../../Specs/Data/Cesium3DTiles/PointCloud/PointCloudRGB/'
resource: Cesium.CesiumIon.createResource(3881, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' })
}, {
name: 'PointCloudConstantColor',
url: '../../../Specs/Data/Cesium3DTiles/PointCloud/PointCloudConstantColor/'
resource: Cesium.CesiumIon.createResource(3879, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' })
}, {
name: 'PointCloudNormals',
url: '../../../Specs/Data/Cesium3DTiles/PointCloud/PointCloudQuantizedOctEncoded/'
resource: Cesium.CesiumIon.createResource(3880, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' })
}, {
name: 'PointCloudBatched',
url: '../../../Specs/Data/Cesium3DTiles/PointCloud/PointCloudBatched/'
resource: Cesium.CesiumIon.createResource(3878, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' })
}
],
selectedTileset: undefined,
Expand All @@ -105,13 +105,14 @@
inspectorViewModel.tileset = undefined;
return;
}
tileset = new Cesium.Cesium3DTileset({
url: options.url
});
inspectorViewModel.tileset = tileset;
scene.primitives.add(tileset);
tileset.readyPromise.then(function(tileset) {

options.resource.then(function(url) {
tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url : url
}));
return tileset.readyPromise;
}).then(function() {
inspectorViewModel.tileset = tileset;
viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0, -2.0, Math.max(100.0 - tileset.boundingSphere.radius, 0.0)));

var properties = tileset.properties;
Expand Down
Loading