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
Show file tree
Hide file tree
Changes from 82 commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { CameraOrbitComponent } from '@etherealengine/spatial/src/camera/compone
import { NameComponent } from '@etherealengine/spatial/src/common/NameComponent'
import { addObjectToGroup } from '@etherealengine/spatial/src/renderer/components/GroupComponent'
import { VisibleComponent } from '@etherealengine/spatial/src/renderer/components/VisibleComponent'
import { MaterialComponent, MaterialComponents } from '@etherealengine/spatial/src/renderer/materials/MaterialComponent'
import { MaterialStateComponent } from '@etherealengine/spatial/src/renderer/materials/MaterialComponent'
import { getMaterial } from '@etherealengine/spatial/src/renderer/materials/materialFunctions'

export const MaterialPreviewCanvas = () => {
Expand All @@ -58,8 +58,7 @@ export const MaterialPreviewCanvas = () => {
orbitCamera.refocus.set(true)
}, [
selectedMaterial,
useComponent(UUIDComponent.getEntityByUUID(selectedMaterial.value!), MaterialComponent[MaterialComponents.State])
.material
useComponent(UUIDComponent.getEntityByUUID(selectedMaterial.value!), MaterialStateComponent).material
])
return (
<>
Expand Down
40 changes: 19 additions & 21 deletions packages/editor/src/components/materials/MaterialEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,14 @@ import { setMaterialName } from '@etherealengine/engine/src/scene/materials/func
import { NO_PROXY } from '@etherealengine/hyperflux'
import createReadableTexture from '@etherealengine/spatial/src/renderer/functions/createReadableTexture'
import {
MaterialComponent,
MaterialComponents,
prototypeByName
MaterialPrototypeComponent,
MaterialStateComponent
} from '@etherealengine/spatial/src/renderer/materials/MaterialComponent'
import { none, State, useHookstate } from '@hookstate/core'
import { EditorControlFunctions } from '../../functions/EditorControlFunctions'
import { Button } from '../inputs/Button'
import { InputGroup } from '../inputs/InputGroup'
import ParameterInput from '../inputs/ParameterInput'
import SelectInput from '../inputs/SelectInput'
import StringInput from '../inputs/StringInput'
import { PanelDragContainer, PanelIcon, PanelTitle } from '../layout/Panel'
import { InfoTooltip } from '../layout/Tooltip'
Expand All @@ -66,13 +64,13 @@ const toBlobs = (thumbnails: Record<string, ThumbnailData>): Record<string, stri

export function MaterialEditor(props: { materialUUID: EntityUUID }) {
const { t } = useTranslation()
const prototypes = Object.keys(prototypeByName).map((prototype) => ({
label: prototype,
value: prototype
}))
// const prototypes = Object.keys(prototypeByName).map((prototype) => ({
// label: prototype,
// value: prototype
// }))

const entity = UUIDComponent.getEntityByUUID(props.materialUUID)
const materialComponent = useComponent(entity, MaterialComponent[MaterialComponents.State])
const materialComponent = useComponent(entity, MaterialStateComponent)
const material = materialComponent.material.value!
const thumbnails = useHookstate<Record<string, ThumbnailData>>({})
const textureUnloadMap = useHookstate<Record<string, (() => void) | undefined>>({})
Expand Down Expand Up @@ -138,7 +136,7 @@ export function MaterialEditor(props: { materialUUID: EntityUUID }) {
}, [materialName, prototypeName])

const prototypeEntity = materialComponent.prototypeEntity.value!
const prototype = useComponent(prototypeEntity, MaterialComponent[MaterialComponents.Prototype])
const prototype = useComponent(prototypeEntity, MaterialPrototypeComponent)

const shouldLoadTexture = async (value, key: string, parametersObject: State<any>) => {
let prop
Expand Down Expand Up @@ -215,14 +213,14 @@ export function MaterialEditor(props: { materialUUID: EntityUUID }) {
</InputGroup>
<br />
<InputGroup name="Prototype" label={t('editor:properties.mesh.material.prototype')}>
<SelectInput
{/* <SelectInput
value={prototypeName.value}
options={prototypes}
onChange={(protoId) => {
if (materialComponent.prototypeEntity.value) materialComponent.prototypeEntity.set(prototypeByName[protoId])
prototypeName.set(protoId)
}}
/>
/> */}
</InputGroup>
<Divider className={styles.divider} />
<ParameterInput
Expand Down Expand Up @@ -260,17 +258,17 @@ export function MaterialEditor(props: { materialUUID: EntityUUID }) {
{t('editor:properties.mesh.material.addPlugin')}
</Button>
</div>
{!!materialComponent.pluginEntities.value?.length && (
{/* {!!materialComponent.pluginEntities.value?.length && (
<div className={styles.contentContainer}>
<ParameterInput
entity={props.materialUUID}
values={pluginValues.value}
onChange={(key) => async (value) => {
// const property = await shouldLoadTexture(value, key, pluginParameters)
// getComponent(pluginEntity.value, MaterialComponent[MaterialComponents.Plugin]).parameters![
// materialName.value
// ][key].value = property
// pluginValues[key].set(property)
const property = await shouldLoadTexture(value, key, pluginParameters)
getComponent(pluginEntity.value, MaterialComponent[MaterialComponents.Plugin]).parameters![
materialName.value
][key].value = property
pluginValues[key].set(property)
}}
defaults={pluginParameters.value}
/>
Expand All @@ -280,15 +278,15 @@ export function MaterialEditor(props: { materialUUID: EntityUUID }) {
materialComponent.pluginEntities.set(
materialComponent.pluginEntities.value.filter((val) => val !== pluginEntity.value)
)
// if (pluginState && pluginState.parameters && pluginState.parameters[materialName.value])
// pluginState.parameters[materialName.value].set(none)
if (pluginState && pluginState.parameters && pluginState.parameters[materialName.value])
pluginState.parameters[materialName.value].set(none)
pluginEntity.set(UndefinedEntity)
}}
>
Remove Plugin
</Button>
</div>
)}
)} */}
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import { useDrag } from 'react-dnd'
import { EntityUUID, getOptionalComponent, UUIDComponent } from '@etherealengine/ecs'
import { MaterialSelectionState } from '@etherealengine/engine/src/scene/materials/MaterialLibraryState'
import { getMutableState, useHookstate, useMutableState } from '@etherealengine/hyperflux'
import { MaterialComponent, MaterialComponents } from '@etherealengine/spatial/src/renderer/materials/MaterialComponent'

import { MaterialStateComponent } from '@etherealengine/spatial/src/renderer/materials/MaterialComponent'
import { ItemTypes } from '../../constants/AssetTypes'
import { SelectionState } from '../../services/SelectionServices'
import styles from '../hierarchy/styles.module.scss'
Expand All @@ -57,10 +57,8 @@ export type MaterialLibraryEntryProps = {

const nodeDisplayName = (node: MaterialLibraryEntryType) => {
return (
getOptionalComponent(
UUIDComponent.getEntityByUUID(node.uuid as EntityUUID),
MaterialComponent[MaterialComponents.State]
)?.material?.name ?? ''
getOptionalComponent(UUIDComponent.getEntityByUUID(node.uuid as EntityUUID), MaterialStateComponent)?.material
?.name ?? ''
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ import {
} from '@etherealengine/engine/src/scene/materials/functions/materialSourcingFunctions'
import { MaterialSelectionState } from '@etherealengine/engine/src/scene/materials/MaterialLibraryState'
import { getMutableState, getState, useHookstate, useState } from '@etherealengine/hyperflux'
import { MaterialComponent, MaterialComponents } from '@etherealengine/spatial/src/renderer/materials/MaterialComponent'

import { MaterialStateComponent } from '@etherealengine/spatial/src/renderer/materials/MaterialComponent'
import { uploadProjectFiles } from '../../functions/assetFunctions'
import { EditorState } from '../../services/EditorServices'
import { SelectionState } from '../../services/SelectionServices'
Expand All @@ -54,7 +54,7 @@ import MaterialLibraryEntry, { MaterialLibraryEntryType } from './MaterialLibrar
export default function MaterialLibraryPanel() {
const srcPath = useState('/mat/material-test')

const materialQuery = useQuery([MaterialComponent[MaterialComponents.State]])
const materialQuery = useQuery([MaterialStateComponent])
const nodes = useHookstate([] as MaterialLibraryEntryType[])
const selected = useHookstate(getMutableState(SelectionState).selectedEntities)

Expand Down
13 changes: 5 additions & 8 deletions packages/editor/src/functions/addMediaNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import iterateObject3D from '@etherealengine/spatial/src/common/functions/iterat
import { GroupComponent } from '@etherealengine/spatial/src/renderer/components/GroupComponent'
import { ObjectLayerComponents } from '@etherealengine/spatial/src/renderer/components/ObjectLayerComponent'
import { ObjectLayers } from '@etherealengine/spatial/src/renderer/constants/ObjectLayers'
import { MaterialComponent, MaterialComponents } from '@etherealengine/spatial/src/renderer/materials/MaterialComponent'
import { MaterialInstanceComponent } from '@etherealengine/spatial/src/renderer/materials/MaterialComponent'
import { getMaterial } from '@etherealengine/spatial/src/renderer/materials/materialFunctions'
import { EditorControlFunctions } from './EditorControlFunctions'

Expand Down Expand Up @@ -98,17 +98,14 @@ export async function addMediaNode(

const materialEntity = UUIDComponent.getEntityByUUID(material.uuid as EntityUUID)
if (materialEntity) material = getMaterial(material.uuid as EntityUUID)!
const materialStateComponent = getMutableComponent(materialEntity, MaterialComponent[MaterialComponents.State])

iterateObject3D(intersected.object, (mesh: Mesh) => {
if (!mesh?.isMesh) return
const materialInstanceComponent = getMutableComponent(
mesh.entity,
MaterialComponent[MaterialComponents.Instance]
)
const materialInstanceComponent = getMutableComponent(mesh.entity, MaterialInstanceComponent)
if (materialInstanceComponent.uuid.value) materialInstanceComponent.uuid.set([material.uuid as EntityUUID])
if (materialStateComponent.instances.value)
materialStateComponent.instances.set([...materialStateComponent.instances.value, mesh.entity])
/**this SHOULD be handled by library reactor */
// if (materialStateComponent.instances.value)
// materialStateComponent.instances.set([...materialStateComponent.instances.value, mesh.entity])
})
})
} else if (contentType.startsWith('model/lookdev')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import matches from 'ts-matches'
import { EntityUUID, getComponent, hasComponent, UUIDComponent } from '@etherealengine/ecs'
import { NameComponent } from '@etherealengine/spatial/src/common/NameComponent'
import {
MaterialComponent,
MaterialComponents,
MaterialPlugins
MaterialPlugins,
MaterialPrototypeComponent,
MaterialStateComponent
} from '@etherealengine/spatial/src/renderer/materials/MaterialComponent'

import { injectMaterialDefaults } from '../../../../scene/materials/functions/materialSourcingFunctions'
Expand Down Expand Up @@ -116,8 +116,8 @@ export default class EEMaterialExporterExtension extends ExporterExtension {
delete materialDef.normalTexture
delete materialDef.emissiveTexture
delete materialDef.emissiveFactor
const materialComponent = getComponent(materialEntity, MaterialComponent[MaterialComponents.State])
const prototype = getComponent(materialComponent.prototypeEntity!, MaterialComponent[MaterialComponents.Prototype])
const materialComponent = getComponent(materialEntity, MaterialStateComponent)
const prototype = getComponent(materialComponent.prototypeEntity!, MaterialPrototypeComponent)
const plugins = Object.keys(MaterialPlugins).map((plugin) => {
if (!hasComponent(materialEntity, MaterialPlugins[plugin])) return
const pluginComponent = getComponent(materialEntity, MaterialPlugins[plugin])
Expand Down
6 changes: 2 additions & 4 deletions packages/engine/src/assets/functions/exportMaterialsGLTF.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Ethereal Engine. All Rights Reserved.
import { BufferGeometry, Material, Mesh, Scene } from 'three'

import { Entity, getComponent } from '@etherealengine/ecs'
import { MaterialComponent, MaterialComponents } from '@etherealengine/spatial/src/renderer/materials/MaterialComponent'
import { MaterialStateComponent } from '@etherealengine/spatial/src/renderer/materials/MaterialComponent'

import { GLTFExporterOptions } from '../exporters/gltf/GLTFExporter'
import createGLTFExporter from './createGLTFExporter'
Expand All @@ -40,9 +40,7 @@ export default async function exportMaterialsGLTF(
scene.name = 'Root'
const dudGeo = new BufferGeometry()
dudGeo.groups = materialEntities.map((_, i) => ({ count: 0, start: 0, materialIndex: i }))
const materials = materialEntities.map(
(entity) => getComponent(entity, MaterialComponent[MaterialComponents.State]).material as Material
)
const materials = materialEntities.map((entity) => getComponent(entity, MaterialStateComponent).material as Material)
const lib = new Mesh(dudGeo, materials)
lib.name = 'Materials'
scene.add(lib)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ import matches from 'ts-matches'

import { getComponent, UUIDComponent } from '@etherealengine/ecs'
import {
MaterialComponent,
MaterialComponents,
MaterialPrototypeComponent,
MaterialPrototypeObjectConstructor,
prototypeByName
MaterialStateComponent
} from '@etherealengine/spatial/src/renderer/materials/MaterialComponent'

import {
getPrototypeConstructorFromName,
getPrototypeEntityFromName,
injectMaterialDefaults,
PrototypeNotFoundError
} from '../../../../scene/materials/functions/materialSourcingFunctions'
Expand All @@ -57,7 +56,10 @@ export class EEMaterialImporterExtension extends ImporterExtension implements GL
const eeMaterial: EEMaterialExtensionType = materialDef.extensions[this.name] as any
let constructor: MaterialPrototypeObjectConstructor | null = null
try {
constructor = getPrototypeConstructorFromName(eeMaterial.prototype)
constructor = getComponent(
getPrototypeEntityFromName(eeMaterial.prototype)!,
MaterialPrototypeComponent
).prototypeConstructor
} catch (e) {
if (e instanceof PrototypeNotFoundError) {
console.warn('prototype ' + eeMaterial.prototype + ' not found')
Expand Down Expand Up @@ -91,18 +93,14 @@ export class EEMaterialImporterExtension extends ImporterExtension implements GL
}
}
}
const materialComponent = getComponent(
UUIDComponent.getEntityByUUID(extension.uuid),
MaterialComponent[MaterialComponents.State]
)
const materialComponent = getComponent(UUIDComponent.getEntityByUUID(extension.uuid), MaterialStateComponent)
let foundPrototype = false
if (materialComponent) {
foundPrototype = !!materialComponent.prototypeConstructor
foundPrototype = !!materialComponent.prototypeEntity
injectMaterialDefaults(extension.uuid)
} else {
try {
getComponent(prototypeByName[extension.prototype], MaterialComponent[MaterialComponents.Prototype])
.prototypeArguments
getComponent(getPrototypeEntityFromName(extension.prototype)!, MaterialPrototypeComponent).prototypeArguments
foundPrototype = true
} catch (e) {
if (e instanceof PrototypeNotFoundError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { TransformComponent } from '@etherealengine/spatial'
import { FollowCameraComponent } from '@etherealengine/spatial/src/camera/components/FollowCameraComponent'
import { XRControlsState } from '@etherealengine/spatial/src/xr/XRState'

import { MaterialComponent, MaterialComponents } from '@etherealengine/spatial/src/renderer/materials/MaterialComponent'
import { MaterialInstanceComponent } from '@etherealengine/spatial/src/renderer/materials/MaterialComponent'
import {
TransparencyDitheringPlugin,
TransparencyDitheringRoot,
Expand Down Expand Up @@ -119,7 +119,7 @@ export const AvatarTransparencySystem = defineSystem({

const DitherChildReactor = (props: { entity: Entity; rootEntity: Entity }) => {
const entity = props.entity
const materialComponentUUID = useOptionalComponent(entity, MaterialComponent[MaterialComponents.Instance])?.uuid
const materialComponentUUID = useOptionalComponent(entity, MaterialInstanceComponent)?.uuid
useEffect(() => {
if (!materialComponentUUID?.value) return
for (const materialUUID of materialComponentUUID.value) {
Expand Down
9 changes: 6 additions & 3 deletions packages/engine/src/scene/components/EnvmapComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@ import { Entity } from '@etherealengine/ecs/src/Entity'
import { useEntityContext } from '@etherealengine/ecs/src/EntityFunctions'
import { GroupComponent } from '@etherealengine/spatial/src/renderer/components/GroupComponent'
import { MeshComponent } from '@etherealengine/spatial/src/renderer/components/MeshComponent'
import { MaterialComponent, MaterialComponents } from '@etherealengine/spatial/src/renderer/materials/MaterialComponent'
import { createDisposable } from '@etherealengine/spatial/src/resources/resourceHooks'

import {
MaterialInstanceComponent,
MaterialStateComponent
} from '@etherealengine/spatial/src/renderer/materials/MaterialComponent'
import { setPlugin } from '@etherealengine/spatial/src/renderer/materials/materialFunctions'
import { useTexture } from '../../assets/functions/resourceLoaderHooks'
import {
Expand Down Expand Up @@ -221,7 +224,7 @@ const EnvBakeComponentReactor = (props: { envmapEntity: Entity; bakeEntity: Enti
const { envmapEntity, bakeEntity } = props
const bakeComponent = useComponent(bakeEntity, EnvMapBakeComponent)
const group = useComponent(envmapEntity, GroupComponent)
const uuid = useComponent(envmapEntity, MaterialComponent[MaterialComponents.Instance]).uuid
const uuid = useComponent(envmapEntity, MaterialInstanceComponent).uuid
const [envMaptexture, error] = useTexture(bakeComponent.envMapOrigin.value, envmapEntity)
useEffect(() => {
const texture = envMaptexture
Expand Down Expand Up @@ -281,7 +284,7 @@ export const BoxProjectionPlugin = defineComponent({
const entity = useEntityContext()

useEffect(() => {
const materialComponent = getComponent(entity, MaterialComponent[MaterialComponents.State])
const materialComponent = getComponent(entity, MaterialStateComponent)

const callback = (shader, renderer) => {
const plugin = getComponent(entity, BoxProjectionPlugin)
Expand Down
Loading
Loading