gears
This commit is contained in:
parent
d3bf896de1
commit
d1d837f327
|
@ -4,7 +4,7 @@
|
|||
# 000 000 000 000 000 000 000
|
||||
# 0000000 00000000 000 000 000 000
|
||||
|
||||
log = require '/Users/kodi/s/ko/js/tools/log'
|
||||
log = require '/Users/kodi/s/ko/js/tools/log'
|
||||
Valve = require './valve'
|
||||
Action = require './action'
|
||||
Pos = require './lib/pos'
|
||||
|
@ -12,9 +12,10 @@ Cage = require './cage'
|
|||
Geom = require './geom'
|
||||
|
||||
class Gear extends Valve
|
||||
|
||||
@neighbors = [ [[0,1,0], [0,-1,0], [0,0,1], [0,0,-1]], [[1,0,0], [-1,0,0], [0,0,1], [0,0,-1]], [[1,0,0], [-1,0,0], [0,1,0], [0,-1,0]] ]
|
||||
|
||||
constructor: (@face) ->
|
||||
|
||||
super @face
|
||||
@updateMesh()
|
||||
|
||||
|
@ -23,16 +24,8 @@ class Gear extends Valve
|
|||
@mesh.add new THREE.Mesh Geom.valve(), Cage.rasterMat
|
||||
@mesh.receiveShadow = true
|
||||
|
||||
getNeighborDirections: (face) ->
|
||||
neighbors = [
|
||||
[[0,1,0], [0,-1,0], [0,0,1], [0,0,-1]]
|
||||
[[1,0,0], [-1,0,0], [0,0,1], [0,0,-1]]
|
||||
[[1,0,0], [-1,0,0], [0,1,0], [0,-1,0]]
|
||||
]
|
||||
neighbors[face % 3]
|
||||
|
||||
getNeighborGears: ->
|
||||
dirs = @getNeighborDirections @face
|
||||
dirs = Gear.neighbors[@face % 3]
|
||||
pos = @getPos()
|
||||
gears = []
|
||||
for i in [0...4]
|
||||
|
@ -74,16 +67,4 @@ class Gear extends Valve
|
|||
else
|
||||
gear.updateActive()
|
||||
|
||||
render: ->
|
||||
# if (@active)
|
||||
# glRotatef (clockwise ? angle : -angle, 0.0, 0.0, 1.0);
|
||||
#
|
||||
# KikiValve::colors[0].glColor();
|
||||
# render_valve;
|
||||
#
|
||||
# glTranslatef (0.0, 0.0, 0.4);
|
||||
#
|
||||
# colors[0].glColor();
|
||||
# render_gear;
|
||||
|
||||
module.exports = Gear
|
||||
|
|
|
@ -16,7 +16,7 @@ class Generator extends Gear
|
|||
|
||||
createMesh: ->
|
||||
@mesh = new THREE.Mesh Geom.generator(), Cage.cageMat
|
||||
# @mesh.add new THREE.Mesh Geom.gear(), Cage.rasterMat
|
||||
@mesh.add new THREE.Mesh Geom.gear(), Cage.rasterMat
|
||||
@mesh.receiveShadow = true
|
||||
|
||||
activateWires: ->
|
||||
|
@ -30,19 +30,5 @@ class Generator extends Gear
|
|||
super active
|
||||
@activateWires()
|
||||
world.playSound @active and 'GENERATOR_ON' or 'GENERATOR_OFF'
|
||||
|
||||
render: ->
|
||||
# if (active)
|
||||
# glRotatef (clockwise ? angle : -angle, 0.0, 0.0, 1.0);
|
||||
#
|
||||
# colors[0].glColor();
|
||||
#
|
||||
# render_generator;
|
||||
#
|
||||
# KikiGear::colors[0].glColor();
|
||||
#
|
||||
# glTranslatef (0.0, 0.0, 0.4);
|
||||
#
|
||||
# render_gear;
|
||||
|
||||
|
||||
module.exports = Generator
|
||||
|
|
|
@ -444,8 +444,8 @@ class Geom
|
|||
@valveQuadStrip2 = [
|
||||
0.042, 0.042, -0.220,
|
||||
0.042, 0.042, 0.220,
|
||||
-0.220,
|
||||
0.220,
|
||||
0.059, 0, -0.220,
|
||||
0.059, 0, 0.220,
|
||||
0.042, -0.042, -0.220,
|
||||
0.042, -0.042, 0.220,
|
||||
0, -0.059, -0.220,
|
||||
|
|
|
@ -19,15 +19,13 @@ module.exports =
|
|||
|
||||
s = world.size
|
||||
{Gear,Generator,MotorCylinder,MotorGear,Face} = require '../items'
|
||||
world.addObjectAtPos new Generator(Face.NX), 4, 5, 0
|
||||
world.addObjectAtPos new Generator(Face.X), 6, 5, 0
|
||||
# world.addObjectAtPos new Gear(Face.NZ), 6, 5, 0
|
||||
# world.addObjectAtPos new Gear(Face.Z), 4, 5, 0
|
||||
return
|
||||
world.addObjectAtPos new Generator(Face.Z), 5, 5, 0
|
||||
|
||||
world.addObjectAtPos new Gear(Face.Z), 4, 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), 5, 4, 0
|
||||
|
||||
|
||||
world.addObjectAtPos new Gear(Face.Z), 6, 6, 0
|
||||
world.addObjectAtPos new Gear(Face.Z), 4, 4, 0
|
||||
world.addObjectAtPos new Gear(Face.Z), 4, 6, 0
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
# 000 000 000 000 000 000
|
||||
# 0 000 000 0000000 0 00000000
|
||||
|
||||
log = require '/Users/kodi/s/ko/js/tools/log'
|
||||
log = require '/Users/kodi/s/ko/js/tools/log'
|
||||
Quaternion = require './lib/quaternion'
|
||||
Pushable = require './pushable'
|
||||
Action = require './action'
|
||||
Face = require './face'
|
||||
Pushable = require './pushable'
|
||||
Action = require './action'
|
||||
Face = require './face'
|
||||
|
||||
class Valve extends Pushable
|
||||
|
||||
|
@ -18,7 +18,7 @@ class Valve extends Pushable
|
|||
@active = false
|
||||
@clockwise = false
|
||||
@addAction new Action @, Action.ROTATE, "rotation", 2000, Action.REPEAT
|
||||
@startTimedAction @getActionWithId Action.ROTATE
|
||||
# @startTimedAction @getActionWithId Action.ROTATE
|
||||
|
||||
updateMesh: ->
|
||||
# log "Valve.updateMesh #{@angle} #{@face}"
|
||||
|
@ -31,7 +31,7 @@ class Valve extends Pushable
|
|||
dir = @face % 3
|
||||
sum = ((dir == Face.Y or dir == Face.Z) and p.x or 0) + ((dir == Face.X or dir == Face.Z) and p.y or 0) + ((dir == Face.X or dir == Face.Y) and p.z or 0)
|
||||
@clockwise = sum % 2
|
||||
log "Valve.setPosition sum #{sum} @clockwise #{@clockwise}", pos
|
||||
# log "Valve.setPosition sum #{sum} @clockwise #{@clockwise}", pos
|
||||
|
||||
performAction: (action) ->
|
||||
switch action.id
|
||||
|
|
|
@ -61,7 +61,7 @@ class World extends Actor
|
|||
|
||||
super
|
||||
|
||||
@noRotations = true
|
||||
@noRotations = false
|
||||
|
||||
@screenSize = new Size @view.clientWidth, @view.clientHeight
|
||||
# log "view @screenSize:", @screenSize
|
||||
|
|
Loading…
Reference in New Issue
Block a user