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

Nyc app #2

Merged
merged 9 commits into from
Aug 11, 2017
Merged

Nyc app #2

merged 9 commits into from
Aug 11, 2017

Conversation

rahwang
Copy link
Contributor

@rahwang rahwang commented Jul 5, 2017

Hey @mramato,

Here's a rough draft of the app. Would you mind taking a big picture look? I'm still considering adding

  1. Flyover camera mode
  2. Visibility test, eg. how many points are currently visible in drone camera mode.

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.

@rahwang
Copy link
Contributor Author

rahwang commented Jul 10, 2017

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).
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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,
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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
Copy link
Contributor

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;
Copy link
Contributor

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({
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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({
Copy link
Contributor

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?

Copy link
Contributor Author

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);
Copy link
Contributor

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

Copy link
Contributor Author

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);
Copy link
Contributor

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

Copy link
Contributor Author

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.

@hpinkos
Copy link
Contributor

hpinkos commented Jul 10, 2017

Make sure we properly credit the data sources in your presentation where necessary

README.md Outdated
* `node server.js`

Browse to `http://localhost:8000/`
Copy link
Contributor

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);
Copy link
Contributor

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];
Copy link
Contributor

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>';
Copy link
Contributor

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);
Copy link
Contributor

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({
Copy link
Contributor

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

Copy link
Contributor

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/

Copy link
Contributor Author

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>
Copy link
Contributor

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">
Copy link
Contributor

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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?

@hpinkos
Copy link
Contributor

hpinkos commented Jul 10, 2017

I think the app overall has a good set of features. This are all of the comments I had about the implementation

@mramato
Copy link
Contributor

mramato commented Aug 4, 2017

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:

  1. Drone may be moving to fast, because even over a good connection the 3D Tiles can't stream in fast enough, meaning the drone spends a lot of time flying over nothing until everything loads

  2. Why can't I move the camera while following the drone?

  3. Clicking on polygons causes an improperly sized InfoBox

  4. The Geocache display distance slider seems to not work (and it's disconnected from the number field next to it)

  5. Switching Free from Drone View keeps the camera locked around a certain point. Are we forgetting to reset the transform back to IDENTITY?

  6. Clicking the Home button while in "Drone View" doesn't seem to have any effect. We should fly to the home view and automatically go back to Free mode.

  7. Terrain is on, but the tileset is not set up for terrian so it submerges some of the buildings (we can probably reprocess for terrain)

  8. It would be nice if clicking on a building showed data or double click allowed you to zoom.

  9. Double clicking on the drone tracks it, but the radio still indicates the camera is in Free view.

  10. The Geocache placemarks do not appear to be on terrain, causing them to either be in the air or buried. Are we telling Cesium to clamp them to ground?

  11. Would be nice to have a custom images for the geocache locations, it will make the app look nicer. (Could make it fun and use a treasure chest or something similar)

  12. The styling examples could probably do something more interesting, I also noticed that when styling by height, the WTC is transparent but no other building is. Was that intentional?

  13. I'm not going to point out "missing" Cesium features in the app because I know we're time contrained, but I assume you are going to discuss stuff like imagery, 2D, CV, etc.. elsehwere in the workshop?

  14. I remember you saying something about writing a CameraLimiter to contrain the view to a certain bounding sphere or volume, is that still the plan? It would work nicely with this app.

  15. Neighborhoods appear to be displayed by default but the checkbox is unchecked.

@mramato
Copy link
Contributor

mramato commented Aug 4, 2017

Looking at the code (only a high-level glance to start):

  1. There are some bad habits here, I understand that we are trying to keep things simple for the workshop, but we also need to enforce good practices. At the very least we should wrap the entirety of App.js in an IIFE and enable strict mode (strict mode also improves performance). Basically this:
(function () {
    "use strict";
    /* globals Cesium */
...
Existing app.js
...
}());
  1. You included the minified version of Cesium.js in your app, which means you won't be getting any error checking from Cesium itself. We strongly encourage users to use the unminified version of the app and then switch to the minified version for release.

  2. Are we going to cover actually deploying a Cesium project? What files you need and other best practices? While general deployment is outside the scope of the project, we should at least cover the Cesium specific parts, since Cesium has more moving parts (by necessity) in order to accomplish what it does.

Source/App.js Outdated
//////////////////////////////////////////////////////////////////////////

// // If the mouse is over a point of interest, change the entity billboard scale and color
var previousPickedEntity = undefined;
Copy link
Contributor

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);
Copy link
Contributor

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.

Copy link
Contributor

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.

@rahwang
Copy link
Contributor Author

rahwang commented Aug 8, 2017

Thank you for the review, @mramato !

  1. Drone may be moving to fast, because even over a good connection the 3D Tiles can't stream in
    fast enough, meaning the drone spends a lot of time flying over nothing until everything loads

Agreed! Changed it to 2x, which seems to look much better.

  1. Why can't I move the camera while following the drone?

This was intentional? I felt that the follow drone camera should have a fixed transform relative to the camera.

  1. Clicking on polygons causes an improperly sized InfoBox

How do I control this??

  1. The Geocache display distance slider seems to not work (and it's disconnected from the ?> number field next to it)

Removed. People weren't particularly interested in this feature at the dry-run anyway.

  1. Switching Free from Drone View keeps the camera locked around a certain point. Are we ?
    forgetting to reset the transform back to IDENTITY?
  2. Clicking the Home button while in "Drone View" doesn't seem to have any effect. We should > fly to the home view and automatically go back to Free mode.

Fixed!

  1. Terrain is on, but the tileset is not set up for terrian so it submerges some of the buildings ?
    (we can probably reprocess for terrain)

How do I get this setup?

  1. It would be nice if clicking on a building showed data or double click allowed you to zoom.

I'll add it if time allows.

  1. Double clicking on the drone tracks it, but the radio still indicates the camera is in Free view.
  1. The Geocache placemarks do not appear to be on terrain, causing them to either be in the ?> air or buried. Are we telling Cesium to clamp them to ground?

Yep, they're definitely ground clamped...

  1. Would be nice to have a custom images for the geocache locations, it will make the app look > nicer. (Could make it fun and use a treasure chest or something similar)

Sure -- this has to be relatively low priority, but I'll take a look.

  1. The styling examples could probably do something more interesting, I also noticed that
    when styling by height, the WTC is transparent but no other building is. Was that intentional?

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.

  1. I'm not going to point out "missing" Cesium features in the app because I know we're time
    constrained, but I assume you are going to discuss stuff like imagery, 2D, CV, etc.. elsehwere in > the workshop?

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.

  1. I remember you saying something about writing a CameraLimiter to contrain the view to a
    certain bounding sphere or volume, is that still the plan? It would work nicely with this app.

Good idea! I'll try to get to it.

  1. Neighborhoods appear to be displayed by default but the checkbox is unchecked.

Fixed.

@lilleyse
Copy link
Contributor

Maybe turn off the water mask? The water looks especially pixely in this area.

Copy link
Contributor

@lilleyse lilleyse left a 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
Copy link
Contributor

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',
Copy link
Contributor

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;
});
Copy link
Contributor

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;
Copy link
Contributor

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) {
Copy link
Contributor

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 () {
Copy link
Contributor

@lilleyse lilleyse Aug 10, 2017

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, see #2 (comment)

@rahwang
Copy link
Contributor Author

rahwang commented Aug 10, 2017

Anything else @lilleyse ? Can this be merged?

@lilleyse
Copy link
Contributor

That's all from me, but someone else who looked closer at everything should merge.

@rahwang
Copy link
Contributor Author

rahwang commented Aug 11, 2017

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.

@rahwang rahwang force-pushed the nyc-app branch 2 times, most recently from 478ac76 to ab92787 Compare August 11, 2017 13:18
@rahwang rahwang merged commit dce6b6a into master Aug 11, 2017
@rahwang rahwang mentioned this pull request Aug 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants