Build threejs with missing functions

Hi, I need to use CSS3DRenderer and DragControls in my project.
after npm install when I use them I have an error “is not a constructor”.
I read that I need to build the project to have them in three.js but I don’t understand how to build.
Someone can help me?
Thanks

No, it’s not necessary to create a custom build. Instead, you have to transform CSS3DRenderer and DragControls into modules and import them separately. You basically copy the files in your own repo and add the following line at the top of the modules:

import * as THREE from 'three';

You then have to ensure, that the respective classes are exported at the end of the module. For CSS3DRenderer you would have to do:

export { CSS3DObject, CSS3DSprite, CSS3DRenderer };

It’s important that you remove the THREE namespace from the exported entities. So for instance instead of:

THREE.CSS3DRenderer = function () {

	var _width, _height;
	var _widthHalf, _heightHalf;

	var matrix = new THREE.Matrix4();

you do:

function CSS3DRenderer () {

	var _width, _height;
	var _widthHalf, _heightHalf;

	var matrix = new THREE.Matrix4(); // this is intended, THREE is not removed for core classes
1 Like