index.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. var sceneReadyBehavior = require('../../behavior-scene/scene-ready');
  2. var handleDecodedXML = require('../../behavior-scene/util').handleDecodedXML;
  3. var xmlCode = `<xr-scene ar-system="modes:OSD" id="xr-scene" bind:ready="handleReady" bind:arReady="handleARReady" bind:log="handleLog">
  4. <xr-assets bind:progress="handleAssetsProgress" bind:loaded="handleAssetsLoaded">
  5. <xr-asset-load type="gltf" asset-id="gltf-burger" src="https://mmbizwxaminiprogram-1258344707.cos.ap-guangzhou.myqcloud.com/xr-frame/demo/burger/burger.gltf" />
  6. <xr-asset-material asset-id="ar-anchor" effect="standrand" uniforms="u_baseColorFactor:0 1 0 1"></xr-asset-material>
  7. </xr-assets>
  8. <xr-node>
  9. <xr-node node-id="id2" scale="2 2 2" position="0 0 0"></xr-node>
  10. <xr-ar-tracker mode="OSD" src="{{markerImg}}">
  11. <xr-mesh id="ar-tracker-mesh" geometry="cylinder" material="ar-anchor" />
  12. </xr-ar-tracker>
  13. <xr-camera
  14. id="camera" node-id="camera" position="0.8 2.2 -5" clear-color="0.925 0.925 0.925 1"
  15. target="id2" background="ar" is-ar-camera
  16. camera-orbit-control
  17. ></xr-camera>
  18. </xr-node>
  19. <xr-node node-id="lights">
  20. <xr-light type="ambient" color="1 1 1" intensity="1" />
  21. <xr-light type="directional" rotation="180 0 0" color="1 1 1" intensity="3" />
  22. </xr-node>
  23. </xr-scene>
  24. `;
  25. Page({
  26. behaviors:[sceneReadyBehavior],
  27. data: {
  28. xmlCode: '<div class="codeWrap">' + handleDecodedXML(xmlCode) + '</div>',
  29. markerImg: 'https://mmbizwxaminiprogram-1258344707.cos.ap-guangzhou.myqcloud.com/xr-frame/demo/marker/osdmarker-test.jpg'
  30. },
  31. handleChangeMarkerImg: function() {
  32. wx.chooseMedia({
  33. count: 1,
  34. sizeType: ['compressed'],
  35. mediaType: ['image'],
  36. sourceType: ['album'],
  37. success: res => {
  38. const fp = res.tempFiles[0].tempFilePath;
  39. this.setData({markerImg: fp});
  40. },
  41. fail: err => {
  42. console.error('[xr-demo]chooseImage failed', err);
  43. }
  44. });
  45. }
  46. });