tencentcloud-webar 2.0.3-dev.2 → 2.0.3-dev.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build-esm/790.js CHANGED
@@ -1 +1 @@
1
- (self['webpackChunktencentcloud_webar']=self['webpackChunktencentcloud_webar']||[])['push']([[0x316],{0xae6:(b,d,f)=>{f['r'](d),f['d'](d,{'PhysicsController':()=>q,'PhysicsModelParser':()=>g});var g=(function(){function u(v){this['CANNON']=v;}return u['prototype']['parse']=function(v){var w,x,y=this,z=[],A=new Map();return v['traverse'](function(B){if(B['name']){var C=B['name']['toLowerCase']();if(console['log']('解析节点:\x20\x22'['concat'](B['name'],'\x22,\x20类型:\x20')['concat'](B['type'],',\x20位置:'),B['position']),/_\d+$/['test'](C))console['log']('\x20\x20->\x20跳过拆分子节点:\x20'['concat'](B['name']));else{if(y['isAnchor'](C))A['has']('anchor')||A['set']('anchor',[]),A['get']('anchor')['push'](B);else{if(y['isChain'](C)){var D=y['extractChainIndex'](C),E='chain-'['concat'](D);A['has'](E)||A['set'](E,[]),A['get'](E)['push'](B);}else y['isPendant'](C)&&(A['has']('pendant')||A['set']('pendant',[]),A['get']('pendant')['push'](B));}}}}),w=this['selectBestCandidate'](A['get']('anchor')),x=this['selectBestCandidate'](A['get']('pendant')),Array['from'](A['keys']())['filter'](function(B){return B['startsWith']('chain-');})['sort'](function(B,C){return parseInt(B['split']('-')[0x1])-parseInt(C['split']('-')[0x1]);})['forEach'](function(B){var C=y['selectBestCandidate'](A['get'](B));C&&z['push'](C);}),x&&!z['includes'](x)&&z['push'](x),console['log']('解析结果:',{'anchor':null==w?void 0x0:w['name'],'chains':z['map'](function(B){return B['name'];}),'pendant':null==x?void 0x0:x['name']}),{'anchorMesh':w,'chainMeshes':z,'pendantMesh':x};},u['prototype']['selectBestCandidate']=function(v){if(!v||0x0===v['length'])return null;var w=v['filter'](function(y){return'Group'===y['type'];});if(w['length']>0x0)return console['log']('\x20\x20->\x20选择\x20Group:\x20'['concat'](w[0x0]['name'])),w[0x0];var x=v['filter'](function(y){return'Mesh'===y['type'];});return x['length']>0x0?(console['log']('\x20\x20->\x20选择\x20Mesh:\x20'['concat'](x[0x0]['name'])),x[0x0]):(console['log']('\x20\x20->\x20选择默认:\x20'['concat'](v[0x0]['name'])),v[0x0]);},u['prototype']['isAnchor']=function(v){return v['startsWith']('anchor');},u['prototype']['isChain']=function(v){return v['startsWith']('chain');},u['prototype']['isPendant']=function(v){return v['startsWith']('pendant');},u['prototype']['extractChainIndex']=function(v){var w=v['match'](/chain-(\d+)/);return w?parseInt(w[0x1])-0x1:0x0;},u;}()),j=function(){return j=Object['assign']||function(u){for(var v,w=0x1,x=arguments['length'];w<x;w++)for(var y in v=arguments[w])Object['prototype']['hasOwnProperty']['call'](v,y)&&(u[y]=v[y]);return u;},j['apply'](this,arguments);},k=function(u,v,w,x){return new(w||(w=Promise))(function(y,z){function A(D){try{C(x['next'](D));}catch(E){z(E);}}function B(D){try{C(x['throw'](D));}catch(E){z(E);}}function C(D){var E;D['done']?y(D['value']):(E=D['value'],E instanceof w?E:new w(function(F){F(E);}))['then'](A,B);}C((x=x['apply'](u,v||[]))['next']());});},l=function(u,v){var w,x,y,z,A={'label':0x0,'sent':function(){if(0x1&y[0x0])throw y[0x1];return y[0x1];},'trys':[],'ops':[]};return z={'next':B(0x0),'throw':B(0x1),'return':B(0x2)},'function'==typeof Symbol&&(z[Symbol['iterator']]=function(){return this;}),z;function B(C){return function(D){return function(E){if(w)throw new TypeError('Generator\x20is\x20already\x20executing.');for(;A;)try{if(w=0x1,x&&(y=0x2&E[0x0]?x['return']:E[0x0]?x['throw']||((y=x['return'])&&y['call'](x),0x0):x['next'])&&!(y=y['call'](x,E[0x1]))['done'])return y;switch(x=0x0,y&&(E=[0x2&E[0x0],y['value']]),E[0x0]){case 0x0:case 0x1:y=E;break;case 0x4:return A['label']++,{'value':E[0x1],'done':!0x1};case 0x5:A['label']++,x=E[0x1],E=[0x0];continue;case 0x7:E=A['ops']['pop'](),A['trys']['pop']();continue;default:if(!(y=A['trys'],(y=y['length']>0x0&&y[y['length']-0x1])||0x6!==E[0x0]&&0x2!==E[0x0])){A=0x0;continue;}if(0x3===E[0x0]&&(!y||E[0x1]>y[0x0]&&E[0x1]<y[0x3])){A['label']=E[0x1];break;}if(0x6===E[0x0]&&A['label']<y[0x1]){A['label']=y[0x1],y=E;break;}if(y&&A['label']<y[0x2]){A['label']=y[0x2],A['ops']['push'](E);break;}y[0x2]&&A['ops']['pop'](),A['trys']['pop']();continue;}E=v['call'](u,A);}catch(F){E=[0x6,F],x=0x0;}finally{w=y=0x0;}if(0x5&E[0x0])throw E[0x1];return{'value':E[0x0]?E[0x1]:void 0x0,'done':!0x0};}([C,D]);};}},m=function(u,v){var w='function'==typeof Symbol&&u[Symbol['iterator']];if(!w)return u;var x,y,z=w['call'](u),A=[];try{for(;(void 0x0===v||v-->0x0)&&!(x=z['next']())['done'];)A['push'](x['value']);}catch(B){y={'error':B};}finally{try{x&&!x['done']&&(w=z['return'])&&w['call'](z);}finally{if(y)throw y['error'];}}return A;},p=function(u,v,w){if(w||0x2===arguments['length']){for(var x,y=0x0,z=v['length'];y<z;y++)!x&&y in v||(x||(x=Array['prototype']['slice']['call'](v,0x0,y)),x[y]=v[y]);}return u['concat'](x||Array['prototype']['slice']['call'](v));},q=(function(){function u(v,w){void 0x0===v&&(v={}),this['chainBodies']=[],this['meshes']=[],this['constraints']=[],this['originalTransforms']=[],this['spacing']=1.2,this['ANCHOR_SWING_ANGLE']=0xf,this['initialized']=!0x1,this['groupScale']=0x1,this['lastAnchorPosition']={'x':0x0,'y':0x0,'z':0x0},this['smoothedAnchorPosition']={'x':0x0,'y':0x0,'z':0x0},this['GRAVITY_SCALE']=14.3,this['config']=j({'gravity':-9.8,'damping':0.8,'mass':0.05,'swingAngle':0x5},v),this['anchorPoint']=w||'';}return u['prototype']['init']=function(v){var w;return k(this,void 0x0,Promise,function(){var x,z,B,C,D,E,F,G,H,I,J,K,L,M,O;return l(this,function(P){switch(P['label']){case 0x0:return P['trys']['push']([0x0,0x2,,0x3]),x=this,[0x4,f['e'](0x21d)['then'](f['bind'](f,0x96f))];case 0x1:return x['CANNON']=P['sent'](),z=(null!==(w=this['config']['gravity'])&&void 0x0!==w?w:-9.8)*this['GRAVITY_SCALE'],this['world']=new this['CANNON']['World']({'gravity':new this['CANNON']['Vec3'](0x0,z,0x0)}),this['world']['solver']['iterations']=0x14,console['log']('PhysicsController:\x20cannon-es\x20加载成功'),B=new g(this['CANNON']),C=B['parse'](v),D=C['anchorMesh'],E=C['chainMeshes'],F=C['pendantMesh'],D&&0x0!==E['length']?(E['length']>=0x1&&(G=D['position'],H=E[0x0]['position'],console['log']('===\x20间距计算详情\x20==='),console['log']('锚点\x20\x22'['concat'](D['name']||'anchor','\x22\x20位置:'),{'x':G['x']['toFixed'](0x6),'y':G['y']['toFixed'](0x6),'z':G['z']['toFixed'](0x6)}),console['log']('第一个链节\x20\x22'['concat'](E[0x0]['name']||'chain_1','\x22\x20位置:'),{'x':H['x']['toFixed'](0x6),'y':H['y']['toFixed'](0x6),'z':H['z']['toFixed'](0x6)}),I=H['x']-G['x'],J=H['y']-G['y'],K=H['z']-G['z'],console['log']('位置差值:',{'deltaX':I['toFixed'](0x6),'deltaY':J['toFixed'](0x6),'deltaZ':K['toFixed'](0x6)}),this['spacing']=Math['sqrt'](I*I+J*J+K*K),console['log']('计算过程:'),console['log']('\x20\x20√('['concat'](I['toFixed'](0x6),'²\x20+\x20')['concat'](J['toFixed'](0x6),'²\x20+\x20')['concat'](K['toFixed'](0x6),'²)')),console['log']('\x20\x20=\x20√('['concat']((I*I)['toFixed'](0x6),'\x20+\x20')['concat']((J*J)['toFixed'](0x6),'\x20+\x20')['concat']((K*K)['toFixed'](0x6),')')),console['log']('\x20\x20=\x20√'['concat']((I*I+J*J+K*K)['toFixed'](0x6))),console['log']('\x20\x20=\x20'['concat'](this['spacing']['toFixed'](0x6))),console['log']('===\x20所有链节间距离\x20==='),L=G,M=D['name']||'anchor',E['forEach'](function(Q,R){var S=Q['position'],T=Q['name']||'chain_'['concat'](R+0x1),U=Math['sqrt'](Math['pow'](S['x']-L['x'],0x2)+Math['pow'](S['y']-L['y'],0x2)+Math['pow'](S['z']-L['z'],0x2));console['log'](''['concat'](M,'\x20→\x20')['concat'](T,':\x20')['concat'](U['toFixed'](0x6))),L=S,M=T;})),console['log']('PhysicsController:\x20模型间距\x20=',this['spacing'],'m'),this['meshes']=p([D],m(E),!0x1),F&&!E['includes'](F)&&this['meshes']['push'](F),this['originalTransforms']=this['meshes']['map'](function(Q){return{'position':{'x':Q['position']['x'],'y':Q['position']['y'],'z':Q['position']['z']},'quaternion':{'x':Q['quaternion']['x'],'y':Q['quaternion']['y'],'z':Q['quaternion']['z'],'w':Q['quaternion']['w']}};}),this['createPhysicsBodies'](),this['initialized']=!0x0,console['log']('PhysicsController:\x20初始化完成,'['concat'](this['chainBodies']['length'],'\x20个链节')),[0x3,0x3]):(console['warn']('PhysicsController:\x20未找到锚点或链节'),[0x2]);case 0x2:throw O=P['sent'](),console['error']('PhysicsController:\x20初始化失败',O),O;case 0x3:return[0x2];}});});},u['prototype']['createPhysicsBodies']=function(){var D,E,F,G,H,I,J=0.3*this['spacing'];this['hiddenAnchor']=new this['CANNON']['Body']({'mass':0x0,'type':this['CANNON']['Body']['KINEMATIC'],'position':new this['CANNON']['Vec3'](0x0,0x0,0x0),'shape':new this['CANNON']['Sphere'](0.5*J)}),this['world']['addBody'](this['hiddenAnchor']);var K=this['meshes'][0x0];this['anchorBody']=new this['CANNON']['Body']({'mass':0.5*(null!==(D=this['config']['mass'])&&void 0x0!==D?D:0.05),'position':new this['CANNON']['Vec3']((null==K?void 0x0:K['position']['x'])||0x0,(null==K?void 0x0:K['position']['y'])||0x0,(null==K?void 0x0:K['position']['z'])||0x0),'shape':new this['CANNON']['Sphere'](J),'linearDamping':0.8,'angularDamping':0.8}),this['world']['addBody'](this['anchorBody']);var L=new this['CANNON']['DistanceConstraint'](this['hiddenAnchor'],this['anchorBody'],0x0);this['world']['addConstraint'](L),this['constraints']['push'](L);var M=this['ANCHOR_SWING_ANGLE']*Math['PI']/0xb4,O=new this['CANNON']['ConeTwistConstraint'](this['hiddenAnchor'],this['anchorBody'],{'pivotA':new this['CANNON']['Vec3'](0x0,0x0,0x0),'pivotB':new this['CANNON']['Vec3'](0x0,0x0,0x0),'axisA':new this['CANNON']['Vec3'](0x0,0x1,0x0),'axisB':new this['CANNON']['Vec3'](0x0,0x1,0x0),'angle':M,'twistAngle':0.5*M});this['world']['addConstraint'](O),this['constraints']['push'](O);for(var P=this['meshes']['slice'](0x1),Q=this['anchorBody'],R=0x0;R<P['length'];R++){var S=P[R],T=R===P['length']-0x1,U=T?0x3*(null!==(E=this['config']['mass'])&&void 0x0!==E?E:0.05):(null!==(F=this['config']['mass'])&&void 0x0!==F?F:0.05)*(0x1+0.1*R),V=new this['CANNON']['Body']({'mass':U,'position':new this['CANNON']['Vec3'](S['position']['x'],S['position']['y'],S['position']['z']),'shape':new this['CANNON']['Sphere'](T?1.5*J:J),'linearDamping':null!==(G=this['config']['damping'])&&void 0x0!==G?G:0.5,'angularDamping':0.5*(null!==(H=this['config']['damping'])&&void 0x0!==H?H:0.5)});this['world']['addBody'](V),this['chainBodies']['push'](V);var W=0x0===R?this['meshes'][0x0]:P[R-0x1],X=S,Y=W['position'],Z=X['position'],a0=Math['sqrt'](Math['pow'](Z['x']-Y['x'],0x2)+Math['pow'](Z['y']-Y['y'],0x2)+Math['pow'](Z['z']-Y['z'],0x2));console['log']('约束距离\x20'['concat'](W['name']||'prev','\x20→\x20')['concat'](X['name']||'current',':\x20')['concat'](a0['toFixed'](0x6)));var a1=new this['CANNON']['DistanceConstraint'](Q,V,a0);this['world']['addConstraint'](a1),this['constraints']['push'](a1);var a2=(null!==(I=this['config']['swingAngle'])&&void 0x0!==I?I:0x2d)*Math['PI']/0xb4,a3=new this['CANNON']['ConeTwistConstraint'](Q,V,{'pivotA':new this['CANNON']['Vec3'](0x0,-a0/0x2,0x0),'pivotB':new this['CANNON']['Vec3'](0x0,a0/0x2,0x0),'axisA':new this['CANNON']['Vec3'](0x0,0x1,0x0),'axisB':new this['CANNON']['Vec3'](0x0,0x1,0x0),'angle':a2,'twistAngle':0x0});this['world']['addConstraint'](a3),this['constraints']['push'](a3),Q=V;}},u['prototype']['setGroupScale']=function(v){v>0x0&&(this['groupScale']=v);},u['prototype']['update']=function(v,w){var x=this;if(this['world']&&this['initialized']&&w){var y=this['groupScale']||0x1,z=w['x']/y,A=w['y']/y,B=w['z']/y;this['smoothedAnchorPosition']['x']+=0.3*(z-this['smoothedAnchorPosition']['x']),this['smoothedAnchorPosition']['y']+=0.3*(A-this['smoothedAnchorPosition']['y']),this['smoothedAnchorPosition']['z']+=0.3*(B-this['smoothedAnchorPosition']['z']);var C=this['smoothedAnchorPosition']['x']-this['lastAnchorPosition']['x'],D=this['smoothedAnchorPosition']['y']-this['lastAnchorPosition']['y'],E=this['smoothedAnchorPosition']['z']-this['lastAnchorPosition']['z'];this['hiddenAnchor']['position']['x']+=C,this['hiddenAnchor']['position']['y']+=D,this['hiddenAnchor']['position']['z']+=E,this['lastAnchorPosition']['x']=this['smoothedAnchorPosition']['x'],this['lastAnchorPosition']['y']=this['smoothedAnchorPosition']['y'],this['lastAnchorPosition']['z']=this['smoothedAnchorPosition']['z'],this['world']['step'](0x1/0x3c,v,0x3);var F=this['meshes'][0x0];F&&(F['position']['x']=this['anchorBody']['position']['x']-this['hiddenAnchor']['position']['x'],F['position']['y']=this['anchorBody']['position']['y']-this['hiddenAnchor']['position']['y'],F['position']['z']=this['anchorBody']['position']['z']-this['hiddenAnchor']['position']['z']),this['chainBodies']['forEach'](function(G,H){var I=x['meshes'][H+0x1];I&&(I['position']['x']=G['position']['x']-x['hiddenAnchor']['position']['x'],I['position']['y']=G['position']['y']-x['hiddenAnchor']['position']['y'],I['position']['z']=G['position']['z']-x['hiddenAnchor']['position']['z'],I['quaternion']['set'](G['quaternion']['x'],G['quaternion']['y'],G['quaternion']['z'],G['quaternion']['w']));});}},u['prototype']['setConfig']=function(v){if(this['config']=j(j({},this['config']),v),void 0x0!==v['gravity']&&this['world']){var w=v['gravity']*this['GRAVITY_SCALE'];this['world']['gravity']['set'](0x0,w,0x0);}void 0x0!==v['damping']&&this['chainBodies']['forEach'](function(x){var y;x['linearDamping']=v['damping'],x['angularDamping']=0.5*(null!==(y=v['damping'])&&void 0x0!==y?y:0.5);});},u['prototype']['destroy']=function(){var v,w,x=this;this['meshes']['forEach'](function(y,z){var A=x['originalTransforms'][z];y&&A&&(y['position']['x']=A['position']['x'],y['position']['y']=A['position']['y'],y['position']['z']=A['position']['z'],y['quaternion']['x']=A['quaternion']['x'],y['quaternion']['y']=A['quaternion']['y'],y['quaternion']['z']=A['quaternion']['z'],y['quaternion']['w']=A['quaternion']['w']);}),this['originalTransforms']=[],this['constraints']['forEach'](function(y){var z;return null===(z=x['world'])||void 0x0===z?void 0x0:z['removeConstraint'](y);}),this['constraints']=[],this['hiddenAnchor']&&(null===(v=this['world'])||void 0x0===v||v['removeBody'](this['hiddenAnchor']),this['hiddenAnchor']=null),this['anchorBody']&&(null===(w=this['world'])||void 0x0===w||w['removeBody'](this['anchorBody']),this['anchorBody']=null),this['chainBodies']['forEach'](function(y){var z;return null===(z=x['world'])||void 0x0===z?void 0x0:z['removeBody'](y);}),this['chainBodies']=[],this['meshes']=[],this['world']=null,this['CANNON']=null,this['initialized']=!0x1;},u;}());}}]);
1
+ (self['webpackChunktencentcloud_webar']=self['webpackChunktencentcloud_webar']||[])['push']([[0x316],{0xae6:(b,d,f)=>{f['r'](d),f['d'](d,{'PhysicsController':()=>q,'PhysicsModelParser':()=>g});var g=(function(){function u(v){this['CANNON']=v;}return u['prototype']['parse']=function(v){var w,x,y=this,z=[],A=new Map();return v['traverse'](function(B){if(B['name']){var C=B['name']['toLowerCase']();if(!/_\d+$/['test'](C)){if(y['isAnchor'](C))A['has']('anchor')||A['set']('anchor',[]),A['get']('anchor')['push'](B);else{if(y['isChain'](C)){var D=y['extractChainIndex'](C),E='chain-'['concat'](D);A['has'](E)||A['set'](E,[]),A['get'](E)['push'](B);}else y['isPendant'](C)&&(A['has']('pendant')||A['set']('pendant',[]),A['get']('pendant')['push'](B));}}}}),w=this['selectBestCandidate'](A['get']('anchor')),x=this['selectBestCandidate'](A['get']('pendant')),Array['from'](A['keys']())['filter'](function(B){return B['startsWith']('chain-');})['sort'](function(B,C){return parseInt(B['split']('-')[0x1])-parseInt(C['split']('-')[0x1]);})['forEach'](function(B){var C=y['selectBestCandidate'](A['get'](B));C&&z['push'](C);}),x&&!z['includes'](x)&&z['push'](x),{'anchorMesh':w,'chainMeshes':z,'pendantMesh':x};},u['prototype']['selectBestCandidate']=function(v){if(!v||0x0===v['length'])return null;var w=v['filter'](function(y){return'Group'===y['type'];});if(w['length']>0x0)return w[0x0];var x=v['filter'](function(y){return'Mesh'===y['type'];});return x['length']>0x0?x[0x0]:v[0x0];},u['prototype']['isAnchor']=function(v){return v['startsWith']('anchor');},u['prototype']['isChain']=function(v){return v['startsWith']('chain');},u['prototype']['isPendant']=function(v){return v['startsWith']('pendant');},u['prototype']['extractChainIndex']=function(v){var w=v['match'](/chain-(\d+)/);return w?parseInt(w[0x1])-0x1:0x0;},u;}()),j=function(){return j=Object['assign']||function(u){for(var v,w=0x1,x=arguments['length'];w<x;w++)for(var y in v=arguments[w])Object['prototype']['hasOwnProperty']['call'](v,y)&&(u[y]=v[y]);return u;},j['apply'](this,arguments);},k=function(u,v,w,x){return new(w||(w=Promise))(function(y,z){function A(D){try{C(x['next'](D));}catch(E){z(E);}}function B(D){try{C(x['throw'](D));}catch(E){z(E);}}function C(D){var E;D['done']?y(D['value']):(E=D['value'],E instanceof w?E:new w(function(F){F(E);}))['then'](A,B);}C((x=x['apply'](u,v||[]))['next']());});},l=function(u,v){var w,x,y,z,A={'label':0x0,'sent':function(){if(0x1&y[0x0])throw y[0x1];return y[0x1];},'trys':[],'ops':[]};return z={'next':B(0x0),'throw':B(0x1),'return':B(0x2)},'function'==typeof Symbol&&(z[Symbol['iterator']]=function(){return this;}),z;function B(C){return function(D){return function(E){if(w)throw new TypeError('Generator\x20is\x20already\x20executing.');for(;A;)try{if(w=0x1,x&&(y=0x2&E[0x0]?x['return']:E[0x0]?x['throw']||((y=x['return'])&&y['call'](x),0x0):x['next'])&&!(y=y['call'](x,E[0x1]))['done'])return y;switch(x=0x0,y&&(E=[0x2&E[0x0],y['value']]),E[0x0]){case 0x0:case 0x1:y=E;break;case 0x4:return A['label']++,{'value':E[0x1],'done':!0x1};case 0x5:A['label']++,x=E[0x1],E=[0x0];continue;case 0x7:E=A['ops']['pop'](),A['trys']['pop']();continue;default:if(!(y=A['trys'],(y=y['length']>0x0&&y[y['length']-0x1])||0x6!==E[0x0]&&0x2!==E[0x0])){A=0x0;continue;}if(0x3===E[0x0]&&(!y||E[0x1]>y[0x0]&&E[0x1]<y[0x3])){A['label']=E[0x1];break;}if(0x6===E[0x0]&&A['label']<y[0x1]){A['label']=y[0x1],y=E;break;}if(y&&A['label']<y[0x2]){A['label']=y[0x2],A['ops']['push'](E);break;}y[0x2]&&A['ops']['pop'](),A['trys']['pop']();continue;}E=v['call'](u,A);}catch(F){E=[0x6,F],x=0x0;}finally{w=y=0x0;}if(0x5&E[0x0])throw E[0x1];return{'value':E[0x0]?E[0x1]:void 0x0,'done':!0x0};}([C,D]);};}},m=function(u,v){var w='function'==typeof Symbol&&u[Symbol['iterator']];if(!w)return u;var x,y,z=w['call'](u),A=[];try{for(;(void 0x0===v||v-->0x0)&&!(x=z['next']())['done'];)A['push'](x['value']);}catch(B){y={'error':B};}finally{try{x&&!x['done']&&(w=z['return'])&&w['call'](z);}finally{if(y)throw y['error'];}}return A;},p=function(u,v,w){if(w||0x2===arguments['length']){for(var x,y=0x0,z=v['length'];y<z;y++)!x&&y in v||(x||(x=Array['prototype']['slice']['call'](v,0x0,y)),x[y]=v[y]);}return u['concat'](x||Array['prototype']['slice']['call'](v));},q=(function(){function u(v,w){void 0x0===v&&(v={}),this['chainBodies']=[],this['meshes']=[],this['constraints']=[],this['originalTransforms']=[],this['spacing']=1.2,this['ANCHOR_SWING_ANGLE']=0xf,this['initialized']=!0x1,this['groupScale']=0x1,this['lastAnchorPosition']={'x':0x0,'y':0x0,'z':0x0},this['smoothedAnchorPosition']={'x':0x0,'y':0x0,'z':0x0},this['GRAVITY_SCALE']=14.3,this['config']=j({'gravity':-9.8,'damping':0.8,'mass':0.05,'swingAngle':0x5},v),this['anchorPoint']=w||'';}return u['prototype']['init']=function(v){var w;return k(this,void 0x0,Promise,function(){var x,z,B,C,D,E,F,G,H,I,J,K;return l(this,function(L){switch(L['label']){case 0x0:return L['trys']['push']([0x0,0x2,,0x3]),x=this,[0x4,f['e'](0x21d)['then'](f['bind'](f,0x96f))];case 0x1:return x['CANNON']=L['sent'](),z=(null!==(w=this['config']['gravity'])&&void 0x0!==w?w:-9.8)*this['GRAVITY_SCALE'],this['world']=new this['CANNON']['World']({'gravity':new this['CANNON']['Vec3'](0x0,z,0x0)}),this['world']['solver']['iterations']=0x14,B=new g(this['CANNON']),C=B['parse'](v),D=C['anchorMesh'],E=C['chainMeshes'],F=C['pendantMesh'],D&&0x0!==E['length']?(E['length']>=0x1&&(G=D['position'],H=E[0x0]['position'],I=H['x']-G['x'],J=H['y']-G['y'],K=H['z']-G['z'],this['spacing']=Math['sqrt'](I*I+J*J+K*K)),this['meshes']=p([D],m(E),!0x1),F&&!E['includes'](F)&&this['meshes']['push'](F),this['originalTransforms']=this['meshes']['map'](function(M){return{'position':{'x':M['position']['x'],'y':M['position']['y'],'z':M['position']['z']},'quaternion':{'x':M['quaternion']['x'],'y':M['quaternion']['y'],'z':M['quaternion']['z'],'w':M['quaternion']['w']}};}),this['createPhysicsBodies'](),this['initialized']=!0x0,[0x3,0x3]):[0x2];case 0x2:throw L['sent']();case 0x3:return[0x2];}});});},u['prototype']['createPhysicsBodies']=function(){var z,D,E,F,G,H,I=0.3*this['spacing'];this['hiddenAnchor']=new this['CANNON']['Body']({'mass':0x0,'type':this['CANNON']['Body']['KINEMATIC'],'position':new this['CANNON']['Vec3'](0x0,0x0,0x0),'shape':new this['CANNON']['Sphere'](0.5*I)}),this['world']['addBody'](this['hiddenAnchor']);var J=this['meshes'][0x0];this['anchorBody']=new this['CANNON']['Body']({'mass':0.5*(null!==(z=this['config']['mass'])&&void 0x0!==z?z:0.05),'position':new this['CANNON']['Vec3']((null==J?void 0x0:J['position']['x'])||0x0,(null==J?void 0x0:J['position']['y'])||0x0,(null==J?void 0x0:J['position']['z'])||0x0),'shape':new this['CANNON']['Sphere'](I),'linearDamping':0.8,'angularDamping':0.8}),this['world']['addBody'](this['anchorBody']);var K=new this['CANNON']['DistanceConstraint'](this['hiddenAnchor'],this['anchorBody'],0x0);this['world']['addConstraint'](K),this['constraints']['push'](K);var L=this['ANCHOR_SWING_ANGLE']*Math['PI']/0xb4,M=new this['CANNON']['ConeTwistConstraint'](this['hiddenAnchor'],this['anchorBody'],{'pivotA':new this['CANNON']['Vec3'](0x0,0x0,0x0),'pivotB':new this['CANNON']['Vec3'](0x0,0x0,0x0),'axisA':new this['CANNON']['Vec3'](0x0,0x1,0x0),'axisB':new this['CANNON']['Vec3'](0x0,0x1,0x0),'angle':L,'twistAngle':0.5*L});this['world']['addConstraint'](M),this['constraints']['push'](M);for(var O=this['meshes']['slice'](0x1),P=this['anchorBody'],Q=0x0;Q<O['length'];Q++){var R=O[Q],S=Q===O['length']-0x1,T=S?0x3*(null!==(D=this['config']['mass'])&&void 0x0!==D?D:0.05):(null!==(E=this['config']['mass'])&&void 0x0!==E?E:0.05)*(0x1+0.1*Q),U=new this['CANNON']['Body']({'mass':T,'position':new this['CANNON']['Vec3'](R['position']['x'],R['position']['y'],R['position']['z']),'shape':new this['CANNON']['Sphere'](S?1.5*I:I),'linearDamping':null!==(F=this['config']['damping'])&&void 0x0!==F?F:0.5,'angularDamping':0.5*(null!==(G=this['config']['damping'])&&void 0x0!==G?G:0.5)});this['world']['addBody'](U),this['chainBodies']['push'](U);var V=R,W=(0x0===Q?this['meshes'][0x0]:O[Q-0x1])['position'],X=V['position'],Y=Math['sqrt'](Math['pow'](X['x']-W['x'],0x2)+Math['pow'](X['y']-W['y'],0x2)+Math['pow'](X['z']-W['z'],0x2)),Z=new this['CANNON']['DistanceConstraint'](P,U,Y);this['world']['addConstraint'](Z),this['constraints']['push'](Z);var a0=(null!==(H=this['config']['swingAngle'])&&void 0x0!==H?H:0x2d)*Math['PI']/0xb4,a1=new this['CANNON']['ConeTwistConstraint'](P,U,{'pivotA':new this['CANNON']['Vec3'](0x0,-Y/0x2,0x0),'pivotB':new this['CANNON']['Vec3'](0x0,Y/0x2,0x0),'axisA':new this['CANNON']['Vec3'](0x0,0x1,0x0),'axisB':new this['CANNON']['Vec3'](0x0,0x1,0x0),'angle':a0,'twistAngle':0x0});this['world']['addConstraint'](a1),this['constraints']['push'](a1),P=U;}},u['prototype']['setGroupScale']=function(v){v>0x0&&(this['groupScale']=v);},u['prototype']['update']=function(v,w){var x=this;if(this['world']&&this['initialized']&&w){var y=this['groupScale']||0x1,z=w['x']/y,A=w['y']/y,B=w['z']/y;this['smoothedAnchorPosition']['x']+=0.3*(z-this['smoothedAnchorPosition']['x']),this['smoothedAnchorPosition']['y']+=0.3*(A-this['smoothedAnchorPosition']['y']),this['smoothedAnchorPosition']['z']+=0.3*(B-this['smoothedAnchorPosition']['z']);var C=this['smoothedAnchorPosition']['x']-this['lastAnchorPosition']['x'],D=this['smoothedAnchorPosition']['y']-this['lastAnchorPosition']['y'],E=this['smoothedAnchorPosition']['z']-this['lastAnchorPosition']['z'];this['hiddenAnchor']['position']['x']+=C,this['hiddenAnchor']['position']['y']+=D,this['hiddenAnchor']['position']['z']+=E,this['lastAnchorPosition']['x']=this['smoothedAnchorPosition']['x'],this['lastAnchorPosition']['y']=this['smoothedAnchorPosition']['y'],this['lastAnchorPosition']['z']=this['smoothedAnchorPosition']['z'],this['world']['step'](0x1/0x3c,v,0x3);var F=this['meshes'][0x0];F&&(F['position']['x']=this['anchorBody']['position']['x']-this['hiddenAnchor']['position']['x'],F['position']['y']=this['anchorBody']['position']['y']-this['hiddenAnchor']['position']['y'],F['position']['z']=this['anchorBody']['position']['z']-this['hiddenAnchor']['position']['z']),this['chainBodies']['forEach'](function(G,H){var I=x['meshes'][H+0x1];I&&(I['position']['x']=G['position']['x']-x['hiddenAnchor']['position']['x'],I['position']['y']=G['position']['y']-x['hiddenAnchor']['position']['y'],I['position']['z']=G['position']['z']-x['hiddenAnchor']['position']['z'],I['quaternion']['set'](G['quaternion']['x'],G['quaternion']['y'],G['quaternion']['z'],G['quaternion']['w']));});}},u['prototype']['setConfig']=function(v){if(this['config']=j(j({},this['config']),v),void 0x0!==v['gravity']&&this['world']){var w=v['gravity']*this['GRAVITY_SCALE'];this['world']['gravity']['set'](0x0,w,0x0);}void 0x0!==v['damping']&&this['chainBodies']['forEach'](function(x){var y;x['linearDamping']=v['damping'],x['angularDamping']=0.5*(null!==(y=v['damping'])&&void 0x0!==y?y:0.5);});},u['prototype']['destroy']=function(){var v,w,x=this;this['meshes']['forEach'](function(y,z){var A=x['originalTransforms'][z];y&&A&&(y['position']['x']=A['position']['x'],y['position']['y']=A['position']['y'],y['position']['z']=A['position']['z'],y['quaternion']['x']=A['quaternion']['x'],y['quaternion']['y']=A['quaternion']['y'],y['quaternion']['z']=A['quaternion']['z'],y['quaternion']['w']=A['quaternion']['w']);}),this['originalTransforms']=[],this['constraints']['forEach'](function(y){var z;return null===(z=x['world'])||void 0x0===z?void 0x0:z['removeConstraint'](y);}),this['constraints']=[],this['hiddenAnchor']&&(null===(v=this['world'])||void 0x0===v||v['removeBody'](this['hiddenAnchor']),this['hiddenAnchor']=null),this['anchorBody']&&(null===(w=this['world'])||void 0x0===w||w['removeBody'](this['anchorBody']),this['anchorBody']=null),this['chainBodies']['forEach'](function(y){var z;return null===(z=x['world'])||void 0x0===z?void 0x0:z['removeBody'](y);}),this['chainBodies']=[],this['meshes']=[],this['world']=null,this['CANNON']=null,this['initialized']=!0x1;},u;}());}}]);
@@ -1 +1 @@
1
- (self['webpackChunktencentcloud_webar']=self['webpackChunktencentcloud_webar']||[])['push']([[0x316],{0xae6:(b,d,f)=>{f['r'](d),f['d'](d,{'PhysicsController':()=>q,'PhysicsModelParser':()=>g});var g=(function(){function u(v){this['CANNON']=v;}return u['prototype']['parse']=function(v){var w,x,y=this,z=[],A=new Map();return v['traverse'](function(B){if(B['name']){var C=B['name']['toLowerCase']();if(console['log']('解析节点:\x20\x22'['concat'](B['name'],'\x22,\x20类型:\x20')['concat'](B['type'],',\x20位置:'),B['position']),/_\d+$/['test'](C))console['log']('\x20\x20->\x20跳过拆分子节点:\x20'['concat'](B['name']));else{if(y['isAnchor'](C))A['has']('anchor')||A['set']('anchor',[]),A['get']('anchor')['push'](B);else{if(y['isChain'](C)){var D=y['extractChainIndex'](C),E='chain-'['concat'](D);A['has'](E)||A['set'](E,[]),A['get'](E)['push'](B);}else y['isPendant'](C)&&(A['has']('pendant')||A['set']('pendant',[]),A['get']('pendant')['push'](B));}}}}),w=this['selectBestCandidate'](A['get']('anchor')),x=this['selectBestCandidate'](A['get']('pendant')),Array['from'](A['keys']())['filter'](function(B){return B['startsWith']('chain-');})['sort'](function(B,C){return parseInt(B['split']('-')[0x1])-parseInt(C['split']('-')[0x1]);})['forEach'](function(B){var C=y['selectBestCandidate'](A['get'](B));C&&z['push'](C);}),x&&!z['includes'](x)&&z['push'](x),console['log']('解析结果:',{'anchor':null==w?void 0x0:w['name'],'chains':z['map'](function(B){return B['name'];}),'pendant':null==x?void 0x0:x['name']}),{'anchorMesh':w,'chainMeshes':z,'pendantMesh':x};},u['prototype']['selectBestCandidate']=function(v){if(!v||0x0===v['length'])return null;var w=v['filter'](function(y){return'Group'===y['type'];});if(w['length']>0x0)return console['log']('\x20\x20->\x20选择\x20Group:\x20'['concat'](w[0x0]['name'])),w[0x0];var x=v['filter'](function(y){return'Mesh'===y['type'];});return x['length']>0x0?(console['log']('\x20\x20->\x20选择\x20Mesh:\x20'['concat'](x[0x0]['name'])),x[0x0]):(console['log']('\x20\x20->\x20选择默认:\x20'['concat'](v[0x0]['name'])),v[0x0]);},u['prototype']['isAnchor']=function(v){return v['startsWith']('anchor');},u['prototype']['isChain']=function(v){return v['startsWith']('chain');},u['prototype']['isPendant']=function(v){return v['startsWith']('pendant');},u['prototype']['extractChainIndex']=function(v){var w=v['match'](/chain-(\d+)/);return w?parseInt(w[0x1])-0x1:0x0;},u;}()),j=function(){return j=Object['assign']||function(u){for(var v,w=0x1,x=arguments['length'];w<x;w++)for(var y in v=arguments[w])Object['prototype']['hasOwnProperty']['call'](v,y)&&(u[y]=v[y]);return u;},j['apply'](this,arguments);},k=function(u,v,w,x){return new(w||(w=Promise))(function(y,z){function A(D){try{C(x['next'](D));}catch(E){z(E);}}function B(D){try{C(x['throw'](D));}catch(E){z(E);}}function C(D){var E;D['done']?y(D['value']):(E=D['value'],E instanceof w?E:new w(function(F){F(E);}))['then'](A,B);}C((x=x['apply'](u,v||[]))['next']());});},l=function(u,v){var w,x,y,z,A={'label':0x0,'sent':function(){if(0x1&y[0x0])throw y[0x1];return y[0x1];},'trys':[],'ops':[]};return z={'next':B(0x0),'throw':B(0x1),'return':B(0x2)},'function'==typeof Symbol&&(z[Symbol['iterator']]=function(){return this;}),z;function B(C){return function(D){return function(E){if(w)throw new TypeError('Generator\x20is\x20already\x20executing.');for(;A;)try{if(w=0x1,x&&(y=0x2&E[0x0]?x['return']:E[0x0]?x['throw']||((y=x['return'])&&y['call'](x),0x0):x['next'])&&!(y=y['call'](x,E[0x1]))['done'])return y;switch(x=0x0,y&&(E=[0x2&E[0x0],y['value']]),E[0x0]){case 0x0:case 0x1:y=E;break;case 0x4:return A['label']++,{'value':E[0x1],'done':!0x1};case 0x5:A['label']++,x=E[0x1],E=[0x0];continue;case 0x7:E=A['ops']['pop'](),A['trys']['pop']();continue;default:if(!(y=A['trys'],(y=y['length']>0x0&&y[y['length']-0x1])||0x6!==E[0x0]&&0x2!==E[0x0])){A=0x0;continue;}if(0x3===E[0x0]&&(!y||E[0x1]>y[0x0]&&E[0x1]<y[0x3])){A['label']=E[0x1];break;}if(0x6===E[0x0]&&A['label']<y[0x1]){A['label']=y[0x1],y=E;break;}if(y&&A['label']<y[0x2]){A['label']=y[0x2],A['ops']['push'](E);break;}y[0x2]&&A['ops']['pop'](),A['trys']['pop']();continue;}E=v['call'](u,A);}catch(F){E=[0x6,F],x=0x0;}finally{w=y=0x0;}if(0x5&E[0x0])throw E[0x1];return{'value':E[0x0]?E[0x1]:void 0x0,'done':!0x0};}([C,D]);};}},m=function(u,v){var w='function'==typeof Symbol&&u[Symbol['iterator']];if(!w)return u;var x,y,z=w['call'](u),A=[];try{for(;(void 0x0===v||v-->0x0)&&!(x=z['next']())['done'];)A['push'](x['value']);}catch(B){y={'error':B};}finally{try{x&&!x['done']&&(w=z['return'])&&w['call'](z);}finally{if(y)throw y['error'];}}return A;},p=function(u,v,w){if(w||0x2===arguments['length']){for(var x,y=0x0,z=v['length'];y<z;y++)!x&&y in v||(x||(x=Array['prototype']['slice']['call'](v,0x0,y)),x[y]=v[y]);}return u['concat'](x||Array['prototype']['slice']['call'](v));},q=(function(){function u(v,w){void 0x0===v&&(v={}),this['chainBodies']=[],this['meshes']=[],this['constraints']=[],this['originalTransforms']=[],this['spacing']=1.2,this['ANCHOR_SWING_ANGLE']=0xf,this['initialized']=!0x1,this['groupScale']=0x1,this['lastAnchorPosition']={'x':0x0,'y':0x0,'z':0x0},this['smoothedAnchorPosition']={'x':0x0,'y':0x0,'z':0x0},this['GRAVITY_SCALE']=14.3,this['config']=j({'gravity':-9.8,'damping':0.8,'mass':0.05,'swingAngle':0x5},v),this['anchorPoint']=w||'';}return u['prototype']['init']=function(v){var w;return k(this,void 0x0,Promise,function(){var x,z,B,C,D,E,F,G,H,I,J,K,L,M,O;return l(this,function(P){switch(P['label']){case 0x0:return P['trys']['push']([0x0,0x2,,0x3]),x=this,[0x4,f['e'](0x21d)['then'](f['bind'](f,0x96f))];case 0x1:return x['CANNON']=P['sent'](),z=(null!==(w=this['config']['gravity'])&&void 0x0!==w?w:-9.8)*this['GRAVITY_SCALE'],this['world']=new this['CANNON']['World']({'gravity':new this['CANNON']['Vec3'](0x0,z,0x0)}),this['world']['solver']['iterations']=0x14,console['log']('PhysicsController:\x20cannon-es\x20加载成功'),B=new g(this['CANNON']),C=B['parse'](v),D=C['anchorMesh'],E=C['chainMeshes'],F=C['pendantMesh'],D&&0x0!==E['length']?(E['length']>=0x1&&(G=D['position'],H=E[0x0]['position'],console['log']('===\x20间距计算详情\x20==='),console['log']('锚点\x20\x22'['concat'](D['name']||'anchor','\x22\x20位置:'),{'x':G['x']['toFixed'](0x6),'y':G['y']['toFixed'](0x6),'z':G['z']['toFixed'](0x6)}),console['log']('第一个链节\x20\x22'['concat'](E[0x0]['name']||'chain_1','\x22\x20位置:'),{'x':H['x']['toFixed'](0x6),'y':H['y']['toFixed'](0x6),'z':H['z']['toFixed'](0x6)}),I=H['x']-G['x'],J=H['y']-G['y'],K=H['z']-G['z'],console['log']('位置差值:',{'deltaX':I['toFixed'](0x6),'deltaY':J['toFixed'](0x6),'deltaZ':K['toFixed'](0x6)}),this['spacing']=Math['sqrt'](I*I+J*J+K*K),console['log']('计算过程:'),console['log']('\x20\x20√('['concat'](I['toFixed'](0x6),'²\x20+\x20')['concat'](J['toFixed'](0x6),'²\x20+\x20')['concat'](K['toFixed'](0x6),'²)')),console['log']('\x20\x20=\x20√('['concat']((I*I)['toFixed'](0x6),'\x20+\x20')['concat']((J*J)['toFixed'](0x6),'\x20+\x20')['concat']((K*K)['toFixed'](0x6),')')),console['log']('\x20\x20=\x20√'['concat']((I*I+J*J+K*K)['toFixed'](0x6))),console['log']('\x20\x20=\x20'['concat'](this['spacing']['toFixed'](0x6))),console['log']('===\x20所有链节间距离\x20==='),L=G,M=D['name']||'anchor',E['forEach'](function(Q,R){var S=Q['position'],T=Q['name']||'chain_'['concat'](R+0x1),U=Math['sqrt'](Math['pow'](S['x']-L['x'],0x2)+Math['pow'](S['y']-L['y'],0x2)+Math['pow'](S['z']-L['z'],0x2));console['log'](''['concat'](M,'\x20→\x20')['concat'](T,':\x20')['concat'](U['toFixed'](0x6))),L=S,M=T;})),console['log']('PhysicsController:\x20模型间距\x20=',this['spacing'],'m'),this['meshes']=p([D],m(E),!0x1),F&&!E['includes'](F)&&this['meshes']['push'](F),this['originalTransforms']=this['meshes']['map'](function(Q){return{'position':{'x':Q['position']['x'],'y':Q['position']['y'],'z':Q['position']['z']},'quaternion':{'x':Q['quaternion']['x'],'y':Q['quaternion']['y'],'z':Q['quaternion']['z'],'w':Q['quaternion']['w']}};}),this['createPhysicsBodies'](),this['initialized']=!0x0,console['log']('PhysicsController:\x20初始化完成,'['concat'](this['chainBodies']['length'],'\x20个链节')),[0x3,0x3]):(console['warn']('PhysicsController:\x20未找到锚点或链节'),[0x2]);case 0x2:throw O=P['sent'](),console['error']('PhysicsController:\x20初始化失败',O),O;case 0x3:return[0x2];}});});},u['prototype']['createPhysicsBodies']=function(){var D,E,F,G,H,I,J=0.3*this['spacing'];this['hiddenAnchor']=new this['CANNON']['Body']({'mass':0x0,'type':this['CANNON']['Body']['KINEMATIC'],'position':new this['CANNON']['Vec3'](0x0,0x0,0x0),'shape':new this['CANNON']['Sphere'](0.5*J)}),this['world']['addBody'](this['hiddenAnchor']);var K=this['meshes'][0x0];this['anchorBody']=new this['CANNON']['Body']({'mass':0.5*(null!==(D=this['config']['mass'])&&void 0x0!==D?D:0.05),'position':new this['CANNON']['Vec3']((null==K?void 0x0:K['position']['x'])||0x0,(null==K?void 0x0:K['position']['y'])||0x0,(null==K?void 0x0:K['position']['z'])||0x0),'shape':new this['CANNON']['Sphere'](J),'linearDamping':0.8,'angularDamping':0.8}),this['world']['addBody'](this['anchorBody']);var L=new this['CANNON']['DistanceConstraint'](this['hiddenAnchor'],this['anchorBody'],0x0);this['world']['addConstraint'](L),this['constraints']['push'](L);var M=this['ANCHOR_SWING_ANGLE']*Math['PI']/0xb4,O=new this['CANNON']['ConeTwistConstraint'](this['hiddenAnchor'],this['anchorBody'],{'pivotA':new this['CANNON']['Vec3'](0x0,0x0,0x0),'pivotB':new this['CANNON']['Vec3'](0x0,0x0,0x0),'axisA':new this['CANNON']['Vec3'](0x0,0x1,0x0),'axisB':new this['CANNON']['Vec3'](0x0,0x1,0x0),'angle':M,'twistAngle':0.5*M});this['world']['addConstraint'](O),this['constraints']['push'](O);for(var P=this['meshes']['slice'](0x1),Q=this['anchorBody'],R=0x0;R<P['length'];R++){var S=P[R],T=R===P['length']-0x1,U=T?0x3*(null!==(E=this['config']['mass'])&&void 0x0!==E?E:0.05):(null!==(F=this['config']['mass'])&&void 0x0!==F?F:0.05)*(0x1+0.1*R),V=new this['CANNON']['Body']({'mass':U,'position':new this['CANNON']['Vec3'](S['position']['x'],S['position']['y'],S['position']['z']),'shape':new this['CANNON']['Sphere'](T?1.5*J:J),'linearDamping':null!==(G=this['config']['damping'])&&void 0x0!==G?G:0.5,'angularDamping':0.5*(null!==(H=this['config']['damping'])&&void 0x0!==H?H:0.5)});this['world']['addBody'](V),this['chainBodies']['push'](V);var W=0x0===R?this['meshes'][0x0]:P[R-0x1],X=S,Y=W['position'],Z=X['position'],a0=Math['sqrt'](Math['pow'](Z['x']-Y['x'],0x2)+Math['pow'](Z['y']-Y['y'],0x2)+Math['pow'](Z['z']-Y['z'],0x2));console['log']('约束距离\x20'['concat'](W['name']||'prev','\x20→\x20')['concat'](X['name']||'current',':\x20')['concat'](a0['toFixed'](0x6)));var a1=new this['CANNON']['DistanceConstraint'](Q,V,a0);this['world']['addConstraint'](a1),this['constraints']['push'](a1);var a2=(null!==(I=this['config']['swingAngle'])&&void 0x0!==I?I:0x2d)*Math['PI']/0xb4,a3=new this['CANNON']['ConeTwistConstraint'](Q,V,{'pivotA':new this['CANNON']['Vec3'](0x0,-a0/0x2,0x0),'pivotB':new this['CANNON']['Vec3'](0x0,a0/0x2,0x0),'axisA':new this['CANNON']['Vec3'](0x0,0x1,0x0),'axisB':new this['CANNON']['Vec3'](0x0,0x1,0x0),'angle':a2,'twistAngle':0x0});this['world']['addConstraint'](a3),this['constraints']['push'](a3),Q=V;}},u['prototype']['setGroupScale']=function(v){v>0x0&&(this['groupScale']=v);},u['prototype']['update']=function(v,w){var x=this;if(this['world']&&this['initialized']&&w){var y=this['groupScale']||0x1,z=w['x']/y,A=w['y']/y,B=w['z']/y;this['smoothedAnchorPosition']['x']+=0.3*(z-this['smoothedAnchorPosition']['x']),this['smoothedAnchorPosition']['y']+=0.3*(A-this['smoothedAnchorPosition']['y']),this['smoothedAnchorPosition']['z']+=0.3*(B-this['smoothedAnchorPosition']['z']);var C=this['smoothedAnchorPosition']['x']-this['lastAnchorPosition']['x'],D=this['smoothedAnchorPosition']['y']-this['lastAnchorPosition']['y'],E=this['smoothedAnchorPosition']['z']-this['lastAnchorPosition']['z'];this['hiddenAnchor']['position']['x']+=C,this['hiddenAnchor']['position']['y']+=D,this['hiddenAnchor']['position']['z']+=E,this['lastAnchorPosition']['x']=this['smoothedAnchorPosition']['x'],this['lastAnchorPosition']['y']=this['smoothedAnchorPosition']['y'],this['lastAnchorPosition']['z']=this['smoothedAnchorPosition']['z'],this['world']['step'](0x1/0x3c,v,0x3);var F=this['meshes'][0x0];F&&(F['position']['x']=this['anchorBody']['position']['x']-this['hiddenAnchor']['position']['x'],F['position']['y']=this['anchorBody']['position']['y']-this['hiddenAnchor']['position']['y'],F['position']['z']=this['anchorBody']['position']['z']-this['hiddenAnchor']['position']['z']),this['chainBodies']['forEach'](function(G,H){var I=x['meshes'][H+0x1];I&&(I['position']['x']=G['position']['x']-x['hiddenAnchor']['position']['x'],I['position']['y']=G['position']['y']-x['hiddenAnchor']['position']['y'],I['position']['z']=G['position']['z']-x['hiddenAnchor']['position']['z'],I['quaternion']['set'](G['quaternion']['x'],G['quaternion']['y'],G['quaternion']['z'],G['quaternion']['w']));});}},u['prototype']['setConfig']=function(v){if(this['config']=j(j({},this['config']),v),void 0x0!==v['gravity']&&this['world']){var w=v['gravity']*this['GRAVITY_SCALE'];this['world']['gravity']['set'](0x0,w,0x0);}void 0x0!==v['damping']&&this['chainBodies']['forEach'](function(x){var y;x['linearDamping']=v['damping'],x['angularDamping']=0.5*(null!==(y=v['damping'])&&void 0x0!==y?y:0.5);});},u['prototype']['destroy']=function(){var v,w,x=this;this['meshes']['forEach'](function(y,z){var A=x['originalTransforms'][z];y&&A&&(y['position']['x']=A['position']['x'],y['position']['y']=A['position']['y'],y['position']['z']=A['position']['z'],y['quaternion']['x']=A['quaternion']['x'],y['quaternion']['y']=A['quaternion']['y'],y['quaternion']['z']=A['quaternion']['z'],y['quaternion']['w']=A['quaternion']['w']);}),this['originalTransforms']=[],this['constraints']['forEach'](function(y){var z;return null===(z=x['world'])||void 0x0===z?void 0x0:z['removeConstraint'](y);}),this['constraints']=[],this['hiddenAnchor']&&(null===(v=this['world'])||void 0x0===v||v['removeBody'](this['hiddenAnchor']),this['hiddenAnchor']=null),this['anchorBody']&&(null===(w=this['world'])||void 0x0===w||w['removeBody'](this['anchorBody']),this['anchorBody']=null),this['chainBodies']['forEach'](function(y){var z;return null===(z=x['world'])||void 0x0===z?void 0x0:z['removeBody'](y);}),this['chainBodies']=[],this['meshes']=[],this['world']=null,this['CANNON']=null,this['initialized']=!0x1;},u;}());}}]);
1
+ (self['webpackChunktencentcloud_webar']=self['webpackChunktencentcloud_webar']||[])['push']([[0x316],{0xae6:(b,d,f)=>{f['r'](d),f['d'](d,{'PhysicsController':()=>q,'PhysicsModelParser':()=>g});var g=(function(){function u(v){this['CANNON']=v;}return u['prototype']['parse']=function(v){var w,x,y=this,z=[],A=new Map();return v['traverse'](function(B){if(B['name']){var C=B['name']['toLowerCase']();if(!/_\d+$/['test'](C)){if(y['isAnchor'](C))A['has']('anchor')||A['set']('anchor',[]),A['get']('anchor')['push'](B);else{if(y['isChain'](C)){var D=y['extractChainIndex'](C),E='chain-'['concat'](D);A['has'](E)||A['set'](E,[]),A['get'](E)['push'](B);}else y['isPendant'](C)&&(A['has']('pendant')||A['set']('pendant',[]),A['get']('pendant')['push'](B));}}}}),w=this['selectBestCandidate'](A['get']('anchor')),x=this['selectBestCandidate'](A['get']('pendant')),Array['from'](A['keys']())['filter'](function(B){return B['startsWith']('chain-');})['sort'](function(B,C){return parseInt(B['split']('-')[0x1])-parseInt(C['split']('-')[0x1]);})['forEach'](function(B){var C=y['selectBestCandidate'](A['get'](B));C&&z['push'](C);}),x&&!z['includes'](x)&&z['push'](x),{'anchorMesh':w,'chainMeshes':z,'pendantMesh':x};},u['prototype']['selectBestCandidate']=function(v){if(!v||0x0===v['length'])return null;var w=v['filter'](function(y){return'Group'===y['type'];});if(w['length']>0x0)return w[0x0];var x=v['filter'](function(y){return'Mesh'===y['type'];});return x['length']>0x0?x[0x0]:v[0x0];},u['prototype']['isAnchor']=function(v){return v['startsWith']('anchor');},u['prototype']['isChain']=function(v){return v['startsWith']('chain');},u['prototype']['isPendant']=function(v){return v['startsWith']('pendant');},u['prototype']['extractChainIndex']=function(v){var w=v['match'](/chain-(\d+)/);return w?parseInt(w[0x1])-0x1:0x0;},u;}()),j=function(){return j=Object['assign']||function(u){for(var v,w=0x1,x=arguments['length'];w<x;w++)for(var y in v=arguments[w])Object['prototype']['hasOwnProperty']['call'](v,y)&&(u[y]=v[y]);return u;},j['apply'](this,arguments);},k=function(u,v,w,x){return new(w||(w=Promise))(function(y,z){function A(D){try{C(x['next'](D));}catch(E){z(E);}}function B(D){try{C(x['throw'](D));}catch(E){z(E);}}function C(D){var E;D['done']?y(D['value']):(E=D['value'],E instanceof w?E:new w(function(F){F(E);}))['then'](A,B);}C((x=x['apply'](u,v||[]))['next']());});},l=function(u,v){var w,x,y,z,A={'label':0x0,'sent':function(){if(0x1&y[0x0])throw y[0x1];return y[0x1];},'trys':[],'ops':[]};return z={'next':B(0x0),'throw':B(0x1),'return':B(0x2)},'function'==typeof Symbol&&(z[Symbol['iterator']]=function(){return this;}),z;function B(C){return function(D){return function(E){if(w)throw new TypeError('Generator\x20is\x20already\x20executing.');for(;A;)try{if(w=0x1,x&&(y=0x2&E[0x0]?x['return']:E[0x0]?x['throw']||((y=x['return'])&&y['call'](x),0x0):x['next'])&&!(y=y['call'](x,E[0x1]))['done'])return y;switch(x=0x0,y&&(E=[0x2&E[0x0],y['value']]),E[0x0]){case 0x0:case 0x1:y=E;break;case 0x4:return A['label']++,{'value':E[0x1],'done':!0x1};case 0x5:A['label']++,x=E[0x1],E=[0x0];continue;case 0x7:E=A['ops']['pop'](),A['trys']['pop']();continue;default:if(!(y=A['trys'],(y=y['length']>0x0&&y[y['length']-0x1])||0x6!==E[0x0]&&0x2!==E[0x0])){A=0x0;continue;}if(0x3===E[0x0]&&(!y||E[0x1]>y[0x0]&&E[0x1]<y[0x3])){A['label']=E[0x1];break;}if(0x6===E[0x0]&&A['label']<y[0x1]){A['label']=y[0x1],y=E;break;}if(y&&A['label']<y[0x2]){A['label']=y[0x2],A['ops']['push'](E);break;}y[0x2]&&A['ops']['pop'](),A['trys']['pop']();continue;}E=v['call'](u,A);}catch(F){E=[0x6,F],x=0x0;}finally{w=y=0x0;}if(0x5&E[0x0])throw E[0x1];return{'value':E[0x0]?E[0x1]:void 0x0,'done':!0x0};}([C,D]);};}},m=function(u,v){var w='function'==typeof Symbol&&u[Symbol['iterator']];if(!w)return u;var x,y,z=w['call'](u),A=[];try{for(;(void 0x0===v||v-->0x0)&&!(x=z['next']())['done'];)A['push'](x['value']);}catch(B){y={'error':B};}finally{try{x&&!x['done']&&(w=z['return'])&&w['call'](z);}finally{if(y)throw y['error'];}}return A;},p=function(u,v,w){if(w||0x2===arguments['length']){for(var x,y=0x0,z=v['length'];y<z;y++)!x&&y in v||(x||(x=Array['prototype']['slice']['call'](v,0x0,y)),x[y]=v[y]);}return u['concat'](x||Array['prototype']['slice']['call'](v));},q=(function(){function u(v,w){void 0x0===v&&(v={}),this['chainBodies']=[],this['meshes']=[],this['constraints']=[],this['originalTransforms']=[],this['spacing']=1.2,this['ANCHOR_SWING_ANGLE']=0xf,this['initialized']=!0x1,this['groupScale']=0x1,this['lastAnchorPosition']={'x':0x0,'y':0x0,'z':0x0},this['smoothedAnchorPosition']={'x':0x0,'y':0x0,'z':0x0},this['GRAVITY_SCALE']=14.3,this['config']=j({'gravity':-9.8,'damping':0.8,'mass':0.05,'swingAngle':0x5},v),this['anchorPoint']=w||'';}return u['prototype']['init']=function(v){var w;return k(this,void 0x0,Promise,function(){var x,z,B,C,D,E,F,G,H,I,J,K;return l(this,function(L){switch(L['label']){case 0x0:return L['trys']['push']([0x0,0x2,,0x3]),x=this,[0x4,f['e'](0x21d)['then'](f['bind'](f,0x96f))];case 0x1:return x['CANNON']=L['sent'](),z=(null!==(w=this['config']['gravity'])&&void 0x0!==w?w:-9.8)*this['GRAVITY_SCALE'],this['world']=new this['CANNON']['World']({'gravity':new this['CANNON']['Vec3'](0x0,z,0x0)}),this['world']['solver']['iterations']=0x14,B=new g(this['CANNON']),C=B['parse'](v),D=C['anchorMesh'],E=C['chainMeshes'],F=C['pendantMesh'],D&&0x0!==E['length']?(E['length']>=0x1&&(G=D['position'],H=E[0x0]['position'],I=H['x']-G['x'],J=H['y']-G['y'],K=H['z']-G['z'],this['spacing']=Math['sqrt'](I*I+J*J+K*K)),this['meshes']=p([D],m(E),!0x1),F&&!E['includes'](F)&&this['meshes']['push'](F),this['originalTransforms']=this['meshes']['map'](function(M){return{'position':{'x':M['position']['x'],'y':M['position']['y'],'z':M['position']['z']},'quaternion':{'x':M['quaternion']['x'],'y':M['quaternion']['y'],'z':M['quaternion']['z'],'w':M['quaternion']['w']}};}),this['createPhysicsBodies'](),this['initialized']=!0x0,[0x3,0x3]):[0x2];case 0x2:throw L['sent']();case 0x3:return[0x2];}});});},u['prototype']['createPhysicsBodies']=function(){var z,D,E,F,G,H,I=0.3*this['spacing'];this['hiddenAnchor']=new this['CANNON']['Body']({'mass':0x0,'type':this['CANNON']['Body']['KINEMATIC'],'position':new this['CANNON']['Vec3'](0x0,0x0,0x0),'shape':new this['CANNON']['Sphere'](0.5*I)}),this['world']['addBody'](this['hiddenAnchor']);var J=this['meshes'][0x0];this['anchorBody']=new this['CANNON']['Body']({'mass':0.5*(null!==(z=this['config']['mass'])&&void 0x0!==z?z:0.05),'position':new this['CANNON']['Vec3']((null==J?void 0x0:J['position']['x'])||0x0,(null==J?void 0x0:J['position']['y'])||0x0,(null==J?void 0x0:J['position']['z'])||0x0),'shape':new this['CANNON']['Sphere'](I),'linearDamping':0.8,'angularDamping':0.8}),this['world']['addBody'](this['anchorBody']);var K=new this['CANNON']['DistanceConstraint'](this['hiddenAnchor'],this['anchorBody'],0x0);this['world']['addConstraint'](K),this['constraints']['push'](K);var L=this['ANCHOR_SWING_ANGLE']*Math['PI']/0xb4,M=new this['CANNON']['ConeTwistConstraint'](this['hiddenAnchor'],this['anchorBody'],{'pivotA':new this['CANNON']['Vec3'](0x0,0x0,0x0),'pivotB':new this['CANNON']['Vec3'](0x0,0x0,0x0),'axisA':new this['CANNON']['Vec3'](0x0,0x1,0x0),'axisB':new this['CANNON']['Vec3'](0x0,0x1,0x0),'angle':L,'twistAngle':0.5*L});this['world']['addConstraint'](M),this['constraints']['push'](M);for(var O=this['meshes']['slice'](0x1),P=this['anchorBody'],Q=0x0;Q<O['length'];Q++){var R=O[Q],S=Q===O['length']-0x1,T=S?0x3*(null!==(D=this['config']['mass'])&&void 0x0!==D?D:0.05):(null!==(E=this['config']['mass'])&&void 0x0!==E?E:0.05)*(0x1+0.1*Q),U=new this['CANNON']['Body']({'mass':T,'position':new this['CANNON']['Vec3'](R['position']['x'],R['position']['y'],R['position']['z']),'shape':new this['CANNON']['Sphere'](S?1.5*I:I),'linearDamping':null!==(F=this['config']['damping'])&&void 0x0!==F?F:0.5,'angularDamping':0.5*(null!==(G=this['config']['damping'])&&void 0x0!==G?G:0.5)});this['world']['addBody'](U),this['chainBodies']['push'](U);var V=R,W=(0x0===Q?this['meshes'][0x0]:O[Q-0x1])['position'],X=V['position'],Y=Math['sqrt'](Math['pow'](X['x']-W['x'],0x2)+Math['pow'](X['y']-W['y'],0x2)+Math['pow'](X['z']-W['z'],0x2)),Z=new this['CANNON']['DistanceConstraint'](P,U,Y);this['world']['addConstraint'](Z),this['constraints']['push'](Z);var a0=(null!==(H=this['config']['swingAngle'])&&void 0x0!==H?H:0x2d)*Math['PI']/0xb4,a1=new this['CANNON']['ConeTwistConstraint'](P,U,{'pivotA':new this['CANNON']['Vec3'](0x0,-Y/0x2,0x0),'pivotB':new this['CANNON']['Vec3'](0x0,Y/0x2,0x0),'axisA':new this['CANNON']['Vec3'](0x0,0x1,0x0),'axisB':new this['CANNON']['Vec3'](0x0,0x1,0x0),'angle':a0,'twistAngle':0x0});this['world']['addConstraint'](a1),this['constraints']['push'](a1),P=U;}},u['prototype']['setGroupScale']=function(v){v>0x0&&(this['groupScale']=v);},u['prototype']['update']=function(v,w){var x=this;if(this['world']&&this['initialized']&&w){var y=this['groupScale']||0x1,z=w['x']/y,A=w['y']/y,B=w['z']/y;this['smoothedAnchorPosition']['x']+=0.3*(z-this['smoothedAnchorPosition']['x']),this['smoothedAnchorPosition']['y']+=0.3*(A-this['smoothedAnchorPosition']['y']),this['smoothedAnchorPosition']['z']+=0.3*(B-this['smoothedAnchorPosition']['z']);var C=this['smoothedAnchorPosition']['x']-this['lastAnchorPosition']['x'],D=this['smoothedAnchorPosition']['y']-this['lastAnchorPosition']['y'],E=this['smoothedAnchorPosition']['z']-this['lastAnchorPosition']['z'];this['hiddenAnchor']['position']['x']+=C,this['hiddenAnchor']['position']['y']+=D,this['hiddenAnchor']['position']['z']+=E,this['lastAnchorPosition']['x']=this['smoothedAnchorPosition']['x'],this['lastAnchorPosition']['y']=this['smoothedAnchorPosition']['y'],this['lastAnchorPosition']['z']=this['smoothedAnchorPosition']['z'],this['world']['step'](0x1/0x3c,v,0x3);var F=this['meshes'][0x0];F&&(F['position']['x']=this['anchorBody']['position']['x']-this['hiddenAnchor']['position']['x'],F['position']['y']=this['anchorBody']['position']['y']-this['hiddenAnchor']['position']['y'],F['position']['z']=this['anchorBody']['position']['z']-this['hiddenAnchor']['position']['z']),this['chainBodies']['forEach'](function(G,H){var I=x['meshes'][H+0x1];I&&(I['position']['x']=G['position']['x']-x['hiddenAnchor']['position']['x'],I['position']['y']=G['position']['y']-x['hiddenAnchor']['position']['y'],I['position']['z']=G['position']['z']-x['hiddenAnchor']['position']['z'],I['quaternion']['set'](G['quaternion']['x'],G['quaternion']['y'],G['quaternion']['z'],G['quaternion']['w']));});}},u['prototype']['setConfig']=function(v){if(this['config']=j(j({},this['config']),v),void 0x0!==v['gravity']&&this['world']){var w=v['gravity']*this['GRAVITY_SCALE'];this['world']['gravity']['set'](0x0,w,0x0);}void 0x0!==v['damping']&&this['chainBodies']['forEach'](function(x){var y;x['linearDamping']=v['damping'],x['angularDamping']=0.5*(null!==(y=v['damping'])&&void 0x0!==y?y:0.5);});},u['prototype']['destroy']=function(){var v,w,x=this;this['meshes']['forEach'](function(y,z){var A=x['originalTransforms'][z];y&&A&&(y['position']['x']=A['position']['x'],y['position']['y']=A['position']['y'],y['position']['z']=A['position']['z'],y['quaternion']['x']=A['quaternion']['x'],y['quaternion']['y']=A['quaternion']['y'],y['quaternion']['z']=A['quaternion']['z'],y['quaternion']['w']=A['quaternion']['w']);}),this['originalTransforms']=[],this['constraints']['forEach'](function(y){var z;return null===(z=x['world'])||void 0x0===z?void 0x0:z['removeConstraint'](y);}),this['constraints']=[],this['hiddenAnchor']&&(null===(v=this['world'])||void 0x0===v||v['removeBody'](this['hiddenAnchor']),this['hiddenAnchor']=null),this['anchorBody']&&(null===(w=this['world'])||void 0x0===w||w['removeBody'](this['anchorBody']),this['anchorBody']=null),this['chainBodies']['forEach'](function(y){var z;return null===(z=x['world'])||void 0x0===z?void 0x0:z['removeBody'](y);}),this['chainBodies']=[],this['meshes']=[],this['world']=null,this['CANNON']=null,this['initialized']=!0x1;},u;}());}}]);