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

feat: export shapeBuildCommandMap to allow custom shape primitives #10508

Merged
merged 9 commits into from
Jun 18, 2024
8 changes: 4 additions & 4 deletions src/scene/graphics/shared/utils/buildContextBatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type { GpuGraphicsContext } from '../GraphicsContextSystem';
import type { GraphicsPath } from '../path/GraphicsPath';
import type { ShapePath } from '../path/ShapePath';

const buildMap: Record<string, ShapeBuildCommand> = {
export const shapeBuildCommandMap: Record<string, ShapeBuildCommand> = {
ShukantPal marked this conversation as resolved.
Show resolved Hide resolved
rectangle: buildRectangle,
polygon: buildPolygon,
triangle: buildTriangle,
Expand Down Expand Up @@ -86,7 +86,7 @@ function addTextureToGeometryData(

const points: number[] = [];

const build = buildMap.rectangle;
const build = shapeBuildCommandMap.rectangle;

const rect = tempRect;

Expand Down Expand Up @@ -158,7 +158,7 @@ function addShapePathToGeometryData(

const points: number[] = [];

const build = buildMap[shape.type];
const build = shapeBuildCommandMap[shape.type];

// TODO - this can be cached...
// TODO - THIS IS DONE TWICE!!!!!!
Expand Down Expand Up @@ -261,7 +261,7 @@ function getHoleArrays(shape: ShapePath)
// TODO - need to transform the points via there transform here..
const holePoints: number[] = [];

const holeBuilder = buildMap[holePrimitive.type] as ShapeBuildCommand;
const holeBuilder = shapeBuildCommandMap[holePrimitive.type] as ShapeBuildCommand;

holeBuilder.build(holePrimitive, holePoints);

Expand Down
Loading