Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use typescript, runtime reports: artoolkit_api__WEBPACK_IMPORTED_MODULE_1__.ARCameraParam/ARController is not a constructor #80

Open
sprhawk opened this issue Feb 15, 2019 · 0 comments

Comments

@sprhawk
Copy link

sprhawk commented Feb 15, 2019

I have been struggling between typescript and jsartoolkit5 for serveral days

I'm using webpack to bundle them.
typescript version: 3.2.2

inside webpack.config.js, I set an alias for lib

resolve: {
    extensions: [".js", ".ts", "json"],
    modules: ["node_modules"],
    alias: {
      "artoolkit.api": path.resolve(__dirname, "thirdparties/jsartoolkit5/js/artoolkit.api.js"),
    },
  },

in typescript:

 import {ARController, ARCameraParam} from 'artoolkit.api';
this._cameraParam = new ARCameraParam("/static/dist/artoolkit/camera_para.dat", 
        function() {
            self._arcontroller = new ARController(320, 240, self._cameraParam);
            self._arcontroller.process(self._videoTexture.video);
            self._arcontroller.debugSetup();

            let camera = self._scene.getCameraByName("Camera");
            if (camera) {
                camera.freezeProjectionMatrix(Matrix.FromArray(self._arcontroller.getCameraMatrix()));
            }
        },
        function(err: Error) {
            console.log("failed to load ARCameraParam: " + err);
        });

in artoolkit.api.d.ts, I changed a bit, added:

constructor(src: string, onload: ()=> void, onerror: (err: Error)=> void);

for

export declare class ARCameraParam {
    onload(): void;
    load(cameraData: string): void;
    constructor(src: string, onload: ()=> void, onerror: (err: Error)=> void);
}

the transpile passed, but when running, the chrome reported:
Uncaught TypeError: artoolkit_api__WEBPACK_IMPORTED_MODULE_1__.ARCameraParam is not a constructor

@sprhawk sprhawk changed the title Question: how to use typescript with jsartoolkit5? use typescript, runtime report: ARCameraParam/ARController is not a constructor Feb 16, 2019
@sprhawk sprhawk changed the title use typescript, runtime report: ARCameraParam/ARController is not a constructor use typescript, runtime report: artoolkit_api__WEBPACK_IMPORTED_MODULE_1__.ARCameraParam/ARController is not a constructor Feb 16, 2019
@sprhawk sprhawk changed the title use typescript, runtime report: artoolkit_api__WEBPACK_IMPORTED_MODULE_1__.ARCameraParam/ARController is not a constructor use typescript, runtime reports: artoolkit_api__WEBPACK_IMPORTED_MODULE_1__.ARCameraParam/ARController is not a constructor Feb 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant