Needle Engine Integration
Integrate Multiset VPS into Needle Engine projects using Inspector components or the NeedleAdapter API
The SDK includes three Needle Engine components that cover the full VPS workflow. You can use them via the Unity Inspector (no code required for basic setups) or programmatically via NeedleAdapter for custom logic.
Installation
npm install @multisetai/vpsNeedle Engine ships its own Three.js fork, so do not install three separately.
Inspector-Driven Setup (Recommended for Unity Developers)
This path lets you configure VPS entirely from the Unity Inspector and export to web with Needle Engine.
Step 1: Copy the Templates
Copy the three template files into your Needle Engine web project's scripts folder:
cp node_modules/@multisetai/vps/templates/MultisetVPS.ts web/src/scripts/
cp node_modules/@multisetai/vps/templates/MapAnchor.ts web/src/scripts/
cp node_modules/@multisetai/vps/templates/MapType.ts web/src/scripts/
cp node_modules/@multisetai/vps/templates/MapType.cs Assets/Scripts/MapType.cs is a C# file for Unity — it exposes the MapType enum in the Inspector dropdown. MapType.ts is the TypeScript counterpart used by Needle Engine at runtime.
Step 2: Add MultisetVPS to a GameObject
In Unity, add the MultisetVPS component to any GameObject. Fill in the Inspector fields:
Client Id
From the Multiset Developer Portal
Client Secret
From the Multiset Developer Portal
Map Code
Map code, MapSet code, or comma-separated object codes
Map Type
SingleMap, MapSet, or ObjectTracking
Auto Localize
Start localization automatically when the AR session begins
Show Mesh
Download and display the map mesh after localization
Show Gizmo
Display a transform gizmo at the map origin
Relocalization
Re-localize when AR tracking is lost
Background Localization
Continuously re-localize to reduce drift
Confidence Check
Reject results below the confidence threshold
Confidence Threshold
Minimum accepted confidence (0.2 to 0.8)
Step 3: Add MapAnchor to Content GameObjects
Add the MapAnchor component to any GameObject you want anchored to the VPS map.
Offset
Position offset from the map origin in metres
Match Orientation
Align object rotation to the map orientation
Rotation Offset
Additional rotation applied after matching orientation
Hide Until Localized
Keep the object hidden until the first successful localization
Is Right Handed
Enable if entering Three.js coordinates directly. Leave off for Unity coordinates (auto-converts)
Step 4: Export and Run
Export the scene to web via Needle Engine. The AR button appears automatically on the exported page. No additional JavaScript is required.
Programmatic Setup (Custom Logic)
Use NeedleAdapter directly when you need to add listeners, react to localization events in other Behaviours, or build custom UI.
Listening to Localization Events from Another Behaviour
NeedleAdapter supports multiple listeners, so other components can subscribe without coupling to MultisetVPS:
Runtime-Spawned MapAnchors
If you instantiate a GameObject containing a MapAnchor after the scene loads, register it with the adapter so it receives the last localization result immediately:
Customizing the buttons
MultisetVPS does not use the SDK's built-in AR button. It passes useDefaultButton: false and builds its own set in _createUI(), so every button you see on screen lives in the template file you copied into src/scripts/. That is the one place to edit.
START AR / STOP AR
always
Toggles the XR session. The label is swapped in _onSessionStart() and _onSessionEnd().
CAPTURE FRAME
VPS modes (SingleMap, MapSet)
Runs one localization. Shows LOCALIZING... and disables itself while the request is in flight, then resets.
TRACK OBJECT
ObjectTracking mode
Runs one object detection pass. Shows TRACKING... while running.
CLEAR MESHES
ObjectTracking mode
Removes the object outline meshes already placed in the scene.
To change the layout, styling, or which buttons exist, edit _createUI(). To change what the capture button reads while it is working, look for LOCALIZING... in the same file and at _resetCaptureButton(), which restores the default label.
Whatever you build, startSession() must be the first call inside the click handler. Any await before it consumes the browser's user activation token and the session request is rejected. The template notes this in a comment directly above _createUI().
The UI is mounted on the canvas's parent element so it shares the same stacking context. During an immersive-ar session the WebGL canvas receives no pointer events, so the session requests the dom-overlay feature to make HTML tappable. A Unity world-space Canvas still renders for signage, but it cannot be tapped while a session is presenting.
Manual Session Control
Last updated
Was this helpful?

