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

(p) allow user to set clipping box on google 3d tiles #758

Closed
kfarr opened this issue Aug 12, 2024 · 8 comments
Closed

(p) allow user to set clipping box on google 3d tiles #758

kfarr opened this issue Aug 12, 2024 · 8 comments
Assignees

Comments

@kfarr
Copy link
Collaborator

kfarr commented Aug 12, 2024

nytimes/three-loader-3dtiles#165

@kfarr kfarr converted this from a draft issue Aug 12, 2024
@kfarr kfarr self-assigned this Aug 12, 2024
@kfarr
Copy link
Collaborator Author

kfarr commented Aug 14, 2024

progress so far: 3DStreet/aframe-loader-3dtiles-component#14

@kfarr
Copy link
Collaborator Author

kfarr commented Aug 17, 2024

Linked the branch WIP to this ticket. Barely works, steps before it's "ready" would be:

  • right now this only works to crop AABB but not OBB. see image. I spent a few hours trying to make this work with claude, it was surprisingly tough.
  • instead of clip-box object, default selector of [data-layer-name="Underground"] which would return one matching underground box for a street if it exists in the scene, at least for a v1 this ok but we may want a better way to better define clipping areas in the future. perhaps allowing as user to select a street and it may be easier to make the clipping planes from scratch based on street component's length and width, the street entity's position and rotation.
  • default clippingEnabled should be false and remove the clip-box from scene

Image

@kfarr kfarr linked a pull request Aug 17, 2024 that will close this issue
@kfarr
Copy link
Collaborator Author

kfarr commented Aug 17, 2024

@vincentfretin curious if you have any quick idea to advise on this AABB vs. OBB issue... ^^

@kfarr kfarr moved this from In progress to For Review in 3DStreet Dev Tracking Aug 17, 2024
@vincentfretin
Copy link
Collaborator

I don't see any rotation applied to your clipPlanes THREE.Plane. Did you try setting clipPlane.rotation.y for each of your plane for example?

@kfarr
Copy link
Collaborator Author

kfarr commented Aug 19, 2024

@vincentfretin you're right it's not very robust.

Instead of reinventing the wheel, I can try this next:
https://github.com/aframevr/aframe/blob/master/src/components/obb-collider.js

example:
https://glitch.com/edit/#!/ritzy-coral-sense?path=index.html%3A1%3A0

@vincentfretin
Copy link
Collaborator

The interesting part of obb-collider that handles the rotation was taken when we created our own OrientedBoxHelper if you remember

update() {
// Bounding box is created axis-aligned AABB.
// If there's any rotation the box will have the wrong size.
// It undoes the local entity rotation and then restores so box has the expected size.
// We also undo the parent world rotation.
if (this.object !== undefined) {
auxEuler.copy(this.object.rotation);
auxLocalPosition.copy(this.object.position);
this.object.rotation.set(0, 0, 0);
this.object.position.set(0, 0, 0);
this.object.parent.matrixWorld.decompose(
auxPosition,
auxQuaternion,
auxScale
);
auxMatrix.compose(origin, identityQuaternion, auxScale);
this.object.parent.matrixWorld.copy(auxMatrix);
if (this.boxFill) {
tempBox3.setFromObject(this.object);
tempBox3.getSize(tempVector3Size);
tempBox3.getCenter(tempVector3Center);
this.boxFill.position.copy(tempVector3Center);
this.boxFill.scale.copy(tempVector3Size);
}
}
super.update();
// Restore rotations.
if (this.object !== undefined) {
this.object.parent.matrixWorld.compose(
auxPosition,
auxQuaternion,
auxScale
);
this.object.rotation.copy(auxEuler);
this.object.position.copy(auxLocalPosition);
this.object.getWorldQuaternion(this.quaternion);
this.object.getWorldPosition(this.position);
this.updateMatrix();
}
}

but here for your THREE.Plane I'm not sure this is relevant, it may be for the initial creation of the bounding box to get a correct size, but you still need to have your planes rotated that are used on your material.

@kfarr kfarr changed the title investigate supporting clipping planes for 3dtiles for patricio (patricio) allow user to set clipping box on google 3d tiles Aug 31, 2024
@kfarr kfarr changed the title (patricio) allow user to set clipping box on google 3d tiles (p) allow user to set clipping box on google 3d tiles Sep 10, 2024
@kfarr kfarr assigned vincentfretin and unassigned kfarr Sep 10, 2024
@kfarr
Copy link
Collaborator Author

kfarr commented Sep 10, 2024

@vincentfretin would you be willing to try to help with this?

Some notes:

  • This was code that was made with me and Claude using Cursor, so it is not great. It works OK but is axis aligned bounding box and doesn't look good.
  • I could use help with how to get this to work on any angle, not just aligned with the bounding box
  • I did find that using OBB component with debugging on will create the desired box that we want
  • It could be that we rewrite this using a modified version of the OBB component debug box, and then set the clipping planes based on this debug box

Any other ideas?

@kfarr
Copy link
Collaborator Author

kfarr commented Oct 2, 2024

closed by #882

@kfarr kfarr closed this as completed Oct 2, 2024
@github-project-automation github-project-automation bot moved this from To Do - High Prio to Done in 3DStreet Dev Tracking Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants