Commit 5fd0df39 by wanghao

同步代码

parent c5260bc0
......@@ -1111,7 +1111,7 @@
"type": "3dtiles",
"name": "校园",
"url": "{dataServer}/3dtiles/qx-xuexiao/tileset.json",
"position": { "alt": 282.0 },
"position": { "alt": 279.0 },
"maximumScreenSpaceError": 1
}
]
......
......@@ -279,7 +279,7 @@
"type": "3dtiles",
"name": "校园",
"url": "//data.mars3d.cn/3dtiles/qx-xuexiao/tileset.json",
"position": { "alt": 282.0},
"position": { "alt": 279.0},
"maximumScreenSpaceError": 1
}
]
......
/**
* Mars3D三维可视化平台 mars3d
*
* 版本信息:v3.6.6
* 编译日期:2023-09-18 16:29:59
* 版本信息:v3.6.7
* 编译日期:2023-09-25 10:01:35
* 版权所有:Copyright by 火星科技 http://mars3d.cn
* 使用单位:免费公开版 ,2023-03-17
*/
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -5,7 +5,7 @@ export let map // mars3d.Map三维地图对象
// 需要覆盖config.json中地图属性参数(当前示例框架中自动处理合并)
export const mapOptions = {
scene: {
center: { lat: 31.815095, lng: 117.220438, alt: 520, heading: 90, pitch: -47 }
center: { lat: 31.81456, lng: 117.231868, alt: 275.7, heading: 268.2, pitch: -12.5 }
}
}
......@@ -28,6 +28,7 @@ export function onMounted(mapInstance) {
addDemoGraphic1(graphicLayer)
addDemoGraphic2(graphicLayer)
addDemoGraphic3(graphicLayer)
addDemoGraphic4(graphicLayer)
}
/**
......@@ -89,8 +90,135 @@ function addDemoGraphic2(graphicLayer) {
graphicLayer.addGraphic(particleSystem)
}
// 动态运行车辆的尾气粒子效果
// 烟花效果
function addDemoGraphic3(graphicLayer) {
const position = Cesium.Cartesian3.fromDegrees(117.22104, 31.813759, 80) // 位置
const minimumExplosionSize = 30.0
const maximumExplosionSize = 100.0
const particlePixelSize = new Cesium.Cartesian2(7.0, 7.0)
const burstSize = 400.0
const lifetime = 10.0
const numberOfFireworks = 20.0
const modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(position)
const emitterInitialLocation = new Cesium.Cartesian3(0.0, 0.0, 100.0)
const emitterModelMatrixScratch = new Cesium.Matrix4()
let particleCanvas
function getImage() {
if (!Cesium.defined(particleCanvas)) {
particleCanvas = document.createElement("canvas")
particleCanvas.width = 20
particleCanvas.height = 20
const context2D = particleCanvas.getContext("2d")
context2D.beginPath()
context2D.arc(8, 8, 8, 0, Cesium.Math.TWO_PI, true)
context2D.closePath()
context2D.fillStyle = "rgb(255, 255, 255)"
context2D.fill()
}
return particleCanvas
}
function createFirework(offset, color, bursts) {
const position = Cesium.Cartesian3.add(emitterInitialLocation, offset, new Cesium.Cartesian3())
const emitterModelMatrix = Cesium.Matrix4.fromTranslation(position, emitterModelMatrixScratch)
const particleToWorld = Cesium.Matrix4.multiply(modelMatrix, emitterModelMatrix, new Cesium.Matrix4())
const worldToParticle = Cesium.Matrix4.inverseTransformation(particleToWorld, particleToWorld)
const size = Cesium.Math.randomBetween(minimumExplosionSize, maximumExplosionSize)
const particlePositionScratch = new Cesium.Cartesian3()
const force = function (particle) {
const position = Cesium.Matrix4.multiplyByPoint(worldToParticle, particle.position, particlePositionScratch)
if (Cesium.Cartesian3.magnitudeSquared(position) >= size * size) {
Cesium.Cartesian3.clone(Cesium.Cartesian3.ZERO, particle.velocity)
}
}
const normalSize = (size - minimumExplosionSize) / (maximumExplosionSize - minimumExplosionSize)
const minLife = 0.3
const maxLife = 1.0
const life = normalSize * (maxLife - minLife) + minLife
const particleSystem = new mars3d.graphic.ParticleSystem({
modelMatrix: modelMatrix,
emitterModelMatrix: emitterModelMatrix,
updateCallback: force,
style: {
image: getImage(),
startColor: color,
endColor: color.withAlpha(0.0),
particleLife: life,
speed: 100.0,
imageSize: particlePixelSize,
emissionRate: 0,
emitter: new Cesium.SphereEmitter(0.1),
bursts: bursts,
lifetime: lifetime
},
attr: { remark: "烟花粒子效果" }
})
graphicLayer.addGraphic(particleSystem)
}
const xMin = -100.0
const xMax = 100.0
const yMin = -80.0
const yMax = 100.0
const zMin = -50.0
const zMax = 50.0
const colorOptions = [
{
minimumRed: 0.75,
green: 0.0,
minimumBlue: 0.8,
alpha: 1.0
},
{
red: 0.0,
minimumGreen: 0.75,
minimumBlue: 0.8,
alpha: 1.0
},
{
red: 0.0,
green: 0.0,
minimumBlue: 0.8,
alpha: 1.0
},
{
minimumRed: 0.75,
minimumGreen: 0.75,
blue: 0.0,
alpha: 1.0
}
]
for (let i = 0; i < numberOfFireworks; ++i) {
const x = Cesium.Math.randomBetween(xMin, xMax)
const y = Cesium.Math.randomBetween(yMin, yMax)
const z = Cesium.Math.randomBetween(zMin, zMax)
const offset = new Cesium.Cartesian3(x, y, z)
const color = Cesium.Color.fromRandom(colorOptions[i % colorOptions.length])
const bursts = []
for (let j = 0; j < 3; ++j) {
bursts.push(
new Cesium.ParticleBurst({
time: Cesium.Math.nextRandomNumber() * lifetime,
minimum: burstSize,
maximum: burstSize
})
)
}
createFirework(offset, color, bursts)
}
}
// 动态运行车辆的尾气粒子效果
function addDemoGraphic4(graphicLayer) {
const fixedRoute = new mars3d.graphic.FixedRoute({
speed: 120,
positions: [
......
......@@ -141,7 +141,9 @@ export function getGraphic(graphicId) {
export function updatePosition(x, y, z) {
const position = Cesium.Cartesian3.fromDegrees(x, y, z)
modelGraphic.position = position
if (modelGraphic && modelGraphic.state !== "destroy") {
modelGraphic.position = position
}
if (satelliteSensor) {
satelliteSensor.position = position
}
......@@ -153,7 +155,9 @@ export function locate() {
// 方向角改变
export function headingChange(value) {
modelGraphic.heading = value
if (modelGraphic && modelGraphic.state !== "destroy") {
modelGraphic.heading = value
}
if (satelliteSensor) {
satelliteSensor.heading = value
}
......@@ -161,7 +165,9 @@ export function headingChange(value) {
// 俯仰角
export function pitchChange(value) {
modelGraphic.pitch = value
if (modelGraphic && modelGraphic.state !== "destroy") {
modelGraphic.pitch = value
}
if (satelliteSensor) {
satelliteSensor.pitch = value
}
......@@ -169,7 +175,9 @@ export function pitchChange(value) {
// 左右角
export function rollChange(value) {
modelGraphic.roll = value
if (modelGraphic && modelGraphic.state !== "destroy") {
modelGraphic.roll = value
}
if (satelliteSensor) {
satelliteSensor.roll = value
}
......@@ -191,7 +199,9 @@ export function angle2(value) {
// 参考轴系显示与隐藏
export function chkShowModelMatrix(val) {
modelGraphic.debugAxis = val
if (modelGraphic && modelGraphic.state !== "destroy") {
modelGraphic.debugAxis = val
}
}
// 视椎体状态
......@@ -219,7 +229,9 @@ export function chkSensorType(value) {
}
export function lengthChange(value) {
modelGraphic.debugAxisLength = value * 1000
if (modelGraphic && modelGraphic.state !== "destroy") {
modelGraphic.debugAxisLength = value * 1000
}
}
export function updateColor(value) {
......
......@@ -59,7 +59,7 @@ export function onUnmounted() {
map = null
}
const flvUrl = "https://sf1-hscdn-tos.pstatp.com/obj/media-fe/xgplayer_doc_video/flv/xgplayer-demo-360p.flv"
const flvUrl = "https://sample-videos.com/video123/flv/720/big_buck_bunny_720p_1mb.flv"
function createVideoDom() {
videoElement = mars3d.DomUtil.create("video", "", document.body)
videoElement.setAttribute("muted", "muted")
......
......@@ -73,7 +73,7 @@ export function onUnmounted() {
map = null
}
const flvUrl = "https://sf1-hscdn-tos.pstatp.com/obj/media-fe/xgplayer_doc_video/flv/xgplayer-demo-360p.flv"
const flvUrl = "https://sample-videos.com/video123/flv/720/big_buck_bunny_720p_1mb.flv"
function createVideoDom() {
videoElement = mars3d.DomUtil.create("video", "", document.body)
......
......@@ -55,7 +55,7 @@ export function onUnmounted() {
map = null
}
const flvUrl = "https://sf1-hscdn-tos.pstatp.com/obj/media-fe/xgplayer_doc_video/flv/xgplayer-demo-360p.flv"
const flvUrl = "https://sample-videos.com/video123/flv/720/big_buck_bunny_720p_1mb.flv"
function createVideoDom() {
videoElement = mars3d.DomUtil.create("video", "", document.body)
videoElement.setAttribute("muted", "muted")
......
......@@ -62,7 +62,6 @@ export function onMounted(mapInstance) {
// mars3d.Lang["_双击完成绘制"][0] = "右击完成绘制"
// mars3d.Lang["_右击删除点"][0] = "中键单击完成绘制"
// map.on(mars3d.EventType.mouseOver, function (event) {
// console.log("mouseover")
// })
......@@ -222,6 +221,17 @@ export function drawPolyline(clampToGround) {
// })
}
export function drawBrushLine(clampToGround) {
graphicLayer.startDraw({
type: "brushLine",
style: {
color: clampToGround ? "#ffff00" : "#3388ff",
width: 3,
clampToGround: clampToGround
}
})
}
export function drawPolygon(clampToGround) {
graphicLayer.startDraw({
type: "polygon",
......
......@@ -31,7 +31,7 @@ export function onMounted(mapInstance) {
type: "3dtiles",
name: "校园",
url: "//data.mars3d.cn/3dtiles/qx-xuexiao/tileset.json",
position: { alt: 282.0 },
position: { alt: 279.0 },
maximumScreenSpaceError: 1
})
map.addLayer(tilesetLayer)
......
......@@ -24,7 +24,7 @@ export function onMounted(mapInstance) {
type: "3dtiles",
name: "校园",
url: "//data.mars3d.cn/3dtiles/qx-xuexiao/tileset.json",
position: { alt: 282.0 },
position: { alt: 279.0 },
maximumScreenSpaceError: 1
})
map.addLayer(tilesetLayer)
......
......@@ -25,7 +25,7 @@ export function onMounted(mapInstance) {
type: "3dtiles",
name: "校园",
url: "//data.mars3d.cn/3dtiles/qx-xuexiao/tileset.json",
position: { alt: 282.0 },
position: { alt: 279.0 },
maximumScreenSpaceError: 1,
center: { lat: 43.821193, lng: 125.143124, alt: 990, heading: 342, pitch: -50 }
})
......
......@@ -25,7 +25,7 @@ export function onMounted(mapInstance) {
type: "3dtiles",
name: "校园",
url: "//data.mars3d.cn/3dtiles/qx-xuexiao/tileset.json",
position: { alt: 282.0 },
position: { alt: 279.0 },
maximumScreenSpaceError: 1,
center: { lat: 43.821193, lng: 125.143124, alt: 990, heading: 342, pitch: -50 }
})
......
......@@ -25,7 +25,7 @@ export function onMounted(mapInstance) {
type: "3dtiles",
name: "校园",
url: "//data.mars3d.cn/3dtiles/qx-xuexiao/tileset.json",
position: { alt: 282.0 },
position: { alt: 279.0 },
maximumScreenSpaceError: 1,
center: { lat: 43.821193, lng: 125.143124, alt: 990, heading: 342, pitch: -50 }
})
......
......@@ -23,7 +23,7 @@ export function onMounted(mapInstance) {
const tiles3dLayer = new mars3d.layer.TilesetLayer({
name: "校园",
url: "//data.mars3d.cn/3dtiles/qx-xuexiao/tileset.json",
position: { alt: 282.0 },
position: { alt: 279.0 },
maximumScreenSpaceError: 1
})
map.addLayer(tiles3dLayer)
......
......@@ -61,21 +61,3 @@ function queryTilesetData() {
console.log("加载JSON出错", error)
})
}
export function cutModel(layer) {
// 3d模型裁剪
tilesetClip = new mars3d.thing.TilesetClip({
layer: layer,
positions: [
[117.217052, 31.828226, 33],
[117.226442, 31.826613, 36.3],
[117.226796, 31.807994, 21.8],
[117.209922, 31.808607, 34.8],
[117.209823, 31.816096, 23.9],
[117.214736, 31.816278, 34],
[117.214412, 31.82334, 33.6],
[117.216856, 31.823559, 28.4]
]
})
map.addThing(tilesetClip)
}
......@@ -10,7 +10,7 @@
<!-- 360浏览器默认使用Webkit内核 -->
<meta name="renderer" content="webkit" />
<script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=qObioeG8HeeQVrOVAGScPVhDzlmv6rL9"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=rRNccUKl1e08vqFqGU2BZMDpkzzULpzk"></script>
<style type="text/css">
body,
html {
......@@ -20,7 +20,7 @@
font-family: "微软雅黑";
}
#streetscapeMap {
width: 50%;
width: 100%;
height: 100%;
}
</style>
......
......@@ -58,9 +58,9 @@ export function chooseStree() {
tileLayer.show = true
if (typeView !== 0) {
viewTo3d()
}
// if (typeView !== 0) {
// viewTo3d()
// }
graphicLayer.startDraw({
type: "billboard",
......
......@@ -48,9 +48,11 @@ export function onUnmounted() {
export function createMap() {
if (map) {
globalMsg("地图已存在,请勿重复创建!")
return
return map
}
map = new mars3d.Map("mars3dContainer", mapOptions)
return map
}
export function destroyMap() {
......
......@@ -5,7 +5,12 @@ export let map // mars3d.Map三维地图对象
// 需要覆盖config.json中地图属性参数(当前示例框架中自动处理合并)
export const mapOptions = {
scene: {
center: { lat: 30.309522, lng: 116.275765, alt: 69659, heading: 0, pitch: -45 }
center: { lat: 30.309522, lng: 116.275765, alt: 69659, heading: 0, pitch: -45 },
contextOptions: {
webgl: {
preserveDrawingBuffer: true // 截图是黑色时,需要将该项设置为true
}
}
},
layers: [
{
......
......@@ -42,42 +42,6 @@ function addMeasure() {
})
map.addThing(measure)
// 直接传入坐标分析
measure
.volume({
positions: mars3d.PointTrans.lonlats2cartesians([
[116.191817, 30.864845, 309.3],
[116.192869, 30.8757, 521.81],
[116.190478, 30.886266, 672.79],
[116.19247, 30.893748, 448.91],
[116.200836, 30.889954, 379.92],
[116.204063, 30.882578, 532.5],
[116.203027, 30.873828, 498.8],
[116.201795, 30.865941, 443.06]
]),
splitNum: 6,
height: 450
})
.then((e) => {
measureVolume = e
showHeightVal()
})
// 有模型时
// tiles3dLayer.readyPromise.then((layer) => {
// // 关键代码,等模型readyPromise加载后执行volume
// measureVolume = measure.volume({
// positions: mars3d.PointTrans.lonlats2cartesians([
// [119.033856, 33.591473, 14.5],
// [119.033098, 33.591836, 13.2],
// [119.033936, 33.592146, 16.9]
// ]),
// has3dtiles: true, //关键代码,标识有模型
// splitNum: 6,
// height: 150
// })
// })
measure.on(mars3d.EventType.start, function (event) {
console.log("开始分析", event)
clearInterResult()
......@@ -89,6 +53,45 @@ function addMeasure() {
console.log("分析完成", event)
hideLoading()
})
// 加一些演示数据
setTimeout(() => {
addDemoGraphic1(measure.graphicLayer)
}, 3000)
// 有模型时
// tiles3dLayer.readyPromise.then((layer) => {
// // 关键代码,等模型readyPromise加载后执行volume
// addDemoGraphic1(measure.graphicLayer)
// })
}
function addDemoGraphic1(graphicLayer) {
const graphic = new mars3d.graphic.VolumeMeasure({
splitNum: 6,
height: 450,
positions: [
[116.191817, 30.864845, 309.3],
[116.192869, 30.8757, 521.81],
[116.190478, 30.886266, 672.79],
[116.19247, 30.893748, 448.91],
[116.200836, 30.889954, 379.92],
[116.204063, 30.882578, 532.5],
[116.203027, 30.873828, 498.8],
[116.201795, 30.865941, 443.06]
],
style: {
width: 5,
color: "#3388ff"
},
attr: { remark: "示例1" }
})
graphic.on(mars3d.EventType.end, function () {
showHeightVal()
})
graphicLayer.addGraphic(graphic)
measureVolume = graphic
}
// 点选高度
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论