feat(nds): atlas versionning
All checks were successful
Build and Push Docker Image / build (push) Successful in 1m40s
All checks were successful
Build and Push Docker Image / build (push) Successful in 1m40s
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { defineNuxtModule, useLogger } from "@nuxt/kit";
|
||||
import { createHash } from "crypto";
|
||||
import { readdir, readFile, writeFile } from "fs/promises";
|
||||
import { join, relative, parse } from "path";
|
||||
import { existsSync, watch } from "fs";
|
||||
@@ -221,6 +222,7 @@ ${sp} }`;
|
||||
const totalAssets = (imagePaths.length > 0 ? 1 : 0) + modelPaths.length;
|
||||
|
||||
let imageCode = "{}";
|
||||
let atlasHash = "";
|
||||
let atlasWidth = 0;
|
||||
let atlasHeight = 0;
|
||||
|
||||
@@ -256,6 +258,12 @@ ${sp} }`;
|
||||
{ stdio: "pipe" },
|
||||
);
|
||||
|
||||
const finalAtlas = await readFile(atlasOutputPath);
|
||||
atlasHash = createHash("md5")
|
||||
.update(finalAtlas)
|
||||
.digest("hex")
|
||||
.slice(0, 8);
|
||||
|
||||
const imageTree = buildImageTree(imagePaths, rects);
|
||||
imageCode = generateImageCode(imageTree);
|
||||
}
|
||||
@@ -266,6 +274,7 @@ ${sp} }`;
|
||||
const template = await readFile(templateFile, "utf-8");
|
||||
const code = template
|
||||
.replace("{{TOTAL}}", totalAssets.toString())
|
||||
.replace("{{ATLAS_HASH}}", atlasHash)
|
||||
.replace("{{IMAGES}}", imageCode)
|
||||
.replace("{{MODELS}}", modelCode);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user