@loaders.gl/potree 3.1.0-alpha.4 → 3.1.0-beta.3

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.
Files changed (53) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +182 -0
  4. package/dist/es5/bundle.js +1 -1
  5. package/dist/es5/bundle.js.map +1 -1
  6. package/dist/es5/index.js +3 -3
  7. package/dist/es5/lib/octree.js +188 -208
  8. package/dist/es5/lib/octree.js.map +1 -1
  9. package/dist/es5/parsers/parse-potree-bin.js.map +1 -1
  10. package/dist/es5/parsers/parse-potree-hierarchy-chunk.js +37 -59
  11. package/dist/es5/parsers/parse-potree-hierarchy-chunk.js.map +1 -1
  12. package/dist/es5/potree-bin-loader.js +4 -4
  13. package/dist/es5/potree-bin-loader.js.map +1 -1
  14. package/dist/es5/potree-hierarchy-chunk-loader.js +3 -32
  15. package/dist/es5/potree-hierarchy-chunk-loader.js.map +1 -1
  16. package/dist/es5/potree-loader.js +4 -8
  17. package/dist/es5/potree-loader.js.map +1 -1
  18. package/dist/esm/lib/octree.js +2 -2
  19. package/dist/esm/lib/octree.js.map +1 -1
  20. package/dist/esm/parsers/parse-potree-bin.js.map +1 -1
  21. package/dist/esm/parsers/parse-potree-hierarchy-chunk.js.map +1 -1
  22. package/dist/esm/potree-bin-loader.js.map +1 -1
  23. package/dist/esm/potree-loader.js +1 -1
  24. package/dist/esm/potree-loader.js.map +1 -1
  25. package/dist/index.d.ts +4 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +9 -0
  28. package/dist/lib/octree.d.ts +22 -0
  29. package/dist/lib/octree.d.ts.map +1 -0
  30. package/dist/lib/octree.js +197 -0
  31. package/dist/parsers/parse-potree-bin.d.ts +2 -0
  32. package/dist/parsers/parse-potree-bin.d.ts.map +1 -0
  33. package/dist/parsers/parse-potree-bin.js +6 -0
  34. package/dist/parsers/parse-potree-hierarchy-chunk.d.ts +2 -0
  35. package/dist/parsers/parse-potree-hierarchy-chunk.d.ts.map +1 -0
  36. package/dist/parsers/parse-potree-hierarchy-chunk.js +129 -0
  37. package/dist/potree-bin-loader.d.ts +6 -0
  38. package/dist/potree-bin-loader.d.ts.map +1 -0
  39. package/dist/potree-bin-loader.js +27 -0
  40. package/dist/potree-hierarchy-chunk-loader.d.ts +4 -0
  41. package/dist/potree-hierarchy-chunk-loader.d.ts.map +1 -0
  42. package/dist/potree-hierarchy-chunk-loader.js +23 -0
  43. package/dist/potree-loader.d.ts +4 -0
  44. package/dist/potree-loader.d.ts.map +1 -0
  45. package/dist/potree-loader.js +21 -0
  46. package/package.json +5 -5
  47. package/src/lib/{octree.js → octree.ts} +0 -0
  48. package/src/parsers/parse-potree-bin.ts +8 -0
  49. package/src/parsers/{parse-potree-hierarchy-chunk.js → parse-potree-hierarchy-chunk.ts} +4 -2
  50. package/src/potree-bin-loader.ts +2 -2
  51. package/dist/dist.min.js +0 -2
  52. package/dist/dist.min.js.map +0 -1
  53. package/src/parsers/parse-potree-bin.js +0 -3
