forked from PrismarineJS/prismarine-web-client
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
66 changed files
with
2,324 additions
and
719 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { defineConfig } from 'vite'; | ||
|
||
export default defineConfig({ | ||
root: 'experiments', | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.