@galacean/engine-physics-lite 1.0.0-alpha.6 → 1.0.0-beta.0
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/dist/browser.js +1199 -1203
- package/dist/browser.min.js +1 -1
- package/dist/main.js +61 -65
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +32386 -2672
- package/dist/module.js +62 -66
- package/dist/module.js.map +1 -1
- package/package.json +10 -4
- package/types/LiteUpdateFlag.d.ts +0 -6
- package/types/StaticInterfaceImplement.d.ts +0 -5
package/dist/browser.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("@galacean/engine")):"function"==typeof define&&define.amd?define(["exports","@galacean/engine"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self)["@galacean/enginePhysicsLite"]={},t["@galacean/engine"])}(this,function(t,i){"use strict";function e(t,i){return(e=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t})(t,i)}function n(t,i){if("function"!=typeof i&&null!==i)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(i&&i.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),i&&e(t,i)}function s(t,i){for(var e=0;e<i.length;e++){var n=i[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function o(t,i,e){return i&&s(t.prototype,i),e&&s(t,e),t}function r(t,i){return null!=i&&"undefined"!=typeof Symbol&&i[Symbol.hasInstance]?!!i[Symbol.hasInstance](t):t instanceof i}var a,h,l,c,u=function(){function t(t){void 0===t&&(t=[]),this._flags=t,this.flag=!0,this._flags.push(this)}return t.prototype.destroy=function(){(function(t,i){var e=t.indexOf(i);if(!(e<0)){var n=t.length-1;e!==n&&(t[e]=t[n]),t.length--}})(this._flags,this),this._flags=null},t}(),d=function(){function t(){this._updateFlags=[]}var i=t.prototype;return i.register=function(){return new u(this._updateFlags)},i.distribute=function(){for(var t=this._updateFlags,i=t.length-1;i>=0;i--)t[i].flag=!0},t}(),_=function(){function t(){this._transform=new p,this._invModelMatrix=new i.Matrix,this._transform.owner=this,this._inverseWorldMatFlag=this._transform.registerWorldChangeFlag()}var e=t.prototype;return e.setRotation=function(t){console.log("Physics-lite don't support setRotation. Use Physics-PhysX instead!")},e.setPosition=function(t){this._transform.setPosition(t.x,t.y,t.z)},e.setContactOffset=function(t){console.log("Physics-lite don't support setContactOffset. Use Physics-PhysX instead!")},e.setMaterial=function(t){console.log("Physics-lite don't support setMaterial. Use Physics-PhysX instead!")},e.setUniqueID=function(t){this._id=t},e.setIsTrigger=function(t){console.log("Physics-lite don't support setIsTrigger. Use Physics-PhysX instead!")},e.destroy=function(){},e._updateHitResult=function(e,n,s,o,r){void 0===r&&(r=!1);var a=t._tempPoint;e.getPoint(n,a),r||i.Vector3.transformCoordinate(a,this._transform.worldMatrix,a);var h=i.Vector3.distance(o,a);h<s.distance&&(s.point.copyFrom(a),s.distance=h,s.shapeID=this._id)},e._getLocalRay=function(e){var n=this._getInvModelMatrix(),s=t._ray;return i.Vector3.transformCoordinate(e.origin,n,s.origin),i.Vector3.transformNormal(e.direction,n,s.direction),s.direction.normalize(),s},e._getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(i.Matrix.invert(this._transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},t}();_._ray=new i.Ray,_._tempPoint=new i.Vector3;var p=function(){function t(){this._position=new i.Vector3,this._rotation=new i.Vector3,this._rotationQuaternion=new i.Quaternion,this._scale=new i.Vector3(1,1,1),this._worldRotationQuaternion=new i.Quaternion,this._localMatrix=new i.Matrix,this._worldMatrix=new i.Matrix,this._updateFlagManager=new d,this._isParentDirty=!0,this._parentTransformCache=null,this._dirtyFlag=188}var e=t.prototype;return e.setPosition=function(t,i,e){this._position.set(t,i,e),this.position=this._position},e.setRotationQuaternion=function(t,i,e,n){this._rotationQuaternion.set(t,i,e,n),this.rotationQuaternion=this._rotationQuaternion},e.setScale=function(t,i,e){this._scale.set(t,i,e),this.scale=this._scale},e.registerWorldChangeFlag=function(){return this._updateFlagManager.register()},e._updateWorldPositionFlag=function(){if(!this._isContainDirtyFlags(132)&&(this._worldAssociatedChange(132),r(this._owner,f)))for(var t=this._owner._shapes,i=0,e=t.length;i<e;i++)t[i]._transform._updateWorldPositionFlag()},e._updateWorldRotationFlag=function(){if(!this._isContainDirtyFlags(152)&&(this._worldAssociatedChange(152),r(this._owner,f)))for(var t=this._owner._shapes,i=0,e=t.length;i<e;i++)t[i]._transform._updateWorldRotationFlag()},e._updateWorldScaleFlag=function(){if(!this._isContainDirtyFlags(160)&&(this._worldAssociatedChange(160),r(this._owner,f)))for(var t=this._owner._shapes,i=0,e=t.length;i<e;i++)t[i]._transform._updateWorldScaleFlag()},e._updateAllWorldFlag=function(){if(!this._isContainDirtyFlags(188)&&(this._worldAssociatedChange(188),r(this._owner,f)))for(var t=this._owner._shapes,i=0,e=t.length;i<e;i++)t[i]._transform._updateAllWorldFlag()},e._getParentTransform=function(){if(!this._isParentDirty)return this._parentTransformCache;var t=null;return r(this._owner,_)&&(t=this._owner._collider._transform),this._parentTransformCache=t,this._isParentDirty=!1,t},e._isContainDirtyFlags=function(t){return(this._dirtyFlag&t)===t},e._isContainDirtyFlag=function(t){return(this._dirtyFlag&t)!=0},e._setDirtyFlagTrue=function(t){this._dirtyFlag|=t},e._setDirtyFlagFalse=function(t){this._dirtyFlag&=~t},e._worldAssociatedChange=function(t){this._dirtyFlag|=t,this._updateFlagManager.distribute()},o(t,[{key:"owner",set:function(t){this._owner=t}},{key:"position",get:function(){return this._position},set:function(t){this._position!==t&&this._position.copyFrom(t),this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()}},{key:"rotationQuaternion",get:function(){return this._isContainDirtyFlag(2)&&(i.Quaternion.rotationEuler(i.MathUtil.degreeToRadian(this._rotation.x),i.MathUtil.degreeToRadian(this._rotation.y),i.MathUtil.degreeToRadian(this._rotation.z),this._rotationQuaternion),this._setDirtyFlagFalse(2)),this._rotationQuaternion},set:function(t){this._rotationQuaternion!==t&&this._rotationQuaternion.copyFrom(t),this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()}},{key:"worldRotationQuaternion",get:function(){if(this._isContainDirtyFlag(16)){var t=this._getParentTransform();null!=t?i.Quaternion.multiply(t.worldRotationQuaternion,this.rotationQuaternion,this._worldRotationQuaternion):this._worldRotationQuaternion.copyFrom(this.rotationQuaternion),this._setDirtyFlagFalse(16)}return this._worldRotationQuaternion},set:function(e){this._worldRotationQuaternion!==e&&this._worldRotationQuaternion.copyFrom(e);var n=this._getParentTransform();n?(i.Quaternion.invert(n.worldRotationQuaternion,t._tempQuat0),i.Quaternion.multiply(e,t._tempQuat0,this._rotationQuaternion)):this._rotationQuaternion.copyFrom(e),this.rotationQuaternion=this._rotationQuaternion,this._setDirtyFlagFalse(16)}},{key:"scale",get:function(){return this._scale},set:function(t){this._scale!==t&&this._scale.copyFrom(t),this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()}},{key:"localMatrix",get:function(){return this._isContainDirtyFlag(64)&&(i.Matrix.affineTransformation(this._scale,this.rotationQuaternion,this._position,this._localMatrix),this._setDirtyFlagFalse(64)),this._localMatrix},set:function(t){this._localMatrix!==t&&this._localMatrix.copyFrom(t),this._localMatrix.decompose(this._position,this._rotationQuaternion,this._scale),this._setDirtyFlagTrue(1),this._setDirtyFlagFalse(64),this._updateAllWorldFlag()}},{key:"worldMatrix",get:function(){if(this._isContainDirtyFlag(128)){var t=this._getParentTransform();t?i.Matrix.multiply(t.worldMatrix,this.localMatrix,this._worldMatrix):this._worldMatrix.copyFrom(this.localMatrix),this._setDirtyFlagFalse(128)}return this._worldMatrix},set:function(e){this._worldMatrix!==e&&this._worldMatrix.copyFrom(e);var n=this._getParentTransform();n?(i.Matrix.invert(n.worldMatrix,t._tempMat42),i.Matrix.multiply(t._tempMat42,e,this._localMatrix)):this._localMatrix.copyFrom(e),this.localMatrix=this._localMatrix,this._setDirtyFlagFalse(128)}}]),t}();p._tempQuat0=new i.Quaternion,p._tempMat42=new i.Matrix,(a=l||(l={}))[a.LocalEuler=1]="LocalEuler",a[a.LocalQuat=2]="LocalQuat",a[a.WorldPosition=4]="WorldPosition",a[a.WorldEuler=8]="WorldEuler",a[a.WorldQuat=16]="WorldQuat",a[a.WorldScale=32]="WorldScale",a[a.LocalMatrix=64]="LocalMatrix",a[a.WorldMatrix=128]="WorldMatrix",a[a.WmWp=132]="WmWp",a[a.WmWeWq=152]="WmWeWq",a[a.WmWpWeWq=156]="WmWpWeWq",a[a.WmWs=160]="WmWs",a[a.WmWpWs=164]="WmWpWs",a[a.WmWpWeWqWs=188]="WmWpWeWqWs";var f=function(){function t(){this._shapes=[],this._transform=new p,this._transform.owner=this}var i=t.prototype;return i.addShape=function(t){var i=t._collider;i!==this&&(i&&i.removeShape(t),this._shapes.push(t),t._collider=this)},i.removeShape=function(t){var i=this._shapes.indexOf(t);-1!==i&&(this._shapes.splice(i,1),t._collider=null)},i.setWorldTransform=function(t,i){this._transform.setPosition(t.x,t.y,t.z),this._transform.setRotationQuaternion(i.x,i.y,i.z,i.w)},i.getWorldTransform=function(t,i){var e=this._transform,n=e.position,s=e.rotationQuaternion;t.set(n.x,n.y,n.z),i.set(s.x,s.y,s.z,s.w)},i.destroy=function(){},i._raycast=function(t,i,e){e.distance=Number.MAX_VALUE;for(var n=this._shapes,s=0,o=n.length;s<o;s++){var r=n[s];i(r._id)&&r._raycast(t,e)}return e.distance!=Number.MAX_VALUE},t}(),y=function(t){function i(i,e){var n;return(n=t.call(this)||this)._transform.setPosition(i.x,i.y,i.z),n._transform.setRotationQuaternion(e.x,e.y,e.z,e.w),n}n(i,t);var e=i.prototype;return e.addForce=function(t){throw"Physics-lite don't support addForce. Use Physics-PhysX instead!"},e.addTorque=function(t){throw"Physics-lite don't support addTorque. Use Physics-PhysX instead!"},e.move=function(t,i){throw"Physics-lite don't support move. Use Physics-PhysX instead!"},e.sleep=function(){throw"Physics-lite don't support putToSleep. Use Physics-PhysX instead!"},e.setAngularDamping=function(t){throw"Physics-lite don't support setAngularDamping. Use Physics-PhysX instead!"},e.setAngularVelocity=function(t){throw"Physics-lite don't support setAngularVelocity. Use Physics-PhysX instead!"},e.setCenterOfMass=function(t){throw"Physics-lite don't support setCenterOfMass. Use Physics-PhysX instead!"},e.setCollisionDetectionMode=function(t){throw"Physics-lite don't support setCollisionDetectionMode. Use Physics-PhysX instead!"},e.setConstraints=function(t){throw"Physics-lite don't support setConstraints. Use Physics-PhysX instead!"},e.setInertiaTensor=function(t){throw"Physics-lite don't support setInertiaTensor. Use Physics-PhysX instead!"},e.setIsKinematic=function(t){throw"Physics-lite don't support setIsKinematic. Use Physics-PhysX instead!"},e.setLinearDamping=function(t){throw"Physics-lite don't support setLinearDamping. Use Physics-PhysX instead!"},e.setLinearVelocity=function(t){throw"Physics-lite don't support setLinearVelocity. Use Physics-PhysX instead!"},e.setMass=function(t){throw"Physics-lite don't support setMass. Use Physics-PhysX instead!"},e.setMaxAngularVelocity=function(t){throw"Physics-lite don't support setMaxAngularVelocity. Use Physics-PhysX instead!"},e.setMaxDepenetrationVelocity=function(t){throw"Physics-lite don't support setMaxDepenetrationVelocity. Use Physics-PhysX instead!"},e.setSleepThreshold=function(t){throw"Physics-lite don't support setSleepThreshold. Use Physics-PhysX instead!"},e.setSolverIterations=function(t){throw"Physics-lite don't support setSolverIterations. Use Physics-PhysX instead!"},e.wakeUp=function(){throw"Physics-lite don't support wakeUp. Use Physics-PhysX instead!"},i}(f),g=function(){function t(t){void 0===t&&(t=0),this.length=0,this._elements=Array(t)}var i=t.prototype;return i.add=function(t){this.length===this._elements.length?this._elements.push(t):this._elements[this.length]=t,this.length++},i.delete=function(t){var i=this._elements.indexOf(t);this.deleteByIndex(i)},i.get=function(t){if(t>=this.length)throw"Index is out of range.";return this._elements[t]},i.deleteByIndex=function(t){var i=this._elements,e=null,n=this.length-1;return t!==n&&(e=i[n],i[t]=e),this.length--,e},i.garbageCollection=function(){this._elements.length=this.length},t}(),m=function(){this.shapeID=-1,this.distance=0,this.point=new i.Vector3,this.normal=new i.Vector3},P=function(t){function e(e,n,s){var o;return(o=t.call(this)||this)._halfSize=new i.Vector3,o._scale=new i.Vector3(1,1,1),o._boxMin=new i.Vector3(-.5,-.5,-.5),o._boxMax=new i.Vector3(.5,.5,.5),o._id=e,o._halfSize.set(.5*n.x,.5*n.y,.5*n.z),o._setBondingBox(),o}n(e,t);var s=e.prototype;return s.setPosition=function(i){t.prototype.setPosition.call(this,i),this._setBondingBox()},s.setWorldScale=function(t){this._transform.position=this._transform.position.multiply(t),this._scale.copyFrom(t)},s.setSize=function(t){this._halfSize.set(.5*t.x,.5*t.y,.5*t.z),this._setBondingBox()},s._raycast=function(t,i){var n=this._getLocalRay(t),s=e._tempBox;s.min.set(-this._halfSize.x*this._scale.x,-this._halfSize.y*this._scale.y,-this._halfSize.z*this._scale.z),s.max.set(this._halfSize.x*this._scale.x,this._halfSize.y*this._scale.y,this._halfSize.z*this._scale.z);var o=n.intersectBox(s);return -1!==o&&(this._updateHitResult(n,o,i,t.origin),!0)},s._setBondingBox=function(){var t=this._transform.position,e=this._halfSize;i.Vector3.add(t,e,this._boxMax),i.Vector3.subtract(t,e,this._boxMin)},e}(_);P._tempBox=new i.BoundingBox;var x=function(t){function e(i,e,n){var s;return(s=t.call(this)||this)._radius=1,s._maxScale=1,s._radius=e,s._id=i,s}n(e,t);var s=e.prototype;return s.setRadius=function(t){this._radius=t},s.setWorldScale=function(t){this._maxScale=Math.max(t.x,Math.max(t.x,t.y))},s._raycast=function(t,n){var s=e._tempSphere;i.Vector3.transformCoordinate(this._transform.position,this._collider._transform.worldMatrix,s.center),s.radius=this.worldRadius;var o=t.intersectSphere(s);return -1!==o&&(this._updateHitResult(t,o,n,t.origin,!0),!0)},o(e,[{key:"worldRadius",get:function(){return this._radius*this._maxScale}}]),e}(_);x._tempSphere=new i.BoundingSphere;var v=function(){function t(t,e,n,s,o,r){this._colliders=[],this._sphere=new i.BoundingSphere,this._box=new i.BoundingBox,this._currentEvents=new g,this._eventMap={},this._eventPool=[],this._onContactEnter=t,this._onContactExit=e,this._onContactStay=n,this._onTriggerEnter=s,this._onTriggerExit=o,this._onTriggerStay=r}var e=t.prototype;return e.setGravity=function(t){console.log("Physics-lite don't support gravity. Use Physics-PhysX instead!")},e.addColliderShape=function(t){this._eventMap[t._id]={}},e.removeColliderShape=function(t){for(var i=this._eventPool,e=this._currentEvents,n=t._id,s=e.length-1;s>=0;s--){var o=e.get(s);(o.index1==n||o.index2==n)&&(e.deleteByIndex(s),i.push(o))}delete this._eventMap[n]},e.addCollider=function(t){this._colliders.push(t)},e.removeCollider=function(t){var i=this._colliders.indexOf(t);-1!==i&&this._colliders.splice(i,1)},e.update=function(t){for(var i=this._colliders,e=0,n=i.length;e<n;e++)this._collisionDetection(t,i[e]);this._fireEvent()},e.raycast=function(i,e,n,s){var o,r=this._colliders;s&&(o=t._hitResult);for(var a=!1,h=t._currentHit,l=0,c=r.length;l<c;l++)if(r[l]._raycast(i,n,h)&&(a=!0,h.distance<e)){if(!o)return!0;o.normal.copyFrom(h.normal),o.point.copyFrom(h.point),o.distance=h.distance,o.shapeID=h.shapeID,e=h.distance}return!a&&o?(o.shapeID=-1,o.distance=0,o.point.set(0,0,0),o.normal.set(0,0,0)):a&&o&&s(o.shapeID,o.distance,o.point,o.normal),a},e.addCharacterController=function(t){throw"Physics-lite don't support addCharacterController. Use Physics-PhysX instead!"},e.removeCharacterController=function(t){throw"Physics-lite don't support removeCharacterController. Use Physics-PhysX instead!"},e._getTrigger=function(t,i){var e;return this._eventPool.length?((e=this._eventPool.pop()).index1=t,e.index2=i):e=new w(t,i),this._eventMap[t][i]=e,e},e._collisionDetection=function(i,e){for(var n=this._colliders,s=e._shapes,o=0,a=s.length;o<a;o++){var h=s[o];if(r(h,P)){t._updateWorldBox(h,this._box);for(var l=0,c=n.length;l<c;l++)for(var u=n[l]._shapes,d=0,_=u.length;d<_;d++){var p=u[d],f=p._id,y=h._id,g=f<y?this._eventMap[f][y]:this._eventMap[y][f];if((void 0===g||g.alreadyInvoked)&&p!=h&&this._boxCollision(p)){if(void 0===g){var m=f<y?this._getTrigger(f,y):this._getTrigger(y,f);m.state=0,m.alreadyInvoked=!1,this._currentEvents.add(m)}else 0===g.state?(g.state=1,g.alreadyInvoked=!1):1===g.state&&(g.alreadyInvoked=!1)}}}else if(r(h,x)){t._upWorldSphere(h,this._sphere);for(var v=0,w=n.length;v<w;v++)for(var M=n[v]._shapes,F=0,C=M.length;F<C;F++){var W=M[F],S=W._id,U=h._id,D=S<U?this._eventMap[S][U]:this._eventMap[U][S];if((void 0===D||D.alreadyInvoked)&&W!=h&&this._sphereCollision(W)){if(void 0===D){var Q=S<U?this._getTrigger(S,U):this._getTrigger(U,S);Q.state=0,Q.alreadyInvoked=!1,this._currentEvents.add(Q)}else 0===D.state?(D.state=1,D.alreadyInvoked=!1):1===D.state&&(D.alreadyInvoked=!1)}}}}},e._fireEvent=function(){for(var t=this._eventPool,i=this._currentEvents,e=i.length-1;e>=0;e--){var n=i.get(e);n.alreadyInvoked?(n.state=2,this._eventMap[n.index1][n.index2]=void 0,this._onTriggerExit(n.index1,n.index2),i.deleteByIndex(e),t.push(n)):0==n.state?(this._onTriggerEnter(n.index1,n.index2),n.alreadyInvoked=!0):1==n.state&&(this._onTriggerStay(n.index1,n.index2),n.alreadyInvoked=!0)}},e._boxCollision=function(e){if(r(e,P)){var n=t._tempBox;return t._updateWorldBox(e,n),i.CollisionUtil.intersectsBoxAndBox(n,this._box)}if(r(e,x)){var s=t._tempSphere;return t._upWorldSphere(e,s),i.CollisionUtil.intersectsSphereAndBox(s,this._box)}return!1},e._sphereCollision=function(e){if(r(e,P)){var n=t._tempBox;return t._updateWorldBox(e,n),i.CollisionUtil.intersectsSphereAndBox(this._sphere,n)}if(r(e,x)){var s=t._tempSphere;return t._upWorldSphere(e,s),i.CollisionUtil.intersectsSphereAndSphere(s,this._sphere)}return!1},t._updateWorldBox=function(t,e){var n=t._transform.worldMatrix;e.min.copyFrom(t._boxMin),e.max.copyFrom(t._boxMax),i.BoundingBox.transform(e,n,e)},t._upWorldSphere=function(t,e){i.Vector3.transformCoordinate(t._transform.position,t._transform.worldMatrix,e.center),e.radius=t.worldRadius},t}();v._tempSphere=new i.BoundingSphere,v._tempBox=new i.BoundingBox,v._currentHit=new m,v._hitResult=new m,(h=c||(c={}))[h.Enter=0]="Enter",h[h.Stay=1]="Stay",h[h.Exit=2]="Exit";var w=function(t,i){this.alreadyInvoked=!1,this.index1=t,this.index2=i},M=function(){function t(t,i,e,n,s){}var i=t.prototype;return i.setBounciness=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},i.setDynamicFriction=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},i.setStaticFriction=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},i.setBounceCombine=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},i.setFrictionCombine=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},i.destroy=function(){},t}(),F=function(t){function i(i,e){var n;return(n=t.call(this)||this)._transform.setPosition(i.x,i.y,i.z),n._transform.setRotationQuaternion(e.x,e.y,e.z,e.w),n}return n(i,t),i}(f),C=function(){function t(){}var i=t.prototype;return i.initialize=function(){return Promise.resolve()},i.createPhysicsManager=function(t,i,e,n,s,o){return new v(t,i,e,n,s,o)},i.createStaticCollider=function(t,i){return new F(t,i)},i.createDynamicCollider=function(t,i){return new y(t,i)},i.createCharacterController=function(){throw"Physics-lite don't support createCharacterController. Use Physics-PhysX instead!"},i.createPhysicsMaterial=function(t,i,e,n,s){return new M(t,i,e,n,s)},i.createBoxColliderShape=function(t,i,e){return new P(t,i,e)},i.createSphereColliderShape=function(t,i,e){return new x(t,i,e)},i.createPlaneColliderShape=function(t,i){throw"Physics-lite don't support PlaneColliderShape. Use Physics-PhysX instead!"},i.createCapsuleColliderShape=function(t,i,e,n){throw"Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!"},i.createFixedJoint=function(t){throw"Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!"},i.createHingeJoint=function(t){throw"Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!"},i.createSpringJoint=function(t){throw"Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!"},t}();t.LitePhysics=C,Object.defineProperty(t,"__esModule",{value:!0})});
|
|
1
|
+
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("@galacean/engine")):"function"==typeof define&&define.amd?define(["exports","@galacean/engine"],i):i(((t="undefined"!=typeof globalThis?globalThis:t||self).Galacean=t.Galacean||{},t.Galacean.PhysicsLite={}),t.Galacean)}(this,function(t,i){"use strict";function e(t,i){return(e=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t})(t,i)}function n(t,i){if("function"!=typeof i&&null!==i)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(i&&i.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),i&&e(t,i)}function s(t,i){for(var e=0;e<i.length;e++){var n=i[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function o(t,i,e){return i&&s(t.prototype,i),e&&s(t,e),t}function r(t,i){return null!=i&&"undefined"!=typeof Symbol&&i[Symbol.hasInstance]?!!i[Symbol.hasInstance](t):t instanceof i}var a,h,l,c,u=function(){function t(t){void 0===t&&(t=[]),this._flags=t,this.flag=!0,this._flags.push(this)}return t.prototype.destroy=function(){i.Utils.removeFromArray(this._flags,this),this._flags=null},t}(),d=function(){function t(){this._updateFlags=[]}var i=t.prototype;return i.register=function(){return new u(this._updateFlags)},i.distribute=function(){for(var t=this._updateFlags,i=t.length-1;i>=0;i--)t[i].flag=!0},t}(),_=function(){function t(){this._transform=new p,this._invModelMatrix=new i.Matrix,this._transform.owner=this,this._inverseWorldMatFlag=this._transform.registerWorldChangeFlag()}var e=t.prototype;return e.setRotation=function(t){console.log("Physics-lite don't support setRotation. Use Physics-PhysX instead!")},e.setPosition=function(t){this._transform.setPosition(t.x,t.y,t.z)},e.setContactOffset=function(t){console.log("Physics-lite don't support setContactOffset. Use Physics-PhysX instead!")},e.setMaterial=function(t){console.log("Physics-lite don't support setMaterial. Use Physics-PhysX instead!")},e.setUniqueID=function(t){this._id=t},e.setIsTrigger=function(t){console.log("Physics-lite don't support setIsTrigger. Use Physics-PhysX instead!")},e.destroy=function(){},e._updateHitResult=function(e,n,s,o,r){void 0===r&&(r=!1);var a=t._tempPoint;e.getPoint(n,a),r||i.Vector3.transformCoordinate(a,this._transform.worldMatrix,a);var h=i.Vector3.distance(o,a);h<s.distance&&(s.point.copyFrom(a),s.distance=h,s.shapeID=this._id)},e._getLocalRay=function(e){var n=this._getInvModelMatrix(),s=t._ray;return i.Vector3.transformCoordinate(e.origin,n,s.origin),i.Vector3.transformNormal(e.direction,n,s.direction),s.direction.normalize(),s},e._getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(i.Matrix.invert(this._transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},t}();_._ray=new i.Ray,_._tempPoint=new i.Vector3;var p=function(){function t(){this._position=new i.Vector3,this._rotation=new i.Vector3,this._rotationQuaternion=new i.Quaternion,this._scale=new i.Vector3(1,1,1),this._worldRotationQuaternion=new i.Quaternion,this._localMatrix=new i.Matrix,this._worldMatrix=new i.Matrix,this._updateFlagManager=new d,this._isParentDirty=!0,this._parentTransformCache=null,this._dirtyFlag=188}var e=t.prototype;return e.setPosition=function(t,i,e){this._position.set(t,i,e),this.position=this._position},e.setRotationQuaternion=function(t,i,e,n){this._rotationQuaternion.set(t,i,e,n),this.rotationQuaternion=this._rotationQuaternion},e.setScale=function(t,i,e){this._scale.set(t,i,e),this.scale=this._scale},e.registerWorldChangeFlag=function(){return this._updateFlagManager.register()},e._updateWorldPositionFlag=function(){if(!this._isContainDirtyFlags(132)&&(this._worldAssociatedChange(132),r(this._owner,f)))for(var t=this._owner._shapes,i=0,e=t.length;i<e;i++)t[i]._transform._updateWorldPositionFlag()},e._updateWorldRotationFlag=function(){if(!this._isContainDirtyFlags(152)&&(this._worldAssociatedChange(152),r(this._owner,f)))for(var t=this._owner._shapes,i=0,e=t.length;i<e;i++)t[i]._transform._updateWorldRotationFlag()},e._updateWorldScaleFlag=function(){if(!this._isContainDirtyFlags(160)&&(this._worldAssociatedChange(160),r(this._owner,f)))for(var t=this._owner._shapes,i=0,e=t.length;i<e;i++)t[i]._transform._updateWorldScaleFlag()},e._updateAllWorldFlag=function(){if(!this._isContainDirtyFlags(188)&&(this._worldAssociatedChange(188),r(this._owner,f)))for(var t=this._owner._shapes,i=0,e=t.length;i<e;i++)t[i]._transform._updateAllWorldFlag()},e._getParentTransform=function(){if(!this._isParentDirty)return this._parentTransformCache;var t=null;return r(this._owner,_)&&(t=this._owner._collider._transform),this._parentTransformCache=t,this._isParentDirty=!1,t},e._isContainDirtyFlags=function(t){return(this._dirtyFlag&t)===t},e._isContainDirtyFlag=function(t){return(this._dirtyFlag&t)!=0},e._setDirtyFlagTrue=function(t){this._dirtyFlag|=t},e._setDirtyFlagFalse=function(t){this._dirtyFlag&=~t},e._worldAssociatedChange=function(t){this._dirtyFlag|=t,this._updateFlagManager.distribute()},o(t,[{key:"owner",set:function(t){this._owner=t}},{key:"position",get:function(){return this._position},set:function(t){this._position!==t&&this._position.copyFrom(t),this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()}},{key:"rotationQuaternion",get:function(){return this._isContainDirtyFlag(2)&&(i.Quaternion.rotationEuler(i.MathUtil.degreeToRadian(this._rotation.x),i.MathUtil.degreeToRadian(this._rotation.y),i.MathUtil.degreeToRadian(this._rotation.z),this._rotationQuaternion),this._setDirtyFlagFalse(2)),this._rotationQuaternion},set:function(t){this._rotationQuaternion!==t&&this._rotationQuaternion.copyFrom(t),this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()}},{key:"worldRotationQuaternion",get:function(){if(this._isContainDirtyFlag(16)){var t=this._getParentTransform();null!=t?i.Quaternion.multiply(t.worldRotationQuaternion,this.rotationQuaternion,this._worldRotationQuaternion):this._worldRotationQuaternion.copyFrom(this.rotationQuaternion),this._setDirtyFlagFalse(16)}return this._worldRotationQuaternion},set:function(e){this._worldRotationQuaternion!==e&&this._worldRotationQuaternion.copyFrom(e);var n=this._getParentTransform();n?(i.Quaternion.invert(n.worldRotationQuaternion,t._tempQuat0),i.Quaternion.multiply(e,t._tempQuat0,this._rotationQuaternion)):this._rotationQuaternion.copyFrom(e),this.rotationQuaternion=this._rotationQuaternion,this._setDirtyFlagFalse(16)}},{key:"scale",get:function(){return this._scale},set:function(t){this._scale!==t&&this._scale.copyFrom(t),this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()}},{key:"localMatrix",get:function(){return this._isContainDirtyFlag(64)&&(i.Matrix.affineTransformation(this._scale,this.rotationQuaternion,this._position,this._localMatrix),this._setDirtyFlagFalse(64)),this._localMatrix},set:function(t){this._localMatrix!==t&&this._localMatrix.copyFrom(t),this._localMatrix.decompose(this._position,this._rotationQuaternion,this._scale),this._setDirtyFlagTrue(1),this._setDirtyFlagFalse(64),this._updateAllWorldFlag()}},{key:"worldMatrix",get:function(){if(this._isContainDirtyFlag(128)){var t=this._getParentTransform();t?i.Matrix.multiply(t.worldMatrix,this.localMatrix,this._worldMatrix):this._worldMatrix.copyFrom(this.localMatrix),this._setDirtyFlagFalse(128)}return this._worldMatrix},set:function(e){this._worldMatrix!==e&&this._worldMatrix.copyFrom(e);var n=this._getParentTransform();n?(i.Matrix.invert(n.worldMatrix,t._tempMat42),i.Matrix.multiply(t._tempMat42,e,this._localMatrix)):this._localMatrix.copyFrom(e),this.localMatrix=this._localMatrix,this._setDirtyFlagFalse(128)}}]),t}();p._tempQuat0=new i.Quaternion,p._tempMat42=new i.Matrix,(a=l||(l={}))[a.LocalEuler=1]="LocalEuler",a[a.LocalQuat=2]="LocalQuat",a[a.WorldPosition=4]="WorldPosition",a[a.WorldEuler=8]="WorldEuler",a[a.WorldQuat=16]="WorldQuat",a[a.WorldScale=32]="WorldScale",a[a.LocalMatrix=64]="LocalMatrix",a[a.WorldMatrix=128]="WorldMatrix",a[a.WmWp=132]="WmWp",a[a.WmWeWq=152]="WmWeWq",a[a.WmWpWeWq=156]="WmWpWeWq",a[a.WmWs=160]="WmWs",a[a.WmWpWs=164]="WmWpWs",a[a.WmWpWeWqWs=188]="WmWpWeWqWs";var f=function(){function t(){this._shapes=[],this._transform=new p,this._transform.owner=this}var i=t.prototype;return i.addShape=function(t){var i=t._collider;i!==this&&(i&&i.removeShape(t),this._shapes.push(t),t._collider=this)},i.removeShape=function(t){var i=this._shapes.indexOf(t);-1!==i&&(this._shapes.splice(i,1),t._collider=null)},i.setWorldTransform=function(t,i){this._transform.setPosition(t.x,t.y,t.z),this._transform.setRotationQuaternion(i.x,i.y,i.z,i.w)},i.getWorldTransform=function(t,i){var e=this._transform,n=e.position,s=e.rotationQuaternion;t.set(n.x,n.y,n.z),i.set(s.x,s.y,s.z,s.w)},i.destroy=function(){},i._raycast=function(t,i,e){e.distance=Number.MAX_VALUE;for(var n=this._shapes,s=0,o=n.length;s<o;s++){var r=n[s];i(r._id)&&r._raycast(t,e)}return e.distance!=Number.MAX_VALUE},t}(),y=function(t){function i(i,e){var n;return(n=t.call(this)||this)._transform.setPosition(i.x,i.y,i.z),n._transform.setRotationQuaternion(e.x,e.y,e.z,e.w),n}n(i,t);var e=i.prototype;return e.addForce=function(t){throw"Physics-lite don't support addForce. Use Physics-PhysX instead!"},e.addTorque=function(t){throw"Physics-lite don't support addTorque. Use Physics-PhysX instead!"},e.move=function(t,i){throw"Physics-lite don't support move. Use Physics-PhysX instead!"},e.sleep=function(){throw"Physics-lite don't support putToSleep. Use Physics-PhysX instead!"},e.setAngularDamping=function(t){throw"Physics-lite don't support setAngularDamping. Use Physics-PhysX instead!"},e.setAngularVelocity=function(t){throw"Physics-lite don't support setAngularVelocity. Use Physics-PhysX instead!"},e.setCenterOfMass=function(t){throw"Physics-lite don't support setCenterOfMass. Use Physics-PhysX instead!"},e.setCollisionDetectionMode=function(t){throw"Physics-lite don't support setCollisionDetectionMode. Use Physics-PhysX instead!"},e.setConstraints=function(t){throw"Physics-lite don't support setConstraints. Use Physics-PhysX instead!"},e.setInertiaTensor=function(t){throw"Physics-lite don't support setInertiaTensor. Use Physics-PhysX instead!"},e.setIsKinematic=function(t){throw"Physics-lite don't support setIsKinematic. Use Physics-PhysX instead!"},e.setLinearDamping=function(t){throw"Physics-lite don't support setLinearDamping. Use Physics-PhysX instead!"},e.setLinearVelocity=function(t){throw"Physics-lite don't support setLinearVelocity. Use Physics-PhysX instead!"},e.setMass=function(t){throw"Physics-lite don't support setMass. Use Physics-PhysX instead!"},e.setMaxAngularVelocity=function(t){throw"Physics-lite don't support setMaxAngularVelocity. Use Physics-PhysX instead!"},e.setMaxDepenetrationVelocity=function(t){throw"Physics-lite don't support setMaxDepenetrationVelocity. Use Physics-PhysX instead!"},e.setSleepThreshold=function(t){throw"Physics-lite don't support setSleepThreshold. Use Physics-PhysX instead!"},e.setSolverIterations=function(t){throw"Physics-lite don't support setSolverIterations. Use Physics-PhysX instead!"},e.wakeUp=function(){throw"Physics-lite don't support wakeUp. Use Physics-PhysX instead!"},i}(f),g=function(){function t(t){void 0===t&&(t=0),this.length=0,this._elements=Array(t)}var i=t.prototype;return i.add=function(t){this.length===this._elements.length?this._elements.push(t):this._elements[this.length]=t,this.length++},i.delete=function(t){var i=this._elements.indexOf(t);this.deleteByIndex(i)},i.get=function(t){if(t>=this.length)throw"Index is out of range.";return this._elements[t]},i.deleteByIndex=function(t){var i=this._elements,e=null,n=this.length-1;return t!==n&&(e=i[n],i[t]=e),this.length--,e},i.garbageCollection=function(){this._elements.length=this.length},t}(),m=function(){this.shapeID=-1,this.distance=0,this.point=new i.Vector3,this.normal=new i.Vector3},P=function(t){function e(e,n,s){var o;return(o=t.call(this)||this)._halfSize=new i.Vector3,o._scale=new i.Vector3(1,1,1),o._boxMin=new i.Vector3(-.5,-.5,-.5),o._boxMax=new i.Vector3(.5,.5,.5),o._id=e,o._halfSize.set(.5*n.x,.5*n.y,.5*n.z),o._setBondingBox(),o}n(e,t);var s=e.prototype;return s.setPosition=function(i){t.prototype.setPosition.call(this,i),this._setBondingBox()},s.setWorldScale=function(t){this._transform.position=this._transform.position.multiply(t),this._scale.copyFrom(t)},s.setSize=function(t){this._halfSize.set(.5*t.x,.5*t.y,.5*t.z),this._setBondingBox()},s._raycast=function(t,i){var n=this._getLocalRay(t),s=e._tempBox;s.min.set(-this._halfSize.x*this._scale.x,-this._halfSize.y*this._scale.y,-this._halfSize.z*this._scale.z),s.max.set(this._halfSize.x*this._scale.x,this._halfSize.y*this._scale.y,this._halfSize.z*this._scale.z);var o=n.intersectBox(s);return -1!==o&&(this._updateHitResult(n,o,i,t.origin),!0)},s._setBondingBox=function(){var t=this._transform.position,e=this._halfSize;i.Vector3.add(t,e,this._boxMax),i.Vector3.subtract(t,e,this._boxMin)},e}(_);P._tempBox=new i.BoundingBox;var x=function(t){function e(i,e,n){var s;return(s=t.call(this)||this)._radius=1,s._maxScale=1,s._radius=e,s._id=i,s}n(e,t);var s=e.prototype;return s.setRadius=function(t){this._radius=t},s.setWorldScale=function(t){this._maxScale=Math.max(t.x,Math.max(t.x,t.y))},s._raycast=function(t,n){var s=e._tempSphere;i.Vector3.transformCoordinate(this._transform.position,this._collider._transform.worldMatrix,s.center),s.radius=this.worldRadius;var o=t.intersectSphere(s);return -1!==o&&(this._updateHitResult(t,o,n,t.origin,!0),!0)},o(e,[{key:"worldRadius",get:function(){return this._radius*this._maxScale}}]),e}(_);x._tempSphere=new i.BoundingSphere;var v=function(){function t(t,e,n,s,o,r){this._colliders=[],this._sphere=new i.BoundingSphere,this._box=new i.BoundingBox,this._currentEvents=new g,this._eventMap={},this._eventPool=[],this._onContactEnter=t,this._onContactExit=e,this._onContactStay=n,this._onTriggerEnter=s,this._onTriggerExit=o,this._onTriggerStay=r}var e=t.prototype;return e.setGravity=function(t){console.log("Physics-lite don't support gravity. Use Physics-PhysX instead!")},e.addColliderShape=function(t){this._eventMap[t._id]={}},e.removeColliderShape=function(t){for(var i=this._eventPool,e=this._currentEvents,n=t._id,s=e.length-1;s>=0;s--){var o=e.get(s);(o.index1==n||o.index2==n)&&(e.deleteByIndex(s),i.push(o))}delete this._eventMap[n]},e.addCollider=function(t){this._colliders.push(t)},e.removeCollider=function(t){var i=this._colliders.indexOf(t);-1!==i&&this._colliders.splice(i,1)},e.update=function(t){for(var i=this._colliders,e=0,n=i.length;e<n;e++)this._collisionDetection(t,i[e]);this._fireEvent()},e.raycast=function(i,e,n,s){var o,r=this._colliders;s&&(o=t._hitResult);for(var a=!1,h=t._currentHit,l=0,c=r.length;l<c;l++)if(r[l]._raycast(i,n,h)&&(a=!0,h.distance<e)){if(!o)return!0;o.normal.copyFrom(h.normal),o.point.copyFrom(h.point),o.distance=h.distance,o.shapeID=h.shapeID,e=h.distance}return!a&&o?(o.shapeID=-1,o.distance=0,o.point.set(0,0,0),o.normal.set(0,0,0)):a&&o&&s(o.shapeID,o.distance,o.point,o.normal),a},e.addCharacterController=function(t){throw"Physics-lite don't support addCharacterController. Use Physics-PhysX instead!"},e.removeCharacterController=function(t){throw"Physics-lite don't support removeCharacterController. Use Physics-PhysX instead!"},e._getTrigger=function(t,i){var e;return this._eventPool.length?((e=this._eventPool.pop()).index1=t,e.index2=i):e=new w(t,i),this._eventMap[t][i]=e,e},e._collisionDetection=function(i,e){for(var n=this._colliders,s=e._shapes,o=0,a=s.length;o<a;o++){var h=s[o];if(r(h,P)){t._updateWorldBox(h,this._box);for(var l=0,c=n.length;l<c;l++)for(var u=n[l]._shapes,d=0,_=u.length;d<_;d++){var p=u[d],f=p._id,y=h._id,g=f<y?this._eventMap[f][y]:this._eventMap[y][f];if((void 0===g||g.alreadyInvoked)&&p!=h&&this._boxCollision(p)){if(void 0===g){var m=f<y?this._getTrigger(f,y):this._getTrigger(y,f);m.state=0,m.alreadyInvoked=!1,this._currentEvents.add(m)}else 0===g.state?(g.state=1,g.alreadyInvoked=!1):1===g.state&&(g.alreadyInvoked=!1)}}}else if(r(h,x)){t._upWorldSphere(h,this._sphere);for(var v=0,w=n.length;v<w;v++)for(var M=n[v]._shapes,F=0,C=M.length;F<C;F++){var W=M[F],S=W._id,U=h._id,D=S<U?this._eventMap[S][U]:this._eventMap[U][S];if((void 0===D||D.alreadyInvoked)&&W!=h&&this._sphereCollision(W)){if(void 0===D){var Q=S<U?this._getTrigger(S,U):this._getTrigger(U,S);Q.state=0,Q.alreadyInvoked=!1,this._currentEvents.add(Q)}else 0===D.state?(D.state=1,D.alreadyInvoked=!1):1===D.state&&(D.alreadyInvoked=!1)}}}}},e._fireEvent=function(){for(var t=this._eventPool,i=this._currentEvents,e=i.length-1;e>=0;e--){var n=i.get(e);n.alreadyInvoked?(n.state=2,this._eventMap[n.index1][n.index2]=void 0,this._onTriggerExit(n.index1,n.index2),i.deleteByIndex(e),t.push(n)):0==n.state?(this._onTriggerEnter(n.index1,n.index2),n.alreadyInvoked=!0):1==n.state&&(this._onTriggerStay(n.index1,n.index2),n.alreadyInvoked=!0)}},e._boxCollision=function(e){if(r(e,P)){var n=t._tempBox;return t._updateWorldBox(e,n),i.CollisionUtil.intersectsBoxAndBox(n,this._box)}if(r(e,x)){var s=t._tempSphere;return t._upWorldSphere(e,s),i.CollisionUtil.intersectsSphereAndBox(s,this._box)}return!1},e._sphereCollision=function(e){if(r(e,P)){var n=t._tempBox;return t._updateWorldBox(e,n),i.CollisionUtil.intersectsSphereAndBox(this._sphere,n)}if(r(e,x)){var s=t._tempSphere;return t._upWorldSphere(e,s),i.CollisionUtil.intersectsSphereAndSphere(s,this._sphere)}return!1},t._updateWorldBox=function(t,e){var n=t._transform.worldMatrix;e.min.copyFrom(t._boxMin),e.max.copyFrom(t._boxMax),i.BoundingBox.transform(e,n,e)},t._upWorldSphere=function(t,e){i.Vector3.transformCoordinate(t._transform.position,t._transform.worldMatrix,e.center),e.radius=t.worldRadius},t}();v._tempSphere=new i.BoundingSphere,v._tempBox=new i.BoundingBox,v._currentHit=new m,v._hitResult=new m,(h=c||(c={}))[h.Enter=0]="Enter",h[h.Stay=1]="Stay",h[h.Exit=2]="Exit";var w=function(t,i){this.alreadyInvoked=!1,this.index1=t,this.index2=i},M=function(){function t(t,i,e,n,s){}var i=t.prototype;return i.setBounciness=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},i.setDynamicFriction=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},i.setStaticFriction=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},i.setBounceCombine=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},i.setFrictionCombine=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},i.destroy=function(){},t}(),F=function(t){function i(i,e){var n;return(n=t.call(this)||this)._transform.setPosition(i.x,i.y,i.z),n._transform.setRotationQuaternion(e.x,e.y,e.z,e.w),n}return n(i,t),i}(f),C=function(){function t(){}var i=t.prototype;return i.initialize=function(){return Promise.resolve()},i.createPhysicsManager=function(t,i,e,n,s,o){return new v(t,i,e,n,s,o)},i.createStaticCollider=function(t,i){return new F(t,i)},i.createDynamicCollider=function(t,i){return new y(t,i)},i.createCharacterController=function(){throw"Physics-lite don't support createCharacterController. Use Physics-PhysX instead!"},i.createPhysicsMaterial=function(t,i,e,n,s){return new M(t,i,e,n,s)},i.createBoxColliderShape=function(t,i,e){return new P(t,i,e)},i.createSphereColliderShape=function(t,i,e){return new x(t,i,e)},i.createPlaneColliderShape=function(t,i){throw"Physics-lite don't support PlaneColliderShape. Use Physics-PhysX instead!"},i.createCapsuleColliderShape=function(t,i,e,n){throw"Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!"},i.createFixedJoint=function(t){throw"Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!"},i.createHingeJoint=function(t){throw"Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!"},i.createSpringJoint=function(t){throw"Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!"},t}();t.LitePhysics=C,Object.defineProperty(t,"__esModule",{value:!0})});
|
package/dist/main.js
CHANGED
|
@@ -4,74 +4,50 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var engine = require('@galacean/engine');
|
|
6
6
|
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return o;
|
|
11
|
-
};
|
|
7
|
+
function _set_prototype_of(o, p) {
|
|
8
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
9
|
+
o.__proto__ = p;
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
}
|
|
11
|
+
return o;
|
|
12
|
+
};
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
return setPrototypeOf(o, p);
|
|
14
|
+
return _set_prototype_of(o, p);
|
|
18
15
|
}
|
|
19
16
|
|
|
20
17
|
function _inherits(subClass, superClass) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
26
|
-
constructor: {
|
|
27
|
-
value: subClass,
|
|
28
|
-
writable: true,
|
|
29
|
-
configurable: true
|
|
18
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
19
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
30
20
|
}
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
|
|
22
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
|
|
23
|
+
|
|
24
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
33
25
|
}
|
|
34
26
|
|
|
35
27
|
function _defineProperties(target, props) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
for (var i = 0; i < props.length; i++) {
|
|
29
|
+
var descriptor = props[i];
|
|
30
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
31
|
+
descriptor.configurable = true;
|
|
32
|
+
|
|
33
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
34
|
+
|
|
35
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
36
|
+
}
|
|
43
37
|
}
|
|
38
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
39
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
40
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
44
41
|
|
|
45
|
-
|
|
46
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
47
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
48
|
-
return Constructor;
|
|
42
|
+
return Constructor;
|
|
49
43
|
}
|
|
50
44
|
|
|
51
45
|
function _instanceof(left, right) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return left instanceof right;
|
|
56
|
-
}
|
|
46
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
47
|
+
return !!right[Symbol.hasInstance](left);
|
|
48
|
+
} else return left instanceof right;
|
|
57
49
|
}
|
|
58
50
|
|
|
59
|
-
/**
|
|
60
|
-
* Fastly remove an element from array.
|
|
61
|
-
* @param array - Array
|
|
62
|
-
* @param item - Element
|
|
63
|
-
*/ function removeFromArray(array, item) {
|
|
64
|
-
var index = array.indexOf(item);
|
|
65
|
-
if (index < 0) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
var last = array.length - 1;
|
|
69
|
-
if (index !== last) {
|
|
70
|
-
array[index] = array[last];
|
|
71
|
-
}
|
|
72
|
-
array.length--;
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
51
|
/**
|
|
76
52
|
* Used to update tags.
|
|
77
53
|
*/ var LiteUpdateFlag = /*#__PURE__*/ function() {
|
|
@@ -85,7 +61,7 @@ function _instanceof(left, right) {
|
|
|
85
61
|
/**
|
|
86
62
|
* Destroy.
|
|
87
63
|
*/ _proto.destroy = function destroy() {
|
|
88
|
-
removeFromArray(this._flags, this);
|
|
64
|
+
engine.Utils.removeFromArray(this._flags, this);
|
|
89
65
|
this._flags = null;
|
|
90
66
|
};
|
|
91
67
|
return LiteUpdateFlag;
|
|
@@ -184,8 +160,12 @@ function _instanceof(left, right) {
|
|
|
184
160
|
};
|
|
185
161
|
return LiteColliderShape;
|
|
186
162
|
}();
|
|
187
|
-
|
|
188
|
-
LiteColliderShape.
|
|
163
|
+
(function() {
|
|
164
|
+
LiteColliderShape._ray = new engine.Ray();
|
|
165
|
+
})();
|
|
166
|
+
(function() {
|
|
167
|
+
LiteColliderShape._tempPoint = new engine.Vector3();
|
|
168
|
+
})();
|
|
189
169
|
|
|
190
170
|
/**
|
|
191
171
|
* Used to implement transformation related functions.
|
|
@@ -328,7 +308,7 @@ LiteColliderShape._tempPoint = new engine.Vector3();
|
|
|
328
308
|
this._dirtyFlag |= type;
|
|
329
309
|
this._updateFlagManager.distribute();
|
|
330
310
|
};
|
|
331
|
-
|
|
311
|
+
_create_class(LiteTransform, [
|
|
332
312
|
{
|
|
333
313
|
key: "owner",
|
|
334
314
|
set: function set(value) {
|
|
@@ -477,8 +457,12 @@ LiteColliderShape._tempPoint = new engine.Vector3();
|
|
|
477
457
|
]);
|
|
478
458
|
return LiteTransform;
|
|
479
459
|
}();
|
|
480
|
-
|
|
481
|
-
LiteTransform.
|
|
460
|
+
(function() {
|
|
461
|
+
LiteTransform._tempQuat0 = new engine.Quaternion();
|
|
462
|
+
})();
|
|
463
|
+
(function() {
|
|
464
|
+
LiteTransform._tempMat42 = new engine.Matrix();
|
|
465
|
+
})();
|
|
482
466
|
var /**
|
|
483
467
|
* Dirty flag of transform.
|
|
484
468
|
*/ TransformFlag;
|
|
@@ -783,7 +767,9 @@ var /**
|
|
|
783
767
|
};
|
|
784
768
|
return LiteBoxColliderShape;
|
|
785
769
|
}(LiteColliderShape);
|
|
786
|
-
|
|
770
|
+
(function() {
|
|
771
|
+
LiteBoxColliderShape._tempBox = new engine.BoundingBox();
|
|
772
|
+
})();
|
|
787
773
|
|
|
788
774
|
/**
|
|
789
775
|
* Sphere collider shape in Lite.
|
|
@@ -823,7 +809,7 @@ LiteBoxColliderShape._tempBox = new engine.BoundingBox();
|
|
|
823
809
|
return false;
|
|
824
810
|
}
|
|
825
811
|
};
|
|
826
|
-
|
|
812
|
+
_create_class(LiteSphereColliderShape, [
|
|
827
813
|
{
|
|
828
814
|
key: "worldRadius",
|
|
829
815
|
get: function get() {
|
|
@@ -833,7 +819,9 @@ LiteBoxColliderShape._tempBox = new engine.BoundingBox();
|
|
|
833
819
|
]);
|
|
834
820
|
return LiteSphereColliderShape;
|
|
835
821
|
}(LiteColliderShape);
|
|
836
|
-
|
|
822
|
+
(function() {
|
|
823
|
+
LiteSphereColliderShape._tempSphere = new engine.BoundingSphere();
|
|
824
|
+
})();
|
|
837
825
|
|
|
838
826
|
/**
|
|
839
827
|
* A manager is a collection of colliders and constraints which can interact.
|
|
@@ -1085,10 +1073,18 @@ LiteSphereColliderShape._tempSphere = new engine.BoundingSphere();
|
|
|
1085
1073
|
};
|
|
1086
1074
|
return LitePhysicsManager;
|
|
1087
1075
|
}();
|
|
1088
|
-
|
|
1089
|
-
LitePhysicsManager.
|
|
1090
|
-
|
|
1091
|
-
|
|
1076
|
+
(function() {
|
|
1077
|
+
LitePhysicsManager._tempSphere = new engine.BoundingSphere();
|
|
1078
|
+
})();
|
|
1079
|
+
(function() {
|
|
1080
|
+
LitePhysicsManager._tempBox = new engine.BoundingBox();
|
|
1081
|
+
})();
|
|
1082
|
+
(function() {
|
|
1083
|
+
LitePhysicsManager._currentHit = new LiteHitResult();
|
|
1084
|
+
})();
|
|
1085
|
+
(function() {
|
|
1086
|
+
LitePhysicsManager._hitResult = new LiteHitResult();
|
|
1087
|
+
})();
|
|
1092
1088
|
var /**
|
|
1093
1089
|
* Physics state
|
|
1094
1090
|
*/ TriggerEventState;
|