on scene selection OK + keyframe model
This commit is contained in:
@@ -14,7 +14,7 @@ export class kfArena{
|
||||
this.sceneSize = app.Assets.Store.json.arenaConfig.arenaSize
|
||||
this.initScene()
|
||||
this.raycaster = new THREE.Raycaster()
|
||||
this.agents = []
|
||||
this.agents = {}
|
||||
this.onclickAgent = null
|
||||
}
|
||||
|
||||
@@ -58,6 +58,13 @@ export class kfArena{
|
||||
this.scene.add(this.axes)
|
||||
|
||||
this.renderer = new THREE.WebGLRenderer({ antialias: true, canvas: this.canvasEl })
|
||||
this.init3DHighlighter({
|
||||
edgeStrength: 3,
|
||||
visibleEdgeColor: 0xffff00,
|
||||
edgeGlow: 1,
|
||||
edgeThickness: 4,
|
||||
pulsePeriod: 2,
|
||||
})
|
||||
this.canvasEl.addEventListener('click', this.onSceneClick.bind(this))
|
||||
}
|
||||
|
||||
@@ -68,11 +75,9 @@ export class kfArena{
|
||||
|
||||
render() {
|
||||
TWEEN.update()
|
||||
if(this.resizeRendererToDisplaySize()) {
|
||||
this.camera.aspect = this.renderer.domElement.clientWidth / this.canvasEl.clientHeight
|
||||
this.camera.updateProjectionMatrix()
|
||||
}
|
||||
this.renderer.render(this.scene, this.camera)
|
||||
this.resizeRendererToDisplaySize()
|
||||
if(this.composer) this.composer.render()
|
||||
else this.renderer.render(this.scene, this.camera)
|
||||
requestAnimationFrame(this.render.bind(this))
|
||||
}
|
||||
|
||||
@@ -114,30 +119,31 @@ export class kfArena{
|
||||
|
||||
if (intersects.length > 0) {
|
||||
const hit = this.getNamedParent(intersects[0].object)
|
||||
if(hit) this.onclickAgent(hit.name)
|
||||
if(hit) this.onclickAgent(hit)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addAgent(typeId, aid, properties){
|
||||
addAgent(typeId, aid, properties, values){
|
||||
const agentSprite = this.agentSprites.find(item => item.atp_id==typeId)
|
||||
if(!agentSprite) return
|
||||
const agentObj = this.agentFromJSON(aid, agentSprite.asp_3d)
|
||||
|
||||
agentObj.position.set(properties.position.x, properties.position.z, properties.position.y )
|
||||
|
||||
agentObj.position.set(values.position.x, values.position.z, values.position.y )
|
||||
//TODO Speed vector
|
||||
this.scene.add(agentObj)
|
||||
|
||||
this.agents.push({
|
||||
aid: aid,
|
||||
this.agents[aid] = {
|
||||
type: typeId,
|
||||
props: properties,
|
||||
})
|
||||
values: values,
|
||||
}
|
||||
}
|
||||
|
||||
removeAgent(aid){
|
||||
const obj3d = scene.getObjectByName(aid)
|
||||
this.scene.remove(obj3d)
|
||||
this.agents = this.agents.filter(a => a.aid !== aid)
|
||||
if(aid in this.agents) delete(this.agents[aid])
|
||||
}
|
||||
|
||||
// getAllAgents(){
|
||||
|
||||
Reference in New Issue
Block a user