浏览代码

updated VR example with custom schedulingCallback

Bruno Fanini 3 年之前
父节点
当前提交
9d7e759ee8
共有 3 个文件被更改,包括 16 次插入2 次删除
  1. 13 0
      example/vr.js
  2. 1 1
      src/utilities/PriorityQueue.d.ts
  3. 2 1
      src/utilities/PriorityQueue.js

+ 13 - 0
example/vr.js

@@ -102,6 +102,19 @@ function init() {
 	tiles = new TilesRenderer( '../data/tileset.json' );
 	offsetParent.add( tiles.group );
 
+
+	// We define a custom scheduling callback to handle also active WebXR sessions
+	const tilesSchedulingCB = func => {
+
+		setTimeout( func, 50 );
+
+	};
+
+	// We set our scheduling callback for tiles downloading and parsing
+	tiles.downloadQueue.schedulingCallback = tilesSchedulingCB;
+	tiles.parseQueue.schedulingCallback = tilesSchedulingCB;
+
+
 	// Raycasting init
 	raycaster = new Raycaster();
 	fwdVector = new Vector3( 0, 0, 1 );

+ 1 - 1
src/utilities/PriorityQueue.d.ts

@@ -4,7 +4,7 @@ export class PriorityQueue {
 	autoUpdate : Boolean;
 	priorityCallback : ( itemA : any , itemB : any ) => Number;
 	
-	schedulingCallback : ( func : Function ) : void;
+	schedulingCallback : ( func : Function ) => void;
 
 	sort() : void;
 	add( item : any, callback : ( item : any ) => any ) : Promise< any >;

+ 2 - 1
src/utilities/PriorityQueue.js

@@ -122,13 +122,14 @@ class PriorityQueue {
 
 	scheduleJobRun() {
 
-		if ( ! this.scheduled ){
+		if ( ! this.scheduled ) {
 
 			this.schedulingCallback( this._runjobs );
 
 			this.scheduled = true;
 
 		}
+
 	}
 
 }