html52.com
我爱小程序-开发者交流社区

XR-FRAME模型交互点击事件不起作用

<xr-scene  bind:ready="handleReady">
  <xr-assets bind:progress="handleAssetsProgress" bind:loaded="handleAssetsLoaded">
      <xr-asset-load type="gltf" asset-id="damage-helmet" src="https://mmbizwxaminiprogram-1258344707.cos.ap-guangzhou.myqcloud.com/xr-frame/demo/damage-helmet/index.glb" />
       <xr-asset-load type="gltf" asset-id="miku" src="https://mmbizwxaminiprogram-1258344707.cos.ap-guangzhou.myqcloud.com/xr-frame/demo/miku.glb" />
  </xr-assets>
  <xr-env env-data="xr-frame-team-workspace-day"/>
  <xr-light type="ambient" color="1 1 1" intensity="1" />
 <xr-light type="directional" rotation="40 70 0" color="1 1 1" intensity="3" cast-shadow />
  <xr-gltf node-id="damage-helmet" model="damage-helmet" id="helmet" mesh-shape bind:touch-shape="handleTouchModel"/>
  <xr-gltf model="miku" position="-0.15 0.75 0" scale="0.07 0.07 0.07" rotation="0 180 0" anim-autoplay 
		id="miku" cube-shape="autoFit:true" shape-gizmo bind:touch-shape="handleTouchModel"/>
<xr-camera  position="0 1.5 4" target="damage-helmet" background="skybox"
	  clear-color="0.4 0.8 0.6 1" camera-orbit-control />
</xr-scene>


// index.js
// 获取应用实例
//const app = getApp()


Page({
	data: {
    },
	// 事件处理函数
	onLoad() {


	},
	methods: {
		handleReady: function ({detail}) {
		    this.scene = detail.value;
		},
		handleAssetsProgress: function ({detail}) {
			console.log('assets progress', detail.value);
	    },
	    handleAssetsLoaded: function ({detail}) {
			console.log('assets loaded', detail.value);
	    },
		//模型点击事件
		handleTouchModel: function ({detail}) {
		  const {target} = detail.value;
		  const id = target.id;
		  
		  wx.showToast({title: `点击了模型: ${id}`});
		}
	}
})


arget.id;
		  
		  wx.showToast({title: `点击了模型: ${id}`});
		}
	}
})


网友回复

goutou1994:

试了下这段代码是可以触发事件的,你可以尝试下更新工具和微信客户端版本。

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付