@loaders.gl/potree 3.4.10 → 3.4.12

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.
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.PotreeLoader = void 0;
7
- var VERSION = typeof "3.4.10" !== 'undefined' ? "3.4.10" : 'latest';
7
+ var VERSION = typeof "3.4.12" !== 'undefined' ? "3.4.12" : 'latest';
8
8
  var PotreeLoader = {
9
9
  name: 'potree',
10
10
  id: 'potree',
@@ -1,4 +1,4 @@
1
- const VERSION = typeof "3.4.10" !== 'undefined' ? "3.4.10" : 'latest';
1
+ const VERSION = typeof "3.4.12" !== 'undefined' ? "3.4.12" : 'latest';
2
2
  export const PotreeLoader = {
3
3
  name: 'potree',
4
4
  id: 'potree',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/potree",
3
- "version": "3.4.10",
3
+ "version": "3.4.12",
4
4
  "description": "potree loaders for large point clouds.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -35,8 +35,8 @@
35
35
  "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/dist.min.js"
36
36
  },
37
37
  "dependencies": {
38
- "@loaders.gl/math": "3.4.10",
38
+ "@loaders.gl/math": "3.4.12",
39
39
  "@math.gl/core": "^3.5.1"
40
40
  },
41
- "gitHead": "4568459c96eaf0480a50ab77cace355307f61f04"
41
+ "gitHead": "85254762ae3082f608a863291deef09f2b40c6cf"
42
42
  }
