better preview on pivot, with axes
This commit is contained in:
@@ -40,16 +40,19 @@ export class AgentPreview{
|
||||
}
|
||||
|
||||
setAgent(id){
|
||||
if(this.currentAgentObj && (this.scene.children.includes(this.currentAgentObj))){
|
||||
this.scene.remove(this.currentAgentObj)
|
||||
if(this.pivot && (this.scene.children.includes(this.pivot))){
|
||||
this.scene.remove(this.pivot)
|
||||
}
|
||||
const agentSprite = this.agentSprites.find(item => item.atp_id==id)
|
||||
const agentSprite = this.agentSprites.find(item => item.atp_id==id)
|
||||
if(!agentSprite) return
|
||||
this.currentAgentObj = this.agentFromJSON('previewedAgent', agentSprite.asp_3d)
|
||||
this.currentAgentObj.position.set(0, 0, 0)
|
||||
this.scene.add(this.currentAgentObj)
|
||||
|
||||
this.pivot = this.makePivotAtGeomCenter(this.currentAgentObj, this.scene)
|
||||
this.cameraAutoFrame(this.pivot, this.camera, 1.5)
|
||||
|
||||
this.cameraAutoFrame(this.currentAgentObj, this.camera, 2)
|
||||
// After creating the pivot, so axes do not unbalance the center,
|
||||
// and after cameraFraming so axes we frame on the object, no matter the axes
|
||||
this.currentAgentObj.add(new THREE.AxesHelper(2))
|
||||
}
|
||||
|
||||
set animation(value){
|
||||
@@ -63,9 +66,9 @@ export class AgentPreview{
|
||||
|
||||
_animate = () => { // to avoid having to bind(this) in requestAnimationFrame, because one bound fn per frame = continuous GC load
|
||||
requestAnimationFrame(this._animate)
|
||||
if(this.currentAgentObj && this.animation){
|
||||
this.currentAgentObj.rotation.x += 0.005
|
||||
this.currentAgentObj.rotation.y += 0.01
|
||||
if(this.pivot && this.animation){
|
||||
this.pivot.rotation.x += 0.005
|
||||
this.pivot.rotation.y += 0.01
|
||||
}
|
||||
this.renderer.render(this.scene, this.camera)
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ export class kfArena{
|
||||
this.basePlane.position.y=-0.01 // to avoid artefacts on objets bases
|
||||
this.scene.add(this.basePlane)
|
||||
|
||||
this.axes = new THREE.AxesHelper(this.sceneSize.x/2, this.sceneSize.y/2)
|
||||
this.axes = new THREE.AxesHelper(this.sceneSize.x/2)
|
||||
this.axes.layers.set(2)
|
||||
this.scene.add(this.axes)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user