1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420 |
- <template>
- <div>
- <div id="container"></div>
- </div>
- </template>
- <script>
- import * as THREE from "three";
- import { TransformControls } from "three/examples/jsm/controls/TransformControls.js";
- import { DragControls } from "three/examples/jsm/controls/DragControls.js";
- import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
- import { OBJLoader } from "three/examples/jsm/loaders/OBJLoader.js";
- import { MTLLoader } from "three/examples/jsm/loaders/MTLLoader.js";
- import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
- import { ConvexGeometry } from "three/examples/jsm/geometries/ConvexGeometry.js";
- import {
- showFullScreenLoading,
- tryHideFullScreenLoading,
- } from "../../../axios/filter";
- import { mapState } from "vuex";
- export default {
- name: "threeVehicleConfiguration",
- components: {},
- data() {
- return {
- publicPath: process.env.BASE_URL,
- scene: null,
- camera: null,
- renderer: null,
- light: null,
- transformControls: null,
- geometryName: null,
- controls: null,
- mesh: null,
- cube: null,
- cacheList: [],
- xAngle: 0,
- yAngle: 0,
- zAngle: 0,
- container: null,
- car: null,
- cubeTexture: null,
- raf: null,
- canDrag: true,
- dragControls: null,
- sensor: null,
- ogt: null,
-
-
- };
- },
- computed: {
- ...mapState(["scale"]),
-
- rate() {
- return 40 / this.scale;
- },
- },
- props: {
- xValue: {
- type: Number,
- default: 0,
- },
- yValue: {
- type: Number,
- default: 0,
- },
- zValue: {
- type: Number,
- default: 0,
- },
- hValue: {
- type: Number,
- default: 0,
- },
- pValue: {
- type: Number,
- default: 0,
- },
- rValue: {
- type: Number,
- default: 0,
- },
- carModel: {
- type: String,
- default: "",
- },
- isAdd: {
- type: Boolean,
- default: false,
- },
- configList: {
- default: {},
- type: Object,
- },
- },
- watch: {
- xValue(newVal, oldVal) {
- if (newVal === oldVal) return;
- const obj = this.scene.getObjectByName("cube");
- if (obj) obj.position.x = newVal || 0;
- if (this.sensor) this.sensor.position.x = newVal || 0;
- },
- yValue(newVal, oldVal) {
- if (newVal === oldVal) return;
- const obj = this.scene.getObjectByName("cube");
- if (obj) obj.position.y = newVal || 0;
- if (this.sensor) this.sensor.position.y = newVal || 0;
- },
- zValue(newVal, oldVal) {
- if (newVal === oldVal) return;
- const obj = this.scene.getObjectByName("cube");
- if (obj) obj.position.z = newVal || 0;
- if (this.sensor) this.sensor.position.z = newVal || 0;
- },
- hValue(newVal, oldVal) {
- if (newVal === oldVal) return;
- let value = (newVal || 0) - 90;
- value = (value * Math.PI) / 180;
- this.xAngle = value;
- const obj = this.scene.getObjectByName("cube");
- if (obj) {
- obj.rotation.set(this.xAngle, this.yAngle, this.zAngle);
- }
-
-
-
-
-
- },
- pValue(newVal, oldVal) {
- if (newVal === oldVal) return;
- let value = newVal || 0;
- value = (value * Math.PI) / 180;
- this.yAngle = value;
- const obj = this.scene.getObjectByName("cube");
- if (obj) {
- obj.rotation.set(this.xAngle, this.yAngle, this.zAngle);
- }
- },
- rValue(newVal, oldVal) {
- if (newVal === oldVal) return;
- let value = newVal || 0;
- value = (value * Math.PI) / 180;
- this.zAngle = value;
- const obj = this.scene.getObjectByName("cube");
- if (obj) {
- obj.rotation.set(this.xAngle, this.yAngle, this.zAngle);
- }
- },
- carModel(newVal, oldVal) {
- if (newVal && newVal != oldVal) {
- this.initCar(newVal);
- }
- },
- },
- methods: {
-
- initScene() {
- this.scene = new THREE.Scene();
- let axes = new THREE.AxesHelper(1500);
- this.scene.add(axes);
- const gridHelper = new THREE.GridHelper(1000, 100);
- gridHelper.material.opacity = 0.25;
- gridHelper.material.transparent = true;
- this.scene.add(gridHelper);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- const genCubeUrls = function (prefix, postfix) {
- return [
- prefix + "px" + postfix,
- prefix + "nx" + postfix,
- prefix + "py" + postfix,
- prefix + "ny" + postfix,
- prefix + "pz" + postfix,
- prefix + "nz" + postfix,
- ];
- };
- const urls = genCubeUrls(`${this.publicPath}Park3Med/`, ".jpg");
-
- const cubeTextureLoader = new THREE.CubeTextureLoader();
- const environmentMapTexture = cubeTextureLoader.load(urls);
-
- },
-
- initCamera() {
-
- this.camera = new THREE.PerspectiveCamera(
- 75,
- this.container.clientWidth / this.container.clientHeight,
- 0.1,
- 1000
- );
-
-
-
- this.camera.position.set(200, 200, 200);
-
- this.scene.add(this.camera);
- },
-
- initRenderer() {
- this.renderer = new THREE.WebGLRenderer({
- antialias: true,
- alpha: true,
- });
- this.renderer.setSize(
- this.container.clientWidth,
- this.container.clientHeight
- );
- this.renderer.setClearColor("#272727");
- this.container.appendChild(this.renderer.domElement);
- },
-
- initLight() {
- var hemiLight = new THREE.HemisphereLight(0xffffff, 0x444444);
- hemiLight.position.set(0, 20, 0);
- this.scene.add(hemiLight);
-
- const light = new THREE.AmbientLight(0x5c5c5c, 0.4);
- this.scene.add(light);
-
-
-
-
-
- const dirLight = new THREE.DirectionalLight(0xffffff, 0.5);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- },
- initTransform() {
-
- this.transformControls = new TransformControls(
- this.camera,
- this.renderer.domElement
- );
- this.transformControls.setMode("translate");
-
- this.transformControls.setSpace("world");
- this.transformControls.addEventListener("objectChange", (e) => {
-
-
-
-
-
-
- if (!this.canDrag) return;
- this.$emit(
- "posChange",
- (e.target.object.position.x + 0.5) >> 0,
- "x"
- );
- this.$emit(
- "posChange",
- (e.target.object.position.y + 0.5) >> 0,
- "y"
- );
- this.$emit(
- "posChange",
- (e.target.object.position.z + 0.5) >> 0,
- "z"
- );
- });
- this.transformControls.addEventListener("mouseDown", (e) => {
- this.controls.enabled = false;
- });
- this.transformControls.addEventListener("mouseUp", (e) => {
- this.controls.enabled = true;
- });
- this.scene.add(this.transformControls);
- },
-
- initContent(r, position, rotation, type) {
- var cubeGeometry = new THREE.ConeGeometry(
- r || 45 * this.scale,
- 150 * this.scale,
- 4,
- 1,
- false
- );
- cubeGeometry.translate(0, -75 * this.scale, 0);
- let obj = {
- color: 0x4c4c4c,
-
- transparent: true,
- opacity: 0.3,
-
-
- lightMapIntensity: 0.1,
-
-
-
-
- };
- if (type === "camera") {
- obj.emissive = 0x0000ff;
-
- } else if (type === "ogt") {
-
-
- obj.emissive = 0x008000;
- } else if (type === "lidar") {
-
-
- obj.emissive = 0xff4500;
- } else if (type === "gps") {
-
-
- obj.emissive = 0x8a2be2;
- }
-
- var cubeMaterial = new THREE.MeshLambertMaterial(obj);
- this.cube = new THREE.Mesh(cubeGeometry, cubeMaterial);
- this.cube.name = this.geometryName || "cube";
- if (position) {
- this.cube.position.x = position.x;
- this.cube.position.y = position.y;
- this.cube.position.z = position.z;
- }
- if (rotation) {
- this.cube.rotateX(rotation.x);
- this.cube.rotateY(rotation.y);
- this.cube.rotateZ(rotation.z);
- }
- this.scene.add(this.cube);
- if (this.transformControls) {
- this.transformControls.attach(this.cube);
- }
- },
-
- initDragControls() {
-
- var objects = [];
- for (let i = 0; i < this.scene.children.length; i++) {
- if (this.scene.children[i].isMesh) {
- objects.push(this.scene.children[i]);
- }
- }
- if (this.dragControls) {
- this.dragControls.deactivate();
- this.dragControls.dispose();
- this.dragControls = null;
- }
-
- this.dragControls = new DragControls(
- objects,
- this.camera,
- this.renderer.domElement
- );
-
-
-
-
-
- this.dragControls.addEventListener("drag", (e) => {
- if (!this.canDrag) return;
-
-
-
- });
- this.dragControls.addEventListener("dragstart", (e) => {
- this.controls.enabled = false;
- });
- this.dragControls.addEventListener("dragend", (e) => {
- this.controls.enabled = true;
- });
- },
- initCar0(model) {
- if (this.car) {
-
- this.scene.remove(this.car);
- this.removeObj(this.car);
- this.car = null;
- }
-
-
-
-
-
-
- showFullScreenLoading();
- var that = this;
- var loader = new GLTFLoader();
-
-
-
- loader.load(
- model,
- function (obj) {
-
- tryHideFullScreenLoading();
-
-
- obj.scene.rotation.set(
- (-90 * Math.PI) / 180,
- 0,
- (-180 * Math.PI) / 180
- );
- let scale = 30 * that.scale;
- obj.scene.scale.set(scale, scale, scale);
-
-
-
-
- that.scene.add(obj.scene);
- that.car = obj.scene;
- },
- (xhr) => {
-
- },
- (error) => {
-
- tryHideFullScreenLoading();
- console.error(error);
- }
- );
- },
- initCar1() {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- },
- initCar2() {
- var that = this;
- var loader2 = new THREE.ObjectLoader();
-
-
- loader2.load(`${that.publicPath}car.json`, function (obj) {
-
-
- obj.name = "car";
-
-
- obj.scale.set(30, 30, 30);
- obj.rotation.set(
- (-90 * Math.PI) / 180,
- 0,
- (-90 * Math.PI) / 180
- );
-
-
- that.scene.add(obj);
- });
- },
- initCar3() {
- var Loader = new MTLLoader();
- var loader = new OBJLoader();
- var that = this;
- Loader.load(
-
-
-
-
-
-
-
-
-
- `${that.publicPath}lb/1/obj/untitled.mtl`,
- function (materials) {
-
-
-
-
-
-
-
- loader.setMaterials(materials);
- loader.load(
-
-
-
-
- `${that.publicPath}lb/1/obj/untitled.obj`,
-
-
-
-
- function (obj) {
-
- obj.name = "car";
-
-
-
-
-
- for (let i = 0; i < obj.children.length; i++) {
-
-
- obj.children[i].position.set(0, 0, 0);
-
- obj.children[i].rotation.set(
- (-90 * Math.PI) / 180,
- 0,
- (-180 * Math.PI) / 180
- );
-
-
- }
-
-
-
-
- that.scene.add(obj);
-
-
-
-
-
-
-
-
- }
- );
- }
- );
- },
-
- initCar(model) {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if (!model) return;
- if (!model.includes(".glb")) return;
- this.initCar0(model);
-
-
-
-
-
-
-
-
-
-
-
- },
-
- init() {
- this.initScene();
- this.initCamera();
- this.initRenderer();
- this.initTransform();
- this.initLight();
-
- this.controls = new OrbitControls(
- this.camera,
- this.renderer.domElement
- );
- 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("container");
- this.init();
- this.animate();
- window.addEventListener("resize", this.onWindowResize);
- },
-
- reset(type) {
- this.canDrag = true;
- if (this.cacheList.length > 0) {
- this.scene.remove(...this.cacheList);
- this.cacheList.forEach((i) => {
- this.clearCache(i);
- });
- this.cacheList = [];
- }
- this.sensor = null;
- const obj1 = this.scene.getObjectByName("cube");
- if (obj1) {
- this.scene.remove(obj1);
- }
- this.xAngle = 0;
- this.yAngle = 0;
- this.zAngle = 0;
- let z = +this.$parent.formA.sensorX || 0;
- let x = +this.$parent.formA.sensorY || 0;
- let y = +this.$parent.formA.sensorZ || 0;
- let h = +this.$parent.formA.sensorP || 0;
- let p = +this.$parent.formA.sensorR || 0;
- let r = +this.$parent.formA.sensorH || 0;
- x = Math.floor(x / this.rate);
- y = Math.floor(y / this.rate);
- z = Math.floor(z / this.rate);
- this.initContent(
- null,
- { x, y, z },
- {
- x: (-90 * Math.PI) / 180,
- y: 0,
- z: 0,
- },
- type
- );
- setTimeout(() => {
- this.initSensor({ x, y, z }, type, true);
- const obj = this.scene.getObjectByName("cube");
- obj.position.x = x;
- obj.position.y = y;
- obj.position.z = z;
-
-
- this.xAngle = ((h - 90) * Math.PI) / 180;
-
-
- this.yAngle = (p * Math.PI) / 180;
-
-
- this.zAngle = (r * Math.PI) / 180;
- obj.rotation.set(this.xAngle, this.yAngle, this.zAngle);
- }, 0);
- },
-
- initSensor(
- pos = { x: 0, y: 0, z: 0 },
- type = "camera",
- canMove = false
- ) {
- let Loader = new MTLLoader();
- let loader = new OBJLoader();
- let that = this;
- let mtlUrl = "";
- let objUrl = "";
- if (type === "ogt1") {
- var loader2 = new THREE.ObjectLoader();
- loader2.load(
- `${that.publicPath}sensor/ogt/ogt.json`,
- function (obj) {
-
- that.cacheList.push(obj);
- for (let i = 0; i < obj.children.length; i++) {
- obj.children[i].scale.set(0.2, 0.2, 0.2);
- }
- obj.position.set(pos.x, pos.y, pos.z);
- obj.name = "ogt";
- if (canMove) {
- that.sensor = obj;
- }
- that.scene.add(obj);
- }
- );
- return;
- }
- if (type === "ogt1" && this.ogt) {
- setTimeout(() => {
- let obj1 = this.ogt;
-
-
-
- obj1.position.set(pos.x, pos.y, pos.z);
- if (canMove) {
- that.sensor = obj1;
- }
- obj1.name = "ogt";
-
- that.scene.add(obj1);
- }, 600);
- return;
- }
- 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`;
- }
- let loading = null;
- if (type === "ogt") {
-
-
-
-
-
-
- showFullScreenLoading();
- }
- Loader.load(
- mtlUrl,
- function (materials) {
-
- loader.setMaterials(materials);
- loader.load(objUrl, function (obj) {
-
-
-
-
-
-
- if (type === "ogt") {
-
- tryHideFullScreenLoading();
- }
- that.cacheList.push(obj);
- for (let i = 0; i < obj.children.length; i++) {
- if (type === "camera") {
-
- obj.children[i].scale.set(0.8, 0.8, 0.8);
- } else if (type === "ogt") {
- obj.children[i].scale.set(0.2, 0.2, 0.2);
- } else if (type === "lidar") {
- obj.children[i].scale.set(0.1, 0.1, 0.1);
- } else if (type === "gps") {
- obj.children[i].scale.set(40, 40, 40);
- }
-
-
-
-
-
- }
- obj.position.set(pos.x, pos.y, pos.z);
-
- if (canMove) {
- that.sensor = obj;
- }
- that.scene.add(obj);
- });
- },
- (xhr) => {
-
- },
- (error) => {
- if (type === "ogt") {
-
- tryHideFullScreenLoading();
- }
- console.error(error);
- }
- );
- },
-
- initContentToShow(r, position, rotation, type) {
- var cubeGeometry = new THREE.ConeGeometry(
- r || 45 * this.scale,
- 150 * this.scale,
- 4,
- 1,
- false
- );
- cubeGeometry.translate(0, -75 * this.scale, 0);
- let obj = {
- transparent: true,
- opacity: 0.3,
-
- lightMapIntensity: 0.1,
- color: 0x4c4c4c,
- };
- if (type === "camera") {
- obj.emissive = 0x000080;
-
- } else if (type === "ogt") {
- obj.emissive = 0x008000;
-
- } else if (type === "lidar") {
-
-
- obj.emissive = 0xff4500;
- } else if (type === "gps") {
-
-
- obj.emissive = 0x8a2be2;
- }
- var cubeMaterial = new THREE.MeshLambertMaterial(obj);
-
- var cube = new THREE.Mesh(cubeGeometry, cubeMaterial);
- cube.name = this.geometryName || "cubeA";
- cube.rotateX((-90 * Math.PI) / 180);
- if (position) {
- cube.position.x = position.x;
- cube.position.y = position.y;
- cube.position.z = position.z;
- }
- if (rotation) {
-
-
-
-
-
-
- cube.rotation.set(
- ((rotation.x - 90) * Math.PI) / 180,
- (rotation.y * Math.PI) / 180,
- (rotation.z * Math.PI) / 180
- );
- }
- this.cacheList.push(cube);
- this.scene.add(cube);
- },
-
- showSensor(sensor, type) {
- if (sensor && Array.isArray(sensor) && sensor.length > 0) {
- sensor.forEach((item) => {
- this.initContentToShow(
- null,
- {
- z: Math.floor(item.sensorX / this.rate || 0),
- x: Math.floor(item.sensorY / this.rate || 0),
- y: Math.floor(item.sensorZ / this.rate || 0),
- },
- {
- x: +item.sensorP,
- y: +item.sensorR,
- z: +item.sensorH,
- },
- type
- );
- this.initSensor(
- {
- z: Math.floor(item.sensorX / this.rate || 0),
- x: Math.floor(item.sensorY / this.rate || 0),
- y: Math.floor(item.sensorZ / this.rate || 0),
- },
- type,
- false
- );
- });
- }
- },
-
- showAll() {
-
- if (!this.canDrag) return;
- this.canDrag = false;
- if (this.cacheList.length > 0) {
- this.scene.remove(...this.cacheList);
- this.cacheList = [];
- }
- const obj = this.scene.getObjectByName("cube");
- if (obj) {
- this.scene.remove(obj);
- }
- if (this.dragControls) {
- this.dragControls.deactivate();
- this.dragControls.dispose();
- this.dragControls = null;
- }
- if (this.transformControls) {
- this.transformControls.detach();
- }
-
- this.showSensor(this.configList.camera, "camera");
- this.showSensor(this.configList.ogt, "ogt");
- this.showSensor(this.configList.lidar, "lidar");
- this.showSensor(this.configList.gps, "gps");
- },
- 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;
- },
- showTX() {
- var pointsArr1 = [
-
-
-
-
- [0, 0, 0],
- [10, -11, 66],
- [30, 31, 66],
- [-20, -21, 66],
- [-30, 21, 66],
- ];
- let x = 0,
- y = 0,
- z = 0;
- let r = 60;
- z = r;
- let a = 120,
- b = 40;
- x = Math.tan(THREE.MathUtils.degToRad(a / 2)) * r;
- y = Math.tan(THREE.MathUtils.degToRad(b / 2)) * r;
- let x1 = 0,
- y1 = 0,
- z1 = 0;
- let r1 = 20;
- z1 = r1;
- x1 = Math.tan(THREE.MathUtils.degToRad(a / 2)) * r1;
- y1 = Math.tan(THREE.MathUtils.degToRad(b / 2)) * r1;
- let pointsArr2 = [
- [0, 0, 0],
-
-
-
-
- [-x, y, z],
- [-x, -y, z],
- [x, y, z],
- [x, -y, z],
- ];
- let x2 = 0,
- y2 = 0,
- z2 = 0,
- x3 = 0,
- y3 = 0,
- z3 = 0,
- x4 = 0,
- y4 = 0,
- z4 = 0,
- x6 = 0,
- y6 = 0,
- z6 = 0,
- r2 = 90,
- a2 = 30,
- b2 = 60,
- c2 = 90,
- d2 = 60;
- x2 = Math.tan(THREE.MathUtils.degToRad(a2 / 2)) * r2;
- y2 = Math.tan(THREE.MathUtils.degToRad(b2 / 2)) * r2;
- x3 = Math.tan(THREE.MathUtils.degToRad(c2 / 2)) * r2;
- y3 = Math.tan(THREE.MathUtils.degToRad(d2 / 2)) * r2;
- let pointsArr3 = [
- [0, 0, 0],
- [-x2, y3, r2],
- [-x3, -y3, r2],
- [x2, y2, r2],
- [x3, -y2, r2],
- ];
-
- let points = pointsArr3.map(
- (d) => new THREE.Vector3(d[0], d[1], d[2])
- );
- let material = new THREE.MeshPhongMaterial({
- color: 0x2c85e1,
- shininess: 60,
- specular: 0x2c85e1,
-
-
- });
- let tixing = new ConvexGeometry(points);
-
- let tixingMesh = new THREE.Mesh(tixing, material);
- this.scene.add(tixingMesh);
-
-
-
-
-
-
-
-
-
-
-
- },
- },
- 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.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;
- THREE.Cache.clear();
- },
- };
- </script>
- <style lang="less" scoped>
- #container {
- width: 100%;
- height: calc(100vh - 125px);
- }
- </style>
|