@enable3d/common
Advanced tools
Comparing version 0.19.0 to 0.19.1
@@ -45,3 +45,3 @@ /** | ||
add: (key: string, animation: AnimationClip) => void; | ||
play: (name: string, transitionDuration?: number) => void; | ||
play: (name: string, transitionDuration?: number, loop?: boolean) => void; | ||
mixer: AnimationMixer; | ||
@@ -48,0 +48,0 @@ }; |
@@ -78,5 +78,6 @@ "use strict"; | ||
add: function (key, animation) { return _this.animationAdd(key, animation); }, | ||
play: function (name, transitionDuration) { | ||
play: function (name, transitionDuration, loop) { | ||
if (transitionDuration === void 0) { transitionDuration = 500; } | ||
return _this.animationPlay(name, transitionDuration); | ||
if (loop === void 0) { loop = true; } | ||
return _this.animationPlay(name, transitionDuration, loop); | ||
}, | ||
@@ -104,16 +105,16 @@ mixer: this.animationMixer | ||
}; | ||
ExtendedObject3D.prototype.animationPlay = function (name, transitionDuration) { | ||
ExtendedObject3D.prototype.animationPlay = function (name, transitionDuration, loop) { | ||
if (transitionDuration === void 0) { transitionDuration = 500; } | ||
if (loop === void 0) { loop = true; } | ||
var next = this._animationActions.get(name); | ||
var current = this._animationActions.get(this._currentAnimation); | ||
if (next) { | ||
next.reset(); | ||
if (current) { | ||
next.reset(); | ||
next.crossFadeFrom(current, transitionDuration / 1000, true); | ||
next.play(); | ||
next.clampWhenFinished = true; | ||
} | ||
else { | ||
next.reset(); | ||
next.play(); | ||
} | ||
if (!loop) | ||
next.setLoop(index_1.LoopOnce, 0); | ||
next.play(); | ||
} | ||
@@ -120,0 +121,0 @@ this._currentAnimation = name; |
@@ -99,3 +99,3 @@ "use strict"; | ||
this.checkCollisions = true; | ||
this.physics.on('collision', function (data) { | ||
this.physics.collisionEvents.on('collision', function (data) { | ||
var bodies = data.bodies, event = data.event; | ||
@@ -102,0 +102,0 @@ if (bodies[0].name === _this.name) |
@@ -184,7 +184,3 @@ /** | ||
} | ||
export interface CollisionEvent { | ||
name: 'start' | 'collision' | 'end'; | ||
impactPoint?: XYZ; | ||
impactNormal?: XYZ; | ||
} | ||
export declare type CollisionEvent = 'start' | 'collision' | 'end'; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@enable3d/common", | ||
"version": "0.19.0", | ||
"version": "0.19.1", | ||
"description": "", | ||
@@ -15,3 +15,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@enable3d/three-wrapper": "^0.19.0" | ||
"@enable3d/three-wrapper": "^0.19.1" | ||
}, | ||
@@ -18,0 +18,0 @@ "funding": { |
@@ -14,3 +14,4 @@ /** | ||
Object3D, | ||
Vector3 | ||
Vector3, | ||
LoopOnce | ||
} from '@enable3d/three-wrapper/dist/index' | ||
@@ -82,3 +83,4 @@ import PhysicsBody from './physicsBody' | ||
add: (key: string, animation: AnimationClip) => this.animationAdd(key, animation), | ||
play: (name: string, transitionDuration = 500) => this.animationPlay(name, transitionDuration), | ||
play: (name: string, transitionDuration = 500, loop: boolean = true) => | ||
this.animationPlay(name, transitionDuration, loop), | ||
mixer: this.animationMixer | ||
@@ -101,3 +103,3 @@ } | ||
private animationPlay(name: string, transitionDuration = 500) { | ||
private animationPlay(name: string, transitionDuration = 500, loop: boolean = true) { | ||
const next = this._animationActions.get(name) | ||
@@ -107,10 +109,11 @@ const current = this._animationActions.get(this._currentAnimation) | ||
if (next) { | ||
next.reset() | ||
if (current) { | ||
next.reset() | ||
next.crossFadeFrom(current, transitionDuration / 1000, true) | ||
next.play() | ||
} else { | ||
next.reset() | ||
next.play() | ||
next.clampWhenFinished = true | ||
} | ||
if (!loop) next.setLoop(LoopOnce, 0) | ||
next.play() | ||
} | ||
@@ -117,0 +120,0 @@ |
@@ -93,3 +93,3 @@ /** | ||
this.physics.on('collision', (data: { bodies: ExtendedObject3D[]; event: CollisionEvent }) => { | ||
this.physics.collisionEvents.on('collision', (data: { bodies: ExtendedObject3D[]; event: CollisionEvent }) => { | ||
const { bodies, event } = data | ||
@@ -96,0 +96,0 @@ if (bodies[0].name === this.name) collisionCallback(bodies[1], event) |
@@ -234,6 +234,2 @@ /** | ||
export interface CollisionEvent { | ||
name: 'start' | 'collision' | 'end' | ||
impactPoint?: XYZ | ||
impactNormal?: XYZ | ||
} | ||
export type CollisionEvent = 'start' | 'collision' | 'end' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
298732
5671