Skip to content

Commit

Permalink
refactor: fix types of extension 3d
Browse files Browse the repository at this point in the history
  • Loading branch information
antv committed Aug 22, 2024
1 parent e913073 commit 88bebc4
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions packages/g6-extension-3d/src/elements/base-node-3d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ export abstract class BaseNode3D<S extends BaseNode3DStyleProps> extends BaseNod
return this.upsert('key', Mesh, this.getKeyStyle(attributes), container);
}

protected abstract getGeometry(attributes: Required<S>): GGeometry<any> | undefined;
protected abstract getGeometry(attributes: Required<S>): GGeometry<any>;

protected getMaterial(attributes: Required<S>): GMaterial<any> | undefined {
protected getMaterial(attributes: Required<S>): GMaterial<any> {
const { texture } = attributes;
const materialStyle = subStyleProps<Material>(attributes, 'material');
return createMaterial(this.plugin, materialStyle, texture);
Expand All @@ -63,6 +63,6 @@ export interface MeshStyleProps extends BaseStyleProps {
x?: number | string;
y?: number | string;
z?: number | string;
geometry?: GGeometry<any>;
material?: GMaterial<any>;
geometry: GGeometry<any>;
material: GMaterial<any>;
}
2 changes: 1 addition & 1 deletion packages/g6-extension-3d/src/elements/capsule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class Capsule extends BaseNode3D<CapsuleStyleProps> {
super(deepMix({}, { style: Capsule.defaultStyleProps }, options));
}

protected getGeometry(attributes: Required<CapsuleStyleProps>): GGeometry<any> | undefined {
protected getGeometry(attributes: Required<CapsuleStyleProps>): GGeometry<any> {
const size = this.getSize();
const { radius = size[0] / 2, height = size[1], heightSegments, sides } = attributes;
return createGeometry('capsule', this.device, CapsuleGeometry, { radius, height, heightSegments, sides });
Expand Down
2 changes: 1 addition & 1 deletion packages/g6-extension-3d/src/elements/cone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class Cone extends BaseNode3D<ConeStyleProps> {
super(deepMix({}, { style: Cone.defaultStyleProps }, options));
}

protected getGeometry(attributes: Required<ConeStyleProps>): GGeometry<any> | undefined {
protected getGeometry(attributes: Required<ConeStyleProps>): GGeometry<any> {
const size = this.getSize();
const {
baseRadius = size[0] / 2,
Expand Down
2 changes: 1 addition & 1 deletion packages/g6-extension-3d/src/elements/cube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class Cube extends BaseNode3D<CubeStyleProps> {
super(deepMix({}, { style: Cube.defaultStyleProps }, options));
}

protected getGeometry(attributes: Required<CubeStyleProps>): GGeometry<any> | undefined {
protected getGeometry(attributes: Required<CubeStyleProps>): GGeometry<any> {
const size = this.getSize();
const {
width = size[0],
Expand Down
2 changes: 1 addition & 1 deletion packages/g6-extension-3d/src/elements/cylinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class Cylinder extends BaseNode3D<CylinderStyleProps> {
super(deepMix({}, { style: Cylinder.defaultStyleProps }, options));
}

protected getGeometry(attributes: Required<CylinderStyleProps>): GGeometry<any> | undefined {
protected getGeometry(attributes: Required<CylinderStyleProps>): GGeometry<any> {
const size = this.getSize();
const { radius = size[0] / 2, height = size[1], heightSegments, capSegments } = attributes;
return createGeometry('cylinder', this.device, CylinderGeometry, { radius, height, heightSegments, capSegments });
Expand Down
2 changes: 1 addition & 1 deletion packages/g6-extension-3d/src/elements/plane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class Plane extends BaseNode3D<PlaneStyleProps> {
super(deepMix({}, { style: Plane.defaultStyleProps }, options));
}

protected getGeometry(attributes: Required<PlaneStyleProps>): GGeometry<any> | undefined {
protected getGeometry(attributes: Required<PlaneStyleProps>): GGeometry<any> {
const size = this.getSize();
const { width = size[0], depth = size[1], widthSegments, depthSegments } = attributes;
return createGeometry('plane', this.device, PlaneGeometry, { width, depth, widthSegments, depthSegments });
Expand Down
2 changes: 1 addition & 1 deletion packages/g6-extension-3d/src/elements/sphere.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class Sphere extends BaseNode3D<SphereStyleProps> {
super(deepMix({}, { style: Sphere.defaultStyleProps }, options));
}

protected getGeometry(attributes: Required<SphereStyleProps>): GGeometry<any> | undefined {
protected getGeometry(attributes: Required<SphereStyleProps>): GGeometry<any> {
const size = this.getSize();
const { radius = size[0] / 2, latitudeBands, longitudeBands } = attributes;
return createGeometry('sphere', this.device, SphereGeometry, { radius, latitudeBands, longitudeBands });
Expand Down
2 changes: 1 addition & 1 deletion packages/g6-extension-3d/src/elements/torus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class Torus extends BaseNode3D<TorusStyleProps> {
super(deepMix({}, { style: Torus.defaultStyleProps }, options));
}

protected getGeometry(attributes: Required<TorusStyleProps>): GGeometry<any> | undefined {
protected getGeometry(attributes: Required<TorusStyleProps>): GGeometry<any> {
const size = this.getSize();
const { tubeRadius = size[0] / 2, ringRadius = size[1] / 2, segments, sides } = attributes;
return createGeometry('torus', this.device, TorusGeometry, { tubeRadius, ringRadius, segments, sides });
Expand Down

0 comments on commit 88bebc4

Please sign in to comment.