Loading...
Loading...
Sets up a 3D CAD model viewer in a Dune app using Cognite Reveal via @cognite/dune-industrial-components/reveal. Use this skill whenever the user mentions 3D viewer, 3D visualization, reveal, CAD model, RevealProvider, RevealCanvas, Reveal3DResources, FDM 3D mapping, asset 3D model, loading a 3D model, or wants to display any Cognite 3D content in a Dune application — even if they don't explicitly say 'Reveal' or '3D viewer'. Do NOT manually wire up RevealProvider, RevealCanvas, or model-loading hooks without consulting this skill first.
npx skill4agent add cognitedata/dune-skills reveal-3dpackage.jsonreactreact-domvite.config.tssrc/main.tsxpnpm add @cognite/reveal three process util assert ajv
pnpm add "@cognite/dune-industrial-components@github:cognitedata/dune-industrial-components#semver:*"
pnpm add -D @types/three
pnpm install --no-frozen-lockfileIf running inside Cursor (sandbox): the GitHub package install requires, which the Cursor sandbox blocks. If you seegit init, the install must be run with full permissions. In a Shell tool call, passgit init ... Operation not permitted.required_permissions: ["all"]
three@cognite/revealnode -e "const r=require('./node_modules/@cognite/reveal/package.json'); console.log(r.peerDependencies?.three)"
node -e "console.log(require('./node_modules/three/package.json').version)"three@cognite/revealpnpm add three@^<required-version> # e.g. three@^0.180.0
pnpm install --no-frozen-lockfilepackage.json@cognite/revealthreeprocessutilassertajv@cognite/dune-industrial-componentsWhy?ajvrequires@cognite/dune-industrial-components. The monorepo root hasajv@>=8as a transitive dep. Without a directajv@6in the app, pnpm picks up the root's v6 and you get a peer warning that can cause schema validation failures.ajv@^8
Do not install. It introduces a different set of transitive-dep conflicts. Use explicitvite-plugin-node-polyfills,process,utilpackage aliases instead.assert
vite.config.tsresolve.dedupereactreact-domreact/jsx-runtimethreededupeutil/assert/process/browserprocessutilassertdependenciesoptimizeDeps.includeprocessutilassertthree@cognite/revealworker.format: 'es'@cognite/dune-industrial-componentsoptimizeDeps.excludeprocessimport process from 'process';
(window as unknown as Record<string, unknown>).process = process;
// all other imports below ↓
import { DuneAuthProvider } from '@cognite/dune';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App.tsx';
import './styles.css';
const queryClient = new QueryClient({
defaultOptions: { queries: { staleTime: 5 * 60 * 1000, gcTime: 10 * 60 * 1000 } },
});
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<QueryClientProvider client={queryClient}>
<DuneAuthProvider>
<App />
</DuneAuthProvider>
</QueryClientProvider>
</React.StrictMode>
);DuneAuthProvider@cognite/duneCDFAuthenticationProviderObjectUnsubscribedError: object unsubscribedCacheProviderRevealKeepAliveRevealProviderApp (always rendered)
CacheProvider ← always mounted
RevealKeepAlive ← always mounted
<sidebar> ← model picker lives here
{selected && (
RevealProvider ← conditional, only when model is ready
<RevealCanvas>
<Reveal3DResources />
)}RevealKeepAliveRevealProviderRevealKeepAliveRevealProviderRevealKeepAliveRevealProviderRevealKeepAliveviewerRefRevealProvider{selected && (
<MyViewerComponent> ← ❌ RevealKeepAlive co-located with RevealProvider
<CacheProvider>
<RevealKeepAlive>
<RevealProvider>DMInstanceRefCogniteVisualizable.object3D → CogniteCADNodesrc/components/ViewerContent.tsxsrc/App.tsxViewerContentCacheProviderRevealKeepAliveRevealProviderApp.tsxresourcesReveal3DResourcesuseMemoonModelsLoadeduseCallbackonSelectonLoaduseCallbackuseEffectsdkRevealProvideruseMemoclient.projectViewerContentReact.lazySuspenseRevealCanvaswidth: 100%; height: 100%<div style={{ width: '100%', height: '70vh', position: 'relative' }}>
<RevealProvider ...>
<ViewerContent modelId={...} revisionId={...} />
</RevealProvider>
</div>| Symptom | Cause | Fix |
|---|---|---|
| Cursor sandbox blocks git operations needed to clone the GitHub package | Re-run |
| Same GitHub package sandbox issue — pnpm is stuck waiting on a blocked syscall | Kill the process, re-run with |
| | Check |
| Monorepo root has | |
| | Move |
| Inline | |
| | Move the call into |
| | Add |
| Missing runtime polyfill | First two lines of |
| Used | Remove the plugin; use package aliases ( |
| Two Three.js copies loaded | |
| Black screen / workers fail silently | Missing ES worker format | Add |
| Canvas 0px tall | Container has no explicit height | |
| No model found (FDM mode) | Instance not linked via Core DM ( | Use model browser (Pattern B) with |
CacheProviderRevealKeepAliveRevealProviderRevealCanvasReveal3DResourcesInstanceStylingProvideruseModelsForInstanceQueryuse3dModelsuseFdmAssetMappingsuseRevealuseOptionalRevealKeepAliveAddCadResourceOptionsTaggedAddResourceOptionsViewerOptionsDMInstanceRef@cognite/reveal@cognite/dune-industrial-components/reveal