import {IconObject3d,Object3d,Transform, Space3d,PathUrl,Tween} from './box3.js';
import { CursorHelper } from './CursorHelper.js';
import * as gui from "./gui.js";
/**空间标签助手 */
export class Space3dTagHelper{
    /**创建楼层标签(3d对象)
     * 
     * @param {Space3d} s3d 
     * @param {{mode:number,side:string}} options
     */
    static CreateFloorTag(s3d,options ={mode:0,side:'left'}){
        /**@type {Object3d} */
        let tag = null;
        if(s3d){
            //3D标签
            if(options.mode == 0){
                /**@type {Transform} */
                let tf = s3d.transform;
                let btn3d = gui.create3dButton(s3d.alias, PathUrl['dcimPath']+'img/floor-bg.png', tf.size.y*4, tf.size.y);
                switch(options.side){
                    case 'left':
                        btn3d.transform.worldPosition = tf.getLeft(tf.size.x/2 + btn3d.transform.size.x/2);
                        btn3d.transform.moveY(tf.size.y/2);
                        break;
                    case 'right':
                        btn3d.transform.worldPosition = tf.getRight(tf.size.x/2 + btn3d.transform.size.x/2);
                        btn3d.transform.moveY(tf.size.y/2);
                        break;
                    case 'top':
                        btn3d.transform.worldPosition = tf.worldPosition;
                        btn3d.transform.moveY(tf.size.y/2+btn3d.transform.size.y/2);
                        break;
                    case 'bottom':
                        btn3d.transform.worldPosition = tf.worldPosition;
                        btn3d.transform.moveY(-tf.size.y/2-btn3d.transform.size.y/2);
                        break;
                }
                btn3d.uid = btn3d.uuid;
                btn3d.useMeshPicking = true;
                btn3d.isPickable = true;
                //把标签的绝对转向调整至与楼层一致  然后旋转180 使文字朝向前方
                btn3d.transform.worldRotation = s3d.transform.worldRotation;
                btn3d.transform.rotateY(180);
                btn3d.action.mouseEnterAction=()=>{CursorHelper.SetStyle('pointer')};
                btn3d.action.mouseExitAction=()=>{CursorHelper.SetStyle('default')};
                tag = btn3d;
            }
            else if(options.mode ==1)//2D标签
            {
                let i3d = new IconObject3d(PathUrl['dcimPath']+'img/bg.png');
                let style = i3d.style;
                style.width = '120px';
                style.height = '40px';
                style.text = s3d.alias;
                style.fontWeight = '700';
                //把ui边框去掉
                style.border = 0
                i3d.transform.worldPosition = s3d.transform.worldPosition;
                i3d.action.mouseEnterAction=()=>{CursorHelper.SetStyle('pointer')};
                i3d.action.mouseExitAction=()=>{CursorHelper.SetStyle('default')};
                tag = i3d;
            }
            if(tag){
                //把楼层标签添加到上级空间  到达楼层后无需再显示标签  无意义
                //const parent3d = s3d.getParentSpace3d();
                //if(parent3d)parent3d.addChild(tag);
            }
        }
        return tag;
    }

 
}