levels
This commit is contained in:
parent
80f11ac384
commit
2e4c5e5233
|
@ -12,6 +12,7 @@ Bullet = require './bullet'
|
||||||
Pos = require './lib/pos'
|
Pos = require './lib/pos'
|
||||||
Vector = require './lib/vector'
|
Vector = require './lib/vector'
|
||||||
Quaternion = require './lib/quaternion'
|
Quaternion = require './lib/quaternion'
|
||||||
|
Material = require './material'
|
||||||
|
|
||||||
class Bot extends Pushable
|
class Bot extends Pushable
|
||||||
|
|
||||||
|
@ -39,35 +40,17 @@ class Bot extends Pushable
|
||||||
geom.rotateX Vector.DEG2RAD -90
|
geom.rotateX Vector.DEG2RAD -90
|
||||||
geom.scale 0.7, 0.7, 0.7
|
geom.scale 0.7, 0.7, 0.7
|
||||||
|
|
||||||
@botMat = new THREE.MeshPhongMaterial
|
@mesh = new THREE.Mesh geom, Material.bot
|
||||||
color: 0x2222ff
|
|
||||||
side: THREE.FrontSide
|
|
||||||
shading: THREE.SmoothShading
|
|
||||||
transparent: true
|
|
||||||
opacity: 1
|
|
||||||
shininess: 5
|
|
||||||
|
|
||||||
@mesh = new THREE.Mesh geom, @botMat
|
|
||||||
|
|
||||||
geom = new THREE.TorusGeometry 0.5-tireRadius, tireRadius, 16, 32
|
geom = new THREE.TorusGeometry 0.5-tireRadius, tireRadius, 16, 32
|
||||||
geom.scale 1,1,2.5
|
geom.scale 1,1,2.5
|
||||||
|
|
||||||
@tireMat = new THREE.MeshPhongMaterial
|
@leftTire = new THREE.Mesh geom, Material.tire
|
||||||
color: 0x000066
|
|
||||||
specular: 0x222255
|
|
||||||
side: THREE.FrontSide
|
|
||||||
shading: THREE.FlatShading
|
|
||||||
transparent: true
|
|
||||||
opacity: 1
|
|
||||||
shininess: 4
|
|
||||||
# alphaTest: 0.1
|
|
||||||
|
|
||||||
@leftTire = new THREE.Mesh geom, @tireMat
|
|
||||||
@leftTire.position.set 0.35,0,0
|
@leftTire.position.set 0.35,0,0
|
||||||
@leftTire.rotation.set 0, Vector.DEG2RAD(90), 0
|
@leftTire.rotation.set 0, Vector.DEG2RAD(90), 0
|
||||||
@mesh.add @leftTire
|
@mesh.add @leftTire
|
||||||
|
|
||||||
@rightTire = new THREE.Mesh geom, @tireMat
|
@rightTire = new THREE.Mesh geom, Material.tire
|
||||||
@rightTire.position.set -0.35,0,0
|
@rightTire.position.set -0.35,0,0
|
||||||
@rightTire.rotation.set 0, Vector.DEG2RAD(-90), 0
|
@rightTire.rotation.set 0, Vector.DEG2RAD(-90), 0
|
||||||
@mesh.add @rightTire
|
@mesh.add @rightTire
|
||||||
|
@ -114,8 +97,11 @@ class Bot extends Pushable
|
||||||
@startTimedAction @getActionWithId(Action.NOOP), 500
|
@startTimedAction @getActionWithId(Action.NOOP), 500
|
||||||
|
|
||||||
setOpacity: (opacity) ->
|
setOpacity: (opacity) ->
|
||||||
@botMat.opacity = opacity
|
Material.tire.visible = opacity > 0
|
||||||
@tireMat.opacity = opacity
|
Material.tire.depthWrite = opacity > 0.5
|
||||||
|
Material.bot.depthWrite = opacity > 0.5
|
||||||
|
Material.bot.opacity = opacity
|
||||||
|
Material.tire.opacity = opacity
|
||||||
|
|
||||||
# 0000000 000 00000000 00000000 0000000 000000000 000 0000000 000 000
|
# 0000000 000 00000000 00000000 0000000 000000000 000 0000000 000 000
|
||||||
# 000 000 000 000 000 000 000 000 000 000 000 0000 000
|
# 000 000 000 000 000 000 000 000 000 000 000 0000 000
|
||||||
|
|
|
@ -9,7 +9,7 @@ class Levels
|
||||||
constructor: () ->
|
constructor: () ->
|
||||||
@dict = {}
|
@dict = {}
|
||||||
@list = [
|
@list = [
|
||||||
"test",
|
# "test",
|
||||||
# intro
|
# intro
|
||||||
# "steps",
|
# "steps",
|
||||||
# "start",
|
# "start",
|
||||||
|
@ -41,7 +41,11 @@ class Levels
|
||||||
# "spiral",
|
# "spiral",
|
||||||
# difficult
|
# difficult
|
||||||
# "slick",
|
# "slick",
|
||||||
"bridge", "flower", "stones", "walls", "grid",
|
# "bridge",
|
||||||
|
# "flower",
|
||||||
|
# "stones",
|
||||||
|
# "walls",
|
||||||
|
# "grid",
|
||||||
"rings",
|
"rings",
|
||||||
# "core",
|
# "core",
|
||||||
"bronze", "pool",
|
"bronze", "pool",
|
||||||
|
|
|
@ -24,16 +24,14 @@ module.exports =
|
||||||
]
|
]
|
||||||
create: ->
|
create: ->
|
||||||
s = world.size
|
s = world.size
|
||||||
Stone = require './stone'
|
{Stone} = require '../items'
|
||||||
for m in [[1,'Wall'], [2,'Stone']]
|
for m in [[1,'Wall'], [2,'Stone']]
|
||||||
for k in [-1*m[0],1*m[0]]
|
for k in [-1*m[0],1*m[0]]
|
||||||
for l in [-1*m[0],1*m[0]]
|
for l in [-1*m[0],1*m[0]]
|
||||||
world.addObjectLine m[1], s.x/2+k, s.y/2+l ,0, s.x/2+k, s.y/2+l ,3
|
world.addObjectLine m[1], s.x/2+k, s.y/2+l ,0, s.x/2+k, s.y/2+l ,3
|
||||||
world.addObjectLine m[1], s.x/2+k, s.y/2+l ,8, s.x/2+k, s.y/2+l ,s.z
|
world.addObjectLine m[1], s.x/2+k, s.y/2+l ,8, s.x/2+k, s.y/2+l ,s.z
|
||||||
|
world.addObjectAtPos new Stone(color:[0,1,0,0.5], slippery:true), world.decenter 1,0,0
|
||||||
|
world.addObjectAtPos new Stone(color:[0,1,0,0.5], slippery:true), world.decenter -1,0,0
|
||||||
world.addObjectAtPos new Stone(KColor(0,1,0,0.5), true), world.decenter(1,0,0)
|
world.addObjectAtPos new Stone(color:[0,1,0,0.5], slippery:true), world.decenter 0,1,0
|
||||||
world.addObjectAtPos new Stone(KColor(0,1,0,0.5), true), world.decenter(-1,0,0)
|
world.addObjectAtPos new Stone(color:[0,1,0,0.5], slippery:true), world.decenter 0,-1,0
|
||||||
world.addObjectAtPos new Stone(KColor(0,1,0,0.5), true), world.decenter(0,1,0)
|
|
||||||
world.addObjectAtPos new Stone(KColor(0,1,0,0.5), true), world.decenter(0,-1,0)
|
|
||||||
|
|
|
@ -24,37 +24,39 @@ module.exports =
|
||||||
create: ->
|
create: ->
|
||||||
s = world.size
|
s = world.size
|
||||||
|
|
||||||
world.addObjectAtPos('KikiWireStone', world.decenter(-1, 0, 0))
|
{Wire,Face,Generator,MotorCylinder,MotorGear,Gear} = require '../items'
|
||||||
world.addObjectAtPos('KikiWireStone', world.decenter( 1, 0, 0))
|
|
||||||
world.addObjectAtPos('KikiWireStone', world.decenter( 0,-1, 0))
|
|
||||||
world.addObjectAtPos('KikiWireStone', world.decenter( 0, 1, 0))
|
|
||||||
world.addObjectAtPos('KikiWireStone', world.decenter( 0, 0,-1))
|
|
||||||
world.addObjectAtPos('KikiWireStone', world.decenter( 0, 0, 1))
|
|
||||||
|
|
||||||
world.addObjectAtPos(KikiGear(KikiFace.PY), s.x/2-1, 0, s.z/2-1)
|
world.addObjectAtPos 'WireStone', world.decenter -1, 0, 0
|
||||||
world.addObjectAtPos(KikiGear(KikiFace.PY), s.x/2+1, 0, s.z/2-1)
|
world.addObjectAtPos 'WireStone', world.decenter 1, 0, 0
|
||||||
world.addObjectAtPos(KikiGear(KikiFace.PY), s.x/2-1, 0, s.z/2+1)
|
world.addObjectAtPos 'WireStone', world.decenter 0,-1, 0
|
||||||
|
world.addObjectAtPos 'WireStone', world.decenter 0, 1, 0
|
||||||
|
world.addObjectAtPos 'WireStone', world.decenter 0, 0,-1
|
||||||
|
world.addObjectAtPos 'WireStone', world.decenter 0, 0, 1
|
||||||
|
|
||||||
|
world.addObjectAtPos new Gear(Face.Y), s.x/2-1, 0, s.z/2-1
|
||||||
|
world.addObjectAtPos new Gear(Face.Y), s.x/2+1, 0, s.z/2-1
|
||||||
|
world.addObjectAtPos new Gear(Face.Y), s.x/2-1, 0, s.z/2+1
|
||||||
|
|
||||||
d = 3
|
d = 3
|
||||||
world.addObjectAtPos(KikiGenerator(KikiFace.PY), s.x/2+1, 0, s.z/2+1)
|
world.addObjectAtPos new Generator(Face.Y), s.x/2+1, 0, s.z/2+1
|
||||||
world.addObjectAtPos(KikiMotorCylinder(KikiFace.PY), s.x/2, 1, s.z/2)
|
world.addObjectAtPos new MotorCylinder(Face.Y), s.x/2, 1, s.z/2
|
||||||
world.addObjectAtPos(KikiMotorGear(KikiFace.PY), s.x/2, 0, s.z/2)
|
world.addObjectAtPos new MotorGear(Face.Y), s.x/2, 0, s.z/2
|
||||||
|
|
||||||
# floor wire square
|
# floor wire square
|
||||||
world.addObjectLine("KikiWire(KikiFace.PY, 10)", s.x/2-d+1, 0, s.z/2-d, s.x/2+d, 0, s.z/2-d)
|
world.addObjectLine 'new Wire(Face.Y, 10)', s.x/2-d+1, 0, s.z/2-d, s.x/2+d, 0, s.z/2-d
|
||||||
world.addObjectLine("KikiWire(KikiFace.PY, 10)", s.x/2-d+1, 0, s.z/2+d, s.x/2+d, 0, s.z/2+d)
|
world.addObjectLine 'new Wire(Face.Y, 10)', s.x/2-d+1, 0, s.z/2+d, s.x/2+d, 0, s.z/2+d
|
||||||
world.addObjectLine("KikiWire(KikiFace.PY, 5)", s.x/2-d, 0, s.z/2-d+1, s.x/2-d, 0, s.z/2+d)
|
world.addObjectLine 'new Wire(Face.Y, 5)', s.x/2-d, 0, s.z/2-d+1, s.x/2-d, 0, s.z/2+d
|
||||||
world.addObjectLine("KikiWire(KikiFace.PY, 5)", s.x/2+d, 0, s.z/2-d+1, s.x/2+d, 0, s.z/2+d)
|
world.addObjectLine 'new Wire(Face.Y, 5)', s.x/2+d, 0, s.z/2-d+1, s.x/2+d, 0, s.z/2+d
|
||||||
# corners of wire square
|
# corners of wire square
|
||||||
world.addObjectAtPos(KikiWire(KikiFace.PY, 6), s.x/2-d, 0, s.z/2-d)
|
world.addObjectAtPos new Wire(Face.Y, 6), s.x/2-d, 0, s.z/2-d
|
||||||
world.addObjectAtPos(KikiWire(KikiFace.PY, 3), s.x/2-d, 0, s.z/2+d)
|
world.addObjectAtPos new Wire(Face.Y, 3), s.x/2-d, 0, s.z/2+d
|
||||||
world.addObjectAtPos(KikiWire(KikiFace.PY, 9), s.x/2+d, 0, s.z/2+d)
|
world.addObjectAtPos new Wire(Face.Y, 9), s.x/2+d, 0, s.z/2+d
|
||||||
world.addObjectAtPos(KikiWire(KikiFace.PY, 12), s.x/2+d, 0, s.z/2-d)
|
world.addObjectAtPos new Wire(Face.Y, 12), s.x/2+d, 0, s.z/2-d
|
||||||
|
|
||||||
world.addObjectAtPos(KikiWire(KikiFace.PX, 1), 0, 0, s.z/2)
|
world.addObjectAtPos new Wire(Face.X, 1), 0, 0, s.z/2
|
||||||
world.addObjectAtPos(KikiWire(KikiFace.NX, 1), s.x-1, 0, s.z/2)
|
world.addObjectAtPos new Wire(Face.NX, 1), s.x-1, 0, s.z/2
|
||||||
|
|
||||||
world.addObjectLine "KikiWire(KikiFace.PX, 5)", 0, 1, s.z/2, 0, s.y, s.z/2
|
world.addObjectLine 'new Wire(Face.X, 5)', 0, 1, s.z/2, 0, s.y, s.z/2
|
||||||
world.addObjectLine "KikiWire(KikiFace.NX, 5)", s.x-1, 1, s.z/2, s.x-1, s.y, s.z/2
|
world.addObjectLine 'new Wire(Face.NX, 5)', s.x-1, 1, s.z/2, s.x-1, s.y, s.z/2
|
||||||
world.addObjectLine "KikiWire(KikiFace.NY, 10)", 0, s.y-1, s.z/2, s.x, s.y-1, s.z/2
|
world.addObjectLine 'new Wire(Face.NY, 10)', 0, s.y-1, s.z/2, s.x, s.y-1, s.z/2
|
||||||
|
|
|
@ -20,19 +20,19 @@ module.exports =
|
||||||
s = world.size
|
s = world.size
|
||||||
|
|
||||||
for y in [-1, 1]
|
for y in [-1, 1]
|
||||||
for x in range(-s.x/2+3, s.x/2-1, 2)
|
for x in [-1,1,3]
|
||||||
for z in range(-s.z/2+3, s.z/2-1, 2)
|
for z in [-1,1,3]
|
||||||
world.addObjectAtPos('KikiWall', world.decenter(x, y, z))
|
world.addObjectAtPos 'Wall', world.decenter x, y, z
|
||||||
|
|
||||||
for y in [-4, 4]
|
for y in [-4, 4]
|
||||||
for x in range(-s.x/2+1, s.x/2+1, 2)
|
for x in [-3, -1, 1, 3]
|
||||||
for z in range(-s.z/2+1, s.z/2+1, 2)
|
for z in [-3, -1, 1, 3]
|
||||||
world.addObjectAtPos('KikiWall', world.decenter(x, y, z))
|
world.addObjectAtPos 'Wall', world.decenter x, y, z
|
||||||
|
|
||||||
world.addObjectAtPos('KikiStone', world.decenter(3,-3,0))
|
world.addObjectAtPos 'Stone', world.decenter 3,-3,0
|
||||||
world.addObjectAtPos('KikiStone', world.decenter(-3,-3,0))
|
world.addObjectAtPos 'Stone', world.decenter -3,-3,0
|
||||||
world.addObjectAtPos('KikiStone', world.decenter(3,3,0))
|
world.addObjectAtPos 'Stone', world.decenter 3,3,0
|
||||||
world.addObjectAtPos('KikiStone', world.decenter(-3,3,0))
|
world.addObjectAtPos 'Stone', world.decenter -3,3,0
|
||||||
world.addObjectAtPos('KikiStone', world.decenter(0,-3,0))
|
world.addObjectAtPos 'Stone', world.decenter 0,-3,0
|
||||||
world.addObjectAtPos('KikiStone', world.decenter(0,3,0))
|
world.addObjectAtPos 'Stone', world.decenter 0,3,0
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
|
||||||
|
# 00000000 000 000 000 0000000 0000000
|
||||||
|
# 000 000 000 0000 000 000 000
|
||||||
|
# 0000000 000 000 0 000 000 0000 0000000
|
||||||
|
# 000 000 000 000 0000 000 000 000
|
||||||
|
# 000 000 000 000 000 0000000 0000000
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
name: "rings"
|
name: "rings"
|
||||||
scheme: "default_scheme"
|
scheme: "default_scheme"
|
||||||
|
@ -21,9 +28,9 @@ module.exports =
|
||||||
|
|
||||||
for y in [-1, 1]
|
for y in [-1, 1]
|
||||||
x = 3
|
x = 3
|
||||||
world.addObjectPoly(KikiStone, [world.decenter(-x, y, -x), world.decenter(-x, y, x), world.decenter(x, y, x), world.decenter(x, y, -x)])
|
world.addObjectPoly 'Stone', [world.decenter(-x, y, -x), world.decenter(-x, y, x), world.decenter(x, y, x), world.decenter(x, y, -x)]
|
||||||
|
|
||||||
for y in [-3, 3]
|
for y in [-3, 3]
|
||||||
for x in [-3, -1, 1, 3]
|
for x in [-3, -1, 1, 3]
|
||||||
world.addObjectPoly(KikiStone, [world.decenter(-x, y, -x), world.decenter(-x, y, x), world.decenter(x, y, x), world.decenter(x, y, -x)])
|
world.addObjectPoly 'Stone', [world.decenter(-x, y, -x), world.decenter(-x, y, x), world.decenter(x, y, x), world.decenter(x, y, -x)]
|
||||||
|
|
|
@ -14,7 +14,7 @@ module.exports =
|
||||||
"""
|
"""
|
||||||
player:
|
player:
|
||||||
position: [0,-1,-1]
|
position: [0,-1,-1]
|
||||||
orientation: rotx90 * roty180
|
orientation: rotx90.mul roty180
|
||||||
exits: [
|
exits: [
|
||||||
name: "exit"
|
name: "exit"
|
||||||
active: 1
|
active: 1
|
||||||
|
|
|
@ -20,28 +20,26 @@ module.exports =
|
||||||
s = world.size
|
s = world.size
|
||||||
{Gear,Generator,MotorCylinder,MotorGear,Face,Wall,Wire,WireStone,Stone} = require '../items'
|
{Gear,Generator,MotorCylinder,MotorGear,Face,Wall,Wire,WireStone,Stone} = require '../items'
|
||||||
|
|
||||||
world.addObjectAtPos new Wire(Face.Z, Wire.ALL), 5, 7, 0
|
world.addObjectAtPos new Wire(Face.Z, Wire.HORIZONTAL), 5, 5, 0
|
||||||
world.addObjectAtPos new Wire(Face.Z, Wire.ALL), 5, 8, 0
|
# world.addObjectAtPos new Wire(Face.Z, Wire.ALL), 5, 6, 0
|
||||||
world.addObjectAtPos new Wire(Face.Z, Wire.ALL), 6, 7, 0
|
# world.addObjectAtPos new Wire(Face.Z, Wire.ALL), 5, 7, 0
|
||||||
world.addObjectAtPos new Wire(Face.Z, Wire.ALL), 5, 6, 0
|
# world.addObjectAtPos new Wire(Face.Z, Wire.ALL), 5, 8, 0
|
||||||
world.addObjectAtPos new Wire(Face.Z, Wire.ALL), 4, 7, 0
|
# world.addObjectAtPos new Wire(Face.Z, Wire.ALL), 4, 7, 0
|
||||||
world.addObjectAtPos new Wire(Face.Z, Wire.ALL), 5, 8, 0
|
# world.addObjectAtPos new Wire(Face.Z, Wire.ALL), 6, 7, 0
|
||||||
world.addObjectAtPos new Wire(Face.Z, Wire.ALL), 5, 5, 0
|
|
||||||
|
|
||||||
world.addObjectAtPos new Generator(Face.Z), 5, 6, 0
|
world.addObjectAtPos new Generator(Face.Z), 5, 6, 0
|
||||||
# world.addObjectAtPos new MotorGear(Face.NZ), 8, 7, 0
|
# world.addObjectAtPos new MotorGear(Face.NZ), 8, 7, 0
|
||||||
# world.addObjectAtPos new Stone(), 6, 7, 0
|
# world.addObjectAtPos new Stone(), 6, 7, 0
|
||||||
# world.addObjectAtPos new Stone(), 6, 7, 2
|
# world.addObjectAtPos new Stone(), 6, 7, 2
|
||||||
# world.addObjectAtPos new WireStone(), 6, 7, 1
|
world.addObjectAtPos new WireStone(), 6, 5, 0
|
||||||
# world.addObjectAtPos new WireStone(), 3, 7, 1
|
# world.addObjectAtPos new WireStone(), 3, 7, 0
|
||||||
|
|
||||||
world.addObjectAtPos new Gear(Face.Z), 6, 5, 0
|
# world.addObjectAtPos new Gear(Face.Z), 6, 5, 0
|
||||||
# world.addObjectAtPos new Gear(Face.Z), 5, 6, 0
|
# world.addObjectAtPos new Gear(Face.Z), 4, 4, 0
|
||||||
# world.addObjectAtPos new Gear(Face.Z), 5, 4, 0
|
# # world.addObjectAtPos new Gear(Face.Z), 5, 6, 0
|
||||||
# world.addObjectAtPos new Gear(Face.Z), 6, 6, 0
|
# # world.addObjectAtPos new Gear(Face.Z), 5, 4, 0
|
||||||
world.addObjectAtPos new Gear(Face.Z), 4, 4, 0
|
# # world.addObjectAtPos new Gear(Face.Z), 6, 6, 0
|
||||||
# world.addObjectAtPos new Gear(Face.Z), 4, 6, 0
|
# # world.addObjectAtPos new Gear(Face.Z), 4, 6, 0
|
||||||
world.addObjectAtPos new Gear(Face.Z), 6, 4, 0
|
|
||||||
world.addObjectAtPos new MotorCylinder(Face.Z), 4, 5, 1
|
world.addObjectAtPos new MotorCylinder(Face.Z), 4, 5, 1
|
||||||
world.addObjectAtPos new MotorGear(Face.Z), 4, 5, 0
|
world.addObjectAtPos new MotorGear(Face.Z), 4, 5, 0
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
# level design by Michael Abel
|
|
||||||
|
# 000 000 0000000 000 000 0000000
|
||||||
|
# 000 0 000 000 000 000 000 000
|
||||||
|
# 000000000 000000000 000 000 0000000
|
||||||
|
# 000 000 000 000 000 000 000
|
||||||
|
# 00 00 000 000 0000000 0000000 0000000
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
name: "walls"
|
name: "walls"
|
||||||
|
design: 'Michael Abel'
|
||||||
scheme: "default_scheme"
|
scheme: "default_scheme"
|
||||||
size: [7,5,5]
|
size: [7,5,5]
|
||||||
intro: "walls"
|
intro: "walls"
|
||||||
|
@ -16,7 +22,6 @@ module.exports =
|
||||||
"""
|
"""
|
||||||
player:
|
player:
|
||||||
coordinates: [0,0,2]
|
coordinates: [0,0,2]
|
||||||
nostatus: 0
|
|
||||||
exits: [
|
exits: [
|
||||||
name: "exit"
|
name: "exit"
|
||||||
active: 1
|
active: 1
|
||||||
|
@ -24,21 +29,22 @@ module.exports =
|
||||||
]
|
]
|
||||||
create: ->
|
create: ->
|
||||||
s=world.size
|
s=world.size
|
||||||
|
{Stone} = require '../items'
|
||||||
middlemax = (u,v,w) ->
|
middlemax = (u,v,w) ->
|
||||||
s=world.size
|
# s=world.size
|
||||||
d= 3.0/( (u-s.x/2.0)**2+ (v-s.y/2.0)**2 + (w-s.z/2.0)**2 + 1 )
|
d= 3.0/( (u-s.x/2.0)**2+ (v-s.y/2.0)**2 + (w-s.z/2.0)**2 + 1 )
|
||||||
return min(1.0 ,max(0.2,d))
|
Math.min 1.0 ,Math.max 0.2, d
|
||||||
|
|
||||||
middlemin = (u,v,w) ->
|
middlemin = (u,v,w) ->
|
||||||
s=world.size
|
# s=world.size
|
||||||
d= 2* ( (u-s.x/2.0)**2+ (v-s.y/2.0)**2 + (w-s.z/2.0)**2 )/25
|
d= 2* ( (u-s.x/2.0)**2+ (v-s.y/2.0)**2 + (w-s.z/2.0)**2 )/25
|
||||||
return min(1.0 ,max(0.4,d))
|
Math.min 1.0, Math.max 0.4,d
|
||||||
|
|
||||||
# for (i,j,l) in [ (m,n,o) for m in range(s.x) for n in range(s.y) for o in range(s.z)]
|
# for (i,j,l) in [ (m,n,o) for m in range(s.x) for n in range(s.y) for o in range(s.z)]
|
||||||
for i in [0...s.x]
|
for i in [0...s.x]
|
||||||
for j in [0...s.y]
|
for j in [0...s.y]
|
||||||
for l in [0...s.z]
|
for l in [0...s.z]
|
||||||
if i==s.x/2 or i==s.x/2-2 or i==s.x/2+2
|
if i==Math.floor(s.x/2) or i==Math.floor(s.x/2-2) or i==Math.floor(s.x/2+2)
|
||||||
world.addObjectAtPos(KikiStone(KColor(0.1*i,0.1*j,0.1*l,0.6) , false) , i,j,l)
|
log "#{i} #{j} #{l}"
|
||||||
|
world.addObjectAtPos new Stone(color:[0.5*i,0.5*j,0.5*l], opacity:0.6), i,j,l
|
||||||
|
|
|
@ -7,6 +7,30 @@
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
|
|
||||||
|
bot: new THREE.MeshPhongMaterial
|
||||||
|
color: 0x2222ff
|
||||||
|
side: THREE.FrontSide
|
||||||
|
shading: THREE.SmoothShading
|
||||||
|
transparent: true
|
||||||
|
opacity: 1
|
||||||
|
shininess: 5
|
||||||
|
|
||||||
|
tire: new THREE.MeshPhongMaterial
|
||||||
|
color: 0x000066
|
||||||
|
specular: 0x222255
|
||||||
|
side: THREE.FrontSide
|
||||||
|
shading: THREE.FlatShading
|
||||||
|
transparent: true
|
||||||
|
opacity: 1
|
||||||
|
shininess: 4
|
||||||
|
|
||||||
|
glow: new THREE.SpriteMaterial
|
||||||
|
map: new THREE.TextureLoader().load "#{__dirname}/../img/glow.png"
|
||||||
|
color: 0xffff00
|
||||||
|
# transparent: true
|
||||||
|
# opacity: 0.8
|
||||||
|
id: 999
|
||||||
|
|
||||||
gear: new THREE.MeshPhongMaterial
|
gear: new THREE.MeshPhongMaterial
|
||||||
color: 0xff0000
|
color: 0xff0000
|
||||||
side: THREE.FrontSide
|
side: THREE.FrontSide
|
||||||
|
@ -39,7 +63,7 @@ module.exports =
|
||||||
|
|
||||||
plate: new THREE.MeshPhongMaterial
|
plate: new THREE.MeshPhongMaterial
|
||||||
color: 0x880000
|
color: 0x880000
|
||||||
side: THREE.DoubleSide
|
side: THREE.FrontSide
|
||||||
shading: THREE.SmoothShading
|
shading: THREE.SmoothShading
|
||||||
shininess: 10
|
shininess: 10
|
||||||
emissive: 0x880000
|
emissive: 0x880000
|
||||||
|
|
|
@ -10,7 +10,12 @@ class Stone extends Pushable
|
||||||
|
|
||||||
constructor: (opt) ->
|
constructor: (opt) ->
|
||||||
@slippery = opt?.slippery or false
|
@slippery = opt?.slippery or false
|
||||||
@color = opt?.color or 0xff8800
|
@color = 0xff8800
|
||||||
|
if opt?.color
|
||||||
|
if Array.isArray opt.color
|
||||||
|
@color = new THREE.Color opt.color[0], opt.color[1], opt.color[2]
|
||||||
|
else
|
||||||
|
@color = opt.color
|
||||||
@geom = new THREE.BoxGeometry 0.98,0.98,0.98
|
@geom = new THREE.BoxGeometry 0.98,0.98,0.98
|
||||||
|
|
||||||
@mat = new THREE.MeshPhongMaterial
|
@mat = new THREE.MeshPhongMaterial
|
||||||
|
@ -18,7 +23,7 @@ class Stone extends Pushable
|
||||||
side: THREE.DoubleSide
|
side: THREE.DoubleSide
|
||||||
shading: THREE.SmoothShading
|
shading: THREE.SmoothShading
|
||||||
transparent: true
|
transparent: true
|
||||||
opacity: 0.7
|
opacity: opt?.opacity ? 0.7
|
||||||
shininess: 20
|
shininess: 20
|
||||||
|
|
||||||
@mesh = new THREE.Mesh @geom, @mat
|
@mesh = new THREE.Mesh @geom, @mat
|
||||||
|
|
|
@ -71,9 +71,8 @@ class Wire extends Item
|
||||||
setActive: (active) ->
|
setActive: (active) ->
|
||||||
if @active != active
|
if @active != active
|
||||||
@active = active
|
@active = active
|
||||||
log "wire active #{active}"
|
|
||||||
neighbors = @neighborWires()
|
neighbors = @neighborWires()
|
||||||
|
# log "wire active:#{active} face:#{@face} neighbors:#{neighbors.length} pos:", @getPos()
|
||||||
for wire in neighbors
|
for wire in neighbors
|
||||||
wire.setActive @active
|
wire.setActive @active
|
||||||
|
|
||||||
|
@ -92,41 +91,13 @@ class Wire extends Item
|
||||||
|
|
||||||
if @active
|
if @active
|
||||||
if not @glow?
|
if not @glow?
|
||||||
map = new THREE.TextureLoader().load "#{__dirname}/../img/wire.png"
|
@glow = new THREE.Sprite Material.glow
|
||||||
# map.offset.set -0.5, -0.5
|
|
||||||
# map.repeat.set 2, 2
|
|
||||||
material = new THREE.SpriteMaterial
|
|
||||||
map: map
|
|
||||||
color: 0xffff00
|
|
||||||
transparent: false
|
|
||||||
# opacity: 0.95
|
|
||||||
blending: THREE.AdditiveBlending
|
|
||||||
fog: true
|
|
||||||
id: 999
|
|
||||||
lights: true
|
|
||||||
# side: THREE.DoubleSide
|
|
||||||
# depthTest: false
|
|
||||||
# depthWrite: true
|
|
||||||
|
|
||||||
@glow = new THREE.Sprite material
|
|
||||||
# @glow.scale.set 0.1, 0.1, 0.1
|
|
||||||
log 'glow position', @position
|
|
||||||
@glow.position.set 0, 0, -0.3
|
@glow.position.set 0, 0, -0.3
|
||||||
@glow.scale.set .5, .5, 1
|
@glow.scale.set .5, .5, 1
|
||||||
@glow.renderOrder = 999
|
@glow.renderOrder = 999
|
||||||
# @glow.position.normalize()
|
|
||||||
# @glow.position.multiplyScalar 2
|
|
||||||
@mesh.add @glow
|
@mesh.add @glow
|
||||||
|
else if @glow?
|
||||||
# @glow2 = new THREE.Sprite material
|
|
||||||
# @glow2.scale.set 1, 1, 1
|
|
||||||
# @glow2.renderOrder = 999
|
|
||||||
# @glow2.position.set @position.x, @position.y, @position.z-0.3
|
|
||||||
# world.scene.add @glow2
|
|
||||||
else if @glow
|
|
||||||
@mesh.remove @glow
|
@mesh.remove @glow
|
||||||
log 'remove glow'
|
|
||||||
# @world.scene.remove @glow
|
|
||||||
@glow = null
|
@glow = null
|
||||||
|
|
||||||
@events[@active and @SWITCH_ON_EVENT or @SWITCH_OFF_EVENT].triggerActions()
|
@events[@active and @SWITCH_ON_EVENT or @SWITCH_OFF_EVENT].triggerActions()
|
||||||
|
@ -135,25 +106,26 @@ class Wire extends Item
|
||||||
neighborWires: ->
|
neighborWires: ->
|
||||||
wires = []
|
wires = []
|
||||||
points = @connectionPoints()
|
points = @connectionPoints()
|
||||||
|
# log 'points', points
|
||||||
neighbor_dirs = []
|
neighbor_dirs = []
|
||||||
|
|
||||||
rot = Face.orientationForFace @face
|
rot = Face.orientationForFace @face
|
||||||
n = Face.normalVectorForFace @face
|
n = Face.normalVectorForFace @face
|
||||||
|
|
||||||
neighbor_dirs.push new Vector
|
neighbor_dirs.push new Vector 0,0,0
|
||||||
|
|
||||||
if @connections & Wire.RIGHT
|
if @connections & Wire.RIGHT
|
||||||
neighbor_dirs.push rot.rotate new Vector(1,0,0)
|
neighbor_dirs.push rot.rotate new Vector(1,0,0)
|
||||||
neighbor_dirs.push rot.rotate new Vector(1,0,0).plus n
|
neighbor_dirs.push rot.rotate(new Vector(1,0,0)).minus n
|
||||||
if @connections & Wire.LEFT
|
if @connections & Wire.LEFT
|
||||||
neighbor_dirs.push rot.rotate new Vector(-1,0,0)
|
neighbor_dirs.push rot.rotate new Vector(-1,0,0)
|
||||||
neighbor_dirs.push rot.rotate new Vector(-1,0,0).plus n
|
neighbor_dirs.push rot.rotate(new Vector(-1,0,0)).minus n
|
||||||
if @connections & Wire.UP
|
if @connections & Wire.UP
|
||||||
neighbor_dirs.push rot.rotate new Vector(0,1,0)
|
neighbor_dirs.push rot.rotate new Vector(0,1,0)
|
||||||
neighbor_dirs.push rot.rotate new Vector(0,1,0).plus n
|
neighbor_dirs.push rot.rotate(new Vector(0,1,0)).minus n
|
||||||
if @connections & Wire.DOWN
|
if @connections & Wire.DOWN
|
||||||
neighbor_dirs.push rot.rotate new Vector(0,-1,0)
|
neighbor_dirs.push rot.rotate new Vector(0,-1,0)
|
||||||
neighbor_dirs.push rot.rotate new Vector(0,-1,0).plus n
|
neighbor_dirs.push rot.rotate(new Vector(0,-1,0)).minus n
|
||||||
|
|
||||||
for i in [0...neighbor_dirs.length]
|
for i in [0...neighbor_dirs.length]
|
||||||
neighbors = world.getObjectsOfTypeAtPos Wire, @position.plus neighbor_dirs[i]
|
neighbors = world.getObjectsOfTypeAtPos Wire, @position.plus neighbor_dirs[i]
|
||||||
|
@ -162,14 +134,14 @@ class Wire extends Item
|
||||||
neighbor_points = iter.connectionPoints()
|
neighbor_points = iter.connectionPoints()
|
||||||
for point in points
|
for point in points
|
||||||
for neighbor_point in neighbor_points
|
for neighbor_point in neighbor_points
|
||||||
if (neighbor_point.minus point).length() < 0.1
|
if neighbor_point.minus(point).length() < 0.1
|
||||||
wires.push iter
|
wires.push iter
|
||||||
wires
|
wires
|
||||||
|
|
||||||
connectionPoints: ->
|
connectionPoints: ->
|
||||||
points = []
|
points = []
|
||||||
to_border = Face.normalVectorForFace(@face).mul 0.5
|
to_border = Face.normal(@face).mul -0.5
|
||||||
rot = Face.orientationForFace @face
|
rot = Face.orientation @face
|
||||||
if @connections & Wire.RIGHT
|
if @connections & Wire.RIGHT
|
||||||
points.push @position.plus to_border.plus rot.rotate new Vector 0.5, 0, 0
|
points.push @position.plus to_border.plus rot.rotate new Vector 0.5, 0, 0
|
||||||
if @connections & Wire.LEFT
|
if @connections & Wire.LEFT
|
||||||
|
@ -180,6 +152,4 @@ class Wire extends Item
|
||||||
points.push @position.plus to_border.plus rot.rotate new Vector 0, -0.5, 0
|
points.push @position.plus to_border.plus rot.rotate new Vector 0, -0.5, 0
|
||||||
points
|
points
|
||||||
|
|
||||||
# KikiBillBoard::displayTextureWithSize 0.15
|
|
||||||
|
|
||||||
module.exports = Wire
|
module.exports = Wire
|
||||||
|
|
|
@ -24,9 +24,8 @@ class WireStone extends Stone
|
||||||
if @wires[i]?
|
if @wires[i]?
|
||||||
world.unsetObject @wires[i]
|
world.unsetObject @wires[i]
|
||||||
@wires[i].setActive false
|
@wires[i].setActive false
|
||||||
for generator in world.getObjectsOfType Generator
|
for generator in world.getObjectsOfType Generator # ???
|
||||||
if generator.active
|
generator.activateWires() if generator.active # ???
|
||||||
generator.activateWires()
|
|
||||||
super action
|
super action
|
||||||
|
|
||||||
setPosition: (pos) ->
|
setPosition: (pos) ->
|
||||||
|
|
|
@ -26,11 +26,13 @@ Item = require './item'
|
||||||
Action = require './action'
|
Action = require './action'
|
||||||
TmpObject = require './tmpobject'
|
TmpObject = require './tmpobject'
|
||||||
Pushable = require './pushable'
|
Pushable = require './pushable'
|
||||||
|
Material = require './material'
|
||||||
Quaternion = require './lib/quaternion'
|
Quaternion = require './lib/quaternion'
|
||||||
Vector = require './lib/vector'
|
Vector = require './lib/vector'
|
||||||
Pos = require './lib/pos'
|
Pos = require './lib/pos'
|
||||||
_ = require 'lodash'
|
_ = require 'lodash'
|
||||||
now = require 'performance-now'
|
now = require 'performance-now'
|
||||||
|
{Wire,Gear,MotorGear,MotorCylinder,Face} = require './items'
|
||||||
|
|
||||||
world = null
|
world = null
|
||||||
|
|
||||||
|
@ -455,6 +457,8 @@ class World extends Actor
|
||||||
if _.isString object
|
if _.isString object
|
||||||
if object.startsWith 'Kiki'
|
if object.startsWith 'Kiki'
|
||||||
return new (require "./#{object.slice(4).toLowerCase()}")()
|
return new (require "./#{object.slice(4).toLowerCase()}")()
|
||||||
|
else if object.startsWith 'new'
|
||||||
|
return eval object
|
||||||
return new (require "./#{object.toLowerCase()}")()
|
return new (require "./#{object.toLowerCase()}")()
|
||||||
if object instanceof Item
|
if object instanceof Item
|
||||||
return object
|
return object
|
||||||
|
@ -654,6 +658,7 @@ class World extends Actor
|
||||||
|
|
||||||
Sound.setMatrix @projection
|
Sound.setMatrix @projection
|
||||||
|
|
||||||
|
# Material.tire.visible = @camera_mode != World.CAMERA_INSIDE
|
||||||
@player.setOpacity clamp 0, 1, @projection.getPosition().minus(@player.current_position).length()-0.4
|
@player.setOpacity clamp 0, 1, @projection.getPosition().minus(@player.current_position).length()-0.4
|
||||||
@projection.apply @camera
|
@projection.apply @camera
|
||||||
@sun.position.copy @camera.position
|
@sun.position.copy @camera.position
|
||||||
|
|
BIN
img/glow.png
BIN
img/glow.png
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 5.1 KiB |
BIN
img/wire.png
BIN
img/wire.png
Binary file not shown.
Before Width: | Height: | Size: 88 KiB |
BIN
img/wire2.png
BIN
img/wire2.png
Binary file not shown.
Before Width: | Height: | Size: 21 KiB |
Loading…
Reference in New Issue
Block a user