@threenative/assets 0.3.13 → 0.3.14
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 +99 -5
- package/dist/index.d.ts +7 -0
- package/dist/index.js +79 -15
- package/package.json +3 -3
package/dist/apply-worker.js
CHANGED
|
@@ -18020,6 +18020,46 @@ function dequantizeAttributeArray(srcArray, componentType, normalized) {
|
|
|
18020
18020
|
return dstArray;
|
|
18021
18021
|
}
|
|
18022
18022
|
var { TEXTURE_INFO, ROOT: ROOT$1 } = PropertyType;
|
|
18023
|
+
function cloneDocument(source) {
|
|
18024
|
+
const target = new Document().setLogger(source.getLogger());
|
|
18025
|
+
const resolve2 = createDefaultPropertyResolver(target, source);
|
|
18026
|
+
mergeDocuments(target, source, resolve2);
|
|
18027
|
+
target.getRoot().copy(source.getRoot(), resolve2);
|
|
18028
|
+
return target;
|
|
18029
|
+
}
|
|
18030
|
+
function mergeDocuments(target, source, resolve2) {
|
|
18031
|
+
resolve2 ||= createDefaultPropertyResolver(target, source);
|
|
18032
|
+
for (const sourceExtension of source.getRoot().listExtensionsUsed()) {
|
|
18033
|
+
const targetExtension = target.createExtension(sourceExtension.constructor);
|
|
18034
|
+
if (sourceExtension.isRequired()) targetExtension.setRequired(true);
|
|
18035
|
+
}
|
|
18036
|
+
return _copyToDocument(target, source, listNonRootProperties(source), resolve2);
|
|
18037
|
+
}
|
|
18038
|
+
function _copyToDocument(target, source, sourceProperties, resolve2) {
|
|
18039
|
+
resolve2 ||= createDefaultPropertyResolver(target, source);
|
|
18040
|
+
const propertyMap = /* @__PURE__ */ new Map();
|
|
18041
|
+
for (const sourceProp of sourceProperties) if (!propertyMap.has(sourceProp) && sourceProp.propertyType !== TEXTURE_INFO) propertyMap.set(sourceProp, resolve2(sourceProp));
|
|
18042
|
+
for (const [sourceProp, targetProp] of propertyMap.entries()) targetProp.copy(sourceProp, resolve2);
|
|
18043
|
+
return propertyMap;
|
|
18044
|
+
}
|
|
18045
|
+
function createDefaultPropertyResolver(target, source) {
|
|
18046
|
+
const propertyMap = /* @__PURE__ */ new Map([[source.getRoot(), target.getRoot()]]);
|
|
18047
|
+
return (sourceProp) => {
|
|
18048
|
+
if (sourceProp.propertyType === TEXTURE_INFO) return sourceProp;
|
|
18049
|
+
let targetProp = propertyMap.get(sourceProp);
|
|
18050
|
+
if (!targetProp) {
|
|
18051
|
+
const PropertyClass = sourceProp.constructor;
|
|
18052
|
+
targetProp = new PropertyClass(target.getGraph());
|
|
18053
|
+
propertyMap.set(sourceProp, targetProp);
|
|
18054
|
+
}
|
|
18055
|
+
return targetProp;
|
|
18056
|
+
};
|
|
18057
|
+
}
|
|
18058
|
+
function listNonRootProperties(document) {
|
|
18059
|
+
const visited = /* @__PURE__ */ new Set();
|
|
18060
|
+
for (const edge of document.getGraph().listEdges()) visited.add(edge.getChild());
|
|
18061
|
+
return Array.from(visited);
|
|
18062
|
+
}
|
|
18023
18063
|
function create2() {
|
|
18024
18064
|
var out = new ARRAY_TYPE2(4);
|
|
18025
18065
|
if (ARRAY_TYPE2 != Float32Array) {
|
|
@@ -19712,6 +19752,7 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
19712
19752
|
const textures = root.listTextures();
|
|
19713
19753
|
if (textures.length === 0) return void 0;
|
|
19714
19754
|
const decoderFree = options.decoderFree === true;
|
|
19755
|
+
const retainable = (mime) => UNIVERSAL_IMAGE_CONTAINERS.has(mime) || mime === "image/webp" && options.webp === true;
|
|
19715
19756
|
const transcoderBytes = Math.max(0, options.transcoderBytes ?? BASIS_TRANSCODER_BYTES);
|
|
19716
19757
|
const quality = Math.min(255, Math.max(1, Math.round(options.quality ?? DEFAULT_ETC1S_QUALITY)));
|
|
19717
19758
|
const keys = textureKeys(root);
|
|
@@ -19905,7 +19946,7 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
19905
19946
|
floor: options.floor
|
|
19906
19947
|
}) : void 0;
|
|
19907
19948
|
const jpegLimit = jpeg !== void 0 && jpeg.buffer.byteLength < image.byteLength ? jpeg.buffer.byteLength : image.byteLength;
|
|
19908
|
-
const automatic = !explicit && target.width === decoded.width && target.height === decoded.height &&
|
|
19949
|
+
const automatic = !explicit && target.width === decoded.width && target.height === decoded.height && retainable(texture.getMimeType());
|
|
19909
19950
|
const charged = automatic && options.astc !== true;
|
|
19910
19951
|
let selected;
|
|
19911
19952
|
try {
|
|
@@ -19963,7 +20004,7 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
19963
20004
|
if (options.measureQuality !== false) scores[key] = jpeg.quality;
|
|
19964
20005
|
continue;
|
|
19965
20006
|
}
|
|
19966
|
-
if (encoded === void 0 || encoded.byteLength >= image.byteLength && target.width === decoded.width && target.height === decoded.height && !explicit &&
|
|
20007
|
+
if (encoded === void 0 || encoded.byteLength >= image.byteLength && target.width === decoded.width && target.height === decoded.height && !explicit && retainable(texture.getMimeType())) {
|
|
19967
20008
|
const downsampled = target.width !== decoded.width || target.height !== decoded.height;
|
|
19968
20009
|
let retained = image;
|
|
19969
20010
|
if (downsampled) {
|
|
@@ -20743,6 +20784,28 @@ function mergeIdenticalMaterials(document) {
|
|
|
20743
20784
|
};
|
|
20744
20785
|
}
|
|
20745
20786
|
|
|
20787
|
+
// src/lod/coarse.ts
|
|
20788
|
+
async function coarseDocument(document) {
|
|
20789
|
+
const coarse = cloneDocument(document);
|
|
20790
|
+
let chained = 0;
|
|
20791
|
+
for (const mesh of coarse.getRoot().listMeshes())
|
|
20792
|
+
for (const primitive of mesh.listPrimitives()) {
|
|
20793
|
+
const chain = primitive.getExtension(TN_DISCRETE_LOD);
|
|
20794
|
+
if (chain === null) continue;
|
|
20795
|
+
const coarsest = chain.getIndices().at(-1);
|
|
20796
|
+
primitive.setExtension(TN_DISCRETE_LOD, null);
|
|
20797
|
+
if (coarsest === void 0) continue;
|
|
20798
|
+
primitive.setIndices(coarsest);
|
|
20799
|
+
compactPrimitive(primitive);
|
|
20800
|
+
chained += 1;
|
|
20801
|
+
}
|
|
20802
|
+
if (chained === 0) return void 0;
|
|
20803
|
+
for (const extension of coarse.getRoot().listExtensionsUsed())
|
|
20804
|
+
if (extension.extensionName === TN_DISCRETE_LOD) extension.dispose();
|
|
20805
|
+
await coarse.transform(prune({ propertyTypes: [PropertyType.ACCESSOR] }));
|
|
20806
|
+
return coarse;
|
|
20807
|
+
}
|
|
20808
|
+
|
|
20746
20809
|
// src/lod/eligibility.ts
|
|
20747
20810
|
var SUPPORTED_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
20748
20811
|
"COLOR_0",
|
|
@@ -21661,6 +21724,15 @@ function generateCardsChain(primitive, maxLevels, minSaving) {
|
|
|
21661
21724
|
vertexCopies: chain.copies
|
|
21662
21725
|
};
|
|
21663
21726
|
}
|
|
21727
|
+
function decodedComponents(accessor, array) {
|
|
21728
|
+
const floats = new Float32Array(array.length);
|
|
21729
|
+
for (let index = 0; index < array.length; index += 1)
|
|
21730
|
+
floats[index] = MathUtils.decodeNormalizedInt(
|
|
21731
|
+
array[index],
|
|
21732
|
+
accessor.getComponentType()
|
|
21733
|
+
);
|
|
21734
|
+
return floats;
|
|
21735
|
+
}
|
|
21664
21736
|
function appendCardCopies(primitive, copies) {
|
|
21665
21737
|
const base = primitive.getAttribute("POSITION")?.getCount() ?? 0;
|
|
21666
21738
|
let added = 0;
|
|
@@ -21680,7 +21752,9 @@ function appendCardCopies(primitive, copies) {
|
|
|
21680
21752
|
grown.set(array.subarray(vertex * size, vertex * size + size), at * size);
|
|
21681
21753
|
at += 1;
|
|
21682
21754
|
}
|
|
21683
|
-
const
|
|
21755
|
+
const metres = semantic === "POSITION" && accessor.getNormalized();
|
|
21756
|
+
const extended = accessor.clone().setArray(metres ? decodedComponents(accessor, grown) : grown);
|
|
21757
|
+
if (metres) extended.setNormalized(false);
|
|
21684
21758
|
if (semantic === "POSITION") {
|
|
21685
21759
|
at = base;
|
|
21686
21760
|
for (const level of copies)
|
|
@@ -23658,6 +23732,11 @@ var SHARED_TRANSCODER_ACCOUNTING_VERSION = 1;
|
|
|
23658
23732
|
var MODEL_DEDUPE_VERSION = 1;
|
|
23659
23733
|
var MODEL_REORDER_VERSION = 1;
|
|
23660
23734
|
var MODEL_QUANTIZE_VERSION = 1;
|
|
23735
|
+
var MODEL_WEBP_RETAIN_VERSION = 1;
|
|
23736
|
+
function keepSmallerSource(textures) {
|
|
23737
|
+
return textures?.webp === true ? `universal-containers+webp-v${String(MODEL_WEBP_RETAIN_VERSION)}` : "universal-containers";
|
|
23738
|
+
}
|
|
23739
|
+
var MODEL_COARSE_COMPANION_VERSION = 1;
|
|
23661
23740
|
var BBOX_TOLERANCE = 1e-3;
|
|
23662
23741
|
var SIMPLIFY_BBOX_TOLERANCE = 0.01;
|
|
23663
23742
|
var SIMPLIFY_RATIO_FLOOR = 0.5;
|
|
@@ -24088,6 +24167,9 @@ function modelPass(options = {}) {
|
|
|
24088
24167
|
// Same reason again: which positions keep their source metres is part of the output, and a
|
|
24089
24168
|
// warm entry from before they did would hand a game geometry its sidecars cannot address.
|
|
24090
24169
|
quantizeVersion: MODEL_QUANTIZE_VERSION,
|
|
24170
|
+
// A warm entry from before the coarse companion carries no `streamedLods`, so a game served
|
|
24171
|
+
// from it never streams: the output gained a file, so the key moves.
|
|
24172
|
+
coarseCompanion: MODEL_COARSE_COMPANION_VERSION,
|
|
24091
24173
|
// `"none"` and "absent" are different cache keys on purpose: absent bakes with defaults.
|
|
24092
24174
|
virtual: options.virtual === "none" ? "none" : {
|
|
24093
24175
|
...options.virtual === void 0 ? {} : options.virtual,
|
|
@@ -24108,7 +24190,7 @@ function modelPass(options = {}) {
|
|
|
24108
24190
|
// Retention is now conditioned on the container, so it is spelled out rather than
|
|
24109
24191
|
// named by a boolean: a warm cache keyed on the old rule would keep shipping the
|
|
24110
24192
|
// WebP-requiring models this replaced.
|
|
24111
|
-
keepSmallerSource:
|
|
24193
|
+
keepSmallerSource: keepSmallerSource(options.textures),
|
|
24112
24194
|
overrides: options.textures?.overrides ?? [],
|
|
24113
24195
|
quality: options.textures?.quality ?? null
|
|
24114
24196
|
}
|
|
@@ -24244,6 +24326,18 @@ function modelPass(options = {}) {
|
|
|
24244
24326
|
}
|
|
24245
24327
|
assertNoTextureDrift(sourceTextures, textureBindings(verified), logicalPath);
|
|
24246
24328
|
if (lod !== void 0 && lod.generated > 0) validateDiscreteLod(verified);
|
|
24329
|
+
const coarse = lod !== void 0 && lod.generated > 0 ? await coarseDocument(document) : void 0;
|
|
24330
|
+
if (coarse !== void 0) {
|
|
24331
|
+
const written = store === void 0 || shared === void 0 || shared.keys.length === 0 ? await writeAndVerify(coarse, logicalPath, options.vertexLayout) : await writeAndVerifyShared(coarse, logicalPath, store, shared, options.vertexLayout);
|
|
24332
|
+
const stats = reachableStats(written.verified);
|
|
24333
|
+
auxiliaryOutputs.push({
|
|
24334
|
+
buffer: written.buffer,
|
|
24335
|
+
extension: ".glb",
|
|
24336
|
+
manifestField: "streamedLods",
|
|
24337
|
+
metadata: { level: "coarsest", triangles: stats.triangles, vertices: stats.vertices },
|
|
24338
|
+
role: "coarse"
|
|
24339
|
+
});
|
|
24340
|
+
}
|
|
24247
24341
|
const entry = {
|
|
24248
24342
|
...compact === void 0 ? {} : { compact },
|
|
24249
24343
|
...embeddedTextures === void 0 ? {} : { embeddedTextures },
|
|
@@ -24289,7 +24383,7 @@ function sharedSettings(texture, textureOptions) {
|
|
|
24289
24383
|
jpeg: textureOptions.jpeg ?? null,
|
|
24290
24384
|
jpegLadder: "colour-opaque-q75-90-v1",
|
|
24291
24385
|
floor: resolveImageQualityFloor(textureOptions.floor),
|
|
24292
|
-
keepSmallerSource:
|
|
24386
|
+
keepSmallerSource: keepSmallerSource(textureOptions),
|
|
24293
24387
|
maxSize: resolveTextureMaxSize(textureOptions.maxSize, listTextureSlots(texture)),
|
|
24294
24388
|
overrides: textureOptions.overrides ?? [],
|
|
24295
24389
|
quality: textureOptions.quality ?? null,
|
package/dist/index.d.ts
CHANGED
|
@@ -42,6 +42,13 @@ type TextureMaxSize = number | Readonly<Record<string, number>>;
|
|
|
42
42
|
interface IModelTexturesOptions {
|
|
43
43
|
/** Internal target-selected raw ASTC output. */
|
|
44
44
|
readonly astc?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Internal: every runtime of this target decodes WebP (the web: browsers and the owned Wasm
|
|
47
|
+
* engine), so an authored WebP is a source the cook may keep, and a KTX2 must undercut its bytes
|
|
48
|
+
* to replace it, as it must a JPEG or PNG. PRD-867: without it, Midway's 300 KB WebP
|
|
49
|
+
* metallic-roughness and normal maps became 4 MB UASTC files.
|
|
50
|
+
*/
|
|
51
|
+
readonly webp?: boolean;
|
|
45
52
|
readonly floor?: Partial<IImageQualityFloor>;
|
|
46
53
|
/** Internal reporting switch; selection still measures and enforces the floor. */
|
|
47
54
|
readonly measureQuality?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -5214,7 +5214,13 @@ function skippedCompressionRows(entries, layout) {
|
|
|
5214
5214
|
bytes,
|
|
5215
5215
|
files,
|
|
5216
5216
|
kind,
|
|
5217
|
-
|
|
5217
|
+
// The decoders this target lacks, not every one the model pass would use: a target that
|
|
5218
|
+
// decodes meshopt but not KTX2 withheld only KTX2 (PRD-861).
|
|
5219
|
+
...kind === "model" ? {
|
|
5220
|
+
decoders: layout.modelCompressionDecoders.filter(
|
|
5221
|
+
(decoder) => decoder === "KTX2" ? !layout.runtimeDecoderCapabilities.ktx2 : !layout.runtimeDecoderCapabilities.meshopt
|
|
5222
|
+
)
|
|
5223
|
+
} : {},
|
|
5218
5224
|
reason
|
|
5219
5225
|
});
|
|
5220
5226
|
}
|
|
@@ -16535,6 +16541,13 @@ function dequantizeAttributeArray(srcArray, componentType, normalized) {
|
|
|
16535
16541
|
}
|
|
16536
16542
|
var { TEXTURE_INFO, ROOT: ROOT$1 } = PropertyType;
|
|
16537
16543
|
var NO_TRANSFER_TYPES = /* @__PURE__ */ new Set([TEXTURE_INFO, ROOT$1]);
|
|
16544
|
+
function cloneDocument(source) {
|
|
16545
|
+
const target = new Document().setLogger(source.getLogger());
|
|
16546
|
+
const resolve2 = createDefaultPropertyResolver(target, source);
|
|
16547
|
+
mergeDocuments(target, source, resolve2);
|
|
16548
|
+
target.getRoot().copy(source.getRoot(), resolve2);
|
|
16549
|
+
return target;
|
|
16550
|
+
}
|
|
16538
16551
|
function mergeDocuments(target, source, resolve2) {
|
|
16539
16552
|
resolve2 ||= createDefaultPropertyResolver(target, source);
|
|
16540
16553
|
for (const sourceExtension of source.getRoot().listExtensionsUsed()) {
|
|
@@ -19954,6 +19967,15 @@ function generateCardsChain(primitive, maxLevels, minSaving) {
|
|
|
19954
19967
|
vertexCopies: chain.copies
|
|
19955
19968
|
};
|
|
19956
19969
|
}
|
|
19970
|
+
function decodedComponents(accessor, array) {
|
|
19971
|
+
const floats = new Float32Array(array.length);
|
|
19972
|
+
for (let index = 0; index < array.length; index += 1)
|
|
19973
|
+
floats[index] = MathUtils.decodeNormalizedInt(
|
|
19974
|
+
array[index],
|
|
19975
|
+
accessor.getComponentType()
|
|
19976
|
+
);
|
|
19977
|
+
return floats;
|
|
19978
|
+
}
|
|
19957
19979
|
function appendCardCopies(primitive, copies) {
|
|
19958
19980
|
const base = primitive.getAttribute("POSITION")?.getCount() ?? 0;
|
|
19959
19981
|
let added = 0;
|
|
@@ -19973,7 +19995,9 @@ function appendCardCopies(primitive, copies) {
|
|
|
19973
19995
|
grown.set(array.subarray(vertex * size, vertex * size + size), at * size);
|
|
19974
19996
|
at += 1;
|
|
19975
19997
|
}
|
|
19976
|
-
const
|
|
19998
|
+
const metres = semantic === "POSITION" && accessor.getNormalized();
|
|
19999
|
+
const extended = accessor.clone().setArray(metres ? decodedComponents(accessor, grown) : grown);
|
|
20000
|
+
if (metres) extended.setNormalized(false);
|
|
19977
20001
|
if (semantic === "POSITION") {
|
|
19978
20002
|
at = base;
|
|
19979
20003
|
for (const level of copies)
|
|
@@ -21124,6 +21148,7 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
21124
21148
|
const textures = root.listTextures();
|
|
21125
21149
|
if (textures.length === 0) return void 0;
|
|
21126
21150
|
const decoderFree = options.decoderFree === true;
|
|
21151
|
+
const retainable = (mime) => UNIVERSAL_IMAGE_CONTAINERS.has(mime) || mime === "image/webp" && options.webp === true;
|
|
21127
21152
|
const transcoderBytes = Math.max(0, options.transcoderBytes ?? BASIS_TRANSCODER_BYTES);
|
|
21128
21153
|
const quality2 = Math.min(255, Math.max(1, Math.round(options.quality ?? DEFAULT_ETC1S_QUALITY)));
|
|
21129
21154
|
const keys = textureKeys(root);
|
|
@@ -21317,7 +21342,7 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
21317
21342
|
floor: options.floor
|
|
21318
21343
|
}) : void 0;
|
|
21319
21344
|
const jpegLimit = jpeg !== void 0 && jpeg.buffer.byteLength < image.byteLength ? jpeg.buffer.byteLength : image.byteLength;
|
|
21320
|
-
const automatic = !explicit && target.width === decoded.width && target.height === decoded.height &&
|
|
21345
|
+
const automatic = !explicit && target.width === decoded.width && target.height === decoded.height && retainable(texture.getMimeType());
|
|
21321
21346
|
const charged = automatic && options.astc !== true;
|
|
21322
21347
|
let selected;
|
|
21323
21348
|
try {
|
|
@@ -21375,7 +21400,7 @@ async function compressEmbeddedTextures(document, logicalPath, options = {}, rec
|
|
|
21375
21400
|
if (options.measureQuality !== false) scores[key] = jpeg.quality;
|
|
21376
21401
|
continue;
|
|
21377
21402
|
}
|
|
21378
|
-
if (encoded === void 0 || encoded.byteLength >= image.byteLength && target.width === decoded.width && target.height === decoded.height && !explicit &&
|
|
21403
|
+
if (encoded === void 0 || encoded.byteLength >= image.byteLength && target.width === decoded.width && target.height === decoded.height && !explicit && retainable(texture.getMimeType())) {
|
|
21379
21404
|
const downsampled = target.width !== decoded.width || target.height !== decoded.height;
|
|
21380
21405
|
let retained = image;
|
|
21381
21406
|
if (downsampled) {
|
|
@@ -22013,9 +22038,9 @@ function parseModelQuantize(raw) {
|
|
|
22013
22038
|
}
|
|
22014
22039
|
return raw;
|
|
22015
22040
|
}
|
|
22016
|
-
function embeddedTexturesFor(configured, ktx2, astc = false) {
|
|
22041
|
+
function embeddedTexturesFor(configured, ktx2, astc = false, webp = false) {
|
|
22017
22042
|
if (astc && configured !== "none") return { textures: { ...configured, astc: true } };
|
|
22018
|
-
if (ktx2) return {};
|
|
22043
|
+
if (ktx2) return webp && configured !== "none" ? { textures: { ...configured, webp: true } } : {};
|
|
22019
22044
|
if (configured !== void 0 && configured !== "none" && configured.maxSize !== void 0) {
|
|
22020
22045
|
return {
|
|
22021
22046
|
textures: {
|
|
@@ -24035,6 +24060,28 @@ function createLightmapPass(options, astc = false) {
|
|
|
24035
24060
|
};
|
|
24036
24061
|
}
|
|
24037
24062
|
|
|
24063
|
+
// src/lod/coarse.ts
|
|
24064
|
+
async function coarseDocument(document) {
|
|
24065
|
+
const coarse = cloneDocument(document);
|
|
24066
|
+
let chained = 0;
|
|
24067
|
+
for (const mesh of coarse.getRoot().listMeshes())
|
|
24068
|
+
for (const primitive of mesh.listPrimitives()) {
|
|
24069
|
+
const chain = primitive.getExtension(TN_DISCRETE_LOD);
|
|
24070
|
+
if (chain === null) continue;
|
|
24071
|
+
const coarsest = chain.getIndices().at(-1);
|
|
24072
|
+
primitive.setExtension(TN_DISCRETE_LOD, null);
|
|
24073
|
+
if (coarsest === void 0) continue;
|
|
24074
|
+
primitive.setIndices(coarsest);
|
|
24075
|
+
compactPrimitive(primitive);
|
|
24076
|
+
chained += 1;
|
|
24077
|
+
}
|
|
24078
|
+
if (chained === 0) return void 0;
|
|
24079
|
+
for (const extension of coarse.getRoot().listExtensionsUsed())
|
|
24080
|
+
if (extension.extensionName === TN_DISCRETE_LOD) extension.dispose();
|
|
24081
|
+
await coarse.transform(prune({ propertyTypes: [PropertyType.ACCESSOR] }));
|
|
24082
|
+
return coarse;
|
|
24083
|
+
}
|
|
24084
|
+
|
|
24038
24085
|
// src/virtual/partition.ts
|
|
24039
24086
|
function edgeKey(a, b) {
|
|
24040
24087
|
return a < b ? a * 4294967296 + b : b * 4294967296 + a;
|
|
@@ -25543,6 +25590,11 @@ var SHARED_TRANSCODER_ACCOUNTING_VERSION = 1;
|
|
|
25543
25590
|
var MODEL_DEDUPE_VERSION = 1;
|
|
25544
25591
|
var MODEL_REORDER_VERSION = 1;
|
|
25545
25592
|
var MODEL_QUANTIZE_VERSION = 1;
|
|
25593
|
+
var MODEL_WEBP_RETAIN_VERSION = 1;
|
|
25594
|
+
function keepSmallerSource(textures) {
|
|
25595
|
+
return textures?.webp === true ? `universal-containers+webp-v${String(MODEL_WEBP_RETAIN_VERSION)}` : "universal-containers";
|
|
25596
|
+
}
|
|
25597
|
+
var MODEL_COARSE_COMPANION_VERSION = 1;
|
|
25546
25598
|
var BBOX_TOLERANCE = 1e-3;
|
|
25547
25599
|
var SIMPLIFY_BBOX_TOLERANCE = 0.01;
|
|
25548
25600
|
var SIMPLIFY_RATIO_FLOOR = 0.5;
|
|
@@ -25973,6 +26025,9 @@ function modelPass(options = {}) {
|
|
|
25973
26025
|
// Same reason again: which positions keep their source metres is part of the output, and a
|
|
25974
26026
|
// warm entry from before they did would hand a game geometry its sidecars cannot address.
|
|
25975
26027
|
quantizeVersion: MODEL_QUANTIZE_VERSION,
|
|
26028
|
+
// A warm entry from before the coarse companion carries no `streamedLods`, so a game served
|
|
26029
|
+
// from it never streams: the output gained a file, so the key moves.
|
|
26030
|
+
coarseCompanion: MODEL_COARSE_COMPANION_VERSION,
|
|
25976
26031
|
// `"none"` and "absent" are different cache keys on purpose: absent bakes with defaults.
|
|
25977
26032
|
virtual: options.virtual === "none" ? "none" : {
|
|
25978
26033
|
...options.virtual === void 0 ? {} : options.virtual,
|
|
@@ -25993,7 +26048,7 @@ function modelPass(options = {}) {
|
|
|
25993
26048
|
// Retention is now conditioned on the container, so it is spelled out rather than
|
|
25994
26049
|
// named by a boolean: a warm cache keyed on the old rule would keep shipping the
|
|
25995
26050
|
// WebP-requiring models this replaced.
|
|
25996
|
-
keepSmallerSource:
|
|
26051
|
+
keepSmallerSource: keepSmallerSource(options.textures),
|
|
25997
26052
|
overrides: options.textures?.overrides ?? [],
|
|
25998
26053
|
quality: options.textures?.quality ?? null
|
|
25999
26054
|
}
|
|
@@ -26129,6 +26184,18 @@ function modelPass(options = {}) {
|
|
|
26129
26184
|
}
|
|
26130
26185
|
assertNoTextureDrift(sourceTextures, textureBindings(verified), logicalPath);
|
|
26131
26186
|
if (lod !== void 0 && lod.generated > 0) validateDiscreteLod(verified);
|
|
26187
|
+
const coarse = lod !== void 0 && lod.generated > 0 ? await coarseDocument(document) : void 0;
|
|
26188
|
+
if (coarse !== void 0) {
|
|
26189
|
+
const written = store === void 0 || shared === void 0 || shared.keys.length === 0 ? await writeAndVerify(coarse, logicalPath, options.vertexLayout) : await writeAndVerifyShared(coarse, logicalPath, store, shared, options.vertexLayout);
|
|
26190
|
+
const stats = reachableStats(written.verified);
|
|
26191
|
+
auxiliaryOutputs.push({
|
|
26192
|
+
buffer: written.buffer,
|
|
26193
|
+
extension: ".glb",
|
|
26194
|
+
manifestField: "streamedLods",
|
|
26195
|
+
metadata: { level: "coarsest", triangles: stats.triangles, vertices: stats.vertices },
|
|
26196
|
+
role: "coarse"
|
|
26197
|
+
});
|
|
26198
|
+
}
|
|
26132
26199
|
const entry = {
|
|
26133
26200
|
...compact === void 0 ? {} : { compact },
|
|
26134
26201
|
...embeddedTextures === void 0 ? {} : { embeddedTextures },
|
|
@@ -26174,7 +26241,7 @@ function sharedSettings(texture, textureOptions) {
|
|
|
26174
26241
|
jpeg: textureOptions.jpeg ?? null,
|
|
26175
26242
|
jpegLadder: "colour-opaque-q75-90-v1",
|
|
26176
26243
|
floor: resolveImageQualityFloor(textureOptions.floor),
|
|
26177
|
-
keepSmallerSource:
|
|
26244
|
+
keepSmallerSource: keepSmallerSource(textureOptions),
|
|
26178
26245
|
maxSize: resolveTextureMaxSize(textureOptions.maxSize, listTextureSlots(texture)),
|
|
26179
26246
|
overrides: textureOptions.overrides ?? [],
|
|
26180
26247
|
quality: textureOptions.quality ?? null,
|
|
@@ -26379,7 +26446,8 @@ function resolveLayout(cwd, options) {
|
|
|
26379
26446
|
...embeddedTexturesFor(
|
|
26380
26447
|
configuredModels.textures,
|
|
26381
26448
|
runtimeDecoderCapabilities.ktx2,
|
|
26382
|
-
mobileAstc
|
|
26449
|
+
mobileAstc,
|
|
26450
|
+
options.platform === "web"
|
|
26383
26451
|
)
|
|
26384
26452
|
};
|
|
26385
26453
|
const textures = configuredTextures === void 0 ? void 0 : mobileAstc ? { ...configuredTextures, astc: true } : configuredTextures;
|
|
@@ -26952,11 +27020,7 @@ async function nativePackageEntries(outputRoot, entries, cookOutputs) {
|
|
|
26952
27020
|
if (bookkeeping.has(relative) || cookOutputs.has(relative) || isLeftover(relative)) continue;
|
|
26953
27021
|
const data = await readFile(path9.join(outputRoot, relative));
|
|
26954
27022
|
const name = `/${relative}`;
|
|
26955
|
-
|
|
26956
|
-
skipped += 1;
|
|
26957
|
-
continue;
|
|
26958
|
-
}
|
|
26959
|
-
const texture = await nativeTextureEntry(name, data);
|
|
27023
|
+
const texture = data.length === 0 ? void 0 : await nativeTextureEntry(name, data);
|
|
26960
27024
|
const scene = data.length >= 4 && data.toString("latin1", 0, 4) === "glTF";
|
|
26961
27025
|
specs.push(
|
|
26962
27026
|
texture ?? {
|
|
@@ -27392,7 +27456,7 @@ function formatSkippedCompression(rows) {
|
|
|
27392
27456
|
return `TN_ASSETS_PASS_SKIPPED ${row.pass}: omitted because the pass declares needsRuntimeDecoder=true and this target has no runtime decoder (reason: platform).`;
|
|
27393
27457
|
}
|
|
27394
27458
|
const decoders = (row.decoders ?? (row.kind === "model" ? ["meshopt", "KTX2"] : ["KTX2"])).join(" and ");
|
|
27395
|
-
const action = row.kind
|
|
27459
|
+
const action = row.kind !== "model" || row.reason !== "platform" ? "shipped as authored" : decoders === "KTX2" ? "kept its textures out of KTX2 while meshopt and the decoder-free model passes ran" : "retained without decoder-backed compression while decoder-free model passes still ran";
|
|
27396
27460
|
const reason = row.reason === "config" ? `assets.${row.kind}s is "none"` : `this target has no qualified ${decoders} decoder`;
|
|
27397
27461
|
return `TN_ASSETS_COMPRESSION_SKIPPED ${row.kind}: ${String(row.files)} file(s), ${(row.bytes / 1e6).toFixed(1)} MB ${action} because ${reason}.`;
|
|
27398
27462
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threenative/assets",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.14",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Content-addressed asset compile step for ThreeNative games.",
|
|
6
6
|
"keywords": [
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"tsup": "8.5.1",
|
|
52
52
|
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
53
53
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
54
|
-
"@threenative/blender-bridge": "0.2.
|
|
54
|
+
"@threenative/blender-bridge": "0.2.6"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@gltf-transform/core": "4.4.2",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"three-mesh-bvh": "0.9.14",
|
|
70
70
|
"wasm-media-encoders": "0.7.0",
|
|
71
71
|
"xatlasjs": "0.2.0",
|
|
72
|
-
"@threenative/terrain": "0.1.
|
|
72
|
+
"@threenative/terrain": "0.1.9"
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|
|
75
75
|
"build": "tsup --config tsup.config.ts && node scripts/copy-basis-encoder.mjs && node scripts/bundle-blender-gpl.mjs && publint",
|