title
This commit is contained in:
parent
fb68cfbd18
commit
e5853e8765
|
@ -30,6 +30,10 @@ class Action
|
|||
@LOOK_RESET = 19
|
||||
@TUCKER = 20
|
||||
|
||||
@SHOW = 1
|
||||
@HIDE = 2
|
||||
@DELETE = 3
|
||||
|
||||
@ONCE = 0
|
||||
@CONTINUOUS = 1
|
||||
@REPEAT = 2
|
||||
|
|
|
@ -62,21 +62,21 @@ class Camera extends Matrix
|
|||
@cam.lookAt @getPosition().plus @getZVector()
|
||||
|
||||
updateViewport: ->
|
||||
ss = world.screenSize
|
||||
vp = []
|
||||
vp[0] = @viewport[0] * ss.w + @border[0]
|
||||
vp[1] = @viewport[1] * ss.h + @border[1]
|
||||
vp[2] = @viewport[2] * ss.w - @border[0] - @border[2]
|
||||
vp[3] = @viewport[3] * ss.h - @border[1] - @border[3]
|
||||
# ss = world.screenSize
|
||||
# vp = []
|
||||
# vp[0] = @viewport[0] * ss.w + @border[0]
|
||||
# vp[1] = @viewport[1] * ss.h + @border[1]
|
||||
# vp[2] = @viewport[2] * ss.w - @border[0] - @border[2]
|
||||
# vp[3] = @viewport[3] * ss.h - @border[1] - @border[3]
|
||||
|
||||
setViewportBorder: (l, b, r, t) ->
|
||||
@border = [l,b,r,t]
|
||||
@updateViewport()
|
||||
# @border = [l,b,r,t]
|
||||
# @updateViewport()
|
||||
|
||||
setViewport: (l, b, w, h) ->
|
||||
@viewport = [l,b,w,h]
|
||||
@updateViewport()
|
||||
|
||||
# @viewport = [l,b,w,h]
|
||||
# @updateViewport()
|
||||
#
|
||||
setFov: (fov) -> @fov = Math.max(2.0, Math.min fov, 175.0)
|
||||
|
||||
# 00000000 00000000 0000000 000 00000000 0000000 000000000 000 0000000 000 000
|
||||
|
|
|
@ -32,6 +32,12 @@ module.exports =
|
|||
transparent: true
|
||||
opacity: 1
|
||||
|
||||
text: new THREE.MeshPhongMaterial
|
||||
side: THREE.FrontSide
|
||||
shading: THREE.SmoothShading
|
||||
specular: 0xffff00
|
||||
transparent: true
|
||||
|
||||
mutant: new THREE.MeshPhongMaterial
|
||||
color: 0x888888
|
||||
side: THREE.FrontSide
|
||||
|
|
|
@ -41,8 +41,6 @@ module.exports =
|
|||
color: rgb 0, 0, 0.2
|
||||
text:
|
||||
color: rgb 0.8, 0.8, 0
|
||||
bright: rgb 1, 1, 0
|
||||
dark: rgb 0.6, 0.4, 0
|
||||
gear:
|
||||
color: rgb 0.1, 0.1, 0.9
|
||||
wire:
|
||||
|
@ -78,9 +76,7 @@ module.exports =
|
|||
mutantTire:
|
||||
color: rgb 0, 0, 0.2
|
||||
text:
|
||||
color: rgb 0.8, 0.8, 0
|
||||
bright: rgb 1, 1, 0
|
||||
dark: rgb 0.6, 0.4, 0
|
||||
color: rgb 0.3, 0.3, 0.9
|
||||
gear:
|
||||
color: rgb 0.1, 0.1, 0.9
|
||||
wire:
|
||||
|
@ -117,9 +113,7 @@ module.exports =
|
|||
mutantTire:
|
||||
color: rgb 0.5, 0, 0
|
||||
text:
|
||||
color: rgb 0.8, 0.8, 0
|
||||
bright: rgb 1, 1, 0
|
||||
dark: rgb 0.6, 0.4, 0
|
||||
color: rgb 0.8, 0.8, 0.8
|
||||
gear:
|
||||
color: rgb 0.1, 0.1, 0.9
|
||||
wire:
|
||||
|
@ -142,8 +136,6 @@ module.exports =
|
|||
color: rgb 1, 1, 1
|
||||
text:
|
||||
color: rgb 0.7, 0, 0.7
|
||||
bright: rgb 1, 0, 1
|
||||
dark: rgb 0.4, 0, 0.4
|
||||
bomb:
|
||||
color: rgb 1, 0.8, 0
|
||||
stone:
|
||||
|
@ -206,9 +198,7 @@ module.exports =
|
|||
bomb:
|
||||
color: rgb 0.9, 0.7, 0.1
|
||||
text:
|
||||
color: rgb 0.7, 0.5, 0.1
|
||||
bright: rgb 0.9, 0.7, 0.15
|
||||
dark: rgb 0.6, 0.4, 0
|
||||
color: rgb 0.9, 0.7, 0.1
|
||||
|
||||
# 00000000 00000000 0000000
|
||||
# 000 000 000 000 000
|
||||
|
@ -245,9 +235,7 @@ module.exports =
|
|||
wire:
|
||||
color: rgb 0.5, 0, 0
|
||||
text:
|
||||
color: rgb 1, 0.5, 0
|
||||
bright: rgb 1, 0.8, 0
|
||||
dark: rgb 0.4, 0.2, 0
|
||||
color: rgb 1, 0, 0
|
||||
|
||||
# 0000000 000 000 000 00000000
|
||||
# 000 000 000 000 000 000
|
||||
|
@ -279,9 +267,7 @@ module.exports =
|
|||
mutantTire:
|
||||
color: rgb 0, 0, 0.7
|
||||
text:
|
||||
color: rgb 0.2, 0.4, 0.8
|
||||
bright: rgb 0.7, 0.8, 1
|
||||
dark: rgb 0, 0, 0.6
|
||||
color: rgb 0.8, 0.4, 0
|
||||
gear:
|
||||
color: rgb 0.8, 0.4, 0
|
||||
shininess: 80
|
||||
|
@ -336,8 +322,6 @@ module.exports =
|
|||
color: rgb 1, 1, 0
|
||||
text:
|
||||
color: rgb 0.7, 0.7, 0
|
||||
bright: rgb 1, 1, 0
|
||||
dark: rgb 0.4, 0.4, 0
|
||||
|
||||
# 0000000 00000000 00000000 00000000 000 000
|
||||
# 000 000 000 000 000 0000 000
|
||||
|
@ -352,7 +336,6 @@ module.exports =
|
|||
color: rgb 0.3, 1, 0.3
|
||||
stone:
|
||||
color: rgb 0, 0.2, 0
|
||||
# specular: rgb 0, 0.01, 0
|
||||
opacity: 0.8
|
||||
shininess: 60
|
||||
switch:
|
||||
|
@ -371,8 +354,6 @@ module.exports =
|
|||
color: rgb 0, 0.7, 0
|
||||
text:
|
||||
color: rgb 0, 0.4, 0
|
||||
bright: rgb 0, 0.6, 0
|
||||
dark: rgb 0, 0.2, 0
|
||||
gear:
|
||||
color: rgb 0, 0.2, 0
|
||||
wire:
|
||||
|
@ -415,9 +396,7 @@ module.exports =
|
|||
glow:
|
||||
color: rgb 1, 1, 1
|
||||
text:
|
||||
color: rgb 0.2, 0.4, 0.5
|
||||
bright: rgb 0.3, 0.9, 1
|
||||
dark: rgb 0.1, 0.3, 0.4
|
||||
color: rgb 0.8, 0.8, 0.8
|
||||
|
||||
# 0000000 00000000 0000000 0000000 000 000
|
||||
# 000 000 000 000 000 000 000 000
|
||||
|
@ -463,9 +442,7 @@ module.exports =
|
|||
glow:
|
||||
color: rgb 0, 0, 1
|
||||
text:
|
||||
color: rgb 0.2, 0.4, 0.5
|
||||
bright: rgb 0.3, 0.9, 1
|
||||
dark: rgb 0.1, 0.3, 0.4
|
||||
color: rgb 1, 0, 0
|
||||
|
||||
# 0000000 00000000 000 000
|
||||
# 000 000 0000 000
|
||||
|
@ -504,7 +481,5 @@ module.exports =
|
|||
color: rgb 0, 0, 1
|
||||
text:
|
||||
color: rgb 0.2, 0.4, 0.5
|
||||
bright: rgb 0.3, 0.9, 1
|
||||
dark: rgb 0.1, 0.3, 0.4
|
||||
|
||||
|
93
coffee/screentext.coffee
Normal file
93
coffee/screentext.coffee
Normal file
|
@ -0,0 +1,93 @@
|
|||
|
||||
# 0000000 0000000 00000000 00000000 00000000 000 000 000000000 00000000 000 000 000000000
|
||||
# 000 000 000 000 000 000 0000 000 000 000 000 000 000
|
||||
# 0000000 000 0000000 0000000 0000000 000 0 000 000 0000000 00000 000
|
||||
# 000 000 000 000 000 000 000 0000 000 000 000 000 000
|
||||
# 0000000 0000000 000 000 00000000 00000000 000 000 000 00000000 000 000 000
|
||||
|
||||
Camera = require './camera'
|
||||
Action = require './action'
|
||||
Timer = require './timer'
|
||||
Actor = require './actor'
|
||||
Vector = require './lib/vector'
|
||||
Material = require './material'
|
||||
|
||||
class ScreenText extends Actor
|
||||
|
||||
@init: -> @font = new THREE.Font require 'three/examples/fonts/helvetiker_bold.typeface.json'
|
||||
|
||||
constructor: (text) ->
|
||||
super
|
||||
|
||||
@addAction new Action @, Action.SHOW, "show", 500
|
||||
@addAction new Action @, Action.HIDE, "hide", 500
|
||||
|
||||
@scene = new THREE.Scene()
|
||||
|
||||
sun = new THREE.PointLight 0xffffff
|
||||
sun.position.set -1,1,10
|
||||
@scene.add sun
|
||||
|
||||
@width = @height = 0
|
||||
@mesh = new THREE.Object3D
|
||||
@scene.add @mesh
|
||||
@fov = 20
|
||||
@aspect = world.screenSize.w/world.screenSize.h
|
||||
@near = 0.1
|
||||
@far = 100
|
||||
@camera = new THREE.PerspectiveCamera @fov, @aspect, @near, @far
|
||||
if text?
|
||||
@addText text
|
||||
@show()
|
||||
|
||||
show: -> @startTimedAction @getActionWithId Action.SHOW
|
||||
|
||||
addText: (str, scaleFactor) ->
|
||||
@height += 1
|
||||
geom = new THREE.TextGeometry str,
|
||||
font: ScreenText.font
|
||||
size: 1
|
||||
height: 0.5
|
||||
bevelEnabled: true
|
||||
bevelThickness: 0.1
|
||||
bevelSize: 0.04
|
||||
|
||||
@width = Math.max str.length, @width
|
||||
geom.computeBoundingBox()
|
||||
geom.normalize()
|
||||
min = geom.boundingBox.min
|
||||
max = geom.boundingBox.max
|
||||
mesh = new THREE.Mesh geom, Material.text
|
||||
@mesh.add mesh
|
||||
|
||||
# adjust projection
|
||||
@camera.position.copy new Vector 0,0,6*@height
|
||||
@camera.lookAt new Vector 0,0,0
|
||||
|
||||
resized: (w,h) ->
|
||||
@aspect = w/h
|
||||
@camera.aspect = @aspect
|
||||
@camera.updateProjectionMatrix()
|
||||
|
||||
performAction: (action) ->
|
||||
switch action.id
|
||||
when Action.SHOW
|
||||
Material.text.opacity = action.getRelativeTime()
|
||||
when Action.HIDE
|
||||
Material.text.opacity = 1 - action.getRelativeTime()
|
||||
|
||||
actionFinished: (action) ->
|
||||
switch action.id
|
||||
when Action.HIDE
|
||||
@emit 'hidden'
|
||||
when Action.SHOW
|
||||
Material.text.opacity = 1
|
||||
|
||||
fadeOut: ->
|
||||
return if @fadingOut
|
||||
@fadingOut = true
|
||||
@stopAction @getActionWithId Action.SHOW
|
||||
@startTimedAction @getActionWithId Action.HIDE
|
||||
|
||||
module.exports = ScreenText
|
||||
|
|
@ -25,6 +25,7 @@ Timer = require './timer'
|
|||
Actor = require './actor'
|
||||
Item = require './item'
|
||||
Action = require './action'
|
||||
ScreenText = require './screentext'
|
||||
TmpObject = require './tmpobject'
|
||||
Pushable = require './pushable'
|
||||
Material = require './material'
|
||||
|
@ -74,10 +75,10 @@ class World extends Actor
|
|||
@renderer = new THREE.WebGLRenderer
|
||||
antialias: true
|
||||
logarithmicDepthBuffer: false
|
||||
autoClear: true
|
||||
autoClear: false
|
||||
sortObjects: true
|
||||
|
||||
@renderer.setClearColor 0x000000
|
||||
# @renderer.setClearColor 0x000000
|
||||
@renderer.setSize @view.offsetWidth, @view.offsetHeight
|
||||
@renderer.shadowMap.type = THREE.PCFSoftShadowMap
|
||||
|
||||
|
@ -127,9 +128,11 @@ class World extends Actor
|
|||
@initGlobal: () ->
|
||||
|
||||
return if @levels?
|
||||
|
||||
Sound.init()
|
||||
global.log = log
|
||||
|
||||
ScreenText.init()
|
||||
Sound.init()
|
||||
|
||||
global.rot0 = Quaternion.rot_0
|
||||
global.rotx90 = Quaternion.rot_90_X
|
||||
global.roty90 = Quaternion.rot_90_Y
|
||||
|
@ -190,19 +193,14 @@ class World extends Actor
|
|||
|
||||
@creating = true
|
||||
|
||||
@setSize @dict["size"] # this removes all objects
|
||||
@setSize @dict.size # this removes all objects
|
||||
|
||||
@applyScheme @dict.scheme ? 'default'
|
||||
|
||||
# ............................................................ intro text
|
||||
# if "intro" in @dict
|
||||
# if not @preview
|
||||
# intro_text = KikiScreenText()
|
||||
# intro_text.addText @dict["intro"]
|
||||
# intro_text.show()
|
||||
# @setName @dict["intro"]
|
||||
# else
|
||||
# @setName "noname"
|
||||
|
||||
if not @preview
|
||||
@text = new ScreenText @dict.name
|
||||
|
||||
# ............................................................ escape
|
||||
# escape_event = Controller.getEventWithName ("escape")
|
||||
|
@ -278,6 +276,7 @@ class World extends Actor
|
|||
opacity =
|
||||
stone: 0.7
|
||||
bomb: 0.9
|
||||
text: 0
|
||||
|
||||
shininess =
|
||||
tire: 4
|
||||
|
@ -286,6 +285,7 @@ class World extends Actor
|
|||
wall: 20
|
||||
stone: 20
|
||||
gear: 20
|
||||
text: 200
|
||||
|
||||
colors.plate.emissive ?= colors.plate.color
|
||||
colors.bulb.emissive ?= colors.bulb.color
|
||||
|
@ -297,7 +297,7 @@ class World extends Actor
|
|||
colors.wirePlate.color ?= colors.wire.color
|
||||
for k,v of colors
|
||||
# log "#{k} #{v.color?.r} #{v.color?.g} #{v.color?.b}", v
|
||||
continue if k == 'text'
|
||||
# continue if k == 'text'
|
||||
mat = Material[k]
|
||||
mat.color = v.color
|
||||
mat.opacity = v.opacity ? opacity[k] ? 1
|
||||
|
@ -690,7 +690,9 @@ class World extends Actor
|
|||
order += 1
|
||||
|
||||
@sun.position.copy camera.position
|
||||
@renderer.autoClearColor = false
|
||||
@renderer.render @scene, camera
|
||||
@renderer.render @text.scene, @text.camera if @text
|
||||
|
||||
# 000000000 000 00 00 00000000
|
||||
# 000 000 000 000 000
|
||||
|
@ -729,11 +731,12 @@ class World extends Actor
|
|||
camera?.updateProjectionMatrix()
|
||||
@renderer?.setSize w,h
|
||||
@screenSize = new Size w,h
|
||||
@text?.resized w,h
|
||||
|
||||
getNearestValidPos: (pos) ->
|
||||
new KikiPos Math.min(size.x-1, Math.max(pos.x, 0)),
|
||||
Math.min(size.y-1, Math.max(pos.y, 0)),
|
||||
Math.min(size.z-1, Math.max(pos.z, 0))
|
||||
new Pos Math.min(@size.x-1, Math.max(pos.x, 0)),
|
||||
Math.min(@size.y-1, Math.max(pos.y, 0)),
|
||||
Math.min(@size.z-1, Math.max(pos.z, 0))
|
||||
|
||||
isUnoccupiedPos: (pos) -> not @isOccupiedPos pos
|
||||
isOccupiedPos: (pos) ->
|
||||
|
@ -915,6 +918,7 @@ class World extends Actor
|
|||
# 000 000 00000000 000
|
||||
|
||||
modKeyComboEventDown: (mod, key, combo, event) ->
|
||||
@text?.fadeOut()
|
||||
return if @player?.modKeyComboEventDown mod, key, combo, event
|
||||
switch combo
|
||||
when '=' then @speed = Math.min 10, @speed+1
|
||||
|
|
Loading…
Reference in New Issue
Block a user