当前位置: 首页> 文旅> 美景 > 做一个简单的网页游戏_制作网页可以使用的网页元素包括_湖南专业关键词优化服务水平_网站建设公司苏州

做一个简单的网页游戏_制作网页可以使用的网页元素包括_湖南专业关键词优化服务水平_网站建设公司苏州

时间:2025/7/13 23:30:18来源:https://blog.csdn.net/m0_69803146/article/details/142383998 浏览次数:0次
做一个简单的网页游戏_制作网页可以使用的网页元素包括_湖南专业关键词优化服务水平_网站建设公司苏州

问题描述:

1.new mars3d.graphic.PolygonEntity({在更新点位高度模拟水面上身的时候,会存在闪烁

2.当把addDemoGraphic4添加到图层后,addDemoGraphic1水位变化不闪烁,把addDemoGraphic4注释后,addDemoGraphic1闪烁。

//可以直接在此附代码内容
import * as mars3d from "mars3d"export let map // mars3d.Map三维地图对象
export let graphicLayer // 矢量图层对象
export let graphicLayer1 // 矢量图层对象
export const eventTarget = new mars3d.BaseClass()// 需要覆盖config.json中地图属性参数(当前示例框架中自动处理合并)
export const mapOptions = {scene: {center: { lat: 31.622151, lng: 117.274595, alt: 28451, heading: 2, pitch: -49 }}
}
/*** 初始化地图业务,生命周期钩子函数(必须)* 框架在地图初始化完成后自动调用该函数* @param {mars3d.Map} mapInstance 地图对象* @returns {void} 无*/
export function onMounted(mapInstance) {map = mapInstance // 记录map// 创建矢量数据图层graphicLayer = new mars3d.layer.GraphicLayer()map.addLayer(graphicLayer)graphicLayer1 = new mars3d.layer.GraphicLayer()map.addLayer(graphicLayer1)// 在layer上绑定监听事件graphicLayer.on(mars3d.EventType.click, function (event) {console.log("监听layer,单击了矢量对象", event)})// 加一些演示数据addDemoGraphic1(graphicLayer)addDemoGraphic4(graphicLayer)
}/*** 释放当前地图业务的生命周期函数* @returns {void} 无*/
export function onUnmounted() {map = nullgraphicLayer.remove()graphicLayer = null
}function addDemoGraphic1(graphicLayer) {const graphic = new mars3d.graphic.PolygonEntity({positions: [[117.271662, 31.870639, 21.49],[117.290605, 31.871517, 19.47],[117.302056, 31.858145, 16.27],[117.299439, 31.847545, 14.77],[117.267705, 31.8491, 22.11]],style: {color: "#3388ff",opacity: 0.5},attr: { remark: "示例1" }})graphicLayer.addGraphic(graphic) // 还可以另外一种写法: graphic.addTo(graphicLayer)let a = 10setInterval(() => {a = a + 10;graphic.positions = [[117.271662, 31.870639, a],[117.290605, 31.871517, 19.47],[117.302056, 31.858145, 16.27],[117.299439, 31.847545, 14.77],[117.267705, 31.8491, 22.11]]}, 200)
}function addDemoGraphic4(graphicLayer) {const graphic = new mars3d.graphic.PolygonEntity({positions: [[117.183593, 31.856606, 32.1],[117.197665, 31.86613, 33.9],[117.213155, 31.854726, 28.6],[117.203837, 31.842409, 30.4],[117.186741, 31.845103, 45.5]],style: {color: "#00ff00",diffHeight: 2000.0,closeTop: false,closeBottom: false,opacity: 0.5,}})graphicLayer.addGraphic(graphic) // 还可以另外一种写法: graphic.addTo(graphicLayer)
}

解决方案:

1.

entity如果不闪烁,需要将坐标改为属性机制的,可以用setCallbackPositions方法赋值。

  let a = 10setInterval(() => {a = a + 10graphic.setCallbackPositions([[117.271662, 31.870639, a],[117.290605, 31.871517, 19.47],[117.302056, 31.858145, 16.27],[117.299439, 31.847545, 14.77],[117.267705, 31.8491, 22.11]])}, 200)

2.至于为什么当把addDemoGraphic4添加到图层后,addDemoGraphic1水位变化不闪烁,目前不太清楚。

 

关键字:做一个简单的网页游戏_制作网页可以使用的网页元素包括_湖南专业关键词优化服务水平_网站建设公司苏州

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: