Skip to content

Commit

Permalink
Support XR
Browse files Browse the repository at this point in the history
  • Loading branch information
fedegratti committed May 14, 2022
1 parent 6f48087 commit 97d4422
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v6.9.0
v6.10.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ohzi-core",
"version": "6.9.0",
"version": "6.10.0",
"description": "OHZI Core Library",
"source": "src/index.js",
"module": "build/index.module.js",
Expand Down
11 changes: 9 additions & 2 deletions src/Graphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ class Graphics
premultipliedAlpha: true,
preserveDrawingBuffer: true,
powerPreference: 'high-performance',
logarithmicDepthBuffer: false
logarithmicDepthBuffer: false,
force_webgl2: true,
xr_enabled: false
};

Object.assign(this.context_attributes, context_attributes);

if (context_attributes.force_webgl2)
if (this.context_attributes.force_webgl2)
{
this.canvas_context = canvas.getContext('webgl2', this.context_attributes) ||
canvas.getContext('webgl', this.context_attributes) ||
Expand All @@ -60,6 +62,11 @@ class Graphics
context: this.canvas_context
});

if (this.context_attributes.xr_enabled)
{
this._renderer.xr.enabled = true;
}

this._renderer.autoClear = false;

this._renderer.setPixelRatio(1);
Expand Down
8 changes: 3 additions & 5 deletions src/RenderLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ export default class RenderLoop
{
target_application = target_application || new BaseApplication();

this._frame_id = -1;

this.target_application = target_application;
this.graphics = graphics;

Expand Down Expand Up @@ -50,7 +48,6 @@ export default class RenderLoop

// ###### END CYCLE #######

this._frame_id = requestAnimationFrame(this.update.bind(this));
this.target_application.on_frame_end();
this.frames_passed++;

Expand All @@ -69,7 +66,8 @@ export default class RenderLoop
}

this.is_running = true;
this.update();

this.graphics._renderer.setAnimationLoop(this.update.bind(this));
}

stop()
Expand All @@ -79,7 +77,7 @@ export default class RenderLoop
this.is_running = false;
this.target_application.on_exit();

cancelAnimationFrame(this._frame_id);
this.graphics._renderer.setAnimationLoop(null);
}

set_state(new_state)
Expand Down
1 change: 0 additions & 1 deletion types/RenderLoop.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export class RenderLoop {
constructor(target_application: any, graphics: any);
_frame_id: number;
target_application: any;
graphics: any;
is_running: boolean;
Expand Down

0 comments on commit 97d4422

Please sign in to comment.