11const Soup = require ( '@stews/soup' ) ;
22const aepl = require ( 'aepl' ) ;
33const OUT = new Soup ( Object ) ;
4- const yaml = require ( 'js-yaml ' ) ;
4+ const fs = require ( 'fs ' ) ;
55
66
77class Scene {
@@ -11,68 +11,13 @@ class Scene {
1111 this . lights = new this . parent . SceneLightGroup ;
1212 this . settings = new Soup ( Object ) ;
1313 }
14-
15-
16- spawn ( type , name , properties = { } ) {
17-
18- }
19-
20- translate ( data , meta ) {
21- Object . assign ( this , yaml . load ( meta ) ) ;
22-
23- let stuff = data . split ( "--- !u" ) ;
24- stuff . shift ( ) ;
25-
26- let ids = [ ] ;
27-
28- stuff = stuff . map ( s => {
29- s = s . split ( / ( \r \n | \n | \r ) / gm) ;
30- let id = s . shift ( ) ;
31- let eid = parseInt ( id . split ( " " ) [ 0 ] . replace ( "!" , "" ) ) ;
32- let fileID = parseInt ( id . split ( " " ) [ 1 ] . replace ( "&" , "" ) ) ;
33- ids . push ( { id : id , eid : eid , fileID : fileID } ) ;
34- s = s . filter ( thing => ! ( thing == "\r\n" ) ) ;
35- return s ;
36- } ) ;
37-
38-
39- this . occlusionCullingSettings = this . __createChild ( 'OcclusionCullingSettings' , stuff ) ;
40- this . renderSettings = this . __createChild ( 'RenderSettings' , stuff ) ;
41- this . lightmapSettings = this . __createChild ( 'LightmapSettings' , stuff ) ;
42- this . navMeshSettings = this . __createChild ( 'NavMeshSettings' , stuff ) ;
43-
44-
45- this . settings . push ( "occlusionCulling" , this . occlusionCullingSettings ) ;
46- this . settings . push ( "rendering" , this . renderSettings ) ;
47- this . settings . push ( "lightmap" , this . lightmapSettings ) ;
48- this . settings . push ( "navMesh" , this . navMeshSettings ) ;
49-
50-
51- stuff . shift ( ) ; stuff . shift ( ) ; stuff . shift ( ) ; stuff . shift ( ) ;
52- ids . shift ( ) ; ids . shift ( ) ; ids . shift ( ) ; ids . shift ( ) ;
53-
54- stuff . forEach ( ( s , i ) => {
55- let name = s [ 0 ] . replace ( ":" , "" ) ;
56- let { fileID } = ids [ i ] ;
57- try {
58- let obj = this . __createChild ( name , stuff ) ;
59-
60- if ( obj instanceof this . parent . GameObject ) { this . objects . push ( fileID , obj ) ; this . parent . objects . push ( fileID , obj ) ; }
61- if ( obj instanceof this . parent . Light ) { this . lights . push ( fileID , obj ) ; }
62-
63- this . children . push ( fileID , obj ) ;
64- } catch ( e ) { }
65-
66- } )
67- }
68-
69- __createChild ( name , settings ) {
70- let thing = settings . filter ( s => s [ 0 ] . includes ( name ) ) [ 0 ] ;
71- let stuff = yaml . load ( thing . join ( "\n" ) ) ;
72- return new this . parent [ name ] ( stuff [ name ] ) ;
73- }
7414}
7515
7616
7717OUT . push ( "Scene" , aepl . init ( "Scene" , Scene ) ) ;
7818module . exports = OUT . pour ( ) ;
19+
20+ let resFiles = fs . readdirSync ( __dirname + "/Resources" ) . filter ( file => file . endsWith ( ".js" ) ) ;
21+ resFiles . forEach ( file => {
22+ require ( './Resources/' + file ) ;
23+ } ) ;
0 commit comments