Skip to content

Commit

Permalink
fix: webgl renderer has logical exception when updating attributes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
wang1212 authored Sep 9, 2024
1 parent e0f8abe commit 61ef85b
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-boxes-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@antv/g-plugin-device-renderer': patch
---

fix: webgl renderer has logical exception when updating attributes
4 changes: 4 additions & 0 deletions packages/g-plugin-device-renderer/src/drawcalls/Image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ export class ImageDrawcall extends Instanced {
name: string,
value: any,
) {
if (objects.length === 0) {
return;
}

super.updateAttribute(objects, startIndex, name, value);

this.updateBatchedAttribute(objects, startIndex, name, value);
Expand Down
10 changes: 10 additions & 0 deletions packages/g-plugin-device-renderer/src/drawcalls/Instanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,16 @@ export abstract class Instanced {
this.geometryDirty = true;
}
}

// fix https://github.com/antvis/G/issues/1768
if (this.geometryDirty === true && this.objects.length !== 0) {
if (this.geometry) {
this.geometry.destroy();
}
this.createGeometry(this.objects);

this.geometryDirty = false;
}
}

changeRenderOrder(object: DisplayObject, renderOrder: number) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ export class InstancedFillDrawcall extends Instanced {
name: string,
value: any,
): void {
if (objects.length === 0) {
return;
}

super.updateAttribute(objects, startIndex, name, value);

this.updateBatchedAttribute(objects, startIndex, name, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@ export class InstancedLineDrawcall extends Instanced {
name: string,
value: any,
) {
if (objects.length === 0) {
return;
}

super.updateAttribute(objects, startIndex, name, value);

this.updateBatchedAttribute(objects, startIndex, name, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ export class InstancedPathDrawcall extends Instanced {
name: string,
value: any,
) {
if (objects.length === 0) {
return;
}

super.updateAttribute(objects, startIndex, name, value);

this.updateBatchedAttribute(objects, startIndex, name, value);
Expand Down
4 changes: 4 additions & 0 deletions packages/g-plugin-device-renderer/src/drawcalls/Mesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export class MeshDrawcall extends Instanced {
name: string,
value: any,
): void {
if (objects.length === 0) {
return;
}

super.updateAttribute(objects, startIndex, name, value);
this.updateBatchedAttribute(objects, startIndex, name, value);
}
Expand Down
4 changes: 4 additions & 0 deletions packages/g-plugin-device-renderer/src/drawcalls/SDF.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ export class SDFDrawcall extends Instanced {
name: string,
value: any,
) {
if (objects.length === 0) {
return;
}

super.updateAttribute(objects, startIndex, name, value);

this.updateBatchedAttribute(objects, startIndex, name, value);
Expand Down
2 changes: 2 additions & 0 deletions packages/g-plugin-device-renderer/src/drawcalls/Text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ export class TextDrawcall extends Instanced {
return;
}

super.updateAttribute(objects, startIndex, name, value);

if (
name === 'text' ||
name === 'fontFamily' ||
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"compilerOptions": {
"outDir": "./",
"rootDir": ".",
"outDir": ".",
"module": "ESNext",
"target": "es5",
"jsx": "react",
"moduleResolution": "node",
"experimentalDecorators": true,
"declaration": true,
"sourceMap": true,
"sourceRoot": ".",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
Expand Down

0 comments on commit 61ef85b

Please sign in to comment.