get projects

beta.r3js.org
cybafelo 2019-10-28 18:25:04 +01:00
parent 8705586d71
commit 1f85c4e7dd
3 changed files with 276 additions and 202 deletions

View File

@ -25,7 +25,7 @@ foreach ($files as $file) {
!preg_match('/Emit|Subscribe|.call|GetEventName|Async|prototype/', $line)
) {
$matches = [];
preg_match_all('/(R3.Event\..*?)(\s+|,|;|$)/', $line, $matches);
preg_match_all('/(R3.Event\..*?)(\s+|,|;|$|\))/', $line, $matches);
if ($matches[1] && $matches[1][0]) {

View File

@ -12,107 +12,109 @@ 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.CLEAR_GUI = 0x10;
R3.Event.COMPILE_FAILED = 0x11;
R3.Event.COMPILE_SUCCESS = 0x12;
R3.Event.COMPONENTS_LINKED = 0x13;
R3.Event.COMPONENT_CLONED = 0x14;
R3.Event.COMPONENT_CREATED = 0x15;
R3.Event.COMPONENT_DELETED = 0x16;
R3.Event.COMPONENT_DOWNLOAD_COMPLETE = 0x17;
R3.Event.COMPONENT_LINKED = 0x18;
R3.Event.COMPONENT_REGISTER = 0x19;
R3.Event.COMPONENT_REPLACED = 0x1a;
R3.Event.COMPONENT_SAVED = 0x1b;
R3.Event.COMPONENT_TYPES_UPDATE = 0x1c;
R3.Event.COMPONENT_UPDATE = 0x1d;
R3.Event.CONTINUE_ALL_AUDIO = 0x1e;
R3.Event.CONTROLS_CANVAS_CHANGE = 0x1f;
R3.Event.DELETE_COMPONENT = 0x20;
R3.Event.DELETE_COMPONENT_ERROR = 0x21;
R3.Event.DONE_SAVING = 0x22;
R3.Event.ENGINE_FIRED_PARTICLES_ZERO = 0x23;
R3.Event.ENTITY_LOADED = 0x24;
R3.Event.EVENT_ID_UPDATE = 0x25;
R3.Event.EXCLUDE_FROM_ENVIRONMENT = 0x26;
R3.Event.FETCH_COMPONENTS = 0x27;
R3.Event.FETCH_COMPONENT_TYPES = 0x28;
R3.Event.GET_API_URL = 0x29;
R3.Event.GET_APPLICATION_MODE = 0x2a;
R3.Event.GET_GRAPHICS_RUNTIME = 0x2b;
R3.Event.GET_PHYSICS_RUNTIME = 0x2c;
R3.Event.GET_PROJECT = 0x2d;
R3.Event.GET_REMOTE_API_URL = 0x2e;
R3.Event.GET_RENDER_CONFIGURATION = 0x2f;
R3.Event.GET_RUNTIME = 0x30;
R3.Event.GET_USER = 0x31;
R3.Event.GET_WEBSOCKET_CONFIG = 0x32;
R3.Event.GET_WINDOW_SIZE = 0x33;
R3.Event.GUI_CREATED = 0x34;
R3.Event.GUI_REMOVED = 0x35;
R3.Event.IMAGE_UPLOAD_COMPLETE = 0x36;
R3.Event.INSTANCE_CLONED = 0x37;
R3.Event.INSTANCE_CREATED = 0x38;
R3.Event.INSTANCE_DISPOSAL = 0x39;
R3.Event.INSTANCE_LOADED = 0x3a;
R3.Event.KEY_DOWN = 0x3b;
R3.Event.KEY_UP = 0x3c;
R3.Event.LOAD_COMPONENT = 0x3d;
R3.Event.LOAD_COMPONENT_ERROR = 0x3e;
R3.Event.LOAD_FONT = 0x3f;
R3.Event.LOAD_IMAGE = 0x40;
R3.Event.LOAD_PROGRESS = 0x41;
R3.Event.MATERIAL_TEXTURES_UPDATED = 0x42;
R3.Event.MATERIAL_TYPE_CHANGED = 0x43;
R3.Event.MAXIMUM_PROJECTS = 0x44;
R3.Event.MESH_DESELECTED = 0x45;
R3.Event.MESH_FACE_DESELECTED = 0x46;
R3.Event.MESH_FACE_SELECTED = 0x47;
R3.Event.MESH_SELECTED = 0x48;
R3.Event.MOUSE_DOWN = 0x49;
R3.Event.MOUSE_MOVE = 0x4a;
R3.Event.MOUSE_UP = 0x4b;
R3.Event.MOUSE_WHEEL = 0x4c;
R3.Event.MUTE_AUDIO = 0x4d;
R3.Event.NAME_UPDATE = 0x4e;
R3.Event.PARENT_SCENE_CHANGE = 0x4f;
R3.Event.PARENT_WORLD_CHANGE = 0x50;
R3.Event.PAUSE = 0x51;
R3.Event.PAUSE_ALL_AUDIO = 0x52;
R3.Event.PLAY_AUDIO = 0x53;
R3.Event.PROJECT_LOADED = 0x54;
R3.Event.QUERY_PARSED = 0x55;
R3.Event.RECEIVE_DESTINATION_CHANGED = 0x56;
R3.Event.REGISTER_DEPENDENCIES = 0x57;
R3.Event.REGISTER_UPDATE = 0x58;
R3.Event.REMOVE_COMPONENT = 0x59;
R3.Event.REMOVE_MESH = 0x5a;
R3.Event.REMOVE_PARTICLE_ENGINE = 0x5b;
R3.Event.RENDERER_SIZE_CHANGE = 0x5c;
R3.Event.REPLACE_COMPONENT = 0x5d;
R3.Event.RESOLVE_DEPENDENCIES = 0x5e;
R3.Event.RESTART = 0x5f;
R3.Event.SAVE_COMPONENT = 0x60;
R3.Event.SAVE_COMPONENT_ERROR = 0x61;
R3.Event.SAVING = 0x62;
R3.Event.SELECTION_MODE_CHANGE = 0x63;
R3.Event.SIGN_IN = 0x64;
R3.Event.SIGN_OUT = 0x65;
R3.Event.START = 0x66;
R3.Event.STOP_ALL_AUDIO = 0x67;
R3.Event.STOP_AUDIO = 0x68;
R3.Event.STOP_VISUALIZE = 0x69;
R3.Event.TEXTURE_ANIMATED_CHANGE = 0x6a;
R3.Event.TEXTURE_INSTANCE_UPDATED = 0x6b;
R3.Event.TOUCH_CANCEL = 0x6c;
R3.Event.TOUCH_END = 0x6d;
R3.Event.TOUCH_MOVE = 0x6e;
R3.Event.TOUCH_START = 0x6f;
R3.Event.UNRESOLVED_DEPENDENCIES_UPDATE = 0x70;
R3.Event.VISUALIZE = 0x71;
R3.Event.WINDOW_RESIZE = 0x72;
R3.Event.MAX_EVENTS = 0x73;
R3.Event.CANVAS_RESIZE = 0xf;
R3.Event.CAST_SOURCE_CHANGED = 0x10;
R3.Event.CLEAR_GUI = 0x11;
R3.Event.COMPILE_FAILED = 0x12;
R3.Event.COMPILE_SUCCESS = 0x13;
R3.Event.COMPONENTS_LINKED = 0x14;
R3.Event.COMPONENT_CLONED = 0x15;
R3.Event.COMPONENT_CREATED = 0x16;
R3.Event.COMPONENT_DELETED = 0x17;
R3.Event.COMPONENT_DOWNLOAD_COMPLETE = 0x18;
R3.Event.COMPONENT_LINKED = 0x19;
R3.Event.COMPONENT_REGISTER = 0x1a;
R3.Event.COMPONENT_REPLACED = 0x1b;
R3.Event.COMPONENT_SAVED = 0x1c;
R3.Event.COMPONENT_TYPES_UPDATE = 0x1d;
R3.Event.COMPONENT_UPDATE = 0x1e;
R3.Event.CONTINUE_ALL_AUDIO = 0x1f;
R3.Event.CONTROLS_CANVAS_CHANGE = 0x20;
R3.Event.DELETE_COMPONENT = 0x21;
R3.Event.DELETE_COMPONENT_ERROR = 0x22;
R3.Event.DONE_SAVING = 0x23;
R3.Event.ENGINE_FIRED_PARTICLES_ZERO = 0x24;
R3.Event.ENTITY_LOADED = 0x25;
R3.Event.EVENT_ID_UPDATE = 0x26;
R3.Event.EXCLUDE_FROM_ENVIRONMENT = 0x27;
R3.Event.FETCH_COMPONENTS = 0x28;
R3.Event.FETCH_COMPONENT_TYPES = 0x29;
R3.Event.GET_API_URL = 0x2a;
R3.Event.GET_APPLICATION_MODE = 0x2b;
R3.Event.GET_GRAPHICS_RUNTIME = 0x2c;
R3.Event.GET_PHYSICS_RUNTIME = 0x2d;
R3.Event.GET_PROJECT = 0x2e;
R3.Event.GET_PROJECTS = 0x2f;
R3.Event.GET_REMOTE_API_URL = 0x30;
R3.Event.GET_RENDER_CONFIGURATION = 0x31;
R3.Event.GET_RUNTIME = 0x32;
R3.Event.GET_USER = 0x33;
R3.Event.GET_WEBSOCKET_CONFIG = 0x34;
R3.Event.GET_WINDOW_SIZE = 0x35;
R3.Event.GUI_CREATED = 0x36;
R3.Event.GUI_REMOVED = 0x37;
R3.Event.IMAGE_UPLOAD_COMPLETE = 0x38;
R3.Event.INSTANCE_CLONED = 0x39;
R3.Event.INSTANCE_CREATED = 0x3a;
R3.Event.INSTANCE_DISPOSAL = 0x3b;
R3.Event.INSTANCE_LOADED = 0x3c;
R3.Event.KEY_DOWN = 0x3d;
R3.Event.KEY_UP = 0x3e;
R3.Event.LOAD_COMPONENT = 0x3f;
R3.Event.LOAD_COMPONENT_ERROR = 0x40;
R3.Event.LOAD_FONT = 0x41;
R3.Event.LOAD_IMAGE = 0x42;
R3.Event.LOAD_PROGRESS = 0x43;
R3.Event.MATERIAL_TEXTURES_UPDATED = 0x44;
R3.Event.MATERIAL_TYPE_CHANGED = 0x45;
R3.Event.MAXIMUM_PROJECTS = 0x46;
R3.Event.MESH_DESELECTED = 0x47;
R3.Event.MESH_FACE_DESELECTED = 0x48;
R3.Event.MESH_FACE_SELECTED = 0x49;
R3.Event.MESH_SELECTED = 0x4a;
R3.Event.MOUSE_DOWN = 0x4b;
R3.Event.MOUSE_MOVE = 0x4c;
R3.Event.MOUSE_UP = 0x4d;
R3.Event.MOUSE_WHEEL = 0x4e;
R3.Event.MUTE_AUDIO = 0x4f;
R3.Event.NAME_UPDATE = 0x50;
R3.Event.PARENT_SCENE_CHANGE = 0x51;
R3.Event.PARENT_WORLD_CHANGE = 0x52;
R3.Event.PAUSE = 0x53;
R3.Event.PAUSE_ALL_AUDIO = 0x54;
R3.Event.PLAY_AUDIO = 0x55;
R3.Event.PROJECT_LOADED = 0x56;
R3.Event.QUERY_PARSED = 0x57;
R3.Event.RECEIVE_DESTINATION_CHANGED = 0x58;
R3.Event.REGISTER_DEPENDENCIES = 0x59;
R3.Event.REGISTER_UPDATE = 0x5a;
R3.Event.REMOVE_COMPONENT = 0x5b;
R3.Event.REMOVE_MESH = 0x5c;
R3.Event.REMOVE_PARTICLE_ENGINE = 0x5d;
R3.Event.RENDERER_SIZE_CHANGE = 0x5e;
R3.Event.REPLACE_COMPONENT = 0x5f;
R3.Event.RESOLVE_DEPENDENCIES = 0x60;
R3.Event.RESTART = 0x61;
R3.Event.SAVE_COMPONENT = 0x62;
R3.Event.SAVE_COMPONENT_ERROR = 0x63;
R3.Event.SAVING = 0x64;
R3.Event.SELECTION_MODE_CHANGE = 0x65;
R3.Event.SIGN_IN = 0x66;
R3.Event.SIGN_OUT = 0x67;
R3.Event.START = 0x68;
R3.Event.STOP_ALL_AUDIO = 0x69;
R3.Event.STOP_AUDIO = 0x6a;
R3.Event.STOP_VISUALIZE = 0x6b;
R3.Event.TEXTURE_ANIMATED_CHANGE = 0x6c;
R3.Event.TEXTURE_INSTANCE_UPDATED = 0x6d;
R3.Event.TOUCH_CANCEL = 0x6e;
R3.Event.TOUCH_END = 0x6f;
R3.Event.TOUCH_MOVE = 0x70;
R3.Event.TOUCH_START = 0x71;
R3.Event.UNRESOLVED_DEPENDENCIES_UPDATE = 0x72;
R3.Event.VISUALIZE = 0x73;
R3.Event.WINDOW_RESIZE = 0x74;
R3.Event.MAX_EVENTS = 0x75;
/**
* R3.Event.GetEventName
@ -137,106 +139,108 @@ R3.Event.GetEventName = function(eventId) {
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 'clear_gui';
case 0x11 : return 'compile_failed';
case 0x12 : return 'compile_success';
case 0x13 : return 'components_linked';
case 0x14 : return 'component_cloned';
case 0x15 : return 'component_created';
case 0x16 : return 'component_deleted';
case 0x17 : return 'component_download_complete';
case 0x18 : return 'component_linked';
case 0x19 : return 'component_register';
case 0x1a : return 'component_replaced';
case 0x1b : return 'component_saved';
case 0x1c : return 'component_types_update';
case 0x1d : return 'component_update';
case 0x1e : return 'continue_all_audio';
case 0x1f : return 'controls_canvas_change';
case 0x20 : return 'delete_component';
case 0x21 : return 'delete_component_error';
case 0x22 : return 'done_saving';
case 0x23 : return 'engine_fired_particles_zero';
case 0x24 : return 'entity_loaded';
case 0x25 : return 'event_id_update';
case 0x26 : return 'exclude_from_environment';
case 0x27 : return 'fetch_components';
case 0x28 : return 'fetch_component_types';
case 0x29 : return 'get_api_url';
case 0x2a : return 'get_application_mode';
case 0x2b : return 'get_graphics_runtime';
case 0x2c : return 'get_physics_runtime';
case 0x2d : return 'get_project';
case 0x2e : return 'get_remote_api_url';
case 0x2f : return 'get_render_configuration';
case 0x30 : return 'get_runtime';
case 0x31 : return 'get_user';
case 0x32 : return 'get_websocket_config';
case 0x33 : return 'get_window_size';
case 0x34 : return 'gui_created';
case 0x35 : return 'gui_removed';
case 0x36 : return 'image_upload_complete';
case 0x37 : return 'instance_cloned';
case 0x38 : return 'instance_created';
case 0x39 : return 'instance_disposal';
case 0x3a : return 'instance_loaded';
case 0x3b : return 'key_down';
case 0x3c : return 'key_up';
case 0x3d : return 'load_component';
case 0x3e : return 'load_component_error';
case 0x3f : return 'load_font';
case 0x40 : return 'load_image';
case 0x41 : return 'load_progress';
case 0x42 : return 'material_textures_updated';
case 0x43 : return 'material_type_changed';
case 0x44 : return 'maximum_projects';
case 0x45 : return 'mesh_deselected';
case 0x46 : return 'mesh_face_deselected';
case 0x47 : return 'mesh_face_selected';
case 0x48 : return 'mesh_selected';
case 0x49 : return 'mouse_down';
case 0x4a : return 'mouse_move';
case 0x4b : return 'mouse_up';
case 0x4c : return 'mouse_wheel';
case 0x4d : return 'mute_audio';
case 0x4e : return 'name_update';
case 0x4f : return 'parent_scene_change';
case 0x50 : return 'parent_world_change';
case 0x51 : return 'pause';
case 0x52 : return 'pause_all_audio';
case 0x53 : return 'play_audio';
case 0x54 : return 'project_loaded';
case 0x55 : return 'query_parsed';
case 0x56 : return 'receive_destination_changed';
case 0x57 : return 'register_dependencies';
case 0x58 : return 'register_update';
case 0x59 : return 'remove_component';
case 0x5a : return 'remove_mesh';
case 0x5b : return 'remove_particle_engine';
case 0x5c : return 'renderer_size_change';
case 0x5d : return 'replace_component';
case 0x5e : return 'resolve_dependencies';
case 0x5f : return 'restart';
case 0x60 : return 'save_component';
case 0x61 : return 'save_component_error';
case 0x62 : return 'saving';
case 0x63 : return 'selection_mode_change';
case 0x64 : return 'sign_in';
case 0x65 : return 'sign_out';
case 0x66 : return 'start';
case 0x67 : return 'stop_all_audio';
case 0x68 : return 'stop_audio';
case 0x69 : return 'stop_visualize';
case 0x6a : return 'texture_animated_change';
case 0x6b : return 'texture_instance_updated';
case 0x6c : return 'touch_cancel';
case 0x6d : return 'touch_end';
case 0x6e : return 'touch_move';
case 0x6f : return 'touch_start';
case 0x70 : return 'unresolved_dependencies_update';
case 0x71 : return 'visualize';
case 0x72 : return 'window_resize';
case 0xf : return 'canvas_resize';
case 0x10 : return 'cast_source_changed';
case 0x11 : return 'clear_gui';
case 0x12 : return 'compile_failed';
case 0x13 : return 'compile_success';
case 0x14 : return 'components_linked';
case 0x15 : return 'component_cloned';
case 0x16 : return 'component_created';
case 0x17 : return 'component_deleted';
case 0x18 : return 'component_download_complete';
case 0x19 : return 'component_linked';
case 0x1a : return 'component_register';
case 0x1b : return 'component_replaced';
case 0x1c : return 'component_saved';
case 0x1d : return 'component_types_update';
case 0x1e : return 'component_update';
case 0x1f : return 'continue_all_audio';
case 0x20 : return 'controls_canvas_change';
case 0x21 : return 'delete_component';
case 0x22 : return 'delete_component_error';
case 0x23 : return 'done_saving';
case 0x24 : return 'engine_fired_particles_zero';
case 0x25 : return 'entity_loaded';
case 0x26 : return 'event_id_update';
case 0x27 : return 'exclude_from_environment';
case 0x28 : return 'fetch_components';
case 0x29 : return 'fetch_component_types';
case 0x2a : return 'get_api_url';
case 0x2b : return 'get_application_mode';
case 0x2c : return 'get_graphics_runtime';
case 0x2d : return 'get_physics_runtime';
case 0x2e : return 'get_project';
case 0x2f : return 'get_projects';
case 0x30 : return 'get_remote_api_url';
case 0x31 : return 'get_render_configuration';
case 0x32 : return 'get_runtime';
case 0x33 : return 'get_user';
case 0x34 : return 'get_websocket_config';
case 0x35 : return 'get_window_size';
case 0x36 : return 'gui_created';
case 0x37 : return 'gui_removed';
case 0x38 : return 'image_upload_complete';
case 0x39 : return 'instance_cloned';
case 0x3a : return 'instance_created';
case 0x3b : return 'instance_disposal';
case 0x3c : return 'instance_loaded';
case 0x3d : return 'key_down';
case 0x3e : return 'key_up';
case 0x3f : return 'load_component';
case 0x40 : return 'load_component_error';
case 0x41 : return 'load_font';
case 0x42 : return 'load_image';
case 0x43 : return 'load_progress';
case 0x44 : return 'material_textures_updated';
case 0x45 : return 'material_type_changed';
case 0x46 : return 'maximum_projects';
case 0x47 : return 'mesh_deselected';
case 0x48 : return 'mesh_face_deselected';
case 0x49 : return 'mesh_face_selected';
case 0x4a : return 'mesh_selected';
case 0x4b : return 'mouse_down';
case 0x4c : return 'mouse_move';
case 0x4d : return 'mouse_up';
case 0x4e : return 'mouse_wheel';
case 0x4f : return 'mute_audio';
case 0x50 : return 'name_update';
case 0x51 : return 'parent_scene_change';
case 0x52 : return 'parent_world_change';
case 0x53 : return 'pause';
case 0x54 : return 'pause_all_audio';
case 0x55 : return 'play_audio';
case 0x56 : return 'project_loaded';
case 0x57 : return 'query_parsed';
case 0x58 : return 'receive_destination_changed';
case 0x59 : return 'register_dependencies';
case 0x5a : return 'register_update';
case 0x5b : return 'remove_component';
case 0x5c : return 'remove_mesh';
case 0x5d : return 'remove_particle_engine';
case 0x5e : return 'renderer_size_change';
case 0x5f : return 'replace_component';
case 0x60 : return 'resolve_dependencies';
case 0x61 : return 'restart';
case 0x62 : return 'save_component';
case 0x63 : return 'save_component_error';
case 0x64 : return 'saving';
case 0x65 : return 'selection_mode_change';
case 0x66 : return 'sign_in';
case 0x67 : return 'sign_out';
case 0x68 : return 'start';
case 0x69 : return 'stop_all_audio';
case 0x6a : return 'stop_audio';
case 0x6b : return 'stop_visualize';
case 0x6c : return 'texture_animated_change';
case 0x6d : return 'texture_instance_updated';
case 0x6e : return 'touch_cancel';
case 0x6f : return 'touch_end';
case 0x70 : return 'touch_move';
case 0x71 : return 'touch_start';
case 0x72 : return 'unresolved_dependencies_update';
case 0x73 : return 'visualize';
case 0x74 : return 'window_resize';
default :
throw new Error('Event type not defined : ' + eventId);
}

View File

@ -17,6 +17,7 @@ R3.System.Storage = function() {
this.signInSubscription = null;
this.signOutSubscription = null;
this.saveSubscription = null;
this.getProjectsSubscription = null;
this.savedSubscription = null;
this.savedErrorSubscription = null;
@ -56,6 +57,11 @@ R3.System.Storage.prototype.start = function() {
this.save.bind(this)
);
this.getProjectsSubscription = R3.Event.Subscribe(
R3.Event.GET_PROJECTS,
this.getProjects.bind(this)
);
//
// this.loadSubscription = this.subscribe(
// R3.Event.LOAD_COMPONENT,
@ -264,6 +270,69 @@ R3.System.Storage.prototype.delete = function(data) {
};
/**
* Gets a list of projects
* @param data
* @param callback
* @param errorCallback
*/
R3.System.Storage.prototype.getProjects = function(data, callback, errorCallback) {
if (typeof XMLHttpRequest === 'undefined') {
console.log('Implement server side save here');
return;
}
var apiUrl = null;
var apiAuthorization = null;
var event = R3.Event.GET_API_URL;
if (data.remote) {
event = R3.Event.GET_REMOTE_API_URL
}
R3.Event.Emit(
event,
null,
function(urlData) {
apiUrl = urlData.apiUrl;
apiAuthorization = urlData.apiAuthorization;
}
);
var xhr = new XMLHttpRequest();
xhr.open(
'GET',
apiUrl + '/project/list'
);
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("x-api-authorization", apiAuthorization);
xhr.setRequestHeader('x-api-user-token', this.apiUserToken);
xhr.onload = function () {
var response = JSON.parse(xhr.responseText);
if (response.result === 'success') {
callback(response);
} else {
errorCallback(response);
}
};
xhr.send();
};
/**
* 'Saves' data to somewhere
*/
@ -1230,6 +1299,7 @@ R3.System.Storage.prototype.stop = function() {
this.loadSubscription.remove();
this.signOutSubscription.remove();
this.saveSubscription.remove();
this.getProjectsSubscription.remove();
this.loaded = [];
this.failed = [];