Skip to content

Commit

Permalink
v1.0.8 (#26)
Browse files Browse the repository at this point in the history
* Update README.md

* Change version to 1.0.8
  • Loading branch information
TiagoCavalcante authored Sep 1, 2023
1 parent f534cf4 commit 38b1386
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 39 deletions.
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,22 @@ function Canvases() {

The `<OrbitControls />` element _may_ receive the following properties:

| Property | Type | Description |
| :-------------- | :---------------: | ----------------------------------------------: |
| camera | PerspectiveCamera | readonly, available to onChange |
| enabled | boolean | |
| target | Vector3 | |
| minPolarAngle | number | how close you can orbit vertically |
| maxPolarAngle | number | how far you can orbit vertically |
| minAzimuthAngle | number | how close you can orbit horizontally |
| maxAzimuthAngle | number | how far you can orbit horizontally |
| dampingFactor | number | inertia factor |
| enableZoom | boolean | |
| zoomSpeed | number | |
| minZoom | number | |
| maxZoom | number | |
| enableRotate | boolean | |
| rotateSpeed | number | |
| enablePan | boolean | |
| panSpeed | number | |
| onChange | (event) => void | receives an event with all the properties above |
| Property | Type | Description |
| :-------------- | :-------------: | ----------------------------------------------: |
| camera | Camera | readonly, available to onChange |
| enabled | boolean | |
| target | Vector3 | |
| minPolarAngle | number | how close you can orbit vertically |
| maxPolarAngle | number | how far you can orbit vertically |
| minAzimuthAngle | number | how close you can orbit horizontally |
| maxAzimuthAngle | number | how far you can orbit horizontally |
| dampingFactor | number | inertia factor |
| enableZoom | boolean | |
| zoomSpeed | number | |
| minZoom | number | |
| maxZoom | number | |
| enableRotate | boolean | |
| rotateSpeed | number | |
| enablePan | boolean | |
| panSpeed | number | |
| onChange | (event) => void | receives an event with all the properties above |
19 changes: 10 additions & 9 deletions lib/index.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,13 @@ function createControls() {
var linearSquare =
// interpolate between x and x²
function (x) { return x + (1 - Math.exp(-x / 10000)) * (x * x - x + 1 / 4); };
var distanceScale = scope.camera.isPerspectiveCamera
// half of the fov is center to top of screen
? scope.camera.fov / 2
// scale the zoom speed by a factor of 300
: 1 / linearSquare(scope.camera.zoom) * scope.zoomSpeed * 300;
targetDistance *= Math.tan(distanceScale * Math.PI / 180.0);
var distanceScale = scope.camera
.isPerspectiveCamera
? // half of the fov is center to top of screen
scope.camera.fov / 2
: // scale the zoom speed by a factor of 300
(1 / linearSquare(scope.camera.zoom)) * scope.zoomSpeed * 300;
targetDistance *= Math.tan((distanceScale * Math.PI) / 180.0);
// we use only height here so aspect ratio does not distort speed
this.panLeft((2 * deltaX * targetDistance) / height, scope.camera.matrix);
this.panUp((2 * deltaY * targetDistance) / height, scope.camera.matrix);
Expand Down Expand Up @@ -393,12 +394,12 @@ function OrbitControls(_a) {
var controls = _a.controls, props = __rest(_a, ["controls"]);
var camera = native.useThree(function (state) { return state.camera; });
React.useEffect(function () {
if (camera.isPerspectiveCamera
|| camera.isOrthographicCamera) {
if (camera.isPerspectiveCamera ||
camera.isOrthographicCamera) {
controls.scope.camera = camera;
}
else {
throw new Error("The camera must be a PerspectiveCamera to orbit controls work");
throw new Error("The camera must be a PerspectiveCamera or OrthographicCamera to orbit controls work");
}
}, [camera]);
React.useEffect(function () {
Expand Down
19 changes: 10 additions & 9 deletions lib/index.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,13 @@ function createControls() {
var linearSquare =
// interpolate between x and x²
function (x) { return x + (1 - Math.exp(-x / 10000)) * (x * x - x + 1 / 4); };
var distanceScale = scope.camera.isPerspectiveCamera
// half of the fov is center to top of screen
? scope.camera.fov / 2
// scale the zoom speed by a factor of 300
: 1 / linearSquare(scope.camera.zoom) * scope.zoomSpeed * 300;
targetDistance *= Math.tan(distanceScale * Math.PI / 180.0);
var distanceScale = scope.camera
.isPerspectiveCamera
? // half of the fov is center to top of screen
scope.camera.fov / 2
: // scale the zoom speed by a factor of 300
(1 / linearSquare(scope.camera.zoom)) * scope.zoomSpeed * 300;
targetDistance *= Math.tan((distanceScale * Math.PI) / 180.0);
// we use only height here so aspect ratio does not distort speed
this.panLeft((2 * deltaX * targetDistance) / height, scope.camera.matrix);
this.panUp((2 * deltaY * targetDistance) / height, scope.camera.matrix);
Expand Down Expand Up @@ -391,12 +392,12 @@ function OrbitControls(_a) {
var controls = _a.controls, props = __rest(_a, ["controls"]);
var camera = useThree(function (state) { return state.camera; });
useEffect(function () {
if (camera.isPerspectiveCamera
|| camera.isOrthographicCamera) {
if (camera.isPerspectiveCamera ||
camera.isOrthographicCamera) {
controls.scope.camera = camera;
}
else {
throw new Error("The camera must be a PerspectiveCamera to orbit controls work");
throw new Error("The camera must be a PerspectiveCamera or OrthographicCamera to orbit controls work");
}
}, [camera]);
useEffect(function () {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "r3f-native-orbitcontrols",
"version": "1.0.7",
"version": "1.0.8",
"description": "OrbitControls for React Three Fiber in React Native",
"main": "lib/index.cjs.js",
"module": "lib/index.esm.js",
Expand Down
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function OrbitControls({ controls, ...props }: OrbitControlsInternalProps) {
controls.scope.camera = camera as PerspectiveCamera | OrthographicCamera
} else {
throw new Error(
"The camera must be a PerspectiveCamera to orbit controls work"
"The camera must be a PerspectiveCamera or OrthographicCamera to orbit controls work"
)
}
}, [camera])
Expand Down

0 comments on commit 38b1386

Please sign in to comment.