Naughty Pinching Mannequins

    @cognite/reveal
    TypeScript icon, indicating that this package has built-in type declarations

    3.1.0 • Public • Published

    Reveal viewer

    Documentation for the latest version is available at https://cognitedata.github.io/reveal-docs/docs. Documentation for the next release is available from https://cognitedata.github.io/reveal-docs/docs/next/.

    The documentation has a bunch of live examples.

    Code Example

    import { Cognite3DViewer } from "@cognite/reveal";
    import { CogniteClient, CogniteAuthentication } from "@cognite/sdk";
    
    const appId = "com.cognite.reveal.example";
    const client = new CogniteClient({
      appId,
      project,
      getToken
    });
    
    async function start() {
      await client.authenticate();
    
      const viewer = new Cognite3DViewer({
        sdk: client,
        domElement: document.querySelector("#your-element-for-viewer")
      });
      viewer.addModel({ modelId: 4715379429968321, revisionId: 5688854005909501 });
    }
    
    const project = "publicdata";
    const legacyInstance = new CogniteAuthentication({
      project,
    });
    
    const getToken = async () => {
      await legacyInstance.handleLoginRedirect();
      let token = await legacyInstance.getCDFToken();
      if (token) {
        return token.accessToken;
      }
      token = await legacyInstance.login({ onAuthenticate: "REDIRECT" });
      if (token) {
        return token.accessToken;
      }
      throw new Error("authentication error");
    };
    
    start();

    Installation

    npm install @cognite/reveal

    There are 2 different types of projects:

    1. These where CDN is available (no restrictive Content-Security-Policy is set)
    2. Projects with CSP that forbids to fetch scripts from apps-cdn.cognitedata.com.

    By default, Reveal tries to fetch its worker/wasm files from apps-cdn.cognitedata.com. If there is no CSP in your project or apps-cdn.cognitedata.com is whitelisted, then it will just work without any additional steps.

    In case if you see an error like that:

    Refused to load the script 'https://apps-cdn.cogniteapp.com/@cognite/reveal-parser-worker/1.1.0/reveal.parser.worker.js' because it violates the following Content Security Policy directive: "script-src 'self' https://localhost:* blob:"

    See the next steps in our documentation.

    Local Packages

    The Reveal viewer is structured using local packages. This allows you to test features in isolation and constrain the dependencies with logical barriers between features. Packages are located in the /packages/ subfolder. There is no enforced structure of the packages and their layout and content will vary depending on what the package exposes to the rest of the system. Dependencies that are located in the viewer/package.json will be shared and are accessible by any package without having to explicitly declare a dependency in the respective package's package.json. Any external dependency (e.g. lodash, threejs, etc.) must be declared in the root package.json such that they will be properly installed by users that consume the Reveal NPM package.

    Creating a local package

    Create a new folder under the /packages/ folder, e.g. /packages/[MY-PACKAGE-NAME] and include a package with the following structure:

    {
      "name": "@reveal/[MY-PACKAGE-NAME]",
      "private": true,
      "main": "index.ts",
    }

    Technically the private: true field can be omitted but it is highly recommended such that one does not accidentally publish the local package to NPM with the npm publish command. The index.ts should include any types, functions and/or classes you wish to expose to consumers of this package. You should also create a README.md file for your package that explains its intent and any information that is needed to use the package.

    If your package depends on another local package, it must be explicitly declared as a dependency:

    {
      "name": "@reveal/[MY-PACKAGE-NAME]",
      "private": true,
      "main": "index.ts",
      "dependencies": {
        "@reveal/[SOME-LOCAL-PACKAGE]": "workspace:*"
      }
    }

    The workspace keyword declares that the dependency is a local package and should never be fetched from NPM. And the ':*' syntax means that it should just grab any version available. See this for more documentation on yarn workspaces.

    It is also possible to run and test a local package in isolation from the rest of Reveal. Convenience functionality has been created to make this easy. Add the following script to your package's package.json:

    {
      "scripts": {
        "test": "yarn ws:test --config ./../../jest.config.js"
      }
    }

    Running yarn run test will run all tests in your package that resolves the *.test.* regex pattern.

    To run a test app that includes your package (and any dependencies), create a /app/ subfolder in your package that includes an index.ts file. Add the following script to your package's package.json:

    {
      "scripts": {
        "start": "yarn ws:start"
      }
    }

    Running the command yarn start will host a localhost site with a template HTML that includes the /app/index.ts script that has been transpiled to javascript. To see an example of this check out the packages/camera-manager package.

    Recommended package folder structure

    ├── app                   # Runnable app
      └──index.ts             # Entry point for runnable app
    ├── src                   # Source code for package
    ├── test                  # Automated tests
    ├── package.json          # Package declaration
    ├── index.ts              # Entry point for package
    └── README.md             # Readme
    

    Keywords

    none

    Install

    npm i @cognite/reveal

    DownloadsWeekly Downloads

    1,572

    Version

    3.1.0

    License

    Apache-2.0

    Unpacked Size

    6.8 MB

    Total Files

    315

    Last publish

    Collaborators

    • vincent-cognite
    • joelnicolaysen-cognite
    • shashan_udawatte
    • kanchana.premachandra
    • dilesha08
    • mhmdfy
    • emircognite
    • simenkristoffersen
    • emmacognite
    • erik.galler
    • jens.kristoffersen
    • redzarosli
    • evertoncolling
    • rastif
    • asankad.cog
    • tokongs
    • cognite.harbs
    • queenie-cognite
    • sig1991
    • mlkrsrc
    • ahmedcognite
    • kondanta
    • bkuzma
    • shubhski
    • stefanmaretic
    • maksym.kowalski
    • bdemirel
    • toonday
    • sennen-cognite
    • eiriklv
    • dmakked
    • caner-cognite
    • 23andreas
    • ikechukwu
    • astridkg
    • marcelo_costa
    • fran.hrzenjak
    • torgrim
    • wchatx
    • julia.scott
    • marvin.reza
    • einar.omang
    • bhavith
    • oleksandr.kolomiiets
    • dafn
    • erlendvollset
    • eirik.djuve
    • luka-mikec-cognite
    • sou1est
    • sagarthalwar
    • martin-wahlberg
    • nabati
    • kinga.cognite
    • borlov
    • cyriaquebrousse
    • tugceozgur
    • erikangelsen-cognite
    • ankku
    • silvavelosa
    • henrist
    • robinhoodie
    • peet.cremer
    • ponnapz
    • shekhardesigner
    • kornelione
    • greenbech-cognite
    • lpereiracgn
    • manoj-cognite
    • oiuytrdsxcvbnjkhgfcvbnm
    • wjoel
    • tapped
    • sumitpandey
    • francisco.rull
    • frxstrem
    • cognitecicd
    • parami.abeysekara
    • cemreyavuz
    • neringaalt
    • rhuan.barreto
    • funsim
    • pavelzubarev
    • msusag
    • nfremming
    • steinhdan
    • dmivankov
    • polomani
    • simen.eriksen
    • nils-cognite
    • dlcognite
    • haak
    • carlospereira
    • larsmoa
    • nishafern
    • trygve.utstumo
    • kathrine-cognite
    • rekarnar
    • maximcognite
    • vegardokland
    • hhenriques
    • tfheen-cognite
    • oksana_korniienko
    • j-bjorne
    • scottmelhop
    • mathialo
    • agadacz-cognite
    • paulo-menezes-cognite
    • miladcognite
    • me-ydv-5
    • cogniteterraform
    • anderscognite
    • fredrik955
    • halvard
    • dan.levings.cognite
    • sindresh92
    • christjt
    • maksim.nesterenko
    • hakontro
    • arnekv
    • ana-gheorghe
    • judeezzz
    • dilinifernando
    • mithilacognite
    • maneshka.cognite
    • vdb93
    • eriklien
    • padalby
    • jorglund
    • tuanng-cognite
    • digaomilleniun.cognite
    • cognite-ornellas
    • harish0489
    • pedro.lindeza
    • abdullah-cognite
    • davidhwu
    • anjalirai2626
    • d0ttir
    • filipjohnsen
    • omarakabbal
    • savokr
    • pramodcog
    • tharindudg
    • brgverst
    • thorkild
    • sigridschaanning
    • smartalas
    • arnels
    • sondre.solbakken
    • pbettler
    • qtiptip
    • sceniclife
    • johan-cognite
    • theresatalor-cognite
    • mspang
    • eliasbjorne
    • oysteinolsen
    • anders-cog
    • skairunner
    • jtcog
    • petmotzf
    • deep-cognite
    • mattmurph9
    • lprovensi
    • haakonflatval-cognite
    • begozcan
    • khalzmax
    • chingyu-cognite
    • sighol
    • heiding
    • ronald-cognite
    • daniel.priori
    • ravinda-cognite
    • timurgen
    • trodden-dev
    • emel.varol
    • bdimitrijoski
    • madskjeldsberg
    • yevhenii.maltsev
    • farrukk24
    • aurlien
    • bianca-mv
    • samarv
    • soleh23
    • malindakpt
    • mihilr
    • gayandeegala
    • tfarvac
    • borajimin
    • samir-ajdarpasic
    • torbjornopheim
    • chanaka25
    • geircognite
    • soumesh.banerjee
    • mohsin.cognite
    • vebjorngilberg
    • roligheten
    • marcushorn
    • sara.aalbu
    • atussa
    • aizumi
    • therockvalley
    • dmitrijs.rutko.cognite
    • perarnet
    • bisera
    • shehan.cognite
    • udara-cognite
    • raabyeeggs
    • jarlah
    • keepfloyding
    • cgustad
    • tommy_thorsen
    • andersfylling
    • meisammalekzadeh
    • ericbrattli
    • mcarun
    • saagar-cognite
    • waqasjaved1