@threenative/assets 0.3.22 → 0.3.24
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/apply-worker.js +39 -11
- package/dist/index.d.ts +10 -0
- package/dist/index.js +47 -11
- package/package.json +4 -4
package/dist/apply-worker.js
CHANGED
|
@@ -16536,7 +16536,7 @@ async function BASIS(moduleArg = {}) {
|
|
|
16536
16536
|
var basis_encoder_default = BASIS;
|
|
16537
16537
|
|
|
16538
16538
|
// src/ktx2-encoder.ts
|
|
16539
|
-
var KTX2_ENCODER_VERSION = "basis-v2.5-ldr16m-zstd-rdo-fast-capped-
|
|
16539
|
+
var KTX2_ENCODER_VERSION = "basis-v2.5-ldr16m-zstd-rdo-fast-capped-projected-v4";
|
|
16540
16540
|
var OUTPUT_HEADER_SLACK = 64 * 1024;
|
|
16541
16541
|
var MAX_SOURCE_TEXELS = 16 * 1024 * 1024;
|
|
16542
16542
|
var modulePromise;
|
|
@@ -19425,6 +19425,7 @@ function _simplifyPoints(document, prim, options) {
|
|
|
19425
19425
|
}
|
|
19426
19426
|
var BASIS_TRANSCODER_BYTES = 600 * 1024;
|
|
19427
19427
|
var DEFAULT_MAX_SIZE = 2048;
|
|
19428
|
+
var PROJECTION_MAX_SIZE = Math.floor(Math.sqrt(MAX_SOURCE_TEXELS));
|
|
19428
19429
|
var DEFAULT_ETC1S_QUALITY = 150;
|
|
19429
19430
|
var BLOCK_SIZE = 4;
|
|
19430
19431
|
var MIP_FACTOR = 4 / 3;
|
|
@@ -19646,6 +19647,25 @@ function resolveTextureMaxSize(maxSize, slots, fallback = DEFAULT_MAX_SIZE) {
|
|
|
19646
19647
|
...slots.length === 0 ? [fallback] : slots.map((slot) => maxSize?.[slot] ?? fallback)
|
|
19647
19648
|
);
|
|
19648
19649
|
}
|
|
19650
|
+
function textureProjectionAtlas(texture) {
|
|
19651
|
+
const threenative = texture.getExtras().threenative;
|
|
19652
|
+
if (typeof threenative !== "object" || threenative === null) return void 0;
|
|
19653
|
+
const marker = threenative.textureProjection;
|
|
19654
|
+
if (marker === void 0) return void 0;
|
|
19655
|
+
const atlas = typeof marker === "object" && marker !== null ? marker.atlas : void 0;
|
|
19656
|
+
if (typeof atlas !== "number" || !Number.isSafeInteger(atlas) || atlas <= 0)
|
|
19657
|
+
throw new Error(
|
|
19658
|
+
`TN_ASSETS_TEXTURE_PROJECTION: embedded texture '${texture.getName() === "" ? "unnamed" : texture.getName()}' carries a threenative.textureProjection marker whose atlas is not a positive integer.`
|
|
19659
|
+
);
|
|
19660
|
+
return atlas;
|
|
19661
|
+
}
|
|
19662
|
+
function textureMaxSize(texture, maxSize, slots = listTextureSlots(texture)) {
|
|
19663
|
+
return resolveTextureMaxSize(
|
|
19664
|
+
maxSize,
|
|
19665
|
+
slots,
|
|
19666
|
+
textureProjectionAtlas(texture) === void 0 ? DEFAULT_MAX_SIZE : PROJECTION_MAX_SIZE
|
|
19667
|
+
);
|
|
19668
|
+
}
|
|
19649
19669
|
function cappedSize(width, height, maxSize) {
|
|
19650
19670
|
const longest = Math.max(width, height);
|
|
19651
19671
|
if (longest <= maxSize) return { height, width };
|
|
@@ -19653,20 +19673,21 @@ function cappedSize(width, height, maxSize) {
|
|
|
19653
19673
|
const snap = (value) => Math.max(BLOCK_SIZE, Math.round(value * scale3 / BLOCK_SIZE) * BLOCK_SIZE);
|
|
19654
19674
|
return { height: snap(height), width: snap(width) };
|
|
19655
19675
|
}
|
|
19656
|
-
function codecLadder(slots, forced) {
|
|
19676
|
+
function codecLadder(slots, forced, projected = false) {
|
|
19657
19677
|
const data = slots.length === 0 || slots.some((slot) => !COLOUR_SLOTS.has(slot));
|
|
19658
19678
|
if (forced !== void 0) {
|
|
19659
19679
|
if (forced === "etc1s" && data)
|
|
19660
19680
|
throw new Error("TN_ASSETS_TEXTURE_SLOT_CODEC: ETC1S is forbidden for normal/data slots.");
|
|
19661
19681
|
return [{ codec: forced }];
|
|
19662
19682
|
}
|
|
19663
|
-
|
|
19664
|
-
|
|
19683
|
+
if (data) return [{ codec: "uastc" }, { codec: "none" }];
|
|
19684
|
+
const uastcRungs = [
|
|
19665
19685
|
{ codec: "uastc", rdoLambda: 3 },
|
|
19666
19686
|
{ codec: "uastc", rdoLambda: 1 },
|
|
19667
19687
|
{ codec: "uastc" },
|
|
19668
19688
|
{ codec: "none" }
|
|
19669
19689
|
];
|
|
19690
|
+
return projected ? uastcRungs : [{ codec: "etc1s" }, ...uastcRungs];
|
|
19670
19691
|
}
|
|
19671
19692
|
var LARGE_LADDER_TEXELS = 256 * 256;
|
|
19672
19693
|
async function encodeTextureLadder(data, width, height, options) {
|
|
@@ -19674,7 +19695,7 @@ async function encodeTextureLadder(data, width, height, options) {
|
|
|
19674
19695
|
let smallest;
|
|
19675
19696
|
let smallerThanSource = options.maxBytes === void 0;
|
|
19676
19697
|
let sourceWins = false;
|
|
19677
|
-
for (const candidate of codecLadder(slots, options.forced)) {
|
|
19698
|
+
for (const candidate of codecLadder(slots, options.forced, options.projected === true)) {
|
|
19678
19699
|
if (candidate.codec === "none" && smallest !== void 0) return smallest;
|
|
19679
19700
|
if (sourceWins && candidate.codec !== "none") continue;
|
|
19680
19701
|
const rung = candidate.codec === "etc1s" ? `etc1s@${options.quality}` : candidate.rdoLambda === void 0 ? candidate.codec : `uastc+rdo \u03BB${candidate.rdoLambda} +zstd`;
|
|
@@ -19760,6 +19781,7 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
19760
19781
|
const formats = {};
|
|
19761
19782
|
const scores = {};
|
|
19762
19783
|
const skippedCompression = {};
|
|
19784
|
+
const projected = {};
|
|
19763
19785
|
let bytesBefore = 0;
|
|
19764
19786
|
let bytesAfter = 0;
|
|
19765
19787
|
let gpuBytesBefore = 0;
|
|
@@ -19771,6 +19793,8 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
19771
19793
|
const transcoderByImage = {};
|
|
19772
19794
|
for (const [index, texture] of textures.entries()) {
|
|
19773
19795
|
const key = keys[index] ?? `texture#${String(index)}`;
|
|
19796
|
+
const projectedAtlas = textureProjectionAtlas(texture);
|
|
19797
|
+
if (projectedAtlas !== void 0) projected[key] = projectedAtlas;
|
|
19774
19798
|
const image = texture.getImage();
|
|
19775
19799
|
if (image === null) {
|
|
19776
19800
|
throw new Error(
|
|
@@ -19834,7 +19858,7 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
19834
19858
|
continue;
|
|
19835
19859
|
}
|
|
19836
19860
|
const authoredCodec = authoredBasis && read(image).dataFormatDescriptor[0]?.colorModel === KHR_DF_MODEL_UASTC ? "uastc" : "etc1s";
|
|
19837
|
-
const maxSize =
|
|
19861
|
+
const maxSize = textureMaxSize(texture, options.maxSize, slots);
|
|
19838
19862
|
let decoded;
|
|
19839
19863
|
try {
|
|
19840
19864
|
if (authoredBasis) {
|
|
@@ -19852,7 +19876,7 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
19852
19876
|
);
|
|
19853
19877
|
}
|
|
19854
19878
|
const explicit = (options.overrides ?? []).some((override) => slots.includes(override.slot));
|
|
19855
|
-
const codec = codecLadder(slots, forced)[0]?.codec ?? "none";
|
|
19879
|
+
const codec = codecLadder(slots, forced, projectedAtlas !== void 0)[0]?.codec ?? "none";
|
|
19856
19880
|
bytesBefore += image.byteLength;
|
|
19857
19881
|
gpuBytesBefore += gpuBytes(
|
|
19858
19882
|
decoded.width,
|
|
@@ -19941,13 +19965,13 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
19941
19965
|
};
|
|
19942
19966
|
continue;
|
|
19943
19967
|
}
|
|
19944
|
-
const authoredContainer = !explicit && !authoredBasis && options.jpeg !== false && options.astc !== true && target.width === decoded.width && target.height === decoded.height && UNIVERSAL_IMAGE_CONTAINERS.has(texture.getMimeType()) && slots.some((slot) => COLOUR_SLOTS.has(slot));
|
|
19968
|
+
const authoredContainer = !explicit && projectedAtlas === void 0 && !authoredBasis && options.jpeg !== false && options.astc !== true && target.width === decoded.width && target.height === decoded.height && UNIVERSAL_IMAGE_CONTAINERS.has(texture.getMimeType()) && slots.some((slot) => COLOUR_SLOTS.has(slot));
|
|
19945
19969
|
const jpeg = authoredContainer ? await encodeJpegCandidate(data, target.width, target.height, {
|
|
19946
19970
|
...textureQualitySemantics(texture),
|
|
19947
19971
|
floor: options.floor
|
|
19948
19972
|
}) : void 0;
|
|
19949
19973
|
const jpegLimit = jpeg !== void 0 && jpeg.buffer.byteLength < image.byteLength ? jpeg.buffer.byteLength : image.byteLength;
|
|
19950
|
-
const automatic = !explicit && target.width === decoded.width && target.height === decoded.height && retainable(texture.getMimeType());
|
|
19974
|
+
const automatic = !explicit && projectedAtlas === void 0 && target.width === decoded.width && target.height === decoded.height && retainable(texture.getMimeType());
|
|
19951
19975
|
const charged = automatic && options.astc !== true;
|
|
19952
19976
|
let selected;
|
|
19953
19977
|
try {
|
|
@@ -19979,7 +20003,8 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
19979
20003
|
quality,
|
|
19980
20004
|
...options.astc === true ? { astc: true, gltfColorPrimaries: srgb ? 1 : 0 } : {},
|
|
19981
20005
|
...automatic ? { maxBytes: jpegLimit } : {},
|
|
19982
|
-
...forced === void 0 ? {} : { forced }
|
|
20006
|
+
...forced === void 0 ? {} : { forced },
|
|
20007
|
+
...projectedAtlas === void 0 ? {} : { projected: true }
|
|
19983
20008
|
});
|
|
19984
20009
|
}
|
|
19985
20010
|
if (authoredBasis && selected.encoded === void 0)
|
|
@@ -20079,6 +20104,7 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
20079
20104
|
gpuBytesBefore,
|
|
20080
20105
|
resized,
|
|
20081
20106
|
skippedCompression,
|
|
20107
|
+
...Object.keys(projected).length === 0 ? {} : { projected },
|
|
20082
20108
|
...transcoderSavings > 0 ? { transcoderSavings } : {},
|
|
20083
20109
|
...transcoderRequired ? { transcoderRequired: true } : {},
|
|
20084
20110
|
...Object.keys(transcoderByImage).length === 0 ? {} : { transcoderByImage }
|
|
@@ -24416,7 +24442,9 @@ function sharedSettings(texture, textureOptions) {
|
|
|
24416
24442
|
jpegLadder: "colour-opaque-q75-90-v1",
|
|
24417
24443
|
floor: resolveImageQualityFloor(textureOptions.floor),
|
|
24418
24444
|
keepSmallerSource: keepSmallerSource(textureOptions),
|
|
24419
|
-
|
|
24445
|
+
// The projection marker changes the cap, so it belongs in the shared-image key: an
|
|
24446
|
+
// unmarked consumer of the same bytes must not hand a marked atlas a capped cook.
|
|
24447
|
+
maxSize: textureMaxSize(texture, textureOptions.maxSize),
|
|
24420
24448
|
overrides: textureOptions.overrides ?? [],
|
|
24421
24449
|
quality: textureOptions.quality ?? null,
|
|
24422
24450
|
transcoderBytes: textureOptions.transcoderBytes ?? null
|
package/dist/index.d.ts
CHANGED
|
@@ -96,6 +96,11 @@ interface IEmbeddedTextureSummary {
|
|
|
96
96
|
readonly resized: number;
|
|
97
97
|
/** Images retained at their authored bytes, by name, with the reason each one was not cooked. */
|
|
98
98
|
readonly skippedCompression: Readonly<Record<string, TextureSkipReason>>;
|
|
99
|
+
/**
|
|
100
|
+
* Texture-projection images, keyed like `formats`, valued with the atlas edge the asset MCP
|
|
101
|
+
* marked: the marker kept the authored size and skipped ETC1S, so a flat row stays explained.
|
|
102
|
+
*/
|
|
103
|
+
readonly projected?: Readonly<Record<string, number>>;
|
|
99
104
|
/**
|
|
100
105
|
* Bytes KTX2 saves over the decoder-free container across this model's automatic images,
|
|
101
106
|
* whether or not the transcoder charge let it ship. The build sums it over every model to
|
|
@@ -716,6 +721,11 @@ interface IEmbeddedTextureRow {
|
|
|
716
721
|
readonly count: number;
|
|
717
722
|
/** Chosen codec per embedded image, keyed by texture name. */
|
|
718
723
|
readonly formats?: Readonly<Record<string, string>>;
|
|
724
|
+
/**
|
|
725
|
+
* Texture-projection images and the atlas edge their marker declared, keyed like `formats`.
|
|
726
|
+
* Printed per image so a cook that skipped ETC1S and the 2048 cap says why.
|
|
727
|
+
*/
|
|
728
|
+
readonly projected?: Readonly<Record<string, number>>;
|
|
719
729
|
readonly gpuBytesAfter: number;
|
|
720
730
|
readonly gpuBytesBefore: number;
|
|
721
731
|
readonly resized: number;
|
package/dist/index.js
CHANGED
|
@@ -4478,7 +4478,7 @@ async function BASIS(moduleArg = {}) {
|
|
|
4478
4478
|
var basis_encoder_default = BASIS;
|
|
4479
4479
|
|
|
4480
4480
|
// src/ktx2-encoder.ts
|
|
4481
|
-
var KTX2_ENCODER_VERSION = "basis-v2.5-ldr16m-zstd-rdo-fast-capped-
|
|
4481
|
+
var KTX2_ENCODER_VERSION = "basis-v2.5-ldr16m-zstd-rdo-fast-capped-projected-v4";
|
|
4482
4482
|
var OUTPUT_HEADER_SLACK = 64 * 1024;
|
|
4483
4483
|
var MAX_SOURCE_TEXELS = 16 * 1024 * 1024;
|
|
4484
4484
|
var modulePromise;
|
|
@@ -5130,6 +5130,11 @@ function embeddedTextureRow(value) {
|
|
|
5130
5130
|
)
|
|
5131
5131
|
)
|
|
5132
5132
|
} : {},
|
|
5133
|
+
...isRecord(value.projected) ? {
|
|
5134
|
+
projected: Object.fromEntries(
|
|
5135
|
+
Object.entries(value.projected).filter(([, atlas]) => typeof atlas === "number")
|
|
5136
|
+
)
|
|
5137
|
+
} : {},
|
|
5133
5138
|
gpuBytesAfter: value.gpuBytesAfter,
|
|
5134
5139
|
gpuBytesBefore: value.gpuBytesBefore,
|
|
5135
5140
|
resized: value.resized,
|
|
@@ -20857,6 +20862,7 @@ function formatHealthReport(report) {
|
|
|
20857
20862
|
// src/passes/model-textures.ts
|
|
20858
20863
|
var BASIS_TRANSCODER_BYTES = 600 * 1024;
|
|
20859
20864
|
var DEFAULT_MAX_SIZE = 2048;
|
|
20865
|
+
var PROJECTION_MAX_SIZE = Math.floor(Math.sqrt(MAX_SOURCE_TEXELS));
|
|
20860
20866
|
var DEFAULT_ETC1S_QUALITY = 150;
|
|
20861
20867
|
var BLOCK_SIZE = 4;
|
|
20862
20868
|
var MIP_FACTOR = 4 / 3;
|
|
@@ -21078,6 +21084,25 @@ function resolveTextureMaxSize(maxSize, slots, fallback = DEFAULT_MAX_SIZE) {
|
|
|
21078
21084
|
...slots.length === 0 ? [fallback] : slots.map((slot) => maxSize?.[slot] ?? fallback)
|
|
21079
21085
|
);
|
|
21080
21086
|
}
|
|
21087
|
+
function textureProjectionAtlas(texture) {
|
|
21088
|
+
const threenative = texture.getExtras().threenative;
|
|
21089
|
+
if (typeof threenative !== "object" || threenative === null) return void 0;
|
|
21090
|
+
const marker = threenative.textureProjection;
|
|
21091
|
+
if (marker === void 0) return void 0;
|
|
21092
|
+
const atlas = typeof marker === "object" && marker !== null ? marker.atlas : void 0;
|
|
21093
|
+
if (typeof atlas !== "number" || !Number.isSafeInteger(atlas) || atlas <= 0)
|
|
21094
|
+
throw new Error(
|
|
21095
|
+
`TN_ASSETS_TEXTURE_PROJECTION: embedded texture '${texture.getName() === "" ? "unnamed" : texture.getName()}' carries a threenative.textureProjection marker whose atlas is not a positive integer.`
|
|
21096
|
+
);
|
|
21097
|
+
return atlas;
|
|
21098
|
+
}
|
|
21099
|
+
function textureMaxSize(texture, maxSize, slots = listTextureSlots(texture)) {
|
|
21100
|
+
return resolveTextureMaxSize(
|
|
21101
|
+
maxSize,
|
|
21102
|
+
slots,
|
|
21103
|
+
textureProjectionAtlas(texture) === void 0 ? DEFAULT_MAX_SIZE : PROJECTION_MAX_SIZE
|
|
21104
|
+
);
|
|
21105
|
+
}
|
|
21081
21106
|
function cappedSize(width, height, maxSize) {
|
|
21082
21107
|
const longest = Math.max(width, height);
|
|
21083
21108
|
if (longest <= maxSize) return { height, width };
|
|
@@ -21085,20 +21110,21 @@ function cappedSize(width, height, maxSize) {
|
|
|
21085
21110
|
const snap = (value) => Math.max(BLOCK_SIZE, Math.round(value * scale3 / BLOCK_SIZE) * BLOCK_SIZE);
|
|
21086
21111
|
return { height: snap(height), width: snap(width) };
|
|
21087
21112
|
}
|
|
21088
|
-
function codecLadder(slots, forced) {
|
|
21113
|
+
function codecLadder(slots, forced, projected = false) {
|
|
21089
21114
|
const data = slots.length === 0 || slots.some((slot) => !COLOUR_SLOTS.has(slot));
|
|
21090
21115
|
if (forced !== void 0) {
|
|
21091
21116
|
if (forced === "etc1s" && data)
|
|
21092
21117
|
throw new Error("TN_ASSETS_TEXTURE_SLOT_CODEC: ETC1S is forbidden for normal/data slots.");
|
|
21093
21118
|
return [{ codec: forced }];
|
|
21094
21119
|
}
|
|
21095
|
-
|
|
21096
|
-
|
|
21120
|
+
if (data) return [{ codec: "uastc" }, { codec: "none" }];
|
|
21121
|
+
const uastcRungs = [
|
|
21097
21122
|
{ codec: "uastc", rdoLambda: 3 },
|
|
21098
21123
|
{ codec: "uastc", rdoLambda: 1 },
|
|
21099
21124
|
{ codec: "uastc" },
|
|
21100
21125
|
{ codec: "none" }
|
|
21101
21126
|
];
|
|
21127
|
+
return projected ? uastcRungs : [{ codec: "etc1s" }, ...uastcRungs];
|
|
21102
21128
|
}
|
|
21103
21129
|
var LARGE_LADDER_TEXELS = 256 * 256;
|
|
21104
21130
|
async function encodeTextureLadder(data, width, height, options) {
|
|
@@ -21106,7 +21132,7 @@ async function encodeTextureLadder(data, width, height, options) {
|
|
|
21106
21132
|
let smallest;
|
|
21107
21133
|
let smallerThanSource = options.maxBytes === void 0;
|
|
21108
21134
|
let sourceWins = false;
|
|
21109
|
-
for (const candidate of codecLadder(slots, options.forced)) {
|
|
21135
|
+
for (const candidate of codecLadder(slots, options.forced, options.projected === true)) {
|
|
21110
21136
|
if (candidate.codec === "none" && smallest !== void 0) return smallest;
|
|
21111
21137
|
if (sourceWins && candidate.codec !== "none") continue;
|
|
21112
21138
|
const rung = candidate.codec === "etc1s" ? `etc1s@${options.quality}` : candidate.rdoLambda === void 0 ? candidate.codec : `uastc+rdo \u03BB${candidate.rdoLambda} +zstd`;
|
|
@@ -21192,6 +21218,7 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
21192
21218
|
const formats = {};
|
|
21193
21219
|
const scores = {};
|
|
21194
21220
|
const skippedCompression = {};
|
|
21221
|
+
const projected = {};
|
|
21195
21222
|
let bytesBefore = 0;
|
|
21196
21223
|
let bytesAfter = 0;
|
|
21197
21224
|
let gpuBytesBefore = 0;
|
|
@@ -21203,6 +21230,8 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
21203
21230
|
const transcoderByImage = {};
|
|
21204
21231
|
for (const [index, texture] of textures.entries()) {
|
|
21205
21232
|
const key = keys[index] ?? `texture#${String(index)}`;
|
|
21233
|
+
const projectedAtlas = textureProjectionAtlas(texture);
|
|
21234
|
+
if (projectedAtlas !== void 0) projected[key] = projectedAtlas;
|
|
21206
21235
|
const image = texture.getImage();
|
|
21207
21236
|
if (image === null) {
|
|
21208
21237
|
throw new Error(
|
|
@@ -21266,7 +21295,7 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
21266
21295
|
continue;
|
|
21267
21296
|
}
|
|
21268
21297
|
const authoredCodec = authoredBasis && read(image).dataFormatDescriptor[0]?.colorModel === KHR_DF_MODEL_UASTC ? "uastc" : "etc1s";
|
|
21269
|
-
const maxSize =
|
|
21298
|
+
const maxSize = textureMaxSize(texture, options.maxSize, slots);
|
|
21270
21299
|
let decoded;
|
|
21271
21300
|
try {
|
|
21272
21301
|
if (authoredBasis) {
|
|
@@ -21284,7 +21313,7 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
21284
21313
|
);
|
|
21285
21314
|
}
|
|
21286
21315
|
const explicit = (options.overrides ?? []).some((override) => slots.includes(override.slot));
|
|
21287
|
-
const codec = codecLadder(slots, forced)[0]?.codec ?? "none";
|
|
21316
|
+
const codec = codecLadder(slots, forced, projectedAtlas !== void 0)[0]?.codec ?? "none";
|
|
21288
21317
|
bytesBefore += image.byteLength;
|
|
21289
21318
|
gpuBytesBefore += gpuBytes(
|
|
21290
21319
|
decoded.width,
|
|
@@ -21373,13 +21402,13 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
21373
21402
|
};
|
|
21374
21403
|
continue;
|
|
21375
21404
|
}
|
|
21376
|
-
const authoredContainer = !explicit && !authoredBasis && options.jpeg !== false && options.astc !== true && target.width === decoded.width && target.height === decoded.height && UNIVERSAL_IMAGE_CONTAINERS.has(texture.getMimeType()) && slots.some((slot) => COLOUR_SLOTS.has(slot));
|
|
21405
|
+
const authoredContainer = !explicit && projectedAtlas === void 0 && !authoredBasis && options.jpeg !== false && options.astc !== true && target.width === decoded.width && target.height === decoded.height && UNIVERSAL_IMAGE_CONTAINERS.has(texture.getMimeType()) && slots.some((slot) => COLOUR_SLOTS.has(slot));
|
|
21377
21406
|
const jpeg = authoredContainer ? await encodeJpegCandidate(data, target.width, target.height, {
|
|
21378
21407
|
...textureQualitySemantics(texture),
|
|
21379
21408
|
floor: options.floor
|
|
21380
21409
|
}) : void 0;
|
|
21381
21410
|
const jpegLimit = jpeg !== void 0 && jpeg.buffer.byteLength < image.byteLength ? jpeg.buffer.byteLength : image.byteLength;
|
|
21382
|
-
const automatic = !explicit && target.width === decoded.width && target.height === decoded.height && retainable(texture.getMimeType());
|
|
21411
|
+
const automatic = !explicit && projectedAtlas === void 0 && target.width === decoded.width && target.height === decoded.height && retainable(texture.getMimeType());
|
|
21383
21412
|
const charged = automatic && options.astc !== true;
|
|
21384
21413
|
let selected;
|
|
21385
21414
|
try {
|
|
@@ -21411,7 +21440,8 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
21411
21440
|
quality: quality2,
|
|
21412
21441
|
...options.astc === true ? { astc: true, gltfColorPrimaries: srgb ? 1 : 0 } : {},
|
|
21413
21442
|
...automatic ? { maxBytes: jpegLimit } : {},
|
|
21414
|
-
...forced === void 0 ? {} : { forced }
|
|
21443
|
+
...forced === void 0 ? {} : { forced },
|
|
21444
|
+
...projectedAtlas === void 0 ? {} : { projected: true }
|
|
21415
21445
|
});
|
|
21416
21446
|
}
|
|
21417
21447
|
if (authoredBasis && selected.encoded === void 0)
|
|
@@ -21511,6 +21541,7 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
21511
21541
|
gpuBytesBefore,
|
|
21512
21542
|
resized,
|
|
21513
21543
|
skippedCompression,
|
|
21544
|
+
...Object.keys(projected).length === 0 ? {} : { projected },
|
|
21514
21545
|
...transcoderSavings > 0 ? { transcoderSavings } : {},
|
|
21515
21546
|
...transcoderRequired ? { transcoderRequired: true } : {},
|
|
21516
21547
|
...Object.keys(transcoderByImage).length === 0 ? {} : { transcoderByImage }
|
|
@@ -26283,7 +26314,9 @@ function sharedSettings(texture, textureOptions) {
|
|
|
26283
26314
|
jpegLadder: "colour-opaque-q75-90-v1",
|
|
26284
26315
|
floor: resolveImageQualityFloor(textureOptions.floor),
|
|
26285
26316
|
keepSmallerSource: keepSmallerSource(textureOptions),
|
|
26286
|
-
|
|
26317
|
+
// The projection marker changes the cap, so it belongs in the shared-image key: an
|
|
26318
|
+
// unmarked consumer of the same bytes must not hand a marked atlas a capped cook.
|
|
26319
|
+
maxSize: textureMaxSize(texture, textureOptions.maxSize),
|
|
26287
26320
|
overrides: textureOptions.overrides ?? [],
|
|
26288
26321
|
quality: textureOptions.quality ?? null,
|
|
26289
26322
|
transcoderBytes: textureOptions.transcoderBytes ?? null
|
|
@@ -27441,6 +27474,9 @@ function formatModelSizes(rows) {
|
|
|
27441
27474
|
...Object.entries(embedded.skippedCompression ?? {}).map(
|
|
27442
27475
|
([name, reason]) => `embedded texture ${row.logicalPath}#${name}: compression skipped: ${reason}`
|
|
27443
27476
|
),
|
|
27477
|
+
...Object.entries(embedded.projected ?? {}).map(
|
|
27478
|
+
([name, atlas]) => `embedded texture ${row.logicalPath}#${name}: textureProjection atlas ${String(atlas)} px`
|
|
27479
|
+
),
|
|
27444
27480
|
...Object.entries(embedded.quality ?? {}).map(
|
|
27445
27481
|
([name, score]) => qualityLine(`${row.logicalPath}#${name}`, score)
|
|
27446
27482
|
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threenative/assets",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.24",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Content-addressed asset compile step for ThreeNative games.",
|
|
6
6
|
"keywords": [
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"publint": "0.3.22",
|
|
52
52
|
"tsup": "8.5.1",
|
|
53
53
|
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
54
|
-
"@threenative/blender-bridge": "0.2.
|
|
55
|
-
"@threenative/procedural-environment": "0.1.
|
|
54
|
+
"@threenative/blender-bridge": "0.2.16",
|
|
55
|
+
"@threenative/procedural-environment": "0.1.9"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@gltf-transform/core": "4.4.2",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"three-mesh-bvh": "0.9.14",
|
|
71
71
|
"wasm-media-encoders": "0.7.0",
|
|
72
72
|
"xatlasjs": "0.2.0",
|
|
73
|
-
"@threenative/terrain": "0.1.
|
|
73
|
+
"@threenative/terrain": "0.1.19"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
76
|
"build": "tsup --config tsup.config.ts && node scripts/copy-basis-encoder.mjs && node scripts/bundle-blender-gpl.mjs && publint",
|