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

Cast.bitmapData() fails #1

Open
eternauta1337 opened this issue Dec 25, 2014 · 2 comments
Open

Cast.bitmapData() fails #1

eternauta1337 opened this issue Dec 25, 2014 · 2 comments

Comments

@eternauta1337
Copy link
Contributor

Cast.bitmapData() fails to identify data that is of type ImageTexture (i.e. lines 278 and 279 are skipped) even tho in the debugger I'm seeing that data is of such type. I believe that this is because TS's instanceof operator is not as powerful as AS3's is operator and in this case is failing to identify the type.

In code:
https://github.com/awayjs/awayjs-display/blob/master/lib/utils/Cast.ts#L278

Stack Overflow comments:
http://stackoverflow.com/questions/12789231/class-type-check-with-typescript

@eternauta1337
Copy link
Contributor Author

The globe demo doesn't work because of this. Funny thing is, I've tried to identify all image datas that WOULD come into Cast.bitmapData() as ImageTexture and instead send them through this method:
private castBitmapDataCustom(data:any, forceImageTexture:boolean = false):BitmapData {
if(!forceImageTexture) {
return Cast.bitmapData(data);
}
else {
console.log("forcing from ImageTexture...");
data = ( data).htmlImageElement;
var imageElement:HTMLImageElement = data;
console.log("w: " + imageElement.width + ", h: " + imageElement.height);
var bitmapData:BitmapData = new BitmapData(imageElement.width, imageElement.height, true, 0x0);
bitmapData.draw(imageElement)
return bitmapData;
}
}

There is no error thrown this time while loading the assets, but there is one while rendering:
Uncaught TypeError: Failed to execute 'texImage2D' on 'WebGLRenderingContext': No function was found that matched the signature provided.
TextureWebGL line 74

@eternauta1337
Copy link
Contributor Author

About the TextureWebGL error, it seems that the line that uses instanceof is also failing.
https://github.com/awayjs/awayjs-stagegl/blob/master/lib/base/TextureWebGL.ts#L70

That is, while debugging, I see incoming data:any to be BitmapData, and the if is never entered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant