tree typescript app

master
xieguigang 8 years ago
parent 7002447c65
commit f8d320fe7f

@ -0,0 +1,13 @@
declare var container: HTMLDivElement;
declare var camera: THREE.PerspectiveCamera;
declare var scene: THREE.Scene;
declare var renderer: THREE.CanvasRenderer;
declare var group: THREE.Group;
declare var mouseX: number, mouseY: number;
declare var windowHalfX: number;
declare var windowHalfY: number;
declare function init(): void;
declare function onWindowResize(): void;
declare function onDocumentMouseMove(event: any): void;
declare function animate(): void;
declare function render(): void;

@ -0,0 +1,66 @@
var container;
var camera;
var scene;
var renderer;
var group;
var mouseX = 0, mouseY = 0;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;
document.addEventListener('mousemove', onDocumentMouseMove, false);
init();
animate();
function init() {
container = document.createElement('div');
document.body.appendChild(container);
camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 1, 10000);
camera.position.z = 500;
scene = new THREE.Scene();
scene.background = new THREE.Color(0xffffff);
var geometry = new THREE.BoxBufferGeometry(100, 100, 100);
var material = new THREE.MeshNormalMaterial({ overdraw: 0.5 });
group = new THREE.Group();
for (var i = 0; i < 200; i++) {
var mesh = new THREE.Mesh(geometry, material);
mesh.position.x = Math.random() * 2000 - 1000;
mesh.position.y = Math.random() * 2000 - 1000;
mesh.position.z = Math.random() * 2000 - 1000;
mesh.rotation.x = Math.random() * 2 * Math.PI;
mesh.rotation.y = Math.random() * 2 * Math.PI;
mesh.matrixAutoUpdate = false;
mesh.updateMatrix();
group.add(mesh);
}
scene.add(group);
renderer = new THREE.CanvasRenderer();
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
container.appendChild(renderer.domElement);
window.addEventListener('resize', onWindowResize, false);
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2;
windowHalfY = window.innerHeight / 2;
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
function onDocumentMouseMove(event) {
mouseX = (event.clientX - windowHalfX) * 10;
mouseY = (event.clientY - windowHalfY) * 10;
}
//
function animate() {
requestAnimationFrame(animate);
render();
}
function render() {
camera.position.x += (mouseX - camera.position.x) * .05;
camera.position.y += (-mouseY - camera.position.y) * .05;
camera.lookAt(scene.position);
var currentSeconds = Date.now();
group.rotation.x = Math.sin(currentSeconds * 0.0007) * 0.5;
group.rotation.y = Math.sin(currentSeconds * 0.0003) * 0.5;
group.rotation.z = Math.sin(currentSeconds * 0.0002) * 0.5;
renderer.render(scene, camera);
}
//# sourceMappingURL=linq.js.map

@ -0,0 +1 @@
{"version":3,"file":"linq.js","sourceRoot":"","sources":["../test/treeTest/server.ts"],"names":[],"mappings":"AAAA,IAAI,SAAyB,CAAC;AAE9B,IAAI,MAA+B,CAAC;AACpC,IAAI,KAAkB,CAAC;AACvB,IAAI,QAA8B,CAAC;AAEnC,IAAI,KAAkB,CAAC;AAEvB,IAAI,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;AAE3B,IAAI,WAAW,GAAG,MAAM,CAAC,UAAU,GAAG,CAAC,CAAC;AACxC,IAAI,WAAW,GAAG,MAAM,CAAC,WAAW,GAAG,CAAC,CAAC;AAEzC,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,mBAAmB,EAAE,KAAK,CAAC,CAAC;AAEnE,IAAI,EAAE,CAAC;AACP,OAAO,EAAE,CAAC;AAEV;IAEI,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC1C,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAErC,MAAM,GAAG,IAAI,KAAK,CAAC,iBAAiB,CAAC,EAAE,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IAC3F,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,GAAG,CAAC;IAExB,KAAK,GAAG,IAAI,KAAK,CAAC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AC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAE9B,IAAI,cAAc,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAChC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC;IAC3D,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC;IAC3D,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC;IAE3D,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAEnC,CAAC"}

@ -0,0 +1,101 @@
var container: HTMLDivElement;
var camera: THREE.PerspectiveCamera;
var scene: THREE.Scene;
var renderer: THREE.CanvasRenderer;
var group: THREE.Group;
var mouseX = 0, mouseY = 0;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;
document.addEventListener('mousemove', onDocumentMouseMove, false);
init();
animate();
function init() {
container = document.createElement('div');
document.body.appendChild(container);
camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 1, 10000);
camera.position.z = 500;
scene = new THREE.Scene();
scene.background = new THREE.Color(0xffffff);
var geometry = new THREE.BoxBufferGeometry(100, 100, 100);
var material = new THREE.MeshNormalMaterial({ overdraw: 0.5 });
group = new THREE.Group();
for (var i = 0; i < 200; i++) {
var mesh = new THREE.Mesh(geometry, material);
mesh.position.x = Math.random() * 2000 - 1000;
mesh.position.y = Math.random() * 2000 - 1000;
mesh.position.z = Math.random() * 2000 - 1000;
mesh.rotation.x = Math.random() * 2 * Math.PI;
mesh.rotation.y = Math.random() * 2 * Math.PI;
mesh.matrixAutoUpdate = false;
mesh.updateMatrix();
group.add(mesh);
}
scene.add(group);
renderer = new THREE.CanvasRenderer();
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
container.appendChild(renderer.domElement);
window.addEventListener('resize', onWindowResize, false);
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2;
windowHalfY = window.innerHeight / 2;
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
function onDocumentMouseMove(event) {
mouseX = (event.clientX - windowHalfX) * 10;
mouseY = (event.clientY - windowHalfY) * 10;
}
//
function animate() {
requestAnimationFrame(animate);
render();
}
function render() {
camera.position.x += (mouseX - camera.position.x) * .05;
camera.position.y += (- mouseY - camera.position.y) * .05;
camera.lookAt(scene.position);
var currentSeconds = Date.now();
group.rotation.x = Math.sin(currentSeconds * 0.0007) * 0.5;
group.rotation.y = Math.sin(currentSeconds * 0.0003) * 0.5;
group.rotation.z = Math.sin(currentSeconds * 0.0002) * 0.5;
renderer.render(scene, camera);
}

