From 08cc8f0a1be2b1e04479d25c40bb6982c7d75767 Mon Sep 17 00:00:00 2001 From: jabenk <40789724+jabenk@users.noreply.github.com> Date: Thu, 30 Apr 2020 12:14:36 +0200 Subject: [PATCH] Jabenk/physics merge1 (#564) * [SDK] Animations overhaul part 2 (#532) * Start filling out animation classes * Add some fields to Animation * Fix some build/lint issues * Finish wiring up SDK * Strip out all old animation system methods/types * Stub out AnimateTo * Fill out AnimateTo * Type checking * Fix some bugs * Update tests for new animation API * Convert input test * Finish porting tests * Fix consistency * Move relative field * Fix * Add vertex colors to test clock * Add animation lookups to anims and materials * Start updating test * Finish up test * Fix up some stuff * Fix test permissions? * Start animation data validation * Add validation * More validation * Debug logging * Consolidate placeholder name/type checking, add validation error class * Document thrown exceptions * Cleanup * Add track easing * Start on more thorough test * Add bouncing cubes test * Fix interpolations * Fix duration for anims with data * Update anim scale test to use relative values * Don't reset time on anim start if speed is 0 * Add orphaned animation detection, delete method * Clean up animations when they're orphaned * Validate target paths as values * Add dynamic animation test * Rename test * Add anim blend test * Rename interpolation-test * Comment out unsupported features * Add back deprecated animateTo * Add back stub of deprecated createAnimation * Add isPlaying prop to AnimationLike * Change return val of AnimateTo, add isPlaying patch prop * Fix intellisense * Add looping relative test * Fix the scale test sliding downward * Correctly override step interpolation * Finish relative anim test * Fix some tests * Move anim finish state transition to client, fixes * Allow occasional actor updates through * Remove post-animation actor updates * Version bump: 0.17 * npm audit fix * Publish - @microsoft/mixed-reality-extension-altspacevr-extras@0.17.0 - @microsoft/mixed-reality-extension-common@0.17.0 - functional-tests@0.17.0 - @microsoft/gltf-gen@0.17.0 - @microsoft/mixed-reality-extension-sdk@0.17.0 * Automated: Regenerated documentation for 0.17.0 * Automated: Updated package-lock.json files for 0.17.0 * Fix for grab sync. Fixes #538 * Add bounciness and frictions to the collider * Add bounce and friction visual tests * Fine tune friciton demo * Fix lint errors * Fix for grab sync. Fixes #538 * Fix lint errors * [SDK] Add more font types (#537) * Add more font types * Change the default font * Publish - @microsoft/mixed-reality-extension-altspacevr-extras@0.17.1 - @microsoft/mixed-reality-extension-common@0.17.1 - functional-tests@0.17.1 - @microsoft/gltf-gen@0.17.1 - @microsoft/mixed-reality-extension-sdk@0.17.1 * Sync animation updates in create calls (#545) * Updated package-lock.json files for 0.17.1 * Jabenk/pr (#541) * Add bounciness and frictions to the collider * Add bounce and friction visual tests * Fine tune friciton demo * PR fixes * More fixes in naming * Format the 2 new files with Ctr+A, and then Ctr+K and Ctr+F * Remove text component from physics planes. * More merges * reduce warning * fix merge errors Co-authored-by: Steven Vergenz Co-authored-by: Eric Anderson --- .../src/tests/physics-collision.ts | 42 +++++++++---------- .../src/tests/physics-free-fall.ts | 32 +++++++------- .../src/tests/physics-head-collision.ts | 42 +++++++++---------- .../sdk/src/actor/physics/physicsBridge.ts | 5 +-- 4 files changed, 57 insertions(+), 64 deletions(-) diff --git a/packages/functional-tests/src/tests/physics-collision.ts b/packages/functional-tests/src/tests/physics-collision.ts index f4a9eb8b2..d9a7dd86b 100644 --- a/packages/functional-tests/src/tests/physics-collision.ts +++ b/packages/functional-tests/src/tests/physics-collision.ts @@ -9,7 +9,7 @@ import * as MRE from '@microsoft/mixed-reality-extension-sdk'; import { Test } from '../test'; export default class PhysicsCollisionTest extends Test { - private assets: MRE.AssetContainer; + private assets: MRE.AssetContainer; private b0: MRE.Actor; private b1: MRE.Actor; @@ -17,9 +17,9 @@ export default class PhysicsCollisionTest extends Test { private redMat: MRE.Material; private blueMat: MRE.Material; - public async run(root: MRE.Actor): Promise { - this.assets = new MRE.AssetContainer(this.app.context); - + public async run(root: MRE.Actor): Promise { + this.assets = new MRE.AssetContainer(this.app.context); + this.redMat = this.assets.createMaterial('redBall', { color: MRE.Color3.Red() }); @@ -27,31 +27,29 @@ export default class PhysicsCollisionTest extends Test { color: MRE.Color3.Blue() }); - if (this.app.context.users.length > 0) - { + if (this.app.context.users.length > 0) { const userId = this.app.context.users[0].id; this.createLabel(root, "RED", MRE.Color3.Red(), userId); - this.spawnBall(root, -1.5, 0.2, this.redMat, userId, { x: 1000, y: 0, z: 0}); + this.spawnBall(root, -1.5, 0.2, this.redMat, userId, { x: 1000, y: 0, z: 0 }); } - if (this.app.context.users.length > 1) - { + if (this.app.context.users.length > 1) { const userId = this.app.context.users[1].id; this.createLabel(root, "BLUE", MRE.Color3.Blue(), userId); - this.spawnBall(root, +1.0, 0.2, this.blueMat, userId, { x: 0, y: 0, z: 0}); + this.spawnBall(root, +1.0, 0.2, this.blueMat, userId, { x: 0, y: 0, z: 0 }); } await this.stoppedAsync(); return true; - } - + } + private createLabel(root: MRE.Actor, text: string, col: MRE.Color3, userId: MRE.Guid) { - const label = MRE.Actor.Create(this.app.context, { + MRE.Actor.Create(this.app.context, { actor: { - name: 'label', - parentId: root.id, - exclusiveToUser: userId, + name: 'label', + parentId: root.id, + exclusiveToUser: userId, transform: { local: { position: { y: 1.5 } } }, text: { contents: text, @@ -60,14 +58,14 @@ export default class PhysicsCollisionTest extends Test { color: col } } - }); + }); } - - private spawnBall(root: MRE.Actor, width: number, height: number, mat: MRE.Material, userId: MRE.Guid, + + private spawnBall(root: MRE.Actor, width: number, height: number, mat: MRE.Material, userId: MRE.Guid, force: Partial, ballRadius = 0.2, killTimeout = 5000) { const ball = MRE.Actor.Create(this.app.context, { actor: { - owner: userId, + owner: userId, parentId: root.id, name: "ball", appearance: { @@ -82,10 +80,10 @@ export default class PhysicsCollisionTest extends Test { }, collider: { geometry: { shape: MRE.ColliderType.Auto } } } - }); + }); setTimeout(() => { - ball.rigidBody.addForce( force ) + ball.rigidBody.addForce(force) }, 1000); setTimeout(() => { diff --git a/packages/functional-tests/src/tests/physics-free-fall.ts b/packages/functional-tests/src/tests/physics-free-fall.ts index 7279b3ef1..ef4823958 100644 --- a/packages/functional-tests/src/tests/physics-free-fall.ts +++ b/packages/functional-tests/src/tests/physics-free-fall.ts @@ -14,7 +14,7 @@ export default class PhysicsFreeFallTest extends Test { public async run(root: MRE.Actor): Promise { this.assets = new MRE.AssetContainer(this.app.context); - + this.redMat = this.assets.createMaterial('redBall', { color: MRE.Color3.Red() }); @@ -22,15 +22,13 @@ export default class PhysicsFreeFallTest extends Test { color: MRE.Color3.Blue() }); - if (this.app.context.users.length > 0) - { + if (this.app.context.users.length > 0) { const userId = this.app.context.users[0].id; this.createLabel(root, "RED", MRE.Color3.Red(), userId); this.spawnBall(root, -0.5, 3.0, this.redMat, userId); } - if (this.app.context.users.length > 1) - { + if (this.app.context.users.length > 1) { const userId = this.app.context.users[1].id; this.createLabel(root, "BLUE", MRE.Color3.Blue(), userId); this.spawnBall(root, +0.5, 3.0, this.blueMat, userId); @@ -38,15 +36,15 @@ export default class PhysicsFreeFallTest extends Test { await this.stoppedAsync(); return true; - } - - private createLabel(root: MRE.Actor, text: string, col: MRE.Color3, userId: MRE.Guid) { + } - const label = MRE.Actor.Create(this.app.context, { + private createLabel(root: MRE.Actor, text: string, col: MRE.Color3, userId: MRE.Guid) { + + MRE.Actor.Create(this.app.context, { actor: { - name: 'label', - parentId: root.id, - exclusiveToUser: userId, + name: 'label', + parentId: root.id, + exclusiveToUser: userId, transform: { local: { position: { y: 1.5 } } }, text: { contents: text, @@ -55,14 +53,14 @@ export default class PhysicsFreeFallTest extends Test { color: col } } - }); - } + }); + } - private spawnBall(root: MRE.Actor, width: number, height: number, mat: MRE.Material, userId: MRE.Guid, + private spawnBall(root: MRE.Actor, width: number, height: number, mat: MRE.Material, userId: MRE.Guid, ballRadius = 0.07, killTimeout = 5000) { const ball = MRE.Actor.Create(this.app.context, { actor: { - owner: userId, + owner: userId, parentId: root.id, name: "ball", appearance: { @@ -77,7 +75,7 @@ export default class PhysicsFreeFallTest extends Test { }, collider: { geometry: { shape: MRE.ColliderType.Auto } } } - }); + }); setTimeout(() => { // We need to disable rendering and move the ball before destroying it so that if it is currently diff --git a/packages/functional-tests/src/tests/physics-head-collision.ts b/packages/functional-tests/src/tests/physics-head-collision.ts index dad0f1639..2e83297ae 100644 --- a/packages/functional-tests/src/tests/physics-head-collision.ts +++ b/packages/functional-tests/src/tests/physics-head-collision.ts @@ -10,7 +10,7 @@ import { Test } from '../test'; import { Vector3Like } from '@microsoft/mixed-reality-extension-sdk'; export default class PhysicsHeadCollisionTest extends Test { - private assets: MRE.AssetContainer; + private assets: MRE.AssetContainer; private b0: MRE.Actor; private b1: MRE.Actor; @@ -18,9 +18,9 @@ export default class PhysicsHeadCollisionTest extends Test { private redMat: MRE.Material; private blueMat: MRE.Material; - public async run(root: MRE.Actor): Promise { - this.assets = new MRE.AssetContainer(this.app.context); - + public async run(root: MRE.Actor): Promise { + this.assets = new MRE.AssetContainer(this.app.context); + this.redMat = this.assets.createMaterial('redBall', { color: MRE.Color3.Red() }); @@ -28,31 +28,29 @@ export default class PhysicsHeadCollisionTest extends Test { color: MRE.Color3.Blue() }); - if (this.app.context.users.length > 0) - { + if (this.app.context.users.length > 0) { const userId = this.app.context.users[0].id; this.createLabel(root, "RED", MRE.Color3.Red(), userId); - this.spawnBall(root, -1.5, 0.2, this.redMat, userId, { x: 1000, y: 0, z: 0}); + this.spawnBall(root, -1.5, 0.2, this.redMat, userId, { x: 1000, y: 0, z: 0 }); } - if (this.app.context.users.length > 1) - { + if (this.app.context.users.length > 1) { const userId = this.app.context.users[1].id; this.createLabel(root, "BLUE", MRE.Color3.Blue(), userId); - this.spawnBall(root, +1.5, 0.2, this.blueMat, userId, { x: -1000, y: 0, z: 0}); + this.spawnBall(root, +1.5, 0.2, this.blueMat, userId, { x: -1000, y: 0, z: 0 }); } await this.stoppedAsync(); return true; - } - + } + private createLabel(root: MRE.Actor, text: string, col: MRE.Color3, userId: MRE.Guid) { - const label = MRE.Actor.Create(this.app.context, { + MRE.Actor.Create(this.app.context, { actor: { - name: 'label', - parentId: root.id, - exclusiveToUser: userId, + name: 'label', + parentId: root.id, + exclusiveToUser: userId, transform: { local: { position: { y: 1.5 } } }, text: { contents: text, @@ -61,14 +59,14 @@ export default class PhysicsHeadCollisionTest extends Test { color: col } } - }); + }); } - - private spawnBall(root: MRE.Actor, width: number, height: number, mat: MRE.Material, userId: MRE.Guid, + + private spawnBall(root: MRE.Actor, width: number, height: number, mat: MRE.Material, userId: MRE.Guid, force: Partial, ballRadius = 0.2, killTimeout = 5000) { const ball = MRE.Actor.Create(this.app.context, { actor: { - owner: userId, + owner: userId, parentId: root.id, name: "ball", appearance: { @@ -83,10 +81,10 @@ export default class PhysicsHeadCollisionTest extends Test { }, collider: { geometry: { shape: MRE.ColliderType.Auto } } } - }); + }); setTimeout(() => { - ball.rigidBody.addForce( force ) + ball.rigidBody.addForce(force) }, 1000); setTimeout(() => { diff --git a/packages/sdk/src/actor/physics/physicsBridge.ts b/packages/sdk/src/actor/physics/physicsBridge.ts index 3cf429d46..9f448ed9b 100644 --- a/packages/sdk/src/actor/physics/physicsBridge.ts +++ b/packages/sdk/src/actor/physics/physicsBridge.ts @@ -11,9 +11,8 @@ export interface PhysicsBridgeTransformInfo { transform: Partial; } - export interface PhysicsBridgeTransformUpdate { +export interface PhysicsBridgeTransformUpdate { id: Guid; time: number; transforms: Array>; - } - \ No newline at end of file +}