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

Add an option to use html5 canvas as a rectangle material #2509

Closed
cesium-user2 opened this issue Feb 23, 2015 · 5 comments · Fixed by #2667
Closed

Add an option to use html5 canvas as a rectangle material #2509

cesium-user2 opened this issue Feb 23, 2015 · 5 comments · Fixed by #2667
Assignees

Comments

@cesium-user2
Copy link

Canvas has very useful capabilities and it would be great to be able to use it directly as a material.

I thought of Something like this:

var entity = viewer.entities.add({...});
var canvas= document.querySelector('#canvas');
entity.rectangle.material=canvas;

For now one can use code that looks like this:

var entity = viewer.entities.add({...});
var canvas= document.querySelector('#canvas');
entity.rectangle.material=canvas.toDataURL();

but this way is not very efficient...

@mramato mramato self-assigned this Feb 23, 2015
@mramato
Copy link
Contributor

mramato commented Feb 23, 2015

I'm surprised this doesn't work already, but I agree we should support it.

@alberto-acevedo
Copy link

I would like to know the status of supporting canvas with rectangle geometries. The use of canvas. in materials instead of toDataURL() will greatly improve the performance of my Cesium application.

Thanks,

Alberto

mramato added a commit that referenced this issue Apr 27, 2015
An often requested feature on the mailing list, this change allows you to
assign a canvas directly to an Entity material property (and also low
level material uniforms).

Fixes #2509
@mramato
Copy link
Contributor

mramato commented Apr 27, 2015

@alberto-acevedo thanks for the reminder. You caught me on a good day so I was able to open up #2667 which adds this capability.

@alberto-acevedo
Copy link

I just tried the new tml5 canvas as a rectangle material capability but there seems to be a problem when rendering more than one canvas. The first time I render a canvas it works fine. But when I tried to render a different canvas, what is rendered is the first canvas. Is it something I'm doing wrong or is this a bug? My code is below:

var multiPointRectangle = new Cesium.RectangleGraphics();
var multiPointMaterial = new Cesium.ImageMaterialProperty();
multiPointMaterial.image = canvas1; //Do not works fine in subsequent calls with different canvas object
//multiPointMaterial.image = canvas1.toDataURL(); //--> works fine in subsequent calls with different canvas object
multiPointRectangle.material = multiPointMaterial ;
multiPointRectangle.coordinates = ....

var entity = new Cesium.Entity();
entity. _id = "someId";
entity.rectangle = multiPointRectangle;
.... add entity to the viewer entity collection

@mramato
Copy link
Contributor

mramato commented May 4, 2015

You might be running into the issue described in #2633. I'll see if I can reproduce and confirm.

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

Successfully merging a pull request may close this issue.

3 participants