Skip to content

Commit

Permalink
Release (#1722)
Browse files Browse the repository at this point in the history
* fix: fix gotoLandmark duration 0 not effect (#1721)

* chore: commit changeset (#1723)

* chore(release): bump version (#1724)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 3, 2024
1 parent 3ec9b93 commit eef62b9
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 44 deletions.
26 changes: 26 additions & 0 deletions __tests__/demos/plugin/camera.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Circle } from '../../../packages/g';

export async function camera(context) {
const { canvas } = context;
await canvas.ready;

const circle = new Circle({
style: {
cx: 10,
cy: 10,
r: 10,
fill: 'red',
},
});

canvas.appendChild(circle);

const camera = canvas.getCamera();

const landmark = camera.createLandmark('camera', {
position: [200, 200, 500],
focalPoint: [200, 200, 0],
});

camera.gotoLandmark(landmark, { duration: 0 });
}
1 change: 1 addition & 0 deletions __tests__/demos/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export { annotation } from './annotation';
export { exporter } from './exporter';
// export { yogaText } from './yoga-text';
export { a11y } from './a11y';
export { camera } from './camera';
6 changes: 6 additions & 0 deletions packages/g-camera-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @antv/g-camera-api

## 2.0.8

### Patch Changes

- a098d3ef: fix goto landmark

## 2.0.7

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-camera-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-camera-api",
"version": "2.0.7",
"version": "2.0.8",
"description": "A simple implementation of Camera API.",
"keywords": [
"antv",
Expand Down
48 changes: 7 additions & 41 deletions packages/g-camera-api/src/AdvancedCamera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,6 @@ export class AdvancedCamera extends Camera {
} = isNumber(options) ? { duration: options } : options;
const epsilon = 0.01;

if (duration === 0) {
this.syncFromLandmark(landmark);
if (onfinish) {
onfinish();
}
return;
}

// cancel ongoing animation
this.cancelLandmarkAnimation();

Expand All @@ -234,26 +226,26 @@ export class AdvancedCamera extends Camera {
const easingFunc = easingFunction || runtime.EasingFunction(easing);

let timeStart: number | undefined;
const endAnimation = () => {
const end = () => {
this.setFocalPoint(destFocalPoint);
this.setPosition(destPosition);
this.setRoll(destRoll);
this.setZoom(destZoom);
this.computeMatrix();
this.triggerUpdate();
if (onfinish) {
onfinish();
}
onfinish?.();
};

if (duration === 0) return end();

const animate = (timestamp: number) => {
if (timeStart === undefined) {
timeStart = timestamp;
}
const elapsed = timestamp - timeStart;

if (elapsed >= duration) {
endAnimation();
end();
return;
}
// use the same ease function in animation system
Expand All @@ -278,17 +270,14 @@ export class AdvancedCamera extends Camera {
vec3.dist(interFocalPoint, destFocalPoint) +
vec3.dist(interPosition, destPosition);
if (dist <= epsilon && destZoom == undefined && destRoll == undefined) {
endAnimation();
return;
return end();
}

this.computeMatrix();
this.triggerUpdate();

if (elapsed < duration) {
if (onframe) {
onframe(t);
}
onframe?.(t);
this.landmarkAnimationID = this.canvas.requestAnimationFrame(animate);
}
};
Expand All @@ -297,29 +286,6 @@ export class AdvancedCamera extends Camera {
}
}

private syncFromLandmark(landmark: Landmark) {
this.matrix = mat4.copy(this.matrix, landmark.matrix);
this.right = vec3.copy(this.right, landmark.right);
this.up = vec3.copy(this.up, landmark.up);
this.forward = vec3.copy(this.forward, landmark.forward);
this.position = vec3.copy(this.position, landmark.position);
this.focalPoint = vec3.copy(this.focalPoint, landmark.focalPoint);
this.distanceVector = vec3.copy(
this.distanceVector,
landmark.distanceVector,
);

this.azimuth = landmark.azimuth;
this.elevation = landmark.elevation;
this.roll = landmark.roll;
this.relAzimuth = landmark.relAzimuth;
this.relElevation = landmark.relElevation;
this.relRoll = landmark.relRoll;
this.dollyingStep = landmark.dollyingStep;
this.distance = landmark.distance;
this.zoom = landmark.zoom;
}

/**
* Sets the camera to a distance such that the area covered by the bounding box is viewed.
*/
Expand Down
7 changes: 7 additions & 0 deletions packages/g/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g

## 6.0.9

### Patch Changes

- Updated dependencies [a098d3ef]
- @antv/g-camera-api@2.0.8

## 6.0.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g",
"version": "6.0.8",
"version": "6.0.9",
"description": "A core module for rendering engine implements DOM API.",
"keywords": [
"antv",
Expand Down
6 changes: 6 additions & 0 deletions packages/react-g/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @antv/react-g

## 2.0.9

### Patch Changes

- @antv/g@6.0.9

## 2.0.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/react-g/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/react-g",
"version": "2.0.8",
"version": "2.0.9",
"description": "react render for @antv/g",
"keywords": [
"react",
Expand Down

0 comments on commit eef62b9

Please sign in to comment.