@driftengine/drft 4.8.5 → 4.8.7
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 +1 -1
- package/dist/meshData.d.ts +12 -0
- package/dist/meshData.js +14 -0
- package/package.json +4 -4
- package/src/meshData.ts +26 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The `.drft` container: read and write a baked scene. Declares no runtime dependency.
|
|
4
4
|
|
|
5
|
-
**Cost: 14.
|
|
5
|
+
**Cost: 14.3 KB gzipped.** Measured by `scripts/size-gate.test.mjs`, which fails if it drifts more than
|
|
6
6
|
3% — the number is a fact about the build rather than a claim in a document.
|
|
7
7
|
|
|
8
8
|
Part of [DriftEngine](../../README.md). See [`docs/ARCHITECTURE.md`](../../docs/ARCHITECTURE.md)
|
package/dist/meshData.d.ts
CHANGED
|
@@ -106,6 +106,18 @@ export interface MeshData {
|
|
|
106
106
|
* separates asphalt from plaster, and the pass states it: see `Renderer.setSurfaceRelief`.
|
|
107
107
|
*/
|
|
108
108
|
relief?: Float32Array;
|
|
109
|
+
/**
|
|
110
|
+
* A second set of texture coordinates, two floats a vertex, for a baked lightmap: where on its
|
|
111
|
+
* page a surface's baked light is, as a material made with `lightmapModel` reads it. Absent means
|
|
112
|
+
* a mesh nothing has baked light for.
|
|
113
|
+
*
|
|
114
|
+
* **It rides the grain and relief attributes**, which a lightmapped surface gives up: a
|
|
115
|
+
* renderer's vertex attributes and the stage's inter-stage values are spent to the last one, and
|
|
116
|
+
* baked stage geometry carries neither procedural grain nor relief. So a mesh with any grain or
|
|
117
|
+
* relief that is not zero is refused with these, rather than one of the two quietly lost; lanes
|
|
118
|
+
* of zeros, which a builder writes for every mesh, are what a surface without either carries.
|
|
119
|
+
*/
|
|
120
|
+
lightmapUvs?: Float32Array;
|
|
109
121
|
/**
|
|
110
122
|
* Which image of a texture array each vertex's face wears: one whole number a vertex, 0 the first
|
|
111
123
|
* layer. Absent means layer 0, which is the only layer a plain texture has.
|
package/dist/meshData.js
CHANGED
|
@@ -49,6 +49,11 @@ export function validateMeshData(data) {
|
|
|
49
49
|
check('roughness', data.roughness, 1);
|
|
50
50
|
check('grain', data.grain, 1);
|
|
51
51
|
check('relief', data.relief, 1);
|
|
52
|
+
check('lightmapUvs', data.lightmapUvs, 2);
|
|
53
|
+
if (data.lightmapUvs !== undefined && (anyNonZero(data.grain) || anyNonZero(data.relief))) {
|
|
54
|
+
throw new Error('Mesh: lightmapUvs and grain or relief together — the second texture coordinates ride the ' +
|
|
55
|
+
'grain and relief attributes, which a lightmapped surface gives up. Name one or the other.');
|
|
56
|
+
}
|
|
52
57
|
check('channel', data.channel, 4);
|
|
53
58
|
check('layers', data.layers, 1);
|
|
54
59
|
if (data.layers !== undefined) {
|
|
@@ -136,3 +141,12 @@ export function validateMeshData(data) {
|
|
|
136
141
|
}
|
|
137
142
|
}
|
|
138
143
|
}
|
|
144
|
+
/** Whether a lane holds anything but zeros: a builder writes zeros for a mesh that asked for none. */
|
|
145
|
+
function anyNonZero(lane) {
|
|
146
|
+
if (lane === undefined)
|
|
147
|
+
return false;
|
|
148
|
+
for (let i = 0; i < lane.length; i++)
|
|
149
|
+
if (lane[i] !== 0)
|
|
150
|
+
return true;
|
|
151
|
+
return false;
|
|
152
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driftengine/drft",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.7",
|
|
4
4
|
"description": "The .drft container: a streaming format for baked 3D scenes",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
],
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@driftengine/core": "4.8.
|
|
31
|
-
"@driftengine/entities": "4.8.
|
|
32
|
-
"@driftengine/texture": "4.8.
|
|
30
|
+
"@driftengine/core": "4.8.7",
|
|
31
|
+
"@driftengine/entities": "4.8.7",
|
|
32
|
+
"@driftengine/texture": "4.8.7"
|
|
33
33
|
},
|
|
34
34
|
"author": "Drift Technologies",
|
|
35
35
|
"repository": {
|
package/src/meshData.ts
CHANGED
|
@@ -107,6 +107,18 @@ export interface MeshData {
|
|
|
107
107
|
* separates asphalt from plaster, and the pass states it: see `Renderer.setSurfaceRelief`.
|
|
108
108
|
*/
|
|
109
109
|
relief?: Float32Array;
|
|
110
|
+
/**
|
|
111
|
+
* A second set of texture coordinates, two floats a vertex, for a baked lightmap: where on its
|
|
112
|
+
* page a surface's baked light is, as a material made with `lightmapModel` reads it. Absent means
|
|
113
|
+
* a mesh nothing has baked light for.
|
|
114
|
+
*
|
|
115
|
+
* **It rides the grain and relief attributes**, which a lightmapped surface gives up: a
|
|
116
|
+
* renderer's vertex attributes and the stage's inter-stage values are spent to the last one, and
|
|
117
|
+
* baked stage geometry carries neither procedural grain nor relief. So a mesh with any grain or
|
|
118
|
+
* relief that is not zero is refused with these, rather than one of the two quietly lost; lanes
|
|
119
|
+
* of zeros, which a builder writes for every mesh, are what a surface without either carries.
|
|
120
|
+
*/
|
|
121
|
+
lightmapUvs?: Float32Array;
|
|
110
122
|
/**
|
|
111
123
|
* Which image of a texture array each vertex's face wears: one whole number a vertex, 0 the first
|
|
112
124
|
* layer. Absent means layer 0, which is the only layer a plain texture has.
|
|
@@ -269,6 +281,13 @@ export function validateMeshData(data: MeshData): void {
|
|
|
269
281
|
check('roughness', data.roughness, 1);
|
|
270
282
|
check('grain', data.grain, 1);
|
|
271
283
|
check('relief', data.relief, 1);
|
|
284
|
+
check('lightmapUvs', data.lightmapUvs, 2);
|
|
285
|
+
if (data.lightmapUvs !== undefined && (anyNonZero(data.grain) || anyNonZero(data.relief))) {
|
|
286
|
+
throw new Error(
|
|
287
|
+
'Mesh: lightmapUvs and grain or relief together — the second texture coordinates ride the ' +
|
|
288
|
+
'grain and relief attributes, which a lightmapped surface gives up. Name one or the other.',
|
|
289
|
+
);
|
|
290
|
+
}
|
|
272
291
|
check('channel', data.channel, 4);
|
|
273
292
|
check('layers', data.layers, 1);
|
|
274
293
|
if (data.layers !== undefined) {
|
|
@@ -375,3 +394,10 @@ export function validateMeshData(data: MeshData): void {
|
|
|
375
394
|
}
|
|
376
395
|
}
|
|
377
396
|
}
|
|
397
|
+
|
|
398
|
+
/** Whether a lane holds anything but zeros: a builder writes zeros for a mesh that asked for none. */
|
|
399
|
+
function anyNonZero(lane: Float32Array | undefined): boolean {
|
|
400
|
+
if (lane === undefined) return false;
|
|
401
|
+
for (let i = 0; i < lane.length; i++) if (lane[i] !== 0) return true;
|
|
402
|
+
return false;
|
|
403
|
+
}
|