2018-package-three-webpack-plugin icon indicating copy to clipboard operation
2018-package-three-webpack-plugin copied to clipboard

Cannot use CSS2DObject from three/examples/js/renderers/CSS2DRenderer

Open SneakySoySauce opened this issue 6 years ago • 1 comments

Hello and thank you for making this plugin.

I'm just starting with threejs/react and I am trying to implement this example : https://github.com/mrdoob/three.js/blob/master/examples/css2d_label.html

Thanks to the plugin I have no issue with instantiating a new CSS2DRenderer.

My issue comes when I try to implement this section of the example : var earthDiv = document.createElement( 'div' ); earthDiv.className = 'label'; earthDiv.textContent = 'Earth'; earthDiv.style.marginTop = '-1em';

var earthLabel = new THREE.CSS2DObject( earthDiv );

I get the following error : " TypeError: three_examples_js_renderers_CSS2DRenderer__WEBPACK_IMPORTED_MODULE_2__.CSS2DObject is not a constructor "

CSS2DObject is defined in CSS2DRenderer.js but for some reason I cannot use it. I configured everything as instructed, am I missing something ?

SneakySoySauce avatar Sep 03 '18 11:09 SneakySoySauce

Sorry I can't look into it right now, I've got a customer project taking all my time at the moment x.x

I think it's one of the classes that needs to use multiple import or exports, and that will be supported in the next version of the plugin when I can finally get to it.

In the meantime, you could add the file to the "entry" array in the Webpack config, and use window.THREE instead of import for now.

cecilemuller avatar Sep 03 '18 11:09 cecilemuller