1
- import React , { } from 'react'
1
+ import React from 'react'
2
2
import { useDrop } from 'react-dnd'
3
+ import { Vector3 } from 'three'
4
+
5
+ import { uploadToFeathersService } from '@etherealengine/client-core/src/util/upload'
6
+ import { StaticResourceInterface } from '@etherealengine/common/src/interfaces/StaticResourceInterface'
7
+ import { AdminAssetUploadArgumentsType } from '@etherealengine/common/src/interfaces/UploadAssetInterface'
3
8
import { DndWrapper } from '@etherealengine/editor/src/components/dnd/DndWrapper'
4
9
import { SupportedFileTypes } from '@etherealengine/editor/src/constants/AssetTypes'
5
- import { Template } from './utils/template'
6
- import { useHookstate } from '@etherealengine/hyperflux'
7
- import { uploadToFeathersService } from '@etherealengine/client-core/src/util/upload'
10
+ import {
11
+ getComponent ,
12
+ getMutableComponent ,
13
+ setComponent
14
+ } from '@etherealengine/engine/src/ecs/functions/ComponentFunctions'
8
15
import { createEntity } from '@etherealengine/engine/src/ecs/functions/EntityFunctions'
9
- import { getComponent , getMutableComponent , setComponent } from '@etherealengine/engine/src/ecs/functions/ComponentFunctions'
10
- import { TransformComponent } from '@etherealengine/engine/src/transform/components/TransformComponent'
11
- import { Vector3 } from 'three'
12
- import { VisibleComponent } from '@etherealengine/engine/src/scene/components/VisibleComponent'
16
+ import { ModelComponent } from '@etherealengine/engine/src/scene/components/ModelComponent'
13
17
import { NameComponent } from '@etherealengine/engine/src/scene/components/NameComponent'
14
18
import { VariantComponent } from '@etherealengine/engine/src/scene/components/VariantComponent'
15
- import { ModelComponent } from '@etherealengine/engine/src/scene/components/ModelComponent'
16
- import { AdminAssetUploadArgumentsType } from '@etherealengine/common/src/interfaces/UploadAssetInterface'
17
- import { StaticResourceInterface } from '@etherealengine/common/src/interfaces/StaticResourceInterface'
19
+ import { VisibleComponent } from '@etherealengine/engine/src/scene/components/VisibleComponent'
20
+ import { TransformComponent } from '@etherealengine/engine/src/transform/components/TransformComponent'
21
+ import { useHookstate } from '@etherealengine/hyperflux'
22
+
23
+ import { Template } from './utils/template'
18
24
19
25
const LODsDND = ( ) => {
20
26
const filenames = useHookstate < string [ ] > ( [ ] )
@@ -26,20 +32,20 @@ const LODsDND = () => {
26
32
const dndItem = monitor . getItem ( )
27
33
const entries = Array . from ( dndItem . items ) . map ( ( item : any ) => item . webkitGetAsEntry ( ) )
28
34
try {
29
- const files = await Promise . all (
35
+ const files = ( await Promise . all (
30
36
entries . map ( ( entry ) => new Promise ( ( resolve , reject ) => entry . file ( resolve , reject ) ) )
31
- ) as File [ ]
37
+ ) ) as File [ ]
32
38
filenames . set ( files . map ( ( file ) => file . name ) )
33
39
34
40
const uploadPromise = uploadToFeathersService ( 'upload-asset' , files , {
35
41
type : 'admin-file-upload' ,
36
42
args : {
37
- project : 'ee-development-test-suite' ,
43
+ project : 'ee-development-test-suite'
38
44
} as AdminAssetUploadArgumentsType ,
39
45
variants : true
40
46
} )
41
47
42
- const result = await uploadPromise . promise as StaticResourceInterface [ ]
48
+ const result = ( await uploadPromise . promise ) as StaticResourceInterface [ ]
43
49
44
50
console . log ( result )
45
51
@@ -49,7 +55,7 @@ const LODsDND = () => {
49
55
setComponent ( entity , NameComponent , 'LOD Test' )
50
56
51
57
setComponent ( entity , ModelComponent , {
52
- src : result [ 0 ] . url ,
58
+ src : result [ 0 ] . url
53
59
} )
54
60
setComponent ( entity , VariantComponent , {
55
61
levels : result . map ( ( variant , i ) => ( {
@@ -58,13 +64,12 @@ const LODsDND = () => {
58
64
src : variant . url ,
59
65
model : null ,
60
66
metadata : variant . metadata ?? {
61
- minDistance : 0 + ( i * 5 ) ,
62
- maxDistance : 0 + ( ( i + 1 ) * 5 ) ,
67
+ minDistance : 0 + i * 5 ,
68
+ maxDistance : 0 + ( i + 1 ) * 5
63
69
}
64
70
} ) ) ,
65
71
heuristic : 'DISTANCE'
66
72
} )
67
-
68
73
} catch ( err ) {
69
74
console . error ( err )
70
75
}
@@ -78,14 +83,17 @@ const LODsDND = () => {
78
83
} )
79
84
} )
80
85
81
- return < div style = { { height : '100%' , width : '100%' , background : 'white' , fontSize : '20px' } } ref = { onDropTarget } >
82
- Drag and drop LOD files here!
83
- { filenames . value . map ( ( filename , i ) => < div key = { filename + i } > - { filename } </ div > ) }
84
- </ div >
86
+ return (
87
+ < div style = { { height : '100%' , width : '100%' , background : 'white' , fontSize : '20px' } } ref = { onDropTarget } >
88
+ Drag and drop LOD files here!
89
+ { filenames . value . map ( ( filename , i ) => (
90
+ < div key = { filename + i } > - { filename } </ div >
91
+ ) ) }
92
+ </ div >
93
+ )
85
94
}
86
95
87
96
export default function LODs ( ) {
88
-
89
97
return (
90
98
< div id = "dnd-container" style = { { height : '25%' , width : '25%' , pointerEvents : 'all' } } >
91
99
< DndWrapper id = "dnd-container" >
0 commit comments