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

Hubble example #14

Merged
merged 21 commits into from
Sep 11, 2020
Merged

Hubble example #14

merged 21 commits into from
Sep 11, 2020

Conversation

97morningstar
Copy link
Member

@97morningstar 97morningstar commented Sep 4, 2020

Issue referencing this pull request
Issue #28 (Still it's needed to integrate into kepler)

Changes [To add this functionality to any example]:

  1. Add to the props to DeckGl component
        viewState={viewState}
        onViewStateChange={({viewState}) => {
          setViewState(viewState);
        }}

        controller={true}

  • 1.1 Add the viewState state

const [viewState, setViewState] = useState(INITIAL_VIEW_STATE);

  1. Add the prop to BasicControls component (optional)

updateCamera={updateCamera}

  1. Add the optional method to start the camera from the current viewState (optional)
const updateCamera = (prevCamera) => {
    // Set by User
  prevCamera = new CameraKeyframes({
        timings: [0, 5000],
        keyframes: [
          {
            longitude: viewState.longitude,
            latitude: viewState.latitude,
            zoom: viewState.zoom,
            pitch: viewState.pitch,
            bearing: viewState.bearing
          },
          {
            longitude: viewState.longitude,
            latitude: viewState.latitude,
            zoom: viewState.zoom,
            bearing: viewState.bearing + 92,
            pitch: viewState.pitch // up to 45/50
          }
        ],
        easings: [easing.easeInOut]
      });
   
    return prevCamera;
  }
  • 3.1. Imports to app
		import {CameraKeyframes} from '@hubble.gl/core';
		import {easing} from 'popmotion';
  1. Fix this line when attaching the camera to the timeline

const currentCamera = animationLoop.timeline.attachAnimation(keyframes.camera);

  • 4.1. Add as prop to DeckScene
  return new DeckScene({
    animationLoop,
    keyframes,
    lengthMs: 5000,
    width: 1280,
    height: 720,
    currentCamera  // Here
  });

@chrisgervang
Copy link
Member

Thanks for the comments to explain everything :) I was wondering if we could split this into two PRs, one for the glTF separate from the hubble-example and viewState changes?

Also, could you rename hubble-example to something more related to the view state feature?

Copy link
Member

@chrisgervang chrisgervang left a comment

Choose a reason for hiding this comment

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

On second look, it looks like the examples added might be accidental duplicates of each other?

examples/camera/app.js Show resolved Hide resolved
modules/core/src/adapters/deck-adapter.js Outdated Show resolved Hide resolved
modules/core/src/adapters/deck-adapter.js Show resolved Hide resolved
@@ -28,20 +28,20 @@ import {
} from '@hubble.gl/core';
import EncoderDropdown from './encoder-dropdown';

export default function BasicControls({adapter, busy, setBusy, encoderSettings}) {
export default function BasicControls({adapter, busy, setBusy, encoderSettings, updateCamera}) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you check to ensure updateCamera is an optional value in both this component and in adapter.getProps?

Want to make sure this feature is "opt in"

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm passing updateCamera = undefined at the end of the props in BasicControls. Now if you don't pass an updateCamera function in the BasicControls component it will use the default keyframes.
The only change in adapter.getProps was that this.enabled was added at the end of the check:

// Animating the camera is optional, but if a keyframe is defined then viewState is controlled by camera keyframe.
    if (this.scene && this.scene.keyframes.camera && this.enabled) {

      props.controller = false;
      props.viewState = this._getViewState();
    }

What should I change about this?

@@ -24,13 +24,15 @@ export async function sceneBuilder(animationLoop) {
easings: [easing.easeInOut]
})
};
animationLoop.timeline.attachAnimation(keyframes.camera);

const currentCamera = animationLoop.timeline.attachAnimation(keyframes.camera);

