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.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 viafindObjectByName() 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).
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 theemitEvent() 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).
emitEvent() function in the Spline Events section.
Handling multiple views
If you have severalSplineViewโ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 theSplineView instance.
SplineObject Properties and Methods
After retrieving a Spline Object withfindObjectById() 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 theaddEventListener(), emitEvent() and emitEventReverse() functions.

