@driftengine/drft 4.4.2 → 4.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/dist/drftFormat.d.ts +16 -3
- package/dist/drftFormat.js +7 -3
- package/dist/drftRead.js +10 -0
- package/dist/drftWrite.js +6 -0
- package/package.json +4 -4
- package/src/drftFormat.ts +16 -3
- package/src/drftRead.ts +10 -0
- package/src/drftWrite.ts +6 -0
package/dist/drftFormat.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare const DRFT_VERSION_MAJOR = 1;
|
|
|
20
20
|
* Additive revisions within a generation: new optional chunks, new attribute bits, new
|
|
21
21
|
* enum values with a defined fallback. Never a changed meaning.
|
|
22
22
|
*/
|
|
23
|
-
export declare const DRFT_VERSION_MINOR =
|
|
23
|
+
export declare const DRFT_VERSION_MINOR = 19;
|
|
24
24
|
/** Bytes before the chunk table. */
|
|
25
25
|
export declare const HEADER_BYTES = 32;
|
|
26
26
|
/** Bytes per chunk table entry. */
|
|
@@ -488,9 +488,18 @@ export interface DrftMaterial {
|
|
|
488
488
|
* tree's cards are not drawn. Absent means false, which is how every surface before it was drawn.
|
|
489
489
|
*/
|
|
490
490
|
readonly doubleSided?: boolean;
|
|
491
|
+
/**
|
|
492
|
+
* Glass, 1.19: the share of light that passes, 0 opaque to 1 clear. Absent or 0 is not glass,
|
|
493
|
+
* which is what every surface before it was. See the engine's `glass.ts`.
|
|
494
|
+
*/
|
|
495
|
+
readonly transmission?: number;
|
|
496
|
+
/** How milky the glass is, 0 see-through to 1 fully diffusing. 1.19. */
|
|
497
|
+
readonly frost?: number;
|
|
498
|
+
/** The colour light takes through the glass; white is clear. 1.19. */
|
|
499
|
+
readonly tint?: readonly [number, number, number];
|
|
491
500
|
}
|
|
492
501
|
/** Floats in a `MATL` entry, then the signed texture indices that follow them. */
|
|
493
|
-
export declare const MATERIAL_FLOATS =
|
|
502
|
+
export declare const MATERIAL_FLOATS = 20;
|
|
494
503
|
/**
|
|
495
504
|
* Albedo, normal, ORM and emissive.
|
|
496
505
|
*
|
|
@@ -501,7 +510,11 @@ export declare const MATERIAL_FLOATS = 15;
|
|
|
501
510
|
* them is speculative — only unbound, and the plans that bind them need no second stride bump.
|
|
502
511
|
*/
|
|
503
512
|
export declare const MATERIAL_INDICES = 4;
|
|
504
|
-
/**
|
|
513
|
+
/**
|
|
514
|
+
* A `u32` of flags after them, since 1.18: bit 0 is `blend`, bit 1 is `doubleSided`. Glass's five
|
|
515
|
+
* floats — transmission, frost, tint — follow the flags word, since 1.19, which is why the float
|
|
516
|
+
* count is twenty while the entry is still laid out floats, indices, flags, floats.
|
|
517
|
+
*/
|
|
505
518
|
export declare const MATERIAL_FLAGS = 1;
|
|
506
519
|
export declare const MATERIAL_ENTRY_BYTES: number;
|
|
507
520
|
/** What `HEAD` says about the asset as a whole. */
|
package/dist/drftFormat.js
CHANGED
|
@@ -20,7 +20,7 @@ export const DRFT_VERSION_MAJOR = 1;
|
|
|
20
20
|
* Additive revisions within a generation: new optional chunks, new attribute bits, new
|
|
21
21
|
* enum values with a defined fallback. Never a changed meaning.
|
|
22
22
|
*/
|
|
23
|
-
export const DRFT_VERSION_MINOR =
|
|
23
|
+
export const DRFT_VERSION_MINOR = 19;
|
|
24
24
|
/** Bytes before the chunk table. */
|
|
25
25
|
export const HEADER_BYTES = 32;
|
|
26
26
|
/** Bytes per chunk table entry. */
|
|
@@ -394,7 +394,7 @@ export function codecName(codec) {
|
|
|
394
394
|
: `codec ${codec}`;
|
|
395
395
|
}
|
|
396
396
|
/** Floats in a `MATL` entry, then the signed texture indices that follow them. */
|
|
397
|
-
export const MATERIAL_FLOATS =
|
|
397
|
+
export const MATERIAL_FLOATS = 20;
|
|
398
398
|
/**
|
|
399
399
|
* Albedo, normal, ORM and emissive.
|
|
400
400
|
*
|
|
@@ -405,7 +405,11 @@ export const MATERIAL_FLOATS = 15;
|
|
|
405
405
|
* them is speculative — only unbound, and the plans that bind them need no second stride bump.
|
|
406
406
|
*/
|
|
407
407
|
export const MATERIAL_INDICES = 4;
|
|
408
|
-
/**
|
|
408
|
+
/**
|
|
409
|
+
* A `u32` of flags after them, since 1.18: bit 0 is `blend`, bit 1 is `doubleSided`. Glass's five
|
|
410
|
+
* floats — transmission, frost, tint — follow the flags word, since 1.19, which is why the float
|
|
411
|
+
* count is twenty while the entry is still laid out floats, indices, flags, floats.
|
|
412
|
+
*/
|
|
409
413
|
export const MATERIAL_FLAGS = 1;
|
|
410
414
|
export const MATERIAL_ENTRY_BYTES = MATERIAL_FLOATS * 4 + MATERIAL_INDICES * 4 + MATERIAL_FLAGS * 4;
|
|
411
415
|
/**
|
package/dist/drftRead.js
CHANGED
|
@@ -536,6 +536,16 @@ export function readMaterials(buffer, chunk) {
|
|
|
536
536
|
blend: has(76, 4) ? (view.getUint32(at + 76, true) & 1) !== 0 : false,
|
|
537
537
|
/* One-sided unless it says otherwise, which is how every file before the bit was drawn. */
|
|
538
538
|
doubleSided: has(76, 4) ? (view.getUint32(at + 76, true) & 2) !== 0 : false,
|
|
539
|
+
/* Not glass, which is what every file before 1.19 meant. */
|
|
540
|
+
transmission: has(80, 4) ? view.getFloat32(at + 80, true) : 0,
|
|
541
|
+
frost: has(84, 4) ? view.getFloat32(at + 84, true) : 0,
|
|
542
|
+
tint: has(88, 12)
|
|
543
|
+
? [
|
|
544
|
+
view.getFloat32(at + 88, true),
|
|
545
|
+
view.getFloat32(at + 92, true),
|
|
546
|
+
view.getFloat32(at + 96, true),
|
|
547
|
+
]
|
|
548
|
+
: [1, 1, 1],
|
|
539
549
|
});
|
|
540
550
|
}
|
|
541
551
|
return out;
|
package/dist/drftWrite.js
CHANGED
|
@@ -366,6 +366,12 @@ function buildMaterials(materials) {
|
|
|
366
366
|
view.setFloat32(at + 68, material.occlusionStrength, true);
|
|
367
367
|
view.setFloat32(at + 72, material.cutout, true);
|
|
368
368
|
view.setUint32(at + 76, (material.blend === true ? 1 : 0) | (material.doubleSided === true ? 2 : 0), true);
|
|
369
|
+
/* Glass, 1.19: after the flags word, so every earlier offset stays where readers expect it. */
|
|
370
|
+
view.setFloat32(at + 80, material.transmission ?? 0, true);
|
|
371
|
+
view.setFloat32(at + 84, material.frost ?? 0, true);
|
|
372
|
+
view.setFloat32(at + 88, material.tint?.[0] ?? 1, true);
|
|
373
|
+
view.setFloat32(at + 92, material.tint?.[1] ?? 1, true);
|
|
374
|
+
view.setFloat32(at + 96, material.tint?.[2] ?? 1, true);
|
|
369
375
|
at += MATERIAL_ENTRY_BYTES;
|
|
370
376
|
}
|
|
371
377
|
return { code: CHUNK_MATL, flags: 0, bytes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driftengine/drft",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
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.
|
|
31
|
-
"@driftengine/entities": "4.
|
|
32
|
-
"@driftengine/texture": "4.
|
|
30
|
+
"@driftengine/core": "4.5.0",
|
|
31
|
+
"@driftengine/entities": "4.5.0",
|
|
32
|
+
"@driftengine/texture": "4.5.0"
|
|
33
33
|
},
|
|
34
34
|
"author": "Drift Technologies",
|
|
35
35
|
"repository": {
|
package/src/drftFormat.ts
CHANGED
|
@@ -23,7 +23,7 @@ export const DRFT_VERSION_MAJOR = 1;
|
|
|
23
23
|
* Additive revisions within a generation: new optional chunks, new attribute bits, new
|
|
24
24
|
* enum values with a defined fallback. Never a changed meaning.
|
|
25
25
|
*/
|
|
26
|
-
export const DRFT_VERSION_MINOR =
|
|
26
|
+
export const DRFT_VERSION_MINOR = 19;
|
|
27
27
|
|
|
28
28
|
/** Bytes before the chunk table. */
|
|
29
29
|
export const HEADER_BYTES = 32;
|
|
@@ -582,10 +582,19 @@ export interface DrftMaterial {
|
|
|
582
582
|
* tree's cards are not drawn. Absent means false, which is how every surface before it was drawn.
|
|
583
583
|
*/
|
|
584
584
|
readonly doubleSided?: boolean;
|
|
585
|
+
/**
|
|
586
|
+
* Glass, 1.19: the share of light that passes, 0 opaque to 1 clear. Absent or 0 is not glass,
|
|
587
|
+
* which is what every surface before it was. See the engine's `glass.ts`.
|
|
588
|
+
*/
|
|
589
|
+
readonly transmission?: number;
|
|
590
|
+
/** How milky the glass is, 0 see-through to 1 fully diffusing. 1.19. */
|
|
591
|
+
readonly frost?: number;
|
|
592
|
+
/** The colour light takes through the glass; white is clear. 1.19. */
|
|
593
|
+
readonly tint?: readonly [number, number, number];
|
|
585
594
|
}
|
|
586
595
|
|
|
587
596
|
/** Floats in a `MATL` entry, then the signed texture indices that follow them. */
|
|
588
|
-
export const MATERIAL_FLOATS =
|
|
597
|
+
export const MATERIAL_FLOATS = 20;
|
|
589
598
|
/**
|
|
590
599
|
* Albedo, normal, ORM and emissive.
|
|
591
600
|
*
|
|
@@ -596,7 +605,11 @@ export const MATERIAL_FLOATS = 15;
|
|
|
596
605
|
* them is speculative — only unbound, and the plans that bind them need no second stride bump.
|
|
597
606
|
*/
|
|
598
607
|
export const MATERIAL_INDICES = 4;
|
|
599
|
-
/**
|
|
608
|
+
/**
|
|
609
|
+
* A `u32` of flags after them, since 1.18: bit 0 is `blend`, bit 1 is `doubleSided`. Glass's five
|
|
610
|
+
* floats — transmission, frost, tint — follow the flags word, since 1.19, which is why the float
|
|
611
|
+
* count is twenty while the entry is still laid out floats, indices, flags, floats.
|
|
612
|
+
*/
|
|
600
613
|
export const MATERIAL_FLAGS = 1;
|
|
601
614
|
export const MATERIAL_ENTRY_BYTES = MATERIAL_FLOATS * 4 + MATERIAL_INDICES * 4 + MATERIAL_FLAGS * 4;
|
|
602
615
|
|
package/src/drftRead.ts
CHANGED
|
@@ -758,6 +758,16 @@ export function readMaterials(buffer: ArrayBuffer, chunk: DrftChunk): DrftMateri
|
|
|
758
758
|
blend: has(76, 4) ? (view.getUint32(at + 76, true) & 1) !== 0 : false,
|
|
759
759
|
/* One-sided unless it says otherwise, which is how every file before the bit was drawn. */
|
|
760
760
|
doubleSided: has(76, 4) ? (view.getUint32(at + 76, true) & 2) !== 0 : false,
|
|
761
|
+
/* Not glass, which is what every file before 1.19 meant. */
|
|
762
|
+
transmission: has(80, 4) ? view.getFloat32(at + 80, true) : 0,
|
|
763
|
+
frost: has(84, 4) ? view.getFloat32(at + 84, true) : 0,
|
|
764
|
+
tint: has(88, 12)
|
|
765
|
+
? [
|
|
766
|
+
view.getFloat32(at + 88, true),
|
|
767
|
+
view.getFloat32(at + 92, true),
|
|
768
|
+
view.getFloat32(at + 96, true),
|
|
769
|
+
]
|
|
770
|
+
: [1, 1, 1],
|
|
761
771
|
});
|
|
762
772
|
}
|
|
763
773
|
return out;
|
package/src/drftWrite.ts
CHANGED
|
@@ -563,6 +563,12 @@ function buildMaterials(materials: readonly DrftMaterial[]): PendingChunk {
|
|
|
563
563
|
(material.blend === true ? 1 : 0) | (material.doubleSided === true ? 2 : 0),
|
|
564
564
|
true,
|
|
565
565
|
);
|
|
566
|
+
/* Glass, 1.19: after the flags word, so every earlier offset stays where readers expect it. */
|
|
567
|
+
view.setFloat32(at + 80, material.transmission ?? 0, true);
|
|
568
|
+
view.setFloat32(at + 84, material.frost ?? 0, true);
|
|
569
|
+
view.setFloat32(at + 88, material.tint?.[0] ?? 1, true);
|
|
570
|
+
view.setFloat32(at + 92, material.tint?.[1] ?? 1, true);
|
|
571
|
+
view.setFloat32(at + 96, material.tint?.[2] ?? 1, true);
|
|
566
572
|
at += MATERIAL_ENTRY_BYTES;
|
|
567
573
|
}
|
|
568
574
|
return { code: CHUNK_MATL, flags: 0, bytes };
|