bot
This commit is contained in:
parent
2acfe785db
commit
c88a0f8c52
|
@ -24,34 +24,63 @@ class Bot extends Pushable
|
|||
@climb_orientation = new Quaternion
|
||||
@rest_orientation = new Quaternion
|
||||
|
||||
tireRadius = 0.18
|
||||
tireRadius = 0.15
|
||||
|
||||
geom = new THREE.SphereGeometry 0.5, 32, 32
|
||||
mat = new THREE.MeshPhongMaterial
|
||||
color: 0x222266
|
||||
nose = new THREE.ConeGeometry 0.404, 0.5, 32, 16, true
|
||||
geom = new THREE.SphereGeometry 0.5, 32, 32, 16, Math.PI
|
||||
geom = new THREE.SphereGeometry 0.5, 32, 32, 0, 2*Math.PI, 0, 2.2
|
||||
|
||||
noseMat = new THREE.Matrix4()
|
||||
trans = new THREE.Vector3 0,-0.543,0
|
||||
rot = new THREE.Quaternion().setFromEuler new THREE.Euler Vector.DEG2RAD(180), 0, 0
|
||||
|
||||
noseMat.compose trans, rot, new THREE.Vector3 1,1,1
|
||||
geom.merge nose, noseMat
|
||||
geom.rotateX Vector.DEG2RAD -90
|
||||
# geom.mergeVertices()
|
||||
# geom.computeFaceNormals()
|
||||
# geom.computeVertexNormals()
|
||||
geom.scale 0.7, 0.7, 0.7
|
||||
|
||||
botMat = new THREE.MeshPhongMaterial
|
||||
color: 0x2222ff
|
||||
side: THREE.FrontSide
|
||||
shading: THREE.SmoothShading
|
||||
roughness: 0.9
|
||||
metalness: 1
|
||||
transparent: true
|
||||
opacity: 0.9
|
||||
shininess: 0.99
|
||||
@mesh = new THREE.Mesh geom, mat
|
||||
shininess: 5
|
||||
|
||||
geom = new THREE.TorusGeometry 0.5, tireRadius, 16, 16
|
||||
mat = new THREE.MeshPhongMaterial
|
||||
color: 0x111155
|
||||
@mesh = new THREE.Mesh geom, botMat
|
||||
|
||||
geom = new THREE.TorusGeometry 0.5-tireRadius, tireRadius, 16, 16
|
||||
|
||||
tireMat = new THREE.MeshStandardMaterial
|
||||
color: 0x2222ff
|
||||
side: THREE.FrontSide
|
||||
shading: THREE.SmoothShading
|
||||
shading: THREE.FlatShading
|
||||
roughness: 0.8
|
||||
metalness: 1
|
||||
transparent: true
|
||||
opacity: 0.9
|
||||
shininess: 0.99
|
||||
opacity: 0.7
|
||||
|
||||
tireMat = new THREE.MeshPhongMaterial
|
||||
color: 0x000066
|
||||
specular: 0x222255
|
||||
side: THREE.FrontSide
|
||||
shading: THREE.FlatShading
|
||||
transparent: true
|
||||
opacity: 0.7
|
||||
shininess: 4
|
||||
|
||||
@leftTire = new THREE.Mesh geom, mat
|
||||
@leftTire.position.set -0.5,0,0
|
||||
@leftTire = new THREE.Mesh geom, tireMat
|
||||
@leftTire.position.set 0.5-tireRadius,0,0
|
||||
@leftTire.rotation.set 0, Vector.DEG2RAD(90), 0
|
||||
@mesh.add @leftTire
|
||||
|
||||
@rightTire = new THREE.Mesh geom, mat
|
||||
@rightTire.position.set 0.5,0,0
|
||||
@rightTire = new THREE.Mesh geom, tireMat
|
||||
@rightTire.position.set -0.5+tireRadius,0,0
|
||||
@rightTire.rotation.set 0, Vector.DEG2RAD(-90), 0
|
||||
@mesh.add @rightTire
|
||||
|
||||
|
|
|
@ -35,7 +35,8 @@ class Item extends Actor
|
|||
isSlippery: -> false
|
||||
|
||||
setPosition: (x,y,z) ->
|
||||
@position = @current_position = new Vector x,y,z
|
||||
@position = new Vector x,y,z
|
||||
@current_position = new Vector x,y,z
|
||||
@mesh?.position.copy @position
|
||||
|
||||
getPos: -> new Pos @current_position
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
# 00000000 0000000 0000000 0000000 00000000 0000000 000 000 000 000 000 0000000
|
||||
# 000 000 000 000 000 000 000 000 000 000 000 000
|
||||
# 000 00000000 000 000 0000000 000 00000000 0000000 000 000 0 00000000
|
||||
|
||||
{
|
||||
clamp
|
||||
} = require '/Users/kodi/s/ko/js/tools/tools'
|
||||
log = require '/Users/kodi/s/ko/js/tools/log'
|
||||
Matrix = require './lib/matrix'
|
||||
|
||||
|
@ -17,9 +19,8 @@ class Perspective extends Matrix
|
|||
@eye_distance = 5.0
|
||||
@border = [0,0,0,0]
|
||||
@setViewport 0.0, 0.0, 1.0, 1.0
|
||||
# WINDOW_SIZE_CHANGED -> updateViewport
|
||||
super
|
||||
log "Perspective #{@fov} #{@znear} #{@zfar}"
|
||||
# log "Perspective #{@fov} #{@znear} #{@zfar}"
|
||||
|
||||
reset: ->
|
||||
@fov = 60.0
|
||||
|
@ -112,7 +113,7 @@ class Perspective extends Matrix
|
|||
|
||||
setFov: (fov) -> @fov = Math.max(2.0, Math.min fov, 175.0)
|
||||
|
||||
setEyeDistance: (distance) -> @eye_distance = Math.min( Math.max(@znear, distance), 0.9 * @zfar );
|
||||
setEyeDistance: (distance) -> @eye_distance = clamp @znear, distance, 0.9 * @zfar
|
||||
|
||||
module.exports = Perspective
|
||||
|
|
@ -161,12 +161,12 @@ class Player extends Bot
|
|||
|
||||
getFollowProjection: () ->
|
||||
|
||||
cameraPos = @projection.getPosition() # current camera position
|
||||
desiredDistance = 2.0 # desired distance from camera to bot
|
||||
cameraPos = @projection.getPosition()
|
||||
desiredDistance = 2.0 # desired distance from camera to bot
|
||||
|
||||
@updatePosition()
|
||||
|
||||
playerPos = @current_position # desired look pos
|
||||
playerPos = @current_position # desired look pos
|
||||
playerDir = @getCurrentDir()
|
||||
playerUp = @current_orientation.rotate new Vector(0,1,0).normal()
|
||||
playerRight = playerDir.cross(playerUp).normal()
|
||||
|
|
|
@ -94,7 +94,7 @@ class World extends Actor
|
|||
@sun.position.copy @camera.position
|
||||
@scene.add @sun
|
||||
|
||||
@ambient = new THREE.AmbientLight 0x444444
|
||||
@ambient = new THREE.AmbientLight 0x111111
|
||||
@scene.add @ambient
|
||||
|
||||
@preview = false
|
||||
|
@ -105,9 +105,8 @@ class World extends Actor
|
|||
@size = new Pos()
|
||||
@depth = -Number.MAX_SAFE_INTEGER
|
||||
# @camera_mode = World.CAMERA_INSIDE
|
||||
@camera_mode = World.CAMERA_BEHIND
|
||||
# @camera_mode = World.CAMERA_FOLLOW
|
||||
@edit_projection = null
|
||||
# @camera_mode = World.CAMERA_BEHIND
|
||||
@camera_mode = World.CAMERA_FOLLOW
|
||||
@raster_size = 0.1
|
||||
|
||||
# 0000000 0000000 0000000 00000000
|
||||
|
@ -287,7 +286,7 @@ class World extends Actor
|
|||
|
||||
@player = new Player
|
||||
player_dict = @dict.player
|
||||
log "player_dict", player_dict
|
||||
# log "player_dict", player_dict
|
||||
if player_dict.orientation?
|
||||
@player.setOrientation player_dict.orientation
|
||||
else
|
||||
|
@ -309,7 +308,7 @@ class World extends Actor
|
|||
# else
|
||||
# Controller.player_status.show()
|
||||
#
|
||||
# @getProjection().setPosition(KVector())
|
||||
@getProjection().setPosition new Vector 0,0,0
|
||||
|
||||
# @player.getStatus().setMinMoves (highscore.levelParMoves (@level_name))
|
||||
# @player.getStatus().setMoves (0)
|
||||
|
@ -601,7 +600,7 @@ class World extends Actor
|
|||
if not cell?
|
||||
cellIndex = @posToIndex(pos)
|
||||
cell = new Cell()
|
||||
log "created cell at index #{cellIndex}"
|
||||
# log "created cell at index #{cellIndex}"
|
||||
@cells[cellIndex] = cell
|
||||
|
||||
object.setPosition pos
|
||||
|
@ -724,14 +723,14 @@ class World extends Actor
|
|||
@moved_objects.push object
|
||||
|
||||
objectWillMoveToPos: (object, pos, duration) ->
|
||||
log "world.objectWillMoveToPos", pos
|
||||
# log "world.objectWillMoveToPos", pos
|
||||
|
||||
if @isInvalidPos pos
|
||||
log "objectWillMoveToPos invalid pos:", pos
|
||||
log "world.objectWillMoveToPos [WARNING] invalid pos:", pos
|
||||
return
|
||||
|
||||
if object.getPos().eql pos
|
||||
log "WARNING objectWillMoveToPos equal pos:", pos
|
||||
log "world.objectWillMoveToPos [WARNING] equal pos:", pos
|
||||
return
|
||||
|
||||
if cell = @getCellAtPos pos
|
||||
|
@ -741,18 +740,18 @@ class World extends Actor
|
|||
# temporary object at new pos will vanish before object will arrive . delete it
|
||||
objectAtNewPos.del()
|
||||
else
|
||||
log "World.objectWillMoveToPos timing conflict at pos:", pos
|
||||
log "world.objectWillMoveToPos [WARNING] timing conflict at pos:", pos
|
||||
else
|
||||
log "World.objectWillMoveToPos already occupied:", pos
|
||||
log "world.objectWillMoveToPos [WARNING] already occupied:", pos
|
||||
|
||||
@unsetObject object # remove object from cell grid
|
||||
# log 'tmpObject at new pos', pos
|
||||
tmpObject = new TmpObject object # insert temporary objects at new pos
|
||||
tmpObject = new TmpObject object # insert tmp object at new pos
|
||||
tmpObject.setPosition pos
|
||||
tmpObject.time = duration
|
||||
@addObjectAtPos tmpObject, pos
|
||||
# log 'tmpObject at old pos', object.position
|
||||
tmpObject = new TmpObject object # insert temporary objects at old pos
|
||||
tmpObject = new TmpObject object # insert tmp object at old pos
|
||||
tmpObject.setPosition object.position
|
||||
tmpObject.time = -duration
|
||||
@addObjectAtPos tmpObject, object.getPos()
|
||||
|
@ -799,7 +798,7 @@ class World extends Actor
|
|||
quat.multiply (new THREE.Quaternion).setFromAxisAngle(new THREE.Vector3(0,1,0), step.dsecs*0.1)
|
||||
# center = @decenter 0,0,0
|
||||
center = @size.div 2
|
||||
log center
|
||||
# log center
|
||||
@camera.position.set(center.x,center.y,center.z+@dist).applyQuaternion quat
|
||||
@camera.quaternion.copy quat
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user