使用three.js Rev 82我的实验飞行模拟器应用程序显示了此显示(显示为所需并支持对象拾取): -
当我更改应用程序以使用three.js Rev 89时,(令人满意地)零执行错误但是它产生了这个显示(由于错误的视口和随之而来的对象拾取失败而导致错误): -
该应用程序使用五(5)个矩形视口来显示图形数据: - (1)覆盖整个屏幕的基础视口,具有扁平的黑色和蓝色矩形; (3)从左到右排列的三个中层视口,显示外部世界的景观; (1)带有文本框,键盘和按钮的覆盖“控制面板”视口。
从Rev 82到Rev 89,中层和上层视口的垂直位置发生了变化。例如,三个“中级”视口已从屏幕的上部移动到下部。并且“控制面板”视口 - 应该朝向屏幕底部 - 已经移动到屏幕顶部附近。
我查看了Migration Summary,但看不到任何相关更改。看着Renderer documentation没有任何明显的东西突然出现在我身上 - 但其中没有修订历史。
我正在使用的代码(定义,更新和渲染视口)如下: -
function F_Render()
{
//... Discover the current window dimensions (usable)
var WINDOW_USABLE_PIXELS_WIDTH = window.innerWidth;
var WINDOW_USABLE_PIXELS_HEIGHT = window.innerHeight;
var Fudge = 0;
var FIXED_DOXELS_WIDTH = 1024;
var FIXED_DOXELS_HEIGHT = 576;
var elastic_viewports = false;
if (elastic_viewports)
{
var SLATE_DOXELS_WIDTH = WINDOW_USABLE_PIXELS_WIDTH - Fudge;
var SLATE_DOXELS_HEIGHT = WINDOW_USABLE_PIXELS_HEIGHT - Fudge;
}
else
{
var SLATE_DOXELS_WIDTH = FIXED_DOXELS_WIDTH -Fudge;
var SLATE_DOXELS_HEIGHT = FIXED_DOXELS_HEIGHT -Fudge;
}
//**** NB SCREEN COORDS ORIGIN IS TOP LEFT CORNER so Y values increase DOWNWARDS *****
//**** BUT RENDERER VIEWPORT COORDS INCREASE FROM BOTTOM LEFT
var numMidPanels = 3;
var mar = Math.floor( SLATE_DOXELS_HEIGHT/16 ); //...careful, changing this has knock-on effects!
midPanelX1min = mar;
var fudge = SLATE_DOXELS_WIDTH*0.06;
var fudge = 0;
//...gives a common width value to be used by all mid panels
var midPanelWidth = fudge +(1/numMidPanels) * (SLATE_DOXELS_WIDTH - ((numMidPanels+1)* mar)) ;
var midPanelAverageWidth = fudge +(1/numMidPanels) * (SLATE_DOXELS_WIDTH - ((numMidPanels+1)* mar)) ;
var midPanelX1_Width = midPanelAverageWidth *2/3;
var midPanelX2_Width = midPanelAverageWidth *5/3;
var midPanelX3_Width = midPanelAverageWidth *2/3;
//---
var bottomPanelXmin = mar;
var bottomPanelYmin = mar;
var bottomPanelHeight = (1/3)* (SLATE_DOXELS_HEIGHT - (3*mar)); //...bottom third of screen height
var bottomPanelWidth = (SLATE_DOXELS_WIDTH - (2*mar));
var midPanelHeight = (2/3)* (SLATE_DOXELS_HEIGHT - (3*mar));
midPanelX2min = mar + midPanelWidth + mar ;
midPanelX3min = mar + midPanelWidth + mar + midPanelWidth + mar;
midPanelX2min = mar + midPanelX1_Width + mar ;
midPanelX3min = mar + midPanelX1_Width + mar + midPanelX2_Width + mar;
midPanelYmin = mar + bottomPanelHeight + mar;
midPanelYmax = mar + bottomPanelHeight + mar + midPanelHeight;
//... set ASPECT RATIOS
//... BASE LAYER Scene111
var BaseLayer_AspectRatio = SLATE_DOXELS_WIDTH/SLATE_DOXELS_HEIGHT;
//... MIDDLE LAYER Scene222 Middle Panels
var MidPanelX1_AspectRatio = midPanelX1_Width/midPanelHeight;
var MidPanelX2_AspectRatio = midPanelX2_Width/midPanelHeight;
var MidPanelX3_AspectRatio = midPanelX3_Width/midPanelHeight;
//... TOP LAYER
var BottomPanel_AspectRatio = bottomPanelWidth/bottomPanelHeight;
//------------------------------------------------------------------------------------------
//... do CAMERA UPDATES if required due to recent change
if ( scene111camera01._SW_needsUpdate == true)
{
scene111camera01.aspect = BaseLayer_AspectRatio;
scene111camera01.updateProjectionMatrix(); //...is this really neccy?
scene111camera01._SW_needsUpdate = false;
}
//... MIDDLE LAYER Scene222 Middle Panels
if ( scene222camera02._SW_needsUpdate == true)
{
scene222camera02.aspect = MidPanelX1_AspectRatio;
scene222camera02.updateProjectionMatrix();
scene222camera02._SW_needsUpdate = false;
}
if ( scene222camera03._SW_needsUpdate == true)
{
scene222camera03.aspect = MidPanelX2_AspectRatio;
scene222camera03.updateProjectionMatrix();
scene222camera03._SW_needsUpdate = false;
}
if ( scene222camera04._SW_needsUpdate == true)
{
scene222camera04.aspect = MidPanelX3_AspectRatio;
scene222camera04.updateProjectionMatrix();
scene222camera04._SW_needsUpdate = false;
}
//... TOP LAYER (DashBoard) Scene333
if ( scene333camera05._SW_needsUpdate == true)
{
scene333camera05.aspect = BottomPanel_AspectRatio;
scene333camera05.updateProjectionMatrix();
scene333camera05._SW_needsUpdate = false;
}
//==========================================================================================================
//... Clear the entire raster area
var Control_Panel_Num = 0;
Renderer_ZERO.setViewport( 0, 0, SLATE_DOXELS_WIDTH, SLATE_DOXELS_HEIGHT );
Renderer_ZERO.clear();
//=========================================================================================================
//... BASE LAYER, scene111 ... Single Panel (viewport)
Renderer_ZERO.setViewport( 0, 0, SLATE_DOXELS_WIDTH, SLATE_DOXELS_HEIGHT );
Renderer_ZERO.render( scene111, scene111camera01 );
Control_Panel_Num = Control_Panel_Num+1;
ObjectPickingActive=true;
xxx = SOW_F_sim_Update_Panel_Data ( Control_Panel_Num,"BasePlane",0, 0, SLATE_DOXELS_WIDTH, SLATE_DOXELS_HEIGHT , ObjectPickingActive, scene111, scene111camera01 );
//===========================================================================================================
//... MIDDLE LAYER, scene222 ... three panels (view-ports)
Renderer_ZERO.clearDepth();
//... MIDDLE LAYER, LEFT PANEL
//showVP_scene222camera02 = true; //...now set elsewhere
if (showVP_scene222camera02 == true)
{
Renderer_ZERO.setViewport( midPanelX1min, midPanelYmin, midPanelX1_Width , midPanelHeight );
Renderer_ZERO.render( scene222, scene222camera02 );
Control_Panel_Num = Control_Panel_Num+1;
ObjectPickingActive=true;
xxx = SOW_F_sim_Update_Panel_Data (Control_Panel_Num,"Middle_Left",midPanelX1min, midPanelYmin, midPanelX1_Width , midPanelHeight, ObjectPickingActive, scene222, scene222camera02 );
}
//... MIDDLE LAYER, CENTRE PANEL
if (showVP_scene222camera03 == true)
{
var midPanelY2min = midPanelYmin //-150 //*** JUST FOR TESTING ***
Renderer_ZERO.setViewport( midPanelX2min, midPanelY2min, midPanelX2_Width, midPanelHeight );
Renderer_ZERO.render( scene222, scene222camera03 );
Control_Panel_Num = Control_Panel_Num+1;
ObjectPickingActive=true;
xxx = SOW_F_sim_Update_Panel_Data (Control_Panel_Num,"Middle_Centre",midPanelX2min, midPanelY2min, midPanelX2_Width, midPanelHeight, ObjectPickingActive, scene222, scene222camera03 );
}
if (showVP_scene222camera04 == true)
{
//... MIDDLE LAYER, RIGHT PANEL
Renderer_ZERO.setViewport( midPanelX3min, midPanelYmin, midPanelX3_Width, midPanelHeight );
Renderer_ZERO.render( scene222, scene222camera04 );
Control_Panel_Num = Control_Panel_Num+1;
ObjectPickingActive=true;
xxx = SOW_F_sim_Update_Panel_Data (Control_Panel_Num,"Middle_Right",midPanelX3min, midPanelYmin, midPanelX3_Width, midPanelHeight, ObjectPickingActive, scene222, scene222camera04 );
}
//================================================================================================
//... TOP LAYER Scene333
//... THIS LAYER CONTAINS BUTTONS WHICH OVERPLOT MID LAYER
//... (Multi-renderers only: display stack sequence controlled by html div declaration sequence).
//... UPPER LAYER (C)
// (DASHBOARD) ...BOTTOM STRIP
//TEST
//bottomPanelXmin
//bottomPanelYmin=100;
//bottomPanelWidth
//bottomPanelHeight= 300 ;
//END TEST
//TEST makes bottom panel viewport overlap upwards over the middle panels just to demo that we can do this
// and thus we can stick objects in a high viewport which display in front of objects from a lower viewport
// but NOTE WELL this only works reliably when VPs are from different scenes/renderers
// otherwise conflicts can occur.
var Fudged_bottomPanelHeight=bottomPanelHeight+40;
Renderer_ZERO.clearDepth();
Renderer_ZERO.setViewport( bottomPanelXmin, bottomPanelYmin, bottomPanelWidth, Fudged_bottomPanelHeight );
Renderer_ZERO.render( scene333, scene333camera05 );
Control_Panel_Num = Control_Panel_Num+1;
ObjectPickingActive=true;
xxx = SOW_F_sim_Update_Panel_Data (Control_Panel_Num,"Bottom_Strip",bottomPanelXmin, bottomPanelYmin, bottomPanelWidth, Fudged_bottomPanelHeight, ObjectPickingActive, scene333, scene333camera05 );
} //... END OF F_Render
如果有人能够提出三个可能导致这个问题的变化,我将不胜感激?
答案 0 :(得分:1)
从r.86开始,WebGLRenderer.setViewport()
和WebGLRenderer.setScissor()
假设一个坐标系,其中(0,0)是左上角。以前,它是左下角。
three.js r.89