stable load

beta.r3js.org
cybafelo 2019-10-15 22:21:34 +02:00
parent 41645d1ca6
commit bfed32cd48
159 changed files with 8702 additions and 4386 deletions

View File

@ -10,7 +10,8 @@ R3.Controls.D3.Editor = function(
__RUNTIME_COMPONENT__;
R3.Controls.D3.call(
this
this,
true
);
};
@ -27,7 +28,7 @@ R3.Controls.D3.Editor.prototype.constructor = R3.Controls.D3.Editor;
*/
R3.Controls.D3.Editor.prototype.createInstance = function() {
this.instance = this.graphics.EditorControls(this.canvas, this.camera);
this.instance = this.graphics.EditorControls(this);
__CREATE_INSTANCE__;
};

View File

@ -19,13 +19,13 @@ R3.D3.Composer.RenderTarget = function(
this.renderTarget = R3.Component.ConstructFromObject(this.renderTarget);
}
var linkedObjects = {
var linkedComponents = {
renderTarget : R3.D3.RenderTarget
};
R3.D3.Composer.call(
this,
linkedObjects
linkedComponents
);
};

View File

@ -19,13 +19,13 @@ R3.D3.Composer.Renderer = function(
this.renderer = R3.Component.ConstructFromObject(this.renderer);
}
var linkedObjects = {
var linkedComponents = {
renderer : R3.Renderer.D3
};
R3.D3.Composer.call(
this,
linkedObjects
linkedComponents
);
};

View File

