function ModelLoader(layer3D) { this.parameter = layer3D.layer.parameter; this.glassBoxMeshes = layer3D.collectMeshes.glassBoxMeshes; this.collidableMeshes=layer3D.collectMeshes.collidableMeshes; this.scene = layer3D.scene3D.scene; this.engine = layer3D.scene3D.engine; this.furnitureScal=0.2; this.currentPhotoMesh=null; }; //添加画,图 ModelLoader.prototype.showPicture=function(src) { var plan = BABYLON.Mesh.CreatePlane("picture-"+src, 1, this.scene); plan.scaling.x=50; plan.scaling.y=40; plan.floor=layer.selectFloor; plan.position=new BABYLON.Vector3(0, (plan.floor-1)*this.parameter.wallHeight, 0); var material = new BABYLON.StandardMaterial("planmaterial", this.scene); material.diffuseTexture = new BABYLON.Texture(this.wallpicture_pre+src, this.scene); material.bumpTexture = new BABYLON.Texture("images/floor1.png", this.scene); plan.material=material; plan.rotation.x=Math.PI/2; this.collidableMeshes.push(plan); }; //添加镜框 ModelLoader.prototype.showPhoFrame=function(src) { BABYLON.SceneLoader.ImportMesh("", "images/3d/", src, this.scene, function (newMeshes) { newMeshes[0].scaling=new BABYLON.Vector3(this.furnitureScal,this.furnitureScal,this.furnitureScal); newMeshes[0].computeWorldMatrix(true); newMeshes[0].refreshBoundingInfo(); newMeshes[0].position=new BABYLON.Vector3(0,this.parameter.softDecorationY,0); //newMeshes[0].name="pho-"+src; newMeshes[0].thice=Math.abs(newMeshes[0]._boundingInfo.boundingBox.maximumWorld.z-newMeshes[0]._boundingInfo.boundingBox.minimumWorld.z); newMeshes[0].firstHeigh=Math.abs(newMeshes[0]._boundingInfo.boundingBox.maximumWorld.y-newMeshes[0]._boundingInfo.boundingBox.minimumWorld.y); this.currentPhotoMesh=newMeshes[0]; this.currentPhotoMesh.name="photo"; this.currentPhotoMesh.height=newMeshes[0].firstHeigh; this.currentPhotoMesh.length=Math.abs(newMeshes[0]._boundingInfo.boundingBox.maximumWorld.x-newMeshes[0]._boundingInfo.boundingBox.minimumWorld.x); this.currentPhotoMesh.visibility=0; document.getElementById("container3d").style.cursor="url('images/brush.ico'),auto"; for(var i=0;ithis.currentPhotoMesh._boundingInfo.boundingBox.minimumWorld.z) { this.currentPhotoMesh.frontindex=i; break; } } this.engine.hideLoadingUI(); }.bind(this)); }; //初始化时,会有一些三维模型 ModelLoader.prototype.showProductfirst=function(src,position,rotation) { BABYLON.SceneLoader.ImportMesh("", "images/3d/", src, this.scene, function (newMeshes) { var mesh; if(newMeshes.length>1) { mesh=BABYLON.Mesh.MergeMeshes(newMeshes); } else { mesh=newMeshes[0]; } var name=src.replace(".babylon",""); mesh.scaling=new BABYLON.Vector3(layer.parameter.testModelData[name],layer.parameter.testModelData[name],layer.parameter.testModelData[name]); mesh.position=position; if(layer.parameter.cabinet.indexOf(name+",")>-1) { var glassMesh = BABYLON.Mesh.CreateBox("box", 1, this.scene); glassMesh.scaling.x=Math.abs(mesh._boundingInfo.maximum.x-mesh._boundingInfo.minimum.x)*mesh.scaling.x-5; glassMesh.scaling.y=80; glassMesh.scaling.z=Math.abs(mesh._boundingInfo.maximum.z-mesh._boundingInfo.minimum.z)*mesh.scaling.z/1.2; glassMesh.position.x=position.x; glassMesh.position.y=Math.abs(mesh._boundingInfo.maximum.y-mesh._boundingInfo.minimum.y)*mesh.scaling.y-40; glassMesh.position.z=position.z-2; glassMesh.visibility = 0.3; glassMesh.name="mirror"; this.glassBoxMeshes.push(glassMesh); } for(var i=0;i21) { this.engine.hideLoadingUI(); initMesh=0; } mesh.floor=layer.selectFloor; mesh.position.y+=(mesh.floor-1)*this.parameter.wallHeight; this.collidableMeshes.push(mesh); }.bind(this)); return this.collidableMeshes[this.collidableMeshes.length-1]; }; //加载三维模型 ModelLoader.prototype.showProduct=function(src) { this.engine.displayLoadingUI(); this.engine.loadingUIText = "正在加载家具,请稍等!"; BABYLON.SceneLoader.ImportMesh("", "images/3d/", src, this.scene, function (newMeshes) { var mesh; if(newMeshes.length>1) { mesh=BABYLON.Mesh.MergeMeshes(newMeshes); } else { mesh=newMeshes[0]; } var name=src.replace(".babylon",""); mesh.scaling=new BABYLON.Vector3(layer.parameter.testModelData[name],layer.parameter.testModelData[name],layer.parameter.testModelData[name]); mesh.name=src; for(var i=0;i