升级threejs版本,修改vr参数
This commit is contained in:
parent
5d08ecb813
commit
994df74123
@ -956,6 +956,7 @@ export function jl3dFaultDeviceVr(dom,group,skinCode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function squeezeStart(){
|
function squeezeStart(){
|
||||||
|
console.log("squeeze");
|
||||||
scope.modelmanager.otherDevice.action.play();
|
scope.modelmanager.otherDevice.action.play();
|
||||||
if(positionStatus == "dm"){
|
if(positionStatus == "dm"){
|
||||||
if(vrPlaneStatus){
|
if(vrPlaneStatus){
|
||||||
|
@ -1,60 +1,24 @@
|
|||||||
/**
|
class VRButton {
|
||||||
* @author mrdoob / http://mrdoob.com
|
|
||||||
* @author Mugen87 / https://github.com/Mugen87
|
|
||||||
*/
|
|
||||||
|
|
||||||
var VRButton = {
|
static createButton(originPos,vrPos, renderer, options ) {
|
||||||
|
|
||||||
createButton: function ( originPos,vrPos,renderer, options ) {
|
if ( options ) {
|
||||||
|
|
||||||
if ( options && options.referenceSpaceType ) {
|
console.error( 'THREE.VRButton: The "options" parameter has been removed. Please set the reference space type via renderer.xr.setReferenceSpaceType() instead.' );
|
||||||
|
|
||||||
renderer.vr.setReferenceSpaceType( options.referenceSpaceType );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showEnterVR( device ) {
|
const button = document.createElement( 'button' );
|
||||||
|
|
||||||
button.style.display = '';
|
function showEnterVR( /*device*/ ) {
|
||||||
|
|
||||||
button.style.cursor = 'pointer';
|
let currentSession = null;
|
||||||
button.style.left = 'calc(50% - 50px)';
|
|
||||||
button.style.width = '100px';
|
|
||||||
|
|
||||||
button.textContent = 'ENTER_VR';
|
async function onSessionStarted( session ) {
|
||||||
|
|
||||||
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 ) {
|
|
||||||
|
|
||||||
session.addEventListener( 'end', onSessionEnded );
|
session.addEventListener( 'end', onSessionEnded );
|
||||||
|
|
||||||
renderer.vr.setSession( session );
|
await renderer.vr.setSession( session );
|
||||||
button.textContent = 'EXIT VR';
|
button.textContent = 'EXIT VR';
|
||||||
|
|
||||||
currentSession = session;
|
currentSession = session;
|
||||||
@ -65,7 +29,6 @@ var VRButton = {
|
|||||||
|
|
||||||
currentSession.removeEventListener( 'end', onSessionEnded );
|
currentSession.removeEventListener( 'end', onSessionEnded );
|
||||||
|
|
||||||
renderer.vr.setSession( null );
|
|
||||||
button.textContent = 'ENTER VR';
|
button.textContent = 'ENTER VR';
|
||||||
|
|
||||||
currentSession = null;
|
currentSession = null;
|
||||||
@ -105,9 +68,9 @@ var VRButton = {
|
|||||||
// ('local' is always available for immersive sessions and doesn't need to
|
// ('local' is always available for immersive sessions and doesn't need to
|
||||||
// be requested separately.)
|
// 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 );
|
navigator.xr.requestSession( 'immersive-vr', sessionInit ).then( onSessionStarted );
|
||||||
|
originPos.position.set(vrPos.x,vrPos.y,vrPos.z);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
currentSession.end();
|
currentSession.end();
|
||||||
@ -133,21 +96,11 @@ var VRButton = {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showVRNotFound() {
|
function showWebXRNotFound() {
|
||||||
|
|
||||||
disableButton();
|
disableButton();
|
||||||
|
|
||||||
button.textContent = 'VR NOT FOUND';
|
button.textContent = 'VR NOT SUPPORTED';
|
||||||
|
|
||||||
renderer.vr.setDevice( null );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function showXRNotFound() {
|
|
||||||
|
|
||||||
disableButton();
|
|
||||||
|
|
||||||
button.textContent = 'VR NOT FOUND';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,82 +122,36 @@ var VRButton = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( 'xr' in navigator ) {
|
if ( 'xr' in navigator ) {
|
||||||
console.log("xr");
|
|
||||||
var button = document.createElement( 'button' );
|
button.id = 'VRButton';
|
||||||
button.style.display = 'none';
|
button.style.display = 'none';
|
||||||
|
|
||||||
stylizeElement( button );
|
stylizeElement( button );
|
||||||
|
|
||||||
navigator.xr.isSessionSupported( 'immersive-vr' ).then( function ( supported ) {
|
navigator.xr.isSessionSupported( 'immersive-vr' ).then( function ( supported ) {
|
||||||
|
|
||||||
if ( supported ) {
|
supported ? showEnterVR() : showWebXRNotFound();
|
||||||
|
|
||||||
showEnterXR();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
showXRNotFound();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
return button;
|
return button;
|
||||||
|
|
||||||
} else if ( 'getVRDisplays' in navigator ) {
|
} else {
|
||||||
console.log("vr");
|
|
||||||
var button = document.createElement( 'button' );
|
|
||||||
button.style.display = 'none';
|
|
||||||
|
|
||||||
stylizeElement( button );
|
const message = document.createElement( 'a' );
|
||||||
|
|
||||||
window.addEventListener( 'vrdisplayconnect', function ( event ) {
|
if ( window.isSecureContext === false ) {
|
||||||
|
|
||||||
showEnterVR( event.display );
|
message.href = document.location.href.replace( /^http:/, 'https:' );
|
||||||
|
message.innerHTML = 'WEBXR NEEDS HTTPS'; // TODO Improve message
|
||||||
}, 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 ] );
|
|
||||||
|
|
||||||
} else {
|
} 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.left = 'calc(50% - 90px)';
|
||||||
message.style.width = '180px';
|
message.style.width = '180px';
|
||||||
message.style.textDecoration = 'none';
|
message.style.textDecoration = 'none';
|
||||||
@ -257,6 +164,6 @@ var VRButton = {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
export { VRButton };
|
export { VRButton };
|
||||||
|
@ -54,6 +54,7 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) {
|
|||||||
// this.renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
// this.renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
||||||
this.renderer.gammaInput = true;
|
this.renderer.gammaInput = true;
|
||||||
this.renderer.gammaOutput = true;
|
this.renderer.gammaOutput = true;
|
||||||
|
console.log( this.renderer);
|
||||||
this.renderer.vr.enabled = true;
|
this.renderer.vr.enabled = true;
|
||||||
this.dom.appendChild(this.renderer.domElement);
|
this.dom.appendChild(this.renderer.domElement);
|
||||||
document.body.appendChild( VRButton.createButton( human,{x:25,y:1.3,z:1},this.renderer ) );
|
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 ) {
|
function onSelectStart( event ) {
|
||||||
// console.log();
|
// console.log();
|
||||||
|
console.log("select");
|
||||||
var controller = event.target;
|
var controller = event.target;
|
||||||
var intersections = getIntersections( controller );
|
var intersections = getIntersections( controller );
|
||||||
|
|
||||||
@ -249,6 +251,7 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) {
|
|||||||
let controlMoveSwitch = false;
|
let controlMoveSwitch = false;
|
||||||
let nowControlModel = null;
|
let nowControlModel = null;
|
||||||
function squeezeStart(){
|
function squeezeStart(){
|
||||||
|
console.log("squeezestart");
|
||||||
TrainRescueStatic.handR.action.reset();
|
TrainRescueStatic.handR.action.reset();
|
||||||
TrainRescueStatic.handR.action.time = TrainRescueStatic.handR.action._clip.duration;
|
TrainRescueStatic.handR.action.time = TrainRescueStatic.handR.action._clip.duration;
|
||||||
TrainRescueStatic.handR.action.timeScale = 1;
|
TrainRescueStatic.handR.action.timeScale = 1;
|
||||||
@ -271,6 +274,7 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
function squeezeEnd(){
|
function squeezeEnd(){
|
||||||
|
console.log("squeezeend");
|
||||||
TrainRescueStatic.handR.action.reset();
|
TrainRescueStatic.handR.action.reset();
|
||||||
TrainRescueStatic.handR.action.time = 0;
|
TrainRescueStatic.handR.action.time = 0;
|
||||||
TrainRescueStatic.handR.action.timeScale = -1;
|
TrainRescueStatic.handR.action.timeScale = -1;
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
<div class="jl3dmap3dMaintainerSelect" :style="{'background-image': 'url('+localStatic+'/background/other.jpg)'}">
|
<div class="jl3dmap3dMaintainerSelect" :style="{'background-image': 'url('+localStatic+'/background/other.jpg)'}">
|
||||||
<div class="maintainerSelectButton selectButtonImg1"
|
<div class="maintainerSelectButton selectButtonImg1"
|
||||||
:style="{'background-image': 'url('+localStatic+'/vrtest/maintainer.png)'}"
|
:style="{'background-image': 'url('+localStatic+'/vrtest/maintainer.png)'}"
|
||||||
style="left:40%" @mouseenter="onMouseOverNormal"></div>
|
style="left:10%" @mouseenter="onMouseOverNormal"></div>
|
||||||
|
|
||||||
<div class="maintainerSelectButton selectButtonImg2"
|
<div class="maintainerSelectButton selectButtonImg2"
|
||||||
:style="{'background-image': 'url('+localStatic+'/vrtest/zc.png)'}"
|
: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="{'background-image': 'url('+localStatic+'/vrtest/maintainervr.png)'}"
|
||||||
style="left:40%;" @mouseenter="onMouseOverVr"></div>
|
style="left:40%;" @mouseenter="onMouseOverVr"></div>
|
||||||
|
|
||||||
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<div class="maintainerSelectButton selectButtonImg6"
|
<div class="maintainerSelectButton selectButtonImg6"
|
||||||
:style="{'background-image': 'url('+localStatic+'/vrtest/trvr.png)'}"
|
: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>
|
</div>
|
||||||
|
2
static/three.min.js
vendored
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
18238
static/three.module.js
18238
static/three.module.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user