Merge pull request #33 from Microsoft/tombu/app-coord
This commit is contained in:
Коммит
a6e9ada58a
|
@ -36,7 +36,7 @@ export default class HelloWorld {
|
|||
actor: {
|
||||
name: 'Text',
|
||||
transform: {
|
||||
position: { x: 0, y: 0.5, z: 0 }
|
||||
app: { position: { x: 0, y: 0.5, z: 0 } }
|
||||
},
|
||||
text: {
|
||||
contents: "Hello World!",
|
||||
|
@ -80,8 +80,10 @@ export default class HelloWorld {
|
|||
// Parent the glTF model to the text actor.
|
||||
parentId: this.text.id,
|
||||
transform: {
|
||||
position: { x: 0, y: -1, z: 0 },
|
||||
scale: { x: 0.4, y: 0.4, z: 0.4 }
|
||||
local: {
|
||||
position: { x: 0, y: -1, z: 0 },
|
||||
scale: { x: 0.4, y: 0.4, z: 0.4 }
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -107,11 +109,11 @@ export default class HelloWorld {
|
|||
// Trigger the grow/shrink animations on hover.
|
||||
buttonBehavior.onHover('enter', (userId: string) => {
|
||||
this.cube.animateTo(
|
||||
{ transform: { scale: { x: 0.5, y: 0.5, z: 0.5 } } }, 0.3, AnimationEaseCurves.EaseOutSine);
|
||||
{ transform: { local: { scale: { x: 0.5, y: 0.5, z: 0.5 } } } }, 0.3, AnimationEaseCurves.EaseOutSine);
|
||||
});
|
||||
buttonBehavior.onHover('exit', (userId: string) => {
|
||||
this.cube.animateTo(
|
||||
{ transform: { scale: { x: 0.4, y: 0.4, z: 0.4 } } }, 0.3, AnimationEaseCurves.EaseOutSine);
|
||||
{ transform: { local: { scale: { x: 0.4, y: 0.4, z: 0.4 } } } }, 0.3, AnimationEaseCurves.EaseOutSine);
|
||||
});
|
||||
|
||||
// When clicked, do a 360 sideways.
|
||||
|
@ -128,19 +130,19 @@ export default class HelloWorld {
|
|||
private generateSpinKeyframes(duration: number, axis: Vector3): AnimationKeyframe[] {
|
||||
return [{
|
||||
time: 0 * duration,
|
||||
value: { transform: { rotation: Quaternion.RotationAxis(axis, 0) } }
|
||||
value: { transform: { local: { rotation: Quaternion.RotationAxis(axis, 0) } } }
|
||||
}, {
|
||||
time: 0.25 * duration,
|
||||
value: { transform: { rotation: Quaternion.RotationAxis(axis, Math.PI / 2) } }
|
||||
value: { transform: { local: { rotation: Quaternion.RotationAxis(axis, Math.PI / 2) } } }
|
||||
}, {
|
||||
time: 0.5 * duration,
|
||||
value: { transform: { rotation: Quaternion.RotationAxis(axis, Math.PI) } }
|
||||
value: { transform: { local: { rotation: Quaternion.RotationAxis(axis, Math.PI) } } }
|
||||
}, {
|
||||
time: 0.75 * duration,
|
||||
value: { transform: { rotation: Quaternion.RotationAxis(axis, 3 * Math.PI / 2) } }
|
||||
value: { transform: { local: { rotation: Quaternion.RotationAxis(axis, 3 * Math.PI / 2) } } }
|
||||
}, {
|
||||
time: 1 * duration,
|
||||
value: { transform: { rotation: Quaternion.RotationAxis(axis, 2 * Math.PI) } }
|
||||
value: { transform: { local: { rotation: Quaternion.RotationAxis(axis, 2 * Math.PI) } } }
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,11 @@ export default class SolarSystem {
|
|||
const sunPrimitives = sun.findChildrenByName('Primitive', true);
|
||||
|
||||
sunPrimitives.forEach((prim) => {
|
||||
// Add a collider so that the behavior system will work properly on Unity host apps.
|
||||
const center = { x: 0, y: 0, z: 0} as MRESDK.Vector3Like;
|
||||
const radius = 3;
|
||||
prim.setCollider('sphere', false, center, radius);
|
||||
|
||||
const buttonBehavior = prim.setBehavior(MRESDK.ButtonBehavior);
|
||||
|
||||
buttonBehavior.onClick('pressed', (userId: string) => {
|
||||
|
@ -157,7 +162,7 @@ export default class SolarSystem {
|
|||
actor: {
|
||||
name: `${bodyName}-inclination`,
|
||||
transform: {
|
||||
rotation: inclinationValue
|
||||
app: { rotation: inclinationValue }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -166,7 +171,7 @@ export default class SolarSystem {
|
|||
name: `${bodyName}-position`,
|
||||
parentId: inclination.value.id,
|
||||
transform: {
|
||||
position: positionValue
|
||||
local: { position: positionValue }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -175,7 +180,7 @@ export default class SolarSystem {
|
|||
name: `${bodyName}-label`,
|
||||
parentId: position.value.id,
|
||||
transform: {
|
||||
position: { y: 0.1 + Math.pow(scaleMultiplier, 1 / 2.5) }
|
||||
local: { position: { y: 0.1 + Math.pow(scaleMultiplier, 1 / 2.5) } }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -190,7 +195,7 @@ export default class SolarSystem {
|
|||
name: `${bodyName}-obliquity1`,
|
||||
parentId: obliquity0.value.id,
|
||||
transform: {
|
||||
rotation: obliquityValue
|
||||
local: { rotation: obliquityValue }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -201,9 +206,10 @@ export default class SolarSystem {
|
|||
name: `${bodyName}-body`,
|
||||
parentId: obliquity1.value.id,
|
||||
transform: {
|
||||
scale: scaleValue
|
||||
local: { scale: scaleValue }
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
label.value.enableText({
|
||||
|
@ -253,7 +259,7 @@ export default class SolarSystem {
|
|||
const timeStep = axisTimeInSeconds / this.axialKeyframeCount;
|
||||
const keyframes: MRESDK.AnimationKeyframe[] = [];
|
||||
const angleStep = 360 / this.axialKeyframeCount;
|
||||
const initial = celestialBody.model.transform.rotation.clone();
|
||||
const initial = celestialBody.model.transform.local.rotation.clone();
|
||||
let value: Partial<MRESDK.ActorLike>;
|
||||
|
||||
for (let i = 0; i < this.axialKeyframeCount; ++i) {
|
||||
|
@ -262,7 +268,7 @@ export default class SolarSystem {
|
|||
const rotation = initial.multiply(rotDelta);
|
||||
value = {
|
||||
transform: {
|
||||
rotation
|
||||
local: { rotation }
|
||||
}
|
||||
};
|
||||
keyframes.push({
|
||||
|
@ -274,7 +280,7 @@ export default class SolarSystem {
|
|||
// Final frame
|
||||
value = {
|
||||
transform: {
|
||||
rotation: celestialBody.model.transform.rotation
|
||||
local: { rotation: celestialBody.model.transform.local.rotation }
|
||||
}
|
||||
};
|
||||
keyframes.push({
|
||||
|
@ -302,7 +308,7 @@ export default class SolarSystem {
|
|||
const timeStep = orbitTimeInSeconds / this.orbitalKeyframeCount;
|
||||
const angleStep = 360 / this.orbitalKeyframeCount;
|
||||
const keyframes: MRESDK.AnimationKeyframe[] = [];
|
||||
const initial = celestialBody.position.transform.position.clone();
|
||||
const initial = celestialBody.position.transform.local.position.clone();
|
||||
let value: Partial<MRESDK.ActorLike>;
|
||||
|
||||
for (let i = 0; i < this.orbitalKeyframeCount; ++i) {
|
||||
|
@ -311,7 +317,7 @@ export default class SolarSystem {
|
|||
const position = initial.rotateByQuaternionToRef(rotDelta, new MRESDK.Vector3());
|
||||
value = {
|
||||
transform: {
|
||||
position
|
||||
local: { position }
|
||||
}
|
||||
};
|
||||
keyframes.push({
|
||||
|
@ -323,7 +329,7 @@ export default class SolarSystem {
|
|||
// Final frame
|
||||
value = {
|
||||
transform: {
|
||||
position: celestialBody.position.transform.position
|
||||
local: { position: celestialBody.position.transform.local.position }
|
||||
}
|
||||
};
|
||||
keyframes.push({
|
||||
|
|
|
@ -69,7 +69,7 @@ export default class TicTacToe {
|
|||
actor: {
|
||||
name: 'TextAnchor',
|
||||
transform: {
|
||||
position: { x: 0, y: 1.2, z: 0 }
|
||||
app: { position: { x: 0, y: 1.2, z: 0 } }
|
||||
},
|
||||
}
|
||||
});
|
||||
|
@ -80,7 +80,7 @@ export default class TicTacToe {
|
|||
parentId: this.textAnchor.id,
|
||||
name: 'Text',
|
||||
transform: {
|
||||
position: { x: 0, y: 0.0, z: -1.5 }
|
||||
local: { position: { x: 0, y: 0.0, z: -1.5 } }
|
||||
},
|
||||
text: {
|
||||
contents: "Tic-Tac-Toe!",
|
||||
|
@ -95,8 +95,10 @@ export default class TicTacToe {
|
|||
parentId: textPromise.value.id,
|
||||
name: 'Light',
|
||||
transform: {
|
||||
position: { x: 0, y: 1.0, z: -0.5 },
|
||||
rotation: Quaternion.RotationAxis(Vector3.Left(), -45.0 * DegreesToRadians),
|
||||
local: {
|
||||
position: { x: 0, y: 1.0, z: -0.5 },
|
||||
rotation: Quaternion.RotationAxis(Vector3.Left(), -45.0 * DegreesToRadians),
|
||||
}
|
||||
},
|
||||
light: {
|
||||
color: { r: 1, g: 0.6, b: 0.3 },
|
||||
|
@ -142,8 +144,10 @@ export default class TicTacToe {
|
|||
actor: {
|
||||
name: 'Altspace Cube',
|
||||
transform: {
|
||||
position: { x: (tileIndexX) - 1.0, y: 0.5, z: (tileIndexZ) - 1.0 },
|
||||
scale: { x: 0.4, y: 0.4, z: 0.4 }
|
||||
app: {
|
||||
position: { x: (tileIndexX) - 1.0, y: 0.5, z: (tileIndexZ) - 1.0 },
|
||||
},
|
||||
local: { scale: { x: 0.4, y: 0.4, z: 0.4 } }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -200,9 +204,9 @@ export default class TicTacToe {
|
|||
console.log("Putting an " + GamePiece[this.currentPlayerGamePiece] +
|
||||
" on: (" + tileIndexX + "," + tileIndexZ + ")");
|
||||
const gamePiecePosition: Vector3 = new Vector3(
|
||||
cube.transform.position.x,
|
||||
cube.transform.position.y + 0.55,
|
||||
cube.transform.position.z);
|
||||
cube.transform.local.position.x,
|
||||
cube.transform.local.position.y + 0.55,
|
||||
cube.transform.local.position.z);
|
||||
if (this.currentPlayerGamePiece === GamePiece.O) {
|
||||
this.gamePieceActors.push(Actor.CreatePrimitive(this.context, {
|
||||
definition: {
|
||||
|
@ -214,7 +218,7 @@ export default class TicTacToe {
|
|||
actor: {
|
||||
name: 'O',
|
||||
transform: {
|
||||
position: gamePiecePosition
|
||||
local: { position: gamePiecePosition }
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
@ -227,7 +231,7 @@ export default class TicTacToe {
|
|||
actor: {
|
||||
name: 'X',
|
||||
transform: {
|
||||
position: gamePiecePosition
|
||||
local: { position: gamePiecePosition }
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
@ -322,35 +326,35 @@ export default class TicTacToe {
|
|||
private generateSpinKeyframes(duration: number, axis: Vector3): AnimationKeyframe[] {
|
||||
return [{
|
||||
time: 0 * duration,
|
||||
value: { transform: { rotation: Quaternion.RotationAxis(axis, 0) } }
|
||||
value: { transform: { local: { rotation: Quaternion.RotationAxis(axis, 0) } } }
|
||||
}, {
|
||||
time: 0.25 * duration,
|
||||
value: { transform: { rotation: Quaternion.RotationAxis(axis, Math.PI / 2) } }
|
||||
value: { transform: { local: { rotation: Quaternion.RotationAxis(axis, Math.PI / 2) } } }
|
||||
}, {
|
||||
time: 0.5 * duration,
|
||||
value: { transform: { rotation: Quaternion.RotationAxis(axis, Math.PI) } }
|
||||
value: { transform: { local: { rotation: Quaternion.RotationAxis(axis, Math.PI) } } }
|
||||
}, {
|
||||
time: 0.75 * duration,
|
||||
value: { transform: { rotation: Quaternion.RotationAxis(axis, 3 * Math.PI / 2) } }
|
||||
value: { transform: { local: { rotation: Quaternion.RotationAxis(axis, 3 * Math.PI / 2) } } }
|
||||
}, {
|
||||
time: 1 * duration,
|
||||
value: { transform: { rotation: Quaternion.RotationAxis(axis, 2 * Math.PI) } }
|
||||
value: { transform: { local: { rotation: Quaternion.RotationAxis(axis, 2 * Math.PI) } } }
|
||||
}];
|
||||
}
|
||||
|
||||
private growAnimationData: AnimationKeyframe[] = [{
|
||||
time: 0,
|
||||
value: { transform: { scale: { x: 0.4, y: 0.4, z: 0.4 } } }
|
||||
value: { transform: { local: { scale: { x: 0.4, y: 0.4, z: 0.4 } } } }
|
||||
}, {
|
||||
time: 0.3,
|
||||
value: { transform: { scale: { x: 0.5, y: 0.5, z: 0.5 } } }
|
||||
value: { transform: { local: { scale: { x: 0.5, y: 0.5, z: 0.5 } } } }
|
||||
}];
|
||||
|
||||
private shrinkAnimationData: AnimationKeyframe[] = [{
|
||||
time: 0,
|
||||
value: { transform: { scale: { x: 0.5, y: 0.5, z: 0.5 } } }
|
||||
value: { transform: { local: { scale: { x: 0.5, y: 0.5, z: 0.5 } } } }
|
||||
}, {
|
||||
time: 0.3,
|
||||
value: { transform: { scale: { x: 0.4, y: 0.4, z: 0.4 } } }
|
||||
value: { transform: { local: { scale: { x: 0.4, y: 0.4, z: 0.4 } } } }
|
||||
}];
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ export default class WearAHat {
|
|||
parentId: menu.id,
|
||||
name: hatId,
|
||||
transform: {
|
||||
position: { x: 0, y, z: 0 }
|
||||
local: { position: { x: 0, y, z: 0 } }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -121,7 +121,7 @@ export default class WearAHat {
|
|||
anchor: MRESDK.TextAnchorLocation.MiddleLeft
|
||||
},
|
||||
transform: {
|
||||
position: { x: 0.5, y, z: 0 }
|
||||
local: { position: { x: 0.5, y, z: 0 } }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -140,7 +140,7 @@ export default class WearAHat {
|
|||
color: MRESDK.Color3.Yellow()
|
||||
},
|
||||
transform: {
|
||||
position: { x: 0.5, y: y + 0.25, z: 0 }
|
||||
local: { position: { x: 0.5, y: y + 0.25, z: 0 } }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -190,12 +190,14 @@ export default class WearAHat {
|
|||
prefabId: this.prefabs[hatId].prefabs.byIndex(0).id,
|
||||
actor: {
|
||||
transform: {
|
||||
position: hatRecord.position,
|
||||
rotation: MRESDK.Quaternion.FromEulerAngles(
|
||||
hatRecord.rotation.x * MRESDK.DegreesToRadians,
|
||||
hatRecord.rotation.y * MRESDK.DegreesToRadians,
|
||||
hatRecord.rotation.z * MRESDK.DegreesToRadians),
|
||||
scale: hatRecord.scale,
|
||||
local: {
|
||||
position: hatRecord.position,
|
||||
rotation: MRESDK.Quaternion.FromEulerAngles(
|
||||
hatRecord.rotation.x * MRESDK.DegreesToRadians,
|
||||
hatRecord.rotation.y * MRESDK.DegreesToRadians,
|
||||
hatRecord.rotation.z * MRESDK.DegreesToRadians),
|
||||
scale: hatRecord.scale,
|
||||
}
|
||||
},
|
||||
attachment: {
|
||||
attachPoint: 'head',
|
||||
|
|
Загрузка…
Ссылка в новой задаче