2
2
3
3
const _ = require ( 'underscore' ) ;
4
4
const path = require ( 'path' ) ;
5
- const fs = require ( 'fs' ) ;
6
5
const fse = require ( 'fs-extra' ) ;
7
6
const Glob = require ( 'glob' ) . Glob ;
8
- const Promise = require ( 'bluebird' ) ;
9
7
const Handlebars = require ( 'handlebars' ) ;
10
8
11
- Promise . promisifyAll ( fs ) ;
12
- Promise . promisifyAll ( fse ) ;
13
-
14
9
const classConfigs = require ( './three-class-config' ) ;
15
10
const Types = require ( './prop-types.js' ) ;
16
11
@@ -56,9 +51,17 @@ const IGNORE_FILES = [
56
51
'**/animation/KeyframeTrackConstructor.js' , // Sub-part of one object, ignore
57
52
'**/animation/KeyframeTrackPrototype.js' , // Sub-part of one object, ignore
58
53
'**/audio/AudioContext.js' , // JS API for audio, nothing to expose
54
+ '**/core/Face3.js' , // Implemented as trait only, not widget model
59
55
'**/geometries/Geometries.js' , // index.js like file, nothing new here
60
56
'**/materials/Materials.js' , // index.js like file, nothing new here
61
57
'**/materials/MeshDistanceMaterial.js' , // TODO: Undocumented as of yet
58
+ '**/math/Vector2.js' , // Implemented as trait only, not widget model
59
+ '**/math/Vector3.js' , // Implemented as trait only, not widget model
60
+ '**/math/Vector4.js' , // Implemented as trait only, not widget model
61
+ '**/math/Matrix3.js' , // Implemented as trait only, not widget model
62
+ '**/math/Matrix4.js' , // Implemented as trait only, not widget model
63
+ '**/math/Color.js' , // Implemented as trait only, not widget model
64
+ '**/math/Euler.js' , // Implemented as trait only, not widget model
62
65
'**/renderers/WebGLRenderer.js' , // For now, the internals of the webgl
63
66
'**/renderers/WebGL2Renderer.js' , // render is not exposed.
64
67
//'**/renderers/webgl/**',
@@ -87,7 +90,7 @@ const IGNORE_FILES = [
87
90
function compileTemplate ( templateName ) {
88
91
templateName = path . basename ( templateName , '.mustache' ) ;
89
92
const templatePath = path . resolve ( templateDir , templateName + '.mustache' ) ;
90
- return Handlebars . compile ( fs . readFileSync ( templatePath , {
93
+ return Handlebars . compile ( fse . readFileSync ( templatePath , {
91
94
encoding : 'utf-8'
92
95
} ) ) ;
93
96
}
@@ -306,7 +309,7 @@ class JavascriptWrapper {
306
309
307
310
// check if manual file exists
308
311
const customSrcPath = path . join ( path . dirname ( this . jsDestPath ) , path . basename ( this . jsDestPath , '.js' ) + '.js' ) ;
309
- this . hasOverride = fs . existsSync ( customSrcPath ) ;
312
+ this . hasOverride = fse . existsSync ( customSrcPath ) ;
310
313
311
314
this . processSuperClass ( ) ;
312
315
this . processDependencies ( ) ;
@@ -363,7 +366,7 @@ class JavascriptWrapper {
363
366
364
367
result . absolutePath = path . resolve ( jsSrcDir , result . relativePath ) ;
365
368
let absPath = result . absolutePath ;
366
- if ( fs . existsSync ( absPath + '.js' ) ) {
369
+ if ( fse . existsSync ( absPath + '.js' ) ) {
367
370
absPath += '.js' ;
368
371
} else {
369
372
absPath += JS_AUTOGEN_EXT ;
@@ -524,7 +527,7 @@ function createJavascriptWrapper(modulePath, className) {
524
527
console . log ( 'skipping: ' + modulePath + ( className ? ':' + className : '' ) ) ;
525
528
return Promise . resolve ( false ) ;
526
529
}
527
- return fse . outputFileAsync ( wrapper . getOutputFilename ( ) , wrapper . output ) ;
530
+ return fse . outputFile ( wrapper . getOutputFilename ( ) , wrapper . output ) ;
528
531
529
532
// NOTE: Old implementation
530
533
// const wrapper = new JavascriptWrapper(modulePath);
@@ -553,7 +556,7 @@ function writeJavascriptIndexFiles() {
553
556
const dirAbsPath = path . resolve ( jsSrcDir , dirPath ) ;
554
557
555
558
// Generate list of files in dir to include in index.js as require lines
556
- return fs . readdirAsync ( dirAbsPath ) . then ( function ( dirFiles ) {
559
+ return fse . readdir ( dirAbsPath ) . then ( function ( dirFiles ) {
557
560
558
561
// get proper relative path for file
559
562
dirFiles = dirFiles . map ( function ( filename ) {
@@ -616,7 +619,7 @@ function writeJavascriptIndexFiles() {
616
619
const output = jsIndexTemplate ( context ) ;
617
620
const outputPath = path . resolve ( jsSrcDir , dirPath , 'index.js' ) ;
618
621
619
- return fse . outputFileAsync ( outputPath , output ) ;
622
+ return fse . outputFile ( outputPath , output ) ;
620
623
621
624
} ) ;
622
625
}
@@ -668,7 +671,9 @@ class PythonWrapper {
668
671
this . pyBaseRelativePath = relativePathToPythonImportPath ( this . pyBaseRelativePath ) ;
669
672
670
673
// check if manual file exists
671
- this . hasOverride = fs . existsSync ( this . pyDestPath ) ;
674
+ this . hasOverride = fse . existsSync ( this . pyDestPath ) ;
675
+
676
+ this . isCustom = CUSTOM_CLASSES . indexOf ( modulePath ) !== - 1 ;
672
677
673
678
this . hasParameters = false ;
674
679
@@ -681,7 +686,6 @@ class PythonWrapper {
681
686
this . processConstructorArgs ( ) ;
682
687
683
688
// Template and context
684
- this . template = pyWrapperTemplate ;
685
689
this . context = {
686
690
now : new Date ( ) ,
687
691
generatorScriptName : path . basename ( __filename ) ,
@@ -698,10 +702,11 @@ class PythonWrapper {
698
702
properties : this . properties ,
699
703
dependencies : this . dependencies ,
700
704
hasOverride : this . hasOverride ,
705
+ isCustom : this . isCustom ,
701
706
} ;
702
707
703
708
// Render template
704
- this . output = this . template ( this . context ) ;
709
+ this . output = pyWrapperTemplate ( this . context ) ;
705
710
706
711
}
707
712
@@ -727,7 +732,7 @@ class PythonWrapper {
727
732
// get path of dependency relative to module dir
728
733
result . absolutePath = path . resolve ( pySrcDir , result . relativePath ) ;
729
734
730
- if ( ! fs . existsSync ( result . absolutePath + '.py' ) ) {
735
+ if ( ! fse . existsSync ( result . absolutePath + '.py' ) ) {
731
736
result . absolutePath += '_' + AUTOGEN_EXT ;
732
737
}
733
738
@@ -821,12 +826,16 @@ class PythonWrapper {
821
826
822
827
processDocsUrl ( ) {
823
828
829
+ if ( this . isCustom ) {
830
+ this . docsUrl = null ;
831
+ }
832
+
824
833
const refTokens = this . modulePath . split ( pathSep ) ;
825
834
826
835
// strip extension off filename
827
836
refTokens [ refTokens . length - 1 ] = path . basename ( refTokens [ refTokens . length - 1 ] , '.js' ) ;
828
837
829
- let refUrl = 'http ://threejs.org/docs/#api/' + refTokens . join ( '/' ) ;
838
+ let refUrl = 'https ://threejs.org/docs/#api/' + refTokens . join ( '/' ) ;
830
839
831
840
// combine middle elements of url with dot
832
841
refUrl = refUrl . replace ( 'Renderers/WebGL/Plugins/' , 'Renderers.WebGL.Plugins/' ) ;
@@ -859,8 +868,10 @@ function createPythonWrapper(modulePath, className) {
859
868
console . log ( 'skipping: ' + modulePath + ( className ? ':' + className : '' ) ) ;
860
869
return Promise . resolve ( false ) ;
861
870
}
862
- return fse . outputFileAsync ( wrapper . getOutputFilename ( ) , wrapper . output ) ;
871
+ let fname = wrapper . getOutputFilename ( ) ;
872
+ let pyPromise = fse . outputFile ( fname , wrapper . output ) ;
863
873
874
+ return pyPromise ;
864
875
}
865
876
866
877
function createPythonModuleInitFile ( modulePath ) {
@@ -892,7 +903,7 @@ function createTopLevelPythonModuleFile() {
892
903
if ( / a u t o g e n / . test ( moduleName ) ) {
893
904
const overrideName = moduleName . replace ( '_autogen' , '' ) ;
894
905
const overridePath = path . resolve ( pySrcDir , modulePath , overrideName + '.py' ) ;
895
- if ( fs . existsSync ( overridePath ) ) {
906
+ if ( fse . existsSync ( overridePath ) ) {
896
907
console . log ( 'Python override exists: ' + overrideName + '. Skipping...' ) ;
897
908
return ;
898
909
}
@@ -925,7 +936,7 @@ function createTopLevelPythonModuleFile() {
925
936
const output = pyTopLevelInitTemplate ( context ) ;
926
937
const outFilePath = path . resolve ( pySrcDir , '__init__.py' ) ;
927
938
928
- return fse . outputFileAsync ( outFilePath , output ) ;
939
+ return fse . outputFile ( outFilePath , output ) ;
929
940
930
941
} ) ;
931
942
@@ -945,7 +956,7 @@ function createJavascriptFiles() {
945
956
function createPythonFiles ( ) {
946
957
947
958
// Prevent python file generation when outside dir (e.g. npm install in dependent)
948
- if ( ! fs . existsSync ( pySrcDir ) ) {
959
+ if ( ! fse . existsSync ( pySrcDir ) ) {
949
960
return Promise . resolve ( ) ;
950
961
}
951
962
@@ -975,6 +986,7 @@ function createPythonFiles() {
975
986
976
987
}
977
988
989
+
978
990
function generateFiles ( ) {
979
991
980
992
return Promise . all ( [
0 commit comments