unity_art_puzzle_playable_luna/5.5.0/engine/luna/physics2d-1.js

1 line
87 KiB
JavaScript
Raw Normal View History

2023-12-21 08:46:57 +00:00
"use strict";(self.webpackChunkluna=self.webpackChunkluna||[]).push([[8],{56:(t,e,i)=>{var n=i(1),o=i(0),s=i(42),r=i(3);const a=new o.j,l=new o.j,c=new o.j,h=new o.j,d=new o.j;function u(t){return a.copy(t),a.w<0&&a.negate(),2*Math.atan2(a.z,a.w)}function y(t,e){e.set(0,0,Math.sin(.5*t),Math.cos(.5*t))}function _(t,e,i){c.copy(t),c.w<0&&c.negate(),y(e,h),function(t,e){l.copy(t),l.w<0&&l.negate(),y(u(l),e)}(c,d),d.invert(),i.mul2(h,d),i.mul(c)}function p(t,e,i=1e-6){return Math.abs(t-e)<=i}let g=0,m=null,f=null,C=null;pc.waitForBox2D.then((t=>{m=t,f=new m.b2Vec2(0,0),C=new m.b2Vec2(0,0)}));class b extends n.k{constructor(t){super(),t=Object.assign({enabled:!0,simulated:!0,type:UnityEngine.RigidbodyType2D.Dynamic,collisionDetectionMode:UnityEngine.CollisionDetectionMode2D.Discrete,mass:1,constraints:0,useAutoMass:!1,gravityScale:1,angularDrag:.05,drag:0},t),this.id=g++,this._enabled=!!t.enabled,this._simulated=!!t.simulated,this._collisionDetectionMode=t.collisionDetectionMode,this._constraints=t.constraints||0,this._freezeRotation=!!(this._constraints&UnityEngine.RigidbodyConstraints2D.FreezeRotation),this._freezeX=!!(this._constraints&UnityEngine.RigidbodyConstraints2D.FreezePositionX),this._freezeY=!!(this._constraints&UnityEngine.RigidbodyConstraints2D.FreezePositionY),this._mass=t.mass,this._material=t.material||null,this._useFullKinematicContacts=!1;const e=new m.b2BodyDef;e.awake=this._enabled,e.type=t.type===UnityEngine.RigidbodyType2D.Dynamic?m.b2_dynamicBody:t.type===UnityEngine.RigidbodyType2D.Kinematic?m.b2_kinematicBody:m.b2_staticBody,e.bullet=this._collisionDetectionMode===UnityEngine.CollisionDetectionMode2D.Continuous,e.gravityScale=Number.isFinite(t.gravityScale)?t.gravityScale:1,e.angularDamping=t.angularDrag>=0?t.angularDrag:.05,e.linearDamping=t.drag>0?t.drag:0,e.fixedRotation=this._freezeRotation,e.fixedPositionX=this._freezeX,e.fixedPositionY=this._freezeY,e.enabled=this._simulated,e.autoMass=t.useAutoMass,this._body=this.world.CreateBody(e),m.destroy(e),this._body.SetComponentId(this.id),this.resetMassData(),this._worldTransformVersion=-1,this._cullingLayer=-1,this._lastSyncEntityPosition=new o.m(-1/0,-1/0,-1/0),this._lastSyncEntityRotation=new o.j(-1/0,-1/0,-1/0,-1/0),this._lastSyncEntityScale=new o.m(-1/0,-1/0,-1/0),this["__UnityEngine.Rigidbody2D"]=null,pc.markPhysics2dModuleAsUsed(),TESTS&&pc.hiddenShapeValidator.addObjectToValidationSet(this,"Rigidbody2DComponent")}get adapter(){return n.a.getApplication().systems.physics2D.adapter}get world(){return this.adapter._world}get body(){return this._body}get destroyed(){return this._destroyed}onEnable(){return!!super.onEnable()&&(this._simulated&&this.adapter.enableRigidbody(this),!0)}onDisable(){return!!super.onDisable()&&(this._simulated&&this.adapter.disableRigidbody(this),this.resetVelocity(),this.resetAngularVelocity(),!0)}onDestroy(){if(!super.onDestroy())return!1;this._destroyed=!0,this.onDisable();let t=this._body.GetJointList();for(;m.getPointer(t)!==m.getPointer(m.NULL);){const e=t.joint,i=this.adapter.getJointComponentForJoint(e);i?(this.adapter.unlinkJointAndJointComponent(e,i),i._joint=null,t=t.next):t=t.next}return this.world.DestroyBody(this._body),!0}syncLayers(){const t=this.entity;t.cullingLayer!==this._cullingLayer&&(this._cullingLayer=t.cullingLayer,this.body.SetUnityLayers(1<<t.cullingLayer),this.wakeUp())}addForce(t){this.body.GetType()===m.b2_dynamicBody&&(f.Set(t.x,t.y),this._body.ApplyForceToCenter(f,!0))}addImpulse(t){this.body.GetType()===m.b2_dynamicBody&&(f.Set(t.x,t.y),this._body.ApplyLinearImpulseToCenter(f,!0))}addForceAtPosition(t,e){this.body.GetType()===m.b2_dynamicBody&&(f.Set(t.x,t.y),C.Set(e.x,e.y),this._body.ApplyForce(f,C,!0))}addImpulseAtPosition(t,e){this.body.GetType()===m.b2_dynamicBody&&(f.Set(t.x,t.y),C.Set(e.x,e.y),this._body.ApplyLinearImpulse(f,C,!0))}addRelativeForce(t){this.body.GetType()===m.b2_dynamicBody&&(f.Set(t.x,t.y),this._body.ApplyForceToCenter(this.body.GetWorldVector(f),!0))}addRelativeImpulse(t){this.body.GetType()===m.b2_dynamicBody&&(f.Set(t.x,t.y),this._body.ApplyLinearImpulseToCenter