cesium加载所有外部资源都需要服务器端允许跨域;解决方法在服务器端;
1若服务端可控:添加跨域头
2若服务器端不可控:添加代理服务器
nginx添加代理示例:
location /3dtiles{
include nginx_cors;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass >
cesium中可以将video标签作为材质赋予实体,实体贴地后会覆盖模型表面,达到视频影像融合的效果。
html video标签所支持的视频文件编码格式如下
展示效果:
本文简述了使用ContextCapture 44生成Cesium的3d tiles的过程。
Windows10 64位,GTX1050Ti
ContextCapture 447
巴黎某街区的无人机相片与控制点
按照 ContextCapture 软件的说明,一步步调整数据参数,进行三维模型的重建,此处 *** 作详见软件 *** 作说明;
模型生成时选择Cesium 3DTiles格式,等待程序生成即可
这个是我根据API及示例整理的历史轨迹播放的demo,其中重要的参数都做了注释,可以直接粘贴到cesium的模拟其中验证或做修改
//设定模拟时间的界限
var start = CesiumJulianDatefromDate(new Date(2021, 3, 2, 23,50,20));//朱利安时间=UTC=北京时间-8 2021-03-02 15:50:20
var stop = CesiumJulianDatefromDate(new Date(2021, 3, 2, 23,56,20));
//确保查看器在想要的时间
viewerclockstartTime = startclone();
viewerclockstopTime = stopclone();
viewerclockcurrentTime = startclone();
viewerclockclockRange = CesiumClockRangeCLAMPED; //达到终止时间后停止,LOOP_STOP:达到终止时间后重新循环,UNBOUNDED:达到终止时间后继续读秒
viewerclockmultiplier = 10;//初始运行速度
//将时间轴设置为模拟边界
viewertimelinezoomTo(start, stop);
//生成一个一条线
function computeCirclularFlight() {
var property = new CesiumSampledPositionProperty();
var dataSource = [{
'id':1,
'time':new Date(2021, 3, 2, 23,50,20),
'lng':12043413519859315,
'lat':30238649673375463,
},{
'id':2,
'time':new Date(2021, 3, 2, 23,51,20),
'lng':1204343605041504,
'lat':3023831135356134,
},{
'id':3,
'time':new Date(2021, 3, 2, 23,52,20),
'lng':12043460726737977,
'lat':30237908148974306,
},{
'id':4,
'time':new Date(2021, 3, 2, 23,53,20),
'lng':12043478429317476,
'lat':30237602268529127,
},{
'id':5,
'time':new Date(2021, 3, 2, 23,54,20),
'lng':1204349720478058,
'lat':30237282483409622,
},{
'id':6,
'time':new Date(2021, 3, 2, 23,55,20),
'lng':1204351720478058,
'lat':30236882483409622,
},{
'id':7,
'time':new Date(2021, 3, 2, 23,56,20),
'lng':1204353720478058,
'lat':30236482483409622,
}
];
for (var i = 0; i < 7; i ++) {
var time = CesiumJulianDatefromDate(dataSource[i]time);//每个点对应的时间
var position = CesiumCartesian3fromDegrees(dataSource[i]lng,dataSource[i]lat,100);
propertyaddSample(time, position);
}
return property;
}
//Compute the entity position property
var position = computeCirclularFlight();
//Actually create the entity
var entity = viewerentitiesadd({
//Set the entity availability to the same interval as the simulation time
availability: new CesiumTimeIntervalCollection([
new CesiumTimeInterval({
start: start,
stop: stop,
}),
]),
//Use our computed positions
position: position,
//Automatically compute orientation based on position movement
orientation: new CesiumVelocityOrientationProperty(position),
//Load the Cesium plane model to represent the entity
model: {
uri: "/SampleData/models/CesiumAir/Cesium_Airglb",//模型地址
minimumPixelSize: 64,
},
//Show the path as a pink line sampled in 1 second increments
path: {
resolution: 1,
material: new CesiumPolylineGlowMaterialProperty({
glowPower: 01,
color: CesiumColorYELLOW,
}),
width: 10,
},
});
//添加按钮从顶部查看路径
SandcastleaddDefaultToolbarButton("View Top Down", function () {
viewertrackedEntity = undefined;
viewerzoomTo(
viewerentities,
new CesiumHeadingPitchRange(0, CesiumMathtoRadians(-90))
);
});
//添加按钮从侧面查看路径
SandcastleaddToolbarButton("View Side", function () {
viewertrackedEntity = undefined;
viewerzoomTo(
viewerentities,
new CesiumHeadingPitchRange(
CesiumMathtoRadians(-90),
CesiumMathtoRadians(-15),
7500
)
);
});
//添加按钮来跟踪实体的移动
SandcastleaddToolbarButton("View Aircraft", function () {
viewertrackedEntity = entity;
});
//添加一个组合框来选择每个插值模式
SandcastleaddToolbarMenu(
[
{
text: "Interpolation: Linear Approximation",
onselect: function () {
entitypositionsetInterpolationOptions({
interpolationDegree: 1,
interpolationAlgorithm: CesiumLinearApproximation,
});
},
},
{
text: "Interpolation: Lagrange Polynomial Approximation",
onselect: function () {
entitypositionsetInterpolationOptions({
interpolationDegree: 5,
interpolationAlgorithm:
CesiumLagrangePolynomialApproximation,
});
},
},
{
text: "Interpolation: Hermite Polynomial Approximation",
onselect: function () {
entitypositionsetInterpolationOptions({
interpolationDegree: 2,
interpolationAlgorithm: CesiumHermitePolynomialApproximation,
});
},
},
],
"interpolationMenu"
);
以上就是关于cesium 加载地图、地形、模型不显示提示CORS policy错误全部的内容,包括:cesium 加载地图、地形、模型不显示提示CORS policy错误、Cesium 3DTiles转换工具、Cesium实现视频影像融合等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)