-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
Add Mesh.getVertexPosition #25049
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
Add Mesh.getVertexPosition #25049
Conversation
It would be nice to make this generic so it works across any vertex attribute (normal, tangent, etc). For three-mesh-bvh (and ultimately three-gpu-pathtracer) the |
Handy! How about |
Can this be something like |
@gkjohnson That sounds like a good idea to me. @mrdoob, would you prefer |
Heh, just position, normal, and tangent are not necessarily enough. All vertex attributes include color, uv, and other custom attributes can all be morphed, no? I think it should be a general function and then implentations like getVertexPosition( i, target ) {
return this.getVertexAttribute( 'position', i, target );
} |
@mrdoob I've updated this to |
examples/jsm/utils/SceneUtils.js
Outdated
|
||
} | ||
|
||
if ( !child.isSkinnedMesh ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linting:
The indentation is incorrect.
Also, it should be ! child.isSkinnedMesh
-- with a space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, good call; I thought the auto-linting would catch that kind of thing now.
Unrelated: In what coordinate space is the returned position in |
Sorry about that, I'll add it.
It's in local space. Honestly though, I feel like there's some kind of bug, or something I don't understand, because I don't think that |
Please, please pursue this until it is understood. |
- add `Mesh.getVertexPosition()` - add doc comment of `SceneUtils.reduceVertices` See: mrdoob/three.js#25049
The glTF specification requires that the world transform of the SkinnedMesh have no direct effect on the final position of a vertex during skinning. Only the world transform of the bones should be used. The bones may or may not be descendants of the SkinnedMesh. The code above seems correct from this standpoint, if that's our intention for three.js as well. |
Ah, thank you for that explanation @donmccurdy, that mostly makes sense. I think that means |
@elalish Skinning in three.js is implemented in world space on the GPU. As I have said elsewhere, I think that is unadvisable due to the precision problems it can introduce. |
Also related: #24479 (comment). |
Whatever we decide for skinning computations, the intention is for |
* docs: update constructor doc comment of geometries See: mrdoob/three.js#25086 * docs: update doc comment of the constructor of BufferAttribute See: mrdoob/three.js#25046 the `normalized` was already optional in the typedef * feat: add TwoPassDoubleSide See: mrdoob/three.js#25165 also add doc comment of Side * feat: add `Mesh.getVertexPosition()` - add `Mesh.getVertexPosition()` - add doc comment of `SceneUtils.reduceVertices` See: mrdoob/three.js#25049 * feat: add `Object3D.getObjectsByProperty()` - add `Object3D.getObjectsByProperty()` - add doc comment of `Object3D.getObjectByProperty()` See: mrdoob/three.js#25006 * docs: add a doc comment of `PointLight.castShadow` See: mrdoob/three.js#25136 * feat (GLTFLoader): add loadNode hook See: mrdoob/three.js#25077 * feat (Nodes): New features and revisions - add three new nodes: `CacheNode`, `StackNode`, and `SpecularMIPLevelNode` - add `NodeCache` - add `getDefaultUV()` to `CubeTextureNode` and `TextureNode` - add `isGlobal()` to `Node` - add `cache` and `globalCache` to `NodeBuilder` - add missing `flowsData` to `NodeBuilder` - add `hasDependencies` to `TempNode` - add `maxMipLevel` and `cache` to `ShaderNodeBaseElements` - replace `maxMipLevel` -> `specularMIPLevel` of `ShaderNodeElements` - change constructor type and texture type of `MaxMipLevelNode` - add `SpecularMIPLevelNode` * feat (Nodes): add FogExp2 node Co-authored-by: Josh <[email protected]>
Somewhat related issues: #18334, #14499
Description
I'm implementing dynamic hotspots for model-viewer, which requires me to find the current position of a vertex in a possibly animated mesh. Three.js does this internally for raycasting, but doesn't expose the method. I've refactored slightly to expose it and slightly simplify the raycasting code. I'm pretty sure I've seen forum discussions where this feature was asked for, so hopefully I'm not the only user. I have tested this (and the updated
reduceVertices
) on my dynamic hotspots branch of model-viewer and it's all working properly, handling morph targets, skinned meshes, etc.