This commit is contained in:
Abigail Carey 2017-03-06 21:16:47 -08:00
Коммит f520a9d939
21 изменённых файлов: 64957 добавлений и 0 удалений

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

@ -0,0 +1,252 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml

3
CONTRIBUTING.md Normal file
Просмотреть файл

@ -0,0 +1,3 @@
We're not ready to accept contributions at this time, but if you have any feedback, please post to the Issues list. Thanks!
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

48
GetStartedJS3D.sln Normal file
Просмотреть файл

@ -0,0 +1,48 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "GetStartedJS3D", "GetStartedJS3D\GetStartedJS3D.jsproj", "{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Debug|ARM.ActiveCfg = Debug|ARM
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Debug|ARM.Build.0 = Debug|ARM
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Debug|ARM.Deploy.0 = Debug|ARM
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Debug|x64.ActiveCfg = Debug|x64
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Debug|x64.Build.0 = Debug|x64
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Debug|x64.Deploy.0 = Debug|x64
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Debug|x86.ActiveCfg = Debug|x86
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Debug|x86.Build.0 = Debug|x86
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Debug|x86.Deploy.0 = Debug|x86
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Release|Any CPU.Build.0 = Release|Any CPU
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Release|Any CPU.Deploy.0 = Release|Any CPU
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Release|ARM.ActiveCfg = Release|ARM
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Release|ARM.Build.0 = Release|ARM
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Release|ARM.Deploy.0 = Release|ARM
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Release|x64.ActiveCfg = Release|x64
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Release|x64.Build.0 = Release|x64
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Release|x64.Deploy.0 = Release|x64
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Release|x86.ActiveCfg = Release|x86
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Release|x86.Build.0 = Release|x86
{C92E4F58-43DC-44FC-BE1B-FB7512C142E1}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

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

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|AnyCPU">
<Configuration>Debug</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x86">
<Configuration>Debug</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|AnyCPU">
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x86">
<Configuration>Release</Configuration>
<Platform>x86</Platform>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>c92e4f58-43dc-44fc-be1b-fb7512c142e1</ProjectGuid>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0'">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).props" />
<PropertyGroup>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.14393.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10586.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>$(VersionNumberMajor).$(VersionNumberMinor)</MinimumVisualStudioVersion>
<DefaultLanguage>en-US</DefaultLanguage>
<PackageCertificateKeyFile>GetStartedJS3D_TemporaryKey.pfx</PackageCertificateKeyFile>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="css\stylesheet.css" />
<Content Include="index.html" />
<Content Include="images\LockScreenLogo.scale-200.png" />
<Content Include="images\SplashScreen.scale-200.png" />
<Content Include="images\Square150x150Logo.scale-200.png" />
<Content Include="images\Square44x44Logo.scale-200.png" />
<Content Include="images\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="images\StoreLogo.png" />
<Content Include="images\Wide310x150Logo.scale-200.png" />
<Content Include="js\controls\PointerLockControls.js" />
<Content Include="js\libs\three.js" />
<Content Include="js\main.js" />
<Content Include="models\dino.json" />
<None Include="GetStartedJS3D_TemporaryKey.pfx" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).targets" />
<!-- To modify your build process, add your task inside one of the targets below then uncomment
that target and the DisableFastUpToDateCheck PropertyGroup.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
<PropertyGroup>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
</PropertyGroup>
-->
</Project>

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

@ -0,0 +1,81 @@
/*
// ---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// The MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// ---------------------------------------------------------------------------------
*/
body {
background-color: #000;
color: #888;
font-family: Helvetica;
line-height: 26px;
margin: 0px;
overflow: hidden;
}
#container {
box-sizing: border-box;
height: 100%;
left: 0;
margin: 0;
position: absolute;
top: 0;
width: 100%;
}
#blocker {
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
}
#instructions {
width: 100%;
height: 100%;
font-size: 30px;
font-family: 'Courier New';
display: -webkit-box;
display: -moz-box;
display: box;
-webkit-box-orient: horizontal;
-moz-box-orient: horizontal;
-webkit-box-pack: center;
-moz-box-pack: center;
-webkit-box-align: center;
-moz-box-align: center;
color: #ffffff;
text-align: center;
cursor: pointer;
}
#dino-alert {
position: absolute;
color: #aa0909;
width: 100%;
height: 5%;
text-align: center;
padding-top:2%;
vertical-align:middle;
}

