reveal-3d
Original:🇺🇸 English
Translated
24 scripts
Integrates a local Cognite Reveal 3D CAD viewer bundle into Flows apps by copying app-local source code. Use when adding 3D viewer, 3D visualization, Reveal, CAD model, RevealProvider, RevealCanvas, Reveal3DResources, FDM 3D mapping, asset 3D model, model browser, or Cognite 3D content to a Flows application.
17installs
Added on
NPX Install
npx skill4agent add cognitedata/builder-skills reveal-3dTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Reveal 3D Viewer
Add a Cognite Reveal 3D viewer to a Flows app by copying the bundled source into the target app. Renders CAD models from CDF, with support for model browsing, direct model/revision IDs, or FDM-linked assets.
FDM instance to visualize: $ARGUMENTS
Use This When
The user wants to embed an interactive Cognite Reveal viewer for CDF 3D/CAD content in a Flows app.
Do not use this skill for static diagrams, graph visualizations, or unrelated custom Three.js scenes.
Prerequisites
- The app uses React + TypeScript and is wrapped in auth (Flows auth).
@cognite/dune - The app has a from
QueryClientProvider.@tanstack/react-query - The CDF project has 3D models, or the user has supplied direct model/revision IDs.
- For FDM-linked 3D, the instance must be linked through Core DM (->
CogniteVisualizable.object3D).CogniteCADNode
Integration Workflow
Follow these steps in order. Adapt paths to the target app's conventions instead of inventing new ones.
-
Inspect the target app. Read,
package.json,vite.config.ts, and the app's folder/alias conventions.src/main.tsx -
Install missing dependencies with the app's package manager. See Dependencies. Reuse existing pinned React, Flows, SDK, and React Query versions.
-
Copy the bundle into the app. Copy every file frominto an app-local feature folder, typically:
skills/reveal-3d/code/reveal/textsrc/features/reveal-3d/ -
Import from the local folder, never from the skill directory or the old external package. With a typicalalias:
@/*tsximport { CacheProvider, RevealKeepAlive, RevealProvider } from '@/features/reveal-3d'; -
Configure Vite and. Read vite-config.md and apply the process polyfill, manual
main.tsx/process/utilaliases,assertalias, dedupe settings, andthree.worker.format: 'es' -
Choose the implementation pattern. Use Pattern B (model browser or direct model ID) unless you already have aand confirmed Core DM 3D linkage. For full examples, read implementation.md.
DMInstanceRef -
Keep provider placement stable.and
CacheProviderare always mounted at page/app level.RevealKeepAliveis conditional, only when a model is selected or linked.RevealProvider -
Run typecheck and build (,
tsc --noEmit, etc.) and fix any copied-import or dependency issues.pnpm build
Minimal Example
tsx
import { useCallback, useMemo } from 'react';
import type { CogniteClient } from '@cognite/sdk';
import {
CacheProvider,
Reveal3DResources,
RevealCanvas,
RevealKeepAlive,
RevealProvider,
type AddCadResourceOptions,
} from '@/features/reveal-3d';
type SelectedModel = { modelId: number; revisionId: number };
function ViewerContent({ modelId, revisionId }: SelectedModel) {
const resources = useMemo<AddCadResourceOptions[]>(
() => [{ modelId, revisionId }],
[modelId, revisionId]
);
const onLoaded = useCallback(() => {}, []);
return (
<RevealCanvas>
<Reveal3DResources resources={resources} onModelsLoaded={onLoaded} />
</RevealCanvas>
);
}
export function ViewerPage({
sdk,
selected,
}: {
sdk: CogniteClient;
selected: SelectedModel | null;
}) {
const memoizedSdk = useMemo(() => sdk, [sdk.project]);
return (
<CacheProvider>
<RevealKeepAlive>
<div style={{ width: '100%', height: '70vh', position: 'relative' }}>
{selected && (
<RevealProvider sdk={memoizedSdk}>
<ViewerContent
modelId={selected.modelId}
revisionId={selected.revisionId}
/>
</RevealProvider>
)}
</div>
</RevealKeepAlive>
</CacheProvider>
);
}Dependencies
Suggested versions are starting points. If the target app already pins compatible versions, defer to the app.
| Package | Suggested version | Purpose |
|---|---|---|
| app version | UI framework |
| app version | Authenticated SDK via |
| | Reveal viewer runtime |
| | CDF API client |
| | Reveal/FDM data fetching hooks |
| | Three.js singleton used by Reveal |
| latest | Browser polyfills for Reveal dependencies |
| | Avoids older transitive AJV resolution in monorepos |
| latest dev dep | TypeScript types |
Example install (pnpm; adapt to the app's package manager):
bash
pnpm add @cognite/reveal @cognite/sdk @tanstack/react-query three process util assert ajv
pnpm add -D @types/threeAfter install, check 's peer requirement and align if needed.
@cognite/revealthreethreeDo not install ; use the explicit Vite aliases in vite-config.md.
vite-plugin-node-polyfillsCritical Rules
- contains only
ViewerContentandRevealCanvas; no providers.Reveal3DResources - passed to
resourcesmust be memoized withReveal3DResources.useMemo - ,
onModelsLoaded, and similar callbacks must be memoized withonSelect.useCallback - The SDK passed to must be memoized with
RevealProviderkeyed onuseMemo.client.project - fills its parent; the parent must have an explicit height.
RevealCanvas - Lazy-load canvas-heavy viewer content with +
React.lazywhen adding a route/page.Suspense
Advanced Reference
For the copied bundle API and exports, read .
code/README.mdFor model browser and FDM-linked implementations, read .
references/implementation.mdFor Vite, worker, polyfill, and troubleshooting details, read .
references/vite-config.mdVerification Checklist
- All files from were copied into an app-local feature folder.
skills/reveal-3d/code/reveal/ - Imports point to the app-local folder (e.g. ).
@/features/reveal-3d - The app does not import Reveal helpers from the old external package.
- Required dependencies are present in .
package.json - starts with the
main.tsxpolyfill before other imports.process - uses manual aliases, dedupe,
vite.config.tssingleton alias, andthree.worker.format: 'es' - and
CacheProviderare always mounted;RevealKeepAliveis conditional when model selection is conditional.RevealProvider - The viewer container has an explicit height.
- Typecheck and build pass.