question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'array' of undefined

See original GitHub issue

Hey there, absolutely love the work that’s being done with this project and react-three-fiber. Thank you so much!

I’m trying to convert a gltf file but I always run into the same error.

THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute().
THREE.BufferGeometry: .addAttribute() now expects ( name, attribute ).
...
...
THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute().
THREE.BufferGeometry: .addAttribute() now expects ( name, attribute ).
TypeError: Cannot read property 'array' of undefined
    at /Users/simonhales/.npm/_npx/10218/lib/node_modules/gltfjsx/bin/GLTFLoader.js:1171:57
    at async Promise.all (index 0)
    at async Promise.all (index 1)
loader failed

The command I’m running is npx gltfjsx Banana.gltf Banana.js --animation

I’ve uploaded my files here https://drive.google.com/drive/folders/1pE7XhITz5oE-WrQKoRPva6bQ24Mmacx8?usp=sharing

Banana.gltf is exported straight from Blender.

bananaDraco.gltf has been converted via gltf-pipeline

I’ve also included the original Blender file.

I verified that the files could be viewed via https://gltf-viewer.donmccurdy.com/

I’m not the most experienced dev (especially when it comes to this kind of stuff), but I have some time off at the moment so I shall clone this repo and see if I’m able to make any progress with determining the issue.

Note: I tested using the example .glb file in this repo, which had no issues.

Edit:

Just to add, I’m able to load Banana.gltf just fine via the example from the react-three-fiber readme.

import { useLoader } from 'react-three-fiber'
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'
...
const gltf = useLoader(GLTFLoader, url)
...

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
drcmdacommented, Feb 6, 2020

should be fixed! at least banana.gltf goes through. the draco thing for some reason still doesn’t. but you can at least keep on working, the output structure between the two would be the same.

0reactions
drcmdacommented, Feb 7, 2020

Do you just need the JSON from the glTF file? Or the exact threejs object hierarchy that GLTFLoader would return?

i think it would need to be the object hierarchy. i think relying on pure gltf would be the easiest when it comes to reading out, but emulating a basic threejs structure is probably going to be very hard.

the current workflow is based on the /bin directory in this repo, a fork of the loader and everything that ever wants to fetch requests for assets or create things that node can’t is removed little by little. i think i oriented myself around the gist you posted, i saw it in the threejs discourse forum i believe. unfortunately i must have minimized it in the very beginning, very clever … 🤭

Read more comments on GitHub >

github_iconTop Results From Across the Web

Javascript Uncaught TypeError: Cannot read property of ...
I'm trying to manipulate my response data in a way that each set of data group as a array ' ...
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
TypeError: Cannot read Property '0' of Undefined in JS
The "Cannot read Property '0' of undefined" error occurs when accessing an undefined value at index 0 . To solve the error, initialize...
Read more >
How to Fix TypeError: Cannot read Property 'push' of ...
How to Fix TypeError: Cannot read Property 'push' of Undefined in JavaScript ... When working with JavaScript arrays, you have to be careful...
Read more >
How to Prevent the Error: Cannot Read Property '0' of Undefined
If a property of an object is an array, it's possible to accidentally misspell the key or try to access the array through...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found