初始化

This commit is contained in:
SmallMain
2022-06-25 00:23:03 +08:00
commit ef0589e8e5
2264 changed files with 617829 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
cc.Assembler2D.prototype.updateWorldVerts = function(comp) {
let local = this._local;
let verts = this._renderData.vDatas[0];
let vl = local[0],
vr = local[2],
vb = local[1],
vt = local[3];
let floatsPerVert = this.floatsPerVert;
let vertexOffset = 0;
// left bottom
verts[vertexOffset] = vl;
verts[vertexOffset + 1] = vb;
vertexOffset += floatsPerVert;
// right bottom
verts[vertexOffset] = vr;
verts[vertexOffset + 1] = vb;
vertexOffset += floatsPerVert;
// left top
verts[vertexOffset] = vl;
verts[vertexOffset + 1] = vt;
vertexOffset += floatsPerVert;
// right top
verts[vertexOffset] = vr;
verts[vertexOffset + 1] = vt;
};
let _updateColor = cc.Assembler2D.prototype.updateColor;
cc.Assembler2D.prototype.updateColor = function(comp, color) {
this._dirtyPtr[0] |= cc.Assembler.FLAG_VERTICES_OPACITY_CHANGED;
_updateColor.call(this, comp, color);
};

View File

@@ -0,0 +1,35 @@
(function(){
if(!cc.Assembler3D) return;
cc.Assembler3D.updateWorldVerts = function (comp) {
let local = this._local;
let world = this._renderData.vDatas[0];
let vl = local[0], vr = local[2], vb = local[1], vt = local[3];
// left bottom
let floatsPerVert = this.floatsPerVert;
let offset = 0;
world[offset] = vl;
world[offset+1] = vb;
world[offset+2] = 0;
offset += floatsPerVert;
// right bottom
world[offset] = vr;
world[offset+1] = vb;
world[offset+2] = 0;
offset += floatsPerVert;
// left top
world[offset] = vl;
world[offset+1] = vt;
world[offset+2] = 0;
offset += floatsPerVert;
// right top
world[offset] = vr;
world[offset+1] = vt;
world[offset+2] = 0;
}
})()

View File

