0.1.21 • Published 7 months ago

@antv/g6-extension-3d v0.1.21

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

3D extension for G6

This extension package provides 3D elements, behaviors and plugins for G6.

Usage

  1. Install
npm install @antv/g6-extension-3d
  1. Import and Register

Where renderer, elements and lighting are necessary

import { ExtensionCategory, register } from '@antv/g6';
import { DragCanvas3D, Light, Line3D, Sphere, renderer } from '@antv/g6-extension-3d';

// 3d light plugin
register(ExtensionCategory.PLUGIN, '3d-light', Light);
// sphere node element
register(ExtensionCategory.NODE, 'sphere', Sphere);
// line edge element
register(ExtensionCategory.EDGE, 'line3d', Line3D);
// drag canvas in 3d scene
register(ExtensionCategory.BEHAVIOR, 'drag-canvas-3d', DragCanvas3D);
// camera setting plugin
register(ExtensionCategory.PLUGIN, 'camera-setting', CameraSetting);
  1. Use
import { Graph } from '@antv/g6';

const graph = new Graph({
  container: 'container',
  renderer, // use 3d renderer
  data: {
    // your data
  },
  node: {
    type: 'sphere', // use sphere node
  },
  edge: {
    type: 'line3d', // use 3d line edge
  },
  behaviors: ['drag-canvas-3d'],
  plugins: [
    // set camera configs, see: https://g.antv.antgroup.com/en/api/camera/intro
    {
      type: 'camera-setting',
      projectionMode: 'perspective',
      near: 0.1,
      far: 1000,
      fov: 45,
      aspect: 1,
    },
    // add directional light
    {
      type: '3d-light',
      directional: {
        direction: [0, 0, 1],
      },
    },
  ],
});

Resources

0.1.20

7 months ago

0.1.21

7 months ago

0.1.10

1 year ago

0.1.11

1 year ago

0.1.12

1 year ago

0.1.13

12 months ago

0.1.14

12 months ago

0.1.15

12 months ago

0.1.16

12 months ago

0.1.8

1 year ago

0.1.17

10 months ago

0.1.7

1 year ago

0.1.18

10 months ago

0.1.19

9 months ago

0.1.9

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.2

1 year ago

0.1.1

2 years ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.0

2 years ago