@loaders.gl/potree 4.3.0-alpha.4 → 4.3.0-alpha.5
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/dist/dist.dev.js +10 -5
- package/dist/dist.min.js +1 -1
- package/dist/index.cjs +11 -6
- package/dist/index.cjs.map +3 -3
- package/dist/lib/potree-node-source.d.ts +66 -0
- package/dist/lib/potree-node-source.d.ts.map +1 -0
- package/dist/lib/potree-node-source.js +138 -0
- package/dist/potree-hierarchy-chunk-loader.d.ts +6 -1
- package/dist/potree-hierarchy-chunk-loader.d.ts.map +1 -1
- package/dist/potree-hierarchy-chunk-loader.js +9 -3
- package/dist/potree-loader.d.ts +3 -2
- package/dist/potree-loader.d.ts.map +1 -1
- package/dist/potree-loader.js +4 -5
- package/dist/potree-source.d.ts +22 -0
- package/dist/potree-source.d.ts.map +1 -0
- package/dist/potree-source.js +22 -0
- package/dist/types/potree-metadata.d.ts +88 -0
- package/dist/types/potree-metadata.d.ts.map +1 -0
- package/dist/types/potree-metadata.js +4 -0
- package/dist/utils/parse-version.d.ts +5 -0
- package/dist/utils/parse-version.d.ts.map +1 -0
- package/dist/utils/parse-version.js +7 -0
- package/package.json +5 -3
- package/src/lib/potree-node-source.ts +171 -0
- package/src/potree-hierarchy-chunk-loader.ts +10 -3
- package/src/potree-loader.ts +3 -4
- package/src/potree-source.ts +28 -0
- package/src/types/potree-metadata.ts +94 -0
- package/src/utils/parse-version.ts +8 -0
package/dist/dist.dev.js
CHANGED
|
@@ -59,18 +59,18 @@ var __exports__ = (() => {
|
|
|
59
59
|
var PotreeLoader = {
|
|
60
60
|
dataType: null,
|
|
61
61
|
batchType: null,
|
|
62
|
-
name: "potree",
|
|
62
|
+
name: "potree metadata",
|
|
63
63
|
id: "potree",
|
|
64
64
|
module: "potree",
|
|
65
65
|
version: VERSION,
|
|
66
|
-
extensions: ["
|
|
66
|
+
extensions: ["js"],
|
|
67
67
|
mimeTypes: ["application/json"],
|
|
68
68
|
testText: (text) => text.indexOf("octreeDir") >= 0,
|
|
69
|
+
parse: (data) => JSON.parse(new TextDecoder().decode(data)),
|
|
69
70
|
parseTextSync: (text) => JSON.parse(text),
|
|
70
71
|
options: {
|
|
71
72
|
potree: {}
|
|
72
73
|
}
|
|
73
|
-
// @ts-ignore
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
// src/parsers/parse-potree-hierarchy-chunk.ts
|
|
@@ -140,19 +140,24 @@ var __exports__ = (() => {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
// src/potree-hierarchy-chunk-loader.ts
|
|
143
|
+
var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
143
144
|
var PotreeHierarchyChunkLoader = {
|
|
144
145
|
dataType: null,
|
|
145
146
|
batchType: null,
|
|
146
|
-
id: "potree",
|
|
147
147
|
name: "potree Hierarchy Chunk",
|
|
148
|
+
id: "potree-hrc",
|
|
149
|
+
module: "potree",
|
|
150
|
+
version: VERSION2,
|
|
148
151
|
extensions: ["hrc"],
|
|
149
152
|
mimeTypes: ["application/octet-stream"],
|
|
150
153
|
// binary potree files have no header bytes, no content test function possible
|
|
151
154
|
// test: ['...'],
|
|
152
155
|
parse: async (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),
|
|
153
156
|
parseSync: (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),
|
|
157
|
+
options: {
|
|
158
|
+
potree: {}
|
|
159
|
+
},
|
|
154
160
|
binary: true
|
|
155
|
-
// @ts-ignore
|
|
156
161
|
};
|
|
157
162
|
|
|
158
163
|
// src/parsers/parse-potree-bin.ts
|
package/dist/dist.min.js
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['loaders'] = factory();
|
|
6
6
|
else root['loaders'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var B=Object.create;var d=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var
|
|
7
|
+
"use strict";var __exports__=(()=>{var B=Object.create;var d=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var w=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),I=(e,n)=>{for(var t in n)d(e,t,{get:n[t],enumerable:!0})},l=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of N(n))!b.call(e,a)&&a!==t&&d(e,a,{get:()=>n[a],enumerable:!(o=L(n,a))||o.enumerable});return e},u=(e,n,t)=>(l(e,n,"default"),t&&l(t,n,"default")),A=(e,n,t)=>(t=e!=null?B(S(e)):{},l(n||!e||!e.__esModule?d(t,"default",{value:e,enumerable:!0}):t,e)),D=e=>l(d({},"__esModule",{value:!0}),e);var f=w((R,x)=>{x.exports=globalThis.loaders});var h={};I(h,{PotreeBinLoader:()=>C,PotreeHierarchyChunkLoader:()=>g,PotreeLoader:()=>T});u(h,A(f(),1));var H="4.3.0-alpha.4",T={dataType:null,batchType:null,name:"potree metadata",id:"potree",module:"potree",version:H,extensions:["js"],mimeTypes:["application/json"],testText:e=>e.indexOf("octreeDir")>=0,parse:e=>JSON.parse(new TextDecoder().decode(e)),parseTextSync:e=>JSON.parse(e),options:{potree:{}}};function m(e){let n=O(e);return v(n)}function O(e,n=0){let t=new DataView(e),o=[],a={};n=P(t,n,a),o.push(a);let r=[];for(;o.length>0;){let i=o.shift(),p=1;for(let c=0;c<8;c++){if(i&&i.header.childMask&p){let s={};n=P(t,n,s),s.name=i.name+c,o.push(s),r.push(s),i.header.childCount++}p=p*2}if(n===t.byteLength)break}return r}function P(e,n,t){return t.header=t.header||{},t.header.childMask=e.getUint8(n),t.header.childCount=0,t.pointCount=e.getUint32(n+1,!0),t.name="",n+=5,n}function v(e,n={}){n={...{spacing:100},...n};let o=e[0],a={};for(let r of e){let{name:i}=r,p=parseInt(i.charAt(i.length-1),10),c=i.substring(0,i.length-1),s=a[c],y=i.length-1;r.level=y,r.hasChildren=r.header.childCount,r.children=[],r.childrenByIndex=new Array(8).fill(null),r.spacing=(n?.spacing||0)/Math.pow(2,y),s&&(s.children.push(r),s.childrenByIndex[p]=r),a[i]=r}return o}var E="4.3.0-alpha.4",g={dataType:null,batchType:null,name:"potree Hierarchy Chunk",id:"potree-hrc",module:"potree",version:E,extensions:["hrc"],mimeTypes:["application/octet-stream"],parse:async(e,n)=>m(e),parseSync:(e,n)=>m(e),options:{potree:{}},binary:!0};function k(e,n,t,o){return null}var C={dataType:null,batchType:null,name:"potree Binary Point Attributes",id:"potree",extensions:["bin"],mimeTypes:["application/octet-stream"],parseSync:U,binary:!0,options:{}};function U(e,n){let t={};return k(e,0,n,t),t}return D(h);})();
|
|
8
8
|
return __exports__;
|
|
9
9
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -27,22 +27,22 @@ __export(dist_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(dist_exports);
|
|
28
28
|
|
|
29
29
|
// dist/potree-loader.js
|
|
30
|
-
var VERSION = true ? "4.3.0-alpha.
|
|
30
|
+
var VERSION = true ? "4.3.0-alpha.4" : "latest";
|
|
31
31
|
var PotreeLoader = {
|
|
32
32
|
dataType: null,
|
|
33
33
|
batchType: null,
|
|
34
|
-
name: "potree",
|
|
34
|
+
name: "potree metadata",
|
|
35
35
|
id: "potree",
|
|
36
36
|
module: "potree",
|
|
37
37
|
version: VERSION,
|
|
38
|
-
extensions: ["
|
|
38
|
+
extensions: ["js"],
|
|
39
39
|
mimeTypes: ["application/json"],
|
|
40
40
|
testText: (text) => text.indexOf("octreeDir") >= 0,
|
|
41
|
+
parse: (data) => JSON.parse(new TextDecoder().decode(data)),
|
|
41
42
|
parseTextSync: (text) => JSON.parse(text),
|
|
42
43
|
options: {
|
|
43
44
|
potree: {}
|
|
44
45
|
}
|
|
45
|
-
// @ts-ignore
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
// dist/parsers/parse-potree-hierarchy-chunk.js
|
|
@@ -112,19 +112,24 @@ function buildHierarchy(tileHeaders, options = {}) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
// dist/potree-hierarchy-chunk-loader.js
|
|
115
|
+
var VERSION2 = true ? "4.3.0-alpha.4" : "latest";
|
|
115
116
|
var PotreeHierarchyChunkLoader = {
|
|
116
117
|
dataType: null,
|
|
117
118
|
batchType: null,
|
|
118
|
-
id: "potree",
|
|
119
119
|
name: "potree Hierarchy Chunk",
|
|
120
|
+
id: "potree-hrc",
|
|
121
|
+
module: "potree",
|
|
122
|
+
version: VERSION2,
|
|
120
123
|
extensions: ["hrc"],
|
|
121
124
|
mimeTypes: ["application/octet-stream"],
|
|
122
125
|
// binary potree files have no header bytes, no content test function possible
|
|
123
126
|
// test: ['...'],
|
|
124
127
|
parse: async (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),
|
|
125
128
|
parseSync: (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),
|
|
129
|
+
options: {
|
|
130
|
+
potree: {}
|
|
131
|
+
},
|
|
126
132
|
binary: true
|
|
127
|
-
// @ts-ignore
|
|
128
133
|
};
|
|
129
134
|
|
|
130
135
|
// dist/parsers/parse-potree-bin.js
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.js", "potree-loader.js", "parsers/parse-potree-hierarchy-chunk.js", "potree-hierarchy-chunk-loader.js", "parsers/parse-potree-bin.js", "potree-bin-loader.js"],
|
|
4
|
-
"sourcesContent": ["export { PotreeLoader } from \"./potree-loader.js\";\nexport { PotreeHierarchyChunkLoader } from \"./potree-hierarchy-chunk-loader.js\";\nexport { PotreeBinLoader } from \"./potree-bin-loader.js\";\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0-alpha.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,IAAM,UAAU,OAAyC,kBAAkB;
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["export { PotreeLoader } from \"./potree-loader.js\";\nexport { PotreeHierarchyChunkLoader } from \"./potree-hierarchy-chunk-loader.js\";\nexport { PotreeBinLoader } from \"./potree-bin-loader.js\";\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0-alpha.4\" !== 'undefined' ? \"4.3.0-alpha.4\" : 'latest';\n/** Potree loader */\nexport const PotreeLoader = {\n dataType: null,\n batchType: null,\n name: 'potree metadata',\n id: 'potree',\n module: 'potree',\n version: VERSION,\n extensions: ['js'],\n mimeTypes: ['application/json'],\n testText: (text) => text.indexOf('octreeDir') >= 0,\n parse: (data) => JSON.parse(new TextDecoder().decode(data)),\n parseTextSync: (text) => JSON.parse(text),\n options: {\n potree: {}\n }\n};\n", "// This file is derived from the Cesium code base under BSD 2-clause license\n// See LICENSE.md and https://github.com/potree/potree/blob/develop/LICENSE\n// type POTreeTileNode = POTreeNode;\n// load hierarchy\nexport function parsePotreeHierarchyChunk(arrayBuffer) {\n const tileHeaders = parseBinaryChunk(arrayBuffer);\n return buildHierarchy(tileHeaders);\n}\n// Parses the binary rows\nfunction parseBinaryChunk(arrayBuffer, byteOffset = 0) {\n const dataView = new DataView(arrayBuffer);\n const stack = [];\n // Get root mask\n // @ts-expect-error\n const topTileHeader = {};\n byteOffset = decodeRow(dataView, byteOffset, topTileHeader);\n stack.push(topTileHeader);\n const tileHeaders = [];\n while (stack.length > 0) {\n const snode = stack.shift();\n let mask = 1;\n for (let i = 0; i < 8; i++) {\n if (snode && (snode.header.childMask & mask) !== 0) {\n // @ts-expect-error\n const tileHeader = {};\n byteOffset = decodeRow(dataView, byteOffset, tileHeader);\n tileHeader.name = snode.name + i;\n // @ts-expect-error\n stack.push(tileHeader);\n tileHeaders.push(tileHeader);\n snode.header.childCount++;\n }\n mask = mask * 2;\n }\n if (byteOffset === dataView.byteLength) {\n break;\n }\n }\n return tileHeaders;\n}\nfunction decodeRow(dataView, byteOffset, tileHeader) {\n tileHeader.header = tileHeader.header || {};\n tileHeader.header.childMask = dataView.getUint8(byteOffset);\n tileHeader.header.childCount = 0;\n tileHeader.pointCount = dataView.getUint32(byteOffset + 1, true);\n tileHeader.name = '';\n byteOffset += 5;\n return byteOffset;\n}\n// Resolves the binary rows into a hierarchy (tree structure)\nfunction buildHierarchy(tileHeaders, options = {}) {\n const DEFAULT_OPTIONS = { spacing: 100 }; // TODO assert instead of default?\n options = { ...DEFAULT_OPTIONS, ...options };\n const topNode = tileHeaders[0];\n const nodes = {};\n for (const tileHeader of tileHeaders) {\n const { name } = tileHeader;\n const index = parseInt(name.charAt(name.length - 1), 10);\n const parentName = name.substring(0, name.length - 1);\n const parentNode = nodes[parentName];\n const level = name.length - 1;\n // assert(parentNode && level >= 0);\n tileHeader.level = level;\n tileHeader.hasChildren = tileHeader.header.childCount;\n tileHeader.children = [];\n tileHeader.childrenByIndex = new Array(8).fill(null);\n tileHeader.spacing = (options?.spacing || 0) / Math.pow(2, level);\n // tileHeader.boundingVolume = Utils.createChildAABB(parentNode.boundingBox, index);\n if (parentNode) {\n parentNode.children.push(tileHeader);\n parentNode.childrenByIndex[index] = tileHeader;\n }\n // Add the node to the map\n nodes[name] = tileHeader;\n }\n // First node is the root\n return topNode;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\nimport { parsePotreeHierarchyChunk } from \"./parsers/parse-potree-hierarchy-chunk.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0-alpha.4\" !== 'undefined' ? \"4.3.0-alpha.4\" : 'latest';\n/** Potree hierarchy chunk loader */\nexport const PotreeHierarchyChunkLoader = {\n dataType: null,\n batchType: null,\n name: 'potree Hierarchy Chunk',\n id: 'potree-hrc',\n module: 'potree',\n version: VERSION,\n extensions: ['hrc'],\n mimeTypes: ['application/octet-stream'],\n // binary potree files have no header bytes, no content test function possible\n // test: ['...'],\n parse: async (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),\n parseSync: (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),\n options: {\n potree: {}\n },\n binary: true\n};\n", "export function parsePotreeBin(arrayBuffer, byteOffset, options, index) {\n return null;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\nimport { parsePotreeBin } from \"./parsers/parse-potree-bin.js\";\n/**\n * Loader for potree Binary Point Attributes\n * */\nexport const PotreeBinLoader = {\n dataType: null,\n batchType: null,\n name: 'potree Binary Point Attributes',\n id: 'potree',\n extensions: ['bin'],\n mimeTypes: ['application/octet-stream'],\n // Unfortunately binary potree files have no header bytes, no test possible\n // test: ['...'],\n parseSync,\n binary: true,\n options: {}\n // @ts-ignore\n};\nfunction parseSync(arrayBuffer, options) {\n const index = {};\n const byteOffset = 0;\n parsePotreeBin(arrayBuffer, byteOffset, options, index);\n return index;\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["VERSION"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { MeshGeometry } from '@loaders.gl/schema';
|
|
2
|
+
import { DataSource, DataSourceProps, LoaderOptions } from '@loaders.gl/loader-utils';
|
|
3
|
+
import { PotreeMetadata } from "../types/potree-metadata.js";
|
|
4
|
+
import { POTreeNode } from "../parsers/parse-potree-hierarchy-chunk.js";
|
|
5
|
+
export type PotreeNodesSourceProps = DataSourceProps & {
|
|
6
|
+
attributions?: string[];
|
|
7
|
+
potree?: {
|
|
8
|
+
loadOptions?: LoaderOptions;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A Potree data source
|
|
13
|
+
* @version 1.0 - https://github.com/potree/potree/blob/1.0RC/docs/file_format.md
|
|
14
|
+
* @version 1.7 - https://github.com/potree/potree/blob/1.7/docs/potree-file-format.md
|
|
15
|
+
* @note Point cloud nodes tile source
|
|
16
|
+
*/
|
|
17
|
+
export declare class PotreeNodesSource extends DataSource {
|
|
18
|
+
/** Dataset base URL */
|
|
19
|
+
baseUrl: string;
|
|
20
|
+
/** Input data: string - dataset url, blob - single file data */
|
|
21
|
+
data: string | Blob;
|
|
22
|
+
/** Input props */
|
|
23
|
+
props: PotreeNodesSourceProps;
|
|
24
|
+
/** Meta information from `cloud.js` */
|
|
25
|
+
metadata: PotreeMetadata | null;
|
|
26
|
+
/** Root node */
|
|
27
|
+
root: POTreeNode | null;
|
|
28
|
+
/** Is data source ready to use after initial loading */
|
|
29
|
+
isReady: boolean;
|
|
30
|
+
private initPromise;
|
|
31
|
+
/**
|
|
32
|
+
* @constructor
|
|
33
|
+
* @param data - if string - data set path url or path to `cloud.js` metadata file
|
|
34
|
+
* - if Blob - single file data
|
|
35
|
+
* @param props - data source properties
|
|
36
|
+
*/
|
|
37
|
+
constructor(data: string | Blob, props: PotreeNodesSourceProps);
|
|
38
|
+
/** Initial data source loading */
|
|
39
|
+
init(): Promise<void>;
|
|
40
|
+
/** Is data set supported */
|
|
41
|
+
isSupported(): boolean;
|
|
42
|
+
/** Get content files extension */
|
|
43
|
+
getContentExtension(): string | null;
|
|
44
|
+
/**
|
|
45
|
+
* Load octree node content
|
|
46
|
+
* @param path array of numbers between 0-7 specifying successive octree divisions.
|
|
47
|
+
* @return node content geometry or null if the node doesn't exist
|
|
48
|
+
*/
|
|
49
|
+
loadNodeContent(path: number[]): Promise<MeshGeometry | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Load data source hierarchy into tree of available nodes
|
|
52
|
+
*/
|
|
53
|
+
loadHierarchy(): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Check if a node exists in the octree
|
|
56
|
+
* @param path array of numbers between 0-7 specifying successive octree divisions
|
|
57
|
+
* @returns true - the node does exist, false - the nodes doesn't exist
|
|
58
|
+
*/
|
|
59
|
+
isNodeAvailable(path: number[]): Promise<boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* Deduce base url from the input url sring
|
|
62
|
+
* @param data - data source input data
|
|
63
|
+
*/
|
|
64
|
+
private makeBaseUrl;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=potree-node-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"potree-node-source.d.ts","sourceRoot":"","sources":["../../src/lib/potree-node-source.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,aAAa,EAAc,MAAM,0BAA0B,CAAC;AAEjG,OAAO,EAAC,cAAc,EAAC,oCAAiC;AACxD,OAAO,EAAC,UAAU,EAAC,mDAAgD;AAKnE,MAAM,MAAM,sBAAsB,GAAG,eAAe,GAAG;IACrD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,MAAM,CAAC,EAAE;QACP,WAAW,CAAC,EAAE,aAAa,CAAC;KAE7B,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,iBAAkB,SAAQ,UAAU;IAC/C,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAM;IACrB,gEAAgE;IAChE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,kBAAkB;IAClB,KAAK,EAAE,sBAAsB,CAAC;IAC9B,uCAAuC;IACvC,QAAQ,EAAE,cAAc,GAAG,IAAI,CAAQ;IACvC,gBAAgB;IAChB,IAAI,EAAE,UAAU,GAAG,IAAI,CAAQ;IAC/B,wDAAwD;IACxD,OAAO,UAAS;IAEhB,OAAO,CAAC,WAAW,CAA8B;IAEjD;;;;;OAKG;gBACS,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,sBAAsB;IAS9D,kCAAkC;IAC5B,IAAI;IAMV,4BAA4B;IAC5B,WAAW,IAAI,OAAO;IAWtB,kCAAkC;IAClC,mBAAmB,IAAI,MAAM,GAAG,IAAI;IAcpC;;;;OAIG;IACG,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAkBnE;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAQpC;;;;OAIG;IACG,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAyBvD;;;OAGG;IACH,OAAO,CAAC,WAAW;CASpB"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { load } from '@loaders.gl/core';
|
|
5
|
+
import { DataSource, resolvePath } from '@loaders.gl/loader-utils';
|
|
6
|
+
import { LASLoader } from '@loaders.gl/las';
|
|
7
|
+
import { PotreeHierarchyChunkLoader } from "../potree-hierarchy-chunk-loader.js";
|
|
8
|
+
import { PotreeLoader } from "../potree-loader.js";
|
|
9
|
+
import { parseVersion } from "../utils/parse-version.js";
|
|
10
|
+
/**
|
|
11
|
+
* A Potree data source
|
|
12
|
+
* @version 1.0 - https://github.com/potree/potree/blob/1.0RC/docs/file_format.md
|
|
13
|
+
* @version 1.7 - https://github.com/potree/potree/blob/1.7/docs/potree-file-format.md
|
|
14
|
+
* @note Point cloud nodes tile source
|
|
15
|
+
*/
|
|
16
|
+
export class PotreeNodesSource extends DataSource {
|
|
17
|
+
/** Dataset base URL */
|
|
18
|
+
baseUrl = '';
|
|
19
|
+
/** Input data: string - dataset url, blob - single file data */
|
|
20
|
+
data;
|
|
21
|
+
/** Input props */
|
|
22
|
+
props;
|
|
23
|
+
/** Meta information from `cloud.js` */
|
|
24
|
+
metadata = null;
|
|
25
|
+
/** Root node */
|
|
26
|
+
root = null;
|
|
27
|
+
/** Is data source ready to use after initial loading */
|
|
28
|
+
isReady = false;
|
|
29
|
+
initPromise = null;
|
|
30
|
+
/**
|
|
31
|
+
* @constructor
|
|
32
|
+
* @param data - if string - data set path url or path to `cloud.js` metadata file
|
|
33
|
+
* - if Blob - single file data
|
|
34
|
+
* @param props - data source properties
|
|
35
|
+
*/
|
|
36
|
+
constructor(data, props) {
|
|
37
|
+
super(props);
|
|
38
|
+
this.props = props;
|
|
39
|
+
this.data = data;
|
|
40
|
+
this.makeBaseUrl(this.data);
|
|
41
|
+
this.initPromise = this.init();
|
|
42
|
+
}
|
|
43
|
+
/** Initial data source loading */
|
|
44
|
+
async init() {
|
|
45
|
+
this.metadata = await load(`${this.baseUrl}/cloud.js`, PotreeLoader);
|
|
46
|
+
await this.loadHierarchy();
|
|
47
|
+
this.isReady = true;
|
|
48
|
+
}
|
|
49
|
+
/** Is data set supported */
|
|
50
|
+
isSupported() {
|
|
51
|
+
const { minor, major } = parseVersion(this.metadata?.version ?? '');
|
|
52
|
+
return (this.isReady &&
|
|
53
|
+
major === 1 &&
|
|
54
|
+
minor < 2 &&
|
|
55
|
+
typeof this.metadata?.pointAttributes === 'string' &&
|
|
56
|
+
['LAS', 'LAZ'].includes(this.metadata?.pointAttributes));
|
|
57
|
+
}
|
|
58
|
+
/** Get content files extension */
|
|
59
|
+
getContentExtension() {
|
|
60
|
+
if (!this.isReady) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
switch (this.metadata?.pointAttributes) {
|
|
64
|
+
case 'LAS':
|
|
65
|
+
return 'las';
|
|
66
|
+
case 'LAZ':
|
|
67
|
+
return 'laz';
|
|
68
|
+
default:
|
|
69
|
+
return 'bin';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Load octree node content
|
|
74
|
+
* @param path array of numbers between 0-7 specifying successive octree divisions.
|
|
75
|
+
* @return node content geometry or null if the node doesn't exist
|
|
76
|
+
*/
|
|
77
|
+
async loadNodeContent(path) {
|
|
78
|
+
await this.initPromise;
|
|
79
|
+
if (!this.isSupported()) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const isAvailable = await this.isNodeAvailable(path);
|
|
83
|
+
if (isAvailable) {
|
|
84
|
+
return load(`${this.baseUrl}/${this.metadata
|
|
85
|
+
?.octreeDir}/r/r${path.join()}.${this.getContentExtension()}`, LASLoader);
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Load data source hierarchy into tree of available nodes
|
|
91
|
+
*/
|
|
92
|
+
async loadHierarchy() {
|
|
93
|
+
await this.initPromise;
|
|
94
|
+
this.root = await load(`${this.baseUrl}/${this.metadata?.octreeDir}/r/r.hrc`, PotreeHierarchyChunkLoader);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Check if a node exists in the octree
|
|
98
|
+
* @param path array of numbers between 0-7 specifying successive octree divisions
|
|
99
|
+
* @returns true - the node does exist, false - the nodes doesn't exist
|
|
100
|
+
*/
|
|
101
|
+
async isNodeAvailable(path) {
|
|
102
|
+
if (this.metadata?.hierarchy) {
|
|
103
|
+
return this.metadata.hierarchy.findIndex((item) => item[0] === `r${path.join()}`) !== -1;
|
|
104
|
+
}
|
|
105
|
+
if (!this.root) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
let currentParent = this.root;
|
|
109
|
+
let name = '';
|
|
110
|
+
let result = true;
|
|
111
|
+
for (const nodeLevel of path) {
|
|
112
|
+
const newName = `${name}${nodeLevel}`;
|
|
113
|
+
const node = currentParent.children.find((child) => child.name === newName);
|
|
114
|
+
if (node) {
|
|
115
|
+
currentParent = node;
|
|
116
|
+
name = newName;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
result = false;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Deduce base url from the input url sring
|
|
127
|
+
* @param data - data source input data
|
|
128
|
+
*/
|
|
129
|
+
makeBaseUrl(data) {
|
|
130
|
+
this.baseUrl = typeof data === 'string' ? resolvePath(data) : '';
|
|
131
|
+
if (this.baseUrl.endsWith('cloud.js')) {
|
|
132
|
+
this.baseUrl = this.baseUrl.substring(0, -8);
|
|
133
|
+
}
|
|
134
|
+
if (this.baseUrl.endsWith('/')) {
|
|
135
|
+
this.baseUrl = this.baseUrl.substring(0, -1);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -4,12 +4,17 @@ import type { POTreeNode } from "./parsers/parse-potree-hierarchy-chunk.js";
|
|
|
4
4
|
export declare const PotreeHierarchyChunkLoader: {
|
|
5
5
|
readonly dataType: POTreeNode;
|
|
6
6
|
readonly batchType: never;
|
|
7
|
-
readonly id: "potree";
|
|
8
7
|
readonly name: "potree Hierarchy Chunk";
|
|
8
|
+
readonly id: "potree-hrc";
|
|
9
|
+
readonly module: "potree";
|
|
10
|
+
readonly version: any;
|
|
9
11
|
readonly extensions: ["hrc"];
|
|
10
12
|
readonly mimeTypes: ["application/octet-stream"];
|
|
11
13
|
readonly parse: (arrayBuffer: ArrayBuffer, options: POTreeLoaderOptions | undefined) => Promise<POTreeNode>;
|
|
12
14
|
readonly parseSync: (arrayBuffer: ArrayBuffer, options: POTreeLoaderOptions | undefined) => POTreeNode;
|
|
15
|
+
readonly options: {
|
|
16
|
+
readonly potree: {};
|
|
17
|
+
};
|
|
13
18
|
readonly binary: true;
|
|
14
19
|
};
|
|
15
20
|
//# sourceMappingURL=potree-hierarchy-chunk-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"potree-hierarchy-chunk-loader.d.ts","sourceRoot":"","sources":["../src/potree-hierarchy-chunk-loader.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,mBAAmB,EAAC,2BAAwB;AACzD,OAAO,KAAK,EAAC,UAAU,EAAC,kDAA+C;
|
|
1
|
+
{"version":3,"file":"potree-hierarchy-chunk-loader.d.ts","sourceRoot":"","sources":["../src/potree-hierarchy-chunk-loader.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,mBAAmB,EAAC,2BAAwB;AACzD,OAAO,KAAK,EAAC,UAAU,EAAC,kDAA+C;AAOvE,oCAAoC;AACpC,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;CAkBsC,CAAC"}
|
|
@@ -2,19 +2,25 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright vis.gl contributors
|
|
4
4
|
import { parsePotreeHierarchyChunk } from "./parsers/parse-potree-hierarchy-chunk.js";
|
|
5
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
6
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
7
|
+
const VERSION = typeof "4.3.0-alpha.4" !== 'undefined' ? "4.3.0-alpha.4" : 'latest';
|
|
5
8
|
/** Potree hierarchy chunk loader */
|
|
6
|
-
// @ts-ignore not a valid loader
|
|
7
9
|
export const PotreeHierarchyChunkLoader = {
|
|
8
10
|
dataType: null,
|
|
9
11
|
batchType: null,
|
|
10
|
-
id: 'potree',
|
|
11
12
|
name: 'potree Hierarchy Chunk',
|
|
13
|
+
id: 'potree-hrc',
|
|
14
|
+
module: 'potree',
|
|
15
|
+
version: VERSION,
|
|
12
16
|
extensions: ['hrc'],
|
|
13
17
|
mimeTypes: ['application/octet-stream'],
|
|
14
18
|
// binary potree files have no header bytes, no content test function possible
|
|
15
19
|
// test: ['...'],
|
|
16
20
|
parse: async (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),
|
|
17
21
|
parseSync: (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),
|
|
22
|
+
options: {
|
|
23
|
+
potree: {}
|
|
24
|
+
},
|
|
18
25
|
binary: true
|
|
19
|
-
// @ts-ignore
|
|
20
26
|
};
|
package/dist/potree-loader.d.ts
CHANGED
|
@@ -6,13 +6,14 @@ export type POTreeLoaderOptions = LoaderOptions & {
|
|
|
6
6
|
export declare const PotreeLoader: {
|
|
7
7
|
readonly dataType: any;
|
|
8
8
|
readonly batchType: never;
|
|
9
|
-
readonly name: "potree";
|
|
9
|
+
readonly name: "potree metadata";
|
|
10
10
|
readonly id: "potree";
|
|
11
11
|
readonly module: "potree";
|
|
12
12
|
readonly version: any;
|
|
13
|
-
readonly extensions: ["
|
|
13
|
+
readonly extensions: ["js"];
|
|
14
14
|
readonly mimeTypes: ["application/json"];
|
|
15
15
|
readonly testText: (text: string) => boolean;
|
|
16
|
+
readonly parse: (data: ArrayBuffer) => any;
|
|
16
17
|
readonly parseTextSync: (text: string) => any;
|
|
17
18
|
readonly options: {
|
|
18
19
|
readonly potree: {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"potree-loader.d.ts","sourceRoot":"","sources":["../src/potree-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAmB,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAM9E,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG;IAChD,MAAM,CAAC,EAAE,EAAE,CAAC;CACb,CAAC;AAEF,oBAAoB;
|
|
1
|
+
{"version":3,"file":"potree-loader.d.ts","sourceRoot":"","sources":["../src/potree-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAmB,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAM9E,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG;IAChD,MAAM,CAAC,EAAE,EAAE,CAAC;CACb,CAAC;AAEF,oBAAoB;AACpB,eAAO,MAAM,YAAY;;;;;;;;;;2BAWT,WAAW;;;;;CAK2C,CAAC"}
|
package/dist/potree-loader.js
CHANGED
|
@@ -3,22 +3,21 @@
|
|
|
3
3
|
// Copyright vis.gl contributors
|
|
4
4
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
5
5
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
6
|
-
const VERSION = typeof "4.3.0-alpha.
|
|
6
|
+
const VERSION = typeof "4.3.0-alpha.4" !== 'undefined' ? "4.3.0-alpha.4" : 'latest';
|
|
7
7
|
/** Potree loader */
|
|
8
|
-
// @ts-ignore
|
|
9
8
|
export const PotreeLoader = {
|
|
10
9
|
dataType: null,
|
|
11
10
|
batchType: null,
|
|
12
|
-
name: 'potree',
|
|
11
|
+
name: 'potree metadata',
|
|
13
12
|
id: 'potree',
|
|
14
13
|
module: 'potree',
|
|
15
14
|
version: VERSION,
|
|
16
|
-
extensions: ['
|
|
15
|
+
extensions: ['js'],
|
|
17
16
|
mimeTypes: ['application/json'],
|
|
18
17
|
testText: (text) => text.indexOf('octreeDir') >= 0,
|
|
18
|
+
parse: (data) => JSON.parse(new TextDecoder().decode(data)),
|
|
19
19
|
parseTextSync: (text) => JSON.parse(text),
|
|
20
20
|
options: {
|
|
21
21
|
potree: {}
|
|
22
22
|
}
|
|
23
|
-
// @ts-ignore
|
|
24
23
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PotreeNodesSource, PotreeNodesSourceProps } from "./lib/potree-node-source.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates point cloud data sources for Potree urls
|
|
4
|
+
*/
|
|
5
|
+
export declare const PotreeSource: {
|
|
6
|
+
readonly name: "Potree";
|
|
7
|
+
readonly id: "potree";
|
|
8
|
+
readonly module: "potree";
|
|
9
|
+
readonly version: "1.7";
|
|
10
|
+
readonly extensions: ["bin", "las", "laz"];
|
|
11
|
+
readonly mimeTypes: ["application/octet-stream"];
|
|
12
|
+
readonly options: {
|
|
13
|
+
readonly url: never;
|
|
14
|
+
readonly potree: {};
|
|
15
|
+
};
|
|
16
|
+
readonly type: "potree";
|
|
17
|
+
readonly fromUrl: true;
|
|
18
|
+
readonly fromBlob: true;
|
|
19
|
+
readonly testURL: (url: string) => boolean;
|
|
20
|
+
readonly createDataSource: (url: string | Blob, props: PotreeNodesSourceProps) => PotreeNodesSource;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=potree-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"potree-source.d.ts","sourceRoot":"","sources":["../src/potree-source.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,iBAAiB,EAAE,sBAAsB,EAAC,oCAAiC;AAInF;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;4BAYR,MAAM;qCACG,MAAM,GAAG,IAAI,SAAS,sBAAsB;CAEA,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { PotreeNodesSource } from "./lib/potree-node-source.js";
|
|
5
|
+
const VERSION = '1.7';
|
|
6
|
+
/**
|
|
7
|
+
* Creates point cloud data sources for Potree urls
|
|
8
|
+
*/
|
|
9
|
+
export const PotreeSource = {
|
|
10
|
+
name: 'Potree',
|
|
11
|
+
id: 'potree',
|
|
12
|
+
module: 'potree',
|
|
13
|
+
version: VERSION,
|
|
14
|
+
extensions: ['bin', 'las', 'laz'],
|
|
15
|
+
mimeTypes: ['application/octet-stream'],
|
|
16
|
+
options: { url: undefined, potree: {} },
|
|
17
|
+
type: 'potree',
|
|
18
|
+
fromUrl: true,
|
|
19
|
+
fromBlob: true,
|
|
20
|
+
testURL: (url) => url.endsWith('.js'),
|
|
21
|
+
createDataSource: (url, props) => new PotreeNodesSource(url, props)
|
|
22
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/** Bounding box */
|
|
2
|
+
export interface PotreeBoundingBox {
|
|
3
|
+
/** Min X */
|
|
4
|
+
lx: number;
|
|
5
|
+
/** Min Y */
|
|
6
|
+
ly: number;
|
|
7
|
+
/** Min Z */
|
|
8
|
+
lz: number;
|
|
9
|
+
/** Max X */
|
|
10
|
+
ux: number;
|
|
11
|
+
/** Max Y */
|
|
12
|
+
uy: number;
|
|
13
|
+
/** Max Z */
|
|
14
|
+
uz: number;
|
|
15
|
+
}
|
|
16
|
+
/** Attribute types for *.bin content */
|
|
17
|
+
export type PotreeAttribute =
|
|
18
|
+
/** 3 (uint32) numbers: x, y, z */
|
|
19
|
+
'POSITION_CARTESIAN'
|
|
20
|
+
/** 4 x (uint8) numbers for the color: r, g, b, a */
|
|
21
|
+
| 'RGBA_PACKED'
|
|
22
|
+
/** 4 x (uint8) numbers for the color: r, g, b, a */
|
|
23
|
+
| 'COLOR_PACKED'
|
|
24
|
+
/** 3 x (uint8) numbers for the color: r, g, b */
|
|
25
|
+
| 'RGB_PACKED'
|
|
26
|
+
/** 3 x (float) numbers: x', y', z' */
|
|
27
|
+
| 'NORMAL_FLOATS'
|
|
28
|
+
/** (uint8) number */
|
|
29
|
+
| 'FILLER_1B'
|
|
30
|
+
/** (uint16) number specifying the point's intensity */
|
|
31
|
+
| 'INTENSITY'
|
|
32
|
+
/** (uint8) id for the class used */
|
|
33
|
+
| 'CLASSIFICATION'
|
|
34
|
+
/** Note: might need to be revisited, best don't use */
|
|
35
|
+
| 'NORMAL_SPHEREMAPPED'
|
|
36
|
+
/** Note: might need to be revisited, best don't use */
|
|
37
|
+
| 'NORMAL_OCT16'
|
|
38
|
+
/** 3 x (float) numbers: x', y', z' */
|
|
39
|
+
| 'NORMAL';
|
|
40
|
+
/** Hierarchy item: [node name leading with 'r', points count
|
|
41
|
+
* @example [r043, 145]
|
|
42
|
+
] */
|
|
43
|
+
export type HierarchyItem = [string, number];
|
|
44
|
+
/**
|
|
45
|
+
* Potree data set format metadata (cloud.js)
|
|
46
|
+
* @version 1.7
|
|
47
|
+
* @link https://github.com/potree/potree/blob/1.7/docs/potree-file-format.md
|
|
48
|
+
* */
|
|
49
|
+
export interface PotreeMetadata {
|
|
50
|
+
/** Version number in which this file is written */
|
|
51
|
+
version: string;
|
|
52
|
+
/** Folder that is used to load additional data */
|
|
53
|
+
octreeDir: string;
|
|
54
|
+
/** Amount of points contained in the whole pointcloud data */
|
|
55
|
+
points: number;
|
|
56
|
+
/**
|
|
57
|
+
* This parameter is used to transform the point data
|
|
58
|
+
* to the projection system used while visualizing the points. It has to be
|
|
59
|
+
* in a format that is parsable by [proj.4][proj4].
|
|
60
|
+
* */
|
|
61
|
+
projection: string;
|
|
62
|
+
/** Bounding box of the world used to limit the initial POV. */
|
|
63
|
+
boundingBox: PotreeBoundingBox;
|
|
64
|
+
/** Bounding box of the actual points in the data */
|
|
65
|
+
tightBoundingBox: PotreeBoundingBox;
|
|
66
|
+
/** Description of point attributes in data files */
|
|
67
|
+
pointAttributes: 'LAS' | 'LAZ' | PotreeAttribute[];
|
|
68
|
+
/**
|
|
69
|
+
* Space between points at the root node.
|
|
70
|
+
* This value is halved at each octree level.
|
|
71
|
+
* */
|
|
72
|
+
spacing: number;
|
|
73
|
+
/**
|
|
74
|
+
* Scale applied to convert POSITION_CARTESIAN components
|
|
75
|
+
* from uint32 values to floating point values. The full transformation
|
|
76
|
+
* to world coordinates is
|
|
77
|
+
* position = (POSITION_CARTESIAN * scale) + boundingBox.min
|
|
78
|
+
* */
|
|
79
|
+
scale: number;
|
|
80
|
+
/** Amount of Octree levels before a new folder hierarchy is expected. */
|
|
81
|
+
hierarchyStepSize: number;
|
|
82
|
+
/**
|
|
83
|
+
* The hierarchy of files, now loaded through index files.
|
|
84
|
+
* @deprecated
|
|
85
|
+
* */
|
|
86
|
+
hierarchy: HierarchyItem[];
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=potree-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"potree-metadata.d.ts","sourceRoot":"","sources":["../../src/types/potree-metadata.ts"],"names":[],"mappings":"AAIA,mBAAmB;AACnB,MAAM,WAAW,iBAAiB;IAChC,YAAY;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,YAAY;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,YAAY;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,YAAY;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,YAAY;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,YAAY;IACZ,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,wCAAwC;AACxC,MAAM,MAAM,eAAe;AACzB,kCAAkC;AAChC,oBAAoB;AACtB,oDAAoD;GAClD,aAAa;AACf,oDAAoD;GAClD,cAAc;AAChB,iDAAiD;GAC/C,YAAY;AACd,uCAAuC;GACrC,eAAe;AACjB,qBAAqB;GACnB,WAAW;AACb,uDAAuD;GACrD,WAAW;AACb,oCAAoC;GAClC,gBAAgB;AAClB,uDAAuD;GACrD,qBAAqB;AACvB,uDAAuD;GACrD,cAAc;AAChB,sCAAsC;GACpC,QAAQ,CAAC;AAEb;;IAEI;AACJ,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE7C;;;;KAIK;AACL,MAAM,WAAW,cAAc;IAC7B,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,MAAM,EAAE,MAAM,CAAC;IACf;;;;SAIK;IACL,UAAU,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,WAAW,EAAE,iBAAiB,CAAC;IAC/B,oDAAoD;IACpD,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,oDAAoD;IACpD,eAAe,EAAE,KAAK,GAAG,KAAK,GAAG,eAAe,EAAE,CAAC;IACnD;;;SAGK;IACL,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;SAKK;IACL,KAAK,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;;SAGK;IACL,SAAS,EAAE,aAAa,EAAE,CAAC;CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-version.d.ts","sourceRoot":"","sources":["../../src/utils/parse-version.ts"],"names":[],"mappings":"AAIA,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CAG5E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/potree",
|
|
3
|
-
"version": "4.3.0-alpha.
|
|
3
|
+
"version": "4.3.0-alpha.5",
|
|
4
4
|
"description": "potree loaders for large point clouds.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -44,11 +44,13 @@
|
|
|
44
44
|
"build-bundle-dev": "ocular-bundle ./bundle.ts --env=dev --output=dist/dist.dev.js"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@loaders.gl/
|
|
47
|
+
"@loaders.gl/las": "4.3.0-alpha.5",
|
|
48
|
+
"@loaders.gl/math": "4.3.0-alpha.5",
|
|
49
|
+
"@loaders.gl/schema": "4.3.0-alpha.5",
|
|
48
50
|
"@math.gl/core": "^4.0.0"
|
|
49
51
|
},
|
|
50
52
|
"peerDependencies": {
|
|
51
53
|
"@loaders.gl/core": "^4.0.0"
|
|
52
54
|
},
|
|
53
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "b57553345b3cbf621c95ad9b22aa672217451f61"
|
|
54
56
|
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {load} from '@loaders.gl/core';
|
|
6
|
+
import {MeshGeometry} from '@loaders.gl/schema';
|
|
7
|
+
import {DataSource, DataSourceProps, LoaderOptions, resolvePath} from '@loaders.gl/loader-utils';
|
|
8
|
+
import {LASLoader} from '@loaders.gl/las';
|
|
9
|
+
import {PotreeMetadata} from '../types/potree-metadata';
|
|
10
|
+
import {POTreeNode} from '../parsers/parse-potree-hierarchy-chunk';
|
|
11
|
+
import {PotreeHierarchyChunkLoader} from '../potree-hierarchy-chunk-loader';
|
|
12
|
+
import {PotreeLoader} from '../potree-loader';
|
|
13
|
+
import {parseVersion} from '../utils/parse-version';
|
|
14
|
+
|
|
15
|
+
export type PotreeNodesSourceProps = DataSourceProps & {
|
|
16
|
+
attributions?: string[];
|
|
17
|
+
potree?: {
|
|
18
|
+
loadOptions?: LoaderOptions; // PotreeLoaderOptions;
|
|
19
|
+
// TODO - add options here
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A Potree data source
|
|
25
|
+
* @version 1.0 - https://github.com/potree/potree/blob/1.0RC/docs/file_format.md
|
|
26
|
+
* @version 1.7 - https://github.com/potree/potree/blob/1.7/docs/potree-file-format.md
|
|
27
|
+
* @note Point cloud nodes tile source
|
|
28
|
+
*/
|
|
29
|
+
export class PotreeNodesSource extends DataSource {
|
|
30
|
+
/** Dataset base URL */
|
|
31
|
+
baseUrl: string = '';
|
|
32
|
+
/** Input data: string - dataset url, blob - single file data */
|
|
33
|
+
data: string | Blob;
|
|
34
|
+
/** Input props */
|
|
35
|
+
props: PotreeNodesSourceProps;
|
|
36
|
+
/** Meta information from `cloud.js` */
|
|
37
|
+
metadata: PotreeMetadata | null = null;
|
|
38
|
+
/** Root node */
|
|
39
|
+
root: POTreeNode | null = null;
|
|
40
|
+
/** Is data source ready to use after initial loading */
|
|
41
|
+
isReady = false;
|
|
42
|
+
|
|
43
|
+
private initPromise: Promise<void> | null = null;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @constructor
|
|
47
|
+
* @param data - if string - data set path url or path to `cloud.js` metadata file
|
|
48
|
+
* - if Blob - single file data
|
|
49
|
+
* @param props - data source properties
|
|
50
|
+
*/
|
|
51
|
+
constructor(data: string | Blob, props: PotreeNodesSourceProps) {
|
|
52
|
+
super(props);
|
|
53
|
+
this.props = props;
|
|
54
|
+
this.data = data;
|
|
55
|
+
this.makeBaseUrl(this.data);
|
|
56
|
+
|
|
57
|
+
this.initPromise = this.init();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Initial data source loading */
|
|
61
|
+
async init() {
|
|
62
|
+
this.metadata = await load(`${this.baseUrl}/cloud.js`, PotreeLoader);
|
|
63
|
+
await this.loadHierarchy();
|
|
64
|
+
this.isReady = true;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Is data set supported */
|
|
68
|
+
isSupported(): boolean {
|
|
69
|
+
const {minor, major} = parseVersion(this.metadata?.version ?? '');
|
|
70
|
+
return (
|
|
71
|
+
this.isReady &&
|
|
72
|
+
major === 1 &&
|
|
73
|
+
minor < 2 &&
|
|
74
|
+
typeof this.metadata?.pointAttributes === 'string' &&
|
|
75
|
+
['LAS', 'LAZ'].includes(this.metadata?.pointAttributes)
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Get content files extension */
|
|
80
|
+
getContentExtension(): string | null {
|
|
81
|
+
if (!this.isReady) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
switch (this.metadata?.pointAttributes) {
|
|
85
|
+
case 'LAS':
|
|
86
|
+
return 'las';
|
|
87
|
+
case 'LAZ':
|
|
88
|
+
return 'laz';
|
|
89
|
+
default:
|
|
90
|
+
return 'bin';
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Load octree node content
|
|
96
|
+
* @param path array of numbers between 0-7 specifying successive octree divisions.
|
|
97
|
+
* @return node content geometry or null if the node doesn't exist
|
|
98
|
+
*/
|
|
99
|
+
async loadNodeContent(path: number[]): Promise<MeshGeometry | null> {
|
|
100
|
+
await this.initPromise;
|
|
101
|
+
|
|
102
|
+
if (!this.isSupported()) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const isAvailable = await this.isNodeAvailable(path);
|
|
107
|
+
if (isAvailable) {
|
|
108
|
+
return load(
|
|
109
|
+
`${this.baseUrl}/${this.metadata
|
|
110
|
+
?.octreeDir}/r/r${path.join()}.${this.getContentExtension()}`,
|
|
111
|
+
LASLoader
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Load data source hierarchy into tree of available nodes
|
|
119
|
+
*/
|
|
120
|
+
async loadHierarchy(): Promise<void> {
|
|
121
|
+
await this.initPromise;
|
|
122
|
+
this.root = await load(
|
|
123
|
+
`${this.baseUrl}/${this.metadata?.octreeDir}/r/r.hrc`,
|
|
124
|
+
PotreeHierarchyChunkLoader
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Check if a node exists in the octree
|
|
130
|
+
* @param path array of numbers between 0-7 specifying successive octree divisions
|
|
131
|
+
* @returns true - the node does exist, false - the nodes doesn't exist
|
|
132
|
+
*/
|
|
133
|
+
async isNodeAvailable(path: number[]): Promise<boolean> {
|
|
134
|
+
if (this.metadata?.hierarchy) {
|
|
135
|
+
return this.metadata.hierarchy.findIndex((item) => item[0] === `r${path.join()}`) !== -1;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (!this.root) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
let currentParent = this.root;
|
|
142
|
+
let name = '';
|
|
143
|
+
let result = true;
|
|
144
|
+
for (const nodeLevel of path) {
|
|
145
|
+
const newName = `${name}${nodeLevel}`;
|
|
146
|
+
const node = currentParent.children.find((child) => child.name === newName);
|
|
147
|
+
if (node) {
|
|
148
|
+
currentParent = node;
|
|
149
|
+
name = newName;
|
|
150
|
+
} else {
|
|
151
|
+
result = false;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return result;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Deduce base url from the input url sring
|
|
160
|
+
* @param data - data source input data
|
|
161
|
+
*/
|
|
162
|
+
private makeBaseUrl(data: string | Blob): void {
|
|
163
|
+
this.baseUrl = typeof data === 'string' ? resolvePath(data) : '';
|
|
164
|
+
if (this.baseUrl.endsWith('cloud.js')) {
|
|
165
|
+
this.baseUrl = this.baseUrl.substring(0, -8);
|
|
166
|
+
}
|
|
167
|
+
if (this.baseUrl.endsWith('/')) {
|
|
168
|
+
this.baseUrl = this.baseUrl.substring(0, -1);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -7,20 +7,27 @@ import type {POTreeLoaderOptions} from './potree-loader';
|
|
|
7
7
|
import type {POTreeNode} from './parsers/parse-potree-hierarchy-chunk';
|
|
8
8
|
import {parsePotreeHierarchyChunk} from './parsers/parse-potree-hierarchy-chunk';
|
|
9
9
|
|
|
10
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
11
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
12
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
13
|
+
|
|
10
14
|
/** Potree hierarchy chunk loader */
|
|
11
|
-
// @ts-ignore not a valid loader
|
|
12
15
|
export const PotreeHierarchyChunkLoader = {
|
|
13
16
|
dataType: null as unknown as POTreeNode,
|
|
14
17
|
batchType: null as never,
|
|
15
18
|
|
|
16
|
-
id: 'potree',
|
|
17
19
|
name: 'potree Hierarchy Chunk',
|
|
20
|
+
id: 'potree-hrc',
|
|
21
|
+
module: 'potree',
|
|
22
|
+
version: VERSION,
|
|
18
23
|
extensions: ['hrc'],
|
|
19
24
|
mimeTypes: ['application/octet-stream'],
|
|
20
25
|
// binary potree files have no header bytes, no content test function possible
|
|
21
26
|
// test: ['...'],
|
|
22
27
|
parse: async (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),
|
|
23
28
|
parseSync: (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),
|
|
29
|
+
options: {
|
|
30
|
+
potree: {}
|
|
31
|
+
},
|
|
24
32
|
binary: true
|
|
25
|
-
// @ts-ignore
|
|
26
33
|
} as const satisfies LoaderWithParser<POTreeNode, never, POTreeLoaderOptions>;
|
package/src/potree-loader.ts
CHANGED
|
@@ -13,21 +13,20 @@ export type POTreeLoaderOptions = LoaderOptions & {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
/** Potree loader */
|
|
16
|
-
// @ts-ignore
|
|
17
16
|
export const PotreeLoader = {
|
|
18
17
|
dataType: null as unknown as any,
|
|
19
18
|
batchType: null as never,
|
|
20
19
|
|
|
21
|
-
name: 'potree',
|
|
20
|
+
name: 'potree metadata',
|
|
22
21
|
id: 'potree',
|
|
23
22
|
module: 'potree',
|
|
24
23
|
version: VERSION,
|
|
25
|
-
extensions: ['
|
|
24
|
+
extensions: ['js'],
|
|
26
25
|
mimeTypes: ['application/json'],
|
|
27
26
|
testText: (text) => text.indexOf('octreeDir') >= 0,
|
|
27
|
+
parse: (data: ArrayBuffer) => JSON.parse(new TextDecoder().decode(data)),
|
|
28
28
|
parseTextSync: (text) => JSON.parse(text),
|
|
29
29
|
options: {
|
|
30
30
|
potree: {}
|
|
31
31
|
}
|
|
32
|
-
// @ts-ignore
|
|
33
32
|
} as const satisfies LoaderWithParser<any, never, POTreeLoaderOptions>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {Source} from '@loaders.gl/loader-utils';
|
|
6
|
+
import {PotreeNodesSource, PotreeNodesSourceProps} from './lib/potree-node-source';
|
|
7
|
+
|
|
8
|
+
const VERSION = '1.7';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Creates point cloud data sources for Potree urls
|
|
12
|
+
*/
|
|
13
|
+
export const PotreeSource = {
|
|
14
|
+
name: 'Potree',
|
|
15
|
+
id: 'potree',
|
|
16
|
+
module: 'potree',
|
|
17
|
+
version: VERSION,
|
|
18
|
+
extensions: ['bin', 'las', 'laz'],
|
|
19
|
+
mimeTypes: ['application/octet-stream'],
|
|
20
|
+
options: {url: undefined!, potree: {}},
|
|
21
|
+
type: 'potree',
|
|
22
|
+
fromUrl: true,
|
|
23
|
+
fromBlob: true,
|
|
24
|
+
|
|
25
|
+
testURL: (url: string) => url.endsWith('.js'),
|
|
26
|
+
createDataSource: (url: string | Blob, props: PotreeNodesSourceProps) =>
|
|
27
|
+
new PotreeNodesSource(url, props)
|
|
28
|
+
} as const satisfies Source<PotreeNodesSource, PotreeNodesSourceProps>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
/** Bounding box */
|
|
6
|
+
export interface PotreeBoundingBox {
|
|
7
|
+
/** Min X */
|
|
8
|
+
lx: number;
|
|
9
|
+
/** Min Y */
|
|
10
|
+
ly: number;
|
|
11
|
+
/** Min Z */
|
|
12
|
+
lz: number;
|
|
13
|
+
/** Max X */
|
|
14
|
+
ux: number;
|
|
15
|
+
/** Max Y */
|
|
16
|
+
uy: number;
|
|
17
|
+
/** Max Z */
|
|
18
|
+
uz: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Attribute types for *.bin content */
|
|
22
|
+
export type PotreeAttribute =
|
|
23
|
+
/** 3 (uint32) numbers: x, y, z */
|
|
24
|
+
| 'POSITION_CARTESIAN'
|
|
25
|
+
/** 4 x (uint8) numbers for the color: r, g, b, a */
|
|
26
|
+
| 'RGBA_PACKED'
|
|
27
|
+
/** 4 x (uint8) numbers for the color: r, g, b, a */
|
|
28
|
+
| 'COLOR_PACKED'
|
|
29
|
+
/** 3 x (uint8) numbers for the color: r, g, b */
|
|
30
|
+
| 'RGB_PACKED'
|
|
31
|
+
/** 3 x (float) numbers: x', y', z' */
|
|
32
|
+
| 'NORMAL_FLOATS'
|
|
33
|
+
/** (uint8) number */
|
|
34
|
+
| 'FILLER_1B'
|
|
35
|
+
/** (uint16) number specifying the point's intensity */
|
|
36
|
+
| 'INTENSITY'
|
|
37
|
+
/** (uint8) id for the class used */
|
|
38
|
+
| 'CLASSIFICATION'
|
|
39
|
+
/** Note: might need to be revisited, best don't use */
|
|
40
|
+
| 'NORMAL_SPHEREMAPPED'
|
|
41
|
+
/** Note: might need to be revisited, best don't use */
|
|
42
|
+
| 'NORMAL_OCT16'
|
|
43
|
+
/** 3 x (float) numbers: x', y', z' */
|
|
44
|
+
| 'NORMAL';
|
|
45
|
+
|
|
46
|
+
/** Hierarchy item: [node name leading with 'r', points count
|
|
47
|
+
* @example [r043, 145]
|
|
48
|
+
] */
|
|
49
|
+
export type HierarchyItem = [string, number];
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Potree data set format metadata (cloud.js)
|
|
53
|
+
* @version 1.7
|
|
54
|
+
* @link https://github.com/potree/potree/blob/1.7/docs/potree-file-format.md
|
|
55
|
+
* */
|
|
56
|
+
export interface PotreeMetadata {
|
|
57
|
+
/** Version number in which this file is written */
|
|
58
|
+
version: string;
|
|
59
|
+
/** Folder that is used to load additional data */
|
|
60
|
+
octreeDir: string;
|
|
61
|
+
/** Amount of points contained in the whole pointcloud data */
|
|
62
|
+
points: number;
|
|
63
|
+
/**
|
|
64
|
+
* This parameter is used to transform the point data
|
|
65
|
+
* to the projection system used while visualizing the points. It has to be
|
|
66
|
+
* in a format that is parsable by [proj.4][proj4].
|
|
67
|
+
* */
|
|
68
|
+
projection: string;
|
|
69
|
+
/** Bounding box of the world used to limit the initial POV. */
|
|
70
|
+
boundingBox: PotreeBoundingBox;
|
|
71
|
+
/** Bounding box of the actual points in the data */
|
|
72
|
+
tightBoundingBox: PotreeBoundingBox;
|
|
73
|
+
/** Description of point attributes in data files */
|
|
74
|
+
pointAttributes: 'LAS' | 'LAZ' | PotreeAttribute[];
|
|
75
|
+
/**
|
|
76
|
+
* Space between points at the root node.
|
|
77
|
+
* This value is halved at each octree level.
|
|
78
|
+
* */
|
|
79
|
+
spacing: number;
|
|
80
|
+
/**
|
|
81
|
+
* Scale applied to convert POSITION_CARTESIAN components
|
|
82
|
+
* from uint32 values to floating point values. The full transformation
|
|
83
|
+
* to world coordinates is
|
|
84
|
+
* position = (POSITION_CARTESIAN * scale) + boundingBox.min
|
|
85
|
+
* */
|
|
86
|
+
scale: number;
|
|
87
|
+
/** Amount of Octree levels before a new folder hierarchy is expected. */
|
|
88
|
+
hierarchyStepSize: number;
|
|
89
|
+
/**
|
|
90
|
+
* The hierarchy of files, now loaded through index files.
|
|
91
|
+
* @deprecated
|
|
92
|
+
* */
|
|
93
|
+
hierarchy: HierarchyItem[];
|
|
94
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
export function parseVersion(version: string): {major: number; minor: number} {
|
|
6
|
+
const parts = version.split('.').map(Number);
|
|
7
|
+
return {major: parts[0], minor: parts[1]};
|
|
8
|
+
}
|