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/[email protected]
 - @microsoft/[email protected]
 - [email protected]
 - @microsoft/[email protected]
 - @microsoft/[email protected]

* 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/[email protected]
 - @microsoft/[email protected]
 - [email protected]
 - @microsoft/[email protected]
 - @microsoft/[email protected]

* 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 <[email protected]>
Co-authored-by: Eric Anderson <[email protected]>
  • Loading branch information
3 people authored Apr 30, 2020
1 parent db0f88c commit a846945
Show file tree
Hide file tree
Showing 21 changed files with 186 additions and 149 deletions.
2 changes: 1 addition & 1 deletion packages/altspacevr-extras/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/altspacevr-extras/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft/mixed-reality-extension-altspacevr-extras",
"version": "0.17.0",
"version": "0.17.1",
"description": "The Mixed Reality Extension AltspaceVR Extras package enables MRE developers to access custom AltspaceVR features.",
"main": "built/index.js",
"types": "built/index.d.ts",
Expand Down Expand Up @@ -41,6 +41,6 @@
"typescript": "^3.7.2"
},
"dependencies": {
"@microsoft/mixed-reality-extension-sdk": "^0.17.0"
"@microsoft/mixed-reality-extension-sdk": "^0.17.1"
}
}
2 changes: 1 addition & 1 deletion packages/common/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft/mixed-reality-extension-common",
"version": "0.17.0",
"version": "0.17.1",
"description": "Common components of the Mixed Reality Extension SDK.",
"main": "built/index.js",
"types": "built/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/functional-tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/functional-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "functional-tests",
"version": "0.17.0",
"version": "0.17.1",
"private": true,
"description": "",
"main": "built/server.js",
Expand All @@ -23,9 +23,9 @@
"typescript": "^3.7.2"
},
"dependencies": {
"@microsoft/gltf-gen": "^0.17.0",
"@microsoft/mixed-reality-extension-altspacevr-extras": "^0.17.0",
"@microsoft/mixed-reality-extension-sdk": "^0.17.0",
"@microsoft/gltf-gen": "^0.17.1",
"@microsoft/mixed-reality-extension-altspacevr-extras": "^0.17.1",
"@microsoft/mixed-reality-extension-sdk": "^0.17.1",
"@types/dotenv": "^6.1.0",
"@types/node": "^10.3.1",
"@types/restify": "^7.2.0",
Expand Down
63 changes: 36 additions & 27 deletions packages/functional-tests/src/tests/physics-bounce-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,26 @@ import * as MRE from '@microsoft/mixed-reality-extension-sdk';

import { Test } from '../test';

const defaultBallColor = MRE.Color3.FromInts(220, 150, 150);

export default class PhysicsBounceTest extends Test {
public expectedResultDescription = "Balls and boxes hit the ground and bounce.";
private assets: MRE.AssetContainer;
private interval: NodeJS.Timeout;
private ballboxMat: MRE.Material;
private materials: MRE.Material[] = [];
private bouncePlane: MRE.Actor;

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

this.ballboxMat = this.assets.createMaterial('ball', {
color: defaultBallColor
});
this.materials.push(this.assets.createMaterial('mat1',
{ color: MRE.Color3.FromHexString('#ff0000').toColor4() }));
this.materials.push(this.assets.createMaterial('mat2',
{ color: MRE.Color3.FromHexString('#ff7700').toColor4() }));
this.materials.push(this.assets.createMaterial('mat3',
{ color: MRE.Color3.FromHexString('#ffbd00').toColor4() }));
this.materials.push(this.assets.createMaterial('mat4',
{ color: MRE.Color3.FromHexString('#fcff00').toColor4() }));
this.materials.push(this.assets.createMaterial('mat5',
{ color: MRE.Color3.FromHexString('#abf300').toColor4() }));

this.createBouncePlane(root, 2, 1.25);

Expand All @@ -42,54 +47,58 @@ export default class PhysicsBounceTest extends Test {
actor: {
parentId: root.id,
appearance: {
meshId: box,
materialId: this.ballboxMat.id
meshId: box
},
transform: {
app: { position: { x: 0.0, y: 0.0, z: -1.0 } }
},
text: {
contents: `Bouncing balls and boxes`,
anchor: MRE.TextAnchorLocation.MiddleLeft,
height: .2
},
collider: { geometry: { shape: MRE.ColliderType.Auto },
bounciness: 0.8, dynamicFriction: 0.0, staticFriction: 0.0 }
collider: {
geometry: { shape: MRE.ColliderType.Auto },
bounciness: 0.8, dynamicFriction: 0.0, staticFriction: 0.0
}
}
});
}

private spawnBallOrBox(root: MRE.Actor, width: number, height: number, radius = 0.1, killTimeout = 20000) {
const isSphere = (Math.random() > 0.5);
const ballOrBoxID = ((isSphere)?(this.assets.createSphereMesh('ball', radius).id):
(this.assets.createBoxMesh('box', 1.5*radius, 1.8*radius, 2.1*radius).id));
const ballOrBoxID = ((isSphere) ? (this.assets.createSphereMesh('ball', radius).id) :
(this.assets.createBoxMesh('box', 1.5 * radius, 1.8 * radius, 2.1 * radius).id));
// create ball or box
const ballOrBall = MRE.Actor.Create(this.app.context, {
const ballOrBox = MRE.Actor.Create(this.app.context, {
actor: {
parentId: root.id,
appearance: {
meshId: ballOrBoxID,
materialId: this.ballboxMat.id
materialId: this.materials[Math.floor(Math.random() * this.materials.length)].id
},
transform: {
local: { position: { x: -width / 2 + width * Math.random(),
y: height, z: -(-0.1 + 0.2*Math.random()) } }
local: {
position: {
x: -width / 2 + width * Math.random(),
y: height, z: -(-0.1 + 0.2 * Math.random())
}
}
},
rigidBody: {
mass: 3,
// give the box or spere some initial velocities
angularVelocity: { x: 10*Math.random() - 5.0, y: 10.0*Math.random()-5.0,
z: 10*Math.random()-5.0},
velocity: {x: 0.0, y: 5*Math.random() - 2.5, z: -3.0*Math.random()},
angularVelocity: {
x: 10 * Math.random() - 5.0, y: 10.0 * Math.random() - 5.0,
z: 10 * Math.random() - 5.0
},
velocity: { x: 0.0, y: 5 * Math.random() - 2.5, z: -3.0 * Math.random() },
constraints: [MRE.RigidBodyConstraints.None]
},
collider: { geometry: { shape: MRE.ColliderType.Auto },
bounciness: 0.8, dynamicFriction: 0.0, staticFriction: 0.0 }
collider: {
geometry: { shape: MRE.ColliderType.Auto },
bounciness: 0.8, dynamicFriction: 0.0, staticFriction: 0.0
}
}
});

setTimeout(() => {
ballOrBall.destroy();
ballOrBox.destroy();
}, killTimeout);
}
}
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
Loading

0 comments on commit a846945

Please sign in to comment.