ohzi-core 6.7.0 → 6.10.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.7.0",
3
+ "version": "6.10.0",
4
4
  "description": "OHZI Core Library",
5
5
  "source": "src/index.js",
6
6
  "module": "build/index.module.js",
package/src/Graphics.js CHANGED
@@ -34,12 +34,14 @@ class Graphics
34
34
  premultipliedAlpha: true,
35
35
  preserveDrawingBuffer: true,
36
36
  powerPreference: 'high-performance',
37
- logarithmicDepthBuffer: false
37
+ logarithmicDepthBuffer: false,
38
+ force_webgl2: true,
39
+ xr_enabled: false
38
40
  };
39
41
 
40
42
  Object.assign(this.context_attributes, context_attributes);
41
43
 
42
- if (context_attributes.force_webgl2)
44
+ if (this.context_attributes.force_webgl2)
43
45
  {
44
46
  this.canvas_context = canvas.getContext('webgl2', this.context_attributes) ||
45
47
  canvas.getContext('webgl', this.context_attributes) ||
@@ -60,6 +62,11 @@ class Graphics
60
62
  context: this.canvas_context
61
63
  });
62
64
 
65
+ if (this.context_attributes.xr_enabled)
66
+ {
67
+ this._renderer.xr.enabled = true;
68
+ }
69
+
63
70
  this._renderer.autoClear = false;
64
71
 
65
72
  this._renderer.setPixelRatio(1);
package/src/RenderLoop.js CHANGED
@@ -12,8 +12,6 @@ export default class RenderLoop
12
12
  {
13
13
  target_application = target_application || new BaseApplication();
14
14
 
15
- this._frame_id = -1;
16
-
17
15
  this.target_application = target_application;
18
16
  this.graphics = graphics;
19
17
 
@@ -50,7 +48,6 @@ export default class RenderLoop
50
48
 
51
49
  // ###### END CYCLE #######
52
50
 
53
- this._frame_id = requestAnimationFrame(this.update.bind(this));
54
51
  this.target_application.on_frame_end();
55
52
  this.frames_passed++;
56
53
 
@@ -69,7 +66,8 @@ export default class RenderLoop
69
66
  }
70
67
 
71
68
  this.is_running = true;
72
- this.update();
69
+
70
+ this.graphics._renderer.setAnimationLoop(this.update.bind(this));
73
71
  }
74
72
 
75
73
  stop()
@@ -79,7 +77,7 @@ export default class RenderLoop
79
77
  this.is_running = false;
80
78
  this.target_application.on_exit();
81
79
 
82
- cancelAnimationFrame(this._frame_id);
80
+ this.graphics._renderer.setAnimationLoop(null);
83
81
  }
84
82
 
85
83
  set_state(new_state)
@@ -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
  }
package/src/index.js CHANGED
@@ -100,6 +100,7 @@ import OBJLoader from './resource_loader/OBJLoader';
100
100
  import PointArrayLoader from './resource_loader/PointArrayLoader';
101
101
  import RGBETextureLoader from './resource_loader/RGBETextureLoader';
102
102
  import TextLoader from './resource_loader/TextLoader';
103
+ import AsyncTextureLoader from './resource_loader/AsyncTextureLoader';
103
104
  import TextureLoader from './resource_loader/TextureLoader';
104
105
  import VideoLoader from './resource_loader/VideoLoader';
105
106
 
@@ -205,6 +206,7 @@ export {
205
206
  PointArrayLoader,
206
207
  RGBETextureLoader,
207
208
  TextLoader,
209
+ AsyncTextureLoader,
208
210
  TextureLoader,
209
211
  VideoLoader,
210
212
 
@@ -0,0 +1,35 @@
1
+ import AbstractLoader from './AbstractLoader';
2
+
3
+ import { Texture } from 'three';
4
+
5
+ export default class AsyncTextureLoader extends AbstractLoader
6
+ {
7
+ constructor(resource_id, url, size)
8
+ {
9
+ super(resource_id, url, size);
10
+ }
11
+
12
+ on_preloaded_finished(resource_container)
13
+ {
14
+ const texture = new Texture();
15
+ const image = new Image();
16
+
17
+ image.src = this.url;
18
+
19
+ image.onload = () =>
20
+ {
21
+ texture.image = image;
22
+ texture.needsUpdate = true;
23
+
24
+ resource_container.set_resource(this.resource_id, this.url, texture);
25
+
26
+ this.__update_downloaded_bytes(1, 1);
27
+ this.__loading_ended();
28
+ };
29
+
30
+ image.onerror = () =>
31
+ {
32
+ console.error('Error loading texture. Maybe the resource is not an image?', this.url);
33
+ };
34
+ }
35
+ }
@@ -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
  {
@@ -1,6 +1,5 @@
1
1
  export class RenderLoop {
2
2
  constructor(target_application: any, graphics: any);
3
- _frame_id: number;
4
3
  target_application: any;
5
4
  graphics: any;
6
5
  is_running: boolean;
@@ -0,0 +1,6 @@
1
+ import { AbstractLoader } from "./AbstractLoader";
2
+
3
+ export class AsyncTextureLoader extends AbstractLoader {
4
+ constructor(resource_id: any, url: any, size: any);
5
+ loader: any;
6
+ }
@@ -1,6 +1,6 @@
1
1
  import { AbstractLoader } from "./AbstractLoader";
2
2
 
3
3
  export class BasisLoader extends AbstractLoader {
4
- constructor(resource_id: any, url: any, renderer: any, loader: any, size: any);
4
+ constructor(resource_id: any, url: any, loader: any, size: any);
5
5
  loader: any;
6
6
  }