potree

repository·develop·Indexed 26 days ago

https://github.com/potree/potree

A WebGL point cloud viewer, version 1.8.0.

Tokens
11.1K
Snippets
37
Records
58
Agent score
90%

What's inside potree

  1. Overview of Cesium

    develop
    Cesium is a cross-platform, cross-browser JavaScript library for creating 3D globes and 2D maps without requiring plugins. It leverages WebGL for high-performance, hardware-accelerated graphics, making it suitable for visualizing static and time-dynamic content.
  2. Overview of jsTree

    develop

    jsTree is an open-source jQuery plugin that provides interactive trees. It is highly configurable, themable, and extendable. Key features include:

    • Support for HTML and JSON data sources.
    • AJAX and asynchronous callback loading.
    • Drag & drop support.
    • Keyboard navigation.
    • Inline editing (create and delete nodes).
    • Tri-state checkboxes.
    • Fuzzy searching.
    • Customizable node types.
    • Built-in mobile theme for responsive design.
    • Compatibility with both content-box and border-box CSS box models.
  3. Install and include three.js

    develop

    You can use three.js in your project by either downloading the minified library and including it via a <script> tag, or by installing it as a module.

    To include the minified version directly in your HTML:

    <script src="js/three.min.js"></script>
    <script src="js/three.min.js"></script>
  4. Use GeoPackage JS in Node.js

    develop

    In Node.js, GeoPackage JS uses node-sqlite3 for reading GeoPackages and PureImage for tile rendering. You can open a GeoPackage file using GeoPackageAPI.open(filename, callback) and then interact with tile and feature tables.

    var GeoPackageAPI = require('@ngageoint/geopackage')
      , GeoPackageManager = GeoPackageAPI.GeoPackageManager
      , GeoPackageConnection = GeoPackageAPI.GeoPackageConnection
      , GeoPackageTileRetriever = GeoPackageAPI.GeoPackageTileRetriever;
    
    GeoPackageAPI.open(filename, function(err, geoPackage) {
    
      // Now you can operate on the GeoPackage
    
      // get the tile table names
      geoPackage.getTileTables(function(err, tileTableNames) {
        // tileTableNames is an array of all tile table names
    
        // get the info for the first table
        geoPackage.getTileDaoWithTableName(tileTableNames[0], function(err, tileDao) {
          geoPackage.getInfoForTable(tileDao, function(err, info) {
            // do something with the tile table info
          });
    
          // draw a tile into a canvas for an XYZ tile
          var canvas = canvasFromSomewhere;
          var gpr = new GeoPackageTileRetriever(tileDao, 256, 256);
          var x = 0;
          var y = 0;
          var zoom = 0;
    
          console.time('Draw tile ' + x + ', ' + y + ' zoom: ' + zoom);
          gpr.drawTileIn(x, y, zoom, canvas, function() {
            console.timeEnd('Draw tile ' + x + ', ' + y + ' zoom: ' + zoom);
          });
    
          // or get a tile base64 data URL for an XYZ tile
          gpr.getTile(x, y, zoom, function(err, tileBase64DataURL) {
            console.log('got the base64 data url');
          });
    
          // or get a tile from a GeoPackage tile column and tile row
          tileDao.queryForTile(tileColumn, tileRow, zoom, function(err, tile) {
            var tileData = tile.getTileData();  // the raw bytes from the GeoPackage
          });
    
        });
      });
    
      // get the feature table names
      geoPackage.getFeatureTables(function(err, featureTableNames) {
        // featureTableNames is an array of all feature table names
    
        // get the info for the first table
        geoPackage.getFeatureDaoWithTableName(featureTableNames[0], function(err, featureDao) {
          geoPackage.getInfoForTable(featureDao, function(err, info) {
            // do something with the feature table info
          });
    
          // query for all features
          featureDao.queryForEach(function(err, row, rowDone) {
            var feature = featureDao.getFeatureRow(row);
            var geometry = currentRow.getGeometry();
            if (geometry) {
              var geom = geometry.geometry;
              var geoJson = geometry.geometry.toGeoJSON();
    
              geoJson.properties = {};
              for (var key in feature.values) {
                if(feature.values.hasOwnProperty(key) && key != feature.getGeometryColumn().name) {
                  var column = info.columnMap[key];
                  geoJson.properties[column.displayName] = currentRow.values[key];
                }
              }
            }
            rowDone();
          });
        });
      });
    });
  5. Initialize sql.js in the browser

    develop

    In the browser, sql.js must be loaded asynchronously. You must include the .js loader and provide a locateFile configuration if the .wasm file is not in the same directory as your HTML file. The initSqlJs function is globally provided by the main distribution files.

    <script src='/dist/sql-wasm.js'></script>
    <script>
      const config = {
        locateFile: filename => `/dist/${filename}` 
      };
    
      initSqlJs(config).then(function(SQL) {
        // SQL is now available
        var db = new SQL.Database();
      });
    </script>
  6. Use GeoPackage JS in the Browser

    develop

    In the browser, GeoPackage JS uses sql.js to read GeoPackages and HTML5 Canvas for tile rendering. To load a GeoPackage from a file input, read the file as an ArrayBuffer, convert it to a Uint8Array, and use GeoPackageConnection.connectWithDatabase to initialize the connection.

    // attach this method to a file input onchange event
    window.loadGeoPackage = function(files) {
      var f = files[0];
      var r = new FileReader();
      r.onload = function() {
        var array = new Uint8Array(r.result);
        loadByteArray(array);
      }
      r.readAsArrayBuffer(f);
    }
    
    function loadByteArray(array, callback) {
      var db = new SQL.Database(array);
      GeoPackageConnection.connectWithDatabase(db, function(err, connection) {
        var geoPackage = new GeoPackage('', '', connection);
    
        // Now you can operate on the GeoPackage
    
        // get the tile table names
        geoPackage.getTileTables(function(err, tileTableNames) {
          // tileTableNames is an array of all tile table names
    
          // get the info for the first table
          geoPackage.getTileDaoWithTableName(tileTableNames[0], function(err, tileDao) {
            geoPackage.getInfoForTable(tileDao, function(err, info) {
              // do something with the tile table info
            });
    
            // draw a tile into a canvas for an XYZ tile
            var canvas = canvasFromSomewhere;
            var gpr = new GeoPackageTileRetriever(tileDao, 256, 256);
            var x = 0;
            var y = 0;
            var zoom = 0;
    
            console.time('Draw tile ' + x + ', ' + y + ' zoom: ' + zoom);
            gpr.drawTileIn(x, y, zoom, canvas, function() {
              console.timeEnd('Draw tile ' + x + ', ' + y + ' zoom: ' + zoom);
            });
    
            // or get a tile base64 data URL for an XYZ tile
            gpr.getTile(x, y, zoom, function(err, tileBase64DataURL) {
              console.log('got the base64 data url');
            });
    
            // or get a tile from a GeoPackage tile column and tile row
            tileDao.queryForTile(tileColumn, tileRow, zoom, function(err, tile) {
              var tileData = tile.getTileData();  // the raw bytes from the GeoPackage
            });
    
          });
        });
    
        // get the feature table names
        geoPackage.getFeatureTables(function(err, featureTableNames) {
          // featureTableNames is an array of all feature table names
    
          // get the info for the first table
          geoPackage.getFeatureDaoWithTableName(featureTableNames[0], function(err, featureDao) {
            geoPackage.getInfoForTable(featureDao, function(err, info) {
              // do something with the feature table info
            });
    
            // query for all features
            featureDao.queryForEach(function(err, row, rowDone) {
              var feature = featureDao.getFeatureRow(row);
              var geometry = currentRow.getGeometry();
              if (geometry) {
                var geom = geometry.geometry;
                var geoJson = geometry.geometry.toGeoJSON();
    
                geoJson.properties = {};
                for (var key in feature.values) {
                  if(feature.values.hasOwnProperty(key) && key != feature.getGeometryColumn().name) {
                    var column = info.columnMap[key];
                    geoJson.properties[column.displayName] = currentRow.values[key];
                  }
                }
              }
              rowDone();
            });
          });
        });
      });
    }
  7. Populate a tree using HTML

    develop

    The simplest way to create a tree is by using existing inline HTML. Select the container element using a jQuery selector and invoke the .jstree() function. You can also use $.jstree.create(element).

    You can pass configuration options to specific nodes using the data-jstree attribute.

    <div id="container">
      <ul>
        <li>Root node
          <ul>
            <li>Child node 1</li>
            <li>Child node 2</li>
          </ul>
        </li>
      </ul>
    </div>
    <script>
    $(function() {
      $('#container').jstree();
    });
    </script>
  8. Use sql.js in a Web Worker

    develop
    To avoid blocking the main thread during intensive queries, use the Web Worker API. You must use the specific worker distribution files: dist/worker.sql-wasm.js and dist/worker.sql-wasm.wasm. The Web Worker API is more limited than the main API.
  9. Build Spectrum Locally

    develop

    To run the development version, use Grunt to automate testing, linting, and building.

    1. Install the Grunt CLI globally: npm install -g grunt-cli
    2. Install project dependencies: npm install
    3. Run tests and linting: grunt
    4. Run tests, linting, and build a minified version: grunt build
    npm install -g grunt-cli
    npm install
    
    # runs jshint and the unit test suite
    grant
    
    # runs jshint, the unit test suite, and builds a minified version of the file.
    grant build