-
Notifications
You must be signed in to change notification settings - Fork 105
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
Nyc app #2
Conversation
Hey @hpinkos, would you mind taking a look at this for cleanliness and content? There's a lot that can definitely be improved! Thanks! |
README.md
Outdated
A simple JavaScript app showcasing some features of [Cesium](http://cesium.agi.com/), the open-source WebGL virtual globe and map engine. Just fork this repo and start coding. | ||
|
||
**Cesium version**: [1.34](http://cesiumjs.org/downloads.html). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be Cesium 1.35? Or probably Cesium 1.36 because the conference is in August?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! Should be 1.36
README.md
Outdated
This uses the unminified version of Cesium.js, which is great for debugging but is quite large for production deployments. To use the minified version, run `ant` with `minify` instead of `combine` before updating `cesium-starter-app`: | ||
``` | ||
./Tools/apache-ant-1.8.2/bin/ant clean minify |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use ant
anymore. Where did you get this from? It needs to be updated to use gulp
Source/App.js
Outdated
////////////////////////////////////////////////////////////////////////// | ||
|
||
var viewer = new Cesium.Viewer('cesiumContainer', { | ||
navigationHelpButton: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't disable this. No one knows how to use our mouse controls the first time they bring up Cesium
Source/App.js
Outdated
// Loading Imagery | ||
////////////////////////////////////////////////////////////////////////// | ||
|
||
Cesium.BingMapsApi.defaultKey = 'AsarFiDvISunWhi137V7l5Bu80baB73npU98oTyjqKOb7NbrkiuBPZfDxgXTrGtQ'; // For use on cesiumjs.org only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to use this in a public app. Should we need to use a different imagery provider?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I sort of put this in as a placeholder because I wasn't sure -- what's the correct thing to do re Bing key for this application? Should we request a new one just for this repo? @hpinkos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mramato what do you think?
Source/App.js
Outdated
// Add Bing imagery | ||
viewer.imageryLayers.addImageryProvider(new Cesium.BingMapsImageryProvider({ | ||
url : 'https://dev.virtualearth.net', | ||
mapStyle: Cesium.BingMapsStyle.AERIAL // Can also use Cesium.BingMapsStyle.ROADS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally like AERIAL_WITH_LABELS
. The satellite imagery is nice, and adding the labels makes it more accessible
Source/App.js
Outdated
// Add to the neighborhoods group | ||
entity.parent = neighborhoods; | ||
// Generate Polygon center | ||
var poly_center = Cesium.BoundingSphere.fromPoints(entity.polygon.hierarchy.getValue().positions).center; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you need to pass a JulianDate
with the current time to getValue
?
Source/App.js
Outdated
poly_center = Cesium.Ellipsoid.WGS84.scaleToGeodeticSurface(poly_center); | ||
entity.position = poly_center; | ||
// Generate labels | ||
entity.label = new Cesium.LabelGraphics({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just set label equal to the in the object instead of explicitly creating a new LabelGraphics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing! But just for my own edification, what's the difference there? Aren't you creating a new object anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it really makes a difference, no. That's just what we do in all our other sandcastle examples.
Source/App.js
Outdated
}); | ||
|
||
// Interpolate smoothly between position sample points. | ||
drone.position.setInterpolationOptions({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be in the computeCircularFlight
function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
computeCircularFlight is a placeholder until I've created a CZML file to read drone positions from.
pickedEntity.billboard.color = Cesium.Color.ORANGERED; | ||
previousPickedEntity = pickedEntity; | ||
} | ||
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to do LEFT_CLICK
than MOUSE_MOVE
. I think doing things on MOUSE_MOVE
can get annoying
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sort of like the on hover behavior, and it matches the original nyc-demo app. I'll let a couple of people try it and I'll go with whatever the majority opinion is.
Source/App.js
Outdated
var scratch = new Cesium.Matrix4(); | ||
var camera = viewer.scene.camera; | ||
function followDrone() { | ||
drone._getModelMatrix(viewer.clock.currentTime, scratch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't teach users to access private functions and variables. Is there another way to do this? If not, maybe we should add one to Cesium
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! I've done that in #5584. I'll switch it out as soon as its merged.
Make sure we properly credit the data sources in your presentation where necessary |
README.md
Outdated
* `node server.js` | ||
|
||
Browse to `http://localhost:8000/` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The server.js included in this repo runs at 8080
by default
Source/App.js
Outdated
if(droneModeElement.checked) { | ||
viewer.scene.preRender.addEventListener(followDrone); | ||
} else { | ||
viewer.scene.preRender.removeEventListener(followDrone); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to reset the lookAt transform after we stop following the drone
Source/App.js
Outdated
var entities = dataSource.entities.values; | ||
|
||
for (var i = 0; i < entities.length; i++) { | ||
var entity = entities[i]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Give the entity a name so the guid
doesn't show up in the header of the infobox
Source/App.js
Outdated
|
||
var description = '<table class="cesium-infoBox-defaultTable cesium-infoBox-defaultTable-lighter"><tbody>'; | ||
description += '<tr><th>' + "Latitude" + '</th><td>' + latitude + '</td></tr>'; | ||
description += '<tr><th>' + "Longitude" + '</th><td>' + longitude + '</td></tr>'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have more interesting information to show here instead of just latitude and longitude?
Source/App.js
Outdated
// Styling Data | ||
////////////////////////////////////////////////////////////////////////// | ||
|
||
var distanceDisplayCondition = new Cesium.DistanceDisplayCondition(10.0, 10000.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the far value could be a little further out. Especially for the !
billboards
Source/App.js
Outdated
|
||
if (Cesium.defined(entity.polygon)) { | ||
//Set the polygon material to a random, translucent color. | ||
entity.polygon.material = Cesium.Color.fromRandom({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we try this on a less-than-stellar machine? I think this dataset might have too many polygons. Toggling them on caused my machine to lag a little and I have pretty good specs. We need something that will perform well on whatever low end laptops people might have with them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, you could try running a polygon simplification algorithm like this one to create an easier dataset http://mourner.github.io/simplify-js/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ho ho ho! I just found a different dataset that's 2 mb smaller which runs much better. Thanks for the suggestion though! I'll try it on a bad machine.
index.html
Outdated
<input id="neighborhoods" type="checkbox"/> | ||
<label for="neighborhoods">Neighborhoods</label> | ||
</div> | ||
<span> Cache max display distance (meters)</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand what this slider is for
index.html
Outdated
</div> | ||
<span> Cache max display distance (meters)</span> | ||
<div class="nowrap"> | ||
<input id="distanceSlider" type="range" min="1000" max="100000" value="10000" step="1000"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to add an input
listener to this so the value updates as you move the slider, not just when you let go of it
} | ||
|
||
.cover { | ||
display: none; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of this if it's never shown?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, fixed it. I do the loading at the end of the app. How can I check if all the visible terrain tiles are loaded?
I think the app overall has a good set of features. This are all of the comments I had about the implementation |
Disclaimer, I intentionally did not read the workshop PR or look at the code yet, here's my thoughts after spending 10 minutes simply playing with the app:
|
Looking at the code (only a high-level glance to start):
(function () {
"use strict";
/* globals Cesium */
...
Existing app.js
...
}());
|
Source/App.js
Outdated
////////////////////////////////////////////////////////////////////////// | ||
|
||
// // If the mouse is over a point of interest, change the entity billboard scale and color | ||
var previousPickedEntity = undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no reason to explicitly set this to undefined.
Source/App.js
Outdated
// // If the mouse is over a point of interest, change the entity billboard scale and color | ||
var previousPickedEntity = undefined; | ||
|
||
var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no reason to create a SSE here, you can use viewer.screenSpaceEventHandler
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though in general, I push users away from using SSE and towards using standard mouse move events. It's important that we stress that using Cesium is similar to using any other browser widget/element. There's nothing special about mouse events.
Thank you for the review, @mramato !
Agreed! Changed it to 2x, which seems to look much better.
This was intentional? I felt that the follow drone camera should have a fixed transform relative to the camera.
How do I control this??
Removed. People weren't particularly interested in this feature at the dry-run anyway.
Fixed!
How do I get this setup?
I'll add it if time allows.
Yep, they're definitely ground clamped...
Sure -- this has to be relatively low priority, but I'll take a look.
I actually copied the NYC demo app for that style. I'm open to other suggestions, but I figured this was enough since we have a more extensive sandcastle demo.
Yep, I mentioned a lot of things not directly in the tutorial during the dry run, I'll try to add as many of them as I can.
Good idea! I'll try to get to it.
Fixed. |
Maybe turn off the water mask? The water looks especially pixely in this area. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed the code only, looks good.
Source/App.js
Outdated
// Add Bing imagery | ||
viewer.imageryLayers.addImageryProvider(new Cesium.BingMapsImageryProvider({ | ||
url : 'https://dev.virtualearth.net', | ||
mapStyle: Cesium.BingMapsStyle.ROADS // Can also use Cesium.BingMapsStyle.ROADS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment seems outdated.
Source/App.js
Outdated
|
||
// Load the NYC buildings tileset | ||
var city = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({ | ||
url: 'https://cesiumjs.org/NewYork/3DTilesGml', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Source/App.js
Outdated
|
||
city.readyPromise.then(function(tileset) { | ||
tileset.style = defaultStyle; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can set the style before the tileset is ready, but double check that.
Source/App.js
Outdated
var handler = viewer.screenSpaceEventHandler; | ||
handler.setInputAction(function (movement) { | ||
var pickedPrimitive = viewer.scene.pick(movement.endPosition); | ||
var pickedEntity = (Cesium.defined(pickedPrimitive)) ? pickedPrimitive.id : undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to wrap with ()
.
Source/App.js
Outdated
|
||
// Create a follow camera by tracking the drone entity | ||
function setViewMode() { | ||
if(droneModeElement.checked) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting: if (
@@ -0,0 +1,343 @@ | |||
(function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be sure, is this file meant to be included?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, see #2 (comment)
Anything else @lilleyse ? Can this be merged? |
That's all from me, but someone else who looked closer at everything should merge. |
Ok, thanks all for the reviews! In the interest of giving workshop attendees time to download, I'm going to go ahead and merge this, but please feel free to look at it some more. |
478ac76
to
ab92787
Compare
Hey @mramato,
Here's a rough draft of the app. Would you mind taking a big picture look? I'm still considering adding
I also still need to create a CZML file of drone positions, which I'm still not sure how to approach. You mentioned that Ed might be able to help me with this, but he's out until July 10.