@@ -0,0 +1,115 @@
/****************************************************************************
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;
let originInit = cc.Assembler.prototype.init;
let FLAG_VERTICES_OPACITY_CHANGED = 1 << 0;
let FLAG_VERTICES_DIRTY = 1 << 1;
let Assembler = {
_ctor () {
this._dirtyPtr = new Uint32Array(1);
this.setDirty(this._dirtyPtr);
this.initVertexFormat();
},
destroy () {
this._renderComp = null;
this._effect = null;
},
clear () {
this._renderData.clear();
},
_extendNative () {
renderer.Assembler.prototype.ctor.call(this);
},
initVertexFormat () {
let vfmt = this.getVfmt();
if (!vfmt) return;
this.setVertexFormat(vfmt._nativeObj);
},
init (renderComp) {
this._effect = [];
originInit.call(this, renderComp);
if (renderComp.node && renderComp.node._proxy) {
renderComp.node._proxy.setAssembler(this);
}
},
_updateRenderData () {
if (!this._renderComp || !this._renderComp.isValid) return;
this.updateRenderData(this._renderComp);
let materials = this._renderComp._materials;
for (let i = 0; i < materials.length; i++) {
let m = materials[i];
// TODO: find why material can be null
if (!m) continue;
m.getHash();
this.updateMaterial(i, m);
}
},
updateRenderData (comp) {
comp._assembler.updateMaterial(0, comp._materials[0]);
},
updateMaterial (iaIndex, material) {
let effect = material && material.effect;
if (this._effect[iaIndex] !== effect) {
this._effect[iaIndex] = effect;
this.updateEffect(iaIndex, effect ? effect._nativeObj : null);
}
},
updateColor(comp, color) {
this._dirtyPtr[0] |= FLAG_VERTICES_OPACITY_CHANGED;
},
updateIADatas (iaIndex, meshIndex) {
// When the MeshBuffer is switched, it is necessary to synchronize the iaData of the native assembler.
this.updateMeshIndex(iaIndex, meshIndex);
let materials = this._renderComp._materials;
let material = materials[iaIndex] || materials[0];
this.updateMaterial(iaIndex, material);
}
};
cc.Assembler.FLAG_VERTICES_OPACITY_CHANGED = FLAG_VERTICES_OPACITY_CHANGED;
cc.Assembler.FLAG_VERTICES_DIRTY = FLAG_VERTICES_DIRTY;
Object.setPrototypeOf(cc.Assembler.prototype, renderer.Assembler.prototype);
cc.js.mixin(cc.Assembler.prototype, Assembler);
module.exports = Assembler;

View File

@@ -0,0 +1,42 @@
let proto = cc.Graphics.__assembler__.prototype;
let _init = proto.init;
proto.init = function (renderComp) {
_init.call(this, renderComp);
this.ignoreOpacityFlag();
}
proto.genBuffer = function (graphics, cverts) {
let buffers = this.getBuffers();
let buffer = buffers[this._bufferOffset];
let meshbuffer = buffer.meshbuffer;
meshbuffer.requestStatic(cverts, cverts*3);
this._buffer = buffer;
meshbuffer.setNativeAssembler(this);
return buffer;
}
let _stroke = proto.stroke;
proto.stroke = function (graphics) {
_stroke.call(this, graphics);
let buffer = this._buffer;
buffer.meshbuffer.used(buffer.vertexStart, buffer.indiceStart);
}
let _fill = proto.fill;
proto.fill = function (graphics) {
_fill.call(this, graphics);
let buffer = this._buffer;
buffer.meshbuffer.used(buffer.vertexStart, buffer.indiceStart);
}
let _updateIADatas = proto.updateIADatas;
proto.updateIADatas = function (iaIndex, meshIndex) {
_updateIADatas.call(this, iaIndex, meshIndex);
// Reset vertexStart and indiceStart when buffer is switched.
this._buffer.vertexStart = 0;
this._buffer.indiceStart = 0;
}

View File

@@ -0,0 +1,37 @@
/****************************************************************************
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 originReserveQuads = cc.Label.__assembler__.Bmfont.prototype._reserveQuads;
Object.assign(cc.Label.__assembler__.Bmfont.prototype, {
updateWorldVerts (comp) {
let local = this._local;
let world = this._renderData.vDatas[0];
let floatsPerVert = this.floatsPerVert;
for (let offset = 0, l = local.length; offset < l; offset += floatsPerVert) {
world[offset] = local[offset];
world[offset + 1] = local[offset + 1];
}
}
});

View File

@@ -0,0 +1,19 @@
(function(){
if(!cc.Label.__assembler__.Bmfont3D) return;
let proto = cc.Label.__assembler__.Bmfont3D.prototype;
Object.assign(proto, {
updateWorldVerts (comp) {
let local = this._local;
let world = this._renderData.vDatas[0];
let floatsPerVert = this.floatsPerVert;
for (let offset = 0, l = world.length; offset < l; offset += floatsPerVert) {
world[offset] = local[offset];
world[offset+1] = local[offset+1];
world[offset+2] = 0;
}
}
})
})()

View File

@@ -0,0 +1,19 @@
(function(){
if(!cc.Label.__assembler__.Letter3D) return;
let proto = cc.Label.__assembler__.Letter3D.prototype;
Object.assign(proto, {
updateWorldVerts (comp) {
let local = this._local;
let world = this._renderData.vDatas[0];
let floatsPerVert = this.floatsPerVert;
for (let offset = 0, l = world.length; offset < l; offset += floatsPerVert) {
world[offset] = local[offset];
world[offset+1] = local[offset+1];
world[offset+2] = 0;
}
}
})
})()

View File

@@ -0,0 +1,9 @@
(function(){
if(!cc.Label.__assembler__.TTF3D) return;
let proto = cc.Label.__assembler__.TTF3D.prototype;
Object.assign(proto, {
updateWorldVerts: cc.Assembler3D.updateWorldVerts
})
})()

View File

@@ -0,0 +1,30 @@
/****************************************************************************
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.
****************************************************************************/
require('./2d/bmfont.js');
require('./3d/bmfont.js');
require('./3d/ttf.js');
require('./3d/letter.js');

View File

