jonobr1 / two.js

A renderer agnostic two-dimensional drawing api for the web.
https://two.js.org
MIT License
8.31k stars 455 forks source link

[Question] Importing ZUI in Angular app. #556

Closed marcin-ochman closed 3 years ago

marcin-ochman commented 3 years ago

I'm using Two.js in Angular app. I would like to use ZUI.

I import two.js with following line:

import Two from "two.js";

and init ZUI with:

   var zui = new Two.ZUI(this.two.scene);

        zui.addLimits(0.05, 10);

        fromEvent(this.container.nativeElement, 'mousewheel').subscribe((event: any) => {
            const dy = (event.wheelDeltaY || - event.deltaY) / 1000;
            zui.zoomBy(dy, event.clientX, event.clientY);
        })

Unfortunately, I get this error (Firefox):

ERROR TypeError: two_js__WEBPACK_IMPORTED_MODULE_2__.default.ZUI is not a constructor

Could you tell me how can I import it and make it work?

jonobr1 commented 3 years ago

You should be able to import it through the extras folder like so:

import ZUI from 'two.js/extras/jsm/zui.js';