Skip to content
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.

Commit

Permalink
Jabenk/physics merge1 (#564)
Browse files Browse the repository at this point in the history
* [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 <steven.vergenz@microsoft.com>
Co-authored-by: Eric Anderson <eanders@microsoft.com>
  • Loading branch information
3 people authored and nik0la31 committed May 20, 2020
1 parent c2809a2 commit 08cc8f0
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 64 deletions.
42 changes: 20 additions & 22 deletions packages/functional-tests/src/tests/physics-collision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,47 @@ 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;

private redMat: MRE.Material;
private blueMat: MRE.Material;

public async run(root: MRE.Actor): Promise<boolean> {
this.assets = new MRE.AssetContainer(this.app.context);
public async run(root: MRE.Actor): Promise<boolean> {
this.assets = new MRE.AssetContainer(this.app.context);

this.redMat = this.assets.createMaterial('redBall', {
color: MRE.Color3.Red()
});
this.blueMat = this.assets.createMaterial('blueBall', {
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,
Expand All @@ -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<MRE.Vector3Like>, ballRadius = 0.2, killTimeout = 5000) {
const ball = MRE.Actor.Create(this.app.context, {
actor: {
owner: userId,
owner: userId,
parentId: root.id,
name: "ball",
appearance: {
Expand All @@ -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(() => {
Expand Down
32 changes: 15 additions & 17 deletions packages/functional-tests/src/tests/physics-free-fall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,37 @@ export default class PhysicsFreeFallTest extends Test {

public async run(root: MRE.Actor): Promise<boolean> {
this.assets = new MRE.AssetContainer(this.app.context);

this.redMat = this.assets.createMaterial('redBall', {
color: MRE.Color3.Red()
});
this.blueMat = this.assets.createMaterial('blueBall', {
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);
}

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,
Expand All @@ -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: {
Expand All @@ -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
Expand Down
42 changes: 20 additions & 22 deletions packages/functional-tests/src/tests/physics-head-collision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,47 @@ 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;

private redMat: MRE.Material;
private blueMat: MRE.Material;

public async run(root: MRE.Actor): Promise<boolean> {
this.assets = new MRE.AssetContainer(this.app.context);
public async run(root: MRE.Actor): Promise<boolean> {
this.assets = new MRE.AssetContainer(this.app.context);

this.redMat = this.assets.createMaterial('redBall', {
color: MRE.Color3.Red()
});
this.blueMat = this.assets.createMaterial('blueBall', {
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,
Expand All @@ -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<Vector3Like>, ballRadius = 0.2, killTimeout = 5000) {
const ball = MRE.Actor.Create(this.app.context, {
actor: {
owner: userId,
owner: userId,
parentId: root.id,
name: "ball",
appearance: {
Expand All @@ -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(() => {
Expand Down
5 changes: 2 additions & 3 deletions packages/sdk/src/actor/physics/physicsBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ export interface PhysicsBridgeTransformInfo {
transform: Partial<TransformLike>;
}

export interface PhysicsBridgeTransformUpdate {
export interface PhysicsBridgeTransformUpdate {
id: Guid;
time: number;
transforms: Array<Partial<PhysicsBridgeTransformInfo>>;
}

}

0 comments on commit 08cc8f0

Please sign in to comment.