mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2025-10-09 20:15:23 +00:00
初始化
This commit is contained in:
33
jsb-adapter/engine/scene/camera.js
Normal file
33
jsb-adapter/engine/scene/camera.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 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.
|
||||
****************************************************************************/
|
||||
|
||||
var nativeCameraProto = renderer.Camera.prototype;
|
||||
var _setNode = nativeCameraProto.setNode;
|
||||
cc.js.mixin(nativeCameraProto, {
|
||||
setNode (node) {
|
||||
this._persistentNode = node;
|
||||
_setNode.call(this, node);
|
||||
}
|
||||
});
|
33
jsb-adapter/engine/scene/light.js
Normal file
33
jsb-adapter/engine/scene/light.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 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.
|
||||
****************************************************************************/
|
||||
|
||||
var nativeLightProto = renderer.Light.prototype;
|
||||
var _setNode = nativeLightProto.setNode;
|
||||
cc.js.mixin(nativeLightProto, {
|
||||
setNode (node) {
|
||||
this._node = node;
|
||||
_setNode.call(this, node);
|
||||
}
|
||||
});
|
177
jsb-adapter/engine/scene/mesh-buffer.js
Normal file
177
jsb-adapter/engine/scene/mesh-buffer.js
Normal file
@@ -0,0 +1,177 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
https://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.
|
||||
****************************************************************************/
|
||||
(function(){
|
||||
if (!cc.MeshBuffer) return;
|
||||
let MeshBuffer = cc.MeshBuffer.prototype;
|
||||
|
||||
MeshBuffer.init = function (batcher, vertexFormat) {
|
||||
this.byteOffset = 0;
|
||||
this.indiceOffset = 0;
|
||||
this.vertexOffset = 0;
|
||||
|
||||
this._vertexFormat = vertexFormat;
|
||||
this._vertexBytes = this._vertexFormat._bytes;
|
||||
|
||||
this._vDatas = [];
|
||||
this._uintVDatas = [];
|
||||
this._iDatas = [];
|
||||
this._arrOffset = 0;
|
||||
|
||||
this._vData = null;
|
||||
this._uintVData = null;
|
||||
this._iData = null;
|
||||
|
||||
this._initVDataCount = 256 * vertexFormat._bytes;// actually 256 * 4 * (vertexFormat._bytes / 4)
|
||||
this._initIDataCount = 256 * 6;
|
||||
|
||||
this._offsetInfo = {
|
||||
byteOffset : 0,
|
||||
vertexOffset : 0,
|
||||
indiceOffset : 0
|
||||
};
|
||||
|
||||
this._renderDataList = new renderer.RenderDataList();
|
||||
this._reallocBuffer();
|
||||
};
|
||||
|
||||
MeshBuffer.setNativeAssembler = function(assembler) {
|
||||
if (assembler !== this._nativeAssembler) {
|
||||
this._nativeAssembler = assembler;
|
||||
assembler.setRenderDataList(this._renderDataList);
|
||||
}
|
||||
};
|
||||
|
||||
MeshBuffer._updateVIDatas = function() {
|
||||
let offset = this._arrOffset;
|
||||
this._vDatas[offset] = this._vData;
|
||||
this._uintVDatas[offset] = this._uintVData;
|
||||
this._iDatas[offset] = this._iData;
|
||||
this._renderDataList.updateMesh(offset, this._vData, this._iData);
|
||||
};
|
||||
|
||||
MeshBuffer.getNativeAssembler = function() {
|
||||
return this._nativeAssembler;
|
||||
};
|
||||
|
||||
MeshBuffer.getCurMeshIndex = function() {
|
||||
return this._arrOffset;
|
||||
};
|
||||
|
||||
MeshBuffer.uploadData = function() {};
|
||||
|
||||
MeshBuffer.switchBuffer = function() {
|
||||
let offset = ++this._arrOffset;
|
||||
|
||||
this.byteOffset = 0;
|
||||
this.vertexOffset = 0;
|
||||
this.indiceOffset = 0;
|
||||
|
||||
if (offset < this._vDatas.length) {
|
||||
this._vData = this._vDatas[offset];
|
||||
this._uintVData = this._uintVDatas[offset];
|
||||
this._iData = this._iDatas[offset];
|
||||
} else {
|
||||
this._reallocBuffer();
|
||||
}
|
||||
};
|
||||
|
||||
MeshBuffer.checkAndSwitchBuffer = function(vertexCount) {
|
||||
if (this.vertexOffset + vertexCount > 65535) {
|
||||
this.switchBuffer();
|
||||
if (!this._nativeAssembler) return;
|
||||
this._nativeAssembler.updateIADatas && this._nativeAssembler.updateIADatas(this._arrOffset, this._arrOffset);
|
||||
}
|
||||
};
|
||||
|
||||
MeshBuffer.used = function(vertexCount, indiceCount) {
|
||||
if (!this._nativeAssembler) return;
|
||||
this._nativeAssembler.updateVerticesRange(this._arrOffset, 0, vertexCount);
|
||||
this._nativeAssembler.updateIndicesRange(this._arrOffset, 0, indiceCount);
|
||||
};
|
||||
|
||||
MeshBuffer.request = function(vertexCount, indiceCount) {
|
||||
this.requestStatic(vertexCount, indiceCount);
|
||||
return this._offsetInfo;
|
||||
};
|
||||
|
||||
MeshBuffer._reallocBuffer = function() {
|
||||
this._reallocVData(true);
|
||||
this._reallocIData(true);
|
||||
this._updateVIDatas();
|
||||
};
|
||||
|
||||
MeshBuffer._reallocVData = function(copyOldData) {
|
||||
let oldVData;
|
||||
if (this._vData) {
|
||||
oldVData = new Uint8Array(this._vData.buffer);
|
||||
}
|
||||
|
||||
this._vData = new Float32Array(this._initVDataCount);
|
||||
this._uintVData = new Uint32Array(this._vData.buffer);
|
||||
|
||||
let newData = new Uint8Array(this._uintVData.buffer);
|
||||
|
||||
if (oldVData && copyOldData) {
|
||||
for (let i = 0, l = oldVData.length; i < l; i++) {
|
||||
newData[i] = oldVData[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MeshBuffer._reallocIData = function(copyOldData) {
|
||||
let oldIData = this._iData;
|
||||
|
||||
this._iData = new Uint16Array(this._initIDataCount);
|
||||
|
||||
if (oldIData && copyOldData) {
|
||||
let iData = this._iData;
|
||||
for (let i = 0, l = oldIData.length; i < l; i++) {
|
||||
iData[i] = oldIData[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MeshBuffer.reset = function() {
|
||||
this._arrOffset = 0;
|
||||
this._vData = this._vDatas[0];
|
||||
this._uintVData = this._uintVDatas[0];
|
||||
this._iData = this._iDatas[0];
|
||||
|
||||
this.byteOffset = 0;
|
||||
this.indiceOffset = 0;
|
||||
this.vertexOffset = 0;
|
||||
|
||||
if (!this._nativeAssembler) return;
|
||||
|
||||
for (let i = 0, len = this._vDatas.length; i < len; i++) {
|
||||
this._nativeAssembler.updateVerticesRange(i, 0, 0);
|
||||
this._nativeAssembler.updateIndicesRange(i, 0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
MeshBuffer.destroy = function() {
|
||||
this.reset();
|
||||
};
|
||||
})();
|
126
jsb-adapter/engine/scene/node-proxy.js
Normal file
126
jsb-adapter/engine/scene/node-proxy.js
Normal file
@@ -0,0 +1,126 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 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.
|
||||
****************************************************************************/
|
||||
|
||||
const RenderFlow = cc.RenderFlow;
|
||||
|
||||
cc.js.mixin(renderer.NodeProxy.prototype, {
|
||||
_ctor () {
|
||||
this._owner = null;
|
||||
},
|
||||
|
||||
init (owner) {
|
||||
this._owner = owner;
|
||||
|
||||
let spaceInfo = owner._spaceInfo;
|
||||
this._owner._dirtyPtr = spaceInfo.dirty;
|
||||
|
||||
this._dirtyPtr = spaceInfo.dirty;
|
||||
this._parentPtr = spaceInfo.parent;
|
||||
this._zOrderPtr = spaceInfo.zOrder;
|
||||
this._cullingMaskPtr = spaceInfo.cullingMask;
|
||||
this._opacityPtr = spaceInfo.opacity;
|
||||
this._is3DPtr = spaceInfo.is3D;
|
||||
this._skewPtr = spaceInfo.skew;
|
||||
this._isVisitingTraversal = false;
|
||||
|
||||
owner._proxy = this;
|
||||
this.updateOpacity();
|
||||
this.update3DNode();
|
||||
this.updateZOrder();
|
||||
this.updateCullingMask();
|
||||
this.updateSkew();
|
||||
owner.on(cc.Node.EventType.SIBLING_ORDER_CHANGED, this.updateZOrder, this);
|
||||
},
|
||||
|
||||
initNative () {
|
||||
this.setName(this._owner._name);
|
||||
this.updateParent();
|
||||
this.updateOpacity();
|
||||
this.update3DNode();
|
||||
this.updateZOrder();
|
||||
this.updateSkew();
|
||||
this.updateCullingMask();
|
||||
},
|
||||
|
||||
destroy () {
|
||||
this.destroyImmediately();
|
||||
|
||||
this._owner.off(cc.Node.EventType.SIBLING_ORDER_CHANGED, this.updateZOrder, this);
|
||||
this._owner._proxy = null;
|
||||
this._owner = null;
|
||||
},
|
||||
|
||||
updateParent () {
|
||||
let parent = this._owner._parent;
|
||||
if (parent) {
|
||||
let parentSpaceInfo = parent._spaceInfo;
|
||||
this._parentPtr[0] = parentSpaceInfo.unitID;
|
||||
this._parentPtr[1] = parentSpaceInfo.index;
|
||||
|
||||
let parentDirtyPtr = parentSpaceInfo.dirty;
|
||||
parentDirtyPtr[0] |= RenderFlow.FLAG_REORDER_CHILDREN;
|
||||
this._dirtyPtr[0] |= RenderFlow.FLAG_OPACITY;
|
||||
} else {
|
||||
this._parentPtr[0] = 0xffffffff;
|
||||
this._parentPtr[1] = 0xffffffff;
|
||||
}
|
||||
this.notifyUpdateParent();
|
||||
},
|
||||
|
||||
updateZOrder () {
|
||||
this._zOrderPtr[0] = this._owner._localZOrder;
|
||||
let parent = this._owner._parent;
|
||||
if (parent && parent._proxy) {
|
||||
parent._proxy._dirtyPtr[0] |= RenderFlow.FLAG_REORDER_CHILDREN;
|
||||
}
|
||||
},
|
||||
|
||||
updateCullingMask () {
|
||||
this._cullingMaskPtr[0] = this._owner._cullingMask;
|
||||
},
|
||||
|
||||
updateOpacity () {
|
||||
this._opacityPtr[0] = this._owner.opacity;
|
||||
this._dirtyPtr[0] |= RenderFlow.FLAG_OPACITY;
|
||||
},
|
||||
|
||||
update3DNode () {
|
||||
this._is3DPtr[0] = this._owner.is3DNode ? 0x1 : 0x0;
|
||||
this._dirtyPtr[0] |= RenderFlow.FLAG_LOCAL_TRANSFORM;
|
||||
},
|
||||
|
||||
updateSkew () {
|
||||
let skewPtr = this._skewPtr;
|
||||
let owner = this._owner;
|
||||
let skx = owner._skewX;
|
||||
let sky = owner._skewY;
|
||||
skewPtr[0] = skx;
|
||||
skewPtr[1] = sky;
|
||||
if (!this._isVisitingTraversal && (skx !== 0 || sky !== 0)) {
|
||||
this.switchTraverseToVisit();
|
||||
this._isVisitingTraversal = true;
|
||||
}
|
||||
}
|
||||
});
|
65
jsb-adapter/engine/scene/node.js
Normal file
65
jsb-adapter/engine/scene/node.js
Normal file
@@ -0,0 +1,65 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 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 RenderFlow = cc.RenderFlow;
|
||||
const LOCAL_TRANSFORM = RenderFlow.FLAG_LOCAL_TRANSFORM;
|
||||
const COLOR = RenderFlow.FLAG_COLOR;
|
||||
const UPDATE_RENDER_DATA = RenderFlow.FLAG_UPDATE_RENDER_DATA;
|
||||
|
||||
const POSITION_ON = 1 << 0;
|
||||
|
||||
cc.Node.prototype.setLocalDirty = function (flag) {
|
||||
this._localMatDirty |= flag;
|
||||
this._worldMatDirty = true;
|
||||
this._dirtyPtr[0] |= RenderFlow.FLAG_TRANSFORM;
|
||||
};
|
||||
|
||||
cc.js.getset(cc.Node.prototype, "_renderFlag",
|
||||
function () {
|
||||
return this._dirtyPtr[0];
|
||||
},
|
||||
function (flag) {
|
||||
this._dirtyPtr[0] = flag;
|
||||
if (flag & UPDATE_RENDER_DATA || flag & COLOR) {
|
||||
cc.RenderFlow.register(this);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
cc.PrivateNode.prototype._posDirty = function (sendEvent) {
|
||||
let parent = this.parent;
|
||||
if (parent) {
|
||||
// Position correction for transform calculation
|
||||
this._trs[0] = this._originPos.x - (parent._anchorPoint.x - 0.5) * parent._contentSize.width;
|
||||
this._trs[1] = this._originPos.y - (parent._anchorPoint.y - 0.5) * parent._contentSize.height;
|
||||
}
|
||||
|
||||
this.setLocalDirty(cc.Node._LocalDirtyFlag.POSITION);
|
||||
if (sendEvent === true && (this._eventMask & POSITION_ON)) {
|
||||
this.emit(cc.Node.EventType.POSITION_CHANGED);
|
||||
}
|
||||
};
|
55
jsb-adapter/engine/scene/quad-buffer.js
Normal file
55
jsb-adapter/engine/scene/quad-buffer.js
Normal file
@@ -0,0 +1,55 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
https://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.
|
||||
****************************************************************************/
|
||||
(function(){
|
||||
if (!cc.QuadBuffer) return;
|
||||
let QuadBuffer = cc.QuadBuffer.prototype;
|
||||
|
||||
QuadBuffer._fillQuadBuffer = function () {
|
||||
let count = this._initIDataCount / 6;
|
||||
let buffer = this._iData;
|
||||
for (let i = 0, idx = 0; i < count; i++) {
|
||||
let vertextID = i * 4;
|
||||
buffer[idx++] = vertextID;
|
||||
buffer[idx++] = vertextID+1;
|
||||
buffer[idx++] = vertextID+2;
|
||||
buffer[idx++] = vertextID+1;
|
||||
buffer[idx++] = vertextID+3;
|
||||
buffer[idx++] = vertextID+2;
|
||||
}
|
||||
};
|
||||
|
||||
QuadBuffer._reallocBuffer = function () {
|
||||
this._reallocVData(true);
|
||||
this._reallocIData();
|
||||
this._fillQuadBuffer();
|
||||
this._updateVIDatas();
|
||||
};
|
||||
|
||||
QuadBuffer.uploadData = function () {};
|
||||
|
||||
QuadBuffer.switchBuffer = function () {
|
||||
cc.MeshBuffer.prototype.switchBuffer.call(this);
|
||||
};
|
||||
})();
|
27
jsb-adapter/engine/scene/render-data.js
Normal file
27
jsb-adapter/engine/scene/render-data.js
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
let proto = cc.RenderData.prototype;
|
||||
cc.RenderData.prototype.init = function (assembler) {
|
||||
this._renderDataList = new renderer.RenderDataList();
|
||||
assembler.setRenderDataList(this._renderDataList);
|
||||
this._nativeAssembler = assembler;
|
||||
};
|
||||
|
||||
let originClear = proto.clear;
|
||||
proto.clear = function () {
|
||||
originClear.call(this);
|
||||
this._renderDataList.clear();
|
||||
};
|
||||
|
||||
let originUpdateMesh = proto.updateMesh;
|
||||
proto.updateMesh = function (meshIndex, vertices, indices) {
|
||||
originUpdateMesh.call(this, meshIndex, vertices, indices);
|
||||
|
||||
if (vertices && indices) {
|
||||
this._renderDataList.updateMesh(meshIndex, vertices, indices);
|
||||
}
|
||||
}
|
||||
|
||||
proto.updateMeshRange = function (verticesCount, indicesCount) {
|
||||
this._nativeAssembler.updateVerticesRange(0, 0, verticesCount);
|
||||
this._nativeAssembler.updateIndicesRange(0, 0, indicesCount);
|
||||
}
|
94
jsb-adapter/engine/scene/render-flow.js
Normal file
94
jsb-adapter/engine/scene/render-flow.js
Normal file
@@ -0,0 +1,94 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 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.
|
||||
****************************************************************************/
|
||||
|
||||
let RenderFlow = cc.RenderFlow;
|
||||
|
||||
RenderFlow.FLAG_REORDER_CHILDREN = 1 << 29;
|
||||
RenderFlow.FLAG_WORLD_TRANSFORM_CHANGED = 1 << 30;
|
||||
RenderFlow.FLAG_OPACITY_CHANGED = 1 << 31;
|
||||
|
||||
let _dirtyTargets = [];
|
||||
let _dirtyWaiting = [];
|
||||
let _rendering = false;
|
||||
|
||||
var director = cc.director;
|
||||
RenderFlow.render = function (scene, dt, camera = null) {
|
||||
_rendering = true;
|
||||
|
||||
RenderFlow.validateRenderers();
|
||||
|
||||
for (let i = 0, l = _dirtyTargets.length; i < l; i++) {
|
||||
let node = _dirtyTargets[i];
|
||||
node._inJsbDirtyList = false;
|
||||
|
||||
let comp = node._renderComponent;
|
||||
if (!comp) continue;
|
||||
let assembler = comp._assembler;
|
||||
if (!assembler) continue;
|
||||
|
||||
let flag = node._dirtyPtr[0];
|
||||
|
||||
if (flag & RenderFlow.FLAG_UPDATE_RENDER_DATA) {
|
||||
node._dirtyPtr[0] &= ~RenderFlow.FLAG_UPDATE_RENDER_DATA;
|
||||
assembler._updateRenderData && assembler._updateRenderData();
|
||||
}
|
||||
if (flag & RenderFlow.FLAG_COLOR) {
|
||||
node._dirtyPtr[0] &= ~RenderFlow.FLAG_COLOR;
|
||||
comp._updateColor && comp._updateColor();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_dirtyTargets.length = 0;
|
||||
|
||||
dt = dt || 0;
|
||||
this._nativeFlow.render(scene._proxy, dt, camera);
|
||||
|
||||
_dirtyTargets = _dirtyWaiting.slice(0);
|
||||
_dirtyWaiting.length = 0;
|
||||
|
||||
_rendering = false;
|
||||
};
|
||||
|
||||
RenderFlow.renderCamera = function (camera, scene) {
|
||||
RenderFlow.render(scene, 0, camera);
|
||||
}
|
||||
|
||||
RenderFlow.init = function (nativeFlow) {
|
||||
cc.EventTarget.call(this);
|
||||
this._nativeFlow = nativeFlow;
|
||||
};
|
||||
|
||||
RenderFlow.register = function (target) {
|
||||
if (target._inJsbDirtyList) return;
|
||||
|
||||
if (_rendering) {
|
||||
_dirtyWaiting.push(target);
|
||||
} else {
|
||||
_dirtyTargets.push(target);
|
||||
}
|
||||
|
||||
target._inJsbDirtyList = true;
|
||||
}
|
Reference in New Issue
Block a user