@manycore/aholo-splat-transform 1.2.6
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/CHANGELOG.md +102 -0
- package/README.md +33 -0
- package/bin/cli.js +118 -0
- package/dist/SplatData.d.ts +67 -0
- package/dist/SplatData.js +156 -0
- package/dist/constant.d.ts +3 -0
- package/dist/constant.js +13 -0
- package/dist/file/IFile.d.ts +5 -0
- package/dist/file/IFile.js +1 -0
- package/dist/file/index.d.ts +7 -0
- package/dist/file/index.js +6 -0
- package/dist/file/ksplat.d.ts +12 -0
- package/dist/file/ksplat.js +232 -0
- package/dist/file/lcc.d.ts +11 -0
- package/dist/file/lcc.js +157 -0
- package/dist/file/ply.d.ts +13 -0
- package/dist/file/ply.js +388 -0
- package/dist/file/sog.d.ts +80 -0
- package/dist/file/sog.js +504 -0
- package/dist/file/splat.d.ts +6 -0
- package/dist/file/splat.js +99 -0
- package/dist/file/spz.d.ts +8 -0
- package/dist/file/spz.js +400 -0
- package/dist/file/voxel.d.ts +37 -0
- package/dist/file/voxel.js +280 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +54 -0
- package/dist/native/cpp/bin/linux/binding.node +0 -0
- package/dist/native/cpp/bin/windows/binding.node +0 -0
- package/dist/native/index.d.ts +54 -0
- package/dist/native/index.js +128 -0
- package/dist/tasks/AutoChunkLodTask.d.ts +13 -0
- package/dist/tasks/AutoChunkLodTask.js +117 -0
- package/dist/tasks/AutoLodTask.d.ts +10 -0
- package/dist/tasks/AutoLodTask.js +20 -0
- package/dist/tasks/BaseTask.d.ts +15 -0
- package/dist/tasks/BaseTask.js +5 -0
- package/dist/tasks/FlexLodTask.d.ts +12 -0
- package/dist/tasks/FlexLodTask.js +44 -0
- package/dist/tasks/ModifyTask.d.ts +9 -0
- package/dist/tasks/ModifyTask.js +156 -0
- package/dist/tasks/ReadTask.d.ts +8 -0
- package/dist/tasks/ReadTask.js +29 -0
- package/dist/tasks/SkeletonLodTask.d.ts +10 -0
- package/dist/tasks/SkeletonLodTask.js +156 -0
- package/dist/tasks/VoxelTask.d.ts +30 -0
- package/dist/tasks/VoxelTask.js +37 -0
- package/dist/tasks/WriteTask.d.ts +11 -0
- package/dist/tasks/WriteTask.js +70 -0
- package/dist/utils/BufferReader.d.ts +12 -0
- package/dist/utils/BufferReader.js +47 -0
- package/dist/utils/Logger.d.ts +11 -0
- package/dist/utils/Logger.js +38 -0
- package/dist/utils/StreamChunkDecoder.d.ts +16 -0
- package/dist/utils/StreamChunkDecoder.js +36 -0
- package/dist/utils/index.d.ts +27 -0
- package/dist/utils/index.js +101 -0
- package/dist/utils/k-means.d.ts +4 -0
- package/dist/utils/k-means.js +350 -0
- package/dist/utils/math.d.ts +46 -0
- package/dist/utils/math.js +351 -0
- package/dist/utils/quantize-1d.d.ts +4 -0
- package/dist/utils/quantize-1d.js +164 -0
- package/dist/utils/sh-rotate.d.ts +2 -0
- package/dist/utils/sh-rotate.js +175 -0
- package/dist/utils/splat.d.ts +20 -0
- package/dist/utils/splat.js +378 -0
- package/dist/utils/voxel/common.d.ts +162 -0
- package/dist/utils/voxel/common.js +1700 -0
- package/dist/utils/voxel/coplanar-merge.d.ts +63 -0
- package/dist/utils/voxel/coplanar-merge.js +819 -0
- package/dist/utils/voxel/gpu-dilation.d.ts +2 -0
- package/dist/utils/voxel/gpu-dilation.js +665 -0
- package/dist/utils/voxel/marching-cubes.d.ts +42 -0
- package/dist/utils/voxel/marching-cubes.js +1657 -0
- package/dist/utils/voxel/mesh.d.ts +3 -0
- package/dist/utils/voxel/mesh.js +130 -0
- package/dist/utils/voxel/nav.d.ts +29 -0
- package/dist/utils/voxel/nav.js +1043 -0
- package/dist/utils/voxel/postprocess.d.ts +23 -0
- package/dist/utils/voxel/postprocess.js +375 -0
- package/dist/utils/voxel/voxel-faces.d.ts +18 -0
- package/dist/utils/voxel/voxel-faces.js +663 -0
- package/dist/utils/voxel/voxelize.d.ts +33 -0
- package/dist/utils/voxel/voxelize.js +1193 -0
- package/dist/utils/webgpu.d.ts +8 -0
- package/dist/utils/webgpu.js +122 -0
- package/package.json +32 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function enumerateAdapters(): Promise<{
|
|
2
|
+
index: number;
|
|
3
|
+
name: string;
|
|
4
|
+
}[]>;
|
|
5
|
+
export declare function initGPUAdapter(options?: string[]): void;
|
|
6
|
+
export declare function createDevice(): Promise<GPUDevice>;
|
|
7
|
+
declare const getOrCreateDevice: () => Promise<GPUDevice>, releaseSharedDevice: () => void;
|
|
8
|
+
export { getOrCreateDevice, releaseSharedDevice };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/// <reference types="@webgpu/types" />
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { logger } from './index.js';
|
|
4
|
+
const getModule = (function () {
|
|
5
|
+
let m = undefined;
|
|
6
|
+
return function () {
|
|
7
|
+
if (!m) {
|
|
8
|
+
m = createRequire(import.meta.url)('webgpu');
|
|
9
|
+
Object.assign(globalThis, m.globals);
|
|
10
|
+
}
|
|
11
|
+
return m;
|
|
12
|
+
};
|
|
13
|
+
})();
|
|
14
|
+
let gpu = undefined;
|
|
15
|
+
// Get Dawn's actual adapter names by triggering its error message.
|
|
16
|
+
// This is the official documented method for enumerating adapters:
|
|
17
|
+
// https://github.com/dawn-gpu/node-webgpu?tab=readme-ov-file#usage
|
|
18
|
+
async function getDawnAdapterNames() {
|
|
19
|
+
try {
|
|
20
|
+
const gpu = getModule().create(['adapter=__list_adapters__']);
|
|
21
|
+
await gpu.requestAdapter();
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
// Parse Dawn's error message to extract adapter names
|
|
25
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
26
|
+
const lines = message.split('\n');
|
|
27
|
+
const names = [];
|
|
28
|
+
for (const line of lines) {
|
|
29
|
+
// Look for lines like: " * backend: 'd3d12', name: 'NVIDIA RTX A2000 8GB Laptop GPU'"
|
|
30
|
+
const match = line.match(/name:\s*'([^']+)'/);
|
|
31
|
+
if (match) {
|
|
32
|
+
names.push(match[1]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return names;
|
|
36
|
+
}
|
|
37
|
+
// Unexpected: requestAdapter should have thrown with invalid adapter name
|
|
38
|
+
logger.warn('Expected adapter enumeration to throw an error, but it did not.');
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
;
|
|
42
|
+
// Cache enumerated adapters so we don't query Dawn multiple times
|
|
43
|
+
let cachedAdapters = null;
|
|
44
|
+
export async function enumerateAdapters() {
|
|
45
|
+
if (cachedAdapters) {
|
|
46
|
+
return cachedAdapters;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
logger.info('Detecting GPU adapters...');
|
|
50
|
+
// Get the actual adapter names directly from Dawn
|
|
51
|
+
const dawnAdapterNames = await getDawnAdapterNames();
|
|
52
|
+
// Cache and return the list
|
|
53
|
+
cachedAdapters = dawnAdapterNames.map((name, index) => ({
|
|
54
|
+
index,
|
|
55
|
+
name
|
|
56
|
+
}));
|
|
57
|
+
return cachedAdapters;
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
logger.error('Failed to enumerate adapters. Error:');
|
|
61
|
+
logger.error(e);
|
|
62
|
+
logger.error('\nThis usually means WebGPU is not available. Please ensure:');
|
|
63
|
+
logger.error(' - Your GPU drivers are up to date');
|
|
64
|
+
logger.error(' - Your GPU supports Vulkan, D3D12, or Metal');
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
;
|
|
69
|
+
export function initGPUAdapter(options = []) {
|
|
70
|
+
if (!gpu) {
|
|
71
|
+
logger.info(`Init WebGPU adapter${options.length > 0 ? ` with [${options.join(';')}]` : '.'}`);
|
|
72
|
+
gpu = getModule().create(options);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export async function createDevice() {
|
|
76
|
+
initGPUAdapter();
|
|
77
|
+
const adapter = await gpu.requestAdapter({
|
|
78
|
+
powerPreference: 'high-performance'
|
|
79
|
+
});
|
|
80
|
+
if (!adapter) {
|
|
81
|
+
throw new Error(`No available WebGPU adapter found.`);
|
|
82
|
+
}
|
|
83
|
+
const device = await adapter.requestDevice({
|
|
84
|
+
requiredFeatures: Array.from(adapter.features),
|
|
85
|
+
requiredLimits: adapter.limits
|
|
86
|
+
});
|
|
87
|
+
if (!device) {
|
|
88
|
+
throw new Error('Create WebGPU device failed.');
|
|
89
|
+
}
|
|
90
|
+
logger.info(`WebGPU device created: ${device.adapterInfo.vendor}, ${device.adapterInfo.device}, ${device.adapterInfo.description}`);
|
|
91
|
+
device.addEventListener('uncapturederror', (event) => {
|
|
92
|
+
const error = event.error;
|
|
93
|
+
const type = error?.type ? ` (${error.type})` : '';
|
|
94
|
+
logger.error(`WebGPU uncaptured error${type}: ${error?.message ?? String(error)}`);
|
|
95
|
+
});
|
|
96
|
+
device.lost.then((info) => {
|
|
97
|
+
const message = info.message ? `, message=${info.message}` : '';
|
|
98
|
+
if (info.reason === 'destroyed') {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
logger.warn(`WebGPU device lost unexpectedly: reason=${info.reason}${message}`);
|
|
102
|
+
}).catch((e) => {
|
|
103
|
+
logger.error(`WebGPU device lost handler failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
104
|
+
});
|
|
105
|
+
return device;
|
|
106
|
+
}
|
|
107
|
+
const { getOrCreateDevice, releaseSharedDevice } = (function () {
|
|
108
|
+
let device = undefined;
|
|
109
|
+
return {
|
|
110
|
+
async getOrCreateDevice() {
|
|
111
|
+
if (!device) {
|
|
112
|
+
device = await createDevice();
|
|
113
|
+
}
|
|
114
|
+
return device;
|
|
115
|
+
},
|
|
116
|
+
releaseSharedDevice() {
|
|
117
|
+
device?.destroy();
|
|
118
|
+
device = undefined;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
})();
|
|
122
|
+
export { getOrCreateDevice, releaseSharedDevice };
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@manycore/aholo-splat-transform",
|
|
3
|
+
"version": "1.2.6",
|
|
4
|
+
"description": "Transform & filter Gaussian splats file",
|
|
5
|
+
"author": "egs",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">= 20.19.0"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"bin": {
|
|
12
|
+
"splat-transform": "bin/cli.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist/",
|
|
16
|
+
"CHANGELOG.md"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"cmake-js": "^8.0.0",
|
|
20
|
+
"commander": "^14.0.2",
|
|
21
|
+
"fflate": "^0.8.2",
|
|
22
|
+
"fs-extra": "^11.3.3",
|
|
23
|
+
"node-addon-api": "^8.6.0",
|
|
24
|
+
"tslib": "^2.8.1",
|
|
25
|
+
"webgpu": "^0.4.0"
|
|
26
|
+
},
|
|
27
|
+
"binary": {
|
|
28
|
+
"napi_versions": [
|
|
29
|
+
8
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
}
|