Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/impl/orbit_camera.cpp
#	src/impl/orbit_camera.h
  • Loading branch information
guillaumeblanc committed Sep 24, 2023
2 parents 47df700 + c27a473 commit 0ae21d7
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 7 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
![](samples/media/flip_128.png)
![](samples/media/flip_grey_256.png)

[Check live wasm samples](https://guillaumeblanc.github.io/flip/).

Flip is a multi-platform 3D programming library designed to simplify the development of basic 3d rendering and viewing applications.

Expand Down
Binary file added samples/media/flip_32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/media/flip_64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/media/flip_grey_128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/media/flip_grey_256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/media/flip_grey_32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/media/flip_grey_512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/media/flip_grey_64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 7 additions & 5 deletions src/impl/orbit_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,15 @@ bool OrbitCamera::Event(const sapp_event& _event) {
const auto v0 = HMM_Vec2{touch0.pos_x, touch0.pos_y};
const auto v1 = HMM_Vec2{touch1.pos_x, touch1.pos_y};

const auto& prev_v0 = last_touches_[touch0.identifier];
const auto& prev_v1 = last_touches_[touch1.identifier];
const auto& pv0 = last_touches_[touch0.identifier];
const auto& pv1 = last_touches_[touch1.identifier];

const float length0 = HMM_LenV2(v1 - v0);
const float length1 = HMM_LenV2(prev_v1 - prev_v0);
Zoom((HMM_LenV2(pv1 - pv0) - HMM_LenV2(v1 - v0)) * kZoomTouchFactor);

Zoom((length1 - length0) * kZoomTouchFactor);
const auto m = (v1 + v0) / 2;
const auto pm = (pv1 + pv0) / 2;
const auto dm = (m - pm) * kPanTouchFactor;
Pan(dm.X, dm.Y);
}

// Updates all touch coords
Expand Down
3 changes: 2 additions & 1 deletion src/impl/orbit_camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ class OrbitCamera : public Camera {
const float kOrbitFactor = .01f;
const float kOrbitTouchFactor = .3f;
const float kPanFactor = .002f;
const float kPanTouchFactor = .05f;
const float kMoveFactor = .002f;
const float kZoomFactor = .5f;
const float kZoomTouchFactor = .1f;
const float kZoomTouchFactor = .02f;

float distance_ = 7.f;
float latitude_ = 0.f;
Expand Down

0 comments on commit 0ae21d7

Please sign in to comment.