Update: CC - Before Render - Moorcow (72d6a2a3kc.js) 712 bytes modified
parent
6ab5cbc1a0
commit
31d3cb0546
201
72d6a2a3kc.js
201
72d6a2a3kc.js
|
@ -6,26 +6,26 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||||
|
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
|
|
||||||
this.fog = this.entityLoaded.fog;
|
this.fog = this.entityLoaded.fog;
|
||||||
this.bull = this.entityLoaded.bull;
|
this.bull = this.entityLoaded.bull;
|
||||||
this.star = this.entityLoaded.star;
|
this.star = this.entityLoaded.star;
|
||||||
this.burger = this.entityLoaded.burger;
|
this.burger = this.entityLoaded.burger;
|
||||||
this.parcel = this.entityLoaded.parcel;
|
this.parcel = this.entityLoaded.parcel;
|
||||||
this.santa = this.entityLoaded.santa;
|
this.santa = this.entityLoaded.santa;
|
||||||
this.renderer = this.entityLoaded.renderer;
|
this.renderer = this.entityLoaded.renderer;
|
||||||
this.raycaster = this.entityLoaded.raycaster;
|
this.raycaster = this.entityLoaded.raycaster;
|
||||||
this.scene = this.entityLoaded.scene;
|
this.scene = this.entityLoaded.scene;
|
||||||
this.smokeParticleEngine = this.entityLoaded.smokeParticleEngine;
|
this.smokeParticleEngine = this.entityLoaded.smokeParticleEngine;
|
||||||
|
|
||||||
this.toBlack = new THREE.Color(0.05, 0.05, 0.05);
|
this.toBlack = new THREE.Color(0.05, 0.05, 0.05);
|
||||||
this.toRed = new THREE.Color(0.02, 0, 0);
|
this.toRed = new THREE.Color(0.02, 0, 0);
|
||||||
|
|
||||||
|
|
||||||
this.bull.instance.visible = false;
|
this.bull.instance.visible = false;
|
||||||
this.star.instance.visible = false;
|
this.star.instance.visible = false;
|
||||||
this.burger.instance.visible = false;
|
this.burger.instance.visible = false;
|
||||||
this.parcel.instance.visible = false;
|
this.parcel.instance.visible = false;
|
||||||
this.santa.instance.visible = false;
|
this.santa.instance.visible = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component is initializing - set the total time to 0
|
* This component is initializing - set the total time to 0
|
||||||
|
@ -59,59 +59,59 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||||
|
|
||||||
var y = GameLib.Utils.GetRandomIntInclusive(2, 10);
|
var y = GameLib.Utils.GetRandomIntInclusive(2, 10);
|
||||||
|
|
||||||
var speed = 1;
|
var speed = 1;
|
||||||
|
|
||||||
var material = null;
|
var material = null;
|
||||||
|
|
||||||
var mesh = null;
|
var mesh = null;
|
||||||
if (meshType === 1) {
|
if (meshType === 1) {
|
||||||
mesh = this.bull.clone();
|
mesh = this.bull.clone();
|
||||||
material = this.bull.materials[0].clone();
|
material = this.bull.materials[0].clone();
|
||||||
speed = 0.2;
|
speed = 0.2;
|
||||||
} else if (meshType === 2) {
|
} else if (meshType === 2) {
|
||||||
mesh = this.star.clone();
|
mesh = this.star.clone();
|
||||||
material = this.star.materials[0].clone();
|
material = this.star.materials[0].clone();
|
||||||
speed = 0.3;
|
speed = 0.3;
|
||||||
} else if (meshType === 3) {
|
} else if (meshType === 3) {
|
||||||
mesh = this.burger.clone();
|
mesh = this.burger.clone();
|
||||||
material = this.burger.materials[0].clone();
|
material = this.burger.materials[0].clone();
|
||||||
speed = 0.4;
|
speed = 0.4;
|
||||||
} else if (meshType === 4) {
|
} else if (meshType === 4) {
|
||||||
mesh = this.parcel.clone();
|
mesh = this.parcel.clone();
|
||||||
material = this.parcel.materials[0].clone();
|
material = this.parcel.materials[0].clone();
|
||||||
speed = 0.5;
|
speed = 0.5;
|
||||||
} else if (meshType === 5) {
|
} else if (meshType === 5) {
|
||||||
mesh = this.santa.clone();
|
mesh = this.santa.clone();
|
||||||
material = this.santa.materials[0].clone();
|
material = this.santa.materials[0].clone();
|
||||||
speed = 0.5;
|
speed = 0.5;
|
||||||
} else {
|
} else {
|
||||||
console.log('unknown mesh type : ' + meshType);
|
console.log('unknown mesh type : ' + meshType);
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh.materials = [material];
|
mesh.materials = [material];
|
||||||
|
|
||||||
mesh.updateInstance();
|
mesh.updateInstance();
|
||||||
|
|
||||||
mesh.instance.visible = true;
|
mesh.instance.visible = true;
|
||||||
|
|
||||||
var velocity = null;
|
var velocity = null;
|
||||||
|
|
||||||
var axis = new GameLib.API.Vector3(
|
var axis = new GameLib.API.Vector3(
|
||||||
GameLib.Utils.GetRandomIntInclusive(1,10) * 0.1,
|
GameLib.Utils.GetRandomIntInclusive(1,10) * 0.1,
|
||||||
GameLib.Utils.GetRandomIntInclusive(1,10) * 0.1,
|
GameLib.Utils.GetRandomIntInclusive(1,10) * 0.1,
|
||||||
GameLib.Utils.GetRandomIntInclusive(1,10) * 0.1
|
GameLib.Utils.GetRandomIntInclusive(1,10) * 0.1
|
||||||
);
|
);
|
||||||
|
|
||||||
axis = axis.normalize();
|
axis = axis.normalize();
|
||||||
|
|
||||||
var angle = GameLib.Utils.GetRandomIntInclusive(1,100) * 0.001;
|
var angle = GameLib.Utils.GetRandomIntInclusive(1,100) * 0.001;
|
||||||
|
|
||||||
var position = {x : 0, y: y, z :0};
|
var position = {x : 0, y: y, z :0};
|
||||||
|
|
||||||
var rotation = {
|
var rotation = {
|
||||||
axis : axis,
|
axis : axis,
|
||||||
angle : angle
|
angle : angle
|
||||||
};
|
};
|
||||||
|
|
||||||
var enemy = {
|
var enemy = {
|
||||||
mesh : mesh
|
mesh : mesh
|
||||||
|
@ -150,11 +150,11 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||||
enemy.mesh.position.z = position.z;
|
enemy.mesh.position.z = position.z;
|
||||||
enemy.mesh.updateInstancePosition();
|
enemy.mesh.updateInstancePosition();
|
||||||
|
|
||||||
enemy.mesh.useQuaternion = true;
|
enemy.mesh.useQuaternion = true;
|
||||||
enemy.mesh.quaternion.axis.x = rotation.axis.x;
|
enemy.mesh.quaternion.axis.x = rotation.axis.x;
|
||||||
enemy.mesh.quaternion.axis.y = rotation.axis.y;
|
enemy.mesh.quaternion.axis.y = rotation.axis.y;
|
||||||
enemy.mesh.quaternion.axis.z = rotation.axis.z;
|
enemy.mesh.quaternion.axis.z = rotation.axis.z;
|
||||||
enemy.mesh.quaternion.angle = rotation.angle;
|
enemy.mesh.quaternion.angle = rotation.angle;
|
||||||
enemy.mesh.updateInstanceRotation();
|
enemy.mesh.updateInstanceRotation();
|
||||||
|
|
||||||
enemy.velocity = velocity;
|
enemy.velocity = velocity;
|
||||||
|
@ -163,100 +163,99 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||||
enemy.lifeTime = 0;
|
enemy.lifeTime = 0;
|
||||||
enemy.life = 15;
|
enemy.life = 15;
|
||||||
|
|
||||||
enemy.exploding = false;
|
enemy.exploding = false;
|
||||||
|
|
||||||
this.enemies.push(enemy);
|
this.enemies.push(enemy);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.explode = function(mesh) {
|
this.explode = function(mesh) {
|
||||||
var particleEngine = this.smokeParticleEngine.clone();
|
var particleEngine = this.smokeParticleEngine.clone();
|
||||||
particleEngine.position = mesh.position.clone();
|
particleEngine.position = mesh.position.clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.totalTime += data.delta;
|
this.totalTime += data.delta;
|
||||||
this.spawnTime += data.delta;
|
this.spawnTime += data.delta;
|
||||||
|
|
||||||
this.scene.meshes.map(
|
this.scene.meshes.map(
|
||||||
function(mesh) {
|
function(mesh) {
|
||||||
if (mesh.instance.material instanceof Array) {
|
if (mesh.instance.material instanceof Array) {
|
||||||
mesh.instance.material.map(
|
mesh.instance.material.map(
|
||||||
function(material) {
|
function(material) {
|
||||||
if (material.emissive) {
|
if (material.emissive) {
|
||||||
material.emissive.sub(this.toRed);
|
material.emissive.sub(this.toRed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (mesh.instance.material.emissive) {
|
if (mesh.instance.material.emissive) {
|
||||||
mesh.instance.material.emissive.sub(this.toRed);
|
mesh.instance.material.emissive.sub(this.toRed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.mouseIsDown) {
|
if (this.mouseIsDown) {
|
||||||
|
|
||||||
this.fog.color.r += 0.01;
|
this.fog.color.r += 0.01;
|
||||||
if (this.fog.color.r > 1) {
|
if (this.fog.color.r > 1) {
|
||||||
this.fog.color.r = 1;
|
this.fog.color.r = 1;
|
||||||
}
|
}
|
||||||
this.fog.updateInstance('color');
|
this.fog.updateInstance('color');
|
||||||
|
|
||||||
this.renderer.clearColor.r += 0.01;
|
this.renderer.clearColor.r += 0.01;
|
||||||
if (this.renderer.clearColor.r > 1) {
|
if (this.renderer.clearColor.r > 1) {
|
||||||
this.renderer.clearColor.r = 1;
|
this.renderer.clearColor.r = 1;
|
||||||
}
|
}
|
||||||
this.renderer.updateInstance('clearColor');
|
this.renderer.updateInstance('clearColor');
|
||||||
|
|
||||||
var intersects = this.raycaster.getIntersectedObjects(this.scene.meshes);
|
var intersects = this.raycaster.getIntersectedObjects(this.scene.meshes);
|
||||||
intersects.map(
|
intersects.map(
|
||||||
function(intersect) {
|
function(intersect) {
|
||||||
|
|
||||||
var mesh = intersect.mesh;
|
var mesh = intersect.mesh;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
mesh.id !== 'ykfzwmaw9j' && //crosshair
|
mesh.id !== 'ykfzwmaw9j' && //crosshair
|
||||||
mesh.id !== 't3uije6lwm' && //floor
|
mesh.id !== 't3uije6lwm' && //floor
|
||||||
mesh.id !== 'x4rhvbj8cn' && //flamethrower
|
mesh.id !== 'x4rhvbj8cn' && //flamethrower
|
||||||
mesh.id !== 'xztyfgwq7i' && //skybox
|
mesh.id !== 'xztyfgwq7i' && //skybox
|
||||||
mesh.name.indexOf('Stone') === -1 //stones
|
mesh.name.indexOf('Stone') === -1 //stones
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if (mesh.materials[0].name.indexOf('Trees') === -1) {
|
if (mesh.materials[0].name.indexOf('Trees') === -1) {
|
||||||
|
|
||||||
mesh.instance.material.color.sub(this.toBlack);
|
mesh.instance.material.color.sub(this.toBlack);
|
||||||
|
|
||||||
if (mesh.instance.material.color.r
|
if (mesh.instance.material.color.r <= 0) {
|
||||||
|
|
||||||
if (mesh.instance.material.color.r <= 0) {
|
if (mesh.instance.material.emissive) {
|
||||||
if (mesh.instance.material.emissive) {
|
mesh.instance.material.emissive.add(this.toRed);
|
||||||
mesh.instance.material.emissive.add(this.toRed);
|
mesh.instance.material.emissive.add(this.toRed);
|
||||||
mesh.instance.material.emissive.add(this.toRed);
|
|
||||||
|
|
||||||
if (mesh.instance.material.emissive.r >= 0.8) {
|
if (mesh.instance.material.emissive.r >= 0.8) {
|
||||||
this.explode(mesh);
|
this.explode(mesh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
this.renderer.clearColor.r -= 0.01;
|
this.renderer.clearColor.r -= 0.01;
|
||||||
if (this.renderer.clearColor.r < 0) {
|
if (this.renderer.clearColor.r < 0) {
|
||||||
this.renderer.clearColor.r = 0;
|
this.renderer.clearColor.r = 0;
|
||||||
}
|
}
|
||||||
this.renderer.updateInstance('clearColor');
|
this.renderer.updateInstance('clearColor');
|
||||||
|
|
||||||
this.fog.color.r -= 0.01;
|
this.fog.color.r -= 0.01;
|
||||||
if (this.fog.color.r < 0) {
|
if (this.fog.color.r < 0) {
|
||||||
this.fog.color.r = 0;
|
this.fog.color.r = 0;
|
||||||
}
|
}
|
||||||
this.fog.updateInstance('color');
|
this.fog.updateInstance('color');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.spawnTime > this.nextSpawnTime) {
|
if (this.spawnTime > this.nextSpawnTime) {
|
||||||
|
@ -271,7 +270,7 @@ this.enemies = this.enemies.reduce(
|
||||||
enemy.mesh.updateInstancePosition();
|
enemy.mesh.updateInstancePosition();
|
||||||
|
|
||||||
enemy.mesh.quaternion.angle += enemy.rotation.angle;
|
enemy.mesh.quaternion.angle += enemy.rotation.angle;
|
||||||
enemy.mesh.updateInstanceRotation();
|
enemy.mesh.updateInstanceRotation();
|
||||||
|
|
||||||
enemy.lifeTime += data.delta;
|
enemy.lifeTime += data.delta;
|
||||||
if (enemy.lifeTime > enemy.life) {
|
if (enemy.lifeTime > enemy.life) {
|
||||||
|
|
Loading…
Reference in New Issue