Loading the 3D model in vue today keeps reporting errorsThere is no error in the code, but the path of the model is wrong, resulting in an error when loading the model (the model was originally placed under the assets path and imported through the relative path). After checking the data, it is found that the model file cannot be placed under the assets path, but under the public path, and the file under the public must be imported through the absolute path (this depends on the configuration of publicpath in vue.config.js. The default is /)
Specific code and steps for loading 3D model in Vue:
1. NPM install three — save package for installing three.js
2. Introduce three related packages
import * as THREE from 'three'; import {OrbitControls} from 'three/examples/jsm/controls/OrbitControls'; import {MTLLoader} from 'three/examples/jsm/loaders/MTLLoader'; import {OBJLoader} from 'three/examples/jsm/loaders/OBJLoader';
3. The model should be placed in the public folder. The resources placed in the public directory will be copied directly and will not be packaged by webpack
4. Load model
Read More:
- [Solved] Vue Project Error: error ‘v-model‘ directives require no argument vue/valid-v-model
- How to Solve Vue add element Install Error
- Vue: How to Solve Eslint error
- How to Solve “Vue is not defined” Error
- How to Solve Vue3 Import lodash error
- How to Solve VUE Error: Mixed spaces and tabs
- How to Solve Vue editor bridge error
- How to Solve Vue3 jweixin-module Error
- VUE: How to Solve NPM Always Install Error
- How to Solve Vue cli syntax Close Error
- How to Solve Vue3 using deep syntax Error
- How to Solve @Vue/cli3.X Using less Error
- How to Solve Vue cli configuration SCSS global variable error
- How to Solve VUE Error: Avoid mutating a prop directly since the value will be overwritten …
- How to Solve Vue route jump repeated clicks Error
- How to Solve Vue project Startup Error (Node Upgrade issue)
- How to Solve Vscode save Vue file eslint error
- Vue: How to Solve error avoided redundant navigation to current location: “/xxx”
- Vue2.0: How to Use vue3 api to encapsulate Axios
- [Solved] VUE D:\project\vueProject\vue-02\src\components\hello.vue 5:5 error Parsing error: x-invalid-end-tag