首页 > 解决方案 > 未找到 TextGeometry.js 和 FontLoader.js 依赖项

问题描述

我使用 Trois.js 来创建 Vue.js+Three.js 应用程序。我安装了Trois.js库:

npm install three@0.127 troisjs

我将一些基本元素导入到我的 Vue 模块中,例如RendererScene等等。

import {Renderer, Scene, Camera, Sphere} from 'troisjs'

当我运行时npm run serve,出现错误:

未找到这些依赖项:

  • ./node_modules/troisjs/build/trois.module.js 中的三个/examples/jsm/geometries/TextGeometry.js
  • ./node_modules/troisjs/build/trois.module.js 中的三个/examples/jsm/loaders/FontLoader.js

有趣的是,TextGeometry 和 FontLoader 存在于上述目录下的 node_modules 中:

..build/trois.module.js

import { TextGeometry } from 'three/examples/jsm/geometries/TextGeometry.js';
import { FontLoader } from 'three/examples/jsm/loaders/FontLoader.js';
...

我不知道为什么会出现这个错误,我重新安装了trois.js软件包但徒劳无功。还是不行。这是我的package.json文件:

{
  "name": "troisapp",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.6.5",
    "three": "^0.127.0",
    "troisjs": "^0.3.3",
    "vue": "^3.0.0",
    "vue-router": "^4.0.0-0",
    "vuex": "^4.0.0-0"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-plugin-router": "~4.5.0",
    "@vue/cli-plugin-vuex": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/compiler-sfc": "^3.0.0",
    "@vue/eslint-config-prettier": "^6.0.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^6.7.2",
    "eslint-plugin-prettier": "^3.3.1",
    "eslint-plugin-vue": "^7.0.0",
    "prettier": "^2.2.1"
  },
  "description": "## Project setup ``` npm install ```",
  "main": ".eslintrc.js",
  "keywords": [],
  "author": "",
  "license": "ISC"
}

标签: vue.jsthree.js

解决方案


TextGeometry并被FontLoader移至带有 的示例r133。意思trois.js是希望您使用更新的three.js版本而不是r127.


推荐阅读