Advertisement
mk88vvv

Untitled

Dec 8th, 2022 (edited)
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 2.30 KB | Source Code | 0 0
  1. const viewer = new Cesium.Viewer("cesiumContainer", {
  2.   infoBox: false,
  3.   selectionIndicator: false,
  4.   shadows: true,
  5.   shouldAnimate: true,
  6. });
  7.  
  8. let entity;
  9. let entity2;
  10. //положение entity
  11. const height=0;
  12. const position = Cesium.Cartesian3.fromDegrees(
  13.   -123.0744619,
  14.   44.0503706,
  15.   height,
  16. );
  17. //положение entity2
  18. const position2 = Cesium.Cartesian3.fromDegrees(
  19.   -123.0745145,
  20.   44.05027029,
  21.   height,
  22. );
  23. const heading = Cesium.Math.toRadians(135);
  24. const pitch = 0;
  25. const roll = 0;
  26. const hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
  27. const orientation = Cesium.Transforms.headingPitchRollQuaternion(position,hpr);
  28.  
  29.   //
  30.  
  31. //entities
  32. entity = viewer.entities.add({
  33.   position: position,
  34.   orientation: orientation,
  35.   model: {
  36.     uri: "../SampleData/models/GroundVehicle/GroundVehicle.glb",
  37.     minimumPixelSize: 128,
  38.     maximumScale: 20000,  
  39.     },
  40.   });
  41.  
  42. entity2 = viewer.entities.add({
  43.  position: position2,
  44.  orientation: orientation,
  45.  model: {
  46.    uri: "../SampleData/models/GroundVehicle/GroundVehicle.glb",
  47.    minimumPixelSize: 128,
  48.    maximumScale: 20000,
  49.    },
  50.   });
  51. //outlines
  52. var handler = new Cesium.ScreenSpaceEventHandler(Cesium.Scene.canvas);
  53.   handler.setInputAction(function(movement) {        
  54.          var mousePosition = Cesium.Cartesian3.clone(movement.position);
  55.           entity.model.silhouetteAlpha = 1.0;
  56.           entity.model.silhouetteSize = 1.5;
  57.           entity.model.silhouetteColor = Cesium.Color.AQUAMARINE;
  58.           console.log("Машина выбрана");
  59.       }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
  60.  
  61. var handler2 = new Cesium.ScreenSpaceEventHandler(Cesium.Scene.canvas);
  62.   handler.setInputAction(function(movement) {        
  63.          var mousePosition = Cesium.Cartesian3.clone(movement.position);
  64.           entity.model.silhouetteSize = 0;
  65.           console.log("Машина больше не выбрана");
  66.       }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
  67.  
  68.  
  69.  
  70.  
  71. //buttons
  72. //move to entity
  73. Sandcastle.addToggleButton("entity", viewer.zoomTo(viewer.entities), function (
  74.   checked
  75. ) {
  76.   viewer.zoomTo(viewer.entities);
  77. });
  78. //move to entity2
  79. Sandcastle.addToggleButton("entity2", viewer.zoomTo(entity2), function (
  80.   checked
  81. ) {
  82.   viewer.zoomTo(entity2);
  83. });
  84.   viewer.trackedEntity = entity;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement