|
@@ -14,6 +14,11 @@ import { MTLLoader } from "three/examples/jsm/loaders/MTLLoader.js";
|
|
|
import { FBXLoader } from "three/examples/jsm/loaders/FBXLoader.js";
|
|
|
import { DDSLoader } from "three/examples/jsm/loaders/DDSLoader.js";
|
|
|
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
|
+import { ConvexGeometry } from "three/examples/jsm/geometries/ConvexGeometry.js";
|
|
|
+import {
|
|
|
+ showFullScreenLoading,
|
|
|
+ tryHideFullScreenLoading,
|
|
|
+} from "../../../axios/filter";
|
|
|
|
|
|
export default {
|
|
|
name: "threeVehicleConfiguration", // 车辆配置详情中的threeJS
|
|
@@ -43,6 +48,8 @@ export default {
|
|
|
dragControls: null,
|
|
|
sensor: null, // 当前操作的传感器模型
|
|
|
ogt: null,
|
|
|
+ scale: 1.5, // 物体加载换算倍数
|
|
|
+ rate: 20, // 坐标换算倍数
|
|
|
};
|
|
|
},
|
|
|
|
|
@@ -121,6 +128,7 @@ export default {
|
|
|
if (obj) {
|
|
|
obj.rotation.set(this.xAngle, this.yAngle, this.zAngle);
|
|
|
}
|
|
|
+
|
|
|
// obj.rotateX(this.xAngle * -1);
|
|
|
// obj.rotateX(value);
|
|
|
|
|
@@ -163,8 +171,12 @@ export default {
|
|
|
// 场景
|
|
|
initScene() {
|
|
|
this.scene = new THREE.Scene();
|
|
|
- let axes = new THREE.AxesHelper(500);
|
|
|
+ let axes = new THREE.AxesHelper(1500);
|
|
|
this.scene.add(axes);
|
|
|
+ const gridHelper = new THREE.GridHelper(1000, 100);
|
|
|
+ gridHelper.material.opacity = 0.25;
|
|
|
+ gridHelper.material.transparent = true;
|
|
|
+ this.scene.add(gridHelper);
|
|
|
|
|
|
const genCubeUrls = function (prefix, postfix) {
|
|
|
return [
|
|
@@ -183,7 +195,7 @@ export default {
|
|
|
const cubeTextureLoader = new THREE.CubeTextureLoader();
|
|
|
const environmentMapTexture = cubeTextureLoader.load(urls);
|
|
|
|
|
|
- this.scene.background = environmentMapTexture;
|
|
|
+ // this.scene.background = environmentMapTexture;
|
|
|
},
|
|
|
// 相机
|
|
|
initCamera() {
|
|
@@ -221,7 +233,7 @@ export default {
|
|
|
this.container.clientWidth,
|
|
|
this.container.clientHeight
|
|
|
);
|
|
|
- this.renderer.setClearColor("#ddd");
|
|
|
+ this.renderer.setClearColor("#272727");
|
|
|
this.container.appendChild(this.renderer.domElement);
|
|
|
},
|
|
|
// 初始化灯光
|
|
@@ -260,7 +272,7 @@ export default {
|
|
|
// dirLight.shadow.mapSize.height = 2048; // default
|
|
|
// //阴影限制
|
|
|
// dirLight.shadow.radius = 1;
|
|
|
- this.scene.add(dirLight);
|
|
|
+ // this.scene.add(dirLight);
|
|
|
|
|
|
// const spotLight = new THREE.SpotLight(0xffffff);
|
|
|
// spotLight.position.set(100, 1000, 100);
|
|
@@ -320,13 +332,13 @@ export default {
|
|
|
// 初始化模型
|
|
|
initContent(r, position, rotation, type) {
|
|
|
var cubeGeometry = new THREE.ConeGeometry(
|
|
|
- r || 45,
|
|
|
- 150,
|
|
|
+ r || 45 * this.scale,
|
|
|
+ 150 * this.scale,
|
|
|
4,
|
|
|
1,
|
|
|
false
|
|
|
);
|
|
|
- cubeGeometry.translate(0, -75, 0);
|
|
|
+ cubeGeometry.translate(0, -150, 0);
|
|
|
|
|
|
let obj = {
|
|
|
color: 0x4c4c4c,
|
|
@@ -424,13 +436,37 @@ export default {
|
|
|
this.controls.enabled = true;
|
|
|
});
|
|
|
},
|
|
|
- initCar0() {
|
|
|
+ initCar0(model) {
|
|
|
+ if (this.car) {
|
|
|
+ console.log(this.car);
|
|
|
+ this.scene.remove(this.car);
|
|
|
+ this.removeObj(this.car);
|
|
|
+ this.car = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // const loading = this.$loading({
|
|
|
+ // lock: true,
|
|
|
+ // text: "模型加载中,请稍等...",
|
|
|
+ // // spinner: "el-icon-loading",
|
|
|
+ // background: "rgba(0, 0, 0, 0.2)",
|
|
|
+ // });
|
|
|
+
|
|
|
+ showFullScreenLoading();
|
|
|
+
|
|
|
var that = this;
|
|
|
var loader = new GLTFLoader(); //创建一个FBX加载器
|
|
|
- loader.load(`${this.publicPath}untitled.glb`, function (obj) {
|
|
|
- console.log(obj);
|
|
|
|
|
|
- /* for (let i = 0; i < obj.children.length; i++) {
|
|
|
+ // loader.load(
|
|
|
+ // `${this.publicPath}glb/AudiA6_10.glb`,
|
|
|
+ // function (obj) {
|
|
|
+ loader.load(
|
|
|
+ model,
|
|
|
+ function (obj) {
|
|
|
+ // loading.close();
|
|
|
+ tryHideFullScreenLoading();
|
|
|
+ // console.log(obj);
|
|
|
+
|
|
|
+ /* for (let i = 0; i < obj.children.length; i++) {
|
|
|
// obj.children[i].position.set(0, -135, 0);
|
|
|
// obj.children[i].position.set(18, 36, 0);
|
|
|
// obj.children[i].scale.set(30, 30, 30);
|
|
@@ -444,18 +480,31 @@ export default {
|
|
|
// that.transformControls.attach(obj.children[i]);
|
|
|
} */
|
|
|
|
|
|
- obj.rotation.set(
|
|
|
- (-90 * Math.PI) / 180,
|
|
|
- 0,
|
|
|
- (-180 * Math.PI) / 180
|
|
|
- );
|
|
|
- // obj.scale.set(30, 30, 30);
|
|
|
+ obj.scene.rotation.set(
|
|
|
+ (-90 * Math.PI) / 180,
|
|
|
+ 0,
|
|
|
+ (-180 * Math.PI) / 180
|
|
|
+ );
|
|
|
|
|
|
- // 查看动画数据 2个剪辑对象AnimationClip,一个有关键帧动画,一个没有
|
|
|
- // console.log(obj.animations);
|
|
|
- // that.scene.add(obj);
|
|
|
- that.scene.add(obj.scene);
|
|
|
- });
|
|
|
+ let scale = 30 * that.scale;
|
|
|
+ obj.scene.scale.set(scale, scale, scale);
|
|
|
+ // obj.scene.scale.set(30, 30, 30);
|
|
|
+
|
|
|
+ // 查看动画数据 2个剪辑对象AnimationClip,一个有关键帧动画,一个没有
|
|
|
+ // console.log(obj.animations);
|
|
|
+ // that.scene.add(obj);
|
|
|
+ that.scene.add(obj.scene);
|
|
|
+ that.car = obj.scene;
|
|
|
+ },
|
|
|
+ (xhr) => {
|
|
|
+ // console.log((xhr.loaded / xhr.total) * 100 + "% loaded");
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ // loading.close();
|
|
|
+ tryHideFullScreenLoading();
|
|
|
+ console.error(error);
|
|
|
+ }
|
|
|
+ );
|
|
|
},
|
|
|
initCar1() {
|
|
|
const loader2 = new DDSLoader();
|
|
@@ -476,47 +525,59 @@ export default {
|
|
|
var loader = new FBXLoader(); //创建一个FBX加载器
|
|
|
// var loader = new GLTFLoader(); //创建一个FBX加载器
|
|
|
// loader.load(`${this.publicPath}6/a8/audia8.fbx`, function (obj) {
|
|
|
- loader.load(`${this.publicPath}q5/audiq5.fbx`, function (obj) {
|
|
|
- // loader.load(`${this.publicPath}q6/audiq5.fbx`, function (obj) {
|
|
|
- // loader.load(`${this.publicPath}untitled.fbx`, function (obj) {
|
|
|
- // loader.load(`${this.publicPath}untitled.glb`, function (obj) {
|
|
|
- // loader.load(`${this.publicPath}fbx/Samba Dancing.fbx`, function (obj) {
|
|
|
- // 可以在控制台打印obj对象,找到animations属性
|
|
|
- console.log(obj);
|
|
|
- obj.name = "car";
|
|
|
+ // loader.load(`${this.publicPath}6/q5/audiq5.fbx`, function (obj) {
|
|
|
+ // loader.load(`${this.publicPath}6/a8/audia8.fbx`, function (obj) {
|
|
|
+ // loader.load(`${this.publicPath}a8/audia8.fbx`, function (obj) {
|
|
|
+ // loader.load(`${this.publicPath}q5/audiq5.fbx`, function (obj) {
|
|
|
+ // loader.load(`${this.publicPath}lb/audiq5.fbx`, function (obj) {
|
|
|
+ loader.load(
|
|
|
+ `${this.publicPath}lb/1/fbx/untitled.fbx`,
|
|
|
+ function (obj) {
|
|
|
+ // loader.load(`${this.publicPath}q6/audiq5.fbx`, function (obj) {
|
|
|
+ // loader.load(`${this.publicPath}untitled.fbx`, function (obj) {
|
|
|
+ // loader.load(`${this.publicPath}untitled.glb`, function (obj) {
|
|
|
+ // loader.load(`${this.publicPath}fbx/Samba Dancing.fbx`, function (obj) {
|
|
|
+ // 可以在控制台打印obj对象,找到animations属性
|
|
|
+ console.log(obj);
|
|
|
+ obj.name = "car";
|
|
|
+
|
|
|
+ // obj.map = map1;
|
|
|
+ function _ChangeMaterialEmissive(parent) {
|
|
|
+ parent.traverse(function (child) {
|
|
|
+ // if (child instanceof THREE.Mesh) {
|
|
|
+ if (child.isMesh) {
|
|
|
+ // child.material.emissive = new THREE.Color(1, 1, 1);
|
|
|
+ // child.material.emissive = child.material.color;
|
|
|
+ // child.material.emissiveIntensity = 1;
|
|
|
+ // child.material.emissiveMap = child.material.map;
|
|
|
+ // child.material.envMap = child.material.map;
|
|
|
+ // child.material.alphaMap = child.material.map;
|
|
|
+ // child.material.aoMap = child.material.map;
|
|
|
+ // child.material.bumpMap = child.material.map;
|
|
|
+ // child.material.lightMap = child.material.map;
|
|
|
+ // child.material.normalMap = child.material.map;
|
|
|
+ // child.material.specularMap = child.material.map;
|
|
|
+ // child.material.transparent = true;
|
|
|
+ child.castShadow = true;
|
|
|
+ child.receiveShadow = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- // obj.map = map1;
|
|
|
-
|
|
|
- function _ChangeMaterialEmissive(parent) {
|
|
|
- parent.traverse(function (child) {
|
|
|
- // if (child instanceof THREE.Mesh) {
|
|
|
- if (child.isMesh) {
|
|
|
- // child.material.emissive = new THREE.Color(1, 1, 1);
|
|
|
- child.material.emissive = child.material.color;
|
|
|
- // child.material.emissiveIntensity = 1;
|
|
|
- child.material.emissiveMap = child.material.map;
|
|
|
- // child.material.envMap = child.material.map;
|
|
|
- // child.material.emissiveMap = map3;
|
|
|
- child.castShadow = true;
|
|
|
- child.receiveShadow = true;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ _ChangeMaterialEmissive(obj);
|
|
|
|
|
|
- _ChangeMaterialEmissive(obj);
|
|
|
-
|
|
|
- // obj.traverse(function (child) {
|
|
|
- // if (child.isMesh) {
|
|
|
- // // child.material.emissive = new THREE.Color(1, 1, 1);
|
|
|
- // child.material.emissive = child.material.color;
|
|
|
- // child.material.emissiveIntensity = 1;
|
|
|
- // child.material.emissiveMap = child.material.map;
|
|
|
- // child.castShadow = true;
|
|
|
- // child.receiveShadow = true;
|
|
|
- // }
|
|
|
- // });
|
|
|
+ // obj.traverse(function (child) {
|
|
|
+ // if (child.isMesh) {
|
|
|
+ // // child.material.emissive = new THREE.Color(1, 1, 1);
|
|
|
+ // child.material.emissive = child.material.color;
|
|
|
+ // child.material.emissiveIntensity = 1;
|
|
|
+ // child.material.emissiveMap = child.material.map;
|
|
|
+ // child.castShadow = true;
|
|
|
+ // child.receiveShadow = true;
|
|
|
+ // }
|
|
|
+ // });
|
|
|
|
|
|
- /* for (let i = 0; i < obj.children.length; i++) {
|
|
|
+ /* for (let i = 0; i < obj.children.length; i++) {
|
|
|
// obj.children[i].position.set(0, -135, 0);
|
|
|
// obj.children[i].position.set(18, 36, 0);
|
|
|
// obj.children[i].scale.set(30, 30, 30);
|
|
@@ -530,18 +591,19 @@ export default {
|
|
|
// that.transformControls.attach(obj.children[i]);
|
|
|
} */
|
|
|
|
|
|
- obj.rotation.set(
|
|
|
- (-90 * Math.PI) / 180,
|
|
|
- 0,
|
|
|
- (-180 * Math.PI) / 180
|
|
|
- );
|
|
|
- obj.scale.set(30, 30, 30);
|
|
|
+ obj.rotation.set(
|
|
|
+ (-90 * Math.PI) / 180,
|
|
|
+ 0,
|
|
|
+ (-180 * Math.PI) / 180
|
|
|
+ );
|
|
|
+ // obj.scale.set(30, 30, 30);
|
|
|
|
|
|
- // 查看动画数据 2个剪辑对象AnimationClip,一个有关键帧动画,一个没有
|
|
|
- // console.log(obj.animations);
|
|
|
- that.scene.add(obj);
|
|
|
- // that.scene.add(obj.scene);
|
|
|
- });
|
|
|
+ // 查看动画数据 2个剪辑对象AnimationClip,一个有关键帧动画,一个没有
|
|
|
+ // console.log(obj.animations);
|
|
|
+ that.scene.add(obj);
|
|
|
+ // that.scene.add(obj.scene);
|
|
|
+ }
|
|
|
+ );
|
|
|
},
|
|
|
initCar2() {
|
|
|
var that = this;
|
|
@@ -577,7 +639,10 @@ export default {
|
|
|
// `${that.publicPath}GTR.mtl`,
|
|
|
// `${that.publicPath}lidar.mtl`,
|
|
|
// `${that.publicPath}female02/female02.mtl`,
|
|
|
- `${that.publicPath}new/audiq5.mtl`,
|
|
|
+ // `${that.publicPath}new/audiq5.mtl`,
|
|
|
+ // `${that.publicPath}lb/obj/audiq5.mtl`,
|
|
|
+ // `${that.publicPath}lb/00obj/00.mtl`,
|
|
|
+ `${that.publicPath}lb/1/obj/untitled.mtl`,
|
|
|
function (materials) {
|
|
|
// 返回一个包含材质的对象MaterialCreator
|
|
|
// console.log(materials);
|
|
@@ -590,7 +655,9 @@ export default {
|
|
|
loader.load(
|
|
|
// "../../../../public/female02/female02.obj",
|
|
|
// `${that.publicPath}female02/female02.obj`,
|
|
|
- `${that.publicPath}new/audiq5.obj`,
|
|
|
+ // `${that.publicPath}new/audiq5.obj`,
|
|
|
+ // `${that.publicPath}lb/00obj/00.obj`,
|
|
|
+ `${that.publicPath}lb/1/obj/untitled.obj`,
|
|
|
// `${that.publicPath}male02/male02.obj`,
|
|
|
// `${that.publicPath}GTR.obj`,
|
|
|
// `${that.publicPath}lidar.obj`,
|
|
@@ -606,7 +673,8 @@ export default {
|
|
|
|
|
|
for (let i = 0; i < obj.children.length; i++) {
|
|
|
// obj.children[i].position.set(0, -135, 0);
|
|
|
- obj.children[i].position.set(0, -30, 0);
|
|
|
+ // obj.children[i].position.set(0, -30, 0);
|
|
|
+ obj.children[i].position.set(0, 0, 0);
|
|
|
// obj.children[i].scale.set(30, 30, 30);
|
|
|
obj.children[i].rotation.set(
|
|
|
(-90 * Math.PI) / 180,
|
|
@@ -637,7 +705,7 @@ export default {
|
|
|
);
|
|
|
},
|
|
|
// 初始化车模型
|
|
|
- initCar(type = "1") {
|
|
|
+ initCar(model) {
|
|
|
// const loading = this.$loading({
|
|
|
// lock: true,
|
|
|
// text: "模型加载中,请稍等...",
|
|
@@ -645,12 +713,12 @@ export default {
|
|
|
// background: "rgba(0, 0, 0, 0.2)",
|
|
|
// });
|
|
|
|
|
|
- const car = this.scene.getObjectByName("car");
|
|
|
+ // const car = this.scene.getObjectByName("car");
|
|
|
// console.log(car);
|
|
|
// console.log(this.scene);
|
|
|
- if (car) {
|
|
|
- this.scene.remove(car);
|
|
|
- }
|
|
|
+ // if (car) {
|
|
|
+ // this.scene.remove(car);
|
|
|
+ // }
|
|
|
|
|
|
// console.log(type);
|
|
|
|
|
@@ -664,7 +732,11 @@ export default {
|
|
|
// this.initCar1();
|
|
|
// }
|
|
|
|
|
|
- this.initCar1();
|
|
|
+ console.log(model);
|
|
|
+ if (!model) return;
|
|
|
+ if (!model.includes(".glb")) return;
|
|
|
+
|
|
|
+ this.initCar0(model);
|
|
|
|
|
|
// console.log(this.scene);
|
|
|
|
|
@@ -753,8 +825,12 @@ export default {
|
|
|
// 每编辑一个传感器则重新生成对应的物体
|
|
|
reset(type) {
|
|
|
this.canDrag = true;
|
|
|
+
|
|
|
if (this.cacheList.length > 0) {
|
|
|
this.scene.remove(...this.cacheList);
|
|
|
+ this.cacheList.forEach((i) => {
|
|
|
+ this.clearCache(i);
|
|
|
+ });
|
|
|
this.cacheList = [];
|
|
|
}
|
|
|
|
|
@@ -776,6 +852,10 @@ export default {
|
|
|
let p = +this.$parent.formA.sensorR || 0;
|
|
|
let r = +this.$parent.formA.sensorH || 0;
|
|
|
|
|
|
+ x = Math.floor(x / this.rate);
|
|
|
+ y = Math.floor(y / this.rate);
|
|
|
+ z = Math.floor(z / this.rate);
|
|
|
+
|
|
|
this.initContent(
|
|
|
null,
|
|
|
{ x, y, z },
|
|
@@ -798,7 +878,7 @@ export default {
|
|
|
|
|
|
// obj.rotateX(0 * -1);
|
|
|
// obj.rotateX((h * Math.PI) / 180);
|
|
|
- this.xAngle = ((h-90) * Math.PI) / 180;
|
|
|
+ this.xAngle = ((h - 90) * Math.PI) / 180;
|
|
|
|
|
|
// obj.rotateY(0 * -1);
|
|
|
// obj.rotateY((p * Math.PI) / 180);
|
|
@@ -876,55 +956,85 @@ export default {
|
|
|
objUrl = `${that.publicPath}sensor/gps/lidar.obj`;
|
|
|
}
|
|
|
|
|
|
- Loader.load(mtlUrl, function (materials) {
|
|
|
- // console.log(materials);
|
|
|
- loader.setMaterials(materials);
|
|
|
- loader.load(objUrl, function (obj) {
|
|
|
- // console.log(obj);
|
|
|
- // console.log(obj.clone());
|
|
|
- // console.log(JSON.stringify(obj.toJSON()));
|
|
|
- // if (type === "ogt" && !that.ogt) {
|
|
|
- // that.ogt = obj.clone();
|
|
|
- // }
|
|
|
+ let loading = null;
|
|
|
+ if (type === "ogt") {
|
|
|
+ // loading = this.$loading({
|
|
|
+ // lock: true,
|
|
|
+ // text: "模型加载中,请稍等...",
|
|
|
+ // // spinner: "el-icon-loading",
|
|
|
+ // background: "rgba(0, 0, 0, 0.2)",
|
|
|
+ // });
|
|
|
+ showFullScreenLoading();
|
|
|
+ }
|
|
|
|
|
|
- that.cacheList.push(obj);
|
|
|
- for (let i = 0; i < obj.children.length; i++) {
|
|
|
- if (type === "camera") {
|
|
|
- obj.children[i].scale.set(0.8, 0.8, 0.8);
|
|
|
- } else if (type === "ogt") {
|
|
|
- obj.children[i].scale.set(0.2, 0.2, 0.2);
|
|
|
- } else if (type === "lidar") {
|
|
|
- obj.children[i].scale.set(0.1, 0.1, 0.1);
|
|
|
- } else if (type === "gps") {
|
|
|
- obj.children[i].scale.set(40, 40, 40);
|
|
|
+ Loader.load(
|
|
|
+ mtlUrl,
|
|
|
+ function (materials) {
|
|
|
+ // console.log(materials);
|
|
|
+ loader.setMaterials(materials);
|
|
|
+ loader.load(objUrl, function (obj) {
|
|
|
+ // console.log(obj);
|
|
|
+ // console.log(obj.clone());
|
|
|
+ // console.log(JSON.stringify(obj.toJSON()));
|
|
|
+ // if (type === "ogt" && !that.ogt) {
|
|
|
+ // that.ogt = obj.clone();
|
|
|
+ // }
|
|
|
+
|
|
|
+ if (type === "ogt") {
|
|
|
+ // loading.close();
|
|
|
+ tryHideFullScreenLoading();
|
|
|
}
|
|
|
- // obj.children[i].position.set(0, 0, 0);
|
|
|
- // obj.children[i].geometry.translate(pos.x, pos.y, pos.z);
|
|
|
- // obj.children[i].position.set(pos.x, pos.y, pos.z);
|
|
|
- // obj.children[i].geometry.translate(-pos.x, -pos.y, -pos.z);
|
|
|
- // obj.children[i].scale.set(30, 30, 30);
|
|
|
- }
|
|
|
- obj.position.set(pos.x, pos.y, pos.z);
|
|
|
- // obj.geometry.translate.set(pos.x, pos.y, pos.z);
|
|
|
|
|
|
- if (canMove) {
|
|
|
- that.sensor = obj;
|
|
|
- }
|
|
|
+ that.cacheList.push(obj);
|
|
|
+ for (let i = 0; i < obj.children.length; i++) {
|
|
|
+ if (type === "camera") {
|
|
|
+ // let scale = 0.8 * that.scale;
|
|
|
+ obj.children[i].scale.set(0.8, 0.8, 0.8);
|
|
|
+ } else if (type === "ogt") {
|
|
|
+ obj.children[i].scale.set(0.2, 0.2, 0.2);
|
|
|
+ } else if (type === "lidar") {
|
|
|
+ obj.children[i].scale.set(0.1, 0.1, 0.1);
|
|
|
+ } else if (type === "gps") {
|
|
|
+ obj.children[i].scale.set(40, 40, 40);
|
|
|
+ }
|
|
|
+ // obj.children[i].position.set(0, 0, 0);
|
|
|
+ // obj.children[i].geometry.translate(pos.x, pos.y, pos.z);
|
|
|
+ // obj.children[i].position.set(pos.x, pos.y, pos.z);
|
|
|
+ // obj.children[i].geometry.translate(-pos.x, -pos.y, -pos.z);
|
|
|
+ // obj.children[i].scale.set(30, 30, 30);
|
|
|
+ }
|
|
|
+ obj.position.set(pos.x, pos.y, pos.z);
|
|
|
+ // obj.geometry.translate.set(pos.x, pos.y, pos.z);
|
|
|
|
|
|
- that.scene.add(obj); //返回的组对象插入场景中
|
|
|
- });
|
|
|
- });
|
|
|
+ if (canMove) {
|
|
|
+ that.sensor = obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ that.scene.add(obj); //返回的组对象插入场景中
|
|
|
+ });
|
|
|
+ },
|
|
|
+ (xhr) => {
|
|
|
+ // console.log((xhr.loaded / xhr.total) * 100 + "% loaded");
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ if (type === "ogt") {
|
|
|
+ // loading.close();
|
|
|
+ tryHideFullScreenLoading();
|
|
|
+ }
|
|
|
+ console.error(error);
|
|
|
+ }
|
|
|
+ );
|
|
|
},
|
|
|
// 初始化已保存过的传感器
|
|
|
initContentToShow(r, position, rotation, type) {
|
|
|
var cubeGeometry = new THREE.ConeGeometry(
|
|
|
- r || 45,
|
|
|
- 150,
|
|
|
+ r || 45 * this.scale,
|
|
|
+ 150 * this.scale,
|
|
|
4,
|
|
|
1,
|
|
|
false
|
|
|
);
|
|
|
- cubeGeometry.translate(0, -75, 0);
|
|
|
+ cubeGeometry.translate(0, -150, 0);
|
|
|
|
|
|
let obj = {
|
|
|
transparent: true,
|
|
@@ -963,12 +1073,18 @@ export default {
|
|
|
cube.position.z = position.z;
|
|
|
}
|
|
|
if (rotation) {
|
|
|
- cube.rotateX(0 * -1);
|
|
|
- cube.rotateX((rotation.x * Math.PI) / 180);
|
|
|
- cube.rotateY(0 * -1);
|
|
|
- cube.rotateY((rotation.y * Math.PI) / 180);
|
|
|
- cube.rotateZ(0 * -1);
|
|
|
- cube.rotateZ((rotation.z * Math.PI) / 180);
|
|
|
+ // cube.rotateX(0 * -1);
|
|
|
+ // cube.rotateX((rotation.x * Math.PI) / 180);
|
|
|
+ // cube.rotateY(0 * -1);
|
|
|
+ // cube.rotateY((rotation.y * Math.PI) / 180);
|
|
|
+ // cube.rotateZ(0 * -1);
|
|
|
+ // cube.rotateZ((rotation.z * Math.PI) / 180);
|
|
|
+
|
|
|
+ cube.rotation.set(
|
|
|
+ ((rotation.x - 90) * Math.PI) / 180,
|
|
|
+ (rotation.y * Math.PI) / 180,
|
|
|
+ (rotation.z * Math.PI) / 180
|
|
|
+ );
|
|
|
}
|
|
|
this.cacheList.push(cube);
|
|
|
this.scene.add(cube);
|
|
@@ -980,9 +1096,9 @@ export default {
|
|
|
this.initContentToShow(
|
|
|
null,
|
|
|
{
|
|
|
- x: +item.sensorX,
|
|
|
- y: +item.sensorY,
|
|
|
- z: +item.sensorZ,
|
|
|
+ x: Math.floor(item.sensorX / this.rate || 0),
|
|
|
+ y: Math.floor(item.sensorY / this.rate || 0),
|
|
|
+ z: Math.floor(item.sensorZ / this.rate || 0),
|
|
|
},
|
|
|
{
|
|
|
x: +item.sensorP,
|
|
@@ -994,9 +1110,9 @@ export default {
|
|
|
|
|
|
this.initSensor(
|
|
|
{
|
|
|
- x: +item.sensorX,
|
|
|
- y: +item.sensorY,
|
|
|
- z: +item.sensorZ,
|
|
|
+ x: Math.floor(item.sensorX / this.rate || 0),
|
|
|
+ y: Math.floor(item.sensorY / this.rate || 0),
|
|
|
+ z: Math.floor(item.sensorZ / this.rate || 0),
|
|
|
},
|
|
|
type,
|
|
|
false
|
|
@@ -1006,6 +1122,9 @@ export default {
|
|
|
},
|
|
|
// 显示全部
|
|
|
showAll() {
|
|
|
+ // 避免重复加载所有传感器
|
|
|
+ if (!this.canDrag) return;
|
|
|
+
|
|
|
this.canDrag = false;
|
|
|
if (this.cacheList.length > 0) {
|
|
|
this.scene.remove(...this.cacheList);
|
|
@@ -1027,6 +1146,8 @@ export default {
|
|
|
this.transformControls.detach();
|
|
|
}
|
|
|
|
|
|
+ console.log(this.configList);
|
|
|
+
|
|
|
this.showSensor(this.configList.camera, "camera");
|
|
|
this.showSensor(this.configList.ogt, "ogt");
|
|
|
this.showSensor(this.configList.lidar, "lidar");
|
|
@@ -1055,16 +1176,170 @@ export default {
|
|
|
obj.clear();
|
|
|
arr = null;
|
|
|
},
|
|
|
+ showTX() {
|
|
|
+ var pointsArr1 = [
|
|
|
+ // [5, -1, 33],
|
|
|
+ // [5, 11, 33],
|
|
|
+ // [-5, -1, 33],
|
|
|
+ // [-5, 11, 33],
|
|
|
+ [0, 0, 0],
|
|
|
+ [10, -11, 66],
|
|
|
+ [30, 31, 66],
|
|
|
+ [-20, -21, 66],
|
|
|
+ [-30, 21, 66],
|
|
|
+ ];
|
|
|
+
|
|
|
+ let x = 0,
|
|
|
+ y = 0,
|
|
|
+ z = 0;
|
|
|
+
|
|
|
+ let r = 60;
|
|
|
+ z = r;
|
|
|
+
|
|
|
+ let a = 120,
|
|
|
+ b = 40;
|
|
|
+
|
|
|
+ x = Math.tan(THREE.MathUtils.degToRad(a / 2)) * r;
|
|
|
+ y = Math.tan(THREE.MathUtils.degToRad(b / 2)) * r;
|
|
|
+
|
|
|
+ let x1 = 0,
|
|
|
+ y1 = 0,
|
|
|
+ z1 = 0;
|
|
|
+
|
|
|
+ let r1 = 20;
|
|
|
+ z1 = r1;
|
|
|
+
|
|
|
+ x1 = Math.tan(THREE.MathUtils.degToRad(a / 2)) * r1;
|
|
|
+ y1 = Math.tan(THREE.MathUtils.degToRad(b / 2)) * r1;
|
|
|
+
|
|
|
+ let pointsArr2 = [
|
|
|
+ [0, 0, 0],
|
|
|
+ // [-x1, y1, z1],
|
|
|
+ // [-x1, -y1, z1],
|
|
|
+ // [x1, y1, z1],
|
|
|
+ // [x1, -y1, z1],
|
|
|
+ [-x, y, z],
|
|
|
+ [-x, -y, z],
|
|
|
+ [x, y, z],
|
|
|
+ [x, -y, z],
|
|
|
+ ];
|
|
|
+
|
|
|
+ let x2 = 0,
|
|
|
+ y2 = 0,
|
|
|
+ z2 = 0,
|
|
|
+ x3 = 0,
|
|
|
+ y3 = 0,
|
|
|
+ z3 = 0,
|
|
|
+ x4 = 0,
|
|
|
+ y4 = 0,
|
|
|
+ z4 = 0,
|
|
|
+ x6 = 0,
|
|
|
+ y6 = 0,
|
|
|
+ z6 = 0,
|
|
|
+ r2 = 90,
|
|
|
+ a2 = 30,
|
|
|
+ b2 = 60,
|
|
|
+ c2 = 90,
|
|
|
+ d2 = 60;
|
|
|
+
|
|
|
+ x2 = Math.tan(THREE.MathUtils.degToRad(a2 / 2)) * r2;
|
|
|
+ y2 = Math.tan(THREE.MathUtils.degToRad(b2 / 2)) * r2;
|
|
|
+ x3 = Math.tan(THREE.MathUtils.degToRad(c2 / 2)) * r2;
|
|
|
+ y3 = Math.tan(THREE.MathUtils.degToRad(d2 / 2)) * r2;
|
|
|
+
|
|
|
+ let pointsArr3 = [
|
|
|
+ [0, 0, 0],
|
|
|
+ [-x2, y3, r2],
|
|
|
+ [-x3, -y3, r2],
|
|
|
+ [x2, y2, r2],
|
|
|
+ [x3, -y2, r2],
|
|
|
+ ];
|
|
|
+ console.log(pointsArr3);
|
|
|
+
|
|
|
+ let points = pointsArr3.map(
|
|
|
+ (d) => new THREE.Vector3(d[0], d[1], d[2])
|
|
|
+ );
|
|
|
+
|
|
|
+ let material = new THREE.MeshPhongMaterial({
|
|
|
+ color: 0x2c85e1,
|
|
|
+ shininess: 60,
|
|
|
+ specular: 0x2c85e1,
|
|
|
+ // opacity: 0.5,
|
|
|
+ // transparent: true,
|
|
|
+ });
|
|
|
+
|
|
|
+ let tixing = new ConvexGeometry(points);
|
|
|
+ //通过ConvexGeometry凸包绘制一个梯台,当然也可以使用ExtrudeGeometry挤压几何体,
|
|
|
+ let tixingMesh = new THREE.Mesh(tixing, material);
|
|
|
+ this.scene.add(tixingMesh);
|
|
|
+ console.log(tixingMesh);
|
|
|
+
|
|
|
+ /* let vertices = [];
|
|
|
+
|
|
|
+ vertices.push(-155, 24, 90);
|
|
|
+ vertices.push(-63, -24, 90);
|
|
|
+ vertices.push(155, 91, 90);
|
|
|
+ vertices.push(63, -90, 90);
|
|
|
+
|
|
|
+ const geometry1 = new THREE.BufferGeometry();
|
|
|
+ geometry1.setAttribute(
|
|
|
+ "position",
|
|
|
+ new THREE.Float32BufferAttribute(vertices, 3)
|
|
|
+ );
|
|
|
+
|
|
|
+ const material1 = new THREE.PointsMaterial({
|
|
|
+ color: 0xff0000,
|
|
|
+ size: 10,
|
|
|
+ fog: false,
|
|
|
+ });
|
|
|
+
|
|
|
+ const points1 = new THREE.Points(geometry1, material1);
|
|
|
+
|
|
|
+ this.scene.add(points1); */
|
|
|
+
|
|
|
+ // if (this.transformControls) {
|
|
|
+ // this.transformControls.attach(tixingMesh);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // const a = new THREE.Vector3(1, 1, 0);
|
|
|
+ // const b = new THREE.Vector3(0, 0, 0);
|
|
|
+ // const d = a.distanceTo(b);
|
|
|
+ // const e = a.angleTo(b);
|
|
|
+
|
|
|
+ // console.log(d, e, (e * 180) / Math.PI, THREE.MathUtils.radToDeg(e));
|
|
|
+
|
|
|
+ // (value * Math.PI) / 180;
|
|
|
+ },
|
|
|
},
|
|
|
|
|
|
mounted() {
|
|
|
this.go();
|
|
|
-
|
|
|
- if (!this.isAdd) {
|
|
|
- setTimeout(() => {
|
|
|
- this.initCar();
|
|
|
- }, 270);
|
|
|
- }
|
|
|
+ // this.showTX();
|
|
|
+
|
|
|
+ // console.log(THREE.Loader.Handlers.add);
|
|
|
+ // THREE.Loader.Handlers.add( /\.dds$/i, new DDSLoader() );
|
|
|
+
|
|
|
+ // console.log(new THREE.LoadingManager()); RGBELoader
|
|
|
+ // let dds = new THREE.LoadingManager();
|
|
|
+ // dds.addHandler(/\.dds$/i, new DDSLoader());
|
|
|
+ // dds.addHandler(/\.rgb$/i, new RGBELoader());
|
|
|
+ // console.log(dds);
|
|
|
+
|
|
|
+ THREE.DefaultLoadingManager.addHandler(/\.dds$/i, new DDSLoader());
|
|
|
+ // THREE.DefaultLoadingManager.addHandler(/\.rgb$/i, new RGBELoader());
|
|
|
+ // console.log(THREE.DefaultLoadingManager);
|
|
|
+
|
|
|
+ // console.log(THREE.LoadingManager.addHandler);
|
|
|
+ // THREE.Loader.Handlers.add( /\.dds$/i, new DDSLoader());
|
|
|
+ // THREE.Loader.addHandler(/\.dds$/i, new DDSLoader());
|
|
|
+ // THREE.Loader.Handlers.add( /\.dds$/i, new THREE.DDSLoader() );
|
|
|
+ // THREE.Loader.Handlers.add( /\.dds$/i, new THREE.DDSLoader() );
|
|
|
+
|
|
|
+ // if (!this.isAdd) {
|
|
|
+ // setTimeout(() => {
|
|
|
+ // this.initCar();
|
|
|
+ // }, 270);
|
|
|
+ // }
|
|
|
},
|
|
|
destroyed() {
|
|
|
window.removeEventListener("resize", this.onWindowResize);
|
|
@@ -1097,7 +1372,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
if (this.cacheList.length > 0) {
|
|
|
- this.scene.remove(...this.cacheList);
|
|
|
+ // this.scene.remove(...this.cacheList);
|
|
|
this.cacheList = [];
|
|
|
}
|
|
|
|