I believe mesh.getVerticesData(‘normal’) and multiplying that by mesh.getWorldMatrix() doesn’t not factor in skeleton data
How do I get the real world normals of meshes with skeletons?
Wouldn’t we need a function similar to getPositionData(applySkeleton, applyMorph)?
Hello! getPositionData accepts as an optional last argument the data you want to apply the transformations to, so you can pass the normals data to it I think the name of this function can be a bit confusing because it only talks about position. @sebavan @Deltakosh I wonder if we can “rename” (well we have to leave the old one too for back compat) it to getTransformedData
?
1 Like
Oh cool
Do I use it like
const normalsBuffer = mesh.getVerticesData('normal')
const normals = mesh.getPositionData(true, true, normalsBuffer)
then multiply each normal by mesh.getWorldMatrix()?
Odd but it doesn’t seem to be very accurate
The normal for the base of the foot went sideways
In fact there’s another bug
After rotating the leg, one would expect the normal to maintain its direction relative to the mesh, but unfortunately it does not with the getPositionData
function
The function only exists for positions not normals and the way it is applied would not work for a direction, only a position.
Do you want to create a PR to add an extra function ? this would mean factorizing out the shared part and mainly replacing TransformCoordinatesFromFloatsToRef by TransformNormalsFromFloatsToRef in case of directions
1 Like
Oh, I hadn’t paid attention to the TransformCoordinatesFromFloatsToRef on the getPositionData, thanks for pointing that out Seb
2 Likes
can’t wait for this, will this be in the next PR?
@mrlooi I was wondering if you want to do the PR ?
1 Like
I’d love to but I don’t know BJS well enough for that : /
What code do I reference? getPositionData?
You can take a look at our contribute guide! Start Contributing to Babylon.js | Babylon.js Documentation (babylonjs.com) (and if anything on the guide doesn’t make sense, please do ask here as we’re constantly trying to improve it)
And yeah, you should look at getPositionData in abstractMesh.ts: Babylon.js/abstractMesh.ts at master · BabylonJS/Babylon.js (github.com)
Ok I’ve created a (literal) function prototype of the code
It seems to work but I might miss something @sebavan
If someone could check this that’ll be awesome and I’ll be happy to submit a proper PR once it’s ready (or probably better for someone else who is more familiar with the BJS PR process )
1 Like
@carolhmj do you want to add this one in ? but probably factorizing to core part of the function.
1 Like