Skip to content

The transform style of the <Html/> be overwritten in some cases #2506

Description

@enpitsuLin
  • three version: ^0.179.1
  • @react-three/fiber version: ^9.3.0
  • @react-three/drei version: ^10.6.1
  • node version: 22.14.0
  • npm (or yarn) version: pnpm@10.13.1

Problem description:

When using <Html/> components on Next.js and set distanceFactor, I found that in some cases scale was not set correctly.

Check reproduction

If this issue does not occur initially, it will occur after navigating between the / and /page multiple times.

expect Image
actual in sometime Image

Relevant code:

reproduce on Stackblitz: https://stackblitz.com/~/github.com/enpitsuLin/r3f-deri-issue

Suggested solution:

I think here is root cause

el.style.cssText = `position:absolute;top:0;left:0;transform:translate3d(${vec[0]}px,${vec[1]}px,0);transform-origin:0 0;`

Assignment seems remove transform scale from

el.style.transform = `translate3d(${vec[0]}px,${vec[1]}px,0) scale(${scale})`

Maybe there are some race condition between useLayoutEffect (triggered by target changes) and useFrame execution. The execution sequence does not always proceed as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions