Coder Social home page Coder Social logo

andrewn93 / reveal Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cognitedata/reveal

0.0 0.0 0.0 107.96 MB

Cognite Reveal 3D viewer

Home Page: https://cognitedata.github.io/reveal

License: Apache License 2.0

JavaScript 0.84% Rust 1.24% TypeScript 93.23% CSS 0.09% HTML 0.01% GLSL 4.56% Dockerfile 0.03%

reveal's Introduction

Cognite logo

Reveal 3D viewer and libraries

Build Status

Documentation with interactive examples for the latest version is available at https://cognitedata.github.io/reveal/docs/


Reveal viewer is a highly performant 3d-viewer for the Web written in a combination of TypeScript and Rust.

This repository contains the source code for the new version of the Cognite Reveal 3D viewer, including its file loading libraries.

All information below is for developers.

Getting started

Install Node and Rust.

To test the viewer, you need to build the viewer and then start the examples.

cd viewer
yarn && yarn run build
cd ../examples
yarn && yarn run start

If you now navigate to localhost:3000, the browser should show a simple 3D model with a UI.

To show a model from your own CDF project, you must first configure Reveal to use your CDF credentials. Follows the steps in the section Credentials Environment.

change the URL to https://localhost:3000/?project=<project>&env=<environment>&modelId=<modelId>&revisionId=<revisionId>.

Here, <project> is the name of the CDF project you want to connect to, <environment> is the name of the environment specified in the .env file (e.g. example_environment), and <modelId> and <revisionId> are the ids of the model you want to visualize. You can find these IDs in Cognite Fusion, in the "Upload 3D models" / "Manage 3D" subapp.

Troubleshooting

Occasionally, and always the first time you login to an environment, you may get a 401 error in the browser, which, after clicking through, resets the browser window to the model with colorful shapes. In this case, there should be a #code=...-segment appended to the URL in the browser. Copy the URL you tried to visit (including the project, environment and IDs), and paste it to the left of the #-sign in the URL, replacing everything that was there before. In other words, your URL should now look like

https://localhost:3000/?project=<project>&env=<environment>&modelId=<modelId>&revisionId=<revisionId>#code=<access token>

Press enter to reload.

This may or may not work on the first try, seemingly depending on the access token expiration or other factors. If it fails at first, you may try this step multiple times, it will usually work by the 5th attempt.

Building on Macbook M1

Building Reveal on Macbook M1 might require some special care.

If you experience issues during the yarn-stage in viewer/, e.g.

   no template named 'remove_cv_t' in namespace 'std'

try forcing GCC to build for C++14:

env CXXFLAGS=-std=c++14 yarn

There also could be an issue with puppeteer in examples/ that is caused by it not finding a correct version of chromium for arm64. To solve it you should follow additional steps:

  1. Install chromium from Homebrew:
brew install chromium
`which chromium`
  1. Inside examples/ add two environment variables to your ~/.zshrc config file:
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
export PUPPETEER_EXECUTABLE_PATH=`which chromium`

or create .env file within the same folder and paste them there, then use source:

source .env
  1. Run yarn again and be happy!

Credentials Environment

The examples are configured to run using any environment variables specified in the file examples/.env, which you create yourself. The file examples/.env.example shows the expected JSON format of the value contained in this variable. You must fill in the appropriate values for your environment in this file; The tenant ID, client ID and the cluster of the CDF project you want to use.

Ask your Cognite contact for the tenant ID and client ID if you don't have these available.

The cluster value is the name of the subdomain in which the project resides. To find its value for your project, log in to your project in Cognite Fusion and observe that the URL ends with a string akin to cluster=<cluster>.cognitedata.com. Here, <cluster> is the name you should put in the .env file.

When starting an example, you can add e.g. env=example_environment to use the authentication credential stored in the example_environment environment specified in .env.

Hosting models locally

If you have locally converted 3D models, these can be viewed locally using the "Simple" example by placing the converted model folder under examples/public/, by providing a modelUrl-parameter, e.g. https://localhost:8080/Simple?modelUrl=/primitives.

Use local build with a project that uses reveal

  1. Run viewer build
cd viewer
yarn run build
  1. Use the build from viewer/dist. You can simply use it as a link dependency in the project that uses reveal if the target project uses yarn as its package manager.
  • Replace reveal version with the link on viewer/dist in the project package.json
{
  "dependencies": {
    "@cognite/reveal": "link:<absolute or relative path to viewer/dist"
  }
}
  • After that, run yarn in the target project.
  • Don't forget you must not commit that change to the target project.

If you don't want to change package.json, you can use CLI utility npm link or yarn link. To do that:

  1. Create a link
cd viewer/dist
npm link
  1. Use the link in your target project
cd your-project-path
npm link @cognite/reveal

Now reveal should be replaced with the local build.

When you don't need it linked in the target project anymore, run:

npm unlink @cognite/reveal

To unregister the link from your local environment:

cd viewer/dist
npm unlink

Releasing Reveal

See RELEASING.md for details on how to releasing NPM packages and update documentation on release.

reveal's People

Contributors

renovate[bot] avatar larsmoa avatar haakonflatval-cognite avatar christjt avatar maksnester avatar dragly avatar pramodcog avatar dependabot[bot] avatar dependabot-preview[bot] avatar savokr avatar astrid-kg avatar j-bjorne avatar strepto avatar mattman22 avatar anders-hopland avatar aslettemark avatar cognite-bulldozer[bot] avatar eiriklegernaes avatar greenbech avatar msusag avatar nilscognite avatar edel-cognite avatar hkot1991 avatar jhutchings1 avatar miladcognite avatar sigridkschaanning avatar danlevings avatar hugolafis avatar vero-so avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.