Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
shanimal08 committed Jan 31, 2025
1 parent 227c033 commit 96b9767
Show file tree
Hide file tree
Showing 30 changed files with 147 additions and 1,580 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
1,499 changes: 12 additions & 1,487 deletions dist/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/main.js.map

Large diffs are not rendered by default.

14 changes: 3 additions & 11 deletions lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,17 @@ import { loadTowerAnimation, removeTowerAnimation } from './scripts/index';
import { properties } from './scripts/core/properties';
import { result, stateManager, status, statusIndex } from './scripts/logic/stateManager';

function setAnimationState(id: string, isReplay = false) {
export function setAnimationState(id: string, isReplay = false) {
stateManager.set(id, isReplay);
}
interface Property {
property: string;
value: unknown;
}
function setAnimationProperties(newProps: Property[]) {
export function setAnimationProperties(newProps: Property[]) {
for (const item of newProps) {
properties[item.property] = item.value;
}
}

export {
loadTowerAnimation,
removeTowerAnimation,
setAnimationProperties,
status as animationStatus,
statusIndex as animationStatusIndex,
result as animationResult,
setAnimationState,
};
export { loadTowerAnimation, removeTowerAnimation, status as animationStatus, statusIndex as animationStatusIndex, result as animationResult };
31 changes: 28 additions & 3 deletions lib/scripts/core/loader.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
import * as THREE from 'three';
import { properties } from './properties';

import BASE from '/assets/BASE.buf?inline';
import BOX from '/assets/BOX.buf?inline';
import COIN from '/assets/COIN.buf?inline';
import COIN_PLACEMENT from '/assets/COIN_PLACEMENT.buf?inline';
import LOSE_ANIMATION from '/assets/LOSE_ANIMATION.buf?inline';

import gobo from '/assets/gobo.jpg?url';
import LDR_RGB1_0 from '/assets/LDR_RGB1_0.png?url';
import matcap_gold from '/assets/matcap_gold.jpg?url';

interface LoaderItems {
list: (() => void | Promise<void>)[];
loadedCount: number;
onLoadCallback: (() => void) | null;
}

const assets = {
'models/BASE.buf': BASE,
'models/BOX.buf': BOX,
'models/COIN.buf': COIN,
'models/COIN_PLACEMENT.buf': COIN_PLACEMENT,
'models/LOSE_ANIMATION.buf': LOSE_ANIMATION,
'textures/gobo.jpg': gobo,
'textures/LDR_RGB1_0.png': LDR_RGB1_0,
'textures/matcap_gold.jpg': matcap_gold,
};
const Loader = () => {
let list: LoaderItems['list'] = [];
let loadedCount: LoaderItems['loadedCount'] = 0;
let onLoadCallback: LoaderItems['onLoadCallback'] = null;

function loadBuf(url, cb) {
console.debug(`url= ${url}`);
function loadBuf(filename, cb) {
console.debug(filename);
const url = assets[filename];
console.debug(url);
list.push(async () => {
try {
const response = await fetch(url);
Expand Down Expand Up @@ -78,7 +100,10 @@ const Loader = () => {
return outArr;
}

function loadTexture(url, cb) {
function loadTexture(filename, cb) {
console.debug(`filename= ${filename}`);
const url = assets[filename];
console.debug(url);
list.push(() => {
new THREE.TextureLoader().load(
url,
Expand Down
2 changes: 1 addition & 1 deletion lib/scripts/core/settings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const ASSETS_PATH = '/assets';
export const ASSETS_PATH = '';
const DPR = Math.min(2, window.devicePixelRatio || 1);
const USE_PIXEL_LIMIT = true;
const MAX_PIXEL_COUNT = 2560 * 1440;
Expand Down
2 changes: 1 addition & 1 deletion lib/scripts/utils/blueNoise/blueNoise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const BlueNoise = () => {
const TEXTURE_SIZE = 128;

async function preInit() {
loader.loadTexture(`${ASSETS_PATH + '/textures'}/LDR_RGB1_0.png`, (texture) => {
loader.loadTexture(`${ASSETS_PATH + 'textures'}/LDR_RGB1_0.png`, (texture) => {
texture.generateMipmaps = false;
texture.minFilter = texture.magFilter = THREE.NearestFilter;
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
Expand Down
4 changes: 2 additions & 2 deletions lib/scripts/visuals/coins/coins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const coinsSharedUniforms = {

const Coins = () => {
async function preload() {
const modelPath = ASSETS_PATH + '/models';
const texturePath = ASSETS_PATH + '/textures';
const modelPath = ASSETS_PATH + 'models';
const texturePath = ASSETS_PATH + 'textures';
loader.loadTexture(`${texturePath}/matcap_gold.jpg`, (texture) => {
matcapTexture = texture;
matcapTexture.needsUpdate = true;
Expand Down
4 changes: 2 additions & 2 deletions lib/scripts/visuals/hero/hero.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ const Hero = () => {
heroState._blockList = arr.map((_) => new HeroBlockCoordinates());
heroState._blockRenderList = [...heroState._blockList];

const modelPath = ASSETS_PATH + '/models';
const texturePath = ASSETS_PATH + '/textures';
const modelPath = ASSETS_PATH + 'models';
const texturePath = ASSETS_PATH + 'textures';

loader.loadBuf(`${modelPath}/BASE.buf`, (geometry) => {
_onBaseBlocksLoaded(geometry);
Expand Down
114 changes: 75 additions & 39 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tari-project/tari-tower",
"version": "0.0.5",
"version": "0.0.6",
"private": false,
"description": "the tower animation used in Tari Universe",
"homepage": "https://github.com/tari-project/tari-tower#readme",
Expand All @@ -12,14 +12,14 @@
"type": "module",
"exports": {
".": {
"assets/models/BASE.buf": "./public/assets/models/BASE.buf",
"assets/models/BOX.buf": "./public/assets/models/BOX.buf",
"assets/models/COIN.buf": "./public/assets/models/COIN.buf",
"assets/models/COIN_PLACEMENT.buf": "./public/assets/models/COIN_PLACEMENT.buf",
"assets/models/LOSE_ANIMATION.buf": "./public/assets/models/LOSE_ANIMATION.buf",
"assets/textures/gobo.jpg": "./public/assets/textures/gobo.jpg",
"assets/textures/LDR_RGB1_0.png": "./public/assets/textures/LDR_RGB1_0.png",
"assets/textures/matcap_gold.jpg": "./public/assets/textures/matcap_gold.jpg",
"assets/BASE.buf": "./public/assets/BASE.buf",
"assets/BOX.buf": "./public/assets/BOX.buf",
"assets/COIN.buf": "./public/assets/COIN.buf",
"assets/COIN_PLACEMENT.buf": "./public/assets/COIN_PLACEMENT.buf",
"assets/LOSE_ANIMATION.buf": "./public/assets/LOSE_ANIMATION.buf",
"assets/gobo.jpg": "./public/assets/gobo.jpg",
"assets/LDR_RGB1_0.png": "./public/assets/LDR_RGB1_0.png",
"assets/matcap_gold.jpg": "./public/assets/matcap_gold.jpg",
"assets": "./dist/assets/",
"types": "./dist/main.d.ts",
"default": "./dist/main.js"
Expand All @@ -39,8 +39,8 @@
},
"devDependencies": {
"@eslint/js": "^9.19.0",
"@laynezh/vite-plugin-lib-assets": "^1.0.0",
"@nabla/vite-plugin-eslint": "^2.0.5",
"@rollup/plugin-commonjs": "^28.0.2",
"@types/eslint__js": "^8.42.3",
"@types/node": "^22.12.0",
"@types/three": "^0.172.0",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
3 changes: 2 additions & 1 deletion tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"strict": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": false,
"types": ["vite/client"]
"types": ["vite/client"],
"baseUrl": "."
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
Expand Down
32 changes: 10 additions & 22 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,30 @@
import { defineConfig } from 'vite';
import eslint from '@nabla/vite-plugin-eslint';

import commonjs from '@rollup/plugin-commonjs';
import tsconfigPaths from 'vite-tsconfig-paths';
import dts from 'vite-plugin-dts';
import libAssetsPlugin from '@laynezh/vite-plugin-lib-assets';
import { resolve } from 'path';

export default defineConfig({
plugins: [
dts({ include: ['lib', 'assets'] }),
tsconfigPaths(),
eslint({ eslintOptions: { cache: false, fix: true } }),
libAssetsPlugin({
outputPath: (url) => {
return url.endsWith('.buf') ? 'assets/models' : 'assets/textures';
},
include: ['**/*.buf', '**/*.jpg', '**/*.png'],
name: '[name].[contenthash:8].[ext]',
}),
],

assetsInclude: ['**/*.buf', '**/*.jpg', '**/*.png'],
plugins: [commonjs(), dts({ include: ['lib'] }), tsconfigPaths(), eslint({ eslintOptions: { cache: false, fix: true } })],
build: {
lib: {
entry: resolve(__dirname, 'lib/main.ts'),
formats: ['es'],
},
sourcemap: true,
emitAssets: true,
rollupOptions: {
input: 'lib/main.ts',
external: ['three', 'min-signal'],
input: { main: resolve(__dirname, 'lib/main.ts') },
output: {
format: 'es',
name: 'main',
entryFileNames: '[name].js',
assetFileNames: 'assets/[name][ext]',
assetFileNames: 'assets/[name][extname]',
globals: {
'three': 'Three',
'min-signal': 'MinSignal',
},
},
makeAbsoluteExternalsRelative: true,
preserveEntrySignatures: 'exports-only',
},
},
});

0 comments on commit 96b9767

Please sign in to comment.