Skip to content

Commit

Permalink
Use useAfterRender instead of useBeforeRender
Browse files Browse the repository at this point in the history
Html component always had a delay in rendering. It seems the position of the attached node was not fully calculated in useBeforeRender, but in useAfterRender it is. Makes sense now, thinking about it. Now the Html component should update in "realtime".
Please confirm.
  • Loading branch information
dennemark authored Nov 17, 2022
1 parent 7f0eac1 commit 34105d0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/react-babylonjs/src/customComponents/Html.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import React, {
// import { unmountComponentAtNode } from 'react-dom'
import { createRoot } from 'react-dom/client'
import { FiberAbstractMeshProps, FiberAbstractMeshPropsCtor } from '../generatedProps'
import { useBeforeRender } from '../hooks/render'
import { useAfterRender } from '../hooks/render'
import { useScene } from '../hooks/scene'

function defaultCalculatePosition(el: AbstractMesh, camera: Camera) {
Expand Down Expand Up @@ -288,7 +288,7 @@ const Html = forwardRef(

const visible = useRef(true)

useBeforeRender(() => {
useAfterRender(() => {
const camera = scene?.activeCamera

if (camera && group.current) {
Expand Down

0 comments on commit 34105d0

Please sign in to comment.