Двоичные данные
GetStartedJS3D/images/LockScreenLogo.scale-200.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 16 KiB

Двоичные данные
GetStartedJS3D/images/SplashScreen.scale-200.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 46 KiB

Двоичные данные
GetStartedJS3D/images/Square150x150Logo.scale-200.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 27 KiB

Двоичные данные
GetStartedJS3D/images/Square44x44Logo.scale-200.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 19 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 16 KiB

Двоичные данные
GetStartedJS3D/images/StoreLogo.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 17 KiB

Двоичные данные
GetStartedJS3D/images/Wide310x150Logo.scale-200.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 23 KiB

50
GetStartedJS3D/index.html Normal file
Просмотреть файл

@ -0,0 +1,50 @@
<!-----------------------------------------------------------------------------------
Copyright (c) Microsoft Corporation. All rights reserved.
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
--------------------------------------------------------------------------------->
<!DOCTYPE html>
<html lang='en'>
<head>
<link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
</head>
<body>
<div id='container'></div>
<script src='js/libs/three.js'></script>
<script src="js/controls/PointerLockControls.js"></script>
<div id="blocker">
<div id="instructions">
<strong>Loading...</strong>
</div>
</div>
<div id="dino-alert">
</div>
<script src="js/main.js"></script>
</body>
</html>

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

@ -0,0 +1,69 @@
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE.PointerLockControls = function ( camera ) {
var scope = this;
camera.rotation.set( 0, 0, 0 );
var pitchObject = new THREE.Object3D();
pitchObject.add( camera );
var yawObject = new THREE.Object3D();
yawObject.position.y = 10;
yawObject.add( pitchObject );
var PI_2 = Math.PI / 2;
var onMouseMove = function ( event ) {
if ( scope.enabled === false ) return;
var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
yawObject.rotation.y -= movementX * 0.002;
pitchObject.rotation.x -= movementY * 0.002;
pitchObject.rotation.x = Math.max( - PI_2, Math.min( PI_2, pitchObject.rotation.x ) );
};
this.dispose = function() {
document.removeEventListener( 'mousemove', onMouseMove, false );
};
document.addEventListener( 'mousemove', onMouseMove, false );
this.enabled = false;
this.getObject = function () {
return yawObject;
};
this.getDirection = function() {
// assumes the camera itself is not rotated
var direction = new THREE.Vector3( 0, 0, - 1 );
var rotation = new THREE.Euler( 0, 0, 0, "YXZ" );
return function( v ) {
rotation.set( pitchObject.rotation.x, yawObject.rotation.y, 0 );
v.copy( direction ).applyEuler( rotation );
return v;
};
}();
};

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

585
GetStartedJS3D/js/main.js Normal file
Просмотреть файл

