@loaders.gl/potree 4.0.0-alpha.9 → 4.0.0-beta.2

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 (45) hide show
  1. package/dist/dist.min.js +5 -8
  2. package/dist/es5/parsers/parse-potree-bin.js +1 -1
  3. package/dist/es5/parsers/parse-potree-bin.js.map +1 -1
  4. package/dist/es5/parsers/parse-potree-hierarchy-chunk.js +3 -2
  5. package/dist/es5/parsers/parse-potree-hierarchy-chunk.js.map +1 -1
  6. package/dist/es5/potree-bin-loader.js +2 -3
  7. package/dist/es5/potree-bin-loader.js.map +1 -1
  8. package/dist/es5/potree-hierarchy-chunk-loader.js +6 -10
  9. package/dist/es5/potree-hierarchy-chunk-loader.js.map +1 -1
  10. package/dist/es5/potree-loader.js +1 -1
  11. package/dist/es5/potree-loader.js.map +1 -1
  12. package/dist/esm/parsers/parse-potree-bin.js +1 -1
  13. package/dist/esm/parsers/parse-potree-bin.js.map +1 -1
  14. package/dist/esm/parsers/parse-potree-hierarchy-chunk.js +3 -2
  15. package/dist/esm/parsers/parse-potree-hierarchy-chunk.js.map +1 -1
  16. package/dist/esm/potree-bin-loader.js +1 -1
  17. package/dist/esm/potree-bin-loader.js.map +1 -1
  18. package/dist/esm/potree-hierarchy-chunk-loader.js +3 -6
  19. package/dist/esm/potree-hierarchy-chunk-loader.js.map +1 -1
  20. package/dist/esm/potree-loader.js +1 -1
  21. package/dist/esm/potree-loader.js.map +1 -1
  22. package/dist/parsers/parse-potree-bin.d.ts +1 -1
  23. package/dist/parsers/parse-potree-bin.d.ts.map +1 -1
  24. package/dist/parsers/parse-potree-hierarchy-chunk.d.ts +15 -1
  25. package/dist/parsers/parse-potree-hierarchy-chunk.d.ts.map +1 -1
  26. package/dist/potree-bin-loader.d.ts +2 -2
  27. package/dist/potree-bin-loader.d.ts.map +1 -1
  28. package/dist/potree-hierarchy-chunk-loader.d.ts +3 -1
  29. package/dist/potree-hierarchy-chunk-loader.d.ts.map +1 -1
  30. package/dist/potree-loader.d.ts +5 -2
  31. package/dist/potree-loader.d.ts.map +1 -1
  32. package/package.json +3 -3
  33. package/src/parsers/parse-potree-bin.ts +1 -1
  34. package/src/parsers/parse-potree-hierarchy-chunk.ts +27 -8
  35. package/src/potree-bin-loader.ts +3 -3
  36. package/src/potree-hierarchy-chunk-loader.ts +16 -17
  37. package/src/potree-loader.ts +6 -2
  38. package/dist/bundle.js +0 -5
  39. package/dist/index.js +0 -9
  40. package/dist/lib/octree.js +0 -197
  41. package/dist/parsers/parse-potree-bin.js +0 -6
  42. package/dist/parsers/parse-potree-hierarchy-chunk.js +0 -129
  43. package/dist/potree-bin-loader.js +0 -27
  44. package/dist/potree-hierarchy-chunk-loader.js +0 -23
  45. package/dist/potree-loader.js +0 -21
package/dist/dist.min.js CHANGED
@@ -90,7 +90,7 @@
90
90
  tileHeader.hasChildren = tileHeader.header.childCount;
91
91
  tileHeader.children = [];
92
92
  tileHeader.childrenByIndex = new Array(8).fill(null);
93
- tileHeader.spacing = options.spacing / Math.pow(2, level);
93
+ tileHeader.spacing = (options?.spacing || 0) / Math.pow(2, level);
94
94
  if (parentNode) {
95
95
  parentNode.children.push(tileHeader);
96
96
  parentNode.childrenByIndex[index] = tileHeader;
@@ -105,9 +105,6 @@
105
105
  });
106
106
 
107
107
  // src/potree-hierarchy-chunk-loader.ts
108
- function parseSync(arrayBuffer) {
109
- return parsePotreeHierarchyChunk(arrayBuffer);
110
- }
111
108
  var PotreeHierarchyChunkLoader;
112
109
  var init_potree_hierarchy_chunk_loader = __esm({
113
110
  "src/potree-hierarchy-chunk-loader.ts"() {
@@ -117,8 +114,8 @@
117
114
  name: "potree Hierarchy Chunk",
118
115
  extensions: ["hrc"],
119
116
  mimeTypes: ["application/octet-stream"],
120
- parse: async (arrayBuffer, options) => await parseSync(arrayBuffer),
121
- parseSync,
117
+ parse: async (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),
118
+ parseSync: (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),
122
119
  binary: true
123
120
  };
124
121
  }
@@ -134,7 +131,7 @@
134
131
  });
135
132
 
136
133
  // src/potree-bin-loader.ts
