Added coins and changed scene

This commit is contained in:
Thomas FORGIONE 2015-05-11 12:04:37 +02:00
parent b1cf8afaaf
commit 687b84f438
7 changed files with 569 additions and 39 deletions

View File

@ -12,6 +12,7 @@ block extrajs
script(src="/static/js/prototype/raycasterTools.js")
script(src="/static/js/prototype/Previewer.js")
script(src="/static/js/prototype/ButtonManager.js")
script(src="/static/js/prototype/Coin.js")
if cameraStyle == 'arrows'
script RecommendedCamera = FixedCamera;
else if cameraStyle == 'viewports'

441
static/data/coin/Coin.obj Normal file
View File

@ -0,0 +1,441 @@
# WaveFront *.obj file (generated by CINEMA 4D)
g coin
v -40.078125 50.765625 -7.109375
v -45.542969 71.191406 -7.109375
v -40.078125 91.613281 -7.109375
v -20.417969 111.273438 -7.109375
v 0.003906 116.738281 -7.109375
v 20.429688 111.273438 -7.109375
v 40.089844 91.613281 -7.109375
v 45.554688 71.191406 -7.109375
v 39.894531 50.257812 -7.109375
v 21.628906 31.382812 -7.109375
v 0.003906 25.640625 -7.109375
v -20.417969 31.105469 -7.109375
v -8.371094 44.738281 -11.738281
v 8.371094 44.738281 -11.738281
v 8.371094 98.230469 -11.738281
v -8.371094 98.230469 -11.738281
v 8.371094 44.738281 -2.425781
v -8.371094 44.738281 -2.425781
v -8.371094 98.230469 -2.425781
v 8.371094 98.230469 -2.425781
v 5.992188 47.542969 -2.425781
v -5.992188 47.542969 -2.425781
v -5.992188 95.425781 -2.425781
v 5.992188 95.425781 -2.425781
v 40.089844 50.765625 7.109375
v 45.554688 71.191406 7.109375
v 40.089844 91.613281 7.109375
v 20.429688 111.273438 7.109375
v 0.003906 116.738281 7.109375
v -20.417969 111.273438 7.109375
v -40.078125 91.613281 7.109375
v -45.542969 71.191406 7.109375
v -40.078125 50.765625 7.109375
v -20.417969 31.105469 7.109375
v 0.003906 25.640625 7.109375
v 21.746094 31.234375 7.109375
v -8.371094 44.738281 11.738281
v -8.371094 98.230469 11.738281
v 8.371094 98.230469 11.738281
v 8.371094 44.738281 11.738281
v -8.371094 44.738281 2.988281
v -8.371094 98.230469 2.988281
v 8.371094 44.738281 2.988281
v 8.371094 98.230469 2.988281
v -5.992188 95.425781 2.988281
v 5.992188 95.425781 2.988281
v -5.992188 47.542969 2.988281
v 5.992188 47.542969 2.988281
v 22.824219 102.597656 11.496094
v 31.410156 94.007812 11.496094
v 36.925781 83.1875 11.496094
v 38.824219 71.191406 11.496094
v 36.925781 59.191406 11.496094
v 31.410156 48.371094 11.496094
v 22.824219 39.78125 11.496094
v 11.828125 34.238281 11.496094
v 0.003906 32.367188 11.496094
v -11.816406 34.242188 11.496094
v -22.8125 39.78125 11.496094
v -31.402344 48.371094 11.496094
v -36.914062 59.191406 11.496094
v -38.816406 71.191406 11.496094
v -36.914062 83.1875 11.496094
v -31.402344 94.007812 11.496094
v -22.8125 102.597656 11.496094
v -11.761719 108.148438 11.496094
v 0.003906 110.011719 11.496094
v 11.773438 108.148438 11.496094
v -36.914062 59.191406 -11.496094
v -31.402344 48.371094 -11.496094
v -38.816406 71.191406 -11.496094
v -36.914062 83.1875 -11.496094
v -31.402344 94.007812 -11.496094
v -22.8125 102.597656 -11.496094
v -11.761719 108.148438 -11.496094
v 0.003906 110.011719 -11.496094
v 11.773438 108.148438 -11.496094
v 22.824219 102.597656 -11.496094
v 31.410156 94.007812 -11.496094
v 36.925781 83.1875 -11.496094
v 38.824219 71.191406 -11.496094
v 36.925781 59.191406 -11.496094
v 31.410156 48.371094 -11.496094
v 22.824219 39.78125 -11.496094
v 11.828125 34.238281 -11.496094
v 0.003906 32.367188 -11.496094
v -11.816406 34.242188 -11.496094
v -22.8125 39.78125 -11.496094
v 15.332031 24.015625 -7.757812
v 0.003906 21.589844 -7.757812
v -15.320312 24.015625 -7.757812
v -29.148438 31.0625 -7.757812
v -40.121094 42.035156 -7.757812
v -47.164062 55.863281 -7.757812
v -49.59375 71.191406 -7.757812
v -47.164062 86.515625 -7.757812
v -40.121094 100.34375 -7.757812
v -29.148438 111.316406 -7.757812
v -15.320312 118.363281 -7.757812
v 0.003906 120.789062 -7.757812
v 15.332031 118.363281 -7.757812
v 29.15625 111.316406 -7.757812
v 40.132812 100.34375 -7.757812
v 47.175781 86.515625 -7.757812
v 49.605469 71.191406 -7.757812
v 47.175781 55.863281 -7.757812
v 40.132812 42.035156 -7.757812
v 29.15625 31.0625 -7.757812
v 15.332031 24.015625 7.757812
v 0.003906 21.589844 7.757812
v -15.320312 24.015625 7.757812
v -29.148438 31.0625 7.757812
v -40.121094 42.035156 7.757812
v -47.164062 55.863281 7.757812
v -49.59375 71.191406 7.757812
v -47.164062 86.515625 7.757812
v -40.121094 100.34375 7.757812
v -29.148438 111.316406 7.757812
v -15.320312 118.363281 7.757812
v 0.003906 120.789062 7.757812
v 15.332031 118.363281 7.757812
v 29.15625 111.316406 7.757812
v 40.132812 100.34375 7.757812
v 47.175781 86.515625 7.757812
v 49.605469 71.191406 7.757812
v 47.175781 55.863281 7.757812
v 40.132812 42.035156 7.757812
v 29.15625 31.0625 7.757812
v 22.824219 102.597656 7.109375
v 31.410156 94.007812 7.109375
v 36.925781 83.1875 7.109375
v 38.824219 71.191406 7.109375
v 36.925781 59.191406 7.109375
v 31.410156 48.371094 7.109375
v 22.824219 39.78125 7.109375
v 12 34.265625 7.109375
v 0.003906 32.367188 7.109375
v -11.988281 34.265625 7.109375
v -22.8125 39.78125 7.109375
v -31.402344 48.371094 7.109375
v -36.914062 59.191406 7.109375
v -38.816406 71.191406 7.109375
v -36.914062 83.1875 7.109375
v -31.402344 94.007812 7.109375
v -22.8125 102.597656 7.109375
v -11.988281 108.113281 7.109375
v 0.003906 110.011719 7.109375
v 12 108.113281 7.109375
v -36.914062 59.191406 -7.109375
v -31.402344 48.371094 -7.109375
v -38.816406 71.191406 -7.109375
v -36.914062 83.1875 -7.109375
v -31.402344 94.007812 -7.109375
v -22.8125 102.597656 -7.109375
v -11.988281 108.113281 -7.109375
v 0.003906 110.011719 -7.109375
v 12 108.113281 -7.109375
v 22.824219 102.597656 -7.109375
v 31.410156 94.007812 -7.109375
v 36.925781 83.1875 -7.109375
v 38.824219 71.191406 -7.109375
v 36.925781 59.191406 -7.109375
v 31.410156 48.371094 -7.109375
v 22.824219 39.78125 -7.109375
v 12 34.265625 -7.109375
v 0.003906 32.367188 -7.109375
v -11.988281 34.265625 -7.109375
v -22.8125 39.78125 -7.109375
f 70 150 88
f 150 70 149
f 69 149 70
f 149 69 151
f 71 151 69
f 151 71 152
f 72 152 71
f 152 72 153
f 73 153 72
f 153 73 154
f 74 154 73
f 154 74 155
f 75 155 74
f 155 75 156
f 76 156 75
f 156 76 77
f 148 68 147
f 68 148 49
f 129 49 148
f 49 129 50
f 130 50 129
f 50 130 51
f 131 51 130
f 51 131 52
f 132 52 131
f 52 132 53
f 133 53 132
f 53 133 54
f 134 54 133
f 54 134 55
f 49 122 121
f 122 49 123
f 50 123 49
f 123 50 124
f 51 124 50
f 124 51 125
f 52 125 51
f 125 52 126
f 53 126 52
f 126 53 127
f 54 127 53
f 127 54 128
f 55 128 54
f 74 98 99
f 98 74 97
f 73 97 74
f 97 73 96
f 72 96 73
f 96 72 95
f 71 95 72
f 95 71 94
f 69 94 71
f 94 69 93
f 70 93 69
f 43 47 41
f 47 43 48
f 44 48 43
f 48 44 46
f 42 46 44
f 46 42 45
f 41 45 42
f 45 41 47
f 79 103 80
f 103 79 102
f 78 102 79
f 102 78 101
f 77 101 78
f 101 77 76
f 146 65 145
f 65 146 66
f 147 66 146
f 66 147 67
f 68 67 147
f 65 118 117
f 118 65 119
f 66 119 65
f 119 66 67
f 24 23 20
f 23 24 22
f 21 22 24
f 22 21 18
f 5 16 4
f 16 5 15
f 6 15 5
f 15 6 7
f 157 78 158
f 78 157 77
f 156 77 157
f 38 30 31
f 30 38 29
f 39 29 38
f 14 11 13
f 11 14 10
f 9 10 14
f 123 103 102
f 103 123 124
f 124 104 103
f 104 124 125
f 125 105 104
f 105 125 126
f 75 99 100
f 99 75 74
f 92 70 88
f 70 92 93
f 126 106 105
f 106 126 127
f 127 107 106
f 107 127 128
f 128 108 107
f 108 128 109
f 109 89 108
f 89 109 110
f 68 120 67
f 120 68 121
f 90 110 111
f 110 90 89
f 168 88 150
f 88 168 167
f 166 86 87
f 86 166 85
f 110 57 111
f 57 110 109
f 60 112 59
f 112 60 113
f 99 119 120
f 119 99 98
f 114 61 62
f 61 114 113
f 98 118 119
f 118 98 97
f 97 117 118
f 117 97 96
f 96 116 117
f 116 96 95
f 163 82 83
f 82 163 162
f 162 81 82
f 81 162 161
f 161 80 81
f 80 161 160
f 160 79 80
f 79 160 159
f 159 78 79
f 78 159 158
f 64 117 116
f 117 64 65
f 141 62 61
f 62 141 142
f 142 63 62
f 63 142 143
f 143 64 63
f 64 143 144
f 144 65 64
f 65 144 145
f 84 108 89
f 108 84 107
f 57 137 58
f 137 57 56
f 95 115 116
f 115 95 94
f 28 39 27
f 39 28 29
f 40 25 26
f 25 40 36
f 23 19 20
f 19 23 22
f 94 114 115
f 114 94 93
f 48 45 47
f 45 48 46
f 44 38 42
f 38 44 39
f 43 39 44
f 39 43 40
f 17 24 20
f 24 17 21
f 93 113 114
f 113 93 92
f 92 112 113
f 112 92 91
f 3 16 2
f 16 3 4
f 91 111 112
f 111 91 90
f 18 16 19
f 16 18 13
f 17 13 18
f 13 17 14
f 19 15 20
f 15 19 16
f 101 121 122
f 102 101 122
f 100 120 121
f 101 100 121
f 100 101 76
f 86 91 87
f 90 91 86
f 87 88 167
f 100 99 120
f 165 85 166
f 165 164 84
f 85 165 84
f 164 163 83
f 84 164 83
f 85 84 89
f 83 82 106
f 107 83 106
f 84 83 107
f 81 80 104
f 105 81 104
f 82 81 105
f 106 82 105
f 104 80 103
f 76 75 100
f 88 87 91
f 167 166 87
f 140 141 61
f 60 140 61
f 139 140 60
f 59 139 60
f 138 139 59
f 58 138 59
f 92 88 91
f 138 58 137
f 136 137 56
f 55 135 136
f 56 55 136
f 134 135 55
f 86 85 90
f 39 26 27
f 89 90 85
f 40 26 39
f 68 49 121
f 55 56 109
f 35 37 34
f 37 33 34
f 37 32 33
f 38 32 37
f 32 38 31
f 128 55 109
f 57 58 111
f 59 111 58
f 112 111 59
f 40 43 41
f 37 40 41
f 37 41 42
f 38 37 42
f 35 36 40
f 115 114 62
f 61 113 60
f 35 40 37
f 18 19 22
f 17 18 21
f 64 116 63
f 14 8 9
f 15 8 14
f 13 12 1
f 13 1 2
f 16 13 2
f 63 115 62
f 116 115 63
f 8 15 7
f 120 119 67
f 56 57 109
f 14 17 20
f 15 14 20
f 102 122 123
f 11 12 13

