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

obb clipping #882

Merged
merged 15 commits into from
Oct 1, 2024
Merged

obb clipping #882

merged 15 commits into from
Oct 1, 2024

Conversation

kfarr
Copy link
Collaborator

@kfarr kfarr commented Sep 29, 2024

barely working v1

enable by pasting into console after loading a scene into editor with google3d tiles layer:

document.querySelector('#clipping-box').setAttribute('obb-collider2', "clipPlaneFunction: obb;"); 
document.querySelector('#clipping-box').play();

video:
https://github.com/user-attachments/assets/b29a31aa-d312-42b0-b87a-15988f23d775

some things this needs:

  • see the other branch on how make the component usable as a boolean option in street geo component, instead of copy/paste console code --> when street-geo sets clipping ON, then the box is created with this component on it
  • rename to 'obb-clipping' (component and system)
  • try setting the "known good" clipping box to be the same dimensions as the default street in the scene
  • try moving the box to a child layer and/or adding obb-collider2 component to the underground box entity itself
  • try moving obb-collider2 component to the 3dtiles itself using trackedObject3D property to reference the box
  • try removing top/bottom planes to have infinite top/bottom
  • once we figure out the right mechanism to allow the user to save the clipping settings, ensure it saves/loads correctly

enable by using console-log

document.querySelector('#clipping-box').setAttribute('obb-collider2', "clipPlaneFunction: obb;")
document.querySelector('#clipping-box').play()
Copy link
Collaborator

@rahulkgupta rahulkgupta left a comment

Choose a reason for hiding this comment

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

the math in this makes my head spin

src/components/obb-clipping.js Outdated Show resolved Hide resolved
@rahulkgupta
Copy link
Collaborator

What's the other branch?

@kfarr
Copy link
Collaborator Author

kfarr commented Sep 30, 2024

What's the other branch?

#877

@kfarr
Copy link
Collaborator Author

kfarr commented Sep 30, 2024

next steps:

  • test if I can put the component on the street underground box instead of a root box

this barely works:
- you need to start a new scene
- add google 3d tiles by specifying location
- then drag and drop a new street from the add panel
- then enter viewer mode
@kfarr
Copy link
Collaborator Author

kfarr commented Sep 30, 2024

barely working 3

barely-working-clipping3.mov

issues to fix:

  • data-no-pause doesn't seem to work right when loading the box at first. need to enter viewer mode and then return to
  • overloading dirt / underground box with clipping seems not like desired user behavior
  • it may make sense to have an explicit clipping box that is created for this purpose at the same level as the underground box but a separate box
  • it is invisible by default, shown with a wireframe if visible

@kfarr
Copy link
Collaborator Author

kfarr commented Sep 30, 2024

ok great progress so far:

  • now you can specify geo, place a scene, and then use the "underground" layer to define your clipping area, then uncheck the visibility checkbox from underground

things to fix:

  • improve logic to specify a target clipping element (the element to be clipped), right now '#google3d' id selector is hardcode
  • improve logic to specify a source clipping element (the element to define clipping volume) ... such as if a street is not present, create a clipping box in the user root?
  • throttle ticking, remove logging, consider removing things from tick as much as possible since this is no longer a collision component

Notes for testing / docs outline:

Sometimes things just get in the way. Now there's an easy way to Clip It Out!

Ingredients:

  • 3DStreet Geospatial Pro
  • Choose a location and enable google3d map source
  • Add a street
  • Click geospatial layer, open right panel, click advanced, click enableClipping
  • Need more clipping? Change the size of our scene by placing objects higher or to the side. You can also place an object and toggle its visibility off.

can turn from false to true during session, but then setting from true to false the user must reload to see tiles without clipping.

I tried using a reduntant 'enabled' boolean on obb-clipping. that didn't work but i kept it in to test a bit more.
still might be better to have an explicit box some day -- i think there will be many case where a user will wish to have a box like this -- but this might be good enough to ship
@kfarr
Copy link
Collaborator Author

kfarr commented Oct 1, 2024

Progress notes:

  • now this will look for a target of [street] and return bounding box of the first street and subelements it finds
  • todo: consider throttle ticking, remove logging, consider removing things from tick as much as possible since this is no longer a collision component

Not working yet:

  • if clipping is turned on, and then i turn it off during the session, it will not remove clipping and the tick appears to still run even though the component has been removed

better solution is to monitor for pose changes on target object AND monitor for tiles loaded events from 3dtiles runtime object via threejs-loader-tiles library
@kfarr
Copy link
Collaborator Author

kfarr commented Oct 1, 2024

Now ready for testing / code review:

  • login with geospatial pro account
  • Choose a location to enable google3d map source
  • Add a street
  • Click geospatial layer, open right panel, click advanced, click enableClipping
  • Need more clipping? Change the size of our scene by placing objects higher or to the side. You can also place an object and toggle its visibility off.

@rahulkgupta
Copy link
Collaborator

works!

  • testing placing things higher also works. note, scaling a lightpole doesn't change the clipping box

Copy link
Collaborator

@rahulkgupta rahulkgupta left a comment

Choose a reason for hiding this comment

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

mostly just questions that dont need an immediate answer

src/components/obb-clipping.js Show resolved Hide resolved
src/components/street-geo.js Show resolved Hide resolved
@kfarr kfarr merged commit 3e56c3c into main Oct 1, 2024
1 check passed
@kfarr kfarr deleted the clipping-box-attempt-2 branch October 1, 2024 20:36
This was referenced Oct 1, 2024
obb.copy(this.aabb);
obb.applyMatrix4(auxMatrix);

const clipPlanes = this.createPlanesFromOBB(obb);
Copy link

Choose a reason for hiding this comment

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

you don't need to update the clipping planes every frame. Can do similar to bounding box recalculation. Consider scenarios when you want to recalculate: rotation, scale, position changes

Copy link

@dmarcos dmarcos Oct 1, 2024

Choose a reason for hiding this comment

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

wrap below lines in an if statement that checks for the relevant changes that trigger a plane recalculation

    const clipPlanes = this.createPlanesFromOBB(obb);
    this.applyClippingPlanes(clipPlanes);

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