@ -0,0 +1,3 @@
# treeTest

@ -0,0 +1,27 @@
{
"name": "tree-test",
"version": "0.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@types/node": {
"version": "8.10.29",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.29.tgz",
"integrity": "sha512-zbteaWZ2mdduacm0byELwtRyhYE40aK+pAanQk415gr1eRuu67x7QGOLmn8jz5zI8LDK7d0WI/oT6r5Trz4rzQ==",
"dev": true
},
"@types/three": {
"version": "0.92.18",
"resolved": "https://registry.npmjs.org/@types/three/-/three-0.92.18.tgz",
"integrity": "sha512-UtF8lf2LKnvo/ORGvX1CKLVld0ZWzkUUSrmc9LssHo6jfXG7t7SgVfMZ4IkvrNBTd4eqQP1MlaEH2enbKfh8NA==",
"requires": {
"@types/webvr-api": "0.0.34"
}
},
"@types/webvr-api": {
"version": "0.0.34",
"resolved": "https://registry.npmjs.org/@types/webvr-api/-/webvr-api-0.0.34.tgz",
"integrity": "sha512-gVAPKK+L1blPJCFnUDmkIdRfIU8xbwl05MDXPRjnjoeDXUUzR6frPuyx9RQz+OCodmxlBcJOkjVTMTZi1BcuZw=="
}
}
}

@ -0,0 +1,15 @@
{
"name": "tree-test",
"version": "0.0.0",
"description": "treeTest",
"main": "server.js",
"author": {
"name": ""
},
"devDependencies": {
"@types/node": "^8.0.14"
},
"dependencies": {
"@types/three": "^0.92.18"
}
}

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<Name>treeTest</Name>
<RootNamespace>treeTest</RootNamespace>
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
<SaveNodeJsSettingsInProjectFile>True</SaveNodeJsSettingsInProjectFile>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>1b3989a2-4334-4b78-a666-4d65f1f64141</ProjectGuid>
<ProjectHome>.</ProjectHome>
<StartupFile>3DApp.ts</StartupFile>
<StartWebBrowser>True</StartWebBrowser>
<SearchPath>
</SearchPath>
<WorkingDirectory>.</WorkingDirectory>
<OutputPath>.</OutputPath>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<ProjectTypeGuids>{3AF33F2E-1136-4D97-BBB7-1795711AC8B8};{349c5851-65df-11da-9384-00065b846f21};{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}</ProjectTypeGuids>
<NodejsPort>1337</NodejsPort>
<TypeScriptSourceMap>true</TypeScriptSourceMap>
<TypeScriptModuleKind>CommonJS</TypeScriptModuleKind>
<TypeScriptToolsVersion>2.8</TypeScriptToolsVersion>
<EnableTypeScript>true</EnableTypeScript>
<StartWebBrowser>True</StartWebBrowser>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<TypeScriptCompile Include="3DApp.ts" />
<Content Include="tsconfig.json" />
<Content Include="package.json" />
<Content Include="README.md" />
</ItemGroup>
<!-- Do not delete the following Import Project. While this appears to do nothing it is a marker for setting TypeScript properties before our import that depends on them. -->
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="False" />
<Import Project="$(VSToolsPath)\Node.js Tools\Microsoft.NodejsTools.targets" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>0</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:48022/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>True</UseCustomServer>
<CustomServerUrl>http://localhost:1337</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}" User="">
<WebProjectProperties>
<StartPageUrl>
</StartPageUrl>
<StartAction>CurrentPage</StartAction>
<AspNetDebugging>True</AspNetDebugging>
<SilverlightDebugging>False</SilverlightDebugging>
<NativeDebugging>False</NativeDebugging>
<SQLDebugging>False</SQLDebugging>
<ExternalProgram>
</ExternalProgram>
<StartExternalURL>
</StartExternalURL>
<StartCmdLineArguments>
</StartCmdLineArguments>
<StartWorkingDirectory>
</StartWorkingDirectory>
<EnableENC>False</EnableENC>
<AlwaysStartWebServerOnDebug>False</AlwaysStartWebServerOnDebug>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2019
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}") = "treeTest", "treeTest.njsproj", "{1B3989A2-4334-4B78-A666-4D65F1F64141}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1B3989A2-4334-4B78-A666-4D65F1F64141}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B3989A2-4334-4B78-A666-4D65F1F64141}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B3989A2-4334-4B78-A666-4D65F1F64141}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B3989A2-4334-4B78-A666-4D65F1F64141}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {78D8450B-34CA-4E02-BF96-556A21EAB5F6}
EndGlobalSection
EndGlobal

@ -0,0 +1,15 @@
{
"compilerOptions": {
"module": "amd",
"target": "es5",
"lib": [ "dom", "es5", "dom.iterable", "scripthost" ],
"sourceMap": true,
"allowSyntheticDefaultImports": true,
"outDir": "../dist",
"outFile": "../../build/linq.js",
"declaration": true
},
"exclude": [
"node_modules"
]
}
Loading…
Cancel
Save