-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: add umd output * chore: add sideeffects
- Loading branch information
Showing
7 changed files
with
127 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules | |
|
||
esm | ||
lib | ||
dist |
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 |
---|---|---|
@@ -1,3 +1,52 @@ | ||
# g2-extension-3d | ||
|
||
> A placeholder for the [threed](https://github.com/antvis/G2/blob/v5/src/lib/std.ts) lib for G2. | ||
The [threed](https://github.com/antvis/G2/blob/v5/src/lib/std.ts) lib for G2. | ||
|
||
## Getting Started | ||
|
||
Create a renderer and register relative plugins which provides 3D rendering capabilities: | ||
|
||
```ts | ||
import { Renderer as WebGLRenderer } from '@antv/g-webgl'; | ||
import { Plugin as ThreeDPlugin } from '@antv/g-plugin-3d'; | ||
import { Plugin as ControlPlugin } from '@antv/g-plugin-control'; | ||
|
||
const renderer = new WebGLRenderer(); | ||
renderer.registerPlugin(new ThreeDPlugin()); | ||
renderer.registerPlugin(new ControlPlugin()); | ||
``` | ||
|
||
Then extend the runtime of G2 with 3D lib: | ||
|
||
```ts | ||
import { threedlib } from '@antv/g2-extension-3d'; | ||
import { Runtime, corelib, extend } from '@antv/g2'; | ||
|
||
const Chart = extend(Runtime, { ...corelib(), ...threedlib() }); | ||
const chart = new Chart({ | ||
container: 'container', | ||
renderer, | ||
depth: 400, | ||
}); | ||
``` | ||
|
||
Now we can use 3D marks like this: | ||
|
||
```ts | ||
chart | ||
.point3D() | ||
.data({}); | ||
``` | ||
|
||
## Scatter | ||
|
||
[DEMO](https://g2.antv.antgroup.com/examples#threed-scatter) | ||
|
||
## Line | ||
|
||
[DEMO](https://g2.antv.antgroup.com/examples#threed-line) | ||
|
||
## Bar | ||
|
||
[DEMO](https://g2.antv.antgroup.com/examples#threed-bar) | ||
|
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,51 @@ | ||
import commonjs from "@rollup/plugin-commonjs"; | ||
import nodeResolve from "@rollup/plugin-node-resolve"; | ||
import terser from "@rollup/plugin-terser"; | ||
import typescript from "@rollup/plugin-typescript"; | ||
import { readFileSync } from "fs"; | ||
|
||
export default createConfig({ | ||
pkg: JSON.parse(readFileSync(new URL("./package.json", import.meta.url), "utf8")), | ||
umdName: "G2.Extension3D", | ||
external: ["@antv/g2"], | ||
globals: { | ||
"@antv/g2": "window.G2", | ||
}, | ||
}); | ||
|
||
function createConfig({ pkg, external = [], umdName = "", globals = {}, plugins = [] }) { | ||
const sharedPlugins = [ | ||
...plugins, | ||
nodeResolve({ | ||
mainFields: ["module", "browser", "main"], | ||
extensions: [".js", ".jsx", ".ts", ".tsx", ".es6", ".es", ".mjs"], | ||
}), | ||
commonjs(), | ||
typescript({ sourceMap: true }), | ||
]; | ||
|
||
return [ | ||
{ | ||
input: "src/index.ts", | ||
output: { | ||
format: "umd", | ||
file: pkg.unpkg, | ||
name: umdName, | ||
globals, | ||
sourcemap: true, | ||
}, | ||
external, | ||
plugins: [ | ||
...sharedPlugins, | ||
terser({ | ||
compress: { | ||
pure_getters: true, | ||
unsafe: true, | ||
unsafe_comps: true, | ||
warnings: false, | ||
}, | ||
}), | ||
], | ||
}, | ||
]; | ||
} |
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