diff --git a/Apps/Sandcastle/gallery/3D Tiles Adjust Height.html b/Apps/Sandcastle/gallery/3D Tiles Adjust Height.html index 638d3a2a1cb0..28a36616ad54 100644 --- a/Apps/Sandcastle/gallery/3D Tiles Adjust Height.html +++ b/Apps/Sandcastle/gallery/3D Tiles Adjust Height.html @@ -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(); } diff --git a/Apps/Sandcastle/gallery/3D Tiles Batch Table Hierarchy.html b/Apps/Sandcastle/gallery/3D Tiles Batch Table Hierarchy.html index b6da5ad00b42..6f15bb508a21 100644 --- a/Apps/Sandcastle/gallery/3D Tiles Batch Table Hierarchy.html +++ b/Apps/Sandcastle/gallery/3D Tiles Batch Table Hierarchy.html @@ -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(); } diff --git a/Apps/Sandcastle/gallery/3D Tiles Clipping Planes.html b/Apps/Sandcastle/gallery/3D Tiles Clipping Planes.html index ce2f11921b42..30aaa548cac1 100644 --- a/Apps/Sandcastle/gallery/3D Tiles Clipping Planes.html +++ b/Apps/Sandcastle/gallery/3D Tiles Clipping Planes.html @@ -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) { @@ -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 { diff --git a/Apps/Sandcastle/gallery/3D Tiles Formats.html b/Apps/Sandcastle/gallery/3D Tiles Formats.html index f06f30585063..fb9e1979dd11 100644 --- a/Apps/Sandcastle/gallery/3D Tiles Formats.html +++ b/Apps/Sandcastle/gallery/3D Tiles Formats.html @@ -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, @@ -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; diff --git a/Apps/Sandcastle/gallery/3D Tiles Point Cloud Styling.html b/Apps/Sandcastle/gallery/3D Tiles Point Cloud Styling.html index ec9dce57a5cd..3c5e80b14148 100644 --- a/Apps/Sandcastle/gallery/3D Tiles Point Cloud Styling.html +++ b/Apps/Sandcastle/gallery/3D Tiles Point Cloud Styling.html @@ -33,186 +33,185 @@ viewer.clock.currentTime = new Cesium.JulianDate(2457522.154792); -var scene = viewer.scene; -var tileset = scene.primitives.add(new Cesium.Cesium3DTileset({ - url : '../../../Specs/Data/Cesium3DTiles/PointCloud/PointCloudWithPerPointProperties/' -})); - -tileset.readyPromise.then(function() { - viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0.0, -1.0, 50.0)); -}).otherwise(function(error) { - throw(error); -}); - -var styles = []; -function addStyle(name, style) { - style.pointSize = Cesium.defaultValue(style.pointSize, 5.0); - styles.push({ - name : name, - style : style +Cesium.CesiumIon.create3DTileset(3882, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' }) + .then(function(tileset) { + viewer.scene.primitives.add(tileset); + viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0.0, -1.0, 50.0)); + onLoad(tileset); + }).otherwise(function(error) { + console.log(error); }); -} -addStyle('No Style', {}); - -addStyle('Red', { - color : "color('#ff0000')" -}); - -addStyle('Color Gradient', { - color : "color() * ${temperature}" -}); - -addStyle('Step Red/Blue', { - color : "${temperature} > 0.5 ? color('red') : color('blue')" -}); - -addStyle('Interpolate Red/Blue', { - color : "color('red') * ${temperature} + color('blue') * (1.0 - ${temperature})" -}); - -addStyle('Color Ramp', { - color : { - conditions : [ - ["${temperature} < 0.1", "color('#000099')"], - ["${temperature} < 0.2", "color('#00cc99', 1.0)"], - ["${temperature} < 0.3", "color('#66ff33', 0.5)"], - ["${temperature} < 0.4", "rgba(255, 255, 0, 0.1)"], - ["${temperature} < 0.5", "rgb(255, 128, 0)"], - ["${temperature} < 0.6", "color('red')"], - ["${temperature} < 0.7", "color('rgb(255, 102, 102)')"], - ["${temperature} < 0.8", "hsl(0.875, 1.0, 0.6)"], - ["${temperature} < 0.9", "hsla(0.83, 1.0, 0.5, 0.1)"], - ["true", "color('#FFFFFF', 1.0)"] - ] - } -}); - -addStyle('Transparency', { - color : "rgba(0, 255, 0, ${temperature})" -}); - -addStyle('Hide Low Temperature', { - color : "rgb(${temperature}*255, 0, 0)", - show : "${temperature} > 0.3" -}); - -addStyle('Show Subsections', { - show : "${id} === 1 || ${id} > 250 && ${id} < 300" -}); - -addStyle('Mod', { - show : "${id} % 2 === 0" -}); - -addStyle('Abs', { - color : "color() * abs(${temperature} - 0.5)" -}); - -addStyle('Trigonometric Functions', { - color : "color() * radians(cos(${temperature})) + color() * sin(${temperature}) + color() * tan(${temperature})" - -}); - -addStyle('Arc Trigonometric Functions', { - color : "color() * acos(degrees(${temperature})) + color() * asin(${temperature}) + color() * atan(${temperature}) + color() * atan2(${POSITION}[0],${temperature})" -}); - -addStyle('Sqrt', { - color : "color() * sqrt(${temperature})" -}); - -addStyle('Sign', { - color : "rgb(sign(${POSITION}[0]) * 255, sign(${POSITION}[1]) * 255, sign(${POSITION}[2]) * 255)" -}); - -addStyle('Rounding Functions', { - color : "rgb(floor(${POSITION}[0]) * 255, ceil(${POSITION}[1]) * 255, round(${POSITION}[2]) * 255)" -}); - -addStyle('Exp and Log Functions', { - color : "rgb(log(${POSITION}[0]) * 255, log2(${POSITION}[1]) * 255 + exp2(${POSITION}[1]) * 255, exp(${POSITION}[2]) * 255)" -}); - -addStyle('Fractional Part', { - color : "rgb(fract(${POSITION}[0]) * 255, fract(${POSITION}[1]) * 255, fract(${POSITION}[2]) * 255)" -}); - -addStyle('Pow', { - color : "color() * pow(${temperature}, 3)" -}); - -addStyle('Min and Max', { - color : "rgb(min(${POSITION}.x, 0.75) * 255, max(${POSITION}.z, 0.25) * 255, 255)" -}); - -addStyle('Clamp and Mix', { - color : "color() * clamp(${temperature}, 0.1, 0.2)" -}); - -addStyle('Secondary Color', { - color : { - conditions : [ - ["${id} < 250", "vec4(${secondaryColor}, 1.0)"], - ["${id} < 500", "vec4(${secondaryColor} * ${secondaryColor}, 1.0)"], - ["${id} < 750", "vec4(${secondaryColor} / 5.0, 1.0)"], - ["${id} < 1000", "rgb(0, 0, Number(${secondaryColor}.x < 0.5) * 255)"] - ] +function onLoad(tileset) { + var styles = []; + function addStyle(name, style) { + style.pointSize = Cesium.defaultValue(style.pointSize, 5.0); + styles.push({ + name : name, + style : style + }); } -}); - -addStyle('Use point colors', { - color : "${COLOR} * ${temperature} + rgb(128,128,128)" -}); - -addStyle('Use point positions', { - show : "${POSITION}[0] > 0.5 || ${POSITION}[1] > 0.5 || ${POSITION}[2] > 0.5" -}); - -// POSITION contains 0 as its last component, so add 1.0 to make the point cloud opaque -addStyle('Color based on position', { - color : "vec4(${POSITION}, 1.0)" -}); - -addStyle('Style point size', { - color : "color('red')", - pointSize : "${temperature} * 10" -}); - -addStyle('Multiple defines', { - defines : { - length : "length(${POSITION})", - time : "${tiles3d_tileset_time} * 3.0" - }, - color : { - conditions : [ - ["${length} < 0.5", "${length} * color('red')"], - ["${length} < 1.0", "vec4(vec3(${temperature} * fract(${time})), 1.0)"], - ["true", "${COLOR}"] - ] - }, - pointSize : "5.0 - ${length} * 2.0", - show : "${length} < 2.0" -}); - -function setStyle(style) { - return function() { - tileset.style = new Cesium.Cesium3DTileStyle(style); - }; -} -var styleOptions = []; -for (var i = 0; i < styles.length; ++i) { - var style = styles[i]; - styleOptions.push({ - text : style.name, - onselect : setStyle(style.style) + addStyle('No Style', {}); + + addStyle('Red', { + color : "color('#ff0000')" + }); + + addStyle('Color Gradient', { + color : "color() * ${temperature}" + }); + + addStyle('Step Red/Blue', { + color : "${temperature} > 0.5 ? color('red') : color('blue')" + }); + + addStyle('Interpolate Red/Blue', { + color : "color('red') * ${temperature} + color('blue') * (1.0 - ${temperature})" + }); + + addStyle('Color Ramp', { + color : { + conditions : [ + ["${temperature} < 0.1", "color('#000099')"], + ["${temperature} < 0.2", "color('#00cc99', 1.0)"], + ["${temperature} < 0.3", "color('#66ff33', 0.5)"], + ["${temperature} < 0.4", "rgba(255, 255, 0, 0.1)"], + ["${temperature} < 0.5", "rgb(255, 128, 0)"], + ["${temperature} < 0.6", "color('red')"], + ["${temperature} < 0.7", "color('rgb(255, 102, 102)')"], + ["${temperature} < 0.8", "hsl(0.875, 1.0, 0.6)"], + ["${temperature} < 0.9", "hsla(0.83, 1.0, 0.5, 0.1)"], + ["true", "color('#FFFFFF', 1.0)"] + ] + } + }); + + addStyle('Transparency', { + color : "rgba(0, 255, 0, ${temperature})" + }); + + addStyle('Hide Low Temperature', { + color : "rgb(${temperature}*255, 0, 0)", + show : "${temperature} > 0.3" + }); + + addStyle('Show Subsections', { + show : "${id} === 1 || ${id} > 250 && ${id} < 300" + }); + + addStyle('Mod', { + show : "${id} % 2 === 0" + }); + + addStyle('Abs', { + color : "color() * abs(${temperature} - 0.5)" + }); + + addStyle('Trigonometric Functions', { + color : "color() * radians(cos(${temperature})) + color() * sin(${temperature}) + color() * tan(${temperature})" + + }); + + addStyle('Arc Trigonometric Functions', { + color : "color() * acos(degrees(${temperature})) + color() * asin(${temperature}) + color() * atan(${temperature}) + color() * atan2(${POSITION}[0],${temperature})" + }); + + addStyle('Sqrt', { + color : "color() * sqrt(${temperature})" }); -} -Sandcastle.addToolbarMenu(styleOptions); + addStyle('Sign', { + color : "rgb(sign(${POSITION}[0]) * 255, sign(${POSITION}[1]) * 255, sign(${POSITION}[2]) * 255)" + }); + + addStyle('Rounding Functions', { + color : "rgb(floor(${POSITION}[0]) * 255, ceil(${POSITION}[1]) * 255, round(${POSITION}[2]) * 255)" + }); + + addStyle('Exp and Log Functions', { + color : "rgb(log(${POSITION}[0]) * 255, log2(${POSITION}[1]) * 255 + exp2(${POSITION}[1]) * 255, exp(${POSITION}[2]) * 255)" + }); + + addStyle('Fractional Part', { + color : "rgb(fract(${POSITION}[0]) * 255, fract(${POSITION}[1]) * 255, fract(${POSITION}[2]) * 255)" + }); + + addStyle('Pow', { + color : "color() * pow(${temperature}, 3)" + }); + + addStyle('Min and Max', { + color : "rgb(min(${POSITION}.x, 0.75) * 255, max(${POSITION}.z, 0.25) * 255, 255)" + }); + + addStyle('Clamp and Mix', { + color : "color() * clamp(${temperature}, 0.1, 0.2)" + }); + + addStyle('Secondary Color', { + color : { + conditions : [ + ["${id} < 250", "vec4(${secondaryColor}, 1.0)"], + ["${id} < 500", "vec4(${secondaryColor} * ${secondaryColor}, 1.0)"], + ["${id} < 750", "vec4(${secondaryColor} / 5.0, 1.0)"], + ["${id} < 1000", "rgb(0, 0, Number(${secondaryColor}.x < 0.5) * 255)"] + ] + } + }); -/////////////////////////////////////////////////////////////////////////////// + addStyle('Use point colors', { + color : "${COLOR} * ${temperature} + rgb(128,128,128)" + }); + + addStyle('Use point positions', { + show : "${POSITION}[0] > 0.5 || ${POSITION}[1] > 0.5 || ${POSITION}[2] > 0.5" + }); + + // POSITION contains 0 as its last component, so add 1.0 to make the point cloud opaque + addStyle('Color based on position', { + color : "vec4(${POSITION}, 1.0)" + }); + + addStyle('Style point size', { + color : "color('red')", + pointSize : "${temperature} * 10" + }); + + addStyle('Multiple defines', { + defines : { + length : "length(${POSITION})", + time : "${tiles3d_tileset_time} * 3.0" + }, + color : { + conditions : [ + ["${length} < 0.5", "${length} * color('red')"], + ["${length} < 1.0", "vec4(vec3(${temperature} * fract(${time})), 1.0)"], + ["true", "${COLOR}"] + ] + }, + pointSize : "5.0 - ${length} * 2.0", + show : "${length} < 2.0" + }); + + function setStyle(style) { + return function() { + tileset.style = new Cesium.Cesium3DTileStyle(style); + }; + } + + var styleOptions = []; + for (var i = 0; i < styles.length; ++i) { + var style = styles[i]; + styleOptions.push({ + text : style.name, + onselect : setStyle(style.style) + }); + } + + Sandcastle.addToolbarMenu(styleOptions); + tileset.style = new Cesium.Cesium3DTileStyle(styles[0].style); +} //Sandcastle_End Sandcastle.finishedLoading(); diff --git a/Apps/Sandcastle/gallery/development/Shadows.html b/Apps/Sandcastle/gallery/development/Shadows.html index 51e07209b3c7..31377d24672d 100644 --- a/Apps/Sandcastle/gallery/development/Shadows.html +++ b/Apps/Sandcastle/gallery/development/Shadows.html @@ -306,7 +306,7 @@ '3D Tiles' : { 'centerLongitude' : -1.31968, 'centerLatitude' : 0.698874, - 'tileset' : '../../../Specs/Data/Cesium3DTiles/Tilesets/Tileset' + 'tileset' : Cesium.CesiumIon.createResource(3883, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' }) } } }; @@ -593,10 +593,15 @@ } } -function createTileset(url) { - scene.primitives.add(new Cesium.Cesium3DTileset({ - url : url - })); +function createTileset(resource) { + resource.then(function(url) { + viewer.scene.primitives.add(new Cesium.Cesium3DTileset({ + url : url + })); + }) + .otherwise(function(error) { + console.log(error); + }); } function createModel(url, origin) {