implement main menu, implement textfield widget, implement create world screen, implement splash screen
This commit is contained in:
@@ -6,6 +6,8 @@ import * as THREE from "../../../../../../libraries/three.module.js";
|
||||
|
||||
export default class Chunk {
|
||||
|
||||
static SECTION_AMOUNT = 16;
|
||||
|
||||
constructor(world, x, z) {
|
||||
this.world = world;
|
||||
this.x = x;
|
||||
@@ -21,7 +23,7 @@ export default class Chunk {
|
||||
|
||||
// Initialize sections
|
||||
this.sections = [];
|
||||
for (let y = 0; y < 16; y++) {
|
||||
for (let y = 0; y < Chunk.SECTION_AMOUNT; y++) {
|
||||
let section = new ChunkSection(world, this, x, y, z);
|
||||
|
||||
this.sections[y] = section;
|
||||
|
||||
@@ -24,7 +24,7 @@ export default class ChunkSection {
|
||||
|
||||
this.group = new THREE.Object3D();
|
||||
this.group.matrixAutoUpdate = false;
|
||||
this.isModified = false;
|
||||
this.isModified = true;
|
||||
|
||||
this.blocks = [];
|
||||
this.blocksData = [];
|
||||
@@ -118,8 +118,8 @@ export default class ChunkSection {
|
||||
|
||||
getTotalLightAt(x, y, z) {
|
||||
let index = y << 8 | z << 4 | x;
|
||||
let skyLight = (!this.empty && index in this.skyLight ? this.skyLight[index] : (this.empty ? 15 : 14)) - this.world.skylightSubtracted;
|
||||
let blockLight = !this.empty && index in this.blockLight ? this.blockLight[index] : 0;
|
||||
let skyLight = (index in this.skyLight ? this.skyLight[index] : (this.empty ? 15 : 14)) - this.world.skylightSubtracted;
|
||||
let blockLight = index in this.blockLight ? this.blockLight[index] : 0;
|
||||
if (blockLight > skyLight) {
|
||||
skyLight = blockLight;
|
||||
}
|
||||
@@ -129,10 +129,10 @@ export default class ChunkSection {
|
||||
getLightAt(sourceType, x, y, z) {
|
||||
let index = y << 8 | z << 4 | x;
|
||||
if (sourceType === EnumSkyBlock.SKY) {
|
||||
return !this.empty && index in this.skyLight ? this.skyLight[index] : (this.empty ? 15 : 14);
|
||||
return index in this.skyLight ? this.skyLight[index] : (this.empty ? 15 : 14);
|
||||
}
|
||||
if (sourceType === EnumSkyBlock.BLOCK) {
|
||||
return !this.empty && index in this.blockLight ? this.blockLight[index] : 0;
|
||||
return index in this.blockLight ? this.blockLight[index] : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import EnumBlockFace from "../../util/EnumBlockFace.js";
|
||||
import Vector3 from "../../util/Vector3.js";
|
||||
import Vector4 from "../../util/Vector4.js";
|
||||
import MetadataChunkBlock from "../../util/MetadataChunkBlock.js";
|
||||
import Long from "../../../../../../libraries/long.js";
|
||||
import * as THREE from "../../../../../../libraries/three.module.js";
|
||||
import WorldRenderer from "../render/WorldRenderer.js";
|
||||
import Random from "../../util/Random.js";
|
||||
@@ -17,7 +16,7 @@ export default class World {
|
||||
|
||||
static TOTAL_HEIGHT = ChunkSection.SIZE * 8 - 1; // ChunkSection.SIZE * 16 - 1;
|
||||
|
||||
constructor(minecraft, seed = Long.fromInt(Date.now() % 100000)) {
|
||||
constructor(minecraft, seed) {
|
||||
this.minecraft = minecraft;
|
||||
|
||||
this.entities = [];
|
||||
@@ -182,6 +181,13 @@ export default class World {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip if section has no blocks
|
||||
let section1 = this.getChunkSectionAt(x1 >> 4, y1 >> 4, z1 >> 4);
|
||||
let section2 = this.getChunkSectionAt(x2 >> 4, y2 >> 4, z2 >> 4);
|
||||
if (section1 === section2 && section1.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add light update region to queue
|
||||
if (this.lightUpdateQueue.length < 9999) {
|
||||
this.lightUpdateQueue.push(new MetadataChunkBlock(sourceType, x1, y1, z1, x2, y2, z2));
|
||||
|
||||
Reference in New Issue
Block a user