pmndrs / gltfjsx

🎮 Turns GLTFs into JSX components
https://gltf.pmnd.rs
MIT License
4.5k stars 293 forks source link

Unexpected Token '.' (react-three-fiber) #57

Closed pcdependency closed 3 years ago

pcdependency commented 3 years ago

I’ve used this tool many times and it somehow doesn't work. I believe this has to do with the update. Now that it has been updated it doesn’t work.

Normally I place my .gltf in my public folder and cd to the public folder. Then I used to run “npx @react-three/gltfjsx [filename.gltf]”, but now the format has changed to just “npx gltfjsx”. Even when I change the command to “npx gltfjsx [filename.gltf]” it doesn’t work. I’ve tested multiple .gltf files with the same result of an Unexpected Token ‘.’. It seems the update broke this useful command. Also the Twitter link at the top links to the old way, it's misleading to new users.

pcdependency commented 3 years ago

It's likely an issue within the module gltfjsx.js. Line 72 has a possible bug?

drcmda commented 3 years ago

no, but ¥our node version maybe cant handle optional chaining, i removed it. nice find!

wileyknight commented 3 years ago

Was this issue resolved? because I am still getting this error trying to use the tool. The error is coming from animations?.length. What is the workaround for this?

PATH\node_modules\gltfjsx\src\gltfjsx.js:72 let hasAnimations = gltf.animations?.length > 0

SyntaxError: Unexpected token '.' at wrapSafe (internal/modules/cjs/loader.js:1054:16) at Module._compile (internal/modules/cjs/loader.js:1102:27) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10) at Module.load (internal/modules/cjs/loader.js:986:32) at Function.Module._load (internal/modules/cjs/loader.js:879:14) at Module.require (internal/modules/cjs/loader.js:1026:19) at require (internal/modules/cjs/helpers.js:72:18) at Object. (PATH\node_modules\gltfjsx\src\components\App.js:12:17) at Module._compile (internal/modules/cjs/loader.js:1138:30) at Module.module._compile (PATH\node_modules\import-jsx\index.js:45:11)

drcmda commented 3 years ago

https://github.com/pmndrs/gltfjsx/blob/master/src/gltfjsx.js#L72 it's fixed.

ghost commented 3 years ago

@drcmda I suggest a release? This is still present in downloads but replacing the code that was added on line 72 works great : ] thanks for the fix!

drcmda commented 3 years ago

oh, youre right - i was a 100% sure i did release

ghost commented 3 years ago

@drcmda I really like this project and am wondering how I could become a contributor? I have noticed some errors when creating jsx or tsx files and would definitely like to help. Also no worries it's technically fixed.

drcmda commented 3 years ago

you could start by making pr's. i would be glad to add more people to the team that looks out for it. there are many interesting things we can still do with it.

ghost commented 3 years ago

@drcmda alrighty will do 😄