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

Re add cached lines when updating #5608

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class PaintBrush {
paintOpt
);
if (newCacheValue) {
console.log('new cache value for', cacheId);
this.renderCache.setToCurrentFrame(cacheId, newCacheValue);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export class ThreeRenderer implements ObjectRenderer<CacheValue> {
alpha: true,
});
this.renderer.setPixelRatio(devicePixelRatio);
this.renderer.sortObjects = false;
}

onResize(rect: Rect) {
Expand Down Expand Up @@ -323,7 +324,7 @@ export class ThreeRenderer implements ObjectRenderer<CacheValue> {
if (!cachedLine && !paintOpt.visible) return null;

const {visible, width} = paintOpt;

let line: THREE.Mesh;
if (!cachedLine) {
const newColor = createOpacityAdjustedColor(
this.backgroundColor,
Expand All @@ -332,37 +333,33 @@ export class ThreeRenderer implements ObjectRenderer<CacheValue> {
);
const geometry = new THREE.BufferGeometry();
const material = new THREE.LineBasicMaterial({color: newColor});
const line = new THREE.Mesh(geometry, material);
line = new THREE.Mesh(geometry, material);
material.visible = visible;
updateThickPolylineGeometry(geometry, polyline, width);
this.scene.add(line);
return {type: CacheType.LINE, data: polyline, obj3d: line, width};
} else {
line = cachedLine.obj3d;
const {data: prevPolyline, width: prevWidth} = cachedLine;
this.scene.remove(line);
const geomUpdated = updateObject(
this.backgroundColor,
line,
(geometry) => {
if (
width !== prevWidth ||
!prevPolyline ||
!arePolylinesEqual(prevPolyline, polyline)
) {
updateThickPolylineGeometry(geometry, polyline, width);
}
return geometry;
},
paintOpt
);
if (!geomUpdated) return cachedLine;
}

const {data: prevPolyline, obj3d: line, width: prevWidth} = cachedLine;
const geomUpdated = updateObject(
this.backgroundColor,
line,
(geometry) => {
if (
width !== prevWidth ||
!prevPolyline ||
!arePolylinesEqual(prevPolyline, polyline)
) {
updateThickPolylineGeometry(geometry, polyline, width);
}
return geometry;
},
paintOpt
);
if (!geomUpdated) return cachedLine;

return {
type: CacheType.LINE,
data: polyline,
obj3d: line,
width,
};
this.scene.add(line);
return {type: CacheType.LINE, data: polyline, obj3d: line, width};
}

private createMesh(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export class SeriesLineView extends DataDrawable {
}

redraw() {
console.log('redrawing', this.series);
for (const series of this.series) {
const map = this.getMetadataMap();
const metadata = map[series.id];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ export class LineChartComponent
* with `recoverRendererIfNeeded`.
*/
private updateLineChart() {
console.log('update line chart');
this.recoverRendererIfNeeded();
if (!this.lineChart || this.disableUpdate) return;

Expand All @@ -437,6 +438,7 @@ export class LineChartComponent
}

if (this.isDataUpdated) {
console.log('is data updated', this.seriesData);
this.isDataUpdated = false;
this.lineChart.setData(this.seriesData);
}
Expand Down