diff --git a/gulpfile.js b/gulpfile.js index 3e4b80c..cb8c9f7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,6 +6,7 @@ var plumber = require('gulp-plumber'); var istanbul = require('gulp-istanbul'); var mocha = require('gulp-mocha'); var watch = require('gulp-watch'); +var preprocessor = require('gulp-c-preprocessor'); gulp.task( 'build', @@ -58,10 +59,92 @@ gulp.task( } ); + +gulp.task('compileRuntime', ['build'], + function() { + gulp.src(['./build/defines/runtime.js', './build/game-lib.js']) + .pipe(concat('game-lib-runtime.js')) + .pipe(preprocessor( + { + // End of line character + endLine: '\n', + + // Escape '//#' & '/*#' comments (see extra/comments) + commentEscape: true, + + // Empty lines to add between code and included files + includeSpaces: 0, + + // Limit of empty following lines (0 = no limit) + emptyLinesLimit: 0, + + // Base path for including files + basePath: './', + + // Stop the compiler when an error ocurred ? + stopOnError: true, + + // Constants in #enum command must be in hexadecimal ? + enumInHex: true + + }) + ) + .pipe(minify({ + ext:{ + src:'.js', + min:'-min.js' + } + })) + .pipe(gulp.dest('./build/')); + } +); + +gulp.task('compileEditor', ['build'], + function() { + gulp.src(['./build/defines/editor.js', './build/game-lib.js']) + .pipe(concat('game-lib-editor.js')) + .pipe(preprocessor( + { + // End of line character + endLine: '\n', + + // Escape '//#' & '/*#' comments (see extra/comments) + commentEscape: true, + + // Empty lines to add between code and included files + includeSpaces: 0, + + // Limit of empty following lines (0 = no limit) + emptyLinesLimit: 0, + + // Base path for including files + basePath: './', + + // Stop the compiler when an error ocurred ? + stopOnError: true, + + // Constants in #enum command must be in hexadecimal ? + enumInHex: true + + }) + ) + .pipe(minify({ + ext:{ + src:'.js', + min:'-min.js' + } + })) + .pipe(gulp.dest('./build/')); + } +); + + gulp.task( 'default', [ - 'build' + 'build', + 'compileRuntime', + 'compileEditor' ], function() { return watch([ @@ -69,7 +152,9 @@ gulp.task( ], function() { gulp.start([ - 'build' + 'build', + 'compileRuntime', + 'compileEditor' ]); }) } diff --git a/src/game-lib-a.js b/src/game-lib-a.js index b133e51..a48500a 100644 --- a/src/game-lib-a.js +++ b/src/game-lib-a.js @@ -22,4 +22,13 @@ if (typeof _ == 'undefined') { } var _ = require('lodash'); -} \ No newline at end of file +} + + +//#ifdef RUNTIME__ +console.log("Loading runtime library..."); +//#endif + +//#ifdef EDITOR__ +console.log("Loading editor library..."); +//#endif \ No newline at end of file diff --git a/src/game-lib-component-mesh-permutation.js b/src/game-lib-component-mesh-permutation.js index 6ca117d..bc1740d 100644 --- a/src/game-lib-component-mesh-permutation.js +++ b/src/game-lib-component-mesh-permutation.js @@ -31,6 +31,7 @@ GameLib.D3.ComponentMeshPermutation = function ComponentMeshPermutation( GameLib.D3.Utils.Extend(GameLib.D3.ComponentMeshPermutation, GameLib.D3.ComponentInterface); }; +//#ifdef RUNTIME__ if(typeof THREE != "undefined") { ComponentMeshPermutation_quaternion = new THREE.Quaternion(); ComponentMeshPermutation_quaternionCopy = new THREE.Quaternion(); @@ -67,4 +68,5 @@ GameLib.D3.ComponentMeshPermutation.prototype.onLateUpdate = function( parentEntity.mesh.quaternion.copy(ComponentMeshPermutation_quaternion); parentEntity.mesh.scale.copy(ComponentMeshPermutation_scale); } -}; \ No newline at end of file +}; +//#endif \ No newline at end of file diff --git a/src/game-lib-component-trigger-box-box.js b/src/game-lib-component-trigger-box-box.js index 5aaa2cd..ec44abc 100644 --- a/src/game-lib-component-trigger-box-box.js +++ b/src/game-lib-component-trigger-box-box.js @@ -31,10 +31,12 @@ GameLib.D3.ComponentTriggerBoxBox = function ComponentTriggerBoxBox( this.onLeave = onLeave || null; this.onSetParent = onSetParent || null; - // runtime code + // defines code this.entitiesInside = []; }; + +//#ifdef RUNTIME__ if(typeof THREE != "undefined") { ComponentTriggerBoxBox_BB = new THREE.Box3(); ComponentTriggerBoxBox_BBEntity = new THREE.Box3(); @@ -89,6 +91,8 @@ GameLib.D3.ComponentTriggerBoxBox.prototype.onUpdate = function( } } }; +//#endif + GameLib.D3.ComponentTriggerBoxBox.prototype.onSetParentEntity = function( parentScene, diff --git a/src/game-lib-component-trigger-box-sphere.js b/src/game-lib-component-trigger-box-sphere.js index ad76876..9a45a94 100644 --- a/src/game-lib-component-trigger-box-sphere.js +++ b/src/game-lib-component-trigger-box-sphere.js @@ -29,10 +29,11 @@ GameLib.D3.ComponentTriggerBoxSphere = function ComponentTriggerBoxSphere( this.onLeave = onLeave || null; this.onSetParent = onSetParent || null; - // runtime code + // defines code this.entitiesInside = []; }; +//#ifdef RUNTIME__ if(typeof THREE != "undefined") { ComponentTriggerBoxSphere_TargetPosition_Vec3 = new THREE.Vector3(); ComponentTriggerBoxSphere_TargetRadius = 0.0; @@ -115,6 +116,8 @@ GameLib.D3.ComponentTriggerBoxSphere.prototype.onUpdate = function( } }; +//#endif + GameLib.D3.ComponentTriggerBoxSphere.prototype.onSetParentEntity = function( parentScene, parentEntity diff --git a/src/game-lib-component-trigger-sphere-sphere.js b/src/game-lib-component-trigger-sphere-sphere.js index 0f68a81..960515c 100644 --- a/src/game-lib-component-trigger-sphere-sphere.js +++ b/src/game-lib-component-trigger-sphere-sphere.js @@ -41,10 +41,11 @@ GameLib.D3.ComponentTriggerSphereSphere = function ComponentTriggerSphereSphere( this.onLeave = onLeave || null; this.onSetParent = onSetParent || null; - // runtime code + // defines code this.entitiesInside = []; }; +//#ifdef RUNTIME__ if(typeof THREE != "undefined") { ComponentTriggerSphereSphere_spherePosition_Vector3 = new THREE.Vector3(); ComponentTriggerSphereSphere_targetBoundingSpherePosition_Vector3 = new THREE.Vector3(); @@ -126,6 +127,8 @@ GameLib.D3.ComponentTriggerSphereSphere.prototype.onUpdate = function( } }; +//#endif + GameLib.D3.ComponentTriggerSphereSphere.prototype.onSetParentEntity = function( parentScene, parentEntity diff --git a/src/game-lib-component-vehicle-ai-object-avoidance.js b/src/game-lib-component-vehicle-ai-object-avoidance.js index 112965f..b768544 100644 --- a/src/game-lib-component-vehicle-ai-object-avoidance.js +++ b/src/game-lib-component-vehicle-ai-object-avoidance.js @@ -30,6 +30,8 @@ GameLib.D3.ComponentVehicleAIObjectAvoidance = function( console.log("constructor for : ComponentVehicleAIObjectAvoidance"); }; +//#ifdef RUNTIME__ + ///////////////////////////////////////////////////////////////////////// ///////////////////////// Methods to override /////////////////////////// ///////////////////////////////////////////////////////////////////////// @@ -563,4 +565,6 @@ GameLib.D3.ComponentVehicleAIObjectAvoidance.prototype.onUpdate = function( } } -}; \ No newline at end of file +}; + +//#endif \ No newline at end of file diff --git a/src/game-lib-component-vehicle-ai-path-steering.js b/src/game-lib-component-vehicle-ai-path-steering.js index 5e3e341..981c3a4 100644 --- a/src/game-lib-component-vehicle-ai-path-steering.js +++ b/src/game-lib-component-vehicle-ai-path-steering.js @@ -49,6 +49,7 @@ GameLib.D3.ComponentVehicleAIPathSteering.prototype.onSetParentEntity = function } }; +//#ifdef RUNTIME__ GameLib.D3.ComponentVehicleAIPathSteering.prototype.onUpdate = function( deltaTime, parentEntity @@ -239,4 +240,5 @@ GameLib.D3.ComponentVehicleAIPathSteering.prototype.onUpdate = function( this.raycastVehicleComponent.instance.applyEngineForce(-3500, 2); this.raycastVehicleComponent.instance.applyEngineForce(-3500, 3); -}; \ No newline at end of file +}; +//#endif \ No newline at end of file