Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting basic example working on glitch #30

Closed
kfarr opened this issue Aug 10, 2023 · 7 comments
Closed

getting basic example working on glitch #30

kfarr opened this issue Aug 10, 2023 · 7 comments

Comments

@kfarr
Copy link

kfarr commented Aug 10, 2023

Hi Diarmid, not urgent but I was trying to get a basic example working but was not successful. Here is the sample project, all it is doing is loading a street and then trying to load 1 instance of an instanced mesh. Is there anything obviously wrong with my setup here or is this a bigger issue related to #28 ?

https://glitch.com/edit/#!/3dstreet-simple-instanced-mesh

@diarmidmackenzie
Copy link
Owner

Hi Kieran, I took a look at the glitch and I'm not sure I understand what the problem is?

The multiple instances of the car seem to be rendering OK to me. Can you explain what the issue is?

image

I'll post some updates on #28 with latest status there.

@kfarr
Copy link
Author

kfarr commented Aug 13, 2023

Hey @diarmidmackenzie sorry for the utterly confusing glitch. I've updated it to (a) remove the confusing street scene and (b) to show 4 examples clearly commented:

      <!-- normal gltf loader using asset loader -->
      <a-entity position="1 0 -5" gltf-model="#car-model"></a-entity>

      <!-- instanced mesh using asset loader -->
      <a-entity id="car-instanced" gltf-model="#car-model" instanced-mesh="capacity: 1000; positioning: world; updateMode: auto"></a-entity>
      <a-entity position="-1 0 -10" instanced-mesh-member="mesh:#car-instanced"></a-entity>

      <!-- using 3dstreet mixin (which uses gltf-model="url(path)" scheme) -->
      <a-entity position="-1 0 -5" mixin="sedan-rig"></a-entity>

      <!-- instanced mesh using 3dstreet mixin -->
      <a-entity id="car-instanced-mixin" mixin="sedan-rig" instanced-mesh="capacity: 1000; positioning: world; updateMode: auto"></a-entity>
      <a-entity position="1 0 -10" instanced-mesh-member="mesh:#car-instanced-mixin"></a-entity>

The "normal" loading ones are closest to the camera at -5 z and the instanced ones are at -10 z but neither appears to load.

Why am I bothering you about this? We are finally getting close to creating scenes to "show off" 3dstreet like this one: https://little-slow-november.glitch.me/ and we plan to have many vehicles and buildings that would definitely benefit from this component. That said there are a lot of irons in the fire right now so this is not urgent and I don't want to distract from higher priority things you might be working on.

@diarmidmackenzie
Copy link
Owner

diarmidmackenzie commented Aug 15, 2023

OK - this issue is that the model uses a SkinnedMesh, which isn't working.

The issue is with the code that traverses the GLTF model searching for the Meshes that make up the model.

if(node.type != "Mesh") return;

It identifies object3Ds of type 'Mesh', but not of type 'SkinnedMesh'.

There's no support in Three.js for instancing of skinned meshes....

https://discourse.threejs.org/t/instancedmesh-animations-like-with-skinnedmesh/12388/7#:~:text=No%2C%20that%20is%20not%20yet%20possible.

....so I'm not sure this can be accommodated very easily.
Edit: here's the latest on Instanced Skinned Meshes in THREE.js. Maybe not a million miles away from happening...

However I can definitely do a better job of error handling in this case. For now, I'll do a quick PR to document the restricton & provide a helpful error message when using Skinned Meshes.

Do you have the option of moving your model away from a Skinned Mesh?

@diarmidmackenzie
Copy link
Owner

One approach that may be useful in some cases would be to bake the default skeleton position into a standard Mesh. This would lose the animation capabilities of the Skinned Mesh, but would at least render a static version of the Skinned Mesh correctly.

Not sure I want to encourage this, though - in most cases, it's going to be preferable to pre-bake the bone positions into the model, and create a new GLTF that contains a Mesh rather than a Skinned Mesh.

It would be nice to be able to recommend a tool that can do this, but I don't know of one.

@diarmidmackenzie
Copy link
Owner

It's possible this baking can be done in Blender using something like this:
https://blender.stackexchange.com/questions/22882/how-do-i-delete-an-armature-but-keep-the-baked-pose

@kfarr
Copy link
Author

kfarr commented Aug 18, 2023

Thanks @diarmidmackenzie you're totally right and sorry for not thinking of this earlier. We will do this again with simplified models.

@kfarr
Copy link
Author

kfarr commented Aug 18, 2023

closing for now since this is out of scope for this component

@kfarr kfarr closed this as completed Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants