@manycore/aholo-splat-transform 1.2.8 → 1.2.9
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 +120 -113
- package/README.md +39 -39
- package/THIRD_PARTY_LICENSES.txt +1373 -1373
- package/bin/cli.js +125 -118
- package/dist/SplatData.d.ts +67 -67
- package/dist/SplatData.js +167 -150
- package/dist/constant.d.ts +3 -3
- package/dist/constant.js +13 -13
- package/dist/file/IFile.d.ts +5 -5
- package/dist/file/IFile.js +1 -1
- package/dist/file/esz.d.ts +11 -11
- package/dist/file/esz.js +337 -322
- package/dist/file/index.d.ts +8 -8
- package/dist/file/index.js +7 -7
- package/dist/file/ksplat.d.ts +12 -12
- package/dist/file/ksplat.js +293 -231
- package/dist/file/lcc.d.ts +11 -11
- package/dist/file/lcc.js +161 -158
- package/dist/file/ply.d.ts +13 -13
- package/dist/file/ply.js +439 -390
- package/dist/file/sog.d.ts +80 -80
- package/dist/file/sog.js +525 -494
- package/dist/file/splat.d.ts +6 -6
- package/dist/file/splat.js +119 -99
- package/dist/file/spz.d.ts +11 -11
- package/dist/file/spz.js +597 -583
- package/dist/file/voxel.d.ts +43 -37
- package/dist/file/voxel.js +411 -280
- package/dist/index.d.ts +33 -33
- package/dist/index.js +54 -54
- package/dist/native/index.d.ts +54 -54
- package/dist/native/index.js +122 -129
- package/dist/native/utils.d.ts +1 -0
- package/dist/native/utils.js +54 -0
- package/dist/tasks/AutoChunkLodTask.d.ts +13 -13
- package/dist/tasks/AutoChunkLodTask.js +117 -117
- package/dist/tasks/AutoLodTask.d.ts +10 -10
- package/dist/tasks/AutoLodTask.js +20 -20
- package/dist/tasks/BaseTask.d.ts +15 -15
- package/dist/tasks/BaseTask.js +5 -5
- package/dist/tasks/FlexLodTask.d.ts +12 -12
- package/dist/tasks/FlexLodTask.js +54 -44
- package/dist/tasks/ModifyTask.d.ts +9 -9
- package/dist/tasks/ModifyTask.js +166 -156
- package/dist/tasks/ReadTask.d.ts +9 -9
- package/dist/tasks/ReadTask.js +29 -29
- package/dist/tasks/SkeletonLodTask.d.ts +10 -10
- package/dist/tasks/SkeletonLodTask.js +176 -156
- package/dist/tasks/VoxelTask.d.ts +35 -30
- package/dist/tasks/VoxelTask.js +40 -37
- package/dist/tasks/WriteTask.d.ts +12 -12
- package/dist/tasks/WriteTask.js +70 -70
- package/dist/utils/BufferReader.d.ts +12 -12
- package/dist/utils/BufferReader.js +45 -45
- package/dist/utils/Logger.d.ts +11 -11
- package/dist/utils/Logger.js +40 -40
- package/dist/utils/StreamChunkDecoder.d.ts +16 -16
- package/dist/utils/StreamChunkDecoder.js +31 -31
- package/dist/utils/index.d.ts +27 -27
- package/dist/utils/index.js +101 -101
- package/dist/utils/k-means.d.ts +4 -4
- package/dist/utils/k-means.js +340 -341
- package/dist/utils/math.d.ts +46 -46
- package/dist/utils/math.js +350 -346
- package/dist/utils/quantize-1d.d.ts +4 -4
- package/dist/utils/quantize-1d.js +164 -164
- package/dist/utils/sh-rotate.d.ts +2 -2
- package/dist/utils/sh-rotate.js +236 -175
- package/dist/utils/splat.d.ts +21 -21
- package/dist/utils/splat.js +397 -387
- package/dist/utils/voxel/binary.d.ts +8 -0
- package/dist/utils/voxel/binary.js +176 -0
- package/dist/utils/voxel/common.d.ts +178 -162
- package/dist/utils/voxel/common.js +1752 -1682
- package/dist/utils/voxel/coplanar-merge.d.ts +63 -63
- package/dist/utils/voxel/coplanar-merge.js +818 -819
- package/dist/utils/voxel/filter-cluster.d.ts +20 -0
- package/dist/utils/voxel/filter-cluster.js +628 -0
- package/dist/utils/voxel/gpu-dilation.d.ts +2 -2
- package/dist/utils/voxel/gpu-dilation.js +677 -656
- package/dist/utils/voxel/marching-cubes.d.ts +42 -42
- package/dist/utils/voxel/marching-cubes.js +1645 -1657
- package/dist/utils/voxel/mesh.d.ts +3 -3
- package/dist/utils/voxel/mesh.js +130 -130
- package/dist/utils/voxel/nav.d.ts +29 -29
- package/dist/utils/voxel/nav.js +1068 -1043
- package/dist/utils/voxel/postprocess.d.ts +23 -23
- package/dist/utils/voxel/postprocess.js +408 -375
- package/dist/utils/voxel/voxel-faces.d.ts +18 -18
- package/dist/utils/voxel/voxel-faces.js +662 -663
- package/dist/utils/voxel/voxelize.d.ts +34 -33
- package/dist/utils/voxel/voxelize.js +1208 -1193
- package/dist/utils/webgpu.d.ts +8 -8
- package/dist/utils/webgpu.js +122 -122
- package/package.json +37 -39
- package/dist/native/cpp/bin/linux/binding.node +0 -0
- package/dist/native/cpp/bin/windows/binding.node +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export declare class BufferReader {
|
|
2
|
-
head: number;
|
|
3
|
-
tail: number;
|
|
4
|
-
buffer: Uint8Array;
|
|
5
|
-
view: DataView;
|
|
6
|
-
get remaining(): number;
|
|
7
|
-
constructor(buffer?: Uint8Array);
|
|
8
|
-
private grow;
|
|
9
|
-
private compact;
|
|
10
|
-
write(chunk: Uint8Array): void;
|
|
11
|
-
read(counts: number): Uint8Array;
|
|
12
|
-
}
|
|
1
|
+
export declare class BufferReader {
|
|
2
|
+
head: number;
|
|
3
|
+
tail: number;
|
|
4
|
+
buffer: Uint8Array;
|
|
5
|
+
view: DataView;
|
|
6
|
+
get remaining(): number;
|
|
7
|
+
constructor(buffer?: Uint8Array);
|
|
8
|
+
private grow;
|
|
9
|
+
private compact;
|
|
10
|
+
write(chunk: Uint8Array): void;
|
|
11
|
+
read(counts: number): Uint8Array;
|
|
12
|
+
}
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
export class BufferReader {
|
|
2
|
-
get remaining() {
|
|
3
|
-
return this.tail - this.head;
|
|
4
|
-
}
|
|
5
|
-
constructor(buffer = new Uint8Array()) {
|
|
6
|
-
this.head = 0;
|
|
7
|
-
this.tail = 0;
|
|
8
|
-
this.buffer = buffer;
|
|
9
|
-
this.view = new DataView(this.buffer.buffer);
|
|
10
|
-
}
|
|
11
|
-
grow(required) {
|
|
12
|
-
const newCap = Math.max(required, this.buffer.length * 2);
|
|
13
|
-
const next = new Uint8Array(newCap);
|
|
14
|
-
next.set(this.buffer.subarray(this.head, this.tail), 0);
|
|
15
|
-
this.tail -= this.head;
|
|
16
|
-
this.head = 0;
|
|
17
|
-
this.buffer = next;
|
|
18
|
-
this.view = new DataView(next.buffer);
|
|
19
|
-
}
|
|
20
|
-
compact() {
|
|
21
|
-
if (this.head === 0) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
this.buffer.copyWithin(0, this.head, this.tail);
|
|
25
|
-
this.tail -= this.head;
|
|
26
|
-
this.head = 0;
|
|
27
|
-
}
|
|
28
|
-
write(chunk) {
|
|
29
|
-
const remaining = this.tail - this.head;
|
|
30
|
-
const required = remaining + chunk.length;
|
|
31
|
-
if (this.buffer.length < required) {
|
|
32
|
-
this.grow(required);
|
|
33
|
-
}
|
|
34
|
-
else if (this.head > 0 && this.buffer.length - this.tail < chunk.length) {
|
|
35
|
-
this.compact();
|
|
36
|
-
}
|
|
37
|
-
this.buffer.set(chunk, this.tail);
|
|
38
|
-
this.tail += chunk.length;
|
|
39
|
-
}
|
|
40
|
-
read(counts) {
|
|
41
|
-
const head = this.head;
|
|
42
|
-
const tail = this.head = head + counts;
|
|
43
|
-
return this.buffer.subarray(head, tail);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
1
|
+
export class BufferReader {
|
|
2
|
+
get remaining() {
|
|
3
|
+
return this.tail - this.head;
|
|
4
|
+
}
|
|
5
|
+
constructor(buffer = new Uint8Array()) {
|
|
6
|
+
this.head = 0;
|
|
7
|
+
this.tail = 0;
|
|
8
|
+
this.buffer = buffer;
|
|
9
|
+
this.view = new DataView(this.buffer.buffer);
|
|
10
|
+
}
|
|
11
|
+
grow(required) {
|
|
12
|
+
const newCap = Math.max(required, this.buffer.length * 2);
|
|
13
|
+
const next = new Uint8Array(newCap);
|
|
14
|
+
next.set(this.buffer.subarray(this.head, this.tail), 0);
|
|
15
|
+
this.tail -= this.head;
|
|
16
|
+
this.head = 0;
|
|
17
|
+
this.buffer = next;
|
|
18
|
+
this.view = new DataView(next.buffer);
|
|
19
|
+
}
|
|
20
|
+
compact() {
|
|
21
|
+
if (this.head === 0) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
this.buffer.copyWithin(0, this.head, this.tail);
|
|
25
|
+
this.tail -= this.head;
|
|
26
|
+
this.head = 0;
|
|
27
|
+
}
|
|
28
|
+
write(chunk) {
|
|
29
|
+
const remaining = this.tail - this.head;
|
|
30
|
+
const required = remaining + chunk.length;
|
|
31
|
+
if (this.buffer.length < required) {
|
|
32
|
+
this.grow(required);
|
|
33
|
+
}
|
|
34
|
+
else if (this.head > 0 && this.buffer.length - this.tail < chunk.length) {
|
|
35
|
+
this.compact();
|
|
36
|
+
}
|
|
37
|
+
this.buffer.set(chunk, this.tail);
|
|
38
|
+
this.tail += chunk.length;
|
|
39
|
+
}
|
|
40
|
+
read(counts) {
|
|
41
|
+
const head = this.head;
|
|
42
|
+
const tail = (this.head = head + counts);
|
|
43
|
+
return this.buffer.subarray(head, tail);
|
|
44
|
+
}
|
|
45
|
+
}
|
package/dist/utils/Logger.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export declare class Logger {
|
|
2
|
-
prefix: string;
|
|
3
|
-
silent: boolean;
|
|
4
|
-
private format;
|
|
5
|
-
info(msg: string, force?: boolean): void;
|
|
6
|
-
warn(msg: string, force?: boolean): void;
|
|
7
|
-
error(msg: string, force?: boolean): void;
|
|
8
|
-
time(label: string): void;
|
|
9
|
-
timeEnd(label: string): void;
|
|
10
|
-
}
|
|
11
|
-
export declare const logger: Logger;
|
|
1
|
+
export declare class Logger {
|
|
2
|
+
prefix: string;
|
|
3
|
+
silent: boolean;
|
|
4
|
+
private format;
|
|
5
|
+
info(msg: string, force?: boolean): void;
|
|
6
|
+
warn(msg: string, force?: boolean): void;
|
|
7
|
+
error(msg: string, force?: boolean): void;
|
|
8
|
+
time(label: string): void;
|
|
9
|
+
timeEnd(label: string): void;
|
|
10
|
+
}
|
|
11
|
+
export declare const logger: Logger;
|
package/dist/utils/Logger.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
export class Logger {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.prefix = '';
|
|
4
|
-
this.silent = false;
|
|
5
|
-
}
|
|
6
|
-
format(msg) {
|
|
7
|
-
return this.prefix ? `${this.prefix} ${msg}` : msg;
|
|
8
|
-
}
|
|
9
|
-
info(msg, force = false) {
|
|
10
|
-
if (this.silent && !force) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
console.log(this.format(msg));
|
|
14
|
-
}
|
|
15
|
-
warn(msg, force = false) {
|
|
16
|
-
if (this.silent && !force) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
console.warn(this.format(msg));
|
|
20
|
-
}
|
|
21
|
-
error(msg, force = false) {
|
|
22
|
-
if (this.silent && !force) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
console.error(this.format(msg));
|
|
26
|
-
}
|
|
27
|
-
time(label) {
|
|
28
|
-
if (this.silent) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
console.time(this.format(label));
|
|
32
|
-
}
|
|
33
|
-
timeEnd(label) {
|
|
34
|
-
if (this.silent) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
console.timeEnd(this.format(label));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
export const logger = new Logger();
|
|
1
|
+
export class Logger {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.prefix = '';
|
|
4
|
+
this.silent = false;
|
|
5
|
+
}
|
|
6
|
+
format(msg) {
|
|
7
|
+
return this.prefix ? `${this.prefix} ${msg}` : msg;
|
|
8
|
+
}
|
|
9
|
+
info(msg, force = false) {
|
|
10
|
+
if (this.silent && !force) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
console.log(this.format(msg));
|
|
14
|
+
}
|
|
15
|
+
warn(msg, force = false) {
|
|
16
|
+
if (this.silent && !force) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
console.warn(this.format(msg));
|
|
20
|
+
}
|
|
21
|
+
error(msg, force = false) {
|
|
22
|
+
if (this.silent && !force) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
console.error(this.format(msg));
|
|
26
|
+
}
|
|
27
|
+
time(label) {
|
|
28
|
+
if (this.silent) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
console.time(this.format(label));
|
|
32
|
+
}
|
|
33
|
+
timeEnd(label) {
|
|
34
|
+
if (this.silent) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
console.timeEnd(this.format(label));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export const logger = new Logger();
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { BufferReader } from './BufferReader.js';
|
|
2
|
-
export interface ChunkDecoder {
|
|
3
|
-
init(): [number, number];
|
|
4
|
-
decode(offset: number, counts: number, buffer: Uint8Array): void;
|
|
5
|
-
}
|
|
6
|
-
export declare class StreamChunkDecoder {
|
|
7
|
-
private reader;
|
|
8
|
-
private decoders;
|
|
9
|
-
private decodedTotals;
|
|
10
|
-
private currentIndex;
|
|
11
|
-
private currentTotals;
|
|
12
|
-
private currentItemSize;
|
|
13
|
-
constructor(reader: BufferReader);
|
|
14
|
-
setDecoders(decoders: ChunkDecoder[]): void;
|
|
15
|
-
flush(): void;
|
|
16
|
-
}
|
|
1
|
+
import type { BufferReader } from './BufferReader.js';
|
|
2
|
+
export interface ChunkDecoder {
|
|
3
|
+
init(): [number, number];
|
|
4
|
+
decode(offset: number, counts: number, buffer: Uint8Array): void;
|
|
5
|
+
}
|
|
6
|
+
export declare class StreamChunkDecoder {
|
|
7
|
+
private reader;
|
|
8
|
+
private decoders;
|
|
9
|
+
private decodedTotals;
|
|
10
|
+
private currentIndex;
|
|
11
|
+
private currentTotals;
|
|
12
|
+
private currentItemSize;
|
|
13
|
+
constructor(reader: BufferReader);
|
|
14
|
+
setDecoders(decoders: ChunkDecoder[]): void;
|
|
15
|
+
flush(): void;
|
|
16
|
+
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
export class StreamChunkDecoder {
|
|
2
|
-
constructor(reader) {
|
|
3
|
-
this.currentIndex = 0;
|
|
4
|
-
this.reader = reader;
|
|
5
|
-
}
|
|
6
|
-
setDecoders(decoders) {
|
|
7
|
-
this.decoders = decoders;
|
|
8
|
-
this.decodedTotals = new Uint32Array(decoders.length);
|
|
9
|
-
const [totals, itemSize] = decoders[this.currentIndex].init();
|
|
10
|
-
this.currentTotals = totals;
|
|
11
|
-
this.currentItemSize = itemSize;
|
|
12
|
-
}
|
|
13
|
-
flush() {
|
|
14
|
-
const { reader, decoders, decodedTotals, currentIndex, currentTotals, currentItemSize } = this;
|
|
15
|
-
const stage = decoders[currentIndex];
|
|
16
|
-
const decoded = decodedTotals[currentIndex];
|
|
17
|
-
const counts = Math.min(currentTotals - decoded, (reader.remaining / currentItemSize) | 0);
|
|
18
|
-
const buf = reader.read(counts * currentItemSize);
|
|
19
|
-
stage.decode(decoded, counts, buf);
|
|
20
|
-
decodedTotals[currentIndex] += counts;
|
|
21
|
-
if (decodedTotals[currentIndex] === currentTotals) {
|
|
22
|
-
this.currentIndex++;
|
|
23
|
-
if (this.currentIndex < decoders.length) {
|
|
24
|
-
const [totals, itemSize] = decoders[this.currentIndex].init();
|
|
25
|
-
this.currentTotals = totals;
|
|
26
|
-
this.currentItemSize = itemSize;
|
|
27
|
-
this.flush();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
export class StreamChunkDecoder {
|
|
2
|
+
constructor(reader) {
|
|
3
|
+
this.currentIndex = 0;
|
|
4
|
+
this.reader = reader;
|
|
5
|
+
}
|
|
6
|
+
setDecoders(decoders) {
|
|
7
|
+
this.decoders = decoders;
|
|
8
|
+
this.decodedTotals = new Uint32Array(decoders.length);
|
|
9
|
+
const [totals, itemSize] = decoders[this.currentIndex].init();
|
|
10
|
+
this.currentTotals = totals;
|
|
11
|
+
this.currentItemSize = itemSize;
|
|
12
|
+
}
|
|
13
|
+
flush() {
|
|
14
|
+
const { reader, decoders, decodedTotals, currentIndex, currentTotals, currentItemSize } = this;
|
|
15
|
+
const stage = decoders[currentIndex];
|
|
16
|
+
const decoded = decodedTotals[currentIndex];
|
|
17
|
+
const counts = Math.min(currentTotals - decoded, (reader.remaining / currentItemSize) | 0);
|
|
18
|
+
const buf = reader.read(counts * currentItemSize);
|
|
19
|
+
stage.decode(decoded, counts, buf);
|
|
20
|
+
decodedTotals[currentIndex] += counts;
|
|
21
|
+
if (decodedTotals[currentIndex] === currentTotals) {
|
|
22
|
+
this.currentIndex++;
|
|
23
|
+
if (this.currentIndex < decoders.length) {
|
|
24
|
+
const [totals, itemSize] = decoders[this.currentIndex].init();
|
|
25
|
+
this.currentTotals = totals;
|
|
26
|
+
this.currentItemSize = itemSize;
|
|
27
|
+
this.flush();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
interface Deferred<T = void> {
|
|
2
|
-
resolve: (value: T | PromiseLike<T>) => void;
|
|
3
|
-
reject: (reason: any) => void;
|
|
4
|
-
promise: Promise<T>;
|
|
5
|
-
}
|
|
6
|
-
export declare function deferred<T = void>(): Deferred<T>;
|
|
7
|
-
export declare function sleep(timeout: number): Promise<void>;
|
|
8
|
-
export declare function clamp(v: number, min: number, max: number): number;
|
|
9
|
-
export declare function isUrl(str: string): boolean;
|
|
10
|
-
export declare function extractFromRootDir(entries: Record<string, Uint8Array>): Record<string, Uint8Array>;
|
|
11
|
-
export declare function fromHalf(h: number): number;
|
|
12
|
-
export * from './Logger.js';
|
|
13
|
-
export * from './BufferReader.js';
|
|
14
|
-
export * from './StreamChunkDecoder.js';
|
|
15
|
-
export * from './math.js';
|
|
16
|
-
export * from './sh-rotate.js';
|
|
17
|
-
export * from './splat.js';
|
|
18
|
-
export * from './k-means.js';
|
|
19
|
-
export * from './quantize-1d.js';
|
|
20
|
-
export * from './webgpu.js';
|
|
21
|
-
export * from './voxel/common.js';
|
|
22
|
-
export * from './voxel/voxelize.js';
|
|
23
|
-
export * from './voxel/postprocess.js';
|
|
24
|
-
export * from './voxel/nav.js';
|
|
25
|
-
export * from './voxel/mesh.js';
|
|
26
|
-
export * from './voxel/voxel-faces.js';
|
|
27
|
-
export * from './voxel/gpu-dilation.js';
|
|
1
|
+
interface Deferred<T = void> {
|
|
2
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
3
|
+
reject: (reason: any) => void;
|
|
4
|
+
promise: Promise<T>;
|
|
5
|
+
}
|
|
6
|
+
export declare function deferred<T = void>(): Deferred<T>;
|
|
7
|
+
export declare function sleep(timeout: number): Promise<void>;
|
|
8
|
+
export declare function clamp(v: number, min: number, max: number): number;
|
|
9
|
+
export declare function isUrl(str: string): boolean;
|
|
10
|
+
export declare function extractFromRootDir(entries: Record<string, Uint8Array>): Record<string, Uint8Array>;
|
|
11
|
+
export declare function fromHalf(h: number): number;
|
|
12
|
+
export * from './Logger.js';
|
|
13
|
+
export * from './BufferReader.js';
|
|
14
|
+
export * from './StreamChunkDecoder.js';
|
|
15
|
+
export * from './math.js';
|
|
16
|
+
export * from './sh-rotate.js';
|
|
17
|
+
export * from './splat.js';
|
|
18
|
+
export * from './k-means.js';
|
|
19
|
+
export * from './quantize-1d.js';
|
|
20
|
+
export * from './webgpu.js';
|
|
21
|
+
export * from './voxel/common.js';
|
|
22
|
+
export * from './voxel/voxelize.js';
|
|
23
|
+
export * from './voxel/postprocess.js';
|
|
24
|
+
export * from './voxel/nav.js';
|
|
25
|
+
export * from './voxel/mesh.js';
|
|
26
|
+
export * from './voxel/voxel-faces.js';
|
|
27
|
+
export * from './voxel/gpu-dilation.js';
|
package/dist/utils/index.js
CHANGED
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
export function deferred() {
|
|
2
|
-
let resolve = () => { };
|
|
3
|
-
let reject = () => { };
|
|
4
|
-
const promise = new Promise(function (resolveInner, rejectInner) {
|
|
5
|
-
resolve = resolveInner;
|
|
6
|
-
reject = rejectInner;
|
|
7
|
-
});
|
|
8
|
-
return {
|
|
9
|
-
promise,
|
|
10
|
-
resolve,
|
|
11
|
-
reject,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export function sleep(timeout) {
|
|
15
|
-
return new Promise(resolve => {
|
|
16
|
-
setTimeout(resolve, timeout);
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
export function clamp(v, min, max) {
|
|
20
|
-
return Math.min(Math.max(v, min), max);
|
|
21
|
-
}
|
|
22
|
-
export function isUrl(str) {
|
|
23
|
-
let url;
|
|
24
|
-
try {
|
|
25
|
-
url = new URL(str);
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
31
|
-
}
|
|
32
|
-
export function extractFromRootDir(entries) {
|
|
33
|
-
let dir = '';
|
|
34
|
-
for (const path in entries) {
|
|
35
|
-
if (path.endsWith('/')) {
|
|
36
|
-
dir = path;
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
const result = {};
|
|
41
|
-
for (const path in entries) {
|
|
42
|
-
result[path.replace(dir, '')] = entries[path];
|
|
43
|
-
}
|
|
44
|
-
return result;
|
|
45
|
-
}
|
|
46
|
-
const f32buffer = new Float32Array(1);
|
|
47
|
-
const u32buffer = new Uint32Array(f32buffer.buffer);
|
|
48
|
-
export function fromHalf(h) {
|
|
49
|
-
const sign = (h >> 15) & 0x1;
|
|
50
|
-
const exp = (h >> 10) & 0x1f;
|
|
51
|
-
const frac = h & 0x3ff;
|
|
52
|
-
let f32bits;
|
|
53
|
-
if (exp === 0) {
|
|
54
|
-
if (frac === 0) {
|
|
55
|
-
f32bits = sign << 31;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
let mant = frac;
|
|
59
|
-
let e = -14;
|
|
60
|
-
while ((mant & 0x400) === 0) {
|
|
61
|
-
mant <<= 1;
|
|
62
|
-
e--;
|
|
63
|
-
}
|
|
64
|
-
mant &= 0x3ff;
|
|
65
|
-
const newExp = e + 127;
|
|
66
|
-
const newFrac = mant << 13;
|
|
67
|
-
f32bits = (sign << 31) | (newExp << 23) | newFrac;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
else if (exp === 0x1f) {
|
|
71
|
-
if (frac === 0) {
|
|
72
|
-
f32bits = (sign << 31) | 0x7f800000;
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
f32bits = (sign << 31) | 0x7fc00000;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
const newExp = exp - 15 + 127;
|
|
80
|
-
const newFrac = frac << 13;
|
|
81
|
-
f32bits = (sign << 31) | (newExp << 23) | newFrac;
|
|
82
|
-
}
|
|
83
|
-
u32buffer[0] = f32bits;
|
|
84
|
-
return f32buffer[0];
|
|
85
|
-
}
|
|
86
|
-
export * from './Logger.js';
|
|
87
|
-
export * from './BufferReader.js';
|
|
88
|
-
export * from './StreamChunkDecoder.js';
|
|
89
|
-
export * from './math.js';
|
|
90
|
-
export * from './sh-rotate.js';
|
|
91
|
-
export * from './splat.js';
|
|
92
|
-
export * from './k-means.js';
|
|
93
|
-
export * from './quantize-1d.js';
|
|
94
|
-
export * from './webgpu.js';
|
|
95
|
-
export * from './voxel/common.js';
|
|
96
|
-
export * from './voxel/voxelize.js';
|
|
97
|
-
export * from './voxel/postprocess.js';
|
|
98
|
-
export * from './voxel/nav.js';
|
|
99
|
-
export * from './voxel/mesh.js';
|
|
100
|
-
export * from './voxel/voxel-faces.js';
|
|
101
|
-
export * from './voxel/gpu-dilation.js';
|
|
1
|
+
export function deferred() {
|
|
2
|
+
let resolve = () => { };
|
|
3
|
+
let reject = () => { };
|
|
4
|
+
const promise = new Promise(function (resolveInner, rejectInner) {
|
|
5
|
+
resolve = resolveInner;
|
|
6
|
+
reject = rejectInner;
|
|
7
|
+
});
|
|
8
|
+
return {
|
|
9
|
+
promise,
|
|
10
|
+
resolve,
|
|
11
|
+
reject,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export function sleep(timeout) {
|
|
15
|
+
return new Promise(resolve => {
|
|
16
|
+
setTimeout(resolve, timeout);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export function clamp(v, min, max) {
|
|
20
|
+
return Math.min(Math.max(v, min), max);
|
|
21
|
+
}
|
|
22
|
+
export function isUrl(str) {
|
|
23
|
+
let url;
|
|
24
|
+
try {
|
|
25
|
+
url = new URL(str);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
31
|
+
}
|
|
32
|
+
export function extractFromRootDir(entries) {
|
|
33
|
+
let dir = '';
|
|
34
|
+
for (const path in entries) {
|
|
35
|
+
if (path.endsWith('/')) {
|
|
36
|
+
dir = path;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const result = {};
|
|
41
|
+
for (const path in entries) {
|
|
42
|
+
result[path.replace(dir, '')] = entries[path];
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
const f32buffer = new Float32Array(1);
|
|
47
|
+
const u32buffer = new Uint32Array(f32buffer.buffer);
|
|
48
|
+
export function fromHalf(h) {
|
|
49
|
+
const sign = (h >> 15) & 0x1;
|
|
50
|
+
const exp = (h >> 10) & 0x1f;
|
|
51
|
+
const frac = h & 0x3ff;
|
|
52
|
+
let f32bits;
|
|
53
|
+
if (exp === 0) {
|
|
54
|
+
if (frac === 0) {
|
|
55
|
+
f32bits = sign << 31;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
let mant = frac;
|
|
59
|
+
let e = -14;
|
|
60
|
+
while ((mant & 0x400) === 0) {
|
|
61
|
+
mant <<= 1;
|
|
62
|
+
e--;
|
|
63
|
+
}
|
|
64
|
+
mant &= 0x3ff;
|
|
65
|
+
const newExp = e + 127;
|
|
66
|
+
const newFrac = mant << 13;
|
|
67
|
+
f32bits = (sign << 31) | (newExp << 23) | newFrac;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else if (exp === 0x1f) {
|
|
71
|
+
if (frac === 0) {
|
|
72
|
+
f32bits = (sign << 31) | 0x7f800000;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
f32bits = (sign << 31) | 0x7fc00000;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const newExp = exp - 15 + 127;
|
|
80
|
+
const newFrac = frac << 13;
|
|
81
|
+
f32bits = (sign << 31) | (newExp << 23) | newFrac;
|
|
82
|
+
}
|
|
83
|
+
u32buffer[0] = f32bits;
|
|
84
|
+
return f32buffer[0];
|
|
85
|
+
}
|
|
86
|
+
export * from './Logger.js';
|
|
87
|
+
export * from './BufferReader.js';
|
|
88
|
+
export * from './StreamChunkDecoder.js';
|
|
89
|
+
export * from './math.js';
|
|
90
|
+
export * from './sh-rotate.js';
|
|
91
|
+
export * from './splat.js';
|
|
92
|
+
export * from './k-means.js';
|
|
93
|
+
export * from './quantize-1d.js';
|
|
94
|
+
export * from './webgpu.js';
|
|
95
|
+
export * from './voxel/common.js';
|
|
96
|
+
export * from './voxel/voxelize.js';
|
|
97
|
+
export * from './voxel/postprocess.js';
|
|
98
|
+
export * from './voxel/nav.js';
|
|
99
|
+
export * from './voxel/mesh.js';
|
|
100
|
+
export * from './voxel/voxel-faces.js';
|
|
101
|
+
export * from './voxel/gpu-dilation.js';
|
package/dist/utils/k-means.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function kmeans(points: Float32Array[], k: number, iterations: number, device: GPUDevice): Promise<{
|
|
2
|
-
centroids: Float32Array<ArrayBufferLike>[];
|
|
3
|
-
labels: Uint32Array<ArrayBuffer>;
|
|
4
|
-
}>;
|
|
1
|
+
export declare function kmeans(points: Float32Array[], k: number, iterations: number, device: GPUDevice): Promise<{
|
|
2
|
+
centroids: Float32Array<ArrayBufferLike>[];
|
|
3
|
+
labels: Uint32Array<ArrayBuffer>;
|
|
4
|
+
}>;
|