package/dist/bundle.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- // @ts-nocheck
3
- const moduleExports = require('./index');
4
- globalThis.loaders = globalThis.loaders || {};
5
- module.exports = Object.assign(globalThis.loaders, moduleExports);
package/dist/index.js DELETED
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PotreeBinLoader = exports.PotreeHierarchyChunkLoader = exports.PotreeLoader = void 0;
4
- var potree_loader_1 = require("./potree-loader");
5
- Object.defineProperty(exports, "PotreeLoader", { enumerable: true, get: function () { return potree_loader_1.PotreeLoader; } });
6
- var potree_hierarchy_chunk_loader_1 = require("./potree-hierarchy-chunk-loader");
7
- Object.defineProperty(exports, "PotreeHierarchyChunkLoader", { enumerable: true, get: function () { return potree_hierarchy_chunk_loader_1.PotreeHierarchyChunkLoader; } });
8
- var potree_bin_loader_1 = require("./potree-bin-loader");
9
- Object.defineProperty(exports, "PotreeBinLoader", { enumerable: true, get: function () { return potree_bin_loader_1.PotreeBinLoader; } });
@@ -1,197 +0,0 @@
1
- "use strict";
2
- /* eslint-disable */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.PointCloudOctant = exports.PointCloudOctree = void 0;
5
- // @ts-nocheck
6
- class PointCloudOctree {
7
- constructor() {
8
- this.url = null;
9
- this.octreeDir = null;
10
- this.spacing = 0;
11
- this.boundingBox = null;
12
- this.root = null;
13
- this.nodes = null;
14
- this.pointAttributes = null;
15
- this.hierarchyStepSize = -1;
16
- this.loader = null;
17
- }
18
- }
19
- exports.PointCloudOctree = PointCloudOctree;
20
- class PointCloudOctant {
21
- constructor(name, octree, boundingBox) {
22
- this.octree = this.id = PointCloudOctreeGeometryNode.IDCount++;
23
- this.name = name;
24
- this.index = parseInt(name.charAt(name.length - 1));
25
- this.octree = octree;
26
- this.geometry = null;
27
- this.boundingBox = boundingBox;
28
- this.boundingSphere = boundingBox.getBoundingSphere(new THREE.Sphere());
29
- this.children = {};
30
- this.numPoints = 0;
31
- this.level = null;
32
- this.loaded = false;
33
- this.oneTimeDisposeHandlers = [];
34
- }
35
- isGeometryNode() {
36
- return true;
37
- }
38
- getLevel() {
39
- return this.level;
40
- }
41
- isTreeNode() {
42
- return false;
43
- }
44
- isLoaded() {
45
- return this.loaded;
46
- }
47
- getBoundingSphere() {
48
- return this.boundingSphere;
49
- }
50
- getBoundingBox() {
51
- return this.boundingBox;
52
- }
53
- getChildren() {
54
- // Children is a length 8 array with nulls for "missing" octants
55
- return this.children.filter(Boolean);
56
- }
57
- getURL() {
58
- const { version } = this.octree;
59
- const hierarchyPath = version >= 1.5 ? `${this.getHierarchyPath()}/` : '';
60
- return `${this.octree.octreeDir}/${hierarchyPath}${this.name}`;
61
- }
62
- getHierarchyPath() {
63
- let path = 'r/';
64
- let hierarchyStepSize = this.octree.hierarchyStepSize;
65
- let indices = this.name.substr(1);
66
- let numParts = Math.floor(indices.length / hierarchyStepSize);
67
- for (let i = 0; i < numParts; i++) {
68
- path += indices.substr(i * hierarchyStepSize, hierarchyStepSize) + '/';
69
- }
70
- path = path.slice(0, -1);
71
- return path;
72
- }
73
- addChild(child) {
74
- this.children[child.index] = child;
75
- child.parent = this;
76
- }
77
- load() {
78
- if (this.loading === true ||
79
- this.loaded === true ||
80
- Potree.numNodesLoading >= Potree.maxNodesLoading) {
81
- return;
82
- }
83
- this.loading = true;
84
- Potree.numNodesLoading++;
85
- if (this.octree.loader.version.equalOrHigher('1.5')) {
86
- if (this.level % this.octree.hierarchyStepSize === 0 && this.hasChildren) {
87
- this.loadHierachyThenPoints();
88
- }
89
- else {
90
- this.loadPoints();
91
- }
92
- }
93
- else {
94
- this.loadPoints();
95
- }
96
- }
97
- loadPoints() {
98
- this.octree.loader.load(this);
99
- }
100
- loadHierachyThenPoints() {
101
- let node = this;
102
- // load hierarchy
103
- let callback = function (node, hbuffer) {
104
- let view = new DataView(hbuffer);
105
- let stack = [];
106
- let children = view.getUint8(0);
107
- let numPoints = view.getUint32(1, true);
108
- node.numPoints = numPoints;
109
- stack.push({ children: children, numPoints: numPoints, name: node.name });
110
- let decoded = [];
111
- let offset = 5;
112
- while (stack.length > 0) {
113
- let snode = stack.shift();
114
- let mask = 1;
115
- for (let i = 0; i < 8; i++) {
116
- if ((snode.children & mask) !== 0) {
117
- let childName = snode.name + i;
118
- let childChildren = view.getUint8(offset);
119
- let childNumPoints = view.getUint32(offset + 1, true);
120
- stack.push({ children: childChildren, numPoints: childNumPoints, name: childName });
121
- decoded.push({ children: childChildren, numPoints: childNumPoints, name: childName });
122
- offset += 5;
123
- }
124
- mask = mask * 2;
125
- }
126
- if (offset === hbuffer.byteLength) {
127
- break;
128
- }
129
- }
130
- // console.log(decoded);
131
- let nodes = {};
132
- nodes[node.name] = node;
133
- let pco = node.pcoGeometry;
134
- for (let i = 0; i < decoded.length; i++) {
135
- let name = decoded[i].name;
136
- let decodedNumPoints = decoded[i].numPoints;
137
- let index = parseInt(name.charAt(name.length - 1));
138
- let parentName = name.substring(0, name.length - 1);
139
- let parentNode = nodes[parentName];
140
- let level = name.length - 1;
141
- let boundingBox = Utils.createChildAABB(parentNode.boundingBox, index);
142
- let currentNode = new PointCloudOctreeGeometryNode(name, pco, boundingBox);
143
- currentNode.level = level;
144
- currentNode.numPoints = decodedNumPoints;
145
- currentNode.hasChildren = decoded[i].children > 0;
146
- currentNode.spacing = pco.spacing / Math.pow(2, level);
147
- parentNode.addChild(currentNode);
148
- nodes[name] = currentNode;
149
- }
150
- node.loadPoints();
151
- };
152
- if (node.level % node.pcoGeometry.hierarchyStepSize === 0) {
153
- // let hurl = node.pcoGeometry.octreeDir + "/../hierarchy/" + node.name + ".hrc";
154
- let hurl = node.pcoGeometry.octreeDir + '/' + node.getHierarchyPath() + '/' + node.name + '.hrc';
155
- let xhr = XHRFactory.createXMLHttpRequest();
156
- xhr.open('GET', hurl, true);
157
- xhr.responseType = 'arraybuffer';
158
- xhr.overrideMimeType('text/plain; charset=x-user-defined');
159
- xhr.onreadystatechange = () => {
160
- if (xhr.readyState === 4) {
161
- if (xhr.status === 200 || xhr.status === 0) {
162
- let hbuffer = xhr.response;
163
- callback(node, hbuffer);
164
- }
165
- else {
166
- console.log('Failed to load file! HTTP status: ' + xhr.status + ', file: ' + hurl);
167
- Potree.numNodesLoading--;
168
- }
169
- }
170
- };
171
- try {
172
- xhr.send(null);
173
- }
174
- catch (e) {
175
- console.log('fehler beim laden der punktwolke: ' + e);
176
- }
177
- }
178
- }
179
- getNumPoints() {
180
- return this.numPoints;
181
- }
182
- dispose() {
183
- if (this.geometry && this.parent != null) {
184
- this.geometry.dispose();
185
- this.geometry = null;
186
- this.loaded = false;
187
- // this.dispatchEvent( { type: 'dispose' } );
188
- for (let i = 0; i < this.oneTimeDisposeHandlers.length; i++) {
189
- let handler = this.oneTimeDisposeHandlers[i];
190
- handler();
191
- }
192
- this.oneTimeDisposeHandlers = [];
193
- }
194
- }
195
- }
196
- exports.PointCloudOctant = PointCloudOctant;
197
- PointCloudOctreeGeometryNode.IDCount = 0;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function parsePotreeBin(arrayBuffer, byteOffset, options, index) {
4
- return null;
5
- }
6
- exports.default = parsePotreeBin;
@@ -1,129 +0,0 @@
1
- "use strict";
2
- // This file is derived from the Cesium code base under BSD 2-clause license
3
- // See LICENSE.md and https://github.com/potree/potree/blob/develop/LICENSE
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- // Potree Hierarchy Chunk file format
6
- // https://github.com/potree/potree/blob/develop/docs/potree-file-format.md#index-files
7
- /*
8
- ### Hierarchy Chunk Files
9
-
10
- As mentioned in the former section, the `.hrc` files contain the index structure
11
- meaning a list of all the files stored within the directory tree.
12
-
13
- An index file contains a list of tuple values with the first being a `uint8`
14
- "mask" and the second being `uint32` "number of points" of a hierarchy level
15
- in a [breadth first level order][breadth-first].
16
-
17
- Per hierarchy level we have 8 possible nodes. To indicate whether a node exists
18
- a simple binary mask is used:
19
-
20
- | Position | Mask | [Binary][bin] |
21
- |----------|------|---------------|
22
- | 0 | 1 | 0b00000001 |
23
- | 1 | 2 | 0b00000010 |
24
- | 2 | 4 | 0b00000100 |
25
- | 3 | 8 | 0b00001000 |
26
- | 4 | 16 | 0b00010000 |
27
- | 5 | 32 | 0b00100000 |
28
- | 6 | 64 | 0b01000000 |
29
- | 7 | 128 | 0b10000000 |
30
-
31
- So if in a hierarchy the child node 3 and node 7 exist then the hierarchies
32
- mask has to be `0b00001000 | 0b10000000` → `0b10001000` (=136).
33
-
34
- _Example:_ A simple, non-realistic tree:
35
-
36
- ```
37
- |- r1
38
- | |
39
- | \- r14 (2 Points)
40
- |
41
- \- r3
42
- |
43
- \- r36 (1 Point)
44
- ```
45
-
46
- Would have an index looking like this:
47
-
48
- | name | mask | points |
49
- |------|--------------------|--------|
50
- | r | `0b00001010` (=10) | `3` |
51
- | r1 | `0b00010000` (=16) | `2` |
52
- | r3 | `0b01000000` (=64) | `1` |
53
- | r14 | `0b00000000` (=0) | `2` |
54
- | r36 | `0b00000000` (=0) | `1` |
55
- */
56
- // @ts-nocheck
57
- // load hierarchy
58
- function parsePotreeHierarchyChunk(arrayBuffer) {
59
- const tileHeaders = parseBinaryChunk(arrayBuffer);
60
- return buildHierarchy(tileHeaders);
61
- }
62
- exports.default = parsePotreeHierarchyChunk;
63
- // Parses the binary rows
64
- function parseBinaryChunk(arrayBuffer, byteOffset = 0) {
65
- const dataView = new DataView(arrayBuffer);
66
- const stack = [];
67
- // Get root mask
68
- const topTileHeader = {};
69
- byteOffset = decodeRow(dataView, byteOffset, topTileHeader);
70
- stack.push(topTileHeader);
71
- const tileHeaders = [];
72
- while (stack.length > 0) {
73
- const snode = stack.shift();
74
- let mask = 1;
75
- for (let i = 0; i < 8; i++) {
76
- if (snode && (snode.header.childMask & mask) !== 0) {
77
- const tileHeader = {};
78
- byteOffset = decodeRow(dataView, byteOffset, tileHeader);
79
- tileHeader.name = snode.name + i;
80
- stack.push(tileHeader);
81
- tileHeaders.push(tileHeader);
82
- snode.header.childCount++;
83
- }
84
- mask = mask * 2;
85
- }
86
- if (byteOffset === dataView.byteLength) {
87
- break;
88
- }
89
- }
90
- return tileHeaders;
91
- }
92
- function decodeRow(dataView, byteOffset, tileHeader) {
93
- tileHeader.header = tileHeader.header || {};
94
- tileHeader.header.childMask = dataView.getUint8(byteOffset);
95
- tileHeader.header.childCount = 0;
96
- tileHeader.pointCount = dataView.getUint32(byteOffset + 1, true);
97
- tileHeader.name = '';
98
- byteOffset += 5;
99
- return byteOffset;
100
- }
101
- // Resolves the binary rows into a hierarchy (tree structure)
102
- function buildHierarchy(tileHeaders, options = {}) {
103
- const DEFAULT_OPTIONS = { spacing: 100 }; // TODO assert instead of default?
104
- options = { ...DEFAULT_OPTIONS, ...options };
105
- const topNode = tileHeaders[0];
106
- const nodes = {};
107
- for (const tileHeader of tileHeaders) {
108
- const { name } = tileHeader;
109
- const index = parseInt(name.charAt(name.length - 1), 10);
110
- const parentName = name.substring(0, name.length - 1);
111
- const parentNode = nodes[parentName];
112
- const level = name.length - 1;
113
- // assert(parentNode && level >= 0);
114
- tileHeader.level = level;
115
- tileHeader.hasChildren = tileHeader.header.childCount;
116
- tileHeader.children = [];
117
- tileHeader.childrenByIndex = new Array(8).fill(null);
118
- tileHeader.spacing = options.spacing / Math.pow(2, level);
119
- // tileHeader.boundingVolume = Utils.createChildAABB(parentNode.boundingBox, index);
120
- if (parentNode) {
121
- parentNode.children.push(tileHeader);
122
- parentNode.childrenByIndex[index] = tileHeader;
123
- }
124
- // Add the node to the map
125
- nodes[name] = tileHeader;
126
- }
127
- // First node is the root
128
- return topNode;
129
- }
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PotreeBinLoader = void 0;
7
- const parse_potree_bin_1 = __importDefault(require("./parsers/parse-potree-bin"));
8
- /**
9
- * Loader for potree Binary Point Attributes
10
- * */
11
- // @ts-ignore
12
- exports.PotreeBinLoader = {
13
- name: 'potree Binary Point Attributes',
14
- id: 'potree',
15
- extensions: ['bin'],
16
- mimeTypes: ['application/octet-stream'],
17
- // Unfortunately binary potree files have no header bytes, no test possible
18
- // test: ['...'],
19
- parseSync,
20
- binary: true
21
- };
22
- function parseSync(arrayBuffer, options) {
23
- const index = {};
24
- const byteOffset = 0;
25
- (0, parse_potree_bin_1.default)(arrayBuffer, byteOffset, options, index);
26
- return index;
27
- }
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PotreeHierarchyChunkLoader = void 0;
7
- const parse_potree_hierarchy_chunk_1 = __importDefault(require("./parsers/parse-potree-hierarchy-chunk"));
8
- /** Potree hierarchy chunk loader */
9
- // @ts-ignore
10
- exports.PotreeHierarchyChunkLoader = {
11
- id: 'potree',
12
- name: 'potree Hierarchy Chunk',
13
- extensions: ['hrc'],
14
- mimeTypes: ['application/octet-stream'],
15
- // binary potree files have no header bytes, no content test function possible
16
- // test: ['...'],
17
- parse: async (arrayBuffer, options) => await parseSync(arrayBuffer),
18
- parseSync,
19
- binary: true
20
- };
21
- function parseSync(arrayBuffer) {
22
- return (0, parse_potree_hierarchy_chunk_1.default)(arrayBuffer);
23
- }
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PotreeLoader = void 0;
4
- // __VERSION__ is injected by babel-plugin-version-inline
5
- // @ts-ignore TS2304: Cannot find name '__VERSION__'.
6
- const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
7
- /** Potree loader */
8
- // @ts-ignore
9
- exports.PotreeLoader = {
10
- name: 'potree',
11
- id: 'potree',
12
- module: 'potree',
13
- version: VERSION,
14
- extensions: ['json'],
15
- mimeTypes: ['application/json'],
16
- testText: (text) => text.indexOf('octreeDir') >= 0,
17
- parseTextSync: (text) => JSON.parse(text),
18
- options: {
19
- potree: {}
20
- }
21
- };