View File

@ -94,7 +94,7 @@ PointerCamera.prototype.hermiteMotion = function() {
this.target = Tools.sum(this.position, this.hermiteAngles.eval(this.t));
this.t += 0.005;
this.t += 0.01;
if (this.t > 1) {
this.movingHermite = false;
@ -155,8 +155,15 @@ PointerCamera.prototype.normalMotion = function() {
}
PointerCamera.prototype.reset = function() {
this.position.copy(new THREE.Vector3(-8.849933489419644, 9.050627639459208, 0.6192960680432451));
this.target.copy(new THREE.Vector3(17.945323228767702, -15.156828589982375, -16.585740412769756));
this.resetBobomb();
// this.position.copy(new THREE.Vector3(-8.849933489419644, 9.050627639459208, 0.6192960680432451));
// this.target.copy(new THREE.Vector3(17.945323228767702, -15.156828589982375, -16.585740412769756));
// this.anglesFromVectors();
}
PointerCamera.prototype.resetBobomb = function() {
this.position.copy(new THREE.Vector3(34.51854618261728,10.038879540840306,-21.772598201888613));
this.target.copy(new THREE.Vector3(-2.593404107644737,8.039712770013185,-6.983870133675925));
this.anglesFromVectors();
}
@ -238,7 +245,7 @@ PointerCamera.prototype.isColliding = function(direction) {
var intersects = this.raycaster.intersectObjects(this.collidableObjects, true);
for (var i in intersects) {
if (intersects[i].distance < 0.1) {
if (intersects[i].distance < 100*this.speed) {
return true;
}
}

View File

@ -27,7 +27,7 @@ var ArrowCamera = function(arg1, arg2, arg3, arg4, position, target) {
this.target.add(Tools.mul(direction,20));
this.arrow = new THREE.Mesh(new THREE.Geometry(), new THREE.MeshLambertMaterial({color: 0xff0000, side:THREE.BackSide}));
this.arrow = new THREE.Mesh(new THREE.Geometry(), new THREE.MeshLambertMaterial({color: 0x00ff00, side:THREE.BackSide}));
this.object3D = new THREE.Object3D();
this.object3D.add(this.initExtremity());
@ -72,7 +72,7 @@ ArrowCamera.prototype.initExtremity = function() {
geometry.computeFaceNormals();
var material = new THREE.MeshLambertMaterial({
color : 0xff0000,
color : 0x00ff00,
transparent : true,
opacity : 0.5,
side: THREE.FrontSide

58
static/js/prototype/Coin.js vendored Normal file
View File

@ -0,0 +1,58 @@
var Coin = function(x,y,z) {
if (Coin.BASIC_MESH !== null) {
this.mesh = Coin.BASIC_MESH.clone();
this.mesh.position.x = x;
this.mesh.position.y = y;
this.mesh.position.z = z;
} else {
(function(self) {
setTimeout(function() {
self.mesh = Coin.BASIC_MESH.clone();
self.mesh.position.x = x;
self.mesh.position.y = y;
self.mesh.position.z = z;
},1000);
})(this);
}
}
Coin.prototype.init = function(x,y,z) {
if (Coin.BASIC_MESH !== null) {
this.mesh = Coin.BASIC_MESH.clone();
this.mesh.position.x = x;
this.mesh.position.y = y;
this.mesh.position.z = z;
} else {
(function(self,x,y,z) {
setTimeout(function() {
self.init(x,y,z);
},1000);
})(this,x,y,z);
}
}
Coin.prototype.addToScene = function(scene) {
scene.add(this.mesh);
}
Coin.prototype.update = function() {
this.mesh.rotation.y += 0.1;
}
Coin.BASIC_MESH = null;
Coin._loader = new THREE.OBJLoader();
Coin._loader.load(
static_path + 'data/coin/Coin.obj',
function(object) {
object.traverse(function (mesh) {
if (mesh instanceof THREE.Mesh) {
mesh.scale.set(0.005,0.005,0.005);
mesh.material.color.setHex(0xff0000);
mesh.geometry.computeVertexNormals();
mesh.raycastable = true;
Coin.BASIC_MESH = mesh
}
});
}
);

View File

@ -61,6 +61,7 @@ function initPeachCastle(scene, collidableObjects, loader, static_path) {
});
}
);
}
@ -111,7 +112,7 @@ function createPeachCameras(width, height) {
return cams;
}
function initBobombScene(scene, loader, static_path) {
function initBobombScene(scene, collidableObjects, loader, static_path) {
// Create loader if not already done
if (loader === undefined) {
loader = new THREE.OBJMTLLoader();
@ -139,7 +140,6 @@ function initBobombScene(scene, loader, static_path) {
object.traverse(function (object) {
if (object instanceof THREE.Mesh) {
object.material.side = THREE.DoubleSide;
console.log(object.geometry.vertices.length);
object.geometry.mergeVertices();
object.geometry.computeVertexNormals();
if (object.material.name === 'Material.071_574B138E_c.bmp' ||
@ -152,36 +152,51 @@ function initBobombScene(scene, loader, static_path) {
}
);
loader.load(
static_path + 'data/star/GrandStar.obj',
static_path + 'data/star/GrandStar.mtl',
function ( object ) {
object.position.z -= 10.9;
object.position.y += 0.555;
object.position.x += 3.23;
// loader.load(
// static_path + 'data/star/GrandStar.obj',
// static_path + 'data/star/GrandStar.mtl',
// function ( object ) {
// object.position.z -= 10.9;
// object.position.y += 0.555;
// object.position.x += 3.23;
var theta = 0.27;
object.rotation.y = Math.PI - theta;
// var theta = 0.27;
// object.rotation.y = Math.PI - theta;
object.up = new THREE.Vector3(0,0,1);
scene.add(object);
collidableObjects.push(object);
object.traverse(function (object) {
if (object instanceof THREE.Mesh) {
object.scale.set(0.005,0.005,0.005);
object.position.x = 13;
object.position.z = -35;
object.position.y = 30;
// object.up = new THREE.Vector3(0,0,1);
// scene.add(object);
// collidableObjects.push(object);
// object.traverse(function (object) {
// if (object instanceof THREE.Mesh) {
// object.scale.set(0.005,0.005,0.005);
// object.position.x = 13;
// object.position.z = -35;
// object.position.y = 30;
object.rotation.z = Math.PI/2;
object.rotation.x = Math.PI/2;
object.rotation.y = Math.PI;
object.material.side = THREE.DoubleSide;
object.geometry.mergeVertices();
object.geometry.computeVertexNormals();
object.raycastable = true;
}
});
// object.rotation.z = Math.PI/2;
// object.rotation.x = Math.PI/2;
// object.rotation.y = Math.PI;
// object.material.side = THREE.DoubleSide;
// object.geometry.mergeVertices();
// object.geometry.computeVertexNormals();
// object.raycastable = true;
// }
// });
// }
//);
}
function createBobombCoins() {
var coins = [];
coins.push(
new Coin(30.451451579494677,12.95882671478358,-4.441244895059621),
new Coin(-23.255456493345882,15.763954882327724,-11.08029248078497),
new Coin(-7.238094745133173,12.95460420281499,-3.1009487490121885),
new Coin(-17.10578612221326,24.17871082944758,-11.574224169812915),
new Coin(-19.696802461559027,29.787916906980758,17.187300848990844),
new Coin(-12.418656949661646,17.09780294217035,32.472022253887665)
);
return coins;
}

View File

@ -10,6 +10,7 @@ var stats;
var previewer;
var loader;
var coins;
var main_section = document.getElementById('main-section');
var offset = function() {
@ -80,7 +81,7 @@ function init() {
// Initialize pointer camera
var camera1 = new PointerCamera(50, container_size.width() / container_size.height(), 0.01, 100000, container);
camera1.speed = 0.001;
camera1.reset();
camera1.resetBobomb();
camera1.save();
scene.add(camera1);
@ -97,7 +98,11 @@ function init() {
var loader = new THREE.OBJMTLLoader();
// Load scene
initPeachCastle(scene, collidableObjects, loader, static_path);
// initPeachCastle(scene, collidableObjects, loader, static_path);
initBobombScene(scene, collidableObjects, loader, static_path);
coins = createBobombCoins();
setTimeout(function() {coins.forEach(function(coin) { coin.addToScene(scene);})}, 1000);
// Add listeners
initListeners();
@ -194,6 +199,9 @@ function render() {
}
});
// Update coins
coins.forEach(function(coin) { coin.update(); });
// Update main camera
cameras.updateMainCamera();