upraiseModel.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. ; (function (Cesium) {
  2. checkSkyScenery(Cesium);
  3. function upraiseModel(primitiveArr, option) {
  4. var defaultParam = {
  5. time: 10,
  6. height: 10,
  7. defaultHeight: 0
  8. }
  9. var options = defaultParam;
  10. if (option) {
  11. if (typeof option == 'object') {
  12. options = Object.assign(defaultParam, option);
  13. }
  14. }
  15. var everyH = options.height / (options.time * 1000 / 10);
  16. var index = 0;
  17. var xh = setInterval(function () {
  18. primitiveArr.map(function (item) {
  19. // // var t = (6378137 + everyH * index + item.geometryInstances.geometry._height) / (6378137 + item.geometryInstances.geometry._height);
  20. var t = (6378137 + everyH * index + options.defaultHeight) / (6378137 + options.defaultHeight);
  21. item.modelMatrix = Cesium.Matrix4.fromScale(new Cesium.Cartesian3(t, t, t));
  22. // const translation = Cesium.Matrix4.fromTranslation(new Cesium.Cartesian3(everyH * index, 0,0))
  23. // Cesium.Matrix4.multiply(item.modelMatrix, translation, item.modelMatrix)
  24. })
  25. index += 1;
  26. if (index > options.time * 100) {
  27. clearInterval(xh);
  28. }
  29. }, 10);
  30. return xh;
  31. }
  32. function destoryUpraise(interval) {
  33. clearInterval(interval);
  34. }
  35. Cesium.upraiseModel = upraiseModel;
  36. Cesium.destoryUpraise = destoryUpraise;
  37. }(SkyScenery))