Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a decent release #225

Merged
merged 20 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/next-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
run: npm install --global vercel [email protected]
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Write Release Info
run: |
echo "{\"latestTag\": \"$(git rev-parse --short $GITHUB_SHA)\"}" > assets/release.json
- name: Build Project Artifacts
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- run: pnpm build-storybook
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ jobs:
- run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- run: node scripts/replaceFavicon.mjs ${{ secrets.FAVICON_MAIN }}
# will install + build to .vercel/output/static
- name: Get Release Info
run: pnpx zardoy-release empty --skip-github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: releaseInfo
- name: Write Release Info
run: echo '${{ toJson(steps.releaseInfo.outputs) }}' > assets/release.json
- run: vercel build --token=${{ secrets.VERCEL_TOKEN }} --prod
- run: pnpm build-storybook
- name: Copy playground files
Expand Down Expand Up @@ -47,6 +54,10 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .vercel/output/static
force_orphan: true
- name: Set publishing config
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: pnpm tsx scripts/buildNpmReact.ts ${{ steps.release.outputs.tag }}
if: steps.release.outputs.tag
env:
Expand Down
9 changes: 9 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
<meta name="darkreader-lock">
<script>
window.startLoad = Date.now()
// g663 fix: forbid change of string prototype
Object.defineProperty(String.prototype, 'format', {
writable: false,
configurable: false
});
Object.defineProperty(String.prototype, 'replaceAll', {
writable: false,
configurable: false
});
</script>
<!-- // #region initial loader -->
<script async>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"esbuild-plugin-polyfill-node": "^0.3.0",
"express": "^4.18.2",
"filesize": "^10.0.12",
"flying-squid": "npm:@zardoy/flying-squid@^0.0.44",
"flying-squid": "npm:@zardoy/flying-squid@^0.0.47",
"fs-extra": "^11.1.1",
"google-drive-browserfs": "github:zardoy/browserfs#google-drive",
"jszip": "^3.10.1",
Expand Down
30 changes: 18 additions & 12 deletions pnpm-lock.yaml

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

