Added red coins
This commit is contained in:
4
static/js/prototype/ArrowCamera.js
vendored
4
static/js/prototype/ArrowCamera.js
vendored
@@ -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: 0x00ff00, side:THREE.BackSide}));
|
||||
this.arrow = new THREE.Mesh(new THREE.Geometry(), new THREE.MeshLambertMaterial({color: 0x0000ff, 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 : 0x00ff00,
|
||||
color : 0x0000ff,
|
||||
transparent : true,
|
||||
opacity : 0.5,
|
||||
side: THREE.FrontSide
|
||||
|
||||
37
static/js/prototype/Coin.js
vendored
37
static/js/prototype/Coin.js
vendored
@@ -1,19 +1,7 @@
|
||||
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);
|
||||
}
|
||||
this.ready = false;
|
||||
this.got = false;
|
||||
this.init(x,y,z);
|
||||
}
|
||||
|
||||
Coin.prototype.init = function(x,y,z) {
|
||||
@@ -22,6 +10,8 @@ Coin.prototype.init = function(x,y,z) {
|
||||
this.mesh.position.x = x;
|
||||
this.mesh.position.y = y;
|
||||
this.mesh.position.z = z;
|
||||
this.mesh.raycastable = true;
|
||||
this.ready = true;
|
||||
} else {
|
||||
(function(self,x,y,z) {
|
||||
setTimeout(function() {
|
||||
@@ -36,9 +26,24 @@ Coin.prototype.addToScene = function(scene) {
|
||||
}
|
||||
|
||||
Coin.prototype.update = function() {
|
||||
this.mesh.rotation.y += 0.1;
|
||||
if (this.ready)
|
||||
(function(self) {
|
||||
self.update = function() {
|
||||
self.mesh.rotation.y += 0.1;
|
||||
}
|
||||
})(this);
|
||||
}
|
||||
|
||||
Coin.prototype.get = function() {
|
||||
this.got = true;
|
||||
this.mesh.visible = false;
|
||||
Coin.total ++;
|
||||
var sound = new Audio('/static/data/music/redcoins/' + Coin.total + '.mp3');
|
||||
sound.play();
|
||||
console.log(sound)
|
||||
}
|
||||
|
||||
Coin.total = 0;
|
||||
Coin.BASIC_MESH = null;
|
||||
|
||||
Coin._loader = new THREE.OBJLoader();
|
||||
|
||||
38
static/js/prototype/initScene.js
vendored
38
static/js/prototype/initScene.js
vendored
@@ -139,6 +139,7 @@ function initBobombScene(scene, collidableObjects, loader, static_path) {
|
||||
scene.add(object);
|
||||
object.traverse(function (object) {
|
||||
if (object instanceof THREE.Mesh) {
|
||||
object.raycastable = true;
|
||||
object.material.side = THREE.DoubleSide;
|
||||
object.geometry.mergeVertices();
|
||||
object.geometry.computeVertexNormals();
|
||||
@@ -200,3 +201,40 @@ function createBobombCoins() {
|
||||
|
||||
return coins;
|
||||
}
|
||||
|
||||
function createBobombCameras(width, height) {
|
||||
var cams = [];
|
||||
|
||||
var createCamera = function(position, target) {
|
||||
return new RecommendedCamera(
|
||||
50,
|
||||
width / height,
|
||||
1,
|
||||
100000,
|
||||
position,
|
||||
target
|
||||
);
|
||||
}
|
||||
|
||||
cams.push(
|
||||
createCamera(
|
||||
new THREE.Vector3(-24.10987782946019,26.75997424452833,-24.7814217620827),
|
||||
new THREE.Vector3(-13.724964120740987,14.939165978074758,11.993869660150779)
|
||||
),
|
||||
createCamera(
|
||||
new THREE.Vector3(-13.484471970922971,20.25938194278451,-30.850247430073622),
|
||||
new THREE.Vector3(-42.04654352929252,-7.608886431102082,-28.099304657929874)
|
||||
),
|
||||
createCamera(
|
||||
new THREE.Vector3(23.58849177613168,18.628351213754488,31.516769692916675),
|
||||
new THREE.Vector3(8.319765065757787,-0.5486703304136178,-0.09189730426033549)
|
||||
)
|
||||
// createCamera(
|
||||
// new THREE.Vector3(28.438969076366728,18.888756501203087,26.694456000440766),
|
||||
// new THREE.Vector3(-5.369166248035665,2.54925886583683,12.909289954623416)
|
||||
// )
|
||||
);
|
||||
|
||||
return cams;
|
||||
|
||||
}
|
||||
|
||||
6
static/js/prototype/main.js
vendored
6
static/js/prototype/main.js
vendored
@@ -75,12 +75,12 @@ function init() {
|
||||
directional_light.castShadow = false;
|
||||
scene.add(directional_light);
|
||||
|
||||
var ambient_light = new THREE.AmbientLight(0x444444);
|
||||
var ambient_light = new THREE.AmbientLight(0x555555);
|
||||
scene.add(ambient_light);
|
||||
|
||||
// Initialize pointer camera
|
||||
var camera1 = new PointerCamera(50, container_size.width() / container_size.height(), 0.01, 100000, container);
|
||||
camera1.speed = 0.001;
|
||||
camera1.speed = 0.005;
|
||||
camera1.resetBobomb();
|
||||
camera1.save();
|
||||
scene.add(camera1);
|
||||
@@ -90,7 +90,7 @@ function init() {
|
||||
|
||||
|
||||
// Initialize recommendations
|
||||
var otherCams = createPeachCameras(container_size.width(), container_size.height());
|
||||
var otherCams = createBobombCameras(container_size.width(), container_size.height());
|
||||
cameras = new CameraContainer(camera1, otherCams);
|
||||
otherCams.forEach(function(cam) { cam.addToScene(scene); });
|
||||
|
||||
|
||||
13
static/js/prototype/raycasterTools.js
vendored
13
static/js/prototype/raycasterTools.js
vendored
@@ -41,6 +41,13 @@ CameraSelecter.prototype.pointedCamera = function() {
|
||||
if (bestIndex !== undefined) {
|
||||
// if (this.cameras.getById(intersects[bestIndex].object.parent.id) !== undefined) {
|
||||
var obj = intersects[bestIndex].object;
|
||||
|
||||
for (var coin in coins) {
|
||||
if (obj === coins[coin].mesh) {
|
||||
return coins[coin];
|
||||
}
|
||||
}
|
||||
|
||||
return this.cameras.getByObject(intersects[bestIndex].object);
|
||||
// }
|
||||
}
|
||||
@@ -55,7 +62,7 @@ CameraSelecter.prototype.update = function(event) {
|
||||
|
||||
var hovered = this.pointedCamera(event);
|
||||
|
||||
if (hovered !== undefined) {
|
||||
if (hovered !== undefined && !hovered instanceof Coin) {
|
||||
this.prev.x = this.mouse.x;
|
||||
this.prev.y = this.mouse.y;
|
||||
this.prev.camera = hovered;
|
||||
@@ -67,8 +74,10 @@ CameraSelecter.prototype.update = function(event) {
|
||||
|
||||
CameraSelecter.prototype.click = function(event) {
|
||||
var newCamera = this.pointedCamera(event);
|
||||
if (newCamera !== undefined) {
|
||||
if (newCamera !== undefined && !newCamera instanceof Coin) {
|
||||
this.cameras.mainCamera().moveHermite(newCamera);
|
||||
buttonManager.updateElements();
|
||||
} else if (newCamera instanceof Coin) {
|
||||
newCamera.get();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user