minecraft-renderer 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minecraft-renderer",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "The most Modular Minecraft world renderer with Three.js WebGL backend",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/index.ts CHANGED
@@ -72,7 +72,7 @@ export * from './modules'
72
72
  // Three.js Backend (re-exported for convenience)
73
73
  // ============================================================================
74
74
  export {
75
- createGraphicsBackend,
75
+ default as createGraphicsBackend,
76
76
  createGraphicsBackendBase
77
77
  } from './three/graphicsBackend'
78
78
 
@@ -1,7 +1,7 @@
1
1
  import { Vec3 } from 'vec3'
2
2
  import worldBlockProvider, { WorldBlockProvider } from 'mc-assets/dist/worldBlockProvider'
3
3
  import legacyJson from '../lib/preflatMap.json'
4
- import { BlockType } from '../../../playground/shared'
4
+ import { BlockType } from '../playground/shared'
5
5
  import { World, BlockModelPartsResolved, WorldBlock as Block, WorldBlock, worldColumnKey } from './world'
6
6
  import { BlockElement, buildRotationMatrix, elemFaces, matmul3, matmulmat3, vecadd3, vecsub3 } from './modelsGeometryCommon'
7
7
  import { INVISIBLE_BLOCKS } from './worldConstants'
@@ -27,7 +27,7 @@ type Tiles = {
27
27
  [blockPos: string]: BlockType
28
28
  }
29
29
 
30
- function prepareTints (tints) {
30
+ function prepareTints(tints) {
31
31
  const map = new Map()
32
32
  const defaultValue = tintToGl(tints.default)
33
33
  for (let { keys, color } of tints.data) {
@@ -37,14 +37,14 @@ function prepareTints (tints) {
37
37
  }
38
38
  }
39
39
  return new Proxy(map, {
40
- get (target, key) {
40
+ get(target, key) {
41
41
  return target.has(key) ? target.get(key) : defaultValue
42
42
  }
43
43
  })
44
44
  }
45
45
 
46
46
  const calculatedBlocksEntries = Object.entries(legacyJson.clientCalculatedBlocks)
47
- export function preflatBlockCalculation (block: Block, world: World, position: Vec3) {
47
+ export function preflatBlockCalculation(block: Block, world: World, position: Vec3) {
48
48
  const type = calculatedBlocksEntries.find(([name, blocks]) => blocks.includes(block.name))?.[0]
49
49
  if (!type) return
50
50
  switch (type) {
@@ -96,14 +96,14 @@ export function preflatBlockCalculation (block: Block, world: World, position: V
96
96
  }
97
97
  }
98
98
 
99
- function tintToGl (tint) {
99
+ function tintToGl(tint) {
100
100
  const r = (tint >> 16) & 0xff
101
101
  const g = (tint >> 8) & 0xff
102
102
  const b = tint & 0xff
103
103
  return [r / 255, g / 255, b / 255]
104
104
  }
105
105
 
106
- function getLiquidRenderHeight (world: World, block: WorldBlock | null, type: number, pos: Vec3, isWater: boolean, isRealWater: boolean) {
106
+ function getLiquidRenderHeight(world: World, block: WorldBlock | null, type: number, pos: Vec3, isWater: boolean, isRealWater: boolean) {
107
107
  if ((isWater && !isRealWater) || (block && isBlockWaterlogged(block))) return 8 / 9
108
108
  if (!block || block.type !== type) return 1 / 9
109
109
  if (block.metadata === 0) { // source block
@@ -132,7 +132,7 @@ const getVec = (v: Vec3, dir: Vec3) => {
132
132
  return v.plus(dir)
133
133
  }
134
134
 
135
- function renderLiquid (world: World, cursor: Vec3, texture: any | undefined, type: number, biome: string, water: boolean, attr: MesherGeometryOutput, isRealWater: boolean) {
135
+ function renderLiquid(world: World, cursor: Vec3, texture: any | undefined, type: number, biome: string, water: boolean, attr: MesherGeometryOutput, isRealWater: boolean) {
136
136
  const heights: number[] = []
137
137
  for (let z = -1; z <= 1; z++) {
138
138
  for (let x = -1; x <= 1; x++) {
@@ -269,7 +269,7 @@ const identicalCull = (currentElement: BlockElement, neighbor: Block, direction:
269
269
 
270
270
  let needSectionRecomputeOnChange = false
271
271
 
272
- function renderElement (world: World, cursor: Vec3, element: BlockElement, doAO: boolean, attr: MesherGeometryOutput, globalMatrix: any, globalShift: any, block: Block, biome: string) {
272
+ function renderElement(world: World, cursor: Vec3, element: BlockElement, doAO: boolean, attr: MesherGeometryOutput, globalMatrix: any, globalShift: any, block: Block, biome: string) {
273
273
  const position = cursor
274
274
  // const key = `${position.x},${position.y},${position.z}`
275
275
  // if (!globalThis.allowedBlocks.includes(key)) return
@@ -519,7 +519,7 @@ const isBlockWaterlogged = (block: Block) => {
519
519
  }
520
520
 
521
521
  let unknownBlockModel: BlockModelPartsResolved
522
- export function getSectionGeometry (sx: number, sy: number, sz: number, world: World) {
522
+ export function getSectionGeometry(sx: number, sy: number, sz: number, world: World) {
523
523
  let delayedRender = [] as Array<() => void>
524
524
 
525
525
  const attr: MesherGeometryOutput = {
@@ -744,11 +744,11 @@ export function getSectionGeometry (sx: number, sy: number, sz: number, world: W
744
744
  }
745
745
 
746
746
  // copied from three.js
747
- function arrayNeedsUint32 (array) {
747
+ function arrayNeedsUint32(array) {
748
748
 
749
749
  // assumes larger values usually on last
750
750
 
751
- for (let i = array.length - 1; i >= 0; -- i) {
751
+ for (let i = array.length - 1; i >= 0; --i) {
752
752
 
753
753
  if (array[i] >= 65_535) return true // account for PRIMITIVE_RESTART_FIXED_INDEX, #24565
754
754