|
@@ -53989,11 +53989,12 @@
|
|
|
}
|
|
|
|
|
|
const children = this.children;
|
|
|
+ if(children){
|
|
|
+ for ( let i = 0, l = children.length; i < l; i ++ ) {
|
|
|
|
|
|
- for ( let i = 0, l = children.length; i < l; i ++ ) {
|
|
|
-
|
|
|
- children[ i ].traverse( callback );
|
|
|
+ children[ i ].traverse( callback );
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -54063,6 +54064,93 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
+ };
|
|
|
+
|
|
|
+ function ascSort$1( a, b ) {
|
|
|
+
|
|
|
+ return a.distance - b.distance;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ function intersectObject$1( object, raycaster, intersects, recursive, ignoreUnvisible ) {
|
|
|
+
|
|
|
+ if(ignoreUnvisible && !object.visible)return //add
|
|
|
+
|
|
|
+ if ( object.layers.test( raycaster.layers ) ) {
|
|
|
+
|
|
|
+ object.raycast( raycaster, intersects );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( recursive === true ) {
|
|
|
+
|
|
|
+ const children = object.children;
|
|
|
+
|
|
|
+ for ( let i = 0, l = children.length; i < l; i ++ ) {
|
|
|
+
|
|
|
+ intersectObject$1( children[ i ], raycaster, intersects, true, ignoreUnvisible);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ Raycaster.prototype.intersectObject = function ( object, recursive, optionalTarget, ignoreUnvisible ) {
|
|
|
+
|
|
|
+ const intersects = optionalTarget || [];
|
|
|
+
|
|
|
+ intersectObject$1( object, this, intersects, recursive, ignoreUnvisible );
|
|
|
+
|
|
|
+ intersects.sort( ascSort$1 );
|
|
|
+
|
|
|
+ return intersects;
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ Raycaster.prototype.intersectObjects = function ( objects, recursive, optionalTarget, ignoreUnvisible ) {//add ignoreUnvisible 跳过不可见
|
|
|
+
|
|
|
+ const intersects = optionalTarget || [];
|
|
|
+
|
|
|
+ if ( Array.isArray( objects ) === false ) {
|
|
|
+
|
|
|
+ console.warn( 'THREE.Raycaster.intersectObjects: objects is not an Array.' );
|
|
|
+ return intersects;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ for ( let i = 0, l = objects.length; i < l; i ++ ) {
|
|
|
+
|
|
|
+ intersectObject$1( objects[ i ], this, intersects, recursive, ignoreUnvisible );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ intersects.sort( ascSort$1 );
|
|
|
+
|
|
|
+ return intersects;
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Object3D.prototype.realVisible = function(){
|
|
|
+ let v = true;
|
|
|
+ let parent = this;
|
|
|
+ let lastParent;
|
|
|
+ while(parent){
|
|
|
+ if(parent.visible === false){
|
|
|
+ v = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ lastParent = parent;
|
|
|
+ parent = parent.parent;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(v && !(lastParent instanceof Scene)){//已被删除
|
|
|
+ v = false;
|
|
|
+ }
|
|
|
+ return v
|
|
|
};
|
|
|
|
|
|
var MathLight = {};
|
|
@@ -59133,7 +59221,7 @@
|
|
|
var reg = new RegExp(f, "g"); //创建正则RegExp对象
|
|
|
return str.replace(reg, e);
|
|
|
}
|
|
|
- ,
|
|
|
+ ,
|
|
|
downloadFile : function(data, filename, cb) {
|
|
|
var save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
|
|
|
save_link.href = data;
|
|
@@ -59143,6 +59231,29 @@
|
|
|
save_link.dispatchEvent(event);
|
|
|
cb && cb();
|
|
|
},
|
|
|
+
|
|
|
+ dealURL(url){
|
|
|
+ return this.replaceAll(url, "\\+", "%2B");// 浏览器似乎不支持访问带+的地址
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ getNameFromURL(url){
|
|
|
+ let get = (e)=>{
|
|
|
+ return e.split('/').pop()
|
|
|
+ };
|
|
|
+ if(url instanceof Array){
|
|
|
+ return url.map(e=>get(e))
|
|
|
+ }
|
|
|
+ return get(url)
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //---------------------------
|
|
|
+
|
|
|
|
|
|
intervalTool:{ //延时update,防止卡顿
|
|
|
list:[],
|
|
@@ -59213,8 +59324,8 @@
|
|
|
}
|
|
|
},
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
getBestCount : function(name, minCount=1,maxCount=6, durBound1 = 1.2, durBound2 = 10, ifLog){
|
|
|
|
|
|
|
|
@@ -69828,8 +69939,9 @@ void main()
|
|
|
|
|
|
Utils.getIntersect = function (camera, meshes, pointer, raycaster) {
|
|
|
//获取鼠标和meshes交点
|
|
|
- camera.updateMatrixWorld();
|
|
|
+
|
|
|
if(!raycaster){//getMouseIntersect
|
|
|
+ camera.updateMatrixWorld();
|
|
|
raycaster = new Raycaster();
|
|
|
var origin = new Vector3(pointer.x, pointer.y, -1).unproject(camera),
|
|
|
end = new Vector3(pointer.x, pointer.y, 1).unproject(camera);
|
|
@@ -69838,7 +69950,7 @@ void main()
|
|
|
}
|
|
|
|
|
|
meshes.forEach(e=>{
|
|
|
- raycaster.layers.enable(math.getBaseLog(e.layers.mask,2));
|
|
|
+ raycaster.layers.enable(math.getBaseLog(2,e.layers.mask));
|
|
|
});
|
|
|
var n = raycaster.intersectObjects(meshes);
|
|
|
if (0 === n.length) return null
|
|
@@ -72537,7 +72649,7 @@ void main()
|
|
|
loadPointsWhenUnfocus:true, //页面unfocus时也仍在加载点云 */
|
|
|
|
|
|
//initialShowPano:true
|
|
|
- drawEntityData: false,
|
|
|
+ drawEntityData: false, //包括marker、线
|
|
|
|
|
|
zoomFromPointert:{//定点缩放(包括点云模式、全景模式、地图)
|
|
|
whenPanos:true,
|
|
@@ -91309,7 +91421,7 @@ void main()
|
|
|
}
|
|
|
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
return {
|
|
|
camera, viewport, pointer
|
|
@@ -91898,7 +92010,7 @@ void main()
|
|
|
//this.hoverViewport.beforeRender && this.hoverViewport.beforeRender()
|
|
|
|
|
|
viewer.dispatchEvent( {type:'raycaster', viewport: this.hoverViewport});//add
|
|
|
- let intersections = raycaster.intersectObjects(interactables.filter(o => o.visible), true); //原本是false 检测不到children
|
|
|
+ let intersections = raycaster.intersectObjects(interactables.filter(o => o.visible), true, null, true); //原本是false 检测不到children
|
|
|
|
|
|
let intersectionsCopy = intersections.slice();
|
|
|
|
|
@@ -98559,24 +98671,24 @@ void main()
|
|
|
if (!pano) {
|
|
|
console.error("Player.checkAndWaitForTiledPanoLoad() -> Cannot load texture for null pano.");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var vectorForward = this.getTileDirection();
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
if (!pano.isLoaded(basePanoSize)) {
|
|
|
iswait && viewer.waitForLoad(pano, function() {//发送loading
|
|
|
return pano.isLoaded(basePanoSize)
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
|
|
|
-
|
|
|
+
|
|
|
/* var fov = {//test for direction 预加载的边缘有一丢丢不准确,尤其在相机倾斜时(4dkk也是)。
|
|
|
hFov: cameraLight.getHFOVForCamera(viewer.scene.getActiveCamera() ),
|
|
|
vFov: viewer.scene.getActiveCamera().fov
|
|
|
}//原先是null,不要求方向 */
|
|
|
var fov = null; //若不为null的话,因为可能可见范围的tile下载过了从而无法触发下载,然后得不到下载成功的消息,怎么办
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
pano.loadTiledPano(/* 1024 */ basePanoSize , vectorForward, fov, isclear, l, null).done(function(e, t) {
|
|
|
callback1 && callback1(e, t);
|
|
@@ -98590,15 +98702,15 @@ void main()
|
|
|
.bind(this));
|
|
|
|
|
|
return !0;
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
fitPanoTowardPoint(o){ //寻找最适合的点位
|
|
@@ -98622,9 +98734,9 @@ void main()
|
|
|
//if(o.floor)require.push(Panorama.filters.atFloor(o.floor))
|
|
|
let depthTiming = Potree.timeCollect.depthSampler.median;
|
|
|
let checkIntersect = o.checkIntersect;// && depthTiming < 0.3
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if(o.boundSphere){//只接受boundSphere
|
|
|
let aspect = 1;//size.x / size.y
|
|
|
let dis;
|
|
@@ -98633,9 +98745,8 @@ void main()
|
|
|
}else {
|
|
|
let hfov = cameraLight.getHFOVForCamera(camera , true );
|
|
|
dis = /* size.x */ o.boundSphere.radius /* / 2 */ / (hfov / 2);
|
|
|
- }
|
|
|
-
|
|
|
- bestDistance = dis;//*0.8
|
|
|
+ }
|
|
|
+ bestDistance = dis;//*0.8
|
|
|
|
|
|
}
|
|
|
let disSquareMap = new Map();
|
|
@@ -98672,23 +98783,25 @@ void main()
|
|
|
if(result1){
|
|
|
g = Common$1.sortByScore(result1, [], [(e)=>{//避免遮挡
|
|
|
let pano = e.item;
|
|
|
- let disSquare = disSquareMap.get(pano), score = 0;
|
|
|
+ let disSquare = disSquareMap.get(pano), score = 0, log = 'score: '+pano.id;
|
|
|
if(pano.depthTex && checkIntersect){
|
|
|
- let intersect = viewer.ifPointBlockedByIntersect(target, pano.id,true); //viewer.inputHandler.ifBlockedByIntersect({pos3d:target, margin:0.1, cameraPos:pano})
|
|
|
+ let intersect = !!viewer.ifPointBlockedByIntersect(target, pano.id,true); //viewer.inputHandler.ifBlockedByIntersect({pos3d:target, margin:0.1, cameraPos:pano})
|
|
|
if(intersect){
|
|
|
score = 0;
|
|
|
}else {
|
|
|
- score = 1000;
|
|
|
+ score = 600;
|
|
|
}
|
|
|
- //console.log('intersect score ', pano.id, score)
|
|
|
+ log += (',intersect: '+intersect );
|
|
|
}else {
|
|
|
- score = 900; //没加载好的话,不管了 , 几乎当做无遮挡,否则容易到不了最近点
|
|
|
+ score = 500; //没加载好的话,不管了 , 几乎当做无遮挡,否则容易到不了最近点
|
|
|
+ log += ',no checkIntersect,';
|
|
|
}
|
|
|
|
|
|
if(atFloor && atFloor.panos.includes(pano)){//如果不在任何一楼呢?
|
|
|
- score += 1000;
|
|
|
+ score += 600;
|
|
|
+ log += ', atFloor,';
|
|
|
}
|
|
|
-
|
|
|
+ console.log(log);
|
|
|
|
|
|
return score + e.score
|
|
|
}]);
|
|
@@ -99713,12 +99826,12 @@ void main()
|
|
|
|
|
|
viewer.addTimeMark('updateCube','end');
|
|
|
|
|
|
-
|
|
|
+
|
|
|
/*
|
|
|
关于卡顿:
|
|
|
即使使用cube,若scale设置为只容纳两个pano,也会卡顿。但也是有的卡有的不卡。
|
|
|
若按照原先的复杂geo,一般在平直的街道上行走流畅,经过拐弯或者复杂区域较卡。减小geo复杂度没有什么作用。
|
|
|
-
|
|
|
+
|
|
|
|
|
|
注: 修改skybox,若不准的话,会遮住其他mesh,比如marker。尤其在没有深度贴图时。
|
|
|
|
|
@@ -111184,11 +111297,15 @@ ENDSEC
|
|
|
}
|
|
|
if(this.buildParent)this.dontDragFloorHeight = this.buildParent.dontDragFloorHeight;
|
|
|
|
|
|
+
|
|
|
+ if(this.buildType != 'hole'){
|
|
|
+ this.box = this.createBox(); //无论是否edit都绘制的原因:为了将在外的点移到在内,需要用mesh来获取intersect
|
|
|
+ this.add(this.box);
|
|
|
+ this.box.visible = !!this.ifDraw;
|
|
|
+ }
|
|
|
+
|
|
|
if(this.ifDraw){ //只存储空间模型信息,不绘制
|
|
|
- if(this.buildType != 'hole'){
|
|
|
- this.box = this.createBox();
|
|
|
- this.add(this.box);
|
|
|
- }
|
|
|
+
|
|
|
{
|
|
|
this.lineMesh = LineDraw.createLine([],{color: color$2});
|
|
|
this.lineMesh.name = 'buildingLines';
|
|
@@ -129017,6 +129134,17 @@ ENDSEC
|
|
|
PERFORMANCE OF THIS SOFTWARE.
|
|
|
***************************************************************************** */
|
|
|
|
|
|
+
|
|
|
+ window.visiVertexCount = 0;
|
|
|
+ window.visiGeoCount = 0;
|
|
|
+ const maxVertexVisi = 5e6;
|
|
|
+ const maxTexVisi = 500;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -137461,6 +137589,7 @@ ENDSEC
|
|
|
|
|
|
function createBox(box, transform, result) {
|
|
|
const center = new Vector3$1(box[0], box[1], box[2]);
|
|
|
+ result && (result.oriCenter = center);//add
|
|
|
transform.transform(center, center);
|
|
|
let origin = [];
|
|
|
|
|
@@ -138776,6 +138905,10 @@ ENDSEC
|
|
|
const TILES_LOAD_FAILED = 'Failed Tile Loads';
|
|
|
const POINTS_COUNT = 'Points';
|
|
|
const TILES_GPU_MEMORY = 'Tile Memory Use';
|
|
|
+
|
|
|
+
|
|
|
+ let tilesetSid = 0;//add
|
|
|
+
|
|
|
class Tileset3D extends EventDispatcher{//xzw add EventDispatcher
|
|
|
constructor(json, options) {
|
|
|
super();
|
|
@@ -138962,7 +139095,9 @@ ENDSEC
|
|
|
|
|
|
getTileUrl(tilePath) {
|
|
|
const isDataUrl = tilePath.startsWith('data:');
|
|
|
-
|
|
|
+
|
|
|
+ tilePath = Potree.Common.dealURL(tilePath); //add 去除'+'
|
|
|
+
|
|
|
if (isDataUrl) {
|
|
|
return tilePath;
|
|
|
}
|
|
@@ -139180,7 +139315,8 @@ ENDSEC
|
|
|
}
|
|
|
|
|
|
_initializeTileHeaders(tilesetJson, parentTileHeader) {
|
|
|
- const rootTile = new TileHeader(this, tilesetJson.root, parentTileHeader);
|
|
|
+
|
|
|
+ const rootTile = new TileHeader(this, tilesetJson.root, parentTileHeader, parentTileHeader == void 0 && 'root_'+tilesetSid++);
|
|
|
|
|
|
if (parentTileHeader) {
|
|
|
parentTileHeader.children.push(rootTile);
|
|
@@ -145927,8 +146063,12 @@ ENDSEC
|
|
|
const { boundingVolume } = tile;
|
|
|
let redColor = 0;
|
|
|
if (tile.content) {
|
|
|
- redColor = Math.min(tile.content.byteLength / 500000, 1.0);
|
|
|
- }
|
|
|
+ //redColor = Math.min((tile.content.byteLength != void 0 ? tile.content.byteLength : 0) / 500000, 1.0);
|
|
|
+ redColor = Math.min( tile.depth / 10 , 1.0); //改
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
const boxColor = new Color(redColor, 1.0, 0.0);
|
|
|
const boxGeometry = new BoxGeometry(1, 1, 1);
|
|
|
const boxTransform = new Matrix4();
|
|
@@ -145938,10 +146078,34 @@ ENDSEC
|
|
|
else if (boundingVolume.radius) {
|
|
|
boxGeometry.scale(boundingVolume.radius * 2, boundingVolume.radius * 2, boundingVolume.radius * 2);
|
|
|
}
|
|
|
+
|
|
|
+ boxTransform.premultiply((new Matrix4()).setPosition(...boundingVolume.center)); //add
|
|
|
+
|
|
|
+
|
|
|
boxGeometry.applyMatrix4(boxTransform);
|
|
|
+
|
|
|
+
|
|
|
const edges = new EdgesGeometry(boxGeometry);
|
|
|
- const dispPlane = new LineSegments(edges, new LineBasicMaterial({ color: boxColor }));
|
|
|
- dispPlane.position.copy(new Vector3(...boundingVolume.center));
|
|
|
+ const dispPlane = new LineSegments(edges, new LineBasicMaterial({ color: boxColor, transparent:true }));
|
|
|
+ //dispPlane.position.copy(new Vector3$1(...boundingVolume.center));
|
|
|
+ dispPlane.matrixAutoUpdate = false; //add
|
|
|
+
|
|
|
+
|
|
|
+ /* if(tile.content.byteLength == void 0){
|
|
|
+ let oldUpdate = dispPlane.updateMatrixWorld.bind(dispPlane)
|
|
|
+ dispPlane.updateMatrixWorld = (a,b)=>{
|
|
|
+ oldUpdate(a,b)
|
|
|
+ }
|
|
|
+
|
|
|
+ let oldU = dispPlane.updateMatrix.bind(dispPlane)
|
|
|
+ dispPlane.updateMatrix = (a,b)=>{
|
|
|
+ oldU(a,b)
|
|
|
+ }
|
|
|
+
|
|
|
+ } */
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
return dispPlane;
|
|
|
}
|
|
|
function getMatrix4FromHalfAxes(halfAxes) {
|
|
@@ -146263,8 +146427,11 @@ ENDSEC
|
|
|
const unloadQueue = [];
|
|
|
const root = new Group();
|
|
|
const tileBoxes = new Group();
|
|
|
+ tileBoxes.matrixAutoUpdate = false;//add
|
|
|
if (!options.debug) {
|
|
|
tileBoxes.visible = false;
|
|
|
+ }else {
|
|
|
+ options.parent.add(tileBoxes); //add
|
|
|
}
|
|
|
const pointcloudUniforms = {
|
|
|
pointSize: { type: 'f', value: options.pointSize },
|
|
@@ -146334,7 +146501,7 @@ ENDSEC
|
|
|
if (options.debug) {
|
|
|
const box = loadersBoundingBoxToMesh(tile);
|
|
|
tileBoxes.add(box);
|
|
|
- boxMap[tile.id] = box;
|
|
|
+ boxMap[tile.id] = box;
|
|
|
}
|
|
|
//xzw :
|
|
|
tileset.dispatchEvent({type:'tileLoaded',tileContent}); //每一个tile加载完要更改透明度等
|
|
@@ -146493,14 +146660,32 @@ ENDSEC
|
|
|
if (!renderMap[tile.id]) {
|
|
|
console.error('TILE SELECTED BUT NOT LOADED!!', tile.id);
|
|
|
}
|
|
|
- else {
|
|
|
- // Make sure it's visible
|
|
|
- renderMap[tile.id].visible = true;
|
|
|
+ else {
|
|
|
+
|
|
|
+ // Make sure it's visible
|
|
|
+ if(!renderMap[tile.id].visible){
|
|
|
+ if(visiVertexCount<maxVertexVisi){
|
|
|
+ renderMap[tile.id].visible = true;
|
|
|
+ visiVertexCount += renderMap[tile.id].vertexCount; //xzw add
|
|
|
+ options.debug && (boxMap[tile.id].material.opacity = 1);
|
|
|
+ }else {
|
|
|
+ console.log('超出', visiVertexCount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /* if(!renderMap[tile.id].realVisible()){
|
|
|
+ console.error('!realVisible')
|
|
|
+ } */
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
if (renderMap[tile.id]) {
|
|
|
- renderMap[tile.id].visible = false;
|
|
|
+ if(renderMap[tile.id].visible){
|
|
|
+ renderMap[tile.id].visible = false;
|
|
|
+ options.debug && (boxMap[tile.id].material.opacity = 0.1);
|
|
|
+
|
|
|
+ visiVertexCount -= renderMap[tile.id].vertexCount; //xzw add
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -146508,6 +146693,7 @@ ENDSEC
|
|
|
while (unloadQueue.length > 0) {
|
|
|
const tile = unloadQueue.pop();
|
|
|
if (renderMap[tile.id] && tile.contentState == TILE_CONTENT_STATE.UNLOADED) {
|
|
|
+ //console.log('removevisi', renderMap[tile.id].visible) 如果是true,visiVertexCount要减
|
|
|
root.remove(renderMap[tile.id]);
|
|
|
disposeNode(renderMap[tile.id]);
|
|
|
delete renderMap[tile.id];
|
|
@@ -146622,25 +146808,36 @@ ENDSEC
|
|
|
pointcloudUniforms.rootNormal.value.copy(new Vector3(0, 0, 1).applyMatrix4(lastRootTransform).normalize());
|
|
|
rootTransformInverse.copy(lastRootTransform).invert();
|
|
|
if (options.debug) {
|
|
|
- boxMap[tileset.root.id].matrixWorld.copy(threeMat);
|
|
|
- boxMap[tileset.root.id].applyMatrix4(lastRootTransform);
|
|
|
+ /* console.log('move', tileset.root.id, boxMap[tileset.root.id].matrix.elements, boxMap[tileset.root.id].matrixWorld.elements)
|
|
|
+ boxMap[tileset.root.id].matrix.copy(root.matrixWorld);
|
|
|
+ boxMap[tileset.root.id].matrixWorld.copy(root.matrixWorld); */
|
|
|
+
|
|
|
+
|
|
|
+ //boxMap[tileset.root.id].applyMatrix4(threeMat);
|
|
|
+ tileBoxes.matrix.copy(root.matrixWorld);
|
|
|
+
|
|
|
+ //boxMap[tileset.root.id].matrixWorld.copy(threeMat);
|
|
|
+ //boxMap[tileset.root.id].applyMatrix4(lastRootTransform);//boxMap[tileset.root.id].applyMatrix4(lastRootTransform);
|
|
|
+ //boxMap[tileset.root.id].updateWorldMatrix()
|
|
|
}
|
|
|
}
|
|
|
- if (lastCameraTransform == null) {
|
|
|
- lastCameraTransform = new Matrix4().copy(camera.matrixWorld);
|
|
|
+ if (this.lastCameraTransform == null) {
|
|
|
+ this.lastCameraTransform = new Matrix4().copy(camera.matrixWorld);
|
|
|
}
|
|
|
else {
|
|
|
- const cameraChanged = !camera.matrixWorld.equals(lastCameraTransform) ||
|
|
|
+ const cameraChanged = !camera.matrixWorld.equals(this.lastCameraTransform) ||
|
|
|
!(camera.aspect == lastCameraAspect);
|
|
|
if (cameraChanged) {
|
|
|
timer = 0;
|
|
|
tileset._frameNumber++;
|
|
|
camera.getWorldPosition(lastCameraPosition);
|
|
|
- lastCameraTransform.copy(camera.matrixWorld);
|
|
|
+ this.lastCameraTransform.copy(camera.matrixWorld);
|
|
|
tilesetUpdate(tileset, renderMap, renderer, camera);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }/* else{
|
|
|
+ console.log('11')
|
|
|
+ } */
|
|
|
},
|
|
|
dispose: function () {
|
|
|
disposeFlag = true;
|
|
@@ -146670,13 +146867,14 @@ ENDSEC
|
|
|
}
|
|
|
}
|
|
|
function createGLTFNodes(gltfLoader, tile, unlitMaterial, options, rootTransformInverse) {
|
|
|
+
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
var _a;
|
|
|
const rotateX = new Matrix4().makeRotationAxis(new Vector3(1, 0, 0), Math.PI / 2);
|
|
|
const shouldRotate = ((_a = tile.tileset.asset) === null || _a === void 0 ? void 0 : _a.gltfUpAxis) !== "Z";
|
|
|
// The computed trasnform already contains the root's transform, so we have to invert it
|
|
|
- const contentTransform = new Matrix4().fromArray(tile.computedTransform).premultiply(rootTransformInverse);
|
|
|
+ const contentTransform = new Matrix4().fromArray(tile.computedTransform).premultiply(rootTransformInverse); //xzw 删。原先的会造成移动后tiles错乱
|
|
|
if (shouldRotate) {
|
|
|
contentTransform.multiply(rotateX); // convert from GLTF Y-up to Z-up
|
|
|
}
|
|
@@ -146686,7 +146884,7 @@ ENDSEC
|
|
|
(gltf) => {
|
|
|
const tileContent = gltf.scenes[0];
|
|
|
//tileContent.applyMatrix4(contentTransform);
|
|
|
-
|
|
|
+ tileContent.vertexCount = 0; //xzw add
|
|
|
tileContent.traverse((object) => {
|
|
|
if (object.type == "Mesh") {
|
|
|
const mesh = object;
|
|
@@ -146724,6 +146922,10 @@ ENDSEC
|
|
|
if (options.computeNormals) {
|
|
|
mesh.geometry.computeVertexNormals();
|
|
|
}
|
|
|
+ //xzw add:
|
|
|
+ tileContent.vertexCount += mesh.geometry.attributes.position.count;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
//------------------add on 2023.1.16----zeg
|
|
|
|
|
@@ -146738,6 +146940,8 @@ ENDSEC
|
|
|
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+
|
|
|
resolve(tileContent);
|
|
|
},
|
|
|
(e) => {
|
|
@@ -149812,7 +150016,7 @@ ENDSEC
|
|
|
let ifShelter;
|
|
|
let now = Date.now();
|
|
|
let extraPanoId = panoId != void 0;
|
|
|
-
|
|
|
+ if(!this.shelterCount)return
|
|
|
|
|
|
let history = shelterHistory.find(e=>e.pos3d.equals(pos3d));
|
|
|
let cameraPos = this.mainViewport.view.position.clone();
|
|
@@ -149847,7 +150051,7 @@ ENDSEC
|
|
|
while(old = shelterHistory[0], now - old.lastTime > 1000){//因为不知热点个数,所以需要加上时间限制,超过时间才能删。
|
|
|
if(old == history || shelterHistory.length == minCount)break;
|
|
|
shelterHistory.pop();
|
|
|
- console.log('delete');
|
|
|
+ //console.log('delete')
|
|
|
}
|
|
|
|
|
|
|
|
@@ -149869,20 +150073,20 @@ ENDSEC
|
|
|
ifShelter = !!viewer.inputHandler.ifBlockedByIntersect({pos3d, margin:0.3, useDepthTex:true, pano } );
|
|
|
history.panos[panoId] = ifShelter;
|
|
|
this.shelterCount.byTex ++ ;
|
|
|
- console.log('computeByTex direct');
|
|
|
+ //console.log('computeByTex direct', panoId, ifShelter)
|
|
|
}else {
|
|
|
- console.log('延迟tex' );
|
|
|
+ //console.log('延迟tex' )
|
|
|
history.waitCompute = {panoId, forceGet:extraPanoId };
|
|
|
return useLastResult()
|
|
|
}
|
|
|
}else {
|
|
|
if(/* history.ifShelter == void 0 || */ this.shelterCount.byCloud<this.shelterCount.maxByCloud){//弊端:第一个总是直接计算,后面的都是延后。但无法改进,因是一个个传进来的,无法预测。
|
|
|
- ifShelter = !!viewer.inputHandler.ifBlockedByIntersect({pos3d, margin:0.3 } );
|
|
|
+ ifShelter = !!viewer.inputHandler.ifBlockedByIntersect({pos3d, margin:0.3, pickWindowSize:3} );
|
|
|
history.notAtPano = {cameraPos , ifShelter };
|
|
|
this.shelterCount.byCloud ++ ;
|
|
|
- console.log('computeByCloud direct', pos3d.toArray());
|
|
|
+ //console.log('computeByCloud direct', pos3d.toArray())
|
|
|
}else {
|
|
|
- console.log('延迟cloud' );
|
|
|
+ //console.log('延迟cloud' )
|
|
|
history.waitCompute = {cameraPos};
|
|
|
return useLastResult()
|
|
|
}
|
|
@@ -149940,7 +150144,7 @@ ENDSEC
|
|
|
history.panos[this.images360.currentPano.id] = ifShelter;
|
|
|
history.ifShelter = ifShelter;
|
|
|
delete history.waitCompute;
|
|
|
- console.log('补1', history.pos3d.toArray());
|
|
|
+ //console.log('补1', history.pos3d.toArray())
|
|
|
}else {
|
|
|
waitCloud.push(history);
|
|
|
}
|
|
@@ -149953,7 +150157,7 @@ ENDSEC
|
|
|
|
|
|
let maxCloudCount;
|
|
|
if(byTex < maxTexCount && waitCloud.length){
|
|
|
- maxCloudCount = this.lastFrameChanged ? Common$1.getBestCount('shelterMaxDepthSample', 0, 2, 4, 8 ,true ) : 5;
|
|
|
+ maxCloudCount = this.lastFrameChanged ? Common$1.getBestCount('shelterMaxCloud', 0, 2, 4, 8 /* ,true */ ) : 5;
|
|
|
let waitCloud2 = [];
|
|
|
if(maxCloudCount){
|
|
|
for(let i=0; i<waitCloud.length; i++){
|
|
@@ -149976,11 +150180,12 @@ ENDSEC
|
|
|
if(maxCloudCount){
|
|
|
let list = waitCloud2.map(e=>e.pos3d);
|
|
|
let result = Common$1.batchHandling.getSlice('shelterByCloud', list, {maxUseCount:maxCloudCount,useEquals:true, stopWhenAllUsed:true} ); //iphonex稳定后大概在7-10。
|
|
|
- list.length>0 && console.log('list',list, maxCloudCount);
|
|
|
+ //list.length>0 && console.log('list',list, maxCloudCount)
|
|
|
|
|
|
result.list.forEach(e=>{
|
|
|
- let history = waitCloud2.find(a=>a.pos3d == e);
|
|
|
- let ifShelter = !!viewer.inputHandler.ifBlockedByIntersect({pos3d:history.pos3d, margin:0.3 } );
|
|
|
+ let history = waitCloud2.find(a=>a.pos3d.equals(e));
|
|
|
+
|
|
|
+ let ifShelter = !!viewer.inputHandler.ifBlockedByIntersect({pos3d:history.pos3d, margin:0.3 , pickWindowSize:3} );
|
|
|
|
|
|
if(history.waitCompute.cameraPos){
|
|
|
history.notAtPano = {cameraPos: history.waitCompute.cameraPos , ifShelter };
|
|
@@ -149989,7 +150194,7 @@ ENDSEC
|
|
|
}
|
|
|
history.ifShelter = ifShelter;
|
|
|
byCloud++;
|
|
|
- console.log('补2', history.pos3d.toArray());
|
|
|
+ //console.log('补2', history.pos3d.toArray())
|
|
|
delete history.waitCompute;
|
|
|
});
|
|
|
|
|
@@ -150001,7 +150206,7 @@ ENDSEC
|
|
|
if(byTex || byCloud){
|
|
|
//console.log('shelterComputed',byTex,byCloud, maxTexCount, maxCloudCount)
|
|
|
Common$1.intervalTool.isWaiting('shelterComputed', ()=>{
|
|
|
- console.log('shelterComputed update');
|
|
|
+ //console.log('shelterComputed update')
|
|
|
this.dispatchEvent('shelterComputed');
|
|
|
},340);
|
|
|
}
|
|
@@ -152844,6 +153049,7 @@ ENDSEC
|
|
|
this.mapViewer.moveTo(target.clone(), null, duration);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
if(Potree.settings.displayMode == 'showPointCloud'){
|
|
|
if(o.dontChangePos){
|
|
|
position.copy(cameraPos);
|
|
@@ -152853,20 +153059,40 @@ ENDSEC
|
|
|
if(o.dontLookUp && dir.z<0) dir.z *= -1;
|
|
|
position.copy(target).add(dir.multiplyScalar(dis));
|
|
|
}
|
|
|
- /* if(o.checkIntersect){//识别被点云遮住的话
|
|
|
- let ifShelter
|
|
|
-
|
|
|
- while(1){
|
|
|
- ifShelter = this.inputHandler.ifBlockedByIntersect(target, o.checkMargin, position)
|
|
|
- if(ifShelter){
|
|
|
- if(dis > 0.5){
|
|
|
- dis --
|
|
|
- dir.dot(ifShelter.normal)>0 ? dir.copy(ifShelter.normal).negate() : dir.copy(ifShelter.normal);
|
|
|
- position.copy(target).add(dir.multiplyScalar(dis))
|
|
|
+
|
|
|
+ if(o.sameFloor){//需要在同一楼层
|
|
|
+ let atFloor = this.modules.SiteModel.pointInWhichEntity(target, 'floor');
|
|
|
+ if(atFloor){
|
|
|
+ let camFloor = this.modules.SiteModel.pointInWhichEntity(position, 'floor');
|
|
|
+ if(camFloor != atFloor){
|
|
|
+ let raycaster = new Raycaster();
|
|
|
+ let origin = target;
|
|
|
+ let dir = new Vector3().subVectors( position, target ).normalize();
|
|
|
+ raycaster.set(origin, dir);
|
|
|
+ let intersect = Potree.Utils.getIntersect(null, [atFloor.box], null, raycaster);
|
|
|
+ if(intersect){
|
|
|
+ let dis = MathUtils.clamp(intersect.distance - 0.2, camera.near, intersect.distance);
|
|
|
+ position.addVectors(origin, dir.multiplyScalar(dis));
|
|
|
+ console.log('移动到楼层');
|
|
|
+ }else {
|
|
|
+ console.error('?no intersect?');
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
- } */
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(o.checkIntersect){//识别被点云遮住的话
|
|
|
+ let intersect; //反向查找从target到相机的第一个intersect
|
|
|
+ intersect = this.inputHandler.ifBlockedByIntersect({pos3d:position, margin:0, cameraPos:target} /* {pos3d:target, margin: 0.2, cameraPos:position} */);
|
|
|
+
|
|
|
+ if(intersect){
|
|
|
+ position.copy(intersect.location);
|
|
|
+ console.log('移近');
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}else if(Potree.settings.displayMode == 'showPanos'){
|
|
|
let pano = viewer.images360.fitPanoTowardPoint({
|
|
@@ -153169,15 +153395,15 @@ ENDSEC
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
- this.update(this.clock.getDelta(), timestamp);
|
|
|
+ let deltaTime = this.clock.getDelta();
|
|
|
+ this.update(deltaTime, timestamp);
|
|
|
this.magnifier.render();
|
|
|
this.render();
|
|
|
|
|
|
-
|
|
|
+
|
|
|
this.objs.children.forEach(e=>{
|
|
|
if(e.fileType == '3dTiles'){
|
|
|
- e.runtime.update(this.clock.getDelta(), this.renderer, this.mainViewport.camera);
|
|
|
+ e.runtime.update(deltaTime, this.renderer, this.mainViewport.camera);
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -153537,7 +153763,7 @@ ENDSEC
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ fileInfo.url = Common$1.dealURL(fileInfo.url); //去除'+'
|
|
|
|
|
|
//let fileType = fileInfo.tilesUrl ? '3dTiles' : fileInfo.objurl ? 'obj' : 'glb'
|
|
|
|
|
@@ -153696,9 +153922,11 @@ ENDSEC
|
|
|
options: {
|
|
|
//dracoDecoderPath: '../utils/loaders/DRACOLoader/draco',
|
|
|
//basisTranscoderPath: '../utils/loaders/KTX2Loader/basis',
|
|
|
- maximumScreenSpaceError: 48,
|
|
|
- maxDepth: 100,
|
|
|
- showAllTile: true,
|
|
|
+ maximumScreenSpaceError: 50,
|
|
|
+ maxDepth: 100,
|
|
|
+ maximumMemoryUsage: 700, //缓存大小。 若太小,密集的tile反复加载很卡
|
|
|
+ //debug:true,
|
|
|
+ parent: this.scene.scene
|
|
|
},
|
|
|
});
|
|
|
console.log(result);
|
|
@@ -153706,7 +153934,7 @@ ENDSEC
|
|
|
loadDone(result.model/* , null, fileInfo.url */);
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
let loaded = false;
|
|
|
let tileset = result.runtime.getTileset();
|
|
|
tileset.addEventListener('endTileLoading', function (data) {//Tileset3D
|