@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.
@@ -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 0.1.0
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 { a as m, d as h, g, h as _, m as v, n as y, p as b, s as x, t as S } from "./shaders-Deu8H36P.js";
7
- import { meshWorldMatrix as C } from "@margoengine/math/mesh";
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 w = 512, T = 1024, E = 224, D = 3e38, O = ((e) => ({
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([D]).buffer)), k = (e, t = e) => m + (e ? y : "") + v(3, 0) + `
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
- ${x}
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(${S.direct}u)){p=order[slot];}
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(${S.colors}u)){color*=pointColor(p);}
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(${T}u)){color=vec4f(mix(color.rgb,margoFog.color.rgb,fogAmount(center.xyz)),color.a);}
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(${S.sizes}u)){size*=sizes[p];}
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(${S.world}u)),cloud.size.y,cloud.size.z);
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(${w}u)){
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
- `, A = k(!1), j = (e, t = !1) => m + `
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
- `, M = j(), N = class m {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url);
106
- static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("0.1.0",import.meta.url));
107
- let n = new m(t);
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, m] = e(t), h = g(u, this.view, s, d, m, t.format);
120
- a.queue.writeBuffer(o.frame, 0, u), this.fogSource && (_(this.fogSource, s.position, this.fogData), a.queue.writeBuffer(o.fog, 0, this.fogData));
121
- let v = this.entryBlock, y = this.entryCount, b = this.entryWeight, x = this.draws;
122
- v.length = y.length = b.length = 0;
123
- let S = 0;
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 ? C(r, t) : e.matrix;
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 = v.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) && (v.push(t), y.push(o.counts[t]), b.push(f(this.box, s.position, u[18], u[16], u[17], h))));
133
- n.blocksVisible += v.length - l, v.length > l && (x[S++] = {
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: v.length
137
+ end: b.length
138
138
  });
139
139
  }
140
- if (!S) return;
141
- this.allotment.length < v.length && (this.allotment = new Uint32Array(Math.max(16, v.length, this.allotment.length * 2)));
142
- let w = this.allotment;
143
- n.pointsDrawn = l(y, b, v.length, this.pointBudget, w);
144
- let T = t, E = this.frameTargets(T), [k, A, j] = this.passes(T, E), M = t.descriptor.depthStencil.format.includes("stencil"), N = {
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
- ...M ? { stencilReadOnly: !0 } : {}
149
- }, P = (e) => {
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 < S; t++) {
152
- let { cloud: r, r: i, first: a, end: o } = x[t];
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++) w[t] && (e.draw(4, w[t], 0, r.blocks.starts[v[t]]), n.drawCalls++);
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
- }, F = t.encoder.beginRenderPass({
157
+ }, L = t.encoder.beginRenderPass({
158
158
  colorAttachments: [{
159
- view: E.frontView,
159
+ view: A.frontView,
160
160
  loadOp: "clear",
161
161
  storeOp: "store",
162
- clearValue: E.packed ? O : {
163
- r: D,
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: N
169
+ depthStencilAttachment: F
170
170
  });
171
- F.setPipeline(k), F.setBindGroup(2, E.depthGroup), P(F);
172
- let I = t.encoder.beginRenderPass({
173
- colorAttachments: E.sumsViews.map((e) => ({
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: N
184
+ depthStencilAttachment: F
185
185
  });
186
- I.setPipeline(A), I.setBindGroup(2, E.frontGroup), P(I);
187
- let L = t.encoder.beginRenderPass({ colorAttachments: [{
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(L, t), L.setBindGroup(0, o.frameGroup), L.setBindGroup(1, E.sumsGroup);
193
- for (let e of j) L.setPipeline(e), L.draw(3), n.drawCalls++;
194
- L.end();
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 = b(e), this;
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: A }),
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: E
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: E,
313
+ size: D,
314
314
  usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
315
- }), p = /* @__PURE__ */ new ArrayBuffer(E);
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: P(k(a, r), n, !1) }) : u.module, m = (e, t, n, r) => l.createRenderPipeline({
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
- }), g = m("vertexDepth", "fragmentDepth", [{ format: a ? "rgba8unorm" : "r32float" }], !0), _ = {
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: h
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(P(j(t, r), n, !1), {
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(P(M, n, !0), { count: n })];
521
- return this.pipelines.set(`d${s}`, g), this.pipelines.set(`b${s}`, y), this.resolves.set(s, S), [
522
- g,
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 r = e.material, i = t.floats, a = t.uints, o = r.clipping;
529
- i.set(n, 0), i.set(r.color, 16), i[19] = r.alphaTest, i[20] = r.size, i[21] = r.minPixelSize, i[22] = r.maxPixelSize, i[23] = this.overlap, a[24] = (e.colors && r.vertexColors ? S.colors : 0) | (e.sizes ? S.sizes : 0) | (r.sizeUnits === "world" ? S.world : 0) | (e.direct ? S.direct : 0) | (e.colorSpace === "srgb" ? S.srgbColors : 0) | (e.colorFormat === "float" ? S.floatColors : 0) | (t.normals ? w : 0) | (this.fogSource && r.fog ? T : 0), a[25] = o.length / 4 + (r.clipIntersection ? 65536 : 0), a[26] = a[27] = 0, i[28] = this.blendDepth, i.set(o, 32), i.fill(0, 32 + o.length), this.device.queue.writeBuffer(t.uniform, 0, i);
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 P(e, t, n) {
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 { N as SurfelPlugin, M as resolveShader, A as surfelShader };
538
+ export { P as SurfelPlugin, N as resolveShader, j as surfelShader };