Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
e5d7a899
T
three.js
项目概览
Ablesons
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e5d7a899
编写于
6月 14, 2017
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated builds.
上级
07b08963
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
860 addition
and
497 deletion
+860
-497
build/three.js
build/three.js
+180
-0
build/three.min.js
build/three.min.js
+500
-497
build/three.module.js
build/three.module.js
+180
-0
未找到文件。
build/three.js
浏览文件 @
e5d7a899
...
...
@@ -19684,6 +19684,164 @@
}
/**
* @author mrdoob / http://mrdoob.com/
*/
function WebVRManager( renderer ) {
var scope = this;
var device = null;
var frameData = null;
if ( 'VRFrameData' in window ) {
frameData = new window.VRFrameData();
}
var cameraL = new THREE.PerspectiveCamera();
cameraL.bounds = new THREE.Vector4( 0.0, 0.0, 0.5, 1.0 );
cameraL.layers.enable( 1 );
var cameraR = new THREE.PerspectiveCamera();
cameraR.bounds = new THREE.Vector4( 0.5, 0.0, 0.5, 1.0 );
cameraR.layers.enable( 2 );
var cameraVR = new THREE.ArrayCamera( [ cameraL, cameraR ] );
//
var currentSize, currentPixelRatio;
function onVRDisplayPresentChange() {
if ( device.isPresenting ) {
var eyeParameters = device.getEyeParameters( 'left' );
var renderWidth = eyeParameters.renderWidth;
var renderHeight = eyeParameters.renderHeight;
currentPixelRatio = renderer.getPixelRatio();
currentSize = renderer.getSize();
renderer.setPixelRatio( 1 );
renderer.setSize( renderWidth * 2, renderHeight, false );
} else if ( scope.enabled ) {
renderer.setPixelRatio( currentPixelRatio );
renderer.setSize( currentSize.width, currentSize.height, true );
}
}
window.addEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange, false );
//
this.enabled = false;
this.getDevice = function () {
return device;
};
this.setDevice = function ( value ) {
if ( value !== undefined ) device = value;
};
this.getCamera = function ( camera ) {
if ( device === null ) return camera;
device.depthNear = camera.near;
device.depthFar = camera.far;
device.getFrameData( frameData );
//
var pose = frameData.pose;
if ( pose.position !== null ) {
camera.position.fromArray( pose.position );
} else {
camera.position.set( 0, 0, 0 );
}
if ( pose.orientation !== null ) {
camera.quaternion.fromArray( pose.orientation );
}
camera.updateMatrixWorld();
if ( device.isPresenting === false ) return camera;
//
cameraVR.matrixWorld.copy( camera.matrixWorld );
cameraVR.matrixWorldInverse.copy( camera.matrixWorldInverse );
cameraL.matrixWorldInverse.fromArray( frameData.leftViewMatrix );
cameraR.matrixWorldInverse.fromArray( frameData.rightViewMatrix );
var parent = camera.parent;
if ( parent !== null ) {
cameraL.matrixWorldInverse.multiply( parent.matrixWorldInverse );
cameraR.matrixWorldInverse.multiply( parent.matrixWorldInverse );
}
cameraL.projectionMatrix.fromArray( frameData.leftProjectionMatrix );
cameraR.projectionMatrix.fromArray( frameData.rightProjectionMatrix );
// HACK @mrdoob
// https://github.com/w3c/webvr/issues/203
cameraVR.projectionMatrix.copy( cameraL.projectionMatrix );
//
var layers = device.getLayers();
if ( layers.length ) {
var layer = layers[ 0 ];
if ( layer.leftBounds !== null && layer.leftBounds.length === 4 ) {
cameraL.bounds.fromArray( layer.leftBounds );
}
if ( layer.rightBounds !== null && layer.rightBounds.length === 4 ) {
cameraR.bounds.fromArray( layer.rightBounds );
}
}
return cameraVR;
};
}
/**
* @author mrdoob / http://mrdoob.com/
*/
...
...
@@ -20166,6 +20324,7 @@
var programCache = new WebGLPrograms( this, capabilities );
var lightCache = new WebGLLights();
var renderLists = new WebGLRenderLists();
var vr = new WebVRManager( this );
this.info.programs = programCache.programs;
...
...
@@ -20216,6 +20375,7 @@
this.properties = properties;
this.renderLists = renderLists;
this.state = state;
this.vr = vr;
// shadow map
...
...
@@ -20953,6 +21113,20 @@
// Rendering
this.animate = function ( callback ) {
function onFrame() {
callback();
( vr.getDevice() || window ).requestAnimationFrame( onFrame );
}
( vr.getDevice() || window ).requestAnimationFrame( onFrame );
};
this.render = function ( scene, camera, renderTarget, forceClear ) {
if ( ! ( camera && camera.isCamera ) ) {
...
...
@@ -20978,6 +21152,12 @@
if ( camera.parent === null ) camera.updateMatrixWorld();
if ( vr.enabled ) {
camera = vr.getCamera( camera );
}
_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
_frustum.setFromMatrix( _projScreenMatrix );
...
...
build/three.min.js
浏览文件 @
e5d7a899
此差异已折叠。
点击以展开。
build/three.module.js
浏览文件 @
e5d7a899
...
...
@@ -19678,6 +19678,164 @@ function WebGLCapabilities( gl, extensions, parameters ) {
}
/**
* @author mrdoob / http://mrdoob.com/
*/
function WebVRManager( renderer ) {
var scope = this;
var device = null;
var frameData = null;
if ( 'VRFrameData' in window ) {
frameData = new window.VRFrameData();
}
var cameraL = new THREE.PerspectiveCamera();
cameraL.bounds = new THREE.Vector4( 0.0, 0.0, 0.5, 1.0 );
cameraL.layers.enable( 1 );
var cameraR = new THREE.PerspectiveCamera();
cameraR.bounds = new THREE.Vector4( 0.5, 0.0, 0.5, 1.0 );
cameraR.layers.enable( 2 );
var cameraVR = new THREE.ArrayCamera( [ cameraL, cameraR ] );
//
var currentSize, currentPixelRatio;
function onVRDisplayPresentChange() {
if ( device.isPresenting ) {
var eyeParameters = device.getEyeParameters( 'left' );
var renderWidth = eyeParameters.renderWidth;
var renderHeight = eyeParameters.renderHeight;
currentPixelRatio = renderer.getPixelRatio();
currentSize = renderer.getSize();
renderer.setPixelRatio( 1 );
renderer.setSize( renderWidth * 2, renderHeight, false );
} else if ( scope.enabled ) {
renderer.setPixelRatio( currentPixelRatio );
renderer.setSize( currentSize.width, currentSize.height, true );
}
}
window.addEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange, false );
//
this.enabled = false;
this.getDevice = function () {
return device;
};
this.setDevice = function ( value ) {
if ( value !== undefined ) device = value;
};
this.getCamera = function ( camera ) {
if ( device === null ) return camera;
device.depthNear = camera.near;
device.depthFar = camera.far;
device.getFrameData( frameData );
//
var pose = frameData.pose;
if ( pose.position !== null ) {
camera.position.fromArray( pose.position );
} else {
camera.position.set( 0, 0, 0 );
}
if ( pose.orientation !== null ) {
camera.quaternion.fromArray( pose.orientation );
}
camera.updateMatrixWorld();
if ( device.isPresenting === false ) return camera;
//
cameraVR.matrixWorld.copy( camera.matrixWorld );
cameraVR.matrixWorldInverse.copy( camera.matrixWorldInverse );
cameraL.matrixWorldInverse.fromArray( frameData.leftViewMatrix );
cameraR.matrixWorldInverse.fromArray( frameData.rightViewMatrix );
var parent = camera.parent;
if ( parent !== null ) {
cameraL.matrixWorldInverse.multiply( parent.matrixWorldInverse );
cameraR.matrixWorldInverse.multiply( parent.matrixWorldInverse );
}
cameraL.projectionMatrix.fromArray( frameData.leftProjectionMatrix );
cameraR.projectionMatrix.fromArray( frameData.rightProjectionMatrix );
// HACK @mrdoob
// https://github.com/w3c/webvr/issues/203
cameraVR.projectionMatrix.copy( cameraL.projectionMatrix );
//
var layers = device.getLayers();
if ( layers.length ) {
var layer = layers[ 0 ];
if ( layer.leftBounds !== null && layer.leftBounds.length === 4 ) {
cameraL.bounds.fromArray( layer.leftBounds );
}
if ( layer.rightBounds !== null && layer.rightBounds.length === 4 ) {
cameraR.bounds.fromArray( layer.rightBounds );
}
}
return cameraVR;
};
}
/**
* @author mrdoob / http://mrdoob.com/
*/
...
...
@@ -20160,6 +20318,7 @@ function WebGLRenderer( parameters ) {
var programCache = new WebGLPrograms( this, capabilities );
var lightCache = new WebGLLights();
var renderLists = new WebGLRenderLists();
var vr = new WebVRManager( this );
this.info.programs = programCache.programs;
...
...
@@ -20210,6 +20369,7 @@ function WebGLRenderer( parameters ) {
this.properties = properties;
this.renderLists = renderLists;
this.state = state;
this.vr = vr;
// shadow map
...
...
@@ -20947,6 +21107,20 @@ function WebGLRenderer( parameters ) {
// Rendering
this.animate = function ( callback ) {
function onFrame() {
callback();
( vr.getDevice() || window ).requestAnimationFrame( onFrame );
}
( vr.getDevice() || window ).requestAnimationFrame( onFrame );
};
this.render = function ( scene, camera, renderTarget, forceClear ) {
if ( ! ( camera && camera.isCamera ) ) {
...
...
@@ -20972,6 +21146,12 @@ function WebGLRenderer( parameters ) {
if ( camera.parent === null ) camera.updateMatrixWorld();
if ( vr.enabled ) {
camera = vr.getCamera( camera );
}
_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
_frustum.setFromMatrix( _projScreenMatrix );
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录