Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 尝试导入错误:';OBJLoader';不是从';三个';(作为三个导入)_Reactjs_Animation_Three.js - Fatal编程技术网

Reactjs 尝试导入错误:';OBJLoader';不是从';三个';(作为三个导入)

Reactjs 尝试导入错误:';OBJLoader';不是从';三个';(作为三个导入),reactjs,animation,three.js,Reactjs,Animation,Three.js,当我尝试运行OBJLoader时,它给出了错误。尝试导入错误:“OBJLoader”未从“three”(导入为“three”)导出 请像这样导入OBJLoader: 从'three/examples/jsm/loaders/OBJLoader.js'导入{OBJLoader}; 不需要使用三个obj加载器。所有示例文件都可以作为threenpm包中的模块使用。当我运行它时,没有给出输出并显示此错误索引。js:1 SyntaxError:Unexpected token

当我尝试运行OBJLoader时,它给出了错误。尝试导入错误:“OBJLoader”未从“three”(导入为“three”)导出


请像这样导入
OBJLoader

从'three/examples/jsm/loaders/OBJLoader.js'导入{OBJLoader};

不需要使用三个obj加载器
。所有示例文件都可以作为
three
npm包中的模块使用。

当我运行它时,没有给出输出并显示此错误索引。js:1 SyntaxError:Unexpected token<在JSON中位于0的位置,GLTFLoader.parse()位于GLTFLoader.parse(GLTFLoader.js:281),Object.onLoad(GLTFLoader.js:174)位于XMLHttpRequest。(three.module.js:36513)此错误表明您的服务器没有正确提供js文件。请对此进行谷歌搜索,关于这个问题应该有多个线程。无限%loaded OBJLoader.js:716 THREE.OBJLoader:意外行:“parse@OBJLoader.js:716(匿名)@OBJLoader.js:455(匿名)@THREE.module.js:36513看起来像同一个问题。加载程序不会从服务器收到正确的OBJ文件,而是HTML文档。three.min.js:2 three.Object3D.add:object不是three.Object3D的实例
     import * as THREE from "three";
     import OBJLoader from "three-obj-loader";
     OBJLoader(THREE);

         const scene = new THREE.Scene();
            const camera = new THREE.PerspectiveCamera(
              75,
              window.innerWidth / window.innerHeight,
              0.1,
              1000
            );
        
            const renderer = new THREE.WebGLRenderer({ antialias: true });
            renderer.setSize(window.innerWidth, window.innerHeight);
            this.mount.appendChild(renderer.domElement);
        
           const loader = new OBJLoader();

            loader.load(
              "model/Room.obj",
              function (object) {
                scene.add(object);
              },
              function (xhr) {
                console.log((xhr.loaded / xhr.total) * 100 + "% loaded");
              },
              function (error) {
                console.log("An error happened");
              }
            );