webgl_rxdz.vue 97 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576
  1. <template src="./webgl_rxdz.html"></template>
  2. <script>
  3. import * as THREE from 'three';
  4. import Stats from 'three/addons/libs/stats.module.js';
  5. import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
  6. import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
  7. import TWEEN from 'three/addons/libs/tween.module.js';
  8. import router from "@/router";
  9. var requestId = "";
  10. const util = require('@/utils/util.js').default;
  11. // const config = require('@/services/urlConfig.js');
  12. import wallType from '@/static/wallData.js';
  13. // import modelData from '@/webgl/static/layoutModelData.js';
  14. // import requestConfig from '@/services/requestConfig.js';
  15. // import viewShell from'@/webgl/components/newBottomCom/viewShell/viewShell.vue';
  16. // import * as BufferGeometryUtils from '@/webgl/jsm/utils/BufferGeometryUtils.js';
  17. import screenshot from '@/mixins/screenshot.js';
  18. import floorMethod from '@/mixins/floorMethod.js';
  19. import wallMethod from '@/mixins/wallMethod.js';
  20. import loadModel from '@/mixins/loadModel.js';
  21. import viewShell from'@/components/newBottomCom/viewShell/viewShell.vue';
  22. export default {
  23. name:"webgl_rxdz",
  24. components:{viewShell},
  25. mixins:[screenshot,floorMethod,wallMethod,loadModel],
  26. /**
  27. * 页面的初始数据
  28. */
  29. data() {
  30. return {
  31. pvCurPageName: "home_show",
  32. locusBehaviorName: "主界面",
  33. pvCurPageParams: null,
  34. houseId: "",
  35. pvId: 'p_2cmina_23080401',
  36. canvas:null,
  37. navbar: {
  38. showCapsule: 0,
  39. title: '',
  40. titleColor: '#000',
  41. navPadding: 0,
  42. navPaddingBg:'transparent',
  43. navBarColor: 'transparent',
  44. navBackColor: 'transparent',
  45. haveCallback: false,
  46. fromShare: false,
  47. fromProject: 0,
  48. shareToken: "",
  49. pageName: this.pvCurPageName,
  50. },
  51. id:'232',// 户型编号
  52. spaceList:[], // 空间列表
  53. spaceListBackup:[], // 空间列表原始尺寸备份,用于墙体比例计算
  54. gltfSpaces:[], // 场景中地板模型数组
  55. curSpaceObj:null, // 当前选中的空间
  56. // curSpaceIndex:-1, // 当前选中的空间索引
  57. curWallDirection:"", // 当前选中的墙面
  58. curWallValue:0, // 当前墙面的滑动值
  59. curWallMaxValue:300,
  60. curWallHidden:false, // 当前墙面的状态
  61. wallIds:[], // 空间墙体id
  62. wallList:[], // 墙体数据
  63. gltfWalls:[], // 场景中墙体模型数组
  64. gltfAutoWalls:[],// 空间自动补墙模型数组
  65. // lastWallPosition:0, // 当面墙中墙体模型的开始位置
  66. tempSpaceList:[],// 全部空间临时数组,寻找关联空间,递归使用
  67. leftSpaces:[], // 移动空间左边数组
  68. rightSpaces:[],// 移动空间右边数组
  69. changeSpaces:[],// 尺寸变化涉及到的全部空间
  70. loader:null,
  71. scene:null,
  72. sky:null,
  73. camera:null,
  74. houseList:[], //当前户型所有的户型详情,可以切换
  75. curHouseType: null, //当前选中的户型类型
  76. curHouseName:'',//当前选中的户型类型名称
  77. curHouseFloor: null, //当前选中的户型楼层
  78. curHouseObj: null,
  79. controlStarPosition : { x:0, y:0, z:0}, //控制器初始位置
  80. cameraStarPosition : { x:0, y:20, z:0} ,//摄像头初始位置
  81. // cameraLastPosition: null, //摄像头上一次移动到的位置
  82. // controlLastPosition: null, //观察点上一次移动到的位置
  83. canvasHeight:200, //canvas视图的高度-计算得出
  84. chooseMesh:null,//标记鼠标拾取到的mesh
  85. // chooseMeshColor:'', //拾取到的mesh的原始颜色;
  86. chooseWallMeshColor:'', // 拾取墙体原始颜色
  87. curWallArr:[], // 当前空间选中墙面的墙体模型
  88. isManyou: false, //当前是否处在漫游状态
  89. pageShowIndex: 2, // 默认户型列表页面
  90. aleadyLoaderModel:[], //已经加载的墙体元数据模型列表
  91. // fontLabelGroup: [],
  92. shottingImg: [],
  93. progress:1, //进度条
  94. myLoadingStatus:false,
  95. // textGeoList:[],
  96. repeatFlag:false, //重复点击
  97. skyPlan: null, // 天空盒子
  98. instancedMeshList: [],
  99. lableItem:[],
  100. showLables:false,
  101. loadOver:false,
  102. voiceMaskShow:false, //录音时的蒙层是否显示
  103. minspace1: null,
  104. minspace2: null,
  105. minspace3: null,
  106. minspace4 : null,
  107. spaces1 : [],
  108. spaces2 : [],
  109. spaces3 : [],
  110. spaces4 : [],
  111. layoutIds:[], // 空间墙体id
  112. layoutLists:[], // 墙体数据
  113. gltfLayouts:[], // 场景中墙体模型数组
  114. screenshotResolve:null,
  115. curLayoutStruct:null,//当前户型大类下所有楼层数据-用于提交
  116. overChange:false, //是否形变中
  117. isIos:false, //是否ios手机。默认不是
  118. currentChangeSpaceId:null, //当前变化的空间id
  119. styleType:1,
  120. sumArea:0, //总面积
  121. changeArea:0, //当次变化的面积
  122. }
  123. },
  124. beforeDestroy() {
  125. cancelAnimationFrame(requestId, this.canvas)
  126. this.worker && this.worker.terminate()
  127. if (this.renderer instanceof THREE.WebGLRenderer) {
  128. this.renderer.dispose()
  129. this.renderer.forceContextLoss()
  130. this.renderer.context = null
  131. this.renderer.domElement = null
  132. this.renderer = null;
  133. this.clearEvent()
  134. }
  135. this.gltfWalls = [];
  136. this.gltfSpaces = [];
  137. this.instancedMeshList = [];
  138. this.instancedSpaceMeshList = [];
  139. this.lableItem = [];
  140. this.gltfLayouts = [];
  141. this.instancedFurList = [];
  142. this.wallList = [];
  143. TWEEN && TWEEN.removeAll();//清除所有的tween;
  144. console.warn("***beforeDestroy-webgl_rxdz***");
  145. },
  146. mounted() {
  147. console.log("***onLoad-webgl_rxdz***", this.$route.query)
  148. var that = this;
  149. this.houseId = this.$store.state.houseId || '';
  150. this.childLayout = this.$route.query.childLayout || 0;//4-测试户型
  151. let unit = window.screen.width / 750;//单位rpm 对应 px 的值
  152. that.canvasHeight = window.screen.height - (200 * unit) + (20 * unit);
  153. const container = this.$refs.webgl;
  154. const canvas3d = this.canvas = this.$refs.glcanvas;
  155. let camera = null, renderer = null, controls=null;
  156. // let trackballControls = null;
  157. console.warn("***loader0***",this.loader)
  158. let loader = null;
  159. loader = this.loader = new GLTFLoader();
  160. this.getInitData();//请求获取页面模型数据等
  161. let scene = this.scene = new THREE.Scene();
  162. let chooseMesh = this.chooseMesh;//标记鼠标拾取到的mesh
  163. let isUserContorl = false;
  164. let tweenCameraAnma = false; //表示当前是否处在动画过程中
  165. let needRender = false; //是否需要渲染 false表示不需要渲染;true 表示需要渲染
  166. let frustumSize = 30;//正交相机的视窗宽度距离
  167. let stats;
  168. init();
  169. // render();
  170. // this.$refs.myLoading.showLoading("加载中..." + this.progress+"%")
  171. // this.myLoadingStatus = true;
  172. this.progress = 1;
  173. this.clearEvent = clearEvent;
  174. this.attendEvent = attendEvent;
  175. this.updateLables = updateLables;
  176. this.enableRenderHandle = enableRender;
  177. this.tweenCameraAnmaChange = tweenCameraAnmaChange;
  178. this.gradientResize = gradientResize;
  179. this.moveMeshCenterHandle = moveMeshCenterHandle;
  180. this.starRender = starRender;//对外暴露启动渲染的方法
  181. this.cameraInit = cameraInit;
  182. this.resetControl = resetControl;
  183. function init() {
  184. scene.background = new THREE.Color("#FFFFFF");
  185. // scene.environment = new THREE.Color("#F2F2F2");
  186. // 创建相机位置-投影相机
  187. camera = new THREE.PerspectiveCamera( 80, window.screen.width / that.canvasHeight, 0.1, 10000 );
  188. // let aspect = window.screen.width / that.canvasHeight;
  189. // camera = new THREE.OrthographicCamera( frustumSize * aspect / - 2, frustumSize * aspect / 2, frustumSize / 2, frustumSize / - 2, 0.1,1000);
  190. camera.up.set(0, 1, 0);//俯视状态,将相机的up向量设置为z轴负方向
  191. scene.add(camera);
  192. that.camera = camera;
  193. // 辅助方格
  194. // const axesHelper = new THREE.AxesHelper( 50 );
  195. // scene.add( axesHelper );
  196. // const gridHelper = new THREE.GridHelper(50, 10, 0xcccccc, 0xcccccc);
  197. // gridHelper.position.y = 0;
  198. // gridHelper.position.x = 0;
  199. // scene.add(gridHelper);
  200. // 环境光会均匀的照亮场景中的所有物体
  201. const ambientLight = new THREE.AmbientLight(0xFFEFE0, 3);
  202. scene.add(ambientLight);
  203. //平行光
  204. const light = new THREE.DirectionalLight(0xFFF8E5, 3);
  205. light.position.set(-3, 9, 3); //default; light shining from top
  206. light.castShadow = true; // default false
  207. // 默认情况下光投影相机区域是一个长宽高为10x10x500的长方体区域,光源投射方向为通过坐标原点
  208. light.shadow.camera.left = -100; // default
  209. light.shadow.camera.right = 100; // default
  210. light.shadow.camera.top = 100; // default
  211. light.shadow.camera.bottom = -100; // default
  212. light.shadow.mapSize.width = 8192; // default
  213. light.shadow.mapSize.height = 8192; // default
  214. // light.shadow.camera.near = 0.1; // default
  215. // light.shadow.camera.far = 500; // default
  216. // light.shadow.bias = -0.01;
  217. // light.shadow.radius = 1;
  218. // light.shadow.darkness = 1; // 设置阴影强度为0.5
  219. scene.add(light);
  220. // const helper = new THREE.CameraHelper( light.shadow.camera );
  221. // scene.add(helper);
  222. // 从一个点向各个方向发射的光源。一个常见的例子是模拟一个灯泡发出的光。
  223. // const pointLight = new THREE.PointLight( 0xffffff, 0.3 );
  224. // camera.add( pointLight );
  225. //antialias 这个值得设置为false,不然IOS上截图会失效
  226. renderer = that.renderer = new THREE.WebGLRenderer({
  227. canvas:canvas3d,
  228. alpha: true,
  229. antialias:false,
  230. // 如果想保存three.js canvas画布上的信息,注意设置preserveDrawingBuffer
  231. preserveDrawingBuffer: true,
  232. });
  233. renderer.shadowMap.enabled = true;//产生阴影
  234. renderer.shadowMap.type = THREE.PCFSoftShadowMap; // 阴影属性
  235. renderer.outputEncoding = THREE.sRGBEncoding;
  236. renderer.outputColorSpace = THREE.SRGBColorSpace;
  237. // renderer.toneMappingExposure = 0.1;//色调映射的曝光级别。默认是1
  238. renderer.toneMapping = THREE.NoToneMapping;//色调映射
  239. renderer.physicallyCorrectLights = true;//关键参数,模拟物理光照影响,必须设置为true
  240. renderer.setPixelRatio( window.devicePixelRatio );
  241. renderer.setSize( window.screen.width, that.canvasHeight );
  242. container.appendChild( renderer.domElement );
  243. controls = new OrbitControls(camera, renderer.domElement);
  244. controls.screenSpacePanning = true;
  245. controls.enableDamping = true;
  246. controls.minDistance = 1;
  247. controls.maxDistance = 400;
  248. controls.minPolarAngle = 0;// 默认0
  249. controls.maxPolarAngle = Math.PI / 2; // 默认Math.PI,即可以向下旋转到的视角。
  250. controls.target.set(that.controlStarPosition.x, that.controlStarPosition.y, that.controlStarPosition.z);
  251. controls.enableZoom = true;//启用摄像机的缩放
  252. // 监听相机移动事件-限制只能在当前空间范围内移动
  253. controls.addEventListener('change', () => {
  254. // 检查相机位置是否超出边界框
  255. if (camera.position.y < 0) {
  256. camera.position.y = 0;
  257. }
  258. });
  259. // controls.target = new THREE.Vector3( that.controlStarPosition.x, that.controlStarPosition.y, that.controlStarPosition.z );;
  260. // stats = new Stats();
  261. // container.appendChild(stats.dom);
  262. // stats.domElement.style.top = '100px';
  263. attendEvent(); //注册监听事件
  264. starRender(); //启动渲染
  265. cameraInit(); //初始化摄像头
  266. controls.saveState();//保存当前控制器的状态
  267. }
  268. //初始化相机位置
  269. function cameraInit(){
  270. camera.position.set(that.cameraStarPosition.x, that.cameraStarPosition.y, that.cameraStarPosition.z);
  271. camera.lookAt(that.controlStarPosition.x,that.controlStarPosition.y,that.controlStarPosition.z);
  272. }
  273. //初始状态
  274. function resetControl(){
  275. controls.reset();
  276. }
  277. function onWindowResize() {
  278. camera.aspect = window.screen.width / that.canvasHeight;
  279. camera.updateProjectionMatrix();
  280. renderer.setSize( window.screen.width, that.canvasHeight );
  281. console.warn("****onWindowResize**")
  282. }
  283. function attendEvent () {
  284. window.addEventListener('resize', onWindowResize);
  285. renderer.domElement.addEventListener('touchstart', onPointerStart, false);
  286. renderer.domElement.addEventListener('touchmove', onPointerMove, false);
  287. renderer.domElement.addEventListener('touchend', onPointerUp, false);
  288. }
  289. function tweenCameraAnmaChange (value) {
  290. tweenCameraAnma = value
  291. }
  292. //开启渲染-帧率优化,不触发时停止渲染
  293. function enableRender() {
  294. }
  295. //取消事件监听-避免二次进入时触发多次事件
  296. function clearEvent(){
  297. console.warn("**clearEvent****")
  298. renderer && renderer.domElement && renderer.domElement.removeEventListener('touchstart', onPointerStart);
  299. renderer && renderer.domElement && renderer.domElement.removeEventListener('touchmove', onPointerMove );
  300. renderer && renderer.domElement && renderer.domElement.removeEventListener('touchend', onPointerUp );
  301. }
  302. // 手指移动开始
  303. function onPointerStart(event){
  304. console.log('开始触摸事件:',that.overChange)
  305. if(that.overChange){//形变中,不能相应用户操作
  306. return false;
  307. }
  308. }
  309. //持续触摸中
  310. function onPointerMove( event ) {
  311. if(that.overChange){//形变中,不能相应用户操作
  312. return false;
  313. }
  314. // that.showLables = false;
  315. }
  316. //触摸结束
  317. function onPointerUp(event) {
  318. if(that.overChange){//形变中,不能相应用户操作
  319. return false;
  320. }
  321. // enableRender();
  322. if(event.touches.length==0){
  323. // that.showLables = true;
  324. // updateLables();
  325. }
  326. }
  327. //把摄像机移动的选中模型的正上方,观察点也变更为模型中心点,同时选中模型
  328. function moveMeshCenterHandle(mesh = null,noChangeColor = true){
  329. if(mesh){//如果传入了模型,则取模型
  330. let spaceId = mesh.spaceId;//空间id
  331. if(chooseMesh && spaceId == chooseMesh.spaceId){
  332. console.warn("**moveMeshCenterHandle-重复选中了***")
  333. return false;
  334. }
  335. chooseMesh = mesh;
  336. }
  337. if(!chooseMesh){
  338. console.warn("**moveMeshCenterHandle-没有数据***")
  339. return false;
  340. }
  341. that.showLables = false;//隐藏
  342. // controls.enable = false;//控制器不响应用户的操作
  343. let spaceObj = chooseMesh;//获取空间模型的相关数据
  344. // controls.panTo(spaceObj.centerX/100, camera.position.y, -spaceObj.centerY/100);
  345. let cameraNewPosition ={};
  346. let targetNewPosition ={};
  347. let oldUp = {};
  348. let newUp = {};
  349. if (isUserContorl === false) { // 非漫游状态
  350. cameraNewPosition = {
  351. x:spaceObj.centerX/100,
  352. y:camera.position.y,
  353. z:-spaceObj.centerY/100 + 0.5,//增加偏差,防止极点翻转问题?不知道为啥会有用
  354. }
  355. //新的观察点的位置-取模型的中心点坐标,加上高度,由于模型都是贴地的,所以高度设置为0
  356. targetNewPosition = {
  357. x:spaceObj.centerX/100,
  358. y:0,
  359. z:-spaceObj.centerY/100,
  360. }
  361. oldUp = camera.up;//俯视状态
  362. newUp = camera.up;
  363. // newUp = new THREE.Vector3(0,0,-1);
  364. // that.cameraLastPosition = cameraNewPosition;//记录下上一次摄像头位置
  365. // that.controlLastPosition = targetNewPosition;//记录下上一次观察点位置
  366. // if(cameraNewPosition.x<0){
  367. // cameraNewPosition.x = 0;
  368. // }
  369. }
  370. console.warn("**moveMeshCenter***",isUserContorl,spaceObj,JSON.stringify(camera.position),JSON.stringify(controls.target)
  371. ,cameraNewPosition,targetNewPosition,JSON.stringify(camera.up))
  372. tweenCamera(camera.position,controls.target,cameraNewPosition,targetNewPosition,oldUp,newUp,1000);
  373. setTimeout(()=>{
  374. that.showLables = true;
  375. // camera.up = new THREE.Vector3(0,1,0);
  376. // updateLables();
  377. },1001);//动画结束后回复原始状态
  378. }
  379. // oldP 相机原来的位置
  380. // oldT target原来的位置
  381. // newP 相机新的位置
  382. // newT target新的位置
  383. function tweenCamera(oldP, oldT, newP, newT, oldUp, newUp, time=1000) {
  384. if(JSON.stringify(oldP) == JSON.stringify(newP) && JSON.stringify(oldT) == JSON.stringify(newT)){
  385. return false;
  386. }
  387. if (!chooseMesh) {
  388. return false;
  389. }
  390. tweenCameraAnma = true;
  391. var tween = new TWEEN.Tween({
  392. x1: oldP.x, // 相机x
  393. y1: oldP.y, // 相机y
  394. z1: oldP.z, // 相机z
  395. x2: oldT.x, // 控制点的中心点x
  396. y2: oldT.y, // 控制点的中心点y
  397. z2: oldT.z, // 控制点的中心点z
  398. x3: oldUp.x, // 控制点的中心点x
  399. y3: oldUp.y, // 控制点的中心点y
  400. z3: oldUp.z // 控制点的中心点z
  401. })
  402. .to({
  403. x1: newP.x,
  404. y1: newP.y,
  405. z1: newP.z,
  406. x2: newT.x,
  407. y2: newT.y,
  408. z2: newT.z,
  409. x3: newUp.x, // up向量
  410. y3: newUp.y, // 控制点的中心点y
  411. z3: newUp.z // 控制点的中心点z
  412. }, time)
  413. .easing(TWEEN.Easing.Quadratic.InOut)
  414. .onUpdate((object)=> {
  415. camera.position.x = object.x1;
  416. camera.position.y = object.y1;
  417. camera.position.z = object.z1;
  418. let newTarget = new THREE.Vector3(object.x3,object.y3,object.z3);
  419. camera.up.copy(newTarget);
  420. camera.lookAt(object.x2,object.y2,object.z2);
  421. // controls.target.x = object.x2;
  422. // controls.target.y = object.y2;
  423. // controls.target.z = object.z2;
  424. // controls.update();
  425. // console.warn("****onUpdate**",object.x1,object.y1,object.z1,object.x2,object.y2,object.z2)
  426. }).onComplete(()=>{
  427. controls.target.x = newT.x;
  428. controls.target.y = newT.y;
  429. controls.target.z = newT.z;
  430. //修正最后的视角
  431. let up = new THREE.Vector3(newUp.x,newUp.y,newUp.z);
  432. camera.up.copy(up);
  433. camera.lookAt(controls.target.x,controls.target.y,controls.target.z);
  434. tweenCameraAnma = false;
  435. })
  436. // 开始动画
  437. tween.start();
  438. }
  439. //高度持续变化处理 time 动画持续时间 单位秒
  440. function gradientResize (time,startHeight,endHeight) {
  441. let _timeStep = 20;//单位 毫秒
  442. // let unit = window.screen.width / 750;//单位rpm 对应 px 的值
  443. // that.canvasHeight = window.screen.height - (200 * unit) + (20 * unit);
  444. let unit = window.screen.width / 750;//单位rpx 对应 px 的值
  445. let _height = startHeight - endHeight;//高度变化-单位rpx
  446. let _jisua = that.canvasHeight;
  447. let lastHeight = _jisua + (_height * unit);//动画结束时的高度值; 单位 px
  448. that.canvasHeight = lastHeight;//触发css动画
  449. let step = (_height * unit) / (time*1000 / _timeStep);//真实大小 单位px
  450. console.warn("***gradientResize***",step,lastHeight,_jisua,startHeight,endHeight)
  451. // that.showLables = false;
  452. // let canvas_webgl = document.getElementById('canvas_webgl');
  453. var tween = new TWEEN.Tween({
  454. h1: _jisua,
  455. })
  456. .to({
  457. h1: lastHeight,
  458. }, 1000)
  459. .easing(TWEEN.Easing.Linear.None)
  460. .onUpdate((object)=> {
  461. if(camera.isOrthographicCamera){//正交相机
  462. let aspect = window.screen.width / object.h1;
  463. camera.left = frustumSize * aspect / - 2;
  464. camera.right = frustumSize * aspect / 2;
  465. camera.top = frustumSize / 2;
  466. camera.bottom = frustumSize / -2;
  467. camera.updateProjectionMatrix();
  468. // that.canvasHeight = object.h1;
  469. }
  470. else if(camera.isPerspectiveCamera){//透视相机
  471. camera.aspect = window.screen.width / object.h1;
  472. camera.updateProjectionMatrix();
  473. renderer.setSize( window.screen.width, object.h1 );
  474. // that.canvasHeight = object.h1;
  475. }
  476. }).onComplete(()=>{
  477. camera.aspect = window.screen.width / that.canvasHeight;
  478. camera.updateProjectionMatrix();
  479. renderer.setSize( window.screen.width, that.canvasHeight );
  480. tweenCameraAnma = false;
  481. // that.showLables = true;
  482. // updateLables();//更新lable
  483. });
  484. // 开始动画
  485. tween.start();
  486. tweenCameraAnma = true;
  487. }
  488. //更新lables
  489. function updateLables(){
  490. if(!that.showLables){
  491. return false;
  492. }
  493. that.lableItem.forEach(lable =>{
  494. if(!that.gltfSpaces[lable.cubeIndex] || !that.gltfSpaces[lable.cubeIndex].instancedMeshIndexList){
  495. return false;
  496. }
  497. let item = that.gltfSpaces[lable.cubeIndex].instancedMeshIndexList[0];//获取地板模型的第一个geometry实例
  498. let _index = item.instancedMeshIndex;//第一个geometry实例 在 全局InstancedMesh实例的位置
  499. let instancedMesh = that.instancedSpaceMeshList[_index];//获取具体的网格实例
  500. let stratMatrix = new THREE.Matrix4();//定义一个四维矩阵
  501. instancedMesh.getMatrixAt(item.instancedAtIndex,stratMatrix);//获取当前几何体的四维矩阵到stratMatrix里面
  502. let position = new THREE.Vector3();//当前几何体的位置参数
  503. position.setFromMatrixPosition(stratMatrix);//从四维向量中提取位置信息
  504. // console.warn("***updateLables***",item.instancedAtIndex,JSON.stringify(position));
  505. position.project(camera);
  506. const x = (position.x * .5 + .5) * window.screen.width;
  507. const y = (position.y * -.5 + .5) * that.canvasHeight;
  508. lable.transform = `translate(-50%, -50%) translate(${x}px,${y}px)`;
  509. })
  510. }
  511. function stopRender () {
  512. needRender = false;
  513. }
  514. function starRender () {
  515. if(needRender==true){//如果已经在渲染中了,则不能再次开启,避免渲染过多
  516. false;
  517. }
  518. needRender = true;
  519. render();//开始渲染
  520. }
  521. function render() {
  522. if(needRender==false){
  523. return false;
  524. }
  525. TWEEN && TWEEN.update();
  526. // stats.update();
  527. //不处在动画过程中,则可以处理移动等动作
  528. if(tweenCameraAnma==false){
  529. controls.update();
  530. updateLables();//更新lable
  531. }
  532. requestId = requestAnimationFrame(render, canvas3d);
  533. renderer.render(scene, camera);//单次渲染
  534. if (that.screenshotResolve) {
  535. // if(that.isIos){//IOS手机
  536. stopRender();
  537. that.screenshotResolve()
  538. that.screenshotResolve = null;//释放Promise
  539. // }else{//安卓手机
  540. // let gl = renderer.getContext();
  541. // let frameBuffer = new THREE.Vector2();
  542. // renderer.getDrawingBufferSize(frameBuffer);
  543. // let pixelData = new Uint8Array(frameBuffer.x * frameBuffer.y * 4);
  544. // //参考 Threejs WebGLRenderer.readRenderTargetPixels
  545. // if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) === gl.FRAMEBUFFER_COMPLETE) {
  546. // gl.readPixels(0, 0, frameBuffer.x, frameBuffer.y, gl.RGBA, gl.UNSIGNED_BYTE, pixelData);
  547. // // 确保有像素,微信小程序安卓在进入子页面返回本页面后,再一次readPixels稳定无像素
  548. // if (pixelData.some(i => i !== 0)) {
  549. // stopRender();
  550. // console.warn("***screenshotResolve-pixelData***");
  551. // that.screenshotResolve([pixelData, frameBuffer.x, frameBuffer.y])
  552. // that.screenshotResolve = null;//释放Promise
  553. // frameBuffer = null;//清空内存中的数据
  554. // pixelData = null;//清空内存中的数据
  555. // }
  556. // }
  557. // }
  558. }
  559. }
  560. },
  561. onShow(){
  562. if(this.attendEvent){
  563. this.attendEvent()
  564. }
  565. },
  566. onHide(){
  567. this.clearEvent();
  568. },
  569. computed: {
  570. aiData() {
  571. return this.$store.state.aiData;
  572. },
  573. userId() {
  574. return this.$store.state.userId;
  575. },
  576. },
  577. methods: {
  578. voiceMaskChange(voiceMask){
  579. this.voiceMaskShow = voiceMask;
  580. },
  581. //黄山数据处理
  582. hushangHandle(param){
  583. let expand = {};
  584. expand.landImg = this.$route.query.landImg || '';
  585. expand.baseImg = this.$route.query.baseImg || '';
  586. expand.bgPrototypeImg = this.$route.query.bgPrototypeImg || '';
  587. expand.landNo = this.$route.query.landNo || '';//地块
  588. expand.landArea = this.$route.query.landArea || '';//地块面积
  589. expand.buildingAreaPreference = this.$route.query.buildingAreaPreference || '';//建筑面积
  590. expand.layer = this.$route.query.layer || '大平层';//层数
  591. expand.structureName = this.$route.query.structureName || '';//结构-L形等
  592. expand.landDescription = this.$route.query.landDescription || '';//地形地势
  593. expand.scenery = this.$route.query.scenery || '';//景观
  594. expand.structureDescription = this.$route.query.structureDescription || '';//空间特质-结构
  595. param.expand = JSON.stringify(expand);
  596. return param;
  597. },
  598. async submitHouse(){
  599. if(this.overChange){
  600. this.$message.warning("空间正在调整");
  601. return false
  602. }
  603. // this.$refs.myLoading.showLoading("提交中...")
  604. let shottingImg = await this.shottingAction() + "?x-oss-process=image/auto-orient,1/quality,Q_46/format,jpg";//开始截图
  605. console.warn("***shottingImg***",shottingImg);
  606. let userId = this.userId ? this.userId : '';
  607. let param = {
  608. "brandId": $config.brandId,
  609. "houseId": this.curHouseObj.houseId,
  610. "userId": userId,
  611. "floot": this.curHouseObj.houseFloor,
  612. "spaceName": this.curHouseName ,
  613. "spaceStructure": this.curHouseType,
  614. "curFloor":this.curHouseFloor,
  615. // "layoutImgCustomized": shottingImg,
  616. // "style": "",
  617. layoutStruct:[],
  618. }
  619. //处理每一个楼层
  620. this.curLayoutStruct.forEach((layoutStruct,index)=>{
  621. let houseData = {
  622. "layoutId": layoutStruct.id,
  623. "layoutName": layoutStruct.name,
  624. "layoutArea": layoutStruct.houseArea,
  625. "floor": layoutStruct.houseFloor,
  626. "layoutImgCustomized": layoutStruct.houseFloor == this.curHouseFloor ? shottingImg:'',
  627. "style": "",
  628. "houseJson": []
  629. }
  630. let spaceList = JSON.parse(layoutStruct.houseJson);
  631. let styleList = [];
  632. //遍历当前户型下的每一个空间
  633. spaceList.forEach((item)=>{
  634. let space = JSON.parse(JSON.stringify(item));
  635. //找到当前空间对象对应的AI数据对象
  636. let AISpace = null;
  637. AISpace = this.aiData && this.aiData.find(it=>{
  638. return it.houseFloor == layoutStruct.houseFloor && it.spaceId == space.spaceId
  639. });
  640. if(AISpace){
  641. let list = AISpace.aiImagesList.filter(it=>it.checked==true);//过滤选中的
  642. list.forEach(it=>{
  643. styleList.push(it.aiStyleName);
  644. })
  645. list = list.map(it=>{
  646. return it.image
  647. })
  648. space.hardboundEffect = list;
  649. console.warn("submitHouse: ", list,space);
  650. }
  651. let wallList = this.wallList.find(it=>it.id==space.wallId);
  652. if(wallList){//找到当前空间的墙体数据
  653. space.wallList = JSON.stringify(wallList);
  654. }
  655. houseData.houseJson.push(space)
  656. })
  657. //寻找styleList里面出现最多次数的风格
  658. if(styleList && styleList.length>0){
  659. let maxEle = styleList[0];
  660. let maxNum = 1;
  661. styleList.reduce((p,k)=>{
  662. p[k] ? p[k]++ : p[k]=1;
  663. if(p[k] > maxNum){
  664. maxEle = k;
  665. maxNum ++
  666. }
  667. return p;
  668. },{});
  669. houseData.style = maxEle;
  670. }
  671. param.layoutStruct.push(houseData)
  672. })
  673. param = this.hushangHandle(param)
  674. console.warn("submitHouse-param: ", param);
  675. let trackparam = {
  676. type: 'CLK', //埋点类型
  677. clkId: 'clk_2cmina_23080409', //点击ID
  678. clkName: 'submit_clk', //点击前往的页面名称
  679. clkParams: {
  680. locusName: "数据提交",
  681. postAIData:this.aiData,
  682. }
  683. };
  684. util.trackRequest(trackparam);
  685. let res = await requestConfig("saveCustomizedRecord", param);
  686. if(res && res.success && res.single){//提交成功
  687. let data = {
  688. houseId:this.houseId,
  689. id:res.single,
  690. }
  691. router.push({
  692. name: "webgl_rxdz_customize",
  693. query:data
  694. });
  695. }
  696. },
  697. enableRender(){
  698. this.enableRenderHandle();
  699. },
  700. /**
  701. * 选中墙体触发
  702. */
  703. selectWall(wallIndex){
  704. console.log("index",wallIndex)
  705. if(this.chooseWallMeshColor){
  706. for (let index = 0; index < this.curWallArr.length; index++) {
  707. const element = this.curWallArr[index];
  708. const cube = element.obj;
  709. this.chooseWallMeshColor.convertSRGBToLinear(); // 将颜色值转换为线性颜色值
  710. if(cube && cube.children[0].children[0] && cube.children[0].children[0].material){
  711. cube.children[0].children[0].material.color = this.chooseWallMeshColor;//修改选中模型的颜色-高亮显示 当前选中的模型
  712. }else{//新版逻辑
  713. // element.instancedMeshIndexList.forEach(item=>{
  714. // let _index = item.instancedMeshIndex;
  715. // let instancedMesh = this.instancedMeshList[_index];//网格实例
  716. // instancedMesh.instanceColor.needsUpdate = true;//打开颜色修改开关,不开,颜色是不能修改额
  717. // instancedMesh.setColorAt(item.instancedAtIndex, this.chooseWallMeshColor);//修改这个几何体的颜色
  718. // })
  719. }
  720. }
  721. }
  722. switch (wallIndex) {
  723. case 1:
  724. this.curWallDirection = "N";
  725. break;
  726. case 2:
  727. this.curWallDirection = "S";
  728. break;
  729. case 3:
  730. this.curWallDirection = "W";
  731. break;
  732. case 4:
  733. this.curWallDirection = "E";
  734. break;
  735. }
  736. this.selectedWall(this.curWallDirection)
  737. this.curWallArr = [];
  738. if(wallIndex!=0){
  739. const wallMoveValues = this.curSpaceObj.wallMoveValue;
  740. console.log
  741. const values = JSON.parse(wallMoveValues);
  742. if(this.curWallValue == 150){
  743. this.curWallValue = values[wallIndex-1]
  744. }else{
  745. let wallIndex = 0
  746. switch (this.curWallDirection) {
  747. case "N":
  748. wallIndex = 0;
  749. values[wallIndex] = this.curWallValue;
  750. values[1] = this.curWallValue;
  751. break;
  752. case "S":
  753. wallIndex = 1;
  754. values[wallIndex] = this.curWallValue;
  755. values[0] = this.curWallValue;
  756. break;
  757. case "W":
  758. wallIndex = 2;
  759. values[wallIndex] = this.curWallValue;
  760. values[3] = this.curWallValue;
  761. break;
  762. case "E":
  763. wallIndex = 3;
  764. values[wallIndex] = this.curWallValue;
  765. values[2] = this.curWallValue;
  766. break;
  767. }
  768. }
  769. this.curSpaceObj.wallMoveValue = JSON.stringify(values)
  770. console.log("墙体可移动数据:", this.curSpaceObj.wallMoveValue, this.spaceList);
  771. const wallStatus = this.curSpaceObj.wallStatus || "[false,false,false,false]"
  772. const status = JSON.parse(wallStatus);
  773. this.curWallHidden = status[wallIndex-1]
  774. console.log("当前墙面数据:", wallStatus , status, wallIndex);
  775. const curSpaceGltfWall = this.gltfWalls.filter((item)=>{
  776. return this.curSpaceObj.spaceId == item.spaceId && item.wallDirection == this.curWallDirection
  777. })
  778. if(curSpaceGltfWall.length != 0){
  779. this.curWallArr.push(...curSpaceGltfWall);
  780. }else{
  781. let rightWallD = "";
  782. switch (wallIndex-1) {
  783. case 0:
  784. rightWallD= "S";
  785. break;
  786. case 1:
  787. rightWallD= "N";
  788. break;
  789. case 2:
  790. rightWallD= "E";
  791. break;
  792. case 3:
  793. rightWallD= "W";
  794. break;
  795. }
  796. for (let index = 0; index < this.leftSpaces.length; index++) {
  797. const element = this.leftSpaces[index];
  798. const gltfWall = this.gltfWalls.filter((item)=>{
  799. return element.spaceId == item.spaceId && item.wallDirection == this.curWallDirection
  800. })
  801. if(gltfWall){
  802. this.curWallArr.push(...gltfWall);
  803. }
  804. }
  805. for (let index = 0; index < this.rightSpaces.length; index++) {
  806. const element = this.rightSpaces[index];
  807. const gltfWall = this.gltfWalls.filter((item)=>{
  808. return element.spaceId == item.spaceId && item.wallDirection == rightWallD;
  809. })
  810. if(gltfWall){
  811. this.curWallArr.push(...gltfWall);
  812. }
  813. }
  814. }
  815. for (let index = 0; index < this.curWallArr.length; index++) {
  816. const element = this.curWallArr[index];
  817. const cube = element.obj;
  818. if(cube && cube.children[0].children[0] && cube.children[0].children[0].material){
  819. this.chooseWallMeshColor = cube.children[0].children[0].material.color.clone();
  820. let color = new THREE.Color(0xff0000); // 使用sRGB颜色值
  821. color.convertSRGBToLinear(); // 将颜色值转换为线性颜色值
  822. cube.children[0].children[0].material.color = color;//修改选中模型的颜色-高亮显示 当前选中的模型
  823. }else{//新版逻辑
  824. // element.instancedMeshIndexList.forEach(item=>{
  825. // let _index = item.instancedMeshIndex;
  826. // let instancedMesh = this.instancedMeshList[_index];//网格实例
  827. // this.chooseWallMeshColor = instancedMesh.material.color.clone();;
  828. // let color = new THREE.Color(0xff0000); // 使用sRGB颜色值
  829. // color.convertSRGBToLinear(); // 将颜色值转换为线性颜色值
  830. // instancedMesh.instanceColor.needsUpdate = true;//打开颜色修改开关,不开,颜色是不能修改额
  831. // instancedMesh.setColorAt(item.instancedAtIndex, color);//修改这个几何体的颜色
  832. // })
  833. }
  834. }
  835. }
  836. },
  837. //具体空间面积变化-拖动产生的
  838. //data = {
  839. // spaceId:245,
  840. // area:12, //正负值 单位平方米
  841. // }
  842. curSpaceChange(data){
  843. console.warn("***空间面积变化***",this.overChange,data);
  844. // let changArea = data.isZoomIn ? parseFloat(data.area.toFixed(2)) : -parseFloat(data.area.toFixed(2));
  845. // this.changeArea = changArea;//当次变化的面积,有正负值
  846. // this.sumArea = parseFloat((this.sumArea + changArea).toFixed(2));
  847. this.overChange = true;//变形开始 防止在形变结束前,再次形变
  848. this.currentChangeSpaceId = data.spaceId
  849. this.changCurSpaceArea(data);
  850. let space = this.spaceList.find(it=>it.spaceId==this.currentChangeSpaceId);
  851. this.moveMeshCenter(space);
  852. },
  853. // 空间移动,
  854. changCurSpaceArea(data){
  855. console.log("当前户型的核心点", this.curHouseObj.houseCore, this.overChange);
  856. const houseCore = this.curHouseObj.houseCore.split(',');
  857. const coreX = houseCore[0] | 0
  858. const coreY = houseCore[1] | 0
  859. // 根据核心点计算空间所在象限
  860. this.spaces1 = [];
  861. this.spaces2 = [];
  862. this.spaces3 = [];
  863. this.spaces4 = [];
  864. let curSpace = null;
  865. for (let index = 0; index < this.spaceList.length; index++) {
  866. const element = this.spaceList[index];
  867. if(element.centerX > coreX){ // 2 3象限
  868. if(element.centerY > coreY){ // 2象限
  869. console.log(`象限2 ${element}`);
  870. element.quadrant = 2;
  871. this.spaces2.push(element)
  872. }else{// 3象限
  873. console.log(`象限3 ${element}`);
  874. element.quadrant = 3;
  875. this.spaces3.push(element)
  876. }
  877. }else{// 1 4象限
  878. if(element.centerY > coreY){ // 1象限
  879. console.log(`象限1 ${element}`);
  880. element.quadrant = 1;
  881. this.spaces1.push(element)
  882. }else{ // 4象限
  883. console.log(`象限4 ${element}`);
  884. element.quadrant = 4;
  885. this.spaces4.push(element)
  886. }
  887. }
  888. if(element.spaceId == data.spaceId){
  889. curSpace = element;
  890. }
  891. }
  892. console.log("当前space所在象限",data.spaceId, curSpace.spaceId , curSpace.quadrant);
  893. console.log("象限", this.spaces1, this.spaces2, this.spaces3, this.spaces4);
  894. this.calculateSpaceData(curSpace, data)
  895. },
  896. calculateSpaceData(curSpace, data){
  897. let that = this;
  898. this.curSpaceObj = curSpace;
  899. // 计算宽高移动数值
  900. const changeArea = data.area;
  901. const isZoomIn = data.isZoomIn;
  902. const oldArea = (curSpace.spaceWidth / 100) * (curSpace.spaceHeight / 100);
  903. const newArea = oldArea + changeArea * (data.isZoomIn ? 1 : -1);
  904. const sizeScale = Math.sqrt(newArea/oldArea) ;
  905. // 新的宽度
  906. let newWidth = curSpace.spaceWidth * sizeScale;
  907. if(newWidth < curSpace.spaceWidthMin){
  908. newWidth = curSpace.spaceWidthMin
  909. }
  910. if(newWidth > curSpace.spaceWidthMax){
  911. newWidth = curSpace.spaceWidthMax
  912. }
  913. // 新的高度
  914. let newHeight = newArea * 10000 / newWidth;
  915. if(newHeight < curSpace.spaceHeightMin){
  916. newHeight = curSpace.spaceHeightMin
  917. }
  918. if(newHeight > curSpace.spaceHeightMax){
  919. newHeight = curSpace.spaceHeightMax
  920. }
  921. newWidth = newArea * 10000 / newHeight;
  922. let changeWidth = Math.abs(newWidth - curSpace.spaceWidth)
  923. let changeHeight = Math.abs(newHeight - curSpace.spaceHeight)
  924. console.log("变化的尺寸", changeWidth, changeHeight, newWidth, newHeight, curSpace.spaceWidth, curSpace.spaceHeight);
  925. if(curSpace.quadrant == 1){
  926. // 默认往南 往西移动
  927. this.moveSpace(curSpace, 1, 3, isZoomIn, newArea, newWidth, newHeight, changeWidth, changeHeight)
  928. }
  929. if(curSpace.quadrant == 2){
  930. // 默认往南 往西移动
  931. this.moveSpace(curSpace, 1, 4, isZoomIn, newArea, newWidth, newHeight, changeWidth, changeHeight)
  932. }
  933. if(curSpace.quadrant == 3){
  934. // this.selectWall(4);
  935. // // // 移动墙面
  936. // this.moveSpaceWall(this.curWallDirection, isZoomIn, changeWidth);
  937. // 默认往南 往东移动
  938. this.moveSpace(curSpace, 2, 4, isZoomIn, newArea, newWidth, newHeight, changeWidth, changeHeight)
  939. }
  940. if(curSpace.quadrant == 4){
  941. // 默认往南 往西移动
  942. this.moveSpace(curSpace, 2, 3, isZoomIn, newArea, newWidth, newHeight, changeWidth, changeHeight)
  943. }
  944. setTimeout(() => {
  945. // that.updataPageData();
  946. that.overChange = false;
  947. that.callBackFun && that.callBackFun(true);
  948. // that.calculateLayoutModelSize(); //重新计算家具位置
  949. that.updateWallModels(); // 替换墙体模型
  950. that.changeLayoutModel(); // 改变空间模型
  951. // that.changeLayoutModelState(true); // 显示家具模型
  952. }, 4200);
  953. },
  954. moveSpace(curSpace, directionIndex, directionIndex01, isZoomIn, newArea, newWidth, newHeight, changeWidth, changeHeight){
  955. let that = this;
  956. const wallLock = this.currWallLock(directionIndex, curSpace); //南边
  957. const wallLock01 = this.currWallLock(directionIndex01, curSpace); //东边
  958. console.log("移动空间", wallLock, wallLock01)
  959. if(wallLock ==-1 && wallLock01 == -1){
  960. return this.$message.warning("空间尺寸已锁定");
  961. }
  962. let changeValue = changeHeight;
  963. if(wallLock == -1){
  964. if(wallLock01 == 0){
  965. directionIndex01 = directionIndex01 == 4 ? 3 : 4; // 往西移动
  966. }
  967. // 南北锁死,重新计算移动的方向
  968. newWidth = newArea / (curSpace.spaceHeight / 100) * 100
  969. changeWidth = newWidth / 100 - curSpace.spaceWidth / 100;
  970. changeWidth = Math.abs(changeWidth * 100);
  971. directionIndex = directionIndex01; // 往东移动
  972. changeValue = changeWidth;
  973. console.log("高度锁死不能拉伸, 宽度变化1",newWidth, directionIndex,curSpace.spaceWidth, curSpace.spaceHeight, changeValue);
  974. that.selectWall(directionIndex);
  975. let checkResult = this.checkRightSpace(!isZoomIn, changeWidth, false, curSpace)
  976. if(!checkResult.result){
  977. changeWidth = checkResult.newValue
  978. }
  979. console.log("宽度达到极限值结果++++++++++++++", checkResult, changeWidth)
  980. that.moveSpaceWall(that.curWallDirection, isZoomIn, changeWidth);
  981. // that.autoCreateWall(directionIndex, curSpace)
  982. return;
  983. }else{
  984. if(wallLock == 0){
  985. directionIndex = directionIndex == 2 ? 1 : 2; // 往北边移动
  986. }
  987. if(wallLock01 == -1){
  988. // 东西锁死,重新计算移动方向
  989. newHeight = newArea / (curSpace.spaceWidth / 100) * 100
  990. changeHeight = newHeight / 100 - curSpace.spaceHeight / 100;
  991. changeHeight = Math.abs(changeHeight * 100);
  992. changeValue = changeHeight;
  993. that.selectWall(directionIndex);
  994. that.moveSpaceWall(that.curWallDirection, isZoomIn, changeValue);
  995. // 自动补墙逻辑
  996. // that.autoCreateWall(directionIndex, curSpace);
  997. return
  998. }
  999. if(wallLock01 == 0){
  1000. directionIndex01 = directionIndex01 == 4 ? 3 : 4; // 往西移动
  1001. }
  1002. console.log("要变化的宽度", newWidth, newHeight)
  1003. // 目标宽度
  1004. if(newHeight > curSpace.spaceHeightMax){
  1005. newHeight = curSpace.spaceHeightMax;
  1006. changeHeight = Math.abs(newHeight - curSpace.spaceHeight)
  1007. // 重新计算宽度值
  1008. newWidth = (newArea / (newHeight / 100)) * 100
  1009. changeWidth = (newWidth / 100 - curSpace.spaceWidth / 100) * 100;
  1010. console.log("高度达到最大值,重新计算宽度",newWidth, newHeight, changeWidth, changeHeight)
  1011. }
  1012. if(newHeight < curSpace.spaceHeightMin){
  1013. newHeight = curSpace.spaceHeightMin;
  1014. changeHeight = Math.abs(newHeight - curSpace.spaceHeight)
  1015. // 重新计算宽度值
  1016. newWidth = (newArea / (newHeight / 100)) * 100
  1017. changeWidth = Math.abs((newWidth / 100 - curSpace.spaceWidth / 100) * 100);
  1018. console.log("高度达到最小值,重新计算宽度",newWidth, newHeight, changeWidth, changeHeight)
  1019. }
  1020. if(newWidth > curSpace.spaceWidthMax){
  1021. newWidth = curSpace.spaceWidthMax;
  1022. changeWidth = Math.abs(newWidth - curSpace.spaceWidth)
  1023. // 重新计算宽度值
  1024. newHeight = (newArea / (newWidth / 100)) * 100
  1025. changeHeight = (newHeight / 100 - curSpace.spaceHeight / 100) * 100;
  1026. console.log("宽度达到最大值,重新计算高度",newWidth, newHeight, changeWidth, changeHeight)
  1027. }
  1028. if(newWidth < curSpace.spaceWidthMin){
  1029. newWidth = curSpace.spaceWidthMin;
  1030. changeWidth = Math.abs(newWidth - curSpace.spaceWidth)
  1031. // 重新计算宽度值
  1032. newHeight = (newArea / (newWidth / 100)) * 100
  1033. changeHeight = Math.abs((newHeight / 100 - curSpace.spaceHeight / 100) * 100);
  1034. console.log("宽度达到最小值,重新计算高度",newWidth, newHeight, changeWidth, changeHeight)
  1035. }
  1036. // if(!checkWidth || !checkHeight){
  1037. // return
  1038. // }
  1039. if(changeHeight > 0){
  1040. that.changeSpaces = [];
  1041. that.selectWall(directionIndex);
  1042. let checkResult = this.checkRightSpace(!isZoomIn, changeHeight, true, curSpace)
  1043. console.log("高度达到极限值结果++++++++++++++", checkResult, changeHeight)
  1044. that.moveSpaceWall(that.curWallDirection, isZoomIn, changeHeight);
  1045. // 自动补墙逻辑
  1046. // that.autoCreateWall(directionIndex, curSpace)
  1047. }
  1048. let timeout = 0
  1049. if(changeWidth > 0 && changeHeight > 0 ){
  1050. timeout = 2100
  1051. }
  1052. console.log("改变尺寸",changeWidth, changeHeight,newWidth, newHeight, timeout, directionIndex, directionIndex01, wallLock, wallLock01)
  1053. if(changeWidth > 0){
  1054. setTimeout(() => {
  1055. that.changeSpaces = [];
  1056. // // 选中墙面
  1057. that.selectWall(directionIndex01);
  1058. // 计算
  1059. let checkResult = this.checkRightSpace(!isZoomIn, changeWidth, false, curSpace)
  1060. if(!checkResult.result){
  1061. changeWidth = checkResult.newValue
  1062. }
  1063. console.log("宽度达到极限值结果++++++++++++++", checkResult, changeWidth)
  1064. // 移动墙面
  1065. that.moveSpaceWall(that.curWallDirection, isZoomIn, changeWidth);
  1066. // 自动补墙逻辑
  1067. // that.autoCreateWall(directionIndex01, curSpace)
  1068. }, timeout);
  1069. }
  1070. }
  1071. },
  1072. currWallLock(direction, curSpace){
  1073. let curDirection = ""
  1074. let faceDirection = ""
  1075. switch (direction) {
  1076. case 1:
  1077. curDirection = "N";
  1078. faceDirection = "S";
  1079. break;
  1080. case 2:
  1081. curDirection = "S";
  1082. faceDirection = "N";
  1083. break;
  1084. case 3:
  1085. curDirection = "W";
  1086. faceDirection = "E";
  1087. break;
  1088. case 4:
  1089. curDirection = "E";
  1090. faceDirection = "W";
  1091. break;
  1092. }
  1093. const wallInfo = this.wallList.find((item)=>{
  1094. let element = JSON.parse(item.wallJson);
  1095. return element.spaceId == curSpace.spaceId;
  1096. })
  1097. let walls = JSON.parse(wallInfo.wallJson).wallData;
  1098. const wall = walls.find((item)=>{ // 当前墙面锁定
  1099. return item.wallDirection==curDirection && item.isLocked=="true"
  1100. })
  1101. const faceWall = walls.find((item)=>{ // 对面墙面锁定
  1102. return item.wallDirection==faceDirection && item.isLocked=="true"
  1103. })
  1104. if(wall){
  1105. if(faceWall){
  1106. return -1 // 当前对面同时锁定
  1107. }
  1108. return 0 // 当前锁定
  1109. }else{
  1110. return 1 // 不锁定,可以移动
  1111. }
  1112. },
  1113. // 排查关联空间是否达到极限值
  1114. checkRightSpace(isZoomIn, changeValue, isNS, curSpace){
  1115. if(changeValue == 0){
  1116. return;
  1117. }
  1118. let n = isZoomIn?1:-1;
  1119. let l = isZoomIn?-1:1;
  1120. let result = true;
  1121. let space = null;
  1122. let newValue = changeValue;
  1123. console.log("排查空间",isZoomIn, changeValue,isNS, this.leftSpaces, this.rightSpaces);
  1124. for (let index = 0; index < this.leftSpaces.length; index++) {
  1125. const element = this.leftSpaces[index];
  1126. // 过滤掉花园判断
  1127. if(element.spaceType == 14 || element.spaceId == curSpace.spaceId){
  1128. continue;
  1129. }
  1130. let newWidth = element.spaceWidth + l * changeValue;
  1131. let newHeight = element.spaceHeight + l * changeValue;
  1132. if(isNS){
  1133. if( newHeight > element.spaceHeightMax || newHeight < element.spaceHeightMin){
  1134. result = false;
  1135. space = element;
  1136. break;
  1137. }
  1138. }else{
  1139. if(newWidth > element.spaceWidthMax || newWidth < element.spaceWidthMin){
  1140. result = false;
  1141. space = element;
  1142. break;
  1143. }
  1144. }
  1145. }
  1146. for (let index = 0; index < this.rightSpaces.length; index++) {
  1147. const element = this.rightSpaces[index];
  1148. // 过滤掉花园判断
  1149. if(element.spaceType == 14){
  1150. console.log("空间排查跳出")
  1151. continue;
  1152. }
  1153. let newWidth = element.spaceWidth + n * changeValue;
  1154. let newHeight = element.spaceHeight + n * changeValue;
  1155. console.log("关联右空间排查", isZoomIn, isNS, changeValue, newWidth,element.spaceWidthMax, element.spaceWidthMin)
  1156. console.log("空间排查-0------", changeValue, 1000, newWidth, newValue)
  1157. if(isNS){
  1158. if( newHeight > element.spaceHeightMax || newHeight < element.spaceHeightMin){
  1159. result = false;
  1160. space = element;
  1161. const newHeightValue = newHeight > element.spaceHeightMax ? element.spaceHeightMax : element.spaceHeightMin;
  1162. newHeight = newHeightValue - newHeight;
  1163. console.log("空间排查-11------", changeValue, 1000, newHeight, newValue)
  1164. const newChangeValue = changeValue - newHeight;
  1165. if(newValue > newChangeValue){
  1166. newValue = newChangeValue;
  1167. }
  1168. break;
  1169. }
  1170. }else{
  1171. if(newWidth > element.spaceWidthMax || newWidth < element.spaceWidthMin){
  1172. result = false;
  1173. space = element;
  1174. const newWidthValue = newWidth > element.spaceWidthMax ? element.spaceWidthMax : element.spaceWidthMin
  1175. newWidth = newWidthValue - newWidth;
  1176. console.log("空间排查-12------", changeValue, 1000, newWidth, newValue)
  1177. const newChangeValue = changeValue - newWidth;
  1178. if(newValue > newChangeValue){
  1179. newValue = newChangeValue;
  1180. }
  1181. console.log("空间排查-2------", changeValue, newChangeValue, newWidth, newValue)
  1182. break;
  1183. }
  1184. }
  1185. }
  1186. if(!result){
  1187. this.$message.warning(`关联空间[${ space && space.spaceName || ''}]达到极限值`);
  1188. }
  1189. return {"result":result,"newValue":newValue}
  1190. },
  1191. checkSpaceSize(isZoomIn, changeWidth, changeHeight){
  1192. console.log("检查尺寸", isZoomIn, changeWidth, changeHeight, this.leftSpaces, this.rightSpaces)
  1193. for (let index = 0; index < this.leftSpaces.length; index++) {
  1194. const element = this.leftSpaces[index];
  1195. if(isZoomIn){
  1196. if(element.spaceWidth + changeWidth > element.spaceWidthMax || element.spaceHeight + changeHeight > element.spaceHeightMax){
  1197. console.log("++++++++++移动空间达到极大值1", element.spaceId, element.spaceWidth + changeWidth > element.spaceWidthMax, element.spaceHeight + changeHeight > element.spaceHeightMax)
  1198. console.log("++++++++++移动空间达到极大值宽", element.spaceWidth, changeWidth, element.spaceWidthMax)
  1199. console.log("++++++++++移动空间达到极大值高", element.spaceHeight, changeHeight, element.spaceHeightMax)
  1200. return false;
  1201. }
  1202. }else{
  1203. if(element.spaceWidth - changeWidth < element.spaceWidthMin || element.spaceHeight - changeHeight < element.spaceHeightMin){
  1204. console.log("++++++++++移动空间达到极小值2", element.spaceId)
  1205. console.log("++++++++++移动空间达到极大值宽", element.spaceWidth, changeWidth, element.spaceWidthMin)
  1206. console.log("++++++++++移动空间达到极大值高", element.spaceHeight, changeHeight, element.spaceHeightMin)
  1207. return false;
  1208. }
  1209. }
  1210. }
  1211. for (let index = 0; index < this.rightSpaces.length; index++) {
  1212. const element = this.rightSpaces[index];
  1213. if(!isZoomIn){
  1214. if(element.spaceWidth - changeWidth < element.spaceWidthMin || element.spaceHeight - changeHeight < element.spaceHeightMin){
  1215. console.log("++++++++++其他空间达到极小值4", element.spaceId)
  1216. console.log("++++++++++移动空间达到极大值宽", element.spaceWidth, changeWidth, element.spaceWidthMin)
  1217. console.log("++++++++++移动空间达到极大值高", element.spaceHeight, changeHeight, element.spaceHeightMin)
  1218. return false;
  1219. }
  1220. }else{
  1221. if(element.spaceWidth + changeWidth > element.spaceWidthMax || element.spaceHeight + changeHeight > element.spaceHeightMax){
  1222. console.log("++++++++++其他空间达到极大值3", element.spaceId)
  1223. console.log("++++++++++移动空间达到极大值宽", element.spaceWidth, changeWidth, element.spaceWidthMax)
  1224. console.log("++++++++++移动空间达到极大值高", element.spaceHeight, changeHeight, element.spaceHeightMax)
  1225. return false;
  1226. }
  1227. }
  1228. }
  1229. return true
  1230. },
  1231. // 新版本空间移动计算
  1232. changeCurSpaceSize(curSpace, changeArea, isZoomIn){
  1233. // 计算当前空间的变化
  1234. // 1.原先面积
  1235. const oldArea = (curSpace.spaceWidth / 100) * (curSpace.spaceHeight / 100);
  1236. const newArea = oldArea + changeArea * isZoomIn;
  1237. const sizeScale = Math.sqrt(newArea/oldArea) ;
  1238. console.log(`新面积:${newArea} 老面积:${oldArea}缩放比例:${sizeScale} 改变的面积:${changeArea} 是否放大:${isZoomIn} 中心点:${curSpace.centerX} ${curSpace.centerX}`);
  1239. console.log(`改变前:尺寸:${curSpace.spaceWidth} ${curSpace.spaceHeight} 中心点:${curSpace.centerX} ${curSpace.centerY}`);
  1240. curSpace.toScaleX = curSpace.spaceWidth * sizeScale / 300 ;
  1241. curSpace.toScaleZ = curSpace.spaceHeight * sizeScale / 300 ;
  1242. if(this.minspace1 && this.minspace1.spaceId == curSpace.spaceId){
  1243. curSpace.toPx = (curSpace.spaceWidth * sizeScale - curSpace.spaceWidth) / 2 / 100 * -1;
  1244. curSpace.toPz = (curSpace.spaceHeight * sizeScale - curSpace.spaceHeight) / 2 / 100 * -1;
  1245. console.log("XXXXXXXX-计算空间变化信息1", curSpace.toScaleX, curSpace.toScaleZ, curSpace.toPx, curSpace.toPz);
  1246. }else if(this.minspace2 && this.minspace2.spaceId == curSpace.spaceId){
  1247. curSpace.toPx = (curSpace.spaceWidth * sizeScale - curSpace.spaceWidth) / 2 / 100;
  1248. curSpace.toPz = (curSpace.spaceHeight * sizeScale - curSpace.spaceHeight) / 2 / 100 * -1;
  1249. console.log("XXXXXXXX-计算空间变化信息2", curSpace.toScaleX, curSpace.toScaleZ, curSpace.toPx, curSpace.toPz);
  1250. }else if(this.minspace3 && this.minspace3.spaceId == curSpace.spaceId){
  1251. curSpace.toPx = (curSpace.spaceWidth * sizeScale - curSpace.spaceWidth) / 2 / 100;
  1252. curSpace.toPz = (curSpace.spaceHeight * sizeScale - curSpace.spaceHeight) / 2 / 100;
  1253. console.log("XXXXXXXX-计算空间变化信息3", curSpace.toScaleX, curSpace.toScaleZ, curSpace.toPx, curSpace.toPz);
  1254. }else if(this.minspace4 && this.minspace4.spaceId == curSpace.spaceId){
  1255. curSpace.toPx = (curSpace.spaceWidth * sizeScale - curSpace.spaceWidth) / 2 / 100 * -1;
  1256. curSpace.toPz = (curSpace.spaceHeight * sizeScale - curSpace.spaceHeight) / 2 / 100;
  1257. console.log("XXXXXXXX-计算空间变化信息4", curSpace.toScaleX, curSpace.toScaleZ, curSpace.toPx, curSpace.toPz);
  1258. }else{
  1259. return
  1260. }
  1261. // 更新数据:
  1262. curSpace.spaceWidth = curSpace.spaceWidth * sizeScale;
  1263. curSpace.spaceHeight = curSpace.spaceHeight * sizeScale;
  1264. curSpace.centerX = curSpace.centerX + curSpace.toPx * 100
  1265. curSpace.centerY = curSpace.centerY + curSpace.toPz * 100
  1266. const spaceIndex = this.spaceList.findIndex((item)=>{
  1267. return item.spaceId == curSpace.spaceId;
  1268. })
  1269. if(spaceIndex!=-1){
  1270. this.spaceList[spaceIndex] = curSpace;
  1271. }
  1272. console.log(`改变后:尺寸:${curSpace.spaceWidth} ${curSpace.spaceHeight} 中心点:${curSpace.centerX} ${curSpace.centerY} `, curSpace.toPx, curSpace.toPz);
  1273. },
  1274. findxxSpace(manSpace,changeArea, xiangxian, isZoomIn){
  1275. if(xiangxian == 1){
  1276. const spaceE = this.spaces1.find((item)=>{
  1277. return item.spaceId == manSpace.eastId;
  1278. })
  1279. const spaceS = this.spaces1.find((item)=>{
  1280. return item.spaceId == manSpace.southId;
  1281. })
  1282. const oldArea = (manSpace.spaceWidth / 100) * (manSpace.spaceHeight / 100);
  1283. const newArea = oldArea + changeArea * isZoomIn;
  1284. const sizeScale = Math.sqrt(newArea/oldArea) ;
  1285. manSpace.toScaleX = manSpace.spaceWidth * sizeScale / 300 ;
  1286. manSpace.toScaleZ = manSpace.spaceHeight * sizeScale / 300 ;
  1287. if(spaceE){
  1288. manSpace.toPx = (manSpace.spaceWidth * sizeScale - manSpace.spaceWidth) / 2 / 100 * -1 + spaceE.toPx * 2;
  1289. console.log("XXXXXXXX东边有空间", manSpace.spaceId, spaceE.toPx)
  1290. }else{
  1291. manSpace.toPx = (manSpace.spaceWidth * sizeScale - manSpace.spaceWidth) / 2 / 100 * -1;
  1292. console.log("XXXXXXXX东边没空间", manSpace.spaceId)
  1293. }
  1294. if(spaceS){
  1295. manSpace.toPz = (manSpace.spaceHeight * sizeScale - manSpace.spaceHeight) / 2 / 100 * -1 + spaceS.toPz * 2;
  1296. console.log("XXXXXXXX南边有空间", manSpace.spaceId, spaceS.toPz)
  1297. }else{
  1298. manSpace.toPz = (manSpace.spaceHeight * sizeScale - manSpace.spaceHeight) / 2 / 100 * -1;
  1299. console.log("XXXXXXXX南边没空间", manSpace.spaceId)
  1300. }
  1301. console.log("XXXXXXXX-前象限1的其他空间", manSpace.spaceId, manSpace.spaceWidth, manSpace.spaceHeight, manSpace.centerX, manSpace.centerY, manSpace.toPx);
  1302. manSpace.spaceWidth = manSpace.spaceWidth * sizeScale;
  1303. manSpace.spaceHeight = manSpace.spaceHeight * sizeScale;
  1304. manSpace.centerX += manSpace.toPx * 100
  1305. manSpace.centerY += manSpace.toPz * 100
  1306. console.log("XXXXXXXX-后象限1的其他空间", manSpace.spaceId, manSpace.spaceWidth, manSpace.spaceHeight, manSpace.centerX, manSpace.centerY);
  1307. const spaceIndex = this.spaceList.findIndex((item)=>{
  1308. return item.spaceId == manSpace.spaceId;
  1309. })
  1310. if(spaceIndex!=-1){
  1311. this.spaceList[spaceIndex] = manSpace;
  1312. }
  1313. const spacesIndex = this.spaces1.findIndex((item)=>{
  1314. return item.spaceId == manSpace.spaceId;
  1315. })
  1316. if(spacesIndex!=-1){
  1317. this.spaces1[spacesIndex] = manSpace;
  1318. }
  1319. }
  1320. if(xiangxian == 2){
  1321. const spaceW = this.spaces2.find((item)=>{
  1322. return item.spaceId == manSpace.westId;
  1323. })
  1324. const spaceS = this.spaces2.find((item)=>{
  1325. return item.spaceId == manSpace.southId;
  1326. })
  1327. const oldArea = (manSpace.spaceWidth / 100) * (manSpace.spaceHeight / 100);
  1328. const newArea = oldArea + changeArea * isZoomIn;
  1329. const sizeScale = Math.sqrt(newArea/oldArea) ;
  1330. manSpace.toScaleX = manSpace.spaceWidth * sizeScale / 300 ;
  1331. manSpace.toScaleZ = manSpace.spaceHeight * sizeScale / 300 ;
  1332. if(spaceW){
  1333. manSpace.toPx = (manSpace.spaceWidth * sizeScale - manSpace.spaceWidth) / 2 / 100 + spaceW.toPx * 2;
  1334. console.log("XXXXXXXX西边有空间", manSpace.spaceId, spaceW.toPx)
  1335. }else{
  1336. manSpace.toPx = (manSpace.spaceWidth * sizeScale - manSpace.spaceWidth) / 2 / 100;
  1337. console.log("XXXXXXXX西边没空间", manSpace.spaceId)
  1338. }
  1339. if(spaceS){
  1340. manSpace.toPz = (manSpace.spaceHeight * sizeScale - manSpace.spaceHeight) / 2 / 100 * -1 + spaceS.toPz * 2;
  1341. console.log("XXXXXXXX南边有空间", manSpace.spaceId, spaceS.toPz)
  1342. }else{
  1343. manSpace.toPz = (manSpace.spaceHeight * sizeScale - manSpace.spaceHeight) / 2 / 100 * -1;
  1344. console.log("XXXXXXXX南边没空间", manSpace.spaceId)
  1345. }
  1346. console.log("XXXXXXXX-前象限2的其他空间", manSpace.spaceId, manSpace.spaceWidth, manSpace.spaceHeight, manSpace.centerX, manSpace.centerY, manSpace.toPx);
  1347. manSpace.spaceWidth = manSpace.spaceWidth * sizeScale;
  1348. manSpace.spaceHeight = manSpace.spaceHeight * sizeScale;
  1349. manSpace.centerX += manSpace.toPx * 100
  1350. manSpace.centerY += manSpace.toPz * 100
  1351. console.log("XXXXXXXX-后象限2的其他空间", manSpace.spaceId, manSpace.spaceWidth, manSpace.spaceHeight, manSpace.centerX, manSpace.centerY);
  1352. const spaceIndex = this.spaceList.findIndex((item)=>{
  1353. return item.spaceId == manSpace.spaceId;
  1354. })
  1355. if(spaceIndex!=-1){
  1356. this.spaceList[spaceIndex] = manSpace;
  1357. }
  1358. const spacesIndex = this.spaces2.findIndex((item)=>{
  1359. return item.spaceId == manSpace.spaceId;
  1360. })
  1361. if(spacesIndex!=-1){
  1362. this.spaces2[spacesIndex] = manSpace;
  1363. }
  1364. }
  1365. if(xiangxian == 3){
  1366. const spaceW = this.spaces3.find((item)=>{
  1367. return item.spaceId == manSpace.westId;
  1368. })
  1369. const spaceN = this.spaces3.find((item)=>{
  1370. return item.spaceId == manSpace.northId;
  1371. })
  1372. const oldArea = (manSpace.spaceWidth / 100) * (manSpace.spaceHeight / 100);
  1373. const newArea = oldArea + changeArea * isZoomIn;
  1374. const sizeScale = Math.sqrt(newArea/oldArea) ;
  1375. manSpace.toScaleX = manSpace.spaceWidth * sizeScale / 300 ;
  1376. manSpace.toScaleZ = manSpace.spaceHeight * sizeScale / 300 ;
  1377. if(spaceW){
  1378. manSpace.toPx = (manSpace.spaceWidth * sizeScale - manSpace.spaceWidth) / 2 / 100 + spaceW.toPx * 2;
  1379. console.log("XXXXXXXX西边有空间", manSpace.spaceId, spaceW.toPx)
  1380. }else{
  1381. manSpace.toPx = (manSpace.spaceWidth * sizeScale - manSpace.spaceWidth) / 2 / 100;
  1382. console.log("XXXXXXXX西边没空间", manSpace.spaceId)
  1383. }
  1384. if(spaceN){
  1385. manSpace.toPz = (manSpace.spaceHeight * sizeScale - manSpace.spaceHeight) / 2 / 100 + spaceN.toPz * 2;
  1386. console.log("XXXXXXXX北边有空间", manSpace.spaceId, spaceN.toPz)
  1387. }else{
  1388. manSpace.toPz = (manSpace.spaceHeight * sizeScale - manSpace.spaceHeight) / 2 / 100;
  1389. console.log("XXXXXXXX北边没空间", manSpace.spaceId)
  1390. }
  1391. console.log("XXXXXXXX-前象限3的其他空间", manSpace.spaceId, manSpace.spaceWidth, manSpace.spaceHeight, manSpace.centerX, manSpace.centerY, manSpace.toPx);
  1392. manSpace.spaceWidth = manSpace.spaceWidth * sizeScale;
  1393. manSpace.spaceHeight = manSpace.spaceHeight * sizeScale;
  1394. manSpace.centerX += manSpace.toPx * 100
  1395. manSpace.centerY += manSpace.toPz * 100
  1396. console.log("XXXXXXXX-后象限3的其他空间", manSpace.spaceId, manSpace.spaceWidth, manSpace.spaceHeight, manSpace.centerX, manSpace.centerY);
  1397. const spaceIndex = this.spaceList.findIndex((item)=>{
  1398. return item.spaceId == manSpace.spaceId;
  1399. })
  1400. if(spaceIndex!=-1){
  1401. this.spaceList[spaceIndex] = manSpace;
  1402. }
  1403. const spacesIndex = this.spaces3.findIndex((item)=>{
  1404. return item.spaceId == manSpace.spaceId;
  1405. })
  1406. if(spacesIndex!=-1){
  1407. this.spaces3[spacesIndex] = manSpace;
  1408. }
  1409. }
  1410. if(xiangxian == 4){
  1411. const spaceE = this.spaces4.find((item)=>{
  1412. return item.spaceId == manSpace.eastId;
  1413. })
  1414. const spaceN = this.spaces4.find((item)=>{
  1415. return item.spaceId == manSpace.northId;
  1416. })
  1417. const oldArea = (manSpace.spaceWidth / 100) * (manSpace.spaceHeight / 100);
  1418. const newArea = oldArea + changeArea * isZoomIn;
  1419. const sizeScale = Math.sqrt(newArea/oldArea) ;
  1420. manSpace.toScaleX = manSpace.spaceWidth * sizeScale / 300 ;
  1421. manSpace.toScaleZ = manSpace.spaceHeight * sizeScale / 300 ;
  1422. if(spaceE){
  1423. manSpace.toPx = (manSpace.spaceWidth * sizeScale - manSpace.spaceWidth) / 2 / 100 * -1 + spaceE.toPx * 2;
  1424. console.log("XXXXXXXX东边有空间", manSpace.spaceId, spaceE.toPx)
  1425. }else{
  1426. manSpace.toPx = (manSpace.spaceWidth * sizeScale - manSpace.spaceWidth) / 2 / 100 * -1;
  1427. console.log("XXXXXXXX东边没空间", manSpace.spaceId)
  1428. }
  1429. if(spaceN){
  1430. manSpace.toPz = (manSpace.spaceHeight * sizeScale - manSpace.spaceHeight) / 2 / 100 + spaceN.toPz * 2;
  1431. console.log("XXXXXXXX北边有空间", manSpace.spaceId, spaceN.toPz)
  1432. }else{
  1433. manSpace.toPz = (manSpace.spaceHeight * sizeScale - manSpace.spaceHeight) / 2 / 100;
  1434. console.log("XXXXXXXX北边没空间", manSpace.spaceId)
  1435. }
  1436. console.log("XXXXXXXX-前象限4的其他空间", manSpace.spaceId, manSpace.spaceWidth, manSpace.spaceHeight, manSpace.centerX, manSpace.centerY, manSpace.toPx);
  1437. manSpace.spaceWidth = manSpace.spaceWidth * sizeScale;
  1438. manSpace.spaceHeight = manSpace.spaceHeight * sizeScale;
  1439. manSpace.centerX += manSpace.toPx * 100
  1440. manSpace.centerY += manSpace.toPz * 100
  1441. console.log("XXXXXXXX-后象限4的其他空间", manSpace.spaceId, manSpace.spaceWidth, manSpace.spaceHeight, manSpace.centerX, manSpace.centerY);
  1442. const spaceIndex = this.spaceList.findIndex((item)=>{
  1443. return item.spaceId == manSpace.spaceId;
  1444. })
  1445. if(spaceIndex!=-1){
  1446. this.spaceList[spaceIndex] = manSpace;
  1447. }
  1448. const spacesIndex = this.spaces4.findIndex((item)=>{
  1449. return item.spaceId == manSpace.spaceId;
  1450. })
  1451. if(spacesIndex!=-1){
  1452. this.spaces4[spacesIndex] = manSpace;
  1453. }
  1454. }
  1455. },
  1456. //空间面积等变更后-同步更新其他数据对象
  1457. updataPageData(){
  1458. let sumArea = 0;
  1459. this.spaceList.forEach(space=>{
  1460. let curSpaceArea = parseFloat((
  1461. (space.spaceWidth * space.spaceHeight) / 10000
  1462. ).toFixed(2));
  1463. sumArea +=curSpaceArea;
  1464. })
  1465. this.changeArea = parseFloat((sumArea - this.sumArea).toFixed(2));
  1466. this.sumArea = parseFloat(sumArea.toFixed(2));
  1467. let str = JSON.stringify(this.spaceList)
  1468. //更新当前空间对象
  1469. this.curHouseObj.houseJson = str;
  1470. //更新提交的数据
  1471. let layoutStruct = this.curLayoutStruct.find(it=>{
  1472. return it.houseFloor == this.curHouseFloor
  1473. })
  1474. layoutStruct.houseJson = str;
  1475. this.currentChangeSpaceId = null;//变化结束后
  1476. console.warn("***curLayoutStruct-updataPageData***",this.changeArea,this.sumArea,this.curHouseFloor,this.curHouseObj,layoutStruct)
  1477. },
  1478. //户型大类发生了变更
  1479. curHouseTypeChange(item){
  1480. this.curHouseType = item.spaceStructure;//当前选中的户型类型-传递给子组件触发具体的户型数据选取
  1481. this.curHouseName = item.spaceName;//当前选中的户型类型名称
  1482. //获取当前户型大类下的所有户型信息-用于用户提交
  1483. this.curLayoutStruct = this.houseList.find(it=>it.spaceStructure == this.curHouseType).layoutStruct;
  1484. console.warn("***curLayoutStruct***",this.curLayoutStruct)
  1485. },
  1486. //户型楼层发生了变更
  1487. curHouseFloorChange(item){
  1488. let that = this;
  1489. this.curHouseFloor = item.houseFloor;//当前选中的户型楼层
  1490. this.curHouseObj = item;//更新当前具体的户型数据
  1491. this.id = this.curHouseObj.id;
  1492. // 遍历场景中的所有子对象,找到类型为Mesh的对象并移除
  1493. let deleList = that.scene && that.scene.children.filter(object=>{
  1494. if(object.userType=="mesh" || object.userType=="layoutMesh"){
  1495. return object
  1496. }
  1497. })
  1498. // console.warn("***deleList***",deleList)
  1499. if(deleList && deleList.length>0){
  1500. that.showLables = false;//隐藏lable
  1501. that.scene.remove(...deleList);
  1502. }
  1503. this.gltfWalls = [];
  1504. this.gltfSpaces = [];
  1505. this.instancedMeshList = [];
  1506. this.instancedSpaceMeshList = [];
  1507. this.lableItem = [];
  1508. this.gltfLayouts = [];
  1509. this.instancedFurList = [];
  1510. this.wallList = [];
  1511. //恢复初始视角
  1512. this.cameraInit();
  1513. this.resetControl();
  1514. setTimeout(()=>{
  1515. that.loadSpace();
  1516. }, 100);
  1517. console.warn("***curHouseObj***",this.curHouseObj,this.aiData)
  1518. this.navbar.title = this.curHouseObj.name + " " + this.curHouseObj.houseArea + "㎡";
  1519. this.sumArea = this.curHouseObj.houseArea;
  1520. },
  1521. async getInitData(){
  1522. let parmas = {
  1523. childLayout:this.childLayout || 0,
  1524. houseId:this.houseId,
  1525. }
  1526. const res = await requestConfig('getHouseTypeSpaceDetailsV2', parmas, true);
  1527. if (res.success && res.list) {
  1528. let list = res.list || [];
  1529. list && list.forEach((single,index)=>{
  1530. single.layoutStruct.forEach((item)=>{
  1531. if(item.houseJson){
  1532. let spaceList = JSON.parse(item.houseJson);
  1533. // 交换centerX, centerY
  1534. for (let index = 0; index < spaceList.length; index++) {
  1535. var element = spaceList[index];
  1536. const {centerX, centerY} = element;
  1537. element.centerX = centerY;
  1538. element.centerY = centerX;
  1539. }
  1540. item.houseJson = JSON.stringify(spaceList);
  1541. }
  1542. })
  1543. })
  1544. console.log("户型详情列表-接口原始数据: ", list);
  1545. this.houseList = list;//数据会同步到组件中-进而反馈更新页面数据
  1546. }
  1547. },
  1548. onMouseMove(e){
  1549. return false;
  1550. },
  1551. goRoam1(spaceId){
  1552. let gltf = this.lableItem.find(it=>it.spaceId==spaceId);
  1553. if(gltf){
  1554. this.goRoam(gltf)
  1555. }
  1556. },
  1557. //物体漫游-切换页面的方式进入
  1558. goRoam(gltf){
  1559. // console.log('是否漫游',this.isManyou ? '漫游' : '俯视',isManyou,this.repeatFlag);
  1560. if(gltf.spaceType==13){//楼梯不能跳转
  1561. return false
  1562. }
  1563. let spaceId = gltf.spaceId;//具体的空间Id
  1564. let data = {
  1565. spaceId:spaceId,
  1566. // curHouseObj:this.curHouseObj,
  1567. houseId:this.houseId,
  1568. }
  1569. if(this.repeatFlag){
  1570. return false;
  1571. }
  1572. this.repeatFlag = true;
  1573. router.push({
  1574. name: "webgl_rxdz_roam",
  1575. query:data
  1576. });
  1577. this.$store.dispatch('setCurHouseObj', this.curHouseObj);
  1578. this.$store.dispatch('setWallList', this.wallList);
  1579. setTimeout(()=> {
  1580. this.repeatFlag = false;
  1581. }, 1000);
  1582. },
  1583. //obj 物体对象,type 是否改变颜色
  1584. moveMeshCenter(obj,type){
  1585. console.warn("**moveMeshCenter***",obj)
  1586. if(obj && this.gltfSpaces && this.gltfSpaces.length>0){
  1587. this.moveMeshCenterHandle(obj,type);
  1588. }
  1589. },
  1590. // 绘制地板
  1591. async loadSpace(){
  1592. this.spaceList = [];
  1593. this.wallIds = [];
  1594. this.layoutIds = [];
  1595. this.gltfSpaces = [];
  1596. this.curWallArr = [];
  1597. this.progress = 0;
  1598. if(!this.curHouseObj){//减少重复请求
  1599. return false
  1600. }
  1601. let type=[];
  1602. if(this.curHouseObj){
  1603. const spaceDetail = this.curHouseObj;
  1604. const spaceList = JSON.parse(spaceDetail.houseJson);
  1605. // 交换centerX, centerY;上一页面已经处理过了,这里不在需要处理
  1606. for (let index = 0; index < spaceList.length; index++) {
  1607. var element = spaceList[index];
  1608. // const centerX = JSON.parse(JSON.stringify(element.centerX))
  1609. // element.centerX = element.centerY;
  1610. // element.centerY = centerX;
  1611. element.wallMoveValue = "[0,0,0,0]"
  1612. this.spaceList.push(element);
  1613. this.wallIds.push(element.wallId);
  1614. this.layoutIds.push(element.layoutId);
  1615. type.push(element.spaceType);
  1616. if(element.isSelected){ // 默认选中空间
  1617. this.curSpaceObj = element;
  1618. }
  1619. }
  1620. if(!this.curSpaceObj && this.spaceList.length > 0){
  1621. this.curSpaceObj = this.spaceList[0];
  1622. }
  1623. }
  1624. console.log("该户型空间数据:", this.spaceList, this.layoutIds,type);
  1625. console.log("当前选中的空间:", this.curSpaceObj,this.curHouseObj);
  1626. this.spaceListBackup = JSON.parse(JSON.stringify(this.spaceList));
  1627. this.loaderSpaceArr(this.spaceList);
  1628. // 绘制墙体
  1629. this.getHouseTypeSpaceWalls();
  1630. },
  1631. // 添加文字标签
  1632. addWordLabel(){
  1633. if(!this.gltfSpaces || this.gltfSpaces.length <= 0){
  1634. return false;
  1635. }
  1636. // 方案二
  1637. this.lableItem = [];
  1638. this.gltfSpaces.forEach((cube,index) =>{
  1639. // 给地板加上空间类型标注, 空间为链接空间的不显示
  1640. if(cube.spaceName && !cube.isSizeLock){
  1641. let spaceIndex = this.spaceList.filter(it=>it.spaceName && !it.isSizeLock).findIndex(item=>item.spaceId==cube.spaceId);
  1642. this.lableItem.push(
  1643. {
  1644. text:cube.spaceName,
  1645. spaceId:cube.spaceId,
  1646. spaceType:cube.spaceType,
  1647. transform:'',
  1648. spaceIndex:spaceIndex,
  1649. cubeIndex:index,
  1650. }
  1651. )
  1652. }
  1653. })
  1654. this.showLables = true;
  1655. // this.updateLables();//更新lable
  1656. },
  1657. // 获取墙体数据
  1658. async getHouseTypeSpaceWalls(){
  1659. let data = {id:this.wallIds}
  1660. const res = await requestConfig('getHouseTypeSpaceWalls', data, true);
  1661. console.log("墙体数据:", res.list)
  1662. let wallList = [];
  1663. if(res.success){
  1664. wallList = this.wallList = res.list;
  1665. }
  1666. let wallArr = []
  1667. for (let index = 0; index < wallList.length; index++) {//每个空间对应一个数据
  1668. let element = JSON.parse(wallList[index].wallJson);
  1669. let space = this.spaceList.find(space=>space.spaceId==element.spaceId);
  1670. this.computeWallHandleOld(space,element);//提前计算
  1671. for (let i = 0; i < element.wallData.length; i ++) {//对应空间里面的4个方向的墙壁数据
  1672. let wallData = element.wallData[i];
  1673. //对应方向的墙壁的墙体模型数据列表,每一面墙可能有多个模型
  1674. for (let j = 0; j < wallData.wallModelData.length; j ++) {
  1675. let wallModelData = wallData.wallModelData[j];
  1676. wallArr.push({spaceId:element.spaceId, wallModelData:wallModelData, wallDirection:wallData.wallDirection})
  1677. // console.log("wallModelData", element,wallData.wallDirection, wallModelData.wallType );
  1678. }
  1679. }
  1680. }
  1681. this.loadSpaceObjWalls(wallArr, wallList);
  1682. this.getOverallArrangementDetailsList(2);
  1683. },
  1684. // 加载单个空间墙体资源
  1685. async loadSpaceObjWalls(wallArr, wallList){
  1686. // 加载远程墙体模型资源
  1687. let startTime = new Date().getTime();
  1688. // console.log("wallArr:", wallArr)
  1689. let promise_list = [];
  1690. let realWallArr = this.preWallData(wallArr);
  1691. let arrLength = realWallArr.length;
  1692. realWallArr && realWallArr.forEach((item,index) => {
  1693. promise_list.push(
  1694. new Promise((resolve, reject) => {
  1695. this.loadWallModels(item, wallList, arrLength , resolve);
  1696. })
  1697. )
  1698. });
  1699. Promise.all(promise_list).then(()=>{
  1700. let endTime = new Date().getTime();
  1701. console.log("模型全部加载完成,时间:",endTime - startTime);
  1702. this.progress = 100;
  1703. // this.$refs.myLoading.showLoading("加载中..." + this.progress + '%')
  1704. // 设置空间数组的墙体信息
  1705. // this.setSpaceListWallInfo();
  1706. this.$nextTick(()=>{
  1707. this.moveMeshCenter(this.curSpaceObj);
  1708. // this.myLoadingStatus = false;
  1709. // this.$refs.myLoading.hideLoading();
  1710. setTimeout(()=>{
  1711. this.addWordLabel(); // 添加文字标签
  1712. }, 610);
  1713. // 设置空间数组的墙体信息
  1714. })
  1715. })
  1716. },
  1717. // 选择墙体
  1718. selectedWall(direction){
  1719. if(!direction || direction==""){
  1720. return
  1721. }
  1722. console.log(`当前空间的id:${this.curSpaceObj.spaceId};墙面方向:${direction};宽度:${this.curSpaceObj.spaceWidth};宽度:${this.curSpaceObj.spaceHeight}`)
  1723. console.log("当前空间的:", this.curSpaceObj);
  1724. this.leftSpaces = [];
  1725. this.rightSpaces = [];
  1726. this.tempSpaceList = JSON.parse(JSON.stringify(this.spaceList));
  1727. // 计算关联空间
  1728. this.findLeftRelateSpace(this.curSpaceObj, direction);
  1729. console.log("空间数组:", this.leftSpaces, this.rightSpaces);
  1730. // 计算墙体的可移动范围
  1731. var min = 0;
  1732. var max = 300;
  1733. // 计算最小值
  1734. for (let index = 0; index < this.leftSpaces.length; index++) {
  1735. const element = this.leftSpaces[index];
  1736. console.log("左边空间数据:", element);
  1737. var spaceMoveNW = element.spaceWidth;
  1738. var spaceMoveSW = element.spaceWidth;
  1739. var spaceMoveEH = element.spaceHeight;
  1740. var spaceMoveWH = element.spaceHeight;
  1741. var curSpaceWall = [];
  1742. for (let index = 0; index < this.gltfWalls.length; index++) {
  1743. const wall = this.gltfWalls[index];
  1744. if(element.spaceId == wall.spaceId && wall.wallDirection != direction){
  1745. curSpaceWall.push(wall);
  1746. if((direction == "W" || direction == "E") && wall.wallDirection != direction){
  1747. if(wall.wallDirection == "N"){
  1748. spaceMoveNW -= wall.wallModelData.wallWidth;
  1749. console.log("北边墙:", spaceMoveNW, wall.wallModelData.wallWidth, wall.id);
  1750. }
  1751. if(wall.wallDirection == "S"){
  1752. spaceMoveSW -= wall.wallModelData.wallWidth;
  1753. console.log("南边墙:", spaceMoveSW, wall.wallModelData.wallWidth, wall.id);
  1754. }
  1755. this.curWallValue = Math.floor(Math.min(Math.min(spaceMoveNW, spaceMoveSW), this.curWallValue));
  1756. }
  1757. if((direction == "N" || direction == "S") && wall.wallDirection != direction){
  1758. if(wall.wallDirection == "E"){
  1759. spaceMoveEH -= wall.wallModelData.wallWidth;
  1760. console.log("东边墙:", spaceMoveNW, wall.wallModelData.wallWidth, wall.id);
  1761. }
  1762. if(wall.wallDirection == "W"){
  1763. spaceMoveWH -= wall.wallModelData.wallWidth;
  1764. console.log("西边墙:", spaceMoveSW, wall.wallModelData.wallWidth, wall.id);
  1765. }
  1766. this.curWallValue = Math.floor(Math.min(Math.min(spaceMoveEH, spaceMoveWH), this.curWallValue));
  1767. }
  1768. }
  1769. }
  1770. // 排序墙体数据
  1771. curSpaceWall.sort(function(a,b){return a.wallModelData.id -b.wallModelData.id});
  1772. curSpaceWall.sort(function(a,b){return a.wallDirection.localeCompare(b.wallDirection)})
  1773. console.log("墙体模型:", curSpaceWall, spaceMoveNW, spaceMoveSW);
  1774. console.log("可缩小的最小值:", Math.floor(Math.min(spaceMoveNW, spaceMoveSW)));
  1775. if((direction == "W" || direction == "E") && element.spaceWidth == this.curWallValue){
  1776. this.curWallValue = 149;
  1777. }
  1778. if((direction == "N" || direction == "S") && element.spaceHeight == this.curWallValue){
  1779. this.curWallValue = 149;
  1780. }
  1781. // this.curWallValue = Math.floor(Math.min(spaceMoveNW, spaceMoveSW));
  1782. }
  1783. // 计算最大值
  1784. for (let index = 0; index < this.rightSpaces.length; index++) {
  1785. const element = this.rightSpaces[index];
  1786. console.log("右边空间数据:", element);
  1787. var spaceMoveNW = element.spaceWidth;
  1788. var spaceMoveSW = element.spaceWidth;
  1789. var spaceMoveEH = element.spaceHeight;
  1790. var spaceMoveWH = element.spaceHeight;
  1791. var curSpaceWall = [];
  1792. for (let index = 0; index < this.gltfWalls.length; index++) {
  1793. const wall = this.gltfWalls[index];
  1794. if(element.spaceId == wall.spaceId && wall.wallDirection != direction){
  1795. curSpaceWall.push(wall);
  1796. if((direction == "W" || direction == "E") && wall.wallDirection != direction){
  1797. if(wall.wallDirection == "N"){
  1798. spaceMoveNW -= wall.wallModelData.wallWidth;
  1799. console.log("北边墙:", spaceMoveNW, wall.wallModelData.wallWidth, wall.id);
  1800. }
  1801. if(wall.wallDirection == "S"){
  1802. spaceMoveSW -= wall.wallModelData.wallWidth;
  1803. console.log("南边墙:", spaceMoveSW, wall.wallModelData.wallWidth, wall.id);
  1804. }
  1805. this.curWallMaxValue = Math.floor(Math.min(spaceMoveNW, spaceMoveSW)) + this.curWallValue;
  1806. }
  1807. if((direction == "N" || direction == "S") && wall.wallDirection != direction){
  1808. if(wall.wallDirection == "E"){
  1809. spaceMoveEH -= wall.wallModelData.wallWidth;
  1810. console.log("东边墙:", spaceMoveNW, wall.wallModelData.wallWidth, wall.id);
  1811. }
  1812. if(wall.wallDirection == "W"){
  1813. spaceMoveWH -= wall.wallModelData.wallWidth;
  1814. console.log("西边墙:", spaceMoveSW, wall.wallModelData.wallWidth, wall.id);
  1815. }
  1816. this.curWallMaxValue = Math.floor(Math.min(spaceMoveEH, spaceMoveWH)) + this.curWallValue;
  1817. }
  1818. }
  1819. }
  1820. // 排序墙体数据
  1821. curSpaceWall.sort(function(a,b){return a.wallModelData.id -b.wallModelData.id});
  1822. curSpaceWall.sort(function(a,b){return a.wallDirection.localeCompare(b.wallDirection)})
  1823. console.log("墙体模型:", curSpaceWall, spaceMoveNW, spaceMoveSW);
  1824. console.log("可缩小的最小值:", Math.floor(Math.min(spaceMoveNW, spaceMoveSW)));
  1825. }
  1826. console.log(`当前墙面的最大值:${this.curWallMaxValue}, 最小值:${this.curWallValue}`)
  1827. // 统计变化的空间
  1828. this.changeSpaces.push(...this.leftSpaces)
  1829. this.changeSpaces.push(...this.rightSpaces)
  1830. },
  1831. // 递归寻找左边->右边关联空间
  1832. findLeftRelateSpace(spaceObj, direction){
  1833. const {eastId, westId, northId, southId, spaceId} = spaceObj;
  1834. const leftIndex = this.tempSpaceList.findIndex((item)=>{
  1835. return item.spaceId == spaceId;
  1836. })
  1837. if(leftIndex!=-1){
  1838. const spaceObj = this.tempSpaceList[leftIndex];
  1839. this.leftSpaces.push(spaceObj);
  1840. this.tempSpaceList.splice(leftIndex,1);
  1841. const leftNextIndex = this.tempSpaceList.findIndex((item)=>{
  1842. if(direction == "E"){
  1843. return item.spaceId == eastId;
  1844. }else if(direction == "W"){
  1845. return item.spaceId == westId;
  1846. }else if(direction == "S"){
  1847. return item.spaceId == southId;
  1848. }else if(direction == "N"){
  1849. return item.spaceId == northId;
  1850. }
  1851. })
  1852. if(leftNextIndex!=-1){
  1853. const nextSpaceObj = this.tempSpaceList[leftNextIndex];
  1854. console.log("递归再一次", nextSpaceObj);
  1855. this.findRightRelateSpace(nextSpaceObj, direction);
  1856. }
  1857. const rightArr = this.tempSpaceList.filter((item)=>{
  1858. if(direction == "E"){
  1859. return item.westId == spaceId;
  1860. }else if(direction == "W"){
  1861. return item.eastId == spaceId;
  1862. }else if(direction == "S"){
  1863. return item.northId == spaceId;
  1864. }else if(direction == "N"){
  1865. return item.southId == spaceId;
  1866. }
  1867. })
  1868. for (let index = 0; index < rightArr.length; index++) {
  1869. const nextSpaceObj = rightArr[index];
  1870. // const nextSpaceObj = this.tempSpaceList[rightNextIndex];
  1871. console.log("递归再一次", nextSpaceObj);
  1872. this.findRightRelateSpace(nextSpaceObj, direction);
  1873. }
  1874. }
  1875. },
  1876. // 递归寻找右边->左边关联空间
  1877. findRightRelateSpace(spaceObj, direction){
  1878. const {eastId, westId, northId, southId, spaceId} = spaceObj;
  1879. const rightIndex = this.tempSpaceList.findIndex((item)=>{
  1880. return item.spaceId == spaceId;
  1881. })
  1882. if(rightIndex!=-1){
  1883. const spaceObj = this.tempSpaceList[rightIndex];
  1884. this.rightSpaces.push(spaceObj);
  1885. this.tempSpaceList.splice(rightIndex,1);
  1886. console.log("当前空间数组:", this.tempSpaceList);
  1887. const leftNextIndex = this.tempSpaceList.findIndex((item)=>{
  1888. if(direction == "E"){
  1889. return item.spaceId == westId;
  1890. }else if(direction == "W"){
  1891. return item.spaceId == eastId;
  1892. }else if(direction == "N"){
  1893. return item.spaceId == southId;
  1894. }else if(direction == "S"){
  1895. return item.spaceId == northId;
  1896. }
  1897. })
  1898. if(leftNextIndex!=-1){
  1899. const nextSpaceObj = this.tempSpaceList[leftNextIndex];
  1900. console.log("递归再一次", nextSpaceObj);
  1901. this.findLeftRelateSpace(nextSpaceObj, direction);
  1902. }
  1903. const rightArr = this.tempSpaceList.filter((item)=>{
  1904. if(direction == "E"){
  1905. return item.eastId == spaceId;
  1906. }else if(direction == "W"){
  1907. return item.westId == spaceId;
  1908. }else if(direction == "N"){
  1909. return item.northId == spaceId;
  1910. }else if(direction == "S"){
  1911. return item.southId == spaceId;
  1912. }
  1913. });
  1914. for (let index = 0; index < rightArr.length; index++) {
  1915. const nextSpaceObj = rightArr[index];
  1916. console.log("递归再一次", nextSpaceObj);
  1917. this.findLeftRelateSpace(nextSpaceObj, direction);
  1918. }
  1919. }
  1920. },
  1921. moveSpaceWall(direction, moveOut, moveValue){
  1922. // let isNS = (direction == "N" || direction == "S")
  1923. // if(!this.checkRightSpace(!moveOut, moveValue, isNS)){
  1924. // return
  1925. // }
  1926. // 隐藏变化空间的家具模型,空间动画结束后显示
  1927. this.changeLayoutModelState();
  1928. console.log("关联空间XXXXX", this.leftSpaces, this.rightSpaces)
  1929. for (let index = 0; index < this.leftSpaces.length; index++) {
  1930. const element = this.leftSpaces[index];
  1931. const space = this.spaceList.find((item)=>{
  1932. return item.spaceId == element.spaceId;
  1933. })
  1934. this.moveWall(space, direction, moveOut, moveValue);
  1935. // this.wallTransform(space, direction, moveOut, moveValue);
  1936. }
  1937. let otherdirection = "";
  1938. switch (direction) {
  1939. case "E":
  1940. otherdirection = "W"
  1941. break;
  1942. case "W":
  1943. otherdirection = "E"
  1944. break;
  1945. case "N":
  1946. otherdirection = "S"
  1947. break;
  1948. case "S":
  1949. otherdirection = "N"
  1950. break;
  1951. }
  1952. for (let index = 0; index < this.rightSpaces.length; index++) {
  1953. const element = this.rightSpaces[index];
  1954. this.moveWall(element, otherdirection, !moveOut, moveValue);
  1955. }
  1956. console.log(`当前空间的后id:${this.curSpaceObj.spaceId};墙面方向:${direction};宽度:${this.curSpaceObj.spaceWidth};高度:${this.curSpaceObj.spaceHeight}`)
  1957. },
  1958. // 调整大小
  1959. // direction:方向
  1960. // moveOut:是否外移
  1961. // moveValue: 移动距离
  1962. moveWall(spaceObj, direction, moveOut, moveValue){
  1963. console.log(`移动的空间的id-------:${spaceObj.spaceId};移动方向:${direction};是否外移:${moveOut};移动距离:${moveValue}`)
  1964. const oldSpaceObj = JSON.parse(JSON.stringify(spaceObj))
  1965. const cube = this.gltfSpaces.find((item)=>{
  1966. return item.spaceId == spaceObj.spaceId;
  1967. })
  1968. if(!cube){
  1969. return
  1970. }
  1971. if(!moveOut){
  1972. moveValue = moveValue * -1;
  1973. }
  1974. const {position,scale} = cube;
  1975. // 重新计算缩放 和 位置
  1976. let toScaleX = scale.x;
  1977. let toScaleZ = scale.z;
  1978. let toPx = position.x;
  1979. let toPz = position.z;
  1980. if(direction == 'E' || direction == 'W'){
  1981. let spaceWidth = scale.x * 300;
  1982. toScaleX = (spaceWidth + moveValue) / 300;
  1983. if(direction == 'W'){
  1984. toPx = position.x - moveValue / 2 / 100;
  1985. }else{
  1986. toPx = position.x + moveValue / 2 / 100;
  1987. }
  1988. spaceObj.spaceWidth += moveValue;
  1989. spaceObj.centerX = toPx * 100;
  1990. }
  1991. if(direction == 'N' || direction == 'S'){
  1992. let spaceHeight = scale.z * 300;
  1993. toScaleZ = (spaceHeight + moveValue) / 300;
  1994. if(direction == 'N'){
  1995. toPz = position.z - moveValue / 2 / 100;
  1996. }else{
  1997. toPz = position.z + moveValue / 2 / 100;
  1998. }
  1999. spaceObj.spaceHeight += moveValue;
  2000. spaceObj.centerY = toPz * 100 * -1;
  2001. }
  2002. console.log("curSpaceObj",this.curSpaceObj.spaceId, spaceObj.spaceId, spaceObj.centerX, spaceObj.centerY, toScaleX,toScaleZ,toPx,toPz)
  2003. console.log("当前空间变化后的尺寸",spaceObj.spaceWidth, spaceObj.spaceHeight, spaceObj.spaceId)
  2004. // 更新数据
  2005. const spaceIndex = this.spaceList.findIndex((item)=>{
  2006. return item.spaceId == spaceObj.spaceId;
  2007. })
  2008. if(spaceIndex!=-1){
  2009. this.spaceList[spaceIndex] = spaceObj;
  2010. if(this.curSpaceObj.spaceId == spaceObj.spaceId){
  2011. this.curSpaceObj = spaceObj;
  2012. }
  2013. }
  2014. this.curHouseObj.houseJson = JSON.stringify(this.spaceList);
  2015. //空间动画处理-提取到floorMethod.js中
  2016. this.changeSpacesAnim({spaceId:spaceObj.spaceId,toScaleX,toScaleZ,toPx,toPz})
  2017. // 墙体动画处理
  2018. //// 根据空间尺寸,更新前提数据
  2019. const wallObj = this.wallList.find((item)=>{
  2020. return item.id == spaceObj.wallId;
  2021. })
  2022. const initSpaceObj = this.spaceListBackup.find((item)=>{
  2023. return item.spaceId == spaceObj.spaceId;
  2024. })
  2025. if(wallObj){
  2026. let element = JSON.parse(wallObj.wallJson);
  2027. console.warn("****wallObj**",element)
  2028. this.computeWallHandle(initSpaceObj, spaceObj, element, moveOut, direction); // 重新计算-并把空间的计算结果同步到gltfWalls中
  2029. }
  2030. // 移动墙体
  2031. let curSpaceWall = [];
  2032. for (let index = 0; index < this.gltfWalls.length; index++) {
  2033. const element = this.gltfWalls[index];
  2034. if(spaceObj.spaceId == element.spaceId){
  2035. curSpaceWall.push(element);
  2036. }
  2037. }
  2038. //移动的是西方的墙壁 和 南方的墙壁,该空间的几何体中心测移动变化
  2039. if(direction == 'W' || direction == 'S'){
  2040. spaceObj.rightCenter = true;
  2041. }
  2042. //移动的是东方的墙壁 和 北方的墙壁,该空间的几何体中心测不移动变化
  2043. if(direction == 'E'|| direction == 'N'){
  2044. spaceObj.rightCenter = false;
  2045. }
  2046. // 排序墙体数据
  2047. curSpaceWall.sort(function(a,b){return a.wallModelData.id -b.wallModelData.id});
  2048. curSpaceWall.sort(function(a,b){return a.wallDirection.localeCompare(b.wallDirection)})
  2049. console.log("移动的墙体:", spaceObj, direction, curSpaceWall);
  2050. // return;
  2051. for (let index = 0; index < curSpaceWall.length; index++) {
  2052. const element = curSpaceWall[index];
  2053. // console.log("重新计算墙体-墙体数据:",element, spaceObj);
  2054. this.drawModel(element.wallModelData, spaceObj, element, true)
  2055. }
  2056. },
  2057. // 空隙自动补签逻辑
  2058. autoCreateWall(directionIndex, spaceObj){
  2059. let direction = ""
  2060. switch (directionIndex) {
  2061. case 1:
  2062. direction = "N"
  2063. break;
  2064. case 2:
  2065. direction = "S"
  2066. break;
  2067. case 3:
  2068. direction = "W"
  2069. break;
  2070. case 4:
  2071. direction = "E"
  2072. break;
  2073. default:
  2074. break;
  2075. }
  2076. // 东西墙 检查 南北墙关联空间 南北墙 检查 东西墙关联空间
  2077. if(direction == "E" || direction == "W"){
  2078. if(spaceObj.quadrant == 3 || spaceObj.quadrant == 4){ // 南边空间
  2079. console.log("南北朝向墙自动补齐", this.leftSpaces, this.rightSpaces)
  2080. this.selectedWall("N");
  2081. this.checkIsAutoCreateWall("N", spaceObj)
  2082. this.selectedWall("S");
  2083. this.checkIsAutoCreateWall("S", spaceObj)
  2084. let autoWall = this.gltfAutoWalls.find(item=>{
  2085. return item.spaceId == spaceObj.spaceId ;
  2086. })
  2087. if(autoWall){
  2088. console.log("南北朝向墙自动补齐---", autoWall, this.gltfAutoWalls)
  2089. if(autoWall.wallDirection == "E"){
  2090. autoWall.obj.position.x = (spaceObj.centerX + (spaceObj.spaceWidth / 2) - 5) / 100
  2091. }
  2092. }
  2093. }else{ // 北边关联空间
  2094. }
  2095. }else{
  2096. if(spaceObj.quadrant == 3 || spaceObj.quadrant == 4){ // 南边空间
  2097. console.log("东西朝向墙自动补齐", this.leftSpaces, this.rightSpaces)
  2098. this.selectedWall("E");
  2099. this.checkIsAutoCreateWall("E", spaceObj)
  2100. this.selectedWall("W");
  2101. this.checkIsAutoCreateWall("W", spaceObj)
  2102. }else{ // 北边关联空间
  2103. }
  2104. }
  2105. },
  2106. // 检测是否需要补强
  2107. checkIsAutoCreateWall(direction, spaceObj){
  2108. var that = this;
  2109. // 判断南边墙是否需要补充
  2110. if(this.rightSpaces.length == 0){
  2111. console.log("不需要补墙1", direction, this.gltfAutoWalls)
  2112. return;
  2113. }
  2114. const n = (direction == "S" || direction == "E") ? 1 : -1; // 南北方向计算系数
  2115. console.log("自动补墙", this.leftSpaces, this.rightSpaces);
  2116. let px = 0;
  2117. let pz = 0;
  2118. let sx = 1;
  2119. let sz = 1;
  2120. let rightids = []
  2121. if(spaceObj.quadrant == 3){
  2122. // 左边空间的最大值
  2123. let leftMaxValue = 0;
  2124. for (let index = 0; index < this.leftSpaces.length; index++) {
  2125. const element = this.leftSpaces[index];
  2126. if(direction=="S" || direction == "N"){
  2127. const curvalue = element.centerX + element.spaceWidth / 2
  2128. if(leftMaxValue < curvalue){
  2129. leftMaxValue = curvalue
  2130. }
  2131. }else{
  2132. leftMaxValue += (-element.centerY + element.spaceHeight / 2)
  2133. }
  2134. }
  2135. // rightSpaces右边最大值
  2136. let rightMaxValue = 0;
  2137. for (let index = 0; index < this.rightSpaces.length; index++) {
  2138. const element = this.rightSpaces[index];
  2139. if(direction=="S" || direction == "N"){
  2140. const curvalue = element.centerX + element.spaceWidth / 2
  2141. if(rightMaxValue < curvalue){
  2142. rightMaxValue = curvalue
  2143. }
  2144. }else{
  2145. rightMaxValue += -element.centerY + element.spaceHeight / 2
  2146. }
  2147. rightids.push(element.spaceId)
  2148. }
  2149. // 是否有墙
  2150. const index = this.gltfWalls.findIndex(item=>{
  2151. // console.log("墙面模型", item)
  2152. return spaceObj.spaceId == item.spaceId && item.wallDirection == direction;
  2153. })
  2154. // 有墙,左边墙>右边墙,计算南北墙
  2155. if(index != -1 && leftMaxValue > rightMaxValue && (direction == "S" || direction == "N")){
  2156. console.log("不需要补墙251",index, leftMaxValue, rightMaxValue)
  2157. // 是否补过墙
  2158. const autoWall = this.gltfAutoWalls.find(item=>{
  2159. return item.rightids.indexOf(spaceObj.spaceId) != -1 && item.wallDirection == (direction == "S" ? "N": "S");
  2160. })
  2161. if(autoWall){
  2162. let cube = autoWall.obj;
  2163. if(cube){
  2164. cube.scale.set(0,0,0);
  2165. }
  2166. }
  2167. return
  2168. }
  2169. // 有墙,左边墙>右边墙,计算东西墙
  2170. if(index != -1 && leftMaxValue > rightMaxValue && (direction == "E" || direction == "W")){
  2171. console.log("不需要补墙252",index, leftMaxValue, rightMaxValue, spaceObj.spaceId, direction, this.gltfAutoWalls)
  2172. const autoWall = this.gltfAutoWalls.find(item=>{
  2173. return item.rightids.indexOf(spaceObj.spaceId) != -1 && item.wallDirection == (direction == "E" ? "W": "E");
  2174. })
  2175. if(autoWall){
  2176. let cube = autoWall.obj;
  2177. if(cube){
  2178. cube.scale.set(0,0,0);
  2179. }
  2180. }
  2181. return
  2182. }
  2183. let wallOffset = index != -1 ? -5 : 5;
  2184. console.log("空间最大值", leftMaxValue, rightMaxValue, direction, index);
  2185. const cubeW = Math.abs(leftMaxValue - rightMaxValue);
  2186. if(direction=="S" || direction == "N"){
  2187. px = (Math.min(leftMaxValue, rightMaxValue) + cubeW / 2) / 100
  2188. pz = (-spaceObj.centerY + spaceObj.spaceHeight * n / 2 + wallOffset * n) / 100;
  2189. sx = cubeW / 10 ;
  2190. // 长边有墙
  2191. }else{
  2192. px = (spaceObj.centerX + spaceObj.spaceWidth * n / 2 + wallOffset * n) / 100;
  2193. pz = (Math.max(leftMaxValue, rightMaxValue) - cubeW / 2) / 100
  2194. sz = cubeW / 10;
  2195. }
  2196. }else{
  2197. let leftMinValue = 0;
  2198. for (let index = 0; index < this.leftSpaces.length; index++) {
  2199. const element = this.leftSpaces[index];
  2200. if(direction=="S" || direction == "N"){
  2201. leftMinValue += (element.centerX - element.spaceWidth / 2)
  2202. }else{
  2203. leftMinValue += (-element.centerY + element.spaceHeight / 2)
  2204. }
  2205. }
  2206. // rightSpaces右边最大值
  2207. let rightMinValue = 0;
  2208. for (let index = 0; index < this.rightSpaces.length; index++) {
  2209. const element = this.rightSpaces[index];
  2210. if(direction=="S" || direction == "N"){
  2211. rightMinValue += (element.centerX - element.spaceWidth / 2)
  2212. }else{
  2213. rightMinValue = (-element.centerY + element.spaceHeight / 2)
  2214. }
  2215. rightids.push(element.spaceId)
  2216. }
  2217. const index = this.gltfWalls.findIndex(item=>{
  2218. // console.log("墙面模型", item)
  2219. return spaceObj.spaceId == item.spaceId && item.wallDirection == direction;
  2220. })
  2221. if(index != -1 && leftMinValue < rightMinValue && (direction == "S" || direction == "N")){
  2222. console.log("不需要补墙251")
  2223. return
  2224. }
  2225. if(index != -1 && leftMinValue > rightMinValue && (direction == "E" || direction == "W")){
  2226. console.log("不需要补墙252")
  2227. return
  2228. }
  2229. let wallOffset = index != -1 ? -5 : 5;
  2230. console.log("空间最大值", leftMinValue, rightMinValue);
  2231. const cubeW = Math.abs(leftMinValue - rightMinValue);
  2232. if(leftMinValue > rightMinValue && index == -1 && (direction == "S" || direction == "N")){
  2233. console.log("不需要补墙241", leftMinValue, rightMinValue)
  2234. const autoWall = this.gltfAutoWalls.find(item=>{
  2235. return item.rightids.indexOf(spaceObj.spaceId) != -1 && item.wallDirection == (direction == "S" ? "N": "S");
  2236. })
  2237. if(autoWall){
  2238. let cube = autoWall.obj;
  2239. if(cube){
  2240. cube.scale.set(0,0,0);
  2241. }
  2242. }
  2243. return
  2244. }
  2245. if(leftMinValue < rightMinValue && index == -1 && (direction == "E" || direction == "W")){
  2246. console.log("不需要补墙242", leftMinValue, rightMinValue)
  2247. const autoWall = this.gltfAutoWalls.find(item=>{
  2248. return item.rightids.indexOf(spaceObj.spaceId) != -1 && item.wallDirection == (direction == "W" ? "E": "W");
  2249. })
  2250. if(autoWall){
  2251. let cube = autoWall.obj;
  2252. if(cube){
  2253. cube.scale.set(0,0,0);
  2254. }
  2255. }
  2256. return
  2257. }
  2258. if(direction=="S" || direction == "N"){
  2259. px = (Math.max(leftMinValue, rightMinValue) - cubeW / 2) / 100
  2260. pz = (-spaceObj.centerY + spaceObj.spaceHeight * n / 2 + wallOffset * n) / 100;
  2261. sx = cubeW / 10;
  2262. }else{
  2263. px = (spaceObj.centerX + spaceObj.spaceWidth * n / 2 + wallOffset * n) / 100;
  2264. pz = (Math.max(leftMinValue, rightMinValue) - cubeW / 2) / 100
  2265. sz = cubeW / 10;
  2266. }
  2267. }
  2268. console.log("空间最大值", px, pz, sx, sz, this.gltfAutoWalls);
  2269. // 寻找是否已添加过墙面
  2270. const autoWall = this.gltfAutoWalls.find(item=>{
  2271. return (item.spaceId == spaceObj.spaceId && item.wallDirection == direction)
  2272. || (item.rightids.findIndex(it=>{ return it == spaceObj.spaceId})!=-1 && item.wallDirection == direction == "S"?"N":"S")
  2273. || (item.rightids.findIndex(it=>{ return it == spaceObj.spaceId})!=-1 && item.wallDirection == direction == "E"?"W":"E")
  2274. })
  2275. if(this.curWallDirection == "S"){
  2276. if(spaceObj.southId > 0){
  2277. return
  2278. }
  2279. }
  2280. if(this.curWallDirection == "E"){
  2281. if(spaceObj.eastId > 0){
  2282. return
  2283. }
  2284. }
  2285. if(this.curWallDirection == "N"){
  2286. if(spaceObj.northId > 0){
  2287. return
  2288. }
  2289. }
  2290. if(this.curWallDirection == "W"){
  2291. if(spaceObj.westId > 0){
  2292. return
  2293. }
  2294. }
  2295. if(autoWall){
  2296. console.log("修改补墙的信息", px, pz, sx, sz);
  2297. let cube = autoWall.obj;
  2298. cube.position.set(px,0,pz);
  2299. cube.scale.set(sx,1,sz);
  2300. }else{
  2301. console.log("添加补墙的信息", px, pz, sx, sz);
  2302. that.loader.load(wallType[0].url, ( gltf ) => {
  2303. let cube = gltf.scene;
  2304. cube.position.set(px,0,pz);
  2305. cube.scale.set(sx,1,sz);
  2306. that.scene.add(cube);
  2307. let md = {
  2308. obj:cube,
  2309. wallDirection:direction,
  2310. spaceId:spaceObj.spaceId,
  2311. quadrant:spaceObj.quadrant,
  2312. rightids:rightids
  2313. };
  2314. that.gltfAutoWalls.push(md);
  2315. // console.log("模型加载成功", that.gltfAutoWalls, spaceObj.spaceId);
  2316. });
  2317. }
  2318. },
  2319. // 墙体缩放逻辑
  2320. wallTransform(spaceObj, direction, moveOut, moveValue){
  2321. console.log(`移动的空间的id:${spaceObj.spaceId};移动方向:${direction};是否外移:${moveOut};移动距离:${moveValue}`)
  2322. },
  2323. updateWallModels(){
  2324. let that = this;
  2325. console.log("开始替换墙体模型", this.leftSpaces, this.rightSpaces, this.gltfWalls);
  2326. let promise_list = [];
  2327. // const gltfWalls = JSON.parse(JSON.stringify(this.gltfWalls))
  2328. this.gltfWalls.forEach((item,index) => {
  2329. promise_list.push(
  2330. new Promise((resolve, reject) => {
  2331. this.loadChangeWallModels(item, resolve);
  2332. })
  2333. )
  2334. });
  2335. Promise.all(promise_list).then(()=>{
  2336. this.$nextTick(()=>{
  2337. let newArr = [];
  2338. const newWalls = that.gltfWalls.filter(it=>{
  2339. return !it.isDidWall
  2340. })
  2341. that.gltfWalls = newWalls;
  2342. console.log("加载完成2",newWalls, newArr, that.gltfWalls, that.wallList);
  2343. })
  2344. })
  2345. },
  2346. }
  2347. }
  2348. </script>
  2349. <style lang="scss" scoped>
  2350. @import "./webgl_rxdz.scss";
  2351. </style>