智慧园区案例

This commit is contained in:
jiawanlong 2025-03-23 09:30:00 +08:00
parent da78e95fc8
commit 87c731257b
38 changed files with 2602 additions and 1 deletions

136
examples/cesiumEx/000.html Normal file
View File

@ -0,0 +1,136 @@
<!--********************************************************************
* by M3D
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link href="https://cesium.com/downloads/cesiumjs/releases/1.103/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.2/animate.min.css" rel="stylesheet">
<script type="text/javascript"
src="https://cesium.com/downloads/cesiumjs/releases/1.103/Build/Cesium/Cesium.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script type="text/javascript" src=" https://cdnjs.cloudflare.com/ajax/libs/wow/1.1.2/wow.min.js"></script>
<script type="text/javascript" src="./gis-scene-sh/index.js"></script>
<style>
html,
body,
#sceneContainer {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
background: #000;
}
#uiContainer {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
#uiContainer {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#topUI {
position: absolute;
width: 100%;
height: 10%;
margin: 0;
padding: 0;
left: 0;
top: 0;
background-image: url("./gis-scene-sh/Static/images/top.png");
background-repeat: round;
pointer-events: none;
}
#leftUI {
position: absolute;
width: 20%;
height: 90%;
margin: 0;
padding: 0;
left: 0;
top: 5%;
background-image: url("./gis-scene-sh/Static/images/left.png");
background-repeat: round;
pointer-events: none;
}
#roghtUI {
position: absolute;
width: 20%;
height: 90%;
margin: 0;
padding: 0;
right: 0;
top: 5%;
background-image: url("./gis-scene-sh/Static/images/right.png");
background-repeat: round;
pointer-events: none;
}
.loadingIndicator {
display: block;
position: absolute;
top: 50%;
left: 50%;
margin-top: -33px;
margin-left: -33px;
width: 66px;
height: 66px;
z-index: 99;
background-position: center;
background-repeat: no-repeat;
background-image: url("./gis-scene-sh/Static/images/ajax-loader.gif");
}
.loadingIndicator2 {
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
background: #000;
}
.bvideo {
position: absolute;
top:10px;
left: 10px;
font-size: 13px;
color: #fff;
z-index: 9999;
}
.view {
position: absolute;
top:10px;
left: 110px;
font-size: 13px;
color: #fff;
z-index: 9999;
}
</style>
</head>
<body style="margin: 0; overflow: hidden; background: #fff; width: 100%; height: 100%; position: absolute; top: 0">
<div id="map" style="margin: 0 auto; width: 100%; height: 100%"></div>
<div id="sceneContainer"></div>
<div id="loadingIndicator" class="loadingIndicator"></div>
<div id="loadingIndicator2" class="loadingIndicator2"></div>
</body>
</html>

View File