@@ -0,0 +1,98 @@
/****************************************************************************
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 Mask = cc.Mask;
const RenderFlow = cc.RenderFlow;
const spriteAssembler = cc.Sprite.__assembler__.Simple.prototype;
const graphicsAssembler = cc.Graphics.__assembler__.prototype;
let proto = cc.Mask.__assembler__.prototype;
let _updateRenderData = proto.updateRenderData;
// Avoid constructor being overridden.
renderer.MaskAssembler.prototype.constructor = cc.Mask.__assembler__;
cc.js.mixin(proto, {
_extendNative () {
renderer.MaskAssembler.prototype.ctor.call(this);
},
initLocal () {
this._local = new Float32Array(4);
renderer.MaskAssembler.prototype.setLocalData.call(this, this._local);
},
updateRenderData (mask) {
_updateRenderData.call(this, mask);
mask._clearGraphics._assembler.updateMaterial(0, mask._clearMaterial);
this.setMaskInverted(mask.inverted);
this.setUseModel(mask._type !== Mask.Type.IMAGE_STENCIL);
this.setImageStencil(mask._type === Mask.Type.IMAGE_STENCIL);
if (mask._graphics) {
mask._graphics._assembler.setUseModel(mask._type !== Mask.Type.IMAGE_STENCIL);
}
mask.node._renderFlag |= cc.RenderFlow.FLAG_UPDATE_RENDER_DATA;
}
}, renderer.MaskAssembler.prototype);
let originCreateGraphics = cc.Mask.prototype._createGraphics;
let originRemoveGraphics = cc.Mask.prototype._removeGraphics;
cc.js.mixin(cc.Mask.prototype, {
_createGraphics () {
originCreateGraphics.call(this);
if (this._graphics) {
this._assembler.setRenderSubHandle(this._graphics._assembler);
}
// TODO: remove clearGraphics
if (!this._clearGraphics) {
this._clearGraphics = new cc.Graphics();
cc.Assembler.init(this._clearGraphics);
this._clearGraphics.node = new cc.Node();
this._clearGraphics._activateMaterial();
this._clearGraphics.lineWidth = 0;
this._clearGraphics.rect(-1, -1, 2, 2);
this._clearGraphics.fill();
this._clearGraphics._assembler.ignoreWorldMatrix();
this._assembler.setClearSubHandle(this._clearGraphics._assembler);
}
},
_removeGraphics () {
originRemoveGraphics.call(this);
// TODO: remove clearGraphics
if (this._clearGraphics) {
this._clearGraphics.destroy();
this._clearGraphics = null;
}
}
})

View File

@@ -0,0 +1,43 @@
(function(){
let Mesh = cc.MeshRenderer;
if (Mesh === undefined) return;
let proto = cc.MeshRenderer.__assembler__.prototype;
let _init = proto.init;
cc.js.mixin(proto, {
initVertexFormat () {},
_extendNative () {
renderer.MeshAssembler.prototype.ctor.call(this);
},
init (comp) {
_init.call(this, comp);
this.updateMeshData(true);
},
setRenderNode (node) {
this.setNode(node._proxy);
},
updateRenderData (comp) {
this.updateMeshData();
comp.node._renderFlag |= cc.RenderFlow.FLAG_UPDATE_RENDER_DATA;
},
updateMeshData (force) {
let comp = this._renderComp;
let mesh = comp.mesh;
if (!mesh || !mesh.loaded) return;
let subdatas = comp.mesh.subDatas;
for(let i = 0, len = subdatas.length; i < len; i++) {
let data = subdatas[i];
if (force || data.vDirty || data.iDirty) {
this.updateIAData(i, data.vfm._nativeObj, data.vData, data.iData);
data.vDirty = false;
data.iDirty = false;
}
}
}
}, renderer.MeshAssembler.prototype);
})();

View File

@@ -0,0 +1,29 @@
let proto = cc.MotionStreak.__assembler__.prototype;
let _init = proto.init;
let _update = proto.update;
cc.js.mixin(proto, {
init (comp) {
_init.call(this, comp);
this.setUseModel(false);
this.ignoreWorldMatrix();
this.ignoreOpacityFlag();
},
update (comp, dt) {
comp.node._updateWorldMatrix();
_update.call(this, comp, dt);
let { iData, usedVertices } = this._renderData._flexBuffer;
let indiceOffset = 0;
for (let i = 0, l = usedVertices; i < l; i += 2) {
iData[indiceOffset++] = i;
iData[indiceOffset++] = i + 2;
iData[indiceOffset++] = i + 1;
iData[indiceOffset++] = i + 1;
iData[indiceOffset++] = i + 2;
iData[indiceOffset++] = i + 3;
}
}
});

View File

@@ -0,0 +1,73 @@
(function(){
let PS = cc.ParticleSystem3D;
if (PS === undefined) return;
let proto = PS.__assembler__.prototype;
let _init = proto.init;
let _updateRenderData = proto.updateRenderData;
cc.js.mixin(proto, {
initVertexFormat () {},
_extendNative () {
renderer.Particle3DAssembler.prototype.ctor.call(this);
},
init (comp) {
_init.call(this, comp);
this._renderDataList = new renderer.RenderDataList();
this.setRenderDataList(this._renderDataList);
this.ignoreOpacityFlag();
this.updateMeshData();
this.setUseModel(true);
},
updateRenderData (comp) {
_updateRenderData.call(this, comp);
if (comp._vertsDirty) {
this.updateMeshData();
comp._vertsDirty = false;
}
},
setRenderNode (node) {
this.setNode(node._proxy);
},
updateMeshData () {
if (!this._model) {
return;
}
let subdatas = this._model._subDatas;
for(let i = 0, len = subdatas.length; i < len; i++) {
let data = subdatas[i];
if (data.vDirty && data.enable) {
this._renderDataList.updateMesh(i, data.vData, data.iData);
}
}
this.setVertexFormat(subdatas[0].vfm._nativeObj);
this.setSimulationSpace(this._particleSystem.simulationSpace);
if (subdatas[1] && subdatas[1].enable) {
this.setTrailVertexFormat(subdatas[1].vfm._nativeObj);
this.setTrailModuleSpace(this._particleSystem.trailModule.space);
}
},
setSimulationSpace (space) {
this.setParticleSpace(space);
},
setTrailModuleSpace (space) {
this.setTrailSpace(space);
},
updateIA (index, count, vDirty, iDirty) {
this.updateIndicesRange(index, 0, count);
}
}, renderer.Particle3DAssembler.prototype);
})();

View File

@@ -0,0 +1,36 @@
/****************************************************************************
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.
****************************************************************************/
Object.assign(cc.Sprite.__assembler__.Mesh.prototype, {
updateWorldVerts (sprite) {
let local = this._local;
let world = this._renderData.vDatas[0];
let floatsPerVert = this.floatsPerVert;
for (let i = 0, l = local.length / 2; i < l; i++) {
world[i*floatsPerVert] = local[i*2];
world[i*floatsPerVert+1] = local[i*2 + 1];
}
},
});

