增加静态测试模型,修改三维课程播放器模型触发器模块,增加三维动画模块,修改课程信息模块

This commit is contained in:
sunzhenyu 2021-04-29 17:55:55 +08:00
parent cf930c1e72
commit 2f60a7a352
21 changed files with 6053 additions and 136 deletions

View File

@ -14,13 +14,12 @@ import { AssetModelManager } from '@/jlmap3d/lesson3d/manager/assetmodelmanager.
import { ControlManager } from '@/jlmap3d/lesson3d/manager/controlmanager.js'; import { ControlManager } from '@/jlmap3d/lesson3d/manager/controlmanager.js';
import { AnimateManager } from '@/jlmap3d/lesson3d/manager/animatemanager.js';
// import { AnimationManager } from '@/jlmap3d/lesson3d/manager/assetmodelmanager.js'; // import { AnimationManager } from '@/jlmap3d/lesson3d/manager/assetmodelmanager.js';
//动画播放相关
let clock = new THREE.Clock();
let delta;
let scene; let scene;
export function Lesson3dPlayer(dom,lessonData,lessonIndex) { export function Lesson3dPlayer(dom,lessonData,lessonIndex) {
@ -45,21 +44,28 @@ export function Lesson3dPlayer(dom,lessonData,lessonIndex) {
light.position.set( 0, 4000, 0 ); light.position.set( 0, 4000, 0 );
scene.add( light ); scene.add( light );
let animateManager = new AnimateManager();
let controlManager = new ControlManager( dom,scene,lessonData,lessonIndex); let controlManager = new ControlManager( dom,scene,lessonData,lessonIndex);
let assetModelManager = new AssetModelManager(scene,controlManager); let assetModelManager = new AssetModelManager(scene,controlManager);
assetModelManager.lessonAssetsLoader(lessonData.assetList,lessonData.modelList).then((result) => { assetModelManager.lessonAssetsLoader(lessonData.assetList,lessonData.modelList).then((result) => {
controlManager.initOctree(assetModelManager.loadAsset['default1'].mesh);
animate();
console.log(lessonData.lessonProgress[lessonIndex]); console.log(lessonData.lessonProgress[lessonIndex]);
if(lessonData.lessonProgress[lessonIndex].action.length>0){ if(lessonData.lessonProgress[lessonIndex].action.length>0){
controlManager.initNewEvent(lessonData.lessonProgress[lessonIndex].action,assetModelManager.lessonTriggerList); controlManager.changeIndexEvent(lessonData.lessonProgress[lessonIndex].action,assetModelManager.lessonTriggerList);
} }
animateManager.initAnimation(assetModelManager);
controlManager.init(animateManager.actions);
startLesson();
animate();
resolve("loadeend"); //['成功了', 'success'] resolve("loadeend"); //['成功了', 'success']
}).catch((error) => { }).catch((error) => {
//console.log(error); //console.log(error);
});; });
@ -67,7 +73,10 @@ export function Lesson3dPlayer(dom,lessonData,lessonIndex) {
assetModelManager.otherModel.remove(actionModel); assetModelManager.otherModel.remove(actionModel);
} }
this.changeIndex = function(nowIndex){
lessonIndex = nowIndex;
controlManager.changeIndexEvent(lessonData.lessonProgress[lessonIndex].action);
}
//循环渲染函数 //循环渲染函数
function animate() { function animate() {
@ -78,7 +87,7 @@ export function Lesson3dPlayer(dom,lessonData,lessonIndex) {
if(controlManager.controlMode == "fps"){ if(controlManager.controlMode == "fps"){
controlManager.updateFpsControl(); controlManager.updateFpsControl();
} }
// delta = clock.getDelta(); animateManager.updateAnimation();
requestAnimationFrame(animate); requestAnimationFrame(animate);
} }

View File

@ -0,0 +1,47 @@
export function AnimateManager() {
let scope = this;
this.animateList = [];
let mixers = [];
this.actions = [];
this.initAnimation = function(assetModelManager){
for(let k in assetModelManager.staticAsset){
if(assetModelManager.staticAsset[k].mesh.animations.length > 0){
console.log(assetModelManager.staticAsset[k].mesh.name);
let animations = assetModelManager.staticAsset[k].mesh.animations;
let mixer = new THREE.AnimationMixer( assetModelManager.staticAsset[k].mesh );
let actionName = assetModelManager.staticAsset[k].mesh.name;
console.log(actionName);
scope.actions[actionName] = {
status:"01",
action:mixer.clipAction( assetModelManager.staticAsset[k].mesh.animations[ 0 ])
};
// scope.actions[actionName].action.play();
mixers.push(mixer);
}
}
}
let clock = new THREE.Clock();
let mixerUpdateDelta;
this.updateAnimation = function(){
mixerUpdateDelta = clock.getDelta();
for(let i=mixers.length-1;i>=0;i--){
if(mixers[i]._actions[0].isRunning()){
// console.log(scope.mixers[i]._actions[0].isRunning());
mixers[i].update( mixerUpdateDelta );
}
}
}
}

View File

@ -1,4 +1,5 @@
import { BASE_ASSET_API } from '@/api/jlmap3d/assets3d.js'; import { BASE_ASSET_API } from '@/api/jlmap3d/assets3d.js';
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
export function AssetModelManager(scene) { export function AssetModelManager(scene) {
let scope = this; let scope = this;
@ -12,16 +13,58 @@ export function AssetModelManager(scene) {
this.loadAsset = []; this.loadAsset = [];
this.loadAsset['default1'] = { this.staticAsset = [];
modelId:'default1', scope.staticAsset['station'] = {
modelId:'station',
packageName:"车站", packageName:"车站",
url:"/MODEL/2021-04-06/1381-54584.FBX", url:JL3D_LOCAL_STATIC+"/lesson3d/station.FBX",
mesh:"", mesh:"",
assetType:'default', assetType:'static',
isUse:true, isUse:true,
resourceType:"三维课程", resourceType:"三维课程",
}; };
scope.staticAsset['FTDH'] = {
modelId:'FTDH',
packageName:"电扶梯",
url:JL3D_LOCAL_STATIC+"/lesson3d/FTDH.FBX",
mesh:"",
assetType:'static',
isUse:true,
resourceType:"三维课程",
};
scope.staticAsset['IN'] = {
modelId:'IN',
packageName:"进闸机",
url:JL3D_LOCAL_STATIC+"/lesson3d/IN.FBX",
mesh:"",
assetType:'static',
isUse:true,
resourceType:"三维课程",
};
scope.staticAsset['OUT'] = {
modelId:'OUT',
packageName:"出闸机",
url:JL3D_LOCAL_STATIC+"/lesson3d/OUT.FBX",
mesh:"",
assetType:'static',
isUse:true,
resourceType:"三维课程",
};
scope.staticAsset['PBMDH'] = {
modelId:'PBMDH',
packageName:"屏蔽门",
url:JL3D_LOCAL_STATIC+"/lesson3d/PBMDH.FBX",
mesh:"",
assetType:'static',
isUse:true,
resourceType:"三维课程",
};
//场景中可触发事件模型 //场景中可触发事件模型
this.lessonTriggerList = []; this.lessonTriggerList = [];
@ -31,13 +74,20 @@ export function AssetModelManager(scene) {
if(assetList){ if(assetList){
for(let i = 0;i<assetList.length;i++){ for(let i = 0;i<assetList.length;i++){
assetList[i].mesh = ""; assetList[i].mesh = "";
scope.loadAsset[assetList[i].modelId] = assetList[i]; if(assetList[i].modelId == "default1"){
}else{
scope.loadAsset[assetList[i].modelId] = assetList[i];
} }
} }
}
for(let k in scope.staticAsset){
initlist.push(fbxpromise(scope.staticAsset[k]));
}
for(let k in scope.loadAsset){ for(let k in scope.loadAsset){
initlist.push(fbxpromise(scope.loadAsset[k])); initlist.push(fbxpromise(scope.loadAsset[k]));
} }
return new Promise(function(resolve, reject){ return new Promise(function(resolve, reject){
@ -84,15 +134,21 @@ export function AssetModelManager(scene) {
//FTKG 扶梯开关(钥匙孔) //FTKG 扶梯开关(钥匙孔)
//FTTJ 扶梯台阶 //FTTJ 扶梯台阶
function initTriggerList(){ function initTriggerList(){
scope.staticAsset['station'].mesh.getObjectByName("FTAN").showType = "default";
scope.staticAsset['station'].mesh.getObjectByName("FTAN").label = "扶梯急停按钮";
scope.staticAsset['station'].mesh.getObjectByName("FTAN").actionName = "FTDH";
scope.lessonTriggerList.push(scope.staticAsset['station'].mesh.getObjectByName("FTAN"));
scope.loadAsset['default1'].mesh.getObjectByName("FTAN").showType = "default";
scope.loadAsset['default1'].mesh.getObjectByName("FTAN").label = "扶梯急停按钮";
scope.lessonTriggerList.push(scope.loadAsset['default1'].mesh.getObjectByName("FTAN"));
scope.loadAsset['default1'].mesh.getObjectByName("FTKG").showType = "default"; scope.staticAsset['station'].mesh.getObjectByName("FTKG").showType = "default";
scope.loadAsset['default1'].mesh.getObjectByName("FTKG").label = "扶梯钥匙孔"; scope.staticAsset['station'].mesh.getObjectByName("FTKG").label = "扶梯钥匙孔";
scope.lessonTriggerList.push(scope.loadAsset['default1'].mesh.getObjectByName("FTKG")); scope.staticAsset['station'].mesh.getObjectByName("FTKG").actionName = "FTDH";
scope.lessonTriggerList.push(scope.staticAsset['station'].mesh.getObjectByName("FTKG"));
scope.staticAsset['station'].mesh.getObjectByName("spbmkg").showType = "default";
scope.staticAsset['station'].mesh.getObjectByName("spbmkg").label = "屏蔽门开关";
scope.staticAsset['station'].mesh.getObjectByName("spbmkg").actionName = "PBMDH";
scope.lessonTriggerList.push(scope.staticAsset['station'].mesh.getObjectByName("spbmkg"));
// console.log(scope.loadAsset['default1'].mesh.getObjectByName("FTKG")); // console.log(scope.loadAsset['default1'].mesh.getObjectByName("FTKG"));
} }
@ -142,17 +198,28 @@ export function AssetModelManager(scene) {
function fbxpromise(asset){ function fbxpromise(asset){
return new Promise(function(resolve, reject){ return new Promise(function(resolve, reject){
var loader = new THREE.FBXLoader(); var loader = new THREE.FBXLoader();
loader.load( BASE_ASSET_API+asset.url, function ( object ) { console.log(asset);
if(asset.assetType == "static"){
if(asset.assetType == "default"){ loader.load( asset.url, function ( object ) {
object.name = asset.modelId;
asset.mesh = object;
scene.add(object); scene.add(object);
resolve();
} );
}else{
loader.load( BASE_ASSET_API+asset.url, function ( object ) {
asset.mesh = object;
if(asset.assetType == "default"){
console.log(object);
// scene.add(object);
}else if(asset.assetType == 'loadModel'){ }else if(asset.assetType == 'loadModel'){
} }
object.label = asset.packageName;
asset.mesh = object;
resolve(); resolve();
} ); } );
}
}); });
} }

View File

@ -3,6 +3,9 @@ import { Capsule } from '@/jlmap3d/lesson3d/math/Capsule.js';
import { Octree } from '@/jlmap3d/lesson3d/math/Octree.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) { export function ControlManager(dom,scene,lessonData,lessonIndex) {
let scope = this; let scope = this;
@ -12,8 +15,10 @@ export function ControlManager(dom,scene,lessonData,lessonIndex) {
this.eventHitMode = false; this.eventHitMode = false;
let eventBoxs = []; let eventBoxs = [];
let raycasterBoxs = [];
let actionList = [];
let eventTrigger;
let nowActions;
let renderer = new THREE.WebGLRenderer({ antialias: true }); let renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setClearColor(new THREE.Color(0x000000)); renderer.setClearColor(new THREE.Color(0x000000));
@ -53,9 +58,9 @@ export function ControlManager(dom,scene,lessonData,lessonIndex) {
const GRAVITY = 30; const GRAVITY = 30;
const NUM_SPHERES = 20; const NUM_SPHERES = 20;
const SPHERE_RADIUS = 0.2; const SPHERE_RADIUS = 0.1;
const sphereGeometry = new THREE.SphereGeometry( SPHERE_RADIUS, 32, 32 ); const sphereGeometry = new THREE.SphereGeometry( SPHERE_RADIUS, 16, 16 );
const sphereMaterial = new THREE.MeshStandardMaterial( { color: 0x888855, roughness: 0.8, metalness: 0.5 } ); const sphereMaterial = new THREE.MeshStandardMaterial( { color: 0x888855, roughness: 0.8, metalness: 0.5 } );
const spheres = []; const spheres = [];
@ -82,7 +87,29 @@ export function ControlManager(dom,scene,lessonData,lessonIndex) {
scope.controls.enabled = false; scope.controls.enabled = false;
} }
let loaderObj = new THREE.OBJLoader();
let pengzhuang;
// load a resource
loaderObj.load(
// resource URL
JL3D_LOCAL_STATIC+'/lesson3d/PZ427.obj',
// called when resource is loaded
function ( object ) {
pengzhuang = object;
},
// called when loading is in progresses
function ( xhr ) {
console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
},
// called when loading has errors
function ( error ) {
console.log( 'An error happened' );
}
);
const worldOctree = new Octree(); const worldOctree = new Octree();
@ -135,12 +162,14 @@ export function ControlManager(dom,scene,lessonData,lessonIndex) {
if(hitBox.intersectsBox(eventBoxs[i])){ if(hitBox.intersectsBox(eventBoxs[i])){
console.log("相交"); console.log("相交");
console.log(eventBoxs[i].action); console.log(eventBoxs[i].action);
if(eventBoxs[i].action.actionMode == "jump"){
jumpEvent("action",eventBoxs[i].action);
}
if(eventBoxs[i].action.actionMode == "remove"){ if(eventBoxs[i].action.actionMode == "remove"){
actionEvent("remove",eventBoxs[i].action,eventBoxs[i].mesh); actionEvent("remove",eventBoxs[i].action,eventBoxs[i].mesh);
} }
if(eventBoxs[i].action.actionMode == "jump"){
jumpEvent("action",eventBoxs[i].action);
}
eventBoxs.splice(i,1); eventBoxs.splice(i,1);
i--; i--;
} }
@ -165,8 +194,10 @@ export function ControlManager(dom,scene,lessonData,lessonIndex) {
render(); render();
}; };
this.initOctree = function(object){ this.init = function(actions){
worldOctree.fromGraphNode( object.getObjectByName("Object173") ); // worldOctree.fromGraphNode( object.getObjectByName("Object173") );
worldOctree.fromGraphNode( pengzhuang );
actionList = actions;
// scope.controlMode = lessonData.lessonProgress[lessonIndex].controlMode; // scope.controlMode = lessonData.lessonProgress[lessonIndex].controlMode;
} }
@ -182,11 +213,52 @@ export function ControlManager(dom,scene,lessonData,lessonIndex) {
} ); } );
let fpsMouseStatus = false; let fpsMouseStatus = false;
document.addEventListener( 'mousedown', () => { document.addEventListener( 'mousedown', (event) => {
fpsMouseStatus = true; fpsMouseStatus = true;
// document.body.requestPointerLock(); // document.body.requestPointerLock();
if(raycasterBoxs.length>0){
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) // 也可以给构造函数传参的形式写
console.log(raycasterBoxs);
for(let i=0;i<raycasterBoxs.length;i++){
var intersects = raycaster.intersectObject( raycasterBoxs[i].mesh);
if(intersects.length>0){
console.log(raycasterBoxs[i]);
if(raycasterBoxs[i].type == "switch"){
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();
}
}
if(raycasterBoxs[i].type == "urgeSwitch"){
if(raycasterBoxs[i].action.status == "02"){
raycasterBoxs[i].action.status = "01";
raycasterBoxs[i].action.action.stop();
}
}
}
}
}
} ); } );
document.body.addEventListener( 'mousemove', ( event ) => { document.body.addEventListener( 'mousemove', ( event ) => {
if(fpsMouseStatus == true){ if(fpsMouseStatus == true){
fpsCamera.rotation.y -= event.movementX / 500; fpsCamera.rotation.y -= event.movementX / 500;
@ -377,27 +449,60 @@ export function ControlManager(dom,scene,lessonData,lessonIndex) {
renderer.setSize(dom.offsetWidth,dom.offsetHeight); renderer.setSize(dom.offsetWidth,dom.offsetHeight);
} }
this.initNewEvent = function(actions,lessonTriggerList){ this.changeIndexEvent = function(actions,lessonTriggerList){
console.log(actions); if(lessonTriggerList){
console.log(lessonTriggerList); eventTrigger = lessonTriggerList;
scope.eventHitMode = true;
}
nowActions = actions;
eventBoxs = []; eventBoxs = [];
raycasterBoxs = [];
if(actions.length>0){
for(let i=0;i<actions.length;i++){ for(let i=0;i<actions.length;i++){
if(actions[i].actionType == "contact"){
for(let j=0;j<lessonTriggerList.length;j++){
if(lessonTriggerList[j].label == actions[i].actionModel){ if(actions[i].actionType == "contact"){
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()); let eventTestBox = new THREE.Box3(new THREE.Vector3(), new THREE.Vector3());
eventTestBox.setFromObject(lessonTriggerList[j]); eventTestBox.setFromObject(eventTrigger[j]);
eventTestBox.mesh = lessonTriggerList[j]; eventTestBox.mesh = eventTrigger[j];
eventTestBox.action = actions[i]; eventTestBox.action = actions[i];
eventBoxs.push(eventTestBox); eventBoxs.push(eventTestBox);
} }
} }
} }
}
scope.eventHitMode = true;
console.log(actions[i].actionType);
if(actions[i].actionType == "switch"){
for(let j=0;j<eventTrigger.length;j++){
if(eventTrigger[j].label == actions[i].actionModel){
console.log(eventTrigger);
console.log(actionList);
let eventRaycaster = {
mesh:eventTrigger[j],
action:actionList[eventTrigger[j].actionName],
type:actions[i].actionType,
}; };
console.log(lessonData); raycasterBoxs.push(eventRaycaster);
}
}
}
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);
}
}
}
}
console.log(raycasterBoxs);
}
};
} }

View File

@ -27,7 +27,7 @@ export function LessonData() {
progressName:"命名", progressName:"命名",
roleName:"", roleName:"",
roleUse:true, roleUse:true,
score:0,
progressScene:"", progressScene:"",
nextCode:"", nextCode:"",
nextNode:"", nextNode:"",
@ -77,7 +77,7 @@ export function LessonData() {
progressName:loadData[i].progressName, progressName:loadData[i].progressName,
roleName:loadData[i].roleName, roleName:loadData[i].roleName,
roleUse:loadData[i].roleUse, roleUse:loadData[i].roleUse,
score:loadData[i].roleUse, score:loadData[i].score,
progressScene:loadData[i].progressScene, progressScene:loadData[i].progressScene,
nextCode:loadData[i].nextCode, nextCode:loadData[i].nextCode,
nextNode:loadData[i].nextNode, nextNode:loadData[i].nextNode,

View File

@ -1,5 +1,7 @@
import { BASE_ASSET_API } from '@/api/jlmap3d/assets3d.js'; import { BASE_ASSET_API } from '@/api/jlmap3d/assets3d.js';
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
export function AssetModelManager(scene) { export function AssetModelManager(scene) {
let scope = this; let scope = this;
@ -12,16 +14,58 @@ export function AssetModelManager(scene) {
this.loadAsset = []; this.loadAsset = [];
this.loadAsset['default1'] = { this.staticAsset = [];
modelId:'default1', scope.staticAsset['station'] = {
modelId:'station',
packageName:"车站", packageName:"车站",
url:"/MODEL/2021-04-06/1381-54584.FBX", url:JL3D_LOCAL_STATIC+"/lesson3d/station.FBX",
mesh:"", mesh:"",
assetType:'default', assetType:'static',
isUse:true, isUse:true,
resourceType:"三维课程", resourceType:"三维课程",
}; };
scope.staticAsset['FTDH'] = {
modelId:'FTDH',
packageName:"电扶梯",
url:JL3D_LOCAL_STATIC+"/lesson3d/FTDH.FBX",
mesh:"",
assetType:'static',
isUse:true,
resourceType:"三维课程",
};
scope.staticAsset['IN'] = {
modelId:'IN',
packageName:"进闸机",
url:JL3D_LOCAL_STATIC+"/lesson3d/IN.FBX",
mesh:"",
assetType:'static',
isUse:true,
resourceType:"三维课程",
};
scope.staticAsset['OUT'] = {
modelId:'OUT',
packageName:"出闸机",
url:JL3D_LOCAL_STATIC+"/lesson3d/OUT.FBX",
mesh:"",
assetType:'static',
isUse:true,
resourceType:"三维课程",
};
scope.staticAsset['PBMDH'] = {
modelId:'PBMDH',
packageName:"屏蔽门",
url:JL3D_LOCAL_STATIC+"/lesson3d/PBMDH.FBX",
mesh:"",
assetType:'static',
isUse:true,
resourceType:"三维课程",
};
//场景中可触发事件模型 //场景中可触发事件模型
this.lessonTriggerList = []; this.lessonTriggerList = [];
@ -77,23 +121,26 @@ export function AssetModelManager(scene) {
if(assetList){ if(assetList){
for(let i = 0;i<assetList.length;i++){ for(let i = 0;i<assetList.length;i++){
assetList[i].mesh = ""; assetList[i].mesh = "";
scope.loadAsset[assetList[i].modelId] = assetList[i]; if(assetList[i].modelId == "default1"){
}else{
scope.loadAsset[assetList[i].modelId] = assetList[i];
} }
} }
}
for(let k in scope.staticAsset){
initlist.push(fbxpromise(scope.staticAsset[k]));
}
for(let k in scope.loadAsset){ for(let k in scope.loadAsset){
initlist.push(fbxpromise(scope.loadAsset[k])); initlist.push(fbxpromise(scope.loadAsset[k]));
} }
console.log(scope.loadAsset);
return new Promise(function(resolve, reject){ return new Promise(function(resolve, reject){
Promise.all(initlist).then((result) => { Promise.all(initlist).then((result) => {
initTriggerList(); initTriggerList();
if(modelList){
for(let i=0;i<modelList.length;i++){ for(let i=0;i<modelList.length;i++){
console.log(modelList[i]);
let newModelTrigger = scope.loadAsset[modelList[i].modelId].mesh.clone(true); let newModelTrigger = scope.loadAsset[modelList[i].modelId].mesh.clone(true);
newModelTrigger.showType = "loadModel"; newModelTrigger.showType = "loadModel";
newModelTrigger.label = modelList[i].label; newModelTrigger.label = modelList[i].label;
@ -108,8 +155,10 @@ export function AssetModelManager(scene) {
scope.otherModel.add(newModelTrigger); scope.otherModel.add(newModelTrigger);
scope.lessonTriggerList.push(newModelTrigger); scope.lessonTriggerList.push(newModelTrigger);
} }
}
updateTriggerList(scope.lessonTriggerList); updateTriggerList(scope.lessonTriggerList);
resolve("loaderassets"); //['成功了', 'success'] resolve("loaderassets"); //['成功了', 'success']
}).catch((error) => { }).catch((error) => {
//console.log(error); //console.log(error);
@ -131,13 +180,18 @@ export function AssetModelManager(scene) {
//FTKG 扶梯开关(钥匙孔) //FTKG 扶梯开关(钥匙孔)
//FTTJ 扶梯台阶 //FTTJ 扶梯台阶
function initTriggerList(){ function initTriggerList(){
scope.loadAsset['default1'].mesh.getObjectByName("FTAN").showType = "default"; scope.staticAsset['station'].mesh.getObjectByName("FTAN").showType = "default";
scope.loadAsset['default1'].mesh.getObjectByName("FTAN").label = "扶梯急停按钮"; scope.staticAsset['station'].mesh.getObjectByName("FTAN").label = "扶梯急停按钮";
scope.lessonTriggerList.push(scope.loadAsset['default1'].mesh.getObjectByName("FTAN")); scope.lessonTriggerList.push(scope.staticAsset['station'].mesh.getObjectByName("FTAN"));
scope.staticAsset['station'].mesh.getObjectByName("FTKG").showType = "default";
scope.staticAsset['station'].mesh.getObjectByName("FTKG").label = "扶梯钥匙孔";
scope.lessonTriggerList.push(scope.staticAsset['station'].mesh.getObjectByName("FTKG"));
scope.staticAsset['station'].mesh.getObjectByName("spbmkg").showType = "default";
scope.staticAsset['station'].mesh.getObjectByName("spbmkg").label = "屏蔽门开关";
scope.lessonTriggerList.push(scope.staticAsset['station'].mesh.getObjectByName("spbmkg"));
scope.loadAsset['default1'].mesh.getObjectByName("FTKG").showType = "default";
scope.loadAsset['default1'].mesh.getObjectByName("FTKG").label = "扶梯钥匙孔";
scope.lessonTriggerList.push(scope.loadAsset['default1'].mesh.getObjectByName("FTKG"));
// console.log(scope.loadAsset['default1'].mesh.getObjectByName("FTKG")); // console.log(scope.loadAsset['default1'].mesh.getObjectByName("FTKG"));
@ -187,16 +241,27 @@ export function AssetModelManager(scene) {
function fbxpromise(asset){ function fbxpromise(asset){
return new Promise(function(resolve, reject){ return new Promise(function(resolve, reject){
var loader = new THREE.FBXLoader(); var loader = new THREE.FBXLoader();
loader.load( BASE_ASSET_API+asset.url, function ( object ) { if(asset.assetType == "static"){
loader.load( asset.url, function ( object ) {
if(asset.assetType == "default"){ asset.mesh = object;
scene.add(object); scene.add(object);
resolve();
} );
}else{
loader.load( BASE_ASSET_API+asset.url, function ( object ) {
asset.mesh = object;
if(asset.assetType == "default"){
console.log(object);
// scene.add(object);
}else if(asset.assetType == 'loadModel'){ }else if(asset.assetType == 'loadModel'){
} }
asset.mesh = object;
resolve(); resolve();
} ); } );
}
}); });
} }

View File

@ -27,7 +27,7 @@ export function LessonData() {
progressName:"命名", progressName:"命名",
roleName:"", roleName:"",
roleUse:true, roleUse:true,
score:0,
progressScene:"", progressScene:"",
nextCode:"", nextCode:"",
nextNode:"", nextNode:"",
@ -77,7 +77,7 @@ export function LessonData() {
progressName:loadData[i].progressName, progressName:loadData[i].progressName,
roleName:loadData[i].roleName, roleName:loadData[i].roleName,
roleUse:loadData[i].roleUse, roleUse:loadData[i].roleUse,
score:loadData[i].roleUse, score:loadData[i].score,
progressScene:loadData[i].progressScene, progressScene:loadData[i].progressScene,
nextCode:loadData[i].nextCode, nextCode:loadData[i].nextCode,
nextNode:loadData[i].nextNode, nextNode:loadData[i].nextNode,

View File

@ -19,6 +19,7 @@ export function LessonTrigger() {
picurl:"", picurl:"",
}, },
]; ];
this.createTrigger = function(type){ this.createTrigger = function(type){

View File

@ -33,6 +33,11 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="当前操作分数:" >
<el-input v-model="lessonData.lessonData.lessonProgress[lessonEditIndex].score" ></el-input>
</el-form-item>
<el-form-item label="课程场景相机设置:"> <el-form-item label="课程场景相机设置:">
<el-switch <el-switch
v-model="lessonData.lessonData.lessonProgress[lessonEditIndex].changeCamera" v-model="lessonData.lessonData.lessonProgress[lessonEditIndex].changeCamera"
@ -114,7 +119,7 @@
<el-option label="接触" value="contact"></el-option> <el-option label="接触" value="contact"></el-option>
<el-option label="自动" value="auto"></el-option> <el-option label="自动" value="auto"></el-option>
<el-option label="开关" value="switch"></el-option> <el-option label="开关" value="switch"></el-option>
<el-option label="紧急开关" value="urgeSwitch"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -360,8 +365,7 @@
} }
}, },
deleteEventItem(deleteAction){ deleteEventItem(deleteAction){
console.log(this.lessonData.lessonData.lessonProgress[this.lessonEditIndex].action);
console.log(deleteAction);
for(let i=0;i<this.lessonData.lessonData.lessonProgress[this.lessonEditIndex].action.length;i++){ for(let i=0;i<this.lessonData.lessonData.lessonProgress[this.lessonEditIndex].action.length;i++){
if(this.lessonData.lessonData.lessonProgress[this.lessonEditIndex].action[i].actionName == deleteAction.actionName){ if(this.lessonData.lessonData.lessonProgress[this.lessonEditIndex].action[i].actionName == deleteAction.actionName){
this.lessonData.lessonData.lessonProgress[this.lessonEditIndex].action.splice(i,1); this.lessonData.lessonData.lessonProgress[this.lessonEditIndex].action.splice(i,1);

View File

@ -217,6 +217,7 @@
updateLesson3dData(this.$route.query.lessonId,this.netData).then(data => { updateLesson3dData(this.$route.query.lessonId,this.netData).then(data => {
console.log(data); console.log(data);
}).catch(() => { }).catch(() => {
}); });
}, },
addProgress(){ addProgress(){

View File

@ -75,10 +75,8 @@
}, },
initJobList(data){ initJobList(data){
this.jobList = data; this.jobList = data;
console.log(data);
}, },
selectJob(item){ selectJob(item){
console.log(item);
this.selectedJob = item; this.selectedJob = item;
}, },
@ -94,7 +92,6 @@
}, },
selsectJobTool(selectTool,jobList){ selsectJobTool(selectTool,jobList){
lesson3dSelect('toolproperty','jobpane',selectTool,jobList); lesson3dSelect('toolproperty','jobpane',selectTool,jobList);
console.log(selectTool);
}, },
generateUUID() { generateUUID() {
var d = new Date().getTime(); var d = new Date().getTime();

View File

@ -10,6 +10,9 @@
</Step-Tips> </Step-Tips>
<Process-Log <Process-Log
:lessonData='lessonData'
:lessonPlayIndex='lessonPlayIndex'
ref="processlog"
v-show="lessonTools[1].isShow && lessonData.lessonData.lessonProgress[lessonPlayIndex].progressScene == 'standstation'"> v-show="lessonTools[1].isShow && lessonData.lessonData.lessonProgress[lessonPlayIndex].progressScene == 'standstation'">
</Process-Log> </Process-Log>
@ -120,6 +123,7 @@
window.updateTriggerList = this.updateTriggerList; window.updateTriggerList = this.updateTriggerList;
window.jumpEvent = this.jumpEvent; window.jumpEvent = this.jumpEvent;
window.actionEvent = this.actionEvent; window.actionEvent = this.actionEvent;
window.startLesson = this.startLesson;
this.init(this.$route.query.lessonId); this.init(this.$route.query.lessonId);
}, },
beforeDestroy() { beforeDestroy() {
@ -145,6 +149,7 @@
this.lessonTools = loadData.lessonTools; this.lessonTools = loadData.lessonTools;
this.lessonData.loadLessonProgress(loadData.lessonProgress); this.lessonData.loadLessonProgress(loadData.lessonProgress);
}else{ }else{
this.lessonData.initLessonProgress(); this.lessonData.initLessonProgress();
this.$refs.jobpane.initJobList(this.jobPaneData.dataList); this.$refs.jobpane.initJobList(this.jobPaneData.dataList);
@ -155,7 +160,9 @@
}).catch(() => { }).catch(() => {
}); });
}, },
startLesson(){
this.$refs.processlog.startLog();
},
saveLesson3dData(){ saveLesson3dData(){
this.lessonData.lessonData.lessonTools = this.lessonTools; this.lessonData.lessonData.lessonTools = this.lessonTools;
let saveData = this.lessonData.lessonData; let saveData = this.lessonData.lessonData;
@ -180,6 +187,8 @@
if(type == "tools"){ if(type == "tools"){
this.lessonPlayIndex = action.nextNode; this.lessonPlayIndex = action.nextNode;
} }
this.jl3d.changeIndex(this.lessonPlayIndex);
}, },
actionEvent(type,action,mesh){ actionEvent(type,action,mesh){
if(type == "remove"){ if(type == "remove"){

View File

@ -91,13 +91,10 @@
this.jobList = data; this.jobList = data;
}, },
selectJob(item){ selectJob(item){
console.log(item);
this.selectedJob = item; this.selectedJob = item;
}, },
selsectJobTool(selectTool){ selsectJobTool(selectTool){
console.log(selectTool);
console.log(this.lessonData.lessonData.lessonProgress[this.lessonPlayIndex]);
let nowProgress = this.lessonData.lessonData.lessonProgress[this.lessonPlayIndex]; let nowProgress = this.lessonData.lessonData.lessonProgress[this.lessonPlayIndex];
if(selectTool.sceneId == nowProgress.id){ if(selectTool.sceneId == nowProgress.id){
jumpEvent("tools",selectTool); jumpEvent("tools",selectTool);

View File

@ -1,23 +1,29 @@
<template> <template>
<div class="processlogdiv" > <div class="processlogdiv"
:style="{'background-image': 'url('+lessonbg+')'}">
<el-tabs type="border-card"> <el-tabs type="border-card"
<el-tab-pane label="进程"> :style="{'background-image': 'url('+lessonbg+')'}">
<div class="processtext" > <el-tab-pane label="进程" style="overflow-y:auto;">
{{processText}} <div id="tabdiv" class = "tabdiv">
<div class="processtext" v-for="(processItem,index) in processTexts">
{{processItem.text}}
</div>
<div class="processtextnow" >
{{nowProcessText}}
</div>
</div> </div>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="日志" > <el-tab-pane label="日志" >
<div class="logtext" > <div id="tabdiv" class = "tabdiv">
{{logText}} <div class="logtext" v-for="(logItem,index) in logTexts">
{{logItem.text}}
</div>
</div> </div>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</div> </div>
</template> </template>
<script> <script>
@ -27,30 +33,45 @@
// //
export default { export default {
name: 'ProcessLog', name: 'ProcessLog',
props:['lessonData','lessonPlayIndex'],
components: { components: {
}, },
data() { data() {
return { return {
processText:"", lessonbg:JL3D_LOCAL_STATIC+"/lesson3d/lessonbg.png",
logText:"", nowProcessText:"",
oldIndex:0,
processTexts:[],
logTexts:[],
} }
}, },
computed: { computed: {
}, },
watch: { watch: {
'lessonPlayIndex': {
handler: function (newVal, oldVal) {
if (newVal != oldVal) {
this.logTexts.push(this.lessonData.lessonData.lessonProgress[oldVal].stepTipsData);
this.processTexts.push(this.lessonData.lessonData.lessonProgress[oldVal].stepTipsData);
this.nowProcessText = this.lessonData.lessonData.lessonProgress[newVal].stepTipsData.text;
var div = document.getElementById('tabdiv');
div.scrollTop = div.scrollHeight;
}
}
},
}, },
mounted() { mounted() {
}, },
beforeDestroy() { beforeDestroy() {
}, },
methods: { methods: {
startLog(){
this.nowProcessText = this.lessonData.lessonData.lessonProgress[this.lessonPlayIndex].stepTipsData.text;
},
}, },
@ -62,23 +83,41 @@
@import "src/styles/mixin.scss"; @import "src/styles/mixin.scss";
.processlogdiv { .processlogdiv {
position: absolute; position: absolute;
width: 28%; width: 450px;
height: 25%; height: 250px;
right:0; right:0;
bottom:0; bottom:0;
// border-radius:10px; border-radius:10px;
border:solid 2px #000;
background-color: #000080;
opacity: 0.6;
color:#fff;
z-index:1; z-index:1;
} }
.tabdiv{
width:100%;
height:175px;
position: relative;
overflow-y: auto;
}
.processtext{ .processtext{
font-size: 16px; font-size: 16px;
color:#00ff00;
border:solid 2px #fff;
margin-top: 5px;
}
.processtextnow{
font-size: 16px;
color:#ff0000;
border:solid 2px #fff;
margin-top: 5px;
} }
.logtext{ .logtext{
font-size: 16px; font-size: 16px;
color:#00ff00;
border:solid 2px #fff;
margin-top: 5px;
} }
</style> </style>

BIN
static/lesson3d/FTDH.2FBX Normal file

Binary file not shown.

BIN
static/lesson3d/FTDH.FBX Normal file

Binary file not shown.

BIN
static/lesson3d/IN.FBX Normal file

Binary file not shown.

BIN
static/lesson3d/OUT.FBX Normal file

Binary file not shown.

BIN
static/lesson3d/PBMDH.FBX Normal file

Binary file not shown.

5576
static/lesson3d/PZ427.obj Normal file

File diff suppressed because it is too large Load Diff

BIN
static/lesson3d/station.FBX Normal file

Binary file not shown.