minecraft-renderer 0.1.59 → 0.1.60

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.59",
3
+ "version": "0.1.60",
4
4
  "description": "The most Modular Minecraft world renderer with Three.js WebGL backend",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -10,6 +10,22 @@ export type PlayerObjectType = PlayerObject & {
10
10
  realUsername: string
11
11
  }
12
12
 
13
+ /** Starfield + log-depth world: cutout skin mats need alphaTest and depthWrite (not mesh traverse). */
14
+ export function configurePlayerSkinMaterials (playerObject: PlayerObject): void {
15
+ const skin = playerObject.skin
16
+ const materials = [
17
+ skin.layer1Material,
18
+ skin.layer1MaterialBiased,
19
+ skin.layer2Material,
20
+ skin.layer2MaterialBiased,
21
+ ]
22
+ for (const mat of materials) {
23
+ mat.transparent = true
24
+ mat.alphaTest = 0.1
25
+ mat.depthWrite = true
26
+ }
27
+ }
28
+
13
29
  export function createPlayerObject (options: {
14
30
  username?: string
15
31
  uuid?: string
@@ -25,12 +41,7 @@ export function createPlayerObject (options: {
25
41
  playerObject.realUsername = options.username ?? ''
26
42
  playerObject.position.set(0, 16, 0)
27
43
 
28
- // fix issues with starfield
29
- playerObject.traverse((obj) => {
30
- if (obj instanceof THREE.Mesh && obj.material instanceof THREE.MeshStandardMaterial) {
31
- obj.material.transparent = true
32
- }
33
- })
44
+ configurePlayerSkinMaterials(playerObject)
34
45
 
35
46
  wrapper.add(playerObject as any)
36
47
  const scale = options.scale ?? (1 / 16)
@@ -16,7 +16,7 @@ import PrismarineChatLoader from 'prismarine-chat'
16
16
  import { loadSkinFromUsername, loadSkinImage, stevePngUrl } from '../lib/utils/skins'
17
17
  import { renderComponent } from '../sign-renderer'
18
18
  import { createCanvas } from '../lib/utils'
19
- import { PlayerObjectType } from '../lib/createPlayerObject'
19
+ import { configurePlayerSkinMaterials, PlayerObjectType } from '../lib/createPlayerObject'
20
20
  import { getBlockMeshFromModel } from './holdingBlock'
21
21
  import { createItemMesh } from './itemMesh'
22
22
  import * as Entity from './entity/EntityMesh'
@@ -832,6 +832,7 @@ export class Entities {
832
832
  playerObject.skin.map = skinTexture as any
833
833
  playerObject.skin.modelType = inferModelType(skinCanvas)
834
834
  playerObject.skin['isCustom'] = skinUrl !== stevePngUrl
835
+ configurePlayerSkinMaterials(playerObject)
835
836
 
836
837
  let earsCanvas: OffscreenCanvas | undefined
837
838
  if (!playerCustomSkinImage) {
@@ -1636,12 +1637,7 @@ export class Entities {
1636
1637
  playerObject.realUsername = entity.username ?? ''
1637
1638
  playerObject.position.set(0, 16, 0)
1638
1639
 
1639
- // fix issues with starfield
1640
- playerObject.traverse((obj) => {
1641
- if (obj instanceof THREE.Mesh && obj.material instanceof THREE.MeshStandardMaterial) {
1642
- obj.material.transparent = true
1643
- }
1644
- })
1640
+ configurePlayerSkinMaterials(playerObject)
1645
1641
 
1646
1642
  wrapper.add(playerObject as any)
1647
1643
  const scale = 1 / 16