3D टाइल रेंडरर के साथ काम करना

फ़ोटोरियलिस्टिक 3D टाइल OGC स्टैंडर्ड glTF फ़ॉर्मैट में होती हैं. इसका मतलब है कि आपके पास किसी भी ऐसे रेंडरर का इस्तेमाल करने का विकल्प है जो 3D विज़ुअलाइज़ेशन बनाने के लिए OGC 3D Tiles की खासियतों के साथ काम करता हो. उदाहरण के लिए, Cesium 3D विज़ुअलाइज़ेशन को रेंडर करने के लिए एक बुनियादी ओपन सोर्स लाइब्रेरी है.

CesiumJS के साथ काम करें

CesiumJS, वेब पर 3D विज़ुअलाइज़ेशन के लिए एक ओपन सोर्स JavaScript लाइब्रेरी है. CesiumJS का इस्तेमाल करने के बारे में ज़्यादा जानकारी के लिए, CsiumJS के बारे में जानें पर जाएं.

उपयोगकर्ता नियंत्रण

CesiumJS टाइल रेंडरर में, उपयोगकर्ता के कंट्रोल का एक स्टैंडर्ड सेट होता है.

ऐक्शन ब्यौरा
पैन व्यू लेफ़्ट क्लिक करके खींचें और छोड़ें
ज़ूम व्यू राइट क्लिक करके खींचें या माउस व्हील पर स्क्रोल करें
व्यू घुमाएं Ctrl + लेफ़्ट/राइट क्लिक करके खींचें और छोड़ें या बीच में क्लिक करके खींचें और छोड़ें

सबसे सही तरीके

CesiumJS 3D लोड होने में लगने वाले समय को कम करने के लिए, कई तरीके अपनाए जा सकते हैं. उदाहरण के लिए:

  • अपने रेंडरिंग एचटीएमएल में इस स्टेटमेंट को जोड़कर, एक साथ किए जाने वाले अनुरोधों को चालू करें:

    Cesium.RequestScheduler.requestsByServer["tile.googleapis.com:443"] = <REQUEST_COUNT>
    

    REQUEST_COUNT जितना ज़्यादा होगा, टाइल उतनी ही जल्दी लोड होंगी. हालांकि, किसी ऐसे Chrome ब्राउज़र में लोड होने पर जिसमें REQUEST_COUNT 10 से ज़्यादा और कैश मेमोरी बंद है, आपको Chrome से जुड़ी कोई समस्या हो सकती है. इस्तेमाल के ज़्यादातर मामलों में, बेहतर परफ़ॉर्मेंस के लिए हम 18 के REQUEST_COUNT इस्तेमाल करने का सुझाव देते हैं.

  • जानकारी के लेवल को स्किप करने की सुविधा चालू करें. ज़्यादा जानकारी के लिए, यह Cesium समस्या देखें.

showCreditsOnScreen: true को चालू करके, यह पक्का करें कि डेटा एट्रिब्यूशन सही तरीके से दिखाए जा रहे हैं. ज़्यादा जानकारी के लिए, नीतियां देखें.

मेट्रिक रेंडर करना

फ़्रेमरेट जानने के लिए, देखें कि हर सेकंड में कितनी बार requestAnimationFrame कॉल किया जाता है.

फ़्रेम के इंतज़ार के समय का हिसाब लगाने का तरीका जानने के लिए, PerformanceDisplay क्लास पर एक नज़र डालें.

CesiumJS रेंडरर के उदाहरण

रूट टाइलसेट यूआरएल की मदद से, Map Tiles API की 3D Tiles के साथ CesiumJS रेंडरर का इस्तेमाल किया जा सकता है.

सामान्य उदाहरण

नीचे दिए गए उदाहरण में, CesiumJS रेंडरर शुरू किया जाता है और फिर रूट टाइलसेट को लोड किया जाता है.

<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <title>CesiumJS 3D Tiles Simple Demo</title>
  <script src="https://ajax.googleapis.com/ajax/libs/cesiumjs/1.105/Build/Cesium/Cesium.js"></script>
  <link href="https://ajax.googleapis.com/ajax/libs/cesiumjs/1.105/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
