@needle-tools/three-mesh-effects 0.2.2 → 0.2.3
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 +8 -0
- package/build/deformation-runtime.js +55 -12
- package/build/deformation-runtime.js.map +3 -3
- package/build/impostor-runtime.js +83 -29
- package/build/impostor-runtime.js.map +3 -3
- package/build/internal/deformation/fur-surface.js +55 -12
- package/build/internal/deformation/fur-surface.js.map +3 -3
- package/build/internal/deformation/rig-runtime.js +55 -12
- package/build/internal/deformation/rig-runtime.js.map +3 -3
- package/build/internal/impostor/impostor-node-material.js +83 -29
- package/build/internal/impostor/impostor-node-material.js.map +3 -3
- package/build/internal/rendering/texture-slot.js +26 -0
- package/build/internal/rendering/texture-slot.js.map +7 -0
- package/build/types/rendering/texture-slot.d.ts +10 -0
- package/build/types/rendering/texture-slot.js +1 -0
- package/package.json +1 -1
- package/src/deformation/fur-surface.ts +22 -12
- package/src/impostor/impostor-node-material.js +61 -33
- package/src/rendering/texture-slot.js +27 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.3 - 2026-10-30
|
|
4
|
+
|
|
5
|
+
- Keep impostor shading and fur textures connected when progressive loading replaces a texture. Fur height preserves its UV channel and texture transforms; fur motion limits follow the loaded resolution.
|
|
6
|
+
- Sample resized impostor color and shading atlases using their loaded dimensions, with frame boundaries and safe mip levels respected. Packed geometry/depth and sparse pixel records still require their authored resolution.
|
|
7
|
+
|
|
3
8
|
## 0.2.2 - 2026-10-21
|
|
4
9
|
|
|
5
10
|
- Include a package-root `SKILL.md` with integration guidance for extension loading, compression decoders, runtime updates, and cleanup in Three.js and Needle Engine applications.
|
package/README.md
CHANGED
|
@@ -58,6 +58,14 @@ Rig animation still needs a per-frame update, pixel display modes remain availab
|
|
|
58
58
|
through `createPixelImpostorDisplay`. Hull effects load alone; optionally use
|
|
59
59
|
`bindHull` to add an original model and animation syncing.
|
|
60
60
|
|
|
61
|
+
When your loader also supports `NEEDLE_progressive`, impostor shading and fur
|
|
62
|
+
textures can change resolution in place. Material bindings and size-dependent
|
|
63
|
+
sampling update when a texture is replaced; fur height keeps its UV channel and
|
|
64
|
+
texture transforms. Resize impostor atlases per frame rather than filtering
|
|
65
|
+
across neighboring views. Compact shading alpha stores material data and needs
|
|
66
|
+
independent channel filtering and lossless PNG encoding. Packed depth/geometry
|
|
67
|
+
and sparse pixel-impostor records must retain their authored resolution.
|
|
68
|
+
|
|
61
69
|
## Hull effects
|
|
62
70
|
|
|
63
71
|
When exporting with a hull effect selected, Mesh Baker saves its mode and
|
|
@@ -1480,9 +1480,32 @@ function driveRig(pins, reference, drivers) {
|
|
|
1480
1480
|
}
|
|
1481
1481
|
|
|
1482
1482
|
// src/deformation/fur-surface.ts
|
|
1483
|
-
import { BufferAttribute, MeshPhysicalMaterial, MeshStandardMaterial, SkinnedMesh } from "three";
|
|
1483
|
+
import { BufferAttribute, MeshPhysicalMaterial, MeshStandardMaterial, SkinnedMesh, Vector2 } from "three";
|
|
1484
1484
|
import { MeshPhysicalNodeMaterial, MeshStandardNodeMaterial } from "three/webgpu";
|
|
1485
1485
|
import { attribute, float, mix, normalMap, positionLocal, texture, uniform, uv, varying, vec2, vec3, vec4 } from "three/tsl";
|
|
1486
|
+
|
|
1487
|
+
// src/rendering/texture-slot.js
|
|
1488
|
+
function bindTextureSlot(material, slot, initial, nodes, onChange) {
|
|
1489
|
+
let current = initial;
|
|
1490
|
+
Object.defineProperty(material, slot, {
|
|
1491
|
+
configurable: true,
|
|
1492
|
+
enumerable: true,
|
|
1493
|
+
get: () => current,
|
|
1494
|
+
set: (value) => {
|
|
1495
|
+
value.channel = current.channel;
|
|
1496
|
+
value.offset = current.offset;
|
|
1497
|
+
value.repeat = current.repeat;
|
|
1498
|
+
value.center = current.center;
|
|
1499
|
+
value.rotation = current.rotation;
|
|
1500
|
+
current = value;
|
|
1501
|
+
for (const node of nodes) node.value = value;
|
|
1502
|
+
onChange?.(value);
|
|
1503
|
+
material.needsUpdate = true;
|
|
1504
|
+
}
|
|
1505
|
+
});
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
// src/deformation/fur-surface.ts
|
|
1486
1509
|
var FurSurface = class {
|
|
1487
1510
|
surfaces = [];
|
|
1488
1511
|
height = null;
|
|
@@ -1559,30 +1582,50 @@ var FurSurface = class {
|
|
|
1559
1582
|
if (!signal) return material;
|
|
1560
1583
|
const depth = attribute("furDepth", "float").mul(5).clamp(0, 1);
|
|
1561
1584
|
const skinnedDelta = varying(positionLocal.sub(attribute("position", "vec3")), "furSkinDelta");
|
|
1562
|
-
const
|
|
1563
|
-
const pixel =
|
|
1585
|
+
const signalSlot = ["map", "normalMap", "roughnessMap", "metalnessMap", "emissiveMap", "aoMap", "alphaMap"].find((slot) => Reflect.get(source, slot) === signal) ?? "furHeightMap";
|
|
1586
|
+
const pixel = uniform(new Vector2());
|
|
1587
|
+
const updatePixel = (map) => {
|
|
1588
|
+
const dimensions = map.image;
|
|
1589
|
+
pixel.value.set(1 / Math.max(1, dimensions?.width ?? 1024), 1 / Math.max(1, dimensions?.height ?? 1024));
|
|
1590
|
+
};
|
|
1591
|
+
updatePixel(signal);
|
|
1564
1592
|
const movement = projectMotionToUv(skinnedDelta, coordinates).clamp(pixel.mul(-1.5), pixel.mul(1.5));
|
|
1565
|
-
const
|
|
1593
|
+
const heightNode = this.height ? texture(this.height, uv(this.height.channel)) : null;
|
|
1594
|
+
if (heightNode && this.height) bindTextureSlot(
|
|
1595
|
+
material,
|
|
1596
|
+
"furHeightMap",
|
|
1597
|
+
this.height,
|
|
1598
|
+
[heightNode],
|
|
1599
|
+
(value) => {
|
|
1600
|
+
this.height = value;
|
|
1601
|
+
if (signalSlot === "furHeightMap") updatePixel(value);
|
|
1602
|
+
}
|
|
1603
|
+
);
|
|
1604
|
+
const height = heightNode ? heightNode.r : float(0.5);
|
|
1566
1605
|
const raised = mix(0.65, 1.35, height);
|
|
1567
1606
|
const phase = coordinates.dot(vec2(31, 43)).add(height.sub(0.5).mul(2.4)).add(this.clock.mul(this.wind).mul(1.7));
|
|
1568
1607
|
const gust = vec2(phase.sin(), phase.mul(1.31).cos()).mul(pixel).mul(this.wind.mul(0.65));
|
|
1569
1608
|
const shift = movement.add(gust).mul(depth).mul(raised).clamp(pixel.mul(-2), pixel.mul(2)).toVar("furTextureShift");
|
|
1570
|
-
const sample = (map) => {
|
|
1609
|
+
const sample = (map, slot) => {
|
|
1571
1610
|
const node = texture(map, uv(map.channel).add(shift));
|
|
1572
1611
|
node.updateMatrix = true;
|
|
1612
|
+
bindTextureSlot(material, slot, map, [node], (value) => {
|
|
1613
|
+
Reflect.set(source, slot, value);
|
|
1614
|
+
if (signalSlot === slot) updatePixel(value);
|
|
1615
|
+
});
|
|
1573
1616
|
return node;
|
|
1574
1617
|
};
|
|
1575
|
-
const base = source.map ? sample(source.map) : vec4(1);
|
|
1618
|
+
const base = source.map ? sample(source.map, "map") : vec4(1);
|
|
1576
1619
|
material.colorNode = base.mul(vec4(source.color.r, source.color.g, source.color.b, 1));
|
|
1577
|
-
if (source.alphaMap) material.opacityNode = sample(source.alphaMap).g;
|
|
1620
|
+
if (source.alphaMap) material.opacityNode = sample(source.alphaMap, "alphaMap").g;
|
|
1578
1621
|
if (source.normalMap) material.normalNode = normalMap(
|
|
1579
|
-
sample(source.normalMap).xyz,
|
|
1622
|
+
sample(source.normalMap, "normalMap").xyz,
|
|
1580
1623
|
vec2(source.normalScale.x, source.normalScale.y)
|
|
1581
1624
|
);
|
|
1582
|
-
material.roughnessNode = source.roughnessMap ? sample(source.roughnessMap).g.mul(source.roughness) : float(source.roughness);
|
|
1583
|
-
material.metalnessNode = source.metalnessMap ? sample(source.metalnessMap).b.mul(source.metalness) : float(source.metalness);
|
|
1584
|
-
if (source.aoMap) material.aoNode = float(1).sub(float(1).sub(sample(source.aoMap).r).mul(source.aoMapIntensity));
|
|
1585
|
-
if (source.emissiveMap) material.emissiveNode = sample(source.emissiveMap).rgb.mul(vec3(
|
|
1625
|
+
material.roughnessNode = source.roughnessMap ? sample(source.roughnessMap, "roughnessMap").g.mul(source.roughness) : float(source.roughness);
|
|
1626
|
+
material.metalnessNode = source.metalnessMap ? sample(source.metalnessMap, "metalnessMap").b.mul(source.metalness) : float(source.metalness);
|
|
1627
|
+
if (source.aoMap) material.aoNode = float(1).sub(float(1).sub(sample(source.aoMap, "aoMap").r).mul(source.aoMapIntensity));
|
|
1628
|
+
if (source.emissiveMap) material.emissiveNode = sample(source.emissiveMap, "emissiveMap").rgb.mul(vec3(
|
|
1586
1629
|
source.emissive.r * source.emissiveIntensity,
|
|
1587
1630
|
source.emissive.g * source.emissiveIntensity,
|
|
1588
1631
|
source.emissive.b * source.emissiveIntensity
|