motir
This commit is contained in:
parent
d1d837f327
commit
8605b93909
|
@ -8,8 +8,8 @@ log = require '/Users/kodi/s/ko/js/tools/log'
|
||||||
Valve = require './valve'
|
Valve = require './valve'
|
||||||
Action = require './action'
|
Action = require './action'
|
||||||
Pos = require './lib/pos'
|
Pos = require './lib/pos'
|
||||||
Cage = require './cage'
|
|
||||||
Geom = require './geom'
|
Geom = require './geom'
|
||||||
|
Material = require './material'
|
||||||
|
|
||||||
class Gear extends Valve
|
class Gear extends Valve
|
||||||
|
|
||||||
|
@ -20,8 +20,8 @@ class Gear extends Valve
|
||||||
@updateMesh()
|
@updateMesh()
|
||||||
|
|
||||||
createMesh: ->
|
createMesh: ->
|
||||||
@mesh = new THREE.Mesh Geom.gear(), Cage.cageMat
|
@mesh = new THREE.Mesh Geom.gear(), Material.gear
|
||||||
@mesh.add new THREE.Mesh Geom.valve(), Cage.rasterMat
|
@mesh.add new THREE.Mesh Geom.valve(), Material.plate
|
||||||
@mesh.receiveShadow = true
|
@mesh.receiveShadow = true
|
||||||
|
|
||||||
getNeighborGears: ->
|
getNeighborGears: ->
|
||||||
|
|
|
@ -10,6 +10,59 @@ Vector = require './lib/vector'
|
||||||
|
|
||||||
class Geom
|
class Geom
|
||||||
|
|
||||||
|
@kolben: ->
|
||||||
|
quads = 6+8
|
||||||
|
triangles = quads*2
|
||||||
|
positions = new Float32Array triangles*9
|
||||||
|
normals = new Float32Array triangles*9
|
||||||
|
pi = -1
|
||||||
|
pi = @quadList positions, normals, pi, @kolbenQuads
|
||||||
|
pi = @quadStrip positions, normals, pi, @kolbenQuadStrip
|
||||||
|
geom = new THREE.BufferGeometry
|
||||||
|
geom.addAttribute 'position', new THREE.BufferAttribute positions, 3
|
||||||
|
geom.addAttribute 'normal', new THREE.BufferAttribute normals, 3
|
||||||
|
geom
|
||||||
|
|
||||||
|
@cylinder: ->
|
||||||
|
quads = 16*8
|
||||||
|
triangles = quads*2
|
||||||
|
positions = new Float32Array triangles*9
|
||||||
|
normals = new Float32Array triangles*9
|
||||||
|
pi = -1
|
||||||
|
pi = @quadStrip positions, normals, pi, @cylinderQuadStrip1
|
||||||
|
pi = @quadStrip positions, normals, pi, @cylinderQuadStrip2
|
||||||
|
pi = @quadStrip positions, normals, pi, @cylinderQuadStrip3
|
||||||
|
pi = @quadStrip positions, normals, pi, @cylinderQuadStrip4
|
||||||
|
pi = @quadStrip positions, normals, pi, @cylinderQuadStrip5
|
||||||
|
pi = @quadStrip positions, normals, pi, @cylinderQuadStrip6
|
||||||
|
pi = @quadStrip positions, normals, pi, @cylinderQuadStrip7
|
||||||
|
pi = @quadStrip positions, normals, pi, @cylinderQuadStrip8
|
||||||
|
pi = @quadStrip positions, normals, pi, @cylinderQuadStrip9
|
||||||
|
pi = @quadStrip positions, normals, pi, @cylinderQuadStrip10
|
||||||
|
pi = @quadStrip positions, normals, pi, @cylinderQuadStrip11
|
||||||
|
pi = @quadStrip positions, normals, pi, @cylinderQuadStrip12
|
||||||
|
pi = @quadStrip positions, normals, pi, @cylinderQuadStrip13
|
||||||
|
pi = @quadStrip positions, normals, pi, @cylinderQuadStrip14
|
||||||
|
pi = @quadStrip positions, normals, pi, @cylinderQuadStrip15
|
||||||
|
pi = @quadStrip positions, normals, pi, @cylinderQuadStrip16
|
||||||
|
geom = new THREE.BufferGeometry
|
||||||
|
geom.addAttribute 'position', new THREE.BufferAttribute positions, 3
|
||||||
|
geom.addAttribute 'normal', new THREE.BufferAttribute normals, 3
|
||||||
|
geom
|
||||||
|
|
||||||
|
@motor: ->
|
||||||
|
quads = 11
|
||||||
|
triangles = quads*2+4
|
||||||
|
positions = new Float32Array triangles*9
|
||||||
|
normals = new Float32Array triangles*9
|
||||||
|
pi = -1
|
||||||
|
pi = @quadList positions, normals, pi, @motorQuads
|
||||||
|
pi = @triangleList positions, normals, pi, @motorTriangles
|
||||||
|
geom = new THREE.BufferGeometry
|
||||||
|
geom.addAttribute 'position', new THREE.BufferAttribute positions, 3
|
||||||
|
geom.addAttribute 'normal', new THREE.BufferAttribute normals, 3
|
||||||
|
geom
|
||||||
|
|
||||||
@generator: ->
|
@generator: ->
|
||||||
quads = 22+4*8+8*4
|
quads = 22+4*8+8*4
|
||||||
triangles = quads*2
|
triangles = quads*2
|
||||||
|
@ -71,9 +124,24 @@ class Geom
|
||||||
geom.translate 0,0,0.4
|
geom.translate 0,0,0.4
|
||||||
geom
|
geom
|
||||||
|
|
||||||
|
@triangleList: (positions, normals, pi, triangles) ->
|
||||||
|
numTrias = triangles.length/9
|
||||||
|
for t in [0...numTrias]
|
||||||
|
ti = t * 9
|
||||||
|
p0 = new Vector triangles[ti+0], triangles[ti+1], triangles[ti+2]
|
||||||
|
p1 = new Vector triangles[ti+3], triangles[ti+4], triangles[ti+5]
|
||||||
|
p2 = new Vector triangles[ti+6], triangles[ti+7], triangles[ti+8]
|
||||||
|
nv = p1.minus(p0).cross(p2.minus(p0)).normal()
|
||||||
|
n = [nv.x, nv.y, nv.z]
|
||||||
|
for j in [0,1,2]
|
||||||
|
jj = j * 3
|
||||||
|
for i in [0...3]
|
||||||
|
positions[pi+=1] = triangles[ti+jj+i]
|
||||||
|
normals[pi] = n[i]
|
||||||
|
pi
|
||||||
|
|
||||||
@quadList: (positions, normals, pi, quads) ->
|
@quadList: (positions, normals, pi, quads) ->
|
||||||
numQuads = quads.length/12
|
numQuads = quads.length/12
|
||||||
# log "quads #{numQuads}"
|
|
||||||
for q in [0...numQuads]
|
for q in [0...numQuads]
|
||||||
qi = q * 12
|
qi = q * 12
|
||||||
p0 = new Vector quads[qi+0], quads[qi+1], quads[qi+2]
|
p0 = new Vector quads[qi+0], quads[qi+1], quads[qi+2]
|
||||||
|
@ -90,7 +158,6 @@ class Geom
|
||||||
|
|
||||||
@quadStrip: (positions, normals, pi, strip) ->
|
@quadStrip: (positions, normals, pi, strip) ->
|
||||||
numQuads = strip.length/6-1
|
numQuads = strip.length/6-1
|
||||||
# log "strip #{numQuads}"
|
|
||||||
for q in [0...numQuads]
|
for q in [0...numQuads]
|
||||||
qi = q * 6
|
qi = q * 6
|
||||||
p0 = new Vector strip[qi+0], strip[qi+1], strip[qi+2]
|
p0 = new Vector strip[qi+0], strip[qi+1], strip[qi+2]
|
||||||
|
@ -105,6 +172,457 @@ class Geom
|
||||||
normals[pi] = n[i]
|
normals[pi] = n[i]
|
||||||
pi
|
pi
|
||||||
|
|
||||||
|
# 000 000 0000000 000 0000000 00000000 000 000
|
||||||
|
# 000 000 000 000 000 000 000 000 0000 000
|
||||||
|
# 0000000 000 000 000 0000000 0000000 000 0 000
|
||||||
|
# 000 000 000 000 000 000 000 000 000 0000
|
||||||
|
# 000 000 0000000 0000000 0000000 00000000 000 000
|
||||||
|
|
||||||
|
@kolbenQuads = [
|
||||||
|
-0.1, -0.25, 0.5,
|
||||||
|
-0.1, 0.25, 0.5,
|
||||||
|
-0.25, 0.1, 0.5,
|
||||||
|
-0.25, -0.1, 0.5,
|
||||||
|
0.25, -0.1, 0.5,
|
||||||
|
0.25, 0.1, 0.5,
|
||||||
|
0.1, 0.25, 0.5,
|
||||||
|
0.1, -0.25, 0.5,
|
||||||
|
-0.1, 0.25, 0.5,
|
||||||
|
-0.1, -0.25, 0.5,
|
||||||
|
0.1, -0.25, 0.5,
|
||||||
|
0.1, 0.25, 0.5,
|
||||||
|
-0.1, 0.25, 0,
|
||||||
|
-0.1, -0.25, 0,
|
||||||
|
-0.25, -0.1, 0,
|
||||||
|
-0.25, 0.1, 0,
|
||||||
|
0.25, 0.1, 0,
|
||||||
|
0.25, -0.1, 0,
|
||||||
|
0.1, -0.25, 0,
|
||||||
|
0.1, 0.25, 0,
|
||||||
|
-0.1, -0.25, 0,
|
||||||
|
-0.1, 0.25, 0,
|
||||||
|
0.1, 0.25, 0,
|
||||||
|
0.1, -0.25, 0,
|
||||||
|
]
|
||||||
|
|
||||||
|
@kolbenQuadStrip = [
|
||||||
|
0.1, 0.25, 0,
|
||||||
|
0.1, 0.25, 0.5,
|
||||||
|
0.25, 0.1, 0,
|
||||||
|
0.25, 0.1, 0.5,
|
||||||
|
0.25, -0.1, 0,
|
||||||
|
0.25, -0.1, 0.5,
|
||||||
|
0.1, -0.25, 0,
|
||||||
|
0.1, -0.25, 0.5,
|
||||||
|
-0.1, -0.25, 0,
|
||||||
|
-0.1, -0.25, 0.5,
|
||||||
|
-0.25, -0.1, 0,
|
||||||
|
-0.25, -0.1, 0.5,
|
||||||
|
-0.25, 0.1, 0,
|
||||||
|
-0.25, 0.1, 0.5,
|
||||||
|
-0.1, 0.25, 0,
|
||||||
|
-0.1, 0.25, 0.5,
|
||||||
|
0.1, 0.25, 0,
|
||||||
|
0.1, 0.25, 0.5,
|
||||||
|
]
|
||||||
|
|
||||||
|
# 0000000 000 000 000 000 000 000 0000000 00000000 00000000
|
||||||
|
# 000 000 000 000 000 0000 000 000 000 000 000 000
|
||||||
|
# 000 00000 000 000 000 0 000 000 000 0000000 0000000
|
||||||
|
# 000 000 000 000 000 0000 000 000 000 000 000
|
||||||
|
# 0000000 000 0000000 000 000 000 0000000 00000000 000 000
|
||||||
|
|
||||||
|
@cylinderQuadStrip1 = [
|
||||||
|
-0.118, 0.284, 0.215,
|
||||||
|
-0.207, 0.499, 0.215,
|
||||||
|
0.118, 0.284, 0.215,
|
||||||
|
0.207, 0.499, 0.215,
|
||||||
|
0.285, 0.117, 0.215,
|
||||||
|
0.500, 0.206, 0.215,
|
||||||
|
0.285, -0.119, 0.215,
|
||||||
|
0.500, -0.208, 0.215,
|
||||||
|
0.118, -0.285, 0.215,
|
||||||
|
0.207, -0.501, 0.215,
|
||||||
|
-0.118, -0.285, 0.215,
|
||||||
|
-0.207, -0.501, 0.215,
|
||||||
|
-0.285, -0.119, 0.215,
|
||||||
|
-0.500, -0.208, 0.215,
|
||||||
|
-0.285, 0.117, 0.215,
|
||||||
|
-0.500, 0.206, 0.215,
|
||||||
|
-0.118, 0.284, 0.215,
|
||||||
|
-0.207, 0.499, 0.215,
|
||||||
|
]
|
||||||
|
@cylinderQuadStrip2 = [
|
||||||
|
0.118, 0.284, 0.315,
|
||||||
|
0.118, 0.284, 0.215,
|
||||||
|
0.285, 0.117, 0.315,
|
||||||
|
0.285, 0.117, 0.215,
|
||||||
|
0.285, -0.119, 0.315,
|
||||||
|
0.285, -0.119, 0.215,
|
||||||
|
0.118, -0.285, 0.315,
|
||||||
|
0.118, -0.285, 0.215,
|
||||||
|
-0.118, -0.285, 0.315,
|
||||||
|
-0.118, -0.285, 0.215,
|
||||||
|
-0.285, -0.119, 0.315,
|
||||||
|
-0.285, -0.119, 0.215,
|
||||||
|
-0.285, 0.117, 0.315,
|
||||||
|
-0.285, 0.117, 0.215,
|
||||||
|
-0.118, 0.284, 0.315,
|
||||||
|
-0.118, 0.284, 0.215,
|
||||||
|
0.118, 0.284, 0.315,
|
||||||
|
0.118, 0.284, 0.215,
|
||||||
|
]
|
||||||
|
@cylinderQuadStrip3 = [
|
||||||
|
0.207, 0.499, 0.315,
|
||||||
|
0.118, 0.284, 0.315,
|
||||||
|
0.500, 0.206, 0.315,
|
||||||
|
0.285, 0.117, 0.315,
|
||||||
|
0.500, -0.208, 0.315,
|
||||||
|
0.285, -0.119, 0.315,
|
||||||
|
0.207, -0.501, 0.315,
|
||||||
|
0.118, -0.285, 0.315,
|
||||||
|
-0.207, -0.501, 0.315,
|
||||||
|
-0.118, -0.285, 0.315,
|
||||||
|
-0.500, -0.208, 0.315,
|
||||||
|
-0.285, -0.119, 0.315,
|
||||||
|
-0.500, 0.206, 0.315,
|
||||||
|
-0.285, 0.117, 0.315,
|
||||||
|
-0.207, 0.499, 0.315,
|
||||||
|
-0.118, 0.284, 0.315,
|
||||||
|
0.207, 0.499, 0.315,
|
||||||
|
0.118, 0.284, 0.315,
|
||||||
|
]
|
||||||
|
@cylinderQuadStrip4 = [
|
||||||
|
-0.207, 0.499, 0.215,
|
||||||
|
-0.207, 0.499, 0.315,
|
||||||
|
0.207, 0.499, 0.215,
|
||||||
|
0.207, 0.499, 0.315,
|
||||||
|
0.500, 0.206, 0.215,
|
||||||
|
0.500, 0.206, 0.315,
|
||||||
|
0.500, -0.208, 0.215,
|
||||||
|
0.500, -0.208, 0.315,
|
||||||
|
0.207, -0.501, 0.215,
|
||||||
|
0.207, -0.501, 0.315,
|
||||||
|
-0.207, -0.501, 0.215,
|
||||||
|
-0.207, -0.501, 0.315,
|
||||||
|
-0.500, -0.208, 0.215,
|
||||||
|
-0.500, -0.208, 0.315,
|
||||||
|
-0.500, 0.206, 0.215,
|
||||||
|
-0.500, 0.206, 0.315,
|
||||||
|
-0.207, 0.499, 0.215,
|
||||||
|
-0.207, 0.499, 0.315,
|
||||||
|
]
|
||||||
|
@cylinderQuadStrip5 = [
|
||||||
|
-0.118, 0.284, 0.397,
|
||||||
|
-0.207, 0.499, 0.397,
|
||||||
|
0.118, 0.284, 0.397,
|
||||||
|
0.207, 0.499, 0.397,
|
||||||
|
0.285, 0.117, 0.397,
|
||||||
|
0.500, 0.206, 0.397,
|
||||||
|
0.285, -0.119, 0.397,
|
||||||
|
0.500, -0.208, 0.397,
|
||||||
|
0.118, -0.285, 0.397,
|
||||||
|
0.207, -0.501, 0.397,
|
||||||
|
-0.118, -0.285, 0.397,
|
||||||
|
-0.207, -0.501, 0.397,
|
||||||
|
-0.285, -0.119, 0.397,
|
||||||
|
-0.500, -0.208, 0.397,
|
||||||
|
-0.285, 0.117, 0.397,
|
||||||
|
-0.500, 0.206, 0.397,
|
||||||
|
-0.118, 0.284, 0.397,
|
||||||
|
-0.207, 0.499, 0.397,
|
||||||
|
]
|
||||||
|
@cylinderQuadStrip6 = [
|
||||||
|
0.118, 0.284, 0.497,
|
||||||
|
0.118, 0.284, 0.397,
|
||||||
|
0.285, 0.117, 0.497,
|
||||||
|
0.285, 0.117, 0.397,
|
||||||
|
0.285, -0.119, 0.497,
|
||||||
|
0.285, -0.119, 0.397,
|
||||||
|
0.118, -0.285, 0.497,
|
||||||
|
0.118, -0.285, 0.397,
|
||||||
|
-0.118, -0.285, 0.497,
|
||||||
|
-0.118, -0.285, 0.397,
|
||||||
|
-0.285, -0.119, 0.497,
|
||||||
|
-0.285, -0.119, 0.397,
|
||||||
|
-0.285, 0.117, 0.497,
|
||||||
|
-0.285, 0.117, 0.397,
|
||||||
|
-0.118, 0.284, 0.497,
|
||||||
|
-0.118, 0.284, 0.397,
|
||||||
|
0.118, 0.284, 0.497,
|
||||||
|
0.118, 0.284, 0.397,
|
||||||
|
]
|
||||||
|
@cylinderQuadStrip7 = [
|
||||||
|
0.207, 0.499, 0.497,
|
||||||
|
0.118, 0.284, 0.497,
|
||||||
|
0.500, 0.206, 0.497,
|
||||||
|
0.285, 0.117, 0.497,
|
||||||
|
0.500, -0.208, 0.497,
|
||||||
|
0.285, -0.119, 0.497,
|
||||||
|
0.207, -0.501, 0.497,
|
||||||
|
0.118, -0.285, 0.497,
|
||||||
|
-0.207, -0.501, 0.497,
|
||||||
|
-0.118, -0.285, 0.497,
|
||||||
|
-0.500, -0.208, 0.497,
|
||||||
|
-0.285, -0.119, 0.497,
|
||||||
|
-0.500, 0.206, 0.497,
|
||||||
|
-0.285, 0.117, 0.497,
|
||||||
|
-0.207, 0.499, 0.497,
|
||||||
|
-0.118, 0.284, 0.497,
|
||||||
|
0.207, 0.499, 0.497,
|
||||||
|
0.118, 0.284, 0.497,
|
||||||
|
]
|
||||||
|
@cylinderQuadStrip8 = [
|
||||||
|
-0.207, 0.499, 0.397,
|
||||||
|
-0.207, 0.499, 0.497,
|
||||||
|
0.207, 0.499, 0.397,
|
||||||
|
0.207, 0.499, 0.497,
|
||||||
|
0.500, 0.206, 0.397,
|
||||||
|
0.500, 0.206, 0.497,
|
||||||
|
0.500, -0.208, 0.397,
|
||||||
|
0.500, -0.208, 0.497,
|
||||||
|
0.207, -0.501, 0.397,
|
||||||
|
0.207, -0.501, 0.497,
|
||||||
|
-0.207, -0.501, 0.397,
|
||||||
|
-0.207, -0.501, 0.497,
|
||||||
|
-0.500, -0.208, 0.397,
|
||||||
|
-0.500, -0.208, 0.497,
|
||||||
|
-0.500, 0.206, 0.397,
|
||||||
|
-0.500, 0.206, 0.497,
|
||||||
|
-0.207, 0.499, 0.397,
|
||||||
|
-0.207, 0.499, 0.497,
|
||||||
|
]
|
||||||
|
@cylinderQuadStrip9 = [
|
||||||
|
-0.208, 0.498, 0.050,
|
||||||
|
-0.208, 0.498, 0.133,
|
||||||
|
0.206, 0.499, 0.050,
|
||||||
|
0.206, 0.499, 0.133,
|
||||||
|
0.499, 0.207, 0.050,
|
||||||
|
0.499, 0.207, 0.133,
|
||||||
|
0.500, -0.207, 0.050,
|
||||||
|
0.500, -0.207, 0.133,
|
||||||
|
0.208, -0.500, 0.050,
|
||||||
|
0.208, -0.500, 0.133,
|
||||||
|
-0.206, -0.501, 0.050,
|
||||||
|
-0.206, -0.501, 0.133,
|
||||||
|
-0.499, -0.209, 0.050,
|
||||||
|
-0.499, -0.209, 0.133,
|
||||||
|
-0.500, 0.205, 0.050,
|
||||||
|
-0.500, 0.205, 0.133,
|
||||||
|
-0.208, 0.498, 0.050,
|
||||||
|
-0.208, 0.498, 0.133,
|
||||||
|
]
|
||||||
|
@cylinderQuadStrip10 = [
|
||||||
|
0.148, 0.360, -0.116,
|
||||||
|
0.206, 0.499, 0.050,
|
||||||
|
0.360, 0.149, -0.116,
|
||||||
|
0.499, 0.207, 0.050,
|
||||||
|
0.360, -0.149, -0.116,
|
||||||
|
0.500, -0.207, 0.050,
|
||||||
|
0.150, -0.361, -0.116,
|
||||||
|
0.208, -0.500, 0.050,
|
||||||
|
-0.148, -0.361, -0.116,
|
||||||
|
-0.206, -0.501, 0.050,
|
||||||
|
-0.360, -0.151, -0.116,
|
||||||
|
-0.499, -0.209, 0.050,
|
||||||
|
-0.360, 0.147, -0.116,
|
||||||
|
-0.500, 0.205, 0.050,
|
||||||
|
-0.150, 0.359, -0.116,
|
||||||
|
-0.208, 0.498, 0.050,
|
||||||
|
0.148, 0.360, -0.116,
|
||||||
|
0.206, 0.499, 0.050,
|
||||||
|
]
|
||||||
|
@cylinderQuadStrip11 = [
|
||||||
|
0.206, 0.499, -0.327,
|
||||||
|
0.148, 0.360, -0.327,
|
||||||
|
0.499, 0.207, -0.327,
|
||||||
|
0.360, 0.149, -0.327,
|
||||||
|
0.500, -0.207, -0.327,
|
||||||
|
0.361, -0.149, -0.327,
|
||||||
|
0.208, -0.500, -0.327,
|
||||||
|
0.150, -0.361, -0.327,
|
||||||
|
-0.206, -0.501, -0.327,
|
||||||
|
-0.148, -0.362, -0.327,
|
||||||
|
-0.499, -0.209, -0.327,
|
||||||
|
-0.360, -0.151, -0.327,
|
||||||
|
-0.500, 0.205, -0.327,
|
||||||
|
-0.361, 0.148, -0.327,
|
||||||
|
-0.208, 0.498, -0.327,
|
||||||
|
-0.150, 0.359, -0.327,
|
||||||
|
0.206, 0.499, -0.327,
|
||||||
|
0.148, 0.360, -0.327,
|
||||||
|
]
|
||||||
|
@cylinderQuadStrip12 = [
|
||||||
|
0.148, 0.360, -0.327,
|
||||||
|
0.148, 0.360, -0.116,
|
||||||
|
0.360, 0.149, -0.327,
|
||||||
|
0.360, 0.149, -0.116,
|
||||||
|
0.361, -0.149, -0.327,
|
||||||
|
0.360, -0.149, -0.116,
|
||||||
|
0.150, -0.361, -0.327,
|
||||||
|
0.150, -0.361, -0.116,
|
||||||
|
-0.148, -0.362, -0.327,
|
||||||
|
-0.148, -0.361, -0.116,
|
||||||
|
-0.360, -0.151, -0.327,
|
||||||
|
-0.360, -0.151, -0.116,
|
||||||
|
-0.361, 0.148, -0.327,
|
||||||
|
-0.360, 0.147, -0.116,
|
||||||
|
-0.150, 0.359, -0.327,
|
||||||
|
-0.150, 0.359, -0.116,
|
||||||
|
0.148, 0.360, -0.327,
|
||||||
|
0.148, 0.360, -0.116,
|
||||||
|
]
|
||||||
|
@cylinderQuadStrip13 = [
|
||||||
|
0.206, 0.499, -0.494,
|
||||||
|
0.206, 0.499, -0.327,
|
||||||
|
0.499, 0.207, -0.494,
|
||||||
|
0.499, 0.207, -0.327,
|
||||||
|
0.500, -0.207, -0.494,
|
||||||
|
0.500, -0.207, -0.327,
|
||||||
|
0.208, -0.500, -0.494,
|
||||||
|
0.208, -0.500, -0.327,
|
||||||
|
-0.206, -0.501, -0.494,
|
||||||
|
-0.206, -0.501, -0.327,
|
||||||
|
-0.499, -0.209, -0.494,
|
||||||
|
-0.499, -0.209, -0.327,
|
||||||
|
-0.500, 0.205, -0.494,
|
||||||
|
-0.500, 0.205, -0.327,
|
||||||
|
-0.208, 0.498, -0.494,
|
||||||
|
-0.208, 0.498, -0.327,
|
||||||
|
0.206, 0.499, -0.494,
|
||||||
|
0.206, 0.499, -0.327,
|
||||||
|
]
|
||||||
|
@cylinderQuadStrip14 = [
|
||||||
|
-0.119, 0.284, -0.494,
|
||||||
|
-0.208, 0.498, -0.494,
|
||||||
|
0.118, 0.285, -0.494,
|
||||||
|
0.206, 0.499, -0.494,
|
||||||
|
0.285, 0.118, -0.494,
|
||||||
|
0.499, 0.207, -0.494,
|
||||||
|
0.286, -0.118, -0.494,
|
||||||
|
0.500, -0.207, -0.494,
|
||||||
|
0.119, -0.286, -0.494,
|
||||||
|
0.208, -0.500, -0.494,
|
||||||
|
-0.118, -0.287, -0.494,
|
||||||
|
-0.206, -0.501, -0.494,
|
||||||
|
-0.285, -0.120, -0.494,
|
||||||
|
-0.499, -0.209, -0.494,
|
||||||
|
-0.286, 0.117, -0.494,
|
||||||
|
-0.500, 0.205, -0.494,
|
||||||
|
-0.119, 0.284, -0.494,
|
||||||
|
-0.208, 0.498, -0.494,
|
||||||
|
]
|
||||||
|
@cylinderQuadStrip15 = [
|
||||||
|
0.118, 0.285, 0.133,
|
||||||
|
0.118, 0.285, -0.494,
|
||||||
|
0.285, 0.118, 0.133,
|
||||||
|
0.285, 0.118, -0.494,
|
||||||
|
0.286, -0.119, 0.133,
|
||||||
|
0.286, -0.118, -0.494,
|
||||||
|
0.119, -0.286, 0.133,
|
||||||
|
0.119, -0.286, -0.494,
|
||||||
|
-0.118, -0.287, 0.133,
|
||||||
|
-0.118, -0.287, -0.494,
|
||||||
|
-0.285, -0.120, 0.133,
|
||||||
|
-0.285, -0.120, -0.494,
|
||||||
|
-0.286, 0.117, 0.133,
|
||||||
|
-0.286, 0.117, -0.494,
|
||||||
|
-0.119, 0.284, 0.133,
|
||||||
|
-0.119, 0.284, -0.494,
|
||||||
|
0.118, 0.285, 0.133,
|
||||||
|
0.118, 0.285, -0.494,
|
||||||
|
]
|
||||||
|
@cylinderQuadStrip16 = [
|
||||||
|
0.206, 0.499, 0.133,
|
||||||
|
0.118, 0.285, 0.133,
|
||||||
|
0.499, 0.207, 0.133,
|
||||||
|
0.285, 0.118, 0.133,
|
||||||
|
0.500, -0.207, 0.133,
|
||||||
|
0.286, -0.119, 0.133,
|
||||||
|
0.208, -0.500, 0.133,
|
||||||
|
0.119, -0.286, 0.133,
|
||||||
|
-0.206, -0.501, 0.133,
|
||||||
|
-0.118, -0.287, 0.133,
|
||||||
|
-0.499, -0.209, 0.133,
|
||||||
|
-0.285, -0.120, 0.133,
|
||||||
|
-0.500, 0.205, 0.133,
|
||||||
|
-0.286, 0.117, 0.133,
|
||||||
|
-0.208, 0.498, 0.133,
|
||||||
|
-0.119, 0.284, 0.133,
|
||||||
|
0.206, 0.499, 0.133,
|
||||||
|
0.118, 0.285, 0.133,
|
||||||
|
]
|
||||||
|
|
||||||
|
# 00 00 0000000 000000000 0000000 00000000
|
||||||
|
# 000 000 000 000 000 000 000 000 000
|
||||||
|
# 000000000 000 000 000 000 000 0000000
|
||||||
|
# 000 0 000 000 000 000 000 000 000 000
|
||||||
|
# 000 000 0000000 000 0000000 000 000
|
||||||
|
|
||||||
|
@motorTriangles = [
|
||||||
|
0.167, -0.5, 0.29, 0.5, -0.5, 0.027, 0.5, -0.167, 0.29,
|
||||||
|
-0.5, -0.5, 0.027, -0.167, -0.5, 0.29, -0.5, -0.167, 0.29,
|
||||||
|
-0.167, 0.5, 0.29, -0.5, 0.5, 0.027, -0.5, 0.167, 0.29,
|
||||||
|
0.5, 0.167, 0.29, 0.5, 0.5, 0.027, 0.167, 0.5, 0.290
|
||||||
|
]
|
||||||
|
|
||||||
|
@motorQuads = [
|
||||||
|
-0.5, -0.5, -0.5,
|
||||||
|
0.5, -0.5, -0.5,
|
||||||
|
0.5, -0.5, 0.027,
|
||||||
|
-0.5, -0.5, 0.027,
|
||||||
|
|
||||||
|
-0.5, 0.5, -0.5,
|
||||||
|
-0.5, -0.5, -0.5,
|
||||||
|
-0.5, -0.5, 0.027,
|
||||||
|
-0.5, 0.5, 0.027,
|
||||||
|
|
||||||
|
0.5, 0.5, -0.5,
|
||||||
|
-0.5, 0.5, -0.5,
|
||||||
|
-0.5, 0.5, 0.027,
|
||||||
|
0.5, 0.5, 0.027,
|
||||||
|
|
||||||
|
0.5, -0.5, -0.5,
|
||||||
|
0.5, 0.5, -0.5,
|
||||||
|
0.5, 0.5, 0.027,
|
||||||
|
0.5, -0.5, 0.027,
|
||||||
|
|
||||||
|
-0.5, -0.167, 0.29,
|
||||||
|
-0.5, 0.167, 0.29,
|
||||||
|
-0.5, 0.5, 0.027,
|
||||||
|
-0.5, -0.5, 0.027,
|
||||||
|
|
||||||
|
-0.5, -0.167, 0.29,
|
||||||
|
0.5, -0.167, 0.29,
|
||||||
|
0.5, 0.167, 0.29,
|
||||||
|
-0.5, 0.167, 0.29,
|
||||||
|
|
||||||
|
-0.167, -0.5, 0.29,
|
||||||
|
0.167, -0.5, 0.29,
|
||||||
|
0.5, -0.167, 0.29,
|
||||||
|
-0.5, -0.167, 0.29,
|
||||||
|
|
||||||
|
0.167, -0.5, 0.29,
|
||||||
|
-0.167, -0.5, 0.29,
|
||||||
|
-0.5, -0.5, 0.027,
|
||||||
|
0.5, -0.5, 0.027,
|
||||||
|
|
||||||
|
-0.167, 0.5, 0.29,
|
||||||
|
0.167, 0.5, 0.29,
|
||||||
|
0.5, 0.5, 0.027,
|
||||||
|
-0.5, 0.5, 0.027,
|
||||||
|
|
||||||
|
0.167, 0.5, 0.29,
|
||||||
|
-0.167, 0.5, 0.29,
|
||||||
|
-0.5, 0.167, 0.29,
|
||||||
|
0.5, 0.167, 0.29,
|
||||||
|
|
||||||
|
0.5, -0.167, 0.29,
|
||||||
|
0.5, -0.5, 0.027,
|
||||||
|
0.5, 0.5, 0.027,
|
||||||
|
0.5, 0.167, 0.290
|
||||||
|
]
|
||||||
|
|
||||||
# 0000000 00000000 000 000 00000000 00000000 0000000 000000000 0000000 00000000
|
# 0000000 00000000 000 000 00000000 00000000 0000000 000000000 0000000 00000000
|
||||||
# 000 000 0000 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 0000000 000 0 000 0000000 0000000 000000000 000 000 000 0000000
|
# 000 0000 0000000 000 0 000 0000000 0000000 000000000 000 000 000 0000000
|
||||||
|
|
|
@ -19,13 +19,14 @@ module.exports =
|
||||||
|
|
||||||
s = world.size
|
s = world.size
|
||||||
{Gear,Generator,MotorCylinder,MotorGear,Face} = require '../items'
|
{Gear,Generator,MotorCylinder,MotorGear,Face} = require '../items'
|
||||||
world.addObjectAtPos new Generator(Face.Z), 5, 5, 0
|
# world.addObjectAtPos new Generator(Face.Z), 5, 5, 0
|
||||||
|
|
||||||
world.addObjectAtPos new Gear(Face.Z), 4, 5, 0
|
world.addObjectAtPos new MotorCylinder(Face.Z), 4, 5, 1
|
||||||
|
world.addObjectAtPos new MotorGear(Face.Z), 4, 5, 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), 5, 6, 0
|
||||||
world.addObjectAtPos new Gear(Face.Z), 5, 4, 0
|
world.addObjectAtPos new Gear(Face.Z), 5, 4, 0
|
||||||
|
return
|
||||||
world.addObjectAtPos new Gear(Face.Z), 6, 6, 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, 4, 0
|
||||||
world.addObjectAtPos new Gear(Face.Z), 4, 6, 0
|
world.addObjectAtPos new Gear(Face.Z), 4, 6, 0
|
||||||
|
|
30
coffee/material.coffee
Normal file
30
coffee/material.coffee
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
|
||||||
|
# 00 00 0000000 000000000 00000000 00000000 000 0000000 000
|
||||||
|
# 000 000 000 000 000 000 000 000 000 000 000 000
|
||||||
|
# 000000000 000000000 000 0000000 0000000 000 000000000 000
|
||||||
|
# 000 0 000 000 000 000 000 000 000 000 000 000 000
|
||||||
|
# 000 000 000 000 000 00000000 000 000 000 000 000 0000000
|
||||||
|
|
||||||
|
module.exports =
|
||||||
|
|
||||||
|
gear: new THREE.MeshPhongMaterial
|
||||||
|
color: 0xff0000
|
||||||
|
side: THREE.FrontSide
|
||||||
|
shading: THREE.SmoothShading
|
||||||
|
shininess: 20
|
||||||
|
|
||||||
|
raster: new THREE.MeshPhongMaterial
|
||||||
|
color: 0x880000
|
||||||
|
side: THREE.FrontSide
|
||||||
|
shading: THREE.SmoothShading
|
||||||
|
shininess: 20
|
||||||
|
|
||||||
|
plate: new THREE.MeshPhongMaterial
|
||||||
|
color: 0x880000
|
||||||
|
side: THREE.FrontSide
|
||||||
|
shading: THREE.SmoothShading
|
||||||
|
shininess: 10
|
||||||
|
emissive: 0x880000
|
||||||
|
emissiveIntensity: 0.02
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,17 @@
|
||||||
# 000 0 000 000 000 000 000 000 000 000 000 000 000 000 000 0000 000 000 000 000 000
|
# 000 0 000 000 000 000 000 000 000 000 000 000 000 000 000 0000 000 000 000 000 000
|
||||||
# 000 000 0000000 000 0000000 000 000 0000000 000 0000000 000 000 000 0000000 00000000 000 000
|
# 000 000 0000000 000 0000000 000 000 0000000 000 0000000 000 000 000 0000000 00000000 000 000
|
||||||
|
|
||||||
|
log = require '/Users/kodi/s/ko/js/tools/log'
|
||||||
Item = require './item'
|
Item = require './item'
|
||||||
Action = require './action'
|
Action = require './action'
|
||||||
Face = require './face'
|
Face = require './face'
|
||||||
|
Geom = require './geom'
|
||||||
|
Material = require './material'
|
||||||
|
|
||||||
class MotorCylinder extends Item
|
class MotorCylinder extends Item
|
||||||
|
|
||||||
|
isSpaceEgoistic: -> true
|
||||||
|
|
||||||
constructor: (face) ->
|
constructor: (face) ->
|
||||||
super
|
super
|
||||||
@value = 0.0
|
@value = 0.0
|
||||||
|
@ -18,38 +23,32 @@ class MotorCylinder extends Item
|
||||||
@addAction new Action @, Action.TUCKER, "tucker", 500, Action.REPEAT
|
@addAction new Action @, Action.TUCKER, "tucker", 500, Action.REPEAT
|
||||||
@setActive true
|
@setActive true
|
||||||
|
|
||||||
|
createMesh: ->
|
||||||
|
|
||||||
|
@mesh = new THREE.Mesh Geom.cylinder(), Material.plate
|
||||||
|
@kolben = new THREE.Mesh Geom.kolben(), Material.gear
|
||||||
|
@mesh.add @kolben
|
||||||
|
@mesh.receiveShadow = true
|
||||||
|
|
||||||
|
updateMesh: -> @kolben.position.set 0, 0, -0.5 * Math.sin(@value)
|
||||||
|
|
||||||
setActive: (active) ->
|
setActive: (active) ->
|
||||||
if @active != active
|
if @active != active
|
||||||
@active = active
|
@active = active
|
||||||
|
|
||||||
if @active
|
if @active
|
||||||
@startTimedAction @getActionWithId Action.TUCKER
|
@startTimedAction @getActionWithId Action.TUCKER
|
||||||
else
|
else
|
||||||
@stopAction @getActionWithId Action.TUCKER
|
@stopAction @getActionWithId Action.TUCKER
|
||||||
|
|
||||||
performAction: (action) ->
|
performAction: (action) ->
|
||||||
|
|
||||||
if action.id == Action.TUCKER
|
if action.id == Action.TUCKER
|
||||||
relTime = action.getRelativeTime()
|
relTime = action.getRelativeTime()
|
||||||
@value = (relTime < 0.5) and relTime or 1.0 - relTime
|
@value = if relTime > 0.5 then 1.0 - relTime else relTime
|
||||||
@value *= 2
|
@value *= 2
|
||||||
|
@updateMesh()
|
||||||
|
|
||||||
finishAction: (action) ->
|
finishAction: (action) ->
|
||||||
|
|
||||||
if action.id == Action.TUCKER
|
if action.id == Action.TUCKER
|
||||||
world.playSound 'MOTOR', @getPos()
|
world.playSound 'MOTOR', @getPos()
|
||||||
|
|
||||||
render: () ->
|
|
||||||
# colors[0].glColor();
|
|
||||||
#
|
|
||||||
# KMatrix (orientation).glMultMatrix();
|
|
||||||
#
|
|
||||||
# render_cylinder;
|
|
||||||
#
|
|
||||||
# glTranslatef (0.0, 0.0, -0.5 * sin(value));
|
|
||||||
#
|
|
||||||
# KikiGear::getObjectColor(0).glColor();
|
|
||||||
#
|
|
||||||
# render_kolben;
|
|
||||||
|
|
||||||
module.exports = MotorCylinder
|
module.exports = MotorCylinder
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
# 000 000 0000000 000 0000000 000 000 0000000 00000000 000 000 000 000
|
# 000 000 0000000 000 0000000 000 000 0000000 00000000 000 000 000 000
|
||||||
|
|
||||||
Gear = require './gear'
|
Gear = require './gear'
|
||||||
|
Geom = require './geom'
|
||||||
|
Material = require './material'
|
||||||
|
|
||||||
class MotorGear extends Gear
|
class MotorGear extends Gear
|
||||||
|
|
||||||
|
@ -12,20 +14,9 @@ class MotorGear extends Gear
|
||||||
super face
|
super face
|
||||||
@setActive true
|
@setActive true
|
||||||
|
|
||||||
render: ->
|
createMesh: ->
|
||||||
# colors[0].glColor();
|
@mesh = new THREE.Mesh Geom.gear(), Material.gear
|
||||||
#
|
@mesh.add new THREE.Mesh Geom.motor(), Material.plate
|
||||||
# render_motor;
|
@mesh.receiveShadow = true
|
||||||
#
|
|
||||||
# if (active)
|
|
||||||
# {
|
|
||||||
# glRotatef (clockwise ? angle : -angle, 0.0, 0.0, 1.0);
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# KikiGear::getObjectColor(0).glColor();
|
|
||||||
#
|
|
||||||
# glTranslatef (0.0, 0.0, 0.4);
|
|
||||||
#
|
|
||||||
# render_gear;
|
|
||||||
|
|
||||||
module.exports = MotorGear
|
module.exports = MotorGear
|
||||||
|
|
Loading…
Reference in New Issue
Block a user