|
@@ -197,25 +197,27 @@ function replaceClippingPlaneNums( string, parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-function parseIncludes( string ) {
|
|
|
+// Resolve Includes
|
|
|
+
|
|
|
+var includePattern = /^[ \t]*#include +<([\w\d./]+)>/gm;
|
|
|
|
|
|
- var pattern = /^[ \t]*#include +<([\w\d./]+)>/gm;
|
|
|
+function parseIncludes( string ) {
|
|
|
|
|
|
- function replace( match, include ) {
|
|
|
+ return string.replace( includePattern, includeReplacer );
|
|
|
|
|
|
- var replace = ShaderChunk[ include ];
|
|
|
+}
|
|
|
|
|
|
- if ( replace === undefined ) {
|
|
|
+function includeReplacer( match, include ) {
|
|
|
|
|
|
- throw new Error( 'Can not resolve #include <' + include + '>' );
|
|
|
+ var string = ShaderChunk[ include ];
|
|
|
|
|
|
- }
|
|
|
+ if ( string === undefined ) {
|
|
|
|
|
|
- return parseIncludes( replace );
|
|
|
+ throw new Error( 'Can not resolve #include <' + include + '>' );
|
|
|
|
|
|
}
|
|
|
|
|
|
- return string.replace( pattern, replace );
|
|
|
+ return parseIncludes( string );
|
|
|
|
|
|
}
|
|
|
|