首页 > 解决方案 > app.js:3524 Uncaught ReferenceError: THREE not defined at Object../node_modules/three-bmfont-text/index.js

问题描述

我正在尝试使用 Three.js 和 three-bmfont-text 来创建 3D 文本并使用着色器给它一个漂亮的外观。

我通过npm安装三三bmfont-text并导入到js文件中:

                import * as THREE from 'three';
                const loadFont = require('load-bmfont');
                const createGeometry = require('three-bmfont-text');

我运行 npm run dev 和 npm run watch ,一切似乎都运行良好,但在 chrome developer 中,它记录了以下错误:

app.js:3524 Uncaught ReferenceError: THREE not defined at Object../node_modules/three-bmfont-text/index.js

我尝试安装和卸载三个和三个 bmfont-text 但没有任何变化,我错过了什么?

标签: javascriptthree.js

解决方案


推荐阅读