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

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelEstes committed Aug 14, 2024
1 parent 8ca240e commit ee4934d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@
"request": "launch",
"type": "node-terminal",
},
{
"command": "cd packages/network && npm run test",
"name": "npm run test - network",
"request": "launch",
"type": "node-terminal",
},
{
"command": "cd packages/engine && npm run test",
"name": "npm run test - engine",
Expand Down
5 changes: 3 additions & 2 deletions packages/ecs/src/ComponentFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,11 @@ export const setComponent = <C extends Component>(
root['component'] = Component.name
Component.reactorMap.set(entity, root)
return getComponent(entity, Component) as ComponentType<C>
} else {
const root = Component.reactorMap.get(entity)
root?.run()
}

const root = Component.reactorMap.get(entity)
root?.run()
return getComponent(entity, Component) as ComponentType<C>
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
updateMaterialPrototype
} from '@etherealengine/spatial/src/renderer/materials/materialFunctions'

import { defineState, getState, useImmediateEffect } from '@etherealengine/hyperflux'
import { MeshComponent } from '@etherealengine/spatial/src/renderer/components/MeshComponent'
import {
MaterialInstanceComponent,
Expand All @@ -61,7 +62,7 @@ import { Material, MeshBasicMaterial } from 'three'
import { SourceComponent } from '../../components/SourceComponent'

const reactor = (): ReactElement => {
useEffect(() => {
useImmediateEffect(() => {
MaterialPrototypeDefinitions.map((prototype: MaterialPrototypeDefinition, uuid) =>
createMaterialPrototype(prototype)
)
Expand Down Expand Up @@ -90,12 +91,13 @@ const MeshReactor = () => {
if (source) setComponent(materialEntity, SourceComponent, source)
}

useEffect(() => {
useImmediateEffect(() => {
if (materialComponent) return
const material = meshComponent.material.value as Material
if (!isArray(material)) createAndSourceMaterial(material)
else for (const mat of material) createAndSourceMaterial(mat)
}, [])

return null
}

Expand Down Expand Up @@ -135,8 +137,16 @@ const MaterialInstanceReactor = () => {
return null
}

export const MaterialLibraryReactorState = defineState({
name: 'ee.engine.scene.MaterialLibrarySystem',
initial: () => false,
reactor
})

export const MaterialLibrarySystem = defineSystem({
uuid: 'ee.engine.scene.MaterialLibrarySystem',
insert: { after: PresentationSystemGroup },
reactor
execute: () => {
getState(MaterialLibraryReactorState)
}
})

0 comments on commit ee4934d

Please sign in to comment.