</head>
<body>
  <div id="cesiumContainer"></div>
  <script>

    // Enable simultaneous requests.
    Cesium.RequestScheduler.requestsByServer["tile.googleapis.com:443"] = 18;

    // Create the viewer.
    const viewer = new Cesium.Viewer('cesiumContainer', {
      imageryProvider: false,
      baseLayerPicker: false,
      geocoder: false,
      globe: false,
      // https://cesium.com/blog/2018/01/24/cesium-scene-rendering-performance/#enabling-request-render-mode
      requestRenderMode: true,
    });

    // Add 3D Tiles tileset.
    const tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
      url: "https://tile.googleapis.com/v1/3dtiles/root.json?key=YOUR_API_KEY",
      // This property is needed to appropriately display attributions
      // as required.
      showCreditsOnScreen: true,
    }));
  </script>
</body>

requestRenderMode के बारे में जानकारी के लिए, अनुरोध रेंडर मोड चालू करना देखें.

एचटीएमएल पेज यहां दिखाए गए तरीके से रेंडर होता है.

Places API इंटिग्रेशन

ज़्यादा जानकारी पाने के लिए, Locations API के साथ CesiumJS का इस्तेमाल किया जा सकता है. जगहों के व्यूपोर्ट पर जाने के लिए, ऑटोकंप्लीट विजेट का इस्तेमाल किया जा सकता है. इस उदाहरण में जगहें ऑटोकंप्लीट एपीआई का इस्तेमाल किया गया है, जिसे इन निर्देशों का पालन करके चालू किया गया है. साथ ही, Maps JavaScript API का इस्तेमाल किया गया है, जिसे इन निर्देशों का पालन करके चालू किया गया है.

<!DOCTYPE html>
<head>
 <meta charset="utf-8" />
 <title>CesiumJS 3D Tiles Places API Integration Demo</title>
 <script src="https://ajax.googleapis.com/ajax/libs/cesiumjs/1.105/Build/Cesium/Cesium.js"></script>
 <link href="https://ajax.googleapis.com/ajax/libs/cesiumjs/1.105/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
</head>
<body>
 <label for="pacViewPlace">Go to a place: </label>
 <input
   type="text"
   id="pacViewPlace"
   name="pacViewPlace"
   placeholder="Enter a location..."
   style="width: 300px"
 />
 <div id="cesiumContainer"></div>
 <script>
   // Enable simultaneous requests.
   Cesium.RequestScheduler.requestsByServer["tile.googleapis.com:443"] = 18;

   // Create the viewer.
   const viewer = new Cesium.Viewer("cesiumContainer", {
     imageryProvider: false,
     baseLayerPicker: false,
     requestRenderMode: true,
     geocoder: false,
     globe: false,
   });

   // Add 3D Tiles tileset.
   const tileset = viewer.scene.primitives.add(
     new Cesium.Cesium3DTileset({
       url: "https://tile.googleapis.com/v1/3dtiles/root.json?key=YOUR_API_KEY",
       // This property is required to display attributions as required.
       showCreditsOnScreen: true,
     })
   );

   const zoomToViewport = (viewport) => {
     viewer.entities.add({
       polyline: {
         positions: Cesium.Cartesian3.fromDegreesArray([
           viewport.getNorthEast().lng(), viewport.getNorthEast().lat(),
           viewport.getSouthWest().lng(), viewport.getNorthEast().lat(),
           viewport.getSouthWest().lng(), viewport.getSouthWest().lat(),
           viewport.getNorthEast().lng(), viewport.getSouthWest().lat(),
           viewport.getNorthEast().lng(), viewport.getNorthEast().lat(),
         ]),
         width: 10,
         clampToGround: true,
         material: Cesium.Color.RED,
       },
     });
     viewer.flyTo(viewer.entities);
   };

   function initAutocomplete() {
     const autocomplete = new google.maps.places.Autocomplete(
       document.getElementById("pacViewPlace"),
       {
         fields: [
           "geometry",
           "name",
         ],
       }
     );
     autocomplete.addListener("place_changed", () => {
       viewer.entities.removeAll();
       const place = autocomplete.getPlace();
       if (!place.geometry || !place.geometry.viewport) {
         window.alert("No viewport for input: " + place.name);
         return;
       }
       zoomToViewport(place.geometry.viewport);
     });
   }
 </script>
 <script
   async=""
   src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places&callback=initAutocomplete"
 ></script>
