Hi guys,
I’m using FBXLoader to load an animated model by using react-three-fiber. I want to draw grid linesegments on the model when the animation running. But It can’t.
const loadModel = () => {
const loader = new FBXLoader()
loader.setPath(resourcePath + '/')
loader.load(
mainFileName,
async (fbx) => {
// create animation
mixer = new THREE.AnimationMixer(fbx)
fbx.animations.forEach((clip) => {
if (mixer) {
const idle = mixer.clipAction(clip)
idle.play()
}
})
animate()
skeleton = new THREE.SkeletonHelper(fbx)
skeleton.visible = false
skeleton.updateMatrixWorld()
scene.add(skeleton)
fbx.traverse((node) => {
if (node instanceof THREE.Mesh) {
node.castShadow = true
node.receiveShadow = true
node.material.side = THREE.FrontSide
node.frustumCulled = false
node.wireframe = true
node.material = customMaterial
node.material.skinning = true
const mat = new THREE.MeshLambertMaterial({ color: color, skinning: true })
const mesh = new THREE.SkinnedMesh(node.geometry, mat)
mesh.material.wireframe = true
const wireframeGeomtry = new THREE.WireframeGeometry(mesh.geometry)
const wireframeMaterial = new THREE.LineBasicMaterial({ color: color })
const wireframe = new THREE.LineSegments(wireframeGeomtry, wireframeMaterial)
wireframe.visible = true
scene.add(wireframe)
}
})
},
async (event) => {
console.log(event.total)
}
)
}
This is my result.
i