@antv/g2-extension-3d
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

g2-extension-3d

The threed lib for G2.

Getting Started

Create a renderer and register relative plugins which provides 3D rendering capabilities:

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:

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:

chart.point3D().data({});

⚠️ For now we only support Chart API and leave the Spec usage in the future.

Scatter

DEMO

scatter

Line

DEMO

line

Bar

DEMO

surface

Surface

DEMO

surface

Use surface3D mark:

chart
  .surface3D()
  .data(points)
  .encode("x", "x")
  .encode("y", "y")
  .encode("z", "z")
  .encode("color", "z")
  .coordinate({ type: "cartesian3D" })
  .scale("x", { nice: true })
  .scale("y", { nice: true })
  .scale("z", { nice: true })
  .scale("color", { palette: "spectral" })
  .legend(false)
  .axis("x", { gridLineWidth: 1 })
  .axis("y", { gridLineWidth: 1, titleBillboardRotation: -Math.PI / 2 })
  .axis("z", { gridLineWidth: 1 })
  .style({
    palette: "spectral",
  });

Run Test Cases

To run playwright, you must download new browsers first:

$npx playwright install

Readme

Keywords

none

Package Sidebar

Install

npm i @antv/g2-extension-3d

Weekly Downloads

103

Version

0.2.0

License

none

Unpacked Size

534 kB

Total Files

263

Last publish

Collaborators

  • xuying1027
  • lvisei
  • yisi.wang
  • basketduck
  • biupiubiupiu
  • flash1
  • dreammy23
  • laixingui.lxg
  • zhangjunjie-loki
  • rainy25ghz
  • zeyuwang
  • yanxiong
  • susiwen8
  • freestyle21
  • soundquiet
  • elaine.q.10
  • sturuby
  • sakuya223
  • serializedowen
  • xdzhao
  • yangzhanmei
  • wjgogogo
  • leungwensen
  • dori
  • iaaron
  • yard
  • simaq
  • dxq613
  • intchous
  • susan_ann
  • jinke.li
  • lzxue
  • army8735
  • atool
  • baizn
  • dengfuping
  • neoddish
  • jeffy2012
  • zqlu
  • afc163
  • pomelo-nwu
  • kopiluwaky
  • ccnuzindex
  • panyuqi
  • bubkoo
  • zengyue
  • kasmine
  • boyu.zlj
  • l1ud0ngq1
  • newbyvector
  • winniexing
  • chenluli
  • kn9117
  • xdddst
  • semious2020
  • esora
  • nadia_liu
  • bbsqq
  • mxz96102
  • openwayne
  • pearmini
  • pddpd
  • yiqianyao
  • zhanba
  • cxxxxxn