|
@@ -14,10 +14,12 @@ Component({
|
|
|
async detached() {
|
|
|
console.error('detached')
|
|
|
this.video1 && (this.video1 = null);
|
|
|
+ this.video12 && (this.video12 = null);
|
|
|
this.video2 && (this.video2 = null);
|
|
|
this.animator1 && (this.animator1 = null);
|
|
|
this.animator2 && (this.animator2 = null);
|
|
|
this.animator3 && (this.animator3 = null);
|
|
|
+ this.innerAudioContext1 && this.innerAudioContext1.destroy() && (this.innerAudioContext1 = null)
|
|
|
this.setData({
|
|
|
isStartPlay1: false,
|
|
|
isStartPlay2: false,
|
|
@@ -48,6 +50,11 @@ Component({
|
|
|
this.mat = new(wx.getXrFrameSystem().Matrix4)();
|
|
|
console.log('xr-scene', xrScene)
|
|
|
this.triggerEvent('ready')
|
|
|
+ this.innerAudioContext1 = wx.createInnerAudioContext({
|
|
|
+ useWebAudioImplement: false // 是否使用 WebAudio 作为底层音频驱动,默认关闭。对于短音频、播放频繁的音频建议开启此选项,开启后将获得更优的性能表现。由于开启此选项后也会带来一定的内存增长,因此对于长音频建议关闭此选项
|
|
|
+ })
|
|
|
+ this.innerAudioContext1.src = 'https://houseoss.4dkankan.com/mini-ar-test/AR/01/audio1.MP3'
|
|
|
+
|
|
|
},
|
|
|
handleARReady() {
|
|
|
console.log('handleARReady')
|
|
@@ -76,19 +83,40 @@ Component({
|
|
|
detail
|
|
|
}) {
|
|
|
const el = detail.value.target;
|
|
|
- console.warn('item1 load')
|
|
|
+ console.warn('item1 load', el)
|
|
|
const gltf = el.getComponent("gltf");
|
|
|
const video = this.scene.assets.getAsset("video-texture", "item1-v");
|
|
|
+ const video12 = this.scene.assets.getAsset("video-texture", "item12-v");
|
|
|
const newMat = this.scene.assets.getAsset("material", "item1-m");
|
|
|
+ const newMat2 = this.scene.assets.getAsset("material", "item12-m");
|
|
|
+
|
|
|
this.video1 = video
|
|
|
- // this.video1.onEnd = () => {}
|
|
|
+ this.video12 = video12
|
|
|
+
|
|
|
+ this.video1.onEnd = () => {
|
|
|
+ this.innerAudioContext1 && this.innerAudioContext1.play()
|
|
|
+ this.video12 && this.video12.play();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
const animator = el.getComponent("animator");
|
|
|
this.animator1 = animator
|
|
|
- console.warn('animator1', this.animator1)
|
|
|
- for (const mesh of gltf.getPrimitivesByNodeName("video")) {
|
|
|
- mesh.material = newMat
|
|
|
+ // getPrimitivesByNodeName
|
|
|
+ const othergltf = this.scene.assets.getAsset("gltf", "item1")
|
|
|
+ console.error('meshes', gltf.meshes)
|
|
|
+ // console.error('othergltf', othergltf)
|
|
|
+ for (const mesh of gltf.meshes) {
|
|
|
+ console.log(mesh.name)
|
|
|
+ if (mesh.name === 'mesh_video_16024video1') {
|
|
|
+ mesh.material = newMat
|
|
|
+ console.log('mesh', mesh)
|
|
|
+ }
|
|
|
+ // mesh.material = newMat
|
|
|
}
|
|
|
-
|
|
|
+ // for (const mesh of gltf.getPrimitivesByMeshName("video2")) {
|
|
|
+ // console.error('2有video2')
|
|
|
+ // mesh.material = newMat2
|
|
|
+ // }
|
|
|
},
|
|
|
handleItem2Loaded({
|
|
|
detail
|
|
@@ -99,7 +127,9 @@ Component({
|
|
|
const video = this.scene.assets.getAsset("video-texture", "item2-v");
|
|
|
const newMat = this.scene.assets.getAsset("material", "item2-m");
|
|
|
this.video2 = video
|
|
|
+
|
|
|
for (const mesh of gltf.getPrimitivesByNodeName("video")) {
|
|
|
+ console.error('2有video')
|
|
|
mesh.material = newMat
|
|
|
}
|
|
|
},
|
|
@@ -118,10 +148,13 @@ Component({
|
|
|
if (type === 1) {
|
|
|
console.warn('play 1')
|
|
|
if (this.video1) {
|
|
|
- this.data.isStartPlay1 ? this.video1.resume() : this.video1.play()
|
|
|
+ // this.data.isStartPlay1 ? this.video1.resume() : this.video1.play()
|
|
|
+ // this.data.isStartPlay1 ? this.innerAudioContext1.resume() : this.innerAudioContext1.play()
|
|
|
+ // this.video1.play()
|
|
|
}
|
|
|
if (this.animator1) {
|
|
|
- this.data.isStartPlay1 ? this.animator1.resume('Animation') : this.animator1.play('Animation')
|
|
|
+ // this.data.isStartPlay1 ? this.animator1.resume('dd') : this.animator1.play('dd')
|
|
|
+ this.animator1.play('dd')
|
|
|
}
|
|
|
this.setData({
|
|
|
isStartPlay1: true
|
|
@@ -166,12 +199,13 @@ Component({
|
|
|
pause(type) {
|
|
|
if (type === 1) {
|
|
|
console.warn('pause 1')
|
|
|
- if (this.video1) {
|
|
|
- this.video1.pause()
|
|
|
- }
|
|
|
- if (this.animator1) {
|
|
|
- this.animator1.pause('Animation')
|
|
|
- }
|
|
|
+
|
|
|
+ // if (this.video1) {
|
|
|
+ // this.video1.pause()
|
|
|
+ // }
|
|
|
+ // if (this.animator1) {
|
|
|
+ // this.animator1.pause('Animation')
|
|
|
+ // }
|
|
|
}
|
|
|
if (type === 2) {
|
|
|
console.warn('pause 2')
|