@dice-o-rolla/dice-assets 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 +95 -6
- package/THIRD_PARTY_NOTICES.md +3 -0
- package/assets/runtime/catalog.json +649 -0
- package/assets/runtime/previews/diagnostic-d10.svg +1 -0
- package/assets/runtime/previews/diagnostic-d100.svg +1 -0
- package/assets/runtime/previews/diagnostic-d12.svg +1 -0
- package/assets/runtime/previews/diagnostic-d20.svg +1 -0
- package/assets/runtime/previews/diagnostic-d4.svg +1 -0
- package/assets/runtime/previews/diagnostic-d6.svg +1 -0
- package/assets/runtime/previews/diagnostic-d66.svg +1 -0
- package/assets/runtime/previews/diagnostic-d8.svg +1 -0
- package/assets/runtime/textures/diagnostic-d10.ktx2 +0 -0
- package/assets/runtime/textures/diagnostic-d100.ktx2 +0 -0
- package/assets/runtime/textures/diagnostic-d12.ktx2 +0 -0
- package/assets/runtime/textures/diagnostic-d20.ktx2 +0 -0
- package/assets/runtime/textures/diagnostic-d4.ktx2 +0 -0
- package/assets/runtime/textures/diagnostic-d6.ktx2 +0 -0
- package/assets/runtime/textures/diagnostic-d66.ktx2 +0 -0
- package/assets/runtime/textures/diagnostic-d8.ktx2 +0 -0
- package/dist/asset-registry.d.ts +2 -1
- package/dist/asset-registry.js +37 -0
- package/dist/catalog-loader.js +19 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/textured-skin-set.d.ts +32 -0
- package/dist/textured-skin-set.js +115 -0
- package/dist/three-material-provider.d.ts +1 -0
- package/dist/three-material-provider.js +61 -20
- package/dist/tools/build.d.ts +2 -0
- package/dist/tools/build.js +232 -0
- package/dist/tools/cli.d.ts +2 -0
- package/dist/tools/cli.js +63 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.js +3 -0
- package/dist/tools/template.d.ts +9 -0
- package/dist/tools/template.js +88 -0
- package/dist/tools/types.d.ts +40 -0
- package/dist/tools/types.js +10 -0
- package/dist/tools/write-directory.d.ts +2 -0
- package/dist/tools/write-directory.js +56 -0
- package/dist/types.d.ts +13 -0
- package/package.json +16 -4
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ engine, physics, and renderer packages never import `dice-assets`; an applicatio
|
|
|
5
5
|
opaque preset IDs to these adapters.
|
|
6
6
|
|
|
7
7
|
The catalog has independent registries for audio sprites, audio banks, PBR materials, reusable
|
|
8
|
-
patterns, skins, and face atlases. A skin references assets by ID, so recolor, hue, saturation,
|
|
8
|
+
patterns, skins, skin sets, and face atlases. A skin references assets by ID, so recolor, hue, saturation,
|
|
9
9
|
pattern scale, and shader compositing create variants without duplicating KTX2 data.
|
|
10
10
|
|
|
11
11
|
```ts
|
|
@@ -37,10 +37,93 @@ Rapier reports contact force on every simulation step while two colliders remain
|
|
|
37
37
|
`ImpactSoundGate` combines that stream with collision start/end events so each physical contact
|
|
38
38
|
produces one sound instead of an overlapping retrigger on every fixed step.
|
|
39
39
|
|
|
40
|
-
For Three.js, pass a `materialProvider` factory to `ThreeDiceRenderer`; the
|
|
41
|
-
active `WebGLRenderer` and can construct `ThreeAssetMaterialProvider`. Call
|
|
42
|
-
dice using that skin can spawn. It loads KTX2 through Three's `KTX2Loader`,
|
|
43
|
-
packed ORM map for AO/roughness/metalness, and composites the face
|
|
40
|
+
For Three.js, pass a `materialProvider` factory to `ThreeDiceRenderer` or `TopDownDiceRenderer`; the
|
|
41
|
+
factory receives its active `WebGLRenderer` and can construct `ThreeAssetMaterialProvider`. Call
|
|
42
|
+
`prepareSkin()` before dice using that skin can spawn. It loads KTX2 through Three's `KTX2Loader`,
|
|
43
|
+
shares texture instances, uses the packed ORM map for AO/roughness/metalness, and composites the face
|
|
44
|
+
atlas in the material shader.
|
|
45
|
+
|
|
46
|
+
## Prepared skin sets
|
|
47
|
+
|
|
48
|
+
Use `prepareTexturedSkinSet({ registry, provider, skinSetId })` to validate and preload a textured
|
|
49
|
+
set. Register the returned handle with `skinSet.register(engine)` and pass
|
|
50
|
+
`{ visualPresetSelector: skinSet.visualPresetSelector }` to `engine.roll()` or `engine.simulate()`.
|
|
51
|
+
The helper handles paired tens variants, leaves absent types to engine defaults and does not
|
|
52
|
+
change defaults during registration. Repeated registrations through the helper are idempotent;
|
|
53
|
+
conflicting content is rejected and failed registration rolls back entries added by that call.
|
|
54
|
+
|
|
55
|
+
The provider must use the same registry and owns the texture lifetime. Use separate registries and
|
|
56
|
+
providers when reloading changed assets. For a complete preparation and browser example, see
|
|
57
|
+
[Preparing and connecting textured dice nets](https://github.com/creepiest-space/dice-o-rolla/blob/main/docs/textured-unwraps.md).
|
|
58
|
+
The `@dice-o-rolla/dice-assets/tools` entry point exports editable SVG templates and builds
|
|
59
|
+
KTX2 catalogs under Node.js or Bun; it is not needed by browser consumers.
|
|
60
|
+
|
|
61
|
+
## Texture authoring API and CLI
|
|
62
|
+
|
|
63
|
+
The same package provides Node.js 20+/Bun tools through `@dice-o-rolla/dice-assets/tools`.
|
|
64
|
+
Keep this entry out of browser imports. Install KTX-Software (`ktx` on PATH) for encoding;
|
|
65
|
+
template export does not require it.
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
npx dice-assets template --types d6 --id painted --out ./art/painted
|
|
69
|
+
# Paint art/painted/d6.svg, then build the runtime catalog.
|
|
70
|
+
npx dice-assets build --input ./art/painted/skin-set.source.json --out ./public/dice/painted
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import {
|
|
75
|
+
createTextureTemplate,
|
|
76
|
+
writeTextureTemplates,
|
|
77
|
+
buildTexturedSkinSet,
|
|
78
|
+
} from '@dice-o-rolla/dice-assets/tools';
|
|
79
|
+
|
|
80
|
+
const template = createTextureTemplate('d6', { size: 2048 });
|
|
81
|
+
await writeTextureTemplates({ outputDirectory: './art/custom', types: ['d6'], id: 'custom' });
|
|
82
|
+
const built = await buildTexturedSkinSet({
|
|
83
|
+
input: './art/custom/skin-set.source.json',
|
|
84
|
+
outputDirectory: './public/dice/custom',
|
|
85
|
+
});
|
|
86
|
+
console.log(template.unwrap, built.catalog);
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Use `--types standard` for all shapes and tens variants. The `artwork` and `labels` layers are
|
|
90
|
+
rasterized; `guides` is removed. `--overwrite` replaces the entire generated destination only after
|
|
91
|
+
a successful build, so keep source files elsewhere. See the guide above for PBR maps and hosting.
|
|
92
|
+
Run `bun run test:integration` in this workspace to verify real KTX encoding.
|
|
93
|
+
|
|
94
|
+
## Connected surface unwraps
|
|
95
|
+
|
|
96
|
+
A `DicePatternDefinition` can include `unwrap: DiceSurfaceUnwrap`: a `geometryId`, a `faces`
|
|
97
|
+
record keyed by physical face value, and an optional SVG `preview` reference. Every face contains
|
|
98
|
+
one `[u, v]` pair per vertex, in the exact order of the geometry's `face.indices`. Coordinates are
|
|
99
|
+
normalized to `[0, 1]` with a **bottom-left origin**. Include all faces, including those whose visible
|
|
100
|
+
labels differ from their physical values. The material provider checks geometry compatibility and
|
|
101
|
+
complete corner coverage before mesh allocation.
|
|
102
|
+
|
|
103
|
+
Use `ktx create --convert-texcoord-origin bottom-left` when encoding surface maps from PNG. KTX2
|
|
104
|
+
textures are compressed and cannot rely on Three.js `flipY`. Base color, normal and ORM maps use
|
|
105
|
+
UV channel 1 with clamp wrapping; label atlases retain local face UVs in channel 0. Unwrapped
|
|
106
|
+
patterns cannot declare `repeat`; pattern scaling is ignored for surface sampling. Existing
|
|
107
|
+
patterns without `unwrap` keep their per-face mapping.
|
|
108
|
+
|
|
109
|
+
`DiceSkinSetDefinition` groups skins by application-level die type:
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
const set = assets.skinSets.get('diagnostic');
|
|
113
|
+
const cubeSkinId = set?.skins.d6; // diagnostic-d6
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The bundled `diagnostic` set provides d4, d6, d8, d10, d12, d20, d100 tens and d66 tens. Each skin
|
|
117
|
+
uses one connected, non-overlapping net; d6 uses a cross. Diagnostic labels are baked into the
|
|
118
|
+
texture, including d4's vertex labels and the separate tens variants. Register a visual preset for
|
|
119
|
+
each skin using its pattern's `unwrap.geometryId`. For paired dice, select the tens preset through
|
|
120
|
+
`roll`/`simulate`'s existing `visualPresetSelector`; its `component.role` and `component.groupType`
|
|
121
|
+
distinguish the tens component from the ordinary d10/d6 units component.
|
|
122
|
+
|
|
123
|
+
Prepare each skin before creating dice. Dispose the provider when its renderer is released;
|
|
124
|
+
in-flight texture loads settle and release resources without repopulating a disposed provider.
|
|
125
|
+
The loader resolves preview URLs relative to the catalog, just like texture URLs. Catalog schema
|
|
126
|
+
version remains 1; all new fields are optional.
|
|
44
127
|
|
|
45
128
|
## Asset pipeline
|
|
46
129
|
|
|
@@ -51,7 +134,8 @@ Run `bun run --filter @dice-o-rolla/dice-assets assets:build`. The documented bu
|
|
|
51
134
|
- `ktx create` conversion to UASTC KTX2 with offline mipmaps and Zstd supercompression;
|
|
52
135
|
- KTX validation with `ktx validate`;
|
|
53
136
|
- FFmpeg conversion and concatenation into mono WebM/Opus audio sprites;
|
|
54
|
-
-
|
|
137
|
+
- connected diagnostic nets, SVG previews and KTX2 textures with edge padding and mipmaps;
|
|
138
|
+
- production JSON catalog generation with clip offsets, material banks, atlas regions and skin sets.
|
|
55
139
|
|
|
56
140
|
The checked-in set combines original procedural test textures/audio with Unlicense impact WAV
|
|
57
141
|
masters from 3DDiceRoller. Runtime audio is split into dice, coin, felt, metal, wood-table, and
|
|
@@ -59,3 +143,8 @@ wood-tray mono Opus sprites. See `THIRD_PARTY_NOTICES.md` and the upstream licen
|
|
|
59
143
|
source masters. No Dice So Nice assets are included.
|
|
60
144
|
|
|
61
145
|
Licensed under Apache-2.0.
|
|
146
|
+
|
|
147
|
+
Diagnostic sources are generated by `scripts/diagnostic-nets.ts` from the registered polyhedra.
|
|
148
|
+
The deterministic edge-unfolding search preserves lengths and rejects overlapping polygons.
|
|
149
|
+
Tests verify connectivity, corner distances, winding, shared edge identifiers, raster colors,
|
|
150
|
+
KTX orientation and mipmaps. Regenerate through `assets:build`; do not hand-edit runtime files.
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -15,3 +15,6 @@ Original procedural test textures and audio generated by Dice O Rolla remain ava
|
|
|
15
15
|
these banks. No Dice So Nice assets are included.
|
|
16
16
|
|
|
17
17
|
Applications remain responsible for verifying licenses of resources added to their own catalogs.
|
|
18
|
+
|
|
19
|
+
Texture authoring uses Resvg and @xmldom/xmldom. Their dependencies retain their upstream licenses;
|
|
20
|
+
see the installed dependency packages for license texts. No third-party artwork is bundled.
|