-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(3d): init g6-extension-3d package
- Loading branch information
Showing
9 changed files
with
152 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
describe('suite', () => { | ||
it('case', () => { | ||
expect(1).toBe(1); | ||
}); | ||
}); |
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,48 @@ | ||
{ | ||
"name": "g6-extension-3d", | ||
"version": "1.0.0", | ||
"description": "", | ||
"keywords": [ | ||
"antv", | ||
"g6", | ||
"extension", | ||
"3d" | ||
], | ||
"license": "MIT", | ||
"author": "", | ||
"main": "lib/index.js", | ||
"module": "esm/index.js", | ||
"types": "lib/index.d.ts", | ||
"files": [ | ||
"src", | ||
"esm", | ||
"lib", | ||
"dist" | ||
], | ||
"scripts": { | ||
"build": "run-p build:*", | ||
"build:cjs": "rimraf ./lib && tsc --module commonjs --outDir lib", | ||
"build:esm": "rimraf ./esm && tsc --module ESNext --outDir esm", | ||
"build:esm:watch": "rimraf ./esm && tsc --module ESNext --outDir esm --watch", | ||
"build:umd": "rimraf ./dist && rollup -c", | ||
"ci": "run-s lint type-check build test", | ||
"lint": "eslint ./src __tests__ --quiet && prettier ./src __tests__ --check", | ||
"prepublishOnly": "npm run ci", | ||
"test": "jest", | ||
"type-check": "tsc --noEmit" | ||
}, | ||
"dependencies": { | ||
"@antv/g": "^5.18.25", | ||
"@antv/g-canvas": "^1.11.27", | ||
"@antv/g-device-api": "^1.6.4", | ||
"@antv/g-plugin-3d": "^1.9.34", | ||
"@antv/g-plugin-control": "^1.9.22", | ||
"@antv/g-webgl": "^1.9.37" | ||
}, | ||
"devDependencies": { | ||
"@antv/g6": "workspace:*" | ||
}, | ||
"peerDependencies": { | ||
"@antv/g6": "workspace:*" | ||
} | ||
} |
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,21 @@ | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
import terser from '@rollup/plugin-terser'; | ||
import typescript from '@rollup/plugin-typescript'; | ||
import nodePolyfills from 'rollup-plugin-polyfill-node'; | ||
import { visualizer } from 'rollup-plugin-visualizer'; | ||
|
||
const isBundleVis = !!process.env.BUNDLE_VIS; | ||
|
||
export default[ | ||
{ | ||
input: 'src/index.ts', | ||
output: { | ||
file: 'dist/g6.min.js', | ||
name: 'G6V5', | ||
format: 'umd', | ||
sourcemap: false, | ||
}, | ||
plugins: [nodePolyfills(), resolve(), commonjs(), typescript(), terser(), ...(isBundleVis ? [visualizer()] : [])], | ||
}, | ||
]; |
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,21 @@ | ||
import type { BaseStyleProps } from '@antv/g'; | ||
import { Device } from '@antv/g-device-api'; | ||
import type { BufferGeometry, Material } from '@antv/g-plugin-3d'; | ||
import type { BaseNodeStyleProps } from '@antv/g6'; | ||
import { BaseNode } from '@antv/g6'; | ||
|
||
export interface BaseNode3DStyleProps extends BaseNodeStyleProps<MeshStyleProps> { | ||
z?: number; | ||
device: Device; | ||
material: Material; | ||
} | ||
|
||
export abstract class BaseNode3D extends BaseNode<BaseNode3DStyleProps> {} | ||
|
||
export interface MeshStyleProps extends BaseStyleProps { | ||
x?: number | string; | ||
y?: number | string; | ||
z?: number | string; | ||
geometry: BufferGeometry; | ||
material: Material; | ||
} |
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,5 @@ | ||
export { BaseNode3D } from './base-node-3d'; | ||
export { Sphere } from './sphere'; | ||
|
||
export type { BaseNode3DStyleProps } from './base-node-3d'; | ||
export type { SphereStyleProps } from './sphere'; |
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,21 @@ | ||
import type { Group } from '@antv/g'; | ||
import { Mesh } from '@antv/g-plugin-3d'; | ||
import type { BaseNode3DStyleProps, MeshStyleProps } from './base-node-3d'; | ||
import { BaseNode3D } from './base-node-3d'; | ||
|
||
export interface SphereStyleProps extends BaseNode3DStyleProps {} | ||
|
||
type ParsedSphereStyleProps = Required<SphereStyleProps>; | ||
|
||
export class Sphere extends BaseNode3D { | ||
protected drawKeyShape(attributes = this.parsedAttributes, container: Group = this) { | ||
return this.upsert('key', Mesh, this.getKeyStyle(attributes), container); | ||
} | ||
|
||
protected getKeyStyle(attributes: ParsedSphereStyleProps): MeshStyleProps { | ||
return { | ||
...super.getKeyStyle(attributes), | ||
z: attributes.z || 0, | ||
}; | ||
} | ||
} |
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,4 @@ | ||
export { BaseNode3D, Sphere } from './elements'; | ||
export { renderer } from './renderer'; | ||
|
||
export type { BaseNode3DStyleProps, SphereStyleProps } from './elements'; |
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,20 @@ | ||
import { Renderer as CanvasRenderer } from '@antv/g-canvas'; | ||
import { Plugin as Plugin3D } from '@antv/g-plugin-3d'; | ||
import { Plugin as PluginControl } from '@antv/g-plugin-control'; | ||
import { Renderer as WebGLRenderer } from '@antv/g-webgl'; | ||
import type { CanvasOptions } from '@antv/g6'; | ||
|
||
export const renderer: CanvasOptions['renderer'] = (layer) => { | ||
if (layer === 'label' || layer === 'transientLabel') { | ||
return new CanvasRenderer(); | ||
} | ||
|
||
const renderer = new WebGLRenderer(); | ||
|
||
if (layer === 'main') { | ||
renderer.registerPlugin(new Plugin3D()); | ||
renderer.registerPlugin(new PluginControl()); | ||
} | ||
|
||
return renderer; | ||
}; |
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,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "lib" | ||
}, | ||
"extends": "../../tsconfig.json", | ||
"include": ["src/**/*"] | ||
} |