@@ -30,7 +30,8 @@ import { VolumetricFileTypes } from '@etherealengine/engine/src/assets/constants
30
30
import {
31
31
getOptionalMutableComponent ,
32
32
hasComponent ,
33
- useComponent
33
+ useComponent ,
34
+ useOptionalComponent
34
35
} from '@etherealengine/engine/src/ecs/functions/ComponentFunctions'
35
36
import { VolumetricComponent } from '@etherealengine/engine/src/scene/components/VolumetricComponent'
36
37
import { PlayMode } from '@etherealengine/engine/src/scene/constants/PlayMode'
@@ -39,6 +40,7 @@ import { EngineState } from '@etherealengine/engine/src/ecs/classes/EngineState'
39
40
import { Entity } from '@etherealengine/engine/src/ecs/classes/Entity'
40
41
import { UVOL1Component } from '@etherealengine/engine/src/scene/components/UVOL1Component'
41
42
import { UVOL2Component } from '@etherealengine/engine/src/scene/components/UVOL2Component'
43
+ import { TextureType } from '@etherealengine/engine/src/scene/constants/UVOLTypes'
42
44
import { getState } from '@etherealengine/hyperflux/functions/StateFunctions'
43
45
import VideocamIcon from '@mui/icons-material/Videocam'
44
46
import { ItemTypes } from '../../constants/AssetTypes'
@@ -48,7 +50,6 @@ import { Button } from '../inputs/Button'
48
50
import CompoundNumericInput from '../inputs/CompoundNumericInput'
49
51
import InputGroup from '../inputs/InputGroup'
50
52
import SelectInput from '../inputs/SelectInput'
51
- import StringInput from '../inputs/StringInput'
52
53
import NodeEditor from './NodeEditor'
53
54
import { EditorComponentType , commitProperty , updateProperty } from './Util'
54
55
@@ -71,6 +72,13 @@ const PlayModeOptions = [
71
72
}
72
73
]
73
74
75
+ type TextureTargetLabelsType = {
76
+ [ key in TextureType ] : {
77
+ label : string
78
+ value : number
79
+ } [ ]
80
+ }
81
+
74
82
/**
75
83
* VolumetricNodeEditor provides the editor view to customize properties.
76
84
*
@@ -79,22 +87,39 @@ const PlayModeOptions = [
79
87
*/
80
88
export const VolumetricNodeEditor : EditorComponentType = ( props ) => {
81
89
const { t } = useTranslation ( )
82
- const [ trackLabel , setTrackLabel ] = React . useState ( '' )
83
90
84
91
const volumetricComponent = useComponent ( props . entity , VolumetricComponent )
85
92
86
93
const toggle = ( ) => {
87
94
volumetricComponent . paused . set ( ! volumetricComponent . paused . value )
88
95
}
89
96
97
+ const [ trackLabels , setTrackLabels ] = React . useState (
98
+ [ ] as {
99
+ label : string
100
+ value : number
101
+ } [ ]
102
+ )
103
+
90
104
useEffect ( ( ) => {
91
105
const tracks = volumetricComponent . paths . value
92
106
if ( tracks . length === 0 ) {
93
107
return
94
108
}
95
109
if ( tracks . length === 1 ) {
96
110
const segments = tracks [ 0 ] . split ( '/' )
97
- setTrackLabel ( segments [ segments . length - 1 ] )
111
+ setTrackLabels ( [
112
+ {
113
+ label : segments [ segments . length - 1 ] ,
114
+ value : 0
115
+ }
116
+ ] )
117
+ console . log ( 'Setting labels: ' , [
118
+ {
119
+ label : segments [ segments . length - 1 ] ,
120
+ value : 0
121
+ }
122
+ ] )
98
123
return
99
124
}
100
125
@@ -106,11 +131,81 @@ export const VolumetricNodeEditor: EditorComponentType = (props) => {
106
131
prefix = prefix . substring ( 0 , prefix . length - 1 )
107
132
}
108
133
}
134
+ const _trackLabels = [ ] as {
135
+ label : string
136
+ value : number
137
+ } [ ]
138
+
139
+ for ( let i = 0 ; i < tracks . length ; i ++ ) {
140
+ _trackLabels . push ( {
141
+ label : tracks [ i ] . slice ( prefix . length ) ,
142
+ value : i
143
+ } )
144
+ }
145
+ setTrackLabels ( _trackLabels )
146
+ console . log ( 'Setting labels: ' , _trackLabels )
147
+ } , [ volumetricComponent . paths ] )
109
148
110
- const currentTrackPath = tracks [ volumetricComponent . track . value ]
149
+ const uvol2 = useOptionalComponent ( props . entity , UVOL2Component )
150
+ const [ geometryTargets , setGeometryTargets ] = React . useState (
151
+ [ ] as {
152
+ label : string
153
+ value : number
154
+ } [ ]
155
+ )
156
+
157
+ useEffect ( ( ) => {
158
+ if ( uvol2 ) {
159
+ const _geometryTargets = [ ] as {
160
+ label : string
161
+ value : number
162
+ } [ ]
163
+ _geometryTargets . push ( {
164
+ label : 'auto' ,
165
+ value : - 1
166
+ } )
167
+ uvol2 . geometryInfo . targets . value . forEach ( ( target , index ) => {
168
+ _geometryTargets . push ( {
169
+ label : target ,
170
+ value : index
171
+ } )
172
+ } )
173
+ setGeometryTargets ( _geometryTargets )
174
+ }
175
+ } , [ uvol2 ?. geometryInfo . targets ] )
111
176
112
- setTrackLabel ( currentTrackPath . slice ( prefix . length ) )
113
- } , [ volumetricComponent . track , volumetricComponent . ended , volumetricComponent . paths ] )
177
+ const [ textureTargets , setTextureTargets ] = React . useState ( { } as TextureTargetLabelsType )
178
+ useEffect ( ( ) => {
179
+ if ( ! uvol2 ) {
180
+ return
181
+ }
182
+ const textureTypes = uvol2 . textureInfo . textureTypes . value
183
+ const _textureTargets = { } as TextureTargetLabelsType
184
+ textureTypes . forEach ( ( textureType ) => {
185
+ _textureTargets [ textureType ] = [ ] as {
186
+ label : string
187
+ value : number
188
+ } [ ]
189
+ _textureTargets [ textureType ] . push ( {
190
+ label : 'auto' ,
191
+ value : - 1
192
+ } )
193
+ uvol2 . textureInfo [ textureType ] . targets . value . forEach ( ( target , index ) => {
194
+ _textureTargets [ textureType ] . push ( {
195
+ label : target ,
196
+ value : index
197
+ } )
198
+ } )
199
+ } )
200
+ setTextureTargets ( _textureTargets )
201
+ } , [
202
+ uvol2 ?. textureInfo . textureTypes ,
203
+ uvol2 ?. textureInfo . baseColor . targets ,
204
+ uvol2 ?. textureInfo . normal . targets ,
205
+ uvol2 ?. textureInfo . emissive . targets ,
206
+ uvol2 ?. textureInfo . metallicRoughness . targets ,
207
+ uvol2 ?. textureInfo . occlusion . targets
208
+ ] )
114
209
115
210
return (
116
211
< NodeEditor
@@ -161,6 +256,18 @@ export const VolumetricNodeEditor: EditorComponentType = (props) => {
161
256
< VolumetricCurrentTimeScrubber entity = { props . entity } />
162
257
) }
163
258
259
+ < InputGroup name = "Playback Rate" label = "Playback Rate" >
260
+ < CompoundNumericInput
261
+ value = { volumetricComponent . currentTrackInfo . playbackRate . value }
262
+ min = { 0.5 }
263
+ max = { 4 }
264
+ step = { 0.1 }
265
+ onChange = { ( value : number ) => {
266
+ volumetricComponent . currentTrackInfo . playbackRate . set ( value )
267
+ } }
268
+ />
269
+ </ InputGroup >
270
+
164
271
< InputGroup name = "Play Mode" label = { t ( 'editor:properties.media.playmode' ) } >
165
272
< SelectInput
166
273
key = { props . entity }
@@ -177,8 +284,48 @@ export const VolumetricNodeEditor: EditorComponentType = (props) => {
177
284
) }
178
285
</ InputGroup >
179
286
287
+ { hasComponent ( props . entity , UVOL2Component ) && (
288
+ < >
289
+ < InputGroup name = "Geometry Target" label = "Geometry Target" >
290
+ < SelectInput
291
+ key = { props . entity }
292
+ options = { geometryTargets }
293
+ value = { uvol2 ?. geometryInfo . userTarget . value }
294
+ onChange = { ( value : number ) => {
295
+ if ( uvol2 ) {
296
+ uvol2 . geometryInfo . userTarget . set ( value )
297
+ }
298
+ } }
299
+ />
300
+ </ InputGroup >
301
+ { Object . keys ( textureTargets ) . map ( ( textureType , index ) => {
302
+ return (
303
+ < InputGroup name = { `${ textureType } target` } label = { `${ textureType } target` } key = { index } >
304
+ < SelectInput
305
+ key = { props . entity }
306
+ options = { textureTargets [ textureType ] }
307
+ value = { uvol2 ?. textureInfo [ textureType ] . userTarget . value }
308
+ onChange = { ( value : number ) => {
309
+ if ( uvol2 ) {
310
+ uvol2 ?. textureInfo [ textureType ] . userTarget . set ( value )
311
+ }
312
+ } }
313
+ />
314
+ </ InputGroup >
315
+ )
316
+ } ) }
317
+ </ >
318
+ ) }
319
+
180
320
< InputGroup name = "Current Track" label = "Current Track" >
181
- < StringInput value = { trackLabel } />
321
+ < SelectInput
322
+ key = { props . entity }
323
+ options = { trackLabels }
324
+ value = { trackLabels . length ? volumetricComponent . track . value : '' }
325
+ onChange = { ( value : number ) => {
326
+ volumetricComponent . track . set ( value )
327
+ } }
328
+ />
182
329
</ InputGroup >
183
330
</ NodeEditor >
184
331
)
@@ -196,19 +343,10 @@ function VolumetricCurrentTimeScrubber(props: { entity: Entity }) {
196
343
step = { 0.01 }
197
344
onChange = { ( value ) => {
198
345
const uvol2Component = getOptionalMutableComponent ( props . entity , UVOL2Component )
199
- const engineState = getState ( EngineState )
200
-
201
- volumetricComponent . startTime . set ( value )
202
- volumetricComponent . currentTrackInfo . currentTime . set ( value )
203
-
204
346
if ( uvol2Component ) {
205
- uvol2Component . playbackStartTime . set ( engineState . elapsedSeconds )
206
- uvol2Component . geometryInfo . bufferHealth . set ( 0 )
207
- uvol2Component . textureInfo . textureTypes . value . forEach ( ( textureType ) => {
208
- uvol2Component . textureInfo [ textureType ] . bufferHealth . set ( 0 )
209
- } )
347
+ const engineState = getState ( EngineState )
348
+ UVOL2Component . setStartAndPlaybackTime ( props . entity , value , engineState . elapsedSeconds )
210
349
}
211
- volumetricComponent . startTime . set ( volumetricComponent . currentTrackInfo . currentTime . value )
212
350
} }
213
351
value = { volumetricComponent . currentTrackInfo . currentTime . value }
214
352
/>
0 commit comments