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:
@@ -12,7 +12,7 @@ const isReady = computed(() => loaded.value === total.value);
|
|||||||
|
|
||||||
if (import.meta.client) {
|
if (import.meta.client) {
|
||||||
atlasImage = document.createElement('img');
|
atlasImage = document.createElement('img');
|
||||||
atlasImage.src = '/nds/atlas.webp';
|
atlasImage.src = '/nds/atlas.webp?v={{ATLAS_HASH}}';
|
||||||
|
|
||||||
if (atlasImage.complete) {
|
if (atlasImage.complete) {
|
||||||
loaded.value += 1;
|
loaded.value += 1;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { defineNuxtModule, useLogger } from "@nuxt/kit";
|
import { defineNuxtModule, useLogger } from "@nuxt/kit";
|
||||||
|
import { createHash } from "crypto";
|
||||||
import { readdir, readFile, writeFile } from "fs/promises";
|
import { readdir, readFile, writeFile } from "fs/promises";
|
||||||
import { join, relative, parse } from "path";
|
import { join, relative, parse } from "path";
|
||||||
import { existsSync, watch } from "fs";
|
import { existsSync, watch } from "fs";
|
||||||
@@ -221,6 +222,7 @@ ${sp} }`;
|
|||||||
const totalAssets = (imagePaths.length > 0 ? 1 : 0) + modelPaths.length;
|
const totalAssets = (imagePaths.length > 0 ? 1 : 0) + modelPaths.length;
|
||||||
|
|
||||||
let imageCode = "{}";
|
let imageCode = "{}";
|
||||||
|
let atlasHash = "";
|
||||||
let atlasWidth = 0;
|
let atlasWidth = 0;
|
||||||
let atlasHeight = 0;
|
let atlasHeight = 0;
|
||||||
|
|
||||||
@@ -256,6 +258,12 @@ ${sp} }`;
|
|||||||
{ stdio: "pipe" },
|
{ stdio: "pipe" },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const finalAtlas = await readFile(atlasOutputPath);
|
||||||
|
atlasHash = createHash("md5")
|
||||||
|
.update(finalAtlas)
|
||||||
|
.digest("hex")
|
||||||
|
.slice(0, 8);
|
||||||
|
|
||||||
const imageTree = buildImageTree(imagePaths, rects);
|
const imageTree = buildImageTree(imagePaths, rects);
|
||||||
imageCode = generateImageCode(imageTree);
|
imageCode = generateImageCode(imageTree);
|
||||||
}
|
}
|
||||||
@@ -266,6 +274,7 @@ ${sp} }`;
|
|||||||
const template = await readFile(templateFile, "utf-8");
|
const template = await readFile(templateFile, "utf-8");
|
||||||
const code = template
|
const code = template
|
||||||
.replace("{{TOTAL}}", totalAssets.toString())
|
.replace("{{TOTAL}}", totalAssets.toString())
|
||||||
|
.replace("{{ATLAS_HASH}}", atlasHash)
|
||||||
.replace("{{IMAGES}}", imageCode)
|
.replace("{{IMAGES}}", imageCode)
|
||||||
.replace("{{MODELS}}", modelCode);
|
.replace("{{MODELS}}", modelCode);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user