I have a blender model that has some shape keys on it. I export this model and use it in threejs. Lets say this is a cube. Then I create Three.Points that draws smalls spheres on the vertices of this model (i.e Cube).
var cube = loadGLTFFromBlender(gltfFile); // This loads the model
var points = new THREE.Points(cube.geometry, pointMaterial); //got my points
Now using the morphTargets, I animate the cube. So far so good.
//Some code that uses the shapee keys
cube.morphTargetInfluences[0] = 0.2; // <-- I animate this value
but I was expecting the points will also morph/animate since the points are using the same Geometry. But does not seem to work out of box.
Some Googling suggested that morphing happens at the GPU level and the geometry data in object, is not really modified. In one of the StackOverflow questions(Three.js: Get updated vertices with morph targets), @WestLangley suggested doing the same Geometry updates on the CPU and then using it.
My questions:
- Are there any other options in approaching this problem.
- The CPU morph calculation seems slower and I am trying to see if there is any other way to keep my Three.Points in sync with the morphed cube? The cube animated with morphtargets and I am expecting the Three.Points to do the same.
I guess #1 is not really a option if the shape key animations in blender are more involved?
Ideally, something like the following will help:
cube.morphTargetInfluences[0] = 0.2; // <-- I animate this value
var morphedGeometry = getMorphedGeometry(cube);
syncPointsGeometry(morphedGeometry);