A Visual Studio Code extension that provides 3D visualization of XKT (xeokit) files directly in the editor.
- 🎯 3D Visualization: View XKT files in an interactive 3D viewer
- 🖱️ Object Selection: Click on objects to view their ID and type information
- 🔄 Auto-rotation: Optional automatic model rotation
- 🎨 Customizable: Configure background color and viewer settings
- 📐 View Controls: Fit to view, reset view, and toggle rotation controls
-
Clone the repository:
git clone <repository-url> cd xkt-viewer-extension
-
Install dependencies:
npm install
-
Compile the extension:
npm run compile
-
Package to VSIX (optional):
# Install packaging tool npm install --save-dev vsce # Create VSIX package npx vsce package
This creates a
xkt-viewer-0.0.1.vsix
file. -
Install the extension:
Option A: Install from VSIX:
- Open VS Code
- Press
Ctrl+Shift+P
(orCmd+Shift+P
on Mac) - Type "Extensions: Install from VSIX..."
- Select the generated
.vsix
file
Option B: Development mode:
- Press
F5
to run the extension in a new Extension Development Host window
-
Open in VS Code:
code .
-
Run in development mode:
- Press
F5
to launch Extension Development Host - Or use
Ctrl+Shift+P
→ "Debug: Start Debugging"
- Press
-
Watch mode (for development):
npm run watch
-
Right-click method:
- Right-click on any
.xkt
file in the Explorer - Select "Open with XKT Viewer"
- Right-click on any
-
Command Palette:
- Press
Ctrl+Shift+P
(orCmd+Shift+P
on Mac) - Type "XKT Viewer: Open Viewer"
- Select your XKT file
- Press
-
From active editor:
- Open an XKT file in the editor
- Use the command palette method above
- Fit to View: Centers and scales the model to fit the viewport
- Toggle Rotation: Enables/disables automatic model rotation
- Reset View: Returns to the default camera position
- Object Selection: Click on any object to view its ID and type
Configure the extension through VS Code settings:
{
"xktViewer.autoRotate": false,
"xktViewer.backgroundColor": "#f0f0f0"
}
xkt-viewer-extension/
├── src/
│ ├── extension.ts # Main extension logic
│ └── webview-script.js # 3D viewer implementation
├── out/ # Compiled JavaScript output
├── package.json # Extension manifest
├── tsconfig.json # TypeScript configuration
└── README.md # This file
- Visual Studio Code 1.74.0 or higher
- Node.js 16.x or higher
- TypeScript 4.9.x or higher
- xeokit SDK: 3D visualization engine
- VS Code Extension API: Integration with VS Code
- TypeScript: Type-safe development
- WebView API: Embedded 3D viewer
# Compile TypeScript
npm run compile
# Watch mode for development
npm run watch
# Prepare for publishing
npm run vscode:prepublish
# Package extension to VSIX
npx vsce package
To create a distributable .vsix
file:
-
Install the packaging tool:
npm install --save-dev vsce
-
Build and package:
npm run compile npx vsce package
-
Result: This creates
xkt-viewer-0.0.1.vsix
file that can be:- Shared with others
- Installed manually in VS Code
- Published to the marketplace
Note: You may see warnings about missing repository or license fields - these are optional for local development.
- Press
F5
to run the extension in debug mode - Open a
.xkt
file in the Extension Development Host - Test the viewer functionality
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
[Add your license information here]
- Added object selection functionality
- Separated webview script from HTML template
- Initial 3D XKT file visualization
-
Extension not loading:
- Ensure VS Code version is 1.74.0 or higher
- Check that all dependencies are installed
-
XKT file not displaying:
- Verify the file is a valid XKT format
- Check browser console for error messages
-
Performance issues:
- Large XKT files may take time to load
- Consider the model complexity and size
- Check the Issues page
- Review the VS Code extension development documentation
- Consult the xeokit SDK documentation