THREE.AnaglyphEffect - webpack


I am working on a project built on three.js.
However, I have an issue using npm, webpack etc. since I am new to these.

I have imported three.js as:
import * as THREE from ‘three’;

I use AnaglyphEffect as:
effect = new THREE.AnaglyphEffect(renderer);

and I get the following error:
UIController.js:188 Uncaught (in promise) TypeError: THREE.AnaglyphEffect is not a constructor

Even if, I install and use ‘three-anaglypheffect’, I get the same error.

Could you help me, please?

AnaglyphEffect is not included in the three.js core. You need to import it separately:

import { AnaglyphEffect } from 'three/examples/jsm/effects/AnaglyphEffect.js';

Then use it like this:

effect = new AnaglyphEffect(renderer); 
1 Like

That worked.

Thank you!

1 Like

Are there any urls that I can also use to import



Thank you in advance!