</body>

रोटेटिंग ड्रोन व्यू

टाइलसेट में जाकर, ऐनिमेट करने के लिए कैमरे को कंट्रोल किया जा सकता है. इस ऐनिमेशन को Places API और Elevation API के साथ इस्तेमाल करने पर, आपकी पसंद की किसी भी जगह पर मौजूद इंटरैक्टिव ड्रोन फ़्लाईओवर की नकल की जाती है.

यह कोड सैंपल आपको उस जगह के आस-पास ले जाता है जिसे आपने 'ऑटोकंप्लीट' विजेट में चुना था.

<!DOCTYPE html>
<head>
  <meta charset="utf-8" />
  <title>CesiumJS 3D Tiles Rotating Drone View Demo</title>
  <script src="https://ajax.googleapis.com/ajax/libs/cesiumjs/1.105/Build/Cesium/Cesium.js"></script>
  <link href="https://ajax.googleapis.com/ajax/libs/cesiumjs/1.105/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
</head>
<body>
  <label for="pacViewPlace">Go to a place: </label>
  <input type="text" id="pacViewPlace" name="pacViewPlace" placeholder="Enter a location..." style="width: 300px" />
  <div id="cesiumContainer"></div>
  <script>
    // Enable simultaneous requests.
    Cesium.RequestScheduler.requestsByServer["tile.googleapis.com:443"] = 18;

    // Create the viewer and remove unneeded options.
    const viewer = new Cesium.Viewer("cesiumContainer", {
      imageryProvider: false,
      baseLayerPicker: false,
      homeButton: false,
      fullscreenButton: false,
      navigationHelpButton: false,
      vrButton: false,
      sceneModePicker: false,
      geocoder: false,
      globe: false,
      infobox: false,
      selectionIndicator: false,
      timeline: false,
      projectionPicker: false,
      clockViewModel: null,
      animation: false,
      requestRenderMode: true,
    });

    // Add 3D Tile set.
    const tileset = viewer.scene.primitives.add(
      new Cesium.Cesium3DTileset({
        url: "https://tile.googleapis.com/v1/3dtiles/root.json?key=YOUR_API_KEY",
        // This property is required to display attributions.
        showCreditsOnScreen: true,
      })
    );

    // Point the camera at a location and elevation, at a viewport-appropriate distance.
    function pointCameraAt(location, viewport, elevation) {
      const distance = Cesium.Cartesian3.distance(
        Cesium.Cartesian3.fromDegrees(
          viewport.getSouthWest().lng(), viewport.getSouthWest().lat(), elevation),
        Cesium.Cartesian3.fromDegrees(
          viewport.getNorthEast().lng(), viewport.getNorthEast().lat(), elevation)
      ) / 2;
      const target = new Cesium.Cartesian3.fromDegrees(location.lng(), location.lat(), elevation);
      const pitch = -Math.PI / 4;
      const heading = 0;
      viewer.camera.lookAt(target, new Cesium.HeadingPitchRange(heading, pitch, distance));
    }

    // Rotate the camera around a location and elevation, at a viewport-appropriate distance.
    let unsubscribe = null;
    function rotateCameraAround(location, viewport, elevation) {
      if(unsubscribe) unsubscribe();
      pointCameraAt(location, viewport, elevation);
      unsubscribe = viewer.clock.onTick.addEventListener(() => {
        viewer.camera.rotate(Cesium.Cartesian3.UNIT_Z);
      });
    }

    function initAutocomplete() {
      const autocomplete = new google.maps.places.Autocomplete(
        document.getElementById("pacViewPlace"), {
          fields: [
            "geometry",
            "name",
          ],
        }
      );
      
      autocomplete.addListener("place_changed", async () => {
        const place = autocomplete.getPlace();
        
        if (!(place.geometry && place.geometry.viewport && place.geometry.location)) {
          window.alert(`Insufficient geometry data for place: ${place.name}`);
          return;
        }
        // Get place elevation using the ElevationService.
        const elevatorService = new google.maps.ElevationService();
        const elevationResponse =  await elevatorService.getElevationForLocations({
          locations: [place.geometry.location],
        });

        if(!(elevationResponse.results && elevationResponse.results.length)){
          window.alert(`Insufficient elevation data for place: ${place.name}`);
          return;
        }
        const elevation = elevationResponse.results[0].elevation || 10;

        rotateCameraAround(
          place.geometry.location,
          place.geometry.viewport,
          elevation
        );
      });
    }
  </script>
  <script async src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places&callback=initAutocomplete"></script>
