在react中单独加载s3m模型树不显示也不报错,而一模一样的代码在vue里面执行的话就可以加载出来??两个都是放在new Cesium.Viewer下面执行的
react 代码:(使用了几个路径都不行,然后创建了一个和vue一模一样的路径也不行,也显示不出来)
// const url="../../public/image/springTree.s3m";
// const url="./springTree.s3m";
// const url="../../mock/springTree.s3m";
const url="../../static/images/S3MData/springTree.s3m";
var positionL={lat:35.165667199,lon:117.509239482,height:330};
const postitionSM=new Cesium.Cartesian3.fromDegrees(positionL.lon, positionL.lat, positionL.height);
const s3mInstanceColc = new Cesium.S3MInstanceCollection(viewer.scene.context);
viewer.scene.primitives.add(s3mInstanceColc);
s3mInstanceColc.add(url,{
position:postitionSM,
color: Cesium.Color.RED
})
vue 代码:
const url="../../../static/images/S3MData/springTree.s3m";
var positionL={lat:35.165667199,lon:117.509239482,height:330};
const postitionSM=new Cesium.Cartesian3.fromDegrees(positionL.lon, positionL.lat, positionL.height);
const s3mInstanceColc = new Cesium.S3MInstanceCollection(viewer.scene.context);
viewer.scene.primitives.add(s3mInstanceColc);
s3mInstanceColc.add(url,{
position:postitionSM,
color: Cesium.Color.RED
})
vue运行出来效果: