canvas can't show as material

1. A concise explanation of the problem you’re experiencing.

I use canvas as txture material ,but can’t show ,i use png picture will work.

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

var canvas = document.getElementById(‘canvas’);

var ctx = canvas.getContext(‘2d’);

ctx.beginPath();

ctx.moveTo(0, 0);

ctx.lineTo(300, 150);

ctx.stroke();

var czml = [{

“id”: “document”,

“name”: “CZML WALL”,

“version”: “1.0”

}, {

“id”: “wall”,

“wall”: {

“positions”: {

“cartographicDegrees”: [-115.0, 50.0, 10000000, -112.5, 50.0, 10000000

]

},

“material”: {

“image”: {

“image”: {

“uri”: canvas.toDataURL(),

},

//“image”: { “uri”: ‘./SampleData/004.png’ } ,

“color”: {

“rgba”: [255, 255, 255, 150]

}

}

},

“fill”: true

}

}];

var dataSourcePromise = Cesium.CzmlDataSource.load(czml);

viewer.dataSources.add(dataSourcePromise);

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I want show a ruler

4. The Cesium version you’re using, your operating system and browser.

cesium 1.45

os win10

browser google

Hi,

You can set the material to the context dynamically:

var dataSourcePromise = Cesium.CzmlDataSource.load(czml);

dataSourcePromise.then(function (dataSource) {

viewer.dataSources.add(dataSource);

var entity = dataSource.entities.getById(‘wall’);

entity.wall.material = canvas;

});

``

Thanks,

Gabby