@jdultra/threedtiles 12.0.0 → 13.0.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.
@@ -3,37 +3,37 @@
3
3
  * @class
4
4
  * @extends {THREE.Object3D}
5
5
  */
6
- export class OGC3DTile {
6
+ export class OGC3DTile extends THREE.Object3D<THREE.Object3DEventMap> {
7
7
  /**
8
8
  * @param {Object} [properties] - the properties for this tileset
9
9
  * @param {String} [properties.url] - the url to the parent tileset.json
10
- * @param {Object} [properties.queryParams] - optional, path params to add to individual tile urls
11
- * @param {Number} [properties.geometricErrorMultiplier] - the geometric error of the parent. 1.0 by default corresponds to a maxScreenSpaceError of 16
12
- * @param {Boolean} [properties.loadOutsideView] - if truthy, tiles otside the camera frustum will be loaded with the least possible amount of detail
13
- * @param {TileLoader} [properties.tileLoader] - A tile loader that can be shared among tilesets in order to share a common cache.
14
- * @param {Function} [properties.meshCallback] - A callback function that will be called on every mesh
15
- * @param {Function} [properties.pointsCallback] - A callback function that will be called on every points
16
- * @param {Function} [properties.onLoadCallback] - A callback function that will be called when the root tile has been loaded
17
- * @param {OcclusionCullingService} [properties.occlusionCullingService] - A service that handles occlusion culling
18
- * @param {Boolean} [properties.centerModel] - If true, the tileset will be centered on 0,0,0 and in the case of georeferenced tilesets that use the "region" bounding volume, it will also be rotated so that the up axis matched the world y axis.
19
- * @param {Boolean} [properties.static] - If true, the tileset is considered static which improves performance but the matrices aren't automatically updated
20
- * @param {String} [properties.rootPath] - optional the root path for fetching children
21
- * @param {String} [properties.json] - optional json object representing the tileset sub-tree
22
- * @param {Number} [properties.parentGeometricError] - optional geometric error of the parent
23
- * @param {Object} [properties.parentBoundingVolume] - optional bounding volume of the parent
24
- * @param {String} [properties.parentRefine] - optional refine strategy of the parent of the parent
25
- * @param {THREE.Camera} [properties.cameraOnLoad] - optional the camera used when loading this particular sub-tile
26
- * @param {OGC3DTile} [properties.parentTile] - optional the OGC3DTile object that loaded this tile as a child
27
- * @param {String} [properties.proxy] - optional the url to a proxy service. Instead of fetching tiles via a GET request, a POST will be sent to the proxy url with the real tile address in the body of the request.
28
- * @param {Boolean} [properties.displayErrors] - optional value indicating that errors should be shown on screen.
29
- * @param {THREE.Renderer} [properties.renderer] - optional the renderer used to display the tileset. Used to infer render resolution at runtime and to instantiate a ktx2loader on the fly if not provided.
30
- * @param {Number} [properties.domWidth] - optional the canvas width (used to calculate geometric error). If a renderer is provided, it'll be used instead, else a default value is used.
31
- * @param {Number} [properties.domHeight] - optional the canvas height (used to calculate geometric error). If a renderer is provided, it'll be used instead, else a default value is used.
32
- * @param {DracoLoader} [properties.dracoLoader] - optional a draco loader (three/addons).
33
- * @param {KTX2Loader} [properties.ktx2Loader] - optional a ktx2 loader (three/addons).
34
- * @param {Number} [properties.distanceBias] - optional a bias that allows loading more or less detail closer to the camera relative to far away. The value should be a positive number. A value below 1 loads less detail near the camera and a value above 1 loads more detail near the camera. This needs to be compensated by the geometricErrorMultiplier in order to load a reasonable number of tiles.
35
- * @param {String} [properties.loadingStrategy] - optional a strategy for loading tiles "INCREMENTAL" loads intermediate LODs while "IMMEDIATE" skips intermediate LODs.
36
- * @param {String} [properties.drawBoundingVolume] - optional draws the bounding volume (may cause flickering)
10
+ * @param {Object} [properties.queryParams = undefined] - optional, path params to add to individual tile urls
11
+ * @param {Number} [properties.geometricErrorMultiplier = 1] - the geometric error of the parent. 1.0 by default corresponds to a maxScreenSpaceError of 16
12
+ * @param {Boolean} [properties.loadOutsideView = false] - if truthy, tiles otside the camera frustum will be loaded with the least possible amount of detail
13
+ * @param {TileLoader} [properties.tileLoader = undefined] - A tile loader that can be shared among tilesets in order to share a common cache.
14
+ * @param {Function} [properties.meshCallback = undefined] - A callback function that will be called on every mesh
15
+ * @param {Function} [properties.pointsCallback = undefined] - A callback function that will be called on every points
16
+ * @param {Function} [properties.onLoadCallback = undefined] - A callback function that will be called when the root tile has been loaded
17
+ * @param {OcclusionCullingService} [properties.occlusionCullingService = undefined] - A service that handles occlusion culling
18
+ * @param {Boolean} [properties.centerModel = false] - If true, the tileset will be centered on 0,0,0 and in the case of georeferenced tilesets that use the "region" bounding volume, it will also be rotated so that the up axis matched the world y axis.
19
+ * @param {Boolean} [properties.static = false] - If true, the tileset is considered static which improves performance but the matrices aren't automatically updated
20
+ * @param {String} [properties.rootPath = undefined] - optional the root path for fetching children
21
+ * @param {String} [properties.json = undefined] - optional json object representing the tileset sub-tree
22
+ * @param {Number} [properties.parentGeometricError = undefined] - optional geometric error of the parent
23
+ * @param {Object} [properties.parentBoundingVolume = undefined] - optional bounding volume of the parent
24
+ * @param {String} [properties.parentRefine = undefined] - optional refine strategy of the parent of the parent
25
+ * @param {THREE.Camera} [properties.cameraOnLoad = undefined] - optional the camera used when loading this particular sub-tile
26
+ * @param {OGC3DTile} [properties.parentTile = undefined] - optional the OGC3DTile object that loaded this tile as a child
27
+ * @param {String} [properties.proxy = undefined] - optional the url to a proxy service. Instead of fetching tiles via a GET request, a POST will be sent to the proxy url with the real tile address in the body of the request.
28
+ * @param {Boolean} [properties.displayErrors = false] - optional value indicating that errors should be shown on screen.
29
+ * @param {THREE.Renderer} [properties.renderer = undefined] - optional the renderer used to display the tileset. Used to infer render resolution at runtime and to instantiate a ktx2loader on the fly if not provided.
30
+ * @param {Number} [properties.domWidth = undefined] - optional the canvas width (used to calculate geometric error). If a renderer is provided, it'll be used instead, else a default value is used.
31
+ * @param {Number} [properties.domHeight = undefined] - optional the canvas height (used to calculate geometric error). If a renderer is provided, it'll be used instead, else a default value is used.
32
+ * @param {DracoLoader} [properties.dracoLoader = undefined] - optional a draco loader (three/addons).
33
+ * @param {KTX2Loader} [properties.ktx2Loader = undefined] - optional a ktx2 loader (three/addons).
34
+ * @param {Number} [properties.distanceBias = 1] - optional a bias that allows loading more or less detail closer to the camera relative to far away. The value should be a positive number. A value below 1 loads less detail near the camera and a value above 1 loads more detail near the camera. This needs to be compensated by the geometricErrorMultiplier in order to load a reasonable number of tiles.
35
+ * @param {String} [properties.loadingStrategy = "INCREMENTAL"] - optional a strategy for loading tiles "INCREMENTAL" loads intermediate LODs while "IMMEDIATE" skips intermediate LODs.
36
+ * @param {String} [properties.drawBoundingVolume = false] - optional draws the bounding volume (may cause flickering)
37
37
  */
38
38
  constructor(properties?: {
39
39
  url?: string | undefined;
@@ -52,11 +52,11 @@ export class OGC3DTile {
52
52
  parentGeometricError?: number | undefined;
53
53
  parentBoundingVolume?: Object | undefined;
54
54
  parentRefine?: string | undefined;
55
- cameraOnLoad?: any;
55
+ cameraOnLoad?: THREE.Camera | undefined;
56
56
  parentTile?: OGC3DTile | undefined;
57
57
  proxy?: string | undefined;
58
58
  displayErrors?: boolean | undefined;
59
- renderer?: any;
59
+ renderer?: THREE.Renderer | undefined;
60
60
  domWidth?: number | undefined;
61
61
  domHeight?: number | undefined;
62
62
  dracoLoader?: any;
@@ -65,8 +65,9 @@ export class OGC3DTile {
65
65
  loadingStrategy?: string | undefined;
66
66
  drawBoundingVolume?: string | undefined;
67
67
  } | undefined);
68
+ splatsMesh: any;
68
69
  contentURL: any[];
69
- rendererSize: any;
70
+ rendererSize: THREE.Vector2;
70
71
  loadingStrategy: string;
71
72
  distanceBias: number;
72
73
  proxy: string | undefined;
@@ -96,17 +97,17 @@ export class OGC3DTile {
96
97
  percentageLoaded: number;
97
98
  };
98
99
  geometricErrorMultiplier: number;
99
- renderer: any;
100
+ splatsCropRadius: number;
101
+ splatsSizeMultiplier: number;
102
+ renderer: THREE.Renderer | undefined;
100
103
  meshCallback: Function | undefined;
101
104
  loadOutsideView: boolean | undefined;
102
- cameraOnLoad: any;
105
+ cameraOnLoad: THREE.Camera | undefined;
103
106
  parentTile: OGC3DTile | undefined;
104
107
  occlusionCullingService: any;
105
108
  static: boolean | undefined;
106
- color: any;
109
+ color: THREE.Color | undefined;
107
110
  colorID: number | undefined;
108
- matrixAutoUpdate: boolean | undefined;
109
- matrixWorldAutoUpdate: boolean | undefined;
110
111
  childrenTiles: any[];
111
112
  meshContent: any[];
112
113
  materialVisibility: boolean;
@@ -116,6 +117,16 @@ export class OGC3DTile {
116
117
  centerModel: boolean | undefined;
117
118
  abortController: AbortController;
118
119
  onLoadCallback: Function | undefined;
120
+ /**
121
+ * Specify a size multiplier for splats
122
+ * @param {number} sizeMultiplier
123
+ */
124
+ setSplatsSizeMultiplier(sizeMultiplier: number): void;
125
+ /**
126
+ * specify a crop radius for splats
127
+ * @param {number} cropRadius
128
+ */
129
+ setSplatsCropRadius(cropRadius: number): void;
119
130
  /**
120
131
  * Manually updates all the matrices of the tileset.
121
132
  * To be called after transforming a {@link OGC3DTile tileset} instantiated with the "static" option
@@ -140,9 +151,9 @@ export class OGC3DTile {
140
151
  */
141
152
  dispose(): void;
142
153
  deleted: boolean | undefined;
143
- parent: any;
144
154
  _disposeMeshContent(): void;
145
155
  _disposeChildren(): void;
156
+ raycast(raycaster: any, intersects: any): boolean | void;
146
157
  _updateImmediate(camera: any, frustum: any): void;
147
158
  shouldBeVisible: boolean | undefined;
148
159
  _statsImmediate(maxLOD: any, numTiles: any, percentageLoaded: any, numTilesRendered: any): void;
@@ -177,6 +188,7 @@ export class OGC3DTile {
177
188
  * @param {Number} geometricErrorMultiplier set the LOD multiplier for the entire tileset
178
189
  */
179
190
  setGeometricErrorMultiplier(geometricErrorMultiplier: number): void;
191
+ splatsReady: boolean | undefined;
180
192
  /**
181
193
  * Set the Distance Bias for the tileset.
182
194
  * the {@param distanceBias} can be a number between 0 and infinity.
@@ -192,4 +204,5 @@ export class OGC3DTile {
192
204
  * @returns a list of vendors that are required by copyright to be displayed in the app.
193
205
  */
194
206
  export function getOGC3DTilesCopyrightInfo(): string[];
207
+ import * as THREE from 'three';
195
208
  import { TileLoader } from "./TileLoader";
@@ -6,15 +6,15 @@
6
6
  */
7
7
  export class OcclusionCullingService {
8
8
  cullMap: any[];
9
- cullMaterial: any;
10
- cullTarget: any;
9
+ cullMaterial: THREE.MeshBasicMaterial;
10
+ cullTarget: THREE.WebGLRenderTarget<THREE.Texture>;
11
11
  cullPixels: Uint8Array;
12
12
  /**
13
13
  *
14
14
  * @param {Integer} side use THREE.FrontSide, THREE.BackSide or THREE.DoubleSide (FrontSide default)
15
15
  */
16
16
  setSide(side: Integer): void;
17
- _createCullTarget(): any;
17
+ _createCullTarget(): THREE.WebGLRenderTarget<THREE.Texture>;
18
18
  /**
19
19
  * Update function to be called on every frame in the render loop.
20
20
  * @param {THREE.scene} scene
@@ -29,3 +29,4 @@ export class OcclusionCullingService {
29
29
  */
30
30
  hasID(id: string | number): any;
31
31
  }
32
+ import * as THREE from 'three';
@@ -16,24 +16,25 @@ export class TileLoader {
16
16
  *
17
17
  *
18
18
  * @param {Object} [options] - Optional configuration object.
19
+ * @param {renderer} [options.renderer] - the WebGL renderer
19
20
  * @param {number} [options.maxCachedItems=100] - the cache size.
20
21
  * @param {function} [options.meshCallback = undefined] - A callback to call on newly decoded meshes.
21
22
  * @param {function} [options.pointsCallback = undefined] - A callback to call on newly decoded points.
22
23
  * @param {sring} [options.proxy = undefined] - An optional proxy that tile requests will be directed too as POST requests with the actual tile url in the body of the request.
23
24
  * @param {KTX2Loader} [options.ktx2Loader = undefined] - A KTX2Loader (three/addons)
24
25
  * @param {DRACOLoader} [options.dracoLoader = undefined] - A DRACOLoader (three/addons)
25
- * @param {renderer} [options.renderer = undefined] - optional the renderer, this is required only for on the fly ktx2 support. not needed if you pass a ktx2Loader manually
26
26
  */
27
27
  constructor(options?: {
28
+ renderer?: any;
28
29
  maxCachedItems?: number | undefined;
29
30
  meshCallback?: Function | undefined;
30
31
  pointsCallback?: Function | undefined;
31
32
  proxy?: any;
32
33
  ktx2Loader?: any;
33
34
  dracoLoader?: any;
34
- renderer?: any;
35
35
  } | undefined);
36
- zUpToYUpMatrix: any;
36
+ renderer: any;
37
+ zUpToYUpMatrix: THREE.Matrix4;
37
38
  maxCachedItems: number;
38
39
  proxy: any;
39
40
  meshCallback: Function | undefined;
@@ -43,6 +44,7 @@ export class TileLoader {
43
44
  hasKTX2Loader: boolean | undefined;
44
45
  hasMeshOptDecoder: boolean;
45
46
  b3dmDecoder: B3DMDecoder;
47
+ splatsDecoder: SplatsDecoder;
46
48
  cache: any;
47
49
  register: {};
48
50
  ready: any[];
@@ -74,7 +76,7 @@ export class TileLoader {
74
76
  * @param {Boolean} meshZupToYup
75
77
  * @param {Number} geometricError
76
78
  */
77
- get(abortController: AbortController, tileIdentifier: string | number, path: string, callback: Function, distanceFunction: Function, getSiblings: Function, level: number, sceneZupToYup: boolean, meshZupToYup: boolean, geometricError: number): void;
79
+ get(abortController: AbortController, tileIdentifier: string | number, path: string, callback: Function, distanceFunction: Function, getSiblings: Function, level: number, sceneZupToYup: boolean, meshZupToYup: boolean, geometricError: number, splatsMesh: any): void;
78
80
  /**
79
81
  * Invalidates all the unused cached tiles.
80
82
  */
@@ -87,4 +89,6 @@ export class TileLoader {
87
89
  invalidate(path: string, tileIdentifier: string | number): void;
88
90
  _checkSize(): void;
89
91
  }
92
+ import * as THREE from 'three';
90
93
  import { B3DMDecoder } from "../decoder/B3DMDecoder";
94
+ import { SplatsDecoder } from "../decoder/SplatsDecoder";
@@ -5,7 +5,7 @@
5
5
  * Each tile content is instanced but each {@link InstancedOGC3DTile} object also has it's own LOD tree making this scenario very efficient.
6
6
  * @class
7
7
  */
8
- export class InstancedOGC3DTile {
8
+ export class InstancedOGC3DTile extends THREE.Object3D<THREE.Object3DEventMap> {
9
9
  /**
10
10
  *
11
11
  * @param {Object} [properties] - the properties for this tileset
@@ -54,12 +54,11 @@ export class InstancedOGC3DTile {
54
54
  renderer?: Object | undefined;
55
55
  distanceBias?: number | undefined;
56
56
  } | undefined);
57
- rendererSize: any;
57
+ rendererSize: THREE.Vector2;
58
58
  renderer: Object | undefined;
59
59
  distanceBias: number;
60
60
  geometricErrorMultiplier: number | Object;
61
61
  tileset: InstancedTile;
62
- matrixAutoUpdate: boolean | undefined;
63
62
  tileLoader: Object | undefined;
64
63
  _renderSize(size: any): void;
65
64
  /**
@@ -85,4 +84,5 @@ export class InstancedOGC3DTile {
85
84
  */
86
85
  setGeometricErrorMultiplier(geometricErrorMultiplier: number): void;
87
86
  }
87
+ import * as THREE from 'three';
88
88
  import { InstancedTile } from "./InstancedTile.js";
@@ -1,4 +1,4 @@
1
- export class InstancedTile {
1
+ export class InstancedTile extends THREE.Object3D<THREE.Object3DEventMap> {
2
2
  /**
3
3
  *
4
4
  * @param {
@@ -31,8 +31,6 @@ export class InstancedTile {
31
31
  jsonChildren: any;
32
32
  meshContent: Set<any>;
33
33
  static: any;
34
- matrixAutoUpdate: boolean | undefined;
35
- matrixWorldAutoUpdate: boolean | undefined;
36
34
  materialVisibility: boolean;
37
35
  inFrustum: boolean;
38
36
  level: any;
@@ -44,7 +42,6 @@ export class InstancedTile {
44
42
  rootPath: any;
45
43
  loadJson(json: any, url: any): void;
46
44
  setup(properties: any): Promise<void>;
47
- matrixWorldNeedsUpdate: boolean | undefined;
48
45
  isSetup: boolean | undefined;
49
46
  isAbsolutePathOrURL(input: any): any;
50
47
  assembleURL(root: any, relative: any): string;
@@ -52,7 +49,6 @@ export class InstancedTile {
52
49
  load(): void;
53
50
  loadMesh(mesh: any): void;
54
51
  dispose(): void;
55
- parent: any;
56
52
  disposeChildren(): void;
57
53
  _update(camera: any, frustum: any): void;
58
54
  areAllChildrenLoadedAndHidden(): boolean;
@@ -65,6 +61,7 @@ export class InstancedTile {
65
61
  calculateUpdateMetric(camera: any, frustum: any): number;
66
62
  getSiblings(): any[];
67
63
  calculateDistanceToCamera(camera: any): number;
68
- getWorldMatrix(): any;
64
+ getWorldMatrix(): THREE.Matrix4;
69
65
  transformWGS84ToCartesian(lon: any, lat: any, h: any, sfct: any): void;
70
66
  }
67
+ import * as THREE from 'three';
@@ -35,7 +35,7 @@ export class InstancedTileLoader {
35
35
  dracoLoader?: any;
36
36
  renderer?: any;
37
37
  } | undefined);
38
- zUpToYUpMatrix: any;
38
+ zUpToYUpMatrix: THREE.Matrix4;
39
39
  maxCachedItems: number;
40
40
  maxInstances: number;
41
41
  proxy: any;
@@ -78,5 +78,6 @@ export class InstancedTileLoader {
78
78
  _getNextDownloads(): void;
79
79
  _checkSize(): void;
80
80
  }
81
+ import * as THREE from 'three';
81
82
  import { B3DMDecoder } from "../../decoder/B3DMDecoder";
82
83
  import { InstancedOGC3DTile } from './InstancedOGC3DTile';
@@ -2,7 +2,7 @@ export class MeshTile {
2
2
  constructor(scene: any);
3
3
  scene: any;
4
4
  instancedTiles: any[];
5
- reuseableMatrix: any;
5
+ reuseableMatrix: THREE.Matrix4;
6
6
  addInstance(instancedTile: any): void;
7
7
  addToScene(): void;
8
8
  setObject(instancedMesh: any): void;
@@ -11,3 +11,4 @@ export class MeshTile {
11
11
  getCount(): number;
12
12
  dispose(): boolean;
13
13
  }
14
+ import * as THREE from 'three';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jdultra/threedtiles",
3
- "version": "12.0.0",
3
+ "version": "13.0.0",
4
4
  "author": "Emeric Beaufays",
5
5
  "description": "An OGC 3DTiles viewer for Three.js",
6
6
  "main": "dist/threedtiles.cjs.js",
@@ -22,12 +22,17 @@
22
22
  "build": "vite build --config vite.prod.config.js && npm run build:types",
23
23
  "build:types": "tsc --declaration --emitDeclarationOnly --allowJs --outDir dist",
24
24
  "generate-docs": "jsdoc --configure jsdoc.json --verbose",
25
- "dev": "vite"
25
+ "dev": "vite",
26
+ "build:dev": "vite build --config vite.config.js",
27
+ "test:watch": "vitest",
28
+ "test": "vitest run"
26
29
  },
27
30
  "peerDependencies": {
28
31
  "three": "0.170.0"
29
32
  },
30
33
  "dependencies": {
34
+ "@haragei/dag": "^1.1.0",
35
+ "data-structure-typed": "^1.53.5",
31
36
  "js-utils-z": "^1.2.1",
32
37
  "meshoptimizer": "^0.20.0",
33
38
  "path-browserify": "^1.0.1",
@@ -36,8 +41,11 @@
36
41
  },
37
42
  "devDependencies": {
38
43
  "@rollup/plugin-terser": "^0.4.4",
44
+ "@types/three": "^0.169.0",
45
+ "jsdom": "^25.0.1",
39
46
  "typescript": "^5.6.3",
40
47
  "vite": "^5.4.10",
41
- "vite-plugin-static-copy": "^2.0.0"
48
+ "vite-plugin-static-copy": "^2.0.0",
49
+ "vitest": "^2.1.5"
42
50
  }
43
51
  }