
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@cognite/3d-viewer
Advanced tools
This is the repository for the Cognite 3D Viewer. Currently this will also contain the documentation for the Cognite3DViewer.
This is the repository for the Cognite 3D Viewer. Currently this will also contain the documentation for the Cognite3DViewer.
For developers using the 3d-viewer, this will be the most important part of the documentation. Please follow the steps below to get development started
There are two ways of setting up the repo. If you have access to the currently internal npm repository, then you can include it as if a node_modules (import { Cognite3DViewer } from 'cognite-3d';
). Otherwise, follow the below guide.
lib/
folder for usage, make sure you use lib/index.browser.js
if you want to include this directly into your application, whether it is via html
or js
file.
<script>
tag:
<script src="./cognite-3d.bundle.js"></script> // Now you have 'cognite' as a global object
...
<script>
var viewer = new cognite.Cognite3DViewer({
...
});
// now you can use Viewer however you like!
</script>
import { Cognite3DViewer } from './link/to/lib/cognite-3d.bundle.js';
...
const viewer = new Cognite3DViewer({
...
});
To create a Cognite3DViewer
object, the constructor takes in an object, which can have the following options:
var viewer = new Cognite3DViewer({
api: '0.4', // required, currently 0.4
project: string, // required, this would be your tenant name, i.e. akso
modelId: number, // required, this would be your model id
revisionId: number, // required, this would be the revision id
apiKey: APIKEEEYYY, // required, the api key that is given to you, please don't leave it in the codebase!
noBackground: boolean, // optional. If the background should be transparent or not
antialias: boolean, // optional. Enable anitalias on rendering (avoid sharp edges). Will have negative performance impact on big 3D models.
onClickListener: (nodeId, node) => {}, // optional, can be set later
progressListener: function (step, totalSteps, subprogress, text){}, // optional, can be set later
});
After the viewer is constructed, it will have a canvas
variable that is accessible. This would need to be appended into any DOM like below:
document.getElementById("app").appendChild(viewer.canvas);
Note: you may need additional styling to make the canvas fit the width, in the example above, the styling could be
#app {
position: relative;
width: 100vw;
height: 400px;
}
#app > canvas {
width: 100%;
height: 100%;
}
After that is added, you should be good to go! use viewer.start()
to begin rendering.
The viewer object has plenty of additional api calls you can make, the below outlines some of these functionalities:
viewer.start()
viewer.stop()
viewer.stop()
viewer.start()
. When paused, the viewer will no longer work in the background, allowing you to do other things, but the context is saved, allowing you to start
with relatively no lag.viewer.toggleNodeSelected(nodeId)
nodeId
twice result it it being deselected.viewer.deselectAllNodes()
viewer.getAssetFromNodeId(nodeId)
data
field.viewer.setControlType("fpv|orbit|fpv-no-cursor")
data
field.viewer.setOnClickListener((nodeId, node) => {})
data
field.viewer.setColorOnNode(nodeId, color, alpha)
You will need yarn
(npm install -g yarn
).
Run yarn
to install packages.
Run yarn run start
to run.
npm publish
, make sure you have bumped the version first!.npmrc
or .yarnrc
setup properly. See Link for more details on Private npm repository section.Look at src/main.js
for more info Link
FAQs
JavaScript viewer to visualize 3D models on Cognite Data Fusion
The npm package @cognite/3d-viewer receives a total of 109 weekly downloads. As such, @cognite/3d-viewer popularity was classified as not popular.
We found that @cognite/3d-viewer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 176 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.