Bläddra i källkod

Add initial ts definitions

Garrett Johnson 5 år sedan
förälder
incheckning
da596a6df4

+ 19 - 9
example/index.js

@@ -1,4 +1,14 @@
-import { DebugTilesRenderer as TilesRenderer } from '../src/index.js';
+import {
+	DebugTilesRenderer as TilesRenderer,
+	DEFAULT,
+	SCREEN_ERROR,
+	GEOMETRIC_ERROR,
+	DISTANCE,
+	DEPTH,
+	RELATIVE_DEPTH,
+	IS_LEAF,
+	RANDOM_COLOR,
+} from '../src/index.js';
 import {
 	Scene,
 	DirectionalLight,
@@ -208,14 +218,14 @@ function init() {
 	debug.add( params, 'displayBoxBounds' );
 	debug.add( params, 'colorMode', {
 
-		DEFAULT: 0,
-		SCREEN_ERROR: 1,
-		GEOMETRIC_ERROR: 2,
-		DISTANCE: 3,
-		DEPTH: 4,
-		RELATIVE_DEPTH: 5,
-		IS_LEAF: 6,
-		RANDOM_COLOR: 7,
+		DEFAULT,
+		SCREEN_ERROR,
+		GEOMETRIC_ERROR,
+		DISTANCE,
+		DEPTH,
+		RELATIVE_DEPTH,
+		IS_LEAF,
+		RANDOM_COLOR,
 
 	} );
 	debug.open();

+ 15 - 0
src/base/B3DMLoaderBase.d.ts

@@ -0,0 +1,15 @@
+export interface B3DMResult {
+
+	version : String;
+	featureTable: Object;
+	batchTable : Object;
+	glbBytes : Uint8Array;
+
+}
+
+export class B3DMLoaderBase {
+
+	load( url : string ) : Promise< B3DMResult >;
+	parse( buffer : ArrayBuffer ) : B3DMResult;
+
+}

+ 21 - 2
src/index.js

@@ -1,4 +1,14 @@
-import { DebugTilesRenderer } from './three/DebugTilesRenderer.js';
+import {
+	DebugTilesRenderer,
+	DEFAULT,
+	SCREEN_ERROR,
+	GEOMETRIC_ERROR,
+	DISTANCE,
+	DEPTH,
+	RELATIVE_DEPTH,
+	IS_LEAF,
+	RANDOM_COLOR,
+} from './three/DebugTilesRenderer.js';
 import { TilesRenderer } from './three/TilesRenderer.js';
 import { B3DMLoader } from './three/B3DMLoader.js';
 
@@ -17,5 +27,14 @@ export {
 	B3DMLoaderBase,
 
 	LRUCache,
-	PriorityQueue
+	PriorityQueue,
+
+	DEFAULT,
+	SCREEN_ERROR,
+	GEOMETRIC_ERROR,
+	DISTANCE,
+	DEPTH,
+	RELATIVE_DEPTH,
+	IS_LEAF,
+	RANDOM_COLOR,
 };

+ 16 - 0
src/three/B3DMLoader.d.ts

@@ -0,0 +1,16 @@
+import { B3MLoaderBase } from '../base/B3DMLoaderBase';
+import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
+
+export interface B3DMResult extends GLTF {
+
+	batchTable : Object;
+	featureTable : Object;
+
+}
+
+export class B3DMLoader extends B3MLoaderBase {
+
+	load( url : String ) : Promise< B3DMResult >;
+	parse( buffer : ArrayBuffer ) : B3DMResult;
+
+}

+ 9 - 9
src/three/DebugTilesRenderer.js

@@ -4,17 +4,17 @@ import { SphereHelper } from './SphereHelper.js';
 
 const ORIGINAL_MATERIAL = Symbol( 'ORIGINAL_MATERIAL' );
 
-const NONE = 0;
-const SCREEN_ERROR = 1;
-const GEOMETRIC_ERROR = 2;
-const DISTANCE = 3;
-const DEPTH = 4;
-const RELATIVE_DEPTH = 5;
-const IS_LEAF = 6;
-const RANDOM_COLOR = 7;
-
 function emptyRaycast() {}
 
+export const NONE = 0;
+export const SCREEN_ERROR = 1;
+export const GEOMETRIC_ERROR = 2;
+export const DISTANCE = 3;
+export const DEPTH = 4;
+export const RELATIVE_DEPTH = 5;
+export const IS_LEAF = 6;
+export const RANDOM_COLOR = 7;
+
 export class DebugTilesRenderer extends TilesRenderer {
 
 	constructor( ...args ) {

+ 18 - 0
src/utilities/LRUCache.d.ts

@@ -0,0 +1,18 @@
+export class LRUCache {
+
+	maxSize : Number;
+	minSize : Number;
+	unloadPercent : Number;
+	unloadPriorityCallback : ( item : any ) => Number;
+
+	isFull() : Boolean;
+	add( item : any, callback : ( item : any ) => Number ) : Boolean;
+	remove( item : any ) : Boolean;
+
+	markUsed( item : any ) : void;
+	markAllUnused() : void;
+
+	unloadUnusedContent() : void;
+	scheduleUnload( markAllUnused : Boolean = true );
+
+}

+ 14 - 0
src/utilities/PriorityQueue.d.ts

@@ -0,0 +1,14 @@
+export class PriorityQueue {
+
+	maxJobs : Number;
+	autoUpdate : Boolean;
+	priorityCallback : ( item : any ) => Number;
+
+	sort() : void;
+	add( item : any, callback : ( item : any ) => any ) : Promise< any >;
+	remove( item : any ) : void;
+
+	tryRunJobs() : void;
+	scheduleJobRun() : void;
+
+}