Skip to content

Commit e178cbd

Browse files
committed
Add TypeScript definitions and configuration for ThreeJSRendererPlugin
1 parent 244eb07 commit e178cbd

File tree

8 files changed

+121
-0
lines changed

8 files changed

+121
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,15 @@ GitHub Actions workflow (`.github/workflows/ci.yml`) runs:
235235
- Tests (Node version defined in `.nvmrc` file)
236236
Badge above shows current status.
237237
238+
## Type Definitions 🔤🧾
239+
240+
TypeScript declaration files are included in the `types` folder. Prefer importing types from the provided declarations:
241+
242+
- `types/index.d.ts`
243+
- `types/threejs-renderer-plugin.d.ts`
244+
245+
Source maps (`.d.ts.map`) are included for better editor/IDE support.
246+
238247
## Compatibility 🔄
239248
- Built & tested with Three.js 0.161.x
240249
- Requires AR.js-core engine abstraction with an event bus (`on/off/emit`)

package-lock.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
},
1515
"sideEffects": false,
1616
"scripts": {
17+
"build:types": "tsc",
1718
"build:vite": "vite build",
1819
"dev:vite": "vite",
1920
"serve:vite": "vite preview",
@@ -33,6 +34,7 @@
3334
"@vitest/coverage-v8": "^4.0.8",
3435
"three": "^0.161.0",
3536
"jsdom": "^19.0.0",
37+
"typescript": "^3.9.10",
3638
"vite": "^7.1.12",
3739
"vitest": "^4.0.8"
3840
},

tsconfig.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
// Change this to match your project
3+
"include": ["src/**/*"],
4+
"compilerOptions": {
5+
"target": "ESnext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
6+
"module": "ESnext",
7+
// Tells TypeScript to read JS files, as
8+
// normally they are ignored as source files
9+
"allowJs": true,
10+
// Generate d.ts files
11+
"declaration": true,
12+
// This compiler run should
13+
// only output d.ts files
14+
"emitDeclarationOnly": true,
15+
/* Module Resolution Options */
16+
"moduleResolution": "node",
17+
// Types should go into this directory.
18+
// Removing this would place the .d.ts files
19+
// next to the .js files
20+
"outDir": "types",
21+
// go to js file when using IDE functions like
22+
// "Go to Definition" in VSCode
23+
"declarationMap": true
24+
}
25+
}

types/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { ThreeJSRendererPlugin } from "./threejs-renderer-plugin.js";
2+
//# sourceMappingURL=index.d.ts.map

types/index.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/threejs-renderer-plugin.d.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* Plugin to render THREE.js scenes driven by AR markers.
3+
* Provides management of renderer, scene, camera and marker anchors.
4+
* Supported options: antialias, alpha, preferRAF, container, invertModelView, applyAxisFix
5+
*/
6+
export class ThreeJSRendererPlugin {
7+
constructor(options?: {});
8+
name: string;
9+
version: any;
10+
engine: any;
11+
emitter: any;
12+
renderer: any;
13+
scene: any;
14+
camera: any;
15+
anchors: Map<any, any>;
16+
options: {
17+
antialias: any;
18+
alpha: any;
19+
preferRAF: any;
20+
container: any;
21+
minConfidence: any;
22+
useLegacyAxisChain: any;
23+
changeMatrixMode: any;
24+
invertModelView: any;
25+
applyAxisFix: any;
26+
debugSceneAxes: any;
27+
sceneAxesSize: any;
28+
debugAnchorAxes: any;
29+
anchorAxesSize: any;
30+
rendererFactory: any;
31+
};
32+
_rafId: number;
33+
_axisFix: any;
34+
init(engine: any): void;
35+
enable(): void;
36+
_onUpdate: () => void;
37+
_onMarker: (e: any) => void;
38+
_onGetMarker: (e: any) => void;
39+
_onCamera: (e: any) => void;
40+
_onLegacyFound: (d: any) => void;
41+
_onLegacyUpdated: (d: any) => void;
42+
_onLegacyLost: (d: any) => void;
43+
_onResize: () => void;
44+
disable(): void;
45+
dispose(): void;
46+
_sub(ev: any, fn: any): void;
47+
_off(ev: any, fn: any): void;
48+
_adaptLegacy(d: any, visible: any): {
49+
id: string;
50+
matrix: any;
51+
visible: any;
52+
_legacy: boolean;
53+
};
54+
handleRawGetMarker(e: any): void;
55+
handleUnifiedMarker(evt: any): void;
56+
handleCamera(e: any): void;
57+
handleUpdate(): void;
58+
handleResize(): void;
59+
_resizeToContainer(container: any): void;
60+
getAnchor(id: any): any;
61+
getScene(): any;
62+
getCamera(): any;
63+
getRenderer(): any;
64+
}
65+
export const THREEJS_RENDERER_PLUGIN_VERSION: any;
66+
//# sourceMappingURL=threejs-renderer-plugin.d.ts.map

types/threejs-renderer-plugin.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)