THREE:ObjectLoader: Can't parse https://cywarr.github.io/small-shop/Kirche3D.obj. Unexpected token # in JSON at position 0

I execute the command statement “import * as THREE from ‘three’” in the js code.
but have shown some bug in the console

my js code https://jsfiddle.net/meijun/f10bu6m5/

Jsfiddle can’t do import statements, as far as I know. You’ll have to use a different environment such as CodeSandBox.io for that.

If you want, you this example here to get yourself started, although it’s a bit opinionated since it’s using my NPM module three-app to abstract away lot of initialisation code.

1546844315453

Hello, I put the code in my local react file, just pasting the code temporarily on jsfiddle as a temporary code display

Hello, I am new to three.js, I am not sure why I will report an error when applying three.js to a react file.It is a successful code when it is pasted in the html page.

Here’s your problem:

const objLoader = new THREE.ObjectLoader(manager);

It’s a bit confusing, but ObjectLoader is actually for loading files in three.js JSON format.

To load OBJ files, you need to OBJLoader, which you need to include seperately the the main three.js script. See this example:

https://threejs.org/examples/?q=obj#webgl_loader_obj

Hello,This is my code:https://jsfiddle.net/meijun/f10bu6m5/5/
It have some new problem,I am very confused, for introducing a model of three.js in react

https://jsfiddle.net/meijun/f10bu6m5/9/
According to the link you provided, I updated the code again, but the error is as follows:
first:THREE:ObjectLoader: Can’t parse https://cywarr.github.io/small-shop/Kirche3D.obj. Unexpected token # in JSON at position 0
second:THREE.Object3D.add: object not an instance of THREE.Object3D. undefined

I have solved this problem, the code is in Case 4 on this blog below
https://blog.csdn.net/qq_37815596/article/details/85708779

Thank you for your reply, I have solved this problem.

Just out of curiousily, where did you find the link to my github repo?
In the link of this thread I’ve used THREE.OBJLoader(). Why did you use THREE.ObjectLoader() instead?

First of all, thank you very much for your provided. I saw it when I googled it. Because the code “imports * as THREE from ‘three’”, three.js has the ObjectLoader component, so I use THREE.ObjectLoader() instead。