Skip to main content
The Code API allows you to seamlessly integrate interactive 3D experiences into your projects, offering greater control and customization. It enables you to trigger actions, modify object properties, and create dynamic, responsive 3D environments directly from your existing code and user interface.
Important: The Code API allows your native interface to control properties in the Spline scene, and vice versa. However, itโ€™s important to note that this is different from the Real-time APIs feature. For information about APIs used for server communication and integrating your scenes with other apps, please refer to the specific API documentation: Real-time API

Key capabilities

  • Event Listeners: React to real-time events within your 3D scenes.
  • Adjust Properties: Dynamically update position, scale, rotation, and more.
  • Trigger Transitions: Create transitions and animations based on events.
  • Adjust variables: Retrieve and update variables in a Spline scene.

Usage

Getting started

First, make sure youโ€™re familiar with Native 3D Embeds for Android and you can already embed 3D content in your Android projects.
To access the API, use the loadResource or loadUrl callback which is invoked once the scene has finished loading:
Info: The SplineView loads its content asynchronously, so API calls may return null or do nothing if the scene hasnโ€™t finished loading. Always use the onComplete callback to ensure the scene is ready before accessing the API.

Read and modify Spline objects

You can query any Spline object in the scene via findObjectByName() or findObjectById() functions. Then, you can read or write any of its properties. (You can get the ID of the object from the right-click context panel on the object in the Spline Editor).
The function returns null if an object with the specified name was not found.

Listen to events

You can listen to any Spline Event you set in the Events panel of the editor by attaching a listener to the view. You can find a list of all of the Spline Event listeners in the API section.

Trigger Spline events from outside

You can trigger any animation Event you set in the Events panel in the Spline Editor. You can use the emitEvent() function, passing the event type and the name or ID of your object. (You can get the ID of the object from the right-click context panel on the object).
Or you can query the spline object first, and then trigger the event:
You can find a list of all of the Spline Events you can pass to the emitEvent() function in the Spline Events section.

Handling multiple views

If you have several SplineViewโ€™s in your Android view hierarchy, each view is independent and has its own API. Simply keep a reference to each view to control them separately.

Updating scene variables

If you set up variables in your Spline scene from the editor, you can change them from code after the scene is loaded.
Note: If in the Spline Editor you have multiple variables with the same name, only the first one will be updated, so make sure to give unique names to the variables you want to update.

Playback control

You can pause and resume the scene rendering and animations:

Customizing the scene

You can customize certain scene properties like zoom level and background color:

API

SplineView Methods

You can call all these different methods on the SplineView instance.

SplineObject Properties and Methods

After retrieving a Spline Object with findObjectById() or findObjectByName(), there are a variety of properties and methods you can use.

Spline Events

These are all the Spline event types that you can pass to the addEventListener(), emitEvent() and emitEventReverse() functions.