</body>

पॉलीलाइन और लेबल बनाएं

यह कोड सैंपल बताता है कि मैप में पॉलीलाइन और लेबल कैसे जोड़े जाएं. ड्राइविंग और पैदल चलने के दिशा-निर्देश दिखाने या प्रॉपर्टी की सीमाएं दिखाने या ड्राइविंग और पैदल चलने की अवधि का हिसाब लगाने के लिए, मैप पर पॉलीलाइन जोड़ें. सीन को रेंडर किए बिना भी एट्रिब्यूट मिल सकते हैं.

आप लोगों को आस-पास की चुनिंदा जगहों की सैर पर ले जा सकते हैं या आस-पास की ऐसी प्रॉपर्टी दिखा सकते हैं जो फ़िलहाल बिक रही हैं. इसके बाद, आप सीन में बिलबोर्ड जैसे 3D चीज़ें जोड़ सकते हैं.

आपके पास यात्रा की खास जानकारी देने का विकल्प होता है. इसमें, देखी गई प्रॉपर्टी की जानकारी शामिल होती है और चीज़ों को वर्चुअल ऑब्जेक्ट में दिखाया जाता है.

<!DOCTYPE html>
<head>
  <meta charset="utf-8" />
  <title>CesiumJS 3D Tiles Polyline and Label Demo</title>
  <script src="https://ajax.googleapis.com/ajax/libs/cesiumjs/1.105/Build/Cesium/Cesium.js"></script>
  <link 
    href="https://ajax.googleapis.com/ajax/libs/cesiumjs/1.105/Build/Cesium/Widgets/widgets.css"
    rel="stylesheet"
  />
