|
@@ -18,15 +18,17 @@ Component({
|
|
|
}) {
|
|
|
const xrScene = this.scene = detail.value;
|
|
|
this.mat = new(wx.getXrFrameSystem().Matrix4)();
|
|
|
- console.log('xr-scene', xrScene);
|
|
|
- wx.showLoading({
|
|
|
- title: 'loading...',
|
|
|
- })
|
|
|
+ console.log('xr-scene', xrScene)
|
|
|
+ this.triggerEvent('ready')
|
|
|
},
|
|
|
handleAssetsProgress: function ({
|
|
|
detail
|
|
|
}) {
|
|
|
- console.log('assets progress', detail.value);
|
|
|
+ // console.log('assets progress', detail.value.progress);
|
|
|
+ const progress =
|
|
|
+ Math.floor(detail.value.progress * 100)
|
|
|
+
|
|
|
+ this.triggerEvent('progress', progress)
|
|
|
},
|
|
|
handleAssetsLoaded: function ({
|
|
|
detail
|
|
@@ -35,7 +37,7 @@ Component({
|
|
|
const el = detail.value.target;
|
|
|
// this.setData({loaded: true});
|
|
|
this.scene.event.addOnce('touchstart', this.placeNode.bind(this));
|
|
|
- wx.hideLoading()
|
|
|
+ this.triggerEvent('loaded')
|
|
|
|
|
|
},
|
|
|
handleARReady: function ({
|
|
@@ -59,6 +61,9 @@ Component({
|
|
|
} else {
|
|
|
this.scene.ar.placeHere('setitem', true);
|
|
|
console.error('show-gltf')
|
|
|
+ if (this.video) {
|
|
|
+ this.video.play()
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -70,14 +75,13 @@ Component({
|
|
|
const el = detail.value.target;
|
|
|
console.error('handleGLTFLoaded')
|
|
|
const gltf = el.getComponent("gltf");
|
|
|
- const vt = this.scene.assets.getAsset("texture", "video-cat");
|
|
|
+ const video = this.scene.assets.getAsset("video-texture", "cat");
|
|
|
const newMat = this.scene.assets.getAsset("material", "catMat");
|
|
|
- console.log('vt', vt)
|
|
|
|
|
|
- for (const mesh of gltf.getPrimitivesByNodeName("video")) {
|
|
|
+ this.video = video
|
|
|
|
|
|
+ for (const mesh of gltf.getPrimitivesByNodeName("video")) {
|
|
|
mesh.material = newMat
|
|
|
- // mesh.material.setTexture("u_baseColorMap", vt);
|
|
|
}
|
|
|
}
|
|
|
}
|