@ -0,0 +1,585 @@
// ---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// The MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// ---------------------------------------------------------------------------------
var UNITWIDTH = 90; // Width of a cubes in the maze
var UNITHEIGHT = 45; // Height of the cubes in the maze
var CATCHOFFSET = 120; // Distance from the player the dino to trigger game over
var DINOCOLLISIONDISTANCE = 55; // How many units away a dino can get to a wall
var PLAYERCOLLISIONDISTANCE = 20; // How many units away the player can get from the wall
var PLAYERSPEED = 800.0; // How fast the player moves
var DINOSPEED = 400.0; // How fast the dino moves
var DINOSCALE = 20; // How big our dino is scaled to
var clock;
var dino;
var loader = new THREE.JSONLoader();
var camera, controls, scene, renderer;
var mapSize;
var collidableObjects = [];
var totalCubesWide;
// Flags to determine which direction the player is moving
var moveForward = false;
var moveBackward = false;
var moveLeft = false;
var moveRight = false;
// Flag to determine if the player lost the game
var gameOver = false;
// Velocity vectors for the player and dino
var playerVelocity = new THREE.Vector3();
var dinoVelocity = new THREE.Vector3();
// HTML elements to be changed
var blocker = document.getElementById('blocker');
var instructions = document.getElementById('instructions');
var dinoAlert = document.getElementById('dino-alert');
dinoAlert.style.display = 'none';
var container = document.getElementById('container');
var body = document.getElementById('body');
var blocker = document.getElementById('blocker');
// Get the pointer lock and start listening for if its state changes
function getPointerLock() {
document.onclick = function () {
container.requestPointerLock();
}
document.addEventListener('pointerlockchange', lockChange, false);
}
// Switch the controls on or off
function lockChange() {
// Turn on controls
if (document.pointerLockElement === container) {
blocker.style.display = "none";
controls.enabled = true;
// Turn off the controls
} else {
if (gameOver) {
location.reload();
}
// Display the blocker and instruction
blocker.style.display = "";
controls.enabled = false;
}
}
// Set up the game
getPointerLock();
init();
// Set up the game
function init() {
// Set clock to keep track of frames
clock = new THREE.Clock();
// Create the scene where everything will go
scene = new THREE.Scene();
// Add some fog for effects
scene.fog = new THREE.FogExp2(0xcccccc, 0.0015);
// Set render settings
renderer = new THREE.WebGLRenderer();
renderer.setClearColor(scene.fog.color);
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
// Render to the container
var container = document.getElementById('container');
container.appendChild(renderer.domElement);
// Set camera position and view details
camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 1, 2000);
camera.position.y = 20; // Height the camera will be looking from
camera.position.x = 0;
camera.position.z = 0;
// Add the camera to the controller, then add to the scene
controls = new THREE.PointerLockControls(camera);
scene.add(controls.getObject());
listenForPlayerMovement();
// Add the walls(cubes) of the maze
createMazeCubes();
// Add ground plane
createGround();
// Add perimeter walls that surround the maze
createPerimWalls();
// load the dino JSON model and start animating once complete
loader.load('./models/dino.json', function (geometry, materials) {
// Get the geometry and materials from the JSON
var dinoObject = new THREE.Mesh(geometry, new THREE.MultiMaterial(materials));
// Scale the size of the dino
dinoObject.scale.set(DINOSCALE, DINOSCALE, DINOSCALE);
dinoObject.rotation.y = degreesToRadians(90);
dinoObject.position.set(30, 0, -400);
dinoObject.name = "dino";
scene.add(dinoObject);
//position.setFromMatrixPosition(dino.matrixWorld);
dino = scene.getObjectByName("dino");
// Model is loaded, switch from "Loading..." to instruction text
instructions.innerHTML = "<strong>Click to Play!</strong> </br></br> W,A,S,D or arrow keys = move </br>Mouse = look around";
// Call the animate function so that animation begins after the model is loaded
animate();
});
// Add lights to the scene
addLights();
// Listen for if the window changes sizes
window.addEventListener('resize', onWindowResize, false);
}
// Add event listeners for player movement key presses
function listenForPlayerMovement() {
// Listen for when a key is pressed
// If it's a specified key, mark the direction as true since moving
var onKeyDown = function (event) {
switch (event.keyCode) {
case 38: // up
case 87: // w
moveForward = true;
break;
case 37: // left
case 65: // a
moveLeft = true;
break;
case 40: // down
case 83: // s
moveBackward = true;
break;
case 39: // right
case 68: // d
moveRight = true;
break;
}
};
// Listen for when a key is released
// If it's a specified key, mark the direction as false since no longer moving
var onKeyUp = function (event) {
switch (event.keyCode) {
case 38: // up
case 87: // w
moveForward = false;
break;
case 37: // left
case 65: // a
moveLeft = false;
break;
case 40: // down
case 83: // s
moveBackward = false;
break;
case 39: // right
case 68: // d
moveRight = false;
break;
}
};
// Add event listeners for when movement keys are pressed and released
document.addEventListener('keydown', onKeyDown, false);
document.addEventListener('keyup', onKeyUp, false);
}
// Add lights to the scene
function addLights() {
var lightOne = new THREE.DirectionalLight(0xffffff);
lightOne.position.set(1, 1, 1);
scene.add(lightOne);
var lightTwo = new THREE.DirectionalLight(0xffffff, .4);
lightTwo.position.set(1, -1, -1);
scene.add(lightTwo);
}
// Create the maze walls using cubes that are mapped with a 2D array
function createMazeCubes() {
// Maze wall mapping, assuming matrix
// 1's are cubes, 0's are empty space
var map = [
[0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0,],
[0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0,],
[0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0,],
[0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0,],
[0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,],
[1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,],
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,],
[0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1,],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0,],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1,],
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0,],
[0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0,],
[1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0,],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,],
[1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0,],
[0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0,],
[0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0,]
];
// wall details
var cubeGeo = new THREE.BoxGeometry(UNITWIDTH, UNITHEIGHT, UNITWIDTH);
var cubeMat = new THREE.MeshPhongMaterial({
color: 0x81cfe0,
});
// Keep cubes within boundry walls
var widthOffset = UNITWIDTH / 2;
// Put the bottom of the cube at y = 0
var heightOffset = UNITHEIGHT / 2;
// See how wide the map is by seeing how long the first array is
totalCubesWide = map[0].length;
// Place walls where 1`s are
for (var i = 0; i < totalCubesWide; i++) {
for (var j = 0; j < map[i].length; j++) {
// If a 1 is found, add a cube at the corresponding position
if (map[i][j]) {
// Make the cube
var cube = new THREE.Mesh(cubeGeo, cubeMat);
// Set the cube position
cube.position.z = (i - totalCubesWide / 2) * UNITWIDTH + widthOffset;
cube.position.y = heightOffset;
cube.position.x = (j - totalCubesWide / 2) * UNITWIDTH + widthOffset;
// Add the cube
scene.add(cube);
// Used later for collision detection
collidableObjects.push(cube);
}
}
}
// Create the ground based on the map size the matrix/cube size produced
mapSize = totalCubesWide * UNITWIDTH;
}
// Create the ground plane that the maze sits on top of
function createGround() {
// Create the ground geometry and material
var groundGeo = new THREE.PlaneGeometry(mapSize, mapSize);
var groundMat = new THREE.MeshPhongMaterial({ color: 0xA0522D, side: THREE.DoubleSide, shading: THREE.FlatShading });
// Create the ground and rotate it flat
var ground = new THREE.Mesh(groundGeo, groundMat);
ground.position.set(0, 1, 0);
ground.rotation.x = degreesToRadians(90);
scene.add(ground);
}
// Make the four perimeter walls for the maze
function createPerimWalls() {
var halfMap = mapSize / 2; // Half the size of the map
var sign = 1; // Used to make an amount positive or negative
// Loop through twice, making two perimeter walls at a time
for (var i = 0; i < 2; i++) {
var perimGeo = new THREE.PlaneGeometry(mapSize, UNITHEIGHT);
// Make the material double sided
var perimMat = new THREE.MeshPhongMaterial({ color: 0x464646, side: THREE.DoubleSide });
// Make two walls
var perimWallLR = new THREE.Mesh(perimGeo, perimMat);
var perimWallFB = new THREE.Mesh(perimGeo, perimMat);
// Create left/right walls
perimWallLR.position.set(halfMap * sign, UNITHEIGHT / 2, 0);
perimWallLR.rotation.y = degreesToRadians(90);
scene.add(perimWallLR);
collidableObjects.push(perimWallLR);
// Create front/back walls
perimWallFB.position.set(0, UNITHEIGHT / 2, halfMap * sign);
scene.add(perimWallFB);
collidableObjects.push(perimWallFB);
collidableObjects.push(perimWallLR);
collidableObjects.push(perimWallFB);
sign = -1; // Swap to negative value
}
}
// Update the camera and renderer when the window changes size
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
function animate() {
render();
requestAnimationFrame(animate);
// Get the change in time between frames
var delta = clock.getDelta();
// Update our frames per second monitor
// If the player is in dino's range, trigger the chase
var isBeingChased = triggerChase();
// If the player is too close, trigger the end of the game
if (dino.position.distanceTo(controls.getObject().position) < CATCHOFFSET) {
caught();
// Player is at an undetected distance
// Keep the dino moving and let the player keep moving too
} else {
animateDino(delta);
animatePlayer(delta);
}
}
// Render the scene
function render() {
renderer.render(scene, camera);
}
// Make the dino chase the player
function triggerChase() {
// Check if in dino agro range
if (dino.position.distanceTo(controls.getObject().position) < 300) {
// Adject the target's y value. We only care about x and z for movement.
var lookTarget = new THREE.Vector3();
lookTarget.copy(controls.getObject().position);
lookTarget.y = dino.position.y;
// Make dino face camera
dino.lookAt(lookTarget);
// Get distance between dino and camera with a 120 unit offset
// Game over when dino is the value of CATCHOFFSET units away from camera
var distanceFrom = Math.round(dino.position.distanceTo(controls.getObject().position)) - CATCHOFFSET;
// Alert and display distance between camera and dino
dinoAlert.innerHTML = "Dino has spotted you! Distance from you: " + distanceFrom;
dinoAlert.style.display = '';
return true;
// Not in agro range, don't start distance countdown
} else {
dinoAlert.style.display = 'none';
return false;
}
}
// Dino has caught the player. Turn on end prompt.
function caught() {
blocker.style.display = '';
instructions.innerHTML = "GAME OVER </br></br></br> Press ESC to restart";
gameOver = true;
instructions.style.display = '';
dinoAlert.style.display = 'none';
}
// Animate the player camera
function animatePlayer(delta) {
// Gradual slowdown
playerVelocity.x -= playerVelocity.x * 10.0 * delta;
playerVelocity.z -= playerVelocity.z * 10.0 * delta;
// If no collision and a movement key is being pressed, apply movement velocity
if (detectPlayerCollision() == false) {
if (moveForward) {
playerVelocity.z -= PLAYERSPEED * delta;
}
if (moveBackward) playerVelocity.z += PLAYERSPEED * delta;
if (moveLeft) playerVelocity.x -= PLAYERSPEED * delta;
if (moveRight) playerVelocity.x += PLAYERSPEED * delta;
controls.getObject().translateX(playerVelocity.x * delta);
controls.getObject().translateZ(playerVelocity.z * delta);
} else {
// Collision or no movement key being pressed. Stop movememnt
playerVelocity.x = 0;
playerVelocity.z = 0;
}
}
// Determine if the player is colliding with a collidable object
function detectPlayerCollision() {
// The rotation matrix to apply to our direction vector
// Undefined by default to indicate ray should coming from front
var rotationMatrix;
// Get direction of camera
var cameraDirection = controls.getDirection(new THREE.Vector3(0, 0, 0)).clone();
// Check which direction we're moving (not looking)
// Flip matrix to that direction so that we can reposition the ray
if (moveBackward) {
rotationMatrix = new THREE.Matrix4();
rotationMatrix.makeRotationY(degreesToRadians(180));
}
else if (moveLeft) {
rotationMatrix = new THREE.Matrix4();
rotationMatrix.makeRotationY(degreesToRadians(90));
}
else if (moveRight) {
rotationMatrix = new THREE.Matrix4();
rotationMatrix.makeRotationY(degreesToRadians(270));
}
// Player is moving forward, no rotation matrix needed
if (rotationMatrix !== undefined) {
cameraDirection.applyMatrix4(rotationMatrix);
}
// Apply ray to player camera
var rayCaster = new THREE.Raycaster(controls.getObject().position, cameraDirection);
// If our ray hit a collidable object, return true
if (rayIntersect(rayCaster, PLAYERCOLLISIONDISTANCE)) {
return true;
} else {
return false;
}
}
// Apply movement to the dino, turning when collisions are made
function animateDino(delta) {
// Gradual slowdown
dinoVelocity.x -= dinoVelocity.x * 10.0 * delta;
dinoVelocity.z -= dinoVelocity.z * 10.0 * delta;
// If no collision, apply movement velocity
if (detectDinoCollision() == false) {
dinoVelocity.z += DINOSPEED * delta;
// Move the dino
dino.translateZ(dinoVelocity.z * delta);
} else {
// Collision. Adjust direction
var directionMultiples = [-1, 1, 2];
var randomIndex = getRandomInt(0, 2);
var randomDirection = degreesToRadians(90 * directionMultiples[randomIndex]);
dinoVelocity.z += DINOSPEED * delta;
// Add the new direction
dino.rotation.y += randomDirection;
}
}
// Determine whether ornot dino is colliding with a wall
function detectDinoCollision() {
// Get the rotation matrix from dino
var matrix = new THREE.Matrix4();
matrix.extractRotation(dino.matrix);
// Create direction vector
var directionFront = new THREE.Vector3(0, 0, 1);
// Get the vectors coming from the front of the dino
directionFront.applyMatrix4(matrix);
// Create raycaster
var rayCasterF = new THREE.Raycaster(dino.position, directionFront);
// If we have a front collision, we have to adjust our direction so return true
if (rayIntersect(rayCasterF, DINOCOLLISIONDISTANCE))
return true;
else
return false;
}
// Takes a ray and sees if it's colliding with anything from the list of collidable objects
// Returns true if certain distance away from object
function rayIntersect(ray, distance) {
var intersects = ray.intersectObjects(collidableObjects);
for (var i = 0; i < intersects.length; i++) {
if (intersects[i].distance < distance) {
return true;
}
}
return false;
}
// Generate a random integer within a range
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
// Converts degrees to radians
function degreesToRadians(degrees) {
return degrees * Math.PI / 180;
}
// Converts radians to degrees
function radiansToDegrees(radians) {
return radians * 180 / Math.PI;
}

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

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

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
IgnorableNamespaces="uap mp">
<Identity
Name="c92e4f58-43dc-44fc-be1b-fb7512c142e1"
Version="1.0.0.0"
Publisher="CN=Microsoft Corporation" />
<mp:PhoneIdentity PhoneProductId="c92e4f58-43dc-44fc-be1b-fb7512c142e1" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>GetStartedJS3D</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<Logo>images\storelogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application
Id="App"
StartPage="index.html">
<uap:VisualElements
DisplayName="GetStartedJS3D"
Description="GetStartedJS3D"
BackgroundColor="transparent"
Square150x150Logo="images\Square150x150Logo.png"
Square44x44Logo="images\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="images\Wide310x150Logo.png" />
<uap:SplashScreen Image="images\splashscreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
</Package>

