|
@@ -65,6 +65,15 @@ import {MeshDraw} from '../utils/DrawUtil'
|
|
import {OBJLoader} from "../../libs/three.js/loaders/OBJLoader.js";
|
|
import {OBJLoader} from "../../libs/three.js/loaders/OBJLoader.js";
|
|
import {MTLLoader} from "../../libs/three.js/loaders/MTLLoader.js";
|
|
import {MTLLoader} from "../../libs/three.js/loaders/MTLLoader.js";
|
|
|
|
|
|
|
|
+import SSAARenderPass from "../materials/postprocessing/SSAARenderPass"
|
|
|
|
+import EffectComposer from '../materials/postprocessing/EffectComposer'
|
|
|
|
+import {ShaderPass} from '../materials/postprocessing/ShaderPass'
|
|
|
|
+import RenderPass from '../materials/postprocessing/RenderPass'
|
|
|
|
+import FXAAShader from "../materials/postprocessing/FXAAShader"
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -311,6 +320,8 @@ export class Viewer extends ViewerBase{
|
|
this.shadowTestCam.lookAt(new THREE.Vector3(0, 0, 4.87));
|
|
this.shadowTestCam.lookAt(new THREE.Vector3(0, 0, 4.87));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
let scene = new Scene(this.renderer);
|
|
let scene = new Scene(this.renderer);
|
|
|
|
|
|
@@ -331,6 +342,48 @@ export class Viewer extends ViewerBase{
|
|
}
|
|
}
|
|
|
|
|
|
this.setScene(scene);
|
|
this.setScene(scene);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //add: for 截图时抗锯齿
|
|
|
|
+ {
|
|
|
|
+ this.composer = new EffectComposer( this.renderer );
|
|
|
|
+ this.ssaaRenderPass = new SSAARenderPass(0x000000, 0);
|
|
|
|
+ this.composer.addPass( this.ssaaRenderPass );
|
|
|
|
+ //this.ssaaRenderPass.useCopy = true
|
|
|
|
+ //this.ssaaRenderPass.renderToScreen = true;
|
|
|
|
+ //this.ssaaRenderPass.needsSwap = false
|
|
|
|
+ //见 https://threejs.org/examples/?q=AA#webgl_postprocessing_fxaa 效果和SSAA差不多,都对透明不太友好。
|
|
|
|
+ /* const renderPass = new RenderPass();
|
|
|
|
+ renderPass.clearColor = new THREE.Color( 0, 0, 0 );
|
|
|
|
+ renderPass.clearAlpha = 0;
|
|
|
|
+ this.composer.addPass( renderPass );
|
|
|
|
+
|
|
|
|
+ this.fxaaPass = new ShaderPass( FXAAShader );
|
|
|
|
+
|
|
|
|
+ this.composer.addPass( this.fxaaPass );
|
|
|
|
+
|
|
|
|
+ this.fxaaPass.setSize = function(width, height){
|
|
|
|
+ this.material.uniforms[ 'resolution' ].value.x = 1 / ( width );
|
|
|
|
+ this.material.uniforms[ 'resolution' ].value.y = 1 / ( height );
|
|
|
|
+ }
|
|
|
|
+ this.fxaaPass.renderToScreen = true; */
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /* this.fxaaPass = new ShaderPass( FXAAShader );
|
|
|
|
+ //this.fxaaPass.readTarget = true //add
|
|
|
|
+ this.composer.addPass( this.fxaaPass );
|
|
|
|
+ this.composer.readTarget = true
|
|
|
|
+ this.fxaaPass.setSize = function(width, height){
|
|
|
|
+ this.material.uniforms[ 'resolution' ].value.x = 1 / ( width );
|
|
|
|
+ this.material.uniforms[ 'resolution' ].value.y = 1 / ( height );
|
|
|
|
+ }
|
|
|
|
+ this.fxaaPass.renderToScreen = true; */
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
{
|
|
{
|
|
this.inputHandler = new InputHandler(this, this.scene.scene);
|
|
this.inputHandler = new InputHandler(this, this.scene.scene);
|
|
@@ -2647,7 +2700,8 @@ export class Viewer extends ViewerBase{
|
|
params_.target.viewport.set(left, bottom, width, height);
|
|
params_.target.viewport.set(left, bottom, width, height);
|
|
scissorTest && params_.target.scissor.set(left, bottom, width, height);
|
|
scissorTest && params_.target.scissor.set(left, bottom, width, height);
|
|
params_.target.scissorTest = scissorTest
|
|
params_.target.scissorTest = scissorTest
|
|
- }else{
|
|
|
|
|
|
+
|
|
|
|
+ }else{
|
|
this.renderer.setViewport(left, bottom, width, height) //规定视口,影响图形变换(画布的使用范围)
|
|
this.renderer.setViewport(left, bottom, width, height) //规定视口,影响图形变换(画布的使用范围)
|
|
scissorTest && this.renderer.setScissor( left, bottom, width, height );//规定渲染范围
|
|
scissorTest && this.renderer.setScissor( left, bottom, width, height );//规定渲染范围
|
|
this.renderer.setScissorTest( scissorTest );//开启WebGL剪裁测试功能,如果不开启,.setScissor方法设置的范围不起作用 | width==1且height==1时开启会只有鼠标的地方刷新,很奇怪
|
|
this.renderer.setScissorTest( scissorTest );//开启WebGL剪裁测试功能,如果不开启,.setScissor方法设置的范围不起作用 | width==1且height==1时开启会只有鼠标的地方刷新,很奇怪
|
|
@@ -2655,7 +2709,10 @@ export class Viewer extends ViewerBase{
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
if(needSResize){
|
|
if(needSResize){
|
|
this.emitResizeMsg( { viewport:view} )
|
|
this.emitResizeMsg( { viewport:view} )
|
|
}
|
|
}
|
|
@@ -2666,11 +2723,11 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
viewer.dispatchEvent({type: "render.begin", viewer: viewer, viewport:view, params });
|
|
viewer.dispatchEvent({type: "render.begin", viewer: viewer, viewport:view, params });
|
|
|
|
|
|
- if(view.render){
|
|
|
|
- view.render({
|
|
|
|
- target: params_.target, renderer:this.renderer, clear:this.clear.bind(this),
|
|
|
|
|
|
+ if(view.render){
|
|
|
|
+ view.render($.extend({}, params, {
|
|
|
|
+ renderer:this.renderer, clear:this.clear.bind(this), resize:null,
|
|
renderOverlay: this.renderOverlay.bind(this), force:!view.noPointcloud //如果要渲染点云,必须也一直渲染地图,否则地图会被覆盖(点云目前未能获取是否改变,也可能有其他动态物体,所以还是一直渲染的好)
|
|
renderOverlay: this.renderOverlay.bind(this), force:!view.noPointcloud //如果要渲染点云,必须也一直渲染地图,否则地图会被覆盖(点云目前未能获取是否改变,也可能有其他动态物体,所以还是一直渲染的好)
|
|
- })
|
|
|
|
|
|
+ }))
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -2710,12 +2767,31 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
view.afterRender && view.afterRender()
|
|
view.afterRender && view.afterRender()
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
+
|
|
this.dispatchEvent({type: "render.end", viewer: this, viewport:view });
|
|
this.dispatchEvent({type: "render.end", viewer: this, viewport:view });
|
|
|
|
+
|
|
|
|
+
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /* if(params_.screenshot){ //抗锯齿
|
|
|
|
+ params_.target.viewport.set(0, 0, params_.target.width, params_.target.height);
|
|
|
|
+ //scissorTest && params_.target.scissor.set(left, bottom, width, height);
|
|
|
|
+ params_.target.scissorTest = false
|
|
|
|
+
|
|
|
|
+ this.renderer.setRenderTarget(params_.target)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ this.composer.render();
|
|
|
|
+
|
|
|
|
+ this.renderer.setRenderTarget(params_.target) //本想再画一层标签,但是viewport总是出错
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ } */
|
|
|
|
+
|
|
|
|
+
|
|
this.renderer.setRenderTarget(null)
|
|
this.renderer.setRenderTarget(null)
|
|
|
|
|
|
|
|
|
|
@@ -2763,12 +2839,11 @@ export class Viewer extends ViewerBase{
|
|
this.renderer.clearDepth();
|
|
this.renderer.clearDepth();
|
|
|
|
|
|
//this.transformationTool.update();
|
|
//this.transformationTool.update();
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
if(!params.magnifier){
|
|
if(!params.magnifier){
|
|
//测量线
|
|
//测量线
|
|
- this.dispatchEvent({type: "render.pass.perspective_overlay", camera});
|
|
|
|
|
|
+ this.dispatchEvent({type: "render.pass.perspective_overlay", camera, screenshot:params.screenshot});
|
|
|
|
|
|
if(!params.screenshot && !params.isMap){
|
|
if(!params.screenshot && !params.isMap){
|
|
this.setCameraLayers(camera, ['magnifier']) //magnifier 遮住测量线
|
|
this.setCameraLayers(camera, ['magnifier']) //magnifier 遮住测量线
|
|
@@ -2781,7 +2856,7 @@ export class Viewer extends ViewerBase{
|
|
this.renderer.render(this.clippingTool.sceneVolume, camera);
|
|
this.renderer.render(this.clippingTool.sceneVolume, camera);
|
|
this.renderer.render(this.transformationTool.scene, camera);
|
|
this.renderer.render(this.transformationTool.scene, camera);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
setLimitFar(state){//切换是否limitFar
|
|
setLimitFar(state){//切换是否limitFar
|