@@ -620,24 +620,56 @@ export class Entities {
620620 let mesh
621621 if ( e === undefined ) {
622622 const group = new THREE . Group ( )
623- if ( entity . name === 'item' ) {
624- const item = entity . metadata ?. find ( ( m : any ) => typeof m === 'object' && m ?. itemCount )
623+ if ( entity . name === 'item' || entity . name === 'tnt' || entity . name === 'falling_block' ) {
624+ const item = entity . name === 'tnt'
625+ ? { name : 'tnt' }
626+ : entity . name === 'falling_block'
627+ ? { blockState : entity [ 'objectData' ] }
628+ : entity . metadata ?. find ( ( m : any ) => typeof m === 'object' && m ?. itemCount )
625629 if ( item ) {
626630 const object = this . getItemMesh ( item , {
627631 'minecraft:display_context' : 'ground' ,
628632 } )
629633 if ( object ) {
630634 mesh = object . mesh
631- mesh . scale . set ( 0.5 , 0.5 , 0.5 )
632- mesh . position . set ( 0 , 0.2 , 0 )
635+ if ( entity . name === 'item' ) {
636+ mesh . scale . set ( 0.5 , 0.5 , 0.5 )
637+ mesh . position . set ( 0 , 0.2 , 0 )
638+ } else {
639+ mesh . scale . set ( 2 , 2 , 2 )
640+ mesh . position . set ( 0 , 0.5 , 0 )
641+ }
633642 // set faces
634643 // mesh.position.set(targetPos.x + 0.5 + 2, targetPos.y + 0.5, targetPos.z + 0.5)
635644 // viewer.scene.add(mesh)
636645 const clock = new THREE . Clock ( )
637- mesh . onBeforeRender = ( ) => {
638- const delta = clock . getDelta ( )
639- mesh . rotation . y += delta
646+ if ( entity . name === 'item' ) {
647+ mesh . onBeforeRender = ( ) => {
648+ const delta = clock . getDelta ( )
649+ mesh . rotation . y += delta
650+ }
640651 }
652+
653+ // TNT blinking
654+ // if (entity.name === 'tnt') {
655+ // let lastBlink = 0
656+ // const blinkInterval = 500 // ms between blinks
657+ // mesh.onBeforeRender = () => {
658+ // const now = Date.now()
659+ // if (now - lastBlink > blinkInterval) {
660+ // lastBlink = now
661+ // mesh.traverse((child) => {
662+ // if (child instanceof THREE.Mesh) {
663+ // const material = child.material as THREE.MeshLambertMaterial
664+ // material.color.set(material.color?.equals(new THREE.Color(0xff_ff_ff))
665+ // ? new THREE.Color(0xff_00_00)
666+ // : new THREE.Color(0xff_ff_ff))
667+ // }
668+ // })
669+ // }
670+ // }
671+ // }
672+
641673 //@ts -expect-error
642674 group . additionalCleanup = ( ) => {
643675 // important: avoid texture memory leak and gpu slowdown
@@ -1076,7 +1108,7 @@ export class Entities {
10761108 const entityMesh = this . entities [ entityId ] ?. children . find ( c => c . name === 'mesh' )
10771109 if ( entityMesh ) {
10781110 entityMesh . traverse ( ( child ) => {
1079- if ( child instanceof THREE . Mesh ) {
1111+ if ( child instanceof THREE . Mesh && child . material . clone ) {
10801112 const clonedMaterial = child . material . clone ( )
10811113 clonedMaterial . dispose ( )
10821114 child . material = child . material . clone ( )
0 commit comments