diff --git a/public/models/dam/license.txt b/public/models/dam/license.txt new file mode 100644 index 000000000..09c075d18 --- /dev/null +++ b/public/models/dam/license.txt @@ -0,0 +1,11 @@ +Model Information: +* title: El Pontón de la Oliva | PATONES, MADRID +* source: https://sketchfab.com/3d-models/el-ponton-de-la-oliva-patones-madrid-eb3cb2b70a8d439aa8abf598989315c3 +* author: Arqueomodel3D (https://sketchfab.com/juanbrualla) + +Model License: +* license type: CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/) +* requirements: Author must be credited. Commercial use is allowed. + +If you use this 3D model in your project be sure to copy paste this credit wherever you share it: +This work is based on "El Pontón de la Oliva | PATONES, MADRID" (https://sketchfab.com/3d-models/el-ponton-de-la-oliva-patones-madrid-eb3cb2b70a8d439aa8abf598989315c3) by Arqueomodel3D (https://sketchfab.com/juanbrualla) licensed under CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/) \ No newline at end of file diff --git a/public/models/dam/scene.bin b/public/models/dam/scene.bin new file mode 100644 index 000000000..d4c3d50e4 Binary files /dev/null and b/public/models/dam/scene.bin differ diff --git a/public/models/dam/scene.gltf b/public/models/dam/scene.gltf new file mode 100644 index 000000000..d6c73043f --- /dev/null +++ b/public/models/dam/scene.gltf @@ -0,0 +1,1178 @@ +{ + "accessors": [ + { + "bufferView": 2, + "componentType": 5126, + "count": 65532, + "max": [ + 7.228588104248047, + 2.396691083908081, + 7.609867095947266 + ], + "min": [ + -4.782299041748047, + -3.659363031387329, + -6.167201995849609 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 786384, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9999881386756897, + 0.9999984502792358, + 0.9999969005584717 + ], + "min": [ + -0.9999757409095764, + -0.9999995231628418, + -1.0 + ], + "type": "VEC3" + }, + { + "bufferView": 1, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9995819926261902, + 0.9999489784240723 + ], + "min": [ + 0.0005879999953322113, + 0.0005489999894052744 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "componentType": 5125, + "count": 351609, + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 1572768, + "componentType": 5126, + "count": 65532, + "max": [ + 5.5598859786987305, + 1.697877049446106, + 1.4050649404525757 + ], + "min": [ + -0.8243420124053955, + -0.6033750176429749, + -6.2631731033325195 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 2359152, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9997668862342834, + 0.9998711347579956, + 0.9999791383743286 + ], + "min": [ + -0.9999803304672241, + -0.9999992251396179, + -0.9999997615814209 + ], + "type": "VEC3" + }, + { + "bufferView": 1, + "byteOffset": 524256, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9992820024490356, + 1.0 + ], + "min": [ + 0.0005709999823011458, + 0.0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 1406436, + "componentType": 5125, + "count": 350400, + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 3145536, + "componentType": 5126, + "count": 65532, + "max": [ + 8.76727294921875, + 1.6879830360412598, + 8.209447860717773 + ], + "min": [ + -2.1708641052246094, + -3.4628450870513916, + -3.1766650676727295 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 3931920, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9999905228614807, + 0.9973353743553162, + 0.9999971389770508 + ], + "min": [ + -1.0, + -0.9999983310699463, + -0.9999632239341736 + ], + "type": "VEC3" + }, + { + "bufferView": 1, + "byteOffset": 1048512, + "componentType": 5126, + "count": 65532, + "max": [ + 0.951587975025177, + 0.9994109869003296 + ], + "min": [ + 0.07398699969053268, + 0.0007130000158213079 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 2808036, + "componentType": 5125, + "count": 349677, + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 4718304, + "componentType": 5126, + "count": 65532, + "max": [ + 7.611456871032715, + 2.396691083908081, + 7.994133949279785 + ], + "min": [ + -3.163243055343628, + -1.5143589973449707, + -4.516446113586426 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 5504688, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9999498724937439, + 0.9999886155128479, + 0.9999978542327881 + ], + "min": [ + -0.9999684691429138, + -1.0, + -0.9999997615814209 + ], + "type": "VEC3" + }, + { + "bufferView": 1, + "byteOffset": 1572768, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9995139837265015, + 0.9999169707298279 + ], + "min": [ + 0.0, + 0.0001429999974789098 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 4206744, + "componentType": 5125, + "count": 343413, + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 6291072, + "componentType": 5126, + "count": 65532, + "max": [ + 2.1048738956451416, + 1.6362370252609253, + 8.012207984924316 + ], + "min": [ + -6.12764310836792, + -1.5727620124816895, + 1.3507009744644165 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 7077456, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9999962449073792, + 0.9998409748077393, + 0.9999837875366211 + ], + "min": [ + -0.9999193549156189, + -0.9999967813491821, + -0.9999938607215881 + ], + "type": "VEC3" + }, + { + "bufferView": 1, + "byteOffset": 2097024, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9991509914398193, + 0.9997580051422119 + ], + "min": [ + 0.0005070000188425183, + 0.0005559999844990671 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 5580396, + "componentType": 5125, + "count": 339954, + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 7863840, + "componentType": 5126, + "count": 65532, + "max": [ + 2.6502509117126465, + 1.6362370252609253, + 7.877142906188965 + ], + "min": [ + -7.352717876434326, + -3.6342859268188477, + 1.4288300275802612 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 8650224, + "componentType": 5126, + "count": 65532, + "max": [ + 0.999995768070221, + 0.9999988675117493, + 0.9999202489852905 + ], + "min": [ + -0.9999966621398926, + -0.9999986290931702, + -0.9999309778213501 + ], + "type": "VEC3" + }, + { + "bufferView": 1, + "byteOffset": 2621280, + "componentType": 5126, + "count": 65532, + "max": [ + 1.0, + 1.0 + ], + "min": [ + 0.00045900000259280205, + 0.0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 6940212, + "componentType": 5125, + "count": 332151, + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 9436608, + "componentType": 5126, + "count": 65532, + "max": [ + 2.2556679248809814, + 2.33524489402771, + 7.175140857696533 + ], + "min": [ + -7.535966873168945, + -3.401179075241089, + -6.286098003387451 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 10222992, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9999972581863403, + 0.9999823570251465, + 0.9999995231628418 + ], + "min": [ + -0.9998458623886108, + -0.9999980926513672, + -0.9999995231628418 + ], + "type": "VEC3" + }, + { + "bufferView": 1, + "byteOffset": 3145536, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9994009733200073, + 0.9997779726982117 + ], + "min": [ + 0.000514000013936311, + 0.00044299999717622995 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 8268816, + "componentType": 5125, + "count": 330759, + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 11009376, + "componentType": 5126, + "count": 65532, + "max": [ + 0.44926801323890686, + 1.761849045753479, + -0.576960027217865 + ], + "min": [ + -5.3822150230407715, + -1.451185941696167, + -6.1891770362854 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 11795760, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9999989867210388, + 0.999997615814209, + 0.9999439716339111 + ], + "min": [ + -0.9995949864387512, + -0.9999989867210388, + -0.9999986290931702 + ], + "type": "VEC3" + }, + { + "bufferView": 1, + "byteOffset": 3669792, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9993810057640076, + 0.9995290040969849 + ], + "min": [ + 0.0005089999758638442, + 0.000446999998530373 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 9591852, + "componentType": 5125, + "count": 338880, + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 12582144, + "componentType": 5126, + "count": 65532, + "max": [ + 5.489595890045166, + 1.6774729490280151, + 3.4012489318847656 + ], + "min": [ + -7.078560829162598, + -2.8832099437713623, + -6.1722187995910645 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 13368528, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9999984502792358, + 0.9999983310699463, + 0.9999035000801086 + ], + "min": [ + -0.9999775290489197, + -0.9999983310699463, + -0.9999998807907104 + ], + "type": "VEC3" + }, + { + "bufferView": 1, + "byteOffset": 4194048, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9995099902153015, + 1.0 + ], + "min": [ + 0.0005039999959990382, + 0.00040600000647827983 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 10947372, + "componentType": 5125, + "count": 297705, + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 14154912, + "componentType": 5126, + "count": 65532, + "max": [ + 8.7686767578125, + 1.6917630434036255, + 7.016080856323242 + ], + "min": [ + -7.340764045715332, + -3.636810064315796, + -3.7149651050567627 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 14941296, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9999998807907104, + 0.9999969005584717, + 0.9999971389770508 + ], + "min": [ + -0.9999996423721313, + -0.999999463558197, + -0.999987006187439 + ], + "type": "VEC3" + }, + { + "bufferView": 1, + "byteOffset": 4718304, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9995250105857849, + 1.0 + ], + "min": [ + 0.0004180000105407089, + 0.00034500000765547156 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 12138192, + "componentType": 5125, + "count": 315075, + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 15727680, + "componentType": 5126, + "count": 65532, + "max": [ + -1.4035530090332031, + 1.4025880098342896, + 7.977602005004883 + ], + "min": [ + -7.538508892059326, + -3.6379239559173584, + -6.172128200531006 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 16514064, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9999960064888, + 0.9999986290931702, + 0.9999996423721313 + ], + "min": [ + -0.9999709725379944, + -0.9999969005584717, + -0.9999996423721313 + ], + "type": "VEC3" + }, + { + "bufferView": 1, + "byteOffset": 5242560, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9998160004615784, + 0.9999809861183167 + ], + "min": [ + 0.00011700000322889537, + 0.0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 13398492, + "componentType": 5125, + "count": 289467, + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 17300448, + "componentType": 5126, + "count": 65532, + "max": [ + 1.9054700136184692, + 2.410862922668457, + 4.684869766235352 + ], + "min": [ + -6.900275230407715, + -2.871273994445801, + -6.330479145050049 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 18086832, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9999984502792358, + 0.9997667670249939, + 0.999974250793457 + ], + "min": [ + -0.9997938871383667, + -0.9999954700469971, + -0.9999998807907104 + ], + "type": "VEC3" + }, + { + "bufferView": 1, + "byteOffset": 5766816, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9994490146636963, + 1.0 + ], + "min": [ + 0.0, + 3.7999998312443495e-05 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 14556360, + "componentType": 5125, + "count": 279339, + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 18873216, + "componentType": 5126, + "count": 65532, + "max": [ + 4.196692943572998, + 2.1428310871124268, + 8.11807632446289 + ], + "min": [ + -5.7700300216674805, + -0.611981987953186, + -1.4684109687805176 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 19659600, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9999961256980896, + 0.9999984502792358, + 0.9999971389770508 + ], + "min": [ + -0.9999961256980896, + -0.9999996423721313, + -0.9999972581863403 + ], + "type": "VEC3" + }, + { + "bufferView": 1, + "byteOffset": 6291072, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9995700120925903, + 0.9999520182609558 + ], + "min": [ + 1.700000029813964e-05, + 0.00011100000119768083 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 15673716, + "componentType": 5125, + "count": 299742, + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 20445984, + "componentType": 5126, + "count": 63875, + "max": [ + 8.716240882873535, + 0.9815379977226257, + 8.043383598327637 + ], + "min": [ + -2.2740559577941895, + -3.659363031387329, + -4.552610874176025 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 21212484, + "componentType": 5126, + "count": 63875, + "max": [ + 0.9999963641166687, + 0.9999983310699463, + 0.9999978542327881 + ], + "min": [ + -0.9999969005584717, + -0.9999983310699463, + -0.9999971389770508 + ], + "type": "VEC3" + }, + { + "bufferView": 1, + "byteOffset": 6815328, + "componentType": 5126, + "count": 63875, + "max": [ + 0.999002993106842, + 0.9999430179595947 + ], + "min": [ + 0.00021699999342672527, + 0.0005339999916031957 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 16872684, + "componentType": 5125, + "count": 289122, + "type": "SCALAR" + } + ], + "asset": { + "extras": { + "author": "Arqueomodel3D (https://sketchfab.com/juanbrualla)", + "license": "CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)", + "source": "https://sketchfab.com/3d-models/el-ponton-de-la-oliva-patones-madrid-eb3cb2b70a8d439aa8abf598989315c3", + "title": "El Pontón de la Oliva | PATONES, MADRID" + }, + "generator": "Sketchfab-14.20.0", + "version": "2.0" + }, + "bufferViews": [ + { + "buffer": 0, + "byteLength": 18029172, + "name": "floatBufferViews", + "target": 34963 + }, + { + "buffer": 0, + "byteLength": 7326328, + "byteOffset": 18029172, + "byteStride": 8, + "name": "floatBufferViews", + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 21978984, + "byteOffset": 25355500, + "byteStride": 12, + "name": "floatBufferViews", + "target": 34962 + } + ], + "buffers": [ + { + "byteLength": 47334484, + "uri": "scene.bin" + } + ], + "images": [ + { + "uri": "textures/PONTON_OLIVA.1001_baseColor.jpeg" + } + ], + "materials": [ + { + "doubleSided": true, + "name": "PONTON_OLIVA.1001", + "pbrMetallicRoughness": { + "baseColorTexture": { + "index": 0 + }, + "metallicFactor": 0.0 + } + } + ], + "meshes": [ + { + "name": "Object_0", + "primitives": [ + { + "attributes": { + "NORMAL": 1, + "POSITION": 0, + "TEXCOORD_0": 2 + }, + "indices": 3, + "material": 0, + "mode": 4 + } + ] + }, + { + "name": "Object_1", + "primitives": [ + { + "attributes": { + "NORMAL": 5, + "POSITION": 4, + "TEXCOORD_0": 6 + }, + "indices": 7, + "material": 0, + "mode": 4 + } + ] + }, + { + "name": "Object_2", + "primitives": [ + { + "attributes": { + "NORMAL": 9, + "POSITION": 8, + "TEXCOORD_0": 10 + }, + "indices": 11, + "material": 0, + "mode": 4 + } + ] + }, + { + "name": "Object_3", + "primitives": [ + { + "attributes": { + "NORMAL": 13, + "POSITION": 12, + "TEXCOORD_0": 14 + }, + "indices": 15, + "material": 0, + "mode": 4 + } + ] + }, + { + "name": "Object_4", + "primitives": [ + { + "attributes": { + "NORMAL": 17, + "POSITION": 16, + "TEXCOORD_0": 18 + }, + "indices": 19, + "material": 0, + "mode": 4 + } + ] + }, + { + "name": "Object_5", + "primitives": [ + { + "attributes": { + "NORMAL": 21, + "POSITION": 20, + "TEXCOORD_0": 22 + }, + "indices": 23, + "material": 0, + "mode": 4 + } + ] + }, + { + "name": "Object_6", + "primitives": [ + { + "attributes": { + "NORMAL": 25, + "POSITION": 24, + "TEXCOORD_0": 26 + }, + "indices": 27, + "material": 0, + "mode": 4 + } + ] + }, + { + "name": "Object_7", + "primitives": [ + { + "attributes": { + "NORMAL": 29, + "POSITION": 28, + "TEXCOORD_0": 30 + }, + "indices": 31, + "material": 0, + "mode": 4 + } + ] + }, + { + "name": "Object_8", + "primitives": [ + { + "attributes": { + "NORMAL": 33, + "POSITION": 32, + "TEXCOORD_0": 34 + }, + "indices": 35, + "material": 0, + "mode": 4 + } + ] + }, + { + "name": "Object_9", + "primitives": [ + { + "attributes": { + "NORMAL": 37, + "POSITION": 36, + "TEXCOORD_0": 38 + }, + "indices": 39, + "material": 0, + "mode": 4 + } + ] + }, + { + "name": "Object_10", + "primitives": [ + { + "attributes": { + "NORMAL": 41, + "POSITION": 40, + "TEXCOORD_0": 42 + }, + "indices": 43, + "material": 0, + "mode": 4 + } + ] + }, + { + "name": "Object_11", + "primitives": [ + { + "attributes": { + "NORMAL": 45, + "POSITION": 44, + "TEXCOORD_0": 46 + }, + "indices": 47, + "material": 0, + "mode": 4 + } + ] + }, + { + "name": "Object_12", + "primitives": [ + { + "attributes": { + "NORMAL": 49, + "POSITION": 48, + "TEXCOORD_0": 50 + }, + "indices": 51, + "material": 0, + "mode": 4 + } + ] + }, + { + "name": "Object_13", + "primitives": [ + { + "attributes": { + "NORMAL": 53, + "POSITION": 52, + "TEXCOORD_0": 54 + }, + "indices": 55, + "material": 0, + "mode": 4 + } + ] + } + ], + "nodes": [ + { + "children": [ + 1 + ], + "matrix": [ + 0.9998416900634766, + 0.017383158206939697, + 0.0037915932480245868, + 0.0, + 0.017549198120832443, + -0.998627245426178, + -0.049352873116731866, + 0.0, + 0.0029284795746207237, + 0.04941160231828712, + -0.9987742304801941, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0 + ], + "name": "Sketchfab_model" + }, + { + "children": [ + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15 + ], + "name": "PONTON_OLIVA.obj.cleaner.materialmerger.gles" + }, + { + "mesh": 0, + "name": "Object_2" + }, + { + "mesh": 1, + "name": "Object_3" + }, + { + "mesh": 2, + "name": "Object_4" + }, + { + "mesh": 3, + "name": "Object_5" + }, + { + "mesh": 4, + "name": "Object_6" + }, + { + "mesh": 5, + "name": "Object_7" + }, + { + "mesh": 6, + "name": "Object_8" + }, + { + "mesh": 7, + "name": "Object_9" + }, + { + "mesh": 8, + "name": "Object_10" + }, + { + "mesh": 9, + "name": "Object_11" + }, + { + "mesh": 10, + "name": "Object_12" + }, + { + "mesh": 11, + "name": "Object_13" + }, + { + "mesh": 12, + "name": "Object_14" + }, + { + "mesh": 13, + "name": "Object_15" + } + ], + "samplers": [ + { + "magFilter": 9729, + "minFilter": 9987, + "wrapS": 10497, + "wrapT": 10497 + } + ], + "scene": 0, + "scenes": [ + { + "name": "Sketchfab_Scene", + "nodes": [ + 0 + ] + } + ], + "textures": [ + { + "sampler": 0, + "source": 0 + } + ] +} diff --git a/public/models/dam/textures/PONTON_OLIVA.1001_baseColor.jpeg b/public/models/dam/textures/PONTON_OLIVA.1001_baseColor.jpeg new file mode 100644 index 000000000..9d84f2fdc Binary files /dev/null and b/public/models/dam/textures/PONTON_OLIVA.1001_baseColor.jpeg differ diff --git a/src/views/Home/MapCtrl/Map3D/Map3D.js b/src/views/Home/MapCtrl/Map3D/Map3D.js index 299ba0d35..6173a5f64 100644 --- a/src/views/Home/MapCtrl/Map3D/Map3D.js +++ b/src/views/Home/MapCtrl/Map3D/Map3D.js @@ -1,6 +1,7 @@ import config from '../config'; import LayerMgr3D from './layermgr3d'; import BaseMap from '../basemap'; +import Demo3D from './demo' import { ToolManager } from './ToolManager3D'; const { Cesium } = window; @@ -38,6 +39,7 @@ export default class Map3D extends BaseMap { this._map = null; // openlayers map obj this.layerMgr = null; this.toolMgr = null; + this.demo = null; // @ts-ignore const open = XMLHttpRequest.prototype.open; @@ -59,73 +61,31 @@ export default class Map3D extends BaseMap { const tiandiKey = "efc861f25f96dc6e5f884f0403ebfefd"; //天地图key,官网申请 const baseUrl = "https://{s}.tianditu.gov.cn";//'https://t{0-7}.tianditu.gov.cn'; - /*const viewer = new Cesium.Viewer(this.divid, { - animation: false, - baseLayerPicker: false, - geocoder: false, - sceneModePicker: false, - fullscreenButton: false, - homeButton: false, - timeline: false, - navigationHelpButton: false, - // scene3DOnly: true, - shadows: false, - infoBox: false, - terrainProvider: new Cesium.CesiumTerrainProvider({ - //url: config.baseDemUrl, - url: 'http://res3dstatic5.cloudowr.cn/wufeng/terrain', - requestVertexNormals: true, - }), - sceneMode: Cesium.SceneMode.COLUMBUS_VIEW, - - imageryProvider: new Cesium.UrlTemplateImageryProvider({ - //url: 'http://mt1.google.cn/vt/lyrs=s&hl=zh-CN&x={x}&y={y}&z={z}&s=Gali', - // url: 'http://t0.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=efc861f25f96dc6e5f884f0403ebfefd', - url: `http://res3dstatic{s}.cloudowr.cn/${localStorage.getItem('address')}/dom2/{z}/{x}/{y}.png`, - // url: `http://112.35.144.31:8888/lfdzspd/${localStorage.getItem('address')}/dom2/{z}/{x}/{y}.png`, - /!*subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'], - maximumLevel: 18,*!/ - subdomains: ['1', '2', '3'], - maximumLevel: 17, - }), - // targetFrameRate: 10, - });*/ - const viewer = new Cesium.Viewer(this.divid, { - terrainProvider: new Cesium.CesiumTerrainProvider({ - //url: 'http://res3dstatic5.cloudowr.cn/wufeng/terrain', - url:"/shzh/mapres/terrain", - requestVertexNormals: true, - }), - imageryProvider: new Cesium.UrlTemplateImageryProvider({ - //url: `http://res3dstatic{s}.cloudowr.cn/${localStorage.getItem('address')}/dom2/{z}/{x}/{y}.png`, - url: baseUrl + '/DataServer?T=img_w&x={x}&y={y}&l={z}&tk='+tiandiKey, - subdomains: ['t0', 't1', 't2', 't3', 't4', 't5', 't6', 't7'], - //minimumLevel:10, - maximumLevel: 17, - }), - scene3DOnly: true, - animation: false, - baseLayerPicker: false, - geocoder: false, - sceneModePicker: false, - fullscreenButton: false, - homeButton: false, - timeline: false, - navigationHelpButton: false, - shadows: false, - infoBox: false, - skyAtmosphere: false,//去掉球边缘 - }); + terrain: Cesium.Terrain.fromWorldTerrain({ + requestVertexNormals: true, + }), + scene3DOnly: true,//用于强制场景以 3D 模式运行,禁止切换至 2D 或 Columbus 视图 + animation: false,//获取动画小部件。 + baseLayerPicker: false,//获取BaseLayerPicker。 + geocoder: false,//获取地理编码器 + sceneModePicker: false,//Gets the SceneModePicker. + fullscreenButton: false, + homeButton: false, + timeline: false, + navigationHelpButton: false,//导航帮助按钮 + shadows: false,//确定阴影是否由光源投射。 + infoBox: false, + skyAtmosphere: false,//去掉球边缘 + }); + //设置地表透明 let globe = viewer.scene.globe; - globe.depthTestAgainstTerrain = false; + globe.depthTestAgainstTerrain = false;//关闭深度测试 //viewer.scene.skyAtmosphere.show = false; //关闭大气层阴影 viewer.scene.screenSpaceCameraController.minimumZoomDistance = 100; - viewer.scene.screenSpaceCameraController.maximumZoomDistance = 200000; - - + // viewer.scene.screenSpaceCameraController.maximumZoomDistance = 200000; viewer.scene.globe.enableLighting = false; //关闭光照 viewer.shadows = false;//关闭阴影 viewer.scene.globe.depthTestAgainstTerrain = false;//解决地形遮挡entity问题 @@ -136,34 +96,31 @@ export default class Map3D extends BaseMap { viewer.scene.sun.show = false; //太阳 viewer.scene.skyBox.show = false; //天空盒 viewer.resolutionScale = 1.0; //画面细度,默认值为1.0 - viewer.scene.fxaa = false; viewer.scene.postProcessStages.fxaa.enabled = true; viewer.scene.globe.depthTestAgainstTerrain = true; viewer.scene.globe.baseColor = Cesium.Color.TRANSPARENT;//设置球的基础色 viewer.scene.globe.undergroundColor= Cesium.Color.BLACK.withAlpha(0.5);//设置球的地下色 viewer.scene.backgroundColor = Cesium.Color.BLACK; - viewer.scene.screenSpaceCameraController.tiltEventTypes = [ Cesium.CameraEventType.RIGHT_DRAG, Cesium.CameraEventType.PINCH, { eventType: Cesium.CameraEventType.LEFT_DRAG, modifier: Cesium.KeyboardEventModifier.CTRL }, { eventType: Cesium.CameraEventType.RIGHT_DRAG, modifier: Cesium.KeyboardEventModifier.CTRL } ]; - viewer.scene.screenSpaceCameraController.zoomEventTypes = [ Cesium.CameraEventType.MIDDLE_DRAG, Cesium.CameraEventType.WHEEL, Cesium.CameraEventType.PINCH ]; //加载倾斜摄影 - var tileset = new Cesium.Cesium3DTileset({ - //url: 'http://res3dstatic7.cloudowr.cn/wufeng/3dtile/tileset.json', - url: localStorage.getItem('address')==="wufeng"? - 'service2/kshdata/1221wtz-3dtile-all/tileset.json': - "service2/kshdata/GRH/tileset.json", - maximumScreenSpaceError: 32, - maximumMemoryUsage: 100, //不可设置太高,目标机子空闲内存值以内,防止浏览器过于卡 - }); + // var tileset = new Cesium.Cesium3DTileset({ + // //url: 'http://res3dstatic7.cloudowr.cn/wufeng/3dtile/tileset.json', + // url: localStorage.getItem('address')==="wufeng"? + // 'service2/kshdata/1221wtz-3dtile-all/tileset.json': + // "service2/kshdata/GRH/tileset.json", + // maximumScreenSpaceError: 32, + // maximumMemoryUsage: 100, //不可设置太高,目标机子空闲内存值以内,防止浏览器过于卡 + // }); // fetch(`${process.env.PUBLIC_URL}/data/geojson/${localStorage.getItem('address')}/boua.geojson`) // .then(resp => resp.json()) @@ -219,16 +176,7 @@ export default class Map3D extends BaseMap { clampToGround: true, }));*/ - tileset.readyPromise.then(function () { - viewer.zoomTo( - tileset, - new Cesium.HeadingPitchRange( - 0.0, - -0.5, - tileset.boundingSphere.radius * 10 - ) - ); - }); + //监听地图移动完成事件 viewer.camera.moveEnd.addEventListener(() => { @@ -241,6 +189,12 @@ export default class Map3D extends BaseMap { }); this.layerMgr = new LayerMgr3D(viewer); + this.demo = new Demo3D() + + this.demo.getGltf(viewer) + this.demo.getQxsy(viewer) + + viewer.scene.postRender.addEventListener(() => { this.dispatch.runtime.tickViewChanged(); this.layerMgr.frameUpdate(); @@ -286,13 +240,13 @@ export default class Map3D extends BaseMap { } coordinateToPixel(lgtd, lttd, elev) { - const pt = Cesium.Cartesian3.fromDegrees(lgtd, lttd, elev); - const result = Cesium.SceneTransforms.wgs84ToWindowCoordinates( - this._map.scene, pt); - if (!result) { - return null - } - return [result.x, result.y, pt.x, pt.y, pt.z]; + // const pt = Cesium.Cartesian3.fromDegrees(lgtd, lttd, elev); + // const result = Cesium.SceneTransforms.wgs84ToWindowCoordinates( + // this._map.scene, pt); + // if (!result) { + // return null + // } + // return [result.x, result.y, pt.x, pt.y, pt.z]; } /** diff --git a/src/views/Home/MapCtrl/Map3D/Map3DOld.js b/src/views/Home/MapCtrl/Map3D/Map3DOld.js new file mode 100644 index 000000000..299ba0d35 --- /dev/null +++ b/src/views/Home/MapCtrl/Map3D/Map3DOld.js @@ -0,0 +1,333 @@ +import config from '../config'; +import LayerMgr3D from './layermgr3d'; +import BaseMap from '../basemap'; +import { ToolManager } from './ToolManager3D'; + +const { Cesium } = window; + +function __prepare_ces(dispatch) { + Cesium.CesiumWidget.prototype.showErrorPanel = function (title) { + dispatch && dispatch.map.setMode('2d'); + if (title && title.indexOf('constructing') >= 0) { + alert('无法初始化三维场景,如果一直出现此问题,请尝试下载最新的chrome浏览器'); + } else { + alert('三维场景渲染出现问题'); + } + }; +} + +/*根据camera高度近似计算当前层级*/ +const heightToZoom = ( height) => { + var A = 40487.57; + var B = 0.00007096758; + var c = 91610.74; + var D = -40467.74; + return Math.round(D+(A-D)/(1+Math.pow( height/c,B)) ); +} + + +/** + * OL 封装 + */ +export default class Map3D extends BaseMap { + constructor({ divid, dispatch }) { + super(); + + this.dispatch = dispatch; + this.divid = divid; // div element id + this._map = null; // openlayers map obj + this.layerMgr = null; + this.toolMgr = null; + + // @ts-ignore + const open = XMLHttpRequest.prototype.open; + // @ts-ignore + XMLHttpRequest.prototype.open = function (method, url, ...rest) { + if (url.startsWith('http://res3dstatic7')) { + url = url.replaceAll('+', '%2B'); + } + return open.call(this, method, url, ...rest); + }; + } + + /** + * 初始化地图、图层 + */ + init() { + __prepare_ces(this.dispatch); + + const tiandiKey = "efc861f25f96dc6e5f884f0403ebfefd"; //天地图key,官网申请 + const baseUrl = "https://{s}.tianditu.gov.cn";//'https://t{0-7}.tianditu.gov.cn'; + + /*const viewer = new Cesium.Viewer(this.divid, { + animation: false, + baseLayerPicker: false, + geocoder: false, + sceneModePicker: false, + fullscreenButton: false, + homeButton: false, + timeline: false, + navigationHelpButton: false, + // scene3DOnly: true, + shadows: false, + infoBox: false, + terrainProvider: new Cesium.CesiumTerrainProvider({ + //url: config.baseDemUrl, + url: 'http://res3dstatic5.cloudowr.cn/wufeng/terrain', + requestVertexNormals: true, + }), + sceneMode: Cesium.SceneMode.COLUMBUS_VIEW, + + imageryProvider: new Cesium.UrlTemplateImageryProvider({ + //url: 'http://mt1.google.cn/vt/lyrs=s&hl=zh-CN&x={x}&y={y}&z={z}&s=Gali', + // url: 'http://t0.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=efc861f25f96dc6e5f884f0403ebfefd', + url: `http://res3dstatic{s}.cloudowr.cn/${localStorage.getItem('address')}/dom2/{z}/{x}/{y}.png`, + // url: `http://112.35.144.31:8888/lfdzspd/${localStorage.getItem('address')}/dom2/{z}/{x}/{y}.png`, + /!*subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'], + maximumLevel: 18,*!/ + subdomains: ['1', '2', '3'], + maximumLevel: 17, + }), + // targetFrameRate: 10, + });*/ + + const viewer = new Cesium.Viewer(this.divid, { + terrainProvider: new Cesium.CesiumTerrainProvider({ + //url: 'http://res3dstatic5.cloudowr.cn/wufeng/terrain', + url:"/shzh/mapres/terrain", + requestVertexNormals: true, + }), + imageryProvider: new Cesium.UrlTemplateImageryProvider({ + //url: `http://res3dstatic{s}.cloudowr.cn/${localStorage.getItem('address')}/dom2/{z}/{x}/{y}.png`, + url: baseUrl + '/DataServer?T=img_w&x={x}&y={y}&l={z}&tk='+tiandiKey, + subdomains: ['t0', 't1', 't2', 't3', 't4', 't5', 't6', 't7'], + //minimumLevel:10, + maximumLevel: 17, + }), + scene3DOnly: true, + animation: false, + baseLayerPicker: false, + geocoder: false, + sceneModePicker: false, + fullscreenButton: false, + homeButton: false, + timeline: false, + navigationHelpButton: false, + shadows: false, + infoBox: false, + skyAtmosphere: false,//去掉球边缘 + }); + + //设置地表透明 + let globe = viewer.scene.globe; + globe.depthTestAgainstTerrain = false; + //viewer.scene.skyAtmosphere.show = false; //关闭大气层阴影 + viewer.scene.screenSpaceCameraController.minimumZoomDistance = 100; + viewer.scene.screenSpaceCameraController.maximumZoomDistance = 200000; + + + viewer.scene.globe.enableLighting = false; //关闭光照 + viewer.shadows = false;//关闭阴影 + viewer.scene.globe.depthTestAgainstTerrain = false;//解决地形遮挡entity问题 + + //优化项--关闭相关特效 + viewer.scene.moon.show = false; //月亮 + viewer.scene.fog.enabled = false; //雾 + viewer.scene.sun.show = false; //太阳 + viewer.scene.skyBox.show = false; //天空盒 + viewer.resolutionScale = 1.0; //画面细度,默认值为1.0 + + viewer.scene.fxaa = false; + viewer.scene.postProcessStages.fxaa.enabled = true; + viewer.scene.globe.depthTestAgainstTerrain = true; + viewer.scene.globe.baseColor = Cesium.Color.TRANSPARENT;//设置球的基础色 + viewer.scene.globe.undergroundColor= Cesium.Color.BLACK.withAlpha(0.5);//设置球的地下色 + viewer.scene.backgroundColor = Cesium.Color.BLACK; + + viewer.scene.screenSpaceCameraController.tiltEventTypes = [ + Cesium.CameraEventType.RIGHT_DRAG, Cesium.CameraEventType.PINCH, + { eventType: Cesium.CameraEventType.LEFT_DRAG, modifier: Cesium.KeyboardEventModifier.CTRL }, + { eventType: Cesium.CameraEventType.RIGHT_DRAG, modifier: Cesium.KeyboardEventModifier.CTRL } + ]; + + viewer.scene.screenSpaceCameraController.zoomEventTypes = [ + Cesium.CameraEventType.MIDDLE_DRAG, Cesium.CameraEventType.WHEEL, Cesium.CameraEventType.PINCH + ]; + + + //加载倾斜摄影 + var tileset = new Cesium.Cesium3DTileset({ + //url: 'http://res3dstatic7.cloudowr.cn/wufeng/3dtile/tileset.json', + url: localStorage.getItem('address')==="wufeng"? + 'service2/kshdata/1221wtz-3dtile-all/tileset.json': + "service2/kshdata/GRH/tileset.json", + maximumScreenSpaceError: 32, + maximumMemoryUsage: 100, //不可设置太高,目标机子空闲内存值以内,防止浏览器过于卡 + }); + + // fetch(`${process.env.PUBLIC_URL}/data/geojson/${localStorage.getItem('address')}/boua.geojson`) + // .then(resp => resp.json()) + // .then(data => { + // let features = data.features; + // let positionArray = []; + + // // 获取区域的经纬度坐标 + // for (let i = 0; i < features[0].geometry.coordinates[0].length; i++) { + // let coor = features[0].geometry.coordinates[0][i]; + // positionArray.push(coor[0]); + // positionArray.push(coor[1]); + // } + + // // 遮罩 + // let polygonEntity = new Cesium.Entity({ + // polygon: { + // hierarchy: { + // // 添加外部区域为1/4半圆,设置为180会报错 [0, 0, 0, 90, 179, 90, 179, 0] + // positions: Cesium.Cartesian3.fromDegreesArray([100, 0, 100, 89, 150, 89, 150, 0]), + // // 中心挖空的“洞” + // holes: [{ + // positions: Cesium.Cartesian3.fromDegreesArray(positionArray) + // }] + // }, + // material: Cesium.Color.BLACK.withAlpha(0.7) //new Cesium.Color(236,242,249, 1) + // } + // }); + + // // 边界线 + // let lineEntity = new Cesium.Entity({ + // polyline: { + // positions: Cesium.Cartesian3.fromDegreesArray(positionArray), + // width: 7, + // material: Cesium.Color.fromCssColorString('#7AE3C8'),//边界线颜色//Cesium.Color.YELLOW //new Cesium.Color(122,227,200, 1) + // clampToGround: true, + // zIndex: 10 + // } + // }); + + // viewer.entities.add(polygonEntity); + // viewer.entities.add(lineEntity); + // //viewer.flyTo(lineEntity); + // }); + + + //添加到球体上 + // viewer.scene.primitives.add(tileset); + + /*viewer.dataSources.add(Cesium.GeoJsonDataSource.load('http://res3dstatic4.cloudowr.cn/wufeng/geojson/boua.geojson', { + stroke: Cesium.Color.PINK, + strokeWidth: 3, + clampToGround: true, + }));*/ + + tileset.readyPromise.then(function () { + viewer.zoomTo( + tileset, + new Cesium.HeadingPitchRange( + 0.0, + -0.5, + tileset.boundingSphere.radius * 10 + ) + ); + }); + + //监听地图移动完成事件 + viewer.camera.moveEnd.addEventListener(() => { + //获取当前相机高度 + let height = Math.ceil(viewer.camera.positionCartographic.height); + let zoom = heightToZoom(height); + + console.log('地图变化监听事件',zoom); + + }); + + this.layerMgr = new LayerMgr3D(viewer); + viewer.scene.postRender.addEventListener(() => { + this.dispatch.runtime.tickViewChanged(); + this.layerMgr.frameUpdate(); + }); + + this.toolMgr = new ToolManager(viewer, this.dispatch); + this.toolMgr.init(); + + viewer.camera.setView({ + destination: Cesium.Cartesian3.fromDegrees(...config.homeCenter3D), + orientation: { + heading: Cesium.Math.toRadians(0), + pitch: Cesium.Math.toRadians(-35.0), + roll: 0.0 + } + }); + + // 限制相机高度 + // 相机最低高度 + const minimumHeight = 120; + + // 在渲染阶段前添加事件监听器 + viewer.scene.preRender.addEventListener(function () { + var eye = viewer.camera.positionCartographic; + + // 判断相机坐标是否小于阈值,若小于阈值,则保持视点方位,修改相机高度 + if (eye.height < minimumHeight) { + viewer.camera.setView({ + destination: Cesium.Cartesian3.fromRadians(eye.longitude, eye.latitude, minimumHeight), + orientation: { + direction: viewer.camera.direction, + up: viewer.camera.up + } + }); + } + }); + + this._map = viewer; + const toremove = document.getElementsByClassName('cesium-widget-credits'); + if (toremove && toremove[0]) { + toremove[0].style.display = 'none'; + } + } + + coordinateToPixel(lgtd, lttd, elev) { + const pt = Cesium.Cartesian3.fromDegrees(lgtd, lttd, elev); + const result = Cesium.SceneTransforms.wgs84ToWindowCoordinates( + this._map.scene, pt); + if (!result) { + return null + } + return [result.x, result.y, pt.x, pt.y, pt.z]; + } + + /** + * 组件卸载时,需要销毁map对象 + */ + destroy() { + console.log('##############destroy##############'); + if (!this.layerMgr) { + return; + } + this.layerMgr.destroy(); + if (this._map) { + this._map.destroy(); + this._map = null; + } + } + + /** + * get layer obj + */ + getLayer(name) { + return this.layerMgr.getLayer(name); + } + + zoomTo(cameraTarget) { + if (cameraTarget.center) { + this._map.camera.flyToBoundingSphere(new Cesium.BoundingSphere( + Cesium.Cartesian3.fromDegrees(cameraTarget.center[0], cameraTarget.center[1], cameraTarget.center[2] || 0), + 800) + ); + } else if (cameraTarget.bound) { + const b = cameraTarget.bound; + const p1 = Cesium.Cartesian3.fromDegrees(...b[0]); + const p2 = Cesium.Cartesian3.fromDegrees(...b[1]); + this._map.camera.flyToBoundingSphere(Cesium.BoundingSphere.fromPoints([p1, p2])); + } + } +} diff --git a/src/views/Home/MapCtrl/Map3D/demo.js b/src/views/Home/MapCtrl/Map3D/demo.js index 55aa033e1..cef73b046 100644 --- a/src/views/Home/MapCtrl/Map3D/demo.js +++ b/src/views/Home/MapCtrl/Map3D/demo.js @@ -1,78 +1,89 @@ +const { Cesium } = window; + + export default class LayerMgr { - constructor({ viewer }) { - this.viewer = viewer + constructor() { + // this.viewer = viewer } //加载模型 - getGltf() { - const model = this.viewer.scene.primitives.add(Cesium.Model.fromGltf({ - url: `${process.env.PUBLIC_URL}/models/dam/scene.gltf`, - modelMatrix: Cesium.Transforms.eastNorthUpToFixedFrame( - Cesium.Cartesian3.fromDegrees(114.97, 31.48) // 模型位置 - ), - scale: 100 - })); + getGltf(viewer) { + viewer.entities.add({ + position: Cesium.Cartesian3.fromDegrees(114.97, 31.48), + model: { + uri: `${process.env.PUBLIC_URL}/models/dam/scene.gltf` , + scale: 200, + runAnimations: false + }, + }); } - getWater() { - let initialHeight = 130 - const geometry = new Cesium.PolygonGeometry({ - polygonHierarchy: new Cesium.PolygonHierarchy( - Cesium.Cartesian3.fromDegreesArray(positions) - ), - extrudedHeight: initialHeight - }); - const waterPrimitive = new Cesium.Primitive({ - geometryInstances: new Cesium.GeometryInstance({ geometry }), - appearance: new Cesium.EllipsoidSurfaceAppearance({ - aboveGround: true, - material: new Cesium.Material({ - fabric: { - type: 'Water', - uniforms: { - normalMap: Cesium.buildModuleUrl( - `${process.env.PUBLIC_URL}/models/waternormals.jpg` - ), - frequency: 1000.0, - animationSpeed: 0.01, - amplitude: 10, - }, - }, - }), - }), - show: true, - // releaseGeometryInstances: false - }); - this.viewer.scene.primitives.add(waterPrimitive); - // 自动抬升 - let height = 0; - setInterval(() => { - if (height < 0.4) { - height += 0.001; - // height += 0.02; - // waterPrimitive.extrudedHeight = height; // 触发setter - var currentModelMatrix = Cesium.Matrix4.clone(waterPrimitive.modelMatrix); - // 定义平移向量(例如,沿x轴平移100单位) - var translation = new Cesium.Cartesian3(-height*0.7, height, height*0.8); - // 创建一个平移矩阵 - var translationMatrix = Cesium.Matrix4.fromTranslation(translation); - // 计算新的modelMatrix(将平移矩阵应用到当前模型矩阵上) - var newModelMatrix = Cesium.Matrix4.multiply(translationMatrix, currentModelMatrix, new Cesium.Matrix4()); - waterPrimitive.modelMatrix = newModelMatrix; - } - }, 100); + getWater(viewer) { + // let initialHeight = 130 + // const geometry = new Cesium.PolygonGeometry({ + // polygonHierarchy: new Cesium.PolygonHierarchy( + // Cesium.Cartesian3.fromDegreesArray(positions) + // ), + // extrudedHeight: initialHeight + // }); + // const waterPrimitive = new Cesium.Primitive({ + // geometryInstances: new Cesium.GeometryInstance({ geometry }), + // appearance: new Cesium.EllipsoidSurfaceAppearance({ + // aboveGround: true, + // material: new Cesium.Material({ + // fabric: { + // type: 'Water', + // uniforms: { + // normalMap: Cesium.buildModuleUrl( + // `${process.env.PUBLIC_URL}/models/waternormals.jpg` + // ), + // frequency: 1000.0, + // animationSpeed: 0.01, + // amplitude: 10, + // }, + // }, + // }), + // }), + // show: true, + // // releaseGeometryInstances: false + // }); + // this.viewer.scene.primitives.add(waterPrimitive); + // // 自动抬升 + // let height = 0; + // setInterval(() => { + // if (height < 0.4) { + // height += 0.001; + // // height += 0.02; + // // waterPrimitive.extrudedHeight = height; // 触发setter + // var currentModelMatrix = Cesium.Matrix4.clone(waterPrimitive.modelMatrix); + // // 定义平移向量(例如,沿x轴平移100单位) + // var translation = new Cesium.Cartesian3(-height*0.7, height, height*0.8); + // // 创建一个平移矩阵 + // var translationMatrix = Cesium.Matrix4.fromTranslation(translation); + // // 计算新的modelMatrix(将平移矩阵应用到当前模型矩阵上) + // var newModelMatrix = Cesium.Matrix4.multiply(translationMatrix, currentModelMatrix, new Cesium.Matrix4()); + // waterPrimitive.modelMatrix = newModelMatrix; + // } + // }, 100); } - getQxsy() { - var tileset = new Cesium.Cesium3DTileset({ - // url: 'http://res3dstatic7.cloudowr.cn/wufeng/3dtile/tileset.json', - url: - // 'service2/kshdata/1221wtz-3dtile-all/tileset.json', + async getQxsy(viewer) { + try { + let tileset = await Cesium.Cesium3DTileset.fromUrl( 'http://res3d.oss-cn-shenzhen.aliyuncs.com/macheng/xiaoyutan/Scene/3DTILE.json', - // "service2/kshdata/GRH/tileset.json", - maximumScreenSpaceError: 1, //精细程度越小越精细 - maximumMemoryUsage: 1000, //不可设置太高,目标机子空闲内存值以内,防止浏览器过于卡 - }); + { + maximumScreenSpaceError: 1, //精细程度越小越精细 + maximumMemoryUsage: 1000, //不可设置太高,目标机子空闲内存值以内,防止浏览器过于卡 + } + + ); + viewer.scene.primitives.add(tileset); + } catch (error) { + console.error(`Error creating tileset: ${error}`); + } + + + // fetch(`${process.env.PUBLIC_URL}/data/geojson/macheng/boua.geojson`) // .then(resp => resp.json()) // .then(data => { @@ -117,32 +128,30 @@ export default class LayerMgr { // }); - //添加到球体上 - viewer.scene.primitives.add(tileset); - tileset.readyPromise.then(function () { - viewer.zoomTo( - tileset, - new Cesium.HeadingPitchRange( - 0, - -0.7, - 2500 - // tileset.boundingSphere.radius * 10 - ) - ); - }); + // tileset.readyPromise.then(function () { + // viewer.zoomTo( + // tileset, + // new Cesium.HeadingPitchRange( + // 0, + // -0.7, + // 2500 + // // tileset.boundingSphere.radius * 10 + // ) + // ); + // }); //设置倾斜摄影Z轴高度 - tileset.readyPromise.then(function (tileset) { - const offsetHeight = 15 - const boundingSphere = tileset.boundingSphere - const cartographic = Cesium.Cartographic.fromCartesian(boundingSphere.center) - const surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0) - const offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, offsetHeight) - const translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3()) - tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation) - // viewer.flyTo(tileset) - }) + // tileset.readyPromise.then(function (tileset) { + // const offsetHeight = 15 + // const boundingSphere = tileset.boundingSphere + // const cartographic = Cesium.Cartographic.fromCartesian(boundingSphere.center) + // const surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0) + // const offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, offsetHeight) + // const translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3()) + // tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation) + // // viewer.flyTo(tileset) + // }) } } diff --git a/src/views/Home/MapCtrl/Map3D/layermgr3d.js b/src/views/Home/MapCtrl/Map3D/layermgr3d.js index 910931fec..f8fe6a0a6 100644 --- a/src/views/Home/MapCtrl/Map3D/layermgr3d.js +++ b/src/views/Home/MapCtrl/Map3D/layermgr3d.js @@ -51,40 +51,39 @@ export default class LayerMgr3D extends LayerMgr { */ addAppLayers(dispatch, visible, setting, otherParams) { visible = visible || {}; + // this.addLayer(new BouaLayer3D({ visible: visible[BouaLayer3D.LayerName], setting, dispatch })); - this.addLayer(new BouaLayer3D({ visible: visible[BouaLayer3D.LayerName], setting, dispatch })); + // if(visible[RainLayer3D.LayerName]){ + // this.addLayer(new RainLayer3D({ visible: visible[RainLayer3D.LayerName], setting, dispatch })); + // }else{ + // //this.viewer.imageryLayers.removeAll(); + // this.viewer.entities.removeAll(); + // } + // if(visible[RainLayer3DRadar.LayerName]){ + // this.addLayer(new RainLayer3DRadar({ visible: visible[RainLayer3DRadar.LayerName], setting, dispatch })); + // }else{ + // //this.viewer.imageryLayers.removeAll(); + // this.viewer.entities.removeAll(); + // } + // if(visible[RainLayer3DRh.LayerName]){ + // this.addLayer(new RainLayer3DRh({ visible: visible[RainLayer3DRh.LayerName], setting, dispatch })); + // }else{ + // //this.viewer.imageryLayers.removeAll(); RainLayer3DRh + // this.viewer.entities.removeAll(); + // } - if(visible[RainLayer3D.LayerName]){ - this.addLayer(new RainLayer3D({ visible: visible[RainLayer3D.LayerName], setting, dispatch })); - }else{ - //this.viewer.imageryLayers.removeAll(); - this.viewer.entities.removeAll(); - } - if(visible[RainLayer3DRadar.LayerName]){ - this.addLayer(new RainLayer3DRadar({ visible: visible[RainLayer3DRadar.LayerName], setting, dispatch })); - }else{ - //this.viewer.imageryLayers.removeAll(); - this.viewer.entities.removeAll(); - } - if(visible[RainLayer3DRh.LayerName]){ - this.addLayer(new RainLayer3DRh({ visible: visible[RainLayer3DRh.LayerName], setting, dispatch })); - }else{ - //this.viewer.imageryLayers.removeAll(); RainLayer3DRh - this.viewer.entities.removeAll(); - } - - if(visible[HLLayer3D.LayerName]){ - this.addLayer(new HLLayer3D({ visible: visible[HLLayer3D.LayerName], setting, dispatch })); - }else{ - //this.viewer.imageryLayers.removeAll(); - this.viewer.entities.removeAll(); - } - if(visible[XLYLayer3D.LayerName]){ - this.addLayer(new XLYLayer3D({ visible: visible[XLYLayer3D.LayerName], setting, dispatch })); - }else{ - //this.viewer.imageryLayers.removeAll(); - this.viewer.entities.removeAll(); - } + // if(visible[HLLayer3D.LayerName]){ + // this.addLayer(new HLLayer3D({ visible: visible[HLLayer3D.LayerName], setting, dispatch })); + // }else{ + // //this.viewer.imageryLayers.removeAll(); + // this.viewer.entities.removeAll(); + // } + // if(visible[XLYLayer3D.LayerName]){ + // this.addLayer(new XLYLayer3D({ visible: visible[XLYLayer3D.LayerName], setting, dispatch })); + // }else{ + // //this.viewer.imageryLayers.removeAll(); + // this.viewer.entities.removeAll(); + // } this._addAppMarkerLayers(dispatch, visible, setting, otherParams); }