Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Commit

Permalink
prevent duplicate uuid error
Browse files Browse the repository at this point in the history
  • Loading branch information
AidanCaruso committed Jul 28, 2024
1 parent 4d958ff commit b5fda7a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/examples/gltf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ const GLTF = () => {
setComponent(entity, ModelComponent, { src: source.value })
}

const entity = createEntity()
setComponent(entity, UUIDComponent, 'ambient light' as EntityUUID)
setComponent(entity, NameComponent, 'Ambient Light')
setComponent(entity, TransformComponent)
setComponent(entity, EntityTreeComponent, { parentEntity: getState(EngineState).originEntity })
setComponent(entity, VisibleComponent, true)
setComponent(entity, DirectionalLightComponent, { color: new Color('white'), intensity: 1 })
if(!UUIDComponent.getEntityByUUID('ambient light' as EntityUUID)) {
const entity = createEntity()
setComponent(entity, UUIDComponent, 'ambient light' as EntityUUID)
setComponent(entity, NameComponent, 'Ambient Light')
setComponent(entity, TransformComponent)
setComponent(entity, EntityTreeComponent, { parentEntity: getState(EngineState).originEntity })
setComponent(entity, VisibleComponent, true)
setComponent(entity, DirectionalLightComponent, { color: new Color('white'), intensity: 1 })
}

return GLTFAssetState.loadScene(source.value, source.value)
}, [source])
Expand Down

0 comments on commit b5fda7a

Please sign in to comment.