Commit 6d038320 authored by 王晓旭's avatar 王晓旭

根据宣汉项目修改了一下灯光和缩放

parent 3b1848c9
......@@ -9,7 +9,7 @@ VUE_APP_BASE_API =127.0.0.1:18222/m
VUE_APP_PORTAL_URL = http://192.168.0.98:11072
# 站点请求地址
VUE_APP_SITETREE_URL = http://192.168.0.98:11078/base/site/siteTree
VUE_APP_SITETREE_URL = http://192.168.0.98:11091/m/basics_api/base/site/siteTree
# 系统名称
VUE_APP_sysName = "设备物联网"
......@@ -283,9 +283,9 @@ export default {
directionalLight: "#0xffc288", //点光源
intensity: 1, //灯光强度
visible: true, //是否可见
castShadow: true,
castShadow: true,//是否阴影
exponent: 30,
target: "plane",
target: "plane",//距原点距离
debug: false,
};
......@@ -334,11 +334,13 @@ export default {
.name("z");
},
_initTree() {
// 把模型放到透视相机中设置
scene = new THREE.Scene();
// alert(this.$el.offsetWidth)
// alert(this.$el.offsetHeight)
let screenW = this.$el.offsetWidth;
let screenH = this.$el.offsetHeight;
// 设置透视相机
camera = new THREE.PerspectiveCamera(4, screenW / screenH, 0.01, 20000);
this._initCamera();
camera.lookAt(scene.position);
......@@ -370,6 +372,7 @@ export default {
}
this.animation();
},
// 动画
animation() {
// TWEEN.update()
requestAnimationFrame(this.animation);
......@@ -390,6 +393,7 @@ export default {
// renderer.render( scene, camera );
// labelRenderer.render( scene, camera );
},
// 样式渲染
css2renderer() {
let screenW = this.$el.offsetWidth;
let screenH = this.$el.offsetHeight;
......@@ -404,12 +408,14 @@ export default {
labelRenderer.domElement.style.top = 0;
this.$refs.three.appendChild(labelRenderer.domElement);
},
// 将渲染好的样式插入节点中
css2controls() {
this.css2renderer();
controls = new OrbitControls(camera, labelRenderer.domElement);
var counter = document.getElementById("counter");
counter.appendChild(renderer.domElement);
},
// 设置灯光
_Light() {
ambientLight = new THREE.AmbientLight(0xffffff, 0.2);
ambientLight.position.set(0, 0, 0);
......@@ -418,11 +424,14 @@ export default {
directionalLight.castShadow = true;
directionalLight.position.set(5, 10, 7.5);
scene.add(directionalLight);
console.log('设置灯光',directionalLight,scene);
// SpotLight = new THREE.SpotLight(0xffffff,1);
// SpotLight.castShadow = true;
// SpotLight.position.set( 385.522, 1132.217, 1825.427 );
// scene.add(SpotLight)
},
// 渲染每一层楼层图
_3Dloder() {
let _this = this;
let dracoLoader=new DRACOLoader();
......@@ -464,8 +473,8 @@ export default {
// console.log(obj,'@@@@@@@');
// const children = obj.scene.children[0].children;
const children = obj.scene.children;
// const positionY = (iterator - 1.7) * 200;
const positionY = (iterator - 1.7) * 50;
const positionY = (iterator - 1.7) * 100;
// const positionY = (iterator - 1.7) * 20;
children.forEach((element) => {
let objname = element.name;
console.log('objname',objname,iterator);
......@@ -502,6 +511,7 @@ export default {
},
obj: obj.scene,
};
scene.scale.set(0.2,0.2,0.2)
scene.add(obj.scene); //返回的组对象插入场景中
_this.isloading = false;
});
......@@ -581,6 +591,7 @@ export default {
//返回选中的对象
return intersects;
},
// 点击模型
clickmodel(event) {
let intersects = this.getIntersects(event);
// 获取选中最近的 Mesh 对象
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment