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

IR-2726 Material Component Breakup #10406

Merged
merged 83 commits into from
Jun 25, 2024
Merged
Changes from 1 commit
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
cb61521
remove materialByName map and stop forcing unique names
AidanCaruso May 21, 2024
892c8a6
react to mesh components to create material instances
AidanCaruso May 22, 2024
ea09c35
Merge branch 'dev' into universal-material-entities
AidanCaruso May 22, 2024
a33296f
begin converting plugins to components
AidanCaruso May 23, 2024
356ce93
wip
AidanCaruso May 23, 2024
c00ef5d
wip
AidanCaruso May 23, 2024
c67bf13
Merge branch 'dev' into universal-material-entities
AidanCaruso May 23, 2024
8055d5e
shader uniforms set by component directly
AidanCaruso May 23, 2024
b3a975d
Merge branch 'dev' into universal-material-entities
AidanCaruso Jun 4, 2024
45d1731
transparency dithering simplification wip
AidanCaruso Jun 5, 2024
6854020
fixes
AidanCaruso Jun 5, 2024
5763d5a
plugin ui and component lookup when importing from ee material extension
AidanCaruso Jun 5, 2024
7b25b88
parameters work with ecs plugin components
AidanCaruso Jun 6, 2024
8a3a508
Merge branch 'dev' into universal-material-entities
AidanCaruso Jun 6, 2024
4ca7e4d
noise offset plugin conversion
AidanCaruso Jun 7, 2024
3cce4f4
Merge branch 'universal-material-entities' of https://github.com/ethe…
AidanCaruso Jun 7, 2024
127a674
Merge branch 'dev' into universal-material-entities
AidanCaruso Jun 7, 2024
8800d81
bpcem
AidanCaruso Jun 8, 2024
fd88130
various fixes
AidanCaruso Jun 8, 2024
85fde2a
Merge branch 'dev' into universal-material-entities
AidanCaruso Jun 10, 2024
30d8384
no more plugin component
AidanCaruso Jun 10, 2024
43d4229
plugin uniforms
AidanCaruso Jun 11, 2024
fe40ab1
Merge branch 'dev' into universal-material-entities
AidanCaruso Jun 11, 2024
eddaf0e
plugin import/exports work again
AidanCaruso Jun 11, 2024
751260f
wip
AidanCaruso Jun 11, 2024
f3fd68c
Merge branch 'dev' into universal-material-entities
AidanCaruso Jun 11, 2024
11c5b27
add lambert preprocessor directives to stop threejs redefinitions
AidanCaruso Jun 11, 2024
4e19d09
undo checkshadererrors commit
AidanCaruso Jun 11, 2024
4fa5377
ditto
AidanCaruso Jun 11, 2024
1cec028
update components
AidanCaruso Jun 11, 2024
b70091a
update noise plugin
AidanCaruso Jun 11, 2024
0c1b7f9
obc api tweaks
AidanCaruso Jun 12, 2024
28fcf54
Merge branch 'dev' into universal-material-entities
AidanCaruso Jun 12, 2024
5706866
Merge branch 'dev' into universal-material-entities
AidanCaruso Jun 12, 2024
6f1f47a
Merge branch 'dev' into universal-material-entities
AidanCaruso Jun 12, 2024
31608f2
fix plugin ui
AidanCaruso Jun 13, 2024
135489e
Merge branch 'universal-material-entities' of https://github.com/ethe…
AidanCaruso Jun 13, 2024
cb94576
Merge branch 'dev' into universal-material-entities
AidanCaruso Jun 13, 2024
4703007
cleanup
AidanCaruso Jun 13, 2024
a26e499
cleanup
AidanCaruso Jun 13, 2024
cd72b5f
Merge branch 'universal-material-entities' of https://github.com/ethe…
AidanCaruso Jun 13, 2024
a8025f1
Merge branch 'dev' into universal-material-entities
AidanCaruso Jun 13, 2024
4ba3682
wip
AidanCaruso Jun 13, 2024
72626d3
remove plugin by name map
AidanCaruso Jun 13, 2024
e8cefe3
Merge branch 'dev' into universal-material-entities
AidanCaruso Jun 14, 2024
849fb61
wip
AidanCaruso Jun 14, 2024
305e5d5
Merge branch 'universal-material-entities' into material-component-br…
AidanCaruso Jun 14, 2024
955c9d3
add needsupdate to setPlugin
dinomut1 Jun 14, 2024
543a4eb
wip
AidanCaruso Jun 14, 2024
7be4d13
fix cross imports
AidanCaruso Jun 15, 2024
276ce48
fix hasplugin
AidanCaruso Jun 15, 2024
453a0e8
Merge branch 'dev' into universal-material-entities
AidanCaruso Jun 15, 2024
ba4f6a2
Merge branch 'universal-material-entities' into material-component-br…
AidanCaruso Jun 16, 2024
ad5cc16
Merge branch 'dev' into universal-material-entities
AidanCaruso Jun 17, 2024
a5ceb80
Merge branch 'dev' into universal-material-entities
AidanCaruso Jun 17, 2024
1f919ab
wip
AidanCaruso Jun 17, 2024
b513cd1
fix plugin reference issues
AidanCaruso Jun 18, 2024
db0e4a9
cleanup logs
AidanCaruso Jun 18, 2024
f72fcd8
Merge branch 'universal-material-entities' of https://github.com/ethe…
AidanCaruso Jun 18, 2024
d65af8e
fix hashing
AidanCaruso Jun 18, 2024
6b42b6d
Merge branch 'dev' into universal-material-entities
AidanCaruso Jun 18, 2024
0c4a443
Merge branch 'dev' into universal-material-entities
AidanCaruso Jun 18, 2024
c217be2
reactive material preview updates
AidanCaruso Jun 18, 2024
75bdb1f
Merge branch 'universal-material-entities' of https://github.com/ethe…
AidanCaruso Jun 18, 2024
f7b1c90
Merge branch 'universal-material-entities' into material-component-br…
AidanCaruso Jun 18, 2024
2c43dfe
fix imports
AidanCaruso Jun 18, 2024
36d5a7c
fix various regressions around plugin parameter setting and exporting
AidanCaruso Jun 18, 2024
c0be1e2
use mesh instead
AidanCaruso Jun 18, 2024
4eafa4c
Merge branch 'universal-material-entities' into material-component-br…
AidanCaruso Jun 18, 2024
edab814
Merge branch 'dev' into universal-material-entities
AidanCaruso Jun 18, 2024
056c84c
Merge branch 'universal-material-entities' into material-component-br…
AidanCaruso Jun 18, 2024
e7d4554
fix missing source component errors
AidanCaruso Jun 18, 2024
bca5813
Merge branch 'universal-material-entities' into material-component-br…
AidanCaruso Jun 18, 2024
7b853e0
Merge branch 'dev' into material-component-breakup
AidanCaruso Jun 21, 2024
ee79c2a
remove plugin entity references in material editor
AidanCaruso Jun 21, 2024
fda6389
Merge branch 'dev' into material-component-breakup
AidanCaruso Jun 21, 2024
97b8c1b
fix prototype switching
AidanCaruso Jun 21, 2024
c47ce73
Merge branch 'material-component-breakup' of https://github.com/ether…
AidanCaruso Jun 21, 2024
39add23
move materialByHash to component definition
AidanCaruso Jun 22, 2024
f7a0499
restore onremove functionality
AidanCaruso Jun 22, 2024
8aab873
Merge branch 'dev' into material-component-breakup
AidanCaruso Jun 22, 2024
dcffd40
Merge branch 'dev' into material-component-breakup
AidanCaruso Jun 24, 2024
437d977
Merge branch 'dev' into material-component-breakup
HexaField Jun 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
react to mesh components to create material instances
  • Loading branch information
