Attempting to perform a raycast on a skinned mesh post-skeleton alterations, with no animations involved to prioritize performance.
The challenge in this endeavor includes:
- Load skinned mesh and add it to the scene
- Make changes to the positions of specific bones in the loaded mesh
- Copy geometries of the transformed loaded mesh (potentially from a buffer?)
- Create a new mesh (a ghost mesh imitation) from the copied geometries and apply it
- Set up a raycast on the ghost mesh with an opacity material of 0.0
Though the aforementioned steps should function, I've been stuck on point 3 for three days now because I'm unable to retrieve transformed vertices after skinning.
var scene, camera, renderer, mesh, ghostMesh;
var raycaster = new THREE.Raycaster();
var raycasterMeshHelper;
// Rest of the code can be checked in the original text for reference.
// The code involves the initialization of the scene, camera, lighting, skeleton manipulation,
// and raycasting functions for the ghost mesh.
// The code snippet deals with creating a ghost mesh and setting up raycasting functionality.
Seeking assistance in resolving this issue using THREE.js build r98 or earlier, and without morph tangents, solely focusing on skinning bones. Apologies for any lack of clarity in my explanation, as I'm not an expert in this field.
I have refrained from sharing my method of computing transformed geometries due to my failures in the process. I've extensively researched this problem, encountering issues such as issue6440, which remains unresolved to date.
Although there are methods available for addressing this, such as https://jsfiddle.net/fnjkeg9x/1/, I've faced challenges, possibly due to differences in approach from projects like Stormtrooper that involve morph tangents.
EDIT:
I've created a codepen based on related discussions here and Stormtrooper. Starting with a simple box to create a bounding box around the skinned transformed mesh.
Unfortunately, there's a setback as it returns 0 at the following line:
boneMatrix.fromArray(skeleton.boneMatrices, si * 16);
Comparing the output from Stormtrooper with my example's console log: Screenshot image
Codepen showcasing the latest progress: https://codepen.io/donkeyLuck0/pen/XQbBMQ
Another idea is to programmatically apply the bones from the loaded model and rig them as a morph tangent (although unsure of the feasibility and approach).
Discovered an example of an animated model here with points tracking.