实现效果:鼠标滚轮在marker或者UIAnchor顶牌上滚动不触发场景缩放。如图:
链接效果:https://www.thingjs.com/s/31f2d37a2fc41da535ccabb5
核心代码:
- // marker001 为元素的id
- document.getElementById('marker001').addEventListener('wheel', (ev) => {
- ev.stopPropagation()
- })
复制代码
整体代码如下:
- var app = new THING.App({
- url: 'https://www.thingjs.com/static/models/factory', // 场景地址
- background: '#000000',
- env: 'Seaside',
- });
- // 场景加载完成的回调函数
- app.on("load", function () {
- let name = '叉车'
- const markDown = document.createElement('div');
- markDown.innerHTML = `
- <div class='name' id='marker001' style="pointer-events:all;height: 150px;width: 320px;">
- <div style='width:320px;height:87px;line-height:87px;color:#FFFFFF;background-size:cover;background-repeat: no-repeat;background-image:url("/uploads/wechat/703071/file/marker滚轮事件不传递到场景事假上/img/顶牌_单名称栏_基础_右.png");text-align:center;font-size:38px;'>
- ${name}
- </div>
- <div style='width:100%;height:30px;margin-top:20px;'>
- <div style='width:25px;height:15px;color:#FFFFFF;margin:0px auto;background-image:url("/uploads/wechat/703071/file/marker滚轮事件不传递到场景事假上/img/顶牌_底三角.png");background-size:cover;'>
- </div>
- </div>
- `
- $('#div3d').append(markDown)
- app.create({
- type: 'Marker',
- name: '叉车顶牌',
- alwaysOnTop: true,
- size: 1,
- parent: app.query("car01")[0],
- element: markDown,
- localPosition: [0, 3, 0],
- complete: function (ev) {
- setTimeout(function () {
- // 核心代码
- // marker001 为marker顶牌 元素的id
- document.getElementById('marker001').addEventListener('wheel', (ev) => {
- ev.stopPropagation()
- })
- }, 500)
- }
- });
- })
复制代码
|
|
|
|
|
|