@ -25,7 +25,12 @@ var exampleConfig = {
thumbnail: "案例1.jpg",
fileName: "0"
},
{
name: "智慧园区",
name_en: "智慧城市",
thumbnail: "000.jpg",
fileName: "000"
},
{
name: "台风",
name_en: "台风",

View File

@ -0,0 +1,11 @@
Model Information:
* title: Building - beveled corners - shiny
* source: https://sketchfab.com/3d-models/building-beveled-corners-shiny-c966bde825cd4254841a0e8b9252eee8
* author: MozillaHubs (https://sketchfab.com/mozillareality)
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 "Building - beveled corners - shiny" (https://sketchfab.com/3d-models/building-beveled-corners-shiny-c966bde825cd4254841a0e8b9252eee8) by MozillaHubs (https://sketchfab.com/mozillareality) licensed under CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)

View File

@ -0,0 +1,265 @@
{
"accessors": [
{
"bufferView": 2,
"componentType": 5126,
"count": 390,
"max": [
1500.0,
12000.0,
1500.0
],
"min": [
-1500.0,
0.0,
-1500.00048828125
],
"type": "VEC3"
},
{
"bufferView": 2,
"byteOffset": 4680,
"componentType": 5126,
"count": 390,
"max": [
1.0,
1.0,
1.0
],
"min": [
-1.0,
-0.04415131360292435,
-1.0
],
"type": "VEC3"
},
{
"bufferView": 3,
"componentType": 5126,
"count": 390,
"max": [
1.0,
0.0004603353445418179,
1.0,
1.0
],
"min": [
-1.0,
-0.00018968465155921876,
-1.0,
1.0
],
"type": "VEC4"
},
{
"bufferView": 1,
"componentType": 5126,
"count": 390,
"max": [
0.9995487332344055,
1.0000228881835938
],
"min": [
-6.255637572394335e-07,
0.0012021064758300781
],
"type": "VEC2"
},
{
"bufferView": 0,
"componentType": 5125,
"count": 654,
"type": "SCALAR"
}
],
"asset": {
"extras": {
"author": "MozillaHubs (https://sketchfab.com/mozillareality)",
"license": "CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)",
"source": "https://sketchfab.com/3d-models/building-beveled-corners-shiny-c966bde825cd4254841a0e8b9252eee8",
"title": "Building - beveled corners - shiny"
},
"generator": "Sketchfab-12.66.0",
"version": "2.0"
},
"bufferViews": [
{
"buffer": 0,
"byteLength": 2616,
"name": "floatBufferViews",
"target": 34963
},
{
"buffer": 0,
"byteLength": 3120,
"byteOffset": 2616,
"byteStride": 8,
"name": "floatBufferViews",
"target": 34962
},
{
"buffer": 0,
"byteLength": 9360,
"byteOffset": 5736,
"byteStride": 12,
"name": "floatBufferViews",
"target": 34962
},
{
"buffer": 0,
"byteLength": 6240,
"byteOffset": 15096,
"byteStride": 16,
"name": "floatBufferViews",
"target": 34962
}
],
"buffers": [
{
"byteLength": 21336,
"uri": "scene.bin"
}
],
"images": [
{
"uri": "textures/lambert1_baseColor.jpeg"
},
{
"uri": "textures/lambert1_metallicRoughness.png"
},
{
"uri": "textures/lambert1_normal.png"
}
],
"materials": [
{
"name": "lambert1",
"normalTexture": {
"index": 2
},
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 0
},
"metallicRoughnessTexture": {
"index": 1
}
}
}
],
"meshes": [
{
"name": "Building_bevelCorners_lambert1_0",
"primitives": [
{
"attributes": {
"NORMAL": 1,
"POSITION": 0,
"TANGENT": 2,
"TEXCOORD_0": 3
},
"indices": 4,
"material": 0,
"mode": 4
}
]
}
],
"nodes": [
{
"children": [
1
],
"matrix": [
0.009999999776482582,
0.0,
0.0,
0.0,
0.0,
2.2204459996194763e-18,
-0.009999999776482582,
0.0,
0.0,
0.009999999776482582,
2.2204459996194763e-18,
0.0,
0.0,
0.0,
0.0,
1.0
],
"name": "Sketchfab_model"
},
{
"children": [
2
],
"matrix": [
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
1.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
1.0
],
"name": "7535f1433fe5458a9f37da71b1dbabfb.fbx"
},
{
"children": [
3
],
"name": "RootNode"
},
{
"children": [
4
],
"name": "Building_bevelCorners"
},
{
"mesh": 0,
"name": "Building_bevelCorners_lambert1_0"
}
],
"samplers": [
{
"magFilter": 9729,
"minFilter": 9987,
"wrapS": 10497,
"wrapT": 10497
}
],
"scene": 0,
"scenes": [
{
"name": "Sketchfab_Scene",
"nodes": [
0
]
}
],
"textures": [
{
"sampler": 0,
"source": 0
},
{
"sampler": 0,
"source": 1
},
{
"sampler": 0,
"source": 2
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -0,0 +1,11 @@
Model Information:
* title: Building - octagonal - shiny
* source: https://sketchfab.com/3d-models/building-octagonal-shiny-85dab84154c24e569e62a8dabfd4c8cb
* author: MozillaHubs (https://sketchfab.com/mozillareality)
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 "Building - octagonal - shiny" (https://sketchfab.com/3d-models/building-octagonal-shiny-85dab84154c24e569e62a8dabfd4c8cb) by MozillaHubs (https://sketchfab.com/mozillareality) licensed under CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)

View File

@ -0,0 +1,265 @@
{
"accessors": [
{
"bufferView": 2,
"componentType": 5126,
"count": 352,
"max": [
2000.000244140625,
14999.994140625,
2000.0
],
"min": [
-1999.999755859375,
0.0,
-1999.999755859375
],
"type": "VEC3"
},
{
"bufferView": 2,
"byteOffset": 4224,
"componentType": 5126,
"count": 352,
"max": [
0.9238796234130859,
1.0,
0.9238796234130859
],
"min": [
-0.9238796830177307,
-1.2182964326257206e-07,
-0.9238796234130859
],
"type": "VEC3"
},
{
"bufferView": 3,
"componentType": 5126,
"count": 352,
"max": [
0.9238797426223755,
4.738464554066013e-07,
0.9238797426223755,
1.0
],
"min": [
-0.9238799810409546,
-9.476929108132026e-07,
-0.9238800406455994,
1.0
],
"type": "VEC4"
},
{
"bufferView": 1,
"componentType": 5126,
"count": 352,
"max": [
0.9987980127334595,
1.0000007152557373
],
"min": [
-1.7881393432617188e-07,
0.0012021064758300781
],
"type": "VEC2"
},
{
"bufferView": 0,
"componentType": 5125,
"count": 522,
"type": "SCALAR"
}
],
"asset": {
"extras": {
"author": "MozillaHubs (https://sketchfab.com/mozillareality)",
"license": "CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)",
"source": "https://sketchfab.com/3d-models/building-octagonal-shiny-85dab84154c24e569e62a8dabfd4c8cb",
"title": "Building - octagonal - shiny"
},
"generator": "Sketchfab-12.66.0",
"version": "2.0"
},
"bufferViews": [
{
"buffer": 0,
"byteLength": 2088,
"name": "floatBufferViews",
"target": 34963
},
{
"buffer": 0,
"byteLength": 2816,
"byteOffset": 2088,
"byteStride": 8,
"name": "floatBufferViews",
"target": 34962
},
{
"buffer": 0,
"byteLength": 8448,
"byteOffset": 4904,
"byteStride": 12,
"name": "floatBufferViews",
"target": 34962
},
{
"buffer": 0,
"byteLength": 5632,
"byteOffset": 13352,
"byteStride": 16,
"name": "floatBufferViews",
"target": 34962
}
],
"buffers": [
{
"byteLength": 18984,
"uri": "scene.bin"
}
],
"images": [
{
"uri": "textures/lambert1_baseColor.jpeg"
},
{
"uri": "textures/lambert1_metallicRoughness.png"
},
{
"uri": "textures/lambert1_normal.png"
}
],
"materials": [
{
"name": "lambert1",
"normalTexture": {
"index": 2
},
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 0
},
"metallicRoughnessTexture": {
"index": 1
}
}
}
],
"meshes": [
{
"name": "Building_octagon_lambert1_0",
"primitives": [
{
"attributes": {
"NORMAL": 1,
"POSITION": 0,
"TANGENT": 2,
"TEXCOORD_0": 3
},
"indices": 4,
"material": 0,
"mode": 4
}
]
}
],
"nodes": [
{
"children": [
1
],
"matrix": [
0.009999999776482582,
0.0,
0.0,
0.0,
0.0,
2.2204459996194763e-18,
-0.009999999776482582,
0.0,
0.0,
0.009999999776482582,
2.2204459996194763e-18,
0.0,
0.0,
0.0,
0.0,
1.0
],
"name": "Sketchfab_model"
},
{
"children": [
2
],
"matrix": [
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
1.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
1.0
],
"name": "0d8d883794ef4f7382a9c7c82691f718.fbx"
},
{
"children": [
3
],
"name": "RootNode"
},
{
"children": [
4
],
"name": "Building_octagon"
},
{
"mesh": 0,
"name": "Building_octagon_lambert1_0"
}
],
"samplers": [
{
"magFilter": 9729,
"minFilter": 9987,
"wrapS": 10497,
"wrapT": 10497
}
],
"scene": 0,
"scenes": [
{
"name": "Sketchfab_Scene",
"nodes": [
0
]
}
],
"textures": [
{
"sampler": 0,
"source": 0
},
{
"sampler": 0,
"source": 1
},
{
"sampler": 0,
"source": 2
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -0,0 +1,11 @@
Model Information:
* title: Oriental Pearl, Shanghai.
* source: https://sketchfab.com/3d-models/oriental-pearl-shanghai-a80155b3f47240ce9a2f79fb8bff9024
* author: drosovila (https://sketchfab.com/Drosovila)
Model License:
* license type: CC-BY-NC-4.0 (http://creativecommons.org/licenses/by-nc/4.0/)
* requirements: Author must be credited. No commercial use.
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 "Oriental Pearl, Shanghai." (https://sketchfab.com/3d-models/oriental-pearl-shanghai-a80155b3f47240ce9a2f79fb8bff9024) by drosovila (https://sketchfab.com/Drosovila) licensed under CC-BY-NC-4.0 (http://creativecommons.org/licenses/by-nc/4.0/)

View File

@ -0,0 +1,278 @@
{
"accessors": [
{
"bufferView": 2,
"componentType": 5126,
"count": 7657,
"max": [
545.1624755859375,
4393.0712890625,
476.9791564941406
],
"min": [
-552.103759765625,
-169.23814392089844,
-625.3477783203125
],
"type": "VEC3"
},
{
"bufferView": 2,
"byteOffset": 91884,
"componentType": 5126,
"count": 7657,
"max": [
1.0,
1.0,
1.0
],
"min": [
-1.0,
-1.0,
-1.0
],
"type": "VEC3"
},
{
"bufferView": 3,
"componentType": 5126,
"count": 7657,
"max": [
1.0,
1.0,
1.0,
1.0
],
"min": [
-1.0,
-1.0,
-1.0,
-1.0
],
"type": "VEC4"
},
{
"bufferView": 1,
"componentType": 5126,
"count": 7657,
"max": [
0.997083842754364,
0.9918742179870605
],
"min": [
0.002415185794234276,
0.002016189508140087
],
"type": "VEC2"
},
{
"bufferView": 0,
"componentType": 5125,
"count": 15189,
"type": "SCALAR"
}
],
"asset": {
"extras": {
"author": "drosovila (https://sketchfab.com/Drosovila)",
"license": "CC-BY-NC-4.0 (http://creativecommons.org/licenses/by-nc/4.0/)",
"source": "https://sketchfab.com/3d-models/oriental-pearl-shanghai-a80155b3f47240ce9a2f79fb8bff9024",
"title": "Oriental Pearl, Shanghai."
},
"generator": "Sketchfab-12.65.0",
"version": "2.0"
},
"bufferViews": [
{
"buffer": 0,
"byteLength": 60756,
"name": "floatBufferViews",
"target": 34963
},
{
"buffer": 0,
"byteLength": 61256,
"byteOffset": 60756,
"byteStride": 8,
"name": "floatBufferViews",
"target": 34962
},
{
"buffer": 0,
"byteLength": 183768,
"byteOffset": 122012,
"byteStride": 12,
"name": "floatBufferViews",
"target": 34962
},
{
"buffer": 0,
"byteLength": 122512,
"byteOffset": 305780,
"byteStride": 16,
"name": "floatBufferViews",
"target": 34962
}
],
"buffers": [
{
"byteLength": 428292,
"uri": "scene.bin"
}
],
"images": [
{
"uri": "textures/Material.002_baseColor.png"
},
{
"uri": "textures/Material.002_normal.png"
}
],
"materials": [
{
"alphaCutoff": 0.83,
"alphaMode": "MASK",
"doubleSided": true,
"name": "Material.002",
"normalTexture": {
"index": 1
},
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 0
},
"metallicFactor": 0.0,
"roughnessFactor": 0.6
}
}
],
"meshes": [
{
"name": "Sphere.011_Material.002_0",
"primitives": [
{
"attributes": {
"NORMAL": 1,
"POSITION": 0,
"TANGENT": 2,
"TEXCOORD_0": 3
},
"indices": 4,
"material": 0,
"mode": 4
}
]
}
],
"nodes": [
{
"children": [
1
],
"matrix": [
1.0,
0.0,
0.0,
0.0,
0.0,
2.220446049250313e-16,
-1.0,
0.0,
0.0,
1.0,
2.220446049250313e-16,
0.0,
0.0,
0.0,
0.0,
1.0
],
"name": "Sketchfab_model"
},
{
"children": [
2
],
"matrix": [
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
1.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
1.0
],
"name": "op.fbx"
},
{
"children": [
3
],
"name": "RootNode"
},
{
"children": [
4
],
"matrix": [
1.0,
0.0,
0.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
0.0,
1.0,
0.0,
0.0,
38.69914245605469,
-1083.8984375,
1.0
],
"name": "Sphere.011"
},
{
"mesh": 0,
"name": "Sphere.011_Material.002_0"
}
],
"samplers": [
{
"magFilter": 9729,
"minFilter": 9987,
"wrapS": 10497,
"wrapT": 10497
}
],
"scene": 0,
"scenes": [
{
"name": "Sketchfab_Scene",
"nodes": [
0
]
}
],
"textures": [
{
"sampler": 0,
"source": 0
},
{
"sampler": 0,
"source": 1
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 963 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 964 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,11 @@
Model Information:
* title: Shanghai Tower
* source: https://sketchfab.com/3d-models/shanghai-tower-e24fd5a66bbb4faaa7a8e26d3e7478fa
* author: NanoRay (https://sketchfab.com/NanoRay)
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 "Shanghai Tower" (https://sketchfab.com/3d-models/shanghai-tower-e24fd5a66bbb4faaa7a8e26d3e7478fa) by NanoRay (https://sketchfab.com/NanoRay) licensed under CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)

View File

@ -0,0 +1,588 @@
{
"accessors": [
{
"bufferView": 1,
"componentType": 5126,
"count": 54338,
"max": [
26.66900062561035,
-0.0,
-0.37599998712539673
],
"min": [
-23.5,
-293.9997863769531,
-44.28879928588867
],
"type": "VEC3"
},
{
"bufferView": 1,
"byteOffset": 652056,
"componentType": 5126,
"count": 54338,
"max": [
1.0,
1.0,
1.0
],
"min": [
-1.0,
-1.0,
-1.0
],
"type": "VEC3"
},
{
"bufferView": 0,
"componentType": 5125,
"count": 154410,
"type": "SCALAR"
},
{
"bufferView": 1,
"byteOffset": 1304112,
"componentType": 5126,
"count": 2868,
"max": [
15.901000022888184,
-0.0,
-19.10099983215332
],
"min": [
-2.13100004196167,
-270.22198486328125,
-36.70600128173828
],
"type": "VEC3"
},
{
"bufferView": 1,
"byteOffset": 1338528,
"componentType": 5126,
"count": 2868,
"max": [
1.0,
1.0,
1.0
],
"min": [
-1.0,
-1.0,
-1.0
],
"type": "VEC3"
},
{
"bufferView": 0,
"byteOffset": 617640,
"componentType": 5125,
"count": 8586,
"type": "SCALAR"
},
{
"bufferView": 1,
"byteOffset": 1372944,
"componentType": 5126,
"count": 157,
"max": [
13.167200088500977,
-263.34100341796875,
-21.970300674438477
],
"min": [
0.7897999882698059,
-266.0929870605469,
-33.76110076904297
],
"type": "VEC3"
},
{
"bufferView": 1,
"byteOffset": 1374828,
"componentType": 5126,
"count": 157,
"max": [
0.6119198799133301,
1.0,
0.9792145490646362
],
"min": [
-0.5585653185844421,
-1.0,
0.0
],
"type": "VEC3"
},
{
"bufferView": 0,
"byteOffset": 651984,
"componentType": 5125,
"count": 447,
"type": "SCALAR"
},
{
"bufferView": 1,
"byteOffset": 1376712,
"componentType": 5126,
"count": 51310,
"max": [
24.14900016784668,
-0.0,
-3.117000102996826
],
"min": [
-20.577999114990234,
-293.05718994140625,
-42.87080001831055
],
"type": "VEC3"
},
{
"bufferView": 1,
"byteOffset": 1992432,
"componentType": 5126,
"count": 51310,
"max": [
1.0,
1.0,
1.0
],
"min": [
-1.0,
-1.0,
-1.0
],
"type": "VEC3"
},
{
"bufferView": 0,
"byteOffset": 653772,
"componentType": 5125,
"count": 146169,
"type": "SCALAR"
},
{
"bufferView": 1,
"byteOffset": 2608152,
"componentType": 5126,
"count": 354,
"max": [
23.051000595092773,
-264.9939880371094,
-12.780599594116211
],
"min": [
-5.75600004196167,
-269.1239929199219,
-40.66299819946289
],
"type": "VEC3"
},
{
"bufferView": 1,
"byteOffset": 2612400,
"componentType": 5126,
"count": 354,
"max": [
0.6754736304283142,
1.0,
0.45345449447631836
],
"min": [
-0.9999932050704956,
-1.0,
-0.9999119639396667
],
"type": "VEC3"
},
{
"bufferView": 0,
"byteOffset": 1238448,
"componentType": 5125,
"count": 1014,
"type": "SCALAR"
},
{
"bufferView": 1,
"byteOffset": 2616648,
"componentType": 5126,
"count": 1214,
"max": [
21.64299964904785,
-262.5169982910156,
-14.782999992370605
],
"min": [
-4.02269983291626,
-275.9989929199219,
-40.27109909057617
],
"type": "VEC3"
},
{
"bufferView": 1,
"byteOffset": 2631216,
"componentType": 5126,
"count": 1214,
"max": [
0.9148340821266174,
1.0,
0.922309935092926
],
"min": [
-0.9916676878929138,
-1.0,
-0.9994908571243286
],
"type": "VEC3"
},
{
"bufferView": 0,
"byteOffset": 1242504,
"componentType": 5125,
"count": 3504,
"type": "SCALAR"
},
{
"bufferView": 1,
"byteOffset": 2645784,
"componentType": 5126,
"count": 16730,
"max": [
27.5,
-54.209999084472656,
-3.549999952316284
],
"min": [
-21.45199966430664,
-258.4070129394531,
-45.999900817871094
],
"type": "VEC3"
},
{
"bufferView": 1,
"byteOffset": 2846544,
"componentType": 5126,
"count": 16730,
"max": [
0.9999999403953552,
1.0,
0.9999994039535522
],
"min": [
-1.0,
-1.0,
-0.9999595880508423
],
"type": "VEC3"
},
{
"bufferView": 0,
"byteOffset": 1256520,
"componentType": 5125,
"count": 49632,
"type": "SCALAR"
}
],
"asset": {
"extras": {
"author": "NanoRay (https://sketchfab.com/NanoRay)",
"license": "CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)",
"source": "https://sketchfab.com/3d-models/shanghai-tower-e24fd5a66bbb4faaa7a8e26d3e7478fa",
"title": "Shanghai Tower"
},
"generator": "Sketchfab-12.67.0",
"version": "2.0"
},
"bufferViews": [
{
"buffer": 0,
"byteLength": 1455048,
"name": "floatBufferViews",
"target": 34963
},
{
"buffer": 0,
"byteLength": 3047304,
"byteOffset": 1455048,
"byteStride": 12,
"name": "floatBufferViews",
"target": 34962
}
],
"buffers": [
{
"byteLength": 4502352,
"uri": "scene.bin"
}
],
"materials": [
{
"doubleSided": true,
"name": "color_10988977",
"pbrMetallicRoughness": {
"baseColorFactor": [
0.28556091140599,
0.37482917854401654,
0.3863840971211095,
1.0
],
"roughnessFactor": 0.0
}
},
{
"doubleSided": true,
"name": "color_12568524",
"pbrMetallicRoughness": {
"baseColorFactor": [
0.74902,
0.780392,
0.8,
1.0
]
}
},
{
"doubleSided": true,
"name": "color_15329769",
"pbrMetallicRoughness": {
"baseColorFactor": [
0.913725,
0.913725,
0.913725,
1.0
],
"metallicFactor": 0.0,
"roughnessFactor": 0.0
}
},
{
"doubleSided": true,
"name": "color_4671303",
"pbrMetallicRoughness": {
"baseColorFactor": [
0.09503719215562158,
0.09503719215562158,
0.09503719215562158,
1.0
]
}
},
{
"doubleSided": true,
"name": "color_5395803",
"pbrMetallicRoughness": {
"baseColorFactor": [
0.321569,
0.333333,
0.356863,
1.0
]
}
},
{
"doubleSided": true,
"name": "color_7831428",
"pbrMetallicRoughness": {
"baseColorFactor": [
0.466667,
0.498039,
0.517647,
1.0
],
"roughnessFactor": 0.7367369186046512
}
},
{
"doubleSided": true,
"name": "color_9804960",
"pbrMetallicRoughness": {
"baseColorFactor": [
0.2818019344781678,
0.33108273651581677,
0.32427361700140833,
1.0
],
"metallicFactor": 0.713090308811995,
"roughnessFactor": 0.0
}
}
],
"meshes": [
{
"name": "Object_0",
"primitives": [
{
"attributes": {
"NORMAL": 1,
"POSITION": 0
},
"indices": 2,
"material": 0,
"mode": 4
}
]
},
{
"name": "Object_1",
"primitives": [
{
"attributes": {
"NORMAL": 4,
"POSITION": 3
},
"indices": 5,
"material": 1,
"mode": 4
}
]
},
{
"name": "Object_2",
"primitives": [
{
"attributes": {
"NORMAL": 7,
"POSITION": 6
},
"indices": 8,
"material": 2,
"mode": 4
}
]
},
{
"name": "Object_3",
"primitives": [
{
"attributes": {
"NORMAL": 10,
"POSITION": 9
},
"indices": 11,
"material": 3,
"mode": 4
}
]
},
{
"name": "Object_4",
"primitives": [
{
"attributes": {
"NORMAL": 13,
"POSITION": 12
},
"indices": 14,
"material": 4,
"mode": 4
}
]
},
{
"name": "Object_5",
"primitives": [
{
"attributes": {
"NORMAL": 16,
"POSITION": 15
},
"indices": 17,
"material": 5,
"mode": 4
}
]
},
{
"name": "Object_6",
"primitives": [
{
"attributes": {
"NORMAL": 19,
"POSITION": 18
},
"indices": 20,
"material": 6,
"mode": 4
}
]
}
],
"nodes": [
{
"children": [
1
],
"matrix": [
1.0,
0.0,
0.0,
0.0,
0.0,
-1.0,
-4.440892098500626e-16,
0.0,
0.0,
4.440892098500626e-16,
-1.0,
0.0,
0.0,
-170.18792724609378,
123.8119964599609,
1.0
],
"name": "Sketchfab_model"
},
{
"children": [
2,
3,
4,
5,
6,
7,
8
],
"name": "tinker.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"
}
],
"scene": 0,
"scenes": [
{
"name": "Sketchfab_Scene",
"nodes": [
0
]
}
]
}

View File

@ -0,0 +1,200 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
121.53943061828612,
31.258229203122266
],
[
121.54157638549806,
31.256321530605064
],
[
121.53900146484375,
31.25844931670105
],
[
121.53822898864745,
31.258155831815298
],
[
121.53325080871582,
31.254780690042416
],
[
121.527156829834,
31.25235931834531
],
[
121.5241527557373,
31.251552180645604
],
[
121.51702880859374,
31.251111920810153
],
[
121.51084899902344,
31.251332050984484
],
[
121.50535583496092,
31.251552180645604
],
[
121.49977684020996,
31.25045152720777
],
[
121.49539947509764,
31.248983969331967
],
[
121.49042129516602,
31.24729624957671
],
[
121.48733139038086,
31.24428763085332
],
[
121.48612976074217,
31.241205531802123
],
[
121.48681640624999,
31.237389460298548
],
[
121.48904800415039,
31.234453915778804
],
[
121.49316787719727,
31.231004534414804
],
[
121.49917602539062,
31.225646734958584
],
[
121.50226593017578,
31.221830035028137
],
[
121.50381088256836,
31.21867380136463
],
[
121.5036392211914,
31.21625150406156
],
[
121.50235176086426,
31.213682333043916
],
[
121.49951934814455,
31.20832355171169
],
[
121.50235176086426,
31.207075572741214
],
[
121.50372505187988,
31.209351286734226
],
[
121.50501251220703,
31.211847168148132
],
[
121.50698661804199,
31.216104696169765
],
[
121.50775909423828,
31.218453595083517
],
[
121.50604248046874,
31.222931021978578
],
[
121.50089263916016,
31.229536674364116
],
[
121.4973735809326,
31.233132890986248
],
[
121.49394035339355,
31.23584831079913
],
[
121.49179458618164,
31.237169297623627
],
[
121.49093627929689,
31.23893058465588
],
[
121.49024963378905,
31.24149906937837
],
[
121.49351119995116,
31.24421424871145
],
[
121.49986267089844,
31.246195546528586
],
[
121.5039825439453,
31.247076109993458
],
[
121.5084457397461,
31.24714948991159
],
[
121.51419639587402,
31.24700273001836
],
[
121.52183532714842,
31.24722286977265
],
[
121.5303325653076,
31.24883721228986
],
[
121.53522491455078,
31.250965167075467
],
[
121.54346466064452,
31.255220932769536
],
[
121.53943061828612,
31.258229203122266
]
]
]
}
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

View File

@ -0,0 +1,138 @@
<!DOCTYPE html>
<head>
<title>CesiumDemo-SH小场景(源码版)</title>
<!-- Use correct character set. -->
<meta charset="utf-8" />
<!-- Tell IE to use the latest, best version. -->
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- Make the application on mobile take up the full browser screen and disable user scaling. -->
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
<link href="https://cesium.com/downloads/cesiumjs/releases/1.103/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.2/animate.min.css" rel="stylesheet">
<script type="text/javascript"
src="https://cesium.com/downloads/cesiumjs/releases/1.103/Build/Cesium/Cesium.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script type="text/javascript" src=" https://cdnjs.cloudflare.com/ajax/libs/wow/1.1.2/wow.min.js"></script>
<script type="text/javascript" src="./index.js"></script>
<style>
html,
body,
#sceneContainer {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
background: #000;
}
#uiContainer {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
#uiContainer {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#topUI {
position: absolute;
width: 100%;
height: 10%;
margin: 0;
padding: 0;
left: 0;
top: 0;
background-image: url("./Static/images/top.png");
background-repeat: round;
pointer-events: none;
}
#leftUI {
position: absolute;
width: 20%;
height: 90%;
margin: 0;
padding: 0;
left: 0;
top: 5%;
background-image: url("./Static/images/left.png");
background-repeat: round;
pointer-events: none;
}
#roghtUI {
position: absolute;
width: 20%;
height: 90%;
margin: 0;
padding: 0;
right: 0;
top: 5%;
background-image: url("./Static/images/right.png");
background-repeat: round;
pointer-events: none;
}
.loadingIndicator {
display: block;
position: absolute;
top: 50%;
left: 50%;
margin-top: -33px;
margin-left: -33px;
width: 66px;
height: 66px;
z-index: 99;
background-position: center;
background-repeat: no-repeat;
background-image: url("./Static/images/ajax-loader.gif");
}
.loadingIndicator2 {
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
background: #000;
}
.bvideo {
position: absolute;
top:10px;
left: 10px;
font-size: 13px;
color: #fff;
z-index: 9999;
}
.view {
position: absolute;
top:10px;
left: 110px;
font-size: 13px;
color: #fff;
z-index: 9999;
}
</style>
</head>
<body>
<a class="bvideo" href="https://space.bilibili.com/432028432">可视化场景分享</a>
<a class="view" id="view" href="#">默认视图</a>
<div id="sceneContainer"></div>
<div id="loadingIndicator" class="loadingIndicator"></div>
<div id="loadingIndicator2" class="loadingIndicator2"></div>
</body>

View File

@ -0,0 +1,638 @@
/**
*/
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjMzU2ZTQyYy1iOTU5LTQ5MDQtOGNkNC0yYzcxMTI1ZDJiZGQiLCJpZCI6NzY1OTcsImlhdCI6MTYzOTU2MDcwOH0.kbWigipGD6l2OPBGpnkkN6dzp8NuNjoHNNM1NF4gaIo';
let viewer;
let imagerLayer;
let building;
let model0;
let model1;
let model2;
let model3;
let waterPrimitive;
/**
* 自定义材质线 github:cesium-materialLine
* @param {*} options
* @returns
*/
function CustomMaterialLine(options) {
let Color = Cesium.Color,
defaultValue = Cesium.defaultValue,
defined = Cesium.defined,
defineProperties = Object.defineProperties,
Event = Cesium.Event,
createPropertyDescriptor = Cesium.createPropertyDescriptor,
Property = Cesium.Property,
Material = Cesium.Material,
defaultColor = Color.WHITE,
currentTime = window.performance.now(),
MaterialType = options.MaterialType || 'wallType' + parseInt(Math.random() * 1000);
function PolylineCustomMaterialProperty(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
this._definitionChanged = new Event();
this._color = undefined;
this._colorSubscription = undefined;
this.color = options.color || Cesium.Color.BLUE;
this.duration = options.duration || 1000;
this._time = currentTime;
}
defineProperties(PolylineCustomMaterialProperty.prototype, {
isvarant: {
get: function () {
return false;
}
},
definitionChanged: {
get: function () {
return this._definitionChanged;
}
},
color: createPropertyDescriptor('color')
});
PolylineCustomMaterialProperty.prototype.getType = function (time) {
return MaterialType;
};
PolylineCustomMaterialProperty.prototype.getValue = function (time, result) {
if (!defined(result)) {
result = {};
}
result.color = Property.getValueOrClonedDefault(this._color, time, defaultColor, result.color);
result.image = options.image;
result.time = ((window.performance.now() - this._time) % this.duration) / this.duration;
return result;
};
PolylineCustomMaterialProperty.prototype.equals = function (other) {
return this === other ||
(other instanceof PolylineCustomMaterialProperty &&
Property.equals(this._color, other._color));
};
Material._materialCache.addMaterial(MaterialType, {
fabric: {
type: MaterialType,
uniforms: {
color: options.color || new Cesium.Color(1.0, 0.0, 0.0, 0.5),
image: options.image,
time: 0
},
source: `czm_material czm_getMaterial(czm_materialInput materialInput)
{
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st;
if(texture(image, vec2(0.0, 0.0)).a == 1.0){
discard;
}else{
material.alpha = texture(image, vec2(1.0 - fract(time - st.s), st.t)).a * color.a;
}
material.diffuse = max(color.rgb * material.alpha * 3.0, color.rgb);
return material;
}
`,
},
translucent: function (material) {
return true;
}
})
return new PolylineCustomMaterialProperty(options);
}
/**
* 初始化viewer
*/
const initViewer = () => {
viewer = new Cesium.Viewer('map', {
infoBox: false,
shouldAnimate: false,
vrButton: false,
geocoder: false,
homeButton: false,
sceneModePicker: false,
baseLayerPicker: false,
navigationHelpButton: false,
animation: false,
timeline: true,
fullscreenButton: false,
terrainProvider: Cesium.createWorldTerrain({
requestWaterMask: true,
requestVertexNormals: true,
}),
contextOptions: {
requestWebgl1: false,
allowTextureFilterAnisotropic: true,
webgl: {
alpha: false,
depth: true,
stencil: false,
antialias: true,
powerPreference: 'high-performance',
premultipliedAlpha: true,
preserveDrawingBuffer: false,
failIfMajorPerformanceCaveat: false
},
},
});
viewer._cesiumWidget._creditContainer.style.display = "none";
viewer.resolutionScale = 1.2;
viewer.scene.msaaSamples = 4;
viewer.postProcessStages.fxaa.enabled = true;
viewer.scene.globe.depthTestAgainstTerrain = true;
viewer.scene.debugShowFramesPerSecond = true;
viewer.scene.globe.shadows = Cesium.ShadowMode.ENABLED;
viewer.shadows = true;
viewer.shadowMap.size = 2048;
viewer.shadowMap.softShadows = false;
viewer.shadowMap.maximumDistance = 4000;
viewer.scene.globe.enableLighting = true
viewer.scene.fog.minimumBrightness = 0.5;
viewer.scene.fog.density = 2.0e-4 * 1.2;
viewer.scene.globe.atmosphereLightIntensity = 20;
viewer.scene.globe.atmosphereBrightnessShift = -0.01;
imagerLayer = viewer.imageryLayers.get(0);
viewer.scene.postProcessStages.bloom.enabled = false;
viewer.scene.postProcessStages.bloom.uniforms.contrast = 119;
viewer.scene.postProcessStages.bloom.uniforms.brightness = -0.4;
viewer.scene.postProcessStages.bloom.uniforms.glowOnly = false;
viewer.scene.postProcessStages.bloom.uniforms.delta = 0.9;
viewer.scene.postProcessStages.bloom.uniforms.sigma = 3.78;
viewer.scene.postProcessStages.bloom.uniforms.stepSize = 5;
viewer.scene.postProcessStages.bloom.uniforms.isSelected = false;
viewer.scene.postProcessStages.ambientOcclusion.enabled = false;
viewer.scene.postProcessStages.ambientOcclusion.uniforms.intensity = 1.5;
viewer.scene.postProcessStages.ambientOcclusion.uniforms.bias = 0.4;
viewer.scene.postProcessStages.ambientOcclusion.uniforms.lengthCap = 0.45;
viewer.scene.postProcessStages.ambientOcclusion.uniforms.stepSize = 1.8;
viewer.scene.postProcessStages.ambientOcclusion.uniforms.blurStepSize = 1.0;
// viewer.scene.screenSpaceCameraController.minimumZoomDistance = 0;
// viewer.scene.screenSpaceCameraController.maximumZoomDistance = 30000;
}
/**
* 初始化场景
*/
const initScene = () => {
const initTiles = () => {
building = viewer.scene.primitives.add(
Cesium.createOsmBuildings({
customShader: new Cesium.CustomShader({
uniforms: {
u_envTexture: {
value: new Cesium.TextureUniform({
url: "./Static/images/sky.jpg"
}),
type: Cesium.UniformType.SAMPLER_2D
},
u_envTexture2: {
value: new Cesium.TextureUniform({
url: "./Static/images/pic.jpg"
}),
type: Cesium.UniformType.SAMPLER_2D
},
u_isDark: {
value: false,
type: Cesium.UniformType.BOOL
}
},
mode: Cesium.CustomShaderMode.REPLACE_MATERIAL,
lightingModel: Cesium.LightingModel.UNLIT,
fragmentShaderText: `
void fragmentMain(FragmentInput fsInput,inout czm_modelMaterial material) {
vec3 positionMC = fsInput.attributes.positionMC;
vec3 positionEC = fsInput.attributes.positionEC;
vec3 normalEC = fsInput.attributes.normalEC;
vec3 posToCamera = normalize(-positionEC);
vec3 coord = normalize(vec3(czm_inverseViewRotation * reflect(posToCamera, normalEC)));
float ambientCoefficient = 0.3;
float diffuseCoefficient = max(0.0, dot(normalEC, czm_sunDirectionEC) * 1.0);
if(u_isDark){
// dark
vec4 darkRefColor = texture(u_envTexture2, vec2(coord.x, (coord.z - coord.y) / 2.0));
material.diffuse = mix(mix(vec3(0.3), vec3(0.1,0.2,0.4),clamp(positionMC.z / 200., 0.0, 1.0)) , darkRefColor.rgb ,0.3);
material.diffuse *= 0.2;
// 注意shader中写浮点数是 一定要带小数点 否则会报错 比如0需要写成0.0 1要写成1.0
float _baseHeight = 0.0; // 物体的基础高度,需要修改成一个合适的建筑基础高度
float _heightRange = 20.0; // 高亮的范围(_baseHeight ~ _baseHeight + _heightRange)
float _glowRange = 300.0; // 光环的移动范围(高度)
// 建筑基础色
float czm_height = positionMC.z - _baseHeight;
float czm_a11 = fract(czm_frameNumber / 120.0) * 3.14159265 * 2.0;
float czm_a12 = czm_height / _heightRange + sin(czm_a11) * 0.1;
float times = czm_frameNumber / 60.0;
material.diffuse *= vec3(czm_a12);// 渐变
// 动态光环
float time = fract(czm_frameNumber / 360.0);
time = abs(time - 0.5) * 2.0;
float czm_h = clamp(czm_height / _glowRange, 0.0, 1.0);
float czm_diff = step(0.005, abs(czm_h - time));
material.diffuse += material.diffuse * (1.0 - czm_diff);
} else {
// day
vec4 dayRefColor = texture(u_envTexture, vec2(coord.x, (coord.z - coord.y) / 3.0));
material.diffuse = mix(mix(vec3(0.000), vec3(0.5),clamp(positionMC.z / 300., 0.0, 1.0)) , dayRefColor.rgb ,0.3);
material.diffuse *= min(diffuseCoefficient + ambientCoefficient, 1.0);
}
material.alpha = 1.0;
}
`
})
})
);
model0 = viewer.scene.primitives.add(
new Cesium.Model.fromGltf({
url: "./Static/data/shanghai_tower/scene.gltf",
imageBasedLighting: imageBasedLighting,
customShader: new Cesium.CustomShader({
uniforms: {
u_texture: {
value: new Cesium.TextureUniform({
url: "./Static/images/color.png"
}),
type: Cesium.UniformType.SAMPLER_2D
},
u_isDark: {
value: true,
type: Cesium.UniformType.BOOL
}
},
lightingModel: Cesium.LightingModel.PBR,
fragmentShaderText: `
void fragmentMain(FragmentInput fsInput,inout czm_modelMaterial material) {
if(u_isDark){
vec2 texCoord = fsInput.attributes.texCoord_0 * 0.3;
float times = czm_frameNumber / 120.0;
vec4 textureColor = texture(u_texture,vec2(fract(texCoord.s),float(texCoord.t) - times));
material.diffuse += textureColor.rgb * 0.8;
}
}
`
}),
modelMatrix: generateModelMatrix(
[121.49805570610201, 31.23266477688614, 400],
[0, 0, 45],
[3, 3, 2.5]),
})
);
model1 = viewer.scene.primitives.add(
Cesium.Model.fromGltf({
url: "./Static/data/building_-_beveled_corners_-_shiny/scene.gltf",
imageBasedLighting: imageBasedLighting,
customShader: new Cesium.CustomShader({
uniforms: {
u_texture: {
value: new Cesium.TextureUniform({
url: "./Static/images/pic.jpg"
}),
type: Cesium.UniformType.SAMPLER_2D
},
u_isDark: {
value: true,
type: Cesium.UniformType.BOOL
}
},
lightingModel: Cesium.LightingModel.PBR,
fragmentShaderText: `
void fragmentMain(FragmentInput fsInput,inout czm_modelMaterial material) {
if(u_isDark){
vec2 texCoord = fsInput.attributes.texCoord_0 * 0.3;
float times = czm_frameNumber / 120.0;
vec4 textureColor = texture(u_texture,vec2(fract(texCoord.s),float(texCoord.t) - times));
material.diffuse += textureColor.rgb * 1.5;
}
}
`
}),
modelMatrix: generateModelMatrix(
[121.50306517515779, 31.236594411927722, 0],
[0, 0, 0],
[3, 3, 4.4]),
})
);
model2 = viewer.scene.primitives.add(
Cesium.Model.fromGltf({
url: "./Static/data/building_-_octagonal_-_shiny/scene.gltf",
imageBasedLighting: imageBasedLighting,
customShader: new Cesium.CustomShader({
uniforms: {
u_texture: {
value: new Cesium.TextureUniform({
url: "./Static/images/color2.png"
}),
type: Cesium.UniformType.SAMPLER_2D
},
u_isDark: {
value: true,
type: Cesium.UniformType.BOOL
}
},
lightingModel: Cesium.LightingModel.PBR,
fragmentShaderText: `
void fragmentMain(FragmentInput fsInput,inout czm_modelMaterial material) {
if(u_isDark){
vec2 texCoord = fsInput.attributes.texCoord_0 * 0.5;
float times = czm_frameNumber / 120.0;
vec4 textureColor = texture(u_texture,vec2(float(texCoord.s) - times),fract(texCoord.t));
material.diffuse += textureColor.rgb * 1.5;
}
}
`
}),
modelMatrix: generateModelMatrix(
[121.50140479453857, 31.237266571858395, 0],
[0, 0, 0],
[2.5, 2.5, 3.0]),
})
);
model3 = viewer.scene.primitives.add(
Cesium.Model.fromGltf({
url: "./Static/data/oriental_pearl_shanghai. (1)/scene.gltf",
imageBasedLighting: imageBasedLighting,
customShader: new Cesium.CustomShader({
uniforms: {
u_texture: {
value: new Cesium.TextureUniform({
url: "./Static/images/color.png"
}),
type: Cesium.UniformType.SAMPLER_2D
},
u_isDark: {
value: true,
type: Cesium.UniformType.BOOL
}
},
lightingModel: Cesium.LightingModel.PBR,
fragmentShaderText: `
void fragmentMain(FragmentInput fsInput,inout czm_modelMaterial material) {
if(u_isDark){
vec2 texCoord = fsInput.attributes.texCoord_0 * 0.5;
float times = czm_frameNumber / 30.0;
vec4 textureColor = texture(u_texture,vec2(fract(texCoord.s),float(texCoord.t) - times));
material.diffuse += textureColor.rgb * 0.8;
}
}
`
}),
modelMatrix: generateModelMatrix(
[121.49697607088487, 31.241891679352257, 10],
[0, 0, 0],
[0.15, 0.15, 0.126])
})
);
}
const initWater = async () => {
const waterPlane = [];
const waterData = await Cesium.Resource.fetchJson({ url: "./Static/data/water.json" });
waterData.features.map(feature => {
feature.geometry.coordinates[0].map(coordinate => {
waterPlane.push(Cesium.Cartesian3.fromDegrees(...coordinate));
})
})
const polygon = new Cesium.PolygonGeometry({
polygonHierarchy: new Cesium.PolygonHierarchy(waterPlane),
});
const instance = new Cesium.GeometryInstance({
geometry: polygon
});
waterPrimitive = new Cesium.GroundPrimitive({
geometryInstances: instance,
appearance: new Cesium.MaterialAppearance({
material: new Cesium.Material({
fabric: {
type: Cesium.Material.WaterType,
uniforms: {
baseWaterColor: Cesium.Color.fromCssColorString("#62809b"),
blendColor: new Cesium.Color(0, 1, 0.699, 1),
// specularMap: Material.DefaultImageId,
normalMap: "https://cesium.com/downloads/cesiumjs/releases/1.103/Build/Cesium/Assets/Textures/waterNormals.jpg",
frequency: 1000,
animationSpeed: 0.01,
amplitude: 2,
specularIntensity: 1,
fadeFactor: 3
}
}
}),
translucent: false,
}),
asynchronous: false
})
viewer.scene.primitives.add(waterPrimitive);
// 创建材质线
let getCustomMaterialLine = (image, color) => {
return new CustomMaterialLine({
image: image,
color: color,
duration: 1000
})
}
const createRoad = (url) => {
let promise = Cesium.GeoJsonDataSource.load(url);
promise.then((dataSource) => {
viewer.dataSources.add(dataSource)
let entities = dataSource.entities.values;
for (let o = 0; o < entities.length; o++) {
entities[o].polyline.width = 3;
entities[o].polyline.clampToGround = true;
entities[o].polyline.material =
getCustomMaterialLine("./Static/images/line.png", Cesium.Color.fromRandom())
}
})
}
createRoad("./Static/data/road.json")
createRoad("./Static/data/road2.json")
}
initTiles();
initWater();
}
/**
* 初始化场景事件
*/
const initEvent = () => {
let _sn = 0;
const updateScene = () => {
const sd = Cesium.Cartesian3.normalize(viewer.scene.sun._boundingVolume.center, new Cesium.Cartesian3);
const vd = Cesium.Cartesian3.normalize(viewer.camera.position, new Cesium.Cartesian3);
const sn = parseFloat(Cesium.Cartesian3.dot(vd, sd).toFixed(3))
if (sn === _sn) return false;
viewer.postProcessStages.bloom.enabled = false;
viewer.scene.postProcessStages.ambientOcclusion.enabled = true;
building.customShader.uniforms.u_isDark.value = false;
model0.customShader.uniforms.u_isDark.value = false;
model1.customShader.uniforms.u_isDark.value = false;
model2.customShader.uniforms.u_isDark.value = false;
model3.customShader.uniforms.u_isDark.value = false;
const value = Cesium.Math.clamp(sn, 0, 1);
if (imagerLayer)
imagerLayer.brightness = value + 0.3;
if (waterPrimitive)
waterPrimitive.appearance.material.uniforms.baseWaterColor =
Cesium.Color.multiplyByScalar(Cesium.Color.fromCssColorString("#62809b"), value + 0.3, new Cesium.Color);
if (sn < 0) {
viewer.postProcessStages.bloom.enabled = true;
viewer.scene.postProcessStages.ambientOcclusion.enabled = false;
building.customShader.uniforms.u_isDark.value = true;
model0.customShader.uniforms.u_isDark.value = true;
model1.customShader.uniforms.u_isDark.value = true;
model2.customShader.uniforms.u_isDark.value = true;
model3.customShader.uniforms.u_isDark.value = true;
}
if (sn < -0.1 && waterPrimitive) {
let scale = parseFloat(Cesium.Math.clamp((sn - (-0.8)) / (-0.1 - (-0.8)), 1.0, 1.5));
waterPrimitive.appearance.material.uniforms.baseWaterColor =
Cesium.Color.multiplyByScalar(Cesium.Color.fromCssColorString("#62809b"), scale, new Cesium.Color);
}
_sn = sn;
}
viewer.scene.postRender.addEventListener(() => updateScene());
const onGlobeEvent = viewer.scene.globe.tileLoadProgressEvent.addEventListener((tileNum) => {
if (tileNum > 2) {
closeLoading(),
showUI(),
onGlobeEvent();
}
})
viewer.camera.setView({
destination: { x: -2850554.9246458095, y: 4656672.153306185, z: 3287574.727124352 },
orientation: {
heading: Cesium.Math.toRadians(48.72529042457395),
pitch: Cesium.Math.toRadians(-10.899276751527792),
roll: Cesium.Math.toRadians(0.0014027234956804583)
}
});
viewer.clock.currentTime = Cesium.JulianDate.fromIso8601("2023-01-01T06:00:00Z");
}
const initGUI = () => { }
const L00 = new Cesium.Cartesian3(
1.234709620475769,
1.221461296081543,
1.273156881332397
);
const L1_1 = new Cesium.Cartesian3(
1.135921120643616,
1.171217799186707,
1.287644743919373
);
const L10 = new Cesium.Cartesian3(
1.245193719863892,
1.245591878890991,
1.282818794250488
);
const L11 = new Cesium.Cartesian3(
-1.106930732727051,
-1.112522482872009,
-1.153198838233948
);
const L2_2 = new Cesium.Cartesian3(
-1.086226940155029,
-1.079731941223145,
-1.101912498474121
);
const L2_1 = new Cesium.Cartesian3(
1.189834713935852,
1.185906887054443,
1.214385271072388
);
const L20 = new Cesium.Cartesian3(
0.01778045296669,
0.02013735473156,
0.025313569232821
);
const L21 = new Cesium.Cartesian3(
-1.086826920509338,
-1.084611177444458,
-1.111204028129578
);
const L22 = new Cesium.Cartesian3(
-0.05241484940052,
-0.048303380608559,
-0.041960217058659
);
const coefficients = [L00, L1_1, L10, L11, L2_2, L2_1, L20, L21, L22];
let imageBasedLighting = new Cesium.ImageBasedLighting({
specularEnvironmentMaps: './Static/images/kiara_6_afternoon_2k_ibl.ktx2',
sphericalHarmonicCoefficients: coefficients
})
/**
* 生成矩阵
* @param {*} position
* @param {*} rotation
* @param {*} scale
* @returns
*/
const generateModelMatrix = (position = [0, 0, 0], rotation = [0, 0, 0], scale = [1, 1, 1]) => {
const rotationX = Cesium.Matrix4.fromRotationTranslation(
Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(rotation[0])));
const rotationY = Cesium.Matrix4.fromRotationTranslation(
Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(rotation[1])));
const rotationZ = Cesium.Matrix4.fromRotationTranslation(
Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(rotation[2])));
if (!(position instanceof Cesium.Cartesian3)) {
position = Cesium.Cartesian3.fromDegrees(...position)
}
const enuMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(position);
Cesium.Matrix4.multiply(enuMatrix, rotationX, enuMatrix);
Cesium.Matrix4.multiply(enuMatrix, rotationY, enuMatrix);
Cesium.Matrix4.multiply(enuMatrix, rotationZ, enuMatrix);
const scaleMatrix = Cesium.Matrix4.fromScale(new Cesium.Cartesian3(...scale));
const modelMatrix = Cesium.Matrix4.multiply(enuMatrix, scaleMatrix, new Cesium.Matrix4());
return modelMatrix;
}
const main = () => {
initViewer();
initScene();
initEvent();
initGUI();
};
new window.WOW().init();
function showUI() {
$("body").append(`
<div id="uiContainer">
<div id="topUI" class="wow bounceInDown" data-wow-duration="1.2s"></div>
<div id="leftUI" class="wow bounceInLeft" data-wow-duration="1.2s"></div>
<div id="roghtUI" class="wow bounceInRight" data-wow-duration="1.2s"></div>
</div>`);
}
function closeLoading() {
$("#loadingIndicator").hide();
$("#loadingIndicator2").hide();
}
function showLoading() {
$("#loadingIndicator").show();
$("#loadingIndicator2").show();
}
window.onload = main;

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB