@@ -3071,9 +3071,9 @@ module.exports = {
30713071 /** @type {number } */
30723072 _defaultDepth ;
30733073
3074- /** @type {[number, number, number] | null } */
3074+ /** @type {[number | null , number | null , number | null] } */
30753075 _originPoint ;
3076- /** @type {[number, number, number] | null } */
3076+ /** @type {[number | null , number | null , number | null] } */
30773077 _centerPoint ;
30783078
30793079 /** @type {[number, number, number] } */
@@ -3168,11 +3168,31 @@ module.exports = {
31683168 }
31693169
31703170 getOriginPoint ( ) {
3171- return this . _originPoint || this . _modelOriginPoint ;
3171+ return [
3172+ this . _originPoint [ 0 ] === null
3173+ ? this . _modelOriginPoint [ 0 ]
3174+ : this . _originPoint [ 0 ] ,
3175+ this . _originPoint [ 1 ] === null
3176+ ? this . _modelOriginPoint [ 1 ]
3177+ : this . _originPoint [ 1 ] ,
3178+ this . _originPoint [ 2 ] === null
3179+ ? this . _modelOriginPoint [ 2 ]
3180+ : this . _originPoint [ 2 ] ,
3181+ ] ;
31723182 }
31733183
31743184 getCenterPoint ( ) {
3175- return this . _centerPoint || this . _modelOriginPoint ;
3185+ return [
3186+ this . _centerPoint [ 0 ] === null
3187+ ? this . _modelOriginPoint [ 0 ]
3188+ : this . _centerPoint [ 0 ] ,
3189+ this . _centerPoint [ 1 ] === null
3190+ ? this . _modelOriginPoint [ 1 ]
3191+ : this . _centerPoint [ 1 ] ,
3192+ this . _centerPoint [ 2 ] === null
3193+ ? this . _modelOriginPoint [ 2 ]
3194+ : this . _centerPoint [ 2 ] ,
3195+ ] ;
31763196 }
31773197
31783198 _updateDefaultTransformation (
@@ -3219,12 +3239,23 @@ module.exports = {
32193239
32203240 // Center the model.
32213241 const centerPoint = this . _centerPoint ;
3222- if ( centerPoint ) {
3223- threeObject . position . set (
3224- - ( boundingBox . min . x + modelWidth * centerPoint [ 0 ] ) ,
3225- // The model is flipped on Y axis.
3226- - ( boundingBox . min . y + modelHeight * ( 1 - centerPoint [ 1 ] ) ) ,
3227- - ( boundingBox . min . z + modelDepth * centerPoint [ 2 ] )
3242+ if ( centerPoint [ 0 ] ) {
3243+ threeObject . position . x = - (
3244+ boundingBox . min . x +
3245+ modelWidth * centerPoint [ 0 ]
3246+ ) ;
3247+ }
3248+ if ( centerPoint [ 1 ] ) {
3249+ // The model is flipped on Y axis.
3250+ threeObject . position . y = - (
3251+ boundingBox . min . y +
3252+ modelHeight * ( 1 - centerPoint [ 1 ] )
3253+ ) ;
3254+ }
3255+ if ( centerPoint [ 2 ] ) {
3256+ threeObject . position . z = - (
3257+ boundingBox . min . z +
3258+ modelDepth * centerPoint [ 2 ]
32283259 ) ;
32293260 }
32303261
@@ -3320,8 +3351,8 @@ module.exports = {
33203351 }
33213352
33223353 /**
3323- * @param {[number, number, number] | null } point1
3324- * @param {[number, number, number] | null } point2
3354+ * @param {[number | null , number | null , number | null] } point1
3355+ * @param {[number | null , number | null , number | null] } point2
33253356 * @returns {boolean }
33263357 */
33273358 const isSamePoint = ( point1 , point2 ) => {
@@ -3337,22 +3368,24 @@ module.exports = {
33373368
33383369 /**
33393370 * @param {string } location
3340- * @returns {[number, number, number] | null }
3371+ * @returns {[number | null , number | null , number | null] }
33413372 */
33423373 const getPointForLocation = ( location ) => {
33433374 switch ( location ) {
33443375 case 'ModelOrigin' :
3345- return null ;
3376+ return [ null , null , null ] ;
33463377 case 'ObjectCenter' :
33473378 return [ 0.5 , 0.5 , 0.5 ] ;
3379+ case 'CenteredOnZ' :
3380+ return [ null , null , 0.5 ] ;
33483381 case 'BottomCenterZ' :
33493382 return [ 0.5 , 0.5 , 0 ] ;
33503383 case 'BottomCenterY' :
33513384 return [ 0.5 , 1 , 0.5 ] ;
33523385 case 'TopLeft' :
33533386 return [ 0 , 0 , 0 ] ;
33543387 default :
3355- return null ;
3388+ return [ null , null , null ] ;
33563389 }
33573390 } ;
33583391
@@ -3367,10 +3400,10 @@ module.exports = {
33673400 _rotationY = 0 ;
33683401 _rotationZ = 0 ;
33693402 _keepAspectRatio = false ;
3370- /** @type {[number, number, number] | null } */
3371- _originPoint = null ;
3372- /** @type {[number, number, number] | null } */
3373- _centerPoint = null ;
3403+ /** @type {[number | null , number | null , number | null] } */
3404+ _originPoint = [ null , null , null ] ;
3405+ /** @type {[number | null , number | null , number | null] } */
3406+ _centerPoint = [ null , null , null ] ;
33743407
33753408 /** @type {[number, number, number] } */
33763409 _modelOriginPoint = [ 0 , 0 , 0 ] ;
@@ -3436,11 +3469,31 @@ module.exports = {
34363469 }
34373470
34383471 getOriginPoint ( ) {
3439- return this . _originPoint || this . _modelOriginPoint ;
3472+ return [
3473+ this . _originPoint [ 0 ] === null
3474+ ? this . _modelOriginPoint [ 0 ]
3475+ : this . _originPoint [ 0 ] ,
3476+ this . _originPoint [ 1 ] === null
3477+ ? this . _modelOriginPoint [ 1 ]
3478+ : this . _originPoint [ 1 ] ,
3479+ this . _originPoint [ 2 ] === null
3480+ ? this . _modelOriginPoint [ 2 ]
3481+ : this . _originPoint [ 2 ] ,
3482+ ] ;
34403483 }
34413484
34423485 getCenterPoint ( ) {
3443- return this . _centerPoint || this . _modelOriginPoint ;
3486+ return [
3487+ this . _centerPoint [ 0 ] === null
3488+ ? this . _modelOriginPoint [ 0 ]
3489+ : this . _centerPoint [ 0 ] ,
3490+ this . _centerPoint [ 1 ] === null
3491+ ? this . _modelOriginPoint [ 1 ]
3492+ : this . _centerPoint [ 1 ] ,
3493+ this . _centerPoint [ 2 ] === null
3494+ ? this . _modelOriginPoint [ 2 ]
3495+ : this . _centerPoint [ 2 ] ,
3496+ ] ;
34443497 }
34453498
34463499 _updateDefaultTransformation ( ) {
@@ -3493,12 +3546,23 @@ module.exports = {
34933546
34943547 // Center the model.
34953548 const centerPoint = this . _centerPoint ;
3496- if ( centerPoint ) {
3497- threeModelGroup . position . set (
3498- - ( boundingBox . min . x + modelWidth * centerPoint [ 0 ] ) ,
3499- // The model is flipped on Y axis.
3500- - ( boundingBox . min . y + modelHeight * ( 1 - centerPoint [ 1 ] ) ) ,
3501- - ( boundingBox . min . z + modelDepth * centerPoint [ 2 ] )
3549+ if ( centerPoint [ 0 ] !== null ) {
3550+ threeModelGroup . position . x = - (
3551+ boundingBox . min . x +
3552+ modelWidth * centerPoint [ 0 ]
3553+ ) ;
3554+ }
3555+ if ( centerPoint [ 1 ] !== null ) {
3556+ // The model is flipped on Y axis.
3557+ threeModelGroup . position . y = - (
3558+ boundingBox . min . y +
3559+ modelHeight * ( 1 - centerPoint [ 1 ] )
3560+ ) ;
3561+ }
3562+ if ( centerPoint [ 2 ] !== null ) {
3563+ threeModelGroup . position . z = - (
3564+ boundingBox . min . z +
3565+ modelDepth * centerPoint [ 2 ]
35023566 ) ;
35033567 }
35043568
0 commit comments