77 lines
2.3 KiB
JavaScript
77 lines
2.3 KiB
JavaScript
// Learn cc.Class:
|
|
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
|
|
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
|
|
// Learn Attribute:
|
|
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
|
|
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
|
|
// - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
|
|
var _vec3_temp_1 = cc.v3()
|
|
|
|
|
|
cc.Class({
|
|
extends: cc.Camera,
|
|
|
|
properties: {
|
|
// foo: {
|
|
// // ATTRIBUTES:
|
|
// default: null, // The default value will be used only when the component attaching
|
|
// // to a node for the first time
|
|
// type: cc.SpriteFrame, // optional, default is typeof default
|
|
// serializable: true, // optional, default is true
|
|
// },
|
|
// bar: {
|
|
// get () {
|
|
// return this._bar;
|
|
// },
|
|
// set (value) {
|
|
// this._bar = value;
|
|
// }
|
|
// },
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
// onLoad () {},
|
|
|
|
start () {
|
|
this.zangle = 0
|
|
this.node.y = -this.zangle
|
|
},
|
|
beforeDraw(){
|
|
let node = this.node;
|
|
|
|
if (!this._matrixDirty && !node._worldMatDirty)
|
|
return;
|
|
|
|
let camera = this._camera;
|
|
let fov = Math.atan(Math.tan(this._fov/2) / this.zoomRatio)*2;
|
|
camera.setFov(fov);
|
|
|
|
let height = cc.game.canvas.height / cc.view._scaleY;
|
|
|
|
let targetTexture = this._targetTexture;
|
|
if (targetTexture) {
|
|
height = targetTexture.height;
|
|
}
|
|
|
|
node._updateWorldMatrix();
|
|
_vec3_temp_1.x = node._worldMatrix.m12;
|
|
_vec3_temp_1.y = node._worldMatrix.m13+this.zangle;
|
|
_vec3_temp_1.z = 0;
|
|
|
|
node.z = height / 1.155//(Math.tan(this._fov/2) * 2);
|
|
node.lookAt(_vec3_temp_1);
|
|
|
|
this._matrixDirty = false;
|
|
camera.dirty = true;
|
|
//
|
|
//
|
|
|
|
|
|
|
|
},
|
|
// update (dt) {},
|
|
});
|