@splinetool/runtime 1.10.16 → 1.10.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -0
- package/build/runtime.cjs +279 -279
- package/build/runtime.js +271 -271
- package/package.json +1 -1
- package/runtime.d.ts +66 -0
package/README.md
CHANGED
|
@@ -176,6 +176,45 @@ spline.setVariables({ myName: 'Paul', mySize: 100 });
|
|
|
176
176
|
spline.setVariable('myName', 'Ringo');
|
|
177
177
|
```
|
|
178
178
|
|
|
179
|
+
### Procedural Transitions
|
|
180
|
+
|
|
181
|
+
If you don't want to define your transition as actions in Spline Editor, it's possible to write and control them from this API. Note that you still need to set the object states from Spline editor, this API will only enable transitioning from one state to another, essentially exposing Spline's Transition action.
|
|
182
|
+
|
|
183
|
+
```js
|
|
184
|
+
import { Easing } from '@splinetool/runtime'
|
|
185
|
+
|
|
186
|
+
// ...
|
|
187
|
+
|
|
188
|
+
const sphere = spline.findObjectByName('Sphere')!;
|
|
189
|
+
|
|
190
|
+
// Simplest way to transition sphere from current state to State.
|
|
191
|
+
// The "to" param is the only mandatory parameter.
|
|
192
|
+
sphere.transition({ to: 'State' });
|
|
193
|
+
|
|
194
|
+
// Same transition with all params set with their default values
|
|
195
|
+
sphere.transition({
|
|
196
|
+
from: undefined, // State name to start from, undefined will start from current state
|
|
197
|
+
to: 'State', // State name to go to, null will go to base state
|
|
198
|
+
duration: 1000, // in ms
|
|
199
|
+
delay: 0, // in ms
|
|
200
|
+
easing: Easing.LINEAR,
|
|
201
|
+
autoplay: true
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// Force transition from Base State
|
|
205
|
+
sphere.transition({ from: null, to: 'State' })
|
|
206
|
+
|
|
207
|
+
// Chaining two transitions, the second one will be playing after first one is over
|
|
208
|
+
sphere.transition({ to: 'State' }).transition({ to: 'State 2' });
|
|
209
|
+
|
|
210
|
+
// Save transition object for later use
|
|
211
|
+
const transition = sphere.transition({ to: 'State', autoPlay: false }).transition({ to: 'State 2' });
|
|
212
|
+
transition.play()
|
|
213
|
+
transition.pause()
|
|
214
|
+
transition.reset()
|
|
215
|
+
transition.seek(1000)
|
|
216
|
+
```
|
|
217
|
+
|
|
179
218
|
## API
|
|
180
219
|
|
|
181
220
|
### Spline Application Methods
|
|
@@ -198,10 +237,32 @@ You can call all these different methods on the Spline `Application` instance.
|
|
|
198
237
|
| `getVariable` | `(name: string, value: string \| number \| boolean) => void` | Get current value for a specific variable from its name |
|
|
199
238
|
| `stop` | `() => void` | Stop/Pause all rendering controls and events. |
|
|
200
239
|
| `play` | `() => void` | Play/Resume rendering, controls and events. |
|
|
240
|
+
| `pauseGameControls`. | `() => void` | Stop/Pause Game Controls if any. |
|
|
241
|
+
| `resumeGameControls`. | `() => void` | Play/Resume Game Controls if any. |
|
|
201
242
|
| `setBackgroundColor` | `(color:string) => void` | Manually sets the scene/canvas background color with a css color value. |
|
|
202
243
|
| `getAllObjects` | `() => SPEObject[]` | Returns a flat list of all the objects present in the scene. |
|
|
203
244
|
| `getSplineEvents` | `() => Object[]` | Returns an array listing all the Spline events used in the scene. |
|
|
204
245
|
|
|
246
|
+
### Spline Objects Methods and Properties
|
|
247
|
+
|
|
248
|
+
After retrieving a Spline Object with `app.findObjectById` or `app.findObjectByName`, there are a variety of properties and methods you can call on those.
|
|
249
|
+
|
|
250
|
+
| Name | Type | Description |
|
|
251
|
+
| ----------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
252
|
+
| `position` | `Vector3` | Gets / Sets object position. |
|
|
253
|
+
| `rotation` | `Vector3` | Gets / Sets object position. |
|
|
254
|
+
| `scale` | `Vector3` | Gets / Sets object scale. |
|
|
255
|
+
| `visible` | `boolean` | Gets / Sets object vibility. |
|
|
256
|
+
| `state` | `string\|number\|undefined` | Gets / Sets object's current state by name. undefined is used for default / Base State. You can also set from state index (0, 1, 2 etc...) |
|
|
257
|
+
| `intensity` | `number` | Only for light objects. Used to change the light intensity. |
|
|
258
|
+
|
|
259
|
+
| Name | Type | Description |
|
|
260
|
+
| ------------ | -------------------------------------- | ---------------------------------------------------------------- |
|
|
261
|
+
| `show` | `() => void` | Change object visible property to true. |
|
|
262
|
+
| `hide` | `() => void` | Change object visible property to false. |
|
|
263
|
+
| `emitEvent` | `(eventName: SplineEventName) => void` | Force trigger an event defined in Spline Editor. |
|
|
264
|
+
| `transition` | `(params: TransitionParams) => void` | Used to procedurally trigger a Spline transition between states. |
|
|
265
|
+
|
|
205
266
|
### Spline Events
|
|
206
267
|
|
|
207
268
|
These are all the Spline event types that you can pass to the `addEventListener`, `emitEvent` and `emitEventReverse` function.
|