Skip to content

Commit

Permalink
fix render test
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaoji Chen committed Jun 4, 2019
1 parent 4200523 commit 32152f9
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions modules/layers/src/bitmap-layer/bitmap-layer.js
Expand Up @@ -38,7 +38,7 @@ const DEFAULT_TEXTURE_PARAMETERS = {
};

const defaultProps = {
image: {type: 'object', value: null, async: true},
image: null,
bounds: {type: 'array', value: [1, 0, 0, 1], compare: true},
fp64: false,

Expand Down Expand Up @@ -93,7 +93,7 @@ export default class BitmapLayer extends Layer {
}

if (props.image !== oldProps.image) {
this.loadTexture();
this.loadTexture(props.image);
}

const attributeManager = this.getAttributeManager();
Expand Down Expand Up @@ -200,24 +200,22 @@ export default class BitmapLayer extends Layer {
}
}

loadTexture() {
loadTexture(image) {
if (typeof image === 'string') {
image = loadImage(image);
}
if (image instanceof Promise) {
image.then(data => this.loadTexture(data));
return;
}

const {gl} = this.context;
const {image} = this.props;

if (this.state.bitmapTexture) {
this.state.bitmapTexture.delete();
}

if (typeof image === 'string') {
loadImage(image).then(data => {
this.setState({
bitmapTexture: new Texture2D(gl, {
data,
parameters: DEFAULT_TEXTURE_PARAMETERS
})
});
});
} else if (image instanceof Texture2D) {
if (image instanceof Texture2D) {
this.setState({bitmapTexture: image});
} else if (
// browser object
Expand Down

0 comments on commit 32152f9

Please sign in to comment.