mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
Merge pull request #1 from pandamicro/jsb
Improve jsb renderer implementation
This commit is contained in:
@@ -53,7 +53,6 @@ const ONE_DEGREE = Math.PI / 180;
|
||||
var ActionManagerExist = !!cc.ActionManager;
|
||||
var emptyFunc = function () {};
|
||||
var _mat4_temp = math.mat4.create();
|
||||
var _typedArray_temp = new Float32Array(16);
|
||||
var _vec3_temp = math.vec3.create();
|
||||
var _quat_temp = math.quat.create();
|
||||
var _parents = [];
|
||||
@@ -1886,31 +1885,6 @@ var Node = cc.Class({
|
||||
return out;
|
||||
},
|
||||
|
||||
_getWorldRT4Native() {
|
||||
this.getWorldRT(_mat4_temp);
|
||||
this._mat4ToArray(_typedArray_temp, _mat4_temp);
|
||||
return _typedArray_temp;
|
||||
},
|
||||
|
||||
_mat4ToArray(typedArray, mat4) {
|
||||
typedArray[0] = mat4.m00;
|
||||
typedArray[1] = mat4.m01;
|
||||
typedArray[2] = mat4.m02;
|
||||
typedArray[3] = mat4.m03;
|
||||
typedArray[4] = mat4.m04;
|
||||
typedArray[5] = mat4.m05;
|
||||
typedArray[6] = mat4.m06;
|
||||
typedArray[7] = mat4.m07;
|
||||
typedArray[8] = mat4.m08;
|
||||
typedArray[9] = mat4.m09;
|
||||
typedArray[10] = mat4.m10;
|
||||
typedArray[11] = mat4.m11;
|
||||
typedArray[12] = mat4.m12;
|
||||
typedArray[13] = mat4.m13;
|
||||
typedArray[14] = mat4.m14;
|
||||
typedArray[15] = mat4.m15;
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en Set rotation by lookAt target point, normally used by Camera Node
|
||||
* !#zh 通过观察目标来设置 rotation,一般用于 Camera Node 上
|
||||
@@ -2094,12 +2068,6 @@ var Node = cc.Class({
|
||||
return math.mat4.copy(out, this._worldMatrix);
|
||||
},
|
||||
|
||||
_getWorldMatrix4Native() {
|
||||
this._updateWorldMatrix();
|
||||
this._mat4ToArray(_typedArray_temp, this._worldMatrix);
|
||||
return _typedArray_temp;
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en Converts a Point to node (local) space coordinates. The result is in Vec2.
|
||||
* !#zh 将一个点转换到节点 (局部) 坐标系。结果以 Vec2 为单位。
|
||||
|
||||
+5
-3
@@ -22,7 +22,9 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
const utils = require('./utils');
|
||||
|
||||
// projection
|
||||
renderer.PROJ_PERSPECTIVE = 0;
|
||||
renderer.PROJ_ORTHO = 1;
|
||||
@@ -82,7 +84,7 @@ var fillModelData = function() {
|
||||
model = models[i];
|
||||
modlesData[index++] = model._dynamicIA;
|
||||
modlesData[index++] = model._viewID;
|
||||
worldMatrix = model._node._getWorldRT4Native();
|
||||
worldMatrix = utils.getWorldRTInAB(model._node);
|
||||
modlesData.set(worldMatrix, index);
|
||||
index += 16;
|
||||
|
||||
@@ -103,7 +105,7 @@ var _p;
|
||||
|
||||
_p = renderer.ForwardRenderer.prototype;
|
||||
_p._ctor = function(device, builtin) {
|
||||
this.init(device, builtin.programTemplates, builtin.defaultTexture, canvas.width, canvas.height);
|
||||
this.init(device, builtin.programTemplates, builtin.defaultTexture, canvas.width, canvas.height);
|
||||
};
|
||||
_p.render = function(scene) {
|
||||
fillModelData();
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
'use strict';
|
||||
|
||||
let _typedArray_temp = new Float32Array(16);
|
||||
var _mat4_temp = cc.vmath.mat4.create();
|
||||
|
||||
function _mat4ToArray(typedArray, mat4) {
|
||||
typedArray[0] = mat4.m00;
|
||||
typedArray[1] = mat4.m01;
|
||||
typedArray[2] = mat4.m02;
|
||||
typedArray[3] = mat4.m03;
|
||||
typedArray[4] = mat4.m04;
|
||||
typedArray[5] = mat4.m05;
|
||||
typedArray[6] = mat4.m06;
|
||||
typedArray[7] = mat4.m07;
|
||||
typedArray[8] = mat4.m08;
|
||||
typedArray[9] = mat4.m09;
|
||||
typedArray[10] = mat4.m10;
|
||||
typedArray[11] = mat4.m11;
|
||||
typedArray[12] = mat4.m12;
|
||||
typedArray[13] = mat4.m13;
|
||||
typedArray[14] = mat4.m14;
|
||||
typedArray[15] = mat4.m15;
|
||||
}
|
||||
|
||||
function getWorldRTInAB (node) {
|
||||
node.getWorldRT(_mat4_temp);
|
||||
_mat4ToArray(_typedArray_temp, _mat4_temp);
|
||||
return _typedArray_temp;
|
||||
}
|
||||
|
||||
function getWorldMatrixInAB (node) {
|
||||
node._updateWorldMatrix();
|
||||
_mat4ToArray(_typedArray_temp, node._worldMatrix);
|
||||
return _typedArray_temp;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getWorldRTInAB,
|
||||
getWorldMatrixInAB
|
||||
}
|
||||
Reference in New Issue
Block a user