工作日志

代码涉及了模型位置的判断与计算,模型改用自创的模型数据,去掉代码中的全部计算,如果以后能用到还可以在这里看,保存在这里。

 * 墙柱
 */
var dxoRoomStruct = function (opt) {
    dxoObject3D.call(this, opt);

    this.name = '墙柱' + this.id;

    this.meta.type = dxsConst.meta.type.dxoRoomStruct;
    this.meta.recvtype = dxsConst.meta.recvtype.wall;
    // var material = new THREE.MeshLambertMaterial({color: "#cccccc"});
    // var columnMeshMaterial = new THREE.MeshLambertMaterial({color: "#cccccc"});
    // var platformMaterial = new THREE.MeshLambertMaterial({color: "#cccccc"});
    this.height=Studio.config.wall.height;
    this.width=Studio.config.wall.width>Studio.config.wall.deep?Studio.config.wall.deep:Studio.config.wall.width;
    //原three.js Mesh创建,后使用公司自建模型
    // var geometry = new THREE.BoxGeometry(1, 1 , 1);
    // var crossbeamGeometry = new THREE.BoxGeometry(1, 1, 1);
    // var platformGeometry = new THREE.BoxGeometry(1,1,1);
    // this.columnMesh = new THREE.Mesh(geometry, material);
    // this.crossbeamMesh = new THREE.Mesh(crossbeamGeometry, columnMeshMaterial);
    // this.platformMesh = new THREE.Mesh(platformGeometry, platformMaterial);
};

dxoRoomStruct.prototype = Object.assign(Object.create(dxoObject3D.prototype), {

    constructor: dxoRoomStruct,

    doAddModel: function (g, opt) {
        var intersectsModel;
        switch (opt.subtype) {
            case dxsConst.meta.subtype.column:

                //立柱
                Studio.input.Raycaster.setFromCamera(Studio.input.mouse.posWorld, Studio.view.current.camera);
                intersectsModel = Studio.input.Raycaster.intersectObjects(Studio.scene.getCustomList(["dxoFloor"]), true);
                if (intersectsModel.length > 0) {
                    this.columnMesh = new dxoDesignBoard();
                    console.log(intersectsModel[0].face.normal);
                    // var pillar = new dxoRoomStruct();
                    this.meta.subtype = opt.subtype;
                    this.columnMesh.setSize(0.5,0.5,this.height);
                    this.columnMesh.position.x = intersectsModel[0].point.x;
                    this.columnMesh.position.y = intersectsModel[0].point.y+this.height/2;//this.height/2;//geometry值除以2
                    this.columnMesh.position.z = intersectsModel[0].point.z;
                    this.columnMesh.lookAt(this.columnMesh.position.clone().add(intersectsModel[0].face.normal));
                    this.add(this.columnMesh);
                    this.meta.fittype = dxsConst.meta.fittype.floor;
                    Studio.scene.add(this);
                }
                break;
            case dxsConst.meta.subtype.pass:
                //垭口
                break;
            case dxsConst.meta.subtype.beam:
                //横梁
                Studio.input.Raycaster.setFromCamera(Studio.input.mouse.posWorld, Studio.view.current.camera);
                intersectsModel = Studio.input.Raycaster.intersectObjects(Studio.scene.getCustomList(['dxoWall']), true);
                if (intersectsModel.length > 0) {
                    this.crossbeamMesh = new dxoDesignBoard();
                    console.log(intersectsModel[0].face.normal);
                    this.meta.subtype = opt.subtype;
                    this.crossbeamMesh.setSize(0.5,0.5,this.width);
                    if(intersectsModel[0].face.normal.x>0){
                        this.crossbeamMesh.position.x = intersectsModel[0].point.x+this.width/2;//+geometry x值除以2
                    }else if(intersectsModel[0].face.normal.x<0){
                        this.crossbeamMesh.position.x = intersectsModel[0].point.x-this.width/2;
                    }else {
                        this.crossbeamMesh.position.x = intersectsModel[0].point.x;//+geometry x值除以2
                    }
                    this.crossbeamMesh.position.y = this.height-this.crossbeamMesh.scale.y/2;
                    if(intersectsModel[0].face.normal.z>0){
                        this.crossbeamMesh.position.z = intersectsModel[0].point.z+this.width/2;
                    }else if(intersectsModel[0].face.normal.z<0){
                        this.crossbeamMesh.position.z = intersectsModel[0].point.z-this.width/2;
                    }else {
                        this.crossbeamMesh.position.z = intersectsModel[0].point.z;
                    }

                    this.crossbeamMesh.lookAt(this.crossbeamMesh.position.clone().add(intersectsModel[0].face.normal));
                    this.add(this.crossbeamMesh);
                    this.meta.fittype = dxsConst.meta.fittype.ceiling;
                    Studio.scene.add(this);
                }
                break;
            case dxsConst.meta.subtype.platform:
                this.platformMesh = new dxoDesignBoard();
                //地台
                Studio.input.Raycaster.setFromCamera(Studio.input.mouse.posWorld, Studio.view.current.camera);
                intersectsModel = Studio.input.Raycaster.intersectObjects(Studio.scene.getCustomList(['dxoFloor']), true);
                if (intersectsModel.length > 0) {
                    console.log(intersectsModel[0]);
                    // var pillar = new dxoRoomStruct();
                    this.meta.subtype = opt.subtype;
                    this.columnMesh.setSize(0.5,0.5,0.5);
                    this.platformMesh.position.x = intersectsModel[0].point.x;
                    this.platformMesh.position.y = intersectsModel[0].point.y;//geometry值除以2
                    this.platformMesh.position.z = intersectsModel[0].point.z;
                    this.platformMesh.lookAt(this.platformMesh.position.clone().add(intersectsModel[0].face.normal));
                    this.add(this.platformMesh);
                    this.meta.fittype = dxsConst.meta.fittype.floor;
                    Studio.scene.add(this);

                }
                break;
            default:
                break;
        }
    }

});
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值