Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

feat: plugin APIs to get camera viewport and layers in the viewport #165

Merged
merged 9 commits into from Feb 9, 2022

Conversation

issmail-basel
Copy link
Contributor

Overview

Extend public API to include layers filtering by viewport

What I've done

  • Use camera.computeViewRectangle() to retrieve the viewport's rectangle.
  • Loop through layers and use Rectangle.contains to check if layer is inside this rectangle or not.

How I tested

reearth.layers.getLayersInViewport() in console.

@netlify
Copy link

netlify bot commented Jan 30, 2022

✔️ Deploy Preview for reearth-web ready!

🔨 Explore the source changes: aaaeb70

🔍 Inspect the deploy log: https://app.netlify.com/sites/reearth-web/deploys/6203943c1ce8160008a1a699

😎 Browse the preview: https://deploy-preview-165--reearth-web.netlify.app

@codecov
Copy link

codecov bot commented Jan 30, 2022

Codecov Report

Merging #165 (aaaeb70) into main (4fdf5f9) will decrease coverage by 0.06%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #165      +/-   ##
==========================================
- Coverage   45.21%   45.14%   -0.07%     
==========================================
  Files          60       60              
  Lines        1307     1309       +2     
  Branches      212      212              
==========================================
  Hits          591      591              
- Misses        657      659       +2     
  Partials       59       59              
Impacted Files Coverage Δ
src/components/molecules/Visualizer/Plugin/api.ts 0.00% <0.00%> (ø)
...components/molecules/Visualizer/Plugin/context.tsx 6.66% <ø> (ø)

@issmail-basel
Copy link
Contributor Author

@rot1024 , I need your advice on the following: (I'll remind you on Monday)

  • How this API should look?
  • Do I loop through all layers, or make this function accept layer id/ids as a parameter?
  • Architecture advice of what to consider when extending the API, and where to place the code.

After answering these, I'll write a development outline and continue with this task.
Thanks.

src/components/molecules/Visualizer/Plugin/types.ts Outdated Show resolved Hide resolved
src/components/molecules/Visualizer/Engine/ref.ts Outdated Show resolved Hide resolved
src/components/molecules/Visualizer/Engine/ref.ts Outdated Show resolved Hide resolved
src/components/molecules/Visualizer/Plugin/api.ts Outdated Show resolved Hide resolved
src/components/molecules/Visualizer/hooks.ts Outdated Show resolved Hide resolved
@rot1024 rot1024 changed the title feat: filter layers by viewport feat: plugin API to get camera viewport and layers in the viewport Feb 2, 2022
@rot1024 rot1024 changed the title feat: plugin API to get camera viewport and layers in the viewport feat: plugin APIs to get camera viewport and layers in the viewport Feb 2, 2022
@rot1024 rot1024 marked this pull request as ready for review February 7, 2022 06:14
Copy link
Member

@rot1024 rot1024 left a comment

Choose a reason for hiding this comment

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

I tested on Netlify preview and roughly ok, but I found that rect fields are radians, and also the plugin APIs often uses getters, so fix them and make sure to return the value directly instead of returning a function.

src/components/molecules/Visualizer/Plugin/api.ts Outdated Show resolved Hide resolved
src/components/molecules/Visualizer/Plugin/api.ts Outdated Show resolved Hide resolved
src/components/molecules/Visualizer/Plugin/types.ts Outdated Show resolved Hide resolved
src/components/molecules/Visualizer/hooks.ts Outdated Show resolved Hide resolved
src/components/molecules/Visualizer/Plugin/types.ts Outdated Show resolved Hide resolved
@issmail-basel issmail-basel enabled auto-merge (squash) February 9, 2022 10:06
@issmail-basel issmail-basel merged commit f1f95a2 into main Feb 9, 2022
@issmail-basel issmail-basel deleted the filter-layers-by-viewport branch February 9, 2022 10:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants