@splinetool/loader 0.9.19

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 ADDED
@@ -0,0 +1,39 @@
1
+ # Spline Loader
2
+
3
+ > Three.js loader for `.spline` files.
4
+
5
+ It returns a three.js compatible rapresentation of the file scene.
6
+
7
+ You should use this package if you want to access your Spline objects and materials from code and manipulate them yourself.
8
+
9
+ If you want to display your Spline scene with interactions and states matching Spline play mode, we recommend you use [spline-runtime](https://www.npmjs.com/package/@splinetool/runtime) instead.
10
+
11
+ ## Installation
12
+
13
+ ```
14
+ npm install @splinetool/loader
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```js
20
+ import SplineLoader from '@splinetool/loader';
21
+
22
+ // Instantiate a loader
23
+ const loader = new SplineLoader();
24
+
25
+ // Load a .spline file
26
+ loader.load(
27
+ // path to the .spline file, either from the Spline servers or local
28
+ 'https://prod.spline.design/TRfTj83xgjIdHPmT/scene.spline',
29
+ // called when the resource is loaded
30
+ (splineScene) => {
31
+ scene.add(splineScene);
32
+ },
33
+ null,
34
+ // called when loading has errors
35
+ (error) => {
36
+ console.log('An error happened');
37
+ }
38
+ );
39
+ ```
@@ -0,0 +1,7 @@
1
+ declare module "SplineLoader" {
2
+ import { Loader, Scene } from 'three';
3
+ export default class SplineLoader extends Loader {
4
+ load(url: string, onLoad: (scene: Scene) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
5
+ parse(buffer: ArrayBuffer): Scene;
6
+ }
7
+ }