Reflect SDK changes (#28)
This commit is contained in:
Родитель
2c23535825
Коммит
e0704b4ce6
|
@ -66,4 +66,5 @@ built/
|
||||||
|
|
||||||
app.zip
|
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
|
// Optionally, we also repeat the animation infinitely. PingPong alternately runs the animation
|
||||||
// foward then backward.
|
// foward then backward.
|
||||||
wrapMode: AnimationWrapMode.PingPong
|
wrapMode: AnimationWrapMode.PingPong
|
||||||
}).catch(reason => console.log(`Failed to create spin animation: ${reason}`));
|
});
|
||||||
|
|
||||||
// Load a glTF model
|
// Load a glTF model
|
||||||
const cubePromise = Actor.CreateFromGLTF(this.context, {
|
const cubePromise = Actor.CreateFromGLTF(this.context, {
|
||||||
|
@ -94,7 +94,7 @@ export default class HelloWorld {
|
||||||
'DoAFlip', {
|
'DoAFlip', {
|
||||||
keyframes: this.generateSpinKeyframes(1.0, Vector3.Right()),
|
keyframes: this.generateSpinKeyframes(1.0, Vector3.Right()),
|
||||||
events: []
|
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
|
// Now that the text and its animation are all being set up, we can start playing
|
||||||
// the animation.
|
// the animation.
|
||||||
|
|
|
@ -55,10 +55,10 @@ export default class SolarSystem {
|
||||||
this.context.onStopped(() => this.stopped());
|
this.context.onStopped(() => this.stopped());
|
||||||
}
|
}
|
||||||
|
|
||||||
private started = async () => {
|
private started = () => {
|
||||||
console.log(`session started ${this.context.sessionId}`);
|
console.log(`session started ${this.context.sessionId}`);
|
||||||
|
|
||||||
await this.createSolarSystem();
|
this.createSolarSystem();
|
||||||
|
|
||||||
const sunEntity = this.celestialBodies.sol;
|
const sunEntity = this.celestialBodies.sol;
|
||||||
if (sunEntity && sunEntity.model) {
|
if (sunEntity && sunEntity.model) {
|
||||||
|
@ -104,13 +104,11 @@ export default class SolarSystem {
|
||||||
console.log(`user-left: ${user.name}`);
|
console.log(`user-left: ${user.name}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
private createSolarSystem(): Promise<any> {
|
private createSolarSystem() {
|
||||||
const promises = [];
|
|
||||||
const keys = Object.keys(database);
|
const keys = Object.keys(database);
|
||||||
for (const bodyName of keys) {
|
for (const bodyName of keys) {
|
||||||
promises.push(this.createBody(bodyName));
|
this.createBody(bodyName);
|
||||||
}
|
}
|
||||||
return Promise.all(promises);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private resumeAnimations() {
|
private resumeAnimations() {
|
||||||
|
@ -131,7 +129,7 @@ export default class SolarSystem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private createBody(bodyName: string): Promise<any> {
|
private createBody(bodyName: string) {
|
||||||
console.log(`Loading ${bodyName}`);
|
console.log(`Loading ${bodyName}`);
|
||||||
|
|
||||||
const facts = database[bodyName];
|
const facts = database[bodyName];
|
||||||
|
@ -229,31 +227,22 @@ export default class SolarSystem {
|
||||||
model: model.value
|
model: model.value
|
||||||
} as CelestialBody;
|
} as CelestialBody;
|
||||||
|
|
||||||
return Promise.all([
|
this.createAnimations(bodyName);
|
||||||
inclination,
|
|
||||||
position,
|
|
||||||
obliquity0,
|
|
||||||
obliquity1,
|
|
||||||
model,
|
|
||||||
this.createAnimations(bodyName)
|
|
||||||
]);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("createBody failed", bodyName, e);
|
console.log("createBody failed", bodyName, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private createAnimations(bodyName: string): Promise<any> {
|
private createAnimations(bodyName: string) {
|
||||||
const promises: Array<Promise<any>> = [];
|
this.createAxialAnimation(bodyName);
|
||||||
promises.push(this.createAxialAnimation(bodyName));
|
this.createOrbitalAnimation(bodyName);
|
||||||
promises.push(this.createOrbitalAnimation(bodyName));
|
|
||||||
return Promise.all(promises);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly timeFactor = 40;
|
public readonly timeFactor = 40;
|
||||||
public readonly axialKeyframeCount = 90;
|
public readonly axialKeyframeCount = 90;
|
||||||
public readonly orbitalKeyframeCount = 90;
|
public readonly orbitalKeyframeCount = 90;
|
||||||
|
|
||||||
private createAxialAnimation(bodyName: string): Promise<any> {
|
private createAxialAnimation(bodyName: string) {
|
||||||
const facts = database[bodyName];
|
const facts = database[bodyName];
|
||||||
const celestialBody = this.celestialBodies[bodyName];
|
const celestialBody = this.celestialBodies[bodyName];
|
||||||
|
|
||||||
|
@ -294,7 +283,7 @@ export default class SolarSystem {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create the animation on the actor
|
// Create the animation on the actor
|
||||||
return celestialBody.model.createAnimation(
|
celestialBody.model.createAnimation(
|
||||||
`${bodyName}:axial`, {
|
`${bodyName}:axial`, {
|
||||||
keyframes,
|
keyframes,
|
||||||
events: [],
|
events: [],
|
||||||
|
@ -303,7 +292,7 @@ export default class SolarSystem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private createOrbitalAnimation(bodyName: string): Promise<any> {
|
private createOrbitalAnimation(bodyName: string) {
|
||||||
const facts = database[bodyName];
|
const facts = database[bodyName];
|
||||||
const celestialBody = this.celestialBodies[bodyName];
|
const celestialBody = this.celestialBodies[bodyName];
|
||||||
|
|
||||||
|
@ -343,7 +332,7 @@ export default class SolarSystem {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create the animation on the actor
|
// Create the animation on the actor
|
||||||
return celestialBody.position.createAnimation(
|
celestialBody.position.createAnimation(
|
||||||
`${bodyName}:orbital`, {
|
`${bodyName}:orbital`, {
|
||||||
keyframes,
|
keyframes,
|
||||||
events: [],
|
events: [],
|
||||||
|
|
|
@ -96,7 +96,7 @@ export default class TicTacToe {
|
||||||
|
|
||||||
// Here we create an animation on our text actor. Animations have three mandatory arguments:
|
// 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.
|
// 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.
|
// The name is a unique identifier for this animation. We'll pass it to "startAnimation" later.
|
||||||
"Spin", {
|
"Spin", {
|
||||||
// Keyframes define the timeline for the animation: where the actor should be, and when.
|
// 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.
|
// Optionally, we also repeat the animation infinitely.
|
||||||
wrapMode: AnimationWrapMode.Loop
|
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 tileIndexX = 0; tileIndexX < 3; tileIndexX++) {
|
||||||
for (let tileIndexZ = 0; tileIndexZ < 3; tileIndexZ++) {
|
for (let tileIndexZ = 0; tileIndexZ < 3; tileIndexZ++) {
|
||||||
|
@ -139,19 +136,19 @@ export default class TicTacToe {
|
||||||
'GrowIn', {
|
'GrowIn', {
|
||||||
keyframes: this.growAnimationData,
|
keyframes: this.growAnimationData,
|
||||||
events: []
|
events: []
|
||||||
}).catch(reason => console.log(`Failed to create grow animation: ${reason}`));
|
});
|
||||||
|
|
||||||
cube.createAnimation(
|
cube.createAnimation(
|
||||||
'ShrinkOut', {
|
'ShrinkOut', {
|
||||||
keyframes: this.shrinkAnimationData,
|
keyframes: this.shrinkAnimationData,
|
||||||
events: []
|
events: []
|
||||||
}).catch(reason => console.log(`Failed to create shrink animation: ${reason}`));
|
});
|
||||||
|
|
||||||
cube.createAnimation(
|
cube.createAnimation(
|
||||||
'DoAFlip', {
|
'DoAFlip', {
|
||||||
keyframes: this.generateSpinKeyframes(1.0, Vector3.Right()),
|
keyframes: this.generateSpinKeyframes(1.0, Vector3.Right()),
|
||||||
events: []
|
events: []
|
||||||
}).catch(reason => console.log(`Failed to create flip animation: ${reason}`));
|
});
|
||||||
|
|
||||||
// Set up cursor interaction. We add the input behavior ButtonBehavior to the cube.
|
// 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.
|
// Button behaviors have two pairs of events: hover start/stop, and click start/stop.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче