Update samples to MRE 0.15, TS 3.7, ESLint
This commit is contained in:
Родитель
83dee7d8f5
Коммит
a4d359db48
|
@ -69,4 +69,6 @@ app.zip
|
|||
.openode
|
||||
|
||||
# git .orig files
|
||||
.orig
|
||||
.orig
|
||||
|
||||
*.tsbuildinfo
|
|
@ -0,0 +1,105 @@
|
|||
module.exports = {
|
||||
"root": true,
|
||||
"env": {
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:@typescript-eslint/recommended-requiring-type-checking"
|
||||
],
|
||||
"globals": {
|
||||
"Atomics": "readonly",
|
||||
"SharedArrayBuffer": "readonly"
|
||||
},
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"tsconfigRootDir": __dirname,
|
||||
"ecmaVersion": 2018,
|
||||
"sourceType": "module",
|
||||
"project": "./tsconfig.json"
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint",
|
||||
"header"
|
||||
],
|
||||
"rules": {
|
||||
"block-spacing": ["warn", "always"],
|
||||
"brace-style": ["warn", "1tbs", {"allowSingleLine": true}],
|
||||
"curly": ["warn", "all"],
|
||||
"default-param-last": "warn",
|
||||
"eol-last": ["warn", "always"],
|
||||
"eqeqeq": ["error", "always"],
|
||||
"indent": [
|
||||
"warn",
|
||||
"tab",
|
||||
{
|
||||
"MemberExpression": "off",
|
||||
"SwitchCase": 1
|
||||
}
|
||||
],
|
||||
"linebreak-style": [
|
||||
"warn",
|
||||
"windows"
|
||||
],
|
||||
"max-classes-per-file": ["warn", 1],
|
||||
"max-len": ["error", 120],
|
||||
"no-console": "error",
|
||||
"no-div-regex": "error",
|
||||
"no-empty": ["error", { "allowEmptyCatch": true }],
|
||||
"no-labels": "error",
|
||||
"no-loop-func": "error",
|
||||
"no-multi-spaces": ["warn", {"ignoreEOLComments": true}],
|
||||
"no-multiple-empty-lines": "warn",
|
||||
"no-new": "error",
|
||||
"no-self-compare": "warn",
|
||||
"no-sequences": "error",
|
||||
"no-shadow": "warn",
|
||||
"no-unmodified-loop-condition": "error",
|
||||
"no-void": "error",
|
||||
"no-warning-comments": ["warn", {"terms": ["todo", "fixme", "tslint"]}],
|
||||
"prefer-const": "warn",
|
||||
"prefer-regex-literals": "warn",
|
||||
"require-unicode-regexp": "error",
|
||||
"yoda": "warn",
|
||||
|
||||
"@typescript-eslint/array-type": [
|
||||
"error",
|
||||
{ "default": "array-simple" }
|
||||
],
|
||||
"@typescript-eslint/ban-types": [
|
||||
"error",
|
||||
{
|
||||
"types": {
|
||||
"Object": "Use {} instead.",
|
||||
"String": "Use 'string' instead.",
|
||||
"Number": "Use 'number' instead.",
|
||||
"Boolean": "Use 'boolean' instead."
|
||||
}
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/camelcase": ["warn", {"allow": ["^_[a-z][A-Za-z0-9]*$"]}],
|
||||
"@typescript-eslint/explicit-function-return-type": "off",
|
||||
"@typescript-eslint/no-empty-function": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-floating-promises": "off",
|
||||
"@typescript-eslint/no-misused-promises": "off",
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"warn",
|
||||
{ "args": "none" }
|
||||
],
|
||||
"@typescript-eslint/unbound-method": "error",
|
||||
"header/header": [
|
||||
"error",
|
||||
"block",
|
||||
[
|
||||
"!",
|
||||
" * Copyright (c) Microsoft Corporation. All rights reserved.",
|
||||
" * Licensed under the MIT License.",
|
||||
" "
|
||||
]
|
||||
]
|
||||
}
|
||||
};
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -21,17 +21,20 @@
|
|||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"clean": "tsc --build --clean",
|
||||
"build": "tsc --build",
|
||||
"lint": "tslint -p ./tsconfig.json src/**/*.ts",
|
||||
"build": "tsc --build && eslint --ext .ts src",
|
||||
"lint": "eslint --ext .ts src",
|
||||
"start": "node .",
|
||||
"debug": "node --nolazy --inspect-brk=9229 ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "3.0.3"
|
||||
"@typescript-eslint/eslint-plugin": "^2.17.0",
|
||||
"@typescript-eslint/parser": "^2.17.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-plugin-header": "^3.0.0",
|
||||
"typescript": "^3.7.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@microsoft/mixed-reality-extension-sdk": "^0.13.1",
|
||||
"@microsoft/mixed-reality-extension-sdk": "^0.15.0",
|
||||
"@types/dotenv": "^6.1.0",
|
||||
"@types/node": "^10.3.1",
|
||||
"dotenv": "^6.2.0"
|
||||
|
|
|
@ -8,8 +8,10 @@ import dotenv from 'dotenv';
|
|||
import { resolve as resolvePath } from 'path';
|
||||
import App from './app';
|
||||
|
||||
/* eslint-disable no-console */
|
||||
process.on('uncaughtException', err => console.log('uncaughtException', err));
|
||||
process.on('unhandledRejection', reason => console.log('unhandledRejection', reason));
|
||||
/* eslint-enable no-console */
|
||||
|
||||
// Read .env if file exists
|
||||
dotenv.config();
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
module.exports = {
|
||||
"root": true,
|
||||
"env": {
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:@typescript-eslint/recommended-requiring-type-checking"
|
||||
],
|
||||
"globals": {
|
||||
"Atomics": "readonly",
|
||||
"SharedArrayBuffer": "readonly"
|
||||
},
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"tsconfigRootDir": __dirname,
|
||||
"ecmaVersion": 2018,
|
||||
"sourceType": "module",
|
||||
"project": "./tsconfig.json"
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint",
|
||||
"header"
|
||||
],
|
||||
"rules": {
|
||||
"block-spacing": ["warn", "always"],
|
||||
"brace-style": ["warn", "1tbs", {"allowSingleLine": true}],
|
||||
"curly": ["warn", "all"],
|
||||
"default-param-last": "warn",
|
||||
"eol-last": ["warn", "always"],
|
||||
"eqeqeq": ["error", "always"],
|
||||
"indent": [
|
||||
"warn",
|
||||
"tab",
|
||||
{
|
||||
"MemberExpression": "off",
|
||||
"SwitchCase": 1
|
||||
}
|
||||
],
|
||||
"linebreak-style": [
|
||||
"warn",
|
||||
"windows"
|
||||
],
|
||||
"max-classes-per-file": ["warn", 1],
|
||||
"max-len": ["error", 120],
|
||||
"no-console": "error",
|
||||
"no-div-regex": "error",
|
||||
"no-empty": ["error", { "allowEmptyCatch": true }],
|
||||
"no-labels": "error",
|
||||
"no-loop-func": "error",
|
||||
"no-multi-spaces": ["warn", {"ignoreEOLComments": true}],
|
||||
"no-multiple-empty-lines": "warn",
|
||||
"no-new": "error",
|
||||
"no-self-compare": "warn",
|
||||
"no-sequences": "error",
|
||||
"no-shadow": "warn",
|
||||
"no-unmodified-loop-condition": "error",
|
||||
"no-void": "error",
|
||||
"no-warning-comments": ["warn", {"terms": ["todo", "fixme", "tslint"]}],
|
||||
"prefer-const": "warn",
|
||||
"prefer-regex-literals": "warn",
|
||||
"require-unicode-regexp": "error",
|
||||
"yoda": "warn",
|
||||
|
||||
"@typescript-eslint/array-type": [
|
||||
"error",
|
||||
{ "default": "array-simple" }
|
||||
],
|
||||
"@typescript-eslint/ban-types": [
|
||||
"error",
|
||||
{
|
||||
"types": {
|
||||
"Object": "Use {} instead.",
|
||||
"String": "Use 'string' instead.",
|
||||
"Number": "Use 'number' instead.",
|
||||
"Boolean": "Use 'boolean' instead."
|
||||
}
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/camelcase": ["warn", {"allow": ["^_[a-z][A-Za-z0-9]*$"]}],
|
||||
"@typescript-eslint/explicit-function-return-type": "off",
|
||||
"@typescript-eslint/no-empty-function": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-floating-promises": "off",
|
||||
"@typescript-eslint/no-misused-promises": "off",
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"warn",
|
||||
{ "args": "none" }
|
||||
],
|
||||
"@typescript-eslint/unbound-method": "error",
|
||||
"header/header": [
|
||||
"error",
|
||||
"block",
|
||||
[
|
||||
"!",
|
||||
" * Copyright (c) Microsoft Corporation. All rights reserved.",
|
||||
" * Licensed under the MIT License.",
|
||||
" "
|
||||
]
|
||||
]
|
||||
}
|
||||
};
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -21,17 +21,20 @@
|
|||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"clean": "tsc --build --clean",
|
||||
"build": "tsc --build",
|
||||
"lint": "tslint -p ./tsconfig.json src/**/*.ts",
|
||||
"build": "tsc --build && eslint --ext .ts src",
|
||||
"lint": "eslint --ext .ts src",
|
||||
"start": "node .",
|
||||
"debug": "node --nolazy --inspect-brk=9229 ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "3.0.3"
|
||||
"@typescript-eslint/eslint-plugin": "^2.17.0",
|
||||
"@typescript-eslint/parser": "^2.17.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-plugin-header": "^3.0.0",
|
||||
"typescript": "^3.7.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@microsoft/mixed-reality-extension-sdk": "^0.13.1",
|
||||
"@microsoft/mixed-reality-extension-sdk": "^0.15.0",
|
||||
"@types/dotenv": "^6.1.0",
|
||||
"@types/node": "^10.3.1",
|
||||
"dotenv": "^6.2.0"
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
|
||||
import * as MRE from '@microsoft/mixed-reality-extension-sdk';
|
||||
import { log } from '@microsoft/mixed-reality-extension-sdk/built/log';
|
||||
|
||||
/**
|
||||
* Solar system database
|
||||
|
@ -38,7 +39,7 @@ interface CelestialBodySet {
|
|||
|
||||
// Data source: https://nssdc.gsfc.nasa.gov/planetary/dataheet/
|
||||
// (some settings modified for scale and dramatic effect)
|
||||
// tslint:disable-next-line:no-var-requires
|
||||
/* eslint-disable-next-line @typescript-eslint/no-var-requires */
|
||||
const database: Database = require('../public/database.json');
|
||||
|
||||
/**
|
||||
|
@ -51,15 +52,10 @@ export default class SolarSystem {
|
|||
|
||||
constructor(private context: MRE.Context, private baseUrl: string) {
|
||||
this.assets = new MRE.AssetContainer(context);
|
||||
this.context.onUserJoined(user => this.userJoined(user));
|
||||
this.context.onUserLeft(user => this.userLeft(user));
|
||||
this.context.onStarted(() => this.started());
|
||||
this.context.onStopped(() => this.stopped());
|
||||
}
|
||||
|
||||
private started = () => {
|
||||
console.log(`session started ${this.context.sessionId}`);
|
||||
|
||||
private started() {
|
||||
this.createSolarSystem();
|
||||
|
||||
const sunEntity = this.celestialBodies.sol;
|
||||
|
@ -70,7 +66,7 @@ export default class SolarSystem {
|
|||
sunPrimitives.forEach((prim) => {
|
||||
// Add a collider so that the behavior system will work properly on Unity host apps.
|
||||
const radius = 3;
|
||||
prim.setCollider('sphere', false, radius);
|
||||
prim.setCollider(MRE.ColliderType.Sphere, false, radius);
|
||||
|
||||
const buttonBehavior = prim.setBehavior(MRE.ButtonBehavior);
|
||||
|
||||
|
@ -83,14 +79,6 @@ export default class SolarSystem {
|
|||
this.animationsRunning = true;
|
||||
}
|
||||
});
|
||||
|
||||
buttonBehavior.onHover('enter', () => {
|
||||
console.log(`Hover entered on ${sunEntity.model.name}.`);
|
||||
});
|
||||
|
||||
buttonBehavior.onHover('exit', () => {
|
||||
console.log(`Hover exited on ${sunEntity.model.name}.`);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -98,18 +86,6 @@ export default class SolarSystem {
|
|||
this.animationsRunning = true;
|
||||
}
|
||||
|
||||
private stopped() {
|
||||
console.log(`session stopped ${this.context.sessionId}`);
|
||||
}
|
||||
|
||||
private userJoined(user: MRE.User) {
|
||||
console.log(`user-joined: ${user.name}, ${user.id}`);
|
||||
}
|
||||
|
||||
private userLeft(user: MRE.User) {
|
||||
console.log(`user-left: ${user.name}`);
|
||||
}
|
||||
|
||||
private createSolarSystem() {
|
||||
const keys = Object.keys(database);
|
||||
for (const bodyName of keys) {
|
||||
|
@ -136,7 +112,6 @@ export default class SolarSystem {
|
|||
}
|
||||
|
||||
private createBody(bodyName: string) {
|
||||
console.log(`Loading ${bodyName}`);
|
||||
|
||||
const facts = database[bodyName];
|
||||
|
||||
|
@ -210,7 +185,7 @@ export default class SolarSystem {
|
|||
},
|
||||
collider: {
|
||||
geometry: {
|
||||
shape: 'sphere',
|
||||
shape: MRE.ColliderType.Sphere,
|
||||
radius: 0.5
|
||||
}
|
||||
}
|
||||
|
@ -241,7 +216,7 @@ export default class SolarSystem {
|
|||
|
||||
this.createAnimations(bodyName);
|
||||
} catch (e) {
|
||||
console.log("createBody failed", bodyName, e);
|
||||
log.info('app', `createBody failed ${bodyName}, ${e}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,10 @@ import dotenv from 'dotenv';
|
|||
import { resolve as resolvePath } from 'path';
|
||||
import App from './app';
|
||||
|
||||
/* eslint-disable no-console */
|
||||
process.on('uncaughtException', err => console.log('uncaughtException', err));
|
||||
process.on('unhandledRejection', reason => console.log('unhandledRejection', reason));
|
||||
/* eslint-enable no-console */
|
||||
|
||||
// Read .env if file exists
|
||||
dotenv.config();
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
module.exports = {
|
||||
"root": true,
|
||||
"env": {
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:@typescript-eslint/recommended-requiring-type-checking"
|
||||
],
|
||||
"globals": {
|
||||
"Atomics": "readonly",
|
||||
"SharedArrayBuffer": "readonly"
|
||||
},
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"tsconfigRootDir": __dirname,
|
||||
"ecmaVersion": 2018,
|
||||
"sourceType": "module",
|
||||
"project": "./tsconfig.json"
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint",
|
||||
"header"
|
||||
],
|
||||
"rules": {
|
||||
"block-spacing": ["warn", "always"],
|
||||
"brace-style": ["warn", "1tbs", {"allowSingleLine": true}],
|
||||
"curly": ["warn", "all"],
|
||||
"default-param-last": "warn",
|
||||
"eol-last": ["warn", "always"],
|
||||
"eqeqeq": ["error", "always"],
|
||||
"indent": [
|
||||
"warn",
|
||||
"tab",
|
||||
{
|
||||
"MemberExpression": "off",
|
||||
"SwitchCase": 1
|
||||
}
|
||||
],
|
||||
"linebreak-style": [
|
||||
"warn",
|
||||
"windows"
|
||||
],
|
||||
"max-classes-per-file": ["warn", 1],
|
||||
"max-len": ["error", 120],
|
||||
"no-console": "error",
|
||||
"no-div-regex": "error",
|
||||
"no-empty": ["error", { "allowEmptyCatch": true }],
|
||||
"no-labels": "error",
|
||||
"no-loop-func": "error",
|
||||
"no-multi-spaces": ["warn", {"ignoreEOLComments": true}],
|
||||
"no-multiple-empty-lines": "warn",
|
||||
"no-new": "error",
|
||||
"no-self-compare": "warn",
|
||||
"no-sequences": "error",
|
||||
"no-shadow": "warn",
|
||||
"no-unmodified-loop-condition": "error",
|
||||
"no-void": "error",
|
||||
"no-warning-comments": ["warn", {"terms": ["todo", "fixme", "tslint"]}],
|
||||
"prefer-const": "warn",
|
||||
"prefer-regex-literals": "warn",
|
||||
"require-unicode-regexp": "error",
|
||||
"yoda": "warn",
|
||||
|
||||
"@typescript-eslint/array-type": [
|
||||
"error",
|
||||
{ "default": "array-simple" }
|
||||
],
|
||||
"@typescript-eslint/ban-types": [
|
||||
"error",
|
||||
{
|
||||
"types": {
|
||||
"Object": "Use {} instead.",
|
||||
"String": "Use 'string' instead.",
|
||||
"Number": "Use 'number' instead.",
|
||||
"Boolean": "Use 'boolean' instead."
|
||||
}
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/camelcase": ["warn", {"allow": ["^_[a-z][A-Za-z0-9]*$"]}],
|
||||
"@typescript-eslint/explicit-function-return-type": "off",
|
||||
"@typescript-eslint/no-empty-function": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-floating-promises": "off",
|
||||
"@typescript-eslint/no-misused-promises": "off",
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"warn",
|
||||
{ "args": "none" }
|
||||
],
|
||||
"@typescript-eslint/unbound-method": "error",
|
||||
"header/header": [
|
||||
"error",
|
||||
"block",
|
||||
[
|
||||
"!",
|
||||
" * Copyright (c) Microsoft Corporation. All rights reserved.",
|
||||
" * Licensed under the MIT License.",
|
||||
" "
|
||||
]
|
||||
]
|
||||
}
|
||||
};
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -21,17 +21,20 @@
|
|||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"clean": "tsc --build --clean",
|
||||
"build": "tsc --build",
|
||||
"lint": "tslint -p ./tsconfig.json src/**/*.ts",
|
||||
"build": "tsc --build && eslint --ext .ts src",
|
||||
"lint": "eslint --ext .ts src",
|
||||
"start": "node .",
|
||||
"debug": "node --nolazy --inspect-brk=9229 ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "3.0.3"
|
||||
"@typescript-eslint/eslint-plugin": "^2.17.0",
|
||||
"@typescript-eslint/parser": "^2.17.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-plugin-header": "^3.0.0",
|
||||
"typescript": "^3.7.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@microsoft/mixed-reality-extension-sdk": "^0.13.1",
|
||||
"@microsoft/mixed-reality-extension-sdk": "^0.15.0",
|
||||
"@types/dotenv": "^6.1.0",
|
||||
"@types/node": "^10.3.1",
|
||||
"dotenv": "^6.2.0"
|
||||
|
|
|
@ -11,11 +11,11 @@ import {
|
|||
ButtonBehavior,
|
||||
Context,
|
||||
DegreesToRadians,
|
||||
PrimitiveShape,
|
||||
Quaternion,
|
||||
TextAnchorLocation,
|
||||
Vector3
|
||||
} from '@microsoft/mixed-reality-extension-sdk';
|
||||
import { log } from '@microsoft/mixed-reality-extension-sdk/built/log';
|
||||
|
||||
enum GameState {
|
||||
Intro,
|
||||
|
@ -190,7 +190,7 @@ export default class TicTacToe {
|
|||
}
|
||||
});
|
||||
|
||||
buttonBehavior.onClick(_ => {
|
||||
buttonBehavior.onClick(() => {
|
||||
switch (this.gameState) {
|
||||
case GameState.Intro:
|
||||
this.beginGameStatePlay();
|
||||
|
@ -199,7 +199,7 @@ export default class TicTacToe {
|
|||
case GameState.Play:
|
||||
// When clicked, put down a tile, and do a victory check
|
||||
if (this.boardState[tileIndexX * 3 + tileIndexZ] === undefined) {
|
||||
console.log("Putting an " + GamePiece[this.currentPlayerGamePiece] +
|
||||
log.info("app", "Putting an " + GamePiece[this.currentPlayerGamePiece] +
|
||||
" on: (" + tileIndexX + "," + tileIndexZ + ")");
|
||||
const gamePiecePosition: Vector3 = new Vector3(
|
||||
cube.transform.local.position.x,
|
||||
|
@ -271,21 +271,21 @@ export default class TicTacToe {
|
|||
}
|
||||
|
||||
private beginGameStateCelebration(winner: GamePiece) {
|
||||
console.log("BeginGameState Celebration");
|
||||
log.info("app", "BeginGameState Celebration");
|
||||
this.gameState = GameState.Celebration;
|
||||
this.light.light.color = { r: 0.3, g: 1.0, b: 0.3 };
|
||||
|
||||
if (winner === undefined) {
|
||||
console.log("Tie");
|
||||
log.info("app", "Tie");
|
||||
this.text.text.contents = "Tie";
|
||||
} else {
|
||||
console.log("Winner: " + GamePiece[winner]);
|
||||
log.info("app", "Winner: " + GamePiece[winner]);
|
||||
this.text.text.contents = "Winner: " + GamePiece[winner];
|
||||
}
|
||||
}
|
||||
|
||||
private beginGameStateIntro() {
|
||||
console.log("BeginGameState Intro");
|
||||
log.info("app", "BeginGameState Intro");
|
||||
this.gameState = GameState.Intro;
|
||||
this.text.text.contents = "Tic-Tac-Toe\nClick To Play";
|
||||
|
||||
|
@ -303,7 +303,7 @@ export default class TicTacToe {
|
|||
}
|
||||
|
||||
private beginGameStatePlay() {
|
||||
console.log("BeginGameState Play");
|
||||
log.info("app", "BeginGameState Play");
|
||||
this.gameState = GameState.Play;
|
||||
this.text.text.contents = "First Piece: " + GamePiece[this.currentPlayerGamePiece];
|
||||
}
|
||||
|
|
|
@ -8,8 +8,10 @@ import dotenv from 'dotenv';
|
|||
import { resolve as resolvePath } from 'path';
|
||||
import App from './app';
|
||||
|
||||
/* eslint-disable no-console */
|
||||
process.on('uncaughtException', err => console.log('uncaughtException', err));
|
||||
process.on('unhandledRejection', reason => console.log('unhandledRejection', reason));
|
||||
/* eslint-enable no-console */
|
||||
|
||||
// Read .env if file exists
|
||||
dotenv.config();
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
module.exports = {
|
||||
"root": true,
|
||||
"env": {
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:@typescript-eslint/recommended-requiring-type-checking"
|
||||
],
|
||||
"globals": {
|
||||
"Atomics": "readonly",
|
||||
"SharedArrayBuffer": "readonly"
|
||||
},
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"tsconfigRootDir": __dirname,
|
||||
"ecmaVersion": 2018,
|
||||
"sourceType": "module",
|
||||
"project": "./tsconfig.json"
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint",
|
||||
"header"
|
||||
],
|
||||
"rules": {
|
||||
"block-spacing": ["warn", "always"],
|
||||
"brace-style": ["warn", "1tbs", {"allowSingleLine": true}],
|
||||
"curly": ["warn", "all"],
|
||||
"default-param-last": "warn",
|
||||
"eol-last": ["warn", "always"],
|
||||
"eqeqeq": ["error", "always"],
|
||||
"indent": [
|
||||
"warn",
|
||||
"tab",
|
||||
{
|
||||
"MemberExpression": "off",
|
||||
"SwitchCase": 1
|
||||
}
|
||||
],
|
||||
"linebreak-style": [
|
||||
"warn",
|
||||
"windows"
|
||||
],
|
||||
"max-classes-per-file": ["warn", 1],
|
||||
"max-len": ["error", 120],
|
||||
"no-console": "error",
|
||||
"no-div-regex": "error",
|
||||
"no-empty": ["error", { "allowEmptyCatch": true }],
|
||||
"no-labels": "error",
|
||||
"no-loop-func": "error",
|
||||
"no-multi-spaces": ["warn", {"ignoreEOLComments": true}],
|
||||
"no-multiple-empty-lines": "warn",
|
||||
"no-new": "error",
|
||||
"no-self-compare": "warn",
|
||||
"no-sequences": "error",
|
||||
"no-shadow": "warn",
|
||||
"no-unmodified-loop-condition": "error",
|
||||
"no-void": "error",
|
||||
"no-warning-comments": ["warn", {"terms": ["todo", "fixme", "tslint"]}],
|
||||
"prefer-const": "warn",
|
||||
"prefer-regex-literals": "warn",
|
||||
"require-unicode-regexp": "error",
|
||||
"yoda": "warn",
|
||||
|
||||
"@typescript-eslint/array-type": [
|
||||
"error",
|
||||
{ "default": "array-simple" }
|
||||
],
|
||||
"@typescript-eslint/ban-types": [
|
||||
"error",
|
||||
{
|
||||
"types": {
|
||||
"Object": "Use {} instead.",
|
||||
"String": "Use 'string' instead.",
|
||||
"Number": "Use 'number' instead.",
|
||||
"Boolean": "Use 'boolean' instead."
|
||||
}
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/camelcase": ["warn", {"allow": ["^_[a-z][A-Za-z0-9]*$"]}],
|
||||
"@typescript-eslint/explicit-function-return-type": "off",
|
||||
"@typescript-eslint/no-empty-function": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-floating-promises": "off",
|
||||
"@typescript-eslint/no-misused-promises": "off",
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"warn",
|
||||
{ "args": "none" }
|
||||
],
|
||||
"@typescript-eslint/unbound-method": "error",
|
||||
"header/header": [
|
||||
"error",
|
||||
"block",
|
||||
[
|
||||
"!",
|
||||
" * Copyright (c) Microsoft Corporation. All rights reserved.",
|
||||
" * Licensed under the MIT License.",
|
||||
" "
|
||||
]
|
||||
]
|
||||
}
|
||||
};
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -21,17 +21,20 @@
|
|||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"clean": "tsc --build --clean",
|
||||
"build": "tsc --build",
|
||||
"lint": "tslint -p ./tsconfig.json src/**/*.ts",
|
||||
"build": "tsc --build && eslint --ext .ts src",
|
||||
"lint": "eslint --ext .ts src",
|
||||
"start": "node .",
|
||||
"debug": "node --nolazy --inspect-brk=9229 ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "3.0.3"
|
||||
"@typescript-eslint/eslint-plugin": "^2.17.0",
|
||||
"@typescript-eslint/parser": "^2.17.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-plugin-header": "^3.0.0",
|
||||
"typescript": "^3.7.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@microsoft/mixed-reality-extension-sdk": "^0.13.1",
|
||||
"@microsoft/mixed-reality-extension-sdk": "^0.15.0",
|
||||
"@types/dotenv": "^6.1.0",
|
||||
"@types/node": "^10.3.1",
|
||||
"dotenv": "^6.2.0"
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
import * as MRESDK from '@microsoft/mixed-reality-extension-sdk';
|
||||
import * as MRE from '@microsoft/mixed-reality-extension-sdk';
|
||||
import { log } from '@microsoft/mixed-reality-extension-sdk/built/log';
|
||||
|
||||
/**
|
||||
* The structure of a hat entry in the hat database.
|
||||
|
@ -36,7 +37,7 @@ type HatDatabase = {
|
|||
};
|
||||
|
||||
// Load the database of hats.
|
||||
// tslint:disable-next-line:no-var-requires variable-name
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const HatDatabase: HatDatabase = require('../public/hats.json');
|
||||
|
||||
/**
|
||||
|
@ -44,18 +45,18 @@ const HatDatabase: HatDatabase = require('../public/hats.json');
|
|||
*/
|
||||
export default class WearAHat {
|
||||
// Container for preloaded hat prefabs.
|
||||
private assets: MRESDK.AssetContainer;
|
||||
private prefabs: { [key: string]: MRESDK.Prefab } = {};
|
||||
private assets: MRE.AssetContainer;
|
||||
private prefabs: { [key: string]: MRE.Prefab } = {};
|
||||
// Container for instantiated hats.
|
||||
private attachedHats: { [key: string]: MRESDK.Actor } = {};
|
||||
private attachedHats: { [key: string]: MRE.Actor } = {};
|
||||
|
||||
/**
|
||||
* Constructs a new instance of this class.
|
||||
* @param context The MRE SDK context.
|
||||
* @param baseUrl The baseUrl to this project's `./public` folder.
|
||||
*/
|
||||
constructor(private context: MRESDK.Context, private baseUrl: string) {
|
||||
this.assets = new MRESDK.AssetContainer(context);
|
||||
constructor(private context: MRE.Context, private baseUrl: string) {
|
||||
this.assets = new MRE.AssetContainer(context);
|
||||
// Hook the context events we're interested in.
|
||||
this.context.onStarted(() => this.started());
|
||||
this.context.onUserLeft(user => this.userLeft(user));
|
||||
|
@ -75,10 +76,10 @@ export default class WearAHat {
|
|||
* Called when a user leaves the application (probably left the Altspace world where this app is running).
|
||||
* @param user The user that left the building.
|
||||
*/
|
||||
private userLeft(user: MRESDK.User) {
|
||||
private userLeft(user: MRE.User) {
|
||||
// If the user was wearing a hat, destroy it. Otherwise it would be
|
||||
// orphaned in the world.
|
||||
if (this.attachedHats[user.id]) this.attachedHats[user.id].destroy();
|
||||
if (this.attachedHats[user.id]) { this.attachedHats[user.id].destroy(); }
|
||||
delete this.attachedHats[user.id];
|
||||
}
|
||||
|
||||
|
@ -87,7 +88,7 @@ export default class WearAHat {
|
|||
*/
|
||||
private showHatMenu() {
|
||||
// Create a parent object for all the menu items.
|
||||
const menu = MRESDK.Actor.Create(this.context, {});
|
||||
const menu = MRE.Actor.Create(this.context, {});
|
||||
let y = 0.3;
|
||||
|
||||
// Create menu button
|
||||
|
@ -96,12 +97,12 @@ export default class WearAHat {
|
|||
// Loop over the hat database, creating a menu item for each entry.
|
||||
for (const hatId of Object.keys(HatDatabase)) {
|
||||
// Create a clickable button.
|
||||
const button = MRESDK.Actor.Create(this.context, {
|
||||
const button = MRE.Actor.Create(this.context, {
|
||||
actor: {
|
||||
parentId: menu.id,
|
||||
name: hatId,
|
||||
appearance: { meshId: buttonMesh.id },
|
||||
collider: { geometry: { shape: 'auto' } },
|
||||
collider: { geometry: { shape: MRE.ColliderType.Auto } },
|
||||
transform: {
|
||||
local: { position: { x: 0, y, z: 0 } }
|
||||
}
|
||||
|
@ -109,18 +110,18 @@ export default class WearAHat {
|
|||
});
|
||||
|
||||
// Set a click handler on the button.
|
||||
button.setBehavior(MRESDK.ButtonBehavior)
|
||||
button.setBehavior(MRE.ButtonBehavior)
|
||||
.onClick(user => this.wearHat(hatId, user.id));
|
||||
|
||||
// Create a label for the menu entry.
|
||||
MRESDK.Actor.Create(this.context, {
|
||||
MRE.Actor.Create(this.context, {
|
||||
actor: {
|
||||
parentId: menu.id,
|
||||
name: 'label',
|
||||
text: {
|
||||
contents: HatDatabase[hatId].displayName,
|
||||
height: 0.5,
|
||||
anchor: MRESDK.TextAnchorLocation.MiddleLeft
|
||||
anchor: MRE.TextAnchorLocation.MiddleLeft
|
||||
},
|
||||
transform: {
|
||||
local: { position: { x: 0.5, y, z: 0 } }
|
||||
|
@ -131,15 +132,15 @@ export default class WearAHat {
|
|||
}
|
||||
|
||||
// Create a label for the menu title.
|
||||
MRESDK.Actor.Create(this.context, {
|
||||
MRE.Actor.Create(this.context, {
|
||||
actor: {
|
||||
parentId: menu.id,
|
||||
name: 'label',
|
||||
text: {
|
||||
contents: ''.padStart(8, ' ') + "Wear a Hat",
|
||||
height: 0.8,
|
||||
anchor: MRESDK.TextAnchorLocation.MiddleCenter,
|
||||
color: MRESDK.Color3.Yellow()
|
||||
anchor: MRE.TextAnchorLocation.MiddleCenter,
|
||||
color: MRE.Color3.Yellow()
|
||||
},
|
||||
transform: {
|
||||
local: { position: { x: 0.5, y: y + 0.25, z: 0 } }
|
||||
|
@ -163,9 +164,9 @@ export default class WearAHat {
|
|||
return this.assets.loadGltf(
|
||||
`${this.baseUrl}/${hatRecord.resourceName}`)
|
||||
.then(assets => {
|
||||
this.prefabs[hatId] = assets.find(a => a.prefab !== null) as MRESDK.Prefab;
|
||||
this.prefabs[hatId] = assets.find(a => a.prefab !== null) as MRE.Prefab;
|
||||
})
|
||||
.catch(e => console.error(e));
|
||||
.catch(e => log.error("app", e));
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
@ -179,7 +180,7 @@ export default class WearAHat {
|
|||
*/
|
||||
private wearHat(hatId: string, userId: string) {
|
||||
// If the user is wearing a hat, destroy it.
|
||||
if (this.attachedHats[userId]) this.attachedHats[userId].destroy();
|
||||
if (this.attachedHats[userId]) { this.attachedHats[userId].destroy(); }
|
||||
delete this.attachedHats[userId];
|
||||
|
||||
const hatRecord = HatDatabase[hatId];
|
||||
|
@ -190,16 +191,16 @@ export default class WearAHat {
|
|||
}
|
||||
|
||||
// Create the hat model and attach it to the avatar's head.
|
||||
this.attachedHats[userId] = MRESDK.Actor.CreateFromPrefab(this.context, {
|
||||
this.attachedHats[userId] = MRE.Actor.CreateFromPrefab(this.context, {
|
||||
prefabId: this.prefabs[hatId].id,
|
||||
actor: {
|
||||
transform: {
|
||||
local: {
|
||||
position: hatRecord.position,
|
||||
rotation: MRESDK.Quaternion.FromEulerAngles(
|
||||
hatRecord.rotation.x * MRESDK.DegreesToRadians,
|
||||
hatRecord.rotation.y * MRESDK.DegreesToRadians,
|
||||
hatRecord.rotation.z * MRESDK.DegreesToRadians),
|
||||
rotation: MRE.Quaternion.FromEulerAngles(
|
||||
hatRecord.rotation.x * MRE.DegreesToRadians,
|
||||
hatRecord.rotation.y * MRE.DegreesToRadians,
|
||||
hatRecord.rotation.z * MRE.DegreesToRadians),
|
||||
scale: hatRecord.scale,
|
||||
}
|
||||
},
|
||||
|
|
|
@ -8,8 +8,10 @@ import dotenv from 'dotenv';
|
|||
import { resolve as resolvePath } from 'path';
|
||||
import App from './app';
|
||||
|
||||
/* eslint-disable no-console */
|
||||
process.on('uncaughtException', err => console.log('uncaughtException', err));
|
||||
process.on('unhandledRejection', reason => console.log('unhandledRejection', reason));
|
||||
/* eslint-enable no-console */
|
||||
|
||||
// Read .env if file exists
|
||||
dotenv.config();
|
||||
|
|
Загрузка…
Ссылка в новой задаче