</head>
<body>
  <div id="cesiumContainer"></div>
  <script>
    // Enable simultaneous requests.
    Cesium.RequestScheduler.requestsByServer["tile.googleapis.com:443"] = 18;

    // Create the viewer.
    const viewer = new Cesium.Viewer("cesiumContainer", {
      imageryProvider: false,
      baseLayerPicker: false,
      requestRenderMode: true,
      geocoder: false,
      globe: false,
    });

    // Add 3D Tiles tileset.
    const tileset = viewer.scene.primitives.add(
      new Cesium.Cesium3DTileset({
        url: "https://tile.googleapis.com/v1/3dtiles/root.json?key=YOUR_API_KEY",

        // This property is required to display attributions as required.
        showCreditsOnScreen: true,
      })
    );

    // Draws a circle at the position, and a line from the previous position.
    const drawPointAndLine = (position, prevPosition) => {
      viewer.entities.removeAll();
      if (prevPosition) {
        viewer.entities.add({
          polyline: {
            positions: [prevPosition, position],
            width: 3,
            material: Cesium.Color.WHITE,
            clampToGround: true,
            classificationType: Cesium.ClassificationType.CESIUM_3D_TILE,
          },
        });
      }
      viewer.entities.add({
        position: position,
        ellipsoid: {
          radii: new Cesium.Cartesian3(1, 1, 1),
          material: Cesium.Color.RED,
        },
      });
    };

    // Compute, draw, and display the position's height relative to the previous position.
    var prevPosition;
    const processHeights = (newPosition) => {
      drawPointAndLine(newPosition, prevPosition);

      const newHeight = Cesium.Cartographic.fromCartesian(newPosition).height;
      let labelText = "Current altitude (meters above sea level):\n\t" + newHeight;
      if (prevPosition) {
        const prevHeight =
          Cesium.Cartographic.fromCartesian(prevPosition).height;
        labelText += "\nHeight from previous point (meters):\n\t" + Math.abs(newHeight - prevHeight);
      }
      viewer.entities.add({
        position: newPosition,
        label: {
          text: labelText,
          disableDepthTestDistance: Number.POSITIVE_INFINITY,
          pixelOffset: new Cesium.Cartesian2(0, -10),
          showBackground: true,
          verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
        }
      });

      prevPosition = newPosition;
    };

    const handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);
    handler.setInputAction(function (event) {
      const earthPosition = viewer.scene.pickPosition(event.position);
      if (Cesium.defined(earthPosition)) {
        processHeights(earthPosition);
      }
    }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
  </script>
</body>

कैमरा ऑर्बिट

सीज़ियम में, आप किसी लोकप्रिय जगह के चारों ओर कैमरे को घुमा सकते हैं. साथ ही, इमारत के साथ टकराव से बचा जा सकता है. इसके अलावा, कैमरे के इधर-उधर जाने पर इमारतों को पारदर्शी बनाया जा सकता है.

सबसे पहले, कैमरे को किसी पॉइंट पर लॉक करें. इसके बाद, अपनी ऐसेट दिखाने के लिए कैमरे की ऑर्बिट बनाई जा सकती है. इवेंट लिसनर के साथ कैमरे के lookAtTransform फ़ंक्शन का इस्तेमाल करके, ऐसा किया जा सकता है, जैसा कि इस कोड सैंपल में बताया गया है.

// Lock the camera onto a point.
const center = Cesium.Cartesian3.fromRadians(
  2.4213211833389243,
  0.6171926869414084,
  3626.0426275055174
);

const transform = Cesium.Transforms.eastNorthUpToFixedFrame(center);

viewer.scene.camera.lookAtTransform(
  transform,
  new Cesium.HeadingPitchRange(0, -Math.PI / 8, 2900)
);

// Orbit around this point.
viewer.clock.onTick.addEventListener(function (clock) {
  viewer.scene.camera.rotateRight(0.005);
});

कैमरे को कंट्रोल करने के बारे में ज़्यादा जानकारी के लिए, कैमरा कंट्रोल करना लेख पढ़ें

सीज़ियम के साथ काम करें

3D Tiles API के साथ Unreal प्लगिन के लिए Cesium का इस्तेमाल करने के लिए, नीचे दिया गया तरीका अपनाएं.

  1. Unreal प्लगिन के लिए Cesium इंस्टॉल करें.

  2. एक नया Unreal प्रोजेक्ट बनाएं.

  3. Google फ़ोटोरियलिस्टिक 3D Tiles API से कनेक्ट करें.

    1. सीज़ियम विंडो खोलने के लिए, मेन्यू से सीज़ियम > सीज़ियम चुनें.

    2. खाली 3D टाइल्स टाइलसेट चुनें.

    3. World Outliner में, ब्यौरा पैनल खोलने के लिए, इस Cesium3DTileset को चुनें.

    4. सोर्स को Cesium Ion से यूआरएल से में बदलें.

    5. यूआरएल को Google 3D Tiles यूआरएल पर सेट करें.

    https://tile.googleapis.com/v1/3dtiles/root.json?key=YOUR_API_KEY
    
    1. एट्रिब्यूशन को सही तरीके से दिखाने के लिए, स्क्रीन पर क्रेडिट दिखाएं को चालू करें.
  4. इससे दुनिया लोड हो जाती है. किसी भी LatLng पर जाने के लिए, Outliner पैनल में CesiumGeoreference आइटम चुनें और फिर जानकारी पैनल में शुरुआत की जगह का अक्षांश/देशांतर/ऊंचाई में बदलाव करें.

सीज़ियम फ़ॉर यूनिटी के साथ काम करें

Cesium for Unity के साथ फ़ोटोरियलिस्टिक टाइल का इस्तेमाल करने के लिए, नीचे दिया गया तरीका अपनाएं.

  1. Unity का एक नया प्रोजेक्ट बनाएं.

  2. पैकेज मैनेजर सेक्शन में एडिटर > प्रोजेक्ट सेटिंग की मदद से, एक नई स्कोप्ड रजिस्ट्री जोड़ें.

    • नाम: सीज़ियम

    • यूआरएल: https://unity.pkg.cesium.com

    • दायरा: com.cesium.unity

  3. Unity पैकेज के लिए सीज़ियम इंस्टॉल करें.

  4. Google Photoरियलिस्टिक 3D Tiles API से कनेक्ट करें.

    1. सीज़ियम विंडो खोलने के लिए, मेन्यू से सीज़ियम > सीज़ियम चुनें.

    2. 3D टाइल वाले खाली टाइलसेट पर क्लिक करें.

    3. बाईं ओर मौजूद पैनल में, सोर्स में टाइलसेट सोर्स विकल्प में, सेज़ियम Ion के बजाय, यूआरएल से चुनें.

    4. Google 3D टाइल के यूआरएल का यूआरएल सेट करें.

    https://tile.googleapis.com/v1/3dtiles/root.json?key=YOUR_API_KEY
    
    1. एट्रिब्यूशन को सही तरीके से दिखाने के लिए, स्क्रीन पर क्रेडिट दिखाएं को चालू करें.
  5. इससे दुनिया लोड हो जाती है. किसी भी LatLng पर जाने के लिए, सीन हैरारकी में CesiumGeoreference आइटम चुनें और फिर जांच करने वाले टूल में जाकर, मूल अक्षांश/देशांतर/ऊंचाई में बदलाव करें.

डेक.gl के साथ काम करें

deck.gl, को WebGL की मदद से काम करता है. यह एक ओपन सोर्स JavaScript फ़्रेमवर्क है, जो बड़े स्तर पर बेहतर परफ़ॉर्म करने वाले डेटा विज़ुअलाइज़ेशन के लिए है.

एट्रिब्यूशन

यह पक्का करें कि टाइल gltf asset से copyright फ़ील्ड को एक्सट्रैक्ट करके, फिर उसे रेंडर किए गए व्यू पर दिखाकर, डेटा एट्रिब्यूशन सही तरीके से दिखाए जा रहे हों. ज़्यादा जानकारी के लिए, डिसप्ले डेटा एट्रिब्यूशन लेख पढ़ें.

Dec.gl रेंडरर के उदाहरण

सामान्य उदाहरण

नीचे दिए गए उदाहरण में, deck.gl के रेंडरर को शुरू किया गया है और फिर किसी जगह को 3D में लोड किया गया है. अपने कोड में, YOUR_API_KEY को अपनी असल एपीआई कुंजी से बदलना न भूलें.

<!DOCTYPE html>
<html>
 <head>
   <title>deck.gl Photorealistic 3D Tiles example</title>
   <script src="https://unpkg.com/deck.gl@latest/dist.min.js"></script>
   <style>
     body { margin: 0; padding: 0;}
     #map { position: absolute; top: 0;bottom: 0;width: 100%;}
     #credits { position: absolute; bottom: 0; right: 0; padding: 2px; font-size: 15px; color: white;
        text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;}
   </style>
 </head>

 <body>
   <div id="map"></div>
   <div id="credits"></div>
   <script>
     const GOOGLE_API_KEY = YOUR_API_KEY;
     const TILESET_URL = `https://tile.googleapis.com/v1/3dtiles/root.json`;
     const creditsElement = document.getElementById('credits');
     new deck.DeckGL({
       container: 'map',
       initialViewState: {
         latitude: 50.0890,
         longitude: 14.4196,
         zoom: 16,
         bearing: 90,
         pitch: 60,
         height: 200
       },
       controller: {minZoom: 8},
       layers: [
         new deck.Tile3DLayer({
           id: 'google-3d-tiles',
           data: TILESET_URL,
           loadOptions: {
            fetch: {
              headers: {
                'X-GOOG-API-KEY': GOOGLE_API_KEY
              }
            }
          },
           onTilesetLoad: tileset3d => {
             tileset3d.options.onTraversalComplete = selectedTiles => {
               const credits = new Set();
               selectedTiles.forEach(tile => {
                 const {copyright} = tile.content.gltf.asset;
                 copyright.split(';').forEach(credits.add, credits);
                 creditsElement.innerHTML = [...credits].join('; ');
               });
               return selectedTiles;
             }
           }
         })
       ]
     });
   </script>
 </body>
