Appearance
Installing XViewr SDK
XViewr SDK is published as a private npm package to Optellix Azure Artifacts.
Package name:
sh
@optellix/xviewr-sdkAzure Artifacts feed:
text
https://pkgs.dev.azure.com/Optellix/Optellix-XView/_packaging/company-packages-sdk/npm/registry/Requirements
- Node.js 20 or newer.
- npm access to the Optellix Azure Artifacts feed.
- A valid XViewr SDK license key for runtime use.
threeinstalled in the consuming application. It is a peer dependency of the SDK.
Configure npm
Add an .npmrc file to the consuming application:
ini
@optellix:registry=https://pkgs.dev.azure.com/Optellix/Optellix-XView/_packaging/company-packages-sdk/npm/registry/
//pkgs.dev.azure.com/Optellix/Optellix-XView/_packaging/company-packages-sdk/npm/registry/:always-auth=trueDo not commit access tokens into the project .npmrc.
Authenticate
Use one of the following approaches, depending on how the consuming environment is set up.
Azure DevOps Users
If the user has access to the Azure Artifacts feed, authenticate npm against the feed using the instructions from Azure DevOps:
- Open Azure DevOps.
- Go to Artifacts.
- Select the
company-packages-sdkfeed. - Open Connect to feed.
- Choose npm.
- Follow the generated authentication instructions.
After authentication, verify access:
sh
npm view @optellix/xviewr-sdk versionCI/CD Pipelines
In Azure Pipelines, authenticate using npmAuthenticate@0 against an .npmrc that contains the scoped registry.
Example:
yaml
- task: npmAuthenticate@0
inputs:
workingFile: .npmrc
- script: npm ciFor non-Azure CI systems, configure npm auth using a secure secret or token provided by the CI platform. Keep the token in the user-level or CI-generated .npmrc, not in source control.
Install
Install the SDK and its peer dependency:
sh
npm install @optellix/xviewr-sdk threeIf the project already has three, make sure the installed version satisfies the SDK peer dependency:
sh
npm ls threeThe SDK currently declares:
text
three >=0.176.0Import
Use the main package entry for the standard SDK API:
ts
import { ViewerCore } from "@optellix/xviewr-sdk";Typed subpath imports are also available:
ts
import { CameraPlugin } from "@optellix/xviewr-sdk/plugins";
import { CameraService } from "@optellix/xviewr-sdk/services";
import type { XViewerConfig } from "@optellix/xviewr-sdk/types";Minimal Usage
ts
import { ViewerCore, CameraType, LoaderService } from "@optellix/xviewr-sdk";
const container = document.getElementById("viewer")!;
const viewer = new ViewerCore(container, {
viewer: {
container,
camera: {
type: CameraType.Perspective,
fov: 75,
position: { x: 5, y: 5, z: 5 },
},
controls: {
type: "TrackballControls",
},
environment: {
preset: "outdoor",
},
licensing: {
key: "YOUR_XVIEWR_LICENSE_KEY",
},
},
plugins: [
{ name: "loader", enabled: true },
{ name: "selection", enabled: true },
{ name: "measurement", enabled: true },
],
features: {
enableCrossSection: true,
enableMeasurement: true,
enableSelection: true,
enableTransform: true,
enableLabels: true,
enableAnimation: true,
enableGrid: true,
enableShadows: true,
enableEnvironment: true,
},
rendering: {
antialias: true,
alpha: true,
},
});
await viewer.ready();Loading A Model
ts
const loader = viewer.getService<LoaderService>("loader");
await loader?.loadFile({
url: "/models/assembly.glb",
type: "glb",
filename: "assembly.glb",
});For very large STEP/CAD workflows, STEP is converted by Xconvert before it reaches the browser. The SDK loads the Xconvert-generated chunk manifest:
ts
const loader = viewer.getService<LoaderService>("loader");
await loader?.loadFile({
url: "/converted/manifest.json",
type: "chunked",
filename: "assembly-manifest.json",
});Supported Install Targets
The package exposes:
- ESM build through the
moduleandexports.importfields. - UMD/CommonJS-compatible build through the
mainandexports.requirefields. - TypeScript declarations through the
typesandexports.typesfields. - Subpath exports for
core,plugins,services,types, andutils.
Troubleshooting
401 Or 403 During Install
The user is not authenticated to the Azure Artifacts feed, or the account/token does not have feed access. Re-run the Azure DevOps Connect to feed npm authentication steps and verify:
sh
npm view @optellix/xviewr-sdk versionPackage Not Found
Check that the consuming project has the scoped registry:
sh
npm config get @optellix:registryIt should print:
text
https://pkgs.dev.azure.com/Optellix/Optellix-XView/_packaging/company-packages-sdk/npm/registry/Peer Dependency Warning For three
Install or update three in the consuming application:
sh
npm install threeRuntime License Error
The package installed successfully, but the viewer will not initialize until a valid XViewr SDK license key is supplied in viewer.licensing.key.
E57 Files
E57 is not currently supported. STEP workflows should go through Xconvert and be loaded as chunked manifests.