-
-
Notifications
You must be signed in to change notification settings - Fork 267
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
Add direction parameters to fitTo method #88
Conversation
Thanks for your contribution. Here is my idea
|
The current direction ? |
yesyes |
but the point is to choose a side to look at, whatever the current camera state is |
Yes this would be more flexible since it allows any point of view. But it still requires extra parameters for direction. |
I guess choosing a side can be done in userland if the library provides free direction fit |
Yes, I'll work on that |
oh btw, don't add generated files (such as .js) for pull requests please. this causes too many changes |
The last changes introduce two new controls.fitTo(mesh, true, {
polarAngle: Math.PI / 2,
azimuthAngle: Math.PI
}) If you specify a side, controls.fitTo(mesh, true, {
side: 'up'
}) This behaviour depends on parameters destructuring and default values: fitTo( box3OrObject: _THREE.Box3 | _THREE.Object3D, enableTransition: boolean, {
side = SIDE.FRONT,
azimuthAngle = SIDES[ side ].azimuthAngle,
polarAngle = SIDES[ side ].polarAngle,
paddingLeft = 0,
paddingRight = 0,
paddingBottom = 0,
paddingTop = 0
}: Partial<FitToOptions> = {} ): void And the available side angles are defined in a constant: export const SIDES: { [side in SIDE]: Direction } = {
[ SIDE.FRONT ]: { polarAngle: PI_HALF, azimuthAngle: 0 },
[ SIDE.BACK ]: { polarAngle: PI_HALF, azimuthAngle: Math.PI },
[ SIDE.UP ]: { polarAngle: - PI_HALF, azimuthAngle: 0 },
[ SIDE.DOWN ]: { polarAngle: Math.PI, azimuthAngle: 0 },
[ SIDE.RIGHT ]: { polarAngle: PI_HALF, azimuthAngle: PI_HALF },
[ SIDE.LEFT ]: { polarAngle: PI_HALF, azimuthAngle: - PI_HALF }
}; As you proposed, each corner of the bounding box is projected on a plane, then the camera distance is computed from the bounding rect containing all projected points. |
Thanks i will take a look |
Thank you for this PR I'd need this to fit the object from a top-down view. Any chance this gets merged/released soon? |
sorry for the delay. Thanks for the PR! |
@yomotsu Any idea when the next release will be so I can update to be able to use this feature? Thank you ! |
I'll work on that this weekend. maybe early next week! |
@yomotsu You have done some releases since but this is still not release. Any chance we can get a release for this soon? |
This feature is already available. |
I updated to |
@yomotsu This is working well when you want a perpendicular view on the object but this is not working if I want to do an isometric view for example. |
This feature allows to specify which side of the bounding box to fit when using
fitTo
.The corresponding example has also been updated so the grid always shows the right unit size regarding the camera position.
Usage
These are the available
side
values:The default value is
'front'
so the feature isn't a breaking change. I haven't written the doc yet, let me know if you would merge this and I'll do it.