本文参考了cesium的自定义texture实现,在此基础上做了修改,引入html5的视频进行渲染,实测比使用视频作为材质效率略有优化,且更具灵活性,利于对视频进行二次处理,废话不多说,代码如下:
var PrimitiveTexture= (
function () {
var vertexShader;
var fragmentShader;
var materialShader;
var video;
function _(options) {
vertexShader = getVS();
fragmentShader = getFS();
materialShader = getMS();
video = options.video;
var postionsTemp = [];
//纹理坐标,调整纹理坐标顺序即可完成贴图的旋转
var stsTemp = [0,0,0,1,1,1,1,0];
//索引数组
var indicesTesm = [0,1,2,0,2,3];
for (var i = 0; i < options.Cartesians.length; i++) {
postionsTemp.push(options.Cartesians[i].x);
postionsTemp.push(options.Cartesians[i].y);
postionsTemp.push(options.Cartesians[i].z);
}
console.log("pos:"+postionsTemp)
this.positionArr = new Flo