升级threejs版本,修改vr参数

This commit is contained in:
sunzhenyu 2021-07-28 17:07:13 +08:00
parent 5d08ecb813
commit 994df74123
8 changed files with 10293 additions and 60298 deletions

View File

@ -956,6 +956,7 @@ export function jl3dFaultDeviceVr(dom,group,skinCode) {
}
function squeezeStart(){
console.log("squeeze");
scope.modelmanager.otherDevice.action.play();
if(positionStatus == "dm"){
if(vrPlaneStatus){

View File

@ -1,60 +1,24 @@
/**
* @author mrdoob / http://mrdoob.com
* @author Mugen87 / https://github.com/Mugen87
*/
class VRButton {
var VRButton = {
static createButton(originPos,vrPos, renderer, options ) {
createButton: function ( originPos,vrPos,renderer, options ) {
if ( options ) {
if ( options && options.referenceSpaceType ) {
renderer.vr.setReferenceSpaceType( options.referenceSpaceType );
console.error( 'THREE.VRButton: The "options" parameter has been removed. Please set the reference space type via renderer.xr.setReferenceSpaceType() instead.' );
}
function showEnterVR( device ) {
const button = document.createElement( 'button' );
button.style.display = '';
function showEnterVR( /*device*/ ) {
button.style.cursor = 'pointer';
button.style.left = 'calc(50% - 50px)';
button.style.width = '100px';
let currentSession = null;
button.textContent = 'ENTER_VR';
button.onmouseenter = function () {
button.style.opacity = '1.0';
};
button.onmouseleave = function () {
button.style.opacity = '0.5';
};
button.onclick = function () {
device.isPresenting ? device.exitPresent() : device.requestPresent( [ { source: renderer.domElement } ] );
originPos.position.set(vrPos.x,vrPos.y,vrPos.z);
};
renderer.vr.setDevice( device );
}
function showEnterXR( /*device*/ ) {
var currentSession = null;
function onSessionStarted( session ) {
async function onSessionStarted( session ) {
session.addEventListener( 'end', onSessionEnded );
renderer.vr.setSession( session );
await renderer.vr.setSession( session );
button.textContent = 'EXIT VR';
currentSession = session;
@ -65,7 +29,6 @@ var VRButton = {
currentSession.removeEventListener( 'end', onSessionEnded );
renderer.vr.setSession( null );
button.textContent = 'ENTER VR';
currentSession = null;
@ -105,9 +68,9 @@ var VRButton = {
// ('local' is always available for immersive sessions and doesn't need to
// be requested separately.)
var sessionInit = { optionalFeatures: [ 'local-floor', 'bounded-floor' ] };
const sessionInit = { optionalFeatures: [ 'local-floor', 'bounded-floor', 'hand-tracking', 'layers' ] };
navigator.xr.requestSession( 'immersive-vr', sessionInit ).then( onSessionStarted );
originPos.position.set(vrPos.x,vrPos.y,vrPos.z);
} else {
currentSession.end();
@ -133,21 +96,11 @@ var VRButton = {
}
function showVRNotFound() {
function showWebXRNotFound() {
disableButton();
button.textContent = 'VR NOT FOUND';
renderer.vr.setDevice( null );
}
function showXRNotFound() {
disableButton();
button.textContent = 'VR NOT FOUND';
button.textContent = 'VR NOT SUPPORTED';
}
@ -169,82 +122,36 @@ var VRButton = {
}
if ( 'xr' in navigator ) {
console.log("xr");
var button = document.createElement( 'button' );
button.id = 'VRButton';
button.style.display = 'none';
stylizeElement( button );
navigator.xr.isSessionSupported( 'immersive-vr' ).then( function ( supported ) {
if ( supported ) {
showEnterXR();
} else {
showXRNotFound();
}
supported ? showEnterVR() : showWebXRNotFound();
} );
return button;
} else if ( 'getVRDisplays' in navigator ) {
console.log("vr");
var button = document.createElement( 'button' );
button.style.display = 'none';
} else {
stylizeElement( button );
const message = document.createElement( 'a' );
window.addEventListener( 'vrdisplayconnect', function ( event ) {
if ( window.isSecureContext === false ) {
showEnterVR( event.display );
}, false );
window.addEventListener( 'vrdisplaydisconnect', function ( /*event*/ ) {
showVRNotFound();
}, false );
window.addEventListener( 'vrdisplaypresentchange', function ( event ) {
button.textContent = event.display.isPresenting ? 'EXIT_VR' : 'ENTER_VR';
}, false );
window.addEventListener( 'vrdisplayactivate', function ( event ) {
event.display.requestPresent( [ { source: renderer.domElement } ] );
}, false );
navigator.getVRDisplays()
.then( function ( displays ) {
if ( displays.length > 0 ) {
showEnterVR( displays[ 0 ] );
message.href = document.location.href.replace( /^http:/, 'https:' );
message.innerHTML = 'WEBXR NEEDS HTTPS'; // TODO Improve message
} else {
showVRNotFound();
message.href = 'https://immersiveweb.dev/';
message.innerHTML = 'WEBXR NOT AVAILABLE';
}
} ).catch( showVRNotFound );
return button;
} else {
var message = document.createElement( 'a' );
message.href = 'https://immersive-web.github.io/webxr/';
message.innerHTML = 'WEBXR NOT SUPPORTED';
message.style.left = 'calc(50% - 90px)';
message.style.width = '180px';
message.style.textDecoration = 'none';
@ -257,6 +164,6 @@ var VRButton = {
}
};
}
export { VRButton };

View File

@ -54,6 +54,7 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) {
// this.renderer.shadowMap.type = THREE.PCFSoftShadowMap;
this.renderer.gammaInput = true;
this.renderer.gammaOutput = true;
console.log( this.renderer);
this.renderer.vr.enabled = true;
this.dom.appendChild(this.renderer.domElement);
document.body.appendChild( VRButton.createButton( human,{x:25,y:1.3,z:1},this.renderer ) );
@ -208,6 +209,7 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) {
function onSelectStart( event ) {
// console.log();
console.log("select");
var controller = event.target;
var intersections = getIntersections( controller );
@ -249,6 +251,7 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) {
let controlMoveSwitch = false;
let nowControlModel = null;
function squeezeStart(){
console.log("squeezestart");
TrainRescueStatic.handR.action.reset();
TrainRescueStatic.handR.action.time = TrainRescueStatic.handR.action._clip.duration;
TrainRescueStatic.handR.action.timeScale = 1;
@ -271,6 +274,7 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) {
}
function squeezeEnd(){
console.log("squeezeend");
TrainRescueStatic.handR.action.reset();
TrainRescueStatic.handR.action.time = 0;
TrainRescueStatic.handR.action.timeScale = -1;

View File

@ -4,13 +4,13 @@
<div class="jl3dmap3dMaintainerSelect" :style="{'background-image': 'url('+localStatic+'/background/other.jpg)'}">
<div class="maintainerSelectButton selectButtonImg1"
:style="{'background-image': 'url('+localStatic+'/vrtest/maintainer.png)'}"
style="left:40%" @mouseenter="onMouseOverNormal"></div>
style="left:10%" @mouseenter="onMouseOverNormal"></div>
<div class="maintainerSelectButton selectButtonImg2"
:style="{'background-image': 'url('+localStatic+'/vrtest/zc.png)'}"
style="left:40%;" v-show="normalShow"@mouseleave="onMouseOutNormal" @click="initNormal"></div>
style="left:10%;" v-show="normalShow"@mouseleave="onMouseOutNormal" @click="initNormal"></div>
<!-- <div class="maintainerSelectButton selectButtonImg3"
<div class="maintainerSelectButton selectButtonImg3"
:style="{'background-image': 'url('+localStatic+'/vrtest/maintainervr.png)'}"
style="left:40%;" @mouseenter="onMouseOverVr"></div>
@ -24,7 +24,7 @@
<div class="maintainerSelectButton selectButtonImg6"
:style="{'background-image': 'url('+localStatic+'/vrtest/trvr.png)'}"
style="left:70%;" v-show="trainRescueShow" @mouseleave="onMouseOutRescue" @click="initTrainRescueVr"></div> -->
style="left:70%;" v-show="trainRescueShow" @mouseleave="onMouseOutRescue" @click="initTrainRescueVr"></div>
</div>

2
static/three.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long