This commit is contained in:
Eric Anderson 2019-03-06 16:09:06 -08:00 коммит произвёл GitHub
Родитель 2c23535825
Коммит e0704b4ce6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 22 добавлений и 35 удалений

3
.gitignore поставляемый
Просмотреть файл

@ -66,4 +66,5 @@ built/
app.zip
.openode
.openode
Dockerfile

Просмотреть файл

@ -66,7 +66,7 @@ export default class HelloWorld {
// Optionally, we also repeat the animation infinitely. PingPong alternately runs the animation
// foward then backward.
wrapMode: AnimationWrapMode.PingPong
}).catch(reason => console.log(`Failed to create spin animation: ${reason}`));
});
// Load a glTF model
const cubePromise = Actor.CreateFromGLTF(this.context, {
@ -94,7 +94,7 @@ export default class HelloWorld {
'DoAFlip', {
keyframes: this.generateSpinKeyframes(1.0, Vector3.Right()),
events: []
}).catch(reason => console.log(`Failed to create flip animation: ${reason}`));
});
// Now that the text and its animation are all being set up, we can start playing
// the animation.

Просмотреть файл

@ -55,10 +55,10 @@ export default class SolarSystem {
this.context.onStopped(() => this.stopped());
}
private started = async () => {
private started = () => {
console.log(`session started ${this.context.sessionId}`);
await this.createSolarSystem();
this.createSolarSystem();
const sunEntity = this.celestialBodies.sol;
if (sunEntity && sunEntity.model) {
@ -104,13 +104,11 @@ export default class SolarSystem {
console.log(`user-left: ${user.name}`);
}
private createSolarSystem(): Promise<any> {
const promises = [];
private createSolarSystem() {
const keys = Object.keys(database);
for (const bodyName of keys) {
promises.push(this.createBody(bodyName));
this.createBody(bodyName);
}
return Promise.all(promises);
}
private resumeAnimations() {
@ -131,7 +129,7 @@ export default class SolarSystem {
}
}
private createBody(bodyName: string): Promise<any> {
private createBody(bodyName: string) {
console.log(`Loading ${bodyName}`);
const facts = database[bodyName];
@ -229,31 +227,22 @@ export default class SolarSystem {
model: model.value
} as CelestialBody;
return Promise.all([
inclination,
position,
obliquity0,
obliquity1,
model,
this.createAnimations(bodyName)
]);
this.createAnimations(bodyName);
} catch (e) {
console.log("createBody failed", bodyName, e);
}
}
private createAnimations(bodyName: string): Promise<any> {
const promises: Array<Promise<any>> = [];
promises.push(this.createAxialAnimation(bodyName));
promises.push(this.createOrbitalAnimation(bodyName));
return Promise.all(promises);
private createAnimations(bodyName: string) {
this.createAxialAnimation(bodyName);
this.createOrbitalAnimation(bodyName);
}
public readonly timeFactor = 40;
public readonly axialKeyframeCount = 90;
public readonly orbitalKeyframeCount = 90;
private createAxialAnimation(bodyName: string): Promise<any> {
private createAxialAnimation(bodyName: string) {
const facts = database[bodyName];
const celestialBody = this.celestialBodies[bodyName];
@ -294,7 +283,7 @@ export default class SolarSystem {
});
// Create the animation on the actor
return celestialBody.model.createAnimation(
celestialBody.model.createAnimation(
`${bodyName}:axial`, {
keyframes,
events: [],
@ -303,7 +292,7 @@ export default class SolarSystem {
}
}
private createOrbitalAnimation(bodyName: string): Promise<any> {
private createOrbitalAnimation(bodyName: string) {
const facts = database[bodyName];
const celestialBody = this.celestialBodies[bodyName];
@ -343,7 +332,7 @@ export default class SolarSystem {
});
// Create the animation on the actor
return celestialBody.position.createAnimation(
celestialBody.position.createAnimation(
`${bodyName}:orbital`, {
keyframes,
events: [],

Просмотреть файл

@ -96,7 +96,7 @@ export default class TicTacToe {
// Here we create an animation on our text actor. Animations have three mandatory arguments:
// a name, an array of keyframes, and an array of events.
const textAnimationPromise = this.textAnchor.createAnimation(
this.textAnchor.createAnimation(
// The name is a unique identifier for this animation. We'll pass it to "startAnimation" later.
"Spin", {
// Keyframes define the timeline for the animation: where the actor should be, and when.
@ -108,10 +108,7 @@ export default class TicTacToe {
// Optionally, we also repeat the animation infinitely.
wrapMode: AnimationWrapMode.Loop
}).catch(reason => console.log(`Failed to create spin animation: ${reason}`));
// TODO: This shouldn't be necessary as playanimation should be awaiting the textanimation first.
await textAnimationPromise;
});
for (let tileIndexX = 0; tileIndexX < 3; tileIndexX++) {
for (let tileIndexZ = 0; tileIndexZ < 3; tileIndexZ++) {
@ -139,19 +136,19 @@ export default class TicTacToe {
'GrowIn', {
keyframes: this.growAnimationData,
events: []
}).catch(reason => console.log(`Failed to create grow animation: ${reason}`));
});
cube.createAnimation(
'ShrinkOut', {
keyframes: this.shrinkAnimationData,
events: []
}).catch(reason => console.log(`Failed to create shrink animation: ${reason}`));
});
cube.createAnimation(
'DoAFlip', {
keyframes: this.generateSpinKeyframes(1.0, Vector3.Right()),
events: []
}).catch(reason => console.log(`Failed to create flip animation: ${reason}`));
});
// Set up cursor interaction. We add the input behavior ButtonBehavior to the cube.
// Button behaviors have two pairs of events: hover start/stop, and click start/stop.