@ -7,20 +7,25 @@ var replace = require('gulp-string-replace');
gulp.task('build', build);
gulp.task('monitor', monitor);
//__API_COMPONENT__
var code = 'if (R3.Utils.UndefinedOrNull(apiComponent)) {\n';
code += '\t\tapiComponent = {};\n';
code += '\t}\n';
code += '\tthis.apiComponent = apiComponent;\n';
code += '\n';
code += '\tR3.API.Component.call(\n';
code += '\t\tthis,\n';
code += '\t\tthis.apiComponent.parent,\n';
code += '\t\tthis.apiComponent.id,\n';
code += '\t\tthis.apiComponent.name,\n';
code += '\t\tthis.apiComponent.register,\n';
code += '\t\tthis.apiComponent.selected\n';
code += '\t\tapiComponent.parent,\n';
code += '\t\tapiComponent.id,\n';
code += '\t\tapiComponent.name,\n';
code += '\t\tapiComponent.register,\n';
code += '\t\tapiComponent.selected\n';
code += '\t)';
//__DEFINE_API_COMPONENT__
var code1 = 'if (R3.Utils.UndefinedOrNull(apiComponent)) {\n';
code1 += '\t\tapiComponent = {};\n';
code1 += '\t}\n';
var code2 = 'R3.D3.API.Geometry.Buffer.call(\n';
code2 += '\t\tthis,\n';
code2 += '\t\tapiComponent\n';
@ -39,41 +44,46 @@ code4 += '\t)';
var code5 = 'if (R3.Utils.UndefinedOrNull(apiTexture)) {\n';
code5 += '\t\tapiTexture = {};\n';
code5 += '\t}\n';
code5 += '\tthis.apiTexture = apiTexture;\n';
code5 += '\n';
code5 += '\tR3.D3.API.Texture.call(\n';
code5 += '\t\tthis,\n';
code5 += '\t\tthis.apiTexture,\n';
code5 += '\t\tthis.apiTexture.parentMaterials,\n';
code5 += '\t\tthis.apiTexture.mipmaps,\n';
code5 += '\t\tthis.apiTexture.mapping,\n';
code5 += '\t\tthis.apiTexture.wrapS,\n';
code5 += '\t\tthis.apiTexture.wrapT,\n';
code5 += '\t\tthis.apiTexture.magFilter,\n';
code5 += '\t\tthis.apiTexture.minFilter,\n';
code5 += '\t\tthis.apiTexture.anisotropy,\n';
code5 += '\t\tthis.apiTexture.format,\n';
code5 += '\t\tthis.apiTexture.storageType,\n';
code5 += '\t\tthis.apiTexture.offset,\n';
code5 += '\t\tthis.apiTexture.repeat,\n';
code5 += '\t\tthis.apiTexture.rotation,\n';
code5 += '\t\tthis.apiTexture.center,\n';
code5 += '\t\tthis.apiTexture.matrixAutoUpdate,\n';
code5 += '\t\tthis.apiTexture.generateMipMaps,\n';
code5 += '\t\tthis.apiTexture.premultiplyAlpha,\n';
code5 += '\t\tthis.apiTexture.flipY,\n';
code5 += '\t\tthis.apiTexture.unpackAlignment,\n';
code5 += '\t\tthis.apiTexture.encoding,\n';
code5 += '\t\tthis.apiTexture.version,\n';
code5 += '\t\tthis.apiTexture.animated,\n';
code5 += '\t\tthis.apiTexture.reverseAnimation,\n';
code5 += '\t\tthis.apiTexture.forward\n';
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';
code5 += '\t)';
//__RUNTIME_COMPONENT__
var code6 = 'if (R3.Utils.UndefinedOrNull(apiComponent)) {\n';
code6 += '\t\tapiComponent = {};\n';
code6 += '\t}\n';
code6 += '\tthis.apiComponent = apiComponent;\n';
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';
code6 += '\n';
code6 += '\tthis.graphics\t= null;\n';
code6 += '\tthis.physics\t= null;\n';
@ -83,17 +93,48 @@ code6 += '\tthis.stats\t\t= null;\n';
code6 += '\n';
code6 += '\tR3.Event.Emit(\n';
code6 += '\t\tR3.Event.GET_RUNTIME,\n';
code6 += '\t\tthis,\n';
code6 += '\t\tfunction(runtime) {\n';
code6 += '\t\t\tif (R3.Utils.UndefinedOrNull(runtime)) {\n';
code6 += '\t\t\t\treturn;\n';
code6 += '\t\t\t}\n';
code6 += '\t\t\tthis.graphics\t= runtime.graphics;\n';
code6 += '\t\t\tthis.physics\t= runtime.physics;\n';
code6 += '\t\t\tthis.coder\t\t= runtime.coder;\n';
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';
code6 += '\t);\n';
code6 += '\n';
code6 += '\tthis.initialize(apiComponent)';
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__
var code7 = 'if (R3.Utils.UndefinedOrNull(apiComponent)) {\n';
code7 += '\t\tapiComponent = {};\n';
code7 += '\t}\n';
@ -106,12 +147,14 @@ code7 += '\tR3.Event.Emit(\n';
code7 += '\t\tR3.Event.GET_REGISTER_FACES,\n';
code7 += '\t\tnull,\n';
code7 += '\t\tfunction(register) {\n';
code7 += '\t\t\tif (register) {\n';
code7 += '\t\t\t\tapiComponent.register = true;\n';
code7 += '\t\t\tif (R3.Utils.UndefinedOrNull(register)) {\n';
code7 += '\t\t\t\treturn;\n';
code7 += '\t\t\t}\n';
code7 += '\t\t\tapiComponent.register = register;\n';
code7 += '\t\t}\n';
code7 += '\t)';
//__UPGRADE_TO_RUNTIME__
var code8 = 'R3.Component.call(this)';
var code9 = 'R3.Component.prototype.createInstance.call(this)';
@ -123,12 +166,31 @@ code11 += '\t\tthis,\n';
code11 += '\t\ttrue\n';
code11 += '\t);';
//__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}';
function build() {
return gulp.src('./src/r3-*.js')
.pipe(sort())
.pipe(concat('r3.js'))
.pipe(replace('__DATE__', new Date().toString()))
.pipe(replace('__API_COMPONENT__', code))
.pipe(replace('__DEFINE_API_COMPONENT__', code1))
.pipe(replace('__API_GEOMETRY_BUFFER__', code2))
.pipe(replace('__API_GEOMETRY_NORMAL__', code3))
.pipe(replace('__API_MATERIAL__', code4))
@ -139,12 +201,14 @@ function build() {
.pipe(replace('__CREATE_INSTANCE__', code9))
.pipe(replace('__UPDATE_INSTANCE__', code10))
.pipe(replace('__RUNTIME_BUFFER_COMPONENT__', code11))
.pipe(minify({
ext:{
src:'.js',
min:'-min.js'
}
}))
.pipe(replace('__INHERIT_ONLY__', code12))
.pipe(replace('__INHERIT_AND_INSTANTIATE__', code13))
// .pipe(minify({
// ext:{
// src:'.js',
// min:'-min.js'
// }
// }))
.pipe(gulp.dest('./build/'));
}

View File

@ -3,10 +3,10 @@
$files = scandir('.', SCANDIR_SORT_DESCENDING);
$statement = "/**\
* R3.GetComponentType\
* @returns {number}\
* @constructor\
$statement = "/**
* R3.GetComponentType
* @param component
* @returns {number}
*/\n";
$statement .= "R3.GetComponentType = function(component) {\n\n";
@ -24,6 +24,7 @@ foreach ($files as $file) {
if (
!preg_match('/r3\-system/', $file) &&
!preg_match('/entityManager/', $file) &&
!preg_match('/r3\-runtime/', $file) &&
!preg_match('/r3\-z\./', $file) &&
!preg_match('/^r3\-a\-.*/', $file) &&
@ -36,6 +37,7 @@ foreach ($files as $file) {
$file = str_replace('api.y.', '', $file);
$file = str_replace('api.z.', '', $file);
$file = str_replace('api', 'API', $file);
$file = str_replace('vpn', 'VPN', $file);
$file = str_replace('gui', 'GUI', $file);
$file = str_replace('ssao', 'SSAO', $file);
$file = str_replace('fxaa', 'FXAA', $file);
@ -96,6 +98,37 @@ $componentDefines .= 'R3.MAX_COMPONENTS = 0x' . dechex($i) . ";\n\n";
$getComponentInfo = "R3.GetComponentInfo = function(componentType) {\n\n\tswitch (componentType) {\n\n";
$getApiConstructor = "/**
* R3.GetAPIConstructor
* @param runtimeComponent
* @returns constructor
*/\n";
$getApiConstructor .= "R3.GetAPIConstructor = function(runtimeComponent) {\n\n";
$getName = "/**
* R3.GetComponentName
* @param runtimeComponent
* @returns string
*/\n";
$getName .= "R3.GetComponentName = function(runtimeComponent) {\n\n";
$getConstructor = "/**
* R3.GetConstructor
* @param apiComponent
* @returns constructor
*/\n";
$getConstructor .= "R3.GetConstructor = function(apiComponent) {\n\n";
$getConstructorFromComponentType = "/**
* R3.GetConstructorFromComponentType
* @param componentType
* @returns constructor
*/\n";
$getConstructorFromComponentType .= "R3.GetConstructorFromComponentType = function(componentType) {\n\n";
$getConstructorFromComponentType .= "\tswitch (componentType) {\n\n";
foreach ($componentTypes as $componentType) {
@ -106,9 +139,14 @@ foreach ($componentTypes as $componentType) {
$name = $components[$componentType];
$getApiConstructor .= "\tif (runtimeComponent instanceof " . $name . "){\n\t\treturn " . $apiComponents[$componentType] . ";\n\t}\n";
$getName .= "\tif (runtimeComponent instanceof " . $name . "){\n\t\treturn '" . $name . "';\n\t}\n";
$getConstructor .= "\tif (apiComponent instanceof " . $apiComponents[$componentType] . "){\n\t\treturn " . $name . ";\n\t}\n";
$getConstructorFromComponentType .= "\t\tcase " . $componentType . ": return " . $name . ";\n";
$runtime = 'R3.Runtime.DEFAULT';
if (preg_match('/Render|Color|Controls|Curve|Image|Video|Camera|Composer|Effect|Graphics|Fog|Geometry|Light|Material|Mesh|Particle|Pass|Raycaster|Scene|Shader|Shadow|Skeleton|Text|Viewport|Object|Bone/', $name)) {
if (preg_match('/Bone|Camera|Canvas|Clock|Color|Composer|Controls|Curve|Effect|Fog|Geometry|Graphics|Image|Light|Material|Mesh|Mouse|Object|Particle|Pass|Raycaster|Render|Scene|Shader|Shadow|Skeleton|Text|Video|Viewport/', $name)) {
$runtime = 'R3.Runtime.GRAPHICS';
}
@ -124,7 +162,7 @@ foreach ($componentTypes as $componentType) {
$runtime = 'R3.Runtime.SOCKETS';
}
if (preg_match('/Friction|Physics|Vehicle|Wheel|Rigid|Shape|Solver|Broadphase/', $name)) {
if (preg_match('/Broadphase|Friction|Physics|Rigid|Shape|Solver|Vehicle|Wheel/', $name)) {
$runtime = 'R3.Runtime.PHYSICS';
}
@ -138,15 +176,32 @@ foreach ($componentTypes as $componentType) {
$getComponentInfo .= "\t\tdefault : \n";
$getComponentInfo .= "\t\t\tthrow new Error('Invalid component type: ' + componentType);\n\n";
$getComponentInfo .= "\t}\n";
$getComponentInfo .= "};\n\n";
$getApiConstructor .= "\tthrow new Error('Invalid Runtime Constructor : ' + runtimeConstructor);\n\n";
$getApiConstructor .= "};\n\n";
$getConstructor .= "\tthrow new Error('Invalid API Constructor : ' + apiConstructor);\n\n";
$getConstructor .= "};\n\n";
$getConstructorFromComponentType .= "\t\tdefault : \n";
$getConstructorFromComponentType .= "\t\t\tthrow new Error('Invalid componentType : ' + componentType);\n\n";
$getConstructorFromComponentType .= "\t}\n";
$getConstructorFromComponentType .= "};\n\n";
$getName .= "\tthrow new Error('Invalid Runtime Constructor : ' + runtimeConstructor);\n\n";
$getName .= "};\n";
$getComponentInfo .= "};\n";
echo $componentDefines;
echo $statement;
echo $getComponentInfo;
echo $getApiConstructor;
echo $getConstructor;
echo $getConstructorFromComponentType;
echo $getName;
file_put_contents('r3-a-1-component-info.js', $componentDefines . $statement . $getComponentInfo);
file_put_contents('r3-a-1-component-info.js', $componentDefines . $statement . $getComponentInfo . $getApiConstructor . $getConstructor . $getConstructorFromComponentType . $getName);
?>

81
src/build_events.php Executable file
View File

@ -0,0 +1,81 @@
#!/usr/bin/php
<?php
$files = scandir('.', SCANDIR_SORT_DESCENDING);
$events = [];
foreach ($files as $file) {
if (
preg_match('/\.js$/', $file) &&
!preg_match('/r3\-a\-2\-event/', $file)
) {
echo "processing file " . $file . "\n";
$fn = fopen($file, "r");
while (!feof($fn)) {
$line = fgets($fn);
if (
preg_match('/R3.Event\./', $line) &&
!preg_match('/Emit|Subscribe|.call|GetEventName|Async|prototype/', $line)
) {
$matches = [];
preg_match_all('/(R3.Event\..*?)(\s+|,|;|$)/', $line, $matches);
if ($matches[1] && $matches[1][0]) {
$event = $matches[1][0];
if (in_array($event, $events)) {
// Do nothing
} else {
array_push($events, $event);
}
}
}
}
fclose($fn);
}
}
sort($events);
$i = 1;
$eventList = '';
$eventFunction = "/**\n * R3.Event.GetEventName\n * @param eventId\n * @returns {string}\n * @constructor\n */\nR3.Event.GetEventName = function(eventId) {\n\n\tswitch(eventId) {\n";
foreach ($events as $event) {
$eventList .= $event . " = " . "0x" . dechex($i) . ";\n";
$eventFunction .= "\t\tcase 0x" . dechex($i). " : return '" . strtolower(str_replace('R3.Event.', '', $event)) . "';\n";
$i++;
}
$eventList .= "R3.Event.MAX_EVENTS = " . "0x" . dechex($i) . ";\n\n";
$eventFunction .= "\t\tdefault :\n\t\t\tthrow new Error('Event type not defined : ' + eventId);\n";
$eventFunction .= "\t}\n\n";
$eventFunction .= "};\n";
echo $eventList;
echo $eventFunction;
file_put_contents('r3-a-2-event-1.js', $eventList . $eventFunction);
?>

File diff suppressed because it is too large Load Diff

282
src/r3-a-2-event-0.js Normal file
View File

@ -0,0 +1,282 @@
/**
* Event Core
* @constructor
*/
R3.Event = function() {
};
/**
* Some nice Events handling
* @type {{}}
*/
R3.Event.Subscriptions = {};
R3.Event.OnceSubscriptions = {};
/**
* Subscribe to some events
* @param eventName
* @param callback
*/
R3.Event.prototype.subscribe = function(
eventName,
callback
) {
return R3.Event.Subscribe(eventName, callback.bind(this));
};
// /**
// * Stop listening for this event after the callback returns true
// * @param eventName
// * @param callback
// * @returns {{fn, remove: remove}}
// */
// R3.Event.prototype.subscribeOnce = function(
// eventName,
// callback
// ) {
// throw new Error('implement first properly');
// // var fn = callback.bind(this);
// //
// // if (R3.Event.OnceSubscriptions.hasOwnProperty(eventName)) {
// // R3.Event.OnceSubscriptions[eventName].push(fn);
// // } else {
// // R3.Event.OnceSubscriptions[eventName] = [];
// // R3.Event.OnceSubscriptions[eventName].push(fn);
// // }
// //
// // /**
// // * Return a handle to the caller to allow us to unsubscribe to this event
// // */
// // return {
// // fn : fn,
// // remove : function() {
// // R3.Event.Subscriptions[eventName].splice(
// // R3.Event.Subscriptions[eventName].indexOf(fn),
// // 1
// // );
// // }
// // }
// };
/**
*
* @param eventName
* @param data
*/
/**
* Publish some event happened with some data
* @param eventName
* @param data
* @param clientCallback
* @param clientErrorCallback
* @returns {number} of callbacks executed
*/
R3.Event.prototype.emit = function(
eventName,
data,
clientCallback,
clientErrorCallback
) {
return R3.Event.Emit(
eventName,
data,
clientCallback,
clientErrorCallback
);
};
/**
* Static method call
* @param eventName
* @param data
* @param clientCallback is executed ideally when the event completed
* @param clientErrorCallback
* @returns {number} of callbacks executed
* @constructor
*/
R3.Event.Emit = function(
eventName,
data,
clientCallback,
clientErrorCallback
) {
var count = 0;
if (R3.Event.Subscriptions.hasOwnProperty(eventName)) {
if (R3.Event.Subscriptions[eventName].length === 0) {
if (clientCallback) {
/**
* We execute the client callback immediately since there are no subscriptions to this event
*/
clientCallback();
}
if (clientErrorCallback) {
clientErrorCallback({
message : 'No subscriptions for event ' + eventName
})
}
}
/**
* We need to execute all the callbacks, but not execute them twice, but also keep in mind they can remove
* themselves during execution
*/
// var length = R3.Event.Subscriptions[eventName].length;
//
// for (var i = 0; i < length; i++) {
//
// var object = R3.Event.Subscriptions[eventName][i];
//
// if (object.fn && object.executed === false) {
// object.fn(data, clientCallback, clientErrorCallback);
// object.executed = true;
// }
//
// if (length !== R3.Event.Subscriptions[eventName].length) {
// /**
// * this callback removed a subscription - reset i and reset the length
// */
// i = 0;
// length = R3.Event.Subscriptions[eventName].length;
// }
// }
//
// R3.Event.Subscriptions[eventName].map(
// function(object){
// object.executed = false;
// }
// )
R3.Event.Subscriptions[eventName].map(
function(subscription) {
if (subscription) {
try {
var result = subscription(data, clientCallback, clientErrorCallback);
} catch (error) {
if (clientErrorCallback) {
try {
clientErrorCallback(error);
} catch (error2) {
console.error('failed to execute client callback error:', error2);
}
}
}
if (clientCallback) {
clientCallback(result);
}
count++;
}
}
)
} else {
if (clientCallback) {
/**
* We execute the client callback immediately since there are no subscriptions to this event
*/
clientCallback();
}
if (clientErrorCallback) {
clientErrorCallback({
message : 'No subscriptions for event ' + eventName
})
}
}
return count;
};
/**
* Execute the functions which subscribe to this event, but don't process the client callback - the subscription function
* should execute the client callback
* @param eventName
* @param data
* @param clientCallback
* @param clientErrorCallback
* @returns {number}
* @constructor
*/
R3.Event.Async = function(
eventName,
data,
clientCallback,
clientErrorCallback
) {
var count = 0;
if (R3.Event.Subscriptions.hasOwnProperty(eventName)) {
R3.Event.Subscriptions[eventName].map(
function(subscription) {
if (subscription) {
subscription(data, clientCallback, clientErrorCallback);
count++;
}
}
)
}
return count;
};
R3.Event.Subscribe = function(
eventName,
fn
) {
if (R3.Event.Subscriptions.hasOwnProperty(eventName)) {
R3.Event.Subscriptions[eventName].push(fn);
// {
// fn : fn,
// executed : false
// }
// );
} else {
R3.Event.Subscriptions[eventName] = [];
R3.Event.Subscriptions[eventName].push(fn);
// {
// fn : fn,
// executed : false
// }
// );
}
/**
* Return a handle to the caller to allow us to unsubscribe to this event
*/
return {
fn : fn,
remove : function() {
var index = R3.Event.Subscriptions[eventName].indexOf(fn);
// reduce(
// function(result, object, index) {
// if (object.fn === fn) {
// result = index;
// }
// return result;
// },
// -1
// );
if (index === -1) {
throw new Error('could not remove subscription');
}
R3.Event.Subscriptions[eventName].splice(
index,
1
);
}
}
};

232
src/r3-a-2-event-1.js Normal file
View File

@ -0,0 +1,232 @@
R3.Event.AFTER_RENDER = 0x1;
R3.Event.AFTER_WINDOW_RESIZE = 0x2;
R3.Event.ANIMATE_TEXTURE_INSTANCE = 0x3;
R3.Event.ANIMATION_COMPILE_FAILED = 0x4;
R3.Event.ANIMATION_COMPILE_SUCCESS = 0x5;
R3.Event.ANIMATION_MESH_ADDED = 0x6;
R3.Event.ANIMATION_MESH_REMOVED = 0x7;
R3.Event.ARRAY_ITEM_ADDED = 0x8;
R3.Event.AUDIO_ENDED = 0x9;
R3.Event.BEFORE_RENDER = 0xa;
R3.Event.BEFORE_WINDOW_RESIZE = 0xb;
R3.Event.BLENDER_DATA_RECEIVED = 0xc;
R3.Event.BUILD_GUI = 0xd;
R3.Event.CANVAS_CHANGE = 0xe;
R3.Event.CAST_SOURCE_CHANGED = 0xf;
R3.Event.COMPILE_FAILED = 0x10;
R3.Event.COMPILE_SUCCESS = 0x11;
R3.Event.COMPONENTS_LINKED = 0x12;
R3.Event.COMPONENT_CLONED = 0x13;
R3.Event.COMPONENT_CREATED = 0x14;
R3.Event.COMPONENT_DELETED = 0x15;
R3.Event.COMPONENT_DOWNLOAD_COMPLETE = 0x16;
R3.Event.COMPONENT_LINKED = 0x17;
R3.Event.COMPONENT_REGISTER = 0x18;
R3.Event.COMPONENT_REPLACED = 0x19;
R3.Event.COMPONENT_SAVED = 0x1a;
R3.Event.COMPONENT_TYPES_UPDATE = 0x1b;
R3.Event.COMPONENT_UPDATE = 0x1c;
R3.Event.CONTINUE_ALL_AUDIO = 0x1d;
R3.Event.CONTROLS_CANVAS_CHANGE = 0x1e;
R3.Event.DELETE_COMPONENT = 0x1f;
R3.Event.DELETE_COMPONENT_ERROR = 0x20;
R3.Event.DONE_SAVING = 0x21;
R3.Event.ENGINE_FIRED_PARTICLES_ZERO = 0x22;
R3.Event.ENTITY_LOADED = 0x23;
R3.Event.EVENT_ID_UPDATE = 0x24;
R3.Event.EXCLUDE_FROM_ENVIRONMENT = 0x25;
R3.Event.FETCH_COMPONENTS = 0x26;
R3.Event.FETCH_COMPONENT_TYPES = 0x27;
R3.Event.GET_API_URL = 0x28;
R3.Event.GET_APPLICATION_MODE = 0x29;
R3.Event.GET_GRAPHICS_RUNTIME = 0x2a;
R3.Event.GET_PHYSICS_RUNTIME = 0x2b;
R3.Event.GET_PROJECT = 0x2c;
R3.Event.GET_REMOTE_API_URL = 0x2d;
R3.Event.GET_RENDER_CONFIGURATION = 0x2e;
R3.Event.GET_RUNTIME = 0x2f;
R3.Event.GET_USER = 0x30;
R3.Event.GET_WEBSOCKET_CONFIG = 0x31;
R3.Event.GET_WINDOW_SIZE = 0x32;
R3.Event.IMAGE_UPLOAD_COMPLETE = 0x33;
R3.Event.INSTANCE_CLONED = 0x34;
R3.Event.INSTANCE_CREATED = 0x35;
R3.Event.INSTANCE_DISPOSAL = 0x36;
R3.Event.KEY_DOWN = 0x37;
R3.Event.KEY_UP = 0x38;
R3.Event.LOAD_COMPONENT = 0x39;
R3.Event.LOAD_COMPONENT_ERROR = 0x3a;
R3.Event.LOAD_FONT = 0x3b;
R3.Event.LOAD_IMAGE = 0x3c;
R3.Event.LOAD_PROGRESS = 0x3d;
R3.Event.MATERIAL_TEXTURES_UPDATED = 0x3e;
R3.Event.MATERIAL_TYPE_CHANGED = 0x3f;
R3.Event.MAXIMUM_PROJECTS = 0x40;
R3.Event.MESH_DESELECTED = 0x41;
R3.Event.MESH_FACE_DESELECTED = 0x42;
R3.Event.MESH_FACE_SELECTED = 0x43;
R3.Event.MESH_SELECTED = 0x44;
R3.Event.MOUSE_DOWN = 0x45;
R3.Event.MOUSE_MOVE = 0x46;
R3.Event.MOUSE_UP = 0x47;
R3.Event.MOUSE_WHEEL = 0x48;
R3.Event.MUTE_AUDIO = 0x49;
R3.Event.NAME_UPDATE = 0x4a;
R3.Event.PARENT_SCENE_CHANGE = 0x4b;
R3.Event.PARENT_WORLD_CHANGE = 0x4c;
R3.Event.PAUSE_ALL_AUDIO = 0x4d;
R3.Event.PLAY_AUDIO = 0x4e;
R3.Event.PROJECT_LOADED = 0x4f;
R3.Event.QUERY_PARSED = 0x50;
R3.Event.RECEIVE_DESTINATION_CHANGED = 0x51;
R3.Event.REGISTER_DEPENDENCIES = 0x52;
R3.Event.REGISTER_UPDATE = 0x53;
R3.Event.REMOVE_COMPONENT = 0x54;
R3.Event.REMOVE_MESH = 0x55;
R3.Event.REMOVE_PARTICLE_ENGINE = 0x56;
R3.Event.RENDERER_SIZE_CHANGE = 0x57;
R3.Event.REPLACE_COMPONENT = 0x58;
R3.Event.RESOLVE_DEPENDENCIES = 0x59;
R3.Event.SAVE_COMPONENT = 0x5a;
R3.Event.SAVE_COMPONENT_ERROR = 0x5b;
R3.Event.SAVING = 0x5c;
R3.Event.SELECTION_MODE_CHANGE = 0x5d;
R3.Event.SET_APPLICATION_MODE = 0x5e;
R3.Event.SIGN_IN = 0x5f;
R3.Event.SIGN_OUT = 0x60;
R3.Event.STOP_ALL_AUDIO = 0x61;
R3.Event.STOP_AUDIO = 0x62;
R3.Event.STOP_VISUALIZE = 0x63;
R3.Event.TEXTURE_ANIMATED_CHANGE = 0x64;
R3.Event.TEXTURE_INSTANCE_UPDATED = 0x65;
R3.Event.TOUCH_CANCEL = 0x66;
R3.Event.TOUCH_END = 0x67;
R3.Event.TOUCH_MOVE = 0x68;
R3.Event.TOUCH_START = 0x69;
R3.Event.UNRESOLVED_DEPENDENCIES_UPDATE = 0x6a;
R3.Event.VISUALIZE = 0x6b;
R3.Event.WINDOW_RESIZE = 0x6c;
R3.Event.MAX_EVENTS = 0x6d;
/**
* R3.Event.GetEventName
* @param eventId
* @returns {string}
* @constructor
*/
R3.Event.GetEventName = function(eventId) {
switch(eventId) {
case 0x1 : return 'after_render';
case 0x2 : return 'after_window_resize';
case 0x3 : return 'animate_texture_instance';
case 0x4 : return 'animation_compile_failed';
case 0x5 : return 'animation_compile_success';
case 0x6 : return 'animation_mesh_added';
case 0x7 : return 'animation_mesh_removed';
case 0x8 : return 'array_item_added';
case 0x9 : return 'audio_ended';
case 0xa : return 'before_render';
case 0xb : return 'before_window_resize';
case 0xc : return 'blender_data_received';
case 0xd : return 'build_gui';
case 0xe : return 'canvas_change';
case 0xf : return 'cast_source_changed';
case 0x10 : return 'compile_failed';
case 0x11 : return 'compile_success';
case 0x12 : return 'components_linked';
case 0x13 : return 'component_cloned';
case 0x14 : return 'component_created';
case 0x15 : return 'component_deleted';
case 0x16 : return 'component_download_complete';
case 0x17 : return 'component_linked';
case 0x18 : return 'component_register';
case 0x19 : return 'component_replaced';
case 0x1a : return 'component_saved';
case 0x1b : return 'component_types_update';
case 0x1c : return 'component_update';
case 0x1d : return 'continue_all_audio';
case 0x1e : return 'controls_canvas_change';
case 0x1f : return 'delete_component';
case 0x20 : return 'delete_component_error';
case 0x21 : return 'done_saving';
case 0x22 : return 'engine_fired_particles_zero';
case 0x23 : return 'entity_loaded';
case 0x24 : return 'event_id_update';
case 0x25 : return 'exclude_from_environment';
case 0x26 : return 'fetch_components';
case 0x27 : return 'fetch_component_types';
case 0x28 : return 'get_api_url';
case 0x29 : return 'get_application_mode';
case 0x2a : return 'get_graphics_runtime';
case 0x2b : return 'get_physics_runtime';
case 0x2c : return 'get_project';
case 0x2d : return 'get_remote_api_url';
case 0x2e : return 'get_render_configuration';
case 0x2f : return 'get_runtime';
case 0x30 : return 'get_user';
case 0x31 : return 'get_websocket_config';
case 0x32 : return 'get_window_size';
case 0x33 : return 'image_upload_complete';
case 0x34 : return 'instance_cloned';
case 0x35 : return 'instance_created';
case 0x36 : return 'instance_disposal';
case 0x37 : return 'key_down';
case 0x38 : return 'key_up';
case 0x39 : return 'load_component';
case 0x3a : return 'load_component_error';
case 0x3b : return 'load_font';
case 0x3c : return 'load_image';
case 0x3d : return 'load_progress';
case 0x3e : return 'material_textures_updated';
case 0x3f : return 'material_type_changed';
case 0x40 : return 'maximum_projects';
case 0x41 : return 'mesh_deselected';
case 0x42 : return 'mesh_face_deselected';
case 0x43 : return 'mesh_face_selected';
case 0x44 : return 'mesh_selected';
case 0x45 : return 'mouse_down';
case 0x46 : return 'mouse_move';
case 0x47 : return 'mouse_up';
case 0x48 : return 'mouse_wheel';
case 0x49 : return 'mute_audio';
case 0x4a : return 'name_update';
case 0x4b : return 'parent_scene_change';
case 0x4c : return 'parent_world_change';
case 0x4d : return 'pause_all_audio';
case 0x4e : return 'play_audio';
case 0x4f : return 'project_loaded';
case 0x50 : return 'query_parsed';
case 0x51 : return 'receive_destination_changed';
case 0x52 : return 'register_dependencies';
case 0x53 : return 'register_update';
case 0x54 : return 'remove_component';
case 0x55 : return 'remove_mesh';
case 0x56 : return 'remove_particle_engine';
case 0x57 : return 'renderer_size_change';
case 0x58 : return 'replace_component';
case 0x59 : return 'resolve_dependencies';
case 0x5a : return 'save_component';
case 0x5b : return 'save_component_error';
case 0x5c : return 'saving';
case 0x5d : return 'selection_mode_change';
case 0x5e : return 'set_application_mode';
case 0x5f : return 'sign_in';
case 0x60 : return 'sign_out';
case 0x61 : return 'stop_all_audio';
case 0x62 : return 'stop_audio';
case 0x63 : return 'stop_visualize';
case 0x64 : return 'texture_animated_change';
case 0x65 : return 'texture_instance_updated';
case 0x66 : return 'touch_cancel';
case 0x67 : return 'touch_end';
case 0x68 : return 'touch_move';
case 0x69 : return 'touch_start';
case 0x6a : return 'unresolved_dependencies_update';
case 0x6b : return 'visualize';
case 0x6c : return 'window_resize';
default :
throw new Error('Event type not defined : ' + eventId);
}
};

View File

@ -1,502 +0,0 @@
/**
* Event Core
* @constructor
*/
R3.Event = function() {
};
/**
* Some nice Events handling
* @type {{}}
*/
R3.Event.Subscriptions = {};
R3.Event.OnceSubscriptions = {};
/**
* Events we can subscribe to and emit
*/
R3.Event.WINDOW_RESIZE = 0x1;
R3.Event.PARENT_SCENE_CHANGE = 0x2;
R3.Event.EXCLUDE_FROM_ENVIRONMENT = 0x3;
R3.Event.INSTANCE_CLONED = 0x4;
R3.Event.LOAD_IMAGE = 0x5;
R3.Event.NEW_ENTITY = 0x6;
R3.Event.MATERIAL_TYPE_CHANGED = 0x7;
R3.Event.SAVE_COMPONENT = 0x8;
R3.Event.SAVE_COMPONENT_ERROR = 0x9;
R3.Event.COMPONENT_SAVED = 0xa;
R3.Event.LOAD_COMPONENT = 0xb;
R3.Event.LOAD_COMPONENT_ERROR = 0xc;
R3.Event.LOGGED_IN = 0xd;
R3.Event.COMPONENT_CREATED = 0xe;
R3.Event.COMPONENT_CLONED = 0xf;
R3.Event.TEXTURE_ANIMATED_CHANGE = 0x10;
R3.Event.ANIMATE_TEXTURE_INSTANCE = 0x11;
R3.Event.REMOVE_PARTICLE_ENGINE = 0x12;
R3.Event.GAME_PAUSE = 0x13;
R3.Event.SHADER_UPDATE = 0x14;
R3.Event.PLAY_AUDIO = 0x15;
R3.Event.MATERIAL_INSTANCE_UPDATED = 0x16;
R3.Event.PAUSE_AUDIO = 0x17;
R3.Event.MESH_INSTANCE_UPDATED = 0x18;
R3.Event.STOP_AUDIO = 0x19;
R3.Event.LIGHT_INSTANCE_UPDATED = 0x1a;
R3.Event.DELETE_COMPONENT = 0x1b;
R3.Event.COMPONENT_DOWNLOAD_COMPLETE = 0x1c;
R3.Event.COMPONENTS_LINKED = 0x1d;
R3.Event.UNRESOLVED_DEPENDENCIES_UPDATE = 0x1e;
R3.Event.REGISTER_UPDATE = 0x1f;
R3.Event.BUILD_GUI = 0x20;
R3.Event.REMOVE_MESH = 0x21;
R3.Event.MESH_SELECTED = 0x22;
R3.Event.MESH_DESELECTED = 0x23;
R3.Event.COMPONENT_REGISTER = 0x24;
R3.Event.IMAGE_NOT_FOUND = 0x25;
R3.Event.BLENDER_DATA_RECEIVED = 0x26;
R3.Event.IMAGE_UPLOAD_COMPLETE = 0x27;
R3.Event.REMOVE_COMPONENT = 0x28;
R3.Event.KEY_DOWN = 0x29;
R3.Event.KEY_UP = 0x2a;
R3.Event.RENDER = 0x2b;
R3.Event.EVENT_LIST = 0x2c;
R3.Event.COMPILE_SUCCESS = 0x2d;
R3.Event.COMPILE_FAILED = 0x2e;
R3.Event.TEXTURE_INSTANCE_UPDATED = 0x2f;
R3.Event.EVENT_ID_UPDATE = 0x30;
R3.Event.MATERIAL_TEXTURES_UPDATED = 0x31;
R3.Event.DELETE_COMPONENT_ERROR = 0x32;
R3.Event.COMPONENT_DELETED = 0x33;
R3.Event.COMPONENT_TYPES_FETCHED = 0x34;
R3.Event.AUDIO_ENDED = 0x35;
R3.Event.COMPONENT_LINKED = 0x36;
R3.Event.DONE_SAVING = 0x37;
R3.Event.BEFORE_RENDER = 0x38;
R3.Event.AFTER_RENDER = 0x39;
R3.Event.ARRAY_ITEM_ADDED = 0x3a;
R3.Event.INSTANCE_CREATED = 0x3b;
R3.Event.VISUALIZE = 0x3c;
R3.Event.STOP_VISUALIZE = 0x3d;
R3.Event.FETCH_COMPONENT_TYPES = 0x3e;
R3.Event.FETCH_COMPONENTS = 0x3f;
R3.Event.GET_API_URL = 0x40;
R3.Event.GET_RUNTIME = 0x41;
R3.Event.PARENT_WORLD_CHANGE = 0x42;
R3.Event.ANIMATE = 0x43;
R3.Event.ANIMATION_COMPILE_SUCCESS = 0x44;
R3.Event.ANIMATION_COMPILE_FAILED = 0x45;
R3.Event.SAVING = 0x46;
R3.Event.GAME_OVER = 0x47;
R3.Event.GAME_START = 0x48;
R3.Event.TOUCH_START = 0x49;
R3.Event.TOUCH_END = 0x4a;
R3.Event.TOUCH_MOVE = 0x4b;
R3.Event.TOUCH_CANCEL = 0x4c;
R3.Event.GET_REMOTE_API_URL = 0x4d;
R3.Event.COMPONENT_TYPES_UPDATE = 0x4e;
R3.Event.PROJECT_LOADED = 0x4f;
R3.Event.CAST_SOURCE_CHANGED = 0x50;
R3.Event.RESOLVE_DEPENDENCIES = 0x51;
R3.Event.NAME_UPDATE = 0x52;
R3.Event.CANVAS_CHANGE = 0x53;
R3.Event.AFTER_WINDOW_RESIZE = 0x54;
R3.Event.LOAD_FONT = 0x55;
R3.Event.FONT_NOT_FOUND = 0x56;
R3.Event.STOP_ALL_AUDIO = 0x57;
R3.Event.REGISTER_DEPENDENCIES = 0x58;
R3.Event.GAME_LOADED = 0x59;
R3.Event.COMPONENT_UPDATE = 0x5a;
R3.Event.LOAD_PROGRESS = 0x5b;
R3.Event.ENTITY_LOADED = 0x5c;
R3.Event.MOUSE_DOWN = 0x5d;
R3.Event.MOUSE_MOVE = 0x5e;
R3.Event.MOUSE_WHEEL = 0x5f;
R3.Event.MOUSE_UP = 0x60;
R3.Event.PARTICLE_INSTANCE_UPDATED = 0x61;
R3.Event.GAME_DATA = 0x62;
R3.Event.PAUSE_ALL_AUDIO = 0x63;
R3.Event.CONTINUE_ALL_AUDIO = 0x64;
R3.Event.MUTE_AUDIO = 0x65;
R3.Event.GAME_STARTED = 0x66;
R3.Event.GAME_PAUSED = 0x67;
R3.Event.GAME_RESUMED = 0x68;
R3.Event.CUSTOM_GAME_START = 0x69;
R3.Event.AUDIO_MUTED = 0x6a;
R3.Event.AUDIO_UNMUTED = 0x6b;
R3.Event.RECEIVE_DESTINATION_CHANGED = 0x6c;
R3.Event.SELECTION_MODE_CHANGE = 0x6d;
R3.Event.MESH_FACE_SELECTED = 0x6e;
R3.Event.MESH_FACE_DESELECTED = 0x6f;
R3.Event.BEFORE_WINDOW_RESIZE = 0x70;
R3.Event.GET_WINDOW_SIZE = 0x71;
R3.Event.GET_QUERY_API_URL = 0x72;
//R3.Event.SET_ACTIVE_RENDER_CONFIGURATION = 0x73;
R3.Event.REPLACE_COMPONENT = 0x74;
R3.Event.COMPONENT_REPLACED = 0x75;
R3.Event.ENGINE_FIRED_PARTICLES_ZERO = 0x76;
R3.Event.GET_DEFAULT_SCENE = 0x77;
R3.Event.GET_DEFAULT_CAMERA = 0x78;
R3.Event.GET_WEBSOCKET_CONFIG = 0x79;
R3.Event.GET_PROJECT = 0x7a;
R3.Event.GET_APPLICATION_MODE = 0x80;
R3.Event.RENDERER_SIZE_CHANGE = 0x81;
R3.Event.GET_REGISTER_FACES = 0x82;
R3.Event.GET_PROJECT_CANVAS = 0x83;
/**
* Returns string name of event ID
* @param number
* @returns {*}
* @constructor
*/
R3.Event.GetEventName = function(number) {
switch(number) {
case 0x1 : return 'window_resize';
case 0x2 : return 'parent_scene_change';
case 0x3 : return 'unused';
case 0x4 : return 'instance_cloned';
case 0x5 : return 'load_image';
case 0x6 : return 'new_entity';
case 0x7 : return 'material_type_changed';
case 0x8 : return 'save_component';
case 0x9 : return 'save_component_error';
case 0xa : return 'component_saved';
case 0xb : return 'load_component';
case 0xc : return 'load_component_error';
case 0xd : return 'logged_in';
case 0xe : return 'component_created';
case 0xf : return 'component_cloned';
case 0x10 : return 'texture_animated_change';
case 0x11 : return 'animate_texture_instance';
case 0x12 : return 'remove_particle_engine';
case 0x13 : return 'pause';
case 0x14 : return 'shader_update';
case 0x15 : return 'play_audio';
case 0x16 : return 'material_instance_updated';
case 0x17 : return 'pause_audio';
case 0x18 : return 'mesh_instance_updated';
case 0x19 : return 'stop_audio';
case 0x1a : return 'light_instance_updated';
case 0x1b : return 'delete_component';
case 0x1c : return 'component_download_complete';
case 0x1d : return 'components_linked';
case 0x1e : return 'unresolved_dependencies_update';
case 0x1f : return 'register_update';
case 0x20 : return 'build_gui';
case 0x21 : return 'remove_mesh';
case 0x22 : return 'mesh_selected';
case 0x23 : return 'mesh_deselected';
case 0x24 : return 'component_register';
case 0x25 : return 'image_not_found';
case 0x26 : return 'blender_data_received';
case 0x27 : return 'image_upload_complete';
case 0x28 : return 'remove_component';
case 0x29 : return 'key_down';
case 0x2a : return 'key_up';
case 0x2b : return 'render';
case 0x2c : return 'event_list';
case 0x2d : return 'compile_success';
case 0x2e : return 'compile_failed';
case 0x2f : return 'texture_image_updated';
case 0x30 : return 'event_id_update';
case 0x31 : return 'material_textures_updated';
case 0x32 : return 'delete_component_error';
case 0x33 : return 'component_deleted';
case 0x34 : return 'component_types_updated';
case 0x35 : return 'audio_ended';
case 0x36 : return 'component_linked';
case 0x37 : return 'done_saving';
case 0x38 : return 'before_render';
case 0x39 : return 'after_render';
case 0x3a : return 'array_item_added';
case 0x3b : return 'instance_created';
case 0x3c : return 'visualize';
case 0x3d : return 'stop_visualize';
case 0x3e : return 'fetch_component_types';
case 0x3f : return 'fetch_components';
case 0x40 : return 'get_api_url';
case 0x41 : return 'get_runtime';
case 0x42 : return 'parent_world_change';
case 0x43 : return 'animate';
case 0x44 : return 'animation_compile_success';
case 0x45 : return 'animation_compile_failed';
case 0x46 : return 'saving';
case 0x47 : return 'game_over';
case 0x48 : return 'game_start';
case 0x49 : return 'touch_start';
case 0x4a : return 'touch_end';
case 0x4b : return 'touch_move';
case 0x4c : return 'touch_cancel';
case 0x4d : return 'get_remote_api_url';
case 0x4e : return 'component_types_update';
case 0x4f : return 'project_loaded';
case 0x50 : return 'cast_source_changed';
case 0x51 : return 'resolve_dependencies';;
case 0x52 : return 'name_update';
case 0x53 : return 'dom_element_change';
case 0x54 : return 'after_window_resize';
case 0x55 : return 'load_font';
case 0x56 : return 'font_not_found';
case 0x57 : return 'stop_all_audio';
case 0x58 : return 'register_dependencies';
case 0x59 : return 'game_loaded';
case 0x5a : return 'component_update';
case 0x5b : return 'load_progress';
case 0x5c : return 'entity_loaded';
case 0x5d : return 'mouse_down';
case 0x5e : return 'mouse_move';
case 0x5f : return 'mouse_wheel';
case 0x60 : return 'mouse_up';
case 0x61 : return 'particle_instance_updated';
case 0x62 : return 'game_data';
case 0x63 : return 'pause_all_audio';
case 0x64 : return 'continue_all_audio';
case 0x65 : return 'mute_audio';
case 0x66 : return 'game_started';
case 0x67 : return 'game_paused';
case 0x68 : return 'game_resumed';
case 0x69 : return 'custom_game_start';
case 0x6a : return 'audio_muted';
case 0x6b : return 'audio_unmuted';
case 0x6c : return 'receive_destination_changed';
case 0x6d : return 'selection_mode_change';
case 0x6e : return 'mesh_face_selected';
case 0x6f : return 'mesh_face_deselected';
case 0x70 : return 'before_window_resize';
case 0x71 : return 'get_window_size';
case 0x72 : return 'get_render_configuration';
case 0x73 : return 'set_active_render_configuration';
case 0x74 : return 'replace_component';
case 0x75 : return 'component_replaced';
case 0x76 : return 'engine_fired_particles_zero';
case 0x77 : return 'get_default_scene';
case 0x78 : return 'get_default_camera';
case 0x79 : return 'get_websocket_config';
case 0x7a : return 'get_project';
case 0x80 : return 'get_application_mode';
case 0x81 : return 'renderer_size_change';
case 0x82 : return 'get_register_faces';
case 0x83 : return 'get_project_canvas';
break;
}
throw new error('unknown event id: ' + number );
};
/**
* Subscribe to some events
* @param eventName
* @param callback
*/
R3.Event.prototype.subscribe = function(
eventName,
callback
) {
return R3.Event.Subscribe(eventName, callback.bind(this));
};
// /**
// * Stop listening for this event after the callback returns true
// * @param eventName
// * @param callback
// * @returns {{fn, remove: remove}}
// */
// R3.Event.prototype.subscribeOnce = function(
// eventName,
// callback
// ) {
// throw new Error('implement first properly');
// // var fn = callback.bind(this);
// //
// // if (R3.Event.OnceSubscriptions.hasOwnProperty(eventName)) {
// // R3.Event.OnceSubscriptions[eventName].push(fn);
// // } else {
// // R3.Event.OnceSubscriptions[eventName] = [];
// // R3.Event.OnceSubscriptions[eventName].push(fn);
// // }
// //
// // /**
// // * Return a handle to the caller to allow us to unsubscribe to this event
// // */
// // return {
// // fn : fn,
// // remove : function() {
// // R3.Event.Subscriptions[eventName].splice(
// // R3.Event.Subscriptions[eventName].indexOf(fn),
// // 1
// // );
// // }
// // }
// };
/**
*
* @param eventName
* @param data
*/
/**
* Publish some event happened with some data
* @param eventName
* @param data
* @param clientCallback
* @param clientErrorCallback
* @returns {number} of callbacks executed
*/
R3.Event.prototype.emit = function(
eventName,
data,
clientCallback,
clientErrorCallback
) {
return R3.Event.Emit(
eventName,
data,
clientCallback,
clientErrorCallback
);
};
/**
* Static method call
* @param eventName
* @param data
* @param clientCallback is executed ideally when the event completed
* @param clientErrorCallback
* @returns {number} of callbacks executed
* @constructor
*/
R3.Event.Emit = function(
eventName,
data,
clientCallback,
clientErrorCallback
) {
var count = 0;
if (R3.Event.Subscriptions.hasOwnProperty(eventName)) {
if (R3.Event.Subscriptions[eventName].length === 0) {
if (clientCallback) {
/**
* We execute the client callback immediately since there are no subscriptions to this event
*/
clientCallback();
}
if (clientErrorCallback) {
clientErrorCallback({
message : 'No subscriptions for event ' + eventName
})
}
}
/**
* We need to execute all the callbacks, but not execute them twice, but also keep in mind they can remove
* themselves during execution
*/
// var length = R3.Event.Subscriptions[eventName].length;
//
// for (var i = 0; i < length; i++) {
//
// var object = R3.Event.Subscriptions[eventName][i];
//
// if (object.fn && object.executed === false) {
// object.fn(data, clientCallback, clientErrorCallback);
// object.executed = true;
// }
//
// if (length !== R3.Event.Subscriptions[eventName].length) {
// /**
// * this callback removed a subscription - reset i and reset the length
// */
// i = 0;
// length = R3.Event.Subscriptions[eventName].length;
// }
// }
//
// R3.Event.Subscriptions[eventName].map(
// function(object){
// object.executed = false;
// }
// )
R3.Event.Subscriptions[eventName].map(
function(callback) {
if (callback) {
callback(data, clientCallback, clientErrorCallback);
count++;
}
}
)
} else {
if (clientCallback) {
/**
* We execute the client callback immediately since there are no subscriptions to this event
*/
clientCallback();
}
if (clientErrorCallback) {
clientErrorCallback({
message : 'No subscriptions for event ' + eventName
})
}
}
return count;
};
R3.Event.Subscribe = function(
eventName,
fn
) {
if (R3.Event.Subscriptions.hasOwnProperty(eventName)) {
R3.Event.Subscriptions[eventName].push(fn);
// {
// fn : fn,
// executed : false
// }
// );
} else {
R3.Event.Subscriptions[eventName] = [];
R3.Event.Subscriptions[eventName].push(fn);
// {
// fn : fn,
// executed : false
// }
// );
}
/**
* Return a handle to the caller to allow us to unsubscribe to this event
*/
return {
fn : fn,
remove : function() {
var index = R3.Event.Subscriptions[eventName].indexOf(fn);
// reduce(
// function(result, object, index) {
// if (object.fn === fn) {
// result = index;
// }
// return result;
// },
// -1
// );
if (index === -1) {
throw new Error('could not remove subscription');
}
R3.Event.Subscriptions[eventName].splice(
index,
1
);
}
}
};

View File

@ -41,6 +41,7 @@ R3.API.Component = function(
selected = false;
}
this.selected = selected;
};
R3.API.Component.prototype.constructor = R3.API.Component;
@ -51,7 +52,7 @@ R3.API.Component.prototype.constructor = R3.API.Component;
* @returns {*}
*/
R3.API.Component.prototype.getFirstParent = function(constructor) {
return R3.D3.GetFirstParent(this, constructor);
return R3.Utils.GetFirstParent(this, constructor);
};
/**
@ -62,5 +63,5 @@ R3.API.Component.prototype.getFirstParent = function(constructor) {
* @returns {*}
*/
R3.API.Component.getParent = function(property, index, constructor) {
return R3.D3.GetParent(this, property, index, constructor);
return R3.Utils.GetParent(this, property, index, constructor);
};

View File

@ -25,6 +25,106 @@ R3.Utils.GetFirstParent = function(object, constructor) {
};
R3.Utils.GetParentProject = function(component) {
if (R3.Utils.UndefinedOrNull(component.parent)) {
throw new Error('Parent not found');
}
if (component.parent instanceof R3.Project) {
return component.parent;
}
return R3.Utils.GetParentProject(component.parent);
};
R3.Utils.GetParents = function(component, parents) {
if (R3.Utils.UndefinedOrNull(parents)) {
parents = [];
}
if (R3.Utils.UndefinedOrNull(component.parent)) {
return parents;
}
parents.push(component.parent);
return R3.Utils.GetParents(component.parent, parents);
};
/**
* @return {boolean}
*/
R3.Utils.Instance = function(component) {
return R3.Utils.Defined(component) && R3.Utils.Defined(component.instance);
};
/**
* R3.Utils.RemoveFromSelect
* @param select
* @param id
* @returns {boolean}
* @constructor
*/
R3.Utils.RemoveFromSelect = function(select, id) {
var i;
for (i = 0; i < select.options.length; i++) {
if (select.options[i].value === id) {
select.remove(i);
return true;
}
}
return false;
};
/**
* R3.Utils.GetSelectIndex
*
* Get the select index of given id
*
* @param select
* @param id
* @returns {null|number}
* @constructor
*/
R3.Utils.SetSelectIndex = function(select, id) {
var i;
for (i = 0; i < select.options.length; i++) {
if (select.options[i].value === id) {
select.selectedIndex = i;
}
}
return null;
};
R3.Utils.SortSelect = function(select) {
var tmp = [];
var i;
for (i = 1; i < select.options.length; i++) {
tmp[i-1] = [];
tmp[i-1][0] = select.options[i].text;
tmp[i-1][1] = select.options[i].value;
}
tmp.sort();
select.options = [select.options[0]];
for (i = 0; i < tmp.length; i++) {
select.options[i+1] = new Option(tmp[i][0], tmp[i][1]);
}
return;
};
/**
* Gets the parent of object whith property of optional type constructor. If index is specified, get the parent of the
* object with property[index] - which means the property should be an array

File diff suppressed because it is too large Load Diff

View File

@ -15,12 +15,12 @@ R3.API.Canvas = function(
this.autoUpdateSize = apiComponent.autoUpdateSize;
if (R3.Utils.UndefinedOrNull(apiComponent.width)) {
apiComponent.width = 512;
apiComponent.width = 450;
}
this.width = apiComponent.width;
if (R3.Utils.UndefinedOrNull(apiComponent.height)) {
apiComponent.height = 512;
apiComponent.height = 450;
}
this.height = apiComponent.height;
@ -28,10 +28,11 @@ R3.API.Canvas = function(
apiComponent.offset = new R3.API.Vector2(
{
parent : this,
register : true
},
0,
0
register : true,
name : this.name + ' - Offset',
x : 0,
y : 0
}
);
}
this.offset = apiComponent.offset;

View File

@ -1,28 +1,23 @@
/**
* R3.API.Controls
* @param apiComponent
* @param canvas
*
* @property canvas
*
* @constructor
*/
R3.API.Controls = function(
apiComponent,
canvas
apiComponent
) {
__API_COMPONENT__;
__DEFINE_API_COMPONENT__
if (R3.Utils.UndefinedOrNull(apiComponent.canvas)) {
R3.Event.Emit(
R3.Event.GET_PROJECT_CANVAS,
{
controls : this
},
function(projectCanvas) {
apiComponent.canvas = projectCanvas;
}
)
apiComponent.canvas = null;
}
this.canvas = apiComponent.canvas;
this.previousCanvas = this.canvas;
};
R3.API.Controls.prototype = Object.create(R3.API.Component.prototype);

View File

@ -1,22 +1,33 @@
/**
* Raw Controls API object
* R3.API.Controls.D3
* @param apiComponent
*
* @property camera
* @property enabled
*
* @constructor
*/
R3.API.Controls.D3 = function(
apiComponent
) {
__DEFINE_API_COMPONENT__
R3.API.Controls.call(
this,
apiComponent
);
if (R3.Utils.UndefinedOrNull(apiComponent.camera)) {
var project = this.getFirstParent(R3.API.Project);
apiComponent.camera = project.cameras[R3.API.Project.CAMERA_INDEX_EDIT];
apiComponent.camera = null;
}
this.camera = apiComponent.camera;
if (R3.Utils.UndefinedOrNull(apiComponent.enabled)) {
apiComponent.enabled = true;
}
this.enabled = apiComponent.enabled;
};
R3.API.Controls.D3.prototype = Object.create(R3.API.Controls.prototype);

View File

@ -7,15 +7,7 @@ R3.API.Controls.D3.FirstPerson = function(
apiComponent
) {
R3.API.Controls.D3.call(
this,
apiComponent
);
if (R3.Utils.UndefinedOrNull(apiComponent.enabled)) {
apiComponent.enabled = true;
}
this.enabled = apiComponent.enabled;
__API_COMPONENT__;
if (R3.Utils.UndefinedOrNull(apiComponent.movementSpeed)) {
apiComponent.movementSpeed = 1.0;
@ -82,6 +74,10 @@ R3.API.Controls.D3.FirstPerson = function(
}
this.autoSpeedFactor = apiComponent.autoSpeedFactor;
R3.API.Controls.D3.call(
this,
apiComponent
);
};
R3.API.Controls.D3.FirstPerson.prototype = Object.create(R3.API.Controls.D3.prototype);

View File

@ -7,21 +7,13 @@ R3.API.Controls.D3.Orbit = function(
apiComponent
) {
R3.API.Controls.D3.call(
this,
apiComponent
);
__API_COMPONENT__;
if (R3.Utils.UndefinedOrNull(apiComponent.target)) {
apiComponent.target = null;
}
this.target = apiComponent.target;
if (R3.Utils.UndefinedOrNull(apiComponent.enabled)) {
apiComponent.enabled = true;
}
this.enabled = apiComponent.enabled;
if (R3.Utils.UndefinedOrNull(apiComponent.minPolarAngle)) {
apiComponent.minPolarAngle = 0;
}
@ -87,6 +79,10 @@ R3.API.Controls.D3.Orbit = function(
}
this.enableKeys = apiComponent.enableKeys;
R3.API.Controls.D3.call(
this,
apiComponent
);
};
R3.API.Controls.D3.Orbit.prototype = Object.create(R3.API.Controls.D3.prototype);

View File

@ -6,6 +6,9 @@
R3.API.Controls.Keyboard = function(
apiComponent
) {
__API_COMPONENT__;
R3.API.Controls.call(
this,
apiComponent

View File

@ -6,6 +6,9 @@
R3.API.Controls.Mouse = function(
apiComponent
) {
__API_COMPONENT__;
R3.API.Controls.call(
this,
apiComponent

View File

@ -1,24 +1,27 @@
/**
* @param apiControls
* @param sensitivity
* R3.API.Controls.Touch
* @param apiComponent
*
* @property sensitivity
*
* @constructor
*/
R3.API.Controls.Touch = function(
apiControls,
sensitivity
apiComponent
) {
R3.API.Controls.call(
this,
apiControls,
apiControls.canvas
);
__API_COMPONENT__;
if (R3.Utils.UndefinedOrNull(apiComponent.sensitivity)) {
apiComponent.sensitivity = 5;
}
this.sensitivity = apiComponent.sensitivity;
R3.API.Controls.call(
this,
apiComponent
);
};
R3.API.Controls.Touch.prototype = Object.create(R3.API.Controls.prototype);

View File

@ -13,6 +13,7 @@ R3.API.DomElement = function(
apiComponent.domElementId = '';
}
this.domElementId = apiComponent.domElementId;
};
R3.API.DomElement.prototype = Object.create(R3.API.Component.prototype);

View File

@ -1,19 +0,0 @@
/**
* R3.API.EntityManager
* @param apiComponent
* @constructor
*/
R3.API.EntityManager = function(
apiComponent
) {
__API_COMPONENT__;
if (R3.Utils.UndefinedOrNull(apiComponent.entities)) {
apiComponent.entities = [];
}
this.entities = apiComponent.entities;
};
R3.API.EntityManager.prototype = Object.create(R3.API.Component.prototype);
R3.API.EntityManager.prototype.constructor = R3.API.EntityManager;

View File

@ -12,10 +12,10 @@ R3.API.Graph = function(
__API_COMPONENT__;
if (R3.Utils.UndefinedOrNull(apiComponent.domElement)) {
apiComponent.domElement = null;
if (R3.Utils.UndefinedOrNull(apiComponent.query)) {
apiComponent.query = null;
}
this.domElement = apiComponent.domElement;
this.query = apiComponent.query;
};

View File

@ -11,8 +11,14 @@ R3.API.Graph.Barchart = function(
this,
apiComponent
);
if (R3.Utils.UndefinedOrNull(apiComponent.domElement)) {
apiComponent.domElement = null;
}
this.domElement = apiComponent.domElement;
};
R3.API.Graph.Barchart.prototype = Object.create(R3.API.Graph.prototype);
R3.API.Graph.Barchart.prototype.constructor = R3.API.Graph.Barchart;

View File

@ -11,8 +11,13 @@ R3.API.Graph.Barchart.Stacked = function(
this,
apiComponent
);
if (R3.Utils.UndefinedOrNull(apiComponent.domElement)) {
apiComponent.domElement = null;
}
this.domElement = apiComponent.domElement;
};
R3.API.Graph.Barchart.prototype = Object.create(R3.API.Graph.Barchart.prototype);
R3.API.Graph.Barchart.prototype.constructor = R3.API.Graph.Barchart;
R3.API.Graph.Barchart.Stacked.prototype = Object.create(R3.API.Graph.Barchart.prototype);
R3.API.Graph.Barchart.Stacked.prototype.constructor = R3.API.Graph.Barchart.Stacked;

View File

@ -11,7 +11,12 @@ R3.API.Graph.Metric = function(
this,
apiComponent
);
if (R3.Utils.UndefinedOrNull(apiComponent.domElements)) {
apiComponent.domElements = [];
}
this.domElements = apiComponent.domElements;
};
R3.API.Graph.Metric.prototype = Object.create(R3.API.Graph.prototype);

View File

@ -11,7 +11,22 @@ R3.API.Graph.Table = function(
this,
apiComponent
);
if (R3.Utils.UndefinedOrNull(apiComponent.domElement)) {
apiComponent.domElement = null;
}
this.domElement = apiComponent.domElement;
if (R3.Utils.UndefinedOrNull(apiComponent.columns)) {
apiComponent.columns = [];
}
this.columns = apiComponent.columns;
if (R3.Utils.UndefinedOrNull(apiComponent.rows)) {
apiComponent.rows = [];
}
this.rows = apiComponent.rows;
};
R3.API.Graph.Table.prototype = Object.create(R3.API.Graph.prototype);

View File

@ -9,15 +9,16 @@ R3.API.Mouse = function(
__API_COMPONENT__;
if (R3.Utils.UndefinedOrNull(apiComponent.x)) {
apiComponent.x = 0;
if (R3.Utils.UndefinedOrNull(apiComponent.position)) {
apiComponent.position = new R3.API.Vector2(
{
parent : this,
register : true,
name : this.name + ' - Position'
}
);
}
this.x = apiComponent.x;
if (R3.Utils.UndefinedOrNull(apiComponent.y)) {
apiComponent.y = 0;
}
this.y = apiComponent.y;
this.position = apiComponent.position;
};

57
src/r3-api-project-0.js Normal file
View File

@ -0,0 +1,57 @@
/**
* R3.API.Project
* @param apiComponent
*
* @property users
* @property isPublic
* @property entities
* @property controls
* @property images
* @property applicationMode
*
* @constructor
*/
R3.API.Project = function(
apiComponent
) {
__DEFINE_API_COMPONENT__
if (R3.Utils.UndefinedOrNull(apiComponent.isPublic)) {
apiComponent.isPublic = true;
}
this.isPublic = apiComponent.isPublic;
if (R3.Utils.UndefinedOrNull(apiComponent.entities)) {
apiComponent.entities = [];
}
this.entities = apiComponent.entities;
if (R3.Utils.UndefinedOrNull(apiComponent.controls)) {
apiComponent.controls = []
}
this.controls = apiComponent.controls;
if (R3.Utils.UndefinedOrNull(apiComponent.images)) {
apiComponent.images = []
}
this.images = apiComponent.images;
if (R3.Utils.UndefinedOrNull(apiComponent.applicationMode)) {
apiComponent.applicationMode = R3.API.Project.APPLICATION_MODE_EDIT;
}
this.applicationMode = apiComponent.applicationMode;
};
R3.API.Project.prototype = Object.create(R3.API.Component.prototype);
R3.API.Project.prototype.constructor = R3.API.Project;
R3.API.Project.CAMERA_INDEX_EDIT = 0x0;
R3.API.Project.CAMERA_INDEX_RUN = 0x1;
R3.API.Project.APPLICATION_MODE_EDIT = R3.API.Project.CAMERA_INDEX_EDIT;
R3.API.Project.APPLICATION_MODE_RUN = R3.API.Project.CAMERA_INDEX_RUN;
R3.API.Project.RENDERER_INDEX_MAIN = 0x0;
R3.API.Project.RENDER_TARGET_INDEX_NONE = -0x1;

65
src/r3-api-project-d2.js Normal file
View File

@ -0,0 +1,65 @@
/**
* R3.API.Project
* @param apiComponent
*
* @property renderers
* @property controls
*
* @constructor
*/
R3.API.Project.D2 = function(
apiComponent
) {
__API_COMPONENT__;
if (R3.Utils.UndefinedOrNull(apiComponent.renderers)) {
apiComponent.renderers = [
new R3.API.Renderer.D2(
{
parent : this,
name : this.name + ' - 2D Renderer'
}
)
];
}
this.renderers = apiComponent.renderers;
if (R3.Utils.UndefinedOrNull(apiComponent.controls)) {
apiComponent.controls = [
new R3.API.Controls.Mouse(
{
parent : this,
name : this.name + ' - Mouse Controls',
canvas : this.renderers[0].canvas
}
),
new R3.API.Controls.Keyboard(
{
parent : this,
name : this.name + ' - Keyboard Controls',
canvas : this.renderers[0].canvas
}
),
new R3.API.Controls.Touch(
{
parent : this,
name : this.name + ' - Touch Controls',
canvas : this.renderers[0].canvas
}
)
]
}
this.controls = apiComponent.controls;
R3.API.Project.call(
this,
apiComponent
);
};
R3.API.Project.D2.prototype = Object.create(R3.API.Project.prototype);
R3.API.Project.D2.prototype.constructor = R3.API.Project.D2;

142
src/r3-api-project-d3.js Normal file
View File

@ -0,0 +1,142 @@
/**
* R3.API.Project
* @param apiComponent
*
* @property renderers
* @property renderTargets
* @property cameras
* @property controls
* @property audios
*
* @constructor
*/
R3.API.Project.D3 = function(
apiComponent
) {
/**
* Override Controls for 3D projects
*/
__API_COMPONENT__;
/**
* This means we need to construct the cameras first if they are not coming from the database
*/
if (R3.Utils.UndefinedOrNull(apiComponent.cameras)) {
var editCamera = new R3.D3.API.Camera.Perspective(
{
parent : this,
name : this.name + ' - Edit Camera'
}
);
var runCamera = new R3.D3.API.Camera.Perspective(
{
parent : this,
name : this.name + ' - Run Camera'
}
);
apiComponent.cameras = [editCamera, runCamera];
}
this.cameras = apiComponent.cameras;
if (R3.Utils.UndefinedOrNull(apiComponent.mouse)) {
apiComponent.mouse = new R3.API.Mouse(
{
parent: this,
name: this.name + ' - Mouse'
}
);
}
this.mouse = apiComponent.mouse;
if (R3.Utils.UndefinedOrNull(apiComponent.raycaster)) {
apiComponent.raycaster = new R3.D3.API.Raycaster(
{
parent: this,
name: this.name + ' - Raycaster'
}
);
}
this.raycaster = apiComponent.raycaster;
if (R3.Utils.UndefinedOrNull(apiComponent.clock)) {
apiComponent.clock = new R3.API.Clock(
{
parent: this,
name: this.name + ' - Clock'
}
);
}
this.clock = apiComponent.clock;
/**
* And we should also override here the renderers if they are not coming from the API
*/
if (R3.Utils.UndefinedOrNull(apiComponent.renderers)) {
apiComponent.renderers = [
new R3.API.Renderer.D3.Canvas(
{
parent : this,
name : this.name + ' - 3D Canvas Renderer'
}
)
];
}
this.renderers = apiComponent.renderers;
/**
* Now override the controls before initializing the other API properties
*/
if (R3.Utils.UndefinedOrNull(apiComponent.controls)) {
apiComponent.controls = [
new R3.API.Controls.Mouse(
{
parent : this,
name : this.name + ' - Mouse Controls',
canvas : this.renderers[0].canvas
}
),
new R3.API.Controls.Keyboard(
{
parent : this,
name : this.name + ' - Keyboard Controls',
canvas : this.renderers[0].canvas
}
),
new R3.API.Controls.Touch(
{
parent : this,
name : this.name + ' - Touch Controls',
canvas : this.renderers[0].canvas
}
),
new R3.API.Controls.D3.Orbit(
{
parent : this,
name : this.name + ' - Orbit Controls',
camera : editCamera,
canvas : this.renderers[0].canvas
}
)
];
}
if (R3.Utils.UndefinedOrNull(apiComponent.renderTargets)) {
apiComponent.renderTargets = [];
}
this.renderTargets = apiComponent.renderTargets;
if (R3.Utils.UndefinedOrNull(apiComponent.audios)) {
apiComponent.audios = [];
}
this.audios = apiComponent.audios;
R3.API.Project.call(
this,
apiComponent
);
};
R3.API.Project.D3.prototype = Object.create(R3.API.Project.prototype);
R3.API.Project.D3.prototype.constructor = R3.API.Project.D3;

View File

@ -1,90 +0,0 @@
/**
* R3.API.Project
* @param apiComponent
*
* @property users
* @property isPublic
* @property entities
* @property renderers
* @property renderTargets
* @property cameras
* @property controls
* @property audios
* @property applicationMode
*
* @constructor
*/
R3.API.Project = function(
apiComponent
) {
__API_COMPONENT__;
if (R3.Utils.UndefinedOrNull(apiComponent.users)) {
throw new Error('Only registered users can create projects');
}
this.users = apiComponent.users;
if (R3.Utils.UndefinedOrNull(apiComponent.isPublic)) {
apiComponent.isPublic = true;
}
this.isPublic = apiComponent.isPublic;
if (R3.Utils.UndefinedOrNull(apiComponent.entities)) {
apiComponent.entities = [];
}
this.entities = apiComponent.entities;
if (R3.Utils.UndefinedOrNull(apiComponent.renderers)) {
apiComponent.renderers = [new R3.API.Renderer.D3()];
}
this.renderers = apiComponent.renderers;
if (R3.Utils.UndefinedOrNull(apiComponent.renderTargets)) {
apiComponent.renderTargets = [];
}
this.renderTargets = apiComponent.renderTargets;
if (R3.Utils.UndefinedOrNull(apiComponent.cameras)) {
var editCamera = new R3.D3.API.Camera.Perspective(
{
name : 'Edit Camera'
}
);
var runCamera = new R3.D3.API.Camera.Perspective(
{
name : 'Run Camera'
}
);
apiComponent.cameras = [editCamera, runCamera];
}
this.cameras = apiComponent.cameras;
if (R3.Utils.UndefinedOrNull(apiComponent.controls)) {
apiComponent.controls = [];
}
this.controls = apiComponent.controls;
if (R3.Utils.UndefinedOrNull(apiComponent.audios)) {
apiComponent.audios = [];
}
this.audios = apiComponent.audios;
if (R3.Utils.UndefinedOrNull(apiComponent.applicationMode)) {
apiComponent.applicationMode = R3.API.Project.APPLICATION_MODE_EDIT;
}
this.applicationMode = apiComponent.applicationMode;
};
R3.API.Project.prototype = Object.create(R3.API.Component.prototype);
R3.API.Project.prototype.constructor = R3.API.Project;
R3.API.Project.CAMERA_INDEX_EDIT = 0x0;
R3.API.Project.CAMERA_INDEX_RUN = 0x1;
R3.API.Project.APPLICATION_MODE_EDIT = R3.API.Project.CAMERA_INDEX_EDIT;
R3.API.Project.APPLICATION_MODE_RUN = R3.API.Project.CAMERA_INDEX_RUN;
R3.API.Project.RENDERER_INDEX_MAIN = 0x0;
R3.API.Project.RENDER_TARGET_INDEX_NONE = -0x1;

View File

@ -34,7 +34,8 @@ R3.API.Quaternion = function(
if (R3.Utils.UndefinedOrNull(apiComponent.axis)) {
apiComponent.axis = new R3.API.Vector3(
{
parent : this,
parent : this.parent,
name : this.parent.name + ' - Quaternion Axis',
register : this.register
}
);

View File

@ -8,7 +8,6 @@
* @property timezone
* @property size
* @property text
* @property onData
*
* @constructor
*/
@ -24,7 +23,7 @@ R3.API.Query = function(
this.path = apiComponent.path;
if (R3.Utils.UndefinedOrNull(apiComponent.start)) {
apiComponent.start = 'now-7d';
apiComponent.start = 'now-365d';
}
this.start = apiComponent.start;
@ -33,13 +32,13 @@ R3.API.Query = function(
}
this.end = apiComponent.end;
if (R3.Utils.UndefinedOrNull(apiComponent.timezone)) {
apiComponent.timezone = 'Europe/Berlin';
if (R3.Utils.UndefinedOrNull(apiComponent.timeZone)) {
apiComponent.timeZone = 'Europe/Berlin';
}
this.timezone = apiComponent.timezone;
this.timeZone = apiComponent.timeZone;
if (R3.Utils.UndefinedOrNull(apiComponent.size)) {
apiComponent.size = 0;
apiComponent.size = 100;
}
this.size = apiComponent.size;
@ -48,13 +47,6 @@ R3.API.Query = function(
}
this.text = apiComponent.text;
if (R3.Utils.UndefinedOrNull(apiComponent.onData)) {
apiComponent.onData = function() {
console.log('todo: implement this query onData event');
};
}
this.onData = apiComponent.onData;
};
R3.API.Query.prototype = Object.create(R3.API.Component.prototype);
@ -65,4 +57,14 @@ R3.API.Query.QUERY_START = 'QUERY_START';
R3.API.Query.QUERY_END = 'QUERY_END';
R3.API.Query.QUERY_TIMEZONE = 'QUERY_TIMEZONE';
R3.API.Query.QUERY_BUCKET_FIELD = 'QUERY_BUCKET_FIELD';
R3.API.Query.QUERY_LOGIN_TYPE = 'QUERY_LOGIN_TYPE';
R3.API.Query.QUERY_ACKNOWLEDGED = 'QUERY_ACKNOWLEDGED';
R3.API.Query.LOGIN_TYPE_ALL = 'local|remote|application|vpn';
R3.API.Query.LOGIN_TYPE_DEVICE = 'local|remote';
R3.API.Query.LOGIN_TYPE_APPLICATION = 'application';
R3.API.Query.LOGIN_TYPE_VPN = 'vpn';
R3.API.Query.ACKNOWLEDGED_ALL = 'true|false';
R3.API.Query.ACKNOWLEDGED_TRUE = 'true';
R3.API.Query.ACKNOWLEDGED_FALSE = 'false';

View File

@ -7,17 +7,18 @@ R3.API.Query.Alerts = function(
apiComponent
) {
R3.API.Query.call(
this,
apiComponent
);
__DEFINE_API_COMPONENT__
if (R3.Utils.UndefinedOrNull(apiComponent.path)) {
apiComponent.path = '/alerts/_search';
}
this.path = apiComponent.path;
R3.API.Query.call(
this,
apiComponent
);
};
R3.API.Query.Alerts.prototype = Object.create(R3.API.Query.prototype);

View File

@ -10,66 +10,94 @@ R3.API.Query.Alerts.Buckets = function(
apiComponent
) {
__DEFINE_API_COMPONENT__
/**
* Override default size
*/
if (R3.Utils.UndefinedOrNull(apiComponent)) {
apiComponent = {
size : 100
};
}
if (R3.Utils.UndefinedOrNull(apiComponent.size)) {
apiComponent.size = 100;
}
/**
* Override default text
*/
if (R3.Utils.UndefinedOrNull(apiComponent.text)) {
apiComponent.text = '{\n' +
' "version": false,\n' +
' "size": ' + R3.API.Query.QUERY_SIZE + ',\n' +
' "sort": [\n' +
' {\n' +
' "priority": {\n' +
' "order": "asc"\n' +
' },\n' +
' "acknowledged": {\n' +
' "order": "asc"\n' +
' },\n' +
' "' + R3.API.Query.QUERY_BUCKET_FIELD + '": {\n' +
' "order": "asc"\n' +
' }\n' +
' }\n' +
' ], \n' +
' "_source": {\n' +
' "includes": ["*"]\n' +
' }, \n' +
' "aggs": {\n' +
' "descriptions": {\n' +
' "terms" : { "field" : "' + R3.API.Query.QUERY_BUCKET_FIELD + '" },\n' +
' "aggs": {\n' +
' "priorities": {\n' +
' "histogram": {\n' +
' "field": "priority",\n' +
' "interval": "1",\n' +
' "min_doc_count": 0\n' +
' }\n' +
' }\n' +
' }\n' +
' }\n' +
' }, \n' +
' "query": {\n' +
' "bool": {\n' +
' "must": [\n' +
' {\n' +
' "range": {\n' +
' "timestamp": {\n' +
' "format": "strict_date_optional_time",\n' +
' "gte" : "' + R3.API.Query.QUERY_START + '", \n' +
' "lt" : "' + R3.API.Query.QUERY_END + '"\n' +
' }\n' +
' }\n' +
' }\n' +
' ]\n' +
' }\n' +
' } \n' +
'}\n';
}
this.text = apiComponent.text;
if (R3.Utils.UndefinedOrNull(apiComponent.bucketField)) {
apiComponent.bucketField = R3.API.Query.Alerts.Buckets.BUCKET_FIELD_ALERT_TYPE;
}
this.bucketField = apiComponent.bucketField;
R3.API.Query.Alerts.call(
this,
apiComponent
);
if (R3.Utils.UndefinedOrNull(apiComponent.bucketField)) {
apiComponent.bucketField = null;
}
this.bucketField = apiComponent.bucketField;
this.text = '{\
"version": false,\
"size": ' + R3.API.Query.QUERY_SIZE + ',\
"sort": [\
{\
"priority": {\
"order": "asc"\
},\
"acknowledged": {\
"order": "asc"\
},\
"' + R3.API.Query.QUERY_BUCKET_FIELD + '": {\
"order": "asc"\
}\
}\
],\
"_source": {\
"includes": ["*"]\
},\
"aggs": {\
"descriptions": {\
"terms" : { "field" : "' + R3.API.Query.QUERY_BUCKET_FIELD + '" },\
"aggs": {\
"priorities": {\
"histogram": {\
"field": "priority",\
"interval": "1",\
"min_doc_count": 0\
}\
}\
}\
}\
},\
"query": {\
"bool": {\
"must": [\
{\
"range": {\
"timestamp": {\
"format": "strict_date_optional_time",\
"gte" : "' + R3.API.Query.QUERY_START + '",\
"lt" : "' + R3.API.Query.QUERY_END + '"\
}\
}\
}\
]\
}\
}\
}';
};
R3.API.Query.Alerts.Buckets.prototype = Object.create(R3.API.Query.Alerts.prototype);
R3.API.Query.Alerts.Buckets.prototype.constructor = R3.API.Query.Alerts.Buckets;
R3.API.Query.Alerts.Buckets.BUCKET_FIELD_ALERT_TYPE = 'alert_type.keyword';
R3.API.Query.Alerts.Buckets.BUCKET_FIELD_COUNTRY = 'geo.country.keyword';
R3.API.Query.Alerts.Buckets.BUCKET_FIELD_HOSTNAME = 'device.hostname.keyword';
R3.API.Query.Alerts.Buckets.BUCKET_FIELD_IP_V4 = 'device.ip_v4.keyword';
R3.API.Query.Alerts.Buckets.BUCKET_FIELD_USERNAME = 'login.username.keyword';

View File

@ -0,0 +1,67 @@
/**
* R3.API.Query.Alerts.FirstTimeLogin
* @param apiComponent
* @constructor
*/
R3.API.Query.Alerts.FirstTimeLogin = function(
apiComponent
) {
__DEFINE_API_COMPONENT__
if (R3.Utils.UndefinedOrNull(apiComponent.loginType)) {
apiComponent.loginType = R3.API.Query.LOGIN_TYPE_ALL;
}
this.loginType = apiComponent.loginType;
if (R3.Utils.UndefinedOrNull(apiComponent.text)) {
apiComponent.text = '{\n' +
' "version": false,\n' +
' "size": ' + R3.API.Query.QUERY_SIZE + ',\n' +
' "sort": [\n' +
' {\n' +
' "login.destination_ip.keyword": {\n' +
' "order": "asc"\n' +
' }\n' +
' }\n' +
' ],\n' +
' "_source": {\n' +
' "includes": ["*"]\n' +
' },\n' +
' "query": {\n' +
' "bool": {\n' +
' "must": [\n' +
' {\n' +
' "range": {\n' +
' "timestamp": {\n' +
' "format": "strict_date_optional_time",\n' +
' "gte" : "' + R3.API.Query.QUERY_START + '",\n' +
' "lt" : "' + R3.API.Query.QUERY_END + '"\n' +
' }\n' +
' }\n' +
' },\n' +
' {\n' +
' "term" : { "acknowledged": "false" }\n' +
' },\n' +
' {\n' +
' "term" : { "alert_type.keyword": "First Time Login" }\n' +
' },\n' +
' {\n' +
' "regexp" : { "login.login_type.keyword": "' + R3.API.Query.QUERY_LOGIN_TYPE + '" }\n' +
' }\n' +
' ]\n' +
' }\n' +
' }\n' +
'}';
}
this.text = apiComponent.text;
R3.API.Query.Alerts.call(
this,
apiComponent
);
};
R3.API.Query.Alerts.FirstTimeLogin.prototype = Object.create(R3.API.Query.Alerts.prototype);
R3.API.Query.Alerts.FirstTimeLogin.prototype.constructor = R3.API.Query.Alerts.FirstTimeLogin;

View File

@ -0,0 +1,27 @@
/**
* R3.API.Query.Alerts.FirstTimeLogin.Applications
* @param apiComponent
* @constructor
*/
R3.API.Query.Alerts.FirstTimeLogin.Applications = function(
apiComponent
) {
__DEFINE_API_COMPONENT__;
/**
* Override the loginType
*/
if (R3.Utils.UndefinedOrNull(apiComponent.loginType)) {
apiComponent.loginType = R3.API.Query.LOGIN_TYPE_APPLICATION;
}
R3.API.Query.Alerts.FirstTimeLogin.call(
this,
apiComponent
);
};
R3.API.Query.Alerts.FirstTimeLogin.Applications.prototype = Object.create(R3.API.Query.Alerts.FirstTimeLogin.prototype);
R3.API.Query.Alerts.FirstTimeLogin.Applications.prototype.constructor = R3.API.Query.Alerts.FirstTimeLogin.Applications;

View File

@ -0,0 +1,27 @@
/**
* R3.API.Query.Alerts.FirstTimeLogin.Devices
* @param apiComponent
* @constructor
*/
R3.API.Query.Alerts.FirstTimeLogin.Devices = function(
apiComponent
) {
__DEFINE_API_COMPONENT__;
/**
* Override the loginType
*/
if (R3.Utils.UndefinedOrNull(apiComponent.loginType)) {
apiComponent.loginType = R3.API.Query.LOGIN_TYPE_DEVICE;
}
R3.API.Query.Alerts.FirstTimeLogin.call(
this,
apiComponent
);
};
R3.API.Query.Alerts.FirstTimeLogin.Devices.prototype = Object.create(R3.API.Query.Alerts.FirstTimeLogin.prototype);
R3.API.Query.Alerts.FirstTimeLogin.Devices.prototype.constructor = R3.API.Query.Alerts.FirstTimeLogin.Devices;

View File

@ -0,0 +1,27 @@
/**
* R3.API.Query.Alerts.FirstTimeLogin.VPN
* @param apiComponent
* @constructor
*/
R3.API.Query.Alerts.FirstTimeLogin.VPN = function(
apiComponent
) {
__DEFINE_API_COMPONENT__;
/**
* Override the loginType
*/
if (R3.Utils.UndefinedOrNull(apiComponent.loginType)) {
apiComponent.loginType = R3.API.Query.LOGIN_TYPE_VPN;
}
R3.API.Query.Alerts.FirstTimeLogin.call(
this,
apiComponent
);
};
R3.API.Query.Alerts.FirstTimeLogin.VPN.prototype = Object.create(R3.API.Query.Alerts.FirstTimeLogin.prototype);
R3.API.Query.Alerts.FirstTimeLogin.VPN.prototype.constructor = R3.API.Query.Alerts.FirstTimeLogin.VPN;

View File

@ -7,55 +7,73 @@ R3.API.Query.Alerts.List = function(
apiComponent
) {
R3.API.Query.Alerts.call(
this,
apiComponent
);
__DEFINE_API_COMPONENT__
/**
* Override default size
*/
if (R3.Utils.UndefinedOrNull(apiComponent)) {
apiComponent = {
size : 100
};
}
if (R3.Utils.UndefinedOrNull(apiComponent.size)) {
apiComponent.size = 100;
}
this.size = apiComponent.size;
this.text = '{\
"version": false,\
"size": ' + R3.API.Query.QUERY_SIZE + ',\
"sort": [\
{\
"timestamp": {\
"order": "desc",\
"unmapped_type": "boolean"\
}\
}\
],\
"_source": {\
"includes": ["*"]\
},\
"aggs": {\
"priorities": {\
"histogram": {\
"field": "priority",\
"interval": "1",\
"min_doc_count": 0\
}\
}\
},\
"query": {\
"bool": {\
"must": [\
{\
"range": {\
"timestamp": {\
"format": "strict_date_optional_time",\
"gte": "' + R3.API.Query.QUERY_START + '",\
"lt": "' + R3.API.Query.QUERY_END + '"\
}\
}\
}\
]\
}\
}\
}';
if (R3.Utils.UndefinedOrNull(apiComponent.columns)) {
apiComponent.columns = [];
}
this.columns = apiComponent.columns;
if (R3.Utils.UndefinedOrNull(apiComponent.rows)) {
apiComponent.rows = [];
}
this.rows = apiComponent.rows;
if (R3.Utils.UndefinedOrNull(apiComponent.text)) {
apiComponent.text = '{\n' +
' "version": false,\n' +
' "size": ' + R3.API.Query.QUERY_SIZE + ',\n' +
' "sort": [\n' +
' {\n' +
' "priority": {\n' +
' "order": "asc",\n' +
' "unmapped_type": "boolean"\n' +
' },\n' +
' "alert_type.keyword": {\n' +
' "order": "asc",\n' +
' "unmapped_type": "boolean"\n' +
' }\n' +
' }\n' +
' ],\n' +
' "_source": {\n' +
' "includes": ["*"]\n' +
' },\n' +
' "query": {\n' +
' "bool": {\n' +
' "must": [\n' +
' {\n' +
' "range": {\n' +
' "timestamp": {\n' +
' "format": "strict_date_optional_time",\n' +
' "gte": "' + R3.API.Query.QUERY_START + '",\n' +
' "lt": "' + R3.API.Query.QUERY_END + '"\n' +
' }\n' +
' }\n' +
' }\n' +
' ]\n' +
' }\n' +
' }\n' +
'}';
}
this.text = apiComponent.text;
R3.API.Query.Alerts.call(
this,
apiComponent
);
};
R3.API.Query.Alerts.List.prototype = Object.create(R3.API.Query.Alerts.prototype);

View File

@ -1,56 +1,70 @@
/**
* R3.API.Query.Alerts.Summary
* @param apiComponent
*
* @priorities
*
* @constructor
*/
R3.API.Query.Alerts.Summary = function(
apiComponent
) {
__DEFINE_API_COMPONENT__
if (R3.Utils.UndefinedOrNull(apiComponent.priorities)) {
apiComponent.priorities = [];
}
this.priorities = apiComponent.priorities;
if (R3.Utils.UndefinedOrNull(apiComponent.text)) {
apiComponent.text = '{\n' +
' "version": false,\n' +
' "size": ' + R3.API.Query.QUERY_SIZE + ',\n' +
' "sort": [\n' +
' {\n' +
' "timestamp": {\n' +
' "order": "desc",\n' +
' "unmapped_type": "boolean"\n' +
' }\n' +
' }\n' +
' ],\n' +
' "_source": {\n' +
' "includes": ["*"]\n' +
' },\n' +
' "aggs": {\n' +
' "priorities": {\n' +
' "histogram": {\n' +
' "field": "priority",\n' +
' "interval": "1",\n' +
' "min_doc_count": 0\n' +
' }\n' +
' }\n' +
' },\n' +
' "query": {\n' +
' "bool": {\n' +
' "must": [\n' +
' {\n' +
' "range": {\n' +
' "timestamp": {\n' +
' "format": "strict_date_optional_time",\n' +
' "gte": "' + R3.API.Query.QUERY_START + '",\n' +
' "lt": "' + R3.API.Query.QUERY_END + '"\n' +
' }\n' +
' }\n' +
' }\n' +
' ]\n' +
' }\n' +
' }\n' +
'}\n';
}
this.text = apiComponent.text;
R3.API.Query.Alerts.call(
this,
apiComponent
);
this.text = '{\
"version": false,\
"size": ' + R3.API.Query.QUERY_SIZE + ',\
"sort": [\
{\
"timestamp": {\
"order": "desc",\
"unmapped_type": "boolean"\
}\
}\
],\
"_source": {\
"includes": ["*"]\
},\
"aggs": {\
"priorities": {\
"histogram": {\
"field": "priority",\
"interval": "1",\
"min_doc_count": 0\
}\
}\
},\
"query": {\
"bool": {\
"must": [\
{\
"range": {\
"timestamp": {\
"format": "strict_date_optional_time",\
"gte": "' + R3.API.Query.QUERY_START + '",\
"lt": "' + R3.API.Query.QUERY_END + '"\
}\
}\
}\
]\
}\
}\
}';
};
R3.API.Query.Alerts.Summary.prototype = Object.create(R3.API.Query.Alerts.prototype);

View File

@ -7,61 +7,66 @@ R3.API.Query.Alerts.Timeseries = function(
apiComponent
) {
__DEFINE_API_COMPONENT__
if (R3.Utils.UndefinedOrNull(apiComponent.text)) {
apiComponent.text = '{\n' +
' "version": false,\n' +
' "size": ' + R3.API.Query.QUERY_SIZE + ',\n' +
' "sort": [\n' +
' {\n' +
' "timestamp": {\n' +
' "order": "desc",\n' +
' "unmapped_type": "boolean"\n' +
' }\n' +
' }\n' +
' ],\n' +
' "_source": {\n' +
' "includes": ["*"]\n' +
' },\n' +
' "aggs": {\n' +
' "mins": {\n' +
' "date_histogram": {\n' +
' "field": "timestamp",\n' +
' "calendar_interval": "1d",\n' +
' "time_zone": "' + R3.API.Query.QUERY_TIMEZONE + '",\n' +
' "min_doc_count": 0,\n' +
' "format" : "yyyy-MM-dd"\n' +
' },\n' +
' "aggs": {\n' +
' "priorities": {\n' +
' "histogram": {\n' +
' "field": "priority",\n' +
' "interval": "1",\n' +
' "min_doc_count": 0\n' +
' }\n' +
' }\n' +
' }\n' +
' }\n' +
' },\n' +
' "query": {\n' +
' "bool": {\n' +
' "must": [\n' +
' {\n' +
' "range": {\n' +
' "timestamp": {\n' +
' "format": "strict_date_optional_time",\n' +
' "gte" : "' + R3.API.Query.QUERY_START + '",\n' +
' "lt" : "' + R3.API.Query.QUERY_END + '"\n' +
' }\n' +
' }\n' +
' }\n' +
' ]\n' +
' }\n' +
' }\n' +
'}\n';
}
this.text = apiComponent.text;
R3.API.Query.Alerts.call(
this,
apiComponent
);
this.text = '{\
"version": false,\
"size": ' + R3.API.Query.QUERY_SIZE + ',\
"sort": [\
{\
"timestamp": {\
"order": "desc",\
"unmapped_type": "boolean"\
}\
}\
],\
"_source": {\
"includes": ["*"]\
},\
"aggs": {\
"mins": {\
"date_histogram": {\
"field": "timestamp",\
"calendar_interval": "1d",\
"time_zone": "' + R3.API.Query.QUERY_TIMEZONE + '",\
"min_doc_count": 0,\
"format" : "yyyy-MM-dd"\
},\
"aggs": {\
"priorities": {\
"histogram": {\
"field": "priority",\
"interval": "1",\
"min_doc_count": 0\
}\
}\
}\
}\
},\
"query": {\
"bool": {\
"must": [\
{\
"range": {\
"timestamp": {\
"format": "strict_date_optional_time",\
"gte" : "' + R3.API.Query.QUERY_START + '",\
"lt" : "' + R3.API.Query.QUERY_END + '"\
}\
}\
}\
]\
}\
}\
}';
};
R3.API.Query.Alerts.Timeseries.prototype = Object.create(R3.API.Query.Alerts.prototype);

View File

@ -0,0 +1,65 @@
/**
* R3.API.Query.Devices
* @param apiComponent
* @constructor
*/
R3.API.Query.Devices = function(
apiComponent
) {
__DEFINE_API_COMPONENT__
if (R3.Utils.UndefinedOrNull(apiComponent.path)) {
apiComponent.path = '/devices/_search';
}
this.path = apiComponent.path;
if (R3.Utils.UndefinedOrNull(apiComponent.acknowledged)) {
apiComponent.acknowledged = R3.API.Query.ACKNOWLEDGED_ALL;
}
this.acknowledged = apiComponent.acknowledged;
if (R3.Utils.UndefinedOrNull(apiComponent.text)) {
apiComponent.text = '{\n' +
' "version": false,\n' +
' "size": ' + R3.API.Query.QUERY_SIZE + ',\n' +
' "sort": [\n' +
' {\n' +
' "ip_v4.keyword": {\n' +
' "order": "asc"\n' +
' }\n' +
' }\n' +
' ],\n' +
' "_source": {\n' +
' "includes": ["*"]\n' +
' },\n' +
' "query": {\n' +
' "bool": {\n' +
' "must": [\n' +
' {\n' +
' "range": {\n' +
' "timestamp": {\n' +
' "format": "strict_date_optional_time",\n' +
' "gte" : "' + R3.API.Query.QUERY_START + '",\n' +
' "lt" : "' + R3.API.Query.QUERY_END + '"\n' +
' }\n' +
' }\n' +
' },\n' +
' {\n' +
' "term" : { "acknowledged": ' + R3.API.Query.QUERY_ACKNOWLEDGED + ' }\n' +
' }\n' +
' ]\n' +
' }\n' +
' }\n' +
'}';
}
this.text = apiComponent.text;
R3.API.Query.call(
this,
apiComponent
);
};
R3.API.Query.Devices.prototype = Object.create(R3.API.Query.prototype);
R3.API.Query.Devices.prototype.constructor = R3.API.Query.Devices;

View File

@ -0,0 +1,25 @@
/**
* R3.API.Query.Devices.Known
* @param apiComponent
* @constructor
*/
R3.API.Query.Devices.Known = function(
apiComponent
) {
__DEFINE_API_COMPONENT__
if (R3.Utils.UndefinedOrNull(apiComponent.acknowledged)) {
apiComponent.acknowledged = R3.API.Query.ACKNOWLEDGED_TRUE;
}
this.acknowledged = apiComponent.acknowledged;
R3.API.Query.Devices.call(
this,
apiComponent
);
};
R3.API.Query.Devices.Known.prototype = Object.create(R3.API.Query.Devices.prototype);
R3.API.Query.Devices.Known.prototype.constructor = R3.API.Query.Devices.Known;

View File

@ -0,0 +1,25 @@
/**
* R3.API.Query.Devices.Unknown
* @param apiComponent
* @constructor
*/
R3.API.Query.Devices.Unknown = function(
apiComponent
) {
__DEFINE_API_COMPONENT__
if (R3.Utils.UndefinedOrNull(apiComponent.acknowledged)) {
apiComponent.acknowledged = R3.API.Query.ACKNOWLEDGED_FALSE;
}
this.acknowledged = apiComponent.acknowledged;
R3.API.Query.Devices.call(
this,
apiComponent
);
};
R3.API.Query.Devices.Unknown.prototype = Object.create(R3.API.Query.Devices.prototype);
R3.API.Query.Devices.Unknown.prototype.constructor = R3.API.Query.Devices.Unknown;

View File

@ -0,0 +1,65 @@
/**
* R3.API.Query.Logins
* @param apiComponent
* @constructor
*/
R3.API.Query.Logins = function(
apiComponent
) {
__DEFINE_API_COMPONENT__
if (R3.Utils.UndefinedOrNull(apiComponent.path)) {
apiComponent.path = '/logins/_search';
}
this.path = apiComponent.path;
if (R3.Utils.UndefinedOrNull(apiComponent.loginType)) {
apiComponent.loginType = R3.API.Query.LOGIN_TYPE_ALL;
}
this.loginType = apiComponent.loginType;
if (R3.Utils.UndefinedOrNull(apiComponent.text)) {
apiComponent.text = '{\n' +
' "version": false,\n' +
' "size": ' + R3.API.Query.QUERY_SIZE + ',\n' +
' "sort": [\n' +
' {\n' +
' "timestamp": {\n' +
' "order": "asc"\n' +
' }\n' +
' }\n' +
' ],\n' +
' "_source": {\n' +
' "includes": ["*"]\n' +
' },\n' +
' "query": {\n' +
' "bool": {\n' +
' "must": [\n' +
' {\n' +
' "range": {\n' +
' "timestamp": {\n' +
' "format": "strict_date_optional_time",\n' +
' "gte" : "' + R3.API.Query.QUERY_START + '",\n' +
' "lt" : "' + R3.API.Query.QUERY_END + '"\n' +
' }\n' +
' }\n' +
' },\n' +
' {\n' +
' "regexp" : { "login_type.keyword": "(' + R3.API.Query.QUERY_LOGIN_TYPE + ')" }\n' +
' }\n' +
' ]\n' +
' }\n' +
' }\n' +
'}';
}
this.text = apiComponent.text;
R3.API.Query.call(
this,
apiComponent
);
};
R3.API.Query.Logins.prototype = Object.create(R3.API.Query.prototype);
R3.API.Query.Logins.prototype.constructor = R3.API.Query.Logins;

View File

@ -0,0 +1,27 @@
/**
* R3.API.Query.Logins.Applications
* @param apiComponent
* @constructor
*/
R3.API.Query.Logins.Applications = function(
apiComponent
) {
__DEFINE_API_COMPONENT__;
/**
* Override the loginType
*/
if (R3.Utils.UndefinedOrNull(apiComponent.loginType)) {
apiComponent.loginType = R3.API.Query.LOGIN_TYPE_APPLICATION;
}
R3.API.Query.Logins.call(
this,
apiComponent
);
};
R3.API.Query.Logins.Applications.prototype = Object.create(R3.API.Query.Logins.prototype);
R3.API.Query.Logins.Applications.prototype.constructor = R3.API.Query.Logins.Applications;

View File

@ -0,0 +1,27 @@
/**
* R3.API.Query.Logins.Devices
* @param apiComponent
* @constructor
*/
R3.API.Query.Logins.Devices = function(
apiComponent
) {
__DEFINE_API_COMPONENT__;
/**
* Override the loginType
*/
if (R3.Utils.UndefinedOrNull(apiComponent.loginType)) {
apiComponent.loginType = R3.API.Query.LOGIN_TYPE_DEVICE;
}
R3.API.Query.Logins.call(
this,
apiComponent
);
};
R3.API.Query.Logins.Devices.prototype = Object.create(R3.API.Query.Logins.prototype);
R3.API.Query.Logins.Devices.prototype.constructor = R3.API.Query.Logins.Devices;

View File

@ -0,0 +1,27 @@
/**
* R3.API.Query.Logins.VPN
* @param apiComponent
* @constructor
*/
R3.API.Query.Logins.VPN = function(
apiComponent
) {
__DEFINE_API_COMPONENT__;
/**
* Override the loginType
*/
if (R3.Utils.UndefinedOrNull(apiComponent.loginType)) {
apiComponent.loginType = R3.API.Query.LOGIN_TYPE_VPN;
}
R3.API.Query.Logins.call(
this,
apiComponent
);
};
R3.API.Query.Logins.VPN.prototype = Object.create(R3.API.Query.Logins.prototype);
R3.API.Query.Logins.VPN.prototype.constructor = R3.API.Query.Logins.VPN;

View File

@ -6,9 +6,7 @@
R3.API.Renderer = function(
apiComponent
) {
__API_COMPONENT__;
__DEFINE_API_COMPONENT__
};
R3.API.Renderer.prototype = Object.create(R3.API.Component.prototype);

View File

@ -10,20 +10,23 @@ R3.API.Renderer.D2 = function(
apiComponent
) {
R3.API.Renderer.call(
this,
apiComponent
);
__API_COMPONENT__;
if (R3.Utils.UndefinedOrNull(apiComponent.canvas)) {
apiComponent.canvas = new R3.API.Canvas(
{
parent : this
parent : this,
name : this.name + ' - Canvas'
}
);
}
this.canvas = apiComponent.canvas;
R3.API.Renderer.call(
this,
apiComponent
);
};
R3.API.Renderer.D2.prototype = Object.create(R3.API.Renderer.prototype);

View File

@ -42,10 +42,7 @@ R3.API.Renderer.D3 = function(
apiComponent
) {
R3.API.Renderer.call(
this,
apiComponent
);
__DEFINE_API_COMPONENT__
if (R3.Utils.UndefinedOrNull(apiComponent.autoClear)) {
apiComponent.autoClear = true;
@ -117,16 +114,6 @@ R3.API.Renderer.D3 = function(
}
this.shadowMapType = apiComponent.shadowMapType;
if (R3.Utils.UndefinedOrNull(apiComponent.shadowMapRenderReverseSided)) {
apiComponent.shadowMapRenderReverseSided = true;
}
this.shadowMapRenderReverseSided = apiComponent.shadowMapRenderReverseSided;
if (R3.Utils.UndefinedOrNull(apiComponent.shadowMapRenderSingleSided)) {
apiComponent.shadowMapRenderSingleSided = true;
}
this.shadowMapRenderSingleSided = apiComponent.shadowMapRenderSingleSided;
if (R3.Utils.UndefinedOrNull(apiComponent.sortObjects)) {
apiComponent.sortObjects = true;
}
@ -191,6 +178,8 @@ R3.API.Renderer.D3 = function(
apiComponent.clearColor = new R3.API.Color(
{
parent : this,
register : true,
name : this.name + ' - Clear Color',
r : 0.11,
g : 0.11,
b : 0.11
@ -201,9 +190,10 @@ R3.API.Renderer.D3 = function(
if (R3.Utils.UndefinedOrNull(apiComponent.viewports)) {
apiComponent.viewports = [
new R3.D3.API.Viewport(
new R3.D3.API.Viewport.FixedAspect(
{
parent : this
parent : this,
name : this.name + ' - Fixed Aspect Viewport'
}
)
];
@ -225,6 +215,11 @@ R3.API.Renderer.D3 = function(
}
this.pixelRatio = apiComponent.pixelRatio;
R3.API.Renderer.call(
this,
apiComponent
);
};
R3.API.Renderer.D3.prototype = Object.create(R3.API.Renderer.prototype);

View File

@ -10,20 +10,23 @@ R3.API.Renderer.D3.Canvas = function(
apiComponent
) {
R3.API.Renderer.D3.call(
this,
apiComponent
);
__API_COMPONENT__;
if (R3.Utils.UndefinedOrNull(apiComponent.canvas)) {
apiComponent.canvas = new R3.API.Canvas(
{
parent : this
parent : this,
name : this.name + ' - Canvas'
}
);
}
this.canvas = apiComponent.canvas;
R3.API.Renderer.D3.call(
this,
apiComponent
);
};
R3.API.Renderer.D3.Canvas.prototype = Object.create(R3.API.Renderer.D3.prototype);

View File

@ -24,27 +24,7 @@ R3.Canvas.prototype.constructor = R3.Canvas;
*/
R3.Canvas.prototype.createInstance = function() {
this.instance = document.createElement('canvas');
this.instance.setAttribute('id', this.id);
this.instance.setAttribute('tabindex', this.tabIndex);
this.instance.setAttribute('style', 'left: ' + this.offset.x + 'px;top: ' + this.offset.y + 'px');
if (this.autoUpdateSize) {
/**
* Update our size from the instance size
*/
this.width = this.instance.width;
this.height = this.instance.height;
} else {
/**
* Update our instance with our size
*/
this.instance.width = this.width;
this.instance.height = this.height;
}
this.instance = this.graphics.Canvas(this);
__CREATE_INSTANCE__;
};

View File

@ -40,14 +40,4 @@ R3.Clock.prototype.getDelta = function() {
return this.instance.getDelta();
/**
* clamp the delta to 1/60
*/
// if (delta > (1 / 30.0)) {
// console.warn('clipping delta - todo: do we still need this?');
// // console.log('clipped ' + (delta - (1/30.0)) + ' seconds - essentially lost time');
// delta = (1 / 30.0);
// }
//return delta;
};

View File

@ -2,7 +2,13 @@
* R3.Controls
* @constructor
*/
R3.Controls = function() {
R3.Controls = function(
inherited
) {
__INHERIT_ONLY__
this.linkedComponents.canvas = R3.Canvas;
__UPGRADE_TO_RUNTIME__;

View File

@ -2,9 +2,18 @@
* R3.Controls.D3
* @constructor
*/
R3.Controls.D3 = function() {
R3.Controls.D3 = function(
inherited
) {
R3.Controls.call(this);
__INHERIT_ONLY__
this.linkedComponents.camera = R3.D3.Camera;
R3.Controls.call(
this,
true
);
};
@ -18,6 +27,11 @@ R3.Controls.D3.prototype.updateInstance = function(property) {
return;
}
if (property === 'enabled') {
this.instance.enabled = this.enabled;
return;
}
R3.Controls.prototype.updateInstance.call(this, property);
};

View File

@ -9,7 +9,10 @@ R3.Controls.D3.FirstPerson = function(
__RUNTIME_COMPONENT__;
R3.Controls.D3.call(this);
R3.Controls.D3.call(
this,
true
);
};
@ -25,24 +28,7 @@ R3.Controls.D3.FirstPerson.prototype.constructor = R3.Controls.D3.FirstPerson;
*/
R3.Controls.D3.FirstPerson.prototype.createInstance = function() {
this.instance = this.graphics.FirstPersonControls(
this.canvas,
this.camera,
this.enabled,
this.movementSpeed,
this.lookSpeed,
this.lookVertical,
this.autoForward,
this.activeLook,
this.heightSpeed,
this.heightCoef,
this.heightMin,
this.heightMax,
this.constrainVertical,
this.verticalMin,
this.verticalMax,
this.autoSpeedFactor
);
this.instance = this.graphics.FirstPersonControls(this);
__CREATE_INSTANCE__;
};
@ -52,11 +38,6 @@ R3.Controls.D3.FirstPerson.prototype.createInstance = function() {
*/
R3.Controls.D3.FirstPerson.prototype.updateInstance = function(property) {
if (property === 'enabled') {
this.instance.enabled = this.enabled;
return;
}
if (property === 'movementSpeed') {
this.instance.movementSpeed = this.movementSpeed;
return;

View File

@ -9,7 +9,12 @@ R3.Controls.D3.Orbit = function(
__RUNTIME_COMPONENT__;
R3.Controls.D3.call(this);
this.linkedComponents.target = R3.D3.Object;
R3.Controls.D3.call(
this,
true
);
};
@ -21,25 +26,7 @@ R3.Controls.D3.Orbit.prototype.constructor = R3.Controls.D3.Orbit;
*/
R3.Controls.D3.Orbit.prototype.createInstance = function() {
this.instance = this.graphics.OrbitControls(
this.canvas,
this.camera,
this.target,
this.enabled,
this.minPolarAngle,
this.maxPolarAngle,
this.enableDamping,
this.dampingFactor,
this.enableZoom,
this.zoomSpeed,
this.enableRotate,
this.rotateSpeed,
this.enablePan,
this.keyPanSpeed,
this.autoRotate,
this.autoRotateSpeed,
this.enableKeys
);
this.instance = this.graphics.OrbitControls(this);
__CREATE_INSTANCE__;
};
@ -59,11 +46,6 @@ R3.Controls.D3.Orbit.prototype.updateInstance = function(property) {
return;
}
if (property === 'enabled') {
this.instance.enabled = this.enabled;
return;
}
if (property === 'minPolarAngle') {
this.instance.minPolarAngle = this.minPolarAngle;
return;

View File

@ -10,7 +10,8 @@ R3.Controls.Keyboard = function(
__RUNTIME_COMPONENT__;
R3.Controls.call(
this
this,
true
);
};

View File

@ -10,7 +10,8 @@ R3.Controls.Mouse = function(
__RUNTIME_COMPONENT__;
R3.Controls.call(
this
this,
true
);
};

View File

@ -10,7 +10,8 @@ R3.Controls.Touch = function(
__RUNTIME_COMPONENT__;
R3.Controls.call(
this
this,
true
);
};

View File

@ -23,7 +23,7 @@ R3.Curve.Path.D2.Shape = function(
}
/**
* Now we call the parent class but with linkedObjects - indicating that its being called from a child class
* Now we call the parent class but with linkedComponents - indicating that its being called from a child class
* and should not do any runtime instantiation
*/
R3.Curve.Path.D2.call(

View File

@ -16,7 +16,7 @@ R3.D3.API.Object = function(
apiComponent
) {
__API_COMPONENT__;
__DEFINE_API_COMPONENT__
if (R3.Utils.UndefinedOrNull(apiComponent.useQuaternion)) {
apiComponent.useQuaternion = false;
@ -27,6 +27,7 @@ R3.D3.API.Object = function(
apiComponent.position = new R3.API.Vector3(
{
parent : this,
name : this.name + ' - Position',
register : true
}
);
@ -37,6 +38,7 @@ R3.D3.API.Object = function(
apiComponent.quaternion = new R3.API.Quaternion(
{
parent : this,
name : this.name + ' - Quaternion',
register : true
}
);
@ -47,6 +49,7 @@ R3.D3.API.Object = function(
apiComponent.rotation = new R3.API.Vector3(
{
parent : this,
name : this.name + ' - Rotation',
register : true
}
);
@ -58,6 +61,7 @@ R3.D3.API.Object = function(
{
parent : this,
register : true,
name : this.name + ' - Scale',
x : 1,
y : 1,
z : 1
@ -71,6 +75,7 @@ R3.D3.API.Object = function(
{
parent : this,
register : true,
name : this.name + ' - Up',
x : 0,
y : 1,
z : 0
@ -83,6 +88,7 @@ R3.D3.API.Object = function(
apiComponent.lookAt = new R3.API.Vector3(
{
parent : this,
name : this.name + ' - LookAt',
register : true
}
);

View File

@ -17,11 +17,12 @@ R3.D3.API.Camera.Cube = function(
apiComponent
) {
R3.D3.API.Camera.call(
this,
apiComponent
);
__API_COMPONENT__;
/**
* Following two properties are hardcoded for Cube Cameras
* @type {number}
*/
this.aspect = 1;
this.fov = 90;
@ -44,12 +45,18 @@ R3.D3.API.Camera.Cube = function(
if (R3.Utils.UndefinedOrNull(apiComponent.renderTarget)) {
apiComponent.renderTarget = new R3.D3.API.RenderTarget.Cube(
{
parent : this
parent : this,
name : this.name + ' - Cube RenderTarget'
}
);
}
this.renderTarget = apiComponent.renderTarget;
R3.D3.API.Camera.call(
this,
apiComponent
);
};
R3.D3.API.Camera.Cube.prototype = Object.create(R3.D3.API.Camera.prototype);

View File

@ -16,9 +16,10 @@ R3.D3.API.Camera.Orthographic = function(
apiComponent
) {
if (R3.Utils.UndefinedOrNull(apiComponent)) {
apiComponent = {};
}
/**
* Override the lookAt vector for Orthographic cameras
*/
__DEFINE_API_COMPONENT__
if (R3.Utils.UndefinedOrNull(apiComponent.lookAt)) {
apiComponent.lookAt = new R3.API.Vector3(
@ -31,11 +32,7 @@ R3.D3.API.Camera.Orthographic = function(
}
);
}
R3.D3.API.Camera.call(
this,
apiComponent
);
this.lookAt = apiComponent.lookAt;
if (R3.Utils.UndefinedOrNull(apiComponent.near)) {
apiComponent.near = 0.1;
@ -52,6 +49,11 @@ R3.D3.API.Camera.Orthographic = function(
}
this.zoom = apiComponent.zoom;
R3.D3.API.Camera.call(
this,
apiComponent
);
};
R3.D3.API.Camera.Orthographic.prototype = Object.create(R3.D3.API.Camera.prototype);

View File

@ -11,6 +11,8 @@ R3.D3.API.Camera.Orthographic.FixedAspect = function(
apiComponent
) {
__API_COMPONENT__;
R3.D3.API.Camera.Orthographic.call(
this,
apiComponent

View File

@ -18,10 +18,7 @@ R3.D3.API.Camera.Orthographic.ScaledAspect = function(
apiComponent
) {
R3.D3.API.Camera.Orthographic.call(
this,
apiComponent
);
__API_COMPONENT__;
if (R3.Utils.UndefinedOrNull(apiComponent.left)) {
apiComponent.left = -5;
@ -43,6 +40,11 @@ R3.D3.API.Camera.Orthographic.ScaledAspect = function(
}
this.bottom = apiComponent.bottom;
R3.D3.API.Camera.Orthographic.call(
this,
apiComponent
);
};
R3.D3.API.Camera.Orthographic.ScaledAspect.prototype = Object.create(R3.D3.API.Camera.Orthographic.prototype);

View File

@ -16,26 +16,24 @@ R3.D3.API.Camera.Perspective = function(
apiComponent
) {
if (R3.Utils.UndefinedOrNull(apiComponent)) {
apiComponent = {};
}
/**
* Override the position for Perspective cameras
*/
__API_COMPONENT__
if (R3.Utils.UndefinedOrNull(apiComponent.position)) {
apiComponent.position = new R3.API.Vector3(
{
parent : this,
register :true,
name : this.name + ' - Position',
x : 15,
y : 15,
z : 15
}
);
}
R3.D3.API.Camera.call(
this,
apiComponent
);
this.position = apiComponent.position;
if (R3.Utils.UndefinedOrNull(apiComponent.near)) {
apiComponent.near = 0.1;
@ -72,6 +70,10 @@ R3.D3.API.Camera.Perspective = function(
}
this.zoom = apiComponent.zoom;
R3.D3.API.Camera.call(
this,
apiComponent
);
};
R3.D3.API.Camera.Perspective.prototype = Object.create(R3.D3.API.Camera.prototype);

View File

@ -7,6 +7,8 @@ R3.D3.API.Camera.Perspective.Stereo = function(
apiComponent
) {
__DEFINE_API_COMPONENT__;
R3.D3.API.Camera.Perspective.call(
this,
apiComponent

View File

@ -17,6 +17,7 @@ R3.D3.API.Fog = function(
{
parent : this,
register : true,
name : this.name + ' - Color',
r : 1,
g : 1,
b : 1,

View File

@ -1,5 +1,5 @@
/**
* R3.D3.API.Particle
* R3.D3.API.Mesh.Particle
* @param apiComponent
* @param lifeTime
* @param elapsed
@ -25,30 +25,8 @@
* @param rotationFn
* @constructor
*/
R3.D3.API.Particle = function(
apiComponent,
lifeTime,
elapsed,
mesh,
opacityType,
fadeInFactor,
fadeOutFactor,
fadeInAfter,
fadeOutAfter,
positionOffsetType,
positionOffset,
positionOffsetFn,
directionType,
direction,
directionFn,
speedType,
speed,
scaleType,
scale,
scaleFn,
rotationType,
rotation,
rotationFn
R3.D3.API.Mesh.Particle = function(
apiComponent
) {
__API_COMPONENT__;
@ -69,7 +47,7 @@ R3.D3.API.Particle = function(
this.mesh = apiComponent.mesh;
if (R3.Utils.UndefinedOrNull(apiComponent.opacityType)) {
apiComponent.opacityType = R3.D3.API.Particle.OPACITY_TYPE_CONSTANT;
apiComponent.opacityType = R3.D3.API.Mesh.Particle.OPACITY_TYPE_CONSTANT;
}
this.opacityType = apiComponent.opacityType;
@ -94,7 +72,7 @@ R3.D3.API.Particle = function(
this.fadeOutAfter = apiComponent.fadeOutAfter;
if (R3.Utils.UndefinedOrNull(apiComponent.positionOffsetType)) {
apiComponent.positionOffsetType = R3.D3.API.Particle.POSITION_OFFSET_TYPE_CONSTANT;
apiComponent.positionOffsetType = R3.D3.API.Mesh.Particle.POSITION_OFFSET_TYPE_CONSTANT;
}
this.positionOffsetType = apiComponent.positionOffsetType;
@ -109,7 +87,7 @@ R3.D3.API.Particle = function(
this.positionOffsetFn = apiComponent.positionOffsetFn;
if (R3.Utils.UndefinedOrNull(apiComponent.directionType)) {
apiComponent.directionType = R3.D3.API.Particle.DIRECTION_TYPE_CONSTANT;
apiComponent.directionType = R3.D3.API.Mesh.Particle.DIRECTION_TYPE_CONSTANT;
}
this.directionType = apiComponent.directionType;
@ -124,7 +102,7 @@ R3.D3.API.Particle = function(
this.directionFn = apiComponent.directionFn;
if (R3.Utils.UndefinedOrNull(apiComponent.speedType)) {
apiComponent.speedType = R3.D3.API.Particle.SPEED_TYPE_CONSTANT;
apiComponent.speedType = R3.D3.API.Mesh.Particle.SPEED_TYPE_CONSTANT;
}
this.speedType = apiComponent.speedType;
@ -134,7 +112,7 @@ R3.D3.API.Particle = function(
this.speed = apiComponent.speed;
if (R3.Utils.UndefinedOrNull(apiComponent.scaleType)) {
apiComponent.scaleType = R3.D3.API.Particle.SCALE_TYPE_CONSTANT;
apiComponent.scaleType = R3.D3.API.Mesh.Particle.SCALE_TYPE_CONSTANT;
}
this.scaleType = apiComponent.scaleType;
@ -149,7 +127,7 @@ R3.D3.API.Particle = function(
this.scaleFn = apiComponent.scaleFn;
if (R3.Utils.UndefinedOrNull(apiComponent.rotationType)) {
apiComponent.rotationType = R3.D3.API.Particle.ROTATION_TYPE_CONSTANT;
apiComponent.rotationType = R3.D3.API.Mesh.Particle.ROTATION_TYPE_CONSTANT;
}
this.rotationType = apiComponent.rotationType;
@ -164,41 +142,41 @@ R3.D3.API.Particle = function(
this.rotationFn = apiComponent.rotationFn;
};
R3.D3.API.Particle.prototype = Object.create(R3.API.Component.prototype);
R3.D3.API.Particle.prototype.constructor = R3.D3.API.Particle;
R3.D3.API.Mesh.Particle.prototype = Object.create(R3.API.Component.prototype);
R3.D3.API.Mesh.Particle.prototype.constructor = R3.D3.API.Mesh.Particle;
R3.D3.API.Particle.OPACITY_TYPE_CONSTANT = 0x1;
R3.D3.API.Particle.OPACITY_TYPE_FADE_OUT_LINEAR = 0x2;
R3.D3.API.Particle.OPACITY_TYPE_FADE_IN_LINEAR = 0x3;
R3.D3.API.Particle.OPACITY_TYPE_FADE_IN_OUT_LINEAR = 0x4;
R3.D3.API.Mesh.Particle.OPACITY_TYPE_CONSTANT = 0x1;
R3.D3.API.Mesh.Particle.OPACITY_TYPE_FADE_OUT_LINEAR = 0x2;
R3.D3.API.Mesh.Particle.OPACITY_TYPE_FADE_IN_LINEAR = 0x3;
R3.D3.API.Mesh.Particle.OPACITY_TYPE_FADE_IN_OUT_LINEAR = 0x4;
R3.D3.API.Particle.POSITION_OFFSET_TYPE_CONSTANT = 0x1;
R3.D3.API.Particle.POSITION_OFFSET_TYPE_RANDOM = 0x2;
R3.D3.API.Particle.POSITION_OFFSET_TYPE_FUNCTION = 0x3;
R3.D3.API.Mesh.Particle.POSITION_OFFSET_TYPE_CONSTANT = 0x1;
R3.D3.API.Mesh.Particle.POSITION_OFFSET_TYPE_RANDOM = 0x2;
R3.D3.API.Mesh.Particle.POSITION_OFFSET_TYPE_FUNCTION = 0x3;
R3.D3.API.Particle.DIRECTION_TYPE_CONSTANT = 0x1;
R3.D3.API.Particle.DIRECTION_TYPE_RANDOM = 0x2;
R3.D3.API.Particle.DIRECTION_TYPE_RANDOM_NORMALIZED = 0x3;
R3.D3.API.Particle.DIRECTION_TYPE_FUNCTION = 0x4;
R3.D3.API.Mesh.Particle.DIRECTION_TYPE_CONSTANT = 0x1;
R3.D3.API.Mesh.Particle.DIRECTION_TYPE_RANDOM = 0x2;
R3.D3.API.Mesh.Particle.DIRECTION_TYPE_RANDOM_NORMALIZED = 0x3;
R3.D3.API.Mesh.Particle.DIRECTION_TYPE_FUNCTION = 0x4;
R3.D3.API.Particle.SCALE_TYPE_CONSTANT = 0x1;
R3.D3.API.Particle.SCALE_TYPE_LINEAR = 0x2;
R3.D3.API.Particle.SCALE_TYPE_EXPONENTIAL = 0x3;
R3.D3.API.Particle.SCALE_TYPE_RANDOM = 0x4;
R3.D3.API.Particle.SCALE_TYPE_RANDOM_X_EQUALS_Y = 0x6;
R3.D3.API.Particle.SCALE_TYPE_FUNCTION = 0x7;
R3.D3.API.Mesh.Particle.SCALE_TYPE_CONSTANT = 0x1;
R3.D3.API.Mesh.Particle.SCALE_TYPE_LINEAR = 0x2;
R3.D3.API.Mesh.Particle.SCALE_TYPE_EXPONENTIAL = 0x3;
R3.D3.API.Mesh.Particle.SCALE_TYPE_RANDOM = 0x4;
R3.D3.API.Mesh.Particle.SCALE_TYPE_RANDOM_X_EQUALS_Y = 0x6;
R3.D3.API.Mesh.Particle.SCALE_TYPE_FUNCTION = 0x7;
R3.D3.API.Particle.SPEED_TYPE_CONSTANT = 0x1;
R3.D3.API.Particle.SPEED_TYPE_LINEAR = 0x2;
R3.D3.API.Particle.SPEED_TYPE_EXPONENTIAL = 0x3;
R3.D3.API.Particle.SPEED_TYPE_LOGARITHMIC = 0x4;
R3.D3.API.Particle.SPEED_TYPE_ONE_OVER_LOG = 0x5;
R3.D3.API.Particle.SPEED_TYPE_EXP = 0x6;
R3.D3.API.Particle.SPEED_TYPE_ONE_OVER_EXP = 0x7;
R3.D3.API.Mesh.Particle.SPEED_TYPE_CONSTANT = 0x1;
R3.D3.API.Mesh.Particle.SPEED_TYPE_LINEAR = 0x2;
R3.D3.API.Mesh.Particle.SPEED_TYPE_EXPONENTIAL = 0x3;
R3.D3.API.Mesh.Particle.SPEED_TYPE_LOGARITHMIC = 0x4;
R3.D3.API.Mesh.Particle.SPEED_TYPE_ONE_OVER_LOG = 0x5;
R3.D3.API.Mesh.Particle.SPEED_TYPE_EXP = 0x6;
R3.D3.API.Mesh.Particle.SPEED_TYPE_ONE_OVER_EXP = 0x7;
R3.D3.API.Particle.ROTATION_TYPE_CONSTANT = 0x1;
R3.D3.API.Particle.ROTATION_TYPE_RANDOM = 0x2;
R3.D3.API.Particle.ROTATION_TYPE_RANDOM_X = 0x3;
R3.D3.API.Particle.ROTATION_TYPE_RANDOM_Y = 0x4;
R3.D3.API.Particle.ROTATION_TYPE_RANDOM_Z = 0x5;
R3.D3.API.Particle.ROTATION_TYPE_FUNCTION = 0x6;
R3.D3.API.Mesh.Particle.ROTATION_TYPE_CONSTANT = 0x1;
R3.D3.API.Mesh.Particle.ROTATION_TYPE_RANDOM = 0x2;
R3.D3.API.Mesh.Particle.ROTATION_TYPE_RANDOM_X = 0x3;
R3.D3.API.Mesh.Particle.ROTATION_TYPE_RANDOM_Y = 0x4;
R3.D3.API.Mesh.Particle.ROTATION_TYPE_RANDOM_Z = 0x5;
R3.D3.API.Mesh.Particle.ROTATION_TYPE_FUNCTION = 0x6;

View File

@ -1,6 +1,6 @@
/**
* R3.D3.API.Particle.Engine
* @param apiParticle
* R3.D3.API.Mesh.Particle.Engine
* @param apiMesh.Particle
* @param position
* @param direction
* @param enabled
@ -11,48 +11,13 @@
* @param fired
* @constructor
*/
R3.D3.API.Particle.Engine = function(
apiParticle,
position,
direction,
enabled,
particlesPerSecond,
frequency,
elapsed,
pulse,
fired
R3.D3.API.Mesh.Particle.Engine = function(
apiComponent
) {
if (R3.Utils.UndefinedOrNull(apiComponent.apiParticle)) {
apiComponent.apiParticle = {};
}
this.apiParticle = apiComponent.apiParticle;
R3.D3.API.Particle.call(
R3.D3.API.Mesh.Particle.call(
this,
this.apiParticle,
this.apiParticle.lifeTime,
this.apiParticle.elapsed,
this.apiParticle.mesh,
this.apiParticle.opacityType,
this.apiParticle.fadeInFactor,
this.apiParticle.fadeOutFactor,
this.apiParticle.fadeInAfter,
this.apiParticle.fadeOutAfter,
this.apiParticle.positionOffsetType,
this.apiParticle.positionOffset,
this.apiParticle.positionOffsetFn,
this.apiParticle.directionType,
this.apiParticle.direction,
this.apiParticle.directionFn,
this.apiParticle.speedType,
this.apiParticle.speed,
this.apiParticle.scaleType,
this.apiParticle.scale,
this.apiParticle.scaleFn,
this.apiParticle.rotationType,
this.apiParticle.rotation,
this.apiParticle.rotationFn
apiComponent
);
if (R3.Utils.UndefinedOrNull(apiComponent.position)) {
@ -97,5 +62,5 @@ R3.D3.API.Particle.Engine = function(
};
R3.D3.API.Particle.Engine.prototype = Object.create(R3.D3.API.Particle.prototype);
R3.D3.API.Particle.Engine.prototype.constructor = R3.D3.API.Particle.Engine;
R3.D3.API.Mesh.Particle.Engine.prototype = Object.create(R3.D3.API.Mesh.Particle.prototype);
R3.D3.API.Mesh.Particle.Engine.prototype.constructor = R3.D3.API.Mesh.Particle.Engine;

View File

@ -1,14 +1,14 @@
/**
* Raycaster for R3.D3
* R3.D3.API.Raycaster
* @param apiComponent
* @param position R3.API.Vector3
* @param direction R3.API.Vector3
*
* @property position
* @property direction
*
* @constructor
*/
R3.D3.API.Raycaster = function(
apiComponent,
position,
direction
apiComponent
) {
__API_COMPONENT__;
@ -17,6 +17,7 @@ R3.D3.API.Raycaster = function(
apiComponent.position = new R3.API.Vector3(
{
parent : this,
name : this.name + ' - Position',
register : true
}
);
@ -27,6 +28,7 @@ R3.D3.API.Raycaster = function(
apiComponent.direction = new R3.API.Vector3(
{
parent : this,
name : this.name + ' - Direction',
register : true
},
0,

View File

@ -1,28 +1,21 @@
/**
* R3.D3.API.RenderTarget
* @param apiComponent
* @param width
* @param height
* @param scissor
* @param scissorTest
* @param viewport
* @param texture
* @param depthBuffer
* @param depthTexture
* @param stencilBuffer
*
* @property width
* @property height
* @property scissor
* @property scissorTest
* @property viewport
* @property texture
* @property depthBuffer
* @property depthTexture
* @property stencilBuffer
*
* @constructor
*/
R3.D3.API.RenderTarget = function(
apiComponent,
width,
height,
scissor,
scissorTest,
viewport,
texture,
depthBuffer,
depthTexture,
stencilBuffer
apiComponent
) {
__API_COMPONENT__;
@ -38,7 +31,16 @@ R3.D3.API.RenderTarget = function(
this.height = apiComponent.height;
if (R3.Utils.UndefinedOrNull(apiComponent.scissor)) {
apiComponent.scissor = R3.API.Vector4(0,0,1,1);
apiComponent.scissor = new R3.API.Vector4(
{
parent : this,
register : true,
x : 0,
y : 0,
z : 1,
w : 1
}
);
}
this.scissor = apiComponent.scissor;
@ -48,12 +50,23 @@ R3.D3.API.RenderTarget = function(
this.scissorTest = apiComponent.scissorTest;
if (R3.Utils.UndefinedOrNull(apiComponent.viewport)) {
apiComponent.viewport = R3.API.Vector4(0,0,1,1);
apiComponent.viewport = new R3.API.Vector4({
parent : this,
register : true,
x : 0,
y : 0,
z : 1,
w : 1
});
}
this.viewport = apiComponent.viewport;
if (R3.Utils.UndefinedOrNull(apiComponent.texture)) {
apiComponent.texture = new R3.D3.API.Texture();
apiComponent.texture = new R3.D3.API.Texture(
{
parent : this
}
);
}
this.texture = apiComponent.texture;

View File

@ -6,7 +6,6 @@
* @property lights []
* @property textures []
* @property materials []
* @property images
* @property fog
* @property showGrid
* @property showAxis
@ -49,13 +48,13 @@ R3.D3.API.Scene = function(
}
this.materials = apiComponent.materials;
if (R3.Utils.UndefinedOrNull(apiComponent.images)) {
apiComponent.images = [];
}
this.images = apiComponent.images;
if (R3.Utils.UndefinedOrNull(apiComponent.fog)) {
apiComponent.fog = new R3.D3.API.Fog();
apiComponent.fog = new R3.D3.API.Fog.Normal(
{
parent : this,
name : this.name + ' - Fog'
}
);
}
this.fog = apiComponent.fog;
@ -75,7 +74,14 @@ R3.D3.API.Scene = function(
this.gridSize = apiComponent.gridSize;
if (R3.Utils.UndefinedOrNull(apiComponent.gridColor)) {
apiComponent.gridColor = new R3.API.Color(this, 0.14117641, 0.576470588, 0.882352941);
apiComponent.gridColor = new R3.API.Color({
parent : this,
register : true,
name : this.name + ' - Grid Color',
r : 0.14117641,
g : 0.576470588,
b : 0.882352941
});
}
this.gridColor = apiComponent.gridColor;
@ -95,12 +101,22 @@ R3.D3.API.Scene = function(
this.cubeCameras = apiComponent.cubeCameras;
if (R3.Utils.UndefinedOrNull(apiComponent.composer)) {
apiComponent.composer = new R3.API.Composer();
apiComponent.composer = new R3.D3.API.Composer(
{
parent : this,
name : this.name + ' - Composer'
}
);
}
this.composer = apiComponent.composer;
if (R3.Utils.UndefinedOrNull(apiComponent.effect)) {
apiComponent.effect = new R3.API.Effect();
apiComponent.effect = new R3.D3.API.Effect(
{
parent : this,
name : this.name + ' - Effect'
}
);
}
this.effect = apiComponent.effect;
@ -114,10 +130,6 @@ R3.D3.API.Scene = function(
}
this.enableEffect = apiComponent.enableEffect;
if (R3.Utils.UndefinedOrNull(apiComponent.controls)) {
apiComponent.controls = new R3.API.Controls.D3.Orbit()
}
this.controls = apiComponent.controls;
};
R3.D3.API.Scene.prototype = Object.create(R3.API.Component.prototype);

View File

@ -4,11 +4,11 @@
* Ignore aspect ratio and make viewport respect x,y,width and height as is
*
* @param apiComponent
*
* @property width
* @property height
*
* @property x
* @property y
* @property width
* @property height
* @property scenes
*
* @constructor
@ -19,16 +19,6 @@ R3.D3.API.Viewport = function(
__API_COMPONENT__;
if (R3.Utils.UndefinedOrNull(apiComponent.width)) {
apiComponent.width = 1;
}
this.width = apiComponent.width;
if (R3.Utils.UndefinedOrNull(apiComponent.height)) {
apiComponent.height = 1;
}
this.height = apiComponent.height;
if (R3.Utils.UndefinedOrNull(apiComponent.x)) {
apiComponent.x = 0;
}
@ -39,8 +29,23 @@ R3.D3.API.Viewport = function(
}
this.y = apiComponent.y;
if (R3.Utils.UndefinedOrNull(apiComponent.width)) {
apiComponent.width = 1;
}
this.width = apiComponent.width;
if (R3.Utils.UndefinedOrNull(apiComponent.height)) {
apiComponent.height = 1;
}
this.height = apiComponent.height;
if (R3.Utils.UndefinedOrNull(apiComponent.scenes)) {
apiComponent.scenes = [new R3.D3.API.Scene()];
apiComponent.scenes = [new R3.D3.API.Scene(
{
parent : this,
name : this.name + ' - Scene'
}
)];
}
this.scenes = apiComponent.scenes;

View File

@ -5,28 +5,19 @@
* - entire viewport remains visible at all times
* - will have empty space above or below viewport depending on canvas size (if canvas ratio != viewport ratio)
*
* @param apiComponent
*
* @property aspectRatio
*
* @constructor
* @param apiViewport
* @param aspectRatio
*/
R3.D3.API.Viewport.FixedAspect = function(
apiViewport,
aspectRatio
apiComponent
) {
if (R3.Utils.UndefinedOrNull(apiComponent.apiViewport)) {
apiComponent.apiViewport = {};
}
this.apiViewport = apiComponent.apiViewport;
R3.D3.API.Viewport.call(
this,
this.apiViewport,
this.apiViewport.width,
this.apiViewport.height,
this.apiViewport.x,
this.apiViewport.y,
this.apiViewport.scenes
apiComponent
);
if (R3.Utils.UndefinedOrNull(apiComponent.aspectRatio)) {

View File

@ -22,32 +22,21 @@
* similar to a VIEWPORT_TYPE_FIXED_ASPECT in the case that the entire viewport actually fits into the canvas
* (when did this ever happen? wouldn't live have been great?)
*
* @param apiComponent
*
* @property aspectRatio
* @property expandWidth
* @property expandHeight
*
* @constructor
* @param apiViewport
* @param aspectRatio
* @param expandWidth
* @param expandHeight
*/
R3.D3.API.Viewport.ZoomedAspect = function(
apiViewport,
aspectRatio,
expandWidth,
expandHeight
apiComponent
) {
if (R3.Utils.UndefinedOrNull(apiComponent.apiViewport)) {
apiComponent.apiViewport = {};
}
this.apiViewport = apiComponent.apiViewport;
R3.D3.API.Viewport.call(
this,
this.apiViewport,
this.apiViewport.width,
this.apiViewport.height,
this.apiViewport.x,
this.apiViewport.y,
this.apiViewport.scenes
apiComponent
);
if (R3.Utils.UndefinedOrNull(apiComponent.aspectRatio)) {

View File

@ -13,13 +13,9 @@ R3.D3.Object = function(
inherited
) {
if (R3.Utils.UndefinedOrNull(inherited)) {
__INHERIT_AND_INSTANTIATE__
__RUNTIME_COMPONENT__;
}
__UPGRADE_TO_RUNTIME;
__UPGRADE_TO_RUNTIME__;
};

View File

@ -1,14 +1,21 @@
/**
* R3.D3.Camera
*
* - This class cannot be instantiated - simply pass it all through to R3.D3.Object
* - This class cannot be instantiated - simply pass it all through to R3.D3.Object - it need apiComponent to pass
* to Object
*
* @constructor
*/
R3.D3.Camera = function() {
R3.D3.Camera = function(
apiComponent,
inherited
) {
__INHERIT_ONLY__
R3.D3.Object.call(
this,
apiComponent,
true
);
@ -17,17 +24,6 @@ R3.D3.Camera = function() {
R3.D3.Camera.prototype = Object.create(R3.D3.Object.prototype);
R3.D3.Camera.prototype.constructor = R3.D3.Camera;
/**
* Although you cannot instatiate this directly - you can set common properties for children on 'createInstance'
*/
R3.D3.Camera.prototype.createInstance = function() {
this.instance.aspect = this.aspect;
__CREATE_INSTANCE__;
};
/**
* Updates the instance with the current state
*/

View File

@ -11,6 +11,7 @@ R3.D3.Camera.Cube = function(
R3.D3.Camera.call(
this,
apiComponent,
true
);

View File

@ -5,9 +5,18 @@
*
* @constructor
*/
R3.D3.Camera.Orthographic = function() {
R3.D3.Camera.Orthographic = function(
apiComponent,
inherited
) {
R3.D3.Camera.call(this);
__INHERIT_ONLY__
R3.D3.Camera.call(
this,
apiComponent,
true
);
};

View File

@ -9,7 +9,11 @@ R3.D3.Camera.Orthographic.FixedAspect = function(
__RUNTIME_COMPONENT__;
R3.D3.Camera.Orthographic.call(this);
R3.D3.Camera.Orthographic.call(
this,
apiComponent,
true
);
};

View File

@ -9,7 +9,11 @@ R3.D3.Camera.Orthographic.ScaledAspect = function(
__RUNTIME_COMPONENT__;
R3.D3.Camera.Orthographic.call(this);
R3.D3.Camera.Orthographic.call(
this,
apiComponent,
true
);
};

View File

@ -9,15 +9,13 @@ R3.D3.Camera.Perspective = function(
inherited
) {
if (R3.Utils.UndefinedOrNull(inherited)) {
inherited = false;
}
__INHERIT_AND_INSTANTIATE__
if (!inherited) {
__RUNTIME_COMPONENT__;
}
R3.D3.Camera.call(this);
R3.D3.Camera.call(
this,
apiComponent,
true
);
};
@ -30,19 +28,7 @@ R3.D3.Camera.Perspective.prototype.constructor = R3.D3.Camera.Perspective;
*/
R3.D3.Camera.Perspective.prototype.createInstance = function() {
this.instance = this.graphics.PerspectiveCamera(
this.fov,
this.aspect,
this.near,
this.far
);
this.instance.filmGauge = this.filmGauge;
this.instance.filmOffset = this.filmOffset;
this.instance.focus = this.focus;
this.instance.zoom = this.zoom;
this.instance.updateProjectionMatrix();
this.instance = this.graphics.PerspectiveCamera(this);
__CREATE_INSTANCE__;
@ -53,6 +39,16 @@ R3.D3.Camera.Perspective.prototype.createInstance = function() {
*/
R3.D3.Camera.Perspective.prototype.updateInstance = function(property) {
if (property === 'position') {
this.instance.position.set(
this.position.x,
this.position.y,
this.position.z
);
this.instance.updateProjectionMatrix();
return;
}
if (property === 'near') {
this.instance.near = this.near;
this.instance.updateProjectionMatrix();

View File

@ -11,6 +11,7 @@ R3.D3.Camera.Perspective.Stereo = function(
R3.D3.Camera.Perspective.call(
this,
apiComponent,
true
);

View File

@ -6,12 +6,7 @@ R3.D3.Fog = function(
inherited
) {
/**
* This class is intended to be inherited only
*/
if (R3.Utils.UndefinedOrNull(inherited)) {
throw new Error('This class can only be inherited');
}
__INHERIT_ONLY__
__UPGRADE_TO_RUNTIME__;

View File

@ -20,10 +20,7 @@ R3.D3.Fog.Exp.prototype.constructor = R3.D3.Fog.Exp;
R3.D3.Fog.Exp.prototype.createInstance = function() {
this.instance = this.graphics.FogExp(
this.color,
this.density
);
this.instance = this.graphics.FogExp(this);
__CREATE_INSTANCE__;
};

View File

@ -21,11 +21,7 @@ R3.D3.Fog.Normal.prototype.constructor = R3.D3.Fog.Normal;
R3.D3.Fog.Normal.prototype.createInstance = function() {
this.instance = this.graphics.Fog(
this.color,
this.near,
this.far
);
this.instance = this.graphics.Fog(this);
__CREATE_INSTANCE__;
};

View File

@ -262,7 +262,7 @@ R3.D3.Material.prototype.getTextures = function() {
var textures = [];
Object.keys(this.linkedObjects).map(
Object.keys(this.linkedComponents).map(
function(property) {
if (this[property] instanceof R3.D3.Texture) {
textures.push(
@ -282,45 +282,45 @@ R3.D3.Material.prototype.getTextures = function() {
/*
switch (this.materialType) {
case R3.D3.API.Material.MATERIAL_TYPE_STANDARD :
linkedObjects.alphaMap = R3.D3.Texture;
linkedObjects.aoMap = R3.D3.Texture;
linkedObjects.bumpMap = R3.D3.Texture;
linkedObjects.diffuseMap = R3.D3.Texture;
linkedObjects.displacementMap = R3.D3.Texture;
linkedObjects.emissiveMap = R3.D3.Texture;
linkedObjects.envMap = R3.D3.Texture;
linkedObjects.lightMap = R3.D3.Texture;
linkedObjects.metalnessMap = R3.D3.Texture;
linkedObjects.normalMap = R3.D3.Texture;
linkedObjects.roughnessMap = R3.D3.Texture;
linkedComponents.alphaMap = R3.D3.Texture;
linkedComponents.aoMap = R3.D3.Texture;
linkedComponents.bumpMap = R3.D3.Texture;
linkedComponents.diffuseMap = R3.D3.Texture;
linkedComponents.displacementMap = R3.D3.Texture;
linkedComponents.emissiveMap = R3.D3.Texture;
linkedComponents.envMap = R3.D3.Texture;
linkedComponents.lightMap = R3.D3.Texture;
linkedComponents.metalnessMap = R3.D3.Texture;
linkedComponents.normalMap = R3.D3.Texture;
linkedComponents.roughnessMap = R3.D3.Texture;
break;
case R3.D3.API.Material.MATERIAL_TYPE_BASIC :
linkedObjects.alphaMap = R3.D3.Texture;
linkedObjects.aoMap = R3.D3.Texture;
linkedObjects.diffuseMap = R3.D3.Texture;
linkedObjects.envMap = R3.D3.Texture;
linkedObjects.lightMap = R3.D3.Texture;
linkedObjects.specularMap = R3.D3.Texture;
linkedComponents.alphaMap = R3.D3.Texture;
linkedComponents.aoMap = R3.D3.Texture;
linkedComponents.diffuseMap = R3.D3.Texture;
linkedComponents.envMap = R3.D3.Texture;
linkedComponents.lightMap = R3.D3.Texture;
linkedComponents.specularMap = R3.D3.Texture;
break;
case R3.D3.API.Material.MATERIAL_TYPE_PHONG :
linkedObjects.alphaMap = R3.D3.Texture;
linkedObjects.aoMap = R3.D3.Texture;
linkedObjects.bumpMap = R3.D3.Texture;
linkedObjects.diffuseMap = R3.D3.Texture;
linkedObjects.displacementMap = R3.D3.Texture;
linkedObjects.emissiveMap = R3.D3.Texture;
linkedObjects.envMap = R3.D3.Texture;
linkedObjects.lightMap = R3.D3.Texture;
linkedObjects.normalMap = R3.D3.Texture;
linkedObjects.specularMap = R3.D3.Texture;
linkedComponents.alphaMap = R3.D3.Texture;
linkedComponents.aoMap = R3.D3.Texture;
linkedComponents.bumpMap = R3.D3.Texture;
linkedComponents.diffuseMap = R3.D3.Texture;
linkedComponents.displacementMap = R3.D3.Texture;
linkedComponents.emissiveMap = R3.D3.Texture;
linkedComponents.envMap = R3.D3.Texture;
linkedComponents.lightMap = R3.D3.Texture;
linkedComponents.normalMap = R3.D3.Texture;
linkedComponents.specularMap = R3.D3.Texture;
break;
case R3.D3.API.Material.MATERIAL_TYPE_SHADER :
case R3.D3.API.Material.MATERIAL_TYPE_SHADER_RAW :
linkedObjects.vertexShader = R3.D3.Shader.Vertex;
linkedObjects.fragmentShader = R3.D3.Shader.Fragment;
linkedComponents.vertexShader = R3.D3.Shader.Vertex;
linkedComponents.fragmentShader = R3.D3.Shader.Fragment;
break;
case R3.D3.API.Material.MATERIAL_TYPE_POINTS :
linkedObjects.diffuseMap = R3.D3.Texture;
linkedComponents.diffuseMap = R3.D3.Texture;
break;
default :
throw new Error('unhandled material type: ' + this.materialType);

View File

@ -1,114 +1,50 @@
/**
* Creates a Particle object
* @param graphics R3.Runtime.Graphics
* @param apiParticle R3.D3.API.Particle
* R3.D3.Mesh.Particle
* @param apiComponent
* @param inherited
* @constructor
*/
R3.D3.Particle = function(
graphics,
apiParticle
R3.D3.Mesh.Particle = function(
apiComponent,
inherited
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (R3.Utils.UndefinedOrNull(apiParticle)) {
apiParticle = {};
if (R3.Utils.UndefinedOrNull(inherited)) {
__RUNTIME_COMPONENT__;
}
R3.D3.API.Particle.call(
R3.D3.Mesh.call(
this,
apiParticle.id,
apiParticle.name,
apiParticle.lifeTime,
apiParticle.elapsed,
apiParticle.mesh,
apiParticle.opacityType,
apiParticle.fadeInFactor,
apiParticle.fadeOutFactor,
apiParticle.fadeInAfter,
apiParticle.fadeOutAfter,
apiParticle.positionOffsetType,
apiParticle.positionOffset,
apiParticle.positionOffsetFn,
apiParticle.directionType,
apiParticle.direction,
apiParticle.directionFn,
apiParticle.speedType,
apiParticle.speed,
apiParticle.scaleType,
apiParticle.scale,
apiParticle.scaleFn,
apiParticle.rotationType,
apiParticle.rotation,
apiParticle.rotationFn,
apiParticle.parentParticleEngine,
apiParticle.parent
);
if (this.mesh instanceof R3.D3.API.Mesh) {
this.mesh = new R3.D3.Mesh(
graphics,
this.mesh
)
}
this.positionOffset = new R3.Vector3(
graphics,
this.positionOffset,
this
);
this.direction = new R3.Vector3(
graphics,
this.direction,
this
);
this.scale = new R3.Vector3(
graphics,
this.scale,
this
);
this.rotation = new R3.Vector3(
graphics,
this.rotation,
this
);
R3.Component.call(
this,
{
mesh : R3.D3.Mesh,
parentParticleEngine : R3.D3.ParticleEngine
}
apiComponent,
true
);
};
R3.D3.Particle.prototype = Object.create(R3.Component.prototype);
R3.D3.Particle.prototype.constructor = R3.D3.Particle;
R3.D3.Mesh.Particle.prototype = Object.create(R3.D3.Mesh.prototype);
R3.D3.Mesh.Particle.prototype.constructor = R3.D3.Mesh.Particle;
/**
* Particle create instance
* Mesh.Particle create instance
*/
R3.D3.Particle.prototype.createInstance = function() {
R3.D3.Mesh.Particle.prototype.createInstance = function() {
if (!this.mesh) {
console.warn('no mesh to clone from - failed dependency check?');
return
}
this.instance = this.mesh.instance;
console.warn('todo : R3.D3.Mesh.Particle.prototype.createInstance');
// if (!this.mesh) {
// console.warn('no mesh to clone from - failed dependency check?');
// return
// }
//
// this.instance = this.mesh.instance;
//
__CREATE_INSTANCE__;
};
/**
* Updates the instance with the current state
*/
R3.D3.Particle.prototype.updateInstance = function(property) {
R3.D3.Mesh.Particle.prototype.updateInstance = function(property) {
if (!this.instance) {
this.createInstance();
@ -154,7 +90,7 @@ R3.D3.Particle.prototype.updateInstance = function(property) {
/**
* Clones a particle - this only clones 3rd party instances, so we have less overhead of creating these types of objects
*/
R3.D3.Particle.prototype.cloneInstance = function() {
R3.D3.Mesh.Particle.prototype.cloneInstance = function() {
this.updateInstance('positionOffset');
this.updateInstance('direction');
@ -163,13 +99,13 @@ R3.D3.Particle.prototype.cloneInstance = function() {
var clone = R3.Component.prototype.cloneInstance.call(this);
clone.position = this.parentParticleEngine.position.instance.clone();
clone.position = this.parentMesh.ParticleEngine.position.instance.clone();
clone.material = this.mesh.materials[0].instance.clone();
clone.visible = true;
if (this.positionOffsetType === R3.D3.API.Particle.POSITION_OFFSET_TYPE_CONSTANT) {
if (this.positionOffsetType === R3.D3.API.Mesh.Particle.POSITION_OFFSET_TYPE_CONSTANT) {
clone.position.add(this.positionOffset.instance);
}
@ -177,7 +113,7 @@ R3.D3.Particle.prototype.cloneInstance = function() {
var addY = 1;
var addZ = 1;
if (this.positionOffsetType === R3.D3.API.Particle.POSITION_OFFSET_TYPE_RANDOM) {
if (this.positionOffsetType === R3.D3.API.Mesh.Particle.POSITION_OFFSET_TYPE_RANDOM) {
addX = R3.Utils.GetRandomIntInclusive(1,2);
addY = R3.Utils.GetRandomIntInclusive(1,2);
@ -204,15 +140,15 @@ R3.D3.Particle.prototype.cloneInstance = function() {
clone.userData.direction = this.direction.clone();
if (this.directionType === R3.D3.API.Particle.DIRECTION_TYPE_CONSTANT) {
if (this.directionType === R3.D3.API.Mesh.Particle.DIRECTION_TYPE_CONSTANT) {
/**
* Nothing to do
*/
} else if (
this.directionType === R3.D3.API.Particle.DIRECTION_TYPE_RANDOM ||
this.directionType === R3.D3.API.Particle.DIRECTION_TYPE_RANDOM_NORMALIZED
this.directionType === R3.D3.API.Mesh.Particle.DIRECTION_TYPE_RANDOM ||
this.directionType === R3.D3.API.Mesh.Particle.DIRECTION_TYPE_RANDOM_NORMALIZED
) {
addX = R3.Utils.GetRandomIntInclusive(1,2);
@ -241,7 +177,7 @@ R3.D3.Particle.prototype.cloneInstance = function() {
clone.userData.direction.z += Math.random() * this.direction.z;
}
if (this.directionType === R3.D3.API.Particle.DIRECTION_TYPE_RANDOM_NORMALIZED) {
if (this.directionType === R3.D3.API.Mesh.Particle.DIRECTION_TYPE_RANDOM_NORMALIZED) {
clone.userData.direction.normalize();
}
@ -250,13 +186,13 @@ R3.D3.Particle.prototype.cloneInstance = function() {
}
if (this.scaleType === R3.D3.API.Particle.SCALE_TYPE_CONSTANT) {
if (this.scaleType === R3.D3.API.Mesh.Particle.SCALE_TYPE_CONSTANT) {
clone.scale.x += this.scale.x;
clone.scale.y += this.scale.y;
clone.scale.z += this.scale.z;
}
if (this.scaleType === R3.D3.API.Particle.SCALE_TYPE_RANDOM) {
if (this.scaleType === R3.D3.API.Mesh.Particle.SCALE_TYPE_RANDOM) {
add = R3.Utils.GetRandomIntInclusive(1,2);
@ -271,7 +207,7 @@ R3.D3.Particle.prototype.cloneInstance = function() {
}
}
if (this.scaleType === R3.D3.API.Particle.SCALE_TYPE_RANDOM_X_EQUALS_Y) {
if (this.scaleType === R3.D3.API.Mesh.Particle.SCALE_TYPE_RANDOM_X_EQUALS_Y) {
add = R3.Utils.GetRandomIntInclusive(1,2);
@ -291,14 +227,14 @@ R3.D3.Particle.prototype.cloneInstance = function() {
var fadeIn = true;
if (
this.opacityType === R3.D3.API.Particle.OPACITY_TYPE_FADE_IN_LINEAR ||
this.opacityType === R3.D3.API.Particle.OPACITY_TYPE_FADE_IN_OUT_LINEAR
this.opacityType === R3.D3.API.Mesh.Particle.OPACITY_TYPE_FADE_IN_LINEAR ||
this.opacityType === R3.D3.API.Mesh.Particle.OPACITY_TYPE_FADE_IN_OUT_LINEAR
) {
clone.material.opacity = 0;
fadeIn = true;
}
if (this.opacityType === R3.D3.API.Particle.OPACITY_TYPE_FADE_OUT_LINEAR) {
if (this.opacityType === R3.D3.API.Mesh.Particle.OPACITY_TYPE_FADE_OUT_LINEAR) {
clone.material.opacity = 1;
fadeIn = false;
}
@ -315,40 +251,3 @@ R3.D3.Particle.prototype.cloneInstance = function() {
return clone;
};
/**
* Converts a R3.D3.Particle to a new R3.D3.API.Particle
* @returns {R3.D3.API.Particle}
*/
R3.D3.Particle.prototype.toApiObject = function() {
return new R3.D3.API.Particle(
this.id,
this.name,
this.lifeTime,
this.elapsed,
R3.Utils.IdOrNull(this.mesh),
this.opacityType,
this.fadeInFactor,
this.fadeOutFactor,
this.fadeInAfter,
this.fadeOutAfter,
this.positionOffsetType,
this.positionOffset.toApiObject(),
this.positionOffsetFn,
this.directionType,
this.direction.toApiObject(),
this.directionFn,
this.speedType,
this.speed,
this.scaleType,
this.scale.toApiObject(),
this.scaleFn,
this.rotationType,
this.rotation.toApiObject(),
this.rotationFn,
R3.Utils.IdOrNull(this.parentParticleEngine),
R3.Utils.IdOrNull(this.parent)
);
};

View File

@ -0,0 +1,192 @@
/**
* Creates a Mesh.Particle.Engine object
* @param graphics R3.Runtime.Graphics
* @param apiMesh.Particle.Engine R3.D3.API.Mesh.Particle.Engine
* @constructor
*/
R3.D3.Mesh.Particle.Engine = function(
apiComponent
) {
__RUNTIME_COMPONENT__;
};
R3.D3.Mesh.Particle.Engine.prototype = Object.create(R3.D3.Mesh.Particle.prototype);
R3.D3.Mesh.Particle.Engine.prototype.constructor = R3.D3.Mesh.Particle.Engine;
/**
* We don't use a 3rd party particle engine right now
* @returns true
*/
R3.D3.Mesh.Particle.Engine.prototype.createInstance = function() {
this.instance = true;
// if (this.templateMesh.Particle) {
//
// this.templateMesh.Particle.mesh.position.x = this.position.x;
// this.templateMesh.Particle.mesh.position.y = this.position.y;
// this.templateMesh.Particle.mesh.position.z = this.position.z;
//
// this.templateMesh.Particle.direction.x = this.direction.x;
// this.templateMesh.Particle.direction.y = this.direction.y;
// this.templateMesh.Particle.direction.z = this.direction.z;
//
// this.templateMesh.Particle.scale.x = this.scale.x;
// this.templateMesh.Particle.scale.y = this.scale.y;
// this.templateMesh.Particle.scale.z = this.scale.z;
// }
__CREATE_INSTANCE__;
};
/**
* Updates the instance with the current state
*/
R3.D3.Mesh.Particle.Engine.prototype.updateInstance = function(property) {
// if (property === 'particlesPerSecond') {
// this.frequency = Number(1 / this.particlesPerSecond);
// }
//
// if (property === 'frequency') {
// this.particlesPerSecond = Math.round(1 / this.frequency);
// }
//
// if (property === 'position') {
// this.position.instance.x = this.position.x;
// this.position.instance.y = this.position.y;
// this.position.instance.z = this.position.z;
// this.templateMeshParticle.mesh.position = this.position.clone();
// this.templateMeshParticle.mesh.updateInstance('position', true);
// }
//
// if (property === 'direction') {
// this.direction.instance.x = this.direction.x;
// this.direction.instance.y = this.direction.y;
// this.direction.instance.z = this.direction.z;
// this.templateMeshParticle.direction = this.direction.clone();
// this.templateMeshParticle.direction.updateInstance('direction', true);
// }
__UPDATE_INSTANCE__;
};
R3.D3.Mesh.Particle.Engine.prototype.remove = function() {
// if (this.removeSubscription) {
// console.log('already another remove subscription for ' + this.name);
// return;
// }
//
// this.removeSubscription = R3.Event.Subscribe(
// R3.Event.REMOVE_PARTICLE_ENGINE,
// function(data){
// if (data.component === this) {
//
// if (this.isClone) {
// /**
// * We only remove the things we cloned, the mesh, particle, and this
// */
// R3.Event.Emit(
// R3.Event.REMOVE_COMPONENT,
// {
// component: this.templateMeshParticle.mesh
// }
// );
//
// R3.Event.Emit(
// R3.Event.REMOVE_COMPONENT,
// {
// component: this.templateMeshParticle
// }
// );
//
// R3.Event.Emit(
// R3.Event.REMOVE_COMPONENT,
// {
// component: this
// }
// )
// } else {
// R3.Component.prototype.remove.call(this);
// }
//
// this.removeSubscription.remove();
//
// this.removeSubscription = null;
// }
// }.bind(this)
// );
/**
* Below signals the particle system to continue processing the particles, but don't create more, and
* we wait for the system to signal REMOVE_PARTICLE_ENGINE so we can destroy ourselves
* @type {boolean}
*/
this.disabledForRemoval = true;
};
// R3.D3.Mesh.Particle.Engine.prototype.getChildrenComponents = function() {
//
// var components = [];
//
// if (this.templateMesh.Particle) {
// components.push(this.templateMesh.Particle);
//
// if (this.templateMesh.Particle.mesh) {
// components.push(this.templateMesh.Particle.mesh);
//
// if (this.templateMesh.Particle.mesh.materials && this.templateMesh.Particle.mesh.materials[0]) {
//
// components.push(this.templateMesh.Particle.mesh.materials[0]);
//
// if (this.templateMesh.Particle.mesh.materials[0].diffuseMap) {
// components.push(this.templateMesh.Particle.mesh.materials[0].diffuseMap);
// }
// }
// }
// }
//
// return components;
// };
R3.D3.Mesh.Particle.Engine.prototype.clone = function() {
// var mesh = this.templateMesh.Particle.mesh.clone();
// var templateMesh.Particle = this.templateMesh.Particle.clone();
// templateMesh.Particle.mesh = mesh;
// templateMesh.Particle.instance = mesh.instance;
// var engine = R3.Component.prototype.clone.call(this);
// engine.templateMesh.Particle = templateMesh.Particle;
// return engine;
};
R3.D3.Mesh.Particle.Engine.prototype.processMeshParticles = function(delta) {
// this.particles = this.particles.reduce(
// function(result, particle){
//
// particle.position.x += particle.userData.direction.x * delta;
// particle.position.y += particle.userData.direction.y * delta;
// particle.position.z += particle.userData.direction.z * delta;
//
// particle.userData.elapsed += delta;
// if (particle.userData.elapsed > particle.userData.lifeTime) {
// particle.parent.remove(particle);
// } else {
// result.push(particle);
// }
//
// return result;
// },
// []
// );
};
R3.D3.Mesh.Particle.Engine.prototype.createNewMeshParticle = function(camera) {
//
// var particle = this.templateMesh.Particle.clone(camera);
//
// this.particles.push(particle);
};

View File

@ -1,272 +0,0 @@
/**
* Creates a ParticleEngine object
* @param graphics R3.Runtime.Graphics
* @param apiParticleEngine R3.D3.API.ParticleEngine
* @constructor
*/
R3.D3.ParticleEngine = function(
graphics,
apiParticleEngine
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (R3.Utils.UndefinedOrNull(apiParticleEngine)) {
apiParticleEngine = {};
}
R3.D3.API.ParticleEngine.call(
this,
apiParticleEngine.id,
apiParticleEngine.name,
apiParticleEngine.position,
apiParticleEngine.direction,
apiParticleEngine.enabled,
apiParticleEngine.templateParticle,
apiParticleEngine.particlesPerSecond,
apiParticleEngine.frequency,
apiParticleEngine.elapsed,
apiParticleEngine.camera,
apiParticleEngine.pulse,
apiParticleEngine.fired,
apiParticleEngine.parent
);
this.position = new R3.Vector3(
graphics,
this.position,
this
);
this.direction = new R3.Vector3(
graphics,
this.direction,
this
);
if (this.templateParticle instanceof R3.D3.API.Particle) {
this.templateParticle = new R3.D3.Particle(
graphics,
this.templateParticle
)
}
this.elapsed = 0;
this.particles = [];
this.disabledForRemoval = false;
R3.Component.call(
this,
{
templateParticle : R3.D3.Particle,
camera : R3.D3.Camera
}
);
};
R3.D3.ParticleEngine.prototype = Object.create(R3.Component.prototype);
R3.D3.ParticleEngine.prototype.constructor = R3.D3.ParticleEngine;
/**
* We don't use a 3rd party particle engine right now
* @returns true
*/
R3.D3.ParticleEngine.prototype.createInstance = function() {
this.instance = true;
// if (this.templateParticle) {
//
// this.templateParticle.mesh.position.x = this.position.x;
// this.templateParticle.mesh.position.y = this.position.y;
// this.templateParticle.mesh.position.z = this.position.z;
//
// this.templateParticle.direction.x = this.direction.x;
// this.templateParticle.direction.y = this.direction.y;
// this.templateParticle.direction.z = this.direction.z;
//
// this.templateParticle.scale.x = this.scale.x;
// this.templateParticle.scale.y = this.scale.y;
// this.templateParticle.scale.z = this.scale.z;
// }
__CREATE_INSTANCE__;
};
/**
* Updates the instance with the current state
*/
R3.D3.ParticleEngine.prototype.updateInstance = function(property) {
if (property === 'particlesPerSecond') {
this.frequency = Number(1 / this.particlesPerSecond);
}
if (property === 'frequency') {
this.particlesPerSecond = Math.round(1 / this.frequency);
}
if (property === 'position') {
this.position.instance.x = this.position.x;
this.position.instance.y = this.position.y;
this.position.instance.z = this.position.z;
this.templateParticle.mesh.position = this.position.clone();
this.templateParticle.mesh.updateInstance('position', true);
}
if (property === 'direction') {
this.direction.instance.x = this.direction.x;
this.direction.instance.y = this.direction.y;
this.direction.instance.z = this.direction.z;
this.templateParticle.direction = this.direction.clone();
this.templateParticle.direction.updateInstance('direction', true);
}
__UPDATE_INSTANCE__;
};
R3.D3.ParticleEngine.prototype.remove = function() {
if (this.removeSubscription) {
console.log('already another remove subscription for ' + this.name);
return;
}
this.removeSubscription = R3.Event.Subscribe(
R3.Event.REMOVE_PARTICLE_ENGINE,
function(data){
if (data.component === this) {
if (this.isClone) {
/**
* We only remove the things we cloned, the mesh, particle, and this
*/
R3.Event.Emit(
R3.Event.REMOVE_COMPONENT,
{
component: this.templateParticle.mesh
}
);
R3.Event.Emit(
R3.Event.REMOVE_COMPONENT,
{
component: this.templateParticle
}
);
R3.Event.Emit(
R3.Event.REMOVE_COMPONENT,
{
component: this
}
)
} else {
R3.Component.prototype.remove.call(this);
}
this.removeSubscription.remove();
this.removeSubscription = null;
}
}.bind(this)
);
/**
* Below signals the particle system to continue processing the particles, but don't create more, and
* we wait for the system to signal REMOVE_PARTICLE_ENGINE so we can destroy ourselves
* @type {boolean}
*/
this.disabledForRemoval = true;
};
// R3.D3.ParticleEngine.prototype.getChildrenComponents = function() {
//
// var components = [];
//
// if (this.templateParticle) {
// components.push(this.templateParticle);
//
// if (this.templateParticle.mesh) {
// components.push(this.templateParticle.mesh);
//
// if (this.templateParticle.mesh.materials && this.templateParticle.mesh.materials[0]) {
//
// components.push(this.templateParticle.mesh.materials[0]);
//
// if (this.templateParticle.mesh.materials[0].diffuseMap) {
// components.push(this.templateParticle.mesh.materials[0].diffuseMap);
// }
// }
// }
// }
//
// return components;
// };
R3.D3.ParticleEngine.prototype.clone = function() {
var mesh = this.templateParticle.mesh.clone();
var templateParticle = this.templateParticle.clone();
templateParticle.mesh = mesh;
templateParticle.instance = mesh.instance;
var engine = R3.Component.prototype.clone.call(this);
engine.templateParticle = templateParticle;
return engine;
};
R3.D3.ParticleEngine.prototype.processParticles = function(delta) {
// this.particles = this.particles.reduce(
// function(result, particle){
//
// particle.position.x += particle.userData.direction.x * delta;
// particle.position.y += particle.userData.direction.y * delta;
// particle.position.z += particle.userData.direction.z * delta;
//
// particle.userData.elapsed += delta;
// if (particle.userData.elapsed > particle.userData.lifeTime) {
// particle.parent.remove(particle);
// } else {
// result.push(particle);
// }
//
// return result;
// },
// []
// );
};
R3.D3.ParticleEngine.prototype.createNewParticle = function(camera) {
//
// var particle = this.templateParticle.clone(camera);
//
// this.particles.push(particle);
};
/**
* Converts a R3.D3.ParticleEngine to a new R3.D3.API.ParticleEngine
* @returns {R3.D3.API.ParticleEngine}
*/
R3.D3.ParticleEngine.prototype.toApiObject = function() {
return new R3.D3.API.ParticleEngine(
this.id,
this.name,
this.position.toApiObject(),
this.direction.toApiObject(),
this.enabled,
R3.Utils.IdOrNull(this.templateParticle),
this.particlesPerSecond,
this.frequency,
this.elapsed,
R3.Utils.IdOrNull(this.camera),
this.pulse,
this.fired,
R3.Utils.IdOrNull(this.parent)
);
};

View File

@ -9,13 +9,6 @@ R3.D3.Raycaster = function(
__RUNTIME_COMPONENT__;
R3.D3.API.Raycaster.call(
this,
apiComponent,
apiComponent.position,
apiComponent.direction
);
__UPGRADE_TO_RUNTIME__;
};
@ -75,8 +68,8 @@ R3.D3.Raycaster.prototype.set = function(
this.direction.y = direction.y;
this.direction.z = direction.z;
this.position.updateInstance();
this.direction.updateInstance();
this.updateInstance('position');
this.updateInstance('direction');
};
/**
@ -90,7 +83,7 @@ R3.D3.Raycaster.prototype.setDirection = function(
this.direction.y = direction.y;
this.direction.z = direction.z;
this.direction.updateInstance();
this.updateInstance('direction');
};
/**
@ -104,7 +97,7 @@ R3.D3.Raycaster.prototype.setPosition = function(
this.position.y = position.y;
this.position.z = position.z;
this.position.updateInstance();
this.updateInstance('position');
};
/**

Some files were not shown because too many files have changed in this diff Show More