AidanCaruso committed May 22, 2024
commit 892c8a64fbf8d4a88e23afe3ccd8910314db2e8f
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import {
PresentationSystemGroup,
QueryReactor,
useComponent,
useEntityContext
useEntityContext,
useOptionalComponent
} from '@etherealengine/ecs'
import { defineSystem } from '@etherealengine/ecs/src/SystemFunctions'
import {
Expand All @@ -50,7 +51,10 @@ import {
} from '@etherealengine/spatial/src/renderer/materials/materialFunctions'
import { iterateEntityNode } from '@etherealengine/spatial/src/transform/components/EntityTree'

import { removeMaterial } from '../functions/materialSourcingFunctions'
import { MeshComponent } from '@etherealengine/spatial/src/renderer/components/MeshComponent'
import { isArray } from 'lodash'
import { Material } from 'three'
import { createMaterialInstance, removeMaterial } from '../functions/materialSourcingFunctions'

const reactor = (): ReactElement => {
useEffect(() => {
Expand All @@ -62,20 +66,32 @@ const reactor = (): ReactElement => {

return (
<>
{
<QueryReactor
Components={[MaterialComponent[MaterialComponents.Instance]]}
ChildEntityReactor={MaterialInstanceReactor}
/>
}
<QueryReactor
Components={[MaterialComponent[MaterialComponents.Instance]]}
ChildEntityReactor={MaterialInstanceReactor}
/>
<QueryReactor
Components={[MaterialComponent[MaterialComponents.State]]}
ChildEntityReactor={MaterialEntityReactor}
/>
<QueryReactor Components={[MeshComponent]} ChildEntityReactor={MeshReactor} />
</>
)
}

const MeshReactor = () => {
const entity = useEntityContext()
const materialComponent = useOptionalComponent(entity, MaterialComponent[MaterialComponents.Instance])
const meshComponent = useComponent(entity, MeshComponent)
useEffect(() => {
if (materialComponent) return
const material = meshComponent.material.value as Material
if (!isArray(material)) createMaterialInstance('', entity, material)
else for (const mat of material) createMaterialInstance('', entity, mat)
}, [])
return null
}

const MaterialEntityReactor = () => {
const entity = useEntityContext()
const materialComponent = useComponent(entity, MaterialComponent[MaterialComponents.State])
Expand Down
Loading