21
LICENSE Normal file
Просмотреть файл

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2017 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

18
README.md Normal file
Просмотреть файл

@ -0,0 +1,18 @@
# Get Started JavaScript 3D
## A UWP game for the Windows Store, written in JavaScript with three.js
## Requirements
This app requires Visual Studio to run. [Click here to learn how to get set up with Visual Studio](https://docs.microsoft.com/en-us/windows/uwp/get-started/get-set-up).
## Install and run the app
1. Clone or download this repository
2. Open **GetStartedJS3D.sln** in Visual Studio.
3. To run the app, press **F5**.
## Learn more about MonoGame and UWP
For a step-by-step walkthrough of the code, check out the [JavaScript 3D tutorial on docs.microsoft.com](https://docs.microsoft.com/en-us/windows/uwp/get-started/get-started-tutorial-game-js3d).
To learn more about getting started with the Universal Windows Platform, see the [Getting Started Hub](https://developer.microsoft.com/windows/apps/getstarted)
To learn how to publish apps to the Windows Store, see [Publishing your Windows Store app](https://developer.microsoft.com/store/publish-apps).

26
ThirdPartyNotices.txt Normal file
Просмотреть файл

@ -0,0 +1,26 @@
This file is based on or incorporates material from the projects listed below (Third Party IP). The original copyright notice and the license under which Microsoft received such Third Party IP, are set forth below. Such licenses and notices are provided for informational purposes only. Microsoft licenses the Third Party IP to you under the licensing terms for the Microsoft product. Microsoft reserves all other rights not expressly granted under this agreement, whether by implication, estoppel or otherwise.
mrdoob/three.js
-------------------
The MIT License
Copyright © 2010-2017 three.js authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.