</html>

Google फ़ोटोरियलिस्टिक 3D टाइल के ऊपर 2D लेयर देखें

डेक.gl TerrainExtension दूसरे तरीके से 2D डेटा को 3D सतह पर रेंडर करता है. उदाहरण के लिए, फ़ोटोरियलिस्टिक 3D टाइल जियोमेट्री के ऊपर, इमारत के फ़ुटप्रिंट के तौर पर GeoJSON फ़ॉर्मैट किया जा सकता है.

नीचे दिए गए उदाहरण में, इमारतों की एक लेयर को ऐसे पॉलीगॉन से दिखाया गया है जो फ़ोटोरियलिस्टिक 3D टाइल की सतह के हिसाब से बने हैं.

<!DOCTYPE html>
<html>
 <head>
   <title>Google 3D tiles example</title>
   <script src="https://unpkg.com/deck.gl@latest/dist.min.js"></script>
   <style>
     body { margin: 0; padding: 0;}
     #map { position: absolute; top: 0;bottom: 0;width: 100%;}
     #credits { position: absolute; bottom: 0; right: 0; padding: 2px; font-size: 15px; color: white;
        text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;}
   </style>
 </head>

 <body>
   <div id="map"></div>
   <div id="credits"></div>
   <script>
     const GOOGLE_API_KEY = YOUR_API_KEY;
     const TILESET_URL = `https://tile.googleapis.com/v1/3dtiles/root.json`;
     const BUILDINGS_URL = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/google-3d-tiles/buildings.geojson'
     const creditsElement = document.getElementById('credits');
     const deckgl = new deck.DeckGL({
       container: 'map',
       initialViewState: {
         latitude: 50.0890,
         longitude: 14.4196,
         zoom: 16,
         bearing: 90,
         pitch: 60,
         height: 200
       },
       controller: true,
       layers: [
         new deck.Tile3DLayer({
           id: 'google-3d-tiles',
           data: TILESET_URL,
           loadOptions: {
            fetch: {
              headers: {
                'X-GOOG-API-KEY': GOOGLE_API_KEY
              }
            }
          },
          onTilesetLoad: tileset3d => {
             tileset3d.options.onTraversalComplete = selectedTiles => {
               const credits = new Set();
               selectedTiles.forEach(tile => {
                 const {copyright} = tile.content.gltf.asset;
                 copyright.split(';').forEach(credits.add, credits);
                 creditsElement.innerHTML = [...credits].join('; ');
               });
               return selectedTiles;
             }
           },
           operation: 'terrain+draw'
         }),
         new deck.GeoJsonLayer({
           id: 'buildings',
           // This dataset is created by CARTO, using other Open Datasets available. More info at: https://3dtiles.carto.com/#about.
           data: 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/google-3d-tiles/buildings.geojson',
           stroked: false,
           filled: true,
           getFillColor: ({properties}) => {
             const {tpp} = properties;
             // quantiles break
             if (tpp < 0.6249)
               return [254, 246, 181]
             else if (tpp < 0.6780)
               return [255, 194, 133]
             else if (tpp < 0.8594)
               return [250, 138, 118]
             return [225, 83, 131]
           },
           opacity: 0.2,
           extensions: [new deck._TerrainExtension()]
         })
       ]
     });
   </script>
 </body>
</html>