summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ08nY2016-04-16 06:41:19 +0200
committerJ08nY2016-04-16 06:41:19 +0200
commit98dabd8fec5d2930add944997577a5f702013736 (patch)
tree24798a75df26cf252be1044a586cfe0d3604d4fa
parent6c5bbc5fa0bad633325fc3901a3c72c2c0ad64a5 (diff)
downloadld35-98dabd8fec5d2930add944997577a5f702013736.tar.gz
ld35-98dabd8fec5d2930add944997577a5f702013736.tar.zst
ld35-98dabd8fec5d2930add944997577a5f702013736.zip
-rw-r--r--.gitignore46
-rw-r--r--Controls.ts4
-rw-r--r--Enemy.ts12
-rw-r--r--Morph.ts43
-rw-r--r--Player.ts15
-rw-r--r--TargetCamera.ts1
-rw-r--r--World.ts11
-rw-r--r--game.ts136
-rw-r--r--index.html41
-rw-r--r--main.ts68
10 files changed, 373 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index bfa6a22..207cbc6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,47 @@
# Created by .ignore support plugin (hsz.mobi)
+### JetBrains template
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
+
+# User-specific stuff:
+.idea/workspace.xml
+.idea/tasks.xml
+.idea/dictionaries
+.idea/vcs.xml
+.idea/jsLibraryMappings.xml
+
+# Sensitive or high-churn files:
+.idea/dataSources.ids
+.idea/dataSources.xml
+.idea/dataSources.local.xml
+.idea/sqlDataSources.xml
+.idea/dynamic.xml
+.idea/uiDesigner.xml
+
+# Gradle:
+.idea/gradle.xml
+.idea/libraries
+
+# Mongo Explorer plugin:
+.idea/mongoSettings.xml
+
+## File-based project format:
+*.iws
+
+## Plugin-specific files:
+
+# IntelliJ
+/out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
diff --git a/Controls.ts b/Controls.ts
new file mode 100644
index 0000000..0c4adef
--- /dev/null
+++ b/Controls.ts
@@ -0,0 +1,4 @@
+
+module Controls{
+
+} \ No newline at end of file
diff --git a/Enemy.ts b/Enemy.ts
new file mode 100644
index 0000000..5193991
--- /dev/null
+++ b/Enemy.ts
@@ -0,0 +1,12 @@
+/// <reference path="three_js/ts/three.d.ts"/>
+/// <reference path="physi_js/physijs.d.ts"/>
+
+import {Morph} from "./Morph";
+
+export class Enemy extends Morph {
+
+ constructor() {
+ super(null, null, null);
+ //todo
+ }
+} \ No newline at end of file
diff --git a/Morph.ts b/Morph.ts
new file mode 100644
index 0000000..f97ea5c
--- /dev/null
+++ b/Morph.ts
@@ -0,0 +1,43 @@
+/// <reference path="three_js/ts/three.d.ts"/>
+/// <reference path="physi_js/physijs.d.ts"/>
+
+export class Morph extends Physijs.Mesh {
+ faces:number;
+ //TODO, probelm s tym ze ked extendujem Mesh, tak sa nedostanem k Geometry ale iba k BufferGeometry
+
+ constructor(numFaces:number, material:THREE.Material, mass:number) {
+ let geometry = Morph.generateGeometry(numFaces);
+ super(geometry, material, mass);
+ }
+
+ static generateGeometry(numFaces:number):THREE.Geometry {
+ if (numFaces == 4) {
+ return new THREE.TetrahedronGeometry();
+ } else if (numFaces == 6) {
+ return new THREE.BoxGeometry(1, 1, 1, 2, 2, 2);
+ } else if (numFaces == 12) {
+ return new THREE.DodecahedronGeometry(1, 0);
+ } else if (numFaces == 20) {
+ return new THREE.IcosahedronGeometry(1, 0);
+ }
+ return null;
+ }
+
+ private updateGeometry(numFaces:number) {
+ this.faces = numFaces;
+ this.geometry = Morph.generateGeometry(this.faces);
+ }
+
+ shrink(numFaces:number):void {
+ this.updateGeometry(this.faces - numFaces);
+ }
+
+ grow(numFaces:number):void {
+ this.updateGeometry(this.faces + numFaces);
+ }
+
+ wobble():void {
+
+ }
+
+} \ No newline at end of file
diff --git a/Player.ts b/Player.ts
new file mode 100644
index 0000000..07718d2
--- /dev/null
+++ b/Player.ts
@@ -0,0 +1,15 @@
+/// <reference path="three_js/ts/three.d.ts"/>
+/// <reference path="physi_js/physijs.d.ts"/>
+
+import {Morph} from "./Morph";
+
+export class Player extends Morph {
+
+ constructor() {
+ let mat = new THREE.MeshBasicMaterial({
+ color: 0x00b0a0,
+ shading: THREE.SmoothShading
+ });
+ super(4, mat, 1);
+ }
+} \ No newline at end of file
diff --git a/TargetCamera.ts b/TargetCamera.ts
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/TargetCamera.ts
@@ -0,0 +1 @@
+
diff --git a/World.ts b/World.ts
new file mode 100644
index 0000000..b3203be
--- /dev/null
+++ b/World.ts
@@ -0,0 +1,11 @@
+/// <reference path="three_js/ts/three.d.ts"/>
+/// <reference path="physi_js/physijs.d.ts"/>
+
+import {Player} from "./Player";
+
+export class World {
+
+ constructor(player: Player, scene:THREE.Scene, camera:THREE.Camera) {
+
+ }
+} \ No newline at end of file
diff --git a/game.ts b/game.ts
new file mode 100644
index 0000000..8d5da32
--- /dev/null
+++ b/game.ts
@@ -0,0 +1,136 @@
+/// <reference path="three_js/ts/three.d.ts"/>
+/// <reference path="physi_js/physijs.d.ts"/>
+/// <reference path="three_js/ts/detector.d.ts"/>
+
+import Vector3 = THREE.Vector3;
+class Morph extends Physijs.Mesh {
+ faces:number;
+ //TODO, probelm s tym ze ked extendujem Mesh, tak sa nedostanem k Geometry ale iba k BufferGeometry
+
+ constructor(numFaces:number, material:THREE.Material, mass:number) {
+ let geometry = Morph.generateGeometry(numFaces);
+ super(geometry, material, mass);
+ }
+
+ static generateGeometry(numFaces:number):THREE.Geometry {
+ if (numFaces == 4) {
+ return new THREE.TetrahedronGeometry();
+ } else if (numFaces == 6) {
+ return new THREE.BoxGeometry(1, 1, 1, 2, 2, 2);
+ } else if (numFaces == 12) {
+ return new THREE.DodecahedronGeometry(1, 0);
+ } else if (numFaces == 20) {
+ return new THREE.IcosahedronGeometry(1, 0);
+ }
+ return null;
+ }
+
+ private updateGeometry(numFaces:number) {
+ this.faces = numFaces;
+ this.geometry = Morph.generateGeometry(this.faces);
+ }
+
+ shrink(numFaces:number):void {
+ this.updateGeometry(this.faces - numFaces);
+ }
+
+ grow(numFaces:number):void {
+ this.updateGeometry(this.faces + numFaces);
+ }
+
+ wobble():void {
+
+ }
+
+}
+
+class Enemy extends Morph {
+
+ constructor() {
+ super(null, null, null);
+ //todo
+ }
+}
+
+class Player extends Morph {
+
+ constructor() {
+ let mat = new THREE.MeshBasicMaterial({
+ color: 0x00b0a0,
+ });
+ super(4, mat, 1);
+ }
+}
+
+class World {
+
+ constructor(player: Player, scene:THREE.Scene, camera:THREE.Camera) {
+ scene.add(player);
+ }
+}
+
+class Game {
+ renderer:THREE.WebGLRenderer;
+ scene:THREE.Scene;
+ camera:THREE.PerspectiveCamera;
+ player:Player;
+ world: World;
+ private ticks:number;
+ private running:boolean;
+
+ constructor() {
+ this.renderer = new THREE.WebGLRenderer({
+ antialias: true
+ });
+ this.renderer.setClearColor(0xffffff);
+ this.renderer.setPixelRatio(window.devicePixelRatio);
+ this.renderer.setSize(window.innerWidth, window.innerHeight);
+ document.body.appendChild(this.renderer.domElement);
+
+ this.scene = new THREE.Scene();
+ this.camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 1000);
+ }
+
+ init():void {
+ //init world
+ this.player = new Player();
+ this.world = new World(this.player, this.scene, this.camera);
+ this.player.position.set(0,0,0);
+ this.camera.position.set(10,10,10);
+ this.camera.lookAt(this.player.position);
+ //init camera
+ }
+
+ render():void {
+ this.renderer.render(this.scene, this.camera);
+ }
+
+ tick():void {
+ this.ticks++;
+
+ }
+
+ run():void {
+ this.running = true;
+ while (this.running) {
+ this.tick();
+ let shouldRender = true;
+ if (shouldRender) {
+ this.render();
+ }
+
+ }
+ }
+
+}
+
+if (!Detector.webgl) {
+ Detector.addGetWebGLMessage();
+}
+
+window.onload = () => {
+ var game = new Game();
+ game.init();
+
+ //game.run();
+}; \ No newline at end of file
diff --git a/index.html b/index.html
index 9ebca2c..7eafeb6 100644
--- a/index.html
+++ b/index.html
@@ -3,10 +3,45 @@
<head>
<meta charset="UTF-8">
<title>Transmuto</title>
- <script type="text/javascript" src="three.js/dist/three.min.js"></script>
- <script type="text/javascript" src="Physi.js/physi.js"></script>
+ <script type="text/javascript" src="three_js/dist/three.min.js"></script>
+ <script type="text/javascript" src="three_js/src/Detector.js"></script>
+ <script type="text/javascript" src="physi_js/physi.js"></script>
</head>
<body>
-<script type="text/javascript" src="main.js"></script>
+<script id="fragment_shader" type="x-shader/x-fragment">
+
+ uniform float time;
+ uniform vec2 resolution;
+
+ varying vec2 vUv;
+
+ void main( void ) {
+
+ vec2 position = -1.0 + 2.0 * vUv;
+
+ float red = abs( sin( position.x * position.y + time / 5.0 ) );
+ float green = abs( sin( position.x * position.y + time / 4.0 ) );
+ float blue = abs( sin( position.x * position.y + time / 3.0 ) );
+ gl_FragColor = vec4( red, green, blue, 1.0 );
+
+ }
+
+
+
+</script>
+<script id="vertex_shader" type="x-shader/x-vertex">
+
+ varying vec2 vUv;
+
+ void main()
+ {
+ vUv = uv;
+ vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
+ gl_Position = projectionMatrix * mvPosition;
+ }
+
+
+</script>
+<script type="text/javascript" src="game.js"></script>
</body>
</html> \ No newline at end of file
diff --git a/main.ts b/main.ts
index a029f8d..757c4b8 100644
--- a/main.ts
+++ b/main.ts
@@ -1 +1,67 @@
-/// <reference path="three.js/ts/three.d.ts"/>
+/// <reference path="three_js/ts/three.d.ts"/>
+/// <reference path="three_js/ts/detector.d.ts"/>
+
+import {Player} from "./Player";
+import {World} from "./World";
+
+export class Game {
+ renderer:THREE.WebGLRenderer;
+ scene:THREE.Scene;
+ camera:THREE.PerspectiveCamera;
+ player:Player;
+ world:World;
+ private ticks:number;
+ private running:boolean;
+
+ constructor() {
+ this.renderer = new THREE.WebGLRenderer({
+ antialias: true
+ });
+ this.renderer.setClearColor(0xffffff);
+ this.renderer.setPixelRatio(window.devicePixelRatio);
+ this.renderer.setSize(window.innerWidth, window.innerHeight);
+ document.body.appendChild(this.renderer.domElement);
+
+ this.scene = new THREE.Scene();
+ this.camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 1000);
+ }
+
+ init():void {
+ //init world
+ this.player = new Player();
+ this.world = new World(this.player, this.scene, this.camera);
+ //init camera
+
+ }
+
+ render():void {
+ this.renderer.render(this.scene, this.camera);
+ }
+
+ tick():void {
+ this.ticks++;
+
+ }
+
+ run():void {
+ this.running = true;
+ while (this.running) {
+ this.tick();
+ let shouldRender = true;
+ if (shouldRender) {
+ this.render();
+ }
+ }
+ }
+
+}
+
+if (!Detector.webgl) {
+ Detector.addGetWebGLMessage();
+}
+
+window.onload = () => {
+ var game = new Game();
+ game.init();
+ game.run();
+}; \ No newline at end of file