@loaders.gl/potree 4.3.1 → 4.4.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +101 -45
- package/dist/dist.min.js +13 -13
- package/dist/index.cjs +10 -13
- package/dist/index.cjs.map +2 -2
- package/dist/lib/potree-node-source.d.ts +7 -16
- package/dist/lib/potree-node-source.d.ts.map +1 -1
- package/dist/lib/potree-node-source.js +5 -11
- package/dist/potree-hierarchy-chunk-loader.js +1 -1
- package/dist/potree-loader.js +1 -1
- package/dist/potree-source.d.ts +9 -6
- package/dist/potree-source.d.ts.map +1 -1
- package/dist/potree-source.js +4 -2
- package/package.json +6 -6
- package/src/lib/potree-node-source.ts +8 -21
- package/src/potree-source.ts +13 -6
package/dist/index.cjs
CHANGED
|
@@ -28,7 +28,7 @@ __export(dist_exports, {
|
|
|
28
28
|
module.exports = __toCommonJS(dist_exports);
|
|
29
29
|
|
|
30
30
|
// dist/potree-loader.js
|
|
31
|
-
var VERSION = true ? "4.
|
|
31
|
+
var VERSION = true ? "4.4.0-alpha.0" : "latest";
|
|
32
32
|
var PotreeLoader = {
|
|
33
33
|
dataType: null,
|
|
34
34
|
batchType: null,
|
|
@@ -113,7 +113,7 @@ function buildHierarchy(flatNodes, options = {}) {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
// dist/potree-hierarchy-chunk-loader.js
|
|
116
|
-
var VERSION2 = true ? "4.
|
|
116
|
+
var VERSION2 = true ? "4.4.0-alpha.0" : "latest";
|
|
117
117
|
var PotreeHierarchyChunkLoader = {
|
|
118
118
|
dataType: null,
|
|
119
119
|
batchType: null,
|
|
@@ -175,10 +175,6 @@ function parseVersion(version) {
|
|
|
175
175
|
var PotreeNodesSource = class extends import_loader_utils.DataSource {
|
|
176
176
|
/** Dataset base URL */
|
|
177
177
|
baseUrl = "";
|
|
178
|
-
/** Input data: string - dataset url, blob - single file data */
|
|
179
|
-
data;
|
|
180
|
-
/** Input props */
|
|
181
|
-
props;
|
|
182
178
|
/** Meta information from `cloud.js` */
|
|
183
179
|
metadata = null;
|
|
184
180
|
/** Root node */
|
|
@@ -190,12 +186,10 @@ var PotreeNodesSource = class extends import_loader_utils.DataSource {
|
|
|
190
186
|
* @constructor
|
|
191
187
|
* @param data - if string - data set path url or path to `cloud.js` metadata file
|
|
192
188
|
* - if Blob - single file data
|
|
193
|
-
* @param
|
|
189
|
+
* @param options - data source properties
|
|
194
190
|
*/
|
|
195
|
-
constructor(data,
|
|
196
|
-
super(
|
|
197
|
-
this.props = props;
|
|
198
|
-
this.data = data;
|
|
191
|
+
constructor(data, options) {
|
|
192
|
+
super(data, options);
|
|
199
193
|
this.makeBaseUrl(this.data);
|
|
200
194
|
this.initPromise = this.init();
|
|
201
195
|
}
|
|
@@ -307,11 +301,14 @@ var PotreeSource = {
|
|
|
307
301
|
version: VERSION3,
|
|
308
302
|
extensions: ["bin", "las", "laz"],
|
|
309
303
|
mimeTypes: ["application/octet-stream"],
|
|
310
|
-
options: { url: void 0, potree: {} },
|
|
311
304
|
type: "potree",
|
|
312
305
|
fromUrl: true,
|
|
313
306
|
fromBlob: true,
|
|
307
|
+
defaultOptions: {
|
|
308
|
+
potree: {}
|
|
309
|
+
},
|
|
314
310
|
testURL: (url) => url.endsWith(".js"),
|
|
315
|
-
createDataSource: (url,
|
|
311
|
+
createDataSource: (url, options) => new PotreeNodesSource(url, options)
|
|
312
|
+
// , PotreeNodesSource.defaultOptions)
|
|
316
313
|
};
|
|
317
314
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.js", "potree-loader.js", "parsers/parse-potree-hierarchy-chunk.js", "potree-hierarchy-chunk-loader.js", "parsers/parse-potree-bin.js", "potree-bin-loader.js", "lib/potree-node-source.js", "utils/parse-version.js", "potree-source.js"],
|
|
4
|
-
"sourcesContent": ["export { PotreeLoader } from \"./potree-loader.js\";\nexport { PotreeHierarchyChunkLoader } from \"./potree-hierarchy-chunk-loader.js\";\nexport { PotreeBinLoader } from \"./potree-bin-loader.js\";\nexport { PotreeSource } from \"./potree-source.js\";\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0\" !== 'undefined' ? \"4.3.0\" : 'latest';\n/** Potree loader */\nexport const PotreeLoader = {\n dataType: null,\n batchType: null,\n name: 'potree metadata',\n id: 'potree',\n module: 'potree',\n version: VERSION,\n extensions: ['js'],\n mimeTypes: ['application/json'],\n testText: (text) => text.indexOf('octreeDir') >= 0,\n parse: (data) => JSON.parse(new TextDecoder().decode(data)),\n parseTextSync: (text) => JSON.parse(text),\n options: {\n potree: {}\n }\n};\n", "// This file is derived from the Cesium code base under BSD 2-clause license\n// See LICENSE.md and https://github.com/potree/potree/blob/develop/LICENSE\n/**\n * load hierarchy\n * @param arrayBuffer - binary index data\n * @returns root node\n **/\nexport function parsePotreeHierarchyChunk(arrayBuffer) {\n const tileHeaders = parseBinaryChunk(arrayBuffer);\n return buildHierarchy(tileHeaders);\n}\n/**\n * Parses the binary rows\n * @param arrayBuffer - binary index data to parse\n * @param byteOffset - byte offset to start from\n * @returns flat nodes array\n * */\nfunction parseBinaryChunk(arrayBuffer, byteOffset = 0) {\n const dataView = new DataView(arrayBuffer);\n const stack = [];\n // Get root mask\n // @ts-expect-error\n const topTileHeader = {};\n byteOffset = decodeRow(dataView, byteOffset, topTileHeader);\n stack.push(topTileHeader);\n const tileHeaders = [topTileHeader];\n while (stack.length > 0) {\n const snode = stack.shift();\n let mask = 1;\n for (let i = 0; i < 8; i++) {\n if (snode && (snode.header.childMask & mask) !== 0) {\n // @ts-expect-error\n const tileHeader = {};\n byteOffset = decodeRow(dataView, byteOffset, tileHeader);\n tileHeader.name = snode.name + i;\n stack.push(tileHeader);\n tileHeaders.push(tileHeader);\n snode.header.childCount++;\n }\n mask = mask * 2;\n }\n if (byteOffset === dataView.byteLength) {\n break;\n }\n }\n return tileHeaders;\n}\n/**\n * Reads next row from binary index file\n * @param dataView - index data\n * @param byteOffset - current offset in the index data\n * @param tileHeader - container to read to\n * @returns new offset\n */\nfunction decodeRow(dataView, byteOffset, tileHeader) {\n tileHeader.header = tileHeader.header || {};\n tileHeader.header.childMask = dataView.getUint8(byteOffset);\n tileHeader.header.childCount = 0;\n tileHeader.pointCount = dataView.getUint32(byteOffset + 1, true);\n tileHeader.name = '';\n byteOffset += 5;\n return byteOffset;\n}\n/** Resolves the binary rows into a hierarchy (tree structure) */\nfunction buildHierarchy(flatNodes, options = {}) {\n const DEFAULT_OPTIONS = { spacing: 100 }; // TODO assert instead of default?\n options = { ...DEFAULT_OPTIONS, ...options };\n const topNode = flatNodes[0];\n const nodes = {};\n for (const node of flatNodes) {\n const { name } = node;\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 node.level = level;\n node.hasChildren = Boolean(node.header.childCount);\n node.children = [];\n node.childrenByIndex = new Array(8).fill(null);\n node.spacing = (options?.spacing || 0) / Math.pow(2, level);\n // tileHeader.boundingVolume = Utils.createChildAABB(parentNode.boundingBox, index);\n if (parentNode) {\n parentNode.children.push(node);\n parentNode.childrenByIndex[index] = node;\n }\n // Add the node to the map\n nodes[name] = node;\n }\n // First node is the root\n return topNode;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\nimport { parsePotreeHierarchyChunk } from \"./parsers/parse-potree-hierarchy-chunk.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0\" !== 'undefined' ? \"4.3.0\" : 'latest';\n/** Potree hierarchy chunk loader */\nexport const PotreeHierarchyChunkLoader = {\n dataType: null,\n batchType: null,\n name: 'potree Hierarchy Chunk',\n id: 'potree-hrc',\n module: 'potree',\n version: VERSION,\n extensions: ['hrc'],\n mimeTypes: ['application/octet-stream'],\n // binary potree files have no header bytes, no content test function possible\n // test: ['...'],\n parse: async (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),\n parseSync: (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),\n options: {\n potree: {}\n },\n binary: true\n};\n", "export function parsePotreeBin(arrayBuffer, byteOffset, options, index) {\n return null;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\nimport { parsePotreeBin } from \"./parsers/parse-potree-bin.js\";\n/**\n * Loader for potree Binary Point Attributes\n * */\nexport const PotreeBinLoader = {\n dataType: null,\n batchType: null,\n name: 'potree Binary Point Attributes',\n id: 'potree',\n extensions: ['bin'],\n mimeTypes: ['application/octet-stream'],\n // Unfortunately binary potree files have no header bytes, no test possible\n // test: ['...'],\n parseSync,\n binary: true,\n options: {}\n // @ts-ignore\n};\nfunction parseSync(arrayBuffer, options) {\n const index = {};\n const byteOffset = 0;\n parsePotreeBin(arrayBuffer, byteOffset, options, index);\n return index;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { load } from '@loaders.gl/core';\nimport { DataSource, resolvePath } from '@loaders.gl/loader-utils';\nimport { LASLoader } from '@loaders.gl/las';\nimport { PotreeHierarchyChunkLoader } from \"../potree-hierarchy-chunk-loader.js\";\nimport { PotreeLoader } from \"../potree-loader.js\";\nimport { parseVersion } from \"../utils/parse-version.js\";\n/**\n * A Potree data source\n * @version 1.0 - https://github.com/potree/potree/blob/1.0RC/docs/file_format.md\n * @version 1.7 - https://github.com/potree/potree/blob/1.7/docs/potree-file-format.md\n * @note Point cloud nodes tile source\n */\nexport class PotreeNodesSource extends DataSource {\n /** Dataset base URL */\n baseUrl = '';\n /** Input data: string - dataset url, blob - single file data */\n data;\n /** Input props */\n props;\n /** Meta information from `cloud.js` */\n metadata = null;\n /** Root node */\n root = null;\n /** Is data source ready to use after initial loading */\n isReady = false;\n initPromise = null;\n /**\n * @constructor\n * @param data - if string - data set path url or path to `cloud.js` metadata file\n * - if Blob - single file data\n * @param props - data source properties\n */\n constructor(data, props) {\n super(props);\n this.props = props;\n this.data = data;\n this.makeBaseUrl(this.data);\n this.initPromise = this.init();\n }\n /** Initial data source loading */\n async init() {\n if (this.initPromise) {\n await this.initPromise;\n return;\n }\n this.metadata = await load(`${this.baseUrl}/cloud.js`, PotreeLoader);\n await this.loadHierarchy();\n this.isReady = true;\n }\n /** Is data set supported */\n isSupported() {\n const { minor, major } = parseVersion(this.metadata?.version ?? '');\n return (this.isReady &&\n major === 1 &&\n minor <= 8 &&\n typeof this.metadata?.pointAttributes === 'string' &&\n ['LAS', 'LAZ'].includes(this.metadata?.pointAttributes));\n }\n /** Get content files extension */\n getContentExtension() {\n if (!this.isReady) {\n return null;\n }\n switch (this.metadata?.pointAttributes) {\n case 'LAS':\n return 'las';\n case 'LAZ':\n return 'laz';\n default:\n return 'bin';\n }\n }\n /**\n * Load octree node content\n * @param path array of numbers between 0-7 specifying successive octree divisions.\n * @return node content geometry or null if the node doesn't exist\n */\n async loadNodeContent(path) {\n await this.initPromise;\n if (!this.isSupported()) {\n return null;\n }\n const isAvailable = await this.isNodeAvailable(path);\n if (isAvailable) {\n return load(`${this.baseUrl}/${this.metadata?.octreeDir}/r/r${path.join('')}.${this.getContentExtension()}`, LASLoader);\n }\n return null;\n }\n /**\n * Check if a node exists in the octree\n * @param path array of numbers between 0-7 specifying successive octree divisions\n * @returns true - the node does exist, false - the nodes doesn't exist\n */\n async isNodeAvailable(path) {\n if (this.metadata?.hierarchy) {\n return this.metadata.hierarchy.findIndex((item) => item[0] === `r${path.join()}`) !== -1;\n }\n if (!this.root) {\n return false;\n }\n let currentParent = this.root;\n let name = '';\n let result = true;\n for (const nodeLevel of path) {\n const newName = `${name}${nodeLevel}`;\n const node = currentParent.children.find((child) => child.name === newName);\n if (node) {\n currentParent = node;\n name = newName;\n }\n else {\n result = false;\n break;\n }\n }\n return result;\n }\n /**\n * Load data source hierarchy into tree of available nodes\n */\n async loadHierarchy() {\n this.root = await load(`${this.baseUrl}/${this.metadata?.octreeDir}/r/r.hrc`, PotreeHierarchyChunkLoader);\n }\n /**\n * Deduce base url from the input url sring\n * @param data - data source input data\n */\n makeBaseUrl(data) {\n this.baseUrl = typeof data === 'string' ? resolvePath(data) : '';\n if (this.baseUrl.endsWith('cloud.js')) {\n this.baseUrl = this.baseUrl.substring(0, -8);\n }\n if (this.baseUrl.endsWith('/')) {\n this.baseUrl = this.baseUrl.substring(0, -1);\n }\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport function parseVersion(version) {\n const parts = version.split('.').map(Number);\n return { major: parts[0], minor: parts[1] };\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { PotreeNodesSource } from \"./lib/potree-node-source.js\";\nconst VERSION = '1.7';\n/**\n * Creates point cloud data sources for Potree urls\n */\nexport const PotreeSource = {\n name: 'Potree',\n id: 'potree',\n module: 'potree',\n version: VERSION,\n extensions: ['bin', 'las', 'laz'],\n mimeTypes: ['application/octet-stream'],\n options: { url: undefined, potree: {} },\n type: 'potree',\n fromUrl: true,\n fromBlob: true,\n testURL: (url) => url.endsWith('.js'),\n createDataSource: (url, props) => new PotreeNodesSource(url, props)\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,IAAM,UAAU,
|
|
4
|
+
"sourcesContent": ["export { PotreeLoader } from \"./potree-loader.js\";\nexport { PotreeHierarchyChunkLoader } from \"./potree-hierarchy-chunk-loader.js\";\nexport { PotreeBinLoader } from \"./potree-bin-loader.js\";\nexport { PotreeSource } from \"./potree-source.js\";\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.4.0-alpha.0\" !== 'undefined' ? \"4.4.0-alpha.0\" : 'latest';\n/** Potree loader */\nexport const PotreeLoader = {\n dataType: null,\n batchType: null,\n name: 'potree metadata',\n id: 'potree',\n module: 'potree',\n version: VERSION,\n extensions: ['js'],\n mimeTypes: ['application/json'],\n testText: (text) => text.indexOf('octreeDir') >= 0,\n parse: (data) => JSON.parse(new TextDecoder().decode(data)),\n parseTextSync: (text) => JSON.parse(text),\n options: {\n potree: {}\n }\n};\n", "// This file is derived from the Cesium code base under BSD 2-clause license\n// See LICENSE.md and https://github.com/potree/potree/blob/develop/LICENSE\n/**\n * load hierarchy\n * @param arrayBuffer - binary index data\n * @returns root node\n **/\nexport function parsePotreeHierarchyChunk(arrayBuffer) {\n const tileHeaders = parseBinaryChunk(arrayBuffer);\n return buildHierarchy(tileHeaders);\n}\n/**\n * Parses the binary rows\n * @param arrayBuffer - binary index data to parse\n * @param byteOffset - byte offset to start from\n * @returns flat nodes array\n * */\nfunction parseBinaryChunk(arrayBuffer, byteOffset = 0) {\n const dataView = new DataView(arrayBuffer);\n const stack = [];\n // Get root mask\n // @ts-expect-error\n const topTileHeader = {};\n byteOffset = decodeRow(dataView, byteOffset, topTileHeader);\n stack.push(topTileHeader);\n const tileHeaders = [topTileHeader];\n while (stack.length > 0) {\n const snode = stack.shift();\n let mask = 1;\n for (let i = 0; i < 8; i++) {\n if (snode && (snode.header.childMask & mask) !== 0) {\n // @ts-expect-error\n const tileHeader = {};\n byteOffset = decodeRow(dataView, byteOffset, tileHeader);\n tileHeader.name = snode.name + i;\n stack.push(tileHeader);\n tileHeaders.push(tileHeader);\n snode.header.childCount++;\n }\n mask = mask * 2;\n }\n if (byteOffset === dataView.byteLength) {\n break;\n }\n }\n return tileHeaders;\n}\n/**\n * Reads next row from binary index file\n * @param dataView - index data\n * @param byteOffset - current offset in the index data\n * @param tileHeader - container to read to\n * @returns new offset\n */\nfunction decodeRow(dataView, byteOffset, tileHeader) {\n tileHeader.header = tileHeader.header || {};\n tileHeader.header.childMask = dataView.getUint8(byteOffset);\n tileHeader.header.childCount = 0;\n tileHeader.pointCount = dataView.getUint32(byteOffset + 1, true);\n tileHeader.name = '';\n byteOffset += 5;\n return byteOffset;\n}\n/** Resolves the binary rows into a hierarchy (tree structure) */\nfunction buildHierarchy(flatNodes, options = {}) {\n const DEFAULT_OPTIONS = { spacing: 100 }; // TODO assert instead of default?\n options = { ...DEFAULT_OPTIONS, ...options };\n const topNode = flatNodes[0];\n const nodes = {};\n for (const node of flatNodes) {\n const { name } = node;\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 node.level = level;\n node.hasChildren = Boolean(node.header.childCount);\n node.children = [];\n node.childrenByIndex = new Array(8).fill(null);\n node.spacing = (options?.spacing || 0) / Math.pow(2, level);\n // tileHeader.boundingVolume = Utils.createChildAABB(parentNode.boundingBox, index);\n if (parentNode) {\n parentNode.children.push(node);\n parentNode.childrenByIndex[index] = node;\n }\n // Add the node to the map\n nodes[name] = node;\n }\n // First node is the root\n return topNode;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\nimport { parsePotreeHierarchyChunk } from \"./parsers/parse-potree-hierarchy-chunk.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.4.0-alpha.0\" !== 'undefined' ? \"4.4.0-alpha.0\" : 'latest';\n/** Potree hierarchy chunk loader */\nexport const PotreeHierarchyChunkLoader = {\n dataType: null,\n batchType: null,\n name: 'potree Hierarchy Chunk',\n id: 'potree-hrc',\n module: 'potree',\n version: VERSION,\n extensions: ['hrc'],\n mimeTypes: ['application/octet-stream'],\n // binary potree files have no header bytes, no content test function possible\n // test: ['...'],\n parse: async (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),\n parseSync: (arrayBuffer, options) => parsePotreeHierarchyChunk(arrayBuffer),\n options: {\n potree: {}\n },\n binary: true\n};\n", "export function parsePotreeBin(arrayBuffer, byteOffset, options, index) {\n return null;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\nimport { parsePotreeBin } from \"./parsers/parse-potree-bin.js\";\n/**\n * Loader for potree Binary Point Attributes\n * */\nexport const PotreeBinLoader = {\n dataType: null,\n batchType: null,\n name: 'potree Binary Point Attributes',\n id: 'potree',\n extensions: ['bin'],\n mimeTypes: ['application/octet-stream'],\n // Unfortunately binary potree files have no header bytes, no test possible\n // test: ['...'],\n parseSync,\n binary: true,\n options: {}\n // @ts-ignore\n};\nfunction parseSync(arrayBuffer, options) {\n const index = {};\n const byteOffset = 0;\n parsePotreeBin(arrayBuffer, byteOffset, options, index);\n return index;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { load } from '@loaders.gl/core';\nimport { DataSource, resolvePath } from '@loaders.gl/loader-utils';\nimport { LASLoader } from '@loaders.gl/las';\nimport { PotreeHierarchyChunkLoader } from \"../potree-hierarchy-chunk-loader.js\";\nimport { PotreeLoader } from \"../potree-loader.js\";\nimport { parseVersion } from \"../utils/parse-version.js\";\n/**\n * A Potree data source\n * @version 1.0 - @see https://github.com/potree/potree/blob/1.0RC/docs/file_format.md\n * @version 1.7 - @see https://github.com/potree/potree/blob/1.7/docs/potree-file-format.md\n * @note Point cloud nodes tile source\n */\nexport class PotreeNodesSource extends DataSource {\n /** Dataset base URL */\n baseUrl = '';\n /** Meta information from `cloud.js` */\n metadata = null;\n /** Root node */\n root = null;\n /** Is data source ready to use after initial loading */\n isReady = false;\n initPromise = null;\n /**\n * @constructor\n * @param data - if string - data set path url or path to `cloud.js` metadata file\n * - if Blob - single file data\n * @param options - data source properties\n */\n constructor(data, options) {\n super(data, options);\n this.makeBaseUrl(this.data);\n this.initPromise = this.init();\n }\n /** Initial data source loading */\n async init() {\n if (this.initPromise) {\n await this.initPromise;\n return;\n }\n this.metadata = await load(`${this.baseUrl}/cloud.js`, PotreeLoader);\n await this.loadHierarchy();\n this.isReady = true;\n }\n /** Is data set supported */\n isSupported() {\n const { minor, major } = parseVersion(this.metadata?.version ?? '');\n return (this.isReady &&\n major === 1 &&\n minor <= 8 &&\n typeof this.metadata?.pointAttributes === 'string' &&\n ['LAS', 'LAZ'].includes(this.metadata?.pointAttributes));\n }\n /** Get content files extension */\n getContentExtension() {\n if (!this.isReady) {\n return null;\n }\n switch (this.metadata?.pointAttributes) {\n case 'LAS':\n return 'las';\n case 'LAZ':\n return 'laz';\n default:\n return 'bin';\n }\n }\n /**\n * Load octree node content\n * @param path array of numbers between 0-7 specifying successive octree divisions.\n * @return node content geometry or null if the node doesn't exist\n */\n async loadNodeContent(path) {\n await this.initPromise;\n if (!this.isSupported()) {\n return null;\n }\n const isAvailable = await this.isNodeAvailable(path);\n if (isAvailable) {\n return load(`${this.baseUrl}/${this.metadata?.octreeDir}/r/r${path.join('')}.${this.getContentExtension()}`, LASLoader);\n }\n return null;\n }\n /**\n * Check if a node exists in the octree\n * @param path array of numbers between 0-7 specifying successive octree divisions\n * @returns true - the node does exist, false - the nodes doesn't exist\n */\n async isNodeAvailable(path) {\n if (this.metadata?.hierarchy) {\n return this.metadata.hierarchy.findIndex((item) => item[0] === `r${path.join()}`) !== -1;\n }\n if (!this.root) {\n return false;\n }\n let currentParent = this.root;\n let name = '';\n let result = true;\n for (const nodeLevel of path) {\n const newName = `${name}${nodeLevel}`;\n const node = currentParent.children.find((child) => child.name === newName);\n if (node) {\n currentParent = node;\n name = newName;\n }\n else {\n result = false;\n break;\n }\n }\n return result;\n }\n /**\n * Load data source hierarchy into tree of available nodes\n */\n async loadHierarchy() {\n this.root = await load(`${this.baseUrl}/${this.metadata?.octreeDir}/r/r.hrc`, PotreeHierarchyChunkLoader);\n }\n /**\n * Deduce base url from the input url sring\n * @param data - data source input data\n */\n makeBaseUrl(data) {\n this.baseUrl = typeof data === 'string' ? resolvePath(data) : '';\n if (this.baseUrl.endsWith('cloud.js')) {\n this.baseUrl = this.baseUrl.substring(0, -8);\n }\n if (this.baseUrl.endsWith('/')) {\n this.baseUrl = this.baseUrl.substring(0, -1);\n }\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport function parseVersion(version) {\n const parts = version.split('.').map(Number);\n return { major: parts[0], minor: parts[1] };\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { PotreeNodesSource } from \"./lib/potree-node-source.js\";\nconst VERSION = '1.7';\n/**\n * Creates point cloud data sources for Potree urls\n */\nexport const PotreeSource = {\n name: 'Potree',\n id: 'potree',\n module: 'potree',\n version: VERSION,\n extensions: ['bin', 'las', 'laz'],\n mimeTypes: ['application/octet-stream'],\n type: 'potree',\n fromUrl: true,\n fromBlob: true,\n defaultOptions: {\n potree: {}\n },\n testURL: (url) => url.endsWith('.js'),\n createDataSource: (url, options) => new PotreeNodesSource(url, options) // , PotreeNodesSource.defaultOptions)\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,IAAM,UAAU,OAAyC,kBAAkB;AAEpE,IAAM,eAAe;AAAA,EACxB,UAAU;AAAA,EACV,WAAW;AAAA,EACX,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,YAAY,CAAC,IAAI;AAAA,EACjB,WAAW,CAAC,kBAAkB;AAAA,EAC9B,UAAU,CAAC,SAAS,KAAK,QAAQ,WAAW,KAAK;AAAA,EACjD,O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O;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAIA,MAAM,gBAAgB;AArH1B;AAsHQ,SAAK,OAAO,UAAM,kBAAK,GAAG,KAAK,YAAW,UAAK,aAAL,mBAAe,qBAAqB,0BAA0B;AAAA,EAC5G;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,YAAY,MAAM;AACd,SAAK,UAAU,OAAO,SAAS,eAAW,iCAAY,IAAI,IAAI;AAC9D,QAAI,KAAK,QAAQ,SAAS,UAAU,GAAG;AACnC,WAAK,UAAU,KAAK,QAAQ,UAAU,GAAG,EAAE;AAAA,IAC/C;AACA,QAAI,KAAK,QAAQ,SAAS,GAAG,GAAG;AAC5B,WAAK,UAAU,KAAK,QAAQ,UAAU,GAAG,EAAE;AAAA,IAC/C;AAAA,EACJ;AACJ;;;AEjIA,IAAMC,WAAU;AAIT,IAAM,eAAe;AAAA,EACxB,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,SAASA;AAAA,EACT,YAAY,CAAC,OAAO,OAAO,KAAK;AAAA,EAChC,WAAW,CAAC,0BAA0B;AAAA,EACtC,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU;AAAA,EACV,gBAAgB;AAAA,IACZ,QAAQ,CAAC;AAAA,EACb;AAAA,EACA,SAAS,CAAC,QAAQ,IAAI,SAAS,KAAK;AAAA,EACpC,kBAAkB,CAAC,KAAK,YAAY,IAAI,kBAAkB,KAAK,OAAO;AAAA;AAC1E;",
|
|
6
6
|
"names": ["VERSION", "VERSION"]
|
|
7
7
|
}
|
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
import { Mesh } from '@loaders.gl/schema';
|
|
2
|
-
import { DataSource
|
|
2
|
+
import { DataSource } from '@loaders.gl/loader-utils';
|
|
3
3
|
import { PotreeMetadata } from "../types/potree-metadata.js";
|
|
4
4
|
import { POTreeNode } from "../parsers/parse-potree-hierarchy-chunk.js";
|
|
5
|
-
|
|
6
|
-
attributions?: string[];
|
|
7
|
-
potree?: {
|
|
8
|
-
loadOptions?: LoaderOptions;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
5
|
+
import type { PotreeSourceOptions } from "../potree-source.js";
|
|
11
6
|
/**
|
|
12
7
|
* A Potree data source
|
|
13
|
-
* @version 1.0 - https://github.com/potree/potree/blob/1.0RC/docs/file_format.md
|
|
14
|
-
* @version 1.7 - https://github.com/potree/potree/blob/1.7/docs/potree-file-format.md
|
|
8
|
+
* @version 1.0 - @see https://github.com/potree/potree/blob/1.0RC/docs/file_format.md
|
|
9
|
+
* @version 1.7 - @see https://github.com/potree/potree/blob/1.7/docs/potree-file-format.md
|
|
15
10
|
* @note Point cloud nodes tile source
|
|
16
11
|
*/
|
|
17
|
-
export declare class PotreeNodesSource extends DataSource {
|
|
12
|
+
export declare class PotreeNodesSource extends DataSource<string, PotreeSourceOptions> {
|
|
18
13
|
/** Dataset base URL */
|
|
19
14
|
baseUrl: string;
|
|
20
|
-
/** Input data: string - dataset url, blob - single file data */
|
|
21
|
-
data: string | Blob;
|
|
22
|
-
/** Input props */
|
|
23
|
-
props: PotreeNodesSourceProps;
|
|
24
15
|
/** Meta information from `cloud.js` */
|
|
25
16
|
metadata: PotreeMetadata | null;
|
|
26
17
|
/** Root node */
|
|
@@ -32,9 +23,9 @@ export declare class PotreeNodesSource extends DataSource {
|
|
|
32
23
|
* @constructor
|
|
33
24
|
* @param data - if string - data set path url or path to `cloud.js` metadata file
|
|
34
25
|
* - if Blob - single file data
|
|
35
|
-
* @param
|
|
26
|
+
* @param options - data source properties
|
|
36
27
|
*/
|
|
37
|
-
constructor(data: string
|
|
28
|
+
constructor(data: string, options: PotreeSourceOptions);
|
|
38
29
|
/** Initial data source loading */
|
|
39
30
|
init(): Promise<void>;
|
|
40
31
|
/** Is data set supported */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"potree-node-source.d.ts","sourceRoot":"","sources":["../../src/lib/potree-node-source.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,IAAI,EAAC,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"potree-node-source.d.ts","sourceRoot":"","sources":["../../src/lib/potree-node-source.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,IAAI,EAAC,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAC,UAAU,EAAc,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAC,cAAc,EAAC,oCAAiC;AACxD,OAAO,EAAC,UAAU,EAAC,mDAAgD;AAInE,OAAO,KAAK,EAAC,mBAAmB,EAAC,4BAAyB;AAE1D;;;;;GAKG;AACH,qBAAa,iBAAkB,SAAQ,UAAU,CAAC,MAAM,EAAE,mBAAmB,CAAC;IAC5E,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAM;IACrB,uCAAuC;IACvC,QAAQ,EAAE,cAAc,GAAG,IAAI,CAAQ;IACvC,gBAAgB;IAChB,IAAI,EAAE,UAAU,GAAG,IAAI,CAAQ;IAC/B,wDAAwD;IACxD,OAAO,UAAS;IAEhB,OAAO,CAAC,WAAW,CAA8B;IAEjD;;;;;OAKG;gBACS,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB;IAOtD,kCAAkC;IAC5B,IAAI;IAUV,4BAA4B;IAC5B,WAAW,IAAI,OAAO;IAWtB,kCAAkC;IAClC,mBAAmB,IAAI,MAAM,GAAG,IAAI;IAcpC;;;;OAIG;IACG,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAmB3D;;;;OAIG;IACG,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAyBvD;;OAEG;YACW,aAAa;IAO3B;;;OAGG;IACH,OAAO,CAAC,WAAW;CASpB"}
|
|
@@ -9,17 +9,13 @@ import { PotreeLoader } from "../potree-loader.js";
|
|
|
9
9
|
import { parseVersion } from "../utils/parse-version.js";
|
|
10
10
|
/**
|
|
11
11
|
* A Potree data source
|
|
12
|
-
* @version 1.0 - https://github.com/potree/potree/blob/1.0RC/docs/file_format.md
|
|
13
|
-
* @version 1.7 - https://github.com/potree/potree/blob/1.7/docs/potree-file-format.md
|
|
12
|
+
* @version 1.0 - @see https://github.com/potree/potree/blob/1.0RC/docs/file_format.md
|
|
13
|
+
* @version 1.7 - @see https://github.com/potree/potree/blob/1.7/docs/potree-file-format.md
|
|
14
14
|
* @note Point cloud nodes tile source
|
|
15
15
|
*/
|
|
16
16
|
export class PotreeNodesSource extends DataSource {
|
|
17
17
|
/** Dataset base URL */
|
|
18
18
|
baseUrl = '';
|
|
19
|
-
/** Input data: string - dataset url, blob - single file data */
|
|
20
|
-
data;
|
|
21
|
-
/** Input props */
|
|
22
|
-
props;
|
|
23
19
|
/** Meta information from `cloud.js` */
|
|
24
20
|
metadata = null;
|
|
25
21
|
/** Root node */
|
|
@@ -31,12 +27,10 @@ export class PotreeNodesSource extends DataSource {
|
|
|
31
27
|
* @constructor
|
|
32
28
|
* @param data - if string - data set path url or path to `cloud.js` metadata file
|
|
33
29
|
* - if Blob - single file data
|
|
34
|
-
* @param
|
|
30
|
+
* @param options - data source properties
|
|
35
31
|
*/
|
|
36
|
-
constructor(data,
|
|
37
|
-
super(
|
|
38
|
-
this.props = props;
|
|
39
|
-
this.data = data;
|
|
32
|
+
constructor(data, options) {
|
|
33
|
+
super(data, options);
|
|
40
34
|
this.makeBaseUrl(this.data);
|
|
41
35
|
this.initPromise = this.init();
|
|
42
36
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { parsePotreeHierarchyChunk } from "./parsers/parse-potree-hierarchy-chunk.js";
|
|
5
5
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
6
6
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
7
|
-
const VERSION = typeof "4.
|
|
7
|
+
const VERSION = typeof "4.4.0-alpha.0" !== 'undefined' ? "4.4.0-alpha.0" : 'latest';
|
|
8
8
|
/** Potree hierarchy chunk loader */
|
|
9
9
|
export const PotreeHierarchyChunkLoader = {
|
|
10
10
|
dataType: null,
|
package/dist/potree-loader.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright vis.gl contributors
|
|
4
4
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
5
5
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
6
|
-
const VERSION = typeof "4.
|
|
6
|
+
const VERSION = typeof "4.4.0-alpha.0" !== 'undefined' ? "4.4.0-alpha.0" : 'latest';
|
|
7
7
|
/** Potree loader */
|
|
8
8
|
export const PotreeLoader = {
|
|
9
9
|
dataType: null,
|
package/dist/potree-source.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DataSourceOptions } from '@loaders.gl/loader-utils';
|
|
2
|
+
import { PotreeNodesSource } from "./lib/potree-node-source.js";
|
|
3
|
+
export type PotreeSourceOptions = DataSourceOptions & {
|
|
4
|
+
potree?: {};
|
|
5
|
+
};
|
|
2
6
|
/**
|
|
3
7
|
* Creates point cloud data sources for Potree urls
|
|
4
8
|
*/
|
|
@@ -9,14 +13,13 @@ export declare const PotreeSource: {
|
|
|
9
13
|
readonly version: "1.7";
|
|
10
14
|
readonly extensions: ["bin", "las", "laz"];
|
|
11
15
|
readonly mimeTypes: ["application/octet-stream"];
|
|
12
|
-
readonly options: {
|
|
13
|
-
readonly url: never;
|
|
14
|
-
readonly potree: {};
|
|
15
|
-
};
|
|
16
16
|
readonly type: "potree";
|
|
17
17
|
readonly fromUrl: true;
|
|
18
18
|
readonly fromBlob: true;
|
|
19
|
+
readonly defaultOptions: {
|
|
20
|
+
readonly potree: {};
|
|
21
|
+
};
|
|
19
22
|
readonly testURL: (url: string) => boolean;
|
|
20
|
-
readonly createDataSource: (url: string
|
|
23
|
+
readonly createDataSource: (url: string, options: PotreeSourceOptions) => PotreeNodesSource;
|
|
21
24
|
};
|
|
22
25
|
//# sourceMappingURL=potree-source.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"potree-source.d.ts","sourceRoot":"","sources":["../src/potree-source.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"potree-source.d.ts","sourceRoot":"","sources":["../src/potree-source.ts"],"names":[],"mappings":"AAIA,OAAO,EAAS,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAC,iBAAiB,EAAC,oCAAiC;AAI3D,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAAG;IACpD,MAAM,CAAC,EAAE,EAAE,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;4BAeR,MAAM;qCACG,MAAM,WAAW,mBAAmB;CAEhB,CAAC"}
|
package/dist/potree-source.js
CHANGED
|
@@ -13,10 +13,12 @@ export const PotreeSource = {
|
|
|
13
13
|
version: VERSION,
|
|
14
14
|
extensions: ['bin', 'las', 'laz'],
|
|
15
15
|
mimeTypes: ['application/octet-stream'],
|
|
16
|
-
options: { url: undefined, potree: {} },
|
|
17
16
|
type: 'potree',
|
|
18
17
|
fromUrl: true,
|
|
19
18
|
fromBlob: true,
|
|
19
|
+
defaultOptions: {
|
|
20
|
+
potree: {}
|
|
21
|
+
},
|
|
20
22
|
testURL: (url) => url.endsWith('.js'),
|
|
21
|
-
createDataSource: (url,
|
|
23
|
+
createDataSource: (url, options) => new PotreeNodesSource(url, options) // , PotreeNodesSource.defaultOptions)
|
|
22
24
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/potree",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0-alpha.1",
|
|
4
4
|
"description": "potree loaders for large point clouds.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
"build-bundle-dev": "ocular-bundle ./bundle.ts --env=dev --output=dist/dist.dev.js"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@loaders.gl/las": "4.
|
|
48
|
-
"@loaders.gl/math": "4.
|
|
49
|
-
"@loaders.gl/schema": "4.
|
|
47
|
+
"@loaders.gl/las": "4.4.0-alpha.1",
|
|
48
|
+
"@loaders.gl/math": "4.4.0-alpha.1",
|
|
49
|
+
"@loaders.gl/schema": "4.4.0-alpha.1",
|
|
50
50
|
"@math.gl/core": "^4.1.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@loaders.gl/core": "
|
|
53
|
+
"@loaders.gl/core": "4.4.0-alpha.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "f1732de45907bd500bf4eedb4803beca8bf4bfb0"
|
|
56
56
|
}
|
|
@@ -4,35 +4,24 @@
|
|
|
4
4
|
|
|
5
5
|
import {load} from '@loaders.gl/core';
|
|
6
6
|
import {Mesh} from '@loaders.gl/schema';
|
|
7
|
-
import {DataSource,
|
|
7
|
+
import {DataSource, resolvePath} from '@loaders.gl/loader-utils';
|
|
8
8
|
import {LASLoader} from '@loaders.gl/las';
|
|
9
9
|
import {PotreeMetadata} from '../types/potree-metadata';
|
|
10
10
|
import {POTreeNode} from '../parsers/parse-potree-hierarchy-chunk';
|
|
11
11
|
import {PotreeHierarchyChunkLoader} from '../potree-hierarchy-chunk-loader';
|
|
12
12
|
import {PotreeLoader} from '../potree-loader';
|
|
13
13
|
import {parseVersion} from '../utils/parse-version';
|
|
14
|
-
|
|
15
|
-
export type PotreeNodesSourceProps = DataSourceProps & {
|
|
16
|
-
attributions?: string[];
|
|
17
|
-
potree?: {
|
|
18
|
-
loadOptions?: LoaderOptions; // PotreeLoaderOptions;
|
|
19
|
-
// TODO - add options here
|
|
20
|
-
};
|
|
21
|
-
};
|
|
14
|
+
import type {PotreeSourceOptions} from '../potree-source';
|
|
22
15
|
|
|
23
16
|
/**
|
|
24
17
|
* A Potree data source
|
|
25
|
-
* @version 1.0 - https://github.com/potree/potree/blob/1.0RC/docs/file_format.md
|
|
26
|
-
* @version 1.7 - https://github.com/potree/potree/blob/1.7/docs/potree-file-format.md
|
|
18
|
+
* @version 1.0 - @see https://github.com/potree/potree/blob/1.0RC/docs/file_format.md
|
|
19
|
+
* @version 1.7 - @see https://github.com/potree/potree/blob/1.7/docs/potree-file-format.md
|
|
27
20
|
* @note Point cloud nodes tile source
|
|
28
21
|
*/
|
|
29
|
-
export class PotreeNodesSource extends DataSource {
|
|
22
|
+
export class PotreeNodesSource extends DataSource<string, PotreeSourceOptions> {
|
|
30
23
|
/** Dataset base URL */
|
|
31
24
|
baseUrl: string = '';
|
|
32
|
-
/** Input data: string - dataset url, blob - single file data */
|
|
33
|
-
data: string | Blob;
|
|
34
|
-
/** Input props */
|
|
35
|
-
props: PotreeNodesSourceProps;
|
|
36
25
|
/** Meta information from `cloud.js` */
|
|
37
26
|
metadata: PotreeMetadata | null = null;
|
|
38
27
|
/** Root node */
|
|
@@ -46,12 +35,10 @@ export class PotreeNodesSource extends DataSource {
|
|
|
46
35
|
* @constructor
|
|
47
36
|
* @param data - if string - data set path url or path to `cloud.js` metadata file
|
|
48
37
|
* - if Blob - single file data
|
|
49
|
-
* @param
|
|
38
|
+
* @param options - data source properties
|
|
50
39
|
*/
|
|
51
|
-
constructor(data: string
|
|
52
|
-
super(
|
|
53
|
-
this.props = props;
|
|
54
|
-
this.data = data;
|
|
40
|
+
constructor(data: string, options: PotreeSourceOptions) {
|
|
41
|
+
super(data, options);
|
|
55
42
|
this.makeBaseUrl(this.data);
|
|
56
43
|
|
|
57
44
|
this.initPromise = this.init();
|
package/src/potree-source.ts
CHANGED
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {Source} from '@loaders.gl/loader-utils';
|
|
6
|
-
import {PotreeNodesSource
|
|
5
|
+
import {Source, DataSourceOptions} from '@loaders.gl/loader-utils';
|
|
6
|
+
import {PotreeNodesSource} from './lib/potree-node-source';
|
|
7
7
|
|
|
8
8
|
const VERSION = '1.7';
|
|
9
9
|
|
|
10
|
+
export type PotreeSourceOptions = DataSourceOptions & {
|
|
11
|
+
potree?: {};
|
|
12
|
+
};
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* Creates point cloud data sources for Potree urls
|
|
12
16
|
*/
|
|
@@ -17,12 +21,15 @@ export const PotreeSource = {
|
|
|
17
21
|
version: VERSION,
|
|
18
22
|
extensions: ['bin', 'las', 'laz'],
|
|
19
23
|
mimeTypes: ['application/octet-stream'],
|
|
20
|
-
options: {url: undefined!, potree: {}},
|
|
21
24
|
type: 'potree',
|
|
22
25
|
fromUrl: true,
|
|
23
26
|
fromBlob: true,
|
|
24
27
|
|
|
28
|
+
defaultOptions: {
|
|
29
|
+
potree: {}
|
|
30
|
+
},
|
|
31
|
+
|
|
25
32
|
testURL: (url: string) => url.endsWith('.js'),
|
|
26
|
-
createDataSource: (url: string
|
|
27
|
-
new PotreeNodesSource(url,
|
|
28
|
-
} as const satisfies Source<PotreeNodesSource
|
|
33
|
+
createDataSource: (url: string, options: PotreeSourceOptions) =>
|
|
34
|
+
new PotreeNodesSource(url, options) // , PotreeNodesSource.defaultOptions)
|
|
35
|
+
} as const satisfies Source<PotreeNodesSource>;
|