Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: refactor api docs #6284

Merged
merged 4 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/g6-extension-3d/src/behaviors/drag-canvas-3d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import type { DragCanvasOptions, Vector2, ViewportAnimationEffectTiming } from '@antv/g6';
import { DragCanvas } from '@antv/g6';

/**
* <zh/> 拖拽 3D 画布交互
*
* <en/> Drag 3D canvas behavior
*/
export interface DragCanvas3DOptions extends DragCanvasOptions {}
Aarebecca marked this conversation as resolved.
Show resolved Hide resolved

/**
Expand Down
5 changes: 5 additions & 0 deletions packages/g6-extension-3d/src/behaviors/observe-canvas-3d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { CameraType } from '@antv/g';
import type { BaseBehaviorOptions, IDragEvent, RuntimeContext, ShortcutKey } from '@antv/g6';
import { BaseBehavior, GraphEvent, Shortcut } from '@antv/g6';

/**
* <zh/> 观察 3D 画布交互配置项
*
* <en/> Observe 3D canvas options
*/
export interface ObserveCanvas3DOptions extends BaseBehaviorOptions {
enable?: boolean;
/**
Expand Down
10 changes: 10 additions & 0 deletions packages/g6-extension-3d/src/behaviors/roll-canvas-3d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import type { BaseBehaviorOptions, IWheelEvent, RuntimeContext, ShortcutKey } from '@antv/g6';
import { BasePlugin, Shortcut } from '@antv/g6';

/**
* <zh/> 滚动画布配置项
*
* <en/> Roll Canvas Options
*/
export interface RollCanvas3DOptions extends BaseBehaviorOptions {
enable?: boolean;
/**
Expand All @@ -17,6 +22,11 @@ export interface RollCanvas3DOptions extends BaseBehaviorOptions {
sensitivity?: number;
}

/**
* <zh/> 滚动画布
*
* <en/> Roll Canvas
*/
export class RollCanvas3D extends BasePlugin<RollCanvas3DOptions> {
static defaultOptions: Partial<RollCanvas3DOptions> = {
enable: true,
Expand Down
10 changes: 10 additions & 0 deletions packages/g6-extension-3d/src/behaviors/zoom-canvas-3d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@ import type { IKeyboardEvent, IWheelEvent, ViewportAnimationEffectTiming, ZoomCa
import { ZoomCanvas } from '@antv/g6';
import { clamp } from '@antv/util';

/**
* <zh/> 缩放画布配置项
*
* <en/> Zoom Canvas Options
*/
export interface ZoomCanvas3DOptions extends ZoomCanvasOptions {}

/**
* <zh/> 缩放画布
*
* <en/> Zoom Canvas
*/
export class ZoomCanvas3D extends ZoomCanvas {
protected zoom = async (
value: number,
Expand Down
10 changes: 10 additions & 0 deletions packages/g6-extension-3d/src/elements/base-node-3d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,23 @@ import { deepMix } from '@antv/util';
import { Material } from '../types';
import { createMaterial } from '../utils/material';

/**
* <zh/> 3D 节点样式
*
* <en/> 3D node style props
*/
export interface BaseNode3DStyleProps extends BaseNodeStyleProps, Prefix<'material', IMaterial> {
geometry?: GGeometry<any>;
material?: GMaterial<any>;
texture?: string | TexImageSource;
materialType?: Material['type'];
}

/**
* <zh/> 3D 节点基类
*
* <en/> 3D node base class
*/
export abstract class BaseNode3D<S extends BaseNode3DStyleProps> extends BaseNode<S> {
static defaultStyleProps: Partial<BaseNode3DStyleProps> = {
materialType: 'basic',
Expand Down
10 changes: 10 additions & 0 deletions packages/g6-extension-3d/src/elements/capsule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ import { createGeometry } from '../utils/geometry';
import type { BaseNode3DStyleProps } from './base-node-3d';
import { BaseNode3D } from './base-node-3d';

/**
* <zh/> 胶囊节点样式
*
* <en/> Capsule Node Style Props
*/
export type CapsuleStyleProps = BaseNode3DStyleProps & CapsuleGeometryProps;

/**
* <zh/> 胶囊节点
*
* <en/> Capsule Node
*/
export class Capsule extends BaseNode3D<CapsuleStyleProps> {
static defaultStyleProps: Partial<CapsuleStyleProps> = {
// radius, height
Expand Down
10 changes: 10 additions & 0 deletions packages/g6-extension-3d/src/elements/cone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ import { createGeometry } from '../utils/geometry';
import type { BaseNode3DStyleProps } from './base-node-3d';
import { BaseNode3D } from './base-node-3d';

/**
* <zh/> 圆锥节点样式
*
* <en/> Cone Node Style Props
*/
export type ConeStyleProps = BaseNode3DStyleProps & ConeGeometryProps;

/**
* <zh/> 圆锥节点
*
* <en/> Cone Node
*/
export class Cone extends BaseNode3D<ConeStyleProps> {
static defaultStyleProps: Partial<ConeStyleProps> = {
// baseRadius, peakRadius, height
Expand Down
10 changes: 10 additions & 0 deletions packages/g6-extension-3d/src/elements/cube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ import { createGeometry } from '../utils/geometry';
import type { BaseNode3DStyleProps } from './base-node-3d';
import { BaseNode3D } from './base-node-3d';

/**
* <zh/> 立方体节点样式
*
* <en/> Cube Node Style Props
*/
export type CubeStyleProps = BaseNode3DStyleProps & CubeGeometryProps;

/**
* <zh/> 立方体节点
*
* <en/> Cube Node
*/
export class Cube extends BaseNode3D<CubeStyleProps> {
static defaultStyleProps: Partial<CubeStyleProps> = {
widthSegments: 1,
Expand Down
10 changes: 10 additions & 0 deletions packages/g6-extension-3d/src/elements/cylinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ import { createGeometry } from '../utils/geometry';
import type { BaseNode3DStyleProps } from './base-node-3d';
import { BaseNode3D } from './base-node-3d';

/**
* <zh/> 圆柱节点样式
*
* <en/> Cylinder Node Style Props
*/
export type CylinderStyleProps = BaseNode3DStyleProps & CylinderGeometryProps;

/**
* <zh/> 圆柱节点
*
* <en/> Cylinder Node
*/
export class Cylinder extends BaseNode3D<CylinderStyleProps> {
static defaultStyleProps: Partial<CylinderStyleProps> = {
// radius, height
Expand Down
10 changes: 10 additions & 0 deletions packages/g6-extension-3d/src/elements/line-3d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@ import { Line } from '@antv/g';
import type { BaseEdgeStyleProps } from '@antv/g6';
import { BaseEdge } from '@antv/g6';

/**
* <zh/> 3D 直线样式
*
* <en/> 3D Line Style Props
*/
export interface Line3DStyleProps extends BaseEdgeStyleProps {}

/**
* <zh/> 直线
*
* <en/> Line Edge
*/
export class Line3D extends BaseEdge {
protected getKeyPath(): any {
return [];
Expand Down
10 changes: 10 additions & 0 deletions packages/g6-extension-3d/src/elements/plane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ import { createGeometry } from '../utils/geometry';
import type { BaseNode3DStyleProps } from './base-node-3d';
import { BaseNode3D } from './base-node-3d';

/**
* <zh/> 平面节点样式
*
* <en/> Plane Node Style Props
*/
export type PlaneStyleProps = BaseNode3DStyleProps & PlaneGeometryProps;

/**
* <zh/> 平面节点
*
* <en/> Plane Node
*/
export class Plane extends BaseNode3D<PlaneStyleProps> {
static defaultStyleProps: Partial<PlaneStyleProps> = {
materialCullMode: CullMode.NONE,
Expand Down
10 changes: 10 additions & 0 deletions packages/g6-extension-3d/src/elements/sphere.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ import { createGeometry } from '../utils/geometry';
import type { BaseNode3DStyleProps } from './base-node-3d';
import { BaseNode3D } from './base-node-3d';

/**
* <zh/> 球体节点样式
*
* <en/> Sphere Node Style Props
*/
export type SphereStyleProps = BaseNode3DStyleProps & SphereGeometryProps;

/**
* <zh/> 球体节点
*
* <en/> Sphere Node
*/
export class Sphere extends BaseNode3D<SphereStyleProps> {
static defaultStyleProps: Partial<SphereStyleProps> = {
// radius
Expand Down
10 changes: 10 additions & 0 deletions packages/g6-extension-3d/src/elements/torus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ import { createGeometry } from '../utils/geometry';
import type { BaseNode3DStyleProps } from './base-node-3d';
import { BaseNode3D } from './base-node-3d';

/**
* <zh/> 圆环节点样式
*
* <en/> Torus Node Style Props
*/
export type TorusStyleProps = BaseNode3DStyleProps & TorusGeometryProps;

/**
* <zh/> 圆环节点
*
* <en/> Torus Node
*/
export class Torus extends BaseNode3D<TorusStyleProps> {
static defaultStyleProps: Partial<TorusStyleProps> = {
// tubeRadius, ringRadius
Expand Down
16 changes: 16 additions & 0 deletions packages/g6-extension-3d/src/plugins/light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import type { BasePluginOptions, RuntimeContext } from '@antv/g6';
import { BasePlugin, GraphEvent } from '@antv/g6';
import { deepMix } from '@antv/util';

/**
* <zh/> 光照插件配置项
*
* <en/> Light plugin options
*/
export interface LightOptions extends BasePluginOptions {
/**
* <zh/> 环境光
Expand All @@ -19,6 +24,11 @@ export interface LightOptions extends BasePluginOptions {
directional?: DirectionalLightProps;
}

/**
* <zh/> 光照插件
*
* <en/> Light plugin
*/
export class Light extends BasePlugin<LightOptions> {
static defaultOptions: Partial<LightOptions> = {
ambient: {
Expand Down Expand Up @@ -71,6 +81,12 @@ export class Light extends BasePlugin<LightOptions> {
} else this[type]?.remove();
}

/**
* <zh/> 销毁插件
*
* <en/> Destroy the plugin
* @internal
*/
public destroy() {
this.ambient?.remove();
this.directional?.remove();
Expand Down
7 changes: 7 additions & 0 deletions packages/g6-extension-3d/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import { Plugin as Plugin3D } from '@antv/g-plugin-3d';
import { Renderer as WebGLRenderer } from '@antv/g-webgl';
import type { CanvasOptions } from '@antv/g6';

/**
* <zh/> 3D 渲染器
*
* <en/> 3D renderer
* @param layer - <zh/> 图层 | <en/> Layer
* @returns <zh/> 渲染器实例 | <en/> Renderer instance
*/
export const renderer: CanvasOptions['renderer'] = (layer) => {
if (layer === 'label') {
return new CanvasRenderer();
Expand Down
10 changes: 10 additions & 0 deletions packages/g6/src/behaviors/base-behavior.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import { BaseExtension } from '../registry/extension';
import type { CustomBehaviorOption } from '../spec/behavior';

/**
* <zh/> 交互通用配置项
*
* <en/> Base options for behaviors
*/
export interface BaseBehaviorOptions extends CustomBehaviorOption {}

/**
* <zh/> 交互的基类
*
* <en/> Base class for behaviors
*/
export abstract class BaseBehavior<T extends BaseBehaviorOptions = BaseBehaviorOptions> extends BaseExtension<T> {}
2 changes: 0 additions & 2 deletions packages/g6/src/elements/edges/line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ type ParsedLineStyleProps = Required<LineStyleProps>;
* <zh/> 直线
*
* <en/> Line
* @remarks
* <img width="300" src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*YbpvTa4liAEAAAAAAAAAAAAADmJ7AQ/original" />
*/
export class Line extends BaseEdge {
static defaultStyleProps: Partial<LineStyleProps> = {};
Expand Down
Loading
Loading