From 6cacac79f3457645cdca5f47ab960b3124fa7cb8 Mon Sep 17 00:00:00 2001 From: "yuqi.pyq" Date: Thu, 26 Oct 2023 16:07:32 +0800 Subject: [PATCH] feat: add onframe param on goToLandmark --- demo/perf-nodes-edges.html | 238 ++++++++++++++++++ packages/g-camera-api/src/AdvancedCamera.ts | 5 + .../src/drawcalls/Instanced.ts | 4 + .../src/renderer/Batch.ts | 2 +- 4 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 demo/perf-nodes-edges.html diff --git a/demo/perf-nodes-edges.html b/demo/perf-nodes-edges.html new file mode 100644 index 000000000..c42468afe --- /dev/null +++ b/demo/perf-nodes-edges.html @@ -0,0 +1,238 @@ + + + + + + Nodes & Edges + + + + +
+ + + + + + diff --git a/packages/g-camera-api/src/AdvancedCamera.ts b/packages/g-camera-api/src/AdvancedCamera.ts index d7ed26031..1b83d7122 100644 --- a/packages/g-camera-api/src/AdvancedCamera.ts +++ b/packages/g-camera-api/src/AdvancedCamera.ts @@ -198,6 +198,7 @@ export class AdvancedCamera extends Camera { easing: string; easingFunction: TypeEasingFunction; duration: number; + onframe: (t: number) => void; onfinish: () => void; }> = {}, ) { @@ -210,6 +211,7 @@ export class AdvancedCamera extends Camera { duration = 100, easingFunction = undefined, onfinish = undefined, + onframe = undefined, } = isNumber(options) ? { duration: options } : options; const epsilon = 0.01; @@ -284,6 +286,9 @@ export class AdvancedCamera extends Camera { this.triggerUpdate(); if (elapsed < duration) { + if (onframe) { + onframe(t); + } this.landmarkAnimationID = this.canvas.requestAnimationFrame(animate); } }; diff --git a/packages/g-plugin-device-renderer/src/drawcalls/Instanced.ts b/packages/g-plugin-device-renderer/src/drawcalls/Instanced.ts index bf264b905..379e8eb6a 100644 --- a/packages/g-plugin-device-renderer/src/drawcalls/Instanced.ts +++ b/packages/g-plugin-device-renderer/src/drawcalls/Instanced.ts @@ -711,6 +711,10 @@ export abstract class Instanced { name: string, value: any, ) { + if (objects.length === 0) { + return; + } + const stylePacked = [ 'opacity', 'fillOpacity', diff --git a/packages/g-plugin-device-renderer/src/renderer/Batch.ts b/packages/g-plugin-device-renderer/src/renderer/Batch.ts index 0c0ea6006..7e5667573 100644 --- a/packages/g-plugin-device-renderer/src/renderer/Batch.ts +++ b/packages/g-plugin-device-renderer/src/renderer/Batch.ts @@ -5,7 +5,7 @@ import type { RenderInst } from '../render/RenderInst'; /** * render order start from 0, our default camera's Z is 500 */ -export const RENDER_ORDER_SCALE = 1 / 200; +export const RENDER_ORDER_SCALE = 500 / 1000000; /** * A container for multiple display objects with the same `style`,