2016-11-29 12:52:48 +01:00
|
|
|
var gulp = require('gulp');
|
|
|
|
var concat = require('gulp-concat');
|
|
|
|
var sort = require('gulp-sort');
|
|
|
|
var minify = require('gulp-minify');
|
2018-11-15 14:50:58 +01:00
|
|
|
var replace = require('gulp-string-replace');
|
2016-10-14 12:32:53 +02:00
|
|
|
|
2018-11-21 20:57:14 +01:00
|
|
|
gulp.task('build', build);
|
|
|
|
gulp.task('monitor', monitor);
|
|
|
|
|
2019-10-15 22:21:34 +02:00
|
|
|
//__API_COMPONENT__
|
2019-07-24 14:45:42 +02:00
|
|
|
var code = 'if (R3.Utils.UndefinedOrNull(apiComponent)) {\n';
|
|
|
|
code += '\t\tapiComponent = {};\n';
|
|
|
|
code += '\t}\n';
|
2019-07-24 08:08:02 +02:00
|
|
|
code += '\n';
|
2019-07-24 14:45:42 +02:00
|
|
|
code += '\tR3.API.Component.call(\n';
|
|
|
|
code += '\t\tthis,\n';
|
2019-10-15 22:21:34 +02:00
|
|
|
code += '\t\tapiComponent.parent,\n';
|
|
|
|
code += '\t\tapiComponent.id,\n';
|
|
|
|
code += '\t\tapiComponent.name,\n';
|
|
|
|
code += '\t\tapiComponent.register,\n';
|
2019-10-24 09:27:43 +02:00
|
|
|
code += '\t\tapiComponent.selected,\n';
|
|
|
|
code += '\t\tapiComponent.isPublic\n';
|
|
|
|
code += '\t)\n';
|
|
|
|
code += '\n';
|
|
|
|
code += '\tif (R3.Utils.UndefinedOrNull(apiComponent.guiInfo)) {\n';
|
|
|
|
code += '\t\tapiComponent.guiInfo = {};\n';
|
|
|
|
code += '\t}\n';
|
|
|
|
code += '\tthis.guiInfo = apiComponent.guiInfo;\n';
|
2019-07-24 14:45:42 +02:00
|
|
|
|
2019-10-15 22:21:34 +02:00
|
|
|
//__DEFINE_API_COMPONENT__
|
|
|
|
var code1 = 'if (R3.Utils.UndefinedOrNull(apiComponent)) {\n';
|
|
|
|
code1 += '\t\tapiComponent = {};\n';
|
|
|
|
code1 += '\t}\n';
|
2019-10-24 09:27:43 +02:00
|
|
|
code1 += '\n';
|
|
|
|
code1 += '\tif (R3.Utils.UndefinedOrNull(apiComponent.guiInfo)) {\n';
|
|
|
|
code1 += '\t\tapiComponent.guiInfo = {};\n';
|
|
|
|
code1 += '\t}\n';
|
|
|
|
code1 += '\tthis.guiInfo = apiComponent.guiInfo;\n';
|
2019-10-15 22:21:34 +02:00
|
|
|
|
2019-10-06 21:11:18 +02:00
|
|
|
var code2 = 'R3.D3.API.Geometry.Buffer.call(\n';
|
2019-07-24 14:45:42 +02:00
|
|
|
code2 += '\t\tthis,\n';
|
2019-10-06 21:11:18 +02:00
|
|
|
code2 += '\t\tapiComponent\n';
|
2019-07-25 22:22:32 +02:00
|
|
|
code2 += '\t)';
|
2019-07-24 14:45:42 +02:00
|
|
|
|
2019-10-06 21:11:18 +02:00
|
|
|
var code3 = 'R3.D3.API.Geometry.Normal.call(\n';
|
2019-07-24 14:45:42 +02:00
|
|
|
code3 += '\t\tthis,\n';
|
2019-10-06 21:11:18 +02:00
|
|
|
code3 += '\t\tapiComponent\n';
|
2019-07-25 22:22:32 +02:00
|
|
|
code3 += '\t)';
|
2019-07-24 14:45:42 +02:00
|
|
|
|
2019-10-06 21:11:18 +02:00
|
|
|
var code4 = 'R3.D3.API.Material.call(\n';
|
2019-07-24 14:45:42 +02:00
|
|
|
code4 += '\t\tthis,\n';
|
2019-10-06 21:11:18 +02:00
|
|
|
code4 += '\t\tapiComponent\n';
|
2019-07-25 22:22:32 +02:00
|
|
|
code4 += '\t)';
|
2019-07-24 14:45:42 +02:00
|
|
|
|
|
|
|
var code5 = 'if (R3.Utils.UndefinedOrNull(apiTexture)) {\n';
|
|
|
|
code5 += '\t\tapiTexture = {};\n';
|
|
|
|
code5 += '\t}\n';
|
|
|
|
code5 += '\n';
|
|
|
|
code5 += '\tR3.D3.API.Texture.call(\n';
|
|
|
|
code5 += '\t\tthis,\n';
|
2019-10-15 22:21:34 +02:00
|
|
|
code5 += '\t\tapiTexture,\n';
|
|
|
|
code5 += '\t\tapiTexture.parentMaterials,\n';
|
|
|
|
code5 += '\t\tapiTexture.mipmaps,\n';
|
|
|
|
code5 += '\t\tapiTexture.mapping,\n';
|
|
|
|
code5 += '\t\tapiTexture.wrapS,\n';
|
|
|
|
code5 += '\t\tapiTexture.wrapT,\n';
|
|
|
|
code5 += '\t\tapiTexture.magFilter,\n';
|
|
|
|
code5 += '\t\tapiTexture.minFilter,\n';
|
|
|
|
code5 += '\t\tapiTexture.anisotropy,\n';
|
|
|
|
code5 += '\t\tapiTexture.format,\n';
|
|
|
|
code5 += '\t\tapiTexture.storageType,\n';
|
|
|
|
code5 += '\t\tapiTexture.offset,\n';
|
|
|
|
code5 += '\t\tapiTexture.repeat,\n';
|
|
|
|
code5 += '\t\tapiTexture.rotation,\n';
|
|
|
|
code5 += '\t\tapiTexture.center,\n';
|
|
|
|
code5 += '\t\tapiTexture.matrixAutoUpdate,\n';
|
|
|
|
code5 += '\t\tapiTexture.generateMipMaps,\n';
|
|
|
|
code5 += '\t\tapiTexture.premultiplyAlpha,\n';
|
|
|
|
code5 += '\t\tapiTexture.flipY,\n';
|
|
|
|
code5 += '\t\tapiTexture.unpackAlignment,\n';
|
|
|
|
code5 += '\t\tapiTexture.encoding,\n';
|
|
|
|
code5 += '\t\tapiTexture.version,\n';
|
|
|
|
code5 += '\t\tapiTexture.animated,\n';
|
|
|
|
code5 += '\t\tapiTexture.reverseAnimation,\n';
|
|
|
|
code5 += '\t\tapiTexture.forward\n';
|
2019-07-25 22:22:32 +02:00
|
|
|
code5 += '\t)';
|
|
|
|
|
2019-10-15 22:21:34 +02:00
|
|
|
//__RUNTIME_COMPONENT__
|
2019-07-25 22:22:32 +02:00
|
|
|
var code6 = 'if (R3.Utils.UndefinedOrNull(apiComponent)) {\n';
|
|
|
|
code6 += '\t\tapiComponent = {};\n';
|
|
|
|
code6 += '\t}\n';
|
2019-10-15 22:21:34 +02:00
|
|
|
code6 += '\n';
|
|
|
|
code6 += '\tif (R3.Utils.UndefinedOrNull(this.linkedComponents)) {\n';
|
|
|
|
code6 += '\t\tthis.linkedComponents = {};\n';
|
|
|
|
code6 += '\t}\n';
|
|
|
|
code6 += '\n';
|
|
|
|
code6 += '\tthis.initialize(apiComponent)\n';
|
2019-07-25 22:22:32 +02:00
|
|
|
code6 += '\n';
|
|
|
|
code6 += '\tthis.graphics\t= null;\n';
|
|
|
|
code6 += '\tthis.physics\t= null;\n';
|
2019-10-06 21:11:18 +02:00
|
|
|
code6 += '\tthis.coder\t\t= null;\n';
|
2019-07-25 22:22:32 +02:00
|
|
|
code6 += '\tthis.gui\t\t= null;\n';
|
|
|
|
code6 += '\tthis.stats\t\t= null;\n';
|
|
|
|
code6 += '\n';
|
|
|
|
code6 += '\tR3.Event.Emit(\n';
|
|
|
|
code6 += '\t\tR3.Event.GET_RUNTIME,\n';
|
2019-10-15 22:21:34 +02:00
|
|
|
code6 += '\t\tthis,\n';
|
2019-07-25 22:22:32 +02:00
|
|
|
code6 += '\t\tfunction(runtime) {\n';
|
2019-10-15 22:21:34 +02:00
|
|
|
code6 += '\t\t\tif (R3.Utils.UndefinedOrNull(runtime)) {\n';
|
|
|
|
code6 += '\t\t\t\treturn;\n';
|
|
|
|
code6 += '\t\t\t}\n';
|
2019-07-25 22:22:32 +02:00
|
|
|
code6 += '\t\t\tthis.graphics\t= runtime.graphics;\n';
|
|
|
|
code6 += '\t\t\tthis.physics\t= runtime.physics;\n';
|
2019-10-06 21:11:18 +02:00
|
|
|
code6 += '\t\t\tthis.coder\t\t= runtime.coder;\n';
|
2019-07-25 22:22:32 +02:00
|
|
|
code6 += '\t\t\tthis.gui\t\t= runtime.gui;\n';
|
|
|
|
code6 += '\t\t\tthis.stats\t\t= runtime.stats;\n';
|
|
|
|
code6 += '\t\t}.bind(this)\n';
|
2019-10-15 22:21:34 +02:00
|
|
|
code6 += '\t)';
|
|
|
|
|
|
|
|
//__RUNTIME_COMPONENT_INHERITABLE__
|
|
|
|
var code14 = 'if (R3.Utils.UndefinedOrNull(apiComponent)) {\n';
|
|
|
|
code14 += '\t\t\tapiComponent = {};\n';
|
|
|
|
code14 += '\t\t}\n';
|
|
|
|
code14 += '\n';
|
|
|
|
code14 += '\t\tthis.initialize(apiComponent)\n';
|
|
|
|
code14 += '\n';
|
|
|
|
code14 += '\t\tthis.graphics\t= null;\n';
|
|
|
|
code14 += '\t\tthis.physics\t= null;\n';
|
|
|
|
code14 += '\t\tthis.coder\t\t= null;\n';
|
|
|
|
code14 += '\t\tthis.gui\t\t= null;\n';
|
|
|
|
code14 += '\t\tthis.stats\t\t= null;\n';
|
|
|
|
code14 += '\n';
|
|
|
|
code14 += '\t\tR3.Event.Emit(\n';
|
|
|
|
code14 += '\t\t\tR3.Event.GET_RUNTIME,\n';
|
|
|
|
code14 += '\t\t\tthis,\n';
|
|
|
|
code14 += '\t\t\tfunction(runtime) {\n';
|
|
|
|
code14 += '\t\t\t\tif (R3.Utils.UndefinedOrNull(runtime)) {\n';
|
|
|
|
code14 += '\t\t\t\t\treturn;\n';
|
|
|
|
code14 += '\t\t\t\t}\n';
|
|
|
|
code14 += '\t\t\t\tthis.graphics\t= runtime.graphics;\n';
|
|
|
|
code14 += '\t\t\t\tthis.physics\t= runtime.physics;\n';
|
|
|
|
code14 += '\t\t\t\tthis.coder\t\t= runtime.coder;\n';
|
|
|
|
code14 += '\t\t\t\tthis.gui\t\t= runtime.gui;\n';
|
|
|
|
code14 += '\t\t\t\tthis.stats\t\t= runtime.stats;\n';
|
|
|
|
code14 += '\t\t\t}.bind(this)\n';
|
|
|
|
code14 += '\t\t)';
|
|
|
|
|
|
|
|
//__DEREGISTER_COMPONENT__
|
2019-10-06 21:11:18 +02:00
|
|
|
var code7 = 'if (R3.Utils.UndefinedOrNull(apiComponent)) {\n';
|
|
|
|
code7 += '\t\tapiComponent = {};\n';
|
|
|
|
code7 += '\t}\n';
|
|
|
|
code7 += '\n';
|
|
|
|
code7 += '\tif (R3.Utils.UndefinedOrNull(apiComponent.register)) {\n';
|
|
|
|
code7 += '\t\tapiComponent.register = false;\n';
|
|
|
|
code7 += '\t}\n';
|
|
|
|
code7 += '\n';
|
|
|
|
code7 += '\tR3.Event.Emit(\n';
|
|
|
|
code7 += '\t\tR3.Event.GET_REGISTER_FACES,\n';
|
|
|
|
code7 += '\t\tnull,\n';
|
|
|
|
code7 += '\t\tfunction(register) {\n';
|
2019-10-15 22:21:34 +02:00
|
|
|
code7 += '\t\t\tif (R3.Utils.UndefinedOrNull(register)) {\n';
|
|
|
|
code7 += '\t\t\t\treturn;\n';
|
2019-10-06 21:11:18 +02:00
|
|
|
code7 += '\t\t\t}\n';
|
2019-10-15 22:21:34 +02:00
|
|
|
code7 += '\t\t\tapiComponent.register = register;\n';
|
2019-10-06 21:11:18 +02:00
|
|
|
code7 += '\t\t}\n';
|
|
|
|
code7 += '\t)';
|
|
|
|
|
2019-10-15 22:21:34 +02:00
|
|
|
//__UPGRADE_TO_RUNTIME__
|
2019-10-06 21:11:18 +02:00
|
|
|
var code8 = 'R3.Component.call(this)';
|
|
|
|
|
|
|
|
var code9 = 'R3.Component.prototype.createInstance.call(this)';
|
|
|
|
|
|
|
|
var code10 = 'R3.Component.prototype.updateInstance.call(this, property)';
|
|
|
|
|
|
|
|
var code11 = 'R3.D3.Geometry.Buffer.call(\n';
|
|
|
|
code11 += '\t\tthis,\n';
|
|
|
|
code11 += '\t\ttrue\n';
|
|
|
|
code11 += '\t);';
|
2019-07-24 08:08:02 +02:00
|
|
|
|
2019-10-15 22:21:34 +02:00
|
|
|
//__INHERIT_ONLY__
|
|
|
|
var code12 = 'if (R3.Utils.UndefinedOrNull(this.linkedComponents)) {\n';
|
|
|
|
code12 += '\t\tthis.linkedComponents = {};\n';
|
|
|
|
code12 += '\t}\n';
|
|
|
|
code12 += '\t\n';
|
|
|
|
code12 += '\tif (inherited !== true && inherited !== false) {\n';
|
|
|
|
code12 += '\t\tthrow new Error(R3.GetComponentName(this) + " should not be instantiated directly");\n';
|
|
|
|
code12 += '\t}';
|
|
|
|
|
|
|
|
//__INHERIT_AND_INSTANTIATE__
|
|
|
|
var code13 = 'if (R3.Utils.UndefinedOrNull(this.linkedComponents)) {\n';
|
|
|
|
code13 += '\t\tthis.linkedComponents = {};\n';
|
|
|
|
code13 += '\t}\n';
|
|
|
|
code13 += '\t\n';
|
|
|
|
code13 += '\tif (R3.Utils.UndefinedOrNull(inherited)) {\n\n';
|
|
|
|
code13 += '\t\t' + code14+ '\n';
|
|
|
|
code13 += '\t}';
|
|
|
|
|
2018-11-21 20:57:14 +01:00
|
|
|
function build() {
|
|
|
|
return gulp.src('./src/r3-*.js')
|
|
|
|
.pipe(sort())
|
|
|
|
.pipe(concat('r3.js'))
|
|
|
|
.pipe(replace('__DATE__', new Date().toString()))
|
2019-10-06 21:11:18 +02:00
|
|
|
.pipe(replace('__API_COMPONENT__', code))
|
2019-10-15 22:21:34 +02:00
|
|
|
.pipe(replace('__DEFINE_API_COMPONENT__', code1))
|
2019-10-06 21:11:18 +02:00
|
|
|
.pipe(replace('__API_GEOMETRY_BUFFER__', code2))
|
|
|
|
.pipe(replace('__API_GEOMETRY_NORMAL__', code3))
|
|
|
|
.pipe(replace('__API_MATERIAL__', code4))
|
|
|
|
.pipe(replace('__API_TEXTURE__', code5))
|
|
|
|
.pipe(replace('__RUNTIME_COMPONENT__', code6))
|
|
|
|
.pipe(replace('__DEREGISTER_COMPONENT__', code7))
|
|
|
|
.pipe(replace('__UPGRADE_TO_RUNTIME__', code8))
|
|
|
|
.pipe(replace('__CREATE_INSTANCE__', code9))
|
|
|
|
.pipe(replace('__UPDATE_INSTANCE__', code10))
|
|
|
|
.pipe(replace('__RUNTIME_BUFFER_COMPONENT__', code11))
|
2019-10-15 22:21:34 +02:00
|
|
|
.pipe(replace('__INHERIT_ONLY__', code12))
|
|
|
|
.pipe(replace('__INHERIT_AND_INSTANTIATE__', code13))
|
|
|
|
// .pipe(minify({
|
|
|
|
// ext:{
|
|
|
|
// src:'.js',
|
|
|
|
// min:'-min.js'
|
|
|
|
// }
|
|
|
|
// }))
|
2018-11-21 20:57:14 +01:00
|
|
|
.pipe(gulp.dest('./build/'));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function monitor() {
|
|
|
|
gulp.watch('src/*.js', build);
|
|
|
|
}
|
2016-10-14 12:32:53 +02:00
|
|
|
|
|
|
|
gulp.task(
|
|
|
|
'default',
|
2018-11-21 20:57:14 +01:00
|
|
|
gulp.series(
|
|
|
|
build,
|
|
|
|
monitor
|
|
|
|
)
|
2019-07-24 08:08:02 +02:00
|
|
|
);
|