@needle-tools/three-mesh-effects 0.3.3 → 0.3.4
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 +5 -0
- package/README.md +2 -1
- package/build/box-impostor-runtime.js +13 -0
- package/build/box-impostor-runtime.js.map +3 -3
- package/build/deformation-runtime.js +11 -9
- package/build/deformation-runtime.js.map +2 -2
- package/build/impostor-runtime.js +41 -19
- package/build/impostor-runtime.js.map +3 -3
- package/build/internal/box-impostor/box-impostor-runtime.js +13 -0
- package/build/internal/box-impostor/box-impostor-runtime.js.map +3 -3
- package/build/internal/deformation/pin-ik.js +11 -9
- package/build/internal/deformation/pin-ik.js.map +2 -2
- package/build/internal/deformation/pin-wiggle.js.map +1 -1
- package/build/internal/deformation/rig-extension.js.map +1 -1
- package/build/internal/deformation/rig-runtime.js +11 -9
- package/build/internal/deformation/rig-runtime.js.map +2 -2
- package/build/internal/impostor/impostor-node-material.js +41 -19
- package/build/internal/impostor/impostor-node-material.js.map +3 -3
- package/build/internal/pixel-impostor/pixel-impostor-display.js +9 -7
- package/build/internal/pixel-impostor/pixel-impostor-display.js.map +2 -2
- package/build/internal/rendering/classic-webgl-support.js +12 -0
- package/build/internal/rendering/classic-webgl-support.js.map +7 -0
- package/build/internal/rendering/renderer-support.js +13 -0
- package/build/internal/rendering/renderer-support.js.map +3 -3
- package/build/pixel-impostor-runtime.js +9 -7
- package/build/pixel-impostor-runtime.js.map +2 -2
- package/build/types/rendering/classic-webgl-support.d.ts +9 -0
- package/build/types/rendering/classic-webgl-support.js +1 -0
- package/package.json +2 -2
- package/src/deformation/pin-ik.ts +13 -9
- package/src/impostor/impostor-node-material.js +31 -15
- package/src/pixel-impostor/pixel-impostor-display.js +18 -7
- package/src/rendering/classic-webgl-support.js +15 -0
- package/src/rendering/renderer-support.js +5 -0
|
@@ -357,6 +357,13 @@ function solvePinIKGoals(pins, parents, goals, mass, fixed = /* @__PURE__ */ new
|
|
|
357
357
|
group.push(pin);
|
|
358
358
|
groups.set(key(pin), group);
|
|
359
359
|
}
|
|
360
|
+
const parentGroup = /* @__PURE__ */ new Map();
|
|
361
|
+
for (const [id, members] of groups) {
|
|
362
|
+
const parent = members.map((p) => byId.get(parents.get(p.id) ?? "")).find((p) => p && key(p) !== id);
|
|
363
|
+
if (parent) parentGroup.set(id, key(parent));
|
|
364
|
+
}
|
|
365
|
+
const holding = /* @__PURE__ */ new Set();
|
|
366
|
+
for (const [id, members] of groups) if (members.some((p) => fixed.has(p.id))) for (let at = id; at && !holding.has(at); at = parentGroup.get(at)) holding.add(at);
|
|
360
367
|
const active = /* @__PURE__ */ new Set(), roots = /* @__PURE__ */ new Set();
|
|
361
368
|
const bendSeeds = /* @__PURE__ */ new Map();
|
|
362
369
|
let size = 0;
|
|
@@ -370,7 +377,7 @@ function solvePinIKGoals(pins, parents, goals, mass, fixed = /* @__PURE__ */ new
|
|
|
370
377
|
if (span > 1e-8 && new Vector33().fromArray(goal.position).distanceTo(start) < span * (1 - 1e-6)) {
|
|
371
378
|
direction.divideScalar(span);
|
|
372
379
|
const straight = chain.every((p) => new Vector33().fromArray(p.pose.position).sub(start).cross(direction).lengthSq() < span * span * 1e-12);
|
|
373
|
-
const candidate = straight ? chain.slice(1, -1).find((p) => !
|
|
380
|
+
const candidate = straight ? chain.slice(1, -1).find((p) => !holding.has(key(p)) && ["free", "cone"].includes((p.ikConstraint ?? DEFAULT_IK_CONSTRAINT).mode)) : void 0;
|
|
374
381
|
if (candidate) {
|
|
375
382
|
const axis = new Vector33().crossVectors(direction, new Vector33().fromArray(goal.position).sub(start));
|
|
376
383
|
if (axis.lengthSq() < 1e-12) {
|
|
@@ -383,11 +390,6 @@ function solvePinIKGoals(pins, parents, goals, mass, fixed = /* @__PURE__ */ new
|
|
|
383
390
|
size = Math.max(size, chain.slice(1).reduce((sum, p, i) => sum + new Vector33().fromArray(p.pose.position).distanceTo(new Vector33().fromArray(chain[i].pose.position)), 0));
|
|
384
391
|
}
|
|
385
392
|
if (size < 1e-8) throw new Error("IK chain has no length. Separate its rest pins first.");
|
|
386
|
-
const parentGroup = /* @__PURE__ */ new Map();
|
|
387
|
-
for (const [id, members] of groups) {
|
|
388
|
-
const parent = members.map((p) => byId.get(parents.get(p.id) ?? "")).find((p) => p && key(p) !== id);
|
|
389
|
-
if (parent) parentGroup.set(id, key(parent));
|
|
390
|
-
}
|
|
391
393
|
const affected = new Set(active);
|
|
392
394
|
for (let changed = true; changed; ) {
|
|
393
395
|
changed = false;
|
|
@@ -414,7 +416,7 @@ function solvePinIKGoals(pins, parents, goals, mass, fixed = /* @__PURE__ */ new
|
|
|
414
416
|
const pin = groups.get(id)[0], parentId = parentGroup.get(id), parent = parentId ? groups.get(parentId)[0] : void 0;
|
|
415
417
|
const parentFrame = parentId ? build(parentId) : new Link();
|
|
416
418
|
let attachment = parentFrame;
|
|
417
|
-
if (parentId && active.has(id) && !
|
|
419
|
+
if (parentId && active.has(id) && !holding.has(id) && holding.has(parentId)) {
|
|
418
420
|
const pivot = new Joint();
|
|
419
421
|
pivot.setDoF(3, 4, 5);
|
|
420
422
|
pivot.setDoFValues(0, 0, 0);
|
|
@@ -431,7 +433,7 @@ function solvePinIKGoals(pins, parents, goals, mass, fixed = /* @__PURE__ */ new
|
|
|
431
433
|
joint.setPosition(position.x, position.y, position.z);
|
|
432
434
|
attachment.addChild(joint);
|
|
433
435
|
const link = new Link(), constraint = pin.ikConstraint ?? DEFAULT_IK_CONSTRAINT;
|
|
434
|
-
const movable = active.has(id) && !
|
|
436
|
+
const movable = active.has(id) && !holding.has(id);
|
|
435
437
|
if (!movable || constraint.mode === "locked") joint.setQuaternion(...relative.toArray());
|
|
436
438
|
else if (constraint.mode === "hinge") {
|
|
437
439
|
let axis = new Vector33();
|
|
@@ -510,7 +512,7 @@ function solvePinIKGoals(pins, parents, goals, mass, fixed = /* @__PURE__ */ new
|
|
|
510
512
|
const requested = new Vector33().fromArray(target.position);
|
|
511
513
|
if (goals.length === 1 && freeEndpoint) {
|
|
512
514
|
const chain = ikChain(pins, parents, target.id, mass);
|
|
513
|
-
const first = chain.findIndex((p) => !
|
|
515
|
+
const first = chain.findIndex((p) => !holding.has(key(p)) && (p.ikConstraint ?? DEFAULT_IK_CONSTRAINT).mode !== "locked");
|
|
514
516
|
const moving = first < 0 ? [] : chain.slice(branchJoints.has(key(chain[first])) ? Math.max(0, first - 1) : first);
|
|
515
517
|
if (moving.length > 1 && moving.every((p, i) => i === 0 && branchJoints.has(key(moving[1])) || !fixed.has(p.id) && groups.get(key(p)).length === 1 && (p.ikConstraint ?? DEFAULT_IK_CONSTRAINT).mode === "free")) {
|
|
516
518
|
const pivot = new Vector33().fromArray(moving[0].pose.position);
|