12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260 |
- function Symbol3D()
- {
- this.canvas;
- this.engine;
- this.scene;
- this.camera;
- this.light;
- this.groundY=-10;
- this.tiledGround;
- this.ground;
- this.skybox;
- this.lock=false;
- this.roomWallMeshes=[];
- this.groundLength=6000;
- this.groundWidth=6000;
- this.doorBottom=60;
- this.windowBottom=100;
- this.doorHeigh=100;
- this.windowHeigh=50;
- this.doorThick=40;
- this.wallHeigh=150;
- this.wallThick=32;
- this.boardThick=16;
- this.baseSymbolThick;
- this.groundMaterial;
- this.skyboxMaterial;
- this.wallmaterial;
- this.floormaterial;
- this.frameMaterial;
- this.doorknobMaterial;
- this.windowframeMaterial;
- this.groundTexture="images/checkerboard.jpg";
- //this.floorStyle={floorTexture:"images/textures/floor/floor0.jpg",floorColor:null,type:0};
- this.floorStyle={floorTexture:"images/textures/floor/floor0.jpg",floorColor:null};
- this.wallTexture=null;
- this.skyTexture="images/textures/skyboxes/sky0";
- this.wallpicture_pre="images/textures/picture/";
- this.meshManager={collidables:[],firstMeshes:[],arrowMeshes:[],selectFurnitureMesh:null,selectMesh:false,editProduct:false,infoSize:15,furnitureScal:0.2,selectCircle:null,rotator:null,angle:0};
- this.paintPlane={id:null,value:null,beginPaint:false,currentId:null};
- this.paintWall={value:null,beginPaint:false};
- this.paintSet=[];
- this.wallSet={submeshes:[],subMaterials:[],verticesStart:0,indexStart:0};
- this.phoSet={start:false,photoFrameMesh:null,phochild:null,pts:null};
-
- };
- Symbol3D.prototype.setwallmaterial = function () {
- this.wallmaterial = new BABYLON.StandardMaterial("wallmaterial", this.scene);
- this.wallmaterial.alpha = 1.0;
- this.wallmaterial.emissiveColor = new BABYLON.Color3(0.8,0.8,0.8);
- this.wallmaterial.backFaceCulling = false;
- };
- Symbol3D.prototype.setgroundmaterial= function ()
- {
- this.groundMaterial = new BABYLON.StandardMaterial("groundmaterial", this.scene);
- this.groundMaterial.diffuseTexture = new BABYLON.Texture(this.groundTexture, this.scene);
- this.groundMaterial.diffuseTexture.uScale = 5.0; //Repeat 5 times on the Vertical Axes
- this.groundMaterial.diffuseTexture.vScale = 5.0; //Repeat 5 times on the Horizont
- };
- Symbol3D.prototype.setskyboxMaterial= function ()
- {
- this.skyboxMaterial = new BABYLON.StandardMaterial("skyBox", this.scene);
- this.skyboxMaterial.backFaceCulling = false;
- this.skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture(this.skyTexture, this.scene);
- this.skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
- this.skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
- this.skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
- this.skyboxMaterial.disableLighting = true;
- };
- Symbol3D.prototype.setframeMaterial= function ()
- {
- this.frameMaterial = new BABYLON.StandardMaterial("frameMaterial", this.scene);
- this.frameMaterial.alpha = 1.0;
- this.frameMaterial.emissiveColor = new BABYLON.Color3(0.7,0.7,0.7);
- this.frameMaterial.backFaceCulling = true;
- };
- Symbol3D.prototype.setwindowframeMaterial= function ()
- {
- this.windowframeMaterial = new BABYLON.StandardMaterial("windowframeMaterial", this.scene);
- this.windowframeMaterial.alpha = 1.0;
- this.windowframeMaterial.emissiveColor = new BABYLON.Color3(0.5,0.5,0.5);
- this.windowframeMaterial.backFaceCulling = true;
- };
- Symbol3D.prototype.setdoorknobMaterial= function ()
- {
- this.doorknobMaterial = new BABYLON.StandardMaterial("doorknobMaterial", this.scene);
- this.doorknobMaterial.alpha = 1.0;
- this.doorknobMaterial.emissiveColor = new BABYLON.Color3(0.1,0.1,0.1);
- this.doorknobMaterial.backFaceCulling = true;
- };
- Symbol3D.prototype.setdoormaterial= function ()
- {
- this.doormaterial = new BABYLON.StandardMaterial("doormaterial", this.scene);
- this.doormaterial.diffuseTexture = new BABYLON.Texture("images/door.png", this.scene);
- this.doormaterial.backFaceCulling = false;
- };
- Symbol3D.prototype.setfloormaterial = function ()
- {
- this.floormaterial = new BABYLON.StandardMaterial("floormaterial", this.scene);
- /*
- if(this.floorStyle.type==0)
- {
- this.floormaterial.diffuseTexture = new BABYLON.Texture(this.floorStyle.floorTexture, this.scene);
- }
- else
- {
- this.floormaterial.diffuseTexture = new BABYLON.Texture(this.floorStyle.floorColor, this.scene);
- }
- */
- this.floormaterial.diffuseTexture = new BABYLON.Texture(this.floorStyle.floorTexture, this.scene);
- this.floormaterial.bumpTexture = new BABYLON.Texture("images/floor1.png", this.scene);
- };
- Symbol3D.prototype.setCamera = function () {
- // Create a rotating camera
-
- this.camera = new BABYLON.ArcRotateCamera("Camera", -Math.PI/2, 0, 1000, BABYLON.Vector3.Zero(), this.scene);
- this.camera.attachControl(this.canvas, true);
- this.camera.lowerBetaLimit = 0.1;
- this.camera.upperBetaLimit = (Math.PI / 2) * 0.99;
- this.camera.lowerRadiusLimit = 125;
- this.camera.checkCollisions = true;
-
- //this.camera = new BABYLON.ArcRotateCamera("Camera", 0.4, 1.2, 20, new BABYLON.Vector3(-10, 0, 0), this.scene);
- };
- Symbol3D.prototype.setFreeCamera=function()
- {
- var followCam = new BABYLON.FollowCamera("fcam", this.camera.position, this.scene);
- //this.followCam.target = mesh;
- followCam.radius = 200;
- followCam.maxCameraSpeed = 10;
- //this.scene.activeCamera = followCam;
- return followCam;
- };
- Symbol3D.prototype.setProductCamera = function (position) {
- // Create a rotating camera
- this.camera.setTarget=position;
- };
- Symbol3D.prototype.createScene = function () {
- // Attach it to handle user inputs (keyboard, mouse, touch)
- this.canvas=document.getElementById('canvas3d');
- this.engine = new BABYLON.Engine(this.canvas, true);
- this.scene = new BABYLON.Scene(this.engine);
- this.setCamera();
-
- // Add a light
-
- this.light = new BABYLON.HemisphericLight("hemi", new BABYLON.Vector3(600, 600, 0), this.scene);
- this.light.diffuse = new BABYLON.Color3(1, 1, 1);
- this.light.specular = new BABYLON.Color3(0, 0, 0);
- this.light.position = new BABYLON.Vector3(250, 400, 0);
- this.light.intensity = 1.8;
-
- //this.light = new BABYLON.SpotLight("Spot0", new BABYLON.Vector3(0, 1000, -10), new BABYLON.Vector3(0, -10, 0), 0.8, 2, this.scene);
- //this.light.diffuse = new BABYLON.Color3(1, 0, 0);
- //this.light.specular = new BABYLON.Color3(1, 1, 1);
-
- //Create a light
- //this.light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(5,200,20), this.scene);
-
- };
- Symbol3D.prototype.addSkybox = function ()
- {
- this.skybox = BABYLON.Mesh.CreateBox("skyBox", 8000, this.scene);
- this.setskyboxMaterial();
- this.skybox.material = this.skyboxMaterial;
- };
- Symbol3D.prototype.refreshSkybox = function () {
- this.setskyboxMaterial();
- this.skybox.material = this.skyboxMaterial;
- };
- Symbol3D.prototype.addGround = function () {
- // make a ground
- this.ground = BABYLON.Mesh.CreateBox("Ground", 1, this.scene);
- this.ground.scaling = new BABYLON.Vector3(this.groundLength, 10, this.groundWidth);
- this.ground.position.y =this.groundY/2
- this.ground.checkCollisions = true;
- this.ground.material = this.groundMaterial;
- };
- Symbol3D.prototype.refreshGround = function () {
-
- this.setgroundmaterial();
- this.ground.material = this.groundMaterial;
- };
- Symbol3D.prototype.drawFloor= function(points,id)
- {
- var shape;
- for(var i=0;i<points.length;++i)
- {
- if(i==0)
- {
- shape = new BABYLON.Path2(points[i].x, points[i].y);
- }
- else
- {
- shape.addLineTo(points[i].x, points[i].y);
- }
- }
-
- var floorPlane = new BABYLON.PolygonMeshBuilder("floorPlane"+this.paintPlane.id, shape, this.scene).build();
- floorPlane.wallid="wall"+id;
- floorPlane.position.y =3;
-
- var flag=false;
- for(var i=0;i<this.paintSet.length;++i)
- {
- if(this.paintSet[i].type=="floor"&&this.paintSet[i].wallId=="wall"+id)
- {
- floorPlane.material=this.paintSet[i].material;
- floorPlane.floorId=this.paintPlane.id;
- flag=true;
- break;
- }
- }
- if(!flag)
- {
- floorPlane.material=this.floormaterial;
- floorPlane.material.hasAlpha=10;
- }
-
- ++this.paintPlane.id;
- this.roomWallMeshes.push(floorPlane);
- return floorPlane;
- };
- Symbol3D.prototype.refreshFloor = function (wallid)
- {
- if(this.paintPlane.currentId!=null)
- {
- var floormaterial = new BABYLON.StandardMaterial("floormaterial", this.scene);
- floormaterial.diffuseTexture = new BABYLON.Texture(this.floorStyle.value, this.scene);
- floormaterial.bumpTexture = new BABYLON.Texture("images/floor1.png", this.scene);
- this.scene.getMeshByID(this.paintPlane.currentId).material=floormaterial;
-
- var flag=false;
- for(var i=0;i<this.paintSet.length;++i)
- {
- if(this.paintSet[i].type=="floor"&&this.paintSet[i].floorId==this.paintPlane.currentId)
- {
- this.paintSet[i].material=floormaterial;
- flag=true;
- break;
- }
- }
- if(!flag)
- {
- this.paintSet.push({wallId:wallid,floorId:this.paintPlane.currentId,material:floormaterial,type:"floor"});
- }
-
- document.getElementById("container3d").style.cursor="default";
- }
- };
- Symbol3D.prototype.getLen = function (type) {
- if(type=="Symbol2D_OpeningWindow")
- {
- return layer.parameter.windowLength[0];
- }
- else if(type=="Symbol2D_OpeningDoor")
- {
- return layer.parameter.doorLength[0];
- }
- else if(type=="Symbol2D_SimpleDoor")
- {
- return layer.parameter.doorLength[1];
- }
- else if(type=="Symbol2D_SingleCasement")
- {
- return layer.parameter.windowLength[1];
- }
- else if(type=="Symbol2D_SlidingDoor")
- {
- return layer.parameter.doorLength[2];
- }
- else if(type=="Symbol2D_SlidingWindow")
- {
- return layer.parameter.windowLength[2];
- }
- else
- {
- return 60;
- }
- };
- Symbol3D.prototype.drawOpenWallSymbols=function(points,symbols,type,id)
- {
- var wallmeshes = [];
- var topWallmeshes=[];
- var pt1,pt2,pt3,pt4,pt5,pt6,pt7,pt8;
-
- this.wallSet.submeshes=[];
- this.wallSet.verticesStart=0;
- this.wallSet.indexStart=0;
- this.wallSet.subMaterials=[];
-
- var outpoints=points.side1;
- var inpoints=points.side2;
-
- var calculateLine=new CalculateLine();
- var towards=[];
- var points=[];
- var collindex=[];
-
- for(var i=0;i<outpoints.length-1;++i)
- {
- pt1=new BABYLON.Vector3(outpoints[i].x, 0, outpoints[i].y);
- pt2=new BABYLON.Vector3(outpoints[i+1].x, 0, outpoints[i+1].y);
- var mesh=this.drawSideWall(pt1,pt2);
-
- pt3=inpoints[i];
- pt4=inpoints[i+1];
- var toward= calculateLine.getToward2(outpoints[i],outpoints[i+1],inpoints[i],inpoints[i+1]);
- towards.push(toward);
- this.meshManager.collidables[this.meshManager.collidables.length-1].toward=toward;
- points.push({point1:outpoints[i],point2:outpoints[i+1]});
- wallmeshes.push(mesh);
- collindex.push(mesh.planindex);
-
- pt5=new BABYLON.Vector3(inpoints[i].x, this.wallHeigh, inpoints[i].y);
- pt6=new BABYLON.Vector3(inpoints[i+1].x, this.wallHeigh, inpoints[i+1].y);
- pt7=new BABYLON.Vector3(outpoints[i].x, this.wallHeigh, outpoints[i].y);
- pt8=new BABYLON.Vector3(outpoints[i+1].x, this.wallHeigh, outpoints[i+1].y);
- mesh=this.drawTopWall(pt5,pt6,pt7,pt8);
- mesh.material=this.wallmaterial;
- topWallmeshes.push(mesh);
- }
-
- pt1=new BABYLON.Vector3(outpoints[outpoints.length-1].x, 0, outpoints[outpoints.length-1].y);
- pt2=new BABYLON.Vector3(inpoints[outpoints.length-1].x, 0, inpoints[outpoints.length-1].y);
- var mesh=this.drawSideWall(pt1,pt2);
- var toward=calculateLine.getToward(outpoints[outpoints.length-1],inpoints[outpoints.length-1],outpoints[outpoints.length-2]);
- towards.push(-1*toward);
- this.meshManager.collidables[this.meshManager.collidables.length-1].toward=-1*toward;
- points.push({point1:outpoints[outpoints.length-1],point2:inpoints[outpoints.length-1]});
- wallmeshes.push(mesh);
- collindex.push(mesh.planindex);
-
- var num=wallmeshes.length-2;
- for(var i=inpoints.length-1;i>0;--i)
- {
- pt1=new BABYLON.Vector3(inpoints[i].x, 0, inpoints[i].y);
- pt2=new BABYLON.Vector3(inpoints[i-1].x, 0, inpoints[i-1].y);
- var toward=-1*towards[num];
- var mesh=this.drawSideWall(pt1,pt2);
- //mesh.toward=toward;
- towards.push(toward);
- this.meshManager.collidables[this.meshManager.collidables.length-1].toward=toward;
- points.push({point1:inpoints[i],point2:inpoints[i-1]});
- --num;
- wallmeshes.push(mesh);
- collindex.push(mesh.planindex);
- }
-
- pt1=new BABYLON.Vector3(inpoints[0].x, 0, inpoints[0].y);
- pt2=new BABYLON.Vector3(outpoints[0].x, 0, outpoints[0].y);
- var mesh=this.drawSideWall(pt1,pt2);
- toward=calculateLine.getToward(inpoints[0],outpoints[0],outpoints[1]);
- towards.push(-1*toward);
- this.meshManager.collidables[this.meshManager.collidables.length-1].toward=-1*toward;
- points.push({point1:inpoints[0],point2:outpoints[0]});
- wallmeshes.push(mesh);
- collindex.push(mesh.planindex);
-
- var _topWallmesh=BABYLON.Mesh.MergeMeshes(topWallmeshes);
- var topCSG = BABYLON.CSG.FromMesh(_topWallmesh);
- var finalTopMesh = topCSG.toMesh("wallopen",this.wallmaterial, this.scene,true);
- _topWallmesh.dispose();
- _topWallmesh=null;
- this.roomWallMeshes.push(finalTopMesh);
-
- var wallmesh=BABYLON.Mesh.MergeMeshes(wallmeshes);
-
- wallmesh.subMeshes = [];
- this.wallSet.subMaterials=[];
- for(var i=0;i<this.wallSet.submeshes.length;++i)
- {
- wallmesh.subMeshes.push(new BABYLON.SubMesh(i, this.wallSet.submeshes[i].verticesStart, this.wallSet.submeshes[i].verticesCount, this.wallSet.submeshes[i].indexStart,this.wallSet.submeshes[i].indexCount, wallmesh));
- var wallmaterial = new BABYLON.StandardMaterial("wall"+i, this.scene);
- wallmaterial.alpha = 1.0;
- wallmaterial.emissiveColor = new BABYLON.Color3(0.8,0.8,0.8);
- wallmaterial.backFaceCulling = false;
- wallmaterial.toward=towards[i];
- wallmaterial.points=points[i];
- wallmaterial.indexplane=collindex[i];
- this.wallSet.subMaterials.push(wallmaterial);
-
- }
-
- var wallCSG =BABYLON.CSG.FromMesh(wallmesh);
-
- if(type==1)
- {
- this.baseSymbolThick=this.wallThick;
- }
- else
- {
- this.baseSymbolThick=this.boardThick;
- }
-
- for(var i=0;i<symbols.length;++i)
- {
- var symMesh;
- //var len=this.getLen(symbols[i].type);
- var len=symbols[i].len;
- if(symbols[i].type=="Symbol2D_OpeningDoor")
- {
- symMesh=this.drawOpeningDoor(symbols[i],len);
- }
- else if(symbols[i].type=="Symbol2D_OpeningWindow")
- {
- symMesh=this.drawOpeningWindow(symbols[i],len);
- }
- else if(symbols[i].type=="Symbol2D_SimpleDoor")
- {
- symMesh=this.drawSimpleDoor(symbols[i],len);
- }
- else if(symbols[i].type=="Symbol2D_SingleCasement")
- {
- symMesh=this.drawSingleCasement(symbols[i],len);
- }
- else if(symbols[i].type=="Symbol2D_SlidingDoor")
- {
- symMesh=this.drawSlidingDoor(symbols[i],len);
- }
- else if(symbols[i].type=="Symbol2D_SlidingWindow")
- {
- symMesh=this.drawSlidingWindow(symbols[i],len);
- }
- else
- {
- continue;
- }
- var symCSG = BABYLON.CSG.FromMesh(symMesh);
- wallCSG = wallCSG.subtract(symCSG);
- symMesh.dispose();
- }
- var wall = wallCSG.toMesh("wall"+id,null, this.scene,true);
- var multi=new BABYLON.MultiMaterial("material"+id,this.scene);
- multi.subMaterials=this.wallSet.subMaterials;
-
- wall.material=multi;
-
- for(var i=0;i<this.paintSet.length;++i)
- {
- if(this.paintSet[i].type=="wall"&&this.paintSet[i].wallId==wall.id&&this.wallSet.subMaterials.length>this.paintSet[i].materialId)
- {
- wall.material.subMaterials[this.paintSet[i].materialId]=this.paintSet[i].material;
- //break;
- }
- }
-
- wallmesh.dispose();
- wallmesh=null;
- this.roomWallMeshes.push(wall);
- //this.meshManager.collidables.push(wall);
-
- };
- Symbol3D.prototype.drawSingleWall=function(pt1,pt2,pt3,pt4)
- {
- var mesh = new BABYLON.Mesh("mesh", this.scene);
- mesh.material = this.wallmaterial;
-
- var path1 = [];
- var path2 = [];
-
- path1.push(pt1);
- path1.push(pt2);
-
- path2.push(pt3);
- path2.push(pt4);
-
- // positions
- var positions = [];
- for (var i = 0; i < path1.length; i++) {
- positions.push(path1[i].x, path1[i].y, path1[i].z);
- positions.push(path2[i].x, path2[i].y, path2[i].z);
- };
- // indices
- var indices = [];
- for (var i = 0; i < path1.length * 2 - 2 ; i+=2) {
- indices.push(i, i+1, i+2);
- indices.push(i+3, i+2, i+1);
- };
-
- // normals
- var normals = [];
- BABYLON.VertexData.ComputeNormals(positions, indices, normals);
- // mesh
- var colors = [
- 1, 0, 0, 1,
- 0, 1, 0, 1,
- 0, 1, 0, 0,
- 0, 0, 1, 0,
- ];
- mesh.setVerticesData(BABYLON.VertexBuffer.ColorKind, colors);
- var uvs=[[0,0],[1,0],[1,1],[0,1]];
- mesh.setVerticesData(BABYLON.VertexBuffer.UVKind, uvs);
- mesh.setVerticesData(BABYLON.VertexBuffer.PositionKind, positions, false);
- mesh.setVerticesData(BABYLON.VertexBuffer.NormalKind, normals, false);
- mesh.setVerticesData(BABYLON.VertexBuffer.MatricesIndicesKind, uvs, false);
- mesh.setVerticesData(BABYLON.VertexBuffer.MatricesIndicesKind, uvs, false);
- mesh.setIndices(indices);
- return mesh;
- };
- Symbol3D.prototype.drawTopWall=function(pt1,pt2,pt3,pt4)
- {
- var mesh = new BABYLON.Mesh("mesh", this.scene);
- //mesh.material = this.wallmaterial;
-
- var path1 = [];
- var path2 = [];
-
- path1.push(pt1);
- path1.push(pt2);
-
- path2.push(pt3);
- path2.push(pt4);
-
- // positions
- var positions = [];
- for (var i = 0; i < path1.length; i++) {
- positions.push(path1[i].x, path1[i].y, path1[i].z);
- positions.push(path2[i].x, path2[i].y, path2[i].z);
- };
- // indices
- var indices = [];
- for (var i = 0; i < path1.length * 2 - 2 ; i+=2) {
- indices.push(i, i+1, i+2);
- indices.push(i+3, i+2, i+1);
- };
-
- // normals
- var normals = [];
- BABYLON.VertexData.ComputeNormals(positions, indices, normals);
- // mesh
- var colors = [
- 1, 0, 0, 1,
- 0, 1, 0, 1,
- 0, 1, 0, 0,
- 0, 0, 1, 0,
- ];
- mesh.setVerticesData(BABYLON.VertexBuffer.ColorKind, colors);
- var uvs=[[0,0],[1,0],[1,1],[0,1]];
- mesh.setVerticesData(BABYLON.VertexBuffer.UVKind, uvs);
- mesh.setVerticesData(BABYLON.VertexBuffer.PositionKind, positions, false);
- mesh.setVerticesData(BABYLON.VertexBuffer.NormalKind, normals, false);
- mesh.setVerticesData(BABYLON.VertexBuffer.MatricesIndicesKind, uvs, false);
- mesh.setIndices(indices);
- mesh.material = this.wallmaterial;
- return mesh;
- };
- Symbol3D.prototype.drawSideWall=function(pt1,pt2)
- {
- var mesh = new BABYLON.Mesh("mesh", this.scene);
- //mesh.material = this.wallmaterial;
- this.createwallPlane(new BABYLON.Vector2(pt1.x,pt1.z),new BABYLON.Vector2(pt2.x,pt2.z));
-
- var path1 = [];
- var path2 = [];
-
- path1.push(pt1);
- path1.push(pt2);
-
- var pt3=new BABYLON.Vector3(pt1.x,this.wallHeigh, pt1.z);
- var pt4=new BABYLON.Vector3(pt2.x,this.wallHeigh, pt2.z);
-
- path2.push(pt3);
- path2.push(pt4);
-
- // positions
- var positions = [];
- for (var i = 0; i < path1.length; i++) {
- positions.push(path1[i].x, path1[i].y, path1[i].z);
- positions.push(path2[i].x, path2[i].y, path2[i].z);
- };
- // indices
- var indices = [];
- for (var i = 0; i < path1.length * 2 - 2 ; i+=2) {
- indices.push(i, i+1, i+2);
- indices.push(i+3, i+2, i+1);
- };
-
- // normals
- var normals = [];
- BABYLON.VertexData.ComputeNormals(positions, indices, normals);
-
- var uvs=[[0,0],[1,0],[1,1],[0,1]];
- mesh.setVerticesData(BABYLON.VertexBuffer.UVKind, uvs);
-
- var colors = [
- 1, 0, 0, 1,
- 0, 1, 0, 1,
- 0, 1, 0, 0,
- 0, 0, 1, 0,
- ];
-
- // mesh
- mesh.setVerticesData(BABYLON.VertexBuffer.ColorKind, colors);
- mesh.setVerticesData(BABYLON.VertexBuffer.PositionKind, positions, false);
- mesh.setVerticesData(BABYLON.VertexBuffer.NormalKind, normals, false);
- mesh.setIndices(indices);
- mesh.setVerticesData(BABYLON.VertexBuffer.MatricesIndicesKind, uvs, false);
- mesh.material = this.wallmaterial;
- this.wallSet.submeshes.push({verticesStart:this.wallSet.verticesStart, verticesCount:mesh.getTotalVertices(), indexStart:this.wallSet.indexStart, indexCount:mesh.getTotalIndices()});
- this.wallSet.verticesStart+=mesh.getTotalVertices();
- this.wallSet.indexStart+=mesh.getTotalIndices();
-
- mesh.planindex=this.meshManager.collidables.length-1;
- return mesh;
- };
- Symbol3D.prototype.drawCloseWallSymbols=function(outpoints,inpoints,symbols,type,id)
- {
- var wallmeshes = [];
- var topWallmeshes=[];
- var pt1,pt2,pt3,pt4,pt5,pt6,pt7,pt8;
-
- this.wallSet.submeshes=[];
- this.wallSet.verticesStart=0;
- this.wallSet.indexStart=0;
- this.wallSet.subMaterials=[];
-
- var calculateLine=new CalculateLine();
- var towards=[];
- var points=[];
- var collindex=[];
-
- for(var i=0;i<outpoints.length;++i)
- {
- if(i==outpoints.length-1)
- {
- pt1=new BABYLON.Vector3(outpoints[0].x, 0, outpoints[0].y);
- pt2=new BABYLON.Vector3(outpoints[outpoints.length-1].x, 0, outpoints[outpoints.length-1].y);
- var mesh=this.drawSideWall(pt2,pt1);
- wallmeshes.push(mesh);
- collindex.push(mesh.planindex);
-
- pt3=new BABYLON.Vector3(inpoints[0].x, 0, inpoints[0].y);
- pt4=new BABYLON.Vector3(inpoints[inpoints.length-1].x, 0, inpoints[inpoints.length-1].y);
-
- var toward= calculateLine.getToward2(outpoints[0],outpoints[outpoints.length-1],inpoints[0],inpoints[inpoints.length-1]);
- towards.push(toward);
- this.meshManager.collidables[this.meshManager.collidables.length-1].toward=toward;
- points.push({point1:outpoints[0],point2:outpoints[outpoints.length-1]});
-
- mesh=this.drawSideWall(pt3,pt4);
- //mesh.toward=-1*toward;
- towards.push(-1*toward);
- this.meshManager.collidables[this.meshManager.collidables.length-1].toward=-1*toward;
- points.push({point1:inpoints[0],point2:inpoints[inpoints.length-1]});
- wallmeshes.push(mesh);
- collindex.push(mesh.planindex);
-
- pt5=new BABYLON.Vector3(inpoints[inpoints.length-1].x, this.wallHeigh, inpoints[inpoints.length-1].y);
- pt6=new BABYLON.Vector3(inpoints[0].x, this.wallHeigh, inpoints[0].y);
- pt7=new BABYLON.Vector3(outpoints[outpoints.length-1].x, this.wallHeigh, outpoints[outpoints.length-1].y);
- pt8=new BABYLON.Vector3(outpoints[0].x, this.wallHeigh, outpoints[0].y);
- mesh=this.drawTopWall(pt5,pt6,pt7,pt8);
- mesh.material=this.wallmaterial;
- topWallmeshes.push(mesh);
- }
- else
- {
- pt1=new BABYLON.Vector3(outpoints[i].x, 0, outpoints[i].y);
- pt2=new BABYLON.Vector3(outpoints[i+1].x, 0, outpoints[i+1].y);
- var mesh=this.drawSideWall(pt1,pt2);
- wallmeshes.push(mesh);
- collindex.push(mesh.planindex);
-
- pt3=new BABYLON.Vector3(inpoints[i].x, 0, inpoints[i].y);
- pt4=new BABYLON.Vector3(inpoints[i+1].x, 0, inpoints[i+1].y);
-
- //var toward= calculateLine.getToward2(pt1,pt2,pt3,pt4);
- var toward= calculateLine.getToward2(outpoints[i],outpoints[i+1],inpoints[i],inpoints[i+1]);
- //mesh.toward=toward;
- points.push({point1:outpoints[i],point2:outpoints[i+1]});
- towards.push(toward);
- this.meshManager.collidables[this.meshManager.collidables.length-1].toward=toward;
-
- mesh=this.drawSideWall(pt3,pt4);
- //mesh.toward=-1*toward;
- points.push({point1:inpoints[i],point2:inpoints[i+1]});
- towards.push(-1*toward);
- this.meshManager.collidables[this.meshManager.collidables.length-1].toward=-1*toward;
- wallmeshes.push(mesh);
- collindex.push(mesh.planindex);
-
- pt5=new BABYLON.Vector3(inpoints[i].x, this.wallHeigh, inpoints[i].y);
- pt6=new BABYLON.Vector3(inpoints[i+1].x, this.wallHeigh, inpoints[i+1].y);
- pt7=new BABYLON.Vector3(outpoints[i].x, this.wallHeigh, outpoints[i].y);
- pt8=new BABYLON.Vector3(outpoints[i+1].x, this.wallHeigh, outpoints[i+1].y);
- mesh=this.drawTopWall(pt5,pt6,pt7,pt8);
- mesh.material=this.wallmaterial;
- topWallmeshes.push(mesh);
- }
- }
- var _topWallmesh=BABYLON.Mesh.MergeMeshes(topWallmeshes);
- var topCSG = BABYLON.CSG.FromMesh(_topWallmesh);
- var finalTopMesh = topCSG.toMesh("walltop",this.wallmaterial, this.scene,true);
- _topWallmesh.dispose();
- _topWallmesh=null;
- this.roomWallMeshes.push(finalTopMesh);
-
- var wallmesh=BABYLON.Mesh.MergeMeshes(wallmeshes);
- wallmesh.subMeshes = [];
- this.wallSet.subMaterials=[];
- for(var i=0;i<this.wallSet.submeshes.length;++i)
- {
- wallmesh.subMeshes.push(new BABYLON.SubMesh(i, this.wallSet.submeshes[i].verticesStart, this.wallSet.submeshes[i].verticesCount, this.wallSet.submeshes[i].indexStart,this.wallSet.submeshes[i].indexCount, wallmesh));
- var wallmaterial = new BABYLON.StandardMaterial("wall"+i, this.scene);
- wallmaterial.alpha = 1.0;
- wallmaterial.emissiveColor = new BABYLON.Color3(0.8,0.8,0.8);
- wallmaterial.backFaceCulling = false;
- wallmaterial.toward=towards[i];
- wallmaterial.points=points[i];
- wallmaterial.indexplane=collindex[i];
- this.wallSet.subMaterials.push(wallmaterial);
- }
-
- var wallCSG =BABYLON.CSG.FromMesh(wallmesh);
-
- if(type==1)
- {
- this.baseSymbolThick=this.wallThick;
- }
- else
- {
- this.baseSymbolThick=this.boardThick;
- }
-
- for(var i=0;i<symbols.length;++i)
- {
- var symMesh;
- //var len=this.getLen(symbols[i].type);
- var len=symbols[i].len;
- if(symbols[i].type=="Symbol2D_OpeningDoor")
- {
- symMesh=this.drawOpeningDoor(symbols[i],len);
- }
- else if(symbols[i].type=="Symbol2D_OpeningWindow")
- {
- symMesh=this.drawOpeningWindow(symbols[i],len);
- }
- else if(symbols[i].type=="Symbol2D_SimpleDoor")
- {
- symMesh=this.drawSimpleDoor(symbols[i],len);
- }
- else if(symbols[i].type=="Symbol2D_SingleCasement")
- {
- symMesh=this.drawSingleCasement(symbols[i],len);
- }
- else if(symbols[i].type=="Symbol2D_SlidingDoor")
- {
- symMesh=this.drawSlidingDoor(symbols[i],len);
- }
- else if(symbols[i].type=="Symbol2D_SlidingWindow")
- {
- symMesh=this.drawSlidingWindow(symbols[i],len);
- }
- else
- {
- continue;
- }
- var symCSG = BABYLON.CSG.FromMesh(symMesh);
- wallCSG = wallCSG.subtract(symCSG);
- symMesh.dispose();
- }
- var wall = wallCSG.toMesh("wall"+id,null, this.scene,true);
- var multi=new BABYLON.MultiMaterial("material"+id,this.scene);
- multi.subMaterials=this.wallSet.subMaterials;
- wall.material=multi;
- wallmesh.dispose();
- wallmesh=null;
-
- for(var i=0;i<this.paintSet.length;++i)
- {
- if(this.paintSet[i].type=="wall"&&this.paintSet[i].wallId==wall.id&&this.wallSet.subMaterials.length>this.paintSet[i].materialId)
- {
- wall.material.subMaterials[this.paintSet[i].materialId]=this.paintSet[i].material;
- //break;
- }
- }
- this.roomWallMeshes.push(wall);
- };
- Symbol3D.prototype.extendedline=function(point,point1)
- {
- var dx=point.x-point1.x;
- var dy=point.y-point1.y;
- while(Math.abs(dx)>10||Math.abs(dx)>10)
- {
- dx/=10;
- dy/=10;
- }
- var dpoint={x:dx,y:dy};
- return dpoint;
- };
- Symbol3D.prototype.showPicture=function(src)
- {
- var plan = BABYLON.Mesh.CreatePlane("picture-"+src, 1, this.scene);
- plan.scaling.x=50;
- plan.scaling.y=40;
- plan.position=new BABYLON.Vector3(0, 0, 0);
- var material = new BABYLON.StandardMaterial("planmaterial", this.scene);
- material.diffuseTexture = new BABYLON.Texture(this.wallpicture_pre+src, this.scene);
- material.bumpTexture = new BABYLON.Texture("images/floor1.png", this.scene);
- plan.material=material;
- plan.rotation.x=Math.PI/2;
- this.meshManager.collidables.push(plan);
- };
- Symbol3D.prototype.showPhoFrame=function(src)
- {
- BABYLON.SceneLoader.ImportMesh("", "images/3d/", src, this.scene, function (newMeshes)
- {
- newMeshes[0].scaling=new BABYLON.Vector3(this.meshManager.furnitureScal,this.meshManager.furnitureScal,this.meshManager.furnitureScal);
-
- newMeshes[0].computeWorldMatrix(true);
- newMeshes[0].refreshBoundingInfo();
-
- newMeshes[0].position=new BABYLON.Vector3(0,-100,0);
- newMeshes[0].name="pho-"+src;
- newMeshes[0].thice=Math.abs(newMeshes[0]._boundingInfo.boundingBox.maximumWorld.z-newMeshes[0]._boundingInfo.boundingBox.minimumWorld.z);
- newMeshes[0].firstHeigh=Math.abs(newMeshes[0]._boundingInfo.boundingBox.maximumWorld.y-newMeshes[0]._boundingInfo.boundingBox.minimumWorld.y);
- if(this.phoSet.photoFrameMesh!=null)
- {
- this.phoSet.photoFrameMesh.dispose();
- this.phoSet.photoFrameMesh=null;
- }
- this.phoSet.photoFrameMesh=newMeshes[0];
- //this.phoSet.photoFrameMesh.showBoundingBox=true;
- this.phoSet.photoFrameMesh.height=newMeshes[0].firstHeigh;
- this.phoSet.photoFrameMesh.length=Math.abs(newMeshes[0]._boundingInfo.boundingBox.maximumWorld.x-newMeshes[0]._boundingInfo.boundingBox.minimumWorld.x);
- this.phoSet.photoFrameMesh.visibility=0;
- this.phoSet.start=true;
- document.getElementById("container3d").style.cursor="url('images/brush.ico'),auto";
- for(var i=0;i<this.phoSet.photoFrameMesh._boundingInfo.boundingBox.vectorsWorld.length;++i)
- {
- if(this.phoSet.photoFrameMesh._boundingInfo.boundingBox.vectorsWorld[i].z>this.phoSet.photoFrameMesh._boundingInfo.boundingBox.minimumWorld.z)
- {
- this.phoSet.photoFrameMesh.frontindex=i;
- break;
- }
- }
-
-
- /*
- var point1=new BABYLON.Vector3(this.phoSet.photoFrameMesh._boundingInfo.boundingBox.minimumWorld.x, -100, this.phoSet.photoFrameMesh._boundingInfo.boundingBox.maximumWorld.z);
- var point2=new BABYLON.Vector3(this.phoSet.photoFrameMesh._boundingInfo.boundingBox.maximumWorld.x, -100, this.phoSet.photoFrameMesh._boundingInfo.boundingBox.maximumWorld.z);
- var point3=new BABYLON.Vector3(this.phoSet.photoFrameMesh._boundingInfo.boundingBox.minimumWorld.x, -100, this.phoSet.photoFrameMesh._boundingInfo.boundingBox.maximumWorld.z);
- var point4=new BABYLON.Vector3(this.phoSet.photoFrameMesh._boundingInfo.boundingBox.maximumWorld.x, -100, this.phoSet.photoFrameMesh._boundingInfo.boundingBox.maximumWorld.z);
- this.phoSet.photoFrameMesh.pts={point1:{x:point1.x,y:point1.z},point2:{x:point2.x,y:point2.z},point3:point3,point4:point4};
- */
- this.engine.hideLoadingUI();
- }.bind(this));
- };
- Symbol3D.prototype.showProductfirst=function(src,position,rotation)
- {
- BABYLON.SceneLoader.ImportMesh("", "images/3d/", src, this.scene, function (newMeshes)
- {
- var mesh;
- if(newMeshes.length>1)
- {
- mesh=BABYLON.Mesh.MergeMeshes(newMeshes);
- }
- else
- {
- mesh=newMeshes[0];
- }
- mesh.scaling=new BABYLON.Vector3(this.meshManager.furnitureScal,this.meshManager.furnitureScal,this.meshManager.furnitureScal);
- mesh.position=position;
- mesh.rotation=rotation;
- mesh.name=src;
-
- for(var i=0;i<this.meshManager.collidables.length;++i)
- {
- if (typeof(this.meshManager.collidables[i]) == "undefined") {
- this.meshManager.collidables.splice(i,1);
- --i;
- continue;
- }
- if (mesh.intersectsMesh(this.meshManager.collidables[i], true))
- {
- this.meshManager.firstMeshes.push(src)
- break;
- }
- }
- ++initMesh;
- if(initMesh>5)
- {
- this.engine.hideLoadingUI();
- }
- this.meshManager.collidables.push(mesh);
- }.bind(this));
- return this.meshManager.collidables[this.meshManager.collidables.length-1];
- };
- Symbol3D.prototype.showProduct=function(src)
- {
- this.engine.displayLoadingUI();
- this.engine.loadingUIText = "正在加载家具,请稍等!";
- //this.engine.loadingUIBackgroundColor = "red";
- BABYLON.SceneLoader.ImportMesh("", "images/3d/", src, this.scene, function (newMeshes)
- {
- var mesh;
- if(newMeshes.length>1)
- {
- mesh=BABYLON.Mesh.MergeMeshes(newMeshes);
- }
- else
- {
- mesh=newMeshes[0];
- }
- //mesh.scaling=new BABYLON.Vector3(this.meshManager.furnitureScal,this.meshManager.furnitureScal,this.meshManager.furnitureScal);
- mesh.scaling=new BABYLON.Vector3(10,10,10);
- //mesh.position=new BABYLON.Vector3(0, 60, 0);
- //newMeshes[0].showBoundingBox=true;
- mesh.name=src;
-
- for(var i=0;i<this.meshManager.collidables.length;++i)
- {
- if (typeof(this.meshManager.collidables[i]) == "undefined") {
- this.meshManager.collidables.splice(i,1);
- --i;
- continue;
- }
- if (mesh.intersectsMesh(this.meshManager.collidables[i], true))
- {
- this.meshManager.firstMeshes.push(src)
- break;
- }
- }
- this.meshManager.collidables.push(mesh);
- //div.style.display="none";
- this.engine.hideLoadingUI();
- }.bind(this));
- /*
- * <div style="position: absolute; left: 0px; top: 50%; margin-top: 80px; width: 100%; height: 20px; font-family: Arial; font-size: 14px; color: white; text-align: center;">Bitte haben Sie einen Moment Geduld, die benötigten Daten werden geladen...</div>
- * */
- };
- Symbol3D.prototype.boxify=function (positions,blankmesh) {
- var box, boxmat;
- for (var i=0;i<positions.length;i+=3) {
- box = BABYLON.Mesh.CreateBox("box"+String(i), 10, this.scene);
- box.position = new BABYLON.Vector3(positions[i], positions[i+1], positions[i+2]);
- boxmat = new BABYLON.StandardMaterial("boxmat", this.scene);
- // new DynamicTexture(name, options, scene, generateMipMaps)
- boxmat.emissiveTexture = new BABYLON.DynamicTexture("dt", 512, this.scene, true);
- // drawText(text, x, y, font, color, clearColor, invertY)
- if (i<300) {
- boxmat.emissiveTexture.drawText((i/3<10?" "+String(i/3):String(i/3)), 10, 340, "bold 250pt verdana", "white", "blue", 1);
- }
- else {
- boxmat.emissiveTexture.drawText(String(i/3), 10, 340, "bold 160pt verdana", "white", "blue", 1);
- }
- box.material = boxmat;
- box.parent = blankmesh;
- }
- };
- /*
- Symbol3D.prototype.createwallPlane=function (point1,point2) {
- var p1=new BABYLON.Vector2(point1.x, point1.y);
- var p2=new BABYLON.Vector2(point2.x, point2.y);
- var distance= BABYLON.Vector2.Distance(p1,p2);
- var plan = BABYLON.Mesh.CreatePlane("plane", distance, this.scene);
- plan.material = this.wallmaterial;
- plan.scaling.y = this.wallHeigh;
- plan.position=new BABYLON.Vector3((p1.x+p2.x)/2,0, (p1.y+p2.y)/2);
- var angle=BABYLON.Angle.BetweenTwoPoints(p1,p2);
- plan.rotation.y=-angle._radians;
- //plan.visibility=0;
- this.meshManager.collidables.push(plan);
- };
- */
- Symbol3D.prototype.createwallPlane=function (point1,point2) {
- var p1=new BABYLON.Vector2(point1.x, point1.y);
- var p2=new BABYLON.Vector2(point2.x, point2.y);
- var distance= BABYLON.Vector2.Distance(p1,p2);
- //var plan = BABYLON.Mesh.CreatePlane("plane", distance, this.scene);
- var plan = BABYLON.Mesh.CreatePlane("plane", 1, this.scene);
- plan.scaling.x=distance;
- //plan.scaling.y =1;
- plan.scaling.y =this.wallHeigh;
- plan.material = this.wallmaterial;
-
- //plan.position=new BABYLON.Vector3((p1.x+p2.x)/2,0.5, (p1.y+p2.y)/2);
- plan.position=new BABYLON.Vector3((p1.x+p2.x)/2,this.wallHeigh/2, (p1.y+p2.y)/2);
- var angle=BABYLON.Angle.BetweenTwoPoints(p1,p2);
- plan.rotation.y=-angle._radians;
- plan.visibility=0;
- plan.pts={point1:point1,point2:point2};
- plan.planindex=this.meshManager.collidables.length;
- this.meshManager.collidables.push(plan);
- //plan.dispose();
- };
- /*
- Symbol3D.prototype.drawCloseWall = function (outpoints,inpoints,flag) {
- var shape=[];
- var shape2=[];
- for(var i=0;i<outpoints.length;++i)
- {
- var pt=new BABYLON.Vector3(outpoints[i].x, outpoints[i].y, 0);
- shape.push(pt);
- if(i!=outpoints.length-1)
- {
- this.createwallPlane(outpoints[i],outpoints[i+1]);
- }
- else
- {
- if(flag)
- {
- this.createwallPlane(outpoints[i],outpoints[0]);
- }
- }
- }
- shape.push(new BABYLON.Vector3(outpoints[0].x, outpoints[0].y, 0));
-
- for(var i=0;i<inpoints.length;++i)
- {
- var pt=new BABYLON.Vector3(inpoints[i].x, inpoints[i].y, 0);
- shape2.push(pt);
- if(i!=inpoints.length-1)
- {
- this.createwallPlane(inpoints[i],inpoints[i+1]);
- }
- else
- {
- if(flag)
- {
- this.createwallPlane(inpoints[i],inpoints[0]);
- }
- }
- }
- shape2.push(new BABYLON.Vector3(inpoints[0].x, inpoints[0].y, 0));
-
- var path = [
- new BABYLON.Vector3(0,0,0),
- new BABYLON.Vector3(0, 0, this.wallHeigh)
- ];
-
- var extruded2 = BABYLON.Mesh.ExtrudeShape("extruded2", shape2, path, 1, 0, 3, this.scene);
- var extruded = BABYLON.Mesh.ExtrudeShape("extruded", shape, path, 1, 0, 3, this.scene);
- var aCSG = BABYLON.CSG.FromMesh(extruded);
- var bCSG = BABYLON.CSG.FromMesh(extruded2);
- extruded.dispose();
- extruded2.dispose();
- //extruded.rotation.x = Math.PI / 2;
- //extruded2.rotation.x = Math.PI / 2;
- //extruded2.position=new BABYLON.Vector3(0, this.wallHeigh,0);
- //extruded.position=new BABYLON.Vector3(0, this.wallHeigh,0);
- var subCSG = bCSG.subtract(aCSG);
- return subCSG;
- };
- */
- Symbol3D.prototype.addSymbol = function () {
- // Meshes
- var blueBox = BABYLON.Mesh.CreateBox("blue", 16, this.scene);
- var blueMat = new BABYLON.StandardMaterial("ground", this.scene);
- blueMat.diffuseColor = new BABYLON.Color3(0.4, 0.4, 0.4);
- blueMat.specularColor = new BABYLON.Color3(0.4, 0.4, 0.4);
- blueMat.emissiveColor = BABYLON.Color3.Blue();
- blueBox.material = blueMat;
- blueBox.position.x += 20;
- blueBox.position.y = 8;
- blueBox.position.z -= 10;
- blueBox.ellipsoid = new BABYLON.Vector3(blueBox.getBoundingInfo().boundingBox.extendSize.x*blueBox.scaling.x,0.0001,blueBox.getBoundingInfo().boundingBox.extendSize.z*blueBox.scaling.z);
- blueBox.checkCollisions = true;
- //blueBox.showSubMeshesBoundingBox =true;
- var redBox = BABYLON.Mesh.CreateBox("red", 16, this.scene);
- var blueMat = new BABYLON.StandardMaterial("ground", this.scene);
- blueMat.diffuseColor = new BABYLON.Color3(0.4, 0.4, 0.4);
- blueMat.specularColor = new BABYLON.Color3(0.4, 0.4, 0.4);
- blueMat.emissiveColor = BABYLON.Color3.Red();
- redBox.material = blueMat;
- redBox.position.x -= 60;
- redBox.position.y = 8;
- redBox.ellipsoid = new BABYLON.Vector3(redBox.getBoundingInfo().boundingBox.extendSize.x*redBox.scaling.x,0.0001,redBox.getBoundingInfo().boundingBox.extendSize.z*redBox.scaling.z);
- redBox.checkCollisions = true;
- blueBox.checkCollisions = true;
- blueBox.applyGravity = true;
- redBox.checkCollisions = true;
- redBox.applyGravity = true;
- this.collidables.push(blueBox);
- this.collidables.push(redBox);
- };
- Symbol3D.prototype.clearSymbol=function()
- {
-
- for(var i=0;i<this.meshManager.collidables.length;++i)
- {
- if(this.meshManager.collidables[i].name=="plane")
- {
- this.meshManager.collidables[i].dispose();
- this.meshManager.collidables.splice(i, 1);
- --i;
- }
-
- }
-
- for(var i=0;i<this.roomWallMeshes.length;++i)
- {
- this.roomWallMeshes[i].dispose();
- }
- };
- Symbol3D.prototype.drawOpeningDoor= function(location,len)
- {
- var cubeMesh = BABYLON.Mesh.CreateBox( "OpeningDoor", 1, this.scene);
- //cubeMesh.scaling=new BABYLON.Vector3(this.baseSymbolThick,len/2,);
- //baseSymbolThick是30,doorHeigh是100,len是60
- cubeMesh.scaling=new BABYLON.Vector3(len,this.doorHeigh,this.baseSymbolThick);
- cubeMesh.position=new BABYLON.Vector3(location.point.x, this.doorBottom,location.point.y);
- cubeMesh.rotation.y=-location.angle;
- return cubeMesh;
- };
- Symbol3D.prototype.drawOpeningWindow= function(location,len)
- {
- var cubeMesh = BABYLON.Mesh.CreateBox( "OpeningWindow", 1, this.scene);
- //baseSymbolThick是30,windowHeigh是50,len是40
- cubeMesh.scaling=new BABYLON.Vector3(len,this.windowHeigh,this.baseSymbolThick);
- cubeMesh.position=new BABYLON.Vector3(location.point.x, this.windowBottom,location.point.y);
- cubeMesh.rotation.y=-location.angle;
- return cubeMesh;
- };
- Symbol3D.prototype.drawSimpleDoor= function(location,len)
- {
- var cubeMesh = BABYLON.Mesh.CreateBox( "SimpleDoor", 1, this.scene);
- cubeMesh.scaling=new BABYLON.Vector3(len,this.doorHeigh,this.doorThick);
- cubeMesh.position=new BABYLON.Vector3(location.point.x,this.doorBottom,location.point.y);
- cubeMesh.rotation.y=-location.angle;
- var cubeMesh2 = BABYLON.Mesh.CreateBox( "SimpleDoor", 1, this.scene);
- cubeMesh2.scaling=new BABYLON.Vector3(len,this.doorHeigh,this.baseSymbolThick+1);
- var aCSG = BABYLON.CSG.FromMesh(cubeMesh2);
-
- var cubeMesh4 = BABYLON.Mesh.CreateBox( "SimpleDoor", 1, this.scene);
- cubeMesh4.scaling=new BABYLON.Vector3(len-10,this.doorHeigh-10,this.baseSymbolThick+1);
- var bCSG = BABYLON.CSG.FromMesh(cubeMesh4);
- var subCSG = aCSG.subtract(bCSG);
- var newMesh = subCSG.toMesh("Door", this.frameMaterial, this.scene);
- newMesh.position=new BABYLON.Vector3(location.point.x,this.doorBottom,location.point.y);
- newMesh.rotation.y=-location.angle;
- //newMesh.rotation.x = Math.PI / 2;
- this.roomWallMeshes.push(newMesh);
- cubeMesh4.dispose();
- cubeMesh2.dispose();
-
- if(this.doormaterial==null)
- {
- this.setdoormaterial();
- }
- var cubeMesh3 = BABYLON.Mesh.CreateBox( "SimpleDoor", 1, this.scene);
- cubeMesh3.scaling=new BABYLON.Vector3(len-10,20,this.doorHeigh-10);
- cubeMesh3.position=new BABYLON.Vector3(location.point.x,this.doorBottom,location.point.y);
- cubeMesh3.rotation.y=-location.angle;
- cubeMesh3.rotation.x = Math.PI / 2;
- cubeMesh3.material=this.doormaterial;
- this.roomWallMeshes.push(cubeMesh3);
- if(this.doorknobMaterial==null)
- {
- this.setdoorknobMaterial();
- }
- var cubeMesh5=BABYLON.Mesh.CreateBox( "Doorknob", 1, this.scene);
- cubeMesh5.scaling=new BABYLON.Vector3(10,2,22);
- cubeMesh5.position=new BABYLON.Vector3(location.point.x+20*Math.cos(location.angle),this.doorBottom,location.point.y+20*Math.sin(location.angle));
- cubeMesh5.rotation.y=-location.angle;
- //cubeMesh5.rotation.x = Math.PI / 2;
- cubeMesh5.material=this.doorknobMaterial;
- this.roomWallMeshes.push(cubeMesh5);
-
- return cubeMesh;
- };
- Symbol3D.prototype.drawSingleCasement= function(location,len)
- {
- var cubeMesh = BABYLON.Mesh.CreateBox( "SingleWindow", 1, this.scene);
- cubeMesh.scaling=new BABYLON.Vector3(len,this.windowHeigh,this.doorThick);
- cubeMesh.position=new BABYLON.Vector3(location.point.x,this.windowBottom,location.point.y);
- cubeMesh.rotation.y=-location.angle;
- var cubeMesh2 = BABYLON.Mesh.CreateBox( "SingleWindow", 1, this.scene);
- cubeMesh2.scaling=new BABYLON.Vector3(len,this.windowHeigh,this.baseSymbolThick+1);
- var aCSG = BABYLON.CSG.FromMesh(cubeMesh2);
-
- var cubeMesh4 = BABYLON.Mesh.CreateBox( "SingleWindow", 1, this.scene);
- cubeMesh4.scaling=new BABYLON.Vector3(len-10,this.windowHeigh-10,this.baseSymbolThick+1);
- var bCSG = BABYLON.CSG.FromMesh(cubeMesh4);
- var subCSG = aCSG.subtract(bCSG);
- var newMesh = subCSG.toMesh("Window", this.frameMaterial, this.scene);
- newMesh.position=new BABYLON.Vector3(location.point.x,this.windowBottom,location.point.y);
- newMesh.rotation.y=-location.angle;
- //newMesh.rotation.x = Math.PI / 2;
- this.roomWallMeshes.push(newMesh);
- cubeMesh4.dispose();
- cubeMesh2.dispose();
-
- if(this.windowframeMaterial==null)
- {
- this.setwindowframeMaterial();
- }
- var cubeMesh3 = BABYLON.Mesh.CreateBox( "SingleWindow", 1, this.scene);
- cubeMesh3.scaling=new BABYLON.Vector3(len-10,this.windowHeigh-10,20);
- var cCSG = BABYLON.CSG.FromMesh(cubeMesh3);
- var cubeMesh1 = BABYLON.Mesh.CreateBox( "SingleWindow", 1, this.scene);
- cubeMesh1.scaling=new BABYLON.Vector3(len-20,this.windowHeigh-20,21);
- var dCSG = BABYLON.CSG.FromMesh(cubeMesh1);
- var subCSG2 = cCSG.subtract(dCSG);
- var newMesh2 = subCSG2.toMesh("Window", this.windowframeMaterial, this.scene);
- newMesh2.position=new BABYLON.Vector3(location.point.x,this.windowBottom,location.point.y);
- newMesh2.rotation.y=-location.angle;
- //newMesh2.rotation.x = Math.PI / 2;
- this.roomWallMeshes.push(newMesh2);
- cubeMesh1.dispose();
- cubeMesh3.dispose();
-
- //镜子
- var cubeMesh6 = BABYLON.Mesh.CreateBox( "SingleWindow", 1, this.scene);
- cubeMesh6.scaling=new BABYLON.Vector3(len-20,21,this.windowHeigh-20);
- cubeMesh6.position=new BABYLON.Vector3(location.point.x,this.windowBottom,location.point.y);
- cubeMesh6.rotation.z=-location.angle;
- cubeMesh6.rotation.x = Math.PI / 2;
- cubeMesh6.visibility = 0.08;
- this.roomWallMeshes.push(cubeMesh6);
-
- if(this.doorknobMaterial==null)
- {
- this.setdoorknobMaterial();
- }
- var cubeMesh5=BABYLON.Mesh.CreateBox( "Windowknob", 1, this.scene);
- cubeMesh5.scaling=new BABYLON.Vector3(2,5,22);
- cubeMesh5.position=new BABYLON.Vector3(location.point.x+14*Math.cos(location.angle),this.windowBottom,location.point.y+14*Math.sin(location.angle));
- cubeMesh5.rotation.y=-location.angle;
- //cubeMesh5.rotation.x = Math.PI / 2;
- cubeMesh5.material=this.doorknobMaterial;
- this.roomWallMeshes.push(cubeMesh5);
- return cubeMesh;
- };
- Symbol3D.prototype.drawSlidingDoor=function(location,len)
- {
- var cubeMesh = BABYLON.Mesh.CreateBox( "SlidingDoor", 1, this.scene);
- cubeMesh.scaling=new BABYLON.Vector3(len,this.doorHeigh,this.doorThick);
- cubeMesh.position=new BABYLON.Vector3(location.point.x,this.doorBottom,location.point.y);
- cubeMesh.rotation.y=-location.angle;
- var cubeMesh2 = BABYLON.Mesh.CreateBox( "SlidingDoor", 1, this.scene);
- cubeMesh2.scaling=new BABYLON.Vector3(len,this.doorHeigh,this.baseSymbolThick+1);
- var aCSG = BABYLON.CSG.FromMesh(cubeMesh2);
-
- var cubeMesh4 = BABYLON.Mesh.CreateBox( "SlidingDoor", 1, this.scene);
- cubeMesh4.scaling=new BABYLON.Vector3(len-10,this.doorHeigh-10,this.baseSymbolThick+1);
- var bCSG = BABYLON.CSG.FromMesh(cubeMesh4);
- var subCSG = aCSG.subtract(bCSG);
- var newMesh = subCSG.toMesh("Door", this.frameMaterial, this.scene);
- newMesh.position=new BABYLON.Vector3(location.point.x,this.doorBottom,location.point.y);
- newMesh.rotation.y=-location.angle;
- //newMesh.rotation.x = Math.PI / 2;
- this.roomWallMeshes.push(newMesh);
- cubeMesh4.dispose();
- cubeMesh2.dispose();
- if(this.doormaterial==null)
- {
- this.setdoormaterial();
- }
- var cubeMesh3 = BABYLON.Mesh.CreateBox( "SlidingDoor", 1, this.scene);
- cubeMesh3.scaling=new BABYLON.Vector3(len-10,this.doorHeigh-10,20);
- cubeMesh3.position=new BABYLON.Vector3(location.point.x,this.doorBottom,location.point.y);
- cubeMesh3.rotation.y=-location.angle;
- //cubeMesh3.rotation.x = Math.PI / 2;
- cubeMesh3.material=this.doormaterial;
- this.roomWallMeshes.push(cubeMesh3);
- if(this.doorknobMaterial==null)
- {
- this.setdoorknobMaterial();
- }
- var cubeMesh5=BABYLON.Mesh.CreateBox( "Doorknob", 1, this.scene);
- cubeMesh5.scaling=new BABYLON.Vector3(2,10,22);
- cubeMesh5.position=new BABYLON.Vector3(location.point.x+5*Math.cos(location.angle),this.doorBottom,location.point.y+5*Math.sin(location.angle));
- cubeMesh5.rotation.y=-location.angle;
- //cubeMesh5.rotation.x = Math.PI / 2;
- cubeMesh5.material=this.doorknobMaterial;
- this.roomWallMeshes.push(cubeMesh5);
-
- var cubeMesh6 = cubeMesh5.clone("cubeMesh5");
- cubeMesh6.position=new BABYLON.Vector3(location.point.x-5*Math.cos(location.angle),this.doorBottom,location.point.y-5*Math.sin(location.angle));
- this.roomWallMeshes.push(cubeMesh6);
-
- return cubeMesh;
- };
- Symbol3D.prototype.drawSlidingWindow=function(location,len)
- {
- var cubeMesh = BABYLON.Mesh.CreateBox( "SlidingWindow", 1, this.scene);
- cubeMesh.scaling=new BABYLON.Vector3(len,this.windowHeigh,this.doorThick);
- cubeMesh.position=new BABYLON.Vector3(location.point.x,this.windowBottom,location.point.y);
- cubeMesh.rotation.y=-location.angle;
- var cubeMesh2 = BABYLON.Mesh.CreateBox( "SlidingWindow", 1, this.scene);
- cubeMesh2.scaling=new BABYLON.Vector3(len,this.windowHeigh,this.baseSymbolThick+1);
- var aCSG = BABYLON.CSG.FromMesh(cubeMesh2);
-
- var cubeMesh4 = BABYLON.Mesh.CreateBox( "SlidingWindow", 1, this.scene);
- cubeMesh4.scaling=new BABYLON.Vector3(len-10,this.windowHeigh-10,this.baseSymbolThick+1);
- var bCSG = BABYLON.CSG.FromMesh(cubeMesh4);
- var subCSG = aCSG.subtract(bCSG);
- var newMesh = subCSG.toMesh("Window", this.frameMaterial, this.scene);
- newMesh.position=new BABYLON.Vector3(location.point.x,this.windowBottom,location.point.y);
- newMesh.rotation.y=-location.angle;
- //newMesh.rotation.x = Math.PI / 2;
- this.roomWallMeshes.push(newMesh);
- cubeMesh4.dispose();
- cubeMesh2.dispose();
-
- if(this.windowframeMaterial==null)
- {
- this.setwindowframeMaterial();
- }
- var cubeMesh3 = BABYLON.Mesh.CreateBox( "SlidingWindow", 1, this.scene);
- cubeMesh3.scaling=new BABYLON.Vector3(len/2-5,this.windowHeigh-10,20);
- var cCSG = BABYLON.CSG.FromMesh(cubeMesh3);
- var cubeMesh1 = BABYLON.Mesh.CreateBox( "SlidingWindow", 1, this.scene);
- cubeMesh1.scaling=new BABYLON.Vector3(len/2-16,this.windowHeigh-20,21);
- var dCSG = BABYLON.CSG.FromMesh(cubeMesh1);
- var subCSG2 = cCSG.subtract(dCSG);
- var newMesh2 = subCSG2.toMesh("Window", this.windowframeMaterial, this.scene);
- //newMesh2.position=new BABYLON.Vector3(location.point.x,this.windowBottom*2,location.point.y);
- newMesh2.position=new BABYLON.Vector3(location.point.x+17*Math.cos(location.angle),this.windowBottom,location.point.y+17*Math.sin(location.angle));
- newMesh2.rotation.y=-location.angle;
- //newMesh2.rotation.x = Math.PI / 2;
- this.roomWallMeshes.push(newMesh2);
-
- var newMesh3 = newMesh2.clone("cubeMesh5");
- newMesh3.position=new BABYLON.Vector3(location.point.x-17*Math.cos(location.angle),this.windowBottom,location.point.y-17*Math.sin(location.angle));
- this.roomWallMeshes.push(newMesh3);
- cubeMesh1.dispose();
- cubeMesh3.dispose();
-
- //镜子
- var cubeMesh6 = BABYLON.Mesh.CreateBox( "SlidingWindow", 1, this.scene);
- cubeMesh6.scaling=new BABYLON.Vector3(len-20,this.windowHeigh,21);
- cubeMesh6.position=new BABYLON.Vector3(location.point.x,this.windowBottom,location.point.y);
- cubeMesh6.rotation.y=-location.angle;
- //cubeMesh6.rotation.x = Math.PI / 2;
- cubeMesh6.visibility = 0.08;
- this.roomWallMeshes.push(cubeMesh6);
-
- if(this.doorknobMaterial==null)
- {
- this.setdoorknobMaterial();
- }
- var cubeMesh5=BABYLON.Mesh.CreateBox( "Windowknob", 1, this.scene);
- cubeMesh5.scaling=new BABYLON.Vector3(2,22,5);
- cubeMesh5.position=new BABYLON.Vector3(location.point.x+2*Math.cos(location.angle),this.windowBottom,location.point.y+2*Math.sin(location.angle));
- cubeMesh5.rotation.y=-location.angle;
- cubeMesh5.rotation.x = Math.PI / 2;
- cubeMesh5.material=this.doorknobMaterial;
- this.roomWallMeshes.push(cubeMesh5);
-
- var cubeMesh7 = cubeMesh5.clone("cubeMesh5");
- cubeMesh7.position=new BABYLON.Vector3(location.point.x-2*Math.cos(location.angle),this.windowBottom,location.point.y-2*Math.sin(location.angle));
- this.roomWallMeshes.push(cubeMesh7);
-
- return cubeMesh;
- };
- Symbol3D.prototype.initialize = function ()
- {
- this.createScene();
- this.setgroundmaterial();
- this.setfloormaterial();
- this.addSkybox();
- this.addGround();
- this.addEvent();
- this.setwallmaterial();
-
- };
- Symbol3D.prototype.render= function () {
- this.scene.collisionsEnabled = true;
- //console.log("radius:"+this.camera.radius);
- var scene=this.scene;
- this.engine.runRenderLoop(
- function () {
- scene.render();
- }
- );
- };
- Symbol3D.prototype.refreshSelectMesh = function (currentMesh) {
- for(var i=0;i<this.meshManager.arrowMeshes.length;++i)
- {
- if(this.meshManager.arrowMeshes[i]!=null&&typeof(this.meshManager.arrowMeshes[i]) != "undefined")
- {
- this.meshManager.arrowMeshes[i].dispose();
- this.meshManager.arrowMeshes[i]=null;
- }
- }
- var height = 10;
- var shape = [
- new BABYLON.Vector3(10, 0, 0),
- new BABYLON.Vector3(5, height, 0)
- ];
- var top=1;
- var radius= BABYLON.Vector2.Distance(new BABYLON.Vector2(currentMesh._boundingInfo.boundingBox.maximumWorld.x,currentMesh._boundingInfo.boundingBox.maximumWorld.z),new BABYLON.Vector2(currentMesh._boundingInfo.boundingBox.minimumWorld.x,currentMesh._boundingInfo.boundingBox.minimumWorld.z))/2;
- if(radius>6)
- {
- top=radius-5;
- }
- var selectmat=new BABYLON.StandardMaterial("selectMat", this.scene);
- selectmat.alpha = 1.0;
- selectmat.diffuseColor = new BABYLON.Color3.Green();
- selectmat.backFaceCulling = false;
-
- this.meshManager.selectCircle = BABYLON.Mesh.CreateLathe('selectCircle', shape , radius,top, this.scene);
- this.meshManager.selectCircle.material = selectmat;
- this.meshManager.selectCircle.position=new BABYLON.Vector3(currentMesh._boundingInfo.boundingBox.center.x,0,currentMesh._boundingInfo.boundingBox.center.z);
-
- if(currentMesh.name.indexOf("pho-")!=0&¤tMesh.name.indexOf("picture-")!=0)
- {
- this.meshManager.rotator = new BABYLON.Mesh.CreatePlane("rotator", 1, this.scene);
- this.meshManager.rotator.scaling.x=28;
- this.meshManager.rotator.scaling.y=14;
- this.meshManager.rotator.material = new BABYLON.StandardMaterial("buttons", this.scene);
- this.meshManager.rotator.material.diffuseTexture = new BABYLON.Texture("images/rotate.png", this.scene);
- this.meshManager.rotator.material.diffuseTexture.hasAlpha = !0;
- this.meshManager.rotator.material.backFaceCulling = !1;
- }
- this.meshManager.rotator.position.z = -radius;
- this.meshManager.rotator.position.y = 0;
- this.meshManager.rotator.parent = this.meshManager.selectCircle;
- this.meshManager.rotator.position.y = Math.PI;
- this.meshManager.rotator.rotation.x = Math.PI / 4;
-
- };
- Symbol3D.prototype.addEvent = function () {
- // Events
- var startingPoint;
- var lastPosition;
- var current;
- //var angle=0;
- var scene =this.scene
- var tiledGround=this.tiledGround;
- var ground =this.ground;
- var camera =this.camera;
- var canvas =this.canvas;
-
- var currentMesh=null;
- var collidables=this.meshManager.collidables;
- var firstMeshes=this.meshManager.firstMeshes;
- //var editProduct=this.meshManager.editProduct;
- var infosize =this.meshManager.infoSize;
- var selectMesh =this.meshManager.selectMesh;
- var mesh1=this.meshManager.arrowMeshes[0];
- var mesh2=this.meshManager.arrowMeshes[1];
- var mesh3=this.meshManager.arrowMeshes[2];
- var mesh4=this.meshManager.arrowMeshes[3];
- //var furnitureMesh=this.meshManager.selectFurnitureMesh;
- var wallHeigh=this.wallHeigh;
- var createArrow=false;
- var image="images/product/info.png";
- var imagearrow="images/product/arrow.png";
- var imageflip="images/product/infoGroup.png";
- var info=null;
- var infoextend=30;
- var selectCircleY=0;
- var infoheigh=3;
- var min,max;
- var top,down,left,right;
- var vertexPoints=[];
- //var length,heigh;
- //line1是上下arrow的连线,line2是左右两个arrow的连线
- var line1,line2;
- var templane=null;
- var interval=25;
- var arrowdown,arrowtop,arrowleft,arrowright;
- var measuremesh1=null,measuremesh2=null,measuremesh3=null,measuremesh4=null,measuremesh5=null,measuremesh6=null;
- var olddistance=null;
- var oldPlanept=null;
- var measurediff=null;
- var showpoint,showmesh;
- var actionmove=false;
- var actionRotator=false;
- //var picflip=1;
- var flipMesh=null;
- var calculateLine=new CalculateLine();
-
- //var curPicPho={target:null,colliMesh:null,distance:0};
- var createSelectMat=function()
- {
- var mat=new BABYLON.StandardMaterial("selectMat", scene);
- mat.alpha = 1.0;
- mat.diffuseColor = new BABYLON.Color3.Green();
- mat.backFaceCulling = false;
- return mat;
- };
- var selectmat = createSelectMat();
- collidables.remove = function(elem, all) {
- for (var i=this.length-1; i>=0; i--) {
- if (this[i] === elem) {
- this.splice(i, 1);
- if(!all)
- break;
- }
- }
- return this;
- };
-
- var setProductInfo=function()
- {
- var position_x=document.getElementById("position-x");
- var position_y=document.getElementById("position-y");
- var position_z=document.getElementById("position-z");
-
- var position=my3DEngine.meshManager.selectFurnitureMesh.position;
- position_x.childNodes[1].childNodes[0].value=Math.floor(position.x);
- position_y.childNodes[1].childNodes[0].value=Math.floor(position.y);
- position_z.childNodes[1].childNodes[0].value=Math.floor(position.z);
-
- var params_width=document.getElementById("params-width");
- var params_length=document.getElementById("params-length");
- var width=BABYLON.Vector2.Distance(new BABYLON.Vector2(arrowdown.x,arrowdown.z),new BABYLON.Vector2(arrowtop.x,arrowtop.z));
- var length=BABYLON.Vector2.Distance(new BABYLON.Vector2(arrowright.x,arrowright.z),new BABYLON.Vector2(arrowleft.x,arrowleft.z));
- params_width.childNodes[1].childNodes[0].value=Math.floor(width);
- params_width.childNodes[1].childNodes[0].alt=Math.floor(width);
- params_length.childNodes[1].childNodes[0].value=Math.floor(length);
- params_length.childNodes[1].childNodes[0].alt=Math.floor(length);
- };
- var editProductInfo=function(h,position)
- {
- var width=BABYLON.Vector2.Distance(new BABYLON.Vector2(arrowdown.x,arrowdown.z),new BABYLON.Vector2(arrowtop.x,arrowtop.z));
- var length=BABYLON.Vector2.Distance(new BABYLON.Vector2(arrowright.x,arrowright.z),new BABYLON.Vector2(arrowleft.x,arrowleft.z));
- var height=h;
-
- var positionX=position.x;
- var positionY=position.y;
- var positionZ=position.z;
- var angleY=Math.floor((my3DEngine.meshManager.angle/Math.PI)*180);
-
- var rotationy=document.getElementById("rotation-y");
- if(angleY<0)
- {
- angleY=360+angleY;
- }
- rotationy.childNodes[1].childNodes[0].value=angleY;
- rotationy.childNodes[1].childNodes[1].value=angleY;
- var position_x=document.getElementById("position-x");
- position_x.childNodes[1].childNodes[0].value=Math.floor(position.x);
-
- var position_y=document.getElementById("position-y");
- position_y.childNodes[1].childNodes[0].value=Math.floor(position.y);
-
- var position_z=document.getElementById("position-z");
- position_z.childNodes[1].childNodes[0].value=Math.floor(position.z);
-
- var params_width=document.getElementById("params-width");
- params_width.childNodes[1].childNodes[0].value=Math.floor(width);
- params_width.childNodes[1].childNodes[0].alt=Math.floor(width);
-
- var params_length=document.getElementById("params-length");
- params_length.childNodes[1].childNodes[0].value=Math.floor(length);
- params_length.childNodes[1].childNodes[0].alt=Math.floor(length);
-
- var params_height=document.getElementById("params-height");
- params_height.childNodes[1].childNodes[0].value=Math.floor(height);
- params_height.childNodes[1].childNodes[0].alt=Math.floor(height);
- };
-
- var setVertex=function(points,min,max)
- {
- var y=points[0].y
- var m_points=[];
- for(var i=0;i<points.length;++i)
- {
- if(y.toFixed(2)==points[i].y.toFixed(2))
- {
- if(points[i].x==min.x&&points[i].z==min.z)
- {
- vertexPoints[0]=i;
- }
- else if(points[i].x==max.x&&points[i].z==max.z)
- {
- vertexPoints[2]=i;
- }
- else if(points[i].x==min.x&&points[i].z==max.z)
- {
- vertexPoints[1]=i;
- }
- else if(points[i].x==max.x&&points[i].z==min.z)
- {
- vertexPoints[3]=i;
- }
- }
- }
- };
- var createRotator=function()
- {
- var rotator = new BABYLON.Mesh.CreatePlane("rotator", 1, scene);
- rotator.scaling.x=28;
- rotator.scaling.y=14;
- rotator.material = new BABYLON.StandardMaterial("buttons", scene);
- rotator.material.diffuseTexture = new BABYLON.Texture("images/rotate.png", scene);
- rotator.material.diffuseTexture.hasAlpha = !0;
- rotator.material.backFaceCulling = !1;
- return rotator;
- };
-
- var isnotFurniture=function (currentMesh)
- {
- if (typeof(currentMesh.name) == "undefined") {
- return false;
- }
- //if(currentMesh.name.indexOf("Door")>=0||currentMesh.name.indexOf("Window")>=0||currentMesh.name.indexOf("floor")>=0||currentMesh.name=="plane"||currentMesh.name=="skyBox"||(currentMesh.id.indexOf("wall")>=0)||(currentMesh.name=="mesh_merged"))
- if(currentMesh.name.indexOf("Door")>=0||currentMesh.name.indexOf("Window")>=0||currentMesh.name=="plane"||currentMesh.name=="skyBox")
- {
- return true;
- }
- else
- {
- return false;
- }
- };
-
- var getWallPlanePosition = function () {
- // Use a predicate to get position on the ground
- var pickinfo = scene.pick(scene.pointerX, scene.pointerY, function (mesh) { return mesh.name == "plane"; });
- if (pickinfo.hit) {
- //return {point:pickinfo.pickedPoint,index:pickinfo.pickedMesh.planindex};
- return {point:pickinfo.pickedPoint,index:pickinfo.pickedMesh.planindex};
- }
- return null;
- };
-
- var getGroundPosition = function () {
- // Use a predicate to get position on the ground
- var pickinfo = scene.pick(scene.pointerX, scene.pointerY, function (mesh) {
- return (mesh == tiledGround || mesh == ground ||isnotFurniture(mesh));
- });
- if (pickinfo.hit) {
- return pickinfo.pickedPoint;
- }
- return null;
- };
-
- var getGroundPositionFromArrow = function () {
- // Use a predicate to get position on the ground
- var pickinfo = scene.pick(scene.pointerX, scene.pointerY, function (mesh) {
- return (mesh == tiledGround || mesh == ground ||isnotFurniture(mesh)||(mesh.id.indexOf("arrow")>-1));
- });
- if (pickinfo.hit) {
- return pickinfo.pickedPoint;
- }
- return null;
- };
-
- var boundcontains=function(point,currentMesh)
- {
- currentMesh.computeWorldMatrix(true);
- currentMesh.refreshBoundingInfo();
- if(point.x>currentMesh._boundingInfo.boundingBox.maximumWorld.x||point.y>currentMesh._boundingInfo.boundingBox.maximumWorld.z||point.x<currentMesh._boundingInfo.boundingBox.minimumWorld.x||point.y<currentMesh._boundingInfo.boundingBox.minimumWorld.z)
- {
- return false;
- }
- else
- {
- return true;
- }
- };
- var getDiff=function(diff,line)
- {
- var result;
- if(line.a==0)
- {
- if(line.x)
- {
- result=new BABYLON.Vector3(0,diff.y,diff.z);
- }
- else
- {
- result=new BABYLON.Vector3(diff.x,diff.y,0);
- }
- }
- else
- {
- line.b=0;
- var interpoint=calculateLine.getPointIntersect2({x:diff.x,y:diff.z},line);
- result=new BABYLON.Vector3(interpoint.x,diff.y,interpoint.y);
- }
- return result;
- };
-
- var getDiff2=function(current,line)
- {
- var result;
- var interpoint=calculateLine.getPointIntersect2({x:current.x,y:current.z},line);
- result=new BABYLON.Vector3(interpoint.x,current.y,interpoint.y);
- return result;
- };
-
- var setselectMesh=function()
- {
- var height = 10;
- var shape = [
- new BABYLON.Vector3(10, 0, 0),
- new BABYLON.Vector3(5, height, 0)
- ];
- var top=1;
- var radius= BABYLON.Vector2.Distance(new BABYLON.Vector2(currentMesh._boundingInfo.boundingBox.maximumWorld.x,currentMesh._boundingInfo.boundingBox.maximumWorld.z),new BABYLON.Vector2(currentMesh._boundingInfo.boundingBox.minimumWorld.x,currentMesh._boundingInfo.boundingBox.minimumWorld.z))/2;
- if(radius>6)
- {
- top=radius-5;
- }
- if(my3DEngine.meshManager.selectCircle==null)
- {
- if(currentMesh.name.indexOf("pho-")!=0&¤tMesh.name.indexOf("picture-")!=0)
- {
- my3DEngine.meshManager.selectCircle = BABYLON.Mesh.CreateLathe('selectCircle', shape , radius,top, scene);
- my3DEngine.meshManager.selectCircle.material = selectmat;
- }
- }
- else
- {
- if(currentMesh.name.indexOf("picture-")==0||currentMesh.name.indexOf("pho-")==0)
- {
- my3DEngine.meshManager.selectCircle.dispose();
- my3DEngine.meshManager.selectCircle=null;
- }
- }
-
- if(currentMesh.name.indexOf("pho-")!=0&¤tMesh.name.indexOf("picture-")!=0)
- {
- my3DEngine.meshManager.selectCircle.position=new BABYLON.Vector3(currentMesh._boundingInfo.boundingBox.center.x,selectCircleY,currentMesh._boundingInfo.boundingBox.center.z);
- if(my3DEngine.meshManager.rotator==null)
- {
- my3DEngine.meshManager.rotator=createRotator();
- }
- my3DEngine.meshManager.rotator.position.z = -radius;
- my3DEngine.meshManager.rotator.position.y = selectCircleY;
- if(my3DEngine.meshManager.selectCircle!=null)
- {
- my3DEngine.meshManager.rotator.parent = my3DEngine.meshManager.selectCircle;
- }
- my3DEngine.meshManager.rotator.position.y = Math.PI;
- my3DEngine.meshManager.rotator.rotation.x = Math.PI / 4;
- }
- else
- {
- if(my3DEngine.meshManager.rotator!=null)
- {
- my3DEngine.meshManager.rotator.dispose();
- my3DEngine.meshManager.rotator=null;
- }
- }
- if(my3DEngine.meshManager.selectFurnitureMesh.rotationQuaternion==null||typeof(my3DEngine.meshManager.selectFurnitureMesh.rotationQuaternion) == "undefined")
- {
- my3DEngine.meshManager.angle=0;
- }
- else
- {
- //var angleY=my3DEngine.meshManager.selectFurnitureMesh.rotationQuaternion.y;
- var angleY=my3DEngine.meshManager.selectFurnitureMesh.rotation.y;
- if(angleY<0)
- {
- angleY=2*Math.PI+angleY;
- }
- my3DEngine.meshManager.angle=angleY;
- }
- };
- var createinfo=function()
- {
- var sprite = new BABYLON.SpriteManager("meshManager", image, 6, 128, scene);
- sprite.isPickable = true;
- // First animated player
- info = new BABYLON.Sprite("editFurniture", sprite);
- info.position= new BABYLON.Vector3(currentMesh.position.x, currentMesh._boundingInfo.boundingBox.maximumWorld.y+infoextend, currentMesh.position.z);
- //if(currentMesh.name.indexOf("picture-")==0||currentMesh.name.indexOf("pho-")==0)
- //{
- // info.position.y=(currentMesh._boundingInfo.boundingBox.maximumWorld.y+ currentMesh._boundingInfo.boundingBox.minimumWorld.y)/2;
- //}
- info.size = infosize;
-
- infoheigh=currentMesh._boundingInfo.boundingBox.maximumWorld.y/2;
-
- // click action for player
- info.actionManager = new BABYLON.ActionManager(scene);
- info.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickUpTrigger, function () {
- if(!actionmove)
- {
- if(!createArrow)
- {
- currentMesh.computeWorldMatrix(true);
- currentMesh.refreshBoundingInfo();
- var configuratorProduct=document.getElementById("configuratorWindow");
- configuratorProduct.style.display="block";
- /*
- if(currentMesh.name.indexOf("picture-")==0||currentMesh.name.indexOf("pho-")==0)
- {
- createArrows2(currentMesh,scene,imagearrow);
- document.getElementById("editptrot").innerText="位置";
- document.getElementById("item-1").style.display="none";
- document.getElementById("rotation-y").style.display="none";
- document.getElementById("params-height").style.display="none";
- }
- else
- {
- */
- createArrows(currentMesh,scene,imagearrow);
- document.getElementById("editptrot").innerText="位置和角度";
- document.getElementById("item-1").style.display="";
- document.getElementById("rotation-y").style.display="";
- document.getElementById("params-height").style.display="";
- //}
-
- createArrow=true;
- info.dispose();
- info=null;
- if(my3DEngine.meshManager.selectCircle!=null)
- {
- my3DEngine.meshManager.selectCircle.dispose();
- my3DEngine.meshManager.selectCircle=null;
- if(my3DEngine.meshManager.rotator!=null)
- {
- my3DEngine.meshManager.rotator.dispose();
- my3DEngine.meshManager.rotator=null;
- }
- }
-
- editProductInfo(Math.abs(currentMesh._boundingInfo.boundingBox.maximumWorld.y- currentMesh._boundingInfo.boundingBox.minimumWorld.y),currentMesh.position);
- }
- my3DEngine.meshManager.editProduct=true;
- }
- }));
- info.isPickable = true;
- };
- var selectArrow=function()
- {
- templane=BABYLON.Mesh.CreatePlane("temp", 1, scene);
-
- if(currentMesh.name=="downarrow")
- {
- templane.scaling.x=my3DEngine.meshManager.selectFurnitureMesh.getBoundingInfo().boundingBox.extendSize.x*my3DEngine.meshManager.selectFurnitureMesh.scaling.x*2;
- templane.scaling.y=my3DEngine.meshManager.selectFurnitureMesh.getBoundingInfo().boundingBox.extendSize.y*my3DEngine.meshManager.selectFurnitureMesh.scaling.y*2;
- templane.rotate(BABYLON.Axis.Y, my3DEngine.meshManager.angle, BABYLON.Space.LOCAL);
- templane.position=arrowdown;
- olddistance=BABYLON.Vector3.Distance(arrowdown,arrowtop);
-
- var distance1= BABYLON.Vector2.Distance(new BABYLON.Vector2(camera.position.x,camera.position.z),new BABYLON.Vector2(arrowleft.x,arrowleft.z));
- var distance2= BABYLON.Vector2.Distance(new BABYLON.Vector2(camera.position.x,camera.position.z),new BABYLON.Vector2(arrowright.x,arrowright.z));
- if(distance1>distance2)
- {
- showpoint=arrowright;
- showmesh=mesh4;
- }
- else
- {
- showpoint=arrowleft;
- showmesh=mesh3;
- }
-
- }
- else if(currentMesh.name=="toparrow")
- {
- templane.scaling.x=my3DEngine.meshManager.selectFurnitureMesh.getBoundingInfo().boundingBox.extendSize.x*my3DEngine.meshManager.selectFurnitureMesh.scaling.x*2;
- templane.scaling.y=my3DEngine.meshManager.selectFurnitureMesh.getBoundingInfo().boundingBox.extendSize.y*my3DEngine.meshManager.selectFurnitureMesh.scaling.y*2;
- templane.rotate(BABYLON.Axis.Y, my3DEngine.meshManager.angle, BABYLON.Space.LOCAL);
- templane.position=arrowtop;
- //templane.position=new BABYLON.Vector3(arrowtop.x,arrowtop.y,arrowtop.z);
- olddistance=BABYLON.Vector3.Distance(arrowdown,arrowtop);
-
- var distance1= BABYLON.Vector2.Distance(new BABYLON.Vector2(camera.position.x,camera.position.z),new BABYLON.Vector2(arrowleft.x,arrowleft.z));
- var distance2= BABYLON.Vector2.Distance(new BABYLON.Vector2(camera.position.x,camera.position.z),new BABYLON.Vector2(arrowright.x,arrowright.z));
- if(distance1>distance2)
- {
- showpoint=arrowright;
- showmesh=mesh4;
- }
- else
- {
- showpoint=arrowleft;
- showmesh=mesh3;
- }
- }
- else if(currentMesh.name=="leftarrow")
- {
- /*
- if(my3DEngine.meshManager.selectFurnitureMesh.name.indexOf("picture-")==0||my3DEngine.meshManager.selectFurnitureMesh.name.indexOf("pho-")==0)
- {
- templane.rotate(BABYLON.Axis.Y,Math.PI/2, BABYLON.Space.LOCAL);
- templane.scaling.x=my3DEngine.meshManager.selectFurnitureMesh.getBoundingInfo().boundingBox.extendSize.y*my3DEngine.meshManager.selectFurnitureMesh.scaling.y*2;
- templane.scaling.y=10;
- }
- else
- {
- */
- templane.rotate(BABYLON.Axis.Y, my3DEngine.meshManager.angle+Math.PI/2, BABYLON.Space.LOCAL);
- templane.scaling.x=my3DEngine.meshManager.selectFurnitureMesh.getBoundingInfo().boundingBox.extendSize.z*my3DEngine.meshManager.selectFurnitureMesh.scaling.z*2;
- templane.scaling.y=my3DEngine.meshManager.selectFurnitureMesh.getBoundingInfo().boundingBox.extendSize.y*my3DEngine.meshManager.selectFurnitureMesh.scaling.y*2;
- //}
-
- templane.position=arrowleft;
- //templane.position=new BABYLON.Vector3(arrowleft.x,arrowleft.y,arrowleft.z);
- olddistance=BABYLON.Vector3.Distance(arrowleft,arrowright);
-
- var distance1= BABYLON.Vector2.Distance(new BABYLON.Vector2(camera.position.x,camera.position.z),new BABYLON.Vector2(arrowtop.x,arrowtop.z));
- var distance2= BABYLON.Vector2.Distance(new BABYLON.Vector2(camera.position.x,camera.position.z),new BABYLON.Vector2(arrowdown.x,arrowdown.z));
- if(distance1>distance2)
- {
- showpoint=arrowdown;
- showmesh=mesh1;
- }
- else
- {
- showpoint=arrowtop;
- showmesh=mesh2;
- }
- }
- else if(currentMesh.name=="rightarrow")
- {
- /*
- if(my3DEngine.meshManager.selectFurnitureMesh.name.indexOf("picture-")==0||my3DEngine.meshManager.selectFurnitureMesh.name.indexOf("pho-")==0)
- {
- templane.rotate(BABYLON.Axis.Y,-Math.PI/2, BABYLON.Space.LOCAL);
- templane.scaling.x=my3DEngine.meshManager.selectFurnitureMesh.getBoundingInfo().boundingBox.extendSize.y*my3DEngine.meshManager.selectFurnitureMesh.scaling.y*2;
- templane.scaling.y=10;
- }
- else
- {
- */
- templane.rotate(BABYLON.Axis.Y, my3DEngine.meshManager.angle+Math.PI/2, BABYLON.Space.LOCAL);
- templane.scaling.x=my3DEngine.meshManager.selectFurnitureMesh.getBoundingInfo().boundingBox.extendSize.z*my3DEngine.meshManager.selectFurnitureMesh.scaling.z*2;
- templane.scaling.y=my3DEngine.meshManager.selectFurnitureMesh.getBoundingInfo().boundingBox.extendSize.y*my3DEngine.meshManager.selectFurnitureMesh.scaling.y*2;
- //}
-
- templane.position=arrowright;
- //templane.position=new BABYLON.Vector3(arrowright.x,arrowright.y,arrowright.z);
- olddistance=BABYLON.Vector3.Distance(arrowleft,arrowright);
-
- var distance1= BABYLON.Vector2.Distance(new BABYLON.Vector2(camera.position.x,camera.position.z),new BABYLON.Vector2(arrowtop.x,arrowtop.z));
- var distance2= BABYLON.Vector2.Distance(new BABYLON.Vector2(camera.position.x,camera.position.z),new BABYLON.Vector2(arrowdown.x,arrowdown.z));
- if(distance1>distance2)
- {
- showpoint=arrowdown;
- showmesh=mesh1;
- }
- else
- {
- showpoint=arrowtop;
- showmesh=mesh2;
- }
- }
- measurediff=showmesh.position.subtract(my3DEngine.meshManager.selectFurnitureMesh._boundingInfo.boundingBox.center);
- var r=new BABYLON.StandardMaterial("materialplane",scene);
- r.diffuseColor=new BABYLON.Color3.Green();
- r.backFaceCulling =false;
- templane.material=r;
- oldPlanept=new BABYLON.Vector3(templane.position.x,templane.position.y,templane.position.z);
- };
-
- var removeinfo=function()
- {
- if(info!=null&&!info._isDisposed)
- {
- info.dispose();
- info=null;
- }
-
- my3DEngine.meshManager.editProduct=false;
- clearArrow();
-
- if(my3DEngine.meshManager.selectCircle!=null)
- {
- my3DEngine.meshManager.selectCircle.dispose();
- my3DEngine.meshManager.selectCircle=null;
- if(my3DEngine.meshManager.rotator!=null)
- {
- my3DEngine.meshManager.rotator.dispose();
- my3DEngine.meshManager.rotator=null;
- }
- }
- };
-
- var removeSelectMesh=function()
- {
- if(my3DEngine.meshManager.selectFurnitureMesh!=null&&typeof(my3DEngine.meshManager.selectFurnitureMesh) != "undefined")
- {
- collidables.push(my3DEngine.meshManager.selectFurnitureMesh);
- my3DEngine.meshManager.selectFurnitureMesh=null;
- }
-
- if(currentMesh==null||typeof(currentMesh) == "undefined")
- {
- return;
- }
- removeinfo();
- };
- var finishEditMesh=function()
- {
- if(templane!=null)
- {
- if(olddistance!=null)
- {
- var dxz=templane.position.subtract(oldPlanept);
- var newscal,m_newdistance,m_olddistance;
- if(currentMesh.name=="downarrow")
- {
- m_newdistance=arrowdown.subtract(arrowtop);
- m_olddistance=oldPlanept.subtract(arrowtop);
- }
- else if(currentMesh.name=="toparrow")
- {
- m_newdistance=arrowtop.subtract(arrowdown);
- m_olddistance=oldPlanept.subtract(arrowdown);
- }
- else if(currentMesh.name=="leftarrow")
- {
- m_newdistance=arrowleft.subtract(arrowright);
- m_olddistance=oldPlanept.subtract(arrowright);
- }
- else if(currentMesh.name=="rightarrow")
- {
- m_newdistance=arrowright.subtract(arrowleft);
- m_olddistance=oldPlanept.subtract(arrowleft);
- }
- newscal=new BABYLON.Vector3(m_newdistance.x.toFixed(2)/m_olddistance.x.toFixed(2)*my3DEngine.meshManager.selectFurnitureMesh.scaling.x.toFixed(2),0,m_newdistance.z.toFixed(2)/m_olddistance.z.toFixed(2)*my3DEngine.meshManager.selectFurnitureMesh.scaling.z.toFixed(2));
-
- if(currentMesh.name=="downarrow"||currentMesh.name=="toparrow")
- {
- if(!isNaN(newscal.z)&&newscal.z!=-Number.POSITIVE_INFINITY&&newscal.z!=Number.POSITIVE_INFINITY)
- {
- /*
- if(my3DEngine.meshManager.selectFurnitureMesh.name.indexOf("picture-")==0||my3DEngine.meshManager.selectFurnitureMesh.name.indexOf("pho-")==0)
- {
- my3DEngine.meshManager.selectFurnitureMesh.scaling.y=m_newdistance.z.toFixed(2)/m_olddistance.z.toFixed(2)*my3DEngine.meshManager.selectFurnitureMesh.scaling.y.toFixed(2)
- }
- else
- {
- */
- my3DEngine.meshManager.selectFurnitureMesh.scaling.z=newscal.z;
- //}
-
- }
- }
- else if(currentMesh.name=="leftarrow"||currentMesh.name=="rightarrow")
- {
- if(!isNaN(newscal.x)&&newscal.x!=-Number.POSITIVE_INFINITY&&newscal.x!=Number.POSITIVE_INFINITY)
- {
- my3DEngine.meshManager.selectFurnitureMesh.scaling.x=newscal.x;
- }
- }
- my3DEngine.meshManager.selectFurnitureMesh.computeWorldMatrix(true);
- my3DEngine.meshManager.selectFurnitureMesh.refreshBoundingInfo();
- var dxz2;
- if(currentMesh.name=="downarrow"||currentMesh.name=="toparrow")
- {
- dxz2=my3DEngine.meshManager.selectFurnitureMesh._boundingInfo.boundingBox.center.subtract(new BABYLON.Vector3((arrowdown.x+arrowtop.x)/2,0,(arrowdown.z+arrowtop.z)/2));
- my3DEngine.meshManager.selectFurnitureMesh.position.addInPlace(new BABYLON.Vector3(-dxz2.x,0,-dxz2.z));
- arrowleft.addInPlace(new BABYLON.Vector3(dxz.x/2,0,dxz.z/2));
- arrowright.addInPlace(new BABYLON.Vector3(dxz.x/2,0,dxz.z/2));
- }
- else if(currentMesh.name=="leftarrow"||currentMesh.name=="rightarrow")
- {
- dxz2=my3DEngine.meshManager.selectFurnitureMesh._boundingInfo.boundingBox.center.subtract(new BABYLON.Vector3((arrowleft.x+arrowright.x)/2,0,(arrowleft.z+arrowright.z)/2));
- my3DEngine.meshManager.selectFurnitureMesh.position.addInPlace(new BABYLON.Vector3(-dxz2.x,0,-dxz2.z));
- arrowtop.addInPlace(new BABYLON.Vector3(dxz.x/2,0,dxz.z/2));
- arrowdown.addInPlace(new BABYLON.Vector3(dxz.x/2,0,dxz.z/2));
- }
- line1=calculateLine.formula_line(new BABYLON.Vector2(arrowdown.x,arrowdown.z),new BABYLON.Vector2(arrowtop.x,arrowtop.z));
- line2=calculateLine.formula_line(new BABYLON.Vector2(arrowleft.x,arrowleft.z),new BABYLON.Vector2(arrowright.x,arrowright.z));
- }
- templane.dispose();
- templane=null;
- olddistance=null;
- }
- };
- var editingMesh=function(type)
- {
- var newpoint;
- clearMeasureMesh();
- if(currentMesh.name=="downarrow"||currentMesh.name=="toparrow")
- {
- if(type==1)
- {
- newpoint=getDiff2(current,line1);
- newpoint.y=currentMesh.position.y;
- }
- else //针对相框和墙贴
- {
- newpoint=new BABYLON.Vector3(line1.x,currentMesh.position.y,current.z);
- }
- diff2=showpoint.subtract(my3DEngine.meshManager.selectFurnitureMesh._boundingInfo.boundingBox.center);
- diff3=measurediff;
-
- ddif=diff3.subtract(diff2);
- ddif.x=ddif.x/4;
- ddif.y=ddif.y/4;
- ddif.z=ddif.z/4;
- startpoint=arrowtop.add(diff3);
- startpoint.addInPlace(ddif);
- endpoint=arrowdown.add(diff3);
- endpoint.addInPlace(ddif);
-
- var fontpt=new BABYLON.Vector3((startpoint.x+endpoint.x)/2,(startpoint.y+endpoint.y)/2,(startpoint.z+endpoint.z)/2);
- fontpt.addInPlace(ddif);
- measuremesh6 = makeTextPlane(BABYLON.Vector3.Distance(startpoint,endpoint).toFixed(2), "black", 50,fontpt);
- measuremesh6.rotation.x=Math.PI/2;
- if(showmesh.name=="rightarrow")
- {
- measuremesh6.rotation.y=-Math.PI/2+my3DEngine.meshManager.angle;
- }
- else
- {
- measuremesh6.rotation.y=Math.PI/2+my3DEngine.meshManager.angle;
- }
- }
- else if(currentMesh.name=="leftarrow"||currentMesh.name=="rightarrow")
- {
- if(type==1)
- {
- newpoint=getDiff2(current,line2);
- newpoint.y=currentMesh.position.y;
- }
- else
- {
- newpoint=new BABYLON.Vector3(line2.y,currentMesh.position.y,current.x);
- }
- diff2=showpoint.subtract(my3DEngine.meshManager.selectFurnitureMesh._boundingInfo.boundingBox.center);
- diff3=measurediff;
-
- ddif=diff3.subtract(diff2);
- ddif.x=ddif.x/4;
- ddif.y=ddif.y/4;
- ddif.z=ddif.z/4;
- startpoint=arrowleft.add(diff3);
- startpoint.addInPlace(ddif);
- endpoint=arrowright.add(diff3);
- endpoint.addInPlace(ddif);
-
- var fontpt=new BABYLON.Vector3((startpoint.x+endpoint.x)/2,(startpoint.y+endpoint.y)/2,(startpoint.z+endpoint.z)/2);
- fontpt.addInPlace(ddif);
- measuremesh6 = makeTextPlane(BABYLON.Vector3.Distance(startpoint,endpoint).toFixed(2), "black", 50,fontpt);
- measuremesh6.rotation.x=Math.PI/2;
- if(showmesh.name=="toparrow")
- {
- measuremesh6.rotation.y=Math.PI+my3DEngine.meshManager.angle;
- if(measuremesh6.rotation.y>2*Math.PI)
- {
- measuremesh6.rotation.y-=2*Math.PI;
- }
- }
- }
- var startpoint1=startpoint.add(ddif);
- var startpoint2=startpoint.subtract(ddif);
-
- var endpoint1=endpoint.add(ddif);
- var endpoint2=endpoint.subtract(ddif);
-
- measuremesh1=BABYLON.Mesh.CreateLines("start",[startpoint1,startpoint2],scene);
- measuremesh2=BABYLON.Mesh.CreateLines("end",[endpoint1,endpoint2],scene);
- measuremesh3=BABYLON.Mesh.CreateLines("end",[startpoint,endpoint],scene);
- var pts1=drawArrow({x:startpoint.x,y:startpoint.z},{x:endpoint.x,y:endpoint.z},endpoint.y);
- var pts2=drawArrow({x:endpoint.x,y:endpoint.z},{x:startpoint.x,y:startpoint.z},startpoint.y);
- measuremesh4=BABYLON.Mesh.CreateLines("arrowend",pts1,scene);
- measuremesh5=BABYLON.Mesh.CreateLines("arrowstart",pts2,scene);
- measuremesh1.color = new BABYLON.Color3.Black();
- measuremesh2.color = new BABYLON.Color3.Black();
- measuremesh3.color = new BABYLON.Color3.Black();
- measuremesh4.color = new BABYLON.Color3.Black();
- measuremesh5.color = new BABYLON.Color3.Black();
- return newpoint;
- };
-
- var closeConfigProduct=function()
- {
- var configuratorProduct=document.getElementById("configuratorWindow");
- configuratorProduct.style.display="none";
- };
- var paintWallFromSubMesh=function(subMeshId)
- {
- var addMat = new BABYLON.StandardMaterial("paint", scene);
- addMat.alpha = 1.0;
- var r=my3DEngine.paintWall.value.r;
- var g=my3DEngine.paintWall.value.g;
- var b=my3DEngine.paintWall.value.b;
- addMat.diffuseColor = new BABYLON.Color3(r, g, b);
- addMat.specularColor =new BABYLON.Color3(r, g, b);
- addMat.emissiveColor = new BABYLON.Color3(r, g, b);
- addMat.backFaceCulling = false;
- addMat.toward=currentMesh.material.subMaterials[subMeshId/2].toward;
- currentMesh.material.subMaterials[subMeshId/2]=addMat;
- startingPoint=null;
- var flag=false;
- for(var i=0;i<my3DEngine.paintSet.length;++i)
- {
- if(my3DEngine.paintSet[i].type=="wall"&&my3DEngine.paintSet[i].wallId==currentMesh.id&&my3DEngine.paintSet[i].materialId==subMeshId/2)
- {
- my3DEngine.paintSet[i].material=addMat;
- flag=true;
- break;
- }
- }
- if(!flag)
- {
- my3DEngine.paintSet.push({wallId:currentMesh.id,materialId:subMeshId/2,material:addMat,type:"wall"});
- }
-
- document.getElementById("container3d").style.cursor="default";
- };
-
- var onPointerDown = function (evt) {
- if(this.lock)
- {
- return;
- }
- actionmove=false;
- if (evt.button !== 0&&evt.button !== 2) {
- return;
- }
- startingPoint = getGroundPosition(evt);
- if(evt.button == 2)
- {
- if (startingPoint) { // we need to disconnect camera from canvas
- setTimeout(function () {
- camera.detachControl(canvas);
- }, 0);
- }
- }
-
- // check if we are under a mesh
- var pickInfo = scene.pick(scene.pointerX, scene.pointerY, function (mesh) {
- return (mesh !== tiledGround && mesh !== ground&&!isnotFurniture(mesh) );
- });
-
- if (pickInfo.hit) {
- currentMesh= pickInfo.pickedMesh;
-
- if(currentMesh.name.indexOf("wall")>=0)
- {
-
- if(my3DEngine.paintWall.beginPaint)
- {
- paintWallFromSubMesh(pickInfo.subMeshId);
- my3DEngine.paintWall.beginPaint=false;
- }
- else if(my3DEngine.phoSet.start)
- {
- my3DEngine.phoSet.start=false;
- document.getElementById("container3d").style.cursor="default";
- var joinpoint=pickInfo.pickedPoint;
- var toward= currentMesh.material.subMaterials[pickInfo.subMeshId/2].toward;
- var indexplane=currentMesh.material.subMaterials[pickInfo.subMeshId/2].indexplane;
- var point1=currentMesh.material.subMaterials[pickInfo.subMeshId/2].points.point1;
- var point2=currentMesh.material.subMaterials[pickInfo.subMeshId/2].points.point2;
- var tempjoin=calculateLine.getPtIntersect3D(point1,point2,toward,my3DEngine.phoSet.photoFrameMesh.thice,joinpoint);
-
- var tempjoin1=new BABYLON.Vector3(tempjoin.point1.x,tempjoin.point1.y,tempjoin.point1.z);
- var tempjoin2=new BABYLON.Vector3(tempjoin.point2.x,tempjoin.point2.y,tempjoin.point2.z);
-
- my3DEngine.phoSet.photoFrameMesh.rotation.y=collidables[indexplane].rotation.y;
-
- my3DEngine.phoSet.photoFrameMesh.position=tempjoin1;
-
- my3DEngine.phoSet.photoFrameMesh.computeWorldMatrix(true);
- my3DEngine.phoSet.photoFrameMesh.refreshBoundingInfo();
- if(my3DEngine.phoSet.photoFrameMesh._boundingInfo.boundingBox.maximumWorld.y>wallHeigh||my3DEngine.phoSet.photoFrameMesh._boundingInfo.boundingBox.minimumWorld.y<0)
- {
- my3DEngine.phoSet.photoFrameMesh.position.y=wallHeigh/2;
- tempjoin1.y=wallHeigh/2;
- tempjoin2.y=wallHeigh/2;
- }
-
- my3DEngine.phoSet.photoFrameMesh.planeindex=pickInfo.subMeshId/2;
-
- var diffplane=tempjoin2.subtract(tempjoin1);
- if(diffplane.x==0&&diffplane.y==0&&diffplane.z==0)
- {
- my3DEngine.phoSet.photoFrameMesh.visibility=1;
- alert("2275");
- return ;
- }
- else
- {
- var add=1;
- while(!collidables[indexplane].intersectsMesh(my3DEngine.phoSet.photoFrameMesh, true))
- {
- tempjoin1.addInPlace(new BABYLON.Vector3(diffplane.x*0.1,diffplane.y*0.1,diffplane.z*0.1));
- ++add;
- if(add>19)
- {
- //alert(2324);
- break;
- }
- my3DEngine.phoSet.photoFrameMesh.position=tempjoin1;
- my3DEngine.phoSet.photoFrameMesh.computeWorldMatrix(true);
- my3DEngine.phoSet.photoFrameMesh.refreshBoundingInfo();
- }
- my3DEngine.phoSet.photoFrameMesh.visibility=1;
-
- var fontpt=my3DEngine.phoSet.photoFrameMesh._boundingInfo.boundingBox.vectorsWorld[my3DEngine.phoSet.photoFrameMesh.frontindex];
- var toward2=calculateLine.getToward(point1,point2,{x:fontpt.x,y:fontpt.z});
- if(toward!=toward2)
- {
- my3DEngine.phoSet.photoFrameMesh.rotation.y+=Math.PI;
- }
- if(my3DEngine.phoSet.photoFrameMesh.rotation.y>=2*Math.PI)
- {
- my3DEngine.phoSet.photoFrameMesh.rotation.y-=2*Math.PI;
- }
-
- for(var i=0;i<collidables.length;++i)
- {
- if(i==indexplane)
- {
- continue;
- }
- if(collidables[i].intersectsMesh(my3DEngine.phoSet.photoFrameMesh, true))
- {
- my3DEngine.phoSet.photoFrameMesh.position.y=-100;
- my3DEngine.phoSet.photoFrameMesh.visibility=0;
- return;
- }
- }
-
- return;
- }
-
- }
- else
- {
- removeSelectMesh();
- closeConfigProduct();
- return;
- }
-
- return;
- }
- else if(currentMesh.name.indexOf("floor")>=0)
- {
- if(!my3DEngine.paintPlane.beginPaint)
- {
- removeSelectMesh();
- closeConfigProduct();
- return;
- }
- else
- {
- my3DEngine.paintPlane.beginPaint=false;
- }
-
- my3DEngine.paintPlane.currentId=currentMesh.id;
- my3DEngine.refreshFloor(currentMesh.wallid);
- return;
- }
- else if(currentMesh.name.indexOf("pho-")>=0||currentMesh.name.indexOf("picture-")>=0)
- {
- var configuratorProduct=document.getElementById("configuratorWindow");
- configuratorProduct.style.display="block";
- document.getElementById("editptrot").style.display="none";
- document.getElementById("item-1").style.display="none";
- document.getElementById("rotation-y").style.display="none";
- document.getElementById("params-width").style.display="none";
- var params_height=document.getElementById("params-height");
- var params_length=document.getElementById("params-length");
-
- //var height=Math.abs(currentMesh._boundingInfo.boundingBox.maximumWorld.y-currentMesh._boundingInfo.boundingBox.minimumWorld.y);
- //var length=Math.abs(currentMesh._boundingInfo.boundingBox.maximumWorld.x-currentMesh._boundingInfo.boundingBox.minimumWorld.x);
- var height=currentMesh.height;
- var length=currentMesh.length;
-
- params_height.childNodes[1].childNodes[0].value=Math.floor(height);
- params_height.childNodes[1].childNodes[0].alt=Math.floor(height);
- params_length.childNodes[1].childNodes[0].value=Math.floor(length);
- params_length.childNodes[1].childNodes[0].alt=Math.floor(length);
-
- selectMesh=true;
- setTimeout(function () {
- camera.detachControl(canvas);
- }, 0);
- return;
- }
- selectMesh=true;
-
- if(currentMesh.name=="selectCircle"||currentMesh.name=="rotator")
- {
- actionRotator=true;
- setTimeout(function () {
- camera.detachControl(canvas);
- }, 0);
- return;
- }
- actionRotator=false;
-
- if(my3DEngine.meshManager.editProduct)
- {
- if(my3DEngine.meshManager.selectFurnitureMesh!=null&¤tMesh.name.indexOf("arrow")>-1)
- {
- selectArrow();
- }
- else if(currentMesh.name.indexOf("arrow")<0)
- {
- clearArrow();
- closeConfigProduct();
- my3DEngine.meshManager.editProduct=false;
-
- if(my3DEngine.meshManager.selectFurnitureMesh.name!=currentMesh.name)
- {
- removeSelectMesh();
- my3DEngine.meshManager.selectFurnitureMesh=currentMesh;
- }
- setselectMesh();
- createinfo();
- createArrow=false;
- setVertex(currentMesh._boundingInfo.boundingBox.vectorsWorld,currentMesh._boundingInfo.boundingBox.minimumWorld,currentMesh._boundingInfo.boundingBox.maximumWorld);
- collidables.remove(currentMesh);
-
- }
- else
- {
- alert("error1729");
- }
- }
- else
- {
-
- if(typeof(my3DEngine.meshManager.selectFurnitureMesh) != "undefined"&&my3DEngine.meshManager.selectFurnitureMesh!=null)
- {
- if(my3DEngine.meshManager.selectFurnitureMesh.name!=currentMesh.name)
- {
- removeSelectMesh();
- my3DEngine.meshManager.selectFurnitureMesh=currentMesh;
- collidables.remove(currentMesh);
- setselectMesh();
- }
- else
- {
- collidables.remove(currentMesh);
- }
- lastPosition=startingPoint;
- }
- else
- {
- collidables.remove(currentMesh);
- my3DEngine.meshManager.selectFurnitureMesh=currentMesh;
- }
-
- if(typeof(currentMesh.rotationQuaternion) != "undefined"&¤tMesh.rotationQuaternion!=null)
- {
- //my3DEngine.meshManager.angle=currentMesh.rotationQuaternion.y;
- my3DEngine.meshManager.angle=currentMesh.rotation.y;
- }
-
-
- if(info==null)
- {
- if(my3DEngine.meshManager.selectCircle==null)
- {
- setselectMesh();
- }
- else
- {
- my3DEngine.meshManager.selectCircle.position=new BABYLON.Vector3(currentMesh._boundingInfo.boundingBox.center.x,selectCircleY,currentMesh._boundingInfo.boundingBox.center.z);
- }
- createinfo();
- createArrow=false;
- setVertex(currentMesh._boundingInfo.boundingBox.vectorsWorld,currentMesh._boundingInfo.boundingBox.minimumWorld,currentMesh._boundingInfo.boundingBox.maximumWorld);
- }
- else
- {
- info.position= new BABYLON.Vector3(currentMesh.position.x, currentMesh._boundingInfo.boundingBox.maximumWorld.y+15, currentMesh.position.z);
- }
- }
-
- if (startingPoint) { // we need to disconnect camera from canvas
- setTimeout(function () {
- camera.detachControl(canvas);
- }, 0);
- }
- }
- else
- {
- removeSelectMesh();
- closeConfigProduct();
- }
- }.bind(this);
- var onPointerUp = function () {
- if(this.lock)
- {
- return;
- }
- if (startingPoint) {
- camera.attachControl(canvas, true);
- startingPoint = null;
- if(my3DEngine.meshManager.editProduct)
- {
- finishEditMesh();
- clearMeasureMesh();
- setProductInfo();
- }
-
- actionRotator=false;
- selectMesh=false;
- return;
- }
- };
-
- var drawArrow= function( p0, p1,height){
- var _ANGLE = 20;
- var _RADIUS = 10.0;
- var _ANGLE_CROSS = 90.0;
-
- var result=[];
-
- var nP = {};
- var angle = Math.atan2(p0.x-p1.x, p0.y-p1.y);
-
- result.push(new BABYLON.Vector3(p1.x,height,p1.y));
- //rotate by _ANGLE
- var tAngle = angle - _ANGLE * Math.PI/180.0;
- nP.x = parseFloat(p1.x) + _RADIUS * Math.sin(tAngle);
- nP.y = parseFloat(p1.y) + _RADIUS * Math.cos(tAngle);
-
- result.push(new BABYLON.Vector3(nP.x,height,nP.y));
- //lower part
- tAngle = angle + _ANGLE * Math.PI/180.0;
- nP.x = parseFloat(p1.x) + _RADIUS * Math.sin(tAngle);
- nP.y = parseFloat(p1.y) + _RADIUS * Math.cos(tAngle);
- result.push(new BABYLON.Vector3(p1.x,height,p1.y));
- result.push(new BABYLON.Vector3(nP.x,height,nP.y));
-
- return result;
- };
- var clearMeasureMesh=function()
- {
- if(measuremesh1!=null)
- {
- measuremesh1.dispose();
- measuremesh1=null;
- }
- if(measuremesh2!=null)
- {
- measuremesh2.dispose();
- measuremesh2=null;
- }
- if(measuremesh3!=null)
- {
- measuremesh3.dispose();
- measuremesh3=null;
- }
- if(measuremesh4!=null)
- {
- measuremesh4.dispose();
- measuremesh4=null;
- }
- if(measuremesh5!=null)
- {
- measuremesh5.dispose();
- measuremesh5=null;
- }
- if(measuremesh6!=null)
- {
- measuremesh6.dispose();
- measuremesh6=null;
- }
- };
-
- var makeTextPlane = function(text, color,size,position) {
- var dynamicTexture = new BABYLON.DynamicTexture("DynamicTexture", 50, scene, true);
- dynamicTexture.hasAlpha = true;
-
- var plane = BABYLON.Mesh.CreatePlane("TextPlane", size, scene, true);
- plane.material = new BABYLON.StandardMaterial("TextPlaneMaterial", scene);
- plane.material.backFaceCulling = false;
- plane.material.specularColor = new BABYLON.Color3(0, 0, 0);
- plane.material.diffuseTexture = dynamicTexture;
- plane.position=position;
-
-
- dynamicTexture._context.font = "bold 12px Arial";
- var textSize=dynamicTexture._context.measureText(text);
- if(size<textSize.width)
- {
- size=Math.floor(1+textSize.width);
- }
- var x = (size - textSize.width) / 2;
- dynamicTexture.drawText(text, x, 40, "bold 12px Arial", color , "transparent", true);
-
- return plane;
- };
-
-
- /*
- var setPhoPosition=function(angle,pt,position,thice)
- {
- var calculateLine=new CalculateLine();
- var line;
- var b=pt.z-pt.x*(Math.tan(angle));
- if(angle==0)
- {
- line={a:0,y:pt.z};
- }
- else if(angle==Math.PI/2||angle==-1.5*Math.PI)
- {
- line={a:0,x:pt.x};
- }
- else
- {
- line={a:Math.tan(angle),b:b};
- }
- var cross=calculateLine.getPointIntersect2(position,line);
- cross=new BABYLON.Vector3(cross.x,position.y,cross.y);
- curPicPho.target=new BABYLON.Vector3(cross.x,cross.y,cross.z);
- var diff=position.subtract(cross);
- var distance=BABYLON.Vector2.Distance(new BABYLON.Vector2(cross.x,cross.z),new BABYLON.Vector2(position.x,position.z));
- diff.x=diff.x*thice/distance;
- diff.y=0;
- diff.z=diff.z*thice/distance;
- cross.addInPlace(diff);
- return cross;
- }
- */
-
- var onPointerMove = function (evt) {
-
- if(this.lock)
- {
- return;
- }
-
- if (!startingPoint) {
- return;
- }
- current = getGroundPosition(evt);
-
- var diff = current.subtract(startingPoint).normalize();
- if (evt.button == 2)
- {
- if(current==null)
- {
- evt.stopPropagation();
- return;
- }
- camera.target.addInPlace(new BABYLON.Vector3(diff.x*5,camera.target.y,diff.z*5));
- startingPoint=current;
- return;
- }
-
- if(!selectMesh)
- {
- evt.stopPropagation();
- return;
- }
-
- if(my3DEngine.meshManager.editProduct)
- {
- if(createArrow)
- {
- current=getGroundPositionFromArrow(evt);
- if(currentMesh.name.indexOf("arrow")>-1)
- {
- if(diff.x==0&&diff.z==0)
- {
- return;
- }
- else
- {
- var diff2,diff3;
- var startpoint,endpoint;
-
- var newpoint=editingMesh(1);
- diff = newpoint.subtract(currentMesh.position);
- templane.position.addInPlace(diff);
- if(currentMesh.name=="downarrow"||currentMesh.name=="toparrow")
- {
- mesh3.position.addInPlace(new BABYLON.Vector3(diff.x/2,diff.y/2,diff.z/2));
- mesh4.position.addInPlace(new BABYLON.Vector3(diff.x/2,diff.y/2,diff.z/2));
- }
- else if(currentMesh.name=="leftarrow"||currentMesh.name=="rightarrow")
- {
- mesh1.position.addInPlace(new BABYLON.Vector3(diff.x/2,diff.y/2,diff.z/2));
- mesh2.position.addInPlace(new BABYLON.Vector3(diff.x/2,diff.y/2,diff.z/2));
- }
- currentMesh.position=newpoint;
-
- my3DEngine.meshManager.selectFurnitureMesh.computeWorldMatrix(true);
- my3DEngine.meshManager.selectFurnitureMesh.refreshBoundingInfo();
- }
- startingPoint = current;
- }
- evt.stopPropagation();
- return;
- }
- evt.stopPropagation();
- return;
- }
-
- if(actionRotator)
- {
- var angle1=BABYLON.Angle.BetweenTwoPoints(new BABYLON.Vector2(startingPoint.x,startingPoint.z),new BABYLON.Vector2(my3DEngine.meshManager.selectCircle.position.x,my3DEngine.meshManager.selectCircle.position.z));
- var angle2=BABYLON.Angle.BetweenTwoPoints(new BABYLON.Vector2(current.x,current.z),new BABYLON.Vector2(my3DEngine.meshManager.selectCircle.position.x,my3DEngine.meshManager.selectCircle.position.z));
- if(my3DEngine.meshManager.angle==null||typeof(my3DEngine.meshManager.angle)=="undefined")
- {
- my3DEngine.meshManager.angle=angle1._radians-angle2._radians;
- }
- else
- {
- my3DEngine.meshManager.angle+=angle1._radians-angle2._radians;
- }
- my3DEngine.meshManager.selectCircle.rotate(BABYLON.Axis.Y, angle1._radians-angle2._radians, BABYLON.Space.LOCAL);
-
- my3DEngine.meshManager.selectCircle.rotation.y+=angle1._radians-angle2._radians;
-
- //if(my3DEngine.meshManager.selectFurnitureMesh.name.indexOf("picture-")!=0&&my3DEngine.meshManager.selectFurnitureMesh.name.indexOf("pho-")!=0)
- //{
- my3DEngine.meshManager.selectFurnitureMesh.rotate(BABYLON.Axis.Y, angle1._radians-angle2._radians, BABYLON.Space.LOCAL);
- my3DEngine.meshManager.selectFurnitureMesh.rotation.y+=angle1._radians-angle2._radians;
-
- my3DEngine.meshManager.angle=my3DEngine.meshManager.selectFurnitureMesh.rotation.y;
- //}
- //console.log("selectFurnitureMesh:"+my3DEngine.meshManager.selectFurnitureMesh.rotation.y+",selectCircle:"+my3DEngine.meshManager.selectCircle.rotation.y);
- startingPoint = current;
- }
-
- if (!current||!currentMesh) {
- evt.stopPropagation();
- return;
- }
-
- if((currentMesh.name.indexOf("pho-")==0||currentMesh.name.indexOf("picture-")==0))
- {
- var m_pt=getWallPlanePosition();
- if(m_pt!=null)
- {
- var temp_last=null;
- var temp_pt =new BABYLON.Vector3(currentMesh.position.x,currentMesh.position.y,currentMesh.position.z);
-
- if(currentMesh.lastPos!=null&&typeof(currentMesh.lastPos) != "undefined")
- {
- temp_last=new BABYLON.Vector3(currentMesh.lastPos.x,currentMesh.lastPos.y,currentMesh.lastPos.z);
- var diff=m_pt.point.subtract(currentMesh.lastPos);
- currentMesh.lastPos=m_pt.point;
- currentMesh.position.addInPlace(diff);
- }
- else
- {
- currentMesh.lastPos=m_pt.point;
- }
- currentMesh.computeWorldMatrix(true);
- currentMesh.refreshBoundingInfo();
-
- if(currentMesh._boundingInfo.boundingBox.maximumWorld.y>wallHeigh||currentMesh._boundingInfo.boundingBox.minimumWorld.y<0)
- {
- currentMesh.lastPos=temp_last;
- currentMesh.position=temp_pt;
- }
- else
- {
- if(m_pt.index==my3DEngine.phoSet.photoFrameMesh.planeindex)
- {
- for(var i=0;i<collidables.length;++i)
- {
- if(i==my3DEngine.phoSet.photoFrameMesh.planeindex)
- {
- continue;
- }
- if(collidables[i].intersectsMesh(currentMesh, true))
- {
- currentMesh.lastPos=temp_last;
- currentMesh.position=temp_pt;
- break;
- }
- }
- }
- else
- {
- var temprotation=currentMesh.rotation.y;
- currentMesh.rotation.y=collidables[m_pt.index].rotation.y;
- if(collidables[my3DEngine.phoSet.photoFrameMesh.planeindex].intersectsMesh(currentMesh, true))
- {
- currentMesh.lastPos=temp_last;
- currentMesh.position=temp_pt;
- currentMesh.rotation.y=temprotation;
- }
- else
- {
- currentMesh.computeWorldMatrix(true);
- currentMesh.refreshBoundingInfo();
- var pos=currentMesh.position;
- var join=calculateLine.getPointIntersect2({x:pos.x,y:pos.z},calculateLine.formula_line(collidables[m_pt.index].pts.point1, collidables[m_pt.index].pts.point2));
- join=new BABYLON.Vector3(join.x,pos.y,join.y);
- var diffplane=join.subtract(pos);
- var add=0;
-
- while(!collidables[m_pt.index].intersectsMesh(currentMesh, true))
- {
- pos.addInPlace(new BABYLON.Vector3(diffplane.x*0.1,diffplane.y*0.1,diffplane.z*0.1));
- ++add;
- if(add>19)
- {
- //alert(2851);
- break;
- }
- currentMesh.position=pos;
- currentMesh.computeWorldMatrix(true);
- currentMesh.refreshBoundingInfo();
- }
-
-
- var fontpt=currentMesh._boundingInfo.boundingBox.vectorsWorld[currentMesh.frontindex];
- var toward2=calculateLine.getToward(collidables[m_pt.index].pts.point1,collidables[m_pt.index].pts.point2,{x:fontpt.x,y:fontpt.z});
- if(collidables[m_pt.index].toward!=toward2)
- {
- currentMesh.rotation.y+=Math.PI;
- }
- if(currentMesh.rotation.y>=2*Math.PI)
- {
- currentMesh.rotation.y-=2*Math.PI;
- }
- my3DEngine.phoSet.photoFrameMesh.planeindex=m_pt.index;
- }
- }
- }
-
-
-
- }
- }
- else
- {
- if(currentMesh.name!="selectCircle"&¤tMesh.name!="rotator")
- {
- currentMesh.position = new BABYLON.Vector3(current.x, currentMesh.position.y, current.z);
- }
- if(BABYLON.Vector2.Distance(new BABYLON.Vector2(startingPoint.x,startingPoint.z),new BABYLON.Vector2(current.x,current.z))>2)
- {
- actionmove=true;
- }
- //actionmove=true;
- if(info!=null)
- {
- info.position= new BABYLON.Vector3(my3DEngine.meshManager.selectFurnitureMesh.position.x, my3DEngine.meshManager.selectFurnitureMesh._boundingInfo.boundingBox.maximumWorld.y+30, my3DEngine.meshManager.selectFurnitureMesh.position.z);
- }
-
- currentMesh.computeWorldMatrix(true);
- currentMesh.refreshBoundingInfo();
-
- if(my3DEngine.meshManager.selectCircle!=null)
- {
- //my3DEngine.meshManager.selectCircle.position=new BABYLON.Vector3(my3DEngine.meshManager.selectFurnitureMesh.position.x,selectCircleY,my3DEngine.meshManager.selectFurnitureMesh.position.z);
- my3DEngine.meshManager.selectCircle.position.x=my3DEngine.meshManager.selectFurnitureMesh.position.x;
- my3DEngine.meshManager.selectCircle.position.z=my3DEngine.meshManager.selectFurnitureMesh.position.z;
- }
-
- var flag=true;
- var meshindex=-1;
-
- if(firstMeshes.length>0)
- {
- for(var i=0;i<firstMeshes.length;++i)
- {
- if(firstMeshes[i]==currentMesh.name)
- {
- meshindex=i;
- break;
- }
- }
- }
-
- for(var i=0;i<collidables.length;++i)
- {
- if (typeof(collidables[i]) == "undefined") {
- collidables.remove(collidables[i]);
- --i;
- continue;
- }
- if (currentMesh.intersectsMesh(collidables[i], true))
- {
- console.log("2762");
- var m_flag=false;
- for(var j=0;j<firstMeshes.length;++j)
- {
- if(collidables[i].name==firstMeshes[j])
- {
- m_flag=true;
- break;
- }
- }
- if(m_flag)
- {
- continue;
- }
- flag=false;
- break;
- }
- }
- if(flag)
- {
- lastPosition=currentMesh.position;
- if(meshindex!=-1)
- {
- firstMeshes.splice(meshindex, 1);
- }
- }
- else
- {
- if(meshindex==-1)
- {
- currentMesh.position = new BABYLON.Vector3(lastPosition.x, lastPosition.y, lastPosition.z);
- if(info!=null)
- {
- info.position= new BABYLON.Vector3(my3DEngine.meshManager.selectFurnitureMesh.position.x, 0, my3DEngine.meshManager.selectFurnitureMesh.position.z);
- }
- if(my3DEngine.meshManager.selectCircle!=null)
- {
- my3DEngine.meshManager.selectCircle.position.x=my3DEngine.meshManager.selectFurnitureMesh.position.x;
- my3DEngine.meshManager.selectCircle.position.z=my3DEngine.meshManager.selectFurnitureMesh.position.z;
- }
-
- flag=true;
- }
- else
- {
- lastPosition=currentMesh.position;
- }
- }
- }
-
- evt.stopPropagation();
- };
-
- //针对相框、壁纸
- var createArrows2=function(currentMesh,scene,imagearrow)
- {
- min=currentMesh._boundingInfo.boundingBox.minimumWorld;
- max=currentMesh._boundingInfo.boundingBox.maximumWorld;
-
- var center=currentMesh._boundingInfo.boundingBox.center;
-
- var points=[];
- points[0]={x:currentMesh._boundingInfo.boundingBox.vectorsWorld[vertexPoints[0]].x,y:currentMesh._boundingInfo.boundingBox.vectorsWorld[vertexPoints[0]].z};
- points[1]={x:currentMesh._boundingInfo.boundingBox.vectorsWorld[vertexPoints[1]].x,y:currentMesh._boundingInfo.boundingBox.vectorsWorld[vertexPoints[1]].z};
- points[2]={x:currentMesh._boundingInfo.boundingBox.vectorsWorld[vertexPoints[2]].x,y:currentMesh._boundingInfo.boundingBox.vectorsWorld[vertexPoints[2]].z};
- points[3]={x:currentMesh._boundingInfo.boundingBox.vectorsWorld[vertexPoints[3]].x,y:currentMesh._boundingInfo.boundingBox.vectorsWorld[vertexPoints[3]].z};
-
- var down =new BABYLON.Vector3((points[0].x+points[3].x)/2,center.y,(points[0].y+points[3].y)/2);
- var top =new BABYLON.Vector3((points[1].x+points[2].x)/2,center.y,(points[1].y+points[2].y)/2);
- var left =new BABYLON.Vector3((points[1].x+points[0].x)/2,center.y,(points[1].y+points[0].y)/2);
- var right=new BABYLON.Vector3((points[2].x+points[3].x)/2,center.y,(points[2].y+points[3].y)/2);
-
- arrowdown =new BABYLON.Vector3(down.x ,down.y,down.z);
- arrowtop =new BABYLON.Vector3(top.x ,top.y,top.z);
- arrowleft =new BABYLON.Vector3(left.x ,left.y,left.z);
- arrowright=new BABYLON.Vector3(right.x,right.y,right.z);
-
- down=arrowdown.add(new BABYLON.Vector3(0,0,-interval));
- top=arrowtop.add(new BABYLON.Vector3(0,0,interval));
- left=arrowleft.add(new BABYLON.Vector3(-interval,0,0));
- right=arrowright.add(new BABYLON.Vector3(interval,0,0));
-
- down =new BABYLON.Vector2(down.x ,down.z);
- top =new BABYLON.Vector2(top.x ,top.z);
- left =new BABYLON.Vector2(left.x ,left.z);
- right=new BABYLON.Vector2(right.x,right.z);
-
- var arrowtexture = new BABYLON.Texture('data:my_image_name1', scene, true,
- true, BABYLON.Texture.BILINEAR_SAMPLINGMODE,
- null, null, imagearrow, true);
-
- mesh1=BABYLON.Mesh.CreateCylinder("arrow1", 0.00001, 24, 24, 64, 12, scene, false);
- mesh1.material =new BABYLON.StandardMaterial('newMaterial', scene);
- mesh1.material.diffuseTexture = arrowtexture;
- mesh1.position= new BABYLON.Vector3(down.x, infoheigh, down.y);
- mesh1.rotation.y=-Math.PI/2;
- mesh1.rotation.z=Math.PI;
- mesh1.name="downarrow";
-
- mesh2=mesh1.clone();
- mesh2.position= new BABYLON.Vector3(top.x, infoheigh, top.y);
- mesh2.rotation.y=-3*Math.PI/2;
- mesh2.rotation.z=Math.PI;
- mesh2.name="toparrow";
-
- mesh3=mesh1.clone();
- mesh3.position= new BABYLON.Vector3(left.x, infoheigh, left.y);
- mesh3.rotation.y=0;
- mesh3.rotation.z=Math.PI;
- mesh3.name="leftarrow";
-
- mesh4=mesh1.clone();
- mesh4.position= new BABYLON.Vector3(right.x, infoheigh, right.y);
- var angle4=BABYLON.Angle.BetweenTwoPoints(right,left);
- mesh4.rotation.y=-Math.PI;
- mesh4.rotation.z=Math.PI;
- mesh4.name="rightarrow";
-
- line1={x:down.x};
- line2={y:left.y};
-
- my3DEngine.meshManager.arrowMeshes[0]=mesh1;
- my3DEngine.meshManager.arrowMeshes[1]=mesh2;
- my3DEngine.meshManager.arrowMeshes[2]=mesh3;
- my3DEngine.meshManager.arrowMeshes[3]=mesh4;
- };
-
- var createArrows=function(currentMesh,scene,imagearrow)
- {
- min=currentMesh._boundingInfo.boundingBox.minimumWorld;
- max=currentMesh._boundingInfo.boundingBox.maximumWorld;
- //heigh=Math.abs(max.z-min.z);
- //length=Math.abs(max.x-min.x);
-
- var center=currentMesh._boundingInfo.boundingBox.center;
-
- var points=[];
- points[0]={x:currentMesh._boundingInfo.boundingBox.vectorsWorld[vertexPoints[0]].x,y:currentMesh._boundingInfo.boundingBox.vectorsWorld[vertexPoints[0]].z};
- points[1]={x:currentMesh._boundingInfo.boundingBox.vectorsWorld[vertexPoints[1]].x,y:currentMesh._boundingInfo.boundingBox.vectorsWorld[vertexPoints[1]].z};
- points[2]={x:currentMesh._boundingInfo.boundingBox.vectorsWorld[vertexPoints[2]].x,y:currentMesh._boundingInfo.boundingBox.vectorsWorld[vertexPoints[2]].z};
- points[3]={x:currentMesh._boundingInfo.boundingBox.vectorsWorld[vertexPoints[3]].x,y:currentMesh._boundingInfo.boundingBox.vectorsWorld[vertexPoints[3]].z};
-
-
- var down =new BABYLON.Vector3((points[0].x+points[3].x)/2,center.y,(points[0].y+points[3].y)/2);
- var top =new BABYLON.Vector3((points[1].x+points[2].x)/2,center.y,(points[1].y+points[2].y)/2);
- var left =new BABYLON.Vector3((points[1].x+points[0].x)/2,center.y,(points[1].y+points[0].y)/2);
- var right=new BABYLON.Vector3((points[2].x+points[3].x)/2,center.y,(points[2].y+points[3].y)/2);
- arrowdown =new BABYLON.Vector3(down.x ,down.y,down.z);
- arrowtop =new BABYLON.Vector3(top.x ,top.y,top.z);
- arrowleft =new BABYLON.Vector3(left.x ,left.y,left.z);
- arrowright=new BABYLON.Vector3(right.x,right.y,right.z);
-
-
- down =new BABYLON.Vector2(down.x ,down.z);
- top =new BABYLON.Vector2(top.x ,top.z);
- left =new BABYLON.Vector2(left.x ,left.z);
- right=new BABYLON.Vector2(right.x,right.z);
-
-
- var d1=BABYLON.Vector2.Distance(down,new BABYLON.Vector2(center.x,center.z));
- var diff1=arrowdown.subtract(center);
- //down=arrowdown.addInPlace(diff1);
- down=arrowdown.add(new BABYLON.Vector3(diff1.x/d1*interval,0,diff1.z/d1*interval));
-
- var d2=BABYLON.Vector2.Distance(top,new BABYLON.Vector2(center.x,center.z));
- var diff2=arrowtop.subtract(center);
- //top=arrowtop.addInPlace(diff2);
- //top.addInPlace(diff2);
- top=arrowtop.add(new BABYLON.Vector3(diff2.x/d2*interval,0,diff2.z/d2*interval));
-
- var d3=BABYLON.Vector2.Distance(left,new BABYLON.Vector2(center.x,center.z));
- var diff3=arrowleft.subtract(center);
- //left=arrowleft.addInPlace(diff3);
- //left.addInPlace(diff3);
- left=arrowleft.add(new BABYLON.Vector3(diff3.x/d3*interval,0,diff3.z/d3*interval));
-
- var d4=BABYLON.Vector2.Distance(right,new BABYLON.Vector2(center.x,center.z));
- var diff4=arrowright.subtract(center);
- //right=arrowright.addInPlace(diff4);
- //right.addInPlace(diff4);
- right=arrowright.add(new BABYLON.Vector3(diff4.x/d4*interval,0,diff4.z/d4*interval));
-
- down =new BABYLON.Vector2(down.x ,down.z);
- top =new BABYLON.Vector2(top.x ,top.z);
- left =new BABYLON.Vector2(left.x ,left.z);
- right=new BABYLON.Vector2(right.x,right.z);
-
- var arrowtexture = new BABYLON.Texture('data:my_image_name1', scene, true,
- true, BABYLON.Texture.BILINEAR_SAMPLINGMODE,
- null, null, imagearrow, true);
-
- mesh1=BABYLON.Mesh.CreateCylinder("arrow1", 0.00001, 24, 24, 64, 12, scene, false);
- mesh1.material =new BABYLON.StandardMaterial('newMaterial', scene);
- mesh1.material.diffuseTexture = arrowtexture;
- mesh1.position= new BABYLON.Vector3(down.x, infoheigh, down.y);
- var angle1=BABYLON.Angle.BetweenTwoPoints(down,top);
- mesh1.rotation.y=-angle1._radians;
- mesh1.rotation.z=Math.PI;
- mesh1.name="downarrow";
-
- mesh2=mesh1.clone();
- mesh2.position= new BABYLON.Vector3(top.x, infoheigh, top.y);
- var angle2=BABYLON.Angle.BetweenTwoPoints(top,down);
- mesh2.rotation.y=-angle2._radians;
- mesh2.rotation.z=Math.PI;
- mesh2.name="toparrow";
-
- mesh3=mesh1.clone();
- mesh3.position= new BABYLON.Vector3(left.x, infoheigh, left.y);
- var angle3=BABYLON.Angle.BetweenTwoPoints(left,right);
- mesh3.rotation.y=-angle3._radians;
- mesh3.rotation.z=Math.PI;
- mesh3.name="leftarrow";
-
- mesh4=mesh1.clone();
- mesh4.position= new BABYLON.Vector3(right.x, infoheigh, right.y);
- var angle4=BABYLON.Angle.BetweenTwoPoints(right,left);
- mesh4.rotation.y=-angle4._radians;
- mesh4.rotation.z=Math.PI;
- mesh4.name="rightarrow";
-
- line1=calculateLine.formula_line(down,top);
- line2=calculateLine.formula_line(left,right);
-
- my3DEngine.meshManager.arrowMeshes[0]=mesh1;
- my3DEngine.meshManager.arrowMeshes[1]=mesh2;
- my3DEngine.meshManager.arrowMeshes[2]=mesh3;
- my3DEngine.meshManager.arrowMeshes[3]=mesh4;
- };
-
- var clearArrow=function()
- {
- //if(typeof(mesh1) != "undefined"&&!mesh1._isDisposed)
- if(typeof(mesh1) != "undefined")
- {
- mesh1.dispose();
- }
- if(typeof(mesh2) != "undefined")
- {
- mesh2.dispose();
- }
- if(typeof(mesh3) != "undefined")
- {
- mesh3.dispose();
- }
- if(typeof(mesh4) != "undefined")
- {
- mesh4.dispose();
- }
- createArrow=false;
- };
-
- var onCameraWheel=function(e)
- {
- var type=e.type;
- var delta;
- if (type == 'DOMMouseScroll' || type == 'mousewheel') {
- delta = (e.wheelDelta) ? (e.wheelDelta / 120)*2 : -(e.detail || 0) / 3*2;
- }
-
- var mark=document.getElementById("mark");
- var markpy=parseInt(mark.style.marginTop);
- markpy-=delta;
- if(markpy<MixMark)
- {
- markpy=MixMark;
- }
- else if(markpy>MaxMark)
- {
- markpy=MaxMark;
- }
- mark.style.marginTop=markpy+"px";
- };
-
- canvas.addEventListener("mousedown", onPointerDown, false);
- canvas.addEventListener("mouseup", onPointerUp, false);
- canvas.addEventListener("mousemove", onPointerMove, false);
- canvas.addEventListener("mousewheel", onCameraWheel,false);
-
- scene.onDispose = function () {
- canvas.removeEventListener("mousedown", onPointerDown);
- canvas.removeEventListener("mouseup", onPointerUp);
- canvas.removeEventListener("mousemove", onPointerMove);
- canvas.removeEventListener("mousewheel", onCameraWheel);
- };
- };
|