Skip to content

Commit

Permalink
fix: Improve "isLoadedCallback" to not return true before first draw …
Browse files Browse the repository at this point in the history
…of layer not only just when data are loaded. (#1656)
  • Loading branch information
nilscb authored Sep 15, 2023
1 parent 77ea355 commit 3875f8b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,17 @@ const defaultProps = {

// This is a private layer used only by the composite Map3DLayer
export default class privateLayer extends Layer<privateLayerProps> {
get isLoaded(): boolean {
return this.state["isLoaded"] ?? false;
}

initializeState(context: DeckGLLayerContext): void {
const { gl } = context;
const [model_mesh, mesh_lines_model] = this._getModels(gl);
this.setState({ models: [model_mesh, mesh_lines_model] });
this.setState({
models: [model_mesh, mesh_lines_model],
isLoaded: false,
});
}

shouldUpdateState({
Expand Down Expand Up @@ -254,6 +261,10 @@ export default class privateLayer extends Layer<privateLayerProps> {
if (!this.props.depthTest) {
gl.enable(gl.DEPTH_TEST);
}

if (!this.state["isLoaded"]) {
this.setState({ ...this.state, isLoaded: true });
}
}

decodePickingColor(): number {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,17 @@ const defaultProps = {

// This is a private layer used only by the composite Map3DLayer
export default class privateMapLayer extends Layer<privateMapLayerProps> {
get isLoaded(): boolean {
return this.state["isLoaded"] ?? false;
}

initializeState(context: DeckGLLayerContext): void {
const { gl } = context;
const [model_mesh, mesh_lines_model] = this._getModels(gl);
this.setState({ models: [model_mesh, mesh_lines_model] });
this.setState({
models: [model_mesh, mesh_lines_model],
isLoaded: false,
});
}

shouldUpdateState({
Expand Down Expand Up @@ -277,6 +284,10 @@ export default class privateMapLayer extends Layer<privateMapLayerProps> {
if (this.props.gridLines) {
mesh_lines_model.draw();
}

if (!this.state["isLoaded"]) {
this.setState({ ...this.state, isLoaded: true });
}
}

decodePickingColor(): number {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,14 @@ const defaultProps = {

// This is a private layer used only by the composite TriangleLayer
export default class PrivateTriangleLayer extends Layer<PrivateTriangleLayerProps> {
get isLoaded(): boolean {
return this.state["isLoaded"] ?? false;
}

initializeState(context: DeckGLLayerContext): void {
const { gl } = context;
const [triangleModel, lineMode] = this._getModels(gl);
this.setState({ models: [triangleModel, lineMode] });
this.setState({ models: [triangleModel, lineMode], isLoaded: false });
}

shouldUpdateState({
Expand Down Expand Up @@ -166,6 +170,10 @@ export default class PrivateTriangleLayer extends Layer<PrivateTriangleLayerProp
if (!this.props.depthTest) {
gl.enable(GL.DEPTH_TEST);
}

if (!this.state["isLoaded"]) {
this.setState({ ...this.state, isLoaded: true });
}
}

decodePickingColor(): number {
Expand Down

0 comments on commit 3875f8b

Please sign in to comment.