This commit is contained in:
fan 2021-09-29 13:19:49 +08:00
commit 869840f0e2
5 changed files with 926 additions and 3 deletions

View File

@ -6,6 +6,9 @@ export function ZzwwTrain() {
tittle:"防溜防护检查",
text:"",
devices:[
{
},
{
id:"ZLQ",
name:"止轮器",

View File

@ -0,0 +1,707 @@
import { Capsule } from '@/jlmap3d/lesson3d/math/Capsule.js';
import { Octree } from '@/jlmap3d/lesson3d/math/Octree.js';
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
import { OBJLoader } from '@/jlmap3d/main/loaders/OBJLoader';
export function ControlManager(dom,scene,lessonData,lessonIndex) {
let scope = this;
this.controlMode = "";
this.controls = {};
this.nowCamera = null;
this.eventHitMode = false;
let modelManager;
let nowRole = "";
let roleMode = false;
let examList = {};
let examData = {};
let eventBoxs = [];
let raycasterBoxs = [];
let actionList = [];
let eventTrigger;
let nowActions;
let trainDeviceMode = false;
let trainDeviceList = [];
let renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setClearColor(new THREE.Color(0x000000));
renderer.setViewport( 0, 0, dom.offsetWidth, dom.offsetHeight);
renderer.setScissor( 0, 0, dom.offsetWidth, dom.offsetHeight);
renderer.setScissorTest( false );
renderer.setSize(dom.offsetWidth, dom.offsetHeight);
renderer.sortObjects = true;
dom.appendChild(renderer.domElement);
let orbitCamera = new THREE.PerspectiveCamera(70, dom.offsetWidth / dom.offsetHeight, 0.01, 1000);
orbitCamera.position.set(0, 80, 40);
orbitCamera.aspect = dom.offsetWidth / dom.offsetHeight;
orbitCamera.updateProjectionMatrix();
let oribitControl = new THREE.OrbitControls(orbitCamera,dom);
oribitControl.maxPolarAngle = Math.PI / 2;
oribitControl.minPolarangle = Math.PI / 5;
oribitControl.maxDistance = 800;
oribitControl.screenSpacePanning = true;
oribitControl.update();
let fpsCamera = new THREE.PerspectiveCamera( 75,dom.offsetWidth / dom.offsetHeight, 0.1, 1000 );
fpsCamera.aspect = dom.offsetWidth / dom.offsetHeight;
fpsCamera.rotation.order = 'YXZ';
let attachBox = new THREE.Mesh(
new THREE.BoxGeometry(1, 5, 1),
new THREE.MeshBasicMaterial({color: 0xff00000,transparent: true,opacity: 0 })//RED box
);
let hitBox = new THREE.Box3(new THREE.Vector3(), new THREE.Vector3());
hitBox.setFromObject(attachBox);
scene.add(attachBox);
//fps control
const GRAVITY = 30;
const NUM_SPHERES = 20;
const SPHERE_RADIUS = 0.1;
const sphereGeometry = new THREE.SphereGeometry( SPHERE_RADIUS, 16, 16 );
const sphereMaterial = new THREE.MeshStandardMaterial( { color: 0x888855, roughness: 0.8, metalness: 0.5, } );
const spheres = [];
let sphereIdx = 0;
for ( let i = 0; i < NUM_SPHERES; i ++ ) {
const sphere = new THREE.Mesh( sphereGeometry, sphereMaterial );
scene.add( sphere );
spheres.push( { mesh: sphere, collider: new THREE.Sphere( new THREE.Vector3( 0, - 100, 0 ), SPHERE_RADIUS ), velocity: new THREE.Vector3() } );
}
let loaderObj = new THREE.OBJLoader();
let standstationPZ,stopstationPZ,occPZ;
// load a resource
loaderObj.load(
JL3D_LOCAL_STATIC+'/lesson3d/standstationPZ.obj',
function ( object ) {
standstationPZ = object;
},
function ( xhr ) {
console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
},
function ( error ) {
console.log( 'An error happened' );
}
);
loaderObj.load(
JL3D_LOCAL_STATIC+'/lesson3d/stopstationPZ.obj',
function ( object ) {
stopstationPZ = object;
},
function ( xhr ) {
console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
},
function ( error ) {
console.log( 'An error happened' );
}
);
loaderObj.load(
JL3D_LOCAL_STATIC+'/lesson3d/occPZ.obj',
function ( object ) {
occPZ = object;
},
function ( xhr ) {
console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
},
function ( error ) {
console.log( 'An error happened' );
}
);
this.initRoleMode = function(rMode,role){
roleMode = rMode;
nowRole = role;
// console.log(roleMode);
};
this.initExam = function(newExamList,newExamData){
examList = newExamList;
examData = newExamData;
};
function updateExam(){
updataExamStatus(examData);
}
const worldOctree = new Octree();
const playerCollider = new Capsule( new THREE.Vector3( 0, 10, 0 ), new THREE.Vector3( 0, 11.9, 0 ), 1 );
// playerCollider.set(
// new THREE.Vector3(
// lessonData.lessonProgress[lessonIndex].cameraPosition.x,
// lessonData.lessonProgress[lessonIndex].cameraPosition.y,
// lessonData.lessonProgress[lessonIndex].cameraPosition.z),
// new THREE.Vector3(
// lessonData.lessonProgress[lessonIndex].cameraPosition.x,
// lessonData.lessonProgress[lessonIndex].cameraPosition.y+1.5,
// lessonData.lessonProgress[lessonIndex].cameraPosition.z ), 1);
// attachBox.position.x = lessonData.lessonProgress[lessonIndex].cameraPosition.x;
// attachBox.position.y = lessonData.lessonProgress[lessonIndex].cameraPosition.y ;
// attachBox.position.z = lessonData.lessonProgress[lessonIndex].cameraPosition.z;
const playerVelocity = new THREE.Vector3();
const playerDirection = new THREE.Vector3();
let playerOnFloor = false;
const keyStates = {};
let clock = new THREE.Clock();
this.updateOrbitControl = function(){
oribitControl.update();
render(orbitCamera);
};
this.updateFpsControl = function(){
const deltaTime = Math.min( 0.1, clock.getDelta() );
controls( deltaTime );
updatePlayer( deltaTime );
updateSpheres( deltaTime );
// console.log(scope.eventHitMode);
// console.log(roleMode);
if(scope.eventHitMode == true && roleMode){
if(eventBoxs.length>0){
attachBox.position.copy(fpsCamera.position);
for(let i=0;i<eventBoxs.length;i++){
hitBox.setFromObject(attachBox);
eventBoxs[i].setFromObject(eventBoxs[i].mesh);
// console.log(eventBoxs[i]);
if(hitBox.intersectsBox(eventBoxs[i])){
// console.log("相交");
// console.log(eventBoxs[i].action);
if(eventBoxs[i].action.actionMode == "remove"){
actionEvent("remove",eventBoxs[i].action,eventBoxs[i].mesh);
}
if(eventBoxs[i].action.actionMode == "jump"){
jumpEvent("action",eventBoxs[i].action);
actionEvent("remove",eventBoxs[i].action,eventBoxs[i].mesh);
}
// console.log("slice");
eventBoxs.splice(i,1);
i--;
}
}
}else{
scope.eventHitMod = false;
}
// attachBox.position.copy(fpsCamera.position);
// hitBox.setFromObject(attachBox);
// eventTestBox.setFromObject(eventBox);
//
// if(hitBox.intersectsBox(eventTestBox)){
// //两个物体相交了
// console.log("相交");
// scope.eventHitMode = false;
// }
// else{
// console.log("不相交");
// }
}
render(fpsCamera);
};
this.init = function(actions,assetModelManager,trainDeviceData){
// worldOctree.fromGraphNode( standstationPZ );
actionList = actions;
modelManager = assetModelManager;
if(trainDeviceData){
trainDeviceMode = true;
trainDeviceList = trainDeviceData;
}
}
this.updatePos = function(pos){
playerCollider.set(
new THREE.Vector3(
pos.x,
pos.y,
pos.z),
new THREE.Vector3(
pos.x,
pos.y+1.5,
pos.z ), 1);
}
document.addEventListener( 'keydown', ( event ) => {
keyStates[ event.code ] = true;
} );
document.addEventListener( 'keyup', ( event ) => {
keyStates[ event.code ] = false;
} );
let fpsMouseStatus = false;
document.addEventListener( 'mousedown', (event) => {
fpsMouseStatus = true;
// document.body.requestPointerLock();
console.log("mousedown-----------------------");
console.log(raycasterBoxs);
console.log(roleMode);
if(raycasterBoxs.length>0 && roleMode){
var mouse = new THREE.Vector2();
var raycaster = new THREE.Raycaster();
mouse.x = ( event.clientX / dom.offsetWidth ) * 2 - 1;
mouse.y = - ( event.clientY / dom.offsetHeight ) * 2 + 1;
raycaster.setFromCamera(mouse,scope.nowCamera) // 也可以给构造函数传参的形式写
for(let i=0;i<raycasterBoxs.length;i++){
var intersects = raycaster.intersectObject( raycasterBoxs[i].mesh,true);
if(intersects.length>0){
if(raycasterBoxs[i].type == "switch"){
if(raycasterBoxs[i].actionMode == "jump"){
actionEvent("remove",raycasterBoxs[i],raycasterBoxs[i].mesh);
jumpEvent("action",raycasterBoxs[i]);
}else{
if(raycasterBoxs[i].action.status == "01"){
raycasterBoxs[i].action.status = "02";
raycasterBoxs[i].action.action.play();
}else if(raycasterBoxs[i].action.status == "02"){
raycasterBoxs[i].action.status = "01";
raycasterBoxs[i].action.action.stop();
}
}
}else if(raycasterBoxs[i].type == "urgeSwitch"){
console.log(raycasterBoxs[i]);
if(raycasterBoxs[i].action.status == "02"){
raycasterBoxs[i].action.status = "01";
raycasterBoxs[i].action.action.stop();
}
}
}
}
}
if(trainDeviceMode == true){
var mouse = new THREE.Vector2();
var raycaster = new THREE.Raycaster();
mouse.x = ( event.clientX / dom.offsetWidth ) * 2 - 1;
mouse.y = - ( event.clientY / dom.offsetHeight ) * 2 + 1;
raycaster.setFromCamera(mouse,scope.nowCamera);
var intersects = raycaster.intersectObject( modelManager.otherModel.children[1],true);
if(intersects.length>0){
jl3dZzwwTrainTestUpdate(intersects[0].object.name);
}
}
} );
document.body.addEventListener( 'mousemove', ( event ) => {
if(fpsMouseStatus == true){
fpsCamera.rotation.y -= event.movementX / 500;
fpsCamera.rotation.x -= event.movementY / 500;
}
// if ( document.pointerLockElement === document.body ) {
// }
} );
document.addEventListener( 'mouseup', () => {
fpsMouseStatus = false;
} );
function playerCollitions() {
const result = worldOctree.capsuleIntersect( playerCollider );
playerOnFloor = false;
if ( result ) {
playerOnFloor = result.normal.y > 0;
if ( ! playerOnFloor ) {
playerVelocity.addScaledVector( result.normal, - result.normal.dot( playerVelocity ) );
}
playerCollider.translate( result.normal.multiplyScalar( result.depth ) );
}
}
function updatePlayer( deltaTime ) {
if ( playerOnFloor ) {
const damping = Math.exp( - 3 * deltaTime ) - 1;
playerVelocity.addScaledVector( playerVelocity, damping );
} else {
playerVelocity.y -= GRAVITY * deltaTime;
}
const deltaPosition = playerVelocity.clone().multiplyScalar( deltaTime );
playerCollider.translate( deltaPosition );
playerCollitions();
fpsCamera.position.copy( playerCollider.end );
}
function spheresCollisions() {
for ( let i = 0; i < spheres.length; i ++ ) {
const s1 = spheres[ i ];
for ( let j = i + 1; j < spheres.length; j ++ ) {
const s2 = spheres[ j ];
const d2 = s1.collider.center.distanceToSquared( s2.collider.center );
const r = s1.collider.radius + s2.collider.radius;
const r2 = r * r;
if ( d2 < r2 ) {
const normal = s1.collider.clone().center.sub( s2.collider.center ).normalize();
const v1 = normal.clone().multiplyScalar( normal.dot( s1.velocity ) );
const v2 = normal.clone().multiplyScalar( normal.dot( s2.velocity ) );
s1.velocity.add( v2 ).sub( v1 );
s2.velocity.add( v1 ).sub( v2 );
const d = ( r - Math.sqrt( d2 ) ) / 2;
s1.collider.center.addScaledVector( normal, d );
s2.collider.center.addScaledVector( normal, - d );
}
}
}
}
function updateSpheres( deltaTime ) {
spheres.forEach( sphere =>{
sphere.collider.center.addScaledVector( sphere.velocity, deltaTime );
const result = worldOctree.sphereIntersect( sphere.collider );
if ( result ) {
sphere.velocity.addScaledVector( result.normal, - result.normal.dot( sphere.velocity ) * 1.5 );
sphere.collider.center.add( result.normal.multiplyScalar( result.depth ) );
} else {
sphere.velocity.y -= GRAVITY * deltaTime;
}
const damping = Math.exp( - 1.5 * deltaTime ) - 1;
sphere.velocity.addScaledVector( sphere.velocity, damping );
spheresCollisions();
sphere.mesh.position.copy( sphere.collider.center );
} );
}
function getForwardVector() {
fpsCamera.getWorldDirection( playerDirection );
playerDirection.y = 0;
playerDirection.normalize();
return playerDirection;
}
function getSideVector() {
fpsCamera.getWorldDirection( playerDirection );
playerDirection.y = 0;
playerDirection.normalize();
playerDirection.cross( fpsCamera.up );
return playerDirection;
}
function controls( deltaTime ) {
const speed = 25;
if ( playerOnFloor ) {
if ( keyStates[ 'KeyW' ] ) {
playerVelocity.add( getForwardVector().multiplyScalar( speed * deltaTime ) );
}
if ( keyStates[ 'KeyS' ] ) {
playerVelocity.add( getForwardVector().multiplyScalar( - speed * deltaTime ) );
}
if ( keyStates[ 'KeyA' ] ) {
playerVelocity.add( getSideVector().multiplyScalar( - speed * deltaTime ) );
}
if ( keyStates[ 'KeyD' ] ) {
playerVelocity.add( getSideVector().multiplyScalar( speed * deltaTime ) );
}
if ( keyStates[ 'Space' ] ) {
playerVelocity.y = 10;
}
}
}
function render(camera){
renderer.render( scene, camera );
}
window.onresize = function () {
renderer.setSize(dom.offsetWidth,dom.offsetHeight);
}
this.initControlMode = function(nowLessonIndex){
// console.log(lessonData.lessonProgress[nowLessonIndex].progressScene);
if(lessonData.lessonProgress[nowLessonIndex].progressScene == "standstation"){
worldOctree.fromGraphNode( standstationPZ );
}else if(lessonData.lessonProgress[nowLessonIndex].progressScene == "stopstation"){
worldOctree.fromGraphNode( stopstationPZ );
}else if(lessonData.lessonProgress[nowLessonIndex].progressScene == "occ"){
worldOctree.fromGraphNode( occPZ );
}
if((lessonData.lessonProgress[nowLessonIndex].changeCamera == true && lessonData.lessonProgress[nowLessonIndex].roleName == nowRole) || nowLessonIndex == 0 || lessonData.lessonProgress[nowLessonIndex].roleName== 'kong'){
scope.controlMode = lessonData.lessonProgress[nowLessonIndex].controlMode;
if(scope.controlMode == "free" || scope.controlMode == "non"){
scope.nowCamera = orbitCamera;
oribitControl.enabled = true;
orbitCamera.position.x = lessonData.lessonProgress[nowLessonIndex].cameraPosition.x;
orbitCamera.position.y = lessonData.lessonProgress[nowLessonIndex].cameraPosition.y;
orbitCamera.position.z = lessonData.lessonProgress[nowLessonIndex].cameraPosition.z;
oribitControl.target = new THREE.Vector3(lessonData.lessonProgress[nowLessonIndex].cameraTarget.x,lessonData.lessonProgress[nowLessonIndex].cameraTarget.y,lessonData.lessonProgress[nowLessonIndex].cameraTarget.z);
scope.updateOrbitControl();
if(scope.controlMode == "non"){
oribitControl.enabled = false;
}
}else if(scope.controlMode == "fps"){
scope.nowCamera = fpsCamera;
oribitControl.enabled = false;
playerCollider.set(
new THREE.Vector3(
lessonData.lessonProgress[nowLessonIndex].cameraPosition.x,
lessonData.lessonProgress[nowLessonIndex].cameraPosition.y,
lessonData.lessonProgress[nowLessonIndex].cameraPosition.z),
new THREE.Vector3(
lessonData.lessonProgress[nowLessonIndex].cameraPosition.x,
lessonData.lessonProgress[nowLessonIndex].cameraPosition.y+1.5,
lessonData.lessonProgress[nowLessonIndex].cameraPosition.z ), 1);
attachBox.position.x = lessonData.lessonProgress[nowLessonIndex].cameraPosition.x;
attachBox.position.y = lessonData.lessonProgress[nowLessonIndex].cameraPosition.y ;
attachBox.position.z = lessonData.lessonProgress[nowLessonIndex].cameraPosition.z;
}
}
}
this.changeIndexEvent = function(actions,rMode,lessonTriggerList){
eventTrigger = lessonTriggerList;
nowActions = actions;
// let newEventBoxs = [];
// eventBoxs = newEventBoxs;
raycasterBoxs = [];
roleMode = rMode;
// console.log("---------changeIndex--------");
// console.log(actions);
// console.log(roleMode);
// console.log(eventTrigger);
// console.log("----------------------------");
console.log(roleMode);
if(actions.length>0 ){
scope.eventHitMode = true;
for(let i=0;i<actions.length;i++){
if(actions[i].actionType == "auto"){
console.log(actions[i]);
if(actions[i].actionMode == "play"){
for(let j=0;j<eventTrigger.length;j++){
if(eventTrigger[j].label == actions[i].actionModel){
if(actionList[eventTrigger[j].actionName].status == "01"){
actionList[eventTrigger[j].actionName].status = "02";
actionList[eventTrigger[j].actionName].action.reset();
actionList[eventTrigger[j].actionName].action.timeScale = 1;
actionList[eventTrigger[j].actionName].action.clampWhenFinished = true;
actionList[eventTrigger[j].actionName].action.setLoop(THREE.LoopOnce);
actionList[eventTrigger[j].actionName].action.play();
}else{
actionList[eventTrigger[j].actionName].status = "01";
actionList[eventTrigger[j].actionName].action.reset();
actionList[eventTrigger[j].actionName].action.timeScale = -1;
actionList[eventTrigger[j].actionName].action.clampWhenFinished = true;
actionList[eventTrigger[j].actionName].action.setLoop(THREE.LoopOnce);
actionList[eventTrigger[j].actionName].action.play();
}
}
}
}
if(actions[i].actionMode == "show"){
for(let j=0;j<eventTrigger.length;j++){
if(eventTrigger[j].label == actions[i].actionModel){
actionEvent("show",actions[i],eventTrigger[j]);
j = eventTrigger.length;
}
}
}
if(actions[i].actionMode == "remove"){
for(let j=0;j<eventTrigger.length;j++){
if(eventTrigger[j].label == actions[i].actionModel){
actionEvent("remove",actions[i],eventTrigger[j]);
j = eventTrigger.length;
}
}
}
}
if(roleMode){
if(actions[i].actionType == "contact"){
if(eventTrigger){
for(let j=0;j<eventTrigger.length;j++){
if(eventTrigger[j].label == actions[i].actionModel){
let eventTestBox = new THREE.Box3(new THREE.Vector3(), new THREE.Vector3());
eventTestBox.setFromObject(eventTrigger[j]);
eventTestBox.mesh = eventTrigger[j];
eventTestBox.action = actions[i];
eventBoxs.push(eventTestBox);
actionEvent("changeIndex",eventBoxs[i].action,eventTestBox.mesh);
}
}
}
}
if(actions[i].actionType == "switch"){
for(let j=0;j<eventTrigger.length;j++){
if(eventTrigger[j].label == actions[i].actionModel){
let eventRaycaster = {
mesh:eventTrigger[j],
action:actionList[eventTrigger[j].actionName],
type:actions[i].actionType,
actionMode:actions[i].actionMode,
jumpNode:actions[i].jumpNode,
};
raycasterBoxs.push(eventRaycaster);
actionEvent("changeIndex",actions[i],eventTrigger[j]);
}
}
}
if(actions[i].actionType == "urgeSwitch"){
for(let j=0;j<eventTrigger.length;j++){
if(eventTrigger[j].label == actions[i].actionModel){
let eventRaycaster = {
mesh:eventTrigger[j],
action:actionList[eventTrigger[j].actionName],
type:actions[i].actionType,
};
raycasterBoxs.push(eventRaycaster);
}
}
}
}
}
}else if(actions.length>0){
// console.log(actions);
}
};
}

View File

@ -0,0 +1,213 @@
import store from '@/store/index';
// import { Loading } from 'element-ui';
import {Stats} from '@/jlmap3d/main/lib/stats.min.js';
//静态资源文件路径
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
//loader
import { FBXLoader } from '@/jlmap3d/main/loaders/FBXLoader';
//轨道视角控制
import { OrbitControls } from '@/jlmap3d/main/control/OrbitControls';
//骨骼动画模型辅助工具
import { SkeletonUtils } from '@/jlmap3d/main/utils/SkeletonUtils.js';
import { AssetModelManager } from '@/jlmap3d/lesson3d/manager/assetmodelmanager.js';
import { ControlManager } from '@/jlmap3d/otherproject/zzww/manager/controlmanager.js';
import { AnimateManager } from '@/jlmap3d/lesson3d/manager/animatemanager.js';
import { Fire } from '@/jlmap3d/lesson3d/utils/fire.js';
// import { AnimationManager } from '@/jlmap3d/lesson3d/manager/assetmodelmanager.js';
let scene;
export function ZzWw(dom,lessonData,lessonIndex) {
// let stats = new Stats();
// dom.appendChild( stats.dom );
let scope = this;
this.dom = dom;
this.nowSceneType = "";
//定义当前课程角色
let nowRole = "";
let oldIndex = 0;
//考试课程
let examList = [];
let examData = {};
//定义场景(渲染容器)
scene = new THREE.Scene();
scene.background = new THREE.Color(0xa0a0a0);
//定义全局光
let ambientLight = new THREE.AmbientLight(0xffffff, 1.3);
scene.add(ambientLight);
var light = new THREE.HemisphereLight( 0xffffff, 0x444444 );
light.position.set( 0, 4000, 0 );
scene.add( light );
// let fire = new Fire();
// fire.init(scene);
let animateManager = new AnimateManager();
let controlManager = new ControlManager( dom,scene,lessonData,lessonIndex);
let assetModelManager = new AssetModelManager(scope,scene,controlManager);
assetModelManager.lessonAssetsLoader(lessonData).then((result) => {
scope.nowSceneType = lessonData.lessonProgress[0].progressScene;
animateManager.initAnimation(assetModelManager);
controlManager.init(animateManager.actions,assetModelManager,lessonData.trainDeviceData);
startLesson();
animate();
resolve("loadeend"); //['成功了', 'success']
}).catch((error) => {
//console.log(error);
});
this.actionModelControl = function(actionType,actionModel){
// console.log(actionType);
// console.log(actionModel);
if(actionType == "remove"){
assetModelManager.otherModel.remove(actionModel);
}else if(actionType == "show"){
actionModel.visible = true;
assetModelManager.otherModel.add(actionModel);
}else if(actionType == "changeIndex"){
actionModel.visible = true;
assetModelManager.otherModel.add(actionModel);
}
}
this.actionRemove = function(actionModel){
}
this.changeIndex = function(nowIndex){
if(nowIndex!=0){
oldIndex = lessonIndex;
if(lessonData.lessonProgress[oldIndex].roleName == nowRole){
updateExam(lessonData.lessonProgress[oldIndex],oldIndex);
}
}
lessonIndex = nowIndex;
// console.log(nowIndex);
scope.nowSceneType = lessonData.lessonProgress[nowIndex].progressScene;
// console.log(nowRole);
// console.log(lessonData.lessonProgress[lessonIndex].roleName);
if(lessonData.lessonProgress[lessonIndex].roleName == nowRole){
assetModelManager.changeSceneGroup(scope.nowSceneType);
controlManager.initRoleMode(true,nowRole);
controlManager.initControlMode(lessonIndex);
controlManager.changeIndexEvent(lessonData.lessonProgress[lessonIndex].action,true,assetModelManager.lessonTriggerList[scope.nowSceneType]);
} else{
if(lessonData.lessonProgress[lessonIndex].roleName == 'kong'){
assetModelManager.changeSceneGroup(scope.nowSceneType); controlManager.initRoleMode(false,nowRole);
}
controlManager.initRoleMode(false,nowRole);
controlManager.initControlMode(lessonIndex);
controlManager.changeIndexEvent(lessonData.lessonProgress[lessonIndex].action,false,assetModelManager.lessonTriggerList[scope.nowSceneType]);
}
if(nowIndex == (lessonData.lessonProgress.length-1)){
console.log(nowIndex);
console.log(lessonData.lessonProgress.length);
lessonEnd();
}
}
this.changeCameraPos = function(pos){
controlManager.updatePos(pos);
}
this.initNowRole = function(role){
if(role){
nowRole = role;
controlManager.initControlMode(lessonIndex);
let roleMode = false;
if(lessonData.lessonProgress[lessonIndex].roleName == nowRole){
roleMode = true;
}
controlManager.initRoleMode(roleMode);
for(let i=0;i<lessonData.lessonProgress.length;i++){
if(nowRole == lessonData.lessonProgress[i].roleName){
examList.push(
{
index:i,
score:10,
isTrue:false,
}
);
}
}
examData = {
allScore:examList.length*10,
lastScore:0,
allStep:examList.length,
trueStep:[],
falseStep:[],
nowStep:0,
time:0,
};
controlManager.initExam(examList,examData);
// updataExamStatus(examData);
// if(lessonData.lessonProgress[lessonIndex].action.length>0){
controlManager.changeIndexEvent(lessonData.lessonProgress[lessonIndex].action,roleMode,assetModelManager.lessonTriggerList[scope.nowSceneType]);
}else{
controlManager.changeIndexEvent(lessonData.lessonProgress[lessonIndex].action,false,assetModelManager.lessonTriggerList[scope.nowSceneType]);
}
// }
};
function updateExam(newIndexData,newIndex){
for(let i=0;i<examList.length;i++){
if(examList[i].index == newIndex){
examData.trueStep.push(newIndexData);
examData.lastScore += 10;
examData.nowStep += 1;
updataExamStatus(examData);
break;
}
}
}
//循环渲染函数
function animate() {
if(controlManager.controlMode == "free"){
controlManager.updateOrbitControl();
}
if(controlManager.controlMode == "fps"){
controlManager.updateFpsControl();
}
if(controlManager.controlMode == "non"){
controlManager.updateOrbitControl();
}
// fire.update();
animateManager.updateAnimation();
requestAnimationFrame(animate);
}
this.attachModel = function(selectModel){
}
}

View File

@ -17,7 +17,7 @@ const Jlmap3dLesson3dEdit = () => import('@/views/jlmap3d/lesson3dedit/lesson3de
const Jlmap3dLesson3dPlayer = () => import('@/views/jlmap3d/lesson3dplayer/lesson3dplayer');
const Jlmap3dLesson3dSelect = () => import('@/views/jlmap3d/lesson3dplayer/lesson3dselect');
const Jlmap3dZzwwTest = () => import('@/views/jlmap3d/zzwwtest/zzwwtest');
const Jlmap3dZzwwTest = () => import('@/views/jlmap3d/otherproject/zzww/zzwwtest');
const Jlmap3d = () => import('@/views/jlmap3d/drive/jl3ddrive');

View File

@ -147,7 +147,7 @@
import TrainTestPane from '@/views/jlmap3d/lesson3dplayer/tools/traintestpane';
import { Lesson3dPlayer } from '@/jlmap3d/lesson3d/lesson3dplayer.js';
import { ZzWw } from '@/jlmap3d/otherproject/zzww/zzww.js';
import { LessonData } from '@/jlmap3d/lesson3d/model/lessondata.js';
import { JobPaneData } from '@/jlmap3d/lesson3d/toolsmodel/jobpanedata.js';
@ -310,7 +310,7 @@
// console.log("loaddata----------------");
// console.log(loadData);
// console.log(this.lessonMsg);
this.jl3d = new Lesson3dPlayer(dom,loadData,this.lessonPlayIndex);
this.jl3d = new ZzWw(dom,loadData,this.lessonPlayIndex);
}).catch(() => {
});
},