sync viewer changes
This commit is contained in:
parent
7d092a39d2
commit
72b4a6a765
3 changed files with 17 additions and 9 deletions
|
|
@ -264,8 +264,8 @@ function renderElement (world, cursor, element, doAO, attr, globalMatrix, global
|
|||
if (block.name === 'redstone_wire') {
|
||||
tint = tints.redstone[`${block.getProperties().power}`]
|
||||
} else if (block.name === 'birch_leaves' ||
|
||||
block.name === 'spruce_leaves' ||
|
||||
block.name === 'lily_pad') {
|
||||
block.name === 'spruce_leaves' ||
|
||||
block.name === 'lily_pad') {
|
||||
tint = tints.constant[block.name]
|
||||
} else if (block.name.includes('leaves') || block.name === 'vine') {
|
||||
tint = tints.foliage[biome]
|
||||
|
|
@ -478,8 +478,9 @@ function matchProperties (block, properties) {
|
|||
}
|
||||
|
||||
function getModelVariants (block, blockStates) {
|
||||
if (block.name === 'air') return []
|
||||
const state = blockStates[block.name] ?? blockStates['missing_texture']
|
||||
// air, cave_air, void_air and so on...
|
||||
if (block.name.includes('air')) return []
|
||||
const state = blockStates[block.name] ?? blockStates.missing_texture
|
||||
if (!state) return []
|
||||
if (state.variants) {
|
||||
for (const [properties, variant] of Object.entries(state.variants)) {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class Viewer {
|
|||
|
||||
this.domElement = renderer.domElement
|
||||
this.playerHeight = 1.6
|
||||
this.isSneaking = false
|
||||
}
|
||||
|
||||
resetAll () {
|
||||
|
|
@ -67,7 +68,11 @@ class Viewer {
|
|||
}
|
||||
|
||||
setFirstPersonCamera (pos, yaw, pitch) {
|
||||
if (pos) new TWEEN.Tween(this.camera.position).to({ x: pos.x, y: pos.y + this.playerHeight, z: pos.z }, 50).start()
|
||||
if (pos) {
|
||||
let y = pos.y + this.playerHeight
|
||||
if (this.isSneaking) y -= 0.3
|
||||
new TWEEN.Tween(this.camera.position).to({ x: pos.x, y, z: pos.z }, 50).start()
|
||||
}
|
||||
this.camera.rotation.set(pitch, yaw, 0, 'ZYX')
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ class WorldRenderer {
|
|||
this.loadedChunks = {}
|
||||
this.sectionsOutstanding = new Set()
|
||||
this.renderUpdateEmitter = new EventEmitter()
|
||||
this.blockStatesData = undefined
|
||||
this.texturesDataUrl = undefined
|
||||
|
||||
this.material = new THREE.MeshLambertMaterial({ vertexColors: true, transparent: true, alphaTest: 0.1 })
|
||||
|
||||
|
|
@ -81,11 +83,11 @@ class WorldRenderer {
|
|||
worker.postMessage({ type: 'version', version })
|
||||
}
|
||||
|
||||
this.updateData()
|
||||
this.updateTexturesData()
|
||||
}
|
||||
|
||||
updateData () {
|
||||
loadTexture(globalThis.texturePackDataUrl || `textures/${this.version}.png`, texture => {
|
||||
updateTexturesData () {
|
||||
loadTexture(this.texturesDataUrl || `textures/${this.version}.png`, texture => {
|
||||
texture.magFilter = THREE.NearestFilter
|
||||
texture.minFilter = THREE.NearestFilter
|
||||
texture.flipY = false
|
||||
|
|
@ -94,7 +96,7 @@ class WorldRenderer {
|
|||
|
||||
const loadBlockStates = () => {
|
||||
return new Promise(resolve => {
|
||||
if (globalThis.texturePackDataBlockStates) return resolve(globalThis.texturePackDataBlockStates)
|
||||
if (this.blockStatesData) return resolve(this.blockStatesData)
|
||||
return loadJSON(`blocksStates/${this.version}.json`, resolve)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue