fast-mesh-wasm 0.3.1 → 0.5.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/README.md +5 -2
- package/dist/{client-Bp9FRd70.js → client-CE6RvmvB.js} +42 -8
- package/dist/{client-m2zSdFlu.d.ts → client-pv0Fwvl4.d.ts} +8 -2
- package/dist/{colormap-D_xH5hI5.js → colormap-DxGMYVfs.js} +1 -1
- package/dist/{engine-BpnthBYQ.js → engine-DLQAL9GT.js} +82 -31
- package/dist/{mesh-B16gV3oX.d.ts → mesh-RtPVmPQy.d.ts} +8 -1
- package/dist/{mesh-B8pae8WA.js → mesh-zj7-wJBw.js} +52 -5
- package/dist/node.d.ts +2 -2
- package/dist/node.js +1 -1
- package/dist/{protocol-CAUYm1gd.js → protocol-DkhGNP0h.js} +6 -4
- package/dist/{protocol-W9R-iGl5.d.ts → protocol-z-jeCUGO.d.ts} +11 -1
- package/dist/r3f.d.ts +3 -3
- package/dist/r3f.js +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/{scene-BFd6nYRe.js → scene-DyYdEQdy.js} +177 -13
- package/dist/{scene-like-B_3qm0u6.d.ts → scene-like-YcY08oii.d.ts} +140 -7
- package/dist/{store-DNnHN33A.d.ts → store-C5nzCpxy.d.ts} +2 -2
- package/dist/{store-D3ErV6o-.js → store-Z6A2HPih.js} +3 -3
- package/dist/store.d.ts +2 -2
- package/dist/store.js +1 -1
- package/dist/three.d.ts +7 -6
- package/dist/three.js +7 -2
- package/dist/{views-BaZqBxlX.js → views-Dh3aWc2q.js} +1 -1
- package/dist/wasm/fast_mesh_wasm.d.ts +53 -12
- package/dist/wasm/fast_mesh_wasm.js +107 -20
- package/dist/wasm/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm/fast_mesh_wasm_bg.wasm.d.ts +6 -1
- package/dist/wasm-threads/fast_mesh_wasm.d.ts +53 -12
- package/dist/wasm-threads/fast_mesh_wasm.js +107 -20
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm.d.ts +6 -1
- package/dist/web.d.ts +2 -2
- package/dist/web.js +1 -1
- package/dist/worker-engine.d.ts +7 -5
- package/dist/worker-engine.js +1 -1
- package/dist/worker-entry.js +1 -1
- package/dist/worker.d.ts +1 -1
- package/dist/worker.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as release, c as wasmMemory, i as finalizer, n as call, r as ensureInitialized, t as FastMeshError } from "./core-Cke_kZ2e.js";
|
|
2
|
-
import { a as FieldHandle, c as rotationMatrix, i as encodeRule, l as targetsOf, n as meshViews, o as MeshHandle, r as copyRule, s as SectionHandle, t as ViewGuard } from "./views-
|
|
2
|
+
import { a as FieldHandle, c as rotationMatrix, i as encodeRule, l as targetsOf, n as meshViews, o as MeshHandle, r as copyRule, s as SectionHandle, t as ViewGuard } from "./views-Dh3aWc2q.js";
|
|
3
3
|
import { WasmScene } from "./wasm/fast_mesh_wasm.js";
|
|
4
4
|
//#region src/changes.ts
|
|
5
5
|
const ADDED = 1;
|
|
@@ -78,6 +78,11 @@ const MODES = {
|
|
|
78
78
|
lazy: 1,
|
|
79
79
|
manual: 2
|
|
80
80
|
};
|
|
81
|
+
const MODE_NAMES = [
|
|
82
|
+
"eager",
|
|
83
|
+
"lazy",
|
|
84
|
+
"manual"
|
|
85
|
+
];
|
|
81
86
|
function modeCode(mode) {
|
|
82
87
|
if (!Object.hasOwn(MODES, mode)) throw invalid("mode must be \"eager\", \"lazy\" or \"manual\"");
|
|
83
88
|
return MODES[mode];
|
|
@@ -197,7 +202,15 @@ const REPAIR_CODES = {
|
|
|
197
202
|
removeDegenerate: 1,
|
|
198
203
|
removeSmallComponents: 2,
|
|
199
204
|
orient: 3,
|
|
200
|
-
fillHoles: 4
|
|
205
|
+
fillHoles: 4,
|
|
206
|
+
inflate: 5,
|
|
207
|
+
smooth: 6,
|
|
208
|
+
remesh: 7,
|
|
209
|
+
bridgeLoops: 8
|
|
210
|
+
};
|
|
211
|
+
const FALLOFF_CODES = {
|
|
212
|
+
linear: 0,
|
|
213
|
+
smooth: 1
|
|
201
214
|
};
|
|
202
215
|
/** An optional number for the binding: NaN when unset; an explicit NaN is rejected. */
|
|
203
216
|
function optional(v, what) {
|
|
@@ -208,6 +221,16 @@ function optional(v, what) {
|
|
|
208
221
|
function flagOf(v, fallback) {
|
|
209
222
|
return v ?? fallback ? 1 : 0;
|
|
210
223
|
}
|
|
224
|
+
/** A brush center as 3 values; anything else is `INVALID_ARGUMENT`. */
|
|
225
|
+
function centerOf(center, values) {
|
|
226
|
+
const c = center;
|
|
227
|
+
if (c?.length !== 3 || ![
|
|
228
|
+
c[0],
|
|
229
|
+
c[1],
|
|
230
|
+
c[2]
|
|
231
|
+
].every(Number.isFinite)) throw invalid("center must be 3 finite numbers");
|
|
232
|
+
values.push(c[0], c[1], c[2]);
|
|
233
|
+
}
|
|
211
234
|
/** A loop id as the binding's `minVertex, len, hash low, hash high`. */
|
|
212
235
|
function encodeLoopId(id, out) {
|
|
213
236
|
const { minVertex, len, hash } = id ?? {};
|
|
@@ -239,9 +262,25 @@ function encodeRepair(ops) {
|
|
|
239
262
|
count = o.loops.length;
|
|
240
263
|
for (const id of o.loops) encodeLoopId(id, loops);
|
|
241
264
|
}
|
|
242
|
-
values.push(optional(o.maxEdges, "maxEdges"), optional(o.maxPerimeter, "maxPerimeter"), optional(o.maxArea, "maxArea"), count, flagOf(o.allowUnclean, false), flagOf(o.fair, true), optional(o.dpLimit, "dpLimit"));
|
|
265
|
+
values.push(optional(o.maxEdges, "maxEdges"), optional(o.maxPerimeter, "maxPerimeter"), optional(o.maxArea, "maxArea"), count, flagOf(o.allowUnclean, false), flagOf(o.fair, true), optional(o.dpLimit, "dpLimit"), optional(o.maxDihedral, "maxDihedral"), optional(o.maxRefineVertices, "maxRefineVertices"));
|
|
243
266
|
break;
|
|
244
267
|
}
|
|
268
|
+
case "inflate":
|
|
269
|
+
centerOf(o.center, values);
|
|
270
|
+
values.push(optional(o.radius, "radius"), codeIn(FALLOFF_CODES, o.falloff, "falloff"), optional(o.strength, "strength"));
|
|
271
|
+
break;
|
|
272
|
+
case "smooth":
|
|
273
|
+
centerOf(o.center, values);
|
|
274
|
+
values.push(optional(o.radius, "radius"), codeIn(FALLOFF_CODES, o.falloff, "falloff"), optional(o.strength, "strength"), optional(o.cycles, "cycles"));
|
|
275
|
+
break;
|
|
276
|
+
case "remesh":
|
|
277
|
+
centerOf(o.center, values);
|
|
278
|
+
values.push(optional(o.radius, "radius"), optional(o.targetLength, "targetLength"), optional(o.maxRounds, "maxRounds"));
|
|
279
|
+
break;
|
|
280
|
+
case "bridgeLoops":
|
|
281
|
+
if (!Array.isArray(o.loops) || o.loops.length !== 2) throw invalid("loops must be an array of two loop ids");
|
|
282
|
+
values.push(optional(o.maxEdges, "maxEdges"));
|
|
283
|
+
for (const id of o.loops) encodeLoopId(id, loops);
|
|
245
284
|
}
|
|
246
285
|
}
|
|
247
286
|
return {
|
|
@@ -326,7 +365,8 @@ function decodeReport(op, r) {
|
|
|
326
365
|
trianglesAdded: r.next(),
|
|
327
366
|
verticesAdded: r.next(),
|
|
328
367
|
converged: r.flag(),
|
|
329
|
-
weights: WEIGHTS[r.next()]
|
|
368
|
+
weights: WEIGHTS[r.next()],
|
|
369
|
+
refineCapped: r.flag()
|
|
330
370
|
})),
|
|
331
371
|
skipped: r.many(() => ({
|
|
332
372
|
id: r.loopId(),
|
|
@@ -337,6 +377,21 @@ function decodeReport(op, r) {
|
|
|
337
377
|
reason: FAIL_REASONS[r.next()]
|
|
338
378
|
}))
|
|
339
379
|
};
|
|
380
|
+
case "inflate": return {
|
|
381
|
+
moved: r.next(),
|
|
382
|
+
maxDisplacement: r.next()
|
|
383
|
+
};
|
|
384
|
+
case "smooth": return {
|
|
385
|
+
moved: r.next(),
|
|
386
|
+
maxDisplacement: r.next()
|
|
387
|
+
};
|
|
388
|
+
case "remesh": return {
|
|
389
|
+
splits: r.next(),
|
|
390
|
+
collapses: r.next(),
|
|
391
|
+
flips: r.next(),
|
|
392
|
+
rounds: r.next()
|
|
393
|
+
};
|
|
394
|
+
case "bridgeLoops": return { trianglesAdded: r.next() };
|
|
340
395
|
}
|
|
341
396
|
}
|
|
342
397
|
/** An analysis result; see `encode_analysis` in the Rust crate. */
|
|
@@ -559,6 +614,35 @@ var Scene = class {
|
|
|
559
614
|
this.#removed.set(key, mesh);
|
|
560
615
|
}
|
|
561
616
|
/**
|
|
617
|
+
* Joins `source` into `target`: copies the source's geometry into the
|
|
618
|
+
* target (keeping its world shape), bridges `options.loopA` to the copied
|
|
619
|
+
* `options.loopB`, and removes the source. The copy and the bridge undo as
|
|
620
|
+
* one step; the removal is permanent. A drag of the source ends first,
|
|
621
|
+
* recording its moves as one step, so they survive a failed join.
|
|
622
|
+
*
|
|
623
|
+
* @throws `UNKNOWN_MESH` for a removed handle; `INVALID_ARGUMENT` for one
|
|
624
|
+
* mesh twice or loops that cannot bridge; `STALE_LOOPS` for a loop that is
|
|
625
|
+
* not there. A failed join changes nothing.
|
|
626
|
+
*/
|
|
627
|
+
join(target, source, options) {
|
|
628
|
+
const ta = this.#id(target);
|
|
629
|
+
const sb = this.#id(source);
|
|
630
|
+
const loops = [];
|
|
631
|
+
encodeLoopId(options.loopA, loops);
|
|
632
|
+
encodeLoopId(options.loopB, loops);
|
|
633
|
+
const maxEdges = optional(options.maxEdges, "maxEdges");
|
|
634
|
+
if (this.#drag?.mesh === source) this.#drag.end();
|
|
635
|
+
const r = call(() => this.#scene().join(ta.index, ta.generation, sb.index, sb.generation, Uint32Array.from(loops), maxEdges));
|
|
636
|
+
const key = `${sb.index}:${sb.generation}`;
|
|
637
|
+
this.#meshes.delete(key);
|
|
638
|
+
this.#removed.set(key, source);
|
|
639
|
+
return {
|
|
640
|
+
verticesAdded: r[0],
|
|
641
|
+
trianglesAdded: r[1],
|
|
642
|
+
bridgeTrianglesAdded: r[2]
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
562
646
|
* Sets a mesh's placement: world = rotation · local + translation, where
|
|
563
647
|
* local is relative to the mesh origin. A quaternion is normalised and
|
|
564
648
|
* converted in double precision.
|
|
@@ -599,6 +683,47 @@ var Scene = class {
|
|
|
599
683
|
const m = modeCode(mode);
|
|
600
684
|
call(() => this.#scene().set_mode(index, generation, m));
|
|
601
685
|
}
|
|
686
|
+
/** When the mesh's derived data follows its edits; see {@link UpdateMode}. */
|
|
687
|
+
mode(mesh) {
|
|
688
|
+
const { index, generation } = this.#id(mesh);
|
|
689
|
+
const code = call(() => this.#peek().mode(index, generation));
|
|
690
|
+
return MODE_NAMES[code] ?? "eager";
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* The box around the vertices the live triangles use, in the mesh's local
|
|
694
|
+
* render coordinates ({@link Scene.matrix4} maps them to the world). Dead
|
|
695
|
+
* slots keep stale positions, so they are excluded. `null` without live
|
|
696
|
+
* triangles.
|
|
697
|
+
*/
|
|
698
|
+
bounds(mesh) {
|
|
699
|
+
const { index, generation } = this.#id(mesh);
|
|
700
|
+
const b = call(() => this.#peek().bounds(index, generation));
|
|
701
|
+
if (b.length === 0) return null;
|
|
702
|
+
const min = [
|
|
703
|
+
b[0],
|
|
704
|
+
b[1],
|
|
705
|
+
b[2]
|
|
706
|
+
];
|
|
707
|
+
const max = [
|
|
708
|
+
b[3],
|
|
709
|
+
b[4],
|
|
710
|
+
b[5]
|
|
711
|
+
];
|
|
712
|
+
return {
|
|
713
|
+
min,
|
|
714
|
+
max,
|
|
715
|
+
center: [
|
|
716
|
+
(min[0] + max[0]) / 2,
|
|
717
|
+
(min[1] + max[1]) / 2,
|
|
718
|
+
(min[2] + max[2]) / 2
|
|
719
|
+
],
|
|
720
|
+
size: [
|
|
721
|
+
max[0] - min[0],
|
|
722
|
+
max[1] - min[1],
|
|
723
|
+
max[2] - min[2]
|
|
724
|
+
]
|
|
725
|
+
};
|
|
726
|
+
}
|
|
602
727
|
/** Brings the mesh's derived data up to date now, whatever its mode. */
|
|
603
728
|
update(mesh) {
|
|
604
729
|
const { index, generation } = this.#id(mesh);
|
|
@@ -645,6 +770,7 @@ var Scene = class {
|
|
|
645
770
|
* {@link Scene.commitFrame} instead.
|
|
646
771
|
*/
|
|
647
772
|
takeChanges() {
|
|
773
|
+
this.#drag?.applyPending();
|
|
648
774
|
const s = this.#scene();
|
|
649
775
|
const raw = decodeChanges(call(() => s.take_changes()));
|
|
650
776
|
const out = raw.map((c) => ({
|
|
@@ -742,6 +868,8 @@ var Scene = class {
|
|
|
742
868
|
/** Ends one nesting level of the open step. Throws `STEP_NOT_OPEN` when none is open. */
|
|
743
869
|
endStep() {
|
|
744
870
|
const s = this.#scene();
|
|
871
|
+
const drag = this.#drag;
|
|
872
|
+
if (drag !== void 0 && this.#stepDepth > 0 && this.#stepDepth <= drag.depth) drag.applyPending();
|
|
745
873
|
call(() => s.end_step());
|
|
746
874
|
this.#stepDepth--;
|
|
747
875
|
if (this.#drag !== void 0 && this.#stepDepth < this.#drag.depth) this.#drag.abandon();
|
|
@@ -757,16 +885,20 @@ var Scene = class {
|
|
|
757
885
|
* Starts dragging a mesh: the moves until {@link DragSession.end} form one
|
|
758
886
|
* undo step (nested in the open step, if there is one). One drag at a time.
|
|
759
887
|
* Every {@link DragSession.move} recomputes the eager fields, so make at most
|
|
760
|
-
* one move per animation frame, with the latest pointer pose
|
|
888
|
+
* one move per animation frame, with the latest pointer pose, or pass
|
|
889
|
+
* `{ coalesce: true }` to have the drag do that for you.
|
|
761
890
|
*/
|
|
762
|
-
drag(mesh) {
|
|
891
|
+
drag(mesh, options = {}) {
|
|
763
892
|
this.#id(mesh);
|
|
764
893
|
if (this.#drag !== void 0) throw invalid("a drag is already active; end or cancel it first");
|
|
894
|
+
const coalesce = options.coalesce ?? false;
|
|
765
895
|
const start = this.placement(mesh);
|
|
766
896
|
const outermost = this.#stepDepth === 0;
|
|
767
897
|
this.beginStep();
|
|
768
898
|
const depth = this.#stepDepth;
|
|
769
899
|
let active = true;
|
|
900
|
+
/** The latest coalesced pose, not yet applied. */
|
|
901
|
+
let pending;
|
|
770
902
|
const finish = () => {
|
|
771
903
|
if (!active) return false;
|
|
772
904
|
active = false;
|
|
@@ -776,6 +908,13 @@ var Scene = class {
|
|
|
776
908
|
const close = () => {
|
|
777
909
|
while (this.#stepDepth >= depth) this.endStep();
|
|
778
910
|
};
|
|
911
|
+
const applyPending = () => {
|
|
912
|
+
if (pending !== void 0) {
|
|
913
|
+
const pose = pending;
|
|
914
|
+
pending = void 0;
|
|
915
|
+
this.setPlacement(mesh, pose);
|
|
916
|
+
}
|
|
917
|
+
};
|
|
779
918
|
const session = {
|
|
780
919
|
depth,
|
|
781
920
|
mesh,
|
|
@@ -784,13 +923,37 @@ var Scene = class {
|
|
|
784
923
|
},
|
|
785
924
|
move: (placement) => {
|
|
786
925
|
if (!active) throw invalid("the drag is over");
|
|
787
|
-
|
|
926
|
+
if (!coalesce) {
|
|
927
|
+
this.setPlacement(mesh, placement);
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
const rotation = rotationMatrix(placement.rotation);
|
|
931
|
+
if (!rotation.every(Number.isFinite)) throw invalid("rotation must be finite numbers");
|
|
932
|
+
const t = placement.translation;
|
|
933
|
+
if (t?.length !== 3 || ![
|
|
934
|
+
t[0],
|
|
935
|
+
t[1],
|
|
936
|
+
t[2]
|
|
937
|
+
].every(Number.isFinite)) throw invalid("translation must be 3 finite numbers");
|
|
938
|
+
pending = {
|
|
939
|
+
rotation,
|
|
940
|
+
translation: [
|
|
941
|
+
t[0],
|
|
942
|
+
t[1],
|
|
943
|
+
t[2]
|
|
944
|
+
]
|
|
945
|
+
};
|
|
788
946
|
},
|
|
789
947
|
end: () => {
|
|
790
|
-
if (finish())
|
|
948
|
+
if (finish()) try {
|
|
949
|
+
applyPending();
|
|
950
|
+
} finally {
|
|
951
|
+
close();
|
|
952
|
+
}
|
|
791
953
|
},
|
|
792
954
|
cancel: () => {
|
|
793
955
|
if (!finish()) return;
|
|
956
|
+
pending = void 0;
|
|
794
957
|
if (outermost) {
|
|
795
958
|
this.cancelStep();
|
|
796
959
|
return;
|
|
@@ -803,7 +966,8 @@ var Scene = class {
|
|
|
803
966
|
},
|
|
804
967
|
abandon: () => {
|
|
805
968
|
finish();
|
|
806
|
-
}
|
|
969
|
+
},
|
|
970
|
+
applyPending
|
|
807
971
|
};
|
|
808
972
|
this.#drag = session;
|
|
809
973
|
return session;
|
|
@@ -1088,14 +1252,14 @@ var Scene = class {
|
|
|
1088
1252
|
}
|
|
1089
1253
|
static {
|
|
1090
1254
|
meshAddsOf = (scene) => ({
|
|
1091
|
-
|
|
1255
|
+
beginUpload: (vertices, triangles, options = {}) => {
|
|
1092
1256
|
const s = scene.#scene();
|
|
1093
1257
|
const mode = modeCode(options.mode ?? "eager");
|
|
1094
1258
|
const origin = options.origin === void 0 ? void 0 : Float64Array.from(options.origin);
|
|
1095
|
-
|
|
1096
|
-
const i = toUint32(indices);
|
|
1097
|
-
return call(() => s.begin_add_mesh(p, i, origin, mode, options.normals ?? true));
|
|
1259
|
+
return call(() => s.begin_add_mesh_upload(vertices, triangles, origin, mode, options.normals ?? true));
|
|
1098
1260
|
},
|
|
1261
|
+
pushPositions: (token, chunk) => call(() => scene.#scene().add_mesh_push_positions(token, chunk)),
|
|
1262
|
+
pushIndices: (token, chunk) => call(() => scene.#scene().add_mesh_push_indices(token, chunk)),
|
|
1099
1263
|
step: (token, budget) => call(() => scene.#scene().add_mesh_step(token, budget)),
|
|
1100
1264
|
buffers: (token) => {
|
|
1101
1265
|
const [pp, pl, np, nl, ip, il] = call(() => scene.#peek().add_mesh_buffers(token));
|
|
@@ -167,6 +167,8 @@ interface MeshChange {
|
|
|
167
167
|
* The drag is over once it is ended or cancelled, and also when its step goes
|
|
168
168
|
* away without it: an `undo()`, `redo()`, `clearHistory()` or `removeMesh()` of
|
|
169
169
|
* the dragged mesh ends it first, and a `cancelStep()` (or an `endStep()` that closes the drag's step) abandons it.
|
|
170
|
+
* An `endStep()` lands a pending coalesced pose in the closing step first; a
|
|
171
|
+
* `cancelStep()` drops it with the step.
|
|
170
172
|
*/
|
|
171
173
|
interface DragSession {
|
|
172
174
|
/**
|
|
@@ -174,7 +176,8 @@ interface DragSession {
|
|
|
174
176
|
*
|
|
175
177
|
* Each move recomputes the eager fields that depend on the mesh, so
|
|
176
178
|
* coalesce pointer events to one move per animation frame (keep the latest
|
|
177
|
-
* pose and apply it before {@link Scene.commitFrame})
|
|
179
|
+
* pose and apply it before {@link Scene.commitFrame}), or start the drag
|
|
180
|
+
* with {@link DragOptions.coalesce}.
|
|
178
181
|
*/
|
|
179
182
|
move(placement: PlacementInput): void;
|
|
180
183
|
/**
|
|
@@ -199,6 +202,18 @@ interface DragSession {
|
|
|
199
202
|
*/
|
|
200
203
|
cancel(): void;
|
|
201
204
|
}
|
|
205
|
+
/** Options of {@link Scene.drag}. */
|
|
206
|
+
interface DragOptions {
|
|
207
|
+
/**
|
|
208
|
+
* Coalesce moves: each {@link DragSession.move} only remembers its pose,
|
|
209
|
+
* and the latest one is applied once at the next {@link Scene.commitFrame}
|
|
210
|
+
* (or {@link DragSession.end}). For pointer events at 120–250 Hz: without
|
|
211
|
+
* it, every move recomputes the eager fields. Until the frame,
|
|
212
|
+
* {@link Scene.placement} and {@link Scene.matrix4} show the last applied
|
|
213
|
+
* pose. `WorkerScene` drags always coalesce. Defaults to `false`.
|
|
214
|
+
*/
|
|
215
|
+
coalesce?: boolean;
|
|
216
|
+
}
|
|
202
217
|
/** Options of {@link Scene.addMesh}. */
|
|
203
218
|
interface AddMeshOptions {
|
|
204
219
|
/**
|
|
@@ -379,7 +394,10 @@ interface SectionDesc {
|
|
|
379
394
|
}
|
|
380
395
|
/** One chain of a section: a closed loop or an open polyline. */
|
|
381
396
|
interface SectionContour {
|
|
382
|
-
/**
|
|
397
|
+
/**
|
|
398
|
+
* World xyz, 3 floats per point. A copy. Where the plane passes exactly
|
|
399
|
+
* through a vertex, the contour repeats that point (a zero-length segment).
|
|
400
|
+
*/
|
|
383
401
|
points: Float32Array;
|
|
384
402
|
closed: boolean;
|
|
385
403
|
}
|
|
@@ -551,6 +569,43 @@ type RepairOp = {
|
|
|
551
569
|
allowUnclean?: boolean;
|
|
552
570
|
fair?: boolean;
|
|
553
571
|
dpLimit?: number;
|
|
572
|
+
/** Reject a minimum-weight triangulation past this dihedral, in radians. */
|
|
573
|
+
maxDihedral?: number;
|
|
574
|
+
/** Stop refining a patch once it has this many new vertices. */
|
|
575
|
+
maxRefineVertices?: number;
|
|
576
|
+
} | {
|
|
577
|
+
op: "inflate";
|
|
578
|
+
/** Brush center in local mesh coordinates, as in `views(mesh).positions()`. */
|
|
579
|
+
center: Readonly<Vec3>;
|
|
580
|
+
radius: number;
|
|
581
|
+
falloff: "linear" | "smooth";
|
|
582
|
+
/** Displacement scale; negative pulls instead of pushing. */
|
|
583
|
+
strength: number;
|
|
584
|
+
} | {
|
|
585
|
+
op: "smooth";
|
|
586
|
+
/** Brush center in local mesh coordinates, as in `views(mesh).positions()`. */
|
|
587
|
+
center: Readonly<Vec3>;
|
|
588
|
+
radius: number;
|
|
589
|
+
falloff: "linear" | "smooth";
|
|
590
|
+
/** Displacement scale; the per-vertex weight is `strength * falloff`. */
|
|
591
|
+
strength: number;
|
|
592
|
+
/** How many Taubin λ/μ cycles to run; 0 moves nothing. */
|
|
593
|
+
cycles: number;
|
|
594
|
+
} | {
|
|
595
|
+
op: "remesh";
|
|
596
|
+
/** Region center in local mesh coordinates, as in `views(mesh).positions()`. */
|
|
597
|
+
center: Readonly<Vec3>;
|
|
598
|
+
radius: number;
|
|
599
|
+
/** Target edge length; unset means the mesh-wide mean edge length. */
|
|
600
|
+
targetLength?: number;
|
|
601
|
+
/** Maximum split/collapse/flip rounds; unset means the default (10). */
|
|
602
|
+
maxRounds?: number;
|
|
603
|
+
} | {
|
|
604
|
+
op: "bridgeLoops";
|
|
605
|
+
/** The two loops to connect, from `analyze(mesh).loops`. Order is insignificant. */
|
|
606
|
+
loops: readonly [LoopId, LoopId];
|
|
607
|
+
/** Maximum vertices per loop; unset means the default (128). */
|
|
608
|
+
maxEdges?: number;
|
|
554
609
|
};
|
|
555
610
|
/** What `weld` did. */
|
|
556
611
|
interface WeldReport {
|
|
@@ -586,6 +641,8 @@ interface FilledLoop {
|
|
|
586
641
|
converged: boolean;
|
|
587
642
|
/** The Laplacian weights fairing used; `null` when it did not run. */
|
|
588
643
|
weights: "cotangent" | "uniform" | null;
|
|
644
|
+
/** Whether refinement stopped early on its vertex budget or rounds. */
|
|
645
|
+
refineCapped: boolean;
|
|
589
646
|
}
|
|
590
647
|
/** What `fillHoles` did, each list in loop order. */
|
|
591
648
|
interface FillReport {
|
|
@@ -601,8 +658,47 @@ interface FillReport {
|
|
|
601
658
|
reason: "projectionFolds" | "noValidTriangulation" | "solver";
|
|
602
659
|
}[];
|
|
603
660
|
}
|
|
661
|
+
/** What `inflate` did. */
|
|
662
|
+
interface InflateReport {
|
|
663
|
+
moved: number;
|
|
664
|
+
maxDisplacement: number;
|
|
665
|
+
}
|
|
666
|
+
/** What `smooth` did. */
|
|
667
|
+
interface SmoothReport {
|
|
668
|
+
moved: number;
|
|
669
|
+
maxDisplacement: number;
|
|
670
|
+
}
|
|
671
|
+
/** What `remesh` did. */
|
|
672
|
+
interface RemeshReport {
|
|
673
|
+
splits: number;
|
|
674
|
+
collapses: number;
|
|
675
|
+
flips: number;
|
|
676
|
+
rounds: number;
|
|
677
|
+
}
|
|
678
|
+
/** What `bridgeLoops` did. */
|
|
679
|
+
interface BridgeReport {
|
|
680
|
+
trianglesAdded: number;
|
|
681
|
+
}
|
|
682
|
+
/** Options of {@link Scene.join}. */
|
|
683
|
+
interface JoinOptions {
|
|
684
|
+
/** The loop on the target, from `analyze(target).loops`. */
|
|
685
|
+
loopA: LoopId;
|
|
686
|
+
/** The loop on the source, from `analyze(source).loops`. */
|
|
687
|
+
loopB: LoopId;
|
|
688
|
+
/** Maximum vertices per loop; unset means the default (128). */
|
|
689
|
+
maxEdges?: number;
|
|
690
|
+
}
|
|
691
|
+
/** What {@link Scene.join} did. */
|
|
692
|
+
interface JoinReport {
|
|
693
|
+
/** Source vertices copied into the target. */
|
|
694
|
+
verticesAdded: number;
|
|
695
|
+
/** Source triangles copied into the target. */
|
|
696
|
+
trianglesAdded: number;
|
|
697
|
+
/** Bridge triangles between the two loops. */
|
|
698
|
+
bridgeTrianglesAdded: number;
|
|
699
|
+
}
|
|
604
700
|
/** The report of a {@link RepairOp}. */
|
|
605
|
-
type RepairReport = WeldReport | DegenerateReport | RemoveReport | OrientReport | FillReport;
|
|
701
|
+
type RepairReport = WeldReport | DegenerateReport | RemoveReport | OrientReport | FillReport | InflateReport | SmoothReport | RemeshReport | BridgeReport;
|
|
606
702
|
/** The report type of a repair op. */
|
|
607
703
|
type RepairReportOf<O extends RepairOp> = O extends {
|
|
608
704
|
op: "weld";
|
|
@@ -614,7 +710,15 @@ type RepairReportOf<O extends RepairOp> = O extends {
|
|
|
614
710
|
op: "orient";
|
|
615
711
|
} ? OrientReport : O extends {
|
|
616
712
|
op: "fillHoles";
|
|
617
|
-
} ? FillReport :
|
|
713
|
+
} ? FillReport : O extends {
|
|
714
|
+
op: "inflate";
|
|
715
|
+
} ? InflateReport : O extends {
|
|
716
|
+
op: "smooth";
|
|
717
|
+
} ? SmoothReport : O extends {
|
|
718
|
+
op: "remesh";
|
|
719
|
+
} ? RemeshReport : O extends {
|
|
720
|
+
op: "bridgeLoops";
|
|
721
|
+
} ? BridgeReport : RepairReport;
|
|
618
722
|
/**
|
|
619
723
|
* A scene of editable meshes. Create it after `await init()`; release it with
|
|
620
724
|
* {@link Scene.free} or a `using` declaration (otherwise it is freed when
|
|
@@ -647,6 +751,18 @@ declare class Scene implements SceneLike {
|
|
|
647
751
|
* (the drag's included) are then dropped with it.
|
|
648
752
|
*/
|
|
649
753
|
removeMesh(mesh: MeshHandle): void;
|
|
754
|
+
/**
|
|
755
|
+
* Joins `source` into `target`: copies the source's geometry into the
|
|
756
|
+
* target (keeping its world shape), bridges `options.loopA` to the copied
|
|
757
|
+
* `options.loopB`, and removes the source. The copy and the bridge undo as
|
|
758
|
+
* one step; the removal is permanent. A drag of the source ends first,
|
|
759
|
+
* recording its moves as one step, so they survive a failed join.
|
|
760
|
+
*
|
|
761
|
+
* @throws `UNKNOWN_MESH` for a removed handle; `INVALID_ARGUMENT` for one
|
|
762
|
+
* mesh twice or loops that cannot bridge; `STALE_LOOPS` for a loop that is
|
|
763
|
+
* not there. A failed join changes nothing.
|
|
764
|
+
*/
|
|
765
|
+
join(target: MeshHandle, source: MeshHandle, options: JoinOptions): JoinReport;
|
|
650
766
|
/**
|
|
651
767
|
* Sets a mesh's placement: world = rotation · local + translation, where
|
|
652
768
|
* local is relative to the mesh origin. A quaternion is normalised and
|
|
@@ -665,6 +781,15 @@ declare class Scene implements SceneLike {
|
|
|
665
781
|
matrix4(mesh: MeshHandle): Float64Array;
|
|
666
782
|
/** Sets when the mesh's derived data follows its edits; see {@link UpdateMode}. */
|
|
667
783
|
setMode(mesh: MeshHandle, mode: UpdateMode): void;
|
|
784
|
+
/** When the mesh's derived data follows its edits; see {@link UpdateMode}. */
|
|
785
|
+
mode(mesh: MeshHandle): UpdateMode;
|
|
786
|
+
/**
|
|
787
|
+
* The box around the vertices the live triangles use, in the mesh's local
|
|
788
|
+
* render coordinates ({@link Scene.matrix4} maps them to the world). Dead
|
|
789
|
+
* slots keep stale positions, so they are excluded. `null` without live
|
|
790
|
+
* triangles.
|
|
791
|
+
*/
|
|
792
|
+
bounds(mesh: MeshHandle): Bounds | null;
|
|
668
793
|
/** Brings the mesh's derived data up to date now, whatever its mode. */
|
|
669
794
|
update(mesh: MeshHandle): void;
|
|
670
795
|
/** Brings every mesh that is not `"manual"` up to date. */
|
|
@@ -729,9 +854,10 @@ declare class Scene implements SceneLike {
|
|
|
729
854
|
* Starts dragging a mesh: the moves until {@link DragSession.end} form one
|
|
730
855
|
* undo step (nested in the open step, if there is one). One drag at a time.
|
|
731
856
|
* Every {@link DragSession.move} recomputes the eager fields, so make at most
|
|
732
|
-
* one move per animation frame, with the latest pointer pose
|
|
857
|
+
* one move per animation frame, with the latest pointer pose, or pass
|
|
858
|
+
* `{ coalesce: true }` to have the drag do that for you.
|
|
733
859
|
*/
|
|
734
|
-
drag(mesh: MeshHandle): DragSession;
|
|
860
|
+
drag(mesh: MeshHandle, options?: DragOptions): DragSession;
|
|
735
861
|
/**
|
|
736
862
|
* Edits a mesh's geometry with a list of ops, run in Rust as one
|
|
737
863
|
* transaction: one undo step (or part of the open step), and when any op
|
|
@@ -920,6 +1046,13 @@ interface SceneLike {
|
|
|
920
1046
|
* falls back to vertex colours on a host without it.
|
|
921
1047
|
*/
|
|
922
1048
|
coloring?(mesh: MeshHandle): ColorRule | null;
|
|
1049
|
+
/**
|
|
1050
|
+
* The box around the vertices the mesh's live triangles use, in local
|
|
1051
|
+
* render coordinates, or `null` without live triangles. Optional:
|
|
1052
|
+
* `bindMesh` takes its bounds from it and walks the mirrors on a host
|
|
1053
|
+
* without it.
|
|
1054
|
+
*/
|
|
1055
|
+
bounds?(mesh: MeshHandle): Bounds | null;
|
|
923
1056
|
}
|
|
924
1057
|
//#endregion
|
|
925
|
-
export {
|
|
1058
|
+
export { Range as $, OrientReport as A, Scene as B, InflateReport as C, MeshChange as D, LoopId as E, RemoveReport as F, SectionPlane as G, SectionContour as H, RepairOp as I, SmoothReport as J, SectionResult as K, RepairReport as L, RayHit as M, RaycastOptions as N, MeshComponent as O, RemeshReport as P, SectionHandle as Q, RepairReportOf as R, FindContactsOptions as S, JoinReport as T, SectionDesc as U, SceneOptions as V, SectionGap as W, FieldHandle as X, WeldReport as Y, MeshHandle as Z, EditRef as _, BoundaryLoop as a, Placement as at, FillReport as b, ClosestPointOptions as c, Positions64 as ct, Contact as d, Vec3 as dt, MeshViews as et, DegenerateReport as f, computeBounds as ft, EditOp as g, DragSession as h, AnalyzeOptions as i, Mat3 as it, OutOfRange as j, MeshDistance as k, ColorRule as l, Quat as lt, DragOptions as m, AddMeshOptions as n, Indices as nt, BridgeReport as o, PlacementInput as ot, DistanceFieldDesc as p, computeVertexNormals as pt, SignMode as q, Analysis as r, InitInput as rt, ClosestHit as s, Positions as st, SceneLike as t, Bounds as tt, Colormap as u, UpdateMode as ut, EditResult as v, JoinOptions as w, FilledLoop as x, FieldStatus as y, Rgba as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as Scene, D as MeshChange, G as SectionPlane, I as RepairOp, L as RepairReport, Q as SectionHandle, U as SectionDesc, Z as MeshHandle, ct as Positions64, g as EditOp, h as DragSession, j as OutOfRange, n as AddMeshOptions, nt as Indices, ot as PlacementInput, q as SignMode, t as SceneLike, u as Colormap, v as EditResult, z as Rgba } from "./scene-like-YcY08oii.js";
|
|
2
2
|
import { t as FastMeshError } from "./core-D2X9GPfK.js";
|
|
3
|
-
import { r as WorkerScene } from "./client-
|
|
3
|
+
import { r as WorkerScene } from "./client-pv0Fwvl4.js";
|
|
4
4
|
//#region src/store/host.d.ts
|
|
5
5
|
/** Options of `SceneStore.addMesh`: those both scenes take (a store mesh is always eager). */
|
|
6
6
|
type StoreAddMeshOptions = Pick<AddMeshOptions, "origin" | "normals">;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { o as reportListenerError, t as FastMeshError } from "./core-Cke_kZ2e.js";
|
|
2
|
-
import { l as targetsOf } from "./views-
|
|
3
|
-
import { i as sectionAspects } from "./protocol-
|
|
4
|
-
import { i as watchStatusKeys, n as addFieldKeyed } from "./client-
|
|
2
|
+
import { l as targetsOf } from "./views-Dh3aWc2q.js";
|
|
3
|
+
import { i as sectionAspects } from "./protocol-DkhGNP0h.js";
|
|
4
|
+
import { i as watchStatusKeys, n as addFieldKeyed } from "./client-CE6RvmvB.js";
|
|
5
5
|
import { a as combine, c as sameData, n as EMPTY_SNAPSHOT, o as frozenCopy, t as DEFAULT_DISPLAY } from "./snapshot-Cf6NgDl7.js";
|
|
6
6
|
//#region src/store/host.ts
|
|
7
7
|
/** Whether `scene` is a Worker scene (structurally: it reports key statuses). */
|
package/dist/store.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _ as StoreAddMeshOptions, a as DisplayState, c as MeshState, d as SceneSnapshot, f as SectionParts, g as sectionState, h as meshState, i as ContactGroup, l as REMOVED_MESH_STATE, m as Status, n as SectionPatch, o as DistanceColoring, p as SectionState, r as createSceneStore, s as EMPTY_SNAPSHOT, t as SceneStore, u as REMOVED_SECTION_STATE } from "./store-
|
|
1
|
+
import { q as SignMode, z as Rgba } from "./scene-like-YcY08oii.js";
|
|
2
|
+
import { _ as StoreAddMeshOptions, a as DisplayState, c as MeshState, d as SceneSnapshot, f as SectionParts, g as sectionState, h as meshState, i as ContactGroup, l as REMOVED_MESH_STATE, m as Status, n as SectionPatch, o as DistanceColoring, p as SectionState, r as createSceneStore, s as EMPTY_SNAPSHOT, t as SceneStore, u as REMOVED_SECTION_STATE } from "./store-C5nzCpxy.js";
|
|
3
3
|
//#region src/store/heatmap.d.ts
|
|
4
4
|
/** Options of {@link contactHeatmap}. Distances are in the meshes' units. */
|
|
5
5
|
interface ContactHeatmapOptions {
|
package/dist/store.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as FastMeshError } from "./core-Cke_kZ2e.js";
|
|
2
2
|
import { i as REMOVED_SECTION_STATE, l as sectionState, n as EMPTY_SNAPSHOT, r as REMOVED_MESH_STATE, s as meshState } from "./snapshot-Cf6NgDl7.js";
|
|
3
|
-
import { n as createSceneStore, t as SceneStore } from "./store-
|
|
3
|
+
import { n as createSceneStore, t as SceneStore } from "./store-Z6A2HPih.js";
|
|
4
4
|
//#region src/store/heatmap.ts
|
|
5
5
|
/** The default colours: `#7f0000`, `#ff6b6b`, `#ffffff`, `#4caf50`, `#1e3a8a`. */
|
|
6
6
|
const DEFAULT_COLORS = {
|
package/dist/three.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as bindMesh, n as BoundMesh, r as MeshBinding, t as BindMeshOptions } from "./mesh-
|
|
1
|
+
import { Q as SectionHandle, t as SceneLike } from "./scene-like-YcY08oii.js";
|
|
2
|
+
import { i as bindMesh, n as BoundMesh, r as MeshBinding, t as BindMeshOptions } from "./mesh-RtPVmPQy.js";
|
|
3
3
|
import * as THREE from "three";
|
|
4
4
|
//#region src/three/controls.d.ts
|
|
5
5
|
/**
|
|
@@ -42,7 +42,8 @@ interface AttachTransformControlsOptions {
|
|
|
42
42
|
*
|
|
43
43
|
* Placements are rigid: TransformControls' scale mode has no effect (the
|
|
44
44
|
* object's scale is kept at 1). The object must be a direct child of an
|
|
45
|
-
* untransformed parent (its matrix is a world matrix), as for `bindMesh
|
|
45
|
+
* untransformed parent (its matrix is a world matrix), as for `bindMesh`;
|
|
46
|
+
* a transformed ancestor is detected and warned about once.
|
|
46
47
|
*
|
|
47
48
|
* The object's `position`, `quaternion` and `scale` are kept in step with its
|
|
48
49
|
* matrix (TransformControls reads them when a drag starts), so call this
|
|
@@ -74,9 +75,9 @@ interface BindSectionOptions {
|
|
|
74
75
|
interface BoundSection {
|
|
75
76
|
/**
|
|
76
77
|
* Add it to the THREE.Scene, untransformed (results are in world
|
|
77
|
-
* coordinates
|
|
78
|
-
*
|
|
79
|
-
* fill).
|
|
78
|
+
* coordinates; a transformed ancestor is detected and warned about once).
|
|
79
|
+
* Per bound mesh the section cuts, it holds a `LineSegments` of the contours
|
|
80
|
+
* and a `Mesh` of the fill (empty while the section has no fill).
|
|
80
81
|
*/
|
|
81
82
|
readonly group: THREE.Group;
|
|
82
83
|
/**
|
package/dist/three.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as FastMeshError } from "./core-Cke_kZ2e.js";
|
|
2
|
-
import { t as bindMesh } from "./mesh-
|
|
2
|
+
import { n as checkUntransformedParent, t as bindMesh } from "./mesh-zj7-wJBw.js";
|
|
3
3
|
import * as THREE from "three";
|
|
4
4
|
//#region src/three/controls.ts
|
|
5
5
|
const defaultSchedule = (callback) => {
|
|
@@ -34,7 +34,8 @@ function rotate(q, v) {
|
|
|
34
34
|
*
|
|
35
35
|
* Placements are rigid: TransformControls' scale mode has no effect (the
|
|
36
36
|
* object's scale is kept at 1). The object must be a direct child of an
|
|
37
|
-
* untransformed parent (its matrix is a world matrix), as for `bindMesh
|
|
37
|
+
* untransformed parent (its matrix is a world matrix), as for `bindMesh`;
|
|
38
|
+
* a transformed ancestor is detected and warned about once.
|
|
38
39
|
*
|
|
39
40
|
* The object's `position`, `quaternion` and `scale` are kept in step with its
|
|
40
41
|
* matrix (TransformControls reads them when a drag starts), so call this
|
|
@@ -166,6 +167,7 @@ function attachTransformControls(controls, scene, bound, options = {}) {
|
|
|
166
167
|
};
|
|
167
168
|
const onObjectChange = () => {
|
|
168
169
|
if (live() === void 0 || controls.object !== object) return;
|
|
170
|
+
checkUntransformedParent(object);
|
|
169
171
|
object.scale.set(1, 1, 1);
|
|
170
172
|
object.updateMatrix();
|
|
171
173
|
const q = object.quaternion;
|
|
@@ -204,6 +206,7 @@ function attachTransformControls(controls, scene, bound, options = {}) {
|
|
|
204
206
|
controls.addEventListener("dragging-changed", onDraggingChanged);
|
|
205
207
|
controls.addEventListener("objectChange", onObjectChange);
|
|
206
208
|
syncFromScene();
|
|
209
|
+
checkUntransformedParent(object);
|
|
207
210
|
return () => {
|
|
208
211
|
if (!attached) return;
|
|
209
212
|
attached = false;
|
|
@@ -349,7 +352,9 @@ function bindSection(scene, section, bound, options = {}) {
|
|
|
349
352
|
unsubscribe?.();
|
|
350
353
|
unsubscribe = void 0;
|
|
351
354
|
};
|
|
355
|
+
checkUntransformedParent(group);
|
|
352
356
|
unsubscribe = scene.onChanges((changes) => {
|
|
357
|
+
checkUntransformedParent(group);
|
|
353
358
|
let plane;
|
|
354
359
|
try {
|
|
355
360
|
plane = scene.sectionPlane(section);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as wasmMemory, n as call, t as FastMeshError } from "./core-Cke_kZ2e.js";
|
|
2
|
-
import { n as DEFAULT_NAN, t as DEFAULT_BASE } from "./colormap-
|
|
2
|
+
import { n as DEFAULT_NAN, t as DEFAULT_BASE } from "./colormap-DxGMYVfs.js";
|
|
3
3
|
//#region src/handles.ts
|
|
4
4
|
/**
|
|
5
5
|
* A mesh in a {@link Scene}. Opaque: pass it to the scene's methods. The same
|