Brakebein/node-three-gltf

This error originated either by throwing inside of an async function without a catch block

quangArchiviet opened this issue ยท 8 comments

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<Object>".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

An error occurs when trying to load this model.

The model shows normally when using GLTFLoader and useGLTF on the Frontend.

I just released version 1.3.0. I found the bug within GLTFLoader not passing the attribute types (specific to animations) to DRACOLoader. It should work now.

Screen Shot 2022-10-04 at 21 22 30

Problem solved. But don't know why the model reversed. ๐Ÿ˜…

In my test render environment, the model looks fine and the orientation is correct. However, I don't apply any animations. Maybe, it has to do something with the animations wrongly applied?

Look like toJSON() didn't copy quaternion and rotation of the model objects.

Quaternion {
  isQuaternion: true,
  _x: -0.7071067811865475,
  _y: 0,
  _z: 0,
  _w: 0.7071067811865476,
  _onChangeCallback: [Function: onQuaternionChange]
}

Ahhhhhh ... even i push quaternion and rotation after convert the Scene to JSON format ... ObjectLoad parse still didn't use it ...

Have a look into the code: .toJSON() only takes the matrix (Object3D.js#L693). And if a matrix is defined, it won't consider any quaternion or rotation while parsing (ObjectLoader.js#L943-L957).
matrixAutoUpdate is either false or undefined, so in ObjectLoader the matrix won't get overridden by matrix.decompose() (on L948).

So, pushing quaternion and rotation won't do anything.

But it can be that the matrix is not set yet when converting to json. This is usually done automatically when you call renderer.render(). Because you won't call render() at the backend, you have to trigger this manually. So, before converting to json, try to update the matrices:

loader.load(file, (gltf) => {
  gltf.scene.updateMatrixWorld(true);
  // ...
});

Problem solved. I tried to update Matrix World at the frontend ... after converting to JSON ... That's why nothing changes... haha