@combos-fun/plugin-renderer-3d-material 0.1.14 → 0.1.16
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/agent-skill.md +17 -68
- package/package.json +4 -4
package/agent-skill.md
CHANGED
|
@@ -1,79 +1,28 @@
|
|
|
1
1
|
# `@combos-fun/plugin-renderer-3d-material` — Agent notes
|
|
2
2
|
|
|
3
|
-
Replaces materials on meshes
|
|
4
|
-
|
|
5
|
-
Prerequisite: follow the parent `@combos-fun/plugin-renderer-3d` skill for system order, named resources, hierarchy, opacity scope, and stale-async handling.
|
|
6
|
-
|
|
7
|
-
## Public API
|
|
8
|
-
|
|
9
|
-
Runtime exports:
|
|
10
|
-
|
|
11
|
-
```ts
|
|
12
|
-
import {
|
|
13
|
-
Material3D,
|
|
14
|
-
Material3DSystem,
|
|
15
|
-
collectTargetMeshes,
|
|
16
|
-
} from '@combos-fun/plugin-renderer-3d-material';
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Type-only exports:
|
|
3
|
+
Replaces materials on meshes in this GameObject. One `Material3D` per GameObject. Parent: `plugin-renderer-3d`. Register after the visual system.
|
|
20
4
|
|
|
21
5
|
```ts
|
|
22
|
-
import
|
|
23
|
-
Material3DParams,
|
|
24
|
-
Material3DKind,
|
|
25
|
-
Material3DUniformValue,
|
|
26
|
-
} from '@combos-fun/plugin-renderer-3d-material';
|
|
6
|
+
import { Material3D, Material3DSystem } from '@combos-fun/plugin-renderer-3d-material';
|
|
27
7
|
```
|
|
28
8
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
## Parameters
|
|
9
|
+
`componentName = 'Material3D'`. `systemName = 'Material3DSystem'`.
|
|
32
10
|
|
|
33
|
-
| Field |
|
|
34
|
-
|
|
35
|
-
| `type` | `'standard' \|
|
|
36
|
-
| `resource` | `
|
|
37
|
-
| `node` | `
|
|
38
|
-
| `uniforms` | `
|
|
39
|
-
| `color` | `
|
|
40
|
-
| `opacity` | `
|
|
41
|
-
| `roughness` / `metalness` | `
|
|
42
|
-
| `emissive` | `
|
|
43
|
-
| `wireframe` / `doubleSide` | `
|
|
44
|
-
| `map` | `
|
|
11
|
+
| Field | Default |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| `type` | `'standard'` — `standard \| basic \| lambert \| toon \| physical \| shader` |
|
|
14
|
+
| `resource` | `''` — SHADER name when `type` is `shader` |
|
|
15
|
+
| `node` | `''` — all meshes; matches own name or an ancestor |
|
|
16
|
+
| `uniforms` | `{}` |
|
|
17
|
+
| `color` | `0xffffff` |
|
|
18
|
+
| `opacity` | `1` |
|
|
19
|
+
| `roughness` / `metalness` | `1` / `0` |
|
|
20
|
+
| `emissive` | `0` |
|
|
21
|
+
| `wireframe` / `doubleSide` | `false` |
|
|
22
|
+
| `map` | `''` — IMAGE name; empty keeps the source map |
|
|
45
23
|
|
|
46
|
-
`
|
|
47
|
-
|
|
48
|
-
## Runtime and lifecycle
|
|
49
|
-
|
|
50
|
-
- Built-in material replacements copy the source texture maps; a non-empty `map` asynchronously loads an IMAGE override.
|
|
51
|
-
- `shader` asynchronously loads a SHADER resource. A missing vertex shader uses the built-in UV vertex shader; a fragment shader is required.
|
|
52
|
-
- Concurrent changes/removal invalidate pending shader or map work. Stale map textures are disposed. Removal restores original materials and disposes created materials/textures.
|
|
53
|
-
- The system retries target discovery each frame, so a sibling `Model3D` can finish loading later.
|
|
54
|
-
- `time` and `uTime` entries in `uniforms` receive elapsed seconds each renderer update; other values are copied, with booleans converted to `0`/`1`.
|
|
55
|
-
- Built-in material classes retain normal skinned-mesh support. The default custom shader has no skinning logic.
|
|
56
|
-
|
|
57
|
-
`Material3D.opacity` is the replacement material's value. A sibling `Render3D` subsequently overwrites every mesh material below that GameObject root each frame; use `Render3D.opacity` for root-wide live fades.
|
|
58
|
-
|
|
59
|
-
## Package-specific pitfalls
|
|
60
|
-
|
|
61
|
-
- Put `Material3DSystem` after the visual system so synchronous visuals exist first.
|
|
62
|
-
- An unknown `type` falls back to `MeshStandardMaterial`.
|
|
63
|
-
- A shader must implement any required skinning and texture sampling itself; setting `map` does not automatically add a map uniform to custom GLSL.
|
|
64
|
-
|
|
65
|
-
## Minimal example
|
|
24
|
+
Unknown `type` becomes `MeshStandardMaterial`. Built-in types keep skinned-mesh support and copy the source maps. `shader` needs a fragment shader; a missing vertex shader uses the built-in UV shader. `time` / `uTime` uniforms get elapsed seconds; booleans become `0` / `1`. Custom GLSL does not get skinning or an automatic map uniform. Instanced meshes are skipped. Traversal stops at nested `Transform3D` roots. Target meshes are retried each frame, so a sibling `Model3D` can finish loading later. Removal restores the original materials. A sibling `Render3D` overwrites opacity each frame.
|
|
66
25
|
|
|
67
26
|
```ts
|
|
68
|
-
hero.addComponent(new
|
|
69
|
-
hero.addComponent(new Material3D({
|
|
70
|
-
type: 'physical',
|
|
71
|
-
metalness: 0.8,
|
|
72
|
-
roughness: 0.2,
|
|
73
|
-
node: 'Armor',
|
|
74
|
-
}));
|
|
27
|
+
hero.addComponent(new Material3D({ type: 'physical', metalness: 0.8, roughness: 0.2, node: 'Armor' }));
|
|
75
28
|
```
|
|
76
|
-
|
|
77
|
-
## Verification
|
|
78
|
-
|
|
79
|
-
`pnpm --filter @combos-fun/plugin-renderer-3d-material run build`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@combos-fun/plugin-renderer-3d-material",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "Per-object 3D materials and custom shaders",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-3d-material.esm.js",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"three": "^0.172.0",
|
|
30
|
-
"@combos-fun/engine": "0.1.
|
|
31
|
-
"@combos-fun/inspector-decorator": "0.1.
|
|
32
|
-
"@combos-fun/plugin-renderer-3d": "0.1.
|
|
30
|
+
"@combos-fun/engine": "0.1.16",
|
|
31
|
+
"@combos-fun/inspector-decorator": "0.1.16",
|
|
32
|
+
"@combos-fun/plugin-renderer-3d": "0.1.16"
|
|
33
33
|
},
|
|
34
34
|
"keywords": [
|
|
35
35
|
"combos-fun",
|