|
@@ -10,12 +10,24 @@ import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
|
|
|
import { ConvexGeometry } from "three/examples/jsm/geometries/ConvexGeometry.js";
|
|
|
import { OBJLoader } from "three/examples/jsm/loaders/OBJLoader.js";
|
|
|
import { MTLLoader } from "three/examples/jsm/loaders/MTLLoader.js";
|
|
|
-// import { mergeVertices } from "three/examples/jsm/utils/BufferGeometryUtils.js";
|
|
|
+import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
|
+// import * as BufferGeometryUtils from "three/examples/jsm/utils/BufferGeometryUtils.js";
|
|
|
+import { BufferGeometryUtils } from "three/examples/jsm/utils/BufferGeometryUtils.js";
|
|
|
import { mapState } from "vuex";
|
|
|
-// import {
|
|
|
-// showFullScreenLoading,
|
|
|
-// tryHideFullScreenLoading,
|
|
|
-// } from "../../../axios/filter";
|
|
|
+
|
|
|
+// "three": "^0.142.0"
|
|
|
+const ThreeBSP = require('three-js-csg')(THREE)
|
|
|
+// import ThreeBSP from "../common/ThreeCSG";
|
|
|
+
|
|
|
+// import { ThreeBSP } from "../common/ThreeBSP";
|
|
|
+
|
|
|
+
|
|
|
+// import { ADDITION, SUBTRACTION, INTERSECTION, DIFFERENCE, Brush, Evaluator } from 'three-bvh-csg';
|
|
|
+
|
|
|
+import {
|
|
|
+ showFullScreenLoading,
|
|
|
+ tryHideFullScreenLoading,
|
|
|
+} from "../../../axios/filter";
|
|
|
|
|
|
export default {
|
|
|
name: "threeSensorModel", // 传感器配置中的threeJS
|
|
@@ -29,7 +41,7 @@ export default {
|
|
|
renderer: null,
|
|
|
light: null,
|
|
|
transformControls: null,
|
|
|
- geometryName: null,
|
|
|
+ geometryName: "cube",
|
|
|
controls: null,
|
|
|
mesh: null,
|
|
|
cube: null,
|
|
@@ -46,6 +58,32 @@ export default {
|
|
|
lidar: null,
|
|
|
gps: null,
|
|
|
// scale: 2, // 物体加载换算倍数
|
|
|
+ group1: null,
|
|
|
+ group2: null,
|
|
|
+ r: 15,
|
|
|
+ r1: 6,
|
|
|
+ horizontal: 120,
|
|
|
+ vertical: 90,
|
|
|
+ horizontalL: 100,
|
|
|
+ horizontalR: 60,
|
|
|
+ verticalT: 30,
|
|
|
+ verticalB: 30,
|
|
|
+ a1: null,
|
|
|
+ b1: null,
|
|
|
+ c1: null,
|
|
|
+ d1: null,
|
|
|
+ a2: null,
|
|
|
+ b2: null,
|
|
|
+ c2: null,
|
|
|
+ d2: null,
|
|
|
+ x1: null,
|
|
|
+ y1: null,
|
|
|
+ z1: null,
|
|
|
+ w1: null,
|
|
|
+ x2: null,
|
|
|
+ y2: null,
|
|
|
+ z2: null,
|
|
|
+ w2: null,
|
|
|
};
|
|
|
},
|
|
|
|
|
@@ -60,7 +98,7 @@ export default {
|
|
|
},
|
|
|
coordinateA: {
|
|
|
type: Object,
|
|
|
- default: { f: 0, n: 0, hl: 0, hr: 0, vl: 0, vb: 0 },
|
|
|
+ default: { f: 0, n: 0, hl: 0, hr: 0, vt: 0, vb: 0 },
|
|
|
},
|
|
|
type: {
|
|
|
type: Number,
|
|
@@ -72,9 +110,10 @@ export default {
|
|
|
// 场景
|
|
|
initScene() {
|
|
|
this.scene = new THREE.Scene();
|
|
|
- let axes = new THREE.AxesHelper(1500);
|
|
|
+ let axes = new THREE.AxesHelper(12000);
|
|
|
this.scene.add(axes);
|
|
|
- const gridHelper = new THREE.GridHelper(1000, 100);
|
|
|
+
|
|
|
+ const gridHelper = new THREE.GridHelper(21000, 2100);
|
|
|
gridHelper.material.opacity = 0.25;
|
|
|
gridHelper.material.transparent = true;
|
|
|
this.scene.add(gridHelper);
|
|
@@ -85,7 +124,7 @@ export default {
|
|
|
75,
|
|
|
this.container.clientWidth / this.container.clientHeight,
|
|
|
0.1,
|
|
|
- 1000
|
|
|
+ 30000
|
|
|
);
|
|
|
|
|
|
this.camera.position.set(200, 200, 200);
|
|
@@ -132,7 +171,7 @@ export default {
|
|
|
this.clearCache(sensor);
|
|
|
}
|
|
|
|
|
|
- if (this.type === 1) {
|
|
|
+ /* if (this.type === 1) {
|
|
|
if (this.cameraSensor) {
|
|
|
this.scene.add(this.cameraSensor);
|
|
|
} else {
|
|
@@ -156,7 +195,7 @@ export default {
|
|
|
} else {
|
|
|
this.initSensor({ x: 0, y: 0, z: 0 }, "gps");
|
|
|
}
|
|
|
- }
|
|
|
+ } */
|
|
|
|
|
|
if (this.type != 2) {
|
|
|
let r = this.coordinate.f;
|
|
@@ -190,8 +229,8 @@ export default {
|
|
|
if (a >= 90) a = 89.99;
|
|
|
if (b >= 90) b = 89.99;
|
|
|
|
|
|
- x = Math.tan(THREE.MathUtils.degToRad(a)) * r;
|
|
|
- y = Math.tan(THREE.MathUtils.degToRad(b)) * r;
|
|
|
+ // x = Math.tan(THREE.MathUtils.degToRad(a)) * r;
|
|
|
+ // y = Math.tan(THREE.MathUtils.degToRad(b)) * r;
|
|
|
|
|
|
let pointsArr = [];
|
|
|
|
|
@@ -208,8 +247,8 @@ export default {
|
|
|
y1 = 0,
|
|
|
z1 = r1;
|
|
|
|
|
|
- x1 = Math.tan(THREE.MathUtils.degToRad(a)) * r1;
|
|
|
- y1 = Math.tan(THREE.MathUtils.degToRad(b)) * r1;
|
|
|
+ // x1 = Math.tan(THREE.MathUtils.degToRad(a)) * r1;
|
|
|
+ // y1 = Math.tan(THREE.MathUtils.degToRad(b)) * r1;
|
|
|
|
|
|
pointsArr = [
|
|
|
[x1, y1, z1],
|
|
@@ -243,10 +282,10 @@ export default {
|
|
|
if (c >= 90) c = 89.99;
|
|
|
if (d >= 90) d = 89.99;
|
|
|
|
|
|
- x1 = Math.tan(THREE.MathUtils.degToRad(a)) * r;
|
|
|
- y1 = Math.tan(THREE.MathUtils.degToRad(b)) * r;
|
|
|
- x2 = Math.tan(THREE.MathUtils.degToRad(c)) * r;
|
|
|
- y2 = Math.tan(THREE.MathUtils.degToRad(d)) * r;
|
|
|
+ // x1 = Math.tan(THREE.MathUtils.degToRad(a)) * r;
|
|
|
+ // y1 = Math.tan(THREE.MathUtils.degToRad(b)) * r;
|
|
|
+ // x2 = Math.tan(THREE.MathUtils.degToRad(c)) * r;
|
|
|
+ // y2 = Math.tan(THREE.MathUtils.degToRad(d)) * r;
|
|
|
|
|
|
let pointsArr = [];
|
|
|
|
|
@@ -265,10 +304,10 @@ export default {
|
|
|
n2 = 0,
|
|
|
z2 = r1;
|
|
|
|
|
|
- m1 = Math.tan(THREE.MathUtils.degToRad(a)) * r1;
|
|
|
- n1 = Math.tan(THREE.MathUtils.degToRad(b)) * r1;
|
|
|
- m2 = Math.tan(THREE.MathUtils.degToRad(c)) * r1;
|
|
|
- n2 = Math.tan(THREE.MathUtils.degToRad(d)) * r1;
|
|
|
+ // m1 = Math.tan(THREE.MathUtils.degToRad(a)) * r1;
|
|
|
+ // n1 = Math.tan(THREE.MathUtils.degToRad(b)) * r1;
|
|
|
+ // m2 = Math.tan(THREE.MathUtils.degToRad(c)) * r1;
|
|
|
+ // n2 = Math.tan(THREE.MathUtils.degToRad(d)) * r1;
|
|
|
|
|
|
pointsArr = [
|
|
|
[m1, n1, z2],
|
|
@@ -284,246 +323,2257 @@ export default {
|
|
|
|
|
|
this.initMesh(pointsArr);
|
|
|
},
|
|
|
- initMesh(pointsArr) {
|
|
|
- let points = pointsArr.map(
|
|
|
- (d) => new THREE.Vector3(d[0], d[1], d[2])
|
|
|
+ initDemo() {
|
|
|
+ let horizontal = this.horizontal;
|
|
|
+
|
|
|
+ let phiStart = Math.PI * ((90 - horizontal) / 180),
|
|
|
+ phiLength = Math.PI * (horizontal * 2 / 180),
|
|
|
+ thetaStart = Math.PI * 0,
|
|
|
+ thetaLength = Math.PI * 1;
|
|
|
+
|
|
|
+ const geometry = new THREE.SphereGeometry(
|
|
|
+ 15, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
);
|
|
|
+ const material = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
|
|
|
- let color = null;
|
|
|
- if (this.type === 1) {
|
|
|
- color = 0x0000ff;
|
|
|
- } else if (this.type === 2) {
|
|
|
- color = 0x008000;
|
|
|
- } else if (this.type === 3) {
|
|
|
- color = 0xff4500;
|
|
|
- } else {
|
|
|
- color = 0x0000ff;
|
|
|
- }
|
|
|
|
|
|
- let material = new THREE.MeshPhongMaterial({
|
|
|
- emissive: color,
|
|
|
- color: 0x4c4c4c,
|
|
|
- transparent: true,
|
|
|
- opacity: 0.3,
|
|
|
- lightMapIntensity: 0.1,
|
|
|
- side: THREE.DoubleSide,
|
|
|
- });
|
|
|
|
|
|
- let tixing = new ConvexGeometry(points);
|
|
|
- //通过ConvexGeometry凸包绘制一个梯台,当然也可以使用ExtrudeGeometry挤压几何体,
|
|
|
- let tixingMesh = new THREE.Mesh(tixing, material);
|
|
|
- tixingMesh.name = "cube";
|
|
|
- this.scene.add(tixingMesh);
|
|
|
- },
|
|
|
- // 初始化传感器
|
|
|
- initSensor(
|
|
|
- pos = { x: 0, y: 0, z: 0 },
|
|
|
- type = "camera",
|
|
|
- canMove = false
|
|
|
- ) {
|
|
|
- let Loader = new MTLLoader(); //材质文件加载器
|
|
|
- let loader = new OBJLoader(); //obj加载器
|
|
|
- let that = this;
|
|
|
- let mtlUrl = "";
|
|
|
- let objUrl = "";
|
|
|
|
|
|
- if (type === "camera") {
|
|
|
- mtlUrl = `${that.publicPath}sensor/camera/camera.mtl`;
|
|
|
- objUrl = `${that.publicPath}sensor/camera/camera.obj`;
|
|
|
- } else if (type === "ogt") {
|
|
|
- mtlUrl = `${that.publicPath}sensor/ogt/millimeter_wave_radar.mtl`;
|
|
|
- objUrl = `${that.publicPath}sensor/ogt/millimeter_wave_radar.obj`;
|
|
|
- } else if (type === "lidar") {
|
|
|
- mtlUrl = `${that.publicPath}sensor/lidar/LIDAR.mtl`;
|
|
|
- objUrl = `${that.publicPath}sensor/lidar/LIDAR.obj`;
|
|
|
- } else if (type === "gps") {
|
|
|
- mtlUrl = `${that.publicPath}sensor/gps/lidar.mtl`;
|
|
|
- objUrl = `${that.publicPath}sensor/gps/lidar.obj`;
|
|
|
- }
|
|
|
+ const sphere = new THREE.Mesh(geometry, material);
|
|
|
+ // sphere.rotateY(Math.PI * -0.25);
|
|
|
+ // this.scene.add(sphere);
|
|
|
|
|
|
- this.$emit('loadingDone', 'carStart');
|
|
|
|
|
|
- // if (type === "ogt") {
|
|
|
- // showFullScreenLoading();
|
|
|
- // }
|
|
|
|
|
|
- Loader.load(
|
|
|
- mtlUrl,
|
|
|
- function (materials) {
|
|
|
- loader.setMaterials(materials);
|
|
|
- loader.load(objUrl, function (obj) {
|
|
|
- // if (type === "ogt") {
|
|
|
- // tryHideFullScreenLoading();
|
|
|
- // }
|
|
|
+ const geometry1 = new THREE.CircleGeometry(
|
|
|
+ 15, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
|
|
|
- that.$emit('loadingDone', 'carDone');
|
|
|
+ const material1 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle1 = new THREE.Mesh(geometry1, material1);
|
|
|
+ circle1.rotateZ(Math.PI * -0.5);
|
|
|
+ circle1.rotateX(phiStart);
|
|
|
+ // this.scene.add(circle1); // left
|
|
|
|
|
|
- if (type === "camera") {
|
|
|
- that.cameraSensor = obj;
|
|
|
- } else if (type === "ogt") {
|
|
|
- that.ogt = obj;
|
|
|
- } else if (type === "lidar") {
|
|
|
- that.lidar = obj;
|
|
|
- } else if (type === "gps") {
|
|
|
- that.gps = 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(scale, scale, scale);
|
|
|
- } else if (type === "ogt") {
|
|
|
- let scale = 0.2 * that.scale;
|
|
|
- obj.children[i].scale.set(scale, scale, scale);
|
|
|
- } else if (type === "lidar") {
|
|
|
- let scale = 0.1 * that.scale;
|
|
|
- obj.children[i].scale.set(scale, scale, scale);
|
|
|
- } else if (type === "gps") {
|
|
|
- let scale = 40 * that.scale;
|
|
|
- obj.children[i].scale.set(scale, scale, scale);
|
|
|
- }
|
|
|
- }
|
|
|
- obj.position.set(pos.x, pos.y, pos.z);
|
|
|
- obj.name = "sensor";
|
|
|
|
|
|
- that.sensor = obj;
|
|
|
+ const geometry2 = new THREE.CircleGeometry(
|
|
|
+ 15, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
|
|
|
- that.scene.add(that.sensor); //返回的组对象插入场景中
|
|
|
- });
|
|
|
- },
|
|
|
- (xhr) => {
|
|
|
- // console.log((xhr.loaded / xhr.total) * 100 + "% loaded");
|
|
|
- },
|
|
|
- (error) => {
|
|
|
- // if (type === "ogt") {
|
|
|
- // tryHideFullScreenLoading();
|
|
|
- // }
|
|
|
+ const material2 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle2 = new THREE.Mesh(geometry2, material2);
|
|
|
+ circle2.rotateZ(Math.PI * 0.5);
|
|
|
+ circle2.rotateX(phiStart);
|
|
|
+ // this.scene.add(circle2); // right
|
|
|
|
|
|
- that.$emit('loadingDone', 'carDone');
|
|
|
+ const group = new THREE.Group();
|
|
|
+ group.add(sphere);
|
|
|
+ group.add(circle1);
|
|
|
+ group.add(circle2);
|
|
|
|
|
|
- console.error(error);
|
|
|
- }
|
|
|
- );
|
|
|
- },
|
|
|
- // 初始化
|
|
|
- init() {
|
|
|
- this.initScene();
|
|
|
- this.initCamera();
|
|
|
- this.initRenderer();
|
|
|
- this.initLight();
|
|
|
+ group.translateZ(40);
|
|
|
|
|
|
- this.controls = new OrbitControls(
|
|
|
- this.camera,
|
|
|
- this.renderer.domElement
|
|
|
- ); //创建控件对象
|
|
|
- this.controls.minDistance = 30;
|
|
|
- this.controls.maxDistance = 720;
|
|
|
- this.controls.update();
|
|
|
+ this.scene.add(group);
|
|
|
},
|
|
|
- animate() {
|
|
|
- this.raf = requestAnimationFrame(this.animate);
|
|
|
- this.renderer.render(this.scene, this.camera);
|
|
|
- if (this.transformControls) {
|
|
|
- this.transformControls.update();
|
|
|
- }
|
|
|
+ initDemo1() {
|
|
|
+ let vertical = this.vertical;
|
|
|
|
|
|
- this.controls.update();
|
|
|
- },
|
|
|
- onWindowResize() {
|
|
|
- this.camera.aspect =
|
|
|
- this.container.clientWidth / this.container.clientHeight;
|
|
|
- this.camera.updateProjectionMatrix();
|
|
|
- this.renderer.setSize(
|
|
|
- this.container.clientWidth,
|
|
|
- this.container.clientHeight
|
|
|
+ let phiStart = Math.PI * ((90 - vertical) / 180),
|
|
|
+ phiLength = Math.PI * (vertical * 2 / 180),
|
|
|
+ thetaStart = Math.PI * 0,
|
|
|
+ thetaLength = Math.PI * 1;
|
|
|
+
|
|
|
+ const geometry = new THREE.SphereGeometry(
|
|
|
+ 15, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
);
|
|
|
- },
|
|
|
- go() {
|
|
|
- this.container = document.getElementById(
|
|
|
- "containerThreeSensorModel"
|
|
|
+ const material = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+ const sphere = new THREE.Mesh(geometry, material);
|
|
|
+ sphere.rotateZ(Math.PI * 0.5);
|
|
|
+ // this.scene.add(sphere);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry1 = new THREE.CircleGeometry(
|
|
|
+ 15, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
);
|
|
|
- this.init();
|
|
|
- this.animate();
|
|
|
|
|
|
- window.addEventListener("resize", this.onWindowResize);
|
|
|
- },
|
|
|
- removeScene() {
|
|
|
- this.clearScene();
|
|
|
- },
|
|
|
- clearCache(item) {
|
|
|
- if (item.geometry && item.geometry.dispose) item.geometry.dispose();
|
|
|
- if (item.material && item.material.dispose) item.material.dispose();
|
|
|
- },
|
|
|
- clearScene() {
|
|
|
- this.removeObj(this.scene);
|
|
|
+ const material1 = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+ const circle1 = new THREE.Mesh(geometry1, material1);
|
|
|
+ // circle1.rotateZ(Math.PI * -0.5);
|
|
|
+ circle1.rotateX(phiStart);
|
|
|
+ // this.scene.add(circle1); // top
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry2 = new THREE.CircleGeometry(
|
|
|
+ 15, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material2 = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+ const circle2 = new THREE.Mesh(geometry2, material2);
|
|
|
+ // circle2.rotateY(Math.PI * 0.5);
|
|
|
+ circle2.rotateX(-phiStart - Math.PI);
|
|
|
+ // this.scene.add(circle2); // bottom
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const group = new THREE.Group();
|
|
|
+ group.add(sphere);
|
|
|
+ group.add(circle1);
|
|
|
+ group.add(circle2);
|
|
|
+
|
|
|
+ group.translateZ(40);
|
|
|
+
|
|
|
+ this.scene.add(group);
|
|
|
},
|
|
|
- removeObj(obj) {
|
|
|
- let arr = obj.children.filter((x) => x);
|
|
|
- arr.forEach((item) => {
|
|
|
- if (item.children.length) {
|
|
|
- this.removeObj(item);
|
|
|
- } else {
|
|
|
- this.clearCache(item);
|
|
|
- item.clear();
|
|
|
- }
|
|
|
- }),
|
|
|
- obj.clear();
|
|
|
- arr = null;
|
|
|
+ initOgtDemo() {
|
|
|
+ let horizontal = this.horizontalR;
|
|
|
+
|
|
|
+ let phiStart = Math.PI * ((90 - horizontal) / 180),
|
|
|
+ phiLength = Math.PI * (horizontal / 180),
|
|
|
+ thetaStart = Math.PI * 0,
|
|
|
+ thetaLength = Math.PI * 1;
|
|
|
+
|
|
|
+ // phiStart = 0;
|
|
|
+
|
|
|
+ const geometry = new THREE.SphereGeometry(
|
|
|
+ 15, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
+ );
|
|
|
+ const material = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+
|
|
|
+ const sphere = new THREE.Mesh(geometry, material);
|
|
|
+ // sphere.rotateY(phiStart);
|
|
|
+ // this.scene.add(sphere); // 右
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let horizontal0 = this.horizontalL;
|
|
|
+
|
|
|
+ let phiStart0 = Math.PI * (90 / 180),
|
|
|
+ phiLength0 = Math.PI * (horizontal0 / 180),
|
|
|
+ thetaStart0 = Math.PI * 0,
|
|
|
+ thetaLength0 = Math.PI * 1;
|
|
|
+
|
|
|
+ // phiStart = 0;
|
|
|
+
|
|
|
+ const geometry0 = new THREE.SphereGeometry(
|
|
|
+ 15, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart0, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength0, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart0, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength0 // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
+ );
|
|
|
+ const material0 = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+
|
|
|
+ const sphere0 = new THREE.Mesh(geometry0, material0);
|
|
|
+ // sphere.rotateY(phiStart);
|
|
|
+ // this.scene.add(sphere0); // 左
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry1 = new THREE.CircleGeometry(
|
|
|
+ 15, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material1 = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+ const circle1 = new THREE.Mesh(geometry1, material1);
|
|
|
+ circle1.rotateZ(Math.PI * -0.5);
|
|
|
+ circle1.rotateX(Math.PI * ((90 - horizontal0) / 180));
|
|
|
+ // this.scene.add(circle1); // left
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry2 = new THREE.CircleGeometry(
|
|
|
+ 15, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material2 = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+ const circle2 = new THREE.Mesh(geometry2, material2);
|
|
|
+ circle2.rotateZ(Math.PI * 0.5);
|
|
|
+ circle2.rotateX(phiStart);
|
|
|
+ // this.scene.add(circle2); // right
|
|
|
+
|
|
|
+
|
|
|
+ const group = new THREE.Group();
|
|
|
+ group.add(sphere);
|
|
|
+ group.add(circle1);
|
|
|
+ group.add(circle2);
|
|
|
+ group.add(sphere0);
|
|
|
+
|
|
|
+ group.translateZ(40);
|
|
|
+
|
|
|
+ this.scene.add(group);
|
|
|
},
|
|
|
- },
|
|
|
+ initOgtDemo1() {
|
|
|
+ let vertical = this.verticalB;
|
|
|
|
|
|
- mounted() {
|
|
|
- this.go();
|
|
|
- },
|
|
|
- destroyed() {
|
|
|
- window.removeEventListener("resize", this.onWindowResize);
|
|
|
- cancelAnimationFrame(this.raf);
|
|
|
+ let phiStart = Math.PI * ((90 - vertical) / 180),
|
|
|
+ phiLength = Math.PI * (vertical / 180),
|
|
|
+ thetaStart = Math.PI * 0,
|
|
|
+ thetaLength = Math.PI * 1;
|
|
|
|
|
|
- if (this.renderer) {
|
|
|
- this.renderer.renderLists.dispose();
|
|
|
- this.renderer.dispose();
|
|
|
- this.renderer.forceContextLoss();
|
|
|
- this.renderer.domElement = null;
|
|
|
- this.renderer.content = null;
|
|
|
- this.renderer = null;
|
|
|
- }
|
|
|
+ const geometry = new THREE.SphereGeometry(
|
|
|
+ 15, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
+ );
|
|
|
+ const material = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const sphere = new THREE.Mesh(geometry, material);
|
|
|
+ sphere.rotateZ(Math.PI * 0.5);
|
|
|
+ // this.scene.add(sphere); // 下
|
|
|
|
|
|
- if (this.dragControls) {
|
|
|
- this.dragControls.deactivate();
|
|
|
- this.dragControls.dispose();
|
|
|
- this.dragControls = null;
|
|
|
- }
|
|
|
|
|
|
- if (this.controls) {
|
|
|
- this.controls.dispose();
|
|
|
- this.controls = null;
|
|
|
- }
|
|
|
|
|
|
- if (this.transformControls) {
|
|
|
- this.transformControls.detach();
|
|
|
- this.transformControls.dispose();
|
|
|
- this.transformControls = null;
|
|
|
- }
|
|
|
|
|
|
- if (this.cacheList.length > 0) {
|
|
|
- this.scene.remove(...this.cacheList);
|
|
|
- this.cacheList = [];
|
|
|
- }
|
|
|
|
|
|
- this.clearScene();
|
|
|
+ let vertical0 = this.verticalT;
|
|
|
|
|
|
- this.scene = null;
|
|
|
- this.camera = null;
|
|
|
- this.light = null;
|
|
|
- this.geometryName = null;
|
|
|
- this.mesh = null;
|
|
|
- this.cube = null;
|
|
|
- this.container = null;
|
|
|
- this.car = null;
|
|
|
+ let phiStart0 = Math.PI * (90 / 180),
|
|
|
+ phiLength0 = Math.PI * (vertical0 / 180),
|
|
|
+ thetaStart0 = Math.PI * 0,
|
|
|
+ thetaLength0 = Math.PI * 1;
|
|
|
+
|
|
|
+ const geometry0 = new THREE.SphereGeometry(
|
|
|
+ 15, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart0, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength0, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart0, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength0 // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
+ );
|
|
|
+ const material0 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const sphere0 = new THREE.Mesh(geometry0, material0);
|
|
|
+ sphere0.rotateZ(Math.PI * 0.5);
|
|
|
+ // this.scene.add(sphere0); // 上
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry1 = new THREE.CircleGeometry(
|
|
|
+ 15, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material1 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle1 = new THREE.Mesh(geometry1, material1);
|
|
|
+ circle1.rotateX(Math.PI * ((90 - vertical0) / 180));
|
|
|
+ // circle1.rotateZ(0);
|
|
|
+ // this.scene.add(circle1); // top
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry2 = new THREE.CircleGeometry(
|
|
|
+ 15, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material2 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle2 = new THREE.Mesh(geometry2, material2);
|
|
|
+ // let p = -phiStart - Math.PI;
|
|
|
+ circle2.rotateX(-phiStart - Math.PI);
|
|
|
+ // circle2.rotateZ(0);
|
|
|
+ // this.scene.add(circle2); // bottom
|
|
|
+
|
|
|
+ const group = new THREE.Group();
|
|
|
+ group.add(sphere);
|
|
|
+ group.add(circle1);
|
|
|
+ group.add(circle2);
|
|
|
+ group.add(sphere0);
|
|
|
+
|
|
|
+ group.translateZ(40);
|
|
|
+
|
|
|
+ this.scene.add(group);
|
|
|
+
|
|
|
+ },
|
|
|
+ initLeft() {
|
|
|
+ let horizontal = this.horizontal;
|
|
|
+
|
|
|
+ if (horizontal % 90 === 0) horizontal = horizontal - 0.1;
|
|
|
+
|
|
|
+ let phiStart = Math.PI * ((90 - horizontal) / 180),
|
|
|
+ phiLength = Math.PI * (horizontal * 2 / 180),
|
|
|
+ thetaStart = Math.PI * 0,
|
|
|
+ thetaLength = Math.PI * 1;
|
|
|
+
|
|
|
+ const geometry = new THREE.SphereGeometry(
|
|
|
+ this.r, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
+ );
|
|
|
+ const material = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const sphere = new THREE.Mesh(geometry, material);
|
|
|
+ // sphere.rotateY(Math.PI * -0.25);
|
|
|
+ // this.scene.add(sphere);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry1 = new THREE.CircleGeometry(
|
|
|
+ this.r, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material1 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle1 = new THREE.Mesh(geometry1, material1);
|
|
|
+ circle1.rotateZ(Math.PI * -0.5);
|
|
|
+ circle1.rotateX(phiStart);
|
|
|
+ // this.scene.add(circle1); // left
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry2 = new THREE.CircleGeometry(
|
|
|
+ this.r, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material2 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle2 = new THREE.Mesh(geometry2, material2);
|
|
|
+ circle2.rotateZ(Math.PI * 0.5);
|
|
|
+ circle2.rotateX(phiStart);
|
|
|
+ // this.scene.add(circle2); // right
|
|
|
+
|
|
|
+
|
|
|
+ /* const group = new THREE.Group();
|
|
|
+ group.add(sphere);
|
|
|
+ group.add(circle1);
|
|
|
+ group.add(circle2); */
|
|
|
+
|
|
|
+ // this.scene.add(group);
|
|
|
+
|
|
|
+ /* const geometry6 = new THREE.BoxGeometry(1, 1, 1);
|
|
|
+ const material6 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle6 = new THREE.Mesh(geometry6, material6); */
|
|
|
+
|
|
|
+ // let geometryArray = [geometry, geometry1, geometry2]; // 将你的要合并的多个geometry放入到该数组
|
|
|
+ // let materialArray = [material]; // 将你的要赋值的多个material放入到该数组
|
|
|
+ // 合并模型
|
|
|
+ // geometry.attributes = {
|
|
|
+ // faceVertexUvs: geometry.faceVertexUvs,
|
|
|
+ // faces: geometry.faces,
|
|
|
+ // }
|
|
|
+ // geometry.morphAttributes = {
|
|
|
+ // faceVertexUvs: geometry.faceVertexUvs,
|
|
|
+ // faces: geometry.faces,
|
|
|
+ // }
|
|
|
+
|
|
|
+ // console.log(geometry);
|
|
|
+ // console.log(geometry.attributes);
|
|
|
+ // console.log(geometry instanceof THREE.BufferGeometry);
|
|
|
+ // console.log(geometry.getAttribute());
|
|
|
+ // console.log(material);
|
|
|
+ // console.log(BufferGeometryUtils.mergeBufferGeometries);
|
|
|
+ // console.log(BufferGeometryUtils);
|
|
|
+ // const mergedGeometries = BufferGeometryUtils.mergeBufferGeometries(geometryArray);
|
|
|
+ // console.log(mergedGeometries);
|
|
|
+ // const singleMergeMesh = new THREE.Mesh(mergedGeometries, materialArray);
|
|
|
+
|
|
|
+ // this.scene.add(singleMergeMesh);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /* const geometry9 = BufferGeometryUtils.mergeBufferGeometries([
|
|
|
+ new THREE.BoxGeometry(2, 1, 1),
|
|
|
+ new THREE.CylinderGeometry(1, 1, 1, 10),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ console.log(geometry);
|
|
|
+ const mergedMesh = new THREE.Mesh(geometry9, material);
|
|
|
+
|
|
|
+ mergedMesh.position.y = -1;
|
|
|
+ // scene.add(car, mergedMesh); */
|
|
|
+
|
|
|
+
|
|
|
+ // sphere.add(circle1);
|
|
|
+ // sphere.add(circle2);
|
|
|
+
|
|
|
+
|
|
|
+ // this.group1 = new ThreeBSP(sphere);
|
|
|
+ // this.group1 = new ThreeBSP(singleMergeMesh);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // intersect (交集) union (并集) subtract (差集)
|
|
|
+
|
|
|
+ this.a1 = new ThreeBSP(sphere);
|
|
|
+ this.b1 = new ThreeBSP(circle1);
|
|
|
+ this.c1 = new ThreeBSP(circle2);
|
|
|
+
|
|
|
+ /* var m = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+ // const resultBSP = a.subtract(b);
|
|
|
+ const resultBSP = a.subtract(b).subtract(c).toMesh(m);
|
|
|
+ // this.group1 = new ThreeBSP(sphere);
|
|
|
+ console.log(resultBSP);
|
|
|
+ this.scene.add(resultBSP); */
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /* const evaluator = new Evaluator();
|
|
|
+ let a = new Brush(geometry, material);
|
|
|
+ a.updateMatrixWorld();
|
|
|
+ let b = new Brush(geometry1, material1);
|
|
|
+ b.rotateZ(Math.PI * -0.5);
|
|
|
+ b.rotateX(phiStart);
|
|
|
+ b.updateMatrixWorld();
|
|
|
+ let c = new Brush(geometry2, material2);
|
|
|
+ c.rotateZ(Math.PI * 0.5);
|
|
|
+ c.rotateX(phiStart);
|
|
|
+ c.updateMatrixWorld();
|
|
|
+
|
|
|
+ let result;
|
|
|
+ result = evaluator.evaluate(a, b, ADDITION);
|
|
|
+ result = evaluator.evaluate(result, c, ADDITION);
|
|
|
+
|
|
|
+ console.log(result); */
|
|
|
+
|
|
|
+ // this.scene.add(result);
|
|
|
+
|
|
|
+
|
|
|
+ // this.group1 = new Brush(geometry, material);
|
|
|
+ // this.group1 = result;
|
|
|
+ // this.group1 = new ThreeBSP(result.geometry);
|
|
|
+ },
|
|
|
+ initTop() {
|
|
|
+ let vertical = this.vertical;
|
|
|
+
|
|
|
+ if (vertical % 90 === 0) vertical = vertical - 0.1;
|
|
|
+
|
|
|
+ let phiStart = Math.PI * ((90 - vertical) / 180),
|
|
|
+ phiLength = Math.PI * (vertical * 2 / 180),
|
|
|
+ thetaStart = Math.PI * 0,
|
|
|
+ thetaLength = Math.PI * 1;
|
|
|
+
|
|
|
+ const geometry = new THREE.SphereGeometry(
|
|
|
+ this.r, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
+ );
|
|
|
+ const material = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+ const sphere = new THREE.Mesh(geometry, material);
|
|
|
+ sphere.rotateZ(Math.PI * 0.5);
|
|
|
+ // this.scene.add(sphere);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry1 = new THREE.CircleGeometry(
|
|
|
+ this.r, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material1 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle1 = new THREE.Mesh(geometry1, material1);
|
|
|
+ circle1.rotateX(phiStart);
|
|
|
+ // circle1.rotateZ(0);
|
|
|
+ // this.scene.add(circle1); // top
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry2 = new THREE.CircleGeometry(
|
|
|
+ this.r, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material2 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle2 = new THREE.Mesh(geometry2, material2);
|
|
|
+ // let p = -phiStart - Math.PI;
|
|
|
+ circle2.rotateX(-phiStart - Math.PI);
|
|
|
+ // circle2.rotateZ(0);
|
|
|
+ // this.scene.add(circle2); // bottom
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /* const group = new THREE.Group();
|
|
|
+ group.add(sphere);
|
|
|
+ group.add(circle1);
|
|
|
+ group.add(circle2); */
|
|
|
+
|
|
|
+ // this.scene.add(group);
|
|
|
+
|
|
|
+
|
|
|
+ /* let geometryArray = [geometry, geometry1, geometry2]; // 将你的要合并的多个geometry放入到该数组
|
|
|
+ let materialArray = [material]; // 将你的要赋值的多个material放入到该数组
|
|
|
+ const mergedGeometries = BufferGeometryUtils.mergeBufferGeometries(geometryArray);
|
|
|
+ const singleMergeMesh = new THREE.Mesh(mergedGeometries, materialArray); */
|
|
|
+
|
|
|
+ // sphere.add(circle1);
|
|
|
+ // sphere.add(circle2);
|
|
|
+
|
|
|
+
|
|
|
+ // this.group2 = new ThreeBSP(singleMergeMesh);
|
|
|
+ // this.group2 = new ThreeBSP(sphere);
|
|
|
+
|
|
|
+ /* this.a1 = new ThreeBSP(sphere);
|
|
|
+ this.b1 = new ThreeBSP(circle1);
|
|
|
+ this.c1 = new ThreeBSP(circle2); */
|
|
|
+
|
|
|
+
|
|
|
+ this.a2 = new ThreeBSP(sphere);
|
|
|
+ this.b2 = new ThreeBSP(circle1);
|
|
|
+ this.c2 = new ThreeBSP(circle2);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /* const evaluator = new Evaluator();
|
|
|
+ let a = new Brush(geometry, material);
|
|
|
+ a.rotateZ(Math.PI * 0.5);
|
|
|
+ a.updateMatrixWorld();
|
|
|
+ let b = new Brush(geometry1, material1);
|
|
|
+ b.rotateX(phiStart);
|
|
|
+ b.updateMatrixWorld();
|
|
|
+ let c = new Brush(geometry2, material2);
|
|
|
+ c.rotateX(-phiStart - Math.PI);
|
|
|
+ c.updateMatrixWorld();
|
|
|
+
|
|
|
+ let result;
|
|
|
+ result = evaluator.evaluate(a, c, SUBTRACTION);
|
|
|
+ result = evaluator.evaluate(result, b, ADDITION);
|
|
|
+
|
|
|
+ this.scene.add(result);
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // this.group2 = new Brush(geometry, material);
|
|
|
+ // this.group2 = result;
|
|
|
+ // this.group2 = new ThreeBSP(result.geometry);
|
|
|
+ },
|
|
|
+ initLeft1() {
|
|
|
+ let horizontal = this.horizontal;
|
|
|
+
|
|
|
+ if (horizontal % 90 === 0) horizontal = horizontal - 0.1;
|
|
|
+
|
|
|
+ let phiStart = Math.PI * ((90 - horizontal) / 180),
|
|
|
+ phiLength = Math.PI * (horizontal * 2 / 180),
|
|
|
+ thetaStart = Math.PI * 0,
|
|
|
+ thetaLength = Math.PI * 1;
|
|
|
+
|
|
|
+ const geometry = new THREE.SphereGeometry(
|
|
|
+ this.r1, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
+ );
|
|
|
+ const material = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+
|
|
|
+ const sphere = new THREE.Mesh(geometry, material);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry1 = new THREE.CircleGeometry(
|
|
|
+ this.r1, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material1 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle1 = new THREE.Mesh(geometry1, material1);
|
|
|
+ circle1.rotateZ(Math.PI * -0.5);
|
|
|
+ circle1.rotateX(phiStart);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry2 = new THREE.CircleGeometry(
|
|
|
+ this.r1, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material2 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle2 = new THREE.Mesh(geometry2, material2);
|
|
|
+ circle2.rotateZ(Math.PI * 0.5);
|
|
|
+ circle2.rotateX(phiStart);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ this.x1 = new ThreeBSP(sphere);
|
|
|
+ this.y1 = new ThreeBSP(circle1);
|
|
|
+ this.z1 = new ThreeBSP(circle2);
|
|
|
+
|
|
|
+ },
|
|
|
+ initTop1() {
|
|
|
+ let vertical = this.vertical;
|
|
|
+
|
|
|
+ if (vertical % 90 === 0) vertical = vertical - 0.1;
|
|
|
+
|
|
|
+ let phiStart = Math.PI * ((90 - vertical) / 180),
|
|
|
+ phiLength = Math.PI * (vertical * 2 / 180),
|
|
|
+ thetaStart = Math.PI * 0,
|
|
|
+ thetaLength = Math.PI * 1;
|
|
|
+
|
|
|
+ const geometry = new THREE.SphereGeometry(
|
|
|
+ this.r1, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
+ );
|
|
|
+ const material = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+ const sphere = new THREE.Mesh(geometry, material);
|
|
|
+ sphere.rotateZ(Math.PI * 0.5);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry1 = new THREE.CircleGeometry(
|
|
|
+ this.r1, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material1 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle1 = new THREE.Mesh(geometry1, material1);
|
|
|
+ circle1.rotateX(phiStart);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry2 = new THREE.CircleGeometry(
|
|
|
+ this.r1, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material2 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle2 = new THREE.Mesh(geometry2, material2);
|
|
|
+ let p = -phiStart - Math.PI;
|
|
|
+ circle2.rotateX(p);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ this.x2 = new ThreeBSP(sphere);
|
|
|
+ this.y2 = new ThreeBSP(circle1);
|
|
|
+ this.z2 = new ThreeBSP(circle2);
|
|
|
+ },
|
|
|
+ initOgt() {
|
|
|
+ let horizontal = this.horizontalR;
|
|
|
+
|
|
|
+ if ((horizontal + this.horizontalL) % 180 === 0) horizontal = horizontal - 0.1;
|
|
|
+
|
|
|
+ let phiStart = Math.PI * ((90 - horizontal) / 180),
|
|
|
+ phiLength = Math.PI * (horizontal / 180),
|
|
|
+ thetaStart = Math.PI * 0,
|
|
|
+ thetaLength = Math.PI * 1;
|
|
|
+
|
|
|
+ // phiStart = 0;
|
|
|
+
|
|
|
+ const geometry = new THREE.SphereGeometry(
|
|
|
+ 15, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
+ );
|
|
|
+ const material = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+
|
|
|
+ const sphere = new THREE.Mesh(geometry, material);
|
|
|
+ // sphere.rotateY(phiStart);
|
|
|
+ // this.scene.add(sphere); // 右
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let horizontal0 = this.horizontalL;
|
|
|
+
|
|
|
+ let phiStart0 = Math.PI * (90 / 180),
|
|
|
+ phiLength0 = Math.PI * (horizontal0 / 180),
|
|
|
+ thetaStart0 = Math.PI * 0,
|
|
|
+ thetaLength0 = Math.PI * 1;
|
|
|
+
|
|
|
+ // phiStart = 0;
|
|
|
+
|
|
|
+ const geometry0 = new THREE.SphereGeometry(
|
|
|
+ 15, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart0, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength0, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart0, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength0 // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
+ );
|
|
|
+ const material0 = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+
|
|
|
+ const sphere0 = new THREE.Mesh(geometry0, material0);
|
|
|
+ // sphere.rotateY(phiStart);
|
|
|
+ // this.scene.add(sphere0); // 左
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry1 = new THREE.CircleGeometry(
|
|
|
+ 15, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material1 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle1 = new THREE.Mesh(geometry1, material1);
|
|
|
+ circle1.rotateZ(Math.PI * -0.5);
|
|
|
+ circle1.rotateX(Math.PI * ((90 - horizontal0) / 180));
|
|
|
+ // this.scene.add(circle1); // left
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry2 = new THREE.CircleGeometry(
|
|
|
+ 15, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material2 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle2 = new THREE.Mesh(geometry2, material2);
|
|
|
+ circle2.rotateZ(Math.PI * 0.5);
|
|
|
+ circle2.rotateX(phiStart);
|
|
|
+ // this.scene.add(circle2); // right
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ this.a1 = new ThreeBSP(sphere);
|
|
|
+ this.b1 = new ThreeBSP(circle1);
|
|
|
+ this.c1 = new ThreeBSP(circle2);
|
|
|
+ this.d1 = new ThreeBSP(sphere0);
|
|
|
+ },
|
|
|
+ initOgt1() {
|
|
|
+ let vertical = this.verticalB;
|
|
|
+
|
|
|
+ if ((vertical + this.verticalT) % 180 === 0) vertical = vertical - 0.1;
|
|
|
+
|
|
|
+ let phiStart = Math.PI * ((90 - vertical) / 180),
|
|
|
+ phiLength = Math.PI * (vertical / 180),
|
|
|
+ thetaStart = Math.PI * 0,
|
|
|
+ thetaLength = Math.PI * 1;
|
|
|
+
|
|
|
+ const geometry = new THREE.SphereGeometry(
|
|
|
+ 15, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
+ );
|
|
|
+ const material = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+ const sphere = new THREE.Mesh(geometry, material);
|
|
|
+ sphere.rotateZ(Math.PI * 0.5);
|
|
|
+ // this.scene.add(sphere); // 下
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let vertical0 = this.verticalT;
|
|
|
+
|
|
|
+ let phiStart0 = Math.PI * (90 / 180),
|
|
|
+ phiLength0 = Math.PI * (vertical0 / 180),
|
|
|
+ thetaStart0 = Math.PI * 0,
|
|
|
+ thetaLength0 = Math.PI * 1;
|
|
|
+
|
|
|
+ const geometry0 = new THREE.SphereGeometry(
|
|
|
+ 15, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart0, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength0, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart0, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength0 // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
+ );
|
|
|
+ const material0 = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+ const sphere0 = new THREE.Mesh(geometry0, material0);
|
|
|
+ sphere0.rotateZ(Math.PI * 0.5);
|
|
|
+ // this.scene.add(sphere0); // 上
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry1 = new THREE.CircleGeometry(
|
|
|
+ 15, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material1 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle1 = new THREE.Mesh(geometry1, material1);
|
|
|
+ circle1.rotateX(Math.PI * ((90 - vertical0) / 180));
|
|
|
+ // circle1.rotateZ(0);
|
|
|
+ // this.scene.add(circle1); // top
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry2 = new THREE.CircleGeometry(
|
|
|
+ 15, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material2 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle2 = new THREE.Mesh(geometry2, material2);
|
|
|
+ // let p = -phiStart - Math.PI;
|
|
|
+ circle2.rotateX(-phiStart - Math.PI);
|
|
|
+ // circle2.rotateZ(0);
|
|
|
+ // this.scene.add(circle2); // bottom
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ this.a2 = new ThreeBSP(sphere);
|
|
|
+ this.b2 = new ThreeBSP(circle1);
|
|
|
+ this.c2 = new ThreeBSP(circle2);
|
|
|
+ this.d2 = new ThreeBSP(sphere0);
|
|
|
+ },
|
|
|
+ initOgt0() {
|
|
|
+ let horizontal = this.horizontalR;
|
|
|
+
|
|
|
+ if ((horizontal + this.horizontalL) % 90 === 0) horizontal = horizontal - 0.1;
|
|
|
+
|
|
|
+ let phiStart = Math.PI * ((90 - horizontal) / 180),
|
|
|
+ phiLength = Math.PI * (horizontal / 180),
|
|
|
+ thetaStart = Math.PI * 0,
|
|
|
+ thetaLength = Math.PI * 1;
|
|
|
+
|
|
|
+ // phiStart = 0;
|
|
|
+
|
|
|
+ const geometry = new THREE.SphereGeometry(
|
|
|
+ 6, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
+ );
|
|
|
+ const material = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+
|
|
|
+ const sphere = new THREE.Mesh(geometry, material);
|
|
|
+ // sphere.rotateY(phiStart);
|
|
|
+ // this.scene.add(sphere); // 右
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let horizontal0 = this.horizontalL;
|
|
|
+
|
|
|
+ let phiStart0 = Math.PI * (90 / 180),
|
|
|
+ phiLength0 = Math.PI * (horizontal0 / 180),
|
|
|
+ thetaStart0 = Math.PI * 0,
|
|
|
+ thetaLength0 = Math.PI * 1;
|
|
|
+
|
|
|
+ // phiStart = 0;
|
|
|
+
|
|
|
+ const geometry0 = new THREE.SphereGeometry(
|
|
|
+ 6, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart0, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength0, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart0, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength0 // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
+ );
|
|
|
+ const material0 = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+
|
|
|
+ const sphere0 = new THREE.Mesh(geometry0, material0);
|
|
|
+ // sphere.rotateY(phiStart);
|
|
|
+ // this.scene.add(sphere0); // 左
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry1 = new THREE.CircleGeometry(
|
|
|
+ 6, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material1 = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+ const circle1 = new THREE.Mesh(geometry1, material1);
|
|
|
+ circle1.rotateZ(Math.PI * -0.5);
|
|
|
+ circle1.rotateX(Math.PI * ((90 - horizontal0) / 180));
|
|
|
+ // this.scene.add(circle1); // left
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry2 = new THREE.CircleGeometry(
|
|
|
+ 6, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material2 = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+ const circle2 = new THREE.Mesh(geometry2, material2);
|
|
|
+ circle2.rotateZ(Math.PI * 0.5);
|
|
|
+ circle2.rotateX(phiStart);
|
|
|
+ // this.scene.add(circle2); // right
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ this.x1 = new ThreeBSP(sphere);
|
|
|
+ this.y1 = new ThreeBSP(circle1);
|
|
|
+ this.z1 = new ThreeBSP(circle2);
|
|
|
+ this.w1 = new ThreeBSP(sphere0);
|
|
|
+ },
|
|
|
+ initOgt01() {
|
|
|
+ let vertical = this.verticalB;
|
|
|
+
|
|
|
+ if ((vertical + this.verticalT) % 90 === 0) vertical = vertical - 0.1;
|
|
|
+
|
|
|
+ let phiStart = Math.PI * ((90 - vertical) / 180),
|
|
|
+ phiLength = Math.PI * (vertical / 180),
|
|
|
+ thetaStart = Math.PI * 0,
|
|
|
+ thetaLength = Math.PI * 1;
|
|
|
+
|
|
|
+ const geometry = new THREE.SphereGeometry(
|
|
|
+ 6, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
+ );
|
|
|
+ const material = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const sphere = new THREE.Mesh(geometry, material);
|
|
|
+ sphere.rotateZ(Math.PI * 0.5);
|
|
|
+ // this.scene.add(sphere); // 下
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let vertical0 = this.verticalT;
|
|
|
+
|
|
|
+ let phiStart0 = Math.PI * (90 / 180),
|
|
|
+ phiLength0 = Math.PI * (vertical0 / 180),
|
|
|
+ thetaStart0 = Math.PI * 0,
|
|
|
+ thetaLength0 = Math.PI * 1;
|
|
|
+
|
|
|
+ const geometry0 = new THREE.SphereGeometry(
|
|
|
+ 6, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart0, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength0, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart0, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength0 // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
+ );
|
|
|
+ const material0 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const sphere0 = new THREE.Mesh(geometry0, material0);
|
|
|
+ sphere0.rotateZ(Math.PI * 0.5);
|
|
|
+ // this.scene.add(sphere0); // 上
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry1 = new THREE.CircleGeometry(
|
|
|
+ 6, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material1 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle1 = new THREE.Mesh(geometry1, material1);
|
|
|
+ circle1.rotateX(Math.PI * ((90 - vertical0) / 180));
|
|
|
+ // circle1.rotateZ(0);
|
|
|
+ // this.scene.add(circle1); // top
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry2 = new THREE.CircleGeometry(
|
|
|
+ 6, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material2 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle2 = new THREE.Mesh(geometry2, material2);
|
|
|
+ // let p = -phiStart - Math.PI;
|
|
|
+ circle2.rotateX(-phiStart - Math.PI);
|
|
|
+ // circle2.rotateZ(0);
|
|
|
+ // this.scene.add(circle2); // bottom
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ this.x2 = new ThreeBSP(sphere);
|
|
|
+ this.y2 = new ThreeBSP(circle1);
|
|
|
+ this.z2 = new ThreeBSP(circle2);
|
|
|
+ this.w2 = new ThreeBSP(sphere0);
|
|
|
+ },
|
|
|
+ initMesh(pointsArr) {
|
|
|
+ /* let points = pointsArr.map(
|
|
|
+ (d) => new THREE.Vector3(d[0], d[1], d[2])
|
|
|
+ );
|
|
|
+
|
|
|
+ let color = null;
|
|
|
+ if (this.type === 1) {
|
|
|
+ color = 0x0000ff;
|
|
|
+ } else if (this.type === 2) {
|
|
|
+ color = 0x008000;
|
|
|
+ } else if (this.type === 3) {
|
|
|
+ color = 0xff4500;
|
|
|
+ } else {
|
|
|
+ color = 0x0000ff;
|
|
|
+ }
|
|
|
+
|
|
|
+ let material = new THREE.MeshPhongMaterial({
|
|
|
+ emissive: color,
|
|
|
+ color: 0x4c4c4c,
|
|
|
+ transparent: true,
|
|
|
+ opacity: 0.3,
|
|
|
+ lightMapIntensity: 0.1,
|
|
|
+ side: THREE.DoubleSide,
|
|
|
+ });
|
|
|
+
|
|
|
+ let tixing = new ConvexGeometry(points);
|
|
|
+ //通过ConvexGeometry凸包绘制一个梯台,当然也可以使用ExtrudeGeometry挤压几何体,
|
|
|
+ let tixingMesh = new THREE.Mesh(tixing, material);
|
|
|
+ tixingMesh.name = "cube";
|
|
|
+ this.scene.add(tixingMesh); */
|
|
|
+
|
|
|
+ this.$emit('loadingDone', 'carDone');
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // this.initLeft();
|
|
|
+ // this.initTop();
|
|
|
+
|
|
|
+
|
|
|
+ // this.initLeft1();
|
|
|
+ // this.initTop1();
|
|
|
+
|
|
|
+
|
|
|
+ // this.initDemo();
|
|
|
+ // this.initDemo1();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ this.initOgtDemo();
|
|
|
+ this.initOgtDemo1();
|
|
|
+
|
|
|
+
|
|
|
+ this.initOgt();
|
|
|
+ this.initOgt1();
|
|
|
+
|
|
|
+ this.initOgt0();
|
|
|
+ this.initOgt01();
|
|
|
+
|
|
|
+ // console.log(this.group1);
|
|
|
+
|
|
|
+
|
|
|
+ // var m = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+
|
|
|
+
|
|
|
+ // var bsp = this.group1.subtract(this.group2);
|
|
|
+ // var mesh = bsp.toMesh(m);
|
|
|
+
|
|
|
+ // this.scene.add(mesh);
|
|
|
+
|
|
|
+ // console.log(bsp);
|
|
|
+
|
|
|
+ // this.scene.add(bsp);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // intersect (交集) union (并集) subtract (差集)
|
|
|
+
|
|
|
+ /* var m = new THREE.MeshBasicMaterial({ color: 0xff0000, side: THREE.DoubleSide });
|
|
|
+ const resultBSP = this.group1.union(this.group2).toMesh(m);
|
|
|
+ console.log(resultBSP);
|
|
|
+ this.scene.add(resultBSP); */
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ var m = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+ // var m = new THREE.MeshBasicMaterial({ color: 0xffaa00, transparent: true, blending: THREE.AdditiveBlending });
|
|
|
+ // var m = new THREE.MeshBasicMaterial( { color: 0xffaa00, wireframe: true } );
|
|
|
+
|
|
|
+
|
|
|
+ // let m = new THREE.MeshPhongMaterial({
|
|
|
+ // emissive: color,
|
|
|
+ // color: 0x4c4c4c,
|
|
|
+ // transparent: true,
|
|
|
+ // opacity: 0.3,
|
|
|
+ // lightMapIntensity: 0.1,
|
|
|
+ // side: THREE.DoubleSide,
|
|
|
+ // });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // const resultBSP = this.a1.subtract(this.b1).subtract(this.c1).union(this.a2).union(this.b2).union(this.c2).toMesh(m);
|
|
|
+ // const resultBSP = (this.a1.subtract(this.b1).subtract(this.c1)).subtract(this.a2.subtract(this.c2).subtract(this.b2)).toMesh(m);
|
|
|
+
|
|
|
+ // const resultBSP = (this.a2.subtract(this.b2).subtract(this.c2)).subtract(this.a1.subtract(this.b1).subtract(this.c1)).toMesh(m);
|
|
|
+ // const resultBSP = this.a2.subtract(this.b2.subtract(this.c2))
|
|
|
+
|
|
|
+ // let aa = new ThreeBSP(this.a1.subtract(this.b1).subtract(this.c1));
|
|
|
+ // let bb = new ThreeBSP(this.a2.subtract(this.b2).subtract(this.c2));
|
|
|
+
|
|
|
+
|
|
|
+ // m = new THREE.MeshBasicMaterial({
|
|
|
+ /* m = new THREE.MeshPhongMaterial({
|
|
|
+ emissive: 0x0000ff,
|
|
|
+ color: 0x4c4c4c,
|
|
|
+ transparent: true,
|
|
|
+ opacity: 0.3,
|
|
|
+ lightMapIntensity: 0.1,
|
|
|
+ side: THREE.DoubleSide,
|
|
|
+ }); */
|
|
|
+
|
|
|
+
|
|
|
+ // const resultBSP = this.a1.subtract(this.b1).subtract(this.c1).toMesh(m);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 都小于90
|
|
|
+ // const resultBSP = this.a2.intersect(this.c2).subtract(this.b2).intersect(this.a1.subtract(this.b1).subtract(this.c1)).toMesh(m);
|
|
|
+ // const resultBSP = this.a1.subtract(this.b1).subtract(this.c1).intersect(this.a2.subtract(this.b2).intersect(this.c2)).toMesh(m);
|
|
|
+ // const resultBSP = this.a1.subtract(this.b1).subtract(this.c1).intersect(this.a2.subtract(this.b2).intersect(this.c2))
|
|
|
+ // .subtract(this.x1.subtract(this.y1).subtract(this.z1).intersect(this.x2.subtract(this.y2).intersect(this.z2)))
|
|
|
+ // .toMesh(m);
|
|
|
+
|
|
|
+ // 大于90
|
|
|
+ // const resultBSP = this.a1.subtract(this.b1.intersect(this.c1)).toMesh(m);
|
|
|
+ // 小于90
|
|
|
+ // const resultBSP = this.a2.subtract(this.b2).intersect(this.c2).toMesh(m);
|
|
|
+ // 1大于90 2小于90
|
|
|
+ // const resultBSP = this.a1.subtract(this.b1.intersect(this.c1)).intersect(this.a2.subtract(this.b2).intersect(this.c2)).toMesh(m);
|
|
|
+ // const resultBSP = this.a1.subtract(this.b1.intersect(this.c1)).intersect(this.a2.subtract(this.b2).intersect(this.c2))
|
|
|
+ // .subtract(this.x1.subtract(this.y1.intersect(this.z1)).intersect(this.x2.subtract(this.y2).intersect(this.z2))).toMesh(m);
|
|
|
+
|
|
|
+ // 小于90
|
|
|
+ // const resultBSP = this.a1.subtract(this.b1).subtract(this.c1).toMesh(m);
|
|
|
+ // 大于90
|
|
|
+ // const resultBSP = this.a2.subtract(this.b2.subtract(this.c2)).toMesh(m);
|
|
|
+ // 1小于90 2大于90
|
|
|
+ // const resultBSP = this.a1.subtract(this.b1).subtract(this.c1).intersect(this.a2.subtract(this.b2.subtract(this.c2))).toMesh(m);
|
|
|
+ // const resultBSP = this.a1.subtract(this.b1).subtract(this.c1).intersect(this.a2.subtract(this.b2.subtract(this.c2)))
|
|
|
+ // .subtract(this.x1.subtract(this.y1).subtract(this.z1).intersect(this.x2.subtract(this.y2.subtract(this.z2)))).toMesh(m);
|
|
|
+
|
|
|
+ // 都大于90
|
|
|
+ // const resultBSP = this.a1.subtract(this.b1.intersect(this.c1)).intersect(this.a2.subtract(this.b2.subtract(this.c2))).toMesh(m);
|
|
|
+ // const resultBSP = this.a1.subtract(this.b1.intersect(this.c1)).intersect(this.a2.subtract(this.b2.subtract(this.c2)))
|
|
|
+ // .subtract(this.x1.subtract(this.y1.intersect(this.z1)).intersect(this.x2.subtract(this.y2.subtract(this.z2)))).toMesh(m);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 带盲区距离
|
|
|
+ // const resultBSP =
|
|
|
+ // this.a1.subtract(this.b1.intersect(this.c1)).intersect(this.a2.subtract(this.b2.subtract(this.c2)))
|
|
|
+ // .subtract
|
|
|
+ // (this.x1.subtract(this.y1.intersect(this.z1)).intersect(this.x2.subtract(this.y2.subtract(this.z2))))
|
|
|
+ // .toMesh(m);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // ogt
|
|
|
+ // const resultBSP = this.a1.subtract(this.b1).intersect(this.c1).intersect(this.a2.subtract(this.b2).intersect(this.c2)).toMesh(m);
|
|
|
+ // resultBSP = resultBSP.subtract(this.a2);
|
|
|
+
|
|
|
+
|
|
|
+ // ogt 带盲区距离
|
|
|
+ // const resultBSP = (this.a1.intersect(this.d1).subtract(this.b1).subtract(this.c1).intersect(this.a2.intersect(this.d2).subtract(this.b2).intersect(this.c2)))
|
|
|
+ // .subtract(this.x1.intersect(this.w1).subtract(this.y1).subtract(this.z1).intersect(this.x2.intersect(this.w2).subtract(this.y2).intersect(this.z2)))
|
|
|
+ // .toMesh(m);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // intersect (交集) union (并集) subtract (差集)
|
|
|
+
|
|
|
+
|
|
|
+ // ogt 相加都小于180
|
|
|
+ // const resultBSP =
|
|
|
+ // this.a1.intersect(this.d1).subtract(this.b1).subtract(this.c1).intersect(this.a2.intersect(this.d2).subtract(this.b2).intersect(this.c2))
|
|
|
+ // .subtract(this.x1.intersect(this.w1).subtract(this.y1).subtract(this.z1).intersect(this.x2.intersect(this.w2).subtract(this.y2).intersect(this.z2)))
|
|
|
+ // .toMesh(m);
|
|
|
+
|
|
|
+ // ogt 左右相加大于180 上下相加小于180
|
|
|
+ // const resultBSP = this.a1.intersect(this.d1).subtract(this.b1.intersect(this.c1)).toMesh(m);
|
|
|
+ // const resultBSP = this.a2.intersect(this.d2).subtract(this.b2).intersect(this.c2).toMesh(m);
|
|
|
+ // const resultBSP =
|
|
|
+ // this.a1.intersect(this.d1).subtract(this.b1.intersect(this.c1)).intersect(this.a2.intersect(this.d2).subtract(this.b2).intersect(this.c2))
|
|
|
+ // .subtract(this.x1.intersect(this.w1).subtract(this.y1.intersect(this.z1)).intersect(this.x2.intersect(this.w2).subtract(this.y2).intersect(this.z2)))
|
|
|
+ // .toMesh(m);
|
|
|
+
|
|
|
+ // ogt 左右相加小于180 上下相加大于180
|
|
|
+ // const resultBSP = this.a1.intersect(this.d1).subtract(this.b1).subtract(this.c1).toMesh(m);
|
|
|
+ // const resultBSP = this.a2.intersect(this.d2).subtract(this.b2.subtract(this.c2)).toMesh(m);
|
|
|
+ // const resultBSP = this.a1.intersect(this.d1).subtract(this.b1).subtract(this.c1).intersect(this.a2.intersect(this.d2).subtract(this.b2.subtract(this.c2)))
|
|
|
+ // .subtract(this.x1.intersect(this.w1).subtract(this.y1).subtract(this.z1).intersect(this.x2.intersect(this.w2).subtract(this.y2.subtract(this.z2))))
|
|
|
+ // .toMesh(m);
|
|
|
+
|
|
|
+
|
|
|
+ // ogt 相加都大于180
|
|
|
+ // const resultBSP = this.a1.intersect(this.d1).subtract(this.b1.intersect(this.c1)).toMesh(m);
|
|
|
+ // const resultBSP = this.a2.intersect(this.d2).subtract(this.b2.subtract(this.c2)).toMesh(m);
|
|
|
+ // const resultBSP = this.a1.intersect(this.d1).subtract(this.b1.intersect(this.c1)).intersect(this.a2.intersect(this.d2).subtract(this.b2.subtract(this.c2)))
|
|
|
+ // .subtract(this.x1.intersect(this.w1).subtract(this.y1.intersect(this.z1)).intersect(this.x2.intersect(this.w2).subtract(this.y2.subtract(this.z2))))
|
|
|
+ // .toMesh(m);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // const resultBSP = this.a1.intersect(this.d1).subtract(this.b1).subtract(this.c1).toMesh(m);
|
|
|
+
|
|
|
+
|
|
|
+ // left大于90
|
|
|
+ // const resultBSP = this.a1.intersect(this.d1).subtract(this.b1.intersect(this.c1))
|
|
|
+ // this.a1.subtract(this.c1) this.d1.subtract(this.b1)
|
|
|
+ // const resultBSP = this.a1.subtract(this.c1).intersect(this.d1.subtract(this.b1))
|
|
|
+ // const resultBSP = this.d1.subtract(this.b1).intersect(this.a1).intersect(this.c1)
|
|
|
+ // const resultBSP = this.a1.intersect(this.d1).subtract(this.b1).subtract(this.c1)
|
|
|
+ // .intersect(this.a2.intersect(this.d2).subtract(this.b2).intersect(this.c2))
|
|
|
+ // .toMesh(m);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // const resultBSP = this.a2.intersect(this.d2).subtract(this.b2).intersect(this.c2).toMesh(m);
|
|
|
+
|
|
|
+ // const resultBSP = this.a1.toMesh(m);
|
|
|
+
|
|
|
+ // const resultBSP =
|
|
|
+ // this.a1.intersect(this.d1).subtract(this.b1).subtract(this.c1).intersect(this.a2.intersect(this.d2).subtract(this.b2).intersect(this.c2))
|
|
|
+ // .subtract(this.x1.intersect(this.w1).subtract(this.y1).subtract(this.z1).intersect(this.x2.intersect(this.w2).subtract(this.y2).intersect(this.z2)))
|
|
|
+ // .toMesh(m);
|
|
|
+
|
|
|
+ const resultBSP =
|
|
|
+ this.a1.intersect(this.d1).subtract(this.b1).subtract(this.c1)
|
|
|
+ .toMesh(m);
|
|
|
+
|
|
|
+
|
|
|
+ // console.log(resultBSP);
|
|
|
+ this.scene.add(resultBSP);
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ ADDITION
|
|
|
+ SUBTRACTION
|
|
|
+ DIFFERENCE
|
|
|
+ INTERSECTION
|
|
|
+ */
|
|
|
+ /* const evaluator = new Evaluator();
|
|
|
+ let result;
|
|
|
+ result = evaluator.evaluate(this.group1, this.group2, INTERSECTION);
|
|
|
+
|
|
|
+ console.log(this.group1); */
|
|
|
+
|
|
|
+ // result.castShadow = true
|
|
|
+ // result.receiveShadow = true;
|
|
|
+ // this.scene.add(result);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // console.log(ThreeBSP);
|
|
|
+ },
|
|
|
+ /*
|
|
|
+ * 初始化非ogt模型
|
|
|
+ * @param {*} coordinate 配置参数
|
|
|
+ * @param {*} vh v 垂直 h 水平
|
|
|
+ * @param {*} nf n 盲区距离 f 探测距离
|
|
|
+ */
|
|
|
+ initContent0(coordinate, vh, nf) {
|
|
|
+ let r = 0, deg = 0, rate = 1;
|
|
|
+ // let a = 100 / (this.scale / 0.6);
|
|
|
+ let a = 1;
|
|
|
+
|
|
|
+ // 若探测距离超出最大值,则默认为10000,盲区距离按比例展示
|
|
|
+ // 值为测试出来的预估值 超过的话ThreeBSP会报内存溢出
|
|
|
+ let maxR = 10000;
|
|
|
+
|
|
|
+ if ((coordinate.farDistance * a) > maxR) {
|
|
|
+ if (nf === 'n') {
|
|
|
+ rate = (coordinate.farDistance * a) / maxR;
|
|
|
+ r = ((coordinate.nearDistance * a) / rate).toFixed();
|
|
|
+ } else {
|
|
|
+ r = maxR - 3.3;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (nf === 'n') {
|
|
|
+ r = coordinate.nearDistance * a;
|
|
|
+ } else {
|
|
|
+ r = coordinate.farDistance * a;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (vh === 'v') {
|
|
|
+ deg = coordinate.fovV;
|
|
|
+ if (coordinate.fovH >= 47 && coordinate.fovH <= 53 && coordinate.fovV == 30) {
|
|
|
+ deg = 31;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (deg == 80) deg = 79;
|
|
|
+ if (deg == 20) deg = 19;
|
|
|
+ if (deg % 10 === 0 && deg % 90 != 0) deg = deg + 0.7;
|
|
|
+ } else {
|
|
|
+ deg = coordinate.fovH;
|
|
|
+ if (deg >= 47 && deg <= 53) deg = 53;
|
|
|
+ if (deg >= 17 && deg <= 23) deg = 17;
|
|
|
+ if (deg >= 117 && deg <= 123) deg = 121;
|
|
|
+ if (deg >= 147 && deg <= 153) deg = 148;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 180°时融合有问题
|
|
|
+ if (deg % 90 === 0) deg = deg - 0.5;
|
|
|
+
|
|
|
+
|
|
|
+ let phiStart = Math.PI * ((90 - deg) / 180),
|
|
|
+ phiLength = Math.PI * (deg * 2 / 180),
|
|
|
+ thetaStart = 0,
|
|
|
+ thetaLength = Math.PI;
|
|
|
+
|
|
|
+ const geometry = new THREE.SphereGeometry(
|
|
|
+ r, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
+ );
|
|
|
+ const material = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+ const sphere = new THREE.Mesh(geometry, material);
|
|
|
+
|
|
|
+
|
|
|
+ const geometry1 = new THREE.CircleGeometry(
|
|
|
+ r, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+ const material1 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle1 = new THREE.Mesh(geometry1, material1); // left top
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry2 = new THREE.CircleGeometry(
|
|
|
+ r, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI * 1 // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+ const material2 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle2 = new THREE.Mesh(geometry2, material2); // right bottom
|
|
|
+
|
|
|
+
|
|
|
+ if (vh === 'v') {
|
|
|
+ sphere.rotateZ(Math.PI * 0.5);
|
|
|
+ circle1.rotateX(phiStart);
|
|
|
+ circle2.rotateX(-phiStart - Math.PI);
|
|
|
+
|
|
|
+ if (nf === 'n') {
|
|
|
+ this.x2 = new ThreeBSP(sphere);
|
|
|
+ this.y2 = new ThreeBSP(circle1);
|
|
|
+ this.z2 = new ThreeBSP(circle2);
|
|
|
+ } else {
|
|
|
+ this.a2 = new ThreeBSP(sphere);
|
|
|
+ this.b2 = new ThreeBSP(circle1);
|
|
|
+ this.c2 = new ThreeBSP(circle2);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ circle1.rotateZ(Math.PI * -0.5);
|
|
|
+ circle1.rotateX(phiStart);
|
|
|
+ circle2.rotateZ(Math.PI * 0.5);
|
|
|
+ circle2.rotateX(phiStart);
|
|
|
+
|
|
|
+ if (nf === 'n') {
|
|
|
+ this.x1 = new ThreeBSP(sphere);
|
|
|
+ this.y1 = new ThreeBSP(circle1);
|
|
|
+ this.z1 = new ThreeBSP(circle2);
|
|
|
+ } else {
|
|
|
+ this.a1 = new ThreeBSP(sphere);
|
|
|
+ this.b1 = new ThreeBSP(circle1);
|
|
|
+ this.c1 = new ThreeBSP(circle2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 初始化ogt模型
|
|
|
+ * @param {*} coordinate 配置参数
|
|
|
+ * @param {*} vh v 垂直 h 水平
|
|
|
+ * @param {*} nf n 盲区距离 f 探测距离
|
|
|
+ */
|
|
|
+ initContentOgt(coordinate, vh, nf) {
|
|
|
+ let r = 0, deg = 0, deg1 = 0, rate = 1;
|
|
|
+ // let a = 100 / (this.scale / 0.6);
|
|
|
+ let a = 1;
|
|
|
+
|
|
|
+ let maxR = 10000;
|
|
|
+
|
|
|
+ // 10000为预估 超过的话ThreeBSP会报内存溢出
|
|
|
+ // 若探测距离超出最大值,则默认为10000,盲区距离按比例展示
|
|
|
+ if ((coordinate.farDistance * a) > maxR) {
|
|
|
+ if (nf === 'n') {
|
|
|
+ rate = (coordinate.farDistance * a) / maxR;
|
|
|
+ r = (coordinate.nearDistance * a) / rate;
|
|
|
+ } else {
|
|
|
+ r = maxR - 3;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (nf === 'n') {
|
|
|
+ r = coordinate.nearDistance * a;
|
|
|
+ } else {
|
|
|
+ r = coordinate.farDistance * a;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (vh === 'v') {
|
|
|
+ deg = coordinate.fovVBottom;
|
|
|
+ deg1 = coordinate.fovVTop;
|
|
|
+ } else {
|
|
|
+ deg = coordinate.fovHRight;
|
|
|
+ deg1 = coordinate.fovHLeft;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 180°时融合有问题
|
|
|
+ if ((deg + deg1) % 180 === 0) {
|
|
|
+ if (deg > 1) {
|
|
|
+ deg = deg - 0.1;
|
|
|
+ } else {
|
|
|
+ deg1 = deg1 - 0.1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ let phiStart = Math.PI * ((90 - deg) / 180),
|
|
|
+ phiLength = Math.PI * (deg / 180),
|
|
|
+ thetaStart = 0,
|
|
|
+ thetaLength = Math.PI;
|
|
|
+
|
|
|
+ const geometry = new THREE.SphereGeometry(
|
|
|
+ r, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
+ );
|
|
|
+ const material = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+
|
|
|
+ const sphere = new THREE.Mesh(geometry, material); // 右 下
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let phiStart0 = Math.PI * (90 / 180),
|
|
|
+ phiLength0 = Math.PI * (deg1 / 180),
|
|
|
+ thetaStart0 = 0,
|
|
|
+ thetaLength0 = Math.PI;
|
|
|
+
|
|
|
+ const geometry0 = new THREE.SphereGeometry(
|
|
|
+ r, // radius — 球体半径,默认为1
|
|
|
+ 32, // widthSegments — 水平分段数(沿着经线分段),最小值为3,默认值为32
|
|
|
+ 16, // heightSegments — 垂直分段数(沿着纬线分段),最小值为2,默认值为16
|
|
|
+ phiStart0, // phiStart — 指定水平(经线)起始角度,默认值为0
|
|
|
+ phiLength0, // phiLength — 指定水平(经线)扫描角度的大小,默认值为 Math.PI * 2
|
|
|
+ thetaStart0, // thetaStart — 指定垂直(纬线)起始角度,默认值为0
|
|
|
+ thetaLength0 // thetaLength — 指定垂直(纬线)扫描角度大小,默认值为 Math.PI
|
|
|
+ );
|
|
|
+ const material0 = new THREE.MeshBasicMaterial({ color: 0xff00ff, side: THREE.DoubleSide });
|
|
|
+
|
|
|
+ const sphere0 = new THREE.Mesh(geometry0, material0); // 左 上
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry1 = new THREE.CircleGeometry(
|
|
|
+ r, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material1 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle1 = new THREE.Mesh(geometry1, material1); // left top
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const geometry2 = new THREE.CircleGeometry(
|
|
|
+ r, // radius — 圆形的半径,默认值为1
|
|
|
+ 32, // segments — 分段(三角面)的数量,最小值为3,默认值为32
|
|
|
+ 0, // thetaStart — 第一个分段的起始角度,默认为0。(three o'clock position)
|
|
|
+ Math.PI // thetaLength — 圆形扇区的中心角,通常被称为“θ”(西塔)。默认值是2*Pi,这使其成为一个完整的圆
|
|
|
+ );
|
|
|
+
|
|
|
+ const material2 = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide });
|
|
|
+ const circle2 = new THREE.Mesh(geometry2, material2); // right bottom
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (vh === 'v') {
|
|
|
+ sphere.rotateZ(Math.PI * 0.5);
|
|
|
+ sphere0.rotateZ(Math.PI * 0.5);
|
|
|
+ circle1.rotateX(Math.PI * ((90 - deg1) / 180));
|
|
|
+ circle2.rotateX(-phiStart - Math.PI);
|
|
|
+
|
|
|
+ if (nf === 'n') {
|
|
|
+ this.x2 = new ThreeBSP(sphere);
|
|
|
+ this.y2 = new ThreeBSP(circle1);
|
|
|
+ this.z2 = new ThreeBSP(circle2);
|
|
|
+ this.w2 = new ThreeBSP(sphere0);
|
|
|
+ } else {
|
|
|
+ this.a2 = new ThreeBSP(sphere);
|
|
|
+ this.b2 = new ThreeBSP(circle1);
|
|
|
+ this.c2 = new ThreeBSP(circle2);
|
|
|
+ this.d2 = new ThreeBSP(sphere0);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ circle1.rotateZ(Math.PI * -0.5);
|
|
|
+ circle1.rotateX(Math.PI * ((90 - deg1) / 180));
|
|
|
+ circle2.rotateZ(Math.PI * 0.5);
|
|
|
+ circle2.rotateX(phiStart);
|
|
|
+
|
|
|
+ if (nf === 'n') {
|
|
|
+ this.x1 = new ThreeBSP(sphere);
|
|
|
+ this.y1 = new ThreeBSP(circle1);
|
|
|
+ this.z1 = new ThreeBSP(circle2);
|
|
|
+ this.w1 = new ThreeBSP(sphere0);
|
|
|
+ } else {
|
|
|
+ this.a1 = new ThreeBSP(sphere);
|
|
|
+ this.b1 = new ThreeBSP(circle1);
|
|
|
+ this.c1 = new ThreeBSP(circle2);
|
|
|
+ this.d1 = new ThreeBSP(sphere0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ initBSP(onlyClear = false) {
|
|
|
+ const obj = this.scene.getObjectByName("cube");
|
|
|
+ if (obj) {
|
|
|
+ this.scene.remove(obj);
|
|
|
+ this.clearCache(obj);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!!onlyClear) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ const sensor = this.scene.getObjectByName("sensor");
|
|
|
+ if (sensor) {
|
|
|
+ this.scene.remove(sensor);
|
|
|
+ this.clearCache(sensor);
|
|
|
+ }
|
|
|
+
|
|
|
+ showFullScreenLoading();
|
|
|
+
|
|
|
+ setTimeout(() => {
|
|
|
+ if (this.type === 1) {
|
|
|
+ if (this.cameraSensor) {
|
|
|
+ this.scene.add(this.cameraSensor);
|
|
|
+ } else {
|
|
|
+ this.initSensor({ x: 0, y: 0, z: 0 }, "camera");
|
|
|
+ }
|
|
|
+ } else if (this.type === 2) {
|
|
|
+ if (this.ogt) {
|
|
|
+ this.scene.add(this.ogt);
|
|
|
+ } else {
|
|
|
+ this.initSensor({ x: 0, y: 0, z: 0 }, "ogt");
|
|
|
+ }
|
|
|
+ } else if (this.type === 3) {
|
|
|
+ if (this.lidar) {
|
|
|
+ this.scene.add(this.lidar);
|
|
|
+ } else {
|
|
|
+ this.initSensor({ x: 0, y: 0, z: 0 }, "lidar");
|
|
|
+ }
|
|
|
+ } else if (this.type === 4) {
|
|
|
+ if (this.gps) {
|
|
|
+ this.scene.add(this.gps);
|
|
|
+ } else {
|
|
|
+ this.initSensor({ x: 0, y: 0, z: 0 }, "gps");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 0)
|
|
|
+
|
|
|
+
|
|
|
+ setTimeout(() => {
|
|
|
+ // 解决bsp内存溢出后没法去掉loading
|
|
|
+ let timer = setTimeout(() => {
|
|
|
+ clearTimeout(timer);
|
|
|
+ timer = null;
|
|
|
+
|
|
|
+ tryHideFullScreenLoading();
|
|
|
+ }, 30000)
|
|
|
+
|
|
|
+ this.initSensorBSP();
|
|
|
+
|
|
|
+ clearTimeout(timer);
|
|
|
+ timer = null;
|
|
|
+
|
|
|
+ tryHideFullScreenLoading();
|
|
|
+ }, 300)
|
|
|
+ },
|
|
|
+ initSensorBSP() {
|
|
|
+ // let sensorId = this.configList[type][index].sensorId;
|
|
|
+
|
|
|
+ // if (!this.bsp[type][sensorId]) {
|
|
|
+ // let coordinate = this.allSensor[type].find(
|
|
|
+ // (i) => i.id === sensorId
|
|
|
+ // );
|
|
|
+
|
|
|
+ // if (!coordinate) {
|
|
|
+ // coordinate = {
|
|
|
+ // farDistance: 60,
|
|
|
+ // nearDistance: 0,
|
|
|
+ // fovH: 60,
|
|
|
+ // fovV: 60,
|
|
|
+ // fovHLeft: 60,
|
|
|
+ // fovVTop: 60,
|
|
|
+ // fovHRight: 60,
|
|
|
+ // fovVBottom: 60,
|
|
|
+ // };
|
|
|
+ // } { f: 0, n: 0, h: 0, v: 0 } { f: 0, n: 0, hl: 0, hr: 0, vt: 0, vb: 0 },
|
|
|
+
|
|
|
+
|
|
|
+ const obj = this.scene.getObjectByName("cube");
|
|
|
+ if (obj) {
|
|
|
+ this.scene.remove(obj);
|
|
|
+ this.clearCache(obj);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ let coordinate = {};
|
|
|
+
|
|
|
+ // console.log(this.type);
|
|
|
+ // console.log(this.coordinate);
|
|
|
+ // console.log(this.coordinateA);
|
|
|
+
|
|
|
+ if (this.type != 2) {
|
|
|
+ if (this.coordinate.f <= 0 || this.coordinate.n < 0 || this.coordinate.f <= this.coordinate.n) {
|
|
|
+ tryHideFullScreenLoading();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ coordinate = {
|
|
|
+ farDistance: this.coordinate.f / 100,
|
|
|
+ nearDistance: this.coordinate.n / 100,
|
|
|
+ fovH: this.coordinate.h,
|
|
|
+ fovV: this.coordinate.v,
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if (this.coordinateA.f <= 0 || this.coordinateA.n < 0 || this.coordinateA.f <= this.coordinateA.n) {
|
|
|
+ tryHideFullScreenLoading();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ coordinate = {
|
|
|
+ farDistance: this.coordinateA.f / 100,
|
|
|
+ nearDistance: this.coordinateA.n / 100,
|
|
|
+ fovHLeft: this.coordinateA.hl,
|
|
|
+ fovHRight: this.coordinateA.hr,
|
|
|
+ fovVTop: this.coordinateA.vt,
|
|
|
+ fovVBottom: this.coordinateA.vb,
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // console.log(coordinate)
|
|
|
+
|
|
|
+ let color = null;
|
|
|
+
|
|
|
+ if (this.type === 1) {
|
|
|
+ color = 0x0000ff;
|
|
|
+ } else if (this.type === 2) {
|
|
|
+ color = 0x008000;
|
|
|
+ } else if (this.type === 3) {
|
|
|
+ color = 0xff4500;
|
|
|
+ } else {
|
|
|
+ color = 0x0000ff;
|
|
|
+ }
|
|
|
+
|
|
|
+ // let m = new THREE.MeshPhongMaterial({ emissive: color, color: 0x4c4c4c, wireframe: true, transparent: true, opacity: 0.3, side: THREE.DoubleSide });
|
|
|
+ // let m = new THREE.MeshPhongMaterial({ emissive: color, color: 0x4c4c4c, wireframe: true, side: THREE.DoubleSide });
|
|
|
+ let m = new THREE.MeshPhongMaterial({ emissive: color, color: 0x4c4c4c, transparent: true, opacity: 0.3, side: THREE.DoubleSide });
|
|
|
+ // let m = new THREE.MeshPhongMaterial({ emissive: color, color: 0x4c4c4c,side: THREE.DoubleSide });
|
|
|
+
|
|
|
+
|
|
|
+ if (this.type != 2) {
|
|
|
+ this.toCube(coordinate, m);
|
|
|
+ } else {
|
|
|
+ this.toCubeOgt(coordinate, m);
|
|
|
+ }
|
|
|
+
|
|
|
+ // this.bsp[type][sensorId] = this.cube;
|
|
|
+ // } else {
|
|
|
+ // this.cube = this.bsp[type][sensorId];
|
|
|
+ // }
|
|
|
+
|
|
|
+ let a = (100 / (this.scale / 0.6)) * 16.5;
|
|
|
+
|
|
|
+ this.cube.scale.set(a, a, a);
|
|
|
+
|
|
|
+ this.cube.name = this.geometryName || "cube";
|
|
|
+ this.scene.add(this.cube);
|
|
|
+
|
|
|
+ this.$emit('loadingDone', 'carDone');
|
|
|
+ },
|
|
|
+ toCube(coordinate, m) {
|
|
|
+ let { fovH, fovV, nearDistance } = coordinate;
|
|
|
+
|
|
|
+ this.initContent0(coordinate, 'h', 'f');
|
|
|
+ this.initContent0(coordinate, 'v', 'f');
|
|
|
+
|
|
|
+ if (nearDistance > 0) {
|
|
|
+ // 带盲区
|
|
|
+ this.initContent0(coordinate, 'h', 'n');
|
|
|
+ this.initContent0(coordinate, 'v', 'n');
|
|
|
+
|
|
|
+ // 有至少一个方向是等于360的
|
|
|
+ if (fovH >= 180 || fovV >= 180) {
|
|
|
+ if (fovH >= 180 && fovV < 180) {
|
|
|
+ if (fovV <= 90) {
|
|
|
+ this.cube = this.a2.subtract(this.b2).intersect(this.c2).subtract(this.x2.subtract(this.y2).intersect(this.z2)).toMesh(m);
|
|
|
+ } else {
|
|
|
+ this.cube = this.a2.subtract(this.b2.subtract(this.c2)).subtract(this.x2.subtract(this.y2.subtract(this.z2))).toMesh(m);
|
|
|
+ }
|
|
|
+ } else if (fovH < 180 && fovV >= 180) {
|
|
|
+ if (fovH <= 90) {
|
|
|
+ this.cube = this.a1.subtract(this.b1).subtract(this.c1).subtract(this.x1.subtract(this.y1).subtract(this.z1)).toMesh(m);
|
|
|
+ } else {
|
|
|
+ this.cube = this.a1.subtract(this.b1.intersect(this.c1)).subtract(this.x1.subtract(this.y1.intersect(this.z1))).toMesh(m);
|
|
|
+ }
|
|
|
+ } else if (fovH >= 180 && fovV >= 180) {
|
|
|
+ this.cube = this.a1.toMesh(m);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (fovH <= 90 && fovV <= 90) {
|
|
|
+ // 都小于90
|
|
|
+ this.cube = this.a1.subtract(this.b1).subtract(this.c1).intersect(this.a2.subtract(this.b2).intersect(this.c2))
|
|
|
+ .subtract(this.x1.subtract(this.y1).subtract(this.z1).intersect(this.x2.subtract(this.y2).intersect(this.z2))).toMesh(m);
|
|
|
+ } else if (fovH > 90 && fovV <= 90) {
|
|
|
+ // h大于90 v小于90
|
|
|
+ // this.cube = this.a1.subtract(this.b1.intersect(this.c1)).intersect(this.a2.subtract(this.b2).intersect(this.c2))
|
|
|
+ // .subtract(this.x1.subtract(this.y1.intersect(this.z1)).intersect(this.x2.subtract(this.y2).intersect(this.z2))).toMesh(m);
|
|
|
+ this.cube = this.a2.subtract(this.b2).intersect(this.c2).subtract(this.x2.subtract(this.y2).intersect(this.z2)).toMesh(m);
|
|
|
+ } else if (fovH <= 90 && fovV > 90) {
|
|
|
+ // h小于90 v大于90
|
|
|
+ // this.cube = this.a1.subtract(this.b1).subtract(this.c1).intersect(this.a2.subtract(this.b2.subtract(this.c2)))
|
|
|
+ // .subtract(this.x1.subtract(this.y1).subtract(this.z1).intersect(this.x2.subtract(this.y2.subtract(this.z2)))).toMesh(m);
|
|
|
+ this.cube = this.a1.subtract(this.b1).subtract(this.c1).subtract(this.x1.subtract(this.y1).subtract(this.z1)).toMesh(m);
|
|
|
+ } else if (fovH > 90 && fovV > 90) {
|
|
|
+ // 都大于90
|
|
|
+ this.cube = this.a1.subtract(this.b1.intersect(this.c1)).intersect(this.a2.subtract(this.b2.subtract(this.c2)))
|
|
|
+ .subtract(this.x1.subtract(this.y1.intersect(this.z1)).intersect(this.x2.subtract(this.y2.subtract(this.z2)))).toMesh(m);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 有至少一个方向是等于360的
|
|
|
+ if (fovH >= 180 || fovV >= 180) {
|
|
|
+ if (fovH >= 180 && fovV < 180) {
|
|
|
+ if (fovV <= 90) {
|
|
|
+ this.cube = this.a2.subtract(this.b2).intersect(this.c2).toMesh(m);
|
|
|
+ } else {
|
|
|
+ this.cube = this.a2.subtract(this.b2.subtract(this.c2)).toMesh(m);
|
|
|
+ }
|
|
|
+ } else if (fovH < 180 && fovV >= 180) {
|
|
|
+ if (fovH <= 90) {
|
|
|
+ this.cube = this.a1.subtract(this.b1).subtract(this.c1).toMesh(m);
|
|
|
+ } else {
|
|
|
+ this.cube = this.a1.subtract(this.b1.intersect(this.c1)).toMesh(m);
|
|
|
+ }
|
|
|
+ } else if (fovH >= 180 && fovV >= 180) {
|
|
|
+ this.cube = this.a1.toMesh(m);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (fovH <= 90 && fovV <= 90) {
|
|
|
+ // 都小于90
|
|
|
+ this.cube = this.a1.subtract(this.b1).subtract(this.c1).intersect(this.a2.subtract(this.b2).intersect(this.c2)).toMesh(m);
|
|
|
+ } else if (fovH > 90 && fovV <= 90) {
|
|
|
+ // h大于90 v小于90
|
|
|
+ // this.cube = this.a1.subtract(this.b1.intersect(this.c1)).intersect(this.a2.subtract(this.b2).intersect(this.c2)).toMesh(m);
|
|
|
+ this.cube = this.a2.subtract(this.b2).intersect(this.c2).toMesh(m);
|
|
|
+ } else if (fovH <= 90 && fovV > 90) {
|
|
|
+ // h小于90 v大于90
|
|
|
+ // this.cube = this.a1.subtract(this.b1).subtract(this.c1).intersect(this.a2.subtract(this.b2.subtract(this.c2))).toMesh(m);
|
|
|
+ this.cube = this.a1.subtract(this.b1).subtract(this.c1).toMesh(m);
|
|
|
+ } else if (fovH > 90 && fovV > 90) {
|
|
|
+ // 都大于90
|
|
|
+ this.cube = this.a1.subtract(this.b1.intersect(this.c1)).intersect(this.a2.subtract(this.b2.subtract(this.c2))).toMesh(m);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ this.a1 = null;
|
|
|
+ this.b1 = null;
|
|
|
+ this.c1 = null;
|
|
|
+ this.d1 = null;
|
|
|
+ this.a2 = null;
|
|
|
+ this.b2 = null;
|
|
|
+ this.c2 = null;
|
|
|
+ this.d2 = null;
|
|
|
+ this.x1 = null;
|
|
|
+ this.y1 = null;
|
|
|
+ this.z1 = null;
|
|
|
+ this.w1 = null;
|
|
|
+ this.x2 = null;
|
|
|
+ this.y2 = null;
|
|
|
+ this.z2 = null;
|
|
|
+ this.w2 = null;
|
|
|
+ },
|
|
|
+ toCubeOgt(coordinate, m) {
|
|
|
+ let { fovHLeft, fovHRight, fovVTop, fovVBottom, nearDistance } = coordinate;
|
|
|
+
|
|
|
+ this.initContentOgt(coordinate, 'h', 'f');
|
|
|
+ this.initContentOgt(coordinate, 'v', 'f');
|
|
|
+
|
|
|
+ if (nearDistance > 0) {
|
|
|
+ // 带盲区
|
|
|
+ this.initContentOgt(coordinate, 'h', 'n');
|
|
|
+ this.initContentOgt(coordinate, 'v', 'n');
|
|
|
+
|
|
|
+ // 有至少一个方向是大于360的
|
|
|
+ if ((fovHLeft + fovHRight >= 360) || (fovVTop + fovVBottom >= 360)) {
|
|
|
+ if ((fovHLeft + fovHRight >= 360) && (fovVTop + fovVBottom < 360)) {
|
|
|
+ if (fovVTop + fovVBottom <= 180) {
|
|
|
+ this.cube = this.a2.intersect(this.d2).subtract(this.b2).intersect(this.c2)
|
|
|
+ .subtract(this.x2.intersect(this.w2).subtract(this.y2).intersect(this.z2))
|
|
|
+ .toMesh(m);
|
|
|
+ } else {
|
|
|
+ this.cube = this.a2.intersect(this.d2).subtract(this.b2.subtract(this.c2))
|
|
|
+ .subtract(this.x2.intersect(this.w2).subtract(this.y2.subtract(this.z2)))
|
|
|
+ .toMesh(m);
|
|
|
+ }
|
|
|
+ } else if ((fovHLeft + fovHRight < 360) && (fovVTop + fovVBottom >= 360)) {
|
|
|
+ if (fovHLeft + fovHRight <= 180) {
|
|
|
+ this.cube = this.a1.intersect(this.d1).subtract(this.b1).subtract(this.c1)
|
|
|
+ .subtract(this.x1.intersect(this.w1).subtract(this.y1).subtract(this.z1))
|
|
|
+ .toMesh(m);
|
|
|
+ } else {
|
|
|
+ this.cube = this.a1.intersect(this.d1).subtract(this.b1.intersect(this.c1))
|
|
|
+ .subtract(this.x1.intersect(this.w1).subtract(this.y1.intersect(this.z1)))
|
|
|
+ .toMesh(m);
|
|
|
+ }
|
|
|
+ } else if ((fovHLeft + fovHRight >= 360) && (fovVTop + fovVBottom >= 360)) {
|
|
|
+ this.cube = this.a1.intersect(this.d1).toMesh(m);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 不带盲区
|
|
|
+ if ((fovHLeft + fovHRight <= 180) && (fovVTop + fovVBottom <= 180)) {
|
|
|
+ // 相加都小于180
|
|
|
+ this.cube = this.a1.intersect(this.d1).subtract(this.b1).subtract(this.c1).intersect(this.a2.intersect(this.d2).subtract(this.b2).intersect(this.c2))
|
|
|
+ .subtract(this.x1.intersect(this.w1).subtract(this.y1).subtract(this.z1).intersect(this.x2.intersect(this.w2).subtract(this.y2).intersect(this.z2)))
|
|
|
+ .toMesh(m);
|
|
|
+ } else if ((fovHLeft + fovHRight > 180) && (fovVTop + fovVBottom <= 180)) {
|
|
|
+ // 左右相加大于180 上下相加小于180
|
|
|
+ this.cube = this.a1.intersect(this.d1).subtract(this.b1.intersect(this.c1)).intersect(this.a2.intersect(this.d2).subtract(this.b2).intersect(this.c2))
|
|
|
+ .subtract(this.x1.intersect(this.w1).subtract(this.y1.intersect(this.z1)).intersect(this.x2.intersect(this.w2).subtract(this.y2).intersect(this.z2)))
|
|
|
+ .toMesh(m);
|
|
|
+ } else if ((fovHLeft + fovHRight <= 180) && (fovVTop + fovVBottom > 180)) {
|
|
|
+ // 左右相加小于180 上下相加大于180
|
|
|
+ this.cube = this.a1.intersect(this.d1).subtract(this.b1).subtract(this.c1).intersect(this.a2.intersect(this.d2).subtract(this.b2.subtract(this.c2)))
|
|
|
+ .subtract(this.x1.intersect(this.w1).subtract(this.y1).subtract(this.z1).intersect(this.x2.intersect(this.w2).subtract(this.y2.subtract(this.z2))))
|
|
|
+ .toMesh(m);
|
|
|
+ } else if ((fovHLeft + fovHRight > 180) && (fovVTop + fovVBottom > 180)) {
|
|
|
+ // 相加都大于180
|
|
|
+ this.cube = this.a1.intersect(this.d1).subtract(this.b1.intersect(this.c1)).intersect(this.a2.intersect(this.d2).subtract(this.b2.subtract(this.c2)))
|
|
|
+ .subtract(this.x1.intersect(this.w1).subtract(this.y1.intersect(this.z1)).intersect(this.x2.intersect(this.w2).subtract(this.y2.subtract(this.z2))))
|
|
|
+ .toMesh(m);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 有至少一个方向是大于360的
|
|
|
+ if ((fovHLeft + fovHRight >= 360) || (fovVTop + fovVBottom >= 360)) {
|
|
|
+ if ((fovHLeft + fovHRight >= 360) && (fovVTop + fovVBottom < 360)) {
|
|
|
+ if (fovVTop + fovVBottom <= 180) {
|
|
|
+ this.cube = this.a2.intersect(this.d2).subtract(this.b2).intersect(this.c2).toMesh(m);
|
|
|
+ } else {
|
|
|
+ this.cube = this.a2.intersect(this.d2).subtract(this.b2.subtract(this.c2)).toMesh(m);
|
|
|
+ }
|
|
|
+ } else if ((fovHLeft + fovHRight < 360) && (fovVTop + fovVBottom >= 360)) {
|
|
|
+ if (fovHLeft + fovHRight <= 180) {
|
|
|
+ this.cube = this.a1.intersect(this.d1).subtract(this.b1).subtract(this.c1).toMesh(m);
|
|
|
+ } else {
|
|
|
+ this.cube = this.a1.intersect(this.d1).subtract(this.b1.intersect(this.c1)).toMesh(m);
|
|
|
+ }
|
|
|
+ } else if ((fovHLeft + fovHRight >= 360) && (fovVTop + fovVBottom >= 360)) {
|
|
|
+ this.cube = this.a1.intersect(this.d1).toMesh(m);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ((fovHLeft + fovHRight <= 180) && (fovVTop + fovVBottom <= 180)) {
|
|
|
+ // 相加都小于180
|
|
|
+ this.cube = this.a1.intersect(this.d1).subtract(this.b1).subtract(this.c1).intersect(this.a2.intersect(this.d2).subtract(this.b2).intersect(this.c2)).toMesh(m);
|
|
|
+ } else if ((fovHLeft + fovHRight > 180) && (fovVTop + fovVBottom <= 180)) {
|
|
|
+ // 左右相加大于180 上下相加小于180
|
|
|
+ this.cube = this.a1.intersect(this.d1).subtract(this.b1.intersect(this.c1)).intersect(this.a2.intersect(this.d2).subtract(this.b2).intersect(this.c2)).toMesh(m);
|
|
|
+ } else if ((fovHLeft + fovHRight <= 180) && (fovVTop + fovVBottom > 180)) {
|
|
|
+ // 左右相加小于180 上下相加大于180
|
|
|
+ this.cube = this.a1.intersect(this.d1).subtract(this.b1).subtract(this.c1).intersect(this.a2.intersect(this.d2).subtract(this.b2.subtract(this.c2))).toMesh(m);
|
|
|
+ } else if ((fovHLeft + fovHRight > 180) && (fovVTop + fovVBottom > 180)) {
|
|
|
+ // 相加都大于180
|
|
|
+ this.cube = this.a1.intersect(this.d1).subtract(this.b1.intersect(this.c1)).intersect(this.a2.intersect(this.d2).subtract(this.b2.subtract(this.c2))).toMesh(m);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.a1 = null;
|
|
|
+ this.b1 = null;
|
|
|
+ this.c1 = null;
|
|
|
+ this.d1 = null;
|
|
|
+ this.a2 = null;
|
|
|
+ this.b2 = null;
|
|
|
+ this.c2 = null;
|
|
|
+ this.d2 = null;
|
|
|
+ this.x1 = null;
|
|
|
+ this.y1 = null;
|
|
|
+ this.z1 = null;
|
|
|
+ this.w1 = null;
|
|
|
+ this.x2 = null;
|
|
|
+ this.y2 = null;
|
|
|
+ this.z2 = null;
|
|
|
+ this.w2 = null;
|
|
|
+ },
|
|
|
+ // 初始化传感器
|
|
|
+ initSensor(
|
|
|
+ pos = { x: 0, y: 0, z: 0 },
|
|
|
+ type = "camera",
|
|
|
+ canMove = false
|
|
|
+ ) {
|
|
|
+ let Loader = new MTLLoader(); //材质文件加载器
|
|
|
+ let loader = new OBJLoader(); //obj加载器
|
|
|
+ let that = this;
|
|
|
+ let mtlUrl = "";
|
|
|
+ let objUrl = "";
|
|
|
+
|
|
|
+ if (type === "camera") {
|
|
|
+ mtlUrl = `${that.publicPath}sensor/camera/camera.mtl`;
|
|
|
+ objUrl = `${that.publicPath}sensor/camera/camera.obj`;
|
|
|
+ } else if (type === "ogt") {
|
|
|
+ mtlUrl = `${that.publicPath}sensor/ogt/millimeter_wave_radar.mtl`;
|
|
|
+ objUrl = `${that.publicPath}sensor/ogt/millimeter_wave_radar.obj`;
|
|
|
+ } else if (type === "lidar") {
|
|
|
+ mtlUrl = `${that.publicPath}sensor/lidar/LIDAR.mtl`;
|
|
|
+ objUrl = `${that.publicPath}sensor/lidar/LIDAR.obj`;
|
|
|
+ } else if (type === "gps") {
|
|
|
+ mtlUrl = `${that.publicPath}sensor/gps/lidar.mtl`;
|
|
|
+ objUrl = `${that.publicPath}sensor/gps/lidar.obj`;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$emit('loadingDone', 'carStart');
|
|
|
+
|
|
|
+ if (type === "ogt") {
|
|
|
+ // showFullScreenLoading();
|
|
|
+
|
|
|
+
|
|
|
+ var loader1 = new GLTFLoader(); //创建一个FBX加载器
|
|
|
+
|
|
|
+ loader1.load(
|
|
|
+ `${that.publicPath}sensor/ogt/ogt.glb`,
|
|
|
+ function (obj) {
|
|
|
+ that.$emit('loadingDone', 'carDone');
|
|
|
+
|
|
|
+ that.ogt = obj.scene;
|
|
|
+
|
|
|
+ that.cacheList.push(obj.scene);
|
|
|
+
|
|
|
+ let s = that.scale;
|
|
|
+
|
|
|
+ let scale = 0.1;
|
|
|
+ obj.scene.scale.set(scale, scale, scale);
|
|
|
+
|
|
|
+ obj.scene.position.set(pos.x, pos.y, pos.z);
|
|
|
+ obj.scene.name = "sensor";
|
|
|
+
|
|
|
+ that.sensor = obj.scene;
|
|
|
+
|
|
|
+ that.scene.add(that.sensor); //返回的组对象插入场景中
|
|
|
+ },
|
|
|
+ (xhr) => { },
|
|
|
+ (error) => {
|
|
|
+ that.$emit('loadingDone', 'carDone');
|
|
|
+
|
|
|
+ console.error(error);
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ Loader.load(
|
|
|
+ mtlUrl,
|
|
|
+ function (materials) {
|
|
|
+ loader.setMaterials(materials);
|
|
|
+ loader.load(objUrl, function (obj) {
|
|
|
+ // if (type === "ogt") {
|
|
|
+ // tryHideFullScreenLoading();
|
|
|
+ // }
|
|
|
+
|
|
|
+ that.$emit('loadingDone', 'carDone');
|
|
|
+
|
|
|
+ if (type === "camera") {
|
|
|
+ that.cameraSensor = obj;
|
|
|
+ } else if (type === "ogt") {
|
|
|
+ that.ogt = obj;
|
|
|
+ } else if (type === "lidar") {
|
|
|
+ that.lidar = obj;
|
|
|
+ } else if (type === "gps") {
|
|
|
+ that.gps = 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(scale, scale, scale);
|
|
|
+ obj.children[i].scale.set(0.4, 0.4, 0.4);
|
|
|
+ } else if (type === "ogt") {
|
|
|
+ let scale = 0.2 * that.scale;
|
|
|
+ obj.children[i].scale.set(scale, scale, scale);
|
|
|
+ } else if (type === "lidar") {
|
|
|
+ let scale = 0.03 * that.scale;
|
|
|
+ // obj.children[i].scale.set(scale, scale, scale);
|
|
|
+ obj.children[i].scale.set(0.06, 0.06, 0.06);
|
|
|
+ } else if (type === "gps") {
|
|
|
+ let scale = 40 * that.scale;
|
|
|
+ obj.children[i].scale.set(scale, scale, scale);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ obj.position.set(pos.x, pos.y, pos.z);
|
|
|
+ obj.name = "sensor";
|
|
|
+
|
|
|
+ that.sensor = obj;
|
|
|
+
|
|
|
+ that.scene.add(that.sensor); //返回的组对象插入场景中
|
|
|
+ });
|
|
|
+ },
|
|
|
+ (xhr) => {
|
|
|
+ // console.log((xhr.loaded / xhr.total) * 100 + "% loaded");
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ // if (type === "ogt") {
|
|
|
+ // tryHideFullScreenLoading();
|
|
|
+ // }
|
|
|
+
|
|
|
+ that.$emit('loadingDone', 'carDone');
|
|
|
+
|
|
|
+ console.error(error);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ // 初始化
|
|
|
+ init() {
|
|
|
+ this.initScene();
|
|
|
+ this.initCamera();
|
|
|
+ this.initRenderer();
|
|
|
+ this.initLight();
|
|
|
+
|
|
|
+ this.controls = new OrbitControls(
|
|
|
+ this.camera,
|
|
|
+ this.renderer.domElement
|
|
|
+ ); //创建控件对象
|
|
|
+ this.controls.minDistance = 30;
|
|
|
+ this.controls.maxDistance = 18000;
|
|
|
+ this.controls.update();
|
|
|
+ },
|
|
|
+ animate() {
|
|
|
+ this.raf = requestAnimationFrame(this.animate);
|
|
|
+ this.renderer.render(this.scene, this.camera);
|
|
|
+ if (this.transformControls) {
|
|
|
+ this.transformControls.update();
|
|
|
+ }
|
|
|
+
|
|
|
+ this.controls.update();
|
|
|
+ },
|
|
|
+ onWindowResize() {
|
|
|
+ this.camera.aspect =
|
|
|
+ this.container.clientWidth / this.container.clientHeight;
|
|
|
+ this.camera.updateProjectionMatrix();
|
|
|
+ this.renderer.setSize(
|
|
|
+ this.container.clientWidth,
|
|
|
+ this.container.clientHeight
|
|
|
+ );
|
|
|
+ },
|
|
|
+ go() {
|
|
|
+ this.container = document.getElementById(
|
|
|
+ "containerThreeSensorModel"
|
|
|
+ );
|
|
|
+ this.init();
|
|
|
+ this.animate();
|
|
|
+
|
|
|
+ window.addEventListener("resize", this.onWindowResize);
|
|
|
+ },
|
|
|
+ removeScene() {
|
|
|
+ this.clearScene();
|
|
|
+ },
|
|
|
+ clearCache(item) {
|
|
|
+ if (item.geometry && item.geometry.dispose) item.geometry.dispose();
|
|
|
+ if (item.material && item.material.dispose) item.material.dispose();
|
|
|
+ },
|
|
|
+ clearScene() {
|
|
|
+ this.removeObj(this.scene);
|
|
|
+ },
|
|
|
+ removeObj(obj) {
|
|
|
+ let arr = obj.children.filter((x) => x);
|
|
|
+ arr.forEach((item) => {
|
|
|
+ if (item.children.length) {
|
|
|
+ this.removeObj(item);
|
|
|
+ } else {
|
|
|
+ this.clearCache(item);
|
|
|
+ item.clear();
|
|
|
+ }
|
|
|
+ }),
|
|
|
+ obj.clear();
|
|
|
+ arr = null;
|
|
|
+ },
|
|
|
+ },
|
|
|
+
|
|
|
+ mounted() {
|
|
|
+ this.go();
|
|
|
+ },
|
|
|
+ destroyed() {
|
|
|
+ window.removeEventListener("resize", this.onWindowResize);
|
|
|
+ cancelAnimationFrame(this.raf);
|
|
|
+
|
|
|
+ if (this.renderer) {
|
|
|
+ this.renderer.renderLists.dispose();
|
|
|
+ this.renderer.dispose();
|
|
|
+ this.renderer.forceContextLoss();
|
|
|
+ this.renderer.domElement = null;
|
|
|
+ this.renderer.content = null;
|
|
|
+ this.renderer = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.dragControls) {
|
|
|
+ this.dragControls.deactivate();
|
|
|
+ this.dragControls.dispose();
|
|
|
+ this.dragControls = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.controls) {
|
|
|
+ this.controls.dispose();
|
|
|
+ this.controls = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.transformControls) {
|
|
|
+ this.transformControls.detach();
|
|
|
+ this.transformControls.dispose();
|
|
|
+ this.transformControls = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.cacheList.length > 0) {
|
|
|
+ this.scene.remove(...this.cacheList);
|
|
|
+ this.cacheList = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ this.clearScene();
|
|
|
+
|
|
|
+ this.scene = null;
|
|
|
+ this.camera = null;
|
|
|
+ this.light = null;
|
|
|
+ this.geometryName = null;
|
|
|
+ this.mesh = null;
|
|
|
+ this.cube = null;
|
|
|
+ this.container = null;
|
|
|
+ this.car = null;
|
|
|
this.cubeTexture = null;
|
|
|
this.raf = null;
|
|
|
|
|
|
+ this.bsp = null;
|
|
|
+ this.a1 = null;
|
|
|
+ this.b1 = null;
|
|
|
+ this.c1 = null;
|
|
|
+ this.d1 = null;
|
|
|
+ this.a2 = null;
|
|
|
+ this.b2 = null;
|
|
|
+ this.c2 = null;
|
|
|
+ this.d2 = null;
|
|
|
+ this.x1 = null;
|
|
|
+ this.y1 = null;
|
|
|
+ this.z1 = null;
|
|
|
+ this.w1 = null;
|
|
|
+ this.x2 = null;
|
|
|
+ this.y2 = null;
|
|
|
+ this.z2 = null;
|
|
|
+ this.w2 = null;
|
|
|
+
|
|
|
THREE.Cache.clear();
|
|
|
},
|
|
|
};
|