codeModel API

Programmatic control of embedded Vectary 3D scenes via JavaScript

Vectary is designed as a no-code platform, but some scenarios - especially integration with external websites - require programmatic control. Model API provides this capability: you can connect your website to an embedded 3D model, synchronize your interface with the scene state, and respond to user actions in 3D.

circle-exclamation

How it works

Vectary projects are embedded on websites via iframes. Since iframes are isolated from the parent page, communication uses the postMessage mechanism.

For Business plans, Vectary provides a script that can be added to your website. This script contains the VctrModelApi class - a wrapper around postMessage with convenient async methods. You create an API instance for each iframe and call methods to control the scene.

Unlike low-level libraries like Three.js or Babylon.js, most visual configuration is done in Vectary Studio without code. The API is for integration - connecting your ready-made 3D scene with your website's logic.

Capabilities

A few examples of API capabilities (see API Reference for the full list of methods).

circle-info

Some features may be available but not yet documented - contact usarrow-up-right if you need something specific

Category
Description

Initialization

Establish connection with the embedded model

Configuration

Read and change active variants and materials

Events

Two-way communication - receive scene events (clicks, hover, state changes, and more), send data to trigger scene logic

Floating UI

Interact with in-scene UI elements

Materials

Change colors, textures, PBR properties

Textures

Upload images, overlay textures with positioning

Camera

Control position, target, field of view

Animations

Play, stop, seek to specific frame

Objects

Transformations, visibility, duplication

Import/Export

Load 3D models, images, export to GLB/GLTF/FBX/USDZ

How API connects to Vectary Studio

Model API works together with settings configured in Vectary Studio. Most visual aspects are set up in the editor, while the API lets you control and modify them programmatically. Learn more about these concepts in Core Concepts.

Studio concept
Role in API

Object groups with switchable visibility - API activates the desired variant

Set of materials on an object - API switches the active material

In-scene UI elements - API reads their state and responds to interactions

Trigger → Action logic - API sends and receives events

Scene variables - API reads and writes values

Timeline animations - API controls playback

Documentation sections

Last updated