@margoengine/points 0.1.0 → 1.0.0
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/LICENSE +201 -201
- package/NOTICE +4 -4
- package/README.md +877 -794
- package/dist/copc-write.d.ts +95 -0
- package/dist/copc-write.js +318 -0
- package/dist/copc.d.ts +1 -1
- package/dist/copc.js +25 -28
- package/dist/frame.d.ts +5 -0
- package/dist/index.js +66 -66
- package/dist/laz-encode-CHXgHra_.js +446 -0
- package/dist/laz-encode.d.ts +14 -0
- package/dist/laz-model-DCphHLqH.js +385 -0
- package/dist/laz-model.d.ts +47 -0
- package/dist/laz-write.d.ts +46 -0
- package/dist/laz-write.js +75 -0
- package/dist/laz.js +198 -578
- package/dist/material.d.ts +3 -3
- package/dist/octree.js +3 -3
- package/dist/pick.js +20 -20
- package/dist/plugin.d.ts +3 -3
- package/dist/potree-las-RC8sjbYU.js +1 -0
- package/dist/potree-las.d.ts +1 -0
- package/dist/potree.js +1 -1
- package/dist/{shaders-Deu8H36P.js → shaders-DCnbvb0-.js} +50 -46
- package/dist/shared/fog.d.ts +33 -33
- package/dist/shared/pass.d.ts +53 -53
- package/dist/shared/selection-mask.d.ts +52 -52
- package/dist/shared/style-expression.d.ts +18 -18
- package/dist/sprites.d.ts +1 -1
- package/dist/style.js +1 -0
- package/dist/surfels.js +68 -68
- package/package.json +104 -96
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
/** How a selection mask shows unselected and selected elements. */
|
|
2
|
-
export interface MaskStyle {
|
|
3
|
-
/**
|
|
4
|
-
* 'fade' darkens unselected elements to `fade` of their displayed sRGB colour; 'highlight' does that and also moves
|
|
5
|
-
* selected elements `highlightAmount` of the way to `highlight`; 'filter' hides unselected elements. Default 'fade'.
|
|
6
|
-
*/
|
|
7
|
-
readonly mode?: 'fade' | 'highlight' | 'filter';
|
|
8
|
-
/** Displayed brightness of unselected elements, in [0, 1]. Default 0.12. */
|
|
9
|
-
readonly fade?: number;
|
|
10
|
-
/** Highlight colour, linear `[r, g, b]`, stored as 8-bit sRGB. Default `[1, 0.4508, 0.0194]` (#ffb326). */
|
|
11
|
-
readonly highlight?: readonly [number, number, number];
|
|
12
|
-
/** How far selected elements move to `highlight`, in [0, 1], stored in 8 bits. Default 0.7. */
|
|
13
|
-
readonly highlightAmount?: number;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const MASK_HEADER: 4;
|
|
17
|
-
export function writeMaskHeader(words: Uint32Array, style: Required<MaskStyle>): Uint32Array;
|
|
18
|
-
export function writeMaskBits(words: Uint32Array, values: ArrayLike<number | boolean>, start?: number): Uint32Array;
|
|
19
|
-
/**
|
|
20
|
-
* The displayed sRGB colour of element `index` (and, for a segment, element `other` too) under the packed mask
|
|
21
|
-
* `words`, exactly as the shader draws it, or null when the mask hides it. `rgb` is its sRGB colour in 0..1 without
|
|
22
|
-
* the mask.
|
|
23
|
-
*/
|
|
24
|
-
export function maskColor(
|
|
25
|
-
words: Uint32Array | null,
|
|
26
|
-
rgb: ArrayLike<number>,
|
|
27
|
-
index: number,
|
|
28
|
-
other?: number,
|
|
29
|
-
): number[] | null;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The selection mask of a point cloud or line: `setMask` (in each class) packs it, the rest is shared. The mask is a
|
|
33
|
-
* 4-word style header, then one bit an element.
|
|
34
|
-
*/
|
|
35
|
-
export abstract class SelectionMasked {
|
|
36
|
-
/** Element count the mask covers. */
|
|
37
|
-
abstract readonly count: number;
|
|
38
|
-
/** The selection mask (see `setMask`): a 4-word style header, then one bit an element; or null. */
|
|
39
|
-
mask: Uint32Array | null;
|
|
40
|
-
/** Bumped when the mask bits or style change, so the next frame uploads them once. @internal */
|
|
41
|
-
maskVersion: number;
|
|
42
|
-
/** How the mask shows elements: mode 'fade' (default), 'highlight' or 'filter', fade 0.12, highlight [1, 0.4508, 0.0194] (#ffb326) at 0.7. */
|
|
43
|
-
get maskStyle(): Readonly<Required<MaskStyle>>;
|
|
44
|
-
/** Changes how the mask shows elements, without touching its bits. */
|
|
45
|
-
setMaskStyle(style: MaskStyle): this;
|
|
46
|
-
/** Overwrites the mask of elements `start ..`; one upload of the mask at the next frame. */
|
|
47
|
-
updateMask(start: number, values: ArrayLike<number | boolean>): this;
|
|
48
|
-
/** Whether element `index` is selected by the mask; true without a mask. */
|
|
49
|
-
isSelected(index: number): boolean;
|
|
50
|
-
/** Validates `style` and makes it the mask style, for `setMask`. @internal */
|
|
51
|
-
takeMaskStyle(style?: MaskStyle): Readonly<Required<MaskStyle>>;
|
|
52
|
-
}
|
|
1
|
+
/** How a selection mask shows unselected and selected elements. */
|
|
2
|
+
export interface MaskStyle {
|
|
3
|
+
/**
|
|
4
|
+
* 'fade' darkens unselected elements to `fade` of their displayed sRGB colour; 'highlight' does that and also moves
|
|
5
|
+
* selected elements `highlightAmount` of the way to `highlight`; 'filter' hides unselected elements. Default 'fade'.
|
|
6
|
+
*/
|
|
7
|
+
readonly mode?: 'fade' | 'highlight' | 'filter';
|
|
8
|
+
/** Displayed brightness of unselected elements, in [0, 1]. Default 0.12. */
|
|
9
|
+
readonly fade?: number;
|
|
10
|
+
/** Highlight colour, linear `[r, g, b]`, stored as 8-bit sRGB. Default `[1, 0.4508, 0.0194]` (#ffb326). */
|
|
11
|
+
readonly highlight?: readonly [number, number, number];
|
|
12
|
+
/** How far selected elements move to `highlight`, in [0, 1], stored in 8 bits. Default 0.7. */
|
|
13
|
+
readonly highlightAmount?: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const MASK_HEADER: 4;
|
|
17
|
+
export function writeMaskHeader(words: Uint32Array, style: Required<MaskStyle>): Uint32Array;
|
|
18
|
+
export function writeMaskBits(words: Uint32Array, values: ArrayLike<number | boolean>, start?: number): Uint32Array;
|
|
19
|
+
/**
|
|
20
|
+
* The displayed sRGB colour of element `index` (and, for a segment, element `other` too) under the packed mask
|
|
21
|
+
* `words`, exactly as the shader draws it, or null when the mask hides it. `rgb` is its sRGB colour in 0..1 without
|
|
22
|
+
* the mask.
|
|
23
|
+
*/
|
|
24
|
+
export function maskColor(
|
|
25
|
+
words: Uint32Array | null,
|
|
26
|
+
rgb: ArrayLike<number>,
|
|
27
|
+
index: number,
|
|
28
|
+
other?: number,
|
|
29
|
+
): number[] | null;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The selection mask of a point cloud or line: `setMask` (in each class) packs it, the rest is shared. The mask is a
|
|
33
|
+
* 4-word style header, then one bit an element.
|
|
34
|
+
*/
|
|
35
|
+
export abstract class SelectionMasked {
|
|
36
|
+
/** Element count the mask covers. */
|
|
37
|
+
abstract readonly count: number;
|
|
38
|
+
/** The selection mask (see `setMask`): a 4-word style header, then one bit an element; or null. */
|
|
39
|
+
mask: Uint32Array | null;
|
|
40
|
+
/** Bumped when the mask bits or style change, so the next frame uploads them once. @internal */
|
|
41
|
+
maskVersion: number;
|
|
42
|
+
/** How the mask shows elements: mode 'fade' (default), 'highlight' or 'filter', fade 0.12, highlight [1, 0.4508, 0.0194] (#ffb326) at 0.7. */
|
|
43
|
+
get maskStyle(): Readonly<Required<MaskStyle>>;
|
|
44
|
+
/** Changes how the mask shows elements, without touching its bits. */
|
|
45
|
+
setMaskStyle(style: MaskStyle): this;
|
|
46
|
+
/** Overwrites the mask of elements `start ..`; one upload of the mask at the next frame. */
|
|
47
|
+
updateMask(start: number, values: ArrayLike<number | boolean>): this;
|
|
48
|
+
/** Whether element `index` is selected by the mask; true without a mask. */
|
|
49
|
+
isSelected(index: number): boolean;
|
|
50
|
+
/** Validates `style` and makes it the mask style, for `setMask`. @internal */
|
|
51
|
+
takeMaskStyle(style?: MaskStyle): Readonly<Required<MaskStyle>>;
|
|
52
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/** A style value: number, boolean, string, null, undefined, a vector (an array of numbers) or a regular expression. */
|
|
2
|
-
export type StyleValue = unknown;
|
|
3
|
-
/** Reads one property or point semantic (`POSITION`, `COLOR`, ...) by name. */
|
|
4
|
-
export type StyleRead = (name: string) => StyleValue;
|
|
5
|
-
/** A compiled expression: evaluate it with a property reader. */
|
|
6
|
-
export type StyleEvaluator = (read: StyleRead) => StyleValue;
|
|
7
|
-
/** An expression, a literal, or an ordered list of `[test, result]` conditions. */
|
|
8
|
-
export type StyleSource =
|
|
9
|
-
| string
|
|
10
|
-
| number
|
|
11
|
-
| boolean
|
|
12
|
-
| { conditions: readonly (readonly [string, string | number | boolean])[] };
|
|
13
|
-
/** A style vector holding `values`. */
|
|
14
|
-
export declare function vector(values: ArrayLike<number>): number[];
|
|
15
|
-
/** Compiles one expression. Throws MargoError `state` on a syntax error. */
|
|
16
|
-
export declare function expression(source: string): StyleEvaluator;
|
|
17
|
-
/** Compiles one style property; `fallback` when it is omitted, undefined when no condition is true. */
|
|
18
|
-
export declare function styleProperty(value: StyleSource | undefined, fallback: StyleValue): StyleEvaluator;
|
|
1
|
+
/** A style value: number, boolean, string, null, undefined, a vector (an array of numbers) or a regular expression. */
|
|
2
|
+
export type StyleValue = unknown;
|
|
3
|
+
/** Reads one property or point semantic (`POSITION`, `COLOR`, ...) by name. */
|
|
4
|
+
export type StyleRead = (name: string) => StyleValue;
|
|
5
|
+
/** A compiled expression: evaluate it with a property reader. */
|
|
6
|
+
export type StyleEvaluator = (read: StyleRead) => StyleValue;
|
|
7
|
+
/** An expression, a literal, or an ordered list of `[test, result]` conditions. */
|
|
8
|
+
export type StyleSource =
|
|
9
|
+
| string
|
|
10
|
+
| number
|
|
11
|
+
| boolean
|
|
12
|
+
| { conditions: readonly (readonly [string, string | number | boolean])[] };
|
|
13
|
+
/** A style vector holding `values`. */
|
|
14
|
+
export declare function vector(values: ArrayLike<number>): number[];
|
|
15
|
+
/** Compiles one expression. Throws MargoError `state` on a syntax error. */
|
|
16
|
+
export declare function expression(source: string): StyleEvaluator;
|
|
17
|
+
/** Compiles one style property; `fallback` when it is omitted, undefined when no condition is true. */
|
|
18
|
+
export declare function styleProperty(value: StyleSource | undefined, fallback: StyleValue): StyleEvaluator;
|
package/dist/sprites.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare const SPRITE_STRIDE = 16;
|
|
|
9
9
|
export interface SpriteOptions {
|
|
10
10
|
/** Local position (the batch's matrix or attached mesh applies). Default [0, 0, 0]. */
|
|
11
11
|
position?: readonly [number, number, number];
|
|
12
|
-
/** Width and height, or one number for a square. World units or pixels per `material.sizeUnits`. Default 1. */
|
|
12
|
+
/** Width and height, or one number for a square. World units or CSS pixels per `material.sizeUnits`. Default 1. */
|
|
13
13
|
size?: number | readonly [number, number];
|
|
14
14
|
/** Radians counterclockwise in the screen plane, added to `material.rotation`. Default 0. */
|
|
15
15
|
rotation?: number;
|
package/dist/style.js
CHANGED
|
@@ -499,6 +499,7 @@ var D = /* @__PURE__ */ new WeakMap(), O = class {
|
|
|
499
499
|
}));
|
|
500
500
|
let n = e.filter ?? {};
|
|
501
501
|
if (typeof n != "object") throw TypeError("A point filter is not an object; pass an object of ranges");
|
|
502
|
+
for (let e of Object.keys(n)) if (e !== "ranges" && e !== "classification" && !T.includes(e)) throw TypeError(`Filter ${e} is not a LAS filter; put other columns under filter.ranges, as {ranges: {${e}: [min, max]}}`);
|
|
502
503
|
for (let e of T) n[e] !== void 0 && t.ranges.push([e, ...E(e, n[e])]);
|
|
503
504
|
for (let [e, r] of Object.entries(n.ranges ?? {})) t.ranges.push([e, ...E(e, r)]);
|
|
504
505
|
if (n.classification !== void 0) {
|
package/dist/surfels.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
// @margo/core-built
|
|
1
|
+
// @margo/core-built 1.0.0
|
|
2
2
|
import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
|
|
3
3
|
|
|
4
4
|
import { c as e, d as t, i as n, n as r, o as i, r as a, t as o, u as s } from "./tier-BcFbLPVT.js";
|
|
5
5
|
import { c, o as l, p as u, t as d, v as f, y as p } from "./cloud-B4O_G-Df.js";
|
|
6
|
-
import {
|
|
7
|
-
import { meshWorldMatrix as
|
|
6
|
+
import { _ as m, a as h, d as g, g as _, h as v, m as y, n as b, p as x, s as S, t as C } from "./shaders-DCnbvb0-.js";
|
|
7
|
+
import { meshWorldMatrix as w } from "@margoengine/math/mesh";
|
|
8
8
|
//#region src/surfels.ts
|
|
9
|
-
var
|
|
9
|
+
var T = 512, E = 1024, D = 224, O = 3e38, k = ((e) => ({
|
|
10
10
|
r: e[0] / 255,
|
|
11
11
|
g: e[1] / 255,
|
|
12
12
|
b: e[2] / 255,
|
|
13
13
|
a: e[3] / 255
|
|
14
|
-
}))(new Uint8Array(new Float32Array([
|
|
14
|
+
}))(new Uint8Array(new Float32Array([O]).buffer)), A = (e, t = e) => h + (e ? b : "") + y(3, 0) + `
|
|
15
15
|
struct Cloud{model:mat4x4f,color:vec4f,size:vec4f,flags:vec4u,blend:vec4f,planes:array<vec4f,6>}
|
|
16
16
|
@group(1) @binding(0) var<uniform> cloud:Cloud;
|
|
17
17
|
@group(1) @binding(1) var<storage,read> positions:array<f32>;
|
|
@@ -28,26 +28,26 @@ struct VOut{
|
|
|
28
28
|
@location(3) @interpolate(flat) reach:f32,
|
|
29
29
|
}
|
|
30
30
|
fn has(bit:u32)->bool{return (cloud.flags.x&bit)!=0u;}
|
|
31
|
-
${
|
|
31
|
+
${S}
|
|
32
32
|
fn disc(vi:u32,slot:u32,pushed:bool)->VOut{
|
|
33
33
|
var out:VOut;
|
|
34
34
|
var p=slot;
|
|
35
|
-
if(!has(${
|
|
35
|
+
if(!has(${C.direct}u)){p=order[slot];}
|
|
36
36
|
let center=cloud.model*vec4f(positions[p*3u],positions[p*3u+1u],positions[p*3u+2u],1.0);
|
|
37
37
|
let middle=frame.viewProj*center;
|
|
38
38
|
var color=vec4f(cloud.color.rgb,1.0);
|
|
39
|
-
if(has(${
|
|
39
|
+
if(has(${C.colors}u)){color*=pointColor(p);}
|
|
40
40
|
|
|
41
41
|
if(!(middle.w>1e-6)||color.a<=0.0||color.a<cloud.color.w){out.clip=vec4f(0.0,0.0,-1.0,1.0);return out;}
|
|
42
|
-
if(has(${
|
|
42
|
+
if(has(${E}u)){color=vec4f(mix(color.rgb,margoFog.color.rgb,fogAmount(center.xyz)),color.a);}
|
|
43
43
|
var size=cloud.size.x;
|
|
44
|
-
if(has(${
|
|
44
|
+
if(has(${C.sizes}u)){size*=sizes[p];}
|
|
45
45
|
let perUnit=frame.viewport.z/middle.w;
|
|
46
|
-
let px=clamp(select(size,size*perUnit,has(${
|
|
46
|
+
let px=clamp(select(size,size*perUnit,has(${C.world}u)),cloud.size.y,cloud.size.z);
|
|
47
47
|
let radius=0.5*px*cloud.size.w/perUnit;
|
|
48
48
|
var right=frame.right.xyz;
|
|
49
49
|
var up=frame.up.xyz;
|
|
50
|
-
if(has(${
|
|
50
|
+
if(has(${T}u)){
|
|
51
51
|
let m=(cloud.model*vec4f(normals[p*3u],normals[p*3u+1u],normals[p*3u+2u],0.0)).xyz;
|
|
52
52
|
if(dot(m,m)>1e-12){
|
|
53
53
|
let n=normalize(m);
|
|
@@ -89,7 +89,7 @@ ${t ? "struct Sums{@location(0) rg:vec4f,@location(1) ba:vec4f}" : ""}
|
|
|
89
89
|
let c=i.color.rgb*w;
|
|
90
90
|
return ${t ? "Sums(vec4f(c.rg,0.0,0.0),vec4f(c.b,w,0.0,0.0))" : "vec4f(c,w)"};
|
|
91
91
|
}
|
|
92
|
-
`,
|
|
92
|
+
`, j = A(!1), M = (e, t = !1) => h + `
|
|
93
93
|
@group(1) @binding(0) var sums:texture_2d<f32>;
|
|
94
94
|
${t ? "@group(1) @binding(1) var rest:texture_2d<f32>;" : ""}
|
|
95
95
|
const EDGE=0.25;
|
|
@@ -102,9 +102,9 @@ const EDGE=0.25;
|
|
|
102
102
|
if(sum.a<=0.0){discard;}
|
|
103
103
|
return encode(vec4f(sum.rgb/sum.a,clamp(sum.a/EDGE,0.0,1.0)));
|
|
104
104
|
}
|
|
105
|
-
`,
|
|
106
|
-
static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("
|
|
107
|
-
let n = new
|
|
105
|
+
`, N = M(), P = class h {coreRequirement=__margoCoreRequirement("1.0.0",import.meta.url);
|
|
106
|
+
static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
|
|
107
|
+
let n = new h(t);
|
|
108
108
|
return e.use(n), n;
|
|
109
109
|
}
|
|
110
110
|
constructor(t = {}) {
|
|
@@ -116,61 +116,61 @@ const EDGE=0.25;
|
|
|
116
116
|
}, this.clouds = /* @__PURE__ */ new Set(), this.cloudGpu = /* @__PURE__ */ new Map(), this.pipelines = /* @__PURE__ */ new Map(), this.resolves = /* @__PURE__ */ new Map(), this.fogSource = null, this.frameData = /* @__PURE__ */ new Float32Array(36), this.fogData = /* @__PURE__ */ new Float32Array(12), this.view = /* @__PURE__ */ new Float32Array(16), this.box = /* @__PURE__ */ new Float64Array(6), this.entryBlock = [], this.entryCount = [], this.entryWeight = [], this.allotment = /* @__PURE__ */ new Uint32Array(), this.draws = [], this.execute = (t) => {
|
|
117
117
|
let n = this.stats;
|
|
118
118
|
if (n.clouds = n.blocksVisible = n.pointsDrawn = n.drawCalls = 0, t.backend !== "webgpu" || !this.device || !this.gpu || !this.engine || t.device !== this.device || !this.clouds.size) return;
|
|
119
|
-
let r = this.engine, a = this.device, o = this.gpu, s = t.camera, u = this.frameData, [d,
|
|
120
|
-
a.queue.writeBuffer(o.frame, 0, u), this.fogSource && (
|
|
121
|
-
let
|
|
122
|
-
|
|
123
|
-
let
|
|
119
|
+
let r = this.engine, a = this.device, o = this.gpu, s = t.camera, u = this.frameData, [d, h] = e(t), g = m(u, this.view, s, d, h, t.format), y = _(r.canvas, t.width);
|
|
120
|
+
a.queue.writeBuffer(o.frame, 0, u), this.fogSource && (v(this.fogSource, s.position, this.fogData), a.queue.writeBuffer(o.fog, 0, this.fogData));
|
|
121
|
+
let b = this.entryBlock, x = this.entryCount, S = this.entryWeight, C = this.draws;
|
|
122
|
+
b.length = x.length = S.length = 0;
|
|
123
|
+
let T = 0;
|
|
124
124
|
for (let e of this.clouds) {
|
|
125
125
|
if (!e.visible || !e.count) continue;
|
|
126
|
-
let t = e.attachedMesh, i = t ?
|
|
126
|
+
let t = e.attachedMesh, i = t ? w(r, t) : e.matrix;
|
|
127
127
|
if (!i) continue;
|
|
128
128
|
e.material.validate();
|
|
129
129
|
let a = this.ensure(e);
|
|
130
|
-
this.flush(e, a), this.writeCloud(e, a, i), n.clouds++;
|
|
131
|
-
let o = e.blocks, l =
|
|
132
|
-
for (let t = 0; t < o.length; t++) o.counts[t] && (p(o.bounds, t, i, this.box), c(this.box, s.planes, e.cullMargin) && (
|
|
133
|
-
n.blocksVisible +=
|
|
130
|
+
this.flush(e, a), this.writeCloud(e, a, i, y), n.clouds++;
|
|
131
|
+
let o = e.blocks, l = b.length;
|
|
132
|
+
for (let t = 0; t < o.length; t++) o.counts[t] && (p(o.bounds, t, i, this.box), c(this.box, s.planes, e.cullMargin) && (b.push(t), x.push(o.counts[t]), S.push(f(this.box, s.position, u[18], u[16], u[17], g))));
|
|
133
|
+
n.blocksVisible += b.length - l, b.length > l && (C[T++] = {
|
|
134
134
|
cloud: e,
|
|
135
135
|
r: a,
|
|
136
136
|
first: l,
|
|
137
|
-
end:
|
|
137
|
+
end: b.length
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
|
-
if (!
|
|
141
|
-
this.allotment.length <
|
|
142
|
-
let
|
|
143
|
-
n.pointsDrawn = l(
|
|
144
|
-
let
|
|
140
|
+
if (!T) return;
|
|
141
|
+
this.allotment.length < b.length && (this.allotment = new Uint32Array(Math.max(16, b.length, this.allotment.length * 2)));
|
|
142
|
+
let E = this.allotment;
|
|
143
|
+
n.pointsDrawn = l(x, S, b.length, this.pointBudget, E);
|
|
144
|
+
let D = t, A = this.frameTargets(D), [j, M, N] = this.passes(D, A), P = t.descriptor.depthStencil.format.includes("stencil"), F = {
|
|
145
145
|
view: t.depth,
|
|
146
146
|
depthLoadOp: "load",
|
|
147
147
|
depthStoreOp: "store",
|
|
148
|
-
...
|
|
149
|
-
},
|
|
148
|
+
...P ? { stencilReadOnly: !0 } : {}
|
|
149
|
+
}, I = (e) => {
|
|
150
150
|
i(e, t), e.setBindGroup(0, o.frameGroup), e.setBindGroup(3, o.fogGroup);
|
|
151
|
-
for (let t = 0; t <
|
|
152
|
-
let { cloud: r, r: i, first: a, end: o } =
|
|
151
|
+
for (let t = 0; t < T; t++) {
|
|
152
|
+
let { cloud: r, r: i, first: a, end: o } = C[t];
|
|
153
153
|
e.setBindGroup(1, i.group);
|
|
154
|
-
for (let t = a; t < o; t++)
|
|
154
|
+
for (let t = a; t < o; t++) E[t] && (e.draw(4, E[t], 0, r.blocks.starts[b[t]]), n.drawCalls++);
|
|
155
155
|
}
|
|
156
156
|
e.end();
|
|
157
|
-
},
|
|
157
|
+
}, L = t.encoder.beginRenderPass({
|
|
158
158
|
colorAttachments: [{
|
|
159
|
-
view:
|
|
159
|
+
view: A.frontView,
|
|
160
160
|
loadOp: "clear",
|
|
161
161
|
storeOp: "store",
|
|
162
|
-
clearValue:
|
|
163
|
-
r:
|
|
162
|
+
clearValue: A.packed ? k : {
|
|
163
|
+
r: O,
|
|
164
164
|
g: 0,
|
|
165
165
|
b: 0,
|
|
166
166
|
a: 0
|
|
167
167
|
}
|
|
168
168
|
}],
|
|
169
|
-
depthStencilAttachment:
|
|
169
|
+
depthStencilAttachment: F
|
|
170
170
|
});
|
|
171
|
-
|
|
172
|
-
let
|
|
173
|
-
colorAttachments:
|
|
171
|
+
L.setPipeline(j), L.setBindGroup(2, A.depthGroup), I(L);
|
|
172
|
+
let R = t.encoder.beginRenderPass({
|
|
173
|
+
colorAttachments: A.sumsViews.map((e) => ({
|
|
174
174
|
view: e,
|
|
175
175
|
loadOp: "clear",
|
|
176
176
|
storeOp: "store",
|
|
@@ -181,17 +181,17 @@ const EDGE=0.25;
|
|
|
181
181
|
a: 0
|
|
182
182
|
}
|
|
183
183
|
})),
|
|
184
|
-
depthStencilAttachment:
|
|
184
|
+
depthStencilAttachment: F
|
|
185
185
|
});
|
|
186
|
-
|
|
187
|
-
let
|
|
186
|
+
R.setPipeline(M), R.setBindGroup(2, A.frontGroup), I(R);
|
|
187
|
+
let z = t.encoder.beginRenderPass({ colorAttachments: [{
|
|
188
188
|
view: t.color,
|
|
189
189
|
loadOp: "load",
|
|
190
190
|
storeOp: "store"
|
|
191
191
|
}] });
|
|
192
|
-
i(
|
|
193
|
-
for (let e of
|
|
194
|
-
|
|
192
|
+
i(z, t), z.setBindGroup(0, o.frameGroup), z.setBindGroup(1, A.sumsGroup);
|
|
193
|
+
for (let e of N) z.setPipeline(e), z.draw(3), n.drawCalls++;
|
|
194
|
+
z.end();
|
|
195
195
|
}, this.name = t.name ?? "surfels", this.order = t.order ?? 10, this.pointBudget = t.pointBudget ?? 1e6, this.overlap = t.overlap ?? 1.5, this.blendDepth = t.blendDepth ?? 1, !this.name || typeof this.name != "string" || !Number.isFinite(this.order)) throw TypeError("SurfelPlugin needs a non-empty string name and a finite order; fix the options.");
|
|
196
196
|
if (!(this.pointBudget >= 0) || !(this.overlap > 0) || !(this.blendDepth > 0)) throw RangeError("Invalid SurfelPlugin option; pointBudget must be 0 or more, overlap and blendDepth above 0");
|
|
197
197
|
}
|
|
@@ -202,7 +202,7 @@ const EDGE=0.25;
|
|
|
202
202
|
return this.fogSource;
|
|
203
203
|
}
|
|
204
204
|
setFog(e) {
|
|
205
|
-
return this.fogSource =
|
|
205
|
+
return this.fogSource = x(e), this;
|
|
206
206
|
}
|
|
207
207
|
add(e) {
|
|
208
208
|
if (!(e instanceof d)) throw TypeError("Expected a PointCloud; surfels draw point clouds only");
|
|
@@ -239,7 +239,7 @@ const EDGE=0.25;
|
|
|
239
239
|
}
|
|
240
240
|
}] }), l = a(144), u = a(48);
|
|
241
241
|
this.gpu = {
|
|
242
|
-
module: r.createShaderModule({ code:
|
|
242
|
+
module: r.createShaderModule({ code: j }),
|
|
243
243
|
frame: l,
|
|
244
244
|
frameLayout: s,
|
|
245
245
|
frameGroup: r.createBindGroup({
|
|
@@ -255,7 +255,7 @@ const EDGE=0.25;
|
|
|
255
255
|
visibility: i,
|
|
256
256
|
buffer: {
|
|
257
257
|
type: "uniform",
|
|
258
|
-
minBindingSize:
|
|
258
|
+
minBindingSize: D
|
|
259
259
|
}
|
|
260
260
|
},
|
|
261
261
|
o(1),
|
|
@@ -310,9 +310,9 @@ const EDGE=0.25;
|
|
|
310
310
|
});
|
|
311
311
|
return i && n.queue.writeBuffer(r, 0, e, 0, t / 4), r;
|
|
312
312
|
}, o = a(e.positions, i * 12), c = a(e.colors, i * 4 * e.colorStride), l = a(e.sizes, i * 4), u = a(e.direct ? null : e.blocks.order, i * 4), d = a(e.normals, i * 12), f = n.createBuffer({
|
|
313
|
-
size:
|
|
313
|
+
size: D,
|
|
314
314
|
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
315
|
-
}), p = /* @__PURE__ */ new ArrayBuffer(
|
|
315
|
+
}), p = /* @__PURE__ */ new ArrayBuffer(D);
|
|
316
316
|
return t = {
|
|
317
317
|
structure: e.structure,
|
|
318
318
|
uniform: f,
|
|
@@ -464,7 +464,7 @@ const EDGE=0.25;
|
|
|
464
464
|
u.cloudLayout,
|
|
465
465
|
this.textureLayout(n),
|
|
466
466
|
u.fogLayout
|
|
467
|
-
] }), f = e.descriptor.multisample, p = n > 1 || a ? l.createShaderModule({ code:
|
|
467
|
+
] }), f = e.descriptor.multisample, p = n > 1 || a ? l.createShaderModule({ code: F(A(a, r), n, !1) }) : u.module, m = (e, t, n, r) => l.createRenderPipeline({
|
|
468
468
|
layout: d,
|
|
469
469
|
vertex: {
|
|
470
470
|
module: p,
|
|
@@ -485,7 +485,7 @@ const EDGE=0.25;
|
|
|
485
485
|
depthWriteEnabled: r,
|
|
486
486
|
depthCompare: "greater-equal"
|
|
487
487
|
}
|
|
488
|
-
}),
|
|
488
|
+
}), h = m("vertexDepth", "fragmentDepth", [{ format: a ? "rgba8unorm" : "r32float" }], !0), _ = {
|
|
489
489
|
srcFactor: "one",
|
|
490
490
|
dstFactor: "one",
|
|
491
491
|
operation: "add"
|
|
@@ -508,31 +508,31 @@ const EDGE=0.25;
|
|
|
508
508
|
entryPoint: "fragment",
|
|
509
509
|
targets: [{
|
|
510
510
|
format: e.format,
|
|
511
|
-
blend:
|
|
511
|
+
blend: g
|
|
512
512
|
}]
|
|
513
513
|
},
|
|
514
514
|
primitive: { topology: "triangle-list" },
|
|
515
515
|
multisample: n
|
|
516
516
|
});
|
|
517
|
-
}, S = i ? Array.from({ length: n }, (e, t) => x(
|
|
517
|
+
}, S = i ? Array.from({ length: n }, (e, t) => x(F(M(t, r), n, !1), {
|
|
518
518
|
count: n,
|
|
519
519
|
mask: 1 << t
|
|
520
|
-
})) : [x(
|
|
521
|
-
return this.pipelines.set(`d${s}`,
|
|
522
|
-
|
|
520
|
+
})) : [x(F(N, n, !0), { count: n })];
|
|
521
|
+
return this.pipelines.set(`d${s}`, h), this.pipelines.set(`b${s}`, y), this.resolves.set(s, S), [
|
|
522
|
+
h,
|
|
523
523
|
y,
|
|
524
524
|
S
|
|
525
525
|
];
|
|
526
526
|
}
|
|
527
|
-
writeCloud(e, t, n) {
|
|
528
|
-
let
|
|
529
|
-
|
|
527
|
+
writeCloud(e, t, n, r) {
|
|
528
|
+
let i = e.material, a = t.floats, o = t.uints, s = i.clipping;
|
|
529
|
+
a.set(n, 0), a.set(i.color, 16), a[19] = i.alphaTest, a[20] = i.sizeUnits === "pixels" ? i.size * r : i.size, a[21] = i.minPixelSize * r, a[22] = i.maxPixelSize * r, a[23] = this.overlap, o[24] = (e.colors && i.vertexColors ? C.colors : 0) | (e.sizes ? C.sizes : 0) | (i.sizeUnits === "world" ? C.world : 0) | (e.direct ? C.direct : 0) | (e.colorSpace === "srgb" ? C.srgbColors : 0) | (e.colorFormat === "float" ? C.floatColors : 0) | (t.normals ? T : 0) | (this.fogSource && i.fog ? E : 0), o[25] = s.length / 4 + (i.clipIntersection ? 65536 : 0), o[26] = o[27] = 0, a[28] = this.blendDepth, a.set(s, 32), a.fill(0, 32 + s.length), this.device.queue.writeBuffer(t.uniform, 0, a);
|
|
530
530
|
}
|
|
531
531
|
};
|
|
532
|
-
function
|
|
532
|
+
function F(e, t, n) {
|
|
533
533
|
if (t === 1) return e;
|
|
534
534
|
let r = e.replaceAll("texture_2d<f32>", "texture_multisampled_2d<f32>");
|
|
535
535
|
return n ? r.replace("position:vec4f)", "position:vec4f,@builtin(sample_index) sample:u32)").replace("sums,q,0)", "sums,q,i32(sample))") : r;
|
|
536
536
|
}
|
|
537
537
|
//#endregion
|
|
538
|
-
export {
|
|
538
|
+
export { P as SurfelPlugin, N as resolveShader, j as surfelShader };
|