ohzi-core 6.6.0 → 6.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ohzi-core",
3
- "version": "6.6.0",
3
+ "version": "6.8.0",
4
4
  "description": "OHZI Core Library",
5
5
  "source": "src/index.js",
6
6
  "module": "build/index.module.js",
@@ -180,7 +180,7 @@ export default class UIElement extends Mesh
180
180
  {
181
181
  this.material.uniforms._MainTex.value.dispose();
182
182
  }
183
- // Screen.remove_screen_material(this.material);
183
+ // OScreen.remove_screen_material(this.material);
184
184
  this.geometry.dispose();
185
185
  this.material.dispose();
186
186
  }
@@ -1,40 +1,20 @@
1
1
  import AbstractLoader from './AbstractLoader';
2
2
 
3
- import { FileLoader as THREEFileLoader } from 'three';
4
-
5
3
  export default class JSONLoader extends AbstractLoader
6
4
  {
7
5
  constructor(resource_id, url, size)
8
6
  {
9
7
  super(resource_id, url, size);
10
-
11
- this.loader = new THREEFileLoader();
12
8
  }
13
9
 
14
- on_preloaded_finished(resource_container)
10
+ on_preloaded_finished(resource_container, response)
15
11
  {
16
- const ctx = this;
17
-
18
- this.loader.load(this.url, (data) =>
12
+ response.json().then((json) =>
19
13
  {
20
- resource_container.set_resource(ctx.resource_id, ctx.url, JSON.parse(data));
14
+ resource_container.set_resource(this.resource_id, this.url, json);
21
15
 
22
- ctx.__update_downloaded_bytes(1, 1);
23
- ctx.__loading_ended();
24
- },
25
- (xhr) =>
26
- {
27
- // if (xhr)
28
- // {
29
- // let total = xhr.total || this.total_bytes;
30
- // ctx.__update_downloaded_bytes(xhr.loaded, total);
31
- // }
32
- },
33
- (msg) =>
34
- {
35
- ctx.__set_error(msg + '\n\n\t If the error says something about unexpected token < in JSON then the probably the problem is related to the file not being found. Check the name and path of the resource');
36
- ctx.__loading_ended();
37
- }
38
- );
16
+ this.__update_downloaded_bytes(1, 1);
17
+ this.__loading_ended();
18
+ });
39
19
  }
40
20
  }
@@ -1,5 +1,4 @@
1
1
  import ResourceContainer from '../ResourceContainer';
2
- import DrawIOAnimationSheet from './transition/DrawIOAnimationSheet';
3
2
  import ViewManager from './ViewManager';
4
3
  import ViewState from './ViewState';
5
4
 
@@ -12,7 +11,12 @@ export default class ApplicationView extends ViewState
12
11
  this.container = container;
13
12
  this.url = url;
14
13
 
15
- const transition_data = new DrawIOAnimationSheet().parse(ResourceContainer.get(`${name}_data`));
14
+ let transition_data = ResourceContainer.get(`${name}_data`);
15
+
16
+ transition_data = transition_data || {
17
+ animation_tracks: [],
18
+ triggers: []
19
+ };
16
20
 
17
21
  const transitions = [
18
22
  {
@@ -11,6 +11,8 @@ class ViewManager
11
11
  this.transition_handler = new ViewStateTransitionHandler(this.transition_table);
12
12
 
13
13
  this.view_change_subscribers = [];
14
+
15
+ this.browser_title_suffix = '';
14
16
  }
15
17
 
16
18
  update()
@@ -28,6 +30,7 @@ class ViewManager
28
30
  if (change_url)
29
31
  {
30
32
  this.__change_browser_url(v.url);
33
+ this.__change_browser_title(v.url);
31
34
  }
32
35
 
33
36
  this.notify_view_change(view_name);
@@ -81,6 +84,11 @@ class ViewManager
81
84
  this.transition_handler.set_state(view);
82
85
  }
83
86
 
87
+ set_browser_title_suffix(title_suffix)
88
+ {
89
+ this.browser_title_suffix = title_suffix;
90
+ }
91
+
84
92
  get_current_view()
85
93
  {
86
94
  return this.transition_handler.current_state;
@@ -135,6 +143,13 @@ class ViewManager
135
143
  window.history.pushState('', '', url);
136
144
  }
137
145
 
146
+ __change_browser_title(name)
147
+ {
148
+ const title = this.__capitalize(name);
149
+
150
+ document.title = title ? `${title} | ${this.browser_title_suffix}` : this.browser_title_suffix;
151
+ }
152
+
138
153
  __set_views_opacities()
139
154
  {
140
155
  for (let i = 0; i < this.views.length; i++)
@@ -142,6 +157,24 @@ class ViewManager
142
157
  this.views[i].set_opacity(this.transition_handler.current_state_data);
143
158
  }
144
159
  }
160
+
161
+ __capitalize(string)
162
+ {
163
+ let aux_string = string.toUpperCase().replace('/', '');
164
+ aux_string = this.__snake_to_whitespace(aux_string);
165
+
166
+ return aux_string;
167
+ }
168
+
169
+ __snake_to_whitespace(string)
170
+ {
171
+ return string.replace(
172
+ /([-_][A-Z])/g,
173
+ (group) => group
174
+ .replace('-', ' ')
175
+ .replace('_', ' ')
176
+ );
177
+ }
145
178
  }
146
179
 
147
180
  export default new ViewManager();