
Reveal 3d
Copy a Cognite Reveal 3D viewer bundle into your React app with providers, canvas, and asset-mapping hooks wired for Vite and TypeScript.
Install
npx skills add https://github.com/cognitedata/builder-skills --skill reveal-3dWhat is this skill?
- Shippable `code/reveal/` bundle meant for `src/features/reveal-3d/` with a single public `index.ts` export surface
- Components: `RevealProvider`, `RevealCanvas`, `Reveal3DResources`, `RevealKeepAlive`, plus `CacheProvider`
- Hooks for viewer state and FDM mappings: `useReveal`, `useModelsForInstanceQuery`, `useFdmAssetMappings`
- Documents required deps: `@cognite/reveal`, `@cognite/sdk`, `@tanstack/react-query`, `three`, and Vite polyfills (`proce
- Includes chunked parallel asset-mapping cache (1000-item chunks) indexed by model/revision and asset instance
Adoption & trust: 1k installs on skills.sh; 4 GitHub stars; 3/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
Recommended Skills
Journey fit
The skill is a build-time integration pack for embedding industrial 3D visualization in a web product, not for ideation or launch distribution. Primary work is UI composition (`RevealCanvas`, providers) and client-side 3D rendering with React and Three.js against Cognite APIs.
Common Questions / FAQ
Is Reveal 3d safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Reveal 3d
# Reveal 3D Code Bundle This bundle is copied from the Reveal source tree. Copy the contents of `code/reveal/` into an app-local feature folder, typically: ```text src/features/reveal-3d/ ``` Then import from the app-local folder: ```tsx import { CacheProvider, Reveal3DResources, RevealCanvas, RevealKeepAlive, RevealProvider, } from '@/features/reveal-3d'; ``` Do not import from `skills/reveal-3d/code/reveal` in the target app. ## Dependencies The copied code expects these app dependencies: - `@cognite/reveal` - `@cognite/sdk` - `@tanstack/react-query` - `react` - `react-dom` - `three` The Vite setup for Reveal also needs `process`, `util`, `assert`, and `ajv`. Install `@types/three` as a dev dependency for TypeScript apps. ## Public Exports The public API is exported from `index.ts`, including: - Components: `RevealProvider`, `RevealCanvas`, `Reveal3DResources`, `RevealKeepAlive` - Providers/hooks: `CacheProvider`, `useReveal`, `useModelsForInstanceQuery`, `useFdmAssetMappings` - Types: `AddCadResourceOptions`, `TaggedAddResourceOptions`, `ViewerOptions` import type { Node3D } from '@cognite/sdk'; import type { DMInstanceRef } from '@cognite/reveal'; import { chunk, executeParallel } from '../utils/executeParallel'; const ASSET_MAPPING_CHUNK_SIZE = 1000; /** * Multi-level asset mapping cache with split-chunk strategy. * * Three-way indexing: * - By model+revision: Fast lookup for all mappings in a model * - By asset instance (space:externalId): Fast lookup for all nodes belonging to an asset * - By node ID: Fast lookup for individual node metadata */ export class AssetMappingCache { private byModelCache = new Map<string, Map<string, Node3D[]>>(); private byAssetCache = new Map<string, Node3D[]>(); private byNodeCache = new Map<string, Node3D>(); async getOrFetch( modelId: number, revisionId: number, assetInstances: DMInstanceRef[], fetchFn: ( modelId: number, revisionId: number, instances: DMInstanceRef[] ) => Promise<Map<string, Node3D[]>> ): Promise<Map<string, Node3D[]>> { const modelKey = this.createModelKey(modelId, revisionId); const cachedModel = this.byModelCache.get(modelKey); if (cachedModel) { const { cached, uncached } = this.splitCachedAndMissing( assetInstances, cachedModel ); if (uncached.length === 0) { return cached; } const fetched = await this.fetchAndCache( modelId, revisionId, uncached, fetchFn ); return this.mergeMappings(cached, fetched); } return this.fetchAndCache(modelId, revisionId, assetInstances, fetchFn); } getCachedAssetMapping(instance: DMInstanceRef): Node3D[] | undefined { return this.byAssetCache.get(this.createAssetKey(instance)); } getCachedNode(modelId: number, revisionId: number, treeIndex: number): Node3D | undefined { const key = this.createNodeKey(modelId, revisionId, treeIndex); return this.byNodeCache.get(key); } clear(): void { this.byModelCache.clear(); this.byAssetCache.clear(); this.byNodeCache.clear(); } clearModel(modelId: number, revisionId: number): void { const modelKey = this.createModelKey(modelId, revisionId); this.byModelCache.delete(modelKey); } private createAssetKey(instance: DMInstanceRef): string { return `${instance.space}:${instance.externalId}`; } private createModelKey(modelId: number, revisionId: number): string { return `${modelId}/${revisionId}`; } private createNodeKey(modelId: number, revisionId: number, treeIndex: number): string { return `${modelId}/${revisionId}/${treeIndex}`; } private splitCachedAndMissing( assetInstances: DMInstanceRef[], cachedModel: Map<string, Node3D[]> ): { cached: Map<string, Node3D[]>; uncached: DMInstanceRef[]; } { const cached = new Map<string, Node3D[]>(); const uncached: DMInstanceRef[] = []; for (const in