@splinetool/viewer 0.0.19 → 0.0.21

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 CHANGED
@@ -54,6 +54,45 @@ A css like color that will override the background color of your scene as it was
54
54
 
55
55
  This option controls the agressiveness of the preload of your scene. Possible values are `auto`, `lazy` and `eager`. By default (`auto`) the behavior is to `lazy` load the scene and only start to preload when the tag enters the viewport. If you need to start loading immediately then you can set `loading="eager"` instead.
56
56
 
57
+ ### `unloadable` (optional)
58
+
59
+ When true (default is false), this options makes the viewer unload the spline element when it leaves the viewport.
60
+
61
+ ### `eventsTarget` (optional)
62
+
63
+ Values can either be `local` (events listened on the canvas) or `global` (events listened on the window).
64
+
65
+ ## Events
66
+
67
+ You can listen for a few custom events on the `spline-viewer` element that are triggered at various moments of its lifecycle.
68
+
69
+ ```js
70
+ const mySplineViewer = document.getElementById('MySplineViewer');
71
+ mySplineViewer.addEventListener('load-start', (e) => {
72
+ console.log('loading started', e.detail.url);
73
+ });
74
+ ```
75
+
76
+ ### `viewport-intersection`
77
+
78
+ Triggered when the viewer enters or leaves the viewport. Event contains a `intersection:boolean` detail value.
79
+
80
+ ### `context-loss`
81
+
82
+ Triggered when the webgl context of the canvas is lost.
83
+
84
+ ### `load-start`
85
+
86
+ Triggered when the viewer starts loading a scene. Event contains a `url:string` detail value. Use This if you want to display a preloader during loading.
87
+
88
+ ### `load-complete`
89
+
90
+ Triggered when the viewer finishes loading a scene. Event contains a `url:string` detail value. Use This if you want to display a preloader during loading.
91
+
92
+ ### `unload`
93
+
94
+ Triggered when the viewer finishes loading a scene. Event contains a `url:string` detail value. Use This if you want to display a preloader during loading.
95
+
57
96
  ## Exporting for `<spline-viewer` from Spline editor
58
97
 
59
98
  If you want a scene to be loaded by the `<spline-viewer>` component, you need to export it from Spline editor using the `Spline Viewer` export type. First click on the Export button from the toolbar, then click on the `Spline Viewer` tab on the sidebar of the export modal. Finally click on update and when export is done you can copy paste the code snippet or the exported URL.