@@ -23,12 +23,12 @@ All portions of the code written by the Ethereal Engine team are Copyright © 20
23
23
Ethereal Engine. All Rights Reserved.
24
24
*/
25
25
26
- import { useEffect , useLayoutEffect } from 'react'
27
26
import { Vector3 } from 'three'
28
27
29
28
import { defineComponent , useComponent , useEntityContext , useOptionalComponent } from '@etherealengine/ecs'
30
29
import { useState } from '@etherealengine/hyperflux'
31
30
31
+ import { useLayoutEffect } from 'react'
32
32
import { useAncestorWithComponent } from '../../transform/components/EntityTree'
33
33
import { TransformComponent } from '../../transform/components/TransformComponent'
34
34
import { Physics } from '../classes/Physics'
@@ -88,10 +88,11 @@ export const ColliderComponent = defineComponent({
88
88
const triggerComponent = useOptionalComponent ( entity , TriggerComponent )
89
89
const hasCollider = useState ( false )
90
90
91
- useEffect ( ( ) => {
91
+ useLayoutEffect ( ( ) => {
92
92
if ( ! rigidbodyComponent || ! physicsWorld ) return
93
93
94
94
const colliderDesc = Physics . createColliderDesc ( physicsWorld , entity , rigidbodyEntity )
95
+
95
96
if ( ! colliderDesc ) return
96
97
97
98
Physics . attachCollider ( physicsWorld , colliderDesc , rigidbodyEntity , entity )
@@ -132,7 +133,7 @@ export const ColliderComponent = defineComponent({
132
133
Physics . setCollisionMask ( physicsWorld , entity , component . collisionMask . value )
133
134
} , [ physicsWorld , component . collisionMask ] )
134
135
135
- useEffect ( ( ) => {
136
+ useLayoutEffect ( ( ) => {
136
137
if ( ! physicsWorld || ! triggerComponent ?. value || ! hasCollider . value ) return
137
138
138
139
Physics . setTrigger ( physicsWorld , entity , true )
0 commit comments