View File

@@ -0,0 +1,37 @@
/****************************************************************************
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.
****************************************************************************/
Object.assign(cc.Sprite.__assembler__.RadialFilled.prototype, {
updateWorldVerts (sprite) {
let local = this._local;
let world = this._renderData.vDatas[0];
let floatsPerVert = this.floatsPerVert;
for (let offset = 0, l = world.length; offset < l; offset += floatsPerVert) {
world[offset] = local[offset];
world[offset+1] = local[offset + 1];
}
},
});

View File

@@ -0,0 +1,39 @@
/****************************************************************************
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 proto = cc.Sprite.__assembler__.Simple.prototype;
let nativeProto = renderer.SimpleSprite2D.prototype;
proto.updateWorldVerts = function(comp) {
this._dirtyPtr[0] |= cc.Assembler.FLAG_VERTICES_DIRTY;
};
proto._extendNative = function () {
nativeProto.ctor.call(this);
};
proto.initLocal = function () {
this._local = new Float32Array(4);
nativeProto.setLocalData.call(this, this._local);
};

View File

@@ -0,0 +1,40 @@
/****************************************************************************
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 proto = cc.Sprite.__assembler__.Sliced.prototype;
let nativeProto = renderer.SlicedSprite2D.prototype;
proto.updateWorldVerts = function(comp) {
this._dirtyPtr[0] |= cc.Assembler.FLAG_VERTICES_DIRTY;
};
proto._extendNative = function () {
nativeProto.ctor.call(this);
};
proto.initLocal = function () {
this._local = new Float32Array(8);
nativeProto.setLocalData.call(this, this._local);
};

View File

@@ -0,0 +1,63 @@
/****************************************************************************
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.
****************************************************************************/
Object.assign(cc.Sprite.__assembler__.Tiled.prototype, {
updateWorldVerts (sprite) {
let renderData = this._renderData;
let local = this._local;
let localX = local.x, localY = local.y;
let world = renderData.vDatas[0];
let { row, col } = this;
let x, x1, y, y1;
let floatsPerVert = this.floatsPerVert;
let vertexOffset = 0;
for (let yindex = 0, ylength = row; yindex < ylength; ++yindex) {
y = localY[yindex];
y1 = localY[yindex + 1];
for (let xindex = 0, xlength = col; xindex < xlength; ++xindex) {
x = localX[xindex];
x1 = localX[xindex + 1];
// lb
world[vertexOffset] = x;
world[vertexOffset + 1] = y;
vertexOffset += floatsPerVert;
// rb
world[vertexOffset] = x1;
world[vertexOffset + 1] = y;
vertexOffset += floatsPerVert;
// lt
world[vertexOffset] = x;
world[vertexOffset + 1] = y1;
vertexOffset += floatsPerVert;
// rt
world[vertexOffset] = x1;
world[vertexOffset + 1] = y1;
vertexOffset += floatsPerVert;
}
}
},
});

