-
-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Hi, I get an issue that if using gltf-transform to quantize my glb files to reduce memory, the transform for mergedMesh doesn't apply for the bvh, and the bvh just stacks at the origin if with bvh helper on.
I'm loading and processing model with custom hook and apply it to primitive on ready with position/rotation/scale applied, so at this point, the mergedMesh and its bvh will be generated from the originalMesh with transfrom applied.
{ model &&
<StaticCollider
key={`collider-${config.id}`}
onPointerEnter={onMeshPointerEnter}
onPointerLeave={onMeshPointerLeave}
onPointerOver={onMeshPointerOver}
onClick={onMeshClick}
onPointerMissed={onClickMissed}
debug={true}
bvhName={`bvh-${config.id}`}
>
<primitive
key={`primitive-collider-${config.id}`}
ref={ref}
object={model}
position={position}
rotation={rotation}
scale={scale}
visible={false}
>
{children}
</primitive>
</StaticCollider>
}
when the mesh is initially loaded, I'll compose a originBVHTransform with original position/rotation/scale, and when any position/rotation/scale changes, I'll calculate a currentMatrix and multiply it with originBVHTransform.invert() to get the relativeMatrix for the transform and apply to mergedMesh. This approach works fine and synchronize bvh and actual mesh transform with previous glb files not quantized, but now when using quantized mesh, it seems none transform applied to the bvh geometry. And not only the transform I added with code, the child mesh in the glb file doesn't get their transform applied.
to reproduce
-
use a glb file with nested meshes(child should have transform applied)
-
in code, put the loaded mesh inside staticCollider, and apply transform(position/rotation/scale) to it
-
set debug = true for staticCollider, the mesh and the bvhHelper should be synced
-
use same glb file, and use `gltf-transform quantize [fileName] [outputFilename] to process,
-
use same code to load the quantized model
-
all the bvhhelper should be stacking at origin, transform for childMesh(from the glb file) and root mesh(from code) are not applied to bvh.
I'm not familiar with gltf quantize approach and don't have a clue on this issue. Hope you can shed some light on it, thank you.