-
Notifications
You must be signed in to change notification settings - Fork 2
/
ARToolKitPlusLoader.ts
54 lines (47 loc) · 1.33 KB
/
ARToolKitPlusLoader.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import ARToolKitPlus from "../build/artoolkitplus_em_ES6";
import packageJson from "../package.json";
const { version } = packageJson;
export class ARToolKitPlusLoader {
private instance: any;
private version: string;
/**
* Default constructor, print in the console the ARToolKitPlus version, example:
* ```ARToolKitPlus 0.3.2```
*/
constructor() {
// reference to WASM module
this.instance;
this.version = version;
console.info("ARToolKitPlus ", this.version);
}
// ---------------------------------------------------------------------------
// initialization
/**
* Init the class injecting the Wasm Module and link the instanced method.
* @return {object} the this object
*/
public async init() {
this.instance = await ARToolKitPlus();
this._decorate();
return this;
}
// private methods
/**
* Used internally to link the instance in the ARToolKitPlusLoader to the
* ARToolKitPlus internal methods.
* @return {void}
*/
private _decorate(): void {
// add delegate methods
["PIXEL_FORMAT", "UNDIST_MODE", "MARKER_MODE"].forEach((method: string) => {
this.converter()[method] = this.instance[method];
});
}
/**
* Used internally to convert and inject code.
* @return {this} the this object
*/
private converter(): any {
return this;
}
}