14 changes: 11 additions & 3 deletions prismarine-viewer/examples/baseScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,14 @@ export class BasePlaygroundScene {

addKeyboardShortcuts () {
document.addEventListener('keydown', (e) => {
if (e.code === 'KeyR' && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
this.controls?.reset()
this.resetCamera()
if (!e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
if (e.code === 'KeyR') {
this.controls?.reset()
this.resetCamera()
}
if (e.code === 'KeyE') {
worldView?.setBlockStateId(this.targetPos, this.world.getBlockStateId(this.targetPos))
}
}
})
document.addEventListener('visibilitychange', () => {
Expand All @@ -297,6 +302,9 @@ export class BasePlaygroundScene {
})

const updateKeys = () => {
if (pressedKeys.has('ControlLeft') || pressedKeys.has('MetaLeft')) {
return
}
// if (typeof viewer === 'undefined') return
// Create a vector that points in the direction the camera is looking
const direction = new THREE.Vector3(0, 0, 0)
Expand Down
2 changes: 1 addition & 1 deletion prismarine-viewer/examples/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as scenes from './scenes'

const qsScene = new URLSearchParams(window.location.search).get('scene')
const Scene: typeof BasePlaygroundScene = qsScene ? scenes[qsScene] : scenes.main
playgroundGlobalUiState.scenes = ['main', 'railsCobweb', 'floorRandom', 'lightingStarfield', 'transparencyIssue', 'entities', 'frequentUpdates']
playgroundGlobalUiState.scenes = ['main', 'railsCobweb', 'floorRandom', 'lightingStarfield', 'transparencyIssue', 'entities', 'frequentUpdates', 'slabsOptimization']
playgroundGlobalUiState.selected = qsScene ?? 'main'

const scene = new Scene()
Expand Down
1 change: 1 addition & 0 deletions prismarine-viewer/examples/scenes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export { default as transparencyIssue } from './transparencyIssue'
export { default as rotationIssue } from './rotationIssue'
export { default as entities } from './entities'
export { default as frequentUpdates } from './frequentUpdates'
export { default as slabsOptimization } from './slabsOptimization'
15 changes: 15 additions & 0 deletions prismarine-viewer/examples/scenes/slabsOptimization.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { BasePlaygroundScene } from '../baseScene'

export default class extends BasePlaygroundScene {
expectedNumberOfFaces = 30

setupWorld () {
this.addWorldBlock(0, 1, 0, 'stone_slab')
this.addWorldBlock(0, 0, 0, 'stone')
this.addWorldBlock(0, -1, 0, 'stone_slab', { type: 'top', waterlogged: false })
this.addWorldBlock(0, -1, -1, 'stone_slab', { type: 'top', waterlogged: false })
this.addWorldBlock(0, -1, 1, 'stone_slab', { type: 'top', waterlogged: false })
this.addWorldBlock(-1, -1, 0, 'stone_slab', { type: 'top', waterlogged: false })
this.addWorldBlock(1, -1, 0, 'stone_slab', { type: 'top', waterlogged: false })
}
}
2 changes: 1 addition & 1 deletion prismarine-viewer/rsbuildSharedConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const appAndRendererSharedConfig = () => defineConfig({
},
server: {
htmlFallback: false,
publicDir: false,
// publicDir: false,
headers: {
// enable shared array buffer
'Cross-Origin-Opener-Policy': 'same-origin',
Expand Down
6 changes: 4 additions & 2 deletions prismarine-viewer/viewer/lib/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import stevePng from 'mc-assets/dist/other-textures/latest/entity/player/wide/st
import { NameTagObject } from 'skinview3d/libs/nametag'
import { flat, fromFormattedString } from '@xmcl/text-component'
import mojangson from 'mojangson'
import { snakeCase } from 'change-case'
import * as Entity from './entity/EntityMesh'
import { WalkingGeneralSwing } from './entity/animations'
import externalTexturesJson from './entity/externalTextures.json'
Expand Down Expand Up @@ -63,11 +64,13 @@ const addNametag = (entity, options, mesh) => {
// todo cleanup
const nametags = {}

const isFirstUpperCase = (str) => str.charAt(0) === str.charAt(0).toUpperCase()

function getEntityMesh (entity, scene, options, overrides) {
if (entity.name) {
try {
// https://github.com/PrismarineJS/prismarine-viewer/pull/410
const entityName = entity.name.toLowerCase()
const entityName = (isFirstUpperCase(entity.name) ? snakeCase(entity.name) : entity.name).toLowerCase()
const e = new Entity.EntityMesh('1.16.4', entityName, scene, overrides)

if (e.mesh) {
Expand Down Expand Up @@ -340,7 +343,6 @@ export class Entities extends EventEmitter {
}

update (entity: import('prismarine-entity').Entity & { delete?; pos }, overrides) {
console.log('entity', entity)
const isPlayerModel = entity.name === 'player'
if (entity.name === 'zombie' || entity.name === 'zombie_villager' || entity.name === 'husk') {
overrides.texture = `textures/1.16.4/entity/${entity.name === 'zombie_villager' ? 'zombie_villager/zombie_villager.png' : `zombie/${entity.name}.png`}`
Expand Down
7 changes: 5 additions & 2 deletions prismarine-viewer/viewer/lib/mesher/mesher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function setSectionDirty (pos, value = true) {
const softCleanup = () => {
// clean block cache and loaded chunks
world = new World(world.config.version)
globalThis.world = world
}

const handleMessage = data => {
Expand All @@ -75,8 +76,10 @@ const handleMessage = data => {
}

if (data.config) {
if (data.type === 'mesherData' && allDataReady) {
world = undefined as any // reset models
if (data.type === 'mesherData' && world) {
// reset models
world.blockCache = {}
world.erroredBlockModel = undefined
}

world ??= new World(data.config.version)
Expand Down
Loading
Loading