@splinetool/runtime 0.6.13 → 0.6.17

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.
Files changed (3) hide show
  1. package/build/runtime.js +3236 -387
  2. package/package.json +6 -4
  3. package/runtime.d.ts +109 -0
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@splinetool/runtime",
3
- "version": "0.6.13",
3
+ "version": "0.6.17",
4
4
  "main": "build/runtime.js",
5
5
  "files": [
6
- "build"
6
+ "build",
7
+ "runtime.d.ts"
7
8
  ],
9
+ "types": "./runtime.d.ts",
8
10
  "scripts": {
9
11
  "start": "cross-env NODE_ENV=development node --experimental-json-modules ./esbuild.mjs",
10
12
  "build": "cross-env NODE_ENV=production node --experimental-json-modules ./esbuild.mjs",
@@ -23,7 +25,7 @@
23
25
  "prettier": "^2.3.2",
24
26
  "raw-loader": "^4.0.2",
25
27
  "source-map-explorer": "^2.5.2",
26
- "spe": "0.0.0",
28
+ "spe": "workspace:*",
27
29
  "three": "0.131.3",
28
30
  "typescript": "^4.1.3"
29
31
  },
@@ -42,4 +44,4 @@
42
44
  "dependencies": {
43
45
  "on-change": "^4.0.0"
44
46
  }
45
- }
47
+ }
package/runtime.d.ts ADDED
@@ -0,0 +1,109 @@
1
+ declare module '@splinetool/runtime' {
2
+ export type SplineEvent = {
3
+ target: {
4
+ name: string;
5
+ id: string;
6
+ };
7
+ };
8
+
9
+ export type SplineEventName =
10
+ | 'mouseDown'
11
+ | 'mouseUp'
12
+ | 'mouseHover'
13
+ | 'keyDown'
14
+ | 'keyUp'
15
+ | 'start'
16
+ | 'lookAt'
17
+ | 'follow';
18
+
19
+ export type SPEObject = {
20
+ name: string;
21
+ uuid: string;
22
+ visible: boolean;
23
+ intensity: number;
24
+ position: { x: number; y: number; z: number };
25
+ rotation: { x: number; y: number; z: number };
26
+ scale: { x: number; y: number; z: number };
27
+ /**
28
+ * Triggers a Spline event.
29
+ * Starts from firt state to last state.
30
+ * @param {string} eventName String that matches Spline event's name
31
+ * @param {string} uuid String to match to the object's uuid
32
+ */
33
+ emitEvent: (eventName: SplineEventName) => void;
34
+ /**
35
+ * Triggers a Spline event in reverse order.
36
+ * Starts from last state to first state.
37
+ * @param {string} eventName String that matches Spline event's name
38
+ */
39
+ emitEventReverse: (eventName: SplineEventName) => void;
40
+ };
41
+
42
+ export class Application {
43
+ autoRender: boolean;
44
+ canvas: HTMLCanvasElement;
45
+ constructor(
46
+ canvas: HTMLCanvasElement,
47
+ { autoRender }: { autoRender: true }
48
+ );
49
+ load(path: string): Promise<void>;
50
+ start(json: any): Promise<void>;
51
+ /**
52
+ * Searches through scene's children and returns the object with that uuid
53
+ * @param uuid String to match to the object's uuid
54
+ * @returns SPEObject
55
+ */
56
+ findObjectById(uuid: string): SPEObject | undefined;
57
+ /**
58
+ * Searches through scene's children and returns the first object with that name
59
+ * @param {string} name
60
+ * @returns {Object} SPEObject
61
+ */
62
+ findObjectByName(name: string): SPEObject | undefined;
63
+ /**
64
+ * Returns an array of Spline events
65
+ * @returns {Array.<Object>}
66
+ */
67
+ getSplineEvents(): {
68
+ [key: string]: {
69
+ [key: string]: CustomEvent<any>;
70
+ };
71
+ };
72
+ /**
73
+ * Triggers a Spline event associated to an object with provided uuid.
74
+ * Starts from first state to last state.
75
+ * @param {string} eventName String that matches Spline event's name
76
+ * @param {string} uuid
77
+ */
78
+ emitEvent(eventName: SplineEventName, uuid: string): void;
79
+ /**
80
+ * Triggers a Spline event associated to an object with provided uuid in reverse order.
81
+ * Starts from last state to first state.
82
+ * @param {string} eventName String that matches Spline event's name
83
+ * @param {string} uuid
84
+ */
85
+ emitEventReverse(eventName: SplineEventName, uuid: string): void;
86
+ /**
87
+ * Add an event listener for Spline events
88
+ * @param {string} eventName String that matches Spline event's name
89
+ * @param {function} cb A callback function with Spline event as parameter
90
+ */
91
+ addEventListener(
92
+ eventName: SplineEventName,
93
+ cb: (e: SplineEvent) => void
94
+ ): void;
95
+ /**
96
+ * Removes the event listener for a Spline event with the same name and callback
97
+ * @param {string} eventName String that matches Spline event's name
98
+ * @param {function} cb A callback function with Spline event as parameter
99
+ */
100
+ removeEventListener(
101
+ eventName: SplineEventName,
102
+ cb: (e: SplineEvent) => void
103
+ ): void;
104
+ /**
105
+ * Deactivates runtime
106
+ */
107
+ unmount(): void;
108
+ }
109
+ }