123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452 |
- Component({
- behaviors: [require('../common/share-behavior').default],
- properties: {
- captureState: {
- type: Number,
- value: 0,
- observer: function (newVal, oldVal) {
- if (newVal !== oldVal) {
- if (newVal === 1) {
- this.capture();
-
- }
- }
- },
- },
- recordState: {
- type: Number,
- value: 0,
- observer: function (newVal, oldVal) {
- if (newVal !== oldVal) {
- if (newVal === 0) {
- this.recordEnd();
- } else {
- this.recordStart();
- }
- }
- }
- },
- captureQuality: {
- type: Number,
- value: 0.8,
- },
- captureType: {
- type: String,
- value: 'jpg',
- },
- recordFPS: {
- type: Number,
- value: 30,
- },
- recordWidth: {
- type: Number,
- value: undefined,
- },
- recordHeight: {
- type: Number,
- value: undefined,
- },
- recordBPS: {
- type: Number,
- value: 1000,
- },
- uiShowModelView:{
- type: Boolean,
- value: false,
- observer: function (newVal, oldVal) {
-
- if (newVal !== oldVal) {
- if(newVal){
- //this.ShowModel(1);
- }else{
- this.CloseModel();
- }
- }
- },
- },
- uiShowIndex:{
- type: Number,
- value: 0,
- observer: function (newVal, oldVal) {
- if (newVal !== oldVal) {
- this.ShowModel(newVal);
- }
- },
- }
- },
- data: {
- loaded: false,
- loadedSaoMiao:false,
- loaded: false,
- arReady: false,
- loaded2:false,
- position2:[0,0,0],
- rot:0,
- str:"1",
- luanniaoShow:false,
- fuzhuShow:false,
- yinglongShow:false,
- nianshouShow:false,
- sceneHight:600,
- sceneWidth:600
- },
- lifetimes: {
- async attached() {
- console.log('data', this.data);
- }
- },
- methods: {
- handleReady: function ({detail}) {
- const xrScene = this.scene = detail.value;
- console.log('xr-scene', xrScene);
- var hight = this.scene.hight;
- var width = this.scene.width;
- this.setData({sceneHight:hight});
- this.setData({sceneWidth:width});
- this.binglong = {el:this.scene.getElementById('binglong')};
- const scene = this.scene = detail.value;
- const appHide = () => this.scene.share.recordPause();
- const appShow = () => this.scene.share.recordResume();
- wx.onAppHide(appHide);
- wx.onAppShow(appShow);
- wx.offAppHide(appHide);
- wx.offAppShow(appShow);
-
- this.triggerEvent('sceneReady', {width: scene.width, height: scene.height});
- const fireworkField = xrScene.getElementById("firework");
- const tempSystem = fireworkField.getComponent('custom-particle')
- tempSystem.addSizeGradient(0,0.2);
- tempSystem.addSizeGradient(3,1);
- var myData ={}
- myData = {
- "capacity": 100,
- "emitRate": 0, //子发射器不进行每秒发射
- "burstCount": 100, // 一次爆发200粒子
- "burstTime": 0, // 爆发延时为0
- "burstCycle": 1, // 发射一次
- "size":[0.05],
- "startColor":[1,0.3,0.1,1],
- "endColor":[1,1,1,0],
- "emitterType":"SphereShape",
- "emitterProps": [["radius","0.5"]],
- "lifeTime":[1], // 粒子生命周期为3秒
- "stopDuration":[2], // 子发射器生命周期为3秒
- "speed":"2",
- "texture":"flarePicture"
- }
- var subEmitter = tempSystem.createSubEmitter(myData)
- subEmitter.state = 1 // 设置为1为当粒子消失后出现作用子发射器
- //可以规定多个子发射器的阵列
- tempSystem.subEmitters = [subEmitter]
- const fireworkField2 = xrScene.getElementById("firework2");
- const tempSystem2 = fireworkField2.getComponent('custom-particle')
- tempSystem2.addSizeGradient(0,0.2);
- tempSystem2.addSizeGradient(3,1);
- var myData2 ={}
- myData2 = {
- "capacity": 100,
- "emitRate": 0, //子发射器不进行每秒发射
- "burstCount": 100, // 一次爆发200粒子
- "burstTime": 0.1, // 爆发延时为0
- "burstCycle": 1, // 发射一次
- "size":[0.05],
- "startColor":[1,0.5,0.8,1],
- "endColor":[1,1,1,0],
- "emitterType":"SphereShape",
- "emitterProps": [["radius","0.5"]],
- "lifeTime":[1], // 粒子生命周期为3秒
- "stopDuration":[2], // 子发射器生命周期为3秒
- "speed":"2",
- "texture":"flarePicture"
- }
- var subEmitter2 = tempSystem2.createSubEmitter(myData2)
- subEmitter2.state = 1 // 设置为1为当粒子消失后出现作用子发射器
- //可以规定多个子发射器的阵列
- tempSystem2.subEmitters = [subEmitter2]
- const fireworkField3 = xrScene.getElementById("firework3");
- const tempSystem3 = fireworkField3.getComponent('custom-particle')
- tempSystem3.addSizeGradient(0,0.2);
- tempSystem3.addSizeGradient(3,1);
- var myData3 ={}
- myData3 = {
- "capacity": 100,
- "emitRate": 0, //子发射器不进行每秒发射
- "burstCount": 100, // 一次爆发200粒子
- "burstTime": 0.1, // 爆发延时为0
- "burstCycle": 1, // 发射一次
- "size":[0.05],
- "startColor":[1,1,0.5,1],
- "endColor":[1,1,1,0],
- "emitterType":"SphereShape",
- "emitterProps": [["radius","0.5"]],
- "lifeTime":[1], // 粒子生命周期为3秒
- "stopDuration":[2], // 子发射器生命周期为3秒
- "speed":"2",
- "texture":"flarePicture"
- }
- var subEmitter3 = tempSystem3.createSubEmitter(myData3)
- subEmitter3.state = 1 // 设置为1为当粒子消失后出现作用子发射器
- //可以规定多个子发射器的阵列
- tempSystem3.subEmitters = [subEmitter3]
- const fireworkField4 = xrScene.getElementById("firework4");
- const tempSystem4 = fireworkField4.getComponent('custom-particle')
- tempSystem4.addSizeGradient(0,0.2);
- tempSystem4.addSizeGradient(3,1);
- var myData4 ={}
- myData4 = {
- "capacity": 100,
- "emitRate": 0, //子发射器不进行每秒发射
- "burstCount": 100, // 一次爆发200粒子
- "burstTime": 0.1, // 爆发延时为0
- "burstCycle": 1, // 发射一次
- "size":[0.05],
- "startColor":[1,0.5,0.8,1],
- "endColor":[1,1,1,0],
- "emitterType":"SphereShape",
- "emitterProps": [["radius","0.5"]],
- "lifeTime":[1], // 粒子生命周期为3秒
- "stopDuration":[2], // 子发射器生命周期为3秒
- "speed":"2",
- "texture":"flarePicture"
- }
- var subEmitter4 = tempSystem4.createSubEmitter(myData4)
- subEmitter4.state = 1 // 设置为1为当粒子消失后出现作用子发射器
- //可以规定多个子发射器的阵列
- tempSystem4.subEmitters = [subEmitter4]
- const fireworkField5 = xrScene.getElementById("firework5");
- const tempSystem5 = fireworkField5.getComponent('custom-particle')
- tempSystem5.addSizeGradient(0,0.2);
- tempSystem5.addSizeGradient(3,1);
- var myData5 ={}
- myData5 = {
- "capacity": 100,
- "emitRate": 0, //子发射器不进行每秒发射
- "burstCount": 100, // 一次爆发200粒子
- "burstTime": 0.1, // 爆发延时为0
- "burstCycle": 1, // 发射一次
- "size":[0.05],
- "startColor":[1,1,0.5,1],
- "endColor":[1,1,1,0],
- "emitterType":"SphereShape",
- "emitterProps": [["radius","0.5"]],
- "lifeTime":[1], // 粒子生命周期为3秒
- "stopDuration":[2], // 子发射器生命周期为3秒
- "speed":"2",
- "texture":"flarePicture"
- }
- var subEmitter5 = tempSystem5.createSubEmitter(myData5)
- subEmitter5.state = 1 // 设置为1为当粒子消失后出现作用子发射器
- //可以规定多个子发射器的阵列
- tempSystem5.subEmitters = [subEmitter5]
- const fireworkField6 = xrScene.getElementById("firework6");
- const tempSystem6 = fireworkField6.getComponent('custom-particle')
- tempSystem6.addSizeGradient(0,0.2);
- tempSystem6.addSizeGradient(3,1);
- var myData6 ={}
- myData6= {
- "capacity": 100,
- "emitRate": 0, //子发射器不进行每秒发射
- "burstCount": 100, // 一次爆发200粒子
- "burstTime": 0.1, // 爆发延时为0
- "burstCycle": 1, // 发射一次
- "size":[0.05],
- "startColor":[1,0.3,0.1,1],
- "endColor":[1,1,1,0],
- "emitterType":"SphereShape",
- "emitterProps": [["radius","0.5"]],
- "lifeTime":[1], // 粒子生命周期为3秒
- "stopDuration":[2], // 子发射器生命周期为3秒
- "speed":"2",
- "texture":"flarePicture"
- }
- var subEmitter6 = tempSystem6.createSubEmitter(myData6)
- subEmitter6.state = 1 // 设置为1为当粒子消失后出现作用子发射器
- //可以规定多个子发射器的阵列
- tempSystem6.subEmitters = [subEmitter6]
- const fireworkField7 = xrScene.getElementById("firework7");
- const tempSystem7 = fireworkField7.getComponent('custom-particle')
- tempSystem7.addSizeGradient(0,0.2);
- tempSystem7.addSizeGradient(3,1);
- var myData7 ={}
- myData7 = {
- "capacity": 100,
- "emitRate": 0, //子发射器不进行每秒发射
- "burstCount": 100, // 一次爆发200粒子
- "burstTime": 0.1, // 爆发延时为0
- "burstCycle": 1, // 发射一次
- "size":[0.05],
- "startColor":[1,1,0.5,1],
- "endColor":[1,1,1,0],
- "emitterType":"SphereShape",
- "emitterProps": [["radius","0.5"]],
- "lifeTime":[1], // 粒子生命周期为3秒
- "stopDuration":[2], // 子发射器生命周期为3秒
- "speed":"2",
- "texture":"flarePicture"
- }
- var subEmitter7 = tempSystem7.createSubEmitter(myData7)
- subEmitter7.state = 1 // 设置为1为当粒子消失后出现作用子发射器
- //可以规定多个子发射器的阵列
- tempSystem7.subEmitters = [subEmitter7]
- },
- handleAssetsProgress: function({detail}) {
- this.triggerEvent('assetsProgress', detail.value);
- },
- handleAssetsLoaded: function ({detail}) {
- console.log('assets loaded', detail.value);
- this.triggerEvent('assetsLoaded', detail.value);
- this.setData({
- loaded: true
- });
-
- },handleGltfLoaded2: function() {
-
- },handleGltfLoaded: function() {
-
- },
- handleTrackerSwitch: function ({detail}) {
- const active = detail.value;
- if(active)
- {
- this.setData({
- loaded2: true
- });
- }
- },handleARTrackerState({detail}) {
- // 事件的值即为`ARTracker`实例
- const tracker = detail.value;
- // 获取当前状态和错误信息
- const {state, errorMessage} = tracker;
- const element = detail.el;
- if( state==2)
- {
- this.triggerEvent('assetsstr',"state" + state);
-
- /*
- this.triggerEvent('assetsstr',"x:" + (180/Math.PI* element.scene.getNodeById("Marker").rotation.x) +"\ny:" + (180/Math.PI*element.scene.getNodeById("Marker").rotation.y)+"\nz:" + (180/Math.PI*element.scene.getNodeById("Marker").rotation.z));*/
-
- }
- },
- handleAnimationStop: function() {
- console.log('animation Stop');
- },
- /* handleGLTFLoadedbingLong:function({detail}){
- const el2 = detail.value;
-
-
- var state = true;
- const xrScene = this.scene;
- const xrFrameSystem = wx.getXrFrameSystem();
- const myModel = xrScene.getElementById('binglong');
- this.myModelAnimator = myModel.getComponent(xrFrameSystem.Animator);
- const clips = this.myModelAnimator._clips;
- this.clipName = []
- clips.forEach((v, key) => {
- if (key.indexOf('pose') == -1) {
- this.clipName.push(key)
- }
- })
- wx.showToast({
- title: this.clipName[0],
- });
- this.myModelAnimator.play.play(this.clipName[0],{ loop:5,});
- var interval = setInterval(function() {
- if(false)
- {
- clearInterval(interval);
- }
- console.log(5000 +" 毫秒更新");
- if(state)
- {
- state = false;
- this.myModelAnimator.play.play(this.clipName[1],{ loop:5,});
- }else{
- state = true;
- this.myModelAnimator.play.play(this.clipName[2],{ loop:5,});
- el2.position =(0 -2.5 -40);
- }
-
- }, 5000)
- },*/
- capture() {
- this.scene.share.captureToFriends({
- fileType: this.data.captureType,
- quality: this.data.captureQuality
- });
- },
- recordStart() {
- console.log('recordStart')
- wx.updateShareMenu({
- withShareTicket: true,
- success () { }
- })
- this.scene.share.recordStart({
- fps: 15,
- videoBitsPerSecond: 10000,
- });
- },
- recordEnd() {
- console.log('recordEnd')
-
-
- //
- const tempFilePath = this.scene.share.recordFinishToAlbum({
- fps: 15,
- videoBitsPerSecond: 10000,
- });
- wx.shareVideoMessage({
- videoPath: tempFilePath,
- });
- },
- ShowModel(modelIndex){
- console.log(' ShowMoelIndex ',modelIndex);
- switch(modelIndex){
- case 1:
- this.setData({luanniaoShow:true});
-
- break;
- case 2:
- this.setData({yinglongShow:true});
- break;
- case 3:
- this.setData({fuzhuShow:true});
- break;
- case 4:
- this.setData({nianshouShow:true});
- break;
- }
-
- },
- CloseModel(){
- this.setData({longshow:false});
- this.setData({binglongshow:false});
- this.setData({lanjiachongshow:false});
- }
- }
- })
|