@@ -0,0 +1,2 @@
1
+ declare const moduleExports: any;
2
+ //# sourceMappingURL=bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,aAAa,KAAqB,CAAC"}
package/dist/bundle.js ADDED
@@ -0,0 +1,182 @@
1
+ (() => {
2
+ var __defProp = Object.defineProperty;
3
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
4
+ var __esm = (fn, res) => function __init() {
5
+ return fn && (res = (0, fn[Object.keys(fn)[0]])(fn = 0)), res;
6
+ };
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __export = (target, all) => {
11
+ __markAsModule(target);
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+
16
+ // src/potree-loader.ts
17
+ var VERSION, PotreeLoader;
18
+ var init_potree_loader = __esm({
19
+ "src/potree-loader.ts"() {
20
+ VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
21
+ PotreeLoader = {
22
+ name: "potree",
23
+ id: "potree",
24
+ module: "potree",
25
+ version: VERSION,
26
+ extensions: ["json"],
27
+ mimeTypes: ["application/json"],
28
+ testText: (text) => text.indexOf("octreeDir") >= 0,
29
+ parseTextSync: (text) => JSON.parse(text),
30
+ options: {
31
+ potree: {}
32
+ }
33
+ };
34
+ }
35
+ });
36
+
37
+ // src/parsers/parse-potree-hierarchy-chunk.ts
38
+ function parsePotreeHierarchyChunk(arrayBuffer) {
39
+ const tileHeaders = parseBinaryChunk(arrayBuffer);
40
+ return buildHierarchy(tileHeaders);
41
+ }
42
+ function parseBinaryChunk(arrayBuffer, byteOffset = 0) {
43
+ const dataView = new DataView(arrayBuffer);
44
+ const stack = [];
45
+ const topTileHeader = {};
46
+ byteOffset = decodeRow(dataView, byteOffset, topTileHeader);
47
+ stack.push(topTileHeader);
48
+ const tileHeaders = [];
49
+ while (stack.length > 0) {
50
+ const snode = stack.shift();
51
+ let mask = 1;
52
+ for (let i = 0; i < 8; i++) {
53
+ if (snode && (snode.header.childMask & mask) !== 0) {
54
+ const tileHeader = {};
55
+ byteOffset = decodeRow(dataView, byteOffset, tileHeader);
56
+ tileHeader.name = snode.name + i;
57
+ stack.push(tileHeader);
58
+ tileHeaders.push(tileHeader);
59
+ snode.header.childCount++;
60
+ }
61
+ mask = mask * 2;
62
+ }
63
+ if (byteOffset === dataView.byteLength) {
64
+ break;
65
+ }
66
+ }
67
+ return tileHeaders;
68
+ }
69
+ function decodeRow(dataView, byteOffset, tileHeader) {
70
+ tileHeader.header = tileHeader.header || {};
71
+ tileHeader.header.childMask = dataView.getUint8(byteOffset);
72
+ tileHeader.header.childCount = 0;
73
+ tileHeader.pointCount = dataView.getUint32(byteOffset + 1, true);
74
+ tileHeader.name = "";
75
+ byteOffset += 5;
76
+ return byteOffset;
77
+ }
78
+ function buildHierarchy(tileHeaders, options = {}) {
79
+ const DEFAULT_OPTIONS = { spacing: 100 };
80
+ options = { ...DEFAULT_OPTIONS, ...options };
81
+ const topNode = tileHeaders[0];
82
+ const nodes = {};
83
+ for (const tileHeader of tileHeaders) {
84
+ const { name } = tileHeader;
85
+ const index = parseInt(name.charAt(name.length - 1), 10);
86
+ const parentName = name.substring(0, name.length - 1);
87
+ const parentNode = nodes[parentName];
88
+ const level = name.length - 1;
89
+ tileHeader.level = level;
90
+ tileHeader.hasChildren = tileHeader.header.childCount;
91
+ tileHeader.children = [];
92
+ tileHeader.childrenByIndex = new Array(8).fill(null);
93
+ tileHeader.spacing = options.spacing / Math.pow(2, level);
94
+ if (parentNode) {
95
+ parentNode.children.push(tileHeader);
96
+ parentNode.childrenByIndex[index] = tileHeader;
97
+ }
98
+ nodes[name] = tileHeader;
99
+ }
100
+ return topNode;
101
+ }
102
+ var init_parse_potree_hierarchy_chunk = __esm({
103
+ "src/parsers/parse-potree-hierarchy-chunk.ts"() {
104
+ }
105
+ });
106
+
107
+ // src/potree-hierarchy-chunk-loader.ts
108
+ function parseSync(arrayBuffer) {
109
+ return parsePotreeHierarchyChunk(arrayBuffer);
110
+ }
111
+ var PotreeHierarchyChunkLoader;
112
+ var init_potree_hierarchy_chunk_loader = __esm({
113
+ "src/potree-hierarchy-chunk-loader.ts"() {
114
+ init_parse_potree_hierarchy_chunk();
115
+ PotreeHierarchyChunkLoader = {
116
+ id: "potree",
117
+ name: "potree Hierarchy Chunk",
118
+ extensions: ["hrc"],
119
+ mimeTypes: ["application/octet-stream"],
120
+ parse: async (arrayBuffer, options) => await parseSync(arrayBuffer),
121
+ parseSync,
122
+ binary: true
123
+ };
124
+ }
125
+ });
126
+
127
+ // src/parsers/parse-potree-bin.ts
128
+ function parsePotreeBin(arrayBuffer, byteOffset, options, index) {
129
+ return null;
130
+ }
131
+ var init_parse_potree_bin = __esm({
132
+ "src/parsers/parse-potree-bin.ts"() {
133
+ }
134
+ });
135
+
136
+ // src/potree-bin-loader.ts
137
+ function parseSync2(arrayBuffer, options) {
138
+ const index = {};
139
+ const byteOffset = 0;
140
+ parsePotreeBin(arrayBuffer, byteOffset, options, index);
141
+ return index;
142
+ }
143
+ var PotreeBinLoader;
144
+ var init_potree_bin_loader = __esm({
145
+ "src/potree-bin-loader.ts"() {
146
+ init_parse_potree_bin();
147
+ PotreeBinLoader = {
148
+ name: "potree Binary Point Attributes",
149
+ id: "potree",
150
+ extensions: ["bin"],
151
+ mimeTypes: ["application/octet-stream"],
152
+ parseSync: parseSync2,
153
+ binary: true
154
+ };
155
+ }
156
+ });
157
+
158
+ // src/index.ts
159
+ var src_exports = {};
160
+ __export(src_exports, {
161
+ PotreeBinLoader: () => PotreeBinLoader,
162
+ PotreeHierarchyChunkLoader: () => PotreeHierarchyChunkLoader,
163
+ PotreeLoader: () => PotreeLoader
164
+ });
165
+ var init_src = __esm({
166
+ "src/index.ts"() {
167
+ init_potree_loader();
168
+ init_potree_hierarchy_chunk_loader();
169
+ init_potree_bin_loader();
170
+ }
171
+ });
172
+
173
+ // src/bundle.ts
174
+ var require_bundle = __commonJS({
175
+ "src/bundle.ts"(exports, module) {
176
+ var moduleExports = (init_src(), src_exports);
177
+ globalThis.loaders = globalThis.loaders || {};
178
+ module.exports = Object.assign(globalThis.loaders, moduleExports);
179
+ }
180
+ });
181
+ require_bundle();
182
+ })();
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var moduleExports = require('./index');
3
+ const moduleExports = require('./index');
4
4
 
5
5
  globalThis.loaders = globalThis.loaders || {};
6
6
  module.exports = Object.assign(globalThis.loaders, moduleExports);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":";;AACA,IAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
1
+ {"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":";;AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
package/dist/es5/index.js CHANGED
@@ -5,19 +5,19 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  Object.defineProperty(exports, "PotreeLoader", {
7
7
  enumerable: true,
8
- get: function get() {
8
+ get: function () {
9
9
  return _potreeLoader.PotreeLoader;
10
10
  }
11
11
  });
12
12
  Object.defineProperty(exports, "PotreeHierarchyChunkLoader", {
13
13
  enumerable: true,
14
- get: function get() {
14
+ get: function () {
15
15
  return _potreeHierarchyChunkLoader.PotreeHierarchyChunkLoader;
16
16
  }
17
17
  });
18
18
  Object.defineProperty(exports, "PotreeBinLoader", {
19
19
  enumerable: true,
20
- get: function get() {
20
+ get: function () {
21
21
  return _potreeBinLoader.PotreeBinLoader;
22
22
  }
23
23
  });
@@ -1,34 +1,29 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.PointCloudOctant = exports.PointCloudOctree = void 0;
9
7
 
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
-
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
8
+ class PointCloudOctree {
9
+ constructor() {
10
+ this.url = null;
11
+ this.octreeDir = null;
12
+ this.spacing = 0;
13
+ this.boundingBox = null;
14
+ this.root = null;
15
+ this.nodes = null;
16
+ this.pointAttributes = null;
17
+ this.hierarchyStepSize = -1;
18
+ this.loader = null;
19
+ }
13
20
 
14
- var PointCloudOctree = function PointCloudOctree() {
15
- (0, _classCallCheck2.default)(this, PointCloudOctree);
16
- this.url = null;
17
- this.octreeDir = null;
18
- this.spacing = 0;
19
- this.boundingBox = null;
20
- this.root = null;
21
- this.nodes = null;
22
- this.pointAttributes = null;
23
- this.hierarchyStepSize = -1;
24
- this.loader = null;
25
- };
21
+ }
26
22
 
27
23
  exports.PointCloudOctree = PointCloudOctree;
28
24
 
29
- var PointCloudOctant = function () {
30
- function PointCloudOctant(name, octree, boundingBox) {
31
- (0, _classCallCheck2.default)(this, PointCloudOctant);
25
+ class PointCloudOctant {
26
+ constructor(name, octree, boundingBox) {
32
27
  this.octree = this.id = PointCloudOctreeGeometryNode.IDCount++;
33
28
  this.name = name;
34
29
  this.index = parseInt(name.charAt(name.length - 1));
@@ -43,217 +38,202 @@ var PointCloudOctant = function () {
43
38
  this.oneTimeDisposeHandlers = [];
44
39
  }
45
40
 
46
- (0, _createClass2.default)(PointCloudOctant, [{
47
- key: "isGeometryNode",
48
- value: function isGeometryNode() {
49
- return true;
50
- }
51
- }, {
52
- key: "getLevel",
53
- value: function getLevel() {
54
- return this.level;
55
- }
56
- }, {
57
- key: "isTreeNode",
58
- value: function isTreeNode() {
59
- return false;
60
- }
61
- }, {
62
- key: "isLoaded",
63
- value: function isLoaded() {
64
- return this.loaded;
65
- }
66
- }, {
67
- key: "getBoundingSphere",
68
- value: function getBoundingSphere() {
69
- return this.boundingSphere;
70
- }
71
- }, {
72
- key: "getBoundingBox",
73
- value: function getBoundingBox() {
74
- return this.boundingBox;
75
- }
76
- }, {
77
- key: "getChildren",
78
- value: function getChildren() {
79
- return this.children.filter(Boolean);
80
- }
81
- }, {
82
- key: "getURL",
83
- value: function getURL() {
84
- var version = this.octree.version;
85
- var hierarchyPath = version >= 1.5 ? "".concat(this.getHierarchyPath(), "/") : '';
86
- return "".concat(this.octree.octreeDir, "/").concat(hierarchyPath).concat(this.name);
87
- }
88
- }, {
89
- key: "getHierarchyPath",
90
- value: function getHierarchyPath() {
91
- var path = 'r/';
92
- var hierarchyStepSize = this.octree.hierarchyStepSize;
93
- var indices = this.name.substr(1);
94
- var numParts = Math.floor(indices.length / hierarchyStepSize);
95
-
96
- for (var i = 0; i < numParts; i++) {
97
- path += indices.substr(i * hierarchyStepSize, hierarchyStepSize) + '/';
98
- }
41
+ isGeometryNode() {
42
+ return true;
43
+ }
44
+
45
+ getLevel() {
46
+ return this.level;
47
+ }
48
+
49
+ isTreeNode() {
50
+ return false;
51
+ }
52
+
53
+ isLoaded() {
54
+ return this.loaded;
55
+ }
56
+
57
+ getBoundingSphere() {
58
+ return this.boundingSphere;
59
+ }
60
+
61
+ getBoundingBox() {
62
+ return this.boundingBox;
63
+ }
64
+
65
+ getChildren() {
66
+ return this.children.filter(Boolean);
67
+ }
68
+
69
+ getURL() {
70
+ const {
71
+ version
72
+ } = this.octree;
73
+ const hierarchyPath = version >= 1.5 ? "".concat(this.getHierarchyPath(), "/") : '';
74
+ return "".concat(this.octree.octreeDir, "/").concat(hierarchyPath).concat(this.name);
75
+ }
76
+
77
+ getHierarchyPath() {
78
+ let path = 'r/';
79
+ let hierarchyStepSize = this.octree.hierarchyStepSize;
80
+ let indices = this.name.substr(1);
81
+ let numParts = Math.floor(indices.length / hierarchyStepSize);
99
82
 
100
- path = path.slice(0, -1);
101
- return path;
83
+ for (let i = 0; i < numParts; i++) {
84
+ path += indices.substr(i * hierarchyStepSize, hierarchyStepSize) + '/';
102
85
  }
103
- }, {
104
- key: "addChild",
105
- value: function addChild(child) {
106
- this.children[child.index] = child;
107
- child.parent = this;
86
+
87
+ path = path.slice(0, -1);
88
+ return path;
89
+ }
90
+
91
+ addChild(child) {
92
+ this.children[child.index] = child;
93
+ child.parent = this;
94
+ }
95
+
96
+ load() {
97
+ if (this.loading === true || this.loaded === true || Potree.numNodesLoading >= Potree.maxNodesLoading) {
98
+ return;
108
99
  }
109
- }, {
110
- key: "load",
111
- value: function load() {
112
- if (this.loading === true || this.loaded === true || Potree.numNodesLoading >= Potree.maxNodesLoading) {
113
- return;
114
- }
115
100
 
116
- this.loading = true;
117
- Potree.numNodesLoading++;
101
+ this.loading = true;
102
+ Potree.numNodesLoading++;
118
103
 
119
- if (this.octree.loader.version.equalOrHigher('1.5')) {
120
- if (this.level % this.octree.hierarchyStepSize === 0 && this.hasChildren) {
121
- this.loadHierachyThenPoints();
122
- } else {
123
- this.loadPoints();
124
- }
104
+ if (this.octree.loader.version.equalOrHigher('1.5')) {
105
+ if (this.level % this.octree.hierarchyStepSize === 0 && this.hasChildren) {
106
+ this.loadHierachyThenPoints();
125
107
  } else {
126
108
  this.loadPoints();
127
109
  }
110
+ } else {
111
+ this.loadPoints();
128
112
  }
129
- }, {
130
- key: "loadPoints",
131
- value: function loadPoints() {
132
- this.octree.loader.load(this);
133
- }
134
- }, {
135
- key: "loadHierachyThenPoints",
136
- value: function loadHierachyThenPoints() {
137
- var node = this;
138
-
139
- var callback = function callback(node, hbuffer) {
140
- var view = new DataView(hbuffer);
141
- var stack = [];
142
- var children = view.getUint8(0);
143
- var numPoints = view.getUint32(1, true);
144
- node.numPoints = numPoints;
145
- stack.push({
146
- children: children,
147
- numPoints: numPoints,
148
- name: node.name
149
- });
150
- var decoded = [];
151
- var offset = 5;
152
-
153
- while (stack.length > 0) {
154
- var snode = stack.shift();
155
- var mask = 1;
156
-
157
- for (var i = 0; i < 8; i++) {
158
- if ((snode.children & mask) !== 0) {
159
- var childName = snode.name + i;
160
- var childChildren = view.getUint8(offset);
161
- var childNumPoints = view.getUint32(offset + 1, true);
162
- stack.push({
163
- children: childChildren,
164
- numPoints: childNumPoints,
165
- name: childName
166
- });
167
- decoded.push({
168
- children: childChildren,
169
- numPoints: childNumPoints,
170
- name: childName
171
- });
172
- offset += 5;
173
- }
174
-
175
- mask = mask * 2;
176
- }
113
+ }
177
114
 
178
- if (offset === hbuffer.byteLength) {
179
- break;
115
+ loadPoints() {
116
+ this.octree.loader.load(this);
117
+ }
118
+
119
+ loadHierachyThenPoints() {
120
+ let node = this;
121
+
122
+ let callback = function (node, hbuffer) {
123
+ let view = new DataView(hbuffer);
124
+ let stack = [];
125
+ let children = view.getUint8(0);
126
+ let numPoints = view.getUint32(1, true);
127
+ node.numPoints = numPoints;
128
+ stack.push({
129
+ children: children,
130
+ numPoints: numPoints,
131
+ name: node.name
132
+ });
133
+ let decoded = [];
134
+ let offset = 5;
135
+
136
+ while (stack.length > 0) {
137
+ let snode = stack.shift();
138
+ let mask = 1;
139
+
140
+ for (let i = 0; i < 8; i++) {
141
+ if ((snode.children & mask) !== 0) {
142
+ let childName = snode.name + i;
143
+ let childChildren = view.getUint8(offset);
144
+ let childNumPoints = view.getUint32(offset + 1, true);
145
+ stack.push({
146
+ children: childChildren,
147
+ numPoints: childNumPoints,
148
+ name: childName
149
+ });
150
+ decoded.push({
151
+ children: childChildren,
152
+ numPoints: childNumPoints,
153
+ name: childName
154
+ });
155
+ offset += 5;
180
156
  }
157
+
158
+ mask = mask * 2;
181
159
  }
182
160
 
183
- var nodes = {};
184
- nodes[node.name] = node;
185
- var pco = node.pcoGeometry;
186
-
187
- for (var _i = 0; _i < decoded.length; _i++) {
188
- var name = decoded[_i].name;
189
- var decodedNumPoints = decoded[_i].numPoints;
190
- var index = parseInt(name.charAt(name.length - 1));
191
- var parentName = name.substring(0, name.length - 1);
192
- var parentNode = nodes[parentName];
193
- var level = name.length - 1;
194
- var boundingBox = Utils.createChildAABB(parentNode.boundingBox, index);
195
- var currentNode = new PointCloudOctreeGeometryNode(name, pco, boundingBox);
196
- currentNode.level = level;
197
- currentNode.numPoints = decodedNumPoints;
198
- currentNode.hasChildren = decoded[_i].children > 0;
199
- currentNode.spacing = pco.spacing / Math.pow(2, level);
200
- parentNode.addChild(currentNode);
201
- nodes[name] = currentNode;
161
+ if (offset === hbuffer.byteLength) {
162
+ break;
202
163
  }
164
+ }
203
165
 
204
- node.loadPoints();
205
- };
166
+ let nodes = {};
167
+ nodes[node.name] = node;
168
+ let pco = node.pcoGeometry;
169
+
170
+ for (let i = 0; i < decoded.length; i++) {
171
+ let name = decoded[i].name;
172
+ let decodedNumPoints = decoded[i].numPoints;
173
+ let index = parseInt(name.charAt(name.length - 1));
174
+ let parentName = name.substring(0, name.length - 1);
175
+ let parentNode = nodes[parentName];
176
+ let level = name.length - 1;
177
+ let boundingBox = Utils.createChildAABB(parentNode.boundingBox, index);
178
+ let currentNode = new PointCloudOctreeGeometryNode(name, pco, boundingBox);
179
+ currentNode.level = level;
180
+ currentNode.numPoints = decodedNumPoints;
181
+ currentNode.hasChildren = decoded[i].children > 0;
182
+ currentNode.spacing = pco.spacing / Math.pow(2, level);
183
+ parentNode.addChild(currentNode);
184
+ nodes[name] = currentNode;
185
+ }
206
186
 
207
- if (node.level % node.pcoGeometry.hierarchyStepSize === 0) {
208
- var hurl = node.pcoGeometry.octreeDir + '/' + node.getHierarchyPath() + '/' + node.name + '.hrc';
209
- var xhr = XHRFactory.createXMLHttpRequest();
210
- xhr.open('GET', hurl, true);
211
- xhr.responseType = 'arraybuffer';
212
- xhr.overrideMimeType('text/plain; charset=x-user-defined');
213
-
214
- xhr.onreadystatechange = function () {
215
- if (xhr.readyState === 4) {
216
- if (xhr.status === 200 || xhr.status === 0) {
217
- var hbuffer = xhr.response;
218
- callback(node, hbuffer);
219
- } else {
220
- console.log('Failed to load file! HTTP status: ' + xhr.status + ', file: ' + hurl);
221
- Potree.numNodesLoading--;
222
- }
187
+ node.loadPoints();
188
+ };
189
+
190
+ if (node.level % node.pcoGeometry.hierarchyStepSize === 0) {
191
+ let hurl = node.pcoGeometry.octreeDir + '/' + node.getHierarchyPath() + '/' + node.name + '.hrc';
192
+ let xhr = XHRFactory.createXMLHttpRequest();
193
+ xhr.open('GET', hurl, true);
194
+ xhr.responseType = 'arraybuffer';
195
+ xhr.overrideMimeType('text/plain; charset=x-user-defined');
196
+
197
+ xhr.onreadystatechange = () => {
198
+ if (xhr.readyState === 4) {
199
+ if (xhr.status === 200 || xhr.status === 0) {
200
+ let hbuffer = xhr.response;
201
+ callback(node, hbuffer);
202
+ } else {
203
+ console.log('Failed to load file! HTTP status: ' + xhr.status + ', file: ' + hurl);
204
+ Potree.numNodesLoading--;
223
205
  }
224
- };
225
-
226
- try {
227
- xhr.send(null);
228
- } catch (e) {
229
- console.log('fehler beim laden der punktwolke: ' + e);
230
206
  }
207
+ };
208
+
209
+ try {
210
+ xhr.send(null);
211
+ } catch (e) {
212
+ console.log('fehler beim laden der punktwolke: ' + e);
231
213
  }
232
214
  }
233
- }, {
234
- key: "getNumPoints",
235
- value: function getNumPoints() {
236
- return this.numPoints;
237
- }
238
- }, {
239
- key: "dispose",
240
- value: function dispose() {
241
- if (this.geometry && this.parent != null) {
242
- this.geometry.dispose();
243
- this.geometry = null;
244
- this.loaded = false;
245
-
246
- for (var i = 0; i < this.oneTimeDisposeHandlers.length; i++) {
247
- var handler = this.oneTimeDisposeHandlers[i];
248
- handler();
249
- }
215
+ }
216
+
217
+ getNumPoints() {
218
+ return this.numPoints;
219
+ }
220
+
221
+ dispose() {
222
+ if (this.geometry && this.parent != null) {
223
+ this.geometry.dispose();
224
+ this.geometry = null;
225
+ this.loaded = false;
250
226
 
251
- this.oneTimeDisposeHandlers = [];
227
+ for (let i = 0; i < this.oneTimeDisposeHandlers.length; i++) {
228
+ let handler = this.oneTimeDisposeHandlers[i];
229
+ handler();
252
230
  }
231
+
232
+ this.oneTimeDisposeHandlers = [];
253
233
  }
254
- }]);
255
- return PointCloudOctant;
256
- }();
234
+ }
235
+
236
+ }
257
237
 
258
238
  exports.PointCloudOctant = PointCloudOctant;
259
239
  PointCloudOctreeGeometryNode.IDCount = 0;