@@ -75,29 +75,35 @@ export function applyModelDisplayTransform(
7575 model : IItemModel ,
7676 itemDisplay : ItemDisplayMode
7777) {
78- if ( itemDisplay === 'none' ) return
78+ if ( itemDisplay === 'none' || ! model . display ) return
7979
8080 // default to right hand if left hand display is not defined
81- if ( itemDisplay === ' thirdperson_lefthand' && ! model . display ?. thirdperson_lefthand ) {
82- itemDisplay = ' thirdperson_righthand'
81+ if ( ! model . display . thirdperson_lefthand && model . display . thirdperson_righthand ) {
82+ model . display . thirdperson_lefthand = structuredClone ( model . display . thirdperson_righthand )
8383 }
84- if ( itemDisplay === ' firstperson_lefthand' && ! model . display ?. firstperson_lefthand ) {
85- itemDisplay = 'firstperson_righthand'
84+ if ( ! model . display . firstperson_lefthand && model . display . firstperson_righthand ) {
85+ model . display . firstperson_lefthand = structuredClone ( model . display . thirdperson_righthand )
8686 }
8787
88- const display = model . display ?. [ itemDisplay ]
88+ const display = model . display [ itemDisplay ]
8989 if ( ! display ) return
9090
9191 const matrix = new THREE . Matrix4 ( )
9292 if ( display . rotation ) {
9393 const rot = display . rotation . map ( ( n : number ) => ( n * Math . PI ) / 180 )
94- matrix . makeRotationFromEuler ( new THREE . Euler ( rot [ 0 ] , rot [ 1 ] , rot [ 2 ] ) )
94+ matrix . makeRotationFromEuler ( Reusable . euler1 . set ( - rot [ 0 ] , - rot [ 1 ] , rot [ 2 ] ) )
9595 }
9696 if ( display . translation ) {
97- matrix . setPosition ( new THREE . Vector3 ( ...display . translation ) )
97+ matrix . setPosition (
98+ Reusable . vec1 . set (
99+ display . translation [ 0 ] ,
100+ display . translation [ 1 ] ,
101+ display . translation [ 2 ]
102+ )
103+ )
98104 }
99105 if ( display . scale ) {
100- matrix . scale ( new THREE . Vector3 ( ...display . scale ) )
106+ matrix . scale ( Reusable . vec2 . set ( ...display . scale ) )
101107 }
102108
103109 itemModel . boundingBox . applyMatrix4 ( matrix )
0 commit comments