removed unused processesseessess

This commit is contained in:
33333-33333 2026-06-29 16:21:58 +09:00
commit 4fdc567e08
158 changed files with 1317 additions and 3351 deletions

View file

@ -1,16 +1,70 @@
"use strict";
const images = new Map();
const imageBoundsCache = new WeakMap();
const imageMetrics = new Map();
const imagePromises = new Map();
const imageAssetIndex = new Map();
const DECOR_ASSETS = [
{ id: "zunchi", path: "assets/objects/zunchi.webp" },
{ id: "zunchi_02", path: "assets/objects/zunchi_02.webp" },
{ id: "ant_queen", path: "assets/objects/ant_queen.webp" },
{ id: "ant_worker", path: "assets/objects/ant_worker.webp" },
{ id: "genkotsu", path: "assets/objects/genkotsu.webp" },
{ id: "pushpin", path: "assets/objects/pushpin.webp" },
{ id: "pushpin_stuck", path: "assets/objects/pushpin_stuck.webp" },
{ id: "oshibyo", path: "assets/objects/oshibyo.webp" },
{ id: "oshibyo_stuck", path: "assets/objects/oshibyo_stuck.webp" },
{ id: "plushie_bear", path: "assets/objects/plushie_bear.png" },
];
const ALPHA_BOUNDS = {
smile: { x: 18, y: 18, w: 476, h: 432, imageW: 512, imageH: 468 },
angry: { x: 16, y: 16, w: 480, h: 432, imageW: 512, imageH: 464 },
teary: { x: 17, y: 17, w: 478, h: 438, imageW: 512, imageH: 472 },
jito: { x: 18, y: 18, w: 476, h: 451, imageW: 512, imageH: 487 },
drool: { x: 18, y: 18, w: 476, h: 425, imageW: 512, imageH: 461 },
cry: { x: 15, y: 15, w: 482, h: 448, imageW: 512, imageH: 478 },
sleep: { x: 18, y: 18, w: 475, h: 439, imageW: 511, imageH: 475 },
pokan: { x: 18, y: 18, w: 476, h: 433, imageW: 512, imageH: 469 },
stretch: { x: 15, y: 15, w: 482, h: 354, imageW: 512, imageH: 384 },
hurt: { x: 17, y: 21, w: 478, h: 432, imageW: 512, imageH: 468 },
weak: { x: 53, y: 18, w: 405, h: 435, imageW: 512, imageH: 468 },
back: { x: 17, y: 21, w: 478, h: 432, imageW: 512, imageH: 468 },
flee: { x: 17, y: 21, w: 478, h: 432, imageW: 512, imageH: 468 },
zunda_eat: { x: 17, y: 21, w: 478, h: 432, imageW: 512, imageH: 468 },
hurt2: { x: 16, y: 20, w: 480, h: 434, imageW: 512, imageH: 468 },
normal_smirk: { x: 16, y: 20, w: 480, h: 434, imageW: 512, imageH: 468 },
normal_tongue: { x: 16, y: 20, w: 480, h: 434, imageW: 512, imageH: 468 },
fear: { x: 16, y: 20, w: 480, h: 434, imageW: 512, imageH: 468 },
flee_fear2: { x: 16, y: 26, w: 480, h: 428, imageW: 512, imageH: 468 },
sleep2: { x: 16, y: 21, w: 480, h: 433, imageW: 512, imageH: 468 },
normal_happy: { x: 16, y: 21, w: 480, h: 433, imageW: 512, imageH: 468 },
fear_blue: { x: 16, y: 21, w: 480, h: 433, imageW: 512, imageH: 468 },
fear_cry: { x: 16, y: 21, w: 480, h: 433, imageW: 512, imageH: 468 },
stress_dizzy: { x: 16, y: 21, w: 480, h: 433, imageW: 512, imageH: 468 },
stress_sweat: { x: 16, y: 26, w: 480, h: 428, imageW: 512, imageH: 468 },
intimidate: { x: 98, y: 16, w: 316, h: 438, imageW: 512, imageH: 468 },
zunchi_slave: { x: 17, y: 22, w: 478, h: 431, imageW: 512, imageH: 468 },
hungry_70: { x: 0, y: 0, w: 430, h: 366, imageW: 430, imageH: 366 },
zunchi_slave_alt: { x: 42, y: 22, w: 425, h: 426, imageW: 512, imageH: 468 },
zunchi: { x: 0, y: 0, w: 236, h: 178, imageW: 236, imageH: 178 },
zunchi_02: { x: 8, y: 63, w: 220, h: 105, imageW: 236, imageH: 178 },
ant_queen: { x: 0, y: 0, w: 300, h: 155, imageW: 300, imageH: 155 },
ant_worker: { x: 0, y: 0, w: 140, h: 72, imageW: 140, imageH: 72 },
genkotsu: { x: 8, y: 8, w: 220, h: 283, imageW: 236, imageH: 299 },
sunbath_1: { x: 71, y: 18, w: 369, h: 432, imageW: 512, imageH: 468 },
sunbath_2: { x: 69, y: 18, w: 374, h: 432, imageW: 512, imageH: 468 },
sunbath_3: { x: 71, y: 18, w: 369, h: 432, imageW: 512, imageH: 468 },
plushie_bear: { x: 0, y: 0, w: 150, h: 192, imageW: 150, imageH: 192 },
};
const scaledSpriteCache = new Map();
const stainOverlayCache = new Map();
const SPRITE_CACHE_LIMIT = 128;
const STAIN_CACHE_LIMIT = 64;
const SUNBATH_IMAGE_IDS = new Set((typeof SPRITES !== "undefined" ? SPRITES : [])
const SUNBATH_IMAGE_IDS = new Set(SPRITES
.map(asset => asset?.id || "")
.filter(id => String(id).startsWith("sunbath")));
const INITIAL_IMAGE_IDS = new Set(["smile", "hungry_70", "zunchi_slave", "zunchi_slave_alt", "zunchi", "zunchi_02", "genkotsu", "pushpin", "pushpin_stuck", "oshibyo", "oshibyo_stuck", ...SUNBATH_IMAGE_IDS]);
@ -35,13 +89,6 @@ function getCachedSpriteCanvas(id, img, w, h) {
const qw = quantizedCanvasSize(w);
const qh = quantizedCanvasSize(h);
const key = `${id}:${qw}x${qh}`;
if (window.TarinaiPhysics?.createCachedCanvas) {
return window.TarinaiPhysics.createCachedCanvas(scaledSpriteCache, key, qw, qh, (c) => {
if ("imageSmoothingQuality" in c) c.imageSmoothingQuality = "high";
c.clearRect(0, 0, qw, qh);
c.drawImage(img, 0, 0, qw, qh);
}, { limit: SPRITE_CACHE_LIMIT });
}
let canvas = scaledSpriteCache.get(key);
if (canvas) return canvas;
canvas = document.createElement("canvas");
@ -86,7 +133,6 @@ function getCachedStainOverlayCanvas(id, img, w, h, stain = 0, seed = 0.5) {
c.globalAlpha = 1;
c.globalCompositeOperation = "source-over";
};
if (window.TarinaiPhysics?.createCachedCanvas) return window.TarinaiPhysics.createCachedCanvas(stainOverlayCache, key, qw, qh, buildOverlay, { limit: STAIN_CACHE_LIMIT });
let canvas = stainOverlayCache.get(key);
if (canvas) return canvas;
canvas = document.createElement("canvas");
@ -109,7 +155,6 @@ function primeImageMetrics(asset) {
w,
h,
ratio: h / Math.max(w, 1),
visibleBottomRatio: bounds ? (bounds.y + bounds.h) / Math.max(bounds.imageH, 1) : 1,
});
}
@ -129,7 +174,6 @@ function markImageLoaded(asset, img) {
w,
h,
ratio: h / Math.max(w, 1),
visibleBottomRatio: (bounds.y + bounds.h) / Math.max(bounds.imageH, 1),
});
}
@ -154,7 +198,7 @@ function loadImageAsset(asset, priority = "auto") {
img.onerror = () => { resolve(null); };
});
imagePromises.set(asset.id, promise);
if (!img.src) img.src = (window.TarinaiVersion?.withStaticVersion ? window.TarinaiVersion.withStaticVersion(asset.path) : asset.path);
if (!img.src) img.src = window.TARINAI_APP?.withVersion ? window.TARINAI_APP.withVersion(asset.path) : asset.path;
return promise;
}
@ -176,10 +220,9 @@ function getRenderableImage(id, fallbackId = "smile") {
return null;
}
function loadImages(ids = null, onProgress = null) {
function loadImages(onProgress = null) {
setupAssetIndex();
const requested = ids ? new Set(ids) : INITIAL_IMAGE_IDS;
const assets = [...requested].map(id => imageAssetIndex.get(id)).filter(Boolean);
const assets = [...INITIAL_IMAGE_IDS].map(id => imageAssetIndex.get(id)).filter(Boolean);
const total = Math.max(assets.length, 1);
let done = 0;
if (typeof onProgress === "function") onProgress(done, total, null);
@ -227,14 +270,9 @@ function startBackgroundImageLoading() {
function imageAlphaBounds(img) {
if (!img) return null;
if (img.alphaBounds) return img.alphaBounds;
if (imageBoundsCache.has(img)) return imageBoundsCache.get(img);
const w = img.naturalWidth || img.width || 0;
const h = img.naturalHeight || img.height || 0;
if (!w || !h) return null;
const bounds = { x: 0, y: 0, w, h, imageW: w, imageH: h };
imageBoundsCache.set(img, bounds);
return bounds;
return w && h ? { x: 0, y: 0, w, h, imageW: w, imageH: h } : null;
}
function getImageMetrics(idOrImg) {
@ -250,9 +288,8 @@ function getImageMetrics(idOrImg) {
}
const w = idOrImg.naturalWidth || idOrImg.width || 0;
const h = idOrImg.naturalHeight || idOrImg.height || 0;
return w && h ? { w, h, ratio: h / w, visibleBottomRatio: 1 } : null;
return w && h ? { w, h, ratio: h / w } : null;
}
setupAssetIndex();
window.TarinaiAssets = { images, imageBoundsCache, imageMetrics, imagePromises, scaledSpriteCache, stainOverlayCache, loadImages, startBackgroundImageLoading, trimImageMemory, ensureImage, isImageReady, getRenderableImage, imageAlphaBounds, getImageMetrics, getCachedSpriteCanvas, getCachedStainOverlayCanvas };