pmndrs / drei

🥉 useful helpers for react-three-fiber
https://docs.pmnd.rs/drei
MIT License
8.28k stars 685 forks source link

Support ktx2 image in SpriteAnimator textureImageURL #1568

Open liho00 opened 1 year ago

liho00 commented 1 year ago

Describe the feature you'd like:

Expected putting .ktx2 in textureImageUrl prop will work

<SpriteAnimator
          castShadow
          receiveShadow
          attach={"sprite"}
          map={texture}
          frameName="female_hair_fx"
          animationNames={["female_hair_fx"]}
          position={[0.197, -0.04, 0.162]}
          rotation={[Math.PI / 2, 0, 0]}
          scale={0.064}
          startFrame={0}
          autoPlay={true}
          loop={true}
          numberOfFrames={24}
          textureDataURL={"/kprverse/female-hair-0.json"}
          textureImageURL={"/kprverse/female-hair-0.ktx2"} <--- this prop is not loaded as expected
        >

Suggested implementation:

Sorry, I dont have so much idea as im new to three js...

netgfx commented 1 year ago

I tried to do an implementation here: https://codesandbox.io/s/r3f-spriteanimator-gamepad-test-lvmkst?file=/src/SpriteAnimator.tsx:9942-9978

But the texture appears flipped (flipY doesn't do anything) and semi-transparent (for some reason). I don't have experience with ktx2 unfortunately, perhaps someone could pick it up from here.