137
- function parseSync2(arrayBuffer, options) {
134
+ function parseSync(arrayBuffer, options) {
138
135
  const index = {};
139
136
  const byteOffset = 0;
140
137
  parsePotreeBin(arrayBuffer, byteOffset, options, index);
@@ -149,7 +146,7 @@
149
146
  id: "potree",
150
147
  extensions: ["bin"],
151
148
  mimeTypes: ["application/octet-stream"],
152
- parseSync: parseSync2,
149
+ parseSync,
153
150
  binary: true
154
151
  };
155
152
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = parsePotreeBin;
6
+ exports.parsePotreeBin = parsePotreeBin;
7
7
  function parsePotreeBin(arrayBuffer, byteOffset, options, index) {
8
8
  return null;
9
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parse-potree-bin.js","names":["parsePotreeBin","arrayBuffer","byteOffset","options","index"],"sources":["../../../src/parsers/parse-potree-bin.ts"],"sourcesContent":["export default function parsePotreeBin(\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n options: unknown,\n index: any\n) {\n return null;\n}\n"],"mappings":";;;;;;AAAe,SAASA,cAAcA,CACpCC,WAAwB,EACxBC,UAAkB,EAClBC,OAAgB,EAChBC,KAAU,EACV;EACA,OAAO,IAAI;AACb"}
1
+ {"version":3,"file":"parse-potree-bin.js","names":["parsePotreeBin","arrayBuffer","byteOffset","options","index"],"sources":["../../../src/parsers/parse-potree-bin.ts"],"sourcesContent":["export function parsePotreeBin(\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n options: unknown,\n index: any\n) {\n return null;\n}\n"],"mappings":";;;;;;AAAO,SAASA,cAAcA,CAC5BC,WAAwB,EACxBC,UAAkB,EAClBC,OAAgB,EAChBC,KAAU,EACV;EACA,OAAO,IAAI;AACb"}
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = parsePotreeHierarchyChunk;
7
+ exports.parsePotreeHierarchyChunk = parsePotreeHierarchyChunk;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
10
10
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -64,6 +64,7 @@ function buildHierarchy(tileHeaders) {
64
64
  _step;
65
65
  try {
66
66
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
67
+ var _options;
67
68
  var tileHeader = _step.value;
68
69
  var name = tileHeader.name;
69
70
  var index = parseInt(name.charAt(name.length - 1), 10);
@@ -74,7 +75,7 @@ function buildHierarchy(tileHeaders) {
74
75
  tileHeader.hasChildren = tileHeader.header.childCount;
75
76
  tileHeader.children = [];
76
77
  tileHeader.childrenByIndex = new Array(8).fill(null);
77
- tileHeader.spacing = options.spacing / Math.pow(2, level);
78
+ tileHeader.spacing = (((_options = options) === null || _options === void 0 ? void 0 : _options.spacing) || 0) / Math.pow(2, level);
78
79
  if (parentNode) {
79
80
  parentNode.children.push(tileHeader);
80
81
  parentNode.childrenByIndex[index] = tileHeader;
@@ -1 +1 @@
1
- {"version":3,"file":"parse-potree-hierarchy-chunk.js","names":["parsePotreeHierarchyChunk","arrayBuffer","tileHeaders","parseBinaryChunk","buildHierarchy","byteOffset","arguments","length","undefined","dataView","DataView","stack","topTileHeader","decodeRow","push","snode","shift","mask","i","header","childMask","tileHeader","name","childCount","byteLength","getUint8","pointCount","getUint32","options","DEFAULT_OPTIONS","spacing","_objectSpread","topNode","nodes","_iterator","_createForOfIteratorHelper","_step","s","n","done","value","index","parseInt","charAt","parentName","substring","parentNode","level","hasChildren","children","childrenByIndex","Array","fill","Math","pow","err","e","f"],"sources":["../../../src/parsers/parse-potree-hierarchy-chunk.ts"],"sourcesContent":["// 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\n// Potree Hierarchy Chunk file format\n// https://github.com/potree/potree/blob/develop/docs/potree-file-format.md#index-files\n\n/*\n### Hierarchy Chunk Files\n\nAs mentioned in the former section, the `.hrc` files contain the index structure\nmeaning a list of all the files stored within the directory tree.\n\nAn index file contains a list of tuple values with the first being a `uint8`\n\"mask\" and the second being `uint32` \"number of points\" of a hierarchy level\nin a [breadth first level order][breadth-first].\n\nPer hierarchy level we have 8 possible nodes. To indicate whether a node exists\na simple binary mask is used:\n\n| Position | Mask | [Binary][bin] |\n|----------|------|---------------|\n| 0 | 1 | 0b00000001 |\n| 1 | 2 | 0b00000010 |\n| 2 | 4 | 0b00000100 |\n| 3 | 8 | 0b00001000 |\n| 4 | 16 | 0b00010000 |\n| 5 | 32 | 0b00100000 |\n| 6 | 64 | 0b01000000 |\n| 7 | 128 | 0b10000000 |\n\nSo if in a hierarchy the child node 3 and node 7 exist then the hierarchies\nmask has to be `0b00001000 | 0b10000000` → `0b10001000` (=136).\n\n_Example:_ A simple, non-realistic tree:\n\n```\n|- r1\n| |\n| \\- r14 (2 Points)\n|\n\\- r3\n |\n \\- r36 (1 Point)\n```\n\nWould have an index looking like this:\n\n| name | mask | points |\n|------|--------------------|--------|\n| r | `0b00001010` (=10) | `3` |\n| r1 | `0b00010000` (=16) | `2` |\n| r3 | `0b01000000` (=64) | `1` |\n| r14 | `0b00000000` (=0) | `2` |\n| r36 | `0b00000000` (=0) | `1` |\n*/\n\n// @ts-nocheck\n\n// load hierarchy\nexport default function parsePotreeHierarchyChunk(arrayBuffer: ArrayBuffer) {\n const tileHeaders = parseBinaryChunk(arrayBuffer);\n return buildHierarchy(tileHeaders);\n}\n\n// Parses the binary rows\nfunction parseBinaryChunk(arrayBuffer: ArrayBuffer, byteOffset = 0) {\n const dataView = new DataView(arrayBuffer);\n\n const stack = [];\n\n // Get root mask\n const topTileHeader = {};\n byteOffset = decodeRow(dataView, byteOffset, topTileHeader);\n\n stack.push(topTileHeader);\n\n const tileHeaders = [];\n\n while (stack.length > 0) {\n const snode = stack.shift();\n let mask = 1;\n\n for (let i = 0; i < 8; i++) {\n if (snode && (snode.header.childMask & mask) !== 0) {\n const tileHeader = {};\n byteOffset = decodeRow(dataView, byteOffset, tileHeader);\n tileHeader.name = snode.name + i;\n\n stack.push(tileHeader);\n tileHeaders.push(tileHeader);\n snode.header.childCount++;\n }\n mask = mask * 2;\n }\n\n if (byteOffset === dataView.byteLength) {\n break;\n }\n }\n\n return tileHeaders;\n}\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\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\n const topNode = tileHeaders[0];\n const nodes = {};\n\n for (const tileHeader of tileHeaders) {\n const {name} = tileHeader;\n\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\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 / Math.pow(2, level);\n // tileHeader.boundingVolume = Utils.createChildAABB(parentNode.boundingBox, index);\n\n if (parentNode) {\n parentNode.children.push(tileHeader);\n parentNode.childrenByIndex[index] = tileHeader;\n }\n\n // Add the node to the map\n nodes[name] = tileHeader;\n }\n\n // First node is the root\n return topNode;\n}\n"],"mappings":";;;;;;;;;;;;;AA2De,SAASA,yBAAyBA,CAACC,WAAwB,EAAE;EAC1E,IAAMC,WAAW,GAAGC,gBAAgB,CAACF,WAAW,CAAC;EACjD,OAAOG,cAAc,CAACF,WAAW,CAAC;AACpC;AAGA,SAASC,gBAAgBA,CAACF,WAAwB,EAAkB;EAAA,IAAhBI,UAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAChE,IAAMG,QAAQ,GAAG,IAAIC,QAAQ,CAACT,WAAW,CAAC;EAE1C,IAAMU,KAAK,GAAG,EAAE;EAGhB,IAAMC,aAAa,GAAG,CAAC,CAAC;EACxBP,UAAU,GAAGQ,SAAS,CAACJ,QAAQ,EAAEJ,UAAU,EAAEO,aAAa,CAAC;EAE3DD,KAAK,CAACG,IAAI,CAACF,aAAa,CAAC;EAEzB,IAAMV,WAAW,GAAG,EAAE;EAEtB,OAA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OAAO,GAAGF,OAAO,CAACE,OAAO,GAAGuB,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEP,KAAK,CAAC;MAGzD,IAAID,UAAU,EAAE;QACdA,UAAU,CAACG,QAAQ,CAACnC,IAAI,CAACO,UAAU,CAAC;QACpCyB,UAAU,CAACI,eAAe,CAACT,KAAK,CAAC,GAAGpB,UAAU;MAChD;MAGAY,KAAK,CAACX,IAAI,CAAC,GAAGD,UAAU;IAC1B;EAAC,SAAAkC,GAAA;IAAArB,SAAA,CAAAsB,CAAA,CAAAD,GAAA;EAAA;IAAArB,SAAA,CAAAuB,CAAA;EAAA;EAGD,OAAOzB,OAAO;AAChB"}
1
+ {"version":3,"file":"parse-potree-hierarchy-chunk.js","names":["parsePotreeHierarchyChunk","arrayBuffer","tileHeaders","parseBinaryChunk","buildHierarchy","byteOffset","arguments","length","undefined","dataView","DataView","stack","topTileHeader","decodeRow","push","snode","shift","mask","i","header","childMask","tileHeader","name","childCount","byteLength","getUint8","pointCount","getUint32","options","DEFAULT_OPTIONS","spacing","_objectSpread","topNode","nodes","_iterator","_createForOfIteratorHelper","_step","s","n","done","_options","value","index","parseInt","charAt","parentName","substring","parentNode","level","hasChildren","children","childrenByIndex","Array","fill","Math","pow","err","e","f"],"sources":["../../../src/parsers/parse-potree-hierarchy-chunk.ts"],"sourcesContent":["// 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\n// Potree Hierarchy Chunk file format\n// https://github.com/potree/potree/blob/develop/docs/potree-file-format.md#index-files\n\n/*\n### Hierarchy Chunk Files\n\nAs mentioned in the former section, the `.hrc` files contain the index structure\nmeaning a list of all the files stored within the directory tree.\n\nAn index file contains a list of tuple values with the first being a `uint8`\n\"mask\" and the second being `uint32` \"number of points\" of a hierarchy level\nin a [breadth first level order][breadth-first].\n\nPer hierarchy level we have 8 possible nodes. To indicate whether a node exists\na simple binary mask is used:\n\n| Position | Mask | [Binary][bin] |\n|----------|------|---------------|\n| 0 | 1 | 0b00000001 |\n| 1 | 2 | 0b00000010 |\n| 2 | 4 | 0b00000100 |\n| 3 | 8 | 0b00001000 |\n| 4 | 16 | 0b00010000 |\n| 5 | 32 | 0b00100000 |\n| 6 | 64 | 0b01000000 |\n| 7 | 128 | 0b10000000 |\n\nSo if in a hierarchy the child node 3 and node 7 exist then the hierarchies\nmask has to be `0b00001000 | 0b10000000` → `0b10001000` (=136).\n\n_Example:_ A simple, non-realistic tree:\n\n```\n|- r1\n| |\n| \\- r14 (2 Points)\n|\n\\- r3\n |\n \\- r36 (1 Point)\n```\n\nWould have an index looking like this:\n\n| name | mask | points |\n|------|--------------------|--------|\n| r | `0b00001010` (=10) | `3` |\n| r1 | `0b00010000` (=16) | `2` |\n| r3 | `0b01000000` (=64) | `1` |\n| r14 | `0b00000000` (=0) | `2` |\n| r36 | `0b00000000` (=0) | `1` |\n*/\n\n/** @todo these types are an incorrect mess */\nexport type POTreeTileHeader = {\n childCount: number;\n name: string;\n childMask: number;\n};\n\n/** @todo these types are an incorrect mess */\nexport type POTreeNode = {\n header: POTreeTileHeader;\n name: string;\n pointCount: number;\n children: POTreeNode[];\n childrenByIndex: POTreeNode[];\n};\n\n// type POTreeTileNode = POTreeNode;\n\n// load hierarchy\nexport function parsePotreeHierarchyChunk(arrayBuffer: ArrayBuffer) {\n const tileHeaders = parseBinaryChunk(arrayBuffer);\n return buildHierarchy(tileHeaders);\n}\n\n// Parses the binary rows\nfunction parseBinaryChunk(arrayBuffer: ArrayBuffer, byteOffset = 0) {\n const dataView = new DataView(arrayBuffer);\n\n const stack: POTreeNode[] = [];\n\n // Get root mask\n // @ts-expect-error\n const topTileHeader: POTreeNode = {};\n byteOffset = decodeRow(dataView, byteOffset, topTileHeader);\n\n stack.push(topTileHeader);\n\n const tileHeaders: POTreeTileHeader[] = [];\n\n while (stack.length > 0) {\n const snode = stack.shift();\n let mask = 1;\n\n for (let i = 0; i < 8; i++) {\n if (snode && (snode.header.childMask & mask) !== 0) {\n // @ts-expect-error\n const tileHeader: POTreeTileHeader = {};\n byteOffset = decodeRow(dataView, byteOffset, tileHeader);\n tileHeader.name = snode.name + i;\n\n // @ts-expect-error\n stack.push(tileHeader);\n tileHeaders.push(tileHeader);\n snode.header.childCount++;\n }\n mask = mask * 2;\n }\n\n if (byteOffset === dataView.byteLength) {\n break;\n }\n }\n\n return tileHeaders;\n}\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\n// Resolves the binary rows into a hierarchy (tree structure)\nfunction buildHierarchy(tileHeaders, options: {spacing?: number} = {}): POTreeNode {\n const DEFAULT_OPTIONS = {spacing: 100}; // TODO assert instead of default?\n options = {...DEFAULT_OPTIONS, ...options};\n\n const topNode = tileHeaders[0];\n const nodes = {};\n\n for (const tileHeader of tileHeaders) {\n const {name} = tileHeader;\n\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\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\n if (parentNode) {\n parentNode.children.push(tileHeader);\n parentNode.childrenByIndex[index] = tileHeader;\n }\n\n // Add the node to the map\n nodes[name] = tileHeader;\n }\n\n // First node is the root\n return topNode;\n}\n"],"mappings":";;;;;;;;;;;;;AA2EO,SAASA,yBAAyBA,CAACC,WAAwB,EAAE;EAClE,IAAMC,WAAW,GAAGC,gBAAgB,CAACF,WAAW,CAAC;EACjD,OAAOG,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CAAC;MACxD,IAAMsC,UAAU,GAAGvB,IAAI,CAACwB,SAAS,CAAC,CAAC,EAAExB,IAAI,CAACf,MAAM,GAAG,CAAC,CAAC;MACrD,IAAMwC,UAAU,GAAGd,KAAK,CAACY,UAAU,CAAC;MACpC,IAAMG,KAAK,GAAG1B,IAAI,CAACf,MAAM,GAAG,CAAC;MAG7Bc,UAAU,CAAC2B,KAAK,GAAGA,KAAK;MACxB3B,UAAU,CAAC4B,WAAW,GAAG5B,UAAU,CAACF,MAAM,CAACI,UAAU;MACrDF,UAAU,CAAC6B,QAAQ,GAAG,EAAE;MACxB7B,UAAU,CAAC8B,eAAe,GAAG,IAAIC,KAAK,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;MACpDhC,UAAU,CAACS,OAAO,GAAG,CAAC,EAAAU,QAAA,GAAAZ,OAAO,cAAAY,QAAA,uBAAPA,QAAA,CAASV,OAAO,KAAI,CAAC,IAAIwB,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEP,KAAK,CAAC;MAGjE,IAAID,UAAU,EAAE;QACdA,UAAU,CAACG,QAAQ,CAACpC,IAAI,CAACO,UAAU,CAAC;QACpC0B,UAAU,CAACI,eAAe,CAACT,KAAK,CAAC,GAAGrB,UAAU;MAChD;MAGAY,KAAK,CAACX,IAAI,CAAC,GAAGD,UAAU;IAC1B;EAAC,SAAAmC,GAAA;IAAAtB,SAAA,CAAAuB,CAAA,CAAAD,GAAA;EAAA;IAAAtB,SAAA,CAAAwB,CAAA;EAAA;EAGD,OAAO1B,OAAO;AAChB"}
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.PotreeBinLoader = void 0;
8
- var _parsePotreeBin = _interopRequireDefault(require("./parsers/parse-potree-bin"));
7
+ var _parsePotreeBin = require("./parsers/parse-potree-bin");
9
8
  var PotreeBinLoader = {
10
9
  name: 'potree Binary Point Attributes',
11
10
  id: 'potree',
@@ -18,7 +17,7 @@ exports.PotreeBinLoader = PotreeBinLoader;
18
17
  function parseSync(arrayBuffer, options) {
19
18
  var index = {};
20
19
  var byteOffset = 0;
21
- (0, _parsePotreeBin.default)(arrayBuffer, byteOffset, options, index);
20
+ (0, _parsePotreeBin.parsePotreeBin)(arrayBuffer, byteOffset, options, index);
22
21
  return index;
23
22
  }
24
23
  //# sourceMappingURL=potree-bin-loader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"potree-bin-loader.js","names":["_parsePotreeBin","_interopRequireDefault","require","PotreeBinLoader","name","id","extensions","mimeTypes","parseSync","binary","exports","arrayBuffer","options","index","byteOffset","parsePotreeBin"],"sources":["../../src/potree-bin-loader.ts"],"sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {default as parsePotreeBin} from './parsers/parse-potree-bin';\n\n/**\n * Loader for potree Binary Point Attributes\n * */\n// @ts-ignore\nexport const PotreeBinLoader: LoaderWithParser = {\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};\n\nfunction parseSync(arrayBuffer: ArrayBuffer, options?: LoaderOptions) {\n const index = {};\n const byteOffset = 0;\n parsePotreeBin(arrayBuffer, byteOffset, options, index);\n return index;\n}\n"],"mappings":";;;;;;;AACA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AAMO,IAAMC,eAAiC,GAAG;EAC/CC,IAAI,EAAE,gCAAgC;EACtCC,EAAE,EAAE,QAAQ;EACZC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,0BAA0B,CAAC;EAGvCC,SAAS,EAATA,SAAS;EACTC,MAAM,EAAE;AACV,CAAC;AAACC,OAAA,CAAAP,eAAA,GAAAA,eAAA;AAEF,SAASK,SAASA,CAACG,WAAwB,EAAEC,OAAuB,EAAE;EACpE,IAAMC,KAAK,GAAG,CAAC,CAAC;EAChB,IAAMC,UAAU,GAAG,CAAC;EACpB,IAAAC,uBAAc,EAACJ,WAAW,EAAEG,UAAU,EAAEF,OAAO,EAAEC,KAAK,CAAC;EACvD,OAAOA,KAAK;AACd"}
1
+ {"version":3,"file":"potree-bin-loader.js","names":["_parsePotreeBin","require","PotreeBinLoader","name","id","extensions","mimeTypes","parseSync","binary","exports","arrayBuffer","options","index","byteOffset","parsePotreeBin"],"sources":["../../src/potree-bin-loader.ts"],"sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {parsePotreeBin} from './parsers/parse-potree-bin';\n\n/**\n * Loader for potree Binary Point Attributes\n * */\n// @ts-ignore\nexport const PotreeBinLoader: LoaderWithParser<{}, never, LoaderOptions> = {\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};\n\nfunction parseSync(arrayBuffer: ArrayBuffer, options?: LoaderOptions): {} {\n const index = {};\n const byteOffset = 0;\n parsePotreeBin(arrayBuffer, byteOffset, options, index);\n return index;\n}\n"],"mappings":";;;;;;AACA,IAAAA,eAAA,GAAAC,OAAA;AAMO,IAAMC,eAA2D,GAAG;EACzEC,IAAI,EAAE,gCAAgC;EACtCC,EAAE,EAAE,QAAQ;EACZC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,0BAA0B,CAAC;EAGvCC,SAAS,EAATA,SAAS;EACTC,MAAM,EAAE;AACV,CAAC;AAACC,OAAA,CAAAP,eAAA,GAAAA,eAAA;AAEF,SAASK,SAASA,CAACG,WAAwB,EAAEC,OAAuB,EAAM;EACxE,IAAMC,KAAK,GAAG,CAAC,CAAC;EAChB,IAAMC,UAAU,GAAG,CAAC;EACpB,IAAAC,8BAAc,EAACJ,WAAW,EAAEG,UAAU,EAAEF,OAAO,EAAEC,KAAK,CAAC;EACvD,OAAOA,KAAK;AACd"}
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.PotreeHierarchyChunkLoader = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
- var _parsePotreeHierarchyChunk = _interopRequireDefault(require("./parsers/parse-potree-hierarchy-chunk"));
10
+ var _parsePotreeHierarchyChunk = require("./parsers/parse-potree-hierarchy-chunk");
11
11
  var PotreeHierarchyChunkLoader = {
12
12
  id: 'potree',
13
13
  name: 'potree Hierarchy Chunk',
@@ -18,11 +18,8 @@ var PotreeHierarchyChunkLoader = {
18
18
  return _regenerator.default.wrap(function _callee$(_context) {
19
19
  while (1) switch (_context.prev = _context.next) {
20
20
  case 0:
21
- _context.next = 2;
22
- return parseSync(arrayBuffer);
23
- case 2:
24
- return _context.abrupt("return", _context.sent);
25
- case 3:
21
+ return _context.abrupt("return", (0, _parsePotreeHierarchyChunk.parsePotreeHierarchyChunk)(arrayBuffer));
22
+ case 1:
26
23
  case "end":
27
24
  return _context.stop();
28
25
  }
@@ -33,11 +30,10 @@ var PotreeHierarchyChunkLoader = {
33
30
  }
34
31
  return parse;
35
32
  }(),
36
- parseSync: parseSync,
33
+ parseSync: function parseSync(arrayBuffer, options) {
34
+ return (0, _parsePotreeHierarchyChunk.parsePotreeHierarchyChunk)(arrayBuffer);
35
+ },
37
36
  binary: true
38
37
  };
39
38
  exports.PotreeHierarchyChunkLoader = PotreeHierarchyChunkLoader;
40
- function parseSync(arrayBuffer) {
41
- return (0, _parsePotreeHierarchyChunk.default)(arrayBuffer);
42
- }
43
39
  //# sourceMappingURL=potree-hierarchy-chunk-loader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"potree-hierarchy-chunk-loader.js","names":["_parsePotreeHierarchyChunk","_interopRequireDefault","require","PotreeHierarchyChunkLoader","id","name","extensions","mimeTypes","parse","_parse","_asyncToGenerator2","default","_regenerator","mark","_callee","arrayBuffer","options","wrap","_callee$","_context","prev","next","parseSync","abrupt","sent","stop","_x","_x2","apply","arguments","binary","exports","parsePotreeHierarchyChunk"],"sources":["../../src/potree-hierarchy-chunk-loader.ts"],"sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {default as parsePotreeHierarchyChunk} from './parsers/parse-potree-hierarchy-chunk';\n\n/** Potree hierarchy chunk loader */\n// @ts-ignore\nexport const PotreeHierarchyChunkLoader: LoaderWithParser = {\n id: 'potree',\n name: 'potree Hierarchy Chunk',\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) => await parseSync(arrayBuffer),\n parseSync,\n binary: true\n};\n\nfunction parseSync(arrayBuffer) {\n return parsePotreeHierarchyChunk(arrayBuffer);\n}\n"],"mappings":";;;;;;;;;AACA,IAAAA,0BAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIO,IAAMC,0BAA4C,GAAG;EAC1DC,EAAE,EAAE,QAAQ;EACZC,IAAI,EAAE,wBAAwB;EAC9BC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,0BAA0B,CAAC;EAGvCC,KAAK;IAAA,IAAAC,MAAA,OAAAC,kBAAA,CAAAC,OAAA,EAAAC,YAAA,CAAAD,OAAA,CAAAE,IAAA,CAAE,SAAAC,QAAOC,WAAW,EAAEC,OAAO;MAAA,OAAAJ,YAAA,CAAAD,OAAA,CAAAM,IAAA,UAAAC,SAAAC,QAAA;QAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;UAAA;YAAAF,QAAA,CAAAE,IAAA;YAAA,OAAWC,SAAS,CAACP,WAAW,CAAC;UAAA;YAAA,OAAAI,QAAA,CAAAI,MAAA,WAAAJ,QAAA,CAAAK,IAAA;UAAA;UAAA;YAAA,OAAAL,QAAA,CAAAM,IAAA;QAAA;MAAA,GAAAX,OAAA;IAAA;IAAA,SAAAN,MAAAkB,EAAA,EAAAC,GAAA;MAAA,OAAAlB,MAAA,CAAAmB,KAAA,OAAAC,SAAA;IAAA;IAAA,OAAArB,KAAA;EAAA;EACnEc,SAAS,EAATA,SAAS;EACTQ,MAAM,EAAE;AACV,CAAC;AAACC,OAAA,CAAA5B,0BAAA,GAAAA,0BAAA;AAEF,SAASmB,SAASA,CAACP,WAAW,EAAE;EAC9B,OAAO,IAAAiB,kCAAyB,EAACjB,WAAW,CAAC;AAC/C"}
1
+ {"version":3,"file":"potree-hierarchy-chunk-loader.js","names":["_parsePotreeHierarchyChunk","require","PotreeHierarchyChunkLoader","id","name","extensions","mimeTypes","parse","_parse","_asyncToGenerator2","default","_regenerator","mark","_callee","arrayBuffer","options","wrap","_callee$","_context","prev","next","abrupt","parsePotreeHierarchyChunk","stop","_x","_x2","apply","arguments","parseSync","binary","exports"],"sources":["../../src/potree-hierarchy-chunk-loader.ts"],"sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {POTreeLoaderOptions} from './potree-loader';\nimport type {POTreeNode} from './parsers/parse-potree-hierarchy-chunk';\nimport {parsePotreeHierarchyChunk} from './parsers/parse-potree-hierarchy-chunk';\n\n/** Potree hierarchy chunk loader */\n// @ts-ignore not a valid loader\nexport const PotreeHierarchyChunkLoader: LoaderWithParser<POTreeNode, never, POTreeLoaderOptions> =\n {\n id: 'potree',\n name: 'potree Hierarchy Chunk',\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 binary: true\n };\n"],"mappings":";;;;;;;;;AAGA,IAAAA,0BAAA,GAAAC,OAAA;AAIO,IAAMC,0BAAoF,GAC/F;EACEC,EAAE,EAAE,QAAQ;EACZC,IAAI,EAAE,wBAAwB;EAC9BC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,0BAA0B,CAAC;EAGvCC,KAAK;IAAA,IAAAC,MAAA,OAAAC,kBAAA,CAAAC,OAAA,EAAAC,YAAA,CAAAD,OAAA,CAAAE,IAAA,CAAE,SAAAC,QAAOC,WAAW,EAAEC,OAAO;MAAA,OAAAJ,YAAA,CAAAD,OAAA,CAAAM,IAAA,UAAAC,SAAAC,QAAA;QAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;UAAA;YAAA,OAAAF,QAAA,CAAAG,MAAA,WAAK,IAAAC,oDAAyB,EAACR,WAAW,CAAC;UAAA;UAAA;YAAA,OAAAI,QAAA,CAAAK,IAAA;QAAA;MAAA,GAAAV,OAAA;IAAA;IAAA,SAAAN,MAAAiB,EAAA,EAAAC,GAAA;MAAA,OAAAjB,MAAA,CAAAkB,KAAA,OAAAC,SAAA;IAAA;IAAA,OAAApB,KAAA;EAAA;EAC7EqB,SAAS,EAAE,SAAAA,UAACd,WAAW,EAAEC,OAAO;IAAA,OAAK,IAAAO,oDAAyB,EAACR,WAAW,CAAC;EAAA;EAC3Ee,MAAM,EAAE;AACV,CAAC;AAACC,OAAA,CAAA5B,0BAAA,GAAAA,0BAAA"}
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.PotreeLoader = void 0;
7
- var VERSION = typeof "4.0.0-alpha.9" !== 'undefined' ? "4.0.0-alpha.9" : 'latest';
7
+ var VERSION = typeof "4.0.0-beta.2" !== 'undefined' ? "4.0.0-beta.2" : 'latest';
8
8
  var PotreeLoader = {
9
9
  name: 'potree',
10
10
  id: 'potree',
@@ -1 +1 @@
1
- {"version":3,"file":"potree-loader.js","names":["VERSION","PotreeLoader","name","id","module","version","extensions","mimeTypes","testText","text","indexOf","parseTextSync","JSON","parse","options","potree","exports"],"sources":["../../src/potree-loader.ts"],"sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/** Potree loader */\n// @ts-ignore\nexport const PotreeLoader: LoaderWithParser = {\n name: 'potree',\n id: 'potree',\n module: 'potree',\n version: VERSION,\n extensions: ['json'],\n mimeTypes: ['application/json'],\n testText: (text) => text.indexOf('octreeDir') >= 0,\n parseTextSync: (text) => JSON.parse(text),\n options: {\n potree: {}\n }\n};\n"],"mappings":";;;;;;AAIA,IAAMA,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAIpE,IAAMC,YAA8B,GAAG;EAC5CC,IAAI,EAAE,QAAQ;EACdC,EAAE,EAAE,QAAQ;EACZC,MAAM,EAAE,QAAQ;EAChBC,OAAO,EAAEL,OAAO;EAChBM,UAAU,EAAE,CAAC,MAAM,CAAC;EACpBC,SAAS,EAAE,CAAC,kBAAkB,CAAC;EAC/BC,QAAQ,EAAE,SAAAA,SAACC,IAAI;IAAA,OAAKA,IAAI,CAACC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC;EAAA;EAClDC,aAAa,EAAE,SAAAA,cAACF,IAAI;IAAA,OAAKG,IAAI,CAACC,KAAK,CAACJ,IAAI,CAAC;EAAA;EACzCK,OAAO,EAAE;IACPC,MAAM,EAAE,CAAC;EACX;AACF,CAAC;AAACC,OAAA,CAAAf,YAAA,GAAAA,YAAA"}
1
+ {"version":3,"file":"potree-loader.js","names":["VERSION","PotreeLoader","name","id","module","version","extensions","mimeTypes","testText","text","indexOf","parseTextSync","JSON","parse","options","potree","exports"],"sources":["../../src/potree-loader.ts"],"sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type POTreeLoaderOptions = LoaderOptions & {\n potree?: {};\n};\n\n/** Potree loader */\n// @ts-ignore\nexport const PotreeLoader: LoaderWithParser<any, never, POTreeLoaderOptions> = {\n name: 'potree',\n id: 'potree',\n module: 'potree',\n version: VERSION,\n extensions: ['json'],\n mimeTypes: ['application/json'],\n testText: (text) => text.indexOf('octreeDir') >= 0,\n parseTextSync: (text) => JSON.parse(text),\n options: {\n potree: {}\n }\n};\n"],"mappings":";;;;;;AAIA,IAAMA,OAAO,GAAG,qBAAkB,KAAK,WAAW,oBAAiB,QAAQ;AAQpE,IAAMC,YAA+D,GAAG;EAC7EC,IAAI,EAAE,QAAQ;EACdC,EAAE,EAAE,QAAQ;EACZC,MAAM,EAAE,QAAQ;EAChBC,OAAO,EAAEL,OAAO;EAChBM,UAAU,EAAE,CAAC,MAAM,CAAC;EACpBC,SAAS,EAAE,CAAC,kBAAkB,CAAC;EAC/BC,QAAQ,EAAE,SAAAA,SAACC,IAAI;IAAA,OAAKA,IAAI,CAACC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC;EAAA;EAClDC,aAAa,EAAE,SAAAA,cAACF,IAAI;IAAA,OAAKG,IAAI,CAACC,KAAK,CAACJ,IAAI,CAAC;EAAA;EACzCK,OAAO,EAAE;IACPC,MAAM,EAAE,CAAC;EACX;AACF,CAAC;AAACC,OAAA,CAAAf,YAAA,GAAAA,YAAA"}
@@ -1,4 +1,4 @@
1
- export default function parsePotreeBin(arrayBuffer, byteOffset, options, index) {
1
+ export function parsePotreeBin(arrayBuffer, byteOffset, options, index) {
2
2
  return null;
3
3
  }
4
4
  //# sourceMappingURL=parse-potree-bin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-potree-bin.js","names":["parsePotreeBin","arrayBuffer","byteOffset","options","index"],"sources":["../../../src/parsers/parse-potree-bin.ts"],"sourcesContent":["export default function parsePotreeBin(\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n options: unknown,\n index: any\n) {\n return null;\n}\n"],"mappings":"AAAA,eAAe,SAASA,cAAcA,CACpCC,WAAwB,EACxBC,UAAkB,EAClBC,OAAgB,EAChBC,KAAU,EACV;EACA,OAAO,IAAI;AACb"}
1
+ {"version":3,"file":"parse-potree-bin.js","names":["parsePotreeBin","arrayBuffer","byteOffset","options","index"],"sources":["../../../src/parsers/parse-potree-bin.ts"],"sourcesContent":["export function parsePotreeBin(\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n options: unknown,\n index: any\n) {\n return null;\n}\n"],"mappings":"AAAA,OAAO,SAASA,cAAcA,CAC5BC,WAAwB,EACxBC,UAAkB,EAClBC,OAAgB,EAChBC,KAAU,EACV;EACA,OAAO,IAAI;AACb"}
@@ -1,4 +1,4 @@
1
- export default function parsePotreeHierarchyChunk(arrayBuffer) {
1
+ export function parsePotreeHierarchyChunk(arrayBuffer) {
2
2
  const tileHeaders = parseBinaryChunk(arrayBuffer);
3
3
  return buildHierarchy(tileHeaders);
4
4
  }
@@ -51,6 +51,7 @@ function buildHierarchy(tileHeaders) {
51
51
  const topNode = tileHeaders[0];
52
52
  const nodes = {};
53
53
  for (const tileHeader of tileHeaders) {
54
+ var _options;
54
55
  const {
55
56
  name
56
57
  } = tileHeader;
@@ -62,7 +63,7 @@ function buildHierarchy(tileHeaders) {
62
63
  tileHeader.hasChildren = tileHeader.header.childCount;
63
64
  tileHeader.children = [];
64
65
  tileHeader.childrenByIndex = new Array(8).fill(null);
65
- tileHeader.spacing = options.spacing / Math.pow(2, level);
66
+ tileHeader.spacing = (((_options = options) === null || _options === void 0 ? void 0 : _options.spacing) || 0) / Math.pow(2, level);
66
67
  if (parentNode) {
67
68
  parentNode.children.push(tileHeader);
68
69
  parentNode.childrenByIndex[index] = tileHeader;
@@ -1 +1 @@
1
- {"version":3,"file":"parse-potree-hierarchy-chunk.js","names":["parsePotreeHierarchyChunk","arrayBuffer","tileHeaders","parseBinaryChunk","buildHierarchy","byteOffset","arguments","length","undefined","dataView","DataView","stack","topTileHeader","decodeRow","push","snode","shift","mask","i","header","childMask","tileHeader","name","childCount","byteLength","getUint8","pointCount","getUint32","options","DEFAULT_OPTIONS","spacing","topNode","nodes","index","parseInt","charAt","parentName","substring","parentNode","level","hasChildren","children","childrenByIndex","Array","fill","Math","pow"],"sources":["../../../src/parsers/parse-potree-hierarchy-chunk.ts"],"sourcesContent":["// 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\n// Potree Hierarchy Chunk file format\n// https://github.com/potree/potree/blob/develop/docs/potree-file-format.md#index-files\n\n/*\n### Hierarchy Chunk Files\n\nAs mentioned in the former section, the `.hrc` files contain the index structure\nmeaning a list of all the files stored within the directory tree.\n\nAn index file contains a list of tuple values with the first being a `uint8`\n\"mask\" and the second being `uint32` \"number of points\" of a hierarchy level\nin a [breadth first level order][breadth-first].\n\nPer hierarchy level we have 8 possible nodes. To indicate whether a node exists\na simple binary mask is used:\n\n| Position | Mask | [Binary][bin] |\n|----------|------|---------------|\n| 0 | 1 | 0b00000001 |\n| 1 | 2 | 0b00000010 |\n| 2 | 4 | 0b00000100 |\n| 3 | 8 | 0b00001000 |\n| 4 | 16 | 0b00010000 |\n| 5 | 32 | 0b00100000 |\n| 6 | 64 | 0b01000000 |\n| 7 | 128 | 0b10000000 |\n\nSo if in a hierarchy the child node 3 and node 7 exist then the hierarchies\nmask has to be `0b00001000 | 0b10000000` → `0b10001000` (=136).\n\n_Example:_ A simple, non-realistic tree:\n\n```\n|- r1\n| |\n| \\- r14 (2 Points)\n|\n\\- r3\n |\n \\- r36 (1 Point)\n```\n\nWould have an index looking like this:\n\n| name | mask | points |\n|------|--------------------|--------|\n| r | `0b00001010` (=10) | `3` |\n| r1 | `0b00010000` (=16) | `2` |\n| r3 | `0b01000000` (=64) | `1` |\n| r14 | `0b00000000` (=0) | `2` |\n| r36 | `0b00000000` (=0) | `1` |\n*/\n\n// @ts-nocheck\n\n// load hierarchy\nexport default function parsePotreeHierarchyChunk(arrayBuffer: ArrayBuffer) {\n const tileHeaders = parseBinaryChunk(arrayBuffer);\n return buildHierarchy(tileHeaders);\n}\n\n// Parses the binary rows\nfunction parseBinaryChunk(arrayBuffer: ArrayBuffer, byteOffset = 0) {\n const dataView = new DataView(arrayBuffer);\n\n const stack = [];\n\n // Get root mask\n const topTileHeader = {};\n byteOffset = decodeRow(dataView, byteOffset, topTileHeader);\n\n stack.push(topTileHeader);\n\n const tileHeaders = [];\n\n while (stack.length > 0) {\n const snode = stack.shift();\n let mask = 1;\n\n for (let i = 0; i < 8; i++) {\n if (snode && (snode.header.childMask & mask) !== 0) {\n const tileHeader = {};\n byteOffset = decodeRow(dataView, byteOffset, tileHeader);\n tileHeader.name = snode.name + i;\n\n stack.push(tileHeader);\n tileHeaders.push(tileHeader);\n snode.header.childCount++;\n }\n mask = mask * 2;\n }\n\n if (byteOffset === dataView.byteLength) {\n break;\n }\n }\n\n return tileHeaders;\n}\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\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\n const topNode = tileHeaders[0];\n const nodes = {};\n\n for (const tileHeader of tileHeaders) {\n const {name} = tileHeader;\n\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\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 / Math.pow(2, level);\n // tileHeader.boundingVolume = Utils.createChildAABB(parentNode.boundingBox, index);\n\n if (parentNode) {\n parentNode.children.push(tileHeader);\n parentNode.childrenByIndex[index] = tileHeader;\n }\n\n // Add the node to the map\n nodes[name] = tileHeader;\n }\n\n // First node is the root\n return topNode;\n}\n"],"mappings":"AA2DA,eAAe,SAASA,yBAAyBA,CAACC,WAAwB,EAAE;EAC1E,MAAMC,WAAW,GAAGC,gBAAgB,CAACF,WAAW,CAAC;EACjD,OAAOG,cAAc,CAACF,WAAW,CAAC;AACpC;AAGA,SAASC,gBAAgBA,CAACF,WAAwB,EAAkB;EAAA,IAAhBI,UAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAChE,MAAMG,QAAQ,GAAG,IAAIC,QAAQ,CAACT,WAAW,CAAC;EAE1C,MAAMU,KAAK,GAAG,EAAE;EAGhB,MAAMC,aAAa,GAAG,CAAC,CAAC;EACxBP,UAAU,GAAGQ,SAAS,CAACJ,QAAQ,EAAEJ,UAAU,EAAEO,aAAa,CAAC;EAE3DD,KAAK,CAACG,IAAI,CAACF,aAAa,CAAC;EAEzB,MAAMV,WAAW,GAAG,EAAE;EAEtB,OAAOS,KAAK,CAACJ,MAAM,GAAG,CAAC,EAAE;IACvB,MAAMQ,KAAK,GAAGJ,KAAK,CAACK,KAAK,CAAC,CAAC;IAC3B,IAAIC,IAAI,GAAG,CAAC;IAEZ,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG,CAAC,EAAEA,CAAC,EAAE,EAAE;MAC1B,IAAIH,KAAK,IAAI,CAACA,KAAK,CAACI,MAAM,CAACC,SAAS,GAAGH,IAAI,MAAM,CAAC,EAAE;QAClD,MAAMI,UAAU,GAAG,CAA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GAAG,CAAC,CAAC;EAEhB,KAAK,MAAMX,UAAU,IAAInB,WAAW,EAAE;IACpC,MAAM;MAACoB;IAAI,CAAC,GAAGD,UAAU;IAEzB,MAAMY,KAAK,GAAGC,QAAQ,CAACZ,IAAI,CAACa,MAAM,CAACb,IAAI,CAACf,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC;IACxD,MAAM6B,UAAU,GAAGd,IAAI,CAACe,SAAS,CAAC,CAAC,EAAEf,IAAI,CAACf,MAAM,GAAG,CAAC,CAAC;IACrD,MAAM+B,UAAU,GAAGN,KAAK,CAACI,UAAU,CAAC;IACpC,MAAMG,KAAK,GAAGjB,IAAI,CAACf,MAAM,GAAG,CAAC;IAG7Bc,UAAU,CAACkB,KAAK,GAAGA,KAAK;IACxBlB,UAAU,CAACmB,WAAW,GAAGnB,UAAU,CAACF,MAAM,CAACI,UAAU;IACrDF,UAAU,CAACoB,QAAQ,GAAG,EAAE;IACxBpB,UAAU,CAACqB,eAAe,GAAG,IAAIC,KAAK,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;IACpDvB,UAAU,CAACS,OAAO,GAAGF,OAAO,CAACE,OAAO,GAAGe,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEP,KAAK,CAAC;IAGzD,IAAID,UAAU,EAAE;MACdA,UAAU,CAACG,QAAQ,CAAC3B,IAAI,CAACO,UAAU,CAAC;MACpCiB,UAAU,CAACI,eAAe,CAACT,KAAK,CAAC,GAAGZ,UAAU;IAChD;IAGAW,KAAK,CAACV,IAAI,CAAC,GAAGD,UAAU;EAC1B;EAGA,OAAOU,OAAO;AAChB"}
1
+ {"version":3,"file":"parse-potree-hierarchy-chunk.js","names":["parsePotreeHierarchyChunk","arrayBuffer","tileHeaders","parseBinaryChunk","buildHierarchy","byteOffset","arguments","length","undefined","dataView","DataView","stack","topTileHeader","decodeRow","push","snode","shift","mask","i","header","childMask","tileHeader","name","childCount","byteLength","getUint8","pointCount","getUint32","options","DEFAULT_OPTIONS","spacing","topNode","nodes","_options","index","parseInt","charAt","parentName","substring","parentNode","level","hasChildren","children","childrenByIndex","Array","fill","Math","pow"],"sources":["../../../src/parsers/parse-potree-hierarchy-chunk.ts"],"sourcesContent":["// 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\n// Potree Hierarchy Chunk file format\n// https://github.com/potree/potree/blob/develop/docs/potree-file-format.md#index-files\n\n/*\n### Hierarchy Chunk Files\n\nAs mentioned in the former section, the `.hrc` files contain the index structure\nmeaning a list of all the files stored within the directory tree.\n\nAn index file contains a list of tuple values with the first being a `uint8`\n\"mask\" and the second being `uint32` \"number of points\" of a hierarchy level\nin a [breadth first level order][breadth-first].\n\nPer hierarchy level we have 8 possible nodes. To indicate whether a node exists\na simple binary mask is used:\n\n| Position | Mask | [Binary][bin] |\n|----------|------|---------------|\n| 0 | 1 | 0b00000001 |\n| 1 | 2 | 0b00000010 |\n| 2 | 4 | 0b00000100 |\n| 3 | 8 | 0b00001000 |\n| 4 | 16 | 0b00010000 |\n| 5 | 32 | 0b00100000 |\n| 6 | 64 | 0b01000000 |\n| 7 | 128 | 0b10000000 |\n\nSo if in a hierarchy the child node 3 and node 7 exist then the hierarchies\nmask has to be `0b00001000 | 0b10000000` → `0b10001000` (=136).\n\n_Example:_ A simple, non-realistic tree:\n\n```\n|- r1\n| |\n| \\- r14 (2 Points)\n|\n\\- r3\n |\n \\- r36 (1 Point)\n```\n\nWould have an index looking like this:\n\n| name | mask | points |\n|------|--------------------|--------|\n| r | `0b00001010` (=10) | `3` |\n| r1 | `0b00010000` (=16) | `2` |\n| r3 | `0b01000000` (=64) | `1` |\n| r14 | `0b00000000` (=0) | `2` |\n| r36 | `0b00000000` (=0) | `1` |\n*/\n\n/** @todo these types are an incorrect mess */\nexport type POTreeTileHeader = {\n childCount: number;\n name: string;\n childMask: number;\n};\n\n/** @todo these types are an incorrect mess */\nexport type POTreeNode = {\n header: POTreeTileHeader;\n name: string;\n pointCount: number;\n children: POTreeNode[];\n childrenByIndex: POTreeNode[];\n};\n\n// type POTreeTileNode = POTreeNode;\n\n// load hierarchy\nexport function parsePotreeHierarchyChunk(arrayBuffer: ArrayBuffer) {\n const tileHeaders = parseBinaryChunk(arrayBuffer);\n return buildHierarchy(tileHeaders);\n}\n\n// Parses the binary rows\nfunction parseBinaryChunk(arrayBuffer: ArrayBuffer, byteOffset = 0) {\n const dataView = new DataView(arrayBuffer);\n\n const stack: POTreeNode[] = [];\n\n // Get root mask\n // @ts-expect-error\n const topTileHeader: POTreeNode = {};\n byteOffset = decodeRow(dataView, byteOffset, topTileHeader);\n\n stack.push(topTileHeader);\n\n const tileHeaders: POTreeTileHeader[] = [];\n\n while (stack.length > 0) {\n const snode = stack.shift();\n let mask = 1;\n\n for (let i = 0; i < 8; i++) {\n if (snode && (snode.header.childMask & mask) !== 0) {\n // @ts-expect-error\n const tileHeader: POTreeTileHeader = {};\n byteOffset = decodeRow(dataView, byteOffset, tileHeader);\n tileHeader.name = snode.name + i;\n\n // @ts-expect-error\n stack.push(tileHeader);\n tileHeaders.push(tileHeader);\n snode.header.childCount++;\n }\n mask = mask * 2;\n }\n\n if (byteOffset === dataView.byteLength) {\n break;\n }\n }\n\n return tileHeaders;\n}\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\n// Resolves the binary rows into a hierarchy (tree structure)\nfunction buildHierarchy(tileHeaders, options: {spacing?: number} = {}): POTreeNode {\n const DEFAULT_OPTIONS = {spacing: 100}; // TODO assert instead of default?\n options = {...DEFAULT_OPTIONS, ...options};\n\n const topNode = tileHeaders[0];\n const nodes = {};\n\n for (const tileHeader of tileHeaders) {\n const {name} = tileHeader;\n\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\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\n if (parentNode) {\n parentNode.children.push(tileHeader);\n parentNode.childrenByIndex[index] = tileHeader;\n }\n\n // Add the node to the map\n nodes[name] = tileHeader;\n }\n\n // First node is the root\n return topNode;\n}\n"],"mappings":"AA2EA,OAAO,SAASA,yBAAyBA,CAACC,WAAwB,EAAE;EAClE,MAAMC,WAAW,GAAGC,gBAAgB,CAACF,WAAW,CAAC;EACjD,OAAOG,cAAc,CAACF,WAAW,CAAC;AACpC;AAGA,SAASC,gBAAgBA,CAACF,WAAwB,EAAkB;EAAA,IAAhBI,UAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAChE,MAAMG,QAAQ,GAAG,IAAIC,QAAQ,CAACT,WAAW,CAAC;EAE1C,MAAMU,KAAmB,GAAG,EAAE;EAI9B,MAAMC,aAAyB,GAAG,CAAC,CAAC;EACpCP,UAAU,GAAGQ,SAAS,CAACJ,QAAQ,EAAEJ,UAAU,EAAEO,aAAa,CAAC;EAE3DD,KAAK,CAACG,IAAI,CAACF,aAAa,CAAC;EAEzB,MAAMV,WAA+B,GAAG,EAAE;EAE1C,OAAOS,KAAK,CAACJ,MAAM,GAAG,CAAC,EAAE;IACvB,MAAMQ,KAAK,GAAGJ,KAAK,CAACK,KAAK,CAAC,CAAC;IAC3B,IAAIC,IAAI,GAAG,CAAC;IAEZ,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG,CAAC,EAAEA,CAAC,EAAE,EAAE;M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,4 +1,4 @@
1
- import { default as parsePotreeBin } from './parsers/parse-potree-bin';
1
+ import { parsePotreeBin } from './parsers/parse-potree-bin';
2
2
  export const PotreeBinLoader = {
3
3
  name: 'potree Binary Point Attributes',
4
4
  id: 'potree',
@@ -1 +1 @@
1
- {"version":3,"file":"potree-bin-loader.js","names":["default","parsePotreeBin","PotreeBinLoader","name","id","extensions","mimeTypes","parseSync","binary","arrayBuffer","options","index","byteOffset"],"sources":["../../src/potree-bin-loader.ts"],"sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {default as parsePotreeBin} from './parsers/parse-potree-bin';\n\n/**\n * Loader for potree Binary Point Attributes\n * */\n// @ts-ignore\nexport const PotreeBinLoader: LoaderWithParser = {\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};\n\nfunction parseSync(arrayBuffer: ArrayBuffer, options?: LoaderOptions) {\n const index = {};\n const byteOffset = 0;\n parsePotreeBin(arrayBuffer, byteOffset, options, index);\n return index;\n}\n"],"mappings":"AACA,SAAQA,OAAO,IAAIC,cAAc,QAAO,4BAA4B;AAMpE,OAAO,MAAMC,eAAiC,GAAG;EAC/CC,IAAI,EAAE,gCAAgC;EACtCC,EAAE,EAAE,QAAQ;EACZC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,0BAA0B,CAAC;EAGvCC,SAAS;EACTC,MAAM,EAAE;AACV,CAAC;AAED,SAASD,SAASA,CAACE,WAAwB,EAAEC,OAAuB,EAAE;EACpE,MAAMC,KAAK,GAAG,CAAC,CAAC;EAChB,MAAMC,UAAU,GAAG,CAAC;EACpBX,cAAc,CAACQ,WAAW,EAAEG,UAAU,EAAEF,OAAO,EAAEC,KAAK,CAAC;EACvD,OAAOA,KAAK;AACd"}
1
+ {"version":3,"file":"potree-bin-loader.js","names":["parsePotreeBin","PotreeBinLoader","name","id","extensions","mimeTypes","parseSync","binary","arrayBuffer","options","index","byteOffset"],"sources":["../../src/potree-bin-loader.ts"],"sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {parsePotreeBin} from './parsers/parse-potree-bin';\n\n/**\n * Loader for potree Binary Point Attributes\n * */\n// @ts-ignore\nexport const PotreeBinLoader: LoaderWithParser<{}, never, LoaderOptions> = {\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};\n\nfunction parseSync(arrayBuffer: ArrayBuffer, options?: LoaderOptions): {} {\n const index = {};\n const byteOffset = 0;\n parsePotreeBin(arrayBuffer, byteOffset, options, index);\n return index;\n}\n"],"mappings":"AACA,SAAQA,cAAc,QAAO,4BAA4B;AAMzD,OAAO,MAAMC,eAA2D,GAAG;EACzEC,IAAI,EAAE,gCAAgC;EACtCC,EAAE,EAAE,QAAQ;EACZC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,0BAA0B,CAAC;EAGvCC,SAAS;EACTC,MAAM,EAAE;AACV,CAAC;AAED,SAASD,SAASA,CAACE,WAAwB,EAAEC,OAAuB,EAAM;EACxE,MAAMC,KAAK,GAAG,CAAC,CAAC;EAChB,MAAMC,UAAU,GAAG,CAAC;EACpBX,cAAc,CAACQ,WAAW,EAAEG,UAAU,EAAEF,OAAO,EAAEC,KAAK,CAAC;EACvD,OAAOA,KAAK;AACd"}
@@ -1,14 +1,11 @@
1
- import { default as parsePotreeHierarchyChunk } from './parsers/parse-potree-hierarchy-chunk';
1
+ import { parsePotreeHierarchyChunk } from './parsers/parse-potree-hierarchy-chunk';
2
2
  export const PotreeHierarchyChunkLoader = {
3
3
  id: 'potree',
4
4
  name: 'potree Hierarchy Chunk',
5
5
  extensions: ['hrc'],
6
6
  mimeTypes: ['application/octet-stream'],
7
- parse: async (arrayBuffer, options) => await parseSync(arrayBuffer),
8
- parseSync,
7
+ parse: async (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),
8
+ parseSync: (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),
9
9
  binary: true
10
10
  };
11
- function parseSync(arrayBuffer) {
12
- return parsePotreeHierarchyChunk(arrayBuffer);
13
- }
14
11
  //# sourceMappingURL=potree-hierarchy-chunk-loader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"potree-hierarchy-chunk-loader.js","names":["default","parsePotreeHierarchyChunk","PotreeHierarchyChunkLoader","id","name","extensions","mimeTypes","parse","arrayBuffer","options","parseSync","binary"],"sources":["../../src/potree-hierarchy-chunk-loader.ts"],"sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {default as parsePotreeHierarchyChunk} from './parsers/parse-potree-hierarchy-chunk';\n\n/** Potree hierarchy chunk loader */\n// @ts-ignore\nexport const PotreeHierarchyChunkLoader: LoaderWithParser = {\n id: 'potree',\n name: 'potree Hierarchy Chunk',\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) => await parseSync(arrayBuffer),\n parseSync,\n binary: true\n};\n\nfunction parseSync(arrayBuffer) {\n return parsePotreeHierarchyChunk(arrayBuffer);\n}\n"],"mappings":"AACA,SAAQA,OAAO,IAAIC,yBAAyB,QAAO,wCAAwC;AAI3F,OAAO,MAAMC,0BAA4C,GAAG;EAC1DC,EAAE,EAAE,QAAQ;EACZC,IAAI,EAAE,wBAAwB;EAC9BC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,0BAA0B,CAAC;EAGvCC,KAAK,EAAE,MAAAA,CAAOC,WAAW,EAAEC,OAAO,KAAK,MAAMC,SAAS,CAACF,WAAW,CAAC;EACnEE,SAAS;EACTC,MAAM,EAAE;AACV,CAAC;AAED,SAASD,SAASA,CAACF,WAAW,EAAE;EAC9B,OAAOP,yBAAyB,CAACO,WAAW,CAAC;AAC/C"}
1
+ {"version":3,"file":"potree-hierarchy-chunk-loader.js","names":["parsePotreeHierarchyChunk","PotreeHierarchyChunkLoader","id","name","extensions","mimeTypes","parse","arrayBuffer","options","parseSync","binary"],"sources":["../../src/potree-hierarchy-chunk-loader.ts"],"sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {POTreeLoaderOptions} from './potree-loader';\nimport type {POTreeNode} from './parsers/parse-potree-hierarchy-chunk';\nimport {parsePotreeHierarchyChunk} from './parsers/parse-potree-hierarchy-chunk';\n\n/** Potree hierarchy chunk loader */\n// @ts-ignore not a valid loader\nexport const PotreeHierarchyChunkLoader: LoaderWithParser<POTreeNode, never, POTreeLoaderOptions> =\n {\n id: 'potree',\n name: 'potree Hierarchy Chunk',\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 binary: true\n };\n"],"mappings":"AAGA,SAAQA,yBAAyB,QAAO,wCAAwC;AAIhF,OAAO,MAAMC,0BAAoF,GAC/F;EACEC,EAAE,EAAE,QAAQ;EACZC,IAAI,EAAE,wBAAwB;EAC9BC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,0BAA0B,CAAC;EAGvCC,KAAK,EAAE,MAAAA,CAAOC,WAAW,EAAEC,OAAO,KAAKR,yBAAyB,CAACO,WAAW,CAAC;EAC7EE,SAAS,EAAEA,CAACF,WAAW,EAAEC,OAAO,KAAKR,yBAAyB,CAACO,WAAW,CAAC;EAC3EG,MAAM,EAAE;AACV,CAAC"}
@@ -1,4 +1,4 @@
1
- const VERSION = typeof "4.0.0-alpha.9" !== 'undefined' ? "4.0.0-alpha.9" : 'latest';
1
+ const VERSION = typeof "4.0.0-beta.2" !== 'undefined' ? "4.0.0-beta.2" : 'latest';
2
2
  export const PotreeLoader = {
3
3
  name: 'potree',
4
4
  id: 'potree',
@@ -1 +1 @@
1
- {"version":3,"file":"potree-loader.js","names":["VERSION","PotreeLoader","name","id","module","version","extensions","mimeTypes","testText","text","indexOf","parseTextSync","JSON","parse","options","potree"],"sources":["../../src/potree-loader.ts"],"sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/** Potree loader */\n// @ts-ignore\nexport const PotreeLoader: LoaderWithParser = {\n name: 'potree',\n id: 'potree',\n module: 'potree',\n version: VERSION,\n extensions: ['json'],\n mimeTypes: ['application/json'],\n testText: (text) => text.indexOf('octreeDir') >= 0,\n parseTextSync: (text) => JSON.parse(text),\n options: {\n potree: {}\n }\n};\n"],"mappings":"AAIA,MAAMA,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAI3E,OAAO,MAAMC,YAA8B,GAAG;EAC5CC,IAAI,EAAE,QAAQ;EACdC,EAAE,EAAE,QAAQ;EACZC,MAAM,EAAE,QAAQ;EAChBC,OAAO,EAAEL,OAAO;EAChBM,UAAU,EAAE,CAAC,MAAM,CAAC;EACpBC,SAAS,EAAE,CAAC,kBAAkB,CAAC;EAC/BC,QAAQ,EAAGC,IAAI,IAAKA,IAAI,CAACC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC;EAClDC,aAAa,EAAGF,IAAI,IAAKG,IAAI,CAACC,KAAK,CAACJ,IAAI,CAAC;EACzCK,OAAO,EAAE;IACPC,MAAM,EAAE,CAAC;EACX;AACF,CAAC"}
1
+ {"version":3,"file":"potree-loader.js","names":["VERSION","PotreeLoader","name","id","module","version","extensions","mimeTypes","testText","text","indexOf","parseTextSync","JSON","parse","options","potree"],"sources":["../../src/potree-loader.ts"],"sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type POTreeLoaderOptions = LoaderOptions & {\n potree?: {};\n};\n\n/** Potree loader */\n// @ts-ignore\nexport const PotreeLoader: LoaderWithParser<any, never, POTreeLoaderOptions> = {\n name: 'potree',\n id: 'potree',\n module: 'potree',\n version: VERSION,\n extensions: ['json'],\n mimeTypes: ['application/json'],\n testText: (text) => text.indexOf('octreeDir') >= 0,\n parseTextSync: (text) => JSON.parse(text),\n options: {\n potree: {}\n }\n};\n"],"mappings":"AAIA,MAAMA,OAAO,GAAG,qBAAkB,KAAK,WAAW,oBAAiB,QAAQ;AAQ3E,OAAO,MAAMC,YAA+D,GAAG;EAC7EC,IAAI,EAAE,QAAQ;EACdC,EAAE,EAAE,QAAQ;EACZC,MAAM,EAAE,QAAQ;EAChBC,OAAO,EAAEL,OAAO;EAChBM,UAAU,EAAE,CAAC,MAAM,CAAC;EACpBC,SAAS,EAAE,CAAC,kBAAkB,CAAC;EAC/BC,QAAQ,EAAGC,IAAI,IAAKA,IAAI,CAACC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC;EAClDC,aAAa,EAAGF,IAAI,IAAKG,IAAI,CAACC,KAAK,CAACJ,IAAI,CAAC;EACzCK,OAAO,EAAE;IACPC,MAAM,EAAE,CAAC;EACX;AACF,CAAC"}
@@ -1,2 +1,2 @@
1
- export default function parsePotreeBin(arrayBuffer: ArrayBuffer, byteOffset: number, options: unknown, index: any): null;
1
+ export declare function parsePotreeBin(arrayBuffer: ArrayBuffer, byteOffset: number, options: unknown, index: any): null;
2
2
  //# sourceMappingURL=parse-potree-bin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-potree-bin.d.ts","sourceRoot":"","sources":["../../src/parsers/parse-potree-bin.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,GAAG,QAGX"}
1
+ {"version":3,"file":"parse-potree-bin.d.ts","sourceRoot":"","sources":["../../src/parsers/parse-potree-bin.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAC5B,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,GAAG,QAGX"}
@@ -1,2 +1,16 @@
1
- export default function parsePotreeHierarchyChunk(arrayBuffer: ArrayBuffer): any;
1
+ /** @todo these types are an incorrect mess */
2
+ export type POTreeTileHeader = {
3
+ childCount: number;
4
+ name: string;
5
+ childMask: number;
6
+ };
7
+ /** @todo these types are an incorrect mess */
8
+ export type POTreeNode = {
9
+ header: POTreeTileHeader;
10
+ name: string;
11
+ pointCount: number;
12
+ children: POTreeNode[];
13
+ childrenByIndex: POTreeNode[];
14
+ };
15
+ export declare function parsePotreeHierarchyChunk(arrayBuffer: ArrayBuffer): POTreeNode;
2
16
  //# sourceMappingURL=parse-potree-hierarchy-chunk.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-potree-hierarchy-chunk.d.ts","sourceRoot":"","sources":["../../src/parsers/parse-potree-hierarchy-chunk.ts"],"names":[],"mappings":"AA2DA,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,WAAW,EAAE,WAAW,OAGzE"}
1
+ {"version":3,"file":"parse-potree-hierarchy-chunk.d.ts","sourceRoot":"","sources":["../../src/parsers/parse-potree-hierarchy-chunk.ts"],"names":[],"mappings":"AAwDA,8CAA8C;AAC9C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,8CAA8C;AAC9C,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,gBAAgB,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,eAAe,EAAE,UAAU,EAAE,CAAC;CAC/B,CAAC;AAKF,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,WAAW,cAGjE"}
@@ -1,6 +1,6 @@
1
- import type { LoaderWithParser } from '@loaders.gl/loader-utils';
1
+ import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
2
2
  /**
3
3
  * Loader for potree Binary Point Attributes
4
4
  * */
5
- export declare const PotreeBinLoader: LoaderWithParser;
5
+ export declare const PotreeBinLoader: LoaderWithParser<{}, never, LoaderOptions>;
6
6
  //# sourceMappingURL=potree-bin-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"potree-bin-loader.d.ts","sourceRoot":"","sources":["../src/potree-bin-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAgB,MAAM,0BAA0B,CAAC;AAG9E;;KAEK;AAEL,eAAO,MAAM,eAAe,EAAE,gBAS7B,CAAC"}
1
+ {"version":3,"file":"potree-bin-loader.d.ts","sourceRoot":"","sources":["../src/potree-bin-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAG9E;;KAEK;AAEL,eAAO,MAAM,eAAe,EAAE,gBAAgB,CAAC,EAAE,EAAE,KAAK,EAAE,aAAa,CAStE,CAAC"}
@@ -1,4 +1,6 @@
1
1
  import type { LoaderWithParser } from '@loaders.gl/loader-utils';
2
+ import type { POTreeLoaderOptions } from './potree-loader';
3
+ import type { POTreeNode } from './parsers/parse-potree-hierarchy-chunk';
2
4
  /** Potree hierarchy chunk loader */
3
- export declare const PotreeHierarchyChunkLoader: LoaderWithParser;
5
+ export declare const PotreeHierarchyChunkLoader: LoaderWithParser<POTreeNode, never, POTreeLoaderOptions>;
4
6
  //# 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":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAG/D,oCAAoC;AAEpC,eAAO,MAAM,0BAA0B,EAAE,gBAUxC,CAAC"}
1
+ {"version":3,"file":"potree-hierarchy-chunk-loader.d.ts","sourceRoot":"","sources":["../src/potree-hierarchy-chunk-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,wCAAwC,CAAC;AAGvE,oCAAoC;AAEpC,eAAO,MAAM,0BAA0B,EAAE,gBAAgB,CAAC,UAAU,EAAE,KAAK,EAAE,mBAAmB,CAW7F,CAAC"}
@@ -1,4 +1,7 @@
1
- import type { LoaderWithParser } from '@loaders.gl/loader-utils';
1
+ import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
2
+ export type POTreeLoaderOptions = LoaderOptions & {
3
+ potree?: {};
4
+ };
2
5
  /** Potree loader */
3
- export declare const PotreeLoader: LoaderWithParser;
6
+ export declare const PotreeLoader: LoaderWithParser<any, never, POTreeLoaderOptions>;
4
7
  //# sourceMappingURL=potree-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"potree-loader.d.ts","sourceRoot":"","sources":["../src/potree-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAM/D,oBAAoB;AAEpB,eAAO,MAAM,YAAY,EAAE,gBAY1B,CAAC"}
1
+ {"version":3,"file":"potree-loader.d.ts","sourceRoot":"","sources":["../src/potree-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAM9E,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG;IAChD,MAAM,CAAC,EAAE,EAAE,CAAC;CACb,CAAC;AAEF,oBAAoB;AAEpB,eAAO,MAAM,YAAY,EAAE,gBAAgB,CAAC,GAAG,EAAE,KAAK,EAAE,mBAAmB,CAY1E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/potree",
3
- "version": "4.0.0-alpha.9",
3
+ "version": "4.0.0-beta.2",
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": "4.0.0-alpha.9",
38
+ "@loaders.gl/math": "4.0.0-beta.2",
39
39
  "@math.gl/core": "^3.5.1"
40
40
  },
41
- "gitHead": "03ff81ab468f20f3bddeec787aa88d477a7e1c72"
41
+ "gitHead": "79c2033f755e88e11bc30a04428e3666b177b8fc"
42
42
  }
@@ -1,4 +1,4 @@
1
- export default function parsePotreeBin(
1
+ export function parsePotreeBin(
2
2
  arrayBuffer: ArrayBuffer,
3
3
  byteOffset: number,
4
4
  options: unknown,
@@ -54,10 +54,26 @@ Would have an index looking like this:
54
54
  | r36 | `0b00000000` (=0) | `1` |
55
55
  */
56
56
 
57
- // @ts-nocheck
57
+ /** @todo these types are an incorrect mess */
58
+ export type POTreeTileHeader = {
59
+ childCount: number;
60
+ name: string;
61
+ childMask: number;
62
+ };
63
+
64
+ /** @todo these types are an incorrect mess */
65
+ export type POTreeNode = {
66
+ header: POTreeTileHeader;
67
+ name: string;
68
+ pointCount: number;
69
+ children: POTreeNode[];
70
+ childrenByIndex: POTreeNode[];
71
+ };
72
+
73
+ // type POTreeTileNode = POTreeNode;
58
74
 
59
75
  // load hierarchy
60
- export default function parsePotreeHierarchyChunk(arrayBuffer: ArrayBuffer) {
76
+ export function parsePotreeHierarchyChunk(arrayBuffer: ArrayBuffer) {
61
77
  const tileHeaders = parseBinaryChunk(arrayBuffer);
62
78
  return buildHierarchy(tileHeaders);
63
79
  }
@@ -66,15 +82,16 @@ export default function parsePotreeHierarchyChunk(arrayBuffer: ArrayBuffer) {
66
82
  function parseBinaryChunk(arrayBuffer: ArrayBuffer, byteOffset = 0) {
67
83
  const dataView = new DataView(arrayBuffer);
68
84
 
69
- const stack = [];
85
+ const stack: POTreeNode[] = [];
70
86
 
71
87
  // Get root mask
72
- const topTileHeader = {};
88
+ // @ts-expect-error
89
+ const topTileHeader: POTreeNode = {};
73
90
  byteOffset = decodeRow(dataView, byteOffset, topTileHeader);
74
91
 
75
92
  stack.push(topTileHeader);
76
93
 
77
- const tileHeaders = [];
94
+ const tileHeaders: POTreeTileHeader[] = [];
78
95
 
79
96
  while (stack.length > 0) {
80
97
  const snode = stack.shift();
@@ -82,10 +99,12 @@ function parseBinaryChunk(arrayBuffer: ArrayBuffer, byteOffset = 0) {
82
99
 
83
100
  for (let i = 0; i < 8; i++) {
84
101
  if (snode && (snode.header.childMask & mask) !== 0) {
85
- const tileHeader = {};
102
+ // @ts-expect-error
103
+ const tileHeader: POTreeTileHeader = {};
86
104
  byteOffset = decodeRow(dataView, byteOffset, tileHeader);
87
105
  tileHeader.name = snode.name + i;
88
106
 
107
+ // @ts-expect-error
89
108
  stack.push(tileHeader);
90
109
  tileHeaders.push(tileHeader);
91
110
  snode.header.childCount++;
@@ -112,7 +131,7 @@ function decodeRow(dataView, byteOffset, tileHeader) {
112
131
  }
113
132
 
114
133
  // Resolves the binary rows into a hierarchy (tree structure)
115
- function buildHierarchy(tileHeaders, options = {}) {
134
+ function buildHierarchy(tileHeaders, options: {spacing?: number} = {}): POTreeNode {
116
135
  const DEFAULT_OPTIONS = {spacing: 100}; // TODO assert instead of default?
117
136
  options = {...DEFAULT_OPTIONS, ...options};
118
137
 
@@ -132,7 +151,7 @@ function buildHierarchy(tileHeaders, options = {}) {
132
151
  tileHeader.hasChildren = tileHeader.header.childCount;
133
152
  tileHeader.children = [];
134
153
  tileHeader.childrenByIndex = new Array(8).fill(null);
135
- tileHeader.spacing = options.spacing / Math.pow(2, level);
154
+ tileHeader.spacing = (options?.spacing || 0) / Math.pow(2, level);
136
155
  // tileHeader.boundingVolume = Utils.createChildAABB(parentNode.boundingBox, index);
137
156
 
138
157
  if (parentNode) {
@@ -1,11 +1,11 @@
1
1
  import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';
2
- import {default as parsePotreeBin} from './parsers/parse-potree-bin';
2
+ import {parsePotreeBin} from './parsers/parse-potree-bin';
3
3
 
4
4
  /**
5
5
  * Loader for potree Binary Point Attributes
6
6
  * */
7
7
  // @ts-ignore
8
- export const PotreeBinLoader: LoaderWithParser = {
8
+ export const PotreeBinLoader: LoaderWithParser<{}, never, LoaderOptions> = {
9
9
  name: 'potree Binary Point Attributes',
10
10
  id: 'potree',
11
11
  extensions: ['bin'],
@@ -16,7 +16,7 @@ export const PotreeBinLoader: LoaderWithParser = {
16
16
  binary: true
17
17
  };
18
18
 
19
- function parseSync(arrayBuffer: ArrayBuffer, options?: LoaderOptions) {
19
+ function parseSync(arrayBuffer: ArrayBuffer, options?: LoaderOptions): {} {
20
20
  const index = {};
21
21
  const byteOffset = 0;
22
22
  parsePotreeBin(arrayBuffer, byteOffset, options, index);
@@ -1,20 +1,19 @@
1
1
  import type {LoaderWithParser} from '@loaders.gl/loader-utils';
2
- import {default as parsePotreeHierarchyChunk} from './parsers/parse-potree-hierarchy-chunk';
2
+ import type {POTreeLoaderOptions} from './potree-loader';
3
+ import type {POTreeNode} from './parsers/parse-potree-hierarchy-chunk';
4
+ import {parsePotreeHierarchyChunk} from './parsers/parse-potree-hierarchy-chunk';
3
5
 
4
6
  /** Potree hierarchy chunk loader */
5
- // @ts-ignore
6
- export const PotreeHierarchyChunkLoader: LoaderWithParser = {
7
- id: 'potree',
8
- name: 'potree Hierarchy Chunk',
9
- extensions: ['hrc'],
10
- mimeTypes: ['application/octet-stream'],
11
- // binary potree files have no header bytes, no content test function possible
12
- // test: ['...'],
13
- parse: async (arrayBuffer, options) => await parseSync(arrayBuffer),
14
- parseSync,
15
- binary: true
16
- };
17
-
18
- function parseSync(arrayBuffer) {
19
- return parsePotreeHierarchyChunk(arrayBuffer);
20
- }
7
+ // @ts-ignore not a valid loader
8
+ export const PotreeHierarchyChunkLoader: LoaderWithParser<POTreeNode, never, POTreeLoaderOptions> =
9
+ {
10
+ id: 'potree',
11
+ name: 'potree Hierarchy Chunk',
12
+ extensions: ['hrc'],
13
+ mimeTypes: ['application/octet-stream'],
14
+ // binary potree files have no header bytes, no content test function possible
15
+ // test: ['...'],
16
+ parse: async (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),
17
+ parseSync: (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),
18
+ binary: true
19
+ };
@@ -1,12 +1,16 @@
1
- import type {LoaderWithParser} from '@loaders.gl/loader-utils';
1
+ import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';
2
2
 
3
3
  // __VERSION__ is injected by babel-plugin-version-inline
4
4
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
5
5
  const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
6
6
 
7
+ export type POTreeLoaderOptions = LoaderOptions & {
8
+ potree?: {};
9
+ };
10
+
7
11
  /** Potree loader */
8
12
  // @ts-ignore
9
- export const PotreeLoader: LoaderWithParser = {
13
+ export const PotreeLoader: LoaderWithParser<any, never, POTreeLoaderOptions> = {
10
14
  name: 'potree',
11
15
  id: 'potree',
12
16
  module: 'potree',
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
- };