return new DeckScene({
animationLoop,
keyframes,
lengthMs: 5000,
width: 640,

Choose a reason for hiding this comment

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

Not sure if you're on this task yet but shouldn't this be modular? So that the user can set resolution themselves

Copy link
Member

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've ever scoped or discussed setting resolution differently. At the moment it's designed to be set within scene definition since it's how I preferred to set up scenes.

We could change this to be optional if DeckAdapter is changed to only set it if it's defined. Happy to accept a PR for that.

Choose a reason for hiding this comment

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

Got it. I imagined those being values being set with state but I must have misremembered.

'https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf-zipcodes.json';

export const layers = [
new PolygonLayer({
Copy link

@RaymondDashWu RaymondDashWu Sep 7, 2020

Choose a reason for hiding this comment

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

I'm not sure what all of these layers are doing. Looking at the filepath it has something to do with GLTF? Which a quick search says is related to 3d assets? Consider adding a README for all of these examples giving a brief overview of what they're showcasing.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm deleting the GLTF example as it was from when we were learning.

Choose a reason for hiding this comment

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

That's fine. The other examples could use a README though

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you think of the README file? I've never written one before so I'm not sure it's correct. The other examples didn't have readme files, should I add to those too?

Copy link
Member

@chrisgervang chrisgervang left a comment

Choose a reason for hiding this comment

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

Looks pretty good! Getting very close. Could you rename the example folder you're keeping to "trips"? (Sorry about the minor requests, I think this consistency will help in the long run)

examples/update-viewState/app.js Outdated Show resolved Hide resolved
examples/update-viewState/app.js Outdated Show resolved Hide resolved
examples/update-viewState/app.js Outdated Show resolved Hide resolved
examples/update-viewState/layers.js Outdated Show resolved Hide resolved
examples/update-viewState/webpack.config.js Outdated Show resolved Hide resolved
RaymondDashWu pushed a commit that referenced this pull request Sep 9, 2020
Pinning node to version 12.6.3 per discussion. Upgrading to deck 8.2.2
@chrisgervang
Copy link
Member

Looks good! Please "squash and merge" from the web UI to consolidate the commits into one.

@97morningstar 97morningstar merged commit 32b1234 into master Sep 11, 2020
chrisgervang added a commit that referenced this pull request Sep 11, 2020
* Upgrade packages, downgrade node (for now) (#14)

Pinning node to version 12.6.3 per discussion. Upgrading to deck 8.2.2

* Improve App Integration: Make Camera and Layers Optional in a DeckScene (#15)

* Minor keyframe class clean up, removing unused defaults

* Camera and Layers are optional in a DeckScene

- Animating the camera is optional, but if a keyframe is defined then viewState is controlled by camera keyframe.
  - To Use: do not provide a `camera` to `keyframes` parameter when constructing DeckScene.
- Animating layers is optional, only replace layers prop when scene provides layers.
  - To Use: do not provide a `renderLayers` parameter when constructing DeckScene

* Adding Camera Example to docs

* [FIX/ADD] Fixed missing steps to instructions + added extra notation (#13)

* [FIX/ADD] Fixed missing steps to instructions + added extra notation

* [FIX] Forgot missing step in #8

* [FIX/ADD] Fix step 9 and added clarification

* [DEL] Extraneous folders/files

* Adding a ResolutionGuide component to examples...(#17)

...so the background doesn't look so empty.

* v1.1.0-alpha.3 (#18)

* v1.1.0-alpha.4

* Bump lodash from 4.17.15 to 4.17.19

Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <[email protected]>

* Bump elliptic from 6.5.2 to 6.5.3

Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.2 to 6.5.3.
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](indutny/elliptic@v6.5.2...v6.5.3)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: RaymondDashWu <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
chrisgervang added a commit that referenced this pull request Sep 23, 2020
* Upgrade packages, downgrade node (for now) (#14)

Pinning node to version 12.6.3 per discussion. Upgrading to deck 8.2.2

* Improve App Integration: Make Camera and Layers Optional in a DeckScene (#15)

* Minor keyframe class clean up, removing unused defaults

* Camera and Layers are optional in a DeckScene

- Animating the camera is optional, but if a keyframe is defined then viewState is controlled by camera keyframe.
  - To Use: do not provide a `camera` to `keyframes` parameter when constructing DeckScene.
- Animating layers is optional, only replace layers prop when scene provides layers.
  - To Use: do not provide a `renderLayers` parameter when constructing DeckScene

* Adding Camera Example to docs

* [FIX/ADD] Fixed missing steps to instructions + added extra notation (#13)

* [FIX/ADD] Fixed missing steps to instructions + added extra notation

* [FIX] Forgot missing step in #8

* [FIX/ADD] Fix step 9 and added clarification

* [DEL] Extraneous folders/files

* Adding a ResolutionGuide component to examples...(#17)

...so the background doesn't look so empty.

* v1.1.0-alpha.3 (#18)

* v1.1.0-alpha.4

* Bump lodash from 4.17.15 to 4.17.19

Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <[email protected]>

* Bump elliptic from 6.5.2 to 6.5.3

Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.2 to 6.5.3.
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](indutny/elliptic@v6.5.2...v6.5.3)

Signed-off-by: dependabot[bot] <[email protected]>

* lint (#28)

* v1.1.0-alpha.5

* Documentation fixes additions (#21)

* [FIX/ADD] Fixed missing steps to instructions + added extra notation

* [FIX] Forgot missing step in #8

* [FIX/ADD] Fix step 9 and added clarification

* [DEL] Extraneous folders/files

* [TEST] Is this how you link markdown images?

* [ADD] Rendering tips/guide

* [FIX] Separated GIF/MP4 so it can't be interpreted together

* [FIX] Made steps more clear by bolding and fixed sequence conversion to gif not mp4

* [FIX?] Image not loading

* [FIX] MP4 => GIF error

* [FIX] Spacing between Step #s

* [FIX] Step #4 spacing

* [FIX/ADD] Removed MP4 from docs + added entry to table of contents

* [MOVE] Images move to website static folder + location updated

* [FIX] Image URLS

* Bump http-proxy from 1.18.0 to 1.18.1 (#25)

Bumps [http-proxy](https://github.com/http-party/node-http-proxy) from 1.18.0 to 1.18.1.
- [Release notes](https://github.com/http-party/node-http-proxy/releases)
- [Changelog](https://github.com/http-party/node-http-proxy/blob/master/CHANGELOG.md)
- [Commits](http-party/node-http-proxy@1.18.0...1.18.1)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump node-fetch from 2.6.0 to 2.6.1 (#26)

Bumps [node-fetch](https://github.com/bitinn/node-fetch) from 2.6.0 to 2.6.1.
- [Release notes](https://github.com/bitinn/node-fetch/releases)
- [Changelog](https://github.com/node-fetch/node-fetch/blob/master/docs/CHANGELOG.md)
- [Commits](node-fetch/node-fetch@v2.6.0...v2.6.1)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: RaymondDashWu <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
chrisgervang added a commit that referenced this pull request Sep 26, 2020
Pinning node to version 12.6.3 per discussion. Upgrading to deck 8.2.2
chrisgervang added a commit that referenced this pull request Oct 16, 2020
… an animation for some datasets (#15)

* Upgrade packages, downgrade node (for now) (#14)

Pinning node to version 12.6.3 per discussion. Upgrading to deck 8.2.2

* Improve App Integration: Make Camera and Layers Optional in a DeckScene (#15)

* Minor keyframe class clean up, removing unused defaults

* Camera and Layers are optional in a DeckScene

- Animating the camera is optional, but if a keyframe is defined then viewState is controlled by camera keyframe.
  - To Use: do not provide a `camera` to `keyframes` parameter when constructing DeckScene.
- Animating layers is optional, only replace layers prop when scene provides layers.
  - To Use: do not provide a `renderLayers` parameter when constructing DeckScene

* Adding Camera Example to docs

* [FIX/ADD] Fixed missing steps to instructions + added extra notation (#13)

* [FIX/ADD] Fixed missing steps to instructions + added extra notation

* [FIX] Forgot missing step in #8

* [FIX/ADD] Fix step 9 and added clarification

* [DEL] Extraneous folders/files

* Adding a ResolutionGuide component to examples...(#17)

...so the background doesn't look so empty.

* v1.1.0-alpha.3 (#18)

* v1.1.0-alpha.4

* Bump lodash from 4.17.15 to 4.17.19

Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <[email protected]>

* Bump elliptic from 6.5.2 to 6.5.3

Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.2 to 6.5.3.
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](indutny/elliptic@v6.5.2...v6.5.3)

Signed-off-by: dependabot[bot] <[email protected]>

* Initial commit. Mini kepler example but not connected to Redux

* [BLOCKED] Can't connect to Kepler's Redux store

* [BLOCKED] Can't connect to Redux

* lint (#28)

* v1.1.0-alpha.5

* Documentation fixes additions (#21)

* [FIX/ADD] Fixed missing steps to instructions + added extra notation

* [FIX] Forgot missing step in #8

* [FIX/ADD] Fix step 9 and added clarification

* [DEL] Extraneous folders/files

* [TEST] Is this how you link markdown images?

* [ADD] Rendering tips/guide

* [FIX] Separated GIF/MP4 so it can't be interpreted together

* [FIX] Made steps more clear by bolding and fixed sequence conversion to gif not mp4

* [FIX?] Image not loading

* [FIX] MP4 => GIF error

* [FIX] Spacing between Step #s

* [FIX] Step #4 spacing

* [FIX/ADD] Removed MP4 from docs + added entry to table of contents

* [MOVE] Images move to website static folder + location updated

* [FIX] Image URLS

* Bump http-proxy from 1.18.0 to 1.18.1 (#25)

Bumps [http-proxy](https://github.com/http-party/node-http-proxy) from 1.18.0 to 1.18.1.
- [Release notes](https://github.com/http-party/node-http-proxy/releases)
- [Changelog](https://github.com/http-party/node-http-proxy/blob/master/CHANGELOG.md)
- [Commits](http-party/node-http-proxy@1.18.0...1.18.1)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [BLOCKED] Issues in #12 Codelabs

* [FIX] Modal now opens

* Bump node-fetch from 2.6.0 to 2.6.1 (#26)

Bumps [node-fetch](https://github.com/bitinn/node-fetch) from 2.6.0 to 2.6.1.
- [Release notes](https://github.com/bitinn/node-fetch/releases)
- [Changelog](https://github.com/node-fetch/node-fetch/blob/master/docs/CHANGELOG.md)
- [Commits](node-fetch/node-fetch@v2.6.0...v2.6.1)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [BLOCKED] Can't find module ocular.config

* [FIX] Webpack config now boots start-local

* [FIX] Modal now opens with map but animations bugged

* Documentation Grammer Edit (#29)

Just a missing comma

* [ADD] Incorporated initial view state + default/update keyframes

* [FIX] Updated keyframes were wrong bug

* [REFACTOR] Created new panel-preview + scene now consistent with hubble's scene

* Mapbox And Deck.gl Canvas Merged When Exported With Hubble.gl In Example Trips (#31)

* Mapbox and Deck.gl canvas merged when exported with Hubble.gl

Co-authored-by: Chris Gervang <[email protected]>

* [FIX] updateCamera temporary fix

* [FIX/REFACTOR] updateCamera now updates keyframe, parseSetCameraType now a generic util

* [FIX/CLEAN] Bug where keyframes weren't updating properly + cleaned dead code in preparation to merge to master

* [CLEAN] Removed unused code, packages, + lint fixes

Co-authored-by: Chris Gervang <[email protected]>
Co-authored-by: Chris Gervang <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Chris Gervang <[email protected]>
Co-authored-by: Vitor Dino <[email protected]>
Co-authored-by: Elisa Martinez <[email protected]>
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.

3 participants