@@ -364,8 +364,9 @@ OutlinerElement.registerType(TextDisplay, TextDisplay.type)
364364export const PREVIEW_CONTROLLER = new NodePreviewController ( TextDisplay , {
365365 setup ( el : TextDisplay ) {
366366 const textMesh = new THREE . Mesh ( new THREE . PlaneGeometry ( 0 , 0 ) )
367- textMesh . fix_rotation = new THREE . Euler ( 0 , 0 , 0 , 'ZYX' )
368- textMesh . fix_position = new THREE . Vector3 ( 0 , 0 , 0 )
367+ textMesh . fix_rotation = new THREE . Euler ( ...el . rotation , 'ZYX' )
368+ textMesh . fix_position = new THREE . Vector3 ( ...el . position )
369+ textMesh . fix_scale = new THREE . Vector3 ( ...el . scale )
369370 // Minecraft's transparency is funky 😭
370371 textMesh . renderOrder = - 1
371372
@@ -401,9 +402,20 @@ export const PREVIEW_CONTROLLER = new NodePreviewController(TextDisplay, {
401402 void el . updateText ( )
402403 } ,
403404 updateTransform ( el : TextDisplay ) {
404- NodePreviewController . prototype . updateTransform . call ( this , el )
405+ NodePreviewController . prototype . updateTransform . call ( PREVIEW_CONTROLLER , el )
405406 if ( el . mesh . fix_position ) {
406407 el . mesh . fix_position . set ( ...el . position )
408+ if ( el . parent instanceof Group ) {
409+ el . mesh . fix_position . x -= el . parent . origin [ 0 ]
410+ el . mesh . fix_position . y -= el . parent . origin [ 1 ]
411+ el . mesh . fix_position . z -= el . parent . origin [ 2 ]
412+ }
413+ }
414+ if ( el . mesh . fix_rotation ) {
415+ el . mesh . fix_rotation . set ( ...el . rotation )
416+ }
417+ if ( el . mesh . fix_scale ) {
418+ el . mesh . fix_scale . set ( ...el . scale )
407419 }
408420 } ,
409421} )
@@ -500,6 +512,62 @@ class TextDisplayAnimator extends BoneAnimator {
500512 this . getElement ( )
501513 return ! ! ( this . element && this . element . mesh )
502514 }
515+
516+ displayRotation ( arr : ArrayVector3 | ArrayVector4 , multiplier = 1 ) {
517+ const bone = this . getElement ( ) . mesh
518+
519+ if ( bone . fix_rotation ) {
520+ bone . rotation . copy ( bone . fix_rotation as THREE . Euler )
521+ }
522+
523+ if ( arr ) {
524+ if ( arr . length === 4 ) {
525+ const added_rotation = new THREE . Euler ( ) . setFromQuaternion (
526+ new THREE . Quaternion ( ) . fromArray ( arr ) ,
527+ 'ZYX'
528+ )
529+ bone . rotation . x -= added_rotation . x * multiplier
530+ bone . rotation . y -= added_rotation . y * multiplier
531+ bone . rotation . z += added_rotation . z * multiplier
532+ } else {
533+ bone . rotation . x += Math . degToRad ( - arr [ 0 ] ) * multiplier
534+ bone . rotation . y += Math . degToRad ( - arr [ 1 ] ) * multiplier
535+ bone . rotation . z += Math . degToRad ( arr [ 2 ] ) * multiplier
536+ }
537+ }
538+ if ( this . rotation_global ) {
539+ const quat = bone . parent ?. getWorldQuaternion ( Reusable . quat1 )
540+ if ( ! quat ) return this
541+ quat . invert ( )
542+ bone . quaternion . premultiply ( quat )
543+ }
544+ return this
545+ }
546+
547+ displayPosition ( arr : ArrayVector3 , multiplier = 1 ) {
548+ const bone = this . getElement ( ) . mesh
549+ if ( bone . fix_position ) {
550+ bone . position . copy ( bone . fix_position as THREE . Vector3 )
551+ }
552+ if ( arr ) {
553+ bone . position . x -= arr [ 0 ] * multiplier
554+ bone . position . y += arr [ 1 ] * multiplier
555+ bone . position . z += arr [ 2 ] * multiplier
556+ }
557+ return this
558+ }
559+
560+ displayScale ( arr : ArrayVector3 , multiplier = 1 ) {
561+ if ( ! arr ) return this
562+ const bone = this . getElement ( ) . mesh
563+ if ( bone . fix_scale ) {
564+ bone . scale . copy ( bone . fix_scale )
565+ }
566+ bone . scale . x *= 1 + ( arr [ 0 ] - 1 ) * multiplier || 0.00001
567+ bone . scale . y *= 1 + ( arr [ 1 ] - 1 ) * multiplier || 0.00001
568+ bone . scale . z *= 1 + ( arr [ 2 ] - 1 ) * multiplier || 0.00001
569+ return this
570+ }
503571}
504572TextDisplayAnimator . prototype . type = TextDisplay . type
505573TextDisplay . animator = TextDisplayAnimator as any
0 commit comments