Merge branch 'master' into master

This commit is contained in:
zhangXQ 2021-02-28 11:41:54 +08:00
commit d625ca61a5
14 changed files with 56 additions and 10 deletions

3
.gitattributes vendored Normal file
View File

@ -0,0 +1,3 @@
*.exe filter=lfs diff=lfs merge=lfs -text
*.dll filter=lfs diff=lfs merge=lfs -text
*.pdb filter=lfs diff=lfs merge=lfs -text

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
20210129/demo - wpf/RenderApp.exe (Stored with Git LFS) Normal file

Binary file not shown.

BIN
20210129/demo - wpf/clrcompression.dll (Stored with Git LFS) Normal file

Binary file not shown.

BIN
20210129/demo - wpf/clrjit.dll (Stored with Git LFS) Normal file

Binary file not shown.

BIN
20210129/demo - wpf/coreclr.dll (Stored with Git LFS) Normal file

Binary file not shown.

BIN
20210129/demo - wpf/mscordaccore.dll (Stored with Git LFS) Normal file

Binary file not shown.

BIN
20210129/demo - wpf/vcruntime140_cor3.dll (Stored with Git LFS) Normal file

Binary file not shown.

BIN
20210129/demo - wpf/wpfgfx_cor3.dll (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -10,5 +10,7 @@
5. 运行wamp程序浏览器输入网址[http://localhost/demo/index.html](http://localhost/demo/index.html)
6. 多个网格组成的构件可以将构件的mesh值改为数组形式里面放入多个网格位置索引
# Q&A记录

View File

@ -20,7 +20,7 @@ BIMLoader = function(json)
var scene = new THREE.Scene();
json.instances.forEach(element => {
var object = ParseInstance(element, meshes[element.mesh]);
var object = ParseInstance(element, meshes, element.mesh);
scene.add(object);
});
@ -55,7 +55,7 @@ BIMLoader = function(json)
return geometry;
}
function ParseInstance(instanceJson, mesh)
function ParseInstance(instanceJson, meshes, index)
{
var obj = new THREE.Object3D();
@ -77,13 +77,26 @@ BIMLoader = function(json)
if(instanceJson.info)
obj.userData = instanceJson.info;
// 边框
var edges = new THREE.EdgesGeometry(mesh.geometry);
var line = new THREE.LineSegments(edges, new THREE.LineBasicMaterial({color: 0xff0000}));
obj.add(mesh);
obj.add(line);
if(Array.isArray(index))
{
index.forEach(element => {
PutMesh(meshes[element], obj);
});
}
else
{
PutMesh(meshes[index], obj);
}
return obj;
}
function PutMesh(mesh, obj)
{
var edges = new THREE.EdgesGeometry(mesh.geometry);
var line = new THREE.LineSegments(edges, new THREE.LineBasicMaterial({color: 0xff0000}));
obj.add(mesh);
obj.add(line);
}
}

View File

@ -28,8 +28,15 @@ loader.load(
var bimScene = BIMLoader(JSON.parse(data));
var box = new THREE.Box3();
box.expandByObject(bimScene);
box.expandByScalar(10000);
var cameraPos = new THREE.Vector3(box.min.x, box.min.y, box.max.z);
var center = new THREE.Vector3();
box.getCenter(center);
var size = new THREE.Vector3();
box.getSize(size);
var result = size.x > size.y ? size.x : size.y;
result = result > size.z ? result : size.z;
var maxLength = Math.round(result);
var radius = center.distanceTo(new THREE.Vector3(center.x + (maxLength/2), center.y + (maxLength/2), center.z + (maxLength/2)));
var cameraPos = new THREE.Vector3(center.x + radius * Math.cos(Math.PI/18) * Math.cos(Math.PI/4), center.y - radius * Math.cos(Math.PI/18) * Math.sin(Math.PI/4), center.z + radius * Math.sin(Math.PI/18));
camera.position.copy(cameraPos);
controls.target = box.getCenter();
scene.add(bimScene);