-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: import eventemitter by default #1186
- Loading branch information
Showing
12 changed files
with
4,311 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/g-plugin-device-renderer/src/geometries/BufferGeometry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { Canvas, CanvasEvent } from '@antv/g'; | ||
import { Renderer as CanvasRenderer } from '@antv/g-canvas'; | ||
import { Renderer as CanvaskitRenderer } from '@antv/g-canvaskit'; | ||
import { loadAnimation } from '@antv/g-lottie-player'; | ||
import { Renderer as SVGRenderer } from '@antv/g-svg'; | ||
import { Renderer as WebGLRenderer } from '@antv/g-webgl'; | ||
import { Renderer as WebGPURenderer } from '@antv/g-webgpu'; | ||
import * as lil from 'lil-gui'; | ||
import Stats from 'stats.js'; | ||
import * as d3 from 'd3'; | ||
|
||
/** | ||
* @see https://lottiefiles.github.io/lottie-docs/concepts/#transform | ||
*/ | ||
|
||
// create a renderer | ||
const canvasRenderer = new CanvasRenderer(); | ||
const svgRenderer = new SVGRenderer(); | ||
const webglRenderer = new WebGLRenderer(); | ||
const webgpuRenderer = new WebGPURenderer(); | ||
const canvaskitRenderer = new CanvaskitRenderer({ | ||
wasmDir: '/', | ||
fonts: [ | ||
{ | ||
name: 'sans-serif', | ||
url: '/NotoSans-Regular.ttf', | ||
}, | ||
], | ||
}); | ||
|
||
// create a canvas | ||
const canvas = new Canvas({ | ||
container: 'container', | ||
width: 600, | ||
height: 500, | ||
renderer: canvasRenderer, | ||
}); | ||
|
||
canvas.addEventListener(CanvasEvent.READY, async () => { | ||
const data = await d3.json('/lottie/ant.json'); | ||
const animation = loadAnimation(data, { loop: true }); | ||
const wrapper = animation.render(canvas); | ||
}); | ||
|
||
// stats | ||
const stats = new Stats(); | ||
stats.showPanel(0); | ||
const $stats = stats.dom; | ||
$stats.style.position = 'absolute'; | ||
$stats.style.left = '0px'; | ||
$stats.style.top = '0px'; | ||
const $wrapper = document.getElementById('container'); | ||
$wrapper.appendChild($stats); | ||
canvas.addEventListener(CanvasEvent.AFTER_RENDER, () => { | ||
if (stats) { | ||
stats.update(); | ||
} | ||
}); | ||
|
||
// GUI | ||
const gui = new lil.GUI({ autoPlace: false }); | ||
$wrapper.appendChild(gui.domElement); | ||
const rendererFolder = gui.addFolder('renderer'); | ||
const rendererConfig = { | ||
renderer: 'canvas', | ||
}; | ||
rendererFolder | ||
.add(rendererConfig, 'renderer', ['canvas', 'svg', 'webgl', 'webgpu', 'canvaskit']) | ||
.onChange((rendererName) => { | ||
let renderer; | ||
if (rendererName === 'canvas') { | ||
renderer = canvasRenderer; | ||
} else if (rendererName === 'svg') { | ||
renderer = svgRenderer; | ||
} else if (rendererName === 'webgl') { | ||
renderer = webglRenderer; | ||
} else if (rendererName === 'webgpu') { | ||
renderer = webgpuRenderer; | ||
} else if (rendererName === 'canvaskit') { | ||
renderer = canvaskitRenderer; | ||
} | ||
canvas.setRenderer(renderer); | ||
}); | ||
rendererFolder.open(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.