修改三维vr转辙机案例模型贴图gui面板

This commit is contained in:
sunzhenyu 2020-07-30 16:57:18 +08:00
parent 3990b41cf3
commit e721fe80a3
6 changed files with 120 additions and 114 deletions

View File

@ -288,96 +288,101 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
function onSelectStart( event ) {
var controller = event.target;
console.log(event);
// console.log(event);
let clickGui = getGuiButton(controller);
if(clickGui.length > 0){
var intersection = clickGui[ 0 ];
var object = intersection.object;
if(object.name == "shebeijian"){
human.position.set( -199.90, 0.20+0.6, -5.76 );
}
if(object.name == "jiankongshi"){
human.position.set( -213.610, 0.20+0.6,5.38);
}
if(object.name == "station1"){
human.position.set( -242.37, -4.46+0.6, 4.13);
}
if(object.name == "station2"){
human.position.set( -242.621, 0.20+0.6, 4.90 );
}
if(object.name == "anime"){
if(scope.animastats){
scope.animastats = false;
moveanima.setplaylist(moveanima.animatelist["undefinedon"],true)
}else{
scope.animastats = true;
moveanima.setplaylist(moveanima.animatelist["undefinedoff"],true);
if(vrPlaneStatus){
var intersection = clickGui[ 0 ];
var object = intersection.object;
if(object.name == "shebeijian"){
human.position.set( -199.90, 0.20+0.6, -5.76 );
}
}
if(object.name == "nav"){
if(navMesh){
scope.scene.remove( navMesh );
if(object.name == "jiankongshi"){
human.position.set( -213.610, 0.20+0.6,5.38);
}
if(navStatus){
navStatus = false;
}else{
navStatus = true;
pathPoints = [];
let startPoint = new THREE.Vector3(human.position.x,human.position.y-0.6,human.position.z);
pathPoints.push(new THREE.Vector3(human.position.x,human.position.y,human.position.z));
groupID = pathfinder.getGroup( ZONE, startPoint );
targetPosition = new THREE.Vector3(switchModel.matrixWorld.elements[12],-5.596,switchModel.matrixWorld.elements[14]);
//
// console.log(pathPoints[0]);
// console.log(targetPosition);
// console.log(ZONE);
// console.log(groupID);
let path = pathfinder.findPath( startPoint, targetPosition, ZONE, groupID );
if(path){
for(let i=0;i<path.length;i++){
pathPoints.push(new THREE.Vector3(path[i].x,path[i].y+0.6,path[i].z));
}
let curve = new THREE.CatmullRomCurve3(pathPoints,false);
var geometry = new THREE.TubeGeometry( curve, 100, 0.2, 50, false );
navMesh = new THREE.Mesh( geometry, materialNav );
scope.scene.add( navMesh );
if(object.name == "station1"){
human.position.set( -242.37, -4.46+0.6, 4.13);
}
if(object.name == "station2"){
human.position.set( -242.621, 0.20+0.6, 4.90 );
}
if(object.name == "anime"){
if(scope.animastats){
scope.animastats = false;
moveanima.setplaylist(moveanima.animatelist["undefinedon"],true)
}else{
scope.animastats = true;
moveanima.setplaylist(moveanima.animatelist["undefinedoff"],true);
}
}
if(object.name == "nav"){
if(navMesh){
scope.scene.remove( navMesh );
}
if(navStatus){
navStatus = false;
}else{
navStatus = true;
pathPoints = [];
let startPoint = new THREE.Vector3(human.position.x,human.position.y-0.6,human.position.z);
pathPoints.push(new THREE.Vector3(human.position.x,human.position.y,human.position.z));
groupID = pathfinder.getGroup( ZONE, startPoint );
targetPosition = new THREE.Vector3(switchModel.matrixWorld.elements[12],-5.596,switchModel.matrixWorld.elements[14]);
//
// console.log(pathPoints[0]);
// console.log(targetPosition);
// console.log(ZONE);
// console.log(groupID);
let path = pathfinder.findPath( startPoint, targetPosition, ZONE, groupID );
}
if(object.name == "reset"){
scope.resetmodel();
}
if(object.name == "repire"){
if(nowdevice){
let command = {
code:nowdevice.code,
faultType:nowdevice.fault,
};
sendCommandNew(group,"Cancel_Fault", command).then((response) => {
resolve(response);
if(response.code == 200){
nowdevice = null;
if(path){
for(let i=0;i<path.length;i++){
pathPoints.push(new THREE.Vector3(path[i].x,path[i].y+0.6,path[i].z));
}
}).catch(error => {
});
let curve = new THREE.CatmullRomCurve3(pathPoints,false);
var geometry = new THREE.TubeGeometry( curve, 100, 0.2, 50, false );
navMesh = new THREE.Mesh( geometry, materialNav );
scope.scene.add( navMesh );
}
}
}
if(object.name == "reset"){
scope.resetmodel();
}
if(object.name == "repire"){
if(nowdevice){
let command = {
code:nowdevice.code,
faultType:nowdevice.fault,
};
sendCommandNew(group,"Cancel_Fault", command).then((response) => {
resolve(response);
if(response.code == 200){
nowdevice = null;
}
}).catch(error => {
});
}
}
}
}else{
var intersections = getIntersections( controller );
// console.log(intersections);
@ -455,6 +460,7 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
vrPlaneStatus = false;
// vrPlane.group.position.copy(circle.position);
vrPlane.group.position.set(10000,10000,10000);
scope.scene.remove( vrPlane.group );
}else{
vrPlaneStatus = true;
@ -467,34 +473,34 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
this.animationmsgshowon = function(nowobject){
scope.animationmodel = nowobject;
if(helpbox){
scope.animationmodel.helpbox = null;
scope.scene.remove( helpbox );
helpbox = undefined;
}
// if(helpbox){
// scope.animationmodel.helpbox = null;
// scope.scene.remove( helpbox );
// helpbox = undefined;
// }
// settext(scope.animationmodel,scope.animationmodel.position);
// console.log(scope.animationmodel);
helpbox = new THREE.BoxHelper( scope.animationmodel, 0xff0000 );
moveanima.updatehelpbox(helpbox,textplane);
// helpbox = new THREE.BoxHelper( scope.animationmodel, 0xff0000 );
// moveanima.updatehelpbox(helpbox,textplane);
// settext(intersects[0].object,intersects[0].point);
// getdevicemsg(intersects[0].object.name);
scope.scene.add( helpbox );
// scope.scene.add( helpbox );
getdevicemsg(nowobject.name);
}
this.animationmsgshowoff = function(nowobject){
if(helpbox){
scope.animationmodel.helpbox = null;
scope.scene.remove( helpbox );
helpbox = undefined;
}
if(textplane){
scope.scene.remove(textplane);
textplane.geometry.dispose();
textplane.material.dispose();
}
scope.animationmodel = null;
// if(helpbox){
// scope.animationmodel.helpbox = null;
// scope.scene.remove( helpbox );
// helpbox = undefined;
// }
// if(textplane){
// scope.scene.remove(textplane);
// textplane.geometry.dispose();
// textplane.material.dispose();
// }
// scope.animationmodel = null;
}
function getGuiButton( controller ) {
@ -628,7 +634,7 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
console.log(intersects);
console.log(plane);
if(intersects.text){
let textgeometry = new THREE.PlaneBufferGeometry( 0.6, 0.4, 1 );
let textgeometry = new THREE.PlaneBufferGeometry( 1.2, 0.8, 1 );
let textt = new THREE.CanvasTexture(getTextCanvas(intersects));
let textmaterial = new THREE.MeshBasicMaterial( {
side: THREE.DoubleSide,
@ -643,7 +649,7 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
textplane= new THREE.Mesh( textgeometry, textmaterial );
// textplane.name = data[i].code;
textplane.position.x = 0;
textplane.position.y = 0.8;
textplane.position.y = 1.55;
textplane.position.z = 0.01;
// console.log(textplane.position);
// textplane.tcode = data[i].code;

View File

@ -2,7 +2,7 @@ export function VrGui(){
let scope = this;
this.group = new THREE.Group();
var geometryPlane = new THREE.PlaneBufferGeometry( 0.7, 1, 16);
var geometryPlane = new THREE.PlaneBufferGeometry( 1.4, 2, 16);
var texturePlane = new THREE.TextureLoader().load( '../../static/texture/devicemsgpane.png' );
var materialPlane = new THREE.MeshBasicMaterial( {
map: texturePlane,
@ -10,13 +10,13 @@ export function VrGui(){
transparent: true,
} );
var plane = new THREE.Mesh( geometryPlane, materialPlane );
plane.position.y = 0.6;
plane.position.y = 1.1;
// plane.position.z = -1.5;
// plane.rotation.x = -Math.PI/6;
scope.group.add( plane );
var geometry = new THREE.PlaneBufferGeometry( 0.15, 0.15, 16 );
var geometry = new THREE.PlaneBufferGeometry( 0.3, 0.3, 16 );
var textureshebei = new THREE.TextureLoader().load( '../../static/vrtest/shebei.png' );
@ -26,8 +26,8 @@ export function VrGui(){
} );
var buttonShiBei = new THREE.Mesh( geometry, material );
buttonShiBei.name = "shebeijian";
buttonShiBei.position.x = -0.24;
buttonShiBei.position.y = -0.13;
buttonShiBei.position.x = -0.45;
buttonShiBei.position.y = -0.15;
buttonShiBei.position.z = 0.01;
plane.add( buttonShiBei );
@ -38,8 +38,8 @@ export function VrGui(){
} );
var buttonZhankong = new THREE.Mesh( geometry, material );
buttonZhankong.name = "jiankongshi";
buttonZhankong.position.x = -0.08;
buttonZhankong.position.y = -0.13;
buttonZhankong.position.x = -0.15;
buttonZhankong.position.y = -0.15;
buttonZhankong.position.z = 0.01;
plane.add( buttonZhankong );
@ -52,8 +52,8 @@ export function VrGui(){
} );
var buttonStation1 = new THREE.Mesh( geometry, material );
buttonStation1.name = "station1";
buttonStation1.position.x = 0.08;
buttonStation1.position.y = -0.13;
buttonStation1.position.x = 0.15;
buttonStation1.position.y = -0.15;
buttonStation1.position.z = 0.01;
plane.add( buttonStation1 );
@ -64,8 +64,8 @@ export function VrGui(){
} );
var buttonStation2 = new THREE.Mesh( geometry, material );
buttonStation2.name = "station2";
buttonStation2.position.x = 0.24;
buttonStation2.position.y = -0.13;
buttonStation2.position.x = 0.45;
buttonStation2.position.y = -0.15;
buttonStation2.position.z = 0.01;
plane.add( buttonStation2 );
@ -76,8 +76,8 @@ export function VrGui(){
} );
var button1 = new THREE.Mesh( geometry, material );
button1.name = "nav";
button1.position.x = -0.24;
button1.position.y = -0.3;
button1.position.x = -0.45;
button1.position.y = -0.6;
button1.position.z = 0.01;
plane.add( button1 );
@ -88,8 +88,8 @@ export function VrGui(){
} );
var buttonnav = new THREE.Mesh( geometry, material );
buttonnav.name = "anime";
buttonnav.position.x = -0.08;
buttonnav.position.y = -0.3;
buttonnav.position.x = -0.15;
buttonnav.position.y = -0.6;
buttonnav.position.z = 0.01;
plane.add( buttonnav );
@ -102,20 +102,20 @@ export function VrGui(){
} );
var button2 = new THREE.Mesh( geometry, material );
button2.name = "reset";
button2.position.x = 0.08;
button2.position.y = -0.3;
button2.position.x = 0.15;
button2.position.y = -0.6;
button2.position.z = 0.01;
plane.add( button2 );
var texture = new THREE.TextureLoader().load( '../../static/texture/xiuli.png' );
var texture = new THREE.TextureLoader().load( '../../static/vrtest/repire.png' );
var material = new THREE.MeshBasicMaterial( {
map: texture,
transparent: true,
} );
var buttonreset = new THREE.Mesh( geometry, material );
buttonreset.name = "repire";
buttonreset.position.x = 0.24;
buttonreset.position.y = -0.3;
buttonreset.position.x = 0.45;
buttonreset.position.y = -0.6;
buttonreset.position.z = 0.01;
plane.add( buttonreset );

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 2.0 MiB

BIN
static/vrtest/daohang1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
static/vrtest/repire.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.