minecraft-renderer 0.1.31 → 0.1.32

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.
@@ -0,0 +1,22 @@
1
+ //@ts-nocheck
2
+ import type * as THREE from 'three'
3
+ import type { WorldRendererConfig } from '../graphicsBackend'
4
+
5
+ export interface IHoldingBlock {
6
+ ready: boolean
7
+ holdingBlock: THREE.Object3D | undefined
8
+ config: WorldRendererConfig
9
+ isSwinging: boolean
10
+
11
+ render(
12
+ originalCamera: THREE.PerspectiveCamera,
13
+ renderer: THREE.WebGLRenderer,
14
+ ambientLight: THREE.AmbientLight,
15
+ directionalLight: THREE.DirectionalLight
16
+ ): void
17
+ startSwing(): void
18
+ stopSwing(): void
19
+ updateItem(): void
20
+ playBlockSwapAnimation(forceState: 'appeared' | 'disappeared'): Promise<boolean>
21
+ dispose(): void
22
+ }
@@ -15,7 +15,8 @@ import { ItemSpecificContextProperties } from '../playerState/types'
15
15
  import { setBlockPosition } from '../mesher/standaloneRenderer'
16
16
  import { getBannerTexture, createBannerMesh, releaseBannerTexture } from './bannerRenderer'
17
17
  import { getMyHand } from './hand'
18
- import HoldingBlock from './holdingBlock'
18
+ import { createHoldingBlock } from './holdingBlockFactory'
19
+ import type { IHoldingBlock } from './holdingBlockTypes'
19
20
  import { getMesh } from './entity/EntityMesh'
20
21
  import { armorModel } from './entity/armorModels'
21
22
  import { disposeObject, loadThreeJsTextureFromBitmap } from './threeJsUtils'
@@ -48,8 +49,8 @@ export class WorldRendererThree extends WorldRendererCommon {
48
49
  chunkTextures = new Map<string, { [pos: string]: THREE.Texture }>()
49
50
  signsCache = new Map<string, any>()
50
51
  cameraSectionPos: Vec3 = new Vec3(0, 0, 0)
51
- holdingBlock: HoldingBlock
52
- holdingBlockLeft: HoldingBlock
52
+ holdingBlock: IHoldingBlock
53
+ holdingBlockLeft: IHoldingBlock
53
54
  scene = new THREE.Scene()
54
55
  ambientLight = new THREE.AmbientLight(0xcc_cc_cc)
55
56
  directionalLight = new THREE.DirectionalLight(0xff_ff_ff, 0.5)
@@ -148,8 +149,8 @@ export class WorldRendererThree extends WorldRendererCommon {
148
149
  this.worldBlockGeometry = new WorldBlockGeometry(this, this.scene, this.material, displayOptions)
149
150
 
150
151
  this.cursorBlock = new CursorBlock(this)
151
- this.holdingBlock = new HoldingBlock(this)
152
- this.holdingBlockLeft = new HoldingBlock(this, true)
152
+ this.holdingBlock = createHoldingBlock(this)
153
+ this.holdingBlockLeft = createHoldingBlock(this, true)
153
154
 
154
155
  // Register built-in modules
155
156
  for (const manifest of Object.values(BUILTIN_MODULES)) {
@@ -500,6 +501,26 @@ export class WorldRendererThree extends WorldRendererCommon {
500
501
  this.skyboxRenderer.updateDefaultSkybox(value)
501
502
  })
502
503
 
504
+ let currentHandRenderer = this.displayOptions.inWorldRenderingConfig.handRenderer
505
+ this.onReactiveConfigUpdated('handRenderer', (value) => {
506
+ if (value === currentHandRenderer) return
507
+ currentHandRenderer = value
508
+ const wasReady = this.holdingBlock.ready
509
+ const wasReadyLeft = this.holdingBlockLeft.ready
510
+ this.holdingBlock.dispose()
511
+ this.holdingBlockLeft.dispose()
512
+ this.holdingBlock = createHoldingBlock(this)
513
+ this.holdingBlockLeft = createHoldingBlock(this, true)
514
+ if (wasReady) {
515
+ this.holdingBlock.ready = true
516
+ this.holdingBlock.updateItem()
517
+ }
518
+ if (wasReadyLeft) {
519
+ this.holdingBlockLeft.ready = true
520
+ this.holdingBlockLeft.updateItem()
521
+ }
522
+ })
523
+
503
524
  // Watch for config changes that affect modules
504
525
  this.onReactiveConfigUpdated('*' as any, () => {
505
526
  this.updateModulesFromConfig()