Skip to content

Commit

Permalink
Greatest fixes (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy authored Oct 28, 2023
2 parents a1fc898 + 0531038 commit 3363583
Show file tree
Hide file tree
Showing 66 changed files with 2,324 additions and 719 deletions.
36 changes: 36 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "viewer-server",
"command": "live-server --port=9090",
"type": "shell",
"args": [],
"problemMatcher": [],
// set cwd
"options": {
"cwd": "${workspaceFolder}/prismarine-viewer/public/"
},
"presentation": {
"reveal": "silent"
},
},
{
"label": "viewer-esbuild",
"type": "shell",
"command": "node prismarine-viewer/esbuild.mjs -w",
"problemMatcher": "$esbuild-watch",
"presentation": {
"reveal": "silent"
},
},
{
"label": "viewer server+esbuild",
"dependsOn": [
"viewer-server",
"viewer-esbuild"
],
"dependsOrder": "parallel",
}
]
}
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"defaultHost": "pjs.deptofcraft.com",
"defaultProxy": "zardoy.site:2344",
"defaultVersion": "1.18.2"
"defaultVersion": "1.18.2",
"mapsProvider": "zardoy.site/maps"
}
7 changes: 3 additions & 4 deletions cypress/integration/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/// <reference types="cypress" />
import type { AppOptions } from '../../src/optionsStorage'

const cleanVisit = () => {
const cleanVisit = (url?) => {
window.localStorage.clear()
visit()
visit(url)
}

const visit = (url = '/') => {
Expand Down Expand Up @@ -38,7 +38,7 @@ const setOptions = (options: Partial<AppOptions>) => {
}

it('Loads & renders singleplayer', () => {
cleanVisit()
cleanVisit('/?singleplayer=1')
setOptions({
localServerOptions: {
generation: {
Expand All @@ -49,7 +49,6 @@ it('Loads & renders singleplayer', () => {
},
renderDistance: 2
})
cy.get('[data-test-id="singleplayer-button"]', { includeShadowDom: true }).click()
testWorldLoad()
})

Expand Down
60 changes: 60 additions & 0 deletions experiments/texture-render.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>

<body>
<script type="module">
//@ts-check
import blockImg from '../prismarine-viewer/public/textures/1.16.1.png'
import blocksStates from '../prismarine-viewer/public/blocksStates/1.16.1.json'

// const block = {
// name: 'oak_sign',
// variant: 0,
// elem: 1,
// face: 'up'
// }
const block = {
name: 'light_gray_stained_glass',
variant: 0,
elem: 0,
face: 'north'
}
//@ts-ignore
const model = Object.entries(blocksStates[block.name].variants).find((a, i) => typeof block.variant === 'number' ? i === block.variant : a === block.variant)[1].model.elements[block.elem]
console.log(model)
const textureUv = model.faces[block.face].texture

const canvas = document.createElement('canvas')
canvas.style.imageRendering = 'pixelated'
document.body.appendChild(canvas)
const factor = 50
const modelWidth = model.to[0] - model.from[0]
const modelHeight = model.to[1] - model.from[1]
canvas.width = modelWidth * factor
canvas.height = modelHeight * factor
// canvas.width = 16 * factor
// canvas.height = 16 * factor * 2

const ctx = canvas.getContext('2d')
//@ts-ignore
ctx.imageSmoothingEnabled = false
const img = new Image()
const img2 = new Image()
img.src = blockImg
img.onload = () => {
//@ts-ignore
ctx.drawImage(img, img.width * textureUv.u, img.height * textureUv.v, img.width * textureUv.su, img.height * textureUv.sv, 0, 0, canvas.width, canvas.height)
// ctx.drawImage(img, 0, 0, canvas.width, canvas.height / 2)
console.log('width;height texture', img.width * textureUv.su, img.height * textureUv.sv)
console.log('base su=sv', 16 / img.width)
}
</script>
</body>

</html>
5 changes: 5 additions & 0 deletions experiments/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineConfig } from 'vite';

export default defineConfig({
root: 'experiments',
})
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<meta property="og:title" content="Prismarine Web Client" />
<meta property="og:type" content="website" />
<meta property="og:image" content="https://prismarinejs.github.io/prismarine-web-client/favicon.png" />
<meta name="format-detection" content="telephone=no">
<link rel="manifest" href="manifest.json" crossorigin="use-credentials">
</head>
<body>
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"lint": "eslint \"{src,cypress}/**/*.{ts,js,jsx,tsx}\"",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"start-experiments": "vite --config experiments/vite.config.ts",
"watch-worker": "node prismarine-viewer/buildWorker.mjs -w"
},
"keywords": [
Expand All @@ -26,9 +27,10 @@
"license": "MIT",
"dependencies": {
"@dimaka/interface": "0.0.3-alpha.0",
"@floating-ui/react": "^0.26.1",
"@types/react": "^18.2.20",
"@types/react-dom": "^18.2.7",
"@types/wicg-file-system-access": "^2020.9.6",
"@types/wicg-file-system-access": "^2023.10.2",
"@zardoy/react-util": "^0.2.0",
"@zardoy/utils": "^0.0.11",
"browserfs": "github:zardoy/browserfs#build",
Expand All @@ -55,9 +57,10 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-transition-group": "^4.4.5",
"sanitize-filename": "^1.6.3",
"stats-gl": "^1.0.5",
"stats.js": "^0.17.0",
"tippy.js": "^6.3.7",
"tabbable": "^6.2.0",
"title-case": "3.x",
"valtio": "^1.11.1",
"workbox-build": "^7.0.0"
Expand Down Expand Up @@ -111,6 +114,7 @@
},
"pnpm": {
"overrides": {
"diamond-square": "github:zardoy/diamond-square",
"prismarine-block": "github:zardoy/prismarine-block#next-era",
"prismarine-world": "github:zardoy/prismarine-world#next-era",
"minecraft-data": "3.45.0",
Expand Down
Loading

0 comments on commit 3363583

Please sign in to comment.