View File

@@ -0,0 +1,9 @@
(function(){
if(!cc.Sprite.__assembler__.BarFilled3D) return;
let proto = cc.Sprite.__assembler__.BarFilled3D.prototype;
Object.assign(proto, {
updateWorldVerts: cc.Assembler3D.updateWorldVerts
})
})()

View File

@@ -0,0 +1,20 @@
(function(){
if(!cc.Sprite.__assembler__.Mesh3D) return;
let proto = cc.Sprite.__assembler__.Mesh3D.prototype;
Object.assign(proto, {
updateWorldVerts (sprite) {
let local = this._local;
let world = this._renderData.vDatas[0];
let floatsPerVert = this.floatsPerVert, offset = 0;
for (let i = 0, j = 0, l = local.length/2; i < l; i++, offset += floatsPerVert) {
j = i * 2;
world[offset] = local[j];
world[offset+1] = local[j+1];
world[offset+2] = 0;
}
}
})
})()

View File

@@ -0,0 +1,19 @@
(function(){
if(!cc.Sprite.__assembler__.RadialFilled3D) return;
let proto = cc.Sprite.__assembler__.RadialFilled3D.prototype;
Object.assign(proto, {
updateWorldVerts (sprite) {
let local = this._local;
let world = this._renderData.vDatas[0];
let floatsPerVert = this.floatsPerVert;
for (let offset = 0, l = world.length; offset < l; offset += floatsPerVert) {
world[offset] = local[offset];
world[offset+1] = local[offset+1];
world[offset+2] = 0;
}
}
})
})()

View File

@@ -0,0 +1,10 @@
(function(){
if(!cc.Sprite.__assembler__.Simple3D) return;
let proto = cc.Sprite.__assembler__.Simple3D.prototype;
let nativeProto = renderer.SimpleSprite3D.prototype;
Object.assign(proto, {
_extendNative: nativeProto.ctor
})
})()

View File

@@ -0,0 +1,10 @@
(function(){
if(!cc.Sprite.__assembler__.Sliced3D) return;
let proto = cc.Sprite.__assembler__.Sliced3D.prototype;
let nativeProto = renderer.SlicedSprite3D.prototype;
Object.assign(proto, {
_extendNative: nativeProto.ctor
})
})()

View File

@@ -0,0 +1,49 @@
(function(){
if(!cc.Sprite.__assembler__.Tiled3D) return;
let proto = cc.Sprite.__assembler__.Tiled3D.prototype;
Object.assign(proto, {
updateWorldVerts (sprite) {
let local = this._local;
let localX = local.x, localY = local.y;
let world = this._renderData.vDatas[0];
let { row, col } = this;
let x, x1, y, y1;
let vertexOffset = 0;
for (let yindex = 0, ylength = row; yindex < ylength; ++yindex) {
y = localY[yindex];
y1 = localY[yindex + 1];
for (let xindex = 0, xlength = col; xindex < xlength; ++xindex) {
x = localX[xindex];
x1 = localX[xindex + 1];
// left bottom
let padding = 6;
world[vertexOffset] = x;
world[vertexOffset + 1] = y;
world[vertexOffset + 2] = 0;
vertexOffset += padding;
// right bottom
world[vertexOffset] = x1;
world[vertexOffset + 1] = y;
world[vertexOffset + 2] = 0;
vertexOffset += padding;
// left top
world[vertexOffset] = x;
world[vertexOffset + 1] = y1;
world[vertexOffset + 2] = 0;
vertexOffset += padding;
// right top
world[vertexOffset] = x1;
world[vertexOffset + 1] = y1;
world[vertexOffset + 2] = 0;
vertexOffset += padding;
}
}
}
})
})()

View File

@@ -0,0 +1,37 @@
/****************************************************************************
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.
****************************************************************************/
require('./2d/sliced.js');
require('./2d/tiled.js');
require('./2d/radial-filled.js');
require('./2d/simple.js');
require('./2d/mesh.js');
require('./3d/sliced.js');
require('./3d/simple.js');
require('./3d/tiled.js');
require('./3d/mesh.js');
require('./3d/bar-filled.js');
require('./3d/radial-filled.js');